@wordpress/components 23.9.0 → 24.0.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 (279) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/CONTRIBUTING.md +65 -1
  3. package/README.md +1 -3
  4. package/build/autocomplete/autocompleter-ui.js +0 -2
  5. package/build/autocomplete/autocompleter-ui.js.map +1 -1
  6. package/build/autocomplete/index.js +2 -0
  7. package/build/autocomplete/index.js.map +1 -1
  8. package/build/button/index.js +2 -0
  9. package/build/button/index.js.map +1 -1
  10. package/build/card/card-media/component.js +2 -1
  11. package/build/card/card-media/component.js.map +1 -1
  12. package/build/combobox-control/index.js +7 -5
  13. package/build/combobox-control/index.js.map +1 -1
  14. package/build/combobox-control/styles.js +3 -3
  15. package/build/combobox-control/styles.js.map +1 -1
  16. package/build/dimension-control/index.js +1 -1
  17. package/build/dimension-control/index.js.map +1 -1
  18. package/build/draggable/index.js +2 -7
  19. package/build/draggable/index.js.map +1 -1
  20. package/build/form-token-field/index.js +5 -3
  21. package/build/form-token-field/index.js.map +1 -1
  22. package/build/form-token-field/styles.js +3 -3
  23. package/build/form-token-field/styles.js.map +1 -1
  24. package/build/mobile/global-styles-context/index.native.js +13 -1
  25. package/build/mobile/global-styles-context/index.native.js.map +1 -1
  26. package/build/mobile/link-picker/link-picker-results.native.js +3 -1
  27. package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
  28. package/build/modal/index.js +2 -1
  29. package/build/modal/index.js.map +1 -1
  30. package/build/navigable-container/container.js +39 -19
  31. package/build/navigable-container/container.js.map +1 -1
  32. package/build/navigable-container/index.js.map +1 -1
  33. package/build/navigable-container/menu.js +37 -5
  34. package/build/navigable-container/menu.js.map +1 -1
  35. package/build/navigable-container/tabbable.js +45 -4
  36. package/build/navigable-container/tabbable.js.map +1 -1
  37. package/build/navigable-container/types.js +6 -0
  38. package/build/navigable-container/types.js.map +1 -0
  39. package/build/palette-edit/index.js +34 -12
  40. package/build/palette-edit/index.js.map +1 -1
  41. package/build/sandbox/index.native.js +6 -2
  42. package/build/sandbox/index.native.js.map +1 -1
  43. package/build/slot-fill/bubbles-virtually/fill.js +2 -1
  44. package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
  45. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +45 -35
  46. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  47. package/build/slot-fill/bubbles-virtually/use-slot.js +11 -26
  48. package/build/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
  49. package/build/slot-fill/fill.js +7 -31
  50. package/build/slot-fill/fill.js.map +1 -1
  51. package/build/slot-fill/index.js.map +1 -1
  52. package/build/slot-fill/provider.js +0 -6
  53. package/build/slot-fill/provider.js.map +1 -1
  54. package/build/slot-fill/slot.js +0 -5
  55. package/build/slot-fill/slot.js.map +1 -1
  56. package/build/tab-panel/index.js.map +1 -1
  57. package/build/theme/color-algorithms.js +1 -1
  58. package/build/theme/color-algorithms.js.map +1 -1
  59. package/build/toolbar/toolbar-button/index.js +1 -2
  60. package/build/toolbar/toolbar-button/index.js.map +1 -1
  61. package/build/toolbar/toolbar-item/index.js +4 -2
  62. package/build/toolbar/toolbar-item/index.js.map +1 -1
  63. package/build/utils/colors-values.js +3 -3
  64. package/build/utils/colors-values.js.map +1 -1
  65. package/build/utils/use-deprecated-props.js +35 -0
  66. package/build/utils/use-deprecated-props.js.map +1 -0
  67. package/build-module/autocomplete/autocompleter-ui.js +1 -3
  68. package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
  69. package/build-module/autocomplete/index.js +3 -3
  70. package/build-module/autocomplete/index.js.map +1 -1
  71. package/build-module/button/index.js +2 -0
  72. package/build-module/button/index.js.map +1 -1
  73. package/build-module/card/card-media/component.js +2 -1
  74. package/build-module/card/card-media/component.js.map +1 -1
  75. package/build-module/combobox-control/index.js +6 -5
  76. package/build-module/combobox-control/index.js.map +1 -1
  77. package/build-module/combobox-control/styles.js +3 -3
  78. package/build-module/combobox-control/styles.js.map +1 -1
  79. package/build-module/dimension-control/index.js +1 -1
  80. package/build-module/dimension-control/index.js.map +1 -1
  81. package/build-module/draggable/index.js +2 -7
  82. package/build-module/draggable/index.js.map +1 -1
  83. package/build-module/form-token-field/index.js +4 -3
  84. package/build-module/form-token-field/index.js.map +1 -1
  85. package/build-module/form-token-field/styles.js +3 -3
  86. package/build-module/form-token-field/styles.js.map +1 -1
  87. package/build-module/mobile/global-styles-context/index.native.js +13 -1
  88. package/build-module/mobile/global-styles-context/index.native.js.map +1 -1
  89. package/build-module/mobile/link-picker/link-picker-results.native.js +3 -1
  90. package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
  91. package/build-module/modal/index.js +2 -1
  92. package/build-module/modal/index.js.map +1 -1
  93. package/build-module/navigable-container/container.js +43 -19
  94. package/build-module/navigable-container/container.js.map +1 -1
  95. package/build-module/navigable-container/index.js +0 -2
  96. package/build-module/navigable-container/index.js.map +1 -1
  97. package/build-module/navigable-container/menu.js +36 -4
  98. package/build-module/navigable-container/menu.js.map +1 -1
  99. package/build-module/navigable-container/tabbable.js +44 -3
  100. package/build-module/navigable-container/tabbable.js.map +1 -1
  101. package/build-module/navigable-container/types.js +2 -0
  102. package/build-module/navigable-container/types.js.map +1 -0
  103. package/build-module/palette-edit/index.js +34 -13
  104. package/build-module/palette-edit/index.js.map +1 -1
  105. package/build-module/sandbox/index.native.js +6 -2
  106. package/build-module/sandbox/index.native.js.map +1 -1
  107. package/build-module/slot-fill/bubbles-virtually/fill.js +2 -1
  108. package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
  109. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +46 -36
  110. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  111. package/build-module/slot-fill/bubbles-virtually/use-slot.js +12 -27
  112. package/build-module/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
  113. package/build-module/slot-fill/fill.js +7 -31
  114. package/build-module/slot-fill/fill.js.map +1 -1
  115. package/build-module/slot-fill/index.js +1 -2
  116. package/build-module/slot-fill/index.js.map +1 -1
  117. package/build-module/slot-fill/provider.js +0 -6
  118. package/build-module/slot-fill/provider.js.map +1 -1
  119. package/build-module/slot-fill/slot.js +0 -5
  120. package/build-module/slot-fill/slot.js.map +1 -1
  121. package/build-module/tab-panel/index.js.map +1 -1
  122. package/build-module/theme/color-algorithms.js +1 -1
  123. package/build-module/theme/color-algorithms.js.map +1 -1
  124. package/build-module/toolbar/toolbar-button/index.js +1 -2
  125. package/build-module/toolbar/toolbar-button/index.js.map +1 -1
  126. package/build-module/toolbar/toolbar-item/index.js +5 -2
  127. package/build-module/toolbar/toolbar-item/index.js.map +1 -1
  128. package/build-module/utils/colors-values.js +3 -3
  129. package/build-module/utils/colors-values.js.map +1 -1
  130. package/build-module/utils/use-deprecated-props.js +25 -0
  131. package/build-module/utils/use-deprecated-props.js.map +1 -0
  132. package/build-style/style-rtl.css +58 -55
  133. package/build-style/style.css +58 -55
  134. package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
  135. package/build-types/autocomplete/index.d.ts.map +1 -1
  136. package/build-types/autocomplete/types.d.ts +2 -18
  137. package/build-types/autocomplete/types.d.ts.map +1 -1
  138. package/build-types/button/deprecated.d.ts +6 -0
  139. package/build-types/button/deprecated.d.ts.map +1 -1
  140. package/build-types/button/index.d.ts.map +1 -1
  141. package/build-types/button/types.d.ts +7 -0
  142. package/build-types/button/types.d.ts.map +1 -1
  143. package/build-types/card/card-media/component.d.ts +2 -1
  144. package/build-types/card/card-media/component.d.ts.map +1 -1
  145. package/build-types/card/stories/index.d.ts +21 -1
  146. package/build-types/card/stories/index.d.ts.map +1 -1
  147. package/build-types/combobox-control/index.d.ts +1 -1
  148. package/build-types/combobox-control/index.d.ts.map +1 -1
  149. package/build-types/combobox-control/stories/index.d.ts.map +1 -1
  150. package/build-types/combobox-control/styles.d.ts +1 -1
  151. package/build-types/combobox-control/types.d.ts +8 -1
  152. package/build-types/combobox-control/types.d.ts.map +1 -1
  153. package/build-types/dimension-control/index.d.ts +1 -1
  154. package/build-types/draggable/index.d.ts.map +1 -1
  155. package/build-types/form-token-field/index.d.ts.map +1 -1
  156. package/build-types/form-token-field/styles.d.ts +1 -1
  157. package/build-types/form-token-field/types.d.ts +8 -1
  158. package/build-types/form-token-field/types.d.ts.map +1 -1
  159. package/build-types/modal/index.d.ts.map +1 -1
  160. package/build-types/navigable-container/container.d.ts +20 -1
  161. package/build-types/navigable-container/container.d.ts.map +1 -1
  162. package/build-types/navigable-container/index.d.ts +5 -2
  163. package/build-types/navigable-container/index.d.ts.map +1 -1
  164. package/build-types/navigable-container/menu.d.ts +45 -11
  165. package/build-types/navigable-container/menu.d.ts.map +1 -1
  166. package/build-types/navigable-container/stories/navigable-menu.d.ts +12 -0
  167. package/build-types/navigable-container/stories/navigable-menu.d.ts.map +1 -0
  168. package/build-types/navigable-container/stories/tabbable-container.d.ts +12 -0
  169. package/build-types/navigable-container/stories/tabbable-container.d.ts.map +1 -0
  170. package/build-types/navigable-container/tabbable.d.ts +52 -9
  171. package/build-types/navigable-container/tabbable.d.ts.map +1 -1
  172. package/build-types/navigable-container/test/navigable-menu.d.ts +2 -0
  173. package/build-types/navigable-container/test/navigable-menu.d.ts.map +1 -0
  174. package/build-types/navigable-container/test/tababble-container.d.ts +2 -0
  175. package/build-types/navigable-container/test/tababble-container.d.ts.map +1 -0
  176. package/build-types/navigable-container/types.d.ts +61 -0
  177. package/build-types/navigable-container/types.d.ts.map +1 -0
  178. package/build-types/navigator/navigator-back-button/component.d.ts +1 -0
  179. package/build-types/navigator/navigator-back-button/component.d.ts.map +1 -1
  180. package/build-types/navigator/navigator-back-button/hook.d.ts +1 -0
  181. package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
  182. package/build-types/navigator/navigator-button/component.d.ts +1 -0
  183. package/build-types/navigator/navigator-button/component.d.ts.map +1 -1
  184. package/build-types/navigator/navigator-button/hook.d.ts +1 -0
  185. package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
  186. package/build-types/navigator/navigator-to-parent-button/component.d.ts +1 -0
  187. package/build-types/navigator/navigator-to-parent-button/component.d.ts.map +1 -1
  188. package/build-types/palette-edit/index.d.ts +1 -1
  189. package/build-types/palette-edit/index.d.ts.map +1 -1
  190. package/build-types/palette-edit/stories/index.d.ts.map +1 -1
  191. package/build-types/palette-edit/types.d.ts +8 -0
  192. package/build-types/palette-edit/types.d.ts.map +1 -1
  193. package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
  194. package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -1
  195. package/build-types/slot-fill/bubbles-virtually/use-slot.d.ts.map +1 -1
  196. package/build-types/slot-fill/fill.d.ts +4 -2
  197. package/build-types/slot-fill/fill.d.ts.map +1 -1
  198. package/build-types/slot-fill/index.d.ts +1 -2
  199. package/build-types/slot-fill/index.d.ts.map +1 -1
  200. package/build-types/slot-fill/provider.d.ts +0 -2
  201. package/build-types/slot-fill/provider.d.ts.map +1 -1
  202. package/build-types/slot-fill/slot.d.ts.map +1 -1
  203. package/build-types/toolbar/stories/index.d.ts.map +1 -1
  204. package/build-types/toolbar/toolbar-button/index.d.ts +6 -0
  205. package/build-types/toolbar/toolbar-button/index.d.ts.map +1 -1
  206. package/build-types/toolbar/toolbar-item/index.d.ts +6 -4
  207. package/build-types/toolbar/toolbar-item/index.d.ts.map +1 -1
  208. package/build-types/tree-grid/types.d.ts +7 -0
  209. package/build-types/tree-grid/types.d.ts.map +1 -1
  210. package/build-types/utils/use-deprecated-props.d.ts +9 -0
  211. package/build-types/utils/use-deprecated-props.d.ts.map +1 -0
  212. package/package.json +19 -19
  213. package/src/autocomplete/README.md +78 -52
  214. package/src/autocomplete/autocompleter-ui.tsx +0 -2
  215. package/src/autocomplete/index.tsx +1 -2
  216. package/src/autocomplete/types.ts +3 -19
  217. package/src/button/index.tsx +2 -0
  218. package/src/button/style.scss +13 -6
  219. package/src/button/types.ts +7 -0
  220. package/src/card/card-media/README.md +1 -1
  221. package/src/card/card-media/component.tsx +2 -1
  222. package/src/card/stories/index.tsx +47 -26
  223. package/src/checkbox-control/style.scss +1 -4
  224. package/src/combobox-control/index.tsx +24 -18
  225. package/src/combobox-control/stories/index.tsx +0 -1
  226. package/src/combobox-control/styles.ts +4 -4
  227. package/src/combobox-control/types.ts +8 -1
  228. package/src/custom-gradient-picker/style.scss +2 -2
  229. package/src/dimension-control/index.tsx +1 -1
  230. package/src/draggable/index.tsx +1 -9
  231. package/src/form-toggle/style.scss +1 -5
  232. package/src/form-token-field/index.tsx +7 -3
  233. package/src/form-token-field/styles.ts +4 -4
  234. package/src/form-token-field/types.ts +8 -1
  235. package/src/mobile/global-styles-context/index.native.js +12 -1
  236. package/src/mobile/link-picker/link-picker-results.native.js +3 -0
  237. package/src/modal/index.tsx +6 -1
  238. package/src/modal/style.scss +1 -1
  239. package/src/navigable-container/README.md +24 -13
  240. package/src/navigable-container/{container.js → container.tsx} +57 -27
  241. package/src/navigable-container/{index.js → index.tsx} +0 -1
  242. package/src/navigable-container/menu.tsx +100 -0
  243. package/src/navigable-container/stories/{navigable-menu.js → navigable-menu.tsx} +15 -10
  244. package/src/navigable-container/stories/{tabbable-container.js → tabbable-container.tsx} +15 -6
  245. package/src/navigable-container/tabbable.tsx +92 -0
  246. package/src/navigable-container/test/{navigable-menu.js → navigable-menu.tsx} +3 -1
  247. package/src/navigable-container/test/{tababble-container.js → tababble-container.tsx} +53 -24
  248. package/src/navigable-container/types.ts +76 -0
  249. package/src/palette-edit/index.tsx +45 -7
  250. package/src/palette-edit/stories/index.tsx +4 -0
  251. package/src/palette-edit/types.ts +11 -0
  252. package/src/sandbox/index.native.js +4 -0
  253. package/src/slot-fill/bubbles-virtually/fill.js +2 -1
  254. package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +46 -60
  255. package/src/slot-fill/bubbles-virtually/use-slot.js +14 -41
  256. package/src/slot-fill/fill.js +4 -26
  257. package/src/slot-fill/index.js +1 -3
  258. package/src/slot-fill/provider.js +0 -6
  259. package/src/slot-fill/slot.js +0 -5
  260. package/src/style.scss +6 -0
  261. package/src/tab-panel/index.tsx +1 -1
  262. package/src/theme/color-algorithms.ts +1 -1
  263. package/src/theme/stories/index.tsx +1 -1
  264. package/src/theme/test/color-algorithms.ts +2 -2
  265. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +4 -4
  266. package/src/toolbar/stories/index.tsx +26 -24
  267. package/src/toolbar/toolbar-button/index.tsx +10 -13
  268. package/src/toolbar/toolbar-item/{index.js → index.tsx} +12 -3
  269. package/src/tree-grid/README.md +18 -0
  270. package/src/tree-grid/types.ts +7 -0
  271. package/src/utils/colors-values.js +3 -3
  272. package/src/utils/theme-variables.scss +4 -4
  273. package/src/utils/use-deprecated-props.ts +29 -0
  274. package/tsconfig.json +1 -0
  275. package/tsconfig.tsbuildinfo +1 -1
  276. package/src/CONTRIBUTING.md +0 -78
  277. package/src/README.md +0 -20
  278. package/src/navigable-container/menu.js +0 -62
  279. package/src/navigable-container/tabbable.js +0 -46
