@wordpress/components 29.1.1 → 29.3.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 (246) hide show
  1. package/CHANGELOG.md +29 -6
  2. package/CONTRIBUTING.md +4 -4
  3. package/README.md +1 -1
  4. package/build/badge/index.js +26 -22
  5. package/build/badge/index.js.map +1 -1
  6. package/build/border-box-control/border-box-control-linked-button/component.js +8 -15
  7. package/build/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  8. package/build/box-control/index.js +6 -0
  9. package/build/box-control/index.js.map +1 -1
  10. package/build/box-control/linked-button.js +7 -11
  11. package/build/box-control/linked-button.js.map +1 -1
  12. package/build/box-control/types.js.map +1 -1
  13. package/build/circular-option-picker/circular-option-picker-option.js +9 -7
  14. package/build/circular-option-picker/circular-option-picker-option.js.map +1 -1
  15. package/build/circular-option-picker/circular-option-picker.js +0 -1
  16. package/build/circular-option-picker/circular-option-picker.js.map +1 -1
  17. package/build/color-palette/index.js +1 -6
  18. package/build/color-palette/index.js.map +1 -1
  19. package/build/font-size-picker/index.native.js +1 -1
  20. package/build/font-size-picker/index.native.js.map +1 -1
  21. package/build/higher-order/with-focus-return/index.js +1 -1
  22. package/build/higher-order/with-focus-return/index.js.map +1 -1
  23. package/build/input-control/styles/input-control-styles.js +22 -22
  24. package/build/input-control/styles/input-control-styles.js.map +1 -1
  25. package/build/menu/checkbox-item.js +6 -6
  26. package/build/menu/checkbox-item.js.map +1 -1
  27. package/build/menu/context.js +2 -2
  28. package/build/menu/context.js.map +1 -1
  29. package/build/menu/group-label.js +4 -4
  30. package/build/menu/group-label.js.map +1 -1
  31. package/build/menu/group.js +4 -4
  32. package/build/menu/group.js.map +1 -1
  33. package/build/menu/index.js +87 -14
  34. package/build/menu/index.js.map +1 -1
  35. package/build/menu/item-help-text.js +4 -4
  36. package/build/menu/item-help-text.js.map +1 -1
  37. package/build/menu/item-label.js +4 -4
  38. package/build/menu/item-label.js.map +1 -1
  39. package/build/menu/item.js +6 -6
  40. package/build/menu/item.js.map +1 -1
  41. package/build/menu/popover.js +5 -5
  42. package/build/menu/popover.js.map +1 -1
  43. package/build/menu/radio-item.js +6 -6
  44. package/build/menu/radio-item.js.map +1 -1
  45. package/build/menu/separator.js +4 -4
  46. package/build/menu/separator.js.map +1 -1
  47. package/build/menu/styles.js +41 -41
  48. package/build/menu/styles.js.map +1 -1
  49. package/build/menu/submenu-trigger-item.js +5 -5
  50. package/build/menu/submenu-trigger-item.js.map +1 -1
  51. package/build/menu/trigger-button.js +3 -3
  52. package/build/menu/trigger-button.js.map +1 -1
  53. package/build/menu/types.js.map +1 -1
  54. package/build/mobile/bottom-sheet/nav-bar/action-button.native.js +1 -1
  55. package/build/mobile/bottom-sheet/nav-bar/action-button.native.js.map +1 -1
  56. package/build/mobile/utils/get-px-from-css-unit.native.js +3 -3
  57. package/build/mobile/utils/get-px-from-css-unit.native.js.map +1 -1
  58. package/build/notice/types.js.map +1 -1
  59. package/build/search-control/index.js +1 -1
  60. package/build/search-control/index.js.map +1 -1
  61. package/build/text/hook.js +8 -6
  62. package/build/text/hook.js.map +1 -1
  63. package/build/text/utils.js +1 -1
  64. package/build/text/utils.js.map +1 -1
  65. package/build-module/badge/index.js +28 -22
  66. package/build-module/badge/index.js.map +1 -1
  67. package/build-module/border-box-control/border-box-control-linked-button/component.js +8 -15
  68. package/build-module/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  69. package/build-module/box-control/index.js +6 -0
  70. package/build-module/box-control/index.js.map +1 -1
  71. package/build-module/box-control/linked-button.js +7 -11
  72. package/build-module/box-control/linked-button.js.map +1 -1
  73. package/build-module/box-control/types.js.map +1 -1
  74. package/build-module/circular-option-picker/circular-option-picker-option.js +9 -7
  75. package/build-module/circular-option-picker/circular-option-picker-option.js.map +1 -1
  76. package/build-module/circular-option-picker/circular-option-picker.js +0 -1
  77. package/build-module/circular-option-picker/circular-option-picker.js.map +1 -1
  78. package/build-module/color-palette/index.js +1 -6
  79. package/build-module/color-palette/index.js.map +1 -1
  80. package/build-module/font-size-picker/index.native.js +1 -1
  81. package/build-module/font-size-picker/index.native.js.map +1 -1
  82. package/build-module/higher-order/with-focus-return/index.js +1 -1
  83. package/build-module/higher-order/with-focus-return/index.js.map +1 -1
  84. package/build-module/input-control/styles/input-control-styles.js +22 -22
  85. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  86. package/build-module/menu/checkbox-item.js +6 -6
  87. package/build-module/menu/checkbox-item.js.map +1 -1
  88. package/build-module/menu/context.js +1 -1
  89. package/build-module/menu/context.js.map +1 -1
  90. package/build-module/menu/group-label.js +4 -4
  91. package/build-module/menu/group-label.js.map +1 -1
  92. package/build-module/menu/group.js +4 -4
  93. package/build-module/menu/group.js.map +1 -1
  94. package/build-module/menu/index.js +99 -26
  95. package/build-module/menu/index.js.map +1 -1
  96. package/build-module/menu/item-help-text.js +4 -4
  97. package/build-module/menu/item-help-text.js.map +1 -1
  98. package/build-module/menu/item-label.js +4 -4
  99. package/build-module/menu/item-label.js.map +1 -1
  100. package/build-module/menu/item.js +6 -6
  101. package/build-module/menu/item.js.map +1 -1
  102. package/build-module/menu/popover.js +5 -5
  103. package/build-module/menu/popover.js.map +1 -1
  104. package/build-module/menu/radio-item.js +6 -6
  105. package/build-module/menu/radio-item.js.map +1 -1
  106. package/build-module/menu/separator.js +4 -4
  107. package/build-module/menu/separator.js.map +1 -1
  108. package/build-module/menu/styles.js +40 -40
  109. package/build-module/menu/styles.js.map +1 -1
  110. package/build-module/menu/submenu-trigger-item.js +6 -6
  111. package/build-module/menu/submenu-trigger-item.js.map +1 -1
  112. package/build-module/menu/trigger-button.js +3 -3
  113. package/build-module/menu/trigger-button.js.map +1 -1
  114. package/build-module/menu/types.js.map +1 -1
  115. package/build-module/mobile/bottom-sheet/nav-bar/action-button.native.js +1 -1
  116. package/build-module/mobile/bottom-sheet/nav-bar/action-button.native.js.map +1 -1
  117. package/build-module/mobile/utils/get-px-from-css-unit.native.js +3 -3
  118. package/build-module/mobile/utils/get-px-from-css-unit.native.js.map +1 -1
  119. package/build-module/notice/types.js.map +1 -1
  120. package/build-module/search-control/index.js +1 -1
  121. package/build-module/search-control/index.js.map +1 -1
  122. package/build-module/text/hook.js +8 -6
  123. package/build-module/text/hook.js.map +1 -1
  124. package/build-module/text/utils.js +1 -1
  125. package/build-module/text/utils.js.map +1 -1
  126. package/build-style/style-rtl.css +89 -170
  127. package/build-style/style.css +89 -170
  128. package/build-types/badge/index.d.ts.map +1 -1
  129. package/build-types/border-box-control/border-box-control-linked-button/component.d.ts.map +1 -1
  130. package/build-types/box-control/index.d.ts.map +1 -1
  131. package/build-types/box-control/linked-button.d.ts.map +1 -1
  132. package/build-types/box-control/stories/index.story.d.ts +7 -2331
  133. package/build-types/box-control/stories/index.story.d.ts.map +1 -1
  134. package/build-types/box-control/types.d.ts +15 -3
  135. package/build-types/box-control/types.d.ts.map +1 -1
  136. package/build-types/circular-option-picker/circular-option-picker-option.d.ts.map +1 -1
  137. package/build-types/circular-option-picker/circular-option-picker.d.ts.map +1 -1
  138. package/build-types/circular-option-picker/stories/index.story.d.ts.map +1 -1
  139. package/build-types/color-palette/index.d.ts.map +1 -1
  140. package/build-types/higher-order/with-focus-return/index.d.ts +1 -1
  141. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  142. package/build-types/menu/checkbox-item.d.ts +2 -2
  143. package/build-types/menu/checkbox-item.d.ts.map +1 -1
  144. package/build-types/menu/context.d.ts +2 -2
  145. package/build-types/menu/context.d.ts.map +1 -1
  146. package/build-types/menu/group-label.d.ts +2 -2
  147. package/build-types/menu/group-label.d.ts.map +1 -1
  148. package/build-types/menu/group.d.ts +2 -2
  149. package/build-types/menu/group.d.ts.map +1 -1
  150. package/build-types/menu/index.d.ts +84 -12
  151. package/build-types/menu/index.d.ts.map +1 -1
  152. package/build-types/menu/item-help-text.d.ts +1 -1
  153. package/build-types/menu/item-help-text.d.ts.map +1 -1
  154. package/build-types/menu/item-label.d.ts +1 -1
  155. package/build-types/menu/item-label.d.ts.map +1 -1
  156. package/build-types/menu/item.d.ts +2 -2
  157. package/build-types/menu/item.d.ts.map +1 -1
  158. package/build-types/menu/popover.d.ts +2 -2
  159. package/build-types/menu/popover.d.ts.map +1 -1
  160. package/build-types/menu/radio-item.d.ts +2 -2
  161. package/build-types/menu/radio-item.d.ts.map +1 -1
  162. package/build-types/menu/separator.d.ts +2 -2
  163. package/build-types/menu/separator.d.ts.map +1 -1
  164. package/build-types/menu/styles.d.ts +15 -15
  165. package/build-types/menu/styles.d.ts.map +1 -1
  166. package/build-types/menu/submenu-trigger-item.d.ts +2 -2
  167. package/build-types/menu/submenu-trigger-item.d.ts.map +1 -1
  168. package/build-types/menu/trigger-button.d.ts +2 -2
  169. package/build-types/menu/trigger-button.d.ts.map +1 -1
  170. package/build-types/menu/types.d.ts +10 -10
  171. package/build-types/menu/types.d.ts.map +1 -1
  172. package/build-types/menu-group/stories/index.story.d.ts +1 -1
  173. package/build-types/notice/types.d.ts +1 -1
  174. package/build-types/progress-bar/stories/index.story.d.ts +1 -1
  175. package/build-types/tabs/stories/index.story.d.ts +0 -3
  176. package/build-types/tabs/stories/index.story.d.ts.map +1 -1
  177. package/build-types/text/hook.d.ts.map +1 -1
  178. package/build-types/text/utils.d.ts +1 -1
  179. package/package.json +19 -19
  180. package/src/animate/style.scss +16 -12
  181. package/src/badge/index.tsx +28 -27
  182. package/src/border-box-control/border-box-control-linked-button/component.tsx +9 -14
  183. package/src/border-control/test/index.js +12 -4
  184. package/src/box-control/index.tsx +9 -0
  185. package/src/box-control/linked-button.tsx +8 -11
  186. package/src/box-control/test/index.tsx +9 -2
  187. package/src/box-control/types.ts +26 -11
  188. package/src/button/style.scss +15 -12
  189. package/src/checkbox-control/style.scss +4 -2
  190. package/src/circular-option-picker/README.md +1 -2
  191. package/src/circular-option-picker/circular-option-picker-option.tsx +17 -10
  192. package/src/circular-option-picker/circular-option-picker.tsx +0 -1
  193. package/src/circular-option-picker/stories/index.story.tsx +0 -1
  194. package/src/circular-option-picker/style.scss +10 -5
  195. package/src/color-palette/index.tsx +0 -7
  196. package/src/color-palette/test/index.tsx +2 -8
  197. package/src/combobox-control/test/index.tsx +1 -1
  198. package/src/drop-zone/style.scss +6 -9
  199. package/src/font-size-picker/index.native.js +1 -1
  200. package/src/form-toggle/style.scss +17 -10
  201. package/src/form-token-field/style.scss +9 -4
  202. package/src/higher-order/navigate-regions/style.scss +2 -2
  203. package/src/higher-order/with-focus-return/index.tsx +1 -1
  204. package/src/input-control/styles/input-control-styles.tsx +6 -0
  205. package/src/menu/README.md +421 -174
  206. package/src/menu/checkbox-item.tsx +12 -12
  207. package/src/menu/context.tsx +2 -4
  208. package/src/menu/docs-manifest.json +62 -0
  209. package/src/menu/group-label.tsx +7 -7
  210. package/src/menu/group.tsx +7 -11
  211. package/src/menu/index.tsx +101 -31
  212. package/src/menu/item-help-text.tsx +5 -7
  213. package/src/menu/item-label.tsx +5 -7
  214. package/src/menu/item.tsx +12 -12
  215. package/src/menu/popover.tsx +9 -9
  216. package/src/menu/radio-item.tsx +12 -12
  217. package/src/menu/separator.tsx +7 -7
  218. package/src/menu/stories/best-practices.mdx +38 -0
  219. package/src/menu/stories/index.story.tsx +8 -8
  220. package/src/menu/styles.ts +24 -24
  221. package/src/menu/submenu-trigger-item.tsx +9 -9
  222. package/src/menu/trigger-button.tsx +6 -6
  223. package/src/menu/types.ts +10 -10
  224. package/src/menu-group/stories/index.story.tsx +2 -2
  225. package/src/mobile/bottom-sheet/nav-bar/action-button.native.js +1 -1
  226. package/src/mobile/utils/get-px-from-css-unit.native.js +3 -3
  227. package/src/modal/style.scss +4 -2
  228. package/src/modal/test/index.tsx +5 -4
  229. package/src/notice/README.md +3 -3
  230. package/src/notice/types.ts +1 -1
  231. package/src/palette-edit/test/index.tsx +1 -1
  232. package/src/panel/style.scss +14 -6
  233. package/src/placeholder/style.scss +5 -3
  234. package/src/progress-bar/stories/index.story.tsx +1 -1
  235. package/src/resizable-box/style.scss +14 -9
  236. package/src/search-control/index.tsx +1 -1
  237. package/src/tab-panel/style.scss +6 -4
  238. package/src/tabs/stories/index.story.tsx +0 -131
  239. package/src/text/README.md +1 -1
  240. package/src/text/hook.ts +3 -2
  241. package/src/text/stories/index.story.tsx +2 -2
  242. package/src/text/test/index.tsx +1 -1
  243. package/src/text/utils.ts +1 -1
  244. package/src/text-highlight/test/index.tsx +3 -3
  245. package/src/toolbar/toolbar/style.scss +4 -3
  246. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 29.3.0 (2025-01-29)
