@wordpress/customize-widgets 4.16.0 → 4.17.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 (150) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-appender/index.js +6 -8
  3. package/build/components/block-appender/index.js.map +1 -1
  4. package/build/components/block-inspector-button/index.js +3 -9
  5. package/build/components/block-inspector-button/index.js.map +1 -1
  6. package/build/components/customize-widgets/index.js +4 -12
  7. package/build/components/customize-widgets/index.js.map +1 -1
  8. package/build/components/customize-widgets/use-clear-selected-block.js +12 -15
  9. package/build/components/customize-widgets/use-clear-selected-block.js.map +1 -1
  10. package/build/components/error-boundary/index.js +1 -14
  11. package/build/components/error-boundary/index.js.map +1 -1
  12. package/build/components/focus-control/index.js +1 -12
  13. package/build/components/focus-control/index.js.map +1 -1
  14. package/build/components/focus-control/use-blocks-focus-control.js +3 -9
  15. package/build/components/focus-control/use-blocks-focus-control.js.map +1 -1
  16. package/build/components/header/index.js +7 -18
  17. package/build/components/header/index.js.map +1 -1
  18. package/build/components/inserter/index.js +1 -10
  19. package/build/components/inserter/index.js.map +1 -1
  20. package/build/components/inserter/use-inserter.js +1 -6
  21. package/build/components/inserter/use-inserter.js.map +1 -1
  22. package/build/components/keyboard-shortcut-help-modal/config.js +1 -2
  23. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  24. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +1 -9
  25. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
  26. package/build/components/keyboard-shortcut-help-modal/index.js +4 -20
  27. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  28. package/build/components/keyboard-shortcut-help-modal/shortcut.js +1 -6
  29. package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
  30. package/build/components/keyboard-shortcuts/index.js +1 -16
  31. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  32. package/build/components/more-menu/index.js +2 -15
  33. package/build/components/more-menu/index.js.map +1 -1
  34. package/build/components/sidebar-block-editor/index.js +5 -22
  35. package/build/components/sidebar-block-editor/index.js.map +1 -1
  36. package/build/components/sidebar-block-editor/sidebar-adapter.js +13 -75
  37. package/build/components/sidebar-block-editor/sidebar-adapter.js.map +1 -1
  38. package/build/components/sidebar-block-editor/sidebar-editor-provider.js +1 -8
  39. package/build/components/sidebar-block-editor/sidebar-editor-provider.js.map +1 -1
  40. package/build/components/sidebar-block-editor/use-sidebar-block-editor.js +14 -24
  41. package/build/components/sidebar-block-editor/use-sidebar-block-editor.js.map +1 -1
  42. package/build/components/sidebar-controls/index.js +1 -5
  43. package/build/components/sidebar-controls/index.js.map +1 -1
  44. package/build/components/welcome-guide/index.js +1 -6
  45. package/build/components/welcome-guide/index.js.map +1 -1
  46. package/build/controls/inserter-outer-section.js +15 -24
  47. package/build/controls/inserter-outer-section.js.map +1 -1
  48. package/build/controls/inspector-section.js +0 -12
  49. package/build/controls/inspector-section.js.map +1 -1
  50. package/build/controls/sidebar-control.js +1 -12
  51. package/build/controls/sidebar-control.js.map +1 -1
  52. package/build/controls/sidebar-section.js +3 -14
  53. package/build/controls/sidebar-section.js.map +1 -1
  54. package/build/filters/index.js +0 -2
  55. package/build/filters/index.js.map +1 -1
  56. package/build/filters/move-to-sidebar.js +7 -17
  57. package/build/filters/move-to-sidebar.js.map +1 -1
  58. package/build/filters/replace-media-upload.js +1 -3
  59. package/build/filters/replace-media-upload.js.map +1 -1
  60. package/build/filters/wide-widget-display.js +3 -5
  61. package/build/filters/wide-widget-display.js.map +1 -1
  62. package/build/index.js +5 -20
  63. package/build/index.js.map +1 -1
  64. package/build/lock-unlock.js +1 -2
  65. package/build/lock-unlock.js.map +1 -1
  66. package/build/store/actions.js +0 -1
  67. package/build/store/actions.js.map +1 -1
  68. package/build/store/constants.js +0 -1
  69. package/build/store/constants.js.map +1 -1
  70. package/build/store/index.js +1 -10
  71. package/build/store/index.js.map +1 -1
  72. package/build/store/reducer.js +0 -5
  73. package/build/store/reducer.js.map +1 -1
  74. package/build/store/selectors.js +9 -10
  75. package/build/store/selectors.js.map +1 -1
  76. package/build/utils.js +8 -18
  77. package/build/utils.js.map +1 -1
  78. package/build-module/components/block-appender/index.js +5 -5
  79. package/build-module/components/block-appender/index.js.map +1 -1
  80. package/build-module/components/block-inspector-button/index.js +2 -5
  81. package/build-module/components/block-inspector-button/index.js.map +1 -1
  82. package/build-module/components/customize-widgets/index.js +4 -4
  83. package/build-module/components/customize-widgets/index.js.map +1 -1
  84. package/build-module/components/customize-widgets/use-clear-selected-block.js +13 -12
  85. package/build-module/components/customize-widgets/use-clear-selected-block.js.map +1 -1
  86. package/build-module/components/error-boundary/index.js +0 -8
  87. package/build-module/components/error-boundary/index.js.map +1 -1
  88. package/build-module/components/focus-control/index.js +1 -8
  89. package/build-module/components/focus-control/index.js.map +1 -1
  90. package/build-module/components/focus-control/use-blocks-focus-control.js +3 -4
  91. package/build-module/components/focus-control/use-blocks-focus-control.js.map +1 -1
  92. package/build-module/components/header/index.js +8 -11
  93. package/build-module/components/header/index.js.map +1 -1
  94. package/build-module/components/inserter/index.js +1 -4
  95. package/build-module/components/inserter/index.js.map +1 -1
  96. package/build-module/components/inserter/use-inserter.js +1 -3
  97. package/build-module/components/inserter/use-inserter.js.map +1 -1
  98. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  99. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +1 -6
  100. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
  101. package/build-module/components/keyboard-shortcut-help-modal/index.js +5 -13
  102. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  103. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +0 -5
  104. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
  105. package/build-module/components/keyboard-shortcuts/index.js +0 -9
  106. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  107. package/build-module/components/more-menu/index.js +2 -6
  108. package/build-module/components/more-menu/index.js.map +1 -1
  109. package/build-module/components/sidebar-block-editor/index.js +5 -9
  110. package/build-module/components/sidebar-block-editor/index.js.map +1 -1
  111. package/build-module/components/sidebar-block-editor/sidebar-adapter.js +12 -72
  112. package/build-module/components/sidebar-block-editor/sidebar-adapter.js.map +1 -1
  113. package/build-module/components/sidebar-block-editor/sidebar-editor-provider.js +1 -2
  114. package/build-module/components/sidebar-block-editor/sidebar-editor-provider.js.map +1 -1
  115. package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js +15 -20
  116. package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js.map +1 -1
  117. package/build-module/components/sidebar-controls/index.js +0 -1
  118. package/build-module/components/sidebar-controls/index.js.map +1 -1
  119. package/build-module/components/welcome-guide/index.js +0 -1
  120. package/build-module/components/welcome-guide/index.js.map +1 -1
  121. package/build-module/controls/inserter-outer-section.js +15 -20
  122. package/build-module/controls/inserter-outer-section.js.map +1 -1
  123. package/build-module/controls/inspector-section.js +0 -11
  124. package/build-module/controls/inspector-section.js.map +1 -1
  125. package/build-module/controls/sidebar-control.js +1 -8
  126. package/build-module/controls/sidebar-control.js.map +1 -1
  127. package/build-module/controls/sidebar-section.js +3 -12
  128. package/build-module/controls/sidebar-section.js.map +1 -1
  129. package/build-module/filters/index.js.map +1 -1
  130. package/build-module/filters/move-to-sidebar.js +7 -10
  131. package/build-module/filters/move-to-sidebar.js.map +1 -1
  132. package/build-module/filters/replace-media-upload.js +0 -2
  133. package/build-module/filters/replace-media-upload.js.map +1 -1
  134. package/build-module/filters/wide-widget-display.js +2 -3
  135. package/build-module/filters/wide-widget-display.js.map +1 -1
  136. package/build-module/index.js +5 -10
  137. package/build-module/index.js.map +1 -1
  138. package/build-module/lock-unlock.js.map +1 -1
  139. package/build-module/store/actions.js.map +1 -1
  140. package/build-module/store/constants.js.map +1 -1
  141. package/build-module/store/index.js +3 -3
  142. package/build-module/store/index.js.map +1 -1
  143. package/build-module/store/reducer.js +1 -3
  144. package/build-module/store/reducer.js.map +1 -1
  145. package/build-module/store/selectors.js +10 -9
  146. package/build-module/store/selectors.js.map +1 -1
  147. package/build-module/utils.js +9 -14
  148. package/build-module/utils.js.map +1 -1
  149. package/package.json +22 -22
  150. package/src/store/selectors.js +10 -2
