@wordpress/interface 4.4.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/store/actions.js +75 -74
- 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 +11 -45
- package/build/store/selectors.js.map +1 -1
- package/build-module/store/actions.js +64 -69
- 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 +8 -39
- package/build-module/store/selectors.js.map +1 -1
- package/package.json +13 -13
- package/src/store/actions.js +57 -63
- package/src/store/index.js +7 -11
- package/src/store/selectors.js +14 -45
- package/src/store/test/actions.js +135 -0
- package/build/store/reducer.js +0 -103
- package/build/store/reducer.js.map +0 -1
- package/build-module/store/reducer.js +0 -87
- package/build-module/store/reducer.js.map +0 -1
- package/src/store/reducer.js +0 -88
package/CHANGELOG.md
CHANGED
package/build/store/actions.js
CHANGED
|
@@ -5,13 +5,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.disableComplementaryArea =
|
|
9
|
-
exports.enableComplementaryArea = enableComplementaryArea;
|
|
10
|
-
exports.pinItem = pinItem;
|
|
8
|
+
exports.pinItem = exports.enableComplementaryArea = exports.disableComplementaryArea = void 0;
|
|
11
9
|
exports.setFeatureDefaults = setFeatureDefaults;
|
|
12
10
|
exports.setFeatureValue = setFeatureValue;
|
|
13
11
|
exports.toggleFeature = toggleFeature;
|
|
14
|
-
exports.unpinItem =
|
|
12
|
+
exports.unpinItem = void 0;
|
|
15
13
|
|
|
16
14
|
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
|
17
15
|
|
|
@@ -22,94 +20,95 @@ var _preferences = require("@wordpress/preferences");
|
|
|
22
20
|
*/
|
|
23
21
|
|
|
24
22
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* @param {string} itemType Type of item.
|
|
28
|
-
* @param {string} scope Item scope.
|
|
29
|
-
* @param {string} item Item identifier.
|
|
30
|
-
*
|
|
31
|
-
* @return {Object} Action object.
|
|
32
|
-
*/
|
|
33
|
-
function setSingleEnableItem(itemType, scope, item) {
|
|
34
|
-
return {
|
|
35
|
-
type: 'SET_SINGLE_ENABLE_ITEM',
|
|
36
|
-
itemType,
|
|
37
|
-
scope,
|
|
38
|
-
item
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Returns an action object used in signalling that a complementary item should be enabled.
|
|
23
|
+
* Enable the complementary area.
|
|
43
24
|
*
|
|
44
25
|
* @param {string} scope Complementary area scope.
|
|
45
26
|
* @param {string} area Area identifier.
|
|
46
|
-
*
|
|
47
|
-
* @return {Object} Action object.
|
|
48
27
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
28
|
+
const enableComplementaryArea = (scope, area) => _ref => {
|
|
29
|
+
let {
|
|
30
|
+
registry
|
|
31
|
+
} = _ref;
|
|
32
|
+
|
|
33
|
+
// Return early if there's no area.
|
|
34
|
+
if (!area) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
registry.dispatch(_preferences.store).set(scope, 'complementaryArea', area);
|
|
39
|
+
};
|
|
54
40
|
/**
|
|
55
|
-
*
|
|
41
|
+
* Disable the complementary area.
|
|
56
42
|
*
|
|
57
43
|
* @param {string} scope Complementary area scope.
|
|
58
|
-
*
|
|
59
|
-
* @return {Object} Action object.
|
|
60
44
|
*/
|
|
61
45
|
|
|
62
46
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
47
|
+
exports.enableComplementaryArea = enableComplementaryArea;
|
|
48
|
+
|
|
49
|
+
const disableComplementaryArea = scope => _ref2 => {
|
|
50
|
+
let {
|
|
51
|
+
registry
|
|
52
|
+
} = _ref2;
|
|
53
|
+
registry.dispatch(_preferences.store).set(scope, 'complementaryArea', null);
|
|
54
|
+
};
|
|
66
55
|
/**
|
|
67
|
-
*
|
|
56
|
+
* Pins an item.
|
|
68
57
|
*
|
|
69
|
-
* @param {string}
|
|
70
|
-
* @param {string}
|
|
71
|
-
* @param {string} item Item identifier.
|
|
72
|
-
* @param {boolean} isEnable Boolean indicating if an area should be pinned or not.
|
|
58
|
+
* @param {string} scope Item scope.
|
|
59
|
+
* @param {string} item Item identifier.
|
|
73
60
|
*
|
|
74
61
|
* @return {Object} Action object.
|
|
75
62
|
*/
|
|
76
63
|
|
|
77
64
|
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
type: 'SET_MULTIPLE_ENABLE_ITEM',
|
|
81
|
-
itemType,
|
|
82
|
-
scope,
|
|
83
|
-
item,
|
|
84
|
-
isEnable
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Returns an action object used in signalling that an item should be pinned.
|
|
89
|
-
*
|
|
90
|
-
* @param {string} scope Item scope.
|
|
91
|
-
* @param {string} itemId Item identifier.
|
|
92
|
-
*
|
|
93
|
-
* @return {Object} Action object.
|
|
94
|
-
*/
|
|
65
|
+
exports.disableComplementaryArea = disableComplementaryArea;
|
|
95
66
|
|
|
67
|
+
const pinItem = (scope, item) => _ref3 => {
|
|
68
|
+
let {
|
|
69
|
+
registry
|
|
70
|
+
} = _ref3;
|
|
96
71
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
72
|
+
// Return early if there's no item.
|
|
73
|
+
if (!item) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const pinnedItems = registry.select(_preferences.store).get(scope, 'pinnedItems'); // The item is already pinned, there's nothing to do.
|
|
78
|
+
|
|
79
|
+
if ((pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) === true) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
registry.dispatch(_preferences.store).set(scope, 'pinnedItems', { ...pinnedItems,
|
|
84
|
+
[item]: true
|
|
85
|
+
});
|
|
86
|
+
};
|
|
100
87
|
/**
|
|
101
|
-
*
|
|
88
|
+
* Unpins an item.
|
|
102
89
|
*
|
|
103
|
-
* @param {string} scope
|
|
104
|
-
* @param {string}
|
|
105
|
-
*
|
|
106
|
-
* @return {Object} Action object.
|
|
90
|
+
* @param {string} scope Item scope.
|
|
91
|
+
* @param {string} item Item identifier.
|
|
107
92
|
*/
|
|
108
93
|
|
|
109
94
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
95
|
+
exports.pinItem = pinItem;
|
|
96
|
+
|
|
97
|
+
const unpinItem = (scope, item) => _ref4 => {
|
|
98
|
+
let {
|
|
99
|
+
registry
|
|
100
|
+
} = _ref4;
|
|
101
|
+
|
|
102
|
+
// Return early if there's no item.
|
|
103
|
+
if (!item) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const pinnedItems = registry.select(_preferences.store).get(scope, 'pinnedItems');
|
|
108
|
+
registry.dispatch(_preferences.store).set(scope, 'pinnedItems', { ...pinnedItems,
|
|
109
|
+
[item]: false
|
|
110
|
+
});
|
|
111
|
+
};
|
|
113
112
|
/**
|
|
114
113
|
* Returns an action object used in signalling that a feature should be toggled.
|
|
115
114
|
*
|
|
@@ -118,11 +117,13 @@ function unpinItem(scope, itemId) {
|
|
|
118
117
|
*/
|
|
119
118
|
|
|
120
119
|
|
|
120
|
+
exports.unpinItem = unpinItem;
|
|
121
|
+
|
|
121
122
|
function toggleFeature(scope, featureName) {
|
|
122
|
-
return function (
|
|
123
|
+
return function (_ref5) {
|
|
123
124
|
let {
|
|
124
125
|
registry
|
|
125
|
-
} =
|
|
126
|
+
} = _ref5;
|
|
126
127
|
(0, _deprecated.default)(`wp.dispatch( 'core/interface' ).toggleFeature`, {
|
|
127
128
|
since: '6.0',
|
|
128
129
|
alternative: `wp.dispatch( 'core/preferences' ).toggle`
|
|
@@ -143,10 +144,10 @@ function toggleFeature(scope, featureName) {
|
|
|
143
144
|
|
|
144
145
|
|
|
145
146
|
function setFeatureValue(scope, featureName, value) {
|
|
146
|
-
return function (
|
|
147
|
+
return function (_ref6) {
|
|
147
148
|
let {
|
|
148
149
|
registry
|
|
149
|
-
} =
|
|
150
|
+
} = _ref6;
|
|
150
151
|
(0, _deprecated.default)(`wp.dispatch( 'core/interface' ).setFeatureValue`, {
|
|
151
152
|
since: '6.0',
|
|
152
153
|
alternative: `wp.dispatch( 'core/preferences' ).set`
|
|
@@ -165,10 +166,10 @@ function setFeatureValue(scope, featureName, value) {
|
|
|
165
166
|
|
|
166
167
|
|
|
167
168
|
function setFeatureDefaults(scope, defaults) {
|
|
168
|
-
return function (
|
|
169
|
+
return function (_ref7) {
|
|
169
170
|
let {
|
|
170
171
|
registry
|
|
171
|
-
} =
|
|
172
|
+
} = _ref7;
|
|
172
173
|
(0, _deprecated.default)(`wp.dispatch( 'core/interface' ).setFeatureDefaults`, {
|
|
173
174
|
since: '6.0',
|
|
174
175
|
alternative: `wp.dispatch( 'core/preferences' ).setDefaults`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/interface/src/store/actions.js"],"names":["
|
|
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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AA,KAAK,EAAE,KAD0D;AAEjEC,MAAAA,WAAW,EAAG;AAFmD,KAAlE;AAKAd,IAAAA,QAAQ,CAACC,QAAT,CAAmBC,kBAAnB,EAAsCkB,WAAtC,CAAmDtB,KAAnD,EAA0DqB,QAA1D;AACA,GAPD;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Enable the complementary area.\n *\n * @param {string} scope Complementary area scope.\n * @param {string} area Area identifier.\n */\nexport const enableComplementaryArea = ( scope, area ) => ( { registry } ) => {\n\t// Return early if there's no area.\n\tif ( ! area ) {\n\t\treturn;\n\t}\n\n\tregistry\n\t\t.dispatch( preferencesStore )\n\t\t.set( scope, 'complementaryArea', area );\n};\n\n/**\n * Disable the complementary area.\n *\n * @param {string} scope Complementary area scope.\n */\nexport const disableComplementaryArea = ( scope ) => ( { registry } ) => {\n\tregistry\n\t\t.dispatch( preferencesStore )\n\t\t.set( scope, 'complementaryArea', null );\n};\n\n/**\n * Pins an item.\n *\n * @param {string} scope Item scope.\n * @param {string} item Item identifier.\n *\n * @return {Object} Action object.\n */\nexport const pinItem = ( scope, item ) => ( { registry } ) => {\n\t// Return early if there's no item.\n\tif ( ! item ) {\n\t\treturn;\n\t}\n\n\tconst pinnedItems = registry\n\t\t.select( preferencesStore )\n\t\t.get( scope, 'pinnedItems' );\n\n\t// The item is already pinned, there's nothing to do.\n\tif ( pinnedItems?.[ item ] === true ) {\n\t\treturn;\n\t}\n\n\tregistry.dispatch( preferencesStore ).set( scope, 'pinnedItems', {\n\t\t...pinnedItems,\n\t\t[ item ]: true,\n\t} );\n};\n\n/**\n * Unpins an item.\n *\n * @param {string} scope Item scope.\n * @param {string} item Item identifier.\n */\nexport const unpinItem = ( scope, item ) => ( { registry } ) => {\n\t// Return early if there's no item.\n\tif ( ! item ) {\n\t\treturn;\n\t}\n\n\tconst pinnedItems = registry\n\t\t.select( preferencesStore )\n\t\t.get( scope, 'pinnedItems' );\n\n\tregistry.dispatch( preferencesStore ).set( scope, 'pinnedItems', {\n\t\t...pinnedItems,\n\t\t[ item ]: false,\n\t} );\n};\n\n/**\n * Returns an action object used in signalling that a feature should be toggled.\n *\n * @param {string} scope The feature scope (e.g. core/edit-post).\n * @param {string} featureName The feature name.\n */\nexport function toggleFeature( scope, featureName ) {\n\treturn function ( { registry } ) {\n\t\tdeprecated( `wp.dispatch( 'core/interface' ).toggleFeature`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `wp.dispatch( 'core/preferences' ).toggle`,\n\t\t} );\n\n\t\tregistry.dispatch( preferencesStore ).toggle( scope, featureName );\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a feature should be set to\n * a true or false value\n *\n * @param {string} scope The feature scope (e.g. core/edit-post).\n * @param {string} featureName The feature name.\n * @param {boolean} value The value to set.\n *\n * @return {Object} Action object.\n */\nexport function setFeatureValue( scope, featureName, value ) {\n\treturn function ( { registry } ) {\n\t\tdeprecated( `wp.dispatch( 'core/interface' ).setFeatureValue`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `wp.dispatch( 'core/preferences' ).set`,\n\t\t} );\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( scope, featureName, !! value );\n\t};\n}\n\n/**\n * Returns an action object used in signalling that defaults should be set for features.\n *\n * @param {string} scope The feature scope (e.g. core/edit-post).\n * @param {Object<string, boolean>} defaults A key/value map of feature names to values.\n *\n * @return {Object} Action object.\n */\nexport function setFeatureDefaults( scope, defaults ) {\n\treturn function ( { registry } ) {\n\t\tdeprecated( `wp.dispatch( 'core/interface' ).setFeatureDefaults`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `wp.dispatch( 'core/preferences' ).setDefaults`,\n\t\t} );\n\n\t\tregistry.dispatch( preferencesStore ).setDefaults( scope, defaults );\n\t};\n}\n"]}
|
package/build/store/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -9,8 +7,6 @@ exports.store = void 0;
|
|
|
9
7
|
|
|
10
8
|
var _data = require("@wordpress/data");
|
|
11
9
|
|
|
12
|
-
var _reducer = _interopRequireDefault(require("./reducer"));
|
|
13
|
-
|
|
14
10
|
var actions = _interopRequireWildcard(require("./actions"));
|
|
15
11
|
|
|
16
12
|
var selectors = _interopRequireWildcard(require("./selectors"));
|
|
@@ -28,12 +24,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
28
24
|
/**
|
|
29
25
|
* Internal dependencies
|
|
30
26
|
*/
|
|
31
|
-
|
|
32
|
-
reducer: _reducer.default,
|
|
33
|
-
actions,
|
|
34
|
-
selectors,
|
|
35
|
-
persist: ['enableItems']
|
|
36
|
-
};
|
|
27
|
+
|
|
37
28
|
/**
|
|
38
29
|
* Store definition for the interface namespace.
|
|
39
30
|
*
|
|
@@ -41,10 +32,13 @@ const storeConfig = {
|
|
|
41
32
|
*
|
|
42
33
|
* @type {Object}
|
|
43
34
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
const store = (0, _data.createReduxStore)(_constants.STORE_NAME, {
|
|
36
|
+
reducer: () => {},
|
|
37
|
+
actions,
|
|
38
|
+
selectors
|
|
39
|
+
}); // Once we build a more generic persistence plugin that works across types of stores
|
|
46
40
|
// we'd be able to replace this with a register call.
|
|
47
41
|
|
|
48
42
|
exports.store = store;
|
|
49
|
-
(0, _data.
|
|
43
|
+
(0, _data.register)(store);
|
|
50
44
|
//# sourceMappingURL=index.js.map
|
package/build/store/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/interface/src/store/index.js"],"names":["
|
|
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"]}
|
package/build/store/selectors.js
CHANGED
|
@@ -5,11 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.getActiveComplementaryArea =
|
|
9
|
-
exports.isFeatureActive = void 0;
|
|
10
|
-
exports.isItemPinned = isItemPinned;
|
|
11
|
-
|
|
12
|
-
var _lodash = require("lodash");
|
|
8
|
+
exports.isItemPinned = exports.isFeatureActive = exports.getActiveComplementaryArea = void 0;
|
|
13
9
|
|
|
14
10
|
var _data = require("@wordpress/data");
|
|
15
11
|
|
|
@@ -17,26 +13,10 @@ var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
|
|
17
13
|
|
|
18
14
|
var _preferences = require("@wordpress/preferences");
|
|
19
15
|
|
|
20
|
-
/**
|
|
21
|
-
* External dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
16
|
/**
|
|
25
17
|
* WordPress dependencies
|
|
26
18
|
*/
|
|
27
19
|
|
|
28
|
-
/**
|
|
29
|
-
* Returns the item that is enabled in a given scope.
|
|
30
|
-
*
|
|
31
|
-
* @param {Object} state Global application state.
|
|
32
|
-
* @param {string} itemType Type of item.
|
|
33
|
-
* @param {string} scope Item scope.
|
|
34
|
-
*
|
|
35
|
-
* @return {?string|null} The item that is enabled in the passed scope and type.
|
|
36
|
-
*/
|
|
37
|
-
function getSingleEnableItem(state, itemType, scope) {
|
|
38
|
-
return (0, _lodash.get)(state.enableItems.singleEnableItems, [itemType, scope]);
|
|
39
|
-
}
|
|
40
20
|
/**
|
|
41
21
|
* Returns the complementary area that is active in a given scope.
|
|
42
22
|
*
|
|
@@ -45,26 +25,9 @@ function getSingleEnableItem(state, itemType, scope) {
|
|
|
45
25
|
*
|
|
46
26
|
* @return {string} The complementary area that is active in the given scope.
|
|
47
27
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return getSingleEnableItem(state, 'complementaryArea', scope);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Returns a boolean indicating if an item is enabled or not in a given scope.
|
|
55
|
-
*
|
|
56
|
-
* @param {Object} state Global application state.
|
|
57
|
-
* @param {string} itemType Type of item.
|
|
58
|
-
* @param {string} scope Scope.
|
|
59
|
-
* @param {string} item Item to check.
|
|
60
|
-
*
|
|
61
|
-
* @return {boolean|undefined} True if the item is enabled, false otherwise if the item is explicitly disabled, and undefined if there is no information for that item.
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
function isMultipleEnabledItemEnabled(state, itemType, scope, item) {
|
|
66
|
-
return (0, _lodash.get)(state.enableItems.multipleEnableItems, [itemType, scope, item]);
|
|
67
|
-
}
|
|
28
|
+
const getActiveComplementaryArea = (0, _data.createRegistrySelector)(select => (state, scope) => {
|
|
29
|
+
return select(_preferences.store).get(scope, 'complementaryArea');
|
|
30
|
+
});
|
|
68
31
|
/**
|
|
69
32
|
* Returns a boolean indicating if an item is pinned or not.
|
|
70
33
|
*
|
|
@@ -75,10 +38,13 @@ function isMultipleEnabledItemEnabled(state, itemType, scope, item) {
|
|
|
75
38
|
* @return {boolean} True if the item is pinned and false otherwise.
|
|
76
39
|
*/
|
|
77
40
|
|
|
41
|
+
exports.getActiveComplementaryArea = getActiveComplementaryArea;
|
|
42
|
+
const isItemPinned = (0, _data.createRegistrySelector)(select => (state, scope, item) => {
|
|
43
|
+
var _pinnedItems$item;
|
|
78
44
|
|
|
79
|
-
|
|
80
|
-
return
|
|
81
|
-
}
|
|
45
|
+
const pinnedItems = select(_preferences.store).get(scope, 'pinnedItems');
|
|
46
|
+
return (_pinnedItems$item = pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) !== null && _pinnedItems$item !== void 0 ? _pinnedItems$item : true;
|
|
47
|
+
});
|
|
82
48
|
/**
|
|
83
49
|
* Returns a boolean indicating whether a feature is active for a particular
|
|
84
50
|
* scope.
|
|
@@ -90,7 +56,7 @@ function isItemPinned(state, scope, item) {
|
|
|
90
56
|
* @return {boolean} Is the feature enabled?
|
|
91
57
|
*/
|
|
92
58
|
|
|
93
|
-
|
|
59
|
+
exports.isItemPinned = isItemPinned;
|
|
94
60
|
const isFeatureActive = (0, _data.createRegistrySelector)(select => (state, scope, featureName) => {
|
|
95
61
|
(0, _deprecated.default)(`wp.select( 'core/interface' ).isFeatureActive( scope, featureName )`, {
|
|
96
62
|
since: '6.0',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/interface/src/store/selectors.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/interface/src/store/selectors.js"],"names":["getActiveComplementaryArea","select","state","scope","preferencesStore","get","isItemPinned","item","pinnedItems","isFeatureActive","featureName","since","alternative"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,0BAA0B,GAAG,kCACvCC,MAAF,IAAc,CAAEC,KAAF,EAASC,KAAT,KAAoB;AACjC,SAAOF,MAAM,CAAEG,kBAAF,CAAN,CAA2BC,GAA3B,CAAgCF,KAAhC,EAAuC,mBAAvC,CAAP;AACA,CAHwC,CAAnC;AAMP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMG,YAAY,GAAG,kCACzBL,MAAF,IAAc,CAAEC,KAAF,EAASC,KAAT,EAAgBI,IAAhB,KAA0B;AAAA;;AACvC,QAAMC,WAAW,GAAGP,MAAM,CAAEG,kBAAF,CAAN,CAA2BC,GAA3B,CACnBF,KADmB,EAEnB,aAFmB,CAApB;AAIA,8BAAOK,WAAP,aAAOA,WAAP,uBAAOA,WAAW,CAAID,IAAJ,CAAlB,iEAAgC,IAAhC;AACA,CAP0B,CAArB;AAUP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAME,eAAe,GAAG,kCAC5BR,MAAF,IAAc,CAAEC,KAAF,EAASC,KAAT,EAAgBO,WAAhB,KAAiC;AAC9C,2BACE,qEADF,EAEC;AACCC,IAAAA,KAAK,EAAE,KADR;AAECC,IAAAA,WAAW,EAAG;AAFf,GAFD;AAQA,SAAO,CAAC,CAAEX,MAAM,CAAEG,kBAAF,CAAN,CAA2BC,GAA3B,CAAgCF,KAAhC,EAAuCO,WAAvC,CAAV;AACA,CAX6B,CAAxB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Returns the complementary area that is active in a given scope.\n *\n * @param {Object} state Global application state.\n * @param {string} scope Item scope.\n *\n * @return {string} The complementary area that is active in the given scope.\n */\nexport const getActiveComplementaryArea = createRegistrySelector(\n\t( select ) => ( state, scope ) => {\n\t\treturn select( preferencesStore ).get( scope, 'complementaryArea' );\n\t}\n);\n\n/**\n * Returns a boolean indicating if an item is pinned or not.\n *\n * @param {Object} state Global application state.\n * @param {string} scope Scope.\n * @param {string} item Item to check.\n *\n * @return {boolean} True if the item is pinned and false otherwise.\n */\nexport const isItemPinned = createRegistrySelector(\n\t( select ) => ( state, scope, item ) => {\n\t\tconst pinnedItems = select( preferencesStore ).get(\n\t\t\tscope,\n\t\t\t'pinnedItems'\n\t\t);\n\t\treturn pinnedItems?.[ item ] ?? true;\n\t}\n);\n\n/**\n * Returns a boolean indicating whether a feature is active for a particular\n * scope.\n *\n * @param {Object} state The store state.\n * @param {string} scope The scope of the feature (e.g. core/edit-post).\n * @param {string} featureName The name of the feature.\n *\n * @return {boolean} Is the feature enabled?\n */\nexport const isFeatureActive = createRegistrySelector(\n\t( select ) => ( state, scope, featureName ) => {\n\t\tdeprecated(\n\t\t\t`wp.select( 'core/interface' ).isFeatureActive( scope, featureName )`,\n\t\t\t{\n\t\t\t\tsince: '6.0',\n\t\t\t\talternative: `!! wp.select( 'core/preferences' ).isFeatureActive( scope, featureName )`,\n\t\t\t}\n\t\t);\n\n\t\treturn !! select( preferencesStore ).get( scope, featureName );\n\t}\n);\n"]}
|
|
@@ -4,92 +4,87 @@
|
|
|
4
4
|
import deprecated from '@wordpress/deprecated';
|
|
5
5
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @param {string} itemType Type of item.
|
|
10
|
-
* @param {string} scope Item scope.
|
|
11
|
-
* @param {string} item Item identifier.
|
|
12
|
-
*
|
|
13
|
-
* @return {Object} Action object.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
function setSingleEnableItem(itemType, scope, item) {
|
|
17
|
-
return {
|
|
18
|
-
type: 'SET_SINGLE_ENABLE_ITEM',
|
|
19
|
-
itemType,
|
|
20
|
-
scope,
|
|
21
|
-
item
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Returns an action object used in signalling that a complementary item should be enabled.
|
|
7
|
+
* Enable the complementary area.
|
|
26
8
|
*
|
|
27
9
|
* @param {string} scope Complementary area scope.
|
|
28
10
|
* @param {string} area Area identifier.
|
|
29
|
-
*
|
|
30
|
-
* @return {Object} Action object.
|
|
31
11
|
*/
|
|
32
12
|
|
|
13
|
+
export const enableComplementaryArea = (scope, area) => _ref => {
|
|
14
|
+
let {
|
|
15
|
+
registry
|
|
16
|
+
} = _ref;
|
|
33
17
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
18
|
+
// Return early if there's no area.
|
|
19
|
+
if (!area) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
registry.dispatch(preferencesStore).set(scope, 'complementaryArea', area);
|
|
24
|
+
};
|
|
37
25
|
/**
|
|
38
|
-
*
|
|
26
|
+
* Disable the complementary area.
|
|
39
27
|
*
|
|
40
28
|
* @param {string} scope Complementary area scope.
|
|
41
|
-
*
|
|
42
|
-
* @return {Object} Action object.
|
|
43
29
|
*/
|
|
44
30
|
|
|
45
|
-
export
|
|
46
|
-
|
|
47
|
-
|
|
31
|
+
export const disableComplementaryArea = scope => _ref2 => {
|
|
32
|
+
let {
|
|
33
|
+
registry
|
|
34
|
+
} = _ref2;
|
|
35
|
+
registry.dispatch(preferencesStore).set(scope, 'complementaryArea', null);
|
|
36
|
+
};
|
|
48
37
|
/**
|
|
49
|
-
*
|
|
38
|
+
* Pins an item.
|
|
50
39
|
*
|
|
51
|
-
* @param {string}
|
|
52
|
-
* @param {string}
|
|
53
|
-
* @param {string} item Item identifier.
|
|
54
|
-
* @param {boolean} isEnable Boolean indicating if an area should be pinned or not.
|
|
40
|
+
* @param {string} scope Item scope.
|
|
41
|
+
* @param {string} item Item identifier.
|
|
55
42
|
*
|
|
56
43
|
* @return {Object} Action object.
|
|
57
44
|
*/
|
|
58
45
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
scope,
|
|
64
|
-
item,
|
|
65
|
-
isEnable
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Returns an action object used in signalling that an item should be pinned.
|
|
70
|
-
*
|
|
71
|
-
* @param {string} scope Item scope.
|
|
72
|
-
* @param {string} itemId Item identifier.
|
|
73
|
-
*
|
|
74
|
-
* @return {Object} Action object.
|
|
75
|
-
*/
|
|
46
|
+
export const pinItem = (scope, item) => _ref3 => {
|
|
47
|
+
let {
|
|
48
|
+
registry
|
|
49
|
+
} = _ref3;
|
|
76
50
|
|
|
51
|
+
// Return early if there's no item.
|
|
52
|
+
if (!item) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
77
55
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
56
|
+
const pinnedItems = registry.select(preferencesStore).get(scope, 'pinnedItems'); // The item is already pinned, there's nothing to do.
|
|
57
|
+
|
|
58
|
+
if ((pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) === true) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
registry.dispatch(preferencesStore).set(scope, 'pinnedItems', { ...pinnedItems,
|
|
63
|
+
[item]: true
|
|
64
|
+
});
|
|
65
|
+
};
|
|
81
66
|
/**
|
|
82
|
-
*
|
|
67
|
+
* Unpins an item.
|
|
83
68
|
*
|
|
84
|
-
* @param {string} scope
|
|
85
|
-
* @param {string}
|
|
86
|
-
*
|
|
87
|
-
* @return {Object} Action object.
|
|
69
|
+
* @param {string} scope Item scope.
|
|
70
|
+
* @param {string} item Item identifier.
|
|
88
71
|
*/
|
|
89
72
|
|
|
90
|
-
export
|
|
91
|
-
|
|
92
|
-
|
|
73
|
+
export const unpinItem = (scope, item) => _ref4 => {
|
|
74
|
+
let {
|
|
75
|
+
registry
|
|
76
|
+
} = _ref4;
|
|
77
|
+
|
|
78
|
+
// Return early if there's no item.
|
|
79
|
+
if (!item) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const pinnedItems = registry.select(preferencesStore).get(scope, 'pinnedItems');
|
|
84
|
+
registry.dispatch(preferencesStore).set(scope, 'pinnedItems', { ...pinnedItems,
|
|
85
|
+
[item]: false
|
|
86
|
+
});
|
|
87
|
+
};
|
|
93
88
|
/**
|
|
94
89
|
* Returns an action object used in signalling that a feature should be toggled.
|
|
95
90
|
*
|
|
@@ -98,10 +93,10 @@ export function unpinItem(scope, itemId) {
|
|
|
98
93
|
*/
|
|
99
94
|
|
|
100
95
|
export function toggleFeature(scope, featureName) {
|
|
101
|
-
return function (
|
|
96
|
+
return function (_ref5) {
|
|
102
97
|
let {
|
|
103
98
|
registry
|
|
104
|
-
} =
|
|
99
|
+
} = _ref5;
|
|
105
100
|
deprecated(`wp.dispatch( 'core/interface' ).toggleFeature`, {
|
|
106
101
|
since: '6.0',
|
|
107
102
|
alternative: `wp.dispatch( 'core/preferences' ).toggle`
|
|
@@ -121,10 +116,10 @@ export function toggleFeature(scope, featureName) {
|
|
|
121
116
|
*/
|
|
122
117
|
|
|
123
118
|
export function setFeatureValue(scope, featureName, value) {
|
|
124
|
-
return function (
|
|
119
|
+
return function (_ref6) {
|
|
125
120
|
let {
|
|
126
121
|
registry
|
|
127
|
-
} =
|
|
122
|
+
} = _ref6;
|
|
128
123
|
deprecated(`wp.dispatch( 'core/interface' ).setFeatureValue`, {
|
|
129
124
|
since: '6.0',
|
|
130
125
|
alternative: `wp.dispatch( 'core/preferences' ).set`
|
|
@@ -142,10 +137,10 @@ export function setFeatureValue(scope, featureName, value) {
|
|
|
142
137
|
*/
|
|
143
138
|
|
|
144
139
|
export function setFeatureDefaults(scope, defaults) {
|
|
145
|
-
return function (
|
|
140
|
+
return function (_ref7) {
|
|
146
141
|
let {
|
|
147
142
|
registry
|
|
148
|
-
} =
|
|
143
|
+
} = _ref7;
|
|
149
144
|
deprecated(`wp.dispatch( 'core/interface' ).setFeatureDefaults`, {
|
|
150
145
|
since: '6.0',
|
|
151
146
|
alternative: `wp.dispatch( 'core/preferences' ).setDefaults`
|