@wordpress/interface 4.0.1-next.5df0cd52b7.0 → 4.1.2

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 (57) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +66 -1
  3. package/build/components/index.js +16 -0
  4. package/build/components/index.js.map +1 -1
  5. package/build/components/interface-skeleton/index.js +7 -6
  6. package/build/components/interface-skeleton/index.js.map +1 -1
  7. package/build/components/more-menu-dropdown/index.js +52 -0
  8. package/build/components/more-menu-dropdown/index.js.map +1 -0
  9. package/build/components/more-menu-feature-toggle/index.js +63 -0
  10. package/build/components/more-menu-feature-toggle/index.js.map +1 -0
  11. package/build/index.js +2 -2
  12. package/build/index.js.map +1 -1
  13. package/build/store/actions.js +57 -0
  14. package/build/store/actions.js.map +1 -1
  15. package/build/store/index.js +4 -2
  16. package/build/store/index.js.map +1 -1
  17. package/build/store/reducer.js +64 -2
  18. package/build/store/reducer.js.map +1 -1
  19. package/build/store/selectors.js +20 -0
  20. package/build/store/selectors.js.map +1 -1
  21. package/build-module/components/index.js +2 -0
  22. package/build-module/components/index.js.map +1 -1
  23. package/build-module/components/interface-skeleton/index.js +7 -7
  24. package/build-module/components/interface-skeleton/index.js.map +1 -1
  25. package/build-module/components/more-menu-dropdown/index.js +39 -0
  26. package/build-module/components/more-menu-dropdown/index.js.map +1 -0
  27. package/build-module/components/more-menu-feature-toggle/index.js +50 -0
  28. package/build-module/components/more-menu-feature-toggle/index.js.map +1 -0
  29. package/build-module/index.js +1 -1
  30. package/build-module/index.js.map +1 -1
  31. package/build-module/store/actions.js +51 -0
  32. package/build-module/store/actions.js.map +1 -1
  33. package/build-module/store/index.js +4 -2
  34. package/build-module/store/index.js.map +1 -1
  35. package/build-module/store/reducer.js +61 -1
  36. package/build-module/store/reducer.js.map +1 -1
  37. package/build-module/store/selectors.js +18 -0
  38. package/build-module/store/selectors.js.map +1 -1
  39. package/build-style/style-rtl.css +47 -2
  40. package/build-style/style.css +47 -2
  41. package/package.json +12 -11
  42. package/src/components/complementary-area/style.scss +10 -2
  43. package/src/components/complementary-area-header/style.scss +8 -0
  44. package/src/components/index.js +2 -0
  45. package/src/components/interface-skeleton/index.js +5 -5
  46. package/src/components/more-menu-dropdown/README.md +78 -0
  47. package/src/components/more-menu-dropdown/index.js +46 -0
  48. package/src/components/more-menu-dropdown/style.scss +35 -0
  49. package/src/components/more-menu-feature-toggle/README.md +59 -0
  50. package/src/components/more-menu-feature-toggle/index.js +53 -0
  51. package/src/index.js +1 -1
  52. package/src/store/actions.js +48 -0
  53. package/src/store/index.js +4 -2
  54. package/src/store/reducer.js +55 -0
  55. package/src/store/selectors.js +20 -0
  56. package/src/store/test/selectors.js +107 -0
  57. package/src/style.scss +1 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.1.0 (2021-09-09)