@@ -1,22 +1,15 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = useSidebarBlockEditor;
9
-
10
8
  var _es = _interopRequireDefault(require("fast-deep-equal/es6"));
11
-
12
9
  var _element = require("@wordpress/element");
13
-
14
10
  var _isShallowEqual = _interopRequireDefault(require("@wordpress/is-shallow-equal"));
15
-
16
11
  var _widgets = require("@wordpress/widgets");
17
-
18
12
  var _utils = require("../../utils");
19
-
20
13
  /**
21
14
  * External dependencies
22
15
  */
@@ -28,10 +21,10 @@ var _utils = require("../../utils");
28
21
  /**
29
22
  * Internal dependencies
30
23
  */
24
+
31
25
  function widgetsToBlocks(widgets) {
32
26
  return widgets.map(widget => (0, _utils.widgetToBlock)(widget));
33
27
  }
34
-
35
28
  function useSidebarBlockEditor(sidebar) {
36
29
  const [blocks, setBlocks] = (0, _element.useState)(() => widgetsToBlocks(sidebar.getWidgets()));
37
30
  (0, _element.useEffect)(() => {
@@ -40,19 +33,19 @@ function useSidebarBlockEditor(sidebar) {
40
33
  const prevWidgetsMap = new Map(prevWidgets.map(widget => [widget.id, widget]));
41
34
  const prevBlocksMap = new Map(prevBlocks.map(block => [(0, _widgets.getWidgetIdFromBlock)(block), block]));
42
35
  const nextBlocks = nextWidgets.map(nextWidget => {
43
- const prevWidget = prevWidgetsMap.get(nextWidget.id); // Bail out updates.
36
+ const prevWidget = prevWidgetsMap.get(nextWidget.id);
44
37
 
38
+ // Bail out updates.
45
39
  if (prevWidget && prevWidget === nextWidget) {
46
40
  return prevBlocksMap.get(nextWidget.id);
47
41
  }
48
-
49
42
  return (0, _utils.widgetToBlock)(nextWidget);
50
- }); // Bail out updates.
43
+ });
51
44
 
45
+ // Bail out updates.
52
46
  if ((0, _isShallowEqual.default)(prevBlocks, nextBlocks)) {
53
47
  return prevBlocks;
54
48
  }
55
-
56
49
  return nextBlocks;
57
50
  });
58
51
  });
@@ -62,45 +55,42 @@ function useSidebarBlockEditor(sidebar) {
62
55
  if ((0, _isShallowEqual.default)(prevBlocks, nextBlocks)) {
63
56
  return prevBlocks;
64
57
  }
65
-
66
58
  const prevBlocksMap = new Map(prevBlocks.map(block => [(0, _widgets.getWidgetIdFromBlock)(block), block]));
67
59
  const nextWidgets = nextBlocks.map(nextBlock => {
68
- const widgetId = (0, _widgets.getWidgetIdFromBlock)(nextBlock); // Update existing widgets.
60
+ const widgetId = (0, _widgets.getWidgetIdFromBlock)(nextBlock);
69
61
 
62
+ // Update existing widgets.
70
63
  if (widgetId && prevBlocksMap.has(widgetId)) {
71
64
  const prevBlock = prevBlocksMap.get(widgetId);
72
- const prevWidget = sidebar.getWidget(widgetId); // Bail out updates by returning the previous widgets.
73
- // Deep equality is necessary until the block editor's internals changes.
65
+ const prevWidget = sidebar.getWidget(widgetId);
74
66
 
67
+ // Bail out updates by returning the previous widgets.
68
+ // Deep equality is necessary until the block editor's internals changes.
75
69
  if ((0, _es.default)(nextBlock, prevBlock) && prevWidget) {
76
70
  return prevWidget;
77
71
  }
78
-
79
72
  return (0, _utils.blockToWidget)(nextBlock, prevWidget);
80
- } // Add a new widget.
81
-
73
+ }
82
74
 
75
+ // Add a new widget.
83
76
  return (0, _utils.blockToWidget)(nextBlock);
84
- }); // Bail out updates if the updated widgets are the same.
77
+ });
85
78
 
79
+ // Bail out updates if the updated widgets are the same.
86
80
  if ((0, _isShallowEqual.default)(sidebar.getWidgets(), nextWidgets)) {
87
81
  return prevBlocks;
88
82
  }
89
-
90
83
  const addedWidgetIds = sidebar.setWidgets(nextWidgets);
91
84
  return nextBlocks.reduce((updatedNextBlocks, nextBlock, index) => {
92
85
  const addedWidgetId = addedWidgetIds[index];
93
-
94
86
  if (addedWidgetId !== null) {
95
87
  // Only create a new instance if necessary to prevent
96
88
  // the whole editor from re-rendering on every edit.
97
89
  if (updatedNextBlocks === nextBlocks) {
98
90
  updatedNextBlocks = nextBlocks.slice();
99
91
  }
100
-
101
92
  updatedNextBlocks[index] = (0, _widgets.addWidgetIdToBlock)(nextBlock, addedWidgetId);
102
93
  }
103
-
104
94
  return updatedNextBlocks;
105
95
  }, nextBlocks);
