You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

387 lines
11 KiB

1 year ago
  1. /******/ (function() { // webpackBootstrap
  2. /******/ "use strict";
  3. /******/ // The require scope
  4. /******/ var __webpack_require__ = {};
  5. /******/
  6. /************************************************************************/
  7. /******/ /* webpack/runtime/define property getters */
  8. /******/ !function() {
  9. /******/ // define getter functions for harmony exports
  10. /******/ __webpack_require__.d = function(exports, definition) {
  11. /******/ for(var key in definition) {
  12. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  13. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  14. /******/ }
  15. /******/ }
  16. /******/ };
  17. /******/ }();
  18. /******/
  19. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  20. /******/ !function() {
  21. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  22. /******/ }();
  23. /******/
  24. /******/ /* webpack/runtime/make namespace object */
  25. /******/ !function() {
  26. /******/ // define __esModule on exports
  27. /******/ __webpack_require__.r = function(exports) {
  28. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  29. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  30. /******/ }
  31. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  32. /******/ };
  33. /******/ }();
  34. /******/
  35. /************************************************************************/
  36. var __webpack_exports__ = {};
  37. // ESM COMPAT FLAG
  38. __webpack_require__.r(__webpack_exports__);
  39. // EXPORTS
  40. __webpack_require__.d(__webpack_exports__, {
  41. PreferenceToggleMenuItem: function() { return /* reexport */ PreferenceToggleMenuItem; },
  42. store: function() { return /* reexport */ store; }
  43. });
  44. // NAMESPACE OBJECT: ./node_modules/@wordpress/preferences/build-module/store/actions.js
  45. var actions_namespaceObject = {};
  46. __webpack_require__.r(actions_namespaceObject);
  47. __webpack_require__.d(actions_namespaceObject, {
  48. set: function() { return set; },
  49. setDefaults: function() { return setDefaults; },
  50. setPersistenceLayer: function() { return setPersistenceLayer; },
  51. toggle: function() { return toggle; }
  52. });
  53. // NAMESPACE OBJECT: ./node_modules/@wordpress/preferences/build-module/store/selectors.js
  54. var selectors_namespaceObject = {};
  55. __webpack_require__.r(selectors_namespaceObject);
  56. __webpack_require__.d(selectors_namespaceObject, {
  57. get: function() { return get; }
  58. });
  59. ;// CONCATENATED MODULE: external ["wp","element"]
  60. var external_wp_element_namespaceObject = window["wp"]["element"];
  61. ;// CONCATENATED MODULE: external ["wp","data"]
  62. var external_wp_data_namespaceObject = window["wp"]["data"];
  63. ;// CONCATENATED MODULE: external ["wp","components"]
  64. var external_wp_components_namespaceObject = window["wp"]["components"];
  65. ;// CONCATENATED MODULE: external ["wp","i18n"]
  66. var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
  67. ;// CONCATENATED MODULE: external ["wp","primitives"]
  68. var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
  69. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/check.js
  70. /**
  71. * WordPress dependencies
  72. */
  73. const check = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  74. xmlns: "http://www.w3.org/2000/svg",
  75. viewBox: "0 0 24 24"
  76. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  77. d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
  78. }));
  79. /* harmony default export */ var library_check = (check);
  80. ;// CONCATENATED MODULE: external ["wp","a11y"]
  81. var external_wp_a11y_namespaceObject = window["wp"]["a11y"];
  82. ;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/store/reducer.js
  83. /**
  84. * WordPress dependencies
  85. */
  86. /**
  87. * Reducer returning the defaults for user preferences.
  88. *
  89. * This is kept intentionally separate from the preferences
  90. * themselves so that defaults are not persisted.
  91. *
  92. * @param {Object} state Current state.
  93. * @param {Object} action Dispatched action.
  94. *
  95. * @return {Object} Updated state.
  96. */
  97. function defaults(state = {}, action) {
  98. if (action.type === 'SET_PREFERENCE_DEFAULTS') {
  99. const {
  100. scope,
  101. defaults: values
  102. } = action;
  103. return {
  104. ...state,
  105. [scope]: {
  106. ...state[scope],
  107. ...values
  108. }
  109. };
  110. }
  111. return state;
  112. }
  113. /**
  114. * Higher order reducer that does the following:
  115. * - Merges any data from the persistence layer into the state when the
  116. * `SET_PERSISTENCE_LAYER` action is received.
  117. * - Passes any preferences changes to the persistence layer.
  118. *
  119. * @param {Function} reducer The preferences reducer.
  120. *
  121. * @return {Function} The enhanced reducer.
  122. */
  123. function withPersistenceLayer(reducer) {
  124. let persistenceLayer;
  125. return (state, action) => {
  126. // Setup the persistence layer, and return the persisted data
  127. // as the state.
  128. if (action.type === 'SET_PERSISTENCE_LAYER') {
  129. const {
  130. persistenceLayer: persistence,
  131. persistedData
  132. } = action;
  133. persistenceLayer = persistence;
  134. return persistedData;
  135. }
  136. const nextState = reducer(state, action);
  137. if (action.type === 'SET_PREFERENCE_VALUE') {
  138. persistenceLayer?.set(nextState);
  139. }
  140. return nextState;
  141. };
  142. }
  143. /**
  144. * Reducer returning the user preferences.
  145. *
  146. * @param {Object} state Current state.
  147. * @param {Object} action Dispatched action.
  148. *
  149. * @return {Object} Updated state.
  150. */
  151. const preferences = withPersistenceLayer((state = {}, action) => {
  152. if (action.type === 'SET_PREFERENCE_VALUE') {
  153. const {
  154. scope,
  155. name,
  156. value
  157. } = action;
  158. return {
  159. ...state,
  160. [scope]: {
  161. ...state[scope],
  162. [name]: value
  163. }
  164. };
  165. }
  166. return state;
  167. });
  168. /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
  169. defaults,
  170. preferences
  171. }));
  172. ;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/store/actions.js
  173. /**
  174. * Returns an action object used in signalling that a preference should be
  175. * toggled.
  176. *
  177. * @param {string} scope The preference scope (e.g. core/edit-post).
  178. * @param {string} name The preference name.
  179. */
  180. function toggle(scope, name) {
  181. return function ({
  182. select,
  183. dispatch
  184. }) {
  185. const currentValue = select.get(scope, name);
  186. dispatch.set(scope, name, !currentValue);
  187. };
  188. }
  189. /**
  190. * Returns an action object used in signalling that a preference should be set
  191. * to a value
  192. *
  193. * @param {string} scope The preference scope (e.g. core/edit-post).
  194. * @param {string} name The preference name.
  195. * @param {*} value The value to set.
  196. *
  197. * @return {Object} Action object.
  198. */
  199. function set(scope, name, value) {
  200. return {
  201. type: 'SET_PREFERENCE_VALUE',
  202. scope,
  203. name,
  204. value
  205. };
  206. }
  207. /**
  208. * Returns an action object used in signalling that preference defaults should
  209. * be set.
  210. *
  211. * @param {string} scope The preference scope (e.g. core/edit-post).
  212. * @param {Object<string, *>} defaults A key/value map of preference names to values.
  213. *
  214. * @return {Object} Action object.
  215. */
  216. function setDefaults(scope, defaults) {
  217. return {
  218. type: 'SET_PREFERENCE_DEFAULTS',
  219. scope,
  220. defaults
  221. };
  222. }
  223. /** @typedef {() => Promise<Object>} WPPreferencesPersistenceLayerGet */
  224. /** @typedef {(Object) => void} WPPreferencesPersistenceLayerSet */
  225. /**
  226. * @typedef WPPreferencesPersistenceLayer
  227. *
  228. * @property {WPPreferencesPersistenceLayerGet} get An async function that gets data from the persistence layer.
  229. * @property {WPPreferencesPersistenceLayerSet} set A function that sets data in the persistence layer.
  230. */
  231. /**
  232. * Sets the persistence layer.
  233. *
  234. * When a persistence layer is set, the preferences store will:
  235. * - call `get` immediately and update the store state to the value returned.
  236. * - call `set` with all preferences whenever a preference changes value.
  237. *
  238. * `setPersistenceLayer` should ideally be dispatched at the start of an
  239. * application's lifecycle, before any other actions have been dispatched to
  240. * the preferences store.
  241. *
  242. * @param {WPPreferencesPersistenceLayer} persistenceLayer The persistence layer.
  243. *
  244. * @return {Object} Action object.
  245. */
  246. async function setPersistenceLayer(persistenceLayer) {
  247. const persistedData = await persistenceLayer.get();
  248. return {
  249. type: 'SET_PERSISTENCE_LAYER',
  250. persistenceLayer,
  251. persistedData
  252. };
  253. }
  254. ;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/store/selectors.js
  255. /**
  256. * Returns a boolean indicating whether a prefer is active for a particular
  257. * scope.
  258. *
  259. * @param {Object} state The store state.
  260. * @param {string} scope The scope of the feature (e.g. core/edit-post).
  261. * @param {string} name The name of the feature.
  262. *
  263. * @return {*} Is the feature enabled?
  264. */
  265. function get(state, scope, name) {
  266. const value = state.preferences[scope]?.[name];
  267. return value !== undefined ? value : state.defaults[scope]?.[name];
  268. }
  269. ;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/store/constants.js
  270. /**
  271. * The identifier for the data store.
  272. *
  273. * @type {string}
  274. */
  275. const STORE_NAME = 'core/preferences';
  276. ;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/store/index.js
  277. /**
  278. * WordPress dependencies
  279. */
  280. /**
  281. * Internal dependencies
  282. */
  283. /**
  284. * Store definition for the interface namespace.
  285. *
  286. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  287. *
  288. * @type {Object}
  289. */
  290. const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
  291. reducer: reducer,
  292. actions: actions_namespaceObject,
  293. selectors: selectors_namespaceObject
  294. });
  295. (0,external_wp_data_namespaceObject.register)(store);
  296. ;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/components/preference-toggle-menu-item/index.js
  297. /**
  298. * WordPress dependencies
  299. */
  300. /**
  301. * Internal dependencies
  302. */
  303. function PreferenceToggleMenuItem({
  304. scope,
  305. name,
  306. label,
  307. info,
  308. messageActivated,
  309. messageDeactivated,
  310. shortcut,
  311. onToggle = () => null,
  312. disabled = false
  313. }) {
  314. const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(store).get(scope, name), [scope, name]);
  315. const {
  316. toggle
  317. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  318. const speakMessage = () => {
  319. if (isActive) {
  320. const message = messageDeactivated || (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: preference name, e.g. 'Fullscreen mode' */
  321. (0,external_wp_i18n_namespaceObject.__)('Preference deactivated - %s'), label);
  322. (0,external_wp_a11y_namespaceObject.speak)(message);
  323. } else {
  324. const message = messageActivated || (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: preference name, e.g. 'Fullscreen mode' */
  325. (0,external_wp_i18n_namespaceObject.__)('Preference activated - %s'), label);
  326. (0,external_wp_a11y_namespaceObject.speak)(message);
  327. }
  328. };
  329. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  330. icon: isActive && library_check,
  331. isSelected: isActive,
  332. onClick: () => {
  333. onToggle();
  334. toggle(scope, name);
  335. speakMessage();
  336. },
  337. role: "menuitemcheckbox",
  338. info: info,
  339. shortcut: shortcut,
  340. disabled: disabled
  341. }, label);
  342. }
  343. ;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/components/index.js
  344. ;// CONCATENATED MODULE: ./node_modules/@wordpress/preferences/build-module/index.js
  345. (window.wp = window.wp || {}).preferences = __webpack_exports__;
  346. /******/ })()
  347. ;