@wordpress/components 40.0.0 → 40.1.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 (472) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/CONTRIBUTING.md +2 -0
  3. package/build/border-box-control/border-box-control/component.cjs +37 -5
  4. package/build/border-box-control/border-box-control/component.cjs.map +3 -3
  5. package/build/border-box-control/border-box-control/hook.cjs +24 -3
  6. package/build/border-box-control/border-box-control/hook.cjs.map +3 -3
  7. package/build/border-box-control/border-box-control-linked-button/hook.cjs +2 -2
  8. package/build/border-box-control/border-box-control-linked-button/hook.cjs.map +2 -2
  9. package/build/border-box-control/border-box-control-split-controls/hook.cjs +2 -2
  10. package/build/border-box-control/border-box-control-split-controls/hook.cjs.map +2 -2
  11. package/build/border-box-control/border-box-control-visualizer/hook.cjs +2 -2
  12. package/build/border-box-control/border-box-control-visualizer/hook.cjs.map +2 -2
  13. package/build/color-palette/index.cjs +1 -1
  14. package/build/color-palette/index.cjs.map +2 -2
  15. package/build/composite/context.cjs +9 -2
  16. package/build/composite/context.cjs.map +2 -2
  17. package/build/composite/group-label.cjs +4 -0
  18. package/build/composite/group-label.cjs.map +2 -2
  19. package/build/composite/group.cjs +10 -2
  20. package/build/composite/group.cjs.map +2 -2
  21. package/build/composite/item.cjs +4 -0
  22. package/build/composite/item.cjs.map +3 -3
  23. package/build/context/context-system-provider.cjs +2 -5
  24. package/build/context/context-system-provider.cjs.map +3 -3
  25. package/build/context/use-context-system.cjs +7 -2
  26. package/build/context/use-context-system.cjs.map +2 -2
  27. package/build/disabled/index.cjs +1 -1
  28. package/build/disabled/index.cjs.map +2 -2
  29. package/build/draggable/index.cjs.map +1 -1
  30. package/build/form-token-field/index.cjs +1 -1
  31. package/build/form-token-field/index.cjs.map +2 -2
  32. package/build/icon/index.cjs +30 -12
  33. package/build/icon/index.cjs.map +2 -2
  34. package/build/input-control/styles/input-control-styles.cjs +42 -27
  35. package/build/input-control/styles/input-control-styles.cjs.map +2 -2
  36. package/build/item-group/context.cjs +1 -0
  37. package/build/item-group/context.cjs.map +2 -2
  38. package/build/item-group/item/component.cjs +12 -0
  39. package/build/item-group/item/component.cjs.map +3 -3
  40. package/build/item-group/item/hook.cjs +7 -6
  41. package/build/item-group/item/hook.cjs.map +2 -2
  42. package/build/item-group/item-group/component.cjs +1 -0
  43. package/build/item-group/item-group/component.cjs.map +2 -2
  44. package/build/item-group/item-group/hook.cjs +1 -1
  45. package/build/item-group/item-group/hook.cjs.map +2 -2
  46. package/build/progress-bar/index.cjs +1 -1
  47. package/build/progress-bar/index.cjs.map +2 -2
  48. package/build/resizable-box/index.cjs.map +1 -1
  49. package/build/snackbar/index.cjs +8 -5
  50. package/build/snackbar/index.cjs.map +2 -2
  51. package/build/textarea-control/index.cjs +1 -1
  52. package/build/textarea-control/index.cjs.map +2 -2
  53. package/build/toggle-group-control/context.cjs +8 -2
  54. package/build/toggle-group-control/context.cjs.map +2 -2
  55. package/build/toggle-group-control/toggle-group-control/as-button-group.cjs +5 -2
  56. package/build/toggle-group-control/toggle-group-control/as-button-group.cjs.map +2 -2
  57. package/build/toggle-group-control/toggle-group-control/as-radio-group.cjs +5 -2
  58. package/build/toggle-group-control/toggle-group-control/as-radio-group.cjs.map +2 -2
  59. package/build/toggle-group-control/toggle-group-control/component.cjs +3 -1
  60. package/build/toggle-group-control/toggle-group-control/component.cjs.map +2 -2
  61. package/build/toggle-group-control/toggle-group-control-option/component.cjs +2 -0
  62. package/build/toggle-group-control/toggle-group-control-option/component.cjs.map +2 -2
  63. package/build/toggle-group-control/toggle-group-control-option-base/component.cjs +2 -1
  64. package/build/toggle-group-control/toggle-group-control-option-base/component.cjs.map +2 -2
  65. package/build/toggle-group-control/toggle-group-control-option-icon/component.cjs +2 -0
  66. package/build/toggle-group-control/toggle-group-control-option-icon/component.cjs.map +2 -2
  67. package/build/tools-panel/tools-panel/hook.cjs +102 -106
  68. package/build/tools-panel/tools-panel/hook.cjs.map +2 -2
  69. package/build/tools-panel/tools-panel-item/hook.cjs +33 -33
  70. package/build/tools-panel/tools-panel-item/hook.cjs.map +2 -2
  71. package/build/tree-grid/cell.cjs +4 -0
  72. package/build/tree-grid/cell.cjs.map +2 -2
  73. package/build/tree-grid/roving-tab-index-item.cjs +5 -1
  74. package/build/tree-grid/roving-tab-index-item.cjs.map +2 -2
  75. package/build/tree-grid/row.cjs +6 -1
  76. package/build/tree-grid/row.cjs.map +2 -2
  77. package/build/tree-grid/use-validate-tree-grid-structure.cjs +81 -0
  78. package/build/tree-grid/use-validate-tree-grid-structure.cjs.map +7 -0
  79. package/build/utils/colors-values.cjs +3 -2
  80. package/build/utils/colors-values.cjs.map +2 -2
  81. package/build-module/border-box-control/border-box-control/component.mjs +38 -6
  82. package/build-module/border-box-control/border-box-control/component.mjs.map +2 -2
  83. package/build-module/border-box-control/border-box-control/hook.mjs +14 -3
  84. package/build-module/border-box-control/border-box-control/hook.mjs.map +2 -2
  85. package/build-module/border-box-control/border-box-control-linked-button/hook.mjs +2 -2
  86. package/build-module/border-box-control/border-box-control-linked-button/hook.mjs.map +2 -2
  87. package/build-module/border-box-control/border-box-control-split-controls/hook.mjs +2 -2
  88. package/build-module/border-box-control/border-box-control-split-controls/hook.mjs.map +2 -2
  89. package/build-module/border-box-control/border-box-control-visualizer/hook.mjs +2 -2
  90. package/build-module/border-box-control/border-box-control-visualizer/hook.mjs.map +2 -2
  91. package/build-module/color-palette/index.mjs +1 -1
  92. package/build-module/color-palette/index.mjs.map +2 -2
  93. package/build-module/composite/context.mjs +6 -1
  94. package/build-module/composite/context.mjs.map +2 -2
  95. package/build-module/composite/group-label.mjs +5 -1
  96. package/build-module/composite/group-label.mjs.map +2 -2
  97. package/build-module/composite/group.mjs +11 -3
  98. package/build-module/composite/group.mjs.map +2 -2
  99. package/build-module/composite/item.mjs +4 -0
  100. package/build-module/composite/item.mjs.map +2 -2
  101. package/build-module/context/context-system-provider.mjs +2 -5
  102. package/build-module/context/context-system-provider.mjs.map +3 -3
  103. package/build-module/context/use-context-system.mjs +7 -2
  104. package/build-module/context/use-context-system.mjs.map +2 -2
  105. package/build-module/disabled/index.mjs +1 -1
  106. package/build-module/disabled/index.mjs.map +2 -2
  107. package/build-module/draggable/index.mjs.map +1 -1
  108. package/build-module/form-token-field/index.mjs +1 -1
  109. package/build-module/form-token-field/index.mjs.map +2 -2
  110. package/build-module/icon/index.mjs +30 -12
  111. package/build-module/icon/index.mjs.map +2 -2
  112. package/build-module/input-control/styles/input-control-styles.mjs +42 -27
  113. package/build-module/input-control/styles/input-control-styles.mjs.map +2 -2
  114. package/build-module/item-group/context.mjs +1 -0
  115. package/build-module/item-group/context.mjs.map +2 -2
  116. package/build-module/item-group/item/component.mjs +12 -0
  117. package/build-module/item-group/item/component.mjs.map +2 -2
  118. package/build-module/item-group/item/hook.mjs +7 -6
  119. package/build-module/item-group/item/hook.mjs.map +2 -2
  120. package/build-module/item-group/item-group/component.mjs +1 -0
  121. package/build-module/item-group/item-group/component.mjs.map +2 -2
  122. package/build-module/item-group/item-group/hook.mjs +1 -1
  123. package/build-module/item-group/item-group/hook.mjs.map +2 -2
  124. package/build-module/progress-bar/index.mjs +1 -1
  125. package/build-module/progress-bar/index.mjs.map +2 -2
  126. package/build-module/resizable-box/index.mjs.map +1 -1
  127. package/build-module/snackbar/index.mjs +8 -5
  128. package/build-module/snackbar/index.mjs.map +2 -2
  129. package/build-module/textarea-control/index.mjs +1 -1
  130. package/build-module/textarea-control/index.mjs.map +2 -2
  131. package/build-module/toggle-group-control/context.mjs +8 -2
  132. package/build-module/toggle-group-control/context.mjs.map +2 -2
  133. package/build-module/toggle-group-control/toggle-group-control/as-button-group.mjs +5 -2
  134. package/build-module/toggle-group-control/toggle-group-control/as-button-group.mjs.map +2 -2
  135. package/build-module/toggle-group-control/toggle-group-control/as-radio-group.mjs +5 -2
  136. package/build-module/toggle-group-control/toggle-group-control/as-radio-group.mjs.map +2 -2
  137. package/build-module/toggle-group-control/toggle-group-control/component.mjs +3 -1
  138. package/build-module/toggle-group-control/toggle-group-control/component.mjs.map +2 -2
  139. package/build-module/toggle-group-control/toggle-group-control-option/component.mjs +2 -0
  140. package/build-module/toggle-group-control/toggle-group-control-option/component.mjs.map +2 -2
  141. package/build-module/toggle-group-control/toggle-group-control-option-base/component.mjs +2 -1
  142. package/build-module/toggle-group-control/toggle-group-control-option-base/component.mjs.map +2 -2
  143. package/build-module/toggle-group-control/toggle-group-control-option-icon/component.mjs +2 -0
  144. package/build-module/toggle-group-control/toggle-group-control-option-icon/component.mjs.map +2 -2
  145. package/build-module/tools-panel/tools-panel/hook.mjs +103 -107
  146. package/build-module/tools-panel/tools-panel/hook.mjs.map +2 -2
  147. package/build-module/tools-panel/tools-panel-item/hook.mjs +35 -35
  148. package/build-module/tools-panel/tools-panel-item/hook.mjs.map +2 -2
  149. package/build-module/tree-grid/cell.mjs +5 -1
  150. package/build-module/tree-grid/cell.mjs.map +2 -2
  151. package/build-module/tree-grid/roving-tab-index-item.mjs +5 -1
  152. package/build-module/tree-grid/roving-tab-index-item.mjs.map +2 -2
  153. package/build-module/tree-grid/row.mjs +7 -2
  154. package/build-module/tree-grid/row.mjs.map +2 -2
  155. package/build-module/tree-grid/use-validate-tree-grid-structure.mjs +56 -0
  156. package/build-module/tree-grid/use-validate-tree-grid-structure.mjs.map +7 -0
  157. package/build-module/utils/colors-values.mjs +3 -2
  158. package/build-module/utils/colors-values.mjs.map +2 -2
  159. package/build-style/style-rtl.css +27 -85
  160. package/build-style/style.css +27 -85
  161. package/build-types/border-box-control/border-box-control/component.d.ts +4 -0
  162. package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
  163. package/build-types/border-box-control/border-box-control/hook.d.ts +4 -2
  164. package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
  165. package/build-types/border-box-control/types.d.ts +6 -2
  166. package/build-types/border-box-control/types.d.ts.map +1 -1
  167. package/build-types/composite/context.d.ts +2 -0
  168. package/build-types/composite/context.d.ts.map +1 -1
  169. package/build-types/composite/group-label.d.ts.map +1 -1
  170. package/build-types/composite/group.d.ts.map +1 -1
  171. package/build-types/composite/item.d.ts.map +1 -1
  172. package/build-types/composite/types.d.ts +1 -1
  173. package/build-types/context/context-system-provider.d.ts +8 -6
  174. package/build-types/context/context-system-provider.d.ts.map +1 -1
  175. package/build-types/context/use-context-system.d.ts.map +1 -1
  176. package/build-types/icon/index.d.ts.map +1 -1
  177. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  178. package/build-types/item-group/context.d.ts.map +1 -1
  179. package/build-types/item-group/item/component.d.ts.map +1 -1
  180. package/build-types/item-group/item/hook.d.ts +1 -1
  181. package/build-types/item-group/item/hook.d.ts.map +1 -1
  182. package/build-types/item-group/item-group/component.d.ts.map +1 -1
  183. package/build-types/item-group/types.d.ts +4 -0
  184. package/build-types/item-group/types.d.ts.map +1 -1
  185. package/build-types/popover/types.d.ts +6 -2
  186. package/build-types/popover/types.d.ts.map +1 -1
  187. package/build-types/snackbar/index.d.ts.map +1 -1
  188. package/build-types/toggle-group-control/context.d.ts +2 -2
  189. package/build-types/toggle-group-control/context.d.ts.map +1 -1
  190. package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts +1 -1
  191. package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts.map +1 -1
  192. package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts +1 -1
  193. package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts.map +1 -1
  194. package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
  195. package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts +2 -2
  196. package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts.map +1 -1
  197. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
  198. package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +2 -2
  199. package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts.map +1 -1
  200. package/build-types/toggle-group-control/types.d.ts +12 -3
  201. package/build-types/toggle-group-control/types.d.ts.map +1 -1
  202. package/build-types/tools-panel/tools-panel/hook.d.ts +4 -4
  203. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  204. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  205. package/build-types/tools-panel/types.d.ts +52 -9
  206. package/build-types/tools-panel/types.d.ts.map +1 -1
  207. package/build-types/tree-grid/cell.d.ts.map +1 -1
  208. package/build-types/tree-grid/roving-tab-index-item.d.ts.map +1 -1
  209. package/build-types/tree-grid/row.d.ts.map +1 -1
  210. package/build-types/tree-grid/use-validate-tree-grid-structure.d.ts +2 -0
  211. package/build-types/tree-grid/use-validate-tree-grid-structure.d.ts.map +1 -0
  212. package/build-types/utils/colors-values.d.ts.map +1 -1
  213. package/emotion-to-scss-modules.md +149 -0
  214. package/package.json +28 -27
  215. package/src/alignment-matrix-control/test/{index.tsx → index.jsdom.test.tsx} +5 -4
  216. package/src/angle-picker-control/style.module.scss +1 -1
  217. package/src/autocomplete/test/get-autocomplete-match.ts +2 -1
  218. package/src/autocomplete/test/{index.tsx → index.jsdom.test.tsx} +2 -1
  219. package/src/badge/test/{index.tsx → index.jsdom.test.tsx} +1 -0
  220. package/src/base-control/stories/index.story.tsx +2 -2
  221. package/src/base-control/test/{index.tsx → index.jsdom.test.tsx} +1 -0
  222. package/src/border-box-control/border-box-control/README.md +5 -3
  223. package/src/border-box-control/border-box-control/component.tsx +83 -15
  224. package/src/border-box-control/border-box-control/hook.ts +19 -1
  225. package/src/border-box-control/stories/index.story.tsx +10 -0
  226. package/src/border-box-control/style.module.scss +34 -3
  227. package/src/border-box-control/test/{index.tsx → index.jsdom.test.tsx} +138 -2
  228. package/src/border-box-control/test/utils.ts +11 -0
  229. package/src/border-box-control/types.ts +6 -2
  230. package/src/border-control/test/{index.js → index.jsdom.test.tsx} +44 -24
  231. package/src/box-control/test/{index.tsx → index.jsdom.test.tsx} +6 -3
  232. package/src/button/style.scss +0 -6
  233. package/src/button/test/{index.tsx → index.jsdom.test.tsx} +6 -2
  234. package/src/checkbox-control/stories/index.story.tsx +1 -1
  235. package/src/checkbox-control/style.scss +2 -2
  236. package/src/checkbox-control/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +10 -7
  237. package/src/checkbox-control/test/{index.tsx → index.jsdom.test.tsx} +4 -1
  238. package/src/circular-option-picker/test/{index.tsx → index.jsdom.test.tsx} +1 -0
  239. package/src/color-indicator/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +2 -2
  240. package/src/color-indicator/test/{index.tsx → index.jsdom.test.tsx} +1 -0
  241. package/src/color-palette/index.tsx +1 -1
  242. package/src/color-palette/test/{index.tsx → index.jsdom.test.tsx} +25 -22
  243. package/src/color-palette/test/{utils.ts → utils.jsdom.test.ts} +1 -0
  244. package/src/combobox-control/test/{index.tsx → index.jsdom.test.tsx} +12 -7
  245. package/src/composite/README.md +1 -1
  246. package/src/composite/context.tsx +6 -0
  247. package/src/composite/group-label.tsx +8 -1
  248. package/src/composite/group.tsx +9 -2
  249. package/src/composite/item.tsx +6 -0
  250. package/src/composite/legacy/test/{index.tsx → index.jsdom.test.tsx} +6 -13
  251. package/src/composite/test/{index.tsx → index.jsdom.test.tsx} +60 -17
  252. package/src/composite/types.ts +1 -1
  253. package/src/confirm-dialog/test/{index.tsx → index.jsdom.test.tsx} +16 -14
  254. package/src/content-editable-control/test/{index.tsx → index.jsdom.test.tsx} +4 -3
  255. package/src/context/{context-system-provider.js → context-system-provider.tsx} +19 -5
  256. package/src/context/stories/{ComponentsProvider.stories.jsx → ComponentsProvider.stories.tsx} +2 -2
  257. package/src/context/test/context-connect.tsx +1 -2
  258. package/src/context/test/{context-system-provider.js → context-system-provider.jsdom.test.tsx} +93 -51
  259. package/src/context/test/wordpress-component.tsx +1 -2
  260. package/src/context/use-context-system.js +13 -4
  261. package/src/custom-gradient-picker/gradient-bar/test/{utils.ts → utils.jsdom.test.ts} +6 -5
  262. package/src/custom-gradient-picker/test/serializer.ts +1 -0
  263. package/src/custom-select-control-v2/test/{index.tsx → index.jsdom.test.tsx} +4 -1
  264. package/src/date-time/date-picker/test/{index.tsx → index.jsdom.test.tsx} +6 -3
  265. package/src/date-time/date-picker/test/{use-lilius.ts → use-lilius.jsdom.test.ts} +1 -0
  266. package/src/date-time/date-time/test/{index.tsx → index.jsdom.test.tsx} +20 -11
  267. package/src/date-time/test/utils.test.ts +9 -0
  268. package/src/date-time/time-picker/test/{index.tsx → index.jsdom.test.tsx} +37 -27
  269. package/src/date-time/time-picker/time-input/test/{index.tsx → index.jsdom.test.tsx} +8 -3
  270. package/src/disabled/index.tsx +7 -7
  271. package/src/disabled/test/{index.tsx → index.jsdom.test.tsx} +26 -0
  272. package/src/draggable/index.tsx +1 -1
  273. package/src/draggable/style.module.scss +1 -1
  274. package/src/dropdown/style.module.scss +2 -2
  275. package/src/dropdown/test/{index.tsx → index.jsdom.test.tsx} +1 -0
  276. package/src/dropdown-menu/test/{index.tsx → index.jsdom.test.tsx} +5 -4
  277. package/src/duotone-picker/test/{custom-duotone-bar.tsx → custom-duotone-bar.jsdom.test.tsx} +11 -8
  278. package/src/duotone-picker/test/{index.tsx → index.jsdom.test.tsx} +11 -10
  279. package/src/external-link/test/{index.tsx → index.jsdom.test.tsx} +5 -4
  280. package/src/focal-point-picker/test/{index.tsx → index.jsdom.test.tsx} +12 -9
  281. package/src/focal-point-picker/test/{media.tsx → media.jsdom.test.tsx} +1 -0
  282. package/src/font-size-picker/test/{font-size-picker-select.tsx → font-size-picker-select.jsdom.test.tsx} +19 -16
  283. package/src/font-size-picker/test/{font-size-picker-toggle-group.tsx → font-size-picker-toggle-group.jsdom.test.tsx} +13 -11
  284. package/src/font-size-picker/test/{index.tsx → index.jsdom.test.tsx} +19 -14
  285. package/src/font-size-picker/test/utils.ts +1 -0
  286. package/src/form-toggle/style.scss +1 -1
  287. package/src/form-toggle/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +4 -4
  288. package/src/form-toggle/test/{index.tsx → index.jsdom.test.tsx} +2 -1
  289. package/src/form-token-field/index.tsx +1 -1
  290. package/src/form-token-field/test/{index.tsx → index.jsdom.test.tsx} +86 -44
  291. package/src/gradient-picker/test/{index.tsx → index.jsdom.test.tsx} +12 -9
  292. package/src/guide/test/{index.tsx → index.jsdom.test.tsx} +4 -2
  293. package/src/h-stack/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +4 -4
  294. package/src/h-stack/test/{index.tsx → index.jsdom.test.tsx} +3 -0
  295. package/src/higher-order/with-fallback-styles/test/{index.tsx → index.jsdom.test.tsx} +3 -2
  296. package/src/higher-order/with-filters/test/__snapshots__/index.jsdom.test.tsx.snap +87 -0
  297. package/src/higher-order/with-filters/test/{index.tsx → index.jsdom.test.tsx} +6 -5
  298. package/src/higher-order/with-focus-outside/test/{index.tsx → index.jsdom.test.tsx} +2 -1
  299. package/src/higher-order/with-focus-return/test/{index.tsx → index.jsdom.test.tsx} +1 -0
  300. package/src/higher-order/with-notices/test/{index.tsx → index.jsdom.test.tsx} +1 -0
  301. package/src/higher-order/with-spoken-messages/test/{index.tsx → index.jsdom.test.tsx} +3 -2
  302. package/src/icon/index.tsx +28 -12
  303. package/src/icon/test/{index.tsx → index.jsdom.test.tsx} +66 -0
  304. package/src/input-control/styles/input-control-styles.tsx +38 -7
  305. package/src/input-control/test/{index.js → index.jsdom.test.tsx} +16 -10
  306. package/src/isolated-event-container/test/{index.tsx → index.jsdom.test.tsx} +4 -3
  307. package/src/item-group/context.ts +1 -0
  308. package/src/item-group/item/component.tsx +19 -1
  309. package/src/item-group/item/hook.ts +2 -3
  310. package/src/item-group/item-group/component.tsx +1 -0
  311. package/src/item-group/style.module.scss +1 -2
  312. package/src/item-group/test/__snapshots__/{index.js.snap → index.jsdom.test.tsx.snap} +9 -9
  313. package/src/item-group/test/{index.js → index.jsdom.test.tsx} +99 -2
  314. package/src/item-group/types.ts +4 -0
  315. package/src/keyboard-shortcuts/test/{index.tsx → index.jsdom.test.tsx} +5 -4
  316. package/src/menu/test/{index.tsx → index.jsdom.test.tsx} +67 -23
  317. package/src/menu-group/test/{index.tsx → index.jsdom.test.tsx} +1 -0
  318. package/src/menu-item/test/__snapshots__/{index.js.snap → index.jsdom.test.tsx.snap} +5 -5
  319. package/src/menu-item/test/{index.js → index.jsdom.test.tsx} +1 -0
  320. package/src/modal/test/{aria-helper.ts → aria-helper.jsdom.test.ts} +1 -0
  321. package/src/modal/test/{index.tsx → index.jsdom.test.tsx} +9 -5
  322. package/src/navigable-container/test/{navigable-menu.tsx → navigable-menu.jsdom.test.tsx} +7 -5
  323. package/src/navigable-container/test/{tababble-container.tsx → tababble-container.jsdom.test.tsx} +5 -3
  324. package/src/navigator/test/{index.tsx → index.jsdom.test.tsx} +5 -2
  325. package/src/navigator/test/router.ts +1 -0
  326. package/src/notice/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +7 -4
  327. package/src/notice/test/{index.tsx → index.jsdom.test.tsx} +8 -4
  328. package/src/notice/test/{list.tsx → list.jsdom.test.tsx} +1 -0
  329. package/src/number-control/test/{index.tsx → index.jsdom.test.tsx} +9 -6
  330. package/src/palette-edit/test/{index.tsx → index.jsdom.test.tsx} +16 -13
  331. package/src/panel/test/__snapshots__/body.jsdom.test.tsx.snap +9 -0
  332. package/src/panel/test/__snapshots__/header.jsdom.test.tsx.snap +9 -0
  333. package/src/panel/test/__snapshots__/index.jsdom.test.tsx.snap +17 -0
  334. package/src/panel/test/__snapshots__/row.jsdom.test.tsx.snap +17 -0
  335. package/src/panel/test/{body.tsx → body.jsdom.test.tsx} +2 -1
  336. package/src/panel/test/{header.tsx → header.jsdom.test.tsx} +1 -0
  337. package/src/panel/test/{index.tsx → index.jsdom.test.tsx} +1 -0
  338. package/src/panel/test/{row.tsx → row.jsdom.test.tsx} +1 -0
  339. package/src/placeholder/style.scss +0 -5
  340. package/src/placeholder/test/{index.tsx → index.jsdom.test.tsx} +19 -14
  341. package/src/popover/README.md +2 -2
  342. package/src/popover/test/{index.tsx → index.jsdom.test.tsx} +23 -0
  343. package/src/popover/types.ts +9 -3
  344. package/src/progress-bar/style.module.scss +9 -1
  345. package/src/query-controls/test/terms.ts +1 -0
  346. package/src/radio-control/test/{index.tsx → index.jsdom.test.tsx} +14 -11
  347. package/src/range-control/test/{index.tsx → index.jsdom.test.tsx} +10 -7
  348. package/src/resizable-box/index.tsx +1 -1
  349. package/src/sandbox/test/{index.tsx → index.jsdom.test.tsx} +1 -0
  350. package/src/scroll-lock/test/{index.tsx → index.jsdom.test.tsx} +1 -0
  351. package/src/shortcut/test/__snapshots__/index.jsdom.test.tsx.snap +15 -0
  352. package/src/shortcut/test/{index.tsx → index.jsdom.test.tsx} +1 -0
  353. package/src/slot-fill/test/{index.js → index.jsdom.test.tsx} +4 -3
  354. package/src/slot-fill/test/{slot.js → slot.jsdom.test.tsx} +17 -9
  355. package/src/snackbar/index.tsx +10 -6
  356. package/src/snackbar/test/{index.tsx → index.jsdom.test.tsx} +41 -11
  357. package/src/snackbar/test/list.jsdom.test.tsx +100 -0
  358. package/src/style-provider/test/{index.tsx → index.jsdom.test.tsx} +1 -0
  359. package/src/surface/style.module.scss +2 -2
  360. package/src/surface/test/{index.tsx → index.jsdom.test.tsx} +1 -0
  361. package/src/tab-panel/style.scss +4 -23
  362. package/src/tab-panel/test/{index.tsx → index.jsdom.test.tsx} +22 -21
  363. package/src/tabs/test/{index.tsx → index.jsdom.test.tsx} +21 -19
  364. package/src/text-control/test/{text-control.tsx → text-control.jsdom.test.tsx} +1 -0
  365. package/src/text-highlight/test/{index.tsx → index.jsdom.test.tsx} +1 -0
  366. package/src/textarea-control/style.module.scss +9 -4
  367. package/src/tip/style.scss +1 -1
  368. package/src/toggle-control/test/{index.tsx → index.jsdom.test.tsx} +4 -1
  369. package/src/toggle-group-control/context.ts +14 -5
  370. package/src/toggle-group-control/stories/index.story.tsx +15 -2
  371. package/src/toggle-group-control/test/{index.tsx → index.jsdom.test.tsx} +283 -9
  372. package/src/toggle-group-control/toggle-group-control/README.md +8 -5
  373. package/src/toggle-group-control/toggle-group-control/as-button-group.tsx +4 -0
  374. package/src/toggle-group-control/toggle-group-control/as-radio-group.tsx +4 -0
  375. package/src/toggle-group-control/toggle-group-control/component.tsx +2 -0
  376. package/src/toggle-group-control/toggle-group-control/style.module.scss +8 -2
  377. package/src/toggle-group-control/toggle-group-control-option/README.md +8 -5
  378. package/src/toggle-group-control/toggle-group-control-option/component.tsx +2 -0
  379. package/src/toggle-group-control/toggle-group-control-option-base/component.tsx +4 -1
  380. package/src/toggle-group-control/toggle-group-control-option-icon/README.md +7 -0
  381. package/src/toggle-group-control/toggle-group-control-option-icon/component.tsx +2 -0
  382. package/src/toggle-group-control/types.ts +12 -3
  383. package/src/toolbar/test/{index.tsx → index.jsdom.test.tsx} +1 -0
  384. package/src/toolbar/test/{toolbar-group.tsx → toolbar-group.jsdom.test.tsx} +2 -1
  385. package/src/tools-panel/test/{index.tsx → index.jsdom.test.tsx} +595 -47
  386. package/src/tools-panel/tools-panel/hook.ts +195 -180
  387. package/src/tools-panel/tools-panel-item/README.md +42 -1
  388. package/src/tools-panel/tools-panel-item/hook.ts +97 -69
  389. package/src/tools-panel/types.ts +54 -9
  390. package/src/tooltip/test/{index.tsx → index.jsdom.test.tsx} +5 -3
  391. package/src/tree-grid/cell.tsx +6 -2
  392. package/src/tree-grid/roving-tab-index-item.tsx +7 -3
  393. package/src/tree-grid/row.tsx +8 -2
  394. package/src/tree-grid/test/__snapshots__/{cell.tsx.snap → cell.jsdom.test.tsx.snap} +2 -2
  395. package/src/tree-grid/test/__snapshots__/index.jsdom.test.tsx.snap +3 -0
  396. package/src/tree-grid/test/__snapshots__/roving-tab-index-item.jsdom.test.tsx.snap +27 -0
  397. package/src/tree-grid/test/__snapshots__/roving-tab-index.jsdom.test.tsx.snap +9 -0
  398. package/src/tree-grid/test/__snapshots__/{row.tsx.snap → row.jsdom.test.tsx.snap} +9 -5
  399. package/src/tree-grid/test/cell.jsdom.test.tsx +149 -0
  400. package/src/tree-grid/test/{index.tsx → index.jsdom.test.tsx} +9 -7
  401. package/src/tree-grid/test/{roving-tab-index-item.tsx → roving-tab-index-item.jsdom.test.tsx} +4 -1
  402. package/src/tree-grid/test/{roving-tab-index.tsx → roving-tab-index.jsdom.test.tsx} +1 -0
  403. package/src/tree-grid/test/row.jsdom.test.tsx +132 -0
  404. package/src/tree-grid/use-validate-tree-grid-structure.ts +104 -0
  405. package/src/truncate/style.module.scss +0 -1
  406. package/src/truncate/test/{index.tsx → index.jsdom.test.tsx} +1 -0
  407. package/src/unit-control/test/{index.tsx → index.jsdom.test.tsx} +22 -19
  408. package/src/unit-control/test/utils.ts +1 -0
  409. package/src/utils/colors-values.js +5 -4
  410. package/src/utils/hooks/test/{use-controlled-state.js → use-controlled-state.jsdom.test.tsx} +22 -7
  411. package/src/utils/hooks/test/{use-controlled-value.js → use-controlled-value.jsdom.test.tsx} +6 -3
  412. package/src/utils/hooks/test/{use-cx.js → use-cx.jsdom.test.tsx} +8 -5
  413. package/src/utils/test/colors.js +1 -0
  414. package/src/utils/test/{get-node-text.js → get-node-text.tsx} +1 -0
  415. package/src/utils/test/math.js +1 -0
  416. package/src/utils/test/rtl.js +1 -0
  417. package/src/utils/test/space.js +1 -0
  418. package/src/utils/test/strings.js +1 -0
  419. package/src/utils/test/unit-values.js +1 -0
  420. package/src/v-stack/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +4 -4
  421. package/src/v-stack/test/{index.tsx → index.jsdom.test.tsx} +3 -0
  422. package/src/validated-form-controls/style.scss +11 -15
  423. package/src/validated-form-controls/test/{content-editable-control.tsx → content-editable-control.jsdom.test.tsx} +1 -1
  424. package/src/validated-form-controls/test/{custom-select-control.tsx → custom-select-control.jsdom.test.tsx} +3 -0
  425. package/src/validated-form-controls/test/{input-control.tsx → input-control.jsdom.test.tsx} +3 -0
  426. package/src/validated-form-controls/test/{range-control.tsx → range-control.jsdom.test.tsx} +3 -0
  427. package/src/validated-form-controls/test/{textarea-control.tsx → textarea-control.jsdom.test.tsx} +1 -0
  428. package/src/view/test/__snapshots__/{index.js.snap → index.jsdom.test.tsx.snap} +7 -7
  429. package/src/view/test/{index.js → index.jsdom.test.tsx} +7 -2
  430. package/src/context/test/__snapshots__/context-system-provider.js.snap +0 -35
  431. package/src/higher-order/with-filters/test/__snapshots__/index.tsx.snap +0 -87
  432. package/src/panel/test/__snapshots__/body.tsx.snap +0 -9
  433. package/src/panel/test/__snapshots__/header.tsx.snap +0 -9
  434. package/src/panel/test/__snapshots__/index.tsx.snap +0 -17
  435. package/src/panel/test/__snapshots__/row.tsx.snap +0 -17
  436. package/src/shortcut/test/__snapshots__/index.tsx.snap +0 -15
  437. package/src/snackbar/test/list.tsx +0 -39
  438. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +0 -359
  439. package/src/tree-grid/test/__snapshots__/index.tsx.snap +0 -3
  440. package/src/tree-grid/test/__snapshots__/roving-tab-index-item.tsx.snap +0 -27
  441. package/src/tree-grid/test/__snapshots__/roving-tab-index.tsx.snap +0 -9
  442. package/src/tree-grid/test/cell.tsx +0 -46
  443. package/src/tree-grid/test/row.tsx +0 -37
  444. /package/src/card/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
  445. /package/src/card/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  446. /package/src/color-picker/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  447. /package/src/custom-gradient-picker/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  448. /package/src/custom-select-control/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
  449. /package/src/custom-select-control/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  450. /package/src/divider/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  451. /package/src/elevation/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
  452. /package/src/elevation/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  453. /package/src/flex/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
  454. /package/src/flex/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  455. /package/src/form-file-upload/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  456. /package/src/grid/test/{grid.tsx → grid.jsdom.test.tsx} +0 -0
  457. /package/src/heading/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
  458. /package/src/heading/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  459. /package/src/input-control/test/__snapshots__/{index.js.snap → index.jsdom.test.tsx.snap} +0 -0
  460. /package/src/progress-bar/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  461. /package/src/resizable-box/resize-tooltip/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  462. /package/src/resizable-box/resize-tooltip/test/{label.tsx → label.jsdom.test.tsx} +0 -0
  463. /package/src/scrollable/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  464. /package/src/search-control/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  465. /package/src/select-control/test/__snapshots__/{select-control.tsx.snap → select-control.jsdom.test.tsx.snap} +0 -0
  466. /package/src/select-control/test/{select-control.tsx → select-control.jsdom.test.tsx} +0 -0
  467. /package/src/slot-fill/test/__snapshots__/{slot.js.snap → slot.jsdom.test.tsx.snap} +0 -0
  468. /package/src/spacer/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
  469. /package/src/spacer/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  470. /package/src/text/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
  471. /package/src/text/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  472. /package/src/utils/test/{polymorphic-element.tsx → polymorphic-element.jsdom.test.tsx} +0 -0