106
96
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/components/sidebar-block-editor/use-sidebar-block-editor.js"],"names":["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"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAGA,SAASA,eAAT,CAA0BC,OAA1B,EAAoC;AACnC,SAAOA,OAAO,CAACC,GAAR,CAAeC,MAAF,IAAc,0BAAeA,MAAf,CAA3B,CAAP;AACA;;AAEc,SAASC,qBAAT,CAAgCC,OAAhC,EAA0C;AACxD,QAAM,CAAEC,MAAF,EAAUC,SAAV,IAAwB,uBAAU,MACvCP,eAAe,CAAEK,OAAO,CAACG,UAAR,EAAF,CADc,CAA9B;AAIA,0BAAW,MAAM;AAChB,WAAOH,OAAO,CAACI,SAAR,CAAmB,CAAEC,WAAF,EAAeC,WAAf,KAAgC;AACzDJ,MAAAA,SAAS,CAAIK,UAAF,IAAkB;AAC5B,cAAMC,cAAc,GAAG,IAAIC,GAAJ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A,cAA1B,CAAP;AACA","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"]}
1
+ {"version":3,"names":["_es","_interopRequireDefault","require","_element","_isShallowEqual","_widgets","_utils","widgetsToBlocks","widgets","map","widget","widgetToBlock","useSidebarBlockEditor","sidebar","blocks","setBlocks","useState","getWidgets","useEffect","subscribe","prevWidgets","nextWidgets","prevBlocks","prevWidgetsMap","Map","id","prevBlocksMap","block","getWidgetIdFromBlock","nextBlocks","nextWidget","prevWidget","get","isShallowEqual","onChangeBlocks","useCallback","nextBlock","widgetId","has","prevBlock","getWidget","fastDeepEqual","blockToWidget","addedWidgetIds","setWidgets","reduce","updatedNextBlocks","index","addedWidgetId","slice","addWidgetIdToBlock"],"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":";;;;;;;AAGA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAGA,SAASK,eAAeA,CAAEC,OAAO,EAAG;EACnC,OAAOA,OAAO,CAACC,GAAG,CAAIC,MAAM,IAAM,IAAAC,oBAAa,EAAED,MAAO,CAAE,CAAC;AAC5D;AAEe,SAASE,qBAAqBA,CAAEC,OAAO,EAAG;EACxD,MAAM,CAAEC,MAAM,EAAEC,SAAS,CAAE,GAAG,IAAAC,iBAAQ,EAAE,MACvCT,eAAe,CAAEM,OAAO,CAACI,UAAU,CAAC,CAAE,CACvC,CAAC;EAED,IAAAC,kBAAS,EAAE,MAAM;IAChB,OAAOL,OAAO,CAACM,SAAS,CAAE,CAAEC,WAAW,EAAEC,WAAW,KAAM;MACzDN,SAAS,CAAIO,UAAU,IAAM;QAC5B,MAAMC,cAAc,GAAG,IAAIC,GAAG,CAC7BJ,WAAW,CAACX,GAAG,CAAIC,MAAM,IAAM,CAAEA,MAAM,CAACe,EAAE,EAAEf,MAAM,CAAG,CACtD,CAAC;QACD,MAAMgB,aAAa,GAAG,IAAIF,GAAG,CA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AACM,GAAG,CAAEK,QAAS,CAAC;UAC/C,MAAMN,UAAU,GAAGlB,OAAO,CAAC2B,SAAS,CAAEH,QAAS,CAAC;;UAEhD;UACA;UACA,IACC,IAAAI,WAAa,EAAEL,SAAS,EAAEG,SAAU,CAAC,IACrCR,UAAU,EACT;YACD,OAAOA,UAAU;UAClB;UAEA,OAAO,IAAAW,oBAAa,EAAEN,SAAS,EAAEL,UAAW,CAAC;QAC9C;;QAEA;QACA,OAAO,IAAAW,oBAAa,EAAEN,SAAU,CAAC;MAClC,CAAE,CAAC;;MAEH;MACA,IAAK,IAAAH,uBAAc,EAAEpB,OAAO,CAACI,UAAU,CAAC,CAAC,EAAEI,WAAY,CAAC,EAAG;QAC1D,OAAOC,UAAU;MAClB;MAEA,MAAMqB,cAAc,GAAG9B,OAAO,CAAC+B,UAAU,CAAEvB,WAAY,CAAC;MAExD,OAAOQ,UAAU,CAACgB,MAAM,CACvB,CAAEC,iBAAiB,EAAEV,SAAS,EAAEW,KAAK,KAAM;QAC1C,MAAMC,aAAa,GAAGL,cAAc,CAAEI,KAAK,CAAE;QAE7C,IAAKC,aAAa,KAAK,IAAI,EAAG;UAC7B;UACA;UACA,IAAKF,iBAAiB,KAAKjB,UAAU,EAAG;YACvCiB,iBAAiB,GAAGjB,UAAU,CAACoB,KAAK,CAAC,CAAC;UACvC;UAEAH,iBAAiB,CAAEC,KAAK,CAAE,GAAG,IAAAG,2BAAkB,EAC9Cd,SAAS,EACTY,aACD,CAAC;QACF;QAEA,OAAOF,iBAAiB;MACzB,CAAC,EACDjB,UACD,CAAC;IACF,CAAE,CAAC;EACJ,CAAC,EACD,CAAEhB,OAAO,CACV,CAAC;EAED,OAAO,CAAEC,MAAM,EAAEoB,cAAc,EAAEA,cAAc,CAAE;AAClD"}
@@ -7,15 +7,13 @@ exports.SidebarControlsContext = void 0;
7
7
  exports.default = SidebarControls;
8
8
  exports.useActiveSidebarControl = useActiveSidebarControl;
9
9
  exports.useSidebarControls = useSidebarControls;
10
-
11
10
  var _element = require("@wordpress/element");
12
-
13
11
  /**
14
12
  * WordPress dependencies
15
13
  */
14
+
16
15
  const SidebarControlsContext = (0, _element.createContext)();
17
16
  exports.SidebarControlsContext = SidebarControlsContext;
