@wordpress/customize-widgets 5.32.0 → 5.32.1-next.ff1cebbba.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 (164) hide show
  1. package/build/components/block-appender/index.js +33 -27
  2. package/build/components/block-appender/index.js.map +7 -1
  3. package/build/components/block-inspector-button/index.js +51 -36
  4. package/build/components/block-inspector-button/index.js.map +7 -1
  5. package/build/components/customize-widgets/index.js +83 -61
  6. package/build/components/customize-widgets/index.js.map +7 -1
  7. package/build/components/customize-widgets/use-clear-selected-block.js +56 -63
  8. package/build/components/customize-widgets/use-clear-selected-block.js.map +7 -1
  9. package/build/components/error-boundary/index.js +46 -45
  10. package/build/components/error-boundary/index.js.map +7 -1
  11. package/build/components/focus-control/index.js +69 -57
  12. package/build/components/focus-control/index.js.map +7 -1
  13. package/build/components/focus-control/use-blocks-focus-control.js +38 -31
  14. package/build/components/focus-control/use-blocks-focus-control.js.map +7 -1
  15. package/build/components/header/index.js +110 -71
  16. package/build/components/header/index.js.map +7 -1
  17. package/build/components/inserter/index.js +77 -53
  18. package/build/components/inserter/index.js.map +7 -1
  19. package/build/components/inserter/use-inserter.js +46 -29
  20. package/build/components/inserter/use-inserter.js.map +7 -1
  21. package/build/components/keyboard-shortcut-help-modal/config.js +74 -71
  22. package/build/components/keyboard-shortcut-help-modal/config.js.map +7 -1
  23. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +61 -44
  24. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +7 -1
  25. package/build/components/keyboard-shortcut-help-modal/index.js +155 -110
  26. package/build/components/keyboard-shortcut-help-modal/index.js.map +7 -1
  27. package/build/components/keyboard-shortcut-help-modal/shortcut.js +76 -56
  28. package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +7 -1
  29. package/build/components/keyboard-shortcuts/index.js +60 -51
  30. package/build/components/keyboard-shortcuts/index.js.map +7 -1
  31. package/build/components/more-menu/index.js +151 -90
  32. package/build/components/more-menu/index.js.map +7 -1
  33. package/build/components/sidebar-block-editor/index.js +133 -105
  34. package/build/components/sidebar-block-editor/index.js.map +7 -1
  35. package/build/components/sidebar-block-editor/sidebar-adapter.js +73 -67
  36. package/build/components/sidebar-block-editor/sidebar-adapter.js.map +7 -1
  37. package/build/components/sidebar-block-editor/sidebar-editor-provider.js +51 -33
  38. package/build/components/sidebar-block-editor/sidebar-editor-provider.js.map +7 -1
  39. package/build/components/sidebar-block-editor/use-sidebar-block-editor.js +100 -79
  40. package/build/components/sidebar-block-editor/use-sidebar-block-editor.js.map +7 -1
  41. package/build/components/sidebar-controls/index.js +45 -31
  42. package/build/components/sidebar-controls/index.js.map +7 -1
  43. package/build/components/welcome-guide/index.js +86 -58
  44. package/build/components/welcome-guide/index.js.map +7 -1
  45. package/build/controls/inserter-outer-section.js +49 -58
  46. package/build/controls/inserter-outer-section.js.map +7 -1
  47. package/build/controls/inspector-section.js +30 -36
  48. package/build/controls/inspector-section.js.map +7 -1
  49. package/build/controls/sidebar-control.js +51 -30
  50. package/build/controls/sidebar-control.js.map +7 -1
  51. package/build/controls/sidebar-section.js +71 -39
  52. package/build/controls/sidebar-section.js.map +7 -1
  53. package/build/filters/index.js +4 -6
  54. package/build/filters/index.js.map +7 -1
  55. package/build/filters/move-to-sidebar.js +77 -79
  56. package/build/filters/move-to-sidebar.js.map +7 -1
  57. package/build/filters/replace-media-upload.js +9 -11
  58. package/build/filters/replace-media-upload.js.map +7 -1
  59. package/build/filters/wide-widget-display.js +20 -25
  60. package/build/filters/wide-widget-display.js.map +7 -1
  61. package/build/index.js +81 -70
  62. package/build/index.js.map +7 -1
  63. package/build/lock-unlock.js +31 -15
  64. package/build/lock-unlock.js.map +7 -1
  65. package/build/store/actions.js +27 -44
  66. package/build/store/actions.js.map +7 -1
  67. package/build/store/constants.js +27 -10
  68. package/build/store/constants.js.map +7 -1
  69. package/build/store/index.js +44 -40
  70. package/build/store/index.js.map +7 -1
  71. package/build/store/reducer.js +25 -19
  72. package/build/store/reducer.js.map +7 -1
  73. package/build/store/selectors.js +31 -44
  74. package/build/store/selectors.js.map +7 -1
  75. package/build/utils.js +45 -73
  76. package/build/utils.js.map +7 -1
  77. package/build-module/components/block-appender/index.js +17 -20
  78. package/build-module/components/block-appender/index.js.map +7 -1
  79. package/build-module/components/block-inspector-button/index.js +33 -30
  80. package/build-module/components/block-inspector-button/index.js.map +7 -1
  81. package/build-module/components/customize-widgets/index.js +52 -51
  82. package/build-module/components/customize-widgets/index.js.map +7 -1
  83. package/build-module/components/customize-widgets/use-clear-selected-block.js +38 -58
  84. package/build-module/components/customize-widgets/use-clear-selected-block.js.map +7 -1
  85. package/build-module/components/error-boundary/index.js +27 -37
  86. package/build-module/components/error-boundary/index.js.map +7 -1
  87. package/build-module/components/focus-control/index.js +50 -45
  88. package/build-module/components/focus-control/index.js.map +7 -1
  89. package/build-module/components/focus-control/use-blocks-focus-control.js +17 -22
  90. package/build-module/components/focus-control/use-blocks-focus-control.js.map +7 -1
  91. package/build-module/components/header/index.js +81 -63
  92. package/build-module/components/header/index.js.map +7 -1
  93. package/build-module/components/inserter/index.js +59 -47
  94. package/build-module/components/inserter/index.js.map +7 -1
  95. package/build-module/components/inserter/use-inserter.js +28 -23
  96. package/build-module/components/inserter/use-inserter.js.map +7 -1
  97. package/build-module/components/keyboard-shortcut-help-modal/config.js +62 -75
  98. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +7 -1
  99. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +33 -37
  100. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +7 -1
  101. package/build-module/components/keyboard-shortcut-help-modal/index.js +130 -103
  102. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +7 -1
  103. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +58 -50
  104. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +7 -1
  105. package/build-module/components/keyboard-shortcuts/index.js +44 -44
  106. package/build-module/components/keyboard-shortcuts/index.js.map +7 -1
  107. package/build-module/components/more-menu/index.js +129 -84
  108. package/build-module/components/more-menu/index.js.map +7 -1
  109. package/build-module/components/sidebar-block-editor/index.js +109 -96
  110. package/build-module/components/sidebar-block-editor/index.js.map +7 -1
  111. package/build-module/components/sidebar-block-editor/sidebar-adapter.js +54 -59
  112. package/build-module/components/sidebar-block-editor/sidebar-adapter.js.map +7 -1
  113. package/build-module/components/sidebar-block-editor/sidebar-editor-provider.js +22 -25
  114. package/build-module/components/sidebar-block-editor/sidebar-editor-provider.js.map +7 -1
  115. package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js +70 -70
  116. package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js.map +7 -1
  117. package/build-module/components/sidebar-controls/index.js +24 -25
  118. package/build-module/components/sidebar-controls/index.js.map +7 -1
  119. package/build-module/components/welcome-guide/index.js +68 -52
  120. package/build-module/components/welcome-guide/index.js.map +7 -1
  121. package/build-module/controls/inserter-outer-section.js +31 -52
  122. package/build-module/controls/inserter-outer-section.js.map +7 -1
  123. package/build-module/controls/inspector-section.js +13 -32
  124. package/build-module/controls/inspector-section.js.map +7 -1
  125. package/build-module/controls/sidebar-control.js +22 -22
  126. package/build-module/controls/sidebar-control.js.map +7 -1
  127. package/build-module/controls/sidebar-section.js +43 -32
  128. package/build-module/controls/sidebar-section.js.map +7 -1
  129. package/build-module/filters/index.js +4 -7
  130. package/build-module/filters/index.js.map +7 -1
  131. package/build-module/filters/move-to-sidebar.js +83 -76
  132. package/build-module/filters/move-to-sidebar.js.map +7 -1
  133. package/build-module/filters/replace-media-upload.js +8 -7
  134. package/build-module/filters/replace-media-upload.js.map +7 -1
  135. package/build-module/filters/wide-widget-display.js +20 -22
  136. package/build-module/filters/wide-widget-display.js.map +7 -1
  137. package/build-module/index.js +53 -51
  138. package/build-module/index.js.map +7 -1
  139. package/build-module/lock-unlock.js +8 -7
  140. package/build-module/lock-unlock.js.map +7 -1
  141. package/build-module/store/actions.js +6 -40
  142. package/build-module/store/actions.js.map +7 -1
  143. package/build-module/store/constants.js +5 -5
  144. package/build-module/store/constants.js.map +7 -1
  145. package/build-module/store/index.js +10 -30
  146. package/build-module/store/index.js.map +7 -1
  147. package/build-module/store/reducer.js +7 -14
  148. package/build-module/store/reducer.js.map +7 -1
  149. package/build-module/store/selectors.js +10 -40
  150. package/build-module/store/selectors.js.map +7 -1
  151. package/build-module/utils.js +21 -66
  152. package/build-module/utils.js.map +7 -1
  153. package/build-style/style-rtl.css +14 -149
  154. package/build-style/style.css +14 -149
  155. package/package.json +30 -23
  156. package/src/components/block-inspector-button/style.scss +3 -0
  157. package/src/components/header/style.scss +5 -0
  158. package/src/components/inserter/style.scss +3 -0
  159. package/src/components/keyboard-shortcut-help-modal/style.scss +2 -0
  160. package/src/components/more-menu/style.scss +2 -0
  161. package/src/components/sidebar-block-editor/style.scss +2 -0
  162. package/src/components/welcome-guide/style.scss +2 -0
  163. package/src/controls/style.scss +2 -0
  164. package/src/style.scss +10 -8
