@dbcdk/react-components 0.0.103 → 0.0.105

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 (357) hide show
  1. package/dist/assets/logo.cjs +87 -0
  2. package/dist/assets/logo.js +85 -0
  3. package/dist/client.cjs +587 -0
  4. package/dist/client.d.ts +83 -0
  5. package/dist/client.js +84 -0
  6. package/dist/components/accordion/Accordion.cjs +117 -0
  7. package/dist/components/accordion/Accordion.d.ts +5 -2
  8. package/dist/components/accordion/Accordion.js +111 -0
  9. package/dist/components/accordion/Accordion.module.css +41 -0
  10. package/dist/components/accordion/components/AccordionRow.cjs +120 -0
  11. package/dist/components/accordion/components/AccordionRow.js +114 -0
  12. package/dist/components/accordion/components/AccordionRow.module.css +133 -0
  13. package/dist/components/alert/Alert.cjs +52 -0
  14. package/dist/components/alert/Alert.d.ts +2 -1
  15. package/dist/components/alert/Alert.js +46 -0
  16. package/dist/components/alert/Alert.module.css +97 -0
  17. package/dist/components/app-header/AppHeader.cjs +14 -0
  18. package/dist/components/app-header/AppHeader.js +8 -0
  19. package/dist/components/app-header/AppHeader.module.css +74 -0
  20. package/dist/components/attribute-chip/AttributeChip.cjs +22 -0
  21. package/dist/components/attribute-chip/AttributeChip.js +16 -0
  22. package/dist/components/attribute-chip/AttributeChip.module.css +65 -0
  23. package/dist/components/avatar/Avatar.cjs +111 -0
  24. package/dist/components/avatar/Avatar.js +86 -0
  25. package/dist/components/avatar/Avatar.module.css +91 -0
  26. package/dist/components/breadcrumbs/Breadcrumbs.cjs +24 -0
  27. package/dist/components/breadcrumbs/Breadcrumbs.js +18 -0
  28. package/dist/components/breadcrumbs/Breadcrumbs.module.css +80 -0
  29. package/dist/components/button/Button.cjs +149 -0
  30. package/dist/components/button/Button.js +124 -0
  31. package/dist/components/button/Button.module.css +260 -0
  32. package/dist/components/button-select/ButtonSelect.cjs +35 -0
  33. package/dist/components/button-select/ButtonSelect.js +29 -0
  34. package/dist/components/button-select/ButtonSelect.module.css +40 -0
  35. package/dist/components/card/Card.cjs +112 -0
  36. package/dist/components/card/Card.d.ts +2 -1
  37. package/dist/components/card/Card.js +106 -0
  38. package/dist/components/card/Card.module.css +187 -0
  39. package/dist/components/card/components/CardMeta.cjs +62 -0
  40. package/dist/components/card/components/CardMeta.js +55 -0
  41. package/dist/components/card/components/CardMeta.module.css +55 -0
  42. package/dist/components/card-container/CardContainer.cjs +34 -0
  43. package/dist/components/card-container/CardContainer.js +28 -0
  44. package/dist/components/card-container/CardContainer.module.css +63 -0
  45. package/dist/components/chip/Chip.cjs +65 -0
  46. package/dist/components/chip/Chip.js +59 -0
  47. package/dist/components/chip/Chip.module.css +236 -0
  48. package/dist/components/circle/Circle.cjs +33 -0
  49. package/dist/components/circle/Circle.js +27 -0
  50. package/dist/components/circle/Circle.module.css +128 -0
  51. package/dist/components/clear-button/ClearButton.cjs +33 -0
  52. package/dist/components/clear-button/ClearButton.d.ts +2 -1
  53. package/dist/components/clear-button/ClearButton.js +27 -0
  54. package/dist/components/clear-button/ClearButton.module.css +26 -0
  55. package/dist/components/code-block/CodeBlock.cjs +97 -0
  56. package/dist/components/code-block/CodeBlock.js +91 -0
  57. package/dist/components/code-block/CodeBlock.module.css +124 -0
  58. package/dist/components/copy-button/CopyButton.cjs +139 -0
  59. package/dist/components/copy-button/CopyButton.js +133 -0
  60. package/dist/components/copy-button/CopyButton.module.css +22 -0
  61. package/dist/components/datetime-picker/DateTimePicker.cjs +559 -0
  62. package/dist/components/datetime-picker/DateTimePicker.js +553 -0
  63. package/dist/components/datetime-picker/DateTimePicker.module.css +155 -0
  64. package/dist/components/datetime-picker/dateTimeHelpers.cjs +179 -0
  65. package/dist/components/datetime-picker/dateTimeHelpers.js +160 -0
  66. package/dist/components/divider/Divider.cjs +22 -0
  67. package/dist/components/divider/Divider.js +20 -0
  68. package/dist/components/filter-field/FilterField.cjs +296 -0
  69. package/dist/components/filter-field/FilterField.js +289 -0
  70. package/dist/components/filter-field/FilterField.module.css +379 -0
  71. package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.cjs +115 -0
  72. package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.js +108 -0
  73. package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.module.css +59 -0
  74. package/dist/components/forms/checkbox/Checkbox.cjs +88 -0
  75. package/dist/components/forms/checkbox/Checkbox.js +82 -0
  76. package/dist/components/forms/checkbox/Checkbox.module.css +104 -0
  77. package/dist/components/forms/checkbox-group/CheckboxGroup.cjs +121 -0
  78. package/dist/components/forms/checkbox-group/CheckboxGroup.js +115 -0
  79. package/dist/components/forms/checkbox-group/CheckboxGroup.module.css +115 -0
  80. package/dist/components/forms/form-select/FormSelect.cjs +191 -0
  81. package/dist/components/forms/form-select/FormSelect.js +166 -0
  82. package/dist/components/forms/form-select/FormSelect.module.css +236 -0
  83. package/dist/components/forms/input/Input.cjs +188 -0
  84. package/dist/components/forms/input/Input.d.ts +1 -0
  85. package/dist/components/forms/input/Input.js +182 -0
  86. package/dist/components/forms/input/Input.module.css +468 -0
  87. package/dist/components/forms/input-container/InputContainer.cjs +72 -0
  88. package/dist/components/forms/input-container/InputContainer.js +66 -0
  89. package/dist/components/forms/input-container/InputContainer.module.css +59 -0
  90. package/dist/components/forms/multi-select/MultiSelect.cjs +227 -0
  91. package/dist/components/forms/multi-select/MultiSelect.js +225 -0
  92. package/dist/components/forms/radio-buttons/RadioButton.cjs +91 -0
  93. package/dist/components/forms/radio-buttons/RadioButton.js +85 -0
  94. package/dist/components/forms/radio-buttons/RadioButtonGroup.cjs +74 -0
  95. package/dist/components/forms/radio-buttons/RadioButtonGroup.js +72 -0
  96. package/dist/components/forms/radio-buttons/RadioButtons.module.css +118 -0
  97. package/dist/components/forms/select/Select.cjs +286 -0
  98. package/dist/components/forms/select/Select.js +280 -0
  99. package/dist/components/forms/select/Select.module.css +32 -0
  100. package/dist/components/forms/text-area/Textarea.cjs +116 -0
  101. package/dist/components/forms/text-area/Textarea.js +110 -0
  102. package/dist/components/forms/text-area/Textarea.module.css +70 -0
  103. package/dist/components/forms/typeahead/Typeahead.cjs +792 -0
  104. package/dist/components/forms/typeahead/Typeahead.js +768 -0
  105. package/dist/components/forms/typeahead/Typeahead.module.css +38 -0
  106. package/dist/components/grid/Grid.cjs +45 -0
  107. package/dist/components/grid/Grid.js +38 -0
  108. package/dist/components/grid/Grid.module.css +35 -0
  109. package/dist/components/headline/CollapsibleHeadline.cjs +89 -0
  110. package/dist/components/headline/CollapsibleHeadline.d.ts +4 -4
  111. package/dist/components/headline/CollapsibleHeadline.js +83 -0
  112. package/dist/components/headline/Headline.cjs +59 -0
  113. package/dist/components/headline/Headline.js +53 -0
  114. package/dist/components/headline/Headline.module.css +185 -0
  115. package/dist/components/hyperlink/Hyperlink.cjs +107 -0
  116. package/dist/components/hyperlink/Hyperlink.js +82 -0
  117. package/dist/components/hyperlink/Hyperlink.module.css +121 -0
  118. package/dist/components/icon/Icon.cjs +27 -0
  119. package/dist/components/icon/Icon.js +20 -0
  120. package/dist/components/icon/Icon.module.css +36 -0
  121. package/dist/components/inline-status/InlineStatus.cjs +39 -0
  122. package/dist/components/inline-status/InlineStatus.js +33 -0
  123. package/dist/components/inline-status/InlineStatus.module.css +92 -0
  124. package/dist/components/interval-select/IntervalSelect.cjs +203 -0
  125. package/dist/components/interval-select/IntervalSelect.js +201 -0
  126. package/dist/components/json-viewer/HighlightedText.cjs +13 -0
  127. package/dist/components/json-viewer/HighlightedText.js +11 -0
  128. package/dist/components/json-viewer/JsonNode.cjs +124 -0
  129. package/dist/components/json-viewer/JsonNode.js +118 -0
  130. package/dist/components/json-viewer/JsonViewer.cjs +164 -0
  131. package/dist/components/json-viewer/JsonViewer.js +158 -0
  132. package/dist/components/json-viewer/JsonViewer.module.css +346 -0
  133. package/dist/components/json-viewer/types.cjs +2 -0
  134. package/dist/components/json-viewer/types.js +1 -0
  135. package/dist/components/json-viewer/useClipboardStatus.cjs +15 -0
  136. package/dist/components/json-viewer/useClipboardStatus.js +13 -0
  137. package/dist/components/json-viewer/utils.cjs +126 -0
  138. package/dist/components/json-viewer/utils.js +111 -0
  139. package/dist/components/media-card/MediaCard.cjs +60 -0
  140. package/dist/components/media-card/MediaCard.d.ts +19 -0
  141. package/dist/components/media-card/MediaCard.js +54 -0
  142. package/dist/components/media-card/MediaCard.module.css +92 -0
  143. package/dist/components/menu/Menu.cjs +287 -0
  144. package/dist/components/menu/Menu.js +262 -0
  145. package/dist/components/menu/Menu.module.css +220 -0
  146. package/dist/components/meta-bar/MetaBar.cjs +28 -0
  147. package/dist/components/meta-bar/MetaBar.js +22 -0
  148. package/dist/components/meta-bar/MetaBar.module.css +27 -0
  149. package/dist/components/nav-bar/NavBar.cjs +104 -0
  150. package/dist/components/nav-bar/NavBar.d.ts +4 -3
  151. package/dist/components/nav-bar/NavBar.js +98 -0
  152. package/dist/components/nav-bar/NavBar.module.css +225 -0
  153. package/dist/components/overlay/fade-overlay/FadeOverlay.cjs +30 -0
  154. package/dist/components/overlay/fade-overlay/FadeOverlay.js +24 -0
  155. package/dist/components/overlay/fade-overlay/FadeOverlay.module.css +54 -0
  156. package/dist/components/overlay/modal/Modal.cjs +189 -0
  157. package/dist/components/overlay/modal/Modal.d.ts +2 -1
  158. package/dist/components/overlay/modal/Modal.js +183 -0
  159. package/dist/components/overlay/modal/Modal.module.css +112 -0
  160. package/dist/components/overlay/modal/provider/ModalProvider.cjs +98 -0
  161. package/dist/components/overlay/modal/provider/ModalProvider.js +95 -0
  162. package/dist/components/overlay/side-panel/SidePanel.cjs +173 -0
  163. package/dist/components/overlay/side-panel/SidePanel.js +167 -0
  164. package/dist/components/overlay/side-panel/SidePanel.module.css +177 -0
  165. package/dist/components/overlay/side-panel/useSidePanel.cjs +16 -0
  166. package/dist/components/overlay/side-panel/useSidePanel.js +14 -0
  167. package/dist/components/overlay/tooltip/Tooltip.cjs +34 -0
  168. package/dist/components/overlay/tooltip/Tooltip.js +32 -0
  169. package/dist/components/overlay/tooltip/Tooltip.module.css +104 -0
  170. package/dist/components/overlay/tooltip/TooltipProvider.cjs +238 -0
  171. package/dist/components/overlay/tooltip/TooltipProvider.js +231 -0
  172. package/dist/components/overlay/tooltip/useTooltipTrigger.cjs +117 -0
  173. package/dist/components/overlay/tooltip/useTooltipTrigger.js +115 -0
  174. package/dist/components/page/Page.cjs +63 -0
  175. package/dist/components/page/Page.js +57 -0
  176. package/dist/components/page/Page.module.css +95 -0
  177. package/dist/components/page-layout/PageLayout.cjs +97 -0
  178. package/dist/components/page-layout/PageLayout.d.ts +0 -5
  179. package/dist/components/page-layout/PageLayout.js +91 -0
  180. package/dist/components/page-layout/PageLayout.module.css +236 -0
  181. package/dist/components/page-layout/components/footer/Footer.cjs +53 -0
  182. package/dist/components/page-layout/components/footer/Footer.js +47 -0
  183. package/dist/components/page-layout/components/footer/Footer.module.css +89 -0
  184. package/dist/components/pagination/Pagination.cjs +160 -0
  185. package/dist/components/pagination/Pagination.js +154 -0
  186. package/dist/components/pagination/Pagination.module.css +25 -0
  187. package/dist/components/panel/Panel.cjs +38 -0
  188. package/dist/components/panel/Panel.js +32 -0
  189. package/dist/components/panel/Panel.module.css +30 -0
  190. package/dist/components/popover/Popover.cjs +331 -0
  191. package/dist/components/popover/Popover.js +307 -0
  192. package/dist/components/popover/Popover.module.css +52 -0
  193. package/dist/components/search-box/SearchBox.cjs +274 -0
  194. package/dist/components/search-box/SearchBox.js +268 -0
  195. package/dist/components/search-box/SearchBox.module.css +27 -0
  196. package/dist/components/segmented-progress-bar/SegmentedProgressBar.cjs +127 -0
  197. package/dist/components/segmented-progress-bar/SegmentedProgressBar.js +121 -0
  198. package/dist/components/segmented-progress-bar/SegmentedProgressBar.module.css +174 -0
  199. package/dist/components/sidebar/Sidebar.cjs +39 -0
  200. package/dist/components/sidebar/Sidebar.js +37 -0
  201. package/dist/components/sidebar/components/SidebarItem.cjs +29 -0
  202. package/dist/components/sidebar/components/SidebarItem.js +27 -0
  203. package/dist/components/sidebar/components/SidebarItem.module.css +0 -0
  204. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.cjs +133 -0
  205. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.js +127 -0
  206. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.module.css +29 -0
  207. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.cjs +214 -0
  208. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.js +207 -0
  209. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.module.css +260 -0
  210. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.cjs +54 -0
  211. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.js +47 -0
  212. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.module.css +106 -0
  213. package/dist/components/sidebar/components/sidebar-items/SidebarItems.cjs +61 -0
  214. package/dist/components/sidebar/components/sidebar-items/SidebarItems.js +55 -0
  215. package/dist/components/sidebar/components/sidebar-items/SidebarItems.module.css +20 -0
  216. package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.cjs +97 -0
  217. package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.js +91 -0
  218. package/dist/components/sidebar/providers/SidebarProvider.cjs +223 -0
  219. package/dist/components/sidebar/providers/SidebarProvider.js +220 -0
  220. package/dist/components/skeleton-loader/SkeletonLoader.cjs +442 -0
  221. package/dist/components/skeleton-loader/SkeletonLoader.js +440 -0
  222. package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.cjs +42 -0
  223. package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.js +36 -0
  224. package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.module.css +51 -0
  225. package/dist/components/split-button/SplitButton.cjs +46 -0
  226. package/dist/components/split-button/SplitButton.js +40 -0
  227. package/dist/components/split-button/SplitButton.module.css +32 -0
  228. package/dist/components/split-pane/SplitPane.cjs +188 -0
  229. package/dist/components/split-pane/SplitPane.d.ts +2 -1
  230. package/dist/components/split-pane/SplitPane.js +179 -0
  231. package/dist/components/split-pane/SplitPane.module.css +118 -0
  232. package/dist/components/split-pane/provider/SplitPaneContext.cjs +129 -0
  233. package/dist/components/split-pane/provider/SplitPaneContext.js +121 -0
  234. package/dist/components/stack/Stack.cjs +47 -0
  235. package/dist/components/stack/Stack.d.ts +1 -1
  236. package/dist/components/stack/Stack.js +41 -0
  237. package/dist/components/stack/Stack.module.css +61 -0
  238. package/dist/components/state-page/StatePage.cjs +48 -0
  239. package/dist/components/state-page/StatePage.js +42 -0
  240. package/dist/components/state-page/StatePage.module.css +9 -0
  241. package/dist/components/state-page/empty.cjs +664 -0
  242. package/dist/components/state-page/empty.js +662 -0
  243. package/dist/components/state-page/error.cjs +310 -0
  244. package/dist/components/state-page/error.js +308 -0
  245. package/dist/components/state-page/notFound.cjs +243 -0
  246. package/dist/components/state-page/notFound.js +241 -0
  247. package/dist/components/sticky-footer-layout/StickyFooterLayout.cjs +98 -0
  248. package/dist/components/sticky-footer-layout/StickyFooterLayout.js +96 -0
  249. package/dist/components/table/Table.cjs +216 -0
  250. package/dist/components/table/Table.js +210 -0
  251. package/dist/components/table/Table.module.css +534 -0
  252. package/dist/components/table/Table.types.cjs +2 -0
  253. package/dist/components/table/Table.types.js +1 -0
  254. package/dist/components/table/TanstackTable.cjs +172 -0
  255. package/dist/components/table/TanstackTable.js +147 -0
  256. package/dist/components/table/components/TableBody.cjs +50 -0
  257. package/dist/components/table/components/TableBody.js +44 -0
  258. package/dist/components/table/components/TableHeader.cjs +56 -0
  259. package/dist/components/table/components/TableHeader.js +50 -0
  260. package/dist/components/table/components/TableHeaderCell.cjs +69 -0
  261. package/dist/components/table/components/TableHeaderCell.js +63 -0
  262. package/dist/components/table/components/TableLoadingBody.cjs +35 -0
  263. package/dist/components/table/components/TableLoadingBody.js +29 -0
  264. package/dist/components/table/components/TablePagination.cjs +2 -0
  265. package/dist/components/table/components/TablePagination.js +1 -0
  266. package/dist/components/table/components/TableRow.cjs +151 -0
  267. package/dist/components/table/components/TableRow.js +145 -0
  268. package/dist/components/table/components/TableSelectionCell.cjs +41 -0
  269. package/dist/components/table/components/TableSelectionCell.js +35 -0
  270. package/dist/components/table/components/column-resizer/ColumnResizer.cjs +25 -0
  271. package/dist/components/table/components/column-resizer/ColumnResizer.js +19 -0
  272. package/dist/components/table/components/column-resizer/ColumnResizer.module.css +22 -0
  273. package/dist/components/table/components/empty-state/EmptyState.cjs +33 -0
  274. package/dist/components/table/components/empty-state/EmptyState.js +31 -0
  275. package/dist/components/table/components/empty-state/EmptyState.module.css +4 -0
  276. package/dist/components/table/components/table-settings/TableSettings.cjs +139 -0
  277. package/dist/components/table/components/table-settings/TableSettings.js +137 -0
  278. package/dist/components/table/hooks/useTableRowInteractions.cjs +46 -0
  279. package/dist/components/table/hooks/useTableRowInteractions.js +44 -0
  280. package/dist/components/table/table.classes.cjs +49 -0
  281. package/dist/components/table/table.classes.js +40 -0
  282. package/dist/components/table/table.utils.cjs +57 -0
  283. package/dist/components/table/table.utils.js +45 -0
  284. package/dist/components/table/tanstackTable.utils.cjs +166 -0
  285. package/dist/components/table/tanstackTable.utils.js +159 -0
  286. package/dist/components/tabs/Tabs.cjs +172 -0
  287. package/dist/components/tabs/Tabs.js +166 -0
  288. package/dist/components/tabs/Tabs.module.css +261 -0
  289. package/dist/components/theme-button/ThemeButton.cjs +78 -0
  290. package/dist/components/theme-button/ThemeButton.js +75 -0
  291. package/dist/components/toast/Toast.cjs +68 -0
  292. package/dist/components/toast/Toast.js +62 -0
  293. package/dist/components/toast/Toast.module.css +161 -0
  294. package/dist/components/toast/provider/ToastProvider.cjs +105 -0
  295. package/dist/components/toast/provider/ToastProvider.js +97 -0
  296. package/dist/components/user-display/UserDisplay.cjs +22 -0
  297. package/dist/components/user-display/UserDisplay.js +16 -0
  298. package/dist/components/user-display/UserDisplay.module.css +25 -0
  299. package/dist/constants/chart-colors.cjs +10 -0
  300. package/dist/constants/chart-colors.js +8 -0
  301. package/dist/constants/chart-colors.types.cjs +2 -0
  302. package/dist/constants/chart-colors.types.js +1 -0
  303. package/dist/constants/severity.cjs +30 -0
  304. package/dist/constants/severity.js +26 -0
  305. package/dist/constants/severity.types.cjs +2 -0
  306. package/dist/constants/severity.types.js +1 -0
  307. package/dist/constants/sizes.cjs +11 -0
  308. package/dist/constants/sizes.js +9 -0
  309. package/dist/hooks/useDeviceSize.cjs +35 -0
  310. package/dist/hooks/useDeviceSize.js +33 -0
  311. package/dist/hooks/useListNavigation.cjs +237 -0
  312. package/dist/hooks/useListNavigation.js +235 -0
  313. package/dist/hooks/usePagination.cjs +144 -0
  314. package/dist/hooks/usePagination.js +142 -0
  315. package/dist/hooks/useSorting.cjs +119 -0
  316. package/dist/hooks/useSorting.js +117 -0
  317. package/dist/hooks/useTableData.cjs +53 -0
  318. package/dist/hooks/useTableData.js +51 -0
  319. package/dist/hooks/useTableSelection.cjs +172 -0
  320. package/dist/hooks/useTableSelection.js +170 -0
  321. package/dist/hooks/useTableSettings.cjs +90 -0
  322. package/dist/hooks/useTableSettings.js +87 -0
  323. package/dist/hooks/useTheme.cjs +64 -0
  324. package/dist/hooks/useTheme.js +62 -0
  325. package/dist/hooks/useTimeDuration.cjs +72 -0
  326. package/dist/hooks/useTimeDuration.js +70 -0
  327. package/dist/hooks/useViewportFill.cjs +82 -0
  328. package/dist/hooks/useViewportFill.js +80 -0
  329. package/dist/index.cjs +161 -12908
  330. package/dist/index.css +67 -7357
  331. package/dist/index.d.ts +0 -58
  332. package/dist/index.js +24 -12809
  333. package/dist/styles/animation.cjs +9 -0
  334. package/dist/styles/animation.js +7 -0
  335. package/dist/styles/themes/dbc/colors.css +5 -0
  336. package/dist/styles/themes/types.cjs +2 -0
  337. package/dist/styles/themes/types.js +1 -0
  338. package/dist/tanstack.cjs +18 -2717
  339. package/dist/tanstack.js +3 -2701
  340. package/dist/types/a11y-props.types.cjs +2 -0
  341. package/dist/types/a11y-props.types.js +1 -0
  342. package/dist/types/assets.d.cjs +2 -0
  343. package/dist/types/assets.d.js +1 -0
  344. package/dist/types/css.d.cjs +2 -0
  345. package/dist/types/css.d.js +1 -0
  346. package/dist/types/sizes.types.cjs +2 -0
  347. package/dist/types/sizes.types.js +1 -0
  348. package/dist/utils/arrays/nested-filtering.cjs +40 -0
  349. package/dist/utils/arrays/nested-filtering.js +38 -0
  350. package/dist/utils/date/formatDate.cjs +35 -0
  351. package/dist/utils/date/formatDate.js +33 -0
  352. package/dist/utils/localStorage.utils.cjs +53 -0
  353. package/dist/utils/localStorage.utils.js +49 -0
  354. package/dist/utils/text/get-highlighted-segments.cjs +49 -0
  355. package/dist/utils/text/get-highlighted-segments.js +47 -0
  356. package/package.json +8 -3
  357. package/dist/tanstack.css +0 -1385
