@wordpress/preferences 3.16.0 → 3.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.17.0 (2023-08-16)
6
+
5
7
  ## 3.16.0 (2023-08-10)
6
8
 
7
9
  ## 3.15.0 (2023-07-20)
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -11,6 +10,5 @@ Object.defineProperty(exports, "PreferenceToggleMenuItem", {
11
10
  return _preferenceToggleMenuItem.default;
12
11
  }
13
12
  });
14
-
15
13
  var _preferenceToggleMenuItem = _interopRequireDefault(require("./preference-toggle-menu-item"));
16
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/preferences/src/components/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA","sourcesContent":["export { default as PreferenceToggleMenuItem } from './preference-toggle-menu-item';\n"]}
1
+ {"version":3,"names":["_preferenceToggleMenuItem","_interopRequireDefault","require"],"sources":["@wordpress/preferences/src/components/index.js"],"sourcesContent":["export { default as PreferenceToggleMenuItem } from './preference-toggle-menu-item';\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,yBAAA,GAAAC,sBAAA,CAAAC,OAAA"}
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = PreferenceToggleMenuItem;
7
-
8
7
  var _element = require("@wordpress/element");
9
-
10
8
  var _data = require("@wordpress/data");
11
-
12
9
  var _components = require("@wordpress/components");
13
-
14
10
  var _i18n = require("@wordpress/i18n");
15
-
16
11
  var _icons = require("@wordpress/icons");
17
-
18
12
  var _a11y = require("@wordpress/a11y");
19
-
20
13
  var _store = require("../../store");
21
-
22
14
  /**
23
15
  * WordPress dependencies
24
16
  */
@@ -26,6 +18,7 @@ var _store = require("../../store");
26
18
  /**
27
19
  * Internal dependencies
28
20
  */
21
+
29
22
  function PreferenceToggleMenuItem({
30
23
  scope,
31
24
  name,
@@ -41,21 +34,17 @@ function PreferenceToggleMenuItem({
41
34
  const {
42
35
  toggle
43
36
  } = (0, _data.useDispatch)(_store.store);
44
-
45
37
  const speakMessage = () => {
46
38
  if (isActive) {
47
- const message = messageDeactivated || (0, _i18n.sprintf)(
48
- /* translators: %s: preference name, e.g. 'Fullscreen mode' */
39
+ const message = messageDeactivated || (0, _i18n.sprintf)( /* translators: %s: preference name, e.g. 'Fullscreen mode' */
49
40
  (0, _i18n.__)('Preference deactivated - %s'), label);
50
41
  (0, _a11y.speak)(message);
51
42
  } else {
52
- const message = messageActivated || (0, _i18n.sprintf)(
53
- /* translators: %s: preference name, e.g. 'Fullscreen mode' */
43
+ const message = messageActivated || (0, _i18n.sprintf)( /* translators: %s: preference name, e.g. 'Fullscreen mode' */
54
44
  (0, _i18n.__)('Preference activated - %s'), label);
55
45
  (0, _a11y.speak)(message);
56
46
  }
57
47
  };
58
-
59
48
  return (0, _element.createElement)(_components.MenuItem, {
60
49
  icon: isActive && _icons.check,
61
50
  isSelected: isActive,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/preferences/src/components/preference-toggle-menu-item/index.js"],"names":["PreferenceToggleMenuItem","scope","name","label","info","messageActivated","messageDeactivated","shortcut","onToggle","disabled","isActive","select","preferencesStore","get","toggle","speakMessage","message","check"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGe,SAASA,wBAAT,CAAmC;AACjDC,EAAAA,KADiD;AAEjDC,EAAAA,IAFiD;AAGjDC,EAAAA,KAHiD;AAIjDC,EAAAA,IAJiD;AAKjDC,EAAAA,gBALiD;AAMjDC,EAAAA,kBANiD;AAOjDC,EAAAA,QAPiD;AAQjDC,EAAAA,QAAQ,GAAG,MAAM,IARgC;AASjDC,EAAAA,QAAQ,GAAG;AATsC,CAAnC,EAUX;AACH,QAAMC,QAAQ,GAAG,qBACdC,MAAF,IAAc,CAAC,CAAEA,MAAM,CAAEC,YAAF,CAAN,CAA2BC,GAA3B,CAAgCZ,KAAhC,EAAuCC,IAAvC,CADD,EAEhB,CAAED,KAAF,EAASC,IAAT,CAFgB,CAAjB;AAIA,QAAM;AAAEY,IAAAA;AAAF,MAAa,uBAAaF,YAAb,CAAnB;;AACA,QAAMG,YAAY,GAAG,MAAM;AAC1B,QAAKL,QAAL,EAAgB;AACf,YAAMM,OAAO,GACZV,kBAAkB,IAClB;AACC;AACA,oBAAI,6BAAJ,CAFD,EAGCH,KAHD,CAFD;AAOA,uBAAOa,OAAP;AACA,KATD,MASO;AACN,YAAMA,OAAO,GACZX,gBAAgB,IAChB;AACC;AACA,oBAAI,2BAAJ,CAFD,EAGCF,KAHD,CAFD;AAOA,uBAAOa,OAAP;AACA;AACD,GApBD;;AAsBA,SACC,4BAAC,oBAAD;AACC,IAAA,IAAI,EAAGN,QAAQ,IAAIO,YADpB;AAEC,IAAA,UAAU,EAAGP,QAFd;AAGC,IAAA,OAAO,EAAG,MAAM;AACfF,MAAAA,QAAQ;AACRM,MAAAA,MAAM,CAAEb,KAAF,EAASC,IAAT,CAAN;AACAa,MAAAA,YAAY;AACZ,KAPF;AAQC,IAAA,IAAI,EAAC,kBARN;AASC,IAAA,IAAI,EAAGX,IATR;AAUC,IAAA,QAAQ,EAAGG,QAVZ;AAWC,IAAA,QAAQ,EAAGE;AAXZ,KAaGN,KAbH,CADD;AAiBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { MenuItem } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { check } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { store as preferencesStore } from '../../store';\n\nexport default function PreferenceToggleMenuItem( {\n\tscope,\n\tname,\n\tlabel,\n\tinfo,\n\tmessageActivated,\n\tmessageDeactivated,\n\tshortcut,\n\tonToggle = () => null,\n\tdisabled = false,\n} ) {\n\tconst isActive = useSelect(\n\t\t( select ) => !! select( preferencesStore ).get( scope, name ),\n\t\t[ scope, name ]\n\t);\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst speakMessage = () => {\n\t\tif ( isActive ) {\n\t\t\tconst message =\n\t\t\t\tmessageDeactivated ||\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: preference name, e.g. 'Fullscreen mode' */\n\t\t\t\t\t__( 'Preference deactivated - %s' ),\n\t\t\t\t\tlabel\n\t\t\t\t);\n\t\t\tspeak( message );\n\t\t} else {\n\t\t\tconst message =\n\t\t\t\tmessageActivated ||\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: preference name, e.g. 'Fullscreen mode' */\n\t\t\t\t\t__( 'Preference activated - %s' ),\n\t\t\t\t\tlabel\n\t\t\t\t);\n\t\t\tspeak( message );\n\t\t}\n\t};\n\n\treturn (\n\t\t<MenuItem\n\t\t\ticon={ isActive && check }\n\t\t\tisSelected={ isActive }\n\t\t\tonClick={ () => {\n\t\t\t\tonToggle();\n\t\t\t\ttoggle( scope, name );\n\t\t\t\tspeakMessage();\n\t\t\t} }\n\t\t\trole=\"menuitemcheckbox\"\n\t\t\tinfo={ info }\n\t\t\tshortcut={ shortcut }\n\t\t\tdisabled={ disabled }\n\t\t>\n\t\t\t{ label }\n\t\t</MenuItem>\n\t);\n}\n"]}
1
+ {"version":3,"names":["_data","require","_components","_i18n","_icons","_a11y","_store","PreferenceToggleMenuItem","scope","name","label","info","messageActivated","messageDeactivated","shortcut","onToggle","disabled","isActive","useSelect","select","preferencesStore","get","toggle","useDispatch","speakMessage","message","sprintf","__","speak","_element","createElement","MenuItem","icon","check","isSelected","onClick","role"],"sources":["@wordpress/preferences/src/components/preference-toggle-menu-item/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { MenuItem } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { check } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { store as preferencesStore } from '../../store';\n\nexport default function PreferenceToggleMenuItem( {\n\tscope,\n\tname,\n\tlabel,\n\tinfo,\n\tmessageActivated,\n\tmessageDeactivated,\n\tshortcut,\n\tonToggle = () => null,\n\tdisabled = false,\n} ) {\n\tconst isActive = useSelect(\n\t\t( select ) => !! select( preferencesStore ).get( scope, name ),\n\t\t[ scope, name ]\n\t);\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst speakMessage = () => {\n\t\tif ( isActive ) {\n\t\t\tconst message =\n\t\t\t\tmessageDeactivated ||\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: preference name, e.g. 'Fullscreen mode' */\n\t\t\t\t\t__( 'Preference deactivated - %s' ),\n\t\t\t\t\tlabel\n\t\t\t\t);\n\t\t\tspeak( message );\n\t\t} else {\n\t\t\tconst message =\n\t\t\t\tmessageActivated ||\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: preference name, e.g. 'Fullscreen mode' */\n\t\t\t\t\t__( 'Preference activated - %s' ),\n\t\t\t\t\tlabel\n\t\t\t\t);\n\t\t\tspeak( message );\n\t\t}\n\t};\n\n\treturn (\n\t\t<MenuItem\n\t\t\ticon={ isActive && check }\n\t\t\tisSelected={ isActive }\n\t\t\tonClick={ () => {\n\t\t\t\tonToggle();\n\t\t\t\ttoggle( scope, name );\n\t\t\t\tspeakMessage();\n\t\t\t} }\n\t\t\trole=\"menuitemcheckbox\"\n\t\t\tinfo={ info }\n\t\t\tshortcut={ shortcut }\n\t\t\tdisabled={ disabled }\n\t\t>\n\t\t\t{ label }\n\t\t</MenuItem>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AAZA;AACA;AACA;;AAOA;AACA;AACA;;AAGe,SAASM,wBAAwBA,CAAE;EACjDC,KAAK;EACLC,IAAI;EACJC,KAAK;EACLC,IAAI;EACJC,gBAAgB;EAChBC,kBAAkB;EAClBC,QAAQ;EACRC,QAAQ,GAAGA,CAAA,KAAM,IAAI;EACrBC,QAAQ,GAAG;AACZ,CAAC,EAAG;EACH,MAAMC,QAAQ,GAAG,IAAAC,eAAS,EACvBC,MAAM,IAAM,CAAC,CAAEA,MAAM,CAAEC,YAAiB,CAAC,CAACC,GAAG,CAAEb,KAAK,EAAEC,IAAK,CAAC,EAC9D,CAAED,KAAK,EAAEC,IAAI,CACd,CAAC;EACD,MAAM;IAAEa;EAAO,CAAC,GAAG,IAAAC,iBAAW,EAAEH,YAAiB,CAAC;EAClD,MAAMI,YAAY,GAAGA,CAAA,KAAM;IAC1B,IAAKP,QAAQ,EAAG;MACf,MAAMQ,OAAO,GACZZ,kBAAkB,IAClB,IAAAa,aAAO,GACN;MACA,IAAAC,QAAE,EAAE,6BAA8B,CAAC,EACnCjB,KACD,CAAC;MACF,IAAAkB,WAAK,EAAEH,OAAQ,CAAC;IACjB,CAAC,MAAM;MACN,MAAMA,OAAO,GACZb,gBAAgB,IAChB,IAAAc,aAAO,GACN;MACA,IAAAC,QAAE,EAAE,2BAA4B,CAAC,EACjCjB,KACD,CAAC;MACF,IAAAkB,WAAK,EAAEH,OAAQ,CAAC;IACjB;EACD,CAAC;EAED,OACC,IAAAI,QAAA,CAAAC,aAAA,EAAC5B,WAAA,CAAA6B,QAAQ;IACRC,IAAI,EAAGf,QAAQ,IAAIgB,YAAO;IAC1BC,UAAU,EAAGjB,QAAU;IACvBkB,OAAO,EAAGA,CAAA,KAAM;MACfpB,QAAQ,CAAC,CAAC;MACVO,MAAM,CAAEd,KAAK,EAAEC,IAAK,CAAC;MACrBe,YAAY,CAAC,CAAC;IACf,CAAG;IACHY,IAAI,EAAC,kBAAkB;IACvBzB,IAAI,EAAGA,IAAM;IACbG,QAAQ,EAAGA,QAAU;IACrBE,QAAQ,EAAGA;EAAU,GAEnBN,KACO,CAAC;AAEb"}
package/build/index.js CHANGED
@@ -12,9 +12,7 @@ Object.defineProperty(exports, "store", {
12
12
  return _store.store;
13
13
  }
14
14
  });
15
-
16
15
  var _components = require("./components");
17
-
18
16
  Object.keys(_components).forEach(function (key) {
19
17
  if (key === "default" || key === "__esModule") return;
20
18
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -26,6 +24,5 @@ Object.keys(_components).forEach(function (key) {
26
24
  }
27
25
  });
28
26
  });
29
-
30
27
  var _store = require("./store");
31
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/preferences/src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA","sourcesContent":["export * from './components';\nexport { store } from './store';\n"]}
1
+ {"version":3,"names":["_components","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_store"],"sources":["@wordpress/preferences/src/index.js"],"sourcesContent":["export * from './components';\nexport { store } from './store';\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,MAAA,GAAAb,OAAA"}
@@ -7,7 +7,6 @@ exports.set = set;
7
7
  exports.setDefaults = setDefaults;
8
8
  exports.setPersistenceLayer = setPersistenceLayer;
9
9
  exports.toggle = toggle;
10
-
11
10
  /**
12
11
  * Returns an action object used in signalling that a preference should be
13
12
  * toggled.
@@ -24,6 +23,7 @@ function toggle(scope, name) {
24
23
  dispatch.set(scope, name, !currentValue);
25
24
  };
26
25
  }
26
+
27
27
  /**
28
28
  * Returns an action object used in signalling that a preference should be set
29
29
  * to a value
@@ -34,8 +34,6 @@ function toggle(scope, name) {
34
34
  *
35
35
  * @return {Object} Action object.
36
36
  */
37
-
38
-
39
37
  function set(scope, name, value) {
40
38
  return {
41
39
  type: 'SET_PREFERENCE_VALUE',
@@ -44,6 +42,7 @@ function set(scope, name, value) {
44
42
  value
45
43
  };
46
44
  }
45
+
47
46
  /**
48
47
  * Returns an action object used in signalling that preference defaults should
49
48
  * be set.
@@ -53,8 +52,6 @@ function set(scope, name, value) {
53
52
  *
54
53
  * @return {Object} Action object.
55
54
  */
56
-
57
-
58
55
  function setDefaults(scope, defaults) {
59
56
  return {
60
57
  type: 'SET_PREFERENCE_DEFAULTS',
@@ -62,10 +59,9 @@ function setDefaults(scope, defaults) {
62
59
  defaults
63
60
  };
64
61
  }
65
- /** @typedef {() => Promise<Object>} WPPreferencesPersistenceLayerGet */
66
62
 
63
+ /** @typedef {() => Promise<Object>} WPPreferencesPersistenceLayerGet */
67
64
  /** @typedef {(Object) => void} WPPreferencesPersistenceLayerSet */
68
-
69
65
  /**
70
66
  * @typedef WPPreferencesPersistenceLayer
71
67
  *
@@ -88,8 +84,6 @@ function setDefaults(scope, defaults) {
88
84
  *
89
85
  * @return {Object} Action object.
90
86
  */
91
-
92
-
93
87
  async function setPersistenceLayer(persistenceLayer) {
94
88
  const persistedData = await persistenceLayer.get();
95
89
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/preferences/src/store/actions.js"],"names":["toggle","scope","name","select","dispatch","currentValue","get","set","value","type","setDefaults","defaults","setPersistenceLayer","persistenceLayer","persistedData"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,MAAT,CAAiBC,KAAjB,EAAwBC,IAAxB,EAA+B;AACrC,SAAO,UAAW;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAX,EAAkC;AACxC,UAAMC,YAAY,GAAGF,MAAM,CAACG,GAAP,CAAYL,KAAZ,EAAmBC,IAAnB,CAArB;AACAE,IAAAA,QAAQ,CAACG,GAAT,CAAcN,KAAd,EAAqBC,IAArB,EAA2B,CAAEG,YAA7B;AACA,GAHD;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,GAAT,CAAcN,KAAd,EAAqBC,IAArB,EAA2BM,KAA3B,EAAmC;AACzC,SAAO;AACNC,IAAAA,IAAI,EAAE,sBADA;AAENR,IAAAA,KAFM;AAGNC,IAAAA,IAHM;AAINM,IAAAA;AAJM,GAAP;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,WAAT,CAAsBT,KAAtB,EAA6BU,QAA7B,EAAwC;AAC9C,SAAO;AACNF,IAAAA,IAAI,EAAE,yBADA;AAENR,IAAAA,KAFM;AAGNU,IAAAA;AAHM,GAAP;AAKA;AAED;;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,eAAeC,mBAAf,CAAoCC,gBAApC,EAAuD;AAC7D,QAAMC,aAAa,GAAG,MAAMD,gBAAgB,CAACP,GAAjB,EAA5B;AACA,SAAO;AACNG,IAAAA,IAAI,EAAE,uBADA;AAENI,IAAAA,gBAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA","sourcesContent":["/**\n * Returns an action object used in signalling that a preference should be\n * toggled.\n *\n * @param {string} scope The preference scope (e.g. core/edit-post).\n * @param {string} name The preference name.\n */\nexport function toggle( scope, name ) {\n\treturn function ( { select, dispatch } ) {\n\t\tconst currentValue = select.get( scope, name );\n\t\tdispatch.set( scope, name, ! currentValue );\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a preference should be set\n * to a value\n *\n * @param {string} scope The preference scope (e.g. core/edit-post).\n * @param {string} name The preference name.\n * @param {*} value The value to set.\n *\n * @return {Object} Action object.\n */\nexport function set( scope, name, value ) {\n\treturn {\n\t\ttype: 'SET_PREFERENCE_VALUE',\n\t\tscope,\n\t\tname,\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that preference defaults should\n * be set.\n *\n * @param {string} scope The preference scope (e.g. core/edit-post).\n * @param {Object<string, *>} defaults A key/value map of preference names to values.\n *\n * @return {Object} Action object.\n */\nexport function setDefaults( scope, defaults ) {\n\treturn {\n\t\ttype: 'SET_PREFERENCE_DEFAULTS',\n\t\tscope,\n\t\tdefaults,\n\t};\n}\n\n/** @typedef {() => Promise<Object>} WPPreferencesPersistenceLayerGet */\n/** @typedef {(Object) => void} WPPreferencesPersistenceLayerSet */\n/**\n * @typedef WPPreferencesPersistenceLayer\n *\n * @property {WPPreferencesPersistenceLayerGet} get An async function that gets data from the persistence layer.\n * @property {WPPreferencesPersistenceLayerSet} set A function that sets data in the persistence layer.\n */\n\n/**\n * Sets the persistence layer.\n *\n * When a persistence layer is set, the preferences store will:\n * - call `get` immediately and update the store state to the value returned.\n * - call `set` with all preferences whenever a preference changes value.\n *\n * `setPersistenceLayer` should ideally be dispatched at the start of an\n * application's lifecycle, before any other actions have been dispatched to\n * the preferences store.\n *\n * @param {WPPreferencesPersistenceLayer} persistenceLayer The persistence layer.\n *\n * @return {Object} Action object.\n */\nexport async function setPersistenceLayer( persistenceLayer ) {\n\tconst persistedData = await persistenceLayer.get();\n\treturn {\n\t\ttype: 'SET_PERSISTENCE_LAYER',\n\t\tpersistenceLayer,\n\t\tpersistedData,\n\t};\n}\n"]}
1
+ {"version":3,"names":["toggle","scope","name","select","dispatch","currentValue","get","set","value","type","setDefaults","defaults","setPersistenceLayer","persistenceLayer","persistedData"],"sources":["@wordpress/preferences/src/store/actions.js"],"sourcesContent":["/**\n * Returns an action object used in signalling that a preference should be\n * toggled.\n *\n * @param {string} scope The preference scope (e.g. core/edit-post).\n * @param {string} name The preference name.\n */\nexport function toggle( scope, name ) {\n\treturn function ( { select, dispatch } ) {\n\t\tconst currentValue = select.get( scope, name );\n\t\tdispatch.set( scope, name, ! currentValue );\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a preference should be set\n * to a value\n *\n * @param {string} scope The preference scope (e.g. core/edit-post).\n * @param {string} name The preference name.\n * @param {*} value The value to set.\n *\n * @return {Object} Action object.\n */\nexport function set( scope, name, value ) {\n\treturn {\n\t\ttype: 'SET_PREFERENCE_VALUE',\n\t\tscope,\n\t\tname,\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that preference defaults should\n * be set.\n *\n * @param {string} scope The preference scope (e.g. core/edit-post).\n * @param {Object<string, *>} defaults A key/value map of preference names to values.\n *\n * @return {Object} Action object.\n */\nexport function setDefaults( scope, defaults ) {\n\treturn {\n\t\ttype: 'SET_PREFERENCE_DEFAULTS',\n\t\tscope,\n\t\tdefaults,\n\t};\n}\n\n/** @typedef {() => Promise<Object>} WPPreferencesPersistenceLayerGet */\n/** @typedef {(Object) => void} WPPreferencesPersistenceLayerSet */\n/**\n * @typedef WPPreferencesPersistenceLayer\n *\n * @property {WPPreferencesPersistenceLayerGet} get An async function that gets data from the persistence layer.\n * @property {WPPreferencesPersistenceLayerSet} set A function that sets data in the persistence layer.\n */\n\n/**\n * Sets the persistence layer.\n *\n * When a persistence layer is set, the preferences store will:\n * - call `get` immediately and update the store state to the value returned.\n * - call `set` with all preferences whenever a preference changes value.\n *\n * `setPersistenceLayer` should ideally be dispatched at the start of an\n * application's lifecycle, before any other actions have been dispatched to\n * the preferences store.\n *\n * @param {WPPreferencesPersistenceLayer} persistenceLayer The persistence layer.\n *\n * @return {Object} Action object.\n */\nexport async function setPersistenceLayer( persistenceLayer ) {\n\tconst persistedData = await persistenceLayer.get();\n\treturn {\n\t\ttype: 'SET_PERSISTENCE_LAYER',\n\t\tpersistenceLayer,\n\t\tpersistedData,\n\t};\n}\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,MAAMA,CAAEC,KAAK,EAAEC,IAAI,EAAG;EACrC,OAAO,UAAW;IAAEC,MAAM;IAAEC;EAAS,CAAC,EAAG;IACxC,MAAMC,YAAY,GAAGF,MAAM,CAACG,GAAG,CAAEL,KAAK,EAAEC,IAAK,CAAC;IAC9CE,QAAQ,CAACG,GAAG,CAAEN,KAAK,EAAEC,IAAI,EAAE,CAAEG,YAAa,CAAC;EAC5C,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,GAAGA,CAAEN,KAAK,EAAEC,IAAI,EAAEM,KAAK,EAAG;EACzC,OAAO;IACNC,IAAI,EAAE,sBAAsB;IAC5BR,KAAK;IACLC,IAAI;IACJM;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,WAAWA,CAAET,KAAK,EAAEU,QAAQ,EAAG;EAC9C,OAAO;IACNF,IAAI,EAAE,yBAAyB;IAC/BR,KAAK;IACLU;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeC,mBAAmBA,CAAEC,gBAAgB,EAAG;EAC7D,MAAMC,aAAa,GAAG,MAAMD,gBAAgB,CAACP,GAAG,CAAC,CAAC;EAClD,OAAO;IACNG,IAAI,EAAE,uBAAuB;IAC7BI,gBAAgB;IAChBC;EACD,CAAC;AACF"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.STORE_NAME = void 0;
7
-
8
7
  /**
9
8
  * The identifier for the data store.
10
9
  *
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/preferences/src/store/constants.js"],"names":["STORE_NAME"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACO,MAAMA,UAAU,GAAG,kBAAnB","sourcesContent":["/**\n * The identifier for the data store.\n *\n * @type {string}\n */\nexport const STORE_NAME = 'core/preferences';\n"]}
1
+ {"version":3,"names":["STORE_NAME","exports"],"sources":["@wordpress/preferences/src/store/constants.js"],"sourcesContent":["/**\n * The identifier for the data store.\n *\n * @type {string}\n */\nexport const STORE_NAME = 'core/preferences';\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACO,MAAMA,UAAU,GAAG,kBAAkB;AAACC,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
@@ -1,26 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.store = void 0;
9
-
10
8
  var _data = require("@wordpress/data");
11
-
12
9
  var _reducer = _interopRequireDefault(require("./reducer"));
13
-
14
10
  var actions = _interopRequireWildcard(require("./actions"));
15
-
16
11
  var selectors = _interopRequireWildcard(require("./selectors"));
17
-
18
12
  var _constants = require("./constants");
19
-
20
13
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
-
22
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
-
24
15
  /**
25
16
  * WordPress dependencies
26
17
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/preferences/src/store/index.js"],"names":["store","STORE_NAME","reducer","actions","selectors"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;;;;;AAXA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,KAAK,GAAG,4BAAkBC,qBAAlB,EAA8B;AAClDC,EAAAA,OAAO,EAAPA,gBADkD;AAElDC,EAAAA,OAFkD;AAGlDC,EAAAA;AAHkD,CAA9B,CAAd;;AAMP,oBAAUJ,KAAV","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport { STORE_NAME } from './constants';\n\n/**\n * Store definition for the interface namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\n"]}
1
+ {"version":3,"names":["_data","require","_reducer","_interopRequireDefault","actions","_interopRequireWildcard","selectors","_constants","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","store","createReduxStore","STORE_NAME","reducer","exports","register"],"sources":["@wordpress/preferences/src/store/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport { STORE_NAME } from './constants';\n\n/**\n * Store definition for the interface namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAD,uBAAA,CAAAJ,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AAAyC,SAAAO,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAJ,wBAAAQ,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA;AAXzC;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMW,KAAK,GAAG,IAAAC,sBAAgB,EAAEC,qBAAU,EAAE;EAClDC,OAAO,EAAPA,gBAAO;EACP7B,OAAO;EACPE;AACD,CAAE,CAAC;AAAC4B,OAAA,CAAAJ,KAAA,GAAAA,KAAA;AAEJ,IAAAK,cAAQ,EAAEL,KAAM,CAAC"}
@@ -6,9 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  exports.defaults = defaults;
8
8
  exports.preferences = void 0;
9
-
10
9
  var _data = require("@wordpress/data");
11
-
12
10
  /**
13
11
  * WordPress dependencies
14
12
  */
@@ -30,15 +28,17 @@ function defaults(state = {}, action) {
30
28
  scope,
31
29
  defaults: values
32
30
  } = action;
33
- return { ...state,
34
- [scope]: { ...state[scope],
31
+ return {
32
+ ...state,
33
+ [scope]: {
34
+ ...state[scope],
35
35
  ...values
36
36
  }
37
37
  };
38
38
  }
39
-
40
39
  return state;
41
40
  }
41
+
42
42
  /**
43
43
  * Higher order reducer that does the following:
44
44
  * - Merges any data from the persistence layer into the state when the
@@ -49,8 +49,6 @@ function defaults(state = {}, action) {
49
49
  *
50
50
  * @return {Function} The enhanced reducer.
51
51
  */
52
-
53
-
54
52
  function withPersistenceLayer(reducer) {
55
53
  let persistenceLayer;
56
54
  return (state, action) => {
@@ -64,16 +62,14 @@ function withPersistenceLayer(reducer) {
64
62
  persistenceLayer = persistence;
65
63
  return persistedData;
66
64
  }
67
-
68
65
  const nextState = reducer(state, action);
69
-
70
66
  if (action.type === 'SET_PREFERENCE_VALUE') {
71
67
  persistenceLayer?.set(nextState);
72
68
  }
73
-
74
69
  return nextState;
75
70
  };
76
71
  }
72
+
77
73
  /**
78
74
  * Reducer returning the user preferences.
79
75
  *
@@ -82,8 +78,6 @@ function withPersistenceLayer(reducer) {
82
78
  *
83
79
  * @return {Object} Updated state.
84
80
  */
85
-
86
-
87
81
  const preferences = withPersistenceLayer((state = {}, action) => {
88
82
  if (action.type === 'SET_PREFERENCE_VALUE') {
89
83
  const {
@@ -91,21 +85,20 @@ const preferences = withPersistenceLayer((state = {}, action) => {
91
85
  name,
92
86
  value
93
87
  } = action;
94
- return { ...state,
95
- [scope]: { ...state[scope],
88
+ return {
89
+ ...state,
90
+ [scope]: {
91
+ ...state[scope],
96
92
  [name]: value
97
93
  }
98
94
  };
99
95
  }
100
-
101
96
  return state;
102
97
  });
103
98
  exports.preferences = preferences;
104
-
105
99
  var _default = (0, _data.combineReducers)({
106
100
  defaults,
107
101
  preferences
108
102
  });
109
-
110
103
  exports.default = _default;
111
104
  //# sourceMappingURL=reducer.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/preferences/src/store/reducer.js"],"names":["defaults","state","action","type","scope","values","withPersistenceLayer","reducer","persistenceLayer","persistence","persistedData","nextState","set","preferences","name","value"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,QAAT,CAAmBC,KAAK,GAAG,EAA3B,EAA+BC,MAA/B,EAAwC;AAC9C,MAAKA,MAAM,CAACC,IAAP,KAAgB,yBAArB,EAAiD;AAChD,UAAM;AAAEC,MAAAA,KAAF;AAASJ,MAAAA,QAAQ,EAAEK;AAAnB,QAA8BH,MAApC;AACA,WAAO,EACN,GAAGD,KADG;AAEN,OAAEG,KAAF,GAAW,EACV,GAAGH,KAAK,CAAEG,KAAF,CADE;AAEV,WAAGC;AAFO;AAFL,KAAP;AAOA;;AAED,SAAOJ,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASK,oBAAT,CAA+BC,OAA/B,EAAyC;AACxC,MAAIC,gBAAJ;AAEA,SAAO,CAAEP,KAAF,EAASC,MAAT,KAAqB;AAC3B;AACA;AACA,QAAKA,MAAM,CAACC,IAAP,KAAgB,uBAArB,EAA+C;AAC9C,YAAM;AAAEK,QAAAA,gBAAgB,EAAEC,WAApB;AAAiCC,QAAAA;AAAjC,UAAmDR,MAAzD;AACAM,MAAAA,gBAAgB,GAAGC,WAAnB;AACA,aAAOC,aAAP;AACA;;AAED,UAAMC,SAAS,GAAGJ,OAAO,CAAEN,KAAF,EAASC,MAAT,CAAzB;;AACA,QAAKA,MAAM,CAACC,IAAP,KAAgB,sBAArB,EAA8C;AAC7CK,MAAAA,gBAAgB,EAAEI,GAAlB,CAAuBD,SAAvB;AACA;;AAED,WAAOA,SAAP;AACA,GAfD;AAgBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAME,WAAW,GAAGP,oBAAoB,CAAE,CAAEL,KAAK,GAAG,EAAV,EAAcC,MAAd,KAA0B;AAC1E,MAAKA,MAAM,CAACC,IAAP,KAAgB,sBAArB,EAA8C;AAC7C,UAAM;AAAEC,MAAAA,KAAF;AAASU,MAAAA,IAAT;AAAeC,MAAAA;AAAf,QAAyBb,MAA/B;AACA,WAAO,EACN,GAAGD,KADG;AAEN,OAAEG,KAAF,GAAW,EACV,GAAGH,KAAK,CAAEG,KAAF,CADE;AAEV,SAAEU,IAAF,GAAUC;AAFA;AAFL,KAAP;AAOA;;AAED,SAAOd,KAAP;AACA,CAb8C,CAAxC;;;eAeQ,2BAAiB;AAC/BD,EAAAA,QAD+B;AAE/Ba,EAAAA;AAF+B,CAAjB,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning the defaults for user preferences.\n *\n * This is kept intentionally separate from the preferences\n * themselves so that defaults are not persisted.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function defaults( state = {}, action ) {\n\tif ( action.type === 'SET_PREFERENCE_DEFAULTS' ) {\n\t\tconst { scope, defaults: values } = action;\n\t\treturn {\n\t\t\t...state,\n\t\t\t[ scope ]: {\n\t\t\t\t...state[ scope ],\n\t\t\t\t...values,\n\t\t\t},\n\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Higher order reducer that does the following:\n * - Merges any data from the persistence layer into the state when the\n * `SET_PERSISTENCE_LAYER` action is received.\n * - Passes any preferences changes to the persistence layer.\n *\n * @param {Function} reducer The preferences reducer.\n *\n * @return {Function} The enhanced reducer.\n */\nfunction withPersistenceLayer( reducer ) {\n\tlet persistenceLayer;\n\n\treturn ( state, action ) => {\n\t\t// Setup the persistence layer, and return the persisted data\n\t\t// as the state.\n\t\tif ( action.type === 'SET_PERSISTENCE_LAYER' ) {\n\t\t\tconst { persistenceLayer: persistence, persistedData } = action;\n\t\t\tpersistenceLayer = persistence;\n\t\t\treturn persistedData;\n\t\t}\n\n\t\tconst nextState = reducer( state, action );\n\t\tif ( action.type === 'SET_PREFERENCE_VALUE' ) {\n\t\t\tpersistenceLayer?.set( nextState );\n\t\t}\n\n\t\treturn nextState;\n\t};\n}\n\n/**\n * Reducer returning the user preferences.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const preferences = withPersistenceLayer( ( state = {}, action ) => {\n\tif ( action.type === 'SET_PREFERENCE_VALUE' ) {\n\t\tconst { scope, name, value } = action;\n\t\treturn {\n\t\t\t...state,\n\t\t\t[ scope ]: {\n\t\t\t\t...state[ scope ],\n\t\t\t\t[ name ]: value,\n\t\t\t},\n\t\t};\n\t}\n\n\treturn state;\n} );\n\nexport default combineReducers( {\n\tdefaults,\n\tpreferences,\n} );\n"]}
1
+ {"version":3,"names":["_data","require","defaults","state","action","type","scope","values","withPersistenceLayer","reducer","persistenceLayer","persistence","persistedData","nextState","set","preferences","name","value","exports","_default","combineReducers","default"],"sources":["@wordpress/preferences/src/store/reducer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning the defaults for user preferences.\n *\n * This is kept intentionally separate from the preferences\n * themselves so that defaults are not persisted.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function defaults( state = {}, action ) {\n\tif ( action.type === 'SET_PREFERENCE_DEFAULTS' ) {\n\t\tconst { scope, defaults: values } = action;\n\t\treturn {\n\t\t\t...state,\n\t\t\t[ scope ]: {\n\t\t\t\t...state[ scope ],\n\t\t\t\t...values,\n\t\t\t},\n\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Higher order reducer that does the following:\n * - Merges any data from the persistence layer into the state when the\n * `SET_PERSISTENCE_LAYER` action is received.\n * - Passes any preferences changes to the persistence layer.\n *\n * @param {Function} reducer The preferences reducer.\n *\n * @return {Function} The enhanced reducer.\n */\nfunction withPersistenceLayer( reducer ) {\n\tlet persistenceLayer;\n\n\treturn ( state, action ) => {\n\t\t// Setup the persistence layer, and return the persisted data\n\t\t// as the state.\n\t\tif ( action.type === 'SET_PERSISTENCE_LAYER' ) {\n\t\t\tconst { persistenceLayer: persistence, persistedData } = action;\n\t\t\tpersistenceLayer = persistence;\n\t\t\treturn persistedData;\n\t\t}\n\n\t\tconst nextState = reducer( state, action );\n\t\tif ( action.type === 'SET_PREFERENCE_VALUE' ) {\n\t\t\tpersistenceLayer?.set( nextState );\n\t\t}\n\n\t\treturn nextState;\n\t};\n}\n\n/**\n * Reducer returning the user preferences.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const preferences = withPersistenceLayer( ( state = {}, action ) => {\n\tif ( action.type === 'SET_PREFERENCE_VALUE' ) {\n\t\tconst { scope, name, value } = action;\n\t\treturn {\n\t\t\t...state,\n\t\t\t[ scope ]: {\n\t\t\t\t...state[ scope ],\n\t\t\t\t[ name ]: value,\n\t\t\t},\n\t\t};\n\t}\n\n\treturn state;\n} );\n\nexport default combineReducers( {\n\tdefaults,\n\tpreferences,\n} );\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,QAAQA,CAAEC,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAG;EAC9C,IAAKA,MAAM,CAACC,IAAI,KAAK,yBAAyB,EAAG;IAChD,MAAM;MAAEC,KAAK;MAAEJ,QAAQ,EAAEK;IAAO,CAAC,GAAGH,MAAM;IAC1C,OAAO;MACN,GAAGD,KAAK;MACR,CAAEG,KAAK,GAAI;QACV,GAAGH,KAAK,CAAEG,KAAK,CAAE;QACjB,GAAGC;MACJ;IACD,CAAC;EACF;EAEA,OAAOJ,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASK,oBAAoBA,CAAEC,OAAO,EAAG;EACxC,IAAIC,gBAAgB;EAEpB,OAAO,CAAEP,KAAK,EAAEC,MAAM,KAAM;IAC3B;IACA;IACA,IAAKA,MAAM,CAACC,IAAI,KAAK,uBAAuB,EAAG;MAC9C,MAAM;QAAEK,gBAAgB,EAAEC,WAAW;QAAEC;MAAc,CAAC,GAAGR,MAAM;MAC/DM,gBAAgB,GAAGC,WAAW;MAC9B,OAAOC,aAAa;IACrB;IAEA,MAAMC,SAAS,GAAGJ,OAAO,CAAEN,KAAK,EAAEC,MAAO,CAAC;IAC1C,IAAKA,MAAM,CAACC,IAAI,KAAK,sBAAsB,EAAG;MAC7CK,gBAAgB,EAAEI,GAAG,CAAED,SAAU,CAAC;IACnC;IAEA,OAAOA,SAAS;EACjB,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,WAAW,GAAGP,oBAAoB,CAAE,CAAEL,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,KAAM;EAC1E,IAAKA,MAAM,CAACC,IAAI,KAAK,sBAAsB,EAAG;IAC7C,MAAM;MAAEC,KAAK;MAAEU,IAAI;MAAEC;IAAM,CAAC,GAAGb,MAAM;IACrC,OAAO;MACN,GAAGD,KAAK;MACR,CAAEG,KAAK,GAAI;QACV,GAAGH,KAAK,CAAEG,KAAK,CAAE;QACjB,CAAEU,IAAI,GAAIC;MACX;IACD,CAAC;EACF;EAEA,OAAOd,KAAK;AACb,CAAE,CAAC;AAACe,OAAA,CAAAH,WAAA,GAAAA,WAAA;AAAA,IAAAI,QAAA,GAEW,IAAAC,qBAAe,EAAE;EAC/BlB,QAAQ;EACRa;AACD,CAAE,CAAC;AAAAG,OAAA,CAAAG,OAAA,GAAAF,QAAA"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.get = get;
7
-
8
7
  /**
9
8
  * Returns a boolean indicating whether a prefer is active for a particular
10
9
  * scope.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/preferences/src/store/selectors.js"],"names":["get","state","scope","name","value","preferences","undefined","defaults"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,GAAT,CAAcC,KAAd,EAAqBC,KAArB,EAA4BC,IAA5B,EAAmC;AACzC,QAAMC,KAAK,GAAGH,KAAK,CAACI,WAAN,CAAmBH,KAAnB,IAA8BC,IAA9B,CAAd;AACA,SAAOC,KAAK,KAAKE,SAAV,GAAsBF,KAAtB,GAA8BH,KAAK,CAACM,QAAN,CAAgBL,KAAhB,IAA2BC,IAA3B,CAArC;AACA","sourcesContent":["/**\n * Returns a boolean indicating whether a prefer is active for a particular\n * scope.\n *\n * @param {Object} state The store state.\n * @param {string} scope The scope of the feature (e.g. core/edit-post).\n * @param {string} name The name of the feature.\n *\n * @return {*} Is the feature enabled?\n */\nexport function get( state, scope, name ) {\n\tconst value = state.preferences[ scope ]?.[ name ];\n\treturn value !== undefined ? value : state.defaults[ scope ]?.[ name ];\n}\n"]}
1
+ {"version":3,"names":["get","state","scope","name","value","preferences","undefined","defaults"],"sources":["@wordpress/preferences/src/store/selectors.js"],"sourcesContent":["/**\n * Returns a boolean indicating whether a prefer is active for a particular\n * scope.\n *\n * @param {Object} state The store state.\n * @param {string} scope The scope of the feature (e.g. core/edit-post).\n * @param {string} name The name of the feature.\n *\n * @return {*} Is the feature enabled?\n */\nexport function get( state, scope, name ) {\n\tconst value = state.preferences[ scope ]?.[ name ];\n\treturn value !== undefined ? value : state.defaults[ scope ]?.[ name ];\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,GAAGA,CAAEC,KAAK,EAAEC,KAAK,EAAEC,IAAI,EAAG;EACzC,MAAMC,KAAK,GAAGH,KAAK,CAACI,WAAW,CAAEH,KAAK,CAAE,GAAIC,IAAI,CAAE;EAClD,OAAOC,KAAK,KAAKE,SAAS,GAAGF,KAAK,GAAGH,KAAK,CAACM,QAAQ,CAAEL,KAAK,CAAE,GAAIC,IAAI,CAAE;AACvE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/preferences/src/components/index.js"],"names":["default","PreferenceToggleMenuItem"],"mappings":"AAAA,SAASA,OAAO,IAAIC,wBAApB,QAAoD,+BAApD","sourcesContent":["export { default as PreferenceToggleMenuItem } from './preference-toggle-menu-item';\n"]}
1
+ {"version":3,"names":["default","PreferenceToggleMenuItem"],"sources":["@wordpress/preferences/src/components/index.js"],"sourcesContent":["export { default as PreferenceToggleMenuItem } from './preference-toggle-menu-item';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,wBAAwB,QAAQ,+BAA+B"}
@@ -1,5 +1,4 @@
1
1
  import { createElement } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * WordPress dependencies
5
4
  */
@@ -8,10 +7,10 @@ import { MenuItem } from '@wordpress/components';
8
7
  import { __, sprintf } from '@wordpress/i18n';
9
8
  import { check } from '@wordpress/icons';
10
9
  import { speak } from '@wordpress/a11y';
10
+
11
11
  /**
12
12
  * Internal dependencies
13
13
  */
14
-
15
14
  import { store as preferencesStore } from '../../store';
16
15
  export default function PreferenceToggleMenuItem({
17
16
  scope,
@@ -28,21 +27,17 @@ export default function PreferenceToggleMenuItem({
28
27
  const {
29
28
  toggle
30
29
  } = useDispatch(preferencesStore);
31
-
32
30
  const speakMessage = () => {
33
31
  if (isActive) {
34
- const message = messageDeactivated || sprintf(
35
- /* translators: %s: preference name, e.g. 'Fullscreen mode' */
32
+ const message = messageDeactivated || sprintf( /* translators: %s: preference name, e.g. 'Fullscreen mode' */
36
33
  __('Preference deactivated - %s'), label);
37
34
  speak(message);
38
35
  } else {
39
- const message = messageActivated || sprintf(
40
- /* translators: %s: preference name, e.g. 'Fullscreen mode' */
36
+ const message = messageActivated || sprintf( /* translators: %s: preference name, e.g. 'Fullscreen mode' */
41
37
  __('Preference activated - %s'), label);
42
38
  speak(message);
43
39
  }
44
40
  };
45
-
46
41
  return createElement(MenuItem, {
47
42
  icon: isActive && check,
48
43
  isSelected: isActive,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/preferences/src/components/preference-toggle-menu-item/index.js"],"names":["useSelect","useDispatch","MenuItem","__","sprintf","check","speak","store","preferencesStore","PreferenceToggleMenuItem","scope","name","label","info","messageActivated","messageDeactivated","shortcut","onToggle","disabled","isActive","select","get","toggle","speakMessage","message"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,QAAT,QAAyB,uBAAzB;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,KAAT,QAAsB,kBAAtB;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,eAAe,SAASC,wBAAT,CAAmC;AACjDC,EAAAA,KADiD;AAEjDC,EAAAA,IAFiD;AAGjDC,EAAAA,KAHiD;AAIjDC,EAAAA,IAJiD;AAKjDC,EAAAA,gBALiD;AAMjDC,EAAAA,kBANiD;AAOjDC,EAAAA,QAPiD;AAQjDC,EAAAA,QAAQ,GAAG,MAAM,IARgC;AASjDC,EAAAA,QAAQ,GAAG;AATsC,CAAnC,EAUX;AACH,QAAMC,QAAQ,GAAGnB,SAAS,CACvBoB,MAAF,IAAc,CAAC,CAAEA,MAAM,CAAEZ,gBAAF,CAAN,CAA2Ba,GAA3B,CAAgCX,KAAhC,EAAuCC,IAAvC,CADQ,EAEzB,CAAED,KAAF,EAASC,IAAT,CAFyB,CAA1B;AAIA,QAAM;AAAEW,IAAAA;AAAF,MAAarB,WAAW,CAAEO,gBAAF,CAA9B;;AACA,QAAMe,YAAY,GAAG,MAAM;AAC1B,QAAKJ,QAAL,EAAgB;AACf,YAAMK,OAAO,GACZT,kBAAkB,IAClBX,OAAO;AACN;AACAD,MAAAA,EAAE,CAAE,6BAAF,CAFI,EAGNS,KAHM,CAFR;AAOAN,MAAAA,KAAK,CAAEkB,OAAF,CAAL;AACA,KATD,MASO;AACN,YAAMA,OAAO,GACZV,gBAAgB,IAChBV,OAAO;AACN;AACAD,MAAAA,EAAE,CAAE,2BAAF,CAFI,EAGNS,KAHM,CAFR;AAOAN,MAAAA,KAAK,CAAEkB,OAAF,CAAL;AACA;AACD,GApBD;;AAsBA,SACC,cAAC,QAAD;AACC,IAAA,IAAI,EAAGL,QAAQ,IAAId,KADpB;AAEC,IAAA,UAAU,EAAGc,QAFd;AAGC,IAAA,OAAO,EAAG,MAAM;AACfF,MAAAA,QAAQ;AACRK,MAAAA,MAAM,CAAEZ,KAAF,EAASC,IAAT,CAAN;AACAY,MAAAA,YAAY;AACZ,KAPF;AAQC,IAAA,IAAI,EAAC,kBARN;AASC,IAAA,IAAI,EAAGV,IATR;AAUC,IAAA,QAAQ,EAAGG,QAVZ;AAWC,IAAA,QAAQ,EAAGE;AAXZ,KAaGN,KAbH,CADD;AAiBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { MenuItem } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { check } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { store as preferencesStore } from '../../store';\n\nexport default function PreferenceToggleMenuItem( {\n\tscope,\n\tname,\n\tlabel,\n\tinfo,\n\tmessageActivated,\n\tmessageDeactivated,\n\tshortcut,\n\tonToggle = () => null,\n\tdisabled = false,\n} ) {\n\tconst isActive = useSelect(\n\t\t( select ) => !! select( preferencesStore ).get( scope, name ),\n\t\t[ scope, name ]\n\t);\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst speakMessage = () => {\n\t\tif ( isActive ) {\n\t\t\tconst message =\n\t\t\t\tmessageDeactivated ||\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: preference name, e.g. 'Fullscreen mode' */\n\t\t\t\t\t__( 'Preference deactivated - %s' ),\n\t\t\t\t\tlabel\n\t\t\t\t);\n\t\t\tspeak( message );\n\t\t} else {\n\t\t\tconst message =\n\t\t\t\tmessageActivated ||\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: preference name, e.g. 'Fullscreen mode' */\n\t\t\t\t\t__( 'Preference activated - %s' ),\n\t\t\t\t\tlabel\n\t\t\t\t);\n\t\t\tspeak( message );\n\t\t}\n\t};\n\n\treturn (\n\t\t<MenuItem\n\t\t\ticon={ isActive && check }\n\t\t\tisSelected={ isActive }\n\t\t\tonClick={ () => {\n\t\t\t\tonToggle();\n\t\t\t\ttoggle( scope, name );\n\t\t\t\tspeakMessage();\n\t\t\t} }\n\t\t\trole=\"menuitemcheckbox\"\n\t\t\tinfo={ info }\n\t\t\tshortcut={ shortcut }\n\t\t\tdisabled={ disabled }\n\t\t>\n\t\t\t{ label }\n\t\t</MenuItem>\n\t);\n}\n"]}
1
+ {"version":3,"names":["useSelect","useDispatch","MenuItem","__","sprintf","check","speak","store","preferencesStore","PreferenceToggleMenuItem","scope","name","label","info","messageActivated","messageDeactivated","shortcut","onToggle","disabled","isActive","select","get","toggle","speakMessage","message","createElement","icon","isSelected","onClick","role"],"sources":["@wordpress/preferences/src/components/preference-toggle-menu-item/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { MenuItem } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { check } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { store as preferencesStore } from '../../store';\n\nexport default function PreferenceToggleMenuItem( {\n\tscope,\n\tname,\n\tlabel,\n\tinfo,\n\tmessageActivated,\n\tmessageDeactivated,\n\tshortcut,\n\tonToggle = () => null,\n\tdisabled = false,\n} ) {\n\tconst isActive = useSelect(\n\t\t( select ) => !! select( preferencesStore ).get( scope, name ),\n\t\t[ scope, name ]\n\t);\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst speakMessage = () => {\n\t\tif ( isActive ) {\n\t\t\tconst message =\n\t\t\t\tmessageDeactivated ||\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: preference name, e.g. 'Fullscreen mode' */\n\t\t\t\t\t__( 'Preference deactivated - %s' ),\n\t\t\t\t\tlabel\n\t\t\t\t);\n\t\t\tspeak( message );\n\t\t} else {\n\t\t\tconst message =\n\t\t\t\tmessageActivated ||\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: preference name, e.g. 'Fullscreen mode' */\n\t\t\t\t\t__( 'Preference activated - %s' ),\n\t\t\t\t\tlabel\n\t\t\t\t);\n\t\t\tspeak( message );\n\t\t}\n\t};\n\n\treturn (\n\t\t<MenuItem\n\t\t\ticon={ isActive && check }\n\t\t\tisSelected={ isActive }\n\t\t\tonClick={ () => {\n\t\t\t\tonToggle();\n\t\t\t\ttoggle( scope, name );\n\t\t\t\tspeakMessage();\n\t\t\t} }\n\t\t\trole=\"menuitemcheckbox\"\n\t\t\tinfo={ info }\n\t\t\tshortcut={ shortcut }\n\t\t\tdisabled={ disabled }\n\t\t>\n\t\t\t{ label }\n\t\t</MenuItem>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,QAAQ,kBAAkB;AACxC,SAASC,KAAK,QAAQ,iBAAiB;;AAEvC;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AAEvD,eAAe,SAASC,wBAAwBA,CAAE;EACjDC,KAAK;EACLC,IAAI;EACJC,KAAK;EACLC,IAAI;EACJC,gBAAgB;EAChBC,kBAAkB;EAClBC,QAAQ;EACRC,QAAQ,GAAGA,CAAA,KAAM,IAAI;EACrBC,QAAQ,GAAG;AACZ,CAAC,EAAG;EACH,MAAMC,QAAQ,GAAGnB,SAAS,CACvBoB,MAAM,IAAM,CAAC,CAAEA,MAAM,CAAEZ,gBAAiB,CAAC,CAACa,GAAG,CAAEX,KAAK,EAAEC,IAAK,CAAC,EAC9D,CAAED,KAAK,EAAEC,IAAI,CACd,CAAC;EACD,MAAM;IAAEW;EAAO,CAAC,GAAGrB,WAAW,CAAEO,gBAAiB,CAAC;EAClD,MAAMe,YAAY,GAAGA,CAAA,KAAM;IAC1B,IAAKJ,QAAQ,EAAG;MACf,MAAMK,OAAO,GACZT,kBAAkB,IAClBX,OAAO,EACN;MACAD,EAAE,CAAE,6BAA8B,CAAC,EACnCS,KACD,CAAC;MACFN,KAAK,CAAEkB,OAAQ,CAAC;IACjB,CAAC,MAAM;MACN,MAAMA,OAAO,GACZV,gBAAgB,IAChBV,OAAO,EACN;MACAD,EAAE,CAAE,2BAA4B,CAAC,EACjCS,KACD,CAAC;MACFN,KAAK,CAAEkB,OAAQ,CAAC;IACjB;EACD,CAAC;EAED,OACCC,aAAA,CAACvB,QAAQ;IACRwB,IAAI,EAAGP,QAAQ,IAAId,KAAO;IAC1BsB,UAAU,EAAGR,QAAU;IACvBS,OAAO,EAAGA,CAAA,KAAM;MACfX,QAAQ,CAAC,CAAC;MACVK,MAAM,CAAEZ,KAAK,EAAEC,IAAK,CAAC;MACrBY,YAAY,CAAC,CAAC;IACf,CAAG;IACHM,IAAI,EAAC,kBAAkB;IACvBhB,IAAI,EAAGA,IAAM;IACbG,QAAQ,EAAGA,QAAU;IACrBE,QAAQ,EAAGA;EAAU,GAEnBN,KACO,CAAC;AAEb"}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/preferences/src/index.js"],"names":["store"],"mappings":"AAAA,cAAc,cAAd;AACA,SAASA,KAAT,QAAsB,SAAtB","sourcesContent":["export * from './components';\nexport { store } from './store';\n"]}
1
+ {"version":3,"names":["store"],"sources":["@wordpress/preferences/src/index.js"],"sourcesContent":["export * from './components';\nexport { store } from './store';\n"],"mappings":"AAAA,cAAc,cAAc;AAC5B,SAASA,KAAK,QAAQ,SAAS"}
@@ -14,6 +14,7 @@ export function toggle(scope, name) {
14
14
  dispatch.set(scope, name, !currentValue);
15
15
  };
16
16
  }
17
+
17
18
  /**
18
19
  * Returns an action object used in signalling that a preference should be set
19
20
  * to a value
@@ -24,7 +25,6 @@ export function toggle(scope, name) {
24
25
  *
25
26
  * @return {Object} Action object.
26
27
  */
27
-
28
28
  export function set(scope, name, value) {
29
29
  return {
30
30
  type: 'SET_PREFERENCE_VALUE',
@@ -33,6 +33,7 @@ export function set(scope, name, value) {
33
33
  value
34
34
  };
35
35
  }
36
+
36
37
  /**
37
38
  * Returns an action object used in signalling that preference defaults should
38
39
  * be set.
@@ -42,7 +43,6 @@ export function set(scope, name, value) {
42
43
  *
43
44
  * @return {Object} Action object.
44
45
  */
45
-
46
46
  export function setDefaults(scope, defaults) {
47
47
  return {
48
48
  type: 'SET_PREFERENCE_DEFAULTS',
@@ -50,10 +50,9 @@ export function setDefaults(scope, defaults) {
50
50
  defaults
51
51
  };
52
52
  }
53
- /** @typedef {() => Promise<Object>} WPPreferencesPersistenceLayerGet */
54
53
 
54
+ /** @typedef {() => Promise<Object>} WPPreferencesPersistenceLayerGet */
55
55
  /** @typedef {(Object) => void} WPPreferencesPersistenceLayerSet */
56
-
57
56
  /**
58
57
  * @typedef WPPreferencesPersistenceLayer
59
58
  *
@@ -76,7 +75,6 @@ export function setDefaults(scope, defaults) {
76
75
  *
77
76
  * @return {Object} Action object.
78
77
  */
79
-
80
78
  export async function setPersistenceLayer(persistenceLayer) {
81
79
  const persistedData = await persistenceLayer.get();
82
80
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/preferences/src/store/actions.js"],"names":["toggle","scope","name","select","dispatch","currentValue","get","set","value","type","setDefaults","defaults","setPersistenceLayer","persistenceLayer","persistedData"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,MAAT,CAAiBC,KAAjB,EAAwBC,IAAxB,EAA+B;AACrC,SAAO,UAAW;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAX,EAAkC;AACxC,UAAMC,YAAY,GAAGF,MAAM,CAACG,GAAP,CAAYL,KAAZ,EAAmBC,IAAnB,CAArB;AACAE,IAAAA,QAAQ,CAACG,GAAT,CAAcN,KAAd,EAAqBC,IAArB,EAA2B,CAAEG,YAA7B;AACA,GAHD;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,GAAT,CAAcN,KAAd,EAAqBC,IAArB,EAA2BM,KAA3B,EAAmC;AACzC,SAAO;AACNC,IAAAA,IAAI,EAAE,sBADA;AAENR,IAAAA,KAFM;AAGNC,IAAAA,IAHM;AAINM,IAAAA;AAJM,GAAP;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,WAAT,CAAsBT,KAAtB,EAA6BU,QAA7B,EAAwC;AAC9C,SAAO;AACNF,IAAAA,IAAI,EAAE,yBADA;AAENR,IAAAA,KAFM;AAGNU,IAAAA;AAHM,GAAP;AAKA;AAED;;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,eAAeC,mBAAf,CAAoCC,gBAApC,EAAuD;AAC7D,QAAMC,aAAa,GAAG,MAAMD,gBAAgB,CAACP,GAAjB,EAA5B;AACA,SAAO;AACNG,IAAAA,IAAI,EAAE,uBADA;AAENI,IAAAA,gBAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA","sourcesContent":["/**\n * Returns an action object used in signalling that a preference should be\n * toggled.\n *\n * @param {string} scope The preference scope (e.g. core/edit-post).\n * @param {string} name The preference name.\n */\nexport function toggle( scope, name ) {\n\treturn function ( { select, dispatch } ) {\n\t\tconst currentValue = select.get( scope, name );\n\t\tdispatch.set( scope, name, ! currentValue );\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a preference should be set\n * to a value\n *\n * @param {string} scope The preference scope (e.g. core/edit-post).\n * @param {string} name The preference name.\n * @param {*} value The value to set.\n *\n * @return {Object} Action object.\n */\nexport function set( scope, name, value ) {\n\treturn {\n\t\ttype: 'SET_PREFERENCE_VALUE',\n\t\tscope,\n\t\tname,\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that preference defaults should\n * be set.\n *\n * @param {string} scope The preference scope (e.g. core/edit-post).\n * @param {Object<string, *>} defaults A key/value map of preference names to values.\n *\n * @return {Object} Action object.\n */\nexport function setDefaults( scope, defaults ) {\n\treturn {\n\t\ttype: 'SET_PREFERENCE_DEFAULTS',\n\t\tscope,\n\t\tdefaults,\n\t};\n}\n\n/** @typedef {() => Promise<Object>} WPPreferencesPersistenceLayerGet */\n/** @typedef {(Object) => void} WPPreferencesPersistenceLayerSet */\n/**\n * @typedef WPPreferencesPersistenceLayer\n *\n * @property {WPPreferencesPersistenceLayerGet} get An async function that gets data from the persistence layer.\n * @property {WPPreferencesPersistenceLayerSet} set A function that sets data in the persistence layer.\n */\n\n/**\n * Sets the persistence layer.\n *\n * When a persistence layer is set, the preferences store will:\n * - call `get` immediately and update the store state to the value returned.\n * - call `set` with all preferences whenever a preference changes value.\n *\n * `setPersistenceLayer` should ideally be dispatched at the start of an\n * application's lifecycle, before any other actions have been dispatched to\n * the preferences store.\n *\n * @param {WPPreferencesPersistenceLayer} persistenceLayer The persistence layer.\n *\n * @return {Object} Action object.\n */\nexport async function setPersistenceLayer( persistenceLayer ) {\n\tconst persistedData = await persistenceLayer.get();\n\treturn {\n\t\ttype: 'SET_PERSISTENCE_LAYER',\n\t\tpersistenceLayer,\n\t\tpersistedData,\n\t};\n}\n"]}
1
+ {"version":3,"names":["toggle","scope","name","select","dispatch","currentValue","get","set","value","type","setDefaults","defaults","setPersistenceLayer","persistenceLayer","persistedData"],"sources":["@wordpress/preferences/src/store/actions.js"],"sourcesContent":["/**\n * Returns an action object used in signalling that a preference should be\n * toggled.\n *\n * @param {string} scope The preference scope (e.g. core/edit-post).\n * @param {string} name The preference name.\n */\nexport function toggle( scope, name ) {\n\treturn function ( { select, dispatch } ) {\n\t\tconst currentValue = select.get( scope, name );\n\t\tdispatch.set( scope, name, ! currentValue );\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a preference should be set\n * to a value\n *\n * @param {string} scope The preference scope (e.g. core/edit-post).\n * @param {string} name The preference name.\n * @param {*} value The value to set.\n *\n * @return {Object} Action object.\n */\nexport function set( scope, name, value ) {\n\treturn {\n\t\ttype: 'SET_PREFERENCE_VALUE',\n\t\tscope,\n\t\tname,\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that preference defaults should\n * be set.\n *\n * @param {string} scope The preference scope (e.g. core/edit-post).\n * @param {Object<string, *>} defaults A key/value map of preference names to values.\n *\n * @return {Object} Action object.\n */\nexport function setDefaults( scope, defaults ) {\n\treturn {\n\t\ttype: 'SET_PREFERENCE_DEFAULTS',\n\t\tscope,\n\t\tdefaults,\n\t};\n}\n\n/** @typedef {() => Promise<Object>} WPPreferencesPersistenceLayerGet */\n/** @typedef {(Object) => void} WPPreferencesPersistenceLayerSet */\n/**\n * @typedef WPPreferencesPersistenceLayer\n *\n * @property {WPPreferencesPersistenceLayerGet} get An async function that gets data from the persistence layer.\n * @property {WPPreferencesPersistenceLayerSet} set A function that sets data in the persistence layer.\n */\n\n/**\n * Sets the persistence layer.\n *\n * When a persistence layer is set, the preferences store will:\n * - call `get` immediately and update the store state to the value returned.\n * - call `set` with all preferences whenever a preference changes value.\n *\n * `setPersistenceLayer` should ideally be dispatched at the start of an\n * application's lifecycle, before any other actions have been dispatched to\n * the preferences store.\n *\n * @param {WPPreferencesPersistenceLayer} persistenceLayer The persistence layer.\n *\n * @return {Object} Action object.\n */\nexport async function setPersistenceLayer( persistenceLayer ) {\n\tconst persistedData = await persistenceLayer.get();\n\treturn {\n\t\ttype: 'SET_PERSISTENCE_LAYER',\n\t\tpersistenceLayer,\n\t\tpersistedData,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,MAAMA,CAAEC,KAAK,EAAEC,IAAI,EAAG;EACrC,OAAO,UAAW;IAAEC,MAAM;IAAEC;EAAS,CAAC,EAAG;IACxC,MAAMC,YAAY,GAAGF,MAAM,CAACG,GAAG,CAAEL,KAAK,EAAEC,IAAK,CAAC;IAC9CE,QAAQ,CAACG,GAAG,CAAEN,KAAK,EAAEC,IAAI,EAAE,CAAEG,YAAa,CAAC;EAC5C,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,GAAGA,CAAEN,KAAK,EAAEC,IAAI,EAAEM,KAAK,EAAG;EACzC,OAAO;IACNC,IAAI,EAAE,sBAAsB;IAC5BR,KAAK;IACLC,IAAI;IACJM;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,WAAWA,CAAET,KAAK,EAAEU,QAAQ,EAAG;EAC9C,OAAO;IACNF,IAAI,EAAE,yBAAyB;IAC/BR,KAAK;IACLU;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,mBAAmBA,CAAEC,gBAAgB,EAAG;EAC7D,MAAMC,aAAa,GAAG,MAAMD,gBAAgB,CAACP,GAAG,CAAC,CAAC;EAClD,OAAO;IACNG,IAAI,EAAE,uBAAuB;IAC7BI,gBAAgB;IAChBC;EACD,CAAC;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/preferences/src/store/constants.js"],"names":["STORE_NAME"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,UAAU,GAAG,kBAAnB","sourcesContent":["/**\n * The identifier for the data store.\n *\n * @type {string}\n */\nexport const STORE_NAME = 'core/preferences';\n"]}
1
+ {"version":3,"names":["STORE_NAME"],"sources":["@wordpress/preferences/src/store/constants.js"],"sourcesContent":["/**\n * The identifier for the data store.\n *\n * @type {string}\n */\nexport const STORE_NAME = 'core/preferences';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,UAAU,GAAG,kBAAkB"}
@@ -2,14 +2,15 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { createReduxStore, register } from '@wordpress/data';
5
+
5
6
  /**
6
7
  * Internal dependencies
7
8
  */
8
-
9
9
  import reducer from './reducer';
10
10
  import * as actions from './actions';
11
11
  import * as selectors from './selectors';
12
12
  import { STORE_NAME } from './constants';
13
+
13
14
  /**
14
15
  * Store definition for the interface namespace.
15
16
  *
@@ -17,7 +18,6 @@ import { STORE_NAME } from './constants';
17
18
  *
18
19
  * @type {Object}
19
20
  */
20
-
21
21
  export const store = createReduxStore(STORE_NAME, {
22
22
  reducer,
23
23
  actions,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/preferences/src/store/index.js"],"names":["createReduxStore","register","reducer","actions","selectors","STORE_NAME","store"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAT,EAA2BC,QAA3B,QAA2C,iBAA3C;AAEA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAO,KAAKC,OAAZ,MAAyB,WAAzB;AACA,OAAO,KAAKC,SAAZ,MAA2B,aAA3B;AACA,SAASC,UAAT,QAA2B,aAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,KAAK,GAAGN,gBAAgB,CAAEK,UAAF,EAAc;AAClDH,EAAAA,OADkD;AAElDC,EAAAA,OAFkD;AAGlDC,EAAAA;AAHkD,CAAd,CAA9B;AAMPH,QAAQ,CAAEK,KAAF,CAAR","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport { STORE_NAME } from './constants';\n\n/**\n * Store definition for the interface namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\n"]}
1
+ {"version":3,"names":["createReduxStore","register","reducer","actions","selectors","STORE_NAME","store"],"sources":["@wordpress/preferences/src/store/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport { STORE_NAME } from './constants';\n\n/**\n * Store definition for the interface namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAgB,EAAEC,QAAQ,QAAQ,iBAAiB;;AAE5D;AACA;AACA;AACA,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAO,KAAKC,OAAO,MAAM,WAAW;AACpC,OAAO,KAAKC,SAAS,MAAM,aAAa;AACxC,SAASC,UAAU,QAAQ,aAAa;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,KAAK,GAAGN,gBAAgB,CAAEK,UAAU,EAAE;EAClDH,OAAO;EACPC,OAAO;EACPC;AACD,CAAE,CAAC;AAEHH,QAAQ,CAAEK,KAAM,CAAC"}
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { combineReducers } from '@wordpress/data';
5
+
5
6
  /**
6
7
  * Reducer returning the defaults for user preferences.
7
8
  *
@@ -13,22 +14,23 @@ import { combineReducers } from '@wordpress/data';
13
14
  *
14
15
  * @return {Object} Updated state.
15
16
  */
16
-
17
17
  export function defaults(state = {}, action) {
18
18
  if (action.type === 'SET_PREFERENCE_DEFAULTS') {
19
19
  const {
20
20
  scope,
21
21
  defaults: values
22
22
  } = action;
23
- return { ...state,
24
- [scope]: { ...state[scope],
23
+ return {
24
+ ...state,
25
+ [scope]: {
26
+ ...state[scope],
25
27
  ...values
26
28
  }
27
29
  };
28
30
  }
29
-
30
31
  return state;
31
32
  }
33
+
32
34
  /**
33
35
  * Higher order reducer that does the following:
34
36
  * - Merges any data from the persistence layer into the state when the
@@ -39,7 +41,6 @@ export function defaults(state = {}, action) {
39
41
  *
40
42
  * @return {Function} The enhanced reducer.
41
43
  */
42
-
43
44
  function withPersistenceLayer(reducer) {
44
45
  let persistenceLayer;
45
46
  return (state, action) => {
@@ -53,16 +54,14 @@ function withPersistenceLayer(reducer) {
53
54
  persistenceLayer = persistence;
54
55
  return persistedData;
55
56
  }
56
-
57
57
  const nextState = reducer(state, action);
58
-
59
58
  if (action.type === 'SET_PREFERENCE_VALUE') {
60
59
  persistenceLayer?.set(nextState);
61
60
  }
62
-
63
61
  return nextState;
64
62
  };
65
63
  }
64
+
66
65
  /**
67
66
  * Reducer returning the user preferences.
68
67
  *
@@ -71,8 +70,6 @@ function withPersistenceLayer(reducer) {
71
70
  *
72
71
  * @return {Object} Updated state.
73
72
  */
74
-
75
-
76
73
  export const preferences = withPersistenceLayer((state = {}, action) => {
77
74
  if (action.type === 'SET_PREFERENCE_VALUE') {
78
75
  const {
@@ -80,13 +77,14 @@ export const preferences = withPersistenceLayer((state = {}, action) => {
80
77
  name,
81
78
  value
82
79
  } = action;
83
- return { ...state,
84
- [scope]: { ...state[scope],
80
+ return {
81
+ ...state,
82
+ [scope]: {
83
+ ...state[scope],
85
84
  [name]: value
86
85
  }
87
86
  };
88
87
  }
89
-
90
88
  return state;
91
89
  });
92
90
  export default combineReducers({
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/preferences/src/store/reducer.js"],"names":["combineReducers","defaults","state","action","type","scope","values","withPersistenceLayer","reducer","persistenceLayer","persistence","persistedData","nextState","set","preferences","name","value"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,iBAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,QAAT,CAAmBC,KAAK,GAAG,EAA3B,EAA+BC,MAA/B,EAAwC;AAC9C,MAAKA,MAAM,CAACC,IAAP,KAAgB,yBAArB,EAAiD;AAChD,UAAM;AAAEC,MAAAA,KAAF;AAASJ,MAAAA,QAAQ,EAAEK;AAAnB,QAA8BH,MAApC;AACA,WAAO,EACN,GAAGD,KADG;AAEN,OAAEG,KAAF,GAAW,EACV,GAAGH,KAAK,CAAEG,KAAF,CADE;AAEV,WAAGC;AAFO;AAFL,KAAP;AAOA;;AAED,SAAOJ,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASK,oBAAT,CAA+BC,OAA/B,EAAyC;AACxC,MAAIC,gBAAJ;AAEA,SAAO,CAAEP,KAAF,EAASC,MAAT,KAAqB;AAC3B;AACA;AACA,QAAKA,MAAM,CAACC,IAAP,KAAgB,uBAArB,EAA+C;AAC9C,YAAM;AAAEK,QAAAA,gBAAgB,EAAEC,WAApB;AAAiCC,QAAAA;AAAjC,UAAmDR,MAAzD;AACAM,MAAAA,gBAAgB,GAAGC,WAAnB;AACA,aAAOC,aAAP;AACA;;AAED,UAAMC,SAAS,GAAGJ,OAAO,CAAEN,KAAF,EAASC,MAAT,CAAzB;;AACA,QAAKA,MAAM,CAACC,IAAP,KAAgB,sBAArB,EAA8C;AAC7CK,MAAAA,gBAAgB,EAAEI,GAAlB,CAAuBD,SAAvB;AACA;;AAED,WAAOA,SAAP;AACA,GAfD;AAgBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAME,WAAW,GAAGP,oBAAoB,CAAE,CAAEL,KAAK,GAAG,EAAV,EAAcC,MAAd,KAA0B;AAC1E,MAAKA,MAAM,CAACC,IAAP,KAAgB,sBAArB,EAA8C;AAC7C,UAAM;AAAEC,MAAAA,KAAF;AAASU,MAAAA,IAAT;AAAeC,MAAAA;AAAf,QAAyBb,MAA/B;AACA,WAAO,EACN,GAAGD,KADG;AAEN,OAAEG,KAAF,GAAW,EACV,GAAGH,KAAK,CAAEG,KAAF,CADE;AAEV,SAAEU,IAAF,GAAUC;AAFA;AAFL,KAAP;AAOA;;AAED,SAAOd,KAAP;AACA,CAb8C,CAAxC;AAeP,eAAeF,eAAe,CAAE;AAC/BC,EAAAA,QAD+B;AAE/Ba,EAAAA;AAF+B,CAAF,CAA9B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning the defaults for user preferences.\n *\n * This is kept intentionally separate from the preferences\n * themselves so that defaults are not persisted.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function defaults( state = {}, action ) {\n\tif ( action.type === 'SET_PREFERENCE_DEFAULTS' ) {\n\t\tconst { scope, defaults: values } = action;\n\t\treturn {\n\t\t\t...state,\n\t\t\t[ scope ]: {\n\t\t\t\t...state[ scope ],\n\t\t\t\t...values,\n\t\t\t},\n\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Higher order reducer that does the following:\n * - Merges any data from the persistence layer into the state when the\n * `SET_PERSISTENCE_LAYER` action is received.\n * - Passes any preferences changes to the persistence layer.\n *\n * @param {Function} reducer The preferences reducer.\n *\n * @return {Function} The enhanced reducer.\n */\nfunction withPersistenceLayer( reducer ) {\n\tlet persistenceLayer;\n\n\treturn ( state, action ) => {\n\t\t// Setup the persistence layer, and return the persisted data\n\t\t// as the state.\n\t\tif ( action.type === 'SET_PERSISTENCE_LAYER' ) {\n\t\t\tconst { persistenceLayer: persistence, persistedData } = action;\n\t\t\tpersistenceLayer = persistence;\n\t\t\treturn persistedData;\n\t\t}\n\n\t\tconst nextState = reducer( state, action );\n\t\tif ( action.type === 'SET_PREFERENCE_VALUE' ) {\n\t\t\tpersistenceLayer?.set( nextState );\n\t\t}\n\n\t\treturn nextState;\n\t};\n}\n\n/**\n * Reducer returning the user preferences.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const preferences = withPersistenceLayer( ( state = {}, action ) => {\n\tif ( action.type === 'SET_PREFERENCE_VALUE' ) {\n\t\tconst { scope, name, value } = action;\n\t\treturn {\n\t\t\t...state,\n\t\t\t[ scope ]: {\n\t\t\t\t...state[ scope ],\n\t\t\t\t[ name ]: value,\n\t\t\t},\n\t\t};\n\t}\n\n\treturn state;\n} );\n\nexport default combineReducers( {\n\tdefaults,\n\tpreferences,\n} );\n"]}
1
+ {"version":3,"names":["combineReducers","defaults","state","action","type","scope","values","withPersistenceLayer","reducer","persistenceLayer","persistence","persistedData","nextState","set","preferences","name","value"],"sources":["@wordpress/preferences/src/store/reducer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning the defaults for user preferences.\n *\n * This is kept intentionally separate from the preferences\n * themselves so that defaults are not persisted.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function defaults( state = {}, action ) {\n\tif ( action.type === 'SET_PREFERENCE_DEFAULTS' ) {\n\t\tconst { scope, defaults: values } = action;\n\t\treturn {\n\t\t\t...state,\n\t\t\t[ scope ]: {\n\t\t\t\t...state[ scope ],\n\t\t\t\t...values,\n\t\t\t},\n\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Higher order reducer that does the following:\n * - Merges any data from the persistence layer into the state when the\n * `SET_PERSISTENCE_LAYER` action is received.\n * - Passes any preferences changes to the persistence layer.\n *\n * @param {Function} reducer The preferences reducer.\n *\n * @return {Function} The enhanced reducer.\n */\nfunction withPersistenceLayer( reducer ) {\n\tlet persistenceLayer;\n\n\treturn ( state, action ) => {\n\t\t// Setup the persistence layer, and return the persisted data\n\t\t// as the state.\n\t\tif ( action.type === 'SET_PERSISTENCE_LAYER' ) {\n\t\t\tconst { persistenceLayer: persistence, persistedData } = action;\n\t\t\tpersistenceLayer = persistence;\n\t\t\treturn persistedData;\n\t\t}\n\n\t\tconst nextState = reducer( state, action );\n\t\tif ( action.type === 'SET_PREFERENCE_VALUE' ) {\n\t\t\tpersistenceLayer?.set( nextState );\n\t\t}\n\n\t\treturn nextState;\n\t};\n}\n\n/**\n * Reducer returning the user preferences.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const preferences = withPersistenceLayer( ( state = {}, action ) => {\n\tif ( action.type === 'SET_PREFERENCE_VALUE' ) {\n\t\tconst { scope, name, value } = action;\n\t\treturn {\n\t\t\t...state,\n\t\t\t[ scope ]: {\n\t\t\t\t...state[ scope ],\n\t\t\t\t[ name ]: value,\n\t\t\t},\n\t\t};\n\t}\n\n\treturn state;\n} );\n\nexport default combineReducers( {\n\tdefaults,\n\tpreferences,\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,iBAAiB;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAAEC,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAG;EAC9C,IAAKA,MAAM,CAACC,IAAI,KAAK,yBAAyB,EAAG;IAChD,MAAM;MAAEC,KAAK;MAAEJ,QAAQ,EAAEK;IAAO,CAAC,GAAGH,MAAM;IAC1C,OAAO;MACN,GAAGD,KAAK;MACR,CAAEG,KAAK,GAAI;QACV,GAAGH,KAAK,CAAEG,KAAK,CAAE;QACjB,GAAGC;MACJ;IACD,CAAC;EACF;EAEA,OAAOJ,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASK,oBAAoBA,CAAEC,OAAO,EAAG;EACxC,IAAIC,gBAAgB;EAEpB,OAAO,CAAEP,KAAK,EAAEC,MAAM,KAAM;IAC3B;IACA;IACA,IAAKA,MAAM,CAACC,IAAI,KAAK,uBAAuB,EAAG;MAC9C,MAAM;QAAEK,gBAAgB,EAAEC,WAAW;QAAEC;MAAc,CAAC,GAAGR,MAAM;MAC/DM,gBAAgB,GAAGC,WAAW;MAC9B,OAAOC,aAAa;IACrB;IAEA,MAAMC,SAAS,GAAGJ,OAAO,CAAEN,KAAK,EAAEC,MAAO,CAAC;IAC1C,IAAKA,MAAM,CAACC,IAAI,KAAK,sBAAsB,EAAG;MAC7CK,gBAAgB,EAAEI,GAAG,CAAED,SAAU,CAAC;IACnC;IAEA,OAAOA,SAAS;EACjB,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,WAAW,GAAGP,oBAAoB,CAAE,CAAEL,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,KAAM;EAC1E,IAAKA,MAAM,CAACC,IAAI,KAAK,sBAAsB,EAAG;IAC7C,MAAM;MAAEC,KAAK;MAAEU,IAAI;MAAEC;IAAM,CAAC,GAAGb,MAAM;IACrC,OAAO;MACN,GAAGD,KAAK;MACR,CAAEG,KAAK,GAAI;QACV,GAAGH,KAAK,CAAEG,KAAK,CAAE;QACjB,CAAEU,IAAI,GAAIC;MACX;IACD,CAAC;EACF;EAEA,OAAOd,KAAK;AACb,CAAE,CAAC;AAEH,eAAeF,eAAe,CAAE;EAC/BC,QAAQ;EACRa;AACD,CAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/preferences/src/store/selectors.js"],"names":["get","state","scope","name","value","preferences","undefined","defaults"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,GAAT,CAAcC,KAAd,EAAqBC,KAArB,EAA4BC,IAA5B,EAAmC;AACzC,QAAMC,KAAK,GAAGH,KAAK,CAACI,WAAN,CAAmBH,KAAnB,IAA8BC,IAA9B,CAAd;AACA,SAAOC,KAAK,KAAKE,SAAV,GAAsBF,KAAtB,GAA8BH,KAAK,CAACM,QAAN,CAAgBL,KAAhB,IAA2BC,IAA3B,CAArC;AACA","sourcesContent":["/**\n * Returns a boolean indicating whether a prefer is active for a particular\n * scope.\n *\n * @param {Object} state The store state.\n * @param {string} scope The scope of the feature (e.g. core/edit-post).\n * @param {string} name The name of the feature.\n *\n * @return {*} Is the feature enabled?\n */\nexport function get( state, scope, name ) {\n\tconst value = state.preferences[ scope ]?.[ name ];\n\treturn value !== undefined ? value : state.defaults[ scope ]?.[ name ];\n}\n"]}
1
+ {"version":3,"names":["get","state","scope","name","value","preferences","undefined","defaults"],"sources":["@wordpress/preferences/src/store/selectors.js"],"sourcesContent":["/**\n * Returns a boolean indicating whether a prefer is active for a particular\n * scope.\n *\n * @param {Object} state The store state.\n * @param {string} scope The scope of the feature (e.g. core/edit-post).\n * @param {string} name The name of the feature.\n *\n * @return {*} Is the feature enabled?\n */\nexport function get( state, scope, name ) {\n\tconst value = state.preferences[ scope ]?.[ name ];\n\treturn value !== undefined ? value : state.defaults[ scope ]?.[ name ];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,GAAGA,CAAEC,KAAK,EAAEC,KAAK,EAAEC,IAAI,EAAG;EACzC,MAAMC,KAAK,GAAGH,KAAK,CAACI,WAAW,CAAEH,KAAK,CAAE,GAAIC,IAAI,CAAE;EAClD,OAAOC,KAAK,KAAKE,SAAS,GAAGF,KAAK,GAAGH,KAAK,CAACM,QAAQ,CAAEL,KAAK,CAAE,GAAIC,IAAI,CAAE;AACvE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/preferences",
3
- "version": "3.16.0",
3
+ "version": "3.17.0",
4
4
  "description": "Utilities for managing WordPress preferences.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -29,11 +29,12 @@
29
29
  "sideEffects": false,
30
30
  "dependencies": {
31
31
  "@babel/runtime": "^7.16.0",
32
- "@wordpress/a11y": "^3.39.0",
33
- "@wordpress/components": "^25.5.0",
34
- "@wordpress/data": "^9.9.0",
35
- "@wordpress/i18n": "^4.39.0",
36
- "@wordpress/icons": "^9.30.0",
32
+ "@wordpress/a11y": "^3.40.0",
33
+ "@wordpress/components": "^25.6.0",
34
+ "@wordpress/data": "^9.10.0",
35
+ "@wordpress/element": "^5.17.0",
36
+ "@wordpress/i18n": "^4.40.0",
37
+ "@wordpress/icons": "^9.31.0",
37
38
  "classnames": "^2.3.1"
38
39
  },
39
40
  "peerDependencies": {
@@ -43,5 +44,5 @@
43
44
  "publishConfig": {
44
45
  "access": "public"
45
46
  },
46
- "gitHead": "b898cf1dc8e70841d1647ea0994ac6278acc18a7"
47
+ "gitHead": "78a288d55b83a713b2f7d98d5a855c0771a2afc6"
47
48
  }