@wordpress/components 25.12.0 → 25.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/build/angle-picker-control/index.js +0 -1
  3. package/build/angle-picker-control/index.js.map +1 -1
  4. package/build/custom-select-control-v2/index.js +87 -0
  5. package/build/custom-select-control-v2/index.js.map +1 -0
  6. package/build/custom-select-control-v2/styles.js +85 -0
  7. package/build/custom-select-control-v2/styles.js.map +1 -0
  8. package/build/custom-select-control-v2/types.js +6 -0
  9. package/build/custom-select-control-v2/types.js.map +1 -0
  10. package/build/dropdown-menu-v2-ariakit/index.js +49 -20
  11. package/build/dropdown-menu-v2-ariakit/index.js.map +1 -1
  12. package/build/dropdown-menu-v2-ariakit/styles.js +82 -59
  13. package/build/dropdown-menu-v2-ariakit/styles.js.map +1 -1
  14. package/build/dropdown-menu-v2-ariakit/types.js.map +1 -1
  15. package/build/form-token-field/index.js +6 -2
  16. package/build/form-token-field/index.js.map +1 -1
  17. package/build/form-token-field/token-input.js.map +1 -1
  18. package/build/form-token-field/types.js.map +1 -1
  19. package/build/heading/hook.js +6 -3
  20. package/build/heading/hook.js.map +1 -1
  21. package/build/heading/types.js.map +1 -1
  22. package/build/mobile/utils/alignments.native.js +1 -1
  23. package/build/mobile/utils/alignments.native.js.map +1 -1
  24. package/build/private-apis.js +3 -2
  25. package/build/private-apis.js.map +1 -1
  26. package/build/slot-fill/types.js.map +1 -1
  27. package/build/tabs/index.js +6 -4
  28. package/build/tabs/index.js.map +1 -1
  29. package/build/tabs/tab.js +2 -2
  30. package/build/tabs/tab.js.map +1 -1
  31. package/build/tabs/tabpanel.js +1 -1
  32. package/build/tabs/tabpanel.js.map +1 -1
  33. package/build/text/types.js.map +1 -1
  34. package/build/tools-panel/tools-panel-item/hook.js +5 -1
  35. package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
  36. package/build-module/angle-picker-control/index.js +0 -1
  37. package/build-module/angle-picker-control/index.js.map +1 -1
  38. package/build-module/custom-select-control-v2/index.js +74 -0
  39. package/build-module/custom-select-control-v2/index.js.map +1 -0
  40. package/build-module/custom-select-control-v2/styles.js +71 -0
  41. package/build-module/custom-select-control-v2/styles.js.map +1 -0
  42. package/build-module/custom-select-control-v2/types.js +2 -0
  43. package/build-module/custom-select-control-v2/types.js.map +1 -0
  44. package/build-module/dropdown-menu-v2-ariakit/index.js +46 -18
  45. package/build-module/dropdown-menu-v2-ariakit/index.js.map +1 -1
  46. package/build-module/dropdown-menu-v2-ariakit/styles.js +69 -40
  47. package/build-module/dropdown-menu-v2-ariakit/styles.js.map +1 -1
  48. package/build-module/dropdown-menu-v2-ariakit/types.js.map +1 -1
  49. package/build-module/form-token-field/index.js +6 -2
  50. package/build-module/form-token-field/index.js.map +1 -1
  51. package/build-module/form-token-field/token-input.js.map +1 -1
  52. package/build-module/form-token-field/types.js.map +1 -1
  53. package/build-module/heading/hook.js +6 -3
  54. package/build-module/heading/hook.js.map +1 -1
  55. package/build-module/heading/types.js.map +1 -1
  56. package/build-module/mobile/utils/alignments.native.js +1 -1
  57. package/build-module/mobile/utils/alignments.native.js.map +1 -1
  58. package/build-module/private-apis.js +4 -3
  59. package/build-module/private-apis.js.map +1 -1
  60. package/build-module/slot-fill/types.js.map +1 -1
  61. package/build-module/tabs/index.js +7 -5
  62. package/build-module/tabs/index.js.map +1 -1
  63. package/build-module/tabs/tab.js +4 -4
  64. package/build-module/tabs/tab.js.map +1 -1
  65. package/build-module/tabs/tabpanel.js +3 -3
  66. package/build-module/tabs/tabpanel.js.map +1 -1
  67. package/build-module/text/types.js.map +1 -1
  68. package/build-module/tools-panel/tools-panel-item/hook.js +6 -2
  69. package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
  70. package/build-style/style-rtl.css +31 -5
  71. package/build-style/style.css +31 -5
  72. package/build-types/angle-picker-control/index.d.ts.map +1 -1
  73. package/build-types/box-control/stories/index.story.d.ts +1944 -0
  74. package/build-types/box-control/stories/index.story.d.ts.map +1 -0
  75. package/build-types/color-palette/styles.d.ts +4 -1
  76. package/build-types/color-palette/styles.d.ts.map +1 -1
  77. package/build-types/custom-select-control-v2/index.d.ts +6 -0
  78. package/build-types/custom-select-control-v2/index.d.ts.map +1 -0
  79. package/build-types/custom-select-control-v2/stories/index.story.d.ts +19 -0
  80. package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +1 -0
  81. package/build-types/custom-select-control-v2/styles.d.ts +47 -0
  82. package/build-types/custom-select-control-v2/styles.d.ts.map +1 -0
  83. package/build-types/custom-select-control-v2/types.d.ts +57 -0
  84. package/build-types/custom-select-control-v2/types.d.ts.map +1 -0
  85. package/build-types/date-time/date/styles.d.ts +4 -1
  86. package/build-types/date-time/date/styles.d.ts.map +1 -1
  87. package/build-types/dropdown-menu-v2-ariakit/index.d.ts +11 -2
  88. package/build-types/dropdown-menu-v2-ariakit/index.d.ts.map +1 -1
  89. package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts.map +1 -1
  90. package/build-types/dropdown-menu-v2-ariakit/styles.d.ts +26 -18
  91. package/build-types/dropdown-menu-v2-ariakit/styles.d.ts.map +1 -1
  92. package/build-types/dropdown-menu-v2-ariakit/types.d.ts +0 -6
  93. package/build-types/dropdown-menu-v2-ariakit/types.d.ts.map +1 -1
  94. package/build-types/form-token-field/index.d.ts.map +1 -1
  95. package/build-types/form-token-field/token-input.d.ts.map +1 -1
  96. package/build-types/form-token-field/types.d.ts +1 -1
  97. package/build-types/form-token-field/types.d.ts.map +1 -1
  98. package/build-types/heading/component.d.ts +4 -1
  99. package/build-types/heading/component.d.ts.map +1 -1
  100. package/build-types/heading/hook.d.ts.map +1 -1
  101. package/build-types/heading/types.d.ts +20 -1
  102. package/build-types/heading/types.d.ts.map +1 -1
  103. package/build-types/navigation/styles/navigation-styles.d.ts +4 -1
  104. package/build-types/navigation/styles/navigation-styles.d.ts.map +1 -1
  105. package/build-types/palette-edit/styles.d.ts +4 -1
  106. package/build-types/palette-edit/styles.d.ts.map +1 -1
  107. package/build-types/private-apis.d.ts.map +1 -1
  108. package/build-types/slot-fill/bubbles-virtually/slot.d.ts +1 -1
  109. package/build-types/slot-fill/types.d.ts +16 -6
  110. package/build-types/slot-fill/types.d.ts.map +1 -1
  111. package/build-types/tabs/index.d.ts +1 -0
  112. package/build-types/tabs/index.d.ts.map +1 -1
  113. package/build-types/tabs/stories/index.story.d.ts.map +1 -1
  114. package/build-types/text/types.d.ts +15 -2
  115. package/build-types/text/types.d.ts.map +1 -1
  116. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  117. package/package.json +19 -19
  118. package/src/angle-picker-control/index.tsx +0 -1
  119. package/src/box-control/stories/index.story.tsx +82 -0
  120. package/src/button/style.scss +10 -2
  121. package/src/combobox-control/README.md +1 -3
  122. package/src/custom-select-control-v2/README.md +73 -0
  123. package/src/custom-select-control-v2/index.tsx +99 -0
  124. package/src/custom-select-control-v2/stories/index.story.tsx +149 -0
  125. package/src/custom-select-control-v2/styles.ts +76 -0
  126. package/src/custom-select-control-v2/types.ts +63 -0
  127. package/src/dropdown-menu-v2-ariakit/README.md +19 -5
  128. package/src/dropdown-menu-v2-ariakit/index.tsx +85 -36
  129. package/src/dropdown-menu-v2-ariakit/stories/index.story.tsx +204 -90
  130. package/src/dropdown-menu-v2-ariakit/styles.ts +153 -117
  131. package/src/dropdown-menu-v2-ariakit/test/index.tsx +5 -10
  132. package/src/dropdown-menu-v2-ariakit/types.ts +0 -7
  133. package/src/form-toggle/style.scss +37 -7
  134. package/src/form-token-field/index.tsx +11 -3
  135. package/src/form-token-field/token-input.tsx +1 -3
  136. package/src/form-token-field/types.ts +1 -0
  137. package/src/heading/README.md +6 -1
  138. package/src/heading/hook.ts +6 -3
  139. package/src/heading/types.ts +23 -1
  140. package/src/mobile/utils/alignments.native.js +1 -0
  141. package/src/navigable-container/README.md +1 -1
  142. package/src/private-apis.ts +4 -2
  143. package/src/slot-fill/README.md +1 -1
  144. package/src/slot-fill/types.ts +18 -6
  145. package/src/tabs/index.tsx +12 -2
  146. package/src/tabs/stories/index.story.tsx +8 -0
  147. package/src/tabs/tab.tsx +4 -4
  148. package/src/tabs/tabpanel.tsx +3 -3
  149. package/src/tabs/test/index.tsx +19 -0
  150. package/src/text/README.md +5 -1
  151. package/src/text/types.ts +15 -2
  152. package/src/toggle-control/README.md +2 -2
  153. package/src/tools-panel/tools-panel-item/hook.ts +11 -2
  154. package/tsconfig.tsbuildinfo +1 -1
  155. package/src/box-control/stories/index.story.js +0 -75
