@wordpress/components 25.2.0 → 25.4.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 (208) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/build/button/index.js +13 -4
  3. package/build/button/index.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/confirm-dialog/component.js +9 -1
  7. package/build/confirm-dialog/component.js.map +1 -1
  8. package/build/font-size-picker/index.js +5 -3
  9. package/build/font-size-picker/index.js.map +1 -1
  10. package/build/font-size-picker/styles.js +19 -26
  11. package/build/font-size-picker/styles.js.map +1 -1
  12. package/build/form-token-field/styles.js +4 -2
  13. package/build/form-token-field/styles.js.map +1 -1
  14. package/build/guide/icons.js +2 -5
  15. package/build/guide/icons.js.map +1 -1
  16. package/build/guide/index.js +14 -11
  17. package/build/guide/index.js.map +1 -1
  18. package/build/guide/page-control.js +1 -3
  19. package/build/guide/page-control.js.map +1 -1
  20. package/build/item-group/item/hook.js +1 -1
  21. package/build/item-group/item/hook.js.map +1 -1
  22. package/build/item-group/styles.js +13 -10
  23. package/build/item-group/styles.js.map +1 -1
  24. package/build/mobile/bottom-sheet/cell.native.js +2 -1
  25. package/build/mobile/bottom-sheet/cell.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/navigator/navigator-provider/component.js +18 -10
  29. package/build/navigator/navigator-provider/component.js.map +1 -1
  30. package/build/number-control/index.js +8 -4
  31. package/build/number-control/index.js.map +1 -1
  32. package/build/number-control/styles/number-control-styles.js +9 -15
  33. package/build/number-control/styles/number-control-styles.js.map +1 -1
  34. package/build/query-controls/index.js +1 -0
  35. package/build/query-controls/index.js.map +1 -1
  36. package/build/query-controls/index.native.js +1 -0
  37. package/build/query-controls/index.native.js.map +1 -1
  38. package/build/range-control/index.js +7 -1
  39. package/build/range-control/index.js.map +1 -1
  40. package/build/range-control/input-range.js.map +1 -1
  41. package/build/range-control/styles/range-control-styles.js +35 -36
  42. package/build/range-control/styles/range-control-styles.js.map +1 -1
  43. package/build/select-control/index.js +2 -1
  44. package/build/select-control/index.js.map +1 -1
  45. package/build/text-control/index.js +2 -2
  46. package/build/text-control/index.js.map +1 -1
  47. package/build/toolbar/toolbar-group/toolbar-group-container.native.js +10 -7
  48. package/build/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -1
  49. package/build/unit-control/index.js +4 -2
  50. package/build/unit-control/index.js.map +1 -1
  51. package/build/z-stack/component.js +5 -3
  52. package/build/z-stack/component.js.map +1 -1
  53. package/build/z-stack/styles.js +23 -42
  54. package/build/z-stack/styles.js.map +1 -1
  55. package/build-module/button/index.js +13 -4
  56. package/build-module/button/index.js.map +1 -1
  57. package/build-module/button/index.native.js +8 -6
  58. package/build-module/button/index.native.js.map +1 -1
  59. package/build-module/confirm-dialog/component.js +10 -2
  60. package/build-module/confirm-dialog/component.js.map +1 -1
  61. package/build-module/font-size-picker/index.js +5 -4
  62. package/build-module/font-size-picker/index.js.map +1 -1
  63. package/build-module/font-size-picker/styles.js +17 -23
  64. package/build-module/font-size-picker/styles.js.map +1 -1
  65. package/build-module/form-token-field/styles.js +3 -2
  66. package/build-module/form-token-field/styles.js.map +1 -1
  67. package/build-module/guide/icons.js +2 -5
  68. package/build-module/guide/icons.js.map +1 -1
  69. package/build-module/guide/index.js +14 -10
  70. package/build-module/guide/index.js.map +1 -1
  71. package/build-module/guide/page-control.js +1 -3
  72. package/build-module/guide/page-control.js.map +1 -1
  73. package/build-module/item-group/item/hook.js +1 -1
  74. package/build-module/item-group/item/hook.js.map +1 -1
  75. package/build-module/item-group/styles.js +13 -11
  76. package/build-module/item-group/styles.js.map +1 -1
  77. package/build-module/mobile/bottom-sheet/cell.native.js +2 -1
  78. package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
  79. package/build-module/mobile/image/index.native.js +4 -3
  80. package/build-module/mobile/image/index.native.js.map +1 -1
  81. package/build-module/navigator/navigator-provider/component.js +18 -10
  82. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  83. package/build-module/number-control/index.js +8 -5
  84. package/build-module/number-control/index.js.map +1 -1
  85. package/build-module/number-control/styles/number-control-styles.js +7 -14
  86. package/build-module/number-control/styles/number-control-styles.js.map +1 -1
  87. package/build-module/query-controls/index.js +1 -0
  88. package/build-module/query-controls/index.js.map +1 -1
  89. package/build-module/query-controls/index.native.js +1 -0
  90. package/build-module/query-controls/index.native.js.map +1 -1
  91. package/build-module/range-control/index.js +6 -1
  92. package/build-module/range-control/index.js.map +1 -1
  93. package/build-module/range-control/input-range.js.map +1 -1
  94. package/build-module/range-control/styles/range-control-styles.js +35 -36
  95. package/build-module/range-control/styles/range-control-styles.js.map +1 -1
  96. package/build-module/select-control/index.js +2 -1
  97. package/build-module/select-control/index.js.map +1 -1
  98. package/build-module/text-control/index.js +2 -2
  99. package/build-module/text-control/index.js.map +1 -1
  100. package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js +11 -7
  101. package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -1
  102. package/build-module/unit-control/index.js +3 -2
  103. package/build-module/unit-control/index.js.map +1 -1
  104. package/build-module/z-stack/component.js +5 -3
  105. package/build-module/z-stack/component.js.map +1 -1
  106. package/build-module/z-stack/styles.js +22 -44
  107. package/build-module/z-stack/styles.js.map +1 -1
  108. package/build-style/style-rtl.css +22 -35
  109. package/build-style/style.css +22 -35
  110. package/build-types/button/deprecated.d.ts +6 -6
  111. package/build-types/button/index.d.ts.map +1 -1
  112. package/build-types/button/types.d.ts +16 -9
  113. package/build-types/button/types.d.ts.map +1 -1
  114. package/build-types/color-picker/styles.d.ts +2 -1
  115. package/build-types/color-picker/styles.d.ts.map +1 -1
  116. package/build-types/confirm-dialog/component.d.ts.map +1 -1
  117. package/build-types/font-size-picker/index.d.ts.map +1 -1
  118. package/build-types/font-size-picker/styles.d.ts +0 -6
  119. package/build-types/font-size-picker/styles.d.ts.map +1 -1
  120. package/build-types/form-token-field/styles.d.ts.map +1 -1
  121. package/build-types/guide/icons.d.ts +1 -3
  122. package/build-types/guide/icons.d.ts.map +1 -1
  123. package/build-types/guide/index.d.ts.map +1 -1
  124. package/build-types/guide/page-control.d.ts.map +1 -1
  125. package/build-types/item-group/item/hook.d.ts.map +1 -1
  126. package/build-types/item-group/stories/index.d.ts.map +1 -1
  127. package/build-types/item-group/styles.d.ts +1 -1
  128. package/build-types/item-group/styles.d.ts.map +1 -1
  129. package/build-types/navigator/navigator-back-button/component.d.ts +1 -1
  130. package/build-types/navigator/navigator-back-button/hook.d.ts +1 -1
  131. package/build-types/navigator/navigator-button/component.d.ts +1 -1
  132. package/build-types/navigator/navigator-button/hook.d.ts +1 -1
  133. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  134. package/build-types/navigator/navigator-to-parent-button/component.d.ts +1 -1
  135. package/build-types/navigator/types.d.ts +3 -1
  136. package/build-types/navigator/types.d.ts.map +1 -1
  137. package/build-types/number-control/index.d.ts.map +1 -1
  138. package/build-types/number-control/styles/number-control-styles.d.ts +5 -3
  139. package/build-types/number-control/styles/number-control-styles.d.ts.map +1 -1
  140. package/build-types/query-controls/index.d.ts.map +1 -1
  141. package/build-types/range-control/index.d.ts +15 -2
  142. package/build-types/range-control/index.d.ts.map +1 -1
  143. package/build-types/range-control/input-range.d.ts.map +1 -1
  144. package/build-types/range-control/styles/range-control-styles.d.ts +4 -2
  145. package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
  146. package/build-types/range-control/types.d.ts +6 -0
  147. package/build-types/range-control/types.d.ts.map +1 -1
  148. package/build-types/select-control/index.d.ts.map +1 -1
  149. package/build-types/select-control/types.d.ts +6 -0
  150. package/build-types/select-control/types.d.ts.map +1 -1
  151. package/build-types/text-control/test/text-control.d.ts +2 -0
  152. package/build-types/text-control/test/text-control.d.ts.map +1 -0
  153. package/build-types/toolbar/toolbar-button/index.d.ts +6 -6
  154. package/build-types/unit-control/index.d.ts.map +1 -1
  155. package/build-types/z-stack/component.d.ts.map +1 -1
  156. package/build-types/z-stack/stories/index.d.ts.map +1 -1
  157. package/build-types/z-stack/styles.d.ts +5 -4
  158. package/build-types/z-stack/styles.d.ts.map +1 -1
  159. package/package.json +22 -22
  160. package/src/button/README.md +15 -0
  161. package/src/button/index.native.js +9 -3
  162. package/src/button/index.tsx +11 -4
  163. package/src/button/style.native.scss +9 -0
  164. package/src/button/style.scss +13 -12
  165. package/src/button/test/index.tsx +13 -0
  166. package/src/button/types.ts +17 -9
  167. package/src/confirm-dialog/component.tsx +12 -2
  168. package/src/confirm-dialog/stories/index.js +8 -15
  169. package/src/confirm-dialog/test/index.js +42 -0
  170. package/src/dropdown-menu/style.scss +9 -13
  171. package/src/font-size-picker/index.tsx +9 -5
  172. package/src/font-size-picker/styles.ts +0 -10
  173. package/src/form-token-field/styles.ts +2 -0
  174. package/src/guide/icons.tsx +2 -7
  175. package/src/guide/index.tsx +14 -13
  176. package/src/guide/page-control.tsx +1 -5
  177. package/src/guide/style.scss +8 -24
  178. package/src/item-group/item/hook.ts +2 -1
  179. package/src/item-group/stories/index.tsx +8 -3
  180. package/src/item-group/styles.ts +39 -28
  181. package/src/mobile/bottom-sheet/cell.native.js +1 -0
  182. package/src/mobile/image/index.native.js +8 -6
  183. package/src/mobile/image/style.native.scss +5 -1
  184. package/src/modal/style.scss +3 -2
  185. package/src/navigator/navigator-provider/component.tsx +30 -23
  186. package/src/navigator/types.ts +4 -1
  187. package/src/number-control/index.tsx +6 -4
  188. package/src/number-control/styles/number-control-styles.ts +8 -16
  189. package/src/placeholder/style.scss +5 -0
  190. package/src/query-controls/index.native.js +1 -0
  191. package/src/query-controls/index.tsx +1 -0
  192. package/src/range-control/index.tsx +14 -2
  193. package/src/range-control/input-range.tsx +0 -1
  194. package/src/range-control/styles/range-control-styles.ts +12 -3
  195. package/src/range-control/types.ts +6 -0
  196. package/src/select-control/index.tsx +1 -0
  197. package/src/select-control/types.ts +6 -0
  198. package/src/text-control/index.tsx +2 -2
  199. package/src/text-control/test/text-control.tsx +61 -0
  200. package/src/toolbar/toolbar-group/style.native.scss +2 -3
  201. package/src/toolbar/toolbar-group/toolbar-group-container.native.js +12 -17
  202. package/src/tooltip/README.md +1 -1
  203. package/src/unit-control/index.tsx +3 -2
  204. package/src/unit-control/test/index.tsx +5 -2
  205. package/src/z-stack/component.tsx +4 -2
  206. package/src/z-stack/stories/index.tsx +6 -13
  207. package/src/z-stack/styles.ts +23 -24
  208. package/tsconfig.tsbuildinfo +1 -1