6
+
7
+ ### New Feature
8
+
9
+ - Add support for editor 'feature' preferences. Adds an `isFeatureActive` selector, a `toggleFeature` action, a `MoreMenuDropdown` component, and a `MoreMenuFeatureToggle` component. ([#33774](https://github.com/WordPress/gutenberg/pull/33774)).
10
+
5
11
  ## 4.0.0 (2021-07-29)
6
12
 
7
13
  ### Breaking Change
package/README.md CHANGED
@@ -10,7 +10,7 @@ Install the module
10
10
  npm install @wordpress/interface --save
11
11
  ```
12
12
 
13
- _This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for ES2015+ such as IE browsers then using [core-js](https://github.com/zloirock/core-js) will add polyfills for these methods._
13
+ _This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for such language features and APIs, you should include [the polyfill shipped in `@wordpress/babel-preset-default`](https://github.com/WordPress/gutenberg/tree/HEAD/packages/babel-preset-default#polyfill) in your code._
14
14
 
15
15
  ## API Usage
16
16
 
@@ -70,3 +70,68 @@ wp.data.select( 'core/interface' ).isItemPinned( 'core/edit-post', 'edit-post-bl
70
70
  ```
71
71
 
72
72
  <br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
73
+
74
+ ### Preferences
75
+
76
+ The interface package provides some helpers for implementing editor preferences.
77
+
78
+ #### Features
79
+
80
+ Features are boolean values used for toggling specific editor features on or off.
81
+
82
+ Set the default values for any features on editor initialization:
83
+
84
+ ```js
85
+ import { dispatch } from '@wordpress/data';
86
+ import { store as interfaceStore } from '@wordpress/interface';
87
+
88
+ function initialize() {
89
+ // ...
90
+
91
+ dispatch( interfaceStore ).setFeatureDefaults(
92
+ 'namespace/editor-or-plugin-name',
93
+ {
94
+ myFeatureName: true,
95
+ }
96
+ );
97
+
98
+ // ...
99
+ }
100
+ ```
101
+
102
+ Use the `toggleFeature` action and the `isFeatureActive` selector to toggle features within your app:
103
+
104
+ ```js
105
+ wp.data
106
+ .select( 'core/interface' )
107
+ .isFeatureActive( 'namespace/editor-or-plugin-name', 'myFeatureName' ); // true
108
+ wp.data
109
+ .dispatch( 'core/interface' )
110
+ .toggleFeature( 'namespace/editor-or-plugin-name', 'myFeatureName' );
111
+ wp.data
112
+ .select( 'core/interface' )
113
+ .isFeatureActive( 'namespace/editor-or-plugin-name', 'myFeatureName' ); // false
114
+ ```
115
+
116
+ The `MoreMenuDropdown` and `MoreMenuFeatureToggle` components help to implement an editor menu for changing preferences and feature values.
117
+
118
+ ```jsx
119
+ function MyEditorMenu() {
120
+ return (
121
+ <MoreMenuDropdown>
122
+ { () => (
123
+ <MenuGroup label={ __( 'Features' ) }>
124
+ <MoreMenuFeatureToggle
125
+ scope="namespace/editor-or-plugin-name"
126
+ feature="myFeatureName"
127
+ label={ __( 'My feature' ) }
128
+ info={ __( 'A really awesome feature' ) }
129
+ messageActivated={ __( 'My feature activated' ) }
130
+ messageDeactivated={ __( 'My feature deactivated' ) }
131
+ />
132
+ </MenuGroup>
133
+ ) }
134
+ </MoreMenuDropdown>
135
+ );
136
+ }
137
+ ```
@@ -35,6 +35,18 @@ Object.defineProperty(exports, "PinnedItems", {
35
35
  return _pinnedItems.default;
36
36
  }
37
37
  });
38
+ Object.defineProperty(exports, "MoreMenuDropdown", {
39
+ enumerable: true,
40
+ get: function () {
41
+ return _moreMenuDropdown.default;
42
+ }
43
+ });
44
+ Object.defineProperty(exports, "MoreMenuFeatureToggle", {
45
+ enumerable: true,
46
+ get: function () {
47
+ return _moreMenuFeatureToggle.default;
48
+ }
49
+ });
38
50
  Object.defineProperty(exports, "ActionItem", {
39
51
  enumerable: true,
40
52
  get: function () {
@@ -52,5 +64,9 @@ var _interfaceSkeleton = _interopRequireDefault(require("./interface-skeleton"))
52
64
 
53
65
  var _pinnedItems = _interopRequireDefault(require("./pinned-items"));
54
66
 
67
+ var _moreMenuDropdown = _interopRequireDefault(require("./more-menu-dropdown"));
68
+
69
+ var _moreMenuFeatureToggle = _interopRequireDefault(require("./more-menu-feature-toggle"));
70
+
55
71
  var _actionItem = _interopRequireDefault(require("./action-item"));
56
72
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/interface/src/components/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;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 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","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"]}
@@ -9,6 +9,8 @@ exports.default = void 0;
9
9
 
10
10
  var _element = require("@wordpress/element");
11
11
 
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
12
14
  var _classnames = _interopRequireDefault(require("classnames"));
13
15
 
14
16
  var _components = require("@wordpress/components");
@@ -56,8 +58,7 @@ function InterfaceSkeleton({
56
58
  className,
57
59
  shortcuts
58
60
  }, ref) {
59
- const fallbackRef = (0, _element.useRef)();
60
- const regionsClassName = (0, _components.__unstableUseNavigateRegions)(fallbackRef, shortcuts);
61
+ const navigateRegionsProps = (0, _components.__unstableUseNavigateRegions)(shortcuts);
61
62
  useHTMLClass('interface-interface-skeleton__html-container');
62
63
  const defaultLabels = {
63
64
  /* translators: accessibility text for the nav bar landmark region. */
@@ -84,10 +85,10 @@ function InterfaceSkeleton({
84
85
  const mergedLabels = { ...defaultLabels,
85
86
  ...labels
86
87
  };
87
- return (0, _element.createElement)("div", {
88
- ref: (0, _compose.useMergeRefs)([ref, fallbackRef]),
89
- className: (0, _classnames.default)(className, 'interface-interface-skeleton', regionsClassName, !!footer && 'has-footer')
90
- }, !!drawer && (0, _element.createElement)("div", {
88
+ return (0, _element.createElement)("div", (0, _extends2.default)({}, navigateRegionsProps, {
89
+ ref: (0, _compose.useMergeRefs)([ref, navigateRegionsProps.ref]),
90
+ className: (0, _classnames.default)(className, 'interface-interface-skeleton', navigateRegionsProps.className, !!footer && 'has-footer')
91
+ }), !!drawer && (0, _element.createElement)("div", {
91
92
  className: "interface-interface-skeleton__drawer",
92
93
  role: "region",
93
94
  "aria-label": mergedLabels.drawer
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/interface/src/components/interface-skeleton/index.js"],"names":["useHTMLClass","className","element","document","querySelector","classList","toggle","InterfaceSkeleton","footer","header","sidebar","secondarySidebar","notices","content","drawer","actions","labels","shortcuts","ref","fallbackRef","regionsClassName","defaultLabels","body","mergedLabels"],"mappings":";;;;;;;;;AAWA;;AARA;;AASA;;AACA;;AACA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AACA;AACA;AACA;AAMA,SAASA,YAAT,CAAuBC,SAAvB,EAAmC;AAClC,0BAAW,MAAM;AAChB,UAAMC,OAAO,GACZC,QAAQ,IAAIA,QAAQ,CAACC,aAAT,CAAyB,aAAaH,SAAW,GAAjD,CADb;;AAEA,QAAK,CAAEC,OAAP,EAAiB;AAChB;AACA;;AACDA,IAAAA,OAAO,CAACG,SAAR,CAAkBC,MAAlB,CAA0BL,SAA1B;AACA,WAAO,MAAM;AACZC,MAAAA,OAAO,CAACG,SAAR,CAAkBC,MAAlB,CAA0BL,SAA1B;AACA,KAFD;AAGA,GAVD,EAUG,CAAEA,SAAF,CAVH;AAWA;;AAED,SAASM,iBAAT,CACC;AACCC,EAAAA,MADD;AAECC,EAAAA,MAFD;AAGCC,EAAAA,OAHD;AAICC,EAAAA,gBAJD;AAKCC,EAAAA,OALD;AAMCC,EAAAA,OAND;AAOCC,EAAAA,MAPD;AAQCC,EAAAA,OARD;AASCC,EAAAA,MATD;AAUCf,EAAAA,SAVD;AAWCgB,EAAAA;AAXD,CADD,EAcCC,GAdD,EAeE;AACD,QAAMC,WAAW,GAAG,sBAApB;AACA,QAAMC,gBAAgB,GAAG,8CAAoBD,WAApB,EAAiCF,SAAjC,CAAzB;AAEAjB,EAAAA,YAAY,CAAE,8CAAF,CAAZ;AAEA,QAAMqB,aAAa,GAAG;AACrB;AACAP,IAAAA,MAAM,EAAE,cAAI,QAAJ,CAFa;;AAGrB;AACAL,IAAAA,MAAM,EAAE,cAAI,QAAJ,CAJa;;AAKrB;AACAa,IAAAA,IAAI,EAAE,cAAI,S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AAA,QAAQ,EAAC;AAJV,KAMGT,OANH,CAhBD,EAwBG,CAAC,CAAEH,OAAH,IACD;AACC,IAAA,SAAS,EAAC,uCADX;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,kBAAaa,YAAY,CAACb,OAH3B;AAIC,IAAA,QAAQ,EAAC;AAJV,KAMGA,OANH,CAzBF,EAkCG,CAAC,CAAEK,OAAH,IACD;AACC,IAAA,SAAS,EAAC,uCADX;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,kBAAaQ,YAAY,CAACR,OAH3B;AAIC,IAAA,QAAQ,EAAC;AAJV,KAMGA,OANH,CAnCF,CAXD,CAlBD,EA2EG,CAAC,CAAEP,MAAH,IACD;AACC,IAAA,SAAS,EAAC,sCADX;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,kBAAae,YAAY,CAACf,MAH3B;AAIC,IAAA,QAAQ,EAAC;AAJV,KAMGA,MANH,CA5EF,CADD;AAwFA;;eAEc,yBAAYD,iBAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useEffect, useRef } from '@wordpress/element';\nimport { __unstableUseNavigateRegions as useNavigateRegions } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs } from '@wordpress/compose';\n\nfunction useHTMLClass( className ) {\n\tuseEffect( () => {\n\t\tconst element =\n\t\t\tdocument && document.querySelector( `html:not(.${ className })` );\n\t\tif ( ! element ) {\n\t\t\treturn;\n\t\t}\n\t\telement.classList.toggle( className );\n\t\treturn () => {\n\t\t\telement.classList.toggle( className );\n\t\t};\n\t}, [ className ] );\n}\n\nfunction InterfaceSkeleton(\n\t{\n\t\tfooter,\n\t\theader,\n\t\tsidebar,\n\t\tsecondarySidebar,\n\t\tnotices,\n\t\tcontent,\n\t\tdrawer,\n\t\tactions,\n\t\tlabels,\n\t\tclassName,\n\t\tshortcuts,\n\t},\n\tref\n) {\n\tconst fallbackRef = useRef();\n\tconst regionsClassName = useNavigateRegions( fallbackRef, shortcuts );\n\n\tuseHTMLClass( 'interface-interface-skeleton__html-container' );\n\n\tconst defaultLabels = {\n\t\t/* translators: accessibility text for the nav bar landmark region. */\n\t\tdrawer: __( 'Drawer' ),\n\t\t/* translators: accessibility text for the top bar landmark region. */\n\t\theader: __( 'Header' ),\n\t\t/* translators: accessibility text for the content landmark region. */\n\t\tbody: __( 'Content' ),\n\t\t/* translators: accessibility text for the secondary sidebar landmark region. */\n\t\tsecondarySidebar: __( 'Block Library' ),\n\t\t/* translators: accessibility text for the settings landmark region. */\n\t\tsidebar: __( 'Settings' ),\n\t\t/* translators: accessibility text for the publish landmark region. */\n\t\tactions: __( 'Publish' ),\n\t\t/* translators: accessibility text for the footer landmark region. */\n\t\tfooter: __( 'Footer' ),\n\t};\n\n\tconst mergedLabels = { ...defaultLabels, ...labels };\n\n\treturn (\n\t\t<div\n\t\t\tref={ useMergeRefs( [ ref, fallbackRef ] ) }\n\t\t\tclassName={ classnames(\n\t\t\t\tclassName,\n\t\t\t\t'interface-interface-skeleton',\n\t\t\t\tregionsClassName,\n\t\t\t\t!! footer && 'has-footer'\n\t\t\t) }\n\t\t>\n\t\t\t{ !! drawer && (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"interface-interface-skeleton__drawer\"\n\t\t\t\t\trole=\"region\"\n\t\t\t\t\taria-label={ mergedLabels.drawer }\n\t\t\t\t>\n\t\t\t\t\t{ drawer }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<div className=\"interface-interface-skeleton__editor\">\n\t\t\t\t{ !! header && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"interface-interface-skeleton__header\"\n\t\t\t\t\t\trole=\"region\"\n\t\t\t\t\t\taria-label={ mergedLabels.header }\n\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ header }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t<div className=\"interface-interface-skeleton__body\">\n\t\t\t\t\t{ !! secondarySidebar && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"interface-interface-skeleton__secondary-sidebar\"\n\t\t\t\t\t\t\trole=\"region\"\n\t\t\t\t\t\t\taria-label={ mergedLabels.secondarySidebar }\n\t\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ secondarySidebar }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t\t{ !! notices && (\n\t\t\t\t\t\t<div className=\"interface-interface-skeleton__notices\">\n\t\t\t\t\t\t\t{ notices }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"interface-interface-skeleton__content\"\n\t\t\t\t\t\trole=\"region\"\n\t\t\t\t\t\taria-label={ mergedLabels.body }\n\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ content }\n\t\t\t\t\t</div>\n\t\t\t\t\t{ !! sidebar && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"interface-interface-skeleton__sidebar\"\n\t\t\t\t\t\t\trole=\"region\"\n\t\t\t\t\t\t\taria-label={ mergedLabels.sidebar }\n\t\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ sidebar }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t\t{ !! actions && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"interface-interface-skeleton__actions\"\n\t\t\t\t\t\t\trole=\"region\"\n\t\t\t\t\t\t\taria-label={ mergedLabels.actions }\n\t\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ actions }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t{ !! footer && (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"interface-interface-skeleton__footer\"\n\t\t\t\t\trole=\"region\"\n\t\t\t\t\taria-label={ mergedLabels.footer }\n\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t>\n\t\t\t\t\t{ footer }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default forwardRef( InterfaceSkeleton );\n"]}
1
+ {"version":3,"sources":["@wordpress/interface/src/components/interface-skeleton/index.js"],"names":["useHTMLClass","className","element","document","querySelector","classList","toggle","InterfaceSkeleton","footer","header","sidebar","secondarySidebar","notices","content","drawer","actions","labels","shortcuts","ref","navigateRegionsProps","defaultLabels","body","mergedLabels"],"mappings":";;;;;;;;;AAWA;;;;AARA;;AASA;;AACA;;AACA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AACA;AACA;AACA;AAMA,SAASA,YAAT,CAAuBC,SAAvB,EAAmC;AAClC,0BAAW,MAAM;AAChB,UAAMC,OAAO,GACZC,QAAQ,IAAIA,QAAQ,CAACC,aAAT,CAAyB,aAAaH,SAAW,GAAjD,CADb;;AAEA,QAAK,CAAEC,OAAP,EAAiB;AAChB;AACA;;AACDA,IAAAA,OAAO,CAACG,SAAR,CAAkBC,MAAlB,CAA0BL,SAA1B;AACA,WAAO,MAAM;AACZC,MAAAA,OAAO,CAACG,SAAR,CAAkBC,MAAlB,CAA0BL,SAA1B;AACA,KAFD;AAGA,GAVD,EAUG,CAAEA,SAAF,CAVH;AAWA;;AAED,SAASM,iBAAT,CACC;AACCC,EAAAA,MADD;AAECC,EAAAA,MAFD;AAGCC,EAAAA,OAHD;AAICC,EAAAA,gBAJD;AAKCC,EAAAA,OALD;AAMCC,EAAAA,OAND;AAOCC,EAAAA,MAPD;AAQCC,EAAAA,OARD;AASCC,EAAAA,MATD;AAUCf,EAAAA,SAVD;AAWCgB,EAAAA;AAXD,CADD,EAcCC,GAdD,EAeE;AACD,QAAMC,oBAAoB,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,IAAI,EAAC,QAFN;AAGC,kBAAaW,YAAY,CAACX,gBAH3B;AAIC,IAAA,QAAQ,EAAC;AAJV,KAMGA,gBANH,CAFF,EAWG,CAAC,CAAEC,OAAH,IACD;AAAK,IAAA,SAAS,EAAC;AAAf,KACGA,OADH,CAZF,EAgBC;AACC,IAAA,SAAS,EAAC,uCADX;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,kBAAaU,YAAY,CAACD,IAH3B;AAIC,IAAA,QAAQ,EAAC;AAJV,KAMGR,OANH,CAhBD,EAwBG,CAAC,CAAEH,OAAH,IACD;AACC,IAAA,SAAS,EAAC,uCADX;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,kBAAaY,YAAY,CAACZ,OAH3B;AAIC,IAAA,QAAQ,EAAC;AAJV,KAMGA,OANH,CAzBF,EAkCG,CAAC,CAAEK,OAAH,IACD;AACC,IAAA,SAAS,EAAC,uCADX;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,kBAAaO,YAAY,CAACP,OAH3B;AAIC,IAAA,QAAQ,EAAC;AAJV,KAMGA,OANH,CAnCF,CAXD,CAnBD,EA4EG,CAAC,CAAEP,MAAH,IACD;AACC,IAAA,SAAS,EAAC,sCADX;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,kBAAac,YAAY,CAACd,MAH3B;AAIC,IAAA,QAAQ,EAAC;AAJV,KAMGA,MANH,CA7EF,CADD;AAyFA;;eAEc,yBAAYD,iBAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useEffect } from '@wordpress/element';\nimport { __unstableUseNavigateRegions as useNavigateRegions } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs } from '@wordpress/compose';\n\nfunction useHTMLClass( className ) {\n\tuseEffect( () => {\n\t\tconst element =\n\t\t\tdocument && document.querySelector( `html:not(.${ className })` );\n\t\tif ( ! element ) {\n\t\t\treturn;\n\t\t}\n\t\telement.classList.toggle( className );\n\t\treturn () => {\n\t\t\telement.classList.toggle( className );\n\t\t};\n\t}, [ className ] );\n}\n\nfunction InterfaceSkeleton(\n\t{\n\t\tfooter,\n\t\theader,\n\t\tsidebar,\n\t\tsecondarySidebar,\n\t\tnotices,\n\t\tcontent,\n\t\tdrawer,\n\t\tactions,\n\t\tlabels,\n\t\tclassName,\n\t\tshortcuts,\n\t},\n\tref\n) {\n\tconst navigateRegionsProps = useNavigateRegions( shortcuts );\n\n\tuseHTMLClass( 'interface-interface-skeleton__html-container' );\n\n\tconst defaultLabels = {\n\t\t/* translators: accessibility text for the nav bar landmark region. */\n\t\tdrawer: __( 'Drawer' ),\n\t\t/* translators: accessibility text for the top bar landmark region. */\n\t\theader: __( 'Header' ),\n\t\t/* translators: accessibility text for the content landmark region. */\n\t\tbody: __( 'Content' ),\n\t\t/* translators: accessibility text for the secondary sidebar landmark region. */\n\t\tsecondarySidebar: __( 'Block Library' ),\n\t\t/* translators: accessibility text for the settings landmark region. */\n\t\tsidebar: __( 'Settings' ),\n\t\t/* translators: accessibility text for the publish landmark region. */\n\t\tactions: __( 'Publish' ),\n\t\t/* translators: accessibility text for the footer landmark region. */\n\t\tfooter: __( 'Footer' ),\n\t};\n\n\tconst mergedLabels = { ...defaultLabels, ...labels };\n\n\treturn (\n\t\t<div\n\t\t\t{ ...navigateRegionsProps }\n\t\t\tref={ useMergeRefs( [ ref, navigateRegionsProps.ref ] ) }\n\t\t\tclassName={ classnames(\n\t\t\t\tclassName,\n\t\t\t\t'interface-interface-skeleton',\n\t\t\t\tnavigateRegionsProps.className,\n\t\t\t\t!! footer && 'has-footer'\n\t\t\t) }\n\t\t>\n\t\t\t{ !! drawer && (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"interface-interface-skeleton__drawer\"\n\t\t\t\t\trole=\"region\"\n\t\t\t\t\taria-label={ mergedLabels.drawer }\n\t\t\t\t>\n\t\t\t\t\t{ drawer }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<div className=\"interface-interface-skeleton__editor\">\n\t\t\t\t{ !! header && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"interface-interface-skeleton__header\"\n\t\t\t\t\t\trole=\"region\"\n\t\t\t\t\t\taria-label={ mergedLabels.header }\n\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ header }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t<div className=\"interface-interface-skeleton__body\">\n\t\t\t\t\t{ !! secondarySidebar && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"interface-interface-skeleton__secondary-sidebar\"\n\t\t\t\t\t\t\trole=\"region\"\n\t\t\t\t\t\t\taria-label={ mergedLabels.secondarySidebar }\n\t\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ secondarySidebar }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t\t{ !! notices && (\n\t\t\t\t\t\t<div className=\"interface-interface-skeleton__notices\">\n\t\t\t\t\t\t\t{ notices }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"interface-interface-skeleton__content\"\n\t\t\t\t\t\trole=\"region\"\n\t\t\t\t\t\taria-label={ mergedLabels.body }\n\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ content }\n\t\t\t\t\t</div>\n\t\t\t\t\t{ !! sidebar && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"interface-interface-skeleton__sidebar\"\n\t\t\t\t\t\t\trole=\"region\"\n\t\t\t\t\t\t\taria-label={ mergedLabels.sidebar }\n\t\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ sidebar }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t\t{ !! actions && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"interface-interface-skeleton__actions\"\n\t\t\t\t\t\t\trole=\"region\"\n\t\t\t\t\t\t\taria-label={ mergedLabels.actions }\n\t\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ actions }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t{ !! footer && (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"interface-interface-skeleton__footer\"\n\t\t\t\t\trole=\"region\"\n\t\t\t\t\taria-label={ mergedLabels.footer }\n\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t>\n\t\t\t\t\t{ footer }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default forwardRef( InterfaceSkeleton );\n"]}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = MoreMenuDropdown;
9
+
10
+ var _element = require("@wordpress/element");
11
+
12
+ var _classnames = _interopRequireDefault(require("classnames"));
13
+
14
+ var _components = require("@wordpress/components");
15
+
16
+ var _i18n = require("@wordpress/i18n");
17
+
18
+ var _icons = require("@wordpress/icons");
19
+
20
+ /**
21
+ * External dependencies
22
+ */
23
+
24
+ /**
25
+ * WordPress dependencies
26
+ */
27
+ function MoreMenuDropdown({
28
+ as: DropdownComponent = _components.DropdownMenu,
29
+ className,
30
+
31
+ /* translators: button label text should, if possible, be under 16 characters. */
32
+ label = (0, _i18n.__)('Options'),
33
+ popoverProps,
34
+ toggleProps,
35
+ children
36
+ }) {
37
+ return (0, _element.createElement)(DropdownComponent, {
38
+ className: (0, _classnames.default)('interface-more-menu-dropdown', className),
39
+ icon: _icons.moreVertical,
40
+ label: label,
41
+ popoverProps: {
42
+ position: 'bottom left',
43
+ ...popoverProps,
44
+ className: (0, _classnames.default)('interface-more-menu-dropdown__content', popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.className)
45
+ },
46
+ toggleProps: {
47
+ tooltipPosition: 'bottom',
48
+ ...toggleProps
49
+ }
50
+ }, onClose => children(onClose));
51
+ }
52
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/interface/src/components/more-menu-dropdown/index.js"],"names":["MoreMenuDropdown","as","DropdownComponent","DropdownMenu","className","label","popoverProps","toggleProps","children","moreVertical","position","tooltipPosition","onClose"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAKe,SAASA,gBAAT,CAA2B;AACzCC,EAAAA,EAAE,EAAEC,iBAAiB,GAAGC,wBADiB;AAEzCC,EAAAA,SAFyC;;AAGzC;AACAC,EAAAA,KAAK,GAAG,cAAI,SAAJ,CAJiC;AAKzCC,EAAAA,YALyC;AAMzCC,EAAAA,WANyC;AAOzCC,EAAAA;AAPyC,CAA3B,EAQX;AACH,SACC,4BAAC,iBAAD;AACC,IAAA,SAAS,EAAG,yBACX,8BADW,EAEXJ,SAFW,CADb;AAKC,IAAA,IAAI,EAAGK,mBALR;AAMC,IAAA,KAAK,EAAGJ,KANT;AAOC,IAAA,YAAY,EAAG;AACdK,MAAAA,QAAQ,EAAE,aADI;AAEd,SAAGJ,YAFW;AAGdF,MAAAA,SAAS,EAAE,yBACV,uCADU,EAEVE,YAFU,aAEVA,YAFU,uBAEVA,YAAY,CAAEF,SAFJ;AAHG,KAPhB;AAeC,IAAA,WAAW,EAAG;AACbO,MAAAA,eAAe,EAAE,QADJ;AAEb,SAAGJ;AAFU;AAff,KAoBKK,OAAF,IAAeJ,QAAQ,CAAEI,OAAF,CApB1B,CADD;AAwBA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { DropdownMenu } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { moreVertical } from '@wordpress/icons';\n\nexport default function MoreMenuDropdown( {\n\tas: DropdownComponent = DropdownMenu,\n\tclassName,\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tlabel = __( 'Options' ),\n\tpopoverProps,\n\ttoggleProps,\n\tchildren,\n} ) {\n\treturn (\n\t\t<DropdownComponent\n\t\t\tclassName={ classnames(\n\t\t\t\t'interface-more-menu-dropdown',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ label }\n\t\t\tpopoverProps={ {\n\t\t\t\tposition: 'bottom left',\n\t\t\t\t...popoverProps,\n\t\t\t\tclassName: classnames(\n\t\t\t\t\t'interface-more-menu-dropdown__content',\n\t\t\t\t\tpopoverProps?.className\n\t\t\t\t),\n\t\t\t} }\n\t\t\ttoggleProps={ {\n\t\t\t\ttooltipPosition: 'bottom',\n\t\t\t\t...toggleProps,\n\t\t\t} }\n\t\t>\n\t\t\t{ ( onClose ) => children( onClose ) }\n\t\t</DropdownComponent>\n\t);\n}\n"]}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = MoreMenuFeatureToggle;
7
+
8
+ var _element = require("@wordpress/element");
9
+
10
+ var _data = require("@wordpress/data");
11
+
12
+ var _components = require("@wordpress/components");
13
+
14
+ var _i18n = require("@wordpress/i18n");
15
+
16
+ var _icons = require("@wordpress/icons");
17
+
18
+ var _a11y = require("@wordpress/a11y");
19
+
20
+ var _store = require("../../store");
21
+
22
+ /**
23
+ * WordPress dependencies
24
+ */
25
+
26
+ /**
27
+ * Internal dependencies
28
+ */
29
+ function MoreMenuFeatureToggle({
30
+ scope,
31
+ label,
32
+ info,
33
+ messageActivated,
34
+ messageDeactivated,
35
+ shortcut,
36
+ feature
37
+ }) {
38
+ const isActive = (0, _data.useSelect)(select => select(_store.store).isFeatureActive(scope, feature), [feature]);
39
+ const {
40
+ toggleFeature
41
+ } = (0, _data.useDispatch)(_store.store);
42
+
43
+ const speakMessage = () => {
44
+ if (isActive) {
45
+ (0, _a11y.speak)(messageDeactivated || (0, _i18n.__)('Feature deactivated'));
46
+ } else {
47
+ (0, _a11y.speak)(messageActivated || (0, _i18n.__)('Feature activated'));
48
+ }
49
+ };
50
+
51
+ return (0, _element.createElement)(_components.MenuItem, {
52
+ icon: isActive && _icons.check,
53
+ isSelected: isActive,
54
+ onClick: () => {
55
+ toggleFeature(scope, feature);
56
+ speakMessage();
57
+ },
58
+ role: "menuitemcheckbox",
59
+ info: info,
60
+ shortcut: shortcut
61
+ }, label);
62
+ }
63
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/interface/src/components/more-menu-feature-toggle/index.js"],"names":["MoreMenuFeatureToggle","scope","label","info","messageActivated","messageDeactivated","shortcut","feature","isActive","select","interfaceStore","isFeatureActive","toggleFeature","speakMessage","check"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGe,SAASA,qBAAT,CAAgC;AAC9CC,EAAAA,KAD8C;AAE9CC,EAAAA,KAF8C;AAG9CC,EAAAA,IAH8C;AAI9CC,EAAAA,gBAJ8C;AAK9CC,EAAAA,kBAL8C;AAM9CC,EAAAA,QAN8C;AAO9CC,EAAAA;AAP8C,CAAhC,EAQX;AACH,QAAMC,QAAQ,GAAG,qBACdC,MAAF,IACCA,MAAM,CAAEC,YAAF,CAAN,CAAyBC,eAAzB,CAA0CV,KAA1C,EAAiDM,OAAjD,CAFe,EAGhB,CAAEA,OAAF,CAHgB,CAAjB;AAKA,QAAM;AAAEK,IAAAA;AAAF,MAAoB,uBAAaF,YAAb,CAA1B;;AACA,QAAMG,YAAY,GAAG,MAAM;AAC1B,QAAKL,QAAL,EAAgB;AACf,uBAAOH,kBAAkB,IAAI,cAAI,qBAAJ,CAA7B;AACA,KAFD,MAEO;AACN,uBAAOD,gBAAgB,IAAI,cAAI,mBAAJ,CAA3B;AACA;AACD,GAND;;AAQA,SACC,4BAAC,oBAAD;AACC,IAAA,IAAI,EAAGI,QAAQ,IAAIM,YADpB;AAEC,IAAA,UAAU,EAAGN,QAFd;AAGC,IAAA,OAAO,EAAG,MAAM;AACfI,MAAAA,aAAa,CAAEX,KAAF,EAASM,OAAT,CAAb;AACAM,MAAAA,YAAY;AACZ,KANF;AAOC,IAAA,IAAI,EAAC,kBAPN;AAQC,IAAA,IAAI,EAAGV,IARR;AASC,IAAA,QAAQ,EAAGG;AATZ,KAWGJ,KAXH,CADD;AAeA","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 ]\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"]}
package/build/index.js CHANGED
@@ -13,8 +13,6 @@ Object.defineProperty(exports, "store", {
13
13
  }
14
14
  });
15
15
 
16
- var _store = require("./store");
17
-
18
16
  var _components = require("./components");
19
17
 
20
18
  Object.keys(_components).forEach(function (key) {
@@ -28,4 +26,6 @@ Object.keys(_components).forEach(function (key) {
28
26
  }
29
27
  });
30
28
  });
29
+
30
+ var _store = require("./store");
31
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/interface/src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export { store } from './store';\nexport * from './components';\n"]}
1
+ {"version":3,"sources":["@wordpress/interface/src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA","sourcesContent":["export * from './components';\nexport { store } from './store';\n"]}
@@ -7,6 +7,9 @@ exports.enableComplementaryArea = enableComplementaryArea;
7
7
  exports.disableComplementaryArea = disableComplementaryArea;
8
8
  exports.pinItem = pinItem;
9
9
  exports.unpinItem = unpinItem;
10
+ exports.toggleFeature = toggleFeature;
11
+ exports.setFeatureValue = setFeatureValue;
12
+ exports.setFeatureDefaults = setFeatureDefaults;
10
13
 
11
14
  /**
12
15
  * Returns an action object used in signalling that an active area should be changed.
@@ -97,4 +100,58 @@ function pinItem(scope, itemId) {
97
100
  function unpinItem(scope, itemId) {
98
101
  return setMultipleEnableItem('pinnedItems', scope, itemId, false);
99
102
  }
103
+ /**
104
+ * Returns an action object used in signalling that a feature should be toggled.
105
+ *
106
+ * @param {string} scope The feature scope (e.g. core/edit-post).
107
+ * @param {string} featureName The feature name.
108
+ */
109
+
110
+
111
+ function toggleFeature(scope, featureName) {
112
+ return function ({
113
+ select,
114
+ dispatch
115
+ }) {
116
+ const currentValue = select.isFeatureActive(scope, featureName);
117
+ dispatch.setFeatureValue(scope, featureName, !currentValue);
118
+ };
119
+ }
120
+ /**
121
+ * Returns an action object used in signalling that a feature should be set to
122
+ * a true or false value
123
+ *
124
+ * @param {string} scope The feature scope (e.g. core/edit-post).
125
+ * @param {string} featureName The feature name.
126
+ * @param {boolean} value The value to set.
127
+ *
128
+ * @return {Object} Action object.
129
+ */
130
+
131
+
132
+ function setFeatureValue(scope, featureName, value) {
133
+ return {
134
+ type: 'SET_FEATURE_VALUE',
135
+ scope,
136
+ featureName,
137
+ value: !!value
138
+ };
139
+ }
140
+ /**
141
+ * Returns an action object used in signalling that defaults should be set for features.
142
+ *
143
+ * @param {string} scope The feature scope (e.g. core/edit-post).
144
+ * @param {Object<string, boolean>} defaults A key/value map of feature names to values.
145
+ *
146
+ * @return {Object} Action object.
147
+ */
148
+
149
+
150
+ function setFeatureDefaults(scope, defaults) {
151
+ return {
152
+ type: 'SET_FEATURE_DEFAULTS',
153
+ scope,
154
+ defaults
155
+ };
156
+ }
100
157
  //# sourceMappingURL=actions.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/interface/src/store/actions.js"],"names":["setSingleEnableItem","itemType","scope","item","type","enableComplementaryArea","area","disableComplementaryArea","undefined","setMultipleEnableItem","isEnable","pinItem","itemId","unpinItem"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,mBAAT,CAA8BC,QAA9B,EAAwCC,KAAxC,EAA+CC,IAA/C,EAAsD;AACrD,SAAO;AACNC,IAAAA,IAAI,EAAE,wBADA;AAENH,IAAAA,QAFM;AAGNC,IAAAA,KAHM;AAINC,IAAAA;AAJM,GAAP;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,uBAAT,CAAkCH,KAAlC,EAAyCI,IAAzC,EAAgD;AACtD,SAAON,mBAAmB,CAAE,mBAAF,EAAuBE,KAAvB,EAA8BI,IAA9B,CAA1B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,wBAAT,CAAmCL,KAAnC,EAA2C;AACjD,SAAOF,mBAAmB,CAAE,mBAAF,EAAuBE,KAAvB,EAA8BM,SAA9B,CAA1B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,qBAAT,CAAgCR,QAAhC,EAA0CC,KAA1C,EAAiDC,IAAjD,EAAuDO,QAAvD,EAAkE;AACjE,SAAO;AACNN,IAAAA,IAAI,EAAE,0BADA;AAENH,IAAAA,QAFM;AAGNC,IAAAA,KAHM;AAINC,IAAAA,IAJM;AAKNO,IAAAA;AALM,GAAP;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,OAAT,CAAkBT,KAAlB,EAAyBU,MAAzB,EAAkC;AACxC,SAAOH,qBAAqB,CAAE,aAAF,EAAiBP,KAAjB,EAAwBU,MAAxB,EAAgC,IAAhC,CAA5B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,SAAT,CAAoBX,KAApB,EAA2BU,MAA3B,EAAoC;AAC1C,SAAOH,qBAAqB,CAAE,aAAF,EAAiBP,KAAjB,EAAwBU,MAAxB,EAAgC,KAAhC,CAA5B;AACA","sourcesContent":["/**\n * Returns an action object used in signalling that an active area should be changed.\n *\n * @param {string} itemType Type of item.\n * @param {string} scope Item scope.\n * @param {string} item Item identifier.\n *\n * @return {Object} Action object.\n */\nfunction setSingleEnableItem( itemType, scope, item ) {\n\treturn {\n\t\ttype: 'SET_SINGLE_ENABLE_ITEM',\n\t\titemType,\n\t\tscope,\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a complementary item should be enabled.\n *\n * @param {string} scope Complementary area scope.\n * @param {string} area Area identifier.\n *\n * @return {Object} Action object.\n */\nexport function enableComplementaryArea( scope, area ) {\n\treturn setSingleEnableItem( 'complementaryArea', scope, area );\n}\n\n/**\n * Returns an action object used in signalling that the complementary area of a given scope should be disabled.\n *\n * @param {string} scope Complementary area scope.\n *\n * @return {Object} Action object.\n */\nexport function disableComplementaryArea( scope ) {\n\treturn setSingleEnableItem( 'complementaryArea', scope, undefined );\n}\n\n/**\n * Returns an action object to make an area enabled/disabled.\n *\n * @param {string} itemType Type of item.\n * @param {string} scope Item scope.\n * @param {string} item Item identifier.\n * @param {boolean} isEnable Boolean indicating if an area should be pinned or not.\n *\n * @return {Object} Action object.\n */\nfunction setMultipleEnableItem( itemType, scope, item, isEnable ) {\n\treturn {\n\t\ttype: 'SET_MULTIPLE_ENABLE_ITEM',\n\t\titemType,\n\t\tscope,\n\t\titem,\n\t\tisEnable,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that an item should be pinned.\n *\n * @param {string} scope Item scope.\n * @param {string} itemId Item identifier.\n *\n * @return {Object} Action object.\n */\nexport function pinItem( scope, itemId ) {\n\treturn setMultipleEnableItem( 'pinnedItems', scope, itemId, true );\n}\n\n/**\n * Returns an action object used in signalling that an item should be unpinned.\n *\n * @param {string} scope Item scope.\n * @param {string} itemId Item identifier.\n *\n * @return {Object} Action object.\n */\nexport function unpinItem( scope, itemId ) {\n\treturn setMultipleEnableItem( 'pinnedItems', scope, itemId, false );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/interface/src/store/actions.js"],"names":["setSingleEnableItem","itemType","scope","item","type","enableComplementaryArea","area","disableComplementaryArea","undefined","setMultipleEnableItem","isEnable","pinItem","itemId","unpinItem","toggleFeature","featureName","select","dispatch","currentValue","isFeatureActive","setFeatureValue","value","setFeatureDefaults","defaults"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,mBAAT,CAA8BC,QAA9B,EAAwCC,KAAxC,EAA+CC,IAA/C,EAAsD;AACrD,SAAO;AACNC,I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;AACxC,UAAMC,YAAY,GAAGF,MAAM,CAACG,eAAP,CAAwBjB,KAAxB,EAA+Ba,WAA/B,CAArB;AACAE,IAAAA,QAAQ,CAACG,eAAT,CAA0BlB,KAA1B,EAAiCa,WAAjC,EAA8C,CAAEG,YAAhD;AACA,GAHD;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,eAAT,CAA0BlB,KAA1B,EAAiCa,WAAjC,EAA8CM,KAA9C,EAAsD;AAC5D,SAAO;AACNjB,IAAAA,IAAI,EAAE,mBADA;AAENF,IAAAA,KAFM;AAGNa,IAAAA,WAHM;AAINM,IAAAA,KAAK,EAAE,CAAC,CAAEA;AAJJ,GAAP;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,kBAAT,CAA6BpB,KAA7B,EAAoCqB,QAApC,EAA+C;AACrD,SAAO;AACNnB,IAAAA,IAAI,EAAE,sBADA;AAENF,IAAAA,KAFM;AAGNqB,IAAAA;AAHM,GAAP;AAKA","sourcesContent":["/**\n * Returns an action object used in signalling that an active area should be changed.\n *\n * @param {string} itemType Type of item.\n * @param {string} scope Item scope.\n * @param {string} item Item identifier.\n *\n * @return {Object} Action object.\n */\nfunction setSingleEnableItem( itemType, scope, item ) {\n\treturn {\n\t\ttype: 'SET_SINGLE_ENABLE_ITEM',\n\t\titemType,\n\t\tscope,\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a complementary item should be enabled.\n *\n * @param {string} scope Complementary area scope.\n * @param {string} area Area identifier.\n *\n * @return {Object} Action object.\n */\nexport function enableComplementaryArea( scope, area ) {\n\treturn setSingleEnableItem( 'complementaryArea', scope, area );\n}\n\n/**\n * Returns an action object used in signalling that the complementary area of a given scope should be disabled.\n *\n * @param {string} scope Complementary area scope.\n *\n * @return {Object} Action object.\n */\nexport function disableComplementaryArea( scope ) {\n\treturn setSingleEnableItem( 'complementaryArea', scope, undefined );\n}\n\n/**\n * Returns an action object to make an area enabled/disabled.\n *\n * @param {string} itemType Type of item.\n * @param {string} scope Item scope.\n * @param {string} item Item identifier.\n * @param {boolean} isEnable Boolean indicating if an area should be pinned or not.\n *\n * @return {Object} Action object.\n */\nfunction setMultipleEnableItem( itemType, scope, item, isEnable ) {\n\treturn {\n\t\ttype: 'SET_MULTIPLE_ENABLE_ITEM',\n\t\titemType,\n\t\tscope,\n\t\titem,\n\t\tisEnable,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that an item should be pinned.\n *\n * @param {string} scope Item scope.\n * @param {string} itemId Item identifier.\n *\n * @return {Object} Action object.\n */\nexport function pinItem( scope, itemId ) {\n\treturn setMultipleEnableItem( 'pinnedItems', scope, itemId, true );\n}\n\n/**\n * Returns an action object used in signalling that an item should be unpinned.\n *\n * @param {string} scope Item scope.\n * @param {string} itemId Item identifier.\n *\n * @return {Object} Action object.\n */\nexport function unpinItem( scope, itemId ) {\n\treturn setMultipleEnableItem( 'pinnedItems', scope, itemId, false );\n}\n\n/**\n * Returns an action object used in signalling that a feature should be toggled.\n *\n * @param {string} scope The feature scope (e.g. core/edit-post).\n * @param {string} featureName The feature name.\n */\nexport function toggleFeature( scope, featureName ) {\n\treturn function ( { select, dispatch } ) {\n\t\tconst currentValue = select.isFeatureActive( scope, featureName );\n\t\tdispatch.setFeatureValue( scope, featureName, ! currentValue );\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 {\n\t\ttype: 'SET_FEATURE_VALUE',\n\t\tscope,\n\t\tfeatureName,\n\t\tvalue: !! 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 {\n\t\ttype: 'SET_FEATURE_DEFAULTS',\n\t\tscope,\n\t\tdefaults,\n\t};\n}\n"]}
@@ -38,7 +38,8 @@ const store = (0, _data.createReduxStore)(_constants.STORE_NAME, {
38
38
  reducer: _reducer.default,
39
39
  actions,
40
40
  selectors,
41
- persist: ['enableItems']
41
+ persist: ['enableItems', 'preferences'],
42
+ __experimentalUseThunks: true
42
43
  }); // Once we build a more generic persistence plugin that works across types of stores
43
44
  // we'd be able to replace this with a register call.
44
45
 
@@ -47,6 +48,7 @@ exports.store = store;
47
48
  reducer: _reducer.default,
48
49
  actions,
49
50
  selectors,
50
- persist: ['enableItems']
51
+ persist: ['enableItems', 'preferences'],
52
+ __experimentalUseThunks: true
51
53
  });
52
54
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/interface/src/store/index.js"],"names":["store","STORE_NAME","reducer","actions","selectors","persist"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,KAAK,GAAG,4BAAkBC,qBAAlB,EAA8B;AAClDC,EAAAA,OAAO,EAAPA,gBADkD;AAElDC,EAAAA,OAFkD;AAGlDC,EAAAA,SAHkD;AAIlDC,EAAAA,OAAO,EAAE,CAAE,aAAF;AAJyC,CAA9B,CAAd,C,CAOP;AACA;;;AACA,yBAAeJ,qBAAf,EAA2B;AAC1BC,EAAAA,OAAO,EAAPA,gBAD0B;AAE1BC,EAAAA,OAF0B;AAG1BC,EAAAA,SAH0B;AAI1BC,EAAAA,OAAO,EAAE,CAAE,aAAF;AAJiB,CAA3B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, registerStore } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport { STORE_NAME } from './constants';\n\n/**\n * Store definition for the interface namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n\tpersist: [ 'enableItems' ],\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.\nregisterStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n\tpersist: [ 'enableItems' ],\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/interface/src/store/index.js"],"names":["store","STORE_NAME","reducer","actions","selectors","persist","__experimentalUseThunks"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,KAAK,GAAG,4BAAkBC,qBAAlB,EAA8B;AAClDC,EAAAA,OAAO,EAAPA,gBADkD;AAElDC,EAAAA,OAFkD;AAGlDC,EAAAA,SAHkD;AAIlDC,EAAAA,OAAO,EAAE,CAAE,aAAF,EAAiB,aAAjB,CAJyC;AAKlDC,EAAAA,uBAAuB,EAAE;AALyB,CAA9B,CAAd,C,CAQP;AACA;;;AACA,yBAAeL,qBAAf,EAA2B;AAC1BC,EAAAA,OAAO,EAAPA,gBAD0B;AAE1BC,EAAAA,OAF0B;AAG1BC,EAAAA,SAH0B;AAI1BC,EAAAA,OAAO,EAAE,CAAE,aAAF,EAAiB,aAAjB,CAJiB;AAK1BC,EAAAA,uBAAuB,EAAE;AALC,CAA3B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, registerStore } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport { STORE_NAME } from './constants';\n\n/**\n * Store definition for the interface namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n\tpersist: [ 'enableItems', 'preferences' ],\n\t__experimentalUseThunks: true,\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.\nregisterStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n\tpersist: [ 'enableItems', 'preferences' ],\n\t__experimentalUseThunks: true,\n} );\n"]}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.singleEnableItems = singleEnableItems;
7
7
  exports.multipleEnableItems = multipleEnableItems;
8
- exports.default = void 0;
8
+ exports.default = exports.preferences = exports.preferenceDefaults = void 0;
9
9
 
10
10
  var _lodash = require("lodash");
11
11
 
@@ -83,14 +83,76 @@ function multipleEnableItems(state = {}, {
83
83
  }
84
84
  };
85
85
  }
86
+ /**
87
+ * Reducer returning the defaults for user preferences.
88
+ *
89
+ * This is kept intentionally separate from the preferences
90
+ * themselves so that defaults are not persisted.
91
+ *
92
+ * @param {Object} state Current state.
93
+ * @param {Object} action Dispatched action.
94
+ *
95
+ * @return {Object} Updated state.
96
+ */
97
+
86
98
 
99
+ const preferenceDefaults = (0, _data.combineReducers)({
100
+ features(state = {}, action) {
101
+ if (action.type === 'SET_FEATURE_DEFAULTS') {
102
+ const {
103
+ scope,
104
+ defaults
105
+ } = action;
106
+ return { ...state,
107
+ [scope]: { ...state[scope],
108
+ ...defaults
109
+ }
110
+ };
111
+ }
112
+
113
+ return state;
114
+ }
115
+
116
+ });
117
+ /**
118
+ * Reducer returning the user preferences.
119
+ *
120
+ * @param {Object} state Current state.
121
+ * @param {Object} action Dispatched action.
122
+ *
123
+ * @return {Object} Updated state.
124
+ */
125
+
126
+ exports.preferenceDefaults = preferenceDefaults;
127
+ const preferences = (0, _data.combineReducers)({
128
+ features(state = {}, action) {
129
+ if (action.type === 'SET_FEATURE_VALUE') {
130
+ const {
131
+ scope,
132
+ featureName,
133
+ value
134
+ } = action;
135
+ return { ...state,
136
+ [scope]: { ...state[scope],
137
+ [featureName]: value
138
+ }
139
+ };
140
+ }
141
+
142
+ return state;
143
+ }
144
+
145
+ });
146
+ exports.preferences = preferences;
87
147
  const enableItems = (0, _data.combineReducers)({
88
148
  singleEnableItems,
89
149
  multipleEnableItems
90
150
  });
91
151
 
92
152
  var _default = (0, _data.combineReducers)({
93
- enableItems
153
+ enableItems,
154
+ preferenceDefaults,
155
+ preferences
94
156
  });
95
157
 
96
158
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/interface/src/store/reducer.js"],"names":["singleEnableItems","state","type","itemType","scope","item","multipleEnableItems","isEnable","currentTypeState","currentScopeState","enableItems"],"mappings":";;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,iBAAT,CACNC,KAAK,GAAG,EADF,EAEN;AAAEC,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA,KAAlB;AAAyBC,EAAAA;AAAzB,CAFM,EAGL;AACD,MAAKH,IAAI,KAAK,wBAAT,IAAqC,CAAEC,QAAvC,IAAmD,CAAEC,KAA1D,EAAkE;AACjE,WAAOH,KAAP;AACA;;AAED,SAAO,EACN,GAAGA,KADG;AAEN,KAAEE,QAAF,GAAc,EACb,GAAGF,KAAK,CAAEE,QAAF,CADK;AAEb,OAAEC,KAAF,GAAWC,IAAI,IAAI;AAFN;AAFR,GAAP;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,mBAAT,CACNL,KAAK,GAAG,EADF,EAEN;AAAEC,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA,KAAlB;AAAyBC,EAAAA,IAAzB;AAA+BE,EAAAA;AAA/B,CAFM,EAGL;AACD,MACCL,IAAI,KAAK,0BAAT,IACA,CAAEC,QADF,IAEA,CAAEC,KAFF,IAGA,CAAEC,IAHF,IAIA,iBAAKJ,KAAL,EAAY,CAAEE,QAAF,EAAYC,KAAZ,EAAmBC,IAAnB,CAAZ,MAA4CE,QAL7C,EAME;AACD,WAAON,KAAP;AACA;;AACD,QAAMO,gBAAgB,GAAGP,KAAK,CAAEE,QAAF,CAAL,IAAqB,EAA9C;AACA,QAAMM,iBAAiB,GAAGD,gBAAgB,CAAEJ,KAAF,CAAhB,IAA6B,EAAvD;AAEA,SAAO,EACN,GAAGH,KADG;AAEN,KAAEE,QAAF,GAAc,EACb,GAAGK,gBADU;AAEb,OAAEJ,KAAF,GAAW,EACV,GAAGK,iBADO;AAEV,SAAEJ,IAAF,GAAUE,QAAQ,IAAI;AAFZ;AAFE;AAFR,GAAP;AAUA;;AAED,MAAMG,WAAW,GAAG,2BAAiB;AACpCV,EAAAA,iBADoC;AAEpCM,EAAAA;AAFoC,CAAjB,CAApB;;eAKe,2BAAiB;AAC/BI,EAAAA;AAD+B,CAAjB,C","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer to keep tract of the active area per scope.\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action object.\n * @param {string} action.type Action type.\n * @param {string} action.itemType Type of item.\n * @param {string} action.scope Item scope.\n * @param {string} action.item Item name.\n *\n * @return {Object} Updated state.\n */\nexport function singleEnableItems(\n\tstate = {},\n\t{ type, itemType, scope, item }\n) {\n\tif ( type !== 'SET_SINGLE_ENABLE_ITEM' || ! itemType || ! scope ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t...state,\n\t\t[ itemType ]: {\n\t\t\t...state[ itemType ],\n\t\t\t[ scope ]: item || null,\n\t\t},\n\t};\n}\n\n/**\n * Reducer keeping track of the \"pinned\" items per scope.\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action object.\n * @param {string} action.type Action type.\n * @param {string} action.itemType Type of item.\n * @param {string} action.scope Item scope.\n * @param {string} action.item Item name.\n * @param {boolean} action.isEnable Whether the item is pinned.\n *\n * @return {Object} Updated state.\n */\nexport function multipleEnableItems(\n\tstate = {},\n\t{ type, itemType, scope, item, isEnable }\n) {\n\tif (\n\t\ttype !== 'SET_MULTIPLE_ENABLE_ITEM' ||\n\t\t! itemType ||\n\t\t! scope ||\n\t\t! item ||\n\t\tget( state, [ itemType, scope, item ] ) === isEnable\n\t) {\n\t\treturn state;\n\t}\n\tconst currentTypeState = state[ itemType ] || {};\n\tconst currentScopeState = currentTypeState[ scope ] || {};\n\n\treturn {\n\t\t...state,\n\t\t[ itemType ]: {\n\t\t\t...currentTypeState,\n\t\t\t[ scope ]: {\n\t\t\t\t...currentScopeState,\n\t\t\t\t[ item ]: isEnable || false,\n\t\t\t},\n\t\t},\n\t};\n}\n\nconst enableItems = combineReducers( {\n\tsingleEnableItems,\n\tmultipleEnableItems,\n} );\n\nexport default combineReducers( {\n\tenableItems,\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/interface/src/store/reducer.js"],"names":["singleEnableItems","state","type","itemType","scope","item","multipleEnableItems","isEnable","currentTypeState","currentScopeState","preferenceDefaults","features","action","defaults","preferences","featureName","value","enableItems"],"mappings":";;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,iBAAT,CACNC,KAAK,GAAG,EADF,EAEN;AAAEC,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA,KAAlB;AAAyBC,EAAAA;AAAzB,CAFM,EAGL;AACD,MAAKH,IAAI,KAAK,wBAAT,IAAqC,CAAEC,QAAvC,IAAmD,CAAEC,KAA1D,EAAkE;AACjE,WAAOH,KAAP;AACA;;AAED,SAAO,EACN,GAA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W,EACV,GAAGH,KAAK,CAAEG,KAAF,CADE;AAEV,aAAGS;AAFO;AAFL,OAAP;AAOA;;AAED,WAAOZ,KAAP;AACA;;AAdiD,CAAjB,CAA3B;AAiBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMa,WAAW,GAAG,2BAAiB;AAC3CH,EAAAA,QAAQ,CAAEV,KAAK,GAAG,EAAV,EAAcW,MAAd,EAAuB;AAC9B,QAAKA,MAAM,CAACV,IAAP,KAAgB,mBAArB,EAA2C;AAC1C,YAAM;AAAEE,QAAAA,KAAF;AAASW,QAAAA,WAAT;AAAsBC,QAAAA;AAAtB,UAAgCJ,MAAtC;AACA,aAAO,EACN,GAAGX,KADG;AAEN,SAAEG,KAAF,GAAW,EACV,GAAGH,KAAK,CAAEG,KAAF,CADE;AAEV,WAAEW,WAAF,GAAiBC;AAFP;AAFL,OAAP;AAOA;;AAED,WAAOf,KAAP;AACA;;AAd0C,CAAjB,CAApB;;AAiBP,MAAMgB,WAAW,GAAG,2BAAiB;AACpCjB,EAAAA,iBADoC;AAEpCM,EAAAA;AAFoC,CAAjB,CAApB;;eAKe,2BAAiB;AAC/BW,EAAAA,WAD+B;AAE/BP,EAAAA,kBAF+B;AAG/BI,EAAAA;AAH+B,CAAjB,C","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer to keep tract of the active area per scope.\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action object.\n * @param {string} action.type Action type.\n * @param {string} action.itemType Type of item.\n * @param {string} action.scope Item scope.\n * @param {string} action.item Item name.\n *\n * @return {Object} Updated state.\n */\nexport function singleEnableItems(\n\tstate = {},\n\t{ type, itemType, scope, item }\n) {\n\tif ( type !== 'SET_SINGLE_ENABLE_ITEM' || ! itemType || ! scope ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t...state,\n\t\t[ itemType ]: {\n\t\t\t...state[ itemType ],\n\t\t\t[ scope ]: item || null,\n\t\t},\n\t};\n}\n\n/**\n * Reducer keeping track of the \"pinned\" items per scope.\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action object.\n * @param {string} action.type Action type.\n * @param {string} action.itemType Type of item.\n * @param {string} action.scope Item scope.\n * @param {string} action.item Item name.\n * @param {boolean} action.isEnable Whether the item is pinned.\n *\n * @return {Object} Updated state.\n */\nexport function multipleEnableItems(\n\tstate = {},\n\t{ type, itemType, scope, item, isEnable }\n) {\n\tif (\n\t\ttype !== 'SET_MULTIPLE_ENABLE_ITEM' ||\n\t\t! itemType ||\n\t\t! scope ||\n\t\t! item ||\n\t\tget( state, [ itemType, scope, item ] ) === isEnable\n\t) {\n\t\treturn state;\n\t}\n\tconst currentTypeState = state[ itemType ] || {};\n\tconst currentScopeState = currentTypeState[ scope ] || {};\n\n\treturn {\n\t\t...state,\n\t\t[ itemType ]: {\n\t\t\t...currentTypeState,\n\t\t\t[ scope ]: {\n\t\t\t\t...currentScopeState,\n\t\t\t\t[ item ]: isEnable || false,\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Reducer returning the defaults for user preferences.\n *\n * This is kept intentionally separate from the preferences\n * themselves so that defaults are not persisted.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const preferenceDefaults = combineReducers( {\n\tfeatures( state = {}, action ) {\n\t\tif ( action.type === 'SET_FEATURE_DEFAULTS' ) {\n\t\t\tconst { scope, defaults } = action;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ scope ]: {\n\t\t\t\t\t...state[ scope ],\n\t\t\t\t\t...defaults,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treturn state;\n\t},\n} );\n\n/**\n * Reducer returning the user preferences.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const preferences = combineReducers( {\n\tfeatures( state = {}, action ) {\n\t\tif ( action.type === 'SET_FEATURE_VALUE' ) {\n\t\t\tconst { scope, featureName, value } = action;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ scope ]: {\n\t\t\t\t\t...state[ scope ],\n\t\t\t\t\t[ featureName ]: value,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treturn state;\n\t},\n} );\n\nconst enableItems = combineReducers( {\n\tsingleEnableItems,\n\tmultipleEnableItems,\n} );\n\nexport default combineReducers( {\n\tenableItems,\n\tpreferenceDefaults,\n\tpreferences,\n} );\n"]}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getActiveComplementaryArea = getActiveComplementaryArea;
7
7
  exports.isItemPinned = isItemPinned;
8
+ exports.isFeatureActive = isFeatureActive;
8
9
 
9
10
  var _lodash = require("lodash");
10
11
 
@@ -66,4 +67,23 @@ function isMultipleEnabledItemEnabled(state, itemType, scope, item) {
66
67
  function isItemPinned(state, scope, item) {
67
68
  return isMultipleEnabledItemEnabled(state, 'pinnedItems', scope, item) !== false;
68
69
  }
70
+ /**
71
+ * Returns a boolean indicating whether a feature is active for a particular
72
+ * scope.
73
+ *
74
+ * @param {Object} state The store state.
75
+ * @param {string} scope The scope of the feature (e.g. core/edit-post).
76
+ * @param {string} featureName The name of the feature.
77
+ *
78
+ * @return {boolean} Is the feature enabled?
79
+ */
80
+
81
+
82
+ function isFeatureActive(state, scope, featureName) {
83
+ var _state$preferences$fe, _state$preferenceDefa;
84
+
85
+ const featureValue = (_state$preferences$fe = state.preferences.features[scope]) === null || _state$preferences$fe === void 0 ? void 0 : _state$preferences$fe[featureName];
86
+ const defaultedFeatureValue = featureValue !== undefined ? featureValue : (_state$preferenceDefa = state.preferenceDefaults.features[scope]) === null || _state$preferenceDefa === void 0 ? void 0 : _state$preferenceDefa[featureName];
87
+ return !!defaultedFeatureValue;
88
+ }
69
89
  //# sourceMappingURL=selectors.js.map