@wordpress/interface 5.16.0 → 5.17.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 +2 -0
- package/build/components/action-item/index.js +6 -14
- package/build/components/action-item/index.js.map +1 -1
- package/build/components/complementary-area/index.js +9 -28
- package/build/components/complementary-area/index.js.map +1 -1
- package/build/components/complementary-area-context/index.js +0 -3
- package/build/components/complementary-area-context/index.js.map +1 -1
- package/build/components/complementary-area-header/index.js +1 -7
- package/build/components/complementary-area-header/index.js.map +1 -1
- package/build/components/complementary-area-more-menu-item/index.js +3 -9
- package/build/components/complementary-area-more-menu-item/index.js.map +1 -1
- package/build/components/complementary-area-toggle/index.js +2 -10
- package/build/components/complementary-area-toggle/index.js.map +1 -1
- package/build/components/fullscreen-mode/index.js +3 -7
- package/build/components/fullscreen-mode/index.js.map +1 -1
- package/build/components/index.js +0 -14
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +0 -3
- package/build/components/index.native.js.map +1 -1
- package/build/components/interface-skeleton/index.js +8 -22
- package/build/components/interface-skeleton/index.js.map +1 -1
- package/build/components/more-menu-dropdown/index.js +1 -8
- package/build/components/more-menu-dropdown/index.js.map +1 -1
- package/build/components/more-menu-feature-toggle/index.js +2 -11
- package/build/components/more-menu-feature-toggle/index.js.map +1 -1
- package/build/components/navigable-region/index.js +1 -4
- package/build/components/navigable-region/index.js.map +1 -1
- package/build/components/pinned-items/index.js +1 -7
- package/build/components/pinned-items/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +1 -4
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preferences-modal-base-option/index.js +1 -4
- package/build/components/preferences-modal-base-option/index.js.map +1 -1
- package/build/components/preferences-modal-section/index.js +0 -3
- package/build/components/preferences-modal-section/index.js.map +1 -1
- package/build/components/preferences-modal-tabs/index.js +6 -15
- package/build/components/preferences-modal-tabs/index.js.map +1 -1
- package/build/index.js +0 -3
- package/build/index.js.map +1 -1
- package/build/store/actions.js +15 -37
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +0 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/index.js +3 -11
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +8 -14
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +8 -15
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/action-item/index.js +5 -10
- package/build-module/components/action-item/index.js.map +1 -1
- package/build-module/components/complementary-area/index.js +10 -17
- package/build-module/components/complementary-area/index.js.map +1 -1
- package/build-module/components/complementary-area-context/index.js.map +1 -1
- package/build-module/components/complementary-area-header/index.js +2 -5
- package/build-module/components/complementary-area-header/index.js.map +1 -1
- package/build-module/components/complementary-area-more-menu-item/index.js +3 -5
- package/build-module/components/complementary-area-more-menu-item/index.js.map +1 -1
- package/build-module/components/complementary-area-toggle/index.js +2 -5
- package/build-module/components/complementary-area-toggle/index.js.map +1 -1
- package/build-module/components/fullscreen-mode/index.js +2 -6
- package/build-module/components/fullscreen-mode/index.js.map +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/interface-skeleton/index.js +9 -17
- package/build-module/components/interface-skeleton/index.js.map +1 -1
- package/build-module/components/more-menu-dropdown/index.js +1 -3
- package/build-module/components/more-menu-dropdown/index.js.map +1 -1
- package/build-module/components/more-menu-feature-toggle/index.js +2 -5
- package/build-module/components/more-menu-feature-toggle/index.js.map +1 -1
- package/build-module/components/navigable-region/index.js +0 -1
- package/build-module/components/navigable-region/index.js.map +1 -1
- package/build-module/components/pinned-items/index.js +1 -5
- package/build-module/components/pinned-items/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +0 -1
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preferences-modal-base-option/index.js +0 -3
- package/build-module/components/preferences-modal-base-option/index.js.map +1 -1
- package/build-module/components/preferences-modal-section/index.js +0 -2
- package/build-module/components/preferences-modal-section/index.js.map +1 -1
- package/build-module/components/preferences-modal-tabs/index.js +5 -9
- package/build-module/components/preferences-modal-tabs/index.js.map +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +16 -20
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/index.js +5 -4
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +7 -9
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +9 -10
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +14 -8
- package/build-style/style.css +14 -8
- package/package.json +13 -13
- package/src/components/complementary-area/README.md +1 -1
- package/src/components/complementary-area/index.js +18 -2
- package/src/components/complementary-area-toggle/index.js +1 -1
- package/src/components/interface-skeleton/index.js +2 -0
- package/src/components/interface-skeleton/style.scss +6 -0
- package/src/components/more-menu-feature-toggle/index.js +1 -1
- package/src/components/pinned-items/style.scss +12 -10
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* WordPress dependencies
|
|
5
4
|
*/
|
|
@@ -8,10 +7,10 @@ import { MenuItem } from '@wordpress/components';
|
|
|
8
7
|
import { __ } from '@wordpress/i18n';
|
|
9
8
|
import { check } from '@wordpress/icons';
|
|
10
9
|
import { speak } from '@wordpress/a11y';
|
|
10
|
+
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
14
|
import { store as interfaceStore } from '../../store';
|
|
16
15
|
export default function MoreMenuFeatureToggle({
|
|
17
16
|
scope,
|
|
@@ -22,11 +21,10 @@ export default function MoreMenuFeatureToggle({
|
|
|
22
21
|
shortcut,
|
|
23
22
|
feature
|
|
24
23
|
}) {
|
|
25
|
-
const isActive = useSelect(select => select(interfaceStore).isFeatureActive(scope, feature), [feature]);
|
|
24
|
+
const isActive = useSelect(select => select(interfaceStore).isFeatureActive(scope, feature), [feature, scope]);
|
|
26
25
|
const {
|
|
27
26
|
toggleFeature
|
|
28
27
|
} = useDispatch(interfaceStore);
|
|
29
|
-
|
|
30
28
|
const speakMessage = () => {
|
|
31
29
|
if (isActive) {
|
|
32
30
|
speak(messageDeactivated || __('Feature deactivated'));
|
|
@@ -34,7 +32,6 @@ export default function MoreMenuFeatureToggle({
|
|
|
34
32
|
speak(messageActivated || __('Feature activated'));
|
|
35
33
|
}
|
|
36
34
|
};
|
|
37
|
-
|
|
38
35
|
return createElement(MenuItem, {
|
|
39
36
|
icon: isActive && check,
|
|
40
37
|
isSelected: isActive,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","MenuItem","__","check","speak","store","interfaceStore","MoreMenuFeatureToggle","scope","label","info","messageActivated","messageDeactivated","shortcut","feature","isActive","select","isFeatureActive","toggleFeature","speakMessage","createElement","icon","isSelected","onClick","role"],"sources":["@wordpress/interface/src/components/more-menu-feature-toggle/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { check } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { store as interfaceStore } from '../../store';\n\nexport default function MoreMenuFeatureToggle( {\n\tscope,\n\tlabel,\n\tinfo,\n\tmessageActivated,\n\tmessageDeactivated,\n\tshortcut,\n\tfeature,\n} ) {\n\tconst isActive = useSelect(\n\t\t( select ) =>\n\t\t\tselect( interfaceStore ).isFeatureActive( scope, feature ),\n\t\t[ feature, scope ]\n\t);\n\tconst { toggleFeature } = useDispatch( interfaceStore );\n\tconst speakMessage = () => {\n\t\tif ( isActive ) {\n\t\t\tspeak( messageDeactivated || __( 'Feature deactivated' ) );\n\t\t} else {\n\t\t\tspeak( messageActivated || __( 'Feature activated' ) );\n\t\t}\n\t};\n\n\treturn (\n\t\t<MenuItem\n\t\t\ticon={ isActive && check }\n\t\t\tisSelected={ isActive }\n\t\t\tonClick={ () => {\n\t\t\t\ttoggleFeature( scope, feature );\n\t\t\t\tspeakMessage();\n\t\t\t} }\n\t\t\trole=\"menuitemcheckbox\"\n\t\t\tinfo={ info }\n\t\t\tshortcut={ shortcut }\n\t\t>\n\t\t\t{ label }\n\t\t</MenuItem>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,QAAQ,kBAAkB;AACxC,SAASC,KAAK,QAAQ,iBAAiB;;AAEvC;AACA;AACA;AACA,SAASC,KAAK,IAAIC,cAAc,QAAQ,aAAa;AAErD,eAAe,SAASC,qBAAqBA,CAAE;EAC9CC,KAAK;EACLC,KAAK;EACLC,IAAI;EACJC,gBAAgB;EAChBC,kBAAkB;EAClBC,QAAQ;EACRC;AACD,CAAC,EAAG;EACH,MAAMC,QAAQ,GAAGhB,SAAS,CACvBiB,MAAM,IACPA,MAAM,CAAEV,cAAe,CAAC,CAACW,eAAe,CAAET,KAAK,EAAEM,OAAQ,CAAC,EAC3D,CAAEA,OAAO,EAAEN,KAAK,CACjB,CAAC;EACD,MAAM;IAAEU;EAAc,CAAC,GAAGlB,WAAW,CAAEM,cAAe,CAAC;EACvD,MAAMa,YAAY,GAAGA,CAAA,KAAM;IAC1B,IAAKJ,QAAQ,EAAG;MACfX,KAAK,CAAEQ,kBAAkB,IAAIV,EAAE,CAAE,qBAAsB,CAAE,CAAC;IAC3D,CAAC,MAAM;MACNE,KAAK,CAAEO,gBAAgB,IAAIT,EAAE,CAAE,mBAAoB,CAAE,CAAC;IACvD;EACD,CAAC;EAED,OACCkB,aAAA,CAACnB,QAAQ;IACRoB,IAAI,EAAGN,QAAQ,IAAIZ,KAAO;IAC1BmB,UAAU,EAAGP,QAAU;IACvBQ,OAAO,EAAGA,CAAA,KAAM;MACfL,aAAa,CAAEV,KAAK,EAAEM,OAAQ,CAAC;MAC/BK,YAAY,CAAC,CAAC;IACf,CAAG;IACHK,IAAI,EAAC,kBAAkB;IACvBd,IAAI,EAAGA,IAAM;IACbG,QAAQ,EAAGA;EAAU,GAEnBJ,KACO,CAAC;AAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["classnames","NavigableRegion","children","className","ariaLabel","as","Tag","props","createElement","role","tabIndex"],"sources":["@wordpress/interface/src/components/navigable-region/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\nexport default function NavigableRegion( {\n\tchildren,\n\tclassName,\n\tariaLabel,\n\tas: Tag = 'div',\n\t...props\n} ) {\n\treturn (\n\t\t<Tag\n\t\t\tclassName={ classnames( 'interface-navigable-region', className ) }\n\t\t\taria-label={ ariaLabel }\n\t\t\trole=\"region\"\n\t\t\ttabIndex=\"-1\"\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ children }\n\t\t</Tag>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;AAEnC,eAAe,SAASC,eAAeA,CAAE;EACxCC,QAAQ;EACRC,SAAS;EACTC,SAAS;EACTC,EAAE,EAAEC,GAAG,GAAG,KAAK;EACf,GAAGC;AACJ,CAAC,EAAG;EACH,OACCC,aAAA,CAACF,GAAG;IACHH,SAAS,EAAGH,UAAU,CAAE,4BAA4B,EAAEG,SAAU,CAAG;IACnE,cAAaC,SAAW;IACxBK,IAAI,EAAC,QAAQ;IACbC,QAAQ,EAAC,IAAI;IAAA,GACRH;EAAK,GAERL,QACE,CAAC;AAER"}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* External dependencies
|
|
5
4
|
*/
|
|
6
5
|
import classnames from 'classnames';
|
|
6
|
+
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
10
|
import { Slot, Fill } from '@wordpress/components';
|
|
12
|
-
|
|
13
11
|
function PinnedItems({
|
|
14
12
|
scope,
|
|
15
13
|
...props
|
|
@@ -19,7 +17,6 @@ function PinnedItems({
|
|
|
19
17
|
...props
|
|
20
18
|
});
|
|
21
19
|
}
|
|
22
|
-
|
|
23
20
|
function PinnedItemsSlot({
|
|
24
21
|
scope,
|
|
25
22
|
className,
|
|
@@ -32,7 +29,6 @@ function PinnedItemsSlot({
|
|
|
32
29
|
className: classnames(className, 'interface-pinned-items')
|
|
33
30
|
}, fills));
|
|
34
31
|
}
|
|
35
|
-
|
|
36
32
|
PinnedItems.Slot = PinnedItemsSlot;
|
|
37
33
|
export default PinnedItems;
|
|
38
34
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["classnames","Slot","Fill","PinnedItems","scope","props","createElement","name","PinnedItemsSlot","className","fills","length"],"sources":["@wordpress/interface/src/components/pinned-items/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Slot, Fill } from '@wordpress/components';\n\nfunction PinnedItems( { scope, ...props } ) {\n\treturn <Fill name={ `PinnedItems/${ scope }` } { ...props } />;\n}\n\nfunction PinnedItemsSlot( { scope, className, ...props } ) {\n\treturn (\n\t\t<Slot name={ `PinnedItems/${ scope }` } { ...props }>\n\t\t\t{ ( fills ) =>\n\t\t\t\tfills?.length > 0 && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t\t'interface-pinned-items'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ fills }\n\t\t\t\t\t</div>\n\t\t\t\t)\n\t\t\t}\n\t\t</Slot>\n\t);\n}\n\nPinnedItems.Slot = PinnedItemsSlot;\n\nexport default PinnedItems;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,IAAI,EAAEC,IAAI,QAAQ,uBAAuB;AAElD,SAASC,WAAWA,CAAE;EAAEC,KAAK;EAAE,GAAGC;AAAM,CAAC,EAAG;EAC3C,OAAOC,aAAA,CAACJ,IAAI;IAACK,IAAI,EAAI,eAAeH,KAAO,EAAG;IAAA,GAAMC;EAAK,CAAI,CAAC;AAC/D;AAEA,SAASG,eAAeA,CAAE;EAAEJ,KAAK;EAAEK,SAAS;EAAE,GAAGJ;AAAM,CAAC,EAAG;EAC1D,OACCC,aAAA,CAACL,IAAI;IAACM,IAAI,EAAI,eAAeH,KAAO,EAAG;IAAA,GAAMC;EAAK,GAC7CK,KAAK,IACRA,KAAK,EAAEC,MAAM,GAAG,CAAC,IAChBL,aAAA;IACCG,SAAS,EAAGT,UAAU,CACrBS,SAAS,EACT,wBACD;EAAG,GAEDC,KACE,CAGF,CAAC;AAET;AAEAP,WAAW,CAACF,IAAI,GAAGO,eAAe;AAElC,eAAeL,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["Modal","__","PreferencesModal","closeModal","children","createElement","className","title","onRequestClose"],"sources":["@wordpress/interface/src/components/preferences-modal/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nexport default function PreferencesModal( { closeModal, children } ) {\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"interface-preferences-modal\"\n\t\t\ttitle={ __( 'Preferences' ) }\n\t\t\tonRequestClose={ closeModal }\n\t\t>\n\t\t\t{ children }\n\t\t</Modal>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,EAAE,QAAQ,iBAAiB;AAEpC,eAAe,SAASC,gBAAgBA,CAAE;EAAEC,UAAU;EAAEC;AAAS,CAAC,EAAG;EACpE,OACCC,aAAA,CAACL,KAAK;IACLM,SAAS,EAAC,6BAA6B;IACvCC,KAAK,EAAGN,EAAE,CAAE,aAAc,CAAG;IAC7BO,cAAc,EAAGL;EAAY,GAE3BC,QACI,CAAC;AAEV"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* WordPress dependencies
|
|
5
4
|
*/
|
|
6
5
|
import { ToggleControl } from '@wordpress/components';
|
|
7
|
-
|
|
8
6
|
function BaseOption({
|
|
9
7
|
help,
|
|
10
8
|
label,
|
|
@@ -22,6 +20,5 @@ function BaseOption({
|
|
|
22
20
|
onChange: onChange
|
|
23
21
|
}), children);
|
|
24
22
|
}
|
|
25
|
-
|
|
26
23
|
export default BaseOption;
|
|
27
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["ToggleControl","BaseOption","help","label","isChecked","onChange","children","createElement","className","__nextHasNoMarginBottom","checked"],"sources":["@wordpress/interface/src/components/preferences-modal-base-option/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToggleControl } from '@wordpress/components';\n\nfunction BaseOption( { help, label, isChecked, onChange, children } ) {\n\treturn (\n\t\t<div className=\"interface-preferences-modal__option\">\n\t\t\t<ToggleControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\thelp={ help }\n\t\t\t\tlabel={ label }\n\t\t\t\tchecked={ isChecked }\n\t\t\t\tonChange={ onChange }\n\t\t\t/>\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\nexport default BaseOption;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,uBAAuB;AAErD,SAASC,UAAUA,CAAE;EAAEC,IAAI;EAAEC,KAAK;EAAEC,SAAS;EAAEC,QAAQ;EAAEC;AAAS,CAAC,EAAG;EACrE,OACCC,aAAA;IAAKC,SAAS,EAAC;EAAqC,GACnDD,aAAA,CAACP,aAAa;IACbS,uBAAuB;IACvBP,IAAI,EAAGA,IAAM;IACbC,KAAK,EAAGA,KAAO;IACfO,OAAO,EAAGN,SAAW;IACrBC,QAAQ,EAAGA;EAAU,CACrB,CAAC,EACAC,QACE,CAAC;AAER;AAEA,eAAeL,UAAU"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
2
|
const Section = ({
|
|
4
3
|
description,
|
|
5
4
|
title,
|
|
@@ -13,6 +12,5 @@ const Section = ({
|
|
|
13
12
|
}, title), description && createElement("p", {
|
|
14
13
|
className: "interface-preferences-modal__section-description"
|
|
15
14
|
}, description)), children);
|
|
16
|
-
|
|
17
15
|
export default Section;
|
|
18
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["Section","description","title","children","createElement","className"],"sources":["@wordpress/interface/src/components/preferences-modal-section/index.js"],"sourcesContent":["const Section = ( { description, title, children } ) => (\n\t<fieldset className=\"interface-preferences-modal__section\">\n\t\t<legend className=\"interface-preferences-modal__section-legend\">\n\t\t\t<h2 className=\"interface-preferences-modal__section-title\">\n\t\t\t\t{ title }\n\t\t\t</h2>\n\t\t\t{ description && (\n\t\t\t\t<p className=\"interface-preferences-modal__section-description\">\n\t\t\t\t\t{ description }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</legend>\n\t\t{ children }\n\t</fieldset>\n);\n\nexport default Section;\n"],"mappings":";AAAA,MAAMA,OAAO,GAAGA,CAAE;EAAEC,WAAW;EAAEC,KAAK;EAAEC;AAAS,CAAC,KACjDC,aAAA;EAAUC,SAAS,EAAC;AAAsC,GACzDD,aAAA;EAAQC,SAAS,EAAC;AAA6C,GAC9DD,aAAA;EAAIC,SAAS,EAAC;AAA4C,GACvDH,KACC,CAAC,EACHD,WAAW,IACZG,aAAA;EAAGC,SAAS,EAAC;AAAkD,GAC5DJ,WACA,CAEG,CAAC,EACPE,QACO,CACV;AAED,eAAeH,OAAO"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* WordPress dependencies
|
|
5
4
|
*/
|
|
@@ -12,16 +11,16 @@ const PREFERENCES_MENU = 'preferences-menu';
|
|
|
12
11
|
export default function PreferencesModalTabs({
|
|
13
12
|
sections
|
|
14
13
|
}) {
|
|
15
|
-
const isLargeViewport = useViewportMatch('medium');
|
|
16
|
-
// between small and large viewports.
|
|
14
|
+
const isLargeViewport = useViewportMatch('medium');
|
|
17
15
|
|
|
16
|
+
// This is also used to sync the two different rendered components
|
|
17
|
+
// between small and large viewports.
|
|
18
18
|
const [activeMenu, setActiveMenu] = useState(PREFERENCES_MENU);
|
|
19
19
|
/**
|
|
20
20
|
* Create helper objects from `sections` for easier data handling.
|
|
21
21
|
* `tabs` is used for creating the `TabPanel` and `sectionsContentMap`
|
|
22
22
|
* is used for easier access to active tab's content.
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
24
|
const {
|
|
26
25
|
tabs,
|
|
27
26
|
sectionsContentMap
|
|
@@ -30,7 +29,6 @@ export default function PreferencesModalTabs({
|
|
|
30
29
|
tabs: [],
|
|
31
30
|
sectionsContentMap: {}
|
|
32
31
|
};
|
|
33
|
-
|
|
34
32
|
if (sections.length) {
|
|
35
33
|
mappedTabs = sections.reduce((accumulator, {
|
|
36
34
|
name,
|
|
@@ -48,12 +46,11 @@ export default function PreferencesModalTabs({
|
|
|
48
46
|
sectionsContentMap: {}
|
|
49
47
|
});
|
|
50
48
|
}
|
|
51
|
-
|
|
52
49
|
return mappedTabs;
|
|
53
50
|
}, [sections]);
|
|
54
51
|
const getCurrentTab = useCallback(tab => sectionsContentMap[tab.name] || null, [sectionsContentMap]);
|
|
55
|
-
let modalContent;
|
|
56
|
-
|
|
52
|
+
let modalContent;
|
|
53
|
+
// We render different components based on the viewport size.
|
|
57
54
|
if (isLargeViewport) {
|
|
58
55
|
modalContent = createElement(TabPanel, {
|
|
59
56
|
className: "interface-preferences__tabs",
|
|
@@ -102,7 +99,6 @@ export default function PreferencesModalTabs({
|
|
|
102
99
|
}, section.tabLabel)), createElement(CardBody, null, section.content)));
|
|
103
100
|
}));
|
|
104
101
|
}
|
|
105
|
-
|
|
106
102
|
return modalContent;
|
|
107
103
|
}
|
|
108
104
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["useViewportMatch","__experimentalNavigatorProvider","NavigatorProvider","__experimentalNavigatorScreen","NavigatorScreen","__experimentalNavigatorButton","NavigatorButton","__experimentalNavigatorBackButton","NavigatorBackButton","__experimentalItemGroup","ItemGroup","__experimentalItem","Item","__experimentalHStack","HStack","__experimentalText","Text","__experimentalTruncate","Truncate","FlexItem","TabPanel","Card","CardHeader","CardBody","useMemo","useCallback","useState","chevronLeft","chevronRight","Icon","isRTL","__","PREFERENCES_MENU","PreferencesModalTabs","sections","isLargeViewport","activeMenu","setActiveMenu","tabs","sectionsContentMap","mappedTabs","length","reduce","accumulator","name","tabLabel","title","content","push","getCurrentTab","tab","modalContent","createElement","className","initialTabName","undefined","onSelect","orientation","initialPath","path","isBorderless","size","map","key","as","isAction","justify","icon","section","gap"],"sources":["@wordpress/interface/src/components/preferences-modal-tabs/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\t__experimentalNavigatorProvider as NavigatorProvider,\n\t__experimentalNavigatorScreen as NavigatorScreen,\n\t__experimentalNavigatorButton as NavigatorButton,\n\t__experimentalNavigatorBackButton as NavigatorBackButton,\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalHStack as HStack,\n\t__experimentalText as Text,\n\t__experimentalTruncate as Truncate,\n\tFlexItem,\n\tTabPanel,\n\tCard,\n\tCardHeader,\n\tCardBody,\n} from '@wordpress/components';\nimport { useMemo, useCallback, useState } from '@wordpress/element';\nimport { chevronLeft, chevronRight, Icon } from '@wordpress/icons';\nimport { isRTL, __ } from '@wordpress/i18n';\n\nconst PREFERENCES_MENU = 'preferences-menu';\n\nexport default function PreferencesModalTabs( { sections } ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\n\t// This is also used to sync the two different rendered components\n\t// between small and large viewports.\n\tconst [ activeMenu, setActiveMenu ] = useState( PREFERENCES_MENU );\n\t/**\n\t * Create helper objects from `sections` for easier data handling.\n\t * `tabs` is used for creating the `TabPanel` and `sectionsContentMap`\n\t * is used for easier access to active tab's content.\n\t */\n\tconst { tabs, sectionsContentMap } = useMemo( () => {\n\t\tlet mappedTabs = {\n\t\t\ttabs: [],\n\t\t\tsectionsContentMap: {},\n\t\t};\n\t\tif ( sections.length ) {\n\t\t\tmappedTabs = sections.reduce(\n\t\t\t\t( accumulator, { name, tabLabel: title, content } ) => {\n\t\t\t\t\taccumulator.tabs.push( { name, title } );\n\t\t\t\t\taccumulator.sectionsContentMap[ name ] = content;\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ tabs: [], sectionsContentMap: {} }\n\t\t\t);\n\t\t}\n\t\treturn mappedTabs;\n\t}, [ sections ] );\n\n\tconst getCurrentTab = useCallback(\n\t\t( tab ) => sectionsContentMap[ tab.name ] || null,\n\t\t[ sectionsContentMap ]\n\t);\n\n\tlet modalContent;\n\t// We render different components based on the viewport size.\n\tif ( isLargeViewport ) {\n\t\tmodalContent = (\n\t\t\t<TabPanel\n\t\t\t\tclassName=\"interface-preferences__tabs\"\n\t\t\t\ttabs={ tabs }\n\t\t\t\tinitialTabName={\n\t\t\t\t\tactiveMenu !== PREFERENCES_MENU ? activeMenu : undefined\n\t\t\t\t}\n\t\t\t\tonSelect={ setActiveMenu }\n\t\t\t\torientation=\"vertical\"\n\t\t\t>\n\t\t\t\t{ getCurrentTab }\n\t\t\t</TabPanel>\n\t\t);\n\t} else {\n\t\tmodalContent = (\n\t\t\t<NavigatorProvider\n\t\t\t\tinitialPath=\"/\"\n\t\t\t\tclassName=\"interface-preferences__provider\"\n\t\t\t>\n\t\t\t\t<NavigatorScreen path=\"/\">\n\t\t\t\t\t<Card isBorderless size=\"small\">\n\t\t\t\t\t\t<CardBody>\n\t\t\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t\t\t{ tabs.map( ( tab ) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\t\t\t\t\t\tpath={ tab.name }\n\t\t\t\t\t\t\t\t\t\t\tas={ Item }\n\t\t\t\t\t\t\t\t\t\t\tisAction\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<HStack justify=\"space-between\">\n\t\t\t\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<Truncate>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tisRTL()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? chevronLeft\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: chevronRight\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t\t\t</NavigatorButton>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t\t</CardBody>\n\t\t\t\t\t</Card>\n\t\t\t\t</NavigatorScreen>\n\t\t\t\t{ sections.length &&\n\t\t\t\t\tsections.map( ( section ) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<NavigatorScreen\n\t\t\t\t\t\t\t\tkey={ `${ section.name }-menu` }\n\t\t\t\t\t\t\t\tpath={ section.name }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Card isBorderless size=\"large\">\n\t\t\t\t\t\t\t\t\t<CardHeader\n\t\t\t\t\t\t\t\t\t\tisBorderless={ false }\n\t\t\t\t\t\t\t\t\t\tjustify=\"left\"\n\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\tgap=\"6\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<NavigatorBackButton\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tisRTL()\n\t\t\t\t\t\t\t\t\t\t\t\t\t? chevronRight\n\t\t\t\t\t\t\t\t\t\t\t\t\t: chevronLeft\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Navigate to the previous view'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<Text size=\"16\">\n\t\t\t\t\t\t\t\t\t\t\t{ section.tabLabel }\n\t\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t\t</CardHeader>\n\t\t\t\t\t\t\t\t\t<CardBody>{ section.content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
|
-
{"version":3,"sources":["@wordpress/interface/src/index.js"],"
|
|
1
|
+
{"version":3,"names":["store"],"sources":["@wordpress/interface/src/index.js"],"sourcesContent":["export * from './components';\nexport { store } from './store';\n"],"mappings":"AAAA,cAAc,cAAc;AAC5B,SAASA,KAAK,QAAQ,SAAS"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import deprecated from '@wordpress/deprecated';
|
|
5
5
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
* Set a default complementary area.
|
|
8
9
|
*
|
|
@@ -11,19 +12,18 @@ import { store as preferencesStore } from '@wordpress/preferences';
|
|
|
11
12
|
*
|
|
12
13
|
* @return {Object} Action object.
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
15
|
export const setDefaultComplementaryArea = (scope, area) => ({
|
|
16
16
|
type: 'SET_DEFAULT_COMPLEMENTARY_AREA',
|
|
17
17
|
scope,
|
|
18
18
|
area
|
|
19
19
|
});
|
|
20
|
+
|
|
20
21
|
/**
|
|
21
22
|
* Enable the complementary area.
|
|
22
23
|
*
|
|
23
24
|
* @param {string} scope Complementary area scope.
|
|
24
25
|
* @param {string} area Area identifier.
|
|
25
26
|
*/
|
|
26
|
-
|
|
27
27
|
export const enableComplementaryArea = (scope, area) => ({
|
|
28
28
|
registry,
|
|
29
29
|
dispatch
|
|
@@ -32,34 +32,31 @@ export const enableComplementaryArea = (scope, area) => ({
|
|
|
32
32
|
if (!area) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
|
|
36
35
|
const isComplementaryAreaVisible = registry.select(preferencesStore).get(scope, 'isComplementaryAreaVisible');
|
|
37
|
-
|
|
38
36
|
if (!isComplementaryAreaVisible) {
|
|
39
37
|
registry.dispatch(preferencesStore).set(scope, 'isComplementaryAreaVisible', true);
|
|
40
38
|
}
|
|
41
|
-
|
|
42
39
|
dispatch({
|
|
43
40
|
type: 'ENABLE_COMPLEMENTARY_AREA',
|
|
44
41
|
scope,
|
|
45
42
|
area
|
|
46
43
|
});
|
|
47
44
|
};
|
|
45
|
+
|
|
48
46
|
/**
|
|
49
47
|
* Disable the complementary area.
|
|
50
48
|
*
|
|
51
49
|
* @param {string} scope Complementary area scope.
|
|
52
50
|
*/
|
|
53
|
-
|
|
54
51
|
export const disableComplementaryArea = scope => ({
|
|
55
52
|
registry
|
|
56
53
|
}) => {
|
|
57
54
|
const isComplementaryAreaVisible = registry.select(preferencesStore).get(scope, 'isComplementaryAreaVisible');
|
|
58
|
-
|
|
59
55
|
if (isComplementaryAreaVisible) {
|
|
60
56
|
registry.dispatch(preferencesStore).set(scope, 'isComplementaryAreaVisible', false);
|
|
61
57
|
}
|
|
62
58
|
};
|
|
59
|
+
|
|
63
60
|
/**
|
|
64
61
|
* Pins an item.
|
|
65
62
|
*
|
|
@@ -68,7 +65,6 @@ export const disableComplementaryArea = scope => ({
|
|
|
68
65
|
*
|
|
69
66
|
* @return {Object} Action object.
|
|
70
67
|
*/
|
|
71
|
-
|
|
72
68
|
export const pinItem = (scope, item) => ({
|
|
73
69
|
registry
|
|
74
70
|
}) => {
|
|
@@ -76,24 +72,24 @@ export const pinItem = (scope, item) => ({
|
|
|
76
72
|
if (!item) {
|
|
77
73
|
return;
|
|
78
74
|
}
|
|
75
|
+
const pinnedItems = registry.select(preferencesStore).get(scope, 'pinnedItems');
|
|
79
76
|
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
// The item is already pinned, there's nothing to do.
|
|
82
78
|
if (pinnedItems?.[item] === true) {
|
|
83
79
|
return;
|
|
84
80
|
}
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
registry.dispatch(preferencesStore).set(scope, 'pinnedItems', {
|
|
82
|
+
...pinnedItems,
|
|
87
83
|
[item]: true
|
|
88
84
|
});
|
|
89
85
|
};
|
|
86
|
+
|
|
90
87
|
/**
|
|
91
88
|
* Unpins an item.
|
|
92
89
|
*
|
|
93
90
|
* @param {string} scope Item scope.
|
|
94
91
|
* @param {string} item Item identifier.
|
|
95
92
|
*/
|
|
96
|
-
|
|
97
93
|
export const unpinItem = (scope, item) => ({
|
|
98
94
|
registry
|
|
99
95
|
}) => {
|
|
@@ -101,19 +97,19 @@ export const unpinItem = (scope, item) => ({
|
|
|
101
97
|
if (!item) {
|
|
102
98
|
return;
|
|
103
99
|
}
|
|
104
|
-
|
|
105
100
|
const pinnedItems = registry.select(preferencesStore).get(scope, 'pinnedItems');
|
|
106
|
-
registry.dispatch(preferencesStore).set(scope, 'pinnedItems', {
|
|
101
|
+
registry.dispatch(preferencesStore).set(scope, 'pinnedItems', {
|
|
102
|
+
...pinnedItems,
|
|
107
103
|
[item]: false
|
|
108
104
|
});
|
|
109
105
|
};
|
|
106
|
+
|
|
110
107
|
/**
|
|
111
108
|
* Returns an action object used in signalling that a feature should be toggled.
|
|
112
109
|
*
|
|
113
110
|
* @param {string} scope The feature scope (e.g. core/edit-post).
|
|
114
111
|
* @param {string} featureName The feature name.
|
|
115
112
|
*/
|
|
116
|
-
|
|
117
113
|
export function toggleFeature(scope, featureName) {
|
|
118
114
|
return function ({
|
|
119
115
|
registry
|
|
@@ -125,6 +121,7 @@ export function toggleFeature(scope, featureName) {
|
|
|
125
121
|
registry.dispatch(preferencesStore).toggle(scope, featureName);
|
|
126
122
|
};
|
|
127
123
|
}
|
|
124
|
+
|
|
128
125
|
/**
|
|
129
126
|
* Returns an action object used in signalling that a feature should be set to
|
|
130
127
|
* a true or false value
|
|
@@ -135,7 +132,6 @@ export function toggleFeature(scope, featureName) {
|
|
|
135
132
|
*
|
|
136
133
|
* @return {Object} Action object.
|
|
137
134
|
*/
|
|
138
|
-
|
|
139
135
|
export function setFeatureValue(scope, featureName, value) {
|
|
140
136
|
return function ({
|
|
141
137
|
registry
|
|
@@ -147,6 +143,7 @@ export function setFeatureValue(scope, featureName, value) {
|
|
|
147
143
|
registry.dispatch(preferencesStore).set(scope, featureName, !!value);
|
|
148
144
|
};
|
|
149
145
|
}
|
|
146
|
+
|
|
150
147
|
/**
|
|
151
148
|
* Returns an action object used in signalling that defaults should be set for features.
|
|
152
149
|
*
|
|
@@ -155,7 +152,6 @@ export function setFeatureValue(scope, featureName, value) {
|
|
|
155
152
|
*
|
|
156
153
|
* @return {Object} Action object.
|
|
157
154
|
*/
|
|
158
|
-
|
|
159
155
|
export function setFeatureDefaults(scope, defaults) {
|
|
160
156
|
return function ({
|
|
161
157
|
registry
|
|
@@ -167,6 +163,7 @@ export function setFeatureDefaults(scope, defaults) {
|
|
|
167
163
|
registry.dispatch(preferencesStore).setDefaults(scope, defaults);
|
|
168
164
|
};
|
|
169
165
|
}
|
|
166
|
+
|
|
170
167
|
/**
|
|
171
168
|
* Returns an action object used in signalling that the user opened a modal.
|
|
172
169
|
*
|
|
@@ -174,19 +171,18 @@ export function setFeatureDefaults(scope, defaults) {
|
|
|
174
171
|
*
|
|
175
172
|
* @return {Object} Action object.
|
|
176
173
|
*/
|
|
177
|
-
|
|
178
174
|
export function openModal(name) {
|
|
179
175
|
return {
|
|
180
176
|
type: 'OPEN_MODAL',
|
|
181
177
|
name
|
|
182
178
|
};
|
|
183
179
|
}
|
|
180
|
+
|
|
184
181
|
/**
|
|
185
182
|
* Returns an action object signalling that the user closed a modal.
|
|
186
183
|
*
|
|
187
184
|
* @return {Object} Action object.
|
|
188
185
|
*/
|
|
189
|
-
|
|
190
186
|
export function closeModal() {
|
|
191
187
|
return {
|
|
192
188
|
type: 'CLOSE_MODAL'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["deprecated","store","preferencesStore","setDefaultComplementaryArea","scope","area","type","enableComplementaryArea","registry","dispatch","isComplementaryAreaVisible","select","get","set","disableComplementaryArea","pinItem","item","pinnedItems","unpinItem","toggleFeature","featureName","since","alternative","toggle","setFeatureValue","value","setFeatureDefaults","defaults","setDefaults","openModal","name","closeModal"],"sources":["@wordpress/interface/src/store/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Set a default complementary area.\n *\n * @param {string} scope Complementary area scope.\n * @param {string} area Area identifier.\n *\n * @return {Object} Action object.\n */\nexport const setDefaultComplementaryArea = ( scope, area ) => ( {\n\ttype: 'SET_DEFAULT_COMPLEMENTARY_AREA',\n\tscope,\n\tarea,\n} );\n\n/**\n * Enable the complementary area.\n *\n * @param {string} scope Complementary area scope.\n * @param {string} area Area identifier.\n */\nexport const enableComplementaryArea =\n\t( scope, area ) =>\n\t( { registry, dispatch } ) => {\n\t\t// Return early if there's no area.\n\t\tif ( ! area ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isComplementaryAreaVisible = registry\n\t\t\t.select( preferencesStore )\n\t\t\t.get( scope, 'isComplementaryAreaVisible' );\n\n\t\tif ( ! isComplementaryAreaVisible ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( preferencesStore )\n\t\t\t\t.set( scope, 'isComplementaryAreaVisible', true );\n\t\t}\n\n\t\tdispatch( {\n\t\t\ttype: 'ENABLE_COMPLEMENTARY_AREA',\n\t\t\tscope,\n\t\t\tarea,\n\t\t} );\n\t};\n\n/**\n * Disable the complementary area.\n *\n * @param {string} scope Complementary area scope.\n */\nexport const disableComplementaryArea =\n\t( scope ) =>\n\t( { registry } ) => {\n\t\tconst isComplementaryAreaVisible = registry\n\t\t\t.select( preferencesStore )\n\t\t\t.get( scope, 'isComplementaryAreaVisible' );\n\n\t\tif ( isComplementaryAreaVisible ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( preferencesStore )\n\t\t\t\t.set( scope, 'isComplementaryAreaVisible', false );\n\t\t}\n\t};\n\n/**\n * Pins an item.\n *\n * @param {string} scope Item scope.\n * @param {string} item Item identifier.\n *\n * @return {Object} Action object.\n */\nexport const pinItem =\n\t( scope, item ) =>\n\t( { registry } ) => {\n\t\t// Return early if there's no item.\n\t\tif ( ! item ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst pinnedItems = registry\n\t\t\t.select( preferencesStore )\n\t\t\t.get( scope, 'pinnedItems' );\n\n\t\t// The item is already pinned, there's nothing to do.\n\t\tif ( pinnedItems?.[ item ] === true ) {\n\t\t\treturn;\n\t\t}\n\n\t\tregistry.dispatch( preferencesStore ).set( scope, 'pinnedItems', {\n\t\t\t...pinnedItems,\n\t\t\t[ item ]: true,\n\t\t} );\n\t};\n\n/**\n * Unpins an item.\n *\n * @param {string} scope Item scope.\n * @param {string} item Item identifier.\n */\nexport const unpinItem =\n\t( scope, item ) =>\n\t( { registry } ) => {\n\t\t// Return early if there's no item.\n\t\tif ( ! item ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst pinnedItems = registry\n\t\t\t.select( preferencesStore )\n\t\t\t.get( scope, 'pinnedItems' );\n\n\t\tregistry.dispatch( preferencesStore ).set( scope, 'pinnedItems', {\n\t\t\t...pinnedItems,\n\t\t\t[ item ]: false,\n\t\t} );\n\t};\n\n/**\n * Returns an action object used in signalling that a feature should be toggled.\n *\n * @param {string} scope The feature scope (e.g. core/edit-post).\n * @param {string} featureName The feature name.\n */\nexport function toggleFeature( scope, featureName ) {\n\treturn function ( { registry } ) {\n\t\tdeprecated( `dispatch( 'core/interface' ).toggleFeature`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `dispatch( 'core/preferences' ).toggle`,\n\t\t} );\n\n\t\tregistry.dispatch( preferencesStore ).toggle( scope, featureName );\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a feature should be set to\n * a true or false value\n *\n * @param {string} scope The feature scope (e.g. core/edit-post).\n * @param {string} featureName The feature name.\n * @param {boolean} value The value to set.\n *\n * @return {Object} Action object.\n */\nexport function setFeatureValue( scope, featureName, value ) {\n\treturn function ( { registry } ) {\n\t\tdeprecated( `dispatch( 'core/interface' ).setFeatureValue`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `dispatch( 'core/preferences' ).set`,\n\t\t} );\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( scope, featureName, !! value );\n\t};\n}\n\n/**\n * Returns an action object used in signalling that defaults should be set for features.\n *\n * @param {string} scope The feature scope (e.g. core/edit-post).\n * @param {Object<string, boolean>} defaults A key/value map of feature names to values.\n *\n * @return {Object} Action object.\n */\nexport function setFeatureDefaults( scope, defaults ) {\n\treturn function ( { registry } ) {\n\t\tdeprecated( `dispatch( 'core/interface' ).setFeatureDefaults`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `dispatch( 'core/preferences' ).setDefaults`,\n\t\t} );\n\n\t\tregistry.dispatch( preferencesStore ).setDefaults( scope, defaults );\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the user opened a modal.\n *\n * @param {string} name A string that uniquely identifies the modal.\n *\n * @return {Object} Action object.\n */\nexport function openModal( name ) {\n\treturn {\n\t\ttype: 'OPEN_MODAL',\n\t\tname,\n\t};\n}\n\n/**\n * Returns an action object signalling that the user closed a modal.\n *\n * @return {Object} Action object.\n */\nexport function closeModal() {\n\treturn {\n\t\ttype: 'CLOSE_MODAL',\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,uBAAuB;AAC9C,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,wBAAwB;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,GAAGA,CAAEC,KAAK,EAAEC,IAAI,MAAQ;EAC/DC,IAAI,EAAE,gCAAgC;EACtCF,KAAK;EACLC;AACD,CAAC,CAAE;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,uBAAuB,GACnCA,CAAEH,KAAK,EAAEC,IAAI,KACb,CAAE;EAAEG,QAAQ;EAAEC;AAAS,CAAC,KAAM;EAC7B;EACA,IAAK,CAAEJ,IAAI,EAAG;IACb;EACD;EAEA,MAAMK,0BAA0B,GAAGF,QAAQ,CACzCG,MAAM,CAAET,gBAAiB,CAAC,CAC1BU,GAAG,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Q,EAAG;EACrD,OAAO,UAAW;IAAEnB;EAAS,CAAC,EAAG;IAChCR,UAAU,CAAG,iDAAgD,EAAE;MAC9DqB,KAAK,EAAE,KAAK;MACZC,WAAW,EAAG;IACf,CAAE,CAAC;IAEHd,QAAQ,CAACC,QAAQ,CAAEP,gBAAiB,CAAC,CAAC0B,WAAW,CAAExB,KAAK,EAAEuB,QAAS,CAAC;EACrE,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,SAASA,CAAEC,IAAI,EAAG;EACjC,OAAO;IACNxB,IAAI,EAAE,YAAY;IAClBwB;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAAA,EAAG;EAC5B,OAAO;IACNzB,IAAI,EAAE;EACP,CAAC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/interface/src/store/constants.js"],"
|
|
1
|
+
{"version":3,"names":["STORE_NAME"],"sources":["@wordpress/interface/src/store/constants.js"],"sourcesContent":["/**\n * The identifier for the data store.\n *\n * @type {string}\n */\nexport const STORE_NAME = 'core/interface';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,UAAU,GAAG,gBAAgB"}
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { createReduxStore, register } from '@wordpress/data';
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* Internal dependencies
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
9
|
import * as actions from './actions';
|
|
10
10
|
import * as selectors from './selectors';
|
|
11
11
|
import reducer from './reducer';
|
|
12
12
|
import { STORE_NAME } from './constants';
|
|
13
|
+
|
|
13
14
|
/**
|
|
14
15
|
* Store definition for the interface namespace.
|
|
15
16
|
*
|
|
@@ -17,13 +18,13 @@ import { STORE_NAME } from './constants';
|
|
|
17
18
|
*
|
|
18
19
|
* @type {Object}
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
21
|
export const store = createReduxStore(STORE_NAME, {
|
|
22
22
|
reducer,
|
|
23
23
|
actions,
|
|
24
24
|
selectors
|
|
25
|
-
});
|
|
26
|
-
// we'd be able to replace this with a register call.
|
|
25
|
+
});
|
|
27
26
|
|
|
27
|
+
// Once we build a more generic persistence plugin that works across types of stores
|
|
28
|
+
// we'd be able to replace this with a register call.
|
|
28
29
|
register(store);
|
|
29
30
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["createReduxStore","register","actions","selectors","reducer","STORE_NAME","store"],"sources":["@wordpress/interface/src/store/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport reducer from './reducer';\nimport { STORE_NAME } from './constants';\n\n/**\n * Store definition for the interface namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\n// Once we build a more generic persistence plugin that works across types of stores\n// we'd be able to replace this with a register call.\nregister( store );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAgB,EAAEC,QAAQ,QAAQ,iBAAiB;;AAE5D;AACA;AACA;AACA,OAAO,KAAKC,OAAO,MAAM,WAAW;AACpC,OAAO,KAAKC,SAAS,MAAM,aAAa;AACxC,OAAOC,OAAO,MAAM,WAAW;AAC/B,SAASC,UAAU,QAAQ,aAAa;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,KAAK,GAAGN,gBAAgB,CAAEK,UAAU,EAAE;EAClDD,OAAO;EACPF,OAAO;EACPC;AACD,CAAE,CAAC;;AAEH;AACA;AACAF,QAAQ,CAAEK,KAAM,CAAC"}
|
|
@@ -9,31 +9,32 @@ export function complementaryAreas(state = {}, action) {
|
|
|
9
9
|
const {
|
|
10
10
|
scope,
|
|
11
11
|
area
|
|
12
|
-
} = action;
|
|
12
|
+
} = action;
|
|
13
13
|
|
|
14
|
+
// If there's already an area, don't overwrite it.
|
|
14
15
|
if (state[scope]) {
|
|
15
16
|
return state;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
return {
|
|
19
|
+
...state,
|
|
19
20
|
[scope]: area
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
|
-
|
|
23
23
|
case 'ENABLE_COMPLEMENTARY_AREA':
|
|
24
24
|
{
|
|
25
25
|
const {
|
|
26
26
|
scope,
|
|
27
27
|
area
|
|
28
28
|
} = action;
|
|
29
|
-
return {
|
|
29
|
+
return {
|
|
30
|
+
...state,
|
|
30
31
|
[scope]: area
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
|
-
|
|
35
35
|
return state;
|
|
36
36
|
}
|
|
37
|
+
|
|
37
38
|
/**
|
|
38
39
|
* Reducer for storing the name of the open modal, or null if no modal is open.
|
|
39
40
|
*
|
|
@@ -42,16 +43,13 @@ export function complementaryAreas(state = {}, action) {
|
|
|
42
43
|
*
|
|
43
44
|
* @return {Object} Updated state
|
|
44
45
|
*/
|
|
45
|
-
|
|
46
46
|
export function activeModal(state = null, action) {
|
|
47
47
|
switch (action.type) {
|
|
48
48
|
case 'OPEN_MODAL':
|
|
49
49
|
return action.name;
|
|
50
|
-
|
|
51
50
|
case 'CLOSE_MODAL':
|
|
52
51
|
return null;
|
|
53
52
|
}
|
|
54
|
-
|
|
55
53
|
return state;
|
|
56
54
|
}
|
|
57
55
|
export default combineReducers({
|