@@ -1,31 +1,26 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { View } from 'react-native';
4
+ import { StyleSheet, View } from 'react-native';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { withPreferredColorScheme } from '@wordpress/compose';
9
+ import { usePreferredColorSchemeStyle } from '@wordpress/compose';
10
10
 
11
11
  /**
12
12
  * Internal dependencies
13
13
  */
14
14
  import styles from './style.scss';
15
15
 
16
- const ToolbarGroupContainer = ( {
17
- getStylesFromColorScheme,
18
- passedStyle,
19
- children,
20
- } ) => (
21
- <View
22
- style={ [
23
- getStylesFromColorScheme( styles.container, styles.containerDark ),
24
- passedStyle,
25
- ] }
26
- >
27
- { children }
28
- </View>
29
- );
16
+ const ToolbarGroupContainer = ( { passedStyle, children } ) => {
17
+ const groupStyles = [
18
+ usePreferredColorSchemeStyle( styles.container, styles.containerDark ),
19
+ { borderLeftWidth: StyleSheet.hairlineWidth },
20
+ passedStyle,
21
+ ];
30
22
 
31
- export default withPreferredColorScheme( ToolbarGroupContainer );
23
+ return <View style={ groupStyles }>{ children }</View>;
24
+ };
25
+
26
+ export default ToolbarGroupContainer;
@@ -28,7 +28,7 @@ The direction in which the tooltip should open relative to its parent node. Spec
28
28
 
