@wordpress/customize-widgets 6.0.0 → 6.1.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 (155) hide show
  1. package/build/components/block-appender/index.cjs +24 -41
  2. package/build/components/block-appender/index.cjs.map +1 -7
  3. package/build/components/block-inspector-button/index.cjs +24 -52
  4. package/build/components/block-inspector-button/index.cjs.map +1 -7
  5. package/build/components/customize-widgets/index.cjs +76 -97
  6. package/build/components/customize-widgets/index.cjs.map +1 -7
  7. package/build/components/customize-widgets/use-clear-selected-block.cjs +58 -67
  8. package/build/components/customize-widgets/use-clear-selected-block.cjs.map +1 -7
  9. package/build/components/error-boundary/index.cjs +115 -155
  10. package/build/components/error-boundary/index.cjs.map +1 -7
  11. package/build/components/focus-control/index.cjs +44 -84
  12. package/build/components/focus-control/index.cjs.map +1 -7
  13. package/build/components/focus-control/use-blocks-focus-control.cjs +28 -49
  14. package/build/components/focus-control/use-blocks-focus-control.cjs.map +1 -7
  15. package/build/components/header/index.cjs +84 -122
  16. package/build/components/header/index.cjs.map +1 -7
  17. package/build/components/inserter/index.cjs +43 -78
  18. package/build/components/inserter/index.cjs.map +1 -7
  19. package/build/components/inserter/use-inserter.cjs +22 -54
  20. package/build/components/inserter/use-inserter.cjs.map +1 -7
  21. package/build/components/keyboard-shortcut-help-modal/config.cjs +88 -85
  22. package/build/components/keyboard-shortcut-help-modal/config.cjs.map +1 -7
  23. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs +40 -57
  24. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs.map +1 -7
  25. package/build/components/keyboard-shortcut-help-modal/index.cjs +103 -165
  26. package/build/components/keyboard-shortcut-help-modal/index.cjs.map +1 -7
  27. package/build/components/keyboard-shortcut-help-modal/shortcut.cjs +37 -76
  28. package/build/components/keyboard-shortcut-help-modal/shortcut.cjs.map +1 -7
  29. package/build/components/keyboard-shortcuts/index.cjs +70 -100
  30. package/build/components/keyboard-shortcuts/index.cjs.map +1 -7
  31. package/build/components/more-menu/index.cjs +103 -151
  32. package/build/components/more-menu/index.cjs.map +1 -7
  33. package/build/components/sidebar-block-editor/index.cjs +122 -155
  34. package/build/components/sidebar-block-editor/index.cjs.map +1 -7
  35. package/build/components/sidebar-block-editor/sidebar-adapter.cjs +207 -270
  36. package/build/components/sidebar-block-editor/sidebar-adapter.cjs.map +1 -7
  37. package/build/components/sidebar-block-editor/sidebar-editor-provider.cjs +40 -50
  38. package/build/components/sidebar-block-editor/sidebar-editor-provider.cjs.map +1 -7
  39. package/build/components/sidebar-block-editor/use-sidebar-block-editor.cjs +75 -110
  40. package/build/components/sidebar-block-editor/use-sidebar-block-editor.cjs.map +1 -7
  41. package/build/components/sidebar-controls/index.cjs +27 -53
  42. package/build/components/sidebar-controls/index.cjs.map +1 -7
  43. package/build/components/welcome-guide/index.cjs +70 -94
  44. package/build/components/welcome-guide/index.cjs.map +1 -7
  45. package/build/controls/inserter-outer-section.cjs +68 -110
  46. package/build/controls/inserter-outer-section.cjs.map +1 -7
  47. package/build/controls/inspector-section.cjs +57 -90
  48. package/build/controls/inspector-section.cjs.map +1 -7
  49. package/build/controls/sidebar-control.cjs +55 -69
  50. package/build/controls/sidebar-control.cjs.map +1 -7
  51. package/build/controls/sidebar-section.cjs +79 -103
  52. package/build/controls/sidebar-section.cjs.map +1 -7
  53. package/build/filters/index.cjs +8 -5
  54. package/build/filters/move-to-sidebar.cjs +62 -78
  55. package/build/filters/move-to-sidebar.cjs.map +1 -7
  56. package/build/filters/replace-media-upload.cjs +11 -9
  57. package/build/filters/replace-media-upload.cjs.map +1 -7
  58. package/build/filters/wide-widget-display.cjs +20 -20
  59. package/build/filters/wide-widget-display.cjs.map +1 -7
  60. package/build/index.cjs +84 -91
  61. package/build/index.cjs.map +1 -7
  62. package/build/lock-unlock.cjs +10 -35
  63. package/build/lock-unlock.cjs.map +1 -7
  64. package/build/store/actions.cjs +49 -32
  65. package/build/store/actions.cjs.map +1 -7
  66. package/build/store/constants.cjs +12 -29
  67. package/build/store/constants.cjs.map +1 -7
  68. package/build/store/index.cjs +49 -41
  69. package/build/store/index.cjs.map +1 -7
  70. package/build/store/reducer.cjs +20 -33
  71. package/build/store/reducer.cjs.map +1 -7
  72. package/build/store/selectors.cjs +47 -38
  73. package/build/store/selectors.cjs.map +1 -7
  74. package/build/utils.cjs +81 -108
  75. package/build/utils.cjs.map +1 -7
  76. package/build-module/components/block-appender/index.mjs +18 -23
  77. package/build-module/components/block-appender/index.mjs.map +1 -7
  78. package/build-module/components/block-inspector-button/index.mjs +15 -28
  79. package/build-module/components/block-inspector-button/index.mjs.map +1 -7
  80. package/build-module/components/customize-widgets/index.mjs +45 -73
  81. package/build-module/components/customize-widgets/index.mjs.map +1 -7
  82. package/build-module/components/customize-widgets/use-clear-selected-block.mjs +52 -46
  83. package/build-module/components/customize-widgets/use-clear-selected-block.mjs.map +1 -7
  84. package/build-module/components/error-boundary/index.mjs +103 -128
  85. package/build-module/components/error-boundary/index.mjs.map +1 -7
  86. package/build-module/components/focus-control/index.mjs +37 -66
  87. package/build-module/components/focus-control/index.mjs.map +1 -7
  88. package/build-module/components/focus-control/use-blocks-focus-control.mjs +21 -27
  89. package/build-module/components/focus-control/use-blocks-focus-control.mjs.map +1 -7
  90. package/build-module/components/header/index.mjs +55 -92
  91. package/build-module/components/header/index.mjs.map +1 -7
  92. package/build-module/components/inserter/index.mjs +33 -53
  93. package/build-module/components/inserter/index.mjs.map +1 -7
  94. package/build-module/components/inserter/use-inserter.mjs +17 -34
  95. package/build-module/components/inserter/use-inserter.mjs.map +1 -7
  96. package/build-module/components/keyboard-shortcut-help-modal/config.mjs +83 -61
  97. package/build-module/components/keyboard-shortcut-help-modal/config.mjs.map +1 -7
  98. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs +19 -33
  99. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs.map +1 -7
  100. package/build-module/components/keyboard-shortcut-help-modal/index.mjs +75 -139
  101. package/build-module/components/keyboard-shortcut-help-modal/index.mjs.map +1 -7
  102. package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs +31 -55
  103. package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs.map +1 -7
  104. package/build-module/components/keyboard-shortcuts/index.mjs +62 -79
  105. package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -7
  106. package/build-module/components/more-menu/index.mjs +76 -128
  107. package/build-module/components/more-menu/index.mjs.map +1 -7
  108. package/build-module/components/sidebar-block-editor/index.mjs +86 -128
  109. package/build-module/components/sidebar-block-editor/index.mjs.map +1 -7
  110. package/build-module/components/sidebar-block-editor/sidebar-adapter.mjs +202 -250
  111. package/build-module/components/sidebar-block-editor/sidebar-adapter.mjs.map +1 -7
  112. package/build-module/components/sidebar-block-editor/sidebar-editor-provider.mjs +17 -25
  113. package/build-module/components/sidebar-block-editor/sidebar-editor-provider.mjs.map +1 -7
  114. package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.mjs +54 -86
  115. package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.mjs.map +1 -7
  116. package/build-module/components/sidebar-controls/index.mjs +19 -27
  117. package/build-module/components/sidebar-controls/index.mjs.map +1 -7
  118. package/build-module/components/welcome-guide/index.mjs +62 -71
  119. package/build-module/components/welcome-guide/index.mjs.map +1 -7
  120. package/build-module/controls/inserter-outer-section.mjs +61 -88
  121. package/build-module/controls/inserter-outer-section.mjs.map +1 -7
  122. package/build-module/controls/inspector-section.mjs +52 -70
  123. package/build-module/controls/inspector-section.mjs.map +1 -7
  124. package/build-module/controls/sidebar-control.mjs +33 -45
  125. package/build-module/controls/sidebar-control.mjs.map +1 -7
  126. package/build-module/controls/sidebar-section.mjs +59 -80
  127. package/build-module/controls/sidebar-section.mjs.map +1 -7
  128. package/build-module/filters/index.mjs +0 -2
  129. package/build-module/filters/move-to-sidebar.mjs +52 -79
  130. package/build-module/filters/move-to-sidebar.mjs.map +1 -7
  131. package/build-module/filters/replace-media-upload.mjs +5 -8
  132. package/build-module/filters/replace-media-upload.mjs.map +1 -7
  133. package/build-module/filters/wide-widget-display.mjs +13 -18
  134. package/build-module/filters/wide-widget-display.mjs.map +1 -7
  135. package/build-module/index.mjs +53 -71
  136. package/build-module/index.mjs.map +1 -7
  137. package/build-module/lock-unlock.mjs +5 -10
  138. package/build-module/lock-unlock.mjs.map +1 -7
  139. package/build-module/store/actions.mjs +44 -8
  140. package/build-module/store/actions.mjs.map +1 -7
  141. package/build-module/store/constants.mjs +7 -5
  142. package/build-module/store/constants.mjs.map +1 -7
  143. package/build-module/store/index.mjs +15 -11
  144. package/build-module/store/index.mjs.map +1 -7
  145. package/build-module/store/reducer.mjs +15 -13
  146. package/build-module/store/reducer.mjs.map +1 -7
  147. package/build-module/store/selectors.mjs +41 -13
  148. package/build-module/store/selectors.mjs.map +1 -7
  149. package/build-module/utils.mjs +74 -82
  150. package/build-module/utils.mjs.map +1 -7
  151. package/package.json +27 -27
  152. package/src/components/customize-widgets/index.jsx +2 -2
  153. package/src/components/welcome-guide/index.jsx +6 -2
  154. package/build/filters/index.cjs.map +0 -7
  155. package/build-module/filters/index.mjs.map +0 -7