@@ -0,0 +1,63 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ // eslint-disable-next-line no-restricted-imports
5
+ import type * as Ariakit from '@ariakit/react';
6
+
7
+ export type CustomSelectContext =
8
+ | {
9
+ /**
10
+ * The store object returned by Ariakit's `useSelectStore` hook.
11
+ */
12
+ store: Ariakit.SelectStore;
13
+ }
14
+ | undefined;
15
+
16
+ export type CustomSelectProps = {
17
+ /**
18
+ * The child elements. This should be composed of CustomSelectItem components.
19
+ */
20
+ children: React.ReactNode;
21
+ /**
22
+ * An optional default value for the control. If left `undefined`, the first
23
+ * non-disabled item will be used.
24
+ */
25
+ defaultValue?: string | string[];
26
+ /**
27
+ * Label for the control.
28
+ */
29
+ label: string;
30
+ /**
31
+ * A function that receives the new value of the input.
32
+ */
33
+ onChange?: ( newValue: string | string[] ) => void;
34
+ /**
35
+ * Can be used to render select UI with custom styled values.
36
+ */
37
+ renderSelectedValue?: (
38
+ selectedValue: string | string[]
39
+ ) => React.ReactNode;
40
+ /**
41
+ * The size of the control.
42
+ *
43
+ * @default 'default'
44
+ */
45
+ size?: 'default' | 'small';
46
+ /**
47
+ * Can be used to externally control the value of the control.
48
+ */
49
+ value?: string | string[];
50
+ };
51
+
52
+ export type CustomSelectItemProps = {
53
+ /**
54
+ * The value of the select item. This will be used as the children if
55
+ * children are left `undefined`.
56
+ */
57
+ value: string;
58
+ /**
59
+ * The children to display for each select item. The `value` will be
60
+ * used if left `undefined`.
61
+ */
62
+ children?: React.ReactNode;
63
+ };
@@ -284,9 +284,9 @@ Event handler called when the checked radio menu item changes.
284
284
 
