@wordpress/components 19.3.0 → 19.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 (308) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/CONTRIBUTING.md +1 -1
  3. package/README.md +8 -4
  4. package/build/base-field/hook.js +1 -1
  5. package/build/base-field/hook.js.map +1 -1
  6. package/build/button/deprecated.js +2 -1
  7. package/build/button/deprecated.js.map +1 -1
  8. package/build/button/index.js +2 -1
  9. package/build/button/index.js.map +1 -1
  10. package/build/card/card/component.js +1 -1
  11. package/build/card/card/component.js.map +1 -1
  12. package/build/card/card/hook.js +1 -1
  13. package/build/card/card/hook.js.map +1 -1
  14. package/build/card/card-body/hook.js +1 -1
  15. package/build/card/card-body/hook.js.map +1 -1
  16. package/build/card/card-divider/hook.js +1 -1
  17. package/build/card/card-divider/hook.js.map +1 -1
  18. package/build/card/card-footer/hook.js +1 -1
  19. package/build/card/card-footer/hook.js.map +1 -1
  20. package/build/card/card-header/hook.js +1 -1
  21. package/build/card/card-header/hook.js.map +1 -1
  22. package/build/card/card-media/hook.js +1 -1
  23. package/build/card/card-media/hook.js.map +1 -1
  24. package/build/circular-option-picker/index.js +2 -0
  25. package/build/circular-option-picker/index.js.map +1 -1
  26. package/build/color-indicator/index.js +2 -0
  27. package/build/color-indicator/index.js.map +1 -1
  28. package/build/color-palette/index.js +2 -0
  29. package/build/color-palette/index.js.map +1 -1
  30. package/build/color-picker/color-display.js.map +1 -1
  31. package/build/color-picker/color-input.js.map +1 -1
  32. package/build/color-picker/component.js +1 -1
  33. package/build/color-picker/component.js.map +1 -1
  34. package/build/color-picker/use-deprecated-props.js +2 -0
  35. package/build/color-picker/use-deprecated-props.js.map +1 -1
  36. package/build/date-time/time.js +1 -1
  37. package/build/date-time/time.js.map +1 -1
  38. package/build/dropdown/index.js +3 -3
  39. package/build/dropdown/index.js.map +1 -1
  40. package/build/elevation/hook.js +5 -5
  41. package/build/elevation/hook.js.map +1 -1
  42. package/build/flex/flex/hook.js +4 -4
  43. package/build/flex/flex/hook.js.map +1 -1
  44. package/build/grid/hook.js +2 -2
  45. package/build/grid/hook.js.map +1 -1
  46. package/build/item-group/item/hook.js +1 -1
  47. package/build/item-group/item/hook.js.map +1 -1
  48. package/build/modal/index.js +1 -12
  49. package/build/modal/index.js.map +1 -1
  50. package/build/navigator/context.js +2 -2
  51. package/build/navigator/context.js.map +1 -1
  52. package/build/navigator/navigator-provider/component.js +18 -25
  53. package/build/navigator/navigator-provider/component.js.map +1 -1
  54. package/build/navigator/navigator-screen/component.js +39 -13
  55. package/build/navigator/navigator-screen/component.js.map +1 -1
  56. package/build/navigator/use-navigator.js +4 -4
  57. package/build/navigator/use-navigator.js.map +1 -1
  58. package/build/placeholder/index.js +4 -4
  59. package/build/placeholder/index.js.map +1 -1
  60. package/build/scrollable/hook.js +1 -1
  61. package/build/scrollable/hook.js.map +1 -1
  62. package/build/slot-fill/bubbles-virtually/fill.js +11 -2
  63. package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
  64. package/build/spinner/index.js +44 -5
  65. package/build/spinner/index.js.map +1 -1
  66. package/build/spinner/styles.js +56 -0
  67. package/build/spinner/styles.js.map +1 -0
  68. package/build/surface/hook.js +1 -1
  69. package/build/surface/hook.js.map +1 -1
  70. package/build/text/hook.js +5 -5
  71. package/build/text/hook.js.map +1 -1
  72. package/build/tip/index.js +4 -8
  73. package/build/tip/index.js.map +1 -1
  74. package/build/toggle-group-control/toggle-group-control/component.js +1 -1
  75. package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
  76. package/build/tools-panel/tools-panel/hook.js +7 -7
  77. package/build/tools-panel/tools-panel/hook.js.map +1 -1
  78. package/build/tools-panel/tools-panel-header/hook.js +3 -3
  79. package/build/tools-panel/tools-panel-header/hook.js.map +1 -1
  80. package/build/tools-panel/tools-panel-item/hook.js +1 -1
  81. package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
  82. package/build/tree-grid/index.js +13 -6
  83. package/build/tree-grid/index.js.map +1 -1
  84. package/build/truncate/hook.js +2 -2
  85. package/build/truncate/hook.js.map +1 -1
  86. package/build/utils/config-values.js +1 -1
  87. package/build/utils/config-values.js.map +1 -1
  88. package/build-module/base-field/hook.js +1 -1
  89. package/build-module/base-field/hook.js.map +1 -1
  90. package/build-module/button/deprecated.js +2 -1
  91. package/build-module/button/deprecated.js.map +1 -1
  92. package/build-module/button/index.js +2 -1
  93. package/build-module/button/index.js.map +1 -1
  94. package/build-module/card/card/component.js +1 -1
  95. package/build-module/card/card/component.js.map +1 -1
  96. package/build-module/card/card/hook.js +1 -1
  97. package/build-module/card/card/hook.js.map +1 -1
  98. package/build-module/card/card-body/hook.js +1 -1
  99. package/build-module/card/card-body/hook.js.map +1 -1
  100. package/build-module/card/card-divider/hook.js +1 -1
  101. package/build-module/card/card-divider/hook.js.map +1 -1
  102. package/build-module/card/card-footer/hook.js +1 -1
  103. package/build-module/card/card-footer/hook.js.map +1 -1
  104. package/build-module/card/card-header/hook.js +1 -1
  105. package/build-module/card/card-header/hook.js.map +1 -1
  106. package/build-module/card/card-media/hook.js +1 -1
  107. package/build-module/card/card-media/hook.js.map +1 -1
  108. package/build-module/circular-option-picker/index.js +1 -0
  109. package/build-module/circular-option-picker/index.js.map +1 -1
  110. package/build-module/color-indicator/index.js +1 -0
  111. package/build-module/color-indicator/index.js.map +1 -1
  112. package/build-module/color-palette/index.js +1 -0
  113. package/build-module/color-palette/index.js.map +1 -1
  114. package/build-module/color-picker/color-display.js.map +1 -1
  115. package/build-module/color-picker/color-input.js.map +1 -1
  116. package/build-module/color-picker/component.js +1 -1
  117. package/build-module/color-picker/component.js.map +1 -1
  118. package/build-module/color-picker/use-deprecated-props.js +2 -0
  119. package/build-module/color-picker/use-deprecated-props.js.map +1 -1
  120. package/build-module/date-time/time.js +1 -1
  121. package/build-module/date-time/time.js.map +1 -1
  122. package/build-module/dropdown/index.js +3 -3
  123. package/build-module/dropdown/index.js.map +1 -1
  124. package/build-module/elevation/hook.js +5 -5
  125. package/build-module/elevation/hook.js.map +1 -1
  126. package/build-module/flex/flex/hook.js +4 -4
  127. package/build-module/flex/flex/hook.js.map +1 -1
  128. package/build-module/grid/hook.js +2 -2
  129. package/build-module/grid/hook.js.map +1 -1
  130. package/build-module/item-group/item/hook.js +1 -1
  131. package/build-module/item-group/item/hook.js.map +1 -1
  132. package/build-module/modal/index.js +1 -11
  133. package/build-module/modal/index.js.map +1 -1
  134. package/build-module/navigator/context.js +2 -2
  135. package/build-module/navigator/context.js.map +1 -1
  136. package/build-module/navigator/navigator-provider/component.js +18 -25
  137. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  138. package/build-module/navigator/navigator-screen/component.js +39 -15
  139. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  140. package/build-module/navigator/use-navigator.js +4 -4
  141. package/build-module/navigator/use-navigator.js.map +1 -1
  142. package/build-module/placeholder/index.js +4 -4
  143. package/build-module/placeholder/index.js.map +1 -1
  144. package/build-module/scrollable/hook.js +1 -1
  145. package/build-module/scrollable/hook.js.map +1 -1
  146. package/build-module/slot-fill/bubbles-virtually/fill.js +11 -2
  147. package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
  148. package/build-module/spinner/index.js +40 -5
  149. package/build-module/spinner/index.js.map +1 -1
  150. package/build-module/spinner/styles.js +49 -0
  151. package/build-module/spinner/styles.js.map +1 -0
  152. package/build-module/surface/hook.js +1 -1
  153. package/build-module/surface/hook.js.map +1 -1
  154. package/build-module/text/hook.js +5 -5
  155. package/build-module/text/hook.js.map +1 -1
  156. package/build-module/tip/index.js +4 -8
  157. package/build-module/tip/index.js.map +1 -1
  158. package/build-module/toggle-group-control/toggle-group-control/component.js +1 -1
  159. package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
  160. package/build-module/tools-panel/tools-panel/hook.js +7 -7
  161. package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
  162. package/build-module/tools-panel/tools-panel-header/hook.js +3 -3
  163. package/build-module/tools-panel/tools-panel-header/hook.js.map +1 -1
  164. package/build-module/tools-panel/tools-panel-item/hook.js +1 -1
  165. package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
  166. package/build-module/tree-grid/index.js +12 -6
  167. package/build-module/tree-grid/index.js.map +1 -1
  168. package/build-module/truncate/hook.js +2 -2
  169. package/build-module/truncate/hook.js.map +1 -1
  170. package/build-module/utils/config-values.js +1 -1
  171. package/build-module/utils/config-values.js.map +1 -1
  172. package/build-style/style-rtl.css +12 -2
  173. package/build-style/style.css +12 -2
  174. package/build-types/button/index.d.ts.map +1 -1
  175. package/build-types/circular-option-picker/index.d.ts +31 -0
  176. package/build-types/circular-option-picker/index.d.ts.map +1 -0
  177. package/build-types/color-palette/index.d.ts +16 -0
  178. package/build-types/color-palette/index.d.ts.map +1 -0
  179. package/build-types/color-palette/styles.d.ts +8 -0
  180. package/build-types/color-palette/styles.d.ts.map +1 -0
  181. package/build-types/color-picker/color-display.d.ts +14 -0
  182. package/build-types/color-picker/color-display.d.ts.map +1 -0
  183. package/build-types/color-picker/color-input.d.ts +14 -0
  184. package/build-types/color-picker/color-input.d.ts.map +1 -0
  185. package/build-types/color-picker/component.d.ts +11 -0
  186. package/build-types/color-picker/component.d.ts.map +1 -0
  187. package/build-types/color-picker/hex-input.d.ts +13 -0
  188. package/build-types/color-picker/hex-input.d.ts.map +1 -0
  189. package/build-types/color-picker/hsl-input.d.ts +13 -0
  190. package/build-types/color-picker/hsl-input.d.ts.map +1 -0
  191. package/build-types/color-picker/index.d.ts +5 -0
  192. package/build-types/color-picker/index.d.ts.map +1 -0
  193. package/build-types/color-picker/input-with-slider.d.ts +12 -0
  194. package/build-types/color-picker/input-with-slider.d.ts.map +1 -0
  195. package/build-types/color-picker/legacy-adapter.d.ts +6 -0
  196. package/build-types/color-picker/legacy-adapter.d.ts.map +1 -0
  197. package/build-types/color-picker/picker.d.ts +10 -0
  198. package/build-types/color-picker/picker.d.ts.map +1 -0
  199. package/build-types/color-picker/rgb-input.d.ts +13 -0
  200. package/build-types/color-picker/rgb-input.d.ts.map +1 -0
  201. package/build-types/color-picker/styles.d.ts +76 -0
  202. package/build-types/color-picker/styles.d.ts.map +1 -0
  203. package/build-types/color-picker/types.d.ts +2 -0
  204. package/build-types/color-picker/types.d.ts.map +1 -0
  205. package/build-types/color-picker/use-deprecated-props.d.ts +49 -0
  206. package/build-types/color-picker/use-deprecated-props.d.ts.map +1 -0
  207. package/build-types/dropdown/index.d.ts +1 -13
  208. package/build-types/dropdown/index.d.ts.map +1 -1
  209. package/build-types/elevation/hook.d.ts.map +1 -1
  210. package/build-types/flex/flex/hook.d.ts.map +1 -1
  211. package/build-types/grid/hook.d.ts.map +1 -1
  212. package/build-types/navigator/navigator-provider/component.d.ts +4 -4
  213. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  214. package/build-types/navigator/navigator-screen/component.d.ts +4 -4
  215. package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
  216. package/build-types/navigator/types.d.ts +5 -3
  217. package/build-types/navigator/types.d.ts.map +1 -1
  218. package/build-types/resizable-box/index.d.ts +1 -1
  219. package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
  220. package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
  221. package/build-types/spinner/index.d.ts +18 -1
  222. package/build-types/spinner/index.d.ts.map +1 -1
  223. package/build-types/spinner/styles.d.ts +13 -0
  224. package/build-types/spinner/styles.d.ts.map +1 -0
  225. package/build-types/surface/hook.d.ts.map +1 -1
  226. package/build-types/text/hook.d.ts.map +1 -1
  227. package/build-types/tip/index.d.ts.map +1 -1
  228. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  229. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  230. package/build-types/unit-control/index.d.ts +3 -2
  231. package/build-types/unit-control/index.d.ts.map +1 -1
  232. package/build-types/unit-control/types.d.ts +2 -1
  233. package/build-types/unit-control/types.d.ts.map +1 -1
  234. package/build-types/utils/config-values.d.ts +1 -1
  235. package/package.json +16 -17
  236. package/src/base-field/hook.js +1 -1
  237. package/src/button/deprecated.js +1 -0
  238. package/src/button/index.js +1 -0
  239. package/src/card/card/component.js +1 -1
  240. package/src/card/card/hook.js +1 -1
  241. package/src/card/card-body/hook.js +1 -1
  242. package/src/card/card-divider/hook.js +1 -1
  243. package/src/card/card-footer/hook.js +1 -1
  244. package/src/card/card-header/hook.js +1 -1
  245. package/src/card/card-media/hook.js +1 -1
  246. package/src/circular-option-picker/index.js +1 -0
  247. package/src/color-indicator/index.js +2 -0
  248. package/src/color-palette/index.js +1 -0
  249. package/src/color-palette/test/__snapshots__/index.js.snap +0 -1
  250. package/src/color-picker/color-display.tsx +1 -1
  251. package/src/color-picker/color-input.tsx +1 -1
  252. package/src/color-picker/component.tsx +1 -1
  253. package/src/color-picker/use-deprecated-props.ts +2 -0
  254. package/src/combobox-control/stories/index.js +6 -2
  255. package/src/combobox-control/style.scss +2 -2
  256. package/src/date-time/README.md +4 -4
  257. package/src/date-time/test/time.js +2 -2
  258. package/src/date-time/time.js +2 -2
  259. package/src/dropdown/index.js +14 -13
  260. package/src/elevation/hook.js +1 -0
  261. package/src/flex/flex/hook.js +1 -0
  262. package/src/grid/hook.js +1 -0
  263. package/src/item-group/item/hook.ts +1 -1
  264. package/src/item-group/stories/index.js +2 -2
  265. package/src/mobile/link-settings/test/edit.native.js +5 -5
  266. package/src/modal/index.js +1 -10
  267. package/src/navigator/context.ts +2 -2
  268. package/src/navigator/navigator-provider/README.md +11 -9
  269. package/src/navigator/navigator-provider/component.tsx +16 -25
  270. package/src/navigator/navigator-screen/component.tsx +55 -15
  271. package/src/navigator/stories/index.js +19 -5
  272. package/src/navigator/test/index.js +77 -25
  273. package/src/navigator/types.ts +5 -3
  274. package/src/navigator/use-navigator.ts +3 -3
  275. package/src/placeholder/index.js +8 -6
  276. package/src/placeholder/style.scss +12 -0
  277. package/src/placeholder/test/index.js +18 -1
  278. package/src/scrollable/hook.js +1 -1
  279. package/src/slot-fill/bubbles-virtually/fill.js +12 -1
  280. package/src/spinner/README.md +10 -10
  281. package/src/spinner/index.js +42 -3
  282. package/src/spinner/stories/index.js +36 -3
  283. package/src/spinner/styles.js +47 -0
  284. package/src/surface/hook.js +1 -0
  285. package/src/text/hook.js +1 -0
  286. package/src/tip/index.js +2 -4
  287. package/src/toggle-group-control/toggle-group-control/component.tsx +1 -1
  288. package/src/tools-panel/stories/index.js +20 -1
  289. package/src/tools-panel/test/__snapshots__/index.js.snap +0 -1
  290. package/src/tools-panel/test/index.js +31 -1
  291. package/src/tools-panel/tools-panel/hook.ts +14 -9
  292. package/src/tools-panel/tools-panel-header/hook.ts +3 -3
  293. package/src/tools-panel/tools-panel-item/hook.ts +1 -0
  294. package/src/tree-grid/index.js +19 -5
  295. package/src/truncate/hook.js +1 -1
  296. package/src/unit-control/types.ts +2 -1
  297. package/src/utils/config-values.js +1 -1
  298. package/src/utils/hooks/stories/use-cx.js +121 -44
  299. package/tsconfig.json +3 -0
  300. package/tsconfig.tsbuildinfo +1 -1
  301. package/build/spinner/styles/spinner-styles.js +0 -40
  302. package/build/spinner/styles/spinner-styles.js.map +0 -1
  303. package/build-module/spinner/styles/spinner-styles.js +0 -28
  304. package/build-module/spinner/styles/spinner-styles.js.map +0 -1
  305. package/build-types/spinner/styles/spinner-styles.d.ts +0 -5
  306. package/build-types/spinner/styles/spinner-styles.d.ts.map +0 -1
  307. package/src/spinner/styles/spinner-styles.js +0 -47
  308. package/src/ui/visually-hidden/README.md +0 -21
