@wordpress/edit-widgets 7.1.0 → 7.3.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 (201) hide show
  1. package/build/blocks/widget-area/edit/index.cjs +10 -8
  2. package/build/blocks/widget-area/edit/index.cjs.map +1 -1
  3. package/build/blocks/widget-area/edit/inner-blocks.cjs +10 -8
  4. package/build/blocks/widget-area/edit/inner-blocks.cjs.map +1 -1
  5. package/build/blocks/widget-area/edit/use-is-dragging-within.cjs.map +1 -1
  6. package/build/blocks/widget-area/index.cjs +9 -7
  7. package/build/blocks/widget-area/index.cjs.map +1 -1
  8. package/build/components/error-boundary/index.cjs +1 -1
  9. package/build/components/error-boundary/index.cjs.map +1 -1
  10. package/build/components/header/document-tools/index.cjs +20 -10
  11. package/build/components/header/document-tools/index.cjs.map +1 -1
  12. package/build/components/header/index.cjs +18 -11
  13. package/build/components/header/index.cjs.map +1 -1
  14. package/build/components/keyboard-shortcut-help-modal/config.cjs +5 -0
  15. package/build/components/keyboard-shortcut-help-modal/config.cjs.map +1 -1
  16. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs +9 -7
  17. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs.map +1 -1
  18. package/build/components/keyboard-shortcut-help-modal/index.cjs +12 -11
  19. package/build/components/keyboard-shortcut-help-modal/index.cjs.map +1 -1
  20. package/build/components/keyboard-shortcut-help-modal/shortcut.cjs +35 -13
  21. package/build/components/keyboard-shortcut-help-modal/shortcut.cjs.map +1 -1
  22. package/build/components/keyboard-shortcuts/index.cjs.map +1 -1
  23. package/build/components/layout/index.cjs +19 -13
  24. package/build/components/layout/index.cjs.map +1 -1
  25. package/build/components/layout/interface.cjs +27 -13
  26. package/build/components/layout/interface.cjs.map +1 -1
  27. package/build/components/layout/unsaved-changes-warning.cjs +3 -6
  28. package/build/components/layout/unsaved-changes-warning.cjs.map +1 -1
  29. package/build/components/more-menu/index.cjs +14 -10
  30. package/build/components/more-menu/index.cjs.map +1 -1
  31. package/build/components/secondary-sidebar/index.cjs +10 -8
  32. package/build/components/secondary-sidebar/index.cjs.map +1 -1
  33. package/build/components/secondary-sidebar/inserter-sidebar.cjs +9 -7
  34. package/build/components/secondary-sidebar/inserter-sidebar.cjs.map +1 -1
  35. package/build/components/sidebar/index.cjs +23 -15
  36. package/build/components/sidebar/index.cjs.map +1 -1
  37. package/build/components/welcome-guide/index.cjs +5 -1
  38. package/build/components/welcome-guide/index.cjs.map +1 -1
  39. package/build/components/widget-areas-block-editor-content/index.cjs +10 -8
  40. package/build/components/widget-areas-block-editor-content/index.cjs.map +1 -1
  41. package/build/components/widget-areas-block-editor-provider/index.cjs +10 -8
  42. package/build/components/widget-areas-block-editor-provider/index.cjs.map +1 -1
  43. package/build/constants.cjs +0 -2
  44. package/build/constants.cjs.map +1 -1
  45. package/build/index.cjs +12 -10
  46. package/build/index.cjs.map +1 -1
  47. package/build/store/actions.cjs +20 -9
  48. package/build/store/actions.cjs.map +1 -1
  49. package/build/store/index.cjs +14 -12
  50. package/build/store/index.cjs.map +1 -1
  51. package/build/store/selectors.cjs +3 -1
  52. package/build/store/selectors.cjs.map +1 -1
  53. package/build-module/blocks/widget-area/index.mjs.map +1 -1
  54. package/build-module/components/error-boundary/index.mjs +2 -2
  55. package/build-module/components/error-boundary/index.mjs.map +1 -1
  56. package/build-module/components/header/document-tools/index.mjs +10 -2
  57. package/build-module/components/header/document-tools/index.mjs.map +1 -1
  58. package/build-module/components/header/index.mjs +6 -2
  59. package/build-module/components/header/index.mjs.map +1 -1
  60. package/build-module/components/header/undo-redo/redo.mjs.map +1 -1
  61. package/build-module/components/header/undo-redo/undo.mjs.map +1 -1
  62. package/build-module/components/keyboard-shortcut-help-modal/config.mjs +5 -0
  63. package/build-module/components/keyboard-shortcut-help-modal/config.mjs.map +1 -1
  64. package/build-module/components/keyboard-shortcut-help-modal/index.mjs +1 -2
  65. package/build-module/components/keyboard-shortcut-help-modal/index.mjs.map +1 -1
  66. package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs +35 -13
  67. package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs.map +1 -1
  68. package/build-module/components/layout/index.mjs +5 -1
  69. package/build-module/components/layout/index.mjs.map +1 -1
  70. package/build-module/components/layout/interface.mjs +16 -4
  71. package/build-module/components/layout/interface.mjs.map +1 -1
  72. package/build-module/components/layout/unsaved-changes-warning.mjs +3 -6
  73. package/build-module/components/layout/unsaved-changes-warning.mjs.map +1 -1
  74. package/build-module/components/more-menu/index.mjs +4 -2
  75. package/build-module/components/more-menu/index.mjs.map +1 -1
  76. package/build-module/components/sidebar/index.mjs +14 -8
  77. package/build-module/components/sidebar/index.mjs.map +1 -1
  78. package/build-module/components/welcome-guide/index.mjs +5 -1
  79. package/build-module/components/welcome-guide/index.mjs.map +1 -1
  80. package/build-module/constants.mjs +1 -2
  81. package/build-module/constants.mjs.map +1 -1
  82. package/build-module/index.mjs +2 -2
  83. package/build-module/index.mjs.map +1 -1
  84. package/build-module/store/actions.mjs +20 -9
  85. package/build-module/store/actions.mjs.map +1 -1
  86. package/build-module/store/selectors.mjs +3 -1
  87. package/build-module/store/selectors.mjs.map +1 -1
  88. package/build-style/style-rtl.css +72 -46
  89. package/build-style/style.css +72 -46
  90. package/build-types/blocks/widget-area/edit/index.d.ts +10 -0
  91. package/build-types/blocks/widget-area/edit/index.d.ts.map +1 -0
  92. package/build-types/blocks/widget-area/edit/inner-blocks.d.ts +4 -0
  93. package/build-types/blocks/widget-area/edit/inner-blocks.d.ts.map +1 -0
  94. package/build-types/blocks/widget-area/edit/use-is-dragging-within.d.ts +12 -0
  95. package/build-types/blocks/widget-area/edit/use-is-dragging-within.d.ts.map +1 -0
  96. package/build-types/blocks/widget-area/index.d.ts +14 -0
  97. package/build-types/blocks/widget-area/index.d.ts.map +1 -0
  98. package/build-types/components/error-boundary/index.d.ts +14 -0
  99. package/build-types/components/error-boundary/index.d.ts.map +1 -0
  100. package/build-types/components/header/document-tools/index.d.ts +3 -0
  101. package/build-types/components/header/document-tools/index.d.ts.map +1 -0
  102. package/build-types/components/header/index.d.ts +3 -0
  103. package/build-types/components/header/index.d.ts.map +1 -0
  104. package/build-types/components/header/undo-redo/redo.d.ts +3 -0
  105. package/build-types/components/header/undo-redo/redo.d.ts.map +1 -0
  106. package/build-types/components/header/undo-redo/undo.d.ts +3 -0
  107. package/build-types/components/header/undo-redo/undo.d.ts.map +1 -0
  108. package/build-types/components/keyboard-shortcut-help-modal/config.d.ts +3 -0
  109. package/build-types/components/keyboard-shortcut-help-modal/config.d.ts.map +1 -0
  110. package/build-types/components/keyboard-shortcut-help-modal/dynamic-shortcut.d.ts +5 -0
  111. package/build-types/components/keyboard-shortcut-help-modal/dynamic-shortcut.d.ts.map +1 -0
  112. package/build-types/components/keyboard-shortcut-help-modal/index.d.ts +5 -0
  113. package/build-types/components/keyboard-shortcut-help-modal/index.d.ts.map +1 -0
  114. package/build-types/components/keyboard-shortcut-help-modal/shortcut.d.ts +25 -0
  115. package/build-types/components/keyboard-shortcut-help-modal/shortcut.d.ts.map +1 -0
  116. package/build-types/components/keyboard-shortcuts/index.d.ts +7 -0
  117. package/build-types/components/keyboard-shortcuts/index.d.ts.map +1 -0
  118. package/build-types/components/layout/index.d.ts +5 -0
  119. package/build-types/components/layout/index.d.ts.map +1 -0
  120. package/build-types/components/layout/interface.d.ts +5 -0
  121. package/build-types/components/layout/interface.d.ts.map +1 -0
  122. package/build-types/components/layout/unsaved-changes-warning.d.ts +10 -0
  123. package/build-types/components/layout/unsaved-changes-warning.d.ts.map +1 -0
  124. package/build-types/components/more-menu/index.d.ts +2 -0
  125. package/build-types/components/more-menu/index.d.ts.map +1 -0
  126. package/build-types/components/more-menu/tools-more-menu-group.d.ts +6 -0
  127. package/build-types/components/more-menu/tools-more-menu-group.d.ts.map +1 -0
  128. package/build-types/components/notices/index.d.ts +3 -0
  129. package/build-types/components/notices/index.d.ts.map +1 -0
  130. package/build-types/components/save-button/index.d.ts +3 -0
  131. package/build-types/components/save-button/index.d.ts.map +1 -0
  132. package/build-types/components/secondary-sidebar/index.d.ts +2 -0
  133. package/build-types/components/secondary-sidebar/index.d.ts.map +1 -0
  134. package/build-types/components/secondary-sidebar/inserter-sidebar.d.ts +2 -0
  135. package/build-types/components/secondary-sidebar/inserter-sidebar.d.ts.map +1 -0
  136. package/build-types/components/secondary-sidebar/list-view-sidebar.d.ts +2 -0
  137. package/build-types/components/secondary-sidebar/list-view-sidebar.d.ts.map +1 -0
  138. package/build-types/components/sidebar/index.d.ts +2 -0
  139. package/build-types/components/sidebar/index.d.ts.map +1 -0
  140. package/build-types/components/sidebar/widget-areas.d.ts +4 -0
  141. package/build-types/components/sidebar/widget-areas.d.ts.map +1 -0
  142. package/build-types/components/welcome-guide/index.d.ts +2 -0
  143. package/build-types/components/welcome-guide/index.d.ts.map +1 -0
  144. package/build-types/components/widget-areas-block-editor-content/index.d.ts +4 -0
  145. package/build-types/components/widget-areas-block-editor-content/index.d.ts.map +1 -0
  146. package/build-types/components/widget-areas-block-editor-provider/index.d.ts +6 -0
  147. package/build-types/components/widget-areas-block-editor-provider/index.d.ts.map +1 -0
  148. package/build-types/constants.d.ts +2 -0
  149. package/build-types/constants.d.ts.map +1 -0
  150. package/build-types/filters/index.d.ts +3 -0
  151. package/build-types/filters/index.d.ts.map +1 -0
  152. package/build-types/filters/move-to-widget-area.d.ts +2 -0
  153. package/build-types/filters/move-to-widget-area.d.ts.map +1 -0
  154. package/build-types/filters/replace-media-upload.d.ts +2 -0
  155. package/build-types/filters/replace-media-upload.d.ts.map +1 -0
  156. package/build-types/hooks/use-last-selected-widget-area.d.ts +9 -0
  157. package/build-types/hooks/use-last-selected-widget-area.d.ts.map +1 -0
  158. package/build-types/hooks/use-widget-library-insertion-point.d.ts +3 -0
  159. package/build-types/hooks/use-widget-library-insertion-point.d.ts.map +1 -0
  160. package/build-types/index.d.ts +16 -0
  161. package/build-types/index.d.ts.map +1 -0
  162. package/build-types/lock-unlock.d.ts +2 -0
  163. package/build-types/lock-unlock.d.ts.map +1 -0
  164. package/build-types/store/actions.d.ts +144 -0
  165. package/build-types/store/actions.d.ts.map +1 -0
  166. package/build-types/store/constants.d.ts +5 -0
  167. package/build-types/store/constants.d.ts.map +1 -0
  168. package/build-types/store/index.d.ts +9 -0
  169. package/build-types/store/index.d.ts.map +1 -0
  170. package/build-types/store/private-selectors.d.ts +3 -0
  171. package/build-types/store/private-selectors.d.ts.map +1 -0
  172. package/build-types/store/reducer.d.ts +73 -0
  173. package/build-types/store/reducer.d.ts.map +1 -0
  174. package/build-types/store/resolvers.d.ts +17 -0
  175. package/build-types/store/resolvers.d.ts.map +1 -0
  176. package/build-types/store/selectors.d.ts +159 -0
  177. package/build-types/store/selectors.d.ts.map +1 -0
  178. package/build-types/store/transformers.d.ts +16 -0
  179. package/build-types/store/transformers.d.ts.map +1 -0
  180. package/build-types/store/utils.d.ts +53 -0
  181. package/build-types/store/utils.d.ts.map +1 -0
  182. package/package.json +33 -33
  183. package/src/components/error-boundary/index.jsx +2 -2
  184. package/src/components/header/index.jsx +11 -2
  185. package/src/components/header/style.scss +30 -3
  186. package/src/components/keyboard-shortcut-help-modal/config.js +3 -0
  187. package/src/components/keyboard-shortcut-help-modal/index.jsx +0 -2
  188. package/src/components/keyboard-shortcut-help-modal/shortcut.jsx +44 -29
  189. package/src/components/keyboard-shortcut-help-modal/style.scss +1 -1
  190. package/src/components/layout/style.scss +5 -9
  191. package/src/components/layout/unsaved-changes-warning.js +4 -9
  192. package/src/components/more-menu/index.jsx +0 -1
  193. package/src/components/sidebar/index.jsx +1 -1
  194. package/src/components/sidebar/style.scss +6 -0
  195. package/src/components/welcome-guide/style.scss +1 -1
  196. package/src/components/widget-areas-block-editor-content/style.scss +1 -1
  197. package/src/constants.js +0 -1
  198. package/src/index.jsx +2 -7
  199. package/src/store/actions.js +33 -14
  200. package/src/store/selectors.js +4 -1
  201. package/src/store/test/actions.jsdom.test.js +275 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["preferencesStore"],"sources":["../../../src/components/more-menu/index.jsx"],"sourcesContent":["import { MenuGroup, MenuItem, DropdownMenu } from '@wordpress/components';\nimport { useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport { external, moreVertical } from '@wordpress/icons';\nimport {\n\tPreferenceToggleMenuItem,\n\tstore as preferencesStore,\n} from '@wordpress/preferences';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport KeyboardShortcutHelpModal from '../keyboard-shortcut-help-modal';\nimport ToolsMoreMenuGroup from './tools-more-menu-group';\n\nexport default function MoreMenu() {\n\tconst [\n\t\tisKeyboardShortcutsModalActive,\n\t\tsetIsKeyboardShortcutsModalVisible,\n\t] = useState( false );\n\tconst toggleKeyboardShortcutsModal = () =>\n\t\tsetIsKeyboardShortcutsModalVisible( ! isKeyboardShortcutsModalActive );\n\n\tuseShortcut(\n\t\t'core/edit-widgets/keyboard-shortcuts',\n\t\ttoggleKeyboardShortcutsModal\n\t);\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst { toggle } = useDispatch( preferencesStore );\n\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\ticon={ moreVertical }\n\t\t\t\tlabel={ __( 'Options' ) }\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tplacement: 'bottom-end',\n\t\t\t\t\tclassName: 'more-menu-dropdown__content',\n\t\t\t\t} }\n\t\t\t\ttoggleProps={ {\n\t\t\t\t\ttooltipPosition: 'bottom',\n\t\t\t\t\tsize: 'compact',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ ( onClose ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t\t\t<MenuGroup label={ _x( 'View', 'noun' ) }>\n\t\t\t\t\t\t\t\t<PreferenceToggleMenuItem\n\t\t\t\t\t\t\t\t\tscope=\"core/edit-widgets\"\n\t\t\t\t\t\t\t\t\tname=\"fixedToolbar\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Top toolbar' ) }\n\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t'Access all block and document tools in a single place'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t\t'Top toolbar activated'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t\t'Top toolbar deactivated'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<MenuGroup label={ __( 'Tools' ) }>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tsetIsKeyboardShortcutsModalVisible( true );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tshortcut={ displayShortcut.access( 'h' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Keyboard shortcuts' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\ttoggle(\n\t\t\t\t\t\t\t\t\t\t'core/edit-widgets',\n\t\t\t\t\t\t\t\t\t\t'welcomeGuide'\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Welcome Guide' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/block-based-widgets-editor/'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\trel=\"noopener\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Help' ) }\n\t\t\t\t\t\t\t\t<VisuallyHidden render={ <span /> }>\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<ToolsMoreMenuGroup.Slot\n\t\t\t\t\t\t\t\tfillProps={ { onClose } }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<MenuGroup label={ __( 'Preferences' ) }>\n\t\t\t\t\t\t\t<PreferenceToggleMenuItem\n\t\t\t\t\t\t\t\tscope=\"core/edit-widgets\"\n\t\t\t\t\t\t\t\tname=\"keepCaretInsideBlock\"\n\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t'Contain text cursor inside block'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t'Aids screen readers by stopping text caret from leaving blocks.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t'Contain text cursor inside block activated'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t'Contain text cursor inside block deactivated'\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<PreferenceToggleMenuItem\n\t\t\t\t\t\t\t\tscope=\"core/edit-widgets\"\n\t\t\t\t\t\t\t\tname=\"themeStyles\"\n\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t'Make the editor look like your theme.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tlabel={ __( 'Use theme styles' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t\t\t\t<PreferenceToggleMenuItem\n\t\t\t\t\t\t\t\t\tscope=\"core/edit-widgets\"\n\t\t\t\t\t\t\t\t\tname=\"showBlockBreadcrumbs\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Display block breadcrumbs' ) }\n\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t'Shows block breadcrumbs at the bottom of the editor.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t\t'Display block breadcrumbs activated'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t\t'Display block breadcrumbs deactivated'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t\t<KeyboardShortcutHelpModal\n\t\t\t\tisModalActive={ isKeyboardShortcutsModalActive }\n\t\t\t\ttoggleModal={ toggleKeyboardShortcutsModal }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,SAAwB,WAAW;CAClC,MAAM,CACL,gCACA,sCACG,SAAU,KAAM;CACpB,MAAM,qCACL,mCAAoC,CAAE,8BAA+B;C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,iEACD;MACA,kBAAmB,GAClB,4CACD;MACA,oBAAqB,GACpB,8CACD;KACA,CAAA;KACD,oBAAC,0BAAD;MACC,OAAM;MACN,MAAK;MACL,MAAO,GACN,uCACD;MACA,OAAQ,GAAI,kBAAmB;KAC/B,CAAA;KACC,mBACD,oBAAC,0BAAD;MACC,OAAM;MACN,MAAK;MACL,OAAQ,GAAI,2BAA4B;MACxC,MAAO,GACN,sDACD;MACA,kBAAmB,GAClB,qCACD;MACA,oBAAqB,GACpB,uCACD;KACA,CAAA;IAEQ;;EACV,EAAA,CAAA;CAEU,CAAA,GACd,oBAAC,2BAAD;EACC,eAAgB;EAChB,aAAc;CACd,CAAA,CACA,EAAA,CAAA;AAEJ"}
