@wordpress/block-editor 12.14.0 → 12.15.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 (240) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +1 -1
  3. package/build/components/block-list/block.native.js +2 -0
  4. package/build/components/block-list/block.native.js.map +1 -1
  5. package/build/components/block-parent-selector/index.js +1 -1
  6. package/build/components/block-parent-selector/index.js.map +1 -1
  7. package/build/components/block-pattern-setup/index.js +25 -16
  8. package/build/components/block-pattern-setup/index.js.map +1 -1
  9. package/build/components/block-pattern-setup/setup-toolbar.js +4 -2
  10. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  11. package/build/components/block-patterns-list/index.js +36 -19
  12. package/build/components/block-patterns-list/index.js.map +1 -1
  13. package/build/components/block-rename/index.js +28 -0
  14. package/build/components/block-rename/index.js.map +1 -0
  15. package/build/components/block-rename/is-empty-string.js +10 -0
  16. package/build/components/block-rename/is-empty-string.js.map +1 -0
  17. package/build/components/block-rename/modal.js +87 -0
  18. package/build/components/block-rename/modal.js.map +1 -0
  19. package/build/components/block-rename/rename-control.js +74 -0
  20. package/build/components/block-rename/rename-control.js.map +1 -0
  21. package/build/components/block-rename/use-block-rename.js +17 -0
  22. package/build/components/block-rename/use-block-rename.js.map +1 -0
  23. package/build/components/block-settings-menu/block-settings-dropdown.js +33 -20
  24. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  25. package/build/components/block-settings-menu-controls/index.js +7 -0
  26. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  27. package/build/components/block-toolbar/block-toolbar-menu.native.js +1 -1
  28. package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
  29. package/build/components/block-types-list/index.js +6 -2
  30. package/build/components/block-types-list/index.js.map +1 -1
  31. package/build/components/date-format-picker/index.js +8 -1
  32. package/build/components/date-format-picker/index.js.map +1 -1
  33. package/build/components/global-styles/advanced-panel.js +1 -1
  34. package/build/components/global-styles/advanced-panel.js.map +1 -1
  35. package/build/components/image-size-control/index.js +0 -5
  36. package/build/components/image-size-control/index.js.map +1 -1
  37. package/build/components/inner-blocks/index.js +3 -1
  38. package/build/components/inner-blocks/index.js.map +1 -1
  39. package/build/components/inner-blocks/warning-max-depth-exceeded.native.js +29 -31
  40. package/build/components/inner-blocks/warning-max-depth-exceeded.native.js.map +1 -1
  41. package/build/components/inserter/block-patterns-explorer/pattern-list.js +1 -1
  42. package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  43. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +1 -1
  44. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  45. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +1 -1
  46. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
  47. package/build/components/inserter/block-patterns-tab/utils.js +3 -4
  48. package/build/components/inserter/block-patterns-tab/utils.js.map +1 -1
  49. package/build/components/inserter/hooks/use-patterns-state.js +2 -1
  50. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  51. package/build/components/inserter-listbox/index.js +11 -6
  52. package/build/components/inserter-listbox/index.js.map +1 -1
  53. package/build/components/inserter-listbox/item.js +24 -23
  54. package/build/components/inserter-listbox/item.js.map +1 -1
  55. package/build/components/inserter-listbox/row.js +5 -5
  56. package/build/components/inserter-listbox/row.js.map +1 -1
  57. package/build/components/list-view/use-list-view-expand-selected-item.js +2 -3
  58. package/build/components/list-view/use-list-view-expand-selected-item.js.map +1 -1
  59. package/build/components/preview-options/index.js +4 -2
  60. package/build/components/preview-options/index.js.map +1 -1
  61. package/build/components/rich-text/index.native.js +1 -1
  62. package/build/components/rich-text/index.native.js.map +1 -1
  63. package/build/components/rich-text/native/index.native.js +34 -3
  64. package/build/components/rich-text/native/index.native.js.map +1 -1
  65. package/build/components/rich-text/use-input-rules.js +30 -1
  66. package/build/components/rich-text/use-input-rules.js.map +1 -1
  67. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  68. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  69. package/build/components/use-block-drop-zone/index.js +4 -1
  70. package/build/components/use-block-drop-zone/index.js.map +1 -1
  71. package/build/components/use-moving-animation/index.js +2 -1
  72. package/build/components/use-moving-animation/index.js.map +1 -1
  73. package/build/components/use-settings/index.js +2 -2
  74. package/build/components/use-settings/index.js.map +1 -1
  75. package/build/hooks/block-renaming.js +42 -0
  76. package/build/hooks/block-renaming.js.map +1 -1
  77. package/build/hooks/custom-fields.js +53 -48
  78. package/build/hooks/custom-fields.js.map +1 -1
  79. package/build/hooks/index.js +0 -1
  80. package/build/hooks/index.js.map +1 -1
  81. package/build/hooks/layout.js +13 -7
  82. package/build/hooks/layout.js.map +1 -1
  83. package/build/layouts/constrained.js +4 -3
  84. package/build/layouts/constrained.js.map +1 -1
  85. package/build/store/selectors.js +2 -0
  86. package/build/store/selectors.js.map +1 -1
  87. package/build/utils/transform-styles/index.js +26 -6
  88. package/build/utils/transform-styles/index.js.map +1 -1
  89. package/build-module/components/block-list/block.native.js +2 -0
  90. package/build-module/components/block-list/block.native.js.map +1 -1
  91. package/build-module/components/block-parent-selector/index.js +1 -1
  92. package/build-module/components/block-parent-selector/index.js.map +1 -1
  93. package/build-module/components/block-pattern-setup/index.js +24 -15
  94. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  95. package/build-module/components/block-pattern-setup/setup-toolbar.js +4 -2
  96. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  97. package/build-module/components/block-patterns-list/index.js +36 -19
  98. package/build-module/components/block-patterns-list/index.js.map +1 -1
  99. package/build-module/components/block-rename/index.js +4 -0
  100. package/build-module/components/block-rename/index.js.map +1 -0
  101. package/build-module/components/block-rename/is-empty-string.js +4 -0
  102. package/build-module/components/block-rename/is-empty-string.js.map +1 -0
  103. package/build-module/components/block-rename/modal.js +79 -0
  104. package/build-module/components/block-rename/modal.js.map +1 -0
  105. package/build-module/components/block-rename/rename-control.js +66 -0
  106. package/build-module/components/block-rename/rename-control.js.map +1 -0
  107. package/build-module/components/block-rename/use-block-rename.js +10 -0
  108. package/build-module/components/block-rename/use-block-rename.js.map +1 -0
  109. package/build-module/components/block-settings-menu/block-settings-dropdown.js +34 -21
  110. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  111. package/build-module/components/block-settings-menu-controls/index.js +7 -0
  112. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  113. package/build-module/components/block-toolbar/block-toolbar-menu.native.js +1 -1
  114. package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
  115. package/build-module/components/block-types-list/index.js +6 -2
  116. package/build-module/components/block-types-list/index.js.map +1 -1
  117. package/build-module/components/date-format-picker/index.js +8 -1
  118. package/build-module/components/date-format-picker/index.js.map +1 -1
  119. package/build-module/components/global-styles/advanced-panel.js +1 -1
  120. package/build-module/components/global-styles/advanced-panel.js.map +1 -1
  121. package/build-module/components/image-size-control/index.js +0 -5
  122. package/build-module/components/image-size-control/index.js.map +1 -1
  123. package/build-module/components/inner-blocks/index.js +3 -1
  124. package/build-module/components/inner-blocks/index.js.map +1 -1
  125. package/build-module/components/inner-blocks/warning-max-depth-exceeded.native.js +30 -32
  126. package/build-module/components/inner-blocks/warning-max-depth-exceeded.native.js.map +1 -1
  127. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
  128. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  129. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -4
  130. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  131. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +2 -2
  132. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
  133. package/build-module/components/inserter/block-patterns-tab/utils.js +3 -4
  134. package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -1
  135. package/build-module/components/inserter/hooks/use-patterns-state.js +2 -1
  136. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  137. package/build-module/components/inserter-listbox/index.js +13 -8
  138. package/build-module/components/inserter-listbox/index.js.map +1 -1
  139. package/build-module/components/inserter-listbox/item.js +25 -23
  140. package/build-module/components/inserter-listbox/item.js.map +1 -1
  141. package/build-module/components/inserter-listbox/row.js +6 -5
  142. package/build-module/components/inserter-listbox/row.js.map +1 -1
  143. package/build-module/components/list-view/use-list-view-expand-selected-item.js +2 -3
  144. package/build-module/components/list-view/use-list-view-expand-selected-item.js.map +1 -1
  145. package/build-module/components/preview-options/index.js +4 -2
  146. package/build-module/components/preview-options/index.js.map +1 -1
  147. package/build-module/components/rich-text/index.native.js +1 -1
  148. package/build-module/components/rich-text/index.native.js.map +1 -1
  149. package/build-module/components/rich-text/native/index.native.js +34 -3
  150. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  151. package/build-module/components/rich-text/use-input-rules.js +31 -2
  152. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  153. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  154. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  155. package/build-module/components/use-block-drop-zone/index.js +4 -1
  156. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  157. package/build-module/components/use-moving-animation/index.js +2 -1
  158. package/build-module/components/use-moving-animation/index.js.map +1 -1
  159. package/build-module/components/use-settings/index.js +2 -2
  160. package/build-module/components/use-settings/index.js.map +1 -1
  161. package/build-module/hooks/block-renaming.js +40 -0
  162. package/build-module/hooks/block-renaming.js.map +1 -1
  163. package/build-module/hooks/custom-fields.js +53 -48
  164. package/build-module/hooks/custom-fields.js.map +1 -1
  165. package/build-module/hooks/index.js +0 -1
  166. package/build-module/hooks/index.js.map +1 -1
  167. package/build-module/hooks/layout.js +13 -7
  168. package/build-module/hooks/layout.js.map +1 -1
  169. package/build-module/layouts/constrained.js +4 -3
  170. package/build-module/layouts/constrained.js.map +1 -1
  171. package/build-module/store/selectors.js +2 -0
  172. package/build-module/store/selectors.js.map +1 -1
  173. package/build-module/utils/transform-styles/index.js +24 -7
  174. package/build-module/utils/transform-styles/index.js.map +1 -1
  175. package/build-style/content-rtl.css +6 -6
  176. package/build-style/content.css +6 -6
  177. package/build-style/style-rtl.css +10 -5
  178. package/build-style/style.css +10 -5
  179. package/package.json +31 -31
  180. package/src/components/block-list/block.native.js +2 -0
  181. package/src/components/block-parent-selector/index.js +1 -1
  182. package/src/components/block-pattern-setup/index.js +38 -22
  183. package/src/components/block-pattern-setup/setup-toolbar.js +2 -0
  184. package/src/components/block-pattern-setup/style.scss +4 -1
  185. package/src/components/block-patterns-list/README.md +4 -4
  186. package/src/components/block-patterns-list/index.js +60 -34
  187. package/src/components/block-patterns-list/style.scss +7 -0
  188. package/src/components/block-rename/index.js +3 -0
  189. package/src/components/block-rename/is-empty-string.js +3 -0
  190. package/src/components/block-rename/modal.js +115 -0
  191. package/src/components/block-rename/rename-control.js +80 -0
  192. package/src/components/block-rename/use-block-rename.js +10 -0
  193. package/src/components/block-settings-menu/block-settings-dropdown.js +38 -34
  194. package/src/components/block-settings-menu-controls/index.js +9 -0
  195. package/src/components/block-toolbar/block-toolbar-menu.native.js +1 -4
  196. package/src/components/block-types-list/index.js +5 -4
  197. package/src/components/button-block-appender/content.scss +2 -2
  198. package/src/components/date-format-picker/index.js +7 -0
  199. package/src/components/editable-text/README.md +0 -36
  200. package/src/components/global-styles/advanced-panel.js +1 -1
  201. package/src/components/image-size-control/index.js +0 -6
  202. package/src/components/inner-blocks/index.js +6 -2
  203. package/src/components/inner-blocks/warning-max-depth-exceeded.native.js +57 -33
  204. package/src/components/inserter/block-patterns-explorer/pattern-list.js +5 -1
  205. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +7 -3
  206. package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +6 -1
  207. package/src/components/inserter/block-patterns-tab/utils.js +6 -4
  208. package/src/components/inserter/hooks/use-patterns-state.js +3 -1
  209. package/src/components/inserter-listbox/index.js +11 -7
  210. package/src/components/inserter-listbox/item.js +11 -12
  211. package/src/components/inserter-listbox/row.js +6 -12
  212. package/src/components/list-view/use-list-view-expand-selected-item.js +7 -8
  213. package/src/components/plain-text/README.md +0 -28
  214. package/src/components/preview-options/index.js +2 -0
  215. package/src/components/rich-text/README.md +0 -58
  216. package/src/components/rich-text/index.native.js +1 -1
  217. package/src/components/rich-text/native/index.native.js +45 -2
  218. package/src/components/rich-text/use-input-rules.js +30 -2
  219. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  220. package/src/components/url-input/README.md +1 -74
  221. package/src/components/use-block-drop-zone/index.js +4 -1
  222. package/src/components/use-moving-animation/index.js +1 -1
  223. package/src/components/use-settings/index.js +2 -2
  224. package/src/components/use-settings/test/index.js +1 -1
  225. package/src/hooks/block-renaming.js +47 -0
  226. package/src/hooks/custom-fields.js +68 -65
  227. package/src/hooks/index.js +0 -1
  228. package/src/hooks/layout.js +12 -8
  229. package/src/hooks/test/__snapshots__/align.native.js.snap +5 -5
  230. package/src/layouts/constrained.js +57 -50
  231. package/src/store/selectors.js +2 -0
  232. package/src/style.scss +1 -1
  233. package/src/utils/test/transform-styles.js +49 -0
  234. package/src/utils/transform-styles/index.js +39 -13
  235. package/build/hooks/block-rename-ui.js +0 -167
  236. package/build/hooks/block-rename-ui.js.map +0 -1
  237. package/build-module/hooks/block-rename-ui.js +0 -159
  238. package/build-module/hooks/block-rename-ui.js.map +0 -1
  239. package/src/hooks/block-rename-ui.js +0 -228
  240. /package/src/{hooks/block-rename-ui.scss → components/block-rename/style.scss} +0 -0
