@wordpress/components 32.5.0 → 32.5.2-next.v.202604091042.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 (117) hide show
  1. package/AGENTS.md +2 -2
  2. package/CHANGELOG.md +20 -0
  3. package/README.md +18 -4
  4. package/build/autocomplete/autocompleter-ui.cjs +75 -79
  5. package/build/autocomplete/autocompleter-ui.cjs.map +2 -2
  6. package/build/autocomplete/get-autocomplete-match.cjs +91 -0
  7. package/build/autocomplete/get-autocomplete-match.cjs.map +7 -0
  8. package/build/autocomplete/index.cjs +104 -107
  9. package/build/autocomplete/index.cjs.map +3 -3
  10. package/build/box-control/index.cjs +0 -8
  11. package/build/box-control/index.cjs.map +2 -2
  12. package/build/box-control/utils.cjs +1 -10
  13. package/build/box-control/utils.cjs.map +2 -2
  14. package/build/calendar/utils/use-localization-props.cjs +3 -2
  15. package/build/calendar/utils/use-localization-props.cjs.map +2 -2
  16. package/build/custom-select-control/index.cjs.map +3 -3
  17. package/build/custom-select-control-v2/custom-select.cjs +2 -2
  18. package/build/custom-select-control-v2/custom-select.cjs.map +2 -2
  19. package/build/custom-select-control-v2/index.cjs.map +3 -3
  20. package/build/sandbox/index.cjs +2 -2
  21. package/build/sandbox/index.cjs.map +2 -2
  22. package/build/validated-form-controls/control-with-error.cjs +12 -8
  23. package/build/validated-form-controls/control-with-error.cjs.map +2 -2
  24. package/build-module/autocomplete/autocompleter-ui.mjs +74 -78
  25. package/build-module/autocomplete/autocompleter-ui.mjs.map +2 -2
  26. package/build-module/autocomplete/get-autocomplete-match.mjs +56 -0
  27. package/build-module/autocomplete/get-autocomplete-match.mjs.map +7 -0
  28. package/build-module/autocomplete/index.mjs +103 -107
  29. package/build-module/autocomplete/index.mjs.map +3 -3
  30. package/build-module/box-control/index.mjs +1 -9
  31. package/build-module/box-control/index.mjs.map +2 -2
  32. package/build-module/box-control/utils.mjs +1 -9
  33. package/build-module/box-control/utils.mjs.map +2 -2
  34. package/build-module/calendar/utils/use-localization-props.mjs +3 -2
  35. package/build-module/calendar/utils/use-localization-props.mjs.map +2 -2
  36. package/build-module/custom-select-control/index.mjs +2 -2
  37. package/build-module/custom-select-control/index.mjs.map +2 -2
  38. package/build-module/custom-select-control-v2/custom-select.mjs +2 -2
  39. package/build-module/custom-select-control-v2/custom-select.mjs.map +2 -2
  40. package/build-module/custom-select-control-v2/index.mjs +2 -2
  41. package/build-module/custom-select-control-v2/index.mjs.map +2 -2
  42. package/build-module/sandbox/index.mjs +2 -2
  43. package/build-module/sandbox/index.mjs.map +2 -2
  44. package/build-module/validated-form-controls/control-with-error.mjs +12 -8
  45. package/build-module/validated-form-controls/control-with-error.mjs.map +2 -2
  46. package/build-style/style-rtl.css +0 -3
  47. package/build-style/style.css +0 -3
  48. package/build-types/autocomplete/autocompleter-ui.d.ts +2 -2
  49. package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
  50. package/build-types/autocomplete/get-autocomplete-match.d.ts +11 -0
  51. package/build-types/autocomplete/get-autocomplete-match.d.ts.map +1 -0
  52. package/build-types/autocomplete/index.d.ts +8 -0
  53. package/build-types/autocomplete/index.d.ts.map +1 -1
  54. package/build-types/autocomplete/test/get-autocomplete-match.d.ts +2 -0
  55. package/build-types/autocomplete/test/get-autocomplete-match.d.ts.map +1 -0
  56. package/build-types/autocomplete/types.d.ts +23 -9
  57. package/build-types/autocomplete/types.d.ts.map +1 -1
  58. package/build-types/box-control/index.d.ts.map +1 -1
  59. package/build-types/box-control/utils.d.ts +7 -16
  60. package/build-types/box-control/utils.d.ts.map +1 -1
  61. package/build-types/button/stories/index.story.d.ts +0 -1
  62. package/build-types/button/stories/index.story.d.ts.map +1 -1
  63. package/build-types/calendar/utils/use-localization-props.d.ts +3 -3
  64. package/build-types/calendar/utils/use-localization-props.d.ts.map +1 -1
  65. package/build-types/custom-gradient-picker/constants.d.ts +2 -2
  66. package/build-types/custom-select-control-v2/custom-select.d.ts +3 -3
  67. package/build-types/custom-select-control-v2/custom-select.d.ts.map +1 -1
  68. package/build-types/custom-select-control-v2/types.d.ts +1 -1
  69. package/build-types/custom-select-control-v2/types.d.ts.map +1 -1
  70. package/build-types/font-size-picker/constants.d.ts +2 -2
  71. package/build-types/font-size-picker/constants.d.ts.map +1 -1
  72. package/build-types/palette-edit/index.d.ts +1 -1
  73. package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -1
  74. package/package.json +21 -21
  75. package/src/alignment-matrix-control/README.md +1 -1
  76. package/src/angle-picker-control/style.module.scss +1 -0
  77. package/src/autocomplete/README.md +2 -2
  78. package/src/autocomplete/autocompleter-ui.native.js +166 -173
  79. package/src/autocomplete/autocompleter-ui.tsx +114 -116
  80. package/src/autocomplete/get-autocomplete-match.ts +115 -0
  81. package/src/autocomplete/index.tsx +129 -208
  82. package/src/autocomplete/test/get-autocomplete-match.ts +338 -0
  83. package/src/autocomplete/test/index.tsx +112 -4
  84. package/src/autocomplete/types.ts +17 -10
  85. package/src/box-control/index.tsx +1 -19
  86. package/src/box-control/utils.ts +1 -19
  87. package/src/button/README.md +1 -1
  88. package/src/button/stories/index.story.tsx +0 -1
  89. package/src/button/style.scss +0 -6
  90. package/src/calendar/utils/use-localization-props.ts +3 -4
  91. package/src/custom-select-control/index.tsx +3 -3
  92. package/src/custom-select-control-v2/custom-select.tsx +4 -4
  93. package/src/custom-select-control-v2/index.tsx +2 -2
  94. package/src/custom-select-control-v2/types.ts +1 -1
  95. package/src/divider/README.md +5 -6
  96. package/src/flex/stories/index.story.tsx +1 -1
  97. package/src/form-file-upload/README.md +3 -3
  98. package/src/gradient-picker/README.md +2 -2
  99. package/src/h-stack/README.md +10 -15
  100. package/src/h-stack/stories/index.story.tsx +2 -2
  101. package/src/heading/stories/index.story.tsx +1 -1
  102. package/src/higher-order/with-focus-outside/index.native.js +21 -20
  103. package/src/icon/README.md +1 -1
  104. package/src/menu/README.md +2 -2
  105. package/src/mobile/utils/get-px-from-css-unit.native.js +1 -1
  106. package/src/sandbox/index.native.js +2 -2
  107. package/src/sandbox/index.tsx +2 -2
  108. package/src/tabs/README.md +6 -6
  109. package/src/text/stories/index.story.tsx +1 -1
  110. package/src/toolbar/toolbar-button/toolbar-button-container.native.js +3 -1
  111. package/src/tree-select/README.md +1 -1
  112. package/src/v-stack/README.md +10 -15
  113. package/src/v-stack/stories/index.story.tsx +2 -2
  114. package/src/validated-form-controls/control-with-error.tsx +17 -12
  115. package/src/validated-form-controls/test/control-with-error.tsx +28 -1
  116. package/src/view/README.md +2 -5
  117. package/src/button/stories/style.css +0 -8