@@ -1,4 +1,4 @@
1
- /* eslint jest/expect-expect: ["warn", { "assertFunctionNames": ["expect", "expectTokensToBeInTheDocument", "expectTokensNotToBeInTheDocument", "expectVisibleSuggestionsToBe", "expectEscapedProperly"] }] */
1
+ import { afterEach, describe, expect, it, vi } from 'vitest';
2
2
  import {
3
3
  render,
4
4
  screen,
@@ -12,6 +12,10 @@ import { useState } from '@wordpress/element';
12
12
  import { logged } from '@wordpress/deprecated';
13
13
  import FormTokenField from '../';
14
14
 
15
+ globalThis.wpVitest.mockMatchMedia();
16
+
17
+ globalThis.wpVitest.mockScrollIntoView();
18
+
15
19
  const FormTokenFieldWithState = ( {
16
20
  onChange,
17
21
  value,
@@ -119,7 +123,7 @@ describe( 'FormTokenField', () => {
119
123
  it( "should add tokens with the input's value when pressing the enter key", async () => {
120
124
  const user = userEvent.setup();
121
125
 
122
- const onChangeSpy = jest.fn();
126
+ const onChangeSpy = vi.fn();
123
127
 
124
128
  render( <FormTokenFieldWithState onChange={ onChangeSpy } /> );
125
129
 
@@ -144,7 +148,7 @@ describe( 'FormTokenField', () => {
144
148
  it( "should add a token with the input's value when pressing the comma key", async () => {
145
149
  const user = userEvent.setup();
146
150
 
147
- const onChangeSpy = jest.fn();
151
+ const onChangeSpy = vi.fn();
148
152
 
149
153
  render( <FormTokenFieldWithState onChange={ onChangeSpy } /> );
150
154
 
@@ -160,7 +164,7 @@ describe( 'FormTokenField', () => {
160
164
  it( 'should add a token with the input value when pressing the space key and the `tokenizeOnSpace` prop is `true`', async () => {
161
165
  const user = userEvent.setup();
162
166
 
163
- const onChangeSpy = jest.fn();
167
+ const onChangeSpy = vi.fn();
164
168
 
165
169
  const { rerender } = render(
166
170
  <FormTokenFieldWithState onChange={ onChangeSpy } />
@@ -204,7 +208,7 @@ describe( 'FormTokenField', () => {
204
208
  it( 'should add a token with the input value with onBlur when `tokenizeOnBlur` prop is `true`', async () => {
205
209
  const user = userEvent.setup();
206
210
 
207
- const onChangeSpy = jest.fn();
211
+ const onChangeSpy = vi.fn();
208
212
 
209
213
  const { rerender } = render(
210
214
  <FormTokenFieldWithState onChange={ onChangeSpy } />
@@ -239,7 +243,7 @@ describe( 'FormTokenField', () => {
239
243
  it( "should not add a token with the input's value when tokenizeOnBlur is not set and pressing the tab key", async () => {
240
244
  const user = userEvent.setup();
241
245
 
242
- const onChangeSpy = jest.fn();
246
+ const onChangeSpy = vi.fn();
243
247
 
244
248
  render( <FormTokenFieldWithState onChange={ onChangeSpy } /> );
245
249
 
@@ -255,7 +259,7 @@ describe( 'FormTokenField', () => {
255
259
  it( 'should remove the last token when pressing the backspace key', async () => {
256
260
  const user = userEvent.setup();
257
261
 
258
- const onChangeSpy = jest.fn();
262
+ const onChangeSpy = vi.fn();
259
263
 
260
264
  render(
261
265
  <FormTokenFieldWithState
@@ -283,7 +287,7 @@ describe( 'FormTokenField', () => {
283
287
  it( 'should remove a token when clicking the token\'s "remove" button', async () => {
284
288
  const user = userEvent.setup();
285
289
 
286
- const onChangeSpy = jest.fn();
290
+ const onChangeSpy = vi.fn();
287
291
 
288
292
  render(
289
293
  <FormTokenFieldWithState
@@ -325,7 +329,7 @@ describe( 'FormTokenField', () => {
325
329
  it( 'should remove a token when by focusing on the token\'s "remove" button and pressing space bar', async () => {
326
330
  const user = userEvent.setup();
327
331
 
328
- const onChangeSpy = jest.fn();
332
+ const onChangeSpy = vi.fn();
329
333
 
330
334
  render(
331
335
  <FormTokenFieldWithState
@@ -360,7 +364,7 @@ describe( 'FormTokenField', () => {
360
364
  it( 'should not add a new token if a token with the same value already exists', async () => {
361
365
  const user = userEvent.setup();
362
366
 
363
- const onChangeSpy = jest.fn();
367
+ const onChangeSpy = vi.fn();
364
368
 
365
369
  render(
366
370
  <FormTokenFieldWithState
@@ -387,7 +391,7 @@ describe( 'FormTokenField', () => {
387
391
  it( 'should not add a new token if the text input is blank', async () => {
388
392
  const user = userEvent.setup();
389
393
 
390
- const onChangeSpy = jest.fn();
394
+ const onChangeSpy = vi.fn();
391
395
 
392
396
  render(
393
397
  <FormTokenFieldWithState
@@ -407,7 +411,7 @@ describe( 'FormTokenField', () => {
407
411
  it( 'should allow moving the cursor through the tokens when pressing the arrow keys, and should remove the token in front of the cursor when pressing the delete key', async () => {
408
412
  const user = userEvent.setup();
409
413
 
410
- const onChangeSpy = jest.fn();
414
+ const onChangeSpy = vi.fn();
411
415
 
412
416
  render(
413
417
  <FormTokenFieldWithState
@@ -534,7 +538,7 @@ describe( 'FormTokenField', () => {
534
538
  it( 'should fire the `onFocus` callback when the input is focused', async () => {
535
539
  const user = userEvent.setup();
536
540
 
537
- const onFocusSpy = jest.fn();
541
+ const onFocusSpy = vi.fn();
538
542
 
539
543
  render( <FormTokenFieldWithState onFocus={ onFocusSpy } /> );
540
544
 
@@ -556,7 +560,7 @@ describe( 'FormTokenField', () => {
556
560
  it( "should fire the `onInputChange` callback when the input's value changes", async () => {
557
561
  const user = userEvent.setup();
558
562
 
559
- const onInputChangeSpy = jest.fn();
563
+ const onInputChangeSpy = vi.fn();
560
564
 
561
565
  render(
562
566
  <FormTokenFieldWithState onInputChange={ onInputChangeSpy } />
@@ -674,7 +678,7 @@ describe( 'FormTokenField', () => {
674
678
  it( "should use the value of the `placeholder` prop as the input's placeholder only when there are no tokens", async () => {
675
679
  const user = userEvent.setup();
676
680
 
677
- const onChangeSpy = jest.fn();
681
+ const onChangeSpy = vi.fn();
678
682
 
679
683
  render(
680
684
  <FormTokenFieldWithState
@@ -703,7 +707,7 @@ describe( 'FormTokenField', () => {
703
707
  it( 'should handle accents and special characters in tokens and input value', async () => {
704
708
  const user = userEvent.setup();
705
709
 
706
- const onChangeSpy = jest.fn();
710
+ const onChangeSpy = vi.fn();
707
711
 
708
712
  render(
709
713
  <FormTokenFieldWithState
@@ -748,7 +752,7 @@ describe( 'FormTokenField', () => {
748
752
  it( 'should render suggestions when receiving focus if the `__experimentalExpandOnFocus` prop is set to `true`', async () => {
749
753
  const user = userEvent.setup();
750
754
 
751
- const onFocusSpy = jest.fn();
755
+ const onFocusSpy = vi.fn();
752
756
 
753
757
  const suggestions = [ 'Cobalt', 'Blue', 'Octane' ];
754
758
 
@@ -791,7 +795,7 @@ describe( 'FormTokenField', () => {
791
795
  it( 'should render suggestions after a selection is made when the `__experimentalExpandOnFocus` prop is set to `true`', async () => {
792
796
  const user = userEvent.setup();
793
797
 
794
- const onFocusSpy = jest.fn();
798
+ const onFocusSpy = vi.fn();
795
799
 
796
800
  const suggestions = [ 'Green', 'Emerald', 'Seaweed' ];
797
801
 
@@ -823,7 +827,7 @@ describe( 'FormTokenField', () => {
823
827
  it( 'should not render suggestions after a selection is made when the `__experimentalExpandOnFocus` prop is set to `false` or not defined', async () => {
824
828
  const user = userEvent.setup();
825
829
 
826
- const onFocusSpy = jest.fn();
830
+ const onFocusSpy = vi.fn();
827
831
 
828
832
  const suggestions = [ 'Green', 'Emerald', 'Seaweed' ];
829
833
 
@@ -854,7 +858,7 @@ describe( 'FormTokenField', () => {
854
858
  it( 'should not render suggestions after the input is blurred', async () => {
855
859
  const user = userEvent.setup();
856
860
 
857
- const onFocusSpy = jest.fn();
861
+ const onFocusSpy = vi.fn();
858
862
 
859
863
  const suggestions = [ 'Green', 'Emerald', 'Seaweed' ];
860
864
 
@@ -951,7 +955,7 @@ describe( 'FormTokenField', () => {
951
955
  it( 'should allow the user to use the keyboard to navigate and select suggestions (which are marked with the `aria-selected` attribute)', async () => {
952
956
  const user = userEvent.setup();
953
957
 
954
- const onChangeSpy = jest.fn();
958
+ const onChangeSpy = vi.fn();
955
959
 
956
960
  const suggestions = [
957
961
  'Pink',
@@ -1027,10 +1031,48 @@ describe( 'FormTokenField', () => {
1027
1031
  expect( screen.queryByRole( 'listbox' ) ).not.toBeInTheDocument();
1028
1032
  } );
1029
1033
 
1034
+ it( 'should select the last suggestion when pressing the up arrow with no suggestion selected', async () => {
1035
+ const user = userEvent.setup();
1036
+
1037
+ const suggestions = [ 'Pink', 'Salmon', 'Carnation', 'Neon' ];
1038
+
1039
+ render( <FormTokenFieldWithState suggestions={ suggestions } /> );
1040
+
1041
+ const input = screen.getByRole( 'combobox' );
1042
+
1043
+ // Typing "on" will show the "Salmon", "Carnation" and "Neon" suggestions
1044
+ await user.type( input, 'on' );
1045
+
1046
+ const suggestionList = screen.getByRole( 'listbox' );
1047
+
1048
+ expectVisibleSuggestionsToBe( suggestionList, [
1049
+ 'Salmon',
1050
+ 'Carnation',
1051
+ 'Neon',
1052
+ ] );
1053
+
1054
+ // Currently, none of the suggestions are selected
1055
+ expect(
1056
+ within( suggestionList ).queryByRole( 'option', {
1057
+ selected: true,
1058
+ } )
1059
+ ).not.toBeInTheDocument();
1060
+
1061
+ // Pressing the up arrow from an empty selection wraps to the end of
1062
+ // the list and selects "Neon"
1063
+ await user.keyboard( '[ArrowUp]' );
1064
+
1065
+ expect(
1066
+ within( suggestionList ).getByRole( 'option', {
1067
+ selected: true,
1068
+ } )
1069
+ ).toHaveAccessibleName( 'Neon' );
1070
+ } );
1071
+
1030
1072
  it( 'should allow the user to use the mouse to navigate and select suggestions (which are marked with the `aria-selected` attribute)', async () => {
1031
1073
  const user = userEvent.setup();
1032
1074
 
1033
- const onChangeSpy = jest.fn();
1075
+ const onChangeSpy = vi.fn();
1034
1076
 
1035
1077
  const suggestions = [ 'Tiger', 'Tangerine', 'Orange' ];
1036
1078
 
@@ -1100,7 +1142,7 @@ describe( 'FormTokenField', () => {
1100
1142
  it( 'should hide the suggestion list when the Escape key is pressed', async () => {
1101
1143
  const user = userEvent.setup();
1102
1144
 
1103
- const onChangeSpy = jest.fn();
1145
+ const onChangeSpy = vi.fn();
1104
1146
 
1105
1147
  const suggestions = [ 'Black', 'Ash', 'Onyx', 'Ebony' ];
1106
1148
 
@@ -1453,7 +1495,7 @@ describe( 'FormTokenField', () => {
1453
1495
  it( 'should accept tokens in their object format', async () => {
1454
1496
  const user = userEvent.setup();
1455
1497
 
1456
- const onChangeSpy = jest.fn();
1498
+ const onChangeSpy = vi.fn();
1457
1499
 
1458
1500
  const { rerender } = render(
1459
1501
  <FormTokenFieldWithState
@@ -1493,8 +1535,8 @@ describe( 'FormTokenField', () => {
1493
1535
  it( 'should trigger mouse callbacks if the `onMouseEnter` and/or the `onMouseLeave` properties are set on a token data object', async () => {
1494
1536
  const user = userEvent.setup();
1495
1537
 
1496
- const onMouseEnterSpy = jest.fn();
1497
- const onMouseLeaveSpy = jest.fn();
1538
+ const onMouseEnterSpy = vi.fn();
1539
+ const onMouseLeaveSpy = vi.fn();
1498
1540
 
1499
1541
  render(
1500
1542
  <FormTokenFieldWithState
@@ -1575,7 +1617,7 @@ describe( 'FormTokenField', () => {
1575
1617
  it( "by default, it should trim the input's value from extra white spaces before attempting to add it as a token", async () => {
1576
1618
  const user = userEvent.setup();
1577
1619
 
1578
- const onChangeSpy = jest.fn();
1620
+ const onChangeSpy = vi.fn();
1579
1621
 
1580
1622
  const { rerender } = render(
1581
1623
  <FormTokenFieldWithState
@@ -1639,7 +1681,7 @@ describe( 'FormTokenField', () => {
1639
1681
  it( "should allow to modify the input's value when saving it as a token", async () => {
1640
1682
  const user = userEvent.setup();
1641
1683
 
1642
- const onChangeSpy = jest.fn();
1684
+ const onChangeSpy = vi.fn();
1643
1685
 
1644
1686
  const { rerender } = render(
1645
1687
  <FormTokenFieldWithState
@@ -1702,7 +1744,7 @@ describe( 'FormTokenField', () => {
1702
1744
  it( 'is applied to the search value when matching it against the list of suggestions', async () => {
1703
1745
  const user = userEvent.setup();
1704
1746
 
1705
- const onChangeSpy = jest.fn();
1747
+ const onChangeSpy = vi.fn();
1706
1748
 
1707
1749
  const suggestions = [ 'Expensive food', 'Free food' ];
1708
1750
 
@@ -1740,7 +1782,7 @@ describe( 'FormTokenField', () => {
1740
1782
  it( 'should allow to modify the text rendered in the browser for each token', async () => {
1741
1783
  const user = userEvent.setup();
1742
1784
 
1743
- const onChangeSpy = jest.fn();
1785
+ const onChangeSpy = vi.fn();
1744
1786
 
1745
1787
  const { rerender } = render(
1746
1788
  <FormTokenFieldWithState
@@ -1796,7 +1838,7 @@ describe( 'FormTokenField', () => {
1796
1838
  it( "is applied to each suggestions, but doesn't influence the matching against the search value", async () => {
1797
1839
  const user = userEvent.setup();
1798
1840
 
1799
- const onChangeSpy = jest.fn();
1841
+ const onChangeSpy = vi.fn();
1800
1842
 
1801
1843
  const suggestions = [ 'Hot coffee', 'Hot tea' ];
1802
1844
 
@@ -1874,7 +1916,7 @@ describe( 'FormTokenField', () => {
1874
1916
  it( 'should add a token only if it passes the validation set via `__experimentalValidateInput`', async () => {
1875
1917
  const user = userEvent.setup();
1876
1918
 
1877
- const onChangeSpy = jest.fn();
1919
+ const onChangeSpy = vi.fn();
1878
1920
  const startsWithCapitalLetter = ( tokenText: string ) =>
1879
1921
  /^[A-Z]/.test( tokenText );
1880
1922
 
@@ -1917,8 +1959,8 @@ describe( 'FormTokenField', () => {
1917
1959
  it( 'should still preventDefault on Enter when validation rejects the value', async () => {
1918
1960
  const user = userEvent.setup();
1919
1961
 
1920
- const onChangeSpy = jest.fn();
1921
- const onSubmitSpy = jest.fn( ( e: React.FormEvent ) =>
1962
+ const onChangeSpy = vi.fn();
1963
+ const onSubmitSpy = vi.fn( ( e: React.FormEvent ) =>
1922
1964
  e.preventDefault()
1923
1965
  );
1924
1966
  const startsWithCapitalLetter = ( tokenText: string ) =>
@@ -1946,7 +1988,7 @@ describe( 'FormTokenField', () => {
1946
1988
  it( 'should not preventDefault on space when validation fails and `tokenizeOnSpace` is true', async () => {
1947
1989
  const user = userEvent.setup();
1948
1990
 
1949
- const onChangeSpy = jest.fn();
1991
+ const onChangeSpy = vi.fn();
1950
1992
  const startsWithCapitalLetter = ( tokenText: string ) =>
1951
1993
  /^[A-Z]/.test( tokenText );
1952
1994
 
@@ -1984,7 +2026,7 @@ describe( 'FormTokenField', () => {
1984
2026
  it( 'should filter out invalid tokens when pasting with separators', async () => {
1985
2027
  const user = userEvent.setup();
1986
2028
 
1987
- const onChangeSpy = jest.fn();
2029
+ const onChangeSpy = vi.fn();
1988
2030
  const startsWithCapitalLetter = ( tokenText: string ) =>
1989
2031
  /^[A-Z]/.test( tokenText );
1990
2032
 
@@ -2012,7 +2054,7 @@ describe( 'FormTokenField', () => {
2012
2054
  it( 'should leave all segments in the input when none pass validation on paste', async () => {
2013
2055
  const user = userEvent.setup();
2014
2056
 
2015
- const onChangeSpy = jest.fn();
2057
+ const onChangeSpy = vi.fn();
2016
2058
  const startsWithCapitalLetter = ( tokenText: string ) =>
2017
2059
  /^[A-Z]/.test( tokenText );
2018
2060
 
@@ -2035,7 +2077,7 @@ describe( 'FormTokenField', () => {
2035
2077
  it( 'should commit a trailing valid segment and leave only failed segments in the input when pasting without a trailing separator', async () => {
2036
2078
  const user = userEvent.setup();
2037
2079
 
2038
- const onChangeSpy = jest.fn();
2080
+ const onChangeSpy = vi.fn();
2039
2081
  const startsWithCapitalLetter = ( tokenText: string ) =>
2040
2082
  /^[A-Z]/.test( tokenText );
2041
2083
 
@@ -2059,7 +2101,7 @@ describe( 'FormTokenField', () => {
2059
2101
  it( 'should not leave a duplicate of an existing token in the input when pasting comma-separated values', async () => {
2060
2102
  const user = userEvent.setup();
2061
2103
 
2062
- const onChangeSpy = jest.fn();
2104
+ const onChangeSpy = vi.fn();
2063
2105
 
2064
2106
  render(
2065
2107
  <FormTokenFieldWithState
@@ -2081,7 +2123,7 @@ describe( 'FormTokenField', () => {
2081
2123
  it( 'should not leave a duplicate of an existing token in the input when pasting comma-separated values with `__experimentalValidateInput`', async () => {
2082
2124
  const user = userEvent.setup();
2083
2125
 
2084
- const onChangeSpy = jest.fn();
2126
+ const onChangeSpy = vi.fn();
2085
2127
  const startsWithCapitalLetter = ( tokenText: string ) =>
2086
2128
  /^[A-Z]/.test( tokenText );
2087
2129
 
@@ -2108,7 +2150,7 @@ describe( 'FormTokenField', () => {
2108
2150
  it( 'should not allow adding new tokens beyond the value defined by the `maxLength` prop', async () => {
2109
2151
  const user = userEvent.setup();
2110
2152
 
2111
- const onChangeSpy = jest.fn();
2153
+ const onChangeSpy = vi.fn();
2112
2154
 
2113
2155
  render(
2114
2156
  <FormTokenFieldWithState
@@ -2176,7 +2218,7 @@ describe( 'FormTokenField', () => {
2176
2218
  it( 'should not affect tokens that were added before the limit was imposed', async () => {
2177
2219
  const user = userEvent.setup();
2178
2220
 
2179
- const onChangeSpy = jest.fn();
2221
+ const onChangeSpy = vi.fn();
2180
2222
 
2181
2223
  const { rerender } = render(
2182
2224
  <FormTokenFieldWithState onChange={ onChangeSpy } />
@@ -2219,7 +2261,7 @@ describe( 'FormTokenField', () => {
2219
2261
  it( 'should not allow adding tokens when the `disabled` prop is `true`', async () => {
2220
2262
  const user = userEvent.setup();
2221
2263
 
2222
- const onChangeSpy = jest.fn();
2264
+ const onChangeSpy = vi.fn();
2223
2265
 
2224
2266
  const { rerender } = render(
2225
2267
  <FormTokenFieldWithState onChange={ onChangeSpy } />
@@ -2247,7 +2289,7 @@ describe( 'FormTokenField', () => {
2247
2289
  it( 'should not allow removing tokens when the `disable` prop is `true`', async () => {
2248
2290
  const user = userEvent.setup();
2249
2291
 
2250
- const onChangeSpy = jest.fn();
2292
+ const onChangeSpy = vi.fn();
2251
2293
 
2252
2294
  render(
2253
2295
  <FormTokenFieldWithState
@@ -1,7 +1,10 @@
1
+ import { describe, expect, it, vi } from 'vitest';
1
2
  import { render, screen } from '@testing-library/react';
2
3
  import userEvent from '@testing-library/user-event';
3
4
  import GradientPicker from '..';
4
5
 
6
+ globalThis.wpVitest.mockMatchMedia();
7
+
5
8
  const GRADIENT_A =
6
9
  'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)';
7
10
  const GRADIENT_B =
@@ -15,7 +18,7 @@ const DUPLICATE_GRADIENTS = [
15
18
  describe( 'GradientPicker', () => {
16
19
  it( 'should use matching values only for display in command button presentation', async () => {
17
20
  const user = userEvent.setup();
18
- const onChange = jest.fn();
21
+ const onChange = vi.fn();
19
22
  render(
20
23
  <GradientPicker
21
24
  aria-label="Gradients"
@@ -51,7 +54,7 @@ describe( 'GradientPicker', () => {
51
54
  <GradientPicker
52
55
  aria-label="Gradients"
53
56
  gradients={ DUPLICATE_GRADIENTS }
54
- onChange={ jest.fn() }
57
+ onChange={ vi.fn() }
55
58
  asButtons={ false }
56
59
  presentation="command-buttons"
57
60
  disableCustomGradients
@@ -76,7 +79,7 @@ describe( 'GradientPicker', () => {
76
79
  gradients={ DUPLICATE_GRADIENTS }
77
80
  value={ GRADIENT_A }
78
81
  selectedSlug="dark-background"
79
- onChange={ jest.fn() }
82
+ onChange={ vi.fn() }
80
83
  asButtons
81
84
  disableCustomGradients
82
85
  clearable={ false }
@@ -104,7 +107,7 @@ describe( 'GradientPicker', () => {
104
107
  aria-label="Gradient"
105
108
  gradients={ DUPLICATE_GRADIENTS }
106
109
  value={ undefined }
107
- onChange={ jest.fn() }
110
+ onChange={ vi.fn() }
108
111
  disableCustomGradients
109
112
  />
110
113
  );
@@ -119,7 +122,7 @@ describe( 'GradientPicker', () => {
119
122
  gradients={ DUPLICATE_GRADIENTS }
120
123
  value={ GRADIENT_A }
121
124
  selectedSlug="dark-text"
122
- onChange={ jest.fn() }
125
+ onChange={ vi.fn() }
123
126
  disableCustomGradients
124
127
  />
125
128
  );
@@ -136,7 +139,7 @@ describe( 'GradientPicker', () => {
136
139
  aria-label="Gradient"
137
140
  gradients={ DUPLICATE_GRADIENTS }
138
141
  value={ GRADIENT_A }
139
- onChange={ jest.fn() }
142
+ onChange={ vi.fn() }
140
143
  disableCustomGradients
141
144
  />
142
145
  );
@@ -153,7 +156,7 @@ describe( 'GradientPicker', () => {
153
156
  gradients={ DUPLICATE_GRADIENTS }
154
157
  value={ GRADIENT_A }
155
158
  selectedSlug=""
156
- onChange={ jest.fn() }
159
+ onChange={ vi.fn() }
157
160
  disableCustomGradients
158
161
  />
159
162
  );
@@ -165,7 +168,7 @@ describe( 'GradientPicker', () => {
165
168
 
166
169
  it( 'should pass slug as third argument to onChange when a swatch is clicked', async () => {
167
170
  const user = userEvent.setup();
168
- const onChange = jest.fn();
171
+ const onChange = vi.fn();
169
172
 
170
173
  render(
171
174
  <GradientPicker
@@ -190,7 +193,7 @@ describe( 'GradientPicker', () => {
190
193
 
191
194
  it( 'should pass slug as third argument to onChange for multiple-origin gradients', async () => {
192
195
  const user = userEvent.setup();
193
- const onChange = jest.fn();
196
+ const onChange = vi.fn();
194
197
 
195
198
  render(
196
199
  <GradientPicker
@@ -1,6 +1,8 @@
1
+ import { describe, expect, it, vi } from 'vitest';
1
2
  import { render, screen, within } from '@testing-library/react';
2
3
  import userEvent from '@testing-library/user-event';
3
4
  import Guide from '..';
5
+ globalThis.wpVitest.mockMatchMedia();
4
6
 
5
7
  const defaultProps = {
6
8
  onFinish: () => {},
@@ -92,7 +94,7 @@ describe( 'Guide', () => {
92
94
 
93
95
  it( 'calls onFinish when the finish button is clicked', async () => {
94
96
  const user = userEvent.setup();
95
- const onFinish = jest.fn();
97
+ const onFinish = vi.fn();
96
98
  render(
97
99
  <Guide
98
100
  { ...defaultProps }
@@ -107,7 +109,7 @@ describe( 'Guide', () => {
107
109
 
108
110
  it( 'calls onFinish when the modal is closed', async () => {
109
111
  const user = userEvent.setup();
110
- const onFinish = jest.fn();
112
+ const onFinish = vi.fn();
111
113
  render(
112
114
  <Guide
113
115
  { ...defaultProps }
@@ -1,6 +1,6 @@
1
- // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
- exports[`props should render alignment 1`] = `
3
+ exports[`props > should render alignment 1`] = `
4
4
  <div>
5
5
  <div
6
6
  class="style-flex style-items-row style-expanded-row components-flex components-h-stack"
@@ -14,7 +14,7 @@ exports[`props should render alignment 1`] = `
14
14
  </div>
15
15
  `;
16
16
 
17
- exports[`props should render correctly 1`] = `
17
+ exports[`props > should render correctly 1`] = `
18
18
  <div>
19
19
  <div
20
20
  class="style-flex style-items-row style-expanded-row components-flex components-h-stack"
@@ -28,7 +28,7 @@ exports[`props should render correctly 1`] = `
28
28
  </div>
29
29
  `;
30
30
 
31
- exports[`props should render spacing 1`] = `
31
+ exports[`props > should render spacing 1`] = `
32
32
  <div>
33
33
  <div
34
34
  class="style-flex style-items-row style-expanded-row components-flex components-h-stack"
@@ -1,7 +1,10 @@
1
+ import { describe, expect, test } from 'vitest';
1
2
  import { render } from '@testing-library/react';
2
3
  import { View } from '../../view';
3
4
  import { HStack } from '..';
4
5
 
6
+ globalThis.wpVitest.mockMatchMedia();
7
+
5
8
  describe( 'props', () => {
6
9
  test( 'should render correctly', () => {
7
10
  const { container } = render(
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it, vi } from 'vitest';
1
2
  import { render, screen } from '@testing-library/react';
2
3
  import withFallbackStyles from '..';
3
4
 
@@ -9,7 +10,7 @@ describe( 'withFallbackStyles', () => {
9
10
  it( 'derives the fallback styles from the provided node prop', () => {
10
11
  const node = document.createElement( 'span' );
11
12
  node.dataset.color = 'rgb(1, 2, 3)';
12
- const mapNodeToProps = jest.fn( ( el: HTMLElement ) => ( {
13
+ const mapNodeToProps = vi.fn( ( el: HTMLElement ) => ( {
13
14
  fallbackColor: el.dataset.color,
14
15
  } ) );
15
16
  const Component = withFallbackStyles( mapNodeToProps )( Wrapped );
@@ -25,7 +26,7 @@ describe( 'withFallbackStyles', () => {
25
26
  } );
26
27
 
27
28
  it( 'derives the fallback styles from the internal wrapper node when no node prop is given', () => {
28
- const mapNodeToProps = jest.fn( ( el: HTMLElement ) => ( {
29
+ const mapNodeToProps = vi.fn( ( el: HTMLElement ) => ( {
29
30
  fallbackColor: el.tagName.toLowerCase(),
30
31
  } ) );
31
32
  const Component = withFallbackStyles( mapNodeToProps )( Wrapped );
@@ -0,0 +1,87 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`withFilters > should display a component overridden by the filter 1`] = `
4
+ <div>
5
+ <div>
6
+ Overridden component
7
+ </div>
8
+ </div>
9
+ `;
10
+
11
+ exports[`withFilters > should display original component when no filters applied 1`] = `
12
+ <div>
13
+ <div>
14
+ My component
15
+ </div>
16
+ </div>
17
+ `;
18
+
19
+ exports[`withFilters > should display two components composed by the filter 1`] = `
20
+ <div>
21
+ <div>
22
+ <div>
23
+ My component
24
+ </div>
25
+ <div>
26
+ Composed component
27
+ </div>
28
+ </div>
29
+ </div>
30
+ `;
31
+
32
+ exports[`withFilters > should not re-render component when new filter added before component was mounted 1`] = `
33
+ <div>
34
+ <blockquote>
35
+ <div>
36
+ Spied component
37
+ </div>
38
+ </blockquote>
39
+ </div>
40
+ `;
41
+
42
+ exports[`withFilters > should re-render both components once each when one filter added 1`] = `
43
+ <div>
44
+ <section>
45
+ <blockquote>
46
+ <div>
47
+ Spied component
48
+ </div>
49
+ </blockquote>
50
+ <blockquote>
51
+ <div>
52
+ Spied component
53
+ </div>
54
+ </blockquote>
55
+ </section>
56
+ </div>
57
+ `;
58
+
59
+ exports[`withFilters > should re-render component once when new filter added after component was mounted 1`] = `
60
+ <div>
61
+ <blockquote>
62
+ <div>
63
+ Spied component
64
+ </div>
65
+ </blockquote>
66
+ </div>
67
+ `;
68
+
69
+ exports[`withFilters > should re-render component once when two filters added in the same animation frame 1`] = `
70
+ <div>
71
+ <section>
72
+ <blockquote>
73
+ <div>
74
+ Spied component
75
+ </div>
76
+ </blockquote>
77
+ </section>
78
+ </div>
79
+ `;
80
+
81
+ exports[`withFilters > should re-render component twice when new filter added and removed in two different animation frames 1`] = `
82
+ <div>
83
+ <div>
84
+ Spied component
85
+ </div>
86
+ </div>
87
+ `;