@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
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_data","_element","_compose","_i18n","_icons","_useSettings","_store","_utils","CUSTOM_VALUE_SETTINGS","px","max","steps","vw","vh","em","rm","svw","lvw","dvw","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","SpacingInputControl","icon","isMixed","minimumCustomValue","onChange","onMouseOut","onMouseOver","showSideInLabel","side","spacingSizes","type","value","_CUSTOM_VALUE_SETTING","_CUSTOM_VALUE_SETTING2","getPresetValueFromCustomValue","selectListSizes","showRangeControl","length","disableCustomSpacingSizes","useSelect","select","editorSettings","blockEditorStore","getSettings","showCustomValueControl","setShowCustomValueControl","useState","undefined","isValueSpacingPreset","previousValue","usePrevious","availableUnits","useSettings","units","useCustomUnits","currentValue","showCustomValueInSelectList","name","sprintf","__","slug","size","getSliderValueFromPreset","getCustomValueFromPreset","selectedUnit","useMemo","parseQuantityAndUnitFromRawValue","setInitialValue","customTooltipContent","newValue","customRangeValue","parseFloat","getNewCustomValue","newSize","isNumeric","isNaN","nextValue","getNewPresetValue","controlType","parseInt","handleCustomValueSliderChange","next","join","allPlaceholder","options","map","index","key","marks","_newValue","label","sideLabel","ALL_SIDES","includes","LABELS","typeLabel","toLowerCase","ariaLabel","trim","_react","createElement","__experimentalHStack","className","Icon","Fragment","__experimentalUnitControl","onFocus","onBlur","min","placeholder","disableUnits","hideLabelFromVision","RangeControl","step","withInputField","__nextHasNoMarginBottom","onMouseDown","event","nativeEvent","offsetX","renderTooltipContent","CustomSelectControl","find","option","selection","selectedItem","__nextUnconstrainedWidth","Button","settings","onClick","isPressed","isSmall","iconSize"],"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/input-controls/spacing-input-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCustomSelectControl,\n\tIcon,\n\tRangeControl,\n\t__experimentalHStack as HStack,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { usePrevious } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { settings } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../../use-settings';\nimport { store as blockEditorStore } from '../../../store';\nimport {\n\tALL_SIDES,\n\tLABELS,\n\tgetSliderValueFromPreset,\n\tgetCustomValueFromPreset,\n\tgetPresetValueFromCustomValue,\n\tisValueSpacingPreset,\n} from '../utils';\n\nconst CUSTOM_VALUE_SETTINGS = {\n\tpx: { max: 300, steps: 1 },\n\t'%': { max: 100, steps: 1 },\n\tvw: { max: 100, steps: 1 },\n\tvh: { max: 100, steps: 1 },\n\tem: { max: 10, steps: 0.1 },\n\trm: { max: 10, steps: 0.1 },\n\tsvw: { max: 100, steps: 1 },\n\tlvw: { max: 100, steps: 1 },\n\tdvw: { max: 100, steps: 1 },\n\tsvh: { max: 100, steps: 1 },\n\tlvh: { max: 100, steps: 1 },\n\tdvh: { max: 100, steps: 1 },\n\tvi: { max: 100, steps: 1 },\n\tsvi: { max: 100, steps: 1 },\n\tlvi: { max: 100, steps: 1 },\n\tdvi: { max: 100, steps: 1 },\n\tvb: { max: 100, steps: 1 },\n\tsvb: { max: 100, steps: 1 },\n\tlvb: { max: 100, steps: 1 },\n\tdvb: { max: 100, steps: 1 },\n\tvmin: { max: 100, steps: 1 },\n\tsvmin: { max: 100, steps: 1 },\n\tlvmin: { max: 100, steps: 1 },\n\tdvmin: { max: 100, steps: 1 },\n\tvmax: { max: 100, steps: 1 },\n\tsvmax: { max: 100, steps: 1 },\n\tlvmax: { max: 100, steps: 1 },\n\tdvmax: { max: 100, steps: 1 },\n};\n\nexport default function SpacingInputControl( {\n\ticon,\n\tisMixed = false,\n\tminimumCustomValue,\n\tonChange,\n\tonMouseOut,\n\tonMouseOver,\n\tshowSideInLabel = true,\n\tside,\n\tspacingSizes,\n\ttype,\n\tvalue,\n} ) {\n\t// Treat value as a preset value if the passed in value matches the value of one of the spacingSizes.\n\tvalue = getPresetValueFromCustomValue( value, spacingSizes );\n\n\tlet selectListSizes = spacingSizes;\n\tconst showRangeControl = spacingSizes.length <= 8;\n\n\tconst disableCustomSpacingSizes = useSelect( ( select ) => {\n\t\tconst editorSettings = select( blockEditorStore ).getSettings();\n\t\treturn editorSettings?.disableCustomSpacingSizes;\n\t} );\n\n\tconst [ showCustomValueControl, setShowCustomValueControl ] = useState(\n\t\t! disableCustomSpacingSizes &&\n\t\t\tvalue !== undefined &&\n\t\t\t! isValueSpacingPreset( value )\n\t);\n\n\tconst previousValue = usePrevious( value );\n\tif (\n\t\t!! value &&\n\t\tpreviousValue !== value &&\n\t\t! isValueSpacingPreset( value ) &&\n\t\tshowCustomValueControl !== true\n\t) {\n\t\tsetShowCustomValueControl( true );\n\t}\n\n\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnits || [ 'px', 'em', 'rem' ],\n\t} );\n\n\tlet currentValue = null;\n\n\tconst showCustomValueInSelectList =\n\t\t! showRangeControl &&\n\t\t! showCustomValueControl &&\n\t\tvalue !== undefined &&\n\t\t( ! isValueSpacingPreset( value ) ||\n\t\t\t( isValueSpacingPreset( value ) && isMixed ) );\n\n\tif ( showCustomValueInSelectList ) {\n\t\tselectListSizes = [\n\t\t\t...spacingSizes,\n\t\t\t{\n\t\t\t\tname: ! isMixed\n\t\t\t\t\t? // translators: A custom measurement, eg. a number followed by a unit like 12px.\n\t\t\t\t\t sprintf( __( 'Custom (%s)' ), value )\n\t\t\t\t\t: __( 'Mixed' ),\n\t\t\t\tslug: 'custom',\n\t\t\t\tsize: value,\n\t\t\t},\n\t\t];\n\t\tcurrentValue = selectListSizes.length - 1;\n\t} else if ( ! isMixed ) {\n\t\tcurrentValue = ! showCustomValueControl\n\t\t\t? getSliderValueFromPreset( value, spacingSizes )\n\t\t\t: getCustomValueFromPreset( value, spacingSizes );\n\t}\n\n\tconst selectedUnit =\n\t\tuseMemo(\n\t\t\t() => parseQuantityAndUnitFromRawValue( currentValue ),\n\t\t\t[ currentValue ]\n\t\t)[ 1 ] || units[ 0 ].value;\n\n\tconst setInitialValue = () => {\n\t\tif ( value === undefined ) {\n\t\t\tonChange( '0' );\n\t\t}\n\t};\n\n\tconst customTooltipContent = ( newValue ) =>\n\t\tvalue === undefined ? undefined : spacingSizes[ newValue ]?.name;\n\n\tconst customRangeValue = parseFloat( currentValue, 10 );\n\n\tconst getNewCustomValue = ( newSize ) => {\n\t\tconst isNumeric = ! isNaN( parseFloat( newSize ) );\n\t\tconst nextValue = isNumeric ? newSize : undefined;\n\t\treturn nextValue;\n\t};\n\n\tconst getNewPresetValue = ( newSize, controlType ) => {\n\t\tconst size = parseInt( newSize, 10 );\n\n\t\tif ( controlType === 'selectList' ) {\n\t\t\tif ( size === 0 ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif ( size === 1 ) {\n\t\t\t\treturn '0';\n\t\t\t}\n\t\t} else if ( size === 0 ) {\n\t\t\treturn '0';\n\t\t}\n\t\treturn `var:preset|spacing|${ spacingSizes[ newSize ]?.slug }`;\n\t};\n\n\tconst handleCustomValueSliderChange = ( next ) => {\n\t\tonChange( [ next, selectedUnit ].join( '' ) );\n\t};\n\n\tconst allPlaceholder = isMixed ? __( 'Mixed' ) : null;\n\n\tconst options = selectListSizes.map( ( size, index ) => ( {\n\t\tkey: index,\n\t\tname: size.name,\n\t} ) );\n\n\tconst marks = spacingSizes.map( ( _newValue, index ) => ( {\n\t\tvalue: index,\n\t\tlabel: undefined,\n\t} ) );\n\n\tconst sideLabel =\n\t\tALL_SIDES.includes( side ) && showSideInLabel ? LABELS[ side ] : '';\n\tconst typeLabel = showSideInLabel ? type?.toLowerCase() : type;\n\n\tconst ariaLabel = sprintf(\n\t\t// translators: 1: The side of the block being modified (top, bottom, left, All sides etc.). 2. Type of spacing being modified (Padding, margin, etc)\n\t\t__( '%1$s %2$s' ),\n\t\tsideLabel,\n\t\ttypeLabel\n\t).trim();\n\n\treturn (\n\t\t<HStack className=\"spacing-sizes-control__wrapper\">\n\t\t\t{ icon && (\n\t\t\t\t<Icon\n\t\t\t\t\tclassName=\"spacing-sizes-control__icon\"\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tsize={ 24 }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showCustomValueControl && (\n\t\t\t\t<>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\t\tonChange={ ( newSize ) =>\n\t\t\t\t\t\t\tonChange( getNewCustomValue( newSize ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tmin={ minimumCustomValue }\n\t\t\t\t\t\tplaceholder={ allPlaceholder }\n\t\t\t\t\t\tdisableUnits={ isMixed }\n\t\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t\tclassName=\"spacing-sizes-control__custom-value-input\"\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t/>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\t\tvalue={ customRangeValue }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tmax={ CUSTOM_VALUE_SETTINGS[ selectedUnit ]?.max ?? 10 }\n\t\t\t\t\t\tstep={\n\t\t\t\t\t\t\tCUSTOM_VALUE_SETTINGS[ selectedUnit ]?.steps ?? 0.1\n\t\t\t\t\t\t}\n\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t\tonChange={ handleCustomValueSliderChange }\n\t\t\t\t\t\tclassName=\"spacing-sizes-control__custom-value-range\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<RangeControl\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tclassName=\"spacing-sizes-control__range-control\"\n\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\tonChange={ ( newSize ) =>\n\t\t\t\t\t\tonChange( getNewPresetValue( newSize ) )\n\t\t\t\t\t}\n\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t// If mouse down is near start of range set initial value to 0, which\n\t\t\t\t\t\t// prevents the user have to drag right then left to get 0 setting.\n\t\t\t\t\t\tif ( event?.nativeEvent?.offsetX < 35 ) {\n\t\t\t\t\t\t\tsetInitialValue();\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\twithInputField={ false }\n\t\t\t\t\taria-valuenow={ currentValue }\n\t\t\t\t\taria-valuetext={ spacingSizes[ currentValue ]?.name }\n\t\t\t\t\trenderTooltipContent={ customTooltipContent }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tmax={ spacingSizes.length - 1 }\n\t\t\t\t\tmarks={ marks }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t__nextHasNoMarginBottom={ true }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<CustomSelectControl\n\t\t\t\t\tclassName=\"spacing-sizes-control__custom-select-control\"\n\t\t\t\t\tvalue={\n\t\t\t\t\t\toptions.find(\n\t\t\t\t\t\t\t( option ) => option.key === currentValue\n\t\t\t\t\t\t) || '' // passing undefined here causes a downshift controlled/uncontrolled warning\n\t\t\t\t\t}\n\t\t\t\t\tonChange={ ( selection ) => {\n\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\tgetNewPresetValue(\n\t\t\t\t\t\t\t\tselection.selectedItem.key,\n\t\t\t\t\t\t\t\t'selectList'\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t__nextUnconstrainedWidth={ true }\n\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! disableCustomSpacingSizes && (\n\t\t\t\t<Button\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tshowCustomValueControl\n\t\t\t\t\t\t\t? __( 'Use size preset' )\n\t\t\t\t\t\t\t: __( 'Set custom size' )\n\t\t\t\t\t}\n\t\t\t\t\ticon={ settings }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowCustomValueControl( ! showCustomValueControl );\n\t\t\t\t\t} }\n\t\t\t\t\tisPressed={ showCustomValueControl }\n\t\t\t\t\tisSmall\n\t\t\t\t\tclassName=\"spacing-sizes-control__custom-toggle\"\n\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</HStack>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAUA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAKA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,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F,WAAa;IACvBiF,MAAM,EAAGlF;EAAY,CACrB,CACD,EACC,CAAEW,gBAAgB,IAAI,CAAEQ,sBAAsB,IAC/C,IAAAuD,MAAA,CAAAC,aAAA,EAACxH,WAAA,CAAA6I,mBAAmB;IACnBnB,SAAS,EAAC,8CAA8C;IACxDvE,KAAK,EACJqD,OAAO,CAACsC,IAAI,CACTC,MAAM,IAAMA,MAAM,CAACpC,GAAG,KAAKhC,YAC9B,CAAC,IAAI,EAAE,CAAC;IACR;;IACD/B,QAAQ,EAAKoG,SAAS,IAAM;MAC3BpG,QAAQ,CACPqD,iBAAiB,CAChB+C,SAAS,CAACC,YAAY,CAACtC,GAAG,EAC1B,YACD,CACD,CAAC;IACF,CAAG;IACHH,OAAO,EAAGA,OAAS;IACnBM,KAAK,EAAGO,SAAW;IACnBc,mBAAmB,EAAG,IAAM;IAC5Be,wBAAwB,EAAG,IAAM;IACjCjE,IAAI,EAAG,kBAAoB;IAC3BnC,WAAW,EAAGA,WAAa;IAC3BD,UAAU,EAAGA,UAAY;IACzBiF,OAAO,EAAGhF,WAAa;IACvBiF,MAAM,EAAGlF;EAAY,CACrB,CACD,EACC,CAAEa,yBAAyB,IAC5B,IAAA6D,MAAA,CAAAC,aAAA,EAACxH,WAAA,CAAAmJ,MAAM;IACNrC,KAAK,EACJ9C,sBAAsB,GACnB,IAAAe,QAAE,EAAE,iBAAkB,CAAC,GACvB,IAAAA,QAAE,EAAE,iBAAkB,CACzB;IACDtC,IAAI,EAAG2G,eAAU;IACjBC,OAAO,EAAGA,CAAA,KAAM;MACfpF,yBAAyB,CAAE,CAAED,sBAAuB,CAAC;IACtD,CAAG;IACHsF,SAAS,EAAGtF,sBAAwB;IACpCuF,OAAO;IACP7B,SAAS,EAAC,sCAAsC;IAChD8B,QAAQ,EAAG;EAAI,CACf,CAEK,CAAC;AAEX"}
1
+ {"version":3,"names":["_components","require","_data","_element","_compose","_i18n","_icons","_useSettings","_store","_utils","CUSTOM_VALUE_SETTINGS","px","max","steps","vw","vh","em","rm","svw","lvw","dvw","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","SpacingInputControl","icon","isMixed","minimumCustomValue","onChange","onMouseOut","onMouseOver","showSideInLabel","side","spacingSizes","type","value","_CUSTOM_VALUE_SETTING","_CUSTOM_VALUE_SETTING2","getPresetValueFromCustomValue","selectListSizes","showRangeControl","length","disableCustomSpacingSizes","useSelect","select","editorSettings","blockEditorStore","getSettings","showCustomValueControl","setShowCustomValueControl","useState","undefined","isValueSpacingPreset","previousValue","usePrevious","availableUnits","useSettings","units","useCustomUnits","currentValue","showCustomValueInSelectList","name","sprintf","__","slug","size","getSliderValueFromPreset","getCustomValueFromPreset","selectedUnit","useMemo","parseQuantityAndUnitFromRawValue","setInitialValue","customTooltipContent","newValue","customRangeValue","parseFloat","getNewCustomValue","newSize","isNumeric","isNaN","nextValue","getNewPresetValue","controlType","parseInt","handleCustomValueSliderChange","next","join","allPlaceholder","options","map","index","key","marks","_newValue","label","sideLabel","ALL_SIDES","includes","LABELS","typeLabel","toLowerCase","ariaLabel","trim","_react","createElement","__experimentalHStack","className","Icon","Fragment","__experimentalUnitControl","onFocus","onBlur","min","placeholder","disableUnits","hideLabelFromVision","RangeControl","step","withInputField","__nextHasNoMarginBottom","onMouseDown","event","nativeEvent","offsetX","renderTooltipContent","CustomSelectControl","find","option","selection","selectedItem","__nextUnconstrainedWidth","Button","settings","onClick","isPressed","isSmall","iconSize"],"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/input-controls/spacing-input-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCustomSelectControl,\n\tIcon,\n\tRangeControl,\n\t__experimentalHStack as HStack,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { usePrevious } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { settings } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../../use-settings';\nimport { store as blockEditorStore } from '../../../store';\nimport {\n\tALL_SIDES,\n\tLABELS,\n\tgetSliderValueFromPreset,\n\tgetCustomValueFromPreset,\n\tgetPresetValueFromCustomValue,\n\tisValueSpacingPreset,\n} from '../utils';\n\nconst CUSTOM_VALUE_SETTINGS = {\n\tpx: { max: 300, steps: 1 },\n\t'%': { max: 100, steps: 1 },\n\tvw: { max: 100, steps: 1 },\n\tvh: { max: 100, steps: 1 },\n\tem: { max: 10, steps: 0.1 },\n\trm: { max: 10, steps: 0.1 },\n\tsvw: { max: 100, steps: 1 },\n\tlvw: { max: 100, steps: 1 },\n\tdvw: { max: 100, steps: 1 },\n\tsvh: { max: 100, steps: 1 },\n\tlvh: { max: 100, steps: 1 },\n\tdvh: { max: 100, steps: 1 },\n\tvi: { max: 100, steps: 1 },\n\tsvi: { max: 100, steps: 1 },\n\tlvi: { max: 100, steps: 1 },\n\tdvi: { max: 100, steps: 1 },\n\tvb: { max: 100, steps: 1 },\n\tsvb: { max: 100, steps: 1 },\n\tlvb: { max: 100, steps: 1 },\n\tdvb: { max: 100, steps: 1 },\n\tvmin: { max: 100, steps: 1 },\n\tsvmin: { max: 100, steps: 1 },\n\tlvmin: { max: 100, steps: 1 },\n\tdvmin: { max: 100, steps: 1 },\n\tvmax: { max: 100, steps: 1 },\n\tsvmax: { max: 100, steps: 1 },\n\tlvmax: { max: 100, steps: 1 },\n\tdvmax: { max: 100, steps: 1 },\n};\n\nexport default function SpacingInputControl( {\n\ticon,\n\tisMixed = false,\n\tminimumCustomValue,\n\tonChange,\n\tonMouseOut,\n\tonMouseOver,\n\tshowSideInLabel = true,\n\tside,\n\tspacingSizes,\n\ttype,\n\tvalue,\n} ) {\n\t// Treat value as a preset value if the passed in value matches the value of one of the spacingSizes.\n\tvalue = getPresetValueFromCustomValue( value, spacingSizes );\n\n\tlet selectListSizes = spacingSizes;\n\tconst showRangeControl = spacingSizes.length <= 8;\n\n\tconst disableCustomSpacingSizes = useSelect( ( select ) => {\n\t\tconst editorSettings = select( blockEditorStore ).getSettings();\n\t\treturn editorSettings?.disableCustomSpacingSizes;\n\t} );\n\n\tconst [ showCustomValueControl, setShowCustomValueControl ] = useState(\n\t\t! disableCustomSpacingSizes &&\n\t\t\tvalue !== undefined &&\n\t\t\t! isValueSpacingPreset( value )\n\t);\n\n\tconst previousValue = usePrevious( value );\n\tif (\n\t\t!! value &&\n\t\tpreviousValue !== value &&\n\t\t! isValueSpacingPreset( value ) &&\n\t\tshowCustomValueControl !== true\n\t) {\n\t\tsetShowCustomValueControl( true );\n\t}\n\n\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnits || [ 'px', 'em', 'rem' ],\n\t} );\n\n\tlet currentValue = null;\n\n\tconst showCustomValueInSelectList =\n\t\t! showRangeControl &&\n\t\t! showCustomValueControl &&\n\t\tvalue !== undefined &&\n\t\t( ! isValueSpacingPreset( value ) ||\n\t\t\t( isValueSpacingPreset( value ) && isMixed ) );\n\n\tif ( showCustomValueInSelectList ) {\n\t\tselectListSizes = [\n\t\t\t...spacingSizes,\n\t\t\t{\n\t\t\t\tname: ! isMixed\n\t\t\t\t\t? // translators: A custom measurement, eg. a number followed by a unit like 12px.\n\t\t\t\t\t sprintf( __( 'Custom (%s)' ), value )\n\t\t\t\t\t: __( 'Mixed' ),\n\t\t\t\tslug: 'custom',\n\t\t\t\tsize: value,\n\t\t\t},\n\t\t];\n\t\tcurrentValue = selectListSizes.length - 1;\n\t} else if ( ! isMixed ) {\n\t\tcurrentValue = ! showCustomValueControl\n\t\t\t? getSliderValueFromPreset( value, spacingSizes )\n\t\t\t: getCustomValueFromPreset( value, spacingSizes );\n\t}\n\n\tconst selectedUnit =\n\t\tuseMemo(\n\t\t\t() => parseQuantityAndUnitFromRawValue( currentValue ),\n\t\t\t[ currentValue ]\n\t\t)[ 1 ] || units[ 0 ]?.value;\n\n\tconst setInitialValue = () => {\n\t\tif ( value === undefined ) {\n\t\t\tonChange( '0' );\n\t\t}\n\t};\n\n\tconst customTooltipContent = ( newValue ) =>\n\t\tvalue === undefined ? undefined : spacingSizes[ newValue ]?.name;\n\n\tconst customRangeValue = parseFloat( currentValue, 10 );\n\n\tconst getNewCustomValue = ( newSize ) => {\n\t\tconst isNumeric = ! isNaN( parseFloat( newSize ) );\n\t\tconst nextValue = isNumeric ? newSize : undefined;\n\t\treturn nextValue;\n\t};\n\n\tconst getNewPresetValue = ( newSize, controlType ) => {\n\t\tconst size = parseInt( newSize, 10 );\n\n\t\tif ( controlType === 'selectList' ) {\n\t\t\tif ( size === 0 ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif ( size === 1 ) {\n\t\t\t\treturn '0';\n\t\t\t}\n\t\t} else if ( size === 0 ) {\n\t\t\treturn '0';\n\t\t}\n\t\treturn `var:preset|spacing|${ spacingSizes[ newSize ]?.slug }`;\n\t};\n\n\tconst handleCustomValueSliderChange = ( next ) => {\n\t\tonChange( [ next, selectedUnit ].join( '' ) );\n\t};\n\n\tconst allPlaceholder = isMixed ? __( 'Mixed' ) : null;\n\n\tconst options = selectListSizes.map( ( size, index ) => ( {\n\t\tkey: index,\n\t\tname: size.name,\n\t} ) );\n\n\tconst marks = spacingSizes.map( ( _newValue, index ) => ( {\n\t\tvalue: index,\n\t\tlabel: undefined,\n\t} ) );\n\n\tconst sideLabel =\n\t\tALL_SIDES.includes( side ) && showSideInLabel ? LABELS[ side ] : '';\n\tconst typeLabel = showSideInLabel ? type?.toLowerCase() : type;\n\n\tconst ariaLabel = sprintf(\n\t\t// translators: 1: The side of the block being modified (top, bottom, left, All sides etc.). 2. Type of spacing being modified (Padding, margin, etc)\n\t\t__( '%1$s %2$s' ),\n\t\tsideLabel,\n\t\ttypeLabel\n\t).trim();\n\n\treturn (\n\t\t<HStack className=\"spacing-sizes-control__wrapper\">\n\t\t\t{ icon && (\n\t\t\t\t<Icon\n\t\t\t\t\tclassName=\"spacing-sizes-control__icon\"\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tsize={ 24 }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showCustomValueControl && (\n\t\t\t\t<>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\t\tonChange={ ( newSize ) =>\n\t\t\t\t\t\t\tonChange( getNewCustomValue( newSize ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tmin={ minimumCustomValue }\n\t\t\t\t\t\tplaceholder={ allPlaceholder }\n\t\t\t\t\t\tdisableUnits={ isMixed }\n\t\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t\tclassName=\"spacing-sizes-control__custom-value-input\"\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t/>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\t\tvalue={ customRangeValue }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tmax={ CUSTOM_VALUE_SETTINGS[ selectedUnit ]?.max ?? 10 }\n\t\t\t\t\t\tstep={\n\t\t\t\t\t\t\tCUSTOM_VALUE_SETTINGS[ selectedUnit ]?.steps ?? 0.1\n\t\t\t\t\t\t}\n\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t\tonChange={ handleCustomValueSliderChange }\n\t\t\t\t\t\tclassName=\"spacing-sizes-control__custom-value-range\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<RangeControl\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tclassName=\"spacing-sizes-control__range-control\"\n\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\tonChange={ ( newSize ) =>\n\t\t\t\t\t\tonChange( getNewPresetValue( newSize ) )\n\t\t\t\t\t}\n\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t// If mouse down is near start of range set initial value to 0, which\n\t\t\t\t\t\t// prevents the user have to drag right then left to get 0 setting.\n\t\t\t\t\t\tif ( event?.nativeEvent?.offsetX < 35 ) {\n\t\t\t\t\t\t\tsetInitialValue();\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\twithInputField={ false }\n\t\t\t\t\taria-valuenow={ currentValue }\n\t\t\t\t\taria-valuetext={ spacingSizes[ currentValue ]?.name }\n\t\t\t\t\trenderTooltipContent={ customTooltipContent }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tmax={ spacingSizes.length - 1 }\n\t\t\t\t\tmarks={ marks }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t__nextHasNoMarginBottom={ true }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<CustomSelectControl\n\t\t\t\t\tclassName=\"spacing-sizes-control__custom-select-control\"\n\t\t\t\t\tvalue={\n\t\t\t\t\t\toptions.find(\n\t\t\t\t\t\t\t( option ) => option.key === currentValue\n\t\t\t\t\t\t) || '' // passing undefined here causes a downshift controlled/uncontrolled warning\n\t\t\t\t\t}\n\t\t\t\t\tonChange={ ( selection ) => {\n\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\tgetNewPresetValue(\n\t\t\t\t\t\t\t\tselection.selectedItem.key,\n\t\t\t\t\t\t\t\t'selectList'\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t__nextUnconstrainedWidth={ true }\n\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! disableCustomSpacingSizes && (\n\t\t\t\t<Button\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tshowCustomValueControl\n\t\t\t\t\t\t\t? __( 'Use size preset' )\n\t\t\t\t\t\t\t: __( 'Set custom size' )\n\t\t\t\t\t}\n\t\t\t\t\ticon={ settings }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowCustomValueControl( ! showCustomValueControl );\n\t\t\t\t\t} }\n\t\t\t\t\tisPressed={ showCustomValueControl }\n\t\t\t\t\tisSmall\n\t\t\t\t\tclassName=\"spacing-sizes-control__custom-toggle\"\n\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</HStack>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAUA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAA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CAAC;AAEX"}
@@ -96,7 +96,8 @@ function getDropTargetPosition(blocksData, position, orientation = 'vertical') {
96
96
 
97
97
  /**
98
98
  * @typedef {Object} WPBlockDropZoneConfig
99
- * @property {string} rootClientId The root client id for the block list.
99
+ * @property {?HTMLElement} dropZoneElement Optional element to be used as the drop zone.
100
+ * @property {string} rootClientId The root client id for the block list.
100
101
  */
101
102
 
102
103
  /**
@@ -105,6 +106,7 @@ function getDropTargetPosition(blocksData, position, orientation = 'vertical') {
105
106
  * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.
106
107
  */
107
108
  function useBlockDropZone({
109
+ dropZoneElement,
108
110
  // An undefined value represents a top-level block. Default to an empty
109
111
  // string for this so that `targetRootClientId` can be easily compared to
110
112
  // values returned by the `getRootBlockClientId` selector, which also uses
@@ -176,6 +178,7 @@ function useBlockDropZone({
176
178
  });
177
179
  }, [getBlocks, targetRootClientId, getBlockListSettings, registry, showInsertionPoint, getBlockIndex]), 200);
