@dbcdk/react-components 0.0.95 → 0.0.97

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 (226) hide show
  1. package/dist/components/alert/Alert.d.ts +13 -0
  2. package/dist/components/forms/input/Input.d.ts +2 -1
  3. package/dist/components/forms/input-container/InputContainer.d.ts +3 -1
  4. package/dist/components/forms/text-area/Textarea.d.ts +1 -1
  5. package/dist/components/stack/Stack.d.ts +11 -3
  6. package/dist/components/table/Table.d.ts +1 -1
  7. package/dist/components/table/Table.types.d.ts +3 -0
  8. package/dist/components/table/components/TableHeader.d.ts +2 -1
  9. package/dist/index.cjs +12750 -0
  10. package/dist/index.css +7149 -0
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.js +12641 -78
  13. package/dist/tanstack.cjs +2674 -0
  14. package/dist/tanstack.css +1267 -0
  15. package/dist/tanstack.js +2650 -3
  16. package/dist/themes/dbc.css +3 -0
  17. package/dist/themes/forfatterweb.css +2 -0
  18. package/package.json +11 -10
  19. package/dist/assets/logo.js +0 -2
  20. package/dist/components/__stories__/_data/table.d.ts +0 -15
  21. package/dist/components/__stories__/_data/table.js +0 -55
  22. package/dist/components/__stories__/_data/tabs.d.ts +0 -9
  23. package/dist/components/__stories__/_data/tabs.js +0 -31
  24. package/dist/components/__stories__/story-components/Colors.d.ts +0 -11
  25. package/dist/components/__stories__/story-components/Colors.js +0 -96
  26. package/dist/components/__stories__/story-components/Colors.module.css +0 -27
  27. package/dist/components/__stories__/story-components/ComponentSizes.d.ts +0 -2
  28. package/dist/components/__stories__/story-components/ComponentSizes.js +0 -26
  29. package/dist/components/__stories__/story-components/Elevation.d.ts +0 -2
  30. package/dist/components/__stories__/story-components/Elevation.js +0 -49
  31. package/dist/components/__stories__/story-components/Flex.d.ts +0 -2
  32. package/dist/components/__stories__/story-components/Flex.js +0 -177
  33. package/dist/components/__stories__/story-components/Flex.module.css +0 -317
  34. package/dist/components/__stories__/story-components/Spacing.d.ts +0 -6
  35. package/dist/components/__stories__/story-components/Spacing.js +0 -76
  36. package/dist/components/__stories__/story-components/Spacing.module.css +0 -154
  37. package/dist/components/accordion/Accordion.js +0 -70
  38. package/dist/components/accordion/Accordion.module.css +0 -28
  39. package/dist/components/accordion/components/AccordionRow.js +0 -53
  40. package/dist/components/accordion/components/AccordionRow.module.css +0 -90
  41. package/dist/components/app-header/AppHeader.js +0 -5
  42. package/dist/components/app-header/AppHeader.module.css +0 -74
  43. package/dist/components/attribute-chip/AttributeChip.js +0 -5
  44. package/dist/components/attribute-chip/AttributeChip.module.css +0 -65
  45. package/dist/components/avatar/Avatar.js +0 -48
  46. package/dist/components/avatar/Avatar.module.css +0 -91
  47. package/dist/components/breadcrumbs/Breadcrumbs.js +0 -6
  48. package/dist/components/breadcrumbs/Breadcrumbs.module.css +0 -80
  49. package/dist/components/button/Button.js +0 -81
  50. package/dist/components/button/Button.module.css +0 -249
  51. package/dist/components/button-select/ButtonSelect.js +0 -7
  52. package/dist/components/button-select/ButtonSelect.module.css +0 -40
  53. package/dist/components/card/Card.js +0 -71
  54. package/dist/components/card/Card.module.css +0 -160
  55. package/dist/components/card/components/CardMeta.js +0 -26
  56. package/dist/components/card/components/CardMeta.module.css +0 -55
  57. package/dist/components/card-container/CardContainer.js +0 -6
  58. package/dist/components/card-container/CardContainer.module.css +0 -61
  59. package/dist/components/chip/Chip.js +0 -31
  60. package/dist/components/chip/Chip.module.css +0 -236
  61. package/dist/components/circle/Circle.js +0 -5
  62. package/dist/components/circle/Circle.module.css +0 -128
  63. package/dist/components/clear-button/ClearButton.js +0 -13
  64. package/dist/components/clear-button/ClearButton.module.css +0 -26
  65. package/dist/components/code-block/CodeBlock.js +0 -58
  66. package/dist/components/code-block/CodeBlock.module.css +0 -124
  67. package/dist/components/copy-button/CopyButton.js +0 -78
  68. package/dist/components/copy-button/CopyButton.module.css +0 -22
  69. package/dist/components/datetime-picker/DateTimePicker.js +0 -403
  70. package/dist/components/datetime-picker/DateTimePicker.module.css +0 -155
  71. package/dist/components/datetime-picker/dateTimeHelpers.js +0 -248
  72. package/dist/components/divider/Divider.js +0 -12
  73. package/dist/components/filter-field/FilterField.js +0 -191
  74. package/dist/components/filter-field/FilterField.module.css +0 -379
  75. package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.js +0 -52
  76. package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.module.css +0 -59
  77. package/dist/components/forms/checkbox/Checkbox.js +0 -26
  78. package/dist/components/forms/checkbox/Checkbox.module.css +0 -99
  79. package/dist/components/forms/checkbox-group/CheckboxGroup.js +0 -75
  80. package/dist/components/forms/checkbox-group/CheckboxGroup.module.css +0 -115
  81. package/dist/components/forms/form-select/FormSelect.js +0 -86
  82. package/dist/components/forms/form-select/FormSelect.module.css +0 -236
  83. package/dist/components/forms/input/Input.js +0 -77
  84. package/dist/components/forms/input/Input.module.css +0 -468
  85. package/dist/components/forms/input-container/InputContainer.js +0 -15
  86. package/dist/components/forms/input-container/InputContainer.module.css +0 -56
  87. package/dist/components/forms/multi-select/MultiSelect.js +0 -122
  88. package/dist/components/forms/radio-buttons/RadioButton.js +0 -26
  89. package/dist/components/forms/radio-buttons/RadioButtonGroup.js +0 -19
  90. package/dist/components/forms/radio-buttons/RadioButtons.module.css +0 -118
  91. package/dist/components/forms/select/Select.js +0 -185
  92. package/dist/components/forms/select/Select.module.css +0 -32
  93. package/dist/components/forms/text-area/Textarea.js +0 -47
  94. package/dist/components/forms/text-area/Textarea.module.css +0 -70
  95. package/dist/components/forms/typeahead/Typeahead.js +0 -668
  96. package/dist/components/forms/typeahead/Typeahead.module.css +0 -38
  97. package/dist/components/grid/Grid.js +0 -23
  98. package/dist/components/grid/Grid.module.css +0 -35
  99. package/dist/components/headline/CollapsibleHeadline.js +0 -29
  100. package/dist/components/headline/Headline.js +0 -26
  101. package/dist/components/headline/Headline.module.css +0 -165
  102. package/dist/components/hyperlink/Hyperlink.js +0 -40
  103. package/dist/components/hyperlink/Hyperlink.module.css +0 -107
  104. package/dist/components/icon/Icon.js +0 -14
  105. package/dist/components/icon/Icon.module.css +0 -36
  106. package/dist/components/interval-select/IntervalSelect.js +0 -99
  107. package/dist/components/json-viewer/HighlightedText.js +0 -6
  108. package/dist/components/json-viewer/JsonNode.js +0 -30
  109. package/dist/components/json-viewer/JsonViewer.js +0 -68
  110. package/dist/components/json-viewer/JsonViewer.module.css +0 -346
  111. package/dist/components/json-viewer/types.js +0 -1
  112. package/dist/components/json-viewer/useClipboardStatus.js +0 -11
  113. package/dist/components/json-viewer/utils.js +0 -125
  114. package/dist/components/menu/Menu.js +0 -165
  115. package/dist/components/menu/Menu.module.css +0 -211
  116. package/dist/components/meta-bar/MetaBar.js +0 -9
  117. package/dist/components/meta-bar/MetaBar.module.css +0 -27
  118. package/dist/components/nav-bar/NavBar.js +0 -29
  119. package/dist/components/nav-bar/NavBar.module.css +0 -200
  120. package/dist/components/overlay/fade-overlay/FadeOverlay.js +0 -8
  121. package/dist/components/overlay/fade-overlay/FadeOverlay.module.css +0 -54
  122. package/dist/components/overlay/modal/Modal.js +0 -115
  123. package/dist/components/overlay/modal/Modal.module.css +0 -109
  124. package/dist/components/overlay/modal/provider/ModalProvider.js +0 -73
  125. package/dist/components/overlay/side-panel/SidePanel.js +0 -83
  126. package/dist/components/overlay/side-panel/SidePanel.module.css +0 -177
  127. package/dist/components/overlay/side-panel/useSidePanel.js +0 -11
  128. package/dist/components/overlay/tooltip/Tooltip.js +0 -17
  129. package/dist/components/overlay/tooltip/Tooltip.module.css +0 -104
  130. package/dist/components/overlay/tooltip/TooltipProvider.js +0 -255
  131. package/dist/components/overlay/tooltip/useTooltipTrigger.js +0 -118
  132. package/dist/components/page/Page.js +0 -11
  133. package/dist/components/page/Page.module.css +0 -76
  134. package/dist/components/page-layout/PageLayout.js +0 -76
  135. package/dist/components/page-layout/PageLayout.module.css +0 -236
  136. package/dist/components/page-layout/components/layout-footer/LayoutFooter.js +0 -27
  137. package/dist/components/page-layout/components/layout-footer/LayoutFooter.module.css +0 -89
  138. package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.js +0 -14
  139. package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.module.css +0 -84
  140. package/dist/components/pagination/Pagination.js +0 -56
  141. package/dist/components/pagination/Pagination.module.css +0 -25
  142. package/dist/components/panel/Panel.js +0 -7
  143. package/dist/components/panel/Panel.module.css +0 -29
  144. package/dist/components/popover/Popover.js +0 -257
  145. package/dist/components/popover/Popover.module.css +0 -54
  146. package/dist/components/search-box/SearchBox.js +0 -170
  147. package/dist/components/search-box/SearchBox.module.css +0 -21
  148. package/dist/components/segmented-progress-bar/SegmentedProgressBar.js +0 -48
  149. package/dist/components/segmented-progress-bar/SegmentedProgressBar.module.css +0 -167
  150. package/dist/components/sidebar/Sidebar.js +0 -6
  151. package/dist/components/sidebar/components/SidebarItem.js +0 -8
  152. package/dist/components/sidebar/components/SidebarItem.module.css +0 -0
  153. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.js +0 -63
  154. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.module.css +0 -29
  155. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.js +0 -153
  156. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.module.css +0 -260
  157. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.js +0 -18
  158. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.module.css +0 -106
  159. package/dist/components/sidebar/components/sidebar-items/SidebarItems.js +0 -26
  160. package/dist/components/sidebar/components/sidebar-items/SidebarItems.module.css +0 -20
  161. package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.js +0 -30
  162. package/dist/components/sidebar/providers/SidebarProvider.js +0 -229
  163. package/dist/components/skeleton-loader/SkeletonLoader.js +0 -73
  164. package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.js +0 -13
  165. package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.module.css +0 -51
  166. package/dist/components/split-button/SplitButton.js +0 -10
  167. package/dist/components/split-button/SplitButton.module.css +0 -32
  168. package/dist/components/split-pane/SplitPane.js +0 -107
  169. package/dist/components/split-pane/SplitPane.module.css +0 -111
  170. package/dist/components/split-pane/provider/SplitPaneContext.js +0 -124
  171. package/dist/components/stack/Stack.js +0 -19
  172. package/dist/components/state-page/StatePage.js +0 -20
  173. package/dist/components/state-page/StatePage.module.css +0 -9
  174. package/dist/components/state-page/empty.js +0 -2
  175. package/dist/components/state-page/error.js +0 -2
  176. package/dist/components/state-page/notFound.js +0 -2
  177. package/dist/components/sticky-footer-layout/StickyFooterLayout.js +0 -64
  178. package/dist/components/table/Table.js +0 -50
  179. package/dist/components/table/Table.module.css +0 -536
  180. package/dist/components/table/Table.types.js +0 -1
  181. package/dist/components/table/TanstackTable.js +0 -111
  182. package/dist/components/table/components/TableBody.js +0 -10
  183. package/dist/components/table/components/TableHeader.js +0 -7
  184. package/dist/components/table/components/TableHeaderCell.js +0 -24
  185. package/dist/components/table/components/TableLoadingBody.js +0 -26
  186. package/dist/components/table/components/TablePagination.js +0 -1
  187. package/dist/components/table/components/TableRow.js +0 -54
  188. package/dist/components/table/components/TableSelectionCell.js +0 -16
  189. package/dist/components/table/components/column-resizer/ColumnResizer.js +0 -5
  190. package/dist/components/table/components/column-resizer/ColumnResizer.module.css +0 -22
  191. package/dist/components/table/components/empty-state/EmptyState.js +0 -23
  192. package/dist/components/table/components/empty-state/EmptyState.module.css +0 -4
  193. package/dist/components/table/components/table-settings/TableSettings.js +0 -63
  194. package/dist/components/table/hooks/useTableRowInteractions.js +0 -30
  195. package/dist/components/table/table.classes.js +0 -23
  196. package/dist/components/table/table.utils.js +0 -47
  197. package/dist/components/table/tanstackTable.utils.js +0 -175
  198. package/dist/components/tabs/Tabs.js +0 -125
  199. package/dist/components/tabs/Tabs.module.css +0 -204
  200. package/dist/components/theme-button/ThemeButton.js +0 -23
  201. package/dist/components/toast/Toast.js +0 -20
  202. package/dist/components/toast/Toast.module.css +0 -161
  203. package/dist/components/toast/provider/ToastProvider.js +0 -70
  204. package/dist/components/user-display/UserDisplay.js +0 -6
  205. package/dist/components/user-display/UserDisplay.module.css +0 -25
  206. package/dist/constants/severity.js +0 -24
  207. package/dist/constants/severity.types.js +0 -1
  208. package/dist/constants/sizes.js +0 -7
  209. package/dist/hooks/useDeviceSize.js +0 -32
  210. package/dist/hooks/useListNavigation.js +0 -234
  211. package/dist/hooks/usePagination.js +0 -140
  212. package/dist/hooks/useSorting.js +0 -118
  213. package/dist/hooks/useTableData.js +0 -45
  214. package/dist/hooks/useTableSelection.js +0 -164
  215. package/dist/hooks/useTableSettings.js +0 -71
  216. package/dist/hooks/useTheme.js +0 -66
  217. package/dist/hooks/useTimeDuration.js +0 -68
  218. package/dist/hooks/useViewportFill.js +0 -77
  219. package/dist/styles/animation.js +0 -5
  220. package/dist/styles/themes/types.js +0 -1
  221. package/dist/types/a11y-props.types.js +0 -1
  222. package/dist/types/sizes.types.js +0 -1
  223. package/dist/utils/arrays/nested-filtering.js +0 -48
  224. package/dist/utils/date/formatDate.js +0 -51
  225. package/dist/utils/localStorage.utils.js +0 -78
  226. package/dist/utils/text/get-highlighted-segments.js +0 -46