@@ -1,93 +1,61 @@
1
- // packages/customize-widgets/src/components/sidebar-block-editor/use-sidebar-block-editor.js
2
1
  import fastDeepEqual from "fast-deep-equal/es6/index.js";
3
- import { useState, useEffect, useCallback } from "@wordpress/element";
2
+ import { useCallback, useEffect, useState } from "@wordpress/element";
4
3
  import { isShallowEqual } from "@wordpress/is-shallow-equal";
5
- import { getWidgetIdFromBlock, addWidgetIdToBlock } from "@wordpress/widgets";
4
+ import { addWidgetIdToBlock, getWidgetIdFromBlock } from "@wordpress/widgets";
6
5
  import { blockToWidget, widgetToBlock } from "../../utils.mjs";
6
+ // packages/customize-widgets/src/components/sidebar-block-editor/use-sidebar-block-editor.js
7
7
  function widgetsToBlocks(widgets) {
8
- return widgets.map((widget) => widgetToBlock(widget));
8
+ return widgets.map((widget) => widgetToBlock(widget));
9
9
  }
10
10
  function useSidebarBlockEditor(sidebar) {
11
- const [blocks, setBlocks] = useState(
12
- () => widgetsToBlocks(sidebar.getWidgets())
13
- );
14
- useEffect(() => {
15
- return sidebar.subscribe((prevWidgets, nextWidgets) => {
16
- setBlocks((prevBlocks) => {
17
- const prevWidgetsMap = new Map(
18
- prevWidgets.map((widget) => [widget.id, widget])
19
- );
20
- const prevBlocksMap = new Map(
21
- prevBlocks.map((block) => [
22
- getWidgetIdFromBlock(block),
23
- block
24
- ])
25
- );
26
- const nextBlocks = nextWidgets.map((nextWidget) => {
27
- const prevWidget = prevWidgetsMap.get(nextWidget.id);
28
- if (prevWidget && prevWidget === nextWidget) {
29
- return prevBlocksMap.get(nextWidget.id);
30
- }
31
- return widgetToBlock(nextWidget);
32
- });
33
- if (isShallowEqual(prevBlocks, nextBlocks)) {
34
- return prevBlocks;
35
- }
36
- return nextBlocks;
37
- });
38
- });
39
- }, [sidebar]);
40
- const onChangeBlocks = useCallback(
41
- (nextBlocks) => {
42
- setBlocks((prevBlocks) => {
43
- if (isShallowEqual(prevBlocks, nextBlocks)) {
44
- return prevBlocks;
45
- }
46
- const prevBlocksMap = new Map(
47
- prevBlocks.map((block) => [
48
- getWidgetIdFromBlock(block),
49
- block
50
- ])
51
- );
52
- const nextWidgets = nextBlocks.map((nextBlock) => {
53
- const widgetId = getWidgetIdFromBlock(nextBlock);
54
- if (widgetId && prevBlocksMap.has(widgetId)) {
55
- const prevBlock = prevBlocksMap.get(widgetId);
56
- const prevWidget = sidebar.getWidget(widgetId);
57
- if (fastDeepEqual(nextBlock, prevBlock) && prevWidget) {
58
- return prevWidget;
59
- }
60
- return blockToWidget(nextBlock, prevWidget);
61
- }
62
- return blockToWidget(nextBlock);
63
- });
64
- if (isShallowEqual(sidebar.getWidgets(), nextWidgets)) {
65
- return prevBlocks;
66
- }
67
- const addedWidgetIds = sidebar.setWidgets(nextWidgets);
68
- return nextBlocks.reduce(
69
- (updatedNextBlocks, nextBlock, index) => {
70
- const addedWidgetId = addedWidgetIds[index];
71
- if (addedWidgetId !== null) {
72
- if (updatedNextBlocks === nextBlocks) {
73
- updatedNextBlocks = nextBlocks.slice();
74
- }
75
- updatedNextBlocks[index] = addWidgetIdToBlock(
76
- nextBlock,
77
- addedWidgetId
78
- );
79
- }
80
- return updatedNextBlocks;
81
- },
82
- nextBlocks
83
- );
84
- });
85
- },
86
- [sidebar]
87
- );
88
- return [blocks, onChangeBlocks, onChangeBlocks];
11
+ const [blocks, setBlocks] = useState(() => widgetsToBlocks(sidebar.getWidgets()));
12
+ useEffect(() => {
13
+ return sidebar.subscribe((prevWidgets, nextWidgets) => {
14
+ setBlocks((prevBlocks) => {
15
+ const prevWidgetsMap = new Map(prevWidgets.map((widget) => [widget.id, widget]));
16
+ const prevBlocksMap = new Map(prevBlocks.map((block) => [getWidgetIdFromBlock(block), block]));
17
+ const nextBlocks = nextWidgets.map((nextWidget) => {
18
+ const prevWidget = prevWidgetsMap.get(nextWidget.id);
19
+ if (prevWidget && prevWidget === nextWidget) return prevBlocksMap.get(nextWidget.id);
20
+ return widgetToBlock(nextWidget);
21
+ });
22
+ if (isShallowEqual(prevBlocks, nextBlocks)) return prevBlocks;
23
+ return nextBlocks;
24
+ });
25
+ });
26
+ }, [sidebar]);
27
+ const onChangeBlocks = useCallback((nextBlocks) => {
28
+ setBlocks((prevBlocks) => {
29
+ if (isShallowEqual(prevBlocks, nextBlocks)) return prevBlocks;
30
+ const prevBlocksMap = new Map(prevBlocks.map((block) => [getWidgetIdFromBlock(block), block]));
31
+ const nextWidgets = nextBlocks.map((nextBlock) => {
32
+ const widgetId = getWidgetIdFromBlock(nextBlock);
33
+ if (widgetId && prevBlocksMap.has(widgetId)) {
34
+ const prevBlock = prevBlocksMap.get(widgetId);
35
+ const prevWidget = sidebar.getWidget(widgetId);
36
+ if (fastDeepEqual(nextBlock, prevBlock) && prevWidget) return prevWidget;
37
+ return blockToWidget(nextBlock, prevWidget);
38
+ }
39
+ return blockToWidget(nextBlock);
40
+ });
41
+ if (isShallowEqual(sidebar.getWidgets(), nextWidgets)) return prevBlocks;
42
+ const addedWidgetIds = sidebar.setWidgets(nextWidgets);
43
+ return nextBlocks.reduce((updatedNextBlocks, nextBlock, index) => {
44
+ const addedWidgetId = addedWidgetIds[index];
45
+ if (addedWidgetId !== null) {
46
+ if (updatedNextBlocks === nextBlocks) updatedNextBlocks = nextBlocks.slice();
47
+ updatedNextBlocks[index] = addWidgetIdToBlock(nextBlock, addedWidgetId);
48
+ }
49
+ return updatedNextBlocks;
50
+ }, nextBlocks);
51
+ });
52
+ }, [sidebar]);
53
+ return [
54
+ blocks,
55
+ onChangeBlocks,
56
+ onChangeBlocks
57
+ ];
89
58
  }
