@wordpress/preferences 4.32.0 → 4.32.1-next.b8c8708f3.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/build/components/index.js +36 -12
- package/build/components/index.js.map +7 -1
- package/build/components/preference-base-option/index.js +39 -30
- package/build/components/preference-base-option/index.js.map +7 -1
- package/build/components/preference-toggle-control/index.js +52 -30
- package/build/components/preference-toggle-control/index.js.map +7 -1
- package/build/components/preference-toggle-menu-item/index.js +65 -47
- package/build/components/preference-toggle-menu-item/index.js.map +7 -1
- package/build/components/preferences-modal/index.js +35 -23
- package/build/components/preferences-modal/index.js.map +7 -1
- package/build/components/preferences-modal-section/index.js +31 -28
- package/build/components/preferences-modal-section/index.js.map +7 -1
- package/build/components/preferences-modal-tabs/index.js +123 -134
- package/build/components/preferences-modal-tabs/index.js.map +7 -1
- package/build/index.js +29 -36
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -15
- package/build/lock-unlock.js.map +7 -1
- package/build/private-apis.js +49 -24
- package/build/private-apis.js.map +7 -1
- package/build/store/actions.js +36 -69
- package/build/store/actions.js.map +7 -1
- package/build/store/constants.js +27 -12
- package/build/store/constants.js.map +7 -1
- package/build/store/index.js +44 -32
- package/build/store/index.js.map +7 -1
- package/build/store/reducer.js +39 -65
- package/build/store/reducer.js.map +7 -1
- package/build/store/selectors.js +67 -33
- package/build/store/selectors.js.map +7 -1
- package/build-module/components/index.js +5 -2
- package/build-module/components/index.js.map +7 -1
- package/build-module/components/preference-base-option/index.js +21 -24
- package/build-module/components/preference-base-option/index.js.map +7 -1
- package/build-module/components/preference-toggle-control/index.js +24 -23
- package/build-module/components/preference-toggle-control/index.js.map +7 -1
- package/build-module/components/preference-toggle-menu-item/index.js +46 -40
- package/build-module/components/preference-toggle-menu-item/index.js.map +7 -1
- package/build-module/components/preferences-modal/index.js +17 -17
- package/build-module/components/preferences-modal/index.js.map +7 -1
- package/build-module/components/preferences-modal-section/index.js +13 -23
- package/build-module/components/preferences-modal-section/index.js.map +7 -1
- package/build-module/components/preferences-modal-tabs/index.js +116 -127
- package/build-module/components/preferences-modal-tabs/index.js.map +7 -1
- package/build-module/index.js +7 -4
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/private-apis.js +11 -11
- package/build-module/private-apis.js.map +7 -1
- package/build-module/store/actions.js +15 -65
- package/build-module/store/actions.js.map +7 -1
- package/build-module/store/constants.js +5 -7
- package/build-module/store/constants.js.map +7 -1
- package/build-module/store/index.js +10 -22
- package/build-module/store/index.js.map +7 -1
- package/build-module/store/reducer.js +17 -59
- package/build-module/store/reducer.js.map +7 -1
- package/build-module/store/selectors.js +35 -26
- package/build-module/store/selectors.js.map +7 -1
- package/build-style/style-rtl.css +4 -158
- package/build-style/style.css +4 -158
- package/package.json +20 -12
- package/src/components/preference-base-option/style.scss +2 -0
- package/src/components/preferences-modal/style.scss +6 -2
- package/src/components/preferences-modal-section/style.scss +3 -0
- package/src/components/preferences-modal-tabs/style.scss +4 -1
- package/src/style.scss +4 -4
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
children
|
|
16
|
-
|
|
17
|
-
help: help,
|
|
18
|
-
label: label,
|
|
19
|
-
checked: isChecked,
|
|
20
|
-
onChange: onChange
|
|
21
|
-
}), children]
|
|
22
|
-
});
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ToggleControl } from "@wordpress/components";
|
|
3
|
+
function BaseOption({ help, label, isChecked, onChange, children }) {
|
|
4
|
+
return /* @__PURE__ */ jsxs("div", { className: "preference-base-option", children: [
|
|
5
|
+
/* @__PURE__ */ jsx(
|
|
6
|
+
ToggleControl,
|
|
7
|
+
{
|
|
8
|
+
__nextHasNoMarginBottom: true,
|
|
9
|
+
help,
|
|
10
|
+
label,
|
|
11
|
+
checked: isChecked,
|
|
12
|
+
onChange
|
|
13
|
+
}
|
|
14
|
+
),
|
|
15
|
+
children
|
|
16
|
+
] });
|
|
23
17
|
}
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
var preference_base_option_default = BaseOption;
|
|
19
|
+
export {
|
|
20
|
+
preference_base_option_default as default
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/preference-base-option/index.js"],
|
|
4
|
+
"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=\"preference-base-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"],
|
|
5
|
+
"mappings": "AAOE,SACC,KADD;AAJF,SAAS,qBAAqB;AAE9B,SAAS,WAAY,EAAE,MAAM,OAAO,WAAW,UAAU,SAAS,GAAI;AACrE,SACC,qBAAC,SAAI,WAAU,0BACd;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,yBAAuB;AAAA,QACvB;AAAA,QACA;AAAA,QACA,SAAU;AAAA,QACV;AAAA;AAAA,IACD;AAAA,IACE;AAAA,KACH;AAEF;AAEA,IAAO,iCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { store as preferencesStore } from '../../store';
|
|
10
|
-
import PreferenceBaseOption from '../preference-base-option';
|
|
11
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useSelect, useDispatch } from "@wordpress/data";
|
|
3
|
+
import { store as preferencesStore } from "../../store";
|
|
4
|
+
import PreferenceBaseOption from "../preference-base-option";
|
|
12
5
|
function PreferenceToggleControl(props) {
|
|
13
6
|
const {
|
|
14
7
|
scope,
|
|
15
8
|
featureName,
|
|
16
|
-
onToggle = () => {
|
|
9
|
+
onToggle = () => {
|
|
10
|
+
},
|
|
17
11
|
...remainingProps
|
|
18
12
|
} = props;
|
|
19
|
-
const isChecked = useSelect(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
const isChecked = useSelect(
|
|
14
|
+
(select) => !!select(preferencesStore).get(scope, featureName),
|
|
15
|
+
[scope, featureName]
|
|
16
|
+
);
|
|
17
|
+
const { toggle } = useDispatch(preferencesStore);
|
|
23
18
|
const onChange = () => {
|
|
24
19
|
onToggle();
|
|
25
20
|
toggle(scope, featureName);
|
|
26
21
|
};
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
return /* @__PURE__ */ jsx(
|
|
23
|
+
PreferenceBaseOption,
|
|
24
|
+
{
|
|
25
|
+
onChange,
|
|
26
|
+
isChecked,
|
|
27
|
+
...remainingProps
|
|
28
|
+
}
|
|
29
|
+
);
|
|
32
30
|
}
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
var preference_toggle_control_default = PreferenceToggleControl;
|
|
32
|
+
export {
|
|
33
|
+
preference_toggle_control_default as default
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/preference-toggle-control/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as preferencesStore } from '../../store';\nimport PreferenceBaseOption from '../preference-base-option';\n\nfunction PreferenceToggleControl( props ) {\n\tconst {\n\t\tscope,\n\t\tfeatureName,\n\t\tonToggle = () => {},\n\t\t...remainingProps\n\t} = props;\n\tconst isChecked = useSelect(\n\t\t( select ) => !! select( preferencesStore ).get( scope, featureName ),\n\t\t[ scope, featureName ]\n\t);\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst onChange = () => {\n\t\tonToggle();\n\t\ttoggle( scope, featureName );\n\t};\n\n\treturn (\n\t\t<PreferenceBaseOption\n\t\t\tonChange={ onChange }\n\t\t\tisChecked={ isChecked }\n\t\t\t{ ...remainingProps }\n\t\t/>\n\t);\n}\n\nexport default PreferenceToggleControl;\n"],
|
|
5
|
+
"mappings": "AA6BE;AA1BF,SAAS,WAAW,mBAAmB;AAKvC,SAAS,SAAS,wBAAwB;AAC1C,OAAO,0BAA0B;AAEjC,SAAS,wBAAyB,OAAQ;AACzC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA,WAAW,MAAM;AAAA,IAAC;AAAA,IAClB,GAAG;AAAA,EACJ,IAAI;AACJ,QAAM,YAAY;AAAA,IACjB,CAAE,WAAY,CAAC,CAAE,OAAQ,gBAAiB,EAAE,IAAK,OAAO,WAAY;AAAA,IACpE,CAAE,OAAO,WAAY;AAAA,EACtB;AACA,QAAM,EAAE,OAAO,IAAI,YAAa,gBAAiB;AACjD,QAAM,WAAW,MAAM;AACtB,aAAS;AACT,WAAQ,OAAO,WAAY;AAAA,EAC5B;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACE,GAAG;AAAA;AAAA,EACN;AAEF;AAEA,IAAO,oCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
13
|
-
import { store as preferencesStore } from '../../store';
|
|
14
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
-
export default function PreferenceToggleMenuItem({
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useSelect, useDispatch } from "@wordpress/data";
|
|
3
|
+
import { MenuItem } from "@wordpress/components";
|
|
4
|
+
import { __, sprintf } from "@wordpress/i18n";
|
|
5
|
+
import { check } from "@wordpress/icons";
|
|
6
|
+
import { speak } from "@wordpress/a11y";
|
|
7
|
+
import { store as preferencesStore } from "../../store";
|
|
8
|
+
function PreferenceToggleMenuItem({
|
|
16
9
|
scope,
|
|
17
10
|
name,
|
|
18
11
|
label,
|
|
@@ -24,36 +17,49 @@ export default function PreferenceToggleMenuItem({
|
|
|
24
17
|
onToggle = () => null,
|
|
25
18
|
disabled = false
|
|
26
19
|
}) {
|
|
27
|
-
const isActive = useSelect(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
const isActive = useSelect(
|
|
21
|
+
(select) => !!select(preferencesStore).get(scope, name),
|
|
22
|
+
[scope, name]
|
|
23
|
+
);
|
|
24
|
+
const { toggle } = useDispatch(preferencesStore);
|
|
31
25
|
const speakMessage = () => {
|
|
32
26
|
if (isActive) {
|
|
33
|
-
const message = messageDeactivated || sprintf(
|
|
34
|
-
|
|
27
|
+
const message = messageDeactivated || sprintf(
|
|
28
|
+
/* translators: %s: preference name, e.g. 'Fullscreen mode' */
|
|
29
|
+
__("Preference deactivated - %s"),
|
|
30
|
+
label
|
|
31
|
+
);
|
|
35
32
|
speak(message);
|
|
36
33
|
} else {
|
|
37
|
-
const message = messageActivated || sprintf(
|
|
38
|
-
|
|
34
|
+
const message = messageActivated || sprintf(
|
|
35
|
+
/* translators: %s: preference name, e.g. 'Fullscreen mode' */
|
|
36
|
+
__("Preference activated - %s"),
|
|
37
|
+
label
|
|
38
|
+
);
|
|
39
39
|
speak(message);
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
-
return
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
43
|
+
MenuItem,
|
|
44
|
+
{
|
|
45
|
+
icon: isActive && check,
|
|
46
|
+
isSelected: isActive,
|
|
47
|
+
onClick: () => {
|
|
48
|
+
onToggle();
|
|
49
|
+
if (handleToggling) {
|
|
50
|
+
toggle(scope, name);
|
|
51
|
+
}
|
|
52
|
+
speakMessage();
|
|
53
|
+
},
|
|
54
|
+
role: "menuitemcheckbox",
|
|
55
|
+
info,
|
|
56
|
+
shortcut,
|
|
57
|
+
disabled,
|
|
58
|
+
children: label
|
|
59
|
+
}
|
|
60
|
+
);
|
|
58
61
|
}
|
|
59
|
-
|
|
62
|
+
export {
|
|
63
|
+
PreferenceToggleMenuItem as default
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/preference-toggle-menu-item/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { MenuItem } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { check } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { store as preferencesStore } from '../../store';\n\nexport default function PreferenceToggleMenuItem( {\n\tscope,\n\tname,\n\tlabel,\n\tinfo,\n\tmessageActivated,\n\tmessageDeactivated,\n\tshortcut,\n\thandleToggling = true,\n\tonToggle = () => null,\n\tdisabled = false,\n} ) {\n\tconst isActive = useSelect(\n\t\t( select ) => !! select( preferencesStore ).get( scope, name ),\n\t\t[ scope, name ]\n\t);\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst speakMessage = () => {\n\t\tif ( isActive ) {\n\t\t\tconst message =\n\t\t\t\tmessageDeactivated ||\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: preference name, e.g. 'Fullscreen mode' */\n\t\t\t\t\t__( 'Preference deactivated - %s' ),\n\t\t\t\t\tlabel\n\t\t\t\t);\n\t\t\tspeak( message );\n\t\t} else {\n\t\t\tconst message =\n\t\t\t\tmessageActivated ||\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: preference name, e.g. 'Fullscreen mode' */\n\t\t\t\t\t__( 'Preference activated - %s' ),\n\t\t\t\t\tlabel\n\t\t\t\t);\n\t\t\tspeak( message );\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\tonToggle();\n\t\t\t\tif ( handleToggling ) {\n\t\t\t\t\ttoggle( scope, name );\n\t\t\t\t}\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\tdisabled={ disabled }\n\t\t>\n\t\t\t{ label }\n\t\t</MenuItem>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAsDE;AAnDF,SAAS,WAAW,mBAAmB;AACvC,SAAS,gBAAgB;AACzB,SAAS,IAAI,eAAe;AAC5B,SAAS,aAAa;AACtB,SAAS,aAAa;AAKtB,SAAS,SAAS,wBAAwB;AAE3B,SAAR,yBAA2C;AAAA,EACjD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,WAAW,MAAM;AAAA,EACjB,WAAW;AACZ,GAAI;AACH,QAAM,WAAW;AAAA,IAChB,CAAE,WAAY,CAAC,CAAE,OAAQ,gBAAiB,EAAE,IAAK,OAAO,IAAK;AAAA,IAC7D,CAAE,OAAO,IAAK;AAAA,EACf;AACA,QAAM,EAAE,OAAO,IAAI,YAAa,gBAAiB;AACjD,QAAM,eAAe,MAAM;AAC1B,QAAK,UAAW;AACf,YAAM,UACL,sBACA;AAAA;AAAA,QAEC,GAAI,6BAA8B;AAAA,QAClC;AAAA,MACD;AACD,YAAO,OAAQ;AAAA,IAChB,OAAO;AACN,YAAM,UACL,oBACA;AAAA;AAAA,QAEC,GAAI,2BAA4B;AAAA,QAChC;AAAA,MACD;AACD,YAAO,OAAQ;AAAA,IAChB;AAAA,EACD;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAO,YAAY;AAAA,MACnB,YAAa;AAAA,MACb,SAAU,MAAM;AACf,iBAAS;AACT,YAAK,gBAAiB;AACrB,iBAAQ,OAAO,IAAK;AAAA,QACrB;AACA,qBAAa;AAAA,MACd;AAAA,MACA,MAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MAEE;AAAA;AAAA,EACH;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
onRequestClose: closeModal,
|
|
15
|
-
children: children
|
|
16
|
-
});
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Modal } from "@wordpress/components";
|
|
3
|
+
import { __ } from "@wordpress/i18n";
|
|
4
|
+
function PreferencesModal({ closeModal, children }) {
|
|
5
|
+
return /* @__PURE__ */ jsx(
|
|
6
|
+
Modal,
|
|
7
|
+
{
|
|
8
|
+
className: "preferences-modal",
|
|
9
|
+
title: __("Preferences"),
|
|
10
|
+
onRequestClose: closeModal,
|
|
11
|
+
children
|
|
12
|
+
}
|
|
13
|
+
);
|
|
17
14
|
}
|
|
18
|
-
|
|
15
|
+
export {
|
|
16
|
+
PreferencesModal as default
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/preferences-modal/index.js"],
|
|
4
|
+
"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=\"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"],
|
|
5
|
+
"mappings": "AAQE;AALF,SAAS,aAAa;AACtB,SAAS,UAAU;AAEJ,SAAR,iBAAmC,EAAE,YAAY,SAAS,GAAI;AACpE,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,OAAQ,GAAI,aAAc;AAAA,MAC1B,gBAAiB;AAAA,MAEf;AAAA;AAAA,EACH;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
const Section = ({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
})
|
|
7
|
-
className: "preferences-modal__section",
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
className: "preferences-modal__section-description",
|
|
15
|
-
children: description
|
|
16
|
-
})]
|
|
17
|
-
}), /*#__PURE__*/_jsx("div", {
|
|
18
|
-
className: "preferences-modal__section-content",
|
|
19
|
-
children: children
|
|
20
|
-
})]
|
|
21
|
-
});
|
|
22
|
-
export default Section;
|
|
23
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
const Section = ({ description, title, children }) => /* @__PURE__ */ jsxs("fieldset", { className: "preferences-modal__section", children: [
|
|
3
|
+
/* @__PURE__ */ jsxs("legend", { className: "preferences-modal__section-legend", children: [
|
|
4
|
+
/* @__PURE__ */ jsx("h2", { className: "preferences-modal__section-title", children: title }),
|
|
5
|
+
description && /* @__PURE__ */ jsx("p", { className: "preferences-modal__section-description", children: description })
|
|
6
|
+
] }),
|
|
7
|
+
/* @__PURE__ */ jsx("div", { className: "preferences-modal__section-content", children })
|
|
8
|
+
] });
|
|
9
|
+
var preferences_modal_section_default = Section;
|
|
10
|
+
export {
|
|
11
|
+
preferences_modal_section_default as default
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/preferences-modal-section/index.js"],
|
|
4
|
+
"sourcesContent": ["const Section = ( { description, title, children } ) => (\n\t<fieldset className=\"preferences-modal__section\">\n\t\t<legend className=\"preferences-modal__section-legend\">\n\t\t\t<h2 className=\"preferences-modal__section-title\">{ title }</h2>\n\t\t\t{ description && (\n\t\t\t\t<p className=\"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<div className=\"preferences-modal__section-content\">{ children }</div>\n\t</fieldset>\n);\n\nexport default Section;\n"],
|
|
5
|
+
"mappings": "AAEE,SACC,KADD;AAFF,MAAM,UAAU,CAAE,EAAE,aAAa,OAAO,SAAS,MAChD,qBAAC,cAAS,WAAU,8BACnB;AAAA,uBAAC,YAAO,WAAU,qCACjB;AAAA,wBAAC,QAAG,WAAU,oCAAqC,iBAAO;AAAA,IACxD,eACD,oBAAC,OAAE,WAAU,0CACV,uBACH;AAAA,KAEF;AAAA,EACA,oBAAC,SAAI,WAAU,sCAAuC,UAAU;AAAA,GACjE;AAGD,IAAO,oCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,144 +1,133 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// This is also used to sync the two different rendered components
|
|
25
|
-
// between small and large viewports.
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useViewportMatch } from "@wordpress/compose";
|
|
3
|
+
import {
|
|
4
|
+
Navigator,
|
|
5
|
+
__experimentalItemGroup as ItemGroup,
|
|
6
|
+
__experimentalItem as Item,
|
|
7
|
+
__experimentalHStack as HStack,
|
|
8
|
+
__experimentalText as Text,
|
|
9
|
+
__experimentalTruncate as Truncate,
|
|
10
|
+
FlexItem,
|
|
11
|
+
Card,
|
|
12
|
+
CardHeader,
|
|
13
|
+
CardBody,
|
|
14
|
+
privateApis as componentsPrivateApis
|
|
15
|
+
} from "@wordpress/components";
|
|
16
|
+
import { useMemo, useState } from "@wordpress/element";
|
|
17
|
+
import { chevronLeft, chevronRight, Icon } from "@wordpress/icons";
|
|
18
|
+
import { isRTL, __ } from "@wordpress/i18n";
|
|
19
|
+
import { unlock } from "../../lock-unlock";
|
|
20
|
+
const { Tabs } = unlock(componentsPrivateApis);
|
|
21
|
+
const PREFERENCES_MENU = "preferences-menu";
|
|
22
|
+
function PreferencesModalTabs({ sections }) {
|
|
23
|
+
const isLargeViewport = useViewportMatch("medium");
|
|
26
24
|
const [activeMenu, setActiveMenu] = useState(PREFERENCES_MENU);
|
|
27
|
-
|
|
28
|
-
* Create helper objects from `sections` for easier data handling.
|
|
29
|
-
* `tabs` is used for creating the `Tabs` and `sectionsContentMap`
|
|
30
|
-
* is used for easier access to active tab's content.
|
|
31
|
-
*/
|
|
32
|
-
const {
|
|
33
|
-
tabs,
|
|
34
|
-
sectionsContentMap
|
|
35
|
-
} = useMemo(() => {
|
|
25
|
+
const { tabs, sectionsContentMap } = useMemo(() => {
|
|
36
26
|
let mappedTabs = {
|
|
37
27
|
tabs: [],
|
|
38
28
|
sectionsContentMap: {}
|
|
39
29
|
};
|
|
40
30
|
if (sections.length) {
|
|
41
|
-
mappedTabs = sections.reduce(
|
|
42
|
-
name,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
accumulator.sectionsContentMap[name] = content;
|
|
51
|
-
return accumulator;
|
|
52
|
-
}, {
|
|
53
|
-
tabs: [],
|
|
54
|
-
sectionsContentMap: {}
|
|
55
|
-
});
|
|
31
|
+
mappedTabs = sections.reduce(
|
|
32
|
+
(accumulator, { name, tabLabel: title, content }) => {
|
|
33
|
+
accumulator.tabs.push({ name, title });
|
|
34
|
+
accumulator.sectionsContentMap[name] = content;
|
|
35
|
+
return accumulator;
|
|
36
|
+
},
|
|
37
|
+
{ tabs: [], sectionsContentMap: {} }
|
|
38
|
+
);
|
|
56
39
|
}
|
|
57
40
|
return mappedTabs;
|
|
58
41
|
}, [sections]);
|
|
59
42
|
let modalContent;
|
|
60
|
-
// We render different components based on the viewport size.
|
|
61
43
|
if (isLargeViewport) {
|
|
62
|
-
modalContent =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
defaultTabId: activeMenu !== PREFERENCES_MENU ? activeMenu :
|
|
44
|
+
modalContent = /* @__PURE__ */ jsx("div", { className: "preferences__tabs", children: /* @__PURE__ */ jsxs(
|
|
45
|
+
Tabs,
|
|
46
|
+
{
|
|
47
|
+
defaultTabId: activeMenu !== PREFERENCES_MENU ? activeMenu : void 0,
|
|
66
48
|
onSelect: setActiveMenu,
|
|
67
49
|
orientation: "vertical",
|
|
68
|
-
children: [
|
|
69
|
-
className: "preferences__tabs-tablist",
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ jsx(Tabs.TabList, { className: "preferences__tabs-tablist", children: tabs.map((tab) => /* @__PURE__ */ jsx(
|
|
52
|
+
Tabs.Tab,
|
|
53
|
+
{
|
|
54
|
+
tabId: tab.name,
|
|
55
|
+
className: "preferences__tabs-tab",
|
|
56
|
+
children: tab.title
|
|
57
|
+
},
|
|
58
|
+
tab.name
|
|
59
|
+
)) }),
|
|
60
|
+
tabs.map((tab) => /* @__PURE__ */ jsx(
|
|
61
|
+
Tabs.TabPanel,
|
|
62
|
+
{
|
|
63
|
+
tabId: tab.name,
|
|
64
|
+
className: "preferences__tabs-tabpanel",
|
|
65
|
+
focusable: false,
|
|
66
|
+
children: sectionsContentMap[tab.name] || null
|
|
67
|
+
},
|
|
68
|
+
tab.name
|
|
69
|
+
))
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
) });
|
|
83
73
|
} else {
|
|
84
|
-
modalContent =
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
children:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
})
|
|
138
|
-
}, `${section.name}-menu`);
|
|
139
|
-
})]
|
|
140
|
-
});
|
|
74
|
+
modalContent = /* @__PURE__ */ jsxs(Navigator, { initialPath: "/", className: "preferences__provider", children: [
|
|
75
|
+
/* @__PURE__ */ jsx(Navigator.Screen, { path: "/", children: /* @__PURE__ */ jsx(Card, { isBorderless: true, size: "small", children: /* @__PURE__ */ jsx(CardBody, { children: /* @__PURE__ */ jsx(ItemGroup, { children: tabs.map((tab) => {
|
|
76
|
+
return /* @__PURE__ */ jsx(
|
|
77
|
+
Navigator.Button,
|
|
78
|
+
{
|
|
79
|
+
path: `/${tab.name}`,
|
|
80
|
+
as: Item,
|
|
81
|
+
isAction: true,
|
|
82
|
+
children: /* @__PURE__ */ jsxs(HStack, { justify: "space-between", children: [
|
|
83
|
+
/* @__PURE__ */ jsx(FlexItem, { children: /* @__PURE__ */ jsx(Truncate, { children: tab.title }) }),
|
|
84
|
+
/* @__PURE__ */ jsx(FlexItem, { children: /* @__PURE__ */ jsx(
|
|
85
|
+
Icon,
|
|
86
|
+
{
|
|
87
|
+
icon: isRTL() ? chevronLeft : chevronRight
|
|
88
|
+
}
|
|
89
|
+
) })
|
|
90
|
+
] })
|
|
91
|
+
},
|
|
92
|
+
tab.name
|
|
93
|
+
);
|
|
94
|
+
}) }) }) }) }),
|
|
95
|
+
sections.length && sections.map((section) => {
|
|
96
|
+
return /* @__PURE__ */ jsx(
|
|
97
|
+
Navigator.Screen,
|
|
98
|
+
{
|
|
99
|
+
path: `/${section.name}`,
|
|
100
|
+
children: /* @__PURE__ */ jsxs(Card, { isBorderless: true, size: "large", children: [
|
|
101
|
+
/* @__PURE__ */ jsxs(
|
|
102
|
+
CardHeader,
|
|
103
|
+
{
|
|
104
|
+
isBorderless: false,
|
|
105
|
+
justify: "left",
|
|
106
|
+
size: "small",
|
|
107
|
+
gap: "6",
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ jsx(
|
|
110
|
+
Navigator.BackButton,
|
|
111
|
+
{
|
|
112
|
+
icon: isRTL() ? chevronRight : chevronLeft,
|
|
113
|
+
label: __("Back")
|
|
114
|
+
}
|
|
115
|
+
),
|
|
116
|
+
/* @__PURE__ */ jsx(Text, { size: "16", children: section.tabLabel })
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
/* @__PURE__ */ jsx(CardBody, { children: section.content })
|
|
121
|
+
] })
|
|
122
|
+
},
|
|
123
|
+
`${section.name}-menu`
|
|
124
|
+
);
|
|
125
|
+
})
|
|
126
|
+
] });
|
|
141
127
|
}
|
|
142
128
|
return modalContent;
|
|
143
129
|
}
|
|
144
|
-
|
|
130
|
+
export {
|
|
131
|
+
PreferencesModalTabs as default
|
|
132
|
+
};
|
|
133
|
+
//# sourceMappingURL=index.js.map
|