29
29
  - Type: `String`
30
30
  - Required: No
31
- - Default: `"top center"`
31
+ - Default: `"bottom"`
32
32
 
33
33
  ### children
34
34
 
@@ -24,6 +24,7 @@ import {
24
24
  getValidParsedQuantityAndUnit,
25
25
  } from './utils';
26
26
  import { useControlledState } from '../utils/hooks';
27
+ import { escapeRegExp } from '../utils/strings';
27
28
  import type { UnitControlProps, UnitControlOnChangeCallback } from './types';
28
29
 
29
30
  function UnforwardedUnitControl(
@@ -76,9 +77,9 @@ function UnforwardedUnitControl(
76
77
  );
77
78
  const [ { value: firstUnitValue = '' } = {}, ...rest ] = list;
78
79
  const firstCharacters = rest.reduce( ( carry, { value } ) => {
79
- const first = value?.substring( 0, 1 ) || '';
80
+ const first = escapeRegExp( value?.substring( 0, 1 ) || '' );
80
81
  return carry.includes( first ) ? carry : `${ carry }|${ first }`;
81
- }, firstUnitValue.substring( 0, 1 ) );
82
+ }, escapeRegExp( firstUnitValue.substring( 0, 1 ) ) );
82
83
  return [ list, new RegExp( `^(?:${ firstCharacters })$`, 'i' ) ];
