@wordpress/components 33.1.1-next.v.202605131032.0 → 35.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 (287) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/build/autocomplete/index.cjs +5 -4
  3. package/build/autocomplete/index.cjs.map +3 -3
  4. package/build/box-control/index.cjs +0 -6
  5. package/build/box-control/index.cjs.map +2 -2
  6. package/build/box-control/utils.cjs +0 -38
  7. package/build/box-control/utils.cjs.map +3 -3
  8. package/build/custom-gradient-picker/gradient-bar/index.cjs.map +2 -2
  9. package/build/draggable/index.cjs +101 -7
  10. package/build/draggable/index.cjs.map +3 -3
  11. package/build/form-token-field/index.cjs +41 -7
  12. package/build/form-token-field/index.cjs.map +2 -2
  13. package/build/index.cjs +0 -17
  14. package/build/index.cjs.map +2 -2
  15. package/build/notice/index.cjs +33 -35
  16. package/build/notice/index.cjs.map +2 -2
  17. package/build/popover/index.cjs +12 -0
  18. package/build/popover/index.cjs.map +2 -2
  19. package/build/tabs/styles.cjs +5 -5
  20. package/build/tabs/styles.cjs.map +2 -2
  21. package/build-module/autocomplete/index.mjs +6 -5
  22. package/build-module/autocomplete/index.mjs.map +2 -2
  23. package/build-module/box-control/index.mjs +0 -2
  24. package/build-module/box-control/index.mjs.map +2 -2
  25. package/build-module/box-control/utils.mjs +0 -27
  26. package/build-module/box-control/utils.mjs.map +2 -2
  27. package/build-module/custom-gradient-picker/gradient-bar/index.mjs.map +2 -2
  28. package/build-module/draggable/index.mjs +101 -7
  29. package/build-module/draggable/index.mjs.map +3 -3
  30. package/build-module/form-token-field/index.mjs +41 -7
  31. package/build-module/form-token-field/index.mjs.map +2 -2
  32. package/build-module/index.mjs +87 -99
  33. package/build-module/index.mjs.map +2 -2
  34. package/build-module/notice/index.mjs +34 -36
  35. package/build-module/notice/index.mjs.map +2 -2
  36. package/build-module/popover/index.mjs +12 -0
  37. package/build-module/popover/index.mjs.map +2 -2
  38. package/build-module/tabs/styles.mjs +5 -5
  39. package/build-module/tabs/styles.mjs.map +2 -2
  40. package/build-style/style-rtl.css +64 -66
  41. package/build-style/style.css +64 -66
  42. package/build-types/autocomplete/index.d.ts.map +1 -1
  43. package/build-types/badge/stories/e2e/index.story.d.ts +7 -0
  44. package/build-types/badge/stories/e2e/index.story.d.ts.map +1 -0
  45. package/build-types/box-control/index.d.ts +0 -1
  46. package/build-types/box-control/index.d.ts.map +1 -1
  47. package/build-types/box-control/styles/box-control-styles.d.ts +1 -2
  48. package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -1
  49. package/build-types/box-control/utils.d.ts +0 -13
  50. package/build-types/box-control/utils.d.ts.map +1 -1
  51. package/build-types/button/stories/e2e/index.story.d.ts +1 -0
  52. package/build-types/button/stories/e2e/index.story.d.ts.map +1 -1
  53. package/build-types/color-picker/styles.d.ts +1 -2
  54. package/build-types/color-picker/styles.d.ts.map +1 -1
  55. package/build-types/custom-gradient-picker/gradient-bar/index.d.ts.map +1 -1
  56. package/build-types/draggable/index.d.ts.map +1 -1
  57. package/build-types/draggable/stories/index.story.d.ts +4 -5
  58. package/build-types/draggable/stories/index.story.d.ts.map +1 -1
  59. package/build-types/draggable/types.d.ts +4 -0
  60. package/build-types/draggable/types.d.ts.map +1 -1
  61. package/build-types/form-token-field/index.d.ts.map +1 -1
  62. package/build-types/icon/stories/index.story.d.ts +0 -6
  63. package/build-types/icon/stories/index.story.d.ts.map +1 -1
  64. package/build-types/index.d.ts +1 -6
  65. package/build-types/index.d.ts.map +1 -1
  66. package/build-types/notice/index.d.ts.map +1 -1
  67. package/build-types/notice/types.d.ts +1 -2
  68. package/build-types/notice/types.d.ts.map +1 -1
  69. package/build-types/popover/index.d.ts.map +1 -1
  70. package/build-types/range-control/index.d.ts +1 -2
  71. package/build-types/range-control/index.d.ts.map +1 -1
  72. package/build-types/range-control/stories/index.story.d.ts.map +1 -1
  73. package/build-types/range-control/types.d.ts +0 -4
  74. package/build-types/range-control/types.d.ts.map +1 -1
  75. package/build-types/tab-panel/stories/index.story.d.ts +0 -6
  76. package/build-types/tab-panel/stories/index.story.d.ts.map +1 -1
  77. package/build-types/tabs/stories/index.story.d.ts +0 -6
  78. package/build-types/tabs/stories/index.story.d.ts.map +1 -1
  79. package/build-types/tabs/styles.d.ts.map +1 -1
  80. package/build-types/validated-form-controls/components/range-control.d.ts +1 -2
  81. package/build-types/validated-form-controls/components/range-control.d.ts.map +1 -1
  82. package/package.json +24 -22
  83. package/src/autocomplete/index.tsx +25 -7
  84. package/src/badge/stories/e2e/index.story.tsx +21 -0
  85. package/src/box-control/index.tsx +0 -1
  86. package/src/box-control/utils.ts +0 -43
  87. package/src/button/stories/e2e/index.story.tsx +11 -0
  88. package/src/custom-gradient-picker/gradient-bar/index.tsx +1 -1
  89. package/src/draggable/index.tsx +32 -10
  90. package/src/draggable/stories/index.story.tsx +11 -6
  91. package/src/draggable/style.module.scss +29 -0
  92. package/src/draggable/types.ts +4 -0
  93. package/src/form-token-field/index.tsx +84 -8
  94. package/src/form-token-field/test/index.tsx +189 -0
  95. package/src/icon/stories/index.story.tsx +2 -14
  96. package/src/index.ts +0 -6
  97. package/src/menu/test/index.tsx +9 -4
  98. package/src/modal/style.scss +2 -1
  99. package/src/notice/README.md +1 -2
  100. package/src/notice/index.tsx +57 -64
  101. package/src/notice/style.scss +49 -41
  102. package/src/notice/test/__snapshots__/index.tsx.snap +23 -23
  103. package/src/notice/test/index.tsx +5 -5
  104. package/src/notice/types.ts +1 -2
  105. package/src/popover/index.tsx +28 -0
  106. package/src/popover/test/index.tsx +138 -1
  107. package/src/range-control/stories/index.story.tsx +0 -1
  108. package/src/range-control/types.ts +0 -4
  109. package/src/style.scss +0 -1
  110. package/src/tab-panel/stories/index.story.tsx +2 -13
  111. package/src/tab-panel/style.scss +36 -14
  112. package/src/tabs/stories/index.story.tsx +2 -13
  113. package/src/tabs/styles.ts +3 -8
  114. package/build/navigation/back-button/index.cjs +0 -86
  115. package/build/navigation/back-button/index.cjs.map +0 -7
  116. package/build/navigation/constants.cjs +0 -34
  117. package/build/navigation/constants.cjs.map +0 -7
  118. package/build/navigation/context.cjs +0 -58
  119. package/build/navigation/context.cjs.map +0 -7
  120. package/build/navigation/group/context.cjs +0 -38
  121. package/build/navigation/group/context.cjs.map +0 -7
  122. package/build/navigation/group/index.cjs +0 -88
  123. package/build/navigation/group/index.cjs.map +0 -7
  124. package/build/navigation/index.cjs +0 -113
  125. package/build/navigation/index.cjs.map +0 -7
  126. package/build/navigation/item/base-content.cjs +0 -44
  127. package/build/navigation/item/base-content.cjs.map +0 -7
  128. package/build/navigation/item/base.cjs +0 -66
  129. package/build/navigation/item/base.cjs.map +0 -7
  130. package/build/navigation/item/index.cjs +0 -119
  131. package/build/navigation/item/index.cjs.map +0 -7
  132. package/build/navigation/item/use-navigation-tree-item.cjs +0 -64
  133. package/build/navigation/item/use-navigation-tree-item.cjs.map +0 -7
  134. package/build/navigation/menu/context.cjs +0 -39
  135. package/build/navigation/menu/context.cjs.map +0 -7
  136. package/build/navigation/menu/index.cjs +0 -114
  137. package/build/navigation/menu/index.cjs.map +0 -7
  138. package/build/navigation/menu/menu-title-search.cjs +0 -111
  139. package/build/navigation/menu/menu-title-search.cjs.map +0 -7
  140. package/build/navigation/menu/menu-title.cjs +0 -104
  141. package/build/navigation/menu/menu-title.cjs.map +0 -7
  142. package/build/navigation/menu/search-no-results-found.cjs +0 -48
  143. package/build/navigation/menu/search-no-results-found.cjs.map +0 -7
  144. package/build/navigation/menu/use-navigation-tree-menu.cjs +0 -51
  145. package/build/navigation/menu/use-navigation-tree-menu.cjs.map +0 -7
  146. package/build/navigation/styles/navigation-styles.cjs +0 -170
  147. package/build/navigation/styles/navigation-styles.cjs.map +0 -7
  148. package/build/navigation/types.cjs +0 -19
  149. package/build/navigation/types.cjs.map +0 -7
  150. package/build/navigation/use-create-navigation-tree.cjs +0 -103
  151. package/build/navigation/use-create-navigation-tree.cjs.map +0 -7
  152. package/build/navigation/use-navigation-tree-nodes.cjs +0 -60
  153. package/build/navigation/use-navigation-tree-nodes.cjs.map +0 -7
  154. package/build/navigation/utils.cjs +0 -45
  155. package/build/navigation/utils.cjs.map +0 -7
  156. package/build-module/navigation/back-button/index.mjs +0 -51
  157. package/build-module/navigation/back-button/index.mjs.map +0 -7
  158. package/build-module/navigation/constants.mjs +0 -8
  159. package/build-module/navigation/constants.mjs.map +0 -7
  160. package/build-module/navigation/context.mjs +0 -32
  161. package/build-module/navigation/context.mjs.map +0 -7
  162. package/build-module/navigation/group/context.mjs +0 -12
  163. package/build-module/navigation/group/context.mjs.map +0 -7
  164. package/build-module/navigation/group/index.mjs +0 -53
  165. package/build-module/navigation/group/index.mjs.map +0 -7
  166. package/build-module/navigation/index.mjs +0 -78
  167. package/build-module/navigation/index.mjs.map +0 -7
  168. package/build-module/navigation/item/base-content.mjs +0 -23
  169. package/build-module/navigation/item/base-content.mjs.map +0 -7
  170. package/build-module/navigation/item/base.mjs +0 -35
  171. package/build-module/navigation/item/base.mjs.map +0 -7
  172. package/build-module/navigation/item/index.mjs +0 -84
  173. package/build-module/navigation/item/index.mjs.map +0 -7
  174. package/build-module/navigation/item/use-navigation-tree-item.mjs +0 -39
  175. package/build-module/navigation/item/use-navigation-tree-item.mjs.map +0 -7
  176. package/build-module/navigation/menu/context.mjs +0 -13
  177. package/build-module/navigation/menu/context.mjs.map +0 -7
  178. package/build-module/navigation/menu/index.mjs +0 -79
  179. package/build-module/navigation/menu/index.mjs.map +0 -7
  180. package/build-module/navigation/menu/menu-title-search.mjs +0 -80
  181. package/build-module/navigation/menu/menu-title-search.mjs.map +0 -7
  182. package/build-module/navigation/menu/menu-title.mjs +0 -73
  183. package/build-module/navigation/menu/menu-title.mjs.map +0 -7
  184. package/build-module/navigation/menu/search-no-results-found.mjs +0 -27
  185. package/build-module/navigation/menu/search-no-results-found.mjs.map +0 -7
  186. package/build-module/navigation/menu/use-navigation-tree-menu.mjs +0 -26
  187. package/build-module/navigation/menu/use-navigation-tree-menu.mjs.map +0 -7
  188. package/build-module/navigation/styles/navigation-styles.mjs +0 -124
  189. package/build-module/navigation/styles/navigation-styles.mjs.map +0 -7
  190. package/build-module/navigation/types.mjs +0 -1
  191. package/build-module/navigation/types.mjs.map +0 -7
  192. package/build-module/navigation/use-create-navigation-tree.mjs +0 -78
  193. package/build-module/navigation/use-create-navigation-tree.mjs.map +0 -7
  194. package/build-module/navigation/use-navigation-tree-nodes.mjs +0 -35
  195. package/build-module/navigation/use-navigation-tree-nodes.mjs.map +0 -7
  196. package/build-module/navigation/utils.mjs +0 -9
  197. package/build-module/navigation/utils.mjs.map +0 -7
  198. package/build-types/navigation/back-button/index.d.ts +0 -7
  199. package/build-types/navigation/back-button/index.d.ts.map +0 -1
  200. package/build-types/navigation/constants.d.ts +0 -3
  201. package/build-types/navigation/constants.d.ts.map +0 -1
  202. package/build-types/navigation/context.d.ts +0 -4
  203. package/build-types/navigation/context.d.ts.map +0 -1
  204. package/build-types/navigation/group/context.d.ts +0 -7
  205. package/build-types/navigation/group/context.d.ts.map +0 -1
  206. package/build-types/navigation/group/index.d.ts +0 -7
  207. package/build-types/navigation/group/index.d.ts.map +0 -1
  208. package/build-types/navigation/index.d.ts +0 -46
  209. package/build-types/navigation/index.d.ts.map +0 -1
  210. package/build-types/navigation/item/base-content.d.ts +0 -3
  211. package/build-types/navigation/item/base-content.d.ts.map +0 -1
  212. package/build-types/navigation/item/base.d.ts +0 -3
  213. package/build-types/navigation/item/base.d.ts.map +0 -1
  214. package/build-types/navigation/item/index.d.ts +0 -7
  215. package/build-types/navigation/item/index.d.ts.map +0 -1
  216. package/build-types/navigation/item/use-navigation-tree-item.d.ts +0 -3
  217. package/build-types/navigation/item/use-navigation-tree-item.d.ts.map +0 -1
  218. package/build-types/navigation/menu/context.d.ts +0 -7
  219. package/build-types/navigation/menu/context.d.ts.map +0 -1
  220. package/build-types/navigation/menu/index.d.ts +0 -7
  221. package/build-types/navigation/menu/index.d.ts.map +0 -1
  222. package/build-types/navigation/menu/menu-title-search.d.ts +0 -3
  223. package/build-types/navigation/menu/menu-title-search.d.ts.map +0 -1
  224. package/build-types/navigation/menu/menu-title.d.ts +0 -3
  225. package/build-types/navigation/menu/menu-title.d.ts.map +0 -1
  226. package/build-types/navigation/menu/search-no-results-found.d.ts +0 -3
  227. package/build-types/navigation/menu/search-no-results-found.d.ts.map +0 -1
  228. package/build-types/navigation/menu/use-navigation-tree-menu.d.ts +0 -3
  229. package/build-types/navigation/menu/use-navigation-tree-menu.d.ts.map +0 -1
  230. package/build-types/navigation/stories/index.story.d.ts +0 -23
  231. package/build-types/navigation/stories/index.story.d.ts.map +0 -1
  232. package/build-types/navigation/stories/utils/controlled-state.d.ts +0 -7
  233. package/build-types/navigation/stories/utils/controlled-state.d.ts.map +0 -1
  234. package/build-types/navigation/stories/utils/default.d.ts +0 -10
  235. package/build-types/navigation/stories/utils/default.d.ts.map +0 -1
  236. package/build-types/navigation/stories/utils/group.d.ts +0 -10
  237. package/build-types/navigation/stories/utils/group.d.ts.map +0 -1
  238. package/build-types/navigation/stories/utils/hide-if-empty.d.ts +0 -10
  239. package/build-types/navigation/stories/utils/hide-if-empty.d.ts.map +0 -1
  240. package/build-types/navigation/stories/utils/more-examples.d.ts +0 -10
  241. package/build-types/navigation/stories/utils/more-examples.d.ts.map +0 -1
  242. package/build-types/navigation/stories/utils/search.d.ts +0 -10
  243. package/build-types/navigation/stories/utils/search.d.ts.map +0 -1
  244. package/build-types/navigation/styles/navigation-styles.d.ts +0 -55
  245. package/build-types/navigation/styles/navigation-styles.d.ts.map +0 -1
  246. package/build-types/navigation/test/index.d.ts +0 -2
  247. package/build-types/navigation/test/index.d.ts.map +0 -1
  248. package/build-types/navigation/types.d.ts +0 -266
  249. package/build-types/navigation/types.d.ts.map +0 -1
  250. package/build-types/navigation/use-create-navigation-tree.d.ts +0 -15
  251. package/build-types/navigation/use-create-navigation-tree.d.ts.map +0 -1
  252. package/build-types/navigation/use-navigation-tree-nodes.d.ts +0 -10
  253. package/build-types/navigation/use-navigation-tree-nodes.d.ts.map +0 -1
  254. package/build-types/navigation/utils.d.ts +0 -3
  255. package/build-types/navigation/utils.d.ts.map +0 -1
  256. package/src/draggable/style.scss +0 -21
  257. package/src/navigation/README.md +0 -267
  258. package/src/navigation/back-button/index.tsx +0 -73
  259. package/src/navigation/constants.tsx +0 -2
  260. package/src/navigation/context.tsx +0 -40
  261. package/src/navigation/group/context.tsx +0 -16
  262. package/src/navigation/group/index.tsx +0 -73
  263. package/src/navigation/index.tsx +0 -152
  264. package/src/navigation/item/base-content.tsx +0 -31
  265. package/src/navigation/item/base.tsx +0 -42
  266. package/src/navigation/item/index.tsx +0 -112
  267. package/src/navigation/item/use-navigation-tree-item.tsx +0 -47
  268. package/src/navigation/menu/context.tsx +0 -20
  269. package/src/navigation/menu/index.tsx +0 -105
  270. package/src/navigation/menu/menu-title-search.tsx +0 -99
  271. package/src/navigation/menu/menu-title.tsx +0 -100
  272. package/src/navigation/menu/search-no-results-found.tsx +0 -34
  273. package/src/navigation/menu/use-navigation-tree-menu.tsx +0 -29
  274. package/src/navigation/stories/index.story.tsx +0 -62
  275. package/src/navigation/stories/style.css +0 -25
  276. package/src/navigation/stories/utils/controlled-state.tsx +0 -149
  277. package/src/navigation/stories/utils/default.tsx +0 -92
  278. package/src/navigation/stories/utils/group.tsx +0 -61
  279. package/src/navigation/stories/utils/hide-if-empty.tsx +0 -66
  280. package/src/navigation/stories/utils/more-examples.tsx +0 -162
  281. package/src/navigation/stories/utils/search.tsx +0 -91
  282. package/src/navigation/styles/navigation-styles.tsx +0 -197
  283. package/src/navigation/test/index.tsx +0 -347
  284. package/src/navigation/types.ts +0 -325
  285. package/src/navigation/use-create-navigation-tree.tsx +0 -110
  286. package/src/navigation/use-navigation-tree-nodes.tsx +0 -31
  287. package/src/navigation/utils.tsx +0 -11
