@economic/taco 1.23.1 → 1.24.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. package/dist/components/Header/Header.d.ts +28 -0
  2. package/dist/components/Header/components/AgreementSelector.d.ts +18 -0
  3. package/dist/components/Header/components/Agreements/AgreementDetails.d.ts +20 -0
  4. package/dist/components/Header/components/Button.d.ts +11 -0
  5. package/dist/components/Header/components/Link.d.ts +21 -0
  6. package/dist/components/Header/components/Logo.d.ts +3 -0
  7. package/dist/components/Header/components/MenuButton.d.ts +5 -0
  8. package/dist/components/Header/components/PrimaryNavigation.d.ts +3 -0
  9. package/dist/components/Header/components/SecondaryNavigation.d.ts +3 -0
  10. package/dist/components/Layout/Layout.d.ts +16 -0
  11. package/dist/components/Layout/components/Content.d.ts +3 -0
  12. package/dist/components/Layout/components/Context.d.ts +6 -0
  13. package/dist/components/Layout/components/Page.d.ts +3 -0
  14. package/dist/components/Layout/components/Sidebar.d.ts +3 -0
  15. package/dist/components/Layout/components/Top.d.ts +7 -0
  16. package/dist/components/Navigation2/Navigation2.d.ts +17 -0
  17. package/dist/components/Navigation2/components/Content.d.ts +3 -0
  18. package/dist/components/Navigation2/components/Group.d.ts +9 -0
  19. package/dist/components/Navigation2/components/Link.d.ts +24 -0
  20. package/dist/components/Navigation2/components/Section.d.ts +7 -0
  21. package/dist/components/Provider/Localization.d.ts +27 -17
  22. package/dist/esm/packages/taco/src/components/Card/Card.js +1 -1
  23. package/dist/esm/packages/taco/src/components/Card/Card.js.map +1 -1
  24. package/dist/esm/packages/taco/src/components/Header/Header.js +30 -0
  25. package/dist/esm/packages/taco/src/components/Header/Header.js.map +1 -0
  26. package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js +134 -0
  27. package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js.map +1 -0
  28. package/dist/esm/packages/taco/src/components/Header/components/Agreements/AgreementDetails.js +73 -0
  29. package/dist/esm/packages/taco/src/components/Header/components/Agreements/AgreementDetails.js.map +1 -0
  30. package/dist/esm/packages/taco/src/components/Header/components/Button.js +23 -0
  31. package/dist/esm/packages/taco/src/components/Header/components/Button.js.map +1 -0
  32. package/dist/esm/packages/taco/src/components/Header/components/Link.js +48 -0
  33. package/dist/esm/packages/taco/src/components/Header/components/Link.js.map +1 -0
  34. package/dist/esm/packages/taco/src/components/Header/components/Logo.js +73 -0
  35. package/dist/esm/packages/taco/src/components/Header/components/Logo.js.map +1 -0
  36. package/dist/esm/packages/taco/src/components/Header/components/MenuButton.js +16 -0
  37. package/dist/esm/packages/taco/src/components/Header/components/MenuButton.js.map +1 -0
  38. package/dist/esm/packages/taco/src/components/Header/components/PrimaryNavigation.js +134 -0
  39. package/dist/esm/packages/taco/src/components/Header/components/PrimaryNavigation.js.map +1 -0
  40. package/dist/esm/packages/taco/src/components/Header/components/SecondaryNavigation.js +13 -0
  41. package/dist/esm/packages/taco/src/components/Header/components/SecondaryNavigation.js.map +1 -0
  42. package/dist/esm/packages/taco/src/components/Layout/Layout.js +28 -0
  43. package/dist/esm/packages/taco/src/components/Layout/Layout.js.map +1 -0
  44. package/dist/esm/packages/taco/src/components/Layout/components/Content.js +13 -0
  45. package/dist/esm/packages/taco/src/components/Layout/components/Content.js.map +1 -0
  46. package/dist/esm/packages/taco/src/components/Layout/components/Context.js +9 -0
  47. package/dist/esm/packages/taco/src/components/Layout/components/Context.js.map +1 -0
  48. package/dist/esm/packages/taco/src/components/Layout/components/Page.js +13 -0
  49. package/dist/esm/packages/taco/src/components/Layout/components/Page.js.map +1 -0
  50. package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js +83 -0
  51. package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js.map +1 -0
  52. package/dist/esm/packages/taco/src/components/Layout/components/Top.js +15 -0
  53. package/dist/esm/packages/taco/src/components/Layout/components/Top.js.map +1 -0
  54. package/dist/esm/packages/taco/src/components/Navigation2/Navigation2.js +31 -0
  55. package/dist/esm/packages/taco/src/components/Navigation2/Navigation2.js.map +1 -0
  56. package/dist/esm/packages/taco/src/components/Navigation2/components/Content.js +19 -0
  57. package/dist/esm/packages/taco/src/components/Navigation2/components/Content.js.map +1 -0
  58. package/dist/esm/packages/taco/src/components/Navigation2/components/Group.js +46 -0
  59. package/dist/esm/packages/taco/src/components/Navigation2/components/Group.js.map +1 -0
  60. package/dist/esm/packages/taco/src/components/Navigation2/components/Link.js +71 -0
  61. package/dist/esm/packages/taco/src/components/Navigation2/components/Link.js.map +1 -0
  62. package/dist/esm/packages/taco/src/components/Navigation2/components/Section.js +24 -0
  63. package/dist/esm/packages/taco/src/components/Navigation2/components/Section.js.map +1 -0
  64. package/dist/esm/packages/taco/src/components/Provider/Localization.js +18 -11
  65. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
  66. package/dist/esm/packages/taco/src/components/SearchInput/SearchInput.js +4 -1
  67. package/dist/esm/packages/taco/src/components/SearchInput/SearchInput.js.map +1 -1
  68. package/dist/esm/packages/taco/src/hooks/useBoundaryOverflowDetection.js +3 -1
  69. package/dist/esm/packages/taco/src/hooks/useBoundaryOverflowDetection.js.map +1 -1
  70. package/dist/esm/packages/taco/src/hooks/useIsLargeScreen.js +6 -0
  71. package/dist/esm/packages/taco/src/hooks/useIsLargeScreen.js.map +1 -0
  72. package/dist/esm/packages/taco/src/hooks/useMatchMedia.js +18 -0
  73. package/dist/esm/packages/taco/src/hooks/useMatchMedia.js.map +1 -0
  74. package/dist/esm/packages/taco/src/index.js +9 -0
  75. package/dist/esm/packages/taco/src/index.js.map +1 -1
  76. package/dist/esm/packages/taco/src/primitives/Collection/Collection.js +3 -0
  77. package/dist/esm/packages/taco/src/primitives/Collection/Collection.js.map +1 -0
  78. package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js +4 -1
  79. package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js.map +1 -1
  80. package/dist/esm/packages/taco/src/primitives/Listbox2/components/Root.js +1 -0
  81. package/dist/esm/packages/taco/src/primitives/Listbox2/components/Root.js.map +1 -1
  82. package/dist/hooks/useIsLargeScreen.d.ts +1 -0
  83. package/dist/hooks/useMatchMedia.d.ts +1 -0
  84. package/dist/index.d.ts +7 -0
  85. package/dist/taco.cjs.development.js +809 -17
  86. package/dist/taco.cjs.development.js.map +1 -1
  87. package/dist/taco.cjs.production.min.js +1 -1
  88. package/dist/taco.cjs.production.min.js.map +1 -1
  89. package/package.json +2 -2
  90. package/types.json +538 -101
  91. package/dist/components/Accordion/Accordion.stories.d.ts +0 -26
  92. package/dist/components/Alert/Alert.stories.d.ts +0 -36
  93. package/dist/components/AlertDialog/AlertDialog.stories.d.ts +0 -10
  94. package/dist/components/Backdrop/Backdrop.stories.d.ts +0 -7
  95. package/dist/components/BadgeIcon/BadgeIcon.stories.d.ts +0 -12
  96. package/dist/components/Banner/Banner.stories.d.ts +0 -5
  97. package/dist/components/Button/Button.stories.d.ts +0 -77
  98. package/dist/components/Calendar/Calendar.stories.d.ts +0 -13
  99. package/dist/components/Card/Card.stories.d.ts +0 -12
  100. package/dist/components/Datepicker/Datepicker.stories.d.ts +0 -43
  101. package/dist/components/Dialog/Dialog.stories.d.ts +0 -57
  102. package/dist/components/Field/Field.stories.d.ts +0 -14
  103. package/dist/components/Form/Form.stories.d.ts +0 -14
  104. package/dist/components/Group/Group.stories.d.ts +0 -23
  105. package/dist/components/Hanger/Hanger.stories.d.ts +0 -11
  106. package/dist/components/HoverCard/HoverCard.stories.d.ts +0 -16
  107. package/dist/components/Icon/Icon.stories.d.ts +0 -8
  108. package/dist/components/IconButton/IconButton.stories.d.ts +0 -12
  109. package/dist/components/Input/Input.stories.d.ts +0 -17
  110. package/dist/components/Listbox/Listbox.stories.d.ts +0 -44
  111. package/dist/components/Menu/Menu.stories.d.ts +0 -73
  112. package/dist/components/Navigation/Navigation.stories.d.ts +0 -7
  113. package/dist/components/Pagination/Pagination.stories.d.ts +0 -28
  114. package/dist/components/Popover/Popover.stories.d.ts +0 -29
  115. package/dist/components/Progress/Progress.stories.d.ts +0 -9
  116. package/dist/components/RadioGroup/RadioGroup.stories.d.ts +0 -49
  117. package/dist/components/ScrollArea/ScrollArea.stories.d.ts +0 -8
  118. package/dist/components/SearchInput/SearchInput.stories.d.ts +0 -38
  119. package/dist/components/Select/Select.stories.d.ts +0 -35
  120. package/dist/components/Select2/Select2.stories.d.ts +0 -57
  121. package/dist/components/Spinner/Spinner.stories.d.ts +0 -15
  122. package/dist/components/Table/Table.stories.d.ts +0 -32
  123. package/dist/components/Table2/Table2.stories.d.ts +0 -48
  124. package/dist/components/Tabs/Tabs.stories.d.ts +0 -19
  125. package/dist/components/Tag/Tag.stories.d.ts +0 -9
  126. package/dist/components/Textarea/Textarea.stories.d.ts +0 -40
  127. package/dist/components/Toast/Toast.stories.d.ts +0 -12
  128. package/dist/components/Tooltip/Tooltip.stories.d.ts +0 -26
  129. package/dist/components/Tour/Tour.stories.d.ts +0 -11
  130. package/dist/css/Typography.stories.d.ts +0 -6
  131. package/dist/hooks/useIsRefOverflowing.d.ts +0 -2
  132. package/dist/primitives/Collection/Collection.stories.d.ts +0 -8
  133. package/dist/primitives/Listbox2/Listbox2.stories.d.ts +0 -16
  134. package/dist/primitives/Sortable/Sortable.stories.d.ts +0 -14