package/dist/tanstack.js CHANGED
@@ -1,3 +1,2650 @@
1
- export * from './components/table/TanstackTable';
2
- export * from './components/table/components/table-settings/TableSettings';
3
- export * from './hooks/useTableSettings';
1
+ import { useReactTable, getSortedRowModel, getCoreRowModel } from '@tanstack/react-table';
2
+ import * as React9 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
+ xs: "Button_xs2",
154
+ sm: "Button_sm2",
155
+ lg: "Button_lg2",
156
+ fullWidth: "Button_fullWidth2",
157
+ primary: "Button_primary2",
158
+ secondary: "Button_secondary2",
159
+ default: "Button_default2",
160
+ outlined: "Button_outlined2",
161
+ active: "Button_active2",
162
+ success: "Button_success2",
163
+ danger: "Button_danger2",
164
+ inline: "Button_inline2"
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 = React9.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 && React9.isValidElement(children) ? (_a = children.ref) != null ? _a : null : null;
208
+ const mergedRef = React9.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 && React9.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 = React9.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 = React9.forwardRef(
558
+ ({ children, className, itemRole = "menuitem", gap, onKeyDown, ...props }, ref) => {
559
+ const internalRef = React9.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) => React9.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 = React9.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 React9.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 React9.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 = React9.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 = React9.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 = React9.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 = React9.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 = React9.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 = React9.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
+ const allowOverflow = 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: allowWrap || allowOverflow ? cellValue : /* @__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 getColumnWidth(column) {
1874
+ if (typeof column.width === "number" && column.width < 150) {
1875
+ return "100%";
1876
+ }
1877
+ if (typeof column.width === "string" && column.width.endsWith("px")) {
1878
+ const px = parseInt(column.width, 10);
1879
+ if (!isNaN(px) && px < 150) {
1880
+ return "100%";
1881
+ }
1882
+ }
1883
+ const percent = Math.floor(Math.random() * (90 - 50 + 1)) + 50;
1884
+ return `${percent}%`;
1885
+ }
1886
+ function TableLoadingBody({ rows, columns, hasSelection }) {
1887
+ const widths = Array.from({ length: rows }, () => columns.map(getColumnWidth));
1888
+ return /* @__PURE__ */ jsx("tbody", { className: Table_default.body, children: Array.from({ length: rows }).map((_, rowIndex) => /* @__PURE__ */ jsxs("tr", { className: Table_default.row, children: [
1889
+ 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,
1890
+ columns.map((column, columnIndex) => {
1891
+ var _a;
1892
+ return /* @__PURE__ */ jsx(
1893
+ "td",
1894
+ {
1895
+ className: cx2(
1896
+ Table_default.cell,
1897
+ column.divider === "left" && Table_default.dividerLeft,
1898
+ column.divider === "right" && Table_default.dividerRight
1899
+ ),
1900
+ "data-align": (_a = column.align) != null ? _a : "left",
1901
+ "data-divider": column.divider,
1902
+ children: /* @__PURE__ */ jsx("div", { className: Table_default.cellContent, children: /* @__PURE__ */ jsx("div", { className: Table_default.cellValueEllipsis, children: /* @__PURE__ */ jsx(SkeletonLoaderItem, { height: 16, width: widths[rowIndex][columnIndex] }) }) })
1903
+ },
1904
+ column.id
1905
+ );
1906
+ })
1907
+ ] }, `loading-row-${rowIndex}`)) });
1908
+ }
1909
+ function Table({
1910
+ data,
1911
+ dataKey,
1912
+ columns,
1913
+ selectedRows,
1914
+ selectionMode = "single",
1915
+ allRowsSelected,
1916
+ sortById,
1917
+ sortDirection,
1918
+ loading,
1919
+ emptyConfig,
1920
+ variant = "primary",
1921
+ size = "md",
1922
+ viewMode,
1923
+ striped,
1924
+ fillViewport = false,
1925
+ fillViewportBottomOffset = 16,
1926
+ containScrolling = true,
1927
+ stickyHeader,
1928
+ tableWidth,
1929
+ tableRootRef,
1930
+ measuringLayout = false,
1931
+ toolbar,
1932
+ headerExtras,
1933
+ take,
1934
+ skip,
1935
+ totalItemsCount,
1936
+ paginationPlacement = "bottom",
1937
+ showFirstLast = false,
1938
+ pageSizeOptions,
1939
+ getRowSeverity,
1940
+ onRowClick,
1941
+ onRowMouseEnter,
1942
+ onRowSelect,
1943
+ onSelectAllRows,
1944
+ onSortChange,
1945
+ onPageChange,
1946
+ ...rest
1947
+ }) {
1948
+ const visibleColumns = useMemo(() => getVisibleColumns(columns), [columns]);
1949
+ const selectionInputName = useId();
1950
+ const internalTableRootRef = useRef(null);
1951
+ const tableRootRefWrapper = useRef(tableRootRef);
1952
+ const hasSelection = Boolean(selectedRows && onRowSelect);
1953
+ const hasPagination = Boolean(onPageChange && (loading || data.length > 0));
1954
+ const paginationOffset = hasPagination ? 72 : 0;
1955
+ const { style: viewportFillStyle, maxHeight } = useViewportFill(internalTableRootRef, {
1956
+ bottomOffset: fillViewportBottomOffset + paginationOffset,
1957
+ min: 0
1958
+ });
1959
+ const fillViewportActive = fillViewport && containScrolling && maxHeight >= 500;
1960
+ const stickyTop = stickyHeader === "app-header" ? "var(--app-header-height, 60px)" : typeof stickyHeader === "number" ? `${stickyHeader}px` : void 0;
1961
+ const setTableRootRef = useCallback((node) => {
1962
+ internalTableRootRef.current = node;
1963
+ if (typeof tableRootRefWrapper.current === "function") {
1964
+ tableRootRefWrapper.current(node);
1965
+ } else if (tableRootRefWrapper.current) {
1966
+ tableRootRefWrapper.current.current = node;
1967
+ }
1968
+ }, []);
1969
+ const handlePageChange = useCallback(
1970
+ (e) => {
1971
+ onPageChange == null ? void 0 : onPageChange(e);
1972
+ },
1973
+ [onPageChange]
1974
+ );
1975
+ const bodyContent = loading && !data.length ? /* @__PURE__ */ jsx(TableLoadingBody, { rows: take != null ? take : 5, columns: visibleColumns, hasSelection }) : /* @__PURE__ */ jsx(
1976
+ TableBody,
1977
+ {
1978
+ data,
1979
+ dataKey,
1980
+ columns: visibleColumns,
1981
+ striped,
1982
+ selectedRows,
1983
+ hasSelection,
1984
+ selectionMode,
1985
+ selectionInputName,
1986
+ viewMode,
1987
+ getRowSeverity,
1988
+ onRowClick,
1989
+ onRowMouseEnter,
1990
+ onRowSelect
1991
+ }
1992
+ );
1993
+ const paginationEl = hasPagination ? /* @__PURE__ */ jsx(
1994
+ "div",
1995
+ {
1996
+ className: cx2(
1997
+ Table_default.paginationSlot,
1998
+ paginationPlacement === "top" && Table_default.paginationSlotTop
1999
+ ),
2000
+ children: /* @__PURE__ */ jsx(
2001
+ Pagination,
2002
+ {
2003
+ itemsCount: totalItemsCount,
2004
+ take,
2005
+ skip,
2006
+ onPageChange: handlePageChange,
2007
+ showFirstLast,
2008
+ pageSizeOptions
2009
+ }
2010
+ )
2011
+ }
2012
+ ) : null;
2013
+ const tableClassName = cx2(
2014
+ Table_default.tableRoot,
2015
+ Table_default[variant],
2016
+ Table_default[size],
2017
+ measuringLayout && Table_default.measuringLayout,
2018
+ getRowSeverity && Table_default.severityTable
2019
+ );
2020
+ const tableShell = /* @__PURE__ */ jsx("div", { ...rest, className: tableClassName, children: /* @__PURE__ */ jsx(
2021
+ "div",
2022
+ {
2023
+ ref: setTableRootRef,
2024
+ className: Table_default.tableScroll,
2025
+ style: fillViewportActive ? viewportFillStyle : !containScrolling ? { overflow: "visible" } : void 0,
2026
+ children: !data.length && !loading ? /* @__PURE__ */ jsx("div", { className: Table_default.emptyStateSlot, children: /* @__PURE__ */ jsx(TableEmptyState, { config: emptyConfig }) }) : /* @__PURE__ */ jsxs(
2027
+ "table",
2028
+ {
2029
+ className: Table_default.tableElement,
2030
+ "aria-rowcount": data.length,
2031
+ style: tableWidth != null ? { width: tableWidth } : void 0,
2032
+ children: [
2033
+ /* @__PURE__ */ jsxs("colgroup", { children: [
2034
+ hasSelection ? /* @__PURE__ */ jsx("col", { style: { width: SELECTION_COLUMN_PX } }) : null,
2035
+ visibleColumns.map((column) => /* @__PURE__ */ jsx(
2036
+ "col",
2037
+ {
2038
+ style: column.width != null ? { width: column.width } : void 0
2039
+ },
2040
+ column.id
2041
+ ))
2042
+ ] }),
2043
+ /* @__PURE__ */ jsx(
2044
+ TableHeader,
2045
+ {
2046
+ columns: visibleColumns,
2047
+ hasSelection,
2048
+ selectionMode,
2049
+ allRowsSelected,
2050
+ onSelectAllRows,
2051
+ sortById,
2052
+ sortDirection,
2053
+ onSortChange,
2054
+ headerExtras,
2055
+ stickyTop
2056
+ }
2057
+ ),
2058
+ bodyContent
2059
+ ]
2060
+ }
2061
+ )
2062
+ }
2063
+ ) });
2064
+ if (fillViewport) {
2065
+ return /* @__PURE__ */ jsxs(
2066
+ "div",
2067
+ {
2068
+ className: Table_default.fillViewportRoot,
2069
+ style: {
2070
+ flexDirection: paginationPlacement === "top" ? "column-reverse" : "column",
2071
+ ...!fillViewportActive && { blockSize: "auto", overflow: "visible" }
2072
+ },
2073
+ children: [
2074
+ toolbar ? /* @__PURE__ */ jsx("div", { className: Table_default.toolbarSlot, children: toolbar }) : null,
2075
+ /* @__PURE__ */ jsx(
2076
+ "div",
2077
+ {
2078
+ className: Table_default.tableViewport,
2079
+ style: !fillViewportActive ? { overflow: "visible" } : void 0,
2080
+ children: tableShell
2081
+ }
2082
+ ),
2083
+ paginationEl
2084
+ ]
2085
+ }
2086
+ );
2087
+ }
2088
+ return /* @__PURE__ */ jsxs(
2089
+ "div",
2090
+ {
2091
+ className: "dbc-flex dbc-flex-column dbc-gap-md",
2092
+ style: {
2093
+ flexFlow: paginationPlacement === "top" ? "column-reverse" : "column",
2094
+ position: "relative"
2095
+ },
2096
+ children: [
2097
+ toolbar ? /* @__PURE__ */ jsx("div", { className: Table_default.toolbarSlot, children: toolbar }) : null,
2098
+ tableShell,
2099
+ paginationEl
2100
+ ]
2101
+ }
2102
+ );
2103
+ }
2104
+
2105
+ // src/components/table/tanstackTable.utils.ts
2106
+ function getColumnId(def, index) {
2107
+ const d = def;
2108
+ if (d.id != null && String(d.id).length > 0) return String(d.id);
2109
+ if (d.accessorKey != null && String(d.accessorKey).length > 0) return String(d.accessorKey);
2110
+ return `col_${index}`;
2111
+ }
2112
+ function buildColumnVisibilityFromVisibleIds(defs, visibleColumnIds) {
2113
+ if (!(visibleColumnIds == null ? void 0 : visibleColumnIds.length)) return {};
2114
+ const visible = new Set(visibleColumnIds);
2115
+ const next = {};
2116
+ defs.forEach((def, index) => {
2117
+ const id = getColumnId(def, index);
2118
+ next[id] = visible.has(id);
2119
+ });
2120
+ return next;
2121
+ }
2122
+ function mapDefsToColumnItems(defs, columnVisibility, resolvedLayout = {}) {
2123
+ return defs.map((def, index) => {
2124
+ var _a, _b, _c, _d, _e, _f, _g;
2125
+ const id = getColumnId(def, index);
2126
+ const accessorKey = def.accessorKey;
2127
+ const accessorFn = def.accessorFn;
2128
+ const cell = def.cell;
2129
+ const meta = (_a = def.meta) != null ? _a : {};
2130
+ let render;
2131
+ if (typeof cell === "function") {
2132
+ render = (row) => cell({
2133
+ row: { original: row },
2134
+ getValue: () => accessorKey != null ? row[accessorKey] : accessorFn ? accessorFn(row) : void 0
2135
+ });
2136
+ } else if (accessorFn) {
2137
+ render = (row) => accessorFn(row);
2138
+ } else if (accessorKey != null) {
2139
+ render = (row) => row[accessorKey];
2140
+ } else {
2141
+ render = () => null;
2142
+ }
2143
+ const isVisible = (_b = columnVisibility[id]) != null ? _b : true;
2144
+ return {
2145
+ id,
2146
+ header: def.header,
2147
+ accessor: accessorKey,
2148
+ sortable: (_c = def.enableSorting) != null ? _c : !!accessorKey,
2149
+ render,
2150
+ hidden: !isVisible,
2151
+ width: (_d = resolvedLayout[id]) == null ? void 0 : _d.width,
2152
+ align: meta.align,
2153
+ verticalAlign: meta.verticalAlign,
2154
+ emptyPlaceholder: (_e = meta.emptyPlaceholder) != null ? _e : "-",
2155
+ allowWrap: (_f = meta.allowWrap) != null ? _f : false,
2156
+ severity: meta.severity,
2157
+ divider: meta.divider,
2158
+ allowOverflow: (_g = meta.allowOverflow) != null ? _g : false
2159
+ };
2160
+ });
2161
+ }
2162
+ function sortingEqual(a, b) {
2163
+ const A = a == null ? void 0 : a[0];
2164
+ const B = b == null ? void 0 : b[0];
2165
+ if (!A && !B) return true;
2166
+ if (!A || !B) return false;
2167
+ return A.id === B.id && A.desc === B.desc;
2168
+ }
2169
+ function getSortPropsFromSorting(sorting) {
2170
+ const s = sorting == null ? void 0 : sorting[0];
2171
+ return {
2172
+ sortById: s == null ? void 0 : s.id,
2173
+ sortDirection: s ? s.desc ? "desc" : "asc" : null
2174
+ };
2175
+ }
2176
+ function clamp(value, min, max) {
2177
+ const lowerBounded = Math.max(min, value);
2178
+ if (max == null || !Number.isFinite(max)) return lowerBounded;
2179
+ return Math.min(lowerBounded, max);
2180
+ }
2181
+ function toIntegerTrackWidths(tracks, targetWidth) {
2182
+ const floored = tracks.map((track) => ({
2183
+ id: track.id,
2184
+ width: Math.floor(track.width),
2185
+ fraction: track.width - Math.floor(track.width)
2186
+ }));
2187
+ const baseTotal = floored.reduce((sum, track) => sum + track.width, 0);
2188
+ let remainder = Math.max(0, targetWidth - baseTotal);
2189
+ floored.slice().sort((a, b) => b.fraction - a.fraction).forEach((track) => {
2190
+ if (remainder <= 0) return;
2191
+ track.width += 1;
2192
+ remainder -= 1;
2193
+ });
2194
+ return Object.fromEntries(floored.map((track) => [track.id, track.width]));
2195
+ }
2196
+ function buildDistributedColumnWidths(args) {
2197
+ const { table, hasSelection, defaultMinPx, columnSizing, availableWidth } = args;
2198
+ const leaf = table.getVisibleLeafColumns();
2199
+ const selectionWidth = hasSelection ? SELECTION_COLUMN_PX : 0;
2200
+ const tracks = leaf.map((c) => {
2201
+ var _a, _b, _c, _d;
2202
+ const def = c.columnDef;
2203
+ const meta = (_a = def.meta) != null ? _a : {};
2204
+ const min = Math.max(1, Number((_b = def.minSize) != null ? _b : defaultMinPx));
2205
+ const max = def.maxSize != null ? Math.max(min, Number(def.maxSize)) : void 0;
2206
+ const resizedPxRaw = columnSizing[c.id];
2207
+ const resizedPx = resizedPxRaw != null ? Math.round(clamp(Number(resizedPxRaw), min, max)) : void 0;
2208
+ if (resizedPx != null) {
2209
+ return {
2210
+ id: c.id,
2211
+ width: resizedPx,
2212
+ weight: 0,
2213
+ max: resizedPx,
2214
+ fixed: true
2215
+ };
2216
+ }
2217
+ const rawWeight = Number((_d = (_c = meta.weight) != null ? _c : def.size) != null ? _d : DEFAULT_COLUMN_PX);
2218
+ const weight = Number.isFinite(rawWeight) && rawWeight > 0 ? rawWeight : DEFAULT_COLUMN_PX;
2219
+ return {
2220
+ id: c.id,
2221
+ width: min,
2222
+ weight,
2223
+ max,
2224
+ fixed: false
2225
+ };
2226
+ });
2227
+ const fixedWidth = selectionWidth + tracks.reduce((sum, track) => sum + track.width, 0);
2228
+ let remaining = Math.max(0, availableWidth - fixedWidth);
2229
+ let active = tracks.filter(
2230
+ (track) => !track.fixed && (track.max == null || track.width < track.max)
2231
+ );
2232
+ while (remaining > 0.5 && active.length > 0) {
2233
+ const totalWeight = active.reduce((sum, track) => sum + track.weight, 0);
2234
+ if (totalWeight <= 0) break;
2235
+ let consumed = 0;
2236
+ const nextActive = [];
2237
+ for (const track of active) {
2238
+ const share = remaining * track.weight / totalWeight;
2239
+ const maxGrow = track.max == null ? share : Math.max(0, track.max - track.width);
2240
+ const growth = Math.min(share, maxGrow);
2241
+ track.width += growth;
2242
+ consumed += growth;
2243
+ if (track.max == null || track.width < track.max - 0.5) {
2244
+ nextActive.push(track);
2245
+ }
2246
+ }
2247
+ if (consumed <= 0.5) break;
2248
+ remaining -= consumed;
2249
+ active = nextActive;
2250
+ }
2251
+ const floatTrackTotal = tracks.reduce((sum, track) => sum + track.width, 0);
2252
+ const targetTrackWidth = floatTrackTotal <= availableWidth - selectionWidth ? Math.floor(floatTrackTotal) : Math.ceil(floatTrackTotal);
2253
+ const widths = toIntegerTrackWidths(tracks, targetTrackWidth);
2254
+ const totalWidth = selectionWidth + Object.values(widths).reduce((sum, width) => sum + width, 0);
2255
+ return {
2256
+ selectionWidth: hasSelection ? SELECTION_COLUMN_PX : void 0,
2257
+ widths,
2258
+ totalWidth
2259
+ };
2260
+ }
2261
+ function TanstackTable(props) {
2262
+ const {
2263
+ data,
2264
+ dataKey,
2265
+ columns,
2266
+ sorting: controlledSorting,
2267
+ onSortingChange,
2268
+ optimisticSortingUi = true,
2269
+ visibleColumnIds,
2270
+ manualSorting,
2271
+ selectedRows,
2272
+ onRowSelect,
2273
+ ...tableProps
2274
+ } = props;
2275
+ const isControlledSorting = controlledSorting != null;
2276
+ const [uiSorting, setUiSorting] = React9.useState(controlledSorting != null ? controlledSorting : []);
2277
+ React9.useEffect(() => {
2278
+ if (!isControlledSorting) return;
2279
+ if (sortingEqual(uiSorting, controlledSorting)) return;
2280
+ setUiSorting(controlledSorting);
2281
+ }, [isControlledSorting, controlledSorting, uiSorting]);
2282
+ const columnVisibility = React9.useMemo(
2283
+ () => buildColumnVisibilityFromVisibleIds(columns, visibleColumnIds),
2284
+ [columns, visibleColumnIds]
2285
+ );
2286
+ const [columnSizing, setColumnSizing] = React9.useState({});
2287
+ const containerRef = React9.useRef(null);
2288
+ const [availableWidth, setAvailableWidth] = React9.useState(void 0);
2289
+ const table = useReactTable({
2290
+ data,
2291
+ columns,
2292
+ state: {
2293
+ sorting: uiSorting,
2294
+ columnSizing,
2295
+ columnVisibility
2296
+ },
2297
+ onSortingChange: (updater) => {
2298
+ const next = typeof updater === "function" ? updater(uiSorting) : updater;
2299
+ if (optimisticSortingUi) setUiSorting(next);
2300
+ onSortingChange == null ? void 0 : onSortingChange(next);
2301
+ },
2302
+ onColumnSizingChange: setColumnSizing,
2303
+ getCoreRowModel: getCoreRowModel(),
2304
+ getSortedRowModel: getSortedRowModel(),
2305
+ manualSorting: manualSorting != null ? manualSorting : false,
2306
+ enableColumnResizing: true,
2307
+ columnResizeMode: "onChange",
2308
+ defaultColumn: {
2309
+ enableResizing: true,
2310
+ minSize: 80,
2311
+ size: DEFAULT_COLUMN_PX
2312
+ }
2313
+ });
2314
+ React9.useLayoutEffect(() => {
2315
+ const el = containerRef.current;
2316
+ if (!el) return;
2317
+ const updateWidth = () => {
2318
+ const next = el.clientWidth;
2319
+ setAvailableWidth(next > 0 ? next : void 0);
2320
+ };
2321
+ updateWidth();
2322
+ if (typeof ResizeObserver === "undefined") {
2323
+ window.addEventListener("resize", updateWidth);
2324
+ return () => window.removeEventListener("resize", updateWidth);
2325
+ }
2326
+ const observer = new ResizeObserver(() => updateWidth());
2327
+ observer.observe(el);
2328
+ return () => observer.disconnect();
2329
+ }, []);
2330
+ const distributedLayout = React9.useMemo(() => {
2331
+ if (availableWidth == null) return null;
2332
+ return buildDistributedColumnWidths({
2333
+ table,
2334
+ hasSelection: Boolean(selectedRows && onRowSelect && dataKey),
2335
+ defaultMinPx: 80,
2336
+ columnSizing,
2337
+ availableWidth
2338
+ });
2339
+ }, [table, selectedRows, onRowSelect, dataKey, columnSizing, availableWidth]);
2340
+ const initialLayoutReady = availableWidth != null;
2341
+ const resolvedLayout = React9.useMemo(() => {
2342
+ const next = {};
2343
+ table.getVisibleLeafColumns().forEach((column) => {
2344
+ next[column.id] = {
2345
+ width: distributedLayout == null ? void 0 : distributedLayout.widths[column.id]
2346
+ };
2347
+ });
2348
+ return next;
2349
+ }, [table, distributedLayout]);
2350
+ const columnItems = React9.useMemo(
2351
+ () => mapDefsToColumnItems(columns, columnVisibility, resolvedLayout),
2352
+ [columns, columnVisibility, resolvedLayout]
2353
+ );
2354
+ const visibleData = table.getRowModel().rows.map((r) => r.original);
2355
+ const { sortById, sortDirection } = getSortPropsFromSorting(uiSorting);
2356
+ const handleSortChange = React9.useCallback(
2357
+ (column, direction) => {
2358
+ const next = direction == null ? [] : [{ id: column.id, desc: direction === "desc" }];
2359
+ if (optimisticSortingUi) setUiSorting(next);
2360
+ onSortingChange == null ? void 0 : onSortingChange(next);
2361
+ },
2362
+ [optimisticSortingUi, onSortingChange]
2363
+ );
2364
+ const headerExtras = React9.useCallback(
2365
+ ({ index }) => {
2366
+ var _a, _b, _c, _d;
2367
+ const headerGroups = table.getHeaderGroups();
2368
+ const leafHeaders = headerGroups.length > 0 ? headerGroups[headerGroups.length - 1].headers : [];
2369
+ const header = leafHeaders[index];
2370
+ if (!header) return null;
2371
+ const canResize = (_c = (_b = (_a = header.column).getCanResize) == null ? void 0 : _b.call(_a)) != null ? _c : false;
2372
+ const handler = (_d = header.getResizeHandler) == null ? void 0 : _d.call(header);
2373
+ if (!canResize || !handler) return null;
2374
+ return /* @__PURE__ */ jsx(ColumnResizer_default2, { id: header.column.id, handler });
2375
+ },
2376
+ [table]
2377
+ );
2378
+ return /* @__PURE__ */ jsx(
2379
+ Table,
2380
+ {
2381
+ ...tableProps,
2382
+ tableRootRef: containerRef,
2383
+ onSortChange: handleSortChange,
2384
+ dataKey,
2385
+ data: visibleData,
2386
+ columns: columnItems,
2387
+ tableWidth: distributedLayout == null ? void 0 : distributedLayout.totalWidth,
2388
+ measuringLayout: !initialLayoutReady,
2389
+ sortById,
2390
+ sortDirection,
2391
+ headerExtras,
2392
+ selectedRows,
2393
+ onRowSelect
2394
+ }
2395
+ );
2396
+ }
2397
+ function TableSettings({
2398
+ viewMode,
2399
+ handleChangeViewMode,
2400
+ columns = [],
2401
+ visibleColumnIds = [],
2402
+ onVisibleColumnIdsChange,
2403
+ columnsLabel = "Kolonner",
2404
+ allPresetLabel = "Alle",
2405
+ standardPresetLabel = "Standard",
2406
+ buttonSize = "sm",
2407
+ additionalSettings
2408
+ }) {
2409
+ const handleViewModeChange = (mode, close) => {
2410
+ handleChangeViewMode(mode === "wrapped" ? "compact" : "wrapped");
2411
+ close == null ? void 0 : close();
2412
+ };
2413
+ const hideableColumns = useMemo(() => columns.filter((c) => c.enableHiding !== false), [columns]);
2414
+ const allPresetIds = useMemo(() => hideableColumns.map((c) => c.id), [hideableColumns]);
2415
+ const standardPresetIds = useMemo(
2416
+ () => hideableColumns.filter((c) => {
2417
+ var _a;
2418
+ return ((_a = c.meta) == null ? void 0 : _a.hidden) !== true;
2419
+ }).map((c) => c.id),
2420
+ [hideableColumns]
2421
+ );
2422
+ const visibleSet = useMemo(() => new Set(visibleColumnIds), [visibleColumnIds]);
2423
+ const visibleCount = useMemo(() => {
2424
+ return hideableColumns.reduce((acc, c) => {
2425
+ var _a;
2426
+ return acc + (visibleSet.has((_a = c.id) != null ? _a : "") ? 1 : 0);
2427
+ }, 0);
2428
+ }, [hideableColumns, visibleSet]);
2429
+ const setVisibleIds = (nextIds) => {
2430
+ if (!onVisibleColumnIdsChange) return;
2431
+ const safe = nextIds.length > 0 ? nextIds : standardPresetIds.length > 0 ? standardPresetIds : allPresetIds;
2432
+ onVisibleColumnIdsChange(
2433
+ safe.filter((id) => typeof id === "string" && Boolean(id))
2434
+ );
2435
+ };
2436
+ const toggleColumn = (id, nextVisible) => {
2437
+ const next = new Set(visibleColumnIds);
2438
+ if (nextVisible) next.add(id);
2439
+ else next.delete(id);
2440
+ setVisibleIds(Array.from(next));
2441
+ };
2442
+ const isAllActive = useMemo(() => {
2443
+ if (!hideableColumns.length) return false;
2444
+ return hideableColumns.every((c) => c.id && visibleSet.has(c.id));
2445
+ }, [hideableColumns, visibleSet]);
2446
+ const isStandardActive = useMemo(() => {
2447
+ if (!hideableColumns.length) return false;
2448
+ const std = new Set(standardPresetIds);
2449
+ return hideableColumns.every((c) => c.id && visibleSet.has(c.id) === std.has(c.id));
2450
+ }, [hideableColumns, visibleSet, standardPresetIds]);
2451
+ const presetRadioName = "table-columns-preset";
2452
+ return /* @__PURE__ */ jsx(
2453
+ Popover,
2454
+ {
2455
+ trigger: (onClick, icon) => /* @__PURE__ */ jsxs(Button, { size: buttonSize, onClick, type: "button", children: [
2456
+ /* @__PURE__ */ jsx(Settings, {}),
2457
+ icon
2458
+ ] }),
2459
+ children: (close) => /* @__PURE__ */ jsxs(Menu, { children: [
2460
+ additionalSettings == null ? void 0 : additionalSettings(close),
2461
+ /* @__PURE__ */ jsx(Menu.Item, { active: viewMode === "wrapped", children: /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => handleViewModeChange(viewMode, close), children: [
2462
+ /* @__PURE__ */ jsx(ListChevronsDownUp, {}),
2463
+ "Ombryd tekst"
2464
+ ] }) }),
2465
+ hideableColumns.length > 0 && onVisibleColumnIdsChange ? /* @__PURE__ */ jsxs(Fragment, { children: [
2466
+ /* @__PURE__ */ jsx(Menu.Separator, {}),
2467
+ /* @__PURE__ */ jsx("div", { style: { padding: "6px 10px", fontSize: 12, opacity: 0.7 }, children: columnsLabel }),
2468
+ /* @__PURE__ */ jsx(
2469
+ Menu.RadioItem,
2470
+ {
2471
+ name: presetRadioName,
2472
+ value: "all",
2473
+ checked: isAllActive,
2474
+ label: allPresetLabel,
2475
+ onValueChange: () => {
2476
+ setVisibleIds(
2477
+ allPresetIds.filter((id) => typeof id === "string" && Boolean(id))
2478
+ );
2479
+ close == null ? void 0 : close();
2480
+ }
2481
+ }
2482
+ ),
2483
+ /* @__PURE__ */ jsx(
2484
+ Menu.RadioItem,
2485
+ {
2486
+ name: presetRadioName,
2487
+ value: "standard",
2488
+ checked: isStandardActive,
2489
+ label: standardPresetLabel,
2490
+ onValueChange: () => {
2491
+ setVisibleIds(
2492
+ standardPresetIds.filter(
2493
+ (id) => typeof id === "string" && Boolean(id)
2494
+ )
2495
+ );
2496
+ close == null ? void 0 : close();
2497
+ }
2498
+ }
2499
+ ),
2500
+ /* @__PURE__ */ jsx(Menu.Separator, {}),
2501
+ hideableColumns.map((col) => {
2502
+ const isVisible = col.id ? visibleSet.has(col.id) : false;
2503
+ const disableUncheckingLast = isVisible && visibleCount <= 1;
2504
+ const label = col.header;
2505
+ return /* @__PURE__ */ jsx(
2506
+ Menu.CheckItem,
2507
+ {
2508
+ checked: isVisible,
2509
+ disabled: disableUncheckingLast,
2510
+ label,
2511
+ onCheckedChange: (nextChecked) => {
2512
+ if (disableUncheckingLast) return;
2513
+ toggleColumn(col.id, nextChecked);
2514
+ }
2515
+ },
2516
+ col.id
2517
+ );
2518
+ })
2519
+ ] }) : null
2520
+ ] })
2521
+ }
2522
+ );
2523
+ }
2524
+
2525
+ // src/utils/localStorage.utils.ts
2526
+ function isBrowser() {
2527
+ return typeof window !== "undefined" && typeof window.localStorage !== "undefined";
2528
+ }
2529
+ function readLocalStorage(key) {
2530
+ if (!isBrowser()) return void 0;
2531
+ try {
2532
+ const raw = window.localStorage.getItem(key);
2533
+ if (raw == null) return void 0;
2534
+ try {
2535
+ const parsed = JSON.parse(raw);
2536
+ if (typeof parsed === "string") {
2537
+ try {
2538
+ return JSON.parse(parsed);
2539
+ } catch {
2540
+ return parsed;
2541
+ }
2542
+ }
2543
+ return parsed;
2544
+ } catch {
2545
+ return raw;
2546
+ }
2547
+ } catch {
2548
+ return void 0;
2549
+ }
2550
+ }
2551
+ function writeLocalStorage(key, value) {
2552
+ if (!isBrowser()) return;
2553
+ try {
2554
+ if (value === void 0) {
2555
+ window.localStorage.removeItem(key);
2556
+ return;
2557
+ }
2558
+ if (typeof value === "string") {
2559
+ window.localStorage.setItem(key, value);
2560
+ } else {
2561
+ window.localStorage.setItem(key, JSON.stringify(value));
2562
+ }
2563
+ } catch {
2564
+ }
2565
+ }
2566
+
2567
+ // src/hooks/useTableSettings.tsx
2568
+ function getDefaultVisibleIds(tableColumns) {
2569
+ var _a;
2570
+ return (_a = tableColumns == null ? void 0 : tableColumns.filter((c) => {
2571
+ var _a2;
2572
+ return !((_a2 = c.meta) == null ? void 0 : _a2.hidden);
2573
+ }).map((c) => c.id).filter(Boolean)) != null ? _a : [];
2574
+ }
2575
+ function mergeDefaults(stored, defaults) {
2576
+ const viewMode = (stored == null ? void 0 : stored.viewMode) === "compact" || (stored == null ? void 0 : stored.viewMode) === "wrapped" ? stored.viewMode : defaults.viewMode;
2577
+ const visibleColumnIds = Array.isArray(stored == null ? void 0 : stored.visibleColumnIds) && stored.visibleColumnIds.length > 0 ? stored.visibleColumnIds : defaults.visibleColumnIds;
2578
+ return { viewMode, visibleColumnIds };
2579
+ }
2580
+ var localStorageTableSettingsStorage = {
2581
+ get: (key) => {
2582
+ const v = readLocalStorage(key);
2583
+ return v && typeof v === "object" ? v : void 0;
2584
+ },
2585
+ set: (key, next) => {
2586
+ writeLocalStorage(key, next);
2587
+ }
2588
+ };
2589
+ function useTableSettings({
2590
+ storageKey,
2591
+ tableColumns,
2592
+ defaultViewMode = "compact",
2593
+ defaultVisibleColumnIds,
2594
+ storage = localStorageTableSettingsStorage
2595
+ }) {
2596
+ const defaults = useMemo(() => {
2597
+ return {
2598
+ viewMode: defaultViewMode,
2599
+ visibleColumnIds: defaultVisibleColumnIds != null ? defaultVisibleColumnIds : getDefaultVisibleIds(tableColumns)
2600
+ };
2601
+ }, [defaultViewMode, defaultVisibleColumnIds, tableColumns]);
2602
+ const [state, setState] = useState(defaults);
2603
+ useEffect(() => {
2604
+ const stored = storage.get(storageKey);
2605
+ const next = mergeDefaults(stored, defaults);
2606
+ setState(next);
2607
+ }, [storageKey, storage, defaults]);
2608
+ const persist = useCallback(
2609
+ (next) => storage.set(storageKey, next),
2610
+ [storage, storageKey]
2611
+ );
2612
+ const setViewMode = useCallback(
2613
+ (mode) => {
2614
+ setState((prev) => {
2615
+ if (prev.viewMode === mode) return prev;
2616
+ const next = { ...prev, viewMode: mode };
2617
+ persist(next);
2618
+ return next;
2619
+ });
2620
+ },
2621
+ [persist]
2622
+ );
2623
+ const toggleViewMode = useCallback(() => {
2624
+ setState((prev) => {
2625
+ const nextMode = prev.viewMode === "wrapped" ? "compact" : "wrapped";
2626
+ const next = { ...prev, viewMode: nextMode };
2627
+ persist(next);
2628
+ return next;
2629
+ });
2630
+ }, [persist]);
2631
+ const setVisibleColumnIds = useCallback(
2632
+ (ids) => {
2633
+ setState((prev) => {
2634
+ const next = { ...prev, visibleColumnIds: ids };
2635
+ persist(next);
2636
+ return next;
2637
+ });
2638
+ },
2639
+ [persist]
2640
+ );
2641
+ return {
2642
+ viewMode: state.viewMode,
2643
+ toggleViewMode,
2644
+ setViewMode,
2645
+ visibleColumnIds: state.visibleColumnIds,
2646
+ setVisibleColumnIds
2647
+ };
2648
+ }
2649
+
2650
+ export { TableSettings, TanstackTable, localStorageTableSettingsStorage, useTableSettings };