6
+
7
+ ### Enhancements
8
+
9
+ - `BorderBoxControl`, `BoxControl`: Remove `Tooltip` component from linked button ([#68498](https://github.com/WordPress/gutenberg/pull/68498)).
10
+
11
+ ### Internal
12
+
13
+ - `BoxControl`: Add runtime check for presets and presetKey ([#68385](https://github.com/WordPress/gutenberg/pull/68385)).
14
+
15
+ ## 29.2.0 (2025-01-15)
16
+
17
+ ### Internal
18
+
19
+ - `Components`: Standardize reduced motion handling using media queries ([#68421](https://github.com/WordPress/gutenberg/pull/68421)).
20
+
21
+ ### Bug Fixes
22
+
23
+ - `CircularOptionPicker`, `ColorPalette`: Fix usage of tooltip in the Circular option picker. ([#68602](https://github.com/WordPress/gutenberg/pull/68602)).
24
+ - `InputControl`: Ensures email and url inputs have consistent LTR alignment in RTL languages ([#68188](https://github.com/WordPress/gutenberg/pull/68188)).
25
+
5
26
  ## 29.1.0 (2025-01-02)
6
27
 
7
28
  ### Enhancements
@@ -10,6 +31,8 @@
10
31
  - `Navigation`: Upsize back buttons ([#68157](https://github.com/WordPress/gutenberg/pull/68157)).
11
32
  - `Heading`: Fix text contrast for dark mode ([#68349](https://github.com/WordPress/gutenberg/pull/68349)).
12
33
  - `Text`: Fix text contrast for dark mode ([#68349](https://github.com/WordPress/gutenberg/pull/68349)).
34
+ - `Heading`: Revert text contrast fix for dark mode with optimizeReadabilityFor ([#68472](https://github.com/WordPress/gutenberg/pull/68472)).
35
+ - `Text`: Revert text contrast fix for dark mode with optimizeReadabilityFor ([#68472](https://github.com/WordPress/gutenberg/pull/68472)).
13
36
 
14
37
  ### Deprecations
15
38
 
@@ -179,7 +202,7 @@
179
202
 
180
203
  - `Tabs`: remove internal custom logic ([#66097](https://github.com/WordPress/gutenberg/pull/66097)).
181
204
  - `Tabs`: add props to control active tab item ([#66223](https://github.com/WordPress/gutenberg/pull/66223)).
182
- - `Tabs`: restore vertical alignent for tabs content ([#66215](https://github.com/WordPress/gutenberg/pull/66215)).
205
+ - `Tabs`: restore vertical alignment for tabs content ([#66215](https://github.com/WordPress/gutenberg/pull/66215)).
183
206
  - `Tabs`: fix indicator animation ([#66198](https://github.com/WordPress/gutenberg/pull/66198)).
184
207
  - `Tabs`: update indicator more reactively ([#66207](https://github.com/WordPress/gutenberg/pull/66207)).
185
208
  - `Tabs` and `TabPanel`: Fix arrow key navigation in RTL ([#66201](https://github.com/WordPress/gutenberg/pull/66201)).
@@ -515,7 +538,7 @@
515
538
  - `Tabs`: Vertical Tabs should be 40px min height. ([#63446](https://github.com/WordPress/gutenberg/pull/63446)).
516
539
  - `ColorPicker`: Use `minimal` variant for `SelectControl` ([#63676](https://github.com/WordPress/gutenberg/pull/63676)).
517
540
  - `Tabs`: keep full opacity of focus ring and remove hover styles on disabled tabs ([#63754](https://github.com/WordPress/gutenberg/pull/63754)).
518
- - `Placeholder`: Remove unnecssary `placeholder-style` Sass mixin ([#63885](https://github.com/WordPress/gutenberg/pull/63885)).
541
+ - `Placeholder`: Remove unnecessary `placeholder-style` Sass mixin ([#63885](https://github.com/WordPress/gutenberg/pull/63885)).
519
542
 
520
543
  ### Documentation
521
544
 
@@ -1582,7 +1605,7 @@
1582
1605
 
1583
1606
  - `TabPanel`: support manual tab activation ([#46004](https://github.com/WordPress/gutenberg/pull/46004)).
1584
1607
  - `TabPanel`: support disabled prop for tab buttons ([#46471](https://github.com/WordPress/gutenberg/pull/46471)).
1585
- - `BaseControl`: Add `useBaseControlProps` hook to help generate id-releated props ([#46170](https://github.com/WordPress/gutenberg/pull/46170)).
1608
+ - `BaseControl`: Add `useBaseControlProps` hook to help generate id-related props ([#46170](https://github.com/WordPress/gutenberg/pull/46170)).
1586
1609
 
1587
1610
  ### Bug Fixes
1588
1611
 
@@ -1605,8 +1628,8 @@
1605
1628
  - `Popover`: Prevent unnecessary paint caused by using outline ([#46201](https://github.com/WordPress/gutenberg/pull/46201)).
1606
1629
  - `PaletteEdit`: Global styles: add onChange actions to color palette items [#45681](https://github.com/WordPress/gutenberg/pull/45681).
1607
1630
  - Lighten the border color on control components ([#46252](https://github.com/WordPress/gutenberg/pull/46252)).
1608
- - `Popover`: Prevent unnecessary paint when scrolling by using transform instead of top/left positionning ([#46187](https://github.com/WordPress/gutenberg/pull/46187)).
1609
- - `CircularOptionPicker`: Prevent unecessary paint on hover ([#46197](https://github.com/WordPress/gutenberg/pull/46197)).
1631
+ - `Popover`: Prevent unnecessary paint when scrolling by using transform instead of top/left positioning ([#46187](https://github.com/WordPress/gutenberg/pull/46187)).
1632
+ - `CircularOptionPicker`: Prevent unnecessary paint on hover ([#46197](https://github.com/WordPress/gutenberg/pull/46197)).
1610
1633
 
1611
1634
  ### Experimental
1612
1635
 
@@ -2452,7 +2475,7 @@
2452
2475
 
2453
2476
  ### Bug Fixes
2454
2477
 
2455
- - Improve accessibility and visibility in `ColorPallete` ([#36925](https://github.com/WordPress/gutenberg/pull/36925))
2478
+ - Improve accessibility and visibility in `ColorPalette` ([#36925](https://github.com/WordPress/gutenberg/pull/36925))
2456
2479
 
2457
2480
  ## 19.1.3 (2021-12-06)
2458
2481
 
package/CONTRIBUTING.md CHANGED
@@ -411,7 +411,7 @@ export default MyComponent;
411
411
 
412
412
  On the component's main named export, add a JSDoc comment that includes the main description and the example code snippet from the README ([example](https://github.com/WordPress/gutenberg/blob/43d9c82922619c1d1ff6b454f86f75c3157d3de6/packages/components/src/date-time/date-time/index.tsx#L193-L217)). _At the time of writing, the `@example` JSDoc keyword is not recognized by StoryBook's docgen, so please avoid using it_.
413
413
 
414
- <!-- TODO: add to the previous paragraph once the composision section gets added to this document.
414
+ <!-- TODO: add to the previous paragraph once the compositions section gets added to this document.
415
415
  (more details about polymorphism can be found above in the "Components composition" section). -->
416
416
 
417
417
  ## Styling
@@ -550,7 +550,7 @@ export function useCardBody( props ) {
550
550
  // Read any derived registered prop from the Context System in the `CardBody` namespace.
551
551
  // If a `CardBody` component is rendered as a child of a `Card` component, the value of
552
552
  // the `size` prop will be the one set by the parent `Card` component via the Context
553
- // System (unless the prop gets explicitely set on the `CardBody` component).
553
+ // System (unless the prop gets explicitly set on the `CardBody` component).
554
554
  const { size = 'medium', ...otherDerivedProps } = useContextSystem(
555
555
  props,
556
556
  'CardBody'
@@ -759,13 +759,13 @@ function NewComponentImplementation( props ) {
759
759
 
760
760
  In case that is not possible (eg. too difficult to reconciliate new and legacy implementations, or impossible to preserve backward compatibility), then the legacy implementation can stay as-is.
761
761
 
762
- In any case, extra attention should be payed to legacy component families made of two or more subcomponents. It is possible, in fact, that the a legacy subcomponent is used as a parent / child of a subcomponent from the new version (this can happen, for example, when Gutenberg allows third party developers to inject React components via Slot/Fill). To avoid incompatibility issues and unexpected behavior, there should be some code in the components warning when the above scenario happens — or even better, aliasing to the correct version of the component.
762
+ In any case, extra attention should be paid to legacy component families made of two or more subcomponents. It is possible, in fact, that the a legacy subcomponent is used as a parent / child of a subcomponent from the new version (this can happen, for example, when Gutenberg allows third party developers to inject React components via Slot/Fill). To avoid incompatibility issues and unexpected behavior, there should be some code in the components warning when the above scenario happens — or even better, aliasing to the correct version of the component.
763
763
 
764
764
  ##### Naming
765
765
 
766
766
  When it comes to naming the newly added component, there are two options.
767
767
 
768
- If there is a good reason for it, pick a new name for the component. For example, some legacy components have names that don't correspond to the corrent name of UI widget that they implement (for example, `TabPanel` should be called `Tabs`, and `Modal` should be called `Dialog`).
768
+ If there is a good reason for it, pick a new name for the component. For example, some legacy components have names that don't correspond to the current name of UI widget that they implement (for example, `TabPanel` should be called `Tabs`, and `Modal` should be called `Dialog`).
769
769
 
770
770
  Alternatively, version the component name. For example, the new version of `Component` could be called `ComponentV2`. This also applies for namespaced subcomponents (ie. `ComponentV2.SubComponent`).
771
771
 
package/README.md CHANGED
@@ -33,7 +33,7 @@ In non-WordPress projects, link to the `build-style/style.css` file directly, it
33
33
 
34
34
  By default, the `Popover` component will render within an extra element appended to the body of the document.
35
35
 
36
- If you want to precisely contol where the popovers render, you will need to use the `Popover.Slot` component.
36
+ If you want to precisely control where the popovers render, you will need to use the `Popover.Slot` component.
37
37
 
38
38
  The following example illustrates how you can wrap a component using a
39
39
  `Popover` and have those popovers render to a single location in the DOM.
@@ -21,36 +21,40 @@ var _jsxRuntime = require("react/jsx-runtime");
21
21
  * Internal dependencies
22
22
  */
23
23
 
24
+ /**
25
+ * Returns an icon based on the badge context.
26
+ *
27
+ * @return The corresponding icon for the provided context.
28
+ */function contextBasedIcon(intent = 'default') {
29
+ switch (intent) {
30
+ case 'info':
31
+ return _icons.info;
32
+ case 'success':
33
+ return _icons.published;
34
+ case 'warning':
35
+ return _icons.caution;
36
+ case 'error':
37
+ return _icons.error;
38
+ default:
39
+ return null;
40
+ }
41
+ }
24
42
  function Badge({
25
43
  className,
26
44
  intent = 'default',
27
45
  children,
28
46
  ...props
29
47
  }) {
30
- /**
31
- * Returns an icon based on the badge context.
32
- *
33
- * @return The corresponding icon for the provided context.
34
- */
35
- function contextBasedIcon() {
36
- switch (intent) {
37
- case 'info':
38
- return _icons.info;
39
- case 'success':
40
- return _icons.published;
41
- case 'warning':
42
- return _icons.caution;
43
- case 'error':
44
- return _icons.error;
45
- default:
46
- return null;
47
- }
48
- }
48
+ const icon = contextBasedIcon(intent);
49
+ const hasIcon = !!icon;
49
50
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
50
- className: (0, _clsx.default)('components-badge', `is-${intent}`, intent !== 'default' && 'has-icon', className),
51
+ className: (0, _clsx.default)('components-badge', className, {
52
+ [`is-${intent}`]: intent,
53
+ 'has-icon': hasIcon
54
+ }),
51
55
  ...props,
52
- children: [intent !== 'default' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icon.default, {
53
- icon: contextBasedIcon(),
56
+ children: [hasIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icon.default, {
57
+ icon: icon,
54
58
  size: 16,
55
59
  fill: "currentColor",
56
60
  className: "components-badge__icon"
@@ -1 +1 @@
1
- {"version":3,"names":["_clsx","_interopRequireDefault","require","_icons","_icon","_jsxRuntime","Badge","className","intent","children","props","contextBasedIcon","info","published","caution","error","jsxs","clsx","jsx","default","icon","size","fill","_default","exports"],"sources":["@wordpress/components/src/badge/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { info, caution, error, published } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport type { BadgeProps } from './types';\nimport type { WordPressComponentProps } from '../context';\nimport Icon from '../icon';\n\nfunction Badge( {\n\tclassName,\n\tintent = 'default',\n\tchildren,\n\t...props\n}: WordPressComponentProps< BadgeProps, 'span', false > ) {\n\t/**\n\t * Returns an icon based on the badge context.\n\t *\n\t * @return The corresponding icon for the provided context.\n\t */\n\tfunction contextBasedIcon() {\n\t\tswitch ( intent ) {\n\t\t\tcase 'info':\n\t\t\t\treturn info;\n\t\t\tcase 'success':\n\t\t\t\treturn published;\n\t\t\tcase 'warning':\n\t\t\t\treturn caution;\n\t\t\tcase 'error':\n\t\t\t\treturn error;\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\t}\n\n\treturn (\n\t\t<span\n\t\t\tclassName={ clsx(\n\t\t\t\t'components-badge',\n\t\t\t\t`is-${ intent }`,\n\t\t\t\tintent !== 'default' && 'has-icon',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ intent !== 'default' && (\n\t\t\t\t<Icon\n\t\t\t\t\ticon={ contextBasedIcon() }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\tclassName=\"components-badge__icon\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<span className=\"components-badge__content\">{ children }</span>\n\t\t</span>\n\t);\n}\n\nexport default Badge;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AAOA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA2B,IAAAG,WAAA,GAAAH,OAAA;AAf3B;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAKA,SAASI,KAAKA,CAAE;EACfC,SAAS;EACTC,MAAM,GAAG,SAAS;EAClBC,QAAQ;EACR,GAAGC;AACkD,CAAC,EAAG;EACzD;AACD;AACA;AACA;AACA;EACC,SAASC,gBAAgBA,CAAA,EAAG;IAC3B,QAASH,MAAM;MACd,KAAK,MAAM;QACV,OAAOI,WAAI;MACZ,KAAK,SAAS;QACb,OAAOC,gBAAS;MACjB,KAAK,SAAS;QACb,OAAOC,cAAO;MACf,KAAK,OAAO;QACX,OAAOC,YAAK;MACb;QACC,OAAO,IAAI;IACb;EACD;EAEA,oBACC,IAAAV,WAAA,CAAAW,IAAA;IACCT,SAAS,EAAG,IAAAU,aAAI,EACf,kBAAkB,EAClB,MAAOT,MAAM,EAAG,EAChBA,MAAM,KAAK,SAAS,IAAI,UAAU,EAClCD,SACD,CAAG;IAAA,GACEG,KAAK;IAAAD,QAAA,GAERD,MAAM,KAAK,SAAS,iBACrB,IAAAH,WAAA,CAAAa,GAAA,EAACd,KAAA,CAAAe,OAAI;MACJC,IAAI,EAAGT,gBAAgB,CAAC,CAAG;MAC3BU,IAAI,EAAG,EAAI;MACXC,IAAI,EAAC,cAAc;MACnBf,SAAS,EAAC;IAAwB,CAClC,CACD,eACD,IAAAF,WAAA,CAAAa,GAAA;MAAMX,SAAS,EAAC,2BAA2B;MAAAE,QAAA,EAAGA;IAAQ,CAAQ,CAAC;EAAA,CAC1D,CAAC;AAET;AAAC,IAAAc,QAAA,GAAAC,OAAA,CAAAL,OAAA,GAEcb,KAAK","ignoreList":[]}
1
+ {"version":3,"names":["_clsx","_interopRequireDefault","require","_icons","_icon","_jsxRuntime","contextBasedIcon","intent","info","published","caution","error","Badge","className","children","props","icon","hasIcon","jsxs","clsx","jsx","default","size","fill","_default","exports"],"sources":["@wordpress/components/src/badge/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { info, caution, error, published } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport type { BadgeProps } from './types';\nimport type { WordPressComponentProps } from '../context';\nimport Icon from '../icon';\n\n/**\n * Returns an icon based on the badge context.\n *\n * @return The corresponding icon for the provided context.\n */\nfunction contextBasedIcon( intent: BadgeProps[ 'intent' ] = 'default' ) {\n\tswitch ( intent ) {\n\t\tcase 'info':\n\t\t\treturn info;\n\t\tcase 'success':\n\t\t\treturn published;\n\t\tcase 'warning':\n\t\t\treturn caution;\n\t\tcase 'error':\n\t\t\treturn error;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\nfunction Badge( {\n\tclassName,\n\tintent = 'default',\n\tchildren,\n\t...props\n}: WordPressComponentProps< BadgeProps, 'span', false > ) {\n\tconst icon = contextBasedIcon( intent );\n\tconst hasIcon = !! icon;\n\n\treturn (\n\t\t<span\n\t\t\tclassName={ clsx( 'components-badge', className, {\n\t\t\t\t[ `is-${ intent }` ]: intent,\n\t\t\t\t'has-icon': hasIcon,\n\t\t\t} ) }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ hasIcon && (\n\t\t\t\t<Icon\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\tclassName=\"components-badge__icon\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<span className=\"components-badge__content\">{ children }</span>\n\t\t</span>\n\t);\n}\n\nexport default Badge;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AAOA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA2B,IAAAG,WAAA,GAAAH,OAAA;AAf3B;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA,GACA,SAASI,gBAAgBA,CAAEC,MAA8B,GAAG,SAAS,EAAG;EACvE,QAASA,MAAM;IACd,KAAK,MAAM;MACV,OAAOC,WAAI;IACZ,KAAK,SAAS;MACb,OAAOC,gBAAS;IACjB,KAAK,SAAS;MACb,OAAOC,cAAO;IACf,KAAK,OAAO;MACX,OAAOC,YAAK;IACb;MACC,OAAO,IAAI;EACb;AACD;AAEA,SAASC,KAAKA,CAAE;EACfC,SAAS;EACTN,MAAM,GAAG,SAAS;EAClBO,QAAQ;EACR,GAAGC;AACkD,CAAC,EAAG;EACzD,MAAMC,IAAI,GAAGV,gBAAgB,CAAEC,MAAO,CAAC;EACvC,MAAMU,OAAO,GAAG,CAAC,CAAED,IAAI;EAEvB,oBACC,IAAAX,WAAA,CAAAa,IAAA;IACCL,SAAS,EAAG,IAAAM,aAAI,EAAE,kBAAkB,EAAEN,SAAS,EAAE;MAChD,CAAE,MAAON,MAAM,EAAG,GAAIA,MAAM;MAC5B,UAAU,EAAEU;IACb,CAAE,CAAG;IAAA,GACAF,KAAK;IAAAD,QAAA,GAERG,OAAO,iBACR,IAAAZ,WAAA,CAAAe,GAAA,EAAChB,KAAA,CAAAiB,OAAI;MACJL,IAAI,EAAGA,IAAM;MACbM,IAAI,EAAG,EAAI;MACXC,IAAI,EAAC,cAAc;MACnBV,SAAS,EAAC;IAAwB,CAClC,CACD,eACD,IAAAR,WAAA,CAAAe,GAAA;MAAMP,SAAS,EAAC,2BAA2B;MAAAC,QAAA,EAAGA;IAAQ,CAAQ,CAAC;EAAA,CAC1D,CAAC;AAET;AAAC,IAAAU,QAAA,GAAAC,OAAA,CAAAJ,OAAA,GAEcT,KAAK","ignoreList":[]}
@@ -8,8 +8,6 @@ exports.default = void 0;
8
8
  var _icons = require("@wordpress/icons");
9
9
  var _i18n = require("@wordpress/i18n");
10
10
  var _button = _interopRequireDefault(require("../../button"));
11
- var _tooltip = _interopRequireDefault(require("../../tooltip"));
12
- var _view = require("../../view");
13
11
  var _context = require("../../context");
14
12
  var _hook = require("./hook");
15
13
  var _jsxRuntime = require("react/jsx-runtime");
@@ -28,19 +26,14 @@ const BorderBoxControlLinkedButton = (props, forwardedRef) => {
28
26
  ...buttonProps
29
27
  } = (0, _hook.useBorderBoxControlLinkedButton)(props);
30
28
  const label = isLinked ? (0, _i18n.__)('Unlink sides') : (0, _i18n.__)('Link sides');
31
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_tooltip.default, {
32
- text: label,
33
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_view.View, {
34
- className: className,
35
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, {
36
- ...buttonProps,
37
- size: "small",
38
- icon: isLinked ? _icons.link : _icons.linkOff,
39
- iconSize: 24,
40
- "aria-label": label,
41
- ref: forwardedRef
42
- })
43
- })
29
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, {
30
+ ...buttonProps,
31
+ size: "small",
32
+ icon: isLinked ? _icons.link : _icons.linkOff,
33
+ iconSize: 24,
34
+ label: label,
35
+ ref: forwardedRef,
36
+ className: className
44
37
  });
45
38
  };
46
39
  const ConnectedBorderBoxControlLinkedButton = (0, _context.contextConnect)(BorderBoxControlLinkedButton, 'BorderBoxControlLinkedButton');
@@ -1 +1 @@
1
- {"version":3,"names":["_icons","require","_i18n","_button","_interopRequireDefault","_tooltip","_view","_context","_hook","_jsxRuntime","BorderBoxControlLinkedButton","props","forwardedRef","className","isLinked","buttonProps","useBorderBoxControlLinkedButton","label","__","jsx","default","text","children","View","size","icon","link","linkOff","iconSize","ref","ConnectedBorderBoxControlLinkedButton","contextConnect","_default","exports"],"sources":["@wordpress/components/src/border-box-control/border-box-control-linked-button/component.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { link, linkOff } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Button from '../../button';\nimport Tooltip from '../../tooltip';\nimport { View } from '../../view';\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect } from '../../context';\nimport { useBorderBoxControlLinkedButton } from './hook';\n\nimport type { LinkedButtonProps } from '../types';\n\nconst BorderBoxControlLinkedButton = (\n\tprops: WordPressComponentProps< LinkedButtonProps, 'button' >,\n\tforwardedRef: React.ForwardedRef< any >\n) => {\n\tconst { className, isLinked, ...buttonProps } =\n\t\tuseBorderBoxControlLinkedButton( props );\n\tconst label = isLinked ? __( 'Unlink sides' ) : __( 'Link sides' );\n\n\treturn (\n\t\t<Tooltip text={ label }>\n\t\t\t<View className={ className }>\n\t\t\t\t<Button\n\t\t\t\t\t{ ...buttonProps }\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t\ticon={ isLinked ? link : linkOff }\n\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t\taria-label={ label }\n\t\t\t\t\tref={ forwardedRef }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t</Tooltip>\n\t);\n};\n\nconst ConnectedBorderBoxControlLinkedButton = contextConnect(\n\tBorderBoxControlLinkedButton,\n\t'BorderBoxControlLinkedButton'\n);\nexport default ConnectedBorderBoxControlLinkedButton;\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,OAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,QAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAEA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AAAyD,IAAAQ,WAAA,GAAAR,OAAA;AAdzD;AACA;AACA;;AAIA;AACA;AACA;;AAUA,MAAMS,4BAA4B,GAAGA,CACpCC,KAA6D,EAC7DC,YAAuC,KACnC;EACJ,MAAM;IAAEC,SAAS;IAAEC,QAAQ;IAAE,GAAGC;EAAY,CAAC,GAC5C,IAAAC,qCAA+B,EAAEL,KAAM,CAAC;EACzC,MAAMM,KAAK,GAAGH,QAAQ,GAAG,IAAAI,QAAE,EAAE,cAAe,CAAC,GAAG,IAAAA,QAAE,EAAE,YAAa,CAAC;EAElE,oBACC,IAAAT,WAAA,CAAAU,GAAA,EAACd,QAAA,CAAAe,OAAO;IAACC,IAAI,EAAGJ,KAAO;IAAAK,QAAA,eACtB,IAAAb,WAAA,CAAAU,GAAA,EAACb,KAAA,CAAAiB,IAAI;MAACV,SAAS,EAAGA,SAAW;MAAAS,QAAA,eAC5B,IAAAb,WAAA,CAAAU,GAAA,EAAChB,OAAA,CAAAiB,OAAM;QAAA,GACDL,WAAW;QAChBS,IAAI,EAAC,OAAO;QACZC,IAAI,EAAGX,QAAQ,GAAGY,WAAI,GAAGC,cAAS;QAClCC,QAAQ,EAAG,EAAI;QACf,cAAaX,KAAO;QACpBY,GAAG,EAAGjB;MAAc,CACpB;IAAC,CACG;EAAC,CACC,CAAC;AAEZ,CAAC;AAED,MAAMkB,qCAAqC,GAAG,IAAAC,uBAAc,EAC3DrB,4BAA4B,EAC5B,8BACD,CAAC;AAAC,IAAAsB,QAAA,GAAAC,OAAA,CAAAb,OAAA,GACaU,qCAAqC","ignoreList":[]}
1
+ {"version":3,"names":["_icons","require","_i18n","_button","_interopRequireDefault","_context","_hook","_jsxRuntime","BorderBoxControlLinkedButton","props","forwardedRef","className","isLinked","buttonProps","useBorderBoxControlLinkedButton","label","__","jsx","default","size","icon","link","linkOff","iconSize","ref","ConnectedBorderBoxControlLinkedButton","contextConnect","_default","exports"],"sources":["@wordpress/components/src/border-box-control/border-box-control-linked-button/component.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { link, linkOff } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Button from '../../button';\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect } from '../../context';\nimport { useBorderBoxControlLinkedButton } from './hook';\n\nimport type { LinkedButtonProps } from '../types';\n\nconst BorderBoxControlLinkedButton = (\n\tprops: WordPressComponentProps< LinkedButtonProps, 'button' >,\n\tforwardedRef: React.ForwardedRef< any >\n) => {\n\tconst { className, isLinked, ...buttonProps } =\n\t\tuseBorderBoxControlLinkedButton( props );\n\tconst label = isLinked ? __( 'Unlink sides' ) : __( 'Link sides' );\n\n\treturn (\n\t\t<Button\n\t\t\t{ ...buttonProps }\n\t\t\tsize=\"small\"\n\t\t\ticon={ isLinked ? link : linkOff }\n\t\t\ticonSize={ 24 }\n\t\t\tlabel={ label }\n\t\t\tref={ forwardedRef }\n\t\t\tclassName={ className }\n\t\t/>\n\t);\n};\n\nconst ConnectedBorderBoxControlLinkedButton = contextConnect(\n\tBorderBoxControlLinkedButton,\n\t'BorderBoxControlLinkedButton'\n);\nexport default ConnectedBorderBoxControlLinkedButton;\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,OAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAAyD,IAAAM,WAAA,GAAAN,OAAA;AAZzD;AACA;AACA;;AAIA;AACA;AACA;;AAQA,MAAMO,4BAA4B,GAAGA,CACpCC,KAA6D,EAC7DC,YAAuC,KACnC;EACJ,MAAM;IAAEC,SAAS;IAAEC,QAAQ;IAAE,GAAGC;EAAY,CAAC,GAC5C,IAAAC,qCAA+B,EAAEL,KAAM,CAAC;EACzC,MAAMM,KAAK,GAAGH,QAAQ,GAAG,IAAAI,QAAE,EAAE,cAAe,CAAC,GAAG,IAAAA,QAAE,EAAE,YAAa,CAAC;EAElE,oBACC,IAAAT,WAAA,CAAAU,GAAA,EAACd,OAAA,CAAAe,OAAM;IAAA,GACDL,WAAW;IAChBM,IAAI,EAAC,OAAO;IACZC,IAAI,EAAGR,QAAQ,GAAGS,WAAI,GAAGC,cAAS;IAClCC,QAAQ,EAAG,EAAI;IACfR,KAAK,EAAGA,KAAO;IACfS,GAAG,EAAGd,YAAc;IACpBC,SAAS,EAAGA;EAAW,CACvB,CAAC;AAEJ,CAAC;AAED,MAAMc,qCAAqC,GAAG,IAAAC,uBAAc,EAC3DlB,4BAA4B,EAC5B,8BACD,CAAC;AAAC,IAAAmB,QAAA,GAAAC,OAAA,CAAAV,OAAA,GACaO,qCAAqC","ignoreList":[]}
@@ -15,6 +15,7 @@ exports.default = void 0;
15
15
  var _compose = require("@wordpress/compose");
16
16
  var _element = require("@wordpress/element");
17
17
  var _i18n = require("@wordpress/i18n");
18
+ var _warning = _interopRequireDefault(require("@wordpress/warning"));
18
19
  var _baseControl = require("../base-control");
19
20
  var _inputControl = _interopRequireDefault(require("./input-control"));
20
21
  var _linkedButton = _interopRequireDefault(require("./linked-button"));
@@ -148,6 +149,11 @@ function BoxControl({
148
149
  size: undefined
149
150
  });
150
151
  const sidesToRender = (0, _utils2.getAllowedSides)(sides);
152
+ if (presets && !presetKey || !presets && presetKey) {
153
+ const definedProp = presets ? 'presets' : 'presetKey';
154
+ const missingProp = presets ? 'presetKey' : 'presets';
155
+ globalThis.SCRIPT_DEBUG === true ? (0, _warning.default)(`wp.components.BoxControl: the '${missingProp}' prop is required when the '${definedProp}' prop is defined.`) : void 0;
156
+ }
151
157
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_grid.Grid, {
152
158
  id: id,
153
159
  columns: 3,
@@ -1 +1 @@
1
- {"version":3,"names":["_compose","require","_element","_i18n","_baseControl","_inputControl","_interopRequireDefault","_linkedButton","_grid","_boxControlStyles","_utils","_utils2","_hooks","_deprecated36pxSize","_jsxRuntime","defaultInputProps","min","noop","useUniqueId","idProp","instanceId","useInstanceId","BoxControl","__next40pxDefaultSize","id","inputProps","onChange","label","__","values","valuesProp","units","sides","splitOnAxis","allowReset","resetValues","DEFAULT_VALUES","presets","presetKey","onMouseOver","onMouseOut","setValues","useControlledState","fallback","inputValues","hasInitialValue","isValuesDefined","hasOneSide","length","isDirty","setIsDirty","useState","isLinked","setIsLinked","isValueMixed","side","setSide","getInitialSide","selectedUnits","setSelectedUnits","top","parseQuantityAndUnitFromRawValue","right","bottom","left","headingId","toggleLinked","handleOnFocus","_event","nextSide","handleOnChange","nextValues","handleOnReset","inputControlProps","onFocus","maybeWarnDeprecated36pxSize","componentName","size","undefined","sidesToRender","getAllowedSides","jsxs","Grid","columns","templateColumns","role","children","jsx","BaseControl","VisualLabel","InputWrapper","default","LinkedButtonWrapper","onClick","map","axis","Array","from","ResetButton","className","variant","disabled","_default","exports"],"sources":["@wordpress/components/src/box-control/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { BaseControl } from '../base-control';\nimport InputControl from './input-control';\nimport LinkedButton from './linked-button';\nimport { Grid } from '../grid';\nimport {\n\tInputWrapper,\n\tResetButton,\n\tLinkedButtonWrapper,\n} from './styles/box-control-styles';\nimport { parseQuantityAndUnitFromRawValue } from '../unit-control/utils';\nimport {\n\tDEFAULT_VALUES,\n\tgetInitialSide,\n\tisValueMixed,\n\tisValuesDefined,\n\tgetAllowedSides,\n} from './utils';\nimport { useControlledState } from '../utils/hooks';\nimport type {\n\tBoxControlIconProps,\n\tBoxControlProps,\n\tBoxControlValue,\n} from './types';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\n\nconst defaultInputProps = {\n\tmin: 0,\n};\n\nconst noop = () => {};\n\nfunction useUniqueId( idProp?: string ) {\n\tconst instanceId = useInstanceId( BoxControl, 'inspector-box-control' );\n\n\treturn idProp || instanceId;\n}\n\n/**\n * A control that lets users set values for top, right, bottom, and left. Can be\n * used as an input control for values like `padding` or `margin`.\n *\n * ```jsx\n * import { useState } from 'react';\n * import { BoxControl } from '@wordpress/components';\n *\n * function Example() {\n * const [ values, setValues ] = useState( {\n * top: '50px',\n * left: '10%',\n * right: '10%',\n * bottom: '50px',\n * } );\n *\n * return (\n * <BoxControl\n * __next40pxDefaultSize\n * values={ values }\n * onChange={ setValues }\n * />\n * );\n * };\n * ```\n */\nfunction BoxControl( {\n\t__next40pxDefaultSize = false,\n\tid: idProp,\n\tinputProps = defaultInputProps,\n\tonChange = noop,\n\tlabel = __( 'Box Control' ),\n\tvalues: valuesProp,\n\tunits,\n\tsides,\n\tsplitOnAxis = false,\n\tallowReset = true,\n\tresetValues = DEFAULT_VALUES,\n\tpresets,\n\tpresetKey,\n\tonMouseOver,\n\tonMouseOut,\n}: BoxControlProps ) {\n\tconst [ values, setValues ] = useControlledState( valuesProp, {\n\t\tfallback: DEFAULT_VALUES,\n\t} );\n\tconst inputValues = values || DEFAULT_VALUES;\n\tconst hasInitialValue = isValuesDefined( valuesProp );\n\tconst hasOneSide = sides?.length === 1;\n\n\tconst [ isDirty, setIsDirty ] = useState( hasInitialValue );\n\tconst [ isLinked, setIsLinked ] = useState(\n\t\t! hasInitialValue || ! isValueMixed( inputValues ) || hasOneSide\n\t);\n\n\tconst [ side, setSide ] = useState< BoxControlIconProps[ 'side' ] >(\n\t\tgetInitialSide( isLinked, splitOnAxis )\n\t);\n\n\t// Tracking selected units via internal state allows filtering of CSS unit\n\t// only values from being saved while maintaining preexisting unit selection\n\t// behaviour. Filtering CSS only values prevents invalid style values.\n\tconst [ selectedUnits, setSelectedUnits ] = useState< BoxControlValue >( {\n\t\ttop: parseQuantityAndUnitFromRawValue( valuesProp?.top )[ 1 ],\n\t\tright: parseQuantityAndUnitFromRawValue( valuesProp?.right )[ 1 ],\n\t\tbottom: parseQuantityAndUnitFromRawValue( valuesProp?.bottom )[ 1 ],\n\t\tleft: parseQuantityAndUnitFromRawValue( valuesProp?.left )[ 1 ],\n\t} );\n\n\tconst id = useUniqueId( idProp );\n\tconst headingId = `${ id }-heading`;\n\n\tconst toggleLinked = () => {\n\t\tsetIsLinked( ! isLinked );\n\t\tsetSide( getInitialSide( ! isLinked, splitOnAxis ) );\n\t};\n\n\tconst handleOnFocus = (\n\t\t_event: React.FocusEvent< HTMLInputElement >,\n\t\t{ side: nextSide }: { side: typeof side }\n\t) => {\n\t\tsetSide( nextSide );\n\t};\n\n\tconst handleOnChange = ( nextValues: BoxControlValue ) => {\n\t\tonChange( nextValues );\n\t\tsetValues( nextValues );\n\t\tsetIsDirty( true );\n\t};\n\n\tconst handleOnReset = () => {\n\t\tonChange( resetValues );\n\t\tsetValues( resetValues );\n\t\tsetSelectedUnits( resetValues );\n\t\tsetIsDirty( false );\n\t};\n\n\tconst inputControlProps = {\n\t\tonMouseOver,\n\t\tonMouseOut,\n\t\t...inputProps,\n\t\tonChange: handleOnChange,\n\t\tonFocus: handleOnFocus,\n\t\tisLinked,\n\t\tunits,\n\t\tselectedUnits,\n\t\tsetSelectedUnits,\n\t\tsides,\n\t\tvalues: inputValues,\n\t\t__next40pxDefaultSize,\n\t\tpresets,\n\t\tpresetKey,\n\t};\n\n\tmaybeWarnDeprecated36pxSize( {\n\t\tcomponentName: 'BoxControl',\n\t\t__next40pxDefaultSize,\n\t\tsize: undefined,\n\t} );\n\tconst sidesToRender = getAllowedSides( sides );\n\n\treturn (\n\t\t<Grid\n\t\t\tid={ id }\n\t\t\tcolumns={ 3 }\n\t\t\ttemplateColumns=\"1fr min-content min-content\"\n\t\t\trole=\"group\"\n\t\t\taria-labelledby={ headingId }\n\t\t>\n\t\t\t<BaseControl.VisualLabel id={ headingId }>\n\t\t\t\t{ label }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t{ isLinked && (\n\t\t\t\t<InputWrapper>\n\t\t\t\t\t<InputControl side=\"all\" { ...inputControlProps } />\n\t\t\t\t</InputWrapper>\n\t\t\t) }\n\t\t\t{ ! hasOneSide && (\n\t\t\t\t<LinkedButtonWrapper>\n\t\t\t\t\t<LinkedButton\n\t\t\t\t\t\tonClick={ toggleLinked }\n\t\t\t\t\t\tisLinked={ isLinked }\n\t\t\t\t\t/>\n\t\t\t\t</LinkedButtonWrapper>\n\t\t\t) }\n\n\t\t\t{ ! isLinked &&\n\t\t\t\tsplitOnAxis &&\n\t\t\t\t[ 'vertical', 'horizontal' ].map( ( axis ) => (\n\t\t\t\t\t<InputControl\n\t\t\t\t\t\tkey={ axis }\n\t\t\t\t\t\tside={ axis as 'horizontal' | 'vertical' }\n\t\t\t\t\t\t{ ...inputControlProps }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t{ ! isLinked &&\n\t\t\t\t! splitOnAxis &&\n\t\t\t\tArray.from( sidesToRender ).map( ( axis ) => (\n\t\t\t\t\t<InputControl\n\t\t\t\t\t\tkey={ axis }\n\t\t\t\t\t\tside={ axis }\n\t\t\t\t\t\t{ ...inputControlProps }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t{ allowReset && (\n\t\t\t\t<ResetButton\n\t\t\t\t\tclassName=\"component-box-control__reset-button\"\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t\tonClick={ handleOnReset }\n\t\t\t\t\tdisabled={ ! isDirty }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t</ResetButton>\n\t\t\t) }\n\t\t</Grid>\n\t);\n}\n\nexport { applyValueToSides } from './utils';\nexport default BoxControl;\n"],"mappings":";;;;;;;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GA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O,EAAC,WAAW;MACnBvB,IAAI,EAAC,OAAO;MACZgB,OAAO,EAAGrB,aAAe;MACzB6B,QAAQ,EAAG,CAAEpD,OAAS;MAAAqC,QAAA,EAEpB,IAAA1D,QAAE,EAAE,OAAQ;IAAC,CACH,CACb;EAAA,CACI,CAAC;AAET;AAAC,IAAA0E,QAAA,GAAAC,OAAA,CAAAZ,OAAA,GAGcrE,UAAU","ignoreList":[]}
1
+ {"version":3,"names":["_compose","require","_element","_i18n","_warning","_interopRequireDefault","_baseControl","_inputControl","_linkedButton","_grid","_boxControlStyles","_utils","_utils2","_hooks","_deprecated36pxSize","_jsxRuntime","defaultInputProps","min","noop","useUniqueId","idProp","instanceId","useInstanceId","BoxControl","__next40pxDefaultSize","id","inputProps","onChange","label","__","values","valuesProp","units","sides","splitOnAxis","allowReset","resetValues","DEFAULT_VALUES","presets","presetKey","onMouseOver","onMouseOut","setValues","useControlledState","fallback","inputValues","hasInitialValue","isValuesDefined","hasOneSide","length","isDirty","setIsDirty","useState","isLinked","setIsLinked","isValueMixed","side","setSide","getInitialSide","selectedUnits","setSelectedUnits","top","parseQuantityAndUnitFromRawValue","right","bottom","left","headingId","toggleLinked","handleOnFocus","_event","nextSide","handleOnChange","nextValues","handleOnReset","inputControlProps","onFocus","maybeWarnDeprecated36pxSize","componentName","size","undefined","sidesToRender","getAllowedSides","definedProp","missingProp","globalThis","SCRIPT_DEBUG","warning","jsxs","Grid","columns","templateColumns","role","children","jsx","BaseControl","VisualLabel","InputWrapper","default","LinkedButtonWrapper","onClick","map","axis","Array","from","ResetButton","className","variant","disabled","_default","exports"],"sources":["@wordpress/components/src/box-control/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { BaseControl } from '../base-control';\nimport InputControl from './input-control';\nimport LinkedButton from './linked-button';\nimport { Grid } from '../grid';\nimport {\n\tInputWrapper,\n\tResetButton,\n\tLinkedButtonWrapper,\n} from './styles/box-control-styles';\nimport { parseQuantityAndUnitFromRawValue } from '../unit-control/utils';\nimport {\n\tDEFAULT_VALUES,\n\tgetInitialSide,\n\tisValueMixed,\n\tisValuesDefined,\n\tgetAllowedSides,\n} from './utils';\nimport { useControlledState } from '../utils/hooks';\nimport type {\n\tBoxControlIconProps,\n\tBoxControlProps,\n\tBoxControlValue,\n} from './types';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\n\nconst defaultInputProps = {\n\tmin: 0,\n};\n\nconst noop = () => {};\n\nfunction useUniqueId( idProp?: string ) {\n\tconst instanceId = useInstanceId( BoxControl, 'inspector-box-control' );\n\n\treturn idProp || instanceId;\n}\n\n/**\n * A control that lets users set values for top, right, bottom, and left. Can be\n * used as an input control for values like `padding` or `margin`.\n *\n * ```jsx\n * import { useState } from 'react';\n * import { BoxControl } from '@wordpress/components';\n *\n * function Example() {\n * const [ values, setValues ] = useState( {\n * top: '50px',\n * left: '10%',\n * right: '10%',\n * bottom: '50px',\n * } );\n *\n * return (\n * <BoxControl\n * __next40pxDefaultSize\n * values={ values }\n * onChange={ setValues }\n * />\n * );\n * };\n * ```\n */\nfunction BoxControl( {\n\t__next40pxDefaultSize = false,\n\tid: idProp,\n\tinputProps = defaultInputProps,\n\tonChange = noop,\n\tlabel = __( 'Box Control' ),\n\tvalues: valuesProp,\n\tunits,\n\tsides,\n\tsplitOnAxis = false,\n\tallowReset = true,\n\tresetValues = DEFAULT_VALUES,\n\tpresets,\n\tpresetKey,\n\tonMouseOver,\n\tonMouseOut,\n}: BoxControlProps ) {\n\tconst [ values, setValues ] = useControlledState( valuesProp, {\n\t\tfallback: DEFAULT_VALUES,\n\t} );\n\tconst inputValues = values || DEFAULT_VALUES;\n\tconst hasInitialValue = isValuesDefined( valuesProp );\n\tconst hasOneSide = sides?.length === 1;\n\n\tconst [ isDirty, setIsDirty ] = useState( hasInitialValue );\n\tconst [ isLinked, setIsLinked ] = useState(\n\t\t! hasInitialValue || ! isValueMixed( inputValues ) || hasOneSide\n\t);\n\n\tconst [ side, setSide ] = useState< BoxControlIconProps[ 'side' ] >(\n\t\tgetInitialSide( isLinked, splitOnAxis )\n\t);\n\n\t// Tracking selected units via internal state allows filtering of CSS unit\n\t// only values from being saved while maintaining preexisting unit selection\n\t// behaviour. Filtering CSS only values prevents invalid style values.\n\tconst [ selectedUnits, setSelectedUnits ] = useState< BoxControlValue >( {\n\t\ttop: parseQuantityAndUnitFromRawValue( valuesProp?.top )[ 1 ],\n\t\tright: parseQuantityAndUnitFromRawValue( valuesProp?.right )[ 1 ],\n\t\tbottom: parseQuantityAndUnitFromRawValue( valuesProp?.bottom )[ 1 ],\n\t\tleft: parseQuantityAndUnitFromRawValue( valuesProp?.left )[ 1 ],\n\t} );\n\n\tconst id = useUniqueId( idProp );\n\tconst headingId = `${ id }-heading`;\n\n\tconst toggleLinked = () => {\n\t\tsetIsLinked( ! isLinked );\n\t\tsetSide( getInitialSide( ! isLinked, splitOnAxis ) );\n\t};\n\n\tconst handleOnFocus = (\n\t\t_event: React.FocusEvent< HTMLInputElement >,\n\t\t{ side: nextSide }: { side: typeof side }\n\t) => {\n\t\tsetSide( nextSide );\n\t};\n\n\tconst handleOnChange = ( nextValues: BoxControlValue ) => {\n\t\tonChange( nextValues );\n\t\tsetValues( nextValues );\n\t\tsetIsDirty( true );\n\t};\n\n\tconst handleOnReset = () => {\n\t\tonChange( resetValues );\n\t\tsetValues( resetValues );\n\t\tsetSelectedUnits( resetValues );\n\t\tsetIsDirty( false );\n\t};\n\n\tconst inputControlProps = {\n\t\tonMouseOver,\n\t\tonMouseOut,\n\t\t...inputProps,\n\t\tonChange: handleOnChange,\n\t\tonFocus: handleOnFocus,\n\t\tisLinked,\n\t\tunits,\n\t\tselectedUnits,\n\t\tsetSelectedUnits,\n\t\tsides,\n\t\tvalues: inputValues,\n\t\t__next40pxDefaultSize,\n\t\tpresets,\n\t\tpresetKey,\n\t};\n\n\tmaybeWarnDeprecated36pxSize( {\n\t\tcomponentName: 'BoxControl',\n\t\t__next40pxDefaultSize,\n\t\tsize: undefined,\n\t} );\n\tconst sidesToRender = getAllowedSides( sides );\n\n\tif ( ( presets && ! presetKey ) || ( ! presets && presetKey ) ) {\n\t\tconst definedProp = presets ? 'presets' : 'presetKey';\n\t\tconst missingProp = presets ? 'presetKey' : 'presets';\n\t\twarning(\n\t\t\t`wp.components.BoxControl: the '${ missingProp }' prop is required when the '${ definedProp }' prop is defined.`\n\t\t);\n\t}\n\n\treturn (\n\t\t<Grid\n\t\t\tid={ id }\n\t\t\tcolumns={ 3 }\n\t\t\ttemplateColumns=\"1fr min-content min-content\"\n\t\t\trole=\"group\"\n\t\t\taria-labelledby={ headingId }\n\t\t>\n\t\t\t<BaseControl.VisualLabel id={ headingId }>\n\t\t\t\t{ label }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t{ isLinked && (\n\t\t\t\t<InputWrapper>\n\t\t\t\t\t<InputControl side=\"all\" { ...inputControlProps } />\n\t\t\t\t</InputWrapper>\n\t\t\t) }\n\t\t\t{ ! hasOneSide && (\n\t\t\t\t<LinkedButtonWrapper>\n\t\t\t\t\t<LinkedButton\n\t\t\t\t\t\tonClick={ toggleLinked }\n\t\t\t\t\t\tisLinked={ isLinked }\n\t\t\t\t\t/>\n\t\t\t\t</LinkedButtonWrapper>\n\t\t\t) }\n\n\t\t\t{ ! isLinked &&\n\t\t\t\tsplitOnAxis &&\n\t\t\t\t[ 'vertical', 'horizontal' ].map( ( axis ) => (\n\t\t\t\t\t<InputControl\n\t\t\t\t\t\tkey={ axis }\n\t\t\t\t\t\tside={ axis as 'horizontal' | 'vertical' }\n\t\t\t\t\t\t{ ...inputControlProps }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t{ ! isLinked &&\n\t\t\t\t! splitOnAxis &&\n\t\t\t\tArray.from( sidesToRender ).map( ( axis ) => (\n\t\t\t\t\t<InputControl\n\t\t\t\t\t\tkey={ axis }\n\t\t\t\t\t\tside={ axis }\n\t\t\t\t\t\t{ ...inputControlProps }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t{ allowReset && (\n\t\t\t\t<ResetButton\n\t\t\t\t\tclassName=\"component-box-control__reset-button\"\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t\tonClick={ handleOnReset }\n\t\t\t\t\tdisabled={ ! isDirty }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t</ResetButton>\n\t\t\t) }\n\t\t</Grid>\n\t);\n}\n\nexport { applyValueToSides } from './utils';\nexport default BoxControl;\n"],"mappings":";;;;;;;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAKA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,aAAA,GAAAH,sBAAA,CAAAJ,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AACA,IAAAS,iBAAA,GAAAT,OAAA;AAKA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,OAAA,GAAAX,OAAA;AAOA,IAAAY,MAAA,GAAAZ,OAAA;AAMA,IAAAa,mBAAA,GAAAb,OAAA;AAA4E,IAAAc,WAAA,GAAAd,OAAA;AAlC5E;AACA;AACA;;AAMA;AACA;AACA;;AA0BA,MAAMe,iBAAiB,GAAG;EACzBC,GAAG,EAAE;AACN,CAAC;AAED,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,SAASC,WAAWA,CAAEC,MAAe,EAAG;EACvC,MAAMC,UAAU,GAAG,IAAAC,sBAAa,EAAEC,UAAU,EAAE,uBAAwB,CAAC;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MAAiB,CAAI;IAAC,CACvC,CACd,EACC,CAAE1B,UAAU,iBACb,IAAAjC,WAAA,CAAA8E,GAAA,EAACnF,iBAAA,CAAAwF,mBAAmB;MAAAN,QAAA,eACnB,IAAA7E,WAAA,CAAA8E,GAAA,EAACrF,aAAA,CAAAyF,OAAY;QACZE,OAAO,EAAGhC,YAAc;QACxBd,QAAQ,EAAGA;MAAU,CACrB;IAAC,CACkB,CACrB,EAEC,CAAEA,QAAQ,IACXnB,WAAW,IACX,CAAE,UAAU,EAAE,YAAY,CAAE,CAACkE,GAAG,CAAIC,IAAI,iBACvC,IAAAtF,WAAA,CAAA8E,GAAA,EAACtF,aAAA,CAAA0F,OAAY;MAEZzC,IAAI,EAAG6C,IAAmC;MAAA,GACrC3B;IAAiB,GAFhB2B,IAGN,CACA,CAAC,EACF,CAAEhD,QAAQ,IACX,CAAEnB,WAAW,IACboE,KAAK,CAACC,IAAI,CAAEvB,aAAc,CAAC,CAACoB,GAAG,CAAIC,IAAI,iBACtC,IAAAtF,WAAA,CAAA8E,GAAA,EAACtF,aAAA,CAAA0F,OAAY;MAEZzC,IAAI,EAAG6C,IAAM;MAAA,GACR3B;IAAiB,GAFhB2B,IAGN,CACA,CAAC,EACFlE,UAAU,iBACX,IAAApB,WAAA,CAAA8E,GAAA,EAACnF,iBAAA,CAAA8F,WAAW;MACXC,SAAS,EAAC,qCAAqC;MAC/CC,OAAO,EAAC,WAAW;MACnB5B,IAAI,EAAC,OAAO;MACZqB,OAAO,EAAG1B,aAAe;MACzBkC,QAAQ,EAAG,CAAEzD,OAAS;MAAA0C,QAAA,EAEpB,IAAA/D,QAAE,EAAE,OAAQ;IAAC,CACH,CACb;EAAA,CACI,CAAC;AAET;AAAC,IAAA+E,QAAA,GAAAC,OAAA,CAAAZ,OAAA,GAGc1E,UAAU","ignoreList":[]}
@@ -8,7 +8,6 @@ exports.default = LinkedButton;
8
8
  var _icons = require("@wordpress/icons");
9
9
  var _i18n = require("@wordpress/i18n");
10
10
  var _button = _interopRequireDefault(require("../button"));
11
- var _tooltip = _interopRequireDefault(require("../tooltip"));
12
11
  var _jsxRuntime = require("react/jsx-runtime");
13
12
  /**
14
13
  * WordPress dependencies
@@ -23,16 +22,13 @@ function LinkedButton({
23
22
  ...props
24
23
  }) {
25
24
  const label = isLinked ? (0, _i18n.__)('Unlink sides') : (0, _i18n.__)('Link sides');
26
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_tooltip.default, {
27
- text: label,
28
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, {
29
- ...props,
30
- className: "component-box-control__linked-button",
31
- size: "small",
32
- icon: isLinked ? _icons.link : _icons.linkOff,
33
- iconSize: 24,
34
- "aria-label": label
35
- })
25
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, {
26
+ ...props,
27
+ className: "component-box-control__linked-button",
28
+ size: "small",
29
+ icon: isLinked ? _icons.link : _icons.linkOff,
30
+ iconSize: 24,
31
+ label: label
36
32
  });
37
33
  }
38
34
  //# sourceMappingURL=linked-button.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_icons","require","_i18n","_button","_interopRequireDefault","_tooltip","_jsxRuntime","LinkedButton","isLinked","props","label","__","jsx","default","text","children","className","size","icon","link","linkOff","iconSize"],"sources":["@wordpress/components/src/box-control/linked-button.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { link, linkOff } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport Tooltip from '../tooltip';\n\nexport default function LinkedButton( {\n\tisLinked,\n\t...props\n}: { isLinked?: boolean } & React.ComponentProps< typeof Button > ) {\n\tconst label = isLinked ? __( 'Unlink sides' ) : __( 'Link sides' );\n\n\treturn (\n\t\t<Tooltip text={ label }>\n\t\t\t<Button\n\t\t\t\t{ ...props }\n\t\t\t\tclassName=\"component-box-control__linked-button\"\n\t\t\t\tsize=\"small\"\n\t\t\t\ticon={ isLinked ? link : linkOff }\n\t\t\t\ticonSize={ 24 }\n\t\t\t\taria-label={ label }\n\t\t\t/>\n\t\t</Tooltip>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,OAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,QAAA,GAAAD,sBAAA,CAAAH,OAAA;AAAiC,IAAAK,WAAA,GAAAL,OAAA;AAVjC;AACA;AACA;;AAIA;AACA;AACA;;AAIe,SAASM,YAAYA,CAAE;EACrCC,QAAQ;EACR,GAAGC;AAC4D,CAAC,EAAG;EACnE,MAAMC,KAAK,GAAGF,QAAQ,GAAG,IAAAG,QAAE,EAAE,cAAe,CAAC,GAAG,IAAAA,QAAE,EAAE,YAAa,CAAC;EAElE,oBACC,IAAAL,WAAA,CAAAM,GAAA,EAACP,QAAA,CAAAQ,OAAO;IAACC,IAAI,EAAGJ,KAAO;IAAAK,QAAA,eACtB,IAAAT,WAAA,CAAAM,GAAA,EAACT,OAAA,CAAAU,OAAM;MAAA,GACDJ,KAAK;MACVO,SAAS,EAAC,sCAAsC;MAChDC,IAAI,EAAC,OAAO;MACZC,IAAI,EAAGV,QAAQ,GAAGW,WAAI,GAAGC,cAAS;MAClCC,QAAQ,EAAG,EAAI;MACf,cAAaX;IAAO,CACpB;EAAC,CACM,CAAC;AAEZ","ignoreList":[]}
1
+ {"version":3,"names":["_icons","require","_i18n","_button","_interopRequireDefault","_jsxRuntime","LinkedButton","isLinked","props","label","__","jsx","default","className","size","icon","link","linkOff","iconSize"],"sources":["@wordpress/components/src/box-control/linked-button.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { link, linkOff } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\n\nexport default function LinkedButton( {\n\tisLinked,\n\t...props\n}: { isLinked?: boolean } & React.ComponentProps< typeof Button > ) {\n\tconst label = isLinked ? __( 'Unlink sides' ) : __( 'Link sides' );\n\n\treturn (\n\t\t<Button\n\t\t\t{ ...props }\n\t\t\tclassName=\"component-box-control__linked-button\"\n\t\t\tsize=\"small\"\n\t\t\ticon={ isLinked ? link : linkOff }\n\t\t\ticonSize={ 24 }\n\t\t\tlabel={ label }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,OAAA,GAAAC,sBAAA,CAAAH,OAAA;AAA+B,IAAAI,WAAA,GAAAJ,OAAA;AAT/B;AACA;AACA;;AAIA;AACA;AACA;;AAGe,SAASK,YAAYA,CAAE;EACrCC,QAAQ;EACR,GAAGC;AAC4D,CAAC,EAAG;EACnE,MAAMC,KAAK,GAAGF,QAAQ,GAAG,IAAAG,QAAE,EAAE,cAAe,CAAC,GAAG,IAAAA,QAAE,EAAE,YAAa,CAAC;EAElE,oBACC,IAAAL,WAAA,CAAAM,GAAA,EAACR,OAAA,CAAAS,OAAM;IAAA,GACDJ,KAAK;IACVK,SAAS,EAAC,sCAAsC;IAChDC,IAAI,EAAC,OAAO;IACZC,IAAI,EAAGR,QAAQ,GAAGS,WAAI,GAAGC,cAAS;IAClCC,QAAQ,EAAG,EAAI;IACfT,KAAK,EAAGA;EAAO,CACf,CAAC;AAEJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/components/src/box-control/types.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { UnitControlProps } from '../unit-control/types';\nimport type { LABELS } from './utils';\n\nexport type BoxControlValue = {\n\ttop?: string;\n\tright?: string;\n\tbottom?: string;\n\tleft?: string;\n};\n\nexport type CustomValueUnits = {\n\t[ key: string ]: { max: number; step: number };\n};\n\nexport interface Preset {\n\tname: string;\n\tslug: string;\n\tvalue?: string;\n}\n\ntype UnitControlPassthroughProps = Omit<\n\tUnitControlProps,\n\t'label' | 'onChange' | 'onFocus' | 'units'\n>;\n\ntype DeprecatedBoxControlProps = {\n\t/**\n\t * @deprecated Pass to the `inputProps` prop instead.\n\t * @ignore\n\t */\n\tonMouseOver?: UnitControlProps[ 'onMouseOver' ];\n\t/**\n\t * @deprecated Pass to the `inputProps` prop instead.\n\t * @ignore\n\t */\n\tonMouseOut?: UnitControlProps[ 'onMouseOut' ];\n};\n\nexport type BoxControlProps = Pick< UnitControlProps, 'units' > &\n\tDeprecatedBoxControlProps & {\n\t\t/**\n\t\t * If this property is true, a button to reset the box control is rendered.\n\t\t *\n\t\t * @default true\n\t\t */\n\t\tallowReset?: boolean;\n\t\t/**\n\t\t * The id to use as a base for the unique HTML id attribute of the control.\n\t\t */\n\t\tid?: string;\n\t\t/**\n\t\t * Props for the internal `UnitControl` components.\n\t\t *\n\t\t * @default { min: 0 }\n\t\t */\n\t\tinputProps?: UnitControlPassthroughProps;\n\t\t/**\n\t\t * Heading label for the control.\n\t\t *\n\t\t * @default __( 'Box Control' )\n\t\t */\n\t\tlabel?: string;\n\t\t/**\n\t\t * A callback function when an input value changes.\n\t\t */\n\t\tonChange: ( next: BoxControlValue ) => void;\n\t\t/**\n\t\t * The `top`, `right`, `bottom`, and `left` box dimension values to use when the control is reset.\n\t\t *\n\t\t * @default { top: undefined, right: undefined, bottom: undefined, left: undefined }\n\t\t */\n\t\tresetValues?: BoxControlValue;\n\t\t/**\n\t\t * Collection of sides to allow control of. If omitted or empty, all sides will be available.\n\t\t *\n\t\t * Allowed values are \"top\", \"right\", \"bottom\", \"left\", \"vertical\", and \"horizontal\".\n\t\t */\n\t\tsides?: readonly (\n\t\t\t| keyof BoxControlValue\n\t\t\t| 'horizontal'\n\t\t\t| 'vertical'\n\t\t)[];\n\t\t/**\n\t\t * If this property is true, when the box control is unlinked, vertical and horizontal controls\n\t\t * can be used instead of updating individual sides.\n\t\t *\n\t\t * @default false\n\t\t */\n\t\tsplitOnAxis?: boolean;\n\t\t/**\n\t\t * The current values of the control, expressed as an object of `top`, `right`, `bottom`, and `left` values.\n\t\t */\n\t\tvalues?: BoxControlValue;\n\t\t/**\n\t\t * Start opting into the larger default height that will become the default size in a future version.\n\t\t *\n\t\t * @default false\n\t\t */\n\t\t__next40pxDefaultSize?: boolean;\n\t\t/**\n\t\t * Available presets to pick from.\n\t\t */\n\t\tpresets?: Preset[];\n\t\t/**\n\t\t * The key of the preset to apply.\n\t\t * If you provide a list of presets, you must provide a preset key to use.\n\t\t * The format of preset selected values is going to be `var:preset|${ presetKey }|${ presetSlug }`\n\t\t */\n\t\tpresetKey?: string;\n\t};\n\nexport type BoxControlInputControlProps = UnitControlPassthroughProps & {\n\tonChange?: ( nextValues: BoxControlValue ) => void;\n\tonFocus?: (\n\t\t_event: React.FocusEvent< HTMLInputElement >,\n\t\t{ side }: { side: keyof typeof LABELS }\n\t) => void;\n\tonHoverOff?: (\n\t\tsides: Partial< Record< keyof BoxControlValue, boolean > >\n\t) => void;\n\tonHoverOn?: (\n\t\tsides: Partial< Record< keyof BoxControlValue, boolean > >\n\t) => void;\n\tselectedUnits: BoxControlValue;\n\tsetSelectedUnits: React.Dispatch< React.SetStateAction< BoxControlValue > >;\n\tvalues: BoxControlValue;\n\t/**\n\t * Collection of sides to allow control of. If omitted or empty, all sides will be available.\n\t */\n\tsides: BoxControlProps[ 'sides' ];\n\t/**\n\t * Side represents the current side being rendered by the input.\n\t * It can be a concrete side like: left, right, top, bottom or a combined one like: horizontal, vertical.\n\t */\n\tside: keyof typeof LABELS;\n\tpresets?: Preset[];\n\tpresetKey?: string;\n};\n\nexport type BoxControlIconProps = {\n\t/**\n\t * @default 24\n\t */\n\tsize?: number;\n\t/**\n\t * @default 'all'\n\t */\n\tside?: keyof typeof LABELS;\n\tsides?: BoxControlProps[ 'sides' ];\n};\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["@wordpress/components/src/box-control/types.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { UnitControlProps } from '../unit-control/types';\nimport type { LABELS } from './utils';\n\nexport type BoxControlValue = {\n\ttop?: string;\n\tright?: string;\n\tbottom?: string;\n\tleft?: string;\n};\n\nexport type CustomValueUnits = {\n\t[ key: string ]: { max: number; step: number };\n};\n\nexport interface Preset {\n\tname: string;\n\tslug: string;\n\tvalue?: string;\n}\n\ntype UnitControlPassthroughProps = Omit<\n\tUnitControlProps,\n\t'label' | 'onChange' | 'onFocus' | 'units'\n>;\n\ntype DeprecatedBoxControlProps = {\n\t/**\n\t * @deprecated Pass to the `inputProps` prop instead.\n\t * @ignore\n\t */\n\tonMouseOver?: UnitControlProps[ 'onMouseOver' ];\n\t/**\n\t * @deprecated Pass to the `inputProps` prop instead.\n\t * @ignore\n\t */\n\tonMouseOut?: UnitControlProps[ 'onMouseOut' ];\n};\n\nexport type BoxControlProps = Pick< UnitControlProps, 'units' > &\n\tDeprecatedBoxControlProps & {\n\t\t/**\n\t\t * If this property is true, a button to reset the box control is rendered.\n\t\t *\n\t\t * @default true\n\t\t */\n\t\tallowReset?: boolean;\n\t\t/**\n\t\t * The id to use as a base for the unique HTML id attribute of the control.\n\t\t */\n\t\tid?: string;\n\t\t/**\n\t\t * Props for the internal `UnitControl` components.\n\t\t *\n\t\t * @default { min: 0 }\n\t\t */\n\t\tinputProps?: UnitControlPassthroughProps;\n\t\t/**\n\t\t * Heading label for the control.\n\t\t *\n\t\t * @default __( 'Box Control' )\n\t\t */\n\t\tlabel?: string;\n\t\t/**\n\t\t * A callback function when an input value changes.\n\t\t */\n\t\tonChange: ( next: BoxControlValue ) => void;\n\t\t/**\n\t\t * The `top`, `right`, `bottom`, and `left` box dimension values to use when the control is reset.\n\t\t *\n\t\t * @default { top: undefined, right: undefined, bottom: undefined, left: undefined }\n\t\t */\n\t\tresetValues?: BoxControlValue;\n\t\t/**\n\t\t * Collection of sides to allow control of. If omitted or empty, all sides will be available.\n\t\t *\n\t\t * Allowed values are \"top\", \"right\", \"bottom\", \"left\", \"vertical\", and \"horizontal\".\n\t\t */\n\t\tsides?: readonly (\n\t\t\t| keyof BoxControlValue\n\t\t\t| 'horizontal'\n\t\t\t| 'vertical'\n\t\t)[];\n\t\t/**\n\t\t * If this property is true, when the box control is unlinked, vertical and horizontal controls\n\t\t * can be used instead of updating individual sides.\n\t\t *\n\t\t * @default false\n\t\t */\n\t\tsplitOnAxis?: boolean;\n\t\t/**\n\t\t * The current values of the control, expressed as an object of `top`, `right`, `bottom`, and `left` values.\n\t\t */\n\t\tvalues?: BoxControlValue;\n\t\t/**\n\t\t * Start opting into the larger default height that will become the default size in a future version.\n\t\t *\n\t\t * @default false\n\t\t */\n\t\t__next40pxDefaultSize?: boolean;\n\t} & (\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Available presets to pick from.\n\t\t\t\t */\n\t\t\t\tpresets?: never;\n\t\t\t\t/**\n\t\t\t\t * The key of the preset to apply.\n\t\t\t\t * If you provide a list of presets, you must provide a preset key to use.\n\t\t\t\t * The format of preset selected values is going to be `var:preset|${ presetKey }|${ presetSlug }`\n\t\t\t\t */\n\t\t\t\tpresetKey?: never;\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Available presets to pick from.\n\t\t\t\t */\n\t\t\t\tpresets: Preset[];\n\t\t\t\t/**\n\t\t\t\t * The key of the preset to apply.\n\t\t\t\t * If you provide a list of presets, you must provide a preset key to use.\n\t\t\t\t * The format of preset selected values is going to be `var:preset|${ presetKey }|${ presetSlug }`\n\t\t\t\t */\n\t\t\t\tpresetKey: string;\n\t\t }\n\t);\n\nexport type BoxControlInputControlProps = UnitControlPassthroughProps & {\n\tonChange?: ( nextValues: BoxControlValue ) => void;\n\tonFocus?: (\n\t\t_event: React.FocusEvent< HTMLInputElement >,\n\t\t{ side }: { side: keyof typeof LABELS }\n\t) => void;\n\tonHoverOff?: (\n\t\tsides: Partial< Record< keyof BoxControlValue, boolean > >\n\t) => void;\n\tonHoverOn?: (\n\t\tsides: Partial< Record< keyof BoxControlValue, boolean > >\n\t) => void;\n\tselectedUnits: BoxControlValue;\n\tsetSelectedUnits: React.Dispatch< React.SetStateAction< BoxControlValue > >;\n\tvalues: BoxControlValue;\n\t/**\n\t * Collection of sides to allow control of. If omitted or empty, all sides will be available.\n\t */\n\tsides: BoxControlProps[ 'sides' ];\n\t/**\n\t * Side represents the current side being rendered by the input.\n\t * It can be a concrete side like: left, right, top, bottom or a combined one like: horizontal, vertical.\n\t */\n\tside: keyof typeof LABELS;\n\tpresets?: Preset[];\n\tpresetKey?: string;\n};\n\nexport type BoxControlIconProps = {\n\t/**\n\t * @default 24\n\t */\n\tsize?: number;\n\t/**\n\t * @default 'all'\n\t */\n\tside?: keyof typeof LABELS;\n\tsides?: BoxControlProps[ 'sides' ];\n};\n"],"mappings":"","ignoreList":[]}
@@ -12,7 +12,6 @@ var _icons = require("@wordpress/icons");
12
12
  var _circularOptionPickerContext = require("./circular-option-picker-context");
13
13
  var _button = _interopRequireDefault(require("../button"));
14
14
  var _composite = require("../composite");
15
- var _tooltip = _interopRequireDefault(require("../tooltip"));
16
15
  var _jsxRuntime = require("react/jsx-runtime");
17
16
  /**
18
17
  * External dependencies
@@ -29,12 +28,14 @@ var _jsxRuntime = require("react/jsx-runtime");
29
28
  function UnforwardedOptionAsButton(props, forwardedRef) {
30
29
  const {
31
30
  isPressed,
31
+ label,
32
32
  ...additionalProps
33
33
  } = props;
34
34
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, {
35
35
  ...additionalProps,
36
36
  "aria-pressed": isPressed,
37
- ref: forwardedRef
37
+ ref: forwardedRef,
38
+ label: label
38
39
  });
39
40
  }
40
41
  const OptionAsButton = (0, _element.forwardRef)(UnforwardedOptionAsButton);
@@ -42,6 +43,7 @@ function UnforwardedOptionAsOption(props, forwardedRef) {
42
43
  const {
43
44
  id,
44
45
  isSelected,
46
+ label,
45
47
  ...additionalProps
46
48
  } = props;
47
49
  const {
@@ -61,7 +63,8 @@ function UnforwardedOptionAsOption(props, forwardedRef) {
61
63
  ...additionalProps,
62
64
  role: "option",
63
65
  "aria-selected": !!isSelected,
64
- ref: forwardedRef
66
+ ref: forwardedRef,
67
+ label: label
65
68
  }),
66
69
  id: id
67
70
  });
@@ -88,17 +91,16 @@ function Option({
88
91
  const isListbox = setActiveId !== undefined;
89
92
  const optionControl = isListbox ? /*#__PURE__*/(0, _jsxRuntime.jsx)(OptionAsOption, {
90
93
  ...commonProps,
94
+ label: tooltipText,
91
95
  isSelected: isSelected
92
96
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(OptionAsButton, {
93
97
  ...commonProps,
98
+ label: tooltipText,
94
99
  isPressed: isSelected
95
100
  });
96
101
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
97
102
  className: (0, _clsx.default)(className, 'components-circular-option-picker__option-wrapper'),
98
- children: [tooltipText ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_tooltip.default, {
99
- text: tooltipText,
100
- children: optionControl
101
- }) : optionControl, isSelected && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
103
+ children: [optionControl, isSelected && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
102
104
  icon: _icons.check,
103
105
  ...selectedIconProps
104
106
  })]
@@ -1 +1 @@
1
- {"version":3,"names":["_clsx","_interopRequireDefault","require","_compose","_element","_icons","_circularOptionPickerContext","_button","_composite","_tooltip","_jsxRuntime","UnforwardedOptionAsButton","props","forwardedRef","isPressed","additionalProps","jsx","default","ref","OptionAsButton","forwardRef","UnforwardedOptionAsOption","id","isSelected","setActiveId","activeId","useContext","CircularOptionPickerContext","useEffect","window","setTimeout","Composite","Item","render","role","OptionAsOption","Option","className","selectedIconProps","tooltipText","baseId","useInstanceId","commonProps","__next40pxDefaultSize","isListbox","undefined","optionControl","jsxs","clsx","children","text","Icon","icon","check"],"sources":["@wordpress/components/src/circular-option-picker/circular-option-picker-option.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef, useContext, useEffect } from '@wordpress/element';\nimport { Icon, check } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { CircularOptionPickerContext } from './circular-option-picker-context';\nimport Button from '../button';\nimport { Composite } from '../composite';\nimport Tooltip from '../tooltip';\nimport type { OptionProps } from './types';\n\nfunction UnforwardedOptionAsButton(\n\tprops: {\n\t\tid?: string;\n\t\tclassName?: string;\n\t\tisPressed?: boolean;\n\t},\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst { isPressed, ...additionalProps } = props;\n\treturn (\n\t\t<Button\n\t\t\t{ ...additionalProps }\n\t\t\taria-pressed={ isPressed }\n\t\t\tref={ forwardedRef }\n\t\t/>\n\t);\n}\n\nconst OptionAsButton = forwardRef( UnforwardedOptionAsButton );\n\nfunction UnforwardedOptionAsOption(\n\tprops: {\n\t\tid: string;\n\t\tclassName?: string;\n\t\tisSelected?: boolean;\n\t},\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst { id, isSelected, ...additionalProps } = props;\n\n\tconst { setActiveId, activeId } = useContext( CircularOptionPickerContext );\n\n\tuseEffect( () => {\n\t\tif ( isSelected && ! activeId ) {\n\t\t\t// The setTimeout call is necessary to make sure that this update\n\t\t\t// doesn't get overridden by `Composite`'s internal logic, which picks\n\t\t\t// an initial active item if one is not specifically set.\n\t\t\twindow.setTimeout( () => setActiveId?.( id ), 0 );\n\t\t}\n\t}, [ isSelected, setActiveId, activeId, id ] );\n\n\treturn (\n\t\t<Composite.Item\n\t\t\trender={\n\t\t\t\t<Button\n\t\t\t\t\t{ ...additionalProps }\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\taria-selected={ !! isSelected }\n\t\t\t\t\tref={ forwardedRef }\n\t\t\t\t/>\n\t\t\t}\n\t\t\tid={ id }\n\t\t/>\n\t);\n}\n\nconst OptionAsOption = forwardRef( UnforwardedOptionAsOption );\n\nexport function Option( {\n\tclassName,\n\tisSelected,\n\tselectedIconProps = {},\n\ttooltipText,\n\t...additionalProps\n}: OptionProps ) {\n\tconst { baseId, setActiveId } = useContext( CircularOptionPickerContext );\n\tconst id = useInstanceId(\n\t\tOption,\n\t\tbaseId || 'components-circular-option-picker__option'\n\t);\n\n\tconst commonProps = {\n\t\tid,\n\t\tclassName: 'components-circular-option-picker__option',\n\t\t__next40pxDefaultSize: true,\n\t\t...additionalProps,\n\t};\n\n\tconst isListbox = setActiveId !== undefined;\n\tconst optionControl = isListbox ? (\n\t\t<OptionAsOption { ...commonProps } isSelected={ isSelected } />\n\t) : (\n\t\t<OptionAsButton { ...commonProps } isPressed={ isSelected } />\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx(\n\t\t\t\tclassName,\n\t\t\t\t'components-circular-option-picker__option-wrapper'\n\t\t\t) }\n\t\t>\n\t\t\t{ tooltipText ? (\n\t\t\t\t<Tooltip text={ tooltipText }>{ optionControl }</Tooltip>\n\t\t\t) : (\n\t\t\t\toptionControl\n\t\t\t) }\n\t\t\t{ isSelected && <Icon icon={ check } { ...selectedIconProps } /> }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAMA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAKA,IAAAI,4BAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAR,sBAAA,CAAAC,OAAA;AAAiC,IAAAQ,WAAA,GAAAR,OAAA;AAnBjC;AACA;AACA;;AAIA;AACA;AACA;;AAKA;AACA;AACA;;AAOA,SAASS,yBAAyBA,CACjCC,KAIC,EACDC,YAAiC,EAChC;EACD,MAAM;IAAEC,SAAS;IAAE,GAAGC;EAAgB,CAAC,GAAGH,KAAK;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Y,CAAC,GAAG,IAAAE,mBAAU,EAAEC,wDAA4B,CAAC;EACzE,MAAML,EAAE,GAAG,IAAAmB,sBAAa,EACvBL,MAAM,EACNI,MAAM,IAAI,2CACX,CAAC;EAED,MAAME,WAAW,GAAG;IACnBpB,EAAE;IACFe,SAAS,EAAE,2CAA2C;IACtDM,qBAAqB,EAAE,IAAI;IAC3B,GAAG5B;EACJ,CAAC;EAED,MAAM6B,SAAS,GAAGpB,WAAW,KAAKqB,SAAS;EAC3C,MAAMC,aAAa,GAAGF,SAAS,gBAC9B,IAAAlC,WAAA,CAAAM,GAAA,EAACmB,cAAc;IAAA,GAAMO,WAAW;IAAGnB,UAAU,EAAGA;EAAY,CAAE,CAAC,gBAE/D,IAAAb,WAAA,CAAAM,GAAA,EAACG,cAAc;IAAA,GAAMuB,WAAW;IAAG5B,SAAS,EAAGS;EAAY,CAAE,CAC7D;EAED,oBACC,IAAAb,WAAA,CAAAqC,IAAA;IACCV,SAAS,EAAG,IAAAW,aAAI,EACfX,SAAS,EACT,mDACD,CAAG;IAAAY,QAAA,GAEDV,WAAW,gBACZ,IAAA7B,WAAA,CAAAM,GAAA,EAACP,QAAA,CAAAQ,OAAO;MAACiC,IAAI,EAAGX,WAAa;MAAAU,QAAA,EAAGH;IAAa,CAAW,CAAC,GAEzDA,aACA,EACCvB,UAAU,iBAAI,IAAAb,WAAA,CAAAM,GAAA,EAACX,MAAA,CAAA8C,IAAI;MAACC,IAAI,EAAGC,YAAO;MAAA,GAAMf;IAAiB,CAAI,CAAC;EAAA,CAC5D,CAAC;AAER","ignoreList":[]}
1
+ {"version":3,"names":["_clsx","_interopRequireDefault","require","_compose","_element","_icons","_circularOptionPickerContext","_button","_composite","_jsxRuntime","UnforwardedOptionAsButton","props","forwardedRef","isPressed","label","additionalProps","jsx","default","ref","OptionAsButton","forwardRef","UnforwardedOptionAsOption","id","isSelected","setActiveId","activeId","useContext","CircularOptionPickerContext","useEffect","window","setTimeout","Composite","Item","render","role","OptionAsOption","Option","className","selectedIconProps","tooltipText","baseId","useInstanceId","commonProps","__next40pxDefaultSize","isListbox","undefined","optionControl","jsxs","clsx","children","Icon","icon","check"],"sources":["@wordpress/components/src/circular-option-picker/circular-option-picker-option.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef, useContext, useEffect } from '@wordpress/element';\nimport { Icon, check } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { CircularOptionPickerContext } from './circular-option-picker-context';\nimport Button from '../button';\nimport { Composite } from '../composite';\nimport type { OptionProps } from './types';\n\nfunction UnforwardedOptionAsButton(\n\tprops: {\n\t\tid?: string;\n\t\tclassName?: string;\n\t\tisPressed?: boolean;\n\t\tlabel?: string;\n\t},\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst { isPressed, label, ...additionalProps } = props;\n\treturn (\n\t\t<Button\n\t\t\t{ ...additionalProps }\n\t\t\taria-pressed={ isPressed }\n\t\t\tref={ forwardedRef }\n\t\t\tlabel={ label }\n\t\t/>\n\t);\n}\n\nconst OptionAsButton = forwardRef( UnforwardedOptionAsButton );\n\nfunction UnforwardedOptionAsOption(\n\tprops: {\n\t\tid: string;\n\t\tclassName?: string;\n\t\tisSelected?: boolean;\n\t\tlabel?: string;\n\t},\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst { id, isSelected, label, ...additionalProps } = props;\n\n\tconst { setActiveId, activeId } = useContext( CircularOptionPickerContext );\n\n\tuseEffect( () => {\n\t\tif ( isSelected && ! activeId ) {\n\t\t\t// The setTimeout call is necessary to make sure that this update\n\t\t\t// doesn't get overridden by `Composite`'s internal logic, which picks\n\t\t\t// an initial active item if one is not specifically set.\n\t\t\twindow.setTimeout( () => setActiveId?.( id ), 0 );\n\t\t}\n\t}, [ isSelected, setActiveId, activeId, id ] );\n\n\treturn (\n\t\t<Composite.Item\n\t\t\trender={\n\t\t\t\t<Button\n\t\t\t\t\t{ ...additionalProps }\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\taria-selected={ !! isSelected }\n\t\t\t\t\tref={ forwardedRef }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t/>\n\t\t\t}\n\t\t\tid={ id }\n\t\t/>\n\t);\n}\n\nconst OptionAsOption = forwardRef( UnforwardedOptionAsOption );\n\nexport function Option( {\n\tclassName,\n\tisSelected,\n\tselectedIconProps = {},\n\ttooltipText,\n\t...additionalProps\n}: OptionProps ) {\n\tconst { baseId, setActiveId } = useContext( CircularOptionPickerContext );\n\tconst id = useInstanceId(\n\t\tOption,\n\t\tbaseId || 'components-circular-option-picker__option'\n\t);\n\n\tconst commonProps = {\n\t\tid,\n\t\tclassName: 'components-circular-option-picker__option',\n\t\t__next40pxDefaultSize: true,\n\t\t...additionalProps,\n\t};\n\n\tconst isListbox = setActiveId !== undefined;\n\tconst optionControl = isListbox ? (\n\t\t<OptionAsOption\n\t\t\t{ ...commonProps }\n\t\t\tlabel={ tooltipText }\n\t\t\tisSelected={ isSelected }\n\t\t/>\n\t) : (\n\t\t<OptionAsButton\n\t\t\t{ ...commonProps }\n\t\t\tlabel={ tooltipText }\n\t\t\tisPressed={ isSelected }\n\t\t/>\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx(\n\t\t\t\tclassName,\n\t\t\t\t'components-circular-option-picker__option-wrapper'\n\t\t\t) }\n\t\t>\n\t\t\t{ optionControl }\n\t\t\t{ isSelected && <Icon icon={ check } { ...selectedIconProps } /> }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAMA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAKA,IAAAI,4BAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAN,sBAAA,CAAAC,O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@@ var _jsxRuntime = require("react/jsx-runtime");
51
51
  * style={ { backgroundColor: color, color } }
52
52
  * isSelected={ index === currentColor }
53
53
  * onClick={ () => setCurrentColor( index ) }
54
- * aria-label={ name }
55
54
  * />
56
55
  * );
57
56
  * } ) }
@@ -1 +1 @@
1
- {"version":3,"names":["_clsx","_interopRequireDefault","require","_compose","_i18n","_element","_circularOptionPickerContext","_composite","_circularOptionPickerOption","_circularOptionPickerOptionGroup","_circularOptionPickerActions","_jsxRuntime","ListboxCircularOptionPicker","props","actions","options","baseId","className","loop","children","additionalProps","activeId","setActiveId","useState","undefined","contextValue","useMemo","jsx","jsxs","CircularOptionPickerContext","Provider","value","Composite","id","focusLoop","rtl","isRTL","role","ButtonsCircularOptionPicker","CircularOptionPicker","asButtons","actionsProp","optionsProp","useInstanceId","OptionPickerImplementation","clsx","Option","OptionGroup","ButtonAction","DropdownLinkAction","_default","exports","default"],"sources":["@wordpress/components/src/circular-option-picker/circular-option-picker.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { CircularOptionPickerContext } from './circular-option-picker-context';\nimport { Composite } from '../composite';\nimport type {\n\tCircularOptionPickerProps,\n\tListboxCircularOptionPickerProps,\n\tButtonsCircularOptionPickerProps,\n} from './types';\nimport { Option } from './circular-option-picker-option';\nimport { OptionGroup } from './circular-option-picker-option-group';\nimport {\n\tButtonAction,\n\tDropdownLinkAction,\n} from './circular-option-picker-actions';\n\n/**\n *`CircularOptionPicker` is a component that displays a set of options as circular buttons.\n *\n * ```jsx\n * import { CircularOptionPicker } from '../circular-option-picker';\n * import { useState } from '@wordpress/element';\n *\n * const Example = () => {\n * \tconst [ currentColor, setCurrentColor ] = useState();\n * \tconst colors = [\n * \t\t{ color: '#f00', name: 'Red' },\n * \t\t{ color: '#0f0', name: 'Green' },\n * \t\t{ color: '#00f', name: 'Blue' },\n * \t];\n * \tconst colorOptions = (\n * \t\t<>\n * \t\t\t{ colors.map( ( { color, name }, index ) => {\n * \t\t\t\treturn (\n * \t\t\t\t\t<CircularOptionPicker.Option\n * \t\t\t\t\t\tkey={ `${ color }-${ index }` }\n * \t\t\t\t\t\ttooltipText={ name }\n * \t\t\t\t\t\tstyle={ { backgroundColor: color, color } }\n * \t\t\t\t\t\tisSelected={ index === currentColor }\n * \t\t\t\t\t\tonClick={ () => setCurrentColor( index ) }\n * \t\t\t\t\t\taria-label={ name }\n * \t\t\t\t\t/>\n * \t\t\t\t);\n * \t\t\t} ) }\n * \t\t</>\n * \t);\n * \treturn (\n * \t\t<CircularOptionPicker\n * \t\t\t\toptions={ colorOptions }\n * \t\t\t\tactions={\n * \t\t\t\t\t<CircularOptionPicker.ButtonAction\n * \t\t\t\t\t\tonClick={ () => setCurrentColor( undefined ) }\n * \t\t\t\t\t>\n * \t\t\t\t\t\t{ 'Clear' }\n * \t\t\t\t\t</CircularOptionPicker.ButtonAction>\n * \t\t\t\t}\n * \t\t\t/>\n * \t);\n * };\n * ```\n */\n\nfunction ListboxCircularOptionPicker(\n\tprops: ListboxCircularOptionPickerProps\n) {\n\tconst {\n\t\tactions,\n\t\toptions,\n\t\tbaseId,\n\t\tclassName,\n\t\tloop = true,\n\t\tchildren,\n\t\t...additionalProps\n\t} = props;\n\n\tconst [ activeId, setActiveId ] = useState< string | null | undefined >(\n\t\tundefined\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tbaseId,\n\t\t\tactiveId,\n\t\t\tsetActiveId,\n\t\t} ),\n\t\t[ baseId, activeId, setActiveId ]\n\t);\n\n\treturn (\n\t\t<div className={ className }>\n\t\t\t<CircularOptionPickerContext.Provider value={ contextValue }>\n\t\t\t\t<Composite\n\t\t\t\t\t{ ...additionalProps }\n\t\t\t\t\tid={ baseId }\n\t\t\t\t\tfocusLoop={ loop }\n\t\t\t\t\trtl={ isRTL() }\n\t\t\t\t\trole=\"listbox\"\n\t\t\t\t\tactiveId={ activeId }\n\t\t\t\t\tsetActiveId={ setActiveId }\n\t\t\t\t>\n\t\t\t\t\t{ options }\n\t\t\t\t</Composite>\n\t\t\t\t{ children }\n\t\t\t\t{ actions }\n\t\t\t</CircularOptionPickerContext.Provider>\n\t\t</div>\n\t);\n}\n\nfunction ButtonsCircularOptionPicker(\n\tprops: ButtonsCircularOptionPickerProps\n) {\n\tconst { actions, options, children, baseId, ...additionalProps } = props;\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tbaseId,\n\t\t} ),\n\t\t[ baseId ]\n\t);\n\n\treturn (\n\t\t<div { ...additionalProps } id={ baseId }>\n\t\t\t<CircularOptionPickerContext.Provider value={ contextValue }>\n\t\t\t\t{ options }\n\t\t\t\t{ children }\n\t\t\t\t{ actions }\n\t\t\t</CircularOptionPickerContext.Provider>\n\t\t</div>\n\t);\n}\n\nfunction CircularOptionPicker( props: CircularOptionPickerProps ) {\n\tconst {\n\t\tasButtons,\n\t\tactions: actionsProp,\n\t\toptions: optionsProp,\n\t\tchildren,\n\t\tclassName,\n\t\t...additionalProps\n\t} = props;\n\n\tconst baseId = useInstanceId(\n\t\tCircularOptionPicker,\n\t\t'components-circular-option-picker',\n\t\tadditionalProps.id\n\t);\n\n\tconst OptionPickerImplementation = asButtons\n\t\t? ButtonsCircularOptionPicker\n\t\t: ListboxCircularOptionPicker;\n\n\tconst actions = actionsProp ? (\n\t\t<div className=\"components-circular-option-picker__custom-clear-wrapper\">\n\t\t\t{ actionsProp }\n\t\t</div>\n\t) : undefined;\n\n\tconst options = (\n\t\t<div className=\"components-circular-option-picker__swatches\">\n\t\t\t{ optionsProp }\n\t\t</div>\n\t);\n\n\treturn (\n\t\t<OptionPickerImplementation\n\t\t\t{ ...additionalProps }\n\t\t\tbaseId={ baseId }\n\t\t\tclassName={ clsx( 'components-circular-option-picker', className ) }\n\t\t\tactions={ actions }\n\t\t\toptions={ options }\n\t\t>\n\t\t\t{ children }\n\t\t</OptionPickerImplementation>\n\t);\n}\n\nCircularOptionPicker.Option = Option;\nCircularOptionPicker.OptionGroup = OptionGroup;\nCircularOptionPicker.ButtonAction = ButtonAction;\nCircularOptionPicker.DropdownLinkAction = DropdownLinkAction;\n\nexport default CircularOptionPicker;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAKA,IAAAI,4BAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AAMA,IAAAM,2BAAA,GAAAN,OAAA;AACA,IAAAO,gCAAA,GAAAP,OAAA;AACA,IAAAQ,4BAAA,GAAAR,OAAA;AAG0C,IAAAS,WAAA,GAAAT,OAAA;AA3B1C;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAEA,SAASU,2BAA2BA,CACnCC,KAAuC,EACtC;EACD,MAAM;IACLC,OAAO;IACPC,OAAO;IACPC,MAAM;IACNC,SAAS;IACTC,IAAI,GAAG,IAAI;IACXC,QAAQ;IACR,GAAGC;EACJ,CAAC,GAAGP,KAAK;EAET,MAAM,CAAEQ,QAAQ,EAAEC,WAAW,CAAE,GAAG,IAAAC,iBAAQ,EACzCC,SACD,CAAC;EAED,MAAMC,YAAY,GAAG,IAAAC,gBAAO,EAC3B,OAAQ;IACPV,MAAM;IACNK,QAAQ;IACRC;EACD,CAAC,CAAE,EACH,CAAEN,MA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O,EAAE2B,WAAW;IACpB1B,OAAO,EAAE2B,WAAW;IACpBvB,QAAQ;IACRF,SAAS;IACT,GAAGG;EACJ,CAAC,GAAGP,KAAK;EAET,MAAMG,MAAM,GAAG,IAAA2B,sBAAa,EAC3BJ,oBAAoB,EACpB,mCAAmC,EACnCnB,eAAe,CAACa,EACjB,CAAC;EAED,MAAMW,0BAA0B,GAAGJ,SAAS,GACzCF,2BAA2B,GAC3B1B,2BAA2B;EAE9B,MAAME,OAAO,GAAG2B,WAAW,gBAC1B,IAAA9B,WAAA,CAAAgB,GAAA;IAAKV,SAAS,EAAC,yDAAyD;IAAAE,QAAA,EACrEsB;EAAW,CACT,CAAC,GACHjB,SAAS;EAEb,MAAMT,OAAO,gBACZ,IAAAJ,WAAA,CAAAgB,GAAA;IAAKV,SAAS,EAAC,6CAA6C;IAAAE,QAAA,EACzDuB;EAAW,CACT,CACL;EAED,oBACC,IAAA/B,WAAA,CAAAgB,GAAA,EAACiB,0BAA0B;IAAA,GACrBxB,eAAe;IACpBJ,MAAM,EAAGA,MAAQ;IACjBC,SAAS,EAAG,IAAA4B,aAAI,EAAE,mCAAmC,EAAE5B,SAAU,CAAG;IACpEH,OAAO,EAAGA,OAAS;IACnBC,OAAO,EAAGA,OAAS;IAAAI,QAAA,EAEjBA;EAAQ,CACiB,CAAC;AAE/B;AAEAoB,oBAAoB,CAACO,MAAM,GAAGA,kCAAM;AACpCP,oBAAoB,CAACQ,WAAW,GAAGA,4CAAW;AAC9CR,oBAAoB,CAACS,YAAY,GAAGA,yCAAY;AAChDT,oBAAoB,CAACU,kBAAkB,GAAGA,+CAAkB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAE9Cb,oBAAoB","ignoreList":[]}
1
+ {"version":3,"names":["_clsx","_interopRequireDefault","require","_compose","_i18n","_element","_circularOptionPickerContext","_composite","_circularOptionPickerOption","_circularOptionPickerOptionGroup","_circularOptionPickerActions","_jsxRuntime","ListboxCircularOptionPicker","props","actions","options","baseId","className","loop","children","additionalProps","activeId","setActiveId","useState","undefined","contextValue","useMemo","jsx","jsxs","CircularOptionPickerContext","Provider","value","Composite","id","focusLoop","rtl","isRTL","role","ButtonsCircularOptionPicker","CircularOptionPicker","asButtons","actionsProp","optionsProp","useInstanceId","OptionPickerImplementation","clsx","Option","OptionGroup","ButtonAction","DropdownLinkAction","_default","exports","default"],"sources":["@wordpress/components/src/circular-option-picker/circular-option-picker.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { CircularOptionPickerContext } from './circular-option-picker-context';\nimport { Composite } from '../composite';\nimport type {\n\tCircularOptionPickerProps,\n\tListboxCircularOptionPickerProps,\n\tButtonsCircularOptionPickerProps,\n} from './types';\nimport { Option } from './circular-option-picker-option';\nimport { OptionGroup } from './circular-option-picker-option-group';\nimport {\n\tButtonAction,\n\tDropdownLinkAction,\n} from './circular-option-picker-actions';\n\n/**\n *`CircularOptionPicker` is a component that displays a set of options as circular buttons.\n *\n * ```jsx\n * import { CircularOptionPicker } from '../circular-option-picker';\n * import { useState } from '@wordpress/element';\n *\n * const Example = () => {\n * \tconst [ currentColor, setCurrentColor ] = useState();\n * \tconst colors = [\n * \t\t{ color: '#f00', name: 'Red' },\n * \t\t{ color: '#0f0', name: 'Green' },\n * \t\t{ color: '#00f', name: 'Blue' },\n * \t];\n * \tconst colorOptions = (\n * \t\t<>\n * \t\t\t{ colors.map( ( { color, name }, index ) => {\n * \t\t\t\treturn (\n * \t\t\t\t\t<CircularOptionPicker.Option\n * \t\t\t\t\t\tkey={ `${ color }-${ index }` }\n * \t\t\t\t\t\ttooltipText={ name }\n * \t\t\t\t\t\tstyle={ { backgroundColor: color, color } }\n * \t\t\t\t\t\tisSelected={ index === currentColor }\n * \t\t\t\t\t\tonClick={ () => setCurrentColor( index ) }\n * \t\t\t\t\t/>\n * \t\t\t\t);\n * \t\t\t} ) }\n * \t\t</>\n * \t);\n * \treturn (\n * \t\t<CircularOptionPicker\n * \t\t\t\toptions={ colorOptions }\n * \t\t\t\tactions={\n * \t\t\t\t\t<CircularOptionPicker.ButtonAction\n * \t\t\t\t\t\tonClick={ () => setCurrentColor( undefined ) }\n * \t\t\t\t\t>\n * \t\t\t\t\t\t{ 'Clear' }\n * \t\t\t\t\t</CircularOptionPicker.ButtonAction>\n * \t\t\t\t}\n * \t\t\t/>\n * \t);\n * };\n * ```\n */\n\nfunction ListboxCircularOptionPicker(\n\tprops: ListboxCircularOptionPickerProps\n) {\n\tconst {\n\t\tactions,\n\t\toptions,\n\t\tbaseId,\n\t\tclassName,\n\t\tloop = true,\n\t\tchildren,\n\t\t...additionalProps\n\t} = props;\n\n\tconst [ activeId, setActiveId ] = useState< string | null | undefined >(\n\t\tundefined\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tbaseId,\n\t\t\tactiveId,\n\t\t\tsetActiveId,\n\t\t} ),\n\t\t[ baseId, activeId, setActiveId ]\n\t);\n\n\treturn (\n\t\t<div className={ className }>\n\t\t\t<CircularOptionPickerContext.Provider value={ contextValue }>\n\t\t\t\t<Composite\n\t\t\t\t\t{ ...additionalProps }\n\t\t\t\t\tid={ baseId }\n\t\t\t\t\tfocusLoop={ loop }\n\t\t\t\t\trtl={ isRTL() }\n\t\t\t\t\trole=\"listbox\"\n\t\t\t\t\tactiveId={ activeId }\n\t\t\t\t\tsetActiveId={ setActiveId }\n\t\t\t\t>\n\t\t\t\t\t{ options }\n\t\t\t\t</Composite>\n\t\t\t\t{ children }\n\t\t\t\t{ actions }\n\t\t\t</CircularOptionPickerContext.Provider>\n\t\t</div>\n\t);\n}\n\nfunction ButtonsCircularOptionPicker(\n\tprops: ButtonsCircularOptionPickerProps\n) {\n\tconst { actions, options, children, baseId, ...additionalProps } = props;\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tbaseId,\n\t\t} ),\n\t\t[ baseId ]\n\t);\n\n\treturn (\n\t\t<div { ...additionalProps } id={ baseId }>\n\t\t\t<CircularOptionPickerContext.Provider value={ contextValue }>\n\t\t\t\t{ options }\n\t\t\t\t{ children }\n\t\t\t\t{ actions }\n\t\t\t</CircularOptionPickerContext.Provider>\n\t\t</div>\n\t);\n}\n\nfunction CircularOptionPicker( props: CircularOptionPickerProps ) {\n\tconst {\n\t\tasButtons,\n\t\tactions: actionsProp,\n\t\toptions: optionsProp,\n\t\tchildren,\n\t\tclassName,\n\t\t...additionalProps\n\t} = props;\n\n\tconst baseId = useInstanceId(\n\t\tCircularOptionPicker,\n\t\t'components-circular-option-picker',\n\t\tadditionalProps.id\n\t);\n\n\tconst OptionPickerImplementation = asButtons\n\t\t? ButtonsCircularOptionPicker\n\t\t: ListboxCircularOptionPicker;\n\n\tconst actions = actionsProp ? (\n\t\t<div className=\"components-circular-option-picker__custom-clear-wrapper\">\n\t\t\t{ actionsProp }\n\t\t</div>\n\t) : undefined;\n\n\tconst options = (\n\t\t<div className=\"components-circular-option-picker__swatches\">\n\t\t\t{ optionsProp }\n\t\t</div>\n\t);\n\n\treturn (\n\t\t<OptionPickerImplementation\n\t\t\t{ ...additionalProps }\n\t\t\tbaseId={ baseId }\n\t\t\tclassName={ clsx( 'components-circular-option-picker', className ) }\n\t\t\tactions={ actions }\n\t\t\toptions={ options }\n\t\t>\n\t\t\t{ children }\n\t\t</OptionPickerImplementation>\n\t);\n}\n\nCircularOptionPicker.Option = Option;\nCircularOptionPicker.OptionGroup = OptionGroup;\nCircularOptionPicker.ButtonAction = ButtonAction;\nCircularOptionPicker.DropdownLinkAction = DropdownLinkAction;\n\nexport default CircularOptionPicker;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;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KV,SAAS,EAAC,yDAAyD;IAAAE,QAAA,EACrEsB;EAAW,CACT,CAAC,GACHjB,SAAS;EAEb,MAAMT,OAAO,gBACZ,IAAAJ,WAAA,CAAAgB,GAAA;IAAKV,SAAS,EAAC,6CAA6C;IAAAE,QAAA,EACzDuB;EAAW,CACT,CACL;EAED,oBACC,IAAA/B,WAAA,CAAAgB,GAAA,EAACiB,0BAA0B;IAAA,GACrBxB,eAAe;IACpBJ,MAAM,EAAGA,MAAQ;IACjBC,SAAS,EAAG,IAAA4B,aAAI,EAAE,mCAAmC,EAAE5B,SAAU,CAAG;IACpEH,OAAO,EAAGA,OAAS;IACnBC,OAAO,EAAGA,OAAS;IAAAI,QAAA,EAEjBA;EAAQ,CACiB,CAAC;AAE/B;AAEAoB,oBAAoB,CAACO,MAAM,GAAGA,kCAAM;AACpCP,oBAAoB,CAACQ,WAAW,GAAGA,4CAAW;AAC9CR,oBAAoB,CAACS,YAAY,GAAGA,yCAAY;AAChDT,oBAAoB,CAACU,kBAAkB,GAAGA,+CAAkB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAE9Cb,oBAAoB","ignoreList":[]}
@@ -64,12 +64,7 @@ function SinglePalette({
64
64
  backgroundColor: color,
65
65
  color
66
66
  },
67
- onClick: isSelected ? clearColor : () => onChange(color, index),
68
- "aria-label": name ?
69
- // translators: %s: The name of the color e.g: "vivid red".
70
- (0, _i18n.sprintf)((0, _i18n.__)('Color: %s'), name) :
71
- // translators: %s: color hex code e.g: "#f00".
72
- (0, _i18n.sprintf)((0, _i18n.__)('Color code: %s'), color)
67
+ onClick: isSelected ? clearColor : () => onChange(color, index)
73
68
  }, `${color}-${index}`);
74
69
  });
75
70
  }, [colors, value, onChange, clearColor]);