@wordpress/components 25.3.0 → 25.5.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 (190) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/build/border-control/border-control-dropdown/component.js +8 -10
  3. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  4. package/build/button/index.native.js +9 -6
  5. package/build/button/index.native.js.map +1 -1
  6. package/build/color-palette/index.js +2 -2
  7. package/build/color-palette/index.js.map +1 -1
  8. package/build/focal-point-picker/index.native.js +6 -4
  9. package/build/focal-point-picker/index.native.js.map +1 -1
  10. package/build/form-token-field/styles.js +4 -2
  11. package/build/form-token-field/styles.js.map +1 -1
  12. package/build/item-group/item/hook.js +1 -1
  13. package/build/item-group/item/hook.js.map +1 -1
  14. package/build/item-group/styles.js +13 -10
  15. package/build/item-group/styles.js.map +1 -1
  16. package/build/menu-items-choice/index.js +1 -0
  17. package/build/menu-items-choice/index.js.map +1 -1
  18. package/build/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js +3 -1
  19. package/build/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js.map +1 -1
  20. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +50 -44
  21. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  22. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +13 -20
  23. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  24. package/build/mobile/bottom-sheet/index.native.js +3 -1
  25. package/build/mobile/bottom-sheet/index.native.js.map +1 -1
  26. package/build/mobile/image/index.native.js +4 -3
  27. package/build/mobile/image/index.native.js.map +1 -1
  28. package/build/mobile/link-picker/link-picker-results.native.js +2 -1
  29. package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
  30. package/build/mobile/segmented-control/index.native.js +7 -7
  31. package/build/mobile/segmented-control/index.native.js.map +1 -1
  32. package/build/modal/index.js +14 -1
  33. package/build/modal/index.js.map +1 -1
  34. package/build/navigator/navigator-provider/component.js +18 -10
  35. package/build/navigator/navigator-provider/component.js.map +1 -1
  36. package/build/private-apis.js +4 -1
  37. package/build/private-apis.js.map +1 -1
  38. package/build/progress-bar/index.js +54 -0
  39. package/build/progress-bar/index.js.map +1 -0
  40. package/build/progress-bar/styles.js +69 -0
  41. package/build/progress-bar/styles.js.map +1 -0
  42. package/build/progress-bar/types.js +6 -0
  43. package/build/progress-bar/types.js.map +1 -0
  44. package/build/query-controls/index.js +1 -0
  45. package/build/query-controls/index.js.map +1 -1
  46. package/build/query-controls/index.native.js +1 -0
  47. package/build/query-controls/index.native.js.map +1 -1
  48. package/build/tab-panel/index.js +91 -58
  49. package/build/tab-panel/index.js.map +1 -1
  50. package/build/text-control/index.js +2 -2
  51. package/build/text-control/index.js.map +1 -1
  52. package/build/toolbar/toolbar-group/toolbar-group-container.native.js +10 -7
  53. package/build/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -1
  54. package/build-module/border-control/border-control-dropdown/component.js +8 -10
  55. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  56. package/build-module/button/index.native.js +8 -6
  57. package/build-module/button/index.native.js.map +1 -1
  58. package/build-module/color-palette/index.js +2 -2
  59. package/build-module/color-palette/index.js.map +1 -1
  60. package/build-module/focal-point-picker/index.native.js +6 -5
  61. package/build-module/focal-point-picker/index.native.js.map +1 -1
  62. package/build-module/form-token-field/styles.js +3 -2
  63. package/build-module/form-token-field/styles.js.map +1 -1
  64. package/build-module/item-group/item/hook.js +1 -1
  65. package/build-module/item-group/item/hook.js.map +1 -1
  66. package/build-module/item-group/styles.js +13 -11
  67. package/build-module/item-group/styles.js.map +1 -1
  68. package/build-module/menu-items-choice/index.js +1 -0
  69. package/build-module/menu-items-choice/index.js.map +1 -1
  70. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js +3 -1
  71. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js.map +1 -1
  72. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +43 -41
  73. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  74. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +14 -20
  75. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  76. package/build-module/mobile/bottom-sheet/index.native.js +3 -1
  77. package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
  78. package/build-module/mobile/image/index.native.js +4 -3
  79. package/build-module/mobile/image/index.native.js.map +1 -1
  80. package/build-module/mobile/link-picker/link-picker-results.native.js +2 -1
  81. package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
  82. package/build-module/mobile/segmented-control/index.native.js +7 -7
  83. package/build-module/mobile/segmented-control/index.native.js.map +1 -1
  84. package/build-module/modal/index.js +14 -1
  85. package/build-module/modal/index.js.map +1 -1
  86. package/build-module/navigator/navigator-provider/component.js +18 -10
  87. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  88. package/build-module/private-apis.js +3 -1
  89. package/build-module/private-apis.js.map +1 -1
  90. package/build-module/progress-bar/index.js +41 -0
  91. package/build-module/progress-bar/index.js.map +1 -0
  92. package/build-module/progress-bar/styles.js +61 -0
  93. package/build-module/progress-bar/styles.js.map +1 -0
  94. package/build-module/progress-bar/types.js +2 -0
  95. package/build-module/progress-bar/types.js.map +1 -0
  96. package/build-module/query-controls/index.js +1 -0
  97. package/build-module/query-controls/index.js.map +1 -1
  98. package/build-module/query-controls/index.native.js +1 -0
  99. package/build-module/query-controls/index.native.js.map +1 -1
  100. package/build-module/tab-panel/index.js +88 -59
  101. package/build-module/tab-panel/index.js.map +1 -1
  102. package/build-module/text-control/index.js +2 -2
  103. package/build-module/text-control/index.js.map +1 -1
  104. package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js +11 -7
  105. package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -1
  106. package/build-style/style-rtl.css +3 -0
  107. package/build-style/style.css +3 -0
  108. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  109. package/build-types/form-token-field/styles.d.ts.map +1 -1
  110. package/build-types/item-group/item/hook.d.ts.map +1 -1
  111. package/build-types/item-group/stories/index.d.ts.map +1 -1
  112. package/build-types/item-group/styles.d.ts +1 -1
  113. package/build-types/item-group/styles.d.ts.map +1 -1
  114. package/build-types/menu-items-choice/index.d.ts.map +1 -1
  115. package/build-types/menu-items-choice/types.d.ts +5 -0
  116. package/build-types/menu-items-choice/types.d.ts.map +1 -1
  117. package/build-types/modal/index.d.ts.map +1 -1
  118. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  119. package/build-types/navigator/types.d.ts +3 -1
  120. package/build-types/navigator/types.d.ts.map +1 -1
  121. package/build-types/private-apis.d.ts.map +1 -1
  122. package/build-types/progress-bar/index.d.ts +5 -0
  123. package/build-types/progress-bar/index.d.ts.map +1 -0
  124. package/build-types/progress-bar/stories/index.d.ts +12 -0
  125. package/build-types/progress-bar/stories/index.d.ts.map +1 -0
  126. package/build-types/progress-bar/styles.d.ts +18 -0
  127. package/build-types/progress-bar/styles.d.ts.map +1 -0
  128. package/build-types/progress-bar/test/index.d.ts +2 -0
  129. package/build-types/progress-bar/test/index.d.ts.map +1 -0
  130. package/build-types/progress-bar/types.d.ts +11 -0
  131. package/build-types/progress-bar/types.d.ts.map +1 -0
  132. package/build-types/query-controls/index.d.ts.map +1 -1
  133. package/build-types/tab-panel/index.d.ts.map +1 -1
  134. package/build-types/tab-panel/stories/index.d.ts +1 -0
  135. package/build-types/tab-panel/stories/index.d.ts.map +1 -1
  136. package/build-types/tab-panel/types.d.ts +1 -9
  137. package/build-types/tab-panel/types.d.ts.map +1 -1
  138. package/build-types/text-control/test/text-control.d.ts +2 -0
  139. package/build-types/text-control/test/text-control.d.ts.map +1 -0
  140. package/package.json +22 -22
  141. package/src/border-control/border-control-dropdown/component.tsx +7 -11
  142. package/src/border-control/test/index.js +6 -6
  143. package/src/button/index.native.js +9 -3
  144. package/src/button/style.native.scss +9 -0
  145. package/src/color-palette/index.tsx +2 -2
  146. package/src/color-palette/test/__snapshots__/index.tsx.snap +1 -1
  147. package/src/color-palette/test/index.tsx +1 -5
  148. package/src/draggable/test/index.native.js +4 -0
  149. package/src/focal-point-picker/index.native.js +6 -5
  150. package/src/form-token-field/styles.ts +2 -0
  151. package/src/item-group/item/hook.ts +2 -1
  152. package/src/item-group/stories/index.tsx +8 -3
  153. package/src/item-group/styles.ts +39 -28
  154. package/src/menu-item/README.md +7 -0
  155. package/src/menu-items-choice/index.tsx +1 -0
  156. package/src/menu-items-choice/types.ts +5 -0
  157. package/src/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js +1 -1
  158. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +72 -53
  159. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +15 -21
  160. package/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js +165 -119
  161. package/src/mobile/bottom-sheet/index.native.js +2 -0
  162. package/src/mobile/image/index.native.js +8 -6
  163. package/src/mobile/image/style.native.scss +5 -1
  164. package/src/mobile/link-picker/link-picker-results.native.js +1 -1
  165. package/src/mobile/link-settings/test/edit.native.js +37 -23
  166. package/src/mobile/segmented-control/index.native.js +11 -11
  167. package/src/modal/index.tsx +16 -0
  168. package/src/modal/test/index.tsx +33 -0
  169. package/src/navigator/navigator-provider/component.tsx +30 -23
  170. package/src/navigator/types.ts +4 -1
  171. package/src/placeholder/style.scss +5 -0
  172. package/src/private-apis.ts +2 -0
  173. package/src/progress-bar/README.md +30 -0
  174. package/src/progress-bar/index.tsx +45 -0
  175. package/src/progress-bar/stories/index.tsx +33 -0
  176. package/src/progress-bar/styles.ts +67 -0
  177. package/src/progress-bar/test/index.tsx +79 -0
  178. package/src/progress-bar/types.ts +11 -0
  179. package/src/query-controls/index.native.js +1 -0
  180. package/src/query-controls/index.tsx +1 -0
  181. package/src/tab-panel/index.tsx +121 -84
  182. package/src/tab-panel/stories/index.tsx +6 -0
  183. package/src/tab-panel/test/index.tsx +128 -109
  184. package/src/tab-panel/types.ts +1 -10
  185. package/src/text-control/index.tsx +2 -2
  186. package/src/text-control/test/text-control.tsx +61 -0
  187. package/src/toolbar/toolbar-group/style.native.scss +2 -3
  188. package/src/toolbar/toolbar-group/toolbar-group-container.native.js +12 -17
  189. package/src/tooltip/README.md +1 -1
  190. package/tsconfig.tsbuildinfo +1 -1
