@dbcdk/react-components 0.0.4 → 0.0.6
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/assets/logo.js +2 -85
- package/dist/components/__stories__/_data/table.d.ts +15 -0
- package/dist/components/__stories__/_data/table.js +49 -0
- package/dist/components/__stories__/story-components/Colors.d.ts +11 -0
- package/dist/components/__stories__/story-components/Colors.js +96 -0
- package/dist/components/__stories__/story-components/Colors.module.css +27 -0
- package/dist/components/__stories__/story-components/Spacing.d.ts +2 -0
- package/dist/components/__stories__/story-components/Spacing.js +76 -0
- package/dist/components/__stories__/story-components/Spacing.module.css +154 -0
- package/dist/components/app-header/AppHeader.d.ts +4 -3
- package/dist/components/app-header/AppHeader.js +3 -6
- package/dist/components/app-header/AppHeader.module.css +10 -15
- package/dist/components/attribute-chip/AttributeChip.d.ts +9 -0
- package/dist/components/attribute-chip/AttributeChip.js +5 -0
- package/dist/components/attribute-chip/AttributeChip.module.css +65 -0
- package/dist/components/avatar/Avatar.d.ts +5 -3
- package/dist/components/avatar/Avatar.js +37 -37
- package/dist/components/avatar/Avatar.module.css +27 -0
- package/dist/components/breadcrumbs/Breadcrumbs.d.ts +4 -4
- package/dist/components/breadcrumbs/Breadcrumbs.js +4 -14
- package/dist/components/breadcrumbs/Breadcrumbs.module.css +19 -22
- package/dist/components/button/Button.d.ts +6 -2
- package/dist/components/button/Button.js +56 -50
- package/dist/components/button/Button.module.css +119 -56
- package/dist/components/card/Card.d.ts +23 -7
- package/dist/components/card/Card.js +20 -21
- package/dist/components/card/Card.module.css +148 -44
- package/dist/components/card-container/CardContainer.d.ts +6 -3
- package/dist/components/card-container/CardContainer.js +4 -15
- package/dist/components/card-container/CardContainer.module.css +40 -0
- package/dist/components/chip/Chip.d.ts +7 -5
- package/dist/components/chip/Chip.js +14 -37
- package/dist/components/chip/Chip.module.css +50 -27
- package/dist/components/circle/Circle.d.ts +3 -2
- package/dist/components/circle/Circle.js +3 -10
- package/dist/components/circle/Circle.module.css +11 -11
- package/dist/components/clear-button/ClearButton.d.ts +2 -1
- package/dist/components/clear-button/ClearButton.js +6 -17
- package/dist/components/clear-button/ClearButton.module.css +8 -7
- package/dist/components/code-block/CodeBlock.d.ts +7 -0
- package/dist/components/code-block/CodeBlock.js +6 -0
- package/dist/components/code-block/CodeBlock.module.css +60 -0
- package/dist/components/copy-button/CopyButton.d.ts +10 -0
- package/dist/components/copy-button/CopyButton.js +22 -0
- package/dist/components/copy-button/CopyButton.module.css +6 -0
- package/dist/components/datetime-picker/DateTimePicker.d.ts +42 -0
- package/dist/components/datetime-picker/DateTimePicker.js +403 -0
- package/dist/components/datetime-picker/DateTimePicker.module.css +144 -0
- package/dist/components/filter-field/FilterField.d.ts +6 -3
- package/dist/components/filter-field/FilterField.js +130 -158
- package/dist/components/filter-field/FilterField.module.css +35 -25
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.d.ts +36 -0
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.js +53 -0
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.module.css +60 -0
- package/dist/components/forms/checkbox/Checkbox.d.ts +31 -0
- package/dist/components/forms/checkbox/Checkbox.js +27 -0
- package/dist/components/{checkbox → forms/checkbox}/Checkbox.module.css +10 -11
- package/dist/components/forms/checkbox-group/CheckboxGroup.d.ts +47 -0
- package/dist/components/forms/checkbox-group/CheckboxGroup.js +75 -0
- package/dist/components/forms/checkbox-group/CheckboxGroup.module.css +115 -0
- package/dist/components/forms/input/Input.d.ts +22 -0
- package/dist/components/forms/input/Input.js +70 -0
- package/dist/components/forms/input/Input.module.css +160 -0
- package/dist/components/forms/input-container/InputContainer.d.ts +15 -0
- package/dist/components/forms/input-container/InputContainer.js +15 -0
- package/dist/components/forms/input-container/InputContainer.module.css +34 -0
- package/dist/components/forms/multi-select/MultiSelect.d.ts +20 -0
- package/dist/components/forms/multi-select/MultiSelect.js +19 -0
- package/dist/components/forms/select/Select.d.ts +21 -0
- package/dist/components/forms/select/Select.js +94 -0
- package/dist/components/forms/text-area/Textarea.d.ts +17 -0
- package/dist/components/forms/text-area/Textarea.js +33 -0
- package/dist/components/forms/text-area/Textarea.module.css +26 -0
- package/dist/components/headline/Headline.d.ts +9 -1
- package/dist/components/headline/Headline.js +18 -37
- package/dist/components/headline/Headline.module.css +32 -7
- package/dist/components/hyperlink/Hyperlink.d.ts +9 -0
- package/dist/components/hyperlink/Hyperlink.js +11 -0
- package/dist/components/hyperlink/Hyperlink.module.css +23 -0
- package/dist/components/icon/Icon.d.ts +4 -3
- package/dist/components/icon/Icon.js +11 -17
- package/dist/components/icon/Icon.module.css +10 -9
- package/dist/components/menu/Menu.js +25 -67
- package/dist/components/menu/Menu.module.css +10 -32
- package/dist/components/meta-bar/MetaBar.d.ts +11 -0
- package/dist/components/meta-bar/MetaBar.js +9 -0
- package/dist/components/meta-bar/MetaBar.module.css +12 -0
- package/dist/components/nav-bar/NavBar.d.ts +5 -5
- package/dist/components/nav-bar/NavBar.js +15 -45
- package/dist/components/nav-bar/NavBar.module.css +11 -16
- package/dist/components/overlay/modal/Modal.d.ts +23 -0
- package/dist/components/overlay/modal/Modal.js +92 -0
- package/dist/components/overlay/modal/Modal.module.css +66 -0
- package/dist/components/overlay/modal/provider/ModalProvider.d.ts +20 -0
- package/dist/components/overlay/modal/provider/ModalProvider.js +70 -0
- package/dist/components/overlay/side-panel/SidePanel.d.ts +16 -0
- package/dist/components/overlay/side-panel/SidePanel.js +10 -0
- package/dist/components/overlay/side-panel/SidePanel.module.css +56 -0
- package/dist/components/overlay/side-panel/useSidePanel.d.ts +5 -0
- package/dist/components/overlay/side-panel/useSidePanel.js +11 -0
- package/dist/components/overlay/tooltip/Tooltip.d.ts +13 -0
- package/dist/components/overlay/tooltip/Tooltip.js +17 -0
- package/dist/components/overlay/tooltip/Tooltip.module.css +106 -0
- package/dist/components/overlay/tooltip/TooltipProvider.d.ts +20 -0
- package/dist/components/overlay/tooltip/TooltipProvider.js +244 -0
- package/dist/components/overlay/tooltip/useTooltipTrigger.d.ts +24 -0
- package/dist/components/overlay/tooltip/useTooltipTrigger.js +108 -0
- package/dist/components/page/Page.d.ts +7 -6
- package/dist/components/page/Page.js +4 -21
- package/dist/components/page/Page.module.css +2 -2
- package/dist/components/page-layout/PageLayout.d.ts +12 -20
- package/dist/components/page-layout/PageLayout.js +35 -88
- package/dist/components/page-layout/PageLayout.module.css +4 -80
- package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.d.ts +11 -0
- package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.js +7 -0
- package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.module.css +84 -0
- package/dist/components/pagination/Pagination.d.ts +4 -1
- package/dist/components/pagination/Pagination.js +38 -105
- package/dist/components/pagination/Pagination.module.css +11 -3
- package/dist/components/panel/Panel.d.ts +4 -3
- package/dist/components/panel/Panel.js +5 -10
- package/dist/components/panel/Panel.module.css +5 -7
- package/dist/components/popover/Popover.d.ts +3 -1
- package/dist/components/popover/Popover.js +116 -124
- package/dist/components/popover/Popover.module.css +4 -6
- package/dist/components/search-box/SearchBox.d.ts +11 -8
- package/dist/components/search-box/SearchBox.js +112 -149
- package/dist/components/search-box/SearchBox.module.css +0 -1
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.d.ts +1 -1
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.js +47 -88
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.module.css +5 -1
- package/dist/components/sidebar/Sidebar.d.ts +3 -1
- package/dist/components/sidebar/Sidebar.js +5 -29
- package/dist/components/sidebar/components/SidebarItem.js +6 -12
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.d.ts +4 -2
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.js +48 -62
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.module.css +9 -38
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.d.ts +9 -0
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.js +13 -0
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.module.css +155 -0
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.d.ts +3 -1
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.js +4 -18
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.module.css +25 -12
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.d.ts +1 -1
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.js +9 -22
- package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.js +20 -18
- package/dist/components/sidebar/providers/SidebarProvider.d.ts +9 -4
- package/dist/components/sidebar/providers/SidebarProvider.js +188 -73
- package/dist/components/skeleton-loader/SkeletonLoader.js +68 -266
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.js +11 -34
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.module.css +0 -12
- package/dist/components/split-button/SplitButton.d.ts +7 -5
- package/dist/components/split-button/SplitButton.js +4 -27
- package/dist/components/split-pane/SplitPane.d.ts +34 -0
- package/dist/components/split-pane/SplitPane.js +78 -0
- package/dist/components/split-pane/SplitPane.module.css +106 -0
- package/dist/components/split-pane/provider/SplitPaneContext.d.ts +23 -0
- package/dist/components/split-pane/provider/SplitPaneContext.js +85 -0
- package/dist/components/table/Table.d.ts +28 -10
- package/dist/components/table/Table.js +117 -172
- package/dist/components/table/Table.module.css +78 -47
- package/dist/components/table/components/column-resizer/ColumnResizer.js +4 -15
- package/dist/components/table/components/empty-state/EmptyState.d.ts +41 -0
- package/dist/components/table/components/empty-state/EmptyState.js +27 -0
- package/dist/components/table/components/empty-state/EmptyState.module.css +16 -0
- package/dist/components/table/components/table-settings/TableSettings.d.ts +8 -0
- package/dist/components/table/components/table-settings/TableSettings.js +12 -0
- package/dist/components/table/tanstack.d.ts +14 -0
- package/dist/components/table/tanstack.js +162 -0
- package/dist/components/tabs/Tabs.d.ts +7 -3
- package/dist/components/tabs/Tabs.js +32 -65
- package/dist/components/tabs/Tabs.module.css +9 -9
- package/dist/components/toast/Toast.d.ts +14 -0
- package/dist/components/toast/Toast.js +8 -0
- package/dist/components/toast/Toast.module.css +102 -0
- package/dist/components/toast/provider/ToastProvider.d.ts +23 -0
- package/dist/components/toast/provider/ToastProvider.js +64 -0
- package/dist/components/user-display/UserDisplay.d.ts +2 -1
- package/dist/components/user-display/UserDisplay.js +4 -20
- package/dist/components/user-display/UserDisplay.module.css +2 -2
- package/dist/constants/severity.d.ts +1 -1
- package/dist/constants/severity.js +14 -16
- package/dist/constants/severity.types.d.ts +1 -1
- package/dist/constants/severity.types.js +1 -1
- package/dist/constants/sizes.d.ts +1 -1
- package/dist/constants/sizes.js +6 -7
- package/dist/hooks/usePagination.d.ts +33 -0
- package/dist/hooks/usePagination.js +79 -0
- package/dist/hooks/useSorting.d.ts +49 -0
- package/dist/hooks/useSorting.js +118 -0
- package/dist/hooks/useTableData.d.ts +40 -0
- package/dist/hooks/useTableData.js +45 -0
- package/dist/hooks/useTableSelection.d.ts +25 -0
- package/dist/hooks/useTableSelection.js +128 -0
- package/dist/hooks/useTableSettings.d.ts +7 -0
- package/dist/hooks/useTableSettings.js +24 -0
- package/dist/hooks/useTheme.d.ts +3 -7
- package/dist/hooks/useTheme.js +52 -47
- package/dist/hooks/useTimeDuration.d.ts +22 -0
- package/dist/hooks/useTimeDuration.js +36 -0
- package/dist/hooks/useViewportFill.d.ts +3 -2
- package/dist/hooks/useViewportFill.js +55 -48
- package/dist/index.d.ts +32 -6
- package/dist/index.js +33 -6
- package/dist/src/styles/styles.css +101 -8
- package/dist/styles/css-helper-classes/flex.css +101 -0
- package/dist/styles/css-helper-classes/typography.css +7 -0
- package/dist/styles/styles.css +101 -8
- package/dist/styles/themes/dbc/dark.css +207 -100
- package/dist/styles/themes/dbc/light.css +185 -90
- package/dist/styles/themes/forfatterweb/light.css +1 -1
- package/dist/styles/themes/types.js +1 -1
- package/dist/types/a11y-props.types.d.ts +5 -5
- package/dist/types/a11y-props.types.js +1 -1
- package/dist/types/sizes.types.d.ts +2 -2
- package/dist/types/sizes.types.js +1 -1
- package/dist/utils/arrays/nested-filtering.js +43 -33
- package/dist/utils/date/formatDate.js +25 -16
- package/package.json +33 -18
- package/dist/assets/logo.cjs +0 -87
- package/dist/components/app-header/AppHeader.cjs +0 -14
- package/dist/components/avatar/Avatar.cjs +0 -67
- package/dist/components/breadcrumbs/Breadcrumbs.cjs +0 -23
- package/dist/components/button/Button.cjs +0 -79
- package/dist/components/card/Card.cjs +0 -29
- package/dist/components/card-container/CardContainer.cjs +0 -23
- package/dist/components/checkbox/Checkbox.cjs +0 -43
- package/dist/components/checkbox/Checkbox.d.ts +0 -12
- package/dist/components/checkbox/Checkbox.js +0 -37
- package/dist/components/chip/Chip.cjs +0 -49
- package/dist/components/circle/Circle.cjs +0 -18
- package/dist/components/clear-button/ClearButton.cjs +0 -26
- package/dist/components/data-summary/DataSummary.cjs +0 -49
- package/dist/components/data-summary/DataSummary.d.ts +0 -19
- package/dist/components/data-summary/DataSummary.js +0 -43
- package/dist/components/data-summary/DataSummary.module.css +0 -51
- package/dist/components/filter-field/FilterField.cjs +0 -174
- package/dist/components/headline/Headline.cjs +0 -47
- package/dist/components/icon/Icon.cjs +0 -27
- package/dist/components/input/Input.cjs +0 -48
- package/dist/components/input/Input.d.ts +0 -13
- package/dist/components/input/Input.js +0 -42
- package/dist/components/input/Input.module.css +0 -112
- package/dist/components/menu/Menu.cjs +0 -96
- package/dist/components/multi-select/MultiSelect.cjs +0 -48
- package/dist/components/multi-select/MultiSelect.d.ts +0 -18
- package/dist/components/multi-select/MultiSelect.js +0 -46
- package/dist/components/nav-bar/NavBar.cjs +0 -55
- package/dist/components/page/Page.cjs +0 -30
- package/dist/components/page-layout/PageLayout.cjs +0 -101
- package/dist/components/pagination/Pagination.cjs +0 -117
- package/dist/components/panel/Panel.cjs +0 -18
- package/dist/components/popover/Popover.cjs +0 -132
- package/dist/components/search-box/SearchBox.cjs +0 -162
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.cjs +0 -97
- package/dist/components/select/Select.cjs +0 -52
- package/dist/components/select/Select.d.ts +0 -11
- package/dist/components/select/Select.js +0 -50
- package/dist/components/sidebar/Sidebar.cjs +0 -38
- package/dist/components/sidebar/Sidebar.module.css +0 -66
- package/dist/components/sidebar/components/SidebarItem.cjs +0 -16
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.cjs +0 -74
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.cjs +0 -27
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.cjs +0 -28
- package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.cjs +0 -25
- package/dist/components/sidebar/providers/SidebarProvider.cjs +0 -81
- package/dist/components/skeleton-loader/SkeletonLoader.cjs +0 -270
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.cjs +0 -42
- package/dist/components/split-button/SplitButton.cjs +0 -37
- package/dist/components/table/Table.cjs +0 -181
- package/dist/components/table/components/column-resizer/ColumnResizer.cjs +0 -22
- package/dist/components/tabs/Tabs.cjs +0 -74
- package/dist/components/text-area/Textarea.cjs +0 -62
- package/dist/components/text-area/Textarea.d.ts +0 -14
- package/dist/components/text-area/Textarea.js +0 -56
- package/dist/components/text-area/Textarea.module.css +0 -3
- package/dist/components/tooltip/Tooltip.cjs +0 -78
- package/dist/components/tooltip/Tooltip.d.ts +0 -11
- package/dist/components/tooltip/Tooltip.js +0 -72
- package/dist/components/tooltip/Tooltip.module.css +0 -84
- package/dist/components/user-display/UserDisplay.cjs +0 -28
- package/dist/constants/severity.cjs +0 -21
- package/dist/constants/severity.types.cjs +0 -2
- package/dist/constants/sizes.cjs +0 -10
- package/dist/hooks/useTheme.cjs +0 -58
- package/dist/hooks/useViewportFill.cjs +0 -52
- package/dist/index.cjs +0 -264
- package/dist/styles/themes/types.cjs +0 -2
- package/dist/tanstack.cjs +0 -231
- package/dist/tanstack.d.ts +0 -25
- package/dist/tanstack.js +0 -206
- package/dist/types/a11y-props.types.cjs +0 -2
- package/dist/types/assets.d.cjs +0 -2
- package/dist/types/assets.d.js +0 -1
- package/dist/types/css.d.cjs +0 -2
- package/dist/types/css.d.js +0 -1
- package/dist/types/sizes.types.cjs +0 -2
- package/dist/utils/arrays/nested-filtering.cjs +0 -40
- package/dist/utils/date/formatDate.cjs +0 -19
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
.container {
|
|
2
2
|
display: inline-flex;
|
|
3
3
|
align-items: center;
|
|
4
|
-
justify-content: center;
|
|
5
4
|
gap: var(--spacing-sm);
|
|
6
5
|
vertical-align: middle;
|
|
7
6
|
line-height: 0;
|
|
@@ -14,9 +13,9 @@
|
|
|
14
13
|
display: flex;
|
|
15
14
|
align-items: center;
|
|
16
15
|
justify-content: center;
|
|
17
|
-
border: var(--border-width-thin) solid var(--color-border-
|
|
16
|
+
border: var(--border-width-thin) solid var(--color-border-default);
|
|
18
17
|
border-radius: var(--border-radius-sm);
|
|
19
|
-
background-color: var(--color-surface);
|
|
18
|
+
background-color: var(--color-bg-surface);
|
|
20
19
|
cursor: pointer;
|
|
21
20
|
transition:
|
|
22
21
|
background-color var(--transition-fast) var(--ease-standard),
|
|
@@ -35,19 +34,19 @@
|
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
.checkbox:hover {
|
|
38
|
-
border-color: var(--color-
|
|
37
|
+
border-color: var(--color-fg-default);
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
.checked {
|
|
42
|
-
background-color: var(--color-
|
|
43
|
-
border-color: var(--color-
|
|
41
|
+
background-color: var(--color-brand);
|
|
42
|
+
border-color: var(--color-brand);
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
.icon {
|
|
47
|
-
width: var(--icon-size);
|
|
48
|
-
height: var(--icon-size);
|
|
49
|
-
color: var(--color-
|
|
50
|
-
stroke-width:
|
|
46
|
+
width: var(--icon-size-md);
|
|
47
|
+
height: var(--icon-size-md);
|
|
48
|
+
color: var(--color-fg-on-brand);
|
|
49
|
+
stroke-width: 2;
|
|
51
50
|
pointer-events: none;
|
|
52
51
|
}
|
|
53
52
|
|
|
@@ -58,6 +57,6 @@
|
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
.icon {
|
|
61
|
-
color: var(--color-
|
|
60
|
+
color: var(--color-fg-default);
|
|
62
61
|
}
|
|
63
62
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
type Variant = 'default' | 'primary' | 'outlined';
|
|
3
|
+
type Size = 'sm' | 'md' | 'lg';
|
|
4
|
+
export interface CheckboxGroupOption {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface CheckboxGroupProps {
|
|
10
|
+
/** Label shown before the checkboxes (e.g. "Fejlede i:") */
|
|
11
|
+
label?: string;
|
|
12
|
+
options: CheckboxGroupOption[];
|
|
13
|
+
selectedValues: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Called with the NEXT selectedValues array (so parent can just setState(next)).
|
|
16
|
+
*/
|
|
17
|
+
onChange: (nextSelectedValues: string[]) => void;
|
|
18
|
+
/** Optional: called when a single value was toggled */
|
|
19
|
+
onToggle?: (toggledValue: string, isSelected: boolean) => void;
|
|
20
|
+
/** Pass-through styling */
|
|
21
|
+
variant?: Variant;
|
|
22
|
+
size?: Size;
|
|
23
|
+
/** Layout */
|
|
24
|
+
wrap?: boolean;
|
|
25
|
+
fullWidth?: boolean;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Renders a compact container row suitable for toolbars:
|
|
29
|
+
* [Label] [Checkboxes...] [Action]
|
|
30
|
+
*/
|
|
31
|
+
contained?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Right-side action that keeps the same width:
|
|
34
|
+
* - When NOT all enabled options are selected => shows "Alle" and selects all on click
|
|
35
|
+
* - When ALL enabled options are selected => shows "Ryd" and deselects all on click
|
|
36
|
+
*/
|
|
37
|
+
actionLabels?: {
|
|
38
|
+
clear?: string;
|
|
39
|
+
all?: string;
|
|
40
|
+
};
|
|
41
|
+
/** Optional hook when action is clicked */
|
|
42
|
+
onActionClick?: (mode: 'clear' | 'all') => void;
|
|
43
|
+
/** Data attributes pass-through */
|
|
44
|
+
'data-cy'?: string;
|
|
45
|
+
}
|
|
46
|
+
export declare function CheckboxGroup({ label, options, selectedValues, onChange, onToggle, variant, size, wrap, fullWidth, disabled, contained, actionLabels, onActionClick, 'data-cy': dataCy, }: CheckboxGroupProps): JSX.Element;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import styles from './CheckboxGroup.module.css';
|
|
5
|
+
import { Checkbox } from '../checkbox/Checkbox';
|
|
6
|
+
export function CheckboxGroup({ label, options, selectedValues, onChange, onToggle, variant = 'outlined', size = 'md', wrap = false, fullWidth = false, disabled = false, contained = true, actionLabels = { clear: 'Ryd', all: 'Alle' }, onActionClick, 'data-cy': dataCy, }) {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
const selectedSet = useMemo(() => new Set(selectedValues), [selectedValues]);
|
|
9
|
+
const enabledValues = useMemo(() => options.filter(o => !(disabled || o.disabled)).map(o => o.value), [options, disabled]);
|
|
10
|
+
const allEnabledSelected = enabledValues.length > 0 && enabledValues.every(v => selectedSet.has(v));
|
|
11
|
+
const toggleValue = (value) => {
|
|
12
|
+
if (disabled)
|
|
13
|
+
return;
|
|
14
|
+
const next = new Set(selectedSet);
|
|
15
|
+
const willSelect = !next.has(value);
|
|
16
|
+
if (willSelect)
|
|
17
|
+
next.add(value);
|
|
18
|
+
else
|
|
19
|
+
next.delete(value);
|
|
20
|
+
onChange(Array.from(next));
|
|
21
|
+
onToggle === null || onToggle === void 0 ? void 0 : onToggle(value, willSelect);
|
|
22
|
+
};
|
|
23
|
+
const selectAll = () => {
|
|
24
|
+
if (disabled)
|
|
25
|
+
return;
|
|
26
|
+
if (enabledValues.length === 0)
|
|
27
|
+
return;
|
|
28
|
+
onChange([...enabledValues]);
|
|
29
|
+
onToggle === null || onToggle === void 0 ? void 0 : onToggle('__select_all__', true);
|
|
30
|
+
};
|
|
31
|
+
const deselectAll = () => {
|
|
32
|
+
if (disabled)
|
|
33
|
+
return;
|
|
34
|
+
onChange([]);
|
|
35
|
+
onToggle === null || onToggle === void 0 ? void 0 : onToggle('__deselect_all__', false);
|
|
36
|
+
};
|
|
37
|
+
const handleAction = () => {
|
|
38
|
+
if (disabled)
|
|
39
|
+
return;
|
|
40
|
+
if (enabledValues.length === 0)
|
|
41
|
+
return;
|
|
42
|
+
if (allEnabledSelected) {
|
|
43
|
+
// currently all -> "Ryd" clears all
|
|
44
|
+
deselectAll();
|
|
45
|
+
onActionClick === null || onActionClick === void 0 ? void 0 : onActionClick('clear');
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// not all -> "Alle" selects all
|
|
49
|
+
selectAll();
|
|
50
|
+
onActionClick === null || onActionClick === void 0 ? void 0 : onActionClick('all');
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const wrapperClassName = [
|
|
54
|
+
styles.wrapper,
|
|
55
|
+
fullWidth ? styles.fullWidth : '',
|
|
56
|
+
contained ? styles.contained : styles.plain,
|
|
57
|
+
styles[size],
|
|
58
|
+
]
|
|
59
|
+
.filter(Boolean)
|
|
60
|
+
.join(' ');
|
|
61
|
+
const itemsClassName = [styles.items, wrap ? styles.wrap : styles.noWrap].join(' ');
|
|
62
|
+
// Prevent UI jump by reserving width equal to the longer label.
|
|
63
|
+
const allText = (_a = actionLabels.all) !== null && _a !== void 0 ? _a : 'Alle';
|
|
64
|
+
const clearText = (_b = actionLabels.clear) !== null && _b !== void 0 ? _b : 'Ryd';
|
|
65
|
+
const actionMinWidth = `${Math.max(allText.length, clearText.length)}ch`;
|
|
66
|
+
return (_jsxs("div", { className: wrapperClassName, "data-cy": dataCy, style: { ['--checkboxgroup-action-min-width']: actionMinWidth }, children: [label && _jsx("span", { className: styles.groupLabel, children: label }), _jsx("div", { className: itemsClassName, role: "group", "aria-label": label, children: options.map(opt => {
|
|
67
|
+
const isChecked = selectedSet.has(opt.value);
|
|
68
|
+
const isDisabled = disabled || !!opt.disabled;
|
|
69
|
+
return (_jsx(Checkbox, { label: opt.label, checked: isChecked, disabled: isDisabled, variant: variant, size: size, onChange: () => {
|
|
70
|
+
if (isDisabled)
|
|
71
|
+
return;
|
|
72
|
+
toggleValue(opt.value);
|
|
73
|
+
}, noContainer: true }, opt.value));
|
|
74
|
+
}) }), _jsx("button", { type: "button", className: styles.actionButton, onClick: handleAction, disabled: disabled || enabledValues.length === 0, "aria-disabled": disabled || enabledValues.length === 0, children: _jsx("span", { className: styles.actionText, "data-mode": allEnabledSelected ? 'clear' : 'all', children: allEnabledSelected ? clearText : allText }) })] }));
|
|
75
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
.wrapper {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: var(--spacing-xs);
|
|
5
|
+
flex-direction: row; /* keep on one line */
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.fullWidth {
|
|
9
|
+
width: 100%;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/* Heights aligned with other controls */
|
|
13
|
+
.xs {
|
|
14
|
+
min-height: var(--component-size-xs);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.sm {
|
|
18
|
+
min-height: var(--component-size-sm);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.md {
|
|
22
|
+
min-height: var(--component-size-md);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.lg {
|
|
26
|
+
min-height: var(--component-size-lg);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Subtle container (lightweight) */
|
|
30
|
+
.contained {
|
|
31
|
+
padding: 0 var(--spacing-xs);
|
|
32
|
+
border: var(--border-width-thin) solid var(--color-border-subtle);
|
|
33
|
+
border-radius: var(--border-radius-md);
|
|
34
|
+
background: var(--color-bg-surface);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.plain {
|
|
38
|
+
padding: 0;
|
|
39
|
+
border: 0;
|
|
40
|
+
background: transparent;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.groupLabel {
|
|
44
|
+
font-weight: var(--font-weight-medium);
|
|
45
|
+
color: var(--color-fg-muted);
|
|
46
|
+
white-space: nowrap;
|
|
47
|
+
font-size: var(--font-size-sm);
|
|
48
|
+
line-height: var(--line-height-tight);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.items {
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
gap: var(--spacing-xs);
|
|
55
|
+
flex: 1 1 auto;
|
|
56
|
+
min-width: 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.wrap {
|
|
60
|
+
flex-wrap: wrap;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.noWrap {
|
|
64
|
+
flex-wrap: nowrap;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* Right action */
|
|
68
|
+
.actionButton {
|
|
69
|
+
appearance: none;
|
|
70
|
+
border: none;
|
|
71
|
+
background: transparent;
|
|
72
|
+
padding: 0;
|
|
73
|
+
margin-left: auto;
|
|
74
|
+
cursor: pointer;
|
|
75
|
+
|
|
76
|
+
display: inline-flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
|
|
79
|
+
height: 100%;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.actionButton:disabled {
|
|
83
|
+
cursor: not-allowed;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.actionText {
|
|
87
|
+
display: inline-block;
|
|
88
|
+
font-size: var(--font-size-sm);
|
|
89
|
+
line-height: var(--line-height-tight);
|
|
90
|
+
font-weight: var(--font-weight-medium);
|
|
91
|
+
white-space: nowrap;
|
|
92
|
+
text-align: right;
|
|
93
|
+
|
|
94
|
+
min-width: var(--checkboxgroup-action-min-width, 4ch);
|
|
95
|
+
color: var(--color-link);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.actionText[data-mode='all'] {
|
|
99
|
+
color: var(--color-link);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.actionText[data-mode='clear'] {
|
|
103
|
+
color: var(--color-link);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.actionButton:not(:disabled):hover .actionText {
|
|
107
|
+
color: var(--color-link-hover);
|
|
108
|
+
text-decoration: underline;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.actionButton:focus-visible {
|
|
112
|
+
outline: 2px solid var(--color-border-strong);
|
|
113
|
+
outline-offset: 3px;
|
|
114
|
+
border-radius: var(--border-radius-rounded);
|
|
115
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Size } from '../../../types/sizes.types';
|
|
3
|
+
import type { InputContainerProps } from '../input-container/InputContainer';
|
|
4
|
+
export type InputVariant = 'outlined' | 'filled' | 'standalone';
|
|
5
|
+
export type InputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'width'> & Omit<InputContainerProps, 'children' | 'htmlFor' | 'tooltip' | 'tooltipPlacement'> & {
|
|
6
|
+
icon?: React.ReactNode;
|
|
7
|
+
autoFocus?: boolean;
|
|
8
|
+
minWidth?: string | number;
|
|
9
|
+
width?: string | number;
|
|
10
|
+
inputSize?: Size;
|
|
11
|
+
variant?: InputVariant;
|
|
12
|
+
onClear?: () => void;
|
|
13
|
+
onButtonClick?: () => void;
|
|
14
|
+
buttonLabel?: string;
|
|
15
|
+
buttonIcon?: React.ReactNode;
|
|
16
|
+
tooltip?: React.ReactNode;
|
|
17
|
+
tooltipPlacement?: 'top' | 'right' | 'bottom' | 'left';
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Explicit exported type annotation is required with --isolatedDeclarations.
|
|
21
|
+
*/
|
|
22
|
+
export declare const Input: React.ForwardRefExoticComponent<React.PropsWithoutRef<InputProps> & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useEffect, useId, useRef } from 'react';
|
|
4
|
+
import { Button } from '../../../components/button/Button';
|
|
5
|
+
import { ClearButton } from '../../../components/clear-button/ClearButton';
|
|
6
|
+
import { useTooltipTrigger } from '../../../components/overlay/tooltip/useTooltipTrigger';
|
|
7
|
+
import styles from '../input/Input.module.css';
|
|
8
|
+
import { InputContainer } from '../input-container/InputContainer';
|
|
9
|
+
function mergeRefs(...refs) {
|
|
10
|
+
return (node) => {
|
|
11
|
+
for (const ref of refs) {
|
|
12
|
+
if (!ref)
|
|
13
|
+
continue;
|
|
14
|
+
if (typeof ref === 'function')
|
|
15
|
+
ref(node);
|
|
16
|
+
else
|
|
17
|
+
ref.current = node;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Explicit exported type annotation is required with --isolatedDeclarations.
|
|
23
|
+
*/
|
|
24
|
+
export const Input = forwardRef(function Input({
|
|
25
|
+
// InputContainer props
|
|
26
|
+
label, error, helpText, orientation = 'horizontal', labelWidth = '120px', fullWidth = false, required,
|
|
27
|
+
// ✅ Input-level tooltip props
|
|
28
|
+
tooltip, tooltipPlacement = 'right',
|
|
29
|
+
// Input-only props
|
|
30
|
+
icon, autoFocus, minWidth, width, inputSize = 'md', variant = 'outlined', onClear, onButtonClick, buttonLabel, buttonIcon,
|
|
31
|
+
// Native input props
|
|
32
|
+
id, style, className, ...inputProps }, ref) {
|
|
33
|
+
const inputRef = useRef(null);
|
|
34
|
+
const reactId = useId();
|
|
35
|
+
const inputId = id !== null && id !== void 0 ? id : `input-${reactId}`;
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
var _a;
|
|
38
|
+
if (autoFocus)
|
|
39
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
40
|
+
}, [autoFocus]);
|
|
41
|
+
const hasButton = Boolean(onButtonClick || buttonLabel || buttonIcon);
|
|
42
|
+
const rootStyle = {
|
|
43
|
+
...(style !== null && style !== void 0 ? style : {}),
|
|
44
|
+
...(minWidth ? { ['--input-min-width']: minWidth } : null),
|
|
45
|
+
...(width ? { ['--input-width']: width } : null),
|
|
46
|
+
};
|
|
47
|
+
// Anchor tooltip to the stable "field" wrapper (input + icon + clear button)
|
|
48
|
+
const { triggerProps } = useTooltipTrigger({
|
|
49
|
+
content: tooltip,
|
|
50
|
+
placement: tooltipPlacement,
|
|
51
|
+
offset: 8,
|
|
52
|
+
});
|
|
53
|
+
return (_jsx(InputContainer, { label: label, htmlFor: inputId, fullWidth: fullWidth, error: error, helpText: helpText, orientation: orientation, labelWidth: labelWidth, required: required, children: _jsxs("div", { style: rootStyle, className: [
|
|
54
|
+
styles.container,
|
|
55
|
+
fullWidth ? styles.fullWidth : '',
|
|
56
|
+
onClear ? styles.withClear : '',
|
|
57
|
+
hasButton ? styles.withButton : '',
|
|
58
|
+
className !== null && className !== void 0 ? className : '',
|
|
59
|
+
]
|
|
60
|
+
.filter(Boolean)
|
|
61
|
+
.join(' '), children: [_jsxs("div", { className: styles.field, ...(tooltip ? triggerProps : {}), children: [icon && _jsx("span", { className: styles.icon, children: icon }), _jsx("input", { ...inputProps, id: inputId, ref: mergeRefs(inputRef, ref), className: [
|
|
62
|
+
styles.input,
|
|
63
|
+
icon ? styles.inputWithIcon : '',
|
|
64
|
+
inputSize ? styles[inputSize] : '',
|
|
65
|
+
styles[variant],
|
|
66
|
+
]
|
|
67
|
+
.filter(Boolean)
|
|
68
|
+
.join(' ') }), onClear && inputProps.value && _jsx(ClearButton, { onClick: onClear, absolute: true })] }), hasButton && (_jsxs(Button, { onClick: onButtonClick, className: styles.trailingButton, type: "button", children: [buttonIcon !== null && buttonIcon !== void 0 ? buttonIcon : null, buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel : null] }))] }) }));
|
|
69
|
+
});
|
|
70
|
+
Input.displayName = 'Input';
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/* Root control group */
|
|
2
|
+
.container {
|
|
3
|
+
/* inline-flex makes width behave weird in parents */
|
|
4
|
+
display: inline-flex;
|
|
5
|
+
align-items: stretch;
|
|
6
|
+
gap: 0;
|
|
7
|
+
|
|
8
|
+
/* width control */
|
|
9
|
+
inline-size: var(--input-width, auto);
|
|
10
|
+
min-inline-size: var(--input-min-width, 0);
|
|
11
|
+
max-inline-size: var(--input-max-width, none);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* When you want it to take available space */
|
|
15
|
+
.fullWidth {
|
|
16
|
+
display: flex;
|
|
17
|
+
inline-size: 100%;
|
|
18
|
+
min-inline-size: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* The "field" (input + icons + clear) */
|
|
22
|
+
.field {
|
|
23
|
+
position: relative;
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
flex: 1 1 auto;
|
|
27
|
+
min-inline-size: 0; /* critical for ellipsis inside flex */
|
|
28
|
+
color: var(--color-fg-default);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* Actual input */
|
|
32
|
+
.input {
|
|
33
|
+
flex: 1 1 auto;
|
|
34
|
+
min-inline-size: 0; /* critical */
|
|
35
|
+
inline-size: 100%;
|
|
36
|
+
|
|
37
|
+
font-family: var(--font-family);
|
|
38
|
+
font-size: var(--font-size-sm);
|
|
39
|
+
line-height: var(--line-height-normal);
|
|
40
|
+
box-sizing: border-box;
|
|
41
|
+
text-overflow: ellipsis;
|
|
42
|
+
|
|
43
|
+
background-color: var(--color-bg-surface);
|
|
44
|
+
border: var(--border-width-thin) solid var(--color-border-default);
|
|
45
|
+
border-radius: var(--border-radius-default);
|
|
46
|
+
|
|
47
|
+
padding-inline: var(--control-padding-x);
|
|
48
|
+
padding-block: calc(var(--control-padding-y) + var(--density));
|
|
49
|
+
|
|
50
|
+
transition:
|
|
51
|
+
background-color var(--transition-fast) var(--ease-standard),
|
|
52
|
+
border-color var(--transition-fast) var(--ease-standard),
|
|
53
|
+
box-shadow var(--transition-fast) var(--ease-standard);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* Button group styling */
|
|
57
|
+
.withButton .input {
|
|
58
|
+
border-top-right-radius: 0;
|
|
59
|
+
border-bottom-right-radius: 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Optional: if ClearButton is absolutely positioned, reserve space */
|
|
63
|
+
.withClear .input {
|
|
64
|
+
padding-inline-end: calc(var(--control-padding-x) + 28px);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* Placeholder */
|
|
68
|
+
.input::placeholder {
|
|
69
|
+
color: var(--color-fg-muted);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* Hover & focus */
|
|
73
|
+
.input:hover {
|
|
74
|
+
border-color: var(--color-border-strong);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.input:focus-visible {
|
|
78
|
+
outline: none;
|
|
79
|
+
border-color: var(--color-border-selected);
|
|
80
|
+
box-shadow: var(--focus-ring);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* Variants */
|
|
84
|
+
.filled {
|
|
85
|
+
background-color: var(--color-bg-surface);
|
|
86
|
+
border: 0;
|
|
87
|
+
}
|
|
88
|
+
.standalone {
|
|
89
|
+
border-radius: var(--border-radius-rounded);
|
|
90
|
+
background-color: var(--color-bg-surface);
|
|
91
|
+
box-shadow: var(--shadow-xs), var(--shadow-md);
|
|
92
|
+
}
|
|
93
|
+
.standalone:focus-visible {
|
|
94
|
+
outline: none;
|
|
95
|
+
border-color: var(--color-border-selected);
|
|
96
|
+
box-shadow: var(--focus-ring);
|
|
97
|
+
}
|
|
98
|
+
.outlined {
|
|
99
|
+
background-color: transparent;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* Sizes */
|
|
103
|
+
.xs {
|
|
104
|
+
block-size: calc(var(--component-size-xs) + var(--density));
|
|
105
|
+
font-size: var(--font-size-sm);
|
|
106
|
+
padding: 0 var(--spacing-xxs);
|
|
107
|
+
}
|
|
108
|
+
.sm {
|
|
109
|
+
block-size: calc(var(--component-size-sm) + var(--density));
|
|
110
|
+
font-size: var(--font-size-sm);
|
|
111
|
+
}
|
|
112
|
+
.md {
|
|
113
|
+
block-size: calc(var(--component-size-md) + var(--density));
|
|
114
|
+
font-size: var(--font-size-sm);
|
|
115
|
+
}
|
|
116
|
+
.lg {
|
|
117
|
+
block-size: calc(var(--component-size-lg) + var(--density));
|
|
118
|
+
font-size: var(--font-size-lg);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* Leading icon */
|
|
122
|
+
.inputWithIcon {
|
|
123
|
+
padding-inline-start: calc(var(--icon-size-md) + var(--spacing-lg));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.icon {
|
|
127
|
+
position: absolute;
|
|
128
|
+
inset-inline-start: var(--spacing-md);
|
|
129
|
+
top: 50%;
|
|
130
|
+
transform: translateY(-50%);
|
|
131
|
+
display: inline-flex;
|
|
132
|
+
align-items: center;
|
|
133
|
+
justify-content: center;
|
|
134
|
+
inline-size: var(--icon-size-md);
|
|
135
|
+
block-size: var(--icon-size-md);
|
|
136
|
+
pointer-events: none;
|
|
137
|
+
color: var(--color-fg-subtle);
|
|
138
|
+
}
|
|
139
|
+
.icon svg {
|
|
140
|
+
inline-size: var(--icon-size-md);
|
|
141
|
+
block-size: var(--icon-size-md);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/* Trailing action button (outside field) */
|
|
145
|
+
.trailingButton {
|
|
146
|
+
flex: 0 0 auto;
|
|
147
|
+
border-top-left-radius: 0;
|
|
148
|
+
border-bottom-left-radius: 0;
|
|
149
|
+
border-left: var(--border-width-thin) solid transparent;
|
|
150
|
+
margin-left: calc(-1 * var(--border-width-thin));
|
|
151
|
+
}
|
|
152
|
+
.trailingButton:hover {
|
|
153
|
+
border-color: var(--color-border-default);
|
|
154
|
+
z-index: 2;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* Date/time picker indicator (WebKit) */
|
|
158
|
+
.input[type='datetime-local']::-webkit-calendar-picker-indicator {
|
|
159
|
+
filter: invert(0.7);
|
|
160
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface InputContainerProps {
|
|
3
|
+
label?: string;
|
|
4
|
+
htmlFor?: string;
|
|
5
|
+
error?: string;
|
|
6
|
+
helpText?: string;
|
|
7
|
+
helpTextAddition?: string;
|
|
8
|
+
fullWidth?: boolean;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
orientation?: 'vertical' | 'horizontal';
|
|
12
|
+
labelWidth?: string;
|
|
13
|
+
labelAlignment?: 'top' | 'center';
|
|
14
|
+
}
|
|
15
|
+
export declare function InputContainer({ label, htmlFor, error, helpText, helpTextAddition, fullWidth, required, children, orientation, labelWidth, }: InputContainerProps): React.ReactElement;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styles from './InputContainer.module.css';
|
|
3
|
+
export function InputContainer({ label, htmlFor, error, helpText, helpTextAddition, fullWidth = false, required = false, children, orientation = 'horizontal', labelWidth = '120px', }) {
|
|
4
|
+
const message = error !== null && error !== void 0 ? error : helpText;
|
|
5
|
+
const messageClass = error ? styles.errorText : styles.helpText;
|
|
6
|
+
const renderLabel = label && (_jsxs("label", { className: styles.label, htmlFor: htmlFor, children: [label, required && _jsx("span", { className: styles.required, children: " *" })] }));
|
|
7
|
+
const renderMessageRow = (message || helpTextAddition) && (_jsxs("div", { className: `${messageClass} ${styles.messageRow}`, children: [_jsx("span", { children: message }), helpTextAddition && _jsx("span", { className: styles.helpTextAddition, children: helpTextAddition })] }));
|
|
8
|
+
if (orientation === 'vertical') {
|
|
9
|
+
return (_jsxs("div", { className: "dbc-flex dbc-flex-column dbc-gap-xs", style: { width: fullWidth ? '100%' : undefined }, children: [renderLabel, children, renderMessageRow] }));
|
|
10
|
+
}
|
|
11
|
+
return (_jsx("div", { className: styles.inputContainer, style: {
|
|
12
|
+
'--label-width': labelWidth,
|
|
13
|
+
width: fullWidth ? '100%' : undefined,
|
|
14
|
+
}, children: _jsxs("div", { className: `${styles.horizontal} dbc-flex dbc-flex-column dbc-gap-xs`, children: [_jsxs("div", { className: `${styles.labelContainer} dbc-flex dbc-items-center dbc-gap-xs`, children: [renderLabel, children] }), renderMessageRow] }) }));
|
|
15
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.horizontal {
|
|
2
|
+
--gap: var(--spacing-sm);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.labelContainer {
|
|
6
|
+
gap: var(--gap);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.horizontal .errorText,
|
|
10
|
+
.horizontal .helpText {
|
|
11
|
+
margin-left: calc(var(--label-width) + var(--gap));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.helpText {
|
|
15
|
+
color: var(--color-fg-subtle);
|
|
16
|
+
font-size: var(--font-size-sm);
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.horizontal label {
|
|
23
|
+
width: var(--label-width);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.errorText {
|
|
27
|
+
color: var(--color-status-error);
|
|
28
|
+
font-size: var(--font-size-sm);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.required {
|
|
32
|
+
color: var(--color-status-error);
|
|
33
|
+
font-weight: bold;
|
|
34
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { ButtonVariant } from '../../../components/button/Button';
|
|
3
|
+
export interface MultiselectOption<T> {
|
|
4
|
+
label: string;
|
|
5
|
+
value: T;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
interface MultiSelectProps<T> {
|
|
9
|
+
options: MultiselectOption<T>[];
|
|
10
|
+
selectedValues: T[];
|
|
11
|
+
onChange: (selectedValue: T) => void;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
variant?: ButtonVariant;
|
|
15
|
+
size?: 'sm' | 'md' | 'lg';
|
|
16
|
+
onClear?: () => void;
|
|
17
|
+
dataCy?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function MultiSelect<T extends string | number>({ options, selectedValues, onChange, children, variant, size, onClear, dataCy, }: MultiSelectProps<T>): ReactNode;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Check, Square } from 'lucide-react';
|
|
3
|
+
import { Button } from '../../../components/button/Button';
|
|
4
|
+
import { Chip } from '../../../components/chip/Chip';
|
|
5
|
+
import { ClearButton } from '../../../components/clear-button/ClearButton';
|
|
6
|
+
import { Menu } from '../../../components/menu/Menu';
|
|
7
|
+
import { Popover } from '../../../components/popover/Popover';
|
|
8
|
+
export function MultiSelect({ options, selectedValues = [], onChange, children, variant = 'outlined', size = 'md', onClear, dataCy, }) {
|
|
9
|
+
return (_jsx(Popover, { dataCy: dataCy, trigger: (onClick, icon) => (_jsxs(Button, { variant: variant, onClick: onClick, size: size, children: [_jsxs("span", { children: [children || 'Vælg', ' ', selectedValues.length > 0 ? (_jsx(Chip, { size: "sm", severity: "info", children: `${selectedValues.length}` })) : null] }), onClear && selectedValues.length > 0 && _jsx(ClearButton, { onClick: onClear }), icon] })), children: _jsx(Menu, { children: options.map(option => (_jsx(Menu.Item, { active: selectedValues === null || selectedValues === void 0 ? void 0 : selectedValues.includes(option.value), children: _jsxs("button", { onClick: () => {
|
|
10
|
+
onChange(option.value);
|
|
11
|
+
}, children: [_jsx("span", { style: {
|
|
12
|
+
pointerEvents: 'none',
|
|
13
|
+
display: 'flex',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
color: !(selectedValues === null || selectedValues === void 0 ? void 0 : selectedValues.includes(option.value))
|
|
16
|
+
? 'var(--color-border-strong)'
|
|
17
|
+
: 'inherit',
|
|
18
|
+
}, children: (selectedValues === null || selectedValues === void 0 ? void 0 : selectedValues.includes(option.value)) ? _jsx(Check, {}) : _jsx(Square, {}) }), option.label] }) }, option.value))) }) }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ButtonVariant } from '../../button/Button';
|
|
3
|
+
import { InputContainer } from '../input-container/InputContainer';
|
|
4
|
+
import { MultiselectOption } from '../multi-select/MultiSelect';
|
|
5
|
+
type InputContainerProps = React.ComponentProps<typeof InputContainer>;
|
|
6
|
+
export type SelectProps<T> = Omit<InputContainerProps, 'children' | 'htmlFor' | 'tooltip' | 'tooltipPlacement'> & {
|
|
7
|
+
id?: string;
|
|
8
|
+
options: MultiselectOption<T>[];
|
|
9
|
+
selectedValue: T | null;
|
|
10
|
+
onChange: (value: T) => void;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
size?: 'sm' | 'md' | 'lg';
|
|
13
|
+
variant?: ButtonVariant;
|
|
14
|
+
onClear?: () => void;
|
|
15
|
+
datakey?: string;
|
|
16
|
+
dataCy?: string;
|
|
17
|
+
tooltip?: React.ReactNode;
|
|
18
|
+
tooltipPlacement?: 'top' | 'right' | 'bottom' | 'left';
|
|
19
|
+
};
|
|
20
|
+
export declare function Select<T extends string | number | Record<string, any>>({ label, error, helpText, orientation, labelWidth, fullWidth, required, tooltip, tooltipPlacement, id, options, selectedValue, onChange, placeholder, size, variant, onClear, datakey, dataCy, }: SelectProps<T>): React.ReactNode;
|
|
21
|
+
export {};
|