@@ -19,7 +19,7 @@ import type {
19
19
  CustomSelectStore,
20
20
  CustomSelectButtonProps,
21
21
  CustomSelectButtonSize,
22
- _CustomSelectInternalProps,
22
+ CustomSelectInternalProps,
23
23
  _CustomSelectProps,
24
24
  } from './types';
25
25
  import InputBase from '../input-control/input-base';
@@ -85,8 +85,8 @@ const CustomSelectButton = ( {
85
85
  );
86
86
  };
87
87
 
88
- function _CustomSelect(
89
- props: _CustomSelectInternalProps &
88
+ function CustomSelect(
89
+ props: CustomSelectInternalProps &
90
90
  _CustomSelectProps &
91
91
  CustomSelectStore &
92
92
  CustomSelectButtonSize
@@ -161,4 +161,4 @@ function _CustomSelect(
161
161
  );
162
162
  }
163
163
 
164
- export default _CustomSelect;
164
+ export default CustomSelect;
@@ -5,7 +5,7 @@ import * as Ariakit from '@ariakit/react';
5
5
  /**
6
6
  * Internal dependencies
7
7
  */
8
- import _CustomSelect from './custom-select';
8
+ import CustomSelect from './custom-select';
9
9
  import type { CustomSelectProps } from './types';
10
10
  import type { WordPressComponentProps } from '../context';
11
11
  import Item from './item';
@@ -21,7 +21,7 @@ function CustomSelectControlV2(
21
21
  value,
22
22
  } );
