@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
@@ -1,66 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import type { StoryFn } from '@storybook/react-vite';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import { Navigation } from '../..';
10
- import { NavigationItem } from '../../item';
11
- import { NavigationMenu } from '../../menu';
12
-
13
- export const HideIfEmptyStory: StoryFn< typeof Navigation > = ( {
14
- className,
15
- ...props
16
- } ) => {
17
- return (
18
- <>
19
- <Navigation
20
- { ...props }
21
- className={ [ 'navigation-story', className ]
22
- .filter( Boolean )
23
- .join( ' ' ) }
24
- >
25
- <NavigationMenu title="Home" menu="root" isEmpty={ false }>
26
- <NavigationItem
27
- navigateToMenu="root-sub-1"
28
- title="To sub 1 (hidden)"
29
- hideIfTargetMenuEmpty
30
- />
31
-
32
- <NavigationItem
33
- navigateToMenu="root-sub-2"
34
- title="To sub 2 (visible)"
35
- hideIfTargetMenuEmpty
36
- />
37
-
38
- <NavigationItem
39
- navigateToMenu="root-sub-1-sub-1"
40
- title="To sub 1-1 (hidden)"
41
- hideIfTargetMenuEmpty
42
- />
43
- </NavigationMenu>
44
-
45
- <NavigationMenu menu="root-sub-1" parentMenu="root" isEmpty />
46
- <NavigationMenu
47
- menu="root-sub-2"
48
- parentMenu="root"
49
- isEmpty={ false }
50
- >
51
- <NavigationItem title="This menu is visible" />
52
- </NavigationMenu>
53
- <NavigationMenu
54
- menu="root-sub-1-sub-1"
55
- parentMenu="root-sub-1"
56
- isEmpty
57
- />
58
- </Navigation>
59
-
60
- <p>
61
- This story contains 3 navigation items and 4 menus. You should
62
- only see one item: <strong>To sub 2 (visible)</strong>
63
- </p>
64
- </>
65
- );
66
- };
@@ -1,162 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import type { StoryFn } from '@storybook/react-vite';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { useEffect, useState } from '@wordpress/element';
10
- import { Icon, wordpress, home } from '@wordpress/icons';
11
-
12
- /**
13
- * Internal dependencies
14
- */
15
- import { Navigation } from '../..';
16
- import { NavigationGroup } from '../../group';
17
- import { NavigationItem } from '../../item';
18
- import { NavigationMenu } from '../../menu';
19
-
20
- export const MoreExamplesStory: StoryFn< typeof Navigation > = ( {
21
- className,
22
- ...props
23
- } ) => {
24
- const [ activeItem, setActiveItem ] = useState( 'child-1' );
25
- const [ delayedBadge, setDelayedBadge ] = useState< number | undefined >();
26
- useEffect( () => {
27
- const timeout = setTimeout( () => setDelayedBadge( 2 ), 1500 );
28
- return () => clearTimeout( timeout );
29
- } );
30
- const [ backButtonBadge, setBackButtonBadge ] = useState( 1 );
31
- const [ backButtonPreventedBadge, setBackButtonPreventedBadge ] =
32
- useState( 1 );
33
-
34
- return (
35
- <Navigation
36
- { ...props }
37
- activeItem={ activeItem }
38
- className={ [ 'navigation-story', className ]
39
- .filter( Boolean )
40
- .join( ' ' ) }
41
- >
42
- <NavigationMenu title="Home">
43
- <NavigationGroup title="Items without Active State">
44
- <NavigationItem item="item-1" title="Item 1" />
45
- <NavigationItem item="item-2" title="Item 2" />
46
- </NavigationGroup>
47
- <NavigationGroup title="Items with Unusual Features">
48
- <NavigationItem
49
- icon={ home }
50
- item="item-sub-menu"
51
- navigateToMenu="sub-menu"
52
- title="Sub-Menu with Custom Back Label"
53
- />
54
- <NavigationItem
55
- item="item-custom-back-click-handler"
56
- navigateToMenu="custom-back-click-handler-menu"
57
- title="Custom Back Click Handler"
58
- badge={ backButtonBadge }
59
- />
60
- <NavigationItem
61
- item="item-custom-back-click-handler-prevented"
62
- navigateToMenu="custom-back-click-handler-prevented-menu"
63
- title="Prevent back navigation"
64
- />
65
- <NavigationItem
66
- item="item-nonexistent-menu"
67
- navigateToMenu="nonexistent-menu"
68
- title="Navigate to Nonexistent Menu"
69
- />
70
- <NavigationItem
71
- badge={ delayedBadge }
72
- item="item-delayed-badge"
73
- onClick={ () => setActiveItem( 'item-delayed-badge' ) }
74
- title="Item with a Delayed Badge"
75
- />
76
- </NavigationGroup>
77
- <NavigationGroup title="External Links">
78
- <NavigationItem
79
- href="https://wordpress.org/"
80
- item="item-4"
81
- target="_blank"
82
- title="WordPress.org"
83
- />
84
- <NavigationItem item="item-5">
85
- { /* eslint-disable-next-line react/jsx-no-target-blank */ }
86
- <a
87
- className="navigation-story__wordpress-icon"
88
- href="https://wordpress.org/"
89
- target="_blank"
90
- rel="noopener"
91
- >
92
- <Icon icon={ wordpress } />
93
- <em>Custom Content</em>
94
- </a>
95
- </NavigationItem>
96
- </NavigationGroup>
97
- <NavigationGroup title="Text only items">
98
- <NavigationItem
99
- item="item-text-only"
100
- title="This is just text, doesn't have any functionality"
101
- isText
102
- />
103
- <NavigationItem
104
- item="item-text-only-with-badge"
105
- title="Text with badge"
106
- badge="2"
107
- isText
108
- />
109
- </NavigationGroup>
110
- </NavigationMenu>
111
-
112
- <NavigationMenu
113
- backButtonLabel="Custom Back Button Label"
114
- menu="sub-menu"
115
- parentMenu="root"
116
- title="Sub-Menu with Custom Back Label"
117
- >
118
- <NavigationItem
119
- item="child-1"
120
- onClick={ () => setActiveItem( 'child-1' ) }
121
- title="Child 1"
122
- />
123
- <NavigationItem
124
- item="child-2"
125
- onClick={ () => setActiveItem( 'child-2' ) }
126
- title="Child 2"
127
- />
128
- </NavigationMenu>
129
-
130
- <NavigationMenu
131
- menu="custom-back-click-handler-menu"
132
- title="Custom back button click handler"
133
- parentMenu="root"
134
- onBackButtonClick={ () =>
135
- setBackButtonBadge( backButtonBadge + 1 )
136
- }
137
- backButtonLabel="Increment badge and go back"
138
- />
139
-
140
- <NavigationMenu
141
- menu="custom-back-click-handler-prevented-menu"
142
- title="Custom back button click handler prevented"
143
- parentMenu="root"
144
- onBackButtonClick={
145
- ( ( event ) => {
146
- event.preventDefault();
147
- setBackButtonPreventedBadge(
148
- backButtonPreventedBadge + 1
149
- );
150
- } ) as React.MouseEventHandler
151
- }
152
- backButtonLabel="Increment badge"
153
- >
154
- <NavigationItem
155
- item="custom-back-click-prevented-child-1"
156
- title="You can't go back from here"
157
- badge={ backButtonPreventedBadge }
158
- />
159
- </NavigationMenu>
160
- </Navigation>
161
- );
162
- };
@@ -1,91 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import type { StoryFn } from '@storybook/react-vite';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { useState } from '@wordpress/element';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import { Navigation } from '../..';
15
- import { NavigationGroup } from '../../group';
16
- import { NavigationItem } from '../../item';
17
- import { NavigationMenu } from '../../menu';
18
- import { normalizedSearch } from '../../utils';
19
-
20
- const searchItems = [
21
- { item: 'foo', title: 'Foo' },
22
- { item: 'bar', title: 'Bar' },
23
- { item: 'baz', title: 'Baz' },
24
- { item: 'qux', title: 'Qux' },
25
- { item: 'quux', title: 'Quux' },
26
- { item: 'corge', title: 'Corge' },
27
- { item: 'grault', title: 'Grault' },
28
- { item: 'garply', title: 'Garply' },
29
- { item: 'waldo', title: 'Waldo' },
30
- ];
31
-
32
- export const SearchStory: StoryFn< typeof Navigation > = ( {
33
- className,
34
- ...props
35
- } ) => {
36
- const [ activeItem, setActiveItem ] = useState( 'item-1' );
37
- const [ search, setSearch ] = useState( '' );
38
-
39
- return (
40
- <Navigation
41
- { ...props }
42
- activeItem={ activeItem }
43
- className={ [ 'navigation-story', className ]
44
- .filter( Boolean )
45
- .join( ' ' ) }
46
- >
47
- <NavigationMenu hasSearch title="Home">
48
- <NavigationGroup title="Items">
49
- { searchItems.map( ( { item, title } ) => (
50
- <NavigationItem
51
- item={ `item-${ item }` }
52
- key={ `item-${ item }` }
53
- onClick={ () => setActiveItem( `item-${ item }` ) }
54
- title={ title }
55
- />
56
- ) ) }
57
- </NavigationGroup>
58
-
59
- <NavigationGroup title="More Examples">
60
- <NavigationItem
61
- item="item-controlled-search"
62
- navigateToMenu="controlled-search"
63
- title="Controlled Search"
64
- />
65
- </NavigationGroup>
66
- </NavigationMenu>
67
-
68
- <NavigationMenu
69
- hasSearch
70
- menu="controlled-search"
71
- onSearch={ ( value ) => setSearch( value ) }
72
- parentMenu="root"
73
- search={ search }
74
- title="Controlled Search"
75
- >
76
- { searchItems
77
- .filter( ( { title } ) =>
78
- normalizedSearch( title, search )
79
- )
80
- .map( ( { item, title } ) => (
81
- <NavigationItem
82
- item={ `child-${ item }` }
83
- key={ `child-${ item }` }
84
- onClick={ () => setActiveItem( `child-${ item }` ) }
85
- title={ title }
86
- />
87
- ) ) }
88
- </NavigationMenu>
89
- </Navigation>
90
- );
91
- };
@@ -1,197 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import styled from '@emotion/styled';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { isRTL } from '@wordpress/i18n';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import { COLORS } from '../../utils/colors-values';
15
- import Button from '../../button';
16
- import { Text } from '../../text';
17
- import { Heading } from '../../heading';
18
- import { rtl, CONFIG } from '../../utils';
19
- import { space } from '../../utils/space';
20
-
21
- export const NavigationUI = styled.div`
22
- width: 100%;
23
- box-sizing: border-box;
24
- padding: 0 ${ space( 4 ) };
25
- overflow: hidden;
26
- `;
27
-
28
- export const MenuUI = styled.div`
29
- margin-top: ${ space( 6 ) };
30
- margin-bottom: ${ space( 6 ) };
31
- display: flex;
32
- flex-direction: column;
33
- ul {
34
- padding: 0;
35
- margin: 0;
36
- list-style: none;
37
- }
38
- .components-navigation__back-button {
39
- margin-bottom: ${ space( 6 ) };
40
- }
41
-
42
- .components-navigation__group + .components-navigation__group {
43
- margin-top: ${ space( 6 ) };
44
- }
45
- `;
46
-
47
- export const MenuBackButtonUI = styled( Button )`
48
- &.is-tertiary {
49
- color: inherit;
50
- opacity: 0.7;
51
-
52
- &:hover:not( :disabled ) {
53
- opacity: 1;
54
- box-shadow: none;
55
- color: inherit;
56
- }
57
-
58
- &:active:not( :disabled ) {
59
- background: transparent;
60
- opacity: 1;
61
- color: inherit;
62
- }
63
- }
64
- `;
65
-
66
- export const MenuTitleUI = styled.div`
67
- overflow: hidden;
68
- width: 100%;
69
- `;
70
-
71
- export const MenuTitleSearchControlWrapper = styled.div`
72
- margin: 11px 0; // non-ideal hardcoding to maintain same height as Heading, could be improved
73
- padding: 1px; // so the focus border doesn't get cut off by the overflow hidden on MenuTitleUI
74
- `;
75
-
76
- export const MenuTitleActionsUI = styled.span`
77
- height: ${ space( 6 ) }; // 24px, same height as the buttons inside
78
-
79
- .components-button.is-small {
80
- color: inherit;
81
- opacity: 0.7;
82
- margin-right: ${ space( 1 ) }; // Avoid hiding the focus outline
83
- padding: 0;
84
-
85
- &:active:not( :disabled ) {
86
- background: none;
87
- opacity: 1;
88
- color: inherit;
89
- }
90
- &:hover:not( :disabled ) {
91
- box-shadow: none;
92
- opacity: 1;
93
- color: inherit;
94
- }
95
- }
96
- `;
97
-
98
- export const GroupTitleUI = styled( Heading )`
99
- min-height: ${ space( 12 ) };
100
- align-items: center;
101
- color: inherit;
102
- display: flex;
103
- justify-content: space-between;
104
- margin-bottom: ${ space( 2 ) };
105
- padding: ${ () =>
106
- isRTL()
107
- ? `${ space( 1 ) } ${ space( 4 ) } ${ space( 1 ) } ${ space( 2 ) }`
108
- : `${ space( 1 ) } ${ space( 2 ) } ${ space( 1 ) } ${ space(
109
- 4
110
- ) }` };
111
- `;
112
-
113
- export const ItemBaseUI = styled.li`
114
- border-radius: ${ CONFIG.radiusSmall };
115
- color: inherit;
116
- margin-bottom: 0;
117
-
118
- > button,
119
- > a.components-button,
120
- > a {
121
- width: 100%;
122
- color: inherit;
123
- opacity: 0.7;
124
- padding: ${ space( 2 ) } ${ space( 4 ) }; /* 8px 16px */
125
- ${ rtl( { textAlign: 'left' }, { textAlign: 'right' } ) }
126
-
127
- &:hover,
128
- &:focus:not( [aria-disabled='true'] ):active,
129
- &:active:not( [aria-disabled='true'] ):active {
130
- color: inherit;
131
- opacity: 1;
132
- }
133
- }
134
-
135
- &.is-active {
136
- background-color: ${ COLORS.theme.accent };
137
- color: ${ COLORS.theme.accentInverted };
138
-
139
- > button,
140
- .components-button:hover,
141
- > a {
142
- color: ${ COLORS.theme.accentInverted };
143
- opacity: 1;
144
- }
145
- }
146
-
147
- > svg path {
148
- color: ${ COLORS.gray[ 600 ] };
149
- }
150
- `;
151
-
152
- export const ItemUI = styled.div`
153
- display: flex;
154
- align-items: center;
155
- height: auto;
156
- min-height: 40px;
157
- margin: 0;
158
- padding: ${ space( 1.5 ) } ${ space( 4 ) };
159
- font-weight: 400;
160
- line-height: 20px;
161
- width: 100%;
162
- color: inherit;
163
- opacity: 0.7;
164
- `;
165
-
166
- export const ItemIconUI = styled.span`
167
- display: flex;
168
- margin-right: ${ space( 2 ) };
169
- `;
170
-
171
- export const ItemBadgeUI = styled.span`
172
- margin-left: ${ () => ( isRTL() ? '0' : space( 2 ) ) };
173
- margin-right: ${ () => ( isRTL() ? space( 2 ) : '0' ) };
174
- display: inline-flex;
175
- padding: ${ space( 1 ) } ${ space( 3 ) };
176
- border-radius: ${ CONFIG.radiusSmall };
177
-
178
- @keyframes fade-in {
179
- from {
180
- opacity: 0;
181
- }
182
- to {
183
- opacity: 1;
184
- }
185
- }
186
-
187
- @media not ( prefers-reduced-motion ) {
188
- animation: fade-in 250ms ease-out;
189
- }
190
- `;
191
-
192
- export const ItemTitleUI = styled( Text )`
193
- ${ () => ( isRTL() ? 'margin-left: auto;' : 'margin-right: auto;' ) }
194
- font-size: 14px;
195
- line-height: 20px;
196
- color: inherit;
197
- `;