@@ -0,0 +1,6 @@
1
+ import { useMatchMedia } from './useMatchMedia.js';
2
+
3
+ const useIsLargeScreen = () => useMatchMedia('(min-width: 1024px)', window.innerWidth > 1024);
4
+
5
+ export { useIsLargeScreen };
6
+ //# sourceMappingURL=useIsLargeScreen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIsLargeScreen.js","sources":["../../../../../../src/hooks/useIsLargeScreen.ts"],"sourcesContent":["import { useMatchMedia } from './useMatchMedia';\n\nexport const useIsLargeScreen = () => useMatchMedia('(min-width: 1024px)', window.innerWidth > 1024);\n"],"names":["useIsLargeScreen","useMatchMedia","window","innerWidth"],"mappings":";;MAEaA,gBAAgB,GAAG,MAAMC,aAAa,CAAC,qBAAqB,EAAEC,MAAM,CAACC,UAAU,GAAG,IAAI;;;;"}
@@ -0,0 +1,18 @@
1
+ import React__default from 'react';
2
+
3
+ const useMatchMedia = (query, defaultMatches = false) => {
4
+ const [matches, setMatches] = React__default.useState(defaultMatches);
5
+ const handleChange = React__default.useCallback(event => setMatches(event.matches), []);
6
+ React__default.useEffect(() => {
7
+ const mediaQuery = window.matchMedia(query);
8
+ setMatches(mediaQuery.matches);
9
+ mediaQuery.addEventListener('change', handleChange);
10
+ return () => {
11
+ mediaQuery.removeEventListener('change', handleChange);
12
+ };
13
+ }, []);
14
+ return matches;
15
+ };
16
+
17
+ export { useMatchMedia };
18
+ //# sourceMappingURL=useMatchMedia.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMatchMedia.js","sources":["../../../../../../src/hooks/useMatchMedia.ts"],"sourcesContent":["import React from 'react';\n\nexport const useMatchMedia = (query: string, defaultMatches = false): boolean => {\n const [matches, setMatches] = React.useState<boolean>(defaultMatches);\n\n const handleChange = React.useCallback((event: MediaQueryList | MediaQueryListEvent) => setMatches(event.matches), []);\n\n React.useEffect(() => {\n const mediaQuery = window.matchMedia(query);\n setMatches(mediaQuery.matches);\n mediaQuery.addEventListener('change', handleChange);\n\n return () => {\n mediaQuery.removeEventListener('change', handleChange);\n };\n }, []);\n\n return matches;\n};\n"],"names":["useMatchMedia","query","defaultMatches","matches","setMatches","React","useState","handleChange","useCallback","event","useEffect","mediaQuery","window","matchMedia","addEventListener","removeEventListener"],"mappings":";;MAEaA,aAAa,GAAG,CAACC,KAAa,EAAEC,cAAc,GAAG,KAAK;EAC/D,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAUJ,cAAc,CAAC;EAErE,MAAMK,YAAY,GAAGF,cAAK,CAACG,WAAW,CAAEC,KAA2C,IAAKL,UAAU,CAACK,KAAK,CAACN,OAAO,CAAC,EAAE,EAAE,CAAC;EAEtHE,cAAK,CAACK,SAAS,CAAC;IACZ,MAAMC,UAAU,GAAGC,MAAM,CAACC,UAAU,CAACZ,KAAK,CAAC;IAC3CG,UAAU,CAACO,UAAU,CAACR,OAAO,CAAC;IAC9BQ,UAAU,CAACG,gBAAgB,CAAC,QAAQ,EAAEP,YAAY,CAAC;IAEnD,OAAO;MACHI,UAAU,CAACI,mBAAmB,CAAC,QAAQ,EAAER,YAAY,CAAC;KACzD;GACJ,EAAE,EAAE,CAAC;EAEN,OAAOJ,OAAO;AAClB;;;;"}
@@ -45,6 +45,8 @@ export { Pagination } from './components/Pagination/Pagination.js';
45
45
  export { Progress } from './components/Progress/Progress.js';