@@ -61,7 +61,7 @@ export function useCard( props ) {
61
61
  isRounded && styles.rounded,
62
62
  className
63
63
  );
64
- }, [ className, isBorderless, isRounded ] );
64
+ }, [ className, cx, isBorderless, isRounded ] );
65
65
 
66
66
  const surfaceProps = useSurface( { ...otherProps, className: classes } );
67
67
 
@@ -35,7 +35,7 @@ export function useCardBody( props ) {
35
35
  'components-card__body',
36
36
  className
37
37
  ),
38
- [ className, isShady, size ]
38
+ [ className, cx, isShady, size ]
39
39
  );
40
40
 
41
41
  return {
@@ -30,7 +30,7 @@ export function useCardDivider( props ) {
30
30
  'components-card__divider',
31
31
  className
32
32
  ),
33
- [ className ]
33
+ [ className, cx ]
34
34
  );
35
35
 
36
36
  return {
@@ -38,7 +38,7 @@ export function useCardFooter( props ) {
38
38
  'components-card__footer',
39
39
  className
40
40
  ),
41
- [ className, isBorderless, isShady, size ]
41
+ [ className, cx, isBorderless, isShady, size ]
42
42
  );
43
43
 
44
44
  return {
@@ -37,7 +37,7 @@ export function useCardHeader( props ) {
37
37
  'components-card__header',
38
38
  className
39
39
  ),
40
- [ className, isBorderless, isShady, size ]
40
+ [ className, cx, isBorderless, isShady, size ]
41
41
  );
