@wordpress/interface 4.7.0 → 4.10.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/action-item/index.js +4 -3
  3. package/build/components/action-item/index.js.map +1 -1
  4. package/build/components/complementary-area/index.js.map +1 -1
  5. package/build/components/complementary-area-toggle/index.js.map +1 -1
  6. package/build/store/actions.js +42 -10
  7. package/build/store/actions.js.map +1 -1
  8. package/build/store/index.js +5 -1
  9. package/build/store/index.js.map +1 -1
  10. package/build/store/reducer.js +55 -0
  11. package/build/store/reducer.js.map +1 -0
  12. package/build/store/selectors.js +19 -4
  13. package/build/store/selectors.js.map +1 -1
  14. package/build-module/components/action-item/index.js +3 -1
  15. package/build-module/components/action-item/index.js.map +1 -1
  16. package/build-module/components/complementary-area/index.js.map +1 -1
  17. package/build-module/components/complementary-area-toggle/index.js.map +1 -1
  18. package/build-module/store/actions.js +38 -9
  19. package/build-module/store/actions.js.map +1 -1
  20. package/build-module/store/index.js +2 -1
  21. package/build-module/store/index.js.map +1 -1
  22. package/build-module/store/reducer.js +43 -0
  23. package/build-module/store/reducer.js.map +1 -0
  24. package/build-module/store/selectors.js +19 -4
  25. package/build-module/store/selectors.js.map +1 -1
  26. package/build-style/style-rtl.css +0 -1
  27. package/build-style/style.css +0 -1
  28. package/package.json +13 -13
  29. package/src/components/action-item/index.js +3 -1
  30. package/src/components/complementary-area/index.js +6 -9
  31. package/src/components/complementary-area-toggle/index.js +2 -3
  32. package/src/components/more-menu-dropdown/style.scss +0 -1
  33. package/src/store/actions.js +96 -56
  34. package/src/store/index.js +2 -1
  35. package/src/store/reducer.js +35 -0
  36. package/src/store/selectors.js +21 -4
  37. package/src/store/test/actions.js +1 -1
@@ -3,6 +3,20 @@
3
3
  */
4
4
  import deprecated from '@wordpress/deprecated';
5
5
  import { store as preferencesStore } from '@wordpress/preferences';
