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