46
46
  export { ToastProvider, useToast } from './components/Toast/Toaster.js';
47
47
  export { Provider } from './components/Provider/Provider.js';
48
+ import * as Collection from './primitives/Collection/Collection.js';
49
+ export { Collection as CollectionPrimitive };
48
50
  export { Tag } from './components/Tag/Tag.js';
49
51
  export { Select2 } from './components/Select2/Select2.js';
50
52
  export { Shortcut } from './components/Shortcut/Shortcut.js';
@@ -54,9 +56,16 @@ export { WindowedTable } from './components/Table/components/WindowedTable.js';
54
56
  export { convertRowIndexPathToNumberArray, getByRowIndexPath, getParentRowIndexPath, setByRowIndexPath } from './components/Table/util/rowIndexPath.js';
55
57
  export { insertChildTableRow, removeChildTableRow, useTableRowCreation } from './components/Table/hooks/useRowCreation.js';
56
58
  export { Switch } from './components/Switch/Switch.js';
59
+ export { useBoundaryOverflowDetection } from './hooks/useBoundaryOverflowDetection.js';
57
60
  export { Table2 } from './components/Table2/Table2.js';
58
61
  export { Tabs } from './components/Tabs/Tabs.js';
59
62
  export { Textarea } from './components/Textarea/Textarea.js';
60
63
  export { Tour, TourStep } from './components/Tour/Tour.js';
64
+ export { Header } from './components/Header/Header.js';
65
+ export { useMatchMedia } from './hooks/useMatchMedia.js';
66
+ export { useIsLargeScreen } from './hooks/useIsLargeScreen.js';
67
+ export { Layout } from './components/Layout/Layout.js';
68
+ export { getNavigationLinkClasses } from './components/Navigation2/components/Link.js';
69
+ export { Navigation2 } from './components/Navigation2/Navigation2.js';
61
70
  export { useOnClickOutside } from './utils/hooks/useOnClickOutside.js';
