WordPress/wp-includes/js/dist/preferences.min.js

2 lines
7.1 KiB
JavaScript
Raw Normal View History

/*! This file is auto-generated */
!function(){"use strict";var e={n:function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{PreferenceToggleMenuItem:function(){return y},privateApis:function(){return F},store:function(){return h}});var n={};e.r(n),e.d(n,{set:function(){return f},setDefaults:function(){return E},setPersistenceLayer:function(){return _},toggle:function(){return p}});var r={};e.r(r),e.d(r,{get:function(){return v}});var a=window.React,s=window.wp.data,o=window.wp.components,c=window.wp.i18n,l=window.wp.primitives;var i=(0,a.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,a.createElement)(l.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),u=window.wp.a11y;const m=function(e){let t;return(n,r)=>{if("SET_PERSISTENCE_LAYER"===r.type){const{persistenceLayer:e,persistedData:n}=r;return t=e,n}const a=e(n,r);return"SET_PREFERENCE_VALUE"===r.type&&t?.set(a),a}}(((e={},t)=>{if("SET_PREFERENCE_VALUE"===t.type){const{scope:n,name:r,value:a}=t;return{...e,[n]:{...e[n],[r]:a}}}return e}));var d=(0,s.combineReducers)({defaults:function(e={},t){if("SET_PREFERENCE_DEFAULTS"===t.type){const{scope:n,defaults:r}=t;return{...e,[n]:{...e[n],...r}}}return e},preferences:m});function p(e,t){return function({select:n,dispatch:r}){const a=n.get(e,t);r.set(e,t,!a)}}function f(e,t,n){return{type:"SET_PREFERENCE_VALUE",scope:e,name:t,value:n}}function E(e,t){return{type:"SET_PREFERENCE_DEFAULTS",scope:e,defaults:t}}async function _(e){const t=await e.get();return{type:"SET_PERSISTENCE_LAYER",persistenceLayer:e,persistedData:t}}var w=window.wp.deprecated,g=e.n(w);const v=(b=(e,t,n)=>{const r=e.preferences[t]?.[n];return void 0!==r?r:e.defaults[t]?.[n]},(e,t,n)=>["allowRightClickOverrides","distractionFree","editorMode","fixedToolbar","focusMode","hiddenBlockTypes","inactivePanels","keepCaretInsideBlock","mostUsedBlocks","openPanels","showBlockBreadcrumbs","showIconLabels","showListViewByDefault"].includes(n)&&["core/edit-post","core/edit-site"].includes(t)?(g()(`wp.data.select( 'core/preferences' ).get( '${t}', '${n}' )`,{since:"6.5",alternative:`wp.data.select( 'core/preferences' ).get( 'core', '${n}' )`}),b(e,"core",n)):b(e,t,n));var b;const h=(0,s.createReduxStore)("core/preferences",{reducer:d,actions:n,selectors:r});function y({scope:e,name:t,label:n,info:r,messageActivated:l,messageDeactivated:m,shortcut:d,onToggle:p=(()=>null),disabled:f=!1}){const E=(0,s.useSelect)((n=>!!n(h).get(e,t)),[e,t]),{toggle:_}=(0,s.useDispatch)(h);return(0,a.createElement)(o.MenuItem,{icon:E&&i,isSelected:E,onClick:()=>{p(),_(e,t),(()=>{if(E){const e=m||(0,c.sprintf)((0,c.__)("Preference deactivated - %s"),n);(0,u.speak)(e)}else{const e=l||(0,c.sprintf)((0,c.__)("Preference activated - %s"),n);(0,u.speak)(e)}})()},role:"menuitemcheckbox",info:r,shortcut:d,disabled:f},n)}(0,s.register)(h);var P=function({help:e,label:t,isChecked:n,onChange:r,children:s}){return(0,a.createElement)("div",{className:"preference-base-option"},(0,a.createElement)(o.ToggleControl,{__nextHasNoMarginBottom:!0,help:e,label:t,checked:n,onChange:r}),s)};var S=function(e){const{scope:t,featureName:n,onToggle:r=(()=>{}),...o}=e,c=(0,s.useSelect)((e=>!!e(h).get(t,n)),[t,n]),{toggle:l}=(0,s.useDispatch)(h);return(0,a.createElement)(P,{onChange:()=>{r(),l(t,n)},isChecked:c,...o})};var T=({description:e,title:t,children:n})=>(0,a.createElement)("fieldset",{className:"preferences-modal__section"},(0,a.createElement)("legend",{className:"preferences-modal__section-legend"},(0,a.createElement)("h2",{className:"preferences-modal__section-title"},t),e&&(0,a.createElement)("p",{className:"preferences-modal__section-description"},e)),(0,a.createElement)("div",{className:"p