@@ -53,8 +53,7 @@ export type NoticeProps = {
53
53
  /**
54
54
  * Determines the color of the notice: `warning` (yellow),
55
55
  * `success` (green), `error` (red), or `'info'`.
56
- * By default `'info'` will be blue, but if there is a parent Theme component
57
- * with an accent color prop, the notice will take on that color instead.
56
+ * By default `'info'` will be blue.
58
57
  *
59
58
  * @default 'info'
60
59
  */
@@ -146,6 +146,11 @@ const UnforwardedPopover = (
146
146
  getAnchorRect,
147
147
  isAlternate,
148
148
 
149
+ // `onKeyDown` is forwarded to `useDialog` so the consumer's handler
150
+ // is merged with the close-on-Escape one (rather than being silently
151
+ // overridden by the spread of `dialogProps` further below).
152
+ onKeyDown,
153
+
149
154
  // Rest
150
155
  ...contentProps
151
156
  } = useContextSystem( props, 'Popover' );
@@ -279,6 +284,28 @@ const UnforwardedPopover = (
279
284
  ) {
280
285
  return;
281
286
  }
287
+ // Treat focus moves involving portaled descendants as
288
+ // internal: either the next focus target is in the
289
+ // `@wordpress/ui` compat overlay slot, or focus is back
290
+ // inside this popover by the time we evaluate (e.g. when
291
+ // a portaled overlay is dismissed and synchronously
292
+ // restores focus to its trigger).
293
+ // See https://github.com/WordPress/gutenberg/issues/78406.
294
+ const relatedTarget =
295
+ 'relatedTarget' in event ? event.relatedTarget : null;
296
+ if (
297
+ relatedTarget instanceof Element &&
298
+ relatedTarget.closest( '[data-wp-compat-overlay-slot]' )
299
+ ) {
300
+ return;
301
+ }
302
+ if (
303
+ floatingElement &&
304
+ ownerDocument?.activeElement instanceof Element &&
305
+ floatingElement.contains( ownerDocument.activeElement )
306
+ ) {
307
+ return;
308
+ }
282
309
  // Call onFocusOutside if defined or call onClose.
283
310
  if ( onFocusOutside ) {
284
311
  onFocusOutside( event );
@@ -295,6 +322,7 @@ const UnforwardedPopover = (
295
322
  const [ dialogRef, dialogProps ] = useDialog( {
296
323
  constrainTabbing,
297
324
  focusOnMount,
325
+ onKeyDown,
298
326
  __unstableOnClose: onDialogClose,
299
327
  // @ts-expect-error The __unstableOnClose property needs to be deprecated first (see https://github.com/WordPress/gutenberg/pull/27675)
300
328
  onClose: onDialogClose,
@@ -1,7 +1,13 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { render, screen, waitFor, getByText } from '@testing-library/react';
4
+ import {
5
+ act,
6
+ render,
7
+ screen,
8
+ waitFor,
9
+ getByText,
10
+ } from '@testing-library/react';
5
11
  import userEvent from '@testing-library/user-event';
6
12
  import type { CSSProperties } from 'react';
7
13
 
@@ -663,4 +669,135 @@ describe( 'Popover', () => {
663
669
  } );
664
670
  } );
665
671
  } );
672
+
673
+ describe( 'wp compat overlay slot', () => {
674
+ function createOverlaySlot() {
675
+ const slot = document.createElement( 'div' );
676
+ slot.setAttribute( 'data-wp-compat-overlay-slot', '' );
677
+ const slotButton = document.createElement( 'button' );
678
+ slotButton.textContent = 'Slotted item';
679
+ slot.appendChild( slotButton );
680
+ document.body.appendChild( slot );
681
+ return { slot, slotButton };
682
+ }
683
+
684
+ it( 'should not call onFocusOutside when focus moves into the wp compat overlay slot', async () => {
685
+ const user = userEvent.setup();
686
+ const onFocusOutside = jest.fn();
687
+ const { slot, slotButton } = createOverlaySlot();
688
+
689
+ render(
690
+ <Popover onFocusOutside={ onFocusOutside }>
691
+ <button>Inside popover</button>
692
+ </Popover>
693
+ );
694
+
695
+ await user.click( screen.getByText( 'Inside popover' ) );
696
+ await user.click( slotButton );
697
+
698
+ await new Promise( ( resolve ) => setTimeout( resolve, 50 ) );
699
+ expect( onFocusOutside ).not.toHaveBeenCalled();
700
+
701
+ document.body.removeChild( slot );
702
+ } );
703
+
704
+ it( 'should not call onFocusOutside when focus returns from the slot to a popover descendant', async () => {
705
+ const user = userEvent.setup();
706
+ const onFocusOutside = jest.fn();
707
+ const { slot, slotButton } = createOverlaySlot();
708
+
709
+ render(
710
+ <Popover onFocusOutside={ onFocusOutside }>
711
+ <button>Inside popover</button>
712
+ </Popover>
713
+ );
714
+
715
+ const insideButton = screen.getByText( 'Inside popover' );
716
+ await user.click( insideButton );
717
+ await user.click( slotButton );
718
+ insideButton.focus();
719
+
720
+ await new Promise( ( resolve ) => setTimeout( resolve, 50 ) );
721
+ expect( onFocusOutside ).not.toHaveBeenCalled();
722
+
723
+ document.body.removeChild( slot );
724
+ } );
725
+
726
+ it( 'should not call onFocusOutside when focus is restored to a popover descendant by the time the blur check runs', async () => {
727
+ // Mimics the base-ui `Select` backdrop dismissal: focus drops
728
+ // to `body` (so the captured `relatedTarget` is `null`), then
729
+ // is synchronously restored to the popover before the blur
730
+ // check runs.
731
+ const onFocusOutside = jest.fn();
732
+ const { slot, slotButton } = createOverlaySlot();
733
+
734
+ render(
735
+ <Popover
736
+ data-testid="popover"
737
+ onFocusOutside={ onFocusOutside }
738
+ >
739
+ <button>Trigger</button>
740
+ </Popover>
741
+ );
742
+
743
+ const trigger = screen.getByText( 'Trigger' );
744
+ const floating = screen.getByTestId( 'popover' );
745
+
746
+ await act( async () => {
747
+ slotButton.focus();
748
+ floating.dispatchEvent(
749
+ new FocusEvent( 'blur', {
750
+ bubbles: true,
751
+ relatedTarget: null,
752
+ } )
753
+ );
754
+ trigger.focus();
755
+ await new Promise( ( resolve ) => setTimeout( resolve, 50 ) );
756
+ } );
757
+
758
+ expect( onFocusOutside ).not.toHaveBeenCalled();
759
+
760
+ document.body.removeChild( slot );
761
+ } );
762
+
763
+ it( 'should still call onFocusOutside when focus moves to a sibling outside the slot', async () => {
764
+ const user = userEvent.setup();
765
+ const onFocusOutside = jest.fn();
766
+
767
+ render(
768
+ <>
769
+ <Popover onFocusOutside={ onFocusOutside }>
770
+ <button>Inside popover</button>
771
+ </Popover>
772
+ <button>Outside</button>
773
+ </>
774
+ );
775
+
776
+ await user.click( screen.getByText( 'Inside popover' ) );
777
+ await user.click( screen.getByText( 'Outside' ) );
778
+
779
+ await waitFor( () => {
780
+ expect( onFocusOutside ).toHaveBeenCalledTimes( 1 );
781
+ } );
782
+ } );
783
+ } );
784
+
785
+ it( 'should call a consumer-provided onKeyDown alongside close-on-Escape', async () => {
786
+ const user = userEvent.setup();
787
+ const onClose = jest.fn();
788
+ const onKeyDown = jest.fn();
789
+
790
+ render(
791
+ <Popover onClose={ onClose } onKeyDown={ onKeyDown }>
792
+ <button>Inside popover</button>
793
+ </Popover>
794
+ );
795
+
796
+ await user.click( screen.getByText( 'Inside popover' ) );
797
+ await user.keyboard( '[Escape]' );
798
+
799
+ expect( onKeyDown ).toHaveBeenCalled();
800
+ expect( onKeyDown.mock.calls[ 0 ][ 0 ].key ).toBe( 'Escape' );
801
+ expect( onClose ).toHaveBeenCalledTimes( 1 );
802
+ } );
666
803
  } );