18
-
19
17
  function SidebarControls({
20
18
  sidebarControls,
21
19
  activeSidebarControl,
@@ -29,14 +27,12 @@ function SidebarControls({
29
27
  value: context
30
28
  }, children);
31
29
  }
32
-
33
30
  function useSidebarControls() {
34
31
  const {
35
32
  sidebarControls
36
33
  } = (0, _element.useContext)(SidebarControlsContext);
37
34
  return sidebarControls;
38
35
  }
39
-
40
36
  function useActiveSidebarControl() {
41
37
  const {
42
38
  activeSidebarControl
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/components/sidebar-controls/index.js"],"names":["SidebarControlsContext","SidebarControls","sidebarControls","activeSidebarControl","children","context","useSidebarControls","useActiveSidebarControl"],"mappings":";;;;;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAMA,sBAAsB,GAAG,6BAA/B;;;AAEQ,SAASC,eAAT,CAA0B;AACxCC,EAAAA,eADwC;AAExCC,EAAAA,oBAFwC;AAGxCC,EAAAA;AAHwC,CAA1B,EAIX;AACH,QAAMC,OAAO,GAAG,sBACf,OAAQ;AACPH,IAAAA,eADO;AAEPC,IAAAA;AAFO,GAAR,CADe,EAKf,CAAED,eAAF,EAAmBC,oBAAnB,CALe,CAAhB;AAQA,SACC,4BAAC,sBAAD,CAAwB,QAAxB;AAAiC,IAAA,KAAK,EAAGE;AAAzC,KACGD,QADH,CADD;AAKA;;AAEM,SAASE,kBAAT,GAA8B;AACpC,QAAM;AAAEJ,IAAAA;AAAF,MAAsB,yBAAYF,sBAAZ,CAA5B;AAEA,SAAOE,eAAP;AACA;;AAEM,SAASK,uBAAT,GAAmC;AACzC,QAAM;AAAEJ,IAAAA;AAAF,MAA2B,yBAAYH,sBAAZ,CAAjC;AAEA,SAAOG,oBAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useMemo, useContext } from '@wordpress/element';\n\nexport const SidebarControlsContext = createContext();\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"]}
1
+ {"version":3,"names":["_element","require","SidebarControlsContext","createContext","exports","SidebarControls","sidebarControls","activeSidebarControl","children","context","useMemo","createElement","Provider","value","useSidebarControls","useContext","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();\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":";;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAMC,sBAAsB,GAAG,IAAAC,sBAAa,EAAC,CAAC;AAACC,OAAA,CAAAF,sBAAA,GAAAA,sBAAA;AAEvC,SAASG,eAAeA,CAAE;EACxCC,eAAe;EACfC,oBAAoB;EACpBC;AACD,CAAC,EAAG;EACH,MAAMC,OAAO,GAAG,IAAAC,gBAAO,EACtB,OAAQ;IACPJ,eAAe;IACfC;EACD,CAAC,CAAE,EACH,CAAED,eAAe,EAAEC,oBAAoB,CACxC,CAAC;EAED,OACC,IAAAP,QAAA,CAAAW,aAAA,EAACT,sBAAsB,CAACU,QAAQ;IAACC,KAAK,EAAGJ;EAAS,GAC/CD,QAC8B,CAAC;AAEpC;AAEO,SAASM,kBAAkBA,CAAA,EAAG;EACpC,MAAM;IAAER;EAAgB,CAAC,GAAG,IAAAS,mBAAU,EAAEb,sBAAuB,CAAC;EAEhE,OAAOI,eAAe;AACvB;AAEO,SAASU,uBAAuBA,CAAA,EAAG;EACzC,MAAM;IAAET;EAAqB,CAAC,GAAG,IAAAQ,mBAAU,EAAEb,sBAAuB,CAAC;EAErE,OAAOK,oBAAoB;AAC5B"}
@@ -4,20 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = WelcomeGuide;
7
-
8
7
  var _element = require("@wordpress/element");
9
-
10
8
  var _i18n = require("@wordpress/i18n");
11
-
12
9
  var _components = require("@wordpress/components");
13
-
14
10
  var _data = require("@wordpress/data");
15
-
16
11
  var _preferences = require("@wordpress/preferences");
17
-
18
12
  /**
19
13
  * WordPress dependencies
20
14
  */
15
+
21
16
  function WelcomeGuide({
22
17
  sidebar
23
18
  }) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/components/welcome-guide/index.js"],"names":["WelcomeGuide","sidebar","toggle","preferencesStore","isEntirelyBlockWidgets","getWidgets","every","widget","id","startsWith"],"mappings":";;;;;;;;;AAGA;;AACA;;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EAAC;AAAb,KACG,cAAI,0BAAJ,CADH,EAEC,uCAFD,EAGC,4BAAC,wBAAD;AACC,IAAA,IAAI,EAAG,cACN,qEADM;AADR,KAKG,cAAI,0BAAJ,CALH,CAHD,CAnDD,CADD;AAiEA","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\tclassName=\"customize-widgets-welcome-guide__button\"\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"]}
1
+ {"version":3,"names":["_i18n","require","_components","_data","_preferences","WelcomeGuide","sidebar","toggle","useDispatch","preferencesStore","isEntirelyBlockWidgets","getWidgets","every","widget","id","startsWith","_element","createElement","className","srcSet","media","src","width","height","alt","__","Button","variant","onClick","ExternalLink","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\tclassName=\"customize-widgets-welcome-guide__button\"\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"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AANA;AACA;AACA;;AAMe,SAASI,YAAYA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EACnD,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,iBAAW,EAAEC,kBAAiB,CAAC;EAElD,MAAMC,sBAAsB,GAAGJ,OAAO,CACpCK,UAAU,CAAC,CAAC,CACZC,KAAK,CAAIC,MAAM,IAAMA,MAAM,CA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EAACf,WAAA,CAAA2B,YAAY;IACZC,IAAI,EAAG,IAAAL,QAAE,EACR,gDACD;EAAG,GAED,IAAAA,QAAE,EAAE,iCAAkC,CAC3B,CACZ,CACH,EACD,IAAAT,QAAA,CAAAC,aAAA;IAAGC,SAAS,EAAC;EAA4C,GACtD,IAAAO,QAAE,EAAE,0BAA2B,CAAC,EAClC,IAAAT,QAAA,CAAAC,aAAA,YAAK,CAAC,EACN,IAAAD,QAAA,CAAAC,aAAA,EAACf,WAAA,CAAA2B,YAAY;IACZC,IAAI,EAAG,IAAAL,QAAE,EACR,qEACD;EAAG,GAED,IAAAA,QAAE,EAAE,0BAA2B,CACpB,CACZ,CACC,CAAC;AAER"}
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = getInserterOuterSection;
7
-
8
7
  var _keycodes = require("@wordpress/keycodes");
9
-
10
8
  var _dom = require("@wordpress/dom");
11
-
12
9
  var _data = require("@wordpress/data");
13
-
14
10
  var _store = require("../store");
15
-
16
11
  /**
17
12
  * WordPress dependencies
18
13
  */
@@ -20,16 +15,17 @@ var _store = require("../store");
20
15
  /**
21
16
  * Internal dependencies
22
17
  */
18
+
23
19
  function getInserterOuterSection() {
24
20
  const {
25
21
  wp: {
26
22
  customize
27
23
  }
28
24
  } = window;
29
- const OuterSection = customize.OuterSection; // Override the OuterSection class to handle multiple outer sections.
25
+ const OuterSection = customize.OuterSection;
26
+ // Override the OuterSection class to handle multiple outer sections.
30
27
  // It closes all the other outer sections whenever one is opened.
31
28
  // The result is that at most one outer section can be opened at the same time.
32
-
33
29
  customize.OuterSection = class extends OuterSection {
34
30
  onChangeExpanded(expanded, args) {
35
31
  if (expanded) {
@@ -41,44 +37,44 @@ function getInserterOuterSection() {
41
37
  }
42
38
  });
43
39
  }
44
-
45
40
  return super.onChangeExpanded(expanded, args);
46
41
  }
47
-
48
- }; // Handle constructor so that "params.type" can be correctly pointed to "outer".
49
-
42
+ };
43
+ // Handle constructor so that "params.type" can be correctly pointed to "outer".
50
44
  customize.sectionConstructor.outer = customize.OuterSection;
51
45
  return class InserterOuterSection extends customize.OuterSection {
52
46
  constructor(...args) {
53
- super(...args); // This is necessary since we're creating a new class which is not identical to the original OuterSection.
54
- // @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436
47
+ super(...args);
55
48
 
49
+ // This is necessary since we're creating a new class which is not identical to the original OuterSection.
50
+ // @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436
56
51
  this.params.type = 'outer';
57
52
  this.activeElementBeforeExpanded = null;
58
- const ownerWindow = this.contentContainer[0].ownerDocument.defaultView; // Handle closing the inserter when pressing the Escape key.
53
+ const ownerWindow = this.contentContainer[0].ownerDocument.defaultView;
59
54
 
55
+ // Handle closing the inserter when pressing the Escape key.
60
56
  ownerWindow.addEventListener('keydown', event => {
61
57
  if (this.expanded() && (event.keyCode === _keycodes.ESCAPE || event.code === 'Escape') && !event.defaultPrevented) {
62
58
  event.preventDefault();
63
59
  event.stopPropagation();
64
60
  (0, _data.dispatch)(_store.store).setIsInserterOpened(false);
65
61
  }
66
- }, // Use capture mode to make this run before other event listeners.
62
+ },
63
+ // Use capture mode to make this run before other event listeners.
67
64
  true);
68
- this.contentContainer.addClass('widgets-inserter'); // Set a flag if the state is being changed from open() or close().
69
- // Don't propagate the event if it's an internal action to prevent infinite loop.
65
+ this.contentContainer.addClass('widgets-inserter');
70
66
 
67
+ // Set a flag if the state is being changed from open() or close().
68
+ // Don't propagate the event if it's an internal action to prevent infinite loop.
71
69
  this.isFromInternalAction = false;
72
70
  this.expanded.bind(() => {
73
71
  if (!this.isFromInternalAction) {
74
72
  // Propagate the event to React to sync the state.
75
73
  (0, _data.dispatch)(_store.store).setIsInserterOpened(this.expanded());
76
74
  }
77
-
78
75
  this.isFromInternalAction = false;
79
76
  });
80
77
  }
81
-
82
78
  open() {
83
79
  if (!this.expanded()) {
84
80
  const contentContainer = this.contentContainer[0];
@@ -90,16 +86,13 @@ function getInserterOuterSection() {
90
86
  // The first one should be the close button,
91
87
  // we want to skip it and choose the second one instead, which is the search box.
92
88
  const searchBox = _dom.focus.tabbable.find(contentContainer)[1];
93
-
94
89
  if (searchBox) {
95
90
  searchBox.focus();
96
91
  }
97
92
  }
98
-
99
93
  });
100
94
  }
