@wordpress/block-editor 12.12.0 → 12.13.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 (287) hide show
  1. package/CHANGELOG.md +12 -10
  2. package/README.md +35 -3
  3. package/build/components/block-alignment-control/use-available-alignments.js +30 -28
  4. package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
  5. package/build/components/block-list/block.native.js +4 -4
  6. package/build/components/block-list/block.native.js.map +1 -1
  7. package/build/components/block-list/layout.js +2 -3
  8. package/build/components/block-list/layout.js.map +1 -1
  9. package/build/components/border-radius-control/index.js +3 -2
  10. package/build/components/border-radius-control/index.js.map +1 -1
  11. package/build/components/color-palette/with-color-context.js +6 -6
  12. package/build/components/color-palette/with-color-context.js.map +1 -1
  13. package/build/components/colors/with-colors.js +2 -8
  14. package/build/components/colors/with-colors.js.map +1 -1
  15. package/build/components/colors-gradients/control.js +6 -7
  16. package/build/components/colors-gradients/control.js.map +1 -1
  17. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +5 -13
  18. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  19. package/build/components/font-family/index.js +2 -3
  20. package/build/components/font-family/index.js.map +1 -1
  21. package/build/components/font-sizes/font-size-picker.js +3 -5
  22. package/build/components/font-sizes/font-size-picker.js.map +1 -1
  23. package/build/components/font-sizes/with-font-sizes.js +3 -4
  24. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  25. package/build/components/global-styles/filters-panel.js +7 -8
  26. package/build/components/global-styles/filters-panel.js.map +1 -1
  27. package/build/components/global-styles/image-settings-panel.js +2 -2
  28. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  29. package/build/components/global-styles/typography-panel.js +1 -1
  30. package/build/components/global-styles/typography-panel.js.map +1 -1
  31. package/build/components/gradients/use-gradient.js +2 -5
  32. package/build/components/gradients/use-gradient.js.map +1 -1
  33. package/build/components/height-control/index.js +3 -3
  34. package/build/components/height-control/index.js.map +1 -1
  35. package/build/components/index.js +9 -2
  36. package/build/components/index.js.map +1 -1
  37. package/build/components/index.native.js +9 -2
  38. package/build/components/index.native.js.map +1 -1
  39. package/build/components/inner-blocks/index.js +2 -2
  40. package/build/components/inner-blocks/index.js.map +1 -1
  41. package/build/components/letter-spacing-control/index.js +3 -3
  42. package/build/components/letter-spacing-control/index.js.map +1 -1
  43. package/build/components/link-control/search-item.js +11 -0
  44. package/build/components/link-control/search-item.js.map +1 -1
  45. package/build/components/link-control/search-results.js +2 -1
  46. package/build/components/link-control/search-results.js.map +1 -1
  47. package/build/components/link-control/use-search-handler.js +10 -5
  48. package/build/components/link-control/use-search-handler.js.map +1 -1
  49. package/build/components/resizable-box-popover/index.js +1 -1
  50. package/build/components/resizable-box-popover/index.js.map +1 -1
  51. package/build/components/rich-text/index.js +1 -1
  52. package/build/components/rich-text/index.js.map +1 -1
  53. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +6 -3
  54. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  55. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +3 -3
  56. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  57. package/build/components/unit-control/index.js +3 -3
  58. package/build/components/unit-control/index.js.map +1 -1
  59. package/build/components/use-block-commands/index.js +6 -1
  60. package/build/components/use-block-commands/index.js.map +1 -1
  61. package/build/components/use-settings/index.js +212 -0
  62. package/build/components/use-settings/index.js.map +1 -0
  63. package/build/hooks/align.js +51 -35
  64. package/build/hooks/align.js.map +1 -1
  65. package/build/hooks/anchor.js +37 -32
  66. package/build/hooks/anchor.js.map +1 -1
  67. package/build/hooks/background.js +4 -4
  68. package/build/hooks/background.js.map +1 -1
  69. package/build/hooks/color.js +2 -4
  70. package/build/hooks/color.js.map +1 -1
  71. package/build/hooks/duotone.js +10 -9
  72. package/build/hooks/duotone.js.map +1 -1
  73. package/build/hooks/font-size.js +4 -4
  74. package/build/hooks/font-size.js.map +1 -1
  75. package/build/hooks/layout.js +10 -11
  76. package/build/hooks/layout.js.map +1 -1
  77. package/build/hooks/line-height.js +3 -3
  78. package/build/hooks/line-height.js.map +1 -1
  79. package/build/hooks/position.js +2 -3
  80. package/build/hooks/position.js.map +1 -1
  81. package/build/hooks/use-color-props.js +3 -11
  82. package/build/hooks/use-color-props.js.map +1 -1
  83. package/build/hooks/utils.js +1 -42
  84. package/build/hooks/utils.js.map +1 -1
  85. package/build/layouts/constrained.js +3 -3
  86. package/build/layouts/constrained.js.map +1 -1
  87. package/build/utils/object.js +4 -1
  88. package/build/utils/object.js.map +1 -1
  89. package/build/utils/transform-styles/index.js +19 -24
  90. package/build/utils/transform-styles/index.js.map +1 -1
  91. package/build-module/components/block-alignment-control/use-available-alignments.js +30 -28
  92. package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
  93. package/build-module/components/block-list/block.native.js +4 -4
  94. package/build-module/components/block-list/block.native.js.map +1 -1
  95. package/build-module/components/block-list/layout.js +2 -2
  96. package/build-module/components/block-list/layout.js.map +1 -1
  97. package/build-module/components/border-radius-control/index.js +3 -2
  98. package/build-module/components/border-radius-control/index.js.map +1 -1
  99. package/build-module/components/color-palette/with-color-context.js +6 -5
  100. package/build-module/components/color-palette/with-color-context.js.map +1 -1
  101. package/build-module/components/colors/with-colors.js +2 -7
  102. package/build-module/components/colors/with-colors.js.map +1 -1
  103. package/build-module/components/colors-gradients/control.js +6 -7
  104. package/build-module/components/colors-gradients/control.js.map +1 -1
  105. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +5 -12
  106. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  107. package/build-module/components/font-family/index.js +2 -2
  108. package/build-module/components/font-family/index.js.map +1 -1
  109. package/build-module/components/font-sizes/font-size-picker.js +3 -4
  110. package/build-module/components/font-sizes/font-size-picker.js.map +1 -1
  111. package/build-module/components/font-sizes/with-font-sizes.js +3 -3
  112. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  113. package/build-module/components/global-styles/filters-panel.js +7 -8
  114. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  115. package/build-module/components/global-styles/image-settings-panel.js +2 -2
  116. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  117. package/build-module/components/global-styles/typography-panel.js +1 -1
  118. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  119. package/build-module/components/gradients/use-gradient.js +2 -4
  120. package/build-module/components/gradients/use-gradient.js.map +1 -1
  121. package/build-module/components/height-control/index.js +3 -2
  122. package/build-module/components/height-control/index.js.map +1 -1
  123. package/build-module/components/index.js +1 -1
  124. package/build-module/components/index.js.map +1 -1
  125. package/build-module/components/index.native.js +1 -1
  126. package/build-module/components/index.native.js.map +1 -1
  127. package/build-module/components/inner-blocks/index.js +2 -2
  128. package/build-module/components/inner-blocks/index.js.map +1 -1
  129. package/build-module/components/letter-spacing-control/index.js +3 -2
  130. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  131. package/build-module/components/link-control/search-item.js +12 -1
  132. package/build-module/components/link-control/search-item.js.map +1 -1
  133. package/build-module/components/link-control/search-results.js +2 -1
  134. package/build-module/components/link-control/search-results.js.map +1 -1
  135. package/build-module/components/link-control/use-search-handler.js +10 -5
  136. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  137. package/build-module/components/resizable-box-popover/index.js +1 -1
  138. package/build-module/components/resizable-box-popover/index.js.map +1 -1
  139. package/build-module/components/rich-text/index.js +1 -1
  140. package/build-module/components/rich-text/index.js.map +1 -1
  141. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +6 -2
  142. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  143. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +3 -2
  144. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  145. package/build-module/components/unit-control/index.js +3 -2
  146. package/build-module/components/unit-control/index.js.map +1 -1
  147. package/build-module/components/use-block-commands/index.js +5 -1
  148. package/build-module/components/use-block-commands/index.js.map +1 -1
  149. package/build-module/components/use-settings/index.js +203 -0
  150. package/build-module/components/use-settings/index.js.map +1 -0
  151. package/build-module/hooks/align.js +51 -35
  152. package/build-module/hooks/align.js.map +1 -1
  153. package/build-module/hooks/anchor.js +37 -32
  154. package/build-module/hooks/anchor.js.map +1 -1
  155. package/build-module/hooks/background.js +4 -4
  156. package/build-module/hooks/background.js.map +1 -1
  157. package/build-module/hooks/color.js +2 -4
  158. package/build-module/hooks/color.js.map +1 -1
  159. package/build-module/hooks/duotone.js +11 -10
  160. package/build-module/hooks/duotone.js.map +1 -1
  161. package/build-module/hooks/font-size.js +4 -4
  162. package/build-module/hooks/font-size.js.map +1 -1
  163. package/build-module/hooks/layout.js +10 -11
  164. package/build-module/hooks/layout.js.map +1 -1
  165. package/build-module/hooks/line-height.js +3 -3
  166. package/build-module/hooks/line-height.js.map +1 -1
  167. package/build-module/hooks/position.js +2 -3
  168. package/build-module/hooks/position.js.map +1 -1
  169. package/build-module/hooks/use-color-props.js +3 -11
  170. package/build-module/hooks/use-color-props.js.map +1 -1
  171. package/build-module/hooks/utils.js +2 -43
  172. package/build-module/hooks/utils.js.map +1 -1
  173. package/build-module/layouts/constrained.js +3 -2
  174. package/build-module/layouts/constrained.js.map +1 -1
  175. package/build-module/utils/object.js +3 -1
  176. package/build-module/utils/object.js.map +1 -1
  177. package/build-module/utils/transform-styles/index.js +20 -24
  178. package/build-module/utils/transform-styles/index.js.map +1 -1
  179. package/build-style/style-rtl.css +13 -6
  180. package/build-style/style.css +13 -6
  181. package/package.json +36 -34
  182. package/src/components/block-alignment-control/use-available-alignments.js +49 -34
  183. package/src/components/block-list/block.native.js +4 -4
  184. package/src/components/block-list/layout.js +2 -2
  185. package/src/components/block-styles/style.scss +1 -1
  186. package/src/components/border-radius-control/index.js +3 -2
  187. package/src/components/color-palette/with-color-context.js +9 -9
  188. package/src/components/colors/with-colors.js +6 -7
  189. package/src/components/colors-gradients/control.js +10 -7
  190. package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +29 -15
  191. package/src/components/font-family/index.js +2 -2
  192. package/src/components/font-sizes/font-size-picker.js +6 -4
  193. package/src/components/font-sizes/with-font-sizes.js +3 -5
  194. package/src/components/global-styles/filters-panel.js +9 -15
  195. package/src/components/global-styles/image-settings-panel.js +2 -2
  196. package/src/components/global-styles/typography-panel.js +1 -1
  197. package/src/components/gradients/use-gradient.js +10 -4
  198. package/src/components/height-control/index.js +3 -2
  199. package/src/components/index.js +1 -1
  200. package/src/components/index.native.js +1 -1
  201. package/src/components/inner-blocks/index.js +2 -2
  202. package/src/components/inserter/style.scss +9 -1
  203. package/src/components/letter-spacing-control/index.js +3 -2
  204. package/src/components/link-control/search-item.js +14 -0
  205. package/src/components/link-control/search-results.js +1 -0
  206. package/src/components/link-control/use-search-handler.js +22 -15
  207. package/src/components/resizable-box-popover/index.js +1 -1
  208. package/src/components/rich-text/index.js +1 -1
  209. package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +7 -5
  210. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +3 -2
  211. package/src/components/unit-control/index.js +3 -8
  212. package/src/components/use-block-commands/index.js +2 -1
  213. package/src/components/{use-setting → use-settings}/README.md +9 -10
  214. package/src/components/use-settings/index.js +272 -0
  215. package/src/components/{use-setting → use-settings}/test/index.js +47 -5
  216. package/src/hooks/align.js +79 -54
  217. package/src/hooks/anchor.js +75 -65
  218. package/src/hooks/background.js +7 -9
  219. package/src/hooks/color.js +7 -4
  220. package/src/hooks/duotone.js +24 -19
  221. package/src/hooks/font-size.js +4 -4
  222. package/src/hooks/layout.js +11 -11
  223. package/src/hooks/line-height.js +3 -3
  224. package/src/hooks/position.js +5 -3
  225. package/src/hooks/use-color-props.js +21 -14
  226. package/src/hooks/utils.js +88 -43
  227. package/src/layouts/constrained.js +3 -8
  228. package/src/utils/object.js +4 -1
  229. package/src/utils/test/__snapshots__/transform-styles.js.snap +103 -0
  230. package/src/utils/test/transform-styles.js +217 -0
  231. package/src/utils/transform-styles/index.js +25 -25
  232. package/build/components/use-setting/index.js +0 -161
  233. package/build/components/use-setting/index.js.map +0 -1
  234. package/build/utils/transform-styles/ast/index.js +0 -21
  235. package/build/utils/transform-styles/ast/index.js.map +0 -1
  236. package/build/utils/transform-styles/ast/parse.js +0 -660
  237. package/build/utils/transform-styles/ast/parse.js.map +0 -1
  238. package/build/utils/transform-styles/ast/stringify/compiler.js +0 -52
  239. package/build/utils/transform-styles/ast/stringify/compiler.js.map +0 -1
  240. package/build/utils/transform-styles/ast/stringify/compress.js +0 -178
  241. package/build/utils/transform-styles/ast/stringify/compress.js.map +0 -1
  242. package/build/utils/transform-styles/ast/stringify/identity.js +0 -207
  243. package/build/utils/transform-styles/ast/stringify/identity.js.map +0 -1
  244. package/build/utils/transform-styles/ast/stringify/index.js +0 -36
  245. package/build/utils/transform-styles/ast/stringify/index.js.map +0 -1
  246. package/build/utils/transform-styles/transforms/url-rewrite.js +0 -130
  247. package/build/utils/transform-styles/transforms/url-rewrite.js.map +0 -1
  248. package/build/utils/transform-styles/transforms/wrap.js +0 -59
  249. package/build/utils/transform-styles/transforms/wrap.js.map +0 -1
  250. package/build/utils/transform-styles/traverse.js +0 -37
  251. package/build/utils/transform-styles/traverse.js.map +0 -1
  252. package/build-module/components/use-setting/index.js +0 -154
  253. package/build-module/components/use-setting/index.js.map +0 -1
  254. package/build-module/utils/transform-styles/ast/index.js +0 -6
  255. package/build-module/utils/transform-styles/ast/index.js.map +0 -1
  256. package/build-module/utils/transform-styles/ast/parse.js +0 -654
  257. package/build-module/utils/transform-styles/ast/parse.js.map +0 -1
  258. package/build-module/utils/transform-styles/ast/stringify/compiler.js +0 -49
  259. package/build-module/utils/transform-styles/ast/stringify/compiler.js.map +0 -1
  260. package/build-module/utils/transform-styles/ast/stringify/compress.js +0 -176
  261. package/build-module/utils/transform-styles/ast/stringify/compress.js.map +0 -1
  262. package/build-module/utils/transform-styles/ast/stringify/identity.js +0 -206
  263. package/build-module/utils/transform-styles/ast/stringify/identity.js.map +0 -1
  264. package/build-module/utils/transform-styles/ast/stringify/index.js +0 -29
  265. package/build-module/utils/transform-styles/ast/stringify/index.js.map +0 -1
  266. package/build-module/utils/transform-styles/transforms/url-rewrite.js +0 -123
  267. package/build-module/utils/transform-styles/transforms/url-rewrite.js.map +0 -1
  268. package/build-module/utils/transform-styles/transforms/wrap.js +0 -52
  269. package/build-module/utils/transform-styles/transforms/wrap.js.map +0 -1
  270. package/build-module/utils/transform-styles/traverse.js +0 -28
  271. package/build-module/utils/transform-styles/traverse.js.map +0 -1
  272. package/src/components/use-setting/index.js +0 -218
  273. package/src/utils/transform-styles/ast/index.js +0 -5
  274. package/src/utils/transform-styles/ast/parse.js +0 -732
  275. package/src/utils/transform-styles/ast/stringify/compiler.js +0 -50
  276. package/src/utils/transform-styles/ast/stringify/compress.js +0 -238
  277. package/src/utils/transform-styles/ast/stringify/identity.js +0 -286
  278. package/src/utils/transform-styles/ast/stringify/index.js +0 -32
  279. package/src/utils/transform-styles/test/__snapshots__/traverse.js.snap +0 -7
  280. package/src/utils/transform-styles/test/traverse.js +0 -24
  281. package/src/utils/transform-styles/transforms/test/__snapshots__/url-rewrite.js.snap +0 -25
  282. package/src/utils/transform-styles/transforms/test/__snapshots__/wrap.js.snap +0 -64
  283. package/src/utils/transform-styles/transforms/test/url-rewrite.js +0 -39
  284. package/src/utils/transform-styles/transforms/test/wrap.js +0 -95
  285. package/src/utils/transform-styles/transforms/url-rewrite.js +0 -139
  286. package/src/utils/transform-styles/transforms/wrap.js +0 -56
  287. package/src/utils/transform-styles/traverse.js +0 -32
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","__","_x","sprintf","getBlockSupport","hasBlockSupport","BaseControl","privateApis","componentsPrivateApis","createHigherOrderComponent","useInstanceId","useSelect","useContext","useMemo","createPortal","Platform","addFilter","BlockList","useSetting","InspectorControls","useBlockDisplayInformation","cleanEmptyObject","unlock","store","blockEditorStore","CustomSelectControl","POSITION_SUPPORT_KEY","OPTION_CLASSNAME","DEFAULT_OPTION","key","value","name","className","STICKY_OPTION","__experimentalHint","FIXED_OPTION","POSITION_SIDES","VALID_POSITION_TYPES","getPositionCSS","selector","style","output","type","positionType","position","includes","forEach","side","undefined","hasStickyPositionSupport","blockType","support","sticky","hasFixedPositionSupport","fixed","hasPositionSupport","hasPositionValue","props","attributes","hasStickyOrFixedPositionValue","resetPosition","setAttributes","top","right","bottom","left","useIsPositionDisabled","blockName","allowFixed","allowSticky","isDisabled","PositionPanel","clientId","firstParentClientId","select","getBlockParents","parents","length","blockInformation","stickyHelpText","title","options","availableOptions","push","onChangeType","next","placementValue","newStyle","selectedOption","find","option","web","createElement","group","__nextHasNoMarginBottom","help","__nextUnconstrainedWidth","__next40pxDefaultSize","label","hideLabelFromVision","describedBy","__experimentalShowSelectedHint","onChange","selectedItem","size","native","withInspectorControls","BlockEdit","positionSupport","isPositionDisabled","showPositionControls","withPositionStyles","BlockListBlock","hasPositionBlockSupport","allowPositionStyles","id","element","__unstableElementContext","positionSelector","css","Fragment"],"sources":["@wordpress/block-editor/src/hooks/position.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport {\n\tBaseControl,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseContext,\n\tuseMemo,\n\tcreatePortal,\n\tPlatform,\n} from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../components/block-list';\nimport useSetting from '../components/use-setting';\nimport InspectorControls from '../components/inspector-controls';\nimport useBlockDisplayInformation from '../components/use-block-display-information';\nimport { cleanEmptyObject } from './utils';\nimport { unlock } from '../lock-unlock';\nimport { store as blockEditorStore } from '../store';\n\nconst { CustomSelectControl } = unlock( componentsPrivateApis );\n\nconst POSITION_SUPPORT_KEY = 'position';\n\nconst OPTION_CLASSNAME =\n\t'block-editor-hooks__position-selection__select-control__option';\n\nconst DEFAULT_OPTION = {\n\tkey: 'default',\n\tvalue: '',\n\tname: __( 'Default' ),\n\tclassName: OPTION_CLASSNAME,\n};\n\nconst STICKY_OPTION = {\n\tkey: 'sticky',\n\tvalue: 'sticky',\n\tname: _x( 'Sticky', 'Name for the value of the CSS position property' ),\n\tclassName: OPTION_CLASSNAME,\n\t__experimentalHint: __(\n\t\t'The block will stick to the top of the window instead of scrolling.'\n\t),\n};\n\nconst FIXED_OPTION = {\n\tkey: 'fixed',\n\tvalue: 'fixed',\n\tname: _x( 'Fixed', 'Name for the value of the CSS position property' ),\n\tclassName: OPTION_CLASSNAME,\n\t__experimentalHint: __(\n\t\t'The block will not move when the page is scrolled.'\n\t),\n};\n\nconst POSITION_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nconst VALID_POSITION_TYPES = [ 'sticky', 'fixed' ];\n\n/**\n * Get calculated position CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.selector Selector to use.\n * @param {Object} props.style Style object.\n * @return {string} The generated CSS rules.\n */\nexport function getPositionCSS( { selector, style } ) {\n\tlet output = '';\n\n\tconst { type: positionType } = style?.position || {};\n\n\tif ( ! VALID_POSITION_TYPES.includes( positionType ) ) {\n\t\treturn output;\n\t}\n\n\toutput += `${ selector } {`;\n\toutput += `position: ${ positionType };`;\n\n\tPOSITION_SIDES.forEach( ( side ) => {\n\t\tif ( style?.position?.[ side ] !== undefined ) {\n\t\t\toutput += `${ side }: ${ style.position[ side ] };`;\n\t\t}\n\t} );\n\n\tif ( positionType === 'sticky' || positionType === 'fixed' ) {\n\t\t// TODO: Replace hard-coded z-index value with a z-index preset approach in theme.json.\n\t\toutput += `z-index: 10`;\n\t}\n\toutput += `}`;\n\n\treturn output;\n}\n\n/**\n * Determines if there is sticky position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasStickyPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.sticky );\n}\n\n/**\n * Determines if there is fixed position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasFixedPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.fixed );\n}\n\n/**\n * Determines if there is position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! support;\n}\n\n/**\n * Checks if there is a current value in the position block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a position value set.\n */\nexport function hasPositionValue( props ) {\n\treturn props.attributes.style?.position?.type !== undefined;\n}\n\n/**\n * Checks if the block is currently set to a sticky or fixed position.\n * This check is helpful for determining how to position block toolbars or other elements.\n *\n * @param {Object} attributes Block attributes.\n * @return {boolean} Whether or not the block is set to a sticky or fixed position.\n */\nexport function hasStickyOrFixedPositionValue( attributes ) {\n\tconst positionType = attributes.style?.position?.type;\n\treturn positionType === 'sticky' || positionType === 'fixed';\n}\n\n/**\n * Resets the position block support attributes. This can be used when disabling\n * the position support controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetPosition( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: undefined,\n\t\t\t\ttop: undefined,\n\t\t\t\tright: undefined,\n\t\t\t\tbottom: undefined,\n\t\t\t\tleft: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if position settings have been disabled.\n *\n * @param {string} name The name of the block.\n *\n * @return {boolean} Whether padding setting is disabled.\n */\nexport function useIsPositionDisabled( { name: blockName } = {} ) {\n\tconst allowFixed = useSetting( 'position.fixed' );\n\tconst allowSticky = useSetting( 'position.sticky' );\n\tconst isDisabled = ! allowFixed && ! allowSticky;\n\n\treturn ! hasPositionSupport( blockName ) || isDisabled;\n}\n\n/*\n * Position controls rendered in an inspector control panel.\n *\n * @param {Object} props\n *\n * @return {Element} Position panel.\n */\nexport function PositionPanel( props ) {\n\tconst {\n\t\tattributes: { style = {} },\n\t\tclientId,\n\t\tname: blockName,\n\t\tsetAttributes,\n\t} = props;\n\n\tconst allowFixed = hasFixedPositionSupport( blockName );\n\tconst allowSticky = hasStickyPositionSupport( blockName );\n\tconst value = style?.position?.type;\n\n\tconst { firstParentClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParents } = select( blockEditorStore );\n\t\t\tconst parents = getBlockParents( clientId );\n\t\t\treturn { firstParentClientId: parents[ parents.length - 1 ] };\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst blockInformation = useBlockDisplayInformation( firstParentClientId );\n\tconst stickyHelpText =\n\t\tallowSticky && value === STICKY_OPTION.value && blockInformation\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: the name of the parent block. */\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The block will stick to the scrollable area of the parent %s block.'\n\t\t\t\t\t),\n\t\t\t\t\tblockInformation.title\n\t\t\t )\n\t\t\t: null;\n\n\tconst options = useMemo( () => {\n\t\tconst availableOptions = [ DEFAULT_OPTION ];\n\t\t// Display options if they are allowed, or if a block already has a valid value set.\n\t\t// This allows for a block to be switched off from a position type that is not allowed.\n\t\tif ( allowSticky || value === STICKY_OPTION.value ) {\n\t\t\tavailableOptions.push( STICKY_OPTION );\n\t\t}\n\t\tif ( allowFixed || value === FIXED_OPTION.value ) {\n\t\t\tavailableOptions.push( FIXED_OPTION );\n\t\t}\n\t\treturn availableOptions;\n\t}, [ allowFixed, allowSticky, value ] );\n\n\tconst onChangeType = ( next ) => {\n\t\t// For now, use a hard-coded `0px` value for the position.\n\t\t// `0px` is preferred over `0` as it can be used in `calc()` functions.\n\t\t// In the future, it could be useful to allow for an offset value.\n\t\tconst placementValue = '0px';\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: next,\n\t\t\t\ttop:\n\t\t\t\t\tnext === 'sticky' || next === 'fixed'\n\t\t\t\t\t\t? placementValue\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\tconst selectedOption = value\n\t\t? options.find( ( option ) => option.value === value ) || DEFAULT_OPTION\n\t\t: DEFAULT_OPTION;\n\n\t// Only display position controls if there is at least one option to choose from.\n\treturn Platform.select( {\n\t\tweb:\n\t\t\toptions.length > 1 ? (\n\t\t\t\t<InspectorControls group=\"position\">\n\t\t\t\t\t<BaseControl\n\t\t\t\t\t\tclassName=\"block-editor-hooks__position-selection\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\thelp={ stickyHelpText }\n\t\t\t\t\t>\n\t\t\t\t\t\t<CustomSelectControl\n\t\t\t\t\t\t\t__nextUnconstrainedWidth\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__position-selection__select-control\"\n\t\t\t\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tdescribedBy={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Currently selected position.\n\t\t\t\t\t\t\t\t__( 'Currently selected position: %s' ),\n\t\t\t\t\t\t\t\tselectedOption.name\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\toptions={ options }\n\t\t\t\t\t\t\tvalue={ selectedOption }\n\t\t\t\t\t\t\t__experimentalShowSelectedHint\n\t\t\t\t\t\t\tonChange={ ( { selectedItem } ) => {\n\t\t\t\t\t\t\t\tonChangeType( selectedItem.value );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BaseControl>\n\t\t\t\t</InspectorControls>\n\t\t\t) : null,\n\t\tnative: null,\n\t} );\n}\n\n/**\n * Override the default edit UI to include position controls.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withInspectorControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name: blockName } = props;\n\t\tconst positionSupport = hasBlockSupport(\n\t\t\tblockName,\n\t\t\tPOSITION_SUPPORT_KEY\n\t\t);\n\t\tconst isPositionDisabled = useIsPositionDisabled( props );\n\t\tconst showPositionControls = positionSupport && ! isPositionDisabled;\n\n\t\treturn [\n\t\t\tshowPositionControls && (\n\t\t\t\t<PositionPanel key=\"position\" { ...props } />\n\t\t\t),\n\t\t\t<BlockEdit key=\"edit\" { ...props } />,\n\t\t];\n\t},\n\t'withInspectorControls'\n);\n\n/**\n * Override the default block element to add the position styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withPositionStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst hasPositionBlockSupport = hasBlockSupport(\n\t\t\tname,\n\t\t\tPOSITION_SUPPORT_KEY\n\t\t);\n\t\tconst isPositionDisabled = useIsPositionDisabled( props );\n\t\tconst allowPositionStyles =\n\t\t\thasPositionBlockSupport && ! isPositionDisabled;\n\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\t// Higher specificity to override defaults in editor UI.\n\t\tconst positionSelector = `.wp-container-${ id }.wp-container-${ id }`;\n\n\t\t// Get CSS string for the current position values.\n\t\tlet css;\n\t\tif ( allowPositionStyles ) {\n\t\t\tcss =\n\t\t\t\tgetPositionCSS( {\n\t\t\t\t\tselector: positionSelector,\n\t\t\t\t\tstyle: attributes?.style,\n\t\t\t\t} ) || '';\n\t\t}\n\n\t\t// Attach a `wp-container-` id-based class name.\n\t\tconst className = classnames( props?.className, {\n\t\t\t[ `wp-container-${ id }` ]: allowPositionStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t\t[ `is-position-${ attributes?.style?.position?.type }` ]:\n\t\t\t\tallowPositionStyles &&\n\t\t\t\t!! css &&\n\t\t\t\t!! attributes?.style?.position?.type,\n\t\t} );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ allowPositionStyles &&\n\t\t\t\t\telement &&\n\t\t\t\t\t!! css &&\n\t\t\t\t\tcreatePortal( <style>{ css }</style>, element ) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withPositionStyles'\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/position/with-position-styles',\n\twithPositionStyles\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/position/with-inspector-controls',\n\twithInspectorControls\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SAASC,eAAe,EAAEC,eAAe,QAAQ,mBAAmB;AACpE,SACCC,WAAW,EACXC,WAAW,IAAIC,qBAAqB,QAC9B,uBAAuB;AAC9B,SAASC,0BAA0B,EAAEC,aAAa,QAAQ,oBAAoB;AAC9E,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,UAAU,EACVC,OAAO,EACPC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AAEDhB,SAAS,CACR,uBAAuB,EACvB,2CAA2C,EAC3C+F,kBACD,CAAC;AACD/F,SAAS,CACR,kBAAkB,EAClB,8CAA8C,EAC9C0F,qBACD,CAAC"}
1
+ {"version":3,"names":["classnames","__","_x","sprintf","getBlockSupport","hasBlockSupport","BaseControl","privateApis","componentsPrivateApis","createHigherOrderComponent","useInstanceId","useSelect","useContext","useMemo","createPortal","Platform","addFilter","BlockList","useSettings","InspectorControls","useBlockDisplayInformation","cleanEmptyObject","unlock","store","blockEditorStore","CustomSelectControl","POSITION_SUPPORT_KEY","OPTION_CLASSNAME","DEFAULT_OPTION","key","value","name","className","STICKY_OPTION","__experimentalHint","FIXED_OPTION","POSITION_SIDES","VALID_POSITION_TYPES","getPositionCSS","selector","style","output","type","positionType","position","includes","forEach","side","undefined","hasStickyPositionSupport","blockType","support","sticky","hasFixedPositionSupport","fixed","hasPositionSupport","hasPositionValue","props","attributes","hasStickyOrFixedPositionValue","resetPosition","setAttributes","top","right","bottom","left","useIsPositionDisabled","blockName","allowFixed","allowSticky","isDisabled","PositionPanel","clientId","firstParentClientId","select","getBlockParents","parents","length","blockInformation","stickyHelpText","title","options","availableOptions","push","onChangeType","next","placementValue","newStyle","selectedOption","find","option","web","createElement","group","__nextHasNoMarginBottom","help","__nextUnconstrainedWidth","__next40pxDefaultSize","label","hideLabelFromVision","describedBy","__experimentalShowSelectedHint","onChange","selectedItem","size","native","withInspectorControls","BlockEdit","positionSupport","isPositionDisabled","showPositionControls","withPositionStyles","BlockListBlock","hasPositionBlockSupport","allowPositionStyles","id","element","__unstableElementContext","positionSelector","css","Fragment"],"sources":["@wordpress/block-editor/src/hooks/position.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport {\n\tBaseControl,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseContext,\n\tuseMemo,\n\tcreatePortal,\n\tPlatform,\n} from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../components/block-list';\nimport { useSettings } from '../components/use-settings';\nimport InspectorControls from '../components/inspector-controls';\nimport useBlockDisplayInformation from '../components/use-block-display-information';\nimport { cleanEmptyObject } from './utils';\nimport { unlock } from '../lock-unlock';\nimport { store as blockEditorStore } from '../store';\n\nconst { CustomSelectControl } = unlock( componentsPrivateApis );\n\nconst POSITION_SUPPORT_KEY = 'position';\n\nconst OPTION_CLASSNAME =\n\t'block-editor-hooks__position-selection__select-control__option';\n\nconst DEFAULT_OPTION = {\n\tkey: 'default',\n\tvalue: '',\n\tname: __( 'Default' ),\n\tclassName: OPTION_CLASSNAME,\n};\n\nconst STICKY_OPTION = {\n\tkey: 'sticky',\n\tvalue: 'sticky',\n\tname: _x( 'Sticky', 'Name for the value of the CSS position property' ),\n\tclassName: OPTION_CLASSNAME,\n\t__experimentalHint: __(\n\t\t'The block will stick to the top of the window instead of scrolling.'\n\t),\n};\n\nconst FIXED_OPTION = {\n\tkey: 'fixed',\n\tvalue: 'fixed',\n\tname: _x( 'Fixed', 'Name for the value of the CSS position property' ),\n\tclassName: OPTION_CLASSNAME,\n\t__experimentalHint: __(\n\t\t'The block will not move when the page is scrolled.'\n\t),\n};\n\nconst POSITION_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nconst VALID_POSITION_TYPES = [ 'sticky', 'fixed' ];\n\n/**\n * Get calculated position CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.selector Selector to use.\n * @param {Object} props.style Style object.\n * @return {string} The generated CSS rules.\n */\nexport function getPositionCSS( { selector, style } ) {\n\tlet output = '';\n\n\tconst { type: positionType } = style?.position || {};\n\n\tif ( ! VALID_POSITION_TYPES.includes( positionType ) ) {\n\t\treturn output;\n\t}\n\n\toutput += `${ selector } {`;\n\toutput += `position: ${ positionType };`;\n\n\tPOSITION_SIDES.forEach( ( side ) => {\n\t\tif ( style?.position?.[ side ] !== undefined ) {\n\t\t\toutput += `${ side }: ${ style.position[ side ] };`;\n\t\t}\n\t} );\n\n\tif ( positionType === 'sticky' || positionType === 'fixed' ) {\n\t\t// TODO: Replace hard-coded z-index value with a z-index preset approach in theme.json.\n\t\toutput += `z-index: 10`;\n\t}\n\toutput += `}`;\n\n\treturn output;\n}\n\n/**\n * Determines if there is sticky position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasStickyPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.sticky );\n}\n\n/**\n * Determines if there is fixed position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasFixedPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.fixed );\n}\n\n/**\n * Determines if there is position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! support;\n}\n\n/**\n * Checks if there is a current value in the position block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a position value set.\n */\nexport function hasPositionValue( props ) {\n\treturn props.attributes.style?.position?.type !== undefined;\n}\n\n/**\n * Checks if the block is currently set to a sticky or fixed position.\n * This check is helpful for determining how to position block toolbars or other elements.\n *\n * @param {Object} attributes Block attributes.\n * @return {boolean} Whether or not the block is set to a sticky or fixed position.\n */\nexport function hasStickyOrFixedPositionValue( attributes ) {\n\tconst positionType = attributes.style?.position?.type;\n\treturn positionType === 'sticky' || positionType === 'fixed';\n}\n\n/**\n * Resets the position block support attributes. This can be used when disabling\n * the position support controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetPosition( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: undefined,\n\t\t\t\ttop: undefined,\n\t\t\t\tright: undefined,\n\t\t\t\tbottom: undefined,\n\t\t\t\tleft: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if position settings have been disabled.\n *\n * @param {string} name The name of the block.\n *\n * @return {boolean} Whether padding setting is disabled.\n */\nexport function useIsPositionDisabled( { name: blockName } = {} ) {\n\tconst [ allowFixed, allowSticky ] = useSettings(\n\t\t'position.fixed',\n\t\t'position.sticky'\n\t);\n\tconst isDisabled = ! allowFixed && ! allowSticky;\n\n\treturn ! hasPositionSupport( blockName ) || isDisabled;\n}\n\n/*\n * Position controls rendered in an inspector control panel.\n *\n * @param {Object} props\n *\n * @return {Element} Position panel.\n */\nexport function PositionPanel( props ) {\n\tconst {\n\t\tattributes: { style = {} },\n\t\tclientId,\n\t\tname: blockName,\n\t\tsetAttributes,\n\t} = props;\n\n\tconst allowFixed = hasFixedPositionSupport( blockName );\n\tconst allowSticky = hasStickyPositionSupport( blockName );\n\tconst value = style?.position?.type;\n\n\tconst { firstParentClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParents } = select( blockEditorStore );\n\t\t\tconst parents = getBlockParents( clientId );\n\t\t\treturn { firstParentClientId: parents[ parents.length - 1 ] };\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst blockInformation = useBlockDisplayInformation( firstParentClientId );\n\tconst stickyHelpText =\n\t\tallowSticky && value === STICKY_OPTION.value && blockInformation\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: the name of the parent block. */\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The block will stick to the scrollable area of the parent %s block.'\n\t\t\t\t\t),\n\t\t\t\t\tblockInformation.title\n\t\t\t )\n\t\t\t: null;\n\n\tconst options = useMemo( () => {\n\t\tconst availableOptions = [ DEFAULT_OPTION ];\n\t\t// Display options if they are allowed, or if a block already has a valid value set.\n\t\t// This allows for a block to be switched off from a position type that is not allowed.\n\t\tif ( allowSticky || value === STICKY_OPTION.value ) {\n\t\t\tavailableOptions.push( STICKY_OPTION );\n\t\t}\n\t\tif ( allowFixed || value === FIXED_OPTION.value ) {\n\t\t\tavailableOptions.push( FIXED_OPTION );\n\t\t}\n\t\treturn availableOptions;\n\t}, [ allowFixed, allowSticky, value ] );\n\n\tconst onChangeType = ( next ) => {\n\t\t// For now, use a hard-coded `0px` value for the position.\n\t\t// `0px` is preferred over `0` as it can be used in `calc()` functions.\n\t\t// In the future, it could be useful to allow for an offset value.\n\t\tconst placementValue = '0px';\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: next,\n\t\t\t\ttop:\n\t\t\t\t\tnext === 'sticky' || next === 'fixed'\n\t\t\t\t\t\t? placementValue\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\tconst selectedOption = value\n\t\t? options.find( ( option ) => option.value === value ) || DEFAULT_OPTION\n\t\t: DEFAULT_OPTION;\n\n\t// Only display position controls if there is at least one option to choose from.\n\treturn Platform.select( {\n\t\tweb:\n\t\t\toptions.length > 1 ? (\n\t\t\t\t<InspectorControls group=\"position\">\n\t\t\t\t\t<BaseControl\n\t\t\t\t\t\tclassName=\"block-editor-hooks__position-selection\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\thelp={ stickyHelpText }\n\t\t\t\t\t>\n\t\t\t\t\t\t<CustomSelectControl\n\t\t\t\t\t\t\t__nextUnconstrainedWidth\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__position-selection__select-control\"\n\t\t\t\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tdescribedBy={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Currently selected position.\n\t\t\t\t\t\t\t\t__( 'Currently selected position: %s' ),\n\t\t\t\t\t\t\t\tselectedOption.name\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\toptions={ options }\n\t\t\t\t\t\t\tvalue={ selectedOption }\n\t\t\t\t\t\t\t__experimentalShowSelectedHint\n\t\t\t\t\t\t\tonChange={ ( { selectedItem } ) => {\n\t\t\t\t\t\t\t\tonChangeType( selectedItem.value );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BaseControl>\n\t\t\t\t</InspectorControls>\n\t\t\t) : null,\n\t\tnative: null,\n\t} );\n}\n\n/**\n * Override the default edit UI to include position controls.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withInspectorControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name: blockName } = props;\n\t\tconst positionSupport = hasBlockSupport(\n\t\t\tblockName,\n\t\t\tPOSITION_SUPPORT_KEY\n\t\t);\n\t\tconst isPositionDisabled = useIsPositionDisabled( props );\n\t\tconst showPositionControls = positionSupport && ! isPositionDisabled;\n\n\t\treturn [\n\t\t\tshowPositionControls && (\n\t\t\t\t<PositionPanel key=\"position\" { ...props } />\n\t\t\t),\n\t\t\t<BlockEdit key=\"edit\" { ...props } />,\n\t\t];\n\t},\n\t'withInspectorControls'\n);\n\n/**\n * Override the default block element to add the position styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withPositionStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst hasPositionBlockSupport = hasBlockSupport(\n\t\t\tname,\n\t\t\tPOSITION_SUPPORT_KEY\n\t\t);\n\t\tconst isPositionDisabled = useIsPositionDisabled( props );\n\t\tconst allowPositionStyles =\n\t\t\thasPositionBlockSupport && ! isPositionDisabled;\n\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\t// Higher specificity to override defaults in editor UI.\n\t\tconst positionSelector = `.wp-container-${ id }.wp-container-${ id }`;\n\n\t\t// Get CSS string for the current position values.\n\t\tlet css;\n\t\tif ( allowPositionStyles ) {\n\t\t\tcss =\n\t\t\t\tgetPositionCSS( {\n\t\t\t\t\tselector: positionSelector,\n\t\t\t\t\tstyle: attributes?.style,\n\t\t\t\t} ) || '';\n\t\t}\n\n\t\t// Attach a `wp-container-` id-based class name.\n\t\tconst className = classnames( props?.className, {\n\t\t\t[ `wp-container-${ id }` ]: allowPositionStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t\t[ `is-position-${ attributes?.style?.position?.type }` ]:\n\t\t\t\tallowPositionStyles &&\n\t\t\t\t!! css &&\n\t\t\t\t!! attributes?.style?.position?.type,\n\t\t} );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ allowPositionStyles &&\n\t\t\t\t\telement &&\n\t\t\t\t\t!! css &&\n\t\t\t\t\tcreatePortal( <style>{ css }</style>, element ) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withPositionStyles'\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/position/with-position-styles',\n\twithPositionStyles\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/position/with-inspector-controls',\n\twithInspectorControls\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU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AAEF;EAClC,CAAE,CAAC;EAEH,OACCkD,aAAA,CAAA4B,QAAA,QACGN,mBAAmB,IACpBE,OAAO,IACP,CAAC,CAAEG,GAAG,IACNzG,YAAY,CAAE8E,aAAA,gBAAS2B,GAAY,CAAC,EAAEH,OAAQ,CAAC,EAChDxB,aAAA,CAACoB,cAAc;IAAA,GAAMvD,KAAK;IAAGzB,SAAS,EAAGA;EAAW,CAAE,CACrD,CAAC;AAEL,CAAC,EACD,oBACD,CAAC;AAEDhB,SAAS,CACR,uBAAuB,EACvB,2CAA2C,EAC3C+F,kBACD,CAAC;AACD/F,SAAS,CACR,kBAAkB,EAClB,8CAA8C,EAC9C0F,qBACD,CAAC"}
@@ -14,7 +14,7 @@ import { useMemo } from '@wordpress/element';
14
14
  import { getInlineStyles } from './style';
15
15
  import { getColorClassName, getColorObjectByAttributeValues } from '../components/colors';
16
16
  import { __experimentalGetGradientClass, getGradientValueBySlug } from '../components/gradients';
17
- import useSetting from '../components/use-setting';
17
+ import { useSettings } from '../components/use-settings';
18
18
 
19
19
  // The code in this file has largely been lifted from the color block support
20
20
  // hook.
@@ -64,7 +64,6 @@ export function getColorClassesAndStyles(attributes) {
64
64
  style: styleProp
65
65
  };
66
66
  }
67
- const EMPTY_OBJECT = {};
68
67
 
69
68
  /**
70
69
  * Determines the color related props for a block derived from its color block
@@ -83,16 +82,9 @@ export function useColorProps(attributes) {
83
82
  textColor,
84
83
  gradient
85
84
  } = attributes;
86
-
87
- // Some color settings have a special handling for deprecated flags in `useSetting`,
88
- // so we can't unwrap them by doing const { ... } = useSetting('color')
89
- // until https://github.com/WordPress/gutenberg/issues/37094 is fixed.
90
- const userPalette = useSetting('color.palette.custom');
91
- const themePalette = useSetting('color.palette.theme');
92
- const defaultPalette = useSetting('color.palette.default');
93
- const gradientsPerOrigin = useSetting('color.gradients') || EMPTY_OBJECT;
85
+ const [userPalette, themePalette, defaultPalette, userGradients, themeGradients, defaultGradients] = useSettings('color.palette.custom', 'color.palette.theme', 'color.palette.default', 'color.gradients.custom', 'color.gradients.theme', 'color.gradients.default');
94
86
  const colors = useMemo(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]);
95
- const gradients = useMemo(() => [...(gradientsPerOrigin?.custom || []), ...(gradientsPerOrigin?.theme || []), ...(gradientsPerOrigin?.default || [])], [gradientsPerOrigin]);
87
+ const gradients = useMemo(() => [...(userGradients || []), ...(themeGradients || []), ...(defaultGradients || [])], [userGradients, themeGradients, defaultGradients]);
96
88
  const colorProps = getColorClassesAndStyles(attributes);
97
89
 
98
90
  // Force inline styles to apply colors when themes do not load their color
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","useMemo","getInlineStyles","getColorClassName","getColorObjectByAttributeValues","__experimentalGetGradientClass","getGradientValueBySlug","useSetting","getColorClassesAndStyles","attributes","backgroundColor","textColor","gradient","style","backgroundClass","textClass","gradientClass","hasGradient","color","className","text","background","elements","link","colorStyles","styleProp","undefined","EMPTY_OBJECT","useColorProps","userPalette","themePalette","defaultPalette","gradientsPerOrigin","colors","gradients","custom","theme","default","colorProps","backgroundColorObject","textColorObject"],"sources":["@wordpress/block-editor/src/hooks/use-color-props.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { getInlineStyles } from './style';\nimport {\n\tgetColorClassName,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport {\n\t__experimentalGetGradientClass,\n\tgetGradientValueBySlug,\n} from '../components/gradients';\nimport useSetting from '../components/use-setting';\n\n// The code in this file has largely been lifted from the color block support\n// hook.\n//\n// This utility is intended to assist where the serialization of the colors\n// block support is being skipped for a block but the color related CSS classes\n// & styles still need to be generated so they can be applied to inner elements.\n\n/**\n * Provides the CSS class names and inline styles for a block's color support\n * attributes.\n *\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Color block support derived CSS classes & styles.\n */\nexport function getColorClassesAndStyles( attributes ) {\n\tconst { backgroundColor, textColor, gradient, style } = attributes;\n\n\t// Collect color CSS classes.\n\tconst backgroundClass = getColorClassName(\n\t\t'background-color',\n\t\tbackgroundColor\n\t);\n\tconst textClass = getColorClassName( 'color', textColor );\n\n\tconst gradientClass = __experimentalGetGradientClass( gradient );\n\tconst hasGradient = gradientClass || style?.color?.gradient;\n\n\t// Determine color CSS class name list.\n\tconst className = classnames( textClass, gradientClass, {\n\t\t// Don't apply the background class if there's a gradient.\n\t\t[ backgroundClass ]: ! hasGradient && !! backgroundClass,\n\t\t'has-text-color': textColor || style?.color?.text,\n\t\t'has-background':\n\t\t\tbackgroundColor ||\n\t\t\tstyle?.color?.background ||\n\t\t\tgradient ||\n\t\t\tstyle?.color?.gradient,\n\t\t'has-link-color': style?.elements?.link?.color,\n\t} );\n\n\t// Collect inline styles for colors.\n\tconst colorStyles = style?.color || {};\n\tconst styleProp = getInlineStyles( { color: colorStyles } );\n\n\treturn {\n\t\tclassName: className || undefined,\n\t\tstyle: styleProp,\n\t};\n}\n\nconst EMPTY_OBJECT = {};\n\n/**\n * Determines the color related props for a block derived from its color block\n * support attributes.\n *\n * Inline styles are forced for named colors to ensure these selections are\n * reflected when themes do not load their color stylesheets in the editor.\n *\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} ClassName & style props from colors block support.\n */\nexport function useColorProps( attributes ) {\n\tconst { backgroundColor, textColor, gradient } = attributes;\n\n\t// Some color settings have a special handling for deprecated flags in `useSetting`,\n\t// so we can't unwrap them by doing const { ... } = useSetting('color')\n\t// until https://github.com/WordPress/gutenberg/issues/37094 is fixed.\n\tconst userPalette = useSetting( 'color.palette.custom' );\n\tconst themePalette = useSetting( 'color.palette.theme' );\n\tconst defaultPalette = useSetting( 'color.palette.default' );\n\tconst gradientsPerOrigin = useSetting( 'color.gradients' ) || EMPTY_OBJECT;\n\tconst colors = useMemo(\n\t\t() => [\n\t\t\t...( userPalette || [] ),\n\t\t\t...( themePalette || [] ),\n\t\t\t...( defaultPalette || [] ),\n\t\t],\n\t\t[ userPalette, themePalette, defaultPalette ]\n\t);\n\tconst gradients = useMemo(\n\t\t() => [\n\t\t\t...( gradientsPerOrigin?.custom || [] ),\n\t\t\t...( gradientsPerOrigin?.theme || [] ),\n\t\t\t...( gradientsPerOrigin?.default || [] ),\n\t\t],\n\t\t[ gradientsPerOrigin ]\n\t);\n\n\tconst colorProps = getColorClassesAndStyles( attributes );\n\n\t// Force inline styles to apply colors when themes do not load their color\n\t// stylesheets in the editor.\n\tif ( backgroundColor ) {\n\t\tconst backgroundColorObject = getColorObjectByAttributeValues(\n\t\t\tcolors,\n\t\t\tbackgroundColor\n\t\t);\n\n\t\tcolorProps.style.backgroundColor = backgroundColorObject.color;\n\t}\n\n\tif ( gradient ) {\n\t\tcolorProps.style.background = getGradientValueBySlug(\n\t\t\tgradients,\n\t\t\tgradient\n\t\t);\n\t}\n\n\tif ( textColor ) {\n\t\tconst textColorObject = getColorObjectByAttributeValues(\n\t\t\tcolors,\n\t\t\ttextColor\n\t\t);\n\n\t\tcolorProps.style.color = textColorObject.color;\n\t}\n\n\treturn colorProps;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,SAASC,eAAe,QAAQ,SAAS;AACzC,SACCC,iBAAiB,EACjBC,+BAA+B,QACzB,sBAAsB;AAC7B,SACCC,8BAA8B,EAC9BC,sBAAsB,QAChB,yBAAyB;AAChC,OAAOC,UAAU,MAAM,2BAA2B;;AAElD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CAAEC,UAAU,EAAG;EACtD,MAAM;IAAEC,eAAe;IAAEC,SAAS;IAAEC,QAAQ;IAAEC;EAAM,CAAC,GAAGJ,UAAU;;EAElE;EAC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AsB,CAAC;EACxD,MAAMwB,cAAc,GAAGxB,UAAU,CAAE,uBAAwB,CAAC;EAC5D,MAAMyB,kBAAkB,GAAGzB,UAAU,CAAE,iBAAkB,CAAC,IAAIoB,YAAY;EAC1E,MAAMM,MAAM,GAAGhC,OAAO,CACrB,MAAM,CACL,IAAK4B,WAAW,IAAI,EAAE,CAAE,EACxB,IAAKC,YAAY,IAAI,EAAE,CAAE,EACzB,IAAKC,cAAc,IAAI,EAAE,CAAE,CAC3B,EACD,CAAEF,WAAW,EAAEC,YAAY,EAAEC,cAAc,CAC5C,CAAC;EACD,MAAMG,SAAS,GAAGjC,OAAO,CACxB,MAAM,CACL,IAAK+B,kBAAkB,EAAEG,MAAM,IAAI,EAAE,CAAE,EACvC,IAAKH,kBAAkB,EAAEI,KAAK,IAAI,EAAE,CAAE,EACtC,IAAKJ,kBAAkB,EAAEK,OAAO,IAAI,EAAE,CAAE,CACxC,EACD,CAAEL,kBAAkB,CACrB,CAAC;EAED,MAAMM,UAAU,GAAG9B,wBAAwB,CAAEC,UAAW,CAAC;;EAEzD;EACA;EACA,IAAKC,eAAe,EAAG;IACtB,MAAM6B,qBAAqB,GAAGnC,+BAA+B,CAC5D6B,MAAM,EACNvB,eACD,CAAC;IAED4B,UAAU,CAACzB,KAAK,CAACH,eAAe,GAAG6B,qBAAqB,CAACrB,KAAK;EAC/D;EAEA,IAAKN,QAAQ,EAAG;IACf0B,UAAU,CAACzB,KAAK,CAACQ,UAAU,GAAGf,sBAAsB,CACnD4B,SAAS,EACTtB,QACD,CAAC;EACF;EAEA,IAAKD,SAAS,EAAG;IAChB,MAAM6B,eAAe,GAAGpC,+BAA+B,CACtD6B,MAAM,EACNtB,SACD,CAAC;IAED2B,UAAU,CAACzB,KAAK,CAACK,KAAK,GAAGsB,eAAe,CAACtB,KAAK;EAC/C;EAEA,OAAOoB,UAAU;AAClB"}
1
+ {"version":3,"names":["classnames","useMemo","getInlineStyles","getColorClassName","getColorObjectByAttributeValues","__experimentalGetGradientClass","getGradientValueBySlug","useSettings","getColorClassesAndStyles","attributes","backgroundColor","textColor","gradient","style","backgroundClass","textClass","gradientClass","hasGradient","color","className","text","background","elements","link","colorStyles","styleProp","undefined","useColorProps","userPalette","themePalette","defaultPalette","userGradients","themeGradients","defaultGradients","colors","gradients","colorProps","backgroundColorObject","textColorObject"],"sources":["@wordpress/block-editor/src/hooks/use-color-props.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { getInlineStyles } from './style';\nimport {\n\tgetColorClassName,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport {\n\t__experimentalGetGradientClass,\n\tgetGradientValueBySlug,\n} from '../components/gradients';\nimport { useSettings } from '../components/use-settings';\n\n// The code in this file has largely been lifted from the color block support\n// hook.\n//\n// This utility is intended to assist where the serialization of the colors\n// block support is being skipped for a block but the color related CSS classes\n// & styles still need to be generated so they can be applied to inner elements.\n\n/**\n * Provides the CSS class names and inline styles for a block's color support\n * attributes.\n *\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Color block support derived CSS classes & styles.\n */\nexport function getColorClassesAndStyles( attributes ) {\n\tconst { backgroundColor, textColor, gradient, style } = attributes;\n\n\t// Collect color CSS classes.\n\tconst backgroundClass = getColorClassName(\n\t\t'background-color',\n\t\tbackgroundColor\n\t);\n\tconst textClass = getColorClassName( 'color', textColor );\n\n\tconst gradientClass = __experimentalGetGradientClass( gradient );\n\tconst hasGradient = gradientClass || style?.color?.gradient;\n\n\t// Determine color CSS class name list.\n\tconst className = classnames( textClass, gradientClass, {\n\t\t// Don't apply the background class if there's a gradient.\n\t\t[ backgroundClass ]: ! hasGradient && !! backgroundClass,\n\t\t'has-text-color': textColor || style?.color?.text,\n\t\t'has-background':\n\t\t\tbackgroundColor ||\n\t\t\tstyle?.color?.background ||\n\t\t\tgradient ||\n\t\t\tstyle?.color?.gradient,\n\t\t'has-link-color': style?.elements?.link?.color,\n\t} );\n\n\t// Collect inline styles for colors.\n\tconst colorStyles = style?.color || {};\n\tconst styleProp = getInlineStyles( { color: colorStyles } );\n\n\treturn {\n\t\tclassName: className || undefined,\n\t\tstyle: styleProp,\n\t};\n}\n\n/**\n * Determines the color related props for a block derived from its color block\n * support attributes.\n *\n * Inline styles are forced for named colors to ensure these selections are\n * reflected when themes do not load their color stylesheets in the editor.\n *\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} ClassName & style props from colors block support.\n */\nexport function useColorProps( attributes ) {\n\tconst { backgroundColor, textColor, gradient } = attributes;\n\n\tconst [\n\t\tuserPalette,\n\t\tthemePalette,\n\t\tdefaultPalette,\n\t\tuserGradients,\n\t\tthemeGradients,\n\t\tdefaultGradients,\n\t] = useSettings(\n\t\t'color.palette.custom',\n\t\t'color.palette.theme',\n\t\t'color.palette.default',\n\t\t'color.gradients.custom',\n\t\t'color.gradients.theme',\n\t\t'color.gradients.default'\n\t);\n\n\tconst colors = useMemo(\n\t\t() => [\n\t\t\t...( userPalette || [] ),\n\t\t\t...( themePalette || [] ),\n\t\t\t...( defaultPalette || [] ),\n\t\t],\n\t\t[ userPalette, themePalette, defaultPalette ]\n\t);\n\tconst gradients = useMemo(\n\t\t() => [\n\t\t\t...( userGradients || [] ),\n\t\t\t...( themeGradients || [] ),\n\t\t\t...( defaultGradients || [] ),\n\t\t],\n\t\t[ userGradients, themeGradients, defaultGradients ]\n\t);\n\n\tconst colorProps = getColorClassesAndStyles( attributes );\n\n\t// Force inline styles to apply colors when themes do not load their color\n\t// stylesheets in the editor.\n\tif ( backgroundColor ) {\n\t\tconst backgroundColorObject = getColorObjectByAttributeValues(\n\t\t\tcolors,\n\t\t\tbackgroundColor\n\t\t);\n\n\t\tcolorProps.style.backgroundColor = backgroundColorObject.color;\n\t}\n\n\tif ( gradient ) {\n\t\tcolorProps.style.background = getGradientValueBySlug(\n\t\t\tgradients,\n\t\t\tgradient\n\t\t);\n\t}\n\n\tif ( textColor ) {\n\t\tconst textColorObject = getColorObjectByAttributeValues(\n\t\t\tcolors,\n\t\t\ttextColor\n\t\t);\n\n\t\tcolorProps.style.color = textColorObject.color;\n\t}\n\n\treturn colorProps;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,SAASC,eAAe,QAAQ,SAAS;AACzC,SACCC,iBAAiB,EACjBC,+BAA+B,QACzB,sBAAsB;AAC7B,SACCC,8BAA8B,EAC9BC,sBAAsB,QAChB,yBAAyB;AAChC,SAASC,WAAW,QAAQ,4BAA4B;;AAExD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CAAEC,UAAU,EAAG;EACtD,MAAM;IAAEC,eAAe;IAAEC,SAAS;IAAEC,QAAQ;IAAEC;EAAM,CAAC,GAAGJ,UAAU;;EAElE;EACA,MAAMK,eAAe,GAAGX,iBAAiB,CACxC,kBAAkB,EAClBO,eACD,CAAC;EACD,MAAMK,SAAS,GAAGZ,iBAAiB,CAAE,OAAO,EAAEQ,SAAU,CAAC;EAEzD,MAAMK,aAAa,GAAGX,8BAA8B,CAAEO,QAAS,CAAC;EAChE,MAAMK,WAAW,GAAGD,aAAa,IAAIH,KAAK,EAAEK,KAAK,EAAEN,QAAQ;;EAE3D;EACA,MAAMO,SAAS,GAAGnB,UAAU,CAAEe,SAAS,EAAEC,aAAa,EAAE;IACvD;IACA,CAAEF,eAAe,GAAI,CAAEG,WAAW,IAAI,CAAC,CAAEH,eAAe;IACxD,gBAAgB,EAAEH,SAAS,IAAIE,KAAK,EAAEK,KAAK,EAAEE,IAAI;IACjD,gBAAgB,EACfV,eAAe,IACfG,KAAK,EAAEK,KAAK,EAAEG,UAAU,IACxBT,QAAQ,IACRC,KAAK,EAAEK,KAAK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eAAe,EAAG;IACtB,MAAM2B,qBAAqB,GAAGjC,+BAA+B,CAC5D8B,MAAM,EACNxB,eACD,CAAC;IAED0B,UAAU,CAACvB,KAAK,CAACH,eAAe,GAAG2B,qBAAqB,CAACnB,KAAK;EAC/D;EAEA,IAAKN,QAAQ,EAAG;IACfwB,UAAU,CAACvB,KAAK,CAACQ,UAAU,GAAGf,sBAAsB,CACnD6B,SAAS,EACTvB,QACD,CAAC;EACF;EAEA,IAAKD,SAAS,EAAG;IAChB,MAAM2B,eAAe,GAAGlC,+BAA+B,CACtD8B,MAAM,EACNvB,SACD,CAAC;IAEDyB,UAAU,CAACvB,KAAK,CAACK,KAAK,GAAGoB,eAAe,CAACpB,KAAK;EAC/C;EAEA,OAAOkB,UAAU;AAClB"}
@@ -7,7 +7,7 @@ import { useMemo } from '@wordpress/element';
7
7
  /**
8
8
  * Internal dependencies
9
9
  */
10
- import { useSetting } from '../components';
10
+ import { useSettings } from '../components';
11
11
  import { useSettingsForBlockElement } from '../components/global-styles/hooks';
12
12
  import { getValueFromObjectPath, setImmutably } from '../utils/object';
13
13
 
@@ -96,48 +96,7 @@ export function shouldSkipSerialization(blockType, featureSet, feature) {
96
96
  * @return {Object} Settings object.
97
97
  */
98
98
  export function useBlockSettings(name, parentLayout) {
99
- const fontFamilies = useSetting('typography.fontFamilies');
100
- const fontSizes = useSetting('typography.fontSizes');
101
- const customFontSize = useSetting('typography.customFontSize');
102
- const fontStyle = useSetting('typography.fontStyle');
103
- const fontWeight = useSetting('typography.fontWeight');
104
- const lineHeight = useSetting('typography.lineHeight');
105
- const textColumns = useSetting('typography.textColumns');
106
- const textDecoration = useSetting('typography.textDecoration');
107
- const writingMode = useSetting('typography.writingMode');
108
- const textTransform = useSetting('typography.textTransform');
109
- const letterSpacing = useSetting('typography.letterSpacing');
110
- const padding = useSetting('spacing.padding');
111
- const margin = useSetting('spacing.margin');
112
- const blockGap = useSetting('spacing.blockGap');
113
- const spacingSizes = useSetting('spacing.spacingSizes');
114
- const units = useSetting('spacing.units');
115
- const minHeight = useSetting('dimensions.minHeight');
116
- const layout = useSetting('layout');
117
- const borderColor = useSetting('border.color');
118
- const borderRadius = useSetting('border.radius');
119
- const borderStyle = useSetting('border.style');
120
- const borderWidth = useSetting('border.width');
121
- const customColorsEnabled = useSetting('color.custom');
122
- const customColors = useSetting('color.palette.custom');
123
- const customDuotone = useSetting('color.customDuotone');
124
- const themeColors = useSetting('color.palette.theme');
125
- const defaultColors = useSetting('color.palette.default');
126
- const defaultPalette = useSetting('color.defaultPalette');
127
- const defaultDuotone = useSetting('color.defaultDuotone');
128
- const userDuotonePalette = useSetting('color.duotone.custom');
129
- const themeDuotonePalette = useSetting('color.duotone.theme');
130
- const defaultDuotonePalette = useSetting('color.duotone.default');
131
- const userGradientPalette = useSetting('color.gradients.custom');
132
- const themeGradientPalette = useSetting('color.gradients.theme');
133
- const defaultGradientPalette = useSetting('color.gradients.default');
134
- const defaultGradients = useSetting('color.defaultGradients');
135
- const areCustomGradientsEnabled = useSetting('color.customGradient');
136
- const isBackgroundEnabled = useSetting('color.background');
137
- const isLinkEnabled = useSetting('color.link');
138
- const isTextEnabled = useSetting('color.text');
139
- const isHeadingEnabled = useSetting('color.heading');
140
- const isButtonEnabled = useSetting('color.button');
99
+ const [fontFamilies, fontSizes, customFontSize, fontStyle, fontWeight, lineHeight, textColumns, textDecoration, writingMode, textTransform, letterSpacing, padding, margin, blockGap, spacingSizes, units, minHeight, layout, borderColor, borderRadius, borderStyle, borderWidth, customColorsEnabled, customColors, customDuotone, themeColors, defaultColors, defaultPalette, defaultDuotone, userDuotonePalette, themeDuotonePalette, defaultDuotonePalette, userGradientPalette, themeGradientPalette, defaultGradientPalette, defaultGradients, areCustomGradientsEnabled, isBackgroundEnabled, isLinkEnabled, isTextEnabled, isHeadingEnabled, isButtonEnabled] = useSettings('typography.fontFamilies', 'typography.fontSizes', 'typography.customFontSize', 'typography.fontStyle', 'typography.fontWeight', 'typography.lineHeight', 'typography.textColumns', 'typography.textDecoration', 'typography.writingMode', 'typography.textTransform', 'typography.letterSpacing', 'spacing.padding', 'spacing.margin', 'spacing.blockGap', 'spacing.spacingSizes', 'spacing.units', 'dimensions.minHeight', 'layout', 'border.color', 'border.radius', 'border.style', 'border.width', 'color.custom', 'color.palette.custom', 'color.customDuotone', 'color.palette.theme', 'color.palette.default', 'color.defaultPalette', 'color.defaultDuotone', 'color.duotone.custom', 'color.duotone.theme', 'color.duotone.default', 'color.gradients.custom', 'color.gradients.theme', 'color.gradients.default', 'color.defaultGradients', 'color.customGradient', 'color.background', 'color.link', 'color.text', 'color.heading', 'color.button');
141
100
  const rawSettings = useMemo(() => {
142
101
  return {
143
102
  color: {
@@ -1 +1 @@
1
- {"version":3,"names":["getBlockSupport","useMemo","useSetting","useSettingsForBlockElement","getValueFromObjectPath","setImmutably","cleanEmptyObject","object","Array","isArray","cleanedNestedObjects","Object","entries","map","key","value","filter","undefined","length","fromEntries","transformStyles","activeSupports","migrationPaths","result","source","index","results","values","every","isActive","innerBlocks","referenceBlockAttributes","attributes","returnBlock","forEach","support","path","styleValue","shouldSkipSerialization","blockType","featureSet","feature","skipSerialization","__experimentalSkipSerialization","includes","useBlockSettings","name","parentLayout","fontFamilies","fontSizes","customFontSize","fontStyle","fontWeight","lineHeight","textColumns","textDecoration","writingMode","textTransform","letterSpacing","padding","margin","blockGap","spacingSizes","units","minHeight","layout","borderColor","borderRadius","borderStyle","borderWidth","customColorsEnabled","customColors","customDuotone","themeColors","defaultColors","defaultPalette","defaultDuotone","userDuotonePalette","themeDuotonePalette","defaultDuotonePalette","userGradientPalette","themeGradientPalette","defaultGradientPalette","defaultGradients","areCustomGradientsEnabled","isBackgroundEnabled","isLinkEnabled","isTextEnabled","isHeadingEnabled","isButtonEnabled","rawSettings","color","palette","custom","theme","default","gradients","duotone","customGradient","background","link","heading","button","text","typography","spacing","border","radius","style","width","dimensions"],"sources":["@wordpress/block-editor/src/hooks/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useSetting } from '../components';\nimport { useSettingsForBlockElement } from '../components/global-styles/hooks';\nimport { getValueFromObjectPath, setImmutably } from '../utils/object';\n\n/**\n * Removed falsy values from nested object.\n *\n * @param {*} object\n * @return {*} Object cleaned from falsy values\n */\nexport const cleanEmptyObject = ( object ) => {\n\tif (\n\t\tobject === null ||\n\t\ttypeof object !== 'object' ||\n\t\tArray.isArray( object )\n\t) {\n\t\treturn object;\n\t}\n\n\tconst cleanedNestedObjects = Object.entries( object )\n\t\t.map( ( [ key, value ] ) => [ key, cleanEmptyObject( value ) ] )\n\t\t.filter( ( [ , value ] ) => value !== undefined );\n\treturn ! cleanedNestedObjects.length\n\t\t? undefined\n\t\t: Object.fromEntries( cleanedNestedObjects );\n};\n\nexport function transformStyles(\n\tactiveSupports,\n\tmigrationPaths,\n\tresult,\n\tsource,\n\tindex,\n\tresults\n) {\n\t// If there are no active supports return early.\n\tif (\n\t\tObject.values( activeSupports ?? {} ).every(\n\t\t\t( isActive ) => ! isActive\n\t\t)\n\t) {\n\t\treturn result;\n\t}\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the styles should not be transformed.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\t// For cases where we have a transform from one block to multiple blocks\n\t// or multiple blocks to one block we apply the styles of the first source block\n\t// to the result(s).\n\tlet referenceBlockAttributes = source[ 0 ]?.attributes;\n\t// If we are in presence of transform between more than one block in the source\n\t// that has more than one block in the result\n\t// we apply the styles on source N to the result N,\n\t// if source N does not exists we do nothing.\n\tif ( results.length > 1 && source.length > 1 ) {\n\t\tif ( source[ index ] ) {\n\t\t\treferenceBlockAttributes = source[ index ]?.attributes;\n\t\t} else {\n\t\t\treturn result;\n\t\t}\n\t}\n\tlet returnBlock = result;\n\tObject.entries( activeSupports ).forEach( ( [ support, isActive ] ) => {\n\t\tif ( isActive ) {\n\t\t\tmigrationPaths[ support ].forEach( ( path ) => {\n\t\t\t\tconst styleValue = getValueFromObjectPath(\n\t\t\t\t\treferenceBlockAttributes,\n\t\t\t\t\tpath\n\t\t\t\t);\n\t\t\t\tif ( styleValue ) {\n\t\t\t\t\treturnBlock = {\n\t\t\t\t\t\t...returnBlock,\n\t\t\t\t\t\tattributes: setImmutably(\n\t\t\t\t\t\t\treturnBlock.attributes,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tstyleValue\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n\treturn returnBlock;\n}\n\n/**\n * Check whether serialization of specific block support feature or set should\n * be skipped.\n *\n * @param {string|Object} blockType Block name or block type object.\n * @param {string} featureSet Name of block support feature set.\n * @param {string} feature Name of the individual feature to check.\n *\n * @return {boolean} Whether serialization should occur.\n */\nexport function shouldSkipSerialization( blockType, featureSet, feature ) {\n\tconst support = getBlockSupport( blockType, featureSet );\n\tconst skipSerialization = support?.__experimentalSkipSerialization;\n\n\tif ( Array.isArray( skipSerialization ) ) {\n\t\treturn skipSerialization.includes( feature );\n\t}\n\n\treturn skipSerialization;\n}\n\n/**\n * Based on the block and its context, returns an object of all the block settings.\n * This object can be passed as a prop to all the Styles UI components\n * (TypographyPanel, DimensionsPanel...).\n *\n * @param {string} name Block name.\n * @param {*} parentLayout Parent layout.\n *\n * @return {Object} Settings object.\n */\nexport function useBlockSettings( name, parentLayout ) {\n\tconst fontFamilies = useSetting( 'typography.fontFamilies' );\n\tconst fontSizes = useSetting( 'typography.fontSizes' );\n\tconst customFontSize = useSetting( 'typography.customFontSize' );\n\tconst fontStyle = useSetting( 'typography.fontStyle' );\n\tconst fontWeight = useSetting( 'typography.fontWeight' );\n\tconst lineHeight = useSetting( 'typography.lineHeight' );\n\tconst textColumns = useSetting( 'typography.textColumns' );\n\tconst textDecoration = useSetting( 'typography.textDecoration' );\n\tconst writingMode = useSetting( 'typography.writingMode' );\n\tconst textTransform = useSetting( 'typography.textTransform' );\n\tconst letterSpacing = useSetting( 'typography.letterSpacing' );\n\tconst padding = useSetting( 'spacing.padding' );\n\tconst margin = useSetting( 'spacing.margin' );\n\tconst blockGap = useSetting( 'spacing.blockGap' );\n\tconst spacingSizes = useSetting( 'spacing.spacingSizes' );\n\tconst units = useSetting( 'spacing.units' );\n\tconst minHeight = useSetting( 'dimensions.minHeight' );\n\tconst layout = useSetting( 'layout' );\n\tconst borderColor = useSetting( 'border.color' );\n\tconst borderRadius = useSetting( 'border.radius' );\n\tconst borderStyle = useSetting( 'border.style' );\n\tconst borderWidth = useSetting( 'border.width' );\n\tconst customColorsEnabled = useSetting( 'color.custom' );\n\tconst customColors = useSetting( 'color.palette.custom' );\n\tconst customDuotone = useSetting( 'color.customDuotone' );\n\tconst themeColors = useSetting( 'color.palette.theme' );\n\tconst defaultColors = useSetting( 'color.palette.default' );\n\tconst defaultPalette = useSetting( 'color.defaultPalette' );\n\tconst defaultDuotone = useSetting( 'color.defaultDuotone' );\n\tconst userDuotonePalette = useSetting( 'color.duotone.custom' );\n\tconst themeDuotonePalette = useSetting( 'color.duotone.theme' );\n\tconst defaultDuotonePalette = useSetting( 'color.duotone.default' );\n\tconst userGradientPalette = useSetting( 'color.gradients.custom' );\n\tconst themeGradientPalette = useSetting( 'color.gradients.theme' );\n\tconst defaultGradientPalette = useSetting( 'color.gradients.default' );\n\tconst defaultGradients = useSetting( 'color.defaultGradients' );\n\tconst areCustomGradientsEnabled = useSetting( 'color.customGradient' );\n\tconst isBackgroundEnabled = useSetting( 'color.background' );\n\tconst isLinkEnabled = useSetting( 'color.link' );\n\tconst isTextEnabled = useSetting( 'color.text' );\n\tconst isHeadingEnabled = useSetting( 'color.heading' );\n\tconst isButtonEnabled = useSetting( 'color.button' );\n\n\tconst rawSettings = useMemo( () => {\n\t\treturn {\n\t\t\tcolor: {\n\t\t\t\tpalette: {\n\t\t\t\t\tcustom: customColors,\n\t\t\t\t\ttheme: themeColors,\n\t\t\t\t\tdefault: defaultColors,\n\t\t\t\t},\n\t\t\t\tgradients: {\n\t\t\t\t\tcustom: userGradientPalette,\n\t\t\t\t\ttheme: themeGradientPalette,\n\t\t\t\t\tdefault: defaultGradientPalette,\n\t\t\t\t},\n\t\t\t\tduotone: {\n\t\t\t\t\tcustom: userDuotonePalette,\n\t\t\t\t\ttheme: themeDuotonePalette,\n\t\t\t\t\tdefault: defaultDuotonePalette,\n\t\t\t\t},\n\t\t\t\tdefaultGradients,\n\t\t\t\tdefaultPalette,\n\t\t\t\tdefaultDuotone,\n\t\t\t\tcustom: customColorsEnabled,\n\t\t\t\tcustomGradient: areCustomGradientsEnabled,\n\t\t\t\tcustomDuotone,\n\t\t\t\tbackground: isBackgroundEnabled,\n\t\t\t\tlink: isLinkEnabled,\n\t\t\t\theading: isHeadingEnabled,\n\t\t\t\tbutton: isButtonEnabled,\n\t\t\t\ttext: isTextEnabled,\n\t\t\t},\n\t\t\ttypography: {\n\t\t\t\tfontFamilies: {\n\t\t\t\t\tcustom: fontFamilies,\n\t\t\t\t},\n\t\t\t\tfontSizes: {\n\t\t\t\t\tcustom: fontSizes,\n\t\t\t\t},\n\t\t\t\tcustomFontSize,\n\t\t\t\tfontStyle,\n\t\t\t\tfontWeight,\n\t\t\t\tlineHeight,\n\t\t\t\ttextColumns,\n\t\t\t\ttextDecoration,\n\t\t\t\ttextTransform,\n\t\t\t\tletterSpacing,\n\t\t\t\twritingMode,\n\t\t\t},\n\t\t\tspacing: {\n\t\t\t\tspacingSizes: {\n\t\t\t\t\tcustom: spacingSizes,\n\t\t\t\t},\n\t\t\t\tpadding,\n\t\t\t\tmargin,\n\t\t\t\tblockGap,\n\t\t\t\tunits,\n\t\t\t},\n\t\t\tborder: {\n\t\t\t\tcolor: borderColor,\n\t\t\t\tradius: borderRadius,\n\t\t\t\tstyle: borderStyle,\n\t\t\t\twidth: borderWidth,\n\t\t\t},\n\t\t\tdimensions: {\n\t\t\t\tminHeight,\n\t\t\t},\n\t\t\tlayout,\n\t\t\tparentLayout,\n\t\t};\n\t}, [\n\t\tfontFamilies,\n\t\tfontSizes,\n\t\tcustomFontSize,\n\t\tfontStyle,\n\t\tfontWeight,\n\t\tlineHeight,\n\t\ttextColumns,\n\t\ttextDecoration,\n\t\ttextTransform,\n\t\tletterSpacing,\n\t\twritingMode,\n\t\tpadding,\n\t\tmargin,\n\t\tblockGap,\n\t\tspacingSizes,\n\t\tunits,\n\t\tminHeight,\n\t\tlayout,\n\t\tparentLayout,\n\t\tborderColor,\n\t\tborderRadius,\n\t\tborderStyle,\n\t\tborderWidth,\n\t\tcustomColorsEnabled,\n\t\tcustomColors,\n\t\tcustomDuotone,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tdefaultPalette,\n\t\tdefaultDuotone,\n\t\tuserDuotonePalette,\n\t\tthemeDuotonePalette,\n\t\tdefaultDuotonePalette,\n\t\tuserGradientPalette,\n\t\tthemeGradientPalette,\n\t\tdefaultGradientPalette,\n\t\tdefaultGradients,\n\t\tareCustomGradientsEnabled,\n\t\tisBackgroundEnabled,\n\t\tisLinkEnabled,\n\t\tisTextEnabled,\n\t\tisHeadingEnabled,\n\t\tisButtonEnabled,\n\t] );\n\n\treturn useSettingsForBlockElement( rawSettings, name );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,0BAA0B,QAAQ,mCAAmC;AAC9E,SAASC,sBAAsB,EAAEC,YAAY,QAAQ,iBAAiB;;AAEtE;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAKC,MAAM,IAAM;EAC7C,IACCA,MAAM,KAAK,IAAI,IACf,OAAOA,MAAM,KAAK,QAAQ,IAC1BC,KAAK,CAACC,OAAO,CA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EACdC,cAAc,EACdC,kBAAkB,EAClBC,mBAAmB,EACnBC,qBAAqB,EACrBC,mBAAmB,EACnBC,oBAAoB,EACpBC,sBAAsB,EACtBC,gBAAgB,EAChBC,yBAAyB,EACzBC,mBAAmB,EACnBC,aAAa,EACbC,aAAa,EACbC,gBAAgB,EAChBC,eAAe,CACd,CAAC;EAEH,OAAOtF,0BAA0B,CAAEuF,WAAW,EAAE5C,IAAK,CAAC;AACvD"}
1
+ {"version":3,"names":["getBlockSupport","useMemo","useSettings","useSettingsForBlockElement","getValueFromObjectPath","setImmutably","cleanEmptyObject","object","Array","isArray","cleanedNestedObjects","Object","entries","map","key","value","filter","undefined","length","fromEntries","transformStyles","activeSupports","migrationPaths","result","source","index","results","values","every","isActive","innerBlocks","referenceBlockAttributes","attributes","returnBlock","forEach","support","path","styleValue","shouldSkipSerialization","blockType","featureSet","feature","skipSerialization","__experimentalSkipSerialization","includes","useBlockSettings","name","parentLayout","fontFamilies","fontSizes","customFontSize","fontStyle","fontWeight","lineHeight","textColumns","textDecoration","writingMode","textTransform","letterSpacing","padding","margin","blockGap","spacingSizes","units","minHeight","layout","borderColor","borderRadius","borderStyle","borderWidth","customColorsEnabled","customColors","customDuotone","themeColors","defaultColors","defaultPalette","defaultDuotone","userDuotonePalette","themeDuotonePalette","defaultDuotonePalette","userGradientPalette","themeGradientPalette","defaultGradientPalette","defaultGradients","areCustomGradientsEnabled","isBackgroundEnabled","isLinkEnabled","isTextEnabled","isHeadingEnabled","isButtonEnabled","rawSettings","color","palette","custom","theme","default","gradients","duotone","customGradient","background","link","heading","button","text","typography","spacing","border","radius","style","width","dimensions"],"sources":["@wordpress/block-editor/src/hooks/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../components';\nimport { useSettingsForBlockElement } from '../components/global-styles/hooks';\nimport { getValueFromObjectPath, setImmutably } from '../utils/object';\n\n/**\n * Removed falsy values from nested object.\n *\n * @param {*} object\n * @return {*} Object cleaned from falsy values\n */\nexport const cleanEmptyObject = ( object ) => {\n\tif (\n\t\tobject === null ||\n\t\ttypeof object !== 'object' ||\n\t\tArray.isArray( object )\n\t) {\n\t\treturn object;\n\t}\n\n\tconst cleanedNestedObjects = Object.entries( object )\n\t\t.map( ( [ key, value ] ) => [ key, cleanEmptyObject( value ) ] )\n\t\t.filter( ( [ , value ] ) => value !== undefined );\n\treturn ! cleanedNestedObjects.length\n\t\t? undefined\n\t\t: Object.fromEntries( cleanedNestedObjects );\n};\n\nexport function transformStyles(\n\tactiveSupports,\n\tmigrationPaths,\n\tresult,\n\tsource,\n\tindex,\n\tresults\n) {\n\t// If there are no active supports return early.\n\tif (\n\t\tObject.values( activeSupports ?? {} ).every(\n\t\t\t( isActive ) => ! isActive\n\t\t)\n\t) {\n\t\treturn result;\n\t}\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the styles should not be transformed.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\t// For cases where we have a transform from one block to multiple blocks\n\t// or multiple blocks to one block we apply the styles of the first source block\n\t// to the result(s).\n\tlet referenceBlockAttributes = source[ 0 ]?.attributes;\n\t// If we are in presence of transform between more than one block in the source\n\t// that has more than one block in the result\n\t// we apply the styles on source N to the result N,\n\t// if source N does not exists we do nothing.\n\tif ( results.length > 1 && source.length > 1 ) {\n\t\tif ( source[ index ] ) {\n\t\t\treferenceBlockAttributes = source[ index ]?.attributes;\n\t\t} else {\n\t\t\treturn result;\n\t\t}\n\t}\n\tlet returnBlock = result;\n\tObject.entries( activeSupports ).forEach( ( [ support, isActive ] ) => {\n\t\tif ( isActive ) {\n\t\t\tmigrationPaths[ support ].forEach( ( path ) => {\n\t\t\t\tconst styleValue = getValueFromObjectPath(\n\t\t\t\t\treferenceBlockAttributes,\n\t\t\t\t\tpath\n\t\t\t\t);\n\t\t\t\tif ( styleValue ) {\n\t\t\t\t\treturnBlock = {\n\t\t\t\t\t\t...returnBlock,\n\t\t\t\t\t\tattributes: setImmutably(\n\t\t\t\t\t\t\treturnBlock.attributes,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tstyleValue\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n\treturn returnBlock;\n}\n\n/**\n * Check whether serialization of specific block support feature or set should\n * be skipped.\n *\n * @param {string|Object} blockType Block name or block type object.\n * @param {string} featureSet Name of block support feature set.\n * @param {string} feature Name of the individual feature to check.\n *\n * @return {boolean} Whether serialization should occur.\n */\nexport function shouldSkipSerialization( blockType, featureSet, feature ) {\n\tconst support = getBlockSupport( blockType, featureSet );\n\tconst skipSerialization = support?.__experimentalSkipSerialization;\n\n\tif ( Array.isArray( skipSerialization ) ) {\n\t\treturn skipSerialization.includes( feature );\n\t}\n\n\treturn skipSerialization;\n}\n\n/**\n * Based on the block and its context, returns an object of all the block settings.\n * This object can be passed as a prop to all the Styles UI components\n * (TypographyPanel, DimensionsPanel...).\n *\n * @param {string} name Block name.\n * @param {*} parentLayout Parent layout.\n *\n * @return {Object} Settings object.\n */\nexport function useBlockSettings( name, parentLayout ) {\n\tconst [\n\t\tfontFamilies,\n\t\tfontSizes,\n\t\tcustomFontSize,\n\t\tfontStyle,\n\t\tfontWeight,\n\t\tlineHeight,\n\t\ttextColumns,\n\t\ttextDecoration,\n\t\twritingMode,\n\t\ttextTransform,\n\t\tletterSpacing,\n\t\tpadding,\n\t\tmargin,\n\t\tblockGap,\n\t\tspacingSizes,\n\t\tunits,\n\t\tminHeight,\n\t\tlayout,\n\t\tborderColor,\n\t\tborderRadius,\n\t\tborderStyle,\n\t\tborderWidth,\n\t\tcustomColorsEnabled,\n\t\tcustomColors,\n\t\tcustomDuotone,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tdefaultPalette,\n\t\tdefaultDuotone,\n\t\tuserDuotonePalette,\n\t\tthemeDuotonePalette,\n\t\tdefaultDuotonePalette,\n\t\tuserGradientPalette,\n\t\tthemeGradientPalette,\n\t\tdefaultGradientPalette,\n\t\tdefaultGradients,\n\t\tareCustomGradientsEnabled,\n\t\tisBackgroundEnabled,\n\t\tisLinkEnabled,\n\t\tisTextEnabled,\n\t\tisHeadingEnabled,\n\t\tisButtonEnabled,\n\t] = useSettings(\n\t\t'typography.fontFamilies',\n\t\t'typography.fontSizes',\n\t\t'typography.customFontSize',\n\t\t'typography.fontStyle',\n\t\t'typography.fontWeight',\n\t\t'typography.lineHeight',\n\t\t'typography.textColumns',\n\t\t'typography.textDecoration',\n\t\t'typography.writingMode',\n\t\t'typography.textTransform',\n\t\t'typography.letterSpacing',\n\t\t'spacing.padding',\n\t\t'spacing.margin',\n\t\t'spacing.blockGap',\n\t\t'spacing.spacingSizes',\n\t\t'spacing.units',\n\t\t'dimensions.minHeight',\n\t\t'layout',\n\t\t'border.color',\n\t\t'border.radius',\n\t\t'border.style',\n\t\t'border.width',\n\t\t'color.custom',\n\t\t'color.palette.custom',\n\t\t'color.customDuotone',\n\t\t'color.palette.theme',\n\t\t'color.palette.default',\n\t\t'color.defaultPalette',\n\t\t'color.defaultDuotone',\n\t\t'color.duotone.custom',\n\t\t'color.duotone.theme',\n\t\t'color.duotone.default',\n\t\t'color.gradients.custom',\n\t\t'color.gradients.theme',\n\t\t'color.gradients.default',\n\t\t'color.defaultGradients',\n\t\t'color.customGradient',\n\t\t'color.background',\n\t\t'color.link',\n\t\t'color.text',\n\t\t'color.heading',\n\t\t'color.button'\n\t);\n\n\tconst rawSettings = useMemo( () => {\n\t\treturn {\n\t\t\tcolor: {\n\t\t\t\tpalette: {\n\t\t\t\t\tcustom: customColors,\n\t\t\t\t\ttheme: themeColors,\n\t\t\t\t\tdefault: defaultColors,\n\t\t\t\t},\n\t\t\t\tgradients: {\n\t\t\t\t\tcustom: userGradientPalette,\n\t\t\t\t\ttheme: themeGradientPalette,\n\t\t\t\t\tdefault: defaultGradientPalette,\n\t\t\t\t},\n\t\t\t\tduotone: {\n\t\t\t\t\tcustom: userDuotonePalette,\n\t\t\t\t\ttheme: themeDuotonePalette,\n\t\t\t\t\tdefault: defaultDuotonePalette,\n\t\t\t\t},\n\t\t\t\tdefaultGradients,\n\t\t\t\tdefaultPalette,\n\t\t\t\tdefaultDuotone,\n\t\t\t\tcustom: customColorsEnabled,\n\t\t\t\tcustomGradient: areCustomGradientsEnabled,\n\t\t\t\tcustomDuotone,\n\t\t\t\tbackground: isBackgroundEnabled,\n\t\t\t\tlink: isLinkEnabled,\n\t\t\t\theading: isHeadingEnabled,\n\t\t\t\tbutton: isButtonEnabled,\n\t\t\t\ttext: isTextEnabled,\n\t\t\t},\n\t\t\ttypography: {\n\t\t\t\tfontFamilies: {\n\t\t\t\t\tcustom: fontFamilies,\n\t\t\t\t},\n\t\t\t\tfontSizes: {\n\t\t\t\t\tcustom: fontSizes,\n\t\t\t\t},\n\t\t\t\tcustomFontSize,\n\t\t\t\tfontStyle,\n\t\t\t\tfontWeight,\n\t\t\t\tlineHeight,\n\t\t\t\ttextColumns,\n\t\t\t\ttextDecoration,\n\t\t\t\ttextTransform,\n\t\t\t\tletterSpacing,\n\t\t\t\twritingMode,\n\t\t\t},\n\t\t\tspacing: {\n\t\t\t\tspacingSizes: {\n\t\t\t\t\tcustom: spacingSizes,\n\t\t\t\t},\n\t\t\t\tpadding,\n\t\t\t\tmargin,\n\t\t\t\tblockGap,\n\t\t\t\tunits,\n\t\t\t},\n\t\t\tborder: {\n\t\t\t\tcolor: borderColor,\n\t\t\t\tradius: borderRadius,\n\t\t\t\tstyle: borderStyle,\n\t\t\t\twidth: borderWidth,\n\t\t\t},\n\t\t\tdimensions: {\n\t\t\t\tminHeight,\n\t\t\t},\n\t\t\tlayout,\n\t\t\tparentLayout,\n\t\t};\n\t}, [\n\t\tfontFamilies,\n\t\tfontSizes,\n\t\tcustomFontSize,\n\t\tfontStyle,\n\t\tfontWeight,\n\t\tlineHeight,\n\t\ttextColumns,\n\t\ttextDecoration,\n\t\ttextTransform,\n\t\tletterSpacing,\n\t\twritingMode,\n\t\tpadding,\n\t\tmargin,\n\t\tblockGap,\n\t\tspacingSizes,\n\t\tunits,\n\t\tminHeight,\n\t\tlayout,\n\t\tparentLayout,\n\t\tborderColor,\n\t\tborderRadius,\n\t\tborderStyle,\n\t\tborderWidth,\n\t\tcustomColorsEnabled,\n\t\tcustomColors,\n\t\tcustomDuotone,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tdefaultPalette,\n\t\tdefaultDuotone,\n\t\tuserDuotonePalette,\n\t\tthemeDuotonePalette,\n\t\tdefaultDuotonePalette,\n\t\tuserGradientPalette,\n\t\tthemeGradientPalette,\n\t\tdefaultGradientPalette,\n\t\tdefaultGradients,\n\t\tareCustomGradientsEnabled,\n\t\tisBackgroundEnabled,\n\t\tisLinkEnabled,\n\t\tisTextEnabled,\n\t\tisHeadingEnabled,\n\t\tisButtonEnabled,\n\t] );\n\n\treturn useSettingsForBlockElement( rawSettings, name );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,0BAA0B,QAAQ,mCAAmC;AAC9E,SAASC,sBAAsB,EAAEC,YAAY,QAAQ,iBAAiB;;AAEtE;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAKC,MAAM,IAAM;EAC7C,IACCA,MAAM,KAAK,IAAI,IACf,OAAOA,MAAM,KAAK,QAAQ,IAC1BC,KAAK,CAACC,OAAO,CAAEF,MAAO,CAAC,EACtB;IACD,OAAOA,MAAM;EACd;EAEA,MAAMG,oBAAoB,GAAGC,MAAM,CAACC,OAAO,CAAEL,MAAO,CAAC,CACnDM,GAAG,CAAE,CAAE,CAAEC,GAAG,EAAE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AAgB,EAChBC,yBAAyB,EACzBC,mBAAmB,EACnBC,aAAa,EACbC,aAAa,EACbC,gBAAgB,EAChBC,eAAe,CACd,CAAC;EAEH,OAAOtF,0BAA0B,CAAEuF,WAAW,EAAE5C,IAAK,CAAC;AACvD"}
@@ -10,7 +10,7 @@ import { getCSSRules } from '@wordpress/style-engine';
10
10
  /**
11
11
  * Internal dependencies
12
12
  */
13
- import useSetting from '../components/use-setting';
13
+ import { useSettings } from '../components/use-settings';
14
14
  import { appendSelectors, getBlockGapCSS, getAlignmentsInfo } from './utils';
15
15
  import { getGapCSSValue } from '../hooks/gap';
16
16
  import { shouldSkipSerialization } from '../hooks/utils';
@@ -50,8 +50,9 @@ export default {
50
50
  icon: justifyRight,
51
51
  label: __('Justify items right')
52
52
  }];
53
+ const [availableUnits] = useSettings('spacing.units');
53
54
  const units = useCustomUnits({
54
- availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
55
+ availableUnits: availableUnits || ['%', 'px', 'em', 'rem', 'vw']
55
56
  });
56
57
  return createElement(Fragment, null, createElement("div", {
57
58
  className: "block-editor-hooks__layout-controls"
@@ -1 +1 @@
1
- {"version":3,"names":["__experimentalUseCustomUnits","useCustomUnits","__experimentalUnitControl","UnitControl","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOptionIcon","ToggleGroupControlOptionIcon","__","Icon","positionCenter","stretchWide","justifyLeft","justifyCenter","justifyRight","getCSSRules","useSetting","appendSelectors","getBlockGapCSS","getAlignmentsInfo","getGapCSSValue","shouldSkipSerialization","LAYOUT_DEFINITIONS","name","label","inspectorControls","DefaultLayoutInspectorControls","layout","onChange","layoutBlockSupport","wideSize","contentSize","justifyContent","allowJustification","onJustificationChange","value","justificationOptions","icon","units","availableUnits","createElement","Fragment","className","labelPosition","__unstableInputWidth","nextWidth","parseFloat","__nextHasNoMarginBottom","map","key","toolBarControls","DefaultLayoutToolbarControls","getLayoutStyle","selector","style","blockName","hasBlockGapSupport","layoutDefinitions","blockGapStyleValue","spacing","blockGap","blockGapValue","top","marginLeft","marginRight","output","padding","paddingValues","forEach","rule","getOrientation","getAlignments","alignmentInfo","alignments","undefined","includes","unshift","alignment","info","wide","none"],"sources":["@wordpress/block-editor/src/layouts/constrained.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tIcon,\n\tpositionCenter,\n\tstretchWide,\n\tjustifyLeft,\n\tjustifyCenter,\n\tjustifyRight,\n} from '@wordpress/icons';\nimport { getCSSRules } from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../components/use-setting';\nimport { appendSelectors, getBlockGapCSS, getAlignmentsInfo } from './utils';\nimport { getGapCSSValue } from '../hooks/gap';\nimport { shouldSkipSerialization } from '../hooks/utils';\nimport { LAYOUT_DEFINITIONS } from './definitions';\n\nexport default {\n\tname: 'constrained',\n\tlabel: __( 'Constrained' ),\n\tinspectorControls: function DefaultLayoutInspectorControls( {\n\t\tlayout,\n\t\tonChange,\n\t\tlayoutBlockSupport = {},\n\t} ) {\n\t\tconst { wideSize, contentSize, justifyContent = 'center' } = layout;\n\t\tconst { allowJustification = true } = layoutBlockSupport;\n\t\tconst onJustificationChange = ( value ) => {\n\t\t\tonChange( {\n\t\t\t\t...layout,\n\t\t\t\tjustifyContent: value,\n\t\t\t} );\n\t\t};\n\t\tconst justificationOptions = [\n\t\t\t{\n\t\t\t\tvalue: 'left',\n\t\t\t\ticon: justifyLeft,\n\t\t\t\tlabel: __( 'Justify items left' ),\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: 'center',\n\t\t\t\ticon: justifyCenter,\n\t\t\t\tlabel: __( 'Justify items center' ),\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: 'right',\n\t\t\t\ticon: justifyRight,\n\t\t\t\tlabel: __( 'Justify items right' ),\n\t\t\t},\n\t\t];\n\t\tconst units = useCustomUnits( {\n\t\t\tavailableUnits: useSetting( 'spacing.units' ) || [\n\t\t\t\t'%',\n\t\t\t\t'px',\n\t\t\t\t'em',\n\t\t\t\t'rem',\n\t\t\t\t'vw',\n\t\t\t],\n\t\t} );\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div className=\"block-editor-hooks__layout-controls\">\n\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-unit\">\n\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__layout-controls-unit-input\"\n\t\t\t\t\t\t\tlabel={ __( 'Content' ) }\n\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\tvalue={ contentSize || wideSize || '' }\n\t\t\t\t\t\t\tonChange={ ( nextWidth ) => {\n\t\t\t\t\t\t\t\tnextWidth =\n\t\t\t\t\t\t\t\t\t0 > parseFloat( nextWidth )\n\t\t\t\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t\t\t\t: nextWidth;\n\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\t\tcontentSize: nextWidth,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Icon icon={ positionCenter } />\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-unit\">\n\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__layout-controls-unit-input\"\n\t\t\t\t\t\t\tlabel={ __( 'Wide' ) }\n\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\tvalue={ wideSize || contentSize || '' }\n\t\t\t\t\t\t\tonChange={ ( nextWidth ) => {\n\t\t\t\t\t\t\t\tnextWidth =\n\t\t\t\t\t\t\t\t\t0 > parseFloat( nextWidth )\n\t\t\t\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t\t\t\t: nextWidth;\n\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\t\twideSize: nextWidth,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Icon icon={ stretchWide } />\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<p className=\"block-editor-hooks__layout-controls-helptext\">\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Customize the width for all elements that are assigned to the center or wide columns.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t\t{ allowJustification && (\n\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Justification' ) }\n\t\t\t\t\t\tvalue={ justifyContent }\n\t\t\t\t\t\tonChange={ onJustificationChange }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ justificationOptions.map(\n\t\t\t\t\t\t\t( { value, icon, label } ) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t},\n\ttoolBarControls: function DefaultLayoutToolbarControls() {\n\t\treturn null;\n\t},\n\tgetLayoutStyle: function getLayoutStyle( {\n\t\tselector,\n\t\tlayout = {},\n\t\tstyle,\n\t\tblockName,\n\t\thasBlockGapSupport,\n\t\tlayoutDefinitions = LAYOUT_DEFINITIONS,\n\t} ) {\n\t\tconst { contentSize, wideSize, justifyContent } = layout;\n\t\tconst blockGapStyleValue = getGapCSSValue( style?.spacing?.blockGap );\n\n\t\t// If a block's block.json skips serialization for spacing or\n\t\t// spacing.blockGap, don't apply the user-defined value to the styles.\n\t\tlet blockGapValue = '';\n\t\tif ( ! shouldSkipSerialization( blockName, 'spacing', 'blockGap' ) ) {\n\t\t\t// If an object is provided only use the 'top' value for this kind of gap.\n\t\t\tif ( blockGapStyleValue?.top ) {\n\t\t\t\tblockGapValue = getGapCSSValue( blockGapStyleValue?.top );\n\t\t\t} else if ( typeof blockGapStyleValue === 'string' ) {\n\t\t\t\tblockGapValue = getGapCSSValue( blockGapStyleValue );\n\t\t\t}\n\t\t}\n\n\t\tconst marginLeft =\n\t\t\tjustifyContent === 'left' ? '0 !important' : 'auto !important';\n\t\tconst marginRight =\n\t\t\tjustifyContent === 'right' ? '0 !important' : 'auto !important';\n\n\t\tlet output =\n\t\t\t!! contentSize || !! wideSize\n\t\t\t\t? `\n\t\t\t\t\t${ appendSelectors(\n\t\t\t\t\t\tselector,\n\t\t\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t\t\t) } {\n\t\t\t\t\t\tmax-width: ${ contentSize ?? wideSize };\n\t\t\t\t\t\tmargin-left: ${ marginLeft };\n\t\t\t\t\t\tmargin-right: ${ marginRight };\n\t\t\t\t\t}\n\t\t\t\t\t${ appendSelectors( selector, '> .alignwide' ) } {\n\t\t\t\t\t\tmax-width: ${ wideSize ?? contentSize };\n\t\t\t\t\t}\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmax-width: none;\n\t\t\t\t\t}\n\t\t\t\t`\n\t\t\t\t: '';\n\n\t\tif ( justifyContent === 'left' ) {\n\t\t\toutput += `${ appendSelectors(\n\t\t\t\tselector,\n\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t) }\n\t\t\t{ margin-left: ${ marginLeft }; }`;\n\t\t} else if ( justifyContent === 'right' ) {\n\t\t\toutput += `${ appendSelectors(\n\t\t\t\tselector,\n\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t) }\n\t\t\t{ margin-right: ${ marginRight }; }`;\n\t\t}\n\n\t\t// If there is custom padding, add negative margins for alignfull blocks.\n\t\tif ( style?.spacing?.padding ) {\n\t\t\t// The style object might be storing a preset so we need to make sure we get a usable value.\n\t\t\tconst paddingValues = getCSSRules( style );\n\t\t\tpaddingValues.forEach( ( rule ) => {\n\t\t\t\tif ( rule.key === 'paddingRight' ) {\n\t\t\t\t\toutput += `\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmargin-right: calc(${ rule.value } * -1);\n\t\t\t\t\t}\n\t\t\t\t\t`;\n\t\t\t\t} else if ( rule.key === 'paddingLeft' ) {\n\t\t\t\t\toutput += `\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmargin-left: calc(${ rule.value } * -1);\n\t\t\t\t\t}\n\t\t\t\t\t`;\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t// Output blockGap styles based on rules contained in layout definitions in theme.json.\n\t\tif ( hasBlockGapSupport && blockGapValue ) {\n\t\t\toutput += getBlockGapCSS(\n\t\t\t\tselector,\n\t\t\t\tlayoutDefinitions,\n\t\t\t\t'constrained',\n\t\t\t\tblockGapValue\n\t\t\t);\n\t\t}\n\t\treturn output;\n\t},\n\tgetOrientation() {\n\t\treturn 'vertical';\n\t},\n\tgetAlignments( layout ) {\n\t\tconst alignmentInfo = getAlignmentsInfo( layout );\n\t\tif ( layout.alignments !== undefined ) {\n\t\t\tif ( ! layout.alignments.includes( 'none' ) ) {\n\t\t\t\tlayout.alignments.unshift( 'none' );\n\t\t\t}\n\t\t\treturn layout.alignments.map( ( alignment ) => ( {\n\t\t\t\tname: alignment,\n\t\t\t\tinfo: alignmentInfo[ alignment ],\n\t\t\t} ) );\n\t\t}\n\t\tconst { contentSize, wideSize } = layout;\n\n\t\tconst alignments = [\n\t\t\t{ name: 'left' },\n\t\t\t{ name: 'center' },\n\t\t\t{ name: 'right' },\n\t\t];\n\n\t\tif ( contentSize ) {\n\t\t\talignments.unshift( { name: 'full' } );\n\t\t}\n\n\t\tif ( wideSize ) {\n\t\t\talignments.unshift( { name: 'wide', info: alignmentInfo.wide } );\n\t\t}\n\n\t\talignments.unshift( { name: 'none', info: alignmentInfo.none } );\n\n\t\treturn alignments;\n\t},\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,4BAA4B,IAAIC,cAAc,EAC9CC,yBAAyB,IAAIC,WAAW,EACxCC,gCAAgC,IAAIC,kBAAkB,EACtDC,0CAA0C,IAAIC,4BAA4B,QACpE,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,IAAI,EACJC,cAAc,EACdC,WAAW,EACXC,WAAW,EACXC,aAAa,EACbC,YAAY,QACN,kBAAkB;AACzB,SAASC,WAAW,QAAQ,yBAAyB;;AAErD;AACA;AACA;AACA,OAAOC,UAAU,MAAM,2BAA2B;AAClD,SAASC,eAAe,EAAEC,cAAc,EAAEC,iBAAiB,QAAQ,SAAS;AAC5E,SAASC,cAAc,QAAQ,cAAc;AAC7C,SAASC,uBAAuB,QAAQ,gBAAgB;AACxD,SAASC,kBAAkB,QAAQ,eAAe;AAElD,eAAe;EACdC,IAAI,EAAE,aAAa;EACnBC,KAAK,EAAEhB,EAAE,CAAE,aAAc,CAAC;EAC1BiB,iBAAiB,EAAE,SAASC,8BAA8BA,CAAE;IAC3DC,MAAM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;IACF;IACA,OAAOI,MAAM;EACd,CAAC;EACDK,cAAcA,CAAA,EAAG;IAChB,OAAO,UAAU;EAClB,CAAC;EACDC,aAAaA,CAAE5C,MAAM,EAAG;IACvB,MAAM6C,aAAa,GAAGrD,iBAAiB,CAAEQ,MAAO,CAAC;IACjD,IAAKA,MAAM,CAAC8C,UAAU,KAAKC,SAAS,EAAG;MACtC,IAAK,CAAE/C,MAAM,CAAC8C,UAAU,CAACE,QAAQ,CAAE,MAAO,CAAC,EAAG;QAC7ChD,MAAM,CAAC8C,UAAU,CAACG,OAAO,CAAE,MAAO,CAAC;MACpC;MACA,OAAOjD,MAAM,CAAC8C,UAAU,CAACzB,GAAG,CAAI6B,SAAS,KAAQ;QAChDtD,IAAI,EAAEsD,SAAS;QACfC,IAAI,EAAEN,aAAa,CAAEK,SAAS;MAC/B,CAAC,CAAG,CAAC;IACN;IACA,MAAM;MAAE9C,WAAW;MAAED;IAAS,CAAC,GAAGH,MAAM;IAExC,MAAM8C,UAAU,GAAG,CAClB;MAAElD,IAAI,EAAE;IAAO,CAAC,EAChB;MAAEA,IAAI,EAAE;IAAS,CAAC,EAClB;MAAEA,IAAI,EAAE;IAAQ,CAAC,CACjB;IAED,IAAKQ,WAAW,EAAG;MAClB0C,UAAU,CAACG,OAAO,CAAE;QAAErD,IAAI,EAAE;MAAO,CAAE,CAAC;IACvC;IAEA,IAAKO,QAAQ,EAAG;MACf2C,UAAU,CAACG,OAAO,CAAE;QAAErD,IAAI,EAAE,MAAM;QAAEuD,IAAI,EAAEN,aAAa,CAACO;MAAK,CAAE,CAAC;IACjE;IAEAN,UAAU,CAACG,OAAO,CAAE;MAAErD,IAAI,EAAE,MAAM;MAAEuD,IAAI,EAAEN,aAAa,CAACQ;IAAK,CAAE,CAAC;IAEhE,OAAOP,UAAU;EAClB;AACD,CAAC"}
1
+ {"version":3,"names":["__experimentalUseCustomUnits","useCustomUnits","__experimentalUnitControl","UnitControl","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOptionIcon","ToggleGroupControlOptionIcon","__","Icon","positionCenter","stretchWide","justifyLeft","justifyCenter","justifyRight","getCSSRules","useSettings","appendSelectors","getBlockGapCSS","getAlignmentsInfo","getGapCSSValue","shouldSkipSerialization","LAYOUT_DEFINITIONS","name","label","inspectorControls","DefaultLayoutInspectorControls","layout","onChange","layoutBlockSupport","wideSize","contentSize","justifyContent","allowJustification","onJustificationChange","value","justificationOptions","icon","availableUnits","units","createElement","Fragment","className","labelPosition","__unstableInputWidth","nextWidth","parseFloat","__nextHasNoMarginBottom","map","key","toolBarControls","DefaultLayoutToolbarControls","getLayoutStyle","selector","style","blockName","hasBlockGapSupport","layoutDefinitions","blockGapStyleValue","spacing","blockGap","blockGapValue","top","marginLeft","marginRight","output","padding","paddingValues","forEach","rule","getOrientation","getAlignments","alignmentInfo","alignments","undefined","includes","unshift","alignment","info","wide","none"],"sources":["@wordpress/block-editor/src/layouts/constrained.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tIcon,\n\tpositionCenter,\n\tstretchWide,\n\tjustifyLeft,\n\tjustifyCenter,\n\tjustifyRight,\n} from '@wordpress/icons';\nimport { getCSSRules } from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../components/use-settings';\nimport { appendSelectors, getBlockGapCSS, getAlignmentsInfo } from './utils';\nimport { getGapCSSValue } from '../hooks/gap';\nimport { shouldSkipSerialization } from '../hooks/utils';\nimport { LAYOUT_DEFINITIONS } from './definitions';\n\nexport default {\n\tname: 'constrained',\n\tlabel: __( 'Constrained' ),\n\tinspectorControls: function DefaultLayoutInspectorControls( {\n\t\tlayout,\n\t\tonChange,\n\t\tlayoutBlockSupport = {},\n\t} ) {\n\t\tconst { wideSize, contentSize, justifyContent = 'center' } = layout;\n\t\tconst { allowJustification = true } = layoutBlockSupport;\n\t\tconst onJustificationChange = ( value ) => {\n\t\t\tonChange( {\n\t\t\t\t...layout,\n\t\t\t\tjustifyContent: value,\n\t\t\t} );\n\t\t};\n\t\tconst justificationOptions = [\n\t\t\t{\n\t\t\t\tvalue: 'left',\n\t\t\t\ticon: justifyLeft,\n\t\t\t\tlabel: __( 'Justify items left' ),\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: 'center',\n\t\t\t\ticon: justifyCenter,\n\t\t\t\tlabel: __( 'Justify items center' ),\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: 'right',\n\t\t\t\ticon: justifyRight,\n\t\t\t\tlabel: __( 'Justify items right' ),\n\t\t\t},\n\t\t];\n\t\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\t\tconst units = useCustomUnits( {\n\t\t\tavailableUnits: availableUnits || [ '%', 'px', 'em', 'rem', 'vw' ],\n\t\t} );\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div className=\"block-editor-hooks__layout-controls\">\n\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-unit\">\n\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__layout-controls-unit-input\"\n\t\t\t\t\t\t\tlabel={ __( 'Content' ) }\n\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\tvalue={ contentSize || wideSize || '' }\n\t\t\t\t\t\t\tonChange={ ( nextWidth ) => {\n\t\t\t\t\t\t\t\tnextWidth =\n\t\t\t\t\t\t\t\t\t0 > parseFloat( nextWidth )\n\t\t\t\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t\t\t\t: nextWidth;\n\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\t\tcontentSize: nextWidth,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Icon icon={ positionCenter } />\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-unit\">\n\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__layout-controls-unit-input\"\n\t\t\t\t\t\t\tlabel={ __( 'Wide' ) }\n\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\tvalue={ wideSize || contentSize || '' }\n\t\t\t\t\t\t\tonChange={ ( nextWidth ) => {\n\t\t\t\t\t\t\t\tnextWidth =\n\t\t\t\t\t\t\t\t\t0 > parseFloat( nextWidth )\n\t\t\t\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t\t\t\t: nextWidth;\n\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\t\twideSize: nextWidth,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Icon icon={ stretchWide } />\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<p className=\"block-editor-hooks__layout-controls-helptext\">\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Customize the width for all elements that are assigned to the center or wide columns.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t\t{ allowJustification && (\n\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Justification' ) }\n\t\t\t\t\t\tvalue={ justifyContent }\n\t\t\t\t\t\tonChange={ onJustificationChange }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ justificationOptions.map(\n\t\t\t\t\t\t\t( { value, icon, label } ) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t},\n\ttoolBarControls: function DefaultLayoutToolbarControls() {\n\t\treturn null;\n\t},\n\tgetLayoutStyle: function getLayoutStyle( {\n\t\tselector,\n\t\tlayout = {},\n\t\tstyle,\n\t\tblockName,\n\t\thasBlockGapSupport,\n\t\tlayoutDefinitions = LAYOUT_DEFINITIONS,\n\t} ) {\n\t\tconst { contentSize, wideSize, justifyContent } = layout;\n\t\tconst blockGapStyleValue = getGapCSSValue( style?.spacing?.blockGap );\n\n\t\t// If a block's block.json skips serialization for spacing or\n\t\t// spacing.blockGap, don't apply the user-defined value to the styles.\n\t\tlet blockGapValue = '';\n\t\tif ( ! shouldSkipSerialization( blockName, 'spacing', 'blockGap' ) ) {\n\t\t\t// If an object is provided only use the 'top' value for this kind of gap.\n\t\t\tif ( blockGapStyleValue?.top ) {\n\t\t\t\tblockGapValue = getGapCSSValue( blockGapStyleValue?.top );\n\t\t\t} else if ( typeof blockGapStyleValue === 'string' ) {\n\t\t\t\tblockGapValue = getGapCSSValue( blockGapStyleValue );\n\t\t\t}\n\t\t}\n\n\t\tconst marginLeft =\n\t\t\tjustifyContent === 'left' ? '0 !important' : 'auto !important';\n\t\tconst marginRight =\n\t\t\tjustifyContent === 'right' ? '0 !important' : 'auto !important';\n\n\t\tlet output =\n\t\t\t!! contentSize || !! wideSize\n\t\t\t\t? `\n\t\t\t\t\t${ appendSelectors(\n\t\t\t\t\t\tselector,\n\t\t\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t\t\t) } {\n\t\t\t\t\t\tmax-width: ${ contentSize ?? wideSize };\n\t\t\t\t\t\tmargin-left: ${ marginLeft };\n\t\t\t\t\t\tmargin-right: ${ marginRight };\n\t\t\t\t\t}\n\t\t\t\t\t${ appendSelectors( selector, '> .alignwide' ) } {\n\t\t\t\t\t\tmax-width: ${ wideSize ?? contentSize };\n\t\t\t\t\t}\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmax-width: none;\n\t\t\t\t\t}\n\t\t\t\t`\n\t\t\t\t: '';\n\n\t\tif ( justifyContent === 'left' ) {\n\t\t\toutput += `${ appendSelectors(\n\t\t\t\tselector,\n\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t) }\n\t\t\t{ margin-left: ${ marginLeft }; }`;\n\t\t} else if ( justifyContent === 'right' ) {\n\t\t\toutput += `${ appendSelectors(\n\t\t\t\tselector,\n\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t) }\n\t\t\t{ margin-right: ${ marginRight }; }`;\n\t\t}\n\n\t\t// If there is custom padding, add negative margins for alignfull blocks.\n\t\tif ( style?.spacing?.padding ) {\n\t\t\t// The style object might be storing a preset so we need to make sure we get a usable value.\n\t\t\tconst paddingValues = getCSSRules( style );\n\t\t\tpaddingValues.forEach( ( rule ) => {\n\t\t\t\tif ( rule.key === 'paddingRight' ) {\n\t\t\t\t\toutput += `\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmargin-right: calc(${ rule.value } * -1);\n\t\t\t\t\t}\n\t\t\t\t\t`;\n\t\t\t\t} else if ( rule.key === 'paddingLeft' ) {\n\t\t\t\t\toutput += `\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmargin-left: calc(${ rule.value } * -1);\n\t\t\t\t\t}\n\t\t\t\t\t`;\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t// Output blockGap styles based on rules contained in layout definitions in theme.json.\n\t\tif ( hasBlockGapSupport && blockGapValue ) {\n\t\t\toutput += getBlockGapCSS(\n\t\t\t\tselector,\n\t\t\t\tlayoutDefinitions,\n\t\t\t\t'constrained',\n\t\t\t\tblockGapValue\n\t\t\t);\n\t\t}\n\t\treturn output;\n\t},\n\tgetOrientation() {\n\t\treturn 'vertical';\n\t},\n\tgetAlignments( layout ) {\n\t\tconst alignmentInfo = getAlignmentsInfo( layout );\n\t\tif ( layout.alignments !== undefined ) {\n\t\t\tif ( ! layout.alignments.includes( 'none' ) ) {\n\t\t\t\tlayout.alignments.unshift( 'none' );\n\t\t\t}\n\t\t\treturn layout.alignments.map( ( alignment ) => ( {\n\t\t\t\tname: alignment,\n\t\t\t\tinfo: alignmentInfo[ alignment ],\n\t\t\t} ) );\n\t\t}\n\t\tconst { contentSize, wideSize } = layout;\n\n\t\tconst alignments = [\n\t\t\t{ name: 'left' },\n\t\t\t{ name: 'center' },\n\t\t\t{ name: 'right' },\n\t\t];\n\n\t\tif ( contentSize ) {\n\t\t\talignments.unshift( { name: 'full' } );\n\t\t}\n\n\t\tif ( wideSize ) {\n\t\t\talignments.unshift( { name: 'wide', info: alignmentInfo.wide } );\n\t\t}\n\n\t\talignments.unshift( { name: 'none', info: alignmentInfo.none } );\n\n\t\treturn alignments;\n\t},\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,4BAA4B,IAAIC,cAAc,EAC9CC,yBAAyB,IAAIC,WAAW,EACxCC,gCAAgC,IAAIC,kBAAkB,EACtDC,0CAA0C,IAAIC,4BAA4B,QACpE,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,IAAI,EACJC,cAAc,EACdC,WAAW,EACXC,WAAW,EACXC,aAAa,EACbC,YAAY,QACN,kBAAkB;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,CAAE;QAAErD,IAAI,EAAE;MAAO,CAAE,CAAC;IACvC;IAEA,IAAKO,QAAQ,EAAG;MACf2C,UAAU,CAACG,OAAO,CAAE;QAAErD,IAAI,EAAE,MAAM;QAAEuD,IAAI,EAAEN,aAAa,CAACO;MAAK,CAAE,CAAC;IACjE;IAEAN,UAAU,CAACG,OAAO,CAAE;MAAErD,IAAI,EAAE,MAAM;MAAEuD,IAAI,EAAEN,aAAa,CAACQ;IAAK,CAAE,CAAC;IAEhE,OAAOP,UAAU;EAClB;AACD,CAAC"}
@@ -2,6 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { paramCase } from 'change-case';
5
+ import memoize from 'memize';
5
6
 
6
7
  /**
7
8
  * Converts a path to an array of its fragments.
@@ -103,6 +104,7 @@ export function setImmutably(object, path, value) {
103
104
  }, newObject);
104
105
  return newObject;
105
106
  }
107
+ const stringToPath = memoize(path => path.split('.'));
106
108
 
107
109
  /**
108
110
  * Helper util to return a value from a certain path of the object.
@@ -118,7 +120,7 @@ export function setImmutably(object, path, value) {
118
120
  */
119
121
  export const getValueFromObjectPath = (object, path, defaultValue) => {
120
122
  var _value;
121
- const normalizedPath = Array.isArray(path) ? path : path.split('.');
123
+ const normalizedPath = Array.isArray(path) ? path : stringToPath(path);
122
124
  let value = object;
123
125
  normalizedPath.forEach(fieldName => {
124
126
  value = value?.[fieldName];
@@ -1 +1 @@
1
- {"version":3,"names":["paramCase","normalizePath","path","Array","isArray","toString","kebabCase","str","input","_str$toString","replace","splitRegexp","cloneObject","object","map","Object","fromEntries","entries","key","value","setImmutably","normalizedPath","newObject","reduce","acc","i","undefined","Number","isInteger","length","getValueFromObjectPath","defaultValue","_value","split","forEach","fieldName"],"sources":["@wordpress/block-editor/src/utils/object.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase } from 'change-case';\n\n/**\n * Converts a path to an array of its fragments.\n * Supports strings, numbers and arrays:\n *\n * 'foo' => [ 'foo' ]\n * 2 => [ '2' ]\n * [ 'foo', 'bar' ] => [ 'foo', 'bar' ]\n *\n * @param {string|number|Array} path Path\n * @return {Array} Normalized path.\n */\nfunction normalizePath( path ) {\n\tif ( Array.isArray( path ) ) {\n\t\treturn path;\n\t} else if ( typeof path === 'number' ) {\n\t\treturn [ path.toString() ];\n\t}\n\n\treturn [ path ];\n}\n\n/**\n * Converts any string to kebab case.\n * Backwards compatible with Lodash's `_.kebabCase()`.\n * Backwards compatible with `_wp_to_kebab_case()`.\n *\n * @see https://lodash.com/docs/4.17.15#kebabCase\n * @see https://developer.wordpress.org/reference/functions/_wp_to_kebab_case/\n *\n * @param {string} str String to convert.\n * @return {string} Kebab-cased string\n */\nexport function kebabCase( str ) {\n\tlet input = str;\n\tif ( typeof str !== 'string' ) {\n\t\tinput = str?.toString?.() ?? '';\n\t}\n\n\t// See https://github.com/lodash/lodash/blob/b185fcee26b2133bd071f4aaca14b455c2ed1008/lodash.js#L4970\n\tinput = input.replace( /['\\u2019]/, '' );\n\n\treturn paramCase( input, {\n\t\tsplitRegexp: [\n\t\t\t/(?!(?:1ST|2ND|3RD|[4-9]TH)(?![a-z]))([a-z0-9])([A-Z])/g, // fooBar => foo-bar, 3Bar => 3-bar\n\t\t\t/(?!(?:1st|2nd|3rd|[4-9]th)(?![a-z]))([0-9])([a-z])/g, // 3bar => 3-bar\n\t\t\t/([A-Za-z])([0-9])/g, // Foo3 => foo-3, foo3 => foo-3\n\t\t\t/([A-Z])([A-Z][a-z])/g, // FOOBar => foo-bar\n\t\t],\n\t} );\n}\n\n/**\n * Clones an object.\n * Arrays are also cloned as arrays.\n * Non-object values are returned unchanged.\n *\n * @param {*} object Object to clone.\n * @return {*} Cloned object, or original literal non-object value.\n */\nfunction cloneObject( object ) {\n\tif ( Array.isArray( object ) ) {\n\t\treturn object.map( cloneObject );\n\t}\n\n\tif ( object && typeof object === 'object' ) {\n\t\treturn {\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries( object ).map( ( [ key, value ] ) => [\n\t\t\t\t\tkey,\n\t\t\t\t\tcloneObject( value ),\n\t\t\t\t] )\n\t\t\t),\n\t\t};\n\t}\n\n\treturn object;\n}\n\n/**\n * Immutably sets a value inside an object. Like `lodash#set`, but returning a\n * new object. Treats nullish initial values as empty objects. Clones any\n * nested objects. Supports arrays, too.\n *\n * @param {Object} object Object to set a value in.\n * @param {number|string|Array} path Path in the object to modify.\n * @param {*} value New value to set.\n * @return {Object} Cloned object with the new value set.\n */\nexport function setImmutably( object, path, value ) {\n\tconst normalizedPath = normalizePath( path );\n\tconst newObject = object ? cloneObject( object ) : {};\n\n\tnormalizedPath.reduce( ( acc, key, i ) => {\n\t\tif ( acc[ key ] === undefined ) {\n\t\t\tif ( Number.isInteger( path[ i + 1 ] ) ) {\n\t\t\t\tacc[ key ] = [];\n\t\t\t} else {\n\t\t\t\tacc[ key ] = {};\n\t\t\t}\n\t\t}\n\t\tif ( i === normalizedPath.length - 1 ) {\n\t\t\tacc[ key ] = value;\n\t\t}\n\t\treturn acc[ key ];\n\t}, newObject );\n\n\treturn newObject;\n}\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as either:\n * - a string of properties, separated by dots, for example: \"x.y\".\n * - an array of properties, for example `[ 'x', 'y' ]`.\n * You can also specify a default value in case the result is nullish.\n *\n * @param {Object} object Input object.\n * @param {string|Array} path Path to the object property.\n * @param {*} defaultValue Default value if the value at the specified path is nullish.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path, defaultValue ) => {\n\tconst normalizedPath = Array.isArray( path ) ? path : path.split( '.' );\n\tlet value = object;\n\tnormalizedPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value ?? defaultValue;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,aAAa;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,aAAaA,CAAEC,IAAI,EAAG;EAC9B,I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,KAAK,GAAGA,KAAK,GAAIgB,SAAS,CAAE;EAC7B,CAAE,CAAC;EACH,QAAAH,MAAA,GAAOb,KAAK,cAAAa,MAAA,cAAAA,MAAA,GAAID,YAAY;AAC7B,CAAC"}
1
+ {"version":3,"names":["paramCase","memoize","normalizePath","path","Array","isArray","toString","kebabCase","str","input","_str$toString","replace","splitRegexp","cloneObject","object","map","Object","fromEntries","entries","key","value","setImmutably","normalizedPath","newObject","reduce","acc","i","undefined","Number","isInteger","length","stringToPath","split","getValueFromObjectPath","defaultValue","_value","forEach","fieldName"],"sources":["@wordpress/block-editor/src/utils/object.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase } from 'change-case';\nimport memoize from 'memize';\n\n/**\n * Converts a path to an array of its fragments.\n * Supports strings, numbers and arrays:\n *\n * 'foo' => [ 'foo' ]\n * 2 => [ '2' ]\n * [ 'foo', 'bar' ] => [ 'foo', 'bar' ]\n *\n * @param {string|number|Array} path Path\n * @return {Array} Normalized path.\n */\nfunction normalizePath( path ) {\n\tif ( Array.isArray( path ) ) {\n\t\treturn path;\n\t} else if ( typeof path === 'number' ) {\n\t\treturn [ path.toString() ];\n\t}\n\n\treturn [ path ];\n}\n\n/**\n * Converts any string to kebab case.\n * Backwards compatible with Lodash's `_.kebabCase()`.\n * Backwards compatible with `_wp_to_kebab_case()`.\n *\n * @see https://lodash.com/docs/4.17.15#kebabCase\n * @see https://developer.wordpress.org/reference/functions/_wp_to_kebab_case/\n *\n * @param {string} str String to convert.\n * @return {string} Kebab-cased string\n */\nexport function kebabCase( str ) {\n\tlet input = str;\n\tif ( typeof str !== 'string' ) {\n\t\tinput = str?.toString?.() ?? '';\n\t}\n\n\t// See https://github.com/lodash/lodash/blob/b185fcee26b2133bd071f4aaca14b455c2ed1008/lodash.js#L4970\n\tinput = input.replace( /['\\u2019]/, '' );\n\n\treturn paramCase( input, {\n\t\tsplitRegexp: [\n\t\t\t/(?!(?:1ST|2ND|3RD|[4-9]TH)(?![a-z]))([a-z0-9])([A-Z])/g, // fooBar => foo-bar, 3Bar => 3-bar\n\t\t\t/(?!(?:1st|2nd|3rd|[4-9]th)(?![a-z]))([0-9])([a-z])/g, // 3bar => 3-bar\n\t\t\t/([A-Za-z])([0-9])/g, // Foo3 => foo-3, foo3 => foo-3\n\t\t\t/([A-Z])([A-Z][a-z])/g, // FOOBar => foo-bar\n\t\t],\n\t} );\n}\n\n/**\n * Clones an object.\n * Arrays are also cloned as arrays.\n * Non-object values are returned unchanged.\n *\n * @param {*} object Object to clone.\n * @return {*} Cloned object, or original literal non-object value.\n */\nfunction cloneObject( object ) {\n\tif ( Array.isArray( object ) ) {\n\t\treturn object.map( cloneObject );\n\t}\n\n\tif ( object && typeof object === 'object' ) {\n\t\treturn {\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries( object ).map( ( [ key, value ] ) => [\n\t\t\t\t\tkey,\n\t\t\t\t\tcloneObject( value ),\n\t\t\t\t] )\n\t\t\t),\n\t\t};\n\t}\n\n\treturn object;\n}\n\n/**\n * Immutably sets a value inside an object. Like `lodash#set`, but returning a\n * new object. Treats nullish initial values as empty objects. Clones any\n * nested objects. Supports arrays, too.\n *\n * @param {Object} object Object to set a value in.\n * @param {number|string|Array} path Path in the object to modify.\n * @param {*} value New value to set.\n * @return {Object} Cloned object with the new value set.\n */\nexport function setImmutably( object, path, value ) {\n\tconst normalizedPath = normalizePath( path );\n\tconst newObject = object ? cloneObject( object ) : {};\n\n\tnormalizedPath.reduce( ( acc, key, i ) => {\n\t\tif ( acc[ key ] === undefined ) {\n\t\t\tif ( Number.isInteger( path[ i + 1 ] ) ) {\n\t\t\t\tacc[ key ] = [];\n\t\t\t} else {\n\t\t\t\tacc[ key ] = {};\n\t\t\t}\n\t\t}\n\t\tif ( i === normalizedPath.length - 1 ) {\n\t\t\tacc[ key ] = value;\n\t\t}\n\t\treturn acc[ key ];\n\t}, newObject );\n\n\treturn newObject;\n}\n\nconst stringToPath = memoize( ( path ) => path.split( '.' ) );\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as either:\n * - a string of properties, separated by dots, for example: \"x.y\".\n * - an array of properties, for example `[ 'x', 'y' ]`.\n * You can also specify a default value in case the result is nullish.\n *\n * @param {Object} object Input object.\n * @param {string|Array} path Path to the object property.\n * @param {*} defaultValue Default value if the value at the specified path is nullish.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path, defaultValue ) => {\n\tconst normalizedPath = Array.isArray( path ) ? path : stringToPath( path );\n\tlet value = object;\n\tnormalizedPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value ?? defaultValue;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,aAAa;AACvC,OAAOC,OAAO,MAAM,QAAQ;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,aAAaA,CAAEC,IAAI,EAAG;EAC9B,IAAKC,KAAK,CAACC,OAAO,CAAEF,IAAK,CAAC,EAAG;IAC5B,OAAOA,IAAI;EACZ,CAAC,MAAM,IAAK,OAAOA,IAAI,KAAK,QAAQ,EAAG;IACtC,OAAO,CAAEA,IAAI,CAACG,QAAQ,CAAC,CAAC,CAAE;EAC3B;EAEA,OAAO,CAAEH,IAAI,CAAE;AAChB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,SAASA,CAAEC,GAAG,EAAG;EAChC,IAAIC,KAAK,GAAGD,GAAG;EACf,IAAK,OAAOA,GAAG,KAAK,QAAQ,EAAG;IAAA,IAAAE,aAAA;IAC9BD,KAAK,IAAAC,aAAA,GAAGF,GAAG,EAAEF,QAAQ,GAAG,CAAC,cAAAI,aAAA,cAAAA,aAAA,GAAI,EAAE;EAChC;;EAEA;EACAD,KAAK,GAAGA,KAAK,CAACE,OAAO,CAAE,WAAW,EAAE,EAAG,CAAC;EAExC,OAAOX,SAA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AAG,CAAC,CAAC;MAChB;IACD;IACA,IAAKO,CAAC,KAAKJ,cAAc,CAACQ,MAAM,GAAG,CAAC,EAAG;MACtCL,GAAG,CAAEN,GAAG,CAAE,GAAGC,KAAK;IACnB;IACA,OAAOK,GAAG,CAAEN,GAAG,CAAE;EAClB,CAAC,EAAEI,SAAU,CAAC;EAEd,OAAOA,SAAS;AACjB;AAEA,MAAMQ,YAAY,GAAG9B,OAAO,CAAIE,IAAI,IAAMA,IAAI,CAAC6B,KAAK,CAAE,GAAI,CAAE,CAAC;;AAE7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAGA,CAAEnB,MAAM,EAAEX,IAAI,EAAE+B,YAAY,KAAM;EAAA,IAAAC,MAAA;EACvE,MAAMb,cAAc,GAAGlB,KAAK,CAACC,OAAO,CAAEF,IAAK,CAAC,GAAGA,IAAI,GAAG4B,YAAY,CAAE5B,IAAK,CAAC;EAC1E,IAAIiB,KAAK,GAAGN,MAAM;EAClBQ,cAAc,CAACc,OAAO,CAAIC,SAAS,IAAM;IACxCjB,KAAK,GAAGA,KAAK,GAAIiB,SAAS,CAAE;EAC7B,CAAE,CAAC;EACH,QAAAF,MAAA,GAAOf,KAAK,cAAAe,MAAA,cAAAA,MAAA,GAAID,YAAY;AAC7B,CAAC"}
@@ -1,39 +1,35 @@
1
1
  /**
2
- * WordPress dependencies
2
+ * External dependencies
3
3
  */
4
- import { compose } from '@wordpress/compose';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import traverse from './traverse';
10
- import urlRewrite from './transforms/url-rewrite';
11
- import wrap from './transforms/wrap';
4
+ import postcss from 'postcss';
5
+ import wrap from 'postcss-prefixwrap';
6
+ import rebaseUrl from 'postcss-urlrebase';
12
7
 
13
8
  /**
14
9
  * Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.
15
10
  *
16
- * @param {Object|Array} styles CSS rules.
17
- * @param {string} wrapperClassName Wrapper Class Name.
11
+ * @typedef {Object} EditorStyle
12
+ * @property {string} css the CSS block(s), as a single string.
13
+ * @property {?string} baseURL the base URL to be used as the reference when rewritting urls.
14
+ * @property {?string[]} ignoredSelectors the selectors not to wrap.
15
+ *
16
+ * @param {EditorStyle[]} styles CSS rules.
17
+ * @param {string} wrapperSelector Wrapper selector.
18
18
  * @return {Array} converted rules.
19
19
  */
20
- const transformStyles = (styles, wrapperClassName = '') => {
21
- return Object.values(styles !== null && styles !== void 0 ? styles : []).map(({
20
+ const transformStyles = (styles, wrapperSelector = '') => {
21
+ return styles.map(({
22
22
  css,
23
+ ignoredSelectors = [],
23
24
  baseURL
24
25
  }) => {
25
- const transforms = [];
26
- if (wrapperClassName) {
27
- transforms.push(wrap(wrapperClassName));
28
- }
29
- if (baseURL) {
30
- transforms.push(urlRewrite(baseURL));
31
- }
32
- if (transforms.length) {
33
- return traverse(css, compose(transforms));
34
- }
35
- return css;
26
+ return postcss([wrapperSelector && wrap(wrapperSelector, {
27
+ ignoredSelectors: [...ignoredSelectors, wrapperSelector]
28
+ }), baseURL && rebaseUrl({
29
+ rootUrl: baseURL
30
+ })].filter(Boolean)).process(css, {}).css; // use sync PostCSS API
36
31
  });
37
32
  };
33
+
38
34
  export default transformStyles;
39
35
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["compose","traverse","urlRewrite","wrap","transformStyles","styles","wrapperClassName","Object","values","map","css","baseURL","transforms","push","length"],"sources":["@wordpress/block-editor/src/utils/transform-styles/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { compose } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport traverse from './traverse';\nimport urlRewrite from './transforms/url-rewrite';\nimport wrap from './transforms/wrap';\n\n/**\n * Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.\n *\n * @param {Object|Array} styles CSS rules.\n * @param {string} wrapperClassName Wrapper Class Name.\n * @return {Array} converted rules.\n */\nconst transformStyles = ( styles, wrapperClassName = '' ) => {\n\treturn Object.values( styles ?? [] ).map( ( { css, baseURL } ) => {\n\t\tconst transforms = [];\n\t\tif ( wrapperClassName ) {\n\t\t\ttransforms.push( wrap( wrapperClassName ) );\n\t\t}\n\t\tif ( baseURL ) {\n\t\t\ttransforms.push( urlRewrite( baseURL ) );\n\t\t}\n\t\tif ( transforms.length ) {\n\t\t\treturn traverse( css, compose( transforms ) );\n\t\t}\n\n\t\treturn css;\n\t} );\n};\n\nexport default transformStyles;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,OAAOC,QAAQ,MAAM,YAAY;AACjC,OAAOC,UAAU,MAAM,0BAA0B;AACjD,OAAOC,IAAI,MAAM,mBAAmB;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAGA,CAAEC,MAAM,EAAEC,gBAAgB,GAAG,EAAE,KAAM;EAC5D,OAAOC,MAAM,CAACC,MAAM,CAAEH,MAAM,aAANA,MAAM,cAANA,MAAM,GAAI,EAAG,CAAC,CAACI,GAAG,CAAE,CAAE;IAAEC,GAAG;IAAEC;EAAQ,CAAC,KAAM;IACjE,MAAMC,UAAU,GAAG,EAAE;IACrB,IAAKN,gBAAgB,EAAG;MACvBM,UAAU,CAACC,IAAI,CAAEV,IAAI,CAAEG,gBAAiB,CAAE,CAAC;IAC5C;IACA,IAAKK,OAAO,EAAG;MACdC,UAAU,CAACC,IAAI,CAAEX,UAAU,CAAES,OAAQ,CAAE,CAAC;IACzC;IACA,IAAKC,UAAU,CAACE,MAAM,EAAG;MACxB,OAAOb,QAAQ,CAAES,GAAG,EAAEV,OAAO,CAAEY,UAAW,CAAE,CAAC;IAC9C;IAEA,OAAOF,GAAG;EACX,CAAE,CAAC;AACJ,CAAC;AAED,eAAeN,eAAe"}
1
+ {"version":3,"names":["postcss","wrap","rebaseUrl","transformStyles","styles","wrapperSelector","map","css","ignoredSelectors","baseURL","rootUrl","filter","Boolean","process"],"sources":["@wordpress/block-editor/src/utils/transform-styles/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport postcss from 'postcss';\nimport wrap from 'postcss-prefixwrap';\nimport rebaseUrl from 'postcss-urlrebase';\n\n/**\n * Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.\n *\n * @typedef {Object} EditorStyle\n * @property {string} css the CSS block(s), as a single string.\n * @property {?string} baseURL the base URL to be used as the reference when rewritting urls.\n * @property {?string[]} ignoredSelectors the selectors not to wrap.\n *\n * @param {EditorStyle[]} styles CSS rules.\n * @param {string} wrapperSelector Wrapper selector.\n * @return {Array} converted rules.\n */\nconst transformStyles = ( styles, wrapperSelector = '' ) => {\n\treturn styles.map( ( { css, ignoredSelectors = [], baseURL } ) => {\n\t\treturn postcss(\n\t\t\t[\n\t\t\t\twrapperSelector &&\n\t\t\t\t\twrap( wrapperSelector, {\n\t\t\t\t\t\tignoredSelectors: [\n\t\t\t\t\t\t\t...ignoredSelectors,\n\t\t\t\t\t\t\twrapperSelector,\n\t\t\t\t\t\t],\n\t\t\t\t\t} ),\n\t\t\t\tbaseURL && rebaseUrl( { rootUrl: baseURL } ),\n\t\t\t].filter( Boolean )\n\t\t).process( css, {} ).css; // use sync PostCSS API\n\t} );\n};\n\nexport default transformStyles;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,OAAO,MAAM,SAAS;AAC7B,OAAOC,IAAI,MAAM,oBAAoB;AACrC,OAAOC,SAAS,MAAM,mBAAmB;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAGA,CAAEC,MAAM,EAAEC,eAAe,GAAG,EAAE,KAAM;EAC3D,OAAOD,MAAM,CAACE,GAAG,CAAE,CAAE;IAAEC,GAAG;IAAEC,gBAAgB,GAAG,EAAE;IAAEC;EAAQ,CAAC,KAAM;IACjE,OAAOT,OAAO,CACb,CACCK,eAAe,IACdJ,IAAI,CAAEI,eAAe,EAAE;MACtBG,gBAAgB,EAAE,CACjB,GAAGA,gBAAgB,EACnBH,eAAe;IAEjB,CAAE,CAAC,EACJI,OAAO,IAAIP,SAAS,CAAE;MAAEQ,OAAO,EAAED;IAAQ,CAAE,CAAC,CAC5C,CAACE,MAAM,CAAEC,OAAQ,CACnB,CAAC,CAACC,OAAO,CAAEN,GAAG,EAAE,CAAC,CAAE,CAAC,CAACA,GAAG,CAAC,CAAC;EAC3B,CAAE,CAAC;AACJ,CAAC;;AAED,eAAeJ,eAAe"}