@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.
@@ -1,103 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- exports.multipleEnableItems = multipleEnableItems;
8
- exports.singleEnableItems = singleEnableItems;
9
-
10
- var _lodash = require("lodash");
11
-
12
- var _data = require("@wordpress/data");
13
-
14
- /**
15
- * External dependencies
16
- */
17
-
18
- /**
19
- * WordPress dependencies
20
- */
21
-
22
- /**
23
- * Reducer to keep tract of the active area per scope.
24
- *
25
- * @param {boolean} state Previous state.
26
- * @param {Object} action Action object.
27
- * @param {string} action.type Action type.
28
- * @param {string} action.itemType Type of item.
29
- * @param {string} action.scope Item scope.
30
- * @param {string} action.item Item name.
31
- *
32
- * @return {Object} Updated state.
33
- */
34
- function singleEnableItems() {
35
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
36
- let {
37
- type,
38
- itemType,
39
- scope,
40
- item
41
- } = arguments.length > 1 ? arguments[1] : undefined;
42
-
43
- if (type !== 'SET_SINGLE_ENABLE_ITEM' || !itemType || !scope) {
44
- return state;
45
- }
46
-
47
- return { ...state,
48
- [itemType]: { ...state[itemType],
49
- [scope]: item || null
50
- }
51
- };
52
- }
53
- /**
54
- * Reducer keeping track of the "pinned" items per scope.
55
- *
56
- * @param {boolean} state Previous state.
57
- * @param {Object} action Action object.
58
- * @param {string} action.type Action type.
59
- * @param {string} action.itemType Type of item.
60
- * @param {string} action.scope Item scope.
61
- * @param {string} action.item Item name.
62
- * @param {boolean} action.isEnable Whether the item is pinned.
63
- *
64
- * @return {Object} Updated state.
65
- */
66
-
67
-
68
- function multipleEnableItems() {
69
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
70
- let {
71
- type,
72
- itemType,
73
- scope,
74
- item,
75
- isEnable
76
- } = arguments.length > 1 ? arguments[1] : undefined;
77
-
78
- if (type !== 'SET_MULTIPLE_ENABLE_ITEM' || !itemType || !scope || !item || (0, _lodash.get)(state, [itemType, scope, item]) === isEnable) {
79
- return state;
80
- }
81
-
82
- const currentTypeState = state[itemType] || {};
83
- const currentScopeState = currentTypeState[scope] || {};
84
- return { ...state,
85
- [itemType]: { ...currentTypeState,
86
- [scope]: { ...currentScopeState,
87
- [item]: isEnable || false
88
- }
89
- }
90
- };
91
- }
92
-
93
- const enableItems = (0, _data.combineReducers)({
94
- singleEnableItems,
95
- multipleEnableItems
96
- });
97
-
98
- var _default = (0, _data.combineReducers)({
99
- enableItems
100
- });
101
-
102
- exports.default = _default;
103
- //# sourceMappingURL=reducer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/interface/src/store/reducer.js"],"names":["singleEnableItems","state","type","itemType","scope","item","multipleEnableItems","isEnable","currentTypeState","currentScopeState","enableItems"],"mappings":";;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,iBAAT,GAGL;AAAA,MAFDC,KAEC,uEAFO,EAEP;AAAA,MADD;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,QAAR;AAAkBC,IAAAA,KAAlB;AAAyBC,IAAAA;AAAzB,GACC;;AACD,MAAKH,IAAI,KAAK,wBAAT,IAAqC,CAAEC,QAAvC,IAAmD,CAAEC,KAA1D,EAAkE;AACjE,WAAOH,KAAP;AACA;;AAED,SAAO,EACN,GAAGA,KADG;AAEN,KAAEE,QAAF,GAAc,EACb,GAAGF,KAAK,CAAEE,QAAF,CADK;AAEb,OAAEC,KAAF,GAAWC,IAAI,IAAI;AAFN;AAFR,GAAP;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,mBAAT,GAGL;AAAA,MAFDL,KAEC,uEAFO,EAEP;AAAA,MADD;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,QAAR;AAAkBC,IAAAA,KAAlB;AAAyBC,IAAAA,IAAzB;AAA+BE,IAAAA;AAA/B,GACC;;AACD,MACCL,IAAI,KAAK,0BAAT,IACA,CAAEC,QADF,IAEA,CAAEC,KAFF,IAGA,CAAEC,IAHF,IAIA,iBAAKJ,KAAL,EAAY,CAAEE,QAAF,EAAYC,KAAZ,EAAmBC,IAAnB,CAAZ,MAA4CE,QAL7C,EAME;AACD,WAAON,KAAP;AACA;;AACD,QAAMO,gBAAgB,GAAGP,KAAK,CAAEE,QAAF,CAAL,IAAqB,EAA9C;AACA,QAAMM,iBAAiB,GAAGD,gBAAgB,CAAEJ,KAAF,CAAhB,IAA6B,EAAvD;AAEA,SAAO,EACN,GAAGH,KADG;AAEN,KAAEE,QAAF,GAAc,EACb,GAAGK,gBADU;AAEb,OAAEJ,KAAF,GAAW,EACV,GAAGK,iBADO;AAEV,SAAEJ,IAAF,GAAUE,QAAQ,IAAI;AAFZ;AAFE;AAFR,GAAP;AAUA;;AAED,MAAMG,WAAW,GAAG,2BAAiB;AACpCV,EAAAA,iBADoC;AAEpCM,EAAAA;AAFoC,CAAjB,CAApB;;eAKe,2BAAiB;AAC/BI,EAAAA;AAD+B,CAAjB,C","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer to keep tract of the active area per scope.\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action object.\n * @param {string} action.type Action type.\n * @param {string} action.itemType Type of item.\n * @param {string} action.scope Item scope.\n * @param {string} action.item Item name.\n *\n * @return {Object} Updated state.\n */\nexport function singleEnableItems(\n\tstate = {},\n\t{ type, itemType, scope, item }\n) {\n\tif ( type !== 'SET_SINGLE_ENABLE_ITEM' || ! itemType || ! scope ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t...state,\n\t\t[ itemType ]: {\n\t\t\t...state[ itemType ],\n\t\t\t[ scope ]: item || null,\n\t\t},\n\t};\n}\n\n/**\n * Reducer keeping track of the \"pinned\" items per scope.\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action object.\n * @param {string} action.type Action type.\n * @param {string} action.itemType Type of item.\n * @param {string} action.scope Item scope.\n * @param {string} action.item Item name.\n * @param {boolean} action.isEnable Whether the item is pinned.\n *\n * @return {Object} Updated state.\n */\nexport function multipleEnableItems(\n\tstate = {},\n\t{ type, itemType, scope, item, isEnable }\n) {\n\tif (\n\t\ttype !== 'SET_MULTIPLE_ENABLE_ITEM' ||\n\t\t! itemType ||\n\t\t! scope ||\n\t\t! item ||\n\t\tget( state, [ itemType, scope, item ] ) === isEnable\n\t) {\n\t\treturn state;\n\t}\n\tconst currentTypeState = state[ itemType ] || {};\n\tconst currentScopeState = currentTypeState[ scope ] || {};\n\n\treturn {\n\t\t...state,\n\t\t[ itemType ]: {\n\t\t\t...currentTypeState,\n\t\t\t[ scope ]: {\n\t\t\t\t...currentScopeState,\n\t\t\t\t[ item ]: isEnable || false,\n\t\t\t},\n\t\t},\n\t};\n}\n\nconst enableItems = combineReducers( {\n\tsingleEnableItems,\n\tmultipleEnableItems,\n} );\n\nexport default combineReducers( {\n\tenableItems,\n} );\n"]}
@@ -1,87 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { get } from 'lodash';
5
- /**
6
- * WordPress dependencies
7
- */
8
-
9
- import { combineReducers } from '@wordpress/data';
10
- /**
11
- * Reducer to keep tract of the active area per scope.
12
- *
13
- * @param {boolean} state Previous state.
14
- * @param {Object} action Action object.
15
- * @param {string} action.type Action type.
16
- * @param {string} action.itemType Type of item.
17
- * @param {string} action.scope Item scope.
18
- * @param {string} action.item Item name.
19
- *
20
- * @return {Object} Updated state.
21
- */
22
-
23
- export function singleEnableItems() {
24
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
25
- let {
26
- type,
27
- itemType,
28
- scope,
29
- item
30
- } = arguments.length > 1 ? arguments[1] : undefined;
31
-
32
- if (type !== 'SET_SINGLE_ENABLE_ITEM' || !itemType || !scope) {
33
- return state;
34
- }
35
-
36
- return { ...state,
37
- [itemType]: { ...state[itemType],
38
- [scope]: item || null
39
- }
40
- };
41
- }
42
- /**
43
- * Reducer keeping track of the "pinned" items per scope.
44
- *
45
- * @param {boolean} state Previous state.
46
- * @param {Object} action Action object.
47
- * @param {string} action.type Action type.
48
- * @param {string} action.itemType Type of item.
49
- * @param {string} action.scope Item scope.
50
- * @param {string} action.item Item name.
51
- * @param {boolean} action.isEnable Whether the item is pinned.
52
- *
53
- * @return {Object} Updated state.
54
- */
55
-
56
- export function multipleEnableItems() {
57
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
58
- let {
59
- type,
60
- itemType,
61
- scope,
62
- item,
63
- isEnable
64
- } = arguments.length > 1 ? arguments[1] : undefined;
65
-
66
- if (type !== 'SET_MULTIPLE_ENABLE_ITEM' || !itemType || !scope || !item || get(state, [itemType, scope, item]) === isEnable) {
67
- return state;
68
- }
69
-
70
- const currentTypeState = state[itemType] || {};
71
- const currentScopeState = currentTypeState[scope] || {};
72
- return { ...state,
73
- [itemType]: { ...currentTypeState,
74
- [scope]: { ...currentScopeState,
75
- [item]: isEnable || false
76
- }
77
- }
78
- };
79
- }
80
- const enableItems = combineReducers({
81
- singleEnableItems,
82
- multipleEnableItems
83
- });
84
- export default combineReducers({
85
- enableItems
86
- });
87
- //# sourceMappingURL=reducer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/interface/src/store/reducer.js"],"names":["get","combineReducers","singleEnableItems","state","type","itemType","scope","item","multipleEnableItems","isEnable","currentTypeState","currentScopeState","enableItems"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,iBAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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AUA;AAED,MAAMG,WAAW,GAAGX,eAAe,CAAE;AACpCC,EAAAA,iBADoC;AAEpCM,EAAAA;AAFoC,CAAF,CAAnC;AAKA,eAAeP,eAAe,CAAE;AAC/BW,EAAAA;AAD+B,CAAF,CAA9B","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer to keep tract of the active area per scope.\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action object.\n * @param {string} action.type Action type.\n * @param {string} action.itemType Type of item.\n * @param {string} action.scope Item scope.\n * @param {string} action.item Item name.\n *\n * @return {Object} Updated state.\n */\nexport function singleEnableItems(\n\tstate = {},\n\t{ type, itemType, scope, item }\n) {\n\tif ( type !== 'SET_SINGLE_ENABLE_ITEM' || ! itemType || ! scope ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t...state,\n\t\t[ itemType ]: {\n\t\t\t...state[ itemType ],\n\t\t\t[ scope ]: item || null,\n\t\t},\n\t};\n}\n\n/**\n * Reducer keeping track of the \"pinned\" items per scope.\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action object.\n * @param {string} action.type Action type.\n * @param {string} action.itemType Type of item.\n * @param {string} action.scope Item scope.\n * @param {string} action.item Item name.\n * @param {boolean} action.isEnable Whether the item is pinned.\n *\n * @return {Object} Updated state.\n */\nexport function multipleEnableItems(\n\tstate = {},\n\t{ type, itemType, scope, item, isEnable }\n) {\n\tif (\n\t\ttype !== 'SET_MULTIPLE_ENABLE_ITEM' ||\n\t\t! itemType ||\n\t\t! scope ||\n\t\t! item ||\n\t\tget( state, [ itemType, scope, item ] ) === isEnable\n\t) {\n\t\treturn state;\n\t}\n\tconst currentTypeState = state[ itemType ] || {};\n\tconst currentScopeState = currentTypeState[ scope ] || {};\n\n\treturn {\n\t\t...state,\n\t\t[ itemType ]: {\n\t\t\t...currentTypeState,\n\t\t\t[ scope ]: {\n\t\t\t\t...currentScopeState,\n\t\t\t\t[ item ]: isEnable || false,\n\t\t\t},\n\t\t},\n\t};\n}\n\nconst enableItems = combineReducers( {\n\tsingleEnableItems,\n\tmultipleEnableItems,\n} );\n\nexport default combineReducers( {\n\tenableItems,\n} );\n"]}
@@ -1,88 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { get } from 'lodash';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { combineReducers } from '@wordpress/data';
10
-
11
- /**
12
- * Reducer to keep tract of the active area per scope.
13
- *
14
- * @param {boolean} state Previous state.
15
- * @param {Object} action Action object.
16
- * @param {string} action.type Action type.
17
- * @param {string} action.itemType Type of item.
18
- * @param {string} action.scope Item scope.
19
- * @param {string} action.item Item name.
20
- *
21
- * @return {Object} Updated state.
22
- */
23
- export function singleEnableItems(
24
- state = {},
25
- { type, itemType, scope, item }
26
- ) {
27
- if ( type !== 'SET_SINGLE_ENABLE_ITEM' || ! itemType || ! scope ) {
28
- return state;
29
- }
30
-
31
- return {
32
- ...state,
33
- [ itemType ]: {
34
- ...state[ itemType ],
35
- [ scope ]: item || null,
36
- },
37
- };
38
- }
39
-
40
- /**
41
- * Reducer keeping track of the "pinned" items per scope.
42
- *
43
- * @param {boolean} state Previous state.
44
- * @param {Object} action Action object.
45
- * @param {string} action.type Action type.
46
- * @param {string} action.itemType Type of item.
47
- * @param {string} action.scope Item scope.
48
- * @param {string} action.item Item name.
49
- * @param {boolean} action.isEnable Whether the item is pinned.
50
- *
51
- * @return {Object} Updated state.
52
- */
53
- export function multipleEnableItems(
54
- state = {},
55
- { type, itemType, scope, item, isEnable }
56
- ) {
57
- if (
58
- type !== 'SET_MULTIPLE_ENABLE_ITEM' ||
59
- ! itemType ||
60
- ! scope ||
61
- ! item ||
62
- get( state, [ itemType, scope, item ] ) === isEnable
63
- ) {
64
- return state;
65
- }
66
- const currentTypeState = state[ itemType ] || {};
67
- const currentScopeState = currentTypeState[ scope ] || {};
68
-
69
- return {
70
- ...state,
71
- [ itemType ]: {
72
- ...currentTypeState,
73
- [ scope ]: {
74
- ...currentScopeState,
75
- [ item ]: isEnable || false,
76
- },
77
- },
78
- };
79
- }
80
-
81
- const enableItems = combineReducers( {
82
- singleEnableItems,
83
- multipleEnableItems,
84
- } );
85
-
86
- export default combineReducers( {
87
- enableItems,
88
- } );