101
95
  }
102
-
103
96
  close() {
104
97
  if (this.expanded()) {
105
98
  const contentContainer = this.contentContainer[0];
@@ -119,11 +112,9 @@ function getInserterOuterSection() {
119
112
  }
120
113
  }
121
114
  }
122
-
123
115
  });
124
116
  }
125
117
  }
126
-
127
118
  };
128
119
  }
129
120
  //# sourceMappingURL=inserter-outer-section.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/controls/inserter-outer-section.js"],"names":["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","ESCAPE","code","defaultPrevented","preventDefault","stopPropagation","customizeWidgetsStore","setIsInserterOpened","addClass","isFromInternalAction","bind","open","activeElement","expand","completeCallback","searchBox","focus","tabbable","find","close","contains"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGe,SAASA,uBAAT,GAAmC;AACjD,QAAM;AACLC,IAAAA,EAAE,EAAE;AAAEC,MAAAA;AAAF;AADC,MAEFC,MAFJ;AAIA,QAAMC,YAAY,GAAGF,SAAS,CAACE,YAA/B,CALiD,CAMjD;AACA;AACA;;AACAF,EAAAA,SAAS,CAACE,YAAV,GAAyB,cAAcA,YAAd,CAA2B;AACnDC,IAAAA,gBAAgB,CAAEC,QAAF,EAAYC,IAAZ,EAAmB;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;;AA/F+D,GAAjE;AAiGA","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"]}