83
84
  }, [ nonNullValueProp, unitProp, unitsProp ] );
84
85
  const [ parsedQuantity, parsedUnit ] = getParsedQuantityAndUnit(
@@ -373,18 +373,21 @@ describe( 'UnitControl', () => {
373
373
  const units = [
374
374
  { value: 'pt', label: 'pt', default: 0 },
375
375
  { value: 'vmax', label: 'vmax', default: 10 },
376
+ // Proves that units with regex control characters don't error.
377
+ { value: '+', label: '+', default: 10 },
376
378
  ];
377
379
 
378
380
  render( <UnitControl units={ units } /> );
379
381
 
380
382
  const options = getSelectOptions();
381
383
 
382
- expect( options.length ).toBe( 2 );
384
+ expect( options.length ).toBe( 3 );
383
385
 
384
- const [ pt, vmax ] = options;
386
+ const [ pt, vmax, plus ] = options;
385
387
 
386
388
  expect( pt.value ).toBe( 'pt' );
387
389
  expect( vmax.value ).toBe( 'vmax' );
390
+ expect( plus.value ).toBe( '+' );
388
391
  } );
389
392
 
390
393
  it( 'should reset value on unit change, if unit has default value', async () => {
@@ -35,13 +35,14 @@ function UnconnectedZStack(
35
35
 
36
36
  const clonedChildren = validChildren.map( ( child, index ) => {
37
37
  const zIndex = isReversed ? childrenLastIndex - index : index;
38
- const offsetAmount = offset * index;
38
+ // Only when the component is layered, the offset needs to be multiplied by
39
+ // the item's index, so that items can correctly stack at the right distance
40
+ const offsetAmount = isLayered ? offset * index : offset;
39
41
 
40
42
  const key = isValidElement( child ) ? child.key : index;
41
43
 
42
44
  return (
43
45
  <ZStackChildView
44
- isLayered={ isLayered }
45
46
  offsetAmount={ offsetAmount }
46
47
  zIndex={ zIndex }
47
48
  key={ key }
@@ -55,6 +56,7 @@ function UnconnectedZStack(
55
56
  <ZStackView
56
57
  { ...otherProps }
57
58
  className={ className }
59
+ isLayered={ isLayered }
58
60
  ref={ forwardedRef }
59
61
  >
60
62
  { clonedChildren }
@@ -8,7 +8,6 @@ import type { ComponentMeta, ComponentStory } from '@storybook/react';
8
8
  * Internal dependencies
9
9
  */
10
10
  import { Elevation } from '../../elevation';
11
- import { HStack } from '../../h-stack';
12
11
  import { View } from '../../view';
13
12
  import { ZStack } from '..';
14
13
 
@@ -55,18 +54,12 @@ const Avatar = ( {
55
54
 
56
55
  const Template: ComponentStory< typeof ZStack > = ( args ) => {
57
56
  return (
58
- <View>
59
- <HStack>
60
- <View>
61
- <ZStack { ...args }>
62
- <Avatar backgroundColor="#444" />
63
- <Avatar backgroundColor="#777" />
64
- <Avatar backgroundColor="#aaa" />
65
- <Avatar backgroundColor="#fff" />
66
- </ZStack>
67
- </View>
68
- </HStack>
69
- </View>
57
+ <ZStack { ...args }>
58
+ <Avatar backgroundColor="#444" />
59
+ <Avatar backgroundColor="#777" />
60
+ <Avatar backgroundColor="#aaa" />
61
+ <Avatar backgroundColor="#fff" />
62
+ </ZStack>
70
63
  );
71
64
  };
72
65
 
@@ -4,36 +4,35 @@
4
4
  import { css } from '@emotion/react';
5
5
  import styled from '@emotion/styled';
6
6
 
7
- /**
8
- * Internal dependencies
9
- */
10
- import { rtl } from '../utils';
11
-
12
- export const ZStackView = styled.div`
13
- display: flex;
14
- position: relative;
15
- `;
16
-
17
7
  export const ZStackChildView = styled.div< {
18
- isLayered: boolean;
19
8
  offsetAmount: number;
20
9
  zIndex: number;
21
10
  } >`
22
- ${ ( { isLayered, offsetAmount } ) =>
23
- isLayered
24
- ? css( rtl( { marginLeft: offsetAmount } )() )
25
- : css( rtl( { right: offsetAmount * -1 } )() ) }
11
+ &:not( :first-of-type ) {
12
+ ${ ( { offsetAmount } ) =>
13
+ css( {
14
+ marginInlineStart: offsetAmount,
15
+ } ) };
16
+ }
26
17
 
27
- ${ ( { isLayered } ) =>
28
- isLayered ? positionAbsolute : positionRelative }
29
-
30
- ${ ( { zIndex } ) => css( { zIndex } ) }
31
- `;
32
-
33
- const positionAbsolute = css`
34
- position: absolute;
18
+ ${ ( { zIndex } ) => css( { zIndex } ) };
35
19
  `;
36
20
 
37
- const positionRelative = css`
21
+ export const ZStackView = styled.div< {
22
+ isLayered: boolean;
23
+ } >`
24
+ display: inline-grid;
25
+ grid-auto-flow: column;
38
26
  position: relative;
27
+
28
+ & > ${ ZStackChildView } {
29
+ position: relative;
30
+ justify-self: start;
31
+
32
+ ${ ( { isLayered } ) =>
33
+ isLayered
34
+ ? // When `isLayered` is true, all items overlap in the same grid cell
35
+ css( { gridRowStart: 1, gridColumnStart: 1 } )
36
+ : undefined };
37
+ }
39
38
  `;