2023-08-11 12:04:29 -04:00
|
|
|
(()=>{"use strict";var e={d:(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:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r: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:()=>y,store:()=>m});var n={};e.r(n),e.d(n,{set:()=>f,setDefaults:()=>w,setPersistenceLayer:()=>g,toggle:()=>l});var r={};e.r(r),e.d(r,{get:()=>S});const s=window.wp.element,o=window.wp.data,c=window.wp.components,i=window.wp.i18n,a=window.wp.primitives,u=(0,s.createElement)(a.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,s.createElement)(a.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),p=window.wp.a11y;const E=function(e){let t;return(n,r)=>{if("SET_PERSISTENCE_LAYER"===r.type){const{persistenceLayer:e,persistedData:n}=r;return t=e,n}const s=e(n,r);return"SET_PREFERENCE_VALUE"===r.type&&t?.set(s),s}}(((e={},t)=>{if("SET_PREFERENCE_VALUE"===t.type){const{scope:n,name:r,value:s}=t;return{...e,[n]:{...e[n],[r]:s}}}return e})),d=(0,o.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:E});function l(e,t){return function({select:n,dispatch:r}){const s=n.get(e,t);r.set(e,t,!s)}}function f(e,t,n){return{type:"SET_PREFERENCE_VALUE",scope:e,name:t,value:n}}function w(e,t){return{type:"SET_PREFERENCE_DEFAULTS",scope:e,defaults:t}}async function g(e){const t=await e.get();return{type:"SET_PERSISTENCE_LAYER",persistenceLayer:e,persistedData:t}}function S(e,t,n){const r=e.preferences[t]?.[n];return void 0!==r?r:e.defaults[t]?.[n]}const m=(0,o.createReduxStore)("core/preferences",{reducer:d,actions:n,selectors:r});function y({scope:e,name:t,label:n,info:r,messageActivated:a,messageDeactivated:E,shortcut:d,onToggle:l=(()=>null),disabled:f=!1}){const w=(0,o.useSelect)((n=>!!n(m).get(e,t)),[e,t]),{toggle:g}=(0,o.useDispatch)(m);return(0,s.createElement)(c.MenuItem,{icon:w&&u,isSelected:w,onClick:()=>{l(),g(e,t),(()=>{if(w){const e=E||(0,i.sprintf)((0,i.__)("Preference deactivated - %s"),n);(0,p.speak)(e)}else{const e=a||(0,i.sprintf)((0,i.__)("Preference activated - %s"),n);(0,p.speak)(e)}})()},role:"menuitemcheckbox",info:r,shortcut:d,disabled:f},n)}(0,o.register)(m),(window.wp=window.wp||{}).preferences=t})();
|