@wordpress/interface 4.5.5 → 4.8.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,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.8.0 (2022-05-18)
6
+
7
+ ## 4.7.0 (2022-05-04)
8
+
9
+ ## 4.6.0 (2022-04-21)
10
+
5
11
  ## 4.5.0 (2022-04-08)
6
12
 
7
13
  ## 4.4.0 (2022-03-23)
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.pinItem = exports.enableComplementaryArea = exports.disableComplementaryArea = void 0;
8
+ exports.setDefaultComplementaryArea = exports.pinItem = exports.enableComplementaryArea = exports.disableComplementaryArea = void 0;
9
9
  exports.setFeatureDefaults = setFeatureDefaults;
10
10
  exports.setFeatureValue = setFeatureValue;
11
11
  exports.toggleFeature = toggleFeature;
@@ -19,15 +19,33 @@ var _preferences = require("@wordpress/preferences");
19
19
  * WordPress dependencies
20
20
  */
21
21
 
22
+ /**
23
+ * Set a default complementary area.
24
+ *
25
+ * @param {string} scope Complementary area scope.
26
+ * @param {string} area Area identifier.
27
+ *
28
+ * @return {Object} Action object.
29
+ */
30
+ const setDefaultComplementaryArea = (scope, area) => ({
31
+ type: 'SET_DEFAULT_COMPLEMENTARY_AREA',
32
+ scope,
33
+ area
34
+ });
22
35
  /**
23
36
  * Enable the complementary area.
24
37
  *
25
38
  * @param {string} scope Complementary area scope.
26
39
  * @param {string} area Area identifier.
27
40
  */
41
+
42
+
43
+ exports.setDefaultComplementaryArea = setDefaultComplementaryArea;
44
+
28
45
  const enableComplementaryArea = (scope, area) => _ref => {
29
46
  let {
30
- registry
47
+ registry,
48
+ dispatch
31
49
  } = _ref;
32
50
 
33
51
  // Return early if there's no area.
@@ -35,7 +53,17 @@ const enableComplementaryArea = (scope, area) => _ref => {
35
53
  return;
36
54
  }
37
55
 
38
- registry.dispatch(_preferences.store).set(scope, 'complementaryArea', area);
56
+ const isComplementaryAreaVisible = registry.select(_preferences.store).get(scope, 'isComplementaryAreaVisible');
57
+
58
+ if (!isComplementaryAreaVisible) {
59
+ registry.dispatch(_preferences.store).set(scope, 'isComplementaryAreaVisible', true);
60
+ }
61
+
62
+ dispatch({
63
+ type: 'ENABLE_COMPLEMENTARY_AREA',
64
+ scope,
65
+ area
66
+ });
39
67
  };
