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

2 lines
2.8 KiB
JavaScript
Raw Normal View History

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