@@ -148,6 +148,7 @@ function UnconnectedNavigatorProvider(
148
148
  focusTargetSelector,
149
149
  isBack = false,
150
150
  skipFocus = false,
151
+ replace = false,
151
152
  ...restOptions
152
153
  } = options;
153
154
 
@@ -172,34 +173,38 @@ function UnconnectedNavigatorProvider(
172
173
  skipFocus,
173
174
  };
174
175
 
175
- if ( prevLocationHistory.length < 1 ) {
176
- return [ newLocation ];
176
+ if ( prevLocationHistory.length === 0 ) {
177
+ return replace ? [] : [ newLocation ];
177
178
  }
178
179
 
179
- return [
180
- ...prevLocationHistory.slice(
181
- prevLocationHistory.length > MAX_HISTORY_LENGTH - 1
182
- ? 1
183
- : 0,
184
- -1
185
- ),
186
- // Assign `focusTargetSelector` to the previous location in history
187
- // (the one we just navigated from).
188
- {
189
- ...prevLocationHistory[
190
- prevLocationHistory.length - 1
191
- ],
192
- focusTargetSelector,
193
- },
194
- newLocation,
195
- ];
180
+ const newLocationHistory = prevLocationHistory.slice(
181
+ prevLocationHistory.length > MAX_HISTORY_LENGTH - 1 ? 1 : 0,
182
+ -1
183
+ );
184
+
185
+ if ( ! replace ) {
186
+ newLocationHistory.push(
187
+ // Assign `focusTargetSelector` to the previous location in history
188
+ // (the one we just navigated from).
189
+ {
190
+ ...prevLocationHistory[
191
+ prevLocationHistory.length - 1
192
+ ],
193
+ focusTargetSelector,
194
+ }
195
+ );
196
+ }
197
+
198
+ newLocationHistory.push( newLocation );
199
+
200
+ return newLocationHistory;
196
201
  } );
