@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.
- package/CHANGELOG.md +6 -0
- package/build/components/action-item/index.js +4 -3
- package/build/components/action-item/index.js.map +1 -1
- package/build/components/complementary-area/index.js.map +1 -1
- package/build/components/complementary-area-toggle/index.js.map +1 -1
- package/build/store/actions.js +42 -10
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +5 -1
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +55 -0
- package/build/store/reducer.js.map +1 -0
- package/build/store/selectors.js +19 -4
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/action-item/index.js +3 -1
- package/build-module/components/action-item/index.js.map +1 -1
- package/build-module/components/complementary-area/index.js.map +1 -1
- package/build-module/components/complementary-area-toggle/index.js.map +1 -1
- package/build-module/store/actions.js +38 -9
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +2 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +43 -0
- package/build-module/store/reducer.js.map +1 -0
- package/build-module/store/selectors.js +19 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +0 -1
- package/build-style/style.css +0 -1
- package/package.json +13 -13
- package/src/components/action-item/index.js +3 -1
- package/src/components/complementary-area/index.js +6 -9
- package/src/components/complementary-area-toggle/index.js +2 -3
- package/src/components/more-menu-dropdown/style.scss +0 -1
- package/src/store/actions.js +96 -56
- package/src/store/index.js +2 -1
- package/src/store/reducer.js +35 -0
- package/src/store/selectors.js +21 -4
- 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.
|
|
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.
|
|
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(`
|
|
129
|
+
deprecated(`dispatch( 'core/interface' ).toggleFeature`, {
|
|
101
130
|
since: '6.0',
|
|
102
|
-
alternative: `
|
|
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(`
|
|
152
|
+
deprecated(`dispatch( 'core/interface' ).setFeatureValue`, {
|
|
124
153
|
since: '6.0',
|
|
125
|
-
alternative: `
|
|
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(`
|
|
173
|
+
deprecated(`dispatch( 'core/interface' ).setFeatureDefaults`, {
|
|
145
174
|
since: '6.0',
|
|
146
|
-
alternative: `
|
|
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","
|
|
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,IACA,SAAoB;AAAA,MAAlB;AAAEI,IAAAA;AAAF,GAAkB;AACnB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d,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","
|
|
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
|
-
|
|
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(`
|
|
62
|
+
deprecated(`select( 'core/interface' ).isFeatureActive( scope, featureName )`, {
|
|
48
63
|
since: '6.0',
|
|
49
|
-
alternative:
|
|
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,
|
|
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,i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G;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"]}
|
package/build-style/style.css
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/interface",
|
|
3
|
-
"version": "4.
|
|
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.
|
|
36
|
-
"@wordpress/components": "^19.
|
|
37
|
-
"@wordpress/compose": "^5.
|
|
38
|
-
"@wordpress/data": "^6.
|
|
39
|
-
"@wordpress/deprecated": "^3.
|
|
40
|
-
"@wordpress/element": "^4.
|
|
41
|
-
"@wordpress/i18n": "^4.
|
|
42
|
-
"@wordpress/icons": "^
|
|
43
|
-
"@wordpress/plugins": "^4.
|
|
44
|
-
"@wordpress/preferences": "^2.
|
|
45
|
-
"@wordpress/viewport": "^4.
|
|
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": "
|
|
56
|
+
"gitHead": "48d5f37dfb52d2e77c8eeb662f9874cf141b8c6b"
|
|
57
57
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { isEmpty
|
|
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 } =
|
|
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 } =
|
|
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 =
|
|
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 } =
|
|
34
|
-
interfaceStore
|
|
35
|
-
);
|
|
33
|
+
const { enableComplementaryArea, disableComplementaryArea } =
|
|
34
|
+
useDispatch( interfaceStore );
|
|
36
35
|
return (
|
|
37
36
|
<ComponentToUse
|
|
38
37
|
icon={ selectedIcon && isSelected ? selectedIcon : icon }
|
package/src/store/actions.js
CHANGED
|
@@ -5,32 +5,68 @@ import deprecated from '@wordpress/deprecated';
|
|
|
5
5
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
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
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
export const setDefaultComplementaryArea = ( scope, area ) => ( {
|
|
16
|
+
type: 'SET_DEFAULT_COMPLEMENTARY_AREA',
|
|
17
|
+
scope,
|
|
18
|
+
area,
|
|
19
|
+
} );
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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 =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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 =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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 =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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( `
|
|
134
|
+
deprecated( `dispatch( 'core/interface' ).toggleFeature`, {
|
|
95
135
|
since: '6.0',
|
|
96
|
-
alternative: `
|
|
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( `
|
|
155
|
+
deprecated( `dispatch( 'core/interface' ).setFeatureValue`, {
|
|
116
156
|
since: '6.0',
|
|
117
|
-
alternative: `
|
|
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( `
|
|
176
|
+
deprecated( `dispatch( 'core/interface' ).setFeatureDefaults`, {
|
|
137
177
|
since: '6.0',
|
|
138
|
-
alternative: `
|
|
178
|
+
alternative: `dispatch( 'core/preferences' ).setDefaults`,
|
|
139
179
|
} );
|
|
140
180
|
|
|
141
181
|
registry.dispatch( preferencesStore ).setDefaults( scope, defaults );
|
package/src/store/index.js
CHANGED
|
@@ -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
|
} );
|