@wordpress/components 25.9.1 → 25.10.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 +32 -0
  2. package/build/alignment-matrix-control/cell.js +8 -5
  3. package/build/alignment-matrix-control/cell.js.map +1 -1
  4. package/build/alignment-matrix-control/index.js +27 -43
  5. package/build/alignment-matrix-control/index.js.map +1 -1
  6. package/build/alignment-matrix-control/utils.js +29 -9
  7. package/build/alignment-matrix-control/utils.js.map +1 -1
  8. package/build/circular-option-picker/circular-option-picker-option.js +20 -39
  9. package/build/circular-option-picker/circular-option-picker-option.js.map +1 -1
  10. package/build/circular-option-picker/circular-option-picker.js +11 -32
  11. package/build/circular-option-picker/circular-option-picker.js.map +1 -1
  12. package/build/circular-option-picker/types.js.map +1 -1
  13. package/build/color-palette/index.js +7 -2
  14. package/build/color-palette/index.js.map +1 -1
  15. package/build/color-picker/component.js +12 -2
  16. package/build/color-picker/component.js.map +1 -1
  17. package/build/color-picker/picker.js +77 -1
  18. package/build/color-picker/picker.js.map +1 -1
  19. package/build/color-picker/styles.js +8 -8
  20. package/build/color-picker/styles.js.map +1 -1
  21. package/build/color-picker/types.js.map +1 -1
  22. package/build/composite/v2.js +43 -0
  23. package/build/composite/v2.js.map +1 -0
  24. package/build/confirm-dialog/component.js +74 -8
  25. package/build/confirm-dialog/component.js.map +1 -1
  26. package/build/confirm-dialog/types.js.map +1 -1
  27. package/build/custom-gradient-picker/gradient-bar/control-points.js +13 -4
  28. package/build/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
  29. package/build/font-size-picker/utils.js +1 -1
  30. package/build/font-size-picker/utils.js.map +1 -1
  31. package/build/modal/index.js +45 -16
  32. package/build/modal/index.js.map +1 -1
  33. package/build/palette-edit/index.js +4 -0
  34. package/build/palette-edit/index.js.map +1 -1
  35. package/build/popover/index.js +34 -6
  36. package/build/popover/index.js.map +1 -1
  37. package/build/private-apis.js +9 -1
  38. package/build/private-apis.js.map +1 -1
  39. package/build/progress-bar/styles.js +5 -5
  40. package/build/progress-bar/styles.js.map +1 -1
  41. package/build/sandbox/index.js +1 -1
  42. package/build/sandbox/index.js.map +1 -1
  43. package/build/sandbox/index.native.js +1 -1
  44. package/build/sandbox/index.native.js.map +1 -1
  45. package/build/tabs/context.js +16 -0
  46. package/build/tabs/context.js.map +1 -0
  47. package/build/tabs/index.js +147 -0
  48. package/build/tabs/index.js.map +1 -0
  49. package/build/tabs/styles.js +38 -0
  50. package/build/tabs/styles.js.map +1 -0
  51. package/build/tabs/tab.js +46 -0
  52. package/build/tabs/tab.js.map +1 -0
  53. package/build/tabs/tablist.js +47 -0
  54. package/build/tabs/tablist.js.map +1 -0
  55. package/build/tabs/tabpanel.js +48 -0
  56. package/build/tabs/tabpanel.js.map +1 -0
  57. package/build/tabs/types.js +6 -0
  58. package/build/tabs/types.js.map +1 -0
  59. package/build/text/component.js +7 -6
  60. package/build/text/component.js.map +1 -1
  61. package/build/text/hook.js +6 -15
  62. package/build/text/hook.js.map +1 -1
  63. package/build/text/index.js.map +1 -1
  64. package/build/text/styles.js +7 -7
  65. package/build/text/styles.js.map +1 -1
  66. package/build/text/types.js.map +1 -1
  67. package/build/text/utils.js +17 -33
  68. package/build/text/utils.js.map +1 -1
  69. package/build/toggle-group-control/toggle-group-control-option-base/component.js +1 -0
  70. package/build/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
  71. package/build/toolbar/toolbar/index.js +17 -10
  72. package/build/toolbar/toolbar/index.js.map +1 -1
  73. package/build/toolbar/toolbar/types.js.map +1 -1
  74. package/build/tools-panel/tools-panel-item/hook.js +2 -2
  75. package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
  76. package/build/tools-panel/types.js.map +1 -1
  77. package/build/unit-control/utils.js +108 -0
  78. package/build/unit-control/utils.js.map +1 -1
  79. package/build/utils/unit-values.js +1 -1
  80. package/build/utils/unit-values.js.map +1 -1
  81. package/build-module/alignment-matrix-control/cell.js +7 -4
  82. package/build-module/alignment-matrix-control/cell.js.map +1 -1
  83. package/build-module/alignment-matrix-control/index.js +27 -43
  84. package/build-module/alignment-matrix-control/index.js.map +1 -1
  85. package/build-module/alignment-matrix-control/utils.js +29 -8
  86. package/build-module/alignment-matrix-control/utils.js.map +1 -1
  87. package/build-module/circular-option-picker/circular-option-picker-option.js +20 -39
  88. package/build-module/circular-option-picker/circular-option-picker-option.js.map +1 -1
  89. package/build-module/circular-option-picker/circular-option-picker.js +10 -31
  90. package/build-module/circular-option-picker/circular-option-picker.js.map +1 -1
  91. package/build-module/circular-option-picker/types.js.map +1 -1
  92. package/build-module/color-palette/index.js +7 -2
  93. package/build-module/color-palette/index.js.map +1 -1
  94. package/build-module/color-picker/component.js +13 -3
  95. package/build-module/color-picker/component.js.map +1 -1
  96. package/build-module/color-picker/picker.js +78 -2
  97. package/build-module/color-picker/picker.js.map +1 -1
  98. package/build-module/color-picker/styles.js +8 -8
  99. package/build-module/color-picker/styles.js.map +1 -1
  100. package/build-module/color-picker/types.js.map +1 -1
  101. package/build-module/composite/v2.js +15 -0
  102. package/build-module/composite/v2.js.map +1 -0
  103. package/build-module/confirm-dialog/component.js +72 -7
  104. package/build-module/confirm-dialog/component.js.map +1 -1
  105. package/build-module/confirm-dialog/types.js.map +1 -1
  106. package/build-module/custom-gradient-picker/gradient-bar/control-points.js +13 -4
  107. package/build-module/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
  108. package/build-module/font-size-picker/utils.js +1 -1
  109. package/build-module/font-size-picker/utils.js.map +1 -1
  110. package/build-module/modal/index.js +47 -18
  111. package/build-module/modal/index.js.map +1 -1
  112. package/build-module/palette-edit/index.js +4 -0
  113. package/build-module/palette-edit/index.js.map +1 -1
  114. package/build-module/popover/index.js +34 -6
  115. package/build-module/popover/index.js.map +1 -1
  116. package/build-module/private-apis.js +9 -1
  117. package/build-module/private-apis.js.map +1 -1
  118. package/build-module/progress-bar/styles.js +5 -5
  119. package/build-module/progress-bar/styles.js.map +1 -1
  120. package/build-module/sandbox/index.js +1 -1
  121. package/build-module/sandbox/index.js.map +1 -1
  122. package/build-module/sandbox/index.native.js +1 -1
  123. package/build-module/sandbox/index.native.js.map +1 -1
  124. package/build-module/tabs/context.js +12 -0
  125. package/build-module/tabs/context.js.map +1 -0
  126. package/build-module/tabs/index.js +142 -0
  127. package/build-module/tabs/index.js.map +1 -0
  128. package/build-module/tabs/styles.js +36 -0
  129. package/build-module/tabs/styles.js.map +1 -0
  130. package/build-module/tabs/tab.js +43 -0
  131. package/build-module/tabs/tab.js.map +1 -0
  132. package/build-module/tabs/tablist.js +41 -0
  133. package/build-module/tabs/tablist.js.map +1 -0
  134. package/build-module/tabs/tabpanel.js +43 -0
  135. package/build-module/tabs/tabpanel.js.map +1 -0
  136. package/build-module/tabs/types.js +2 -0
  137. package/build-module/tabs/types.js.map +1 -0
  138. package/build-module/text/component.js +6 -6
  139. package/build-module/text/component.js.map +1 -1
  140. package/build-module/text/hook.js +11 -19
  141. package/build-module/text/hook.js.map +1 -1
  142. package/build-module/text/index.js.map +1 -1
  143. package/build-module/text/styles.js +7 -7
  144. package/build-module/text/styles.js.map +1 -1
  145. package/build-module/text/types.js.map +1 -1
  146. package/build-module/text/utils.js +17 -10
  147. package/build-module/text/utils.js.map +1 -1
  148. package/build-module/toggle-group-control/toggle-group-control-option-base/component.js +1 -0
  149. package/build-module/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
  150. package/build-module/toolbar/toolbar/index.js +18 -11
  151. package/build-module/toolbar/toolbar/index.js.map +1 -1
  152. package/build-module/toolbar/toolbar/types.js.map +1 -1
  153. package/build-module/tools-panel/tools-panel-item/hook.js +2 -2
  154. package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
  155. package/build-module/tools-panel/types.js.map +1 -1
  156. package/build-module/unit-control/utils.js +108 -0
  157. package/build-module/unit-control/utils.js.map +1 -1
  158. package/build-module/utils/unit-values.js +1 -1
  159. package/build-module/utils/unit-values.js.map +1 -1
  160. package/build-style/style-rtl.css +16 -4
  161. package/build-style/style.css +16 -4
  162. package/build-types/alignment-matrix-control/cell.d.ts +1 -1
  163. package/build-types/alignment-matrix-control/cell.d.ts.map +1 -1
  164. package/build-types/alignment-matrix-control/index.d.ts.map +1 -1
  165. package/build-types/alignment-matrix-control/stories/index.story.d.ts.map +1 -1
  166. package/build-types/alignment-matrix-control/utils.d.ts +9 -9
  167. package/build-types/alignment-matrix-control/utils.d.ts.map +1 -1
  168. package/build-types/circular-option-picker/circular-option-picker-option.d.ts.map +1 -1
  169. package/build-types/circular-option-picker/circular-option-picker.d.ts.map +1 -1
  170. package/build-types/circular-option-picker/types.d.ts +4 -6
  171. package/build-types/circular-option-picker/types.d.ts.map +1 -1
  172. package/build-types/color-palette/index.d.ts.map +1 -1
  173. package/build-types/color-picker/component.d.ts.map +1 -1
  174. package/build-types/color-picker/picker.d.ts +1 -1
  175. package/build-types/color-picker/picker.d.ts.map +1 -1
  176. package/build-types/color-picker/styles.d.ts.map +1 -1
  177. package/build-types/color-picker/types.d.ts +3 -0
  178. package/build-types/color-picker/types.d.ts.map +1 -1
  179. package/build-types/composite/v2.d.ts +12 -0
  180. package/build-types/composite/v2.d.ts.map +1 -0
  181. package/build-types/confirm-dialog/component.d.ts +70 -29
  182. package/build-types/confirm-dialog/component.d.ts.map +1 -1
  183. package/build-types/confirm-dialog/stories/index.story.d.ts +11 -0
  184. package/build-types/confirm-dialog/stories/index.story.d.ts.map +1 -0
  185. package/build-types/confirm-dialog/test/index.d.ts +2 -0
  186. package/build-types/confirm-dialog/test/index.d.ts.map +1 -0
  187. package/build-types/confirm-dialog/types.d.ts +32 -10
  188. package/build-types/confirm-dialog/types.d.ts.map +1 -1
  189. package/build-types/custom-gradient-picker/gradient-bar/control-points.d.ts.map +1 -1
  190. package/build-types/font-size-picker/utils.d.ts.map +1 -1
  191. package/build-types/heading/stories/index.story.d.ts.map +1 -1
  192. package/build-types/modal/index.d.ts.map +1 -1
  193. package/build-types/palette-edit/index.d.ts.map +1 -1
  194. package/build-types/popover/index.d.ts +1 -1
  195. package/build-types/popover/index.d.ts.map +1 -1
  196. package/build-types/popover/stories/e2e/index.story.d.ts +1 -1
  197. package/build-types/private-apis.d.ts.map +1 -1
  198. package/build-types/progress-bar/styles.d.ts.map +1 -1
  199. package/build-types/sandbox/index.d.ts.map +1 -1
  200. package/build-types/tabs/context.d.ts +8 -0
  201. package/build-types/tabs/context.d.ts.map +1 -0
  202. package/build-types/tabs/index.d.ts +13 -0
  203. package/build-types/tabs/index.d.ts.map +1 -0
  204. package/build-types/tabs/stories/index.story.d.ts +20 -0
  205. package/build-types/tabs/stories/index.story.d.ts.map +1 -0
  206. package/build-types/tabs/styles.d.ts +17 -0
  207. package/build-types/tabs/styles.d.ts.map +1 -0
  208. package/build-types/tabs/tab.d.ts +10 -0
  209. package/build-types/tabs/tab.d.ts.map +1 -0
  210. package/build-types/tabs/tablist.d.ts +7 -0
  211. package/build-types/tabs/tablist.d.ts.map +1 -0
  212. package/build-types/tabs/tabpanel.d.ts +7 -0
  213. package/build-types/tabs/tabpanel.d.ts.map +1 -0
  214. package/build-types/tabs/test/index.d.ts +2 -0
  215. package/build-types/tabs/test/index.d.ts.map +1 -0
  216. package/build-types/tabs/types.d.ts +134 -0
  217. package/build-types/tabs/types.d.ts.map +1 -0
  218. package/build-types/text/component.d.ts +4 -2
  219. package/build-types/text/component.d.ts.map +1 -1
  220. package/build-types/text/hook.d.ts +171 -165
  221. package/build-types/text/hook.d.ts.map +1 -1
  222. package/build-types/text/index.d.ts +2 -2
  223. package/build-types/text/index.d.ts.map +1 -1
  224. package/build-types/text/stories/index.story.d.ts +21 -0
  225. package/build-types/text/stories/index.story.d.ts.map +1 -0
  226. package/build-types/text/styles.d.ts +7 -7
  227. package/build-types/text/styles.d.ts.map +1 -1
  228. package/build-types/text/types.d.ts +1 -1
  229. package/build-types/text/types.d.ts.map +1 -1
  230. package/build-types/text/utils.d.ts +56 -61
  231. package/build-types/text/utils.d.ts.map +1 -1
  232. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
  233. package/build-types/toolbar/stories/index.story.d.ts +5 -0
  234. package/build-types/toolbar/stories/index.story.d.ts.map +1 -1
  235. package/build-types/toolbar/toolbar/index.d.ts.map +1 -1
  236. package/build-types/toolbar/toolbar/types.d.ts +10 -0
  237. package/build-types/toolbar/toolbar/types.d.ts.map +1 -1
  238. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  239. package/build-types/tools-panel/types.d.ts +2 -0
  240. package/build-types/tools-panel/types.d.ts.map +1 -1
  241. package/build-types/unit-control/utils.d.ts.map +1 -1
  242. package/package.json +19 -19
  243. package/src/alignment-matrix-control/cell.tsx +6 -2
  244. package/src/alignment-matrix-control/index.tsx +31 -54
  245. package/src/alignment-matrix-control/stories/index.story.tsx +3 -7
  246. package/src/alignment-matrix-control/test/index.tsx +117 -18
  247. package/src/alignment-matrix-control/utils.tsx +33 -9
  248. package/src/button/style.scss +1 -2
  249. package/src/circular-option-picker/circular-option-picker-option.tsx +24 -38
  250. package/src/circular-option-picker/circular-option-picker.tsx +11 -28
  251. package/src/circular-option-picker/types.ts +6 -5
  252. package/src/color-palette/index.tsx +6 -1
  253. package/src/color-picker/component.tsx +25 -3
  254. package/src/color-picker/picker.tsx +96 -2
  255. package/src/color-picker/styles.ts +0 -1
  256. package/src/color-picker/types.ts +3 -0
  257. package/src/composite/v2.ts +22 -0
  258. package/src/confirm-dialog/README.md +1 -1
  259. package/src/confirm-dialog/component.tsx +79 -13
  260. package/src/confirm-dialog/stories/{index.story.js → index.story.tsx} +26 -24
  261. package/src/confirm-dialog/test/{index.js → index.tsx} +3 -3
  262. package/src/confirm-dialog/types.ts +32 -12
  263. package/src/custom-gradient-picker/gradient-bar/control-points.tsx +32 -25
  264. package/src/font-size-picker/utils.ts +2 -1
  265. package/src/heading/stories/index.story.tsx +2 -4
  266. package/src/modal/index.tsx +58 -22
  267. package/src/modal/test/index.tsx +29 -0
  268. package/src/notice/style.scss +0 -1
  269. package/src/palette-edit/index.tsx +4 -0
  270. package/src/popover/index.tsx +99 -57
  271. package/src/popover/style.scss +9 -0
  272. package/src/private-apis.ts +15 -1
  273. package/src/progress-bar/styles.ts +19 -4
  274. package/src/sandbox/index.native.js +1 -1
  275. package/src/sandbox/index.tsx +3 -1
  276. package/src/tabs/README.md +242 -0
  277. package/src/tabs/context.ts +13 -0
  278. package/src/tabs/index.tsx +167 -0
  279. package/src/tabs/stories/index.story.tsx +352 -0
  280. package/src/tabs/styles.ts +103 -0
  281. package/src/tabs/tab.tsx +39 -0
  282. package/src/tabs/tablist.tsx +40 -0
  283. package/src/tabs/tabpanel.tsx +42 -0
  284. package/src/tabs/test/index.tsx +1124 -0
  285. package/src/tabs/types.ts +142 -0
  286. package/src/text/README.md +2 -2
  287. package/src/text/{component.js → component.tsx} +10 -6
  288. package/src/text/{hook.js → hook.ts} +12 -15
  289. package/src/text/stories/index.story.tsx +80 -0
  290. package/src/text/types.ts +1 -6
  291. package/src/text/{utils.js → utils.ts} +40 -14
  292. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +8 -0
  293. package/src/toggle-group-control/toggle-group-control-option-base/component.tsx +1 -0
  294. package/src/toolbar/stories/index.story.tsx +15 -0
  295. package/src/toolbar/test/index.tsx +8 -0
  296. package/src/toolbar/toolbar/README.md +9 -0
  297. package/src/toolbar/toolbar/index.tsx +21 -12
  298. package/src/toolbar/toolbar/style.scss +9 -0
  299. package/src/toolbar/toolbar/types.ts +10 -0
  300. package/src/tools-panel/tools-panel/README.md +3 -0
  301. package/src/tools-panel/tools-panel-item/hook.ts +4 -6
  302. package/src/tools-panel/types.ts +2 -0
  303. package/src/unit-control/utils.ts +124 -0
  304. package/src/utils/unit-values.ts +1 -1
  305. package/tsconfig.tsbuildinfo +1 -1
  306. package/src/text/stories/index.story.js +0 -53
  307. /package/src/text/{index.js → index.ts} +0 -0
  308. /package/src/text/{styles.js → styles.ts} +0 -0
