@dbcdk/react-components 0.0.96 → 0.0.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/table/Table.d.ts +1 -1
- package/dist/components/table/Table.types.d.ts +3 -0
- package/dist/components/table/components/TableHeader.d.ts +2 -1
- package/dist/index.cjs +12750 -0
- package/dist/index.css +7149 -0
- package/dist/index.js +12641 -79
- package/dist/tanstack.cjs +2674 -0
- package/dist/tanstack.css +1267 -0
- package/dist/tanstack.js +2650 -3
- package/dist/themes/dbc.css +3 -0
- package/dist/themes/forfatterweb.css +2 -0
- package/package.json +11 -10
- package/dist/assets/logo.js +0 -2
- package/dist/components/__stories__/_data/table.d.ts +0 -15
- package/dist/components/__stories__/_data/table.js +0 -55
- package/dist/components/__stories__/_data/tabs.d.ts +0 -9
- package/dist/components/__stories__/_data/tabs.js +0 -31
- package/dist/components/__stories__/story-components/Colors.d.ts +0 -11
- package/dist/components/__stories__/story-components/Colors.js +0 -96
- package/dist/components/__stories__/story-components/Colors.module.css +0 -27
- package/dist/components/__stories__/story-components/ComponentSizes.d.ts +0 -2
- package/dist/components/__stories__/story-components/ComponentSizes.js +0 -26
- package/dist/components/__stories__/story-components/Elevation.d.ts +0 -2
- package/dist/components/__stories__/story-components/Elevation.js +0 -49
- package/dist/components/__stories__/story-components/Flex.d.ts +0 -2
- package/dist/components/__stories__/story-components/Flex.js +0 -177
- package/dist/components/__stories__/story-components/Flex.module.css +0 -317
- package/dist/components/__stories__/story-components/Spacing.d.ts +0 -6
- package/dist/components/__stories__/story-components/Spacing.js +0 -76
- package/dist/components/__stories__/story-components/Spacing.module.css +0 -154
- package/dist/components/accordion/Accordion.js +0 -70
- package/dist/components/accordion/Accordion.module.css +0 -28
- package/dist/components/accordion/components/AccordionRow.js +0 -53
- package/dist/components/accordion/components/AccordionRow.module.css +0 -90
- package/dist/components/alert/Alert.js +0 -17
- package/dist/components/alert/Alert.module.css +0 -98
- package/dist/components/app-header/AppHeader.js +0 -5
- package/dist/components/app-header/AppHeader.module.css +0 -74
- package/dist/components/attribute-chip/AttributeChip.js +0 -5
- package/dist/components/attribute-chip/AttributeChip.module.css +0 -65
- package/dist/components/avatar/Avatar.js +0 -48
- package/dist/components/avatar/Avatar.module.css +0 -91
- package/dist/components/breadcrumbs/Breadcrumbs.js +0 -6
- package/dist/components/breadcrumbs/Breadcrumbs.module.css +0 -80
- package/dist/components/button/Button.js +0 -81
- package/dist/components/button/Button.module.css +0 -249
- package/dist/components/button-select/ButtonSelect.js +0 -7
- package/dist/components/button-select/ButtonSelect.module.css +0 -40
- package/dist/components/card/Card.js +0 -71
- package/dist/components/card/Card.module.css +0 -160
- package/dist/components/card/components/CardMeta.js +0 -26
- package/dist/components/card/components/CardMeta.module.css +0 -55
- package/dist/components/card-container/CardContainer.js +0 -6
- package/dist/components/card-container/CardContainer.module.css +0 -61
- package/dist/components/chip/Chip.js +0 -31
- package/dist/components/chip/Chip.module.css +0 -236
- package/dist/components/circle/Circle.js +0 -5
- package/dist/components/circle/Circle.module.css +0 -128
- package/dist/components/clear-button/ClearButton.js +0 -13
- package/dist/components/clear-button/ClearButton.module.css +0 -26
- package/dist/components/code-block/CodeBlock.js +0 -58
- package/dist/components/code-block/CodeBlock.module.css +0 -124
- package/dist/components/copy-button/CopyButton.js +0 -78
- package/dist/components/copy-button/CopyButton.module.css +0 -22
- package/dist/components/datetime-picker/DateTimePicker.js +0 -403
- package/dist/components/datetime-picker/DateTimePicker.module.css +0 -155
- package/dist/components/datetime-picker/dateTimeHelpers.js +0 -248
- package/dist/components/divider/Divider.js +0 -12
- package/dist/components/filter-field/FilterField.js +0 -191
- package/dist/components/filter-field/FilterField.module.css +0 -379
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.js +0 -52
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.module.css +0 -59
- package/dist/components/forms/checkbox/Checkbox.js +0 -28
- package/dist/components/forms/checkbox/Checkbox.module.css +0 -103
- package/dist/components/forms/checkbox-group/CheckboxGroup.js +0 -75
- package/dist/components/forms/checkbox-group/CheckboxGroup.module.css +0 -115
- package/dist/components/forms/form-select/FormSelect.js +0 -86
- package/dist/components/forms/form-select/FormSelect.module.css +0 -236
- package/dist/components/forms/input/Input.js +0 -77
- package/dist/components/forms/input/Input.module.css +0 -468
- package/dist/components/forms/input-container/InputContainer.js +0 -15
- package/dist/components/forms/input-container/InputContainer.module.css +0 -60
- package/dist/components/forms/multi-select/MultiSelect.js +0 -122
- package/dist/components/forms/radio-buttons/RadioButton.js +0 -26
- package/dist/components/forms/radio-buttons/RadioButtonGroup.js +0 -19
- package/dist/components/forms/radio-buttons/RadioButtons.module.css +0 -118
- package/dist/components/forms/select/Select.js +0 -185
- package/dist/components/forms/select/Select.module.css +0 -32
- package/dist/components/forms/text-area/Textarea.js +0 -47
- package/dist/components/forms/text-area/Textarea.module.css +0 -70
- package/dist/components/forms/typeahead/Typeahead.js +0 -668
- package/dist/components/forms/typeahead/Typeahead.module.css +0 -38
- package/dist/components/grid/Grid.js +0 -23
- package/dist/components/grid/Grid.module.css +0 -35
- package/dist/components/headline/CollapsibleHeadline.js +0 -29
- package/dist/components/headline/Headline.js +0 -26
- package/dist/components/headline/Headline.module.css +0 -185
- package/dist/components/hyperlink/Hyperlink.js +0 -40
- package/dist/components/hyperlink/Hyperlink.module.css +0 -107
- package/dist/components/icon/Icon.js +0 -14
- package/dist/components/icon/Icon.module.css +0 -36
- package/dist/components/interval-select/IntervalSelect.js +0 -99
- package/dist/components/json-viewer/HighlightedText.js +0 -6
- package/dist/components/json-viewer/JsonNode.js +0 -30
- package/dist/components/json-viewer/JsonViewer.js +0 -68
- package/dist/components/json-viewer/JsonViewer.module.css +0 -346
- package/dist/components/json-viewer/types.js +0 -1
- package/dist/components/json-viewer/useClipboardStatus.js +0 -11
- package/dist/components/json-viewer/utils.js +0 -125
- package/dist/components/menu/Menu.js +0 -165
- package/dist/components/menu/Menu.module.css +0 -220
- package/dist/components/meta-bar/MetaBar.js +0 -9
- package/dist/components/meta-bar/MetaBar.module.css +0 -27
- package/dist/components/nav-bar/NavBar.js +0 -29
- package/dist/components/nav-bar/NavBar.module.css +0 -221
- package/dist/components/overlay/fade-overlay/FadeOverlay.js +0 -8
- package/dist/components/overlay/fade-overlay/FadeOverlay.module.css +0 -54
- package/dist/components/overlay/modal/Modal.js +0 -115
- package/dist/components/overlay/modal/Modal.module.css +0 -109
- package/dist/components/overlay/modal/provider/ModalProvider.js +0 -73
- package/dist/components/overlay/side-panel/SidePanel.js +0 -83
- package/dist/components/overlay/side-panel/SidePanel.module.css +0 -177
- package/dist/components/overlay/side-panel/useSidePanel.js +0 -11
- package/dist/components/overlay/tooltip/Tooltip.js +0 -17
- package/dist/components/overlay/tooltip/Tooltip.module.css +0 -104
- package/dist/components/overlay/tooltip/TooltipProvider.js +0 -255
- package/dist/components/overlay/tooltip/useTooltipTrigger.js +0 -118
- package/dist/components/page/Page.js +0 -11
- package/dist/components/page/Page.module.css +0 -89
- package/dist/components/page-layout/PageLayout.js +0 -76
- package/dist/components/page-layout/PageLayout.module.css +0 -236
- package/dist/components/page-layout/components/layout-footer/LayoutFooter.js +0 -27
- package/dist/components/page-layout/components/layout-footer/LayoutFooter.module.css +0 -89
- package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.js +0 -14
- package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.module.css +0 -84
- package/dist/components/pagination/Pagination.js +0 -56
- package/dist/components/pagination/Pagination.module.css +0 -25
- package/dist/components/panel/Panel.js +0 -7
- package/dist/components/panel/Panel.module.css +0 -29
- package/dist/components/popover/Popover.js +0 -257
- package/dist/components/popover/Popover.module.css +0 -54
- package/dist/components/search-box/SearchBox.js +0 -170
- package/dist/components/search-box/SearchBox.module.css +0 -21
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.js +0 -48
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.module.css +0 -167
- package/dist/components/sidebar/Sidebar.js +0 -6
- package/dist/components/sidebar/components/SidebarItem.js +0 -8
- package/dist/components/sidebar/components/SidebarItem.module.css +0 -0
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.js +0 -63
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.module.css +0 -29
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.js +0 -153
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.module.css +0 -260
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.js +0 -18
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.module.css +0 -106
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.js +0 -26
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.module.css +0 -20
- package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.js +0 -30
- package/dist/components/sidebar/providers/SidebarProvider.js +0 -229
- package/dist/components/skeleton-loader/SkeletonLoader.js +0 -73
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.js +0 -13
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.module.css +0 -51
- package/dist/components/split-button/SplitButton.js +0 -10
- package/dist/components/split-button/SplitButton.module.css +0 -32
- package/dist/components/split-pane/SplitPane.js +0 -107
- package/dist/components/split-pane/SplitPane.module.css +0 -111
- package/dist/components/split-pane/provider/SplitPaneContext.js +0 -124
- package/dist/components/stack/Stack.js +0 -33
- package/dist/components/stack/Stack.module.css +0 -61
- package/dist/components/state-page/StatePage.js +0 -20
- package/dist/components/state-page/StatePage.module.css +0 -9
- package/dist/components/state-page/empty.js +0 -2
- package/dist/components/state-page/error.js +0 -2
- package/dist/components/state-page/notFound.js +0 -2
- package/dist/components/sticky-footer-layout/StickyFooterLayout.js +0 -64
- package/dist/components/table/Table.js +0 -50
- package/dist/components/table/Table.module.css +0 -536
- package/dist/components/table/Table.types.js +0 -1
- package/dist/components/table/TanstackTable.js +0 -111
- package/dist/components/table/components/TableBody.js +0 -10
- package/dist/components/table/components/TableHeader.js +0 -7
- package/dist/components/table/components/TableHeaderCell.js +0 -24
- package/dist/components/table/components/TableLoadingBody.js +0 -26
- package/dist/components/table/components/TablePagination.js +0 -1
- package/dist/components/table/components/TableRow.js +0 -54
- package/dist/components/table/components/TableSelectionCell.js +0 -16
- package/dist/components/table/components/column-resizer/ColumnResizer.js +0 -5
- package/dist/components/table/components/column-resizer/ColumnResizer.module.css +0 -22
- package/dist/components/table/components/empty-state/EmptyState.js +0 -23
- package/dist/components/table/components/empty-state/EmptyState.module.css +0 -4
- package/dist/components/table/components/table-settings/TableSettings.js +0 -63
- package/dist/components/table/hooks/useTableRowInteractions.js +0 -30
- package/dist/components/table/table.classes.js +0 -23
- package/dist/components/table/table.utils.js +0 -47
- package/dist/components/table/tanstackTable.utils.js +0 -175
- package/dist/components/tabs/Tabs.js +0 -125
- package/dist/components/tabs/Tabs.module.css +0 -233
- package/dist/components/theme-button/ThemeButton.js +0 -23
- package/dist/components/toast/Toast.js +0 -20
- package/dist/components/toast/Toast.module.css +0 -161
- package/dist/components/toast/provider/ToastProvider.js +0 -70
- package/dist/components/user-display/UserDisplay.js +0 -6
- package/dist/components/user-display/UserDisplay.module.css +0 -25
- package/dist/constants/severity.js +0 -24
- package/dist/constants/severity.types.js +0 -1
- package/dist/constants/sizes.js +0 -7
- package/dist/hooks/useDeviceSize.js +0 -32
- package/dist/hooks/useListNavigation.js +0 -234
- package/dist/hooks/usePagination.js +0 -140
- package/dist/hooks/useSorting.js +0 -118
- package/dist/hooks/useTableData.js +0 -45
- package/dist/hooks/useTableSelection.js +0 -164
- package/dist/hooks/useTableSettings.js +0 -71
- package/dist/hooks/useTheme.js +0 -66
- package/dist/hooks/useTimeDuration.js +0 -68
- package/dist/hooks/useViewportFill.js +0 -77
- package/dist/styles/animation.js +0 -5
- package/dist/styles/themes/types.js +0 -1
- package/dist/types/a11y-props.types.js +0 -1
- package/dist/types/sizes.types.js +0 -1
- package/dist/utils/arrays/nested-filtering.js +0 -48
- package/dist/utils/date/formatDate.js +0 -51
- package/dist/utils/localStorage.utils.js +0 -78
- package/dist/utils/text/get-highlighted-segments.js +0 -46
|
@@ -1,115 +0,0 @@
|
|
|
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-default);
|
|
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
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { ChevronDown, X } from 'lucide-react';
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import { useTooltipTrigger } from '../../../components/overlay/tooltip/useTooltipTrigger';
|
|
6
|
-
import styles from './FormSelect.module.css';
|
|
7
|
-
import { InputContainer } from '../input-container/InputContainer';
|
|
8
|
-
function isEqualValue(a, b, datakey) {
|
|
9
|
-
if (a === b)
|
|
10
|
-
return true;
|
|
11
|
-
if (!a || !b)
|
|
12
|
-
return false;
|
|
13
|
-
if (typeof a === 'object' && typeof b === 'object' && datakey) {
|
|
14
|
-
return a[datakey] === b[datakey];
|
|
15
|
-
}
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
function serializeValue(value, datakey) {
|
|
19
|
-
if (typeof value === 'string' || typeof value === 'number')
|
|
20
|
-
return String(value);
|
|
21
|
-
if (datakey && value && typeof value === 'object') {
|
|
22
|
-
const v = value[datakey];
|
|
23
|
-
return v == null ? '' : String(v);
|
|
24
|
-
}
|
|
25
|
-
throw new Error('FormSelect: option value is an object but no `datakey` was provided. Native select requires string/number values.');
|
|
26
|
-
}
|
|
27
|
-
function findSelectedOption(options, selectedValue, datakey) {
|
|
28
|
-
return options.find(o => isEqualValue(o.value, selectedValue, datakey));
|
|
29
|
-
}
|
|
30
|
-
export function FormSelect({
|
|
31
|
-
// InputContainer props
|
|
32
|
-
label, error, helpText, orientation = 'vertical', labelWidth = '160px', fullWidth = true, required, tooltip, tooltipPlacement = 'right', modified = false,
|
|
33
|
-
// FormSelect props
|
|
34
|
-
id, name, options, selectedValue, onChange, placeholder = 'Vælg', size = 'md', variant = 'outlined', onClear, datakey, dataCy, disabled, includePlaceholderOption = true, allowClearWhenRequired = false, }) {
|
|
35
|
-
const generatedId = React.useId();
|
|
36
|
-
const controlId = id !== null && id !== void 0 ? id : `select-${generatedId}`;
|
|
37
|
-
const describedById = `${controlId}-desc`;
|
|
38
|
-
const selected = React.useMemo(() => findSelectedOption(options, selectedValue, datakey), [options, selectedValue, datakey]);
|
|
39
|
-
const tooltipEnabled = Boolean(tooltip);
|
|
40
|
-
const { triggerProps, id: tooltipId } = useTooltipTrigger({
|
|
41
|
-
content: tooltipEnabled ? tooltip : null,
|
|
42
|
-
placement: tooltipPlacement,
|
|
43
|
-
offset: 8,
|
|
44
|
-
});
|
|
45
|
-
const describedBy = (() => {
|
|
46
|
-
const ids = [];
|
|
47
|
-
if (error || helpText)
|
|
48
|
-
ids.push(describedById);
|
|
49
|
-
if (tooltipEnabled)
|
|
50
|
-
ids.push(tooltipId);
|
|
51
|
-
return ids.length ? ids.join(' ') : undefined;
|
|
52
|
-
})();
|
|
53
|
-
const nativeValue = React.useMemo(() => {
|
|
54
|
-
if (selected && selected.value != null)
|
|
55
|
-
return serializeValue(selected.value, datakey);
|
|
56
|
-
return '';
|
|
57
|
-
}, [selected, datakey]);
|
|
58
|
-
const canClear = Boolean(onClear) && !disabled && (allowClearWhenRequired || !required);
|
|
59
|
-
const showClear = canClear && Boolean(selected);
|
|
60
|
-
const placeholderDisabled = Boolean(required) && !allowClearWhenRequired;
|
|
61
|
-
const handleNativeChange = e => {
|
|
62
|
-
const raw = e.target.value;
|
|
63
|
-
if (raw === '') {
|
|
64
|
-
// Clear only if consumer provided onClear
|
|
65
|
-
onClear === null || onClear === void 0 ? void 0 : onClear();
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const opt = options.find(o => serializeValue(o.value, datakey) === raw);
|
|
69
|
-
if (opt)
|
|
70
|
-
onChange(opt.value);
|
|
71
|
-
};
|
|
72
|
-
return (_jsxs(InputContainer, { label: label, htmlFor: controlId, fullWidth: fullWidth, error: error, helpText: helpText, orientation: orientation, labelWidth: labelWidth, required: required, modified: modified, children: [_jsxs("div", { className: [
|
|
73
|
-
styles.container,
|
|
74
|
-
fullWidth ? styles.fullWidth : '',
|
|
75
|
-
canClear ? styles.withButton : '',
|
|
76
|
-
]
|
|
77
|
-
.filter(Boolean)
|
|
78
|
-
.join(' '), children: [_jsxs("div", { className: styles.field, children: [_jsxs("select", { ...(tooltipEnabled ? triggerProps : {}), id: controlId, name: name, className: [styles.input, styles[size], styles[variant]].filter(Boolean).join(' '), value: nativeValue, onChange: handleNativeChange, disabled: disabled, "aria-invalid": Boolean(error) || undefined, "aria-describedby": describedBy, "data-cy": dataCy !== null && dataCy !== void 0 ? dataCy : 'formselect', "data-forminput": true, children: [includePlaceholderOption && (_jsx("option", { value: "", disabled: placeholderDisabled, children: placeholder })), options.map(opt => {
|
|
79
|
-
const v = serializeValue(opt.value, datakey);
|
|
80
|
-
return (_jsx("option", { value: v, children: opt.label }, v));
|
|
81
|
-
})] }), _jsx("span", { className: styles.chevron, "aria-hidden": "true", children: _jsx(ChevronDown, { size: 20 }) })] }), canClear && (_jsx("button", { type: "button", className: styles.trailingButton, onClick: e => {
|
|
82
|
-
e.preventDefault();
|
|
83
|
-
e.stopPropagation();
|
|
84
|
-
onClear === null || onClear === void 0 ? void 0 : onClear();
|
|
85
|
-
}, "aria-label": "Ryd valg", disabled: !showClear, "data-cy": dataCy ? `${dataCy}-clear` : 'formselect-clear', children: _jsx(X, { size: 18, "aria-hidden": "true" }) }))] }), (error || helpText) && (_jsx("span", { id: describedById, style: { display: 'none' }, children: error !== null && error !== void 0 ? error : helpText }))] }));
|
|
86
|
-
}
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
/* FormSelect.module.css */
|
|
2
|
-
|
|
3
|
-
/* =========================================
|
|
4
|
-
Root container (select + optional clear)
|
|
5
|
-
========================================= */
|
|
6
|
-
|
|
7
|
-
.container {
|
|
8
|
-
display: inline-flex;
|
|
9
|
-
align-items: stretch;
|
|
10
|
-
flex-grow: 1;
|
|
11
|
-
gap: 0;
|
|
12
|
-
|
|
13
|
-
inline-size: var(--input-width, auto);
|
|
14
|
-
min-inline-size: var(--input-min-width, 0);
|
|
15
|
-
max-inline-size: var(--input-max-width, none);
|
|
16
|
-
|
|
17
|
-
position: relative;
|
|
18
|
-
border-radius: var(--border-radius-default);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/* Full width variant */
|
|
22
|
-
.fullWidth {
|
|
23
|
-
display: flex;
|
|
24
|
-
inline-size: 100%;
|
|
25
|
-
min-inline-size: 0;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/* =========================================
|
|
29
|
-
Focus ring (GROUP LEVEL)
|
|
30
|
-
========================================= */
|
|
31
|
-
|
|
32
|
-
.container:focus-within {
|
|
33
|
-
box-shadow: 0 0 0 2px var(--color-border-selected);
|
|
34
|
-
z-index: 1;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/* IMPORTANT:
|
|
38
|
-
When focused, do NOT also turn the select's border blue,
|
|
39
|
-
otherwise you get the vertical seam line next to the button. */
|
|
40
|
-
.container:focus-within .input {
|
|
41
|
-
border-color: var(--color-border-default);
|
|
42
|
-
}
|
|
43
|
-
.container:focus-within .trailingButton {
|
|
44
|
-
border-color: var(--color-border-default);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/* =========================================
|
|
48
|
-
Field wrapper (native select + chevron)
|
|
49
|
-
========================================= */
|
|
50
|
-
|
|
51
|
-
.field {
|
|
52
|
-
position: relative;
|
|
53
|
-
display: flex;
|
|
54
|
-
align-items: center;
|
|
55
|
-
flex: 1 1 auto;
|
|
56
|
-
min-inline-size: 0;
|
|
57
|
-
color: var(--color-fg-default);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/* =========================================
|
|
61
|
-
Native select styling
|
|
62
|
-
========================================= */
|
|
63
|
-
|
|
64
|
-
.input {
|
|
65
|
-
appearance: none;
|
|
66
|
-
-webkit-appearance: none;
|
|
67
|
-
-moz-appearance: none;
|
|
68
|
-
|
|
69
|
-
flex: 1 1 auto;
|
|
70
|
-
min-inline-size: 0;
|
|
71
|
-
inline-size: 100%;
|
|
72
|
-
max-inline-size: 100%;
|
|
73
|
-
|
|
74
|
-
background: var(--color-bg-surface);
|
|
75
|
-
font-family: var(--font-family);
|
|
76
|
-
font-size: var(--font-size-sm);
|
|
77
|
-
line-height: var(--line-height-normal);
|
|
78
|
-
box-sizing: border-box;
|
|
79
|
-
text-overflow: ellipsis;
|
|
80
|
-
|
|
81
|
-
border: var(--border-width-thin) solid var(--color-border-default);
|
|
82
|
-
border-radius: var(--border-radius-default);
|
|
83
|
-
|
|
84
|
-
padding-inline: var(--spacing-sm);
|
|
85
|
-
padding-block: var(--spacing-xs);
|
|
86
|
-
|
|
87
|
-
/* Reserve space for chevron */
|
|
88
|
-
padding-inline-end: calc(var(--spacing-lg) + 28px);
|
|
89
|
-
|
|
90
|
-
transition:
|
|
91
|
-
background-color var(--transition-fast) var(--ease-standard),
|
|
92
|
-
border-color var(--transition-fast) var(--ease-standard),
|
|
93
|
-
box-shadow var(--transition-fast) var(--ease-standard);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/* Disabled select */
|
|
97
|
-
.input:disabled {
|
|
98
|
-
background-color: var(--color-disabled-bg);
|
|
99
|
-
color: var(--color-disabled-fg);
|
|
100
|
-
cursor: not-allowed;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/* Hover state */
|
|
104
|
-
.input:hover:not(:disabled) {
|
|
105
|
-
border-color: var(--color-border-strong);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/* Remove default focus ring (we use group-level ring) */
|
|
109
|
-
.input:focus-visible {
|
|
110
|
-
outline: none;
|
|
111
|
-
/* DO NOT set border-color here */
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/* =========================================
|
|
115
|
-
Variants
|
|
116
|
-
========================================= */
|
|
117
|
-
|
|
118
|
-
.filled {
|
|
119
|
-
background-color: var(--color-bg-surface);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.standalone {
|
|
123
|
-
border-radius: var(--border-radius-rounded);
|
|
124
|
-
background-color: var(--color-bg-surface);
|
|
125
|
-
box-shadow: var(--shadow-xs), var(--shadow-md);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.outlined {
|
|
129
|
-
background-color: transparent;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/* =========================================
|
|
133
|
-
Sizes
|
|
134
|
-
========================================= */
|
|
135
|
-
|
|
136
|
-
.sm {
|
|
137
|
-
block-size: var(--component-size-sm);
|
|
138
|
-
font-size: var(--font-size-sm);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.md {
|
|
142
|
-
block-size: var(--component-size-md);
|
|
143
|
-
font-size: var(--font-size-sm);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
.lg {
|
|
147
|
-
block-size: var(--component-size-lg);
|
|
148
|
-
font-size: var(--font-size-lg);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/* =========================================
|
|
152
|
-
Chevron (decorative only)
|
|
153
|
-
========================================= */
|
|
154
|
-
|
|
155
|
-
.chevron {
|
|
156
|
-
position: absolute;
|
|
157
|
-
inset-inline-end: var(--spacing-sm);
|
|
158
|
-
top: 50%;
|
|
159
|
-
transform: translateY(-50%);
|
|
160
|
-
display: inline-flex;
|
|
161
|
-
align-items: center;
|
|
162
|
-
justify-content: center;
|
|
163
|
-
pointer-events: none;
|
|
164
|
-
color: var(--color-fg-subtle);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.chevron svg {
|
|
168
|
-
inline-size: 20px;
|
|
169
|
-
block-size: 20px;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/* =========================================
|
|
173
|
-
Clear button integration
|
|
174
|
-
========================================= */
|
|
175
|
-
|
|
176
|
-
/* Remove right radius from select when button exists */
|
|
177
|
-
.withButton .input {
|
|
178
|
-
border-top-right-radius: 0;
|
|
179
|
-
border-bottom-right-radius: 0;
|
|
180
|
-
|
|
181
|
-
/* Prevent double border seam; the button provides the right side */
|
|
182
|
-
border-right-color: transparent;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/* Trailing clear button */
|
|
186
|
-
.trailingButton {
|
|
187
|
-
position: relative;
|
|
188
|
-
z-index: 2;
|
|
189
|
-
flex: 0 0 auto;
|
|
190
|
-
|
|
191
|
-
display: inline-flex;
|
|
192
|
-
align-items: center;
|
|
193
|
-
justify-content: center;
|
|
194
|
-
|
|
195
|
-
padding-inline: var(--spacing-sm);
|
|
196
|
-
|
|
197
|
-
border: var(--border-width-thin) solid var(--color-border-default);
|
|
198
|
-
|
|
199
|
-
/* Seam join: don't draw left border; select covers it */
|
|
200
|
-
border-left-color: transparent;
|
|
201
|
-
margin-left: calc(-1 * var(--border-width-thin));
|
|
202
|
-
|
|
203
|
-
border-top-right-radius: var(--border-radius-default);
|
|
204
|
-
border-bottom-right-radius: var(--border-radius-default);
|
|
205
|
-
|
|
206
|
-
background: var(--color-bg-surface);
|
|
207
|
-
cursor: pointer;
|
|
208
|
-
|
|
209
|
-
transition:
|
|
210
|
-
background-color var(--transition-fast) var(--ease-standard),
|
|
211
|
-
border-color var(--transition-fast) var(--ease-standard),
|
|
212
|
-
box-shadow var(--transition-fast) var(--ease-standard);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/* Hover state */
|
|
216
|
-
.trailingButton:hover:not(:disabled) {
|
|
217
|
-
border-color: var(--color-border-strong);
|
|
218
|
-
background-color: var(--color-bg-surface-hover, var(--color-bg-surface));
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/* Remove individual focus ring (group handles it) */
|
|
222
|
-
.trailingButton:focus-visible {
|
|
223
|
-
outline: none;
|
|
224
|
-
box-shadow: none;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/* Disabled clear button:
|
|
228
|
-
keep border/background stable; dim only icon */
|
|
229
|
-
.trailingButton:disabled {
|
|
230
|
-
cursor: default;
|
|
231
|
-
background: var(--color-bg-surface);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
.trailingButton:disabled svg {
|
|
235
|
-
opacity: 0.4;
|
|
236
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
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
|
-
export const Input = forwardRef(function Input({ label, error, helpText, orientation = 'vertical', labelWidth = '160px', fullWidth = false, required, tooltip, tooltipPlacement = 'right', modified = false, icon, autoFocus, minWidth, width, maxWidth, inputSize = 'md', variant = 'outlined', onClear, onButtonClick, buttonDisabled = false, buttonLabel, buttonIcon, trailingLabel, id, tooltipOpenOnFocus = true, style, className, fieldClassName, inputClassName, startAdornment, endAdornment, ...inputProps }, ref) {
|
|
22
|
-
const inputRef = useRef(null);
|
|
23
|
-
const reactId = useId();
|
|
24
|
-
const inputId = id !== null && id !== void 0 ? id : `input-${reactId}`;
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
var _a;
|
|
27
|
-
if (autoFocus)
|
|
28
|
-
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
29
|
-
}, [autoFocus]);
|
|
30
|
-
const hasButton = Boolean(onButtonClick || buttonLabel || buttonIcon);
|
|
31
|
-
const hasTrailingLabel = Boolean(trailingLabel);
|
|
32
|
-
const hasValue = Boolean(inputProps.value);
|
|
33
|
-
const hasVisibleClear = Boolean(onClear && hasValue);
|
|
34
|
-
const hasEndAdornment = Boolean(endAdornment);
|
|
35
|
-
const reservesInlineClearSlot = Boolean(onClear);
|
|
36
|
-
const hasInlineClear = Boolean(hasVisibleClear && hasEndAdornment);
|
|
37
|
-
const rootStyle = {
|
|
38
|
-
...(style !== null && style !== void 0 ? style : {}),
|
|
39
|
-
...(minWidth ? { ['--input-min-width']: minWidth } : null),
|
|
40
|
-
...(width ? { ['--input-width']: width } : null),
|
|
41
|
-
...(maxWidth ? { ['--input-max-width']: maxWidth } : null),
|
|
42
|
-
};
|
|
43
|
-
const { triggerProps } = useTooltipTrigger({
|
|
44
|
-
content: tooltip,
|
|
45
|
-
placement: tooltipPlacement,
|
|
46
|
-
offset: 8,
|
|
47
|
-
delayOpenMs: 0,
|
|
48
|
-
focusOpenMode: tooltipOpenOnFocus ? 'any' : 'focus-visible',
|
|
49
|
-
closeOnPointerDown: false,
|
|
50
|
-
});
|
|
51
|
-
const trailingButtonVariant = variant === 'outlined' || variant === 'standalone' ? 'outlined' : 'default';
|
|
52
|
-
return (_jsx(InputContainer, { label: label, labelAction: inputProps.labelAction, htmlFor: inputId, fullWidth: fullWidth, error: error, helpText: helpText, orientation: orientation, labelWidth: labelWidth, required: required, modified: modified, children: _jsxs("div", { style: rootStyle, className: [
|
|
53
|
-
styles.container,
|
|
54
|
-
fullWidth ? styles.fullWidth : '',
|
|
55
|
-
onClear ? styles.withClear : '',
|
|
56
|
-
hasInlineClear ? styles.withInlineClear : '',
|
|
57
|
-
hasButton ? styles.withButton : '',
|
|
58
|
-
hasTrailingLabel ? styles.withTrailingLabel : '',
|
|
59
|
-
className !== null && className !== void 0 ? className : '',
|
|
60
|
-
]
|
|
61
|
-
.filter(Boolean)
|
|
62
|
-
.join(' '), children: [_jsxs("div", { className: [
|
|
63
|
-
styles.field,
|
|
64
|
-
styles[variant],
|
|
65
|
-
icon ? styles.fieldWithIcon : '',
|
|
66
|
-
inputSize ? styles[inputSize] : '',
|
|
67
|
-
modified ? styles.modified : '',
|
|
68
|
-
fieldClassName !== null && fieldClassName !== void 0 ? fieldClassName : '',
|
|
69
|
-
]
|
|
70
|
-
.filter(Boolean)
|
|
71
|
-
.join(' '), "data-forminput": "field", "data-modified": modified ? 'true' : undefined, "aria-disabled": inputProps.disabled ? 'true' : undefined, ...(tooltip ? triggerProps : {}), children: [icon && (_jsx("span", { className: styles.icon, "data-input-role": "icon", children: icon })), startAdornment && (_jsx("span", { className: styles.startAdornment, "data-input-role": "start-adornment", children: startAdornment })), _jsx("input", { ...inputProps, id: inputId, ref: mergeRefs(inputRef, ref), className: [styles.input, inputSize ? styles[inputSize] : '', inputClassName !== null && inputClassName !== void 0 ? inputClassName : '']
|
|
72
|
-
.filter(Boolean)
|
|
73
|
-
.join(' ') }), (reservesInlineClearSlot || hasEndAdornment) && (_jsxs("span", { className: styles.endAdornment, "data-input-role": "end-adornment", children: [reservesInlineClearSlot ? (_jsx("span", { className: styles.clearSlot, "aria-hidden": hasVisibleClear ? undefined : 'true', children: hasVisibleClear && onClear ? _jsx(ClearButton, { onClick: onClear }) : null })) : null, endAdornment] })), hasVisibleClear && !hasEndAdornment && onClear ? (_jsx(ClearButton, { onClick: onClear, absolute: true })) : null] }), hasTrailingLabel && (_jsx("span", { className: [styles.trailingLabel, inputSize ? styles[inputSize] : '']
|
|
74
|
-
.filter(Boolean)
|
|
75
|
-
.join(' '), children: trailingLabel })), hasButton && (_jsxs(Button, { onClick: onButtonClick, disabled: buttonDisabled, className: styles.trailingButton, type: "button", variant: trailingButtonVariant, size: inputSize, children: [buttonIcon !== null && buttonIcon !== void 0 ? buttonIcon : null, buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel : null] }))] }) }));
|
|
76
|
-
});
|
|
77
|
-
Input.displayName = 'Input';
|