@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.
Files changed (223) hide show
  1. package/dist/components/table/Table.d.ts +1 -1
  2. package/dist/components/table/Table.types.d.ts +3 -0
  3. package/dist/components/table/components/TableHeader.d.ts +2 -1
  4. package/dist/index.cjs +12750 -0
  5. package/dist/index.css +7149 -0
  6. package/dist/index.js +12641 -79
  7. package/dist/tanstack.cjs +2674 -0
  8. package/dist/tanstack.css +1267 -0
  9. package/dist/tanstack.js +2650 -3
  10. package/dist/themes/dbc.css +3 -0
  11. package/dist/themes/forfatterweb.css +2 -0
  12. package/package.json +11 -10
  13. package/dist/assets/logo.js +0 -2
  14. package/dist/components/__stories__/_data/table.d.ts +0 -15
  15. package/dist/components/__stories__/_data/table.js +0 -55
  16. package/dist/components/__stories__/_data/tabs.d.ts +0 -9
  17. package/dist/components/__stories__/_data/tabs.js +0 -31
  18. package/dist/components/__stories__/story-components/Colors.d.ts +0 -11
  19. package/dist/components/__stories__/story-components/Colors.js +0 -96
  20. package/dist/components/__stories__/story-components/Colors.module.css +0 -27
  21. package/dist/components/__stories__/story-components/ComponentSizes.d.ts +0 -2
  22. package/dist/components/__stories__/story-components/ComponentSizes.js +0 -26
  23. package/dist/components/__stories__/story-components/Elevation.d.ts +0 -2
  24. package/dist/components/__stories__/story-components/Elevation.js +0 -49
  25. package/dist/components/__stories__/story-components/Flex.d.ts +0 -2
  26. package/dist/components/__stories__/story-components/Flex.js +0 -177
  27. package/dist/components/__stories__/story-components/Flex.module.css +0 -317
  28. package/dist/components/__stories__/story-components/Spacing.d.ts +0 -6
  29. package/dist/components/__stories__/story-components/Spacing.js +0 -76
  30. package/dist/components/__stories__/story-components/Spacing.module.css +0 -154
  31. package/dist/components/accordion/Accordion.js +0 -70
  32. package/dist/components/accordion/Accordion.module.css +0 -28
  33. package/dist/components/accordion/components/AccordionRow.js +0 -53
  34. package/dist/components/accordion/components/AccordionRow.module.css +0 -90
  35. package/dist/components/alert/Alert.js +0 -17
  36. package/dist/components/alert/Alert.module.css +0 -98
  37. package/dist/components/app-header/AppHeader.js +0 -5
  38. package/dist/components/app-header/AppHeader.module.css +0 -74
  39. package/dist/components/attribute-chip/AttributeChip.js +0 -5
  40. package/dist/components/attribute-chip/AttributeChip.module.css +0 -65
  41. package/dist/components/avatar/Avatar.js +0 -48
  42. package/dist/components/avatar/Avatar.module.css +0 -91
  43. package/dist/components/breadcrumbs/Breadcrumbs.js +0 -6
  44. package/dist/components/breadcrumbs/Breadcrumbs.module.css +0 -80
  45. package/dist/components/button/Button.js +0 -81
  46. package/dist/components/button/Button.module.css +0 -249
  47. package/dist/components/button-select/ButtonSelect.js +0 -7
  48. package/dist/components/button-select/ButtonSelect.module.css +0 -40
  49. package/dist/components/card/Card.js +0 -71
  50. package/dist/components/card/Card.module.css +0 -160
  51. package/dist/components/card/components/CardMeta.js +0 -26
  52. package/dist/components/card/components/CardMeta.module.css +0 -55
  53. package/dist/components/card-container/CardContainer.js +0 -6
  54. package/dist/components/card-container/CardContainer.module.css +0 -61
  55. package/dist/components/chip/Chip.js +0 -31
  56. package/dist/components/chip/Chip.module.css +0 -236
  57. package/dist/components/circle/Circle.js +0 -5
  58. package/dist/components/circle/Circle.module.css +0 -128
  59. package/dist/components/clear-button/ClearButton.js +0 -13
  60. package/dist/components/clear-button/ClearButton.module.css +0 -26
  61. package/dist/components/code-block/CodeBlock.js +0 -58
  62. package/dist/components/code-block/CodeBlock.module.css +0 -124
  63. package/dist/components/copy-button/CopyButton.js +0 -78
  64. package/dist/components/copy-button/CopyButton.module.css +0 -22
  65. package/dist/components/datetime-picker/DateTimePicker.js +0 -403
  66. package/dist/components/datetime-picker/DateTimePicker.module.css +0 -155
  67. package/dist/components/datetime-picker/dateTimeHelpers.js +0 -248
  68. package/dist/components/divider/Divider.js +0 -12
  69. package/dist/components/filter-field/FilterField.js +0 -191
  70. package/dist/components/filter-field/FilterField.module.css +0 -379
  71. package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.js +0 -52
  72. package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.module.css +0 -59
  73. package/dist/components/forms/checkbox/Checkbox.js +0 -28
  74. package/dist/components/forms/checkbox/Checkbox.module.css +0 -103
  75. package/dist/components/forms/checkbox-group/CheckboxGroup.js +0 -75
  76. package/dist/components/forms/checkbox-group/CheckboxGroup.module.css +0 -115
  77. package/dist/components/forms/form-select/FormSelect.js +0 -86
  78. package/dist/components/forms/form-select/FormSelect.module.css +0 -236
  79. package/dist/components/forms/input/Input.js +0 -77
  80. package/dist/components/forms/input/Input.module.css +0 -468
  81. package/dist/components/forms/input-container/InputContainer.js +0 -15
  82. package/dist/components/forms/input-container/InputContainer.module.css +0 -60
  83. package/dist/components/forms/multi-select/MultiSelect.js +0 -122
  84. package/dist/components/forms/radio-buttons/RadioButton.js +0 -26
  85. package/dist/components/forms/radio-buttons/RadioButtonGroup.js +0 -19
  86. package/dist/components/forms/radio-buttons/RadioButtons.module.css +0 -118
  87. package/dist/components/forms/select/Select.js +0 -185
  88. package/dist/components/forms/select/Select.module.css +0 -32
  89. package/dist/components/forms/text-area/Textarea.js +0 -47
  90. package/dist/components/forms/text-area/Textarea.module.css +0 -70
  91. package/dist/components/forms/typeahead/Typeahead.js +0 -668
  92. package/dist/components/forms/typeahead/Typeahead.module.css +0 -38
  93. package/dist/components/grid/Grid.js +0 -23
  94. package/dist/components/grid/Grid.module.css +0 -35
  95. package/dist/components/headline/CollapsibleHeadline.js +0 -29
  96. package/dist/components/headline/Headline.js +0 -26
  97. package/dist/components/headline/Headline.module.css +0 -185
  98. package/dist/components/hyperlink/Hyperlink.js +0 -40
  99. package/dist/components/hyperlink/Hyperlink.module.css +0 -107
  100. package/dist/components/icon/Icon.js +0 -14
  101. package/dist/components/icon/Icon.module.css +0 -36
  102. package/dist/components/interval-select/IntervalSelect.js +0 -99
  103. package/dist/components/json-viewer/HighlightedText.js +0 -6
  104. package/dist/components/json-viewer/JsonNode.js +0 -30
  105. package/dist/components/json-viewer/JsonViewer.js +0 -68
  106. package/dist/components/json-viewer/JsonViewer.module.css +0 -346
  107. package/dist/components/json-viewer/types.js +0 -1
  108. package/dist/components/json-viewer/useClipboardStatus.js +0 -11
  109. package/dist/components/json-viewer/utils.js +0 -125
  110. package/dist/components/menu/Menu.js +0 -165
  111. package/dist/components/menu/Menu.module.css +0 -220
  112. package/dist/components/meta-bar/MetaBar.js +0 -9
  113. package/dist/components/meta-bar/MetaBar.module.css +0 -27
  114. package/dist/components/nav-bar/NavBar.js +0 -29
  115. package/dist/components/nav-bar/NavBar.module.css +0 -221
  116. package/dist/components/overlay/fade-overlay/FadeOverlay.js +0 -8
  117. package/dist/components/overlay/fade-overlay/FadeOverlay.module.css +0 -54
  118. package/dist/components/overlay/modal/Modal.js +0 -115
  119. package/dist/components/overlay/modal/Modal.module.css +0 -109
  120. package/dist/components/overlay/modal/provider/ModalProvider.js +0 -73
  121. package/dist/components/overlay/side-panel/SidePanel.js +0 -83
  122. package/dist/components/overlay/side-panel/SidePanel.module.css +0 -177
  123. package/dist/components/overlay/side-panel/useSidePanel.js +0 -11
  124. package/dist/components/overlay/tooltip/Tooltip.js +0 -17
  125. package/dist/components/overlay/tooltip/Tooltip.module.css +0 -104
  126. package/dist/components/overlay/tooltip/TooltipProvider.js +0 -255
  127. package/dist/components/overlay/tooltip/useTooltipTrigger.js +0 -118
  128. package/dist/components/page/Page.js +0 -11
  129. package/dist/components/page/Page.module.css +0 -89
  130. package/dist/components/page-layout/PageLayout.js +0 -76
  131. package/dist/components/page-layout/PageLayout.module.css +0 -236
  132. package/dist/components/page-layout/components/layout-footer/LayoutFooter.js +0 -27
  133. package/dist/components/page-layout/components/layout-footer/LayoutFooter.module.css +0 -89
  134. package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.js +0 -14
  135. package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.module.css +0 -84
  136. package/dist/components/pagination/Pagination.js +0 -56
  137. package/dist/components/pagination/Pagination.module.css +0 -25
  138. package/dist/components/panel/Panel.js +0 -7
  139. package/dist/components/panel/Panel.module.css +0 -29
  140. package/dist/components/popover/Popover.js +0 -257
  141. package/dist/components/popover/Popover.module.css +0 -54
  142. package/dist/components/search-box/SearchBox.js +0 -170
  143. package/dist/components/search-box/SearchBox.module.css +0 -21
  144. package/dist/components/segmented-progress-bar/SegmentedProgressBar.js +0 -48
  145. package/dist/components/segmented-progress-bar/SegmentedProgressBar.module.css +0 -167
  146. package/dist/components/sidebar/Sidebar.js +0 -6
  147. package/dist/components/sidebar/components/SidebarItem.js +0 -8
  148. package/dist/components/sidebar/components/SidebarItem.module.css +0 -0
  149. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.js +0 -63
  150. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.module.css +0 -29
  151. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.js +0 -153
  152. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.module.css +0 -260
  153. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.js +0 -18
  154. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.module.css +0 -106
  155. package/dist/components/sidebar/components/sidebar-items/SidebarItems.js +0 -26
  156. package/dist/components/sidebar/components/sidebar-items/SidebarItems.module.css +0 -20
  157. package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.js +0 -30
  158. package/dist/components/sidebar/providers/SidebarProvider.js +0 -229
  159. package/dist/components/skeleton-loader/SkeletonLoader.js +0 -73
  160. package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.js +0 -13
  161. package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.module.css +0 -51
  162. package/dist/components/split-button/SplitButton.js +0 -10
  163. package/dist/components/split-button/SplitButton.module.css +0 -32
  164. package/dist/components/split-pane/SplitPane.js +0 -107
  165. package/dist/components/split-pane/SplitPane.module.css +0 -111
  166. package/dist/components/split-pane/provider/SplitPaneContext.js +0 -124
  167. package/dist/components/stack/Stack.js +0 -33
  168. package/dist/components/stack/Stack.module.css +0 -61
  169. package/dist/components/state-page/StatePage.js +0 -20
  170. package/dist/components/state-page/StatePage.module.css +0 -9
  171. package/dist/components/state-page/empty.js +0 -2
  172. package/dist/components/state-page/error.js +0 -2
  173. package/dist/components/state-page/notFound.js +0 -2
  174. package/dist/components/sticky-footer-layout/StickyFooterLayout.js +0 -64
  175. package/dist/components/table/Table.js +0 -50
  176. package/dist/components/table/Table.module.css +0 -536
  177. package/dist/components/table/Table.types.js +0 -1
  178. package/dist/components/table/TanstackTable.js +0 -111
  179. package/dist/components/table/components/TableBody.js +0 -10
  180. package/dist/components/table/components/TableHeader.js +0 -7
  181. package/dist/components/table/components/TableHeaderCell.js +0 -24
  182. package/dist/components/table/components/TableLoadingBody.js +0 -26
  183. package/dist/components/table/components/TablePagination.js +0 -1
  184. package/dist/components/table/components/TableRow.js +0 -54
  185. package/dist/components/table/components/TableSelectionCell.js +0 -16
  186. package/dist/components/table/components/column-resizer/ColumnResizer.js +0 -5
  187. package/dist/components/table/components/column-resizer/ColumnResizer.module.css +0 -22
  188. package/dist/components/table/components/empty-state/EmptyState.js +0 -23
  189. package/dist/components/table/components/empty-state/EmptyState.module.css +0 -4
  190. package/dist/components/table/components/table-settings/TableSettings.js +0 -63
  191. package/dist/components/table/hooks/useTableRowInteractions.js +0 -30
  192. package/dist/components/table/table.classes.js +0 -23
  193. package/dist/components/table/table.utils.js +0 -47
  194. package/dist/components/table/tanstackTable.utils.js +0 -175
  195. package/dist/components/tabs/Tabs.js +0 -125
  196. package/dist/components/tabs/Tabs.module.css +0 -233
  197. package/dist/components/theme-button/ThemeButton.js +0 -23
  198. package/dist/components/toast/Toast.js +0 -20
  199. package/dist/components/toast/Toast.module.css +0 -161
  200. package/dist/components/toast/provider/ToastProvider.js +0 -70
  201. package/dist/components/user-display/UserDisplay.js +0 -6
  202. package/dist/components/user-display/UserDisplay.module.css +0 -25
  203. package/dist/constants/severity.js +0 -24
  204. package/dist/constants/severity.types.js +0 -1
  205. package/dist/constants/sizes.js +0 -7
  206. package/dist/hooks/useDeviceSize.js +0 -32
  207. package/dist/hooks/useListNavigation.js +0 -234
  208. package/dist/hooks/usePagination.js +0 -140
  209. package/dist/hooks/useSorting.js +0 -118
  210. package/dist/hooks/useTableData.js +0 -45
  211. package/dist/hooks/useTableSelection.js +0 -164
  212. package/dist/hooks/useTableSettings.js +0 -71
  213. package/dist/hooks/useTheme.js +0 -66
  214. package/dist/hooks/useTimeDuration.js +0 -68
  215. package/dist/hooks/useViewportFill.js +0 -77
  216. package/dist/styles/animation.js +0 -5
  217. package/dist/styles/themes/types.js +0 -1
  218. package/dist/types/a11y-props.types.js +0 -1
  219. package/dist/types/sizes.types.js +0 -1
  220. package/dist/utils/arrays/nested-filtering.js +0 -48
  221. package/dist/utils/date/formatDate.js +0 -51
  222. package/dist/utils/localStorage.utils.js +0 -78
  223. package/dist/utils/text/get-highlighted-segments.js +0 -46
