@wordpress/interface 4.2.3 → 4.2.4-next.a55ed9455a.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.
Files changed (44) hide show
  1. package/build/components/fullscreen-mode/index.js +1 -1
  2. package/build/components/fullscreen-mode/index.js.map +1 -1
  3. package/build/components/index.js +32 -0
  4. package/build/components/index.js.map +1 -1
  5. package/build/components/preferences-modal/index.js +29 -0
  6. package/build/components/preferences-modal/index.js.map +1 -0
  7. package/build/components/preferences-modal-base-option/index.js +35 -0
  8. package/build/components/preferences-modal-base-option/index.js.map +1 -0
  9. package/build/components/preferences-modal-section/index.js +27 -0
  10. package/build/components/preferences-modal-section/index.js.map +1 -0
  11. package/build/components/preferences-modal-tabs/index.js +121 -0
  12. package/build/components/preferences-modal-tabs/index.js.map +1 -0
  13. package/build-module/components/fullscreen-mode/index.js +1 -1
  14. package/build-module/components/fullscreen-mode/index.js.map +1 -1
  15. package/build-module/components/index.js +4 -0
  16. package/build-module/components/index.js.map +1 -1
  17. package/build-module/components/preferences-modal/index.js +20 -0
  18. package/build-module/components/preferences-modal/index.js.map +1 -0
  19. package/build-module/components/preferences-modal-base-option/index.js +27 -0
  20. package/build-module/components/preferences-modal-base-option/index.js.map +1 -0
  21. package/build-module/components/preferences-modal-section/index.js +19 -0
  22. package/build-module/components/preferences-modal-section/index.js.map +1 -0
  23. package/build-module/components/preferences-modal-tabs/index.js +110 -0
  24. package/build-module/components/preferences-modal-tabs/index.js.map +1 -0
  25. package/build-style/style-rtl.css +89 -0
  26. package/build-style/style.css +89 -0
  27. package/package.json +15 -11
  28. package/src/components/fullscreen-mode/index.js +1 -1
  29. package/src/components/fullscreen-mode/test/index.js +3 -3
  30. package/src/components/index.js +4 -0
  31. package/src/components/more-menu-dropdown/style.scss +1 -1
  32. package/src/components/preferences-modal/README.md +69 -0
  33. package/src/components/preferences-modal/index.js +18 -0
  34. package/src/components/preferences-modal/style.scss +25 -0
  35. package/src/components/preferences-modal-base-option/README.md +42 -0
  36. package/src/components/preferences-modal-base-option/index.js +20 -0
  37. package/src/components/preferences-modal-base-option/style.scss +21 -0
  38. package/src/components/preferences-modal-section/README.md +30 -0
  39. package/src/components/preferences-modal-section/index.js +17 -0
  40. package/src/components/preferences-modal-section/style.scss +20 -0
  41. package/src/components/preferences-modal-tabs/README.md +14 -0
  42. package/src/components/preferences-modal-tabs/index.js +156 -0
  43. package/src/components/preferences-modal-tabs/style.scss +35 -0
  44. package/src/style.scss +4 -0
@@ -18,7 +18,7 @@ const FullscreenMode = _ref => {
18
18
  let isSticky = false; // `is-fullscreen-mode` is set in PHP as a body class by Gutenberg, and this causes
19
19
  // `sticky-menu` to be applied by WordPress and prevents the admin menu being scrolled
20
20
  // even if `is-fullscreen-mode` is then removed. Let's remove `sticky-menu` here as
21
- // a consequence of the FullscreenMode setup
21
+ // a consequence of the FullscreenMode setup.
22
22
 
23
23
  if (document.body.classList.contains('sticky-menu')) {
24
24
  isSticky = true;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/interface/src/components/fullscreen-mode/index.js"],"names":["FullscreenMode","isActive","isSticky","document","body","classList","contains","remove","add"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA,MAAMA,cAAc,GAAG,QAAoB;AAAA,MAAlB;AAAEC,IAAAA;AAAF,GAAkB;AAC1C,0BAAW,MAAM;AAChB,QAAIC,QAAQ,GAAG,KAAf,CADgB,CAEhB;AACA;AACA;AACA;;AACA,QAAKC,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBC,QAAxB,CAAkC,aAAlC,CAAL,EAAyD;AACxDJ,MAAAA,QAAQ,GAAG,IAAX;AACAC,MAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBE,MAAxB,CAAgC,aAAhC;AACA;;AAED,WAAO,MAAM;AACZ,UAAKL,QAAL,EAAgB;AACfC,QAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBG,GAAxB,CAA6B,aAA7B;AACA;AACD,KAJD;AAKA,GAhBD,EAgBG,EAhBH;AAkBA,0BAAW,MAAM;AAChB,QAAKP,QAAL,EAAgB;AACfE,MAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBG,GAAxB,CAA6B,oBAA7B;AACA,KAFD,MAEO;AACNL,MAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBE,MAAxB,CAAgC,oBAAhC;AACA;;AAED,WAAO,MAAM;AACZ,UAAKN,QAAL,EAAgB;AACfE,QAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBE,MAAxB,CAAgC,oBAAhC;AACA;AACD,KAJD;AAKA,GAZD,EAYG,CAAEN,QAAF,CAZH;AAcA,SAAO,IAAP;AACA,CAlCD;;eAmCeD,c","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\nconst FullscreenMode = ( { isActive } ) => {\n\tuseEffect( () => {\n\t\tlet isSticky = false;\n\t\t// `is-fullscreen-mode` is set in PHP as a body class by Gutenberg, and this causes\n\t\t// `sticky-menu` to be applied by WordPress and prevents the admin menu being scrolled\n\t\t// even if `is-fullscreen-mode` is then removed. Let's remove `sticky-menu` here as\n\t\t// a consequence of the FullscreenMode setup\n\t\tif ( document.body.classList.contains( 'sticky-menu' ) ) {\n\t\t\tisSticky = true;\n\t\t\tdocument.body.classList.remove( 'sticky-menu' );\n\t\t}\n\n\t\treturn () => {\n\t\t\tif ( isSticky ) {\n\t\t\t\tdocument.body.classList.add( 'sticky-menu' );\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( isActive ) {\n\t\t\tdocument.body.classList.add( 'is-fullscreen-mode' );\n\t\t} else {\n\t\t\tdocument.body.classList.remove( 'is-fullscreen-mode' );\n\t\t}\n\n\t\treturn () => {\n\t\t\tif ( isActive ) {\n\t\t\t\tdocument.body.classList.remove( 'is-fullscreen-mode' );\n\t\t\t}\n\t\t};\n\t}, [ isActive ] );\n\n\treturn null;\n};\nexport default FullscreenMode;\n"]}
