@wordpress/interface 4.4.0 → 4.6.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,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.6.0 (2022-04-21)
6
+
7
+ ## 4.5.0 (2022-04-08)
8
+
5
9
  ## 4.4.0 (2022-03-23)
6
10
 
7
11
  ## 4.3.0 (2022-03-11)
@@ -5,13 +5,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.disableComplementaryArea = disableComplementaryArea;
9
- exports.enableComplementaryArea = enableComplementaryArea;
10
- exports.pinItem = pinItem;
8
+ exports.pinItem = exports.enableComplementaryArea = exports.disableComplementaryArea = void 0;
11
9
  exports.setFeatureDefaults = setFeatureDefaults;
12
10
  exports.setFeatureValue = setFeatureValue;
13
11
  exports.toggleFeature = toggleFeature;
14
- exports.unpinItem = unpinItem;
12
+ exports.unpinItem = void 0;
15
13
 
16
14
  var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
17
15
 
@@ -22,94 +20,95 @@ var _preferences = require("@wordpress/preferences");
22
20
  */
23
21
 
24
22
  /**
25
- * Returns an action object used in signalling that an active area should be changed.
26
- *
27
- * @param {string} itemType Type of item.
28
- * @param {string} scope Item scope.
29
- * @param {string} item Item identifier.
30
- *
31
- * @return {Object} Action object.
32
- */
33
- function setSingleEnableItem(itemType, scope, item) {
34
- return {
35
- type: 'SET_SINGLE_ENABLE_ITEM',
36
- itemType,
37
- scope,
38
- item
39
- };
40
- }
41
- /**
42
- * Returns an action object used in signalling that a complementary item should be enabled.
23
+ * Enable the complementary area.
43
24
  *
44
25
  * @param {string} scope Complementary area scope.
45
26
  * @param {string} area Area identifier.
46
- *
47
- * @return {Object} Action object.
48
27
  */
49
-
50
-
51
- function enableComplementaryArea(scope, area) {
52
- return setSingleEnableItem('complementaryArea', scope, area);
53
- }
28
+ const enableComplementaryArea = (scope, area) => _ref => {
29
+ let {
30
+ registry
31
+ } = _ref;
32
+
33
+ // Return early if there's no area.
34
+ if (!area) {
35
+ return;
36
+ }
37
+
38
+ registry.dispatch(_preferences.store).set(scope, 'complementaryArea', area);
39
+ };
54
40
  /**
55
- * Returns an action object used in signalling that the complementary area of a given scope should be disabled.
41
+ * Disable the complementary area.
56
42
  *
57
43
  * @param {string} scope Complementary area scope.
58
- *
59
- * @return {Object} Action object.
60
44
  */
61
45
 
62
46
 
63
- function disableComplementaryArea(scope) {
64
- return setSingleEnableItem('complementaryArea', scope, undefined);
65
- }
47
+ exports.enableComplementaryArea = enableComplementaryArea;
48
+
49
+ const disableComplementaryArea = scope => _ref2 => {
50
+ let {
51
+ registry
52
+ } = _ref2;
53
+ registry.dispatch(_preferences.store).set(scope, 'complementaryArea', null);
54
+ };
66
55
  /**
67
- * Returns an action object to make an area enabled/disabled.
56
+ * Pins an item.
68
57
  *
69
- * @param {string} itemType Type of item.
70
- * @param {string} scope Item scope.
71
- * @param {string} item Item identifier.
72
- * @param {boolean} isEnable Boolean indicating if an area should be pinned or not.
58
+ * @param {string} scope Item scope.
59
+ * @param {string} item Item identifier.
73
60
  *
74
61
  * @return {Object} Action object.
75
62
  */
76
63
 
77
64
 
78
- function setMultipleEnableItem(itemType, scope, item, isEnable) {
79
- return {
80
- type: 'SET_MULTIPLE_ENABLE_ITEM',
81
- itemType,
82
- scope,
83
- item,
84
- isEnable
85
- };
86
- }
87
- /**
88
- * Returns an action object used in signalling that an item should be pinned.
89
- *
90
- * @param {string} scope Item scope.
91
- * @param {string} itemId Item identifier.
92
- *
93
- * @return {Object} Action object.
94
- */
65
+ exports.disableComplementaryArea = disableComplementaryArea;
95
66
 
67
+ const pinItem = (scope, item) => _ref3 => {
68
+ let {
69
+ registry
70
+ } = _ref3;
96
71
 
97
- function pinItem(scope, itemId) {
98
- return setMultipleEnableItem('pinnedItems', scope, itemId, true);
99
- }
72
+ // Return early if there's no item.
73
+ if (!item) {
74
+ return;
75
+ }
76
+
77
+ const pinnedItems = registry.select(_preferences.store).get(scope, 'pinnedItems'); // The item is already pinned, there's nothing to do.
78
+
79
+ if ((pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) === true) {
80
+ return;
81
+ }
82
+
83
+ registry.dispatch(_preferences.store).set(scope, 'pinnedItems', { ...pinnedItems,
84
+ [item]: true
85
+ });
86
+ };
100
87
  /**
101
- * Returns an action object used in signalling that an item should be unpinned.
88
+ * Unpins an item.
102
89
  *
103
- * @param {string} scope Item scope.
104
- * @param {string} itemId Item identifier.
105
- *
106
- * @return {Object} Action object.
90
+ * @param {string} scope Item scope.
91
+ * @param {string} item Item identifier.
107
92
  */
108
93
 
109
94
 