62
71
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,3 @@
1
+ import { Root } from './components/Root.js';
2
+ export { Root } from './components/Root.js';
3
+ //# sourceMappingURL=Collection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Collection.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -45,7 +45,10 @@ const Root = /*#__PURE__*/React__default.forwardRef(function CollectionRoot(prop
45
45
  if (internalRef.current) {
46
46
  const options = getOptionsFromCollection(internalRef.current, querySelector);
47
47
  if (options.length && options.length !== lastLengthRef.current) {
48
- const selected = internalRef.current.querySelectorAll(`[aria-selected]`);
48
+ let selected = internalRef.current.querySelectorAll(`[aria-current="true"]`);
49
+ if (selected.length === 0) {
50
+ selected = internalRef.current.querySelectorAll(`[aria-selected]`);
51
+ }
49
52
  if (selected.length === 1) {
50
53
  if (options) {
51
54
  const firstSelected = selected.item(0);
@@ -1 +1 @@
1
- {"version":3,"file":"Root.js","sources":["../../../../../../../../src/primitives/Collection/components/Root.tsx"],"sourcesContent":["import React from 'react';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\nimport { isAriaDirectionKey } from '../../../utils/aria';\nimport { createCustomKeyboardEvent } from '../../../utils/input';\n\n/* This component provides a keyboard navigable collection primitive for use in lists\n * It is unlikely you need to edit this component\n */\n\nexport type CollectionProps = React.HTMLAttributes<HTMLDivElement> & {\n querySelector: string;\n};\n\nexport type CollectionRef = HTMLDivElement & {\n setActiveIndex: (option: HTMLDivElement) => void;\n};\n\nconst getOptionsFromCollection = (collection: HTMLDivElement, selector: string): NodeListOf<Element> =>\n collection.querySelectorAll(selector);\n\n// we use javascript to set attributes (rather than cloning children and adding them)\n// so that we can support nesting (e.g. groups) - child elements that aren't options.\n// without doing this we would have to unwrap and flatten all groups\nexport const Root = React.forwardRef<CollectionRef, CollectionProps>(function CollectionRoot(props, ref) {\n const { querySelector, tabIndex = 0, ...otherProps } = props;\n const internalRef = useMergedRef<CollectionRef>(ref);\n const [activeIndex, setActiveIndex] = React.useState<number | undefined>();\n const lastLengthRef = React.useRef(0);\n\n const setActiveOption = (index: number, collection: HTMLDivElement, option: Element) => {\n collection.querySelector(`[aria-current]`)?.removeAttribute('aria-current');\n option.setAttribute('aria-current', 'true');\n option.scrollIntoView({ block: 'nearest' });\n setActiveIndex(index);\n };\n\n const setActiveIndexByElement = React.useCallback(\n (option: HTMLDivElement) => {\n if (internalRef.current) {\n if (option.matches(querySelector)) {\n const options = getOptionsFromCollection(internalRef.current, querySelector);\n const nextActiveIndex = Array.from(options).indexOf(option);\n\n if (nextActiveIndex > -1) {\n setActiveOption(nextActiveIndex, internalRef.current, option);\n }\n }\n }\n },\n [internalRef.current, querySelector]\n );\n\n React.useEffect(() => {\n if (internalRef.current) {\n internalRef.current.setActiveIndex = setActiveIndexByElement;\n }\n }, [internalRef.current]);\n\n React.useEffect(() => {\n if (internalRef.current) {\n const options = getOptionsFromCollection(internalRef.current, querySelector);\n\n if (options.length && options.length !== lastLengthRef.current) {\n const selected = internalRef.current.querySelectorAll(`[aria-selected]`);\n\n if (selected.length === 1) {\n if (options) {\n const firstSelected = selected.item(0);\n const selectedIndex = Array.from(options).indexOf(firstSelected);\n\n if (selectedIndex > -1) {\n setActiveOption(selectedIndex, internalRef.current, firstSelected);\n }\n }\n } else {\n // multiple selected or none selected should go to 0\n setActiveOption(0, internalRef.current, options.item(0));\n }\n }\n\n lastLengthRef.current = options.length;\n }\n }, [props.children]);\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n const option = event.target as HTMLElement;\n\n if (option.matches(querySelector)) {\n const options = getOptionsFromCollection(event.currentTarget, querySelector);\n const nextActiveIndex = Array.from(options).indexOf(option);\n\n if (nextActiveIndex > -1) {\n setActiveOption(nextActiveIndex, event.currentTarget, option);\n }\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n // this stops the event dispatched to the option rebounding back and starting an infinite loop\n if (event.target !== event.currentTarget) {\n return;\n }\n\n if (otherProps.onKeyDown) {\n otherProps.onKeyDown(event);\n }\n\n if (event.isDefaultPrevented()) {\n return;\n }\n\n const options = getOptionsFromCollection(event.currentTarget, querySelector);\n\n if (options) {\n if (isAriaDirectionKey(event)) {\n event.preventDefault();\n event.stopPropagation();\n const nextActiveIndex = getNextEnabledItem(event, options, activeIndex);\n\n if (nextActiveIndex !== undefined && nextActiveIndex !== activeIndex) {\n setActiveOption(nextActiveIndex, event.currentTarget, options.item(nextActiveIndex));\n }\n } else if (activeIndex !== undefined) {\n // forward events onto the underlying option - this lets consumers place onKeyDown handlers on their own components\n options\n .item(activeIndex)\n .dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n }\n }\n };\n\n return <div {...otherProps} onClick={handleClick} onKeyDown={handleKeyDown} ref={internalRef} tabIndex={tabIndex} />;\n});\n\nexport const getNextIndexFromKeycode = (\n event: React.KeyboardEvent,\n length: number,\n activeIndex: number | undefined\n): number | undefined => {\n switch (event.key) {\n case 'ArrowUp':\n return activeIndex === undefined ? length - 1 : activeIndex > 0 ? activeIndex - 1 : activeIndex;\n\n case 'ArrowDown':\n return activeIndex === undefined ? 0 : activeIndex < length - 1 ? activeIndex + 1 : activeIndex;\n\n case 'Home':\n return 0;\n\n case 'End':\n return length - 1;\n\n default:\n return;\n }\n};\n\nexport const getNextEnabledItem = (\n event: React.KeyboardEvent<HTMLElement>,\n options: NodeListOf<Element>,\n activeIndex: number | undefined,\n recurse = true\n): number | undefined => {\n const nextIndex = getNextIndexFromKeycode(event, options.length, activeIndex);\n\n if (nextIndex !== undefined) {\n if (nextIndex === activeIndex) {\n return activeIndex;\n } else if (options.item(nextIndex) && isSkippableItem(options.item(nextIndex))) {\n // check in the other direction if the first or last item is disabled,\n // but prevent infinite loops if all elements are disabled by disabling recursion\n if (recurse) {\n if (nextIndex === 0) {\n return getNextEnabledItem(\n new KeyboardEvent(event.type, { ...(event as any), key: 'ArrowDown' }) as any,\n options,\n nextIndex,\n false\n );\n } else if (nextIndex === options.length - 1) {\n return getNextEnabledItem(\n new KeyboardEvent(event.type, { ...(event as any), key: 'ArrowUp' }) as any,\n options,\n nextIndex,\n false\n );\n }\n }\n\n return getNextEnabledItem(event, options, nextIndex, recurse);\n }\n }\n\n return nextIndex;\n};\n\nconst isSkippableItem = (element: Element) => {\n return (\n element.getAttribute('role') === 'presentation' ||\n !!element.hasAttribute('disabled') ||\n !!element.getAttribute('aria-disabled') ||\n !!element.getAttribute('aria-hidden')\n );\n};\n"],"names":["getOptionsFromCollection","collection","selector","querySelectorAll","Root","React","forwardRef","CollectionRoot","props","ref","querySelector","tabIndex","otherProps","internalRef","useMergedRef","activeIndex","setActiveIndex","useState","lastLengthRef","useRef","setActiveOption","index","option","removeAttribute","setAttribute","scrollIntoView","block","setActiveIndexByElement","useCallback","current","matches","options","nextActiveIndex","Array","from","indexOf","useEffect","length","selected","firstSelected","item","selectedIndex","children","handleClick","event","target","currentTarget","handleKeyDown","onKeyDown","isDefaultPrevented","isAriaDirectionKey","preventDefault","stopPropagation","getNextEnabledItem","undefined","dispatchEvent","createCustomKeyboardEvent","onClick","getNextIndexFromKeycode","key","recurse","nextIndex","isSkippableItem","KeyboardEvent","type","element","getAttribute","hasAttribute"],"mappings":";;;;;AAiBA,MAAMA,wBAAwB,GAAG,CAACC,UAA0B,EAAEC,QAAgB,KAC1ED,UAAU,CAACE,gBAAgB,CAACD,QAAQ,CAAC;AAEzC;AACA;AACA;MACaE,IAAI,gBAAGC,cAAK,CAAC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9B,OAAO,CAACM,MAAM,GAAG,CAAC,EAAE;UACzC,OAAOgB,kBAAkB,CACrB,IAAIU,aAAa,CAACnB,KAAK,CAACoB,IAAI,EAAE;YAAE,GAAIpB,KAAa;YAAEe,GAAG,EAAE;WAAW,CAAQ,EAC3E5B,OAAO,EACP8B,SAAS,EACT,KAAK,CACR;;;MAIT,OAAOR,kBAAkB,CAACT,KAAK,EAAEb,OAAO,EAAE8B,SAAS,EAAED,OAAO,CAAC;;;EAIrE,OAAOC,SAAS;AACpB;AAEA,MAAMC,eAAe,GAAIG,OAAgB;EACrC,OACIA,OAAO,CAACC,YAAY,CAAC,MAAM,CAAC,KAAK,cAAc,IAC/C,CAAC,CAACD,OAAO,CAACE,YAAY,CAAC,UAAU,CAAC,IAClC,CAAC,CAACF,OAAO,CAACC,YAAY,CAAC,eAAe,CAAC,IACvC,CAAC,CAACD,OAAO,CAACC,YAAY,CAAC,aAAa,CAAC;AAE7C,CAAC;;;;"}
1
+ {"version":3,"file":"Root.js","sources":["../../../../../../../../src/primitives/Collection/components/Root.tsx"],"sourcesContent":["import React from 'react';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\nimport { isAriaDirectionKey } from '../../../utils/aria';\nimport { createCustomKeyboardEvent } from '../../../utils/input';\n\n/* This component provides a keyboard navigable collection primitive for use in lists\n * It is unlikely you need to edit this component\n */\n\nexport type CollectionProps = React.HTMLAttributes<HTMLDivElement> & {\n querySelector: string;\n};\n\nexport type CollectionRef = HTMLDivElement & {\n setActiveIndex: (option: HTMLDivElement) => void;\n};\n\nconst getOptionsFromCollection = (collection: HTMLDivElement, selector: string): NodeListOf<Element> =>\n collection.querySelectorAll(selector);\n\n// we use javascript to set attributes (rather than cloning children and adding them)\n// so that we can support nesting (e.g. groups) - child elements that aren't options.\n// without doing this we would have to unwrap and flatten all groups\nexport const Root = React.forwardRef<CollectionRef, CollectionProps>(function CollectionRoot(props, ref) {\n const { querySelector, tabIndex = 0, ...otherProps } = props;\n const internalRef = useMergedRef<CollectionRef>(ref);\n const [activeIndex, setActiveIndex] = React.useState<number | undefined>();\n const lastLengthRef = React.useRef(0);\n\n const setActiveOption = (index: number, collection: HTMLDivElement, option: Element) => {\n collection.querySelector(`[aria-current]`)?.removeAttribute('aria-current');\n option.setAttribute('aria-current', 'true');\n option.scrollIntoView({ block: 'nearest' });\n setActiveIndex(index);\n };\n\n const setActiveIndexByElement = React.useCallback(\n (option: HTMLDivElement) => {\n if (internalRef.current) {\n if (option.matches(querySelector)) {\n const options = getOptionsFromCollection(internalRef.current, querySelector);\n const nextActiveIndex = Array.from(options).indexOf(option);\n\n if (nextActiveIndex > -1) {\n setActiveOption(nextActiveIndex, internalRef.current, option);\n }\n }\n }\n },\n [internalRef.current, querySelector]\n );\n\n React.useEffect(() => {\n if (internalRef.current) {\n internalRef.current.setActiveIndex = setActiveIndexByElement;\n }\n }, [internalRef.current]);\n\n React.useEffect(() => {\n if (internalRef.current) {\n const options = getOptionsFromCollection(internalRef.current, querySelector);\n\n if (options.length && options.length !== lastLengthRef.current) {\n let selected = internalRef.current.querySelectorAll(`[aria-current=\"true\"]`);\n\n if (selected.length === 0) {\n selected = internalRef.current.querySelectorAll(`[aria-selected]`);\n }\n\n if (selected.length === 1) {\n if (options) {\n const firstSelected = selected.item(0);\n const selectedIndex = Array.from(options).indexOf(firstSelected);\n\n if (selectedIndex > -1) {\n setActiveOption(selectedIndex, internalRef.current, firstSelected);\n }\n }\n } else {\n // multiple selected or none selected should go to 0\n setActiveOption(0, internalRef.current, options.item(0));\n }\n }\n\n lastLengthRef.current = options.length;\n }\n }, [props.children]);\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n const option = event.target as HTMLElement;\n\n if (option.matches(querySelector)) {\n const options = getOptionsFromCollection(event.currentTarget, querySelector);\n const nextActiveIndex = Array.from(options).indexOf(option);\n\n if (nextActiveIndex > -1) {\n setActiveOption(nextActiveIndex, event.currentTarget, option);\n }\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n // this stops the event dispatched to the option rebounding back and starting an infinite loop\n if (event.target !== event.currentTarget) {\n return;\n }\n\n if (otherProps.onKeyDown) {\n otherProps.onKeyDown(event);\n }\n\n if (event.isDefaultPrevented()) {\n return;\n }\n\n const options = getOptionsFromCollection(event.currentTarget, querySelector);\n\n if (options) {\n if (isAriaDirectionKey(event)) {\n event.preventDefault();\n event.stopPropagation();\n const nextActiveIndex = getNextEnabledItem(event, options, activeIndex);\n\n if (nextActiveIndex !== undefined && nextActiveIndex !== activeIndex) {\n setActiveOption(nextActiveIndex, event.currentTarget, options.item(nextActiveIndex));\n }\n } else if (activeIndex !== undefined) {\n // forward events onto the underlying option - this lets consumers place onKeyDown handlers on their own components\n options\n .item(activeIndex)\n .dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n }\n }\n };\n\n return <div {...otherProps} onClick={handleClick} onKeyDown={handleKeyDown} ref={internalRef} tabIndex={tabIndex} />;\n});\n\nexport const getNextIndexFromKeycode = (\n event: React.KeyboardEvent,\n length: number,\n activeIndex: number | undefined\n): number | undefined => {\n switch (event.key) {\n case 'ArrowUp':\n return activeIndex === undefined ? length - 1 : activeIndex > 0 ? activeIndex - 1 : activeIndex;\n\n case 'ArrowDown':\n return activeIndex === undefined ? 0 : activeIndex < length - 1 ? activeIndex + 1 : activeIndex;\n\n case 'Home':\n return 0;\n\n case 'End':\n return length - 1;\n\n default:\n return;\n }\n};\n\nexport const getNextEnabledItem = (\n event: React.KeyboardEvent<HTMLElement>,\n options: NodeListOf<Element>,\n activeIndex: number | undefined,\n recurse = true\n): number | undefined => {\n const nextIndex = getNextIndexFromKeycode(event, options.length, activeIndex);\n\n if (nextIndex !== undefined) {\n if (nextIndex === activeIndex) {\n return activeIndex;\n } else if (options.item(nextIndex) && isSkippableItem(options.item(nextIndex))) {\n // check in the other direction if the first or last item is disabled,\n // but prevent infinite loops if all elements are disabled by disabling recursion\n if (recurse) {\n if (nextIndex === 0) {\n return getNextEnabledItem(\n new KeyboardEvent(event.type, { ...(event as any), key: 'ArrowDown' }) as any,\n options,\n nextIndex,\n false\n );\n } else if (nextIndex === options.length - 1) {\n return getNextEnabledItem(\n new KeyboardEvent(event.type, { ...(event as any), key: 'ArrowUp' }) as any,\n options,\n nextIndex,\n false\n );\n }\n }\n\n return getNextEnabledItem(event, options, nextIndex, recurse);\n }\n }\n\n return nextIndex;\n};\n\nconst isSkippableItem = (element: Element) => {\n return (\n element.getAttribute('role') === 'presentation' ||\n !!element.hasAttribute('disabled') ||\n !!element.getAttribute('aria-disabled') ||\n !!element.getAttribute('aria-hidden')\n );\n};\n"],"names":["getOptionsFromCollection","collection","selector","querySelectorAll","Root","React","forwardRef","CollectionRoot","props","ref","querySelector","tabIndex","otherProps","internalRef","useMergedRef","activeIndex","setActiveIndex","useState","lastLengthRef","useRef","setActiveOption","index","option","removeAttribute","setAttribute","scrollIntoView","block","setActiveIndexByElement","useCallback","current","matches","options","nextActiveIndex","Array","from","indexOf","useEffect","length","selected","firstSelected","item","selectedIndex","children","handleClick","event","target","currentTarget","handleKeyDown","onKeyDown","isDefaultPrevented","isAriaDirectionKey","preventDefault","stopPropagation","getNextEnabledItem","undefined","dispatchEvent","createCustomKeyboardEvent","onClick","getNextIndexFromKeycode","key","recurse","nextIndex","isSkippableItem","KeyboardEvent","type","element","getAttribute","hasAttribute"],"mappings":";;;;;AAiBA,MAAMA,wBAAwB,GAAG,CAACC,UAA0B,EAAEC,QAAgB,KAC1ED,UAAU,CAACE,gBAAgB,CAACD,QAAQ,CAAC;AAEzC;AACA;AACA;MACaE,IAAI,gBAAGC,cAAK,CAACC,UAAU,CAAiC,SAASC,cAAc,CAACC,KAAK,EAAEC,GAAG;EACnG,MAAM;IAAEC,aAAa;IAAEC,QAAQ,GAAG,CAAC;IAAE,GAAGC;GAAY,GAAGJ,KAAK;EAC5D,MAAMK,WAAW,GAAGC,YAAY,CAAgBL,GAAG,CAAC;EACpD,MAAM,CAACM,WA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nB,KAAK,CAACoB,IAAI,EAAE;YAAE,GAAIpB,KAAa;YAAEe,GAAG,EAAE;WAAW,CAAQ,EAC3E5B,OAAO,EACP8B,SAAS,EACT,KAAK,CACR;;;MAIT,OAAOR,kBAAkB,CAACT,KAAK,EAAEb,OAAO,EAAE8B,SAAS,EAAED,OAAO,CAAC;;;EAIrE,OAAOC,SAAS;AACpB;AAEA,MAAMC,eAAe,GAAIG,OAAgB;EACrC,OACIA,OAAO,CAACC,YAAY,CAAC,MAAM,CAAC,KAAK,cAAc,IAC/C,CAAC,CAACD,OAAO,CAACE,YAAY,CAAC,UAAU,CAAC,IAClC,CAAC,CAACF,OAAO,CAACC,YAAY,CAAC,eAAe,CAAC,IACvC,CAAC,CAACD,OAAO,CAACC,YAAY,CAAC,aAAa,CAAC;AAE7C,CAAC;;;;"}
@@ -1,6 +1,7 @@
1
1
  import React__default from 'react';
2
2
  import { useId } from '../../../hooks/useId.js';
3
3
  import { Root as Root$1 } from '../../Collection/components/Root.js';
4
+ import '../../Collection/Collection.js';
4
5
  import { Listbox2Context } from './Context.js';
5
6
 
6
7
  const DEFAULT_SELECTOR = '[role="option"]';
@@ -1 +1 @@
1
- {"version":3,"file":"Root.js","sources":["../../../../../../../../src/primitives/Listbox2/components/Root.tsx"],"sourcesContent":["import React from 'react';\nimport { useId } from '../../../hooks/useId';\nimport * as CollectionPrimitive from '../../Collection/Collection';\nimport { Listbox2Value } from '../types';\nimport { Listbox2Context } from './Context';\n\nexport type Listbox2Props = React.HTMLAttributes<HTMLDivElement> & {\n customSelector?: string;\n disabled?: boolean;\n multiple?: boolean;\n readOnly?: boolean;\n setValue: (value: Listbox2Value) => void;\n value?: Listbox2Value;\n};\n\nconst DEFAULT_SELECTOR = '[role=\"option\"]';\n\nexport const Root = React.forwardRef<CollectionPrimitive.CollectionRef, Listbox2Props>(function Listbox2(props, ref) {\n const {\n children,\n customSelector,\n disabled = false,\n id: nativeId,\n multiple,\n readOnly = false,\n setValue,\n title,\n value,\n ...otherProps\n } = props;\n const id = useId(nativeId);\n\n const context = React.useMemo(\n () => ({\n disabled,\n readOnly,\n setValue,\n value,\n }),\n [disabled, readOnly, value]\n );\n\n return (\n <Listbox2Context.Provider value={context}>\n <div data-taco=\"listbox2\">\n <CollectionPrimitive.Root\n {...otherProps}\n aria-multiselectable={multiple ? true : undefined}\n id={id}\n querySelector={customSelector ? `${DEFAULT_SELECTOR}, ${customSelector}` : DEFAULT_SELECTOR}\n ref={ref}\n role=\"listbox\">\n {children}\n </CollectionPrimitive.Root>\n </div>\n </Listbox2Context.Provider>\n );\n});\n\nexport const createListboxValueSetter =\n (multiple: boolean, setValue: React.Dispatch<React.SetStateAction<Listbox2Value | undefined>>) =>\n (nextValue: Listbox2Value) => {\n setValue(value => {\n if (Array.isArray(nextValue)) {\n return nextValue;\n }\n\n if (multiple) {\n if (value === undefined) {\n return [nextValue];\n } else if (Array.isArray(value)) {\n if (value.includes(nextValue)) {\n return value.filter(v => v !== nextValue);\n }\n\n return [...value, nextValue];\n } else if (value === nextValue) {\n return [];\n }\n\n return [value, nextValue];\n }\n\n return nextValue;\n });\n };\n"],"names":["DEFAULT_SELECTOR","Root","React","forwardRef","Listbox2","props","ref","children","customSelector","disabled","id","nativeId","multiple","readOnly","setValue","title","value","otherProps","useId","context","useMemo","Listbox2Context","Provider","CollectionPrimitive","undefined","querySelector","role","createListboxValueSetter","nextValue","Array","isArray","includes","filter","v"],"mappings":";;;;;AAeA,MAAMA,gBAAgB,GAAG,iBAAiB;MAE7BC,IAAI,gBAAGC,cAAK,CAACC,UAAU,CAAmD,SAASC,QAAQ,CAACC,KAAK,EAAEC,GAAG;EAC/G,MAAM;IACFC,QAAQ;IACRC,cAAc;IACdC,QAAQ,GAAG,KAAK;IAChBC,EAAE,EAAEC,QAAQ;IACZC,QAAQ;IACRC,QAAQ,GAAG,KAAK;IAChBC,QAAQ;IACRC,KAAK;IACLC,KAAK;IACL,GAAGC;GACN,GAAGZ,KAAK;EACT,MAAMK,EA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+ {"version":3,"file":"Root.js","sources":["../../../../../../../../src/primitives/Listbox2/components/Root.tsx"],"sourcesContent":["import React from 'react';\nimport { useId } from '../../../hooks/useId';\nimport * as CollectionPrimitive from '../../Collection/Collection';\nimport { Listbox2Value } from '../types';\nimport { Listbox2Context } from './Context';\n\nexport type Listbox2Props = React.HTMLAttributes<HTMLDivElement> & {\n customSelector?: string;\n disabled?: boolean;\n multiple?: boolean;\n readOnly?: boolean;\n setValue: (value: Listbox2Value) => void;\n value?: Listbox2Value;\n};\n\nconst DEFAULT_SELECTOR = '[role=\"option\"]';\n\nexport const Root = React.forwardRef<CollectionPrimitive.CollectionRef, Listbox2Props>(function Listbox2(props, ref) {\n const {\n children,\n customSelector,\n disabled = false,\n id: nativeId,\n multiple,\n readOnly = false,\n setValue,\n title,\n value,\n ...otherProps\n } = props;\n const id = useId(nativeId);\n\n const context = React.useMemo(\n () => ({\n disabled,\n readOnly,\n setValue,\n value,\n }),\n [disabled, readOnly, value]\n );\n\n return (\n <Listbox2Context.Provider value={context}>\n <div data-taco=\"listbox2\">\n <CollectionPrimitive.Root\n {...otherProps}\n aria-multiselectable={multiple ? true : undefined}\n id={id}\n querySelector={customSelector ? `${DEFAULT_SELECTOR}, ${customSelector}` : DEFAULT_SELECTOR}\n ref={ref}\n role=\"listbox\">\n {children}\n </CollectionPrimitive.Root>\n </div>\n </Listbox2Context.Provider>\n );\n});\n\nexport const createListboxValueSetter =\n (multiple: boolean, setValue: React.Dispatch<React.SetStateAction<Listbox2Value | undefined>>) =>\n (nextValue: Listbox2Value) => {\n setValue(value => {\n if (Array.isArray(nextValue)) {\n return nextValue;\n }\n\n if (multiple) {\n if (value === undefined) {\n return [nextValue];\n } else if (Array.isArray(value)) {\n if (value.includes(nextValue)) {\n return value.filter(v => v !== nextValue);\n }\n\n return [...value, nextValue];\n } else if (value === nextValue) {\n return [];\n }\n\n return [value, nextValue];\n }\n\n return nextValue;\n });\n };\n"],"names":["DEFAULT_SELECTOR","Root","React","forwardRef","Listbox2","props","ref","children","customSelector","disabled","id","nativeId","multiple","readOnly","setValue","title","value","otherProps","useId","context","useMemo","Listbox2Context","Provider","CollectionPrimitive","undefined","querySelector","role","createListboxValueSetter","nextValue","Array","isArray","includes","filter","v"],"mappings":";;;;;;AAeA,MAAMA,gBAAgB,GAAG,iBAAiB;MAE7BC,IAAI,gBAAGC,cAAK,CAACC,UAAU,CAAmD,SAASC,QAAQ,CAACC,KAAK,EAAEC,GAAG;EAC/G,MAAM;IACFC,QAAQ;IACRC,cAAc;IACdC,QAAQ,GAAG,KAAK;IAChBC,EAAE,EAAEC,QAAQ;IACZC,QAAQ;IACRC,QAAQ,GAAG,KAAK;IAChBC,QAAQ;IACRC,KAAK;IACLC,KAAK;IACL,GAAGC;GACN,GAAGZ,KAAK;EACT,MAAMK,EAAE,GAAGQ,KAAK,CAACP,QAAQ,CAAC;EAE1B,MAAMQ,OAAO,GAAGjB,cAAK,CAACkB,OAAO,CACzB,OAAO;IACHX,QAAQ;IACRI,QAAQ;IACRC,QAAQ;IACRE;GACH,CAAC,EACF,CAACP,QAAQ,EAAEI,QAAQ,EAAEG,KAAK,CAAC,CAC9B;EAED,oBACId,6BAACmB,eAAe,CAACC,QAAQ;IAACN,KAAK,EAAEG;kBAC7BjB;iBAAe;kBACXA,6BAACqB,MAAwB,oBACjBN,UAAU;4BACQL,QAAQ,GAAG,IAAI,GAAGY,SAAS;IACjDd,EAAE,EAAEA,EAAE;IACNe,aAAa,EAAEjB,cAAc,MAAMR,qBAAqBQ,gBAAgB,GAAGR,gBAAgB;IAC3FM,GAAG,EAAEA,GAAG;IACRoB,IAAI,EAAC;MACJnB,QAAQ,CACc,CACzB,CACiB;AAEnC,CAAC;MAEYoB,wBAAwB,GACjC,CAACf,QAAiB,EAAEE,QAAyE,KAC5Fc,SAAwB;EACrBd,QAAQ,CAACE,KAAK;IACV,IAAIa,KAAK,CAACC,OAAO,CAACF,SAAS,CAAC,EAAE;MAC1B,OAAOA,SAAS;;IAGpB,IAAIhB,QAAQ,EAAE;MACV,IAAII,KAAK,KAAKQ,SAAS,EAAE;QACrB,OAAO,CAACI,SAAS,CAAC;OACrB,MAAM,IAAIC,KAAK,CAACC,OAAO,CAACd,KAAK,CAAC,EAAE;QAC7B,IAAIA,KAAK,CAACe,QAAQ,CAACH,SAAS,CAAC,EAAE;UAC3B,OAAOZ,KAAK,CAACgB,MAAM,CAACC,CAAC,IAAIA,CAAC,KAAKL,SAAS,CAAC;;QAG7C,OAAO,CAAC,GAAGZ,KAAK,EAAEY,SAAS,CAAC;OAC/B,MAAM,IAAIZ,KAAK,KAAKY,SAAS,EAAE;QAC5B,OAAO,EAAE;;MAGb,OAAO,CAACZ,KAAK,EAAEY,SAAS,CAAC;;IAG7B,OAAOA,SAAS;GACnB,CAAC;AACN;;;;"}
@@ -0,0 +1 @@
1
+ export declare const useIsLargeScreen: () => boolean;
@@ -0,0 +1 @@
1
+ export declare const useMatchMedia: (query: string, defaultMatches?: boolean) => boolean;
package/dist/index.d.ts CHANGED
@@ -46,9 +46,16 @@ export * from './components/Tooltip/Tooltip';
46
46
  export * from './components/Tour/Tour';
47
47
  export * from './components/Treeview/Treeview';
48
48
  export * from './components/VisuallyHidden/VisuallyHidden';
49
+ export * from './components/Header/Header';
50
+ export * from './components/Layout/Layout';
51
+ export * from './components/Navigation2/Navigation2';
52
+ export * as CollectionPrimitive from './primitives/Collection/Collection';
49
53
  export * from './utils/date';
50
54
  export * from './utils/mergeRefs';
55
+ export * from './hooks/useBoundaryOverflowDetection';
51
56
  export * from './hooks/useBoundingClientRectListener';
57
+ export * from './hooks/useIsLargeScreen';
58
+ export * from './hooks/useMatchMedia';
52
59
  export * from './hooks/useMergedRef';
53
60
  export * from './utils/hooks/useDropTarget';
54
61
  export * from './utils/hooks/useListKeyboardNavigation';