@wordpress/components 25.11.1-next.f8d8eceb.0 → 25.13.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 (317) hide show
  1. package/CHANGELOG.md +58 -1
  2. package/build/angle-picker-control/index.js +0 -1
  3. package/build/angle-picker-control/index.js.map +1 -1
  4. package/build/custom-select-control-v2/index.js +87 -0
  5. package/build/custom-select-control-v2/index.js.map +1 -0
  6. package/build/custom-select-control-v2/styles.js +85 -0
  7. package/build/custom-select-control-v2/styles.js.map +1 -0
  8. package/build/custom-select-control-v2/types.js +6 -0
  9. package/build/custom-select-control-v2/types.js.map +1 -0
  10. package/build/disclosure/index.js +37 -7
  11. package/build/disclosure/index.js.map +1 -1
  12. package/build/disclosure/types.js +6 -0
  13. package/build/disclosure/types.js.map +1 -0
  14. package/build/divider/component.js +5 -3
  15. package/build/divider/component.js.map +1 -1
  16. package/build/divider/types.js.map +1 -1
  17. package/build/dropdown-menu-v2-ariakit/index.js +74 -35
  18. package/build/dropdown-menu-v2-ariakit/index.js.map +1 -1
  19. package/build/dropdown-menu-v2-ariakit/styles.js +82 -59
  20. package/build/dropdown-menu-v2-ariakit/styles.js.map +1 -1
  21. package/build/dropdown-menu-v2-ariakit/types.js.map +1 -1
  22. package/build/form-token-field/index.js +6 -2
  23. package/build/form-token-field/index.js.map +1 -1
  24. package/build/form-token-field/token-input.js.map +1 -1
  25. package/build/form-token-field/types.js.map +1 -1
  26. package/build/gradient-picker/index.js +1 -1
  27. package/build/gradient-picker/index.js.map +1 -1
  28. package/build/heading/hook.js +6 -3
  29. package/build/heading/hook.js.map +1 -1
  30. package/build/heading/types.js.map +1 -1
  31. package/build/index.native.js +8 -1
  32. package/build/index.native.js.map +1 -1
  33. package/build/mobile/audio-player/index.native.js +8 -9
  34. package/build/mobile/audio-player/index.native.js.map +1 -1
  35. package/build/mobile/global-styles-context/utils.native.js +44 -3
  36. package/build/mobile/global-styles-context/utils.native.js.map +1 -1
  37. package/build/mobile/utils/alignments.native.js +1 -1
  38. package/build/mobile/utils/alignments.native.js.map +1 -1
  39. package/build/private-apis.js +3 -2
  40. package/build/private-apis.js.map +1 -1
  41. package/build/radio-group/context.js +22 -0
  42. package/build/radio-group/context.js.map +1 -0
  43. package/build/radio-group/index.js +27 -23
  44. package/build/radio-group/index.js.map +1 -1
  45. package/build/radio-group/radio.js +58 -0
  46. package/build/radio-group/radio.js.map +1 -0
  47. package/build/radio-group/types.js +6 -0
  48. package/build/radio-group/types.js.map +1 -0
  49. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
  50. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  51. package/build/slot-fill/types.js.map +1 -1
  52. package/build/tabs/index.js +6 -4
  53. package/build/tabs/index.js.map +1 -1
  54. package/build/tabs/styles.js +14 -7
  55. package/build/tabs/styles.js.map +1 -1
  56. package/build/tabs/tab.js +5 -7
  57. package/build/tabs/tab.js.map +1 -1
  58. package/build/tabs/tablist.js +3 -5
  59. package/build/tabs/tablist.js.map +1 -1
  60. package/build/tabs/tabpanel.js +7 -10
  61. package/build/tabs/tabpanel.js.map +1 -1
  62. package/build/tabs/types.js.map +1 -1
  63. package/build/text/types.js.map +1 -1
  64. package/build/text-control/index.js +5 -1
  65. package/build/text-control/index.js.map +1 -1
  66. package/build/text-control/types.js.map +1 -1
  67. package/build/toggle-group-control/toggle-group-control/component.js +4 -2
  68. package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
  69. package/build/toggle-group-control/toggle-group-control/styles.js +13 -9
  70. package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  71. package/build/toggle-group-control/types.js.map +1 -1
  72. package/build/tools-panel/tools-panel-item/hook.js +5 -1
  73. package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
  74. package/build-module/angle-picker-control/index.js +0 -1
  75. package/build-module/angle-picker-control/index.js.map +1 -1
  76. package/build-module/custom-select-control-v2/index.js +74 -0
  77. package/build-module/custom-select-control-v2/index.js.map +1 -0
  78. package/build-module/custom-select-control-v2/styles.js +71 -0
  79. package/build-module/custom-select-control-v2/styles.js.map +1 -0
  80. package/build-module/custom-select-control-v2/types.js +2 -0
  81. package/build-module/custom-select-control-v2/types.js.map +1 -0
  82. package/build-module/disclosure/index.js +33 -8
  83. package/build-module/disclosure/index.js.map +1 -1
  84. package/build-module/disclosure/types.js +2 -0
  85. package/build-module/disclosure/types.js.map +1 -0
  86. package/build-module/divider/component.js +3 -3
  87. package/build-module/divider/component.js.map +1 -1
  88. package/build-module/divider/types.js.map +1 -1
  89. package/build-module/dropdown-menu-v2-ariakit/index.js +72 -34
  90. package/build-module/dropdown-menu-v2-ariakit/index.js.map +1 -1
  91. package/build-module/dropdown-menu-v2-ariakit/styles.js +69 -40
  92. package/build-module/dropdown-menu-v2-ariakit/styles.js.map +1 -1
  93. package/build-module/dropdown-menu-v2-ariakit/types.js.map +1 -1
  94. package/build-module/form-token-field/index.js +6 -2
  95. package/build-module/form-token-field/index.js.map +1 -1
  96. package/build-module/form-token-field/token-input.js.map +1 -1
  97. package/build-module/form-token-field/types.js.map +1 -1
  98. package/build-module/gradient-picker/index.js +1 -1
  99. package/build-module/gradient-picker/index.js.map +1 -1
  100. package/build-module/heading/hook.js +6 -3
  101. package/build-module/heading/hook.js.map +1 -1
  102. package/build-module/heading/types.js.map +1 -1
  103. package/build-module/index.native.js +1 -1
  104. package/build-module/index.native.js.map +1 -1
  105. package/build-module/mobile/audio-player/index.native.js +9 -10
  106. package/build-module/mobile/audio-player/index.native.js.map +1 -1
  107. package/build-module/mobile/global-styles-context/utils.native.js +43 -4
  108. package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
  109. package/build-module/mobile/utils/alignments.native.js +1 -1
  110. package/build-module/mobile/utils/alignments.native.js.map +1 -1
  111. package/build-module/private-apis.js +4 -3
  112. package/build-module/private-apis.js.map +1 -1
  113. package/build-module/radio-group/context.js +14 -0
  114. package/build-module/radio-group/context.js.map +1 -0
  115. package/build-module/radio-group/index.js +24 -23
  116. package/build-module/radio-group/index.js.map +1 -1
  117. package/build-module/radio-group/radio.js +46 -0
  118. package/build-module/radio-group/radio.js.map +1 -0
  119. package/build-module/radio-group/types.js +2 -0
  120. package/build-module/radio-group/types.js.map +1 -0
  121. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
  122. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  123. package/build-module/slot-fill/types.js.map +1 -1
  124. package/build-module/tabs/index.js +7 -5
  125. package/build-module/tabs/index.js.map +1 -1
  126. package/build-module/tabs/styles.js +11 -5
  127. package/build-module/tabs/styles.js.map +1 -1
  128. package/build-module/tabs/tab.js +7 -9
  129. package/build-module/tabs/tab.js.map +1 -1
  130. package/build-module/tabs/tablist.js +3 -5
  131. package/build-module/tabs/tablist.js.map +1 -1
  132. package/build-module/tabs/tabpanel.js +9 -10
  133. package/build-module/tabs/tabpanel.js.map +1 -1
  134. package/build-module/tabs/types.js.map +1 -1
  135. package/build-module/text/types.js.map +1 -1
  136. package/build-module/text-control/index.js +6 -1
  137. package/build-module/text-control/index.js.map +1 -1
  138. package/build-module/text-control/types.js.map +1 -1
  139. package/build-module/toggle-group-control/toggle-group-control/component.js +4 -2
  140. package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
  141. package/build-module/toggle-group-control/toggle-group-control/styles.js +13 -9
  142. package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  143. package/build-module/toggle-group-control/types.js.map +1 -1
  144. package/build-module/tools-panel/tools-panel-item/hook.js +6 -2
  145. package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
  146. package/build-style/style-rtl.css +52 -8
  147. package/build-style/style.css +52 -8
  148. package/build-types/angle-picker-control/index.d.ts.map +1 -1
  149. package/build-types/box-control/stories/index.story.d.ts +1944 -0
  150. package/build-types/box-control/stories/index.story.d.ts.map +1 -0
  151. package/build-types/card/card-divider/component.d.ts +1 -1
  152. package/build-types/card/card-divider/hook.d.ts +162 -162
  153. package/build-types/color-palette/styles.d.ts +4 -1
  154. package/build-types/color-palette/styles.d.ts.map +1 -1
  155. package/build-types/custom-select-control-v2/index.d.ts +6 -0
  156. package/build-types/custom-select-control-v2/index.d.ts.map +1 -0
  157. package/build-types/custom-select-control-v2/stories/index.story.d.ts +19 -0
  158. package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +1 -0
  159. package/build-types/custom-select-control-v2/styles.d.ts +47 -0
  160. package/build-types/custom-select-control-v2/styles.d.ts.map +1 -0
  161. package/build-types/custom-select-control-v2/types.d.ts +57 -0
  162. package/build-types/custom-select-control-v2/types.d.ts.map +1 -0
  163. package/build-types/date-time/date/styles.d.ts +4 -1
  164. package/build-types/date-time/date/styles.d.ts.map +1 -1
  165. package/build-types/disclosure/index.d.ts +7 -1
  166. package/build-types/disclosure/index.d.ts.map +1 -1
  167. package/build-types/disclosure/types.d.ts +12 -0
  168. package/build-types/disclosure/types.d.ts.map +1 -0
  169. package/build-types/divider/component.d.ts +5 -1
  170. package/build-types/divider/component.d.ts.map +1 -1
  171. package/build-types/divider/stories/index.story.d.ts.map +1 -1
  172. package/build-types/divider/styles.d.ts +1 -1
  173. package/build-types/divider/types.d.ts +2 -2
  174. package/build-types/divider/types.d.ts.map +1 -1
  175. package/build-types/dropdown-menu-v2-ariakit/index.d.ts +11 -2
  176. package/build-types/dropdown-menu-v2-ariakit/index.d.ts.map +1 -1
  177. package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts.map +1 -1
  178. package/build-types/dropdown-menu-v2-ariakit/styles.d.ts +26 -18
  179. package/build-types/dropdown-menu-v2-ariakit/styles.d.ts.map +1 -1
  180. package/build-types/dropdown-menu-v2-ariakit/types.d.ts +1 -7
  181. package/build-types/dropdown-menu-v2-ariakit/types.d.ts.map +1 -1
  182. package/build-types/form-token-field/index.d.ts.map +1 -1
  183. package/build-types/form-token-field/token-input.d.ts.map +1 -1
  184. package/build-types/form-token-field/types.d.ts +1 -1
  185. package/build-types/form-token-field/types.d.ts.map +1 -1
  186. package/build-types/heading/component.d.ts +4 -1
  187. package/build-types/heading/component.d.ts.map +1 -1
  188. package/build-types/heading/hook.d.ts.map +1 -1
  189. package/build-types/heading/types.d.ts +20 -1
  190. package/build-types/heading/types.d.ts.map +1 -1
  191. package/build-types/navigation/styles/navigation-styles.d.ts +4 -1
  192. package/build-types/navigation/styles/navigation-styles.d.ts.map +1 -1
  193. package/build-types/palette-edit/styles.d.ts +4 -1
  194. package/build-types/palette-edit/styles.d.ts.map +1 -1
  195. package/build-types/private-apis.d.ts.map +1 -1
  196. package/build-types/radio-group/context.d.ts +10 -0
  197. package/build-types/radio-group/context.d.ts.map +1 -0
  198. package/build-types/radio-group/index.d.ts +7 -9
  199. package/build-types/radio-group/index.d.ts.map +1 -1
  200. package/build-types/radio-group/radio.d.ts +8 -0
  201. package/build-types/radio-group/radio.d.ts.map +1 -0
  202. package/build-types/radio-group/stories/index.story.d.ts +14 -0
  203. package/build-types/radio-group/stories/index.story.d.ts.map +1 -0
  204. package/build-types/radio-group/types.d.ts +40 -0
  205. package/build-types/radio-group/types.d.ts.map +1 -0
  206. package/build-types/slot-fill/bubbles-virtually/slot.d.ts +1 -1
  207. package/build-types/slot-fill/types.d.ts +16 -6
  208. package/build-types/slot-fill/types.d.ts.map +1 -1
  209. package/build-types/tabs/index.d.ts +4 -3
  210. package/build-types/tabs/index.d.ts.map +1 -1
  211. package/build-types/tabs/stories/index.story.d.ts.map +1 -1
  212. package/build-types/tabs/styles.d.ts +10 -0
  213. package/build-types/tabs/styles.d.ts.map +1 -1
  214. package/build-types/tabs/tab.d.ts +1 -1
  215. package/build-types/tabs/tab.d.ts.map +1 -1
  216. package/build-types/tabs/tablist.d.ts +1 -1
  217. package/build-types/tabs/tablist.d.ts.map +1 -1
  218. package/build-types/tabs/tabpanel.d.ts +4 -1
  219. package/build-types/tabs/tabpanel.d.ts.map +1 -1
  220. package/build-types/tabs/types.d.ts +7 -31
  221. package/build-types/tabs/types.d.ts.map +1 -1
  222. package/build-types/text/types.d.ts +15 -2
  223. package/build-types/text/types.d.ts.map +1 -1
  224. package/build-types/text-control/index.d.ts +2 -1
  225. package/build-types/text-control/index.d.ts.map +1 -1
  226. package/build-types/text-control/types.d.ts +6 -0
  227. package/build-types/text-control/types.d.ts.map +1 -1
  228. package/build-types/toggle-group-control/toggle-group-control/component.d.ts +1 -0
  229. package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
  230. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts +2 -2
  231. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
  232. package/build-types/toggle-group-control/types.d.ts +6 -0
  233. package/build-types/toggle-group-control/types.d.ts.map +1 -1
  234. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  235. package/package.json +19 -20
  236. package/src/angle-picker-control/index.tsx +0 -1
  237. package/src/box-control/stories/index.story.tsx +82 -0
  238. package/src/button/style.scss +10 -2
  239. package/src/combobox-control/README.md +1 -3
  240. package/src/custom-select-control-v2/README.md +73 -0
  241. package/src/custom-select-control-v2/index.tsx +99 -0
  242. package/src/custom-select-control-v2/stories/index.story.tsx +149 -0
  243. package/src/custom-select-control-v2/styles.ts +76 -0
  244. package/src/custom-select-control-v2/types.ts +63 -0
  245. package/src/disclosure/index.tsx +44 -0
  246. package/src/disclosure/types.tsx +10 -0
  247. package/src/divider/component.tsx +3 -3
  248. package/src/divider/stories/index.story.tsx +8 -0
  249. package/src/divider/types.ts +2 -2
  250. package/src/dropdown-menu/style.scss +4 -0
  251. package/src/dropdown-menu-v2-ariakit/README.md +19 -12
  252. package/src/dropdown-menu-v2-ariakit/index.tsx +116 -51
  253. package/src/dropdown-menu-v2-ariakit/stories/index.story.tsx +205 -94
  254. package/src/dropdown-menu-v2-ariakit/styles.ts +153 -117
  255. package/src/dropdown-menu-v2-ariakit/test/index.tsx +5 -36
  256. package/src/dropdown-menu-v2-ariakit/types.ts +1 -8
  257. package/src/form-toggle/style.scss +37 -7
  258. package/src/form-token-field/index.tsx +11 -3
  259. package/src/form-token-field/token-input.tsx +1 -3
  260. package/src/form-token-field/types.ts +1 -0
  261. package/src/gradient-picker/index.tsx +1 -1
  262. package/src/heading/README.md +6 -1
  263. package/src/heading/hook.ts +6 -3
  264. package/src/heading/types.ts +23 -1
  265. package/src/index.native.js +1 -0
  266. package/src/mobile/audio-player/index.native.js +9 -13
  267. package/src/mobile/global-styles-context/utils.native.js +52 -3
  268. package/src/mobile/utils/alignments.native.js +1 -0
  269. package/src/navigable-container/README.md +1 -1
  270. package/src/private-apis.ts +4 -2
  271. package/src/radio-group/context.tsx +18 -0
  272. package/src/radio-group/index.tsx +65 -0
  273. package/src/radio-group/radio.tsx +55 -0
  274. package/src/radio-group/stories/index.story.tsx +90 -0
  275. package/src/radio-group/types.ts +39 -0
  276. package/src/slot-fill/README.md +1 -1
  277. package/src/slot-fill/bubbles-virtually/slot-fill-provider.tsx +1 -1
  278. package/src/slot-fill/types.ts +18 -6
  279. package/src/tabs/README.md +3 -33
  280. package/src/tabs/index.tsx +12 -2
  281. package/src/tabs/stories/index.story.tsx +17 -1
  282. package/src/tabs/styles.ts +16 -0
  283. package/src/tabs/tab.tsx +10 -10
  284. package/src/tabs/tablist.tsx +21 -20
  285. package/src/tabs/tabpanel.tsx +26 -25
  286. package/src/tabs/test/index.tsx +90 -16
  287. package/src/tabs/types.ts +7 -32
  288. package/src/text/README.md +5 -1
  289. package/src/text/types.ts +15 -2
  290. package/src/text-control/index.tsx +5 -1
  291. package/src/text-control/style.scss +5 -0
  292. package/src/text-control/types.ts +6 -0
  293. package/src/toggle-control/README.md +2 -2
  294. package/src/toggle-group-control/toggle-group-control/component.tsx +8 -2
  295. package/src/toggle-group-control/toggle-group-control/styles.ts +13 -4
  296. package/src/toggle-group-control/types.ts +6 -0
  297. package/src/toolbar/toolbar-button/style.scss +0 -5
  298. package/src/tools-panel/tools-panel-item/hook.ts +11 -2
  299. package/tsconfig.tsbuildinfo +1 -1
  300. package/build/radio-group/radio/index.js +0 -49
  301. package/build/radio-group/radio/index.js.map +0 -1
  302. package/build/radio-group/radio-context/index.js +0 -18
  303. package/build/radio-group/radio-context/index.js.map +0 -1
  304. package/build-module/radio-group/radio/index.js +0 -40
  305. package/build-module/radio-group/radio/index.js.map +0 -1
  306. package/build-module/radio-group/radio-context/index.js +0 -10
  307. package/build-module/radio-group/radio-context/index.js.map +0 -1
  308. package/build-types/radio-group/radio/index.d.ts +0 -7
  309. package/build-types/radio-group/radio/index.d.ts.map +0 -1
  310. package/build-types/radio-group/radio-context/index.d.ts +0 -6
  311. package/build-types/radio-group/radio-context/index.d.ts.map +0 -1
  312. package/src/box-control/stories/index.story.js +0 -75
  313. package/src/disclosure/index.js +0 -11
  314. package/src/radio-group/index.js +0 -51
  315. package/src/radio-group/radio/index.js +0 -40
  316. package/src/radio-group/radio-context/index.js +0 -11
  317. package/src/radio-group/stories/index.story.js +0 -83