1
+ {"version":3,"sources":["@wordpress/interface/src/components/fullscreen-mode/index.js"],"names":["FullscreenMode","isActive","isSticky","document","body","classList","contains","remove","add"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA,MAAMA,cAAc,GAAG,QAAoB;AAAA,MAAlB;AAAEC,IAAAA;AAAF,GAAkB;AAC1C,0BAAW,MAAM;AAChB,QAAIC,QAAQ,GAAG,KAAf,CADgB,CAEhB;AACA;AACA;AACA;;AACA,QAAKC,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBC,QAAxB,CAAkC,aAAlC,CAAL,EAAyD;AACxDJ,MAAAA,QAAQ,GAAG,IAAX;AACAC,MAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBE,MAAxB,CAAgC,aAAhC;AACA;;AAED,WAAO,MAAM;AACZ,UAAKL,QAAL,EAAgB;AACfC,QAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBG,GAAxB,CAA6B,aAA7B;AACA;AACD,KAJD;AAKA,GAhBD,EAgBG,EAhBH;AAkBA,0BAAW,MAAM;AAChB,QAAKP,QAAL,EAAgB;AACfE,MAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBG,GAAxB,CAA6B,oBAA7B;AACA,KAFD,MAEO;AACNL,MAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBE,MAAxB,CAAgC,oBAAhC;AACA;;AAED,WAAO,MAAM;AACZ,UAAKN,QAAL,EAAgB;AACfE,QAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBE,MAAxB,CAAgC,oBAAhC;AACA;AACD,KAJD;AAKA,GAZD,EAYG,CAAEN,QAAF,CAZH;AAcA,SAAO,IAAP;AACA,CAlCD;;eAmCeD,c","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\nconst FullscreenMode = ( { isActive } ) => {\n\tuseEffect( () => {\n\t\tlet isSticky = false;\n\t\t// `is-fullscreen-mode` is set in PHP as a body class by Gutenberg, and this causes\n\t\t// `sticky-menu` to be applied by WordPress and prevents the admin menu being scrolled\n\t\t// even if `is-fullscreen-mode` is then removed. Let's remove `sticky-menu` here as\n\t\t// a consequence of the FullscreenMode setup.\n\t\tif ( document.body.classList.contains( 'sticky-menu' ) ) {\n\t\t\tisSticky = true;\n\t\t\tdocument.body.classList.remove( 'sticky-menu' );\n\t\t}\n\n\t\treturn () => {\n\t\t\tif ( isSticky ) {\n\t\t\t\tdocument.body.classList.add( 'sticky-menu' );\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( isActive ) {\n\t\t\tdocument.body.classList.add( 'is-fullscreen-mode' );\n\t\t} else {\n\t\t\tdocument.body.classList.remove( 'is-fullscreen-mode' );\n\t\t}\n\n\t\treturn () => {\n\t\t\tif ( isActive ) {\n\t\t\t\tdocument.body.classList.remove( 'is-fullscreen-mode' );\n\t\t\t}\n\t\t};\n\t}, [ isActive ] );\n\n\treturn null;\n};\nexport default FullscreenMode;\n"]}
@@ -53,6 +53,30 @@ Object.defineProperty(exports, "PinnedItems", {
53
53
  return _pinnedItems.default;
54
54
  }
55
55
  });
56
+ Object.defineProperty(exports, "PreferencesModal", {
57
+ enumerable: true,
58
+ get: function () {
59
+ return _preferencesModal.default;
60
+ }
61
+ });
62
+ Object.defineProperty(exports, "PreferencesModalSection", {
63
+ enumerable: true,
64
+ get: function () {
65
+ return _preferencesModalSection.default;
66
+ }
67
+ });
68
+ Object.defineProperty(exports, "PreferencesModalTabs", {
69
+ enumerable: true,
70
+ get: function () {
71
+ return _preferencesModalTabs.default;
72
+ }
73
+ });
74
+ Object.defineProperty(exports, "___unstablePreferencesModalBaseOption", {
75
+ enumerable: true,
76
+ get: function () {
77
+ return _preferencesModalBaseOption.default;
78
+ }
79
+ });
56
80
 
57
81
  var _complementaryArea = _interopRequireDefault(require("./complementary-area"));
58
82
 
@@ -69,4 +93,12 @@ var _moreMenuDropdown = _interopRequireDefault(require("./more-menu-dropdown"));
69
93
  var _moreMenuFeatureToggle = _interopRequireDefault(require("./more-menu-feature-toggle"));
70
94
 
71
95
  var _actionItem = _interopRequireDefault(require("./action-item"));
96
+
97
+ var _preferencesModal = _interopRequireDefault(require("./preferences-modal"));
98
+
99
+ var _preferencesModalTabs = _interopRequireDefault(require("./preferences-modal-tabs"));
100
+
101
+ var _preferencesModalSection = _interopRequireDefault(require("./preferences-modal-section"));
102
+
103
+ var _preferencesModalBaseOption = _interopRequireDefault(require("./preferences-modal-base-option"));
72
104
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/interface/src/components/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["export { default as ComplementaryArea } from './complementary-area';\nexport { default as ComplementaryAreaMoreMenuItem } from './complementary-area-more-menu-item';\nexport { default as FullscreenMode } from './fullscreen-mode';\nexport { default as InterfaceSkeleton } from './interface-skeleton';\nexport { default as PinnedItems } from './pinned-items';\nexport { default as MoreMenuDropdown } from './more-menu-dropdown';\nexport { default as MoreMenuFeatureToggle } from './more-menu-feature-toggle';\nexport { default as ActionItem } from './action-item';\n"]}
1
+ {"version":3,"sources":["@wordpress/interface/src/components/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["export { default as ComplementaryArea } from './complementary-area';\nexport { default as ComplementaryAreaMoreMenuItem } from './complementary-area-more-menu-item';\nexport { default as FullscreenMode } from './fullscreen-mode';\nexport { default as InterfaceSkeleton } from './interface-skeleton';\nexport { default as PinnedItems } from './pinned-items';\nexport { default as MoreMenuDropdown } from './more-menu-dropdown';\nexport { default as MoreMenuFeatureToggle } from './more-menu-feature-toggle';\nexport { default as ActionItem } from './action-item';\nexport { default as PreferencesModal } from './preferences-modal';\nexport { default as PreferencesModalTabs } from './preferences-modal-tabs';\nexport { default as PreferencesModalSection } from './preferences-modal-section';\nexport { default as ___unstablePreferencesModalBaseOption } from './preferences-modal-base-option';\n"]}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = PreferencesModal;
7
+
8
+ var _element = require("@wordpress/element");
9
+
10
+ var _components = require("@wordpress/components");
11
+
12
+ var _i18n = require("@wordpress/i18n");
13
+
14
+ /**
15
+ * WordPress dependencies
16
+ */
17
+ function PreferencesModal(_ref) {
18
+ let {
19
+ closeModal,
20
+ children
21
+ } = _ref;
22
+ return (0, _element.createElement)(_components.Modal, {
23
+ className: "interface-preferences-modal",
24
+ title: (0, _i18n.__)('Preferences'),
25
+ closeLabel: (0, _i18n.__)('Close'),
26
+ onRequestClose: closeModal
27
+ }, children);
28
+ }
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/interface/src/components/preferences-modal/index.js"],"names":["PreferencesModal","closeModal","children"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIe,SAASA,gBAAT,OAAsD;AAAA,MAA3B;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAA2B;AACpE,SACC,4BAAC,iBAAD;AACC,IAAA,SAAS,EAAC,6BADX;AAEC,IAAA,KAAK,EAAG,cAAI,aAAJ,CAFT;AAGC,IAAA,UAAU,EAAG,cAAI,OAAJ,CAHd;AAIC,IAAA,cAAc,EAAGD;AAJlB,KAMGC,QANH,CADD;AAUA","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\tcloseLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ closeModal }\n\t\t>\n\t\t\t{ children }\n\t\t</Modal>\n\t);\n}\n"]}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _element = require("@wordpress/element");
9
+
10
+ var _components = require("@wordpress/components");
11
+
12
+ /**
13
+ * WordPress dependencies
14
+ */
15
+ function BaseOption(_ref) {
16
+ let {
17
+ help,
18
+ label,
19
+ isChecked,
20
+ onChange,
21
+ children
22
+ } = _ref;
23
+ return (0, _element.createElement)("div", {
24
+ className: "interface-preferences-modal__option"
25
+ }, (0, _element.createElement)(_components.ToggleControl, {
26
+ help: help,
27
+ label: label,
28
+ checked: isChecked,
29
+ onChange: onChange
30
+ }), children);
31
+ }
32
+
33
+ var _default = BaseOption;
34
+ exports.default = _default;
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/interface/src/components/preferences-modal-base-option/index.js"],"names":["BaseOption","help","label","isChecked","onChange","children"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;AAGA,SAASA,UAAT,OAAsE;AAAA,MAAjD;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,KAAR;AAAeC,IAAAA,SAAf;AAA0BC,IAAAA,QAA1B;AAAoCC,IAAAA;AAApC,GAAiD;AACrE,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,yBAAD;AACC,IAAA,IAAI,EAAGJ,IADR;AAEC,IAAA,KAAK,EAAGC,KAFT;AAGC,IAAA,OAAO,EAAGC,SAHX;AAIC,IAAA,QAAQ,EAAGC;AAJZ,IADD,EAOGC,QAPH,CADD;AAWA;;eAEcL,U","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\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"]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _element = require("@wordpress/element");
9
+
10
+ const Section = _ref => {
11
+ let {
12
+ description,
13
+ title,
14
+ children
15
+ } = _ref;
16
+ return (0, _element.createElement)("fieldset", {
17
+ className: "interface-preferences-modal__section"
18
+ }, (0, _element.createElement)("legend", null, (0, _element.createElement)("h2", {
19
+ className: "interface-preferences-modal__section-title"
20
+ }, title), description && (0, _element.createElement)("p", {
21
+ className: "interface-preferences-modal__section-description"
22
+ }, description)), children);
23
+ };
24
+
25
+ var _default = Section;
26
+ exports.default = _default;
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/interface/src/components/preferences-modal-section/index.js"],"names":["Section","description","title","children"],"mappings":";;;;;;;;;AAAA,MAAMA,OAAO,GAAG;AAAA,MAAE;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,KAAf;AAAsBC,IAAAA;AAAtB,GAAF;AAAA,SACf;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,4CACC;AAAI,IAAA,SAAS,EAAC;AAAd,KACGD,KADH,CADD,EAIGD,WAAW,IACZ;AAAG,IAAA,SAAS,EAAC;AAAb,KACGA,WADH,CALF,CADD,EAWGE,QAXH,CADe;AAAA,CAAhB;;eAgBeH,O","sourcesContent":["const Section = ( { description, title, children } ) => (\n\t<fieldset className=\"interface-preferences-modal__section\">\n\t\t<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"]}
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = PreferencesModalTabs;
7
+
8
+ var _element = require("@wordpress/element");
9
+
10
+ var _compose = require("@wordpress/compose");
11
+
12
+ var _components = require("@wordpress/components");
13
+
14
+ var _icons = require("@wordpress/icons");
15
+
16
+ var _i18n = require("@wordpress/i18n");
17
+
18
+ /**
19
+ * WordPress dependencies
20
+ */
21
+ const PREFERENCES_MENU = 'preferences-menu';
22
+
23
+ function PreferencesModalTabs(_ref) {
24
+ let {
25
+ sections
26
+ } = _ref;
27
+ const isLargeViewport = (0, _compose.useViewportMatch)('medium'); // This is also used to sync the two different rendered components
28
+ // between small and large viewports.
29
+
30
+ const [activeMenu, setActiveMenu] = (0, _element.useState)(PREFERENCES_MENU);
31
+ /**
32
+ * Create helper objects from `sections` for easier data handling.
33
+ * `tabs` is used for creating the `TabPanel` and `sectionsContentMap`
34
+ * is used for easier access to active tab's content.
35
+ */
36
+
37
+ const {
38
+ tabs,
39
+ sectionsContentMap
40
+ } = (0, _element.useMemo)(() => {
41
+ let mappedTabs = {
42
+ tabs: [],
43
+ sectionsContentMap: {}
44
+ };
45
+
46
+ if (sections.length) {
47
+ mappedTabs = sections.reduce((accumulator, _ref2) => {
48
+ let {
49
+ name,
50
+ tabLabel: title,
51
+ content
52
+ } = _ref2;
53
+ accumulator.tabs.push({
54
+ name,
55
+ title
56
+ });
57
+ accumulator.sectionsContentMap[name] = content;
58
+ return accumulator;
59
+ }, {
60
+ tabs: [],
61
+ sectionsContentMap: {}
62
+ });
63
+ }
64
+
65
+ return mappedTabs;
66
+ }, [sections]);
67
+ const getCurrentTab = (0, _element.useCallback)(tab => sectionsContentMap[tab.name] || null, [sectionsContentMap]);
68
+ let modalContent; // We render different components based on the viewport size.
69
+
70
+ if (isLargeViewport) {
71
+ modalContent = (0, _element.createElement)(_components.TabPanel, {
72
+ className: "interface-preferences__tabs",
73
+ tabs: tabs,
74
+ initialTabName: activeMenu !== PREFERENCES_MENU ? activeMenu : undefined,
75
+ onSelect: setActiveMenu,
76
+ orientation: "vertical"
77
+ }, getCurrentTab);
78
+ } else {
79
+ modalContent = (0, _element.createElement)(_components.__experimentalNavigatorProvider, {
80
+ initialPath: "/",
81
+ className: "interface-preferences__provider"
82
+ }, (0, _element.createElement)(_components.__experimentalNavigatorScreen, {
83
+ path: "/"
84
+ }, (0, _element.createElement)(_components.Card, {
85
+ isBorderless: true,
86
+ size: "small"
87
+ }, (0, _element.createElement)(_components.CardBody, null, (0, _element.createElement)(_components.__experimentalItemGroup, null, tabs.map(tab => {
88
+ return (0, _element.createElement)(_components.__experimentalNavigatorButton, {
89
+ key: tab.name,
90
+ path: tab.name,
91
+ as: _components.__experimentalItem,
92
+ isAction: true
93
+ }, (0, _element.createElement)(_components.__experimentalHStack, {
94
+ justify: "space-between"
95
+ }, (0, _element.createElement)(_components.FlexItem, null, (0, _element.createElement)(_components.__experimentalTruncate, null, tab.title)), (0, _element.createElement)(_components.FlexItem, null, (0, _element.createElement)(_icons.Icon, {
96
+ icon: (0, _i18n.isRTL)() ? _icons.chevronLeft : _icons.chevronRight
97
+ }))));
98
+ }))))), sections.length && sections.map(section => {
99
+ return (0, _element.createElement)(_components.__experimentalNavigatorScreen, {
100
+ key: `${section.name}-menu`,
101
+ path: section.name
102
+ }, (0, _element.createElement)(_components.Card, {
103
+ isBorderless: true,
104
+ size: "large"
105
+ }, (0, _element.createElement)(_components.CardHeader, {
106
+ isBorderless: false,
107
+ justify: "left",
108
+ size: "small",
109
+ gap: "6"
110
+ }, (0, _element.createElement)(_components.__experimentalNavigatorBackButton, {
111
+ icon: (0, _i18n.isRTL)() ? _icons.chevronRight : _icons.chevronLeft,
112
+ "aria-label": (0, _i18n.__)('Navigate to the previous view')
113
+ }), (0, _element.createElement)(_components.__experimentalText, {
114
+ size: "16"
115
+ }, section.tabLabel)), (0, _element.createElement)(_components.CardBody, null, section.content)));
116
+ }));
117
+ }
118
+
119
+ return modalContent;
120
+ }
121
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/interface/src/components/preferences-modal-tabs/index.js"],"names":["PREFERENCES_MENU","PreferencesModalTabs","sections","isLargeViewport","activeMenu","setActiveMenu","tabs","sectionsContentMap","mappedTabs","length","reduce","accumulator","name","tabLabel","title","content","push","getCurrentTab","tab","modalContent","undefined","map","Item","chevronLeft","chevronRight","section"],"mappings":"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","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 }</CardBody>\n\t\t\t\t\t\t\t\t</Card>\n\t\t\t\t\t\t\t</NavigatorScreen>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t</NavigatorProvider>\n\t\t);\n\t}\n\n\treturn modalContent;\n}\n"]}
@@ -11,7 +11,7 @@ const FullscreenMode = _ref => {
11
11
  let isSticky = false; // `is-fullscreen-mode` is set in PHP as a body class by Gutenberg, and this causes
12
12
  // `sticky-menu` to be applied by WordPress and prevents the admin menu being scrolled
13
13
  // even if `is-fullscreen-mode` is then removed. Let's remove `sticky-menu` here as
14
- // a consequence of the FullscreenMode setup
14
+ // a consequence of the FullscreenMode setup.
15
15
 
16
16
  if (document.body.classList.contains('sticky-menu')) {
17
17
  isSticky = true;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/interface/src/components/fullscreen-mode/index.js"],"names":["useEffect","FullscreenMode","isActive","isSticky","document","body","classList","contains","remove","add"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;;AAEA,MAAMC,cAAc,GAAG,QAAoB;AAAA,MAAlB;AAAEC,IAAAA;AAAF,GAAkB;AAC1CF,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAIG,QAAQ,GAAG,KAAf,CADgB,CAEhB;AACA;AACA;AACA;;AACA,QAAKC,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBC,QAAxB,CAAkC,aAAlC,CAAL,EAAyD;AACxDJ,MAAAA,QAAQ,GAAG,IAAX;AACAC,MAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBE,MAAxB,CAAgC,aAAhC;AACA;;AAED,WAAO,MAAM;AACZ,UAAKL,QAAL,EAAgB;AACfC,QAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBG,GAAxB,CAA6B,aAA7B;AACA;AACD,KAJD;AAKA,GAhBQ,EAgBN,EAhBM,CAAT;AAkBAT,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAKE,QAAL,EAAgB;AACfE,MAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBG,GAAxB,CAA6B,oBAA7B;AACA,KAFD,MAEO;AACNL,MAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBE,MAAxB,CAAgC,oBAAhC;AACA;;AAED,WAAO,MAAM;AACZ,UAAKN,QAAL,EAAgB;AACfE,QAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBE,MAAxB,CAAgC,oBAAhC;AACA;AACD,KAJD;AAKA,GAZQ,EAYN,CAAEN,QAAF,CAZM,CAAT;AAcA,SAAO,IAAP;AACA,CAlCD;;AAmCA,eAAeD,cAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\nconst FullscreenMode = ( { isActive } ) => {\n\tuseEffect( () => {\n\t\tlet isSticky = false;\n\t\t// `is-fullscreen-mode` is set in PHP as a body class by Gutenberg, and this causes\n\t\t// `sticky-menu` to be applied by WordPress and prevents the admin menu being scrolled\n\t\t// even if `is-fullscreen-mode` is then removed. Let's remove `sticky-menu` here as\n\t\t// a consequence of the FullscreenMode setup\n\t\tif ( document.body.classList.contains( 'sticky-menu' ) ) {\n\t\t\tisSticky = true;\n\t\t\tdocument.body.classList.remove( 'sticky-menu' );\n\t\t}\n\n\t\treturn () => {\n\t\t\tif ( isSticky ) {\n\t\t\t\tdocument.body.classList.add( 'sticky-menu' );\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( isActive ) {\n\t\t\tdocument.body.classList.add( 'is-fullscreen-mode' );\n\t\t} else {\n\t\t\tdocument.body.classList.remove( 'is-fullscreen-mode' );\n\t\t}\n\n\t\treturn () => {\n\t\t\tif ( isActive ) {\n\t\t\t\tdocument.body.classList.remove( 'is-fullscreen-mode' );\n\t\t\t}\n\t\t};\n\t}, [ isActive ] );\n\n\treturn null;\n};\nexport default FullscreenMode;\n"]}