@@ -35,7 +35,6 @@ const meta: Meta< typeof RangeControl > = {
35
35
  },
36
36
  color: { control: { type: 'color' } },
37
37
  help: { control: { type: 'text' } },
38
- icon: { control: false },
39
38
  marks: { control: { type: 'object' } },
40
39
  onBlur: { control: false },
41
40
  onChange: { control: false },
@@ -114,10 +114,6 @@ export type RangeControlProps = Pick<
114
114
  * `undefined`.
115
115
  */
116
116
  currentInput?: number;
117
- /**
118
- * An icon to be shown above the slider next to its container title.
119
- */
120
- icon?: string;
121
117
  /**
122
118
  * The slider starting position, used when no `value` is passed.
123
119
  * The `initialPosition` will be clamped between the provided `min`
package/src/style.scss CHANGED
@@ -12,7 +12,6 @@
12
12
  @use "./combobox-control/style.scss" as *;
13
13
  @use "./color-palette/style.scss" as *;
14
14
  @use "./custom-gradient-picker/style.scss" as *;
15
- @use "./draggable/style.scss" as *;
16
15
  @use "./drop-zone/style.scss" as *;
17
16
  @use "./dropdown/style.scss" as *;
18
17
  @use "./dropdown-menu/style.scss" as *;
@@ -1,17 +1,6 @@
1
- /**
2
- * External dependencies
3
- */
4
1
  import type { Meta, StoryFn } from '@storybook/react-vite';