6
+ /**
7
+ * Set a default complementary area.
8
+ *
9
+ * @param {string} scope Complementary area scope.
10
+ * @param {string} area Area identifier.
11
+ *
12
+ * @return {Object} Action object.
13
+ */
14
+
15
+ export const setDefaultComplementaryArea = (scope, area) => ({
16
+ type: 'SET_DEFAULT_COMPLEMENTARY_AREA',
17
+ scope,
18
+ area
19
+ });
6
20
  /**
7
21
  * Enable the complementary area.
8
22
  *
@@ -12,7 +26,8 @@ import { store as preferencesStore } from '@wordpress/preferences';
12
26
 
13
27
  export const enableComplementaryArea = (scope, area) => _ref => {
14
28
  let {
15
- registry
29
+ registry,
30
+ dispatch
16
31
  } = _ref;
17
32
 
18
33
  // Return early if there's no area.
@@ -20,7 +35,17 @@ export const enableComplementaryArea = (scope, area) => _ref => {
20
35
  return;
21
36
  }
22
37
 
23
- registry.dispatch(preferencesStore).set(scope, 'complementaryArea', area);
38
+ const isComplementaryAreaVisible = registry.select(preferencesStore).get(scope, 'isComplementaryAreaVisible');
39
+
40
+ if (!isComplementaryAreaVisible) {
41
+ registry.dispatch(preferencesStore).set(scope, 'isComplementaryAreaVisible', true);
42
+ }
43
+
44
+ dispatch({
45
+ type: 'ENABLE_COMPLEMENTARY_AREA',
46
+ scope,
47
+ area
48
+ });
24
49
  };
25
50
  /**
26
51
  * Disable the complementary area.
@@ -32,7 +57,11 @@ export const disableComplementaryArea = scope => _ref2 => {
32
57
  let {
33
58
  registry
34
59
  } = _ref2;
35
- registry.dispatch(preferencesStore).set(scope, 'complementaryArea', null);
60
+ const isComplementaryAreaVisible = registry.select(preferencesStore).get(scope, 'isComplementaryAreaVisible');
61
+
62
+ if (isComplementaryAreaVisible) {
63
+ registry.dispatch(preferencesStore).set(scope, 'isComplementaryAreaVisible', false);
64
+ }
36
65
  };
37
66
  /**
38
67
  * Pins an item.
@@ -97,9 +126,9 @@ export function toggleFeature(scope, featureName) {
97
126
  let {
98
127
  registry
99
128
  } = _ref5;
100
- deprecated(`wp.dispatch( 'core/interface' ).toggleFeature`, {
129
+ deprecated(`dispatch( 'core/interface' ).toggleFeature`, {
101
130
  since: '6.0',
102
- alternative: `wp.dispatch( 'core/preferences' ).toggle`
131
+ alternative: `dispatch( 'core/preferences' ).toggle`
103
132
  });
104
133
  registry.dispatch(preferencesStore).toggle(scope, featureName);
105
134
  };
@@ -120,9 +149,9 @@ export function setFeatureValue(scope, featureName, value) {
120
149
  let {
121
150
  registry
122
151
  } = _ref6;
123
- deprecated(`wp.dispatch( 'core/interface' ).setFeatureValue`, {
152
+ deprecated(`dispatch( 'core/interface' ).setFeatureValue`, {
124
153
  since: '6.0',
125
- alternative: `wp.dispatch( 'core/preferences' ).set`
154
+ alternative: `dispatch( 'core/preferences' ).set`
126
155
  });
127
156
  registry.dispatch(preferencesStore).set(scope, featureName, !!value);
128
157
  };
@@ -141,9 +170,9 @@ export function setFeatureDefaults(scope, defaults) {
141
170
  let {
142
171
  registry
143
172
  } = _ref7;
144
- deprecated(`wp.dispatch( 'core/interface' ).setFeatureDefaults`, {
173
+ deprecated(`dispatch( 'core/interface' ).setFeatureDefaults`, {
145
174
  since: '6.0',
146
- alternative: `wp.dispatch( 'core/preferences' ).setDefaults`
175
+ alternative: `dispatch( 'core/preferences' ).setDefaults`
147
176
  });
148
177
  registry.dispatch(preferencesStore).setDefaults(scope, defaults);
149
178
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/interface/src/store/actions.js"],"names":["deprecated","store","preferencesStore","enableComplementaryArea","scope","area","registry","dispatch","set","disableComplementaryArea","pinItem","item","pinnedItems","select","get","unpinItem","toggleFeature","featureName","since","alternative","toggle","setFeatureValue","value","setFeatureDefaults","defaults","setDefaults"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,uBAAvB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,uBAAuB,GAAG,CAAEC,KAAF,EAASC,IAAT,KAAmB,QAAoB;AAAA,MAAlB;AAAEC,IA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;AAAA,QAAf;AAAElB,MAAAA;AAAF,KAAe;AAChCN,IAAAA,UAAU,CAAG,oDAAH,EAAwD;AACjEkB,MAAAA,KAAK,EAAE,KAD0D;AAEjEC,MAAAA,WAAW,EAAG;AAFmD,KAAxD,CAAV;AAKAb,IAAAA,QAAQ,CAACC,QAAT,CAAmBL,gBAAnB,EAAsCuB,WAAtC,CAAmDrB,KAAnD,EAA0DoB,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
+ {"version":3,"sources":["@wordpress/interface/src/store/actions.js"],"names":["deprecated","store","preferencesStore","setDefaultComplementaryArea","scope","area","type","enableComplementaryArea","registry","dispatch","isComplementaryAreaVisible","select","get","set","disableComplementaryArea","pinItem","item","pinnedItems","unpinItem","toggleFeature","featureName","since","alternative","toggle","setFeatureValue","value","setFeatureDefaults","defaults","setDefaults"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,uBAAvB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,2BAA2B,GAAG,CAAEC,KAAF,EAASC,IAAT,MAAqB;AAC/DC,EAAAA,IAAI,EAAE,gCADyD;AAE/DF,EAAAA,KAF+D;AAG/DC,EAAAA;AAH+D,CAArB,CAApC;AAMP;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAME,uBAAuB,GACnC,CAAEH,KAAF,EAASC,IAAT,KACA,QAA8B;AAAA,MAA5B;AAAEG,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAA4B;;AAC7B;AACA,MAAK,CAAEJ,IAAP,EAAc;AACb;AACA;;AAED,QAAMK,0BAA0B,GAAGF,QAAQ,CACzCG,MADiC,CACzBT,gBADyB,EAEjCU,GAFiC,CAE5BR,KAF4B,EAErB,4BAFqB,CAAnC;;AAIA,MAAK,CAAEM,0BAAP,EAAoC;AACnCF,IAAAA,QAAQ,CACNC,QADF,CACYP,gBADZ,EAEEW,GAFF,CAEOT,KAFP,EAEc,4BAFd,EAE4C,IAF5C;AAGA;;AAEDK,EAAAA,QAAQ,CAAE;AACTH,IAAAA,IAAI,EAAE,2BADG;AAETF,IAAAA,KAFS;AAGTC,IAAAA;AAHS,GAAF,CAAR;AAKA,CAvBK;AAyBP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMS,wBAAwB,GAClCV,KAAF,I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ADuD;AAE9DC,MAAAA,WAAW,EAAG;AAFgD,KAArD,CAAV;AAKAd,IAAAA,QAAQ,CAACC,QAAT,CAAmBP,gBAAnB,EAAsC0B,WAAtC,CAAmDxB,KAAnD,EAA0DuB,QAA1D;AACA,GAPD;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Set a default complementary area.\n *\n * @param {string} scope Complementary area scope.\n * @param {string} area Area identifier.\n *\n * @return {Object} Action object.\n */\nexport const setDefaultComplementaryArea = ( scope, area ) => ( {\n\ttype: 'SET_DEFAULT_COMPLEMENTARY_AREA',\n\tscope,\n\tarea,\n} );\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 =\n\t( scope, area ) =>\n\t( { registry, dispatch } ) => {\n\t\t// Return early if there's no area.\n\t\tif ( ! area ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isComplementaryAreaVisible = registry\n\t\t\t.select( preferencesStore )\n\t\t\t.get( scope, 'isComplementaryAreaVisible' );\n\n\t\tif ( ! isComplementaryAreaVisible ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( preferencesStore )\n\t\t\t\t.set( scope, 'isComplementaryAreaVisible', true );\n\t\t}\n\n\t\tdispatch( {\n\t\t\ttype: 'ENABLE_COMPLEMENTARY_AREA',\n\t\t\tscope,\n\t\t\tarea,\n\t\t} );\n\t};\n\n/**\n * Disable the complementary area.\n *\n * @param {string} scope Complementary area scope.\n */\nexport const disableComplementaryArea =\n\t( scope ) =>\n\t( { registry } ) => {\n\t\tconst isComplementaryAreaVisible = registry\n\t\t\t.select( preferencesStore )\n\t\t\t.get( scope, 'isComplementaryAreaVisible' );\n\n\t\tif ( isComplementaryAreaVisible ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( preferencesStore )\n\t\t\t\t.set( scope, 'isComplementaryAreaVisible', false );\n\t\t}\n\t};\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 =\n\t( scope, item ) =>\n\t( { registry } ) => {\n\t\t// Return early if there's no item.\n\t\tif ( ! item ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst pinnedItems = registry\n\t\t\t.select( preferencesStore )\n\t\t\t.get( scope, 'pinnedItems' );\n\n\t\t// The item is already pinned, there's nothing to do.\n\t\tif ( pinnedItems?.[ item ] === true ) {\n\t\t\treturn;\n\t\t}\n\n\t\tregistry.dispatch( preferencesStore ).set( scope, 'pinnedItems', {\n\t\t\t...pinnedItems,\n\t\t\t[ item ]: true,\n\t\t} );\n\t};\n\n/**\n * Unpins an item.\n *\n * @param {string} scope Item scope.\n * @param {string} item Item identifier.\n */\nexport const unpinItem =\n\t( scope, item ) =>\n\t( { registry } ) => {\n\t\t// Return early if there's no item.\n\t\tif ( ! item ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst pinnedItems = registry\n\t\t\t.select( preferencesStore )\n\t\t\t.get( scope, 'pinnedItems' );\n\n\t\tregistry.dispatch( preferencesStore ).set( scope, 'pinnedItems', {\n\t\t\t...pinnedItems,\n\t\t\t[ item ]: false,\n\t\t} );\n\t};\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( `dispatch( 'core/interface' ).toggleFeature`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `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( `dispatch( 'core/interface' ).setFeatureValue`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `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( `dispatch( 'core/interface' ).setFeatureDefaults`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `dispatch( 'core/preferences' ).setDefaults`,\n\t\t} );\n\n\t\tregistry.dispatch( preferencesStore ).setDefaults( scope, defaults );\n\t};\n}\n"]}
@@ -8,6 +8,7 @@ import { createReduxStore, register } from '@wordpress/data';
8
8
 
9
9
  import * as actions from './actions';
10
10
  import * as selectors from './selectors';
11
+ import reducer from './reducer';
11
12
  import { STORE_NAME } from './constants';
12
13
  /**
13
14
  * Store definition for the interface namespace.
@@ -18,7 +19,7 @@ import { STORE_NAME } from './constants';
18
19
  */
19
20
 
20
21
  export const store = createReduxStore(STORE_NAME, {
21
- reducer: () => {},
22
+ reducer,
22
23
  actions,
23
24
  selectors
24
25
  }); // Once we build a more generic persistence plugin that works across types of stores
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/interface/src/store/index.js"],"names":["createReduxStore","register","actions","selectors","STORE_NAME","store","reducer"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAT,EAA2BC,QAA3B,QAA2C,iBAA3C;AAEA;AACA;AACA;;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,GAAGL,gBAAgB,CAAEI,UAAF,EAAc;AAClDE,EAAAA,OAAO,EAAE,MAAM,CAAE,CADiC;AAElDJ,EAAAA,OAFkD;AAGlDC,EAAAA;AAHkD,CAAd,CAA9B,C,CAMP;AACA;;AACAF,QAAQ,CAAEI,KAAF,CAAR","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"]}
1
+ {"version":3,"sources":["@wordpress/interface/src/store/index.js"],"names":["createReduxStore","register","actions","selectors","reducer","STORE_NAME","store"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAT,EAA2BC,QAA3B,QAA2C,iBAA3C;AAEA;AACA;AACA;;AACA,OAAO,KAAKC,OAAZ,MAAyB,WAAzB;AACA,OAAO,KAAKC,SAAZ,MAA2B,aAA3B;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,SAASC,UAAT,QAA2B,aAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,KAAK,GAAGN,gBAAgB,CAAEK,UAAF,EAAc;AAClDD,EAAAA,OADkD;AAElDF,EAAAA,OAFkD;AAGlDC,EAAAA;AAHkD,CAAd,CAA9B,C,CAMP;AACA;;AACAF,QAAQ,CAAEK,KAAF,CAAR","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 reducer from './reducer';\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"]}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { combineReducers } from '@wordpress/data';
5
+ export function complementaryAreas() {
6
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7
+ let action = arguments.length > 1 ? arguments[1] : undefined;
8
+
9
+ switch (action.type) {
10
+ case 'SET_DEFAULT_COMPLEMENTARY_AREA':
11
+ {
12
+ const {
13
+ scope,
14
+ area
15
+ } = action; // If there's already an area, don't overwrite it.
16
+
17
+ if (state[scope]) {
18
+ return state;
19
+ }
20
+
21
+ return { ...state,
22
+ [scope]: area
23
+ };
24
+ }
25
+
26
+ case 'ENABLE_COMPLEMENTARY_AREA':
27
+ {
28
+ const {
29
+ scope,
30
+ area
31
+ } = action;
32
+ return { ...state,
33
+ [scope]: area
34
+ };
35
+ }
36
+ }
37
+
38
+ return state;
39
+ }
40
+ export default combineReducers({
41
+ complementaryAreas
42
+ });
43
+ //# sourceMappingURL=reducer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/interface/src/store/reducer.js"],"names":["combineReducers","complementaryAreas","state","action","type","scope","area"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,iBAAhC;AAEA,OAAO,SAASC,kBAAT,GAAkD;AAAA,MAArBC,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;AACxD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,gCAAL;AAAuC;AACtC,cAAM;AAAEC,UAAAA,KAAF;AAASC,UAAAA;AAAT,YAAkBH,MAAxB,CADsC,CAGtC;;AACA,YAAKD,KAAK,CAAEG,KAAF,CAAV,EAAsB;AACrB,iBAAOH,KAAP;AACA;;AAED,eAAO,EACN,GAAGA,KADG;AAEN,WAAEG,KAAF,GAAWC;AAFL,SAAP;AAIA;;AACD,SAAK,2BAAL;AAAkC;AACjC,cAAM;AAAED,UAAAA,KAAF;AAASC,UAAAA;AAAT,YAAkBH,MAAxB;AACA,eAAO,EACN,GAAGD,KADG;AAEN,WAAEG,KAAF,GAAWC;AAFL,SAAP;AAIA;AApBF;;AAuBA,SAAOJ,KAAP;AACA;AAED,eAAeF,eAAe,CAAE;AAC/BC,EAAAA;AAD+B,CAAF,CAA9B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\nexport function complementaryAreas( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_DEFAULT_COMPLEMENTARY_AREA': {\n\t\t\tconst { scope, area } = action;\n\n\t\t\t// If there's already an area, don't overwrite it.\n\t\t\tif ( state[ scope ] ) {\n\t\t\t\treturn state;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ scope ]: area,\n\t\t\t};\n\t\t}\n\t\tcase 'ENABLE_COMPLEMENTARY_AREA': {\n\t\t\tconst { scope, area } = action;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ scope ]: area,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn state;\n}\n\nexport default combineReducers( {\n\tcomplementaryAreas,\n} );\n"]}
@@ -10,11 +10,26 @@ import { store as preferencesStore } from '@wordpress/preferences';
10
10
  * @param {Object} state Global application state.
11
11
  * @param {string} scope Item scope.
12
12
  *
13
- * @return {string} The complementary area that is active in the given scope.
13
+ * @return {string | null | undefined} The complementary area that is active in the given scope.
14
14
  */
15
15
 
16
16
  export const getActiveComplementaryArea = createRegistrySelector(select => (state, scope) => {
17
- return select(preferencesStore).get(scope, 'complementaryArea');
17
+ var _state$complementaryA;
18
+
19
+ const isComplementaryAreaVisible = select(preferencesStore).get(scope, 'isComplementaryAreaVisible'); // Return `undefined` to indicate that the user has never toggled
20
+ // visibility, this is the vanilla default. Other code relies on this
21
+ // nuance in the return value.
22
+
23
+ if (isComplementaryAreaVisible === undefined) {
24
+ return undefined;
25
+ } // Return `null` to indicate the user hid the complementary area.
26
+
27
+
28
+ if (!isComplementaryAreaVisible) {
29
+ return null;
30
+ }
31
+
32
+ return state === null || state === void 0 ? void 0 : (_state$complementaryA = state.complementaryAreas) === null || _state$complementaryA === void 0 ? void 0 : _state$complementaryA[scope];
18
33
  });
19
34
  /**
20
35
  * Returns a boolean indicating if an item is pinned or not.
@@ -44,9 +59,9 @@ export const isItemPinned = createRegistrySelector(select => (state, scope, item
44
59
  */
45
60
 
46
61
  export const isFeatureActive = createRegistrySelector(select => (state, scope, featureName) => {
47
- deprecated(`wp.select( 'core/interface' ).isFeatureActive( scope, featureName )`, {
62
+ deprecated(`select( 'core/interface' ).isFeatureActive( scope, featureName )`, {
48
63
  since: '6.0',
49
- alternative: `!! wp.select( 'core/preferences' ).isFeatureActive( scope, featureName )`
64
+ alternative: `select( 'core/preferences' ).get( scope, featureName )`
50
65
  });
51
66
  return !!select(preferencesStore).get(scope, featureName);
52
67
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/interface/src/store/selectors.js"],"names":["createRegistrySelector","deprecated","store","preferencesStore","getActiveComplementaryArea","select","state","scope","get","isItemPinned","item","pinnedItems","isFeatureActive","featureName","since","alternative"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAT,QAAuC,iBAAvC;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,0BAA0B,GAAGJ,sBAAsB,CAC7DK,MAAF,IAAc,CAAEC,KAAF,EAASC,KAAT,KAAoB;AACjC,SAAOF,MAAM,CAAEF,gBAAF,CAAN,CAA2BK,GAA3B,CAAgCD,KAAhC,EAAuC,mBAAvC,CAAP;AACA,CAH8D,CAAzD;AAMP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAME,YAAY,GAAGT,sBAAsB,CAC/CK,MAAF,IAAc,CAAEC,KAAF,EAASC,KAAT,EAAgBG,IAAhB,KAA0B;AAAA;;AACvC,QAAMC,WAAW,GAAGN,MAAM,CAAEF,gBAAF,CAAN,CAA2BK,GAA3B,CACnBD,KADmB,EAEnB,aAFmB,CAApB;AAIA,8BAAOI,WAAP,aAAOA,WAAP,uBAAOA,WAAW,CAAID,IAAJ,CAAlB,iEAAgC,IAAhC;AACA,CAPgD,CAA3C;AAUP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAME,eAAe,GAAGZ,sBAAsB,CAClDK,MAAF,IAAc,CAAEC,KAAF,EAASC,KAAT,EAAgBM,WAAhB,KAAiC;AAC9CZ,EAAAA,UAAU,CACR,qEADQ,EAET;AACCa,IAAAA,KAAK,EAAE,KADR;AAECC,IAAAA,WAAW,EAAG;AAFf,GAFS,CAAV;AAQA,SAAO,CAAC,CAAEV,MAAM,CAAEF,gBAAF,CAAN,CAA2BK,GAA3B,CAAgCD,KAAhC,EAAuCM,WAAvC,CAAV;AACA,CAXmD,CAA9C","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"]}
1
+ {"version":3,"sources":["@wordpress/interface/src/store/selectors.js"],"names":["createRegistrySelector","deprecated","store","preferencesStore","getActiveComplementaryArea","select","state","scope","isComplementaryAreaVisible","get","undefined","complementaryAreas","isItemPinned","item","pinnedItems","isFeatureActive","featureName","since","alternative"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAT,QAAuC,iBAAvC;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,0BAA0B,GAAGJ,sBAAsB,CAC7DK,MAAF,IAAc,CAAEC,KAAF,EAASC,KAAT,KAAoB;AAAA;;AACjC,QAAMC,0BAA0B,GAAGH,MAAM,CAAEF,gBAAF,CAAN,CAA2BM,GAA3B,CAClCF,KADkC,EAElC,4BAFkC,CAAnC,CADiC,CAMjC;AACA;AACA;;AACA,MAAKC,0BAA0B,KAAKE,SAApC,EAAgD;AAC/C,WAAOA,SAAP;AACA,GAXgC,CAajC;;;AACA,MAAK,CAAEF,0BAAP,EAAoC;AACnC,WAAO,IAAP;AACA;;AAED,SAAOF,KAAP,aAAOA,KAAP,gDAAOA,KAAK,CAAEK,kBAAd,0DAAO,sBAA6BJ,KAA7B,CAAP;AACA,CApB8D,CAAzD;AAuBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMK,YAAY,GAAGZ,sBAAsB,CAC/CK,MAAF,IAAc,CAAEC,KAAF,EAASC,KAAT,EAAgBM,IAAhB,KAA0B;AAAA;;AACvC,QAAMC,WAAW,GAAGT,MAAM,CAAEF,gBAAF,CAAN,CAA2BM,GAA3B,CACnBF,KADmB,EAEnB,aAFmB,CAApB;AAIA,8BAAOO,WAAP,aAAOA,WAAP,uBAAOA,WAAW,CAAID,IAAJ,CAAlB,iEAAgC,IAAhC;AACA,CAPgD,CAA3C;AAUP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAME,eAAe,GAAGf,sBAAsB,CAClDK,MAAF,IAAc,CAAEC,KAAF,EAASC,KAAT,EAAgBS,WAAhB,KAAiC;AAC9Cf,EAAAA,UAAU,CACR,kEADQ,EAET;AACCgB,IAAAA,KAAK,EAAE,KADR;AAECC,IAAAA,WAAW,EAAG;AAFf,GAFS,CAAV;AAQA,SAAO,CAAC,CAAEb,MAAM,CAAEF,gBAAF,CAAN,CAA2BM,GAA3B,CAAgCF,KAAhC,EAAuCS,WAAvC,CAAV;AACA,CAXmD,CAA9C","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 | null | undefined} The complementary area that is active in the given scope.\n */\nexport const getActiveComplementaryArea = createRegistrySelector(\n\t( select ) => ( state, scope ) => {\n\t\tconst isComplementaryAreaVisible = select( preferencesStore ).get(\n\t\t\tscope,\n\t\t\t'isComplementaryAreaVisible'\n\t\t);\n\n\t\t// Return `undefined` to indicate that the user has never toggled\n\t\t// visibility, this is the vanilla default. Other code relies on this\n\t\t// nuance in the return value.\n\t\tif ( isComplementaryAreaVisible === undefined ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Return `null` to indicate the user hid the complementary area.\n\t\tif ( ! isComplementaryAreaVisible ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn state?.complementaryAreas?.[ scope ];\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`select( 'core/interface' ).isFeatureActive( scope, featureName )`,\n\t\t\t{\n\t\t\t\tsince: '6.0',\n\t\t\t\talternative: `select( 'core/preferences' ).get( scope, featureName )`,\n\t\t\t}\n\t\t);\n\n\t\treturn !! select( preferencesStore ).get( scope, featureName );\n\t}\n);\n"]}
@@ -416,7 +416,6 @@ body.is-fullscreen-mode .interface-interface-skeleton {
416
416
  }
417
417
  @media (min-width: 480px) {
418
418
  .interface-more-menu-dropdown__content .components-popover__content {
419
- width: auto;
420
419
  max-width: 480px;
421
420
  }
422
421
  }
@@ -416,7 +416,6 @@ body.is-fullscreen-mode .interface-interface-skeleton {
416
416
  }
417
417
  @media (min-width: 480px) {
418
418
  .interface-more-menu-dropdown__content .components-popover__content {
419
- width: auto;
420
419
  max-width: 480px;
421
420
  }
422
421
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/interface",
3
- "version": "4.7.0",
3
+ "version": "4.10.0",
4
4
  "description": "Interface module for WordPress. The package contains shared functionality across the modern JavaScript-based WordPress screens.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -32,17 +32,17 @@
32
32
  ],
33
33
  "dependencies": {
34
34
  "@babel/runtime": "^7.16.0",
35
- "@wordpress/a11y": "^3.8.0",
36
- "@wordpress/components": "^19.10.0",
37
- "@wordpress/compose": "^5.6.0",
38
- "@wordpress/data": "^6.8.0",
39
- "@wordpress/deprecated": "^3.8.0",
40
- "@wordpress/element": "^4.6.0",
41
- "@wordpress/i18n": "^4.8.0",
42
- "@wordpress/icons": "^8.4.0",
43
- "@wordpress/plugins": "^4.6.0",
44
- "@wordpress/preferences": "^2.0.0",
45
- "@wordpress/viewport": "^4.6.0",
35
+ "@wordpress/a11y": "^3.11.0",
36
+ "@wordpress/components": "^19.13.0",
37
+ "@wordpress/compose": "^5.9.0",
38
+ "@wordpress/data": "^6.11.0",
39
+ "@wordpress/deprecated": "^3.11.0",
40
+ "@wordpress/element": "^4.9.0",
41
+ "@wordpress/i18n": "^4.11.0",
42
+ "@wordpress/icons": "^9.2.0",
43
+ "@wordpress/plugins": "^4.9.0",
44
+ "@wordpress/preferences": "^2.3.0",
45
+ "@wordpress/viewport": "^4.9.0",
46
46
  "classnames": "^2.3.1",
47
47
  "lodash": "^4.17.21"
48
48
  },
@@ -53,5 +53,5 @@
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  },
56
- "gitHead": "4631d515033397fcfeda77e5755960253caef9bf"
56
+ "gitHead": "48d5f37dfb52d2e77c8eeb662f9874cf141b8c6b"
57
57
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { isEmpty, noop } from 'lodash';
4
+ import { isEmpty } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -9,6 +9,8 @@ import { isEmpty, noop } from 'lodash';
9
9
  import { ButtonGroup, Button, Slot, Fill } from '@wordpress/components';
10
10
  import { Children } from '@wordpress/element';
11
11
 
12
+ const noop = () => {};
13
+
12
14
  function ActionItemSlot( {
13
15
  name,
14
16
  as: Component = ButtonGroup,
@@ -44,9 +44,8 @@ function useAdjustComplementaryListener(
44
44
  ) {
45
45
  const previousIsSmall = useRef( false );
46
46
  const shouldOpenWhenNotSmall = useRef( false );
47
- const { enableComplementaryArea, disableComplementaryArea } = useDispatch(
48
- interfaceStore
49
- );
47
+ const { enableComplementaryArea, disableComplementaryArea } =
48
+ useDispatch( interfaceStore );
50
49
  useEffect( () => {
51
50
  // If the complementary area is active and the editor is switching from a big to a small window size.
52
51
  if ( isActive && isSmall && ! previousIsSmall.current ) {
@@ -100,9 +99,8 @@ function ComplementaryArea( {
100
99
  } ) {
101
100
  const { isActive, isPinned, activeArea, isSmall, isLarge } = useSelect(
102
101
  ( select ) => {
103
- const { getActiveComplementaryArea, isItemPinned } = select(
104
- interfaceStore
105
- );
102
+ const { getActiveComplementaryArea, isItemPinned } =
103
+ select( interfaceStore );
106
104
  const _activeArea = getActiveComplementaryArea( scope );
107
105
  return {
108
106
  isActive: _activeArea === identifier,
@@ -217,9 +215,8 @@ function ComplementaryArea( {
217
215
  );
218
216
  }
219
217
 
220
- const ComplementaryAreaWrapped = withComplementaryAreaContext(
221
- ComplementaryArea
222
- );
218
+ const ComplementaryAreaWrapped =
219
+ withComplementaryAreaContext( ComplementaryArea );
223
220
 
224
221
  ComplementaryAreaWrapped.Slot = ComplementaryAreaSlot;
225
222
 
@@ -30,9 +30,8 @@ function ComplementaryAreaToggle( {
30
30
  identifier,
31
31
  [ identifier ]
32
32
  );
33
- const { enableComplementaryArea, disableComplementaryArea } = useDispatch(
34
- interfaceStore
35
- );
33
+ const { enableComplementaryArea, disableComplementaryArea } =
34
+ useDispatch( interfaceStore );
36
35
  return (
37
36
  <ComponentToUse
38
37
  icon={ selectedIcon && isSelected ? selectedIcon : icon }
@@ -21,7 +21,6 @@
21
21
 
22
22
  // Let the menu scale to fit items.
23
23
  @include break-mobile() {
24
- width: auto;
25
24
  max-width: $break-mobile;
26
25
  }
27
26
 
@@ -5,32 +5,68 @@ import deprecated from '@wordpress/deprecated';
5
5
  import { store as preferencesStore } from '@wordpress/preferences';
6
6
 
7
7
  /**
8
- * Enable the complementary area.
8
+ * Set a default complementary area.
9
9
  *
10
10
  * @param {string} scope Complementary area scope.
11
11
  * @param {string} area Area identifier.
12
+ *
13
+ * @return {Object} Action object.
12
14
  */
13
- export const enableComplementaryArea = ( scope, area ) => ( { registry } ) => {
14
- // Return early if there's no area.
15
- if ( ! area ) {
16
- return;
17
- }
15
+ export const setDefaultComplementaryArea = ( scope, area ) => ( {
16
+ type: 'SET_DEFAULT_COMPLEMENTARY_AREA',
17
+ scope,
18
+ area,
19
+ } );
18
20
 
19
- registry
20
- .dispatch( preferencesStore )
21
- .set( scope, 'complementaryArea', area );
22
- };
21
+ /**
22
+ * Enable the complementary area.
23
+ *
24
+ * @param {string} scope Complementary area scope.
25
+ * @param {string} area Area identifier.
26
+ */
27
+ export const enableComplementaryArea =
28
+ ( scope, area ) =>
29
+ ( { registry, dispatch } ) => {
30
+ // Return early if there's no area.
31
+ if ( ! area ) {
32
+ return;
33
+ }
34
+
35
+ const isComplementaryAreaVisible = registry
36
+ .select( preferencesStore )
37
+ .get( scope, 'isComplementaryAreaVisible' );
38
+
39
+ if ( ! isComplementaryAreaVisible ) {
40
+ registry
41
+ .dispatch( preferencesStore )
42
+ .set( scope, 'isComplementaryAreaVisible', true );
43
+ }
44
+
45
+ dispatch( {
46
+ type: 'ENABLE_COMPLEMENTARY_AREA',
47
+ scope,
48
+ area,
49
+ } );
50
+ };
23
51
 
24
52
  /**
25
53
  * Disable the complementary area.
26
54
  *
27
55
  * @param {string} scope Complementary area scope.
28
56
  */
29
- export const disableComplementaryArea = ( scope ) => ( { registry } ) => {
30
- registry
31
- .dispatch( preferencesStore )
32
- .set( scope, 'complementaryArea', null );
33
- };
57
+ export const disableComplementaryArea =
58
+ ( scope ) =>
59
+ ( { registry } ) => {
60
+ const isComplementaryAreaVisible = registry
61
+ .select( preferencesStore )
62
+ .get( scope, 'isComplementaryAreaVisible' );
63
+
64
+ if ( isComplementaryAreaVisible ) {
65
+ registry
66
+ .dispatch( preferencesStore )
67
+ .set( scope, 'isComplementaryAreaVisible', false );
68
+ }
69
+ };
34
70
 
35
71
  /**
36
72
  * Pins an item.
@@ -40,26 +76,28 @@ export const disableComplementaryArea = ( scope ) => ( { registry } ) => {
40
76
  *
41
77
  * @return {Object} Action object.
42
78
  */
43
- export const pinItem = ( scope, item ) => ( { registry } ) => {
44
- // Return early if there's no item.
45
- if ( ! item ) {
46
- return;
47
- }
48
-
49
- const pinnedItems = registry
50
- .select( preferencesStore )
51
- .get( scope, 'pinnedItems' );
52
-
53
- // The item is already pinned, there's nothing to do.
54
- if ( pinnedItems?.[ item ] === true ) {
55
- return;
56
- }
57
-
58
- registry.dispatch( preferencesStore ).set( scope, 'pinnedItems', {
59
- ...pinnedItems,
60
- [ item ]: true,
61
- } );
62
- };
79
+ export const pinItem =
80
+ ( scope, item ) =>
81
+ ( { registry } ) => {
82
+ // Return early if there's no item.
83
+ if ( ! item ) {
84
+ return;
85
+ }
86
+
87
+ const pinnedItems = registry
88
+ .select( preferencesStore )
89
+ .get( scope, 'pinnedItems' );
90
+
91
+ // The item is already pinned, there's nothing to do.
92
+ if ( pinnedItems?.[ item ] === true ) {
93
+ return;
94
+ }
95
+
96
+ registry.dispatch( preferencesStore ).set( scope, 'pinnedItems', {
97
+ ...pinnedItems,
98
+ [ item ]: true,
99
+ } );
100
+ };
63
101
 
64
102
  /**
65
103
  * Unpins an item.
@@ -67,21 +105,23 @@ export const pinItem = ( scope, item ) => ( { registry } ) => {
67
105
  * @param {string} scope Item scope.
68
106
  * @param {string} item Item identifier.
69
107
  */
70
- export const unpinItem = ( scope, item ) => ( { registry } ) => {
71
- // Return early if there's no item.
72
- if ( ! item ) {
73
- return;
74
- }
75
-
76
- const pinnedItems = registry
77
- .select( preferencesStore )
78
- .get( scope, 'pinnedItems' );
79
-
80
- registry.dispatch( preferencesStore ).set( scope, 'pinnedItems', {
81
- ...pinnedItems,
82
- [ item ]: false,
83
- } );
84
- };
108
+ export const unpinItem =
109
+ ( scope, item ) =>
110
+ ( { registry } ) => {
111
+ // Return early if there's no item.
112
+ if ( ! item ) {
113
+ return;
114
+ }
115
+
116
+ const pinnedItems = registry
117
+ .select( preferencesStore )
118
+ .get( scope, 'pinnedItems' );
119
+
120
+ registry.dispatch( preferencesStore ).set( scope, 'pinnedItems', {
121
+ ...pinnedItems,
122
+ [ item ]: false,
123
+ } );
124
+ };
85
125
 
86
126
  /**
87
127
  * Returns an action object used in signalling that a feature should be toggled.
@@ -91,9 +131,9 @@ export const unpinItem = ( scope, item ) => ( { registry } ) => {
91
131
  */
92
132
  export function toggleFeature( scope, featureName ) {
93
133
  return function ( { registry } ) {
94
- deprecated( `wp.dispatch( 'core/interface' ).toggleFeature`, {
134
+ deprecated( `dispatch( 'core/interface' ).toggleFeature`, {
95
135
  since: '6.0',
96
- alternative: `wp.dispatch( 'core/preferences' ).toggle`,
136
+ alternative: `dispatch( 'core/preferences' ).toggle`,
97
137
  } );
98
138
 
99
139
  registry.dispatch( preferencesStore ).toggle( scope, featureName );
@@ -112,9 +152,9 @@ export function toggleFeature( scope, featureName ) {
112
152
  */
113
153
  export function setFeatureValue( scope, featureName, value ) {
114
154
  return function ( { registry } ) {
115
- deprecated( `wp.dispatch( 'core/interface' ).setFeatureValue`, {
155
+ deprecated( `dispatch( 'core/interface' ).setFeatureValue`, {
116
156
  since: '6.0',
117
- alternative: `wp.dispatch( 'core/preferences' ).set`,
157
+ alternative: `dispatch( 'core/preferences' ).set`,
118
158
  } );
119
159
 
120
160
  registry
@@ -133,9 +173,9 @@ export function setFeatureValue( scope, featureName, value ) {
133
173
  */
134
174
  export function setFeatureDefaults( scope, defaults ) {
135
175
  return function ( { registry } ) {
136
- deprecated( `wp.dispatch( 'core/interface' ).setFeatureDefaults`, {
176
+ deprecated( `dispatch( 'core/interface' ).setFeatureDefaults`, {
137
177
  since: '6.0',
138
- alternative: `wp.dispatch( 'core/preferences' ).setDefaults`,
178
+ alternative: `dispatch( 'core/preferences' ).setDefaults`,
139
179
  } );
140
180
 
141
181
  registry.dispatch( preferencesStore ).setDefaults( scope, defaults );
@@ -8,6 +8,7 @@ import { createReduxStore, register } from '@wordpress/data';
8
8
  */
9
9
  import * as actions from './actions';
10
10
  import * as selectors from './selectors';
11
+ import reducer from './reducer';
11
12
  import { STORE_NAME } from './constants';
12
13
 
13
14
  /**
@@ -18,7 +19,7 @@ import { STORE_NAME } from './constants';
18
19
  * @type {Object}
19
20
  */
20
21
  export const store = createReduxStore( STORE_NAME, {
21
- reducer: () => {},
22
+ reducer,
22
23
  actions,
23
24
  selectors,
24
25
  } );