1
+ {"version":3,"sources":["@wordpress/interface/src/components/fullscreen-mode/index.js"],"names":["useEffect","FullscreenMode","isActive","isSticky","document","body","classList","contains","remove","add"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;;AAEA,MAAMC,cAAc,GAAG,QAAoB;AAAA,MAAlB;AAAEC,IAAAA;AAAF,GAAkB;AAC1CF,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAIG,QAAQ,GAAG,KAAf,CADgB,CAEhB;AACA;AACA;AACA;;AACA,QAAKC,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBC,QAAxB,CAAkC,aAAlC,CAAL,EAAyD;AACxDJ,MAAAA,QAAQ,GAAG,IAAX;AACAC,MAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBE,MAAxB,CAAgC,aAAhC;AACA;;AAED,WAAO,MAAM;AACZ,UAAKL,QAAL,EAAgB;AACfC,QAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBG,GAAxB,CAA6B,aAA7B;AACA;AACD,KAJD;AAKA,GAhBQ,EAgBN,EAhBM,CAAT;AAkBAT,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAKE,QAAL,EAAgB;AACfE,MAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBG,GAAxB,CAA6B,oBAA7B;AACA,KAFD,MAEO;AACNL,MAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBE,MAAxB,CAAgC,oBAAhC;AACA;;AAED,WAAO,MAAM;AACZ,UAAKN,QAAL,EAAgB;AACfE,QAAAA,QAAQ,CAACC,IAAT,CAAcC,SAAd,CAAwBE,MAAxB,CAAgC,oBAAhC;AACA;AACD,KAJD;AAKA,GAZQ,EAYN,CAAEN,QAAF,CAZM,CAAT;AAcA,SAAO,IAAP;AACA,CAlCD;;AAmCA,eAAeD,cAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\nconst FullscreenMode = ( { isActive } ) => {\n\tuseEffect( () => {\n\t\tlet isSticky = false;\n\t\t// `is-fullscreen-mode` is set in PHP as a body class by Gutenberg, and this causes\n\t\t// `sticky-menu` to be applied by WordPress and prevents the admin menu being scrolled\n\t\t// even if `is-fullscreen-mode` is then removed. Let's remove `sticky-menu` here as\n\t\t// a consequence of the FullscreenMode setup.\n\t\tif ( document.body.classList.contains( 'sticky-menu' ) ) {\n\t\t\tisSticky = true;\n\t\t\tdocument.body.classList.remove( 'sticky-menu' );\n\t\t}\n\n\t\treturn () => {\n\t\t\tif ( isSticky ) {\n\t\t\t\tdocument.body.classList.add( 'sticky-menu' );\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( isActive ) {\n\t\t\tdocument.body.classList.add( 'is-fullscreen-mode' );\n\t\t} else {\n\t\t\tdocument.body.classList.remove( 'is-fullscreen-mode' );\n\t\t}\n\n\t\treturn () => {\n\t\t\tif ( isActive ) {\n\t\t\t\tdocument.body.classList.remove( 'is-fullscreen-mode' );\n\t\t\t}\n\t\t};\n\t}, [ isActive ] );\n\n\treturn null;\n};\nexport default FullscreenMode;\n"]}
@@ -6,4 +6,8 @@ export { default as PinnedItems } from './pinned-items';
6
6
  export { default as MoreMenuDropdown } from './more-menu-dropdown';
7
7
  export { default as MoreMenuFeatureToggle } from './more-menu-feature-toggle';
8
8
  export { default as ActionItem } from './action-item';
9
+ export { default as PreferencesModal } from './preferences-modal';
10
+ export { default as PreferencesModalTabs } from './preferences-modal-tabs';
11
+ export { default as PreferencesModalSection } from './preferences-modal-section';
12
+ export { default as ___unstablePreferencesModalBaseOption } from './preferences-modal-base-option';
9
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/interface/src/components/index.js"],"names":["default","ComplementaryArea","ComplementaryAreaMoreMenuItem","FullscreenMode","InterfaceSkeleton","PinnedItems","MoreMenuDropdown","MoreMenuFeatureToggle","ActionItem"],"mappings":"AAAA,SAASA,OAAO,IAAIC,iBAApB,QAA6C,sBAA7C;AACA,SAASD,OAAO,IAAIE,6BAApB,QAAyD,qCAAzD;AACA,SAASF,OAAO,IAAIG,cAApB,QAA0C,mBAA1C;AACA,SAASH,OAAO,IAAII,iBAApB,QAA6C,sBAA7C;AACA,SAASJ,OAAO,IAAIK,WAApB,QAAuC,gBAAvC;AACA,SAASL,OAAO,IAAIM,gBAApB,QAA4C,sBAA5C;AACA,SAASN,OAAO,IAAIO,qBAApB,QAAiD,4BAAjD;AACA,SAASP,OAAO,IAAIQ,UAApB,QAAsC,eAAtC","sourcesContent":["export { default as ComplementaryArea } from './complementary-area';\nexport { default as ComplementaryAreaMoreMenuItem } from './complementary-area-more-menu-item';\nexport { default as FullscreenMode } from './fullscreen-mode';\nexport { default as InterfaceSkeleton } from './interface-skeleton';\nexport { default as PinnedItems } from './pinned-items';\nexport { default as MoreMenuDropdown } from './more-menu-dropdown';\nexport { default as MoreMenuFeatureToggle } from './more-menu-feature-toggle';\nexport { default as ActionItem } from './action-item';\n"]}
1
+ {"version":3,"sources":["@wordpress/interface/src/components/index.js"],"names":["default","ComplementaryArea","ComplementaryAreaMoreMenuItem","FullscreenMode","InterfaceSkeleton","PinnedItems","MoreMenuDropdown","MoreMenuFeatureToggle","ActionItem","PreferencesModal","PreferencesModalTabs","PreferencesModalSection","___unstablePreferencesModalBaseOption"],"mappings":"AAAA,SAASA,OAAO,IAAIC,iBAApB,QAA6C,sBAA7C;AACA,SAASD,OAAO,IAAIE,6BAApB,QAAyD,qCAAzD;AACA,SAASF,OAAO,IAAIG,cAApB,QAA0C,mBAA1C;AACA,SAASH,OAAO,IAAII,iBAApB,QAA6C,sBAA7C;AACA,SAASJ,OAAO,IAAIK,WAApB,QAAuC,gBAAvC;AACA,SAASL,OAAO,IAAIM,gBAApB,QAA4C,sBAA5C;AACA,SAASN,OAAO,IAAIO,qBAApB,QAAiD,4BAAjD;AACA,SAASP,OAAO,IAAIQ,UAApB,QAAsC,eAAtC;AACA,SAASR,OAAO,IAAIS,gBAApB,QAA4C,qBAA5C;AACA,SAAST,OAAO,IAAIU,oBAApB,QAAgD,0BAAhD;AACA,SAASV,OAAO,IAAIW,uBAApB,QAAmD,6BAAnD;AACA,SAASX,OAAO,IAAIY,qCAApB,QAAiE,iCAAjE","sourcesContent":["export { default as ComplementaryArea } from './complementary-area';\nexport { default as ComplementaryAreaMoreMenuItem } from './complementary-area-more-menu-item';\nexport { default as FullscreenMode } from './fullscreen-mode';\nexport { default as InterfaceSkeleton } from './interface-skeleton';\nexport { default as PinnedItems } from './pinned-items';\nexport { default as MoreMenuDropdown } from './more-menu-dropdown';\nexport { default as MoreMenuFeatureToggle } from './more-menu-feature-toggle';\nexport { default as ActionItem } from './action-item';\nexport { default as PreferencesModal } from './preferences-modal';\nexport { default as PreferencesModalTabs } from './preferences-modal-tabs';\nexport { default as PreferencesModalSection } from './preferences-modal-section';\nexport { default as ___unstablePreferencesModalBaseOption } from './preferences-modal-base-option';\n"]}
@@ -0,0 +1,20 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { Modal } from '@wordpress/components';
7
+ import { __ } from '@wordpress/i18n';
8
+ export default function PreferencesModal(_ref) {
9
+ let {
10
+ closeModal,
11
+ children
12
+ } = _ref;
13
+ return createElement(Modal, {
14
+ className: "interface-preferences-modal",
15
+ title: __('Preferences'),
16
+ closeLabel: __('Close'),
17
+ onRequestClose: closeModal
18
+ }, children);
19
+ }
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/interface/src/components/preferences-modal/index.js"],"names":["Modal","__","PreferencesModal","closeModal","children"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAT,QAAsB,uBAAtB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA,eAAe,SAASC,gBAAT,OAAsD;AAAA,MAA3B;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAA2B;AACpE,SACC,cAAC,KAAD;AACC,IAAA,SAAS,EAAC,6BADX;AAEC,IAAA,KAAK,EAAGH,EAAE,CAAE,aAAF,CAFX;AAGC,IAAA,UAAU,EAAGA,EAAE,CAAE,OAAF,CAHhB;AAIC,IAAA,cAAc,EAAGE;AAJlB,KAMGC,QANH,CADD;AAUA","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\tcloseLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ closeModal }\n\t\t>\n\t\t\t{ children }\n\t\t</Modal>\n\t);\n}\n"]}
@@ -0,0 +1,27 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { ToggleControl } from '@wordpress/components';
7
+
8
+ function BaseOption(_ref) {
9
+ let {
10
+ help,
11
+ label,
12
+ isChecked,
13
+ onChange,
14
+ children
15
+ } = _ref;
16
+ return createElement("div", {
17
+ className: "interface-preferences-modal__option"
18
+ }, createElement(ToggleControl, {
19
+ help: help,
20
+ label: label,
21
+ checked: isChecked,
22
+ onChange: onChange
23
+ }), children);
24
+ }
25
+
26
+ export default BaseOption;
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/interface/src/components/preferences-modal-base-option/index.js"],"names":["ToggleControl","BaseOption","help","label","isChecked","onChange","children"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,uBAA9B;;AAEA,SAASC,UAAT,OAAsE;AAAA,MAAjD;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,KAAR;AAAeC,IAAAA,SAAf;AAA0BC,IAAAA,QAA1B;AAAoCC,IAAAA;AAApC,GAAiD;AACrE,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,aAAD;AACC,IAAA,IAAI,EAAGJ,IADR;AAEC,IAAA,KAAK,EAAGC,KAFT;AAGC,IAAA,OAAO,EAAGC,SAHX;AAIC,IAAA,QAAQ,EAAGC;AAJZ,IADD,EAOGC,QAPH,CADD;AAWA;;AAED,eAAeL,UAAf","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\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"]}
@@ -0,0 +1,19 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ const Section = _ref => {
4
+ let {
5
+ description,
6
+ title,
7
+ children
8
+ } = _ref;
9
+ return createElement("fieldset", {
10
+ className: "interface-preferences-modal__section"
11
+ }, createElement("legend", null, createElement("h2", {
12
+ className: "interface-preferences-modal__section-title"
13
+ }, title), description && createElement("p", {
14
+ className: "interface-preferences-modal__section-description"
15
+ }, description)), children);
16
+ };
17
+
18
+ export default Section;
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/interface/src/components/preferences-modal-section/index.js"],"names":["Section","description","title","children"],"mappings":";;AAAA,MAAMA,OAAO,GAAG;AAAA,MAAE;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,KAAf;AAAsBC,IAAAA;AAAtB,GAAF;AAAA,SACf;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,8BACC;AAAI,IAAA,SAAS,EAAC;AAAd,KACGD,KADH,CADD,EAIGD,WAAW,IACZ;AAAG,IAAA,SAAS,EAAC;AAAb,KACGA,WADH,CALF,CADD,EAWGE,QAXH,CADe;AAAA,CAAhB;;AAgBA,eAAeH,OAAf","sourcesContent":["const Section = ( { description, title, children } ) => (\n\t<fieldset className=\"interface-preferences-modal__section\">\n\t\t<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"]}
@@ -0,0 +1,110 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { useViewportMatch } from '@wordpress/compose';
7
+ import { __experimentalNavigatorProvider as NavigatorProvider, __experimentalNavigatorScreen as NavigatorScreen, __experimentalNavigatorButton as NavigatorButton, __experimentalNavigatorBackButton as NavigatorBackButton, __experimentalItemGroup as ItemGroup, __experimentalItem as Item, __experimentalHStack as HStack, __experimentalText as Text, __experimentalTruncate as Truncate, FlexItem, TabPanel, Card, CardHeader, CardBody } from '@wordpress/components';
8
+ import { useMemo, useCallback, useState } from '@wordpress/element';
9
+ import { chevronLeft, chevronRight, Icon } from '@wordpress/icons';
10
+ import { isRTL, __ } from '@wordpress/i18n';
11
+ const PREFERENCES_MENU = 'preferences-menu';
12
+ export default function PreferencesModalTabs(_ref) {
13
+ let {
14
+ sections
15
+ } = _ref;
16
+ const isLargeViewport = useViewportMatch('medium'); // This is also used to sync the two different rendered components
17
+ // between small and large viewports.
18
+
19
+ const [activeMenu, setActiveMenu] = useState(PREFERENCES_MENU);
20
+ /**
21
+ * Create helper objects from `sections` for easier data handling.
22
+ * `tabs` is used for creating the `TabPanel` and `sectionsContentMap`
23
+ * is used for easier access to active tab's content.
24
+ */
25
+
26
+ const {
27
+ tabs,
28
+ sectionsContentMap
29
+ } = useMemo(() => {
30
+ let mappedTabs = {
31
+ tabs: [],
32
+ sectionsContentMap: {}
33
+ };
34
+
35
+ if (sections.length) {
36
+ mappedTabs = sections.reduce((accumulator, _ref2) => {
37
+ let {
38
+ name,
39
+ tabLabel: title,
40
+ content
41
+ } = _ref2;
42
+ accumulator.tabs.push({
43
+ name,
44
+ title
45
+ });
46
+ accumulator.sectionsContentMap[name] = content;
47
+ return accumulator;
48
+ }, {
49
+ tabs: [],
50
+ sectionsContentMap: {}
51
+ });
52
+ }
53
+
54
+ return mappedTabs;
55
+ }, [sections]);
56
+ const getCurrentTab = useCallback(tab => sectionsContentMap[tab.name] || null, [sectionsContentMap]);
57
+ let modalContent; // We render different components based on the viewport size.
58
+
59
+ if (isLargeViewport) {
60
+ modalContent = createElement(TabPanel, {
61
+ className: "interface-preferences__tabs",
62
+ tabs: tabs,
63
+ initialTabName: activeMenu !== PREFERENCES_MENU ? activeMenu : undefined,
64
+ onSelect: setActiveMenu,
65
+ orientation: "vertical"
66
+ }, getCurrentTab);
67
+ } else {
68
+ modalContent = createElement(NavigatorProvider, {
69
+ initialPath: "/",
70
+ className: "interface-preferences__provider"
71
+ }, createElement(NavigatorScreen, {
72
+ path: "/"
73
+ }, createElement(Card, {
74
+ isBorderless: true,
75
+ size: "small"
76
+ }, createElement(CardBody, null, createElement(ItemGroup, null, tabs.map(tab => {
77
+ return createElement(NavigatorButton, {
78
+ key: tab.name,
79
+ path: tab.name,
80
+ as: Item,
81
+ isAction: true
82
+ }, createElement(HStack, {
83
+ justify: "space-between"
84
+ }, createElement(FlexItem, null, createElement(Truncate, null, tab.title)), createElement(FlexItem, null, createElement(Icon, {
85
+ icon: isRTL() ? chevronLeft : chevronRight
86
+ }))));
87
+ }))))), sections.length && sections.map(section => {
88
+ return createElement(NavigatorScreen, {
89
+ key: `${section.name}-menu`,
90
+ path: section.name
91
+ }, createElement(Card, {
92
+ isBorderless: true,
93
+ size: "large"
94
+ }, createElement(CardHeader, {
95
+ isBorderless: false,
96
+ justify: "left",
97
+ size: "small",
98
+ gap: "6"
99
+ }, createElement(NavigatorBackButton, {
100
+ icon: isRTL() ? chevronRight : chevronLeft,
101
+ "aria-label": __('Navigate to the previous view')
102
+ }), createElement(Text, {
103
+ size: "16"
104
+ }, section.tabLabel)), createElement(CardBody, null, section.content)));
105
+ }));
106
+ }
107
+
108
+ return modalContent;
109
+ }
110
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/interface/src/components/preferences-modal-tabs/index.js"],"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","undefined","map","section"],"mappings":"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","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 }</CardBody>\n\t\t\t\t\t\t\t\t</Card>\n\t\t\t\t\t\t\t</NavigatorScreen>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t</NavigatorProvider>\n\t\t);\n\t}\n\n\treturn modalContent;\n}\n"]}