90
- export {
91
- useSidebarBlockEditor as default
92
- };
93
- //# sourceMappingURL=use-sidebar-block-editor.mjs.map
59
+ export { useSidebarBlockEditor as default };
60
+
61
+ //# sourceMappingURL=use-sidebar-block-editor.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/sidebar-block-editor/use-sidebar-block-editor.js"],
4
- "sourcesContent": ["import fastDeepEqual from 'fast-deep-equal/es6/index.js';\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport { isShallowEqual } from '@wordpress/is-shallow-equal';\nimport { getWidgetIdFromBlock, addWidgetIdToBlock } from '@wordpress/widgets';\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": ";AAAA,OAAO,mBAAmB;AAC1B,SAAS,UAA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A,UACD,CAAE;AAAA,QACH;AAEA,cAAM,cAAc,WAAW,IAAK,CAAE,cAAe;AACpD,gBAAM,WAAW,qBAAsB,SAAU;AAGjD,cAAK,YAAY,cAAc,IAAK,QAAS,GAAI;AAChD,kBAAM,YAAY,cAAc,IAAK,QAAS;AAC9C,kBAAM,aAAa,QAAQ,UAAW,QAAS;AAI/C,gBACC,cAAe,WAAW,SAAU,KACpC,YACC;AACD,qBAAO;AAAA,YACR;AAEA,mBAAO,cAAe,WAAW,UAAW;AAAA,UAC7C;AAGA,iBAAO,cAAe,SAAU;AAAA,QACjC,CAAE;AAGF,YAAK,eAAgB,QAAQ,WAAW,GAAG,WAAY,GAAI;AAC1D,iBAAO;AAAA,QACR;AAEA,cAAM,iBAAiB,QAAQ,WAAY,WAAY;AAEvD,eAAO,WAAW;AAAA,UACjB,CAAE,mBAAmB,WAAW,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
+ {"version":3,"file":"use-sidebar-block-editor.mjs","names":[],"sources":["../../../src/components/sidebar-block-editor/use-sidebar-block-editor.js"],"sourcesContent":["import fastDeepEqual from 'fast-deep-equal/es6/index.js';\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport { isShallowEqual } from '@wordpress/is-shallow-equal';\nimport { getWidgetIdFromBlock, addWidgetIdToBlock } from '@wordpress/widgets';\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 ] = addWidgetIdTo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W,KAAO,cAAe;IACpD,MAAM,WAAW,qBAAsB,SAAU;IAGjD,IAAK,YAAY,cAAc,IAAK,QAAS,GAAI;KAChD,MAAM,YAAY,cAAc,IAAK,QAAS;KAC9C,MAAM,aAAa,QAAQ,UAAW,QAAS;KAI/C,IACC,cAAe,WAAW,SAAU,KACpC,YAEA,OAAO;KAGR,OAAO,cAAe,WAAW,UAAW;IAC7C;IAGA,OAAO,cAAe,SAAU;GACjC,CAAE;GAGF,IAAK,eAAgB,QAAQ,WAAW,GAAG,WAAY,GACtD,OAAO;GAGR,MAAM,iBAAiB,QAAQ,WAAY,WAAY;GAEvD,OAAO,WAAW,QACf,mBAAmB,WAAW,UAAW;IAC1C,MAAM,gBAAgB,eAAgB;IAEtC,IAAK,kBAAkB,MAAO;KAG7B,IAAK,sBAAsB,YAC1B,oBAAoB,WAAW,MAAM;KAGtC,kBAAmB,SAAU,mBAC5B,WACA,aACD;IACD;IAEA,OAAO;GACR,GACA,UACD;EACD,CAAE;CACH,GACA,CAAE,OAAQ,CACX;CAEA,OAAO;EAAE;EAAQ;EAAgB;CAAe;AACjD"}
@@ -1,34 +1,26 @@
1
- // packages/customize-widgets/src/components/sidebar-controls/index.jsx
2
- import { createContext, useMemo, useContext } from "@wordpress/element";
1
+ import { createContext, useContext, useMemo } from "@wordpress/element";
3
2
  import { jsx } from "react/jsx-runtime";
4
- var SidebarControlsContext = createContext();
3
+ // packages/customize-widgets/src/components/sidebar-controls/index.jsx
4
+ const SidebarControlsContext = createContext();
5
5
  SidebarControlsContext.displayName = "SidebarControlsContext";
6
- function SidebarControls({
7
- sidebarControls,
8
- activeSidebarControl,
9
- children
10
- }) {
11
- const context = useMemo(
12
- () => ({
13
- sidebarControls,
14
- activeSidebarControl
15
- }),
16
- [sidebarControls, activeSidebarControl]
17
- );
18
- return /* @__PURE__ */ jsx(SidebarControlsContext.Provider, { value: context, children });
6
+ function SidebarControls({ sidebarControls, activeSidebarControl, children }) {
7
+ const context = useMemo(() => ({
8
+ sidebarControls,
9
+ activeSidebarControl
10
+ }), [sidebarControls, activeSidebarControl]);
11
+ return /* @__PURE__ */ jsx(SidebarControlsContext.Provider, {
12
+ value: context,
13
+ children
14
+ });
19
15
  }
20
16
  function useSidebarControls() {
21
- const { sidebarControls } = useContext(SidebarControlsContext);
22
- return sidebarControls;
17
+ const { sidebarControls } = useContext(SidebarControlsContext);
18
+ return sidebarControls;
23
19
  }
24
20
  function useActiveSidebarControl() {
25
- const { activeSidebarControl } = useContext(SidebarControlsContext);
26
- return activeSidebarControl;
21
+ const { activeSidebarControl } = useContext(SidebarControlsContext);
22
+ return activeSidebarControl;
27
23
  }
28
- export {
29
- SidebarControlsContext,
30
- SidebarControls as default,
31
- useActiveSidebarControl,
32
- useSidebarControls
33
- };
34
- //# sourceMappingURL=index.mjs.map
24
+ export { SidebarControlsContext, SidebarControls as default, useActiveSidebarControl, useSidebarControls };
25
+
26
+ //# sourceMappingURL=index.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/sidebar-controls/index.jsx"],
4
- "sourcesContent": ["import { 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": ";AAAA,SAAS,eAAe,SAAS,kBAAkB;AAmBjD;AAjBK,IAAM,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
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/components/sidebar-controls/index.jsx"],"sourcesContent":["import { 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":";;;AAEA,MAAa,yBAAyB,cAAc;AACpD,uBAAuB,cAAc;AAErC,SAAwB,gBAAiB,EACxC,iBACA,sBACA,YACG;CACH,MAAM,UAAU,eACP;EACP;EACA;CACD,IACA,CAAE,iBAAiB,oBAAqB,CACzC;CAEA,OACC,oBAAC,uBAAuB,UAAxB;EAAiC,OAAQ;EACtC;CAC8B,CAAA;AAEnC;AAEA,SAAgB,qBAAqB;CACpC,MAAM,EAAE,oBAAoB,WAAY,sBAAuB;CAE/D,OAAO;AACR;AAEA,SAAgB,0BAA0B;CACzC,MAAM,EAAE,yBAAyB,WAAY,sBAAuB;CAEpE,OAAO;AACR"}
@@ -1,77 +1,68 @@
1
- // packages/customize-widgets/src/components/welcome-guide/index.jsx
2
1
  import { __ } from "@wordpress/i18n";
3
2
  import { Button, ExternalLink } from "@wordpress/components";
4
3
  import { useDispatch } from "@wordpress/data";
5
- import { store as preferencesStore } from "@wordpress/preferences";
4
+ import { store } from "@wordpress/preferences";
6
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
+ // packages/customize-widgets/src/components/welcome-guide/index.jsx
7
7
  function WelcomeGuide({ sidebar }) {
8
- const { toggle } = useDispatch(preferencesStore);
9
- const isEntirelyBlockWidgets = sidebar.getWidgets().every((widget) => widget.id.startsWith("block-"));
10
- return /* @__PURE__ */ jsxs("div", { className: "customize-widgets-welcome-guide", children: [
11
- /* @__PURE__ */ jsx("div", { className: "customize-widgets-welcome-guide__image__wrapper", children: /* @__PURE__ */ jsxs("picture", { children: [
12
- /* @__PURE__ */ jsx(
13
- "source",
14
- {
15
- srcSet: "https://s.w.org/images/block-editor/welcome-editor.svg",
16
- media: "(prefers-reduced-motion: reduce)"
17
- }
18
- ),
19
- /* @__PURE__ */ jsx(
20
- "img",
21
- {
22
- className: "customize-widgets-welcome-guide__image",
23
- src: "https://s.w.org/images/block-editor/welcome-editor.gif",
24
- width: "312",
25
- height: "240",
26
- alt: ""
27
- }
28
- )
29
- ] }) }),
30
- /* @__PURE__ */ jsx("h1", { className: "customize-widgets-welcome-guide__heading", children: __("Welcome to block Widgets") }),
31
- /* @__PURE__ */ jsx("p", { className: "customize-widgets-welcome-guide__text", children: isEntirelyBlockWidgets ? __(
32
- "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."
33
- ) : __(
34
- "You can now add any block to your site’s widget areas. Don’t worry, all of your favorite widgets still work flawlessly."
35
- ) }),
36
- /* @__PURE__ */ jsx(
37
- Button,
38
- {
39
- size: "compact",
40
- variant: "primary",
41
- onClick: () => toggle("core/customize-widgets", "welcomeGuide"),
42
- children: __("Got it")
43
- }
44
- ),
45
- /* @__PURE__ */ jsx("hr", { className: "customize-widgets-welcome-guide__separator" }),
46
- !isEntirelyBlockWidgets && /* @__PURE__ */ jsxs("p", { className: "customize-widgets-welcome-guide__more-info", children: [
47
- __("Want to stick with the old widgets?"),
48
- /* @__PURE__ */ jsx("br", {}),
49
- /* @__PURE__ */ jsx(
50
- ExternalLink,
51
- {
52
- href: __(
53
- "https://wordpress.org/plugins/classic-widgets/"
54
- ),
55
- children: __("Get the Classic Widgets plugin.")
56
- }
57
- )
58
- ] }),
59
- /* @__PURE__ */ jsxs("p", { className: "customize-widgets-welcome-guide__more-info", children: [
60
- __("New to the block editor?"),
61
- /* @__PURE__ */ jsx("br", {}),
62
- /* @__PURE__ */ jsx(
63
- ExternalLink,
64
- {
65
- href: __(
66
- "https://wordpress.org/documentation/article/wordpress-block-editor/"
67
- ),
68
- children: __("Here's a detailed guide.")
69
- }
70
- )
71
- ] })
72
- ] });
8
+ const { set: setPreference } = useDispatch(store);
9
+ const isEntirelyBlockWidgets = sidebar.getWidgets().every((widget) => widget.id.startsWith("block-"));
10
+ return /* @__PURE__ */ jsxs("div", {
11
+ className: "customize-widgets-welcome-guide",
12
+ children: [
13
+ /* @__PURE__ */ jsx("div", {
14
+ className: "customize-widgets-welcome-guide__image__wrapper",
15
+ children: /* @__PURE__ */ jsxs("picture", { children: [/* @__PURE__ */ jsx("source", {
16
+ srcSet: "https://s.w.org/images/block-editor/welcome-editor.svg",
17
+ media: "(prefers-reduced-motion: reduce)"
18
+ }), /* @__PURE__ */ jsx("img", {
19
+ className: "customize-widgets-welcome-guide__image",
20
+ src: "https://s.w.org/images/block-editor/welcome-editor.gif",
21
+ width: "312",
22
+ height: "240",
23
+ alt: ""
24
+ })] })
25
+ }),
26
+ /* @__PURE__ */ jsx("h1", {
27
+ className: "customize-widgets-welcome-guide__heading",
28
+ children: __("Welcome to block Widgets")
29
+ }),
30
+ /* @__PURE__ */ jsx("p", {
31
+ className: "customize-widgets-welcome-guide__text",
32
+ children: isEntirelyBlockWidgets ? __("Your theme provides different “block” 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’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.")
33
+ }),
34
+ /* @__PURE__ */ jsx(Button, {
35
+ size: "compact",
36
+ variant: "primary",
37
+ onClick: () => setPreference("core/customize-widgets", "welcomeGuide", false),
38
+ children: __("Got it")
39
+ }),
40
+ /* @__PURE__ */ jsx("hr", { className: "customize-widgets-welcome-guide__separator" }),
41
+ !isEntirelyBlockWidgets && /* @__PURE__ */ jsxs("p", {
42
+ className: "customize-widgets-welcome-guide__more-info",
43
+ children: [
44
+ __("Want to stick with the old widgets?"),
45
+ /* @__PURE__ */ jsx("br", {}),
46
+ /* @__PURE__ */ jsx(ExternalLink, {
47
+ href: __("https://wordpress.org/plugins/classic-widgets/"),
48
+ children: __("Get the Classic Widgets plugin.")
49
+ })
50
+ ]
51
+ }),
52
+ /* @__PURE__ */ jsxs("p", {
53
+ className: "customize-widgets-welcome-guide__more-info",
54
+ children: [
55
+ __("New to the block editor?"),
56
+ /* @__PURE__ */ jsx("br", {}),
57
+ /* @__PURE__ */ jsx(ExternalLink, {
58
+ href: __("https://wordpress.org/documentation/article/wordpress-block-editor/"),
59
+ children: __("Here's a detailed guide.")
60
+ })
61
+ ]
62
+ })
63
+ ]
64
+ });
73
65
  }
74
- export {
75
- WelcomeGuide as default
76
- };
77
- //# sourceMappingURL=index.mjs.map
66
+ export { WelcomeGuide as default };
67
+
68
+ //# sourceMappingURL=index.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/welcome-guide/index.jsx"],
4
- "sourcesContent": ["import { __ } 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\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\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": ";AAAA,SAAS,UAAU;AACnB,SAAS,QAAQ,oBAAoB;AACrC,SAAS,mBAAmB;AAC5B,SAAS,SAAS,wBAAwB;AAYtC,SACC,KADD;AAVW,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,IACD,IACC;AAAA,MACA;AAAA,IACD,GACH;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
+ {"version":3,"file":"index.mjs","names":["preferencesStore"],"sources":["../../../src/components/welcome-guide/index.jsx"],"sourcesContent":["import { __ } 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 { set: setPreference } = 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\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\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\tsetPreference(\n\t\t\t\t\t\t'core/customize-widgets',\n\t\t\t\t\t\t'welcomeGuide',\n\t\t\t\t\t\tfalse\n\t\t\t\t\t)\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"],"mappings":";;;;;;AAKA,SAAwB,aAAc,EAAE,WAAY;CACnD,MAAM,EAAE,KAAK,kBAAkB,YAAaA,KAAiB;CAE7D,MAAM,yBAAyB,QAC7B,WAAW,CAAC,CACZ,OAAS,WAAY,OAAO,GAAG,WAAY,QAAS,CAAE;CAExD,OACC,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACC,oBAAC,OAAD;IAAK,WAAU;IACd,UAAA,qBAAC,WAAD,EAAA,UAAA,CACC,oBAAC,UAAD;KACC,QAAO;KACP,OAAM;IACN,CAAA,GACD,oBAAC,OAAD;KACC,WAAU;KACV,KAAI;KACJ,OAAM;KACN,QAAO;KACP,KAAI;IACJ,CAAA,CACO,EAAA,CAAA;GACL,CAAA;GACL,oBAAC,MAAD;IAAI,WAAU;IACX,UAAA,GAAI,0BAA2B;GAC9B,CAAA;GACJ,oBAAC,KAAD;IAAG,WAAU;IACV,UAAA,yBACC,GACA,6LACD,IACC,GACA,yHACD;GACA,CAAA;GACH,oBAAC,QAAD;IACC,MAAK;IACL,SAAQ;IACR,eACC,cACC,0BACA,gBACA,KACD;IAGC,UAAA,GAAI,QAAS;GACR,CAAA;GACR,oBAAC,MAAD,EAAI,WAAU,6CAA8C,CAAA;GAC1D,CAAE,0BACH,qBAAC,KAAD;IAAG,WAAU;IAAb,UAAA;KACG,GAAI,qCAAsC;KAC5C,oBAAC,MAAD,CAAK,CAAA;KACL,oBAAC,cAAD;MACC,MAAO,GACN,gDACD;MAEE,UAAA,GAAI,iCAAkC;KAC3B,CAAA;IACZ;;GAEJ,qBAAC,KAAD;IAAG,WAAU;IAAb,UAAA;KACG,GAAI,0BAA2B;KACjC,oBAAC,MAAD,CAAK,CAAA;KACL,oBAAC,cAAD;MACC,MAAO,GACN,qEACD;MAEE,UAAA,GAAI,0BAA2B;KACpB,CAAA;IACZ;;EACC;;AAEP"}
@@ -1,93 +1,66 @@
1
- // packages/customize-widgets/src/controls/inserter-outer-section.js
2
1
  import { ESCAPE } from "@wordpress/keycodes";
3
2
  import { focus } from "@wordpress/dom";
4
3
  import { dispatch } from "@wordpress/data";
5
- import { store as customizeWidgetsStore } from "../store/index.mjs";
4
+ import { store } from "../store/index.mjs";
5
+ // packages/customize-widgets/src/controls/inserter-outer-section.js
6
6
  function getInserterOuterSection() {
7
- const {
8
- wp: { customize }
9
- } = window;
10
- const OuterSection = customize.OuterSection;
11
- customize.OuterSection = class extends OuterSection {
12
- onChangeExpanded(expanded, args) {
13
- if (expanded) {
14
- customize.section.each((section) => {
15
- if (section.params.type === "outer" && section.id !== this.id) {
16
- if (section.expanded()) {
17
- section.collapse();
18
- }
19
- }
20
- });
21
- }
22
- return super.onChangeExpanded(expanded, args);
23
- }
24
- };
25
- customize.sectionConstructor.outer = customize.OuterSection;
26
- return class InserterOuterSection extends customize.OuterSection {
27
- constructor(...args) {
28
- super(...args);
29
- this.params.type = "outer";
30
- this.activeElementBeforeExpanded = null;
31
- const ownerWindow = this.contentContainer[0].ownerDocument.defaultView;
32
- ownerWindow.addEventListener(
33
- "keydown",
34
- (event) => {
35
- if (this.expanded() && (event.keyCode === ESCAPE || event.code === "Escape") && !event.defaultPrevented) {
36
- event.preventDefault();
37
- event.stopPropagation();
38
- dispatch(customizeWidgetsStore).setIsInserterOpened(
39
- false
40
- );
41
- }
42
- },
43
- // Use capture mode to make this run before other event listeners.
44
- true
45
- );
46
- this.contentContainer.addClass("widgets-inserter");
47
- this.isFromInternalAction = false;
48
- this.expanded.bind(() => {
49
- if (!this.isFromInternalAction) {
50
- dispatch(customizeWidgetsStore).setIsInserterOpened(
51
- this.expanded()
52
- );
53
- }
54
- this.isFromInternalAction = false;
55
- });
56
- }
57
- open() {
58
- if (!this.expanded()) {
59
- const contentContainer = this.contentContainer[0];
60
- this.activeElementBeforeExpanded = contentContainer.ownerDocument.activeElement;
61
- this.isFromInternalAction = true;
62
- this.expand({
63
- completeCallback() {
64
- const searchBox = focus.tabbable.find(contentContainer)[1];
65
- if (searchBox) {
66
- searchBox.focus();
67
- }
68
- }
69
- });
70
- }
71
- }
72
- close() {
73
- if (this.expanded()) {
74
- const contentContainer = this.contentContainer[0];
75
- const activeElement = contentContainer.ownerDocument.activeElement;
76
- this.isFromInternalAction = true;
77
- this.collapse({
78
- completeCallback() {
79
- if (contentContainer.contains(activeElement)) {
80
- if (this.activeElementBeforeExpanded) {
81
- this.activeElementBeforeExpanded.focus();
82
- }
83
- }
84
- }
85
- });
86
- }
87
- }
88
- };
7
+ const { wp: { customize } } = window;
8
+ const OuterSection = customize.OuterSection;
9
+ customize.OuterSection = class extends OuterSection {
10
+ onChangeExpanded(expanded, args) {
11
+ if (expanded) customize.section.each((section) => {
12
+ if (section.params.type === "outer" && section.id !== this.id) {
13
+ if (section.expanded()) section.collapse();
14
+ }
15
+ });
16
+ return super.onChangeExpanded(expanded, args);
17
+ }
18
+ };
19
+ customize.sectionConstructor.outer = customize.OuterSection;
20
+ return class InserterOuterSection extends customize.OuterSection {
21
+ constructor(...args) {
22
+ super(...args);
23
+ this.params.type = "outer";
24
+ this.activeElementBeforeExpanded = null;
25
+ this.contentContainer[0].ownerDocument.defaultView.addEventListener("keydown", (event) => {
26
+ if (this.expanded() && (event.keyCode === ESCAPE || event.code === "Escape") && !event.defaultPrevented) {
27
+ event.preventDefault();
28
+ event.stopPropagation();
29
+ dispatch(store).setIsInserterOpened(false);
30
+ }
31
+ }, true);
32
+ this.contentContainer.addClass("widgets-inserter");
33
+ this.isFromInternalAction = false;
34
+ this.expanded.bind(() => {
35
+ if (!this.isFromInternalAction) dispatch(store).setIsInserterOpened(this.expanded());
36
+ this.isFromInternalAction = false;
37
+ });
38
+ }
39
+ open() {
40
+ if (!this.expanded()) {
41
+ const contentContainer = this.contentContainer[0];
42
+ this.activeElementBeforeExpanded = contentContainer.ownerDocument.activeElement;
43
+ this.isFromInternalAction = true;
44
+ this.expand({ completeCallback() {
45
+ const searchBox = focus.tabbable.find(contentContainer)[1];
46
+ if (searchBox) searchBox.focus();
47
+ } });
48
+ }
49
+ }
50
+ close() {
51
+ if (this.expanded()) {
52
+ const contentContainer = this.contentContainer[0];
53
+ const activeElement = contentContainer.ownerDocument.activeElement;
54
+ this.isFromInternalAction = true;
55
+ this.collapse({ completeCallback() {
56
+ if (contentContainer.contains(activeElement)) {
57
+ if (this.activeElementBeforeExpanded) this.activeElementBeforeExpanded.focus();
58
+ }
59
+ } });
60
+ }
61
+ }
62
+ };
89
63
  }
90
- export {
91
- getInserterOuterSection as default
92
- };
93
- //# sourceMappingURL=inserter-outer-section.mjs.map
64
+ export { getInserterOuterSection as default };
65
+
66
+ //# sourceMappingURL=inserter-outer-section.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/controls/inserter-outer-section.js"],
4
- "sourcesContent": ["import { ESCAPE } from '@wordpress/keycodes';\nimport { focus } from '@wordpress/dom';\nimport { dispatch } from '@wordpress/data';\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": ";AAAA,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,gBAAgB;AACzB,SAAS,SAAS,6BAA6B;AAEhC,SAAR,0BAA2C;AACjD,QAAM;AAAA,IACL,IAAI,EAAE,UAAU;AAAA,EACjB,IAAI;AAEJ,QAAM,eAAe,UAAU;AAI/B,YAAU,eAAe,cAAc,aAAa;AAAA,IACnD,iBAAkB,UAAU,MAAO;AAClC,UAAK,UAAW;AACf,kBAAU,QAAQ,KAAM,CAAE,YAAa;AACtC,cACC,QAAQ,OAAO,SAAS,WACxB,QAAQ,OAAO,KAAK,IACnB;AACD,gBAAK,QAAQ,SAAS,GAAI;AACzB,sBAAQ,SAAS;AAAA,YAClB;AAA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AAM,mBAAmB,KAAK,iBAAkB,CAAE;AAClD,cAAM,gBACL,iBAAiB,cAAc;AAEhC,aAAK,uBAAuB;AAE5B,aAAK,SAAU;AAAA,UACd,mBAAmB;AAMlB,gBAAK,iBAAiB,SAAU,aAAc,GAAI;AAEjD,kBAAK,KAAK,6BAA8B;AACvC,qBAAK,4BAA4B,MAAM;AAAA,cACxC;AAAA,YACD;AAAA,UACD;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AACD;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"inserter-outer-section.mjs","names":["customizeWidgetsStore"],"sources":["../../src/controls/inserter-outer-section.js"],"sourcesContent":["import { ESCAPE } from '@wordpress/keycodes';\nimport { focus } from '@wordpress/dom';\nimport { dispatch } from '@wordpress/data';\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":";;;;;AAKA,SAAwB,0BAA0B;CACjD,MAAM,EACL,IAAI,EAAE,gBACH;CAEJ,MAAM,eAAe,UAAU;C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