110
- function unpinItem(scope, itemId) {
111
- return setMultipleEnableItem('pinnedItems', scope, itemId, false);
112
- }
95
+ exports.pinItem = pinItem;
96
+
97
+ const unpinItem = (scope, item) => _ref4 => {
98
+ let {
99
+ registry
100
+ } = _ref4;
101
+
102
+ // Return early if there's no item.
103
+ if (!item) {
104
+ return;
105
+ }
106
+
107
+ const pinnedItems = registry.select(_preferences.store).get(scope, 'pinnedItems');
108
+ registry.dispatch(_preferences.store).set(scope, 'pinnedItems', { ...pinnedItems,
109
+ [item]: false
110
+ });
111
+ };
113
112
  /**
114
113
  * Returns an action object used in signalling that a feature should be toggled.
115
114
  *
@@ -118,11 +117,13 @@ function unpinItem(scope, itemId) {
118
117
  */
119
118
 
120
119
 
120
+ exports.unpinItem = unpinItem;
121
+
121
122
  function toggleFeature(scope, featureName) {
122
- return function (_ref) {
123
+ return function (_ref5) {
123
124
  let {
124
125
  registry
125
- } = _ref;
126
+ } = _ref5;
126
127
  (0, _deprecated.default)(`wp.dispatch( 'core/interface' ).toggleFeature`, {
127
128
  since: '6.0',
128
129
  alternative: `wp.dispatch( 'core/preferences' ).toggle`
@@ -143,10 +144,10 @@ function toggleFeature(scope, featureName) {
143
144
 
144
145
 
145
146
  function setFeatureValue(scope, featureName, value) {
146
- return function (_ref2) {
147
+ return function (_ref6) {
147
148
  let {
148
149
  registry
149
- } = _ref2;
150
+ } = _ref6;
150
151
  (0, _deprecated.default)(`wp.dispatch( 'core/interface' ).setFeatureValue`, {
151
152
  since: '6.0',
152
153
  alternative: `wp.dispatch( 'core/preferences' ).set`
@@ -165,10 +166,10 @@ function setFeatureValue(scope, featureName, value) {
165
166
 
166
167
 
167
168
  function setFeatureDefaults(scope, defaults) {
168
- return function (_ref3) {
169
+ return function (_ref7) {
169
170
  let {
170
171
  registry
171
- } = _ref3;
172
+ } = _ref7;
172
173
  (0, _deprecated.default)(`wp.dispatch( 'core/interface' ).setFeatureDefaults`, {
173
174
  since: '6.0',
174
175
  alternative: `wp.dispatch( 'core/preferences' ).setDefaults`
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/interface/src/store/actions.js"],"names":["setSingleEnableItem","itemType","scope","item","type","enableComplementaryArea","area","disableComplementaryArea","undefined","setMultipleEnableItem","isEnable","pinItem","itemId","unpinItem","toggleFeature","featureName","registry","since","alternative","dispatch","preferencesStore","toggle","setFeatureValue","value","set","setFeatureDefaults","defaults","setDefaults"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Returns an action object used in signalling that an active area should be changed.\n *\n * @param {string} itemType Type of item.\n * @param {string} scope Item scope.\n * @param {string} item Item identifier.\n *\n * @return {Object} Action object.\n */\nfunction setSingleEnableItem( itemType, scope, item ) {\n\treturn {\n\t\ttype: 'SET_SINGLE_ENABLE_ITEM',\n\t\titemType,\n\t\tscope,\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a complementary item should be enabled.\n *\n * @param {string} scope Complementary area scope.\n * @param {string} area Area identifier.\n *\n * @return {Object} Action object.\n */\nexport function enableComplementaryArea( scope, area ) {\n\treturn setSingleEnableItem( 'complementaryArea', scope, area );\n}\n\n/**\n * Returns an action object used in signalling that the complementary area of a given scope should be disabled.\n *\n * @param {string} scope Complementary area scope.\n *\n * @return {Object} Action object.\n */\nexport function disableComplementaryArea( scope ) {\n\treturn setSingleEnableItem( 'complementaryArea', scope, undefined );\n}\n\n/**\n * Returns an action object to make an area enabled/disabled.\n *\n * @param {string} itemType Type of item.\n * @param {string} scope Item scope.\n * @param {string} item Item identifier.\n * @param {boolean} isEnable Boolean indicating if an area should be pinned or not.\n *\n * @return {Object} Action object.\n */\nfunction setMultipleEnableItem( itemType, scope, item, isEnable ) {\n\treturn {\n\t\ttype: 'SET_MULTIPLE_ENABLE_ITEM',\n\t\titemType,\n\t\tscope,\n\t\titem,\n\t\tisEnable,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that an item should be pinned.\n *\n * @param {string} scope Item scope.\n * @param {string} itemId Item identifier.\n *\n * @return {Object} Action object.\n */\nexport function pinItem( scope, itemId ) {\n\treturn setMultipleEnableItem( 'pinnedItems', scope, itemId, true );\n}\n\n/**\n * Returns an action object used in signalling that an item should be unpinned.\n *\n * @param {string} scope Item scope.\n * @param {string} itemId Item identifier.\n *\n * @return {Object} Action object.\n */\nexport function unpinItem( scope, itemId ) {\n\treturn setMultipleEnableItem( 'pinnedItems', scope, itemId, false );\n}\n\n/**\n * Returns an action object used in signalling that a feature should be toggled.\n *\n * @param {string} scope The feature scope (e.g. core/edit-post).\n * @param {string} featureName The feature name.\n */\nexport function toggleFeature( scope, featureName ) {\n\treturn function ( { registry } ) {\n\t\tdeprecated( `wp.dispatch( 'core/interface' ).toggleFeature`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `wp.dispatch( 'core/preferences' ).toggle`,\n\t\t} );\n\n\t\tregistry.dispatch( preferencesStore ).toggle( scope, featureName );\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a feature should be set to\n * a true or false value\n *\n * @param {string} scope The feature scope (e.g. core/edit-post).\n * @param {string} featureName The feature name.\n * @param {boolean} value The value to set.\n *\n * @return {Object} Action object.\n */\nexport function setFeatureValue( scope, featureName, value ) {\n\treturn function ( { registry } ) {\n\t\tdeprecated( `wp.dispatch( 'core/interface' ).setFeatureValue`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `wp.dispatch( 'core/preferences' ).set`,\n\t\t} );\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( scope, featureName, !! value );\n\t};\n}\n\n/**\n * Returns an action object used in signalling that defaults should be set for features.\n *\n * @param {string} scope The feature scope (e.g. core/edit-post).\n * @param {Object<string, boolean>} defaults A key/value map of feature names to values.\n *\n * @return {Object} Action object.\n */\nexport function setFeatureDefaults( scope, defaults ) {\n\treturn function ( { registry } ) {\n\t\tdeprecated( `wp.dispatch( 'core/interface' ).setFeatureDefaults`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `wp.dispatch( 'core/preferences' ).setDefaults`,\n\t\t} );\n\n\t\tregistry.dispatch( preferencesStore ).setDefaults( scope, defaults );\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/interface/src/store/actions.js"],"names":["enableComplementaryArea","scope","area","registry","dispatch","preferencesStore","set","disableComplementaryArea","pinItem","item","pinnedItems","select","get","unpinItem","toggleFeature","featureName","since","alternative","toggle","setFeatureValue","value","setFeatureDefaults","defaults","setDefaults"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,uBAAuB,GAAG,CAAEC,KAAF,EAASC,IAAT,KAAmB,QAAoB;AAAA,MAAlB;AAAEC,IAAAA;AAAF,GAAkB;;AAC7E;AACA,MAAK,CAAED,IAAP,EAAc;AACb;AACA;;AAEDC,EAAAA,QAAQ,CACNC,QADF,CACYC,kBADZ,EAEEC,GAFF,CAEOL,KAFP,EAEc,mBAFd,EAEmCC,IAFnC;AAGA,CATM;AAWP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMK,wBAAwB,GAAKN,KAAF,IAAa,SAAoB;AAAA,MAAlB;AAAEE,IAAAA;AAAF,GAAkB;AACxEA,EAAAA,QAAQ,CACNC,QADF,CACYC,kBADZ,EAEEC,GAFF,CAEOL,KAFP,EAEc,mBAFd,EAEmC,IAFnC;AAGA,CAJM;AAMP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMO,OAAO,GAAG,CAAEP,KAAF,EAASQ,IAAT,KAAmB,SAAoB;AAAA,MAAlB;AAAEN,IAAAA;AAAF,GAAkB;;AAC7D;AACA,MAAK,CAAEM,IAAP,EAAc;AACb;AACA;;AAED,QAAMC,WAAW,GAAGP,QAAQ,CAC1BQ,MADkB,CACVN,kBADU,EAElBO,GAFkB,CAEbX,KAFa,EAEN,aAFM,CAApB,CAN6D,CAU7D;;AACA,MAAK,CAAAS,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW,CAAID,IAAJ,CAAX,MAA0B,IAA/B,EAAsC;AACrC;AACA;;AAEDN,EAAAA,QAAQ,CAACC,QAAT,CAAmBC,kBAAnB,EAAsCC,GAAtC,CAA2CL,KAA3C,EAAkD,aAAlD,EAAiE,EAChE,GAAGS,WAD6D;AAEhE,KAAED,IAAF,GAAU;AAFsD,GAAjE;AAIA,CAnBM;AAqBP;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMI,SAAS,GAAG,CAAEZ,KAAF,EAASQ,IAAT,KAAmB,SAAoB;AAAA,MAAlB;AAAEN,IAAAA;AAAF,GAAkB;;AAC/D;AACA,MAAK,CAAEM,IAAP,EAAc;AACb;AACA;;AAED,QAAMC,WAAW,GAAGP,QAAQ,CAC1BQ,MADkB,CACVN,kBADU,EAElBO,GAFkB,CAEbX,KAFa,EAEN,aAFM,CAApB;AAIAE,EAAAA,QAAQ,CAACC,QAAT,CAAmBC,kBAAnB,EAAsCC,GAAtC,CAA2CL,KAA3C,EAAkD,aAAlD,EAAiE,EAChE,GAAGS,WAD6D;AAEhE,KAAED,IAAF,GAAU;AAFsD,GAAjE;AAIA,CAdM;AAgBP;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASK,aAAT,CAAwBb,KAAxB,EAA+Bc,WAA/B,EAA6C;AACnD,SAAO,iBAA0B;AAAA,QAAf;AAAEZ,MAAAA;AAAF,KAAe;AAChC,6BAAa,+CAAb,EAA6D;AAC5Da,MAAAA,KAAK,EAAE,KADqD;AAE5DC,MAAAA,WAAW,EAAG;AAF8C,KAA7D;AAKAd,IAAAA,QAAQ,CAACC,QAAT,CAAmBC,kBAAnB,EAAsCa,MAAtC,CAA8CjB,KAA9C,EAAqDc,WAArD;AACA,GAPD;AAQA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,eAAT,CAA0BlB,KAA1B,EAAiCc,WAAjC,EAA8CK,KAA9C,EAAsD;AAC5D,SAAO,iBAA0B;AAAA,QAAf;AAAEjB,MAAAA;AAAF,KAAe;AAChC,6BAAa,iDAAb,EAA+D;AAC9Da,MAAAA,KAAK,EAAE,KADuD;AAE9DC,MAAAA,WAAW,EAAG;AAFgD,KAA/D;AAKAd,IAAAA,QAAQ,CACNC,QADF,CACYC,kBADZ,EAEEC,GAFF,CAEOL,KAFP,EAEcc,WAFd,EAE2B,CAAC,CAAEK,KAF9B;AAGA,GATD;AAUA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,kBAAT,CAA6BpB,KAA7B,EAAoCqB,QAApC,EAA+C;AACrD,SAAO,iBAA0B;AAAA,QAAf;AAAEnB,MAAAA;AAAF,KAAe;AAChC,6BAAa,oDAAb,EAAkE;AACjEa,MAAAA,KAAK,EAAE,KAD0D;AAEjEC,MAAAA,WAAW,EAAG;AAFmD,KAAlE;AAKAd,IAAAA,QAAQ,CAACC,QAAT,CAAmBC,kBAAnB,EAAsCkB,WAAtC,CAAmDtB,KAAnD,EAA0DqB,QAA1D;AACA,GAPD;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Enable the complementary area.\n *\n * @param {string} scope Complementary area scope.\n * @param {string} area Area identifier.\n */\nexport const enableComplementaryArea = ( scope, area ) => ( { registry } ) => {\n\t// Return early if there's no area.\n\tif ( ! area ) {\n\t\treturn;\n\t}\n\n\tregistry\n\t\t.dispatch( preferencesStore )\n\t\t.set( scope, 'complementaryArea', area );\n};\n\n/**\n * Disable the complementary area.\n *\n * @param {string} scope Complementary area scope.\n */\nexport const disableComplementaryArea = ( scope ) => ( { registry } ) => {\n\tregistry\n\t\t.dispatch( preferencesStore )\n\t\t.set( scope, 'complementaryArea', null );\n};\n\n/**\n * Pins an item.\n *\n * @param {string} scope Item scope.\n * @param {string} item Item identifier.\n *\n * @return {Object} Action object.\n */\nexport const pinItem = ( scope, item ) => ( { registry } ) => {\n\t// Return early if there's no item.\n\tif ( ! item ) {\n\t\treturn;\n\t}\n\n\tconst pinnedItems = registry\n\t\t.select( preferencesStore )\n\t\t.get( scope, 'pinnedItems' );\n\n\t// The item is already pinned, there's nothing to do.\n\tif ( pinnedItems?.[ item ] === true ) {\n\t\treturn;\n\t}\n\n\tregistry.dispatch( preferencesStore ).set( scope, 'pinnedItems', {\n\t\t...pinnedItems,\n\t\t[ item ]: true,\n\t} );\n};\n\n/**\n * Unpins an item.\n *\n * @param {string} scope Item scope.\n * @param {string} item Item identifier.\n */\nexport const unpinItem = ( scope, item ) => ( { registry } ) => {\n\t// Return early if there's no item.\n\tif ( ! item ) {\n\t\treturn;\n\t}\n\n\tconst pinnedItems = registry\n\t\t.select( preferencesStore )\n\t\t.get( scope, 'pinnedItems' );\n\n\tregistry.dispatch( preferencesStore ).set( scope, 'pinnedItems', {\n\t\t...pinnedItems,\n\t\t[ item ]: false,\n\t} );\n};\n\n/**\n * Returns an action object used in signalling that a feature should be toggled.\n *\n * @param {string} scope The feature scope (e.g. core/edit-post).\n * @param {string} featureName The feature name.\n */\nexport function toggleFeature( scope, featureName ) {\n\treturn function ( { registry } ) {\n\t\tdeprecated( `wp.dispatch( 'core/interface' ).toggleFeature`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `wp.dispatch( 'core/preferences' ).toggle`,\n\t\t} );\n\n\t\tregistry.dispatch( preferencesStore ).toggle( scope, featureName );\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a feature should be set to\n * a true or false value\n *\n * @param {string} scope The feature scope (e.g. core/edit-post).\n * @param {string} featureName The feature name.\n * @param {boolean} value The value to set.\n *\n * @return {Object} Action object.\n */\nexport function setFeatureValue( scope, featureName, value ) {\n\treturn function ( { registry } ) {\n\t\tdeprecated( `wp.dispatch( 'core/interface' ).setFeatureValue`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `wp.dispatch( 'core/preferences' ).set`,\n\t\t} );\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( scope, featureName, !! value );\n\t};\n}\n\n/**\n * Returns an action object used in signalling that defaults should be set for features.\n *\n * @param {string} scope The feature scope (e.g. core/edit-post).\n * @param {Object<string, boolean>} defaults A key/value map of feature names to values.\n *\n * @return {Object} Action object.\n */\nexport function setFeatureDefaults( scope, defaults ) {\n\treturn function ( { registry } ) {\n\t\tdeprecated( `wp.dispatch( 'core/interface' ).setFeatureDefaults`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `wp.dispatch( 'core/preferences' ).setDefaults`,\n\t\t} );\n\n\t\tregistry.dispatch( preferencesStore ).setDefaults( scope, defaults );\n\t};\n}\n"]}
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -9,8 +7,6 @@ exports.store = void 0;
9
7
 
10
8
  var _data = require("@wordpress/data");
11
9
 
12
- var _reducer = _interopRequireDefault(require("./reducer"));
13
-
14
10
  var actions = _interopRequireWildcard(require("./actions"));
15
11
 
16
12
  var selectors = _interopRequireWildcard(require("./selectors"));
@@ -28,12 +24,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
28
24
  /**
29
25
  * Internal dependencies
30
26
  */
31
- const storeConfig = {
32
- reducer: _reducer.default,
33
- actions,
34
- selectors,
35
- persist: ['enableItems']
36
- };
27
+
37
28
  /**
38
29
  * Store definition for the interface namespace.
39
30
  *
@@ -41,10 +32,13 @@ const storeConfig = {
41
32
  *
42
33
  * @type {Object}
43
34
  */
44
-
45
- const store = (0, _data.createReduxStore)(_constants.STORE_NAME, storeConfig); // Once we build a more generic persistence plugin that works across types of stores
35
+ const store = (0, _data.createReduxStore)(_constants.STORE_NAME, {
36
+ reducer: () => {},
37
+ actions,
38
+ selectors
39
+ }); // Once we build a more generic persistence plugin that works across types of stores
46
40
  // we'd be able to replace this with a register call.
47
41
 
48
42
  exports.store = store;
49
- (0, _data.registerStore)(_constants.STORE_NAME, storeConfig);
43
+ (0, _data.register)(store);
50
44
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/interface/src/store/index.js"],"names":["storeConfig","reducer","actions","selectors","persist","store","STORE_NAME"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;;;;;AAXA;AACA;AACA;;AAGA;AACA;AACA;AAMA,MAAMA,WAAW,GAAG;AACnBC,EAAAA,OAAO,EAAPA,gBADmB;AAEnBC,EAAAA,OAFmB;AAGnBC,EAAAA,SAHmB;AAInBC,EAAAA,OAAO,EAAE,CAAE,aAAF;AAJU,CAApB;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,KAAK,GAAG,4BAAkBC,qBAAlB,EAA8BN,WAA9B,CAAd,C,CAEP;AACA;;;AACA,yBAAeM,qBAAf,EAA2BN,WAA3B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, registerStore } 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\nconst storeConfig = {\n\treducer,\n\tactions,\n\tselectors,\n\tpersist: [ 'enableItems' ],\n};\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, storeConfig );\n\n// Once we build a more generic persistence plugin that works across types of stores\n// we'd be able to replace this with a register call.\nregisterStore( STORE_NAME, storeConfig );\n"]}
1
+ {"version":3,"sources":["@wordpress/interface/src/store/index.js"],"names":["store","STORE_NAME","reducer","actions","selectors"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;;;;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,KAAK,GAAG,4BAAkBC,qBAAlB,EAA8B;AAClDC,EAAAA,OAAO,EAAE,MAAM,CAAE,CADiC;AAElDC,EAAAA,OAFkD;AAGlDC,EAAAA;AAHkD,CAA9B,CAAd,C,CAMP;AACA;;;AACA,oBAAUJ,KAAV","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\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\n// Once we build a more generic persistence plugin that works across types of stores\n// we'd be able to replace this with a register call.\nregister( store );\n"]}
@@ -5,11 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.getActiveComplementaryArea = getActiveComplementaryArea;
9
- exports.isFeatureActive = void 0;
10
- exports.isItemPinned = isItemPinned;
11
-
12
- var _lodash = require("lodash");
8
+ exports.isItemPinned = exports.isFeatureActive = exports.getActiveComplementaryArea = void 0;
13
9
 
14
10
  var _data = require("@wordpress/data");
15
11
 
@@ -17,26 +13,10 @@ var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
17
13
 
18
14
  var _preferences = require("@wordpress/preferences");
19
15
 
20
- /**
21
- * External dependencies
22
- */
23
-
24
16
  /**
25
17
  * WordPress dependencies
26
18
  */
27
19
 
28
- /**
29
- * Returns the item that is enabled in a given scope.
30
- *
31
- * @param {Object} state Global application state.
32
- * @param {string} itemType Type of item.
33
- * @param {string} scope Item scope.
34
- *
35
- * @return {?string|null} The item that is enabled in the passed scope and type.
36
- */
37
- function getSingleEnableItem(state, itemType, scope) {
38
- return (0, _lodash.get)(state.enableItems.singleEnableItems, [itemType, scope]);
39
- }
40
20
  /**
41
21
  * Returns the complementary area that is active in a given scope.
42
22
  *
@@ -45,26 +25,9 @@ function getSingleEnableItem(state, itemType, scope) {
45
25
  *
46
26
  * @return {string} The complementary area that is active in the given scope.
47
27
  */
48
-
49
-
50
- function getActiveComplementaryArea(state, scope) {
51
- return getSingleEnableItem(state, 'complementaryArea', scope);
52
- }
53
- /**
54
- * Returns a boolean indicating if an item is enabled or not in a given scope.
55
- *
56
- * @param {Object} state Global application state.
57
- * @param {string} itemType Type of item.
58
- * @param {string} scope Scope.
59
- * @param {string} item Item to check.
60
- *
61
- * @return {boolean|undefined} True if the item is enabled, false otherwise if the item is explicitly disabled, and undefined if there is no information for that item.
62
- */
63
-
64
-
65
- function isMultipleEnabledItemEnabled(state, itemType, scope, item) {
66
- return (0, _lodash.get)(state.enableItems.multipleEnableItems, [itemType, scope, item]);
67
- }
28
+ const getActiveComplementaryArea = (0, _data.createRegistrySelector)(select => (state, scope) => {
29
+ return select(_preferences.store).get(scope, 'complementaryArea');
30
+ });
68
31
  /**
69
32
  * Returns a boolean indicating if an item is pinned or not.
70
33
  *
@@ -75,10 +38,13 @@ function isMultipleEnabledItemEnabled(state, itemType, scope, item) {
75
38
  * @return {boolean} True if the item is pinned and false otherwise.
76
39
  */
77
40
 
41
+ exports.getActiveComplementaryArea = getActiveComplementaryArea;
42
+ const isItemPinned = (0, _data.createRegistrySelector)(select => (state, scope, item) => {
43
+ var _pinnedItems$item;
78
44
 
79
- function isItemPinned(state, scope, item) {
80
- return isMultipleEnabledItemEnabled(state, 'pinnedItems', scope, item) !== false;
81
- }
45
+ const pinnedItems = select(_preferences.store).get(scope, 'pinnedItems');
46
+ return (_pinnedItems$item = pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) !== null && _pinnedItems$item !== void 0 ? _pinnedItems$item : true;
47
+ });
82
48
  /**
83
49
  * Returns a boolean indicating whether a feature is active for a particular
84
50
  * scope.
@@ -90,7 +56,7 @@ function isItemPinned(state, scope, item) {
90
56
  * @return {boolean} Is the feature enabled?
91
57
  */
92
58
 
93
-
59
+ exports.isItemPinned = isItemPinned;
94
60
  const isFeatureActive = (0, _data.createRegistrySelector)(select => (state, scope, featureName) => {
95
61
  (0, _deprecated.default)(`wp.select( 'core/interface' ).isFeatureActive( scope, featureName )`, {
96
62
  since: '6.0',
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/interface/src/store/selectors.js"],"names":["getSingleEnableItem","state","itemType","scope","enableItems","singleEnableItems","getActiveComplementaryArea","isMultipleEnabledItemEnabled","item","multipleEnableItems","isItemPinned","isFeatureActive","select","featureName","since","alternative","preferencesStore","get"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,mBAAT,CAA8BC,KAA9B,EAAqCC,QAArC,EAA+CC,KAA/C,EAAuD;AACtD,SAAO,iBAAKF,KAAK,CAACG,WAAN,CAAkBC,iBAAvB,EAA0C,CAAEH,QAAF,EAAYC,KAAZ,CAA1C,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,0BAAT,CAAqCL,KAArC,EAA4CE,KAA5C,EAAoD;AAC1D,SAAOH,mBAAmB,CAAEC,KAAF,EAAS,mBAAT,EAA8BE,KAA9B,CAA1B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASI,4BAAT,CAAuCN,KAAvC,EAA8CC,QAA9C,EAAwDC,KAAxD,EAA+DK,IAA/D,EAAsE;AACrE,SAAO,iBAAKP,KAAK,CAACG,WAAN,CAAkBK,mBAAvB,EAA4C,CAClDP,QADkD,EAElDC,KAFkD,EAGlDK,IAHkD,CAA5C,CAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,YAAT,CAAuBT,KAAvB,EAA8BE,KAA9B,EAAqCK,IAArC,EAA4C;AAClD,SACCD,4BAA4B,CAAEN,KAAF,EAAS,aAAT,EAAwBE,KAAxB,EAA+BK,IAA/B,CAA5B,KACA,KAFD;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMG,eAAe,GAAG,kCAC5BC,MAAF,IAAc,CAAEX,KAAF,EAASE,KAAT,EAAgBU,WAAhB,KAAiC;AAC9C,2BACE,qEADF,EAEC;AACCC,IAAAA,KAAK,EAAE,KADR;AAECC,IAAAA,WAAW,EAAG;AAFf,GAFD;AAQA,SAAO,CAAC,CAAEH,MAAM,CAAEI,kBAAF,CAAN,CAA2BC,GAA3B,CAAgCd,KAAhC,EAAuCU,WAAvC,CAAV;AACA,CAX6B,CAAxB","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Returns the item that is enabled in a given scope.\n *\n * @param {Object} state Global application state.\n * @param {string} itemType Type of item.\n * @param {string} scope Item scope.\n *\n * @return {?string|null} The item that is enabled in the passed scope and type.\n */\nfunction getSingleEnableItem( state, itemType, scope ) {\n\treturn get( state.enableItems.singleEnableItems, [ itemType, scope ] );\n}\n\n/**\n * Returns the complementary area that is active in a given scope.\n *\n * @param {Object} state Global application state.\n * @param {string} scope Item scope.\n *\n * @return {string} The complementary area that is active in the given scope.\n */\nexport function getActiveComplementaryArea( state, scope ) {\n\treturn getSingleEnableItem( state, 'complementaryArea', scope );\n}\n\n/**\n * Returns a boolean indicating if an item is enabled or not in a given scope.\n *\n * @param {Object} state Global application state.\n * @param {string} itemType Type of item.\n * @param {string} scope Scope.\n * @param {string} item Item to check.\n *\n * @return {boolean|undefined} True if the item is enabled, false otherwise if the item is explicitly disabled, and undefined if there is no information for that item.\n */\nfunction isMultipleEnabledItemEnabled( state, itemType, scope, item ) {\n\treturn get( state.enableItems.multipleEnableItems, [\n\t\titemType,\n\t\tscope,\n\t\titem,\n\t] );\n}\n\n/**\n * Returns a boolean indicating if an item is pinned or not.\n *\n * @param {Object} state Global application state.\n * @param {string} scope Scope.\n * @param {string} item Item to check.\n *\n * @return {boolean} True if the item is pinned and false otherwise.\n */\nexport function isItemPinned( state, scope, item ) {\n\treturn (\n\t\tisMultipleEnabledItemEnabled( state, 'pinnedItems', scope, item ) !==\n\t\tfalse\n\t);\n}\n\n/**\n * Returns a boolean indicating whether a feature 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} featureName The name of the feature.\n *\n * @return {boolean} Is the feature enabled?\n */\nexport const isFeatureActive = createRegistrySelector(\n\t( select ) => ( state, scope, featureName ) => {\n\t\tdeprecated(\n\t\t\t`wp.select( 'core/interface' ).isFeatureActive( scope, featureName )`,\n\t\t\t{\n\t\t\t\tsince: '6.0',\n\t\t\t\talternative: `!! wp.select( 'core/preferences' ).isFeatureActive( scope, featureName )`,\n\t\t\t}\n\t\t);\n\n\t\treturn !! select( preferencesStore ).get( scope, featureName );\n\t}\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/interface/src/store/selectors.js"],"names":["getActiveComplementaryArea","select","state","scope","preferencesStore","get","isItemPinned","item","pinnedItems","isFeatureActive","featureName","since","alternative"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,0BAA0B,GAAG,kCACvCC,MAAF,IAAc,CAAEC,KAAF,EAASC,KAAT,KAAoB;AACjC,SAAOF,MAAM,CAAEG,kBAAF,CAAN,CAA2BC,GAA3B,CAAgCF,KAAhC,EAAuC,mBAAvC,CAAP;AACA,CAHwC,CAAnC;AAMP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMG,YAAY,GAAG,kCACzBL,MAAF,IAAc,CAAEC,KAAF,EAASC,KAAT,EAAgBI,IAAhB,KAA0B;AAAA;;AACvC,QAAMC,WAAW,GAAGP,MAAM,CAAEG,kBAAF,CAAN,CAA2BC,GAA3B,CACnBF,KADmB,EAEnB,aAFmB,CAApB;AAIA,8BAAOK,WAAP,aAAOA,WAAP,uBAAOA,WAAW,CAAID,IAAJ,CAAlB,iEAAgC,IAAhC;AACA,CAP0B,CAArB;AAUP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAME,eAAe,GAAG,kCAC5BR,MAAF,IAAc,CAAEC,KAAF,EAASC,KAAT,EAAgBO,WAAhB,KAAiC;AAC9C,2BACE,qEADF,EAEC;AACCC,IAAAA,KAAK,EAAE,KADR;AAECC,IAAAA,WAAW,EAAG;AAFf,GAFD;AAQA,SAAO,CAAC,CAAEX,MAAM,CAAEG,kBAAF,CAAN,CAA2BC,GAA3B,CAAgCF,KAAhC,EAAuCO,WAAvC,CAAV;AACA,CAX6B,CAAxB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Returns the complementary area that is active in a given scope.\n *\n * @param {Object} state Global application state.\n * @param {string} scope Item scope.\n *\n * @return {string} The complementary area that is active in the given scope.\n */\nexport const getActiveComplementaryArea = createRegistrySelector(\n\t( select ) => ( state, scope ) => {\n\t\treturn select( preferencesStore ).get( scope, 'complementaryArea' );\n\t}\n);\n\n/**\n * Returns a boolean indicating if an item is pinned or not.\n *\n * @param {Object} state Global application state.\n * @param {string} scope Scope.\n * @param {string} item Item to check.\n *\n * @return {boolean} True if the item is pinned and false otherwise.\n */\nexport const isItemPinned = createRegistrySelector(\n\t( select ) => ( state, scope, item ) => {\n\t\tconst pinnedItems = select( preferencesStore ).get(\n\t\t\tscope,\n\t\t\t'pinnedItems'\n\t\t);\n\t\treturn pinnedItems?.[ item ] ?? true;\n\t}\n);\n\n/**\n * Returns a boolean indicating whether a feature 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} featureName The name of the feature.\n *\n * @return {boolean} Is the feature enabled?\n */\nexport const isFeatureActive = createRegistrySelector(\n\t( select ) => ( state, scope, featureName ) => {\n\t\tdeprecated(\n\t\t\t`wp.select( 'core/interface' ).isFeatureActive( scope, featureName )`,\n\t\t\t{\n\t\t\t\tsince: '6.0',\n\t\t\t\talternative: `!! wp.select( 'core/preferences' ).isFeatureActive( scope, featureName )`,\n\t\t\t}\n\t\t);\n\n\t\treturn !! select( preferencesStore ).get( scope, featureName );\n\t}\n);\n"]}
@@ -4,92 +4,87 @@
4
4
  import deprecated from '@wordpress/deprecated';
5
5
  import { store as preferencesStore } from '@wordpress/preferences';
6
6
  /**
7
- * Returns an action object used in signalling that an active area should be changed.
8
- *
9
- * @param {string} itemType Type of item.
10
- * @param {string} scope Item scope.
11
- * @param {string} item Item identifier.
12
- *
13
- * @return {Object} Action object.
14
- */
15
-
16
- function setSingleEnableItem(itemType, scope, item) {
17
- return {
18
- type: 'SET_SINGLE_ENABLE_ITEM',
19
- itemType,
20
- scope,
21
- item
22
- };
23
- }
24
- /**
25
- * Returns an action object used in signalling that a complementary item should be enabled.
7
+ * Enable the complementary area.
26
8
  *
27
9
  * @param {string} scope Complementary area scope.
28
10
  * @param {string} area Area identifier.
29
- *
30
- * @return {Object} Action object.
31
11
  */
32
12
 
13
+ export const enableComplementaryArea = (scope, area) => _ref => {
14
+ let {
15
+ registry
16
+ } = _ref;
33
17
 
34
- export function enableComplementaryArea(scope, area) {
35
- return setSingleEnableItem('complementaryArea', scope, area);
36
- }
18
+ // Return early if there's no area.
19
+ if (!area) {
20
+ return;
21
+ }
22
+
23
+ registry.dispatch(preferencesStore).set(scope, 'complementaryArea', area);
24
+ };
37
25
  /**
38
- * Returns an action object used in signalling that the complementary area of a given scope should be disabled.
26
+ * Disable the complementary area.
39
27
  *
40
28
  * @param {string} scope Complementary area scope.
41
- *
42
- * @return {Object} Action object.
43
29
  */
44
30
 
45
- export function disableComplementaryArea(scope) {
46
- return setSingleEnableItem('complementaryArea', scope, undefined);
47
- }
31
+ export const disableComplementaryArea = scope => _ref2 => {
32
+ let {
33
+ registry
34
+ } = _ref2;
35
+ registry.dispatch(preferencesStore).set(scope, 'complementaryArea', null);
36
+ };
48
37
  /**
49
- * Returns an action object to make an area enabled/disabled.
38
+ * Pins an item.
50
39
  *
51
- * @param {string} itemType Type of item.
52
- * @param {string} scope Item scope.
53
- * @param {string} item Item identifier.
54
- * @param {boolean} isEnable Boolean indicating if an area should be pinned or not.
40
+ * @param {string} scope Item scope.
41
+ * @param {string} item Item identifier.
55
42
  *
56
43
  * @return {Object} Action object.
57
44
  */
58
45
 
59
- function setMultipleEnableItem(itemType, scope, item, isEnable) {
60
- return {
61
- type: 'SET_MULTIPLE_ENABLE_ITEM',
62
- itemType,
63
- scope,
64
- item,
65
- isEnable
66
- };
67
- }
68
- /**
69
- * Returns an action object used in signalling that an item should be pinned.
70
- *
71
- * @param {string} scope Item scope.
72
- * @param {string} itemId Item identifier.
73
- *
74
- * @return {Object} Action object.
75
- */
46
+ export const pinItem = (scope, item) => _ref3 => {
47
+ let {
48
+ registry
49
+ } = _ref3;
76
50
 
51
+ // Return early if there's no item.
52
+ if (!item) {
53
+ return;
54
+ }
77
55
 
78
- export function pinItem(scope, itemId) {
79
- return setMultipleEnableItem('pinnedItems', scope, itemId, true);
80
- }
56
+ const pinnedItems = registry.select(preferencesStore).get(scope, 'pinnedItems'); // The item is already pinned, there's nothing to do.
57
+
58
+ if ((pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) === true) {
59
+ return;
60
+ }
61
+
62
+ registry.dispatch(preferencesStore).set(scope, 'pinnedItems', { ...pinnedItems,
63
+ [item]: true
64
+ });
65
+ };
81
66
  /**
82
- * Returns an action object used in signalling that an item should be unpinned.
67
+ * Unpins an item.
83
68
  *
84
- * @param {string} scope Item scope.
85
- * @param {string} itemId Item identifier.
86
- *
87
- * @return {Object} Action object.
69
+ * @param {string} scope Item scope.
70
+ * @param {string} item Item identifier.
88
71
  */
89
72
 
90
- export function unpinItem(scope, itemId) {
91
- return setMultipleEnableItem('pinnedItems', scope, itemId, false);
92
- }
73
+ export const unpinItem = (scope, item) => _ref4 => {
74
+ let {
75
+ registry
76
+ } = _ref4;
77
+
78
+ // Return early if there's no item.
79
+ if (!item) {
80
+ return;
81
+ }
82
+
83
+ const pinnedItems = registry.select(preferencesStore).get(scope, 'pinnedItems');
84
+ registry.dispatch(preferencesStore).set(scope, 'pinnedItems', { ...pinnedItems,
85
+ [item]: false
86
+ });
87
+ };
93
88
  /**
94
89
  * Returns an action object used in signalling that a feature should be toggled.
95
90
  *
@@ -98,10 +93,10 @@ export function unpinItem(scope, itemId) {
98
93
  */
99
94
 
100
95
  export function toggleFeature(scope, featureName) {
101
- return function (_ref) {
96
+ return function (_ref5) {
102
97
  let {
103
98
  registry
104
- } = _ref;
99
+ } = _ref5;
105
100
  deprecated(`wp.dispatch( 'core/interface' ).toggleFeature`, {
106
101
  since: '6.0',
107
102
  alternative: `wp.dispatch( 'core/preferences' ).toggle`
@@ -121,10 +116,10 @@ export function toggleFeature(scope, featureName) {
121
116
  */
122
117
 
123
118
  export function setFeatureValue(scope, featureName, value) {
124
- return function (_ref2) {
119
+ return function (_ref6) {
125
120
  let {
126
121
  registry
127
- } = _ref2;
122
+ } = _ref6;
128
123
  deprecated(`wp.dispatch( 'core/interface' ).setFeatureValue`, {
129
124
  since: '6.0',
130
125
  alternative: `wp.dispatch( 'core/preferences' ).set`
@@ -142,10 +137,10 @@ export function setFeatureValue(scope, featureName, value) {
142
137
  */
143
138
 
144
139
  export function setFeatureDefaults(scope, defaults) {
145
- return function (_ref3) {
140
+ return function (_ref7) {
146
141
  let {
147
142
  registry
148
- } = _ref3;
143
+ } = _ref7;
149
144
  deprecated(`wp.dispatch( 'core/interface' ).setFeatureDefaults`, {
150
145
  since: '6.0',
151
146
  alternative: `wp.dispatch( 'core/preferences' ).setDefaults`