@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
package/CHANGELOG.md
CHANGED
package/build/store/actions.js
CHANGED
|
@@ -1,105 +1,114 @@
|
|
|
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
|
});
|
|
6
|
-
exports.disableComplementaryArea =
|
|
7
|
-
exports.enableComplementaryArea = enableComplementaryArea;
|
|
8
|
-
exports.pinItem = pinItem;
|
|
8
|
+
exports.pinItem = exports.enableComplementaryArea = exports.disableComplementaryArea = void 0;
|
|
9
9
|
exports.setFeatureDefaults = setFeatureDefaults;
|
|
10
10
|
exports.setFeatureValue = setFeatureValue;
|
|
11
11
|
exports.toggleFeature = toggleFeature;
|
|
12
|
-
exports.unpinItem =
|
|
12
|
+
exports.unpinItem = void 0;
|
|
13
|
+
|
|
14
|
+
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
|
15
|
+
|
|
16
|
+
var _preferences = require("@wordpress/preferences");
|
|
13
17
|
|
|
14
18
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @param {string} itemType Type of item.
|
|
18
|
-
* @param {string} scope Item scope.
|
|
19
|
-
* @param {string} item Item identifier.
|
|
20
|
-
*
|
|
21
|
-
* @return {Object} Action object.
|
|
19
|
+
* WordPress dependencies
|
|
22
20
|
*/
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
type: 'SET_SINGLE_ENABLE_ITEM',
|
|
26
|
-
itemType,
|
|
27
|
-
scope,
|
|
28
|
-
item
|
|
29
|
-
};
|
|
30
|
-
}
|
|
21
|
+
|
|
31
22
|
/**
|
|
32
|
-
*
|
|
23
|
+
* Enable the complementary area.
|
|
33
24
|
*
|
|
34
25
|
* @param {string} scope Complementary area scope.
|
|
35
26
|
* @param {string} area Area identifier.
|
|
36
|
-
*
|
|
37
|
-
* @return {Object} Action object.
|
|
38
27
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
+
};
|
|
44
40
|
/**
|
|
45
|
-
*
|
|
41
|
+
* Disable the complementary area.
|
|
46
42
|
*
|
|
47
43
|
* @param {string} scope Complementary area scope.
|
|
48
|
-
*
|
|
49
|
-
* @return {Object} Action object.
|
|
50
44
|
*/
|
|
51
45
|
|
|
52
46
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
+
};
|
|
56
55
|
/**
|
|
57
|
-
*
|
|
56
|
+
* Pins an item.
|
|
58
57
|
*
|
|
59
|
-
* @param {string}
|
|
60
|
-
* @param {string}
|
|
61
|
-
* @param {string} item Item identifier.
|
|
62
|
-
* @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.
|
|
63
60
|
*
|
|
64
61
|
* @return {Object} Action object.
|
|
65
62
|
*/
|
|
66
63
|
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
type: 'SET_MULTIPLE_ENABLE_ITEM',
|
|
71
|
-
itemType,
|
|
72
|
-
scope,
|
|
73
|
-
item,
|
|
74
|
-
isEnable
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Returns an action object used in signalling that an item should be pinned.
|
|
79
|
-
*
|
|
80
|
-
* @param {string} scope Item scope.
|
|
81
|
-
* @param {string} itemId Item identifier.
|
|
82
|
-
*
|
|
83
|
-
* @return {Object} Action object.
|
|
84
|
-
*/
|
|
65
|
+
exports.disableComplementaryArea = disableComplementaryArea;
|
|
85
66
|
|
|
67
|
+
const pinItem = (scope, item) => _ref3 => {
|
|
68
|
+
let {
|
|
69
|
+
registry
|
|
70
|
+
} = _ref3;
|
|
86
71
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
+
};
|
|
90
87
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* @param {string} scope Item scope.
|
|
94
|
-
* @param {string} itemId Item identifier.
|
|
88
|
+
* Unpins an item.
|
|
95
89
|
*
|
|
96
|
-
* @
|
|
90
|
+
* @param {string} scope Item scope.
|
|
91
|
+
* @param {string} item Item identifier.
|
|
97
92
|
*/
|
|
98
93
|
|
|
99
94
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
+
};
|
|
103
112
|
/**
|
|
104
113
|
* Returns an action object used in signalling that a feature should be toggled.
|
|
105
114
|
*
|
|
@@ -108,14 +117,18 @@ function unpinItem(scope, itemId) {
|
|
|
108
117
|
*/
|
|
109
118
|
|
|
110
119
|
|
|
120
|
+
exports.unpinItem = unpinItem;
|
|
121
|
+
|
|
111
122
|
function toggleFeature(scope, featureName) {
|
|
112
|
-
return function (
|
|
123
|
+
return function (_ref5) {
|
|
113
124
|
let {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
125
|
+
registry
|
|
126
|
+
} = _ref5;
|
|
127
|
+
(0, _deprecated.default)(`wp.dispatch( 'core/interface' ).toggleFeature`, {
|
|
128
|
+
since: '6.0',
|
|
129
|
+
alternative: `wp.dispatch( 'core/preferences' ).toggle`
|
|
130
|
+
});
|
|
131
|
+
registry.dispatch(_preferences.store).toggle(scope, featureName);
|
|
119
132
|
};
|
|
120
133
|
}
|
|
121
134
|
/**
|
|
@@ -131,11 +144,15 @@ function toggleFeature(scope, featureName) {
|
|
|
131
144
|
|
|
132
145
|
|
|
133
146
|
function setFeatureValue(scope, featureName, value) {
|
|
134
|
-
return {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
147
|
+
return function (_ref6) {
|
|
148
|
+
let {
|
|
149
|
+
registry
|
|
150
|
+
} = _ref6;
|
|
151
|
+
(0, _deprecated.default)(`wp.dispatch( 'core/interface' ).setFeatureValue`, {
|
|
152
|
+
since: '6.0',
|
|
153
|
+
alternative: `wp.dispatch( 'core/preferences' ).set`
|
|
154
|
+
});
|
|
155
|
+
registry.dispatch(_preferences.store).set(scope, featureName, !!value);
|
|
139
156
|
};
|
|
140
157
|
}
|
|
141
158
|
/**
|
|
@@ -149,10 +166,15 @@ function setFeatureValue(scope, featureName, value) {
|
|
|
149
166
|
|
|
150
167
|
|
|
151
168
|
function setFeatureDefaults(scope, defaults) {
|
|
152
|
-
return {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
169
|
+
return function (_ref7) {
|
|
170
|
+
let {
|
|
171
|
+
registry
|
|
172
|
+
} = _ref7;
|
|
173
|
+
(0, _deprecated.default)(`wp.dispatch( 'core/interface' ).setFeatureDefaults`, {
|
|
174
|
+
since: '6.0',
|
|
175
|
+
alternative: `wp.dispatch( 'core/preferences' ).setDefaults`
|
|
176
|
+
});
|
|
177
|
+
registry.dispatch(_preferences.store).setDefaults(scope, defaults);
|
|
156
178
|
};
|
|
157
179
|
}
|
|
158
180
|
//# 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":["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;AACA;AACA;;;;;AACO,MAAMK,wBAAwB,GAAKN,KAAF,IAAa,SAAoB;AAAA,MAAlB;AAAEE,IAAAA;AAAF,GAAkB;AACxEA,EAAAA,QAAQ,CACNC,QADF,CACYC,kBADZ,EAEEC,GAFF,CAEOL,KAFP,EAEc,mBAFd,EAEmC,IAFnC;AAGA,CAJM;AAMP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMO,OAAO,GAAG,CAAEP,KAAF,EAASQ,IAAT,KAAmB,SAAoB;AAAA,MAAlB;AAAEN,IAAAA;AAAF,GAAkB;;AAC7D;AACA,MAAK,CAAEM,IAAP,EAAc;AACb;AACA;;AAED,QAAMC,WAAW,GAAGP,QAAQ,CAC1BQ,MADkB,CACVN,kBADU,EAElBO,GAFkB,CAEbX,KAFa,EAEN,aAFM,CAApB,CAN6D,CAU7D;;AACA,MAAK,CAAAS,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW,CAAID,IAAJ,CAAX,MAA0B,IAA/B,EAAsC;AACrC;AACA;;AAEDN,EAAAA,QAAQ,CAACC,QAAT,CAAmBC,kBAAnB,EAAsCC,GAAtC,CAA2CL,KAA3C,EAAkD,aAAlD,EAAiE,EAChE,GAAGS,WAD6D;AAEhE,KAAED,IAAF,GAAU;AAFsD,GAAjE;AAIA,CAnBM;AAqBP;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMI,SAAS,GAAG,CAAEZ,KAAF,EAASQ,IAAT,KAAmB,SAAoB;AAAA,MAAlB;AAAEN,IAAAA;AAAF,GAAkB;;AAC/D;AACA,MAAK,CAAEM,IAAP,EAAc;AACb;AACA;;AAED,QAAMC,WAAW,GAAGP,QAAQ,CAC1BQ,MADkB,CACVN,kBADU,EAElBO,GAFkB,CAEbX,KAFa,EAEN,aAFM,CAApB;AAIAE,EAAAA,QAAQ,CAACC,QAAT,CAAmBC,kBAAnB,EAAsCC,GAAtC,CAA2CL,KAA3C,EAAkD,aAAlD,EAAiE,EAChE,GAAGS,WAD6D;AAEhE,KAAED,IAAF,GAAU;AAFsD,GAAjE;AAIA,CAdM;AAgBP;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASK,aAAT,CAAwBb,KAAxB,EAA+Bc,WAA/B,EAA6C;AACnD,SAAO,iBAA0B;AAAA,QAAf;AAAEZ,MAAAA;AAAF,KAAe;AAChC,6BAAa,+CAAb,EAA6D;AAC5Da,MAAAA,KAAK,EAAE,KADqD;AAE5DC,MAAAA,WAAW,EAAG;AAF8C,KAA7D;AAKAd,IAAAA,QAAQ,CAACC,QAAT,CAAmBC,kBAAnB,EAAsCa,MAAtC,CAA8CjB,KAA9C,EAAqDc,WAArD;AACA,GAPD;AAQA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,eAAT,CAA0BlB,KAA1B,EAAiCc,WAAjC,EAA8CK,KAA9C,EAAsD;AAC5D,SAAO,iBAA0B;AAAA,QAAf;AAAEjB,MAAAA;AAAF,KAAe;AAChC,6BAAa,iDAAb,EAA+D;AAC9Da,MAAAA,KAAK,EAAE,KADuD;AAE9DC,MAAAA,WAAW,EAAG;AAFgD,KAA/D;AAKAd,IAAAA,QAAQ,CACNC,QADF,CACYC,kBADZ,EAEEC,GAFF,CAEOL,KAFP,EAEcc,WAFd,EAE2B,CAAC,CAAEK,KAF9B;AAGA,GATD;AAUA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,kBAAT,CAA6BpB,KAA7B,EAAoCqB,QAApC,EAA+C;AACrD,SAAO,iBAA0B;AAAA,QAAf;AAAEnB,MAAAA;AAAF,KAAe;AAChC,6BAAa,oDAAb,EAAkE;AACjEa,MAAAA,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', 'preferences']
|
|
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
|
@@ -1,30 +1,22 @@
|
|
|
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
|
});
|
|
6
|
-
exports.getActiveComplementaryArea =
|
|
7
|
-
exports.isFeatureActive = isFeatureActive;
|
|
8
|
-
exports.isItemPinned = isItemPinned;
|
|
8
|
+
exports.isItemPinned = exports.isFeatureActive = exports.getActiveComplementaryArea = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _data = require("@wordpress/data");
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
|
13
|
+
|
|
14
|
+
var _preferences = require("@wordpress/preferences");
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @param {Object} state Global application state.
|
|
20
|
-
* @param {string} itemType Type of item.
|
|
21
|
-
* @param {string} scope Item scope.
|
|
22
|
-
*
|
|
23
|
-
* @return {?string|null} The item that is enabled in the passed scope and type.
|
|
17
|
+
* WordPress dependencies
|
|
24
18
|
*/
|
|
25
|
-
|
|
26
|
-
return (0, _lodash.get)(state.enableItems.singleEnableItems, [itemType, scope]);
|
|
27
|
-
}
|
|
19
|
+
|
|
28
20
|
/**
|
|
29
21
|
* Returns the complementary area that is active in a given scope.
|
|
30
22
|
*
|
|
@@ -33,26 +25,9 @@ function getSingleEnableItem(state, itemType, scope) {
|
|
|
33
25
|
*
|
|
34
26
|
* @return {string} The complementary area that is active in the given scope.
|
|
35
27
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return getSingleEnableItem(state, 'complementaryArea', scope);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Returns a boolean indicating if an item is enabled or not in a given scope.
|
|
43
|
-
*
|
|
44
|
-
* @param {Object} state Global application state.
|
|
45
|
-
* @param {string} itemType Type of item.
|
|
46
|
-
* @param {string} scope Scope.
|
|
47
|
-
* @param {string} item Item to check.
|
|
48
|
-
*
|
|
49
|
-
* @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.
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
function isMultipleEnabledItemEnabled(state, itemType, scope, item) {
|
|
54
|
-
return (0, _lodash.get)(state.enableItems.multipleEnableItems, [itemType, scope, item]);
|
|
55
|
-
}
|
|
28
|
+
const getActiveComplementaryArea = (0, _data.createRegistrySelector)(select => (state, scope) => {
|
|
29
|
+
return select(_preferences.store).get(scope, 'complementaryArea');
|
|
30
|
+
});
|
|
56
31
|
/**
|
|
57
32
|
* Returns a boolean indicating if an item is pinned or not.
|
|
58
33
|
*
|
|
@@ -63,10 +38,13 @@ function isMultipleEnabledItemEnabled(state, itemType, scope, item) {
|
|
|
63
38
|
* @return {boolean} True if the item is pinned and false otherwise.
|
|
64
39
|
*/
|
|
65
40
|
|
|
41
|
+
exports.getActiveComplementaryArea = getActiveComplementaryArea;
|
|
42
|
+
const isItemPinned = (0, _data.createRegistrySelector)(select => (state, scope, item) => {
|
|
43
|
+
var _pinnedItems$item;
|
|
66
44
|
|
|
67
|
-
|
|
68
|
-
return
|
|
69
|
-
}
|
|
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
|
+
});
|
|
70
48
|
/**
|
|
71
49
|
* Returns a boolean indicating whether a feature is active for a particular
|
|
72
50
|
* scope.
|
|
@@ -78,12 +56,13 @@ function isItemPinned(state, scope, item) {
|
|
|
78
56
|
* @return {boolean} Is the feature enabled?
|
|
79
57
|
*/
|
|
80
58
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return !!
|
|
88
|
-
}
|
|
59
|
+
exports.isItemPinned = isItemPinned;
|
|
60
|
+
const isFeatureActive = (0, _data.createRegistrySelector)(select => (state, scope, featureName) => {
|
|
61
|
+
(0, _deprecated.default)(`wp.select( 'core/interface' ).isFeatureActive( scope, featureName )`, {
|
|
62
|
+
since: '6.0',
|
|
63
|
+
alternative: `!! wp.select( 'core/preferences' ).isFeatureActive( scope, featureName )`
|
|
64
|
+
});
|
|
65
|
+
return !!select(_preferences.store).get(scope, featureName);
|
|
66
|
+
});
|
|
67
|
+
exports.isFeatureActive = isFeatureActive;
|
|
89
68
|
//# 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":["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"]}
|