@dbcdk/react-components 0.0.103 → 0.0.104
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.cjs +87 -0
- package/dist/assets/logo.js +85 -0
- package/dist/client.cjs +587 -0
- package/dist/client.d.ts +83 -0
- package/dist/client.js +84 -0
- package/dist/components/accordion/Accordion.cjs +103 -0
- package/dist/components/accordion/Accordion.js +97 -0
- package/dist/components/accordion/Accordion.module.css +41 -0
- package/dist/components/accordion/components/AccordionRow.cjs +115 -0
- package/dist/components/accordion/components/AccordionRow.js +109 -0
- package/dist/components/accordion/components/AccordionRow.module.css +99 -0
- package/dist/components/alert/Alert.cjs +52 -0
- package/dist/components/alert/Alert.d.ts +2 -1
- package/dist/components/alert/Alert.js +46 -0
- package/dist/components/alert/Alert.module.css +97 -0
- package/dist/components/app-header/AppHeader.cjs +14 -0
- package/dist/components/app-header/AppHeader.js +8 -0
- package/dist/components/app-header/AppHeader.module.css +74 -0
- package/dist/components/attribute-chip/AttributeChip.cjs +22 -0
- package/dist/components/attribute-chip/AttributeChip.js +16 -0
- package/dist/components/attribute-chip/AttributeChip.module.css +65 -0
- package/dist/components/avatar/Avatar.cjs +111 -0
- package/dist/components/avatar/Avatar.js +86 -0
- package/dist/components/avatar/Avatar.module.css +91 -0
- package/dist/components/breadcrumbs/Breadcrumbs.cjs +24 -0
- package/dist/components/breadcrumbs/Breadcrumbs.js +18 -0
- package/dist/components/breadcrumbs/Breadcrumbs.module.css +80 -0
- package/dist/components/button/Button.cjs +149 -0
- package/dist/components/button/Button.js +124 -0
- package/dist/components/button/Button.module.css +260 -0
- package/dist/components/button-select/ButtonSelect.cjs +35 -0
- package/dist/components/button-select/ButtonSelect.js +29 -0
- package/dist/components/button-select/ButtonSelect.module.css +40 -0
- package/dist/components/card/Card.cjs +112 -0
- package/dist/components/card/Card.d.ts +2 -1
- package/dist/components/card/Card.js +106 -0
- package/dist/components/card/Card.module.css +187 -0
- package/dist/components/card/components/CardMeta.cjs +62 -0
- package/dist/components/card/components/CardMeta.js +55 -0
- package/dist/components/card/components/CardMeta.module.css +55 -0
- package/dist/components/card-container/CardContainer.cjs +34 -0
- package/dist/components/card-container/CardContainer.js +28 -0
- package/dist/components/card-container/CardContainer.module.css +63 -0
- package/dist/components/chip/Chip.cjs +65 -0
- package/dist/components/chip/Chip.js +59 -0
- package/dist/components/chip/Chip.module.css +236 -0
- package/dist/components/circle/Circle.cjs +33 -0
- package/dist/components/circle/Circle.js +27 -0
- package/dist/components/circle/Circle.module.css +128 -0
- package/dist/components/clear-button/ClearButton.cjs +33 -0
- package/dist/components/clear-button/ClearButton.d.ts +2 -1
- package/dist/components/clear-button/ClearButton.js +27 -0
- package/dist/components/clear-button/ClearButton.module.css +26 -0
- package/dist/components/code-block/CodeBlock.cjs +97 -0
- package/dist/components/code-block/CodeBlock.js +91 -0
- package/dist/components/code-block/CodeBlock.module.css +124 -0
- package/dist/components/copy-button/CopyButton.cjs +139 -0
- package/dist/components/copy-button/CopyButton.js +133 -0
- package/dist/components/copy-button/CopyButton.module.css +22 -0
- package/dist/components/datetime-picker/DateTimePicker.cjs +559 -0
- package/dist/components/datetime-picker/DateTimePicker.js +553 -0
- package/dist/components/datetime-picker/DateTimePicker.module.css +155 -0
- package/dist/components/datetime-picker/dateTimeHelpers.cjs +179 -0
- package/dist/components/datetime-picker/dateTimeHelpers.js +160 -0
- package/dist/components/divider/Divider.cjs +22 -0
- package/dist/components/divider/Divider.js +20 -0
- package/dist/components/filter-field/FilterField.cjs +296 -0
- package/dist/components/filter-field/FilterField.js +289 -0
- package/dist/components/filter-field/FilterField.module.css +379 -0
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.cjs +115 -0
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.js +108 -0
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.module.css +59 -0
- package/dist/components/forms/checkbox/Checkbox.cjs +88 -0
- package/dist/components/forms/checkbox/Checkbox.js +82 -0
- package/dist/components/forms/checkbox/Checkbox.module.css +104 -0
- package/dist/components/forms/checkbox-group/CheckboxGroup.cjs +121 -0
- package/dist/components/forms/checkbox-group/CheckboxGroup.js +115 -0
- package/dist/components/forms/checkbox-group/CheckboxGroup.module.css +115 -0
- package/dist/components/forms/form-select/FormSelect.cjs +191 -0
- package/dist/components/forms/form-select/FormSelect.js +166 -0
- package/dist/components/forms/form-select/FormSelect.module.css +236 -0
- package/dist/components/forms/input/Input.cjs +188 -0
- package/dist/components/forms/input/Input.d.ts +1 -0
- package/dist/components/forms/input/Input.js +182 -0
- package/dist/components/forms/input/Input.module.css +468 -0
- package/dist/components/forms/input-container/InputContainer.cjs +72 -0
- package/dist/components/forms/input-container/InputContainer.js +66 -0
- package/dist/components/forms/input-container/InputContainer.module.css +59 -0
- package/dist/components/forms/multi-select/MultiSelect.cjs +227 -0
- package/dist/components/forms/multi-select/MultiSelect.js +225 -0
- package/dist/components/forms/radio-buttons/RadioButton.cjs +91 -0
- package/dist/components/forms/radio-buttons/RadioButton.js +85 -0
- package/dist/components/forms/radio-buttons/RadioButtonGroup.cjs +74 -0
- package/dist/components/forms/radio-buttons/RadioButtonGroup.js +72 -0
- package/dist/components/forms/radio-buttons/RadioButtons.module.css +118 -0
- package/dist/components/forms/select/Select.cjs +286 -0
- package/dist/components/forms/select/Select.js +280 -0
- package/dist/components/forms/select/Select.module.css +32 -0
- package/dist/components/forms/text-area/Textarea.cjs +116 -0
- package/dist/components/forms/text-area/Textarea.js +110 -0
- package/dist/components/forms/text-area/Textarea.module.css +70 -0
- package/dist/components/forms/typeahead/Typeahead.cjs +792 -0
- package/dist/components/forms/typeahead/Typeahead.js +768 -0
- package/dist/components/forms/typeahead/Typeahead.module.css +38 -0
- package/dist/components/grid/Grid.cjs +45 -0
- package/dist/components/grid/Grid.js +38 -0
- package/dist/components/grid/Grid.module.css +35 -0
- package/dist/components/headline/CollapsibleHeadline.cjs +80 -0
- package/dist/components/headline/CollapsibleHeadline.js +74 -0
- package/dist/components/headline/Headline.cjs +59 -0
- package/dist/components/headline/Headline.js +53 -0
- package/dist/components/headline/Headline.module.css +185 -0
- package/dist/components/hyperlink/Hyperlink.cjs +107 -0
- package/dist/components/hyperlink/Hyperlink.js +82 -0
- package/dist/components/hyperlink/Hyperlink.module.css +121 -0
- package/dist/components/icon/Icon.cjs +27 -0
- package/dist/components/icon/Icon.js +20 -0
- package/dist/components/icon/Icon.module.css +36 -0
- package/dist/components/inline-status/InlineStatus.cjs +39 -0
- package/dist/components/inline-status/InlineStatus.js +33 -0
- package/dist/components/inline-status/InlineStatus.module.css +92 -0
- package/dist/components/interval-select/IntervalSelect.cjs +203 -0
- package/dist/components/interval-select/IntervalSelect.js +201 -0
- package/dist/components/json-viewer/HighlightedText.cjs +13 -0
- package/dist/components/json-viewer/HighlightedText.js +11 -0
- package/dist/components/json-viewer/JsonNode.cjs +124 -0
- package/dist/components/json-viewer/JsonNode.js +118 -0
- package/dist/components/json-viewer/JsonViewer.cjs +164 -0
- package/dist/components/json-viewer/JsonViewer.js +158 -0
- package/dist/components/json-viewer/JsonViewer.module.css +346 -0
- package/dist/components/json-viewer/types.cjs +2 -0
- package/dist/components/json-viewer/types.js +1 -0
- package/dist/components/json-viewer/useClipboardStatus.cjs +15 -0
- package/dist/components/json-viewer/useClipboardStatus.js +13 -0
- package/dist/components/json-viewer/utils.cjs +126 -0
- package/dist/components/json-viewer/utils.js +111 -0
- package/dist/components/media-card/MediaCard.cjs +60 -0
- package/dist/components/media-card/MediaCard.d.ts +19 -0
- package/dist/components/media-card/MediaCard.js +54 -0
- package/dist/components/media-card/MediaCard.module.css +92 -0
- package/dist/components/menu/Menu.cjs +287 -0
- package/dist/components/menu/Menu.js +262 -0
- package/dist/components/menu/Menu.module.css +220 -0
- package/dist/components/meta-bar/MetaBar.cjs +28 -0
- package/dist/components/meta-bar/MetaBar.js +22 -0
- package/dist/components/meta-bar/MetaBar.module.css +27 -0
- package/dist/components/nav-bar/NavBar.cjs +95 -0
- package/dist/components/nav-bar/NavBar.d.ts +1 -1
- package/dist/components/nav-bar/NavBar.js +89 -0
- package/dist/components/nav-bar/NavBar.module.css +225 -0
- package/dist/components/overlay/fade-overlay/FadeOverlay.cjs +30 -0
- package/dist/components/overlay/fade-overlay/FadeOverlay.js +24 -0
- package/dist/components/overlay/fade-overlay/FadeOverlay.module.css +54 -0
- package/dist/components/overlay/modal/Modal.cjs +189 -0
- package/dist/components/overlay/modal/Modal.d.ts +2 -1
- package/dist/components/overlay/modal/Modal.js +183 -0
- package/dist/components/overlay/modal/Modal.module.css +112 -0
- package/dist/components/overlay/modal/provider/ModalProvider.cjs +98 -0
- package/dist/components/overlay/modal/provider/ModalProvider.js +95 -0
- package/dist/components/overlay/side-panel/SidePanel.cjs +173 -0
- package/dist/components/overlay/side-panel/SidePanel.js +167 -0
- package/dist/components/overlay/side-panel/SidePanel.module.css +177 -0
- package/dist/components/overlay/side-panel/useSidePanel.cjs +16 -0
- package/dist/components/overlay/side-panel/useSidePanel.js +14 -0
- package/dist/components/overlay/tooltip/Tooltip.cjs +34 -0
- package/dist/components/overlay/tooltip/Tooltip.js +32 -0
- package/dist/components/overlay/tooltip/Tooltip.module.css +104 -0
- package/dist/components/overlay/tooltip/TooltipProvider.cjs +238 -0
- package/dist/components/overlay/tooltip/TooltipProvider.js +231 -0
- package/dist/components/overlay/tooltip/useTooltipTrigger.cjs +117 -0
- package/dist/components/overlay/tooltip/useTooltipTrigger.js +115 -0
- package/dist/components/page/Page.cjs +63 -0
- package/dist/components/page/Page.js +57 -0
- package/dist/components/page/Page.module.css +95 -0
- package/dist/components/page-layout/PageLayout.cjs +97 -0
- package/dist/components/page-layout/PageLayout.d.ts +0 -5
- package/dist/components/page-layout/PageLayout.js +91 -0
- package/dist/components/page-layout/PageLayout.module.css +236 -0
- package/dist/components/page-layout/components/footer/Footer.cjs +53 -0
- package/dist/components/page-layout/components/footer/Footer.js +47 -0
- package/dist/components/page-layout/components/footer/Footer.module.css +89 -0
- package/dist/components/pagination/Pagination.cjs +160 -0
- package/dist/components/pagination/Pagination.js +154 -0
- package/dist/components/pagination/Pagination.module.css +25 -0
- package/dist/components/panel/Panel.cjs +38 -0
- package/dist/components/panel/Panel.js +32 -0
- package/dist/components/panel/Panel.module.css +30 -0
- package/dist/components/popover/Popover.cjs +331 -0
- package/dist/components/popover/Popover.js +307 -0
- package/dist/components/popover/Popover.module.css +52 -0
- package/dist/components/search-box/SearchBox.cjs +274 -0
- package/dist/components/search-box/SearchBox.js +268 -0
- package/dist/components/search-box/SearchBox.module.css +27 -0
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.cjs +127 -0
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.js +121 -0
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.module.css +174 -0
- package/dist/components/sidebar/Sidebar.cjs +39 -0
- package/dist/components/sidebar/Sidebar.js +37 -0
- package/dist/components/sidebar/components/SidebarItem.cjs +29 -0
- package/dist/components/sidebar/components/SidebarItem.js +27 -0
- package/dist/components/sidebar/components/SidebarItem.module.css +0 -0
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.cjs +133 -0
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.js +127 -0
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.module.css +29 -0
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.cjs +214 -0
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.js +207 -0
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.module.css +260 -0
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.cjs +54 -0
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.js +47 -0
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.module.css +106 -0
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.cjs +61 -0
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.js +55 -0
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.module.css +20 -0
- package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.cjs +97 -0
- package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.js +91 -0
- package/dist/components/sidebar/providers/SidebarProvider.cjs +223 -0
- package/dist/components/sidebar/providers/SidebarProvider.js +220 -0
- package/dist/components/skeleton-loader/SkeletonLoader.cjs +442 -0
- package/dist/components/skeleton-loader/SkeletonLoader.js +440 -0
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.cjs +42 -0
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.js +36 -0
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.module.css +51 -0
- package/dist/components/split-button/SplitButton.cjs +46 -0
- package/dist/components/split-button/SplitButton.js +40 -0
- package/dist/components/split-button/SplitButton.module.css +32 -0
- package/dist/components/split-pane/SplitPane.cjs +177 -0
- package/dist/components/split-pane/SplitPane.js +168 -0
- package/dist/components/split-pane/SplitPane.module.css +111 -0
- package/dist/components/split-pane/provider/SplitPaneContext.cjs +129 -0
- package/dist/components/split-pane/provider/SplitPaneContext.js +121 -0
- package/dist/components/stack/Stack.cjs +47 -0
- package/dist/components/stack/Stack.d.ts +1 -1
- package/dist/components/stack/Stack.js +41 -0
- package/dist/components/stack/Stack.module.css +61 -0
- package/dist/components/state-page/StatePage.cjs +48 -0
- package/dist/components/state-page/StatePage.js +42 -0
- package/dist/components/state-page/StatePage.module.css +9 -0
- package/dist/components/state-page/empty.cjs +664 -0
- package/dist/components/state-page/empty.js +662 -0
- package/dist/components/state-page/error.cjs +310 -0
- package/dist/components/state-page/error.js +308 -0
- package/dist/components/state-page/notFound.cjs +243 -0
- package/dist/components/state-page/notFound.js +241 -0
- package/dist/components/sticky-footer-layout/StickyFooterLayout.cjs +98 -0
- package/dist/components/sticky-footer-layout/StickyFooterLayout.js +96 -0
- package/dist/components/table/Table.cjs +216 -0
- package/dist/components/table/Table.js +210 -0
- package/dist/components/table/Table.module.css +534 -0
- package/dist/components/table/Table.types.cjs +2 -0
- package/dist/components/table/Table.types.js +1 -0
- package/dist/components/table/TanstackTable.cjs +172 -0
- package/dist/components/table/TanstackTable.js +147 -0
- package/dist/components/table/components/TableBody.cjs +50 -0
- package/dist/components/table/components/TableBody.js +44 -0
- package/dist/components/table/components/TableHeader.cjs +56 -0
- package/dist/components/table/components/TableHeader.js +50 -0
- package/dist/components/table/components/TableHeaderCell.cjs +69 -0
- package/dist/components/table/components/TableHeaderCell.js +63 -0
- package/dist/components/table/components/TableLoadingBody.cjs +35 -0
- package/dist/components/table/components/TableLoadingBody.js +29 -0
- package/dist/components/table/components/TablePagination.cjs +2 -0
- package/dist/components/table/components/TablePagination.js +1 -0
- package/dist/components/table/components/TableRow.cjs +151 -0
- package/dist/components/table/components/TableRow.js +145 -0
- package/dist/components/table/components/TableSelectionCell.cjs +41 -0
- package/dist/components/table/components/TableSelectionCell.js +35 -0
- package/dist/components/table/components/column-resizer/ColumnResizer.cjs +25 -0
- package/dist/components/table/components/column-resizer/ColumnResizer.js +19 -0
- package/dist/components/table/components/column-resizer/ColumnResizer.module.css +22 -0
- package/dist/components/table/components/empty-state/EmptyState.cjs +33 -0
- package/dist/components/table/components/empty-state/EmptyState.js +31 -0
- package/dist/components/table/components/empty-state/EmptyState.module.css +4 -0
- package/dist/components/table/components/table-settings/TableSettings.cjs +139 -0
- package/dist/components/table/components/table-settings/TableSettings.js +137 -0
- package/dist/components/table/hooks/useTableRowInteractions.cjs +46 -0
- package/dist/components/table/hooks/useTableRowInteractions.js +44 -0
- package/dist/components/table/table.classes.cjs +49 -0
- package/dist/components/table/table.classes.js +40 -0
- package/dist/components/table/table.utils.cjs +57 -0
- package/dist/components/table/table.utils.js +45 -0
- package/dist/components/table/tanstackTable.utils.cjs +166 -0
- package/dist/components/table/tanstackTable.utils.js +159 -0
- package/dist/components/tabs/Tabs.cjs +172 -0
- package/dist/components/tabs/Tabs.js +166 -0
- package/dist/components/tabs/Tabs.module.css +261 -0
- package/dist/components/theme-button/ThemeButton.cjs +78 -0
- package/dist/components/theme-button/ThemeButton.js +75 -0
- package/dist/components/toast/Toast.cjs +68 -0
- package/dist/components/toast/Toast.js +62 -0
- package/dist/components/toast/Toast.module.css +161 -0
- package/dist/components/toast/provider/ToastProvider.cjs +105 -0
- package/dist/components/toast/provider/ToastProvider.js +97 -0
- package/dist/components/user-display/UserDisplay.cjs +22 -0
- package/dist/components/user-display/UserDisplay.js +16 -0
- package/dist/components/user-display/UserDisplay.module.css +25 -0
- package/dist/constants/chart-colors.cjs +10 -0
- package/dist/constants/chart-colors.js +8 -0
- package/dist/constants/chart-colors.types.cjs +2 -0
- package/dist/constants/chart-colors.types.js +1 -0
- package/dist/constants/severity.cjs +30 -0
- package/dist/constants/severity.js +26 -0
- package/dist/constants/severity.types.cjs +2 -0
- package/dist/constants/severity.types.js +1 -0
- package/dist/constants/sizes.cjs +11 -0
- package/dist/constants/sizes.js +9 -0
- package/dist/hooks/useDeviceSize.cjs +35 -0
- package/dist/hooks/useDeviceSize.js +33 -0
- package/dist/hooks/useListNavigation.cjs +237 -0
- package/dist/hooks/useListNavigation.js +235 -0
- package/dist/hooks/usePagination.cjs +144 -0
- package/dist/hooks/usePagination.js +142 -0
- package/dist/hooks/useSorting.cjs +119 -0
- package/dist/hooks/useSorting.js +117 -0
- package/dist/hooks/useTableData.cjs +53 -0
- package/dist/hooks/useTableData.js +51 -0
- package/dist/hooks/useTableSelection.cjs +172 -0
- package/dist/hooks/useTableSelection.js +170 -0
- package/dist/hooks/useTableSettings.cjs +90 -0
- package/dist/hooks/useTableSettings.js +87 -0
- package/dist/hooks/useTheme.cjs +64 -0
- package/dist/hooks/useTheme.js +62 -0
- package/dist/hooks/useTimeDuration.cjs +72 -0
- package/dist/hooks/useTimeDuration.js +70 -0
- package/dist/hooks/useViewportFill.cjs +82 -0
- package/dist/hooks/useViewportFill.js +80 -0
- package/dist/index.cjs +161 -12908
- package/dist/index.css +67 -7357
- package/dist/index.d.ts +0 -58
- package/dist/index.js +24 -12809
- package/dist/styles/animation.cjs +9 -0
- package/dist/styles/animation.js +7 -0
- package/dist/styles/themes/dbc/colors.css +5 -0
- package/dist/styles/themes/types.cjs +2 -0
- package/dist/styles/themes/types.js +1 -0
- package/dist/tanstack.cjs +18 -2717
- package/dist/tanstack.js +3 -2701
- package/dist/types/a11y-props.types.cjs +2 -0
- package/dist/types/a11y-props.types.js +1 -0
- package/dist/types/assets.d.cjs +2 -0
- package/dist/types/assets.d.js +1 -0
- package/dist/types/css.d.cjs +2 -0
- package/dist/types/css.d.js +1 -0
- package/dist/types/sizes.types.cjs +2 -0
- package/dist/types/sizes.types.js +1 -0
- package/dist/utils/arrays/nested-filtering.cjs +40 -0
- package/dist/utils/arrays/nested-filtering.js +38 -0
- package/dist/utils/date/formatDate.cjs +35 -0
- package/dist/utils/date/formatDate.js +33 -0
- package/dist/utils/localStorage.utils.cjs +53 -0
- package/dist/utils/localStorage.utils.js +49 -0
- package/dist/utils/text/get-highlighted-segments.cjs +49 -0
- package/dist/utils/text/get-highlighted-segments.js +47 -0
- package/package.json +8 -3
- package/dist/tanstack.css +0 -1385
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import styles from './CheckboxGroup.module.css';
|
|
5
|
+
import { Checkbox } from '../checkbox/Checkbox';
|
|
6
|
+
|
|
7
|
+
function CheckboxGroup({
|
|
8
|
+
label,
|
|
9
|
+
options,
|
|
10
|
+
selectedValues,
|
|
11
|
+
onChange,
|
|
12
|
+
onToggle,
|
|
13
|
+
variant = "outlined",
|
|
14
|
+
size = "md",
|
|
15
|
+
wrap = false,
|
|
16
|
+
fullWidth = false,
|
|
17
|
+
disabled = false,
|
|
18
|
+
contained = true,
|
|
19
|
+
actionLabels = { clear: "Ryd", all: "Alle" },
|
|
20
|
+
onActionClick,
|
|
21
|
+
"data-cy": dataCy
|
|
22
|
+
}) {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
const selectedSet = useMemo(() => new Set(selectedValues), [selectedValues]);
|
|
25
|
+
const enabledValues = useMemo(
|
|
26
|
+
() => options.filter((o) => !(disabled || o.disabled)).map((o) => o.value),
|
|
27
|
+
[options, disabled]
|
|
28
|
+
);
|
|
29
|
+
const allEnabledSelected = enabledValues.length > 0 && enabledValues.every((v) => selectedSet.has(v));
|
|
30
|
+
const toggleValue = (value) => {
|
|
31
|
+
if (disabled) return;
|
|
32
|
+
const next = new Set(selectedSet);
|
|
33
|
+
const willSelect = !next.has(value);
|
|
34
|
+
if (willSelect) next.add(value);
|
|
35
|
+
else next.delete(value);
|
|
36
|
+
onChange(Array.from(next));
|
|
37
|
+
onToggle == null ? void 0 : onToggle(value, willSelect);
|
|
38
|
+
};
|
|
39
|
+
const selectAll = () => {
|
|
40
|
+
if (disabled) return;
|
|
41
|
+
if (enabledValues.length === 0) return;
|
|
42
|
+
onChange([...enabledValues]);
|
|
43
|
+
onToggle == null ? void 0 : onToggle("__select_all__", true);
|
|
44
|
+
};
|
|
45
|
+
const deselectAll = () => {
|
|
46
|
+
if (disabled) return;
|
|
47
|
+
onChange([]);
|
|
48
|
+
onToggle == null ? void 0 : onToggle("__deselect_all__", false);
|
|
49
|
+
};
|
|
50
|
+
const handleAction = () => {
|
|
51
|
+
if (disabled) return;
|
|
52
|
+
if (enabledValues.length === 0) return;
|
|
53
|
+
if (allEnabledSelected) {
|
|
54
|
+
deselectAll();
|
|
55
|
+
onActionClick == null ? void 0 : onActionClick("clear");
|
|
56
|
+
} else {
|
|
57
|
+
selectAll();
|
|
58
|
+
onActionClick == null ? void 0 : onActionClick("all");
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const wrapperClassName = [
|
|
62
|
+
styles.wrapper,
|
|
63
|
+
fullWidth ? styles.fullWidth : "",
|
|
64
|
+
contained ? styles.contained : styles.plain,
|
|
65
|
+
styles[size]
|
|
66
|
+
].filter(Boolean).join(" ");
|
|
67
|
+
const itemsClassName = [styles.items, wrap ? styles.wrap : styles.noWrap].join(" ");
|
|
68
|
+
const allText = (_a = actionLabels.all) != null ? _a : "Alle";
|
|
69
|
+
const clearText = (_b = actionLabels.clear) != null ? _b : "Ryd";
|
|
70
|
+
const actionMinWidth = `${Math.max(allText.length, clearText.length)}ch`;
|
|
71
|
+
return /* @__PURE__ */ jsxs(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
className: wrapperClassName,
|
|
75
|
+
"data-cy": dataCy,
|
|
76
|
+
style: { ["--checkboxgroup-action-min-width"]: actionMinWidth },
|
|
77
|
+
children: [
|
|
78
|
+
label && /* @__PURE__ */ jsx("span", { className: styles.groupLabel, children: label }),
|
|
79
|
+
/* @__PURE__ */ jsx("div", { className: itemsClassName, role: "group", "aria-label": label, children: options.map((opt) => {
|
|
80
|
+
const isChecked = selectedSet.has(opt.value);
|
|
81
|
+
const isDisabled = disabled || !!opt.disabled;
|
|
82
|
+
return /* @__PURE__ */ jsx(
|
|
83
|
+
Checkbox,
|
|
84
|
+
{
|
|
85
|
+
label: opt.label,
|
|
86
|
+
checked: isChecked,
|
|
87
|
+
disabled: isDisabled,
|
|
88
|
+
variant,
|
|
89
|
+
size: "sm",
|
|
90
|
+
onChange: () => {
|
|
91
|
+
if (isDisabled) return;
|
|
92
|
+
toggleValue(opt.value);
|
|
93
|
+
},
|
|
94
|
+
noContainer: true
|
|
95
|
+
},
|
|
96
|
+
opt.value
|
|
97
|
+
);
|
|
98
|
+
}) }),
|
|
99
|
+
/* @__PURE__ */ jsx(
|
|
100
|
+
"button",
|
|
101
|
+
{
|
|
102
|
+
type: "button",
|
|
103
|
+
className: styles.actionButton,
|
|
104
|
+
onClick: handleAction,
|
|
105
|
+
disabled: disabled || enabledValues.length === 0,
|
|
106
|
+
"aria-disabled": disabled || enabledValues.length === 0,
|
|
107
|
+
children: /* @__PURE__ */ jsx("span", { className: styles.actionText, "data-mode": allEnabledSelected ? "clear" : "all", children: allEnabledSelected ? clearText : allText })
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { CheckboxGroup };
|
|
@@ -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-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
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var lucideReact = require('lucide-react');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var useTooltipTrigger = require('../../../components/overlay/tooltip/useTooltipTrigger');
|
|
8
|
+
var styles = require('./FormSelect.module.css');
|
|
9
|
+
var InputContainer = require('../input-container/InputContainer');
|
|
10
|
+
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
|
|
13
|
+
function _interopNamespace(e) {
|
|
14
|
+
if (e && e.__esModule) return e;
|
|
15
|
+
var n = Object.create(null);
|
|
16
|
+
if (e) {
|
|
17
|
+
Object.keys(e).forEach(function (k) {
|
|
18
|
+
if (k !== 'default') {
|
|
19
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
20
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return e[k]; }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
n.default = e;
|
|
28
|
+
return Object.freeze(n);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
32
|
+
var styles__default = /*#__PURE__*/_interopDefault(styles);
|
|
33
|
+
|
|
34
|
+
function isEqualValue(a, b, datakey) {
|
|
35
|
+
if (a === b) return true;
|
|
36
|
+
if (!a || !b) return false;
|
|
37
|
+
if (typeof a === "object" && typeof b === "object" && datakey) {
|
|
38
|
+
return a[datakey] === b[datakey];
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
function serializeValue(value, datakey) {
|
|
43
|
+
if (typeof value === "string" || typeof value === "number") return String(value);
|
|
44
|
+
if (datakey && value && typeof value === "object") {
|
|
45
|
+
const v = value[datakey];
|
|
46
|
+
return v == null ? "" : String(v);
|
|
47
|
+
}
|
|
48
|
+
throw new Error(
|
|
49
|
+
"FormSelect: option value is an object but no `datakey` was provided. Native select requires string/number values."
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
function findSelectedOption(options, selectedValue, datakey) {
|
|
53
|
+
return options.find((o) => isEqualValue(o.value, selectedValue, datakey));
|
|
54
|
+
}
|
|
55
|
+
function FormSelect({
|
|
56
|
+
// InputContainer props
|
|
57
|
+
label,
|
|
58
|
+
error,
|
|
59
|
+
helpText,
|
|
60
|
+
orientation = "vertical",
|
|
61
|
+
labelWidth = "160px",
|
|
62
|
+
fullWidth = true,
|
|
63
|
+
required,
|
|
64
|
+
tooltip,
|
|
65
|
+
tooltipPlacement = "right",
|
|
66
|
+
modified = false,
|
|
67
|
+
// FormSelect props
|
|
68
|
+
id,
|
|
69
|
+
name,
|
|
70
|
+
options,
|
|
71
|
+
selectedValue,
|
|
72
|
+
onChange,
|
|
73
|
+
placeholder = "V\xE6lg",
|
|
74
|
+
size = "md",
|
|
75
|
+
variant = "outlined",
|
|
76
|
+
onClear,
|
|
77
|
+
datakey,
|
|
78
|
+
dataCy,
|
|
79
|
+
disabled,
|
|
80
|
+
includePlaceholderOption = true,
|
|
81
|
+
allowClearWhenRequired = false
|
|
82
|
+
}) {
|
|
83
|
+
const generatedId = React__namespace.useId();
|
|
84
|
+
const controlId = id != null ? id : `select-${generatedId}`;
|
|
85
|
+
const describedById = `${controlId}-desc`;
|
|
86
|
+
const selected = React__namespace.useMemo(
|
|
87
|
+
() => findSelectedOption(options, selectedValue, datakey),
|
|
88
|
+
[options, selectedValue, datakey]
|
|
89
|
+
);
|
|
90
|
+
const tooltipEnabled = Boolean(tooltip);
|
|
91
|
+
const { triggerProps, id: tooltipId } = useTooltipTrigger.useTooltipTrigger({
|
|
92
|
+
content: tooltipEnabled ? tooltip : null,
|
|
93
|
+
placement: tooltipPlacement,
|
|
94
|
+
offset: 8
|
|
95
|
+
});
|
|
96
|
+
const describedBy = (() => {
|
|
97
|
+
const ids = [];
|
|
98
|
+
if (error || helpText) ids.push(describedById);
|
|
99
|
+
if (tooltipEnabled) ids.push(tooltipId);
|
|
100
|
+
return ids.length ? ids.join(" ") : void 0;
|
|
101
|
+
})();
|
|
102
|
+
const nativeValue = React__namespace.useMemo(() => {
|
|
103
|
+
if (selected && selected.value != null) return serializeValue(selected.value, datakey);
|
|
104
|
+
return "";
|
|
105
|
+
}, [selected, datakey]);
|
|
106
|
+
const canClear = Boolean(onClear) && !disabled && (allowClearWhenRequired || !required);
|
|
107
|
+
const showClear = canClear && Boolean(selected);
|
|
108
|
+
const placeholderDisabled = Boolean(required) && !allowClearWhenRequired;
|
|
109
|
+
const handleNativeChange = (e) => {
|
|
110
|
+
const raw = e.target.value;
|
|
111
|
+
if (raw === "") {
|
|
112
|
+
onClear == null ? void 0 : onClear();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const opt = options.find((o) => serializeValue(o.value, datakey) === raw);
|
|
116
|
+
if (opt) onChange(opt.value);
|
|
117
|
+
};
|
|
118
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
119
|
+
InputContainer.InputContainer,
|
|
120
|
+
{
|
|
121
|
+
label,
|
|
122
|
+
htmlFor: controlId,
|
|
123
|
+
fullWidth,
|
|
124
|
+
error,
|
|
125
|
+
helpText,
|
|
126
|
+
orientation,
|
|
127
|
+
labelWidth,
|
|
128
|
+
required,
|
|
129
|
+
modified,
|
|
130
|
+
children: [
|
|
131
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
132
|
+
"div",
|
|
133
|
+
{
|
|
134
|
+
className: [
|
|
135
|
+
styles__default.default.container,
|
|
136
|
+
fullWidth ? styles__default.default.fullWidth : "",
|
|
137
|
+
canClear ? styles__default.default.withButton : ""
|
|
138
|
+
].filter(Boolean).join(" "),
|
|
139
|
+
children: [
|
|
140
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles__default.default.field, children: [
|
|
141
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
142
|
+
"select",
|
|
143
|
+
{
|
|
144
|
+
...tooltipEnabled ? triggerProps : {},
|
|
145
|
+
id: controlId,
|
|
146
|
+
name,
|
|
147
|
+
className: [styles__default.default.input, styles__default.default[size], styles__default.default[variant]].filter(Boolean).join(" "),
|
|
148
|
+
value: nativeValue,
|
|
149
|
+
onChange: handleNativeChange,
|
|
150
|
+
disabled,
|
|
151
|
+
"aria-invalid": Boolean(error) || void 0,
|
|
152
|
+
"aria-describedby": describedBy,
|
|
153
|
+
"data-cy": dataCy != null ? dataCy : "formselect",
|
|
154
|
+
"data-forminput": true,
|
|
155
|
+
children: [
|
|
156
|
+
includePlaceholderOption && /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: placeholderDisabled, children: placeholder }),
|
|
157
|
+
options.map((opt) => {
|
|
158
|
+
const v = serializeValue(opt.value, datakey);
|
|
159
|
+
return /* @__PURE__ */ jsxRuntime.jsx("option", { value: v, children: opt.label }, v);
|
|
160
|
+
})
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
),
|
|
164
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.chevron, "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { size: 20 }) })
|
|
165
|
+
] }),
|
|
166
|
+
canClear && /* @__PURE__ */ jsxRuntime.jsx(
|
|
167
|
+
"button",
|
|
168
|
+
{
|
|
169
|
+
type: "button",
|
|
170
|
+
className: styles__default.default.trailingButton,
|
|
171
|
+
onClick: (e) => {
|
|
172
|
+
e.preventDefault();
|
|
173
|
+
e.stopPropagation();
|
|
174
|
+
onClear == null ? void 0 : onClear();
|
|
175
|
+
},
|
|
176
|
+
"aria-label": "Ryd valg",
|
|
177
|
+
disabled: !showClear,
|
|
178
|
+
"data-cy": dataCy ? `${dataCy}-clear` : "formselect-clear",
|
|
179
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { size: 18, "aria-hidden": "true" })
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
(error || helpText) && /* @__PURE__ */ jsxRuntime.jsx("span", { id: describedById, style: { display: "none" }, children: error != null ? error : helpText })
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
exports.FormSelect = FormSelect;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } 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
|
+
|
|
9
|
+
function isEqualValue(a, b, datakey) {
|
|
10
|
+
if (a === b) return true;
|
|
11
|
+
if (!a || !b) return false;
|
|
12
|
+
if (typeof a === "object" && typeof b === "object" && datakey) {
|
|
13
|
+
return a[datakey] === b[datakey];
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
function serializeValue(value, datakey) {
|
|
18
|
+
if (typeof value === "string" || typeof value === "number") return String(value);
|
|
19
|
+
if (datakey && value && typeof value === "object") {
|
|
20
|
+
const v = value[datakey];
|
|
21
|
+
return v == null ? "" : String(v);
|
|
22
|
+
}
|
|
23
|
+
throw new Error(
|
|
24
|
+
"FormSelect: option value is an object but no `datakey` was provided. Native select requires string/number values."
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
function findSelectedOption(options, selectedValue, datakey) {
|
|
28
|
+
return options.find((o) => isEqualValue(o.value, selectedValue, datakey));
|
|
29
|
+
}
|
|
30
|
+
function FormSelect({
|
|
31
|
+
// InputContainer props
|
|
32
|
+
label,
|
|
33
|
+
error,
|
|
34
|
+
helpText,
|
|
35
|
+
orientation = "vertical",
|
|
36
|
+
labelWidth = "160px",
|
|
37
|
+
fullWidth = true,
|
|
38
|
+
required,
|
|
39
|
+
tooltip,
|
|
40
|
+
tooltipPlacement = "right",
|
|
41
|
+
modified = false,
|
|
42
|
+
// FormSelect props
|
|
43
|
+
id,
|
|
44
|
+
name,
|
|
45
|
+
options,
|
|
46
|
+
selectedValue,
|
|
47
|
+
onChange,
|
|
48
|
+
placeholder = "V\xE6lg",
|
|
49
|
+
size = "md",
|
|
50
|
+
variant = "outlined",
|
|
51
|
+
onClear,
|
|
52
|
+
datakey,
|
|
53
|
+
dataCy,
|
|
54
|
+
disabled,
|
|
55
|
+
includePlaceholderOption = true,
|
|
56
|
+
allowClearWhenRequired = false
|
|
57
|
+
}) {
|
|
58
|
+
const generatedId = React.useId();
|
|
59
|
+
const controlId = id != null ? id : `select-${generatedId}`;
|
|
60
|
+
const describedById = `${controlId}-desc`;
|
|
61
|
+
const selected = React.useMemo(
|
|
62
|
+
() => findSelectedOption(options, selectedValue, datakey),
|
|
63
|
+
[options, selectedValue, datakey]
|
|
64
|
+
);
|
|
65
|
+
const tooltipEnabled = Boolean(tooltip);
|
|
66
|
+
const { triggerProps, id: tooltipId } = useTooltipTrigger({
|
|
67
|
+
content: tooltipEnabled ? tooltip : null,
|
|
68
|
+
placement: tooltipPlacement,
|
|
69
|
+
offset: 8
|
|
70
|
+
});
|
|
71
|
+
const describedBy = (() => {
|
|
72
|
+
const ids = [];
|
|
73
|
+
if (error || helpText) ids.push(describedById);
|
|
74
|
+
if (tooltipEnabled) ids.push(tooltipId);
|
|
75
|
+
return ids.length ? ids.join(" ") : void 0;
|
|
76
|
+
})();
|
|
77
|
+
const nativeValue = React.useMemo(() => {
|
|
78
|
+
if (selected && selected.value != null) return serializeValue(selected.value, datakey);
|
|
79
|
+
return "";
|
|
80
|
+
}, [selected, datakey]);
|
|
81
|
+
const canClear = Boolean(onClear) && !disabled && (allowClearWhenRequired || !required);
|
|
82
|
+
const showClear = canClear && Boolean(selected);
|
|
83
|
+
const placeholderDisabled = Boolean(required) && !allowClearWhenRequired;
|
|
84
|
+
const handleNativeChange = (e) => {
|
|
85
|
+
const raw = e.target.value;
|
|
86
|
+
if (raw === "") {
|
|
87
|
+
onClear == null ? void 0 : onClear();
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const opt = options.find((o) => serializeValue(o.value, datakey) === raw);
|
|
91
|
+
if (opt) onChange(opt.value);
|
|
92
|
+
};
|
|
93
|
+
return /* @__PURE__ */ jsxs(
|
|
94
|
+
InputContainer,
|
|
95
|
+
{
|
|
96
|
+
label,
|
|
97
|
+
htmlFor: controlId,
|
|
98
|
+
fullWidth,
|
|
99
|
+
error,
|
|
100
|
+
helpText,
|
|
101
|
+
orientation,
|
|
102
|
+
labelWidth,
|
|
103
|
+
required,
|
|
104
|
+
modified,
|
|
105
|
+
children: [
|
|
106
|
+
/* @__PURE__ */ jsxs(
|
|
107
|
+
"div",
|
|
108
|
+
{
|
|
109
|
+
className: [
|
|
110
|
+
styles.container,
|
|
111
|
+
fullWidth ? styles.fullWidth : "",
|
|
112
|
+
canClear ? styles.withButton : ""
|
|
113
|
+
].filter(Boolean).join(" "),
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ jsxs("div", { className: styles.field, children: [
|
|
116
|
+
/* @__PURE__ */ jsxs(
|
|
117
|
+
"select",
|
|
118
|
+
{
|
|
119
|
+
...tooltipEnabled ? triggerProps : {},
|
|
120
|
+
id: controlId,
|
|
121
|
+
name,
|
|
122
|
+
className: [styles.input, styles[size], styles[variant]].filter(Boolean).join(" "),
|
|
123
|
+
value: nativeValue,
|
|
124
|
+
onChange: handleNativeChange,
|
|
125
|
+
disabled,
|
|
126
|
+
"aria-invalid": Boolean(error) || void 0,
|
|
127
|
+
"aria-describedby": describedBy,
|
|
128
|
+
"data-cy": dataCy != null ? dataCy : "formselect",
|
|
129
|
+
"data-forminput": true,
|
|
130
|
+
children: [
|
|
131
|
+
includePlaceholderOption && /* @__PURE__ */ jsx("option", { value: "", disabled: placeholderDisabled, children: placeholder }),
|
|
132
|
+
options.map((opt) => {
|
|
133
|
+
const v = serializeValue(opt.value, datakey);
|
|
134
|
+
return /* @__PURE__ */ jsx("option", { value: v, children: opt.label }, v);
|
|
135
|
+
})
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
/* @__PURE__ */ jsx("span", { className: styles.chevron, "aria-hidden": "true", children: /* @__PURE__ */ jsx(ChevronDown, { size: 20 }) })
|
|
140
|
+
] }),
|
|
141
|
+
canClear && /* @__PURE__ */ jsx(
|
|
142
|
+
"button",
|
|
143
|
+
{
|
|
144
|
+
type: "button",
|
|
145
|
+
className: styles.trailingButton,
|
|
146
|
+
onClick: (e) => {
|
|
147
|
+
e.preventDefault();
|
|
148
|
+
e.stopPropagation();
|
|
149
|
+
onClear == null ? void 0 : onClear();
|
|
150
|
+
},
|
|
151
|
+
"aria-label": "Ryd valg",
|
|
152
|
+
disabled: !showClear,
|
|
153
|
+
"data-cy": dataCy ? `${dataCy}-clear` : "formselect-clear",
|
|
154
|
+
children: /* @__PURE__ */ jsx(X, { size: 18, "aria-hidden": "true" })
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
(error || helpText) && /* @__PURE__ */ jsx("span", { id: describedById, style: { display: "none" }, children: error != null ? error : helpText })
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export { FormSelect };
|