@@ -0,0 +1,792 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var React = require('react');
6
+ var Chip = require('../../../components/chip/Chip');
7
+ var Input = require('../../../components/forms/input/Input');
8
+ var Menu = require('../../../components/menu/Menu');
9
+ var Popover = require('../../../components/popover/Popover');
10
+ var styles = require('./Typeahead.module.css');
11
+
12
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
+
14
+ function _interopNamespace(e) {
15
+ if (e && e.__esModule) return e;
16
+ var n = Object.create(null);
17
+ if (e) {
18
+ Object.keys(e).forEach(function (k) {
19
+ if (k !== 'default') {
20
+ var d = Object.getOwnPropertyDescriptor(e, k);
21
+ Object.defineProperty(n, k, d.get ? d : {
22
+ enumerable: true,
23
+ get: function () { return e[k]; }
24
+ });
25
+ }
26
+ });
27
+ }
28
+ n.default = e;
29
+ return Object.freeze(n);
30
+ }
31
+
32
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
33
+ var styles__default = /*#__PURE__*/_interopDefault(styles);
34
+
35
+ function parseLengthToPx(value, referenceFontSize = 16) {
36
+ if (!value) return 0;
37
+ const trimmed = value.trim();
38
+ if (!trimmed) return 0;
39
+ if (trimmed.endsWith("px")) {
40
+ const n2 = Number.parseFloat(trimmed);
41
+ return Number.isFinite(n2) ? n2 : 0;
42
+ }
43
+ if (trimmed.endsWith("rem")) {
44
+ const n2 = Number.parseFloat(trimmed);
45
+ if (!Number.isFinite(n2)) return 0;
46
+ const rootFont = Number.parseFloat(getComputedStyle(document.documentElement).fontSize || "16");
47
+ return n2 * (Number.isFinite(rootFont) ? rootFont : 16);
48
+ }
49
+ if (trimmed.endsWith("em")) {
50
+ const n2 = Number.parseFloat(trimmed);
51
+ return Number.isFinite(n2) ? n2 * referenceFontSize : 0;
52
+ }
53
+ const n = Number.parseFloat(trimmed);
54
+ return Number.isFinite(n) ? n : 0;
55
+ }
56
+ function getOuterWidthWithMargins(element) {
57
+ if (!(element instanceof HTMLElement)) return 0;
58
+ const rect = element.getBoundingClientRect();
59
+ const styles2 = window.getComputedStyle(element);
60
+ const marginLeft = Number.parseFloat(styles2.marginLeft || "0");
61
+ const marginRight = Number.parseFloat(styles2.marginRight || "0");
62
+ return Math.ceil(rect.width + marginLeft + marginRight);
63
+ }
64
+ function getInputFontShorthand(inputStyles) {
65
+ return inputStyles.font || [
66
+ inputStyles.fontStyle,
67
+ inputStyles.fontVariant,
68
+ inputStyles.fontWeight,
69
+ inputStyles.fontStretch,
70
+ inputStyles.fontSize,
71
+ inputStyles.lineHeight !== "normal" ? `/${inputStyles.lineHeight}` : "",
72
+ inputStyles.fontFamily
73
+ ].filter(Boolean).join(" ");
74
+ }
75
+ function measureFitContentWidth(input, text, minWidth) {
76
+ const field = input.closest('[data-forminput="field"]');
77
+ if (!field) return null;
78
+ const inputStyles = window.getComputedStyle(input);
79
+ const fieldStyles = window.getComputedStyle(field);
80
+ const canvas = document.createElement("canvas");
81
+ const ctx = canvas.getContext("2d");
82
+ if (!ctx) return null;
83
+ ctx.font = getInputFontShorthand(inputStyles);
84
+ const textWidth = Math.ceil(ctx.measureText(text).width);
85
+ const inputFontSize = Number.parseFloat(inputStyles.fontSize || "16");
86
+ const inputPaddingLeft = Number.parseFloat(inputStyles.paddingLeft || "0");
87
+ const inputPaddingRight = Number.parseFloat(inputStyles.paddingRight || "0");
88
+ const borderLeft = Number.parseFloat(fieldStyles.borderLeftWidth || "0");
89
+ const borderRight = Number.parseFloat(fieldStyles.borderRightWidth || "0");
90
+ const startAdornmentWidth = getOuterWidthWithMargins(
91
+ field.querySelector('[data-input-role="start-adornment"]')
92
+ );
93
+ const endAdornmentWidth = getOuterWidthWithMargins(
94
+ field.querySelector('[data-input-role="end-adornment"]')
95
+ );
96
+ const iconWidth = getOuterWidthWithMargins(field.querySelector('[data-input-role="icon"]'));
97
+ const breathingRoom = 6;
98
+ const nextWidth = Math.ceil(
99
+ borderLeft + borderRight + iconWidth + startAdornmentWidth + inputPaddingLeft + textWidth + breathingRoom + inputPaddingRight + endAdornmentWidth
100
+ );
101
+ return Math.max(parseLengthToPx(minWidth, inputFontSize) || 120, nextWidth);
102
+ }
103
+ function Typeahead({
104
+ options,
105
+ mode = "single",
106
+ multiValueDisplayMode = "chips",
107
+ multiSelectedValuesDisplayMode = "hidden",
108
+ multiSelectedValueChipContent = "label",
109
+ selectedValue = null,
110
+ onChange,
111
+ placeholder,
112
+ variant = "outlined",
113
+ disabled = false,
114
+ fullWidth = false,
115
+ onClear,
116
+ emptyMessage = "Ingen resultater",
117
+ filterOptions,
118
+ inputProps,
119
+ inputSize,
120
+ width,
121
+ minWidth,
122
+ popoverWidth,
123
+ autoComplete,
124
+ autoCorrect,
125
+ autoCapitalize,
126
+ spellCheck,
127
+ popoverAnchorRef,
128
+ fitContent = false,
129
+ enableHotkey = false
130
+ }) {
131
+ var _a, _b;
132
+ const rootRef = React.useRef(null);
133
+ const triggerWrapperRef = React.useRef(null);
134
+ const inputRef = React.useRef(null);
135
+ const popoverContentRef = React.useRef(null);
136
+ const interactingWithOptionsRef = React.useRef(false);
137
+ const justClearedRef = React.useRef(false);
138
+ const locallyClearedRef = React.useRef(false);
139
+ const listboxId = React.useId();
140
+ const {
141
+ onFocus: inputPropsOnFocus,
142
+ onBlur: inputPropsOnBlur,
143
+ onKeyDown: inputPropsOnKeyDown,
144
+ onMouseDown: inputPropsOnMouseDown,
145
+ onClear: inputPropsOnClear,
146
+ startAdornment: inputPropsStartAdornment,
147
+ endAdornment: inputPropsEndAdornment,
148
+ ...passthroughInputProps
149
+ } = inputProps != null ? inputProps : {};
150
+ const selectedOption = React.useMemo(() => {
151
+ var _a2;
152
+ if (mode === "multi") return null;
153
+ return (_a2 = options.find((option) => option.value === selectedValue)) != null ? _a2 : null;
154
+ }, [options, selectedValue, mode]);
155
+ const selectedOptions = React.useMemo(() => {
156
+ if (mode !== "multi" || !Array.isArray(selectedValue)) return [];
157
+ return options.filter((option) => selectedValue.includes(option.value));
158
+ }, [options, selectedValue, mode]);
159
+ const [open, setOpen] = React.useState(false);
160
+ const [inputValue, setInputValue] = React.useState(
161
+ mode === "multi" ? "" : (_a = selectedOption == null ? void 0 : selectedOption.label) != null ? _a : ""
162
+ );
163
+ const [query, setQuery] = React.useState("");
164
+ const [activeIndex, setActiveIndex] = React.useState(-1);
165
+ const [hideSelectedHighlight, setHideSelectedHighlight] = React.useState(false);
166
+ const clearJustClearedAfterEventCycle = React__namespace.useCallback(() => {
167
+ requestAnimationFrame(() => {
168
+ justClearedRef.current = false;
169
+ });
170
+ }, []);
171
+ const getSelectedValueChipLabel = React__namespace.useCallback(
172
+ (option) => {
173
+ switch (multiSelectedValueChipContent) {
174
+ case "value":
175
+ return String(option.value);
176
+ case "value-label":
177
+ return `${String(option.value)} - ${option.label}`;
178
+ case "label":
179
+ default:
180
+ return option.label;
181
+ }
182
+ },
183
+ [multiSelectedValueChipContent]
184
+ );
185
+ let filteredOptions;
186
+ if (filterOptions) {
187
+ filteredOptions = filterOptions(options, query);
188
+ } else {
189
+ const normalizedQuery = query.trim().toLocaleLowerCase();
190
+ if (!normalizedQuery) {
191
+ filteredOptions = options;
192
+ } else {
193
+ filteredOptions = options.filter(
194
+ (option) => option.label.toLocaleLowerCase().includes(normalizedQuery)
195
+ );
196
+ }
197
+ }
198
+ const commitSelection = React__namespace.useCallback(
199
+ (option) => {
200
+ var _a2, _b2;
201
+ locallyClearedRef.current = false;
202
+ setHideSelectedHighlight(false);
203
+ if (mode === "multi") {
204
+ if (!option) return;
205
+ const nextValues = Array.isArray(selectedValue) ? [...selectedValue] : [];
206
+ const idx = nextValues.indexOf(option.value);
207
+ if (idx > -1) {
208
+ nextValues.splice(idx, 1);
209
+ } else {
210
+ nextValues.push(option.value);
211
+ }
212
+ onChange(nextValues);
213
+ if (filteredOptions.length > 1) {
214
+ return;
215
+ }
216
+ setInputValue("");
217
+ setQuery("");
218
+ return;
219
+ }
220
+ onChange((_a2 = option == null ? void 0 : option.value) != null ? _a2 : null);
221
+ setInputValue((_b2 = option == null ? void 0 : option.label) != null ? _b2 : "");
222
+ setQuery("");
223
+ setOpen(false);
224
+ setActiveIndex(-1);
225
+ },
226
+ [mode, selectedValue, onChange, filteredOptions.length]
227
+ );
228
+ const multiSelectionAdornment = mode === "multi" && selectedOptions.length > 0 ? multiValueDisplayMode === "count" ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: `dbc-muted-text dbc-sm-text ${styles__default.default.countAdornment}`, children: [
229
+ "(",
230
+ selectedOptions.length,
231
+ ")"
232
+ ] }) : (() => {
233
+ const MAX_CHIPS = 2;
234
+ const chipsToShow = selectedOptions.slice(0, MAX_CHIPS);
235
+ const extraCount = selectedOptions.length - MAX_CHIPS;
236
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles__default.default.chipRow, children: [
237
+ chipsToShow.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
238
+ Chip.Chip,
239
+ {
240
+ size: "sm",
241
+ type: "rounded",
242
+ onClose: () => commitSelection(option),
243
+ children: option.label
244
+ },
245
+ option.value
246
+ )),
247
+ extraCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "dbc-muted-text dbc-sm-text dbc-px-xxs", children: [
248
+ "+",
249
+ extraCount
250
+ ] })
251
+ ] });
252
+ })() : void 0;
253
+ const usesCountAdornment = mode === "multi" && multiValueDisplayMode === "count" && selectedOptions.length > 0;
254
+ const resolvedInputSize = (_b = inputSize != null ? inputSize : inputProps == null ? void 0 : inputProps.inputSize) != null ? _b : "md";
255
+ const shouldFitContent = fitContent && mode === "single";
256
+ const [fittedWidthPx, setFittedWidthPx] = React.useState(null);
257
+ const visibleSingleValueText = React.useMemo(() => {
258
+ if (!shouldFitContent) return "";
259
+ return inputValue || (selectedOption == null ? void 0 : selectedOption.label) || placeholder || "";
260
+ }, [shouldFitContent, inputValue, selectedOption, placeholder]);
261
+ React.useLayoutEffect(() => {
262
+ if (!shouldFitContent) return;
263
+ const input = inputRef.current;
264
+ if (!input) return;
265
+ let cancelled = false;
266
+ const frameId = requestAnimationFrame(() => {
267
+ const nextWidth = measureFitContentWidth(input, visibleSingleValueText, minWidth);
268
+ if (!cancelled && nextWidth != null) {
269
+ setFittedWidthPx((current) => current !== nextWidth ? nextWidth : current);
270
+ }
271
+ });
272
+ const fonts = document.fonts;
273
+ if (fonts == null ? void 0 : fonts.ready) {
274
+ void fonts.ready.then(() => {
275
+ if (cancelled) return;
276
+ const liveInput = inputRef.current;
277
+ if (!liveInput) return;
278
+ const nextWidth = measureFitContentWidth(liveInput, visibleSingleValueText, minWidth);
279
+ if (nextWidth != null) {
280
+ setFittedWidthPx((current) => current !== nextWidth ? nextWidth : current);
281
+ }
282
+ });
283
+ }
284
+ return () => {
285
+ cancelled = true;
286
+ cancelAnimationFrame(frameId);
287
+ };
288
+ }, [
289
+ shouldFitContent,
290
+ visibleSingleValueText,
291
+ minWidth,
292
+ inputPropsStartAdornment,
293
+ inputPropsEndAdornment
294
+ ]);
295
+ const measuredRootWidth = React.useMemo(() => {
296
+ if (!shouldFitContent) return void 0;
297
+ if (fittedWidthPx == null) return minWidth != null ? minWidth : "120px";
298
+ return `${fittedWidthPx}px`;
299
+ }, [shouldFitContent, fittedWidthPx, minWidth]);
300
+ const shouldStretchInput = fullWidth || shouldFitContent;
301
+ React.useEffect(() => {
302
+ if (!enableHotkey) return;
303
+ function handleKeyDown2(event) {
304
+ var _a2;
305
+ if (event.key === "k" && (event.metaKey || event.ctrlKey)) {
306
+ event.preventDefault();
307
+ (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
308
+ }
309
+ }
310
+ window.addEventListener("keydown", handleKeyDown2);
311
+ return () => window.removeEventListener("keydown", handleKeyDown2);
312
+ }, [enableHotkey]);
313
+ React.useEffect(() => {
314
+ var _a2;
315
+ if (justClearedRef.current || locallyClearedRef.current) return;
316
+ if (mode === "multi") {
317
+ setInputValue("");
318
+ setQuery("");
319
+ } else {
320
+ setInputValue((_a2 = selectedOption == null ? void 0 : selectedOption.label) != null ? _a2 : "");
321
+ }
322
+ }, [selectedOption, mode]);
323
+ const getSelectedIndex = React__namespace.useCallback(
324
+ (items) => {
325
+ if (items.length === 0) return -1;
326
+ if (locallyClearedRef.current) return 0;
327
+ if (mode === "multi") {
328
+ if (!Array.isArray(selectedValue) || selectedValue.length === 0) return 0;
329
+ const firstSelectedIndex = items.findIndex((option) => selectedValue.includes(option.value));
330
+ return firstSelectedIndex >= 0 ? firstSelectedIndex : 0;
331
+ }
332
+ const singleSelectedIndex = items.findIndex((option) => option.value === selectedValue);
333
+ return singleSelectedIndex >= 0 ? singleSelectedIndex : 0;
334
+ },
335
+ [mode, selectedValue]
336
+ );
337
+ React.useEffect(() => {
338
+ setActiveIndex((current) => {
339
+ if (filteredOptions.length === 0) return -1;
340
+ if (locallyClearedRef.current) return 0;
341
+ if (current < 0) return getSelectedIndex(filteredOptions);
342
+ return Math.min(current, filteredOptions.length - 1);
343
+ });
344
+ }, [filteredOptions, getSelectedIndex]);
345
+ React.useEffect(() => {
346
+ var _a2, _b2;
347
+ if (!open || activeIndex < 0) return;
348
+ const activeEl = (_a2 = document.getElementById(listboxId)) == null ? void 0 : _a2.querySelector(`#${CSS.escape(`${listboxId}-option-${activeIndex}`)}`);
349
+ (_b2 = activeEl == null ? void 0 : activeEl.scrollIntoView) == null ? void 0 : _b2.call(activeEl, { block: "nearest" });
350
+ }, [open, activeIndex, filteredOptions, listboxId]);
351
+ const getFocusableElements = React__namespace.useCallback(() => {
352
+ const selector = [
353
+ "a[href]",
354
+ "button:not([disabled])",
355
+ "input:not([disabled])",
356
+ "select:not([disabled])",
357
+ "textarea:not([disabled])",
358
+ '[tabindex]:not([tabindex="-1"])'
359
+ ].join(",");
360
+ const seen = /* @__PURE__ */ new Set();
361
+ const focusables = [];
362
+ for (const container of [rootRef.current, popoverContentRef.current]) {
363
+ if (!container) continue;
364
+ const elements = container.matches(selector) ? [container] : Array.from(container.querySelectorAll(selector));
365
+ for (const element of elements) {
366
+ if (seen.has(element) || element.getAttribute("aria-hidden") === "true" || element.tabIndex < 0) {
367
+ continue;
368
+ }
369
+ seen.add(element);
370
+ focusables.push(element);
371
+ }
372
+ }
373
+ return focusables;
374
+ }, []);
375
+ const isFocusWithinTypeahead = React__namespace.useCallback((target) => {
376
+ var _a2, _b2;
377
+ if (!(target instanceof Node)) return false;
378
+ return Boolean(((_a2 = rootRef.current) == null ? void 0 : _a2.contains(target)) || ((_b2 = popoverContentRef.current) == null ? void 0 : _b2.contains(target)));
379
+ }, []);
380
+ const handleTabKeyDown = React__namespace.useCallback(
381
+ (event) => {
382
+ var _a2, _b2, _c;
383
+ if (event.key !== "Tab" || !open) return;
384
+ const focusables = getFocusableElements();
385
+ if (focusables.length === 0) return;
386
+ const eventTarget = event.target instanceof HTMLElement ? event.target : document.activeElement;
387
+ const activeElement = eventTarget && focusables.includes(eventTarget) ? eventTarget : (_a2 = document.activeElement) != null ? _a2 : null;
388
+ const activeIndexInScope = activeElement ? focusables.indexOf(activeElement) : -1;
389
+ if (mode === "multi") {
390
+ if (activeIndexInScope === -1) {
391
+ event.preventDefault();
392
+ (_b2 = focusables[0]) == null ? void 0 : _b2.focus();
393
+ return;
394
+ }
395
+ event.preventDefault();
396
+ const nextIndex = event.shiftKey ? (activeIndexInScope - 1 + focusables.length) % focusables.length : (activeIndexInScope + 1) % focusables.length;
397
+ (_c = focusables[nextIndex]) == null ? void 0 : _c.focus();
398
+ return;
399
+ }
400
+ setOpen(false);
401
+ setActiveIndex(-1);
402
+ },
403
+ [open, getFocusableElements, mode]
404
+ );
405
+ const handleInputChange = (nextValue) => {
406
+ if (justClearedRef.current) return;
407
+ locallyClearedRef.current = false;
408
+ setHideSelectedHighlight(false);
409
+ setInputValue(nextValue);
410
+ setQuery(nextValue);
411
+ if (!open) setOpen(true);
412
+ if (mode === "multi") return;
413
+ const exactMatch = options.find((option) => option.label === nextValue);
414
+ if (!exactMatch && selectedValue !== null) {
415
+ onChange(null);
416
+ }
417
+ };
418
+ const handleBlur = (nextFocusedTarget) => {
419
+ if (justClearedRef.current || locallyClearedRef.current) {
420
+ setInputValue("");
421
+ setQuery("");
422
+ setOpen(false);
423
+ setActiveIndex(-1);
424
+ return;
425
+ }
426
+ if (isFocusWithinTypeahead(nextFocusedTarget)) return;
427
+ if (mode === "multi") {
428
+ if (interactingWithOptionsRef.current) {
429
+ interactingWithOptionsRef.current = false;
430
+ setInputValue("");
431
+ setQuery("");
432
+ return;
433
+ }
434
+ setInputValue("");
435
+ setQuery("");
436
+ setOpen(false);
437
+ setActiveIndex(-1);
438
+ return;
439
+ }
440
+ const exactLabelMatch = options.find((option) => option.label === inputValue);
441
+ if (exactLabelMatch) {
442
+ commitSelection(exactLabelMatch);
443
+ return;
444
+ }
445
+ if (selectedOption) {
446
+ setInputValue(selectedOption.label);
447
+ } else {
448
+ setInputValue("");
449
+ }
450
+ setQuery("");
451
+ setOpen(false);
452
+ setActiveIndex(-1);
453
+ };
454
+ const openWithAllOptions = React__namespace.useCallback(() => {
455
+ if (justClearedRef.current) return;
456
+ setQuery("");
457
+ setOpen(true);
458
+ setActiveIndex(getSelectedIndex(options));
459
+ }, [getSelectedIndex, options]);
460
+ const openWithCurrentFilter = React__namespace.useCallback(() => {
461
+ if (justClearedRef.current) return;
462
+ setOpen(true);
463
+ setActiveIndex(getSelectedIndex(filteredOptions));
464
+ }, [getSelectedIndex, filteredOptions]);
465
+ const prepareSingleSearchInput = React__namespace.useCallback(() => {
466
+ if (mode !== "single" || !selectedOption || justClearedRef.current) return;
467
+ setInputValue("");
468
+ setQuery("");
469
+ }, [mode, selectedOption]);
470
+ const handleOpen = React__namespace.useCallback(() => {
471
+ if (justClearedRef.current) return;
472
+ if (mode === "single" && selectedOption && !locallyClearedRef.current) {
473
+ prepareSingleSearchInput();
474
+ openWithAllOptions();
475
+ return;
476
+ }
477
+ openWithCurrentFilter();
478
+ }, [mode, selectedOption, prepareSingleSearchInput, openWithAllOptions, openWithCurrentFilter]);
479
+ const handleTriggerMouseDown = React__namespace.useCallback(
480
+ (e) => {
481
+ var _a2;
482
+ inputPropsOnMouseDown == null ? void 0 : inputPropsOnMouseDown(e);
483
+ if (e.defaultPrevented) return;
484
+ if (justClearedRef.current) {
485
+ e.preventDefault();
486
+ e.stopPropagation();
487
+ return;
488
+ }
489
+ const isAlreadyFocused = document.activeElement === inputRef.current;
490
+ if (isAlreadyFocused && open) {
491
+ e.preventDefault();
492
+ setOpen(false);
493
+ setActiveIndex(-1);
494
+ setQuery("");
495
+ setInputValue(
496
+ mode === "single" && !locallyClearedRef.current ? (_a2 = selectedOption == null ? void 0 : selectedOption.label) != null ? _a2 : "" : ""
497
+ );
498
+ return;
499
+ }
500
+ if (isAlreadyFocused && mode === "single" && selectedOption && !locallyClearedRef.current) {
501
+ prepareSingleSearchInput();
502
+ setOpen(true);
503
+ setActiveIndex(getSelectedIndex(options));
504
+ } else if (isAlreadyFocused && !open) {
505
+ setOpen(true);
506
+ setActiveIndex(getSelectedIndex(filteredOptions));
507
+ }
508
+ },
509
+ [
510
+ inputPropsOnMouseDown,
511
+ open,
512
+ mode,
513
+ selectedOption,
514
+ prepareSingleSearchInput,
515
+ getSelectedIndex,
516
+ options,
517
+ filteredOptions
518
+ ]
519
+ );
520
+ const handleChevronMouseDown = React__namespace.useCallback(
521
+ (e) => {
522
+ var _a2, _b2;
523
+ e.preventDefault();
524
+ e.stopPropagation();
525
+ if (justClearedRef.current) return;
526
+ (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
527
+ if (open) {
528
+ setOpen(false);
529
+ setActiveIndex(-1);
530
+ setQuery("");
531
+ setInputValue(
532
+ mode === "single" && !locallyClearedRef.current ? (_b2 = selectedOption == null ? void 0 : selectedOption.label) != null ? _b2 : "" : ""
533
+ );
534
+ return;
535
+ }
536
+ handleOpen();
537
+ },
538
+ [open, mode, selectedOption, handleOpen]
539
+ );
540
+ const handleKeyDown = (e) => {
541
+ switch (e.key) {
542
+ case "ArrowDown":
543
+ e.preventDefault();
544
+ if (!open) {
545
+ handleOpen();
546
+ return;
547
+ }
548
+ setActiveIndex((index) => {
549
+ if (filteredOptions.length === 0) return -1;
550
+ if (index < 0) return getSelectedIndex(filteredOptions);
551
+ return Math.min(index + 1, filteredOptions.length - 1);
552
+ });
553
+ return;
554
+ case "ArrowUp":
555
+ e.preventDefault();
556
+ if (!open) {
557
+ handleOpen();
558
+ return;
559
+ }
560
+ setActiveIndex((index) => {
561
+ if (filteredOptions.length === 0) return -1;
562
+ if (index < 0) return filteredOptions.length - 1;
563
+ return Math.max(index - 1, 0);
564
+ });
565
+ return;
566
+ case "Home":
567
+ if (!open || filteredOptions.length === 0) return;
568
+ e.preventDefault();
569
+ setActiveIndex(0);
570
+ return;
571
+ case "End":
572
+ if (!open || filteredOptions.length === 0) return;
573
+ e.preventDefault();
574
+ setActiveIndex(filteredOptions.length - 1);
575
+ return;
576
+ case "Enter":
577
+ if (!open) return;
578
+ e.preventDefault();
579
+ if (activeIndex >= 0 && filteredOptions[activeIndex]) {
580
+ commitSelection(filteredOptions[activeIndex]);
581
+ }
582
+ return;
583
+ case "Escape":
584
+ e.preventDefault();
585
+ e.stopPropagation();
586
+ setOpen(false);
587
+ setActiveIndex(-1);
588
+ setQuery("");
589
+ setInputValue(
590
+ mode === "single" && selectedOption && !locallyClearedRef.current ? selectedOption.label : ""
591
+ );
592
+ return;
593
+ }
594
+ };
595
+ return /* @__PURE__ */ jsxRuntime.jsxs(
596
+ "div",
597
+ {
598
+ ref: rootRef,
599
+ style: {
600
+ display: "flex",
601
+ flexDirection: "column",
602
+ gap: mode === "multi" && multiSelectedValuesDisplayMode === "below-input" && selectedOptions.length > 0 ? 8 : 0,
603
+ width: fullWidth ? "100%" : shouldFitContent ? measuredRootWidth : void 0,
604
+ flex: fullWidth || shouldFitContent ? "1 1 auto" : void 0,
605
+ minWidth: shouldFitContent ? measuredRootWidth : 0,
606
+ maxWidth: shouldFitContent ? "100%" : void 0
607
+ },
608
+ children: [
609
+ /* @__PURE__ */ jsxRuntime.jsx(
610
+ Popover.Popover,
611
+ {
612
+ open,
613
+ minWidth: popoverWidth != null ? popoverWidth : minWidth,
614
+ matchTriggerWidth: true,
615
+ fillTrigger: true,
616
+ anchorRef: popoverAnchorRef != null ? popoverAnchorRef : triggerWrapperRef,
617
+ onOpenChange: (nextOpen) => {
618
+ if (justClearedRef.current) {
619
+ setOpen(false);
620
+ setActiveIndex(-1);
621
+ return;
622
+ }
623
+ setOpen(nextOpen);
624
+ if (nextOpen) {
625
+ if (mode === "single" && selectedOption && !locallyClearedRef.current) {
626
+ setQuery("");
627
+ setActiveIndex(getSelectedIndex(options));
628
+ } else {
629
+ setActiveIndex(getSelectedIndex(filteredOptions));
630
+ }
631
+ } else {
632
+ setActiveIndex(-1);
633
+ }
634
+ },
635
+ fullWidth,
636
+ autoFocusContent: false,
637
+ returnFocus: false,
638
+ overlayRef: popoverContentRef,
639
+ trigger: (openPopover, icon) => {
640
+ var _a2, _b2, _c, _d;
641
+ return /* @__PURE__ */ jsxRuntime.jsx(
642
+ "div",
643
+ {
644
+ ref: triggerWrapperRef,
645
+ onMouseDown: (e) => {
646
+ const target = e.target;
647
+ if (justClearedRef.current) {
648
+ e.preventDefault();
649
+ e.stopPropagation();
650
+ return;
651
+ }
652
+ if (target.closest('input, button, [data-input-role="clear"]')) return;
653
+ handleChevronMouseDown(e);
654
+ },
655
+ children: /* @__PURE__ */ jsxRuntime.jsx(
656
+ Input.Input,
657
+ {
658
+ ...passthroughInputProps,
659
+ ref: inputRef,
660
+ value: inputValue,
661
+ startAdornment: multiSelectionAdornment || inputPropsStartAdornment ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
662
+ multiSelectionAdornment,
663
+ inputPropsStartAdornment
664
+ ] }) : void 0,
665
+ endAdornment: inputPropsEndAdornment || icon ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
666
+ inputPropsEndAdornment,
667
+ icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.chevronButton, onMouseDown: handleChevronMouseDown, children: icon }) : null
668
+ ] }) : void 0,
669
+ onFocus: (e) => {
670
+ inputPropsOnFocus == null ? void 0 : inputPropsOnFocus(e);
671
+ if (e.defaultPrevented) return;
672
+ if (justClearedRef.current) return;
673
+ handleOpen();
674
+ openPopover(e);
675
+ },
676
+ onMouseDown: handleTriggerMouseDown,
677
+ onChange: (e) => handleInputChange(e.currentTarget.value),
678
+ onBlur: (e) => {
679
+ inputPropsOnBlur == null ? void 0 : inputPropsOnBlur(e);
680
+ if (e.defaultPrevented) return;
681
+ handleBlur(e.relatedTarget);
682
+ },
683
+ onKeyDown: (e) => {
684
+ inputPropsOnKeyDown == null ? void 0 : inputPropsOnKeyDown(e);
685
+ if (e.defaultPrevented) return;
686
+ handleTabKeyDown(e);
687
+ if (e.defaultPrevented) return;
688
+ handleKeyDown(e);
689
+ },
690
+ placeholder,
691
+ variant,
692
+ inputSize: resolvedInputSize,
693
+ width: shouldFitContent ? void 0 : width != null ? width : inputProps == null ? void 0 : inputProps.width,
694
+ autoComplete: (_a2 = autoComplete != null ? autoComplete : inputProps == null ? void 0 : inputProps.autoComplete) != null ? _a2 : "off",
695
+ autoCorrect: (_b2 = autoCorrect != null ? autoCorrect : inputProps == null ? void 0 : inputProps.autoCorrect) != null ? _b2 : "off",
696
+ autoCapitalize: (_c = autoCapitalize != null ? autoCapitalize : inputProps == null ? void 0 : inputProps.autoCapitalize) != null ? _c : "none",
697
+ spellCheck: (_d = spellCheck != null ? spellCheck : inputProps == null ? void 0 : inputProps.spellCheck) != null ? _d : false,
698
+ disabled,
699
+ fullWidth: shouldStretchInput,
700
+ inputClassName: [
701
+ inputProps == null ? void 0 : inputProps.inputClassName,
702
+ styles__default.default.typeaheadInput,
703
+ usesCountAdornment ? styles__default.default.inputWithoutStartPadding : ""
704
+ ].filter(Boolean).join(" "),
705
+ onClear: (event) => {
706
+ var _a3, _b3;
707
+ (_a3 = event == null ? void 0 : event.preventDefault) == null ? void 0 : _a3.call(event);
708
+ (_b3 = event == null ? void 0 : event.stopPropagation) == null ? void 0 : _b3.call(event);
709
+ justClearedRef.current = true;
710
+ locallyClearedRef.current = true;
711
+ setHideSelectedHighlight(true);
712
+ setOpen(false);
713
+ setInputValue("");
714
+ setQuery("");
715
+ setActiveIndex(-1);
716
+ inputPropsOnClear == null ? void 0 : inputPropsOnClear();
717
+ if (onClear) {
718
+ onClear();
719
+ } else {
720
+ onChange(mode === "multi" ? [] : null);
721
+ }
722
+ clearJustClearedAfterEventCycle();
723
+ },
724
+ role: "combobox",
725
+ "aria-expanded": open,
726
+ "aria-controls": listboxId,
727
+ "aria-autocomplete": "list",
728
+ "aria-activedescendant": open && activeIndex >= 0 ? `${listboxId}-option-${activeIndex}` : void 0
729
+ }
730
+ )
731
+ }
732
+ );
733
+ },
734
+ children: /* @__PURE__ */ jsxRuntime.jsx(Menu.Menu, { role: "listbox", id: listboxId, children: filteredOptions.length > 0 ? filteredOptions.map((option, index) => {
735
+ const isActive = index === activeIndex;
736
+ const isSelected = mode === "multi" ? Array.isArray(selectedValue) && selectedValue.includes(option.value) : option.value === selectedValue && !hideSelectedHighlight;
737
+ const optionId = `${listboxId}-option-${index}`;
738
+ return mode === "multi" ? /* @__PURE__ */ jsxRuntime.jsx(
739
+ Menu.Menu.CheckItem,
740
+ {
741
+ checked: isSelected,
742
+ active: isActive,
743
+ interactiveProps: {
744
+ id: optionId,
745
+ role: "option",
746
+ onMouseEnter: () => setActiveIndex(index),
747
+ onMouseDown: (e) => {
748
+ interactingWithOptionsRef.current = true;
749
+ e.preventDefault();
750
+ },
751
+ onKeyDown: (e) => handleTabKeyDown(e)
752
+ },
753
+ label: /* @__PURE__ */ jsxRuntime.jsx("span", { children: option.label }),
754
+ onCheckedChange: () => commitSelection(option)
755
+ },
756
+ option.value
757
+ ) : /* @__PURE__ */ jsxRuntime.jsx(Menu.Menu.Item, { active: isActive, selected: isSelected, children: /* @__PURE__ */ jsxRuntime.jsx(
758
+ "button",
759
+ {
760
+ id: optionId,
761
+ type: "button",
762
+ role: "option",
763
+ "aria-selected": isSelected,
764
+ onMouseEnter: () => setActiveIndex(index),
765
+ onMouseDown: (e) => {
766
+ e.preventDefault();
767
+ },
768
+ onKeyDown: (e) => handleTabKeyDown(e),
769
+ onClick: () => commitSelection(option),
770
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: option.label })
771
+ }
772
+ ) }, option.value);
773
+ }) : /* @__PURE__ */ jsxRuntime.jsx(Menu.Menu.Item, { disabled: true, children: emptyMessage }) })
774
+ }
775
+ ),
776
+ mode === "multi" && multiSelectedValuesDisplayMode === "below-input" && selectedOptions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles__default.default.selectedValues, children: selectedOptions.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
777
+ Chip.Chip,
778
+ {
779
+ size: "sm",
780
+ type: "default",
781
+ severity: "neutral",
782
+ onClose: () => commitSelection(option),
783
+ children: getSelectedValueChipLabel(option)
784
+ },
785
+ option.value
786
+ )) })
787
+ ]
788
+ }
789
+ );
790
+ }
791
+
792
+ exports.Typeahead = Typeahead;