@@ -1,175 +0,0 @@
1
- import { DEFAULT_COLUMN_PX, SELECTION_COLUMN_PX } from './table.utils';
2
- export function getColumnId(def, index) {
3
- const d = def;
4
- if (d.id != null && String(d.id).length > 0)
5
- return String(d.id);
6
- if (d.accessorKey != null && String(d.accessorKey).length > 0)
7
- return String(d.accessorKey);
8
- return `col_${index}`;
9
- }
10
- export function buildColumnVisibilityFromVisibleIds(defs, visibleColumnIds) {
11
- if (!(visibleColumnIds === null || visibleColumnIds === void 0 ? void 0 : visibleColumnIds.length))
12
- return {};
13
- const visible = new Set(visibleColumnIds);
14
- const next = {};
15
- defs.forEach((def, index) => {
16
- const id = getColumnId(def, index);
17
- next[id] = visible.has(id);
18
- });
19
- return next;
20
- }
21
- export function mapDefsToColumnItems(defs, columnVisibility, resolvedLayout = {}) {
22
- return defs.map((def, index) => {
23
- var _a, _b, _c, _d, _e, _f, _g;
24
- const id = getColumnId(def, index);
25
- const accessorKey = def.accessorKey;
26
- const accessorFn = def.accessorFn;
27
- const cell = def.cell;
28
- const meta = ((_a = def.meta) !== null && _a !== void 0 ? _a : {});
29
- let render;
30
- if (typeof cell === 'function') {
31
- render = (row) => cell({
32
- row: { original: row },
33
- getValue: () => accessorKey != null
34
- ? row[accessorKey]
35
- : accessorFn
36
- ? accessorFn(row)
37
- : undefined,
38
- });
39
- }
40
- else if (accessorFn) {
41
- render = (row) => accessorFn(row);
42
- }
43
- else if (accessorKey != null) {
44
- render = (row) => row[accessorKey];
45
- }
46
- else {
47
- render = () => null;
48
- }
49
- const isVisible = (_b = columnVisibility[id]) !== null && _b !== void 0 ? _b : true;
50
- return {
51
- id,
52
- header: def.header,
53
- accessor: accessorKey,
54
- sortable: (_c = def.enableSorting) !== null && _c !== void 0 ? _c : !!accessorKey,
55
- render,
56
- hidden: !isVisible,
57
- width: (_d = resolvedLayout[id]) === null || _d === void 0 ? void 0 : _d.width,
58
- align: meta.align,
59
- verticalAlign: meta.verticalAlign,
60
- emptyPlaceholder: (_e = meta.emptyPlaceholder) !== null && _e !== void 0 ? _e : '-',
61
- allowWrap: (_f = meta.allowWrap) !== null && _f !== void 0 ? _f : false,
62
- severity: meta.severity,
63
- divider: meta.divider,
64
- allowOverflow: (_g = meta.allowOverflow) !== null && _g !== void 0 ? _g : false,
65
- };
66
- });
67
- }
68
- export function sortingEqual(a, b) {
69
- const A = a === null || a === void 0 ? void 0 : a[0];
70
- const B = b === null || b === void 0 ? void 0 : b[0];
71
- if (!A && !B)
72
- return true;
73
- if (!A || !B)
74
- return false;
75
- return A.id === B.id && A.desc === B.desc;
76
- }
77
- export function getSortPropsFromSorting(sorting) {
78
- const s = sorting === null || sorting === void 0 ? void 0 : sorting[0];
79
- return {
80
- sortById: s === null || s === void 0 ? void 0 : s.id,
81
- sortDirection: s ? (s.desc ? 'desc' : 'asc') : null,
82
- };
83
- }
84
- function clamp(value, min, max) {
85
- const lowerBounded = Math.max(min, value);
86
- if (max == null || !Number.isFinite(max))
87
- return lowerBounded;
88
- return Math.min(lowerBounded, max);
89
- }
90
- function toIntegerTrackWidths(tracks, targetWidth) {
91
- const floored = tracks.map(track => ({
92
- id: track.id,
93
- width: Math.floor(track.width),
94
- fraction: track.width - Math.floor(track.width),
95
- }));
96
- const baseTotal = floored.reduce((sum, track) => sum + track.width, 0);
97
- let remainder = Math.max(0, targetWidth - baseTotal);
98
- floored
99
- .slice()
100
- .sort((a, b) => b.fraction - a.fraction)
101
- .forEach(track => {
102
- if (remainder <= 0)
103
- return;
104
- track.width += 1;
105
- remainder -= 1;
106
- });
107
- return Object.fromEntries(floored.map(track => [track.id, track.width]));
108
- }
109
- export function buildDistributedColumnWidths(args) {
110
- const { table, hasSelection, defaultMinPx, columnSizing, availableWidth } = args;
111
- const leaf = table.getVisibleLeafColumns();
112
- const selectionWidth = hasSelection ? SELECTION_COLUMN_PX : 0;
113
- const tracks = leaf.map((c) => {
114
- var _a, _b, _c, _d;
115
- const def = c.columnDef;
116
- const meta = ((_a = def.meta) !== null && _a !== void 0 ? _a : {});
117
- const min = Math.max(1, Number((_b = def.minSize) !== null && _b !== void 0 ? _b : defaultMinPx));
118
- const max = def.maxSize != null ? Math.max(min, Number(def.maxSize)) : undefined;
119
- const resizedPxRaw = columnSizing[c.id];
120
- const resizedPx = resizedPxRaw != null ? Math.round(clamp(Number(resizedPxRaw), min, max)) : undefined;
121
- if (resizedPx != null) {
122
- return {
123
- id: c.id,
124
- width: resizedPx,
125
- weight: 0,
126
- max: resizedPx,
127
- fixed: true,
128
- };
129
- }
130
- const rawWeight = Number((_d = (_c = meta.weight) !== null && _c !== void 0 ? _c : def.size) !== null && _d !== void 0 ? _d : DEFAULT_COLUMN_PX);
131
- const weight = Number.isFinite(rawWeight) && rawWeight > 0 ? rawWeight : DEFAULT_COLUMN_PX;
132
- return {
133
- id: c.id,
134
- width: min,
135
- weight,
136
- max,
137
- fixed: false,
138
- };
139
- });
140
- const fixedWidth = selectionWidth + tracks.reduce((sum, track) => sum + track.width, 0);
141
- let remaining = Math.max(0, availableWidth - fixedWidth);
142
- let active = tracks.filter(track => !track.fixed && (track.max == null || track.width < track.max));
143
- while (remaining > 0.5 && active.length > 0) {
144
- const totalWeight = active.reduce((sum, track) => sum + track.weight, 0);
145
- if (totalWeight <= 0)
146
- break;
147
- let consumed = 0;
148
- const nextActive = [];
149
- for (const track of active) {
150
- const share = (remaining * track.weight) / totalWeight;
151
- const maxGrow = track.max == null ? share : Math.max(0, track.max - track.width);
152
- const growth = Math.min(share, maxGrow);
153
- track.width += growth;
154
- consumed += growth;
155
- if (track.max == null || track.width < track.max - 0.5) {
156
- nextActive.push(track);
157
- }
158
- }
159
- if (consumed <= 0.5)
160
- break;
161
- remaining -= consumed;
162
- active = nextActive;
163
- }
164
- const floatTrackTotal = tracks.reduce((sum, track) => sum + track.width, 0);
165
- const targetTrackWidth = floatTrackTotal <= availableWidth - selectionWidth
166
- ? Math.floor(floatTrackTotal)
167
- : Math.ceil(floatTrackTotal);
168
- const widths = toIntegerTrackWidths(tracks, targetTrackWidth);
169
- const totalWidth = selectionWidth + Object.values(widths).reduce((sum, width) => sum + width, 0);
170
- return {
171
- selectionWidth: hasSelection ? SELECTION_COLUMN_PX : undefined,
172
- widths,
173
- totalWidth,
174
- };
175
- }
@@ -1,125 +0,0 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Children, isValidElement, useCallback, useEffect, useId, useMemo, useState, } from 'react';
3
- import styles from './Tabs.module.css';
4
- import { Chip } from '../chip/Chip';
5
- import { Headline } from '../headline/Headline';
6
- const TabsItem = (_props) => {
7
- // This never renders directly; parent consumes it.
8
- return _jsx(_Fragment, {});
9
- };
10
- TabsItem.__TABS_SLOT__ = 'Item';
11
- function getFirstEnabledId(items) {
12
- var _a;
13
- return (_a = items.find(t => !t.hidden && !t.disabled)) === null || _a === void 0 ? void 0 : _a.id;
14
- }
15
- function normalizeFromChildren(children) {
16
- const items = [];
17
- Children.forEach(children, child => {
18
- if (!isValidElement(child))
19
- return;
20
- const t = child.type;
21
- if ((t === null || t === void 0 ? void 0 : t.__TABS_SLOT__) !== 'Item')
22
- return;
23
- const props = child.props;
24
- items.push({
25
- id: props.id,
26
- header: props.header,
27
- headerIcon: props.headerIcon,
28
- disabled: props.disabled,
29
- hidden: props.hidden,
30
- badge: props.badge,
31
- content: props.children,
32
- });
33
- });
34
- return items;
35
- }
36
- export function Tabs({ header, subheader, variant, panelStyle = false, tabs, value, defaultValue, onValueChange, addition, disableTopPadding, children, }) {
37
- const uid = useId();
38
- // Data API wins if provided; otherwise parse <Tabs.Item>
39
- const sourceTabs = useMemo(() => {
40
- if (tabs && tabs.length)
41
- return tabs;
42
- return normalizeFromChildren(children);
43
- }, [tabs, children]);
44
- const visibleTabs = useMemo(() => sourceTabs.filter(t => !t.hidden), [sourceTabs]);
45
- const isControlled = value !== undefined;
46
- const [internalValue, setInternalValue] = useState(() => {
47
- return defaultValue !== null && defaultValue !== void 0 ? defaultValue : getFirstEnabledId(visibleTabs);
48
- });
49
- const currentValue = isControlled ? value : internalValue;
50
- const activeIndex = useMemo(() => {
51
- if (!visibleTabs.length)
52
- return -1;
53
- const idx = visibleTabs.findIndex(t => t.id === currentValue);
54
- return idx >= 0 ? idx : 0;
55
- }, [visibleTabs, currentValue]);
56
- const activeTab = activeIndex >= 0 ? visibleTabs[activeIndex] : undefined;
57
- const setValue = useCallback((nextId) => {
58
- const idx = visibleTabs.findIndex(t => t.id === nextId);
59
- const tab = idx >= 0 ? visibleTabs[idx] : undefined;
60
- if (!tab || tab.disabled)
61
- return;
62
- if (!isControlled)
63
- setInternalValue(nextId);
64
- onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(nextId, tab, idx);
65
- }, [visibleTabs, isControlled, onValueChange]);
66
- // If current tab disappears (hidden/removed) or becomes disabled, recover to first enabled.
67
- useEffect(() => {
68
- if (!visibleTabs.length)
69
- return;
70
- const current = currentValue;
71
- const stillValid = visibleTabs.some(t => t.id === current && !t.disabled);
72
- if (stillValid)
73
- return;
74
- const next = getFirstEnabledId(visibleTabs);
75
- if (next === undefined)
76
- return;
77
- setValue(next);
78
- // setValue already calls onValueChange; fine.
79
- // For controlled usage, parent should update `value` accordingly.
80
- // If parent doesn't, it will remain "stuck" by design.
81
- }, [visibleTabs, currentValue, setValue]);
82
- // Keyboard: roving tabindex + select-on-arrow
83
- const onKeyDownTab = useCallback((e, index) => {
84
- var _a;
85
- const enabled = visibleTabs.filter(t => !t.disabled);
86
- if (!enabled.length)
87
- return;
88
- // Map current index -> enabled index
89
- const currentId = (_a = visibleTabs[index]) === null || _a === void 0 ? void 0 : _a.id;
90
- const currentEnabledIndex = enabled.findIndex(t => t.id === currentId);
91
- const focusAndSelect = (enabledIndex) => {
92
- const nextTab = enabled[enabledIndex];
93
- if (!nextTab)
94
- return;
95
- const btn = document.getElementById(`${uid}-tab-${String(nextTab.id)}`);
96
- btn === null || btn === void 0 ? void 0 : btn.focus();
97
- setValue(nextTab.id);
98
- };
99
- if (e.key === 'ArrowRight') {
100
- e.preventDefault();
101
- focusAndSelect((currentEnabledIndex + 1) % enabled.length);
102
- }
103
- else if (e.key === 'ArrowLeft') {
104
- e.preventDefault();
105
- focusAndSelect((currentEnabledIndex - 1 + enabled.length) % enabled.length);
106
- }
107
- else if (e.key === 'Home') {
108
- e.preventDefault();
109
- focusAndSelect(0);
110
- }
111
- else if (e.key === 'End') {
112
- e.preventDefault();
113
- focusAndSelect(enabled.length - 1);
114
- }
115
- }, [uid, visibleTabs, setValue]);
116
- return (_jsxs("div", { className: styles.root, children: [header ? (_jsx("div", { className: [styles.headerContainer, disableTopPadding ? styles.disableTopPadding : '']
117
- .filter(Boolean)
118
- .join(' '), children: _jsx(Headline, { disableMargin: true, size: 2, subheader: subheader, addition: addition, children: header }) })) : null, _jsxs("div", { className: `${styles.tabs} ${styles[variant]} ${panelStyle ? styles.panelStyle : ''}`, children: [_jsx("div", { className: styles.tabList, role: "tablist", "aria-label": header !== null && header !== void 0 ? header : 'Tabs', children: visibleTabs.map((tab, index) => {
119
- const selected = index === activeIndex;
120
- const tabDomId = `${uid}-tab-${String(tab.id)}`;
121
- const panelDomId = `${uid}-panel-${String(tab.id)}`;
122
- return (_jsx("div", { className: `${styles.tab} ${selected ? styles.active : ''}`, children: _jsxs("button", { id: tabDomId, type: "button", className: styles.tabButton, role: "tab", "aria-selected": selected, "aria-controls": panelDomId, tabIndex: selected ? 0 : -1, disabled: tab.disabled, onClick: () => setValue(tab.id), onKeyDown: e => onKeyDownTab(e, index), children: [tab.headerIcon ? _jsx("span", { className: styles.icon, children: tab.headerIcon }) : null, _jsx("span", { className: styles.label, children: tab.header }), tab.badge ? (_jsx("span", { className: styles.badge, children: _jsx(Chip, { size: "sm", children: tab.badge.toLocaleString('da-DK') }) })) : null] }) }, tab.id));
123
- }) }), _jsx("div", { id: activeTab ? `${uid}-panel-${String(activeTab.id)}` : undefined, role: "tabpanel", "aria-labelledby": activeTab ? `${uid}-tab-${String(activeTab.id)}` : undefined, className: styles.tabContent, children: activeTab === null || activeTab === void 0 ? void 0 : activeTab.content })] })] }));
124
- }
125
- Tabs.Item = TabsItem;
@@ -1,233 +0,0 @@
1
- .root {
2
- display: flex;
3
- flex-direction: column;
4
- min-width: 0;
5
- overflow: auto;
6
- }
7
-
8
- .headerContainer {
9
- display: flex;
10
- justify-content: space-between;
11
- align-items: center;
12
- padding-block: var(--spacing-lg);
13
- gap: var(--spacing-md);
14
- }
15
-
16
- .headerContainer.disableTopPadding {
17
- padding-block-start: 0;
18
- }
19
-
20
- /* Outer wrapper for tablist + content */
21
- .tabs {
22
- display: flex;
23
- flex-direction: column;
24
- flex-grow: 1;
25
- overflow: hidden;
26
- min-height: 0;
27
- }
28
-
29
- /* Tablist */
30
- .tabList {
31
- display: flex;
32
- flex-wrap: wrap;
33
- min-width: 0;
34
- }
35
-
36
- /* Individual tab wrapper */
37
- .tab {
38
- display: flex;
39
- flex-direction: column;
40
- border-radius: 0;
41
- border-block-end: 2px solid var(--color-border-default);
42
- }
43
-
44
- .active {
45
- border-block-end-color: var(--color-brand);
46
- }
47
-
48
- /* Button */
49
- .tabButton {
50
- font-size: var(--font-size-sm);
51
- color: inherit;
52
-
53
- display: inline-flex;
54
- align-items: center;
55
- justify-content: center;
56
- gap: var(--spacing-xs);
57
-
58
- white-space: nowrap;
59
-
60
- background: none;
61
- border: 0;
62
- border-radius: 0;
63
-
64
- padding-block: var(--spacing-sm);
65
- padding-inline: var(--spacing-md);
66
-
67
- cursor: pointer;
68
-
69
- transition:
70
- color var(--transition-fast) var(--ease-standard),
71
- background-color var(--transition-fast) var(--ease-standard),
72
- border-color var(--transition-fast) var(--ease-standard);
73
- }
74
-
75
- .tabButton:focus-visible {
76
- outline: none;
77
- box-shadow: var(--focus-ring);
78
- }
79
-
80
- .tabButton:disabled {
81
- cursor: not-allowed;
82
- color: var(--color-disabled-fg);
83
- }
84
-
85
- /* Icon + label */
86
- .icon {
87
- display: inline-flex;
88
- align-items: center;
89
- color: inherit;
90
- }
91
-
92
- .icon svg {
93
- inline-size: var(--icon-size-md);
94
- block-size: var(--icon-size-md);
95
- }
96
-
97
- .label {
98
- display: inline-block;
99
- }
100
-
101
- .badge {
102
- display: inline-flex;
103
- align-items: center;
104
- }
105
-
106
- /* Content panel */
107
- .tabContent {
108
- flex: 1 1 auto;
109
- min-height: 0;
110
- overflow: auto;
111
- }
112
-
113
- /* =========================
114
- Filled variant
115
- ========================= */
116
-
117
- .filled {
118
- gap: 0;
119
- }
120
-
121
- .filled .tabList {
122
- border-start-start-radius: var(--border-radius-default);
123
- border-start-end-radius: var(--border-radius-default);
124
- inline-size: fit-content;
125
- }
126
-
127
- .filled .tab {
128
- border: var(--border-width-thin) solid transparent;
129
- border-block-end: 0;
130
- color: var(--color-fg-muted);
131
- z-index: 3;
132
- border-start-start-radius: var(--border-radius-default);
133
- border-start-end-radius: var(--border-radius-default);
134
- transition:
135
- background-color var(--transition-fast) var(--ease-standard),
136
- color var(--transition-fast) var(--ease-standard),
137
- border-color var(--transition-fast) var(--ease-standard);
138
- }
139
-
140
- .filled .tab:not(.active):hover {
141
- color: var(--color-brand);
142
- }
143
-
144
- .filled .tab.active {
145
- background: var(--opac-bg-brand);
146
- color: var(--color-brand);
147
- border-color: var(--opac-bg-dark);
148
- }
149
-
150
- .filled .tabContent {
151
- border: var(--border-width-thin) solid var(--opac-bg-dark);
152
- background: var(--color-bg-surface);
153
- padding: var(--spacing-lg);
154
- }
155
-
156
- /* =========================
157
- Outlined variant
158
- ========================= */
159
-
160
- .outlined {
161
- gap: var(--spacing-md);
162
- }
163
-
164
- .outlined .tab {
165
- color: var(--color-fg-muted);
166
- border-block-end: 2px solid var(--color-border-default);
167
- transition: color var(--transition-fast) var(--ease-standard);
168
- }
169
-
170
- .outlined .tab:not(.active):hover {
171
- color: var(--color-brand);
172
- }
173
-
174
- .outlined .tab.active {
175
- color: var(--color-brand);
176
- border-block-end-color: var(--color-brand);
177
- }
178
-
179
- .outlined .tabContent {
180
- background: transparent;
181
- padding: 0;
182
- }
183
-
184
- /* =========================
185
- Panel style modifier
186
- ========================= */
187
-
188
- .panelStyle .tabList {
189
- border: var(--border-width-thin) solid var(--color-border-default);
190
- border-block-end: 0;
191
- }
192
-
193
- /* When panelStyle is on, tabs look “embedded” (no bottom border indicators) */
194
- .panelStyle .tab {
195
- border-block-end: 0;
196
- }
197
-
198
- /* In filled mode, keep the filled content panel visuals (already handled above).
199
- In outlined mode with panelStyle, give the content a panel container too. */
200
- .panelStyle.outlined .tabContent {
201
- border: var(--border-width-thin) solid var(--color-border-default);
202
- background: var(--color-bg-surface);
203
- padding: var(--spacing-lg);
204
- }
205
-
206
- @media (max-width: 767px) {
207
- .headerContainer {
208
- padding-block: var(--spacing-md);
209
- }
210
-
211
- .tabButton {
212
- padding-block: var(--spacing-sm);
213
- padding-inline: var(--spacing-xs);
214
- }
215
-
216
- .filled .tabList {
217
- border-start-start-radius: 0;
218
- border-start-end-radius: 0;
219
- inline-size: 100%;
220
- }
221
-
222
- .filled .tabContent,
223
- .panelStyle.outlined .tabContent {
224
- padding-block: var(--spacing-md);
225
- padding-inline: 0;
226
- border: 0;
227
- border-radius: 0;
228
- }
229
-
230
- .panelStyle .tabList {
231
- border: 0;
232
- }
233
- }
@@ -1,23 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { Monitor, Moon, Palette, Sun } from 'lucide-react';
4
- import { Button } from '../../components/button/Button';
5
- import { Menu } from '../../components/menu/Menu';
6
- import { Popover } from '../../components/popover/Popover';
7
- import { useTheme } from '../../hooks/useTheme';
8
- const THEME_OPTIONS = [
9
- { value: 'system', label: 'System', icon: _jsx(Monitor, { size: 16 }) },
10
- { value: 'light', label: 'Lyst', icon: _jsx(Sun, { size: 16 }) },
11
- { value: 'dark', label: 'Mørkt', icon: _jsx(Moon, { size: 16 }) },
12
- ];
13
- export function ThemeMenuSection() {
14
- const { theme, switchTheme } = useTheme();
15
- return (_jsxs(_Fragment, { children: [_jsxs(Menu.Header, { children: [_jsx(Palette, {}), "Udseende"] }), THEME_OPTIONS.map(option => (_jsx(Menu.RadioItem, { name: "theme", value: option.value, checked: theme === option.value, label: option.label, onValueChange: value => switchTheme(value) }, option.value)))] }));
16
- }
17
- export function ThemeButton({ size, variant = 'outlined' }) {
18
- const { theme, switchTheme } = useTheme();
19
- return (_jsx(Popover, { matchTriggerWidth: false, minWidth: "140px", trigger: (handleClick, chevron) => (_jsxs(Button, { variant: variant, size: size, onClick: handleClick, "aria-label": "Skift tema", "aria-haspopup": "menu", children: [_jsx(Palette, {}), chevron] })), children: close => (_jsxs(Menu, { children: [_jsx(Menu.Header, { children: "Udseende" }), THEME_OPTIONS.map(option => (_jsx(Menu.Item, { active: theme === option.value, children: _jsxs("button", { onClick: () => {
20
- switchTheme(option.value);
21
- close();
22
- }, children: [option.icon, option.label] }) }, option.value)))] })) }));
23
- }
@@ -1,20 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { X } from 'lucide-react';
3
- import styles from './Toast.module.css';
4
- import { Button } from '../button/Button';
5
- import { Headline } from '../headline/Headline';
6
- export function Toast({ title, subheader, message, severity = 'info', action, onClose, }) {
7
- const showHeader = Boolean(title);
8
- const showMessage = Boolean(message);
9
- const canClose = severity !== 'neutral';
10
- const isDismissibleNeutral = severity === 'neutral' && Boolean(onClose);
11
- const CloseButton = onClose && canClose ? (_jsx(Button, { type: "button", variant: "inline", shape: "round", className: styles.closeButton, "aria-label": "Dismiss notification", onClick: onClose, children: _jsx(X, { className: styles.closeIcon, "aria-hidden": "true" }) })) : null;
12
- return (_jsxs("div", { className: `${styles.toast} ${styles[severity]} ${isDismissibleNeutral ? styles.dismissibleNeutral : ''}`, role: "status", onClick: isDismissibleNeutral ? onClose : undefined, onKeyDown: isDismissibleNeutral
13
- ? e => {
14
- if (e.key === 'Enter' || e.key === ' ') {
15
- e.preventDefault();
16
- onClose === null || onClose === void 0 ? void 0 : onClose();
17
- }
18
- }
19
- : undefined, tabIndex: isDismissibleNeutral ? 0 : undefined, "aria-label": isDismissibleNeutral ? 'Luk notifikation' : undefined, children: [_jsxs("div", { className: styles.content, children: [showHeader && (_jsxs("div", { className: styles.row, children: [_jsx(Headline, { size: 4, severity: severity, disableMargin: true, subheader: subheader, children: title }), CloseButton] })), showMessage && (_jsxs("div", { className: styles.row, children: [_jsx("div", { className: styles.message, children: message }), !showHeader && CloseButton] }))] }), action && (_jsx("div", { className: styles.actions, children: _jsx(Button, { type: "button", variant: "primary", onClick: action.onClick, children: action.label }) }))] }));
20
- }