@@ -0,0 +1,142 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ // eslint-disable-next-line no-restricted-imports
5
+ import type * as Ariakit from '@ariakit/react';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import type { IconType } from '../icon';
11
+
12
+ export type TabsContextProps =
13
+ | {
14
+ /**
15
+ * The tabStore object returned by Ariakit's `useTabStore` hook.
16
+ */
17
+ store: Ariakit.TabStore;
18
+ /**
19
+ * The unique id string for this instance of the Tabs component.
20
+ */
21
+ instanceId: string;
22
+ }
23
+ | undefined;
24
+
25
+ export type TabsProps = {
26
+ /**
27
+ * The children elements, which should be at least a
28
+ * `Tabs.Tablist` component and a series of `Tabs.TabPanel`
29
+ * components.
30
+ */
31
+ children: React.ReactNode;
32
+ /**
33
+ * When `true`, the tab will be selected when receiving focus (automatic tab
34
+ * activation). When `false`, the tab will be selected only when clicked
35
+ * (manual tab activation). See the official W3C docs for more info.
36
+ *
37
+ * @default true
38
+ *
39
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/tabpanel/
40
+ */
41
+ selectOnMove?: boolean;
42
+ /**
43
+ * The id of the tab to be selected upon mounting of component.
44
+ * If this prop is not set, the first tab will be selected by default.
45
+ * The id provided will be internally prefixed with the
46
+ * `TabsContextProps.instanceId`.
47
+ *
48
+ * Note: this prop will be overridden by the `selectedTabId` prop if it is
49
+ * provided. (Controlled Mode)
50
+ */
51
+ initialTabId?: string;
52
+ /**
53
+ * The function called when a tab has been selected.
54
+ * It is passed the id of the newly selected tab as an argument.
55
+ */
56
+ onSelect?: ( selectedId: string | null | undefined ) => void;
57
+
58
+ /**
59
+ * The orientation of the tablist.
60
+ *
61
+ * @default `horizontal`
62
+ */
63
+ orientation?: 'horizontal' | 'vertical';
64
+ /**
65
+ * The Id of the tab to display. This id is prepended with the `Tabs`
66
+ * instanceId internally.
67
+ *
68
+ * If left `undefined`, the component assumes it is being used in
69
+ * uncontrolled mode. Consequently, any value different than `undefined`
70
+ * will set the component in `controlled` mode.
71
+ * When in controlled mode, the `null` value will result in no tab being selected.
72
+ */
73
+ selectedTabId?: string | null;
74
+ };
75
+
76
+ export type TabListProps = {
77
+ /**
78
+ * The children elements, which should be a series of `Tabs.TabPanel` components.
79
+ */
80
+ children?: React.ReactNode;
81
+ /**
82
+ * The class name to apply to the tablist.
83
+ */
84
+ className?: string;
85
+ /**
86
+ * Custom CSS styles for the rendered tablist.
87
+ */
88
+ style?: React.CSSProperties;
89
+ };
90
+
91
+ export type TabProps = {
92
+ /**
93
+ * The id of the tab, which is prepended with the `Tabs` instanceId.
94
+ */
95
+ id: string;
96
+ /**
97
+ * Custom CSS styles for the tab.
98
+ */
99
+ style?: React.CSSProperties;
100
+ /**
101
+ * The children elements, generally the text to display on the tab.
102
+ */
103
+ children?: React.ReactNode;
104
+ /**
105
+ * The class name to apply to the tab button.
106
+ */
107
+ className?: string;
108
+ /**
109
+ * The icon used for the tab button.
110
+ */
111
+ icon?: IconType;
112
+ /**
113
+ * Determines if the tab button should be disabled.
114
+ *
115
+ * @default false
116
+ */
117
+ disabled?: boolean;
118
+ /**
119
+ * The type of component to render the tab button as. If this prop is not
120
+ * provided, the tab button will be rendered as a `button` element.
121
+ */
122
+ render?: React.ReactElement;
123
+ };
124
+
125
+ export type TabPanelProps = {
126
+ /**
127
+ * The children elements, generally the content to display on the tabpanel.
128
+ */
129
+ children?: React.ReactNode;
130
+ /**
131
+ * A unique identifier for the TabPanel, which is used to generate a unique `id` for the underlying element.
132
+ */
133
+ id: string;
134
+ /**
135
+ * The class name to apply to the tabpanel.
136
+ */
137
+ className?: string;
138
+ /**
139
+ * Custom CSS styles for the rendered `TabPanel` component.
140
+ */
141
+ style?: React.CSSProperties;
142
+ };
@@ -22,7 +22,7 @@ function Example() {
22
22
 
23
23
  ### adjustLineHeightForInnerControls
24
24
 
25
- **Type**: `boolean`,`"large"`,`"medium"`,`"small"`,`"xSmall"`
25
+ **Type**: `"large"`,`"medium"`,`"small"`,`"xSmall"`
26
26
 
27
27
  Automatically calculate the appropriate line-height value for contents that render text and Control elements (e.g. `TextInput`).
28
28
 
@@ -31,7 +31,7 @@ import { __experimentalText as Text, TextInput } from '@wordpress/components';
31
31
 
32
32
  function Example() {
33
33
  return (
34
- <Text adjustLineHeightForInnerControls>
34
+ <Text adjustLineHeightForInnerControls={"small"}>
35
35
  Lorem ipsum dolor sit amet, consectetur
36
36
  <TextInput value="adipiscing elit..." />
37
37
  </Text>
@@ -1,15 +1,20 @@
1
1
  /**
2
2
  * Internal dependencies
3
3
  */
4
+ import type { WordPressComponentProps } from '../context';
4
5
  import { contextConnect } from '../context';
5
6
  import { View } from '../view';
6
7
  import useText from './hook';
8
+ import type { Props } from './types';
7
9
 
8
10
  /**
9
- * @param {import('../context').WordPressComponentProps<import('./types').Props, 'span'>} props
10
- * @param {import('react').ForwardedRef<any>} forwardedRef
11
+ * @param props
12
+ * @param forwardedRef
11
13
  */
12
- function Text( props, forwardedRef ) {
14
+ function UnconnectedText(
15
+ props: WordPressComponentProps< Props, 'span' >,
16
+ forwardedRef: React.ForwardedRef< any >
17
+ ) {
13
18
  const textProps = useText( props );
14
19
 
15
20
  return <View as="span" { ...textProps } ref={ forwardedRef } />;
@@ -31,6 +36,5 @@ function Text( props, forwardedRef ) {
31
36
  * }
32
37
  * ```
33
38
  */
34
- const ConnectedText = contextConnect( Text, 'Text' );
35
-
36
- export default ConnectedText;
39
+ export const Text = contextConnect( UnconnectedText, 'Text' );
40
+ export default Text;
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
+ import type { SerializedStyles } from '@emotion/react';
4
5
  import { css } from '@emotion/react';
5
6
 
6
7
  /**
@@ -11,6 +12,7 @@ import { useMemo, Children, cloneElement } from '@wordpress/element';
11
12
  /**
12
13
  * Internal dependencies
13
14
  */
15
+ import type { WordPressComponentProps } from '../context';
14
16
  import { hasConnectNamespace, useContextSystem } from '../context';
15
17
  import { useTruncate } from '../truncate';
16
18
  import { getOptimalTextShade } from '../utils/colors';
@@ -20,11 +22,15 @@ import { getFontSize } from '../utils/font-size';
20
22
  import { CONFIG, COLORS } from '../utils';
21
23
  import { getLineHeight } from './get-line-height';
22
24
  import { useCx } from '../utils/hooks/use-cx';
25
+ import type { Props } from './types';
26
+ import type React from 'react';
23
27
 
24
28
  /**
25
29
  * @param {import('../context').WordPressComponentProps<import('./types').Props, 'span'>} props
26
30
  */
27
- export default function useText( props ) {
31
+ export default function useText(
32
+ props: WordPressComponentProps< Props, 'span' >
33
+ ) {
28
34
  const {
29
35
  adjustLineHeightForInnerControls,
30
36
  align,
@@ -50,8 +56,7 @@ export default function useText( props ) {
50
56
  ...otherProps
51
57
  } = useContextSystem( props, 'Text' );
52
58
 
53
- /** @type {import('react').ReactNode} */
54
- let content = children;
59
+ let content: React.ReactNode = children;
55
60
  const isHighlighter = Array.isArray( highlightWords );
56
61
  const isCaption = size === 'caption';
57
62
 
@@ -64,9 +69,7 @@ export default function useText( props ) {
64
69
 
65
70
  content = createHighlighterText( {
66
71
  autoEscape: highlightEscape,
67
- // Disable reason: We need to disable this otherwise it erases the cast
68
- // eslint-disable-next-line object-shorthand
69
- children: /** @type {string} */ ( children ),
72
+ children,
70
73
  caseSensitive: highlightCaseSensitive,
71
74
  searchWords: highlightWords,
72
75
  sanitize: highlightSanitize,
@@ -76,7 +79,7 @@ export default function useText( props ) {
76
79
  const cx = useCx();
77
80
 
78
81
  const classes = useMemo( () => {
79
- const sx = {};
82
+ const sx: Record< string, SerializedStyles | null > = {};
80
83
 
81
84
  const lineHeight = getLineHeight(
82
85
  adjustLineHeightForInnerControls,
@@ -87,12 +90,7 @@ export default function useText( props ) {
87
90
  color,
88
91
  display,
89
92
  fontSize: getFontSize( size ),
90
- /* eslint-disable jsdoc/valid-types */
91
- fontWeight:
92
- /** @type {import('react').CSSProperties['fontWeight']} */ (
93
- weight
94
- ),
95
- /* eslint-enable jsdoc/valid-types */
93
+ fontWeight: weight,
96
94
  lineHeight,
97
95
  letterSpacing,
98
96
  textAlign: align,
@@ -143,8 +141,7 @@ export default function useText( props ) {
143
141
  weight,
144
142
  ] );
145
143
 
146
- /** @type {undefined | 'auto' | 'none'} */
147
- let finalEllipsizeMode;
144
+ let finalEllipsizeMode: undefined | 'auto' | 'none';
148
145
  if ( truncate === true ) {
149
146
  finalEllipsizeMode = 'auto';
150
147
  }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { Meta, StoryFn } from '@storybook/react';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { Text } from '../component';
10
+
11
+ const meta: Meta< typeof Text > = {
12
+ component: Text,
13
+ title: 'Components (Experimental)/Text',
14
+ argTypes: {
15
+ as: { control: { type: 'text' } },
16
+ color: { control: { type: 'color' } },
17
+ display: { control: { type: 'text' } },
18
+ lineHeight: { control: { type: 'text' } },
19
+ letterSpacing: { control: { type: 'text' } },
20
+ optimizeReadabilityFor: { control: { type: 'color' } },
21
+ size: { control: { type: 'text' } },
22
+ variant: {
23
+ options: [ undefined, 'muted' ],
24
+ control: { type: 'select' },
25
+ },
26
+ weight: { control: { type: 'text' } },
27
+ },
28
+ parameters: {
29
+ actions: { argTypesRegex: '^on.*' },
30
+ controls: { expanded: true },
31
+ docs: { canvas: { sourceState: 'shown' } },
32
+ },
33
+ };
34
+ export default meta;
35
+
36
+ const Template: StoryFn< typeof Text > = ( props ) => {
37
+ return <Text { ...props } />;
38
+ };
39
+
40
+ export const Default = Template.bind( {} );
41
+ Default.args = {
42
+ children: 'Code is poetry',
43
+ };
44
+
45
+ export const Truncate = Template.bind( {} );
46
+ Truncate.args = {
47
+ children: `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut
48
+ facilisis dictum tortor, eu tincidunt justo scelerisque tincidunt.
49
+ Duis semper dui id augue malesuada, ut feugiat nisi aliquam.
50
+ Vestibulum venenatis diam sem, finibus dictum massa semper in. Nulla
51
+ facilisi. Nunc vulputate faucibus diam, in lobortis arcu ornare vel.
52
+ In dignissim nunc sed facilisis finibus. Etiam imperdiet mattis
53
+ arcu, sed rutrum sapien blandit gravida. Aenean sollicitudin neque
54
+ eget enim blandit, sit amet rutrum leo vehicula. Nunc malesuada
55
+ ultricies eros ut faucibus. Aliquam erat volutpat. Nulla nec feugiat
56
+ risus. Vivamus iaculis dui aliquet ante ultricies feugiat.
57
+ Vestibulum ante ipsum primis in faucibus orci luctus et ultrices
58
+ posuere cubilia curae; Vivamus nec pretium velit, sit amet
59
+ consectetur ante. Praesent porttitor ex eget fermentum mattis.`,
60
+ numberOfLines: 2,
61
+ truncate: true,
62
+ };
63
+
64
+ export const Highlight = Template.bind( {} );
65
+ Highlight.args = {
66
+ children: `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut
67
+ facilisis dictum tortor, eu tincidunt justo scelerisque tincidunt.
68
+ Duis semper dui id augue malesuada, ut feugiat nisi aliquam.
69
+ Vestibulum venenatis diam sem, finibus dictum massa semper in. Nulla
70
+ facilisi. Nunc vulputate faucibus diam, in lobortis arcu ornare vel.
71
+ In dignissim nunc sed facilisis finibus. Etiam imperdiet mattis
72
+ arcu, sed rutrum sapien blandit gravida. Aenean sollicitudin neque
73
+ eget enim blandit, sit amet rutrum leo vehicula. Nunc malesuada
74
+ ultricies eros ut faucibus. Aliquam erat volutpat. Nulla nec feugiat
75
+ risus. Vivamus iaculis dui aliquet ante ultricies feugiat.
76
+ Vestibulum ante ipsum primis in faucibus orci luctus et ultrices
77
+ posuere cubilia curae; Vivamus nec pretium velit, sit amet
78
+ consectetur ante. Praesent porttitor ex eget fermentum mattis.`,
79
+ highlightWords: [ 'con' ],
80
+ };
package/src/text/types.ts CHANGED
@@ -29,12 +29,7 @@ export interface Props extends TruncateProps {
29
29
  /**
30
30
  * Automatically calculate the appropriate line-height value for contents that render text and Control elements (e.g. `TextInput`).
31
31
  */
32
- adjustLineHeightForInnerControls?:
33
- | boolean
34
- | 'large'
35
- | 'medium'
36
- | 'small'
37
- | 'xSmall';
32
+ adjustLineHeightForInnerControls?: 'large' | 'medium' | 'small' | 'xSmall';
38
33
  /**
39
34
  * Adjusts the text color.
40
35
  */
@@ -2,6 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import memoize from 'memize';
5
+ import type { FindAllArgs } from 'highlight-words-core';
5
6
  import { findAll } from 'highlight-words-core';
6
7
 
7
8
  /**
@@ -14,7 +15,6 @@ import { createElement } from '@wordpress/element';
14
15
  * https://github.com/bvaughn/react-highlight-words/blob/HEAD/src/Highlighter.js
15
16
  */
16
17
 
17
- /* eslint-disable jsdoc/valid-types */
18
18
  /**
19
19
  * @typedef Options
20
20
  * @property {string} [activeClassName=''] Classname for active highlighted areas.
@@ -33,28 +33,55 @@ import { createElement } from '@wordpress/element';
33
33
  * @property {import('react').AllHTMLAttributes<HTMLDivElement>['style']} [unhighlightStyle] Style to apply to unhighlighted text.
34
34
  */
35
35
 
36
+ interface Options {
37
+ activeClassName?: string;
38
+ activeIndex?: number;
39
+ activeStyle?: React.AllHTMLAttributes< HTMLDivElement >[ 'style' ];
40
+ autoEscape?: boolean;
41
+ caseSensitive?: boolean;
42
+ children: string;
43
+ findChunks?: FindAllArgs[ 'findChunks' ];
44
+ highlightClassName?: string | Record< string, unknown >;
45
+ highlightStyle?: React.AllHTMLAttributes< HTMLDivElement >[ 'style' ];
46
+ highlightTag?: keyof JSX.IntrinsicElements;
47
+ sanitize?: FindAllArgs[ 'sanitize' ];
48
+ searchWords?: string[];
49
+ unhighlightClassName?: string;
50
+ unhighlightStyle?: React.AllHTMLAttributes< HTMLDivElement >[ 'style' ];
51
+ }
52
+
36
53
  /**
37
54
  * Maps props to lowercase names.
38
55
  *
39
- * @template {Record<string, unknown>} T
40
- * @param {T} object Props to map.
41
- * @return {{[K in keyof T as Lowercase<string & K>]: T[K]}} The mapped props.
56
+ * @param object Props to map.
57
+ * @return The mapped props.
42
58
  */
43
- /* eslint-enable jsdoc/valid-types */
44
- const lowercaseProps = ( object ) => {
45
- /** @type {any} */
46
- const mapped = {};
59
+ const lowercaseProps = < T extends Record< string, unknown > >( object: T ) => {
60
+ const mapped: Record< string, unknown > = {};
47
61
  for ( const key in object ) {
48
62
  mapped[ key.toLowerCase() ] = object[ key ];
49
63
  }
50
- return mapped;
64
+ return mapped as { [ K in keyof T as Lowercase< string & K > ]: T[ K ] };
51
65
  };
52
66
 
53
67
  const memoizedLowercaseProps = memoize( lowercaseProps );
54
68
 
55
69
  /**
56
- *
57
- * @param {Options} options
70
+ * @param options
71
+ * @param options.activeClassName
72
+ * @param options.activeIndex
73
+ * @param options.activeStyle
74
+ * @param options.autoEscape
75
+ * @param options.caseSensitive
76
+ * @param options.children
77
+ * @param options.findChunks
78
+ * @param options.highlightClassName
79
+ * @param options.highlightStyle
80
+ * @param options.highlightTag
81
+ * @param options.sanitize
82
+ * @param options.searchWords
83
+ * @param options.unhighlightClassName
84
+ * @param options.unhighlightStyle
58
85
  */
59
86
  export function createHighlighterText( {
60
87
  activeClassName = '',
@@ -71,7 +98,7 @@ export function createHighlighterText( {
71
98
  searchWords = [],
72
99
  unhighlightClassName = '',
73
100
  unhighlightStyle,
74
- } ) {
101
+ }: Options ) {
75
102
  if ( ! children ) return null;
76
103
  if ( typeof children !== 'string' ) return children;
77
104
 
@@ -122,8 +149,7 @@ export function createHighlighterText( {
122
149
  ? Object.assign( {}, highlightStyle, activeStyle )
123
150
  : highlightStyle;
124
151
 
125
- /** @type {Record<string, any>} */
126
- const props = {
152
+ const props: Record< string, unknown > = {
127
153
  children: text,
128
154
  className: highlightClassNames,
129
155
  key: index,
@@ -255,6 +255,7 @@ exports[`ToggleGroupControl controlled should render correctly with icons 1`] =
255
255
  data-wp-component="ToggleGroupControlOptionBase"
256
256
  id="toggle-group-control-as-radio-group-8-20"
257
257
  role="radio"
258
+ type="button"
258
259
  >
259
260
  <div
260
261
  class="emotion-13 emotion-14"
@@ -292,6 +293,7 @@ exports[`ToggleGroupControl controlled should render correctly with icons 1`] =
292
293
  data-wp-component="ToggleGroupControlOptionBase"
293
294
  id="toggle-group-control-as-radio-group-8-21"
294
295
  role="radio"
296
+ type="button"
295
297
  >
296
298
  <div
297
299
  class="emotion-13 emotion-14"
@@ -500,6 +502,7 @@ exports[`ToggleGroupControl controlled should render correctly with text options
500
502
  data-wp-component="ToggleGroupControlOptionBase"
501
503
  id="toggle-group-control-as-radio-group-7-18"
502
504
  role="radio"
505
+ type="button"
503
506
  >
504
507
  <div
505
508
  class="emotion-13 emotion-14"
@@ -521,6 +524,7 @@ exports[`ToggleGroupControl controlled should render correctly with text options
521
524
  data-wp-component="ToggleGroupControlOptionBase"
522
525
  id="toggle-group-control-as-radio-group-7-19"
523
526
  role="radio"
527
+ type="button"
524
528
  >
525
529
  <div
526
530
  class="emotion-13 emotion-14"
@@ -796,6 +800,7 @@ exports[`ToggleGroupControl uncontrolled should render correctly with icons 1`]
796
800
  data-wp-component="ToggleGroupControlOptionBase"
797
801
  id="toggle-group-control-as-radio-group-1-2"
798
802
  role="radio"
803
+ type="button"
799
804
  >
800
805
  <div
801
806
  class="emotion-13 emotion-14"
@@ -833,6 +838,7 @@ exports[`ToggleGroupControl uncontrolled should render correctly with icons 1`]
833
838
  data-wp-component="ToggleGroupControlOptionBase"
834
839
  id="toggle-group-control-as-radio-group-1-3"
835
840
  role="radio"
841
+ type="button"
836
842
  >
837
843
  <div
838
844
  class="emotion-13 emotion-14"
@@ -1035,6 +1041,7 @@ exports[`ToggleGroupControl uncontrolled should render correctly with text optio
1035
1041
  data-wp-component="ToggleGroupControlOptionBase"
1036
1042
  id="toggle-group-control-as-radio-group-0-0"
1037
1043
  role="radio"
1044
+ type="button"
1038
1045
  >
1039
1046
  <div
1040
1047
  class="emotion-13 emotion-14"
@@ -1056,6 +1063,7 @@ exports[`ToggleGroupControl uncontrolled should render correctly with text optio
1056
1063
  data-wp-component="ToggleGroupControlOptionBase"
1057
1064
  id="toggle-group-control-as-radio-group-0-1"
1058
1065
  role="radio"
1066
+ type="button"
1059
1067
  >
1060
1068
  <div
1061
1069
  class="emotion-13 emotion-14"
@@ -143,6 +143,7 @@ function ToggleGroupControlOptionBase(
143
143
  <Ariakit.Radio
144
144
  render={
145
145
  <button
146
+ type="button"
146
147
  { ...commonProps }
147
148
  onFocus={ ( event ) => {
148
149
  onFocusProp?.( event );
@@ -52,6 +52,10 @@ const meta: Meta< typeof Toolbar > = {
52
52
  },
53
53
  argTypes: {
54
54
  children: { control: { type: null } },
55
+ variant: {
56
+ options: [ undefined, 'unstyled' ],
57
+ control: { type: 'radio' },
58
+ },
55
59
  },
56
60
  parameters: {
57
61
  controls: { expanded: true },
@@ -181,3 +185,14 @@ WithoutGroup.args = {
181
185
  </>
182
186
  ),
183
187
  };
188
+
189
+ /**
190
+ * Set the variant to `unstyled` to remove default border styles.
191
+ * Otherwise, leave it as `undefined` for default styles.
192
+ */
193
+
194
+ export const Unstyled = Template.bind( {} );
195
+ Unstyled.args = {
196
+ ...Default.args,
197
+ variant: 'unstyled',
198
+ };
@@ -25,5 +25,13 @@ describe( 'Toolbar', () => {
25
25
  screen.getByLabelText( 'control2', { selector: 'button' } )
26
26
  ).toBeInTheDocument();
27
27
  } );
28
+
29
+ it( 'should apply the unstyled variant correctly via the `variant` prop', () => {
30
+ render( <Toolbar label="blocks" variant="unstyled" /> );
31
+
32
+ expect( screen.getByRole( 'toolbar' ) ).toHaveClass(
33
+ 'is-unstyled'
34
+ );
35
+ } );
28
36
  } );
29
37
  } );
@@ -71,6 +71,15 @@ An accessible label for the toolbar.
71
71
 
72
72
  - Required: Yes
73
73
 
74
+ #### `variant`: `'unstyled' | undefined`
75
+
76
+ Specifies the toolbar's style.
77
+
78
+ Leave undefined for the default style. Or `'unstyled'` which removes the border from the toolbar, but keeps the default popover style.
79
+
80
+ - Required: No
81
+ - Default: `undefined`
82
+
74
83
  ## Related components
75
84
 
76
85
  - Toolbar may contain [ToolbarGroup](/packages/components/src/toolbar-group/README.md), [ToolbarButton](/packages/components/src/toolbar-button/README.md) and [ToolbarItem](/packages/components/src/toolbar-Item/README.md) as children.
@@ -7,7 +7,7 @@ import type { ForwardedRef } from 'react';
7
7
  /**
8
8
  * WordPress dependencies
9
9
  */
10
- import { forwardRef } from '@wordpress/element';
10
+ import { forwardRef, useMemo } from '@wordpress/element';
11
11
  import deprecated from '@wordpress/deprecated';
12
12
 
13
13
  /**
@@ -19,23 +19,30 @@ import type { ToolbarProps } from './types';
19
19
  import type { WordPressComponentProps } from '../../context';
20
20
  import { ContextSystemProvider } from '../../context';
21
21
 
22
- const CONTEXT_SYSTEM_VALUE = {
23
- DropdownMenu: {
24
- variant: 'toolbar',
25
- },
26
- Dropdown: {
27
- variant: 'toolbar',
28
- },
29
- };
30
-
31
22
  function UnforwardedToolbar(
32
23
  {
33
24
  className,
34
25
  label,
26
+ variant,
35
27
  ...props
36
28
  }: WordPressComponentProps< ToolbarProps, 'div', false >,
37
29
  ref: ForwardedRef< any >
38
30
  ) {
31
+ const isVariantDefined = variant !== undefined;
32
+ const contextSystemValue = useMemo( () => {
33
+ if ( isVariantDefined ) {
34
+ return {};
35
+ }
36
+ return {
37
+ DropdownMenu: {
38
+ variant: 'toolbar',
39
+ },
40
+ Dropdown: {
41
+ variant: 'toolbar',
42
+ },
43
+ };
44
+ }, [ isVariantDefined ] );
45
+
39
46
  if ( ! label ) {
40
47
  deprecated( 'Using Toolbar without label prop', {
41
48
  since: '5.6',
@@ -55,10 +62,12 @@ function UnforwardedToolbar(
55
62
  // `ToolbarGroup` already uses components-toolbar for compatibility reasons.
56
63
  const finalClassName = classnames(
57
64
  'components-accessible-toolbar',
58
- className
65
+ className,
66
+ variant && `is-${ variant }`
59
67
  );
68
+
60
69
  return (
61
- <ContextSystemProvider value={ CONTEXT_SYSTEM_VALUE }>
70
+ <ContextSystemProvider value={ contextSystemValue }>
62
71
  <ToolbarContainer
63
72
  className={ finalClassName }
64
73
  label={ label }
@@ -7,6 +7,15 @@
7
7
  & > .components-toolbar-group:last-child {
8
8
  border-right: none;
9
9
  }
10
+
11
+ &.is-unstyled {
12
+ border: none;
13
+
14
+ & > .components-toolbar-group {
15
+ border-right: none;
16
+ }
17
+
18
+ }
10
19
  }
11
20
 
12
21
  .components-accessible-toolbar,