@wordpress/block-editor 15.16.1-next.v.202604091042.0 → 15.18.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 (303) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/build/components/autocomplete/index.cjs.map +3 -3
  3. package/build/components/background-image-control/index.cjs +2 -1
  4. package/build/components/background-image-control/index.cjs.map +2 -2
  5. package/build/components/block-allowed-blocks/modal.cjs.map +2 -2
  6. package/build/components/block-bindings/attribute-control.cjs.map +3 -3
  7. package/build/components/block-card/index.cjs +2 -2
  8. package/build/components/block-card/index.cjs.map +3 -3
  9. package/build/components/block-mover/button.cjs +9 -3
  10. package/build/components/block-mover/button.cjs.map +2 -2
  11. package/build/components/block-pattern-setup/index.cjs +3 -2
  12. package/build/components/block-pattern-setup/index.cjs.map +2 -2
  13. package/build/components/block-patterns-list/index.cjs +2 -1
  14. package/build/components/block-patterns-list/index.cjs.map +2 -2
  15. package/build/components/block-patterns-paging/index.cjs.map +3 -3
  16. package/build/components/block-settings-menu/block-settings-dropdown.cjs +2 -2
  17. package/build/components/block-settings-menu/block-settings-dropdown.cjs.map +3 -3
  18. package/build/components/block-settings-menu/index.cjs +2 -2
  19. package/build/components/block-settings-menu/index.cjs.map +3 -3
  20. package/build/components/block-styles/menu-items.cjs.map +3 -3
  21. package/build/components/block-switcher/index.cjs.map +3 -3
  22. package/build/components/block-switcher/pattern-transformations-menu.cjs +2 -1
  23. package/build/components/block-switcher/pattern-transformations-menu.cjs.map +2 -2
  24. package/build/components/block-toolbar/pattern-overrides-dropdown.cjs.map +3 -3
  25. package/build/components/block-variation-transforms/index.cjs +2 -1
  26. package/build/components/block-variation-transforms/index.cjs.map +2 -2
  27. package/build/components/block-visibility/viewport-visibility-info.cjs +4 -4
  28. package/build/components/block-visibility/viewport-visibility-info.cjs.map +3 -3
  29. package/build/components/collab/{block-comment-icon-slot.cjs → note-icon-slot.cjs} +8 -8
  30. package/build/components/collab/note-icon-slot.cjs.map +7 -0
  31. package/build/components/collab/{block-comment-icon-toolbar-slot.cjs → note-icon-toolbar-slot.cjs} +9 -9
  32. package/build/components/collab/note-icon-toolbar-slot.cjs.map +7 -0
  33. package/build/components/copy-handler/index.cjs.map +2 -2
  34. package/build/components/date-format-picker/index.cjs +2 -1
  35. package/build/components/date-format-picker/index.cjs.map +2 -2
  36. package/build/components/global-styles/color-panel.cjs.map +2 -2
  37. package/build/components/global-styles/dimensions-panel.cjs +87 -62
  38. package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
  39. package/build/components/global-styles/filters-panel.cjs.map +2 -2
  40. package/build/components/global-styles/hooks.cjs +9 -7
  41. package/build/components/global-styles/hooks.cjs.map +2 -2
  42. package/build/components/grid/grid-item-movers.cjs +2 -1
  43. package/build/components/grid/grid-item-movers.cjs.map +2 -2
  44. package/build/components/inserter/block-patterns-tab/pattern-category-previews.cjs.map +2 -2
  45. package/build/components/inserter/menu.cjs +2 -1
  46. package/build/components/inserter/menu.cjs.map +2 -2
  47. package/build/components/inserter/search-results.cjs +3 -3
  48. package/build/components/inserter/search-results.cjs.map +2 -2
  49. package/build/components/inspector-popover-header/index.cjs.map +3 -3
  50. package/build/components/link-control/link-preview.cjs +5 -3
  51. package/build/components/link-control/link-preview.cjs.map +2 -2
  52. package/build/components/link-control/settings.cjs +2 -1
  53. package/build/components/link-control/settings.cjs.map +2 -2
  54. package/build/components/link-picker/link-picker.cjs +3 -2
  55. package/build/components/link-picker/link-picker.cjs.map +2 -2
  56. package/build/components/link-picker/link-preview.cjs +2 -2
  57. package/build/components/link-picker/link-preview.cjs.map +2 -2
  58. package/build/components/list-view/block-select-button.cjs +2 -2
  59. package/build/components/list-view/block-select-button.cjs.map +2 -2
  60. package/build/components/list-view/index.cjs +2 -1
  61. package/build/components/list-view/index.cjs.map +2 -2
  62. package/build/components/preset-input-control/index.cjs +7 -4
  63. package/build/components/preset-input-control/index.cjs.map +2 -2
  64. package/build/components/provider/index.cjs +80 -7
  65. package/build/components/provider/index.cjs.map +2 -2
  66. package/build/components/responsive-block-control/label.cjs +9 -2
  67. package/build/components/responsive-block-control/label.cjs.map +2 -2
  68. package/build/components/rich-text/event-listeners/index.cjs.map +2 -2
  69. package/build/components/rich-text/event-listeners/paste-handler.cjs +12 -5
  70. package/build/components/rich-text/event-listeners/paste-handler.cjs.map +3 -3
  71. package/build/components/spacing-sizes-control/utils.cjs +1 -1
  72. package/build/components/spacing-sizes-control/utils.cjs.map +2 -2
  73. package/build/components/url-popover/image-url-input-ui.cjs +1 -1
  74. package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
  75. package/build/components/writing-flow/use-arrow-nav.cjs +1 -1
  76. package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
  77. package/build/components/writing-flow/use-selection-observer.cjs +23 -1
  78. package/build/components/writing-flow/use-selection-observer.cjs.map +2 -2
  79. package/build/hooks/block-bindings.cjs.map +3 -3
  80. package/build/hooks/block-fields/link/index.cjs +1 -1
  81. package/build/hooks/block-fields/link/index.cjs.map +1 -1
  82. package/build/hooks/custom-css.cjs +21 -0
  83. package/build/hooks/custom-css.cjs.map +3 -3
  84. package/build/hooks/dimensions.cjs +5 -1
  85. package/build/hooks/dimensions.cjs.map +2 -2
  86. package/build/hooks/grid-visualizer.cjs +1 -1
  87. package/build/hooks/grid-visualizer.cjs.map +1 -1
  88. package/build/hooks/layout-child.cjs +1 -1
  89. package/build/hooks/layout-child.cjs.map +1 -1
  90. package/build/hooks/style.cjs +54 -52
  91. package/build/hooks/style.cjs.map +2 -2
  92. package/build/hooks/utils.cjs +4 -0
  93. package/build/hooks/utils.cjs.map +2 -2
  94. package/build/layouts/flex.cjs +5 -8
  95. package/build/layouts/flex.cjs.map +3 -3
  96. package/build/layouts/grid.cjs +5 -5
  97. package/build/layouts/grid.cjs.map +2 -2
  98. package/build/private-apis.cjs +5 -4
  99. package/build/private-apis.cjs.map +3 -3
  100. package/build/store/private-keys.cjs +3 -0
  101. package/build/store/private-keys.cjs.map +2 -2
  102. package/build/utils/dom.cjs +3 -1
  103. package/build/utils/dom.cjs.map +2 -2
  104. package/build-module/components/autocomplete/index.mjs +2 -2
  105. package/build-module/components/autocomplete/index.mjs.map +2 -2
  106. package/build-module/components/background-image-control/index.mjs +2 -2
  107. package/build-module/components/background-image-control/index.mjs.map +2 -2
  108. package/build-module/components/block-allowed-blocks/modal.mjs +2 -2
  109. package/build-module/components/block-allowed-blocks/modal.mjs.map +2 -2
  110. package/build-module/components/block-bindings/attribute-control.mjs +3 -3
  111. package/build-module/components/block-bindings/attribute-control.mjs.map +2 -2
  112. package/build-module/components/block-card/index.mjs +4 -4
  113. package/build-module/components/block-card/index.mjs.map +2 -2
  114. package/build-module/components/block-mover/button.mjs +11 -5
  115. package/build-module/components/block-mover/button.mjs.map +2 -2
  116. package/build-module/components/block-pattern-setup/index.mjs +2 -1
  117. package/build-module/components/block-pattern-setup/index.mjs.map +2 -2
  118. package/build-module/components/block-patterns-list/index.mjs +1 -1
  119. package/build-module/components/block-patterns-list/index.mjs.map +2 -2
  120. package/build-module/components/block-patterns-paging/index.mjs +3 -3
  121. package/build-module/components/block-patterns-paging/index.mjs.map +2 -2
  122. package/build-module/components/block-settings-menu/block-settings-dropdown.mjs +2 -2
  123. package/build-module/components/block-settings-menu/block-settings-dropdown.mjs.map +2 -2
  124. package/build-module/components/block-settings-menu/index.mjs +2 -2
  125. package/build-module/components/block-settings-menu/index.mjs.map +2 -2
  126. package/build-module/components/block-styles/menu-items.mjs +2 -2
  127. package/build-module/components/block-styles/menu-items.mjs.map +2 -2
  128. package/build-module/components/block-switcher/index.mjs +2 -2
  129. package/build-module/components/block-switcher/index.mjs.map +2 -2
  130. package/build-module/components/block-switcher/pattern-transformations-menu.mjs +2 -7
  131. package/build-module/components/block-switcher/pattern-transformations-menu.mjs.map +2 -2
  132. package/build-module/components/block-toolbar/pattern-overrides-dropdown.mjs +2 -2
  133. package/build-module/components/block-toolbar/pattern-overrides-dropdown.mjs.map +2 -2
  134. package/build-module/components/block-variation-transforms/index.mjs +2 -2
  135. package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
  136. package/build-module/components/block-visibility/viewport-visibility-info.mjs +6 -6
  137. package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +2 -2
  138. package/build-module/components/collab/note-icon-slot.mjs +8 -0
  139. package/build-module/components/collab/note-icon-slot.mjs.map +7 -0
  140. package/build-module/components/collab/note-icon-toolbar-slot.mjs +10 -0
  141. package/build-module/components/collab/note-icon-toolbar-slot.mjs.map +7 -0
  142. package/build-module/components/copy-handler/index.mjs.map +2 -2
  143. package/build-module/components/date-format-picker/index.mjs +2 -2
  144. package/build-module/components/date-format-picker/index.mjs.map +2 -2
  145. package/build-module/components/global-styles/color-panel.mjs.map +2 -2
  146. package/build-module/components/global-styles/dimensions-panel.mjs +87 -62
  147. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  148. package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
  149. package/build-module/components/global-styles/hooks.mjs +9 -7
  150. package/build-module/components/global-styles/hooks.mjs.map +2 -2
  151. package/build-module/components/grid/grid-item-movers.mjs +2 -5
  152. package/build-module/components/grid/grid-item-movers.mjs.map +2 -2
  153. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.mjs +3 -3
  154. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.mjs.map +1 -1
  155. package/build-module/components/inserter/menu.mjs +3 -2
  156. package/build-module/components/inserter/menu.mjs.map +2 -2
  157. package/build-module/components/inserter/search-results.mjs +1 -1
  158. package/build-module/components/inserter/search-results.mjs.map +1 -1
  159. package/build-module/components/inspector-popover-header/index.mjs +2 -2
  160. package/build-module/components/inspector-popover-header/index.mjs.map +2 -2
  161. package/build-module/components/link-control/link-preview.mjs +5 -3
  162. package/build-module/components/link-control/link-preview.mjs.map +2 -2
  163. package/build-module/components/link-control/settings.mjs +3 -2
  164. package/build-module/components/link-control/settings.mjs.map +2 -2
  165. package/build-module/components/link-picker/link-picker.mjs +1 -1
  166. package/build-module/components/link-picker/link-picker.mjs.map +2 -2
  167. package/build-module/components/link-picker/link-preview.mjs +2 -2
  168. package/build-module/components/link-picker/link-preview.mjs.map +2 -2
  169. package/build-module/components/list-view/block-select-button.mjs +2 -2
  170. package/build-module/components/list-view/block-select-button.mjs.map +2 -2
  171. package/build-module/components/list-view/index.mjs +2 -4
  172. package/build-module/components/list-view/index.mjs.map +2 -2
  173. package/build-module/components/preset-input-control/index.mjs +7 -4
  174. package/build-module/components/preset-input-control/index.mjs.map +2 -2
  175. package/build-module/components/provider/index.mjs +82 -8
  176. package/build-module/components/provider/index.mjs.map +2 -2
  177. package/build-module/components/responsive-block-control/label.mjs +9 -2
  178. package/build-module/components/responsive-block-control/label.mjs.map +2 -2
  179. package/build-module/components/rich-text/event-listeners/index.mjs.map +2 -2
  180. package/build-module/components/rich-text/event-listeners/paste-handler.mjs +12 -5
  181. package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +2 -2
  182. package/build-module/components/spacing-sizes-control/utils.mjs +1 -1
  183. package/build-module/components/spacing-sizes-control/utils.mjs.map +2 -2
  184. package/build-module/components/url-popover/image-url-input-ui.mjs +1 -1
  185. package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
  186. package/build-module/components/writing-flow/use-arrow-nav.mjs +1 -1
  187. package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
  188. package/build-module/components/writing-flow/use-selection-observer.mjs +23 -1
  189. package/build-module/components/writing-flow/use-selection-observer.mjs.map +2 -2
  190. package/build-module/hooks/block-bindings.mjs +2 -2
  191. package/build-module/hooks/block-bindings.mjs.map +2 -2
  192. package/build-module/hooks/block-fields/link/index.mjs +1 -1
  193. package/build-module/hooks/block-fields/link/index.mjs.map +1 -1
  194. package/build-module/hooks/custom-css.mjs +23 -2
  195. package/build-module/hooks/custom-css.mjs.map +2 -2
  196. package/build-module/hooks/dimensions.mjs +5 -1
  197. package/build-module/hooks/dimensions.mjs.map +2 -2
  198. package/build-module/hooks/grid-visualizer.mjs +1 -1
  199. package/build-module/hooks/grid-visualizer.mjs.map +1 -1
  200. package/build-module/hooks/layout-child.mjs +1 -1
  201. package/build-module/hooks/layout-child.mjs.map +1 -1
  202. package/build-module/hooks/style.mjs +54 -52
  203. package/build-module/hooks/style.mjs.map +2 -2
  204. package/build-module/hooks/utils.mjs +4 -0
  205. package/build-module/hooks/utils.mjs.map +2 -2
  206. package/build-module/layouts/flex.mjs +4 -7
  207. package/build-module/layouts/flex.mjs.map +2 -2
  208. package/build-module/layouts/grid.mjs +4 -4
  209. package/build-module/layouts/grid.mjs.map +2 -2
  210. package/build-module/private-apis.mjs +7 -5
  211. package/build-module/private-apis.mjs.map +2 -2
  212. package/build-module/store/private-keys.mjs +2 -0
  213. package/build-module/store/private-keys.mjs.map +2 -2
  214. package/build-module/utils/dom.mjs +2 -1
  215. package/build-module/utils/dom.mjs.map +2 -2
  216. package/build-style/content-rtl.css +1 -4
  217. package/build-style/content.css +1 -4
  218. package/build-style/style-rtl.css +12 -12
  219. package/build-style/style.css +12 -12
  220. package/build-types/utils/dom.d.ts +7 -0
  221. package/build-types/utils/dom.d.ts.map +1 -1
  222. package/package.json +39 -38
  223. package/src/components/autocomplete/index.js +4 -2
  224. package/src/components/background-image-control/index.js +2 -2
  225. package/src/components/background-image-control/style.scss +1 -1
  226. package/src/components/block-allowed-blocks/modal.js +3 -3
  227. package/src/components/block-bindings/attribute-control.js +4 -4
  228. package/src/components/block-card/index.js +5 -5
  229. package/src/components/block-list/content.scss +0 -4
  230. package/src/components/block-mover/button.js +17 -7
  231. package/src/components/block-pattern-setup/index.js +2 -1
  232. package/src/components/block-pattern-setup/style.scss +2 -2
  233. package/src/components/block-patterns-list/index.js +1 -1
  234. package/src/components/block-patterns-list/style.scss +1 -1
  235. package/src/components/block-patterns-paging/index.js +5 -6
  236. package/src/components/block-settings-menu/block-settings-dropdown.js +2 -2
  237. package/src/components/block-settings-menu/index.js +2 -2
  238. package/src/components/block-styles/menu-items.js +3 -3
  239. package/src/components/block-switcher/index.js +3 -3
  240. package/src/components/block-switcher/pattern-transformations-menu.js +2 -7
  241. package/src/components/block-switcher/style.scss +2 -2
  242. package/src/components/block-toolbar/pattern-overrides-dropdown.js +2 -2
  243. package/src/components/block-variation-transforms/index.js +2 -2
  244. package/src/components/block-visibility/viewport-visibility-info.js +7 -7
  245. package/src/components/collab/note-icon-slot.js +8 -0
  246. package/src/components/collab/note-icon-toolbar-slot.js +10 -0
  247. package/src/components/copy-handler/index.js +1 -0
  248. package/src/components/date-format-picker/index.js +4 -2
  249. package/src/components/global-styles/color-panel.js +0 -2
  250. package/src/components/global-styles/dimensions-panel.js +100 -73
  251. package/src/components/global-styles/filters-panel.js +0 -2
  252. package/src/components/global-styles/hooks.js +9 -7
  253. package/src/components/global-styles/style.scss +1 -1
  254. package/src/components/grid/grid-item-movers.js +2 -5
  255. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +5 -5
  256. package/src/components/inserter/menu.js +3 -2
  257. package/src/components/inserter/search-results.js +1 -1
  258. package/src/components/inserter/style.scss +2 -2
  259. package/src/components/inserter-list-item/style.scss +1 -1
  260. package/src/components/inspector-popover-header/index.js +2 -2
  261. package/src/components/link-control/link-preview.js +6 -4
  262. package/src/components/link-control/settings.js +3 -2
  263. package/src/components/link-picker/link-picker.js +1 -1
  264. package/src/components/link-picker/link-preview.js +3 -3
  265. package/src/components/list-view/block-select-button.js +3 -3
  266. package/src/components/list-view/index.js +2 -4
  267. package/src/components/list-view/style.scss +1 -1
  268. package/src/components/media-placeholder/content.scss +1 -1
  269. package/src/components/preset-input-control/index.js +10 -4
  270. package/src/components/preset-input-control/test/index.js +70 -0
  271. package/src/components/provider/index.js +149 -8
  272. package/src/components/responsive-block-control/label.js +5 -2
  273. package/src/components/rich-text/event-listeners/index.js +1 -0
  274. package/src/components/rich-text/event-listeners/paste-handler.js +18 -4
  275. package/src/components/spacing-sizes-control/utils.js +1 -1
  276. package/src/components/url-input/style.scss +1 -1
  277. package/src/components/url-popover/image-url-input-ui.js +1 -1
  278. package/src/components/writing-flow/use-arrow-nav.js +9 -2
  279. package/src/components/writing-flow/use-selection-observer.js +39 -1
  280. package/src/hooks/block-bindings.js +3 -3
  281. package/src/hooks/block-fields/link/index.js +1 -1
  282. package/src/hooks/custom-css.js +30 -9
  283. package/src/hooks/dimensions.js +6 -1
  284. package/src/hooks/grid-visualizer.js +1 -1
  285. package/src/hooks/layout-child.js +1 -1
  286. package/src/hooks/style.js +75 -61
  287. package/src/hooks/test/dimensions.js +16 -0
  288. package/src/hooks/test/style.js +2 -0
  289. package/src/hooks/utils.js +4 -0
  290. package/src/layouts/flex.js +7 -9
  291. package/src/layouts/grid.js +7 -4
  292. package/src/private-apis.js +6 -4
  293. package/src/store/private-keys.js +1 -0
  294. package/src/utils/dom.js +3 -3
  295. package/src/utils/test/dom.js +47 -4
  296. package/build/components/collab/block-comment-icon-slot.cjs.map +0 -7
  297. package/build/components/collab/block-comment-icon-toolbar-slot.cjs.map +0 -7
  298. package/build-module/components/collab/block-comment-icon-slot.mjs +0 -8
  299. package/build-module/components/collab/block-comment-icon-slot.mjs.map +0 -7
  300. package/build-module/components/collab/block-comment-icon-toolbar-slot.mjs +0 -10
  301. package/build-module/components/collab/block-comment-icon-toolbar-slot.mjs.map +0 -7
  302. package/src/components/collab/block-comment-icon-slot.js +0 -8
  303. package/src/components/collab/block-comment-icon-toolbar-slot.js +0 -10
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/preset-input-control/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCustomSelectControl,\n\tIcon,\n\tRangeControl,\n\t__experimentalHStack as HStack,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { usePrevious } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { settings } from '@wordpress/icons';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tCUSTOM_VALUE_SETTINGS,\n\tICON_SIZE,\n\tRANGE_CONTROL_MAX_SIZE,\n} from './constants';\nimport {\n\tgetCustomValueFromPreset,\n\tgetPresetValueFromCustomValue,\n\tgetSliderValueFromPreset,\n\tisValuePreset,\n} from './utils';\nimport CustomValueControls from './custom-value-controls';\n\n/**\n * PresetInputControl component for selecting preset values or entering custom values.\n *\n * Displays preset values as either a slider (for <= 8 presets) or a select dropdown.\n * Allows toggling to custom value mode with a UnitControl and RangeControl.\n * Handles unit tracking and conversion between preset and custom values.\n *\n * @param {Object} props Component props.\n * @param {boolean} props.allowNegativeOnDrag Whether to allow negative values during drag operations.\n * @param {string} props.ariaLabel Accessible label for the control.\n * @param {string} props.className Optional CSS class name.\n * @param {Object} props.customValueSettings Optional custom value settings for max/steps per unit.\n * @param {boolean} props.disableCustomValues Whether to disable custom value input.\n * @param {Object} props.icon Icon to display alongside the control.\n * @param {boolean} props.isMixed Whether the current value is mixed (multiple values).\n * @param {number} props.minimumCustomValue Minimum allowed custom value.\n * @param {Function} props.onChange Callback when value changes.\n * @param {Function} props.onMouseOut Callback for mouse out events.\n * @param {Function} props.onMouseOver Callback for mouse over events.\n * @param {Function} props.onUnitChange Callback when unit changes.\n * @param {Array} props.presets Array of preset objects with name, slug, and size.\n * @param {string} props.presetType Type of preset (e.g., 'spacing', 'border-radius').\n * @param {string} props.selectedUnit Currently selected unit (e.g., 'px', 'em').\n * @param {boolean} props.showTooltip Whether to show tooltip on custom UnitControl.\n * @param {Array} props.units Array of available unit objects (can include max and step).\n * @param {string} props.value Current value (preset or custom).\n *\n * @return {Element} The PresetInputControl component.\n */\nexport default function PresetInputControl( {\n\tallowNegativeOnDrag = false,\n\tariaLabel,\n\tclassName: classNameProp,\n\tcustomValueSettings = CUSTOM_VALUE_SETTINGS,\n\tdisableCustomValues,\n\ticon,\n\tisMixed,\n\tvalue: valueProp,\n\tminimumCustomValue,\n\tonChange,\n\tonMouseOut,\n\tonMouseOver,\n\tonUnitChange,\n\tpresets = [],\n\tpresetType,\n\tselectedUnit,\n\tshowTooltip,\n\tunits,\n} ) {\n\tconst value = useMemo(\n\t\t() => getPresetValueFromCustomValue( valueProp, presets, presetType ),\n\t\t[ valueProp, presets, presetType ]\n\t);\n\n\tconst className = classNameProp ?? 'preset-input-control';\n\n\tconst marks = presets\n\t\t.slice( 1, presets.length - 1 )\n\t\t.map( ( _newValue, index ) => ( {\n\t\t\tvalue: index + 1,\n\t\t\tlabel: undefined,\n\t\t} ) );\n\tconst hasPresets = marks.length > 0;\n\tconst showRangeControl = presets.length <= RANGE_CONTROL_MAX_SIZE;\n\n\tconst allPlaceholder = isMixed ? __( 'Mixed' ) : null;\n\n\tconst [ minValue, setMinValue ] = useState( minimumCustomValue );\n\tconst [ showCustomValueControl, setShowCustomValueControl ] = useState(\n\t\t! disableCustomValues &&\n\t\t\tvalue !== undefined &&\n\t\t\t! isValuePreset( value, presetType )\n\t);\n\n\tlet currentValue = null;\n\n\tconst previousValue = usePrevious( value );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t!! value &&\n\t\t\tpreviousValue !== value &&\n\t\t\t! isValuePreset( value, presetType ) &&\n\t\t\tshowCustomValueControl !== true\n\t\t) {\n\t\t\tsetShowCustomValueControl( true );\n\t\t}\n\t}, [ value, previousValue, presetType, showCustomValueControl ] );\n\n\tconst showCustomValueInSelectList =\n\t\t! showRangeControl &&\n\t\t! showCustomValueControl &&\n\t\tvalue !== undefined &&\n\t\t( ! isValuePreset( value, presetType ) ||\n\t\t\t( isValuePreset( value, presetType ) && isMixed ) );\n\n\tlet selectListOptions = presets;\n\tif ( showCustomValueInSelectList ) {\n\t\tselectListOptions = [\n\t\t\t...presets,\n\t\t\t{\n\t\t\t\tname: ! isMixed\n\t\t\t\t\t? // translators: %s: A custom measurement, e.g. 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 = selectListOptions.length - 1;\n\t} else if ( ! isMixed ) {\n\t\tcurrentValue = ! showCustomValueControl\n\t\t\t? getSliderValueFromPreset( value, presets, presetType )\n\t\t\t: getCustomValueFromPreset( value, presets, presetType );\n\t}\n\n\tconst options = selectListOptions.map( ( size, index ) => ( {\n\t\tkey: index,\n\t\tname: size.name,\n\t} ) );\n\n\tconst resolvedPresetValue = isValuePreset( value, presetType )\n\t\t? getCustomValueFromPreset( value, presets, presetType )\n\t\t: value;\n\n\tconst [ parsedQuantity, parsedUnit ] =\n\t\tparseQuantityAndUnitFromRawValue( resolvedPresetValue );\n\n\tconst computedUnit = parsedUnit || selectedUnit || 'px';\n\n\t// Get step and max from units prop, falling back to customValueSettings\n\tconst unitConfig = units?.find( ( item ) => item.value === computedUnit );\n\tconst step =\n\t\tunitConfig?.step ?? customValueSettings[ computedUnit ]?.steps ?? 0.1;\n\tconst max =\n\t\tunitConfig?.max ?? customValueSettings[ computedUnit ]?.max ?? 10;\n\n\tconst handleCustomValueChange = ( newValue ) => {\n\t\tconst isNumeric = ! isNaN( parseFloat( newValue ) );\n\t\tconst newCustomValue = isNumeric ? newValue : undefined;\n\n\t\tif ( newCustomValue !== undefined ) {\n\t\t\tonChange( newCustomValue );\n\t\t}\n\t};\n\tconst handleCustomValueSliderChange = ( next ) => {\n\t\tonChange( [ next, computedUnit ].join( '' ) );\n\t};\n\tconst customTooltipContent = ( newValue ) =>\n\t\tvalue === undefined ? undefined : presets[ newValue ]?.name;\n\n\tconst getNewPresetValue = ( next, controlType ) => {\n\t\tconst newValue = parseInt( next, 10 );\n\n\t\tif ( controlType === 'selectList' ) {\n\t\t\tif ( newValue === 0 && presets[ 0 ]?.slug === '0' ) {\n\t\t\t\treturn '0';\n\t\t\t}\n\t\t\tif ( newValue === 0 ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t} else if ( newValue === 0 ) {\n\t\t\treturn '0';\n\t\t}\n\t\treturn `var:preset|${ presetType }|${ presets[ next ]?.slug }`;\n\t};\n\n\treturn (\n\t\t<HStack\n\t\t\tclassName={ `preset-input-control__wrapper ${ className }__wrapper` }\n\t\t>\n\t\t\t{ icon && (\n\t\t\t\t<Icon\n\t\t\t\t\tclassName=\"preset-input-control__icon\"\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tsize={ ICON_SIZE }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ( ! hasPresets || showCustomValueControl ) && (\n\t\t\t\t<CustomValueControls\n\t\t\t\t\tallowNegativeOnDrag={ allowNegativeOnDrag }\n\t\t\t\t\tariaLabel={ ariaLabel }\n\t\t\t\t\tallPlaceholder={ allPlaceholder }\n\t\t\t\t\tminValue={ minValue }\n\t\t\t\t\tparsedQuantity={ parsedQuantity }\n\t\t\t\t\tcomputedUnit={ computedUnit }\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tisMixed={ isMixed }\n\t\t\t\t\tstep={ step }\n\t\t\t\t\tmax={ max }\n\t\t\t\t\tshowTooltip={ showTooltip }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tminimumCustomValue={ minimumCustomValue }\n\t\t\t\t\tonCustomValueChange={ handleCustomValueChange }\n\t\t\t\t\tonCustomValueSliderChange={ handleCustomValueSliderChange }\n\t\t\t\t\tonUnitChange={ onUnitChange }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tsetMinValue={ setMinValue }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<RangeControl\n\t\t\t\t\taria-valuenow={ currentValue }\n\t\t\t\t\taria-valuetext={ presets[ currentValue ]?.name }\n\t\t\t\t\tclassName=\"preset-input-control__preset-range\"\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tinitialPosition={ 0 }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\tmax={ presets.length - 1 }\n\t\t\t\t\tmarks={ marks }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\tonChange( getNewPresetValue( newValue ) )\n\t\t\t\t\t}\n\t\t\t\t\tonFocus={ onMouseOver }\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\tconst nearStart = event?.nativeEvent?.offsetX < 35;\n\t\t\t\t\t\tif ( nearStart && value === undefined ) {\n\t\t\t\t\t\t\tonChange( '0' );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\trenderTooltipContent={ customTooltipContent }\n\t\t\t\t\tstep={ 1 }\n\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && ! showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<CustomSelectControl\n\t\t\t\t\tclassName=\"preset-input-control__custom-select-control\"\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\tonChange={ ( selection ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tshowCustomValueInSelectList &&\n\t\t\t\t\t\t\tselection.selectedItem.key === options.length - 1\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tsetShowCustomValueControl( true );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tgetNewPresetValue(\n\t\t\t\t\t\t\t\t\tselection.selectedItem.key,\n\t\t\t\t\t\t\t\t\t'selectList'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\tvalue={\n\t\t\t\t\t\t// passing empty string as a fallback to continue using the\n\t\t\t\t\t\t// component in controlled mode\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) || ''\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && ! disableCustomValues && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"preset-input-control__custom-toggle\"\n\t\t\t\t\ticon={ settings }\n\t\t\t\t\ticonSize={ ICON_SIZE }\n\t\t\t\t\tisPressed={ showCustomValueControl }\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tshowCustomValueControl\n\t\t\t\t\t\t\t? __( 'Use preset' )\n\t\t\t\t\t\t\t: __( 'Set custom value' )\n\t\t\t\t\t}\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\tsize=\"small\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t</HStack>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAOO;AACP,qBAA4B;AAC5B,kBAA4B;AAC5B,mBAAyB;AACzB,qBAA6C;AAK7C,uBAIO;AACP,mBAKO;AACP,mCAAgC;AA0K9B;AA3Ia,SAAR,mBAAqC;AAAA,EAC3C,sBAAsB;AAAA,EACtB;AAAA,EACA,WAAW;AAAA,EACX,sBAAsB;A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YACP,OAAQ;AAAA,YACR,gBAAiB;AAAA,YACjB,uBAAqB;AAAA;AAAA,QACtB;AAAA,QAEC,cAAc,CAAE,oBAAoB,CAAE,0BACvC;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,qBAAmB;AAAA,YACnB,OAAQ;AAAA,YACR,QAAS;AAAA,YACT,UAAW,CAAE,cAAe;AAC3B,kBACC,+BACA,UAAU,aAAa,QAAQ,QAAQ,SAAS,GAC/C;AACD,0CAA2B,IAAK;AAAA,cACjC,OAAO;AACN;AAAA,kBACC;AAAA,oBACC,UAAU,aAAa;AAAA,oBACvB;AAAA,kBACD;AAAA,gBACD;AAAA,cACD;AAAA,YACD;AAAA,YACA,SAAU;AAAA,YACV;AAAA,YACA;AAAA,YACA;AAAA,YACA,MAAK;AAAA,YACL;AAAA;AAAA;AAAA,cAGC,QAAQ;AAAA,gBACP,CAAE,WAAY,OAAO,QAAQ;AAAA,cAC9B,KAAK;AAAA;AAAA;AAAA,QAEP;AAAA,QAEC,cAAc,CAAE,uBACjB;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,MAAO;AAAA,YACP,UAAW;AAAA,YACX,WAAY;AAAA,YACZ,OACC,6BACG,gBAAI,YAAa,QACjB,gBAAI,kBAAmB;AAAA,YAE3B,SAAU,MAAM;AACf,wCAA2B,CAAE,sBAAuB;AAAA,YACrD;AAAA,YACA,MAAK;AAAA;AAAA,QACN;AAAA;AAAA;AAAA,EAEF;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCustomSelectControl,\n\tIcon,\n\tRangeControl,\n\t__experimentalHStack as HStack,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { usePrevious } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { settings } from '@wordpress/icons';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tCUSTOM_VALUE_SETTINGS,\n\tICON_SIZE,\n\tRANGE_CONTROL_MAX_SIZE,\n} from './constants';\nimport {\n\tgetCustomValueFromPreset,\n\tgetPresetValueFromCustomValue,\n\tgetSliderValueFromPreset,\n\tisValuePreset,\n} from './utils';\nimport CustomValueControls from './custom-value-controls';\n\n/**\n * PresetInputControl component for selecting preset values or entering custom values.\n *\n * Displays preset values as either a slider (for <= 8 presets) or a select dropdown.\n * Allows toggling to custom value mode with a UnitControl and RangeControl.\n * Handles unit tracking and conversion between preset and custom values.\n *\n * @param {Object} props Component props.\n * @param {boolean} props.allowNegativeOnDrag Whether to allow negative values during drag operations.\n * @param {string} props.ariaLabel Accessible label for the control.\n * @param {string} props.className Optional CSS class name.\n * @param {Object} props.customValueSettings Optional custom value settings for max/steps per unit.\n * @param {boolean} props.disableCustomValues Whether to disable custom value input.\n * @param {Object} props.icon Icon to display alongside the control.\n * @param {boolean} props.isMixed Whether the current value is mixed (multiple values).\n * @param {number} props.minimumCustomValue Minimum allowed custom value.\n * @param {Function} props.onChange Callback when value changes.\n * @param {Function} props.onMouseOut Callback for mouse out events.\n * @param {Function} props.onMouseOver Callback for mouse over events.\n * @param {Function} props.onUnitChange Callback when unit changes.\n * @param {Array} props.presets Array of preset objects with name, slug, and size.\n * @param {string} props.presetType Type of preset (e.g., 'spacing', 'border-radius').\n * @param {string} props.selectedUnit Currently selected unit (e.g., 'px', 'em').\n * @param {boolean} props.showTooltip Whether to show tooltip on custom UnitControl.\n * @param {Array} props.units Array of available unit objects (can include max and step).\n * @param {string} props.value Current value (preset or custom).\n *\n * @return {Element} The PresetInputControl component.\n */\nexport default function PresetInputControl( {\n\tallowNegativeOnDrag = false,\n\tariaLabel,\n\tclassName: classNameProp,\n\tcustomValueSettings = CUSTOM_VALUE_SETTINGS,\n\tdisableCustomValues,\n\ticon,\n\tisMixed,\n\tvalue: valueProp,\n\tminimumCustomValue,\n\tonChange,\n\tonMouseOut,\n\tonMouseOver,\n\tonUnitChange,\n\tpresets = [],\n\tpresetType,\n\tselectedUnit,\n\tshowTooltip,\n\tunits,\n} ) {\n\tconst value = useMemo(\n\t\t() => getPresetValueFromCustomValue( valueProp, presets, presetType ),\n\t\t[ valueProp, presets, presetType ]\n\t);\n\n\tconst className = classNameProp ?? 'preset-input-control';\n\n\tconst marks = presets\n\t\t.slice( 1, presets.length - 1 )\n\t\t.map( ( _newValue, index ) => ( {\n\t\t\tvalue: index + 1,\n\t\t\tlabel: undefined,\n\t\t} ) );\n\tconst hasPresets = marks.length > 0;\n\tconst showRangeControl = presets.length <= RANGE_CONTROL_MAX_SIZE;\n\n\tconst allPlaceholder = isMixed ? __( 'Mixed' ) : null;\n\n\tconst [ minValue, setMinValue ] = useState( minimumCustomValue );\n\tconst [ showCustomValueControl, setShowCustomValueControl ] = useState(\n\t\t! disableCustomValues &&\n\t\t\tvalue !== undefined &&\n\t\t\t! isValuePreset( value, presetType )\n\t);\n\n\tlet currentValue = null;\n\n\tconst previousValue = usePrevious( value );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t!! value &&\n\t\t\tpreviousValue !== value &&\n\t\t\t! isValuePreset( value, presetType ) &&\n\t\t\tshowCustomValueControl !== true\n\t\t) {\n\t\t\tsetShowCustomValueControl( true );\n\t\t}\n\t}, [ value, previousValue, presetType, showCustomValueControl ] );\n\n\tconst showCustomValueInSelectList =\n\t\t! showRangeControl &&\n\t\t! showCustomValueControl &&\n\t\tvalue !== undefined &&\n\t\t( ! isValuePreset( value, presetType ) ||\n\t\t\t( isValuePreset( value, presetType ) && isMixed ) );\n\n\tlet selectListOptions = presets;\n\tif ( showCustomValueInSelectList ) {\n\t\tselectListOptions = [\n\t\t\t...presets,\n\t\t\t{\n\t\t\t\tname: ! isMixed\n\t\t\t\t\t? // translators: %s: A custom measurement, e.g. 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 = selectListOptions.length - 1;\n\t} else if ( ! isMixed ) {\n\t\tcurrentValue = ! showCustomValueControl\n\t\t\t? getSliderValueFromPreset( value, presets, presetType )\n\t\t\t: getCustomValueFromPreset( value, presets, presetType );\n\t}\n\n\tconst options = selectListOptions.map( ( size, index ) => ( {\n\t\tkey: index,\n\t\tname: size.name,\n\t} ) );\n\n\tconst resolvedPresetValue = isValuePreset( value, presetType )\n\t\t? getCustomValueFromPreset( value, presets, presetType )\n\t\t: value;\n\n\tconst [ parsedQuantity, parsedUnit ] =\n\t\tparseQuantityAndUnitFromRawValue( resolvedPresetValue );\n\n\tconst computedUnit = parsedUnit || selectedUnit || 'px';\n\n\t// Get step and max from units prop, falling back to customValueSettings\n\tconst unitConfig = units?.find( ( item ) => item.value === computedUnit );\n\tconst step =\n\t\tunitConfig?.step ?? customValueSettings[ computedUnit ]?.steps ?? 0.1;\n\tconst max =\n\t\tunitConfig?.max ?? customValueSettings[ computedUnit ]?.max ?? 10;\n\n\tconst handleCustomValueChange = ( newValue ) => {\n\t\t// Treat empty or undefined as an explicit clear and propagate undefined.\n\t\tif ( newValue === undefined || newValue === '' ) {\n\t\t\tonChange( undefined );\n\t\t\treturn;\n\t\t}\n\n\t\t// Ignore non-numeric intermediate input (e.g. just a unit).\n\t\tif ( isNaN( parseFloat( newValue ) ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tonChange( newValue );\n\t};\n\tconst handleCustomValueSliderChange = ( next ) => {\n\t\tonChange( [ next, computedUnit ].join( '' ) );\n\t};\n\tconst customTooltipContent = ( newValue ) =>\n\t\tvalue === undefined ? undefined : presets[ newValue ]?.name;\n\n\tconst getNewPresetValue = ( next, controlType ) => {\n\t\tconst newValue = parseInt( next, 10 );\n\n\t\tif ( controlType === 'selectList' ) {\n\t\t\tif ( newValue === 0 && presets[ 0 ]?.slug === '0' ) {\n\t\t\t\treturn '0';\n\t\t\t}\n\t\t\tif ( newValue === 0 ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t} else if ( newValue === 0 ) {\n\t\t\treturn '0';\n\t\t}\n\t\treturn `var:preset|${ presetType }|${ presets[ next ]?.slug }`;\n\t};\n\n\treturn (\n\t\t<HStack\n\t\t\tclassName={ `preset-input-control__wrapper ${ className }__wrapper` }\n\t\t>\n\t\t\t{ icon && (\n\t\t\t\t<Icon\n\t\t\t\t\tclassName=\"preset-input-control__icon\"\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tsize={ ICON_SIZE }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ( ! hasPresets || showCustomValueControl ) && (\n\t\t\t\t<CustomValueControls\n\t\t\t\t\tallowNegativeOnDrag={ allowNegativeOnDrag }\n\t\t\t\t\tariaLabel={ ariaLabel }\n\t\t\t\t\tallPlaceholder={ allPlaceholder }\n\t\t\t\t\tminValue={ minValue }\n\t\t\t\t\tparsedQuantity={ parsedQuantity }\n\t\t\t\t\tcomputedUnit={ computedUnit }\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tisMixed={ isMixed }\n\t\t\t\t\tstep={ step }\n\t\t\t\t\tmax={ max }\n\t\t\t\t\tshowTooltip={ showTooltip }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tminimumCustomValue={ minimumCustomValue }\n\t\t\t\t\tonCustomValueChange={ handleCustomValueChange }\n\t\t\t\t\tonCustomValueSliderChange={ handleCustomValueSliderChange }\n\t\t\t\t\tonUnitChange={ onUnitChange }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tsetMinValue={ setMinValue }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<RangeControl\n\t\t\t\t\taria-valuenow={ currentValue }\n\t\t\t\t\taria-valuetext={ presets[ currentValue ]?.name }\n\t\t\t\t\tclassName=\"preset-input-control__preset-range\"\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tinitialPosition={ 0 }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\tmax={ presets.length - 1 }\n\t\t\t\t\tmarks={ marks }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\tonChange( getNewPresetValue( newValue ) )\n\t\t\t\t\t}\n\t\t\t\t\tonFocus={ onMouseOver }\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\tconst nearStart = event?.nativeEvent?.offsetX < 35;\n\t\t\t\t\t\tif ( nearStart && value === undefined ) {\n\t\t\t\t\t\t\tonChange( '0' );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\trenderTooltipContent={ customTooltipContent }\n\t\t\t\t\tstep={ 1 }\n\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && ! showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<CustomSelectControl\n\t\t\t\t\tclassName=\"preset-input-control__custom-select-control\"\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\tonChange={ ( selection ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tshowCustomValueInSelectList &&\n\t\t\t\t\t\t\tselection.selectedItem.key === options.length - 1\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tsetShowCustomValueControl( true );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tgetNewPresetValue(\n\t\t\t\t\t\t\t\t\tselection.selectedItem.key,\n\t\t\t\t\t\t\t\t\t'selectList'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\tvalue={\n\t\t\t\t\t\t// passing empty string as a fallback to continue using the\n\t\t\t\t\t\t// component in controlled mode\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) || ''\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && ! disableCustomValues && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"preset-input-control__custom-toggle\"\n\t\t\t\t\ticon={ settings }\n\t\t\t\t\ticonSize={ ICON_SIZE }\n\t\t\t\t\tisPressed={ showCustomValueControl }\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tshowCustomValueControl\n\t\t\t\t\t\t\t? __( 'Use preset' )\n\t\t\t\t\t\t\t: __( 'Set custom value' )\n\t\t\t\t\t}\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\tsize=\"small\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t</HStack>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAOO;AACP,qBAA4B;AAC5B,kBAA4B;AAC5B,mBAAyB;AACzB,qBAA6C;AAK7C,uBAIO;AACP,mBAKO;AACP,mCAAgC;AAgL9B;AAjJa,SAAR,mBAAqC;AAAA,EAC3C,sBAAsB;AAAA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AAAA,YACA;AAAA,YACA,sBAAuB;AAAA,YACvB,MAAO;AAAA,YACP,OAAQ;AAAA,YACR,gBAAiB;AAAA,YACjB,uBAAqB;AAAA;AAAA,QACtB;AAAA,QAEC,cAAc,CAAE,oBAAoB,CAAE,0BACvC;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,qBAAmB;AAAA,YACnB,OAAQ;AAAA,YACR,QAAS;AAAA,YACT,UAAW,CAAE,cAAe;AAC3B,kBACC,+BACA,UAAU,aAAa,QAAQ,QAAQ,SAAS,GAC/C;AACD,0CAA2B,IAAK;AAAA,cACjC,OAAO;AACN;AAAA,kBACC;AAAA,oBACC,UAAU,aAAa;AAAA,oBACvB;AAAA,kBACD;AAAA,gBACD;AAAA,cACD;AAAA,YACD;AAAA,YACA,SAAU;AAAA,YACV;AAAA,YACA;AAAA,YACA;AAAA,YACA,MAAK;AAAA,YACL;AAAA;AAAA;AAAA,cAGC,QAAQ;AAAA,gBACP,CAAE,WAAY,OAAO,QAAQ;AAAA,cAC9B,KAAK;AAAA;AAAA;AAAA,QAEP;AAAA,QAEC,cAAc,CAAE,uBACjB;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,MAAO;AAAA,YACP,UAAW;AAAA,YACX,WAAY;AAAA,YACZ,OACC,6BACG,gBAAI,YAAa,QACjB,gBAAI,kBAAmB;AAAA,YAE3B,SAAU,MAAM;AACf,wCAA2B,CAAE,sBAAuB;AAAA,YACrD;AAAA,YACA,MAAK;AAAA;AAAA,QACN;AAAA;AAAA;AAAA,EAEF;AAEF;",
6
6
  "names": ["parseQuantityAndUnitFromRawValue", "HStack", "CustomValueControls"]
7
7
  }
@@ -53,6 +53,8 @@ var noop = () => {
53
53
  };
54
54
  var hasLoggedFallback = false;
55
55
  var isClientSideMediaEnabledCache = null;
56
+ var isHeicCanvasEnabledCache = null;
57
+ var HEIC_MIME_TYPES = ["image/heic", "image/heif"];
56
58
  function shouldEnableClientSideMediaProcessing() {
57
59
  if (isClientSideMediaEnabledCache !== null) {
58
60
  return isClientSideMediaEnabledCache;
@@ -79,6 +81,25 @@ function shouldEnableClientSideMediaProcessing() {
79
81
  isClientSideMediaEnabledCache = true;
80
82
  return true;
81
83
  }
84
+ function shouldEnableHeicCanvasProcessing() {
85
+ if (isHeicCanvasEnabledCache !== null) {
86
+ return isHeicCanvasEnabledCache;
87
+ }
88
+ if (shouldEnableClientSideMediaProcessing()) {
89
+ isHeicCanvasEnabledCache = false;
90
+ return false;
91
+ }
92
+ if (!window.__heicUploadSupport) {
93
+ isHeicCanvasEnabledCache = false;
94
+ return false;
95
+ }
96
+ if (typeof import_upload_media.isHeicCanvasSupported !== "function" || !(0, import_upload_media.isHeicCanvasSupported)()) {
97
+ isHeicCanvasEnabledCache = false;
98
+ return false;
99
+ }
100
+ isHeicCanvasEnabledCache = true;
101
+ return true;
102
+ }
82
103
  function mediaUpload(registry, settings, {
83
104
  allowedTypes,
84
105
  additionalData = {},
@@ -101,6 +122,58 @@ function mediaUpload(registry, settings, {
101
122
  allowedTypes
102
123
  });
103
124
  }
125
+ function heicMediaUpload(registry, settings, {
126
+ allowedTypes,
127
+ additionalData = {},
128
+ filesList,
129
+ onError = noop,
130
+ onFileChange,
131
+ onSuccess,
132
+ onBatchSuccess
133
+ }) {
134
+ const files = Array.from(filesList);
135
+ const heicFiles = files.filter(
136
+ (file) => HEIC_MIME_TYPES.includes(file.type)
137
+ );
138
+ const otherFiles = files.filter(
139
+ (file) => !HEIC_MIME_TYPES.includes(file.type)
140
+ );
141
+ const hasBothPaths = heicFiles.length > 0 && otherFiles.length > 0 && settings?.mediaUpload;
142
+ let pathsRemaining = hasBothPaths ? 2 : 1;
143
+ const coordinatedBatchSuccess = hasBothPaths ? () => {
144
+ pathsRemaining--;
145
+ if (pathsRemaining <= 0) {
146
+ onBatchSuccess?.();
147
+ }
148
+ } : onBatchSuccess;
149
+ if (heicFiles.length > 0) {
150
+ void registry.dispatch(import_upload_media.store).addItems({
151
+ files: heicFiles,
152
+ onChange: onFileChange,
153
+ onSuccess: (attachments) => {
154
+ settings?.[import_private_keys.mediaUploadOnSuccessKey]?.(attachments);
155
+ onSuccess?.(attachments);
156
+ },
157
+ onBatchSuccess: coordinatedBatchSuccess,
158
+ onError: (error) => onError(
159
+ typeof error === "string" ? error : error?.message ?? ""
160
+ ),
161
+ additionalData,
162
+ allowedTypes
163
+ });
164
+ }
165
+ if (otherFiles.length > 0 && settings?.mediaUpload) {
166
+ settings.mediaUpload({
167
+ allowedTypes,
168
+ additionalData,
169
+ filesList: otherFiles,
170
+ onError,
171
+ onFileChange,
172
+ onSuccess,
173
+ onBatchSuccess: coordinatedBatchSuccess
174
+ });
175
+ }
176
+ }
104
177
  function BlockSyncEffect(props) {
105
178
  (0, import_use_block_sync.default)(props);
106
179
  return null;
@@ -114,14 +187,13 @@ var ExperimentalBlockEditorProvider = (0, import_with_registry_provider.default)
114
187
  } = props;
115
188
  const mediaUploadSettings = (0, import_use_media_upload_settings.default)(_settings);
116
189
  const isClientSideMediaEnabled = shouldEnableClientSideMediaProcessing();
190
+ const isHeicCanvasEnabled = shouldEnableHeicCanvasProcessing();
191
+ const useUploadMediaPipeline = isClientSideMediaEnabled || isHeicCanvasEnabled;
117
192
  const isMediaUploadIntercepted = !!_settings?.mediaUpload?.__isMediaUploadInterceptor;
118
193
  const settings = (0, import_element.useMemo)(() => {
119
- if (isClientSideMediaEnabled && _settings?.mediaUpload && !isMediaUploadIntercepted) {
120
- const interceptor = mediaUpload.bind(
121
- null,
122
- registry,
123
- _settings
124
- );
194
+ if (useUploadMediaPipeline && _settings?.mediaUpload && !isMediaUploadIntercepted) {
195
+ const uploadFn = isClientSideMediaEnabled ? mediaUpload : heicMediaUpload;
196
+ const interceptor = uploadFn.bind(null, registry, _settings);
125
197
  interceptor.__isMediaUploadInterceptor = true;
126
198
  return {
127
199
  ..._settings,
@@ -132,6 +204,7 @@ var ExperimentalBlockEditorProvider = (0, import_with_registry_provider.default)
132
204
  }, [
133
205
  _settings,
134
206
  registry,
207
+ useUploadMediaPipeline,
135
208
  isClientSideMediaEnabled,
136
209
  isMediaUploadIntercepted
137
210
  ]);
@@ -181,7 +254,7 @@ var ExperimentalBlockEditorProvider = (0, import_with_registry_provider.default)
181
254
  ),
182
255
  children
183
256
  ] });
184
- if (isClientSideMediaEnabled && !isMediaUploadIntercepted) {
257
+ if (useUploadMediaPipeline && !isMediaUploadIntercepted) {
185
258
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
186
259
  import_upload_media.MediaUploadProvider,
187
260
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/provider/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { useEffect, useMemo, useRef } from '@wordpress/element';\nimport { SlotFillProvider } from '@wordpress/components';\nimport {\n\tMediaUploadProvider,\n\tstore as uploadStore,\n\tdetectClientSideMediaSupport,\n} from '@wordpress/upload-media';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport useBlockSync from './use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockRefsProvider } from './block-refs-provider';\nimport { unlock } from '../../lock-unlock';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport useMediaUploadSettings from './use-media-upload-settings';\nimport { mediaUploadOnSuccessKey } from '../../store/private-keys';\nimport { SelectionContext } from './selection-context';\n\n/** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */\n\nconst noop = () => {};\n\n/**\n * Flag to track if we've already logged the fallback message.\n */\nlet hasLoggedFallback = false;\n\n/**\n * Cached result of whether client-side media processing should be enabled.\n * This is computed once per session for efficiency and stability.\n */\nlet isClientSideMediaEnabledCache = null;\n\n/**\n * Checks if client-side media processing should be enabled.\n *\n * Returns true only if:\n * 1. The client-side media processing flag is enabled\n * 2. The browser supports WebAssembly, SharedArrayBuffer, cross-origin isolation, and CSP allows blob workers\n *\n * The result is cached for the session to ensure stability during React renders.\n *\n * @return {boolean} Whether client-side media processing should be enabled.\n */\nfunction shouldEnableClientSideMediaProcessing() {\n\t// Return cached result if available.\n\tif ( isClientSideMediaEnabledCache !== null ) {\n\t\treturn isClientSideMediaEnabledCache;\n\t}\n\n\t// Check if the client-side media processing flag is enabled first.\n\tif ( ! window.__clientSideMediaProcessing ) {\n\t\tisClientSideMediaEnabledCache = false;\n\t\treturn false;\n\t}\n\n\t// Safety check in case the import is unavailable.\n\tif ( typeof detectClientSideMediaSupport !== 'function' ) {\n\t\tisClientSideMediaEnabledCache = false;\n\t\treturn false;\n\t}\n\n\tconst detection = detectClientSideMediaSupport();\n\tif ( ! detection || ! detection.supported ) {\n\t\t// Only log once per session to avoid console spam.\n\t\tif ( ! hasLoggedFallback ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.info(\n\t\t\t\t`Client-side media processing unavailable: ${ detection.reason }. Using server-side processing.`\n\t\t\t);\n\t\t\thasLoggedFallback = true;\n\t\t}\n\t\tisClientSideMediaEnabledCache = false;\n\t\treturn false;\n\t}\n\n\tisClientSideMediaEnabledCache = true;\n\treturn true;\n}\n\n/**\n * Upload a media file when the file upload button is activated\n * or when adding a file to the editor via drag & drop.\n *\n * @param {WPDataRegistry} registry\n * @param {Object} settings Block editor settings.\n * @param {Object} $3 Parameters object passed to the function.\n * @param {Array} $3.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.\n * @param {Object} $3.additionalData Additional data to include in the request.\n * @param {Array<File>} $3.filesList List of files.\n * @param {Function} $3.onError Function called when an error happens.\n * @param {Function} $3.onFileChange Function called each time a file or a temporary representation of the file is available.\n * @param {Function} $3.onSuccess Function called once a file has completely finished uploading, including thumbnails.\n * @param {Function} $3.onBatchSuccess Function called once all files in a group have completely finished uploading, including thumbnails.\n */\nfunction mediaUpload(\n\tregistry,\n\tsettings,\n\t{\n\t\tallowedTypes,\n\t\tadditionalData = {},\n\t\tfilesList,\n\t\tonError = noop,\n\t\tonFileChange,\n\t\tonSuccess,\n\t\tonBatchSuccess,\n\t}\n) {\n\tvoid registry.dispatch( uploadStore ).addItems( {\n\t\tfiles: Array.from( filesList ),\n\t\tonChange: onFileChange,\n\t\tonSuccess: ( attachments ) => {\n\t\t\tsettings?.[ mediaUploadOnSuccessKey ]?.( attachments );\n\t\t\tonSuccess?.( attachments );\n\t\t},\n\t\tonBatchSuccess,\n\t\tonError: ( error ) =>\n\t\t\tonError( typeof error === 'string' ? error : error?.message ?? '' ),\n\t\tadditionalData,\n\t\tallowedTypes,\n\t} );\n}\n\n/**\n * Calls useBlockSync as a child of SelectionContext.Provider so that the\n * hook can read selection state from the context provided by this tree\n * rather than from a parent provider (which may not exist for the root).\n *\n * @param {Object} props Props forwarded to useBlockSync.\n */\nfunction BlockSyncEffect( props ) {\n\tuseBlockSync( props );\n\treturn null;\n}\n\nexport const ExperimentalBlockEditorProvider = withRegistryProvider(\n\t( props ) => {\n\t\tconst {\n\t\t\tsettings: _settings,\n\t\t\tregistry,\n\t\t\tstripExperimentalSettings = false,\n\t\t} = props;\n\n\t\tconst mediaUploadSettings = useMediaUploadSettings( _settings );\n\n\t\tconst isClientSideMediaEnabled =\n\t\t\tshouldEnableClientSideMediaProcessing();\n\n\t\t// Nested providers (e.g. from useBlockPreview) inherit settings\n\t\t// where mediaUpload has already been replaced with the\n\t\t// interceptor. Detect this so we skip the replacement and\n\t\t// MediaUploadProvider for them \u2014 see the longer comment below.\n\t\tconst isMediaUploadIntercepted =\n\t\t\t!! _settings?.mediaUpload?.__isMediaUploadInterceptor;\n\n\t\tconst settings = useMemo( () => {\n\t\t\tif (\n\t\t\t\tisClientSideMediaEnabled &&\n\t\t\t\t_settings?.mediaUpload &&\n\t\t\t\t! isMediaUploadIntercepted\n\t\t\t) {\n\t\t\t\t// Create a new object so that the original props.settings.mediaUpload is not modified.\n\t\t\t\tconst interceptor = mediaUpload.bind(\n\t\t\t\t\tnull,\n\t\t\t\t\tregistry,\n\t\t\t\t\t_settings\n\t\t\t\t);\n\t\t\t\tinterceptor.__isMediaUploadInterceptor = true;\n\t\t\t\treturn {\n\t\t\t\t\t..._settings,\n\t\t\t\t\tmediaUpload: interceptor,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn _settings;\n\t\t}, [\n\t\t\t_settings,\n\t\t\tregistry,\n\t\t\tisClientSideMediaEnabled,\n\t\t\tisMediaUploadIntercepted,\n\t\t] );\n\n\t\tconst { __experimentalUpdateSettings } = unlock(\n\t\t\tuseDispatch( blockEditorStore )\n\t\t);\n\t\tuseEffect( () => {\n\t\t\t__experimentalUpdateSettings(\n\t\t\t\t{\n\t\t\t\t\t...settings,\n\t\t\t\t\t__internalIsInitialized: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tstripExperimentalSettings,\n\t\t\t\t\treset: true,\n\t\t\t\t}\n\t\t\t);\n\t\t}, [\n\t\t\tsettings,\n\t\t\tstripExperimentalSettings,\n\t\t\t__experimentalUpdateSettings,\n\t\t] );\n\n\t\t// Store selection and onChangeSelection in refs and expose\n\t\t// stable getters/callers so that the context value is a\n\t\t// complete constant. This prevents re-rendering the entire\n\t\t// block tree (including async-rendered off-screen blocks)\n\t\t// when either value changes.\n\t\tconst selectionRef = useRef( props.selection );\n\t\tselectionRef.current = props.selection;\n\t\tconst onChangeSelectionRef = useRef( props.onChangeSelection ?? noop );\n\t\tonChangeSelectionRef.current = props.onChangeSelection ?? noop;\n\n\t\tconst selectionContextValue = useMemo(\n\t\t\t() => ( {\n\t\t\t\tgetSelection: () => selectionRef.current,\n\t\t\t\tonChangeSelection: ( ...args ) =>\n\t\t\t\t\tonChangeSelectionRef.current( ...args ),\n\t\t\t} ),\n\t\t\t[]\n\t\t);\n\n\t\tconst children = (\n\t\t\t<SlotFillProvider passthrough>\n\t\t\t\t{ ! settings?.isPreviewMode && <KeyboardShortcuts.Register /> }\n\t\t\t\t<BlockRefsProvider>{ props.children }</BlockRefsProvider>\n\t\t\t</SlotFillProvider>\n\t\t);\n\n\t\tconst content = (\n\t\t\t<SelectionContext.Provider value={ selectionContextValue }>\n\t\t\t\t<BlockSyncEffect\n\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\tvalue={ props.value }\n\t\t\t\t\tonChange={ props.onChange }\n\t\t\t\t\tonInput={ props.onInput }\n\t\t\t\t/>\n\t\t\t\t{ children }\n\t\t\t</SelectionContext.Provider>\n\t\t);\n\n\t\t// MediaUploadProvider writes the mediaUpload function from\n\t\t// _settings into the shared upload-media store so the store can\n\t\t// hand files off to the server. useMediaUploadSettings extracts\n\t\t// mediaUpload from the original _settings prop \u2014 *before* the\n\t\t// interceptor replacement above \u2014 so the store receives the\n\t\t// real server-side upload function.\n\t\t//\n\t\t// Only the first (outermost) provider should do this.\n\t\t// Nested providers (e.g. from useBlockPreview in\n\t\t// core/post-template) inherit settings that already contain\n\t\t// the interceptor, so their MediaUploadProvider would\n\t\t// overwrite the store's server-side function with the\n\t\t// interceptor, causing uploads to loop instead of reaching\n\t\t// the server.\n\t\tif ( isClientSideMediaEnabled && ! isMediaUploadIntercepted ) {\n\t\t\treturn (\n\t\t\t\t<MediaUploadProvider\n\t\t\t\t\tsettings={ mediaUploadSettings }\n\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t>\n\t\t\t\t\t{ content }\n\t\t\t\t</MediaUploadProvider>\n\t\t\t);\n\t\t}\n\n\t\treturn content;\n\t}\n);\n\nexport const BlockEditorProvider = ( props ) => {\n\treturn (\n\t\t<ExperimentalBlockEditorProvider { ...props } stripExperimentalSettings>\n\t\t\t{ props.children }\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n};\n\nexport default BlockEditorProvider;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,qBAA2C;AAC3C,wBAAiC;AACjC,0BAIO;AAKP,oCAAiC;AACjC,4BAAyB;AACzB,mBAA0C;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A,MAC3D,4CAAC,gDAAoB,gBAAM,UAAU;AAAA,OACtC;AAGD,UAAM,UACL,6CAAC,0CAAiB,UAAjB,EAA0B,OAAQ,uBAClC;AAAA;AAAA,QAAC;AAAA;AAAA,UACA,UAAW,MAAM;AAAA,UACjB,OAAQ,MAAM;AAAA,UACd,UAAW,MAAM;AAAA,UACjB,SAAU,MAAM;AAAA;AAAA,MACjB;AAAA,MACE;AAAA,OACH;AAiBD,QAAK,4BAA4B,CAAE,0BAA2B;AAC7D,aACC;AAAA,QAAC;AAAA;AAAA,UACA,UAAW;AAAA,UACX,gBAAiB;AAAA,UAEf;AAAA;AAAA,MACH;AAAA,IAEF;AAEA,WAAO;AAAA,EACR;AACD;AAEO,IAAM,sBAAsB,CAAE,UAAW;AAC/C,SACC,4CAAC,mCAAkC,GAAG,OAAQ,2BAAyB,MACpE,gBAAM,UACT;AAEF;AAEA,IAAO,mBAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { useEffect, useMemo, useRef } from '@wordpress/element';\nimport { SlotFillProvider } from '@wordpress/components';\nimport {\n\tMediaUploadProvider,\n\tstore as uploadStore,\n\tdetectClientSideMediaSupport,\n\tisHeicCanvasSupported,\n} from '@wordpress/upload-media';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport useBlockSync from './use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockRefsProvider } from './block-refs-provider';\nimport { unlock } from '../../lock-unlock';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport useMediaUploadSettings from './use-media-upload-settings';\nimport { mediaUploadOnSuccessKey } from '../../store/private-keys';\nimport { SelectionContext } from './selection-context';\n\n/** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */\n\nconst noop = () => {};\n\n/**\n * Flag to track if we've already logged the fallback message.\n */\nlet hasLoggedFallback = false;\n\n/**\n * Cached result of whether client-side media processing should be enabled.\n * This is computed once per session for efficiency and stability.\n */\nlet isClientSideMediaEnabledCache = null;\n\n/**\n * Cached result of whether HEIC-only canvas processing should be enabled.\n */\nlet isHeicCanvasEnabledCache = null;\n\n/**\n * HEIC MIME types that should be routed through the upload-media pipeline\n * when in HEIC-only mode.\n */\nconst HEIC_MIME_TYPES = [ 'image/heic', 'image/heif' ];\n\n/**\n * Checks if client-side media processing should be enabled.\n *\n * Returns true only if:\n * 1. The client-side media processing flag is enabled\n * 2. The browser supports WebAssembly, SharedArrayBuffer, cross-origin isolation, and CSP allows blob workers\n *\n * The result is cached for the session to ensure stability during React renders.\n *\n * @return {boolean} Whether client-side media processing should be enabled.\n */\nfunction shouldEnableClientSideMediaProcessing() {\n\t// Return cached result if available.\n\tif ( isClientSideMediaEnabledCache !== null ) {\n\t\treturn isClientSideMediaEnabledCache;\n\t}\n\n\t// Check if the client-side media processing flag is enabled first.\n\tif ( ! window.__clientSideMediaProcessing ) {\n\t\tisClientSideMediaEnabledCache = false;\n\t\treturn false;\n\t}\n\n\t// Safety check in case the import is unavailable.\n\tif ( typeof detectClientSideMediaSupport !== 'function' ) {\n\t\tisClientSideMediaEnabledCache = false;\n\t\treturn false;\n\t}\n\n\tconst detection = detectClientSideMediaSupport();\n\tif ( ! detection || ! detection.supported ) {\n\t\t// Only log once per session to avoid console spam.\n\t\tif ( ! hasLoggedFallback ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.info(\n\t\t\t\t`Client-side media processing unavailable: ${ detection.reason }. Using server-side processing.`\n\t\t\t);\n\t\t\thasLoggedFallback = true;\n\t\t}\n\t\tisClientSideMediaEnabledCache = false;\n\t\treturn false;\n\t}\n\n\tisClientSideMediaEnabledCache = true;\n\treturn true;\n}\n\n/**\n * Checks if HEIC-only canvas processing should be enabled.\n *\n * Returns true when:\n * 1. Full client-side processing is NOT available (otherwise it handles HEIC already)\n * 2. The server has set the __heicUploadSupport flag\n * 3. The browser supports createImageBitmap + OffscreenCanvas (e.g. Safari)\n *\n * @return {boolean} Whether HEIC-only canvas processing should be enabled.\n */\nfunction shouldEnableHeicCanvasProcessing() {\n\tif ( isHeicCanvasEnabledCache !== null ) {\n\t\treturn isHeicCanvasEnabledCache;\n\t}\n\n\t// If full client-side processing is enabled, it already handles HEIC.\n\tif ( shouldEnableClientSideMediaProcessing() ) {\n\t\tisHeicCanvasEnabledCache = false;\n\t\treturn false;\n\t}\n\n\tif ( ! window.__heicUploadSupport ) {\n\t\tisHeicCanvasEnabledCache = false;\n\t\treturn false;\n\t}\n\n\tif (\n\t\ttypeof isHeicCanvasSupported !== 'function' ||\n\t\t! isHeicCanvasSupported()\n\t) {\n\t\tisHeicCanvasEnabledCache = false;\n\t\treturn false;\n\t}\n\n\tisHeicCanvasEnabledCache = true;\n\treturn true;\n}\n\n/**\n * Upload a media file when the file upload button is activated\n * or when adding a file to the editor via drag & drop.\n *\n * @param {WPDataRegistry} registry\n * @param {Object} settings Block editor settings.\n * @param {Object} $3 Parameters object passed to the function.\n * @param {Array} $3.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.\n * @param {Object} $3.additionalData Additional data to include in the request.\n * @param {Array<File>} $3.filesList List of files.\n * @param {Function} $3.onError Function called when an error happens.\n * @param {Function} $3.onFileChange Function called each time a file or a temporary representation of the file is available.\n * @param {Function} $3.onSuccess Function called once a file has completely finished uploading, including thumbnails.\n * @param {Function} $3.onBatchSuccess Function called once all files in a group have completely finished uploading, including thumbnails.\n */\nfunction mediaUpload(\n\tregistry,\n\tsettings,\n\t{\n\t\tallowedTypes,\n\t\tadditionalData = {},\n\t\tfilesList,\n\t\tonError = noop,\n\t\tonFileChange,\n\t\tonSuccess,\n\t\tonBatchSuccess,\n\t}\n) {\n\tvoid registry.dispatch( uploadStore ).addItems( {\n\t\tfiles: Array.from( filesList ),\n\t\tonChange: onFileChange,\n\t\tonSuccess: ( attachments ) => {\n\t\t\tsettings?.[ mediaUploadOnSuccessKey ]?.( attachments );\n\t\t\tonSuccess?.( attachments );\n\t\t},\n\t\tonBatchSuccess,\n\t\tonError: ( error ) =>\n\t\t\tonError( typeof error === 'string' ? error : error?.message ?? '' ),\n\t\tadditionalData,\n\t\tallowedTypes,\n\t} );\n}\n\n/**\n * Upload interceptor for HEIC-only mode.\n *\n * Routes HEIC files through the upload-media pipeline for canvas-based\n * conversion, while passing non-HEIC files to the original mediaUpload\n * function for standard server-side processing.\n *\n * @param {WPDataRegistry} registry\n * @param {Object} settings Block editor settings.\n * @param {Object} $3 Parameters object passed to the function.\n * @param {Array} $3.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.\n * @param {Object} $3.additionalData Additional data to include in the request.\n * @param {Array<File>} $3.filesList List of files.\n * @param {Function} $3.onError Function called when an error happens.\n * @param {Function} $3.onFileChange Function called each time a file or a temporary representation of the file is available.\n * @param {Function} $3.onSuccess Function called once a file has completely finished uploading, including thumbnails.\n * @param {Function} $3.onBatchSuccess Function called once all files in a group have completely finished uploading, including thumbnails.\n */\nfunction heicMediaUpload(\n\tregistry,\n\tsettings,\n\t{\n\t\tallowedTypes,\n\t\tadditionalData = {},\n\t\tfilesList,\n\t\tonError = noop,\n\t\tonFileChange,\n\t\tonSuccess,\n\t\tonBatchSuccess,\n\t}\n) {\n\tconst files = Array.from( filesList );\n\tconst heicFiles = files.filter( ( file ) =>\n\t\tHEIC_MIME_TYPES.includes( file.type )\n\t);\n\tconst otherFiles = files.filter(\n\t\t( file ) => ! HEIC_MIME_TYPES.includes( file.type )\n\t);\n\n\t// When the batch contains both HEIC and non-HEIC files, coordinate\n\t// onBatchSuccess so it fires only after *both* paths have completed.\n\tconst hasBothPaths =\n\t\theicFiles.length > 0 && otherFiles.length > 0 && settings?.mediaUpload;\n\tlet pathsRemaining = hasBothPaths ? 2 : 1;\n\tconst coordinatedBatchSuccess = hasBothPaths\n\t\t? () => {\n\t\t\t\tpathsRemaining--;\n\t\t\t\tif ( pathsRemaining <= 0 ) {\n\t\t\t\t\tonBatchSuccess?.();\n\t\t\t\t}\n\t\t }\n\t\t: onBatchSuccess;\n\n\t// Route HEIC files through the upload-media pipeline.\n\tif ( heicFiles.length > 0 ) {\n\t\tvoid registry.dispatch( uploadStore ).addItems( {\n\t\t\tfiles: heicFiles,\n\t\t\tonChange: onFileChange,\n\t\t\tonSuccess: ( attachments ) => {\n\t\t\t\tsettings?.[ mediaUploadOnSuccessKey ]?.( attachments );\n\t\t\t\tonSuccess?.( attachments );\n\t\t\t},\n\t\t\tonBatchSuccess: coordinatedBatchSuccess,\n\t\t\tonError: ( error ) =>\n\t\t\t\tonError(\n\t\t\t\t\ttypeof error === 'string' ? error : error?.message ?? ''\n\t\t\t\t),\n\t\t\tadditionalData,\n\t\t\tallowedTypes,\n\t\t} );\n\t}\n\n\t// Pass non-HEIC files to the original server-side upload function.\n\tif ( otherFiles.length > 0 && settings?.mediaUpload ) {\n\t\tsettings.mediaUpload( {\n\t\t\tallowedTypes,\n\t\t\tadditionalData,\n\t\t\tfilesList: otherFiles,\n\t\t\tonError,\n\t\t\tonFileChange,\n\t\t\tonSuccess,\n\t\t\tonBatchSuccess: coordinatedBatchSuccess,\n\t\t} );\n\t}\n}\n\n/**\n * Calls useBlockSync as a child of SelectionContext.Provider so that the\n * hook can read selection state from the context provided by this tree\n * rather than from a parent provider (which may not exist for the root).\n *\n * @param {Object} props Props forwarded to useBlockSync.\n */\nfunction BlockSyncEffect( props ) {\n\tuseBlockSync( props );\n\treturn null;\n}\n\nexport const ExperimentalBlockEditorProvider = withRegistryProvider(\n\t( props ) => {\n\t\tconst {\n\t\t\tsettings: _settings,\n\t\t\tregistry,\n\t\t\tstripExperimentalSettings = false,\n\t\t} = props;\n\n\t\tconst mediaUploadSettings = useMediaUploadSettings( _settings );\n\n\t\tconst isClientSideMediaEnabled =\n\t\t\tshouldEnableClientSideMediaProcessing();\n\t\tconst isHeicCanvasEnabled = shouldEnableHeicCanvasProcessing();\n\t\tconst useUploadMediaPipeline =\n\t\t\tisClientSideMediaEnabled || isHeicCanvasEnabled;\n\n\t\t// Nested providers (e.g. from useBlockPreview) inherit settings\n\t\t// where mediaUpload has already been replaced with the\n\t\t// interceptor. Detect this so we skip the replacement and\n\t\t// MediaUploadProvider for them \u2014 see the longer comment below.\n\t\tconst isMediaUploadIntercepted =\n\t\t\t!! _settings?.mediaUpload?.__isMediaUploadInterceptor;\n\n\t\tconst settings = useMemo( () => {\n\t\t\tif (\n\t\t\t\tuseUploadMediaPipeline &&\n\t\t\t\t_settings?.mediaUpload &&\n\t\t\t\t! isMediaUploadIntercepted\n\t\t\t) {\n\t\t\t\t// Choose the right interceptor:\n\t\t\t\t// - Full mode: all uploads go through upload-media pipeline.\n\t\t\t\t// - HEIC-only mode: only HEIC files go through, rest use legacy path.\n\t\t\t\tconst uploadFn = isClientSideMediaEnabled\n\t\t\t\t\t? mediaUpload\n\t\t\t\t\t: heicMediaUpload;\n\t\t\t\tconst interceptor = uploadFn.bind( null, registry, _settings );\n\t\t\t\tinterceptor.__isMediaUploadInterceptor = true;\n\t\t\t\treturn {\n\t\t\t\t\t..._settings,\n\t\t\t\t\tmediaUpload: interceptor,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn _settings;\n\t\t}, [\n\t\t\t_settings,\n\t\t\tregistry,\n\t\t\tuseUploadMediaPipeline,\n\t\t\tisClientSideMediaEnabled,\n\t\t\tisMediaUploadIntercepted,\n\t\t] );\n\n\t\tconst { __experimentalUpdateSettings } = unlock(\n\t\t\tuseDispatch( blockEditorStore )\n\t\t);\n\t\tuseEffect( () => {\n\t\t\t__experimentalUpdateSettings(\n\t\t\t\t{\n\t\t\t\t\t...settings,\n\t\t\t\t\t__internalIsInitialized: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tstripExperimentalSettings,\n\t\t\t\t\treset: true,\n\t\t\t\t}\n\t\t\t);\n\t\t}, [\n\t\t\tsettings,\n\t\t\tstripExperimentalSettings,\n\t\t\t__experimentalUpdateSettings,\n\t\t] );\n\n\t\t// Store selection and onChangeSelection in refs and expose\n\t\t// stable getters/callers so that the context value is a\n\t\t// complete constant. This prevents re-rendering the entire\n\t\t// block tree (including async-rendered off-screen blocks)\n\t\t// when either value changes.\n\t\tconst selectionRef = useRef( props.selection );\n\t\tselectionRef.current = props.selection;\n\t\tconst onChangeSelectionRef = useRef( props.onChangeSelection ?? noop );\n\t\tonChangeSelectionRef.current = props.onChangeSelection ?? noop;\n\n\t\tconst selectionContextValue = useMemo(\n\t\t\t() => ( {\n\t\t\t\tgetSelection: () => selectionRef.current,\n\t\t\t\tonChangeSelection: ( ...args ) =>\n\t\t\t\t\tonChangeSelectionRef.current( ...args ),\n\t\t\t} ),\n\t\t\t[]\n\t\t);\n\n\t\tconst children = (\n\t\t\t<SlotFillProvider passthrough>\n\t\t\t\t{ ! settings?.isPreviewMode && <KeyboardShortcuts.Register /> }\n\t\t\t\t<BlockRefsProvider>{ props.children }</BlockRefsProvider>\n\t\t\t</SlotFillProvider>\n\t\t);\n\n\t\tconst content = (\n\t\t\t<SelectionContext.Provider value={ selectionContextValue }>\n\t\t\t\t<BlockSyncEffect\n\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\tvalue={ props.value }\n\t\t\t\t\tonChange={ props.onChange }\n\t\t\t\t\tonInput={ props.onInput }\n\t\t\t\t/>\n\t\t\t\t{ children }\n\t\t\t</SelectionContext.Provider>\n\t\t);\n\n\t\t// MediaUploadProvider writes the mediaUpload function from\n\t\t// _settings into the shared upload-media store so the store can\n\t\t// hand files off to the server. useMediaUploadSettings extracts\n\t\t// mediaUpload from the original _settings prop \u2014 *before* the\n\t\t// interceptor replacement above \u2014 so the store receives the\n\t\t// real server-side upload function.\n\t\t//\n\t\t// Only the first (outermost) provider should do this.\n\t\t// Nested providers (e.g. from useBlockPreview in\n\t\t// core/post-template) inherit settings that already contain\n\t\t// the interceptor, so their MediaUploadProvider would\n\t\t// overwrite the store's server-side function with the\n\t\t// interceptor, causing uploads to loop instead of reaching\n\t\t// the server.\n\t\tif ( useUploadMediaPipeline && ! isMediaUploadIntercepted ) {\n\t\t\treturn (\n\t\t\t\t<MediaUploadProvider\n\t\t\t\t\tsettings={ mediaUploadSettings }\n\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t>\n\t\t\t\t\t{ content }\n\t\t\t\t</MediaUploadProvider>\n\t\t\t);\n\t\t}\n\n\t\treturn content;\n\t}\n);\n\nexport const BlockEditorProvider = ( props ) => {\n\treturn (\n\t\t<ExperimentalBlockEditorProvider { ...props } stripExperimentalSettings>\n\t\t\t{ props.children }\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n};\n\nexport default BlockEditorProvider;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,qBAA2C;AAC3C,wBAAiC;AACjC,0BAKO;AAKP,oCAAiC;AACjC,4BAAyB;AACzB,mBAA0C;AAC1C,iCAAkC;AAClC,yBAAuB;AACvB,gCAA8B;AAC9B,uCAAmC;AACnC,0BAAwC;AACxC,+BAAiC;AAyV9B;AArVH,IAAM,OAAO,MAAM;AAAC;AAKpB,IAAI,oBAAoB;AAMxB,IAAI,gCAAgC;AAKpC,IAAI,2BAA2B;AAM/B,IAAM,kBAAkB,CAAE,cAAc,YAAa;AAarD,SAAS,wCAAwC;AAEhD,MAAK,kCAAkC,MAAO;AAC7C,WAAO;AAAA,EACR;AAGA,MAAK,CAAE,OAAO,6BAA8B;AAC3C,oCAAgC;AAChC,WAAO;AAAA,EACR;AAGA,MAAK,OAAO,qDAAiC,YAAa;AACzD,oCAAgC;AAChC,WAAO;AAAA,EACR;AAEA,QAAM,gBAAY,kDAA6B;AAC/C,MAAK,CAAE,aAAa,CAAE,UAAU,WAAY;AAE3C,QAAK,CAAE,mBAAoB;AAE1B,cAAQ;AAAA,QACP,6CAA8C,UAAU,MAAO;AAAA,MAChE;AACA,0BAAoB;AAAA,IACrB;AACA,oCAAgC;AAChC,WAAO;AAAA,EACR;AAEA,kC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AC;AAAA;AAAA,UACA,UAAW;AAAA,UACX,gBAAiB;AAAA,UAEf;AAAA;AAAA,MACH;AAAA,IAEF;AAEA,WAAO;AAAA,EACR;AACD;AAEO,IAAM,sBAAsB,CAAE,UAAW;AAC/C,SACC,4CAAC,mCAAkC,GAAG,OAAQ,2BAAyB,MACpE,gBAAM,UACT;AAEF;AAEA,IAAO,mBAAQ;",
6
6
  "names": ["uploadStore", "useBlockSync", "withRegistryProvider", "useMediaUploadSettings", "blockEditorStore", "KeyboardShortcuts"]
7
7
  }
@@ -24,7 +24,7 @@ __export(label_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(label_exports);
26
26
  var import_compose = require("@wordpress/compose");
27
- var import_components = require("@wordpress/components");
27
+ var import_ui = require("@wordpress/ui");
28
28
  var import_i18n = require("@wordpress/i18n");
29
29
  var import_jsx_runtime = require("react/jsx-runtime");
30
30
  function ResponsiveBlockControlLabel({
@@ -44,7 +44,14 @@ function ResponsiveBlockControlLabel({
44
44
  );
45
45
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
46
46
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-describedby": `rbc-desc-${instanceId}`, children: viewport.label }),
47
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.VisuallyHidden, { as: "span", id: `rbc-desc-${instanceId}`, children: accessibleLabel })
47
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
48
+ import_ui.VisuallyHidden,
49
+ {
50
+ id: `rbc-desc-${instanceId}`,
51
+ render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {}),
52
+ children: accessibleLabel
53
+ }
54
+ )
48
55
  ] });
49
56
  }
50
57
  //# sourceMappingURL=label.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/responsive-block-control/label.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/components';\nimport { _x, sprintf } from '@wordpress/i18n';\n\nexport default function ResponsiveBlockControlLabel( {\n\tproperty,\n\tviewport,\n\tdesc,\n} ) {\n\tconst instanceId = useInstanceId( ResponsiveBlockControlLabel );\n\tconst accessibleLabel =\n\t\tdesc ||\n\t\tsprintf(\n\t\t\t/* translators: 1: property name. 2: viewport name. */\n\t\t\t_x(\n\t\t\t\t'Controls the %1$s property for %2$s viewports.',\n\t\t\t\t'Text labelling a interface as controlling a given layout property (eg: margin) for a given screen size.'\n\t\t\t),\n\t\t\tproperty,\n\t\t\tviewport.label\n\t\t);\n\treturn (\n\t\t<>\n\t\t\t<span aria-describedby={ `rbc-desc-${ instanceId }` }>\n\t\t\t\t{ viewport.label }\n\t\t\t</span>\n\t\t\t<VisuallyHidden as=\"span\" id={ `rbc-desc-${ instanceId }` }>\n\t\t\t\t{ accessibleLabel }\n\t\t\t</VisuallyHidden>\n\t\t</>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA8B;AAC9B,wBAA+B;AAC/B,kBAA4B;AAoB1B;AAlBa,SAAR,4BAA8C;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,iBAAa,8BAAe,2BAA4B;AAC9D,QAAM,kBACL,YACA;AAAA;AAAA,QAEC;AAAA,MACC;AAAA,MACA;AAAA,IACD;AAAA,IACA;AAAA,IACA,SAAS;AAAA,EACV;AACD,SACC,4EACC;AAAA,gDAAC,UAAK,oBAAmB,YAAa,UAAW,IAC9C,mBAAS,OACZ;AAAA,IACA,4CAAC,oCAAe,IAAG,QAAO,IAAK,YAAa,UAAW,IACpD,2BACH;AAAA,KACD;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { _x, sprintf } from '@wordpress/i18n';\n\nexport default function ResponsiveBlockControlLabel( {\n\tproperty,\n\tviewport,\n\tdesc,\n} ) {\n\tconst instanceId = useInstanceId( ResponsiveBlockControlLabel );\n\tconst accessibleLabel =\n\t\tdesc ||\n\t\tsprintf(\n\t\t\t/* translators: 1: property name. 2: viewport name. */\n\t\t\t_x(\n\t\t\t\t'Controls the %1$s property for %2$s viewports.',\n\t\t\t\t'Text labelling a interface as controlling a given layout property (eg: margin) for a given screen size.'\n\t\t\t),\n\t\t\tproperty,\n\t\t\tviewport.label\n\t\t);\n\treturn (\n\t\t<>\n\t\t\t<span aria-describedby={ `rbc-desc-${ instanceId }` }>\n\t\t\t\t{ viewport.label }\n\t\t\t</span>\n\t\t\t<VisuallyHidden\n\t\t\t\tid={ `rbc-desc-${ instanceId }` }\n\t\t\t\trender={ <span /> }\n\t\t\t>\n\t\t\t\t{ accessibleLabel }\n\t\t\t</VisuallyHidden>\n\t\t</>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA8B;AAC9B,gBAA+B;AAC/B,kBAA4B;AAoB1B;AAlBa,SAAR,4BAA8C;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,iBAAa,8BAAe,2BAA4B;AAC9D,QAAM,kBACL,YACA;AAAA;AAAA,QAEC;AAAA,MACC;AAAA,MACA;AAAA,IACD;AAAA,IACA;AAAA,IACA,SAAS;AAAA,EACV;AACD,SACC,4EACC;AAAA,gDAAC,UAAK,oBAAmB,YAAa,UAAW,IAC9C,mBAAS,OACZ;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,IAAK,YAAa,UAAW;AAAA,QAC7B,QAAS,4CAAC,UAAK;AAAA,QAEb;AAAA;AAAA,IACH;AAAA,KACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/rich-text/event-listeners/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo, useRef, useInsertionEffect } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport beforeInputRules from './before-input-rules';\nimport inputRules from './input-rules';\nimport insertReplacementText from './insert-replacement-text';\nimport removeBrowserShortcuts from './remove-browser-shortcuts';\nimport shortcuts from './shortcuts';\nimport inputEvents from './input-events';\nimport undoAutomaticChange from './undo-automatic-change';\nimport pasteHandler from './paste-handler';\nimport _delete from './delete';\nimport enter from './enter';\nimport firefoxCompat from './firefox-compat';\n\nconst allEventListeners = [\n\tbeforeInputRules,\n\tinputRules,\n\tinsertReplacementText,\n\tremoveBrowserShortcuts,\n\tshortcuts,\n\tinputEvents,\n\tundoAutomaticChange,\n\tpasteHandler,\n\t_delete,\n\tenter,\n\tfirefoxCompat,\n];\n\nexport function useEventListeners( props ) {\n\tconst propsRef = useRef( props );\n\tuseInsertionEffect( () => {\n\t\tpropsRef.current = props;\n\t} );\n\tconst refEffects = useMemo(\n\t\t() => allEventListeners.map( ( refEffect ) => refEffect( propsRef ) ),\n\t\t[ propsRef ]\n\t);\n\n\treturn useRefEffect(\n\t\t( element ) => {\n\t\t\tif ( ! props.isSelected ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst cleanups = refEffects.map( ( effect ) => effect( element ) );\n\t\t\treturn () => {\n\t\t\t\tcleanups.forEach( ( cleanup ) => cleanup() );\n\t\t\t};\n\t\t},\n\t\t[ refEffects, props.isSelected ]\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAoD;AACpD,qBAA6B;AAK7B,gCAA6B;AAC7B,yBAAuB;AACvB,qCAAkC;AAClC,sCAAmC;AACnC,uBAAsB;AACtB,0BAAwB;AACxB,mCAAgC;AAChC,2BAAyB;AACzB,oBAAoB;AACpB,mBAAkB;AAClB,4BAA0B;AAE1B,IAAM,oBAAoB;AAAA,EACzB,0BAAAA;AAAA,EACA,mBAAAC;AAAA,EACA,+BAAAC;AAAA,EACA,gCAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,6BAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC;AAAA,EACA,sBAAAC;AACD;AAEO,SAAS,kBAAmB,OAAQ;AAC1C,QAAM,eAAW,uBAAQ,KAAM;AAC/B,yCAAoB,MAAM;AACzB,aAAS,UAAU;AAAA,EACpB,CAAE;AACF,QAAM,iBAAa;AAAA,IAClB,MAAM,kBAAkB,IAAK,CAAE,cAAe,UAAW,QAAS,CAAE;AAAA,IACpE,CAAE,QAAS;AAAA,EACZ;AAEA,aAAO;AAAA,IACN,CAAE,YAAa;AACd,UAAK,CAAE,MAAM,YAAa;AACzB;AAAA,MACD;AACA,YAAM,WAAW,WAAW,IAAK,CAAE,WAAY,OAAQ,OAAQ,CAAE;AACjE,aAAO,MAAM;AACZ,iBAAS,QAAS,CAAE,YAAa,QAAQ,CAAE;AAAA,MAC5C;AAAA,IACD;AAAA,IACA,CAAE,YAAY,MAAM,UAAW;AAAA,EAChC;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo, useRef, useInsertionEffect } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport beforeInputRules from './before-input-rules';\nimport inputRules from './input-rules';\nimport insertReplacementText from './insert-replacement-text';\nimport removeBrowserShortcuts from './remove-browser-shortcuts';\nimport shortcuts from './shortcuts';\nimport inputEvents from './input-events';\nimport undoAutomaticChange from './undo-automatic-change';\nimport pasteHandler from './paste-handler';\nimport _delete from './delete';\nimport enter from './enter';\nimport firefoxCompat from './firefox-compat';\n\nconst allEventListeners = [\n\tbeforeInputRules,\n\tinputRules,\n\tinsertReplacementText,\n\tremoveBrowserShortcuts,\n\tshortcuts,\n\tinputEvents,\n\tundoAutomaticChange,\n\tpasteHandler,\n\t_delete,\n\tenter,\n\tfirefoxCompat,\n];\n\nexport function useEventListeners( props ) {\n\tconst propsRef = useRef( props );\n\tuseInsertionEffect( () => {\n\t\t// eslint-disable-next-line react-compiler/react-compiler -- false positive, see https://github.com/facebook/react/issues/29196\n\t\tpropsRef.current = props;\n\t} );\n\tconst refEffects = useMemo(\n\t\t() => allEventListeners.map( ( refEffect ) => refEffect( propsRef ) ),\n\t\t[ propsRef ]\n\t);\n\n\treturn useRefEffect(\n\t\t( element ) => {\n\t\t\tif ( ! props.isSelected ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst cleanups = refEffects.map( ( effect ) => effect( element ) );\n\t\t\treturn () => {\n\t\t\t\tcleanups.forEach( ( cleanup ) => cleanup() );\n\t\t\t};\n\t\t},\n\t\t[ refEffects, props.isSelected ]\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAoD;AACpD,qBAA6B;AAK7B,gCAA6B;AAC7B,yBAAuB;AACvB,qCAAkC;AAClC,sCAAmC;AACnC,uBAAsB;AACtB,0BAAwB;AACxB,mCAAgC;AAChC,2BAAyB;AACzB,oBAAoB;AACpB,mBAAkB;AAClB,4BAA0B;AAE1B,IAAM,oBAAoB;AAAA,EACzB,0BAAAA;AAAA,EACA,mBAAAC;AAAA,EACA,+BAAAC;AAAA,EACA,gCAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,6BAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC;AAAA,EACA,sBAAAC;AACD;AAEO,SAAS,kBAAmB,OAAQ;AAC1C,QAAM,eAAW,uBAAQ,KAAM;AAC/B,yCAAoB,MAAM;AAEzB,aAAS,UAAU;AAAA,EACpB,CAAE;AACF,QAAM,iBAAa;AAAA,IAClB,MAAM,kBAAkB,IAAK,CAAE,cAAe,UAAW,QAAS,CAAE;AAAA,IACpE,CAAE,QAAS;AAAA,EACZ;AAEA,aAAO;AAAA,IACN,CAAE,YAAa;AACd,UAAK,CAAE,MAAM,YAAa;AACzB;AAAA,MACD;AACA,YAAM,WAAW,WAAW,IAAK,CAAE,WAAY,OAAQ,OAAQ,CAAE;AACjE,aAAO,MAAM;AACZ,iBAAS,QAAS,CAAE,YAAa,QAAQ,CAAE;AAAA,MAC5C;AAAA,IACD;AAAA,IACA,CAAE,YAAY,MAAM,UAAW;AAAA,EAChC;AACD;",
6
6
  "names": ["beforeInputRules", "inputRules", "insertReplacementText", "removeBrowserShortcuts", "shortcuts", "inputEvents", "undoAutomaticChange", "pasteHandler", "_delete", "enter", "firefoxCompat"]
7
7
  }
@@ -26,6 +26,7 @@ module.exports = __toCommonJS(paste_handler_exports);
26
26
  var import_blocks = require("@wordpress/blocks");
27
27
  var import_rich_text = require("@wordpress/rich-text");
28
28
  var import_url = require("@wordpress/url");
29
+ var import_store = require("../../../store/index.cjs");
29
30
  var import_utils = require("../utils.cjs");
30
31
  var import_pasting = require("../../../utils/pasting.cjs");
31
32
  var paste_handler_default = (props) => (element) => {
@@ -39,7 +40,8 @@ var paste_handler_default = (props) => (element) => {
39
40
  onReplace,
40
41
  __unstableEmbedURLOnPaste,
41
42
  preserveWhiteSpace,
42
- pastePlainText
43
+ pastePlainText,
44
+ registry
43
45
  } = props.current;
44
46
  if (!element.contains(event.target)) {
45
47
  return;
@@ -100,11 +102,16 @@ var paste_handler_default = (props) => (element) => {
100
102
  });
101
103
  if (typeof content === "string") {
102
104
  pasteInline(content);
103
- } else if (content.length > 0) {
104
- if (onReplace && (0, import_rich_text.isEmpty)(value)) {
105
- onReplace(content, content.length - 1, -1);
106
- }
105
+ return;
106
+ }
107
+ if (!content.length || !onReplace || !(0, import_rich_text.isEmpty)(value)) {
108
+ return;
109
+ }
110
+ if (mode === "BLOCKS") {
111
+ pasteInline(html);
112
+ registry.dispatch(import_store.store).__unstableMarkLastChangeAsPersistent();
107
113
  }
114
+ onReplace(content, content.length - 1, -1);
108
115
  }
109
116
  const { defaultView } = element.ownerDocument;
110
117
  defaultView.addEventListener("paste", _onPaste);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/rich-text/event-listeners/paste-handler.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { pasteHandler } from '@wordpress/blocks';\nimport { isEmpty, insert, create } from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { addActiveFormats } from '../utils';\nimport { getPasteEventData } from '../../../utils/pasting';\n\n/** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */\n\nexport default ( props ) => ( element ) => {\n\tfunction _onPaste( event ) {\n\t\tconst {\n\t\t\tdisableFormats,\n\t\t\tonChange,\n\t\t\tvalue,\n\t\t\tformatTypes,\n\t\t\ttagName,\n\t\t\tonReplace,\n\t\t\t__unstableEmbedURLOnPaste,\n\t\t\tpreserveWhiteSpace,\n\t\t\tpastePlainText,\n\t\t} = props.current;\n\n\t\t// The event listener is attached to the window, so we need to check if\n\t\t// the target is the element or inside the element.\n\t\tif ( ! element.contains( event.target ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { plainText, html } = getPasteEventData( event );\n\n\t\tevent.preventDefault();\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\t// `pasteHandler` also logs this, but we're not using `pasteHandler` in\n\t\t// every case.\n\t\twindow.console.log( 'Received HTML (RichText):\\n\\n', html );\n\t\twindow.console.log( 'Received plain text (RichText):\\n\\n', plainText );\n\n\t\tif ( disableFormats ) {\n\t\t\tonChange( insert( value, plainText ) );\n\t\t\treturn;\n\t\t}\n\n\t\tconst isInternal =\n\t\t\tevent.clipboardData.getData( 'rich-text' ) === 'true';\n\n\t\tfunction pasteInline( content ) {\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumulator, { __unstablePasteRule } ) => {\n\t\t\t\t\t// Only allow one transform.\n\t\t\t\t\tif ( __unstablePasteRule && accumulator === value ) {\n\t\t\t\t\t\taccumulator = __unstablePasteRule( value, {\n\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\tplainText,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\t\t\tif ( transformed !== value ) {\n\t\t\t\tonChange( transformed );\n\t\t\t} else {\n\t\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\t\taddActiveFormats( valueToInsert, value.activeFormats );\n\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t}\n\t\t}\n\n\t\t// If the data comes from a rich text instance, we can directly use it\n\t\t// without filtering the data. The filters are only meant for externally\n\t\t// pasted content and remove inline styles.\n\t\tif ( isInternal ) {\n\t\t\tpasteInline( html );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( pastePlainText ) {\n\t\t\tonChange( insert( value, create( { text: plainText } ) ) );\n\t\t\treturn;\n\t\t}\n\n\t\tlet mode = 'INLINE';\n\n\t\tconst trimmedPlainText = plainText.trim();\n\n\t\tif (\n\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\tisEmpty( value ) &&\n\t\t\tisURL( trimmedPlainText ) &&\n\t\t\t// For the link pasting feature, allow only http(s) protocols.\n\t\t\t/^https?:/.test( trimmedPlainText )\n\t\t) {\n\t\t\tmode = 'BLOCKS';\n\t\t}\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode,\n\t\t\ttagName,\n\t\t\tpreserveWhiteSpace,\n\t\t} );\n\n\t\tif ( typeof content === 'string' ) {\n\t\t\tpasteInline( content );\n\t\t} else if ( content.length > 0 ) {\n\t\t\tif ( onReplace && isEmpty( value ) ) {\n\t\t\t\tonReplace( content, content.length - 1, -1 );\n\t\t\t}\n\t\t}\n\t}\n\n\tconst { defaultView } = element.ownerDocument;\n\n\t// Attach the listener to the window so parent elements have the chance to\n\t// prevent the default behavior.\n\tdefaultView.addEventListener( 'paste', _onPaste );\n\treturn () => {\n\t\tdefaultView.removeEventListener( 'paste', _onPaste );\n\t};\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA6B;AAC7B,uBAAwC;AACxC,iBAAsB;AAKtB,mBAAiC;AACjC,qBAAkC;AAIlC,IAAO,wBAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,SAAU,OAAQ;AAC1B,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,IAAI,MAAM;AAIV,QAAK,CAAE,QAAQ,SAAU,MAAM,MAAO,GAAI;AACzC;AAAA,IACD;AAEA,QAAK,MAAM,kBAAmB;AAC7B;AAAA,IACD;AAEA,UAAM,EAAE,WAAW,KAAK,QAAI,kCAAmB,KAAM;AAErD,UAAM,eAAe;AAKrB,WAAO,QAAQ,IAAK,iCAAiC,IAAK;AAC1D,WAAO,QAAQ,IAAK,uCAAuC,SAAU;AAErE,QAAK,gBAAiB;AACrB,mBAAU,yBAAQ,OAAO,SAAU,CAAE;AACrC;AAAA,IACD;AAEA,UAAM,aACL,MAAM,cAAc,QAAS,WAAY,MAAM;AAEhD,aAAS,YAAaA,UAAU;AAC/B,YAAM,cAAc,YAAY;AAAA,QAC/B,CAAE,aAAa,EAAE,oBAAoB,MAAO;AAE3C,cAAK,uBAAuB,gBAAgB,OAAQ;AACnD,0BAAc,oBAAqB,OAAO;AAAA,cACzC;AAAA,cACA;AAAA,YACD,CAAE;AAAA,UACH;AAEA,iBAAO;AAAA,QACR;AAAA,QACA;AAAA,MACD;AACA,UAAK,gBAAgB,OAAQ;AAC5B,iBAAU,WAAY;AAAA,MACvB,OAAO;AACN,cAAM,oBAAgB,yBAAQ,EAAE,MAAMA,SAAQ,CAAE;AAChD,2CAAkB,eAAe,MAAM,aAAc;AACrD,qBAAU,yBAAQ,OAAO,aAAc,CAAE;AAAA,MAC1C;AAAA,IACD;AAKA,QAAK,YAAa;AACjB,kBAAa,IAAK;AAClB;AAAA,IACD;AAEA,QAAK,gBAAiB;AACrB,mBAAU,yBAAQ,WAAO,yBAAQ,EAAE,MAAM,UAAU,CAAE,CAAE,CAAE;AACzD;AAAA,IACD;AAEA,QAAI,OAAO;AAEX,UAAM,mBAAmB,UAAU,KAAK;AAExC,QACC,iCACA,0BAAS,KAAM,SACf,kBAAO,gBAAiB;AAAA,IAExB,WAAW,KAAM,gBAAiB,GACjC;AACD,aAAO;AAAA,IACR;AAEA,UAAM,cAAU,4BAAc;AAAA,MAC7B,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAE;AAEF,QAAK,OAAO,YAAY,UAAW;AAClC,kBAAa,OAAQ;AAAA,IACtB,WAAY,QAAQ,SAAS,GAAI;AAChC,UAAK,iBAAa,0BAAS,KAAM,GAAI;AACpC,kBAAW,SAAS,QAAQ,SAAS,GAAG,EAAG;AAAA,MAC5C;AAAA,IACD;AAAA,EACD;AAEA,QAAM,EAAE,YAAY,IAAI,QAAQ;AAIhC,cAAY,iBAAkB,SAAS,QAAS;AAChD,SAAO,MAAM;AACZ,gBAAY,oBAAqB,SAAS,QAAS;AAAA,EACpD;AACD;",
6
- "names": ["content"]
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { pasteHandler } from '@wordpress/blocks';\nimport { isEmpty, insert, create } from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { addActiveFormats } from '../utils';\nimport { getPasteEventData } from '../../../utils/pasting';\n\n/** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */\n\nexport default ( props ) => ( element ) => {\n\tfunction _onPaste( event ) {\n\t\tconst {\n\t\t\tdisableFormats,\n\t\t\tonChange,\n\t\t\tvalue,\n\t\t\tformatTypes,\n\t\t\ttagName,\n\t\t\tonReplace,\n\t\t\t__unstableEmbedURLOnPaste,\n\t\t\tpreserveWhiteSpace,\n\t\t\tpastePlainText,\n\t\t\tregistry,\n\t\t} = props.current;\n\n\t\t// The event listener is attached to the window, so we need to check if\n\t\t// the target is the element or inside the element.\n\t\tif ( ! element.contains( event.target ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { plainText, html } = getPasteEventData( event );\n\n\t\tevent.preventDefault();\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\t// `pasteHandler` also logs this, but we're not using `pasteHandler` in\n\t\t// every case.\n\t\twindow.console.log( 'Received HTML (RichText):\\n\\n', html );\n\t\twindow.console.log( 'Received plain text (RichText):\\n\\n', plainText );\n\n\t\tif ( disableFormats ) {\n\t\t\tonChange( insert( value, plainText ) );\n\t\t\treturn;\n\t\t}\n\n\t\tconst isInternal =\n\t\t\tevent.clipboardData.getData( 'rich-text' ) === 'true';\n\n\t\tfunction pasteInline( content ) {\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumulator, { __unstablePasteRule } ) => {\n\t\t\t\t\t// Only allow one transform.\n\t\t\t\t\tif ( __unstablePasteRule && accumulator === value ) {\n\t\t\t\t\t\taccumulator = __unstablePasteRule( value, {\n\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\tplainText,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\t\t\tif ( transformed !== value ) {\n\t\t\t\tonChange( transformed );\n\t\t\t} else {\n\t\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\t\taddActiveFormats( valueToInsert, value.activeFormats );\n\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t}\n\t\t}\n\n\t\t// If the data comes from a rich text instance, we can directly use it\n\t\t// without filtering the data. The filters are only meant for externally\n\t\t// pasted content and remove inline styles.\n\t\tif ( isInternal ) {\n\t\t\tpasteInline( html );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( pastePlainText ) {\n\t\t\tonChange( insert( value, create( { text: plainText } ) ) );\n\t\t\treturn;\n\t\t}\n\n\t\tlet mode = 'INLINE';\n\n\t\tconst trimmedPlainText = plainText.trim();\n\n\t\tif (\n\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\tisEmpty( value ) &&\n\t\t\tisURL( trimmedPlainText ) &&\n\t\t\t// For the link pasting feature, allow only http(s) protocols.\n\t\t\t/^https?:/.test( trimmedPlainText )\n\t\t) {\n\t\t\tmode = 'BLOCKS';\n\t\t}\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode,\n\t\t\ttagName,\n\t\t\tpreserveWhiteSpace,\n\t\t} );\n\n\t\tif ( typeof content === 'string' ) {\n\t\t\tpasteInline( content );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! content.length || ! onReplace || ! isEmpty( value ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Record an intermediate paragraph-with-URL state so a single undo\n\t\t// after the URL \u2192 block transformation restores the pasted link.\n\t\tif ( mode === 'BLOCKS' ) {\n\t\t\tpasteInline( html );\n\t\t\tregistry\n\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t\t}\n\n\t\tonReplace( content, content.length - 1, -1 );\n\t}\n\n\tconst { defaultView } = element.ownerDocument;\n\n\t// Attach the listener to the window so parent elements have the chance to\n\t// prevent the default behavior.\n\tdefaultView.addEventListener( 'paste', _onPaste );\n\treturn () => {\n\t\tdefaultView.removeEventListener( 'paste', _onPaste );\n\t};\n};\n"],
5
+ "mappings": ";;;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a;AACjB,kBAAa,IAAK;AAClB;AAAA,IACD;AAEA,QAAK,gBAAiB;AACrB,mBAAU,yBAAQ,WAAO,yBAAQ,EAAE,MAAM,UAAU,CAAE,CAAE,CAAE;AACzD;AAAA,IACD;AAEA,QAAI,OAAO;AAEX,UAAM,mBAAmB,UAAU,KAAK;AAExC,QACC,iCACA,0BAAS,KAAM,SACf,kBAAO,gBAAiB;AAAA,IAExB,WAAW,KAAM,gBAAiB,GACjC;AACD,aAAO;AAAA,IACR;AAEA,UAAM,cAAU,4BAAc;AAAA,MAC7B,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAE;AAEF,QAAK,OAAO,YAAY,UAAW;AAClC,kBAAa,OAAQ;AACrB;AAAA,IACD;AAEA,QAAK,CAAE,QAAQ,UAAU,CAAE,aAAa,KAAE,0BAAS,KAAM,GAAI;AAC5D;AAAA,IACD;AAIA,QAAK,SAAS,UAAW;AACxB,kBAAa,IAAK;AAClB,eACE,SAAU,aAAAC,KAAiB,EAC3B,qCAAqC;AAAA,IACxC;AAEA,cAAW,SAAS,QAAQ,SAAS,GAAG,EAAG;AAAA,EAC5C;AAEA,QAAM,EAAE,YAAY,IAAI,QAAQ;AAIhC,cAAY,iBAAkB,SAAS,QAAS;AAChD,SAAO,MAAM;AACZ,gBAAY,oBAAqB,SAAS,QAAS;AAAA,EACpD;AACD;",
6
+ "names": ["content", "blockEditorStore"]
7
7
  }
@@ -40,7 +40,7 @@ module.exports = __toCommonJS(utils_exports);
40
40
  var import_i18n = require("@wordpress/i18n");
41
41
  var import_icons = require("@wordpress/icons");
42
42
  var RANGE_CONTROL_MAX_SIZE = 8;
43
- var ALL_SIDES = ["top", "right", "bottom", "left"];
43
+ var ALL_SIDES = ["top", "bottom", "left", "right"];
44
44
  var DEFAULT_VALUES = {
45
45
  top: void 0,
46
46
  right: void 0,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/spacing-sizes-control/utils.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tsidesAll,\n\tsidesBottom,\n\tsidesHorizontal,\n\tsidesLeft,\n\tsidesRight,\n\tsidesTop,\n\tsidesVertical,\n} from '@wordpress/icons';\n\nexport const RANGE_CONTROL_MAX_SIZE = 8;\n\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\n\nexport const DEFAULT_VALUES = {\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nexport const ICONS = {\n\tcustom: sidesAll,\n\taxial: sidesAll,\n\thorizontal: sidesHorizontal,\n\tvertical: sidesVertical,\n\ttop: sidesTop,\n\tright: sidesRight,\n\tbottom: sidesBottom,\n\tleft: sidesLeft,\n};\n\nexport const LABELS = {\n\tdefault: __( 'Spacing control' ),\n\ttop: __( 'Top' ),\n\tbottom: __( 'Bottom' ),\n\tleft: __( 'Left' ),\n\tright: __( 'Right' ),\n\tmixed: __( 'Mixed' ),\n\tvertical: __( 'Vertical' ),\n\thorizontal: __( 'Horizontal' ),\n\taxial: __( 'Horizontal & vertical' ),\n\tcustom: __( 'Custom' ),\n};\n\nexport const VIEWS = {\n\taxial: 'axial',\n\ttop: 'top',\n\tright: 'right',\n\tbottom: 'bottom',\n\tleft: 'left',\n\tcustom: 'custom',\n};\n\n/**\n * Checks is given value is a spacing preset.\n *\n * @param {string} value Value to check\n *\n * @return {boolean} Return true if value is string in format var:preset|spacing|.\n */\nexport function isValueSpacingPreset( value ) {\n\tif ( ! value?.includes ) {\n\t\treturn false;\n\t}\n\treturn value === '0' || value.includes( 'var:preset|spacing|' );\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} Mapping of the spacing preset to its equivalent custom value.\n */\nexport function getCustomValueFromPreset( value, spacingSizes ) {\n\tif ( ! isValueSpacingPreset( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst slug = getSpacingPresetSlug( value );\n\tconst spacingSize = spacingSizes.find(\n\t\t( size ) => String( size.slug ) === slug\n\t);\n\n\treturn spacingSize?.size;\n}\n\n/**\n * Converts a custom value to preset value if one can be found.\n *\n * Returns value as-is if no match is found.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} The preset value if it can be found.\n */\nexport function getPresetValueFromCustomValue( value, spacingSizes ) {\n\t// Return value as-is if it is undefined or is already a preset, or '0';\n\tif ( ! value || isValueSpacingPreset( value ) || value === '0' ) {\n\t\treturn value;\n\t}\n\n\tconst spacingMatch = spacingSizes.find(\n\t\t( size ) => String( size.size ) === String( value )\n\t);\n\n\tif ( spacingMatch?.slug ) {\n\t\treturn `var:preset|spacing|${ spacingMatch.slug }`;\n\t}\n\n\treturn value;\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert.\n *\n * @return {string | undefined} CSS var string for given spacing preset value.\n */\nexport function getSpacingPresetCssVar( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\tif ( ! slug ) {\n\t\treturn value;\n\t}\n\n\treturn `var(--wp--preset--spacing--${ slug[ 1 ] })`;\n}\n\n/**\n * Returns the slug section of the given spacing preset string.\n *\n * @param {string} value Value to extract slug from.\n *\n * @return {string|undefined} The int value of the slug from given spacing preset.\n */\nexport function getSpacingPresetSlug( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tif ( value === '0' || value === 'default' ) {\n\t\treturn value;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\treturn slug ? slug[ 1 ] : undefined;\n}\n\n/**\n * Converts spacing preset value into a Range component value .\n *\n * @param {string} presetValue Value to convert to Range value.\n * @param {Array} spacingSizes Array of current spacing preset value objects.\n *\n * @return {number} The int value for use in Range control.\n */\nexport function getSliderValueFromPreset( presetValue, spacingSizes ) {\n\tif ( presetValue === undefined ) {\n\t\treturn 0;\n\t}\n\tconst slug =\n\t\tparseFloat( presetValue, 10 ) === 0\n\t\t\t? '0'\n\t\t\t: getSpacingPresetSlug( presetValue );\n\tconst sliderValue = spacingSizes.findIndex( ( spacingSize ) => {\n\t\treturn String( spacingSize.slug ) === slug;\n\t} );\n\n\t// Returning NaN rather than undefined as undefined makes range control thumb sit in center\n\treturn sliderValue !== -1 ? sliderValue : NaN;\n}\n\n/**\n * Determines whether a particular axis has support. If no axis is\n * specified, this function checks if either axis is supported.\n *\n * @param {Array} sides Supported sides.\n * @param {string} axis Which axis to check.\n *\n * @return {boolean} Whether there is support for the specified axis or both axes.\n */\nexport function hasAxisSupport( sides, axis ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn false;\n\t}\n\n\tconst hasHorizontalSupport =\n\t\tsides.includes( 'horizontal' ) ||\n\t\t( sides.includes( 'left' ) && sides.includes( 'right' ) );\n\n\tconst hasVerticalSupport =\n\t\tsides.includes( 'vertical' ) ||\n\t\t( sides.includes( 'top' ) && sides.includes( 'bottom' ) );\n\n\tif ( axis === 'horizontal' ) {\n\t\treturn hasHorizontalSupport;\n\t}\n\n\tif ( axis === 'vertical' ) {\n\t\treturn hasVerticalSupport;\n\t}\n\n\treturn hasHorizontalSupport || hasVerticalSupport;\n}\n\n/**\n * Checks if the supported sides are balanced for each axis.\n * - Horizontal - both left and right sides are supported.\n * - Vertical - both top and bottom are supported.\n *\n * @param {Array} sides The supported sides which may be axes as well.\n *\n * @return {boolean} Whether or not the supported sides are balanced.\n */\nexport function hasBalancedSidesSupport( sides = [] ) {\n\tconst counts = { top: 0, right: 0, bottom: 0, left: 0 };\n\tsides.forEach( ( side ) => ( counts[ side ] += 1 ) );\n\n\treturn (\n\t\t( counts.top + counts.bottom ) % 2 === 0 &&\n\t\t( counts.left + counts.right ) % 2 === 0\n\t);\n}\n\n/**\n * Determines which view the SpacingSizesControl should default to on its\n * first render; Axial, Custom, or Single side.\n *\n * @param {Object} values Current side values.\n * @param {Array} sides Supported sides.\n *\n * @return {string} View to display.\n */\nexport function getInitialView( values = {}, sides ) {\n\tconst { top, right, bottom, left } = values;\n\tconst sideValues = [ top, right, bottom, left ].filter( Boolean );\n\n\t// Axial ( Horizontal & vertical ).\n\t// - Has axial side support\n\t// - Has axial side values which match\n\t// - Has no values and the supported sides are balanced\n\tconst hasMatchingAxialValues =\n\t\ttop === bottom && left === right && ( !! top || !! left );\n\tconst hasNoValuesAndBalancedSides =\n\t\t! sideValues.length && hasBalancedSidesSupport( sides );\n\tconst hasOnlyAxialSides =\n\t\tsides?.includes( 'horizontal' ) &&\n\t\tsides?.includes( 'vertical' ) &&\n\t\tsides?.length === 2;\n\n\tif (\n\t\thasAxisSupport( sides ) &&\n\t\t( hasMatchingAxialValues || hasNoValuesAndBalancedSides )\n\t) {\n\t\treturn VIEWS.axial;\n\t}\n\n\t// Only axial sides are supported and single value defined.\n\t// - Ensure the side returned is the first side that has a value.\n\tif ( hasOnlyAxialSides && sideValues.length === 1 ) {\n\t\tlet side;\n\n\t\tObject.entries( values ).some( ( [ key, value ] ) => {\n\t\t\tside = key;\n\t\t\treturn value !== undefined;\n\t\t} );\n\n\t\treturn side;\n\t}\n\n\t// Only single side supported and no value defined.\n\tif ( sides?.length === 1 && ! sideValues.length ) {\n\t\treturn sides[ 0 ];\n\t}\n\n\t// Default to the Custom (separated sides) view.\n\treturn VIEWS.custom;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,mBAQO;AAEA,IAAM,yBAAyB;AAE/B,IAAM,YAAY,CAAE,OAAO,SAAS,UAAU,MAAO;AAErD,IAAM,iBAAiB;AAAA,EAC7B,KAAK;AAAA,EACL,OAAO;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,CAAC,GAAI;AACrD,QAAM,SAAS,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,EAAE;AACtD,QAAM,QAAS,CAAE,SAAY,OAAQ,IAAK,KAAK,CAAI;AAEnD,UACG,OAAO,MAAM,OAAO,UAAW,MAAM,MACrC,OAAO,OAAO,OAAO,SAAU,MAAM;AAEzC;AAWO,SAAS,eAAgB,SAAS,CAAC,GAAG,OAAQ;AACpD,QAAM,EAAE,KAAK,OAAO,QAAQ,KAAK,IAAI;AACrC,QAAM,aAAa,CAAE,KAAK,OAAO,QAAQ,IAAK,EAAE,OAAQ,OAAQ;AAMhE,QAAM,yBACL,QAAQ,UAAU,SAAS,UAAW,CAAC,CAAE,OAAO,CAAC,CAAE;AACpD,QAAM,8BACL,CAAE,WAAW,UAAU,wBAAyB,KAAM;AACvD,QAAM,oBACL,OAAO,SAAU,YAAa,KAC9B,OAAO,SAAU,UAAW,KAC5B,OAAO,WAAW;AAEnB,MACC,eAAgB,KAAM,MACpB,0BAA0B,8BAC3B;AACD,WAAO,MAAM;AAAA,EACd;AAIA,MAAK,qBAAqB,WAAW,WAAW,GAAI;AACnD,QAAI;AAEJ,WAAO,QAAS,MAAO,EAAE,KAAM,CAAE,CAAE,KAAK,KAAM,MAAO;AACpD,aAAO;AACP,aAAO,UAAU;AAAA,IAClB,CAAE;AAEF,WAAO;AAAA,EACR;AAGA,MAAK,OAAO,WAAW,KAAK,CAAE,WAAW,QAAS;AACjD,WAAO,MAAO,CAAE;AAAA,EACjB;AAGA,SAAO,MAAM;AACd;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tsidesAll,\n\tsidesBottom,\n\tsidesHorizontal,\n\tsidesLeft,\n\tsidesRight,\n\tsidesTop,\n\tsidesVertical,\n} from '@wordpress/icons';\n\nexport const RANGE_CONTROL_MAX_SIZE = 8;\n\nexport const ALL_SIDES = [ 'top', 'bottom', 'left', 'right' ];\n\nexport const DEFAULT_VALUES = {\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nexport const ICONS = {\n\tcustom: sidesAll,\n\taxial: sidesAll,\n\thorizontal: sidesHorizontal,\n\tvertical: sidesVertical,\n\ttop: sidesTop,\n\tright: sidesRight,\n\tbottom: sidesBottom,\n\tleft: sidesLeft,\n};\n\nexport const LABELS = {\n\tdefault: __( 'Spacing control' ),\n\ttop: __( 'Top' ),\n\tbottom: __( 'Bottom' ),\n\tleft: __( 'Left' ),\n\tright: __( 'Right' ),\n\tmixed: __( 'Mixed' ),\n\tvertical: __( 'Vertical' ),\n\thorizontal: __( 'Horizontal' ),\n\taxial: __( 'Horizontal & vertical' ),\n\tcustom: __( 'Custom' ),\n};\n\nexport const VIEWS = {\n\taxial: 'axial',\n\ttop: 'top',\n\tright: 'right',\n\tbottom: 'bottom',\n\tleft: 'left',\n\tcustom: 'custom',\n};\n\n/**\n * Checks is given value is a spacing preset.\n *\n * @param {string} value Value to check\n *\n * @return {boolean} Return true if value is string in format var:preset|spacing|.\n */\nexport function isValueSpacingPreset( value ) {\n\tif ( ! value?.includes ) {\n\t\treturn false;\n\t}\n\treturn value === '0' || value.includes( 'var:preset|spacing|' );\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} Mapping of the spacing preset to its equivalent custom value.\n */\nexport function getCustomValueFromPreset( value, spacingSizes ) {\n\tif ( ! isValueSpacingPreset( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst slug = getSpacingPresetSlug( value );\n\tconst spacingSize = spacingSizes.find(\n\t\t( size ) => String( size.slug ) === slug\n\t);\n\n\treturn spacingSize?.size;\n}\n\n/**\n * Converts a custom value to preset value if one can be found.\n *\n * Returns value as-is if no match is found.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} The preset value if it can be found.\n */\nexport function getPresetValueFromCustomValue( value, spacingSizes ) {\n\t// Return value as-is if it is undefined or is already a preset, or '0';\n\tif ( ! value || isValueSpacingPreset( value ) || value === '0' ) {\n\t\treturn value;\n\t}\n\n\tconst spacingMatch = spacingSizes.find(\n\t\t( size ) => String( size.size ) === String( value )\n\t);\n\n\tif ( spacingMatch?.slug ) {\n\t\treturn `var:preset|spacing|${ spacingMatch.slug }`;\n\t}\n\n\treturn value;\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert.\n *\n * @return {string | undefined} CSS var string for given spacing preset value.\n */\nexport function getSpacingPresetCssVar( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\tif ( ! slug ) {\n\t\treturn value;\n\t}\n\n\treturn `var(--wp--preset--spacing--${ slug[ 1 ] })`;\n}\n\n/**\n * Returns the slug section of the given spacing preset string.\n *\n * @param {string} value Value to extract slug from.\n *\n * @return {string|undefined} The int value of the slug from given spacing preset.\n */\nexport function getSpacingPresetSlug( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tif ( value === '0' || value === 'default' ) {\n\t\treturn value;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\treturn slug ? slug[ 1 ] : undefined;\n}\n\n/**\n * Converts spacing preset value into a Range component value .\n *\n * @param {string} presetValue Value to convert to Range value.\n * @param {Array} spacingSizes Array of current spacing preset value objects.\n *\n * @return {number} The int value for use in Range control.\n */\nexport function getSliderValueFromPreset( presetValue, spacingSizes ) {\n\tif ( presetValue === undefined ) {\n\t\treturn 0;\n\t}\n\tconst slug =\n\t\tparseFloat( presetValue, 10 ) === 0\n\t\t\t? '0'\n\t\t\t: getSpacingPresetSlug( presetValue );\n\tconst sliderValue = spacingSizes.findIndex( ( spacingSize ) => {\n\t\treturn String( spacingSize.slug ) === slug;\n\t} );\n\n\t// Returning NaN rather than undefined as undefined makes range control thumb sit in center\n\treturn sliderValue !== -1 ? sliderValue : NaN;\n}\n\n/**\n * Determines whether a particular axis has support. If no axis is\n * specified, this function checks if either axis is supported.\n *\n * @param {Array} sides Supported sides.\n * @param {string} axis Which axis to check.\n *\n * @return {boolean} Whether there is support for the specified axis or both axes.\n */\nexport function hasAxisSupport( sides, axis ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn false;\n\t}\n\n\tconst hasHorizontalSupport =\n\t\tsides.includes( 'horizontal' ) ||\n\t\t( sides.includes( 'left' ) && sides.includes( 'right' ) );\n\n\tconst hasVerticalSupport =\n\t\tsides.includes( 'vertical' ) ||\n\t\t( sides.includes( 'top' ) && sides.includes( 'bottom' ) );\n\n\tif ( axis === 'horizontal' ) {\n\t\treturn hasHorizontalSupport;\n\t}\n\n\tif ( axis === 'vertical' ) {\n\t\treturn hasVerticalSupport;\n\t}\n\n\treturn hasHorizontalSupport || hasVerticalSupport;\n}\n\n/**\n * Checks if the supported sides are balanced for each axis.\n * - Horizontal - both left and right sides are supported.\n * - Vertical - both top and bottom are supported.\n *\n * @param {Array} sides The supported sides which may be axes as well.\n *\n * @return {boolean} Whether or not the supported sides are balanced.\n */\nexport function hasBalancedSidesSupport( sides = [] ) {\n\tconst counts = { top: 0, right: 0, bottom: 0, left: 0 };\n\tsides.forEach( ( side ) => ( counts[ side ] += 1 ) );\n\n\treturn (\n\t\t( counts.top + counts.bottom ) % 2 === 0 &&\n\t\t( counts.left + counts.right ) % 2 === 0\n\t);\n}\n\n/**\n * Determines which view the SpacingSizesControl should default to on its\n * first render; Axial, Custom, or Single side.\n *\n * @param {Object} values Current side values.\n * @param {Array} sides Supported sides.\n *\n * @return {string} View to display.\n */\nexport function getInitialView( values = {}, sides ) {\n\tconst { top, right, bottom, left } = values;\n\tconst sideValues = [ top, right, bottom, left ].filter( Boolean );\n\n\t// Axial ( Horizontal & vertical ).\n\t// - Has axial side support\n\t// - Has axial side values which match\n\t// - Has no values and the supported sides are balanced\n\tconst hasMatchingAxialValues =\n\t\ttop === bottom && left === right && ( !! top || !! left );\n\tconst hasNoValuesAndBalancedSides =\n\t\t! sideValues.length && hasBalancedSidesSupport( sides );\n\tconst hasOnlyAxialSides =\n\t\tsides?.includes( 'horizontal' ) &&\n\t\tsides?.includes( 'vertical' ) &&\n\t\tsides?.length === 2;\n\n\tif (\n\t\thasAxisSupport( sides ) &&\n\t\t( hasMatchingAxialValues || hasNoValuesAndBalancedSides )\n\t) {\n\t\treturn VIEWS.axial;\n\t}\n\n\t// Only axial sides are supported and single value defined.\n\t// - Ensure the side returned is the first side that has a value.\n\tif ( hasOnlyAxialSides && sideValues.length === 1 ) {\n\t\tlet side;\n\n\t\tObject.entries( values ).some( ( [ key, value ] ) => {\n\t\t\tside = key;\n\t\t\treturn value !== undefined;\n\t\t} );\n\n\t\treturn side;\n\t}\n\n\t// Only single side supported and no value defined.\n\tif ( sides?.length === 1 && ! sideValues.length ) {\n\t\treturn sides[ 0 ];\n\t}\n\n\t// Default to the Custom (separated sides) view.\n\treturn VIEWS.custom;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,mBAQO;AAEA,IAAM,yBAAyB;AAE/B,IAAM,YAAY,CAAE,OAAO,UAAU,QAAQ,OAAQ;AAErD,IAAM,iBAAiB;AAAA,EAC7B,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AACP;AAEO,IAAM,QAAQ;AAAA,EACpB,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AACP;AAEO,IAAM,SAAS;AAAA,EACrB,aAAS,gBAAI,iBAAkB;AAAA,EAC/B,SAAK,g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pD,QAAM,EAAE,KAAK,OAAO,QAAQ,KAAK,IAAI;AACrC,QAAM,aAAa,CAAE,KAAK,OAAO,QAAQ,IAAK,EAAE,OAAQ,OAAQ;AAMhE,QAAM,yBACL,QAAQ,UAAU,SAAS,UAAW,CAAC,CAAE,OAAO,CAAC,CAAE;AACpD,QAAM,8BACL,CAAE,WAAW,UAAU,wBAAyB,KAAM;AACvD,QAAM,oBACL,OAAO,SAAU,YAAa,KAC9B,OAAO,SAAU,UAAW,KAC5B,OAAO,WAAW;AAEnB,MACC,eAAgB,KAAM,MACpB,0BAA0B,8BAC3B;AACD,WAAO,MAAM;AAAA,EACd;AAIA,MAAK,qBAAqB,WAAW,WAAW,GAAI;AACnD,QAAI;AAEJ,WAAO,QAAS,MAAO,EAAE,KAAM,CAAE,CAAE,KAAK,KAAM,MAAO;AACpD,aAAO;AACP,aAAO,UAAU;AAAA,IAClB,CAAE;AAEF,WAAO;AAAA,EACR;AAGA,MAAK,OAAO,WAAW,KAAK,CAAE,WAAW,QAAS;AACjD,WAAO,MAAO,CAAE;AAAA,EACjB;AAGA,SAAO,MAAM;AACd;",
6
6
  "names": []
7
7
  }
@@ -45,7 +45,7 @@ var LINK_DESTINATION_NONE = "none";
45
45
  var LINK_DESTINATION_CUSTOM = "custom";
46
46
  var LINK_DESTINATION_MEDIA = "media";
47
47
  var LINK_DESTINATION_ATTACHMENT = "attachment";
48
- var NEW_TAB_REL = ["noreferrer", "noopener"];
48
+ var NEW_TAB_REL = ["noopener"];
49
49
  var ImageURLInputUI = ({
50
50
  linkDestination,
51
51
  onChangeUrl,