@dbcdk/react-components 0.0.102 → 0.0.104

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 (355) 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 +103 -0
  7. package/dist/components/accordion/Accordion.js +97 -0
  8. package/dist/components/accordion/Accordion.module.css +41 -0
  9. package/dist/components/accordion/components/AccordionRow.cjs +115 -0
  10. package/dist/components/accordion/components/AccordionRow.js +109 -0
  11. package/dist/components/accordion/components/AccordionRow.module.css +99 -0
  12. package/dist/components/alert/Alert.cjs +52 -0
  13. package/dist/components/alert/Alert.d.ts +2 -1
  14. package/dist/components/alert/Alert.js +46 -0
  15. package/dist/components/alert/Alert.module.css +97 -0
  16. package/dist/components/app-header/AppHeader.cjs +14 -0
  17. package/dist/components/app-header/AppHeader.js +8 -0
  18. package/dist/components/app-header/AppHeader.module.css +74 -0
  19. package/dist/components/attribute-chip/AttributeChip.cjs +22 -0
  20. package/dist/components/attribute-chip/AttributeChip.js +16 -0
  21. package/dist/components/attribute-chip/AttributeChip.module.css +65 -0
  22. package/dist/components/avatar/Avatar.cjs +111 -0
  23. package/dist/components/avatar/Avatar.js +86 -0
  24. package/dist/components/avatar/Avatar.module.css +91 -0
  25. package/dist/components/breadcrumbs/Breadcrumbs.cjs +24 -0
  26. package/dist/components/breadcrumbs/Breadcrumbs.js +18 -0
  27. package/dist/components/breadcrumbs/Breadcrumbs.module.css +80 -0
  28. package/dist/components/button/Button.cjs +149 -0
  29. package/dist/components/button/Button.js +124 -0
  30. package/dist/components/button/Button.module.css +260 -0
  31. package/dist/components/button-select/ButtonSelect.cjs +35 -0
  32. package/dist/components/button-select/ButtonSelect.js +29 -0
  33. package/dist/components/button-select/ButtonSelect.module.css +40 -0
  34. package/dist/components/card/Card.cjs +112 -0
  35. package/dist/components/card/Card.d.ts +2 -1
  36. package/dist/components/card/Card.js +106 -0
  37. package/dist/components/card/Card.module.css +187 -0
  38. package/dist/components/card/components/CardMeta.cjs +62 -0
  39. package/dist/components/card/components/CardMeta.js +55 -0
  40. package/dist/components/card/components/CardMeta.module.css +55 -0
  41. package/dist/components/card-container/CardContainer.cjs +34 -0
  42. package/dist/components/card-container/CardContainer.js +28 -0
  43. package/dist/components/card-container/CardContainer.module.css +63 -0
  44. package/dist/components/chip/Chip.cjs +65 -0
  45. package/dist/components/chip/Chip.js +59 -0
  46. package/dist/components/chip/Chip.module.css +236 -0
  47. package/dist/components/circle/Circle.cjs +33 -0
  48. package/dist/components/circle/Circle.js +27 -0
  49. package/dist/components/circle/Circle.module.css +128 -0
  50. package/dist/components/clear-button/ClearButton.cjs +33 -0
  51. package/dist/components/clear-button/ClearButton.d.ts +2 -1
  52. package/dist/components/clear-button/ClearButton.js +27 -0
  53. package/dist/components/clear-button/ClearButton.module.css +26 -0
  54. package/dist/components/code-block/CodeBlock.cjs +97 -0
  55. package/dist/components/code-block/CodeBlock.js +91 -0
  56. package/dist/components/code-block/CodeBlock.module.css +124 -0
  57. package/dist/components/copy-button/CopyButton.cjs +139 -0
  58. package/dist/components/copy-button/CopyButton.js +133 -0
  59. package/dist/components/copy-button/CopyButton.module.css +22 -0
  60. package/dist/components/datetime-picker/DateTimePicker.cjs +559 -0
  61. package/dist/components/datetime-picker/DateTimePicker.js +553 -0
  62. package/dist/components/datetime-picker/DateTimePicker.module.css +155 -0
  63. package/dist/components/datetime-picker/dateTimeHelpers.cjs +179 -0
  64. package/dist/components/datetime-picker/dateTimeHelpers.js +160 -0
  65. package/dist/components/divider/Divider.cjs +22 -0
  66. package/dist/components/divider/Divider.js +20 -0
  67. package/dist/components/filter-field/FilterField.cjs +296 -0
  68. package/dist/components/filter-field/FilterField.js +289 -0
  69. package/dist/components/filter-field/FilterField.module.css +379 -0
  70. package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.cjs +115 -0
  71. package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.js +108 -0
  72. package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.module.css +59 -0
  73. package/dist/components/forms/checkbox/Checkbox.cjs +88 -0
  74. package/dist/components/forms/checkbox/Checkbox.js +82 -0
  75. package/dist/components/forms/checkbox/Checkbox.module.css +104 -0
  76. package/dist/components/forms/checkbox-group/CheckboxGroup.cjs +121 -0
  77. package/dist/components/forms/checkbox-group/CheckboxGroup.js +115 -0
  78. package/dist/components/forms/checkbox-group/CheckboxGroup.module.css +115 -0
  79. package/dist/components/forms/form-select/FormSelect.cjs +191 -0
  80. package/dist/components/forms/form-select/FormSelect.js +166 -0
  81. package/dist/components/forms/form-select/FormSelect.module.css +236 -0
  82. package/dist/components/forms/input/Input.cjs +188 -0
  83. package/dist/components/forms/input/Input.d.ts +1 -0
  84. package/dist/components/forms/input/Input.js +182 -0
  85. package/dist/components/forms/input/Input.module.css +468 -0
  86. package/dist/components/forms/input-container/InputContainer.cjs +72 -0
  87. package/dist/components/forms/input-container/InputContainer.js +66 -0
  88. package/dist/components/forms/input-container/InputContainer.module.css +59 -0
  89. package/dist/components/forms/multi-select/MultiSelect.cjs +227 -0
  90. package/dist/components/forms/multi-select/MultiSelect.js +225 -0
  91. package/dist/components/forms/radio-buttons/RadioButton.cjs +91 -0
  92. package/dist/components/forms/radio-buttons/RadioButton.js +85 -0
  93. package/dist/components/forms/radio-buttons/RadioButtonGroup.cjs +74 -0
  94. package/dist/components/forms/radio-buttons/RadioButtonGroup.js +72 -0
  95. package/dist/components/forms/radio-buttons/RadioButtons.module.css +118 -0
  96. package/dist/components/forms/select/Select.cjs +286 -0
  97. package/dist/components/forms/select/Select.js +280 -0
  98. package/dist/components/forms/select/Select.module.css +32 -0
  99. package/dist/components/forms/text-area/Textarea.cjs +116 -0
  100. package/dist/components/forms/text-area/Textarea.js +110 -0
  101. package/dist/components/forms/text-area/Textarea.module.css +70 -0
  102. package/dist/components/forms/typeahead/Typeahead.cjs +792 -0
  103. package/dist/components/forms/typeahead/Typeahead.js +768 -0
  104. package/dist/components/forms/typeahead/Typeahead.module.css +38 -0
  105. package/dist/components/grid/Grid.cjs +45 -0
  106. package/dist/components/grid/Grid.js +38 -0
  107. package/dist/components/grid/Grid.module.css +35 -0
  108. package/dist/components/headline/CollapsibleHeadline.cjs +80 -0
  109. package/dist/components/headline/CollapsibleHeadline.js +74 -0
  110. package/dist/components/headline/Headline.cjs +59 -0
  111. package/dist/components/headline/Headline.js +53 -0
  112. package/dist/components/headline/Headline.module.css +185 -0
  113. package/dist/components/hyperlink/Hyperlink.cjs +107 -0
  114. package/dist/components/hyperlink/Hyperlink.d.ts +1 -0
  115. package/dist/components/hyperlink/Hyperlink.js +82 -0
  116. package/dist/components/hyperlink/Hyperlink.module.css +121 -0
  117. package/dist/components/icon/Icon.cjs +27 -0
  118. package/dist/components/icon/Icon.js +20 -0
  119. package/dist/components/icon/Icon.module.css +36 -0
  120. package/dist/components/inline-status/InlineStatus.cjs +39 -0
  121. package/dist/components/inline-status/InlineStatus.js +33 -0
  122. package/dist/components/inline-status/InlineStatus.module.css +92 -0
  123. package/dist/components/interval-select/IntervalSelect.cjs +203 -0
  124. package/dist/components/interval-select/IntervalSelect.js +201 -0
  125. package/dist/components/json-viewer/HighlightedText.cjs +13 -0
  126. package/dist/components/json-viewer/HighlightedText.js +11 -0
  127. package/dist/components/json-viewer/JsonNode.cjs +124 -0
  128. package/dist/components/json-viewer/JsonNode.js +118 -0
  129. package/dist/components/json-viewer/JsonViewer.cjs +164 -0
  130. package/dist/components/json-viewer/JsonViewer.js +158 -0
  131. package/dist/components/json-viewer/JsonViewer.module.css +346 -0
  132. package/dist/components/json-viewer/types.cjs +2 -0
  133. package/dist/components/json-viewer/types.js +1 -0
  134. package/dist/components/json-viewer/useClipboardStatus.cjs +15 -0
  135. package/dist/components/json-viewer/useClipboardStatus.js +13 -0
  136. package/dist/components/json-viewer/utils.cjs +126 -0
  137. package/dist/components/json-viewer/utils.js +111 -0
  138. package/dist/components/media-card/MediaCard.cjs +60 -0
  139. package/dist/components/media-card/MediaCard.d.ts +19 -0
  140. package/dist/components/media-card/MediaCard.js +54 -0
  141. package/dist/components/media-card/MediaCard.module.css +92 -0
  142. package/dist/components/menu/Menu.cjs +287 -0
  143. package/dist/components/menu/Menu.js +262 -0
  144. package/dist/components/menu/Menu.module.css +220 -0
  145. package/dist/components/meta-bar/MetaBar.cjs +28 -0
  146. package/dist/components/meta-bar/MetaBar.js +22 -0
  147. package/dist/components/meta-bar/MetaBar.module.css +27 -0
  148. package/dist/components/nav-bar/NavBar.cjs +95 -0
  149. package/dist/components/nav-bar/NavBar.d.ts +1 -1
  150. package/dist/components/nav-bar/NavBar.js +89 -0
  151. package/dist/components/nav-bar/NavBar.module.css +225 -0
  152. package/dist/components/overlay/fade-overlay/FadeOverlay.cjs +30 -0
  153. package/dist/components/overlay/fade-overlay/FadeOverlay.js +24 -0
  154. package/dist/components/overlay/fade-overlay/FadeOverlay.module.css +54 -0
  155. package/dist/components/overlay/modal/Modal.cjs +189 -0
  156. package/dist/components/overlay/modal/Modal.d.ts +2 -1
  157. package/dist/components/overlay/modal/Modal.js +183 -0
  158. package/dist/components/overlay/modal/Modal.module.css +112 -0
  159. package/dist/components/overlay/modal/provider/ModalProvider.cjs +98 -0
  160. package/dist/components/overlay/modal/provider/ModalProvider.js +95 -0
  161. package/dist/components/overlay/side-panel/SidePanel.cjs +173 -0
  162. package/dist/components/overlay/side-panel/SidePanel.js +167 -0
  163. package/dist/components/overlay/side-panel/SidePanel.module.css +177 -0
  164. package/dist/components/overlay/side-panel/useSidePanel.cjs +16 -0
  165. package/dist/components/overlay/side-panel/useSidePanel.js +14 -0
  166. package/dist/components/overlay/tooltip/Tooltip.cjs +34 -0
  167. package/dist/components/overlay/tooltip/Tooltip.js +32 -0
  168. package/dist/components/overlay/tooltip/Tooltip.module.css +104 -0
  169. package/dist/components/overlay/tooltip/TooltipProvider.cjs +238 -0
  170. package/dist/components/overlay/tooltip/TooltipProvider.js +231 -0
  171. package/dist/components/overlay/tooltip/useTooltipTrigger.cjs +117 -0
  172. package/dist/components/overlay/tooltip/useTooltipTrigger.js +115 -0
  173. package/dist/components/page/Page.cjs +63 -0
  174. package/dist/components/page/Page.js +57 -0
  175. package/dist/components/page/Page.module.css +95 -0
  176. package/dist/components/page-layout/PageLayout.cjs +97 -0
  177. package/dist/components/page-layout/PageLayout.d.ts +0 -5
  178. package/dist/components/page-layout/PageLayout.js +91 -0
  179. package/dist/components/page-layout/PageLayout.module.css +236 -0
  180. package/dist/components/page-layout/components/footer/Footer.cjs +53 -0
  181. package/dist/components/page-layout/components/footer/Footer.js +47 -0
  182. package/dist/components/page-layout/components/footer/Footer.module.css +89 -0
  183. package/dist/components/pagination/Pagination.cjs +160 -0
  184. package/dist/components/pagination/Pagination.js +154 -0
  185. package/dist/components/pagination/Pagination.module.css +25 -0
  186. package/dist/components/panel/Panel.cjs +38 -0
  187. package/dist/components/panel/Panel.js +32 -0
  188. package/dist/components/panel/Panel.module.css +30 -0
  189. package/dist/components/popover/Popover.cjs +331 -0
  190. package/dist/components/popover/Popover.js +307 -0
  191. package/dist/components/popover/Popover.module.css +52 -0
  192. package/dist/components/search-box/SearchBox.cjs +274 -0
  193. package/dist/components/search-box/SearchBox.js +268 -0
  194. package/dist/components/search-box/SearchBox.module.css +27 -0
  195. package/dist/components/segmented-progress-bar/SegmentedProgressBar.cjs +127 -0
  196. package/dist/components/segmented-progress-bar/SegmentedProgressBar.js +121 -0
  197. package/dist/components/segmented-progress-bar/SegmentedProgressBar.module.css +174 -0
  198. package/dist/components/sidebar/Sidebar.cjs +39 -0
  199. package/dist/components/sidebar/Sidebar.js +37 -0
  200. package/dist/components/sidebar/components/SidebarItem.cjs +29 -0
  201. package/dist/components/sidebar/components/SidebarItem.js +27 -0
  202. package/dist/components/sidebar/components/SidebarItem.module.css +0 -0
  203. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.cjs +133 -0
  204. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.js +127 -0
  205. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.module.css +29 -0
  206. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.cjs +214 -0
  207. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.js +207 -0
  208. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.module.css +260 -0
  209. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.cjs +54 -0
  210. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.js +47 -0
  211. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.module.css +106 -0
  212. package/dist/components/sidebar/components/sidebar-items/SidebarItems.cjs +61 -0
  213. package/dist/components/sidebar/components/sidebar-items/SidebarItems.js +55 -0
  214. package/dist/components/sidebar/components/sidebar-items/SidebarItems.module.css +20 -0
  215. package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.cjs +97 -0
  216. package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.js +91 -0
  217. package/dist/components/sidebar/providers/SidebarProvider.cjs +223 -0
  218. package/dist/components/sidebar/providers/SidebarProvider.js +220 -0
  219. package/dist/components/skeleton-loader/SkeletonLoader.cjs +442 -0
  220. package/dist/components/skeleton-loader/SkeletonLoader.js +440 -0
  221. package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.cjs +42 -0
  222. package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.js +36 -0
  223. package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.module.css +51 -0
  224. package/dist/components/split-button/SplitButton.cjs +46 -0
  225. package/dist/components/split-button/SplitButton.js +40 -0
  226. package/dist/components/split-button/SplitButton.module.css +32 -0
  227. package/dist/components/split-pane/SplitPane.cjs +177 -0
  228. package/dist/components/split-pane/SplitPane.js +168 -0
  229. package/dist/components/split-pane/SplitPane.module.css +111 -0
  230. package/dist/components/split-pane/provider/SplitPaneContext.cjs +129 -0
  231. package/dist/components/split-pane/provider/SplitPaneContext.js +121 -0
  232. package/dist/components/stack/Stack.cjs +47 -0
  233. package/dist/components/stack/Stack.d.ts +1 -1
  234. package/dist/components/stack/Stack.js +41 -0
  235. package/dist/components/stack/Stack.module.css +61 -0
  236. package/dist/components/state-page/StatePage.cjs +48 -0
  237. package/dist/components/state-page/StatePage.js +42 -0
  238. package/dist/components/state-page/StatePage.module.css +9 -0
  239. package/dist/components/state-page/empty.cjs +664 -0
  240. package/dist/components/state-page/empty.js +662 -0
  241. package/dist/components/state-page/error.cjs +310 -0
  242. package/dist/components/state-page/error.js +308 -0
  243. package/dist/components/state-page/notFound.cjs +243 -0
  244. package/dist/components/state-page/notFound.js +241 -0
  245. package/dist/components/sticky-footer-layout/StickyFooterLayout.cjs +98 -0
  246. package/dist/components/sticky-footer-layout/StickyFooterLayout.js +96 -0
  247. package/dist/components/table/Table.cjs +216 -0
  248. package/dist/components/table/Table.js +210 -0
  249. package/dist/components/table/Table.module.css +534 -0
  250. package/dist/components/table/Table.types.cjs +2 -0
  251. package/dist/components/table/Table.types.js +1 -0
  252. package/dist/components/table/TanstackTable.cjs +172 -0
  253. package/dist/components/table/TanstackTable.js +147 -0
  254. package/dist/components/table/components/TableBody.cjs +50 -0
  255. package/dist/components/table/components/TableBody.js +44 -0
  256. package/dist/components/table/components/TableHeader.cjs +56 -0
  257. package/dist/components/table/components/TableHeader.js +50 -0
  258. package/dist/components/table/components/TableHeaderCell.cjs +69 -0
  259. package/dist/components/table/components/TableHeaderCell.js +63 -0
  260. package/dist/components/table/components/TableLoadingBody.cjs +35 -0
  261. package/dist/components/table/components/TableLoadingBody.js +29 -0
  262. package/dist/components/table/components/TablePagination.cjs +2 -0
  263. package/dist/components/table/components/TablePagination.js +1 -0
  264. package/dist/components/table/components/TableRow.cjs +151 -0
  265. package/dist/components/table/components/TableRow.js +145 -0
  266. package/dist/components/table/components/TableSelectionCell.cjs +41 -0
  267. package/dist/components/table/components/TableSelectionCell.js +35 -0
  268. package/dist/components/table/components/column-resizer/ColumnResizer.cjs +25 -0
  269. package/dist/components/table/components/column-resizer/ColumnResizer.js +19 -0
  270. package/dist/components/table/components/column-resizer/ColumnResizer.module.css +22 -0
  271. package/dist/components/table/components/empty-state/EmptyState.cjs +33 -0
  272. package/dist/components/table/components/empty-state/EmptyState.js +31 -0
  273. package/dist/components/table/components/empty-state/EmptyState.module.css +4 -0
  274. package/dist/components/table/components/table-settings/TableSettings.cjs +139 -0
  275. package/dist/components/table/components/table-settings/TableSettings.js +137 -0
  276. package/dist/components/table/hooks/useTableRowInteractions.cjs +46 -0
  277. package/dist/components/table/hooks/useTableRowInteractions.js +44 -0
  278. package/dist/components/table/table.classes.cjs +49 -0
  279. package/dist/components/table/table.classes.js +40 -0
  280. package/dist/components/table/table.utils.cjs +57 -0
  281. package/dist/components/table/table.utils.js +45 -0
  282. package/dist/components/table/tanstackTable.utils.cjs +166 -0
  283. package/dist/components/table/tanstackTable.utils.js +159 -0
  284. package/dist/components/tabs/Tabs.cjs +172 -0
  285. package/dist/components/tabs/Tabs.js +166 -0
  286. package/dist/components/tabs/Tabs.module.css +261 -0
  287. package/dist/components/theme-button/ThemeButton.cjs +78 -0
  288. package/dist/components/theme-button/ThemeButton.js +75 -0
  289. package/dist/components/toast/Toast.cjs +68 -0
  290. package/dist/components/toast/Toast.js +62 -0
  291. package/dist/components/toast/Toast.module.css +161 -0
  292. package/dist/components/toast/provider/ToastProvider.cjs +105 -0
  293. package/dist/components/toast/provider/ToastProvider.js +97 -0
  294. package/dist/components/user-display/UserDisplay.cjs +22 -0
  295. package/dist/components/user-display/UserDisplay.js +16 -0
  296. package/dist/components/user-display/UserDisplay.module.css +25 -0
  297. package/dist/constants/chart-colors.cjs +10 -0
  298. package/dist/constants/chart-colors.js +8 -0
  299. package/dist/constants/chart-colors.types.cjs +2 -0
  300. package/dist/constants/chart-colors.types.js +1 -0
  301. package/dist/constants/severity.cjs +30 -0
  302. package/dist/constants/severity.js +26 -0
  303. package/dist/constants/severity.types.cjs +2 -0
  304. package/dist/constants/severity.types.js +1 -0
  305. package/dist/constants/sizes.cjs +11 -0
  306. package/dist/constants/sizes.js +9 -0
  307. package/dist/hooks/useDeviceSize.cjs +35 -0
  308. package/dist/hooks/useDeviceSize.js +33 -0
  309. package/dist/hooks/useListNavigation.cjs +237 -0
  310. package/dist/hooks/useListNavigation.js +235 -0
  311. package/dist/hooks/usePagination.cjs +144 -0
  312. package/dist/hooks/usePagination.js +142 -0
  313. package/dist/hooks/useSorting.cjs +119 -0
  314. package/dist/hooks/useSorting.js +117 -0
  315. package/dist/hooks/useTableData.cjs +53 -0
  316. package/dist/hooks/useTableData.js +51 -0
  317. package/dist/hooks/useTableSelection.cjs +172 -0
  318. package/dist/hooks/useTableSelection.js +170 -0
  319. package/dist/hooks/useTableSettings.cjs +90 -0
  320. package/dist/hooks/useTableSettings.js +87 -0
  321. package/dist/hooks/useTheme.cjs +64 -0
  322. package/dist/hooks/useTheme.js +62 -0
  323. package/dist/hooks/useTimeDuration.cjs +72 -0
  324. package/dist/hooks/useTimeDuration.js +70 -0
  325. package/dist/hooks/useViewportFill.cjs +82 -0
  326. package/dist/hooks/useViewportFill.js +80 -0
  327. package/dist/index.cjs +161 -12901
  328. package/dist/index.css +67 -7228
  329. package/dist/index.d.ts +0 -58
  330. package/dist/index.js +24 -12802
  331. package/dist/styles/animation.cjs +9 -0
  332. package/dist/styles/animation.js +7 -0
  333. package/dist/styles/themes/dbc/colors.css +5 -0
  334. package/dist/styles/themes/types.cjs +2 -0
  335. package/dist/styles/themes/types.js +1 -0
  336. package/dist/tanstack.cjs +18 -2652
  337. package/dist/tanstack.js +3 -2636
  338. package/dist/types/a11y-props.types.cjs +2 -0
  339. package/dist/types/a11y-props.types.js +1 -0
  340. package/dist/types/assets.d.cjs +2 -0
  341. package/dist/types/assets.d.js +1 -0
  342. package/dist/types/css.d.cjs +2 -0
  343. package/dist/types/css.d.js +1 -0
  344. package/dist/types/sizes.types.cjs +2 -0
  345. package/dist/types/sizes.types.js +1 -0
  346. package/dist/utils/arrays/nested-filtering.cjs +40 -0
  347. package/dist/utils/arrays/nested-filtering.js +38 -0
  348. package/dist/utils/date/formatDate.cjs +35 -0
  349. package/dist/utils/date/formatDate.js +33 -0
  350. package/dist/utils/localStorage.utils.cjs +53 -0
  351. package/dist/utils/localStorage.utils.js +49 -0
  352. package/dist/utils/text/get-highlighted-segments.cjs +49 -0
  353. package/dist/utils/text/get-highlighted-segments.js +47 -0
  354. package/package.json +8 -3
  355. package/dist/tanstack.css +0 -1271