178
180
  return (0, _compose.__experimentalUseDropZone)({
181
+ dropZoneElement,
179
182
  isDisabled,
180
183
  onDrop: onBlockDrop,
181
184
  onDragOver(event) {
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_element","_compose","_i18n","_blocks","_useOnBlockDrop","_interopRequireDefault","_math","_store","getDropTargetPosition","blocksData","position","orientation","allowedEdges","isRightToLeft","isRTL","nearestIndex","insertPosition","minDistance","Infinity","forEach","isUnmodifiedDefaultBlock","getBoundingClientRect","blockIndex","rect","distance","edge","getDistanceToNearestEdge","isPointContainedByRect","adjacentIndex","isNearestBlockUnmodifiedDefaultBlock","isAdjacentBlockUnmodifiedDefaultBlock","insertionIndex","useBlockDropZone","rootClientId","targetRootClientId","registry","useRegistry","dropTarget","setDropTarget","useState","index","operation","isDisabled","useSelect","select","__unstableIsWithinBlockOverlay","__unstableHasActiveBlockOverlayActive","getBlockEditingMode","blockEditorStore","blockEditingMode","getBlockListSettings","getBlocks","getBlockIndex","showInsertionPoint","hideInsertionPoint","useDispatch","onBlockDrop","useOnBlockDrop","throttled","useThrottle","useCallback","event","ownerDocument","blocks","length","batch","map","block","clientId","getIsUnmodifiedDefaultBlock","getElementById","targetIndex","x","clientX","y","clientY","useDropZone","onDrop","onDragOver","currentTarget","onDragLeave","cancel","onDragEnd"],"sources":["@wordpress/block-editor/src/components/use-block-drop-zone/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { useCallback, useState } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\nimport { isUnmodifiedDefaultBlock as getIsUnmodifiedDefaultBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useOnBlockDrop from '../use-on-block-drop';\nimport {\n\tgetDistanceToNearestEdge,\n\tisPointContainedByRect,\n} from '../../utils/math';\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n/** @typedef {import('../use-on-block-drop/types').WPDropOperation} WPDropOperation */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * The insert position when dropping a block.\n *\n * @typedef {'before'|'after'} WPInsertPosition\n */\n\n/**\n * @typedef {Object} WPBlockData\n * @property {boolean} isUnmodifiedDefaultBlock Is the block unmodified default block.\n * @property {() => DOMRect} getBoundingClientRect Get the bounding client rect of the block.\n * @property {number} blockIndex The index of the block.\n */\n\n/**\n * Get the drop target position from a given drop point and the orientation.\n *\n * @param {WPBlockData[]} blocksData The block data list.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of the block list.\n * @return {[number, WPDropOperation]} The drop target position.\n */\nexport function getDropTargetPosition(\n\tblocksData,\n\tposition,\n\torientation = 'vertical'\n) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tconst isRightToLeft = isRTL();\n\n\tlet nearestIndex = 0;\n\tlet insertPosition = 'before';\n\tlet minDistance = Infinity;\n\n\tblocksData.forEach(\n\t\t( { isUnmodifiedDefaultBlock, getBoundingClientRect, blockIndex } ) => {\n\t\t\tconst rect = getBoundingClientRect();\n\n\t\t\tlet [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\tallowedEdges\n\t\t\t);\n\t\t\t// Prioritize the element if the point is inside of an unmodified default block.\n\t\t\tif (\n\t\t\t\tisUnmodifiedDefaultBlock &&\n\t\t\t\tisPointContainedByRect( position, rect )\n\t\t\t) {\n\t\t\t\tdistance = 0;\n\t\t\t}\n\n\t\t\tif ( distance < minDistance ) {\n\t\t\t\t// Where the dropped block will be inserted on the nearest block.\n\t\t\t\tinsertPosition =\n\t\t\t\t\tedge === 'bottom' ||\n\t\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t\t( isRightToLeft && edge === 'left' )\n\t\t\t\t\t\t? 'after'\n\t\t\t\t\t\t: 'before';\n\n\t\t\t\t// Update the currently known best candidate.\n\t\t\t\tminDistance = distance;\n\t\t\t\tnearestIndex = blockIndex;\n\t\t\t}\n\t\t}\n\t);\n\n\tconst adjacentIndex =\n\t\tnearestIndex + ( insertPosition === 'after' ? 1 : -1 );\n\tconst isNearestBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ nearestIndex ]?.isUnmodifiedDefaultBlock;\n\tconst isAdjacentBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ adjacentIndex ]?.isUnmodifiedDefaultBlock;\n\n\t// If both blocks are not unmodified default blocks then just insert between them.\n\tif (\n\t\t! isNearestBlockUnmodifiedDefaultBlock &&\n\t\t! isAdjacentBlockUnmodifiedDefaultBlock\n\t) {\n\t\t// If the user is dropping to the trailing edge of the block\n\t\t// add 1 to the index to represent dragging after.\n\t\tconst insertionIndex =\n\t\t\tinsertPosition === 'after' ? nearestIndex + 1 : nearestIndex;\n\t\treturn [ insertionIndex, 'insert' ];\n\t}\n\n\t// Otherwise, replace the nearest unmodified default block.\n\treturn [\n\t\tisNearestBlockUnmodifiedDefaultBlock ? nearestIndex : adjacentIndex,\n\t\t'replace',\n\t];\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n */\nexport default function useBlockDropZone( {\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n} = {} ) {\n\tconst registry = useRegistry();\n\tconst [ dropTarget, setDropTarget ] = useState( {\n\t\tindex: null,\n\t\toperation: 'insert',\n\t} );\n\n\tconst isDisabled = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\t__unstableIsWithinBlockOverlay,\n\t\t\t\t__unstableHasActiveBlockOverlayActive,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst blockEditingMode = getBlockEditingMode( targetRootClientId );\n\t\t\treturn (\n\t\t\t\tblockEditingMode !== 'default' ||\n\t\t\t\t__unstableHasActiveBlockOverlayActive( targetRootClientId ) ||\n\t\t\t\t__unstableIsWithinBlockOverlay( targetRootClientId )\n\t\t\t);\n\t\t},\n\t\t[ targetRootClientId ]\n\t);\n\n\tconst { getBlockListSettings, getBlocks, getBlockIndex } =\n\t\tuseSelect( blockEditorStore );\n\tconst { showInsertionPoint, hideInsertionPoint } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst onBlockDrop = useOnBlockDrop( targetRootClientId, dropTarget.index, {\n\t\toperation: dropTarget.operation,\n\t} );\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, ownerDocument ) => {\n\t\t\t\tconst blocks = getBlocks( targetRootClientId );\n\n\t\t\t\t// The block list is empty, don't show the insertion point but still allow dropping.\n\t\t\t\tif ( blocks.length === 0 ) {\n\t\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tshowInsertionPoint( targetRootClientId, 0, {\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocksData = blocks.map( ( block ) => {\n\t\t\t\t\tconst clientId = block.clientId;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisUnmodifiedDefaultBlock:\n\t\t\t\t\t\t\tgetIsUnmodifiedDefaultBlock( block ),\n\t\t\t\t\t\tgetBoundingClientRect: () =>\n\t\t\t\t\t\t\townerDocument\n\t\t\t\t\t\t\t\t.getElementById( `block-${ clientId }` )\n\t\t\t\t\t\t\t\t.getBoundingClientRect(),\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst [ targetIndex, operation ] = getDropTargetPosition(\n\t\t\t\t\tblocksData,\n\t\t\t\t\t{ x: event.clientX, y: event.clientY },\n\t\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation\n\t\t\t\t);\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\tindex: targetIndex,\n\t\t\t\t\t\toperation,\n\t\t\t\t\t} );\n\t\t\t\t\tshowInsertionPoint( targetRootClientId, targetIndex, {\n\t\t\t\t\t\toperation,\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tgetBlocks,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tregistry,\n\t\t\t\tshowInsertionPoint,\n\t\t\t\tgetBlockIndex,\n\t\t\t]\n\t\t),\n\t\t200\n\t);\n\n\treturn useDropZone( {\n\t\tisDisabled,\n\t\tonDrop: onBlockDrop,\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget.ownerDocument );\n\t\t},\n\t\tonDragLeave() {\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t},\n\t} );\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAIA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAKA,IAAAK,eAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AAIA,IAAAQ,MAAA,GAAAR,OAAA;AApBA;AACA;AACA;;AAUA;AACA;AACA;;AAQA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASS,qBAAqBA,CACpCC,UAAU,EACVC,QAAQ,EACRC,WAAW,GAAG,UAAU,EACvB;EACD,MAAMC,YAAY,GACjBD,WAAW,KAAK,YAAY,GACzB,CAAE,MAAM,EAAE,OAAO,CAAE,GACnB,CAAE,KAAK,EAAE,QAAQ,CAAE;EAEvB,MAAME,aAAa,GAAG,IAAAC,WAAK,EAAC,CAAC;EAE7B,IAAIC,YAAY,GAAG,CAAC;E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ACD,GACD,CAAC;EAED,OAAO,IAAAwB,kCAAW,EAAE;IACnBlC,UAAU;IACVmC,MAAM,EAAErB,WAAW;IACnBsB,UAAUA,CAAEjB,KAAK,EAAG;MACnB;MACA;MACA;MACAH,SAAS,CAAEG,KAAK,EAAEA,KAAK,CAACkB,aAAa,CAACjB,aAAc,CAAC;IACtD,CAAC;IACDkB,WAAWA,CAAA,EAAG;MACbtB,SAAS,CAACuB,MAAM,CAAC,CAAC;MAClB3B,kBAAkB,CAAC,CAAC;IACrB,CAAC;IACD4B,SAASA,CAAA,EAAG;MACXxB,SAAS,CAACuB,MAAM,CAAC,CAAC;MAClB3B,kBAAkB,CAAC,CAAC;IACrB;EACD,CAAE,CAAC;AACJ"}
1
+ {"version":3,"names":["_data","require","_element","_compose","_i18n","_blocks","_useOnBlockDrop","_interopRequireDefault","_math","_store","getDropTargetPosition","blocksData","position","orientation","allowedEdges","isRightToLeft","isRTL","nearestIndex","insertPosition","minDistance","Infinity","forEach","isUnmodifiedDefaultBlock","getBoundingClientRect","blockIndex","rect","distance","edge","getDistanceToNearestEdge","isPointContainedByRect","adjacentIndex","isNearestBlockUnmodifiedDefaultBlock","isAdjacentBlockUnmodifiedDefaultBlock","insertionIndex","useBlockDropZone","dropZoneElement","rootClientId","targetRootClientId","registry","useRegistry","dropTarget","setDropTarget","useState","index","operation","isDisabled","useSelect","select","__unstableIsWithinBlockOverlay","__unstableHasActiveBlockOverlayActive","getBlockEditingMode","blockEditorStore","blockEditingMode","getBlockListSettings","getBlocks","getBlockIndex","showInsertionPoint","hideInsertionPoint","useDispatch","onBlockDrop","useOnBlockDrop","throttled","useThrottle","useCallback","event","ownerDocument","blocks","length","batch","map","block","clientId","getIsUnmodifiedDefaultBlock","getElementById","targetIndex","x","clientX","y","clientY","useDropZone","onDrop","onDragOver","currentTarget","onDragLeave","cancel","onDragEnd"],"sources":["@wordpress/block-editor/src/components/use-block-drop-zone/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { useCallback, useState } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\nimport { isUnmodifiedDefaultBlock as getIsUnmodifiedDefaultBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useOnBlockDrop from '../use-on-block-drop';\nimport {\n\tgetDistanceToNearestEdge,\n\tisPointContainedByRect,\n} from '../../utils/math';\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n/** @typedef {import('../use-on-block-drop/types').WPDropOperation} WPDropOperation */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * The insert position when dropping a block.\n *\n * @typedef {'before'|'after'} WPInsertPosition\n */\n\n/**\n * @typedef {Object} WPBlockData\n * @property {boolean} isUnmodifiedDefaultBlock Is the block unmodified default block.\n * @property {() => DOMRect} getBoundingClientRect Get the bounding client rect of the block.\n * @property {number} blockIndex The index of the block.\n */\n\n/**\n * Get the drop target position from a given drop point and the orientation.\n *\n * @param {WPBlockData[]} blocksData The block data list.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of the block list.\n * @return {[number, WPDropOperation]} The drop target position.\n */\nexport function getDropTargetPosition(\n\tblocksData,\n\tposition,\n\torientation = 'vertical'\n) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tconst isRightToLeft = isRTL();\n\n\tlet nearestIndex = 0;\n\tlet insertPosition = 'before';\n\tlet minDistance = Infinity;\n\n\tblocksData.forEach(\n\t\t( { isUnmodifiedDefaultBlock, getBoundingClientRect, blockIndex } ) => {\n\t\t\tconst rect = getBoundingClientRect();\n\n\t\t\tlet [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\tallowedEdges\n\t\t\t);\n\t\t\t// Prioritize the element if the point is inside of an unmodified default block.\n\t\t\tif (\n\t\t\t\tisUnmodifiedDefaultBlock &&\n\t\t\t\tisPointContainedByRect( position, rect )\n\t\t\t) {\n\t\t\t\tdistance = 0;\n\t\t\t}\n\n\t\t\tif ( distance < minDistance ) {\n\t\t\t\t// Where the dropped block will be inserted on the nearest block.\n\t\t\t\tinsertPosition =\n\t\t\t\t\tedge === 'bottom' ||\n\t\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t\t( isRightToLeft && edge === 'left' )\n\t\t\t\t\t\t? 'after'\n\t\t\t\t\t\t: 'before';\n\n\t\t\t\t// Update the currently known best candidate.\n\t\t\t\tminDistance = distance;\n\t\t\t\tnearestIndex = blockIndex;\n\t\t\t}\n\t\t}\n\t);\n\n\tconst adjacentIndex =\n\t\tnearestIndex + ( insertPosition === 'after' ? 1 : -1 );\n\tconst isNearestBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ nearestIndex ]?.isUnmodifiedDefaultBlock;\n\tconst isAdjacentBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ adjacentIndex ]?.isUnmodifiedDefaultBlock;\n\n\t// If both blocks are not unmodified default blocks then just insert between them.\n\tif (\n\t\t! isNearestBlockUnmodifiedDefaultBlock &&\n\t\t! isAdjacentBlockUnmodifiedDefaultBlock\n\t) {\n\t\t// If the user is dropping to the trailing edge of the block\n\t\t// add 1 to the index to represent dragging after.\n\t\tconst insertionIndex =\n\t\t\tinsertPosition === 'after' ? nearestIndex + 1 : nearestIndex;\n\t\treturn [ insertionIndex, 'insert' ];\n\t}\n\n\t// Otherwise, replace the nearest unmodified default block.\n\treturn [\n\t\tisNearestBlockUnmodifiedDefaultBlock ? nearestIndex : adjacentIndex,\n\t\t'replace',\n\t];\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {?HTMLElement} dropZoneElement Optional element to be used as the drop zone.\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n */\nexport default function useBlockDropZone( {\n\tdropZoneElement,\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n} = {} ) {\n\tconst registry = useRegistry();\n\tconst [ dropTarget, setDropTarget ] = useState( {\n\t\tindex: null,\n\t\toperation: 'insert',\n\t} );\n\n\tconst isDisabled = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\t__unstableIsWithinBlockOverlay,\n\t\t\t\t__unstableHasActiveBlockOverlayActive,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst blockEditingMode = getBlockEditingMode( targetRootClientId );\n\t\t\treturn (\n\t\t\t\tblockEditingMode !== 'default' ||\n\t\t\t\t__unstableHasActiveBlockOverlayActive( targetRootClientId ) ||\n\t\t\t\t__unstableIsWithinBlockOverlay( targetRootClientId )\n\t\t\t);\n\t\t},\n\t\t[ targetRootClientId ]\n\t);\n\n\tconst { getBlockListSettings, getBlocks, getBlockIndex } =\n\t\tuseSelect( blockEditorStore );\n\tconst { showInsertionPoint, hideInsertionPoint } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst onBlockDrop = useOnBlockDrop( targetRootClientId, dropTarget.index, {\n\t\toperation: dropTarget.operation,\n\t} );\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, ownerDocument ) => {\n\t\t\t\tconst blocks = getBlocks( targetRootClientId );\n\n\t\t\t\t// The block list is empty, don't show the insertion point but still allow dropping.\n\t\t\t\tif ( blocks.length === 0 ) {\n\t\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tshowInsertionPoint( targetRootClientId, 0, {\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocksData = blocks.map( ( block ) => {\n\t\t\t\t\tconst clientId = block.clientId;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisUnmodifiedDefaultBlock:\n\t\t\t\t\t\t\tgetIsUnmodifiedDefaultBlock( block ),\n\t\t\t\t\t\tgetBoundingClientRect: () =>\n\t\t\t\t\t\t\townerDocument\n\t\t\t\t\t\t\t\t.getElementById( `block-${ clientId }` )\n\t\t\t\t\t\t\t\t.getBoundingClientRect(),\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst [ targetIndex, operation ] = getDropTargetPosition(\n\t\t\t\t\tblocksData,\n\t\t\t\t\t{ x: event.clientX, y: event.clientY },\n\t\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation\n\t\t\t\t);\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\tindex: targetIndex,\n\t\t\t\t\t\toperation,\n\t\t\t\t\t} );\n\t\t\t\t\tshowInsertionPoint( targetRootClientId, targetIndex, {\n\t\t\t\t\t\toperation,\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tgetBlocks,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tregistry,\n\t\t\t\tshowInsertionPoint,\n\t\t\t\tgetBlockIndex,\n\t\t\t]\n\t\t),\n\t\t200\n\t);\n\n\treturn useDropZone( {\n\t\tdropZoneElement,\n\t\tisDisabled,\n\t\tonDrop: onBlockDrop,\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget.ownerDocument );\n\t\t},\n\t\tonDragLeave() {\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t},\n\t} );\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAIA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAKA,IAAAK,eAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AAIA,IAAAQ,MAAA,GAAAR,OAAA;AApBA;AACA;AACA;;AAUA;AACA;AACA;;AAQA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASS,qBAAqBA,CACpCC,UAAU,EACVC,QAAQ,EACRC,WAAW,GAAG,UAAU,EACvB;EACD,MAAMC,YAAY,GACjBD,WAAW,KAAK,YAAY,GACzB,CAAE,MAAM,EAAE,OAAO,CAAE,GACnB,CAAE,KAAK,EAAE,QAAQ,CAAE;EAEvB,MAAME,aAAa,GAAG,IAAAC,WAAK,EAAC,CAAC;EAE7B,IAAIC,YAAY,GAAG,CAAC;EACpB,IAAIC,cAAc,GAAG,QAAQ;EAC7B,IAAIC,WAAW,GAAGC,QAAQ;EAE1BT,UAAU,CAACU,OAAO,CACjB,CAAE;IAAEC,wBAAwB;IAAEC,qBAAqB;IAAEC;EAAW,CAAC,KAAM;IACtE,MAAMC,IAAI,GAAGF,qBA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,EAAEA,KAAK,CAACkB,aAAa,CAACjB,aAAc,CAAC;IACtD,CAAC;IACDkB,WAAWA,CAAA,EAAG;MACbtB,SAAS,CAACuB,MAAM,CAAC,CAAC;MAClB3B,kBAAkB,CAAC,CAAC;IACrB,CAAC;IACD4B,SAASA,CAAA,EAAG;MACXxB,SAAS,CAACuB,MAAM,CAAC,CAAC;MAClB3B,kBAAkB,CAAC,CAAC;IACrB;EACD,CAAE,CAAC;AACJ"}
@@ -119,7 +119,8 @@ function useMovingAnimation({
119
119
  y = Math.round(y);
120
120
  const finishedMoving = x === 0 && y === 0;
121
121
  ref.current.style.transformOrigin = 'center center';
122
- ref.current.style.transform = finishedMoving ? undefined : `translate3d(${x}px,${y}px,0)`;
122
+ ref.current.style.transform = finishedMoving ? null // Set to `null` to explicitly remove the transform.
123
+ : `translate3d(${x}px,${y}px,0)`;
123
124
  ref.current.style.zIndex = isSelected ? '1' : '';
124
125
  preserveScrollPosition();
125
126
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_web","require","_element","_compose","_dom","counterReducer","state","getAbsolutePosition","element","top","offsetTop","left","offsetLeft","useMovingAnimation","isSelected","adjustScrolling","enableAnimation","triggerAnimationOnChange","ref","useRef","prefersReducedMotion","useReducedMotion","triggeredAnimation","triggerAnimation","useReducer","finishedAnimation","endAnimation","transform","setTransform","useState","x","y","previous","useMemo","current","preserveScrollPosition","scrollContainer","getScrollContainer","prevRect","getBoundingClientRect","blockRect","diff","scrollTop","useLayoutEffect","style","undefined","destination","Math","round","onChange","value","finishedMoving","transformOrigin","zIndex","useSpring","from","to","reset","config","mass","tension","friction","immediate","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/use-moving-animation/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { useSpring } from '@react-spring/web';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseLayoutEffect,\n\tuseReducer,\n\tuseMemo,\n\tuseRef,\n} from '@wordpress/element';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { getScrollContainer } from '@wordpress/dom';\n\n/**\n * Simple reducer used to increment a counter.\n *\n * @param {number} state Previous counter value.\n * @return {number} New state value.\n */\nconst counterReducer = ( state ) => state + 1;\n\nconst getAbsolutePosition = ( element ) => {\n\treturn {\n\t\ttop: element.offsetTop,\n\t\tleft: element.offsetLeft,\n\t};\n};\n\n/**\n * Hook used to compute the styles required to move a div into a new position.\n *\n * The way this animation works is the following:\n * - It first renders the element as if there was no animation.\n * - It takes a snapshot of the position of the block to use it\n * as a destination point for the animation.\n * - It restores the element to the previous position using a CSS transform\n * - It uses the \"resetAnimation\" flag to reset the animation\n * from the beginning in order to animate to the new destination point.\n *\n * @param {Object} $1 Options\n * @param {boolean} $1.isSelected Whether it's the current block or not.\n * @param {boolean} $1.adjustScrolling Adjust the scroll position to the current block.\n * @param {boolean} $1.enableAnimation Enable/Disable animation.\n * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.\n */\nfunction useMovingAnimation( {\n\tisSelected,\n\tadjustScrolling,\n\tenableAnimation,\n\ttriggerAnimationOnChange,\n} ) {\n\tconst ref = useRef();\n\tconst prefersReducedMotion = useReducedMotion() || ! enableAnimation;\n\tconst [ triggeredAnimation, triggerAnimation ] = useReducer(\n\t\tcounterReducer,\n\t\t0\n\t);\n\tconst [ finishedAnimation, endAnimation ] = useReducer( counterReducer, 0 );\n\tconst [ transform, setTransform ] = useState( { x: 0, y: 0 } );\n\tconst previous = useMemo(\n\t\t() => ( ref.current ? getAbsolutePosition( ref.current ) : null ),\n\t\t[ triggerAnimationOnChange ]\n\t);\n\n\t// Calculate the previous position of the block relative to the viewport and\n\t// return a function to maintain that position by scrolling.\n\tconst preserveScrollPosition = useMemo( () => {\n\t\tif ( ! adjustScrolling || ! ref.current ) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst scrollContainer = getScrollContainer( ref.current );\n\n\t\tif ( ! scrollContainer ) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst prevRect = ref.current.getBoundingClientRect();\n\t\treturn () => {\n\t\t\tconst blockRect = ref.current.getBoundingClientRect();\n\t\t\tconst diff = blockRect.top - prevRect.top;\n\n\t\t\tif ( diff ) {\n\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t}\n\t\t};\n\t}, [ triggerAnimationOnChange, adjustScrolling ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( triggeredAnimation ) {\n\t\t\tendAnimation();\n\t\t}\n\t}, [ triggeredAnimation ] );\n\tuseLayoutEffect( () => {\n\t\tif ( ! previous ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( prefersReducedMotion ) {\n\t\t\t// If the animation is disabled and the scroll needs to be adjusted,\n\t\t\t// just move directly to the final scroll position.\n\t\t\tpreserveScrollPosition();\n\n\t\t\treturn;\n\t\t}\n\n\t\tref.current.style.transform = undefined;\n\t\tconst destination = getAbsolutePosition( ref.current );\n\n\t\ttriggerAnimation();\n\t\tsetTransform( {\n\t\t\tx: Math.round( previous.left - destination.left ),\n\t\t\ty: Math.round( previous.top - destination.top ),\n\t\t} );\n\t}, [ triggerAnimationOnChange ] );\n\n\tfunction onChange( { value } ) {\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\t\tlet { x, y } = value;\n\t\tx = Math.round( x );\n\t\ty = Math.round( y );\n\t\tconst finishedMoving = x === 0 && y === 0;\n\t\tref.current.style.transformOrigin = 'center center';\n\t\tref.current.style.transform = finishedMoving\n\t\t\t? undefined\n\t\t\t: `translate3d(${ x }px,${ y }px,0)`;\n\t\tref.current.style.zIndex = isSelected ? '1' : '';\n\n\t\tpreserveScrollPosition();\n\t}\n\n\tuseSpring( {\n\t\tfrom: {\n\t\t\tx: transform.x,\n\t\t\ty: transform.y,\n\t\t},\n\t\tto: {\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t},\n\t\treset: triggeredAnimation !== finishedAnimation,\n\t\tconfig: { mass: 5, tension: 2000, friction: 200 },\n\t\timmediate: prefersReducedMotion,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AAEC,QAAQ,EAAE;IAAI,CAAC;IACjDC,SAAS,EAAE1C,oBAAoB;IAC/B6B;EACD,CAAE,CAAC;EAEH,OAAO/B,GAAG;AACX;AAAC,IAAA6C,QAAA,GAEclD,kBAAkB;AAAAmD,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_web","require","_element","_compose","_dom","counterReducer","state","getAbsolutePosition","element","top","offsetTop","left","offsetLeft","useMovingAnimation","isSelected","adjustScrolling","enableAnimation","triggerAnimationOnChange","ref","useRef","prefersReducedMotion","useReducedMotion","triggeredAnimation","triggerAnimation","useReducer","finishedAnimation","endAnimation","transform","setTransform","useState","x","y","previous","useMemo","current","preserveScrollPosition","scrollContainer","getScrollContainer","prevRect","getBoundingClientRect","blockRect","diff","scrollTop","useLayoutEffect","style","undefined","destination","Math","round","onChange","value","finishedMoving","transformOrigin","zIndex","useSpring","from","to","reset","config","mass","tension","friction","immediate","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/use-moving-animation/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { useSpring } from '@react-spring/web';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseLayoutEffect,\n\tuseReducer,\n\tuseMemo,\n\tuseRef,\n} from '@wordpress/element';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { getScrollContainer } from '@wordpress/dom';\n\n/**\n * Simple reducer used to increment a counter.\n *\n * @param {number} state Previous counter value.\n * @return {number} New state value.\n */\nconst counterReducer = ( state ) => state + 1;\n\nconst getAbsolutePosition = ( element ) => {\n\treturn {\n\t\ttop: element.offsetTop,\n\t\tleft: element.offsetLeft,\n\t};\n};\n\n/**\n * Hook used to compute the styles required to move a div into a new position.\n *\n * The way this animation works is the following:\n * - It first renders the element as if there was no animation.\n * - It takes a snapshot of the position of the block to use it\n * as a destination point for the animation.\n * - It restores the element to the previous position using a CSS transform\n * - It uses the \"resetAnimation\" flag to reset the animation\n * from the beginning in order to animate to the new destination point.\n *\n * @param {Object} $1 Options\n * @param {boolean} $1.isSelected Whether it's the current block or not.\n * @param {boolean} $1.adjustScrolling Adjust the scroll position to the current block.\n * @param {boolean} $1.enableAnimation Enable/Disable animation.\n * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.\n */\nfunction useMovingAnimation( {\n\tisSelected,\n\tadjustScrolling,\n\tenableAnimation,\n\ttriggerAnimationOnChange,\n} ) {\n\tconst ref = useRef();\n\tconst prefersReducedMotion = useReducedMotion() || ! enableAnimation;\n\tconst [ triggeredAnimation, triggerAnimation ] = useReducer(\n\t\tcounterReducer,\n\t\t0\n\t);\n\tconst [ finishedAnimation, endAnimation ] = useReducer( counterReducer, 0 );\n\tconst [ transform, setTransform ] = useState( { x: 0, y: 0 } );\n\tconst previous = useMemo(\n\t\t() => ( ref.current ? getAbsolutePosition( ref.current ) : null ),\n\t\t[ triggerAnimationOnChange ]\n\t);\n\n\t// Calculate the previous position of the block relative to the viewport and\n\t// return a function to maintain that position by scrolling.\n\tconst preserveScrollPosition = useMemo( () => {\n\t\tif ( ! adjustScrolling || ! ref.current ) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst scrollContainer = getScrollContainer( ref.current );\n\n\t\tif ( ! scrollContainer ) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst prevRect = ref.current.getBoundingClientRect();\n\t\treturn () => {\n\t\t\tconst blockRect = ref.current.getBoundingClientRect();\n\t\t\tconst diff = blockRect.top - prevRect.top;\n\n\t\t\tif ( diff ) {\n\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t}\n\t\t};\n\t}, [ triggerAnimationOnChange, adjustScrolling ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( triggeredAnimation ) {\n\t\t\tendAnimation();\n\t\t}\n\t}, [ triggeredAnimation ] );\n\tuseLayoutEffect( () => {\n\t\tif ( ! previous ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( prefersReducedMotion ) {\n\t\t\t// If the animation is disabled and the scroll needs to be adjusted,\n\t\t\t// just move directly to the final scroll position.\n\t\t\tpreserveScrollPosition();\n\n\t\t\treturn;\n\t\t}\n\n\t\tref.current.style.transform = undefined;\n\t\tconst destination = getAbsolutePosition( ref.current );\n\n\t\ttriggerAnimation();\n\t\tsetTransform( {\n\t\t\tx: Math.round( previous.left - destination.left ),\n\t\t\ty: Math.round( previous.top - destination.top ),\n\t\t} );\n\t}, [ triggerAnimationOnChange ] );\n\n\tfunction onChange( { value } ) {\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\t\tlet { x, y } = value;\n\t\tx = Math.round( x );\n\t\ty = Math.round( y );\n\t\tconst finishedMoving = x === 0 && y === 0;\n\t\tref.current.style.transformOrigin = 'center center';\n\t\tref.current.style.transform = finishedMoving\n\t\t\t? null // Set to `null` to explicitly remove the transform.\n\t\t\t: `translate3d(${ x }px,${ y }px,0)`;\n\t\tref.current.style.zIndex = isSelected ? '1' : '';\n\n\t\tpreserveScrollPosition();\n\t}\n\n\tuseSpring( {\n\t\tfrom: {\n\t\t\tx: transform.x,\n\t\t\ty: transform.y,\n\t\t},\n\t\tto: {\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t},\n\t\treset: triggeredAnimation !== finishedAnimation,\n\t\tconfig: { mass: 5, tension: 2000, friction: 200 },\n\t\timmediate: prefersReducedMotion,\n\t\tonChange,\n\t} );\n\n\treturn ref;\n}\n\nexport default useMovingAnimation;\n"],"mappings":";;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAOA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,cAAc,GAAKC,KAAK,IAAMA,KAAK,GAAG,CAAC;AAE7C,MAAMC,mBAAmB,GAAKC,OAAO,IAAM;EAC1C,OAAO;IACNC,GAAG,EAAED,OAAO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AGmB,KAAK;IACpBpB,CAAC,GAAGiB,IAAI,CAACC,KAAK,CAAElB,CAAE,CAAC;IACnBC,CAAC,GAAGgB,IAAI,CAACC,KAAK,CAAEjB,CAAE,CAAC;IACnB,MAAMoB,cAAc,GAAGrB,CAAC,KAAK,CAAC,IAAIC,CAAC,KAAK,CAAC;IACzCb,GAAG,CAACgB,OAAO,CAACU,KAAK,CAACQ,eAAe,GAAG,eAAe;IACnDlC,GAAG,CAACgB,OAAO,CAACU,KAAK,CAACjB,SAAS,GAAGwB,cAAc,GACzC,IAAI,CAAC;IAAA,EACJ,eAAerB,CAAG,MAAMC,CAAG,OAAM;IACrCb,GAAG,CAACgB,OAAO,CAACU,KAAK,CAACS,MAAM,GAAGvC,UAAU,GAAG,GAAG,GAAG,EAAE;IAEhDqB,sBAAsB,CAAC,CAAC;EACzB;EAEA,IAAAmB,cAAS,EAAE;IACVC,IAAI,EAAE;MACLzB,CAAC,EAAEH,SAAS,CAACG,CAAC;MACdC,CAAC,EAAEJ,SAAS,CAACI;IACd,CAAC;IACDyB,EAAE,EAAE;MACH1B,CAAC,EAAE,CAAC;MACJC,CAAC,EAAE;IACJ,CAAC;IACD0B,KAAK,EAAEnC,kBAAkB,KAAKG,iBAAiB;IAC/CiC,MAAM,EAAE;MAAEC,IAAI,EAAE,CAAC;MAAEC,OAAO,EAAE,IAAI;MAAEC,QAAQ,EAAE;IAAI,CAAC;IACjDC,SAAS,EAAE1C,oBAAoB;IAC/B6B;EACD,CAAE,CAAC;EAEH,OAAO/B,GAAG;AACX;AAAC,IAAA6C,QAAA,GAEclD,kBAAkB;AAAAmD,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -194,7 +194,7 @@ function useSettings(...paths) {
194
194
  *
195
195
  * @param {string} path The path to the setting.
196
196
  * @return {any} Returns the value defined for the setting.
197
- * @deprecated 6.4.0 Use useSettings instead.
197
+ * @deprecated 6.5.0 Use useSettings instead.
198
198
  * @example
199
199
  * ```js
200
200
  * const isEnabled = useSetting( 'typography.dropCap' );
@@ -202,7 +202,7 @@ function useSettings(...paths) {
202
202
  */
203
203
  function useSetting(path) {
204
204
  (0, _deprecated.default)('wp.blockEditor.useSetting', {
205
- since: '6.4',
205
+ since: '6.5',
206
206
  alternative: 'wp.blockEditor.useSettings',
207
207
  note: 'The new useSettings function can retrieve multiple settings at once, with better performance.'
208
208
  });
@@ -1 +1 @@
1
- {"version":3,"names":["_blocks","require","_data","_deprecated","_interopRequireDefault","_element","_hooks","_blockEdit","_store","_object","blockedPaths","deprecatedFlags","settings","colors","gradients","disableCustomColors","undefined","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","prefixedFlags","removeCustomPrefixes","path","mergeOrigins","value","result","mergeCache","get","flatMap","key","_value$key","set","WeakMap","useSettings","paths","name","blockName","clientId","useBlockEditContext","useMemo","useSelect","select","candidates","blockEditorStore","getBlockParents","filter","candidateClientId","candidateBlockName","getBlockName","hasBlockSupport","map","includes","console","warn","applyFilters","normalizedPath","_getValueFromObjectPa","candidateAtts","getBlockAttributes","getValueFromObjectPath","blocks","getSettings","__experimentalFeatures","PATHS_WITH_MERGE","deprecatedSettingsValue","useSetting","deprecated","since","alternative","note"],"sources":["@wordpress/block-editor/src/components/use-settings/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { useMemo } from '@wordpress/element';\nimport { applyFilters } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport { store as blockEditorStore } from '../../store';\nimport { getValueFromObjectPath } from '../../utils/object';\n\nconst blockedPaths = [\n\t'color',\n\t'border',\n\t'dimensions',\n\t'typography',\n\t'spacing',\n];\n\nconst deprecatedFlags = {\n\t'color.palette': ( settings ) => settings.colors,\n\t'color.gradients': ( settings ) => settings.gradients,\n\t'color.custom': ( settings ) =>\n\t\tsettings.disableCustomColors === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomColors,\n\t'color.customGradient': ( settings ) =>\n\t\tsettings.disableCustomGradients === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomGradients,\n\t'typography.fontSizes': ( settings ) => settings.fontSizes,\n\t'typography.customFontSize': ( settings ) =>\n\t\tsettings.disableCustomFontSizes === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomFontSizes,\n\t'typography.lineHeight': ( settings ) => settings.enableCustomLineHeight,\n\t'spacing.units': ( settings ) => {\n\t\tif ( settings.enableCustomUnits === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( settings.enableCustomUnits === true ) {\n\t\t\treturn [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];\n\t\t}\n\n\t\treturn settings.enableCustomUnits;\n\t},\n\t'spacing.padding': ( settings ) => settings.enableCustomSpacing,\n};\n\nconst prefixedFlags = {\n\t/*\n\t * These were only available in the plugin\n\t * and can be removed when the minimum WordPress version\n\t * for the plugin is 5.9.\n\t */\n\t'border.customColor': 'border.color',\n\t'border.customStyle': 'border.style',\n\t'border.customWidth': 'border.width',\n\t'typography.customFontStyle': 'typography.fontStyle',\n\t'typography.customFontWeight': 'typography.fontWeight',\n\t'typography.customLetterSpacing': 'typography.letterSpacing',\n\t'typography.customTextDecorations': 'typography.textDecoration',\n\t'typography.customTextTransforms': 'typography.textTransform',\n\t/*\n\t * These were part of WordPress 5.8 and we need to keep them.\n\t */\n\t'border.customRadius': 'border.radius',\n\t'spacing.customMargin': 'spacing.margin',\n\t'spacing.customPadding': 'spacing.padding',\n\t'typography.customLineHeight': 'typography.lineHeight',\n};\n\n/**\n * Remove `custom` prefixes for flags that did not land in 5.8.\n *\n * This provides continued support for `custom` prefixed properties. It will\n * be removed once third party devs have had sufficient time to update themes,\n * plugins, etc.\n *\n * @see https://github.com/WordPress/gutenberg/pull/34485\n *\n * @param {string} path Path to desired value in settings.\n * @return {string} The value for defined setting.\n */\nconst removeCustomPrefixes = ( path ) => {\n\treturn prefixedFlags[ path ] || path;\n};\n\n/**\n * For settings like `color.palette`, which have a value that is an object\n * with `default`, `theme`, `custom`, with field values that are arrays of\n * items, merge these three arrays into one and return it. The calculation\n * is memoized so that identical input values produce identical output.\n * @param {Object} value Object to merge\n * @return {Array} Array of merged items\n */\nfunction mergeOrigins( value ) {\n\tlet result = mergeCache.get( value );\n\tif ( ! result ) {\n\t\tresult = [ 'default', 'theme', 'custom' ].flatMap(\n\t\t\t( key ) => value[ key ] ?? []\n\t\t);\n\t\tmergeCache.set( value, result );\n\t}\n\treturn result;\n}\nconst mergeCache = new WeakMap();\n\n/**\n * Hook that retrieves the given settings for the block instance in use.\n *\n * It looks up the settings first in the block instance hierarchy.\n * If none are found, it'll look them up in the block editor settings.\n *\n * @param {string[]} paths The paths to the settings.\n * @return {any[]} Returns the values defined for the settings.\n * @example\n * ```js\n * const [ fixed, sticky ] = useSettings( 'position.fixed', 'position.sticky' );\n * ```\n */\nexport function useSettings( ...paths ) {\n\tconst { name: blockName, clientId = null } = useBlockEditContext();\n\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tpaths = useMemo( () => paths, paths );\n\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst candidates = clientId\n\t\t\t\t? [\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t...select( blockEditorStore ).getBlockParents(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t/* ascending */ true\n\t\t\t\t\t\t),\n\t\t\t\t ].filter( ( candidateClientId ) => {\n\t\t\t\t\t\tconst candidateBlockName =\n\t\t\t\t\t\t\tselect( blockEditorStore ).getBlockName(\n\t\t\t\t\t\t\t\tcandidateClientId\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\treturn hasBlockSupport(\n\t\t\t\t\t\t\tcandidateBlockName,\n\t\t\t\t\t\t\t'__experimentalSettings',\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t } )\n\t\t\t\t: [];\n\n\t\t\treturn paths.map( ( path ) => {\n\t\t\t\tif ( blockedPaths.includes( path ) ) {\n\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t'Top level useSetting paths are disabled. Please use a subpath to query the information needed.'\n\t\t\t\t\t);\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\t// 0. Allow third parties to filter the block's settings at runtime.\n\t\t\t\tlet result = applyFilters(\n\t\t\t\t\t'blockEditor.useSetting.before',\n\t\t\t\t\tundefined,\n\t\t\t\t\tpath,\n\t\t\t\t\tclientId,\n\t\t\t\t\tblockName\n\t\t\t\t);\n\n\t\t\t\tif ( undefined !== result ) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tconst normalizedPath = removeCustomPrefixes( path );\n\n\t\t\t\t// 1. Take settings from the block instance or its ancestors.\n\t\t\t\t// Start from the current block and work our way up the ancestors.\n\t\t\t\tfor ( const candidateClientId of candidates ) {\n\t\t\t\t\tconst candidateAtts =\n\t\t\t\t\t\tselect( blockEditorStore ).getBlockAttributes(\n\t\t\t\t\t\t\tcandidateClientId\n\t\t\t\t\t\t);\n\t\t\t\t\tresult =\n\t\t\t\t\t\tgetValueFromObjectPath(\n\t\t\t\t\t\t\tcandidateAtts.settings?.blocks?.[ blockName ],\n\t\t\t\t\t\t\tnormalizedPath\n\t\t\t\t\t\t) ??\n\t\t\t\t\t\tgetValueFromObjectPath(\n\t\t\t\t\t\t\tcandidateAtts.settings,\n\t\t\t\t\t\t\tnormalizedPath\n\t\t\t\t\t\t);\n\t\t\t\t\tif ( result !== undefined ) {\n\t\t\t\t\t\t// Stop the search for more distant ancestors and move on.\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// 2. Fall back to the settings from the block editor store (__experimentalFeatures).\n\t\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\t\t\tif ( result === undefined && blockName ) {\n\t\t\t\t\tresult = getValueFromObjectPath(\n\t\t\t\t\t\tsettings.__experimentalFeatures?.blocks?.[ blockName ],\n\t\t\t\t\t\tnormalizedPath\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif ( result === undefined ) {\n\t\t\t\t\tresult = getValueFromObjectPath(\n\t\t\t\t\t\tsettings.__experimentalFeatures,\n\t\t\t\t\t\tnormalizedPath\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Return if the setting was found in either the block instance or the store.\n\t\t\t\tif ( result !== undefined ) {\n\t\t\t\t\tif ( PATHS_WITH_MERGE[ normalizedPath ] ) {\n\t\t\t\t\t\treturn mergeOrigins( result );\n\t\t\t\t\t}\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\t// 3. Otherwise, use deprecated settings.\n\t\t\t\tconst deprecatedSettingsValue =\n\t\t\t\t\tdeprecatedFlags[ normalizedPath ]?.( settings );\n\t\t\t\tif ( deprecatedSettingsValue !== undefined ) {\n\t\t\t\t\treturn deprecatedSettingsValue;\n\t\t\t\t}\n\n\t\t\t\t// 4. Fallback for typography.dropCap:\n\t\t\t\t// This is only necessary to support typography.dropCap.\n\t\t\t\t// when __experimentalFeatures are not present (core without plugin).\n\t\t\t\t// To remove when __experimentalFeatures are ported to core.\n\t\t\t\treturn normalizedPath === 'typography.dropCap'\n\t\t\t\t\t? true\n\t\t\t\t\t: undefined;\n\t\t\t} );\n\t\t},\n\t\t[ blockName, clientId, paths ]\n\t);\n}\n\n/**\n * Hook that retrieves the given setting for the block instance in use.\n *\n * It looks up the setting first in the block instance hierarchy.\n * If none is found, it'll look it up in the block editor settings.\n *\n * @param {string} path The path to the setting.\n * @return {any} Returns the value defined for the setting.\n * @deprecated 6.4.0 Use useSettings instead.\n * @example\n * ```js\n * const isEnabled = useSetting( 'typography.dropCap' );\n * ```\n */\nexport function useSetting( path ) {\n\tdeprecated( 'wp.blockEditor.useSetting', {\n\t\tsince: '6.4',\n\t\talternative: 'wp.blockEditor.useSettings',\n\t\tnote: 'The new useSettings function can retrieve multiple settings at once, with better performance.',\n\t} );\n\n\tconst [ value ] = useSettings( path );\n\treturn value;\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAKA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AAjBA;AACA;AACA;;AAUA;AACA;AACA;;AAKA,MAAMS,YAAY,GAAG,CACpB,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,SAAS,CACT;AAED,MAAMC,eAAe,GAAG;EACvB,eAAe,EAAIC,QAAQ,IAAMA,QAAQ,CAACC,MAAM;EAChD,iBAAiB,EAAID,QAAQ,IAAMA,QAAQ,CAACE,SAAS;EACrD,cAAc,EAAIF,QAAQ,IACzBA,QAAQ,CAACG,mBAAmB,KAAKC,SAAS,GACvCA,SAAS,GACT,CAAEJ,QAAQ,CAACG,mBAAmB;EAClC,sBAAsB,EAAIH,QAAQ,IACjCA,QAAQ,CAACK,sBAAsB,KAAKD,SAAS,GAC1CA,SAAS,GACT,CAAEJ,QAAQ,CAACK,sBAAsB;EACrC,sBAAsB,EAAIL,QAAQ,IAAMA,QAAQ,CAACM,SAAS;EAC1D,2BAA2B,EAAIN,QAAQ,IACtCA,QAAQ,CAACO,sBAAsB,KAAKH,SAAS,GAC1CA,SAAS,GACT,CAAEJ,QAAQ,CAACO,sBAAsB;EACrC,uBAAuB,EAAIP,QAAQ,IAAMA,QAAQ,CAACQ,sBAAsB;EACxE,eAAe,EAAIR,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KuD,uBAAuB,KAAKnD,SAAS,EAAG;QAC5C,OAAOmD,uBAAuB;MAC/B;;MAEA;MACA;MACA;MACA;MACA,OAAOT,cAAc,KAAK,oBAAoB,GAC3C,IAAI,GACJ1C,SAAS;IACb,CAAE,CAAC;EACJ,CAAC,EACD,CAAEuB,SAAS,EAAEC,QAAQ,EAAEH,KAAK,CAC7B,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS+B,UAAUA,CAAE3C,IAAI,EAAG;EAClC,IAAA4C,mBAAU,EAAE,2BAA2B,EAAE;IACxCC,KAAK,EAAE,KAAK;IACZC,WAAW,EAAE,4BAA4B;IACzCC,IAAI,EAAE;EACP,CAAE,CAAC;EAEH,MAAM,CAAE7C,KAAK,CAAE,GAAGS,WAAW,CAAEX,IAAK,CAAC;EACrC,OAAOE,KAAK;AACb"}
1
+ {"version":3,"names":["_blocks","require","_data","_deprecated","_interopRequireDefault","_element","_hooks","_blockEdit","_store","_object","blockedPaths","deprecatedFlags","settings","colors","gradients","disableCustomColors","undefined","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","prefixedFlags","removeCustomPrefixes","path","mergeOrigins","value","result","mergeCache","get","flatMap","key","_value$key","set","WeakMap","useSettings","paths","name","blockName","clientId","useBlockEditContext","useMemo","useSelect","select","candidates","blockEditorStore","getBlockParents","filter","candidateClientId","candidateBlockName","getBlockName","hasBlockSupport","map","includes","console","warn","applyFilters","normalizedPath","_getValueFromObjectPa","candidateAtts","getBlockAttributes","getValueFromObjectPath","blocks","getSettings","__experimentalFeatures","PATHS_WITH_MERGE","deprecatedSettingsValue","useSetting","deprecated","since","alternative","note"],"sources":["@wordpress/block-editor/src/components/use-settings/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { useMemo } from '@wordpress/element';\nimport { applyFilters } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport { store as blockEditorStore } from '../../store';\nimport { getValueFromObjectPath } from '../../utils/object';\n\nconst blockedPaths = [\n\t'color',\n\t'border',\n\t'dimensions',\n\t'typography',\n\t'spacing',\n];\n\nconst deprecatedFlags = {\n\t'color.palette': ( settings ) => settings.colors,\n\t'color.gradients': ( settings ) => settings.gradients,\n\t'color.custom': ( settings ) =>\n\t\tsettings.disableCustomColors === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomColors,\n\t'color.customGradient': ( settings ) =>\n\t\tsettings.disableCustomGradients === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomGradients,\n\t'typography.fontSizes': ( settings ) => settings.fontSizes,\n\t'typography.customFontSize': ( settings ) =>\n\t\tsettings.disableCustomFontSizes === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomFontSizes,\n\t'typography.lineHeight': ( settings ) => settings.enableCustomLineHeight,\n\t'spacing.units': ( settings ) => {\n\t\tif ( settings.enableCustomUnits === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( settings.enableCustomUnits === true ) {\n\t\t\treturn [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];\n\t\t}\n\n\t\treturn settings.enableCustomUnits;\n\t},\n\t'spacing.padding': ( settings ) => settings.enableCustomSpacing,\n};\n\nconst prefixedFlags = {\n\t/*\n\t * These were only available in the plugin\n\t * and can be removed when the minimum WordPress version\n\t * for the plugin is 5.9.\n\t */\n\t'border.customColor': 'border.color',\n\t'border.customStyle': 'border.style',\n\t'border.customWidth': 'border.width',\n\t'typography.customFontStyle': 'typography.fontStyle',\n\t'typography.customFontWeight': 'typography.fontWeight',\n\t'typography.customLetterSpacing': 'typography.letterSpacing',\n\t'typography.customTextDecorations': 'typography.textDecoration',\n\t'typography.customTextTransforms': 'typography.textTransform',\n\t/*\n\t * These were part of WordPress 5.8 and we need to keep them.\n\t */\n\t'border.customRadius': 'border.radius',\n\t'spacing.customMargin': 'spacing.margin',\n\t'spacing.customPadding': 'spacing.padding',\n\t'typography.customLineHeight': 'typography.lineHeight',\n};\n\n/**\n * Remove `custom` prefixes for flags that did not land in 5.8.\n *\n * This provides continued support for `custom` prefixed properties. It will\n * be removed once third party devs have had sufficient time to update themes,\n * plugins, etc.\n *\n * @see https://github.com/WordPress/gutenberg/pull/34485\n *\n * @param {string} path Path to desired value in settings.\n * @return {string} The value for defined setting.\n */\nconst removeCustomPrefixes = ( path ) => {\n\treturn prefixedFlags[ path ] || path;\n};\n\n/**\n * For settings like `color.palette`, which have a value that is an object\n * with `default`, `theme`, `custom`, with field values that are arrays of\n * items, merge these three arrays into one and return it. The calculation\n * is memoized so that identical input values produce identical output.\n * @param {Object} value Object to merge\n * @return {Array} Array of merged items\n */\nfunction mergeOrigins( value ) {\n\tlet result = mergeCache.get( value );\n\tif ( ! result ) {\n\t\tresult = [ 'default', 'theme', 'custom' ].flatMap(\n\t\t\t( key ) => value[ key ] ?? []\n\t\t);\n\t\tmergeCache.set( value, result );\n\t}\n\treturn result;\n}\nconst mergeCache = new WeakMap();\n\n/**\n * Hook that retrieves the given settings for the block instance in use.\n *\n * It looks up the settings first in the block instance hierarchy.\n * If none are found, it'll look them up in the block editor settings.\n *\n * @param {string[]} paths The paths to the settings.\n * @return {any[]} Returns the values defined for the settings.\n * @example\n * ```js\n * const [ fixed, sticky ] = useSettings( 'position.fixed', 'position.sticky' );\n * ```\n */\nexport function useSettings( ...paths ) {\n\tconst { name: blockName, clientId = null } = useBlockEditContext();\n\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tpaths = useMemo( () => paths, paths );\n\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst candidates = clientId\n\t\t\t\t? [\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t...select( blockEditorStore ).getBlockParents(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t/* ascending */ true\n\t\t\t\t\t\t),\n\t\t\t\t ].filter( ( candidateClientId ) => {\n\t\t\t\t\t\tconst candidateBlockName =\n\t\t\t\t\t\t\tselect( blockEditorStore ).getBlockName(\n\t\t\t\t\t\t\t\tcandidateClientId\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\treturn hasBlockSupport(\n\t\t\t\t\t\t\tcandidateBlockName,\n\t\t\t\t\t\t\t'__experimentalSettings',\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t } )\n\t\t\t\t: [];\n\n\t\t\treturn paths.map( ( path ) => {\n\t\t\t\tif ( blockedPaths.includes( path ) ) {\n\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t'Top level useSetting paths are disabled. Please use a subpath to query the information needed.'\n\t\t\t\t\t);\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\t// 0. Allow third parties to filter the block's settings at runtime.\n\t\t\t\tlet result = applyFilters(\n\t\t\t\t\t'blockEditor.useSetting.before',\n\t\t\t\t\tundefined,\n\t\t\t\t\tpath,\n\t\t\t\t\tclientId,\n\t\t\t\t\tblockName\n\t\t\t\t);\n\n\t\t\t\tif ( undefined !== result ) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tconst normalizedPath = removeCustomPrefixes( path );\n\n\t\t\t\t// 1. Take settings from the block instance or its ancestors.\n\t\t\t\t// Start from the current block and work our way up the ancestors.\n\t\t\t\tfor ( const candidateClientId of candidates ) {\n\t\t\t\t\tconst candidateAtts =\n\t\t\t\t\t\tselect( blockEditorStore ).getBlockAttributes(\n\t\t\t\t\t\t\tcandidateClientId\n\t\t\t\t\t\t);\n\t\t\t\t\tresult =\n\t\t\t\t\t\tgetValueFromObjectPath(\n\t\t\t\t\t\t\tcandidateAtts.settings?.blocks?.[ blockName ],\n\t\t\t\t\t\t\tnormalizedPath\n\t\t\t\t\t\t) ??\n\t\t\t\t\t\tgetValueFromObjectPath(\n\t\t\t\t\t\t\tcandidateAtts.settings,\n\t\t\t\t\t\t\tnormalizedPath\n\t\t\t\t\t\t);\n\t\t\t\t\tif ( result !== undefined ) {\n\t\t\t\t\t\t// Stop the search for more distant ancestors and move on.\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// 2. Fall back to the settings from the block editor store (__experimentalFeatures).\n\t\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\t\t\tif ( result === undefined && blockName ) {\n\t\t\t\t\tresult = getValueFromObjectPath(\n\t\t\t\t\t\tsettings.__experimentalFeatures?.blocks?.[ blockName ],\n\t\t\t\t\t\tnormalizedPath\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif ( result === undefined ) {\n\t\t\t\t\tresult = getValueFromObjectPath(\n\t\t\t\t\t\tsettings.__experimentalFeatures,\n\t\t\t\t\t\tnormalizedPath\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Return if the setting was found in either the block instance or the store.\n\t\t\t\tif ( result !== undefined ) {\n\t\t\t\t\tif ( PATHS_WITH_MERGE[ normalizedPath ] ) {\n\t\t\t\t\t\treturn mergeOrigins( result );\n\t\t\t\t\t}\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\t// 3. Otherwise, use deprecated settings.\n\t\t\t\tconst deprecatedSettingsValue =\n\t\t\t\t\tdeprecatedFlags[ normalizedPath ]?.( settings );\n\t\t\t\tif ( deprecatedSettingsValue !== undefined ) {\n\t\t\t\t\treturn deprecatedSettingsValue;\n\t\t\t\t}\n\n\t\t\t\t// 4. Fallback for typography.dropCap:\n\t\t\t\t// This is only necessary to support typography.dropCap.\n\t\t\t\t// when __experimentalFeatures are not present (core without plugin).\n\t\t\t\t// To remove when __experimentalFeatures are ported to core.\n\t\t\t\treturn normalizedPath === 'typography.dropCap'\n\t\t\t\t\t? true\n\t\t\t\t\t: undefined;\n\t\t\t} );\n\t\t},\n\t\t[ blockName, clientId, paths ]\n\t);\n}\n\n/**\n * Hook that retrieves the given setting for the block instance in use.\n *\n * It looks up the setting first in the block instance hierarchy.\n * If none is found, it'll look it up in the block editor settings.\n *\n * @param {string} path The path to the setting.\n * @return {any} Returns the value defined for the setting.\n * @deprecated 6.5.0 Use useSettings instead.\n * @example\n * ```js\n * const isEnabled = useSetting( 'typography.dropCap' );\n * ```\n */\nexport function useSetting( path ) {\n\tdeprecated( 'wp.blockEditor.useSetting', {\n\t\tsince: '6.5',\n\t\talternative: 'wp.blockEditor.useSettings',\n\t\tnote: 'The new useSettings function can retrieve multiple settings at once, with better performance.',\n\t} );\n\n\tconst [ value ] = useSettings( path );\n\treturn value;\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAKA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AAjBA;AACA;AACA;;AAUA;AACA;AACA;;AAKA,MAAMS,YAAY,GAAG,CACpB,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,SAAS,CACT;AAED,MAAMC,eAAe,GAAG;EACvB,eAAe,EAAIC,QAAQ,IAAMA,QAAQ,CAACC,MAAM;EAChD,iBAAiB,EAAID,QAAQ,IAAMA,QAAQ,CAACE,SAAS;EACrD,cAAc,EAAIF,QAAQ,IACzBA,QAAQ,CAACG,mBAAmB,KAAKC,SAAS,GACvCA,SAAS,GACT,CAAEJ,QAAQ,CAACG,mBAAmB;EAClC,sBAAsB,EAAIH,QAAQ,IACjCA,QAAQ,CAACK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C,8BAAsB,EAC9BlD,QAAQ,CAACqD,sBAAsB,EAC/BP,cACD,CAAC;MACF;;MAEA;MACA,IAAK9B,MAAM,KAAKZ,SAAS,EAAG;QAC3B,IAAKkD,uCAAgB,CAAER,cAAc,CAAE,EAAG;UACzC,OAAOhC,YAAY,CAAEE,MAAO,CAAC;QAC9B;QACA,OAAOA,MAAM;MACd;;MAEA;MACA,MAAMuC,uBAAuB,GAC5BxD,eAAe,CAAE+C,cAAc,CAAE,GAAI9C,QAAS,CAAC;MAChD,IAAKuD,uBAAuB,KAAKnD,SAAS,EAAG;QAC5C,OAAOmD,uBAAuB;MAC/B;;MAEA;MACA;MACA;MACA;MACA,OAAOT,cAAc,KAAK,oBAAoB,GAC3C,IAAI,GACJ1C,SAAS;IACb,CAAE,CAAC;EACJ,CAAC,EACD,CAAEuB,SAAS,EAAEC,QAAQ,EAAEH,KAAK,CAC7B,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS+B,UAAUA,CAAE3C,IAAI,EAAG;EAClC,IAAA4C,mBAAU,EAAE,2BAA2B,EAAE;IACxCC,KAAK,EAAE,KAAK;IACZC,WAAW,EAAE,4BAA4B;IACzCC,IAAI,EAAE;EACP,CAAE,CAAC;EAEH,MAAM,CAAE7C,KAAK,CAAE,GAAGS,WAAW,CAAEX,IAAK,CAAC;EACrC,OAAOE,KAAK;AACb"}
@@ -4,12 +4,23 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.addLabelCallback = addLabelCallback;
7
+ exports.withBlockRenameControl = void 0;
8
+ var _react = require("react");
7
9
  var _hooks = require("@wordpress/hooks");
8
10
  var _blocks = require("@wordpress/blocks");
11
+ var _compose = require("@wordpress/compose");
12
+ var _i18n = require("@wordpress/i18n");
13
+ var _components = require("@wordpress/components");
14
+ var _components2 = require("../components");
15
+ var _blockRename = require("../components/block-rename");
9
16
  /**
10
17
  * WordPress dependencies
11
18
  */
12
19
 
20
+ /**
21
+ * Internal dependencies
22
+ */
23
+
13
24
  /**
14
25
  * Filters registered block settings, adding an `__experimentalLabel` callback if one does not already exist.
15
26
  *
@@ -42,5 +53,36 @@ function addLabelCallback(settings) {
42
53
  }
43
54
  return settings;
44
55
  }
56
+ const withBlockRenameControl = (0, _compose.createHigherOrderComponent)(BlockEdit => props => {
57
+ const {
58
+ name,
59
+ attributes,
60
+ setAttributes,
61
+ isSelected
62
+ } = props;
63
+ const {
64
+ canRename
65
+ } = (0, _blockRename.useBlockRename)(name);
66
+ return (0, _react.createElement)(_react.Fragment, null, isSelected && canRename && (0, _react.createElement)(_components2.InspectorControls, {
67
+ group: "advanced"
68
+ }, (0, _react.createElement)(_components.TextControl, {
69
+ __nextHasNoMarginBottom: true,
70
+ label: (0, _i18n.__)('Block name'),
71
+ value: attributes?.metadata?.name || '',
72
+ onChange: newName => {
73
+ setAttributes({
74
+ metadata: {
75
+ ...attributes?.metadata,
76
+ name: newName
77
+ }
78
+ });
79
+ }
80
+ })), (0, _react.createElement)(BlockEdit, {
81
+ key: "edit",
82
+ ...props
83
+ }));
84
+ }, 'withToolbarControls');
85
+ exports.withBlockRenameControl = withBlockRenameControl;
86
+ (0, _hooks.addFilter)('editor.BlockEdit', 'core/block-rename-ui/with-block-rename-control', withBlockRenameControl);
45
87
  (0, _hooks.addFilter)('blocks.registerBlockType', 'core/metadata/addLabelCallback', addLabelCallback);
46
88
  //# sourceMappingURL=block-renaming.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_hooks","require","_blocks","addLabelCallback","settings","__experimentalLabel","supportsBlockNaming","hasBlockSupport","attributes","context","metadata","name","addFilter"],"sources":["@wordpress/block-editor/src/hooks/block-renaming.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Filters registered block settings, adding an `__experimentalLabel` callback if one does not already exist.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addLabelCallback( settings ) {\n\t// If blocks provide their own label callback, do not override it.\n\tif ( settings.__experimentalLabel ) {\n\t\treturn settings;\n\t}\n\n\tconst supportsBlockNaming = hasBlockSupport(\n\t\tsettings,\n\t\t'renaming',\n\t\ttrue // default value\n\t);\n\n\t// Check whether block metadata is supported before using it.\n\tif ( supportsBlockNaming ) {\n\t\tsettings.__experimentalLabel = ( attributes, { context } ) => {\n\t\t\tconst { metadata } = attributes;\n\n\t\t\t// In the list view, use the block's name attribute as the label.\n\t\t\tif ( context === 'list-view' && metadata?.name ) {\n\t\t\t\treturn metadata.name;\n\t\t\t}\n\t\t};\n\t}\n\n\treturn settings;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/metadata/addLabelCallback',\n\taddLabelCallback\n);\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,gBAAgBA,CAAEC,QAAQ,EAAG;EAC5C;EACA,IAAKA,QAAQ,CAACC,mBAAmB,EAAG;IACnC,OAAOD,QAAQ;EAChB;EAEA,MAAME,mBAAmB,GAAG,IAAAC,uBAAe,EAC1CH,QAAQ,EACR,UAAU,EACV,IAAI,CAAC;EACN,CAAC;;EAED;EACA,IAAKE,mBAAmB,EAAG;IAC1BF,QAAQ,CAACC,mBAAmB,GAAG,CAAEG,UAAU,EAAE;MAAEC;IAAQ,CAAC,KAAM;MAC7D,MAAM;QAAEC;MAAS,CAAC,GAAGF,UAAU;;MAE/B;MACA,IAAKC,OAAO,KAAK,WAAW,IAAIC,QAAQ,EAAEC,IAAI,EAAG;QAChD,OAAOD,QAAQ,CAACC,IAAI;MACrB;IACD,CAAC;EACF;EAEA,OAAOP,QAAQ;AAChB;AAEA,IAAAQ,gBAAS,EACR,0BAA0B,EAC1B,gCAAgC,EAChCT,gBACD,CAAC"}
1
+ {"version":3,"names":["_hooks","require","_blocks","_compose","_i18n","_components","_components2","_blockRename","addLabelCallback","settings","__experimentalLabel","supportsBlockNaming","hasBlockSupport","attributes","context","metadata","name","withBlockRenameControl","createHigherOrderComponent","BlockEdit","props","setAttributes","isSelected","canRename","useBlockRename","_react","createElement","Fragment","InspectorControls","group","TextControl","__nextHasNoMarginBottom","label","__","value","onChange","newName","key","exports","addFilter"],"sources":["@wordpress/block-editor/src/hooks/block-renaming.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { TextControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockRename } from '../components/block-rename';\n\n/**\n * Filters registered block settings, adding an `__experimentalLabel` callback if one does not already exist.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addLabelCallback( settings ) {\n\t// If blocks provide their own label callback, do not override it.\n\tif ( settings.__experimentalLabel ) {\n\t\treturn settings;\n\t}\n\n\tconst supportsBlockNaming = hasBlockSupport(\n\t\tsettings,\n\t\t'renaming',\n\t\ttrue // default value\n\t);\n\n\t// Check whether block metadata is supported before using it.\n\tif ( supportsBlockNaming ) {\n\t\tsettings.__experimentalLabel = ( attributes, { context } ) => {\n\t\t\tconst { metadata } = attributes;\n\n\t\t\t// In the list view, use the block's name attribute as the label.\n\t\t\tif ( context === 'list-view' && metadata?.name ) {\n\t\t\t\treturn metadata.name;\n\t\t\t}\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nexport const withBlockRenameControl = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name, attributes, setAttributes, isSelected } = props;\n\n\t\tconst { canRename } = useBlockRename( name );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ isSelected && canRename && (\n\t\t\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\t\t\tvalue={ attributes?.metadata?.name || '' }\n\t\t\t\t\t\t\tonChange={ ( newName ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\t...attributes?.metadata,\n\t\t\t\t\t\t\t\t\t\tname: newName,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</InspectorControls>\n\t\t\t\t) }\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/block-rename-ui/with-block-rename-control',\n\twithBlockRenameControl\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/metadata/addLabelCallback',\n\taddLabelCallback\n);\n"],"mappings":";;;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAKA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAOA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASO,gBAAgBA,CAAEC,QAAQ,EAAG;EAC5C;EACA,IAAKA,QAAQ,CAACC,mBAAmB,EAAG;IACnC,OAAOD,QAAQ;EAChB;EAEA,MAAME,mBAAmB,GAAG,IAAAC,uBAAe,EAC1CH,QAAQ,EACR,UAAU,EACV,IAAI,CAAC;EACN,CA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D,CAAC;AAACkB,OAAA,CAAArB,sBAAA,GAAAA,sBAAA;AAEF,IAAAsB,gBAAS,EACR,kBAAkB,EAClB,gDAAgD,EAChDtB,sBACD,CAAC;AAED,IAAAsB,gBAAS,EACR,0BAA0B,EAC1B,gCAAgC,EAChC/B,gBACD,CAAC"}
@@ -35,6 +35,53 @@ function addAttribute(settings) {
35
35
  }
36
36
  return settings;
37
37
  }
38
+ function CustomFieldsControl(props) {
39
+ const blockEditingMode = (0, _blockEditingMode.useBlockEditingMode)();
40
+ if (blockEditingMode !== 'default') {
41
+ return null;
42
+ }
43
+
44
+ // If the block is a paragraph or image block, we need to know which
45
+ // attribute to use for the connection. Only the `content` attribute
46
+ // of the paragraph block and the `url` attribute of the image block are supported.
47
+ let attributeName;
48
+ if (props.name === 'core/paragraph') attributeName = 'content';
49
+ if (props.name === 'core/image') attributeName = 'url';
50
+ return (0, _react.createElement)(_components2.InspectorControls, null, (0, _react.createElement)(_components.PanelBody, {
51
+ title: (0, _i18n.__)('Connections'),
52
+ initialOpen: true
53
+ }, (0, _react.createElement)(_components.TextControl, {
54
+ __nextHasNoMarginBottom: true,
55
+ autoComplete: "off",
56
+ label: (0, _i18n.__)('Custom field meta_key'),
57
+ value: props.attributes?.connections?.attributes?.[attributeName]?.value || '',
58
+ onChange: nextValue => {
59
+ if (nextValue === '') {
60
+ props.setAttributes({
61
+ connections: undefined,
62
+ [attributeName]: undefined,
63
+ placeholder: undefined
64
+ });
65
+ } else {
66
+ props.setAttributes({
67
+ connections: {
68
+ attributes: {
69
+ // The attributeName will be either `content` or `url`.
70
+ [attributeName]: {
71
+ // Source will be variable, could be post_meta, user_meta, term_meta, etc.
72
+ // Could even be a custom source like a social media attribute.
73
+ source: 'meta_fields',
74
+ value: nextValue
75
+ }
76
+ }
77
+ },
78
+ [attributeName]: undefined,
79
+ placeholder: (0, _i18n.sprintf)('This content will be replaced on the frontend by the value of "%s" custom field.', nextValue)
80
+ });
81
+ }
82
+ }
83
+ })));
84
+ }
38
85
 
39
86
  /**
40
87
  * Override the default edit UI to include a new block inspector control for
@@ -48,64 +95,22 @@ function addAttribute(settings) {
48
95
  */
49
96
  const withCustomFieldsControls = (0, _compose.createHigherOrderComponent)(BlockEdit => {
50
97
  return props => {
51
- const blockEditingMode = (0, _blockEditingMode.useBlockEditingMode)();
52
98
  const hasCustomFieldsSupport = (0, _blocks.hasBlockSupport)(props.name, '__experimentalConnections', false);
53
99
 
54
100
  // Check if the current block is a paragraph or image block.
55
101
  // Currently, only these two blocks are supported.
56
102
  if (!['core/paragraph', 'core/image'].includes(props.name)) {
57
103
  return (0, _react.createElement)(BlockEdit, {
104
+ key: "edit",
58
105
  ...props
59
106
  });
60
107
  }
61
-
62
- // If the block is a paragraph or image block, we need to know which
63
- // attribute to use for the connection. Only the `content` attribute
64
- // of the paragraph block and the `url` attribute of the image block are supported.
65
- let attributeName;
66
- if (props.name === 'core/paragraph') attributeName = 'content';
67
- if (props.name === 'core/image') attributeName = 'url';
68
- if (hasCustomFieldsSupport && props.isSelected) {
69
- return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(BlockEdit, {
70
- ...props
71
- }), blockEditingMode === 'default' && (0, _react.createElement)(_components2.InspectorControls, null, (0, _react.createElement)(_components.PanelBody, {
72
- title: (0, _i18n.__)('Connections'),
73
- initialOpen: true
74
- }, (0, _react.createElement)(_components.TextControl, {
75
- __nextHasNoMarginBottom: true,
76
- autoComplete: "off",
77
- label: (0, _i18n.__)('Custom field meta_key'),
78
- value: props.attributes?.connections?.attributes?.[attributeName]?.value || '',
79
- onChange: nextValue => {
80
- if (nextValue === '') {
81
- props.setAttributes({
82
- connections: undefined,
83
- [attributeName]: undefined,
84
- placeholder: undefined
85
- });
86
- } else {
87
- props.setAttributes({
88
- connections: {
89
- attributes: {
90
- // The attributeName will be either `content` or `url`.
91
- [attributeName]: {
92
- // Source will be variable, could be post_meta, user_meta, term_meta, etc.
93
- // Could even be a custom source like a social media attribute.
94
- source: 'meta_fields',
95
- value: nextValue
96
- }
97
- }
98
- },
99
- [attributeName]: undefined,
100
- placeholder: (0, _i18n.sprintf)('This content will be replaced on the frontend by the value of "%s" custom field.', nextValue)
101
- });
102
- }
103
- }
104
- }))));
105
- }
106
- return (0, _react.createElement)(BlockEdit, {
108
+ return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(BlockEdit, {
109
+ key: "edit",
110
+ ...props
111
+ }), hasCustomFieldsSupport && props.isSelected && (0, _react.createElement)(CustomFieldsControl, {
107
112
  ...props
108
- });
113
+ }));
109
114
  };
110
115
  }, 'withCustomFieldsControls');
111
116
  if (window.__experimentalConnections) {