@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,18 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import React from 'react';
4
- import { getHighlightedSegments } from '../../../../utils/text/get-highlighted-segments';
5
- import styles from './SidebarItemContent.module.css';
6
- import { useSidebar } from '../../providers/SidebarProvider';
7
- export function SidebarItemContent({ icon, label, suffixIcon, href, iconWidth, disableActiveStyles = false, headerStyle, truncateLabel = false, }) {
8
- const { activeLink, activeQuery, isSidebarCollapsed, wrapItemText } = useSidebar();
9
- const iconStyle = iconWidth !== undefined
10
- ? { ['--sidebar-item-icon-width']: iconWidth }
11
- : undefined;
12
- const shouldTruncate = truncateLabel && !wrapItemText && !activeQuery;
13
- const highlightTerms = activeQuery.trim().split(/\s+/).filter(Boolean);
14
- const renderedLabel = typeof label === 'string' && highlightTerms.length > 0
15
- ? getHighlightedSegments(label, highlightTerms).map((segment, index) => segment.matched ? (_jsx("mark", { className: "dbc-highlight", children: segment.text }, `${segment.text}-${index}`)) : (_jsx(React.Fragment, { children: segment.text }, `${segment.text}-${index}`)))
16
- : label;
17
- return (_jsxs("span", { className: `${styles.container} ${!disableActiveStyles && activeLink === href ? styles.active : ''} ${isSidebarCollapsed ? styles.collapsed : ''} ${headerStyle ? styles.headerStyle : ''}`, children: [_jsxs("span", { className: styles.iconLabel, children: [_jsx("span", { className: styles.icon, style: iconStyle, children: icon }), !isSidebarCollapsed && (_jsx("span", { className: `${styles.label} ${shouldTruncate ? styles.truncate : ''}`, title: shouldTruncate && typeof label === 'string' ? label : undefined, children: renderedLabel }))] }), suffixIcon && !isSidebarCollapsed && _jsx("span", { className: styles.suffixIcon, children: suffixIcon })] }));
18
- }
@@ -1,106 +0,0 @@
1
- .container {
2
- inline-size: 100%;
3
- display: flex;
4
- align-items: center;
5
- justify-content: space-between;
6
- gap: var(--spacing-sm);
7
- padding-block: var(--spacing-xs);
8
- padding-inline: var(--spacing-xs);
9
- text-decoration: none;
10
- color: var(--color-fg-muted);
11
- cursor: pointer;
12
- position: relative;
13
- border-radius: var(--border-radius-md);
14
- user-select: none;
15
- transition:
16
- background-color var(--transition-fast) var(--ease-standard),
17
- color var(--transition-fast) var(--ease-standard);
18
- }
19
-
20
- .container.collapsed {
21
- justify-content: center;
22
- padding: var(--spacing-xs);
23
- border-radius: 0;
24
- }
25
-
26
- .active {
27
- background: var(--color-bg-selected);
28
- }
29
-
30
- .active::before {
31
- content: '';
32
- position: absolute;
33
- inset-inline-start: 0;
34
- inset-block: 0;
35
- inline-size: 3px;
36
- background-color: var(--color-brand);
37
- border-start-start-radius: inherit;
38
- border-end-start-radius: inherit;
39
- }
40
-
41
- .iconLabel {
42
- display: flex;
43
- align-items: center;
44
- gap: var(--spacing-sm);
45
- min-inline-size: 0;
46
- flex: 1 1 0;
47
- overflow: hidden;
48
- }
49
-
50
- .container:not(.active):hover {
51
- background-color: var(--color-bg-toolbar-hover);
52
-
53
- color: var(--color-fg-default);
54
- }
55
-
56
- .icon,
57
- .suffixIcon {
58
- inline-size: var(--sidebar-item-icon-width, auto);
59
- min-inline-size: var(--icon-size-sm);
60
- flex: 0 0 var(--sidebar-item-icon-width, auto);
61
- display: flex;
62
- align-items: center;
63
- justify-content: flex-start;
64
- color: var(--color-fg-subtle);
65
- }
66
-
67
- .icon {
68
- min-inline-size: var(--sidebar-item-icon-width, var(--icon-size-sm));
69
- }
70
-
71
- .icon svg,
72
- .suffixIcon svg {
73
- inline-size: var(--icon-size-sm);
74
- block-size: var(--icon-size-sm);
75
- color: inherit;
76
- }
77
-
78
- .collapsed svg {
79
- inline-size: var(--icon-size-md);
80
- block-size: var(--icon-size-md);
81
- }
82
-
83
- .container:focus-visible {
84
- outline: none;
85
- box-shadow: var(--focus-ring);
86
- }
87
-
88
- .headerStyle .label {
89
- font-weight: 500;
90
- color: var(--color-fg-subtle);
91
- font-size: var(--font-size-xs);
92
- text-transform: uppercase;
93
- letter-spacing: 0.04em;
94
- transition: 0.15s ease-in-out;
95
- }
96
-
97
- .label {
98
- min-inline-size: 0;
99
- flex: 1 1 auto;
100
- }
101
-
102
- .truncate {
103
- overflow: hidden;
104
- text-overflow: ellipsis;
105
- white-space: nowrap;
106
- }
@@ -1,26 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useEffect } from 'react';
4
- import styles from './SidebarItems.module.css';
5
- import { useSidebar } from '../../providers/SidebarProvider';
6
- import { ExpandableSidebarItem } from '../expandable-sidebar-item/ExpandableSidebarItem';
7
- import { SidebarItem } from '../SidebarItem';
8
- export function SidebarItems({ activeLink }) {
9
- const { filteredItems, setActiveLink, isSidebarCollapsed } = useSidebar();
10
- useEffect(() => {
11
- setActiveLink(activeLink !== null && activeLink !== void 0 ? activeLink : '');
12
- }, [activeLink, setActiveLink]);
13
- const renderItem = (item, key) => {
14
- var _a, _b;
15
- if (item.type === 'group') {
16
- return isSidebarCollapsed ? ((_a = item.children) === null || _a === void 0 ? void 0 : _a.map((child, idx) => renderItem(child, `${key}-c${idx}`))) : (_jsxs("div", { className: styles.group, children: [_jsx("div", { className: styles.groupLabel, children: item.label }), (_b = item.children) === null || _b === void 0 ? void 0 : _b.map((child, idx) => renderItem(child, `${key}-c${idx}`))] }, key));
17
- }
18
- if (item.type === 'expandable') {
19
- const { component: Component, label, icon, children, href, iconWidth, truncateLabel } = item;
20
- return (_jsx(ExpandableSidebarItem, { items: children, label: label, icon: icon, href: href, iconWidth: iconWidth, truncateLabel: truncateLabel, component: Component }, key));
21
- }
22
- const { component: Component, label, icon, href, iconWidth, truncateLabel } = item;
23
- return (_jsx(SidebarItem, { component: Component, label: label, icon: icon, href: href, iconWidth: iconWidth, truncateLabel: truncateLabel }, key));
24
- };
25
- return filteredItems === null || filteredItems === void 0 ? void 0 : filteredItems.map((item, idx) => renderItem(item, `nav-${idx}-${item.label}`));
26
- }
@@ -1,20 +0,0 @@
1
- .group {
2
- display: flex;
3
- flex-direction: column;
4
- gap: var(--spacing-xxs);
5
- margin-top: var(--spacing-xs);
6
- }
7
-
8
- .group:first-child {
9
- margin-top: 0;
10
- }
11
-
12
- .groupLabel {
13
- padding: 0 var(--spacing-xs);
14
- margin: var(--spacing-xs) 0;
15
- font-size: var(--font-size-xs);
16
- font-weight: var(--font-weight-medium);
17
- color: var(--color-fg-subtle);
18
- letter-spacing: 0.04em;
19
- text-transform: uppercase;
20
- }
@@ -1,30 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Search, Settings2 } from 'lucide-react';
4
- import React from 'react';
5
- import { Button } from '../../../button/Button';
6
- import { Menu } from '../../../menu/Menu';
7
- import { Popover } from '../../../popover/Popover';
8
- import { SearchBox } from '../../../search-box/SearchBox';
9
- import { useSidebar } from '../../providers/SidebarProvider';
10
- const SidenavFiltering = ({ placeholder = 'Filtrer menu', showSettings = false, }) => {
11
- const { activeQuery, setActiveQuery, isSidebarCollapsed, handleSidebarCollapseChange, wrapItemText, setWrapItemText, } = useSidebar();
12
- const searchBoxRef = React.useRef(null);
13
- const handleSearch = (value) => {
14
- setActiveQuery === null || setActiveQuery === void 0 ? void 0 : setActiveQuery(value);
15
- };
16
- if (isSidebarCollapsed) {
17
- return (_jsx(Button, { fullWidth: true, icon: _jsx(Search, {}), size: "sm", variant: "inline", onClick: () => {
18
- handleSidebarCollapseChange(false);
19
- setTimeout(() => {
20
- var _a;
21
- (_a = searchBoxRef.current) === null || _a === void 0 ? void 0 : _a.focus();
22
- }, 50);
23
- } }));
24
- }
25
- return (_jsxs("div", { style: { display: 'flex', alignItems: 'stretch', gap: 'var(--spacing-xs)' }, children: [_jsx(SearchBox, { ref: searchBoxRef, inputWidth: "100%", inputSize: "sm", value: activeQuery !== null && activeQuery !== void 0 ? activeQuery : '', onSearch: handleSearch, placeholder: placeholder, fullWidth: true }), showSettings ? (_jsx(Popover, { minWidth: "220px", trigger: toggle => (_jsx(Button, { type: "button", size: "sm", variant: "outlined", shape: "round", "aria-label": "\u00C5bn indstillinger for sidemenu", onClick: toggle, icon: _jsx(Settings2, {}) })), children: close => (_jsx(Menu, { children: _jsx(Menu.Item, { active: wrapItemText, children: _jsx("button", { type: "button", onClick: () => {
26
- setWrapItemText(!wrapItemText);
27
- close();
28
- }, children: "Ombryd tekst" }) }) })) })) : null] }));
29
- };
30
- export default SidenavFiltering;
@@ -1,229 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
4
- import { nestedFiltering } from '../../../utils/arrays/nested-filtering';
5
- const hasChildren = (item) => Array.isArray(item.children) && item.children.length > 0;
6
- const hasHref = (item) => typeof item.href === 'string' && item.href.length > 0;
7
- const normalizeHref = (href) => {
8
- if (!href)
9
- return href;
10
- // strip trailing slashes except root
11
- return href.length > 1 ? href.replace(/\/+$/, '') : href;
12
- };
13
- /**
14
- * Returns the chain of "expandable parents" (hrefs) that contain `targetHref`.
15
- *
16
- * Behavior:
17
- * - If targetHref matches an expandable parent item itself, the chain includes it.
18
- * - If targetHref matches a leaf under expandables, the chain includes expandable ancestors.
19
- *
20
- * Expandable parent definition:
21
- * - any node with children AND an href
22
- * (If you want to restrict this to a specific type, update isExpandableParent.)
23
- */
24
- const findExpandableParentChain = (targetHref, items) => {
25
- var _a;
26
- const target = normalizeHref(targetHref);
27
- const dfs = (nodes, parentExpandables) => {
28
- for (const node of nodes) {
29
- const nodeHref = hasHref(node) ? normalizeHref(node.href) : null;
30
- const isExpandableParent = hasChildren(node) && hasHref(node);
31
- const nextParents = isExpandableParent && nodeHref ? [...parentExpandables, nodeHref] : parentExpandables;
32
- // Match this node
33
- if (nodeHref === target) {
34
- return isExpandableParent ? nextParents : parentExpandables;
35
- }
36
- // Recurse into children
37
- if (hasChildren(node)) {
38
- const found = dfs(node.children, nextParents);
39
- if (found)
40
- return found;
41
- }
42
- }
43
- return null;
44
- };
45
- return (_a = dfs(items, [])) !== null && _a !== void 0 ? _a : [];
46
- };
47
- const SidebarContext = createContext({
48
- defaultExpanded: null,
49
- expandedItems: new Set(),
50
- activeQuery: '',
51
- wrapItemText: false,
52
- areItemsCollapsed: false,
53
- setActiveQuery: () => { },
54
- setWrapItemText: () => { },
55
- triggerExpandAll: () => { },
56
- setItemsCollapsed: () => { },
57
- resetExpandAll: () => { },
58
- activeLink: '',
59
- setActiveLink: () => { },
60
- expandItem: () => { },
61
- collapseItem: () => { },
62
- isExpanded: () => false,
63
- isSidebarCollapsed: false,
64
- handleSidebarCollapseChange: () => { },
65
- });
66
- const SIDEBAR_COLLAPSED_STORAGE_KEY = 'sidebar-is-collapsed';
67
- const SIDEBAR_BREAKPOINT = 1024;
68
- const getBreakpoint = (width) => width < SIDEBAR_BREAKPOINT ? 'small' : 'large';
69
- export function SidebarProvider({ children, items, initialQuery, initialCollapsed = false, initialSidebarCollapsed, }) {
70
- const [defaultExpanded, setDefaultExpanded] = useState(null);
71
- const [activeQuery, setActiveQuery] = useState(initialQuery !== null && initialQuery !== void 0 ? initialQuery : '');
72
- const [wrapItemText, setWrapItemText] = useState(false);
73
- const [areItemsCollapsed, setItemsCollapsed] = useState(initialCollapsed);
74
- const [activeHref, setActiveHref] = useState('');
75
- // expandedItems is the source of truth for "open groups"
76
- const [expandedItems, setExpandedItems] = useState(new Set());
77
- // Keep latest items without creating effect loops if parent recreates the array
78
- const itemsRef = useRef(items);
79
- useEffect(() => {
80
- itemsRef.current = items;
81
- }, [items]);
82
- const [isSidebarCollapsed, setSidebarCollapsed] = useState(initialSidebarCollapsed !== null && initialSidebarCollapsed !== void 0 ? initialSidebarCollapsed : false);
83
- // Runs once after hydration — safe to read localStorage and window.innerWidth here.
84
- useEffect(() => {
85
- if (initialSidebarCollapsed !== undefined)
86
- return;
87
- try {
88
- const stored = window.localStorage.getItem(SIDEBAR_COLLAPSED_STORAGE_KEY);
89
- if (stored !== null) {
90
- setSidebarCollapsed(Boolean(JSON.parse(stored))); // eslint-disable-line react-hooks/set-state-in-effect -- intentional: SSR-safe initial read
91
- return;
92
- }
93
- }
94
- catch {
95
- // ignore parse failures
96
- }
97
- setSidebarCollapsed(getBreakpoint(window.innerWidth) === 'small');
98
- }, []); // intentionally empty — only runs once after first mount
99
- const triggerExpandAll = useCallback(() => setDefaultExpanded(true), []);
100
- const resetExpandAll = useCallback(() => setDefaultExpanded(null), []);
101
- const setActiveLink = useCallback((href) => setActiveHref(href), []);
102
- const expandItem = useCallback((href) => {
103
- const h = normalizeHref(href);
104
- setExpandedItems(prev => {
105
- if (prev.has(h))
106
- return prev;
107
- const next = new Set(prev);
108
- next.add(h);
109
- return next;
110
- });
111
- }, []);
112
- const collapseItem = useCallback((href) => {
113
- const h = normalizeHref(href);
114
- setExpandedItems(prev => {
115
- if (!prev.has(h))
116
- return prev;
117
- const next = new Set(prev);
118
- next.delete(h);
119
- return next;
120
- });
121
- }, []);
122
- const isExpanded = useCallback((href) => expandedItems.has(normalizeHref(href)), [expandedItems]);
123
- // Auto-expand: when active link changes, ensure its expandable parent chain is expanded.
124
- useEffect(() => {
125
- if (!activeHref)
126
- return;
127
- const currentItems = itemsRef.current;
128
- const parents = findExpandableParentChain(activeHref, currentItems);
129
- if (parents.length === 0)
130
- return;
131
- setExpandedItems(prev => {
132
- let changed = false;
133
- const next = new Set(prev);
134
- for (const p of parents) {
135
- const norm = normalizeHref(p);
136
- if (!next.has(norm)) {
137
- next.add(norm);
138
- changed = true;
139
- }
140
- }
141
- return changed ? next : prev;
142
- });
143
- }, [activeHref]);
144
- const filteredItems = useMemo(() => {
145
- return activeQuery
146
- ? nestedFiltering(items, {
147
- keys: ['label', 'tags'],
148
- includeParents: true,
149
- mode: 'OR',
150
- query: activeQuery,
151
- })
152
- : items;
153
- }, [items, activeQuery]);
154
- const persistCollapsed = useCallback((collapsed) => {
155
- if (typeof window === 'undefined')
156
- return;
157
- try {
158
- window.localStorage.setItem(SIDEBAR_COLLAPSED_STORAGE_KEY, JSON.stringify(collapsed));
159
- }
160
- catch {
161
- // ignore persist failures
162
- }
163
- }, []);
164
- // Only persist user-triggered changes
165
- const handleSidebarCollapseChange = useCallback((collapsed) => {
166
- setSidebarCollapsed(collapsed);
167
- persistCollapsed(collapsed);
168
- }, [persistCollapsed]);
169
- // Resize behavior:
170
- // - only apply auto-collapse when breakpoint changes
171
- // - do NOT persist automatic changes (only user actions persist)
172
- useEffect(() => {
173
- if (typeof window === 'undefined')
174
- return;
175
- let lastBreakpoint = getBreakpoint(window.innerWidth);
176
- const onResize = () => {
177
- const nextBreakpoint = getBreakpoint(window.innerWidth);
178
- if (nextBreakpoint === lastBreakpoint)
179
- return;
180
- lastBreakpoint = nextBreakpoint;
181
- setSidebarCollapsed(nextBreakpoint === 'small');
182
- };
183
- window.addEventListener('resize', onResize);
184
- return () => window.removeEventListener('resize', onResize);
185
- }, []);
186
- const value = useMemo(() => ({
187
- defaultExpanded: activeQuery ? true : defaultExpanded,
188
- expandedItems,
189
- filteredItems,
190
- activeQuery,
191
- wrapItemText,
192
- areItemsCollapsed,
193
- setActiveQuery,
194
- setWrapItemText,
195
- triggerExpandAll,
196
- resetExpandAll,
197
- setItemsCollapsed,
198
- activeLink: activeHref,
199
- setActiveLink,
200
- expandItem,
201
- collapseItem,
202
- isExpanded,
203
- isSidebarCollapsed,
204
- handleSidebarCollapseChange,
205
- }), [
206
- defaultExpanded,
207
- expandedItems,
208
- filteredItems,
209
- activeQuery,
210
- wrapItemText,
211
- areItemsCollapsed,
212
- setActiveQuery,
213
- setWrapItemText,
214
- triggerExpandAll,
215
- resetExpandAll,
216
- setItemsCollapsed,
217
- activeHref,
218
- setActiveLink,
219
- expandItem,
220
- collapseItem,
221
- isExpanded,
222
- isSidebarCollapsed,
223
- handleSidebarCollapseChange,
224
- ]);
225
- return _jsx(SidebarContext.Provider, { value: value, children: children });
226
- }
227
- export function useSidebar() {
228
- return useContext(SidebarContext);
229
- }
@@ -1,73 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { SkeletonLoaderItem } from './skeleton-loader-item/SkeletonLoaderItem';
3
- export function SkeletonLoader({ type, rows = 3, columns = 3, variant = 'default', speedSec = 3, }) {
4
- const line = (width, height = 14, radius = 6) => (_jsx(SkeletonLoaderItem, { width: width, height: height, radius: radius, variant: variant, speedSec: speedSec }, `${String(width)}-${height}-${String(radius)}-${Math.random()}`));
5
- const pills = (count) => Array.from({ length: count }).map((_, i) => (_jsx(SkeletonLoaderItem, { width: 80 + (i % 3) * 30, height: 30, radius: 6, variant: variant, speedSec: speedSec, ariaLabel: "Loading filter" }, `pill-${i}`)));
6
- const textBlock = (count) => Array.from({ length: count }).map((_, i) => (_jsx(SkeletonLoaderItem, { width: i === count - 1 ? '60%' : `${90 - (i % 3) * 10}%`, height: 12, radius: 4, variant: variant, speedSec: speedSec, ariaLabel: "Loading text line" }, `text-${i}`)));
7
- const tableHeaderRow = () => (_jsx("div", { style: {
8
- display: 'grid',
9
- gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`,
10
- gap: 12,
11
- alignItems: 'center',
12
- width: '100%',
13
- }, children: Array.from({ length: columns }).map((_, i) => (_jsx(SkeletonLoaderItem, { height: 20, width: "90%", radius: 6, variant: variant, speedSec: speedSec, ariaLabel: "Loading table header" }, `thead-${i}`))) }));
14
- const tableBodyRow = (rowIndex) => (_jsx("div", { style: {
15
- display: 'grid',
16
- gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`,
17
- gap: 12,
18
- alignItems: 'center',
19
- width: '100%',
20
- }, children: Array.from({ length: columns }).map((_, colIndex) => (_jsx(SkeletonLoaderItem, { height: 20, width: colIndex % 3 === 0 ? '93%' : colIndex % 3 === 1 ? '98%' : '90%', radius: 4, variant: variant, speedSec: speedSec, ariaLabel: "Loading table cell" }, `tcell-${rowIndex}-${colIndex}`))) }, `trow-${rowIndex}`));
21
- const inputFieldRow = (i) => {
22
- const labelW = i % 3 === 0 ? '34%' : i % 3 === 1 ? '42%' : '28%';
23
- return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 8, width: '100%' }, children: [_jsx("div", { style: {
24
- display: 'flex',
25
- alignItems: 'center',
26
- justifyContent: 'space-between',
27
- gap: 12,
28
- }, children: _jsx(SkeletonLoaderItem, { width: labelW, height: 10, radius: 4, variant: variant, speedSec: speedSec, ariaLabel: "Loading label" }) }), _jsx(SkeletonLoaderItem, { width: "100%", height: 25, radius: 8, variant: variant, speedSec: speedSec, ariaLabel: "Loading input" })] }, `if-${i}`));
29
- };
30
- const inputFieldList = (count) => (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 16, width: '100%' }, children: [Array.from({ length: count }).map((_, i) => inputFieldRow(i)), _jsxs("div", { style: { display: 'flex', gap: 12, justifyContent: 'flex-end', marginTop: 8 }, children: [_jsx(SkeletonLoaderItem, { width: 110, height: 30, radius: 8, variant: variant, speedSec: speedSec, ariaLabel: "Loading action" }), _jsx(SkeletonLoaderItem, { width: 90, height: 30, radius: 8, variant: variant, speedSec: speedSec, ariaLabel: "Loading action" })] })] }));
31
- const getSkeletonItems = () => {
32
- switch (type) {
33
- case 'button': {
34
- return (_jsxs("div", { style: {
35
- display: 'flex',
36
- gap: 12,
37
- alignItems: 'center',
38
- justifyContent: 'flex-start',
39
- width: '100%',
40
- flexWrap: 'wrap',
41
- }, children: [_jsx(SkeletonLoaderItem, { width: 120, height: 40, radius: 8, variant: variant, speedSec: speedSec, ariaLabel: "Loading button" }), _jsx(SkeletonLoaderItem, { width: 96, height: 40, radius: 8, variant: variant, speedSec: speedSec, ariaLabel: "Loading button" })] }));
42
- }
43
- case 'card': {
44
- return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 12, width: '100%' }, children: [_jsx(SkeletonLoaderItem, { width: "100%", height: 160, radius: 12, variant: variant, speedSec: speedSec, ariaLabel: "Loading card media" }), line('60%', 16, 6), textBlock(3), _jsxs("div", { style: { display: 'flex', gap: 12, justifyContent: 'flex-start' }, children: [_jsx(SkeletonLoaderItem, { width: 100, height: 30, variant: variant, speedSec: speedSec, ariaLabel: "Loading action" }), _jsx(SkeletonLoaderItem, { width: 72, height: 30, variant: variant, speedSec: speedSec, ariaLabel: "Loading action" })] })] }));
45
- }
46
- case 'avatar': {
47
- return (_jsxs("div", { style: { display: 'flex', gap: 12, alignItems: 'center', width: '100%' }, children: [_jsx(SkeletonLoaderItem, { width: 48, height: 48, radius: "50%", variant: variant, speedSec: speedSec, ariaLabel: "Loading avatar" }), _jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 8, flex: 1 }, children: [line('40%', 14), line('25%', 12)] })] }));
48
- }
49
- case 'text': {
50
- return (_jsx("div", { style: { display: 'flex', flexDirection: 'column', gap: 10, width: '100%' }, children: textBlock(rows) }));
51
- }
52
- case 'table': {
53
- return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 12, width: '100%' }, children: [tableHeaderRow(), Array.from({ length: rows }).map((_, r) => tableBodyRow(r))] }));
54
- }
55
- case 'filterbar': {
56
- return (_jsxs("div", { style: {
57
- display: 'flex',
58
- alignItems: 'center',
59
- justifyContent: 'space-between',
60
- gap: 12,
61
- flexWrap: 'wrap',
62
- width: '100%',
63
- }, children: [_jsx("div", { style: { display: 'flex', gap: 12, flexWrap: 'wrap' }, children: pills(columns) }), _jsx(SkeletonLoaderItem, { width: 240, height: 30, variant: variant, speedSec: speedSec, ariaLabel: "Loading" })] }));
64
- }
65
- case 'inputFieldList': {
66
- return inputFieldList(rows);
67
- }
68
- default:
69
- return null;
70
- }
71
- };
72
- return (_jsx("div", { role: "status", "aria-label": "Loading content", style: { display: 'flex', flexDirection: 'column', gap: 16, width: '100%' }, children: getSkeletonItems() }));
73
- }
@@ -1,13 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import styles from './SkeletonLoaderItem.module.css';
3
- export function SkeletonLoaderItem({ height = 14, width = '100%', radius = 6, speedSec = 3, ariaLabel = 'Loading', variant = 'default', }) {
4
- const h = typeof height === 'number' ? `${height}px` : height;
5
- const w = typeof width === 'number' ? `${width}px` : width;
6
- const r = typeof radius === 'number' ? `${radius}px` : radius;
7
- return (_jsxs("div", { className: `${styles.skeletonLoader} ${styles[variant]}`, role: "status", "aria-label": ariaLabel, "aria-live": "polite", style: {
8
- ['--h']: h,
9
- ['--r']: r,
10
- ['--speed']: `${speedSec}s`,
11
- ['--width']: w,
12
- }, children: [_jsx("span", { className: styles.bar, "aria-hidden": "true" }), _jsx("span", { className: "srOnly", children: "Loading\u2026" })] }));
13
- }
@@ -1,51 +0,0 @@
1
- .skeletonLoader {
2
- --h: var(--skeleton-height, 14px);
3
- --r: var(--border-radius-md, 6px);
4
- --speed: var(--skeleton-speed, 1.2s);
5
- --skeleton-base: var(--opac-bg-dark);
6
- --skeleton-sheen: var(--opac-bg-default);
7
- position: relative;
8
- display: block;
9
- inline-size: var(--width, 100%);
10
- block-size: var(--h);
11
- width: var(--width, 100%);
12
- height: var(--h);
13
- overflow: hidden;
14
- border-radius: var(--r);
15
- background: linear-gradient(
16
- 90deg,
17
- var(--skeleton-sheen) 0%,
18
- var(--skeleton-base) 45%,
19
- var(--skeleton-sheen) 60%,
20
- var(--skeleton-base) 100%
21
- );
22
- background-size: 200% 100%;
23
- animation: shimmer var(--speed) linear infinite;
24
- }
25
-
26
- .invert {
27
- --skeleton-base: var(--opac-bg-dark-invert);
28
- --skeleton-sheen: var(--opac-bg-light-invert);
29
- }
30
-
31
- .bar {
32
- display: block;
33
- inline-size: 100%;
34
- block-size: 100%;
35
- border-radius: inherit;
36
- }
37
-
38
- @keyframes shimmer {
39
- 0% {
40
- background-position: 200% 0;
41
- }
42
- 100% {
43
- background-position: -200% 0;
44
- }
45
- }
46
-
47
- @media (prefers-reduced-motion: reduce) {
48
- .skeletonLoader {
49
- animation: none;
50
- }
51
- }
@@ -1,10 +0,0 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import styles from './SplitButton.module.css';
3
- import { Button } from '../button/Button';
4
- import { Menu } from '../menu/Menu';
5
- import { Popover } from '../popover/Popover';
6
- export function SplitButton({ children, options, onClick, icon, ...rest }) {
7
- return (_jsxs("div", { className: styles.container, style: { display: 'inline-flex', alignItems: 'center' }, children: [_jsxs(Button, { ...rest, onClick: onClick, children: [icon, children] }), _jsx(Popover, { trigger: (handleClick, icon) => (_jsx("span", { className: styles.triggerContainer, children: _jsx(Button, { ...rest, onClick: handleClick, children: icon }) })), children: close => (_jsx(Menu, { children: options.map(option => (_jsx(Menu.Item, { active: option.active, children: _jsxs("button", { onClick: () => {
8
- option.onClick(close);
9
- }, children: [option.icon, option.label] }) }, option.label))) })) })] }));
10
- }
@@ -1,32 +0,0 @@
1
- .container {
2
- display: inline-flex;
3
- }
4
-
5
- .container > button:first-child {
6
- border-start-start-radius: var(--border-radius-default);
7
- border-end-start-radius: var(--border-radius-default);
8
- border-start-end-radius: 0;
9
- border-end-end-radius: 0;
10
- }
11
-
12
- .triggerContainer button {
13
- border-start-end-radius: var(--border-radius-default);
14
- border-end-end-radius: var(--border-radius-default);
15
- border-start-start-radius: 0;
16
- border-end-start-radius: 0;
17
- padding-block: 0;
18
- padding-inline: var(--spacing-xs);
19
- }
20
-
21
- .triggerContainer button {
22
- margin-inline-start: -1px;
23
- }
24
- .triggerContainer button:not(:hover) {
25
- border-inline-start-color: transparent;
26
- }
27
-
28
- .container > button:first-child:focus-visible,
29
- .triggerContainer button:focus-visible {
30
- outline: none;
31
- box-shadow: var(--focus-ring);
32
- }