23
23
 
24
- return <_CustomSelect { ...restProps } store={ store } />;
24
+ return <CustomSelect { ...restProps } store={ store } />;
25
25
  }
26
26
 
27
27
  CustomSelectControlV2.Item = Item;
@@ -50,7 +50,7 @@ export type CustomSelectButtonProps = {
50
50
  };
51
51
 
52
52
  // Props only exposed on the internal implementation
53
- export type _CustomSelectInternalProps = {
53
+ export type CustomSelectInternalProps = {
54
54
  /**
55
55
  * True if the consumer is emulating the legacy component behavior and look
56
56
  */
@@ -11,17 +11,16 @@ This feature is still experimental. “Experimental” means this is an early im
11
11
  ```jsx
12
12
  import {
13
13
  __experimentalDivider as Divider,
14
- __experimentalText as Text,
15
- __experimentalVStack as VStack,
16
14
  } from `@wordpress/components`;
15
+ import { Stack } from '@wordpress/ui';
17
16
 
18
17
  function Example() {
19
18
  return (
20
- <VStack spacing={4}>
21
- <Text>Some text here</Text>
19
+ <Stack direction="column" gap="lg">
20
+ <span>Some text here</span>
22
21
  <Divider />
23
- <Text>Some more text here</Text>
24
- </VStack>
22
+ <span>Some more text here</span>
23
+ </Stack>
25
24
  );
26
25
  }
27
26
  ```
@@ -34,7 +34,7 @@ const meta: Meta< typeof Flex > = {
34
34
  componentStatus: {
35
35
  status: 'not-recommended',
36
36
  whereUsed: 'global',
37
- notes: 'Planned for deprecation. For use cases not covered by `HStack` and `VStack`, write your own CSS.',
37
+ notes: 'Planned for deprecation. For use cases not covered by `Stack` from `@wordpress/ui`, write your own CSS.',
38
38
  },
39
39
  },
40
40
  };
@@ -48,7 +48,7 @@ Children are passed as children of `Button`.
48
48
 
49
49
  ### `icon`
50
50
 
51
- - Type: `IconType`
51
+ - Type: `IconType | null`
52
52
  - Required: No
53
53
 
54
54
  The icon to render in the default button.
@@ -65,7 +65,7 @@ Whether to allow multiple selection of files or not.
65
65
 
66
66
  ### `onChange`
67
67
 
68
- - Type: `ChangeEventHandler<HTMLInputElement>`
68
+ - Type: `ChangeEventHandler<HTMLInputElement> | undefined`
69
69
  - Required: Yes
70
70
 
71
71
  Callback function passed directly to the `input` file element.
@@ -95,7 +95,7 @@ an empty string in the `onClick` function.
95
95
 
96
96
  ### `render`
97
97
 
98
- - Type: `(arg: { openFileDialog: () => void; }) => ReactNode`
98
+ - Type: `((arg: { openFileDialog: () => void; }) => ReactNode)`
99
99
  - Required: No
100
100
 
101
101
  Optional callback function used to render the UI.
@@ -141,7 +141,7 @@ Only used when `asButtons` is not true.
141
141
 
142
142
  ### `onChange`
143
143
 
144
- - Type: `(currentGradient: string) => void`
144
+ - Type: `(currentGradient: string | undefined) => void`
145
145
  - Required: Yes
146
146
 
147
147
  The function called when a new gradient has been defined. It is passed to
@@ -149,7 +149,7 @@ the `currentGradient` as an argument.
149
149
 
150
150
  ### `value`
151
151
 
152
- - Type: `string`
152
+ - Type: `string | null`
153
153
  - Required: No
154
154
  - Default: `'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)'`
155
155
 
@@ -11,17 +11,14 @@ This feature is still experimental. “Experimental” means this is an early im
11
11
  `HStack` can render anything inside.
12
12
 
13
13
  ```jsx
14
- import {
15
- __experimentalHStack as HStack,
16
- __experimentalText as Text,
17
- } from '@wordpress/components';
14
+ import { __experimentalHStack as HStack } from '@wordpress/components';
18
15
 
19
16
  function Example() {
20
17
  return (
21
18
  <HStack>
22
- <Text>Code</Text>
23
- <Text>is</Text>
24
- <Text>Poetry</Text>
19
+ <span>Code</span>
20
+ <span>is</span>
21
+ <span>Poetry</span>
25
22
  </HStack>
26
23
  );
27
24
  }
@@ -87,17 +84,16 @@ When a `Spacer` is used within an `HStack`, the `Spacer` adaptively expands to t
87
84
  import {
88
85
  __experimentalHStack as HStack,
89
86
  __experimentalSpacer as Spacer,
90
- __experimentalText as Text,
91
87
  } from '@wordpress/components';
92
88
 
93
89
  function Example() {
94
90
  return (
95
91
  <HStack>
96
- <Text>Code</Text>
92
+ <span>Code</span>
97
93
  <Spacer>
98
- <Text>is</Text>
94
+ <span>is</span>
99
95
  </Spacer>
100
- <Text>Poetry</Text>
96
+ <span>Poetry</span>
101
97
  </HStack>
102
98
  );
103
99
  }
@@ -109,16 +105,15 @@ function Example() {
109
105
  import {
110
106
  __experimentalHStack as HStack,
111
107
  __experimentalSpacer as Spacer,
112
- __experimentalText as Text,
113
108
  } from '@wordpress/components';
114
109
 
115
110
  function Example() {
116
111
  return (
117
112
  <HStack>
118
- <Text>Code</Text>
113
+ <span>Code</span>
119
114
  <Spacer />
120
- <Text>is</Text>
121
- <Text>Poetry</Text>
115
+ <span>is</span>
116
+ <span>Poetry</span>
122
117
  </HStack>
123
118
  );
124
119
  }
@@ -75,9 +75,9 @@ const meta: Meta< typeof HStack > = {
75
75
  controls: { expanded: true },
76
76
  docs: { canvas: { sourceState: 'shown' } },
77
77
  componentStatus: {
78
- status: 'stable',
78
+ status: 'not-recommended',
79
79
  whereUsed: 'global',
80
- notes: 'Will be superseded by `Stack` in `@wordpress/ui`, but continue using for now.',
80
+ notes: 'Use `Stack` from `@wordpress/ui` instead.',
81
81
  },
82
82
  },
83
83
  };
@@ -32,7 +32,7 @@ const meta: Meta< typeof Heading > = {
32
32
  componentStatus: {
33
33
  status: 'not-recommended',
34
34
  whereUsed: 'global',
35
- notes: 'Values are not aligned with the current design system. Use [typography tokens](?path=/docs/tokens-typography--page) from `@wordpress/base-styles` instead.',
35
+ notes: 'Use `Text` from `@wordpress/ui` instead, with the `render` prop set to the heading level element and the variant set to the visual heading size (e.g. `<Text render={ <h1 /> } variant="heading-2xl">`).',
36
36
  },
37
37
  },
38
38
  };
@@ -12,26 +12,27 @@ import {
12
12
  } from '@wordpress/compose';
13
13
 
14
14
  export default createHigherOrderComponent(
15
- ( WrappedComponent ) => ( props ) => {
16
- const [ handleFocusOutside, setHandleFocusOutside ] = useState();
17
- const bindFocusOutsideHandler = useCallback(
18
- ( node ) =>
19
- setHandleFocusOutside( () =>
20
- node?.handleFocusOutside
21
- ? node.handleFocusOutside.bind( node )
22
- : undefined
23
- ),
24
- []
25
- );
15
+ ( WrappedComponent ) =>
16
+ function WithFocusOutside( props ) {
17
+ const [ handleFocusOutside, setHandleFocusOutside ] = useState();
18
+ const bindFocusOutsideHandler = useCallback(
19
+ ( node ) =>
20
+ setHandleFocusOutside( () =>
21
+ node?.handleFocusOutside
22
+ ? node.handleFocusOutside.bind( node )
23
+ : undefined
24
+ ),
25
+ []
26
+ );
26
27
 
27
- return (
28
- <View { ...useFocusOutside( handleFocusOutside ) }>
29
- <WrappedComponent
30
- ref={ bindFocusOutsideHandler }
31
- { ...props }
32
- />
33
- </View>
34
- );
35
- },
28
+ return (
29
+ <View { ...useFocusOutside( handleFocusOutside ) }>
30
+ <WrappedComponent
31
+ ref={ bindFocusOutsideHandler }
32
+ { ...props }
33
+ />
34
+ </View>
35
+ );
36
+ },
36
37
  'withFocusOutside'
37
38
  );
@@ -16,7 +16,7 @@ import { wordpress } from '@wordpress/icons';
16
16
 
17
17
  ### `icon`
18
18
 
19
- - Type: `IconType`
19
+ - Type: `IconType | null`
20
20
  - Required: No
21
21
  - Default: `null`
22
22
 
@@ -19,7 +19,7 @@ component, and the `Menu.Popover` component.
19
19
 
20
20
  ### `as`
21
21
 
22
- - Type: `"symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | ... 516 more ... | ("view" & FunctionComponent<...>)`
22
+ - Type: `"symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | ... 517 more ...`
23
23
  - Required: No
24
24
 
25
25
  The HTML element or React component to render the component as.
@@ -57,7 +57,7 @@ override the `defaultOpen` prop.
57
57
 
58
58
  ### `onOpenChange`
59
59
 
60
- - Type: `(open: boolean) => void`
60
+ - Type: `((open: boolean) => void)`
61
61
  - Required: No
62
62
 
63
63
  A callback that gets called when the `open` state changes.
@@ -26,7 +26,7 @@ function parseUnit( cssUnit ) {
26
26
  function calculate( expression ) {
27
27
  try {
28
28
  return Function( `'use strict'; return (${ expression })` )();
29
- } catch ( err ) {
29
+ } catch {
30
30
  return null;
31
31
  }
32
32
  }
@@ -172,7 +172,7 @@ const style = `
172
172
 
173
173
  const EMPTY_ARRAY = [];
174
174
 
175
- const Sandbox = forwardRef( function Sandbox(
175
+ const Sandbox = forwardRef( function UnforwardedSandbox(
176
176
  {
177
177
  containerStyle,
178
178
  customJS,
@@ -297,7 +297,7 @@ const Sandbox = forwardRef( function Sandbox(
297
297
 
298
298
  try {
299
299
  data = JSON.parse( data );
300
- } catch ( e ) {
300
+ } catch {
301
301
  return;
302
302
  }
303
303
 
@@ -141,7 +141,7 @@ function SandBox( {
141
141
  function isFrameAccessible() {
142
142
  try {
143
143
  return !! ref.current?.contentDocument?.body;
144
- } catch ( e ) {
144
+ } catch {
145
145
  return false;
146
146
  }
147
147
  }
@@ -232,7 +232,7 @@ function SandBox( {
232
232
  if ( 'string' === typeof data ) {
233
233
  try {
234
234
  data = JSON.parse( data );
235
- } catch ( e ) {}
235
+ } catch {}
236
236
  }
237
237
 
238
238
  // Update the state only if the message is formatted as we expect,
@@ -19,7 +19,7 @@ It is responsible for managing the state of the tabs, and rendering one instance
19
19
 
20
20
  ### `activeTabId`
21
21
 
22
- - Type: `string`
22
+ - Type: `string | null`
23
23
  - Required: No
24
24
 
25
25
  The current active tab `id`. The active tab is the tab element within the
@@ -42,7 +42,7 @@ components as there are `Tabs.Tab` components.
42
42
 
43
43
  ### `defaultTabId`
44
44
 
45
- - Type: `string`
45
+ - Type: `string | null`
46
46
  - Required: No
47
47
 
48
48
  The id of the tab whose panel is currently visible.
@@ -56,7 +56,7 @@ provided (meaning the component will be used in "controlled" mode).
56
56
 
57
57
  ### `defaultActiveTabId`
58
58
 
59
- - Type: `string`
59
+ - Type: `string | null`
60
60
  - Required: No
61
61
 
62
62
  The tab id that should be active by default when the composite widget is
@@ -69,14 +69,14 @@ provided.
69
69
 
70
70
  ### `onSelect`
71
71
 
72
- - Type: `(selectedId: string) => void`
72
+ - Type: `((selectedId: string | null) => void)`
73
73
  - Required: No
74
74
 
75
75
  The function called when the `selectedTabId` changes.
76
76
 
77
77
  ### `onActiveTabIdChange`
78
78
 
79
- - Type: `(activeId: string) => void`
79
+ - Type: `((activeId: string | null) => void)`
80
80
  - Required: No
81
81
 
82
82
  A callback that gets called when the `activeTabId` state changes.
@@ -107,7 +107,7 @@ for more info.
107
107
 
108
108
  ### `selectedTabId`
109
109
 
110
- - Type: `string`
110
+ - Type: `string | null`
111
111
  - Required: No
112
112
 
113
113
  The id of the tab whose panel is currently visible.
@@ -33,7 +33,7 @@ const meta: Meta< typeof Text > = {
33
33
  componentStatus: {
34
34
  status: 'not-recommended',
35
35
  whereUsed: 'global',
36
- notes: 'Values are not aligned with the current design system. Use [typography tokens](?path=/docs/tokens-typography--page) from `@wordpress/base-styles` instead.',
36
+ notes: 'Use `Text` from `@wordpress/ui` instead.',
37
37
  },
38
38
  },
39
39
  };
@@ -3,4 +3,6 @@
3
3
  */
4
4
  import { View } from 'react-native';
5
5
 
6
- export default ( props ) => <View>{ props.children }</View>;
6
+ export default function ToolbarButtonContainer( props ) {
7
+ return <View>{ props.children }</View>;
8
+ }
@@ -118,7 +118,7 @@ If this property is added, an option will be added with this label to represent
118
118
 
119
119
  ### `onChange`
120
120
 
121
- - Type: `(value: string, extra?: { event?: ChangeEvent<HTMLSelectElement>; }) => void`
121
+ - Type: `((value: string, extra?: { event?: ChangeEvent<HTMLSelectElement>; }) => void) | undefined`
122
122
  - Required: No
123
123
 
124
124
  A function that receives the value of the new option that is being selected as input.
@@ -11,17 +11,14 @@ This feature is still experimental. “Experimental” means this is an early im
11
11
  `VStack` can render anything inside.
12
12
 
13
13
  ```jsx
14
- import {
15
- __experimentalText as Text,
16
- __experimentalVStack as VStack,
17
- } from '@wordpress/components';
14
+ import { __experimentalVStack as VStack } from '@wordpress/components';
18
15
 
19
16
  function Example() {
20
17
  return (
21
18
  <VStack>
22
- <Text>Code</Text>
23
- <Text>is</Text>
24
- <Text>Poetry</Text>
19
+ <span>Code</span>
20
+ <span>is</span>
21
+ <span>Poetry</span>
25
22
  </VStack>
26
23
  );
27
24
  }
@@ -74,18 +71,17 @@ When a `Spacer` is used within an `VStack`, the `Spacer` adaptively expands to t
74
71
  ```jsx
75
72
  import {
76
73
  __experimentalSpacer as Spacer,
77
- __experimentalText as Text,
78
74
  __experimentalVStack as VStack,
79
75
  } from '@wordpress/components';
80
76
 
81
77
  function Example() {
82
78
  return (
83
79
  <VStack>
84
- <Text>Code</Text>
80
+ <span>Code</span>
85
81
  <Spacer>
86
- <Text>is</Text>
82
+ <span>is</span>
87
83
  </Spacer>
88
- <Text>Poetry</Text>
84
+ <span>Poetry</span>
89
85
  </VStack>
90
86
  );
91
87
  }
@@ -96,17 +92,16 @@ function Example() {
96
92
  ```jsx
97
93
  import {
98
94
  __experimentalSpacer as Spacer,
99
- __experimentalText as Text,
100
95
  __experimentalVStack as VStack,
101
96
  } from '@wordpress/components';
102
97
 
103
98
  function Example() {
104
99
  return (
105
100
  <VStack>
106
- <Text>Code</Text>
101
+ <span>Code</span>
107
102
  <Spacer />
108
- <Text>is</Text>
109
- <Text>Poetry</Text>
103
+ <span>is</span>
104
+ <span>Poetry</span>
110
105
  </VStack>
111
106
  );
112
107
  }
@@ -43,9 +43,9 @@ const meta: Meta< typeof VStack > = {
43
43
  controls: { expanded: true },
44
44
  docs: { canvas: { sourceState: 'shown' } },
45
45
  componentStatus: {
46
- status: 'stable',
46
+ status: 'not-recommended',
47
47
  whereUsed: 'global',
48
- notes: 'Will be superseded by `Stack` in `@wordpress/ui`, but continue using for now.',
48
+ notes: 'Use `Stack` from `@wordpress/ui` instead.',
49
49
  },
50
50
  },
51
51
  };
@@ -21,21 +21,26 @@ function appendRequiredIndicator(
21
21
  required: boolean | undefined,
22
22
  markWhenOptional: boolean | undefined
23
23
  ) {
24
+ let suffix;
24
25
  if ( required && ! markWhenOptional ) {
25
- return (
26
- <>
27
- { label } { `(${ __( 'Required' ) })` }
28
- </>
29
- );
26
+ suffix = `(${ __( 'Required' ) })`;
27
+ } else if ( ! required && markWhenOptional ) {
28
+ suffix = `(${ __( 'Optional' ) })`;
30
29
  }
31
- if ( ! required && markWhenOptional ) {
32
- return (
33
- <>
34
- { label } { `(${ __( 'Optional' ) })` }
35
- </>
36
- );
30
+
31
+ if ( ! suffix ) {
32
+ return label;
33
+ }
34
+
35
+ if ( typeof label === 'string' ) {
36
+ return `${ label } ${ suffix }`;
37
37
  }
38
- return label;
38
+
39
+ return (
40
+ <>
41
+ { label } { suffix }
42
+ </>
43
+ );
39
44
  }
40
45
 
41
46
  const VALIDITY_VISIBLE_ATTRIBUTE = 'data-validity-visible';
@@ -12,7 +12,7 @@ import { useState, useCallback, useId, useRef } from '@wordpress/element';
12
12
  /**
13
13
  * Internal dependencies
14
14
  */
15
- import { ValidatedInputControl } from '../components';
15
+ import { ValidatedInputControl, ValidatedRangeControl } from '../components';
16
16
 
17
17
  describe( 'ControlWithError', () => {
18
18
  describe( 'Async Validation', () => {
@@ -464,6 +464,33 @@ describe( 'ControlWithError', () => {
464
464
  } );
465
465
  } );
466
466
 
467
+ describe( 'ValidatedRangeControl', () => {
468
+ it( 'should accessibly label the internal slider and spin button', () => {
469
+ render(
470
+ <ValidatedRangeControl
471
+ label="Opacity"
472
+ required
473
+ min={ 0 }
474
+ max={ 100 }
475
+ onChange={ () => {} }
476
+ />
477
+ );
478
+
479
+ // The slider is styled with `opacity: 0`, so it's not "visible"
480
+ // in the DOM sense, but it's still accessible.
481
+ expect(
482
+ screen.getByRole( 'slider', {
483
+ name: 'Opacity (Required)',
484
+ } )
485
+ ).toBeInTheDocument();
486
+ expect(
487
+ screen.getByRole( 'spinbutton', {
488
+ name: 'Opacity (Required)',
489
+ } )
490
+ ).toBeVisible();
491
+ } );
492
+ } );
493
+
467
494
  describe( 'Focus behavior', () => {
468
495
  it( 'should focus the first error in the form', async () => {
469
496
  const user = userEvent.setup();
@@ -11,15 +11,12 @@ This feature is still experimental. “Experimental” means this is an early im
11
11
  ## Usage
12
12
 
13
13
  ```jsx
14
- import {
15
- __experimentalText as Text,
16
- __experimentalView as View,
17
- } from '@wordpress/components';
14
+ import { __experimentalView as View } from '@wordpress/components';
18
15
 
19
16
  function Example() {
20
17
  return (
21
18
  <View>
22
- <Text>Code is Poetry</Text>
19
+ <span>Code is Poetry</span>
23
20
  </View>
24
21
  );
25
22
  }
@@ -1,8 +0,0 @@
1
- .story-buttons-container {
2
- display: flex;
3
- }
4
-
5
- .story-buttons-container > * {
6
- margin-right: 10px;
7
- margin-bottom: 10px;
8
- }