40
68
  /**
41
69
  * Disable the complementary area.
@@ -50,7 +78,11 @@ const disableComplementaryArea = scope => _ref2 => {
50
78
  let {
51
79
  registry
52
80
  } = _ref2;
53
- registry.dispatch(_preferences.store).set(scope, 'complementaryArea', null);
81
+ const isComplementaryAreaVisible = registry.select(_preferences.store).get(scope, 'isComplementaryAreaVisible');
82
+
83
+ if (isComplementaryAreaVisible) {
84
+ registry.dispatch(_preferences.store).set(scope, 'isComplementaryAreaVisible', false);
85
+ }
54
86
  };
55
87
  /**
56
88
  * Pins an item.
@@ -1 +1 @@
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;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AQA","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( `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"]}
1
+ {"version":3,"sources":["@wordpress/interface/src/store/actions.js"],"names":["setDefaultComplementaryArea","scope","area","type","enableComplementaryArea","registry","dispatch","isComplementaryAreaVisible","select","preferencesStore","get","set","disableComplementaryArea","pinItem","item","pinnedItems","unpinItem","toggleFeature","featureName","since","alternative","toggle","setFeatureValue","value","setFeatureDefaults","defaults","setDefaults"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AAJA;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kD;AAEzDC,MAAAA,WAAW,EAAG;AAF2C,KAA1D;AAKAf,IAAAA,QAAQ,CAACC,QAAT,CAAmBG,kBAAnB,EAAsCY,MAAtC,CAA8CpB,KAA9C,EAAqDiB,WAArD;AACA,GAPD;AAQA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,eAAT,CAA0BrB,KAA1B,EAAiCiB,WAAjC,EAA8CK,KAA9C,EAAsD;AAC5D,SAAO,iBAA0B;AAAA,QAAf;AAAElB,MAAAA;AAAF,KAAe;AAChC,6BAAa,8CAAb,EAA4D;AAC3Dc,MAAAA,KAAK,EAAE,KADoD;AAE3DC,MAAAA,WAAW,EAAG;AAF6C,KAA5D;AAKAf,IAAAA,QAAQ,CACNC,QADF,CACYG,kBADZ,EAEEE,GAFF,CAEOV,KAFP,EAEciB,WAFd,EAE2B,CAAC,CAAEK,KAF9B;AAGA,GATD;AAUA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,kBAAT,CAA6BvB,KAA7B,EAAoCwB,QAApC,EAA+C;AACrD,SAAO,iBAA0B;AAAA,QAAf;AAAEpB,MAAAA;AAAF,KAAe;AAChC,6BAAa,iDAAb,EAA+D;AAC9Dc,MAAAA,KAAK,EAAE,KADuD;AAE9DC,MAAAA,WAAW,EAAG;AAFgD,KAA/D;AAKAf,IAAAA,QAAQ,CAACC,QAAT,CAAmBG,kBAAnB,EAAsCiB,WAAtC,CAAmDzB,KAAnD,EAA0DwB,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 = ( scope, area ) => ( {\n\tregistry,\n\tdispatch,\n} ) => {\n\t// Return early if there's no area.\n\tif ( ! area ) {\n\t\treturn;\n\t}\n\n\tconst isComplementaryAreaVisible = registry\n\t\t.select( preferencesStore )\n\t\t.get( scope, 'isComplementaryAreaVisible' );\n\n\tif ( ! isComplementaryAreaVisible ) {\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( scope, 'isComplementaryAreaVisible', true );\n\t}\n\n\tdispatch( {\n\t\ttype: 'ENABLE_COMPLEMENTARY_AREA',\n\t\tscope,\n\t\tarea,\n\t} );\n};\n\n/**\n * Disable the complementary area.\n *\n * @param {string} scope Complementary area scope.\n */\nexport const disableComplementaryArea = ( scope ) => ( { registry } ) => {\n\tconst isComplementaryAreaVisible = registry\n\t\t.select( preferencesStore )\n\t\t.get( scope, 'isComplementaryAreaVisible' );\n\n\tif ( isComplementaryAreaVisible ) {\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( scope, 'isComplementaryAreaVisible', false );\n\t}\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( `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"]}
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -11,6 +13,8 @@ var actions = _interopRequireWildcard(require("./actions"));
11
13
 
12
14
  var selectors = _interopRequireWildcard(require("./selectors"));
13
15
 
16
+ var _reducer = _interopRequireDefault(require("./reducer"));
17
+
14
18
  var _constants = require("./constants");
15
19
 
16
20
  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); }
@@ -33,7 +37,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
33
37
  * @type {Object}
34
38
  */
35
39
  const store = (0, _data.createReduxStore)(_constants.STORE_NAME, {
36
- reducer: () => {},
40
+ reducer: _reducer.default,
37
41
  actions,
38
42
  selectors
39
43
  }); // 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":["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"]}
1
+ {"version":3,"sources":["@wordpress/interface/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,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 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,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.complementaryAreas = complementaryAreas;
7
+ exports.default = void 0;
8
+
9
+ var _data = require("@wordpress/data");
10
+
11
+ /**
12
+ * WordPress dependencies
13
+ */
14
+ function complementaryAreas() {
15
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
16
+ let action = arguments.length > 1 ? arguments[1] : undefined;
17
+
18
+ switch (action.type) {
19
+ case 'SET_DEFAULT_COMPLEMENTARY_AREA':
20
+ {
21
+ const {
22
+ scope,
23
+ area
24
+ } = action; // If there's already an area, don't overwrite it.
25
+
26
+ if (state[scope]) {
27
+ return state;
28
+ }
29
+
30
+ return { ...state,
31
+ [scope]: area
32
+ };
33
+ }
34
+
35
+ case 'ENABLE_COMPLEMENTARY_AREA':
36
+ {
37
+ const {
38
+ scope,
39
+ area
40
+ } = action;
41
+ return { ...state,
42
+ [scope]: area
43
+ };
44
+ }
45
+ }
46
+
47
+ return state;
48
+ }
49
+
50
+ var _default = (0, _data.combineReducers)({
51
+ complementaryAreas
52
+ });
53
+
54
+ exports.default = _default;
55
+ //# sourceMappingURL=reducer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/interface/src/store/reducer.js"],"names":["complementaryAreas","state","action","type","scope","area"],"mappings":";;;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,SAASA,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;;eAEc,2BAAiB;AAC/BD,EAAAA;AAD+B,CAAjB,C","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"]}
@@ -23,10 +23,25 @@ var _preferences = require("@wordpress/preferences");
23
23
  * @param {Object} state Global application state.
24
24
  * @param {string} scope Item scope.
25
25
  *
26
- * @return {string} The complementary area that is active in the given scope.
26
+ * @return {string | null | undefined} The complementary area that is active in the given scope.
27
27
  */
28
28
  const getActiveComplementaryArea = (0, _data.createRegistrySelector)(select => (state, scope) => {
29
- return select(_preferences.store).get(scope, 'complementaryArea');
29
+ var _state$complementaryA;
30
+
31
+ const isComplementaryAreaVisible = select(_preferences.store).get(scope, 'isComplementaryAreaVisible'); // Return `undefined` to indicate that the user has never toggled
32
+ // visibility, this is the vanilla default. Other code relies on this
33
+ // nuance in the return value.
34
+
35
+ if (isComplementaryAreaVisible === undefined) {
36
+ return undefined;
37
+ } // Return `null` to indicate the user hid the complementary area.
38
+
39
+
40
+ if (!isComplementaryAreaVisible) {
41
+ return null;
42
+ }
43
+
44
+ return state === null || state === void 0 ? void 0 : (_state$complementaryA = state.complementaryAreas) === null || _state$complementaryA === void 0 ? void 0 : _state$complementaryA[scope];
30
45
  });
31
46
  /**
32
47
  * Returns a boolean indicating if an item is pinned or not.
@@ -1 +1 @@
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,kEADF,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`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"]}
1
+ {"version":3,"sources":["@wordpress/interface/src/store/selectors.js"],"names":["getActiveComplementaryArea","select","state","scope","isComplementaryAreaVisible","preferencesStore","get","undefined","complementaryAreas","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;AAAA;;AACjC,QAAMC,0BAA0B,GAAGH,MAAM,CAAEI,kBAAF,CAAN,CAA2BC,GAA3B,CAClCH,KADkC,EAElC,4BAFkC,CAAnC,CADiC,CAMjC;AACA;AACA;;AACA,MAAKC,0BAA0B,KAAKG,SAApC,EAAgD;AAC/C,WAAOA,SAAP;AACA,GAXgC,CAajC;;;AACA,MAAK,CAAEH,0BAAP,EAAoC;AACnC,WAAO,IAAP;AACA;;AAED,SAAOF,KAAP,aAAOA,KAAP,gDAAOA,KAAK,CAAEM,kBAAd,0DAAO,sBAA6BL,KAA7B,CAAP;AACA,CApBwC,CAAnC;AAuBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMM,YAAY,GAAG,kCACzBR,MAAF,IAAc,CAAEC,KAAF,EAASC,KAAT,EAAgBO,IAAhB,KAA0B;AAAA;;AACvC,QAAMC,WAAW,GAAGV,MAAM,CAAEI,kBAAF,CAAN,CAA2BC,GAA3B,CACnBH,KADmB,EAEnB,aAFmB,CAApB;AAIA,8BAAOQ,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,kCAC5BX,MAAF,IAAc,CAAEC,KAAF,EAASC,KAAT,EAAgBU,WAAhB,KAAiC;AAC9C,2BACE,kEADF,EAEC;AACCC,IAAAA,KAAK,EAAE,KADR;AAECC,IAAAA,WAAW,EAAG;AAFf,GAFD;AAQA,SAAO,CAAC,CAAEd,MAAM,CAAEI,kBAAF,CAAN,CAA2BC,GAA3B,CAAgCH,KAAhC,EAAuCU,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 | 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"]}
@@ -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.
@@ -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,IAAAA;AAAF,GAAkB;;AAC7E;AACA,MAAK,CAAED,IAAP,EAAc;AACb;AACA;;AAEDC,EAAAA,QAAQ,CACNC,QADF,CACYL,gBADZ,EAEEM,GAFF,CAEOJ,KAFP,EAEc,mBAFd,EAEmCC,IAFnC;AAGA,CATM;AAWP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMI,wBAAwB,GAAKL,KAAF,IAAa,SAAoB;AAAA,MAAlB;AAAEE,IAAAA;AAAF,GAAkB;AACxEA,EAAAA,QAAQ,CACNC,QADF,CACYL,gBADZ,EAEEM,GAFF,CAEOJ,KAFP,EAEc,mBAFd,EAEmC,IAFnC;AAGA,CAJM;AAMP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMM,OAAO,GAAG,CAAEN,KAAF,EAASO,IAAT,KAAmB,SAAoB;AAAA,MAAlB;AAAEL,IAAAA;AAAF,GAAkB;;AAC7D;AACA,MAAK,CAAEK,IAAP,EAAc;AACb;AACA;;AAED,QAAMC,WAAW,GAAGN,QAAQ,CAC1BO,MADkB,CACVX,gBADU,EAElBY,GAFkB,CAEbV,KAFa,EAEN,aAFM,CAApB,CAN6D,CAU7D;;AACA,MAAK,CAAAQ,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW,CAAID,IAAJ,CAAX,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AAA,QAAf;AAAEhB,MAAAA;AAAF,KAAe;AAChCN,IAAAA,UAAU,CAAG,8CAAH,EAAkD;AAC3DkB,MAAAA,KAAK,EAAE,KADoD;AAE3DC,MAAAA,WAAW,EAAG;AAF6C,KAAlD,CAAV;AAKAb,IAAAA,QAAQ,CACNC,QADF,CACYL,gBADZ,EAEEM,GAFF,CAEOJ,KAFP,EAEca,WAFd,EAE2B,CAAC,CAAEK,KAF9B;AAGA,GATD;AAUA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,kBAAT,CAA6BnB,KAA7B,EAAoCoB,QAApC,EAA+C;AACrD,SAAO,iBAA0B;AAAA,QAAf;AAAElB,MAAAA;AAAF,KAAe;AAChCN,IAAAA,UAAU,CAAG,iDAAH,EAAqD;AAC9DkB,MAAAA,KAAK,EAAE,KADuD;AAE9DC,MAAAA,WAAW,EAAG;AAFgD,KAArD,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( `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"]}
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,GAAG,CAAEH,KAAF,EAASC,IAAT,KAAmB,QAGnD;AAAA,MAHqD;AAC3DG,IAAAA,QAD2D;AAE3DC,IAAAA;AAF2D,GAGrD;;AACN;AACA,MAAK,CAAEJ,IAAP,EAAc;AACb;AACA;;AAED,QAAMK,0BAA0B,GAAGF,QAAQ,CACzCG,MADiC,CACzBT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MAAAA,WAAW,EAAG;AAF6C,KAAlD,CAAV;AAKAd,IAAAA,QAAQ,CACNC,QADF,CACYP,gBADZ,EAEEW,GAFF,CAEOT,KAFP,EAEcgB,WAFd,EAE2B,CAAC,CAAEK,KAF9B;AAGA,GATD;AAUA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,kBAAT,CAA6BtB,KAA7B,EAAoCuB,QAApC,EAA+C;AACrD,SAAO,iBAA0B;AAAA,QAAf;AAAEnB,MAAAA;AAAF,KAAe;AAChCR,IAAAA,UAAU,CAAG,iDAAH,EAAqD;AAC9DqB,MAAAA,KAAK,EAAE,KADuD;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 = ( scope, area ) => ( {\n\tregistry,\n\tdispatch,\n} ) => {\n\t// Return early if there's no area.\n\tif ( ! area ) {\n\t\treturn;\n\t}\n\n\tconst isComplementaryAreaVisible = registry\n\t\t.select( preferencesStore )\n\t\t.get( scope, 'isComplementaryAreaVisible' );\n\n\tif ( ! isComplementaryAreaVisible ) {\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( scope, 'isComplementaryAreaVisible', true );\n\t}\n\n\tdispatch( {\n\t\ttype: 'ENABLE_COMPLEMENTARY_AREA',\n\t\tscope,\n\t\tarea,\n\t} );\n};\n\n/**\n * Disable the complementary area.\n *\n * @param {string} scope Complementary area scope.\n */\nexport const disableComplementaryArea = ( scope ) => ( { registry } ) => {\n\tconst isComplementaryAreaVisible = registry\n\t\t.select( preferencesStore )\n\t\t.get( scope, 'isComplementaryAreaVisible' );\n\n\tif ( isComplementaryAreaVisible ) {\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( scope, 'isComplementaryAreaVisible', false );\n\t}\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( `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.
@@ -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,kEADQ,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`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"]}
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
  }
@@ -430,6 +429,8 @@ body.is-fullscreen-mode .interface-interface-skeleton {
430
429
 
431
430
  .interface-pinned-items {
432
431
  display: flex;
432
+ gap: 4px;
433
+ margin-left: -4px;
433
434
  }
434
435
  .interface-pinned-items .components-button:not(:first-child) {
435
436
  display: none;
@@ -440,7 +441,7 @@ body.is-fullscreen-mode .interface-interface-skeleton {
440
441
  }
441
442
  }
442
443
  .interface-pinned-items .components-button {
443
- margin-right: 4px;
444
+ margin: 0;
444
445
  }
445
446
  .interface-pinned-items .components-button svg {
446
447
  max-width: 24px;
@@ -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
  }
@@ -430,6 +429,8 @@ body.is-fullscreen-mode .interface-interface-skeleton {
430
429
 
431
430
  .interface-pinned-items {
432
431
  display: flex;
432
+ gap: 4px;
433
+ margin-right: -4px;
433
434
  }
434
435
  .interface-pinned-items .components-button:not(:first-child) {
435
436
  display: none;
@@ -440,7 +441,7 @@ body.is-fullscreen-mode .interface-interface-skeleton {
440
441
  }
441
442
  }
442
443
  .interface-pinned-items .components-button {
443
- margin-left: 4px;
444
+ margin: 0;
444
445
  }
445
446
  .interface-pinned-items .components-button svg {
446
447
  max-width: 24px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/interface",
3
- "version": "4.5.5",
3
+ "version": "4.8.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.6.1",
36
- "@wordpress/components": "^19.8.4",
37
- "@wordpress/compose": "^5.4.1",
38
- "@wordpress/data": "^6.6.1",
39
- "@wordpress/deprecated": "^3.6.1",
40
- "@wordpress/element": "^4.4.1",
41
- "@wordpress/i18n": "^4.6.1",
42
- "@wordpress/icons": "^8.2.2",
43
- "@wordpress/plugins": "^4.4.2",
44
- "@wordpress/preferences": "^1.2.4",
45
- "@wordpress/viewport": "^4.4.1",
35
+ "@wordpress/a11y": "^3.9.0",
36
+ "@wordpress/components": "^19.11.0",
37
+ "@wordpress/compose": "^5.7.0",
38
+ "@wordpress/data": "^6.9.0",
39
+ "@wordpress/deprecated": "^3.9.0",
40
+ "@wordpress/element": "^4.7.0",
41
+ "@wordpress/i18n": "^4.9.0",
42
+ "@wordpress/icons": "^9.0.0",
43
+ "@wordpress/plugins": "^4.7.0",
44
+ "@wordpress/preferences": "^2.1.0",
45
+ "@wordpress/viewport": "^4.7.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": "89fbea298119228eea3ebdc8d30e87033a497f43"
56
+ "gitHead": "198fa129cf1af8dc615918987ea6795cd40ab7df"
57
57
  }
@@ -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
 
@@ -11,8 +11,14 @@
11
11
  }
12
12
  }
13
13
 
14
+ // Gap between pinned items.
15
+ gap: $grid-unit-05;
16
+
17
+ // Account for larger grid from parent container gap.
18
+ margin-right: -$grid-unit-05;
19
+
14
20
  .components-button {
15
- margin-left: $grid-unit-05;
21
+ margin: 0;
16
22
 
17
23
  svg {
18
24
  max-width: $icon-size;
@@ -4,21 +4,50 @@
4
4
  import deprecated from '@wordpress/deprecated';
5
5
  import { store as preferencesStore } from '@wordpress/preferences';
6
6
 
7
+ /**
8
+ * Set a default complementary area.
9
+ *
10
+ * @param {string} scope Complementary area scope.
11
+ * @param {string} area Area identifier.
12
+ *
13
+ * @return {Object} Action object.
14
+ */
15
+ export const setDefaultComplementaryArea = ( scope, area ) => ( {
16
+ type: 'SET_DEFAULT_COMPLEMENTARY_AREA',
17
+ scope,
18
+ area,
19
+ } );
20
+
7
21
  /**
8
22
  * Enable the complementary area.
9
23
  *
10
24
  * @param {string} scope Complementary area scope.
11
25
  * @param {string} area Area identifier.
12
26
  */
13
- export const enableComplementaryArea = ( scope, area ) => ( { registry } ) => {
27
+ export const enableComplementaryArea = ( scope, area ) => ( {
28
+ registry,
29
+ dispatch,
30
+ } ) => {
14
31
  // Return early if there's no area.
15
32
  if ( ! area ) {
16
33
  return;
17
34
  }
18
35
 
19
- registry
20
- .dispatch( preferencesStore )
21
- .set( scope, 'complementaryArea', area );
36
+ const isComplementaryAreaVisible = registry
37
+ .select( preferencesStore )
38
+ .get( scope, 'isComplementaryAreaVisible' );
39
+
40
+ if ( ! isComplementaryAreaVisible ) {
41
+ registry
42
+ .dispatch( preferencesStore )
43
+ .set( scope, 'isComplementaryAreaVisible', true );
44
+ }
45
+
46
+ dispatch( {
47
+ type: 'ENABLE_COMPLEMENTARY_AREA',
48
+ scope,
49
+ area,
50
+ } );
22
51
  };
23
52
 
24
53
  /**
@@ -27,9 +56,15 @@ export const enableComplementaryArea = ( scope, area ) => ( { registry } ) => {
27
56
  * @param {string} scope Complementary area scope.
28
57
  */
29
58
  export const disableComplementaryArea = ( scope ) => ( { registry } ) => {
30
- registry
31
- .dispatch( preferencesStore )
32
- .set( scope, 'complementaryArea', null );
59
+ const isComplementaryAreaVisible = registry
60
+ .select( preferencesStore )
61
+ .get( scope, 'isComplementaryAreaVisible' );
62
+
63
+ if ( isComplementaryAreaVisible ) {
64
+ registry
65
+ .dispatch( preferencesStore )
66
+ .set( scope, 'isComplementaryAreaVisible', false );
67
+ }
33
68
  };
34
69
 
35
70
  /**
@@ -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
  } );
@@ -0,0 +1,35 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { combineReducers } from '@wordpress/data';
5
+
6
+ export function complementaryAreas( state = {}, action ) {
7
+ switch ( action.type ) {
8
+ case 'SET_DEFAULT_COMPLEMENTARY_AREA': {
9
+ const { scope, area } = action;
10
+
11
+ // If there's already an area, don't overwrite it.
12
+ if ( state[ scope ] ) {
13
+ return state;
14
+ }
15
+
16
+ return {
17
+ ...state,
18
+ [ scope ]: area,
19
+ };
20
+ }
21
+ case 'ENABLE_COMPLEMENTARY_AREA': {
22
+ const { scope, area } = action;
23
+ return {
24
+ ...state,
25
+ [ scope ]: area,
26
+ };
27
+ }
28
+ }
29
+
30
+ return state;
31
+ }
32
+
33
+ export default combineReducers( {
34
+ complementaryAreas,
35
+ } );
@@ -11,11 +11,28 @@ import { store as preferencesStore } from '@wordpress/preferences';
11
11
  * @param {Object} state Global application state.
12
12
  * @param {string} scope Item scope.
13
13
  *
14
- * @return {string} The complementary area that is active in the given scope.
14
+ * @return {string | null | undefined} The complementary area that is active in the given scope.
15
15
  */
16
16
  export const getActiveComplementaryArea = createRegistrySelector(
17
17
  ( select ) => ( state, scope ) => {
18
- return select( preferencesStore ).get( scope, 'complementaryArea' );
18
+ const isComplementaryAreaVisible = select( preferencesStore ).get(
19
+ scope,
20
+ 'isComplementaryAreaVisible'
21
+ );
22
+
23
+ // Return `undefined` to indicate that the user has never toggled
24
+ // visibility, this is the vanilla default. Other code relies on this
25
+ // nuance in the return value.
26
+ if ( isComplementaryAreaVisible === undefined ) {
27
+ return undefined;
28
+ }
29
+
30
+ // Return `null` to indicate the user hid the complementary area.
31
+ if ( ! isComplementaryAreaVisible ) {
32
+ return null;
33
+ }
34
+
35
+ return state?.complementaryAreas?.[ scope ];
19
36
  }
20
37
  );
21
38
 
@@ -54,7 +54,7 @@ describe( 'actions', () => {
54
54
  } );
55
55
 
56
56
  describe( 'disableComplementaryArea', () => {
57
- it( 'removes any assignment to a complementary area', () => {
57
+ it( 'results in the complementary area being inactive', () => {
58
58
  registry
59
59
  .dispatch( interfaceStore )
60
60
  .enableComplementaryArea( 'my-plugin', 'custom-sidebar' );