197
202
  },
198
203
  [ goBack ]
199
204
  );
200
205
 
201
- const goToParent: NavigatorContextType[ 'goToParent' ] =
202
- useCallback( () => {
206
+ const goToParent: NavigatorContextType[ 'goToParent' ] = useCallback(
207
+ ( options = {} ) => {
203
208
  const currentPath =
204
209
  currentLocationHistory.current[
205
210
  currentLocationHistory.current.length - 1
@@ -214,8 +219,10 @@ function UnconnectedNavigatorProvider(
214
219
  if ( parentPath === undefined ) {
215
220
  return;
216
221
  }
217
- goTo( parentPath, { isBack: true } );
218
- }, [ goTo ] );
222
+ goTo( parentPath, { ...options, isBack: true } );
223
+ },
224
+ [ goTo ]
225
+ );
219
226
 
220
227
  const navigatorContextValue: NavigatorContextType = useMemo(
221
228
  () => ( {
@@ -14,8 +14,11 @@ export type NavigateOptions = {
14
14
  focusTargetSelector?: string;
15
15
  isBack?: boolean;
16
16
  skipFocus?: boolean;
17
+ replace?: boolean;
17
18
  };
18
19
 
20
+ export type NavigateToParentOptions = Omit< NavigateOptions, 'isBack' >;
21
+
19
22
  export type NavigatorLocation = NavigateOptions & {
20
23
  isInitial?: boolean;
21
24
  path?: string;
@@ -28,7 +31,7 @@ export type Navigator = {
28
31
  params: MatchParams;
29
32
  goTo: ( path: string, options?: NavigateOptions ) => void;
30
33
  goBack: () => void;
31
- goToParent: () => void;
34
+ goToParent: ( options?: NavigateToParentOptions ) => void;
32
35
  };
33
36
 
34
37
  export type NavigatorContext = Navigator & {
@@ -161,6 +161,11 @@
161
161
  padding: 0 $grid-unit-10 2px;
162
162
  }
163
163
  }
164
+ .components-placeholder__learn-more {
165
+ .components-external-link {
166
+ color: var(--wp-admin-theme-color);
167
+ }
168
+ }
164
169
  }
165
170
 
166
171
 
@@ -8,6 +8,7 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri
8
8
  */
9
9
  import { default as CustomSelectControl } from './custom-select-control';
10
10
  import { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';
11
+ import { default as ProgressBar } from './progress-bar';
11
12
  import { createPrivateSlotFill } from './slot-fill';
12
13
  import {
13
14
  DropdownMenu as DropdownMenuV2,
@@ -45,4 +46,5 @@ lock( privateApis, {
45
46
  DropdownMenuSeparatorV2,
46
47
  DropdownSubMenuV2,
47
48
  DropdownSubMenuTriggerV2,
49
+ ProgressBar,
48
50
  } );
@@ -0,0 +1,30 @@
1
+ # ProgressBar
2
+
3
+ <div class="callout callout-alert">
4
+ This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
5
+ </div>
6
+
7
+ A simple horizontal progress bar component.
8
+
9
+ Supports two modes: determinate and indeterminate. A progress bar is determinate when a specific progress value has been specified (from 0 to 100), and indeterminate when a value hasn't been specified.
10
+
11
+ ### Props
12
+
13
+ The component accepts the following props:
14
+
15
+ #### `value`: `number`
16
+
17
+ The progress value, a number from 0 to 100.
18
+ If a `value` is not specified, the progress bar will be considered indeterminate.
19
+
20
+ - Required: No
21
+
22
+ ##### `className`: `string`
23
+
24
+ A CSS class to apply to the underlying `div` element, serving as a progress bar track.
25
+
26
+ - Required: No
27
+
28
+ #### Inherited props
29
+
30
+ Any additional props will be passed the underlying `<progress/>` element.
@@ -0,0 +1,45 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { ForwardedRef } from 'react';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { __ } from '@wordpress/i18n';
10
+ import { forwardRef } from '@wordpress/element';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import * as ProgressBarStyled from './styles';
16
+ import type { ProgressBarProps } from './types';
17
+ import type { WordPressComponentProps } from '../ui/context';
18
+
19
+ function UnforwardedProgressBar(
20
+ props: WordPressComponentProps< ProgressBarProps, 'progress', false >,
21
+ ref: ForwardedRef< HTMLProgressElement >
22
+ ) {
23
+ const { className, value, ...progressProps } = props;
24
+ const isIndeterminate = ! Number.isFinite( value );
25
+
26
+ return (
27
+ <ProgressBarStyled.Track className={ className }>
28
+ <ProgressBarStyled.Indicator
29
+ isIndeterminate={ isIndeterminate }
30
+ value={ value }
31
+ />
32
+ <ProgressBarStyled.ProgressElement
33
+ max={ 100 }
34
+ value={ value }
35
+ aria-label={ __( 'Loading …' ) }
36
+ ref={ ref }
37
+ { ...progressProps }
38
+ />
39
+ </ProgressBarStyled.Track>
40
+ );
41
+ }
42
+
43
+ export const ProgressBar = forwardRef( UnforwardedProgressBar );
44
+
45
+ export default ProgressBar;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { ComponentMeta, ComponentStory } from '@storybook/react';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { ProgressBar } from '..';
10
+
11
+ const meta: ComponentMeta< typeof ProgressBar > = {
12
+ component: ProgressBar,
13
+ title: 'Components (Experimental)/ProgressBar',
14
+ argTypes: {
15
+ value: { control: { type: 'number', min: 0, max: 100, step: 1 } },
16
+ },
17
+ parameters: {
18
+ controls: {
19
+ expanded: true,
20
+ },
21
+ docs: { source: { state: 'open' } },
22
+ },
23
+ };
24
+ export default meta;
25
+
26
+ const Template: ComponentStory< typeof ProgressBar > = ( { ...args } ) => {
27
+ return <ProgressBar { ...args } />;
28
+ };
29
+
30
+ export const Default: ComponentStory< typeof ProgressBar > = Template.bind(
31
+ {}
32
+ );
33
+ Default.args = {};
@@ -0,0 +1,67 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import styled from '@emotion/styled';
5
+ import { css, keyframes } from '@emotion/react';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { COLORS, CONFIG } from '../utils';
11
+
12
+ const animateProgressBar = keyframes( {
13
+ '0%': {
14
+ left: '-50%',
15
+ },
16
+ '100%': {
17
+ left: '100%',
18
+ },
19
+ } );
20
+
21
+ // Width of the indicator for the indeterminate progress bar
22
+ export const INDETERMINATE_TRACK_WIDTH = 50;
23
+
24
+ export const Track = styled.div`
25
+ position: relative;
26
+ overflow: hidden;
27
+ width: 100%;
28
+ max-width: 160px;
29
+ height: ${ CONFIG.borderWidthFocus };
30
+ background-color: var(
31
+ --wp-components-color-gray-100,
32
+ ${ COLORS.gray[ 100 ] }
33
+ );
34
+ border-radius: ${ CONFIG.radiusBlockUi };
35
+ `;
36
+
37
+ export const Indicator = styled.div< {
38
+ isIndeterminate: boolean;
39
+ value?: number;
40
+ } >`
41
+ display: inline-block;
42
+ position: absolute;
43
+ top: 0;
44
+ height: 100%;
45
+ border-radius: ${ CONFIG.radiusBlockUi };
46
+ background-color: ${ COLORS.ui.theme };
47
+
48
+ ${ ( { isIndeterminate, value } ) =>
49
+ isIndeterminate
50
+ ? css( {
51
+ animationDuration: '1.5s',
52
+ animationTimingFunction: 'ease-in-out',
53
+ animationIterationCount: 'infinite',
54
+ animationName: animateProgressBar,
55
+ width: `${ INDETERMINATE_TRACK_WIDTH }%`,
56
+ } )
57
+ : css( { width: `${ value }%` } ) };
58
+ `;
59
+
60
+ export const ProgressElement = styled.progress`
61
+ position: absolute;
62
+ top: 0;
63
+ left: 0;
64
+ opacity: 0;
65
+ width: 100%;
66
+ height: 100%;
67
+ `;
@@ -0,0 +1,79 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { render, screen } from '@testing-library/react';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { ProgressBar } from '..';
10
+ import { INDETERMINATE_TRACK_WIDTH } from '../styles';
11
+
12
+ describe( 'ProgressBar', () => {
13
+ it( 'should render an indeterminate semantic progress bar element', () => {
14
+ render( <ProgressBar /> );
15
+
16
+ const progressBar = screen.getByRole( 'progressbar' );
17
+
18
+ expect( progressBar ).toBeInTheDocument();
19
+ expect( progressBar ).not.toBeVisible();
20
+ expect( progressBar ).not.toHaveValue();
21
+ } );
22
+
23
+ it( 'should render a determinate semantic progress bar element', () => {
24
+ render( <ProgressBar value={ 55 } /> );
25
+
26
+ const progressBar = screen.getByRole( 'progressbar' );
27
+
28
+ expect( progressBar ).toBeInTheDocument();
29
+ expect( progressBar ).not.toBeVisible();
30
+ expect( progressBar ).toHaveValue( 55 );
31
+ } );
32
+
33
+ it( 'should use `INDETERMINATE_TRACK_WIDTH`% as track width for indeterminate progress bar', () => {
34
+ const { container } = render( <ProgressBar /> );
35
+
36
+ /**
37
+ * We're intentionally not using an accessible selector, because
38
+ * the track is an intentionally non-interactive presentation element.
39
+ */
40
+ // eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
41
+ const indicator = container.firstChild?.firstChild;
42
+
43
+ expect( indicator ).toHaveStyle( {
44
+ width: `${ INDETERMINATE_TRACK_WIDTH }%`,
45
+ } );
46
+ } );
47
+
48
+ it( 'should use `value`% as width for determinate progress bar', () => {
49
+ const { container } = render( <ProgressBar value={ 55 } /> );
50
+
51
+ /**
52
+ * We're intentionally not using an accessible selector, because
53
+ * the track is an intentionally non-interactive presentation element.
54
+ */
55
+ // eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
56
+ const indicator = container.firstChild?.firstChild;
57
+
58
+ expect( indicator ).toHaveStyle( {
59
+ width: '55%',
60
+ } );
61
+ } );
62
+
63
+ it( 'should pass any additional props down to the underlying `progress` element', () => {
64
+ const id = 'foo-bar-123';
65
+ const ariaLabel = 'in progress...';
66
+ const style = { opacity: 1 };
67
+
68
+ render(
69
+ <ProgressBar id={ id } aria-label={ ariaLabel } style={ style } />
70
+ );
71
+
72
+ expect( screen.getByRole( 'progressbar' ) ).toHaveAttribute( 'id', id );
73
+ expect( screen.getByRole( 'progressbar' ) ).toHaveAttribute(
74
+ 'aria-label',
75
+ ariaLabel
76
+ );
77
+ expect( screen.getByRole( 'progressbar' ) ).toHaveStyle( style );
78
+ } );
79
+ } );
@@ -0,0 +1,11 @@
1
+ export type ProgressBarProps = {
2
+ /**
3
+ * Value of the progress bar.
4
+ */
5
+ value?: number;
6
+
7
+ /**
8
+ * A CSS class to apply to the progress bar wrapper (track) element.
9
+ */
10
+ className?: string;
11
+ };
@@ -84,6 +84,7 @@ const QueryControls = memo(
84
84
  ) }
85
85
  { onNumberOfItemsChange && (
86
86
  <RangeControl
87
+ __next40pxDefaultSize
87
88
  label={ __( 'Number of items' ) }
88
89
  value={ numberOfItems }
89
90
  onChange={ onNumberOfItemsChange }
@@ -177,6 +177,7 @@ export function QueryControls( {
177
177
  onNumberOfItemsChange && (
178
178
  <RangeControl
179
179
  __nextHasNoMarginBottom
180
+ __next40pxDefaultSize
180
181
  key="query-controls-range-control"
181
182
  label={ __( 'Number of items' ) }
182
183
  value={ numberOfItems }