@@ -145,7 +145,8 @@ const ForwardedInnerBlocks = (0, _element.forwardRef)((props, ref) => {
145
145
  function useInnerBlocksProps(props = {}, options = {}) {
146
146
  const {
147
147
  __unstableDisableLayoutClassNames,
148
- __unstableDisableDropZone
148
+ __unstableDisableDropZone,
149
+ dropZoneElement
149
150
  } = options;
150
151
  const {
151
152
  clientId,
@@ -174,6 +175,7 @@ function useInnerBlocksProps(props = {}, options = {}) {
174
175
  };
175
176
  }, [clientId, isSmallScreen]);
176
177
  const blockDropZoneRef = (0, _useBlockDropZone.default)({
178
+ dropZoneElement,
177
179
  rootClientId: clientId
178
180
  });
179
181
  const ref = (0, _compose.useMergeRefs)([props.ref, __unstableDisableDropZone ? null : blockDropZoneRef]);
@@ -1 +1 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_compose","_element","_data","_blocks","_buttonBlockAppender","_defaultBlockAppender","_useNestedSettingsUpdate","_useInnerBlockTemplateSync","_useBlockContext","_blockList","_blockContext","_context","_useBlockSync","_store","_useBlockDropZone","_useSettings","EMPTY_OBJECT","UncontrolledInnerBlocks","props","clientId","allowedBlocks","prioritizedInserterBlocks","defaultBlock","directInsert","__experimentalDefaultBlock","__experimentalDirectInsert","template","templateLock","wrapperRef","templateInsertUpdatesSelection","__experimentalCaptureToolbars","captureToolbars","__experimentalAppenderTagName","renderAppender","orientation","placeholder","layout","useNestedSettingsUpdate","useInnerBlockTemplateSync","context","useBlockContext","name","useSelect","select","blockEditorStore","getBlock","defaultLayoutBlockSupport","getBlockSupport","allowSizingOnChildren","defaultLayout","useSettings","usedLayout","memoedLayout","useMemo","_react","createElement","BlockContextProvider","value","BlockListItems","rootClientId","ControlledInnerBlocks","useBlockSync","ForwardedInnerBlocks","forwardRef","ref","innerBlocksProps","useInnerBlocksProps","className","options","__unstableDisableLayoutClassNames","__unstableDisableDropZone","__unstableLayoutClassNames","layoutClassNames","useBlockEditContext","isSmallScreen","useViewportMatch","hasOverlay","getBlockName","isBlockSelected","hasSelectedInnerBlock","__unstableGetEditorMode","blockName","enableClickThrough","blocksStore","hasBlockSupport","blockDropZoneRef","useBlockDropZone","useMergeRefs","InnerBlocks","onChange","classnames","children","save","getInnerBlocksProps","DefaultBlockAppender","ButtonBlockAppender","Content","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/inner-blocks/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch, useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockSupport,\n\tstore as blocksStore,\n\t__unstableGetInnerBlocksProps as getInnerBlocksProps,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport ButtonBlockAppender from './button-block-appender';\nimport DefaultBlockAppender from './default-block-appender';\nimport useNestedSettingsUpdate from './use-nested-settings-update';\nimport useInnerBlockTemplateSync from './use-inner-block-template-sync';\nimport useBlockContext from './use-block-context';\nimport { BlockListItems } from '../block-list';\nimport { BlockContextProvider } from '../block-context';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useBlockSync from '../provider/use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDropZone from '../use-block-drop-zone';\nimport { useSettings } from '../use-settings';\n\nconst EMPTY_OBJECT = {};\n\n/**\n * InnerBlocks is a component which allows a single block to have multiple blocks\n * as children. The UncontrolledInnerBlocks component is used whenever the inner\n * blocks are not controlled by another entity. In other words, it is normally\n * used for inner blocks in the post editor\n *\n * @param {Object} props The component props.\n */\nfunction UncontrolledInnerBlocks( props ) {\n\tconst {\n\t\tclientId,\n\t\tallowedBlocks,\n\t\tprioritizedInserterBlocks,\n\t\tdefaultBlock,\n\t\tdirectInsert,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\twrapperRef,\n\t\ttemplateInsertUpdatesSelection,\n\t\t__experimentalCaptureToolbars: captureToolbars,\n\t\t__experimentalAppenderTagName,\n\t\trenderAppender,\n\t\torientation,\n\t\tplaceholder,\n\t\tlayout,\n\t} = props;\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tallowedBlocks,\n\t\tprioritizedInserterBlocks,\n\t\tdefaultBlock,\n\t\tdirectInsert,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\tlayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\tconst context = useBlockContext( clientId );\n\tconst name = useSelect(\n\t\t( select ) => {\n\t\t\treturn select( blockEditorStore ).getBlock( clientId )?.name;\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst defaultLayoutBlockSupport =\n\t\tgetBlockSupport( name, 'layout' ) ||\n\t\tgetBlockSupport( name, '__experimentalLayout' ) ||\n\t\tEMPTY_OBJECT;\n\n\tconst { allowSizingOnChildren = false } = defaultLayoutBlockSupport;\n\n\tconst [ defaultLayout ] = useSettings( 'layout' );\n\n\tconst usedLayout = layout || defaultLayoutBlockSupport;\n\n\tconst memoedLayout = useMemo(\n\t\t() => ( {\n\t\t\t// Default layout will know about any content/wide size defined by the theme.\n\t\t\t...defaultLayout,\n\t\t\t...usedLayout,\n\t\t\t...( allowSizingOnChildren && {\n\t\t\t\tallowSizingOnChildren: true,\n\t\t\t} ),\n\t\t} ),\n\t\t[ defaultLayout, usedLayout, allowSizingOnChildren ]\n\t);\n\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<BlockContextProvider value={ context }>\n\t\t\t<BlockListItems\n\t\t\t\trootClientId={ clientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t__experimentalAppenderTagName={ __experimentalAppenderTagName }\n\t\t\t\tlayout={ memoedLayout }\n\t\t\t\twrapperRef={ wrapperRef }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t/>\n\t\t</BlockContextProvider>\n\t);\n}\n\n/**\n * The controlled inner blocks component wraps the uncontrolled inner blocks\n * component with the blockSync hook. This keeps the innerBlocks of the block in\n * the block-editor store in sync with the blocks of the controlling entity. An\n * example of an inner block controller is a template part block, which provides\n * its own blocks from the template part entity data source.\n *\n * @param {Object} props The component props.\n */\nfunction ControlledInnerBlocks( props ) {\n\tuseBlockSync( props );\n\treturn <UncontrolledInnerBlocks { ...props } />;\n}\n\nconst ForwardedInnerBlocks = forwardRef( ( props, ref ) => {\n\tconst innerBlocksProps = useInnerBlocksProps( { ref }, props );\n\treturn (\n\t\t<div className=\"block-editor-inner-blocks\">\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n} );\n\n/**\n * This hook is used to lightly mark an element as an inner blocks wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * an inner blocks wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Optional. Inner blocks options.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport function useInnerBlocksProps( props = {}, options = {} ) {\n\tconst { __unstableDisableLayoutClassNames, __unstableDisableDropZone } =\n\t\toptions;\n\tconst {\n\t\tclientId,\n\t\tlayout = null,\n\t\t__unstableLayoutClassNames: layoutClassNames = '',\n\t} = useBlockEditContext();\n\tconst isSmallScreen = useViewportMatch( 'medium', '<' );\n\tconst { __experimentalCaptureToolbars, hasOverlay } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tisBlockSelected,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst enableClickThrough =\n\t\t\t\t__unstableGetEditorMode() === 'navigation' || isSmallScreen;\n\t\t\treturn {\n\t\t\t\t__experimentalCaptureToolbars: select(\n\t\t\t\t\tblocksStore\n\t\t\t\t).hasBlockSupport(\n\t\t\t\t\tblockName,\n\t\t\t\t\t'__experimentalExposeControlsToChildren',\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasOverlay:\n\t\t\t\t\tblockName !== 'core/template' &&\n\t\t\t\t\t! isBlockSelected( clientId ) &&\n\t\t\t\t\t! hasSelectedInnerBlock( clientId, true ) &&\n\t\t\t\t\tenableClickThrough,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isSmallScreen ]\n\t);\n\n\tconst blockDropZoneRef = useBlockDropZone( {\n\t\trootClientId: clientId,\n\t} );\n\n\tconst ref = useMergeRefs( [\n\t\tprops.ref,\n\t\t__unstableDisableDropZone ? null : blockDropZoneRef,\n\t] );\n\n\tconst innerBlocksProps = {\n\t\t__experimentalCaptureToolbars,\n\t\tlayout,\n\t\t...options,\n\t};\n\tconst InnerBlocks =\n\t\tinnerBlocksProps.value && innerBlocksProps.onChange\n\t\t\t? ControlledInnerBlocks\n\t\t\t: UncontrolledInnerBlocks;\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: classnames(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-list__layout',\n\t\t\t__unstableDisableLayoutClassNames ? '' : layoutClassNames,\n\t\t\t{\n\t\t\t\t'has-overlay': hasOverlay,\n\t\t\t}\n\t\t),\n\t\tchildren: clientId ? (\n\t\t\t<InnerBlocks { ...innerBlocksProps } clientId={ clientId } />\n\t\t) : (\n\t\t\t<BlockListItems { ...options } />\n\t\t),\n\t};\n}\n\nuseInnerBlocksProps.save = getInnerBlocksProps;\n\n// Expose default appender placeholders as components.\nForwardedInnerBlocks.DefaultBlockAppender = DefaultBlockAppender;\nForwardedInnerBlocks.ButtonBlockAppender = ButtonBlockAppender;\n\nForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/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ACDe,QAAQ,EAAExE,QAAQ,GACjB,IAAAmC,MAAA,CAAAC,aAAA,EAACiC,WAAW;MAAA,GAAMvB,gBAAgB;MAAG9C,QAAQ,EAAGA;IAAU,CAAE,CAAC,GAE7D,IAAAmC,MAAA,CAAAC,aAAA,EAAC9C,UAAA,CAAAiD,cAAc;MAAA,GAAMU;IAAO,CAAI;EAElC,CAAC;AACF;AAEAF,mBAAmB,CAAC0B,IAAI,GAAGC,qCAAmB;;AAE9C;AACA/B,oBAAoB,CAACgC,oBAAoB,GAAGA,6BAAoB;AAChEhC,oBAAoB,CAACiC,mBAAmB,GAAGA,4BAAmB;AAE9DjC,oBAAoB,CAACkC,OAAO,GAAG,MAAM9B,mBAAmB,CAAC0B,IAAI,CAAC,CAAC,CAACD,QAAQ;;AAExE;AACA;AACA;AAFA,IAAAM,QAAA,GAGenC,oBAAoB;AAAAoC,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_classnames","_interopRequireDefault","require","_compose","_element","_data","_blocks","_buttonBlockAppender","_defaultBlockAppender","_useNestedSettingsUpdate","_useInnerBlockTemplateSync","_useBlockContext","_blockList","_blockContext","_context","_useBlockSync","_store","_useBlockDropZone","_useSettings","EMPTY_OBJECT","UncontrolledInnerBlocks","props","clientId","allowedBlocks","prioritizedInserterBlocks","defaultBlock","directInsert","__experimentalDefaultBlock","__experimentalDirectInsert","template","templateLock","wrapperRef","templateInsertUpdatesSelection","__experimentalCaptureToolbars","captureToolbars","__experimentalAppenderTagName","renderAppender","orientation","placeholder","layout","useNestedSettingsUpdate","useInnerBlockTemplateSync","context","useBlockContext","name","useSelect","select","blockEditorStore","getBlock","defaultLayoutBlockSupport","getBlockSupport","allowSizingOnChildren","defaultLayout","useSettings","usedLayout","memoedLayout","useMemo","_react","createElement","BlockContextProvider","value","BlockListItems","rootClientId","ControlledInnerBlocks","useBlockSync","ForwardedInnerBlocks","forwardRef","ref","innerBlocksProps","useInnerBlocksProps","className","options","__unstableDisableLayoutClassNames","__unstableDisableDropZone","dropZoneElement","__unstableLayoutClassNames","layoutClassNames","useBlockEditContext","isSmallScreen","useViewportMatch","hasOverlay","getBlockName","isBlockSelected","hasSelectedInnerBlock","__unstableGetEditorMode","blockName","enableClickThrough","blocksStore","hasBlockSupport","blockDropZoneRef","useBlockDropZone","useMergeRefs","InnerBlocks","onChange","classnames","children","save","getInnerBlocksProps","DefaultBlockAppender","ButtonBlockAppender","Content","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/inner-blocks/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch, useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockSupport,\n\tstore as blocksStore,\n\t__unstableGetInnerBlocksProps as getInnerBlocksProps,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport ButtonBlockAppender from './button-block-appender';\nimport DefaultBlockAppender from './default-block-appender';\nimport useNestedSettingsUpdate from './use-nested-settings-update';\nimport useInnerBlockTemplateSync from './use-inner-block-template-sync';\nimport useBlockContext from './use-block-context';\nimport { BlockListItems } from '../block-list';\nimport { BlockContextProvider } from '../block-context';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useBlockSync from '../provider/use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDropZone from '../use-block-drop-zone';\nimport { useSettings } from '../use-settings';\n\nconst EMPTY_OBJECT = {};\n\n/**\n * InnerBlocks is a component which allows a single block to have multiple blocks\n * as children. The UncontrolledInnerBlocks component is used whenever the inner\n * blocks are not controlled by another entity. In other words, it is normally\n * used for inner blocks in the post editor\n *\n * @param {Object} props The component props.\n */\nfunction UncontrolledInnerBlocks( props ) {\n\tconst {\n\t\tclientId,\n\t\tallowedBlocks,\n\t\tprioritizedInserterBlocks,\n\t\tdefaultBlock,\n\t\tdirectInsert,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\twrapperRef,\n\t\ttemplateInsertUpdatesSelection,\n\t\t__experimentalCaptureToolbars: captureToolbars,\n\t\t__experimentalAppenderTagName,\n\t\trenderAppender,\n\t\torientation,\n\t\tplaceholder,\n\t\tlayout,\n\t} = props;\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tallowedBlocks,\n\t\tprioritizedInserterBlocks,\n\t\tdefaultBlock,\n\t\tdirectInsert,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\tlayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\tconst context = useBlockContext( clientId );\n\tconst name = useSelect(\n\t\t( select ) => {\n\t\t\treturn select( blockEditorStore ).getBlock( clientId )?.name;\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst defaultLayoutBlockSupport =\n\t\tgetBlockSupport( name, 'layout' ) ||\n\t\tgetBlockSupport( name, '__experimentalLayout' ) ||\n\t\tEMPTY_OBJECT;\n\n\tconst { allowSizingOnChildren = false } = defaultLayoutBlockSupport;\n\n\tconst [ defaultLayout ] = useSettings( 'layout' );\n\n\tconst usedLayout = layout || defaultLayoutBlockSupport;\n\n\tconst memoedLayout = useMemo(\n\t\t() => ( {\n\t\t\t// Default layout will know about any content/wide size defined by the theme.\n\t\t\t...defaultLayout,\n\t\t\t...usedLayout,\n\t\t\t...( allowSizingOnChildren && {\n\t\t\t\tallowSizingOnChildren: true,\n\t\t\t} ),\n\t\t} ),\n\t\t[ defaultLayout, usedLayout, allowSizingOnChildren ]\n\t);\n\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<BlockContextProvider value={ context }>\n\t\t\t<BlockListItems\n\t\t\t\trootClientId={ clientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t__experimentalAppenderTagName={ __experimentalAppenderTagName }\n\t\t\t\tlayout={ memoedLayout }\n\t\t\t\twrapperRef={ wrapperRef }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t/>\n\t\t</BlockContextProvider>\n\t);\n}\n\n/**\n * The controlled inner blocks component wraps the uncontrolled inner blocks\n * component with the blockSync hook. This keeps the innerBlocks of the block in\n * the block-editor store in sync with the blocks of the controlling entity. An\n * example of an inner block controller is a template part block, which provides\n * its own blocks from the template part entity data source.\n *\n * @param {Object} props The component props.\n */\nfunction ControlledInnerBlocks( props ) {\n\tuseBlockSync( props );\n\treturn <UncontrolledInnerBlocks { ...props } />;\n}\n\nconst ForwardedInnerBlocks = forwardRef( ( props, ref ) => {\n\tconst innerBlocksProps = useInnerBlocksProps( { ref }, props );\n\treturn (\n\t\t<div className=\"block-editor-inner-blocks\">\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n} );\n\n/**\n * This hook is used to lightly mark an element as an inner blocks wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * an inner blocks wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Optional. Inner blocks options.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport function useInnerBlocksProps( props = {}, options = {} ) {\n\tconst {\n\t\t__unstableDisableLayoutClassNames,\n\t\t__unstableDisableDropZone,\n\t\tdropZoneElement,\n\t} = options;\n\tconst {\n\t\tclientId,\n\t\tlayout = null,\n\t\t__unstableLayoutClassNames: layoutClassNames = '',\n\t} = useBlockEditContext();\n\tconst isSmallScreen = useViewportMatch( 'medium', '<' );\n\tconst { __experimentalCaptureToolbars, hasOverlay } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tisBlockSelected,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst enableClickThrough =\n\t\t\t\t__unstableGetEditorMode() === 'navigation' || isSmallScreen;\n\t\t\treturn {\n\t\t\t\t__experimentalCaptureToolbars: select(\n\t\t\t\t\tblocksStore\n\t\t\t\t).hasBlockSupport(\n\t\t\t\t\tblockName,\n\t\t\t\t\t'__experimentalExposeControlsToChildren',\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasOverlay:\n\t\t\t\t\tblockName !== 'core/template' &&\n\t\t\t\t\t! isBlockSelected( clientId ) &&\n\t\t\t\t\t! hasSelectedInnerBlock( clientId, true ) &&\n\t\t\t\t\tenableClickThrough,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isSmallScreen ]\n\t);\n\n\tconst blockDropZoneRef = useBlockDropZone( {\n\t\tdropZoneElement,\n\t\trootClientId: clientId,\n\t} );\n\n\tconst ref = useMergeRefs( [\n\t\tprops.ref,\n\t\t__unstableDisableDropZone ? null : blockDropZoneRef,\n\t] );\n\n\tconst innerBlocksProps = {\n\t\t__experimentalCaptureToolbars,\n\t\tlayout,\n\t\t...options,\n\t};\n\tconst InnerBlocks =\n\t\tinnerBlocksProps.value && innerBlocksProps.onChange\n\t\t\t? ControlledInnerBlocks\n\t\t\t: UncontrolledInnerBlocks;\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: classnames(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-list__layout',\n\t\t\t__unstableDisableLayoutClassNames ? '' : layoutClassNames,\n\t\t\t{\n\t\t\t\t'has-overlay': hasOverlay,\n\t\t\t}\n\t\t),\n\t\tchildren: clientId ? (\n\t\t\t<InnerBlocks { ...innerBlocksProps } clientId={ clientId } />\n\t\t) : (\n\t\t\t<BlockListItems { ...options } />\n\t\t),\n\t};\n}\n\nuseInnerBlocksProps.save = getInnerBlocksProps;\n\n// Expose default appender placeholders as components.\nForwardedInnerBlocks.DefaultBlockAppender = DefaultBlockAppender;\nForwardedInnerBlocks.ButtonBlockAppender = ButtonBlockAppender;\n\nForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport default ForwardedInnerBlocks;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AASA,IAAAK,oBAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,qBAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,wBAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,0BAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,gBAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,UAAA,GAAAV,OAAA;AACA,IAAAW,aAAA,GAAAX,OAAA;AACA,IAAAY,QAAA,GAAAZ,OAAA;AACA,IAAAa,aAAA,GAAAd,sBAAA,CAAAC,OAAA;AACA,IAAAc,MAAA,GAAAd,OAAA;AACA,IAAAe,iBAAA,GAAAhB,sBAAA,CAAAC,OAAA;AACA,IAAAgB,YAAA,GAAAhB,OAAA;AA/BA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAcA,MAAMiB,YAAY,GAAG,CAAC,CAAC;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,S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B,gBAAgB,GAAG;IACxBnC,6BAA6B;IAC7BM,MAAM;IACN,GAAGgC;EACJ,CAAC;EACD,MAAMqB,WAAW,GAChBxB,gBAAgB,CAACR,KAAK,IAAIQ,gBAAgB,CAACyB,QAAQ,GAChD9B,qBAAqB,GACrB3C,uBAAuB;EAE3B,OAAO;IACN,GAAGC,KAAK;IACR8C,GAAG;IACHG,SAAS,EAAE,IAAAwB,mBAAU,EACpBzE,KAAK,CAACiD,SAAS,EACf,iCAAiC,EACjCE,iCAAiC,GAAG,EAAE,GAAGI,gBAAgB,EACzD;MACC,aAAa,EAAEI;IAChB,CACD,CAAC;IACDe,QAAQ,EAAEzE,QAAQ,GACjB,IAAAmC,MAAA,CAAAC,aAAA,EAACkC,WAAW;MAAA,GAAMxB,gBAAgB;MAAG9C,QAAQ,EAAGA;IAAU,CAAE,CAAC,GAE7D,IAAAmC,MAAA,CAAAC,aAAA,EAAC9C,UAAA,CAAAiD,cAAc;MAAA,GAAMU;IAAO,CAAI;EAElC,CAAC;AACF;AAEAF,mBAAmB,CAAC2B,IAAI,GAAGC,qCAAmB;;AAE9C;AACAhC,oBAAoB,CAACiC,oBAAoB,GAAGA,6BAAoB;AAChEjC,oBAAoB,CAACkC,mBAAmB,GAAGA,4BAAmB;AAE9DlC,oBAAoB,CAACmC,OAAO,GAAG,MAAM/B,mBAAmB,CAAC2B,IAAI,CAAC,CAAC,CAACD,QAAQ;;AAExE;AACA;AACA;AAFA,IAAAM,QAAA,GAGepC,oBAAoB;AAAAqC,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -15,6 +15,7 @@ var _unsupportedBlockDetails = _interopRequireDefault(require("../unsupported-bl
15
15
  var _store = require("../../store");