@@ -17,7 +17,10 @@ export type HeadingSize =
17
17
  | '5'
18
18
  | '6';
19
19
 
20
- export type HeadingProps = Omit< TextProps, 'size' > & {
20
+ export type HeadingProps = Omit<
21
+ TextProps,
22
+ 'size' | 'isBlock' | 'color' | 'weight'
23
+ > & {
21
24
  /**
22
25
  * Passing any of the heading levels to `level` will both render the correct
23
26
  * typographic text size as well as the semantic element corresponding to
@@ -26,4 +29,23 @@ export type HeadingProps = Omit< TextProps, 'size' > & {
26
29
  * @default 2
27
30
  */
28
31
  level?: HeadingSize;
32
+ /**
33
+ * Sets `Heading` to have `display: block`. Note: text truncation only works
34
+ * when `isBlock` is `false`.
35
+ *
36
+ * @default true
37
+ */
38
+ isBlock?: TextProps[ 'isBlock' ];
39
+ /**
40
+ * Adjusts the text color.
41
+ *
42
+ * @default '#1e1e1e'
43
+ */
44
+ color?: TextProps[ 'color' ];
45
+ /**
46
+ * Adjusts font-weight of the text.
47
+ *
48
+ * @default '600'
49
+ */
50
+ weight?: TextProps[ 'weight' ];
29
51
  };
@@ -141,4 +141,5 @@ export {
141
141
  getGlobalStyles,
142
142
  getColorsAndGradients,
143
143
  useMobileGlobalStylesColors,
144
+ useEditorColorScheme,
144
145
  } from './mobile/global-styles-context/utils';
@@ -14,7 +14,7 @@ import { default as VideoPlayer } from 'react-native-video';
14
14
  * WordPress dependencies
15
15
  */
16
16
  import { View } from '@wordpress/primitives';
17
- import { Icon } from '@wordpress/components';
17
+ import { Icon, useEditorColorScheme } from '@wordpress/components';
18
18
  import { withPreferredColorScheme } from '@wordpress/compose';
19
19
  import { __ } from '@wordpress/i18n';
20
20
  import { audio, warning } from '@wordpress/icons';
@@ -34,7 +34,6 @@ import { parseAudioUrl } from './audio-url-parser.native';
34
34
  const isIOS = Platform.OS === 'ios';
35
35
 
36
36
  function Player( {
37
- getStylesFromColorScheme,
38
37
  isUploadInProgress,
39
38
  isUploadFailed,
40
39
  attributes,
@@ -70,14 +69,14 @@ function Player( {
70
69
  }
71
70
  };
72
71
 
73
- const containerStyle = getStylesFromColorScheme(
72
+ const containerStyle = useEditorColorScheme(
74
73
  styles.container,
75
74
  styles.containerDark
76
75
  );
77
76
 
78
- const iconStyle = getStylesFromColorScheme( styles.icon, styles.iconDark );
77
+ const iconStyle = useEditorColorScheme( styles.icon, styles.iconDark );
79
78
 
80
- const iconDisabledStyle = getStylesFromColorScheme(
79
+ const iconDisabledStyle = useEditorColorScheme(
81
80
  styles.iconDisabled,
82
81
  styles.iconDisabledDark
83
82
  );
@@ -89,7 +88,7 @@ function Player( {
89
88
  ...( isDisabled && iconDisabledStyle ),
90
89
  };
91
90
 
92
- const iconContainerStyle = getStylesFromColorScheme(
91
+ const iconContainerStyle = useEditorColorScheme(
93
92
  styles.iconContainer,
94
93
  styles.iconContainerDark
95
94
  );
@@ -99,17 +98,14 @@ function Player( {
99
98
  ...( isIOS ? styles.titleContainerIOS : styles.titleContainerAndroid ),
100
99
  };
101
100
 
102
- const titleStyle = getStylesFromColorScheme(
103
- styles.title,
104
- styles.titleDark
105
- );
101
+ const titleStyle = useEditorColorScheme( styles.title, styles.titleDark );
106
102
 
107
- const uploadFailedStyle = getStylesFromColorScheme(
103
+ const uploadFailedStyle = useEditorColorScheme(
108
104
  styles.uploadFailed,
109
105
  styles.uploadFailedDark
110
106
  );
111
107
 
112
- const subtitleStyle = getStylesFromColorScheme(
108
+ const subtitleStyle = useEditorColorScheme(
113
109
  styles.subtitle,
114
110
  styles.subtitleDark
115
111
  );
@@ -119,7 +115,7 @@ function Player( {
119
115
  ...( isUploadFailed && uploadFailedStyle ),
120
116
  };
121
117
 
122
- const buttonBackgroundStyle = getStylesFromColorScheme(
118
+ const buttonBackgroundStyle = useEditorColorScheme(
123
119
  styles.buttonBackground,
124
120
  styles.buttonBackgroundDark
125
121
  );
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { camelCase } from 'change-case';
5
5
  import { Dimensions } from 'react-native';
6
+ import { colord } from 'colord';
6
7
 
7
8
  /**
8
9
  * WordPress dependencies
@@ -11,7 +12,14 @@ import {
11
12
  getPxFromCssUnit,
12
13
  useSettings,
13
14
  useMultipleOriginColorsAndGradients,
15
+ SETTINGS_DEFAULTS,
14
16
  } from '@wordpress/block-editor';
17
+ import { usePreferredColorSchemeStyle } from '@wordpress/compose';
18
+
19
+ /**
20
+ * Internal dependencies
21
+ */
22
+ import { useGlobalStyles } from './index.native';
15
23
 
16
24
  export const BLOCK_STYLE_ATTRIBUTES = [
17
25
  'textColor',
@@ -355,13 +363,17 @@ export function useMobileGlobalStylesColors( type = 'colors' ) {
355
363
  []
356
364
  );
357
365
  // Default editor colors/gradients if it's not a block-based theme.
358
- const colorPalette =
366
+ const defaultPaletteSetting =
359
367
  type === 'colors' ? 'color.palette' : 'color.gradients';
360
- const [ editorDefaultPalette ] = useSettings( colorPalette );
368
+ const [ defaultPaletteValue ] = useSettings( defaultPaletteSetting );
369
+ // In edge cases, the default palette might be undefined. To avoid
370
+ // exceptions across the editor in that case, we explicitly return
371
+ // the default editor colors.
372
+ const defaultPalette = defaultPaletteValue ?? SETTINGS_DEFAULTS.colors;
361
373
 
362
374
  return availableThemeColors.length >= 1
363
375
  ? availableThemeColors
364
- : editorDefaultPalette;
376
+ : defaultPalette;
365
377
  }
366
378
 
367
379
  export function getColorsAndGradients(
@@ -436,3 +448,40 @@ export function getGlobalStyles( rawStyles, rawFeatures ) {
436
448
  __experimentalGlobalStylesBaseStyles: globalStyles,
437
449
  };
438
450
  }
451
+
452
+ /**
453
+ * Determine and apply appropriate color scheme based on global styles or device's light/dark mode.
454
+ *
455
+ * The function first attempts to retrieve the editor's background color from global styles.
456
+ * If the detected background color is light, light styles are applied, and dark styles otherwise.
457
+ * If no custom background color is defined, styles are applied using the device's dark/light setting.
458
+ *
459
+ * @param {Object} baseStyle - An object representing the base (light theme) styles for the editor.
460
+ * @param {Object} darkStyle - An object representing the additional styles to apply when the editor is in dark mode.
461
+ *
462
+ * @return {Object} - The combined style object that should be applied to the editor.
463
+ */
464
+ export const useEditorColorScheme = ( baseStyle, darkStyle ) => {
465
+ const globalStyles = useGlobalStyles();
466
+
467
+ const deviceColorScheme = usePreferredColorSchemeStyle(
468
+ baseStyle,
469
+ darkStyle
470
+ );
471
+
472
+ const editorColors = globalStyles?.baseColors?.color;
473
+ const editorBackgroundColor = editorColors?.background;
474
+
475
+ const isBackgroundColorDefined =
476
+ typeof editorBackgroundColor !== 'undefined' &&
477
+ editorBackgroundColor !== 'undefined';
478
+
479
+ if ( isBackgroundColorDefined ) {
480
+ const isEditorBackgroundDark = colord( editorBackgroundColor ).isDark();
481
+ return isEditorBackgroundDark
482
+ ? { ...baseStyle, ...darkStyle }
483
+ : baseStyle;
484
+ }
485
+
486
+ return deviceColorScheme;
487
+ };
@@ -10,6 +10,7 @@ export const WIDE_ALIGNMENTS = {
10
10
  },
11
11
  excludeBlocks: [ 'core/heading' ],
12
12
  notInnerContainers: [
13
+ 'core/image',
13
14
  'core/separator',
14
15
  'core/media-text',
15
16
  'core/pullquote',
@@ -24,7 +24,7 @@ Gets an offset, given an event.
24
24
 
25
25
  - Required: No
26
26
 
27
- ### `onKeydown`: `( event: KeyboardEvent ) => void`
27
+ ### `onKeyDown`: `( event: KeyboardEvent ) => void`
28
28
 
29
29
  A callback invoked on the keydown event.
30
30
 
@@ -32,11 +32,12 @@ import {
32
32
  import {
33
33
  DropdownMenu as DropdownMenuV2Ariakit,
34
34
  DropdownMenuGroup as DropdownMenuGroupV2Ariakit,
35
- DropdownMenuGroupLabel as DropdownMenuGroupLabelV2Ariakit,
36
35
  DropdownMenuItem as DropdownMenuItemV2Ariakit,
37
36
  DropdownMenuCheckboxItem as DropdownMenuCheckboxItemV2Ariakit,
38
37
  DropdownMenuRadioItem as DropdownMenuRadioItemV2Ariakit,
39
38
  DropdownMenuSeparator as DropdownMenuSeparatorV2Ariakit,
39
+ DropdownMenuItemLabel as DropdownMenuItemLabelV2Ariakit,
40
+ DropdownMenuItemHelpText as DropdownMenuItemHelpTextV2Ariakit,
40
41
  } from './dropdown-menu-v2-ariakit';
41
42
  import { ComponentsContext } from './context/context-system-provider';
42
43
  import Theme from './theme';
@@ -74,9 +75,10 @@ lock( privateApis, {
74
75
  Theme,
75
76
  DropdownMenuV2Ariakit,
76
77
  DropdownMenuGroupV2Ariakit,
77
- DropdownMenuGroupLabelV2Ariakit,
78
78
  DropdownMenuItemV2Ariakit,
79
79
  DropdownMenuCheckboxItemV2Ariakit,
80
80
  DropdownMenuRadioItemV2Ariakit,
81
81
  DropdownMenuSeparatorV2Ariakit,
82
+ DropdownMenuItemLabelV2Ariakit,
83
+ DropdownMenuItemHelpTextV2Ariakit,
82
84
  } );
@@ -0,0 +1,18 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ // eslint-disable-next-line no-restricted-imports
5
+ import type * as Ariakit from '@ariakit/react';
6
+
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+ import { createContext } from '@wordpress/element';
11
+
12
+ export const RadioGroupContext = createContext< {
13
+ store?: Ariakit.RadioStore;
14
+ disabled?: boolean;
15
+ } >( {
16
+ store: undefined,
17
+ disabled: undefined,
18
+ } );
@@ -0,0 +1,65 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ // eslint-disable-next-line no-restricted-imports
5
+ import * as Ariakit from '@ariakit/react';
6
+
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+ import { useMemo, forwardRef } from '@wordpress/element';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import ButtonGroup from '../button-group';
16
+ import type { WordPressComponentProps } from '../context';
17
+ import { RadioGroupContext } from './context';
18
+ import type { RadioGroupProps } from './types';
19
+
20
+ function UnforwardedRadioGroup(
21
+ {
22
+ label,
23
+ checked,
24
+ defaultChecked,
25
+ disabled,
26
+ onChange,
27
+ children,
28
+ ...props
29
+ }: WordPressComponentProps< RadioGroupProps, 'div', false >,
30
+ ref: React.ForwardedRef< any >
31
+ ) {
32
+ const radioStore = Ariakit.useRadioStore( {
33
+ value: checked,
34
+ defaultValue: defaultChecked,
35
+ setValue: ( newValue ) => {
36
+ onChange?.( newValue ?? undefined );
37
+ },
38
+ } );
39
+
40
+ const contextValue = useMemo(
41
+ () => ( {
42
+ store: radioStore,
43
+ disabled,
44
+ } ),
45
+ [ radioStore, disabled ]
46
+ );
47
+
48
+ return (
49
+ <RadioGroupContext.Provider value={ contextValue }>
50
+ <Ariakit.RadioGroup
51
+ store={ radioStore }
52
+ render={ <ButtonGroup>{ children }</ButtonGroup> }
53
+ aria-label={ label }
54
+ ref={ ref }
55
+ { ...props }
56
+ />
57
+ </RadioGroupContext.Provider>
58
+ );
59
+ }
60
+
61
+ /**
62
+ * @deprecated Use `RadioControl` or `ToggleGroupControl` instead.
63
+ */
64
+ export const RadioGroup = forwardRef( UnforwardedRadioGroup );
65
+ export default RadioGroup;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { forwardRef, useContext } from '@wordpress/element';
5
+
6
+ /**
7
+ * External dependencies
8
+ */
9
+ // eslint-disable-next-line no-restricted-imports
10
+ import * as Ariakit from '@ariakit/react';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import Button from '../button';
16
+ import { RadioGroupContext } from './context';
17
+ import type { WordPressComponentProps } from '../context';
18
+ import type { RadioProps } from './types';
19
+
20
+ function UnforwardedRadio(
21
+ {
22
+ value,
23
+ children,
24
+ ...props
25
+ }: WordPressComponentProps< RadioProps, 'button', false >,
26
+ ref: React.ForwardedRef< any >
27
+ ) {
28
+ const { store, disabled } = useContext( RadioGroupContext );
29
+
30
+ const selectedValue = store?.useState( 'value' );
31
+ const isChecked = selectedValue !== undefined && selectedValue === value;
32
+
33
+ return (
34
+ <Ariakit.Radio
35
+ disabled={ disabled }
36
+ store={ store }
37
+ ref={ ref }
38
+ value={ value }
39
+ render={
40
+ <Button
41
+ variant={ isChecked ? 'primary' : 'secondary' }
42
+ { ...props }
43
+ />
44
+ }
45
+ >
46
+ { children || value }
47
+ </Ariakit.Radio>
48
+ );
49
+ }
50
+
51
+ /**
52
+ * @deprecated Use `RadioControl` or `ToggleGroupControl` instead.
53
+ */
54
+ export const Radio = forwardRef( UnforwardedRadio );
55
+ export default Radio;
@@ -0,0 +1,90 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { Meta, StoryFn } from '@storybook/react';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { RadioGroup } from '..';
10
+ import { Radio } from '../radio';
11
+
12
+ /**
13
+ * WordPress dependencies
14
+ */
15
+ import { useState } from '@wordpress/element';
16
+
17
+ const meta: Meta< typeof RadioGroup > = {
18
+ title: 'Components (Deprecated)/RadioGroup',
19
+ component: RadioGroup,
20
+ // @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170
21
+ subcomponents: { Radio },
22
+ argTypes: {
23
+ onChange: { control: { type: null } },
24
+ children: { control: { type: null } },
25
+ checked: { control: { type: 'text' } },
26
+ },
27
+ parameters: {
28
+ actions: { argTypesRegex: '^on.*' },
29
+ controls: { expanded: true },
30
+ docs: { canvas: { sourceState: 'shown' } },
31
+ },
32
+ };
33
+ export default meta;
34
+
35
+ const Template: StoryFn< typeof RadioGroup > = ( props ) => {
36
+ return <RadioGroup { ...props } />;
37
+ };
38
+
39
+ export const Default: StoryFn< typeof RadioGroup > = Template.bind( {} );
40
+ Default.args = {
41
+ id: 'default-radiogroup',
42
+ label: 'options',
43
+ defaultChecked: 'option2',
44
+ children: (
45
+ <>
46
+ <Radio value="option1">Option 1</Radio>
47
+ <Radio value="option2">Option 2</Radio>
48
+ <Radio value="option3">Option 3</Radio>
49
+ </>
50
+ ),
51
+ };
52
+
53
+ export const Disabled: StoryFn< typeof RadioGroup > = Template.bind( {} );
54
+ Disabled.args = {
55
+ ...Default.args,
56
+ id: 'disabled-radiogroup',
57
+ disabled: true,
58
+ };
59
+
60
+ const ControlledTemplate: StoryFn< typeof RadioGroup > = ( {
61
+ checked: checkedProp,
62
+ onChange: onChangeProp,
63
+ ...props
64
+ } ) => {
65
+ const [ checked, setChecked ] =
66
+ useState< React.ComponentProps< typeof RadioGroup >[ 'checked' ] >(
67
+ checkedProp
68
+ );
69
+
70
+ const onChange: typeof onChangeProp = ( value ) => {
71
+ setChecked( value );
72
+ onChangeProp?.( value );
73
+ };
74
+
75
+ return (
76
+ <RadioGroup { ...props } onChange={ onChange } checked={ checked } />
77
+ );
78
+ };
79
+
80
+ export const Controlled: StoryFn< typeof RadioGroup > = ControlledTemplate.bind(
81
+ {}
82
+ );
83
+ Controlled.args = {
84
+ ...Default.args,
85
+ checked: 'option2',
86
+ id: 'controlled-radiogroup',
87
+ };
88
+ Controlled.argTypes = {
89
+ checked: { control: { type: null } },
90
+ };
@@ -0,0 +1,39 @@
1
+ export type RadioGroupProps = {
2
+ /**
3
+ * Accessible label for the radio group
4
+ */
5
+ label: string;
6
+ /**
7
+ * The `value` of the `Radio` element which should be selected.
8
+ * Indicates controlled usage of the component.
9
+ */
10
+ checked?: string | number;
11
+ /**
12
+ * The value of the radio element which is initially selected.
13
+ */
14
+ defaultChecked?: string | number;
15
+ /**
16
+ * Whether the `RadioGroup` should be disabled.
17
+ */
18
+ disabled?: boolean;
19
+ /**
20
+ * Called when a `Radio` element has been selected.
21
+ * Receives the `value` of the selected element as an argument.
22
+ */
23
+ onChange?: ( value: string | number | undefined ) => void;
24
+ /**
25
+ * The children elements, which should be a series of `Radio` components.
26
+ */
27
+ children: React.ReactNode;
28
+ };
29
+
30
+ export type RadioProps = {
31
+ /**
32
+ * The actual value of the radio element.
33
+ */
34
+ value: string | number;
35
+ /**
36
+ * Content displayed on the Radio element. If there aren't any children, `value` is displayed.
37
+ */
38
+ children?: React.ReactNode;
39
+ };
@@ -68,7 +68,7 @@ Both `Slot` and `Fill` accept a `name` string prop, where a `Slot` with a given
68
68
  - By default, events will bubble to their parents on the DOM hierarchy (native event bubbling)
69
69
  - If `bubblesVirtually` is set to true, events will bubble to their virtual parent in the React elements hierarchy instead.
70
70
 
71
- `Slot` with `bubblesVirtually` set to true also accept an optional `className` to add to the slot container.
71
+ `Slot` with `bubblesVirtually` set to true also accept optional `className` and `style` props to add to the slot container.
72
72
 
73
73
  `Slot` **without** `bubblesVirtually` accepts an optional `children` function prop, which takes `fills` as a param. It allows you to perform additional processing and wrap `fills` conditionally.
74
74
 
@@ -66,7 +66,7 @@ function createSlotRegistry(): SlotFillBubblesVirtuallyContext {
66
66
  const slotFills = fills.get( name );
67
67
  if ( slotFills ) {
68
68
  // Force update fills.
69
- slotFills.map( ( fill ) => fill.current.rerender() );
69
+ slotFills.forEach( ( fill ) => fill.current.rerender() );
70
70
  }
71
71
  };
72
72
 
@@ -36,15 +36,21 @@ export type SlotComponentProps =
36
36
 
37
37
  /**
38
38
  * A function that returns nodes to be rendered.
39
- * Not supported when `bubblesVirtually` is true.
39
+ * Supported only when `bubblesVirtually` is `false`.
40
40
  */
41
41
  children?: never;
42
42
 
43
43
  /**
44
- * className.
45
- * Not supported when `bubblesVirtually` is true.
44
+ * Additional className for the `Slot` component.
45
+ * Supported only when `bubblesVirtually` is `true`.
46
46
  */
47
47
  className?: string;
48
+
49
+ /**
50
+ * Additional styles for the `Slot` component.
51
+ * Supported only when `bubblesVirtually` is `true`.
52
+ */
53
+ style?: React.CSSProperties;
48
54
  } )
49
55
  | ( SlotPropBase & {
50
56
  /**
@@ -56,15 +62,21 @@ export type SlotComponentProps =
56
62
 
57
63
  /**
58
64
  * A function that returns nodes to be rendered.
59
- * Not supported when `bubblesVirtually` is true.
65
+ * Supported only when `bubblesVirtually` is `false`.
60
66
  */
61
67
  children?: ( fills: ReactNode ) => ReactNode;
62
68
 
63
69
  /**
64
- * className.
65
- * Not supported when `bubblesVirtually` is false.
70
+ * Additional className for the `Slot` component.
71
+ * Supported only when `bubblesVirtually` is `true`.
66
72
  */
67
73
  className?: never;
74
+
75
+ /**
76
+ * Additional styles for the `Slot` component.
77
+ * Supported only when `bubblesVirtually` is `true`.
78
+ */
79
+ style?: never;
68
80
  } );
69
81
 
70
82
  export type FillComponentProps = {
@@ -159,19 +159,6 @@ The children elements, which should be a series of `Tabs.TabPanel` components.
159
159
 
160
160
  - Required: No
161
161
 
162
- ###### `className`: `string`
163
-
164
- The class name to apply to the tablist.
165
-
166
- - Required: No
167
- - Default: ''
168
-
169
- ###### `style`: `React.CSSProperties`
170
-
171
- Custom CSS styles for the tablist.
172
-
173
- - Required: No
174
-
175
162
  #### Tab
176
163
 
177
164
  ##### Props
@@ -182,24 +169,12 @@ The id of the tab, which is prepended with the `Tabs` instance ID.
182
169
 
183
170
  - Required: Yes
184
171
 
185
- ###### `style`: `React.CSSProperties`
186
-
187
- Custom CSS styles for the tab.
188
-
189
- - Required: No
190
-
191
172
  ###### `children`: `React.ReactNode`
192
173
 
193
174
  The children elements, generally the text to display on the tab.
194
175
 
195
176
  - Required: No
196
177
 
197
- ###### `className`: `string`
198
-
199
- The class name to apply to the tab.
200
-
201
- - Required: No
202
-
203
178
  ###### `disabled`: `boolean`
204
179
 
205
180
  Determines if the tab button should be disabled.
@@ -229,14 +204,9 @@ The id of the tabpanel, which is combined with the `Tabs` instance ID and the su
229
204
 
230
205
  - Required: Yes
231
206
 
232
- ###### `className`: `string`
233
-
234
- The class name to apply to the tabpanel.
235
-
236
- - Required: No
237
-
238
- ###### `style`: `React.CSSProperties`
207
+ ###### `focusable`: `boolean`
239
208
 
240
- Custom CSS styles for the tab.
209
+ Determines whether or not the tabpanel element should be focusable. If `false`, pressing the tab key will skip over the tabpanel, and instead focus on the first focusable element in the panel (if there is one).
241
210
 
242
211
  - Required: No
212
+ - Default: `true`
@@ -8,7 +8,7 @@ import * as Ariakit from '@ariakit/react';
8
8
  * WordPress dependencies
9
9
  */
10
10
  import { useInstanceId } from '@wordpress/compose';
11
- import { useLayoutEffect, useRef } from '@wordpress/element';
11
+ import { useLayoutEffect, useMemo, useRef } from '@wordpress/element';
12
12
 
13
13
  /**
14
14
  * Internal dependencies
@@ -154,8 +154,16 @@ function Tabs( {
154
154
  setSelectedId,
155
155
  ] );
156
156
 
157
+ const contextValue = useMemo(
158
+ () => ( {
159
+ store,
160
+ instanceId,
161
+ } ),
162
+ [ store, instanceId ]
163
+ );
164
+
157
165
  return (
158
- <TabsContext.Provider value={ { store, instanceId } }>
166
+ <TabsContext.Provider value={ contextValue }>
159
167
  { children }
160
168
  </TabsContext.Provider>
161
169
  );
@@ -164,4 +172,6 @@ function Tabs( {
164
172
  Tabs.TabList = TabList;
165
173
  Tabs.Tab = Tab;
166
174
  Tabs.TabPanel = TabPanel;
175
+ Tabs.Context = TabsContext;
176
+
167
177
  export default Tabs;