@@ -1 +1,7 @@
1
- {"version":3,"names":["privateApis","blockEditorPrivateApis","useSidebarBlockEditor","useBlocksFocusControl","unlock","jsx","_jsx","ExperimentalBlockEditorProvider","SidebarEditorProvider","sidebar","settings","children","blocks","onInput","onChange","value","useSubRegistry"],"sources":["@wordpress/customize-widgets/src/components/sidebar-block-editor/sidebar-editor-provider.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport useSidebarBlockEditor from './use-sidebar-block-editor';\nimport useBlocksFocusControl from '../focus-control/use-blocks-focus-control';\n\nimport { unlock } from '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\n\nexport default function SidebarEditorProvider( {\n\tsidebar,\n\tsettings,\n\tchildren,\n} ) {\n\tconst [ blocks, onInput, onChange ] = useSidebarBlockEditor( sidebar );\n\n\tuseBlocksFocusControl( blocks );\n\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ blocks }\n\t\t\tonInput={ onInput }\n\t\t\tonChange={ onChange }\n\t\t\tsettings={ settings }\n\t\t\tuseSubRegistry={ false }\n\t\t>\n\t\t\t{ children }\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,sBAAsB,QAAQ,yBAAyB;;AAE/E;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,qBAAqB,MAAM,2CAA2C;AAE7E,SAASC,MAAM,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE3C,MAAM;EAAEC;AAAgC,CAAC,GAAGH,MAAM,CAAEH,sBAAuB,CAAC;AAE5E,eAAe,SAASO,qBAAqBA,CAAE;EAC9CC,OAAO;EACPC,QAAQ;EACRC;AACD,CAAC,EAAG;EACH,MAAM,CAAEC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,CAAE,GAAGZ,qBAAqB,CAAEO,OAAQ,CAAC;EAEtEN,qBAAqB,CAAES,MAAO,CAAC;EAE/B,oBACCN,IAAA,CAACC,+BAA+B;IAC/BQ,KAAK,EAAGH,MAAQ;IAChBC,OAAO,EAAGA,OAAS;IACnBC,QAAQ,EAAGA,QAAU;IACrBJ,QAAQ,EAAGA,QAAU;IACrBM,cAAc,EAAG,KAAO;IAAAL,QAAA,EAEtBA;EAAQ,CACsB,CAAC;AAEpC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/sidebar-block-editor/sidebar-editor-provider.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport useSidebarBlockEditor from './use-sidebar-block-editor';\nimport useBlocksFocusControl from '../focus-control/use-blocks-focus-control';\n\nimport { unlock } from '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\n\nexport default function SidebarEditorProvider( {\n\tsidebar,\n\tsettings,\n\tchildren,\n} ) {\n\tconst [ blocks, onInput, onChange ] = useSidebarBlockEditor( sidebar );\n\n\tuseBlocksFocusControl( blocks );\n\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ blocks }\n\t\t\tonInput={ onInput }\n\t\t\tonChange={ onChange }\n\t\t\tsettings={ settings }\n\t\t\tuseSubRegistry={ false }\n\t\t>\n\t\t\t{ children }\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n"],
5
+ "mappings": "AAyBE;AAtBF,SAAS,eAAe,8BAA8B;AAKtD,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAElC,SAAS,cAAc;AAEvB,MAAM,EAAE,gCAAgC,IAAI,OAAQ,sBAAuB;AAE5D,SAAR,sBAAwC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,CAAE,QAAQ,SAAS,QAAS,IAAI,sBAAuB,OAAQ;AAErE,wBAAuB,MAAO;AAE9B,SACC;AAAA,IAAC;AAAA;AAAA,MACA,OAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAiB;AAAA,MAEf;AAAA;AAAA,EACH;AAEF;",
6
+ "names": []
7
+ }
@@ -1,40 +1,34 @@
1
- /**
2
- * External dependencies
3
- */
4
- import fastDeepEqual from 'fast-deep-equal/es6';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { useState, useEffect, useCallback } from '@wordpress/element';
10
- import isShallowEqual from '@wordpress/is-shallow-equal';
11
- import { getWidgetIdFromBlock, addWidgetIdToBlock } from '@wordpress/widgets';
12
-
13
- /**
14
- * Internal dependencies
15
- */
16
- import { blockToWidget, widgetToBlock } from '../../utils';
1
+ import fastDeepEqual from "fast-deep-equal/es6";
2
+ import { useState, useEffect, useCallback } from "@wordpress/element";
3
+ import isShallowEqual from "@wordpress/is-shallow-equal";
4
+ import { getWidgetIdFromBlock, addWidgetIdToBlock } from "@wordpress/widgets";
5
+ import { blockToWidget, widgetToBlock } from "../../utils";
17
6
  function widgetsToBlocks(widgets) {
18
- return widgets.map(widget => widgetToBlock(widget));
7
+ return widgets.map((widget) => widgetToBlock(widget));
19
8
  }