285
285
  - Required: no
286
286
 
287
- ### `DropdownMenuGroup`
287
+ ### `DropdownMenuItemLabel`
288
288
 
289
- Used to group menu items.
289
+ Used to render the menu item's label.
290
290
 
291
291
  #### Props
292
292
 
@@ -294,13 +294,27 @@ The component accepts the following props:
294
294
 
295
295
  ##### `children`: `React.ReactNode`
296
296
 
297
- The contents of the group.
297
+ The label contents.
298
+
299
+ - Required: yes
300
+
301
+ ### `DropdownMenuItemHelpText`
302
+
303
+ Used to render the menu item's help text.
304
+
305
+ #### Props
306
+
307
+ The component accepts the following props:
308
+
309
+ ##### `children`: `React.ReactNode`
310
+
311
+ The help text contents.
298
312
 
299
313
  - Required: yes
300
314
 
301
- ### `DropdownMenuGroupLabel`
315
+ ### `DropdownMenuGroup`
302
316
 
303
- Used to render a group label.
317
+ Used to group menu items.
304
318
 
305
319
  #### Props
306
320
 
@@ -30,7 +30,6 @@ import type {
30
30
  DropdownMenuContext as DropdownMenuContextType,
31
31
  DropdownMenuProps,
32
32
  DropdownMenuGroupProps,
33
- DropdownMenuGroupLabelProps,
34
33
  DropdownMenuItemProps,
35
34
  DropdownMenuCheckboxItemProps,
36
35
  DropdownMenuRadioItemProps,
@@ -55,16 +54,23 @@ export const DropdownMenuItem = forwardRef<
55
54
  <Styled.DropdownMenuItem
56
55
  ref={ ref }
57
56
  { ...props }
57
+ accessibleWhenDisabled
58
58
  hideOnClick={ hideOnClick }
59
59
  store={ dropdownMenuContext?.store }
60
60
  >
61
- { prefix && (
62
- <Styled.ItemPrefixWrapper>{ prefix }</Styled.ItemPrefixWrapper>
63
- ) }
64
- { children }
65
- { suffix && (
66
- <Styled.ItemSuffixWrapper>{ suffix }</Styled.ItemSuffixWrapper>
67
- ) }
61
+ <Styled.ItemPrefixWrapper>{ prefix }</Styled.ItemPrefixWrapper>
62
+
63
+ <Styled.DropdownMenuItemContentWrapper>
64
+ <Styled.DropdownMenuItemChildrenWrapper>
65
+ { children }
66
+ </Styled.DropdownMenuItemChildrenWrapper>
67
+
68
+ { suffix && (
69
+ <Styled.ItemSuffixWrapper>
70
+ { suffix }
71
+ </Styled.ItemSuffixWrapper>
72
+ ) }
73
+ </Styled.DropdownMenuItemContentWrapper>
68
74
  </Styled.DropdownMenuItem>
69
75
  );
