@dbcdk/react-components 0.0.5 → 0.0.7
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 +2 -1
- package/dist/components/__stories__/story-components/Colors.js +87 -142
- package/dist/components/__stories__/story-components/Spacing.d.ts +1 -0
- package/dist/components/__stories__/story-components/Spacing.js +58 -166
- package/dist/components/app-header/AppHeader.d.ts +4 -3
- package/dist/components/app-header/AppHeader.js +3 -6
- package/dist/components/attribute-chip/AttributeChip.d.ts +1 -0
- package/dist/components/attribute-chip/AttributeChip.js +3 -14
- package/dist/components/avatar/Avatar.d.ts +2 -2
- package/dist/components/avatar/Avatar.js +37 -71
- package/dist/components/breadcrumbs/Breadcrumbs.d.ts +4 -4
- package/dist/components/breadcrumbs/Breadcrumbs.js +4 -13
- package/dist/components/button/Button.d.ts +3 -2
- package/dist/components/button/Button.js +54 -56
- package/dist/components/button/Button.module.css +1 -1
- package/dist/components/card/Card.d.ts +8 -7
- package/dist/components/card/Card.js +19 -60
- package/dist/components/card-container/CardContainer.d.ts +3 -3
- package/dist/components/card-container/CardContainer.js +4 -16
- package/dist/components/chip/Chip.d.ts +6 -5
- package/dist/components/chip/Chip.js +14 -38
- package/dist/components/chip/Chip.module.css +9 -1
- package/dist/components/circle/Circle.d.ts +3 -2
- package/dist/components/circle/Circle.js +3 -10
- package/dist/components/clear-button/ClearButton.d.ts +2 -1
- package/dist/components/clear-button/ClearButton.js +6 -17
- package/dist/components/code-block/CodeBlock.d.ts +1 -0
- package/dist/components/code-block/CodeBlock.js +4 -10
- package/dist/components/copy-button/CopyButton.d.ts +4 -3
- package/dist/components/copy-button/CopyButton.js +19 -26
- package/dist/components/datetime-picker/DateTimePicker.d.ts +8 -5
- package/dist/components/datetime-picker/DateTimePicker.js +262 -475
- package/dist/components/datetime-picker/dateTimeHelpers.d.ts +13 -0
- package/dist/components/datetime-picker/dateTimeHelpers.js +119 -0
- package/dist/components/filter-field/FilterField.d.ts +5 -2
- package/dist/components/filter-field/FilterField.js +130 -173
- package/dist/components/filter-field/FilterField.module.css +21 -5
- 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 +0 -1
- 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/{input → forms/input}/Input.d.ts +9 -5
- package/dist/components/forms/input/Input.js +70 -0
- package/dist/components/{input → forms/input}/Input.module.css +1 -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.js +18 -43
- package/dist/components/{link/Link.d.ts → hyperlink/Hyperlink.d.ts} +2 -2
- package/dist/components/hyperlink/Hyperlink.js +11 -0
- package/dist/components/{link/Link.module.css → hyperlink/Hyperlink.module.css} +5 -14
- package/dist/components/icon/Icon.d.ts +4 -3
- package/dist/components/icon/Icon.js +11 -17
- package/dist/components/interval-select/IntervalSelect.d.ts +30 -0
- package/dist/components/interval-select/IntervalSelect.js +82 -0
- package/dist/components/menu/Menu.js +25 -67
- package/dist/components/meta-bar/MetaBar.d.ts +4 -4
- package/dist/components/meta-bar/MetaBar.js +7 -20
- package/dist/components/nav-bar/NavBar.d.ts +5 -5
- package/dist/components/nav-bar/NavBar.js +15 -45
- package/dist/components/{modal → overlay/modal}/Modal.d.ts +4 -2
- package/dist/components/overlay/modal/Modal.js +92 -0
- package/dist/components/{modal → overlay/modal}/provider/ModalProvider.d.ts +0 -1
- 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-layout/PageLayout.d.ts +11 -12
- package/dist/components/page-layout/PageLayout.js +35 -71
- package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.js +4 -22
- package/dist/components/pagination/Pagination.d.ts +2 -1
- package/dist/components/pagination/Pagination.js +38 -121
- package/dist/components/panel/Panel.d.ts +4 -3
- package/dist/components/panel/Panel.js +5 -10
- package/dist/components/popover/Popover.d.ts +1 -0
- package/dist/components/popover/Popover.js +116 -141
- package/dist/components/search-box/SearchBox.d.ts +2 -2
- package/dist/components/search-box/SearchBox.js +112 -162
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.d.ts +1 -1
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.js +47 -94
- package/dist/components/sidebar/Sidebar.d.ts +1 -0
- package/dist/components/sidebar/Sidebar.js +5 -7
- package/dist/components/sidebar/components/SidebarItem.js +6 -14
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.d.ts +1 -1
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.js +48 -88
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.d.ts +3 -2
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.js +11 -41
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.d.ts +1 -0
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.js +4 -25
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.js +9 -23
- package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.js +19 -40
- package/dist/components/sidebar/providers/SidebarProvider.d.ts +2 -1
- package/dist/components/sidebar/providers/SidebarProvider.js +182 -165
- package/dist/components/skeleton-loader/SkeletonLoader.js +68 -266
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.js +11 -34
- 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.js +69 -105
- package/dist/components/split-pane/provider/SplitPaneContext.js +77 -71
- package/dist/components/table/Table.d.ts +9 -7
- package/dist/components/table/Table.js +115 -238
- package/dist/components/table/Table.module.css +5 -1
- package/dist/components/table/components/column-resizer/ColumnResizer.js +4 -15
- package/dist/components/table/components/empty-state/EmptyState.d.ts +6 -5
- package/dist/components/table/components/empty-state/EmptyState.js +22 -41
- package/dist/components/table/components/table-settings/TableSettings.d.ts +2 -1
- package/dist/components/table/components/table-settings/TableSettings.js +9 -27
- package/dist/components/table/tanstack.d.ts +1 -1
- package/dist/components/table/tanstack.js +154 -160
- package/dist/components/tabs/Tabs.d.ts +1 -0
- package/dist/components/tabs/Tabs.js +32 -81
- package/dist/components/toast/Toast.d.ts +1 -1
- package/dist/components/toast/Toast.js +4 -37
- package/dist/components/toast/Toast.module.css +1 -0
- package/dist/components/toast/provider/ToastProvider.d.ts +1 -1
- package/dist/components/toast/provider/ToastProvider.js +60 -87
- package/dist/components/user-display/UserDisplay.d.ts +2 -1
- package/dist/components/user-display/UserDisplay.js +4 -20
- 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.js +6 -8
- package/dist/hooks/usePagination.d.ts +1 -1
- package/dist/hooks/usePagination.js +75 -82
- package/dist/hooks/useSorting.js +112 -110
- package/dist/hooks/useTableData.d.ts +1 -1
- package/dist/hooks/useTableData.js +42 -47
- package/dist/hooks/useTableSelection.js +121 -121
- package/dist/hooks/useTableSettings.js +23 -25
- package/dist/hooks/useTheme.d.ts +3 -7
- package/dist/hooks/useTheme.js +52 -47
- package/dist/hooks/useTimeDuration.d.ts +2 -2
- package/dist/hooks/useTimeDuration.js +33 -34
- package/dist/hooks/useViewportFill.d.ts +3 -2
- package/dist/hooks/useViewportFill.js +55 -48
- package/dist/index.d.ts +17 -8
- package/dist/index.js +18 -8
- package/dist/src/styles/styles.css +3 -3
- package/dist/styles/css-helper-classes/flex.css +4 -0
- package/dist/styles/styles.css +3 -3
- package/dist/styles/themes/dbc/dark.css +1 -1
- package/dist/styles/themes/dbc/light.css +2 -1
- 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.js +1 -1
- package/dist/utils/arrays/nested-filtering.js +43 -33
- package/dist/utils/date/formatDate.js +25 -16
- package/package.json +18 -9
- package/dist/assets/logo.cjs +0 -87
- package/dist/components/__stories__/story-components/Colors.cjs +0 -159
- package/dist/components/__stories__/story-components/Spacing.cjs +0 -190
- package/dist/components/app-header/AppHeader.cjs +0 -14
- package/dist/components/attribute-chip/AttributeChip.cjs +0 -22
- package/dist/components/avatar/Avatar.cjs +0 -101
- package/dist/components/breadcrumbs/Breadcrumbs.cjs +0 -22
- package/dist/components/button/Button.cjs +0 -87
- package/dist/components/card/Card.cjs +0 -69
- package/dist/components/card-container/CardContainer.cjs +0 -24
- package/dist/components/checkbox/Checkbox.cjs +0 -42
- package/dist/components/checkbox/Checkbox.d.ts +0 -12
- package/dist/components/checkbox/Checkbox.js +0 -36
- package/dist/components/chip/Chip.cjs +0 -50
- package/dist/components/circle/Circle.cjs +0 -18
- package/dist/components/clear-button/ClearButton.cjs +0 -26
- package/dist/components/code-block/CodeBlock.cjs +0 -18
- package/dist/components/copy-button/CopyButton.cjs +0 -35
- package/dist/components/datetime-picker/DateTimePicker.cjs +0 -504
- package/dist/components/filter-field/FilterField.cjs +0 -189
- package/dist/components/headline/Headline.cjs +0 -53
- package/dist/components/icon/Icon.cjs +0 -27
- package/dist/components/input/Input.cjs +0 -89
- package/dist/components/input/Input.js +0 -83
- package/dist/components/link/Link.cjs +0 -46
- package/dist/components/link/Link.js +0 -21
- package/dist/components/menu/Menu.cjs +0 -96
- package/dist/components/meta-bar/MetaBar.cjs +0 -29
- package/dist/components/modal/Modal.cjs +0 -134
- package/dist/components/modal/Modal.js +0 -128
- package/dist/components/modal/provider/ModalProvider.cjs +0 -80
- package/dist/components/modal/provider/ModalProvider.js +0 -77
- package/dist/components/multi-select/MultiSelect.cjs +0 -59
- package/dist/components/multi-select/MultiSelect.d.ts +0 -18
- package/dist/components/multi-select/MultiSelect.js +0 -57
- 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 -84
- package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.cjs +0 -32
- package/dist/components/pagination/Pagination.cjs +0 -133
- package/dist/components/panel/Panel.cjs +0 -18
- package/dist/components/popover/Popover.cjs +0 -149
- package/dist/components/search-box/SearchBox.cjs +0 -175
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.cjs +0 -103
- package/dist/components/select/Select.cjs +0 -121
- package/dist/components/select/Select.d.ts +0 -12
- package/dist/components/select/Select.js +0 -119
- package/dist/components/sidebar/Sidebar.cjs +0 -11
- package/dist/components/sidebar/components/SidebarItem.cjs +0 -18
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.cjs +0 -100
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.cjs +0 -50
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.cjs +0 -34
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.cjs +0 -29
- package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.cjs +0 -52
- package/dist/components/sidebar/providers/SidebarProvider.cjs +0 -179
- 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/split-pane/SplitPane.cjs +0 -123
- package/dist/components/split-pane/provider/SplitPaneContext.cjs +0 -87
- package/dist/components/table/Table.cjs +0 -249
- package/dist/components/table/components/column-resizer/ColumnResizer.cjs +0 -22
- package/dist/components/table/components/empty-state/EmptyState.cjs +0 -52
- package/dist/components/table/components/table-settings/TableSettings.cjs +0 -32
- package/dist/components/table/tanstack.cjs +0 -193
- package/dist/components/tabs/Tabs.cjs +0 -90
- 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/toast/Toast.cjs +0 -47
- package/dist/components/toast/provider/ToastProvider.cjs +0 -98
- package/dist/components/tooltip/Tooltip.cjs +0 -183
- package/dist/components/tooltip/Tooltip.d.ts +0 -11
- package/dist/components/tooltip/Tooltip.js +0 -177
- package/dist/components/tooltip/Tooltip.module.css +0 -66
- 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 -11
- package/dist/hooks/usePagination.cjs +0 -88
- package/dist/hooks/useSorting.cjs +0 -118
- package/dist/hooks/useTableData.cjs +0 -52
- package/dist/hooks/useTableSelection.cjs +0 -130
- package/dist/hooks/useTableSettings.cjs +0 -28
- package/dist/hooks/useTheme.cjs +0 -58
- package/dist/hooks/useTimeDuration.cjs +0 -39
- package/dist/hooks/useViewportFill.cjs +0 -52
- package/dist/index.cjs +0 -383
- package/dist/styles/themes/types.cjs +0 -2
- 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
- /package/dist/components/{modal → overlay/modal}/Modal.module.css +0 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Check } from 'lucide-react';
|
|
4
|
+
import { useEffect, useId, useRef, useState } from 'react';
|
|
5
|
+
import { useTooltipTrigger } from '../../../components/overlay/tooltip/useTooltipTrigger';
|
|
6
|
+
import { Button } from '../../button/Button';
|
|
7
|
+
import { ClearButton } from '../../clear-button/ClearButton';
|
|
8
|
+
import { Menu } from '../../menu/Menu';
|
|
9
|
+
import { Popover } from '../../popover/Popover';
|
|
10
|
+
import { InputContainer } from '../input-container/InputContainer';
|
|
11
|
+
export function Select({
|
|
12
|
+
// InputContainer props
|
|
13
|
+
label, error, helpText, orientation = 'vertical', labelWidth = '120px', fullWidth = true, required,
|
|
14
|
+
// ✅ tooltip props
|
|
15
|
+
tooltip, tooltipPlacement = 'right',
|
|
16
|
+
// Select props
|
|
17
|
+
id, options, selectedValue, onChange, placeholder = 'Vælg', size, variant = 'outlined', onClear, datakey, dataCy, }) {
|
|
18
|
+
const generatedId = useId();
|
|
19
|
+
const controlId = id !== null && id !== void 0 ? id : `select-${generatedId}`;
|
|
20
|
+
const describedById = `${controlId}-desc`;
|
|
21
|
+
const popoverRef = useRef(null);
|
|
22
|
+
const optionRefs = useRef([]);
|
|
23
|
+
const selectedIndex = options.findIndex(o => o.value === selectedValue);
|
|
24
|
+
const [activeIndex, setActiveIndex] = useState(selectedIndex >= 0 ? selectedIndex : 0);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
var _a;
|
|
27
|
+
(_a = optionRefs.current[activeIndex]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
28
|
+
}, [activeIndex]);
|
|
29
|
+
const handleKeyDown = (e) => {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
switch (e.key) {
|
|
32
|
+
case 'ArrowDown': {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
setActiveIndex(i => Math.min(i + 1, options.length - 1));
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
case 'ArrowUp': {
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
setActiveIndex(i => Math.max(i - 1, 0));
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case 'Enter':
|
|
43
|
+
case ' ': {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
const opt = options[activeIndex];
|
|
46
|
+
if (opt) {
|
|
47
|
+
onChange(opt.value);
|
|
48
|
+
(_a = popoverRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
case 'Escape': {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
(_b = popoverRef.current) === null || _b === void 0 ? void 0 : _b.close();
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const selected = options.find(o => o.value === selectedValue);
|
|
60
|
+
// Tooltip trigger props (anchor to the Button)
|
|
61
|
+
const tooltipEnabled = Boolean(tooltip);
|
|
62
|
+
const { triggerProps, id: tooltipId } = useTooltipTrigger({
|
|
63
|
+
content: tooltipEnabled ? tooltip : null,
|
|
64
|
+
placement: tooltipPlacement,
|
|
65
|
+
offset: 8,
|
|
66
|
+
});
|
|
67
|
+
// If you want BOTH tooltip + error/helpText describedby:
|
|
68
|
+
// merge describedby ids (keeping existing describedById)
|
|
69
|
+
const describedBy = (() => {
|
|
70
|
+
const ids = [];
|
|
71
|
+
if (error || helpText)
|
|
72
|
+
ids.push(describedById);
|
|
73
|
+
if (tooltipEnabled)
|
|
74
|
+
ids.push(tooltipId);
|
|
75
|
+
return ids.length ? ids.join(' ') : undefined;
|
|
76
|
+
})();
|
|
77
|
+
return (_jsxs(InputContainer, { label: label, htmlFor: controlId, fullWidth: fullWidth, error: error, helpText: helpText, orientation: orientation, labelWidth: labelWidth, required: required, children: [_jsx(Popover, { ref: popoverRef, trigger: (onClick, icon) => (_jsx(Button
|
|
78
|
+
// IMPORTANT: keep triggerProps last for events, but let our aria-describedby win
|
|
79
|
+
// We'll spread triggerProps and then override aria-describedby to include both.
|
|
80
|
+
, { ...(tooltipEnabled ? triggerProps : {}), id: controlId, "data-cy": dataCy !== null && dataCy !== void 0 ? dataCy : 'select-button', onKeyDown: handleKeyDown, fullWidth: fullWidth, variant: variant, onClick: e => {
|
|
81
|
+
setActiveIndex(selectedIndex >= 0 ? selectedIndex : 0);
|
|
82
|
+
onClick(e);
|
|
83
|
+
}, size: size, type: "button", "aria-haspopup": "listbox", "aria-invalid": Boolean(error) || undefined, "aria-describedby": describedBy, children: _jsxs("span", { className: "dbc-flex dbc-justify-between dbc-items-center dbc-gap-xxs", style: { width: '100%' }, children: [_jsx("span", { children: selected ? selected.label : placeholder }), onClear && selected && _jsx(ClearButton, { onClick: onClear }), icon] }) })), children: _jsx(Menu, { onKeyDown: handleKeyDown, role: "listbox", children: options.map((opt, index) => {
|
|
84
|
+
const isSelected = typeof opt.value === 'object' && typeof selectedValue === 'object' && datakey
|
|
85
|
+
? (selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue[datakey]) === opt.value[datakey]
|
|
86
|
+
: opt.value === selectedValue;
|
|
87
|
+
const isActive = index === activeIndex;
|
|
88
|
+
return (_jsx(Menu.Item, { active: isActive, "aria-selected": isSelected, children: _jsxs("button", { ref: el => (optionRefs.current[index] = el), type: "button", tabIndex: isActive ? 0 : -1, onClick: () => {
|
|
89
|
+
var _a;
|
|
90
|
+
onChange(opt.value);
|
|
91
|
+
(_a = popoverRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
92
|
+
}, onFocus: () => setActiveIndex(index), style: { display: 'flex', alignItems: 'center', width: '100%' }, children: [_jsx("span", { style: { width: 16, display: 'inline-flex', justifyContent: 'center' }, children: isSelected ? _jsx(Check, {}) : null }), opt.label] }) }, String(opt.value)));
|
|
93
|
+
}) }) }), (error || helpText) && (_jsx("span", { id: describedById, style: { display: 'none' }, children: error !== null && error !== void 0 ? error : helpText }))] }));
|
|
94
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { InputContainerProps } from '../input-container/InputContainer';
|
|
3
|
+
export type TextareaProps = Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'onChange' | 'disabled'> & Omit<InputContainerProps, 'children' | 'htmlFor' | 'tooltip' | 'tooltipPlacement'> & {
|
|
4
|
+
value: string;
|
|
5
|
+
inputChanged: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
loading?: React.ReactNode;
|
|
8
|
+
rows?: number;
|
|
9
|
+
showCount?: boolean;
|
|
10
|
+
tooltip?: React.ReactNode;
|
|
11
|
+
tooltipPlacement?: 'top' | 'right' | 'bottom' | 'left';
|
|
12
|
+
showTooltip?: boolean;
|
|
13
|
+
adjustHeight?: boolean;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
id?: string;
|
|
16
|
+
};
|
|
17
|
+
export declare const Textarea: React.FC<TextareaProps>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useId, useMemo } from 'react';
|
|
4
|
+
import { useTooltipTrigger } from '../../../components/overlay/tooltip/useTooltipTrigger';
|
|
5
|
+
import styles from './Textarea.module.css';
|
|
6
|
+
import { InputContainer } from '../input-container/InputContainer';
|
|
7
|
+
export const Textarea = function Textarea({ value, inputChanged, disabled, rows = 3, showCount, tooltip, tooltipPlacement = 'right', showTooltip, placeholder, adjustHeight, id,
|
|
8
|
+
// InputContainer props
|
|
9
|
+
label, error, helpText, orientation = 'horizontal', labelWidth = '120px', fullWidth = false, required,
|
|
10
|
+
// Native textarea props
|
|
11
|
+
className, ...rest }) {
|
|
12
|
+
const generatedId = useId();
|
|
13
|
+
const textareaId = id !== null && id !== void 0 ? id : `textarea-${generatedId}`;
|
|
14
|
+
const onInput = useCallback((e) => {
|
|
15
|
+
const textarea = e.currentTarget;
|
|
16
|
+
if (adjustHeight) {
|
|
17
|
+
textarea.style.height = 'auto';
|
|
18
|
+
textarea.style.height = `${textarea.scrollHeight}px`;
|
|
19
|
+
}
|
|
20
|
+
inputChanged(e);
|
|
21
|
+
}, [inputChanged, adjustHeight]);
|
|
22
|
+
const inputField = useMemo(() => (_jsx("textarea", { ...rest, id: textareaId, className: [styles.textarea, className].filter(Boolean).join(' '), placeholder: placeholder, rows: rows, value: value, onChange: onInput, disabled: disabled, "aria-invalid": Boolean(error) || undefined })), [rest, textareaId, className, placeholder, rows, value, onInput, disabled, error]);
|
|
23
|
+
// Enable tooltip if tooltip exists, and if showTooltip is either true or undefined.
|
|
24
|
+
// (So you can deprecate showTooltip later without breaking callers.)
|
|
25
|
+
const tooltipEnabled = Boolean(tooltip) && (showTooltip !== null && showTooltip !== void 0 ? showTooltip : true);
|
|
26
|
+
const { triggerProps } = useTooltipTrigger({
|
|
27
|
+
content: tooltipEnabled ? tooltip : null,
|
|
28
|
+
placement: tooltipPlacement,
|
|
29
|
+
offset: 8,
|
|
30
|
+
});
|
|
31
|
+
return (_jsx(InputContainer, { label: label, htmlFor: textareaId, error: error, helpText: helpText, helpTextAddition: showCount ? `${value === null || value === void 0 ? void 0 : value.length} tegn i denne boks` : undefined, orientation: orientation, labelWidth: labelWidth, fullWidth: fullWidth, required: required, children: _jsx("div", { className: styles.container, children: _jsx("div", { ...(tooltipEnabled ? triggerProps : {}), children: inputField }) }) }));
|
|
32
|
+
};
|
|
33
|
+
Textarea.displayName = 'Textarea';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
flex-grow: 1;
|
|
3
|
+
}
|
|
4
|
+
.container textarea {
|
|
5
|
+
width: 100%;
|
|
6
|
+
padding: var(--spacing-xs);
|
|
7
|
+
border: var(--border-width-thin) solid var(--color-border-default);
|
|
8
|
+
border-radius: var(--border-radius-sm);
|
|
9
|
+
font-family: var(--font-family);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.internalCount {
|
|
13
|
+
text-align: right;
|
|
14
|
+
font-size: var(--font-size-sm);
|
|
15
|
+
color: var(--color-fg-subtle);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.container textarea:hover {
|
|
19
|
+
border-color: var(--color-border-strong);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.container textarea:focus-visible {
|
|
23
|
+
outline: none;
|
|
24
|
+
border-color: var(--color-border-selected);
|
|
25
|
+
box-shadow: var(--focus-ring);
|
|
26
|
+
}
|
|
@@ -1,47 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
3
|
import styles from './Headline.module.css';
|
|
3
4
|
import { SeverityBgColor } from '../../constants/severity';
|
|
4
5
|
import { Icon } from '../icon/Icon';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
styles.headline,
|
|
22
|
-
disableMargin ? styles.noMargin : "",
|
|
23
|
-
marker ? styles.marker : ""
|
|
24
|
-
].filter(Boolean).join(" ");
|
|
25
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
26
|
-
/* @__PURE__ */ jsxs("div", { className: containerClassName, children: [
|
|
27
|
-
/* @__PURE__ */ jsxs(
|
|
28
|
-
Tag,
|
|
29
|
-
{
|
|
30
|
-
style: {
|
|
31
|
-
"--font-weight": weight,
|
|
32
|
-
"--marker-color": severity ? SeverityBgColor[severity] : void 0
|
|
33
|
-
},
|
|
34
|
-
className: headlineClassName,
|
|
35
|
-
children: [
|
|
36
|
-
icon || severity && !marker ? /* @__PURE__ */ jsx(Icon, { customIcon: icon, severity }) : null,
|
|
37
|
-
children
|
|
38
|
-
]
|
|
39
|
-
}
|
|
40
|
-
),
|
|
41
|
-
addition
|
|
42
|
-
] }),
|
|
43
|
-
subHeadline && /* @__PURE__ */ jsx("div", { className: styles.subHeadline, children: subHeadline })
|
|
44
|
-
] });
|
|
6
|
+
export function Headline({ size = 2, marker, disableMargin, children, severity, weight = 600, subHeadline, addition, icon, tone, }) {
|
|
7
|
+
const Tag = `h${size}`;
|
|
8
|
+
const containerClassName = [styles.headlineContainer, tone ? styles[`tone-${tone}`] : '']
|
|
9
|
+
.filter(Boolean)
|
|
10
|
+
.join(' ');
|
|
11
|
+
const headlineClassName = [
|
|
12
|
+
styles.headline,
|
|
13
|
+
disableMargin ? styles.noMargin : '',
|
|
14
|
+
marker ? styles.marker : '',
|
|
15
|
+
]
|
|
16
|
+
.filter(Boolean)
|
|
17
|
+
.join(' ');
|
|
18
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: containerClassName, children: [_jsxs(Tag, { style: {
|
|
19
|
+
'--font-weight': weight,
|
|
20
|
+
'--marker-color': severity ? SeverityBgColor[severity] : undefined,
|
|
21
|
+
}, className: headlineClassName, children: [icon || (severity && !marker) ? _jsx(Icon, { customIcon: icon, severity: severity }) : null, children] }), addition] }), subHeadline && _jsx("div", { className: styles.subHeadline, children: subHeadline })] }));
|
|
45
22
|
}
|
|
46
|
-
|
|
47
|
-
export { Headline };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
interface
|
|
2
|
+
interface HyperlinkProps {
|
|
3
3
|
component: React.ReactElement;
|
|
4
4
|
className?: string;
|
|
5
5
|
icon?: React.ReactNode;
|
|
6
6
|
disableIcon?: boolean;
|
|
7
7
|
}
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function Hyperlink({ component, icon }: HyperlinkProps): React.ReactElement;
|
|
9
9
|
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import styles from './Hyperlink.module.css';
|
|
4
|
+
export function Hyperlink({ component, icon }) {
|
|
5
|
+
const originalProps = component.props;
|
|
6
|
+
return React.cloneElement(component, {
|
|
7
|
+
...originalProps,
|
|
8
|
+
className: styles.link,
|
|
9
|
+
onClick: (e) => e.stopPropagation(),
|
|
10
|
+
}, _jsxs(_Fragment, { children: [_jsx("span", { className: styles.content, children: originalProps.children }), icon && _jsx("span", { className: styles.icon, children: icon })] }));
|
|
11
|
+
}
|
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
gap: var(--spacing-xs);
|
|
4
4
|
position: relative;
|
|
5
5
|
text-decoration: none;
|
|
6
|
-
|
|
7
|
-
color: inherit;
|
|
6
|
+
color: var(--color-brand);
|
|
8
7
|
font-size: inherit;
|
|
9
8
|
}
|
|
10
9
|
|
|
10
|
+
.link:hover {
|
|
11
|
+
text-decoration: underline;
|
|
12
|
+
}
|
|
13
|
+
|
|
11
14
|
.icon {
|
|
12
15
|
display: flex;
|
|
13
16
|
align-items: center;
|
|
@@ -18,15 +21,3 @@
|
|
|
18
21
|
inline-size: var(--icon-size-sm);
|
|
19
22
|
block-size: var(--icon-size-sm);
|
|
20
23
|
}
|
|
21
|
-
|
|
22
|
-
.link::after {
|
|
23
|
-
content: '';
|
|
24
|
-
display: block;
|
|
25
|
-
height: var(--border-width-medium);
|
|
26
|
-
background-color: var(--color-brand);
|
|
27
|
-
width: 100%;
|
|
28
|
-
align-self: flex-end;
|
|
29
|
-
position: absolute;
|
|
30
|
-
left: 0;
|
|
31
|
-
bottom: calc(var(--spacing-xxs) * -1);
|
|
32
|
-
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { ReactNode, JSX } from 'react';
|
|
2
|
+
import { Severity } from '../../constants/severity.types';
|
|
3
|
+
export declare const SeverityIcon: Record<Severity, ReactNode>;
|
|
3
4
|
interface IconProps {
|
|
4
5
|
severity?: Severity;
|
|
5
|
-
customIcon?:
|
|
6
|
+
customIcon?: ReactNode;
|
|
6
7
|
label?: string;
|
|
7
8
|
}
|
|
8
9
|
export declare function Icon({ severity, label, customIcon }: IconProps): JSX.Element;
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import { jsx, jsxs } from
|
|
2
|
-
import { Building2, CircleAlert,
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Building2, CircleAlert, CircleCheck, CircleX, Info } from 'lucide-react';
|
|
3
3
|
import styles from './Icon.module.css';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
brand: /* @__PURE__ */ jsx(Building2, {})
|
|
4
|
+
export const SeverityIcon = {
|
|
5
|
+
neutral: _jsx(CircleCheck, {}),
|
|
6
|
+
success: _jsx(CircleCheck, {}),
|
|
7
|
+
error: _jsx(CircleX, {}),
|
|
8
|
+
info: _jsx(Info, {}),
|
|
9
|
+
warning: _jsx(CircleAlert, {}),
|
|
10
|
+
brand: _jsx(Building2, {}),
|
|
12
11
|
};
|
|
13
|
-
function Icon({ severity, label, customIcon }) {
|
|
14
|
-
|
|
15
|
-
/* @__PURE__ */ jsx("span", { className: `${styles.icon} ${severity ? styles[severity] : ""} dbc-icon`, children: customIcon ? customIcon : severity ? SeverityIcon[severity] : null }),
|
|
16
|
-
label && /* @__PURE__ */ jsx("span", { children: label })
|
|
17
|
-
] });
|
|
12
|
+
export function Icon({ severity, label, customIcon }) {
|
|
13
|
+
return (_jsxs("div", { className: `${styles.container}`, children: [_jsx("span", { className: `${styles.icon} ${severity ? styles[severity] : ''} dbc-icon`, children: customIcon ? customIcon : severity ? SeverityIcon[severity] : null }), label && _jsx("span", { children: label })] }));
|
|
18
14
|
}
|
|
19
|
-
|
|
20
|
-
export { Icon, SeverityIcon };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ButtonVariant } from '../../components/button/Button';
|
|
3
|
+
import { InputContainer } from '../../components/forms/input-container/InputContainer';
|
|
4
|
+
type InputContainerProps = React.ComponentProps<typeof InputContainer>;
|
|
5
|
+
export type IntervalOption = {
|
|
6
|
+
label: string;
|
|
7
|
+
/** How many minutes back from baseDate (default: now). */
|
|
8
|
+
minutesAgo: number;
|
|
9
|
+
};
|
|
10
|
+
export type IntervalSelectValue = number | null;
|
|
11
|
+
export type IntervalSelectProps = Omit<InputContainerProps, 'children' | 'htmlFor' | 'tooltip' | 'tooltipPlacement'> & {
|
|
12
|
+
id?: string;
|
|
13
|
+
options: IntervalOption[];
|
|
14
|
+
selectedValue: IntervalSelectValue;
|
|
15
|
+
onChange: (date: Date, meta: {
|
|
16
|
+
minutesAgo: number;
|
|
17
|
+
option: IntervalOption;
|
|
18
|
+
}) => void;
|
|
19
|
+
/** Base date for the calculation; defaults to "now". */
|
|
20
|
+
baseDate?: Date;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
size?: 'sm' | 'md' | 'lg';
|
|
23
|
+
variant?: ButtonVariant;
|
|
24
|
+
onClear?: () => void;
|
|
25
|
+
dataCy?: string;
|
|
26
|
+
tooltip?: React.ReactNode;
|
|
27
|
+
tooltipPlacement?: 'top' | 'right' | 'bottom' | 'left';
|
|
28
|
+
};
|
|
29
|
+
export declare function IntervalSelect({ label, error, helpText, orientation, labelWidth, fullWidth, required, tooltip, tooltipPlacement, id, options, selectedValue, onChange, baseDate, placeholder, size, variant, onClear, dataCy, }: IntervalSelectProps): React.ReactNode;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Check, Clock } from 'lucide-react';
|
|
4
|
+
import { useEffect, useId, useMemo, useRef, useState } from 'react';
|
|
5
|
+
import { Button } from '../../components/button/Button';
|
|
6
|
+
import { ClearButton } from '../../components/clear-button/ClearButton';
|
|
7
|
+
import { InputContainer } from '../../components/forms/input-container/InputContainer';
|
|
8
|
+
import { Menu } from '../../components/menu/Menu';
|
|
9
|
+
import { useTooltipTrigger } from '../../components/overlay/tooltip/useTooltipTrigger';
|
|
10
|
+
import { Popover } from '../../components/popover/Popover';
|
|
11
|
+
export function IntervalSelect({
|
|
12
|
+
// InputContainer props
|
|
13
|
+
label, error, helpText, orientation = 'vertical', labelWidth = '120px', fullWidth = true, required,
|
|
14
|
+
// tooltip
|
|
15
|
+
tooltip, tooltipPlacement = 'right',
|
|
16
|
+
// IntervalSelect props
|
|
17
|
+
id, options, selectedValue, onChange, baseDate, placeholder = 'Vælg interval', size, variant = 'outlined', onClear, dataCy, }) {
|
|
18
|
+
const generatedId = useId();
|
|
19
|
+
const controlId = id !== null && id !== void 0 ? id : `interval-select-${generatedId}`;
|
|
20
|
+
const describedById = `${controlId}-desc`;
|
|
21
|
+
const popoverRef = useRef(null);
|
|
22
|
+
const optionRefs = useRef([]);
|
|
23
|
+
const selectedIndex = useMemo(() => options.findIndex(o => o.minutesAgo === selectedValue), [options, selectedValue]);
|
|
24
|
+
const [activeIndex, setActiveIndex] = useState(selectedIndex >= 0 ? selectedIndex : 0);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
var _a;
|
|
27
|
+
(_a = optionRefs.current[activeIndex]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
28
|
+
}, [activeIndex]);
|
|
29
|
+
const selected = useMemo(() => { var _a; return (_a = options.find(o => o.minutesAgo === selectedValue)) !== null && _a !== void 0 ? _a : null; }, [options, selectedValue]);
|
|
30
|
+
const tooltipEnabled = Boolean(tooltip);
|
|
31
|
+
const { triggerProps, id: tooltipId } = useTooltipTrigger({
|
|
32
|
+
content: tooltipEnabled ? tooltip : null,
|
|
33
|
+
placement: tooltipPlacement,
|
|
34
|
+
offset: 8,
|
|
35
|
+
});
|
|
36
|
+
const describedBy = (() => {
|
|
37
|
+
const ids = [];
|
|
38
|
+
if (error || helpText)
|
|
39
|
+
ids.push(describedById);
|
|
40
|
+
if (tooltipEnabled)
|
|
41
|
+
ids.push(tooltipId);
|
|
42
|
+
return ids.length ? ids.join(' ') : undefined;
|
|
43
|
+
})();
|
|
44
|
+
const handleCommit = (opt) => {
|
|
45
|
+
var _a;
|
|
46
|
+
const base = baseDate !== null && baseDate !== void 0 ? baseDate : new Date();
|
|
47
|
+
const dt = new Date(base.getTime() - opt.minutesAgo * 60000);
|
|
48
|
+
onChange(dt, { minutesAgo: opt.minutesAgo, option: opt });
|
|
49
|
+
(_a = popoverRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
50
|
+
};
|
|
51
|
+
const handleKeyDown = (e) => {
|
|
52
|
+
var _a;
|
|
53
|
+
switch (e.key) {
|
|
54
|
+
case 'ArrowDown':
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
setActiveIndex(i => Math.min(i + 1, options.length - 1));
|
|
57
|
+
break;
|
|
58
|
+
case 'ArrowUp':
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
setActiveIndex(i => Math.max(i - 1, 0));
|
|
61
|
+
break;
|
|
62
|
+
case 'Enter':
|
|
63
|
+
case ' ':
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
if (options[activeIndex])
|
|
66
|
+
handleCommit(options[activeIndex]);
|
|
67
|
+
break;
|
|
68
|
+
case 'Escape':
|
|
69
|
+
e.preventDefault();
|
|
70
|
+
(_a = popoverRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
return (_jsxs(InputContainer, { label: label, htmlFor: controlId, fullWidth: fullWidth, error: error, helpText: helpText, orientation: orientation, labelWidth: labelWidth, required: required, children: [_jsx(Popover, { ref: popoverRef, trigger: (onClick, icon) => (_jsx(Button, { ...(tooltipEnabled ? triggerProps : {}), id: controlId, "data-cy": dataCy !== null && dataCy !== void 0 ? dataCy : 'interval-select-button', onKeyDown: handleKeyDown, fullWidth: fullWidth, variant: variant, onClick: e => {
|
|
75
|
+
setActiveIndex(selectedIndex >= 0 ? selectedIndex : 0);
|
|
76
|
+
onClick(e);
|
|
77
|
+
}, size: size, type: "button", "aria-haspopup": "listbox", "aria-invalid": Boolean(error) || undefined, "aria-describedby": describedBy, children: _jsxs("span", { className: "dbc-flex dbc-justify-between dbc-items-center dbc-gap-xxs", style: { width: '100%' }, children: [_jsxs("span", { className: "dbc-flex dbc-items-center dbc-gap-xxs", children: [_jsx(Clock, { size: 14 }), selected ? selected.label : placeholder] }), onClear && selected && _jsx(ClearButton, { onClick: onClear }), icon] }) })), children: _jsx(Menu, { onKeyDown: handleKeyDown, role: "listbox", children: options.map((opt, index) => {
|
|
78
|
+
const isSelected = opt.minutesAgo === selectedValue;
|
|
79
|
+
const isActive = index === activeIndex;
|
|
80
|
+
return (_jsx(Menu.Item, { active: isActive, "aria-selected": isSelected, children: _jsxs("button", { ref: el => (optionRefs.current[index] = el), type: "button", tabIndex: isActive ? 0 : -1, onClick: () => handleCommit(opt), onFocus: () => setActiveIndex(index), style: { display: 'flex', alignItems: 'center', width: '100%' }, children: [_jsx("span", { style: { width: 16, display: 'inline-flex', justifyContent: 'center' }, children: isSelected ? _jsx(Check, {}) : null }), opt.label] }) }, opt.minutesAgo));
|
|
81
|
+
}) }) }), (error || helpText) && (_jsx("span", { id: describedById, style: { display: 'none' }, children: error !== null && error !== void 0 ? error : helpText }))] }));
|
|
82
|
+
}
|
|
@@ -1,71 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import styles from './Menu.module.css';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
role: "menu",
|
|
11
|
-
className: [styles.container, className].filter(Boolean).join(" "),
|
|
12
|
-
...props,
|
|
13
|
-
children
|
|
14
|
-
}
|
|
15
|
-
)
|
|
16
|
-
);
|
|
17
|
-
MenuBase.displayName = "Menu";
|
|
18
|
-
const isInteractiveEl = (el) => React.isValidElement(el) && (typeof el.type === "string" ? el.type === "a" || el.type === "button" : true);
|
|
19
|
-
const MenuItem = React.forwardRef(
|
|
20
|
-
({ children, active, disabled, className, ...liProps }, ref) => {
|
|
5
|
+
const MenuBase = React.forwardRef(({ children, className, ...props }, ref) => (_jsx("ul", { ref: ref, role: "menu", className: [styles.container, className].filter(Boolean).join(' '), ...props, children: children })));
|
|
6
|
+
MenuBase.displayName = 'Menu';
|
|
7
|
+
const isInteractiveEl = (el) => React.isValidElement(el) &&
|
|
8
|
+
(typeof el.type === 'string' ? el.type === 'a' || el.type === 'button' : true); // allow custom/Next Link components
|
|
9
|
+
const MenuItem = React.forwardRef(({ children, active, disabled, className, ...liProps }, ref) => {
|
|
10
|
+
// If child is interactive (a/button/NextLink), clone it and style it.
|
|
21
11
|
if (isInteractiveEl(children)) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
tabIndex: -1,
|
|
34
|
-
"aria-selected": active || void 0,
|
|
35
|
-
"aria-disabled": disabled || void 0,
|
|
36
|
-
className: [child.props.className, styles.interactive, childClass].filter(Boolean).join(" ")
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
);
|
|
12
|
+
const child = children;
|
|
13
|
+
const childClass = [styles.item, active ? styles.active : ''].filter(Boolean).join(' ');
|
|
14
|
+
return (_jsx("li", { ref: ref, role: "none", className: [styles.row, className].filter(Boolean).join(' '), ...liProps, children: React.cloneElement(child, {
|
|
15
|
+
role: 'menuitem',
|
|
16
|
+
tabIndex: -1,
|
|
17
|
+
'aria-selected': active || undefined,
|
|
18
|
+
'aria-disabled': disabled || undefined,
|
|
19
|
+
className: [child.props.className, styles.interactive, childClass]
|
|
20
|
+
.filter(Boolean)
|
|
21
|
+
.join(' '),
|
|
22
|
+
}) }));
|
|
40
23
|
}
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
...liProps,
|
|
48
|
-
children: /* @__PURE__ */ jsx(
|
|
49
|
-
"button",
|
|
50
|
-
{
|
|
51
|
-
role: "menuitem",
|
|
52
|
-
tabIndex: -1,
|
|
53
|
-
"aria-selected": active || void 0,
|
|
54
|
-
"aria-disabled": disabled || void 0,
|
|
55
|
-
className: [styles.interactive, styles.item, active ? styles.active : ""].filter(Boolean).join(" "),
|
|
56
|
-
type: "button",
|
|
57
|
-
disabled,
|
|
58
|
-
children
|
|
59
|
-
}
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
MenuItem.displayName = "Menu.Item";
|
|
66
|
-
const Menu = Object.assign(
|
|
67
|
-
MenuBase,
|
|
68
|
-
{ Item: MenuItem }
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
export { Menu };
|
|
24
|
+
return (_jsx("li", { ref: ref, role: "none", className: [styles.row, className].filter(Boolean).join(' '), ...liProps, children: _jsx("button", { role: "menuitem", tabIndex: -1, "aria-selected": active || undefined, "aria-disabled": disabled || undefined, className: [styles.interactive, styles.item, active ? styles.active : '']
|
|
25
|
+
.filter(Boolean)
|
|
26
|
+
.join(' '), type: "button", disabled: disabled, children: children }) }));
|
|
27
|
+
});
|
|
28
|
+
MenuItem.displayName = 'Menu.Item';
|
|
29
|
+
export const Menu = Object.assign(MenuBase, { Item: MenuItem });
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type ReactNode, type JSX } from 'react';
|
|
2
2
|
export interface MetaItem {
|
|
3
|
-
label?:
|
|
4
|
-
value:
|
|
3
|
+
label?: ReactNode;
|
|
4
|
+
value: ReactNode;
|
|
5
5
|
}
|
|
6
6
|
interface MetaBarProps {
|
|
7
7
|
items: MetaItem[];
|
|
8
|
-
separator?:
|
|
8
|
+
separator?: ReactNode;
|
|
9
9
|
}
|
|
10
10
|
export declare function MetaBar({ items, separator }: MetaBarProps): JSX.Element | null;
|
|
11
11
|
export {};
|
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from 'react';
|
|
3
3
|
import styles from './MetaBar.module.css';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (visibleItems.length === 0) return null;
|
|
10
|
-
return /* @__PURE__ */ jsx("div", { className: styles.meta, children: visibleItems.map((item, index) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
11
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
12
|
-
item.label && /* @__PURE__ */ jsxs("span", { children: [
|
|
13
|
-
item.label,
|
|
14
|
-
": "
|
|
15
|
-
] }),
|
|
16
|
-
/* @__PURE__ */ jsx("span", { children: item.value })
|
|
17
|
-
] }),
|
|
18
|
-
index < visibleItems.length - 1 && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: styles.dot, children: separator })
|
|
19
|
-
] }, index)) });
|
|
4
|
+
export function MetaBar({ items, separator = '•' }) {
|
|
5
|
+
const visibleItems = items.filter(item => item.value !== null && item.value !== undefined && item.value !== '');
|
|
6
|
+
if (visibleItems.length === 0)
|
|
7
|
+
return null;
|
|
8
|
+
return (_jsx("div", { className: styles.meta, children: visibleItems.map((item, index) => (_jsxs(Fragment, { children: [_jsxs("span", { children: [item.label && _jsxs("span", { children: [item.label, ": "] }), _jsx("span", { children: item.value })] }), index < visibleItems.length - 1 && (_jsx("span", { "aria-hidden": "true", className: styles.dot, children: separator }))] }, index))) }));
|
|
20
9
|
}
|
|
21
|
-
|
|
22
|
-
export { MetaBar };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { ElementType, ReactNode, JSX } from 'react';
|
|
2
2
|
export type NavBarItem = {
|
|
3
|
-
component?:
|
|
3
|
+
component?: ElementType<any>;
|
|
4
4
|
label: string;
|
|
5
|
-
icon?:
|
|
5
|
+
icon?: ReactNode;
|
|
6
6
|
active?: boolean;
|
|
7
7
|
external?: boolean;
|
|
8
8
|
enabled?: boolean;
|
|
@@ -11,10 +11,10 @@ export type NavBarItem = {
|
|
|
11
11
|
children?: NavBarItem[];
|
|
12
12
|
};
|
|
13
13
|
interface NavBarProps {
|
|
14
|
-
logo?:
|
|
14
|
+
logo?: ReactNode;
|
|
15
15
|
items: NavBarItem[];
|
|
16
16
|
productName?: string;
|
|
17
|
-
addition?:
|
|
17
|
+
addition?: ReactNode;
|
|
18
18
|
}
|
|
19
19
|
export declare function NavBar({ logo, items, productName, addition }: NavBarProps): JSX.Element;
|
|
20
20
|
export {};
|