1
+ {"version":3,"names":["_keycodes","require","_dom","_data","_store","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","ESCAPE","code","defaultPrevented","preventDefault","stopPropagation","dispatch","customizeWidgetsStore","setIsInserterOpened","addClass","isFromInternalAction","bind","open","activeElement","expand","completeCallback","searchBox","focus","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":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AAVA;AACA;AACA;;AAKA;AACA;AACA;;AAGe,SAASI,uBAAuBA,CAAA,EAAG;EACjD,MAAM;IACLC,EAAE,EAAE;MAAEC;IAAU;EACjB,CAAC,GAAGC,MAAM;EAEV,MAAMC,YAAY,GAAGF,SAAS,CAACE,YAAY;EAC3C;EACA;EACA;EACAF,SAAS,CAACE,YAAY,GAAG,cAAcA,YAAY,CAAC;IACnDC,gBAAgBA,CAAEC,QAAQ,EAAEC,IAAI,EAAG;MAClC,IAAKD,QAAQ,EAAG;QACfJ,SAAS,CAACM,OAAO,CAACC,IAAI,CAAID,OAAO,IAAM;UACtC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EAAG;gBACvC,IAAI,CAACA,2BAA2B,CAACwB,KAAK,CAAC,CAAC;cACzC;YACD;UACD;QACD,CAAE,CAAC;MACJ;IACD;EACD,CAAC;AACF"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = getInspectorSection;
7
-
8
7
  function getInspectorSection() {
9
8
  const {
10
9
  wp: {
@@ -18,27 +17,21 @@ function getInspectorSection() {
18
17
  this.returnFocusWhenClose = null;
19
18
  this._isOpen = false;
20
19
  }
21
-
22
20
  get isOpen() {
23
21
  return this._isOpen;
24
22
  }
25
-
26
23
  set isOpen(value) {
27
24
  this._isOpen = value;
28
25
  this.triggerActiveCallbacks();
29
26
  }
30
-
31
27
  ready() {
32
28
  this.contentContainer[0].classList.add('customize-widgets-layout__inspector');
33
29
  }
34
-
35
30
  isContextuallyActive() {
36
31
  return this.isOpen;
37
32
  }
38
-
39
33
  onChangeExpanded(expanded, args) {
40
34
  super.onChangeExpanded(expanded, args);
41
-
42
35
  if (this.parentSection && !args.unchanged) {
43
36
  if (expanded) {
44
37
  this.parentSection.collapse({
@@ -57,7 +50,6 @@ function getInspectorSection() {
57
50
  }
58
51
  }
59
52
  }
60
-
61
53
  open({
62
54
  returnFocusWhenClose
63
55
  } = {}) {
@@ -67,13 +59,11 @@ function getInspectorSection() {
67
59
  allowMultiple: true
68
60
  });
69
61
  }
70
-
71
62
  close() {
72
63
  this.collapse({
73
64
  allowMultiple: true
74
65
  });
75
66
  }
76
-
77
67
  collapse(options) {
78
68
  // Overridden collapse() function. Mostly call the parent collapse(), but also
79
69
  // move our .isOpen to false.
@@ -87,7 +77,6 @@ function getInspectorSection() {
87
77
  this.isOpen = false;
88
78
  super.collapse(options);
89
79
  }
90
-
91
80
  triggerActiveCallbacks() {
92
81
  // Manually fire the callbacks associated with moving this.active
93
82
  // from false to true. "active" is always true for this section,
@@ -103,7 +92,6 @@ function getInspectorSection() {
103
92
  // update its view of our status.
104
93
  this.active.callbacks.fireWith(this.active, [false, true]);
105
94
  }
106
-
107
95
  };
108
96
  }
109
97
  //# sourceMappingURL=inspector-section.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/controls/inspector-section.js"],"names":["getInspectorSection","wp","customize","window","InspectorSection","Section","constructor","id","options","parentSection","returnFocusWhenClose","_isOpen","isOpen","value","triggerActiveCallbacks","ready","contentContainer","classList","add","isContextuallyActive","onChangeExpanded","expanded","args","unchanged","collapse","manualTransition","expand","completeCallback","contains","focus","open","allowMultiple","close","active","callbacks","fireWith"],"mappings":";;;;;;;AAAe,SAASA,mBAAT,GAA+B;AAC7C,QAAM;AACLC,IAAAA,EAAE,EAAE;AAAEC,MAAAA;AAAF;AADC,MAEFC,MAFJ;AAIA,SAAO,MAAMC,gBAAN,SAA+BF,SAAS,CAACG,OAAzC,CAAiD;AACvDC,IAAAA,WAAW,CAAEC,EAAF,EAAMC,OAAN,EAAgB;AAC1B,YAAOD,EAAP,EAAWC,OAAX;AAEA,WAAKC,aAAL,GAAqBD,OAAO,CAACC,aAA7B;AAEA,WAAKC,oBAAL,GAA4B,IAA5B;AACA,WAAKC,OAAL,GAAe,KAAf;AACA;;AACS,QAANC,MAAM,GAAG;AACZ,aAAO,KAAKD,OAAZ;AACA;;AACS,QAANC,MAAM,CAAEC,KAAF,EAAU;AACnB,WAAKF,OAAL,GAAeE,KAAf;AACA,WAAKC,sBAAL;AACA;;AACDC,IAAAA,KAAK,GAAG;AACP,WAAKC,gBAAL,CAAuB,CAAvB,EAA2BC,SAA3B,CAAqCC,GAArC,CACC,qCADD;AAGA;;AACDC,IAAAA,oBAAoB,GAAG;AACtB,aAAO,KAAKP,MAAZ;AACA;;AACDQ,IAAAA,gBAAgB,CAAEC,QAAF,EAAYC,IAAZ,EAAmB;AAClC,YAAMF,gBAAN,CAAwBC,QAAxB,EAAkCC,IAAlC;;AAEA,UAAK,KAAKb,aAAL,IAAsB,CAAEa,IAAI,CAACC,SAAlC,EAA8C;AAC7C,YAAKF,QAAL,EAAgB;AACf,eAAKZ,aAAL,CAAmBe,QAAnB,CAA6B;AAC5BC,YAAAA,gBAAgB,EAAE;AADU,WAA7B;AAGA,SAJD,MAIO;AACN,eAAKhB,aAAL,CAAmBiB,MAAnB,CAA2B;AAC1BD,YAAAA,gBAAgB,EAAE,IADQ;AAE1BE,YAAAA,gBAAgB,EAAE,MAAM;AACvB;AACA,kBACC,KAAKjB,oBAAL,IACA,CAAE,KAAKM,gBAAL,CAAuB,CAAvB,EAA2BY,QAA3B,CACD,KAAKlB,oBADJ,CAFH,EAKE;AACD,qBAAKA,oBAAL,CAA0BmB,KAA1B;AACA;AACD;AAZyB,WAA3B;AAcA;AACD;AACD;;AACDC,IAAAA,IAAI,CAAE;AAAEpB,MAAAA;AAAF,QAA2B,EAA7B,EAAkC;AACrC,WAAKE,MAAL,GAAc,IAAd;AACA,WAAKF,oBAAL,GAA4BA,oBAA5B;AAEA,WAAKgB,MAAL,CAAa;AACZK,QAAAA,aAAa,EAAE;AADH,OAAb;AAGA;;AACDC,IAAAA,KAAK,GAAG;AACP,WAAKR,QAAL,CAAe;AACdO,QAAAA,aAAa,EAAE;AADD,OAAf;AAGA;;AACDP,IAAAA,QAAQ,CAAEhB,OAAF,EAAY;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAKI,MAAL,GAAc,KAAd;AACA,YAAMY,QAAN,CAAgBhB,OAAhB;AACA;;AACDM,IAAAA,sBAAsB,GAAG;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAKmB,MAAL,CAAYC,SAAZ,CAAsBC,QAAtB,CAAgC,KAAKF,MAArC,EAA6C,CAAE,KAAF,EAAS,IAAT,CAA7C;AACA;;AA1FsD,GAAxD;AA4FA","sourcesContent":["export default function getInspectorSection() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\treturn class InspectorSection extends customize.Section {\n\t\tconstructor( id, options ) {\n\t\t\tsuper( id, options );\n\n\t\t\tthis.parentSection = options.parentSection;\n\n\t\t\tthis.returnFocusWhenClose = null;\n\t\t\tthis._isOpen = false;\n\t\t}\n\t\tget isOpen() {\n\t\t\treturn this._isOpen;\n\t\t}\n\t\tset isOpen( value ) {\n\t\t\tthis._isOpen = value;\n\t\t\tthis.triggerActiveCallbacks();\n\t\t}\n\t\tready() {\n\t\t\tthis.contentContainer[ 0 ].classList.add(\n\t\t\t\t'customize-widgets-layout__inspector'\n\t\t\t);\n\t\t}\n\t\tisContextuallyActive() {\n\t\t\treturn this.isOpen;\n\t\t}\n\t\tonChangeExpanded( expanded, args ) {\n\t\t\tsuper.onChangeExpanded( expanded, args );\n\n\t\t\tif ( this.parentSection && ! args.unchanged ) {\n\t\t\t\tif ( expanded ) {\n\t\t\t\t\tthis.parentSection.collapse( {\n\t\t\t\t\t\tmanualTransition: true,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tthis.parentSection.expand( {\n\t\t\t\t\t\tmanualTransition: true,\n\t\t\t\t\t\tcompleteCallback: () => {\n\t\t\t\t\t\t\t// Return focus after finishing the transition.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tthis.returnFocusWhenClose &&\n\t\t\t\t\t\t\t\t! this.contentContainer[ 0 ].contains(\n\t\t\t\t\t\t\t\t\tthis.returnFocusWhenClose\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tthis.returnFocusWhenClose.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\topen( { returnFocusWhenClose } = {} ) {\n\t\t\tthis.isOpen = true;\n\t\t\tthis.returnFocusWhenClose = returnFocusWhenClose;\n\n\t\t\tthis.expand( {\n\t\t\t\tallowMultiple: true,\n\t\t\t} );\n\t\t}\n\t\tclose() {\n\t\t\tthis.collapse( {\n\t\t\t\tallowMultiple: true,\n\t\t\t} );\n\t\t}\n\t\tcollapse( options ) {\n\t\t\t// Overridden collapse() function. Mostly call the parent collapse(), but also\n\t\t\t// move our .isOpen to false.\n\t\t\t// Initially, I tried tracking this with onChangeExpanded(), but it doesn't work\n\t\t\t// because the block settings sidebar is a layer \"on top of\" the G editor sidebar.\n\t\t\t//\n\t\t\t// For example, when closing the block settings sidebar, the G\n\t\t\t// editor sidebar would display, and onChangeExpanded in\n\t\t\t// inspector-section would run with expanded=true, but I want\n\t\t\t// isOpen to be false when the block settings is closed.\n\t\t\tthis.isOpen = false;\n\t\t\tsuper.collapse( options );\n\t\t}\n\t\ttriggerActiveCallbacks() {\n\t\t\t// Manually fire the callbacks associated with moving this.active\n\t\t\t// from false to true. \"active\" is always true for this section,\n\t\t\t// and \"isContextuallyActive\" reflects if the block settings\n\t\t\t// sidebar is currently visible, that is, it has replaced the main\n\t\t\t// Gutenberg view.\n\t\t\t// The WP customizer only checks \".isContextuallyActive()\" when\n\t\t\t// \".active\" changes values. But our \".active\" never changes value.\n\t\t\t// The WP customizer never foresaw a section being used a way we\n\t\t\t// fit the block settings sidebar into a section. By manually\n\t\t\t// triggering the \"this.active\" callbacks, we force the WP\n\t\t\t// customizer to query our .isContextuallyActive() function and\n\t\t\t// update its view of our status.\n\t\t\tthis.active.callbacks.fireWith( this.active, [ false, true ] );\n\t\t}\n\t};\n}\n"]}
1
+ {"version":3,"names":["getInspectorSection","wp","customize","window","InspectorSection","Section","constructor","id","options","parentSection","returnFocusWhenClose","_isOpen","isOpen","value","triggerActiveCallbacks","ready","contentContainer","classList","add","isContextuallyActive","onChangeExpanded","expanded","args","unchanged","collapse","manualTransition","expand","completeCallback","contains","focus","open","allowMultiple","close","active","callbacks","fireWith"],"sources":["@wordpress/customize-widgets/src/controls/inspector-section.js"],"sourcesContent":["export default function getInspectorSection() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\treturn class InspectorSection extends customize.Section {\n\t\tconstructor( id, options ) {\n\t\t\tsuper( id, options );\n\n\t\t\tthis.parentSection = options.parentSection;\n\n\t\t\tthis.returnFocusWhenClose = null;\n\t\t\tthis._isOpen = false;\n\t\t}\n\t\tget isOpen() {\n\t\t\treturn this._isOpen;\n\t\t}\n\t\tset isOpen( value ) {\n\t\t\tthis._isOpen = value;\n\t\t\tthis.triggerActiveCallbacks();\n\t\t}\n\t\tready() {\n\t\t\tthis.contentContainer[ 0 ].classList.add(\n\t\t\t\t'customize-widgets-layout__inspector'\n\t\t\t);\n\t\t}\n\t\tisContextuallyActive() {\n\t\t\treturn this.isOpen;\n\t\t}\n\t\tonChangeExpanded( expanded, args ) {\n\t\t\tsuper.onChangeExpanded( expanded, args );\n\n\t\t\tif ( this.parentSection && ! args.unchanged ) {\n\t\t\t\tif ( expanded ) {\n\t\t\t\t\tthis.parentSection.collapse( {\n\t\t\t\t\t\tmanualTransition: true,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tthis.parentSection.expand( {\n\t\t\t\t\t\tmanualTransition: true,\n\t\t\t\t\t\tcompleteCallback: () => {\n\t\t\t\t\t\t\t// Return focus after finishing the transition.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tthis.returnFocusWhenClose &&\n\t\t\t\t\t\t\t\t! this.contentContainer[ 0 ].contains(\n\t\t\t\t\t\t\t\t\tthis.returnFocusWhenClose\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tthis.returnFocusWhenClose.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\topen( { returnFocusWhenClose } = {} ) {\n\t\t\tthis.isOpen = true;\n\t\t\tthis.returnFocusWhenClose = returnFocusWhenClose;\n\n\t\t\tthis.expand( {\n\t\t\t\tallowMultiple: true,\n\t\t\t} );\n\t\t}\n\t\tclose() {\n\t\t\tthis.collapse( {\n\t\t\t\tallowMultiple: true,\n\t\t\t} );\n\t\t}\n\t\tcollapse( options ) {\n\t\t\t// Overridden collapse() function. Mostly call the parent collapse(), but also\n\t\t\t// move our .isOpen to false.\n\t\t\t// Initially, I tried tracking this with onChangeExpanded(), but it doesn't work\n\t\t\t// because the block settings sidebar is a layer \"on top of\" the G editor sidebar.\n\t\t\t//\n\t\t\t// For example, when closing the block settings sidebar, the G\n\t\t\t// editor sidebar would display, and onChangeExpanded in\n\t\t\t// inspector-section would run with expanded=true, but I want\n\t\t\t// isOpen to be false when the block settings is closed.\n\t\t\tthis.isOpen = false;\n\t\t\tsuper.collapse( options );\n\t\t}\n\t\ttriggerActiveCallbacks() {\n\t\t\t// Manually fire the callbacks associated with moving this.active\n\t\t\t// from false to true. \"active\" is always true for this section,\n\t\t\t// and \"isContextuallyActive\" reflects if the block settings\n\t\t\t// sidebar is currently visible, that is, it has replaced the main\n\t\t\t// Gutenberg view.\n\t\t\t// The WP customizer only checks \".isContextuallyActive()\" when\n\t\t\t// \".active\" changes values. But our \".active\" never changes value.\n\t\t\t// The WP customizer never foresaw a section being used a way we\n\t\t\t// fit the block settings sidebar into a section. By manually\n\t\t\t// triggering the \"this.active\" callbacks, we force the WP\n\t\t\t// customizer to query our .isContextuallyActive() function and\n\t\t\t// update its view of our status.\n\t\t\tthis.active.callbacks.fireWith( this.active, [ false, true ] );\n\t\t}\n\t};\n}\n"],"mappings":";;;;;;AAAe,SAASA,mBAAmBA,CAAA,EAAG;EAC7C,MAAM;IACLC,EAAE,EAAE;MAAEC;IAAU;EACjB,CAAC,GAAGC,MAAM;EAEV,OAAO,MAAMC,gBAAgB,SAASF,SAAS,CAACG,OAAO,CAAC;IACvDC,WAAWA,CAAEC,EAAE,EAAEC,OAAO,EAAG;MAC1B,KAAK,CAAED,EAAE,EAAEC,OAAQ,CAAC;MAEpB,IAAI,CAACC,aAAa,GAAGD,OAAO,CAACC,aAAa;MAE1C,IAAI,CAACC,oBAAoB,GAAG,IAAI;MAChC,IAAI,CAACC,OAAO,GA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AAE,CAAC;IACJ;IACAC,KAAKA,CAAA,EAAG;MACP,IAAI,CAACR,QAAQ,CAAE;QACdO,aAAa,EAAE;MAChB,CAAE,CAAC;IACJ;IACAP,QAAQA,CAAEhB,OAAO,EAAG;MACnB;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA,IAAI,CAACI,MAAM,GAAG,KAAK;MACnB,KAAK,CAACY,QAAQ,CAAEhB,OAAQ,CAAC;IAC1B;IACAM,sBAAsBA,CAAA,EAAG;MACxB;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA,IAAI,CAACmB,MAAM,CAACC,SAAS,CAACC,QAAQ,CAAE,IAAI,CAACF,MAAM,EAAE,CAAE,KAAK,EAAE,IAAI,CAAG,CAAC;IAC/D;EACD,CAAC;AACF"}
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = getSidebarControl;
9
-
10
8
  var _data = require("@wordpress/data");
11
-
12
9
  var _sidebarAdapter = _interopRequireDefault(require("../components/sidebar-block-editor/sidebar-adapter"));
13
-
14
10
  var _inserterOuterSection = _interopRequireDefault(require("./inserter-outer-section"));
15
-
16
11
  var _store = require("../store");
17
-
18
12
  /**
19
13
  * WordPress dependencies
20
14
  */
@@ -22,8 +16,8 @@ var _store = require("../store");
22
16
  /**
23
17
  * Internal dependencies
24
18
  */
25
- const getInserterId = controlId => `widgets-inserter-${controlId}`;
26
19
 
20
+ const getInserterId = controlId => `widgets-inserter-${controlId}`;
27
21
  function getSidebarControl() {
28
22
  const {
29
23
  wp: {
@@ -35,7 +29,6 @@ function getSidebarControl() {
35
29
  super(...args);
36
30
  this.subscribers = new Set();
37
31
  }
38
-
39
32
  ready() {
40
33
  const InserterOuterSection = (0, _inserterOuterSection.default)();
41
34
  this.inserter = new InserterOuterSection(getInserterId(this.id), {});
@@ -44,25 +37,21 @@ function getSidebarControl() {
44
37
  this.inspector = this.sectionInstance.inspector;
45
38
  this.sidebarAdapter = new _sidebarAdapter.default(this.setting, customize);
46
39
  }
47
-
48
40
  subscribe(callback) {
49
41
  this.subscribers.add(callback);
50
42
  return () => {
51
43
  this.subscribers.delete(callback);
52
44
  };
53
45
  }
54
-
55
46
  onChangeSectionExpanded(expanded, args) {
56
47
  if (!args.unchanged) {
57
48
  // Close the inserter when the section collapses.
58
49
  if (!expanded) {
59
50
  (0, _data.dispatch)(_store.store).setIsInserterOpened(false);
60
51
  }
61
-
62
52
  this.subscribers.forEach(subscriber => subscriber(expanded, args));
63
53
  }
64
54
  }
65
-
66
55
  };
67
56
  }
68
57
  //# sourceMappingURL=sidebar-control.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/controls/sidebar-control.js"],"names":["getInserterId","controlId","getSidebarControl","wp","customize","window","SidebarControl","Control","constructor","args","subscribers","Set","ready","InserterOuterSection","inserter","id","section","add","sectionInstance","inspector","sidebarAdapter","SidebarAdapter","setting","subscribe","callback","delete","onChangeSectionExpanded","expanded","unchanged","customizeWidgetsStore","setIsInserterOpened","forEach","subscriber"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAKA,MAAMA,aAAa,GAAKC,SAAF,IAAkB,oBAAoBA,SAAW,EAAvE;;AAEe,SAASC,iBAAT,GAA6B;AAC3C,QAAM;AACLC,IAAAA,EAAE,EAAE;AAAEC,MAAAA;AAAF;AADC,MAEFC,MAFJ;AAIA,SAAO,MAAMC,cAAN,SAA6BF,SAAS,CAACG,OAAvC,CAA+C;AACrDC,IAAAA,WAAW,CAAE,GAAGC,IAAL,EAAY;AACtB,YAAO,GAAGA,IAAV;AAEA,WAAKC,WAAL,GAAmB,IAAIC,GAAJ,EAAnB;AACA;;AAEDC,IAAAA,KAAK,GAAG;AACP,YAAMC,oBAAoB,GAAG,oCAA7B;AACA,WAAKC,QAAL,GAAgB,IAAID,oBAAJ,CACfb,aAAa,CAAE,KAAKe,EAAP,CADE,EAEf,EAFe,CAAhB;AAIAX,MAAAA,SAAS,CAACY,OAAV,CAAkBC,GAAlB,CAAuB,KAAKH,QAA5B;AAEA,WAAKI,eAAL,GAAuBd,SAAS,CAACY,OAAV,CAAmB,KAAKA,OAAL,EAAnB,CAAvB;AAEA,WAAKG,SAAL,GAAiB,KAAKD,eAAL,CAAqBC,SAAtC;AAEA,WAAKC,cAAL,GAAsB,IAAIC,uBAAJ,CAAoB,KAAKC,OAAzB,EAAkClB,SAAlC,CAAtB;AACA;;AAEDmB,IAAAA,SAAS,CAAEC,QAAF,EAAa;AACrB,WAAKd,WAAL,CAAiBO,GAAjB,CAAsBO,QAAtB;AAEA,aAAO,MAAM;AACZ,aAAKd,WAAL,CAAiBe,MAAjB,CAAyBD,QAAzB;AACA,OAFD;AAGA;;AAEDE,IAAAA,uBAAuB,CAAEC,QAAF,EAAYlB,IAAZ,EAAmB;AACzC,UAAK,CAAEA,IAAI,CAACmB,SAAZ,EAAwB;AACvB;AACA,YAAK,CAAED,QAAP,EAAkB;AACjB,8BAAUE,YAAV,EAAkCC,mBAAlC,CACC,KADD;AAGA;;AAED,aAAKpB,WAAL,CAAiBqB,OAAjB,CAA4BC,UAAF,IACzBA,UAAU,CAAEL,QAAF,EAAYlB,IAAZ,CADX;AAGA;AACD;;AA3CoD,GAAtD;AA6CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport SidebarAdapter from '../components/sidebar-block-editor/sidebar-adapter';\nimport getInserterOuterSection from './inserter-outer-section';\nimport { store as customizeWidgetsStore } from '../store';\n\nconst getInserterId = ( controlId ) => `widgets-inserter-${ controlId }`;\n\nexport default function getSidebarControl() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\treturn class SidebarControl extends customize.Control {\n\t\tconstructor( ...args ) {\n\t\t\tsuper( ...args );\n\n\t\t\tthis.subscribers = new Set();\n\t\t}\n\n\t\tready() {\n\t\t\tconst InserterOuterSection = getInserterOuterSection();\n\t\t\tthis.inserter = new InserterOuterSection(\n\t\t\t\tgetInserterId( this.id ),\n\t\t\t\t{}\n\t\t\t);\n\t\t\tcustomize.section.add( this.inserter );\n\n\t\t\tthis.sectionInstance = customize.section( this.section() );\n\n\t\t\tthis.inspector = this.sectionInstance.inspector;\n\n\t\t\tthis.sidebarAdapter = new SidebarAdapter( this.setting, customize );\n\t\t}\n\n\t\tsubscribe( callback ) {\n\t\t\tthis.subscribers.add( callback );\n\n\t\t\treturn () => {\n\t\t\t\tthis.subscribers.delete( callback );\n\t\t\t};\n\t\t}\n\n\t\tonChangeSectionExpanded( expanded, args ) {\n\t\t\tif ( ! args.unchanged ) {\n\t\t\t\t// Close the inserter when the section collapses.\n\t\t\t\tif ( ! expanded ) {\n\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tthis.subscribers.forEach( ( subscriber ) =>\n\t\t\t\t\tsubscriber( expanded, args )\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n}\n"]}
1
+ {"version":3,"names":["_data","require","_sidebarAdapter","_interopRequireDefault","_inserterOuterSection","_store","getInserterId","controlId","getSidebarControl","wp","customize","window","SidebarControl","Control","constructor","args","subscribers","Set","ready","InserterOuterSection","getInserterOuterSection","inserter","id","section","add","sectionInstance","inspector","sidebarAdapter","SidebarAdapter","setting","subscribe","callback","delete","onChangeSectionExpanded","expanded","unchanged","dispatch","customizeWidgetsStore","setIsInserterOpened","forEach","subscriber"],"sources":["@wordpress/customize-widgets/src/controls/sidebar-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport SidebarAdapter from '../components/sidebar-block-editor/sidebar-adapter';\nimport getInserterOuterSection from './inserter-outer-section';\nimport { store as customizeWidgetsStore } from '../store';\n\nconst getInserterId = ( controlId ) => `widgets-inserter-${ controlId }`;\n\nexport default function getSidebarControl() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\treturn class SidebarControl extends customize.Control {\n\t\tconstructor( ...args ) {\n\t\t\tsuper( ...args );\n\n\t\t\tthis.subscribers = new Set();\n\t\t}\n\n\t\tready() {\n\t\t\tconst InserterOuterSection = getInserterOuterSection();\n\t\t\tthis.inserter = new InserterOuterSection(\n\t\t\t\tgetInserterId( this.id ),\n\t\t\t\t{}\n\t\t\t);\n\t\t\tcustomize.section.add( this.inserter );\n\n\t\t\tthis.sectionInstance = customize.section( this.section() );\n\n\t\t\tthis.inspector = this.sectionInstance.inspector;\n\n\t\t\tthis.sidebarAdapter = new SidebarAdapter( this.setting, customize );\n\t\t}\n\n\t\tsubscribe( callback ) {\n\t\t\tthis.subscribers.add( callback );\n\n\t\t\treturn () => {\n\t\t\t\tthis.subscribers.delete( callback );\n\t\t\t};\n\t\t}\n\n\t\tonChangeSectionExpanded( expanded, args ) {\n\t\t\tif ( ! args.unchanged ) {\n\t\t\t\t// Close the inserter when the section collapses.\n\t\t\t\tif ( ! expanded ) {\n\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tthis.subscribers.forEach( ( subscriber ) =>\n\t\t\t\t\tsubscriber( expanded, args )\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,eAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,qBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA,MAAMK,aAAa,GAAKC,SAAS,IAAO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