70
76
  } );
@@ -82,20 +88,30 @@ export const DropdownMenuCheckboxItem = forwardRef<
82
88
  <Styled.DropdownMenuCheckboxItem
83
89
  ref={ ref }
84
90
  { ...props }
91
+ accessibleWhenDisabled
85
92
  hideOnClick={ hideOnClick }
86
93
  store={ dropdownMenuContext?.store }
87
94
  >
88
95
  <Ariakit.MenuItemCheck
89
96
  store={ dropdownMenuContext?.store }
90
97
  render={ <Styled.ItemPrefixWrapper /> }
98
+ // Override some ariakit inline styles
99
+ style={ { width: 'auto', height: 'auto' } }
91
100
  >
92
101
  <Icon icon={ check } size={ 24 } />
93
102
  </Ariakit.MenuItemCheck>
94
103
 
95
- { children }
96
- { suffix && (
97
- <Styled.ItemSuffixWrapper>{ suffix }</Styled.ItemSuffixWrapper>
98
- ) }
104
+ <Styled.DropdownMenuItemContentWrapper>
105
+ <Styled.DropdownMenuItemChildrenWrapper>
106
+ { children }
107
+ </Styled.DropdownMenuItemChildrenWrapper>
108
+
109
+ { suffix && (
110
+ <Styled.ItemSuffixWrapper>
111
+ { suffix }
112
+ </Styled.ItemSuffixWrapper>
113
+ ) }
114
+ </Styled.DropdownMenuItemContentWrapper>
99
115
  </Styled.DropdownMenuCheckboxItem>
100
116
  );
101
117
  } );
@@ -119,17 +135,30 @@ export const DropdownMenuRadioItem = forwardRef<
119
135
  <Styled.DropdownMenuRadioItem
120
136
  ref={ ref }
121
137
  { ...props }
138
+ accessibleWhenDisabled
122
139
  hideOnClick={ hideOnClick }
123
140
  store={ dropdownMenuContext?.store }
124
141
  >
125
142
  <Ariakit.MenuItemCheck
126
143
  store={ dropdownMenuContext?.store }
127
144
  render={ <Styled.ItemPrefixWrapper /> }
145
+ // Override some ariakit inline styles
146
+ style={ { width: 'auto', height: 'auto' } }
128
147
  >
129
148
  <Icon icon={ radioCheck } size={ 24 } />
130
149
  </Ariakit.MenuItemCheck>