20
- export default function useSidebarBlockEditor(sidebar) {
21
- const [blocks, setBlocks] = useState(() => widgetsToBlocks(sidebar.getWidgets()));
9
+ function useSidebarBlockEditor(sidebar) {
10
+ const [blocks, setBlocks] = useState(
11
+ () => widgetsToBlocks(sidebar.getWidgets())
12
+ );
22
13
  useEffect(() => {
23
14
  return sidebar.subscribe((prevWidgets, nextWidgets) => {
24
- setBlocks(prevBlocks => {
25
- const prevWidgetsMap = new Map(prevWidgets.map(widget => [widget.id, widget]));
26
- const prevBlocksMap = new Map(prevBlocks.map(block => [getWidgetIdFromBlock(block), block]));
27
- const nextBlocks = nextWidgets.map(nextWidget => {
15
+ setBlocks((prevBlocks) => {
16
+ const prevWidgetsMap = new Map(
17
+ prevWidgets.map((widget) => [widget.id, widget])
18
+ );
19
+ const prevBlocksMap = new Map(
20
+ prevBlocks.map((block) => [
21
+ getWidgetIdFromBlock(block),
22
+ block
23
+ ])
24
+ );
25
+ const nextBlocks = nextWidgets.map((nextWidget) => {
28
26
  const prevWidget = prevWidgetsMap.get(nextWidget.id);
29
-
30
- // Bail out updates.
31
27
  if (prevWidget && prevWidget === nextWidget) {
32
28
  return prevBlocksMap.get(nextWidget.id);
33
29
  }
34
30
  return widgetToBlock(nextWidget);
35
31
  });
36
-
37
- // Bail out updates.
38
32
  if (isShallowEqual(prevBlocks, nextBlocks)) {
39
33
  return prevBlocks;
40
34
  }
@@ -42,51 +36,57 @@ export default function useSidebarBlockEditor(sidebar) {
42
36
  });
43
37
  });
44
38
  }, [sidebar]);
45
- const onChangeBlocks = useCallback(nextBlocks => {
46
- setBlocks(prevBlocks => {
47
- if (isShallowEqual(prevBlocks, nextBlocks)) {
48
- return prevBlocks;
49
- }
50
- const prevBlocksMap = new Map(prevBlocks.map(block => [getWidgetIdFromBlock(block), block]));
51
- const nextWidgets = nextBlocks.map(nextBlock => {
52
- const widgetId = getWidgetIdFromBlock(nextBlock);
53
-
54
- // Update existing widgets.
55
- if (widgetId && prevBlocksMap.has(widgetId)) {
56
- const prevBlock = prevBlocksMap.get(widgetId);
57
- const prevWidget = sidebar.getWidget(widgetId);
58
-
59
- // Bail out updates by returning the previous widgets.
60
- // Deep equality is necessary until the block editor's internals changes.
61
- if (fastDeepEqual(nextBlock, prevBlock) && prevWidget) {
62
- return prevWidget;
63
- }
64
- return blockToWidget(nextBlock, prevWidget);
39
+ const onChangeBlocks = useCallback(
40
+ (nextBlocks) => {
41
+ setBlocks((prevBlocks) => {
42
+ if (isShallowEqual(prevBlocks, nextBlocks)) {
43
+ return prevBlocks;
65
44
  }
66
-
67
- // Add a new widget.
68
- return blockToWidget(nextBlock);
69
- });
70
-
71
- // Bail out updates if the updated widgets are the same.
72
- if (isShallowEqual(sidebar.getWidgets(), nextWidgets)) {
73
- return prevBlocks;
74
- }
75
- const addedWidgetIds = sidebar.setWidgets(nextWidgets);
76
- return nextBlocks.reduce((updatedNextBlocks, nextBlock, index) => {
77
- const addedWidgetId = addedWidgetIds[index];
78
- if (addedWidgetId !== null) {
79
- // Only create a new instance if necessary to prevent
80
- // the whole editor from re-rendering on every edit.
81
- if (updatedNextBlocks === nextBlocks) {
82
- updatedNextBlocks = nextBlocks.slice();
45
+ const prevBlocksMap = new Map(
46
+ prevBlocks.map((block) => [
47
+ getWidgetIdFromBlock(block),
48
+ block
49
+ ])
50
+ );
51
+ const nextWidgets = nextBlocks.map((nextBlock) => {
52
+ const widgetId = getWidgetIdFromBlock(nextBlock);
53
+ if (widgetId && prevBlocksMap.has(widgetId)) {
54
+ const prevBlock = prevBlocksMap.get(widgetId);
55
+ const prevWidget = sidebar.getWidget(widgetId);
56
+ if (fastDeepEqual(nextBlock, prevBlock) && prevWidget) {
57
+ return prevWidget;
58
+ }
59
+ return blockToWidget(nextBlock, prevWidget);
83
60
  }
84
- updatedNextBlocks[index] = addWidgetIdToBlock(nextBlock, addedWidgetId);
61
+ return blockToWidget(nextBlock);
62
+ });
63
+ if (isShallowEqual(sidebar.getWidgets(), nextWidgets)) {
64
+ return prevBlocks;
85
65
  }
86
- return updatedNextBlocks;
87
- }, nextBlocks);
88
- });
89
- }, [sidebar]);
66
+ const addedWidgetIds = sidebar.setWidgets(nextWidgets);
67
+ return nextBlocks.reduce(
68
+ (updatedNextBlocks, nextBlock, index) => {
69
+ const addedWidgetId = addedWidgetIds[index];
70
+ if (addedWidgetId !== null) {
71
+ if (updatedNextBlocks === nextBlocks) {
72
+ updatedNextBlocks = nextBlocks.slice();
73
+ }
74
+ updatedNextBlocks[index] = addWidgetIdToBlock(
75
+ nextBlock,
76
+ addedWidgetId
77
+ );
78
+ }
79
+ return updatedNextBlocks;
80
+ },
81
+ nextBlocks
82
+ );
83
+ });
84
+ },
85
+ [sidebar]
86
+ );
90
87
  return [blocks, onChangeBlocks, onChangeBlocks];
91
88
  }
92
- //# sourceMappingURL=use-sidebar-block-editor.js.map
89
+ export {
90
+ useSidebarBlockEditor as default
91
+ };
92
+ //# sourceMappingURL=use-sidebar-block-editor.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["fastDeepEqual","useState","useEffect","useCallback","isShallowEqual","getWidgetIdFromBlock","addWidgetIdToBlock","blockToWidget","widgetToBlock","widgetsToBlocks","widgets","map","widget","useSidebarBlockEditor","sidebar","blocks","setBlocks","getWidgets","subscribe","prevWidgets","nextWidgets","prevBlocks","prevWidgetsMap","Map","id","prevBlocksMap","block","nextBlocks","nextWidget","prevWidget","get","onChangeBlocks","nextBlock","widgetId","has","prevBlock","getWidget","addedWidgetIds","setWidgets","reduce","updatedNextBlocks","index","addedWidgetId","slice"],"sources":["@wordpress/customize-widgets/src/components/sidebar-block-editor/use-sidebar-block-editor.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { getWidgetIdFromBlock, addWidgetIdToBlock } from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport { blockToWidget, widgetToBlock } from '../../utils';\n\nfunction widgetsToBlocks( widgets ) {\n\treturn widgets.map( ( widget ) => widgetToBlock( widget ) );\n}\n\nexport default function useSidebarBlockEditor( sidebar ) {\n\tconst [ blocks, setBlocks ] = useState( () =>\n\t\twidgetsToBlocks( sidebar.getWidgets() )\n\t);\n\n\tuseEffect( () => {\n\t\treturn sidebar.subscribe( ( prevWidgets, nextWidgets ) => {\n\t\t\tsetBlocks( ( prevBlocks ) => {\n\t\t\t\tconst prevWidgetsMap = new Map(\n\t\t\t\t\tprevWidgets.map( ( widget ) => [ widget.id, widget ] )\n\t\t\t\t);\n\t\t\t\tconst prevBlocksMap = new Map(\n\t\t\t\t\tprevBlocks.map( ( block ) => [\n\t\t\t\t\t\tgetWidgetIdFromBlock( block ),\n\t\t\t\t\t\tblock,\n\t\t\t\t\t] )\n\t\t\t\t);\n\n\t\t\t\tconst nextBlocks = nextWidgets.map( ( nextWidget ) => {\n\t\t\t\t\tconst prevWidget = prevWidgetsMap.get( nextWidget.id );\n\n\t\t\t\t\t// Bail out updates.\n\t\t\t\t\tif ( prevWidget && prevWidget === nextWidget ) {\n\t\t\t\t\t\treturn prevBlocksMap.get( nextWidget.id );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn widgetToBlock( nextWidget );\n\t\t\t\t} );\n\n\t\t\t\t// Bail out updates.\n\t\t\t\tif ( isShallowEqual( prevBlocks, nextBlocks ) ) {\n\t\t\t\t\treturn prevBlocks;\n\t\t\t\t}\n\n\t\t\t\treturn nextBlocks;\n\t\t\t} );\n\t\t} );\n\t}, [ sidebar ] );\n\n\tconst onChangeBlocks = useCallback(\n\t\t( nextBlocks ) => {\n\t\t\tsetBlocks( ( prevBlocks ) => {\n\t\t\t\tif ( isShallowEqual( prevBlocks, nextBlocks ) ) {\n\t\t\t\t\treturn prevBlocks;\n\t\t\t\t}\n\n\t\t\t\tconst prevBlocksMap = new Map(\n\t\t\t\t\tprevBlocks.map( ( block ) => [\n\t\t\t\t\t\tgetWidgetIdFromBlock( block ),\n\t\t\t\t\t\tblock,\n\t\t\t\t\t] )\n\t\t\t\t);\n\n\t\t\t\tconst nextWidgets = nextBlocks.map( ( nextBlock ) => {\n\t\t\t\t\tconst widgetId = getWidgetIdFromBlock( nextBlock );\n\n\t\t\t\t\t// Update existing widgets.\n\t\t\t\t\tif ( widgetId && prevBlocksMap.has( widgetId ) ) {\n\t\t\t\t\t\tconst prevBlock = prevBlocksMap.get( widgetId );\n\t\t\t\t\t\tconst prevWidget = sidebar.getWidget( widgetId );\n\n\t\t\t\t\t\t// Bail out updates by returning the previous widgets.\n\t\t\t\t\t\t// Deep equality is necessary until the block editor's internals changes.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tfastDeepEqual( nextBlock, prevBlock ) &&\n\t\t\t\t\t\t\tprevWidget\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn prevWidget;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn blockToWidget( nextBlock, prevWidget );\n\t\t\t\t\t}\n\n\t\t\t\t\t// Add a new widget.\n\t\t\t\t\treturn blockToWidget( nextBlock );\n\t\t\t\t} );\n\n\t\t\t\t// Bail out updates if the updated widgets are the same.\n\t\t\t\tif ( isShallowEqual( sidebar.getWidgets(), nextWidgets ) ) {\n\t\t\t\t\treturn prevBlocks;\n\t\t\t\t}\n\n\t\t\t\tconst addedWidgetIds = sidebar.setWidgets( nextWidgets );\n\n\t\t\t\treturn nextBlocks.reduce(\n\t\t\t\t\t( updatedNextBlocks, nextBlock, index ) => {\n\t\t\t\t\t\tconst addedWidgetId = addedWidgetIds[ index ];\n\n\t\t\t\t\t\tif ( addedWidgetId !== null ) {\n\t\t\t\t\t\t\t// Only create a new instance if necessary to prevent\n\t\t\t\t\t\t\t// the whole editor from re-rendering on every edit.\n\t\t\t\t\t\t\tif ( updatedNextBlocks === nextBlocks ) {\n\t\t\t\t\t\t\t\tupdatedNextBlocks = nextBlocks.slice();\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tupdatedNextBlocks[ index ] = addWidgetIdToBlock(\n\t\t\t\t\t\t\t\tnextBlock,\n\t\t\t\t\t\t\t\taddedWidgetId\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn updatedNextBlocks;\n\t\t\t\t\t},\n\t\t\t\t\tnextBlocks\n\t\t\t\t);\n\t\t\t} );\n\t\t},\n\t\t[ sidebar ]\n\t);\n\n\treturn [ blocks, onChangeBlocks, onChangeBlocks ];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,qBAAqB;;AAE/C;AACA;AACA;AACA,SAASC,QAAQ,EAAEC,SAAS,EAAEC,WAAW,QAAQ,oBAAoB;AACrE,OAAOC,cAAc,MAAM,6BAA6B;AACxD,SAASC,oBAAoB,EAAEC,kBAAkB,QAAQ,oBAAoB;;AAE7E;AACA;AACA;AACA,SAASC,aAAa,EAAEC,aAAa,QAAQ,aAAa;AAE1D,SAASC,eAAeA,CAAEC,OAAO,EAAG;EACnC,OAAOA,OAAO,CAACC,GAAG,CAAIC,MAAM,IAAMJ,aAAa,CAAEI,MAAO,CAAE,CAAC;AAC5D;AAEA,eAAe,SAASC,qBAAqBA,CAAEC,OAAO,EAAG;EACxD,MAAM,CAAEC,MAAM,EAAEC,SAAS,CAAE,GAAGf,QAAQ,CAAE,MACvCQ,eAAe,CAAEK,OAAO,CAACG,UAAU,CAAC,CAAE,CACvC,CAAC;EAEDf,SAAS,CAAE,MAAM;IAChB,OAAOY,OAAO,CAACI,SAAS,CAAE,CAAEC,WAAW,EAAEC,WAAW,KAAM;MACzDJ,SAAS,CA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List":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/sidebar-block-editor/use-sidebar-block-editor.js"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { getWidgetIdFromBlock, addWidgetIdToBlock } from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport { blockToWidget, widgetToBlock } from '../../utils';\n\nfunction widgetsToBlocks( widgets ) {\n\treturn widgets.map( ( widget ) => widgetToBlock( widget ) );\n}\n\nexport default function useSidebarBlockEditor( sidebar ) {\n\tconst [ blocks, setBlocks ] = useState( () =>\n\t\twidgetsToBlocks( sidebar.getWidgets() )\n\t);\n\n\tuseEffect( () => {\n\t\treturn sidebar.subscribe( ( prevWidgets, nextWidgets ) => {\n\t\t\tsetBlocks( ( prevBlocks ) => {\n\t\t\t\tconst prevWidgetsMap = new Map(\n\t\t\t\t\tprevWidgets.map( ( widget ) => [ widget.id, widget ] )\n\t\t\t\t);\n\t\t\t\tconst prevBlocksMap = new Map(\n\t\t\t\t\tprevBlocks.map( ( block ) => [\n\t\t\t\t\t\tgetWidgetIdFromBlock( block ),\n\t\t\t\t\t\tblock,\n\t\t\t\t\t] )\n\t\t\t\t);\n\n\t\t\t\tconst nextBlocks = nextWidgets.map( ( nextWidget ) => {\n\t\t\t\t\tconst prevWidget = prevWidgetsMap.get( nextWidget.id );\n\n\t\t\t\t\t// Bail out updates.\n\t\t\t\t\tif ( prevWidget && prevWidget === nextWidget ) {\n\t\t\t\t\t\treturn prevBlocksMap.get( nextWidget.id );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn widgetToBlock( nextWidget );\n\t\t\t\t} );\n\n\t\t\t\t// Bail out updates.\n\t\t\t\tif ( isShallowEqual( prevBlocks, nextBlocks ) ) {\n\t\t\t\t\treturn prevBlocks;\n\t\t\t\t}\n\n\t\t\t\treturn nextBlocks;\n\t\t\t} );\n\t\t} );\n\t}, [ sidebar ] );\n\n\tconst onChangeBlocks = useCallback(\n\t\t( nextBlocks ) => {\n\t\t\tsetBlocks( ( prevBlocks ) => {\n\t\t\t\tif ( isShallowEqual( prevBlocks, nextBlocks ) ) {\n\t\t\t\t\treturn prevBlocks;\n\t\t\t\t}\n\n\t\t\t\tconst prevBlocksMap = new Map(\n\t\t\t\t\tprevBlocks.map( ( block ) => [\n\t\t\t\t\t\tgetWidgetIdFromBlock( block ),\n\t\t\t\t\t\tblock,\n\t\t\t\t\t] )\n\t\t\t\t);\n\n\t\t\t\tconst nextWidgets = nextBlocks.map( ( nextBlock ) => {\n\t\t\t\t\tconst widgetId = getWidgetIdFromBlock( nextBlock );\n\n\t\t\t\t\t// Update existing widgets.\n\t\t\t\t\tif ( widgetId && prevBlocksMap.has( widgetId ) ) {\n\t\t\t\t\t\tconst prevBlock = prevBlocksMap.get( widgetId );\n\t\t\t\t\t\tconst prevWidget = sidebar.getWidget( widgetId );\n\n\t\t\t\t\t\t// Bail out updates by returning the previous widgets.\n\t\t\t\t\t\t// Deep equality is necessary until the block editor's internals changes.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tfastDeepEqual( nextBlock, prevBlock ) &&\n\t\t\t\t\t\t\tprevWidget\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn prevWidget;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn blockToWidget( nextBlock, prevWidget );\n\t\t\t\t\t}\n\n\t\t\t\t\t// Add a new widget.\n\t\t\t\t\treturn blockToWidget( nextBlock );\n\t\t\t\t} );\n\n\t\t\t\t// Bail out updates if the updated widgets are the same.\n\t\t\t\tif ( isShallowEqual( sidebar.getWidgets(), nextWidgets ) ) {\n\t\t\t\t\treturn prevBlocks;\n\t\t\t\t}\n\n\t\t\t\tconst addedWidgetIds = sidebar.setWidgets( nextWidgets );\n\n\t\t\t\treturn nextBlocks.reduce(\n\t\t\t\t\t( updatedNextBlocks, nextBlock, index ) => {\n\t\t\t\t\t\tconst addedWidgetId = addedWidgetIds[ index ];\n\n\t\t\t\t\t\tif ( addedWidgetId !== null ) {\n\t\t\t\t\t\t\t// Only create a new instance if necessary to prevent\n\t\t\t\t\t\t\t// the whole editor from re-rendering on every edit.\n\t\t\t\t\t\t\tif ( updatedNextBlocks === nextBlocks ) {\n\t\t\t\t\t\t\t\tupdatedNextBlocks = nextBlocks.slice();\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tupdatedNextBlocks[ index ] = addWidgetIdToBlock(\n\t\t\t\t\t\t\t\tnextBlock,\n\t\t\t\t\t\t\t\taddedWidgetId\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn updatedNextBlocks;\n\t\t\t\t\t},\n\t\t\t\t\tnextBlocks\n\t\t\t\t);\n\t\t\t} );\n\t\t},\n\t\t[ sidebar ]\n\t);\n\n\treturn [ blocks, onChangeBlocks, onChangeBlocks ];\n}\n"],
5
+ "mappings": "AAGA,OAAO,mBAAmB;AAK1B,SAAS,UAAU,WAAW,mBAAmB;AACjD,OAAO,oBAAoB;AAC3B,SAAS,sBAAsB,0BAA0B;AAKzD,SAAS,eAAe,qBAAqB;AAE7C,SAAS,gBAAiB,SAAU;AACnC,SAAO,QAAQ,IAAK,CAAE,WAAY,cAAe,MAAO,CAAE;AAC3D;AAEe,SAAR,sBAAwC,SAAU;AACxD,QAAM,CAAE,QAAQ,SAAU,IAAI;AAAA,IAAU,MACvC,gBAAiB,QAAQ,WAAW,CAAE;AAAA,EACvC;AAEA,YAAW,MAAM;AAChB,WAAO,QAAQ,UAAW,CAAE,aAAa,gBAAiB;AACzD,gBAAW,CAAE,eAAgB;AAC5B,cAAM,iBAAiB,IAAI;AAAA,UAC1B,YAAY,IAAK,CAAE,WAAY,CAAE,OAAO,IAAI,MAAO,CAAE;AAAA,QACtD;AACA,cAAM,gBAAgB,IAAI;AAAA,UAC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AW,UAAW;AAC1C,kBAAM,gBAAgB,eAAgB,KAAM;AAE5C,gBAAK,kBAAkB,MAAO;AAG7B,kBAAK,sBAAsB,YAAa;AACvC,oCAAoB,WAAW,MAAM;AAAA,cACtC;AAEA,gCAAmB,KAAM,IAAI;AAAA,gBAC5B;AAAA,gBACA;AAAA,cACD;AAAA,YACD;AAEA,mBAAO;AAAA,UACR;AAAA,UACA;AAAA,QACD;AAAA,MACD,CAAE;AAAA,IACH;AAAA,IACA,CAAE,OAAQ;AAAA,EACX;AAEA,SAAO,CAAE,QAAQ,gBAAgB,cAAe;AACjD;",
6
+ "names": []
7
+ }
@@ -1,34 +1,33 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { createContext, useMemo, useContext } from '@wordpress/element';
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- export const SidebarControlsContext = createContext();
7
- SidebarControlsContext.displayName = 'SidebarControlsContext';
8
- export default function SidebarControls({
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { createContext, useMemo, useContext } from "@wordpress/element";
3
+ const SidebarControlsContext = createContext();
4
+ SidebarControlsContext.displayName = "SidebarControlsContext";
5
+ function SidebarControls({
9
6
  sidebarControls,
10
7
  activeSidebarControl,
11
8
  children
12
9
  }) {
13
- const context = useMemo(() => ({
14
- sidebarControls,
15
- activeSidebarControl
16
- }), [sidebarControls, activeSidebarControl]);
17
- return /*#__PURE__*/_jsx(SidebarControlsContext.Provider, {
18
- value: context,
19
- children: children
20
- });
10
+ const context = useMemo(
11
+ () => ({
12
+ sidebarControls,
13
+ activeSidebarControl
14
+ }),
15
+ [sidebarControls, activeSidebarControl]
16
+ );
17
+ return /* @__PURE__ */ jsx(SidebarControlsContext.Provider, { value: context, children });
21
18
  }
22
- export function useSidebarControls() {
23
- const {
24
- sidebarControls
25
- } = useContext(SidebarControlsContext);
19
+ function useSidebarControls() {
20
+ const { sidebarControls } = useContext(SidebarControlsContext);
26
21
  return sidebarControls;
27
22
  }
28
- export function useActiveSidebarControl() {
29
- const {
30
- activeSidebarControl
31
- } = useContext(SidebarControlsContext);
23
+ function useActiveSidebarControl() {
24
+ const { activeSidebarControl } = useContext(SidebarControlsContext);
32
25
  return activeSidebarControl;
33
26
  }
34
- //# sourceMappingURL=index.js.map
27
+ export {
28
+ SidebarControlsContext,
29
+ SidebarControls as default,
30
+ useActiveSidebarControl,
31
+ useSidebarControls
32
+ };
33
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["createContext","useMemo","useContext","jsx","_jsx","SidebarControlsContext","displayName","SidebarControls","sidebarControls","activeSidebarControl","children","context","Provider","value","useSidebarControls","useActiveSidebarControl"],"sources":["@wordpress/customize-widgets/src/components/sidebar-controls/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useMemo, useContext } from '@wordpress/element';\n\nexport const SidebarControlsContext = createContext();\nSidebarControlsContext.displayName = 'SidebarControlsContext';\n\nexport default function SidebarControls( {\n\tsidebarControls,\n\tactiveSidebarControl,\n\tchildren,\n} ) {\n\tconst context = useMemo(\n\t\t() => ( {\n\t\t\tsidebarControls,\n\t\t\tactiveSidebarControl,\n\t\t} ),\n\t\t[ sidebarControls, activeSidebarControl ]\n\t);\n\n\treturn (\n\t\t<SidebarControlsContext.Provider value={ context }>\n\t\t\t{ children }\n\t\t</SidebarControlsContext.Provider>\n\t);\n}\n\nexport function useSidebarControls() {\n\tconst { sidebarControls } = useContext( SidebarControlsContext );\n\n\treturn sidebarControls;\n}\n\nexport function useActiveSidebarControl() {\n\tconst { activeSidebarControl } = useContext( SidebarControlsContext );\n\n\treturn activeSidebarControl;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,OAAO,EAAEC,UAAU,QAAQ,oBAAoB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAExE,OAAO,MAAMC,sBAAsB,GAAGL,aAAa,CAAC,CAAC;AACrDK,sBAAsB,CAACC,WAAW,GAAG,wBAAwB;AAE7D,eAAe,SAASC,eAAeA,CAAE;EACxCC,eAAe;EACfC,oBAAoB;EACpBC;AACD,CAAC,EAAG;EACH,MAAMC,OAAO,GAAGV,OAAO,CACtB,OAAQ;IACPO,eAAe;IACfC;EACD,CAAC,CAAE,EACH,CAAED,eAAe,EAAEC,oBAAoB,CACxC,CAAC;EAED,oBACCL,IAAA,CAACC,sBAAsB,CAACO,QAAQ;IAACC,KAAK,EAAGF,OAAS;IAAAD,QAAA,EAC/CA;EAAQ,CACsB,CAAC;AAEpC;AAEA,OAAO,SAASI,kBAAkBA,CAAA,EAAG;EACpC,MAAM;IAAEN;EAAgB,CAAC,GAAGN,UAAU,CAAEG,sBAAuB,CAAC;EAEhE,OAAOG,eAAe;AACvB;AAEA,OAAO,SAASO,uBAAuBA,CAAA,EAAG;EACzC,MAAM;IAAEN;EAAqB,CAAC,GAAGP,UAAU,CAAEG,sBAAuB,CAAC;EAErE,OAAOI,oBAAoB;AAC5B","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/sidebar-controls/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext, useMemo, useContext } from '@wordpress/element';\n\nexport const SidebarControlsContext = createContext();\nSidebarControlsContext.displayName = 'SidebarControlsContext';\n\nexport default function SidebarControls( {\n\tsidebarControls,\n\tactiveSidebarControl,\n\tchildren,\n} ) {\n\tconst context = useMemo(\n\t\t() => ( {\n\t\t\tsidebarControls,\n\t\t\tactiveSidebarControl,\n\t\t} ),\n\t\t[ sidebarControls, activeSidebarControl ]\n\t);\n\n\treturn (\n\t\t<SidebarControlsContext.Provider value={ context }>\n\t\t\t{ children }\n\t\t</SidebarControlsContext.Provider>\n\t);\n}\n\nexport function useSidebarControls() {\n\tconst { sidebarControls } = useContext( SidebarControlsContext );\n\n\treturn sidebarControls;\n}\n\nexport function useActiveSidebarControl() {\n\tconst { activeSidebarControl } = useContext( SidebarControlsContext );\n\n\treturn activeSidebarControl;\n}\n"],
5
+ "mappings": "AAsBE;AAnBF,SAAS,eAAe,SAAS,kBAAkB;AAE5C,MAAM,yBAAyB,cAAc;AACpD,uBAAuB,cAAc;AAEtB,SAAR,gBAAkC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,UAAU;AAAA,IACf,OAAQ;AAAA,MACP;AAAA,MACA;AAAA,IACD;AAAA,IACA,CAAE,iBAAiB,oBAAqB;AAAA,EACzC;AAEA,SACC,oBAAC,uBAAuB,UAAvB,EAAgC,OAAQ,SACtC,UACH;AAEF;AAEO,SAAS,qBAAqB;AACpC,QAAM,EAAE,gBAAgB,IAAI,WAAY,sBAAuB;AAE/D,SAAO;AACR;AAEO,SAAS,0BAA0B;AACzC,QAAM,EAAE,qBAAqB,IAAI,WAAY,sBAAuB;AAEpE,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -1,60 +1,76 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __ } from '@wordpress/i18n';
5
- import { Button, ExternalLink } from '@wordpress/components';
6
- import { useDispatch } from '@wordpress/data';
7
- import { store as preferencesStore } from '@wordpress/preferences';
8
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
- export default function WelcomeGuide({
10
- sidebar
11
- }) {
12
- const {
13
- toggle
14
- } = useDispatch(preferencesStore);
15
- const isEntirelyBlockWidgets = sidebar.getWidgets().every(widget => widget.id.startsWith('block-'));
16
- return /*#__PURE__*/_jsxs("div", {
17
- className: "customize-widgets-welcome-guide",
18
- children: [/*#__PURE__*/_jsx("div", {
19
- className: "customize-widgets-welcome-guide__image__wrapper",
20
- children: /*#__PURE__*/_jsxs("picture", {
21
- children: [/*#__PURE__*/_jsx("source", {
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { __ } from "@wordpress/i18n";
3
+ import { Button, ExternalLink } from "@wordpress/components";
4
+ import { useDispatch } from "@wordpress/data";
5
+ import { store as preferencesStore } from "@wordpress/preferences";
6
+ function WelcomeGuide({ sidebar }) {
7
+ const { toggle } = useDispatch(preferencesStore);
8
+ const isEntirelyBlockWidgets = sidebar.getWidgets().every((widget) => widget.id.startsWith("block-"));
9
+ return /* @__PURE__ */ jsxs("div", { className: "customize-widgets-welcome-guide", children: [
10
+ /* @__PURE__ */ jsx("div", { className: "customize-widgets-welcome-guide__image__wrapper", children: /* @__PURE__ */ jsxs("picture", { children: [
11
+ /* @__PURE__ */ jsx(
12
+ "source",
13
+ {
22
14
  srcSet: "https://s.w.org/images/block-editor/welcome-editor.svg",
23
15
  media: "(prefers-reduced-motion: reduce)"
24
- }), /*#__PURE__*/_jsx("img", {
16
+ }
17
+ ),
18
+ /* @__PURE__ */ jsx(
19
+ "img",
20
+ {
25
21
  className: "customize-widgets-welcome-guide__image",
26
22
  src: "https://s.w.org/images/block-editor/welcome-editor.gif",
27
23
  width: "312",
28
24
  height: "240",
29
25
  alt: ""
30
- })]
31
- })
32
- }), /*#__PURE__*/_jsx("h1", {
33
- className: "customize-widgets-welcome-guide__heading",
34
- children: __('Welcome to block Widgets')
35
- }), /*#__PURE__*/_jsx("p", {
36
- className: "customize-widgets-welcome-guide__text",
37
- children: isEntirelyBlockWidgets ? __('Your theme provides different “block” areas for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.') : __('You can now add any block to your site’s widget areas. Don’t worry, all of your favorite widgets still work flawlessly.')
38
- }), /*#__PURE__*/_jsx(Button, {
39
- size: "compact",
40
- variant: "primary",
41
- onClick: () => toggle('core/customize-widgets', 'welcomeGuide'),
42
- children: __('Got it')
43
- }), /*#__PURE__*/_jsx("hr", {
44
- className: "customize-widgets-welcome-guide__separator"
45
- }), !isEntirelyBlockWidgets && /*#__PURE__*/_jsxs("p", {
46
- className: "customize-widgets-welcome-guide__more-info",
47
- children: [__('Want to stick with the old widgets?'), /*#__PURE__*/_jsx("br", {}), /*#__PURE__*/_jsx(ExternalLink, {
48
- href: __('https://wordpress.org/plugins/classic-widgets/'),
49
- children: __('Get the Classic Widgets plugin.')
50
- })]
51
- }), /*#__PURE__*/_jsxs("p", {
52
- className: "customize-widgets-welcome-guide__more-info",
53
- children: [__('New to the block editor?'), /*#__PURE__*/_jsx("br", {}), /*#__PURE__*/_jsx(ExternalLink, {
54
- href: __('https://wordpress.org/documentation/article/wordpress-block-editor/'),
55
- children: __("Here's a detailed guide.")
56
- })]
57
- })]
58
- });
26
+ }
27
+ )
28
+ ] }) }),
29
+ /* @__PURE__ */ jsx("h1", { className: "customize-widgets-welcome-guide__heading", children: __("Welcome to block Widgets") }),
30
+ /* @__PURE__ */ jsx("p", { className: "customize-widgets-welcome-guide__text", children: isEntirelyBlockWidgets ? __(
31
+ "Your theme provides different \u201Cblock\u201D areas for you to add and edit content.\xA0Try adding a search bar, social icons, or other types of blocks here and see how they\u2019ll look on your site."
32
+ ) : __(
33
+ "You can now add any block to your site\u2019s widget areas. Don\u2019t worry, all of your favorite widgets still work flawlessly."
34
+ ) }),
35
+ /* @__PURE__ */ jsx(
36
+ Button,
37
+ {
38
+ size: "compact",
39
+ variant: "primary",
40
+ onClick: () => toggle("core/customize-widgets", "welcomeGuide"),
41
+ children: __("Got it")
42
+ }
43
+ ),
44
+ /* @__PURE__ */ jsx("hr", { className: "customize-widgets-welcome-guide__separator" }),
45
+ !isEntirelyBlockWidgets && /* @__PURE__ */ jsxs("p", { className: "customize-widgets-welcome-guide__more-info", children: [
46
+ __("Want to stick with the old widgets?"),
47
+ /* @__PURE__ */ jsx("br", {}),
48
+ /* @__PURE__ */ jsx(
49
+ ExternalLink,
50
+ {
51
+ href: __(
52
+ "https://wordpress.org/plugins/classic-widgets/"
53
+ ),
54
+ children: __("Get the Classic Widgets plugin.")
55
+ }
56
+ )
57
+ ] }),
58
+ /* @__PURE__ */ jsxs("p", { className: "customize-widgets-welcome-guide__more-info", children: [
59
+ __("New to the block editor?"),
60
+ /* @__PURE__ */ jsx("br", {}),
61
+ /* @__PURE__ */ jsx(
62
+ ExternalLink,
63
+ {
64
+ href: __(
65
+ "https://wordpress.org/documentation/article/wordpress-block-editor/"
66
+ ),
67
+ children: __("Here's a detailed guide.")
68
+ }
69
+ )
70
+ ] })
71
+ ] });
59
72
  }
60
- //# sourceMappingURL=index.js.map
73
+ export {
74
+ WelcomeGuide as default
75
+ };
76
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["__","Button","ExternalLink","useDispatch","store","preferencesStore","jsx","_jsx","jsxs","_jsxs","WelcomeGuide","sidebar","toggle","isEntirelyBlockWidgets","getWidgets","every","widget","id","startsWith","className","children","srcSet","media","src","width","height","alt","size","variant","onClick","href"],"sources":["@wordpress/customize-widgets/src/components/welcome-guide/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Button, ExternalLink } from '@wordpress/components';\nimport { useDispatch } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\nexport default function WelcomeGuide( { sidebar } ) {\n\tconst { toggle } = useDispatch( preferencesStore );\n\n\tconst isEntirelyBlockWidgets = sidebar\n\t\t.getWidgets()\n\t\t.every( ( widget ) => widget.id.startsWith( 'block-' ) );\n\n\treturn (\n\t\t<div className=\"customize-widgets-welcome-guide\">\n\t\t\t<div className=\"customize-widgets-welcome-guide__image__wrapper\">\n\t\t\t\t<picture>\n\t\t\t\t\t<source\n\t\t\t\t\t\tsrcSet=\"https://s.w.org/images/block-editor/welcome-editor.svg\"\n\t\t\t\t\t\tmedia=\"(prefers-reduced-motion: reduce)\"\n\t\t\t\t\t/>\n\t\t\t\t\t<img\n\t\t\t\t\t\tclassName=\"customize-widgets-welcome-guide__image\"\n\t\t\t\t\t\tsrc=\"https://s.w.org/images/block-editor/welcome-editor.gif\"\n\t\t\t\t\t\twidth=\"312\"\n\t\t\t\t\t\theight=\"240\"\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t/>\n\t\t\t\t</picture>\n\t\t\t</div>\n\t\t\t<h1 className=\"customize-widgets-welcome-guide__heading\">\n\t\t\t\t{ __( 'Welcome to block Widgets' ) }\n\t\t\t</h1>\n\t\t\t<p className=\"customize-widgets-welcome-guide__text\">\n\t\t\t\t{ isEntirelyBlockWidgets\n\t\t\t\t\t? __(\n\t\t\t\t\t\t\t'Your theme provides different “block” areas for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.'\n\t\t\t\t\t )\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'You can now add any block to your site’s widget areas. Don’t worry, all of your favorite widgets still work flawlessly.'\n\t\t\t\t\t ) }\n\t\t\t</p>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tonClick={ () =>\n\t\t\t\t\ttoggle( 'core/customize-widgets', 'welcomeGuide' )\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ __( 'Got it' ) }\n\t\t\t</Button>\n\t\t\t<hr className=\"customize-widgets-welcome-guide__separator\" />\n\t\t\t{ ! isEntirelyBlockWidgets && (\n\t\t\t\t<p className=\"customize-widgets-welcome-guide__more-info\">\n\t\t\t\t\t{ __( 'Want to stick with the old widgets?' ) }\n\t\t\t\t\t<br />\n\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t'https://wordpress.org/plugins/classic-widgets/'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Get the Classic Widgets plugin.' ) }\n\t\t\t\t\t</ExternalLink>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t<p className=\"customize-widgets-welcome-guide__more-info\">\n\t\t\t\t{ __( 'New to the block editor?' ) }\n\t\t\t\t<br />\n\t\t\t\t<ExternalLink\n\t\t\t\t\thref={ __(\n\t\t\t\t\t\t'https://wordpress.org/documentation/article/wordpress-block-editor/'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ __( \"Here's a detailed guide.\" ) }\n\t\t\t\t</ExternalLink>\n\t\t\t</p>\n\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AAS;MACdC,OAAO,EAAC,SAAS;MACjBC,OAAO,EAAGA,CAAA,KACTjB,MAAM,CAAE,wBAAwB,EAAE,cAAe,CACjD;MAAAQ,QAAA,EAECpB,EAAE,CAAE,QAAS;IAAC,CACT,CAAC,eACTO,IAAA;MAAIY,SAAS,EAAC;IAA4C,CAAE,CAAC,EAC3D,CAAEN,sBAAsB,iBACzBJ,KAAA;MAAGU,SAAS,EAAC,4CAA4C;MAAAC,QAAA,GACtDpB,EAAE,CAAE,qCAAsC,CAAC,eAC7CO,IAAA,SAAK,CAAC,eACNA,IAAA,CAACL,YAAY;QACZ4B,IAAI,EAAG9B,EAAE,CACR,gDACD,CAAG;QAAAoB,QAAA,EAEDpB,EAAE,CAAE,iCAAkC;MAAC,CAC5B,CAAC;IAAA,CACb,CACH,eACDS,KAAA;MAAGU,SAAS,EAAC,4CAA4C;MAAAC,QAAA,GACtDpB,EAAE,CAAE,0BAA2B,CAAC,eAClCO,IAAA,SAAK,CAAC,eACNA,IAAA,CAACL,YAAY;QACZ4B,IAAI,EAAG9B,EAAE,CACR,qEACD,CAAG;QAAAoB,QAAA,EAEDpB,EAAE,CAAE,0BAA2B;MAAC,CACrB,CAAC;IAAA,CACb,CAAC;EAAA,CACA,CAAC;AAER","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/welcome-guide/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Button, ExternalLink } from '@wordpress/components';\nimport { useDispatch } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\nexport default function WelcomeGuide( { sidebar } ) {\n\tconst { toggle } = useDispatch( preferencesStore );\n\n\tconst isEntirelyBlockWidgets = sidebar\n\t\t.getWidgets()\n\t\t.every( ( widget ) => widget.id.startsWith( 'block-' ) );\n\n\treturn (\n\t\t<div className=\"customize-widgets-welcome-guide\">\n\t\t\t<div className=\"customize-widgets-welcome-guide__image__wrapper\">\n\t\t\t\t<picture>\n\t\t\t\t\t<source\n\t\t\t\t\t\tsrcSet=\"https://s.w.org/images/block-editor/welcome-editor.svg\"\n\t\t\t\t\t\tmedia=\"(prefers-reduced-motion: reduce)\"\n\t\t\t\t\t/>\n\t\t\t\t\t<img\n\t\t\t\t\t\tclassName=\"customize-widgets-welcome-guide__image\"\n\t\t\t\t\t\tsrc=\"https://s.w.org/images/block-editor/welcome-editor.gif\"\n\t\t\t\t\t\twidth=\"312\"\n\t\t\t\t\t\theight=\"240\"\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t/>\n\t\t\t\t</picture>\n\t\t\t</div>\n\t\t\t<h1 className=\"customize-widgets-welcome-guide__heading\">\n\t\t\t\t{ __( 'Welcome to block Widgets' ) }\n\t\t\t</h1>\n\t\t\t<p className=\"customize-widgets-welcome-guide__text\">\n\t\t\t\t{ isEntirelyBlockWidgets\n\t\t\t\t\t? __(\n\t\t\t\t\t\t\t'Your theme provides different \u201Cblock\u201D areas for you to add and edit content.\u00A0Try adding a search bar, social icons, or other types of blocks here and see how they\u2019ll look on your site.'\n\t\t\t\t\t )\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'You can now add any block to your site\u2019s widget areas. Don\u2019t worry, all of your favorite widgets still work flawlessly.'\n\t\t\t\t\t ) }\n\t\t\t</p>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tonClick={ () =>\n\t\t\t\t\ttoggle( 'core/customize-widgets', 'welcomeGuide' )\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ __( 'Got it' ) }\n\t\t\t</Button>\n\t\t\t<hr className=\"customize-widgets-welcome-guide__separator\" />\n\t\t\t{ ! isEntirelyBlockWidgets && (\n\t\t\t\t<p className=\"customize-widgets-welcome-guide__more-info\">\n\t\t\t\t\t{ __( 'Want to stick with the old widgets?' ) }\n\t\t\t\t\t<br />\n\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t'https://wordpress.org/plugins/classic-widgets/'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Get the Classic Widgets plugin.' ) }\n\t\t\t\t\t</ExternalLink>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t<p className=\"customize-widgets-welcome-guide__more-info\">\n\t\t\t\t{ __( 'New to the block editor?' ) }\n\t\t\t\t<br />\n\t\t\t\t<ExternalLink\n\t\t\t\t\thref={ __(\n\t\t\t\t\t\t'https://wordpress.org/documentation/article/wordpress-block-editor/'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ __( \"Here's a detailed guide.\" ) }\n\t\t\t\t</ExternalLink>\n\t\t\t</p>\n\t\t</div>\n\t);\n}\n"],
5
+ "mappings": "AAkBI,SACC,KADD;AAfJ,SAAS,UAAU;AACnB,SAAS,QAAQ,oBAAoB;AACrC,SAAS,mBAAmB;AAC5B,SAAS,SAAS,wBAAwB;AAE3B,SAAR,aAA+B,EAAE,QAAQ,GAAI;AACnD,QAAM,EAAE,OAAO,IAAI,YAAa,gBAAiB;AAEjD,QAAM,yBAAyB,QAC7B,WAAW,EACX,MAAO,CAAE,WAAY,OAAO,GAAG,WAAY,QAAS,CAAE;AAExD,SACC,qBAAC,SAAI,WAAU,mCACd;AAAA,wBAAC,SAAI,WAAU,mDACd,+BAAC,aACA;AAAA;AAAA,QAAC;AAAA;AAAA,UACA,QAAO;AAAA,UACP,OAAM;AAAA;AAAA,MACP;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,KAAI;AAAA,UACJ,OAAM;AAAA,UACN,QAAO;AAAA,UACP,KAAI;AAAA;AAAA,MACL;AAAA,OACD,GACD;AAAA,IACA,oBAAC,QAAG,WAAU,4CACX,aAAI,0BAA2B,GAClC;AAAA,IACA,oBAAC,OAAE,WAAU,yCACV,mCACC;AAAA,MACA;AAAA,IACA,IACA;AAAA,MACA;AAAA,IACA,GACJ;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,SAAQ;AAAA,QACR,SAAU,MACT,OAAQ,0BAA0B,cAAe;AAAA,QAGhD,aAAI,QAAS;AAAA;AAAA,IAChB;AAAA,IACA,oBAAC,QAAG,WAAU,8CAA6C;AAAA,IACzD,CAAE,0BACH,qBAAC,OAAE,WAAU,8CACV;AAAA,SAAI,qCAAsC;AAAA,MAC5C,oBAAC,QAAG;AAAA,MACJ;AAAA,QAAC;AAAA;AAAA,UACA,MAAO;AAAA,YACN;AAAA,UACD;AAAA,UAEE,aAAI,iCAAkC;AAAA;AAAA,MACzC;AAAA,OACD;AAAA,IAED,qBAAC,OAAE,WAAU,8CACV;AAAA,SAAI,0BAA2B;AAAA,MACjC,oBAAC,QAAG;AAAA,MACJ;AAAA,QAAC;AAAA;AAAA,UACA,MAAO;AAAA,YACN;AAAA,UACD;AAAA,UAEE,aAAI,0BAA2B;AAAA;AAAA,MAClC;AAAA,OACD;AAAA,KACD;AAEF;",
6
+ "names": []
7
+ }
@@ -1,29 +1,17 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { ESCAPE } from '@wordpress/keycodes';
5
- import { focus } from '@wordpress/dom';
6
- import { dispatch } from '@wordpress/data';
7
-
8
- /**
9
- * Internal dependencies
10
- */
11
- import { store as customizeWidgetsStore } from '../store';
12
- export default function getInserterOuterSection() {
1
+ import { ESCAPE } from "@wordpress/keycodes";
2
+ import { focus } from "@wordpress/dom";
3
+ import { dispatch } from "@wordpress/data";
4
+ import { store as customizeWidgetsStore } from "../store";
5
+ function getInserterOuterSection() {
13
6
  const {
14
- wp: {
15
- customize
16
- }
7
+ wp: { customize }
17
8
  } = window;
18
9
  const OuterSection = customize.OuterSection;
19
- // Override the OuterSection class to handle multiple outer sections.
20
- // It closes all the other outer sections whenever one is opened.
21
- // The result is that at most one outer section can be opened at the same time.
22
10
  customize.OuterSection = class extends OuterSection {
23
11
  onChangeExpanded(expanded, args) {
24
12
  if (expanded) {
25
- customize.section.each(section => {
26
- if (section.params.type === 'outer' && section.id !== this.id) {
13
+ customize.section.each((section) => {
14
+ if (section.params.type === "outer" && section.id !== this.id) {
27
15
  if (section.expanded()) {
28
16
  section.collapse();
29
17
  }
@@ -33,37 +21,34 @@ export default function getInserterOuterSection() {
33
21
  return super.onChangeExpanded(expanded, args);
34
22
  }
35
23
  };
36
- // Handle constructor so that "params.type" can be correctly pointed to "outer".
37
24
  customize.sectionConstructor.outer = customize.OuterSection;
38
25
  return class InserterOuterSection extends customize.OuterSection {
39
26
  constructor(...args) {
40
27
  super(...args);
41
-
42
- // This is necessary since we're creating a new class which is not identical to the original OuterSection.
43
- // @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436
44
- this.params.type = 'outer';
28
+ this.params.type = "outer";
45
29
  this.activeElementBeforeExpanded = null;
46
30
  const ownerWindow = this.contentContainer[0].ownerDocument.defaultView;
47
-
48
- // Handle closing the inserter when pressing the Escape key.
49
- ownerWindow.addEventListener('keydown', event => {
50
- if (this.expanded() && (event.keyCode === ESCAPE || event.code === 'Escape') && !event.defaultPrevented) {
51
- event.preventDefault();
52
- event.stopPropagation();
53
- dispatch(customizeWidgetsStore).setIsInserterOpened(false);
54
- }
55
- },
56
- // Use capture mode to make this run before other event listeners.
57
- true);
58
- this.contentContainer.addClass('widgets-inserter');
59
-
60
- // Set a flag if the state is being changed from open() or close().
61
- // Don't propagate the event if it's an internal action to prevent infinite loop.
31
+ ownerWindow.addEventListener(
32
+ "keydown",
33
+ (event) => {
34
+ if (this.expanded() && (event.keyCode === ESCAPE || event.code === "Escape") && !event.defaultPrevented) {
35
+ event.preventDefault();
36
+ event.stopPropagation();
37
+ dispatch(customizeWidgetsStore).setIsInserterOpened(
38
+ false
39
+ );
40
+ }
41
+ },
42
+ // Use capture mode to make this run before other event listeners.
43
+ true
44
+ );
45
+ this.contentContainer.addClass("widgets-inserter");
62
46
  this.isFromInternalAction = false;
63
47
  this.expanded.bind(() => {
64
48
  if (!this.isFromInternalAction) {
65
- // Propagate the event to React to sync the state.
66
- dispatch(customizeWidgetsStore).setIsInserterOpened(this.expanded());
49
+ dispatch(customizeWidgetsStore).setIsInserterOpened(
50
+ this.expanded()
51
+ );
67
52
  }
68
53
  this.isFromInternalAction = false;
69
54
  });
@@ -75,9 +60,6 @@ export default function getInserterOuterSection() {
75
60
  this.isFromInternalAction = true;
76
61
  this.expand({
77
62
  completeCallback() {
78
- // We have to do this in a "completeCallback" or else the elements will not yet be visible/tabbable.
79
- // The first one should be the close button,
80
- // we want to skip it and choose the second one instead, which is the search box.
81
63
  const searchBox = focus.tabbable.find(contentContainer)[1];
82
64
  if (searchBox) {
83
65
  searchBox.focus();
@@ -93,13 +75,7 @@ export default function getInserterOuterSection() {
93
75
  this.isFromInternalAction = true;
94
76
  this.collapse({
95
77
  completeCallback() {
96
- // Return back the focus when closing the inserter.
97
- // Only do this if the active element which triggers the action is inside the inserter,
98
- // (the close button for instance). In that case the focus will be lost.
99
- // Otherwise, we don't hijack the focus when the user is focusing on other elements
100
- // (like the quick inserter).
101
78
  if (contentContainer.contains(activeElement)) {
102
- // Return back the focus when closing the inserter.
103
79
  if (this.activeElementBeforeExpanded) {
104
80
  this.activeElementBeforeExpanded.focus();
105
81
  }
@@ -110,4 +86,7 @@ export default function getInserterOuterSection() {
110
86
  }
111
87
  };
112
88
  }
113
- //# sourceMappingURL=inserter-outer-section.js.map
89
+ export {
90
+ getInserterOuterSection as default
91
+ };
92
+ //# sourceMappingURL=inserter-outer-section.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["ESCAPE","focus","dispatch","store","customizeWidgetsStore","getInserterOuterSection","wp","customize","window","OuterSection","onChangeExpanded","expanded","args","section","each","params","type","id","collapse","sectionConstructor","outer","InserterOuterSection","constructor","activeElementBeforeExpanded","ownerWindow","contentContainer","ownerDocument","defaultView","addEventListener","event","keyCode","code","defaultPrevented","preventDefault","stopPropagation","setIsInserterOpened","addClass","isFromInternalAction","bind","open","activeElement","expand","completeCallback","searchBox","tabbable","find","close","contains"],"sources":["@wordpress/customize-widgets/src/controls/inserter-outer-section.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ESCAPE } from '@wordpress/keycodes';\nimport { focus } from '@wordpress/dom';\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as customizeWidgetsStore } from '../store';\n\nexport default function getInserterOuterSection() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\tconst OuterSection = customize.OuterSection;\n\t// Override the OuterSection class to handle multiple outer sections.\n\t// It closes all the other outer sections whenever one is opened.\n\t// The result is that at most one outer section can be opened at the same time.\n\tcustomize.OuterSection = class extends OuterSection {\n\t\tonChangeExpanded( expanded, args ) {\n\t\t\tif ( expanded ) {\n\t\t\t\tcustomize.section.each( ( section ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tsection.params.type === 'outer' &&\n\t\t\t\t\t\tsection.id !== this.id\n\t\t\t\t\t) {\n\t\t\t\t\t\tif ( section.expanded() ) {\n\t\t\t\t\t\t\tsection.collapse();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn super.onChangeExpanded( expanded, args );\n\t\t}\n\t};\n\t// Handle constructor so that \"params.type\" can be correctly pointed to \"outer\".\n\tcustomize.sectionConstructor.outer = customize.OuterSection;\n\n\treturn class InserterOuterSection extends customize.OuterSection {\n\t\tconstructor( ...args ) {\n\t\t\tsuper( ...args );\n\n\t\t\t// This is necessary since we're creating a new class which is not identical to the original OuterSection.\n\t\t\t// @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436\n\t\t\tthis.params.type = 'outer';\n\n\t\t\tthis.activeElementBeforeExpanded = null;\n\n\t\t\tconst ownerWindow =\n\t\t\t\tthis.contentContainer[ 0 ].ownerDocument.defaultView;\n\n\t\t\t// Handle closing the inserter when pressing the Escape key.\n\t\t\townerWindow.addEventListener(\n\t\t\t\t'keydown',\n\t\t\t\t( event ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.expanded() &&\n\t\t\t\t\t\t( event.keyCode === ESCAPE ||\n\t\t\t\t\t\t\tevent.code === 'Escape' ) &&\n\t\t\t\t\t\t! event.defaultPrevented\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t// Use capture mode to make this run before other event listeners.\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tthis.contentContainer.addClass( 'widgets-inserter' );\n\n\t\t\t// Set a flag if the state is being changed from open() or close().\n\t\t\t// Don't propagate the event if it's an internal action to prevent infinite loop.\n\t\t\tthis.isFromInternalAction = false;\n\t\t\tthis.expanded.bind( () => {\n\t\t\t\tif ( ! this.isFromInternalAction ) {\n\t\t\t\t\t// Propagate the event to React to sync the state.\n\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\tthis.expanded()\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.isFromInternalAction = false;\n\t\t\t} );\n\t\t}\n\t\topen() {\n\t\t\tif ( ! this.expanded() ) {\n\t\t\t\tconst contentContainer = this.contentContainer[ 0 ];\n\t\t\t\tthis.activeElementBeforeExpanded =\n\t\t\t\t\tcontentContainer.ownerDocument.activeElement;\n\n\t\t\t\tthis.isFromInternalAction = true;\n\n\t\t\t\tthis.expand( {\n\t\t\t\t\tcompleteCallback() {\n\t\t\t\t\t\t// We have to do this in a \"completeCallback\" or else the elements will not yet be visible/tabbable.\n\t\t\t\t\t\t// The first one should be the close button,\n\t\t\t\t\t\t// we want to skip it and choose the second one instead, which is the search box.\n\t\t\t\t\t\tconst searchBox =\n\t\t\t\t\t\t\tfocus.tabbable.find( contentContainer )[ 1 ];\n\t\t\t\t\t\tif ( searchBox ) {\n\t\t\t\t\t\t\tsearchBox.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t\tclose() {\n\t\t\tif ( this.expanded() ) {\n\t\t\t\tconst contentContainer = this.contentContainer[ 0 ];\n\t\t\t\tconst activeElement =\n\t\t\t\t\tcontentContainer.ownerDocument.activeElement;\n\n\t\t\t\tthis.isFromInternalAction = true;\n\n\t\t\t\tthis.collapse( {\n\t\t\t\t\tcompleteCallback() {\n\t\t\t\t\t\t// Return back the focus when closing the inserter.\n\t\t\t\t\t\t// Only do this if the active element which triggers the action is inside the inserter,\n\t\t\t\t\t\t// (the close button for instance). In that case the focus will be lost.\n\t\t\t\t\t\t// Otherwise, we don't hijack the focus when the user is focusing on other elements\n\t\t\t\t\t\t// (like the quick inserter).\n\t\t\t\t\t\tif ( contentContainer.contains( activeElement ) ) {\n\t\t\t\t\t\t\t// Return back the focus when closing the inserter.\n\t\t\t\t\t\t\tif ( this.activeElementBeforeExpanded ) {\n\t\t\t\t\t\t\t\tthis.activeElementBeforeExpanded.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,QAAQ,QAAQ,iBAAiB;;AAE1C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,qBAAqB,QAAQ,UAAU;AAEzD,eAAe,SAASC,uBAAuBA,CAAA,EAAG;EACjD,MAAM;IACLC,EAAE,EAAE;MAAEC;IAAU;EACjB,CAAC,GAAGC,MAAM;EAEV,MAAMC,YAAY,GAAGF,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,IAAI,CAACH,oBAAoB,GAAG,IAAI;QAEhC,IAAI,CAACnB,QAAQ,CAAE;UACdwB,gBAAgBA,CAAA,EAAG;YAClB;YACA;YACA;YACA;YACA;YACA,IAAKjB,gBAAgB,CAACsB,QAAQ,CAAEP,aAAc,CAAC,EAAG;cACjD;cACA,IAAK,IAAI,CAACjB,2BAA2B,EAAG;gBACvC,IAAI,CAACA,2BAA2B,CAACtB,KAAK,CAAC,CAAC;cACzC;YACD;UACD;QACD,CAAE,CAAC;MACJ;IACD;EACD,CAAC;AACF","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/controls/inserter-outer-section.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { ESCAPE } from '@wordpress/keycodes';\nimport { focus } from '@wordpress/dom';\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as customizeWidgetsStore } from '../store';\n\nexport default function getInserterOuterSection() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\tconst OuterSection = customize.OuterSection;\n\t// Override the OuterSection class to handle multiple outer sections.\n\t// It closes all the other outer sections whenever one is opened.\n\t// The result is that at most one outer section can be opened at the same time.\n\tcustomize.OuterSection = class extends OuterSection {\n\t\tonChangeExpanded( expanded, args ) {\n\t\t\tif ( expanded ) {\n\t\t\t\tcustomize.section.each( ( section ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tsection.params.type === 'outer' &&\n\t\t\t\t\t\tsection.id !== this.id\n\t\t\t\t\t) {\n\t\t\t\t\t\tif ( section.expanded() ) {\n\t\t\t\t\t\t\tsection.collapse();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn super.onChangeExpanded( expanded, args );\n\t\t}\n\t};\n\t// Handle constructor so that \"params.type\" can be correctly pointed to \"outer\".\n\tcustomize.sectionConstructor.outer = customize.OuterSection;\n\n\treturn class InserterOuterSection extends customize.OuterSection {\n\t\tconstructor( ...args ) {\n\t\t\tsuper( ...args );\n\n\t\t\t// This is necessary since we're creating a new class which is not identical to the original OuterSection.\n\t\t\t// @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436\n\t\t\tthis.params.type = 'outer';\n\n\t\t\tthis.activeElementBeforeExpanded = null;\n\n\t\t\tconst ownerWindow =\n\t\t\t\tthis.contentContainer[ 0 ].ownerDocument.defaultView;\n\n\t\t\t// Handle closing the inserter when pressing the Escape key.\n\t\t\townerWindow.addEventListener(\n\t\t\t\t'keydown',\n\t\t\t\t( event ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.expanded() &&\n\t\t\t\t\t\t( event.keyCode === ESCAPE ||\n\t\t\t\t\t\t\tevent.code === 'Escape' ) &&\n\t\t\t\t\t\t! event.defaultPrevented\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t// Use capture mode to make this run before other event listeners.\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tthis.contentContainer.addClass( 'widgets-inserter' );\n\n\t\t\t// Set a flag if the state is being changed from open() or close().\n\t\t\t// Don't propagate the event if it's an internal action to prevent infinite loop.\n\t\t\tthis.isFromInternalAction = false;\n\t\t\tthis.expanded.bind( () => {\n\t\t\t\tif ( ! this.isFromInternalAction ) {\n\t\t\t\t\t// Propagate the event to React to sync the state.\n\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\tthis.expanded()\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.isFromInternalAction = false;\n\t\t\t} );\n\t\t}\n\t\topen() {\n\t\t\tif ( ! this.expanded() ) {\n\t\t\t\tconst contentContainer = this.contentContainer[ 0 ];\n\t\t\t\tthis.activeElementBeforeExpanded =\n\t\t\t\t\tcontentContainer.ownerDocument.activeElement;\n\n\t\t\t\tthis.isFromInternalAction = true;\n\n\t\t\t\tthis.expand( {\n\t\t\t\t\tcompleteCallback() {\n\t\t\t\t\t\t// We have to do this in a \"completeCallback\" or else the elements will not yet be visible/tabbable.\n\t\t\t\t\t\t// The first one should be the close button,\n\t\t\t\t\t\t// we want to skip it and choose the second one instead, which is the search box.\n\t\t\t\t\t\tconst searchBox =\n\t\t\t\t\t\t\tfocus.tabbable.find( contentContainer )[ 1 ];\n\t\t\t\t\t\tif ( searchBox ) {\n\t\t\t\t\t\t\tsearchBox.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t\tclose() {\n\t\t\tif ( this.expanded() ) {\n\t\t\t\tconst contentContainer = this.contentContainer[ 0 ];\n\t\t\t\tconst activeElement =\n\t\t\t\t\tcontentContainer.ownerDocument.activeElement;\n\n\t\t\t\tthis.isFromInternalAction = true;\n\n\t\t\t\tthis.collapse( {\n\t\t\t\t\tcompleteCallback() {\n\t\t\t\t\t\t// Return back the focus when closing the inserter.\n\t\t\t\t\t\t// Only do this if the active element which triggers the action is inside the inserter,\n\t\t\t\t\t\t// (the close button for instance). In that case the focus will be lost.\n\t\t\t\t\t\t// Otherwise, we don't hijack the focus when the user is focusing on other elements\n\t\t\t\t\t\t// (like the quick inserter).\n\t\t\t\t\t\tif ( contentContainer.contains( activeElement ) ) {\n\t\t\t\t\t\t\t// Return back the focus when closing the inserter.\n\t\t\t\t\t\t\tif ( this.activeElementBeforeExpanded ) {\n\t\t\t\t\t\t\t\tthis.activeElementBeforeExpanded.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t};\n}\n"],
5
+ "mappings": "AAGA,SAAS,cAAc;AACvB,SAAS,a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