@@ -186,6 +186,8 @@ const Sandbox = forwardRef( function Sandbox(
186
186
  url,
187
187
  onWindowEvents = {},
188
188
  viewportProps = '',
189
+ onLoadEnd = () => {},
190
+ testID,
189
191
  },
190
192
  ref
191
193
  ) {
@@ -372,6 +374,8 @@ const Sandbox = forwardRef( function Sandbox(
372
374
  showsHorizontalScrollIndicator={ false }
373
375
  showsVerticalScrollIndicator={ false }
374
376
  mediaPlaybackRequiresUserAction={ false }
377
+ onLoadEnd={ onLoadEnd }
378
+ testID={ testID }
375
379
  />
376
380
  );
377
381
  } );
@@ -30,7 +30,8 @@ function useForceUpdate() {
30
30
 
31
31
  export default function Fill( { name, children } ) {
32
32
  const { registerFill, unregisterFill, ...slot } = useSlot( name );
33
- const ref = useRef( { rerender: useForceUpdate() } );
33
+ const rerender = useForceUpdate();
34
+ const ref = useRef( { rerender } );
34
35
 
35
36
  useEffect( () => {
36
37
  // We register fills so we can keep track of their existence.
@@ -8,7 +8,7 @@ import { proxyMap } from 'valtio/utils';
8
8
  /**
9
9
  * WordPress dependencies
10
10
  */
11
- import { useMemo, useCallback, useRef } from '@wordpress/element';
11
+ import { useState } from '@wordpress/element';
12
12
  import isShallowEqual from '@wordpress/is-shallow-equal';
13
13
 
14
14
  /**
@@ -16,13 +16,13 @@ import isShallowEqual from '@wordpress/is-shallow-equal';
16
16
  */
17
17
  import SlotFillContext from './slot-fill-context';
18
18
 
19
- function useSlotRegistry() {
20
- const slots = useRef( proxyMap() );
21
- const fills = useRef( proxyMap() );
19
+ function createSlotRegistry() {
20
+ const slots = proxyMap();
21
+ const fills = proxyMap();
22
22
 
23
- const registerSlot = useCallback( ( name, ref, fillProps ) => {
24
- const slot = slots.current.get( name ) || {};
25
- slots.current.set(
23
+ function registerSlot( name, ref, fillProps ) {
24
+ const slot = slots.get( name ) || {};
25
+ slots.set(
26
26
  name,
27
27
  valRef( {
28
28
  ...slot,
@@ -30,77 +30,63 @@ function useSlotRegistry() {
30
30
  fillProps: fillProps || slot.fillProps || {},
31
31
  } )
32
32
  );
33
- }, [] );
33
+ }
34
34
 
35
- const unregisterSlot = useCallback( ( name, ref ) => {
35
+ function unregisterSlot( name, ref ) {
36
36
  // Make sure we're not unregistering a slot registered by another element
37
37
  // See https://github.com/WordPress/gutenberg/pull/19242#issuecomment-590295412
38
- if ( slots.current.get( name )?.ref === ref ) {
39
- slots.current.delete( name );
38
+ if ( slots.get( name )?.ref === ref ) {
39
+ slots.delete( name );
40
40
  }
41
- }, [] );
41
+ }
42
42
 
43
- const updateSlot = useCallback( ( name, fillProps ) => {
44
- const slot = slots.current.get( name );
43
+ function updateSlot( name, fillProps ) {
44
+ const slot = slots.get( name );
45
45
  if ( ! slot ) {
46
46
  return;
47
47
  }
48
48
 
49
- if ( ! isShallowEqual( slot.fillProps, fillProps ) ) {
50
- slot.fillProps = fillProps;
51
- const slotFills = fills.current.get( name );
52
- if ( slotFills ) {
53
- // Force update fills.
54
- slotFills.map( ( fill ) => fill.current.rerender() );
55
- }
49
+ if ( isShallowEqual( slot.fillProps, fillProps ) ) {
50
+ return;
56
51
  }
57
- }, [] );
58
52
 
59
- const registerFill = useCallback( ( name, ref ) => {
60
- fills.current.set(
61
- name,
62
- valRef( [ ...( fills.current.get( name ) || [] ), ref ] )
63
- );
64
- }, [] );
53
+ slot.fillProps = fillProps;
54
+ const slotFills = fills.get( name );
55
+ if ( slotFills ) {
56
+ // Force update fills.
57
+ slotFills.map( ( fill ) => fill.current.rerender() );
58
+ }
59
+ }
60
+
61
+ function registerFill( name, ref ) {
62
+ fills.set( name, valRef( [ ...( fills.get( name ) || [] ), ref ] ) );
63
+ }
65
64
 
66
- const unregisterFill = useCallback( ( name, ref ) => {
67
- if ( fills.current.get( name ) ) {
68
- fills.current.set(
69
- name,
70
- valRef(
71
- fills.current
72
- .get( name )
73
- .filter( ( fillRef ) => fillRef !== ref )
74
- )
75
- );
65
+ function unregisterFill( name, ref ) {
66
+ const fillsForName = fills.get( name );
67
+ if ( ! fillsForName ) {
68
+ return;
76
69
  }
77
- }, [] );
78
70
 
79
- // Memoizing the return value so it can be directly passed to Provider value
80
- const registry = useMemo(
81
- () => ( {
82
- slots: slots.current,
83
- fills: fills.current,
84
- registerSlot,
85
- updateSlot,
86
- unregisterSlot,
87
- registerFill,
88
- unregisterFill,
89
- } ),
90
- [
91
- registerSlot,
92
- updateSlot,
93
- unregisterSlot,
94
- registerFill,
95
- unregisterFill,
96
- ]
97
- );
71
+ fills.set(
72
+ name,
73
+ valRef( fillsForName.filter( ( fillRef ) => fillRef !== ref ) )
74
+ );
75
+ }
98
76
 
99
- return registry;
77
+ return {
78
+ slots,
79
+ fills,
80
+ registerSlot,
81
+ updateSlot,
82
+ unregisterSlot,
83
+ registerFill,
84
+ unregisterFill,
85
+ };
100
86
  }
101
87
 
102
88
  export default function SlotFillProvider( { children } ) {
103
- const registry = useSlotRegistry();
89
+ const [ registry ] = useState( createSlotRegistry );
104
90
  return (
105
91
  <SlotFillContext.Provider value={ registry }>
106
92
  { children }
@@ -7,7 +7,7 @@ import { useSnapshot } from 'valtio';
7
7
  /**
8
8
  * WordPress dependencies
9
9
  */
10
- import { useCallback, useContext } from '@wordpress/element';
10
+ import { useMemo, useContext } from '@wordpress/element';
11
11
 
12
12
  /**
13
13
  * Internal dependencies
@@ -15,52 +15,25 @@ import { useCallback, useContext } from '@wordpress/element';
15
15
  import SlotFillContext from './slot-fill-context';
16
16
 
17
17
  export default function useSlot( name ) {
18
- const {
19
- updateSlot: registryUpdateSlot,
20
- unregisterSlot: registryUnregisterSlot,
21
- registerFill: registryRegisterFill,
22
- unregisterFill: registryUnregisterFill,
23
- ...registry
24
- } = useContext( SlotFillContext );
18
+ const registry = useContext( SlotFillContext );
25
19
  const slots = useSnapshot( registry.slots, { sync: true } );
26
- // The important bit here is that this call ensures
27
- // the hook only causes a re-render if the slot
28
- // with the given name change, not any other slot.
20
+ // The important bit here is that the `useSnapshot` call ensures that the
21
+ // hook only causes a re-render if the slot with the given name changes,
22
+ // not any other slot.
29
23
  const slot = slots.get( name );
30
24
 
31
- const updateSlot = useCallback(
32
- ( fillProps ) => {
33
- registryUpdateSlot( name, fillProps );
34
- },
35
- [ name, registryUpdateSlot ]
36
- );
37
-
38
- const unregisterSlot = useCallback(
39
- ( slotRef ) => {
40
- registryUnregisterSlot( name, slotRef );
41
- },
42
- [ name, registryUnregisterSlot ]
43
- );
44
-
45
- const registerFill = useCallback(
46
- ( fillRef ) => {
47
- registryRegisterFill( name, fillRef );
48
- },
49
- [ name, registryRegisterFill ]
50
- );
51
-
52
- const unregisterFill = useCallback(
53
- ( fillRef ) => {
54
- registryUnregisterFill( name, fillRef );
55
- },
56
- [ name, registryUnregisterFill ]
25
+ const api = useMemo(
26
+ () => ( {
27
+ updateSlot: ( fillProps ) => registry.updateSlot( name, fillProps ),
28
+ unregisterSlot: ( ref ) => registry.unregisterSlot( name, ref ),
29
+ registerFill: ( ref ) => registry.registerFill( name, ref ),
30
+ unregisterFill: ( ref ) => registry.unregisterFill( name, ref ),
31
+ } ),
32
+ [ name, registry ]
57
33
  );
58
34
 
59
35
  return {
60
36
  ...slot,
61
- updateSlot,
62
- unregisterSlot,
63
- registerFill,
64
- unregisterFill,
37
+ ...api,
65
38
  };
66
39
  }
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * WordPress dependencies
5
5
  */
6
- import { createPortal, useLayoutEffect, useRef } from '@wordpress/element';
6
+ import { useContext, useLayoutEffect, useRef } from '@wordpress/element';
7
7
 
8
8
  /**
9
9
  * Internal dependencies
@@ -11,7 +11,8 @@ import { createPortal, useLayoutEffect, useRef } from '@wordpress/element';
11
11
  import SlotFillContext from './context';
12
12
  import useSlot from './use-slot';
13
13
 
14
- function FillComponent( { name, children, registerFill, unregisterFill } ) {
14
+ export default function Fill( { name, children } ) {
15
+ const { registerFill, unregisterFill } = useContext( SlotFillContext );
15
16
  const slot = useSlot( name );
16
17
 
17
18
  const ref = useRef( {
@@ -51,28 +52,5 @@ function FillComponent( { name, children, registerFill, unregisterFill } ) {
51
52
  // eslint-disable-next-line react-hooks/exhaustive-deps
52
53
  }, [ name ] );
53
54
 
54
- if ( ! slot || ! slot.node ) {
55
- return null;
56
- }
57
-
58
- // If a function is passed as a child, provide it with the fillProps.
59
- if ( typeof children === 'function' ) {
60
- children = children( slot.props.fillProps );
61
- }
62
-
63
- return createPortal( children, slot.node );
55
+ return null;
64
56
  }
65
-
66
- const Fill = ( props ) => (
67
- <SlotFillContext.Consumer>
68
- { ( { registerFill, unregisterFill } ) => (
69
- <FillComponent
70
- { ...props }
71
- registerFill={ registerFill }
72
- unregisterFill={ unregisterFill }
73
- />
74
- ) }
75
- </SlotFillContext.Consumer>
76
- );
77
-
78
- export default Fill;
@@ -13,7 +13,7 @@ import BubblesVirtuallyFill from './bubbles-virtually/fill';
13
13
  import BubblesVirtuallySlot from './bubbles-virtually/slot';
14
14
  import BubblesVirtuallySlotFillProvider from './bubbles-virtually/slot-fill-provider';
15
15
  import SlotFillProvider from './provider';
16
- import useSlot from './bubbles-virtually/use-slot';
16
+ export { default as useSlot } from './bubbles-virtually/use-slot';
17
17
  export { default as useSlotFills } from './bubbles-virtually/use-slot-fills';
18
18
 
19
19
  export function Fill( props ) {
@@ -65,5 +65,3 @@ export const createPrivateSlotFill = ( name ) => {
65
65
 
66
66
  return { privateKey, ...privateSlotFill };
67
67
  };
68
-
69
- export { useSlot };
@@ -19,7 +19,6 @@ export default class SlotFillProvider extends Component {
19
19
  this.unregisterFill = this.unregisterFill.bind( this );
20
20
  this.getSlot = this.getSlot.bind( this );
21
21
  this.getFills = this.getFills.bind( this );
22
- this.hasFills = this.hasFills.bind( this );
23
22
  this.subscribe = this.subscribe.bind( this );
24
23
 
25
24
  this.slots = {};
@@ -32,7 +31,6 @@ export default class SlotFillProvider extends Component {
32
31
  unregisterFill: this.unregisterFill,
33
32
  getSlot: this.getSlot,
34
33
  getFills: this.getFills,
35
- hasFills: this.hasFills,
36
34
  subscribe: this.subscribe,
37
35
  };
38
36
  }
@@ -91,10 +89,6 @@ export default class SlotFillProvider extends Component {
91
89
  return this.fills[ name ];
92
90
  }
93
91
 
94
- hasFills( name ) {
95
- return this.fills[ name ] && !! this.fills[ name ].length;
96
- }
97
-
98
92
  forceUpdateSlot( name ) {
99
93
  const slot = this.getSlot( name );
100
94
 
@@ -29,7 +29,6 @@ class SlotComponent extends Component {
29
29
  super( ...arguments );
30
30
 
31
31
  this.isUnmounted = false;
32
- this.bindNode = this.bindNode.bind( this );
33
32
  }
34
33
 
35
34
  componentDidMount() {
@@ -53,10 +52,6 @@ class SlotComponent extends Component {
53
52
  }
54
53
  }
55
54
 
56
- bindNode( node ) {
57
- this.node = node;
58
- }
59
-
60
55
  forceUpdate() {
61
56
  if ( this.isUnmounted ) {
62
57
  return;
package/src/style.scss CHANGED
@@ -1,3 +1,9 @@
1
+ // Include the default WP Components color variables.
2
+ // TODO: Remove this once all admin-scheme variables are accounted for in the wp-components fallback values.
3
+ :root {
4
+ @include admin-scheme(#3858e9);
5
+ }
6
+
1
7
  // Variables
2
8
  @import "./utils/theme-variables.scss";
3
9
 
@@ -101,7 +101,7 @@ export function TabPanel( {
101
101
  // to show the `tab-panel` associated with the clicked tab.
102
102
  const activateTabAutomatically = (
103
103
  _childIndex: number,
104
- child: HTMLButtonElement
104
+ child: HTMLElement
105
105
  ) => {
106
106
  child.click();
107
107
  };
@@ -48,7 +48,7 @@ export function checkContrasts(
48
48
  outputs: ThemeOutputValues[ 'colors' ]
49
49
  ) {
50
50
  const background = inputs.background || COLORS.white;
51
- const accent = inputs.accent || '#007cba';
51
+ const accent = inputs.accent || '#3858e9';
52
52
  const foreground = outputs.foreground || COLORS.gray[ 900 ];
53
53
  const gray = outputs.gray || COLORS.gray;
54
54
 
@@ -103,7 +103,7 @@ export const ColorScheme: ComponentStory< typeof Theme > = ( {
103
103
  );
104
104
  };
105
105
  ColorScheme.args = {
106
- accent: '#007cba',
106
+ accent: '#3858e9',
107
107
  background: '#fff',
108
108
  };
109
109
  ColorScheme.argTypes = {
@@ -53,9 +53,9 @@ describe( 'Theme color algorithms', () => {
53
53
  'wp.components.Theme: The background color ("#000") does not have sufficient contrast against the accent color ("#111").'
54
54
  );
55
55
 
56
- generateThemeVariables( { background: '#eee' } );
56
+ generateThemeVariables( { background: '#1a1a1a' } );
57
57
  expect( console ).toHaveWarnedWith(
58
- 'wp.components.Theme: The background color ("#eee") does not have sufficient contrast against the accent color ("#007cba").'
58
+ 'wp.components.Theme: The background color ("#1a1a1a") does not have sufficient contrast against the accent color ("#3858e9").'
59
59
  );
60
60
  } );
61
61
 
@@ -65,8 +65,8 @@ exports[`ToggleGroupControl should render correctly with icons 1`] = `
65
65
  }
66
66
 
67
67
  .emotion-8:focus-within {
68
- border-color: var(--wp-components-color-accent-darker-10, var(--wp-admin-theme-color-darker-10, #006ba1));
69
- box-shadow: 0 0 0 0.5px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
68
+ border-color: var(--wp-components-color-accent-darker-10, var(--wp-admin-theme-color-darker-10, #2145e6));
69
+ box-shadow: 0 0 0 0.5px var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
70
70
  outline: none;
71
71
  z-index: 1;
72
72
  }
@@ -400,8 +400,8 @@ exports[`ToggleGroupControl should render correctly with text options 1`] = `
400
400
  }
401
401
 
402
402
  .emotion-8:focus-within {
403
- border-color: var(--wp-components-color-accent-darker-10, var(--wp-admin-theme-color-darker-10, #006ba1));
404
- box-shadow: 0 0 0 0.5px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
403
+ border-color: var(--wp-components-color-accent-darker-10, var(--wp-admin-theme-color-darker-10, #2145e6));
404
+ box-shadow: 0 0 0 0.5px var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
405
405
  outline: none;
406
406
  z-index: 1;
407
407
  }
@@ -83,30 +83,32 @@ Default.args = {
83
83
  <ToolbarGroup>
84
84
  <ToolbarItem>
85
85
  {
86
- // @ts-expect-error TODO: Remove when ToolbarItem/DropdownMenu is typed
87
- ( toggleProps ) => (
88
- <DropdownMenu
89
- hasArrowIndicator
90
- icon={ alignLeft }
91
- label="Align"
92
- controls={ [
93
- {
94
- icon: alignLeft,
95
- title: 'Align left',
96
- isActive: true,
97
- },
98
- {
99
- icon: alignCenter,
100
- title: 'Align center',
101
- },
102
- {
103
- icon: alignRight,
104
- title: 'Align right',
105
- },
106
- ] }
107
- toggleProps={ toggleProps }
108
- />
109
- )
86
+ // @ts-expect-error TODO: Remove when DropdownMenu is typed
87
+ ( toggleProps ) => {
88
+ return (
89
+ <DropdownMenu
90
+ hasArrowIndicator
91
+ icon={ alignLeft }
92
+ label="Align"
93
+ controls={ [
94
+ {
95
+ icon: alignLeft,
96
+ title: 'Align left',
97
+ isActive: true,
98
+ },
99
+ {
100
+ icon: alignCenter,
101
+ title: 'Align center',
102
+ },
103
+ {
104
+ icon: alignRight,
105
+ title: 'Align right',
106
+ },
107
+ ] }
108
+ toggleProps={ toggleProps }
109
+ />
110
+ );
111
+ }
110
112
  }
111
113
  </ToolbarItem>
112
114
  </ToolbarGroup>
@@ -82,19 +82,16 @@ function UnforwardedToolbarButton(
82
82
  { ...props }
83
83
  ref={ ref }
84
84
  >
85
- {
86
- // @ts-expect-error
87
- ( toolbarItemProps ) => (
88
- <Button
89
- label={ title }
90
- isPressed={ isActive }
91
- disabled={ isDisabled }
92
- { ...toolbarItemProps }
93
- >
94
- { children }
95
- </Button>
96
- )
97
- }
85
+ { ( toolbarItemProps ) => (
86
+ <Button
87
+ label={ title }
88
+ isPressed={ isActive }
89
+ disabled={ isDisabled }
90
+ { ...toolbarItemProps }
91
+ >
92
+ { children }
93
+ </Button>
94
+ ) }
98
95
  </ToolbarItem>
99
96
  );
100
97
  }
@@ -1,9 +1,8 @@
1
- // @ts-nocheck
2
-
3
1
  /**
4
2
  * External dependencies
5
3
  */
6
4
  import { ToolbarItem as BaseToolbarItem } from 'reakit/Toolbar';
5
+ import type { ForwardedRef } from 'react';
7
6
 
8
7
  /**
9
8
  * WordPress dependencies
@@ -16,7 +15,14 @@ import warning from '@wordpress/warning';
16
15
  */
17
16
  import ToolbarContext from '../toolbar-context';
18
17
 
19
- function ToolbarItem( { children, as: Component, ...props }, ref ) {
18
+ function ToolbarItem(
19
+ {
20
+ children,
21
+ as: Component,
22
+ ...props
23
+ }: React.ComponentPropsWithoutRef< typeof BaseToolbarItem >,
24
+ ref: ForwardedRef< any >
25
+ ) {
20
26
  const accessibleToolbarState = useContext( ToolbarContext );
21
27
 
22
28
  if ( typeof children !== 'function' && ! Component ) {
@@ -33,6 +39,9 @@ function ToolbarItem( { children, as: Component, ...props }, ref ) {
33
39
  if ( Component ) {
34
40
  return <Component { ...allProps }>{ children }</Component>;
35
41
  }
42
+ if ( typeof children !== 'function' ) {
43
+ return null;
44
+ }
36
45
  return children( allProps );
37
46
  }
38
47
 
@@ -127,8 +127,26 @@ An integer value that represents the total number of items in the set, at this s
127
127
 
128
128
  An optional value that designates whether a row is expanded or collapsed. Currently this value only sets the correct aria-expanded property on a row, it has no other built-in behavior.
129
129
 
130
+ If there is a need to implement `aria-expanded` elsewhere in the row, cell, or element within a cell, you may pass `isExpanded={ undefined }`. In order for keyboard navigation to continue working, add the `data-expanded` attribute with either `true`/`false`. This allows the `TreeGrid` component to still manage keyboard interactions while allowing the `aria-expanded` attribute to be placed elsewhere. See the example below.
131
+
130
132
  - Required: No
131
133
 
134
+ ```jsx
135
+ function TreeMenu() {
136
+ return (
137
+ <TreeGrid>
138
+ <TreeGridRow level={ 1 } positionInSet={ 1 } setSize={ 2 } isExpanded={ undefined } data-expanded={ false }>
139
+ <TreeGridCell>
140
+ { ( props ) => (
141
+ <Button aria-expanded="false" onClick={ onSelect } { ...props }>Select</Button>
142
+ ) }
143
+ </TreeGridCell>
144
+ </TreeGridRow>
145
+ </TreeGrid>
146
+ );
147
+ }
148
+ ```
149
+
132
150
  ### TreeGridCell
133
151
 
134
152
  #### Props
@@ -22,6 +22,13 @@ export type TreeGridRowProps = {
22
22
  * An optional value that designates whether a row is expanded or collapsed.
23
23
  * Currently this value only sets the correct aria-expanded property on a row,
24
24
  * it has no other built-in behavior.
25
+ *
26
+ * If there is a need to implement `aria-expanded` elsewhere in the row, cell,
27
+ * or element within a cell, you may pass `isExpanded={ undefined }`.
28
+ * In order for keyboard navigation to continue working, add the
29
+ * `data-expanded` attribute with either `true`/`false`. This allows the
30
+ * `TreeGrid` component to still manage keyboard interactions while allowing
31
+ * the `aria-expanded` attribute to be placed elsewhere.
25
32
  */
26
33
  isExpanded?: boolean;
27
34
  };
@@ -29,11 +29,11 @@ const ALERT = {
29
29
  green: '#4ab866',
30
30
  };
31
31
 
32
- // Matches @wordpress/base-styles
32
+ // Matches the Modern admin scheme in @wordpress/base-styles
33
33
  const ADMIN = {
34
- theme: 'var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba))',
34
+ theme: 'var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9))',
35
35
  themeDark10:
36
- 'var(--wp-components-color-accent-darker-10, var(--wp-admin-theme-color-darker-10, #006ba1))',
36
+ 'var(--wp-components-color-accent-darker-10, var(--wp-admin-theme-color-darker-10, #2145e6))',
37
37
  };
38
38
 
39
39
  const UI = {
@@ -2,10 +2,10 @@
2
2
  //
3
3
  // If the `--wp-components-color-accent` variable is not defined, fallback to
4
4
  // `--wp-admin-theme-color`. If the `--wp-admin-theme-color` variable is not
5
- // defined, fallback to the default theme color (WP blue).
6
- $components-color-accent: var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
7
- $components-color-accent-darker-10: var(--wp-components-color-accent-darker-10, var(--wp-admin-theme-color-darker-10, #006ba1));
8
- $components-color-accent-darker-20: var(--wp-components-color-accent-darker-20, var(--wp-admin-theme-color-darker-20, #005a87));
5
+ // defined, fallback to the default theme color (WP blueberry).
6
+ $components-color-accent: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
7
+ $components-color-accent-darker-10: var(--wp-components-color-accent-darker-10, var(--wp-admin-theme-color-darker-10, #2145e6));
8
+ $components-color-accent-darker-20: var(--wp-components-color-accent-darker-20, var(--wp-admin-theme-color-darker-20, #183ad6));
9
9
 
10
10
  // Used when placing text on the accent color.
11
11
  $components-color-accent-inverted: var(--wp-components-color-accent-inverted, $white);
@@ -0,0 +1,29 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import deprecated from '@wordpress/deprecated';
5
+
6
+ export function useDeprecated36pxDefaultSizeProp<
7
+ P extends Record< string, any > & {
8
+ __next36pxDefaultSize?: boolean;
9
+ __next40pxDefaultSize?: boolean;
10
+ }
11
+ >(
12
+ props: P,
13
+ /** The component identifier in dot notation, e.g. `wp.components.ComponentName`. */
14
+ componentIdentifier: string
15
+ ) {
16
+ const { __next36pxDefaultSize, __next40pxDefaultSize, ...otherProps } =
17
+ props;
18
+ if ( typeof __next36pxDefaultSize !== 'undefined' ) {
19
+ deprecated( '`__next36pxDefaultSize` prop in ' + componentIdentifier, {
20
+ alternative: '`__next40pxDefaultSize`',
21
+ since: '6.3',
22
+ } );
23
+ }
24
+
25
+ return {
26
+ ...otherProps,
27
+ __next40pxDefaultSize: __next40pxDefaultSize ?? __next36pxDefaultSize,
28
+ };
29
+ }