package/dist/tanstack.js CHANGED
@@ -1,2636 +1,3 @@
1
- import { useReactTable, getSortedRowModel, getCoreRowModel } from '@tanstack/react-table';
2
- import * as React8 from 'react';
3
- import { createContext, forwardRef, useId, useState, useRef, useEffect, useCallback, useImperativeHandle, useLayoutEffect, useContext, useMemo } from 'react';
4
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
5
- import { LoaderCircle, ChevronUp, ChevronDown, Check, ListChevronsDownUp, Settings, ChevronsLeft, ArrowLeft, ArrowRight, ChevronsRight, ArrowUp, ArrowDown } from 'lucide-react';
6
- import { createPortal } from 'react-dom';
7
-
8
- // src/components/table/components/column-resizer/ColumnResizer.module.css
9
- var ColumnResizer_default = {
10
- resizer: "ColumnResizer_resizer"
11
- };
12
- var ColumnResizer = ({ id, handler }) => /* @__PURE__ */ jsx(
13
- "span",
14
- {
15
- className: ColumnResizer_default.resizer,
16
- "data-resizer": "true",
17
- onMouseDown: handler,
18
- onTouchStart: handler,
19
- role: "separator",
20
- "aria-orientation": "vertical",
21
- "aria-label": `Resize ${id}`
22
- }
23
- );
24
- var ColumnResizer_default2 = ColumnResizer;
25
-
26
- // src/components/pagination/Pagination.module.css
27
- var Pagination_default = {
28
- container: "Pagination_container2",
29
- range: "Pagination_range2"
30
- };
31
- var TooltipContext = createContext(null);
32
-
33
- // src/components/overlay/tooltip/useTooltipTrigger.tsx
34
- function useTooltipTrigger(options) {
35
- const ctx = useContext(TooltipContext);
36
- if (!ctx) throw new Error("useTooltipTrigger must be used within <TooltipProvider>.");
37
- const {
38
- content,
39
- placement = "top",
40
- offset = 8,
41
- open,
42
- defaultOpen = false,
43
- delayOpenMs = 150,
44
- delayCloseMs = 50,
45
- focusOpenMode = "focus-visible",
46
- closeOnPointerDown = true
47
- } = options;
48
- const id = useId();
49
- const triggerElRef = useRef(null);
50
- const isControlled = open !== void 0;
51
- const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
52
- const isOpen = isControlled ? !!open : uncontrolledOpen;
53
- const openTimer = useRef(null);
54
- const closeTimer = useRef(null);
55
- const clearTimers = () => {
56
- if (openTimer.current) window.clearTimeout(openTimer.current);
57
- if (closeTimer.current) window.clearTimeout(closeTimer.current);
58
- openTimer.current = null;
59
- closeTimer.current = null;
60
- };
61
- const lastSentRef = useRef(null);
62
- const show = useCallback(() => {
63
- if (!content) return;
64
- ctx.show({
65
- id,
66
- content,
67
- placement,
68
- offset,
69
- triggerEl: triggerElRef.current
70
- });
71
- lastSentRef.current = { content, placement, offset };
72
- }, [ctx, id, content, placement, offset]);
73
- const hide = useCallback(() => {
74
- ctx.hide(id);
75
- }, [ctx, id]);
76
- useEffect(() => {
77
- if (!isOpen) {
78
- hide();
79
- return;
80
- }
81
- show();
82
- }, [isOpen, show, hide]);
83
- useEffect(() => {
84
- var _a;
85
- if (!isOpen) return;
86
- if (((_a = ctx.active) == null ? void 0 : _a.id) !== id) return;
87
- const last = lastSentRef.current;
88
- const changed = !last || last.content !== content || last.placement !== placement || last.offset !== offset;
89
- if (!changed) return;
90
- ctx.update(id, {
91
- content,
92
- placement,
93
- offset,
94
- triggerEl: triggerElRef.current
95
- });
96
- lastSentRef.current = { content, placement, offset };
97
- }, [ctx, id, isOpen, content, placement, offset]);
98
- const setOpen = (next) => {
99
- if (isControlled) return;
100
- setUncontrolledOpen(next);
101
- };
102
- const onPointerEnter = () => {
103
- clearTimers();
104
- if (isControlled) return;
105
- openTimer.current = window.setTimeout(() => setOpen(true), delayOpenMs);
106
- };
107
- const onPointerLeave = () => {
108
- clearTimers();
109
- if (isControlled) return;
110
- closeTimer.current = window.setTimeout(() => setOpen(false), delayCloseMs);
111
- };
112
- const onPointerDown = () => {
113
- clearTimers();
114
- if (!isControlled && closeOnPointerDown) setOpen(false);
115
- };
116
- const onFocus = (e) => {
117
- clearTimers();
118
- if (focusOpenMode === "off") return;
119
- const shouldOpen = focusOpenMode === "any" || e.currentTarget.matches(":focus-visible");
120
- if (!isControlled && shouldOpen) {
121
- openTimer.current = window.setTimeout(() => setOpen(true), delayOpenMs);
122
- }
123
- };
124
- const onBlur = () => {
125
- clearTimers();
126
- if (!isControlled) setOpen(false);
127
- };
128
- return {
129
- id,
130
- isOpen,
131
- triggerProps: {
132
- ref: (node) => {
133
- triggerElRef.current = node;
134
- },
135
- onPointerEnter,
136
- onPointerLeave,
137
- onPointerDown,
138
- onFocus,
139
- onBlur,
140
- "aria-describedby": content ? id : void 0
141
- }
142
- };
143
- }
144
-
145
- // src/components/button/Button.module.css
146
- var Button_default = {
147
- button: "Button_button2",
148
- buttonLink: "Button_buttonLink2",
149
- round: "Button_round2",
150
- rounded: "Button_rounded2",
151
- link: "Button_link2",
152
- icon: "Button_icon2",
153
- sm: "Button_sm2",
154
- lg: "Button_lg2",
155
- fullWidth: "Button_fullWidth2",
156
- primary: "Button_primary2",
157
- secondary: "Button_secondary2",
158
- default: "Button_default2",
159
- outlined: "Button_outlined2",
160
- active: "Button_active2",
161
- success: "Button_success2",
162
- danger: "Button_danger2",
163
- inline: "Button_inline2",
164
- xs: "Button_xs2"
165
- };
166
- function cx(...parts) {
167
- return parts.filter(Boolean).join(" ");
168
- }
169
- function mergeRefs(...refs) {
170
- return (node) => {
171
- for (const ref of refs) {
172
- if (!ref) continue;
173
- if (typeof ref === "function") ref(node);
174
- else ref.current = node;
175
- }
176
- };
177
- }
178
- var Button = React8.forwardRef(function Button2({
179
- variant = "outlined",
180
- shape = "default",
181
- size = "md",
182
- fullWidth,
183
- icon,
184
- children,
185
- loading,
186
- active,
187
- spinIcon,
188
- tooltip,
189
- tooltipPlacement = "top",
190
- isLink,
191
- type = "button",
192
- ...rest
193
- }, ref) {
194
- var _a;
195
- const { className: userClassName, ...buttonProps } = rest;
196
- const computedClassName = cx(
197
- Button_default.button,
198
- Button_default[variant],
199
- Button_default[size],
200
- fullWidth ? Button_default.fullWidth : "",
201
- active ? Button_default.active : "",
202
- loading ? Button_default.loading : "",
203
- shape !== "default" ? Button_default[shape] : "",
204
- userClassName
205
- );
206
- const tooltipEnabled = Boolean(tooltip);
207
- const childRef = isLink && React8.isValidElement(children) ? (_a = children.ref) != null ? _a : null : null;
208
- const mergedRef = React8.useMemo(() => mergeRefs(childRef, ref), [childRef, ref]);
209
- const { triggerProps, id: tooltipId } = useTooltipTrigger({
210
- content: tooltipEnabled ? tooltip : null,
211
- placement: tooltipPlacement,
212
- offset: 8
213
- });
214
- const describedBy = (() => {
215
- const existing = typeof buttonProps["aria-describedby"] === "string" ? buttonProps["aria-describedby"] : "";
216
- const ids = [existing, tooltipEnabled ? tooltipId : ""].filter(Boolean);
217
- return ids.length ? ids.join(" ") : void 0;
218
- })();
219
- const content = /* @__PURE__ */ jsxs(Fragment, { children: [
220
- icon && /* @__PURE__ */ jsx("span", { className: cx(Button_default.icon, spinIcon ? "spin" : ""), children: icon }),
221
- children,
222
- loading && /* @__PURE__ */ jsx("span", { style: { display: "flex", opacity: 0.5 }, className: "spin", children: /* @__PURE__ */ jsx(LoaderCircle, {}) })
223
- ] });
224
- let buttonEl;
225
- if (isLink && React8.isValidElement(children)) {
226
- const childClassName = typeof children.props.className === "string" ? children.props.className : "";
227
- const { disabled, onClick, ...linkButtonProps } = buttonProps;
228
- const handleClick = (e) => {
229
- if (disabled) {
230
- e.preventDefault();
231
- return;
232
- }
233
- onClick == null ? void 0 : onClick(e);
234
- };
235
- buttonEl = React8.cloneElement(children, {
236
- ...linkButtonProps,
237
- ref: mergedRef,
238
- className: cx(childClassName, computedClassName, Button_default.buttonLink),
239
- ...tooltipEnabled ? triggerProps : {},
240
- "aria-describedby": describedBy,
241
- "aria-disabled": disabled ? "true" : void 0,
242
- onClick: handleClick,
243
- children: /* @__PURE__ */ jsxs(Fragment, { children: [
244
- icon && /* @__PURE__ */ jsx("span", { className: cx(Button_default.icon, spinIcon ? "spin" : ""), children: icon }),
245
- children.props.children,
246
- loading && /* @__PURE__ */ jsx("span", { style: { display: "flex", opacity: 0.5 }, className: "spin", children: /* @__PURE__ */ jsx(LoaderCircle, {}) })
247
- ] })
248
- });
249
- } else {
250
- const isDisabled = Boolean(buttonProps.disabled);
251
- buttonEl = /* @__PURE__ */ jsx(
252
- "button",
253
- {
254
- className: computedClassName,
255
- type,
256
- ...buttonProps,
257
- ...tooltipEnabled && !isDisabled ? triggerProps : {},
258
- "aria-describedby": describedBy,
259
- children: content
260
- }
261
- );
262
- if (tooltipEnabled && isDisabled) {
263
- buttonEl = /* @__PURE__ */ jsx(
264
- "span",
265
- {
266
- ref: triggerProps.ref,
267
- onPointerEnter: triggerProps.onPointerEnter,
268
- onPointerLeave: triggerProps.onPointerLeave,
269
- style: {
270
- display: fullWidth ? "flex" : "inline-flex",
271
- cursor: "not-allowed"
272
- },
273
- children: buttonEl
274
- }
275
- );
276
- }
277
- }
278
- return buttonEl;
279
- });
280
- Button.displayName = "Button";
281
-
282
- // src/components/menu/Menu.module.css
283
- var Menu_default = {
284
- container: "Menu_container2",
285
- row: "Menu_row2",
286
- interactive: "Menu_interactive2",
287
- interactiveChild: "Menu_interactiveChild2",
288
- selected: "Menu_selected2",
289
- active: "Menu_active2",
290
- itemDanger: "Menu_itemDanger2",
291
- separator: "Menu_separator2",
292
- header: "Menu_header2",
293
- gap: "Menu_gap2",
294
- rowBordered: "Menu_rowBordered2"
295
- };
296
-
297
- // src/components/forms/checkbox/Checkbox.module.css
298
- var Checkbox_default = {
299
- container: "Checkbox_container2",
300
- containerSm: "Checkbox_containerSm2",
301
- checkbox: "Checkbox_checkbox2",
302
- sm: "Checkbox_sm2",
303
- label: "Checkbox_label2",
304
- checked: "Checkbox_checked2",
305
- icon: "Checkbox_icon2",
306
- default: "Checkbox_default2",
307
- outlined: "Checkbox_outlined2",
308
- success: "Checkbox_success2",
309
- info: "Checkbox_info2"
310
- };
311
-
312
- // src/components/forms/input-container/InputContainer.module.css
313
- var InputContainer_default = {
314
- horizontal: "InputContainer_horizontal2",
315
- labelContainer: "InputContainer_labelContainer2",
316
- label: "InputContainer_label2",
317
- errorText: "InputContainer_errorText2",
318
- helpText: "InputContainer_helpText2",
319
- helpTextAddition: "InputContainer_helpTextAddition2",
320
- required: "InputContainer_required2",
321
- messageRow: "InputContainer_messageRow2",
322
- inputContainer: "InputContainer_inputContainer2"
323
- };
324
- function InputContainer({
325
- label,
326
- labelAction,
327
- htmlFor,
328
- error,
329
- helpText,
330
- helpTextAddition,
331
- fullWidth = false,
332
- required = false,
333
- children,
334
- orientation = "horizontal",
335
- size = "md",
336
- labelWidth = "160px",
337
- modified = false
338
- }) {
339
- const message = error != null ? error : helpText;
340
- const messageClass = error ? InputContainer_default.errorText : InputContainer_default.helpText;
341
- const renderLabelRow = (label || labelAction) && /* @__PURE__ */ jsxs("div", { className: `${InputContainer_default.labelRow} dbc-flex dbc-items-center dbc-gap-md`, children: [
342
- label && /* @__PURE__ */ jsxs("label", { className: InputContainer_default.label, htmlFor, children: [
343
- label,
344
- required && /* @__PURE__ */ jsx("span", { className: InputContainer_default.required, children: " *" })
345
- ] }),
346
- labelAction && /* @__PURE__ */ jsx("div", { className: InputContainer_default.labelAction, children: labelAction })
347
- ] });
348
- const renderMessageRow = (message || helpTextAddition) && /* @__PURE__ */ jsxs("div", { className: `${messageClass} ${InputContainer_default.messageRow}`, children: [
349
- /* @__PURE__ */ jsx("span", { children: message }),
350
- helpTextAddition && /* @__PURE__ */ jsx("span", { className: InputContainer_default.helpTextAddition, children: helpTextAddition })
351
- ] });
352
- if (orientation === "vertical") {
353
- return /* @__PURE__ */ jsxs(
354
- "div",
355
- {
356
- "data-modified": modified ? "true" : void 0,
357
- className: `dbc-flex dbc-flex-column dbc-gap-xs ${InputContainer_default.inputContainer}`,
358
- style: { width: fullWidth ? "100%" : void 0 },
359
- children: [
360
- renderLabelRow,
361
- children,
362
- renderMessageRow
363
- ]
364
- }
365
- );
366
- }
367
- return /* @__PURE__ */ jsx(
368
- "div",
369
- {
370
- "data-modified": modified ? "true" : void 0,
371
- className: InputContainer_default.inputContainer,
372
- style: {
373
- "--label-width": labelWidth,
374
- width: fullWidth ? "100%" : void 0
375
- },
376
- children: /* @__PURE__ */ jsxs("div", { className: `${InputContainer_default.horizontal} dbc-flex dbc-flex-column dbc-gap-xs`, "data-size": size, children: [
377
- /* @__PURE__ */ jsxs("div", { className: `${InputContainer_default.labelContainer} dbc-flex dbc-items-center dbc-gap-xs`, children: [
378
- renderLabelRow,
379
- children
380
- ] }),
381
- renderMessageRow
382
- ] })
383
- }
384
- );
385
- }
386
- function Checkbox({
387
- checked: controlled,
388
- onChange,
389
- variant = "default",
390
- disabled,
391
- label,
392
- labelAs = "label",
393
- size = "md",
394
- modified,
395
- containerLabel,
396
- error,
397
- helpText,
398
- orientation = "horizontal",
399
- labelWidth = "160px",
400
- fullWidth = false,
401
- required = false,
402
- noContainer = false,
403
- id,
404
- "data-cy": dataCy
405
- }) {
406
- const [internal, setInternal] = useState(false);
407
- const isChecked = controlled != null ? controlled : internal;
408
- const generatedId = useId();
409
- const controlId = id != null ? id : `checkbox-${generatedId}`;
410
- const toggle = (e) => {
411
- if (disabled) return;
412
- const value = !isChecked;
413
- setInternal(value);
414
- onChange == null ? void 0 : onChange(value, e);
415
- };
416
- const content = /* @__PURE__ */ jsxs(
417
- "span",
418
- {
419
- className: [Checkbox_default.container, size === "sm" ? Checkbox_default.containerSm : ""].filter(Boolean).join(" "),
420
- "data-cy": dataCy,
421
- children: [
422
- /* @__PURE__ */ jsx(
423
- "button",
424
- {
425
- id: controlId,
426
- disabled,
427
- type: "button",
428
- role: "checkbox",
429
- "aria-checked": isChecked,
430
- "aria-disabled": disabled || void 0,
431
- "aria-invalid": Boolean(error) || void 0,
432
- onClick: toggle,
433
- className: [Checkbox_default.checkbox, isChecked ? Checkbox_default.checked : "", Checkbox_default[variant], Checkbox_default[size]].filter(Boolean).join(" "),
434
- children: isChecked && /* @__PURE__ */ jsx(Check, { className: Checkbox_default.icon })
435
- }
436
- ),
437
- label && (labelAs === "label" ? /* @__PURE__ */ jsx("label", { className: Checkbox_default.label, htmlFor: controlId, children: label }) : /* @__PURE__ */ jsx("span", { className: Checkbox_default.label, children: label }))
438
- ]
439
- }
440
- );
441
- if (noContainer) return content;
442
- return /* @__PURE__ */ jsx(
443
- InputContainer,
444
- {
445
- modified,
446
- label: containerLabel,
447
- htmlFor: controlId,
448
- error,
449
- helpText,
450
- orientation,
451
- size,
452
- labelWidth,
453
- fullWidth,
454
- required,
455
- children: content
456
- }
457
- );
458
- }
459
-
460
- // src/components/forms/radio-buttons/RadioButtons.module.css
461
- var RadioButtons_default = {
462
- container: "RadioButtons_container2",
463
- controlWrap: "RadioButtons_controlWrap2",
464
- input: "RadioButtons_input2",
465
- radio: "RadioButtons_radio2",
466
- dot: "RadioButtons_dot2",
467
- checked: "RadioButtons_checked2",
468
- disabled: "RadioButtons_disabled2",
469
- label: "RadioButtons_label2",
470
- primary: "RadioButtons_primary2",
471
- default: "RadioButtons_default2",
472
- sm: "RadioButtons_sm2",
473
- md: "RadioButtons_md2",
474
- lg: "RadioButtons_lg2"
475
- };
476
- function RadioButton({
477
- name,
478
- value,
479
- selectedValue,
480
- checked,
481
- onChange,
482
- disabled,
483
- label,
484
- variant = "outlined",
485
- size = "md",
486
- containerLabel,
487
- error,
488
- helpText,
489
- orientation = "horizontal",
490
- labelWidth = "160px",
491
- fullWidth = false,
492
- required = false,
493
- noContainer = false,
494
- id,
495
- "data-cy": dataCy
496
- }) {
497
- const generatedId = useId();
498
- const controlId = id != null ? id : `radio-${generatedId}`;
499
- const isChecked = selectedValue !== void 0 ? selectedValue === value : Boolean(checked);
500
- const content = /* @__PURE__ */ jsxs("span", { className: RadioButtons_default.container, "data-cy": dataCy, children: [
501
- /* @__PURE__ */ jsxs("span", { className: RadioButtons_default.controlWrap, children: [
502
- /* @__PURE__ */ jsx(
503
- "input",
504
- {
505
- id: controlId,
506
- className: RadioButtons_default.input,
507
- type: "radio",
508
- name,
509
- value,
510
- checked: isChecked,
511
- disabled,
512
- required,
513
- "aria-invalid": Boolean(error) || void 0,
514
- onChange: (e) => {
515
- if (disabled) return;
516
- onChange == null ? void 0 : onChange(e.target.value, e);
517
- }
518
- }
519
- ),
520
- /* @__PURE__ */ jsx(
521
- "span",
522
- {
523
- className: [
524
- RadioButtons_default.radio,
525
- isChecked ? RadioButtons_default.checked : "",
526
- disabled ? RadioButtons_default.disabled : "",
527
- RadioButtons_default[variant],
528
- RadioButtons_default[size]
529
- ].filter(Boolean).join(" "),
530
- "aria-hidden": "true",
531
- children: /* @__PURE__ */ jsx("span", { className: RadioButtons_default.dot })
532
- }
533
- )
534
- ] }),
535
- label && /* @__PURE__ */ jsx("label", { className: RadioButtons_default.label, htmlFor: controlId, children: label })
536
- ] });
537
- if (noContainer || !containerLabel && !error) return content;
538
- return /* @__PURE__ */ jsx(
539
- InputContainer,
540
- {
541
- label: containerLabel,
542
- htmlFor: controlId,
543
- error,
544
- helpText,
545
- orientation,
546
- labelWidth,
547
- fullWidth,
548
- required,
549
- children: content
550
- }
551
- );
552
- }
553
- var INTERACTIVE_SELECTOR = 'a:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"]):not([aria-disabled="true"]), [role="menuitem"]:not([aria-disabled="true"]), [role="option"]:not([aria-disabled="true"])';
554
- function getMenuItems(el) {
555
- return Array.from(el.querySelectorAll(INTERACTIVE_SELECTOR));
556
- }
557
- var MenuBase = React8.forwardRef(
558
- ({ children, className, itemRole = "menuitem", gap, onKeyDown, ...props }, ref) => {
559
- const internalRef = React8.useRef(null);
560
- const handleKeyDown = (e) => {
561
- const ul = internalRef.current;
562
- if (!ul) return;
563
- const items = getMenuItems(ul);
564
- if (items.length === 0) return;
565
- const focused = document.activeElement;
566
- const currentIndex = items.indexOf(focused);
567
- let nextIndex = null;
568
- if (e.key === "ArrowDown") {
569
- nextIndex = currentIndex < items.length - 1 ? currentIndex + 1 : 0;
570
- } else if (e.key === "ArrowUp") {
571
- nextIndex = currentIndex > 0 ? currentIndex - 1 : items.length - 1;
572
- } else if (e.key === "Home") {
573
- nextIndex = 0;
574
- } else if (e.key === "End") {
575
- nextIndex = items.length - 1;
576
- }
577
- if (nextIndex !== null) {
578
- e.preventDefault();
579
- items[nextIndex].focus();
580
- }
581
- onKeyDown == null ? void 0 : onKeyDown(e);
582
- };
583
- return /* @__PURE__ */ jsx(
584
- "ul",
585
- {
586
- ref: (node) => {
587
- internalRef.current = node;
588
- if (typeof ref === "function") ref(node);
589
- else if (ref) ref.current = node;
590
- },
591
- role: "menu",
592
- "data-itemrole": itemRole,
593
- className: [Menu_default.container, gap ? Menu_default.gap : "", className].filter(Boolean).join(" "),
594
- onKeyDown: handleKeyDown,
595
- ...props,
596
- children
597
- }
598
- );
599
- }
600
- );
601
- MenuBase.displayName = "Menu";
602
- var isInteractiveEl = (el) => React8.isValidElement(el) && (typeof el.type === "string" ? el.type === "a" || el.type === "button" : true);
603
- function applyMenuItemPropsToElement(child, opts) {
604
- var _a, _b, _c, _d;
605
- const { active, selected, disabled, role, tabIndex = 0, className } = opts;
606
- const childClass = [Menu_default.item, active ? Menu_default.active : "", selected ? Menu_default.selected : ""].filter(Boolean).join(" ");
607
- const nextImmediate = React8.cloneElement(child, {
608
- className: [child.props.className, Menu_default.interactiveChild, className].filter(Boolean).join(" ")
609
- });
610
- if (typeof child.type === "string" && (child.type === "a" || child.type === "button")) {
611
- return React8.cloneElement(child, {
612
- role: (_a = child.props.role) != null ? _a : role,
613
- tabIndex: (_b = child.props.tabIndex) != null ? _b : tabIndex,
614
- "aria-selected": selected || void 0,
615
- "aria-disabled": disabled || void 0,
616
- className: [child.props.className, Menu_default.interactive, childClass, className].filter(Boolean).join(" "),
617
- ...child.type === "button" ? { disabled } : {}
618
- });
619
- }
620
- return React8.cloneElement(nextImmediate, {
621
- role: (_c = nextImmediate.props.role) != null ? _c : role,
622
- tabIndex: (_d = nextImmediate.props.tabIndex) != null ? _d : tabIndex,
623
- "aria-selected": selected || void 0,
624
- "aria-disabled": disabled || void 0,
625
- className: [nextImmediate.props.className, Menu_default.interactive, childClass].filter(Boolean).join(" "),
626
- disabled
627
- });
628
- }
629
- var MenuItem = React8.forwardRef(
630
- ({ children, active, selected, disabled, className, itemRole, variant, ...liProps }, ref) => {
631
- const resolvedRole = itemRole != null ? itemRole : "menuitem";
632
- const isBordered = variant === "bordered";
633
- const itemClassName = variant === "danger" ? Menu_default.itemDanger : void 0;
634
- const rowClass = [Menu_default.row, isBordered ? Menu_default.rowBordered : "", className].filter(Boolean).join(" ");
635
- if (isInteractiveEl(children)) {
636
- const child = children;
637
- return /* @__PURE__ */ jsx("li", { ref, role: "none", className: rowClass, ...liProps, children: applyMenuItemPropsToElement(child, {
638
- active,
639
- selected,
640
- disabled,
641
- role: resolvedRole,
642
- className: itemClassName
643
- }) });
644
- }
645
- return /* @__PURE__ */ jsx("li", { ref, role: "none", className: rowClass, ...liProps, children: /* @__PURE__ */ jsx(
646
- "button",
647
- {
648
- role: resolvedRole,
649
- tabIndex: 0,
650
- "aria-selected": selected || void 0,
651
- "aria-disabled": disabled || void 0,
652
- className: [
653
- Menu_default.interactive,
654
- Menu_default.item,
655
- itemClassName,
656
- active ? Menu_default.active : "",
657
- selected ? Menu_default.selected : ""
658
- ].filter(Boolean).join(" "),
659
- type: "button",
660
- disabled,
661
- children
662
- }
663
- ) });
664
- }
665
- );
666
- MenuItem.displayName = "Menu.Item";
667
- var MenuCheckItem = React8.forwardRef(
668
- ({
669
- label,
670
- checked,
671
- active,
672
- disabled,
673
- interactiveRef,
674
- interactiveProps,
675
- onCheckedChange,
676
- className,
677
- ...liProps
678
- }, ref) => {
679
- const isSelected = checked;
680
- const interactiveClass = [
681
- Menu_default.interactiveChild,
682
- Menu_default.item,
683
- active ? Menu_default.active : "",
684
- isSelected ? Menu_default.selected : ""
685
- ].filter(Boolean).join(" ");
686
- return /* @__PURE__ */ jsx(
687
- "li",
688
- {
689
- ref,
690
- role: "none",
691
- className: [Menu_default.row, className].filter(Boolean).join(" "),
692
- ...liProps,
693
- children: /* @__PURE__ */ jsx(
694
- "div",
695
- {
696
- ref: interactiveRef,
697
- role: interactiveProps == null ? void 0 : interactiveProps.role,
698
- tabIndex: -1,
699
- "aria-selected": isSelected || void 0,
700
- "aria-disabled": disabled || void 0,
701
- className: interactiveClass,
702
- ...interactiveProps,
703
- onClick: (event) => {
704
- var _a;
705
- (_a = interactiveProps == null ? void 0 : interactiveProps.onClick) == null ? void 0 : _a.call(interactiveProps, event);
706
- if (event.defaultPrevented || disabled) return;
707
- const target = event.target;
708
- if (target instanceof Element && target.closest("button") !== null) {
709
- return;
710
- }
711
- onCheckedChange == null ? void 0 : onCheckedChange(!checked);
712
- },
713
- children: /* @__PURE__ */ jsx(
714
- Checkbox,
715
- {
716
- variant: "primary",
717
- size: "sm",
718
- noContainer: true,
719
- checked,
720
- disabled,
721
- labelAs: "span",
722
- label,
723
- onChange: (next, _e) => onCheckedChange == null ? void 0 : onCheckedChange(next)
724
- }
725
- )
726
- }
727
- )
728
- }
729
- );
730
- }
731
- );
732
- MenuCheckItem.displayName = "Menu.CheckItem";
733
- var MenuRadioItem = React8.forwardRef(
734
- ({ name, value, checked, disabled, label, onValueChange, className, ...liProps }, ref) => {
735
- return /* @__PURE__ */ jsx(
736
- "li",
737
- {
738
- ref,
739
- role: "none",
740
- className: [Menu_default.row, className].filter(Boolean).join(" "),
741
- ...liProps,
742
- children: /* @__PURE__ */ jsx(
743
- "div",
744
- {
745
- className: Menu_default.interactiveChild,
746
- onClick: (event) => {
747
- var _a;
748
- if (disabled) return;
749
- const target = event.target;
750
- if ((_a = target.closest("label")) != null ? _a : target.closest("input")) return;
751
- onValueChange == null ? void 0 : onValueChange(value);
752
- },
753
- children: /* @__PURE__ */ jsx(
754
- RadioButton,
755
- {
756
- noContainer: true,
757
- name,
758
- size: "sm",
759
- value,
760
- checked,
761
- disabled,
762
- label,
763
- onChange: (v, _e) => onValueChange == null ? void 0 : onValueChange(v)
764
- }
765
- )
766
- }
767
- )
768
- }
769
- );
770
- }
771
- );
772
- MenuRadioItem.displayName = "Menu.RadioItem";
773
- var MenuSeparator = React8.forwardRef(
774
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
775
- "li",
776
- {
777
- ref,
778
- role: "separator",
779
- className: [Menu_default.separator, className].filter(Boolean).join(" "),
780
- ...props
781
- }
782
- )
783
- );
784
- MenuSeparator.displayName = "Menu.Separator";
785
- var MenuHeader = React8.forwardRef(
786
- ({ className, children, ...props }, ref) => /* @__PURE__ */ jsx(
787
- "li",
788
- {
789
- ref,
790
- role: "presentation",
791
- "aria-hidden": "true",
792
- className: [Menu_default.header, className].filter(Boolean).join(" "),
793
- ...props,
794
- children
795
- }
796
- )
797
- );
798
- MenuHeader.displayName = "Menu.Header";
799
- var Menu = Object.assign(MenuBase, {
800
- Item: MenuItem,
801
- CheckItem: MenuCheckItem,
802
- RadioItem: MenuRadioItem,
803
- Separator: MenuSeparator,
804
- Header: MenuHeader
805
- });
806
-
807
- // src/components/popover/Popover.module.css
808
- var Popover_default = {
809
- container: "Popover_container2",
810
- triggerSlot: "Popover_triggerSlot2",
811
- fullWidth: "Popover_fullWidth2",
812
- fillTrigger: "Popover_fillTrigger2",
813
- content: "Popover_content2"
814
- };
815
- function assignRef(ref, value) {
816
- if (!ref) return;
817
- if (typeof ref === "function") {
818
- ref(value);
819
- return;
820
- }
821
- ref.current = value;
822
- }
823
- function getFocusable(container) {
824
- const els = container.querySelectorAll(
825
- [
826
- "a[href]",
827
- "button:not([disabled])",
828
- "input:not([disabled])",
829
- "select:not([disabled])",
830
- "textarea:not([disabled])",
831
- '[tabindex]:not([tabindex="-1"])'
832
- ].join(",")
833
- );
834
- return Array.from(els).filter(
835
- (el) => !el.hasAttribute("disabled") && !el.getAttribute("aria-hidden")
836
- );
837
- }
838
- function parseMinWidthPx(minWidth, elForEm) {
839
- const v = minWidth.trim();
840
- if (v.endsWith("px")) {
841
- const n = Number.parseFloat(v);
842
- return Number.isFinite(n) ? n : 0;
843
- }
844
- if (typeof window !== "undefined" && v.endsWith("rem")) {
845
- const n = Number.parseFloat(v);
846
- if (!Number.isFinite(n)) return 0;
847
- const rootFont = Number.parseFloat(getComputedStyle(document.documentElement).fontSize || "16");
848
- return n * (Number.isFinite(rootFont) ? rootFont : 16);
849
- }
850
- if (typeof window !== "undefined" && v.endsWith("em")) {
851
- const n = Number.parseFloat(v);
852
- if (!Number.isFinite(n)) return 0;
853
- const font = elForEm ? Number.parseFloat(getComputedStyle(elForEm).fontSize || "16") : 16;
854
- return n * (Number.isFinite(font) ? font : 16);
855
- }
856
- return 0;
857
- }
858
- var Popover = forwardRef(function Popover2({
859
- trigger: Trigger,
860
- children,
861
- open,
862
- defaultOpen = false,
863
- onOpenChange,
864
- contentId,
865
- minWidth = "200px",
866
- matchTriggerWidth = true,
867
- viewportPadding = 8,
868
- contentMaxHeightPx = 400,
869
- edgeBuffer = 100,
870
- dataCy,
871
- fullWidth = false,
872
- fillTrigger = false,
873
- autoFocusContent = false,
874
- returnFocus = true,
875
- anchorRef,
876
- overlayRef
877
- }, ref) {
878
- const internalId = useId();
879
- const resolvedContentId = contentId != null ? contentId : `popover-${internalId}`;
880
- const isControlled = open !== void 0;
881
- const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
882
- const isOpen = isControlled ? !!open : uncontrolledOpen;
883
- const [pos, setPos] = useState({ top: 0, left: 0 });
884
- const [positioned, setPositioned] = useState(false);
885
- const [triggerWidth, setTriggerWidth] = useState(null);
886
- const containerRef = useRef(null);
887
- const contentRef = useRef(null);
888
- const triggerElRef = useRef(null);
889
- const lastCloseReasonRef = useRef("unknown");
890
- const [mounted, setMounted] = useState(false);
891
- useEffect(() => setMounted(true), []);
892
- const setOpen = useCallback(
893
- (next) => {
894
- if (!isControlled) setUncontrolledOpen(next);
895
- onOpenChange == null ? void 0 : onOpenChange(next);
896
- },
897
- [isControlled, onOpenChange]
898
- );
899
- const openPopover = useCallback(() => {
900
- setPositioned(false);
901
- setOpen(true);
902
- }, [setOpen]);
903
- const closePopover = useCallback(
904
- (reason = "api") => {
905
- lastCloseReasonRef.current = reason;
906
- setOpen(false);
907
- },
908
- [setOpen]
909
- );
910
- const togglePopover = useCallback(
911
- (e) => {
912
- var _a, _b;
913
- triggerElRef.current = (_b = (_a = anchorRef == null ? void 0 : anchorRef.current) != null ? _a : e.currentTarget) != null ? _b : containerRef.current;
914
- if (isOpen) closePopover("trigger");
915
- else openPopover();
916
- },
917
- [isOpen, closePopover, openPopover, anchorRef]
918
- );
919
- useImperativeHandle(
920
- ref,
921
- () => ({
922
- close: () => closePopover("api"),
923
- open: openPopover,
924
- isOpen: () => isOpen
925
- }),
926
- [closePopover, openPopover, isOpen]
927
- );
928
- const computeAndSetPosition = useCallback(() => {
929
- var _a, _b;
930
- const content = contentRef.current;
931
- if (!content) return;
932
- const triggerEl = (_b = (_a = anchorRef == null ? void 0 : anchorRef.current) != null ? _a : triggerElRef.current) != null ? _b : containerRef.current;
933
- if (!triggerEl) return;
934
- const triggerRect = triggerEl.getBoundingClientRect();
935
- const overlayWidthBuffer = 8;
936
- let forcedWidthPx = null;
937
- if (matchTriggerWidth) {
938
- const minWidthPx = parseMinWidthPx(minWidth, triggerEl);
939
- forcedWidthPx = Math.max(triggerRect.width + overlayWidthBuffer, minWidthPx || 0);
940
- setTriggerWidth(forcedWidthPx);
941
- } else {
942
- setTriggerWidth(null);
943
- }
944
- const prevHidden = content.hidden;
945
- const prevVis = content.style.visibility;
946
- const prevDisp = content.style.display;
947
- const prevMinWidth = content.style.minWidth;
948
- const prevWidth = content.style.width;
949
- const prevTop = content.style.top;
950
- const prevLeft = content.style.left;
951
- content.hidden = false;
952
- content.style.visibility = "hidden";
953
- content.style.display = "block";
954
- content.style.top = "0px";
955
- content.style.left = "0px";
956
- content.style.minWidth = minWidth;
957
- content.style.width = forcedWidthPx != null ? `${forcedWidthPx}px` : "auto";
958
- const contentWidth = content.offsetWidth;
959
- const contentHeight = content.offsetHeight;
960
- content.hidden = prevHidden;
961
- content.style.visibility = prevVis;
962
- content.style.display = prevDisp;
963
- content.style.minWidth = prevMinWidth;
964
- content.style.width = prevWidth;
965
- content.style.top = prevTop;
966
- content.style.left = prevLeft;
967
- const vw = window.innerWidth;
968
- const vh = window.innerHeight;
969
- const spaceAbove = Math.max(0, triggerRect.top);
970
- const spaceBelow = Math.max(0, vh - triggerRect.bottom);
971
- const spaceLeft = Math.max(0, triggerRect.left);
972
- const spaceRight = Math.max(0, vw - triggerRect.right);
973
- const preferBelow = spaceBelow >= contentHeight + edgeBuffer || spaceBelow >= spaceAbove;
974
- const spacing = viewportPadding;
975
- const rawTop = preferBelow ? triggerRect.bottom + spacing : triggerRect.top - contentHeight - spacing;
976
- const placeRightOfLeftEdge = spaceRight >= contentWidth + edgeBuffer;
977
- const placeLeftOfRightEdge = spaceLeft >= contentWidth + edgeBuffer;
978
- let rawLeft;
979
- if (placeRightOfLeftEdge) rawLeft = triggerRect.left;
980
- else if (placeLeftOfRightEdge) rawLeft = triggerRect.right - contentWidth;
981
- else rawLeft = triggerRect.left + (triggerRect.width - contentWidth) / 2;
982
- const clampedLeft = Math.max(
983
- viewportPadding,
984
- Math.min(rawLeft, vw - contentWidth - viewportPadding)
985
- );
986
- const clampedTop = Math.max(
987
- viewportPadding,
988
- Math.min(rawTop, vh - contentHeight - viewportPadding)
989
- );
990
- setPos({ top: clampedTop, left: clampedLeft });
991
- setPositioned(true);
992
- }, [anchorRef, edgeBuffer, viewportPadding, minWidth, matchTriggerWidth]);
993
- useLayoutEffect(() => {
994
- if (!isOpen) return;
995
- computeAndSetPosition();
996
- }, [isOpen, computeAndSetPosition]);
997
- useEffect(() => {
998
- var _a, _b, _c;
999
- if (!isOpen) return;
1000
- const content = contentRef.current;
1001
- if (!content) return;
1002
- const triggerEl = (_b = (_a = anchorRef == null ? void 0 : anchorRef.current) != null ? _a : triggerElRef.current) != null ? _b : containerRef.current;
1003
- if (autoFocusContent) {
1004
- const focusables = getFocusable(content);
1005
- (_c = focusables[0]) == null ? void 0 : _c.focus();
1006
- }
1007
- const handlePointerDownCapture = (e) => {
1008
- const container = containerRef.current;
1009
- const contentEl = contentRef.current;
1010
- if (!container || !contentEl) return;
1011
- const target = e.target;
1012
- if (!container.contains(target) && !contentEl.contains(target)) {
1013
- closePopover("outside");
1014
- }
1015
- };
1016
- const handleEscape = (e) => {
1017
- if (e.key === "Escape") closePopover("escape");
1018
- };
1019
- const handleReposition = () => computeAndSetPosition();
1020
- const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
1021
- handleReposition();
1022
- }) : null;
1023
- document.addEventListener("pointerdown", handlePointerDownCapture, true);
1024
- document.addEventListener("keydown", handleEscape, true);
1025
- window.addEventListener("resize", handleReposition);
1026
- window.addEventListener("scroll", handleReposition, true);
1027
- resizeObserver == null ? void 0 : resizeObserver.observe(content);
1028
- if (triggerEl) resizeObserver == null ? void 0 : resizeObserver.observe(triggerEl);
1029
- return () => {
1030
- document.removeEventListener("pointerdown", handlePointerDownCapture, true);
1031
- document.removeEventListener("keydown", handleEscape, true);
1032
- window.removeEventListener("resize", handleReposition);
1033
- window.removeEventListener("scroll", handleReposition, true);
1034
- resizeObserver == null ? void 0 : resizeObserver.disconnect();
1035
- };
1036
- }, [isOpen, closePopover, computeAndSetPosition, autoFocusContent, anchorRef]);
1037
- useEffect(() => {
1038
- var _a, _b;
1039
- if (isOpen) return;
1040
- if (!returnFocus) return;
1041
- if (lastCloseReasonRef.current === "outside") return;
1042
- (_b = (_a = triggerElRef.current) == null ? void 0 : _a.focus) == null ? void 0 : _b.call(_a);
1043
- }, [isOpen, returnFocus]);
1044
- const icon = isOpen ? /* @__PURE__ */ jsx(ChevronUp, { className: "dbc-muted-text", size: 20 }) : /* @__PURE__ */ jsx(ChevronDown, { className: "dbc-muted-text", size: 20 });
1045
- const setOverlayRef = React8.useCallback(
1046
- (node) => {
1047
- assignRef(overlayRef, node);
1048
- },
1049
- [overlayRef]
1050
- );
1051
- return /* @__PURE__ */ jsxs(
1052
- "div",
1053
- {
1054
- className: [
1055
- Popover_default.container,
1056
- fullWidth ? Popover_default.fullWidth : "",
1057
- fillTrigger ? Popover_default.fillTrigger : ""
1058
- ].filter(Boolean).join(" "),
1059
- ref: containerRef,
1060
- children: [
1061
- /* @__PURE__ */ jsx(
1062
- "div",
1063
- {
1064
- className: [
1065
- Popover_default.triggerSlot,
1066
- fullWidth ? Popover_default.fullWidth : "",
1067
- fillTrigger ? Popover_default.fillTrigger : ""
1068
- ].filter(Boolean).join(" "),
1069
- children: Trigger(togglePopover, icon, isOpen)
1070
- }
1071
- ),
1072
- mounted && isOpen && createPortal(
1073
- /* @__PURE__ */ jsx(
1074
- "div",
1075
- {
1076
- id: resolvedContentId,
1077
- ref: (node) => {
1078
- contentRef.current = node;
1079
- setOverlayRef(node);
1080
- },
1081
- className: Popover_default.content,
1082
- style: {
1083
- top: pos.top,
1084
- left: pos.left,
1085
- minWidth,
1086
- width: triggerWidth != null ? `${triggerWidth}px` : void 0,
1087
- maxWidth: `calc(100vw - ${viewportPadding * 2}px)`,
1088
- maxHeight: `clamp(100px, calc(100vh - ${viewportPadding * 2}px), ${contentMaxHeightPx}px)`,
1089
- visibility: positioned ? void 0 : "hidden"
1090
- },
1091
- "data-cy": dataCy != null ? dataCy : "popover-content",
1092
- children: typeof children === "function" ? (
1093
- // eslint-disable-next-line react-hooks/refs
1094
- children(() => closePopover("api"))
1095
- ) : children
1096
- }
1097
- ),
1098
- document.body
1099
- )
1100
- ]
1101
- }
1102
- );
1103
- });
1104
- Popover.displayName = "Popover";
1105
- var DEFAULT_PAGE_SIZE_OPTIONS = [20, 50, 100];
1106
- var NUMBER_LOCALE = "da-DK";
1107
- function Pagination({
1108
- itemsCount = 0,
1109
- skip = 0,
1110
- take = DEFAULT_PAGE_SIZE_OPTIONS[1],
1111
- onPageChange,
1112
- pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS,
1113
- showFirstLast = true,
1114
- showGoToPage = true
1115
- }) {
1116
- const popoverRef = useRef(null);
1117
- const pageSizeRef = useRef(null);
1118
- const formatNumber = useCallback((value) => value.toLocaleString(NUMBER_LOCALE), []);
1119
- const totalPages = useMemo(
1120
- () => Math.max(1, Math.ceil(itemsCount / Math.max(1, take))),
1121
- [itemsCount, take]
1122
- );
1123
- const currentPage = useMemo(() => {
1124
- const p = Math.floor(skip / Math.max(1, take)) + 1;
1125
- return Math.min(Math.max(1, p), totalPages);
1126
- }, [skip, take, totalPages]);
1127
- const emit = useCallback(
1128
- (page, nextTake = take) => {
1129
- const nextTotalPages = Math.max(1, Math.ceil(itemsCount / Math.max(1, nextTake)));
1130
- const clampedPage = Math.min(Math.max(1, page), nextTotalPages);
1131
- const nextSkip = (clampedPage - 1) * nextTake;
1132
- onPageChange == null ? void 0 : onPageChange({
1133
- page: clampedPage,
1134
- take: nextTake,
1135
- skip: nextSkip,
1136
- totalPages: nextTotalPages
1137
- });
1138
- },
1139
- [onPageChange, take, itemsCount]
1140
- );
1141
- const firstPage = useCallback(() => emit(1), [emit]);
1142
- const lastPage = useCallback(() => emit(totalPages), [emit, totalPages]);
1143
- const prevPage = useCallback(() => emit(currentPage - 1), [emit, currentPage]);
1144
- const nextPage = useCallback(() => emit(currentPage + 1), [emit, currentPage]);
1145
- const goToPage = useCallback((page) => emit(page), [emit]);
1146
- const canPrev = currentPage > 1;
1147
- const canNext = currentPage < totalPages;
1148
- const rangeLabel = useMemo(() => {
1149
- if (itemsCount <= 0) return "0 af 0";
1150
- const first = skip + 1;
1151
- const last = Math.min(skip + take, itemsCount);
1152
- return `${formatNumber(first)}\u2013${formatNumber(last)} af ${formatNumber(itemsCount)}`;
1153
- }, [formatNumber, itemsCount, skip, take]);
1154
- const pages = useMemo(() => Array.from({ length: totalPages }, (_, i) => i + 1), [totalPages]);
1155
- const handlePageSizeChange = useCallback((size) => emit(1, size), [emit]);
1156
- return /* @__PURE__ */ jsxs("div", { className: Pagination_default.container, children: [
1157
- showFirstLast && /* @__PURE__ */ jsx(
1158
- Button,
1159
- {
1160
- size: "sm",
1161
- icon: /* @__PURE__ */ jsx(ChevronsLeft, {}),
1162
- disabled: !canPrev,
1163
- onClick: firstPage,
1164
- "aria-label": "First page"
1165
- }
1166
- ),
1167
- /* @__PURE__ */ jsx(
1168
- Button,
1169
- {
1170
- size: "sm",
1171
- icon: /* @__PURE__ */ jsx(ArrowLeft, {}),
1172
- disabled: !canPrev,
1173
- onClick: prevPage,
1174
- "aria-label": "Previous page"
1175
- }
1176
- ),
1177
- /* @__PURE__ */ jsx("div", { className: Pagination_default.range, "aria-live": "polite", children: rangeLabel }),
1178
- /* @__PURE__ */ jsx(
1179
- Button,
1180
- {
1181
- size: "sm",
1182
- icon: /* @__PURE__ */ jsx(ArrowRight, {}),
1183
- disabled: !canNext,
1184
- onClick: nextPage,
1185
- "aria-label": "Next page"
1186
- }
1187
- ),
1188
- showFirstLast && /* @__PURE__ */ jsx(
1189
- Button,
1190
- {
1191
- size: "sm",
1192
- icon: /* @__PURE__ */ jsx(ChevronsRight, {}),
1193
- disabled: !canNext,
1194
- onClick: lastPage,
1195
- "aria-label": "Last page"
1196
- }
1197
- ),
1198
- showGoToPage && /* @__PURE__ */ jsx(
1199
- Popover,
1200
- {
1201
- ref: popoverRef,
1202
- trigger: (open) => /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "outlined", onClick: open, children: [
1203
- "Side ",
1204
- formatNumber(currentPage),
1205
- "/",
1206
- formatNumber(totalPages),
1207
- " ",
1208
- /* @__PURE__ */ jsx(ChevronDown, { size: 16 })
1209
- ] }),
1210
- children: /* @__PURE__ */ jsx(Menu, { children: pages == null ? void 0 : pages.map((page) => /* @__PURE__ */ jsx(Menu.Item, { active: page === currentPage, children: /* @__PURE__ */ jsx(
1211
- "button",
1212
- {
1213
- onClick: () => {
1214
- var _a;
1215
- goToPage(page);
1216
- (_a = popoverRef.current) == null ? void 0 : _a.close();
1217
- },
1218
- children: formatNumber(page)
1219
- }
1220
- ) }, page)) })
1221
- }
1222
- ),
1223
- /* @__PURE__ */ jsx(
1224
- Popover,
1225
- {
1226
- ref: pageSizeRef,
1227
- trigger: (open) => /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "outlined", onClick: open, children: [
1228
- "Vis ",
1229
- formatNumber(take),
1230
- " ",
1231
- /* @__PURE__ */ jsx(ChevronDown, { size: 16 })
1232
- ] }),
1233
- children: /* @__PURE__ */ jsx(Menu, { children: pageSizeOptions == null ? void 0 : pageSizeOptions.map((size) => /* @__PURE__ */ jsx(Menu.Item, { active: size === take, children: /* @__PURE__ */ jsx(
1234
- "button",
1235
- {
1236
- onClick: () => {
1237
- var _a;
1238
- handlePageSizeChange(size);
1239
- (_a = pageSizeRef.current) == null ? void 0 : _a.close();
1240
- },
1241
- children: formatNumber(size)
1242
- }
1243
- ) }, size)) })
1244
- }
1245
- )
1246
- ] });
1247
- }
1248
- var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
1249
- function useViewportFill(ref, { bottomOffset = 0, min = 120, includeMarginTop = false, watchRef } = {}) {
1250
- const [maxHeight, setMaxHeight] = useState(min);
1251
- const raf = useRef(null);
1252
- const measure = useCallback(() => {
1253
- if (typeof window === "undefined" || !ref.current) return;
1254
- const el = ref.current;
1255
- const rect = el.getBoundingClientRect();
1256
- let top = rect.top;
1257
- if (includeMarginTop) {
1258
- const marginTop = parseFloat(window.getComputedStyle(el).marginTop || "0") || 0;
1259
- top -= marginTop;
1260
- }
1261
- const next = Math.max(min, Math.floor(window.innerHeight - bottomOffset - top));
1262
- setMaxHeight((prev) => prev === next ? prev : next);
1263
- }, [ref, bottomOffset, min, includeMarginTop]);
1264
- const scheduleMeasure = useCallback(() => {
1265
- if (typeof window === "undefined") return;
1266
- if (raf.current != null) {
1267
- cancelAnimationFrame(raf.current);
1268
- }
1269
- raf.current = window.requestAnimationFrame(() => {
1270
- raf.current = null;
1271
- measure();
1272
- });
1273
- }, [measure]);
1274
- useIsomorphicLayoutEffect(() => {
1275
- measure();
1276
- }, [measure]);
1277
- useEffect(() => {
1278
- var _a;
1279
- if (typeof window === "undefined" || !ref.current) return;
1280
- const target = ref.current;
1281
- const extra = (_a = watchRef == null ? void 0 : watchRef.current) != null ? _a : null;
1282
- const parent = target.parentElement;
1283
- const onResize = () => scheduleMeasure();
1284
- const onTransitionOrAnimationEnd = () => scheduleMeasure();
1285
- window.addEventListener("resize", onResize);
1286
- document.addEventListener("transitionend", onTransitionOrAnimationEnd, true);
1287
- document.addEventListener("animationend", onTransitionOrAnimationEnd, true);
1288
- let resizeObserver = null;
1289
- if ("ResizeObserver" in window) {
1290
- resizeObserver = new ResizeObserver(() => scheduleMeasure());
1291
- resizeObserver.observe(target);
1292
- if (parent && parent !== target) {
1293
- resizeObserver.observe(parent);
1294
- }
1295
- if (extra && extra !== target && extra !== parent) {
1296
- resizeObserver.observe(extra);
1297
- }
1298
- }
1299
- return () => {
1300
- window.removeEventListener("resize", onResize);
1301
- document.removeEventListener("transitionend", onTransitionOrAnimationEnd, true);
1302
- document.removeEventListener("animationend", onTransitionOrAnimationEnd, true);
1303
- resizeObserver == null ? void 0 : resizeObserver.disconnect();
1304
- if (raf.current != null) {
1305
- cancelAnimationFrame(raf.current);
1306
- raf.current = null;
1307
- }
1308
- };
1309
- }, [ref, watchRef, scheduleMeasure]);
1310
- const style = useMemo(
1311
- () => ({
1312
- maxHeight,
1313
- overflow: "auto"
1314
- }),
1315
- [maxHeight]
1316
- );
1317
- return {
1318
- maxHeight,
1319
- style,
1320
- recompute: measure
1321
- };
1322
- }
1323
- var defaultEmptyConfig = {
1324
- enabled: true,
1325
- title: "Ingen resultater",
1326
- description: /* @__PURE__ */ jsx("span", { children: "Ingen data at vise." }),
1327
- showBack: false,
1328
- showRefresh: false,
1329
- showClearFilters: true,
1330
- backLabel: /* @__PURE__ */ jsxs(Fragment, { children: [
1331
- /* @__PURE__ */ jsx(ArrowLeft, { size: 16 }),
1332
- "Tilbage"
1333
- ] }),
1334
- refreshLabel: /* @__PURE__ */ jsx(Fragment, { children: "Indl\xE6s igen" }),
1335
- clearFiltersLabel: /* @__PURE__ */ jsx(Fragment, { children: "Nulstil alle filtre" }),
1336
- className: "dbc-flex dbc-flex-column dbc-items-start dbc-justify-start dbc-text-left dbc-gap-sm dbc-py-lg"
1337
- };
1338
- function TableEmptyState({ config }) {
1339
- const merged = {
1340
- ...defaultEmptyConfig,
1341
- ...config != null ? config : {}
1342
- };
1343
- if (!merged.enabled) return null;
1344
- return /* @__PURE__ */ jsxs("div", { className: "dbc-flex dbc-flex-column dbc-gap-md dbc-pt-sm dbc-pb-sm", children: [
1345
- /* @__PURE__ */ jsx("span", { className: "dbc-text-sm dbc-muted-text", children: merged.description }),
1346
- merged.actions ? /* @__PURE__ */ jsx("span", { className: "dbc-flex dbc-gap-sm", children: merged.actions }) : null
1347
- ] });
1348
- }
1349
-
1350
- // src/components/table/Table.module.css
1351
- var Table_default = {
1352
- fillViewportRoot: "Table_fillViewportRoot2",
1353
- inlineRoot: "Table_inlineRoot2",
1354
- toolbarSlot: "Table_toolbarSlot2",
1355
- tableViewport: "Table_tableViewport2",
1356
- paginationSlot: "Table_paginationSlot2",
1357
- paginationSlotTop: "Table_paginationSlotTop2",
1358
- tableRoot: "Table_tableRoot2",
1359
- measuringLayout: "Table_measuringLayout2",
1360
- tableScroll: "Table_tableScroll2",
1361
- tableElement: "Table_tableElement2",
1362
- header: "Table_header2",
1363
- headerRow: "Table_headerRow2",
1364
- row: "Table_row2",
1365
- emptyStateSlot: "Table_emptyStateSlot2",
1366
- body: "Table_body2",
1367
- cell: "Table_cell2",
1368
- headerCell: "Table_headerCell2",
1369
- md: "Table_md2",
1370
- sm: "Table_sm2",
1371
- selectionCell: "Table_selectionCell2",
1372
- selectionHitArea: "Table_selectionHitArea2",
1373
- selectionControlWrap: "Table_selectionControlWrap2",
1374
- clickableRow: "Table_clickableRow2",
1375
- selectedRow: "Table_selectedRow2",
1376
- striped: "Table_striped2",
1377
- nowrap: "Table_nowrap2",
1378
- allowWrap: "Table_allowWrap2",
1379
- thInner: "Table_thInner2",
1380
- thInnerRight: "Table_thInnerRight2",
1381
- thInnerCenter: "Table_thInnerCenter2",
1382
- thMain: "Table_thMain2",
1383
- thMainRight: "Table_thMainRight2",
1384
- thMainCenter: "Table_thMainCenter2",
1385
- thButton: "Table_thButton2",
1386
- thButtonRight: "Table_thButtonRight2",
1387
- thButtonCenter: "Table_thButtonCenter2",
1388
- thLabel: "Table_thLabel2",
1389
- thLabelRight: "Table_thLabelRight2",
1390
- thLabelCenter: "Table_thLabelCenter2",
1391
- thOverlayExtras: "Table_thOverlayExtras2",
1392
- sortIndicator: "Table_sortIndicator2",
1393
- descending: "Table_descending2",
1394
- inActiveSort: "Table_inActiveSort2",
1395
- cellContent: "Table_cellContent2",
1396
- cellValueEllipsis: "Table_cellValueEllipsis2",
1397
- severityTable: "Table_severityTable2",
1398
- severity: "Table_severity2",
1399
- severityFailed: "Table_severityFailed2",
1400
- dividerLeft: "Table_dividerLeft2",
1401
- dividerRight: "Table_dividerRight2"
1402
- };
1403
-
1404
- // src/components/table/table.classes.ts
1405
- function cx2(...values) {
1406
- return values.filter(Boolean).join(" ");
1407
- }
1408
- function getDividerClass(column) {
1409
- if (column.divider === "left") return Table_default.dividerLeft;
1410
- if (column.divider === "right") return Table_default.dividerRight;
1411
- return "";
1412
- }
1413
- function getAlignValue(column) {
1414
- var _a;
1415
- return (_a = column.align) != null ? _a : "left";
1416
- }
1417
- function getHeaderAlignClasses(align) {
1418
- return {
1419
- inner: cx2(
1420
- Table_default.thInner,
1421
- align === "right" && Table_default.thInnerRight,
1422
- align === "center" && Table_default.thInnerCenter
1423
- ),
1424
- main: cx2(
1425
- Table_default.thMain,
1426
- align === "right" && Table_default.thMainRight,
1427
- align === "center" && Table_default.thMainCenter
1428
- ),
1429
- button: cx2(
1430
- Table_default.thButton,
1431
- align === "right" && Table_default.thButtonRight,
1432
- align === "center" && Table_default.thButtonCenter
1433
- ),
1434
- label: cx2(
1435
- Table_default.thLabel,
1436
- align === "right" && Table_default.thLabelRight,
1437
- align === "center" && Table_default.thLabelCenter
1438
- )
1439
- };
1440
- }
1441
-
1442
- // src/constants/severity.ts
1443
- var SeverityBorderColor = {
1444
- neutral: "var(--color-neutral-strong)",
1445
- brand: "var(--color-brand)",
1446
- success: "var(--color-status-success-border)",
1447
- error: "var(--color-status-error-border)",
1448
- info: "var(--color-status-info-border)",
1449
- warning: "var(--color-status-warning-border)"
1450
- };
1451
-
1452
- // src/components/table/table.utils.ts
1453
- var SELECTION_COLUMN_PX = 40;
1454
- var DEFAULT_COLUMN_PX = 150;
1455
- function getVisibleColumns(columns) {
1456
- return columns.filter((column) => !column.hidden);
1457
- }
1458
- function getHeaderLabel(header) {
1459
- return typeof header === "function" ? header() : header;
1460
- }
1461
- function isActiveSort(sortById, columnId) {
1462
- return sortById === columnId;
1463
- }
1464
- function getAriaSort(sortable, active, direction) {
1465
- if (!sortable || !active || !direction) return "none";
1466
- return direction === "asc" ? "ascending" : "descending";
1467
- }
1468
- function getNextSortDirection(sortable, active, currentDirection) {
1469
- if (!sortable) return null;
1470
- if (!active) return "asc";
1471
- if (currentDirection === "asc") return "desc";
1472
- return null;
1473
- }
1474
- function shouldToggleOnKey(key) {
1475
- return key === "Enter" || key === " ";
1476
- }
1477
- function isModifierClick(e) {
1478
- return Boolean(e.metaKey || e.ctrlKey);
1479
- }
1480
- function shouldAllowWrap(columnAllowWrap, isRowSelected, viewMode) {
1481
- return Boolean(columnAllowWrap || isRowSelected || viewMode === "wrapped");
1482
- }
1483
- function getCellDisplayValue(row, column) {
1484
- var _a;
1485
- const empty = (_a = column.emptyPlaceholder) != null ? _a : "";
1486
- if (column.render) {
1487
- const rendered = column.render(row);
1488
- return rendered != null ? rendered : empty;
1489
- }
1490
- if (column.accessor) {
1491
- const value = row[column.accessor];
1492
- return value != null ? value : empty;
1493
- }
1494
- return empty;
1495
- }
1496
-
1497
- // src/components/table/hooks/useTableRowInteractions.ts
1498
- function useTableRowInteractions({
1499
- row,
1500
- rowId,
1501
- isSelected,
1502
- canSelect,
1503
- onRowClick,
1504
- onRowSelect
1505
- }) {
1506
- const handleRowClick = useCallback(
1507
- (e) => {
1508
- var _a;
1509
- const target = e.target;
1510
- if ((_a = target == null ? void 0 : target.closest) == null ? void 0 : _a.call(target, '[data-selection-control="true"]')) {
1511
- return;
1512
- }
1513
- if (isModifierClick(e) && canSelect) {
1514
- e.preventDefault();
1515
- e.stopPropagation();
1516
- onRowSelect == null ? void 0 : onRowSelect(rowId, !isSelected);
1517
- return;
1518
- }
1519
- onRowClick == null ? void 0 : onRowClick(row);
1520
- },
1521
- [canSelect, isSelected, onRowClick, onRowSelect, row, rowId]
1522
- );
1523
- const handleRowKeyDown = useCallback(
1524
- (e) => {
1525
- if (!onRowClick) return;
1526
- if (!shouldToggleOnKey(e.key)) return;
1527
- e.preventDefault();
1528
- onRowClick(row);
1529
- },
1530
- [onRowClick, row]
1531
- );
1532
- return {
1533
- handleRowClick,
1534
- handleRowKeyDown
1535
- };
1536
- }
1537
- function TableRow({
1538
- row,
1539
- rowId,
1540
- columns,
1541
- selectedRows,
1542
- hasSelection,
1543
- selectionMode,
1544
- selectionInputName,
1545
- viewMode,
1546
- getRowSeverity,
1547
- onRowClick,
1548
- onRowMouseEnter,
1549
- onRowSelect
1550
- }) {
1551
- var _a;
1552
- const isSelected = (_a = selectedRows == null ? void 0 : selectedRows.has(rowId)) != null ? _a : false;
1553
- const rowSeverity = getRowSeverity == null ? void 0 : getRowSeverity(row);
1554
- const canSelect = Boolean(selectedRows && onRowSelect);
1555
- const { handleRowClick, handleRowKeyDown } = useTableRowInteractions({
1556
- row,
1557
- rowId,
1558
- isSelected,
1559
- canSelect,
1560
- onRowClick,
1561
- onRowSelect
1562
- });
1563
- return /* @__PURE__ */ jsxs(
1564
- "tr",
1565
- {
1566
- className: cx2(
1567
- Table_default.row,
1568
- onRowClick && Table_default.clickableRow,
1569
- isSelected && Table_default.selectedRow,
1570
- rowSeverity && Table_default.severity
1571
- ),
1572
- style: {
1573
- ["--row-severity-color"]: rowSeverity ? SeverityBorderColor[rowSeverity] : void 0
1574
- },
1575
- tabIndex: onRowClick ? 0 : -1,
1576
- onKeyDown: handleRowKeyDown,
1577
- onMouseEnter: () => onRowMouseEnter == null ? void 0 : onRowMouseEnter(row),
1578
- onClick: handleRowClick,
1579
- children: [
1580
- hasSelection ? /* @__PURE__ */ jsx("td", { className: cx2(Table_default.cell, Table_default.selectionCell), "data-selection-control": "true", children: /* @__PURE__ */ jsx(
1581
- "div",
1582
- {
1583
- className: Table_default.selectionHitArea,
1584
- "data-selection-control": "true",
1585
- onClick: (e) => {
1586
- if (e.target !== e.currentTarget) return;
1587
- e.stopPropagation();
1588
- onRowSelect == null ? void 0 : onRowSelect(rowId, !isSelected);
1589
- },
1590
- children: /* @__PURE__ */ jsx(
1591
- "div",
1592
- {
1593
- className: Table_default.selectionControlWrap,
1594
- "data-selection-control": "true",
1595
- onMouseDown: (e) => {
1596
- if (selectionMode !== "single" || !isSelected) return;
1597
- e.preventDefault();
1598
- },
1599
- onClick: (e) => {
1600
- e.stopPropagation();
1601
- if (selectionMode === "single" && isSelected) {
1602
- e.preventDefault();
1603
- onRowSelect == null ? void 0 : onRowSelect(rowId, false);
1604
- }
1605
- },
1606
- children: selectionMode === "single" ? /* @__PURE__ */ jsx(
1607
- RadioButton,
1608
- {
1609
- noContainer: true,
1610
- name: selectionInputName,
1611
- value: String(rowId),
1612
- checked: isSelected,
1613
- size: "sm",
1614
- variant: "primary",
1615
- onChange: (_value, e) => {
1616
- e.stopPropagation();
1617
- onRowSelect == null ? void 0 : onRowSelect(rowId, true);
1618
- }
1619
- }
1620
- ) : /* @__PURE__ */ jsx(
1621
- Checkbox,
1622
- {
1623
- noContainer: true,
1624
- variant: "primary",
1625
- checked: isSelected,
1626
- size: "sm",
1627
- onChange: (checked, e) => {
1628
- e.stopPropagation();
1629
- onRowSelect == null ? void 0 : onRowSelect(rowId, checked);
1630
- }
1631
- }
1632
- )
1633
- }
1634
- )
1635
- }
1636
- ) }) : null,
1637
- columns.map((column) => {
1638
- var _a2, _b, _c, _d;
1639
- const allowWrap = shouldAllowWrap(column.allowWrap, isSelected, viewMode);
1640
- column.allowOverflow;
1641
- const cellValue = getCellDisplayValue(row, column);
1642
- return /* @__PURE__ */ jsx(
1643
- "td",
1644
- {
1645
- className: cx2(
1646
- Table_default.cell,
1647
- allowWrap ? Table_default.allowWrap : Table_default.nowrap,
1648
- column.divider === "left" && Table_default.dividerLeft,
1649
- column.divider === "right" && Table_default.dividerRight
1650
- ),
1651
- "data-align": (_a2 = column.align) != null ? _a2 : "left",
1652
- "data-vertical-align": (_b = column.verticalAlign) != null ? _b : "top",
1653
- "data-divider": column.divider,
1654
- children: /* @__PURE__ */ jsx(
1655
- "div",
1656
- {
1657
- className: Table_default.cellContent,
1658
- "data-align": (_c = column.align) != null ? _c : "left",
1659
- "data-vertical-align": (_d = column.verticalAlign) != null ? _d : "top",
1660
- children: /* @__PURE__ */ jsx("div", { className: Table_default.cellValueEllipsis, children: cellValue })
1661
- }
1662
- )
1663
- },
1664
- column.id
1665
- );
1666
- })
1667
- ]
1668
- }
1669
- );
1670
- }
1671
- function TableBody({
1672
- data,
1673
- dataKey,
1674
- columns,
1675
- striped,
1676
- selectedRows,
1677
- hasSelection,
1678
- selectionMode,
1679
- selectionInputName,
1680
- viewMode,
1681
- getRowSeverity,
1682
- onRowClick,
1683
- onRowMouseEnter,
1684
- onRowSelect
1685
- }) {
1686
- return /* @__PURE__ */ jsx("tbody", { className: cx2(Table_default.body, striped && Table_default.striped), children: data.map((row) => {
1687
- const rowId = row[dataKey];
1688
- return /* @__PURE__ */ jsx(
1689
- TableRow,
1690
- {
1691
- row,
1692
- rowId,
1693
- columns,
1694
- selectedRows,
1695
- hasSelection,
1696
- selectionMode,
1697
- selectionInputName,
1698
- viewMode,
1699
- getRowSeverity,
1700
- onRowClick,
1701
- onRowMouseEnter,
1702
- onRowSelect
1703
- },
1704
- `gridRow-${rowId}`
1705
- );
1706
- }) });
1707
- }
1708
- function TableHeaderCell({
1709
- column,
1710
- index,
1711
- sortById,
1712
- sortDirection,
1713
- onSortChange,
1714
- extraContent
1715
- }) {
1716
- const active = isActiveSort(sortById, column.id);
1717
- const ariaSort = getAriaSort(column.sortable, active, sortDirection != null ? sortDirection : null);
1718
- const align = getAlignValue(column);
1719
- const dividerClass = getDividerClass(column);
1720
- const alignClasses = getHeaderAlignClasses(align);
1721
- const handleToggleSort = () => {
1722
- if (!column.sortable || !onSortChange) return;
1723
- const nextDirection = getNextSortDirection(column.sortable, active, sortDirection != null ? sortDirection : null);
1724
- onSortChange(column, nextDirection);
1725
- };
1726
- return /* @__PURE__ */ jsxs(
1727
- "th",
1728
- {
1729
- className: cx2(Table_default.headerCell, dividerClass),
1730
- scope: "col",
1731
- "aria-sort": ariaSort,
1732
- "data-align": align,
1733
- "data-divider": column.divider,
1734
- "data-column-index": index,
1735
- children: [
1736
- /* @__PURE__ */ jsx("div", { className: alignClasses.inner, children: /* @__PURE__ */ jsx("div", { className: alignClasses.main, children: column.sortable ? /* @__PURE__ */ jsxs(
1737
- "button",
1738
- {
1739
- type: "button",
1740
- className: alignClasses.button,
1741
- onClick: handleToggleSort,
1742
- onKeyDown: (e) => {
1743
- if (!shouldToggleOnKey(e.key)) return;
1744
- e.preventDefault();
1745
- handleToggleSort();
1746
- },
1747
- children: [
1748
- /* @__PURE__ */ jsx("span", { className: alignClasses.label, children: getHeaderLabel(column.header) }),
1749
- /* @__PURE__ */ jsxs("span", { className: Table_default.sortIndicator, "aria-hidden": "true", children: [
1750
- active && sortDirection === "asc" && /* @__PURE__ */ jsx(ArrowUp, {}),
1751
- active && sortDirection === "desc" && /* @__PURE__ */ jsx(ArrowDown, {}),
1752
- !active && /* @__PURE__ */ jsx(ArrowDown, { className: Table_default.inActiveSort })
1753
- ] })
1754
- ]
1755
- }
1756
- ) : /* @__PURE__ */ jsx("span", { className: alignClasses.label, children: getHeaderLabel(column.header) }) }) }),
1757
- extraContent != null ? /* @__PURE__ */ jsx("div", { className: Table_default.thOverlayExtras, children: extraContent }) : null
1758
- ]
1759
- },
1760
- column.id
1761
- );
1762
- }
1763
- function TableSelectionCell({ checked, isHeader, multiple, onToggle }) {
1764
- const Tag = isHeader ? "th" : "td";
1765
- return /* @__PURE__ */ jsx(
1766
- Tag,
1767
- {
1768
- className: cx2(Table_default.headerCell, Table_default.selectionCell),
1769
- scope: isHeader ? "col" : void 0,
1770
- onClick: (e) => {
1771
- if (isHeader && !multiple) return;
1772
- e.stopPropagation();
1773
- onToggle(!checked, e);
1774
- },
1775
- children: isHeader && !multiple ? null : /* @__PURE__ */ jsx("div", { className: Table_default.selectionHitArea, children: /* @__PURE__ */ jsx(
1776
- Checkbox,
1777
- {
1778
- noContainer: true,
1779
- size: "sm",
1780
- variant: "primary",
1781
- checked,
1782
- onChange: (nextChecked, e) => {
1783
- e.stopPropagation();
1784
- onToggle(nextChecked, e);
1785
- }
1786
- }
1787
- ) })
1788
- }
1789
- );
1790
- }
1791
- function TableHeader({
1792
- columns,
1793
- hasSelection,
1794
- selectionMode,
1795
- allRowsSelected,
1796
- onSelectAllRows,
1797
- sortById,
1798
- sortDirection,
1799
- onSortChange,
1800
- headerExtras,
1801
- stickyTop
1802
- }) {
1803
- return /* @__PURE__ */ jsx(
1804
- "thead",
1805
- {
1806
- className: Table_default.header,
1807
- style: stickyTop ? { top: stickyTop, position: "sticky", zIndex: 2 } : void 0,
1808
- children: /* @__PURE__ */ jsxs("tr", { className: Table_default.headerRow, children: [
1809
- hasSelection ? /* @__PURE__ */ jsx(
1810
- TableSelectionCell,
1811
- {
1812
- isHeader: true,
1813
- multiple: selectionMode === "multiple",
1814
- checked: allRowsSelected,
1815
- onToggle: (checked) => onSelectAllRows == null ? void 0 : onSelectAllRows(checked)
1816
- }
1817
- ) : null,
1818
- columns.map((column, index) => /* @__PURE__ */ jsx(
1819
- TableHeaderCell,
1820
- {
1821
- column,
1822
- index,
1823
- sortById,
1824
- sortDirection,
1825
- onSortChange,
1826
- extraContent: headerExtras == null ? void 0 : headerExtras({ column, index })
1827
- },
1828
- column.id
1829
- ))
1830
- ] })
1831
- }
1832
- );
1833
- }
1834
-
1835
- // src/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.module.css
1836
- var SkeletonLoaderItem_default = {
1837
- skeletonLoader: "SkeletonLoaderItem_skeletonLoader2",
1838
- shimmer: "SkeletonLoaderItem_shimmer2",
1839
- invert: "SkeletonLoaderItem_invert2",
1840
- bar: "SkeletonLoaderItem_bar2"
1841
- };
1842
- function SkeletonLoaderItem({
1843
- height = 14,
1844
- width = "100%",
1845
- radius = 6,
1846
- speedSec = 3,
1847
- ariaLabel = "Loading",
1848
- variant = "default"
1849
- }) {
1850
- const h = typeof height === "number" ? `${height}px` : height;
1851
- const w = typeof width === "number" ? `${width}px` : width;
1852
- const r = typeof radius === "number" ? `${radius}px` : radius;
1853
- return /* @__PURE__ */ jsxs(
1854
- "div",
1855
- {
1856
- className: `${SkeletonLoaderItem_default.skeletonLoader} ${SkeletonLoaderItem_default[variant]}`,
1857
- role: "status",
1858
- "aria-label": ariaLabel,
1859
- "aria-live": "polite",
1860
- style: {
1861
- ["--h"]: h,
1862
- ["--r"]: r,
1863
- ["--speed"]: `${speedSec}s`,
1864
- ["--width"]: w
1865
- },
1866
- children: [
1867
- /* @__PURE__ */ jsx("span", { className: SkeletonLoaderItem_default.bar, "aria-hidden": "true" }),
1868
- /* @__PURE__ */ jsx("span", { className: "srOnly", children: "Loading\u2026" })
1869
- ]
1870
- }
1871
- );
1872
- }
1873
- function TableLoadingBody({ rows, columns, hasSelection }) {
1874
- return /* @__PURE__ */ jsx("tbody", { className: Table_default.body, children: Array.from({ length: rows }).map((_, rowIndex) => /* @__PURE__ */ jsxs("tr", { className: Table_default.row, children: [
1875
- hasSelection ? /* @__PURE__ */ jsx("td", { className: cx2(Table_default.cell, Table_default.selectionCell), children: /* @__PURE__ */ jsx("div", { className: Table_default.cellContent, children: /* @__PURE__ */ jsx(SkeletonLoaderItem, { height: 20, width: 20 }) }) }) : null,
1876
- columns.map((column) => {
1877
- var _a;
1878
- return /* @__PURE__ */ jsx(
1879
- "td",
1880
- {
1881
- className: cx2(
1882
- Table_default.cell,
1883
- column.divider === "left" && Table_default.dividerLeft,
1884
- column.divider === "right" && Table_default.dividerRight
1885
- ),
1886
- "data-align": (_a = column.align) != null ? _a : "left",
1887
- "data-divider": column.divider,
1888
- children: /* @__PURE__ */ jsx("div", { className: Table_default.cellContent, children: /* @__PURE__ */ jsx("div", { className: Table_default.cellValueEllipsis, children: /* @__PURE__ */ jsx(SkeletonLoaderItem, { height: 20, width: "100%" }) }) })
1889
- },
1890
- column.id
1891
- );
1892
- })
1893
- ] }, `loading-row-${rowIndex}`)) });
1894
- }
1895
- function Table({
1896
- data,
1897
- dataKey,
1898
- columns,
1899
- selectedRows,
1900
- selectionMode = "single",
1901
- allRowsSelected,
1902
- sortById,
1903
- sortDirection,
1904
- loading,
1905
- emptyConfig,
1906
- variant = "primary",
1907
- size = "md",
1908
- viewMode,
1909
- striped,
1910
- fillViewport = false,
1911
- fillViewportBottomOffset = 16,
1912
- containScrolling = true,
1913
- stickyHeader,
1914
- tableWidth,
1915
- tableRootRef,
1916
- measuringLayout = false,
1917
- toolbar,
1918
- headerExtras,
1919
- take,
1920
- skip,
1921
- totalItemsCount,
1922
- paginationPlacement = "bottom",
1923
- showFirstLast = false,
1924
- pageSizeOptions,
1925
- getRowSeverity,
1926
- onRowClick,
1927
- onRowMouseEnter,
1928
- onRowSelect,
1929
- onSelectAllRows,
1930
- onSortChange,
1931
- onPageChange,
1932
- ...rest
1933
- }) {
1934
- const visibleColumns = useMemo(() => getVisibleColumns(columns), [columns]);
1935
- const selectionInputName = useId();
1936
- const internalTableRootRef = useRef(null);
1937
- const tableRootRefWrapper = useRef(tableRootRef);
1938
- const hasSelection = Boolean(selectedRows && onRowSelect);
1939
- const hasPagination = Boolean(onPageChange && (loading || data.length > 0));
1940
- const paginationOffset = hasPagination ? 72 : 0;
1941
- const { style: viewportFillStyle, maxHeight } = useViewportFill(internalTableRootRef, {
1942
- bottomOffset: fillViewportBottomOffset + paginationOffset,
1943
- min: 0
1944
- });
1945
- const fillViewportActive = fillViewport && containScrolling && maxHeight >= 500;
1946
- const stickyTop = stickyHeader === "app-header" ? "var(--app-header-height, 60px)" : typeof stickyHeader === "number" ? `${stickyHeader}px` : void 0;
1947
- const setTableRootRef = useCallback((node) => {
1948
- internalTableRootRef.current = node;
1949
- if (typeof tableRootRefWrapper.current === "function") {
1950
- tableRootRefWrapper.current(node);
1951
- } else if (tableRootRefWrapper.current) {
1952
- tableRootRefWrapper.current.current = node;
1953
- }
1954
- }, []);
1955
- const handlePageChange = useCallback(
1956
- (e) => {
1957
- onPageChange == null ? void 0 : onPageChange(e);
1958
- },
1959
- [onPageChange]
1960
- );
1961
- const bodyContent = loading && !data.length ? /* @__PURE__ */ jsx(TableLoadingBody, { rows: take != null ? take : 5, columns: visibleColumns, hasSelection }) : /* @__PURE__ */ jsx(
1962
- TableBody,
1963
- {
1964
- data,
1965
- dataKey,
1966
- columns: visibleColumns,
1967
- striped,
1968
- selectedRows,
1969
- hasSelection,
1970
- selectionMode,
1971
- selectionInputName,
1972
- viewMode,
1973
- getRowSeverity,
1974
- onRowClick,
1975
- onRowMouseEnter,
1976
- onRowSelect
1977
- }
1978
- );
1979
- const paginationEl = hasPagination ? /* @__PURE__ */ jsx(
1980
- "div",
1981
- {
1982
- className: cx2(
1983
- Table_default.paginationSlot,
1984
- paginationPlacement === "top" && Table_default.paginationSlotTop
1985
- ),
1986
- children: /* @__PURE__ */ jsx(
1987
- Pagination,
1988
- {
1989
- itemsCount: totalItemsCount,
1990
- take,
1991
- skip,
1992
- onPageChange: handlePageChange,
1993
- showFirstLast,
1994
- pageSizeOptions
1995
- }
1996
- )
1997
- }
1998
- ) : null;
1999
- const tableClassName = cx2(
2000
- Table_default.tableRoot,
2001
- Table_default[variant],
2002
- Table_default[size],
2003
- measuringLayout && Table_default.measuringLayout,
2004
- getRowSeverity && Table_default.severityTable
2005
- );
2006
- const tableShell = /* @__PURE__ */ jsx("div", { ...rest, className: tableClassName, children: /* @__PURE__ */ jsx(
2007
- "div",
2008
- {
2009
- ref: setTableRootRef,
2010
- className: Table_default.tableScroll,
2011
- style: fillViewportActive ? viewportFillStyle : !containScrolling ? { overflow: "visible" } : void 0,
2012
- children: !data.length && !loading ? /* @__PURE__ */ jsx("div", { className: Table_default.emptyStateSlot, children: /* @__PURE__ */ jsx(TableEmptyState, { config: emptyConfig }) }) : /* @__PURE__ */ jsxs(
2013
- "table",
2014
- {
2015
- className: Table_default.tableElement,
2016
- "aria-rowcount": data.length,
2017
- style: tableWidth != null ? { width: tableWidth } : void 0,
2018
- children: [
2019
- /* @__PURE__ */ jsxs("colgroup", { children: [
2020
- hasSelection ? /* @__PURE__ */ jsx("col", { style: { width: SELECTION_COLUMN_PX } }) : null,
2021
- visibleColumns.map((column) => /* @__PURE__ */ jsx(
2022
- "col",
2023
- {
2024
- style: column.width != null ? { width: column.width } : void 0
2025
- },
2026
- column.id
2027
- ))
2028
- ] }),
2029
- /* @__PURE__ */ jsx(
2030
- TableHeader,
2031
- {
2032
- columns: visibleColumns,
2033
- hasSelection,
2034
- selectionMode,
2035
- allRowsSelected,
2036
- onSelectAllRows,
2037
- sortById,
2038
- sortDirection,
2039
- onSortChange,
2040
- headerExtras,
2041
- stickyTop
2042
- }
2043
- ),
2044
- bodyContent
2045
- ]
2046
- }
2047
- )
2048
- }
2049
- ) });
2050
- if (fillViewport) {
2051
- return /* @__PURE__ */ jsxs(
2052
- "div",
2053
- {
2054
- className: Table_default.fillViewportRoot,
2055
- style: {
2056
- flexDirection: paginationPlacement === "top" ? "column-reverse" : "column",
2057
- ...!fillViewportActive && { blockSize: "auto", overflow: "visible" }
2058
- },
2059
- children: [
2060
- toolbar ? /* @__PURE__ */ jsx("div", { className: Table_default.toolbarSlot, children: toolbar }) : null,
2061
- /* @__PURE__ */ jsx(
2062
- "div",
2063
- {
2064
- className: Table_default.tableViewport,
2065
- style: !fillViewportActive ? { overflow: "visible" } : void 0,
2066
- children: tableShell
2067
- }
2068
- ),
2069
- paginationEl
2070
- ]
2071
- }
2072
- );
2073
- }
2074
- return /* @__PURE__ */ jsxs(
2075
- "div",
2076
- {
2077
- className: "dbc-flex dbc-flex-column dbc-gap-md",
2078
- style: {
2079
- flexFlow: paginationPlacement === "top" ? "column-reverse" : "column",
2080
- position: "relative"
2081
- },
2082
- children: [
2083
- toolbar ? /* @__PURE__ */ jsx("div", { className: Table_default.toolbarSlot, children: toolbar }) : null,
2084
- tableShell,
2085
- paginationEl
2086
- ]
2087
- }
2088
- );
2089
- }
2090
-
2091
- // src/components/table/tanstackTable.utils.ts
2092
- function getColumnId(def, index) {
2093
- const d = def;
2094
- if (d.id != null && String(d.id).length > 0) return String(d.id);
2095
- if (d.accessorKey != null && String(d.accessorKey).length > 0) return String(d.accessorKey);
2096
- return `col_${index}`;
2097
- }
2098
- function buildColumnVisibilityFromVisibleIds(defs, visibleColumnIds) {
2099
- if (!(visibleColumnIds == null ? void 0 : visibleColumnIds.length)) return {};
2100
- const visible = new Set(visibleColumnIds);
2101
- const next = {};
2102
- defs.forEach((def, index) => {
2103
- const id = getColumnId(def, index);
2104
- next[id] = visible.has(id);
2105
- });
2106
- return next;
2107
- }
2108
- function mapDefsToColumnItems(defs, columnVisibility, resolvedLayout = {}) {
2109
- return defs.map((def, index) => {
2110
- var _a, _b, _c, _d, _e, _f, _g;
2111
- const id = getColumnId(def, index);
2112
- const accessorKey = def.accessorKey;
2113
- const accessorFn = def.accessorFn;
2114
- const cell = def.cell;
2115
- const meta = (_a = def.meta) != null ? _a : {};
2116
- let render;
2117
- if (typeof cell === "function") {
2118
- render = (row) => cell({
2119
- row: { original: row },
2120
- getValue: () => accessorKey != null ? row[accessorKey] : accessorFn ? accessorFn(row) : void 0
2121
- });
2122
- } else if (accessorFn) {
2123
- render = (row) => accessorFn(row);
2124
- } else if (accessorKey != null) {
2125
- render = (row) => row[accessorKey];
2126
- } else {
2127
- render = () => null;
2128
- }
2129
- const isVisible = (_b = columnVisibility[id]) != null ? _b : true;
2130
- return {
2131
- id,
2132
- header: def.header,
2133
- accessor: accessorKey,
2134
- sortable: (_c = def.enableSorting) != null ? _c : !!accessorKey,
2135
- render,
2136
- hidden: !isVisible,
2137
- width: (_d = resolvedLayout[id]) == null ? void 0 : _d.width,
2138
- align: meta.align,
2139
- verticalAlign: meta.verticalAlign,
2140
- emptyPlaceholder: (_e = meta.emptyPlaceholder) != null ? _e : "-",
2141
- allowWrap: (_f = meta.allowWrap) != null ? _f : false,
2142
- severity: meta.severity,
2143
- divider: meta.divider,
2144
- allowOverflow: (_g = meta.allowOverflow) != null ? _g : false
2145
- };
2146
- });
2147
- }
2148
- function sortingEqual(a, b) {
2149
- const A = a == null ? void 0 : a[0];
2150
- const B = b == null ? void 0 : b[0];
2151
- if (!A && !B) return true;
2152
- if (!A || !B) return false;
2153
- return A.id === B.id && A.desc === B.desc;
2154
- }
2155
- function getSortPropsFromSorting(sorting) {
2156
- const s = sorting == null ? void 0 : sorting[0];
2157
- return {
2158
- sortById: s == null ? void 0 : s.id,
2159
- sortDirection: s ? s.desc ? "desc" : "asc" : null
2160
- };
2161
- }
2162
- function clamp(value, min, max) {
2163
- const lowerBounded = Math.max(min, value);
2164
- if (max == null || !Number.isFinite(max)) return lowerBounded;
2165
- return Math.min(lowerBounded, max);
2166
- }
2167
- function toIntegerTrackWidths(tracks, targetWidth) {
2168
- const floored = tracks.map((track) => ({
2169
- id: track.id,
2170
- width: Math.floor(track.width),
2171
- fraction: track.width - Math.floor(track.width)
2172
- }));
2173
- const baseTotal = floored.reduce((sum, track) => sum + track.width, 0);
2174
- let remainder = Math.max(0, targetWidth - baseTotal);
2175
- floored.slice().sort((a, b) => b.fraction - a.fraction).forEach((track) => {
2176
- if (remainder <= 0) return;
2177
- track.width += 1;
2178
- remainder -= 1;
2179
- });
2180
- return Object.fromEntries(floored.map((track) => [track.id, track.width]));
2181
- }
2182
- function buildDistributedColumnWidths(args) {
2183
- const { table, hasSelection, defaultMinPx, columnSizing, availableWidth } = args;
2184
- const leaf = table.getVisibleLeafColumns();
2185
- const selectionWidth = hasSelection ? SELECTION_COLUMN_PX : 0;
2186
- const tracks = leaf.map((c) => {
2187
- var _a, _b, _c, _d;
2188
- const def = c.columnDef;
2189
- const meta = (_a = def.meta) != null ? _a : {};
2190
- const min = Math.max(1, Number((_b = def.minSize) != null ? _b : defaultMinPx));
2191
- const max = def.maxSize != null ? Math.max(min, Number(def.maxSize)) : void 0;
2192
- const resizedPxRaw = columnSizing[c.id];
2193
- const resizedPx = resizedPxRaw != null ? Math.round(clamp(Number(resizedPxRaw), min, max)) : void 0;
2194
- if (resizedPx != null) {
2195
- return {
2196
- id: c.id,
2197
- width: resizedPx,
2198
- weight: 0,
2199
- max: resizedPx,
2200
- fixed: true
2201
- };
2202
- }
2203
- const rawWeight = Number((_d = (_c = meta.weight) != null ? _c : def.size) != null ? _d : DEFAULT_COLUMN_PX);
2204
- const weight = Number.isFinite(rawWeight) && rawWeight > 0 ? rawWeight : DEFAULT_COLUMN_PX;
2205
- return {
2206
- id: c.id,
2207
- width: min,
2208
- weight,
2209
- max,
2210
- fixed: false
2211
- };
2212
- });
2213
- const fixedWidth = selectionWidth + tracks.reduce((sum, track) => sum + track.width, 0);
2214
- let remaining = Math.max(0, availableWidth - fixedWidth);
2215
- let active = tracks.filter(
2216
- (track) => !track.fixed && (track.max == null || track.width < track.max)
2217
- );
2218
- while (remaining > 0.5 && active.length > 0) {
2219
- const totalWeight = active.reduce((sum, track) => sum + track.weight, 0);
2220
- if (totalWeight <= 0) break;
2221
- let consumed = 0;
2222
- const nextActive = [];
2223
- for (const track of active) {
2224
- const share = remaining * track.weight / totalWeight;
2225
- const maxGrow = track.max == null ? share : Math.max(0, track.max - track.width);
2226
- const growth = Math.min(share, maxGrow);
2227
- track.width += growth;
2228
- consumed += growth;
2229
- if (track.max == null || track.width < track.max - 0.5) {
2230
- nextActive.push(track);
2231
- }
2232
- }
2233
- if (consumed <= 0.5) break;
2234
- remaining -= consumed;
2235
- active = nextActive;
2236
- }
2237
- const floatTrackTotal = tracks.reduce((sum, track) => sum + track.width, 0);
2238
- const targetTrackWidth = floatTrackTotal <= availableWidth - selectionWidth ? Math.floor(floatTrackTotal) : Math.ceil(floatTrackTotal);
2239
- const widths = toIntegerTrackWidths(tracks, targetTrackWidth);
2240
- const totalWidth = selectionWidth + Object.values(widths).reduce((sum, width) => sum + width, 0);
2241
- return {
2242
- selectionWidth: hasSelection ? SELECTION_COLUMN_PX : void 0,
2243
- widths,
2244
- totalWidth
2245
- };
2246
- }
2247
- function TanstackTable(props) {
2248
- const {
2249
- data,
2250
- dataKey,
2251
- columns,
2252
- sorting: controlledSorting,
2253
- onSortingChange,
2254
- optimisticSortingUi = true,
2255
- visibleColumnIds,
2256
- manualSorting,
2257
- selectedRows,
2258
- onRowSelect,
2259
- ...tableProps
2260
- } = props;
2261
- const isControlledSorting = controlledSorting != null;
2262
- const [uiSorting, setUiSorting] = React8.useState(controlledSorting != null ? controlledSorting : []);
2263
- React8.useEffect(() => {
2264
- if (!isControlledSorting) return;
2265
- if (sortingEqual(uiSorting, controlledSorting)) return;
2266
- setUiSorting(controlledSorting);
2267
- }, [isControlledSorting, controlledSorting, uiSorting]);
2268
- const columnVisibility = React8.useMemo(
2269
- () => buildColumnVisibilityFromVisibleIds(columns, visibleColumnIds),
2270
- [columns, visibleColumnIds]
2271
- );
2272
- const [columnSizing, setColumnSizing] = React8.useState({});
2273
- const containerRef = React8.useRef(null);
2274
- const [availableWidth, setAvailableWidth] = React8.useState(void 0);
2275
- const table = useReactTable({
2276
- data,
2277
- columns,
2278
- state: {
2279
- sorting: uiSorting,
2280
- columnSizing,
2281
- columnVisibility
2282
- },
2283
- onSortingChange: (updater) => {
2284
- const next = typeof updater === "function" ? updater(uiSorting) : updater;
2285
- if (optimisticSortingUi) setUiSorting(next);
2286
- onSortingChange == null ? void 0 : onSortingChange(next);
2287
- },
2288
- onColumnSizingChange: setColumnSizing,
2289
- getCoreRowModel: getCoreRowModel(),
2290
- getSortedRowModel: getSortedRowModel(),
2291
- manualSorting: manualSorting != null ? manualSorting : false,
2292
- enableColumnResizing: true,
2293
- columnResizeMode: "onChange",
2294
- defaultColumn: {
2295
- enableResizing: true,
2296
- minSize: 80,
2297
- size: DEFAULT_COLUMN_PX
2298
- }
2299
- });
2300
- React8.useLayoutEffect(() => {
2301
- const el = containerRef.current;
2302
- if (!el) return;
2303
- const updateWidth = () => {
2304
- const next = el.clientWidth;
2305
- setAvailableWidth(next > 0 ? next : void 0);
2306
- };
2307
- updateWidth();
2308
- if (typeof ResizeObserver === "undefined") {
2309
- window.addEventListener("resize", updateWidth);
2310
- return () => window.removeEventListener("resize", updateWidth);
2311
- }
2312
- const observer = new ResizeObserver(() => updateWidth());
2313
- observer.observe(el);
2314
- return () => observer.disconnect();
2315
- }, []);
2316
- const distributedLayout = React8.useMemo(() => {
2317
- if (availableWidth == null) return null;
2318
- return buildDistributedColumnWidths({
2319
- table,
2320
- hasSelection: Boolean(selectedRows && onRowSelect && dataKey),
2321
- defaultMinPx: 80,
2322
- columnSizing,
2323
- availableWidth
2324
- });
2325
- }, [table, selectedRows, onRowSelect, dataKey, columnSizing, availableWidth]);
2326
- const initialLayoutReady = availableWidth != null;
2327
- const resolvedLayout = React8.useMemo(() => {
2328
- const next = {};
2329
- table.getVisibleLeafColumns().forEach((column) => {
2330
- next[column.id] = {
2331
- width: distributedLayout == null ? void 0 : distributedLayout.widths[column.id]
2332
- };
2333
- });
2334
- return next;
2335
- }, [table, distributedLayout]);
2336
- const columnItems = React8.useMemo(
2337
- () => mapDefsToColumnItems(columns, columnVisibility, resolvedLayout),
2338
- [columns, columnVisibility, resolvedLayout]
2339
- );
2340
- const visibleData = table.getRowModel().rows.map((r) => r.original);
2341
- const { sortById, sortDirection } = getSortPropsFromSorting(uiSorting);
2342
- const handleSortChange = React8.useCallback(
2343
- (column, direction) => {
2344
- const next = direction == null ? [] : [{ id: column.id, desc: direction === "desc" }];
2345
- if (optimisticSortingUi) setUiSorting(next);
2346
- onSortingChange == null ? void 0 : onSortingChange(next);
2347
- },
2348
- [optimisticSortingUi, onSortingChange]
2349
- );
2350
- const headerExtras = React8.useCallback(
2351
- ({ index }) => {
2352
- var _a, _b, _c, _d;
2353
- const headerGroups = table.getHeaderGroups();
2354
- const leafHeaders = headerGroups.length > 0 ? headerGroups[headerGroups.length - 1].headers : [];
2355
- const header = leafHeaders[index];
2356
- if (!header) return null;
2357
- const canResize = (_c = (_b = (_a = header.column).getCanResize) == null ? void 0 : _b.call(_a)) != null ? _c : false;
2358
- const handler = (_d = header.getResizeHandler) == null ? void 0 : _d.call(header);
2359
- if (!canResize || !handler) return null;
2360
- return /* @__PURE__ */ jsx(ColumnResizer_default2, { id: header.column.id, handler });
2361
- },
2362
- [table]
2363
- );
2364
- return /* @__PURE__ */ jsx(
2365
- Table,
2366
- {
2367
- ...tableProps,
2368
- tableRootRef: containerRef,
2369
- onSortChange: handleSortChange,
2370
- dataKey,
2371
- data: visibleData,
2372
- columns: columnItems,
2373
- tableWidth: distributedLayout == null ? void 0 : distributedLayout.totalWidth,
2374
- measuringLayout: !initialLayoutReady,
2375
- sortById,
2376
- sortDirection,
2377
- headerExtras,
2378
- selectedRows,
2379
- onRowSelect
2380
- }
2381
- );
2382
- }
2383
- function TableSettings({
2384
- viewMode,
2385
- handleChangeViewMode,
2386
- columns = [],
2387
- visibleColumnIds = [],
2388
- onVisibleColumnIdsChange,
2389
- columnsLabel = "Kolonner",
2390
- allPresetLabel = "Alle",
2391
- standardPresetLabel = "Standard",
2392
- buttonSize = "sm",
2393
- additionalSettings
2394
- }) {
2395
- const handleViewModeChange = (mode, close) => {
2396
- handleChangeViewMode(mode === "wrapped" ? "compact" : "wrapped");
2397
- close == null ? void 0 : close();
2398
- };
2399
- const hideableColumns = useMemo(() => columns.filter((c) => c.enableHiding !== false), [columns]);
2400
- const allPresetIds = useMemo(() => hideableColumns.map((c) => c.id), [hideableColumns]);
2401
- const standardPresetIds = useMemo(
2402
- () => hideableColumns.filter((c) => {
2403
- var _a;
2404
- return ((_a = c.meta) == null ? void 0 : _a.hidden) !== true;
2405
- }).map((c) => c.id),
2406
- [hideableColumns]
2407
- );
2408
- const visibleSet = useMemo(() => new Set(visibleColumnIds), [visibleColumnIds]);
2409
- const visibleCount = useMemo(() => {
2410
- return hideableColumns.reduce((acc, c) => {
2411
- var _a;
2412
- return acc + (visibleSet.has((_a = c.id) != null ? _a : "") ? 1 : 0);
2413
- }, 0);
2414
- }, [hideableColumns, visibleSet]);
2415
- const setVisibleIds = (nextIds) => {
2416
- if (!onVisibleColumnIdsChange) return;
2417
- const safe = nextIds.length > 0 ? nextIds : standardPresetIds.length > 0 ? standardPresetIds : allPresetIds;
2418
- onVisibleColumnIdsChange(
2419
- safe.filter((id) => typeof id === "string" && Boolean(id))
2420
- );
2421
- };
2422
- const toggleColumn = (id, nextVisible) => {
2423
- const next = new Set(visibleColumnIds);
2424
- if (nextVisible) next.add(id);
2425
- else next.delete(id);
2426
- setVisibleIds(Array.from(next));
2427
- };
2428
- const isAllActive = useMemo(() => {
2429
- if (!hideableColumns.length) return false;
2430
- return hideableColumns.every((c) => c.id && visibleSet.has(c.id));
2431
- }, [hideableColumns, visibleSet]);
2432
- const isStandardActive = useMemo(() => {
2433
- if (!hideableColumns.length) return false;
2434
- const std = new Set(standardPresetIds);
2435
- return hideableColumns.every((c) => c.id && visibleSet.has(c.id) === std.has(c.id));
2436
- }, [hideableColumns, visibleSet, standardPresetIds]);
2437
- const presetRadioName = "table-columns-preset";
2438
- return /* @__PURE__ */ jsx(
2439
- Popover,
2440
- {
2441
- trigger: (onClick, icon) => /* @__PURE__ */ jsxs(Button, { size: buttonSize, onClick, type: "button", children: [
2442
- /* @__PURE__ */ jsx(Settings, {}),
2443
- icon
2444
- ] }),
2445
- children: (close) => /* @__PURE__ */ jsxs(Menu, { children: [
2446
- additionalSettings == null ? void 0 : additionalSettings(close),
2447
- /* @__PURE__ */ jsx(Menu.Item, { active: viewMode === "wrapped", children: /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => handleViewModeChange(viewMode, close), children: [
2448
- /* @__PURE__ */ jsx(ListChevronsDownUp, {}),
2449
- "Ombryd tekst"
2450
- ] }) }),
2451
- hideableColumns.length > 0 && onVisibleColumnIdsChange ? /* @__PURE__ */ jsxs(Fragment, { children: [
2452
- /* @__PURE__ */ jsx(Menu.Separator, {}),
2453
- /* @__PURE__ */ jsx("div", { style: { padding: "6px 10px", fontSize: 12, opacity: 0.7 }, children: columnsLabel }),
2454
- /* @__PURE__ */ jsx(
2455
- Menu.RadioItem,
2456
- {
2457
- name: presetRadioName,
2458
- value: "all",
2459
- checked: isAllActive,
2460
- label: allPresetLabel,
2461
- onValueChange: () => {
2462
- setVisibleIds(
2463
- allPresetIds.filter((id) => typeof id === "string" && Boolean(id))
2464
- );
2465
- close == null ? void 0 : close();
2466
- }
2467
- }
2468
- ),
2469
- /* @__PURE__ */ jsx(
2470
- Menu.RadioItem,
2471
- {
2472
- name: presetRadioName,
2473
- value: "standard",
2474
- checked: isStandardActive,
2475
- label: standardPresetLabel,
2476
- onValueChange: () => {
2477
- setVisibleIds(
2478
- standardPresetIds.filter(
2479
- (id) => typeof id === "string" && Boolean(id)
2480
- )
2481
- );
2482
- close == null ? void 0 : close();
2483
- }
2484
- }
2485
- ),
2486
- /* @__PURE__ */ jsx(Menu.Separator, {}),
2487
- hideableColumns.map((col) => {
2488
- const isVisible = col.id ? visibleSet.has(col.id) : false;
2489
- const disableUncheckingLast = isVisible && visibleCount <= 1;
2490
- const label = col.header;
2491
- return /* @__PURE__ */ jsx(
2492
- Menu.CheckItem,
2493
- {
2494
- checked: isVisible,
2495
- disabled: disableUncheckingLast,
2496
- label,
2497
- onCheckedChange: (nextChecked) => {
2498
- if (disableUncheckingLast) return;
2499
- toggleColumn(col.id, nextChecked);
2500
- }
2501
- },
2502
- col.id
2503
- );
2504
- })
2505
- ] }) : null
2506
- ] })
2507
- }
2508
- );
2509
- }
2510
-
2511
- // src/utils/localStorage.utils.ts
2512
- function isBrowser() {
2513
- return typeof window !== "undefined" && typeof window.localStorage !== "undefined";
2514
- }
2515
- function readLocalStorage(key) {
2516
- if (!isBrowser()) return void 0;
2517
- try {
2518
- const raw = window.localStorage.getItem(key);
2519
- if (raw == null) return void 0;
2520
- try {
2521
- const parsed = JSON.parse(raw);
2522
- if (typeof parsed === "string") {
2523
- try {
2524
- return JSON.parse(parsed);
2525
- } catch {
2526
- return parsed;
2527
- }
2528
- }
2529
- return parsed;
2530
- } catch {
2531
- return raw;
2532
- }
2533
- } catch {
2534
- return void 0;
2535
- }
2536
- }
2537
- function writeLocalStorage(key, value) {
2538
- if (!isBrowser()) return;
2539
- try {
2540
- if (value === void 0) {
2541
- window.localStorage.removeItem(key);
2542
- return;
2543
- }
2544
- if (typeof value === "string") {
2545
- window.localStorage.setItem(key, value);
2546
- } else {
2547
- window.localStorage.setItem(key, JSON.stringify(value));
2548
- }
2549
- } catch {
2550
- }
2551
- }
2552
-
2553
- // src/hooks/useTableSettings.tsx
2554
- function getDefaultVisibleIds(tableColumns) {
2555
- var _a;
2556
- return (_a = tableColumns == null ? void 0 : tableColumns.filter((c) => {
2557
- var _a2;
2558
- return !((_a2 = c.meta) == null ? void 0 : _a2.hidden);
2559
- }).map((c) => c.id).filter(Boolean)) != null ? _a : [];
2560
- }
2561
- function mergeDefaults(stored, defaults) {
2562
- const viewMode = (stored == null ? void 0 : stored.viewMode) === "compact" || (stored == null ? void 0 : stored.viewMode) === "wrapped" ? stored.viewMode : defaults.viewMode;
2563
- const visibleColumnIds = Array.isArray(stored == null ? void 0 : stored.visibleColumnIds) && stored.visibleColumnIds.length > 0 ? stored.visibleColumnIds : defaults.visibleColumnIds;
2564
- return { viewMode, visibleColumnIds };
2565
- }
2566
- var localStorageTableSettingsStorage = {
2567
- get: (key) => {
2568
- const v = readLocalStorage(key);
2569
- return v && typeof v === "object" ? v : void 0;
2570
- },
2571
- set: (key, next) => {
2572
- writeLocalStorage(key, next);
2573
- }
2574
- };
2575
- function useTableSettings({
2576
- storageKey,
2577
- tableColumns,
2578
- defaultViewMode = "compact",
2579
- defaultVisibleColumnIds,
2580
- storage = localStorageTableSettingsStorage
2581
- }) {
2582
- const defaults = useMemo(() => {
2583
- return {
2584
- viewMode: defaultViewMode,
2585
- visibleColumnIds: defaultVisibleColumnIds != null ? defaultVisibleColumnIds : getDefaultVisibleIds(tableColumns)
2586
- };
2587
- }, [defaultViewMode, defaultVisibleColumnIds, tableColumns]);
2588
- const [state, setState] = useState(defaults);
2589
- useEffect(() => {
2590
- const stored = storage.get(storageKey);
2591
- const next = mergeDefaults(stored, defaults);
2592
- setState(next);
2593
- }, [storageKey, storage, defaults]);
2594
- const persist = useCallback(
2595
- (next) => storage.set(storageKey, next),
2596
- [storage, storageKey]
2597
- );
2598
- const setViewMode = useCallback(
2599
- (mode) => {
2600
- setState((prev) => {
2601
- if (prev.viewMode === mode) return prev;
2602
- const next = { ...prev, viewMode: mode };
2603
- persist(next);
2604
- return next;
2605
- });
2606
- },
2607
- [persist]
2608
- );
2609
- const toggleViewMode = useCallback(() => {
2610
- setState((prev) => {
2611
- const nextMode = prev.viewMode === "wrapped" ? "compact" : "wrapped";
2612
- const next = { ...prev, viewMode: nextMode };
2613
- persist(next);
2614
- return next;
2615
- });
2616
- }, [persist]);
2617
- const setVisibleColumnIds = useCallback(
2618
- (ids) => {
2619
- setState((prev) => {
2620
- const next = { ...prev, visibleColumnIds: ids };
2621
- persist(next);
2622
- return next;
2623
- });
2624
- },
2625
- [persist]
2626
- );
2627
- return {
2628
- viewMode: state.viewMode,
2629
- toggleViewMode,
2630
- setViewMode,
2631
- visibleColumnIds: state.visibleColumnIds,
2632
- setVisibleColumnIds
2633
- };
2634
- }
2635
-
2636
- export { TableSettings, TanstackTable, localStorageTableSettingsStorage, useTableSettings };
1
+ export * from './components/table/TanstackTable';
2
+ export * from './components/table/components/table-settings/TableSettings';
3
+ export * from './hooks/useTableSettings';