16
16
  var _constants = require("./constants");
17
17
  var _useUnsupportedBlockEditor = _interopRequireDefault(require("../use-unsupported-block-editor"));
18
+ var _convertToGroupButtons = require("../convert-to-group-buttons");
18
19
  /**
19
20
  * External dependencies
20
21
  */
@@ -27,48 +28,45 @@ var _useUnsupportedBlockEditor = _interopRequireDefault(require("../use-unsuppor
27
28
  * Internal dependencies
28
29
  */
29
30
 
31
+ const EMPTY_ARRAY = [];
30
32
  const WarningMaxDepthExceeded = ({
31
33
  clientId
32
34
  }) => {
33
35
  const [showDetails, setShowDetails] = (0, _element.useState)(false);
36
+ const isSelected = (0, _data.useSelect)(select => select(_store.store).isBlockSelected(clientId), [clientId]);
37
+
38
+ // We rely on the logic related to the Group/Ungroup buttons used in the block options to
39
+ // determine whether to use the Ungroup action.
40
+ const convertToGroupButtonProps = (0, _convertToGroupButtons.useConvertToGroupButtonProps)([clientId]);
34
41
  const {
35
- isSelected,
36
- innerBlocks
37
- } = (0, _data.useSelect)(select => {
38
- const {
39
- getBlock,
40
- isBlockSelected
41
- } = select(_store.store);
42
- return {
43
- innerBlocks: getBlock(clientId)?.innerBlocks || [],
44
- isSelected: isBlockSelected(clientId)
45
- };
46
- }, [clientId]);
47
- const {
48
- replaceBlocks
49
- } = (0, _data.useDispatch)(_store.store);
42
+ isUngroupable
43
+ } = convertToGroupButtonProps;
44
+ const convertToGroupButtons = (0, _convertToGroupButtons.useConvertToGroupButtons)({
45
+ ...convertToGroupButtonProps
46
+ });
47
+ const onUngroup = convertToGroupButtons.ungroup.onSelect;
50
48
  const {
51
49
  isUnsupportedBlockEditorSupported,
52
50
  canEnableUnsupportedBlockEditor
53
51
  } = (0, _useUnsupportedBlockEditor.default)(clientId);
54
- const onUngroup = () => {
55
- if (!innerBlocks.length) {
56
- return;
57
- }
58
- replaceBlocks(clientId, innerBlocks);
59
- };
60
- let description;
61
- // When UBE can't be used, the description mentions using the web browser to edit the block.
52
+
53
+ /* translators: Warning related to having blocks deeply nested. %d: The deepest nesting level. */
54
+ const descriptionFormat = (0, _i18n.__)('Blocks nested deeper than %d levels may not render properly in the mobile editor.');
55
+ let description = (0, _i18n.sprintf)(descriptionFormat, _constants.MAX_NESTING_DEPTH);
62
56
  if (!isUnsupportedBlockEditorSupported && !canEnableUnsupportedBlockEditor) {
63
- /* translators: Warning related to having blocks deeply nested. %d: The deepest nesting level. */
64
- const descriptionFormat = (0, _i18n.__)('Blocks nested deeper than %d levels may not render properly in the mobile editor. For this reason, we recommend flattening the content by ungrouping the block or editing the block using your web browser.');
65
- description = (0, _i18n.sprintf)(descriptionFormat, _constants.MAX_NESTING_DEPTH);
57
+ // When UBE can't be used, the description mentions using the web browser to edit the block.
58
+ description += ' ' + /* translators: Recommendation included in a warning related to having blocks deeply nested. */
59
+ (0, _i18n.__)('For this reason, we recommend editing the block using your web browser.');
66
60
  }
67
61
  // Otherwise, the description mentions using the web editor (i.e. UBE).
68
62
  else {
69
- /* translators: Warning related to having blocks deeply nested. %d: The deepest nesting level. */
70
- const descriptionFormat = (0, _i18n.__)('Blocks nested deeper than %d levels may not render properly in the mobile editor. For this reason, we recommend flattening the content by ungrouping the block or editing the block using the web editor.');
71
- description = (0, _i18n.sprintf)(descriptionFormat, _constants.MAX_NESTING_DEPTH);
63
+ description += ' ' + /* translators: Recommendation included in a warning related to having blocks deeply nested. */
64
+ (0, _i18n.__)('For this reason, we recommend editing the block using the web editor.');
65
+ }
66
+ // If the block can be flattened, we also suggest to ungroup the block.
67
+ if (isUngroupable) {
68
+ description += ' ' + /* translators: Alternative option included in a warning related to having blocks deeply nested. */
69
+ (0, _i18n.__)('Alternatively, you can flatten the content by ungrouping the block.');
72
70
  }
73
71
  return (0, _react.createElement)(_reactNative.TouchableWithoutFeedback, {
74
72
  disabled: !isSelected,
@@ -84,10 +82,10 @@ const WarningMaxDepthExceeded = ({
84
82
  onCloseSheet: () => setShowDetails(false),
85
83
  title: (0, _i18n.__)('Deeply nested block'),
86
84
  description: description,
87
- customActions: [{
85
+ customActions: isUngroupable ? [{
88
86
  label: (0, _i18n.__)('Ungroup block'),
89
87
  onPress: onUngroup
90
- }]
88
+ }] : EMPTY_ARRAY
91
89
  })));
92
90
  };
93
91
  var _default = WarningMaxDepthExceeded;
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_i18n","_element","_data","_warning","_interopRequireDefault","_unsupportedBlockDetails","_store","_constants","_useUnsupportedBlockEditor","WarningMaxDepthExceeded","clientId","showDetails","setShowDetails","useState","isSelected","innerBlocks","useSelect","select","getBlock","isBlockSelected","blockEditorStore","replaceBlocks","useDispatch","isUnsupportedBlockEditorSupported","canEnableUnsupportedBlockEditor","useUnsupportedBlockEditor","onUngroup","length","description","descriptionFormat","__","sprintf","MAX_NESTING_DEPTH","_react","createElement","TouchableWithoutFeedback","disabled","accessibilityLabel","accessibilityRole","accessibilityHint","onPress","View","default","message","showSheet","onCloseSheet","title","customActions","label","_default","exports"],"sources":["@wordpress/block-editor/src/components/inner-blocks/warning-max-depth-exceeded.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { TouchableWithoutFeedback, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport Warning from '../warning';\nimport UnsupportedBlockDetails from '../unsupported-block-details';\nimport { store as blockEditorStore } from '../../store';\nimport { MAX_NESTING_DEPTH } from './constants';\nimport useUnsupportedBlockEditor from '../use-unsupported-block-editor';\n\nconst WarningMaxDepthExceeded = ( { clientId } ) => {\n\tconst [ showDetails, setShowDetails ] = useState( false );\n\n\tconst { isSelected, innerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, isBlockSelected } = select( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tinnerBlocks: getBlock( clientId )?.innerBlocks || [],\n\t\t\t\tisSelected: isBlockSelected( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\n\tconst {\n\t\tisUnsupportedBlockEditorSupported,\n\t\tcanEnableUnsupportedBlockEditor,\n\t} = useUnsupportedBlockEditor( clientId );\n\n\tconst onUngroup = () => {\n\t\tif ( ! innerBlocks.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\treplaceBlocks( clientId, innerBlocks );\n\t};\n\n\tlet description;\n\t// When UBE can't be used, the description mentions using the web browser to edit the block.\n\tif (\n\t\t! isUnsupportedBlockEditorSupported &&\n\t\t! canEnableUnsupportedBlockEditor\n\t) {\n\t\t/* translators: Warning related to having blocks deeply nested. %d: The deepest nesting level. */\n\t\tconst descriptionFormat = __(\n\t\t\t'Blocks nested deeper than %d levels may not render properly in the mobile editor. For this reason, we recommend flattening the content by ungrouping the block or editing the block using your web browser.'\n\t\t);\n\t\tdescription = sprintf( descriptionFormat, MAX_NESTING_DEPTH );\n\t}\n\t// Otherwise, the description mentions using the web editor (i.e. UBE).\n\telse {\n\t\t/* translators: Warning related to having blocks deeply nested. %d: The deepest nesting level. */\n\t\tconst descriptionFormat = __(\n\t\t\t'Blocks nested deeper than %d levels may not render properly in the mobile editor. For this reason, we recommend flattening the content by ungrouping the block or editing the block using the web editor.'\n\t\t);\n\t\tdescription = sprintf( descriptionFormat, MAX_NESTING_DEPTH );\n\t}\n\n\treturn (\n\t\t<TouchableWithoutFeedback\n\t\t\tdisabled={ ! isSelected }\n\t\t\taccessibilityLabel={ __( 'Warning message' ) }\n\t\t\taccessibilityRole={ 'button' }\n\t\t\taccessibilityHint={ __( 'Tap here to show more details.' ) }\n\t\t\tonPress={ () => setShowDetails( true ) }\n\t\t>\n\t\t\t<View>\n\t\t\t\t<Warning\n\t\t\t\t\tmessage={ __(\n\t\t\t\t\t\t'Block cannot be rendered because it is deeply nested. Tap here for more details.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t\t<UnsupportedBlockDetails\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tshowSheet={ showDetails }\n\t\t\t\t\tonCloseSheet={ () => setShowDetails( false ) }\n\t\t\t\t\ttitle={ __( 'Deeply nested block' ) }\n\t\t\t\t\tdescription={ description }\n\t\t\t\t\tcustomActions={ [\n\t\t\t\t\t\t{ label: __( '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AAG,CACf;MAAEC,KAAK,EAAE,IAAAlB,QAAE,EAAE,eAAgB,CAAC;MAAEU,OAAO,EAAEd;IAAU,CAAC;EAClD,CACH,CACI,CACmB,CAAC;AAE7B,CAAC;AAAC,IAAAuB,QAAA,GAEaxC,uBAAuB;AAAAyC,OAAA,CAAAR,OAAA,GAAAO,QAAA"}
1
+ {"version":3,"names":["_reactNative","require","_i18n","_element","_data","_warning","_interopRequireDefault","_unsupportedBlockDetails","_store","_constants","_useUnsupportedBlockEditor","_convertToGroupButtons","EMPTY_ARRAY","WarningMaxDepthExceeded","clientId","showDetails","setShowDetails","useState","isSelected","useSelect","select","blockEditorStore","isBlockSelected","convertToGroupButtonProps","useConvertToGroupButtonProps","isUngroupable","convertToGroupButtons","useConvertToGroupButtons","onUngroup","ungroup","onSelect","isUnsupportedBlockEditorSupported","canEnableUnsupportedBlockEditor","useUnsupportedBlockEditor","descriptionFormat","__","description","sprintf","MAX_NESTING_DEPTH","_react","createElement","TouchableWithoutFeedback","disabled","accessibilityLabel","accessibilityRole","accessibilityHint","onPress","View","default","message","showSheet","onCloseSheet","title","customActions","label","_default","exports"],"sources":["@wordpress/block-editor/src/components/inner-blocks/warning-max-depth-exceeded.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { TouchableWithoutFeedback, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport Warning from '../warning';\nimport UnsupportedBlockDetails from '../unsupported-block-details';\nimport { store as blockEditorStore } from '../../store';\nimport { MAX_NESTING_DEPTH } from './constants';\nimport useUnsupportedBlockEditor from '../use-unsupported-block-editor';\nimport {\n\tuseConvertToGroupButtons,\n\tuseConvertToGroupButtonProps,\n} from '../convert-to-group-buttons';\n\nconst EMPTY_ARRAY = [];\n\nconst WarningMaxDepthExceeded = ( { clientId } ) => {\n\tconst [ showDetails, setShowDetails ] = useState( false );\n\n\tconst isSelected = useSelect(\n\t\t( select ) => select( blockEditorStore ).isBlockSelected( clientId ),\n\t\t[ clientId ]\n\t);\n\n\t// We rely on the logic related to the Group/Ungroup buttons used in the block options to\n\t// determine whether to use the Ungroup action.\n\tconst convertToGroupButtonProps = useConvertToGroupButtonProps( [\n\t\tclientId,\n\t] );\n\tconst { isUngroupable } = convertToGroupButtonProps;\n\tconst convertToGroupButtons = useConvertToGroupButtons( {\n\t\t...convertToGroupButtonProps,\n\t} );\n\tconst onUngroup = convertToGroupButtons.ungroup.onSelect;\n\n\tconst {\n\t\tisUnsupportedBlockEditorSupported,\n\t\tcanEnableUnsupportedBlockEditor,\n\t} = useUnsupportedBlockEditor( clientId );\n\n\t/* translators: Warning related to having blocks deeply nested. %d: The deepest nesting level. */\n\tconst descriptionFormat = __(\n\t\t'Blocks nested deeper than %d levels may not render properly in the mobile editor.'\n\t);\n\tlet description = sprintf( descriptionFormat, MAX_NESTING_DEPTH );\n\tif (\n\t\t! isUnsupportedBlockEditorSupported &&\n\t\t! canEnableUnsupportedBlockEditor\n\t) {\n\t\t// When UBE can't be used, the description mentions using the web browser to edit the block.\n\t\tdescription +=\n\t\t\t' ' +\n\t\t\t/* translators: Recommendation included in a warning related to having blocks deeply nested. */\n\t\t\t__(\n\t\t\t\t'For this reason, we recommend editing the block using your web browser.'\n\t\t\t);\n\t}\n\t// Otherwise, the description mentions using the web editor (i.e. UBE).\n\telse {\n\t\tdescription +=\n\t\t\t' ' +\n\t\t\t/* translators: Recommendation included in a warning related to having blocks deeply nested. */\n\t\t\t__(\n\t\t\t\t'For this reason, we recommend editing the block using the web editor.'\n\t\t\t);\n\t}\n\t// If the block can be flattened, we also suggest to ungroup the block.\n\tif ( isUngroupable ) {\n\t\tdescription +=\n\t\t\t' ' +\n\t\t\t/* translators: Alternative option included in a warning related to having blocks deeply nested. */\n\t\t\t__(\n\t\t\t\t'Alternatively, you can flatten the content by ungrouping the block.'\n\t\t\t);\n\t}\n\n\treturn (\n\t\t<TouchableWithoutFeedback\n\t\t\tdisabled={ ! isSelected }\n\t\t\taccessibilityLabel={ __( 'Warning message' ) }\n\t\t\taccessibilityRole={ 'button' }\n\t\t\taccessibilityHint={ __( 'Tap here to show more details.' ) }\n\t\t\tonPress={ () => setShowDetails( true ) }\n\t\t>\n\t\t\t<View>\n\t\t\t\t<Warning\n\t\t\t\t\tmessage={ __(\n\t\t\t\t\t\t'Block cannot be rendered because it is deeply nested. Tap here for more details.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t\t<UnsupportedBlockDetails\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tshowSheet={ showDetails }\n\t\t\t\t\tonCloseSheet={ () => setShowDetails( false ) }\n\t\t\t\t\ttitle={ __( 'Deeply nested block' ) }\n\t\t\t\t\tdescription={ description }\n\t\t\t\t\tcustomActions={\n\t\t\t\t\t\tisUngroupable\n\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\tlabel: __( 'Ungroup block' ),\n\t\t\t\t\t\t\t\t\t\tonPress: onUngroup,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t: EMPTY_ARRAY\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</View>\n\t\t</TouchableWithoutFeedback>\n\t);\n};\n\nexport default WarningMaxDepthExceeded;\n"],"mappings":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAKA,IAAAI,QAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,wBAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AACA,IAAAS,0BAAA,GAAAJ,sBAAA,CAAAL,OAA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AAI,MAAA,CAAAC,aAAA,EAACxC,YAAA,CAAAyC,wBAAwB;IACxBC,QAAQ,EAAG,CAAExB,UAAY;IACzByB,kBAAkB,EAAG,IAAAR,QAAE,EAAE,iBAAkB,CAAG;IAC9CS,iBAAiB,EAAG,QAAU;IAC9BC,iBAAiB,EAAG,IAAAV,QAAE,EAAE,gCAAiC,CAAG;IAC5DW,OAAO,EAAGA,CAAA,KAAM9B,cAAc,CAAE,IAAK;EAAG,GAExC,IAAAuB,MAAA,CAAAC,aAAA,EAACxC,YAAA,CAAA+C,IAAI,QACJ,IAAAR,MAAA,CAAAC,aAAA,EAACnC,QAAA,CAAA2C,OAAO;IACPC,OAAO,EAAG,IAAAd,QAAE,EACX,kFACD;EAAG,CACH,CAAC,EACF,IAAAI,MAAA,CAAAC,aAAA,EAACjC,wBAAA,CAAAyC,OAAuB;IACvBlC,QAAQ,EAAGA,QAAU;IACrBoC,SAAS,EAAGnC,WAAa;IACzBoC,YAAY,EAAGA,CAAA,KAAMnC,cAAc,CAAE,KAAM,CAAG;IAC9CoC,KAAK,EAAG,IAAAjB,QAAE,EAAE,qBAAsB,CAAG;IACrCC,WAAW,EAAGA,WAAa;IAC3BiB,aAAa,EACZ5B,aAAa,GACV,CACA;MACC6B,KAAK,EAAE,IAAAnB,QAAE,EAAE,eAAgB,CAAC;MAC5BW,OAAO,EAAElB;IACV,CAAC,CACA,GACDhB;EACH,CACD,CACI,CACmB,CAAC;AAE7B,CAAC;AAAC,IAAA2C,QAAA,GAEa1C,uBAAuB;AAAA2C,OAAA,CAAAR,OAAA,GAAAO,QAAA"}
@@ -58,7 +58,7 @@ function PatternList({
58
58
  if (selectedCategory === _utils.allPatternsCategory.name) {
59
59
  return true;
60
60
  }
61
- if (selectedCategory === _utils.myPatternsCategory.name && pattern.id) {
61
+ if (selectedCategory === _utils.myPatternsCategory.name && pattern.type === _utils.PATTERN_TYPES.user) {
62
62
  return true;
63
63
  }
64
64
  if (selectedCategory === 'uncategorized') {
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_i18n","_compose","_components","_a11y","_blockPatternsList","_interopRequireDefault","_useInsertionPoint","_usePatternsState","_inserterListbox","_searchItems","_blockPatternsPaging","_usePatternsPaging","_utils","PatternsListHeader","filterValue","filteredBlockPatternsLength","_react","createElement","__experimentalHeading","level","lineHeight","className","sprintf","_n","PatternList","searchValue","selectedCategory","patternCategories","container","useRef","debouncedSpeak","useDebounce","speak","destinationRootClientId","onInsertBlocks","useInsertionPoint","shouldFocusBlock","patterns","onClickPattern","usePatternsState","registeredPatternCategories","useMemo","map","patternCategory","name","filteredBlockPatterns","filteredPatterns","filter","pattern","allPatternsCategory","myPatternsCategory","id","hasKnownCategory","categories","some","category","includes","length","searchItems","useEffect","count","resultsFoundMessage","pagingProps","usePatternsPaging","previousSearchValue","setPreviousSearchValue","useState","changePage","hasItems","ref","default","Fragment","shownPatterns","categoryPatternsAsyncList","blockPatterns","categoryPatterns","isDraggable","_default","exports"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/pattern-list.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect, useRef, useState } from '@wordpress/element';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useDebounce } from '@wordpress/compose';\nimport { __experimentalHeading as Heading } from '@wordpress/components';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport BlockPatternsList from '../../block-patterns-list';\nimport useInsertionPoint from '../hooks/use-insertion-point';\nimport usePatternsState from '../hooks/use-patterns-state';\nimport InserterListbox from '../../inserter-listbox';\nimport { searchItems } from '../search-items';\nimport BlockPatternsPaging from '../../block-patterns-paging';\nimport usePatternsPaging from '../hooks/use-patterns-paging';\nimport {\n\tallPatternsCategory,\n\tmyPatternsCategory,\n} from '../block-patterns-tab/utils';\n\nfunction PatternsListHeader( { filterValue, filteredBlockPatternsLength } ) {\n\tif ( ! filterValue ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Heading\n\t\t\tlevel={ 2 }\n\t\t\tlineHeight={ '48px' }\n\t\t\tclassName=\"block-editor-block-patterns-explorer__search-results-count\"\n\t\t>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %d: number of patterns. */\n\t\t\t\t_n(\n\t\t\t\t\t'%d pattern found',\n\t\t\t\t\t'%d patterns found',\n\t\t\t\t\tfilteredBlockPatternsLength\n\t\t\t\t),\n\t\t\t\tfilteredBlockPatternsLength\n\t\t\t) }\n\t\t</Heading>\n\t);\n}\n\nfunction PatternList( { searchValue, selectedCategory, patternCategories } ) {\n\tconst container = useRef();\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\tshouldFocusBlock: true,\n\t} );\n\tconst [ patterns, , onClickPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId\n\t);\n\n\tconst registeredPatternCategories = useMemo(\n\t\t() =>\n\t\t\tpatternCategories.map(\n\t\t\t\t( patternCategory ) => patternCategory.name\n\t\t\t),\n\t\t[ patternCategories ]\n\t);\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tconst filteredPatterns = patterns.filter( ( pattern ) => {\n\t\t\tif ( selectedCategory === allPatternsCategory.name ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif ( selectedCategory === myPatternsCategory.name && pattern.id ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif ( selectedCategory === 'uncategorized' ) {\n\t\t\t\tconst hasKnownCategory = pattern.categories.some(\n\t\t\t\t\t( category ) =>\n\t\t\t\t\t\tregisteredPatternCategories.includes( category )\n\t\t\t\t);\n\n\t\t\t\treturn ! pattern.categories?.length || ! hasKnownCategory;\n\t\t\t}\n\n\t\t\treturn pattern.categories?.includes( selectedCategory );\n\t\t} );\n\n\t\tif ( ! searchValue ) {\n\t\t\treturn filteredPatterns;\n\t\t}\n\n\t\treturn searchItems( filteredPatterns, searchValue );\n\t}, [\n\t\tsearchValue,\n\t\tpatterns,\n\t\tselectedCategory,\n\t\tregisteredPatternCategories,\n\t] );\n\n\t// Announce search results on change.\n\tuseEffect( () => {\n\t\tif ( ! searchValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockPatterns.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ searchValue, debouncedSpeak, filteredBlockPatterns.length ] );\n\n\tconst pagingProps = usePatternsPaging(\n\t\tfilteredBlockPatterns,\n\t\tselectedCategory,\n\t\tcontainer\n\t);\n\n\t// Reset page when search value changes.\n\tconst [ previousSearchValue, setPreviousSearchValue ] =\n\t\tuseState( searchValue );\n\tif ( searchValue !== previousSearchValue ) {\n\t\tsetPreviousSearchValue( searchValue );\n\t\tpagingProps.changePage( 1 );\n\t}\n\n\tconst hasItems = !! filteredBlockPatterns?.length;\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-block-patterns-explorer__list\"\n\t\t\tref={ container }\n\t\t>\n\t\t\t<PatternsListHeader\n\t\t\t\tfilterValue={ searchValue }\n\t\t\t\tfilteredBlockPatternsLength={ filteredBlockPatterns.length }\n\t\t\t/>\n\n\t\t\t<InserterListbox>\n\t\t\t\t{ hasItems && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tshownPatterns={\n\t\t\t\t\t\t\t\tpagingProps.categoryPatternsAsyncList\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\t\t\tisDraggable={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BlockPatternsPaging { ...pagingProps } />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</InserterListbox>\n\t\t</div>\n\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CsC,WAAW,EAAG;EAAO,CACrB,CAAC,EACF,IAAA5D,MAAA,CAAAC,aAAA,EAACP,oBAAA,CAAA4D,OAAmB;IAAA,GAAMR;EAAW,CAAI,CACxC,CAEa,CACb,CAAC;AAER;AAAC,IAAAe,QAAA,GAEcrD,WAAW;AAAAsD,OAAA,CAAAR,OAAA,GAAAO,QAAA"}
1
+ {"version":3,"names":["_element","require","_i18n","_compose","_components","_a11y","_blockPatternsList","_interopRequireDefault","_useInsertionPoint","_usePatternsState","_inserterListbox","_searchItems","_blockPatternsPaging","_usePatternsPaging","_utils","PatternsListHeader","filterValue","filteredBlockPatternsLength","_react","createElement","__experimentalHeading","level","lineHeight","className","sprintf","_n","PatternList","searchValue","selectedCategory","patternCategories","container","useRef","debouncedSpeak","useDebounce","speak","destinationRootClientId","onInsertBlocks","useInsertionPoint","shouldFocusBlock","patterns","onClickPattern","usePatternsState","registeredPatternCategories","useMemo","map","patternCategory","name","filteredBlockPatterns","filteredPatterns","filter","pattern","allPatternsCategory","myPatternsCategory","type","PATTERN_TYPES","user","hasKnownCategory","categories","some","category","includes","length","searchItems","useEffect","count","resultsFoundMessage","pagingProps","usePatternsPaging","previousSearchValue","setPreviousSearchValue","useState","changePage","hasItems","ref","default","Fragment","shownPatterns","categoryPatternsAsyncList","blockPatterns","categoryPatterns","isDraggable","_default","exports"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/pattern-list.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect, useRef, useState } from '@wordpress/element';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useDebounce } from '@wordpress/compose';\nimport { __experimentalHeading as Heading } from '@wordpress/components';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport BlockPatternsList from '../../block-patterns-list';\nimport useInsertionPoint from '../hooks/use-insertion-point';\nimport usePatternsState from '../hooks/use-patterns-state';\nimport InserterListbox from '../../inserter-listbox';\nimport { searchItems } from '../search-items';\nimport BlockPatternsPaging from '../../block-patterns-paging';\nimport usePatternsPaging from '../hooks/use-patterns-paging';\nimport {\n\tPATTERN_TYPES,\n\tallPatternsCategory,\n\tmyPatternsCategory,\n} from '../block-patterns-tab/utils';\n\nfunction PatternsListHeader( { filterValue, filteredBlockPatternsLength } ) {\n\tif ( ! filterValue ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Heading\n\t\t\tlevel={ 2 }\n\t\t\tlineHeight={ '48px' }\n\t\t\tclassName=\"block-editor-block-patterns-explorer__search-results-count\"\n\t\t>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %d: number of patterns. */\n\t\t\t\t_n(\n\t\t\t\t\t'%d pattern found',\n\t\t\t\t\t'%d patterns found',\n\t\t\t\t\tfilteredBlockPatternsLength\n\t\t\t\t),\n\t\t\t\tfilteredBlockPatternsLength\n\t\t\t) }\n\t\t</Heading>\n\t);\n}\n\nfunction PatternList( { searchValue, selectedCategory, patternCategories } ) {\n\tconst container = useRef();\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\tshouldFocusBlock: true,\n\t} );\n\tconst [ patterns, , onClickPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId\n\t);\n\n\tconst registeredPatternCategories = useMemo(\n\t\t() =>\n\t\t\tpatternCategories.map(\n\t\t\t\t( patternCategory ) => patternCategory.name\n\t\t\t),\n\t\t[ patternCategories ]\n\t);\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tconst filteredPatterns = patterns.filter( ( pattern ) => {\n\t\t\tif ( selectedCategory === allPatternsCategory.name ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tselectedCategory === myPatternsCategory.name &&\n\t\t\t\tpattern.type === PATTERN_TYPES.user\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif ( selectedCategory === 'uncategorized' ) {\n\t\t\t\tconst hasKnownCategory = pattern.categories.some(\n\t\t\t\t\t( category ) =>\n\t\t\t\t\t\tregisteredPatternCategories.includes( category )\n\t\t\t\t);\n\n\t\t\t\treturn ! pattern.categories?.length || ! hasKnownCategory;\n\t\t\t}\n\n\t\t\treturn pattern.categories?.includes( selectedCategory );\n\t\t} );\n\n\t\tif ( ! searchValue ) {\n\t\t\treturn filteredPatterns;\n\t\t}\n\n\t\treturn searchItems( filteredPatterns, searchValue );\n\t}, [\n\t\tsearchValue,\n\t\tpatterns,\n\t\tselectedCategory,\n\t\tregisteredPatternCategories,\n\t] );\n\n\t// Announce search results on change.\n\tuseEffect( () => {\n\t\tif ( ! searchValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockPatterns.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ searchValue, debouncedSpeak, filteredBlockPatterns.length ] );\n\n\tconst pagingProps = usePatternsPaging(\n\t\tfilteredBlockPatterns,\n\t\tselectedCategory,\n\t\tcontainer\n\t);\n\n\t// Reset page when search value changes.\n\tconst [ previousSearchValue, setPreviousSearchValue ] =\n\t\tuseState( searchValue );\n\tif ( searchValue !== previousSearchValue ) {\n\t\tsetPreviousSearchValue( searchValue );\n\t\tpagingProps.changePage( 1 );\n\t}\n\n\tconst hasItems = !! filteredBlockPatterns?.length;\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-block-patterns-explorer__list\"\n\t\t\tref={ container }\n\t\t>\n\t\t\t<PatternsListHeader\n\t\t\t\tfilterValue={ searchValue }\n\t\t\t\tfilteredBlockPatternsLength={ filteredBlockPatterns.length }\n\t\t\t/>\n\n\t\t\t<InserterListbox>\n\t\t\t\t{ hasItems && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tshownPatterns={\n\t\t\t\t\t\t\t\tpagingProps.categoryPatternsAsyncList\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\t\t\tisDraggable={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BlockPatternsPaging { ...pagingProps } />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</InserterListbox>\n\t\t</div>\n\t);\n}\n\nexport default PatternList;\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,kBAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,kBAAA,GAAAD,sBAAA,CAAAN,OAAA;AACA,IAAAQ,iBAAA,GAAAF,sBAAA,CAAAN,OAAA;AACA,IAAAS,gBAAA,GAAAH,sBAAA,CAAAN,OAAA;AACA,IAAAU,YAAA,GAAAV,OAAA;AACA,IAAAW,oBAAA,GAAAL,sBAAA,CAAAN,OAAA;AACA,IAAAY,kBAAA,GAAAN,sBAAA,CAAAN,OAAA;AACA,IAAAa,MAAA,GAAAb,OAAA;AAnBA;AACA;AACA;;AAOA;AACA;AACA;;AAcA,SAASc,kBAAkBA,CAAE;EAAEC,WAAW;EAAEC;AAA4B,CAAC,EAAG;EAC3E,IAAK,CAAED,WAAW,EAAG;IACpB,OAAO,IAAI;EACZ;EAEA,OACC,IAAAE,MAAA,CAAAC,aAAA,EAACf,WAAA,CAAAgB,qBAAO;IACPC,KAAK,EAAG,CAAG;IACXC,UAAU,EAAG,MAAQ;IACrBC,SAAS,EAAC;EAA4D,GAEpE,IAAAC,aAAO,GACR;EACA,IAAAC,QAAE,EACD,kBAAkB,EAClB,mBAAmB,EACnBR,2BACD,CAA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Q,CAC5D,CAAC,EAEF,IAAA3C,MAAA,CAAAC,aAAA,EAACT,gBAAA,CAAAgE,OAAe,QACbF,QAAQ,IACT,IAAAtD,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAyD,QAAA,QACC,IAAAzD,MAAA,CAAAC,aAAA,EAACb,kBAAA,CAAAoE,OAAiB;IACjBE,aAAa,EACZV,WAAW,CAACW,yBACZ;IACDC,aAAa,EAAGZ,WAAW,CAACa,gBAAkB;IAC9CvC,cAAc,EAAGA,cAAgB;IACjCwC,WAAW,EAAG;EAAO,CACrB,CAAC,EACF,IAAA9D,MAAA,CAAAC,aAAA,EAACP,oBAAA,CAAA8D,OAAmB;IAAA,GAAMR;EAAW,CAAI,CACxC,CAEa,CACb,CAAC;AAER;AAAC,IAAAe,QAAA,GAEcvD,WAAW;AAAAwD,OAAA,CAAAR,OAAA,GAAAO,QAAA"}
@@ -44,7 +44,7 @@ function PatternCategoryPreviews({
44
44
  if (category.name === _utils.allPatternsCategory.name) {
45
45
  return true;
46
46
  }
47
- if (category.name === _utils.myPatternsCategory.name && pattern.id) {
47
+ if (category.name === _utils.myPatternsCategory.name && pattern.type === _utils.PATTERN_TYPES.user) {
48
48
  return true;
49
49
  }
50
50
  if (category.name !== 'uncategorized') {
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_i18n","_components","_usePatternsState","_interopRequireDefault","_blockPatternsList","_usePatternsPaging","_patternsFilter","_usePatternCategories","_utils","noop","PatternCategoryPreviews","rootClientId","onInsert","onHover","category","showTitlesAsTooltip","allPatterns","onClickPattern","usePatternsState","patternSyncFilter","setPatternSyncFilter","useState","patternSourceFilter","setPatternSourceFilter","availableCategories","usePatternCategories","scrollContainerRef","useRef","currentCategoryPatterns","useMemo","filter","pattern","_pattern$categories$f","isPatternFiltered","name","allPatternsCategory","myPatternsCategory","id","categories","includes","availablePatternCategories","cat","find","availableCategory","length","pagingProps","usePatternsPaging","changePage","useEffect","onSetPatternSyncFilter","useCallback","value","onSetPatternSourceFilter","_react","createElement","className","__experimentalVStack","spacing","__experimentalHStack","FlexBlock","__experimentalHeading","level","as","label","PatternsFilter","__experimentalText","variant","__","default","ref","shownPatterns","categoryPatternsAsyncList","blockPatterns","categoryPatterns","orientation","isDraggable","patternFilter"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab/pattern-category-previews.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMemo,\n\tuseState,\n\tuseCallback,\n\tuseRef,\n\tuseEffect,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalHeading as Heading,\n\t__experimentalText as Text,\n\tFlexBlock,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport usePatternsState from '../hooks/use-patterns-state';\nimport BlockPatternList from '../../block-patterns-list';\nimport usePatternsPaging from '../hooks/use-patterns-paging';\nimport { PatternsFilter } from './patterns-filter';\nimport { usePatternCategories } from './use-pattern-categories';\nimport {\n\tisPatternFiltered,\n\tallPatternsCategory,\n\tmyPatternsCategory,\n} from './utils';\n\nconst noop = () => {};\n\nexport function PatternCategoryPreviews( {\n\trootClientId,\n\tonInsert,\n\tonHover = noop,\n\tcategory,\n\tshowTitlesAsTooltip,\n} ) {\n\tconst [ allPatterns, , onClickPattern ] = usePatternsState(\n\t\tonInsert,\n\t\trootClientId\n\t);\n\tconst [ patternSyncFilter, setPatternSyncFilter ] = useState( 'all' );\n\tconst [ patternSourceFilter, setPatternSourceFilter ] = useState( 'all' );\n\n\tconst availableCategories = usePatternCategories(\n\t\trootClientId,\n\t\tpatternSourceFilter\n\t);\n\tconst scrollContainerRef = useRef();\n\tconst currentCategoryPatterns = useMemo(\n\t\t() =>\n\t\t\tallPatterns.filter( ( pattern ) => {\n\t\t\t\tif (\n\t\t\t\t\tisPatternFiltered(\n\t\t\t\t\t\tpattern,\n\t\t\t\t\t\tpatternSourceFilter,\n\t\t\t\t\t\tpatternSyncFilter\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif ( category.name === allPatternsCategory.name ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif ( category.name === myPatternsCategory.name && pattern.id ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif ( category.name !== 'uncategorized' ) {\n\t\t\t\t\treturn pattern.categories?.includes( category.name );\n\t\t\t\t}\n\n\t\t\t\t// The uncategorized category should show all the patterns without any category\n\t\t\t\t// or with no available category.\n\t\t\t\tconst availablePatternCategories =\n\t\t\t\t\tpattern.categories?.filter( ( cat ) =>\n\t\t\t\t\t\tavailableCategories.find(\n\t\t\t\t\t\t\t( availableCategory ) =>\n\t\t\t\t\t\t\t\tavailableCategory.name === cat\n\t\t\t\t\t\t)\n\t\t\t\t\t) ?? [];\n\n\t\t\t\treturn availablePatternCategories.length === 0;\n\t\t\t} ),\n\t\t[\n\t\t\tallPatterns,\n\t\t\tavailableCategories,\n\t\t\tcategory.name,\n\t\t\tpatternSourceFilter,\n\t\t\tpatternSyncFilter,\n\t\t]\n\t);\n\n\tconst pagingProps = usePatternsPaging(\n\t\tcurrentCategoryPatterns,\n\t\tcategory,\n\t\tscrollContainerRef\n\t);\n\tconst { changePage } = pagingProps;\n\n\t// Hide block pattern preview on unmount.\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tuseEffect( () => () => onHover( null ), [] );\n\n\tconst onSetPatternSyncFilter = useCallback(\n\t\t( value ) => {\n\t\t\tsetPatternSyncFilter( value );\n\t\t\tchangePage( 1 );\n\t\t},\n\t\t[ setPatternSyncFilter, changePage ]\n\t);\n\tconst onSetPatternSourceFilter = useCallback(\n\t\t( value ) => {\n\t\t\tsetPatternSourceFilter( value );\n\t\t\tchangePage( 1 );\n\t\t},\n\t\t[ setPatternSourceFilter, changePage ]\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-inserter__patterns-category-panel\">\n\t\t\t<VStack\n\t\t\t\tspacing={ 2 }\n\t\t\t\tclassName=\"block-editor-inserter__patterns-category-panel-header\"\n\t\t\t>\n\t\t\t\t<HStack>\n\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t<Heading level={ 4 } as=\"div\">\n\t\t\t\t\t\t\t{ category.label }\n\t\t\t\t\t\t</Heading>\n\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t<PatternsFilter\n\t\t\t\t\t\tpatternSyncFilter={ patternSyncFilter }\n\t\t\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t\t\t\tsetPatternSyncFilter={ onSetPatternSyncFilter }\n\t\t\t\t\t\tsetPatternSourceFilter={ onSetPatternSourceFilter }\n\t\t\t\t\t\tscrollContainerRef={ scrollContainerRef }\n\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t\t{ ! currentCategoryPatterns.length && (\n\t\t\t\t\t<Text\n\t\t\t\t\t\tvariant=\"muted\"\n\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-category-no-results\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'No results found' ) }\n\t\t\t\t\t</Text>\n\t\t\t\t) }\n\t\t\t</VStack>\n\n\t\t\t{ currentCategoryPatterns.length > 0 && (\n\t\t\t\t<BlockPatternList\n\t\t\t\t\tref={ scrollContainerRef }\n\t\t\t\t\tshownPatterns={ pagingProps.categoryPatternsAsyncList }\n\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\tlabel={ category.label }\n\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\tcategory={ category.name }\n\t\t\t\t\tisDraggable\n\t\t\t\t\tshowTitlesAsTooltip={ showTitlesAsTooltip }\n\t\t\t\t\tpatternFilter={ patternSourceFilter }\n\t\t\t\t\tpagingProps={ pagingProps }\n\t\t\t\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3B,WAAW,CAAC4B,gBAAkB;IAC9CxD,cAAc,EAAGA,cAAgB;IACjCJ,OAAO,EAAGA,OAAS;IACnBkD,KAAK,EAAGjD,QAAQ,CAACiD,KAAO;IACxBW,WAAW,EAAC,UAAU;IACtB5D,QAAQ,EAAGA,QAAQ,CAACoB,IAAM;IAC1ByC,WAAW;IACX5D,mBAAmB,EAAGA,mBAAqB;IAC3C6D,aAAa,EAAGtD,mBAAqB;IACrCuB,WAAW,EAAGA;EAAa,CAC3B,CAEE,CAAC;AAER"}
1
+ {"version":3,"names":["_element","require","_i18n","_components","_usePatternsState","_interopRequireDefault","_blockPatternsList","_usePatternsPaging","_patternsFilter","_usePatternCategories","_utils","noop","PatternCategoryPreviews","rootClientId","onInsert","onHover","category","showTitlesAsTooltip","allPatterns","onClickPattern","usePatternsState","patternSyncFilter","setPatternSyncFilter","useState","patternSourceFilter","setPatternSourceFilter","availableCategories","usePatternCategories","scrollContainerRef","useRef","currentCategoryPatterns","useMemo","filter","pattern","_pattern$categories$f","isPatternFiltered","name","allPatternsCategory","myPatternsCategory","type","PATTERN_TYPES","user","categories","includes","availablePatternCategories","cat","find","availableCategory","length","pagingProps","usePatternsPaging","changePage","useEffect","onSetPatternSyncFilter","useCallback","value","onSetPatternSourceFilter","_react","createElement","className","__experimentalVStack","spacing","__experimentalHStack","FlexBlock","__experimentalHeading","level","as","label","PatternsFilter","__experimentalText","variant","__","default","ref","shownPatterns","categoryPatternsAsyncList","blockPatterns","categoryPatterns","orientation","isDraggable","patternFilter"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab/pattern-category-previews.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMemo,\n\tuseState,\n\tuseCallback,\n\tuseRef,\n\tuseEffect,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalHeading as Heading,\n\t__experimentalText as Text,\n\tFlexBlock,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport usePatternsState from '../hooks/use-patterns-state';\nimport BlockPatternsList from '../../block-patterns-list';\nimport usePatternsPaging from '../hooks/use-patterns-paging';\nimport { PatternsFilter } from './patterns-filter';\nimport { usePatternCategories } from './use-pattern-categories';\nimport {\n\tisPatternFiltered,\n\tallPatternsCategory,\n\tmyPatternsCategory,\n\tPATTERN_TYPES,\n} from './utils';\n\nconst noop = () => {};\n\nexport function PatternCategoryPreviews( {\n\trootClientId,\n\tonInsert,\n\tonHover = noop,\n\tcategory,\n\tshowTitlesAsTooltip,\n} ) {\n\tconst [ allPatterns, , onClickPattern ] = usePatternsState(\n\t\tonInsert,\n\t\trootClientId\n\t);\n\tconst [ patternSyncFilter, setPatternSyncFilter ] = useState( 'all' );\n\tconst [ patternSourceFilter, setPatternSourceFilter ] = useState( 'all' );\n\n\tconst availableCategories = usePatternCategories(\n\t\trootClientId,\n\t\tpatternSourceFilter\n\t);\n\tconst scrollContainerRef = useRef();\n\tconst currentCategoryPatterns = useMemo(\n\t\t() =>\n\t\t\tallPatterns.filter( ( pattern ) => {\n\t\t\t\tif (\n\t\t\t\t\tisPatternFiltered(\n\t\t\t\t\t\tpattern,\n\t\t\t\t\t\tpatternSourceFilter,\n\t\t\t\t\t\tpatternSyncFilter\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif ( category.name === allPatternsCategory.name ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\tcategory.name === myPatternsCategory.name &&\n\t\t\t\t\tpattern.type === PATTERN_TYPES.user\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif ( category.name !== 'uncategorized' ) {\n\t\t\t\t\treturn pattern.categories?.includes( category.name );\n\t\t\t\t}\n\n\t\t\t\t// The uncategorized category should show all the patterns without any category\n\t\t\t\t// or with no available category.\n\t\t\t\tconst availablePatternCategories =\n\t\t\t\t\tpattern.categories?.filter( ( cat ) =>\n\t\t\t\t\t\tavailableCategories.find(\n\t\t\t\t\t\t\t( availableCategory ) =>\n\t\t\t\t\t\t\t\tavailableCategory.name === cat\n\t\t\t\t\t\t)\n\t\t\t\t\t) ?? [];\n\n\t\t\t\treturn availablePatternCategories.length === 0;\n\t\t\t} ),\n\t\t[\n\t\t\tallPatterns,\n\t\t\tavailableCategories,\n\t\t\tcategory.name,\n\t\t\tpatternSourceFilter,\n\t\t\tpatternSyncFilter,\n\t\t]\n\t);\n\n\tconst pagingProps = usePatternsPaging(\n\t\tcurrentCategoryPatterns,\n\t\tcategory,\n\t\tscrollContainerRef\n\t);\n\tconst { changePage } = pagingProps;\n\n\t// Hide block pattern preview on unmount.\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tuseEffect( () => () => onHover( null ), [] );\n\n\tconst onSetPatternSyncFilter = useCallback(\n\t\t( value ) => {\n\t\t\tsetPatternSyncFilter( value );\n\t\t\tchangePage( 1 );\n\t\t},\n\t\t[ setPatternSyncFilter, changePage ]\n\t);\n\tconst onSetPatternSourceFilter = useCallback(\n\t\t( value ) => {\n\t\t\tsetPatternSourceFilter( value );\n\t\t\tchangePage( 1 );\n\t\t},\n\t\t[ setPatternSourceFilter, changePage ]\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-inserter__patterns-category-panel\">\n\t\t\t<VStack\n\t\t\t\tspacing={ 2 }\n\t\t\t\tclassName=\"block-editor-inserter__patterns-category-panel-header\"\n\t\t\t>\n\t\t\t\t<HStack>\n\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t<Heading level={ 4 } as=\"div\">\n\t\t\t\t\t\t\t{ category.label }\n\t\t\t\t\t\t</Heading>\n\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t<PatternsFilter\n\t\t\t\t\t\tpatternSyncFilter={ patternSyncFilter }\n\t\t\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t\t\t\tsetPatternSyncFilter={ onSetPatternSyncFilter }\n\t\t\t\t\t\tsetPatternSourceFilter={ onSetPatternSourceFilter }\n\t\t\t\t\t\tscrollContainerRef={ scrollContainerRef }\n\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t\t{ ! currentCategoryPatterns.length && (\n\t\t\t\t\t<Text\n\t\t\t\t\t\tvariant=\"muted\"\n\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-category-no-results\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'No results found' ) }\n\t\t\t\t\t</Text>\n\t\t\t\t) }\n\t\t\t</VStack>\n\n\t\t\t{ currentCategoryPatterns.length > 0 && (\n\t\t\t\t<BlockPatternsList\n\t\t\t\t\tref={ scrollContainerRef }\n\t\t\t\t\tshownPatterns={ pagingProps.categoryPatternsAsyncList }\n\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\tlabel={ category.label }\n\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\tcategory={ category.name }\n\t\t\t\t\tisDraggable\n\t\t\t\t\tshowTitlesAsTooltip={ showTitlesAsTooltip }\n\t\t\t\t\tpatternFilter={ patternSourceFilter }\n\t\t\t\t\tpagingProps={ pagingProps }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAOA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAWA,IAAAG,iBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,kBAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,kBAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,eAAA,GAAAP,OAAA;AACA,IAAAQ,qBAAA,GAAAR,OAAA;AACA,IAAAS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usePatternCategories(rootClientId, sourceFilter = 'all') {
37
37
  label: (0, _i18n._x)('Uncategorized')
38
38
  });
39
39
  }
40
- if (filteredPatterns.some(pattern => pattern.id)) {
40
+ if (filteredPatterns.some(pattern => pattern.type === _utils.PATTERN_TYPES.user)) {
41
41
  categories.unshift(_utils.myPatternsCategory);
42
42
  }
43
43
  if (filteredPatterns.length > 0) {
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_i18n","_a11y","_usePatternsState","_interopRequireDefault","_utils","usePatternCategories","rootClientId","sourceFilter","patterns","allCategories","usePatternsState","undefined","filteredPatterns","useMemo","filter","pattern","isPatternFiltered","hasRegisteredCategory","useCallback","categories","length","some","cat","category","name","populatedCategories","includes","sort","a","b","label","localeCompare","find","push","_x","id","unshift","myPatternsCategory","allPatternsCategory","speak","sprintf","_n"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab/use-pattern-categories.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { _x, _n, sprintf } from '@wordpress/i18n';\n\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport usePatternsState from '../hooks/use-patterns-state';\nimport {\n\tisPatternFiltered,\n\tallPatternsCategory,\n\tmyPatternsCategory,\n} from './utils';\n\nexport function usePatternCategories( rootClientId, sourceFilter = 'all' ) {\n\tconst [ patterns, allCategories ] = usePatternsState(\n\t\tundefined,\n\t\trootClientId\n\t);\n\n\tconst filteredPatterns = useMemo(\n\t\t() =>\n\t\t\tsourceFilter === 'all'\n\t\t\t\t? patterns\n\t\t\t\t: patterns.filter(\n\t\t\t\t\t\t( pattern ) =>\n\t\t\t\t\t\t\t! isPatternFiltered( pattern, sourceFilter )\n\t\t\t\t ),\n\t\t[ sourceFilter, patterns ]\n\t);\n\n\tconst hasRegisteredCategory = useCallback(\n\t\t( pattern ) => {\n\t\t\tif ( ! pattern.categories || ! pattern.categories.length ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn pattern.categories.some( ( cat ) =>\n\t\t\t\tallCategories.some( ( category ) => category.name === cat )\n\t\t\t);\n\t\t},\n\t\t[ allCategories ]\n\t);\n\n\t// Remove any empty categories.\n\tconst populatedCategories = useMemo( () => {\n\t\tconst categories = allCategories\n\t\t\t.filter( ( category ) =>\n\t\t\t\tfilteredPatterns.some( ( pattern ) =>\n\t\t\t\t\tpattern.categories?.includes( category.name )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.sort( ( a, b ) => a.label.localeCompare( b.label ) );\n\n\t\tif (\n\t\t\tfilteredPatterns.some(\n\t\t\t\t( pattern ) => ! hasRegisteredCategory( pattern )\n\t\t\t) &&\n\t\t\t! categories.find(\n\t\t\t\t( category ) => category.name === 'uncategorized'\n\t\t\t)\n\t\t) {\n\t\t\tcategories.push( {\n\t\t\t\tname: 'uncategorized',\n\t\t\t\tlabel: _x( 'Uncategorized' ),\n\t\t\t} );\n\t\t}\n\t\tif ( filteredPatterns.some( ( pattern ) => pattern.id ) ) {\n\t\t\tcategories.unshift( myPatternsCategory );\n\t\t}\n\t\tif ( filteredPatterns.length > 0 ) {\n\t\t\tcategories.unshift( {\n\t\t\t\tname: allPatternsCategory.name,\n\t\t\t\tlabel: allPatternsCategory.label,\n\t\t\t} );\n\t\t}\n\t\tspeak(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of categories . */\n\t\t\t\t_n(\n\t\t\t\t\t'%d category button displayed.',\n\t\t\t\t\t'%d category buttons displayed.',\n\t\t\t\t\tcategories.length\n\t\t\t\t),\n\t\t\t\tcategories.length\n\t\t\t)\n\t\t);\n\t\treturn categories;\n\t}, [ allCategories, filteredPatterns, hasRegisteredCategory ] );\n\n\treturn populatedCategories;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,iBAAA,GAAAC,sBAAA,CAAA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AI,CAClBN,OAAO,IAAM,CAAEE,qBAAqB,CAAEF,OAAQ,CACjD,CAAC,IACD,CAAEI,UAAU,CAACa,IAAI,CACdT,QAAQ,IAAMA,QAAQ,CAACC,IAAI,KAAK,eACnC,CAAC,EACA;MACDL,UAAU,CAACc,IAAI,CAAE;QAChBT,IAAI,EAAE,eAAe;QACrBM,KAAK,EAAE,IAAAI,QAAE,EAAE,eAAgB;MAC5B,CAAE,CAAC;IACJ;IACA,IAAKtB,gBAAgB,CAACS,IAAI,CAAIN,OAAO,IAAMA,OAAO,CAACoB,EAAG,CAAC,EAAG;MACzDhB,UAAU,CAACiB,OAAO,CAAEC,yBAAmB,CAAC;IACzC;IACA,IAAKzB,gBAAgB,CAACQ,MAAM,GAAG,CAAC,EAAG;MAClCD,UAAU,CAACiB,OAAO,CAAE;QACnBZ,IAAI,EAAEc,0BAAmB,CAACd,IAAI;QAC9BM,KAAK,EAAEQ,0BAAmB,CAACR;MAC5B,CAAE,CAAC;IACJ;IACA,IAAAS,WAAK,EACJ,IAAAC,aAAO,GACN;IACA,IAAAC,QAAE,EACD,+BAA+B,EAC/B,gCAAgC,EAChCtB,UAAU,CAACC,MACZ,CAAC,EACDD,UAAU,CAACC,MACZ,CACD,CAAC;IACD,OAAOD,UAAU;EAClB,CAAC,EAAE,CAAEV,aAAa,EAAEG,gBAAgB,EAAEK,qBAAqB,CAAG,CAAC;EAE/D,OAAOQ,mBAAmB;AAC3B"}
1
+ {"version":3,"names":["_element","require","_i18n","_a11y","_usePatternsState","_interopRequireDefault","_utils","usePatternCategories","rootClientId","sourceFilter","patterns","allCategories","usePatternsState","undefined","filteredPatterns","useMemo","filter","pattern","isPatternFiltered","hasRegisteredCategory","useCallback","categories","length","some","cat","category","name","populatedCategories","includes","sort","a","b","label","localeCompare","find","push","_x","type","PATTERN_TYPES","user","unshift","myPatternsCategory","allPatternsCategory","speak","sprintf","_n"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab/use-pattern-categories.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { _x, _n, sprintf } from '@wordpress/i18n';\n\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport usePatternsState from '../hooks/use-patterns-state';\nimport {\n\tisPatternFiltered,\n\tallPatternsCategory,\n\tmyPatternsCategory,\n\tPATTERN_TYPES,\n} from './utils';\n\nexport function usePatternCategories( rootClientId, sourceFilter = 'all' ) {\n\tconst [ patterns, allCategories ] = usePatternsState(\n\t\tundefined,\n\t\trootClientId\n\t);\n\n\tconst filteredPatterns = useMemo(\n\t\t() =>\n\t\t\tsourceFilter === 'all'\n\t\t\t\t? patterns\n\t\t\t\t: patterns.filter(\n\t\t\t\t\t\t( pattern ) =>\n\t\t\t\t\t\t\t! isPatternFiltered( pattern, sourceFilter )\n\t\t\t\t ),\n\t\t[ sourceFilter, patterns ]\n\t);\n\n\tconst hasRegisteredCategory = useCallback(\n\t\t( pattern ) => {\n\t\t\tif ( ! pattern.categories || ! pattern.categories.length ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn pattern.categories.some( ( cat ) =>\n\t\t\t\tallCategories.some( ( category ) => category.name === cat )\n\t\t\t);\n\t\t},\n\t\t[ allCategories ]\n\t);\n\n\t// Remove any empty categories.\n\tconst populatedCategories = useMemo( () => {\n\t\tconst categories = allCategories\n\t\t\t.filter( ( category ) =>\n\t\t\t\tfilteredPatterns.some( ( pattern ) =>\n\t\t\t\t\tpattern.categories?.includes( category.name )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.sort( ( a, b ) => a.label.localeCompare( b.label ) );\n\n\t\tif (\n\t\t\tfilteredPatterns.some(\n\t\t\t\t( pattern ) => ! hasRegisteredCategory( pattern )\n\t\t\t) &&\n\t\t\t! categories.find(\n\t\t\t\t( category ) => category.name === 'uncategorized'\n\t\t\t)\n\t\t) {\n\t\t\tcategories.push( {\n\t\t\t\tname: 'uncategorized',\n\t\t\t\tlabel: _x( 'Uncategorized' ),\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tfilteredPatterns.some(\n\t\t\t\t( pattern ) => pattern.type === PATTERN_TYPES.user\n\t\t\t)\n\t\t) {\n\t\t\tcategories.unshift( myPatternsCategory );\n\t\t}\n\t\tif ( filteredPatterns.length > 0 ) {\n\t\t\tcategories.unshift( {\n\t\t\t\tname: allPatternsCategory.name,\n\t\t\t\tlabel: allPatternsCategory.label,\n\t\t\t} );\n\t\t}\n\t\tspeak(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of categories . */\n\t\t\t\t_n(\n\t\t\t\t\t'%d category button displayed.',\n\t\t\t\t\t'%d category buttons displayed.',\n\t\t\t\t\tcategories.length\n\t\t\t\t),\n\t\t\t\tcategories.length\n\t\t\t)\n\t\t);\n\t\treturn categories;\n\t}, [ allCategories, filteredPatterns, hasRegisteredCategory ] );\n\n\treturn populatedCategories;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,iBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAZA;AACA;AACA;;AAMA;AACA;AACA;;AASO,SAASM,oBAAoBA,CAAEC,YAAY,EAAEC,YAAY,GAAG,KAAK,EAAG;EAC1E,MAAM,CAAEC,QAAQ,EAAEC,aAAa,CAAE,GAAG,IAAAC,yBAAgB,EACnDC,SAAS,EACTL,YACD,CAAC;EAED,MAAMM,gBAAgB,GAAG,IAAAC,gBAAO,EAC/B,MACCN,YAAY,KAAK,KAAK,GACnBC,QAAQ,GACRA,QAAQ,CAACM,MAAM,CACbC,OAAO,IACR,CAAE,IAAAC,wBAAiB,EAAED,OAAO,EAAER,YAAa,CAC5C,CAAC,EACL,CAAEA,YAAY,EAAEC,QAAQ,CACzB,CAAC;EAED,MAAMS,qBAAqB,GAAG,IA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;MAClCD,UAAU,CAACmB,OAAO,CAAE;QACnBd,IAAI,EAAEgB,0BAAmB,CAAChB,IAAI;QAC9BM,KAAK,EAAEU,0BAAmB,CAACV;MAC5B,CAAE,CAAC;IACJ;IACA,IAAAW,WAAK,EACJ,IAAAC,aAAO,GACN;IACA,IAAAC,QAAE,EACD,+BAA+B,EAC/B,gCAAgC,EAChCxB,UAAU,CAACC,MACZ,CAAC,EACDD,UAAU,CAACC,MACZ,CACD,CAAC;IACD,OAAOD,UAAU;EAClB,CAAC,EAAE,CAAEV,aAAa,EAAEG,gBAAgB,EAAEK,qBAAqB,CAAG,CAAC;EAE/D,OAAOQ,mBAAmB;AAC3B"}
@@ -28,7 +28,7 @@ const SYNC_TYPES = {
28
28
  exports.SYNC_TYPES = SYNC_TYPES;
29
29
  const allPatternsCategory = {
30
30
  name: 'allPatterns',
31
- label: (0, _i18n.__)('All patterns')
31
+ label: (0, _i18n.__)('All')
32
32
  };
33
33
  exports.allPatternsCategory = allPatternsCategory;
34
34
  const myPatternsCategory = {
@@ -52,9 +52,8 @@ function isPatternFiltered(pattern, sourceFilter, syncFilter) {
52
52
  return true;
53
53
  }
54
54
 
55
- // If user source selected, filter out theme patterns. Any pattern without
56
- // an id wasn't created by a user.
57
- if (sourceFilter === PATTERN_TYPES.user && !pattern.id) {
55
+ // If user source selected, filter out theme patterns.
56
+ if (sourceFilter === PATTERN_TYPES.user && pattern.type !== PATTERN_TYPES.user) {
58
57
  return true;
59
58
  }
60
59
 
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","PATTERN_TYPES","all","synced","unsynced","user","theme","directory","exports","SYNC_TYPES","full","allPatternsCategory","name","label","__","myPatternsCategory","isPatternFiltered","pattern","sourceFilter","syncFilter","isUserPattern","startsWith","isDirectoryPattern","source","id","syncStatus"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport { __ } from '@wordpress/i18n';\n\nexport const PATTERN_TYPES = {\n\tall: 'all',\n\tsynced: 'synced',\n\tunsynced: 'unsynced',\n\tuser: 'user',\n\ttheme: 'theme',\n\tdirectory: 'directory',\n};\n\nexport const SYNC_TYPES = {\n\tall: 'all',\n\tfull: 'fully',\n\tunsynced: 'unsynced',\n};\n\nexport const allPatternsCategory = {\n\tname: 'allPatterns',\n\tlabel: __( 'All patterns' ),\n};\n\nexport const myPatternsCategory = {\n\tname: 'myPatterns',\n\tlabel: __( 'My patterns' ),\n};\n\nexport function isPatternFiltered( pattern, sourceFilter, syncFilter ) {\n\tconst isUserPattern = pattern.name.startsWith( 'core/block' );\n\tconst isDirectoryPattern =\n\t\tpattern.source === 'core' ||\n\t\tpattern.source?.startsWith( 'pattern-directory' );\n\n\t// If theme source selected, filter out user created patterns and those from\n\t// the core patterns directory.\n\tif (\n\t\tsourceFilter === PATTERN_TYPES.theme &&\n\t\t( isUserPattern || isDirectoryPattern )\n\t) {\n\t\treturn true;\n\t}\n\n\t// If the directory source is selected, filter out user created patterns\n\t// and those bundled with the theme.\n\tif (\n\t\tsourceFilter === PATTERN_TYPES.directory &&\n\t\t( isUserPattern || ! isDirectoryPattern )\n\t) {\n\t\treturn true;\n\t}\n\n\t// If user source selected, filter out theme patterns. Any pattern without\n\t// an id wasn't created by a user.\n\tif ( sourceFilter === PATTERN_TYPES.user && ! pattern.id ) {\n\t\treturn true;\n\t}\n\n\t// Filter by sync status.\n\tif ( syncFilter === SYNC_TYPES.full && pattern.syncStatus !== '' ) {\n\t\treturn true;\n\t}\n\n\tif (\n\t\tsyncFilter === SYNC_TYPES.unsynced &&\n\t\tpattern.syncStatus !== 'unsynced' &&\n\t\tisUserPattern\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n"],"mappings":";;;;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIO,MAAMC,aAAa,GAAG;EAC5BC,GAAG,EAAE,KAAK;EACVC,MAAM,EAAE,QAAQ;EAChBC,QA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U,KAAKV,UAAU,CAACC,IAAI,IAAIO,OAAO,CAACQ,UAAU,KAAK,EAAE,EAAG;IAClE,OAAO,IAAI;EACZ;EAEA,IACCN,UAAU,KAAKV,UAAU,CAACL,QAAQ,IAClCa,OAAO,CAACQ,UAAU,KAAK,UAAU,IACjCL,aAAa,EACZ;IACD,OAAO,IAAI;EACZ;EAEA,OAAO,KAAK;AACb"}
1
+ {"version":3,"names":["_i18n","require","PATTERN_TYPES","all","synced","unsynced","user","theme","directory","exports","SYNC_TYPES","full","allPatternsCategory","name","label","__","myPatternsCategory","isPatternFiltered","pattern","sourceFilter","syncFilter","isUserPattern","startsWith","isDirectoryPattern","source","type","syncStatus"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport { __ } from '@wordpress/i18n';\n\nexport const PATTERN_TYPES = {\n\tall: 'all',\n\tsynced: 'synced',\n\tunsynced: 'unsynced',\n\tuser: 'user',\n\ttheme: 'theme',\n\tdirectory: 'directory',\n};\n\nexport const SYNC_TYPES = {\n\tall: 'all',\n\tfull: 'fully',\n\tunsynced: 'unsynced',\n};\n\nexport const allPatternsCategory = {\n\tname: 'allPatterns',\n\tlabel: __( 'All' ),\n};\n\nexport const myPatternsCategory = {\n\tname: 'myPatterns',\n\tlabel: __( 'My patterns' ),\n};\n\nexport function isPatternFiltered( pattern, sourceFilter, syncFilter ) {\n\tconst isUserPattern = pattern.name.startsWith( 'core/block' );\n\tconst isDirectoryPattern =\n\t\tpattern.source === 'core' ||\n\t\tpattern.source?.startsWith( 'pattern-directory' );\n\n\t// If theme source selected, filter out user created patterns and those from\n\t// the core patterns directory.\n\tif (\n\t\tsourceFilter === PATTERN_TYPES.theme &&\n\t\t( isUserPattern || isDirectoryPattern )\n\t) {\n\t\treturn true;\n\t}\n\n\t// If the directory source is selected, filter out user created patterns\n\t// and those bundled with the theme.\n\tif (\n\t\tsourceFilter === PATTERN_TYPES.directory &&\n\t\t( isUserPattern || ! isDirectoryPattern )\n\t) {\n\t\treturn true;\n\t}\n\n\t// If user source selected, filter out theme patterns.\n\tif (\n\t\tsourceFilter === PATTERN_TYPES.user &&\n\t\tpattern.type !== PATTERN_TYPES.user\n\t) {\n\t\treturn true;\n\t}\n\n\t// Filter by sync status.\n\tif ( syncFilter === SYNC_TYPES.full && pattern.syncStatus !== '' ) {\n\t\treturn true;\n\t}\n\n\tif (\n\t\tsyncFilter === SYNC_TYPES.unsynced &&\n\t\tpattern.syncStatus !== 'unsynced' &&\n\t\tisUserPattern\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n"],"mappings":";;;;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIO,MAAMC,aAAa,GAAG;EAC5BC,GAAG,EAAE,KAAK;EACVC,MAAM,EAAE,QAAQ;EAChBC,QAAQ,EAAE,UAAU;EACpBC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,OAAO;EACdC,SAAS,EAAE;AACZ,CAAC;AAACC,OAAA,CAAAP,aAAA,GAAAA,aAAA;AAEK,MAAMQ,UAAU,GAAG;EACzBP,GAAG,EAAE,KAAK;EACVQ,IAAI,EAAE,OAAO;EACbN,QAAQ,EAAE;AACX,CAAC;AAACI,OAAA,CAAAC,UAAA,GAAAA,UAAA;AAEK,MAAME,mBAAmB,GAAG;EAClCC,IAAI,EAAE,aAAa;EACnBC,KAAK,EAAE,IAAAC,QAAE,EAAE,KAAM;AAClB,CAAC;AAACN,OAAA,CAAAG,mBAAA,GAAAA,mBAAA;AAEK,MAAMI,kBAAkB,GAAG;EACjCH,IAAI,EAAE,YAAY;EAClBC,KAAK,EAAE,IAAAC,QAAE,EAAE,aAAc;AAC1B,CAAC;AAACN,OAAA,CAAAO,kBAAA,GAAAA,kBAAA;AAEK,SAASC,iBAAiBA,CAAEC,OAAO,EAAEC,YAAY,EAAEC,UAAU,EAAG;EACtE,MAAMC,aAAa,GAAGH,OAAO,CAACL,IAAI,CAACS,UAAU,CAAE,YAAa,CAAC;EAC7D,MAAMC,kBAAkB,GACvBL,OAAO,CAACM,MAAM,KAAK,MAAM,IACzBN,OAAO,CAACM,MAAM,EAAEF,UAAU,CAAE,mBAAoB,CAAC;;EAElD;EACA;EACA,IACCH,YAAY,KAAKjB,aAAa,CAACK,KAAK,KAClCc,aAAa,IAAIE,kBAAkB,CAAE,EACtC;IACD,OAAO,IAAI;EACZ;;EAEA;EACA;EACA,IACCJ,YAAY,KAAKjB,aAAa,CAACM,SAAS,KACtCa,aAAa,IAAI,CAAEE,kBAAkB,CAAE,EACxC;IACD,OAAO,IAAI;EACZ;;EAEA;EACA,IACCJ,YAAY,KAAKjB,aAAa,CAACI,IAAI,IACnCY,OAAO,CAACO,IAAI,KAAKvB,aAAa,CAACI,IAAI,EAClC;IACD,OAAO,IAAI;EACZ;;EAEA;EACA,IAAKc,UAAU,KAAKV,UAAU,CAACC,IAAI,IAAIO,OAAO,CAACQ,UAAU,KAAK,EAAE,EAAG;IAClE,OAAO,IAAI;EACZ;EAEA,IACCN,UAAU,KAAKV,UAAU,CAACL,QAAQ,IAClCa,OAAO,CAACQ,UAAU,KAAK,UAAU,IACjCL,aAAa,EACZ;IACD,OAAO,IAAI;EACZ;EAEA,OAAO,KAAK;AACb"}
@@ -10,6 +10,7 @@ var _data = require("@wordpress/data");
10
10
  var _i18n = require("@wordpress/i18n");
11
11
  var _notices = require("@wordpress/notices");
12
12
  var _store = require("../../../store");
13
+ var _utils = require("../block-patterns-tab/utils");
13
14
  /**
14
15
  * WordPress dependencies
15
16
  */
@@ -59,7 +60,7 @@ const usePatternsState = (onInsert, rootClientId) => {
59
60
  createSuccessNotice
60
61
  } = (0, _data.useDispatch)(_notices.store);
61
62
  const onClickPattern = (0, _element.useCallback)((pattern, blocks) => {
62
- const patternBlocks = pattern.id && pattern.syncStatus !== 'unsynced' ? [(0, _blocks.createBlock)('core/block', {
63
+ const patternBlocks = pattern.type === _utils.PATTERN_TYPES.user && pattern.syncStatus !== 'unsynced' ? [(0, _blocks.createBlock)('core/block', {
63
64
  ref: pattern.id
64
65
  })] : blocks;
65
66
  onInsert((patternBlocks !== null && patternBlocks !== void 0 ? patternBlocks : []).map(block => (0, _blocks.cloneBlock)(block)), pattern.name);
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_blocks","_data","_i18n","_notices","_store","usePatternsState","onInsert","rootClientId","patternCategories","patterns","userPatternCategories","useSelect","select","__experimentalGetAllowedPatterns","getSettings","blockEditorStore","__experimentalUserPatternCategories","__experimentalBlockPatternCategories","allCategories","useMemo","categories","forEach","userCategory","find","existingCategory","name","push","createSuccessNotice","useDispatch","noticesStore","onClickPattern","useCallback","pattern","blocks","patternBlocks","id","syncStatus","createBlock","ref","map","block","cloneBlock","sprintf","__","title","type","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-patterns-state.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { cloneBlock, createBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * Retrieves the block patterns inserter state.\n *\n * @param {Function} onInsert function called when inserter a list of blocks.\n * @param {string=} rootClientId Insertion's root client ID.\n *\n * @return {Array} Returns the patterns state. (patterns, categories, onSelect handler)\n */\nconst usePatternsState = ( onInsert, rootClientId ) => {\n\tconst { patternCategories, patterns, userPatternCategories } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { __experimentalGetAllowedPatterns, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst {\n\t\t\t\t__experimentalUserPatternCategories,\n\t\t\t\t__experimentalBlockPatternCategories,\n\t\t\t} = getSettings();\n\t\t\treturn {\n\t\t\t\tpatterns: __experimentalGetAllowedPatterns( rootClientId ),\n\t\t\t\tuserPatternCategories: __experimentalUserPatternCategories,\n\t\t\t\tpatternCategories: __experimentalBlockPatternCategories,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tconst allCategories = useMemo( () => {\n\t\tconst categories = [ ...patternCategories ];\n\t\tuserPatternCategories?.forEach( ( userCategory ) => {\n\t\t\tif (\n\t\t\t\t! categories.find(\n\t\t\t\t\t( existingCategory ) =>\n\t\t\t\t\t\texistingCategory.name === userCategory.name\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tcategories.push( userCategory );\n\t\t\t}\n\t\t} );\n\t\treturn categories;\n\t}, [ patternCategories, userPatternCategories ] );\n\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst onClickPattern = useCallback(\n\t\t( pattern, blocks ) => {\n\t\t\tconst patternBlocks =\n\t\t\t\tpattern.id && pattern.syncStatus !== 'unsynced'\n\t\t\t\t\t? [ createBlock( 'core/block', { ref: pattern.id } ) ]\n\t\t\t\t\t: blocks;\n\t\t\tonInsert(\n\t\t\t\t( patternBlocks ?? [] ).map( ( block ) => cloneBlock( block ) ),\n\t\t\t\tpattern.name\n\t\t\t);\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: block pattern title. */\n\t\t\t\t\t__( 'Block pattern \"%s\" inserted.' ),\n\t\t\t\t\tpattern.title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'block-pattern-inserted-notice',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t\t[ createSuccessNotice, onInsert ]\n\t);\n\n\treturn [ patterns, allCategories, onClickPattern ];\n};\n\nexport default usePatternsState;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA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,UAAU,GAC5C,CAAE,IAAAC,mBAAW,EAAE,YAAY,EAAE;MAAEC,GAAG,EAAEN,OAAO,CAACG;IAAG,CAAE,CAAC,CAAE,GACpDF,MAAM;IACV3B,QAAQ,CACP,CAAE4B,aAAa,aAAbA,aAAa,cAAbA,aAAa,GAAI,EAAE,EAAGK,GAAG,CAAIC,KAAK,IAAM,IAAAC,kBAAU,EAAED,KAAM,CAAE,CAAC,EAC/DR,OAAO,CAACP,IACT,CAAC;IACDE,mBAAmB,CAClB,IAAAe,aAAO,GACN;IACA,IAAAC,QAAE,EAAE,8BAA+B,CAAC,EACpCX,OAAO,CAACY,KACT,CAAC,EACD;MACCC,IAAI,EAAE,UAAU;MAChBV,EAAE,EAAE;IACL,CACD,CAAC;EACF,CAAC,EACD,CAAER,mBAAmB,EAAErB,QAAQ,CAChC,CAAC;EAED,OAAO,CAAEG,QAAQ,EAAES,aAAa,EAAEY,cAAc,CAAE;AACnD,CAAC;AAAC,IAAAgB,QAAA,GAEazC,gBAAgB;AAAA0C,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_element","require","_blocks","_data","_i18n","_notices","_store","_utils","usePatternsState","onInsert","rootClientId","patternCategories","patterns","userPatternCategories","useSelect","select","__experimentalGetAllowedPatterns","getSettings","blockEditorStore","__experimentalUserPatternCategories","__experimentalBlockPatternCategories","allCategories","useMemo","categories","forEach","userCategory","find","existingCategory","name","push","createSuccessNotice","useDispatch","noticesStore","onClickPattern","useCallback","pattern","blocks","patternBlocks","type","PATTERN_TYPES","user","syncStatus","createBlock","ref","id","map","block","cloneBlock","sprintf","__","title","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-patterns-state.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { cloneBlock, createBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { PATTERN_TYPES } from '../block-patterns-tab/utils';\n\n/**\n * Retrieves the block patterns inserter state.\n *\n * @param {Function} onInsert function called when inserter a list of blocks.\n * @param {string=} rootClientId Insertion's root client ID.\n *\n * @return {Array} Returns the patterns state. (patterns, categories, onSelect handler)\n */\nconst usePatternsState = ( onInsert, rootClientId ) => {\n\tconst { patternCategories, patterns, userPatternCategories } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { __experimentalGetAllowedPatterns, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst {\n\t\t\t\t__experimentalUserPatternCategories,\n\t\t\t\t__experimentalBlockPatternCategories,\n\t\t\t} = getSettings();\n\t\t\treturn {\n\t\t\t\tpatterns: __experimentalGetAllowedPatterns( rootClientId ),\n\t\t\t\tuserPatternCategories: __experimentalUserPatternCategories,\n\t\t\t\tpatternCategories: __experimentalBlockPatternCategories,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tconst allCategories = useMemo( () => {\n\t\tconst categories = [ ...patternCategories ];\n\t\tuserPatternCategories?.forEach( ( userCategory ) => {\n\t\t\tif (\n\t\t\t\t! categories.find(\n\t\t\t\t\t( existingCategory ) =>\n\t\t\t\t\t\texistingCategory.name === userCategory.name\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tcategories.push( userCategory );\n\t\t\t}\n\t\t} );\n\t\treturn categories;\n\t}, [ patternCategories, userPatternCategories ] );\n\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst onClickPattern = useCallback(\n\t\t( pattern, blocks ) => {\n\t\t\tconst patternBlocks =\n\t\t\t\tpattern.type === PATTERN_TYPES.user &&\n\t\t\t\tpattern.syncStatus !== 'unsynced'\n\t\t\t\t\t? [ createBlock( 'core/block', { ref: pattern.id } ) ]\n\t\t\t\t\t: blocks;\n\t\t\tonInsert(\n\t\t\t\t( patternBlocks ?? [] ).map( ( block ) => cloneBlock( block ) ),\n\t\t\t\tpattern.name\n\t\t\t);\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: block pattern title. */\n\t\t\t\t\t__( 'Block pattern \"%s\" inserted.' ),\n\t\t\t\t\tpattern.title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'block-pattern-inserted-notice',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t\t[ createSuccessNotice, onInsert ]\n\t);\n\n\treturn [ patterns, allCategories, onClickPattern ];\n};\n\nexport default usePatternsState;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAOA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMO,gBAAgB,GAAGA,CAAEC,QAAQ,EAAEC,YAAY,KAAM;EACtD,MAAM;IAAEC,iBAAiB;IAAEC,QAAQ;IAAEC;EAAsB,CAAC,GAAG,IAAAC,eAAS,EACrEC,MAAM,IAAM;IACb,MAAM;MAAEC,gCAAgC;MAAEC;IAAY,CAAC,GACtDF,MAAM,CAAEG,YAAiB,CAAC;IAC3B,MAAM;MACLC,mCAAmC;MACnCC;IACD,CAAC,GAAGH,WAAW,CAAC,CAAC;IACjB,OAAO;MACNL,QAAQ,EAAEI,gCAAgC,CAAEN,YAAa,CAAC;MAC1DG,qBAAqB,EAAEM,mCAAmC;MAC1DR,iBAAiB,EAAES;IACpB,CAAC;EACF,CAAC,EACD,CAAEV,YAAY,CACf,CAAC;EAED,MAAMW,aAAa,GAAG,IAAAC,gBAAO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AAC,IAAAkB,QAAA,GAEa3C,gBAAgB;AAAA4C,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -25,7 +25,7 @@ Object.defineProperty(exports, "InserterListboxRow", {
25
25
  exports.default = void 0;
26
26
  var _react = require("react");
27
27
  var _components = require("@wordpress/components");
28
- var _context = _interopRequireDefault(require("./context"));
28
+ var _lockUnlock = require("../../lock-unlock");
29
29
  var _group = _interopRequireDefault(require("./group"));
30
30
  var _row = _interopRequireDefault(require("./row"));
31
31
  var _item = _interopRequireDefault(require("./item"));
@@ -37,15 +37,20 @@ var _item = _interopRequireDefault(require("./item"));
37
37
  * Internal dependencies
38
38
  */
39
39
 
40
+ const {
41
+ CompositeV2: Composite,
42
+ useCompositeStoreV2: useCompositeStore
43
+ } = (0, _lockUnlock.unlock)(_components.privateApis);
40
44
  function InserterListbox({
41
45
  children
42
46
  }) {
43
- const compositeState = (0, _components.__unstableUseCompositeState)({
44
- shift: true,
45
- wrap: 'horizontal'
47
+ const store = useCompositeStore({
48
+ focusShift: true,
49
+ focusWrap: 'horizontal'
46
50
  });
47
- return (0, _react.createElement)(_context.default.Provider, {
48
- value: compositeState
51
+ return (0, _react.createElement)(Composite, {
52
+ store: store,
53
+ render: (0, _react.createElement)(_react.Fragment, null)
49
54
  }, children);
50
55
  }
51
56
  var _default = InserterListbox;
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_context","_interopRequireDefault","_group","_row","_item","InserterListbox","children","compositeState","useCompositeState","shift","wrap","_react","createElement","default","Provider","value","_default","exports"],"sources":["@wordpress/block-editor/src/components/inserter-listbox/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __unstableUseCompositeState as useCompositeState } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport InserterListboxContext from './context';\n\nexport { default as InserterListboxGroup } from './group';\nexport { default as InserterListboxRow } from './row';\nexport { default as InserterListboxItem } from './item';\n\nfunction InserterListbox( { children } ) {\n\tconst compositeState = useCompositeState( {\n\t\tshift: true,\n\t\twrap: 'horizontal',\n\t} );\n\treturn (\n\t\t<InserterListboxContext.Provider value={ compositeState }>\n\t\t\t{ children }\n\t\t</InserterListboxContext.Provider>\n\t);\n}\n\nexport default InserterListbox;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,IAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,KAAA,GAAAH,sBAAA,CAAAF,OAAA;AAZA;AACA;AACA;;AAGA;AACA;AACA;;AAOA,SAASM,eAAeA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACxC,MAAMC,cAAc,GAAG,IAAAC,uCAAiB,EAAE;IACzCC,KAAK,EAAE,IAAI;IACXC,IAAI,EAAE;EACP,CAAE,CAAC;EACH,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACZ,QAAA,CAAAa,OAAsB,CAACC,QAAQ;IAACC,KAAK,EAAGR;EAAgB,GACtDD,QAC8B,CAAC;AAEpC;AAAC,IAAAU,QAAA,GAEcX,eAAe;AAAAY,OAAA,CAAAJ,OAAA,GAAAG,QAAA"}
1
+ {"version":3,"names":["_components","require","_lockUnlock","_group","_interopRequireDefault","_row","_item","CompositeV2","Composite","useCompositeStoreV2","useCompositeStore","unlock","componentsPrivateApis","InserterListbox","children","store","focusShift","focusWrap","_react","createElement","render","Fragment","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/inserter-listbox/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nexport { default as InserterListboxGroup } from './group';\nexport { default as InserterListboxRow } from './row';\nexport { default as InserterListboxItem } from './item';\n\nconst { CompositeV2: Composite, useCompositeStoreV2: useCompositeStore } =\n\tunlock( componentsPrivateApis );\n\nfunction InserterListbox( { children } ) {\n\tconst store = useCompositeStore( {\n\t\tfocusShift: true,\n\t\tfocusWrap: 'horizontal',\n\t} );\n\n\treturn (\n\t\t<Composite store={ store } render={ <></> }>\n\t\t\t{ children }\n\t\t</Composite>\n\t);\n}\n\nexport default InserterListbox;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,IAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,KAAA,GAAAF,sBAAA,CAAAH,OAAA;AAZA;AACA;AACA;;AAGA;AACA;AACA;;AAOA,MAAM;EAAEM,WAAW,EAAEC,SAAS;EAAEC,mBAAmB,EAAEC;AAAkB,CAAC,GACvE,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;AAEhC,SAASC,eAAeA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACxC,MAAMC,KAAK,GAAGL,iBAAiB,CAAE;IAChCM,UAAU,EAAE,IAAI;IAChBC,SAAS,EAAE;EACZ,CAAE,CAAC;EAEH,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACX,SAAS;IAACO,KAAK,EAAGA,KAAO;IAACK,MAAM,EAAG,IAAAF,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAG,QAAA,MAAI;EAAG,GACxCP,QACQ,CAAC;AAEd;AAAC,IAAAQ,QAAA,GAEcT,eAAe;AAAAU,OAAA,CAAAC,OAAA,GAAAF,QAAA"}