131
- { children }
132
- { suffix }
150
+
151
+ <Styled.DropdownMenuItemContentWrapper>
152
+ <Styled.DropdownMenuItemChildrenWrapper>
153
+ { children }
154
+ </Styled.DropdownMenuItemChildrenWrapper>
155
+
156
+ { suffix && (
157
+ <Styled.ItemSuffixWrapper>
158
+ { suffix }
159
+ </Styled.ItemSuffixWrapper>
160
+ ) }
161
+ </Styled.DropdownMenuItemContentWrapper>
133
162
  </Styled.DropdownMenuRadioItem>
134
163
  );
135
164
  } );
@@ -148,20 +177,6 @@ export const DropdownMenuGroup = forwardRef<
148
177
  );
149
178
  } );
150
179
 
151
- export const DropdownMenuGroupLabel = forwardRef<
152
- HTMLDivElement,
153
- WordPressComponentProps< DropdownMenuGroupLabelProps, 'div', false >
154
- >( function DropdownMenuGroupLabel( props, ref ) {
155
- const dropdownMenuContext = useContext( DropdownMenuContext );
156
- return (
157
- <Styled.DropdownMenuGroupLabel
158
- ref={ ref }
159
- { ...props }
160
- store={ dropdownMenuContext?.store }
161
- />
162
- );
163
- } );
164
-
165
180
  const UnconnectedDropdownMenu = (
166
181
  props: WordPressComponentProps< DropdownMenuProps, 'div', false >,
167
182
  ref: React.ForwardedRef< HTMLDivElement >
@@ -280,12 +295,16 @@ const UnconnectedDropdownMenu = (
280
295
  dropdownMenuStore.parent
281
296
  ? cloneElement( trigger, {
282
297
  // Add submenu arrow, unless a `suffix` is explicitly specified
283
- suffix: trigger.props.suffix ?? (
284
- <Styled.SubmenuChevronIcon
285
- aria-hidden="true"
286
- icon={ chevronRightSmall }
287
- size={ 24 }
288
- />
298
+ suffix: (
299
+ <>
300
+ { trigger.props.suffix }
301
+ <Styled.SubmenuChevronIcon
302
+ aria-hidden="true"
303
+ icon={ chevronRightSmall }
304
+ size={ 24 }
305
+ preserveAspectRatio="xMidYMid slice"
306
+ />
307
+ </>
289
308
  ),
290
309
  } )
291
310
  : trigger
@@ -297,8 +316,12 @@ const UnconnectedDropdownMenu = (
297
316
  { ...otherProps }
298
317
  modal={ modal }
299
318
  store={ dropdownMenuStore }
300
- gutter={ gutter ?? ( dropdownMenuStore.parent ? 16 : 8 ) }
301
- shift={ shift ?? ( dropdownMenuStore.parent ? -8 : 0 ) }
319
+ // Root menu has an 8px distance from its trigger,
320
+ // otherwise 0 (which causes the submenu to slightly overlap)
321
+ gutter={ gutter ?? ( dropdownMenuStore.parent ? 0 : 8 ) }
322
+ // Align nested menu by the same (but opposite) amount
323
+ // as the menu container's padding.
324
+ shift={ shift ?? ( dropdownMenuStore.parent ? -4 : 0 ) }
302
325
  hideOnHoverOutside={ false }
303
326
  data-side={ appliedPlacementSide }
304
327
  variant={ variant }
@@ -332,3 +355,29 @@ export const DropdownMenuSeparator = forwardRef<
332
355
  />
333
356
  );
334
357
  } );
358
+
359
+ export const DropdownMenuItemLabel = forwardRef<
360
+ HTMLSpanElement,
361
+ WordPressComponentProps< { children: React.ReactNode }, 'span', true >
362
+ >( function DropdownMenuItemLabel( props, ref ) {
363
+ return (
364
+ <Styled.DropdownMenuItemLabel
365
+ numberOfLines={ 1 }
366
+ ref={ ref }
367
+ { ...props }
368
+ />
369
+ );
370
+ } );
371
+
372
+ export const DropdownMenuItemHelpText = forwardRef<
373
+ HTMLSpanElement,
374
+ WordPressComponentProps< { children: React.ReactNode }, 'span', true >
375
+ >( function DropdownMenuItemHelpText( props, ref ) {
376
+ return (
377
+ <Styled.DropdownMenuItemHelpText
378
+ numberOfLines={ 2 }
379
+ ref={ ref }
380
+ { ...props }
381
+ />
382
+ );
383
+ } );