1
+ {"version":3,"file":"index.mjs","names":["preferencesStore"],"sources":["../../../src/components/more-menu/index.jsx"],"sourcesContent":["import { MenuGroup, MenuItem, DropdownMenu } from '@wordpress/components';\nimport { useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport { external, moreVertical } from '@wordpress/icons';\nimport {\n\tPreferenceToggleMenuItem,\n\tstore as preferencesStore,\n} from '@wordpress/preferences';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport KeyboardShortcutHelpModal from '../keyboard-shortcut-help-modal';\nimport ToolsMoreMenuGroup from './tools-more-menu-group';\n\nexport default function MoreMenu() {\n\tconst [\n\t\tisKeyboardShortcutsModalActive,\n\t\tsetIsKeyboardShortcutsModalVisible,\n\t] = useState( false );\n\tconst toggleKeyboardShortcutsModal = () =>\n\t\tsetIsKeyboardShortcutsModalVisible( ! isKeyboardShortcutsModalActive );\n\n\tuseShortcut(\n\t\t'core/edit-widgets/keyboard-shortcuts',\n\t\ttoggleKeyboardShortcutsModal\n\t);\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst { toggle } = useDispatch( preferencesStore );\n\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\ticon={ moreVertical }\n\t\t\t\tlabel={ __( 'Options' ) }\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tplacement: 'bottom-end',\n\t\t\t\t\tclassName: 'more-menu-dropdown__content',\n\t\t\t\t} }\n\t\t\t\ttoggleProps={ {\n\t\t\t\t\ttooltipPosition: 'bottom',\n\t\t\t\t\tsize: 'compact',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ ( onClose ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t\t\t<MenuGroup label={ _x( 'View', 'noun' ) }>\n\t\t\t\t\t\t\t\t<PreferenceToggleMenuItem\n\t\t\t\t\t\t\t\t\tscope=\"core/edit-widgets\"\n\t\t\t\t\t\t\t\t\tname=\"fixedToolbar\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Top toolbar' ) }\n\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t'Access all block and document tools in a single place'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t\t'Top toolbar activated'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t\t'Top toolbar deactivated'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<MenuGroup label={ __( 'Tools' ) }>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tsetIsKeyboardShortcutsModalVisible( true );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tshortcut={ displayShortcut.access( 'h' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Keyboard shortcuts' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\ttoggle(\n\t\t\t\t\t\t\t\t\t\t'core/edit-widgets',\n\t\t\t\t\t\t\t\t\t\t'welcomeGuide'\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Welcome Guide' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/block-based-widgets-editor/'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Help' ) }\n\t\t\t\t\t\t\t\t<VisuallyHidden render={ <span /> }>\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<ToolsMoreMenuGroup.Slot\n\t\t\t\t\t\t\t\tfillProps={ { onClose } }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<MenuGroup label={ __( 'Preferences' ) }>\n\t\t\t\t\t\t\t<PreferenceToggleMenuItem\n\t\t\t\t\t\t\t\tscope=\"core/edit-widgets\"\n\t\t\t\t\t\t\t\tname=\"keepCaretInsideBlock\"\n\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t'Contain text cursor inside block'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t'Aids screen readers by stopping text caret from leaving blocks.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t'Contain text cursor inside block activated'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t'Contain text cursor inside block deactivated'\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<PreferenceToggleMenuItem\n\t\t\t\t\t\t\t\tscope=\"core/edit-widgets\"\n\t\t\t\t\t\t\t\tname=\"themeStyles\"\n\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t'Make the editor look like your theme.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tlabel={ __( 'Use theme styles' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t\t\t\t<PreferenceToggleMenuItem\n\t\t\t\t\t\t\t\t\tscope=\"core/edit-widgets\"\n\t\t\t\t\t\t\t\t\tname=\"showBlockBreadcrumbs\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Display block breadcrumbs' ) }\n\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t'Shows block breadcrumbs at the bottom of the editor.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t\t'Display block breadcrumbs activated'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t\t'Display block breadcrumbs deactivated'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t\t<KeyboardShortcutHelpModal\n\t\t\t\tisModalActive={ isKeyboardShortcutsModalActive }\n\t\t\t\ttoggleModal={ toggleKeyboardShortcutsModal }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,SAAwB,WAAW;CAClC,MAAM,CACL,gCACA,sCACG,SAAU,KAAM;CACpB,MAAM,qCACL,mCAAoC,CAAE,8BAA+B;CAEtE,YACC,wCACA,4BACD;CAEA,MAAM,kBAAkB,iBAAkB,QAAS;CACnD,MAAM,EAAE,WAAW,YAAaA,KAAiB;CAEjD,OACC,qBAAA,UAAA,EAAA,UAAA,CACC,oBAAC,cAAD;EACC,MAAO;EACP,OAAQ,GAAI,SAAU;EACtB,cAAe;GACd,WAAW;GACX,WAAW;EACZ;EACA,aAAc;GACb,iBAAiB;GACjB,MAAM;EACP;EAEI,WAAA,YACH,qBAAA,UAAA,EAAA,UAAA;GACG,mBACD,oBAAC,WAAD;IAAW,OAAQ,GAAI,QAAQ,MAAO;IACrC,UAAA,oBAAC,0BAAD;KACC,OAAM;KACN,MAAK;KACL,OAAQ,GAAI,aAAc;KAC1B,MAAO,GACN,uDACD;KACA,kBAAmB,GAClB,uBACD;KACA,oBAAqB,GACpB,yBACD;IACA,CAAA;GACS,CAAA;GAEZ,qBAAC,WAAD;IAAW,OAAQ,GAAI,OAAQ;IAA/B,UAAA;KACC,oBAAC,UAAD;MACC,eAAgB;OACf,mCAAoC,IAAK;MAC1C;MACA,UAAW,gBAAgB,OAAQ,GAAI;MAErC,UAAA,GAAI,oBAAqB;KAClB,CAAA;KACV,oBAAC,UAAD;MACC,eACC,OACC,qBACA,cACD;MAED,iBAAc;MAEZ,UAAA,GAAI,eAAgB;KACb,CAAA;KACV,qBAAC,UAAD;MACC,MAAK;MACL,MAAO;MACP,MAAO,GACN,yEACD;MACA,QAAO;MANR,UAAA,CAQG,GAAI,MAAO,GACb,oBAAC,gBAAD;OAAgB,QAAS,oBAAC,QAAD,CAAO,CAAA;OAG9B,UAAA;;QAAI;OAAuB;MAEb,CAAA,CACP;;KACV,oBAAC,mBAAmB,MAApB,EACC,WAAY,EAAE,QAAQ,EACtB,CAAA;IACS;;GACX,qBAAC,WAAD;IAAW,OAAQ,GAAI,aAAc;IAArC,UAAA;KACC,oBAAC,0BAAD;MACC,OAAM;MACN,MAAK;MACL,OAAQ,GACP,kCACD;MACA,MAAO,GACN,iEACD;MACA,kBAAmB,GAClB,4CACD;MACA,oBAAqB,GACpB,8CACD;KACA,CAAA;KACD,oBAAC,0BAAD;MACC,OAAM;MACN,MAAK;MACL,MAAO,GACN,uCACD;MACA,OAAQ,GAAI,kBAAmB;KAC/B,CAAA;KACC,mBACD,oBAAC,0BAAD;MACC,OAAM;MACN,MAAK;MACL,OAAQ,GAAI,2BAA4B;MACxC,MAAO,GACN,sDACD;MACA,kBAAmB,GAClB,qCACD;MACA,oBAAqB,GACpB,uCACD;KACA,CAAA;IAEQ;;EACV,EAAA,CAAA;CAEU,CAAA,GACd,oBAAC,2BAAD;EACC,eAAgB;EAChB,aAAc;CACd,CAAA,CACA,EAAA,CAAA;AAEJ"}
@@ -15,13 +15,16 @@ const BLOCK_INSPECTOR_IDENTIFIER = "edit-widgets/block-inspector";
15
15
  const WIDGET_AREAS_IDENTIFIER = "edit-widgets/block-areas";
16
16
  const { Tabs: WCTabs } = unlock(privateApis);
17
17
  function SidebarHeader({ selectedWidgetAreaBlock }) {
18
- return /* @__PURE__ */ jsxs(WCTabs.TabList, { children: [/* @__PURE__ */ jsx(WCTabs.Tab, {
19
- tabId: WIDGET_AREAS_IDENTIFIER,
20
- children: selectedWidgetAreaBlock ? selectedWidgetAreaBlock.attributes.name : __("Widget Areas")
21
- }), /* @__PURE__ */ jsx(WCTabs.Tab, {
22
- tabId: BLOCK_INSPECTOR_IDENTIFIER,
23
- children: __("Block")
24
- })] });
18
+ return /* @__PURE__ */ jsxs(WCTabs.TabList, {
19
+ className: "edit-widgets-sidebar__panel-tablist",
20
+ children: [/* @__PURE__ */ jsx(WCTabs.Tab, {
21
+ tabId: WIDGET_AREAS_IDENTIFIER,
22
+ children: selectedWidgetAreaBlock ? selectedWidgetAreaBlock.attributes.name : __("Widget Areas")
23
+ }), /* @__PURE__ */ jsx(WCTabs.Tab, {
24
+ tabId: BLOCK_INSPECTOR_IDENTIFIER,
25
+ children: __("Block")
26
+ })]
27
+ });
25
28
  }
26
29
  function SidebarContent({ hasSelectedNonAreaBlock, currentArea, isGeneralSidebarOpen, selectedWidgetAreaBlock }) {
27
30
  const { enableComplementaryArea } = useDispatch(store);
@@ -37,7 +40,10 @@ function SidebarContent({ hasSelectedNonAreaBlock, currentArea, isGeneralSidebar
37
40
  children: /* @__PURE__ */ jsx(SidebarHeader, { selectedWidgetAreaBlock })
38
41
  }),
39
42
  headerClassName: "edit-widgets-sidebar__panel-tabs",
40
- title: __("Settings"),
43
+ title: __(
44
+ /** translators: button label text should, if possible, be under 16 characters. */
45
+ "Settings"
46
+ ),
41
47
  closeLabel: __("Close Settings"),
42
48
  scope: "core/edit-widgets",
43
49
  identifier: currentArea,
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["componentsPrivateApis","interfaceStore","blockEditorStore","editWidgetsStore"],"sources":["../../../src/components/sidebar/index.jsx"],"sourcesContent":["import { useEffect, useContext, useCallback } from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport {\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport {\n\tBlockInspector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nconst SIDEBAR_ACTIVE_BY_DEFAULT = true;\nconst BLOCK_INSPECTOR_IDENTIFIER = 'edit-widgets/block-inspector';\n// Widget areas were once called block areas, so use 'edit-widgets/block-areas'\n// for backwards compatibility.\nconst WIDGET_AREAS_IDENTIFIER = 'edit-widgets/block-areas';\nimport WidgetAreas from './widget-areas';\nimport { store as editWidgetsStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { Tabs: WCTabs } = unlock( componentsPrivateApis );\n\nfunction SidebarHeader( { selectedWidgetAreaBlock } ) {\n\treturn (\n\t\t<WCTabs.TabList>\n\t\t\t<WCTabs.Tab tabId={ WIDGET_AREAS_IDENTIFIER }>\n\t\t\t\t{ selectedWidgetAreaBlock\n\t\t\t\t\t? selectedWidgetAreaBlock.attributes.name\n\t\t\t\t\t: __( 'Widget Areas' ) }\n\t\t\t</WCTabs.Tab>\n\t\t\t<WCTabs.Tab tabId={ BLOCK_INSPECTOR_IDENTIFIER }>\n\t\t\t\t{ __( 'Block' ) }\n\t\t\t</WCTabs.Tab>\n\t\t</WCTabs.TabList>\n\t);\n}\n\nfunction SidebarContent( {\n\thasSelectedNonAreaBlock,\n\tcurrentArea,\n\tisGeneralSidebarOpen,\n\tselectedWidgetAreaBlock,\n} ) {\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\thasSelectedNonAreaBlock &&\n\t\t\tcurrentArea === WIDGET_AREAS_IDENTIFIER &&\n\t\t\tisGeneralSidebarOpen\n\t\t) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\tBLOCK_INSPECTOR_IDENTIFIER\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\t! hasSelectedNonAreaBlock &&\n\t\t\tcurrentArea === BLOCK_INSPECTOR_IDENTIFIER &&\n\t\t\tisGeneralSidebarOpen\n\t\t) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\tWIDGET_AREAS_IDENTIFIER\n\t\t\t);\n\t\t}\n\t\t// We're intentionally leaving `currentArea` and `isGeneralSidebarOpen`\n\t\t// out of the dep array because we want this effect to run based on\n\t\t// block selection changes, not sidebar state changes.\n\t}, [ hasSelectedNonAreaBlock, enableComplementaryArea ] );\n\n\tconst tabsContextValue = useContext( WCTabs.Context );\n\n\treturn (\n\t\t<ComplementaryArea\n\t\t\tclassName=\"edit-widgets-sidebar\"\n\t\t\theader={\n\t\t\t\t<WCTabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t\t<SidebarHeader\n\t\t\t\t\t\tselectedWidgetAreaBlock={ selectedWidgetAreaBlock }\n\t\t\t\t\t/>\n\t\t\t\t</WCTabs.Context.Provider>\n\t\t\t}\n\t\t\theaderClassName=\"edit-widgets-sidebar__panel-tabs\"\n\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\ttitle={ __( 'Settings' ) }\n\t\t\tcloseLabel={ __( 'Close Settings' ) }\n\t\t\tscope=\"core/edit-widgets\"\n\t\t\tidentifier={ currentArea }\n\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\tisActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }\n\t\t>\n\t\t\t<WCTabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t<WCTabs.TabPanel\n\t\t\t\t\ttabId={ WIDGET_AREAS_IDENTIFIER }\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t<WidgetAreas\n\t\t\t\t\t\tselectedWidgetAreaId={\n\t\t\t\t\t\t\tselectedWidgetAreaBlock?.attributes.id\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</WCTabs.TabPanel>\n\t\t\t\t<WCTabs.TabPanel\n\t\t\t\t\ttabId={ BLOCK_INSPECTOR_IDENTIFIER }\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t{ hasSelectedNonAreaBlock ? (\n\t\t\t\t\t\t<BlockInspector />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t// Pretend that Widget Areas are part of the UI by not\n\t\t\t\t\t\t// showing the Block Inspector when one is selected.\n\t\t\t\t\t\t<span className=\"block-editor-block-inspector__no-blocks\">\n\t\t\t\t\t\t\t{ __( 'No block selected.' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</WCTabs.TabPanel>\n\t\t\t</WCTabs.Context.Provider>\n\t\t</ComplementaryArea>\n\t);\n}\n\nexport default function Sidebar() {\n\tconst {\n\t\tcurrentArea,\n\t\thasSelectedNonAreaBlock,\n\t\tisGeneralSidebarOpen,\n\t\tselectedWidgetAreaBlock,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSelectedBlock, getBlock, getBlockParentsByBlockName } =\n\t\t\tselect( blockEditorStore );\n\t\tconst { getActiveComplementaryArea } = select( interfaceStore );\n\n\t\tconst selectedBlock = getSelectedBlock();\n\n\t\tconst activeArea = getActiveComplementaryArea( editWidgetsStore.name );\n\n\t\tlet currentSelection = activeArea;\n\t\tif ( ! currentSelection ) {\n\t\t\tif ( selectedBlock ) {\n\t\t\t\tcurrentSelection = BLOCK_INSPECTOR_IDENTIFIER;\n\t\t\t} else {\n\t\t\t\tcurrentSelection = WIDGET_AREAS_IDENTIFIER;\n\t\t\t}\n\t\t}\n\n\t\tlet widgetAreaBlock;\n\t\tif ( selectedBlock ) {\n\t\t\tif ( selectedBlock.name === 'core/widget-area' ) {\n\t\t\t\twidgetAreaBlock = selectedBlock;\n\t\t\t} else {\n\t\t\t\twidgetAreaBlock = getBlock(\n\t\t\t\t\tgetBlockParentsByBlockName(\n\t\t\t\t\t\tselectedBlock.clientId,\n\t\t\t\t\t\t'core/widget-area'\n\t\t\t\t\t)[ 0 ]\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tcurrentArea: currentSelection,\n\t\t\thasSelectedNonAreaBlock: !! (\n\t\t\t\tselectedBlock && selectedBlock.name !== 'core/widget-area'\n\t\t\t),\n\t\t\tisGeneralSidebarOpen: !! activeArea,\n\t\t\tselectedWidgetAreaBlock: widgetAreaBlock,\n\t\t};\n\t}, [] );\n\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\t// `newSelectedTabId` could technically be falsy if no tab is selected (i.e.\n\t// the initial render) or when we don't want a tab displayed (i.e. the\n\t// sidebar is closed). These cases should both be covered by the `!!` check\n\t// below, so we shouldn't need any additional falsy handling.\n\tconst onTabSelect = useCallback(\n\t\t( newSelectedTabId ) => {\n\t\t\tif ( !! newSelectedTabId ) {\n\t\t\t\tenableComplementaryArea(\n\t\t\t\t\teditWidgetsStore.name,\n\t\t\t\t\tnewSelectedTabId\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ enableComplementaryArea ]\n\t);\n\n\treturn (\n\t\t<WCTabs\n\t\t\t// Due to how this component is controlled (via a value from the\n\t\t\t// `interfaceStore`), when the sidebar closes the currently selected\n\t\t\t// tab can't be found. This causes the component to continuously reset\n\t\t\t// the selection to `null` in an infinite loop. Proactively setting\n\t\t\t// the selected tab to `null` avoids that.\n\t\t\tselectedTabId={ isGeneralSidebarOpen ? currentArea : null }\n\t\t\tonSelect={ onTabSelect }\n\t\t\tselectOnMove={ false }\n\t\t>\n\t\t\t<SidebarContent\n\t\t\t\thasSelectedNonAreaBlock={ hasSelectedNonAreaBlock }\n\t\t\t\tcurrentArea={ currentArea }\n\t\t\t\tisGeneralSidebarOpen={ isGeneralSidebarOpen }\n\t\t\t\tselectedWidgetAreaBlock={ selectedWidgetAreaBlock }\n\t\t\t/>\n\t\t</WCTabs>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;AAaA,MAAM,4BAA4B;AAClC,MAAM,6BAA6B;AAGnC,MAAM,0BAA0B;AAKhC,MAAM,EAAE,MAAM,WAAW,OAAQA,WAAsB;AAEvD,SAAS,cAAe,EAAE,2BAA4B;CACrD,OACC,qBAAC,OAAO,SAAR,EAAA,UAAA,CACC,oBAAC,OAAO,KAAR;EAA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,kBAAkB,UAAU,+BACnC,OAAQC,OAAiB;EAC1B,MAAM,EAAE,+BAA+B,OAAQD,KAAe;EAE9D,MAAM,gBAAgB,iBAAiB;EAEvC,MAAM,aAAa,2BAA4BE,QAAiB,IAAK;EAErE,IAAI,mBAAmB;EACvB,IAAK,CAAE,kBAAmB;GACzB,IAAK,eACJ,mBAAmB;QAEnB,mBAAmB;EAErB;EAEA,IAAI;EACJ,IAAK,eAAgB;GACpB,IAAK,cAAc,SAAS,oBAC3B,kBAAkB;QAElB,kBAAkB,SACjB,2BACC,cAAc,UACd,kBACD,CAAC,CAAE,EACJ;EAEF;EAEA,OAAO;GACN,aAAa;GACb,yBAAyB,CAAC,EACzB,iBAAiB,cAAc,SAAS;GAEzC,sBAAsB,CAAC,CAAE;GACzB,yBAAyB;EAC1B;CACD,GAAG,CAAC,CAAE;CAEN,MAAM,EAAE,4BAA4B,YAAaF,KAAe;CAMhE,MAAM,cAAc,aACjB,qBAAsB;EACvB,IAAK,CAAC,CAAE,kBACP,wBACCE,QAAiB,MACjB,gBACD;CAEF,GACA,CAAE,uBAAwB,CAC3B;CAEA,OACC,oBAAC,QAAD;EAMC,eAAgB,uBAAuB,cAAc;EACrD,UAAW;EACX,cAAe;EAEf,UAAA,oBAAC,gBAAD;GAC2B;GACZ;GACS;GACG;EAC1B,CAAA;CACM,CAAA;AAEV"}
1
+ {"version":3,"file":"index.mjs","names":["componentsPrivateApis","interfaceStore","blockEditorStore","editWidgetsStore"],"sources":["../../../src/components/sidebar/index.jsx"],"sourcesContent":["import { useEffect, useContext, useCallback } from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport {\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport {\n\tBlockInspector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nconst SIDEBAR_ACTIVE_BY_DEFAULT = true;\nconst BLOCK_INSPECTOR_IDENTIFIER = 'edit-widgets/block-inspector';\n// Widget areas were once called block areas, so use 'edit-widgets/block-areas'\n// for backwards compatibility.\nconst WIDGET_AREAS_IDENTIFIER = 'edit-widgets/block-areas';\nimport WidgetAreas from './widget-areas';\nimport { store as editWidgetsStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { Tabs: WCTabs } = unlock( componentsPrivateApis );\n\nfunction SidebarHeader( { selectedWidgetAreaBlock } ) {\n\treturn (\n\t\t<WCTabs.TabList className=\"edit-widgets-sidebar__panel-tablist\">\n\t\t\t<WCTabs.Tab tabId={ WIDGET_AREAS_IDENTIFIER }>\n\t\t\t\t{ selectedWidgetAreaBlock\n\t\t\t\t\t? selectedWidgetAreaBlock.attributes.name\n\t\t\t\t\t: __( 'Widget Areas' ) }\n\t\t\t</WCTabs.Tab>\n\t\t\t<WCTabs.Tab tabId={ BLOCK_INSPECTOR_IDENTIFIER }>\n\t\t\t\t{ __( 'Block' ) }\n\t\t\t</WCTabs.Tab>\n\t\t</WCTabs.TabList>\n\t);\n}\n\nfunction SidebarContent( {\n\thasSelectedNonAreaBlock,\n\tcurrentArea,\n\tisGeneralSidebarOpen,\n\tselectedWidgetAreaBlock,\n} ) {\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\thasSelectedNonAreaBlock &&\n\t\t\tcurrentArea === WIDGET_AREAS_IDENTIFIER &&\n\t\t\tisGeneralSidebarOpen\n\t\t) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\tBLOCK_INSPECTOR_IDENTIFIER\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\t! hasSelectedNonAreaBlock &&\n\t\t\tcurrentArea === BLOCK_INSPECTOR_IDENTIFIER &&\n\t\t\tisGeneralSidebarOpen\n\t\t) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\tWIDGET_AREAS_IDENTIFIER\n\t\t\t);\n\t\t}\n\t\t// We're intentionally leaving `currentArea` and `isGeneralSidebarOpen`\n\t\t// out of the dep array because we want this effect to run based on\n\t\t// block selection changes, not sidebar state changes.\n\t}, [ hasSelectedNonAreaBlock, enableComplementaryArea ] );\n\n\tconst tabsContextValue = useContext( WCTabs.Context );\n\n\treturn (\n\t\t<ComplementaryArea\n\t\t\tclassName=\"edit-widgets-sidebar\"\n\t\t\theader={\n\t\t\t\t<WCTabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t\t<SidebarHeader\n\t\t\t\t\t\tselectedWidgetAreaBlock={ selectedWidgetAreaBlock }\n\t\t\t\t\t/>\n\t\t\t\t</WCTabs.Context.Provider>\n\t\t\t}\n\t\t\theaderClassName=\"edit-widgets-sidebar__panel-tabs\"\n\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\ttitle={ __( 'Settings' ) }\n\t\t\tcloseLabel={ __( 'Close Settings' ) }\n\t\t\tscope=\"core/edit-widgets\"\n\t\t\tidentifier={ currentArea }\n\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\tisActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }\n\t\t>\n\t\t\t<WCTabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t<WCTabs.TabPanel\n\t\t\t\t\ttabId={ WIDGET_AREAS_IDENTIFIER }\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t<WidgetAreas\n\t\t\t\t\t\tselectedWidgetAreaId={\n\t\t\t\t\t\t\tselectedWidgetAreaBlock?.attributes.id\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</WCTabs.TabPanel>\n\t\t\t\t<WCTabs.TabPanel\n\t\t\t\t\ttabId={ BLOCK_INSPECTOR_IDENTIFIER }\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t{ hasSelectedNonAreaBlock ? (\n\t\t\t\t\t\t<BlockInspector />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t// Pretend that Widget Areas are part of the UI by not\n\t\t\t\t\t\t// showing the Block Inspector when one is selected.\n\t\t\t\t\t\t<span className=\"block-editor-block-inspector__no-blocks\">\n\t\t\t\t\t\t\t{ __( 'No block selected.' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</WCTabs.TabPanel>\n\t\t\t</WCTabs.Context.Provider>\n\t\t</ComplementaryArea>\n\t);\n}\n\nexport default function Sidebar() {\n\tconst {\n\t\tcurrentArea,\n\t\thasSelectedNonAreaBlock,\n\t\tisGeneralSidebarOpen,\n\t\tselectedWidgetAreaBlock,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSelectedBlock, getBlock, getBlockParentsByBlockName } =\n\t\t\tselect( blockEditorStore );\n\t\tconst { getActiveComplementaryArea } = select( interfaceStore );\n\n\t\tconst selectedBlock = getSelectedBlock();\n\n\t\tconst activeArea = getActiveComplementaryArea( editWidgetsStore.name );\n\n\t\tlet currentSelection = activeArea;\n\t\tif ( ! currentSelection ) {\n\t\t\tif ( selectedBlock ) {\n\t\t\t\tcurrentSelection = BLOCK_INSPECTOR_IDENTIFIER;\n\t\t\t} else {\n\t\t\t\tcurrentSelection = WIDGET_AREAS_IDENTIFIER;\n\t\t\t}\n\t\t}\n\n\t\tlet widgetAreaBlock;\n\t\tif ( selectedBlock ) {\n\t\t\tif ( selectedBlock.name === 'core/widget-area' ) {\n\t\t\t\twidgetAreaBlock = selectedBlock;\n\t\t\t} else {\n\t\t\t\twidgetAreaBlock = getBlock(\n\t\t\t\t\tgetBlockParentsByBlockName(\n\t\t\t\t\t\tselectedBlock.clientId,\n\t\t\t\t\t\t'core/widget-area'\n\t\t\t\t\t)[ 0 ]\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tcurrentArea: currentSelection,\n\t\t\thasSelectedNonAreaBlock: !! (\n\t\t\t\tselectedBlock && selectedBlock.name !== 'core/widget-area'\n\t\t\t),\n\t\t\tisGeneralSidebarOpen: !! activeArea,\n\t\t\tselectedWidgetAreaBlock: widgetAreaBlock,\n\t\t};\n\t}, [] );\n\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\t// `newSelectedTabId` could technically be falsy if no tab is selected (i.e.\n\t// the initial render) or when we don't want a tab displayed (i.e. the\n\t// sidebar is closed). These cases should both be covered by the `!!` check\n\t// below, so we shouldn't need any additional falsy handling.\n\tconst onTabSelect = useCallback(\n\t\t( newSelectedTabId ) => {\n\t\t\tif ( !! newSelectedTabId ) {\n\t\t\t\tenableComplementaryArea(\n\t\t\t\t\teditWidgetsStore.name,\n\t\t\t\t\tnewSelectedTabId\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ enableComplementaryArea ]\n\t);\n\n\treturn (\n\t\t<WCTabs\n\t\t\t// Due to how this component is controlled (via a value from the\n\t\t\t// `interfaceStore`), when the sidebar closes the currently selected\n\t\t\t// tab can't be found. This causes the component to continuously reset\n\t\t\t// the selection to `null` in an infinite loop. Proactively setting\n\t\t\t// the selected tab to `null` avoids that.\n\t\t\tselectedTabId={ isGeneralSidebarOpen ? currentArea : null }\n\t\t\tonSelect={ onTabSelect }\n\t\t\tselectOnMove={ false }\n\t\t>\n\t\t\t<SidebarContent\n\t\t\t\thasSelectedNonAreaBlock={ hasSelectedNonAreaBlock }\n\t\t\t\tcurrentArea={ currentArea }\n\t\t\t\tisGeneralSidebarOpen={ isGeneralSidebarOpen }\n\t\t\t\tselectedWidgetAreaBlock={ selectedWidgetAreaBlock }\n\t\t\t/>\n\t\t</WCTabs>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;AAaA,MAAM,4BAA4B;AAClC,MAAM,6BAA6B;AAGnC,MAAM,0BAA0B;AAKhC,MAAM,EAAE,MAAM,WAAW,OAAQA,WAAsB;AAEvD,SAAS,cAAe,EAAE,2BAA4B;CACrD,OACC,qBAAC,OAAO,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A,yBACA,sBACA,4BACG,WAAa,WAAY;EAC5B,MAAM,EAAE,kBAAkB,UAAU,+BACnC,OAAQC,OAAiB;EAC1B,MAAM,EAAE,+BAA+B,OAAQD,KAAe;EAE9D,MAAM,gBAAgB,iBAAiB;EAEvC,MAAM,aAAa,2BAA4BE,QAAiB,IAAK;EAErE,IAAI,mBAAmB;EACvB,IAAK,CAAE,kBAAmB;GACzB,IAAK,eACJ,mBAAmB;QAEnB,mBAAmB;EAErB;EAEA,IAAI;EACJ,IAAK,eAAgB;GACpB,IAAK,cAAc,SAAS,oBAC3B,kBAAkB;QAElB,kBAAkB,SACjB,2BACC,cAAc,UACd,kBACD,CAAC,CAAE,EACJ;EAEF;EAEA,OAAO;GACN,aAAa;GACb,yBAAyB,CAAC,EACzB,iBAAiB,cAAc,SAAS;GAEzC,sBAAsB,CAAC,CAAE;GACzB,yBAAyB;EAC1B;CACD,GAAG,CAAC,CAAE;CAEN,MAAM,EAAE,4BAA4B,YAAaF,KAAe;CAMhE,MAAM,cAAc,aACjB,qBAAsB;EACvB,IAAK,CAAC,CAAE,kBACP,wBACCE,QAAiB,MACjB,gBACD;CAEF,GACA,CAAE,uBAAwB,CAC3B;CAEA,OACC,oBAAC,QAAD;EAMC,eAAgB,uBAAuB,cAAc;EACrD,UAAW;EACX,cAAe;EAEf,UAAA,oBAAC,gBAAD;GAC2B;GACZ;GACS;GACG;EAC1B,CAAA;CACM,CAAA;AAEV"}
@@ -29,7 +29,11 @@ function WelcomeGuide() {
29
29
  children: __("Welcome to block Widgets")
30
30
  }), isEntirelyBlockWidgets ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("p", {
31
31
  className: "edit-widgets-welcome-guide__text",
32
- children: sprintf(_n("Your theme provides %s “block” area 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.", "Your theme provides %s 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.", numWidgetAreas), numWidgetAreas)
32
+ children: sprintf(
33
+ /** Translators: %s: Number of block areas in the current theme. */
34
+ _n("Your theme provides %s “block” area 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.", "Your theme provides %s 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.", numWidgetAreas),
35
+ numWidgetAreas
36
+ )
33
37
  }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("p", {
34
38
  className: "edit-widgets-welcome-guide__text",
35
39
  children: __("You can now add any block to your site’s widget areas. Don’t worry, all of your favorite widgets still work flawlessly.")
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["preferencesStore","editWidgetsStore"],"sources":["../../../src/components/welcome-guide/index.jsx"],"sourcesContent":["import { useSelect, useDispatch } from '@wordpress/data';\nimport { ExternalLink, Guide } from '@wordpress/components';\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as editWidgetsStore } from '../../store';\n\nexport default function WelcomeGuide() {\n\tconst isActive = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'welcomeGuide'\n\t\t\t),\n\t\t[]\n\t);\n\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\n\tconst widgetAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getWidgetAreas( { per_page: -1 } ),\n\t\t[]\n\t);\n\n\tif ( ! isActive ) {\n\t\treturn null;\n\t}\n\n\tconst isEntirelyBlockWidgets = widgetAreas?.every(\n\t\t( widgetArea ) =>\n\t\t\twidgetArea.id === 'wp_inactive_widgets' ||\n\t\t\twidgetArea.widgets.every( ( widgetId ) =>\n\t\t\t\twidgetId.startsWith( 'block-' )\n\t\t\t)\n\t);\n\n\tconst numWidgetAreas =\n\t\twidgetAreas?.filter(\n\t\t\t( widgetArea ) => widgetArea.id !== 'wp_inactive_widgets'\n\t\t).length ?? 0;\n\n\treturn (\n\t\t<Guide\n\t\t\tclassName=\"edit-widgets-welcome-guide\"\n\t\t\tcontentLabel={ __( 'Welcome to block Widgets' ) }\n\t\t\tfinishButtonText={ __( 'Get started' ) }\n\t\t\tonFinish={ () =>\n\t\t\t\tsetPreference( 'core/edit-widgets', 'welcomeGuide', false )\n\t\t\t}\n\t\t\tpages={ [\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-canvas.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-canvas.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Welcome to block Widgets' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t{ isEntirelyBlockWidgets ? (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t// Translators: %s: Number of block areas in the current theme.\n\t\t\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t\t\t'Your theme provides %s “block” area 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\t\t\t\t\t\t'Your theme provides %s 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\t\t\t\t\t\tnumWidgetAreas\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tnumWidgetAreas\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</p>\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\t<>\n\t\t\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\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\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t\t\t<strong>\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Want to stick with the old widgets?'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</strong>{ ' ' }\n\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/plugins/classic-widgets/'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Get the Classic Widgets plugin.'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t</>\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\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-editor.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-editor.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Customize each block' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Each block comes with its own set of controls for changing things like color, width, and alignment. These will show and hide automatically when you have a block selected.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-library.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-library.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Explore all blocks' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'All of the blocks available to you live in the block library. You’ll find it wherever you see the <InserterIconImage /> icon.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tInserterIconImage: (\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"edit-widgets-welcome-guide__inserter-icon\"\n\t\t\t\t\t\t\t\t\t\t\t\talt={ __( 'inserter' ) }\n\t\t\t\t\t\t\t\t\t\t\t\tsrc=\"data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='18' height='18' rx='2' fill='%231E1E1E'/%3E%3Cpath d='M9.22727 4V14M4 8.77273H14' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E%0A\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-documentation.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-documentation.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Learn more' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\"New to the block editor? Want to learn more about using it? <a>Here's a detailed guide.</a>\"\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/wordpress-block-editor/'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\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\nfunction WelcomeGuideImage( { nonAnimatedSrc, animatedSrc } ) {\n\treturn (\n\t\t<picture className=\"edit-widgets-welcome-guide__image\">\n\t\t\t<source\n\t\t\t\tsrcSet={ nonAnimatedSrc }\n\t\t\t\tmedia=\"(prefers-reduced-motion: reduce)\"\n\t\t\t/>\n\t\t\t<img src={ animatedSrc } width=\"312\" height=\"240\" alt=\"\" />\n\t\t</picture>\n\t);\n}\n"],"mappings":";;;;;;;;AAOA,SAAwB,eAAe;CACtC,MAAM,WAAW,WACd,WACD,CAAC,CAAE,OAAQA,KAAiB,CAAC,CAAC,IAC7B,qBACA,cACD,GACD,CAAC,CACF;CAEA,MAAM,EAAE,KAAK,kBAAkB,YAAaA,KAAiB;CAE7D,MAAM,cAAc,WACjB,WACD,OAAQC,OAAiB,CAAC,CAAC,eAAgB,EAAE,UAAU,GAAG,CAAE,GAC7D,CAAC,CACF;CAEA,IAAK,CAAE,UACN,OAAO;CAGR,MAAM,yBAAyB,aAAa,OACzC,eACD,WAAW,OAAO,yBAClB,WAAW,QAAQ,OAAS,aAC3B,SAAS,WAAY,QAAS,CAC/B,CACF;CAEA,MAAM,iBACL,aAAa,QACV,eAAgB,WAAW,OAAO,qBACrC,CAAC,CAAC,UAAU;CAEb,OACC,oBAAC,OAAD;EACC,WAAU;EACV,cAAe,GAAI,0BAA2B;EAC9C,kBAAmB,GAAI,aAAc;EACrC,gBACC,cAAe,qBAAqB,gBAAgB,KAAM;EAE3D,OAAQ;GACP;IACC,OACC,oBAAC,mBAAD;KACC,gBAAe;KACf,aAAY;IACZ,CAAA;IAEF,SACC,qBAAA,UAAA,EAAA,UAAA,CACC,oBAAC,MA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AC,MAAD;KAAI,WAAU;KACX,UAAA,GAAI,YAAa;IAChB,CAAA,GACJ,oBAAC,KAAD;KAAG,WAAU;KACV,UAAA,yBACD,GACC,6FACD,GACA,EACC,GACC,oBAAC,cAAD,EACC,MAAO,GACN,qEACD,EACA,CAAA,EAEH,CACD;IACE,CAAA,CACF,EAAA,CAAA;GAEJ;EACD;CACA,CAAA;AAEH;AAEA,SAAS,kBAAmB,EAAE,gBAAgB,eAAgB;CAC7D,OACC,qBAAC,WAAD;EAAS,WAAU;EAAnB,UAAA,CACC,oBAAC,UAAD;GACC,QAAS;GACT,OAAM;EACN,CAAA,GACD,oBAAC,OAAD;GAAK,KAAM;GAAc,OAAM;GAAM,QAAO;GAAM,KAAI;EAAI,CAAA,CAClD;;AAEX"}
1
+ {"version":3,"file":"index.mjs","names":["preferencesStore","editWidgetsStore"],"sources":["../../../src/components/welcome-guide/index.jsx"],"sourcesContent":["import { useSelect, useDispatch } from '@wordpress/data';\nimport { ExternalLink, Guide } from '@wordpress/components';\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as editWidgetsStore } from '../../store';\n\nexport default function WelcomeGuide() {\n\tconst isActive = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'welcomeGuide'\n\t\t\t),\n\t\t[]\n\t);\n\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\n\tconst widgetAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getWidgetAreas( { per_page: -1 } ),\n\t\t[]\n\t);\n\n\tif ( ! isActive ) {\n\t\treturn null;\n\t}\n\n\tconst isEntirelyBlockWidgets = widgetAreas?.every(\n\t\t( widgetArea ) =>\n\t\t\twidgetArea.id === 'wp_inactive_widgets' ||\n\t\t\twidgetArea.widgets.every( ( widgetId ) =>\n\t\t\t\twidgetId.startsWith( 'block-' )\n\t\t\t)\n\t);\n\n\tconst numWidgetAreas =\n\t\twidgetAreas?.filter(\n\t\t\t( widgetArea ) => widgetArea.id !== 'wp_inactive_widgets'\n\t\t).length ?? 0;\n\n\treturn (\n\t\t<Guide\n\t\t\tclassName=\"edit-widgets-welcome-guide\"\n\t\t\tcontentLabel={ __( 'Welcome to block Widgets' ) }\n\t\t\tfinishButtonText={ __( 'Get started' ) }\n\t\t\tonFinish={ () =>\n\t\t\t\tsetPreference( 'core/edit-widgets', 'welcomeGuide', false )\n\t\t\t}\n\t\t\tpages={ [\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-canvas.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-canvas.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Welcome to block Widgets' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t{ isEntirelyBlockWidgets ? (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t// Translators: %s: Number of block areas in the current theme.\n\t\t\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t\t\t'Your theme provides %s “block” area 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\t\t\t\t\t\t'Your theme provides %s 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\t\t\t\t\t\tnumWidgetAreas\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tnumWidgetAreas\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</p>\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\t<>\n\t\t\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\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\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t\t\t<strong>\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Want to stick with the old widgets?'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</strong>{ ' ' }\n\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/plugins/classic-widgets/'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Get the Classic Widgets plugin.'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t</>\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\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-editor.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-editor.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Customize each block' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Each block comes with its own set of controls for changing things like color, width, and alignment. These will show and hide automatically when you have a block selected.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-library.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-library.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Explore all blocks' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'All of the blocks available to you live in the block library. You’ll find it wherever you see the <InserterIconImage /> icon.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tInserterIconImage: (\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"edit-widgets-welcome-guide__inserter-icon\"\n\t\t\t\t\t\t\t\t\t\t\t\talt={ __( 'inserter' ) }\n\t\t\t\t\t\t\t\t\t\t\t\tsrc=\"data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='18' height='18' rx='2' fill='%231E1E1E'/%3E%3Cpath d='M9.22727 4V14M4 8.77273H14' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E%0A\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-documentation.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-documentation.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Learn more' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\"New to the block editor? Want to learn more about using it? <a>Here's a detailed guide.</a>\"\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/wordpress-block-editor/'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\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\nfunction WelcomeGuideImage( { nonAnimatedSrc, animatedSrc } ) {\n\treturn (\n\t\t<picture className=\"edit-widgets-welcome-guide__image\">\n\t\t\t<source\n\t\t\t\tsrcSet={ nonAnimatedSrc }\n\t\t\t\tmedia=\"(prefers-reduced-motion: reduce)\"\n\t\t\t/>\n\t\t\t<img src={ animatedSrc } width=\"312\" height=\"240\" alt=\"\" />\n\t\t</picture>\n\t);\n}\n"],"mappings":";;;;;;;;AAOA,SAAwB,eAAe;CACtC,MAAM,WAAW,WACd,WACD,CAAC,CAAE,OAAQA,KAAiB,CAAC,CAAC,IAC7B,qBACA,cACD,GACD,CAAC,CACF;CAEA,MAAM,EAAE,KAAK,kBAAkB,YAAaA,KAAiB;CAE7D,MAAM,cAAc,WACjB,WACD,OAAQC,OAAiB,CAAC,CAAC,eAAgB,EAAE,UAAU,GAAG,CAAE,GAC7D,CAAC,CACF;CAEA,IAAK,CAAE,UACN,OAAO;CAGR,MAAM,yBAAyB,aAAa,OACzC,eACD,WAAW,OAAO,yBAClB,WAAW,QAAQ,OAAS,aAC3B,SAAS,WAAY,QAAS,CAC/B,CACF;CAEA,MAAM,iBACL,aAAa,QACV,eAAgB,WAAW,OAAO,qBACrC,CAAC,CAAC,UAAU;CAEb,OACC,oBAAC,OAAD;EACC,WAAU;EACV,cAAe,GAAI,0BAA2B;EAC9C,kBAAmB,GAAI,aAAc;EACrC,gBACC,cAAe,qBAAqB,gBAAgB,KAAM;EAE3D,OAAQ;GACP;IACC,OACC,oBAAC,mBAAD;KACC,gBAAe;KACf,aAAY;I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aAAY;IACZ,CAAA;IAEF,SACC,qBAAA,UAAA,EAAA,UAAA,CACC,oBAAC,MAAD;KAAI,WAAU;KACX,UAAA,GAAI,YAAa;IAChB,CAAA,GACJ,oBAAC,KAAD;KAAG,WAAU;KACV,UAAA,yBACD,GACC,6FACD,GACA,EACC,GACC,oBAAC,cAAD,EACC,MAAO,GACN,qEACD,EACA,CAAA,EAEH,CACD;IACE,CAAA,CACF,EAAA,CAAA;GAEJ;EACD;CACA,CAAA;AAEH;AAEA,SAAS,kBAAmB,EAAE,gBAAgB,eAAgB;CAC7D,OACC,qBAAC,WAAD;EAAS,WAAU;EAAnB,UAAA,CACC,oBAAC,UAAD;GACC,QAAS;GACT,OAAM;EACN,CAAA,GACD,oBAAC,OAAD;GAAK,KAAM;GAAc,OAAM;GAAM,QAAO;GAAM,KAAI;EAAI,CAAA,CAClD;;AAEX"}
@@ -1,6 +1,5 @@
1
1
  // packages/edit-widgets/src/constants.js
2
2
  const ALLOW_REUSABLE_BLOCKS = false;
3
- const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;
4
- export { ALLOW_REUSABLE_BLOCKS, ENABLE_EXPERIMENTAL_FSE_BLOCKS };
3
+ export { ALLOW_REUSABLE_BLOCKS };
5
4
 
6
5
  //# sourceMappingURL=constants.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.mjs","names":[],"sources":["../src/constants.js"],"sourcesContent":["export const ALLOW_REUSABLE_BLOCKS = false;\nexport const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;\n"],"mappings":";AAAA,MAAa,wBAAwB;AACrC,MAAa,iCAAiC"}
1
+ {"version":3,"file":"constants.mjs","names":[],"sources":["../src/constants.js"],"sourcesContent":["export const ALLOW_REUSABLE_BLOCKS = false;\n"],"mappings":";AAAA,MAAa,wBAAwB"}
@@ -10,7 +10,7 @@ import { store } from "./store/index.mjs";
10
10
  import "./filters/index.mjs";
11
11
  import * as widgetArea from "./blocks/widget-area/index.mjs";
12
12
  import Layout from "./components/layout/index.mjs";
13
- import { ALLOW_REUSABLE_BLOCKS, ENABLE_EXPERIMENTAL_FSE_BLOCKS } from "./constants.mjs";
13
+ import { ALLOW_REUSABLE_BLOCKS } from "./constants.mjs";
14
14
  import { jsx } from "react/jsx-runtime";
15
15
  // packages/edit-widgets/src/index.jsx
16
16
  const disabledBlocks = [
@@ -40,7 +40,7 @@ function initializeEditor(id, settings) {
40
40
  dispatch(store$1).reapplyBlockTypeFilters();
41
41
  registerCoreBlocks(coreBlocks);
42
42
  registerLegacyWidgetBlock();
43
- if (globalThis.IS_GUTENBERG_PLUGIN) __experimentalRegisterExperimentalCoreBlocks({ enableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS });
43
+ if (globalThis.IS_GUTENBERG_PLUGIN) __experimentalRegisterExperimentalCoreBlocks();
44
44
  registerLegacyWidgetVariations(settings);
45
45
  registerBlock(widgetArea);
46
46
  registerWidgetGroupBlock();
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["preferencesStore","blocksStore","fetchLinkSuggestions"],"sources":["../src/index.jsx"],"sourcesContent":["import {\n\tregisterBlockType,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n\tsetFreeformContentHandlerName,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { StrictMode, createRoot } from '@wordpress/element';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterLegacyWidgetVariations,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport './store';\nimport './filters';\nimport * as widgetArea from './blocks/widget-area';\nimport Layout from './components/layout';\nimport {\n\tALLOW_REUSABLE_BLOCKS,\n\tENABLE_EXPERIMENTAL_FSE_BLOCKS,\n} from './constants';\n\nconst disabledBlocks = [\n\t'core/more',\n\t'core/freeform',\n\t'core/template-part',\n\t...( ALLOW_REUSABLE_BLOCKS ? [] : [ 'core/block' ] ),\n];\n\n/**\n * Initializes the block editor in the widgets screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Block editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tconst coreBlocks = __experimentalGetCoreBlocks().filter( ( block ) => {\n\t\treturn ! (\n\t\t\tdisabledBlocks.includes( block.name ) ||\n\t\t\tblock.name.startsWith( 'core/post' ) ||\n\t\t\tblock.name.startsWith( 'core/query' ) ||\n\t\t\tblock.name.startsWith( 'core/site' ) ||\n\t\t\tblock.name.startsWith( 'core/navigation' ) ||\n\t\t\tblock.name.startsWith( 'core/term' )\n\t\t);\n\t} );\n\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-widgets', {\n\t\tfixedToolbar: false,\n\t\twelcomeGuide: true,\n\t\tshowBlockBreadcrumbs: true,\n\t\tthemeStyles: true,\n\t} );\n\n\tdispatch( blocksStore ).reapplyBlockTypeFilters();\n\tregisterCoreBlocks( coreBlocks );\n\tregisterLegacyWidgetBlock();\n\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS,\n\t\t} );\n\t}\n\tregisterLegacyWidgetVariations( settings );\n\tregisterBlock( widgetArea );\n\tregisterWidgetGroupBlock();\n\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\n\t// As we are unregistering `core/freeform` to avoid the Classic block, we must\n\t// replace it with something as the default freeform content handler. Failure to\n\t// do this will result in errors in the default block parser.\n\t// see: https://github.com/WordPress/gutenberg/issues/33097\n\tsetFreeformContentHandlerName( 'core/html' );\n\n\troot.render(\n\t\t<StrictMode>\n\t\t\t<Layout blockEditorSettings={ settings } />\n\t\t</StrictMode>\n\t);\n\n\treturn root;\n}\n\n/**\n * Compatibility export under the old `initialize` name.\n */\nexport const initialize = initializeEditor;\n\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editWidgets.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\n/**\n * Function to register an individual block.\n *\n * @param {Object} block The block to be registered.\n */\nconst registerBlock = ( block ) => {\n\tif ( ! block ) {\n\t\treturn;\n\t}\n\tconst { metadata, settings, name } = block;\n\tif ( metadata ) {\n\t\tunstable__bootstrapServerSideBlockDefinitions( { [ name ]: metadata } );\n\t}\n\tregisterBlockType( name, settings );\n};\n\nexport { store } from './store';\n"],"mappings":";;;;;;;;;;;;;;;AA8BA,MAAM,iBAAiB;CACtB;CACA;CACA;CACA,GAAK,wBAAwB,CAAC,IAAI,CAAE,YAAa;AAClD;;;;;;;AAQA,SAAgB,iBAAkB,IAAI,UAAW;CAChD,MAAM,SAAS,SAAS,eAAgB,EAAG;CAC3C,MAAM,OAAO,WAAY,MAAO;CAEhC,MAAM,aAAa,4BAA4B,CAAC,CAAC,QAAU,UAAW;EACrE,OAAO,EACN,eAAe,SAAU,MAAM,IAAK,KACpC,MAAM,KAAK,WAAY,WAAY,KACnC,MAAM,KAAK,WAAY,YAAa,KACpC,MAAM,KAAK,WAAY,WAAY,KACnC,MAAM,KAAK,WAAY,iBAAkB,KACzC,MAAM,KAAK,WAAY,WAAY;CAErC,CAAE;CAEF,SAAUA,OAAiB,CAAC,CAAC,YAAa,qBAAqB;EAC9D,cAAc;EACd,cAAc;EACd,sBAAsB;EACtB,aAAa;CACd,CAAE;CAEF,SAAUC,OAAY,CAAC,CAAC,wBAAwB;CAChD,mBAAoB,UAAW;CAC/B,0BAA0B;CAC1B,IAAK,WAAW,qBACf,6CAA8C,EAC7C,iBAAiB,+BAClB,CAAE;CAEH,+BAAgC,QAAS;CACzC,cAAe,UAAW;CAC1B,yBAAyB;CAEzB,SAAS,sCAAuC,QAAQ,kBACvDC,mCAAsB,QAAQ,eAAe,QAAS;CAMvD,8BAA+B,WAAY;CAE3C,KAAK,OACJ,oBAAC,YAAD,EAAA,UACC,oBAAC,QAAD,EAAQ,qBAAsB,SAAY,CAAA,EAC/B,CAAA,CACb;CAEA,OAAO;AACR;;;;AAKA,MAAa,aAAa;AAE1B,SAAgB,qBAAqB;CACpC,WAAY,qCAAqC;EAChD,OAAO;EACP,SAAS;CACV,CAAE;AACH;;;;;;AAOA,MAAM,iBAAkB,UAAW;CAClC,IAAK,CAAE,OACN;CAED,MAAM,EAAE,UAAU,UAAU,SAAS;CACrC,IAAK,UACJ,8CAA+C,GAAI,OAAQ,SAAS,CAAE;CAEvE,kBAAmB,MAAM,QAAS;AACnC"}
1
+ {"version":3,"file":"index.mjs","names":["preferencesStore","blocksStore","fetchLinkSuggestions"],"sources":["../src/index.jsx"],"sourcesContent":["import {\n\tregisterBlockType,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n\tsetFreeformContentHandlerName,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { StrictMode, createRoot } from '@wordpress/element';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterLegacyWidgetVariations,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport './store';\nimport './filters';\nimport * as widgetArea from './blocks/widget-area';\nimport Layout from './components/layout';\nimport { ALLOW_REUSABLE_BLOCKS } from './constants';\n\nconst disabledBlocks = [\n\t'core/more',\n\t'core/freeform',\n\t'core/template-part',\n\t...( ALLOW_REUSABLE_BLOCKS ? [] : [ 'core/block' ] ),\n];\n\n/**\n * Initializes the block editor in the widgets screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Block editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tconst coreBlocks = __experimentalGetCoreBlocks().filter( ( block ) => {\n\t\treturn ! (\n\t\t\tdisabledBlocks.includes( block.name ) ||\n\t\t\tblock.name.startsWith( 'core/post' ) ||\n\t\t\tblock.name.startsWith( 'core/query' ) ||\n\t\t\tblock.name.startsWith( 'core/site' ) ||\n\t\t\tblock.name.startsWith( 'core/navigation' ) ||\n\t\t\tblock.name.startsWith( 'core/term' )\n\t\t);\n\t} );\n\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-widgets', {\n\t\tfixedToolbar: false,\n\t\twelcomeGuide: true,\n\t\tshowBlockBreadcrumbs: true,\n\t\tthemeStyles: true,\n\t} );\n\n\tdispatch( blocksStore ).reapplyBlockTypeFilters();\n\tregisterCoreBlocks( coreBlocks );\n\tregisterLegacyWidgetBlock();\n\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks();\n\t}\n\tregisterLegacyWidgetVariations( settings );\n\tregisterBlock( widgetArea );\n\tregisterWidgetGroupBlock();\n\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\n\t// As we are unregistering `core/freeform` to avoid the Classic block, we must\n\t// replace it with something as the default freeform content handler. Failure to\n\t// do this will result in errors in the default block parser.\n\t// see: https://github.com/WordPress/gutenberg/issues/33097\n\tsetFreeformContentHandlerName( 'core/html' );\n\n\troot.render(\n\t\t<StrictMode>\n\t\t\t<Layout blockEditorSettings={ settings } />\n\t\t</StrictMode>\n\t);\n\n\treturn root;\n}\n\n/**\n * Compatibility export under the old `initialize` name.\n */\nexport const initialize = initializeEditor;\n\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editWidgets.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\n/**\n * Function to register an individual block.\n *\n * @param {Object} block The block to be registered.\n */\nconst registerBlock = ( block ) => {\n\tif ( ! block ) {\n\t\treturn;\n\t}\n\tconst { metadata, settings, name } = block;\n\tif ( metadata ) {\n\t\tunstable__bootstrapServerSideBlockDefinitions( { [ name ]: metadata } );\n\t}\n\tregisterBlockType( name, settings );\n};\n\nexport { store } from './store';\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,MAAM,iBAAiB;CACtB;CACA;CACA;CACA,GAAK,wBAAwB,CAAC,IAAI,CAAE,YAAa;AAClD;;;;;;;AAQA,SAAgB,iBAAkB,IAAI,UAAW;CAChD,MAAM,SAAS,SAAS,eAAgB,EAAG;CAC3C,MAAM,OAAO,WAAY,MAAO;CAEhC,MAAM,aAAa,4BAA4B,CAAC,CAAC,QAAU,UAAW;EACrE,OAAO,EACN,eAAe,SAAU,MAAM,IAAK,KACpC,MAAM,KAAK,WAAY,WAAY,KACnC,MAAM,KAAK,WAAY,YAAa,KACpC,MAAM,KAAK,WAAY,WAAY,KACnC,MAAM,KAAK,WAAY,iBAAkB,KACzC,MAAM,KAAK,WAAY,WAAY;CAErC,CAAE;CAEF,SAAUA,OAAiB,CAAC,CAAC,YAAa,qBAAqB;EAC9D,cAAc;EACd,cAAc;EACd,sBAAsB;EACtB,aAAa;CACd,CAAE;CAEF,SAAUC,OAAY,CAAC,CAAC,wBAAwB;CAChD,mBAAoB,UAAW;CAC/B,0BAA0B;CAC1B,IAAK,WAAW,qBACf,6CAA6C;CAE9C,+BAAgC,QAAS;CACzC,cAAe,UAAW;CAC1B,yBAAyB;CAEzB,SAAS,sCAAuC,QAAQ,kBACvDC,mCAAsB,QAAQ,eAAe,QAAS;CAMvD,8BAA+B,WAAY;CAE3C,KAAK,OACJ,oBAAC,YAAD,EAAA,UACC,oBAAC,QAAD,EAAQ,qBAAsB,SAAY,CAAA,EAC/B,CAAA,CACb;CAEA,OAAO;AACR;;;;AAKA,MAAa,aAAa;AAE1B,SAAgB,qBAAqB;CACpC,WAAY,qCAAqC;EAChD,OAAO;EACP,SAAS;CACV,CAAE;AACH;;;;;;AAOA,MAAM,iBAAkB,UAAW;CAClC,IAAK,CAAE,OACN;CAED,MAAM,EAAE,UAAU,UAAU,SAAS;CACrC,IAAK,UACJ,8CAA+C,GAAI,OAAQ,SAAS,CAAE;CAEvE,kBAAmB,MAAM,QAAS;AACnC"}
@@ -36,7 +36,10 @@ const saveEditedWidgetAreas = () => async ({ select, dispatch, registry }) => {
36
36
  await dispatch.saveWidgetAreas(editedWidgetAreas);
37
37
  registry.dispatch(store).createSuccessNotice(__("Widgets saved."), { type: "snackbar" });
38
38
  } catch (e) {
39
- registry.dispatch(store).createErrorNotice(sprintf(__("There was an error. %s"), e.message), { type: "snackbar" });
39
+ registry.dispatch(store).createErrorNotice(sprintf(__(
40
+ /** translators: %s: The error message. */
41
+ "There was an error. %s"
42
+ ), e.message), { type: "snackbar" });
40
43
  }
41
44
  };
42
45
  /**
@@ -60,7 +63,7 @@ const saveWidgetAreas = (widgetAreas) => async ({ dispatch, registry }) => {
60
63
  * @param {string} widgetAreaId ID of the widget area to process.
61
64
  * @return {Function} An action creator.
62
65
  */
63
- const saveWidgetArea = (widgetAreaId) => async ({ dispatch, select, registry }) => {
66
+ const saveWidgetArea = (widgetAreaId) => async ({ select, registry }) => {
64
67
  const widgets = select.getWidgets();
65
68
  const post = registry.select(store$2).getEditedEntityRecord(KIND, POST_TYPE, buildWidgetAreaPostId(widgetAreaId));
66
69
  const areaWidgets = Object.values(widgets).filter(({ sidebar }) => sidebar === widgetAreaId);
@@ -78,9 +81,16 @@ const saveWidgetArea = (widgetAreaId) => async ({ dispatch, select, registry })
78
81
  const batchMeta = [];
79
82
  const batchTasks = [];
80
83
  const sidebarWidgetsIds = [];
84
+ const claimedWidgetIds = /* @__PURE__ */ new Set();
81
85
  for (let i = 0; i < widgetsBlocks.length; i++) {
82
86
  const block = widgetsBlocks[i];
83
- const widgetId = getWidgetIdFromBlock(block);
87
+ let widgetId = getWidgetIdFromBlock(block);
88
+ if (widgetId) {
89
+ if (claimedWidgetIds.has(widgetId) || select.getWidgetAreaForWidgetId(widgetId)?.id !== widgetAreaId) {
90
+ widgetId = void 0;
91
+ delete block.attributes.__internalWidgetId;
92
+ } else claimedWidgetIds.add(widgetId);
93
+ }
84
94
  const oldWidget = widgets[widgetId];
85
95
  const widget = transformBlockToWidget(block, oldWidget);
86
96
  sidebarWidgetsIds.push(widgetId);
@@ -107,18 +117,19 @@ const saveWidgetArea = (widgetAreaId) => async ({ dispatch, select, registry })
107
117
  for (let i = 0; i < preservedRecords.length; i++) {
108
118
  const widget = preservedRecords[i];
109
119
  const { block, position } = batchMeta[i];
110
- post.blocks[position].attributes.__internalWidgetId = widget.id;
120
+ block.attributes.__internalWidgetId = widget.id;
111
121
  if (registry.select(store$2).getLastEntitySaveError("root", "widget", widget.id)) failedWidgetNames.push(block.attributes?.name || block?.name);
112
122
  if (!sidebarWidgetsIds[position]) sidebarWidgetsIds[position] = widget.id;
113
123
  }
114
- if (failedWidgetNames.length) throw new Error(sprintf(__("Could not save the following widgets: %s."), failedWidgetNames.join(", ")));
124
+ if (failedWidgetNames.length) throw new Error(sprintf(
125
+ /** translators: %s: List of widget names */
126
+ __("Could not save the following widgets: %s."),
127
+ failedWidgetNames.join(", ")
128
+ ));
115
129
  registry.dispatch(store$2).editEntityRecord(KIND, WIDGET_AREA_ENTITY_TYPE, widgetAreaId, { widgets: sidebarWidgetsIds }, { undoIgnore: true });
116
- dispatch(trySaveWidgetArea(widgetAreaId));
130
+ await registry.dispatch(store$2).saveEditedEntityRecord(KIND, WIDGET_AREA_ENTITY_TYPE, widgetAreaId, { throwOnError: true });
117
131
  registry.dispatch(store$2).receiveEntityRecords(KIND, POST_TYPE, post, void 0);
118
132
  };
119
- const trySaveWidgetArea = (widgetAreaId) => ({ registry }) => {
120
- registry.dispatch(store$2).saveEditedEntityRecord(KIND, WIDGET_AREA_ENTITY_TYPE, widgetAreaId, { throwOnError: true });
121
- };
122
133
  /**
123
134
  * Sets the clientId stored for a particular widgetId.
124
135
  *
@@ -1 +1 @@
1
- {"version":3,"file":"actions.mjs","names":["coreStore","noticesStore","interfaceStore","editWidgetsStoreName","blockEditorStore"],"sources":["../../src/store/actions.js"],"sourcesContent":["import { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { transformBlockToWidget } from './transformers';\nimport {\n\tbuildWidgetAreaPostId,\n\tbuildWidgetAreasQuery,\n\tcreateStubPost,\n\tKIND,\n\tPOST_TYPE,\n\tWIDGET_AREA_ENTITY_TYPE,\n} from './utils';\nimport { STORE_NAME as editWidgetsStoreName } from './constants';\n\n/**\n * Persists a stub post with given ID to core data store. The post is meant to be in-memory only and\n * shouldn't be saved via the API.\n *\n * @param {string} id Post ID.\n * @param {Array} blocks Blocks the post should consist of.\n * @return {Object} The post object.\n */\nexport const persistStubPost =\n\t( id, blocks ) =>\n\t( { registry } ) => {\n\t\tconst stubPost = createStubPost( id, blocks );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.receiveEntityRecords(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tstubPost,\n\t\t\t\t{ id: stubPost.id },\n\t\t\t\tfalse\n\t\t\t);\n\t\treturn stubPost;\n\t};\n\n/**\n * Converts all the blocks from edited widget areas into widgets,\n * and submits a batch request to save everything at once.\n *\n * Creates a snackbar notice on either success or error.\n *\n * @return {Function} An action creator.\n */\nexport const saveEditedWidgetAreas =\n\t() =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst editedWidgetAreas = select.getEditedWidgetAreas();\n\t\tif ( ! editedWidgetAreas?.length ) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tawait dispatch.saveWidgetAreas( editedWidgetAreas );\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( __( 'Widgets saved.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t} catch ( e ) {\n\t\t\tregistry.dispatch( noticesStore ).createErrorNotice(\n\t\t\t\t/* translators: %s: The error message. */\n\t\t\t\tsprintf( __( 'There was an error. %s' ), e.message ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n/**\n * Converts all the blocks from specified widget areas into widgets,\n * and submits a batch request to save everything at once.\n *\n * @param {Object[]} widgetAreas Widget areas to save.\n * @return {Function} An action creator.\n */\nexport const saveWidgetAreas =\n\t( widgetAreas ) =>\n\tasync ( { dispatch, registry } ) => {\n\t\ttry {\n\t\t\tfor ( const widgetArea of widgetAreas ) {\n\t\t\t\tawait dispatch.saveWidgetArea( widgetArea.id );\n\t\t\t}\n\t\t} finally {\n\t\t\t// saveEditedEntityRecord resets the resolution status, let's fix it manually.\n\t\t\tawait registry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.finishResolution(\n\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\tKIND,\n\t\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\t\tbuildWidgetAreasQuery()\n\t\t\t\t);\n\t\t}\n\t};\n\n/**\n * Converts all the blocks from a widget area specified by ID into widgets,\n * and submits a batch request to save everything at once.\n *\n * @param {string} widgetAreaId ID of the widget area to process.\n * @return {Function} An action creator.\n */\nexport const saveWidgetArea =\n\t( widgetAreaId ) =>\n\tasync ( { dispatch, select, registry } ) => {\n\t\tconst widgets = select.getWidgets();\n\n\t\tconst post = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tbuildWidgetAreaPostId( widgetAreaId )\n\t\t\t);\n\n\t\t// Get all widgets from this area\n\t\tconst areaWidgets = Object.values( widgets ).filter(\n\t\t\t( { sidebar } ) => sidebar === widgetAreaId\n\t\t);\n\n\t\t// Remove all duplicate reference widget instances for legacy widgets.\n\t\t// Why? We filter out the widgets with duplicate IDs to prevent adding more than one instance of a widget\n\t\t// implemented using a function. WordPress doesn't support having more than one instance of these, if you try to\n\t\t// save multiple instances of these in different sidebars you will run into undefined behaviors.\n\t\tconst usedReferenceWidgets = [];\n\t\tconst widgetsBlocks = post.blocks.filter( ( block ) => {\n\t\t\tconst { id } = block.attributes;\n\n\t\t\tif ( block.name === 'core/legacy-widget' && id ) {\n\t\t\t\tif ( usedReferenceWidgets.includes( id ) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tusedReferenceWidgets.push( id );\n\t\t\t}\n\t\t\treturn true;\n\t\t} );\n\n\t\t// Determine which widgets have been deleted. We can tell if a widget is\n\t\t// deleted and not just moved to a different area by looking to see if\n\t\t// getWidgetAreaForWidgetId() finds something.\n\t\tconst deletedWidgets = [];\n\t\tfor ( const widget of areaWidgets ) {\n\t\t\tconst widgetsNewArea = select.getWidgetAreaForWidgetId( widget.id );\n\t\t\tif ( ! widgetsNewArea ) {\n\t\t\t\tdeletedWidgets.push( widget );\n\t\t\t}\n\t\t}\n\n\t\tconst batchMeta = [];\n\t\tconst batchTasks = [];\n\t\tconst sidebarWidgetsIds = [];\n\t\tfor ( let i = 0; i < widgetsBlocks.length; i++ ) {\n\t\t\tconst block = widgetsBlocks[ i ];\n\t\t\tconst widgetId = getWidgetIdFromBlock( block );\n\t\t\tconst oldWidget = widgets[ widgetId ];\n\t\t\tconst widget = transformBlockToWidget( block, oldWidget );\n\n\t\t\t// We'll replace the null widgetId after save, but we track it here\n\t\t\t// since order is important.\n\t\t\tsidebarWidgetsIds.push( widgetId );\n\n\t\t\t// Check oldWidget as widgetId might refer to an ID which has been\n\t\t\t// deleted, e.g. if a deleted block is restored via undo after saving.\n\t\t\tif ( oldWidget ) {\n\t\t\t\t// Update an existing widget.\n\t\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t\t'root',\n\t\t\t\t\t'widget',\n\t\t\t\t\twidgetId,\n\t\t\t\t\t{\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tsidebar: widgetAreaId,\n\t\t\t\t\t},\n\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t);\n\n\t\t\t\tconst hasEdits = registry\n\t\t\t\t\t.select( coreStore )\n\t\t\t\t\t.hasEditsForEntityRecord( 'root', 'widget', widgetId );\n\n\t\t\t\tif ( ! hasEdits ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tbatchTasks.push( ( { saveEditedEntityRecord } ) =>\n\t\t\t\t\tsaveEditedEntityRecord( 'root', 'widget', widgetId )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Create a new widget.\n\t\t\t\tbatchTasks.push( ( { saveEntityRecord } ) =>\n\t\t\t\t\tsaveEntityRecord( 'root', 'widget', {\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tsidebar: widgetAreaId,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tbatchMeta.push( {\n\t\t\t\tblock,\n\t\t\t\tposition: i,\n\t\t\t\tclientId: block.clientId,\n\t\t\t} );\n\t\t}\n\t\tfor ( const widget of deletedWidgets ) {\n\t\t\tbatchTasks.push( ( { deleteEntityRecord } ) =>\n\t\t\t\tdeleteEntityRecord( 'root', 'widget', widget.id, {\n\t\t\t\t\tforce: true,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\n\t\tconst records = await registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.__experimentalBatch( batchTasks );\n\t\tconst preservedRecords = records.filter(\n\t\t\t( record ) => ! record.hasOwnProperty( 'deleted' )\n\t\t);\n\n\t\tconst failedWidgetNames = [];\n\n\t\tfor ( let i = 0; i < preservedRecords.length; i++ ) {\n\t\t\tconst widget = preservedRecords[ i ];\n\t\t\tconst { block, position } = batchMeta[ i ];\n\n\t\t\t// Set __internalWidgetId on the block. This will be persisted to the\n\t\t\t// store when we dispatch receiveEntityRecords( post ) below.\n\t\t\tpost.blocks[ position ].attributes.__internalWidgetId = widget.id;\n\n\t\t\tconst error = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getLastEntitySaveError( 'root', 'widget', widget.id );\n\t\t\tif ( error ) {\n\t\t\t\tfailedWidgetNames.push( block.attributes?.name || block?.name );\n\t\t\t}\n\n\t\t\tif ( ! sidebarWidgetsIds[ position ] ) {\n\t\t\t\tsidebarWidgetsIds[ position ] = widget.id;\n\t\t\t}\n\t\t}\n\n\t\tif ( failedWidgetNames.length ) {\n\t\t\tthrow new Error(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: List of widget names */\n\t\t\t\t\t__( 'Could not save the following widgets: %s.' ),\n\t\t\t\t\tfailedWidgetNames.join( ', ' )\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\tKIND,\n\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\twidgetAreaId,\n\t\t\t{\n\t\t\t\twidgets: sidebarWidgetsIds,\n\t\t\t},\n\t\t\t{ undoIgnore: true }\n\t\t);\n\n\t\tdispatch( trySaveWidgetArea( widgetAreaId ) );\n\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.receiveEntityRecords( KIND, POST_TYPE, post, undefined );\n\t};\n\nconst trySaveWidgetArea =\n\t( widgetAreaId ) =>\n\t( { registry } ) => {\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.saveEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\twidgetAreaId,\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\t};\n\n/**\n * Sets the clientId stored for a particular widgetId.\n *\n * @param {number} clientId Client id.\n * @param {number} widgetId Widget id.\n *\n * @return {Object} Action.\n */\nexport function setWidgetIdForClientId( clientId, widgetId ) {\n\treturn {\n\t\ttype: 'SET_WIDGET_ID_FOR_CLIENT_ID',\n\t\tclientId,\n\t\twidgetId,\n\t};\n}\n\n/**\n * Sets the open state of all the widget areas.\n *\n * @param {Object} widgetAreasOpenState The open states of all the widget areas.\n *\n * @return {Object} Action.\n */\nexport function setWidgetAreasOpenState( widgetAreasOpenState ) {\n\treturn {\n\t\ttype: 'SET_WIDGET_AREAS_OPEN_STATE',\n\t\twidgetAreasOpenState,\n\t};\n}\n\n/**\n * Sets the open state of the widget area.\n *\n * @param {string} clientId The clientId of the widget area.\n * @param {boolean} isOpen Whether the widget area should be opened.\n *\n * @return {Object} Action.\n */\nexport function setIsWidgetAreaOpen( clientId, isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_WIDGET_AREA_OPEN',\n\t\tclientId,\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the list view.\n *\n * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.\n * @return {Object} Action object.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n *\n * @return {Object} Action creator.\n */\nexport const closeGeneralSidebar =\n\t() =>\n\t( { registry } ) => {\n\t\tregistry\n\t\t\t.dispatch( interfaceStore )\n\t\t\t.disableComplementaryArea( editWidgetsStoreName );\n\t};\n\n/**\n * Action that handles moving a block between widget areas\n *\n * @param {string} clientId The clientId of the block to move.\n * @param {string} widgetAreaId The id of the widget area to move the block to.\n */\nexport const moveBlockToWidgetArea =\n\t( clientId, widgetAreaId ) =>\n\tasync ( { dispatch, select, registry } ) => {\n\t\tconst sourceRootClientId = registry\n\t\t\t.select( blockEditorStore )\n\t\t\t.getBlockRootClientId( clientId );\n\n\t\t// Search the top level blocks (widget areas) for the one with the matching\n\t\t// id attribute. Makes the assumption that all top-level blocks are widget\n\t\t// areas.\n\t\tconst widgetAreas = registry.select( blockEditorStore ).getBlocks();\n\t\tconst destinationWidgetAreaBlock = widgetAreas.find(\n\t\t\t( { attributes } ) => attributes.id === widgetAreaId\n\t\t);\n\t\tconst destinationRootClientId = destinationWidgetAreaBlock.clientId;\n\n\t\t// Get the index for moving to the end of the destination widget area.\n\t\tconst destinationInnerBlocksClientIds = registry\n\t\t\t.select( blockEditorStore )\n\t\t\t.getBlockOrder( destinationRootClientId );\n\t\tconst destinationIndex = destinationInnerBlocksClientIds.length;\n\n\t\t// Reveal the widget area, if it's not open.\n\t\tconst isDestinationWidgetAreaOpen = select.getIsWidgetAreaOpen(\n\t\t\tdestinationRootClientId\n\t\t);\n\n\t\tif ( ! isDestinationWidgetAreaOpen ) {\n\t\t\tdispatch.setIsWidgetAreaOpen( destinationRootClientId, true );\n\t\t}\n\n\t\t// Move the block.\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.moveBlocksToPosition(\n\t\t\t\t[ clientId ],\n\t\t\t\tsourceRootClientId,\n\t\t\t\tdestinationRootClientId,\n\t\t\t\tdestinationIndex\n\t\t\t);\n\t};\n\n/**\n * Returns an action object used to signal that widget saving is unlocked.\n *\n * @param {string} lockName The lock name.\n *\n * @example\n * ```js\n * import { store as widgetStore } from '@wordpress/edit-widgets';\n * import { useDispatch } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * \tconst { unlockWidgetSaving } = useDispatch( widgetStore );\n * \treturn (\n * \t\t<Button onClick={ () => unlockWidgetSaving( 'lockName' ) }>\n * \t\t\t{ __( 'Unlock Widget Saving' ) }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n * @return {Object} Action object\n */\nexport function unlockWidgetSaving( lockName ) {\n\treturn {\n\t\ttype: 'UNLOCK_WIDGET_SAVING',\n\t\tlockName,\n\t};\n}\n\n/**\n * Returns an action object used to signal that widget saving is locked.\n *\n * @param {string} lockName The lock name.\n *\n * @example\n * ```js\n * import { store as widgetStore } from '@wordpress/edit-widgets';\n * import { useDispatch } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * \tconst { lockWidgetSaving } = useDispatch( widgetStore );\n * \treturn (\n * \t\t<Button onClick={ () => lockWidgetSaving( 'lockName' ) }>\n * \t\t\t{ __( 'Lock Widget Saving' ) }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n * @return {Object} Action object\n */\nexport function lockWidgetSaving( lockName ) {\n\treturn {\n\t\ttype: 'LOCK_WIDGET_SAVING',\n\t\tlockName,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,MAAa,mBACV,IAAI,YACJ,EAAE,eAAgB;CACnB,MAAM,WAAW,eAAgB,IAAI,MAAO;CAC5C,SACE,SAAUA,OAAU,CAAC,CACrB,qBACA,MACA,WACA,UACA,EAAE,IAAI,SAAS,GAAG,GAClB,KACD;CACD,OAAO;AACR;;;;;;;;;AAUD,MAAa,8BAEZ,OAAQ,EAAE,QAAQ,UAAU,eAAgB;CAC3C,MAAM,oBAAoB,OAAO,qBAAqB;CACtD,IAAK,CAAE,mBAAmB,QACzB;CAED,IAAI;EACH,MAAM,SAAS,gBAAiB,iBAAkB;EAClD,SACE,SAAUC,KAAa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Ae,uBACsC,CAAC,CAAC;CAOzD,IAAK,CAJ+B,OAAO,oBAC1C,uBAGgC,GAChC,SAAS,oBAAqB,yBAAyB,IAAK;CAI7D,SACE,SAAUA,OAAiB,CAAC,CAC5B,qBACA,CAAE,QAAS,GACX,oBACA,yBACA,gBACD;AACF;;;;;;;;;;;;;;;;;;;;;;;AAwBD,SAAgB,mBAAoB,UAAW;CAC9C,OAAO;EACN,MAAM;EACN;CACD;AACD;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,iBAAkB,UAAW;CAC5C,OAAO;EACN,MAAM;EACN;CACD;AACD"}
1
+ {"version":3,"file":"actions.mjs","names":["coreStore","noticesStore","interfaceStore","editWidgetsStoreName","blockEditorStore"],"sources":["../../src/store/actions.js"],"sourcesContent":["import { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { transformBlockToWidget } from './transformers';\nimport {\n\tbuildWidgetAreaPostId,\n\tbuildWidgetAreasQuery,\n\tcreateStubPost,\n\tKIND,\n\tPOST_TYPE,\n\tWIDGET_AREA_ENTITY_TYPE,\n} from './utils';\nimport { STORE_NAME as editWidgetsStoreName } from './constants';\n\n/**\n * Persists a stub post with given ID to core data store. The post is meant to be in-memory only and\n * shouldn't be saved via the API.\n *\n * @param {string} id Post ID.\n * @param {Array} blocks Blocks the post should consist of.\n * @return {Object} The post object.\n */\nexport const persistStubPost =\n\t( id, blocks ) =>\n\t( { registry } ) => {\n\t\tconst stubPost = createStubPost( id, blocks );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.receiveEntityRecords(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tstubPost,\n\t\t\t\t{ id: stubPost.id },\n\t\t\t\tfalse\n\t\t\t);\n\t\treturn stubPost;\n\t};\n\n/**\n * Converts all the blocks from edited widget areas into widgets,\n * and submits a batch request to save everything at once.\n *\n * Creates a snackbar notice on either success or error.\n *\n * @return {Function} An action creator.\n */\nexport const saveEditedWidgetAreas =\n\t() =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst editedWidgetAreas = select.getEditedWidgetAreas();\n\t\tif ( ! editedWidgetAreas?.length ) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tawait dispatch.saveWidgetAreas( editedWidgetAreas );\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( __( 'Widgets saved.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t} catch ( e ) {\n\t\t\tregistry.dispatch( noticesStore ).createErrorNotice(\n\t\t\t\t/* translators: %s: The error message. */\n\t\t\t\tsprintf( __( 'There was an error. %s' ), e.message ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n/**\n * Converts all the blocks from specified widget areas into widgets,\n * and submits a batch request to save everything at once.\n *\n * @param {Object[]} widgetAreas Widget areas to save.\n * @return {Function} An action creator.\n */\nexport const saveWidgetAreas =\n\t( widgetAreas ) =>\n\tasync ( { dispatch, registry } ) => {\n\t\ttry {\n\t\t\tfor ( const widgetArea of widgetAreas ) {\n\t\t\t\tawait dispatch.saveWidgetArea( widgetArea.id );\n\t\t\t}\n\t\t} finally {\n\t\t\t// saveEditedEntityRecord resets the resolution status, let's fix it manually.\n\t\t\tawait registry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.finishResolution(\n\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\tKIND,\n\t\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\t\tbuildWidgetAreasQuery()\n\t\t\t\t);\n\t\t}\n\t};\n\n/**\n * Converts all the blocks from a widget area specified by ID into widgets,\n * and submits a batch request to save everything at once.\n *\n * @param {string} widgetAreaId ID of the widget area to process.\n * @return {Function} An action creator.\n */\nexport const saveWidgetArea =\n\t( widgetAreaId ) =>\n\tasync ( { select, registry } ) => {\n\t\tconst widgets = select.getWidgets();\n\n\t\tconst post = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tbuildWidgetAreaPostId( widgetAreaId )\n\t\t\t);\n\n\t\t// Get all widgets from this area\n\t\tconst areaWidgets = Object.values( widgets ).filter(\n\t\t\t( { sidebar } ) => sidebar === widgetAreaId\n\t\t);\n\n\t\t// Remove all duplicate reference widget instances for legacy widgets.\n\t\t// Why? We filter out the widgets with duplicate IDs to prevent adding more than one instance of a widget\n\t\t// implemented using a function. WordPress doesn't support having more than one instance of these, if you try to\n\t\t// save multiple instances of these in different sidebars you will run into undefined behaviors.\n\t\tconst usedReferenceWidgets = [];\n\t\tconst widgetsBlocks = post.blocks.filter( ( block ) => {\n\t\t\tconst { id } = block.attributes;\n\n\t\t\tif ( block.name === 'core/legacy-widget' && id ) {\n\t\t\t\tif ( usedReferenceWidgets.includes( id ) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tusedReferenceWidgets.push( id );\n\t\t\t}\n\t\t\treturn true;\n\t\t} );\n\n\t\t// Determine which widgets have been deleted. We can tell if a widget is\n\t\t// deleted and not just moved to a different area by looking to see if\n\t\t// getWidgetAreaForWidgetId() finds something.\n\t\tconst deletedWidgets = [];\n\t\tfor ( const widget of areaWidgets ) {\n\t\t\tconst widgetsNewArea = select.getWidgetAreaForWidgetId( widget.id );\n\t\t\tif ( ! widgetsNewArea ) {\n\t\t\t\tdeletedWidgets.push( widget );\n\t\t\t}\n\t\t}\n\n\t\tconst batchMeta = [];\n\t\tconst batchTasks = [];\n\t\tconst sidebarWidgetsIds = [];\n\t\tconst claimedWidgetIds = new Set();\n\t\tfor ( let i = 0; i < widgetsBlocks.length; i++ ) {\n\t\t\tconst block = widgetsBlocks[ i ];\n\t\t\tlet widgetId = getWidgetIdFromBlock( block );\n\n\t\t\t// Splitting a block, e.g. pressing Enter in the middle of a\n\t\t\t// paragraph, copies all of its attributes to the new block,\n\t\t\t// including the widget ID, and the new block can then be moved to\n\t\t\t// another widget area. Only the first block with a given ID, in the\n\t\t\t// first widget area that holds it, updates that widget. Any other\n\t\t\t// block with the same ID is saved as a new widget.\n\t\t\tif ( widgetId ) {\n\t\t\t\tif (\n\t\t\t\t\tclaimedWidgetIds.has( widgetId ) ||\n\t\t\t\t\tselect.getWidgetAreaForWidgetId( widgetId )?.id !==\n\t\t\t\t\t\twidgetAreaId\n\t\t\t\t) {\n\t\t\t\t\twidgetId = undefined;\n\t\t\t\t\t// Drop the duplicate ID now, so nothing reads it before the\n\t\t\t\t\t// new widget's ID is written back after the batch.\n\t\t\t\t\tdelete block.attributes.__internalWidgetId;\n\t\t\t\t} else {\n\t\t\t\t\tclaimedWidgetIds.add( widgetId );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst oldWidget = widgets[ widgetId ];\n\t\t\tconst widget = transformBlockToWidget( block, oldWidget );\n\n\t\t\t// We'll replace the null widgetId after save, but we track it here\n\t\t\t// since order is important.\n\t\t\tsidebarWidgetsIds.push( widgetId );\n\n\t\t\t// Check oldWidget as widgetId might refer to an ID which has been\n\t\t\t// deleted, e.g. if a deleted block is restored via undo after saving.\n\t\t\tif ( oldWidget ) {\n\t\t\t\t// Update an existing widget.\n\t\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t\t'root',\n\t\t\t\t\t'widget',\n\t\t\t\t\twidgetId,\n\t\t\t\t\t{\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tsidebar: widgetAreaId,\n\t\t\t\t\t},\n\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t);\n\n\t\t\t\tconst hasEdits = registry\n\t\t\t\t\t.select( coreStore )\n\t\t\t\t\t.hasEditsForEntityRecord( 'root', 'widget', widgetId );\n\n\t\t\t\tif ( ! hasEdits ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tbatchTasks.push( ( { saveEditedEntityRecord } ) =>\n\t\t\t\t\tsaveEditedEntityRecord( 'root', 'widget', widgetId )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Create a new widget.\n\t\t\t\tbatchTasks.push( ( { saveEntityRecord } ) =>\n\t\t\t\t\tsaveEntityRecord( 'root', 'widget', {\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tsidebar: widgetAreaId,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tbatchMeta.push( {\n\t\t\t\tblock,\n\t\t\t\tposition: i,\n\t\t\t\tclientId: block.clientId,\n\t\t\t} );\n\t\t}\n\t\tfor ( const widget of deletedWidgets ) {\n\t\t\tbatchTasks.push( ( { deleteEntityRecord } ) =>\n\t\t\t\tdeleteEntityRecord( 'root', 'widget', widget.id, {\n\t\t\t\t\tforce: true,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\n\t\tconst records = await registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.__experimentalBatch( batchTasks );\n\t\tconst preservedRecords = records.filter(\n\t\t\t( record ) => ! record.hasOwnProperty( 'deleted' )\n\t\t);\n\n\t\tconst failedWidgetNames = [];\n\n\t\tfor ( let i = 0; i < preservedRecords.length; i++ ) {\n\t\t\tconst widget = preservedRecords[ i ];\n\t\t\tconst { block, position } = batchMeta[ i ];\n\n\t\t\t// Set __internalWidgetId on the block. This will be persisted to the\n\t\t\t// store when we dispatch receiveEntityRecords( post ) below.\n\t\t\tblock.attributes.__internalWidgetId = widget.id;\n\n\t\t\tconst error = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getLastEntitySaveError( 'root', 'widget', widget.id );\n\t\t\tif ( error ) {\n\t\t\t\tfailedWidgetNames.push( block.attributes?.name || block?.name );\n\t\t\t}\n\n\t\t\tif ( ! sidebarWidgetsIds[ position ] ) {\n\t\t\t\tsidebarWidgetsIds[ position ] = widget.id;\n\t\t\t}\n\t\t}\n\n\t\tif ( failedWidgetNames.length ) {\n\t\t\tthrow new Error(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: List of widget names */\n\t\t\t\t\t__( 'Could not save the following widgets: %s.' ),\n\t\t\t\t\tfailedWidgetNames.join( ', ' )\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\tKIND,\n\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\twidgetAreaId,\n\t\t\t{\n\t\t\t\twidgets: sidebarWidgetsIds,\n\t\t\t},\n\t\t\t{ undoIgnore: true }\n\t\t);\n\n\t\t// Sidebar and widget requests can both rewrite the sidebar lists. Finish\n\t\t// this write before saveWidgetAreas starts saving the next area.\n\t\tawait registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.saveEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\twidgetAreaId,\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.receiveEntityRecords( KIND, POST_TYPE, post, undefined );\n\t};\n\n/**\n * Sets the clientId stored for a particular widgetId.\n *\n * @param {number} clientId Client id.\n * @param {number} widgetId Widget id.\n *\n * @return {Object} Action.\n */\nexport function setWidgetIdForClientId( clientId, widgetId ) {\n\treturn {\n\t\ttype: 'SET_WIDGET_ID_FOR_CLIENT_ID',\n\t\tclientId,\n\t\twidgetId,\n\t};\n}\n\n/**\n * Sets the open state of all the widget areas.\n *\n * @param {Object} widgetAreasOpenState The open states of all the widget areas.\n *\n * @return {Object} Action.\n */\nexport function setWidgetAreasOpenState( widgetAreasOpenState ) {\n\treturn {\n\t\ttype: 'SET_WIDGET_AREAS_OPEN_STATE',\n\t\twidgetAreasOpenState,\n\t};\n}\n\n/**\n * Sets the open state of the widget area.\n *\n * @param {string} clientId The clientId of the widget area.\n * @param {boolean} isOpen Whether the widget area should be opened.\n *\n * @return {Object} Action.\n */\nexport function setIsWidgetAreaOpen( clientId, isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_WIDGET_AREA_OPEN',\n\t\tclientId,\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the list view.\n *\n * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.\n * @return {Object} Action object.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n *\n * @return {Object} Action creator.\n */\nexport const closeGeneralSidebar =\n\t() =>\n\t( { registry } ) => {\n\t\tregistry\n\t\t\t.dispatch( interfaceStore )\n\t\t\t.disableComplementaryArea( editWidgetsStoreName );\n\t};\n\n/**\n * Action that handles moving a block between widget areas\n *\n * @param {string} clientId The clientId of the block to move.\n * @param {string} widgetAreaId The id of the widget area to move the block to.\n */\nexport const moveBlockToWidgetArea =\n\t( clientId, widgetAreaId ) =>\n\tasync ( { dispatch, select, registry } ) => {\n\t\tconst sourceRootClientId = registry\n\t\t\t.select( blockEditorStore )\n\t\t\t.getBlockRootClientId( clientId );\n\n\t\t// Search the top level blocks (widget areas) for the one with the matching\n\t\t// id attribute. Makes the assumption that all top-level blocks are widget\n\t\t// areas.\n\t\tconst widgetAreas = registry.select( blockEditorStore ).getBlocks();\n\t\tconst destinationWidgetAreaBlock = widgetAreas.find(\n\t\t\t( { attributes } ) => attributes.id === widgetAreaId\n\t\t);\n\t\tconst destinationRootClientId = destinationWidgetAreaBlock.clientId;\n\n\t\t// Get the index for moving to the end of the destination widget area.\n\t\tconst destinationInnerBlocksClientIds = registry\n\t\t\t.select( blockEditorStore )\n\t\t\t.getBlockOrder( destinationRootClientId );\n\t\tconst destinationIndex = destinationInnerBlocksClientIds.length;\n\n\t\t// Reveal the widget area, if it's not open.\n\t\tconst isDestinationWidgetAreaOpen = select.getIsWidgetAreaOpen(\n\t\t\tdestinationRootClientId\n\t\t);\n\n\t\tif ( ! isDestinationWidgetAreaOpen ) {\n\t\t\tdispatch.setIsWidgetAreaOpen( destinationRootClientId, true );\n\t\t}\n\n\t\t// Move the block.\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.moveBlocksToPosition(\n\t\t\t\t[ clientId ],\n\t\t\t\tsourceRootClientId,\n\t\t\t\tdestinationRootClientId,\n\t\t\t\tdestinationIndex\n\t\t\t);\n\t};\n\n/**\n * Returns an action object used to signal that widget saving is unlocked.\n *\n * @param {string} lockName The lock name.\n *\n * @example\n * ```js\n * import { store as widgetStore } from '@wordpress/edit-widgets';\n * import { useDispatch } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * \tconst { unlockWidgetSaving } = useDispatch( widgetStore );\n * \treturn (\n * \t\t<Button onClick={ () => unlockWidgetSaving( 'lockName' ) }>\n * \t\t\t{ __( 'Unlock Widget Saving' ) }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n * @return {Object} Action object\n */\nexport function unlockWidgetSaving( lockName ) {\n\treturn {\n\t\ttype: 'UNLOCK_WIDGET_SAVING',\n\t\tlockName,\n\t};\n}\n\n/**\n * Returns an action object used to signal that widget saving is locked.\n *\n * @param {string} lockName The lock name.\n *\n * @example\n * ```js\n * import { store as widgetStore } from '@wordpress/edit-widgets';\n * import { useDispatch } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * \tconst { lockWidgetSaving } = useDispatch( widgetStore );\n * \treturn (\n * \t\t<Button onClick={ () => lockWidgetSaving( 'lockName' ) }>\n * \t\t\t{ __( 'Lock Widget Saving' ) }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n * @return {Object} Action object\n */\nexport function lockWidgetSaving( lockName ) {\n\treturn {\n\t\ttype: 'LOCK_WIDGET_SAVING',\n\t\tlockName,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,MAAa,mBACV,IAAI,YACJ,EAAE,eAAgB;CACnB,MAAM,WAAW,eAAgB,IAAI,MAAO;CAC5C,SACE,SAAUA,OAAU,CAAA,CACpB,qBACA,MACA,WACA,UACA,EAAE,IAAI,SAAS,GAAG,GAClB,KACD;CACD,OAAO;AACR;;;;;;;;;AAUD,MAAa,8BAEZ,OAAQ,EAAE,QAAQ,UAAU,eAAgB;CAC3C,MAAM,oBAAoB,OAAO,qBAAqB;CACtD,IAAK,CAAE,mBAAmB,QACzB;CAED,IAAI;EACH,MAAM,SAAS,gBAAiB,iBAAkB;EAClD,SACE,SAAUC,KAAa,CAAA,CACvB,oBAAqB,GAAI,gBAAiB,GAAG,EAC7C,MAAM,WACP,CAAE;CACJ,SAAU,GAAI;EACb,SAAS,SAAUA,KAAa,CAAC,CAAC,kBAEjC,QAAS;;GAAI;EAAyB,GAAG,EAAE,OAAQ,GACnD,EACC,MAAM,WACP,CACD;CACD;AACD;;;;;;;;AASD,MAAa,mBACV,gBACF,OAAQ,EAAE,UAAU,eAAgB;CACnC,IAAI;EACH,KAAM,MAAM,cAAc,aACzB,MAAM,SAAS,eAAgB,WAAW,EAAG;CAE/C,UAAU;EAET,MAAM,SACJ,SAAUD,OAAU,CAAA,CACpB,iBACA,mBACA,MACA,yBACA,sBAAsB,CACvB;CACF;AACD;;;;;;;;AASD,MAAa,kBACV,iBACF,OAAQ,EAAE,QAAQ,eAAgB;CACjC,MAAM,UAAU,OAAO,W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from "@wordpress/block-editor";
5
5
  import { KIND, POST_TYPE, WIDGET_AREA_ENTITY_TYPE, buildWidgetAreaPostId, buildWidgetAreasQuery, buildWidgetsQuery } from "./utils.mjs";
6
6
  import { STORE_NAME } from "./constants.mjs";
7
7
  // packages/edit-widgets/src/store/selectors.js
8
+ /** @typedef {import('@wordpress/blocks').Block} Block */
8
9
  const EMPTY_INSERTION_POINT = {
9
10
  rootClientId: void 0,
10
11
  insertionIndex: void 0
@@ -55,7 +56,8 @@ const getWidgetAreaForWidgetId = createRegistrySelector((select) => (state, widg
55
56
  *
56
57
  * @param {string} clientId The client id of a block in a widget area.
57
58
  *
58
- * @return {WPBlock} The widget area block.
59
+ * @return {Block | null} The widget area block.
60
+ * @type {(state: Record<string, unknown>, clientId: string) => Block | null}
59
61
  */
60
62
  const getParentWidgetAreaBlock = createRegistrySelector((select) => (state, clientId) => {
61
63
  const { getBlock, getBlockName, getBlockParents } = select(store$1);
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.mjs","names":["coreStore","editWidgetsStoreName","blockEditorStore"],"sources":["../../src/store/selectors.js"],"sourcesContent":["import { createSelector, createRegistrySelector } from '@wordpress/data';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\tbuildWidgetsQuery,\n\tbuildWidgetAreasQuery,\n\tbuildWidgetAreaPostId,\n\tKIND,\n\tPOST_TYPE,\n\tWIDGET_AREA_ENTITY_TYPE,\n} from './utils';\nimport { STORE_NAME as editWidgetsStoreName } from './constants';\n\nconst EMPTY_INSERTION_POINT = {\n\trootClientId: undefined,\n\tinsertionIndex: undefined,\n};\n\n/**\n * Returns all API widgets.\n *\n * @return {Object[]} API List of widgets.\n */\nexport const getWidgets = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t() => {\n\t\t\tconst widgets = select( coreStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'widget',\n\t\t\t\tbuildWidgetsQuery()\n\t\t\t);\n\n\t\t\treturn (\n\t\t\t\t// Key widgets by their ID.\n\t\t\t\twidgets?.reduce(\n\t\t\t\t\t( allWidgets, widget ) => ( {\n\t\t\t\t\t\t...allWidgets,\n\t\t\t\t\t\t[ widget.id ]: widget,\n\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\t() => [\n\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'widget',\n\t\t\t\tbuildWidgetsQuery()\n\t\t\t),\n\t\t]\n\t)\n);\n\n/**\n * Returns API widget data for a particular widget ID.\n *\n * @param {number} id Widget ID.\n *\n * @return {Object} API widget data for a particular widget ID.\n */\nexport const getWidget = createRegistrySelector(\n\t( select ) => ( state, id ) => {\n\t\tconst widgets = select( editWidgetsStoreName ).getWidgets();\n\t\treturn widgets[ id ];\n\t}\n);\n\n/**\n * Returns all API widget areas.\n *\n * @return {Object[]} API List of widget areas.\n */\nexport const getWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst query = buildWidgetAreasQuery();\n\treturn select( coreStore ).getEntityRecords(\n\t\tKIND,\n\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\tquery\n\t);\n} );\n\n/**\n * Returns widgetArea containing a block identify by given widgetId\n *\n * @param {string} widgetId The ID of the widget.\n * @return {Object} Containing widget area.\n */\nexport const getWidgetAreaForWidgetId = createRegistrySelector(\n\t( select ) => ( state, widgetId ) => {\n\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\treturn widgetAreas.find( ( widgetArea ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tbuildWidgetAreaPostId( widgetArea.id )\n\t\t\t);\n\t\t\tconst blockWidgetIds = post.blocks.map( ( block ) =>\n\t\t\t\tgetWidgetIdFromBlock( block )\n\t\t\t);\n\t\t\treturn blockWidgetIds.includes( widgetId );\n\t\t} );\n\t}\n);\n\n/**\n * Given a child client id, returns the parent widget area block.\n *\n * @param {string} clientId The client id of a block in a widget area.\n *\n * @return {WPBlock} The widget area block.\n */\nexport const getParentWidgetAreaBlock = createRegistrySelector(\n\t( select ) => ( state, clientId ) => {\n\t\tconst { getBlock, getBlockName, getBlockParents } =\n\t\t\tselect( blockEditorStore );\n\t\tconst blockParents = getBlockParents( clientId );\n\t\tconst widgetAreaClientId = blockParents.find(\n\t\t\t( parentClientId ) =>\n\t\t\t\tgetBlockName( parentClientId ) === 'core/widget-area'\n\t\t);\n\t\treturn getBlock( widgetAreaClientId );\n\t}\n);\n\n/**\n * Returns all edited widget area entity records.\n *\n * @return {Object[]} List of edited widget area entity records.\n */\nexport const getEditedWidgetAreas = createRegistrySelector(\n\t( select ) => ( state, ids ) => {\n\t\tlet widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\tif ( ! widgetAreas ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( ids ) {\n\t\t\twidgetAreas = widgetAreas.filter( ( { id } ) =>\n\t\t\t\tids.includes( id )\n\t\t\t);\n\t\t}\n\t\treturn widgetAreas\n\t\t\t.filter( ( { id } ) =>\n\t\t\t\tselect( coreStore ).hasEditsForEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tPOST_TYPE,\n\t\t\t\t\tbuildWidgetAreaPostId( id )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.map( ( { id } ) =>\n\t\t\t\tselect( coreStore ).getEditedEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\t\tid\n\t\t\t\t)\n\t\t\t);\n\t}\n);\n\n/**\n * Returns all blocks representing reference widgets.\n *\n * @param {string} referenceWidgetName Optional. If given, only reference widgets with this name will be returned.\n * @return {Array} List of all blocks representing reference widgets\n */\nexport const getReferenceWidgetBlocks = createRegistrySelector(\n\t( select ) =>\n\t\t( state, referenceWidgetName = null ) => {\n\t\t\tconst results = [];\n\t\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\t\tfor ( const _widgetArea of widgetAreas ) {\n\t\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tPOST_TYPE,\n\t\t\t\t\tbuildWidgetAreaPostId( _widgetArea.id )\n\t\t\t\t);\n\t\t\t\tfor ( const block of post.blocks ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tblock.name === 'core/legacy-widget' &&\n\t\t\t\t\t\t( ! referenceWidgetName ||\n\t\t\t\t\t\t\tblock.attributes?.referenceWidgetName ===\n\t\t\t\t\t\t\t\treferenceWidgetName )\n\t\t\t\t\t) {\n\t\t\t\t\t\tresults.push( block );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn results;\n\t\t}\n);\n\n/**\n * Returns true if any widget area is currently being saved.\n *\n * @return {boolean} True if any widget area is currently being saved. False otherwise.\n */\nexport const isSavingWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst widgetAreasIds = select( editWidgetsStoreName )\n\t\t.getWidgetAreas()\n\t\t?.map( ( { id } ) => id );\n\tif ( ! widgetAreasIds ) {\n\t\treturn false;\n\t}\n\n\tfor ( const id of widgetAreasIds ) {\n\t\tconst isSaving = select( coreStore ).isSavingEntityRecord(\n\t\t\tKIND,\n\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tconst widgetIds = [\n\t\t...Object.keys( select( editWidgetsStoreName ).getWidgets() ),\n\t\tundefined, // account for new widgets without an ID\n\t];\n\tfor ( const id of widgetIds ) {\n\t\tconst isSaving = select( coreStore ).isSavingEntityRecord(\n\t\t\t'root',\n\t\t\t'widget',\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n} );\n\n/**\n * Gets whether the widget area is opened.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} clientId The clientId of the widget area.\n *\n * @return {boolean} True if the widget area is open.\n */\nexport const getIsWidgetAreaOpen = ( state, clientId ) => {\n\tconst { widgetAreasOpenState } = state;\n\treturn !! widgetAreasOpenState[ clientId ];\n};\n\n/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID and index to insert at.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tif ( typeof state.blockInserterPanel === 'boolean' ) {\n\t\treturn EMPTY_INSERTION_POINT;\n\t}\n\n\treturn state.blockInserterPanel;\n}\n\n/**\n * Returns true if a block can be inserted into a widget area.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} blockName The name of the block being inserted.\n *\n * @return {boolean} True if the block can be inserted in a widget area.\n */\nexport const canInsertBlockInWidgetArea = createRegistrySelector(\n\t( select ) => ( state, blockName ) => {\n\t\t// Widget areas are always top-level blocks, which getBlocks will return.\n\t\tconst widgetAreas = select( blockEditorStore ).getBlocks();\n\n\t\t// Makes an assumption that a block that can be inserted into one\n\t\t// widget area can be inserted into any widget area. Uses the first\n\t\t// widget area for testing whether the block can be inserted.\n\t\tconst [ firstWidgetArea ] = widgetAreas;\n\t\tif ( ! firstWidgetArea ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn select( blockEditorStore ).canInsertBlockType(\n\t\t\tblockName,\n\t\t\tfirstWidgetArea.clientId\n\t\t);\n\t}\n);\n\n/**\n * Returns true if the list view is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the list view is opened.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns whether widget saving is locked.\n *\n * @param {Object} state Global application state.\n *\n * @example\n * ```jsx\n * import { __ } from '@wordpress/i18n';\n * import { store as widgetStore } from '@wordpress/edit-widgets';\n * import { useSelect } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * \tconst isSavingLocked = useSelect(\n * \t\t( select ) => select( widgetStore ).isWidgetSavingLocked(),\n * \t\t[]\n * \t);\n *\n * \treturn isSavingLocked ? (\n * \t\t<p>{ __( 'Widget saving is locked' ) }</p>\n * \t) : (\n * \t\t<p>{ __( 'Widget saving is not locked' ) }</p>\n * \t);\n * };\n * ```\n *\n * @return {boolean} Is locked.\n */\nexport function isWidgetSavingLocked( state ) {\n\treturn Object.keys( state.widgetSavingLock ).length > 0;\n}\n"],"mappings":";;;;;;;AAcA,MAAM,wBAAwB;CAC7B,cAAc,KAAA;CACd,gBAAgB,KAAA;AACjB;;;;;;AAOA,MAAa,aAAa,wBAA0B,WACnD,qBACO;CAOL,OANgB,OAAQA,KAAU,CAAC,CAAC,iBACnC,QACA,UACA,kBAAkB,CAKZ,CAAC,EAAE,QACN,YAAY,YAAc;EAC3B,GAAG;GACD,OAAO,KAAM;CAChB,IACA,CAAC,CACF,KAAK,CAAC;AAER,SACM,CACL,OAAQA,KAAU,CAAC,CAAC,iBACnB,QACA,UACA,kBAAkB,CACnB,CACD,CACD,CACD;;;;;;;;AASA,MAAa,YAAY,wBACtB,YAAc,OAAO,OAAQ;CAE9B,OADgB,OAAQC,UAAqB,CAAC,CAAC,WAClC,CAAC,CAAE;AACjB,CACD;;;;;;AAOA,MAAa,iBAAiB,wBAA0B,iBAAkB;CACzE,MAAM,QAAQ,sBAAsB;CACpC,OAAO,OAAQD,KAAU,CAAC,CAAC,iBAC1B,MACA,yBACA,KACD;AACD,CAAE;;;;;;;AAQF,MAAa,2BAA2B,wBACrC,YAAc,OAAO,aAAc;CAEpC,OADoB,OAAQC,UAAqB,CAAC,CAAC,eAClC,CAAC,CAAC,MAAQ,eAAgB;EAS1C,OARa,OAAQD,KAAU,C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AAC,CACnD,eAAe,CAAC,EACf,KAAO,EAAE,SAAU,EAAG;CACzB,IAAK,CAAE,gBACN,OAAO;CAGR,KAAM,MAAM,MAAM,gBAMjB,IALiB,OAAQD,KAAU,CAAC,CAAC,qBACpC,MACA,yBACA,EAEW,GACX,OAAO;CAIT,MAAM,YAAY,CACjB,GAAG,OAAO,KAAM,OAAQC,UAAqB,CAAC,CAAC,WAAW,CAAE,GAC5D,KAAA,CACD;CACA,KAAM,MAAM,MAAM,WAMjB,IALiB,OAAQD,KAAU,CAAC,CAAC,qBACpC,QACA,UACA,EAEW,GACX,OAAO;CAIT,OAAO;AACR,CAAE;;;;;;;;;AAUF,MAAa,uBAAwB,OAAO,aAAc;CACzD,MAAM,EAAE,yBAAyB;CACjC,OAAO,CAAC,CAAE,qBAAsB;AACjC;;;;;;;;AASA,SAAgB,iBAAkB,OAAQ;CACzC,OAAO,CAAC,CAAE,MAAM;AACjB;;;;;;;;AASA,SAAgB,gCAAiC,OAAQ;CACxD,IAAK,OAAO,MAAM,uBAAuB,WACxC,OAAO;CAGR,OAAO,MAAM;AACd;;;;;;;;;AAUA,MAAa,6BAA6B,wBACvC,YAAc,OAAO,cAAe;CAOrC,MAAM,CAAE,mBALY,OAAQE,OAAiB,CAAC,CAAC,UAKT;CACtC,IAAK,CAAE,iBACN,OAAO;CAGR,OAAO,OAAQA,OAAiB,CAAC,CAAC,mBACjC,WACA,gBAAgB,QACjB;AACD,CACD;;;;;;;;AASA,SAAgB,iBAAkB,OAAQ;CACzC,OAAO,MAAM;AACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,qBAAsB,OAAQ;CAC7C,OAAO,OAAO,KAAM,MAAM,gBAAiB,CAAC,CAAC,SAAS;AACvD"}
1
+ {"version":3,"file":"selectors.mjs","names":["coreStore","editWidgetsStoreName","blockEditorStore"],"sources":["../../src/store/selectors.js"],"sourcesContent":["import { createSelector, createRegistrySelector } from '@wordpress/data';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\tbuildWidgetsQuery,\n\tbuildWidgetAreasQuery,\n\tbuildWidgetAreaPostId,\n\tKIND,\n\tPOST_TYPE,\n\tWIDGET_AREA_ENTITY_TYPE,\n} from './utils';\nimport { STORE_NAME as editWidgetsStoreName } from './constants';\n\n/** @typedef {import('@wordpress/blocks').Block} Block */\n\nconst EMPTY_INSERTION_POINT = {\n\trootClientId: undefined,\n\tinsertionIndex: undefined,\n};\n\n/**\n * Returns all API widgets.\n *\n * @return {Object[]} API List of widgets.\n */\nexport const getWidgets = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t() => {\n\t\t\tconst widgets = select( coreStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'widget',\n\t\t\t\tbuildWidgetsQuery()\n\t\t\t);\n\n\t\t\treturn (\n\t\t\t\t// Key widgets by their ID.\n\t\t\t\twidgets?.reduce(\n\t\t\t\t\t( allWidgets, widget ) => ( {\n\t\t\t\t\t\t...allWidgets,\n\t\t\t\t\t\t[ widget.id ]: widget,\n\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\t() => [\n\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'widget',\n\t\t\t\tbuildWidgetsQuery()\n\t\t\t),\n\t\t]\n\t)\n);\n\n/**\n * Returns API widget data for a particular widget ID.\n *\n * @param {number} id Widget ID.\n *\n * @return {Object} API widget data for a particular widget ID.\n */\nexport const getWidget = createRegistrySelector(\n\t( select ) => ( state, id ) => {\n\t\tconst widgets = select( editWidgetsStoreName ).getWidgets();\n\t\treturn widgets[ id ];\n\t}\n);\n\n/**\n * Returns all API widget areas.\n *\n * @return {Object[]} API List of widget areas.\n */\nexport const getWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst query = buildWidgetAreasQuery();\n\treturn select( coreStore ).getEntityRecords(\n\t\tKIND,\n\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\tquery\n\t);\n} );\n\n/**\n * Returns widgetArea containing a block identify by given widgetId\n *\n * @param {string} widgetId The ID of the widget.\n * @return {Object} Containing widget area.\n */\nexport const getWidgetAreaForWidgetId = createRegistrySelector(\n\t( select ) => ( state, widgetId ) => {\n\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\treturn widgetAreas.find( ( widgetArea ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tbuildWidgetAreaPostId( widgetArea.id )\n\t\t\t);\n\t\t\tconst blockWidgetIds = post.blocks.map( ( block ) =>\n\t\t\t\tgetWidgetIdFromBlock( block )\n\t\t\t);\n\t\t\treturn blockWidgetIds.includes( widgetId );\n\t\t} );\n\t}\n);\n\n/**\n * Given a child client id, returns the parent widget area block.\n *\n * @param {string} clientId The client id of a block in a widget area.\n *\n * @return {Block | null} The widget area block.\n * @type {(state: Record<string, unknown>, clientId: string) => Block | null}\n */\nexport const getParentWidgetAreaBlock = createRegistrySelector(\n\t( select ) => ( state, clientId ) => {\n\t\tconst { getBlock, getBlockName, getBlockParents } =\n\t\t\tselect( blockEditorStore );\n\t\tconst blockParents = getBlockParents( clientId );\n\t\tconst widgetAreaClientId = blockParents.find(\n\t\t\t( parentClientId ) =>\n\t\t\t\tgetBlockName( parentClientId ) === 'core/widget-area'\n\t\t);\n\t\treturn getBlock( widgetAreaClientId );\n\t}\n);\n\n/**\n * Returns all edited widget area entity records.\n *\n * @return {Object[]} List of edited widget area entity records.\n */\nexport const getEditedWidgetAreas = createRegistrySelector(\n\t( select ) => ( state, ids ) => {\n\t\tlet widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\tif ( ! widgetAreas ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( ids ) {\n\t\t\twidgetAreas = widgetAreas.filter( ( { id } ) =>\n\t\t\t\tids.includes( id )\n\t\t\t);\n\t\t}\n\t\treturn widgetAreas\n\t\t\t.filter( ( { id } ) =>\n\t\t\t\tselect( coreStore ).hasEditsForEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tPOST_TYPE,\n\t\t\t\t\tbuildWidgetAreaPostId( id )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.map( ( { id } ) =>\n\t\t\t\tselect( coreStore ).getEditedEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\t\tid\n\t\t\t\t)\n\t\t\t);\n\t}\n);\n\n/**\n * Returns all blocks representing reference widgets.\n *\n * @param {string} referenceWidgetName Optional. If given, only reference widgets with this name will be returned.\n * @return {Array} List of all blocks representing reference widgets\n */\nexport const getReferenceWidgetBlocks = createRegistrySelector(\n\t( select ) =>\n\t\t( state, referenceWidgetName = null ) => {\n\t\t\tconst results = [];\n\t\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\t\tfor ( const _widgetArea of widgetAreas ) {\n\t\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tPOST_TYPE,\n\t\t\t\t\tbuildWidgetAreaPostId( _widgetArea.id )\n\t\t\t\t);\n\t\t\t\tfor ( const block of post.blocks ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tblock.name === 'core/legacy-widget' &&\n\t\t\t\t\t\t( ! referenceWidgetName ||\n\t\t\t\t\t\t\tblock.attributes?.referenceWidgetName ===\n\t\t\t\t\t\t\t\treferenceWidgetName )\n\t\t\t\t\t) {\n\t\t\t\t\t\tresults.push( block );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn results;\n\t\t}\n);\n\n/**\n * Returns true if any widget area is currently being saved.\n *\n * @return {boolean} True if any widget area is currently being saved. False otherwise.\n */\nexport const isSavingWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst widgetAreasIds = select( editWidgetsStoreName )\n\t\t.getWidgetAreas()\n\t\t?.map( ( { id } ) => id );\n\tif ( ! widgetAreasIds ) {\n\t\treturn false;\n\t}\n\n\tfor ( const id of widgetAreasIds ) {\n\t\tconst isSaving = select( coreStore ).isSavingEntityRecord(\n\t\t\tKIND,\n\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tconst widgetIds = [\n\t\t...Object.keys( select( editWidgetsStoreName ).getWidgets() ),\n\t\tundefined, // account for new widgets without an ID\n\t];\n\tfor ( const id of widgetIds ) {\n\t\tconst isSaving = select( coreStore ).isSavingEntityRecord(\n\t\t\t'root',\n\t\t\t'widget',\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n} );\n\n/**\n * Gets whether the widget area is opened.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} clientId The clientId of the widget area.\n *\n * @return {boolean} True if the widget area is open.\n */\nexport const getIsWidgetAreaOpen = ( state, clientId ) => {\n\tconst { widgetAreasOpenState } = state;\n\treturn !! widgetAreasOpenState[ clientId ];\n};\n\n/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID and index to insert at.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tif ( typeof state.blockInserterPanel === 'boolean' ) {\n\t\treturn EMPTY_INSERTION_POINT;\n\t}\n\n\treturn state.blockInserterPanel;\n}\n\n/**\n * Returns true if a block can be inserted into a widget area.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} blockName The name of the block being inserted.\n *\n * @return {boolean} True if the block can be inserted in a widget area.\n */\nexport const canInsertBlockInWidgetArea = createRegistrySelector(\n\t( select ) => ( state, blockName ) => {\n\t\t// Widget areas are always top-level blocks, which getBlocks will return.\n\t\tconst widgetAreas = select( blockEditorStore ).getBlocks();\n\n\t\t// Makes an assumption that a block that can be inserted into one\n\t\t// widget area can be inserted into any widget area. Uses the first\n\t\t// widget area for testing whether the block can be inserted.\n\t\tconst [ firstWidgetArea ] = widgetAreas;\n\t\tif ( ! firstWidgetArea ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn select( blockEditorStore ).canInsertBlockType(\n\t\t\tblockName,\n\t\t\tfirstWidgetArea.clientId\n\t\t);\n\t}\n);\n\n/**\n * Returns true if the list view is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the list view is opened.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns whether widget saving is locked.\n *\n * @param {Object} state Global application state.\n *\n * @example\n * ```jsx\n * import { __ } from '@wordpress/i18n';\n * import { store as widgetStore } from '@wordpress/edit-widgets';\n * import { useSelect } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * \tconst isSavingLocked = useSelect(\n * \t\t( select ) => select( widgetStore ).isWidgetSavingLocked(),\n * \t\t[]\n * \t);\n *\n * \treturn isSavingLocked ? (\n * \t\t<p>{ __( 'Widget saving is locked' ) }</p>\n * \t) : (\n * \t\t<p>{ __( 'Widget saving is not locked' ) }</p>\n * \t);\n * };\n * ```\n *\n * @return {boolean} Is locked.\n */\nexport function isWidgetSavingLocked( state ) {\n\treturn Object.keys( state.widgetSavingLock ).length > 0;\n}\n"],"mappings":";;;;;;;;AAgBA,MAAM,wBAAwB;CAC7B,cAAc,KAAA;CACd,gBAAgB,KAAA;AACjB;;;;;;AAOA,MAAa,aAAa,wBAA0B,WACnD,qBACO;CAOL,OANgB,OAAQA,KAAU,CAAC,CAAC,iBACnC,QACA,UACA,kBAAkB,CAKZ,CAAC,EAAE,QACN,YAAY,YAAc;EAC3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