@wordpress/interface 4.3.1 → 4.5.1
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 +4 -0
- package/build/store/actions.js +103 -81
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +7 -13
- package/build/store/index.js.map +1 -1
- package/build/store/selectors.js +27 -48
- package/build/store/selectors.js.map +1 -1
- package/build-module/store/actions.js +87 -75
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +7 -10
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/selectors.js +19 -43
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +1 -1
- package/build-style/style.css +1 -1
- package/package.json +13 -11
- package/src/store/actions.js +83 -72
- package/src/store/index.js +7 -11
- package/src/store/selectors.js +30 -50
- package/src/store/test/actions.js +259 -0
- package/build/store/reducer.js +0 -172
- package/build/store/reducer.js.map +0 -1
- package/build-module/store/reducer.js +0 -153
- package/build-module/store/reducer.js.map +0 -1
- package/src/store/reducer.js +0 -143
- package/src/store/test/selectors.js +0 -107
|
@@ -1,89 +1,90 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @param {string} itemType Type of item.
|
|
5
|
-
* @param {string} scope Item scope.
|
|
6
|
-
* @param {string} item Item identifier.
|
|
7
|
-
*
|
|
8
|
-
* @return {Object} Action object.
|
|
2
|
+
* WordPress dependencies
|
|
9
3
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type: 'SET_SINGLE_ENABLE_ITEM',
|
|
13
|
-
itemType,
|
|
14
|
-
scope,
|
|
15
|
-
item
|
|
16
|
-
};
|
|
17
|
-
}
|
|
4
|
+
import deprecated from '@wordpress/deprecated';
|
|
5
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
18
6
|
/**
|
|
19
|
-
*
|
|
7
|
+
* Enable the complementary area.
|
|
20
8
|
*
|
|
21
9
|
* @param {string} scope Complementary area scope.
|
|
22
10
|
* @param {string} area Area identifier.
|
|
23
|
-
*
|
|
24
|
-
* @return {Object} Action object.
|
|
25
11
|
*/
|
|
26
12
|
|
|
13
|
+
export const enableComplementaryArea = (scope, area) => _ref => {
|
|
14
|
+
let {
|
|
15
|
+
registry
|
|
16
|
+
} = _ref;
|
|
27
17
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
// Return early if there's no area.
|
|
19
|
+
if (!area) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
registry.dispatch(preferencesStore).set(scope, 'complementaryArea', area);
|
|
24
|
+
};
|
|
31
25
|
/**
|
|
32
|
-
*
|
|
26
|
+
* Disable the complementary area.
|
|
33
27
|
*
|
|
34
28
|
* @param {string} scope Complementary area scope.
|
|
35
|
-
*
|
|
36
|
-
* @return {Object} Action object.
|
|
37
29
|
*/
|
|
38
30
|
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
export const disableComplementaryArea = scope => _ref2 => {
|
|
32
|
+
let {
|
|
33
|
+
registry
|
|
34
|
+
} = _ref2;
|
|
35
|
+
registry.dispatch(preferencesStore).set(scope, 'complementaryArea', null);
|
|
36
|
+
};
|
|
42
37
|
/**
|
|
43
|
-
*
|
|
38
|
+
* Pins an item.
|
|
44
39
|
*
|
|
45
|
-
* @param {string}
|
|
46
|
-
* @param {string}
|
|
47
|
-
* @param {string} item Item identifier.
|
|
48
|
-
* @param {boolean} isEnable Boolean indicating if an area should be pinned or not.
|
|
40
|
+
* @param {string} scope Item scope.
|
|
41
|
+
* @param {string} item Item identifier.
|
|
49
42
|
*
|
|
50
43
|
* @return {Object} Action object.
|
|
51
44
|
*/
|
|
52
45
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
scope,
|
|
58
|
-
item,
|
|
59
|
-
isEnable
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Returns an action object used in signalling that an item should be pinned.
|
|
64
|
-
*
|
|
65
|
-
* @param {string} scope Item scope.
|
|
66
|
-
* @param {string} itemId Item identifier.
|
|
67
|
-
*
|
|
68
|
-
* @return {Object} Action object.
|
|
69
|
-
*/
|
|
46
|
+
export const pinItem = (scope, item) => _ref3 => {
|
|
47
|
+
let {
|
|
48
|
+
registry
|
|
49
|
+
} = _ref3;
|
|
70
50
|
|
|
51
|
+
// Return early if there's no item.
|
|
52
|
+
if (!item) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
71
55
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
56
|
+
const pinnedItems = registry.select(preferencesStore).get(scope, 'pinnedItems'); // The item is already pinned, there's nothing to do.
|
|
57
|
+
|
|
58
|
+
if ((pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) === true) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
registry.dispatch(preferencesStore).set(scope, 'pinnedItems', { ...pinnedItems,
|
|
63
|
+
[item]: true
|
|
64
|
+
});
|
|
65
|
+
};
|
|
75
66
|
/**
|
|
76
|
-
*
|
|
67
|
+
* Unpins an item.
|
|
77
68
|
*
|
|
78
|
-
* @param {string} scope
|
|
79
|
-
* @param {string}
|
|
80
|
-
*
|
|
81
|
-
* @return {Object} Action object.
|
|
69
|
+
* @param {string} scope Item scope.
|
|
70
|
+
* @param {string} item Item identifier.
|
|
82
71
|
*/
|
|
83
72
|
|
|
84
|
-
export
|
|
85
|
-
|
|
86
|
-
|
|
73
|
+
export const unpinItem = (scope, item) => _ref4 => {
|
|
74
|
+
let {
|
|
75
|
+
registry
|
|
76
|
+
} = _ref4;
|
|
77
|
+
|
|
78
|
+
// Return early if there's no item.
|
|
79
|
+
if (!item) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const pinnedItems = registry.select(preferencesStore).get(scope, 'pinnedItems');
|
|
84
|
+
registry.dispatch(preferencesStore).set(scope, 'pinnedItems', { ...pinnedItems,
|
|
85
|
+
[item]: false
|
|
86
|
+
});
|
|
87
|
+
};
|
|
87
88
|
/**
|
|
88
89
|
* Returns an action object used in signalling that a feature should be toggled.
|
|
89
90
|
*
|
|
@@ -92,13 +93,15 @@ export function unpinItem(scope, itemId) {
|
|
|
92
93
|
*/
|
|
93
94
|
|
|
94
95
|
export function toggleFeature(scope, featureName) {
|
|
95
|
-
return function (
|
|
96
|
+
return function (_ref5) {
|
|
96
97
|
let {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
registry
|
|
99
|
+
} = _ref5;
|
|
100
|
+
deprecated(`wp.dispatch( 'core/interface' ).toggleFeature`, {
|
|
101
|
+
since: '6.0',
|
|
102
|
+
alternative: `wp.dispatch( 'core/preferences' ).toggle`
|
|
103
|
+
});
|
|
104
|
+
registry.dispatch(preferencesStore).toggle(scope, featureName);
|
|
102
105
|
};
|
|
103
106
|
}
|
|
104
107
|
/**
|
|
@@ -113,11 +116,15 @@ export function toggleFeature(scope, featureName) {
|
|
|
113
116
|
*/
|
|
114
117
|
|
|
115
118
|
export function setFeatureValue(scope, featureName, value) {
|
|
116
|
-
return {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
return function (_ref6) {
|
|
120
|
+
let {
|
|
121
|
+
registry
|
|
122
|
+
} = _ref6;
|
|
123
|
+
deprecated(`wp.dispatch( 'core/interface' ).setFeatureValue`, {
|
|
124
|
+
since: '6.0',
|
|
125
|
+
alternative: `wp.dispatch( 'core/preferences' ).set`
|
|
126
|
+
});
|
|
127
|
+
registry.dispatch(preferencesStore).set(scope, featureName, !!value);
|
|
121
128
|
};
|
|
122
129
|
}
|
|
123
130
|
/**
|
|
@@ -130,10 +137,15 @@ export function setFeatureValue(scope, featureName, value) {
|
|
|
130
137
|
*/
|
|
131
138
|
|
|
132
139
|
export function setFeatureDefaults(scope, defaults) {
|
|
133
|
-
return {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
140
|
+
return function (_ref7) {
|
|
141
|
+
let {
|
|
142
|
+
registry
|
|
143
|
+
} = _ref7;
|
|
144
|
+
deprecated(`wp.dispatch( 'core/interface' ).setFeatureDefaults`, {
|
|
145
|
+
since: '6.0',
|
|
146
|
+
alternative: `wp.dispatch( 'core/preferences' ).setDefaults`
|
|
147
|
+
});
|
|
148
|
+
registry.dispatch(preferencesStore).setDefaults(scope, defaults);
|
|
137
149
|
};
|
|
138
150
|
}
|
|
139
151
|
//# sourceMappingURL=actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/interface/src/store/actions.js"],"names":["
|
|
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,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ress/deprecated';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Enable the complementary area.\n *\n * @param {string} scope Complementary area scope.\n * @param {string} area Area identifier.\n */\nexport const enableComplementaryArea = ( scope, area ) => ( { registry } ) => {\n\t// Return early if there's no area.\n\tif ( ! area ) {\n\t\treturn;\n\t}\n\n\tregistry\n\t\t.dispatch( preferencesStore )\n\t\t.set( scope, 'complementaryArea', area );\n};\n\n/**\n * Disable the complementary area.\n *\n * @param {string} scope Complementary area scope.\n */\nexport const disableComplementaryArea = ( scope ) => ( { registry } ) => {\n\tregistry\n\t\t.dispatch( preferencesStore )\n\t\t.set( scope, 'complementaryArea', null );\n};\n\n/**\n * Pins an item.\n *\n * @param {string} scope Item scope.\n * @param {string} item Item identifier.\n *\n * @return {Object} Action object.\n */\nexport const pinItem = ( scope, item ) => ( { registry } ) => {\n\t// Return early if there's no item.\n\tif ( ! item ) {\n\t\treturn;\n\t}\n\n\tconst pinnedItems = registry\n\t\t.select( preferencesStore )\n\t\t.get( scope, 'pinnedItems' );\n\n\t// The item is already pinned, there's nothing to do.\n\tif ( pinnedItems?.[ item ] === true ) {\n\t\treturn;\n\t}\n\n\tregistry.dispatch( preferencesStore ).set( scope, 'pinnedItems', {\n\t\t...pinnedItems,\n\t\t[ item ]: true,\n\t} );\n};\n\n/**\n * Unpins an item.\n *\n * @param {string} scope Item scope.\n * @param {string} item Item identifier.\n */\nexport const unpinItem = ( scope, item ) => ( { registry } ) => {\n\t// Return early if there's no item.\n\tif ( ! item ) {\n\t\treturn;\n\t}\n\n\tconst pinnedItems = registry\n\t\t.select( preferencesStore )\n\t\t.get( scope, 'pinnedItems' );\n\n\tregistry.dispatch( preferencesStore ).set( scope, 'pinnedItems', {\n\t\t...pinnedItems,\n\t\t[ item ]: false,\n\t} );\n};\n\n/**\n * Returns an action object used in signalling that a feature should be toggled.\n *\n * @param {string} scope The feature scope (e.g. core/edit-post).\n * @param {string} featureName The feature name.\n */\nexport function toggleFeature( scope, featureName ) {\n\treturn function ( { registry } ) {\n\t\tdeprecated( `wp.dispatch( 'core/interface' ).toggleFeature`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `wp.dispatch( 'core/preferences' ).toggle`,\n\t\t} );\n\n\t\tregistry.dispatch( preferencesStore ).toggle( scope, featureName );\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a feature should be set to\n * a true or false value\n *\n * @param {string} scope The feature scope (e.g. core/edit-post).\n * @param {string} featureName The feature name.\n * @param {boolean} value The value to set.\n *\n * @return {Object} Action object.\n */\nexport function setFeatureValue( scope, featureName, value ) {\n\treturn function ( { registry } ) {\n\t\tdeprecated( `wp.dispatch( 'core/interface' ).setFeatureValue`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `wp.dispatch( 'core/preferences' ).set`,\n\t\t} );\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( scope, featureName, !! value );\n\t};\n}\n\n/**\n * Returns an action object used in signalling that defaults should be set for features.\n *\n * @param {string} scope The feature scope (e.g. core/edit-post).\n * @param {Object<string, boolean>} defaults A key/value map of feature names to values.\n *\n * @return {Object} Action object.\n */\nexport function setFeatureDefaults( scope, defaults ) {\n\treturn function ( { registry } ) {\n\t\tdeprecated( `wp.dispatch( 'core/interface' ).setFeatureDefaults`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `wp.dispatch( 'core/preferences' ).setDefaults`,\n\t\t} );\n\n\t\tregistry.dispatch( preferencesStore ).setDefaults( scope, defaults );\n\t};\n}\n"]}
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { createReduxStore,
|
|
4
|
+
import { createReduxStore, register } from '@wordpress/data';
|
|
5
5
|
/**
|
|
6
6
|
* Internal dependencies
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import reducer from './reducer';
|
|
10
9
|
import * as actions from './actions';
|
|
11
10
|
import * as selectors from './selectors';
|
|
12
11
|
import { STORE_NAME } from './constants';
|
|
13
|
-
const storeConfig = {
|
|
14
|
-
reducer,
|
|
15
|
-
actions,
|
|
16
|
-
selectors,
|
|
17
|
-
persist: ['enableItems', 'preferences']
|
|
18
|
-
};
|
|
19
12
|
/**
|
|
20
13
|
* Store definition for the interface namespace.
|
|
21
14
|
*
|
|
@@ -24,8 +17,12 @@ const storeConfig = {
|
|
|
24
17
|
* @type {Object}
|
|
25
18
|
*/
|
|
26
19
|
|
|
27
|
-
export const store = createReduxStore(STORE_NAME,
|
|
20
|
+
export const store = createReduxStore(STORE_NAME, {
|
|
21
|
+
reducer: () => {},
|
|
22
|
+
actions,
|
|
23
|
+
selectors
|
|
24
|
+
}); // Once we build a more generic persistence plugin that works across types of stores
|
|
28
25
|
// we'd be able to replace this with a register call.
|
|
29
26
|
|
|
30
|
-
|
|
27
|
+
register(store);
|
|
31
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/interface/src/store/index.js"],"names":["createReduxStore","
|
|
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,20 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* @param {Object} state Global application state.
|
|
9
|
-
* @param {string} itemType Type of item.
|
|
10
|
-
* @param {string} scope Item scope.
|
|
11
|
-
*
|
|
12
|
-
* @return {?string|null} The item that is enabled in the passed scope and type.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
function getSingleEnableItem(state, itemType, scope) {
|
|
16
|
-
return get(state.enableItems.singleEnableItems, [itemType, scope]);
|
|
17
|
-
}
|
|
4
|
+
import { createRegistrySelector } from '@wordpress/data';
|
|
5
|
+
import deprecated from '@wordpress/deprecated';
|
|
6
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
18
7
|
/**
|
|
19
8
|
* Returns the complementary area that is active in a given scope.
|
|
20
9
|
*
|
|
@@ -24,24 +13,9 @@ function getSingleEnableItem(state, itemType, scope) {
|
|
|
24
13
|
* @return {string} The complementary area that is active in the given scope.
|
|
25
14
|
*/
|
|
26
15
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Returns a boolean indicating if an item is enabled or not in a given scope.
|
|
33
|
-
*
|
|
34
|
-
* @param {Object} state Global application state.
|
|
35
|
-
* @param {string} itemType Type of item.
|
|
36
|
-
* @param {string} scope Scope.
|
|
37
|
-
* @param {string} item Item to check.
|
|
38
|
-
*
|
|
39
|
-
* @return {boolean|undefined} True if the item is enabled, false otherwise if the item is explicitly disabled, and undefined if there is no information for that item.
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
function isMultipleEnabledItemEnabled(state, itemType, scope, item) {
|
|
43
|
-
return get(state.enableItems.multipleEnableItems, [itemType, scope, item]);
|
|
44
|
-
}
|
|
16
|
+
export const getActiveComplementaryArea = createRegistrySelector(select => (state, scope) => {
|
|
17
|
+
return select(preferencesStore).get(scope, 'complementaryArea');
|
|
18
|
+
});
|
|
45
19
|
/**
|
|
46
20
|
* Returns a boolean indicating if an item is pinned or not.
|
|
47
21
|
*
|
|
@@ -52,10 +26,12 @@ function isMultipleEnabledItemEnabled(state, itemType, scope, item) {
|
|
|
52
26
|
* @return {boolean} True if the item is pinned and false otherwise.
|
|
53
27
|
*/
|
|
54
28
|
|
|
29
|
+
export const isItemPinned = createRegistrySelector(select => (state, scope, item) => {
|
|
30
|
+
var _pinnedItems$item;
|
|
55
31
|
|
|
56
|
-
|
|
57
|
-
return
|
|
58
|
-
}
|
|
32
|
+
const pinnedItems = select(preferencesStore).get(scope, 'pinnedItems');
|
|
33
|
+
return (_pinnedItems$item = pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) !== null && _pinnedItems$item !== void 0 ? _pinnedItems$item : true;
|
|
34
|
+
});
|
|
59
35
|
/**
|
|
60
36
|
* Returns a boolean indicating whether a feature is active for a particular
|
|
61
37
|
* scope.
|
|
@@ -67,11 +43,11 @@ export function isItemPinned(state, scope, item) {
|
|
|
67
43
|
* @return {boolean} Is the feature enabled?
|
|
68
44
|
*/
|
|
69
45
|
|
|
70
|
-
export
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return !!
|
|
76
|
-
}
|
|
46
|
+
export const isFeatureActive = createRegistrySelector(select => (state, scope, featureName) => {
|
|
47
|
+
deprecated(`wp.select( 'core/interface' ).isFeatureActive( scope, featureName )`, {
|
|
48
|
+
since: '6.0',
|
|
49
|
+
alternative: `!! wp.select( 'core/preferences' ).isFeatureActive( scope, featureName )`
|
|
50
|
+
});
|
|
51
|
+
return !!select(preferencesStore).get(scope, featureName);
|
|
52
|
+
});
|
|
77
53
|
//# sourceMappingURL=selectors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/interface/src/store/selectors.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/interface/src/store/selectors.js"],"names":["createRegistrySelector","deprecated","store","preferencesStore","getActiveComplementaryArea","select","state","scope","get","isItemPinned","item","pinnedItems","isFeatureActive","featureName","since","alternative"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAT,QAAuC,iBAAvC;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,0BAA0B,GAAGJ,sBAAsB,CAC7DK,MAAF,IAAc,CAAEC,KAAF,EAASC,KAAT,KAAoB;AACjC,SAAOF,MAAM,CAAEF,gBAAF,CAAN,CAA2BK,GAA3B,CAAgCD,KAAhC,EAAuC,mBAAvC,CAAP;AACA,CAH8D,CAAzD;AAMP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAME,YAAY,GAAGT,sBAAsB,CAC/CK,MAAF,IAAc,CAAEC,KAAF,EAASC,KAAT,EAAgBG,IAAhB,KAA0B;AAAA;;AACvC,QAAMC,WAAW,GAAGN,MAAM,CAAEF,gBAAF,CAAN,CAA2BK,GAA3B,CACnBD,KADmB,EAEnB,aAFmB,CAApB;AAIA,8BAAOI,WAAP,aAAOA,WAAP,uBAAOA,WAAW,CAAID,IAAJ,CAAlB,iEAAgC,IAAhC;AACA,CAPgD,CAA3C;AAUP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAME,eAAe,GAAGZ,sBAAsB,CAClDK,MAAF,IAAc,CAAEC,KAAF,EAASC,KAAT,EAAgBM,WAAhB,KAAiC;AAC9CZ,EAAAA,UAAU,CACR,qEADQ,EAET;AACCa,IAAAA,KAAK,EAAE,KADR;AAECC,IAAAA,WAAW,EAAG;AAFf,GAFS,CAAV;AAQA,SAAO,CAAC,CAAEV,MAAM,CAAEF,gBAAF,CAAN,CAA2BK,GAA3B,CAAgCD,KAAhC,EAAuCM,WAAvC,CAAV;AACA,CAXmD,CAA9C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Returns the complementary area that is active in a given scope.\n *\n * @param {Object} state Global application state.\n * @param {string} scope Item scope.\n *\n * @return {string} The complementary area that is active in the given scope.\n */\nexport const getActiveComplementaryArea = createRegistrySelector(\n\t( select ) => ( state, scope ) => {\n\t\treturn select( preferencesStore ).get( scope, 'complementaryArea' );\n\t}\n);\n\n/**\n * Returns a boolean indicating if an item is pinned or not.\n *\n * @param {Object} state Global application state.\n * @param {string} scope Scope.\n * @param {string} item Item to check.\n *\n * @return {boolean} True if the item is pinned and false otherwise.\n */\nexport const isItemPinned = createRegistrySelector(\n\t( select ) => ( state, scope, item ) => {\n\t\tconst pinnedItems = select( preferencesStore ).get(\n\t\t\tscope,\n\t\t\t'pinnedItems'\n\t\t);\n\t\treturn pinnedItems?.[ item ] ?? true;\n\t}\n);\n\n/**\n * Returns a boolean indicating whether a feature is active for a particular\n * scope.\n *\n * @param {Object} state The store state.\n * @param {string} scope The scope of the feature (e.g. core/edit-post).\n * @param {string} featureName The name of the feature.\n *\n * @return {boolean} Is the feature enabled?\n */\nexport const isFeatureActive = createRegistrySelector(\n\t( select ) => ( state, scope, featureName ) => {\n\t\tdeprecated(\n\t\t\t`wp.select( 'core/interface' ).isFeatureActive( scope, featureName )`,\n\t\t\t{\n\t\t\t\tsince: '6.0',\n\t\t\t\talternative: `!! wp.select( 'core/preferences' ).isFeatureActive( scope, featureName )`,\n\t\t\t}\n\t\t);\n\n\t\treturn !! select( preferencesStore ).get( scope, featureName );\n\t}\n);\n"]}
|
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.5.1",
|
|
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,15 +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/
|
|
40
|
-
"@wordpress/
|
|
41
|
-
"@wordpress/
|
|
42
|
-
"@wordpress/
|
|
43
|
-
"@wordpress/
|
|
35
|
+
"@wordpress/a11y": "^3.6.1",
|
|
36
|
+
"@wordpress/components": "^19.8.1",
|
|
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.1",
|
|
43
|
+
"@wordpress/plugins": "^4.4.1",
|
|
44
|
+
"@wordpress/preferences": "^1.2.1",
|
|
45
|
+
"@wordpress/viewport": "^4.4.1",
|
|
44
46
|
"classnames": "^2.3.1",
|
|
45
47
|
"lodash": "^4.17.21"
|
|
46
48
|
},
|
|
@@ -51,5 +53,5 @@
|
|
|
51
53
|
"publishConfig": {
|
|
52
54
|
"access": "public"
|
|
53
55
|
},
|
|
54
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "446565ecaa40370173c18926535e975ec5652b71"
|
|
55
57
|
}
|