5
2
  import { fn } from 'storybook/test';
6
-
7
- /**
8
- * WordPress dependencies
9
- */
10
3
  import { link, more, wordpress } from '@wordpress/icons';
11
-
12
- /**
13
- * Internal dependencies
14
- */
15
4
  import TabPanel from '..';
16
5
 
17
6
  const meta: Meta< typeof TabPanel > = {
@@ -22,9 +11,9 @@ const meta: Meta< typeof TabPanel > = {
22
11
  controls: { expanded: true },
23
12
  docs: { canvas: { sourceState: 'shown' } },
24
13
  componentStatus: {
25
- status: 'use-with-caution',
14
+ status: 'not-recommended',
26
15
  whereUsed: 'global',
27
- notes: 'When building for the Gutenberg repo, use `Tabs` instead. Otherwise, continue using for now.',
16
+ notes: 'Use `Tabs` from `@wordpress/ui` instead.',
28
17
  },
29
18
  },
30
19
  args: {
@@ -1,11 +1,10 @@
1
- @use "@wordpress/base-styles/colors" as *;
2
1
  @use "@wordpress/base-styles/variables" as *;
3
- @use "../utils/theme-variables" as *;
4
2
 
5
3
  .components-tab-panel__tabs {
6
4
  display: flex;
7
5
  align-items: stretch;
8
6
  flex-direction: row;
7
+
9
8
  &[aria-orientation="vertical"] {
10
9
  flex-direction: column;
11
10
  }
@@ -19,9 +18,19 @@
19
18
  border: none;
20
19
  box-shadow: none;
21
20
  cursor: var(--wpds-cursor-control);
22
- padding: 3px $grid-unit-20; // Use padding to offset the is-active border, this benefits Windows High Contrast mode
21
+ padding: 3px var(--wpds-dimension-padding-lg); // Use padding to offset the is-active border, this benefits Windows High Contrast mode
23
22
  margin-left: 0;
24
- font-weight: $font-weight-regular;
23
+ font-weight: var(--wpds-typography-font-weight-regular);
24
+ color: var(--wpds-color-fg-interactive-neutral);
25
+
26
+ &:disabled,
27
+ &[aria-disabled="true"] {
28
+ color: var(--wpds-color-fg-interactive-neutral-disabled);
29
+ }
30
+
31
+ &:not(:disabled, [aria-disabled="true"]):is(:hover, :focus-visible) {
32
+ color: var(--wpds-color-fg-interactive-neutral-active);
33
+ }
25
34
 
26
35
  &:focus:not(:disabled) {
27
36
  position: relative;
@@ -39,8 +48,8 @@
39
48
  pointer-events: none;
40
49
 
41
50
  // Draw the indicator.
42
- background: $components-color-accent;
43
- height: calc(0 * var(--wp-admin-border-width-focus));
51
+ background: var(--wpds-color-stroke-interactive-neutral-strong);
52
+ height: calc(0 * var(--wpds-border-width-focus));
44
53
  border-radius: 0;
45
54
 
46
55
  // Animation
@@ -51,7 +60,7 @@
51
60
 
52
61
  // Active.
53
62
  &.is-active::after {
54
- height: calc(1 * var(--wp-admin-border-width-focus));
63
+ height: calc(1 * var(--wpds-border-width-focus));
55
64
 
56
65
  // Windows high contrast mode.
57
66
  outline: 2px solid transparent;
@@ -62,15 +71,12 @@
62
71
  &::before {
63
72
  content: "";
64
73
  position: absolute;
65
- top: $grid-unit-15;
66
- right: $grid-unit-15;
67
- bottom: $grid-unit-15;
68
- left: $grid-unit-15;
74
+ inset: var(--wpds-dimension-padding-md);
69
75
  pointer-events: none;
70
76
 
71
77
  // Draw the indicator.
72
78
  box-shadow: 0 0 0 0 transparent;
73
- border-radius: $radius-small;
79
+ border-radius: var(--wpds-border-radius-sm);
74
80
 
75
81
  // Animation
76
82
  @media not (prefers-reduced-motion) {
@@ -79,11 +85,25 @@
79
85
  }
80
86
 
81
87
  &:focus-visible::before {
82
- box-shadow: 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent;
88
+ box-shadow:
89
+ 0 0 0 var(--wpds-border-width-focus)
90
+ var(--wpds-color-stroke-focus-brand);
83
91
 
84
92
  // Windows high contrast mode.
85
93
  outline: 2px solid transparent;
86
94
  }
95
+
96
+ .components-tab-panel__tabs[aria-orientation="vertical"] & {
97
+ border-radius: var(--wpds-border-radius-sm);
98
+
99
+ &::after {
100
+ display: none;
101
+ }
102
+
103
+ &.is-active {
104
+ background: var(--wpds-color-bg-interactive-neutral-weak-active);
105
+ }
106
+ }
87
107
  }
88
108
 
89
109
  .components-tab-panel__tab-content {
@@ -93,7 +113,9 @@
93
113
  }
94
114
 
95
115
  &:focus-visible {
96
- box-shadow: 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent;
116
+ box-shadow:
117
+ 0 0 0 var(--wpds-border-width-focus)
118
+ var(--wpds-color-stroke-focus-brand);
97
119
 
98
120
  // Windows high contrast mode.
99
121
  outline: 2px solid transparent;
@@ -1,18 +1,7 @@
1
- /**
2
- * External dependencies
3
- */
4
1
  import type { Meta, StoryFn } from '@storybook/react-vite';
5
2
  import { fn } from 'storybook/test';
6
-
7
- /**
8
- * WordPress dependencies
9
- */
10
3
  import { wordpress, more, link } from '@wordpress/icons';
11
4
  import { useState } from '@wordpress/element';
12
-
13
- /**
14
- * Internal dependencies
15
- */
16
5
  import { Tabs } from '..';
17
6
  import { Slot, Fill, Provider as SlotFillProvider } from '../../slot-fill';
18
7
  import Button from '../../button';
@@ -35,9 +24,9 @@ const meta: Meta< typeof Tabs > = {
35
24
  controls: { expanded: true },
36
25
  docs: { canvas: { sourceState: 'shown' } },
37
26
  componentStatus: {
38
- status: 'recommended',
27
+ status: 'not-recommended',
39
28
  whereUsed: 'global',
40
- notes: 'When building for the Gutenberg repo, use this component instead of `TabPanel`. Otherwise, continue using `TabPanel`. Both will be superseded by `Tabs` in `@wordpress/ui`, but continue using these for now.',
29
+ notes: 'Use `Tabs` from `@wordpress/ui` instead.',
41
30
  },
42
31
  },
43
32
  args: {
@@ -99,7 +99,7 @@ export const StyledTabList = styled( Ariakit.TabList )`
99
99
  )
100
100
  );
101
101
  border-bottom: var( --wp-admin-border-width-focus ) solid
102
- ${ COLORS.theme.accent };
102
+ ${ COLORS.theme.gray[ 700 ] };
103
103
  }
104
104
  }
105
105
  &[aria-orientation='vertical'] {
@@ -124,11 +124,7 @@ export const StyledTabList = styled( Ariakit.TabList )`
124
124
  var( --antialiasing-factor )
125
125
  )
126
126
  );
127
- background-color: color-mix(
128
- in srgb,
129
- ${ COLORS.theme.accent },
130
- transparent 96%
131
- );
127
+ background-color: ${ COLORS.theme.gray[ 100 ] };
132
128
  }
133
129
  &[data-select-on-move='true']:has(
134
130
  :is( :focus-visible, [data-focus-visible] )
@@ -173,7 +169,7 @@ export const Tab = styled( Ariakit.Tab )`
173
169
  }
174
170
 
175
171
  &:not( [aria-disabled='true'] ):is( :hover, [data-focus-visible] ) {
176
- color: ${ COLORS.theme.accent };
172
+ color: ${ COLORS.theme.foreground };
177
173
  }
178
174
 
179
175
  &:focus:not( :disabled ) {
@@ -222,7 +218,6 @@ export const Tab = styled( Ariakit.Tab )`
222
218
  min-height: ${ space( 10 ) };
223
219
 
224
220
  &[aria-selected='true'] {
225
- color: ${ COLORS.theme.accent };
226
221
  fill: currentColor;
227
222
  }
228
223
  }
@@ -1,86 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // packages/components/src/navigation/back-button/index.tsx
31
- var back_button_exports = {};
32
- __export(back_button_exports, {
33
- NavigationBackButton: () => NavigationBackButton,
34
- default: () => back_button_default
35
- });
36
- module.exports = __toCommonJS(back_button_exports);
37
- var import_clsx = __toESM(require("clsx"));
38
- var import_element = require("@wordpress/element");
39
- var import_i18n = require("@wordpress/i18n");
40
- var import_icons = require("@wordpress/icons");
41
- var import_context = require("../context.cjs");
42
- var import_navigation_styles = require("../styles/navigation-styles.cjs");
43
- var import_jsx_runtime = require("react/jsx-runtime");
44
- function UnforwardedNavigationBackButton({
45
- backButtonLabel,
46
- className,
47
- href,
48
- onClick,
49
- parentMenu
50
- }, ref) {
51
- const {
52
- setActiveMenu,
53
- navigationTree
54
- } = (0, import_context.useNavigationContext)();
55
- const classes = (0, import_clsx.default)("components-navigation__back-button", className);
56
- const parentMenuTitle = parentMenu !== void 0 ? navigationTree.getMenu(parentMenu)?.title : void 0;
57
- const handleOnClick = (event) => {
58
- if (typeof onClick === "function") {
59
- onClick(event);
60
- }
61
- const animationDirection = (0, import_i18n.isRTL)() ? "left" : "right";
62
- if (parentMenu && !event.defaultPrevented) {
63
- setActiveMenu(parentMenu, animationDirection);
64
- }
65
- };
66
- const icon = (0, import_i18n.isRTL)() ? import_icons.chevronRight : import_icons.chevronLeft;
67
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_navigation_styles.MenuBackButtonUI, {
68
- __next40pxDefaultSize: true,
69
- className: classes,
70
- href,
71
- variant: "tertiary",
72
- ref,
73
- onClick: handleOnClick,
74
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.Icon, {
75
- icon
76
- }), backButtonLabel || parentMenuTitle || (0, import_i18n.__)("Back")]
77
- });
78
- }
79
- var NavigationBackButton = (0, import_element.forwardRef)(UnforwardedNavigationBackButton);
80
- NavigationBackButton.displayName = "NavigationBackButton";
81
- var back_button_default = NavigationBackButton;
82
- // Annotate the CommonJS export names for ESM import in node:
83
- 0 && (module.exports = {
84
- NavigationBackButton
85
- });
86
- //# sourceMappingURL=index.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/navigation/back-button/index.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { Icon, chevronLeft, chevronRight } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { useNavigationContext } from '../context';\nimport { MenuBackButtonUI } from '../styles/navigation-styles';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nfunction UnforwardedNavigationBackButton({\n backButtonLabel,\n className,\n href,\n onClick,\n parentMenu\n}, ref) {\n const {\n setActiveMenu,\n navigationTree\n } = useNavigationContext();\n const classes = clsx('components-navigation__back-button', className);\n const parentMenuTitle = parentMenu !== undefined ? navigationTree.getMenu(parentMenu)?.title : undefined;\n const handleOnClick = event => {\n if (typeof onClick === 'function') {\n onClick(event);\n }\n const animationDirection = isRTL() ? 'left' : 'right';\n if (parentMenu && !event.defaultPrevented) {\n setActiveMenu(parentMenu, animationDirection);\n }\n };\n const icon = isRTL() ? chevronRight : chevronLeft;\n return /*#__PURE__*/_jsxs(MenuBackButtonUI, {\n __next40pxDefaultSize: true,\n className: classes,\n href: href,\n variant: \"tertiary\",\n ref: ref,\n onClick: handleOnClick,\n children: [/*#__PURE__*/_jsx(Icon, {\n icon: icon\n }), backButtonLabel || parentMenuTitle || __('Back')]\n });\n}\n\n/**\n * @deprecated Use `Navigator` instead.\n */\nexport const NavigationBackButton = forwardRef(UnforwardedNavigationBackButton);\nNavigationBackButton.displayName = 'NavigationBackButton';\nexport default NavigationBackButton;"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAIjB,qBAA2B;AAC3B,kBAA0B;AAC1B,mBAAgD;AAKhD,qBAAqC;AACrC,+BAAiC;AACjC,yBAA2C;AAC3C,SAAS,gCAAgC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAG,KAAK;AACN,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,EACF,QAAI,qCAAqB;AACzB,QAAM,cAAU,YAAAA,SAAK,sCAAsC,SAAS;AACpE,QAAM,kBAAkB,eAAe,SAAY,eAAe,QAAQ,UAAU,GAAG,QAAQ;AAC/F,QAAM,gBAAgB,WAAS;AAC7B,QAAI,OAAO,YAAY,YAAY;AACjC,cAAQ,KAAK;AAAA,IACf;AACA,UAAM,yBAAqB,mBAAM,IAAI,SAAS;AAC9C,QAAI,cAAc,CAAC,MAAM,kBAAkB;AACzC,oBAAc,YAAY,kBAAkB;AAAA,IAC9C;AAAA,EACF;AACA,QAAM,WAAO,mBAAM,IAAI,4BAAe;AACtC,SAAoB,uCAAAC,MAAM,2CAAkB;AAAA,IAC1C,uBAAuB;AAAA,IACvB,WAAW;AAAA,IACX;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,SAAS;AAAA,IACT,UAAU,CAAc,uCAAAC,KAAK,mBAAM;AAAA,MACjC;AAAA,IACF,CAAC,GAAG,mBAAmB,uBAAmB,gBAAG,MAAM,CAAC;AAAA,EACtD,CAAC;AACH;AAKO,IAAM,2BAAuB,2BAAW,+BAA+B;AAC9E,qBAAqB,cAAc;AACnC,IAAO,sBAAQ;",
6
- "names": ["clsx", "_jsxs", "_jsx"]
7
- }
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/components/src/navigation/constants.tsx
21
- var constants_exports = {};
22
- __export(constants_exports, {
23
- ROOT_MENU: () => ROOT_MENU,
24
- SEARCH_FOCUS_DELAY: () => SEARCH_FOCUS_DELAY
25
- });
26
- module.exports = __toCommonJS(constants_exports);
27
- var ROOT_MENU = "root";
28
- var SEARCH_FOCUS_DELAY = 100;
29
- // Annotate the CommonJS export names for ESM import in node:
30
- 0 && (module.exports = {
31
- ROOT_MENU,
32
- SEARCH_FOCUS_DELAY
33
- });
34
- //# sourceMappingURL=constants.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/navigation/constants.tsx"],
4
- "sourcesContent": ["export const ROOT_MENU = 'root';\nexport const SEARCH_FOCUS_DELAY = 100;"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,YAAY;AAClB,IAAM,qBAAqB;",
6
- "names": []
7
- }
@@ -1,58 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/components/src/navigation/context.tsx
21
- var context_exports = {};
22
- __export(context_exports, {
23
- NavigationContext: () => NavigationContext,
24
- useNavigationContext: () => useNavigationContext
25
- });
26
- module.exports = __toCommonJS(context_exports);
27
- var import_element = require("@wordpress/element");
28
- var import_constants = require("./constants.cjs");
29
- var noop = () => {
30
- };
31
- var defaultIsEmpty = () => false;
32
- var defaultGetter = () => void 0;
33
- var NavigationContext = (0, import_element.createContext)({
34
- activeItem: void 0,
35
- activeMenu: import_constants.ROOT_MENU,
36
- setActiveMenu: noop,
37
- navigationTree: {
38
- items: {},
39
- getItem: defaultGetter,
40
- addItem: noop,
41
- removeItem: noop,
42
- menus: {},
43
- getMenu: defaultGetter,
44
- addMenu: noop,
45
- removeMenu: noop,
46
- childMenu: {},
47
- traverseMenu: noop,
48
- isMenuEmpty: defaultIsEmpty
49
- }
50
- });
51
- NavigationContext.displayName = "NavigationContext";
52
- var useNavigationContext = () => (0, import_element.useContext)(NavigationContext);
53
- // Annotate the CommonJS export names for ESM import in node:
54
- 0 && (module.exports = {
55
- NavigationContext,
56
- useNavigationContext
57
- });
58
- //# sourceMappingURL=context.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/navigation/context.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ROOT_MENU } from './constants';\nconst noop = () => {};\nconst defaultIsEmpty = () => false;\nconst defaultGetter = () => undefined;\nexport const NavigationContext = createContext({\n activeItem: undefined,\n activeMenu: ROOT_MENU,\n setActiveMenu: noop,\n navigationTree: {\n items: {},\n getItem: defaultGetter,\n addItem: noop,\n removeItem: noop,\n menus: {},\n getMenu: defaultGetter,\n addMenu: noop,\n removeMenu: noop,\n childMenu: {},\n traverseMenu: noop,\n isMenuEmpty: defaultIsEmpty\n }\n});\nNavigationContext.displayName = 'NavigationContext';\nexport const useNavigationContext = () => useContext(NavigationContext);"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA0C;AAK1C,uBAA0B;AAC1B,IAAM,OAAO,MAAM;AAAC;AACpB,IAAM,iBAAiB,MAAM;AAC7B,IAAM,gBAAgB,MAAM;AACrB,IAAM,wBAAoB,8BAAc;AAAA,EAC7C,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,gBAAgB;AAAA,IACd,OAAO,CAAC;AAAA,IACR,SAAS;AAAA,IACT,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,OAAO,CAAC;AAAA,IACR,SAAS;AAAA,IACT,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW,CAAC;AAAA,IACZ,cAAc;AAAA,IACd,aAAa;AAAA,EACf;AACF,CAAC;AACD,kBAAkB,cAAc;AACzB,IAAM,uBAAuB,UAAM,2BAAW,iBAAiB;",
6
- "names": []
7
- }