@wordpress/components 25.15.1-next.79a6196f.0 → 25.16.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 (259) hide show
  1. package/CHANGELOG.md +27 -2
  2. package/build/border-box-control/border-box-control/component.js.map +1 -1
  3. package/build/border-box-control/border-box-control/hook.js +3 -1
  4. package/build/border-box-control/border-box-control/hook.js.map +1 -1
  5. package/build/border-box-control/types.js.map +1 -1
  6. package/build/border-control/border-control/component.js +5 -1
  7. package/build/border-control/border-control/component.js.map +1 -1
  8. package/build/border-control/border-control/hook.js +18 -15
  9. package/build/border-control/border-control/hook.js.map +1 -1
  10. package/build/border-control/border-control-dropdown/component.js +2 -1
  11. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  12. package/build/border-control/border-control-style-picker/component.js +21 -49
  13. package/build/border-control/border-control-style-picker/component.js.map +1 -1
  14. package/build/border-control/styles.js +15 -27
  15. package/build/border-control/styles.js.map +1 -1
  16. package/build/border-control/types.js.map +1 -1
  17. package/build/box-control/all-input-control.js +35 -29
  18. package/build/box-control/all-input-control.js.map +1 -1
  19. package/build/box-control/axial-input-controls.js +40 -54
  20. package/build/box-control/axial-input-controls.js.map +1 -1
  21. package/build/box-control/index.js +21 -24
  22. package/build/box-control/index.js.map +1 -1
  23. package/build/box-control/input-controls.js +45 -37
  24. package/build/box-control/input-controls.js.map +1 -1
  25. package/build/box-control/styles/box-control-styles.js +50 -112
  26. package/build/box-control/styles/box-control-styles.js.map +1 -1
  27. package/build/box-control/types.js.map +1 -1
  28. package/build/box-control/utils.js +123 -8
  29. package/build/box-control/utils.js.map +1 -1
  30. package/build/button/index.js +14 -16
  31. package/build/button/index.js.map +1 -1
  32. package/build/button/types.js.map +1 -1
  33. package/build/color-picker/hsl-input.js +55 -33
  34. package/build/color-picker/hsl-input.js.map +1 -1
  35. package/build/custom-select-control-v2/index.js +3 -2
  36. package/build/custom-select-control-v2/index.js.map +1 -1
  37. package/build/slot-fill/bubbles-virtually/use-slot-fills.js +1 -1
  38. package/build/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -1
  39. package/build/theme/styles.js +11 -6
  40. package/build/theme/styles.js.map +1 -1
  41. package/build/toggle-group-control/toggle-group-control/utils.js +7 -1
  42. package/build/toggle-group-control/toggle-group-control/utils.js.map +1 -1
  43. package/build/tooltip/index.js +15 -12
  44. package/build/tooltip/index.js.map +1 -1
  45. package/build/tooltip/types.js.map +1 -1
  46. package/build-module/border-box-control/border-box-control/component.js.map +1 -1
  47. package/build-module/border-box-control/border-box-control/hook.js +3 -1
  48. package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
  49. package/build-module/border-box-control/types.js.map +1 -1
  50. package/build-module/border-control/border-control/component.js +5 -1
  51. package/build-module/border-control/border-control/component.js.map +1 -1
  52. package/build-module/border-control/border-control/hook.js +18 -15
  53. package/build-module/border-control/border-control/hook.js.map +1 -1
  54. package/build-module/border-control/border-control-dropdown/component.js +2 -1
  55. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  56. package/build-module/border-control/border-control-style-picker/component.js +21 -48
  57. package/build-module/border-control/border-control-style-picker/component.js.map +1 -1
  58. package/build-module/border-control/styles.js +14 -24
  59. package/build-module/border-control/styles.js.map +1 -1
  60. package/build-module/border-control/types.js.map +1 -1
  61. package/build-module/box-control/all-input-control.js +38 -28
  62. package/build-module/box-control/all-input-control.js.map +1 -1
  63. package/build-module/box-control/axial-input-controls.js +42 -57
  64. package/build-module/box-control/axial-input-controls.js.map +1 -1
  65. package/build-module/box-control/index.js +22 -25
  66. package/build-module/box-control/index.js.map +1 -1
  67. package/build-module/box-control/input-controls.js +47 -40
  68. package/build-module/box-control/input-controls.js.map +1 -1
  69. package/build-module/box-control/styles/box-control-styles.js +45 -105
  70. package/build-module/box-control/styles/box-control-styles.js.map +1 -1
  71. package/build-module/box-control/types.js.map +1 -1
  72. package/build-module/box-control/utils.js +121 -7
  73. package/build-module/box-control/utils.js.map +1 -1
  74. package/build-module/button/index.js +14 -16
  75. package/build-module/button/index.js.map +1 -1
  76. package/build-module/button/types.js.map +1 -1
  77. package/build-module/color-picker/hsl-input.js +55 -33
  78. package/build-module/color-picker/hsl-input.js.map +1 -1
  79. package/build-module/custom-select-control-v2/index.js +3 -2
  80. package/build-module/custom-select-control-v2/index.js.map +1 -1
  81. package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js +1 -1
  82. package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -1
  83. package/build-module/theme/styles.js +11 -2
  84. package/build-module/theme/styles.js.map +1 -1
  85. package/build-module/toggle-group-control/toggle-group-control/utils.js +7 -1
  86. package/build-module/toggle-group-control/toggle-group-control/utils.js.map +1 -1
  87. package/build-module/tooltip/index.js +16 -13
  88. package/build-module/tooltip/index.js.map +1 -1
  89. package/build-module/tooltip/types.js.map +1 -1
  90. package/build-style/style-rtl.css +6 -4
  91. package/build-style/style.css +6 -4
  92. package/build-types/border-box-control/border-box-control/component.d.ts +1 -0
  93. package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
  94. package/build-types/border-box-control/border-box-control/hook.d.ts +4 -4
  95. package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
  96. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +5 -5
  97. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +4 -4
  98. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +4 -4
  99. package/build-types/border-box-control/stories/index.story.d.ts +2 -1
  100. package/build-types/border-box-control/stories/index.story.d.ts.map +1 -1
  101. package/build-types/border-box-control/types.d.ts +6 -0
  102. package/build-types/border-box-control/types.d.ts.map +1 -1
  103. package/build-types/border-control/border-control/component.d.ts +1 -0
  104. package/build-types/border-control/border-control/component.d.ts.map +1 -1
  105. package/build-types/border-control/border-control/hook.d.ts +6 -4
  106. package/build-types/border-control/border-control/hook.d.ts.map +1 -1
  107. package/build-types/border-control/border-control-dropdown/component.d.ts +1 -0
  108. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  109. package/build-types/border-control/border-control-dropdown/hook.d.ts +5 -4
  110. package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
  111. package/build-types/border-control/border-control-style-picker/component.d.ts +3 -4
  112. package/build-types/border-control/border-control-style-picker/component.d.ts.map +1 -1
  113. package/build-types/border-control/stories/index.story.d.ts +12 -6
  114. package/build-types/border-control/stories/index.story.d.ts.map +1 -1
  115. package/build-types/border-control/styles.d.ts +0 -2
  116. package/build-types/border-control/styles.d.ts.map +1 -1
  117. package/build-types/border-control/types.d.ts +12 -1
  118. package/build-types/border-control/types.d.ts.map +1 -1
  119. package/build-types/box-control/all-input-control.d.ts +1 -1
  120. package/build-types/box-control/all-input-control.d.ts.map +1 -1
  121. package/build-types/box-control/axial-input-controls.d.ts +1 -1
  122. package/build-types/box-control/axial-input-controls.d.ts.map +1 -1
  123. package/build-types/box-control/index.d.ts +1 -1
  124. package/build-types/box-control/index.d.ts.map +1 -1
  125. package/build-types/box-control/input-controls.d.ts +1 -1
  126. package/build-types/box-control/input-controls.d.ts.map +1 -1
  127. package/build-types/box-control/stories/index.story.d.ts +42 -36
  128. package/build-types/box-control/stories/index.story.d.ts.map +1 -1
  129. package/build-types/box-control/styles/box-control-styles.d.ts +49 -23
  130. package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -1
  131. package/build-types/box-control/types.d.ts +12 -12
  132. package/build-types/box-control/types.d.ts.map +1 -1
  133. package/build-types/box-control/utils.d.ts +2 -1
  134. package/build-types/box-control/utils.d.ts.map +1 -1
  135. package/build-types/button/deprecated.d.ts +3 -3
  136. package/build-types/button/index.d.ts.map +1 -1
  137. package/build-types/button/types.d.ts +7 -3
  138. package/build-types/button/types.d.ts.map +1 -1
  139. package/build-types/card/card/hook.d.ts +4 -4
  140. package/build-types/card/card-body/hook.d.ts +4 -4
  141. package/build-types/card/card-divider/hook.d.ts +4 -4
  142. package/build-types/card/card-footer/hook.d.ts +4 -4
  143. package/build-types/card/card-header/hook.d.ts +4 -4
  144. package/build-types/card/card-media/hook.d.ts +4 -4
  145. package/build-types/color-palette/styles.d.ts +2 -2
  146. package/build-types/color-picker/component.d.ts +1 -1
  147. package/build-types/color-picker/hsl-input.d.ts.map +1 -1
  148. package/build-types/color-picker/stories/index.story.d.ts +1 -1
  149. package/build-types/color-picker/styles.d.ts +3 -3
  150. package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
  151. package/build-types/date-time/date/styles.d.ts +3 -3
  152. package/build-types/date-time/date-time/styles.d.ts +1 -1
  153. package/build-types/date-time/time/styles.d.ts +4 -4
  154. package/build-types/elevation/hook.d.ts +4 -4
  155. package/build-types/flex/flex/hook.d.ts +4 -4
  156. package/build-types/flex/flex-block/hook.d.ts +4 -4
  157. package/build-types/flex/flex-item/hook.d.ts +4 -4
  158. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
  159. package/build-types/font-size-picker/styles.d.ts +1 -1
  160. package/build-types/grid/hook.d.ts +4 -4
  161. package/build-types/h-stack/hook.d.ts +4 -4
  162. package/build-types/heading/component.d.ts +1 -1
  163. package/build-types/heading/hook.d.ts +4 -4
  164. package/build-types/item-group/item/hook.d.ts +4 -4
  165. package/build-types/item-group/item-group/hook.d.ts +4 -4
  166. package/build-types/menu-item/index.d.ts +1 -1
  167. package/build-types/menu-item/stories/index.story.d.ts +4 -4
  168. package/build-types/navigation/styles/navigation-styles.d.ts +2 -2
  169. package/build-types/navigator/navigator-back-button/hook.d.ts +4 -4
  170. package/build-types/navigator/navigator-button/hook.d.ts +4 -4
  171. package/build-types/number-control/index.d.ts +1 -1
  172. package/build-types/number-control/stories/index.story.d.ts +1 -1
  173. package/build-types/palette-edit/styles.d.ts +3 -3
  174. package/build-types/range-control/index.d.ts +1 -1
  175. package/build-types/range-control/styles/range-control-styles.d.ts +1 -1
  176. package/build-types/resizable-box/index.d.ts +1 -1
  177. package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
  178. package/build-types/resizable-box/stories/index.story.d.ts +2 -2
  179. package/build-types/scrollable/hook.d.ts +4 -4
  180. package/build-types/spacer/hook.d.ts +4 -4
  181. package/build-types/surface/hook.d.ts +4 -4
  182. package/build-types/text/hook.d.ts +4 -4
  183. package/build-types/theme/styles.d.ts.map +1 -1
  184. package/build-types/toggle-control/stories/index.story.d.ts +2 -2
  185. package/build-types/toggle-group-control/toggle-group-control/utils.d.ts.map +1 -1
  186. package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +1 -1
  187. package/build-types/toolbar/toolbar-button/index.d.ts +3 -3
  188. package/build-types/tools-panel/tools-panel/hook.d.ts +4 -4
  189. package/build-types/tools-panel/tools-panel-header/hook.d.ts +4 -4
  190. package/build-types/tools-panel/tools-panel-item/hook.d.ts +4 -4
  191. package/build-types/tooltip/index.d.ts +1 -1
  192. package/build-types/tooltip/index.d.ts.map +1 -1
  193. package/build-types/tooltip/stories/index.story.d.ts +1 -1
  194. package/build-types/tooltip/stories/index.story.d.ts.map +1 -1
  195. package/build-types/tooltip/types.d.ts +1 -1
  196. package/build-types/tooltip/types.d.ts.map +1 -1
  197. package/build-types/truncate/hook.d.ts +4 -4
  198. package/build-types/unit-control/index.d.ts +1 -1
  199. package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -1
  200. package/build-types/v-stack/hook.d.ts +4 -4
  201. package/build-types/v-stack/stories/index.story.d.ts +1 -1
  202. package/package.json +19 -19
  203. package/src/border-box-control/border-box-control/component.tsx +0 -1
  204. package/src/border-box-control/border-box-control/hook.ts +5 -1
  205. package/src/border-box-control/types.ts +6 -0
  206. package/src/border-control/border-control/component.tsx +4 -0
  207. package/src/border-control/border-control/hook.ts +22 -16
  208. package/src/border-control/border-control-dropdown/component.tsx +2 -1
  209. package/src/border-control/border-control-style-picker/component.tsx +31 -66
  210. package/src/border-control/styles.ts +0 -15
  211. package/src/border-control/types.ts +15 -1
  212. package/src/box-control/all-input-control.tsx +57 -34
  213. package/src/box-control/axial-input-controls.tsx +79 -69
  214. package/src/box-control/index.tsx +47 -54
  215. package/src/box-control/input-controls.tsx +114 -83
  216. package/src/box-control/styles/box-control-styles.ts +21 -61
  217. package/src/box-control/test/index.tsx +126 -18
  218. package/src/box-control/types.ts +10 -21
  219. package/src/box-control/utils.ts +43 -8
  220. package/src/button/README.md +1 -1
  221. package/src/button/index.tsx +21 -33
  222. package/src/button/test/index.tsx +122 -0
  223. package/src/button/types.ts +7 -3
  224. package/src/circular-option-picker/test/index.tsx +10 -16
  225. package/src/color-picker/hsl-input.tsx +56 -30
  226. package/src/color-picker/test/index.tsx +190 -16
  227. package/src/custom-select-control-v2/index.tsx +5 -2
  228. package/src/palette-edit/test/index.tsx +326 -10
  229. package/src/slot-fill/bubbles-virtually/use-slot-fills.ts +1 -1
  230. package/src/tabs/test/index.tsx +3 -1
  231. package/src/theme/styles.ts +3 -1
  232. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +6 -6
  233. package/src/toggle-group-control/test/index.tsx +73 -36
  234. package/src/toggle-group-control/toggle-group-control/utils.ts +8 -3
  235. package/src/tooltip/index.tsx +29 -29
  236. package/src/tooltip/test/index.tsx +32 -13
  237. package/src/tooltip/types.ts +1 -1
  238. package/tsconfig.tsbuildinfo +1 -1
  239. package/build/border-control/border-control-style-picker/hook.js +0 -41
  240. package/build/border-control/border-control-style-picker/hook.js.map +0 -1
  241. package/build/box-control/styles/box-control-visualizer-styles.js +0 -93
  242. package/build/box-control/styles/box-control-visualizer-styles.js.map +0 -1
  243. package/build/box-control/unit-control.js +0 -76
  244. package/build/box-control/unit-control.js.map +0 -1
  245. package/build-module/border-control/border-control-style-picker/hook.js +0 -32
  246. package/build-module/border-control/border-control-style-picker/hook.js.map +0 -1
  247. package/build-module/box-control/styles/box-control-visualizer-styles.js +0 -86
  248. package/build-module/box-control/styles/box-control-visualizer-styles.js.map +0 -1
  249. package/build-module/box-control/unit-control.js +0 -68
  250. package/build-module/box-control/unit-control.js.map +0 -1
  251. package/build-types/border-control/border-control-style-picker/hook.d.ts +0 -267
  252. package/build-types/border-control/border-control-style-picker/hook.d.ts.map +0 -1
  253. package/build-types/box-control/styles/box-control-visualizer-styles.d.ts +0 -46
  254. package/build-types/box-control/styles/box-control-visualizer-styles.d.ts.map +0 -1
  255. package/build-types/box-control/unit-control.d.ts +0 -4
  256. package/build-types/box-control/unit-control.d.ts.map +0 -1
  257. package/src/border-control/border-control-style-picker/hook.ts +0 -35
  258. package/src/box-control/styles/box-control-visualizer-styles.ts +0 -75
  259. package/src/box-control/unit-control.tsx +0 -74
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","useMemo","useState","styles","parseQuantityAndUnitFromRawValue","useContextSystem","useCx","sanitizeBorder","border","hasNoWidth","width","undefined","hasNoColor","color","useBorderControl","props","className","colors","isCompact","onChange","enableAlpha","enableStyle","shouldSanitizeBorder","size","value","__experimentalIsRenderedInSidebar","otherProps","widthValue","originalWidthUnit","widthUnit","hadPreviousZeroWidth","colorSelection","setColorSelection","styleSelection","setStyleSelection","onBorderChange","newBorder","onWidthChange","newWidth","newWidthValue","parsedValue","hasZeroWidth","updatedBorder","style","onSliderChange","cx","classes","borderControl","wrapperWidth","innerWrapperClassName","widthStyle","heightStyle","wrapperHeight","innerWrapper","sliderClassName","borderSlider","inputWidth","previousStyleSelection"],"sources":["@wordpress/components/src/border-control/border-control/hook.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { parseQuantityAndUnitFromRawValue } from '../../unit-control/utils';\nimport type { WordPressComponentProps } from '../../context';\nimport { useContextSystem } from '../../context';\nimport { useCx } from '../../utils/hooks/use-cx';\n\nimport type { Border, BorderControlProps } from '../types';\n\nconst sanitizeBorder = ( border?: Border ) => {\n\tconst hasNoWidth = border?.width === undefined || border.width === '';\n\tconst hasNoColor = border?.color === undefined;\n\n\t// If width and color are undefined, unset any style selection as well.\n\tif ( hasNoWidth && hasNoColor ) {\n\t\treturn undefined;\n\t}\n\n\treturn border;\n};\n\nexport function useBorderControl(\n\tprops: WordPressComponentProps< BorderControlProps, 'div' >\n) {\n\tconst {\n\t\tclassName,\n\t\tcolors = [],\n\t\tisCompact,\n\t\tonChange,\n\t\tenableAlpha = true,\n\t\tenableStyle = true,\n\t\tshouldSanitizeBorder = true,\n\t\tsize = 'default',\n\t\tvalue: border,\n\t\twidth,\n\t\t__experimentalIsRenderedInSidebar = false,\n\t\t...otherProps\n\t} = useContextSystem( props, 'BorderControl' );\n\n\tconst [ widthValue, originalWidthUnit ] = parseQuantityAndUnitFromRawValue(\n\t\tborder?.width\n\t);\n\tconst widthUnit = originalWidthUnit || 'px';\n\tconst hadPreviousZeroWidth = widthValue === 0;\n\n\tconst [ colorSelection, setColorSelection ] = useState< string >();\n\tconst [ styleSelection, setStyleSelection ] = useState< string >();\n\n\tconst onBorderChange = useCallback(\n\t\t( newBorder?: Border ) => {\n\t\t\tif ( shouldSanitizeBorder ) {\n\t\t\t\treturn onChange( sanitizeBorder( newBorder ) );\n\t\t\t}\n\n\t\t\tonChange( newBorder );\n\t\t},\n\t\t[ onChange, shouldSanitizeBorder ]\n\t);\n\n\tconst onWidthChange = useCallback(\n\t\t( newWidth?: string ) => {\n\t\t\tconst newWidthValue = newWidth === '' ? undefined : newWidth;\n\t\t\tconst [ parsedValue ] =\n\t\t\t\tparseQuantityAndUnitFromRawValue( newWidth );\n\t\t\tconst hasZeroWidth = parsedValue === 0;\n\t\t\tconst updatedBorder = { ...border, width: newWidthValue };\n\n\t\t\t// Setting the border width explicitly to zero will also set the\n\t\t\t// border style to `none` and clear the border color.\n\t\t\tif ( hasZeroWidth && ! hadPreviousZeroWidth ) {\n\t\t\t\t// Before clearing the color and style selections, keep track of\n\t\t\t\t// the current selections so they can be restored when the width\n\t\t\t\t// changes to a non-zero value.\n\t\t\t\tsetColorSelection( border?.color );\n\t\t\t\tsetStyleSelection( border?.style );\n\n\t\t\t\t// Clear the color and style border properties.\n\t\t\t\tupdatedBorder.color = undefined;\n\t\t\t\tupdatedBorder.style = 'none';\n\t\t\t}\n\n\t\t\t// Selection has changed from zero border width to non-zero width.\n\t\t\tif ( ! hasZeroWidth && hadPreviousZeroWidth ) {\n\t\t\t\t// Restore previous border color and style selections if width\n\t\t\t\t// is now not zero.\n\t\t\t\tif ( updatedBorder.color === undefined ) {\n\t\t\t\t\tupdatedBorder.color = colorSelection;\n\t\t\t\t}\n\t\t\t\tif ( updatedBorder.style === 'none' ) {\n\t\t\t\t\tupdatedBorder.style = styleSelection;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tonBorderChange( updatedBorder );\n\t\t},\n\t\t[\n\t\t\tborder,\n\t\t\thadPreviousZeroWidth,\n\t\t\tcolorSelection,\n\t\t\tstyleSelection,\n\t\t\tonBorderChange,\n\t\t]\n\t);\n\n\tconst onSliderChange = useCallback(\n\t\t( value?: number ) => {\n\t\t\tonWidthChange( `${ value }${ widthUnit }` );\n\t\t},\n\t\t[ onWidthChange, widthUnit ]\n\t);\n\n\t// Generate class names.\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\treturn cx( styles.borderControl, className );\n\t}, [ className, cx ] );\n\n\tlet wrapperWidth = width;\n\tif ( isCompact ) {\n\t\t// Widths below represent the minimum usable width for compact controls.\n\t\t// Taller controls contain greater internal padding, thus greater width.\n\t\twrapperWidth = size === '__unstable-large' ? '116px' : '90px';\n\t}\n\tconst innerWrapperClassName = useMemo( () => {\n\t\tconst widthStyle = !! wrapperWidth && styles.wrapperWidth;\n\t\tconst heightStyle = styles.wrapperHeight( size );\n\n\t\treturn cx( styles.innerWrapper(), widthStyle, heightStyle );\n\t}, [ wrapperWidth, cx, size ] );\n\n\tconst sliderClassName = useMemo( () => {\n\t\treturn cx( styles.borderSlider() );\n\t}, [ cx ] );\n\n\treturn {\n\t\t...otherProps,\n\t\tclassName: classes,\n\t\tcolors,\n\t\tenableAlpha,\n\t\tenableStyle,\n\t\tinnerWrapperClassName,\n\t\tinputWidth: wrapperWidth,\n\t\tonBorderChange,\n\t\tonSliderChange,\n\t\tonWidthChange,\n\t\tpreviousStyleSelection: styleSelection,\n\t\tsliderClassName,\n\t\tvalue: border,\n\t\twidthUnit,\n\t\twidthValue,\n\t\tsize,\n\t\t__experimentalIsRenderedInSidebar,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;;AAEnE;AACA;AACA;AACA,OAAO,KAAKC,MAAM,MAAM,WAAW;AACnC,SAASC,gCAAgC,QAAQ,0BAA0B;AAE3E,SAASC,gBAAgB,QAAQ,eAAe;AAChD,SAASC,KAAK,QAAQ,0BAA0B;AAIhD,MAAMC,cAAc,GAAKC,MAAe,IAAM;EAC7C,MAAMC,UAAU,GAAGD,MAAM,EAAEE,KAAK,KAAKC,SAAS,IAAIH,MAAM,CAACE,KAAK,KAAK,EAAE;EACrE,MAAME,UAAU,GAAGJ,MAAM,EAAEK,KAAK,KAAKF,SAAS;;EAE9C;EACA,IAAKF,UAAU,IAAIG,UAAU,EAAG;IAC/B,OAAOD,SAAS;EACjB;EAEA,OAAOH,MAAM;AACd,CAAC;AAED,OAAO,SAASM,gBAAgBA,CAC/BC,KAA2D,EAC1D;EACD,MAAM;IACLC,SAAS;IACTC,MAAM,GAAG,EAAE;IACXC,SAAS;IACTC,QAAQ;IACRC,WAAW,GAAG,IAAI;IAClBC,WAAW,GAAG,IAAI;IAClBC,oBAAoB,GAAG,IAAI;IAC3BC,IAAI,GAAG,SAAS;IAChBC,KAAK,EAAEhB,MAAM;IACbE,KAAK;IACLe,iCAAiC,GAAG,KAAK;IACzC,GAAGC;EACJ,CAAC,GAAGrB,gBAAgB,CAAEU,KAAK,EAAE,eAAgB,CAAC;EAE9C,MAAM,CAAEY,UAAU,EAAEC,iBAAiB,CAAE,GAAGxB,gCAAgC,CACzEI,MAAM,EAAEE,KACT,CAAC;EACD,MAAMmB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Y,CAAC,CAAE,CAAC;EACnC,CAAC,EAAE,CAAEV,EAAE,CAAG,CAAC;EAEX,OAAO;IACN,GAAGnB,UAAU;IACbV,SAAS,EAAE8B,OAAO;IAClB7B,MAAM;IACNG,WAAW;IACXC,WAAW;IACX4B,qBAAqB;IACrBO,UAAU,EAAER,YAAY;IACxBb,cAAc;IACdS,cAAc;IACdP,aAAa;IACboB,sBAAsB,EAAExB,cAAc;IACtCqB,eAAe;IACf9B,KAAK,EAAEhB,MAAM;IACbqB,SAAS;IACTF,UAAU;IACVJ,IAAI;IACJE;EACD,CAAC;AACF"}
1
+ {"version":3,"names":["useCallback","useMemo","useState","styles","parseQuantityAndUnitFromRawValue","useContextSystem","useCx","isValidBorder","border","hasWidth","width","undefined","hasColor","color","useBorderControl","props","className","colors","isCompact","onChange","enableAlpha","enableStyle","shouldSanitizeBorder","size","value","__experimentalIsRenderedInSidebar","__next40pxDefaultSize","otherProps","computedSize","widthValue","originalWidthUnit","widthUnit","hadPreviousZeroWidth","colorSelection","setColorSelection","styleSelection","setStyleSelection","isStyleSettable","onBorderChange","newBorder","onWidthChange","newWidth","newWidthValue","parsedValue","hasZeroWidth","updatedBorder","style","onSliderChange","cx","classes","borderControl","wrapperWidth","innerWrapperClassName","widthStyle","heightStyle","wrapperHeight","innerWrapper","sliderClassName","borderSlider","inputWidth","previousStyleSelection"],"sources":["@wordpress/components/src/border-control/border-control/hook.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { parseQuantityAndUnitFromRawValue } from '../../unit-control/utils';\nimport type { WordPressComponentProps } from '../../context';\nimport { useContextSystem } from '../../context';\nimport { useCx } from '../../utils/hooks/use-cx';\n\nimport type { Border, BorderControlProps } from '../types';\n\n// If either width or color are defined, the border is considered valid\n// and a border style can be set as well.\nconst isValidBorder = ( border?: Border ) => {\n\tconst hasWidth = border?.width !== undefined && border.width !== '';\n\tconst hasColor = border?.color !== undefined;\n\treturn hasWidth || hasColor;\n};\n\nexport function useBorderControl(\n\tprops: WordPressComponentProps< BorderControlProps, 'div' >\n) {\n\tconst {\n\t\tclassName,\n\t\tcolors = [],\n\t\tisCompact,\n\t\tonChange,\n\t\tenableAlpha = true,\n\t\tenableStyle = true,\n\t\tshouldSanitizeBorder = true,\n\t\tsize = 'default',\n\t\tvalue: border,\n\t\twidth,\n\t\t__experimentalIsRenderedInSidebar = false,\n\t\t__next40pxDefaultSize,\n\t\t...otherProps\n\t} = useContextSystem( props, 'BorderControl' );\n\n\tconst computedSize =\n\t\tsize === 'default' && __next40pxDefaultSize ? '__unstable-large' : size;\n\n\tconst [ widthValue, originalWidthUnit ] = parseQuantityAndUnitFromRawValue(\n\t\tborder?.width\n\t);\n\tconst widthUnit = originalWidthUnit || 'px';\n\tconst hadPreviousZeroWidth = widthValue === 0;\n\n\tconst [ colorSelection, setColorSelection ] = useState< string >();\n\tconst [ styleSelection, setStyleSelection ] = useState< string >();\n\n\tconst isStyleSettable = shouldSanitizeBorder\n\t\t? isValidBorder( border )\n\t\t: true;\n\n\tconst onBorderChange = useCallback(\n\t\t( newBorder?: Border ) => {\n\t\t\tif ( shouldSanitizeBorder && ! isValidBorder( newBorder ) ) {\n\t\t\t\tonChange( undefined );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonChange( newBorder );\n\t\t},\n\t\t[ onChange, shouldSanitizeBorder ]\n\t);\n\n\tconst onWidthChange = useCallback(\n\t\t( newWidth?: string ) => {\n\t\t\tconst newWidthValue = newWidth === '' ? undefined : newWidth;\n\t\t\tconst [ parsedValue ] =\n\t\t\t\tparseQuantityAndUnitFromRawValue( newWidth );\n\t\t\tconst hasZeroWidth = parsedValue === 0;\n\t\t\tconst updatedBorder = { ...border, width: newWidthValue };\n\n\t\t\t// Setting the border width explicitly to zero will also set the\n\t\t\t// border style to `none` and clear the border color.\n\t\t\tif ( hasZeroWidth && ! hadPreviousZeroWidth ) {\n\t\t\t\t// Before clearing the color and style selections, keep track of\n\t\t\t\t// the current selections so they can be restored when the width\n\t\t\t\t// changes to a non-zero value.\n\t\t\t\tsetColorSelection( border?.color );\n\t\t\t\tsetStyleSelection( border?.style );\n\n\t\t\t\t// Clear the color and style border properties.\n\t\t\t\tupdatedBorder.color = undefined;\n\t\t\t\tupdatedBorder.style = 'none';\n\t\t\t}\n\n\t\t\t// Selection has changed from zero border width to non-zero width.\n\t\t\tif ( ! hasZeroWidth && hadPreviousZeroWidth ) {\n\t\t\t\t// Restore previous border color and style selections if width\n\t\t\t\t// is now not zero.\n\t\t\t\tif ( updatedBorder.color === undefined ) {\n\t\t\t\t\tupdatedBorder.color = colorSelection;\n\t\t\t\t}\n\t\t\t\tif ( updatedBorder.style === 'none' ) {\n\t\t\t\t\tupdatedBorder.style = styleSelection;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tonBorderChange( updatedBorder );\n\t\t},\n\t\t[\n\t\t\tborder,\n\t\t\thadPreviousZeroWidth,\n\t\t\tcolorSelection,\n\t\t\tstyleSelection,\n\t\t\tonBorderChange,\n\t\t]\n\t);\n\n\tconst onSliderChange = useCallback(\n\t\t( value?: number ) => {\n\t\t\tonWidthChange( `${ value }${ widthUnit }` );\n\t\t},\n\t\t[ onWidthChange, widthUnit ]\n\t);\n\n\t// Generate class names.\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\treturn cx( styles.borderControl, className );\n\t}, [ className, cx ] );\n\n\tlet wrapperWidth = width;\n\tif ( isCompact ) {\n\t\t// Widths below represent the minimum usable width for compact controls.\n\t\t// Taller controls contain greater internal padding, thus greater width.\n\t\twrapperWidth = size === '__unstable-large' ? '116px' : '90px';\n\t}\n\tconst innerWrapperClassName = useMemo( () => {\n\t\tconst widthStyle = !! wrapperWidth && styles.wrapperWidth;\n\t\tconst heightStyle = styles.wrapperHeight( computedSize );\n\n\t\treturn cx( styles.innerWrapper(), widthStyle, heightStyle );\n\t}, [ wrapperWidth, cx, computedSize ] );\n\n\tconst sliderClassName = useMemo( () => {\n\t\treturn cx( styles.borderSlider() );\n\t}, [ cx ] );\n\n\treturn {\n\t\t...otherProps,\n\t\tclassName: classes,\n\t\tcolors,\n\t\tenableAlpha,\n\t\tenableStyle,\n\t\tinnerWrapperClassName,\n\t\tinputWidth: wrapperWidth,\n\t\tisStyleSettable,\n\t\tonBorderChange,\n\t\tonSliderChange,\n\t\tonWidthChange,\n\t\tpreviousStyleSelection: styleSelection,\n\t\tsliderClassName,\n\t\tvalue: border,\n\t\twidthUnit,\n\t\twidthValue,\n\t\tsize: computedSize,\n\t\t__experimentalIsRenderedInSidebar,\n\t\t__next40pxDefaultSize,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;;AAEnE;AACA;AACA;AACA,OAAO,KAAKC,MAAM,MAAM,WAAW;AACnC,SAASC,gCAAgC,QAAQ,0BAA0B;AAE3E,SAASC,gBAAgB,QAAQ,eAAe;AAChD,SAASC,KAAK,QAAQ,0BAA0B;AAIhD;AACA;AACA,MAAMC,aAAa,GAAKC,MAAe,IAAM;EAC5C,MAAMC,QAAQ,GAAGD,MAAM,EAAEE,KAAK,KAAKC,SAAS,IAAIH,MAAM,CAACE,KAAK,KAAK,EAAE;EACnE,MAAME,QAAQ,GAAGJ,MAAM,EAAEK,KAAK,KAAKF,SAAS;EAC5C,OAAOF,QAAQ,IAAIG,QAAQ;AAC5B,CAAC;AAED,OAAO,SAASE,gBAAgBA,CAC/BC,KAA2D,EAC1D;EACD,MAAM;IACLC,SAAS;IACTC,MAAM,GAAG,EAAE;IACXC,SAAS;IACTC,QAAQ;IACRC,WAAW,GAAG,IAAI;IAClBC,WAAW,GAAG,IAAI;IAClBC,oBAAoB,GAAG,IAAI;IAC3BC,IAAI,GAAG,SAAS;IAChBC,KAAK,EAAEhB,MAAM;IACbE,KAAK;IACLe,iCAAiC,GAAG,KAAK;IACzCC,q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CAAC,CAAEF,YAAY,IAAIhD,MAAM,CAACgD,YAAY;IACzD,MAAMG,WAAW,GAAGnD,MAAM,CAACoD,aAAa,CAAE3B,YAAa,CAAC;IAExD,OAAOoB,EAAE,CAAE7C,MAAM,CAACqD,YAAY,CAAC,CAAC,EAAEH,UAAU,EAAEC,WAAY,CAAC;EAC5D,CAAC,EAAE,CAAEH,YAAY,EAAEH,EAAE,EAAEpB,YAAY,CAAG,CAAC;EAEvC,MAAM6B,eAAe,GAAGxD,OAAO,CAAE,MAAM;IACtC,OAAO+C,EAAE,CAAE7C,MAAM,CAACuD,YAAY,CAAC,CAAE,CAAC;EACnC,CAAC,EAAE,CAAEV,EAAE,CAAG,CAAC;EAEX,OAAO;IACN,GAAGrB,UAAU;IACbX,SAAS,EAAEiC,OAAO;IAClBhC,MAAM;IACNG,WAAW;IACXC,WAAW;IACX+B,qBAAqB;IACrBO,UAAU,EAAER,YAAY;IACxBd,eAAe;IACfC,cAAc;IACdS,cAAc;IACdP,aAAa;IACboB,sBAAsB,EAAEzB,cAAc;IACtCsB,eAAe;IACfjC,KAAK,EAAEhB,MAAM;IACbuB,SAAS;IACTF,UAAU;IACVN,IAAI,EAAEK,YAAY;IAClBH,iCAAiC;IACjCC;EACD,CAAC;AACF"}
@@ -90,6 +90,7 @@ const BorderControlDropdown = (props, forwardedRef) => {
90
90
  enableStyle,
91
91
  indicatorClassName,
92
92
  indicatorWrapperClassName,
93
+ isStyleSettable,
93
94
  onReset,
94
95
  onColorChange,
95
96
  onStyleChange,
@@ -146,7 +147,7 @@ const BorderControlDropdown = (props, forwardedRef) => {
146
147
  __experimentalIsRenderedInSidebar: __experimentalIsRenderedInSidebar,
147
148
  clearable: false,
148
149
  enableAlpha: enableAlpha
149
- }), enableStyle && createElement(BorderControlStylePicker, {
150
+ }), enableStyle && isStyleSettable && createElement(BorderControlStylePicker, {
150
151
  label: __('Style'),
151
152
  value: style,
152
153
  onChange: onStyleChange
@@ -1 +1 @@
1
- {"version":3,"names":["__","sprintf","closeSmall","BorderControlStylePicker","Button","ColorIndicator","ColorPalette","Dropdown","HStack","VStack","contextConnect","useBorderControlDropdown","StyledLabel","DropdownContentWrapper","isMultiplePaletteArray","getAriaLabelColorValue","colorValue","replace","getColorObject","colors","matchedColor","some","origin","color","find","getToggleAriaLabel","colorObject","style","isStyleEnabled","ariaLabelValue","name","BorderControlDropdown","props","forwardedRef","__experimentalIsRenderedInSidebar","border","disableCustomColors","enableAlpha","enableStyle","indicatorClassName","indicatorWrapperClassName","onReset","onColorChange","onStyleChange","popoverContentClassName","popoverControlsClassName","resetButtonClassName","showDropdownHeader","size","__unstablePopoverProps","otherProps","toggleAriaLabel","showResetButton","dropdownPosition","undefined","renderToggle","onToggle","createElement","onClick","variant","tooltipPosition","label","showTooltip","__next40pxDefaultSize","className","renderContent","onClose","Fragment","paddingSize","spacing","icon","value","onChange","clearable","popoverProps","ref","ConnectedBorderControlDropdown"],"sources":["@wordpress/components/src/border-control/border-control-dropdown/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BorderControlStylePicker from '../border-control-style-picker';\nimport Button from '../../button';\nimport ColorIndicator from '../../color-indicator';\nimport ColorPalette from '../../color-palette';\nimport Dropdown from '../../dropdown';\nimport { HStack } from '../../h-stack';\nimport { VStack } from '../../v-stack';\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect } from '../../context';\nimport { useBorderControlDropdown } from './hook';\nimport { StyledLabel } from '../../base-control/styles/base-control-styles';\nimport DropdownContentWrapper from '../../dropdown/dropdown-content-wrapper';\n\nimport type { ColorObject } from '../../color-palette/types';\nimport { isMultiplePaletteArray } from '../../color-palette/utils';\nimport type { DropdownProps as DropdownComponentProps } from '../../dropdown/types';\nimport type { ColorProps, DropdownProps } from '../types';\n\nconst getAriaLabelColorValue = ( colorValue: string ) => {\n\t// Leave hex values as-is. Remove the `var()` wrapper from CSS vars.\n\treturn colorValue.replace( /^var\\((.+)\\)$/, '$1' );\n};\n\nconst getColorObject = (\n\tcolorValue: CSSProperties[ 'borderColor' ],\n\tcolors: ColorProps[ 'colors' ] | undefined\n) => {\n\tif ( ! colorValue || ! colors ) {\n\t\treturn;\n\t}\n\n\tif ( isMultiplePaletteArray( colors ) ) {\n\t\t// Multiple origins\n\t\tlet matchedColor;\n\n\t\tcolors.some( ( origin ) =>\n\t\t\torigin.colors.some( ( color ) => {\n\t\t\t\tif ( color.color === colorValue ) {\n\t\t\t\t\tmatchedColor = color;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t} )\n\t\t);\n\n\t\treturn matchedColor;\n\t}\n\n\t// Single origin\n\treturn colors.find( ( color ) => color.color === colorValue );\n};\n\nconst getToggleAriaLabel = (\n\tcolorValue: CSSProperties[ 'borderColor' ],\n\tcolorObject: ColorObject | undefined,\n\tstyle: CSSProperties[ 'borderStyle' ],\n\tisStyleEnabled: boolean\n) => {\n\tif ( isStyleEnabled ) {\n\t\tif ( colorObject ) {\n\t\t\tconst ariaLabelValue = getAriaLabelColorValue( colorObject.color );\n\t\t\treturn style\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %1$s: The name of the color e.g. \"vivid red\". %2$s: The color's hex code e.g.: \"#f00:\". %3$s: The current border style selection e.g. \"solid\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\". The currently selected style is \"%3$s\".',\n\t\t\t\t\t\tcolorObject.name,\n\t\t\t\t\t\tariaLabelValue,\n\t\t\t\t\t\tstyle\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t// translators: %1$s: The name of the color e.g. \"vivid red\". %2$s: The color's hex code e.g.: \"#f00:\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".',\n\t\t\t\t\t\tcolorObject.name,\n\t\t\t\t\t\tariaLabelValue\n\t\t\t\t );\n\t\t}\n\n\t\tif ( colorValue ) {\n\t\t\tconst ariaLabelValue = getAriaLabelColorValue( colorValue );\n\t\t\treturn style\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %1$s: The color's hex code e.g.: \"#f00:\". %2$s: The current border style selection e.g. \"solid\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color has a value of \"%1$s\". The currently selected style is \"%2$s\".',\n\t\t\t\t\t\tariaLabelValue,\n\t\t\t\t\t\tstyle\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t// translators: %1$s: The color's hex code e.g: \"#f00\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color has a value of \"%1$s\".',\n\t\t\t\t\t\tariaLabelValue\n\t\t\t\t );\n\t\t}\n\n\t\treturn __( 'Border color and style picker.' );\n\t}\n\n\tif ( colorObject ) {\n\t\treturn sprintf(\n\t\t\t// translators: %1$s: The name of the color e.g. \"vivid red\". %2$s: The color's hex code e.g: \"#f00\".\n\t\t\t'Border color picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".',\n\t\t\tcolorObject.name,\n\t\t\tgetAriaLabelColorValue( colorObject.color )\n\t\t);\n\t}\n\n\tif ( colorValue ) {\n\t\treturn sprintf(\n\t\t\t// translators: %1$s: The color's hex code e.g: \"#f00\".\n\t\t\t'Border color picker. The currently selected color has a value of \"%1$s\".',\n\t\t\tgetAriaLabelColorValue( colorValue )\n\t\t);\n\t}\n\n\treturn __( 'Border color picker.' );\n};\n\nconst BorderControlDropdown = (\n\tprops: WordPressComponentProps< DropdownProps, 'div' >,\n\tforwardedRef: React.ForwardedRef< any >\n) => {\n\tconst {\n\t\t__experimentalIsRenderedInSidebar,\n\t\tborder,\n\t\tcolors,\n\t\tdisableCustomColors,\n\t\tenableAlpha,\n\t\tenableStyle,\n\t\tindicatorClassName,\n\t\tindicatorWrapperClassName,\n\t\tonReset,\n\t\tonColorChange,\n\t\tonStyleChange,\n\t\tpopoverContentClassName,\n\t\tpopoverControlsClassName,\n\t\tresetButtonClassName,\n\t\tshowDropdownHeader,\n\t\tsize,\n\t\t__unstablePopoverProps,\n\t\t...otherProps\n\t} = useBorderControlDropdown( props );\n\n\tconst { color, style } = border || {};\n\tconst colorObject = getColorObject( color, colors );\n\n\tconst toggleAriaLabel = getToggleAriaLabel(\n\t\tcolor,\n\t\tcolorObject,\n\t\tstyle,\n\t\tenableStyle\n\t);\n\n\tconst showResetButton = color || ( style && style !== 'none' );\n\tconst dropdownPosition = __experimentalIsRenderedInSidebar\n\t\t? 'bottom left'\n\t\t: undefined;\n\n\tconst renderToggle: DropdownComponentProps[ 'renderToggle' ] = ( {\n\t\tonToggle,\n\t} ) => (\n\t\t<Button\n\t\t\tonClick={ onToggle }\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-label={ toggleAriaLabel }\n\t\t\ttooltipPosition={ dropdownPosition }\n\t\t\tlabel={ __( 'Border color and style picker' ) }\n\t\t\tshowTooltip={ true }\n\t\t\t__next40pxDefaultSize={ size === '__unstable-large' ? true : false }\n\t\t>\n\t\t\t<span className={ indicatorWrapperClassName }>\n\t\t\t\t<ColorIndicator\n\t\t\t\t\tclassName={ indicatorClassName }\n\t\t\t\t\tcolorValue={ color }\n\t\t\t\t/>\n\t\t\t</span>\n\t\t</Button>\n\t);\n\n\tconst renderContent: DropdownComponentProps[ 'renderContent' ] = ( {\n\t\tonClose,\n\t} ) => (\n\t\t<>\n\t\t\t<DropdownContentWrapper paddingSize=\"medium\">\n\t\t\t\t<VStack className={ popoverControlsClassName } spacing={ 6 }>\n\t\t\t\t\t{ showDropdownHeader ? (\n\t\t\t\t\t\t<HStack>\n\t\t\t\t\t\t\t<StyledLabel>{ __( 'Border color' ) }</StyledLabel>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Close border color' ) }\n\t\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t) : undefined }\n\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\tclassName={ popoverContentClassName }\n\t\t\t\t\t\tvalue={ color }\n\t\t\t\t\t\tonChange={ onColorChange }\n\t\t\t\t\t\t{ ...{ colors, disableCustomColors } }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t\t/>\n\t\t\t\t\t{ enableStyle && (\n\t\t\t\t\t\t<BorderControlStylePicker\n\t\t\t\t\t\t\tlabel={ __( 'Style' ) }\n\t\t\t\t\t\t\tvalue={ style }\n\t\t\t\t\t\t\tonChange={ onStyleChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</VStack>\n\t\t\t</DropdownContentWrapper>\n\t\t\t{ showResetButton && (\n\t\t\t\t<DropdownContentWrapper paddingSize=\"none\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName={ resetButtonClassName }\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonReset();\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</DropdownContentWrapper>\n\t\t\t) }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<Dropdown\n\t\t\trenderToggle={ renderToggle }\n\t\t\trenderContent={ renderContent }\n\t\t\tpopoverProps={ {\n\t\t\t\t...__unstablePopoverProps,\n\t\t\t} }\n\t\t\t{ ...otherProps }\n\t\t\tref={ forwardedRef }\n\t\t/>\n\t);\n};\n\nconst ConnectedBorderControlDropdown = contextConnect(\n\tBorderControlDropdown,\n\t'BorderControlDropdown'\n);\n\nexport default ConnectedBorderControlDropdown;\n"],"mappings":";AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,UAAU,QAAQ,kBAAkB;;AAE7C;AACA;AACA;AACA,OAAOC,wBAAwB,MAAM,gCAAgC;AACrE,OAAOC,MAAM,MAAM,cAAc;AACjC,OAAOC,cAAc,MAAM,uBAAuB;AAClD,OAAOC,YAAY,MAAM,qBAAqB;AAC9C,OAAOC,QAAQ,MAAM,gBAAgB;AACrC,SAASC,MAAM,QAAQ,eAAe;AACtC,SAASC,MAAM,QAAQ,eAAe;AAEtC,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAASC,wBAAwB,QAAQ,QAAQ;AACjD,SAASC,WAAW,QAAQ,+CAA+C;AAC3E,OAAOC,sBAAsB,MAAM,yCAAyC;AAG5E,SAASC,sBAAsB,QAAQ,2BAA2B;AAIlE,MAAMC,sBAAsB,GAAKC,UAAkB,IAAM;EACxD;EACA,OAAOA,UAAU,CAACC,OAAO,CAAE,eAAe,EAAE,IAAK,CAAC;AACnD,CAAC;AAED,MAAMC,cAAc,GAAGA,CACtBF,UAA0C,EAC1CG,MAA0C,KACtC;EACJ,IAAK,CAAEH,UAAU,IAAI,CAAEG,MAAM,EAAG;IAC/B;EACD;EAEA,IAAKL,sBAAsB,CAAEK,MAAO,CAAC,EAAG;IACvC;IACA,IAAIC,YAAY;IAEhBD,MAAM,CAACE,IAAI,CAAIC,MAAM,IACpBA,MAAM,CAACH,MAAM,CAACE,IAAI,CAAIE,KAAK,IAAM;MAChC,IAAKA,KAAK,CAACA,KAAK,KAAKP,UAAU,EAAG;QACjCI,YAAY,GAAGG,KAAK;QACpB,OAAO,IAAI;MACZ;MAEA,OAAO,KAAK;IACb,CAAE,CACH,CAAC;IAED,OAAOH,YAAY;EACpB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AAG1C;EAAc,CACpB,CAAC;AAEJ,CAAC;AAED,MAAM2C,8BAA8B,GAAGlE,cAAc,CACpDqB,qBAAqB,EACrB,uBACD,CAAC;AAED,eAAe6C,8BAA8B"}
1
+ {"version":3,"names":["__","sprintf","closeSmall","BorderControlStylePicker","Button","ColorIndicator","ColorPalette","Dropdown","HStack","VStack","contextConnect","useBorderControlDropdown","StyledLabel","DropdownContentWrapper","isMultiplePaletteArray","getAriaLabelColorValue","colorValue","replace","getColorObject","colors","matchedColor","some","origin","color","find","getToggleAriaLabel","colorObject","style","isStyleEnabled","ariaLabelValue","name","BorderControlDropdown","props","forwardedRef","__experimentalIsRenderedInSidebar","border","disableCustomColors","enableAlpha","enableStyle","indicatorClassName","indicatorWrapperClassName","isStyleSettable","onReset","onColorChange","onStyleChange","popoverContentClassName","popoverControlsClassName","resetButtonClassName","showDropdownHeader","size","__unstablePopoverProps","otherProps","toggleAriaLabel","showResetButton","dropdownPosition","undefined","renderToggle","onToggle","createElement","onClick","variant","tooltipPosition","label","showTooltip","__next40pxDefaultSize","className","renderContent","onClose","Fragment","paddingSize","spacing","icon","value","onChange","clearable","popoverProps","ref","ConnectedBorderControlDropdown"],"sources":["@wordpress/components/src/border-control/border-control-dropdown/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BorderControlStylePicker from '../border-control-style-picker';\nimport Button from '../../button';\nimport ColorIndicator from '../../color-indicator';\nimport ColorPalette from '../../color-palette';\nimport Dropdown from '../../dropdown';\nimport { HStack } from '../../h-stack';\nimport { VStack } from '../../v-stack';\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect } from '../../context';\nimport { useBorderControlDropdown } from './hook';\nimport { StyledLabel } from '../../base-control/styles/base-control-styles';\nimport DropdownContentWrapper from '../../dropdown/dropdown-content-wrapper';\n\nimport type { ColorObject } from '../../color-palette/types';\nimport { isMultiplePaletteArray } from '../../color-palette/utils';\nimport type { DropdownProps as DropdownComponentProps } from '../../dropdown/types';\nimport type { ColorProps, DropdownProps } from '../types';\n\nconst getAriaLabelColorValue = ( colorValue: string ) => {\n\t// Leave hex values as-is. Remove the `var()` wrapper from CSS vars.\n\treturn colorValue.replace( /^var\\((.+)\\)$/, '$1' );\n};\n\nconst getColorObject = (\n\tcolorValue: CSSProperties[ 'borderColor' ],\n\tcolors: ColorProps[ 'colors' ] | undefined\n) => {\n\tif ( ! colorValue || ! colors ) {\n\t\treturn;\n\t}\n\n\tif ( isMultiplePaletteArray( colors ) ) {\n\t\t// Multiple origins\n\t\tlet matchedColor;\n\n\t\tcolors.some( ( origin ) =>\n\t\t\torigin.colors.some( ( color ) => {\n\t\t\t\tif ( color.color === colorValue ) {\n\t\t\t\t\tmatchedColor = color;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t} )\n\t\t);\n\n\t\treturn matchedColor;\n\t}\n\n\t// Single origin\n\treturn colors.find( ( color ) => color.color === colorValue );\n};\n\nconst getToggleAriaLabel = (\n\tcolorValue: CSSProperties[ 'borderColor' ],\n\tcolorObject: ColorObject | undefined,\n\tstyle: CSSProperties[ 'borderStyle' ],\n\tisStyleEnabled: boolean\n) => {\n\tif ( isStyleEnabled ) {\n\t\tif ( colorObject ) {\n\t\t\tconst ariaLabelValue = getAriaLabelColorValue( colorObject.color );\n\t\t\treturn style\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %1$s: The name of the color e.g. \"vivid red\". %2$s: The color's hex code e.g.: \"#f00:\". %3$s: The current border style selection e.g. \"solid\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\". The currently selected style is \"%3$s\".',\n\t\t\t\t\t\tcolorObject.name,\n\t\t\t\t\t\tariaLabelValue,\n\t\t\t\t\t\tstyle\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t// translators: %1$s: The name of the color e.g. \"vivid red\". %2$s: The color's hex code e.g.: \"#f00:\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".',\n\t\t\t\t\t\tcolorObject.name,\n\t\t\t\t\t\tariaLabelValue\n\t\t\t\t );\n\t\t}\n\n\t\tif ( colorValue ) {\n\t\t\tconst ariaLabelValue = getAriaLabelColorValue( colorValue );\n\t\t\treturn style\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %1$s: The color's hex code e.g.: \"#f00:\". %2$s: The current border style selection e.g. \"solid\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color has a value of \"%1$s\". The currently selected style is \"%2$s\".',\n\t\t\t\t\t\tariaLabelValue,\n\t\t\t\t\t\tstyle\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t// translators: %1$s: The color's hex code e.g: \"#f00\".\n\t\t\t\t\t\t'Border color and style picker. The currently selected color has a value of \"%1$s\".',\n\t\t\t\t\t\tariaLabelValue\n\t\t\t\t );\n\t\t}\n\n\t\treturn __( 'Border color and style picker.' );\n\t}\n\n\tif ( colorObject ) {\n\t\treturn sprintf(\n\t\t\t// translators: %1$s: The name of the color e.g. \"vivid red\". %2$s: The color's hex code e.g: \"#f00\".\n\t\t\t'Border color picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".',\n\t\t\tcolorObject.name,\n\t\t\tgetAriaLabelColorValue( colorObject.color )\n\t\t);\n\t}\n\n\tif ( colorValue ) {\n\t\treturn sprintf(\n\t\t\t// translators: %1$s: The color's hex code e.g: \"#f00\".\n\t\t\t'Border color picker. The currently selected color has a value of \"%1$s\".',\n\t\t\tgetAriaLabelColorValue( colorValue )\n\t\t);\n\t}\n\n\treturn __( 'Border color picker.' );\n};\n\nconst BorderControlDropdown = (\n\tprops: WordPressComponentProps< DropdownProps, 'div' >,\n\tforwardedRef: React.ForwardedRef< any >\n) => {\n\tconst {\n\t\t__experimentalIsRenderedInSidebar,\n\t\tborder,\n\t\tcolors,\n\t\tdisableCustomColors,\n\t\tenableAlpha,\n\t\tenableStyle,\n\t\tindicatorClassName,\n\t\tindicatorWrapperClassName,\n\t\tisStyleSettable,\n\t\tonReset,\n\t\tonColorChange,\n\t\tonStyleChange,\n\t\tpopoverContentClassName,\n\t\tpopoverControlsClassName,\n\t\tresetButtonClassName,\n\t\tshowDropdownHeader,\n\t\tsize,\n\t\t__unstablePopoverProps,\n\t\t...otherProps\n\t} = useBorderControlDropdown( props );\n\n\tconst { color, style } = border || {};\n\tconst colorObject = getColorObject( color, colors );\n\n\tconst toggleAriaLabel = getToggleAriaLabel(\n\t\tcolor,\n\t\tcolorObject,\n\t\tstyle,\n\t\tenableStyle\n\t);\n\n\tconst showResetButton = color || ( style && style !== 'none' );\n\tconst dropdownPosition = __experimentalIsRenderedInSidebar\n\t\t? 'bottom left'\n\t\t: undefined;\n\n\tconst renderToggle: DropdownComponentProps[ 'renderToggle' ] = ( {\n\t\tonToggle,\n\t} ) => (\n\t\t<Button\n\t\t\tonClick={ onToggle }\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-label={ toggleAriaLabel }\n\t\t\ttooltipPosition={ dropdownPosition }\n\t\t\tlabel={ __( 'Border color and style picker' ) }\n\t\t\tshowTooltip={ true }\n\t\t\t__next40pxDefaultSize={ size === '__unstable-large' ? true : false }\n\t\t>\n\t\t\t<span className={ indicatorWrapperClassName }>\n\t\t\t\t<ColorIndicator\n\t\t\t\t\tclassName={ indicatorClassName }\n\t\t\t\t\tcolorValue={ color }\n\t\t\t\t/>\n\t\t\t</span>\n\t\t</Button>\n\t);\n\n\tconst renderContent: DropdownComponentProps[ 'renderContent' ] = ( {\n\t\tonClose,\n\t} ) => (\n\t\t<>\n\t\t\t<DropdownContentWrapper paddingSize=\"medium\">\n\t\t\t\t<VStack className={ popoverControlsClassName } spacing={ 6 }>\n\t\t\t\t\t{ showDropdownHeader ? (\n\t\t\t\t\t\t<HStack>\n\t\t\t\t\t\t\t<StyledLabel>{ __( 'Border color' ) }</StyledLabel>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Close border color' ) }\n\t\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t) : undefined }\n\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\tclassName={ popoverContentClassName }\n\t\t\t\t\t\tvalue={ color }\n\t\t\t\t\t\tonChange={ onColorChange }\n\t\t\t\t\t\t{ ...{ colors, disableCustomColors } }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\t\t/>\n\t\t\t\t\t{ enableStyle && isStyleSettable && (\n\t\t\t\t\t\t<BorderControlStylePicker\n\t\t\t\t\t\t\tlabel={ __( 'Style' ) }\n\t\t\t\t\t\t\tvalue={ style }\n\t\t\t\t\t\t\tonChange={ onStyleChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</VStack>\n\t\t\t</DropdownContentWrapper>\n\t\t\t{ showResetButton && (\n\t\t\t\t<DropdownContentWrapper paddingSize=\"none\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName={ resetButtonClassName }\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonReset();\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</DropdownContentWrapper>\n\t\t\t) }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<Dropdown\n\t\t\trenderToggle={ renderToggle }\n\t\t\trenderContent={ renderContent }\n\t\t\tpopoverProps={ {\n\t\t\t\t...__unstablePopoverProps,\n\t\t\t} }\n\t\t\t{ ...otherProps }\n\t\t\tref={ forwardedRef }\n\t\t/>\n\t);\n};\n\nconst ConnectedBorderControlDropdown = contextConnect(\n\tBorderControlDropdown,\n\t'BorderControlDropdown'\n);\n\nexport default ConnectedBorderControlDropdown;\n"],"mappings":";AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,UAAU,QAAQ,kBAAkB;;AAE7C;AACA;AACA;AACA,OAAOC,wBAAwB,MAAM,gCAAgC;AACrE,OAAOC,MAAM,MAAM,cAAc;AACjC,OAAOC,cAAc,MAAM,uBAAuB;AAClD,OAAOC,YAAY,MAAM,qBAAqB;AAC9C,OAAOC,QAAQ,MAAM,gBAAgB;AACrC,SAASC,MAAM,QAAQ,eAAe;AACtC,SAASC,MAAM,QAAQ,eAAe;AAEtC,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAASC,wBAAwB,QAAQ,QAAQ;AACjD,SAASC,WAAW,QAAQ,+CAA+C;AAC3E,OAAOC,sBAAsB,MAAM,yCAAyC;AAG5E,SAASC,sBAAsB,QAAQ,2BAA2B;AAIlE,MAAMC,sBAAsB,GAAKC,UAAkB,IAAM;EACxD;EACA,OAAOA,UAAU,CAACC,OAAO,CAAE,eAAe,EAAE,IAAK,CAAC;AACnD,CAAC;AAED,MAAMC,cAAc,GAAGA,CACtBF,UAA0C,EAC1CG,MAA0C,KACtC;EACJ,IAAK,CAAEH,UAAU,IAAI,CAAEG,MAAM,EAAG;IAC/B;EACD;EAEA,IAAKL,sBAAsB,CAAEK,MAAO,CAAC,EAAG;IACvC;IACA,IAAIC,YAAY;IAEhBD,MAAM,CAACE,IAAI,CAAIC,MAAM,IACpBA,MAAM,CAACH,MAAM,CAACE,IAAI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AEDnE,EAAE,CAAE,OAAQ,CACP,CACe,CAExB,CACF;EAED,OACC0D,aAAA,CAACnD,QAAQ;IACRiD,YAAY,EAAGA,YAAc;IAC7BU,aAAa,EAAGA,aAAe;IAC/BS,YAAY,EAAG;MACd,GAAGzB;IACJ,CAAG;IAAA,GACEC,UAAU;IACfyB,GAAG,EAAG3C;EAAc,CACpB,CAAC;AAEJ,CAAC;AAED,MAAM4C,8BAA8B,GAAGnE,cAAc,CACpDqB,qBAAqB,EACrB,uBACD,CAAC;AAED,eAAe8C,8BAA8B"}
@@ -8,13 +8,8 @@ import { __ } from '@wordpress/i18n';
8
8
  /**
9
9
  * Internal dependencies
10
10
  */
11
- import Button from '../../button';
12
- import { StyledLabel } from '../../base-control/styles/base-control-styles';
13
- import { View } from '../../view';
14
- import { Flex } from '../../flex';
15
- import { VisuallyHidden } from '../../visually-hidden';
16
11
  import { contextConnect } from '../../context';
17
- import { useBorderControlStylePicker } from './hook';
12
+ import { ToggleGroupControl, ToggleGroupControlOptionIcon } from '../../toggle-group-control';
18
13
  const BORDER_STYLES = [{
19
14
  label: __('Solid'),
20
15
  icon: lineSolid,
@@ -28,48 +23,26 @@ const BORDER_STYLES = [{
28
23
  icon: lineDotted,
29
24
  value: 'dotted'
30
25
  }];
31
- const Label = props => {
32
- const {
33
- label,
34
- hideLabelFromVision
35
- } = props;
36
- if (!label) {
37
- return null;
38
- }
39
- return hideLabelFromVision ? createElement(VisuallyHidden, {
40
- as: "label"
41
- }, label) : createElement(StyledLabel, null, label);
42
- };
43
- const BorderControlStylePicker = (props, forwardedRef) => {
44
- const {
45
- buttonClassName,
46
- hideLabelFromVision,
47
- label,
48
- onChange,
49
- value,
50
- ...otherProps
51
- } = useBorderControlStylePicker(props);
52
- return createElement(View, {
53
- ...otherProps,
54
- ref: forwardedRef
55
- }, createElement(Label, {
56
- label: label,
57
- hideLabelFromVision: hideLabelFromVision
58
- }), createElement(Flex, {
59
- justify: "flex-start",
60
- gap: 1
61
- }, BORDER_STYLES.map(borderStyle => createElement(Button, {
26
+ function UnconnectedBorderControlStylePicker({
27
+ onChange,
28
+ ...restProps
29
+ }, forwardedRef) {
30
+ return createElement(ToggleGroupControl, {
31
+ __nextHasNoMarginBottom: true,
32
+ __next40pxDefaultSize: true,
33
+ ref: forwardedRef,
34
+ isDeselectable: true,
35
+ onChange: value => {
36
+ onChange?.(value);
37
+ },
38
+ ...restProps
39
+ }, BORDER_STYLES.map(borderStyle => createElement(ToggleGroupControlOptionIcon, {
62
40
  key: borderStyle.value,
63
- className: buttonClassName,
41
+ value: borderStyle.value,
64
42
  icon: borderStyle.icon,
65
- size: "small",
66
- isPressed: borderStyle.value === value,
67
- onClick: () => onChange(borderStyle.value === value ? undefined : borderStyle.value),
68
- "aria-label": borderStyle.label,
69
- label: borderStyle.label,
70
- showTooltip: true
71
- }))));
72
- };
73
- const ConnectedBorderControlStylePicker = contextConnect(BorderControlStylePicker, 'BorderControlStylePicker');
74
- export default ConnectedBorderControlStylePicker;
43
+ label: borderStyle.label
44
+ })));
45
+ }
46
+ const BorderControlStylePicker = contextConnect(UnconnectedBorderControlStylePicker, 'BorderControlStylePicker');
47
+ export default BorderControlStylePicker;
75
48
  //# sourceMappingURL=component.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["lineDashed","lineDotted","lineSolid","__","Button","StyledLabel","View","Flex","VisuallyHidden","contextConnect","useBorderControlStylePicker","BORDER_STYLES","label","icon","value","Label","props","hideLabelFromVision","createElement","as","BorderControlStylePicker","forwardedRef","buttonClassName","onChange","otherProps","ref","justify","gap","map","borderStyle","key","className","size","isPressed","onClick","undefined","showTooltip","ConnectedBorderControlStylePicker"],"sources":["@wordpress/components/src/border-control/border-control-style-picker/component.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { lineDashed, lineDotted, lineSolid } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Button from '../../button';\nimport { StyledLabel } from '../../base-control/styles/base-control-styles';\nimport { View } from '../../view';\nimport { Flex } from '../../flex';\nimport { VisuallyHidden } from '../../visually-hidden';\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect } from '../../context';\nimport { useBorderControlStylePicker } from './hook';\n\nimport type { LabelProps, StylePickerProps } from '../types';\n\nconst BORDER_STYLES = [\n\t{ label: __( 'Solid' ), icon: lineSolid, value: 'solid' },\n\t{ label: __( 'Dashed' ), icon: lineDashed, value: 'dashed' },\n\t{ label: __( 'Dotted' ), icon: lineDotted, value: 'dotted' },\n];\n\nconst Label = ( props: LabelProps ) => {\n\tconst { label, hideLabelFromVision } = props;\n\n\tif ( ! label ) {\n\t\treturn null;\n\t}\n\n\treturn hideLabelFromVision ? (\n\t\t<VisuallyHidden as=\"label\">{ label }</VisuallyHidden>\n\t) : (\n\t\t<StyledLabel>{ label }</StyledLabel>\n\t);\n};\n\nconst BorderControlStylePicker = (\n\tprops: WordPressComponentProps< StylePickerProps, 'div' >,\n\tforwardedRef: React.ForwardedRef< any >\n) => {\n\tconst {\n\t\tbuttonClassName,\n\t\thideLabelFromVision,\n\t\tlabel,\n\t\tonChange,\n\t\tvalue,\n\t\t...otherProps\n\t} = useBorderControlStylePicker( props );\n\n\treturn (\n\t\t<View { ...otherProps } ref={ forwardedRef }>\n\t\t\t<Label\n\t\t\t\tlabel={ label }\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t/>\n\t\t\t<Flex justify=\"flex-start\" gap={ 1 }>\n\t\t\t\t{ BORDER_STYLES.map( ( borderStyle ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ borderStyle.value }\n\t\t\t\t\t\tclassName={ buttonClassName }\n\t\t\t\t\t\ticon={ borderStyle.icon }\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\tisPressed={ borderStyle.value === value }\n\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tborderStyle.value === value\n\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t: borderStyle.value\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\taria-label={ borderStyle.label }\n\t\t\t\t\t\tlabel={ borderStyle.label }\n\t\t\t\t\t\tshowTooltip={ true }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</Flex>\n\t\t</View>\n\t);\n};\n\nconst ConnectedBorderControlStylePicker = contextConnect(\n\tBorderControlStylePicker,\n\t'BorderControlStylePicker'\n);\n\nexport default ConnectedBorderControlStylePicker;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,UAAU,EAAEC,SAAS,QAAQ,kBAAkB;AACpE,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,MAAM,MAAM,cAAc;AACjC,SAASC,WAAW,QAAQ,+CAA+C;AAC3E,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,cAAc,QAAQ,uBAAuB;AAEtD,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAASC,2BAA2B,QAAQ,QAAQ;AAIpD,MAAMC,aAAa,GAAG,CACrB;EAAEC,KAAK,EAAET,EAAE,CAAE,OAAQ,CAAC;EAAEU,IAAI,EAAEX,SAAS;EAAEY,KAAK,EAAE;AAAQ,CAAC,EACzD;EAAEF,KAAK,EAAET,EAAE,CAAE,QAAS,CAAC;EAAEU,IAAI,EAAEb,UAAU;EAAEc,KAAK,EAAE;AAAS,CAAC,EAC5D;EAAEF,KAAK,EAAET,EAAE,CAAE,QAAS,CAAC;EAAEU,IAAI,EAAEZ,UAAU;EAAEa,KAAK,EAAE;AAAS,CAAC,CAC5D;AAED,MAAMC,KAAK,GAAKC,KAAiB,IAAM;EACtC,MAAM;IAAEJ,KAAK;IAAEK;EAAoB,CAAC,GAAGD,KAAK;EAE5C,IAAK,CAAEJ,KAAK,EAAG;IACd,OAAO,IAAI;EACZ;EAE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","__","contextConnect","ToggleGroupControl","ToggleGroupControlOptionIcon","BORDER_STYLES","label","icon","value","UnconnectedBorderControlStylePicker","onChange","restProps","forwardedRef","createElement","__nextHasNoMarginBottom","__next40pxDefaultSize","ref","isDeselectable","map","borderStyle","key","BorderControlStylePicker"],"sources":["@wordpress/components/src/border-control/border-control-style-picker/component.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { lineDashed, lineDotted, lineSolid } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { contextConnect } from '../../context';\nimport type { StylePickerProps } from '../types';\nimport {\n\tToggleGroupControl,\n\tToggleGroupControlOptionIcon,\n} from '../../toggle-group-control';\n\nconst BORDER_STYLES = [\n\t{ label: __( 'Solid' ), icon: lineSolid, value: 'solid' },\n\t{ label: __( 'Dashed' ), icon: lineDashed, value: 'dashed' },\n\t{ label: __( 'Dotted' ), icon: lineDotted, value: 'dotted' },\n];\n\nfunction UnconnectedBorderControlStylePicker(\n\t{ onChange, ...restProps }: StylePickerProps,\n\tforwardedRef: React.ForwardedRef< any >\n) {\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tref={ forwardedRef }\n\t\t\tisDeselectable\n\t\t\tonChange={ ( value ) => {\n\t\t\t\tonChange?.( value as string | undefined );\n\t\t\t} }\n\t\t\t{ ...restProps }\n\t\t>\n\t\t\t{ BORDER_STYLES.map( ( borderStyle ) => (\n\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\tkey={ borderStyle.value }\n\t\t\t\t\tvalue={ borderStyle.value }\n\t\t\t\t\ticon={ borderStyle.icon }\n\t\t\t\t\tlabel={ borderStyle.label }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</ToggleGroupControl>\n\t);\n}\n\nconst BorderControlStylePicker = contextConnect(\n\tUnconnectedBorderControlStylePicker,\n\t'BorderControlStylePicker'\n);\n\nexport default Border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