42
42
 
43
43
  return {
@@ -27,7 +27,7 @@ export function useCardMedia( props ) {
27
27
  'components-card__media',
28
28
  className
29
29
  ),
30
- [ className ]
30
+ [ className, cx ]
31
31
  );
32
32
 
33
33
  return {
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  /**
2
3
  * External dependencies
3
4
  */
@@ -1,3 +1,5 @@
1
+ // @ts-nocheck
2
+
1
3
  /**
2
4
  * External dependencies
3
5
  */
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  /**
2
3
  * External dependencies
3
4
  */
@@ -391,7 +391,6 @@ exports[`ColorPalette should render a dynamic toolbar of colors 1`] = `
391
391
  fill="#000"
392
392
  focusable={false}
393
393
  height={24}
394
- role="img"
395
394
  viewBox="0 0 24 24"
396
395
  width={24}
397
396
  xmlns="http://www.w3.org/2000/svg"
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { colord, extend, Colord } from 'colord';
4
+ import type { Colord } from 'colord';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { colord, extend, Colord } from 'colord';
4
+ import type { Colord } from 'colord';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -73,7 +73,7 @@ const ColorPicker = (
73
73
  } );
74
74
 
75
75
  const safeColordColor = useMemo( () => {
76
- return colord( color );
76
+ return colord( color || '' );
77
77
  }, [ color ] );
78
78
 
79
79
  const debouncedSetColor = useDebounce( setColor );
@@ -83,6 +83,8 @@ function getColorFromLegacyProps( props: LegacyProps ): string | undefined {
83
83
  if ( props.color.hex ) {
84
84
  return props.color.hex;
85
85
  }
86
+
87
+ return undefined;
86
88
  }
87
89
 
88
90
  const transformColorStringToLegacyColor = memoize(
@@ -266,7 +266,7 @@ const mapCountryOption = ( country ) => ( {
266
266
 
267
267
  const countryOptions = countries.map( mapCountryOption );
268
268
 
269
- function CountryCodeComboboxControl() {
269
+ function CountryCodeComboboxControl( { allowReset } ) {
270
270
  const [ value, setValue ] = useState( null );
271
271
 
272
272
  return (
@@ -276,9 +276,13 @@ function CountryCodeComboboxControl() {
276
276
  onChange={ setValue }
277
277
  label="Select a country"
278
278
  options={ countryOptions }
279
+ allowReset={ allowReset }
279
280
  />
280
281
  <p>Value: { value }</p>
281
282
  </>
282
283
  );
283
284
  }
284
- export const _default = () => <CountryCodeComboboxControl />;
285
+ export const _default = CountryCodeComboboxControl.bind( {} );
286
+ _default.args = {
287
+ allowReset: false,
288
+ };
@@ -40,7 +40,7 @@ input.components-combobox-control__input[type="text"] {
40
40
 
41
41
  .components-combobox-control__reset.components-button {
42
42
  display: flex;
43
- height: $grid-unit-30;
44
- min-width: $grid-unit-30;
43
+ height: $grid-unit-20;
44
+ min-width: $grid-unit-20;
45
45
  padding: 0;
46
46
  }
@@ -28,7 +28,7 @@ const MyDateTimePicker = () => {
28
28
  is12Hour={ true }
29
29
  />
30
30
  );
31
- }
31
+ };
32
32
  ```
33
33
 
34
34
  ## Props
@@ -52,7 +52,7 @@ The function called when a new date or time has been selected. It is passed the
52
52
 
53
53
  ### is12Hour
54
54
 
55
- Whether we use a 12-hour clock. With a 12-hour clock, an AM/PM widget is displayed and the time format is assumed to be MM-DD-YYYY.
55
+ Whether we use a 12-hour clock. With a 12-hour clock, an AM/PM widget is displayed and the time format is assumed to be `MM-DD-YYYY` (as opposed to the default format `DD-MM-YYYY`).
56
56
 
57
57
  - Type: `bool`
58
58
  - Required: No
@@ -69,5 +69,5 @@ A callback function which receives a Date object representing a day as an argume
69
69
 
70
70
  A callback invoked when selecting the previous/next month in the date picker. The callback receives the new month date in the ISO format as an argument.
71
71
 
72
- - Type: `Function`
73
- - Required: No
72
+ - Type: `Function`
73
+ - Required: No
@@ -278,7 +278,7 @@ describe( 'TimePicker', () => {
278
278
  screen.getByLabelText( 'Day' )
279
279
  );
280
280
 
281
- expect( monthInputIndex < dayInputIndex ).toBe( true );
281
+ expect( monthInputIndex > dayInputIndex ).toBe( true );
282
282
 
283
283
  rerender(
284
284
  <form aria-label="form">
@@ -299,7 +299,7 @@ describe( 'TimePicker', () => {
299
299
  screen.getByLabelText( 'Day' )
300
300
  );
301
301
 
302
- expect( monthInputIndex > dayInputIndex ).toBe( true );
302
+ expect( monthInputIndex < dayInputIndex ).toBe( true );
303
303
  } );
304
304
 
305
305
  it( 'Should set a time when passed a null currentTime', () => {
@@ -196,13 +196,13 @@ export function TimePicker( { is12Hour, currentTime, onChange } ) {
196
196
 
197
197
  const dayMonthFormat = is12Hour ? (
198
198
  <>
199
- { dayFormat }
200
199
  { monthFormat }
200
+ { dayFormat }
201
201
  </>
202
202
  ) : (
203
203
  <>
204
- { monthFormat }
205
204
  { dayFormat }
205
+ { monthFormat }
206
206
  </>
207
207
  );
208
208
 
@@ -27,19 +27,20 @@ function useObservableState( initialState, onStateChange ) {
27
27
  ];
28
28
  }
29
29
 
30
- export default function Dropdown( {
31
- renderContent,
32
- renderToggle,
33
- position = 'bottom right',
34
- className,
35
- contentClassName,
36
- expandOnMobile,
37
- headerTitle,
38
- focusOnMount,
39
- popoverProps,
40
- onClose,
41
- onToggle,
42
- } ) {
30
+ export default function Dropdown( props ) {
31
+ const {
32
+ renderContent,
33
+ renderToggle,
34
+ position = 'bottom right',
35
+ className,
36
+ contentClassName,
37
+ expandOnMobile,
38
+ headerTitle,
39
+ focusOnMount,
40
+ popoverProps,
41
+ onClose,
42
+ onToggle,
43
+ } = props;
43
44
  const containerRef = useRef();
44
45
  const [ isOpen, setIsOpen ] = useObservableState( false, onToggle );
45
46
 
@@ -112,6 +112,7 @@ export function useElevation( props ) {
112
112
  active,
113
113
  borderRadius,
114
114
  className,
115
+ cx,
115
116
  focus,
116
117
  hover,
117
118
  isInteractive,
@@ -126,6 +126,7 @@ export function useFlex( props ) {
126
126
  }, [
127
127
  align,
128
128
  className,
129
+ cx,
129
130
  direction,
130
131
  expanded,
131
132
  gap,
package/src/grid/hook.js CHANGED
@@ -71,6 +71,7 @@ export default function useGrid( props ) {
71
71
  alignment,
72
72
  className,
73
73
  columnGap,
74
+ cx,
74
75
  gap,
75
76
  gridTemplateColumns,
76
77
  gridTemplateRows,
@@ -48,7 +48,7 @@ export function useItem( props: WordPressComponentProps< ItemProps, 'div' > ) {
48
48
  spacedAround && styles.spacedAround,
49
49
  className
50
50
  ),
51
- [ as, className, size, spacedAround ]
51
+ [ as, className, cx, size, spacedAround ]
52
52
  );
53
53
 
54
54
  const wrapperClassName = cx( styles.itemWrapper );
@@ -145,7 +145,7 @@ const ItemWithChevron = ( {
145
145
 
146
146
  const itemClassName = useMemo(
147
147
  () => cx( ! alwaysVisible && appearingChevron, className ),
148
- [ alwaysVisible, className ]
148
+ [ alwaysVisible, className, cx ]
149
149
  );
150
150
 
151
151
  const chevronIconClassName = useMemo(
@@ -155,7 +155,7 @@ const ItemWithChevron = ( {
155
155
  fill: currentColor;
156
156
  transform: ${ isRtlLayout ? 'scaleX( -100% )' : 'none' };
157
157
  ` ),
158
- [ isRtlLayout ]
158
+ [ cx, isRtlLayout ]
159
159
  );
160
160
 
161
161
  return (
@@ -72,7 +72,7 @@ describe.each( [
72
72
  it( 'should display the LINK SETTINGS with an EMPTY LINK TO field.', async () => {
73
73
  // Arrange
74
74
  const url = 'https://tonytahmouchtest.files.wordpress.com';
75
- const subject = initializeEditor( { initialHtml } );
75
+ const subject = await initializeEditor( { initialHtml } );
76
76
  Clipboard.getString.mockReturnValue( url );
77
77
 
78
78
  // Act
@@ -109,7 +109,7 @@ describe.each( [
109
109
  it( 'should display the LINK PICKER with NO FROM CLIPBOARD CELL.', async () => {
110
110
  // Arrange
111
111
  const url = 'tonytahmouchtest.files.wordpress.com';
112
- const subject = initializeEditor( { initialHtml } );
112
+ const subject = await initializeEditor( { initialHtml } );
113
113
  Clipboard.getString.mockReturnValue( url );
114
114
 
115
115
  // Act
@@ -162,7 +162,7 @@ describe.each( [
162
162
  it( 'should display the LINK PICKER with NO FROM CLIPBOARD CELL.', async () => {
163
163
  // Arrange
164
164
  const url = 'https://tonytahmouchtest.files.wordpress.com';
165
- const subject = initializeEditor( { initialHtml } );
165
+ const subject = await initializeEditor( { initialHtml } );
166
166
  Clipboard.getString.mockReturnValue( url );
167
167
 
168
168
  // Act
@@ -241,7 +241,7 @@ describe.each( [
241
241
  async () => {
242
242
  // Arrange
243
243
  const url = 'https://tonytahmouchtest.files.wordpress.com';
244
- const subject = initializeEditor( { initialHtml } );
244
+ const subject = await initializeEditor( { initialHtml } );
245
245
  Clipboard.getString.mockReturnValue( url );
246
246
 
247
247
  // Act
@@ -308,7 +308,7 @@ describe.each( [
308
308
  async () => {
309
309
  // Arrange
310
310
  const url = 'https://tonytahmouchtest.files.wordpress.com';
311
- const subject = initializeEditor( { initialHtml } );
311
+ const subject = await initializeEditor( { initialHtml } );
312
312
  Clipboard.getString.mockReturnValue( url );
313
313
 
314
314
  // Act
@@ -22,7 +22,6 @@ import {
22
22
  useConstrainedTabbing,
23
23
  useMergeRefs,
24
24
  } from '@wordpress/compose';
25
- import deprecated from '@wordpress/deprecated';
26
25
  import { ESCAPE } from '@wordpress/keycodes';
27
26
  import { __ } from '@wordpress/i18n';
28
27
  import { closeSmall } from '@wordpress/icons';
@@ -45,8 +44,7 @@ function Modal( props, forwardedRef ) {
45
44
  focusOnMount = true,
46
45
  shouldCloseOnEsc = true,
47
46
  shouldCloseOnClickOutside = true,
48
- isDismissable, // Deprecated
49
- isDismissible = isDismissable || true,
47
+ isDismissible = true,
50
48
  /* accessibility */
51
49
  aria = {
52
50
  labelledby: null,
@@ -93,13 +91,6 @@ function Modal( props, forwardedRef ) {
93
91
  };
94
92
  }, [] );
95
93
 
96
- if ( isDismissable ) {
97
- deprecated( 'isDismissable prop of the Modal component', {
98
- since: '5.4',
99
- alternative: 'isDismissible prop (renamed) of the Modal component',
100
- } );
101
- }
102
-
103
94
  function handleEscapeKeyDown( event ) {
104
95
  if (
105
96
  shouldCloseOnEsc &&
@@ -10,7 +10,7 @@ import type { NavigatorContext as NavigatorContextType } from './types';
10
10
 
11
11
  const initialContextValue: NavigatorContextType = {
12
12
  location: {},
13
- push: () => {},
14
- pop: () => {},
13
+ goTo: () => {},
14
+ goBack: () => {},
15
15
  };
16
16
  export const NavigatorContext = createContext( initialContextValue );
@@ -16,19 +16,19 @@ import {
16
16
  } from '@wordpress/components';
17
17
 
18
18
  function NavigatorButton( { path, ...props } ) {
19
- const { push } = useNavigator();
19
+ const { goTo } = useNavigator();
20
20
  return (
21
21
  <Button
22
22
  variant="primary"
23
- onClick={ () => push( path ) }
23
+ onClick={ () => goTo( path ) }
24
24
  { ...props }
25
25
  />
26
26
  );
27
27
  }
28
28
 
29
29
  function NavigatorBackButton( props ) {
30
- const { pop } = useNavigator();
31
- return <Button variant="secondary" onClick={ () => pop() } { ...props } />;
30
+ const { goBack } = useNavigator();
31
+ return <Button variant="secondary" onClick={ () => goBack() } { ...props } />;
32
32
  }
33
33
 
34
34
  const MyNavigation = () => (
@@ -64,15 +64,17 @@ You can retrieve a `navigator` instance by using the `useNavigator` hook.
64
64
 
65
65
  The `navigator` instance has a few properties:
66
66
 
67
- ### `push`: `( path: string, options: NavigateOptions ) => void`
67
+ ### `goTo`: `( path: string, options: NavigateOptions ) => void`
68
68
 
69
- The `push` function allows navigating to a given path. The second argument can augment the navigation operations with different options.
69
+ The `goTo` function allows navigating to a given path. The second argument can augment the navigation operations with different options.
70
70
 
71
- There currently aren't any available options.
71
+ The available options are:
72
72
 
73
- ### `pop`: `() => void`
73
+ - `focusTargetSelector`: `string`. An optional property used to specify the CSS selector used to restore focus on the matching element when navigating back.
74
74
 
75
- The `pop` function allows navigating to the previous path.
75
+ ### `goBack`: `() => void`
76
+
77
+ The `goBack` function allows navigating to the previous path.
76
78
 
77
79
  ### `location`: `NavigatorLocation`
78
80
 
@@ -42,37 +42,25 @@ function NavigatorProvider(
42
42
  >( [
43
43
  {
44
44
  path: initialPath,
45
- isBack: false,
46
- isInitial: true,
47
45
  },
48
46
  ] );
49
47
 
50
- const push: NavigatorContextType[ 'push' ] = useCallback(
51
- ( path, options ) => {
52
- // Force the `isBack` flag to `false` when navigating forward on both the
53
- // previous and the new location.
54
- // Also force the `isInitial` flag to `false` for the new location, to make
55
- // sure it doesn't get overridden by mistake.
48
+ const goTo: NavigatorContextType[ 'goTo' ] = useCallback(
49
+ ( path, options = {} ) => {
56
50
  setLocationHistory( [
57
- ...locationHistory.slice( 0, -1 ),
58
- {
59
- ...locationHistory[ locationHistory.length - 1 ],
60
- isBack: false,
61
- },
51
+ ...locationHistory,
62
52
  {
63
53
  ...options,
64
54
  path,
65
55
  isBack: false,
66
- isInitial: false,
67
56
  },
68
57
  ] );
69
58
  },
70
59
  [ locationHistory ]
71
60
  );
72
61
 
73
- const pop: NavigatorContextType[ 'pop' ] = useCallback( () => {
62
+ const goBack: NavigatorContextType[ 'goBack' ] = useCallback( () => {
74
63
  if ( locationHistory.length > 1 ) {
75
- // Force the `isBack` flag to `true` when navigating back.
76
64
  setLocationHistory( [
77
65
  ...locationHistory.slice( 0, -2 ),
78
66
  {
@@ -85,18 +73,21 @@ function NavigatorProvider(
85
73
 
86
74
  const navigatorContextValue: NavigatorContextType = useMemo(
87
75
  () => ( {
88
- location: locationHistory[ locationHistory.length - 1 ],
89
- push,
90
- pop,
76
+ location: {
77
+ ...locationHistory[ locationHistory.length - 1 ],
78
+ isInitial: locationHistory.length === 1,
79
+ },
80
+ goTo,
81
+ goBack,
91
82
  } ),
92
- [ locationHistory, push, pop ]
83
+ [ locationHistory, goTo, goBack ]
93
84
  );
94
85
 
95
86
  const cx = useCx();
96
87
  const classes = useMemo(
97
88
  // Prevents horizontal overflow while animating screen transitions
98
89
  () => cx( css( { overflowX: 'hidden' } ), className ),
99
- [ className ]
90
+ [ className, cx ]
100
91
  );
101
92
 
102
93
  return (
@@ -120,19 +111,19 @@ function NavigatorProvider(
120
111
  * } from '@wordpress/components';
121
112
  *
122
113
  * function NavigatorButton( { path, ...props } ) {
123
- * const { push } = useNavigator();
114
+ * const { goTo } = useNavigator();
124
115
  * return (
125
116
  * <Button
126
117
  * variant="primary"
127
- * onClick={ () => push( path ) }
118
+ * onClick={ () => goTo( path ) }
128
119
  * { ...props }
129
120
  * />
130
121
  * );
131
122
  * }
132
123
  *
133
124
  * function NavigatorBackButton( props ) {
134
- * const { pop } = useNavigator();
135
- * return <Button variant="secondary" onClick={ () => pop() } { ...props } />;
125
+ * const { goBack } = useNavigator();
126
+ * return <Button variant="secondary" onClick={ () => goBack() } { ...props } />;
136
127
  * }
137
128
  *
138
129
  * const MyNavigation = () => (
@@ -9,8 +9,13 @@ import { css } from '@emotion/react';
9
9
  /**
10
10
  * WordPress dependencies
11
11
  */
12
- import { useContext, useEffect, useState, useMemo } from '@wordpress/element';
13
- import { useReducedMotion, useFocusOnMount } from '@wordpress/compose';
12
+ import { focus } from '@wordpress/dom';
13
+ import { useContext, useEffect, useMemo, useRef } from '@wordpress/element';
14
+ import {
15
+ useReducedMotion,
16
+ useMergeRefs,
17
+ usePrevious,
18
+ } from '@wordpress/compose';
14
19
  import { isRTL } from '@wordpress/i18n';
15
20
 
16
21
  /**
@@ -47,7 +52,9 @@ function NavigatorScreen( props: Props, forwardedRef: Ref< any > ) {
47
52
  const prefersReducedMotion = useReducedMotion();
48
53
  const { location } = useContext( NavigatorContext );
49
54
  const isMatch = location.path === path;
50
- const ref = useFocusOnMount();
55
+ const wrapperRef = useRef< HTMLDivElement >( null );
56
+
57
+ const previousLocation = usePrevious( location );
51
58
 
52
59
  const cx = useCx();
53
60
  const classes = useMemo(
@@ -61,15 +68,44 @@ function NavigatorScreen( props: Props, forwardedRef: Ref< any > ) {
61
68
  } ),
62
69
  className
63
70
  ),
64
- [ className ]
71
+ [ className, cx ]
65
72
  );
66
73
 
67
- // This flag is used to only apply the focus on mount when the actual path changes.
68
- // It avoids the focus to happen on the first render.
69
- const [ hasPathChanged, setHasPathChanged ] = useState( false );
74
+ // Focus restoration
75
+ const isInitialLocation = location.isInitial && ! location.isBack;
70
76
  useEffect( () => {
71
- setHasPathChanged( true );
72
- }, [ path ] );
77
+ // Only attempt to restore focus:
78
+ // - if the current location is not the initial one (to avoid moving focus on page load)
79
+ // - when the screen becomes visible
80
+ // - if the wrapper ref has been assigned
81
+ if ( isInitialLocation || ! isMatch || ! wrapperRef.current ) {
82
+ return;
83
+ }
84
+
85
+ let elementToFocus: HTMLElement | null = null;
86
+
87
+ // When navigating back, if a selector is provided, use it to look for the
88
+ // target element (assumed to be a node inside the current NavigatorScreen)
89
+ if ( location.isBack && previousLocation?.focusTargetSelector ) {
90
+ elementToFocus = wrapperRef.current.querySelector(
91
+ previousLocation.focusTargetSelector
92
+ );
93
+ }
94
+
95
+ // If the previous query didn't run or find any element to focus, fallback
96
+ // to the first tabbable element in the screen (or the screen itself).
97
+ if ( ! elementToFocus ) {
98
+ const firstTabbable = ( focus.tabbable.find(
99
+ wrapperRef.current
100
+ ) as HTMLElement[] )[ 0 ];
101
+
102
+ elementToFocus = firstTabbable ?? wrapperRef.current;
103
+ }
104
+
105
+ elementToFocus.focus();
106
+ }, [ isInitialLocation, isMatch ] );
107
+
108
+ const mergedWrapperRef = useMergeRefs( [ forwardedRef, wrapperRef ] );
73
109
 
74
110
  if ( ! isMatch ) {
75
111
  return null;
@@ -77,7 +113,11 @@ function NavigatorScreen( props: Props, forwardedRef: Ref< any > ) {
77
113
 
78
114
  if ( prefersReducedMotion ) {
79
115
  return (
80
- <View ref={ forwardedRef } className={ classes } { ...otherProps }>
116
+ <View
117
+ ref={ mergedWrapperRef }
118
+ className={ classes }
119
+ { ...otherProps }
120
+ >
81
121
  { children }
82
122
  </View>
83
123
  );
@@ -120,7 +160,7 @@ function NavigatorScreen( props: Props, forwardedRef: Ref< any > ) {
120
160
 
121
161
  return (
122
162
  <motion.div
123
- ref={ hasPathChanged ? ref : undefined }
163
+ ref={ mergedWrapperRef }
124
164
  className={ classes }
125
165
  { ...otherProps }
126
166
  { ...animatedProps }
@@ -142,19 +182,19 @@ function NavigatorScreen( props: Props, forwardedRef: Ref< any > ) {
142
182
  * } from '@wordpress/components';
143
183
  *
144
184
  * function NavigatorButton( { path, ...props } ) {
145
- * const { push } = useNavigator();
185
+ * const { goTo } = useNavigator();
146
186
  * return (
147
187
  * <Button
148
188
  * variant="primary"
149
- * onClick={ () => push( path ) }
189
+ * onClick={ () => goTo( path ) }
150
190
  * { ...props }
151
191
  * />
152
192
  * );
153
193
  * }
154
194
  *
155
195
  * function NavigatorBackButton( props ) {
156
- * const { pop } = useNavigator();
157
- * return <Button variant="secondary" onClick={ () => pop() } { ...props } />;
196
+ * const { goBack } = useNavigator();
197
+ * return <Button variant="secondary" onClick={ () => goBack() } { ...props } />;
158
198
  * }
159
199
  *
160
200
  * const MyNavigation = () => (