@dbcdk/react-components 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/logo.js +2 -85
- package/dist/components/__stories__/_data/table.d.ts +15 -0
- package/dist/components/__stories__/_data/table.js +49 -0
- package/dist/components/__stories__/story-components/Colors.d.ts +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 +364 -459
- 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/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
|
@@ -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 };
|
|
@@ -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 {};
|
|
@@ -1,49 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import styles from './NavBar.module.css';
|
|
3
4
|
import { Logo } from '../../assets/logo';
|
|
4
|
-
import { Headline } from '../headline/Headline';
|
|
5
5
|
import { AppHeader } from '../app-header/AppHeader';
|
|
6
|
-
|
|
7
|
-
function NavBar({ logo, items, productName, addition }) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
style: { display: "flex", alignItems: "center", gap: 16 },
|
|
20
|
-
children: [
|
|
21
|
-
/* @__PURE__ */ jsx(Logo, {}),
|
|
22
|
-
/* @__PURE__ */ jsx(Headline, { disableMargin: true, size: 1, children: productName })
|
|
23
|
-
]
|
|
24
|
-
}
|
|
25
|
-
),
|
|
26
|
-
/* @__PURE__ */ jsx("ul", { className: styles.navItems, role: "list", children: items == null ? void 0 : items.filter((i) => i.enabled !== false).map((item, id) => {
|
|
27
|
-
const { component: Component, label, icon, href, active, external } = item;
|
|
28
|
-
const linkClass = [styles.link, active ? styles.active : ""].filter(Boolean).join(" ");
|
|
29
|
-
const commonProps = {
|
|
30
|
-
className: linkClass,
|
|
31
|
-
href,
|
|
32
|
-
...active ? { "aria-current": "page" } : {},
|
|
33
|
-
...external ? { target: "_blank", rel: "noopener noreferrer" } : {}
|
|
34
|
-
};
|
|
35
|
-
return /* @__PURE__ */ jsx("li", { className: styles.navItem, role: "listitem", children: Component ? /* @__PURE__ */ jsxs(Component, { ...commonProps, children: [
|
|
36
|
-
icon,
|
|
37
|
-
/* @__PURE__ */ jsx("span", { className: styles.label, children: label })
|
|
38
|
-
] }) : /* @__PURE__ */ jsxs("a", { ...commonProps, children: [
|
|
39
|
-
icon,
|
|
40
|
-
/* @__PURE__ */ jsx("span", { className: styles.label, children: label })
|
|
41
|
-
] }) }, id);
|
|
42
|
-
}) }),
|
|
43
|
-
addition
|
|
44
|
-
]
|
|
45
|
-
}
|
|
46
|
-
) });
|
|
6
|
+
import { Headline } from '../headline/Headline';
|
|
7
|
+
export function NavBar({ logo, items, productName, addition }) {
|
|
8
|
+
return (_jsx(AppHeader, { children: _jsxs("nav", { className: styles.container, "aria-label": productName ? `${productName} navigation` : 'Main navigation', children: [logo, productName && (_jsxs("span", { className: styles.productName, style: { display: 'flex', alignItems: 'center', gap: 16 }, children: [_jsx(Logo, {}), _jsx(Headline, { disableMargin: true, size: 1, children: productName })] })), _jsx("ul", { className: styles.navItems, role: "list", children: items === null || items === void 0 ? void 0 : items.filter(i => i.enabled !== false).map((item, id) => {
|
|
9
|
+
const { component: Component, label, icon, href, active, external } = item;
|
|
10
|
+
const linkClass = [styles.link, active ? styles.active : ''].filter(Boolean).join(' ');
|
|
11
|
+
const commonProps = {
|
|
12
|
+
className: linkClass,
|
|
13
|
+
href,
|
|
14
|
+
...(active ? { 'aria-current': 'page' } : {}),
|
|
15
|
+
...(external ? { target: '_blank', rel: 'noopener noreferrer' } : {}),
|
|
16
|
+
};
|
|
17
|
+
return (_jsx("li", { className: styles.navItem, role: "listitem", children: Component ? (_jsxs(Component, { ...commonProps, children: [icon, _jsx("span", { className: styles.label, children: label })] })) : (_jsxs("a", { ...commonProps, children: [icon, _jsx("span", { className: styles.label, children: label })] })) }, id));
|
|
18
|
+
}) }), addition] }) }));
|
|
47
19
|
}
|
|
48
|
-
|
|
49
|
-
export { NavBar };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import { Severity } from '
|
|
2
|
+
import { Severity } from '../../../constants/severity.types';
|
|
3
3
|
export type ModalActionConfig = {
|
|
4
4
|
label: string;
|
|
5
5
|
onClick?: () => void;
|
|
@@ -12,10 +12,12 @@ export type ModalProps = {
|
|
|
12
12
|
onRequestClose: () => void;
|
|
13
13
|
header?: ReactNode;
|
|
14
14
|
content?: ReactNode;
|
|
15
|
+
children?: ReactNode;
|
|
15
16
|
primaryAction?: ModalActionConfig;
|
|
16
17
|
secondaryAction?: ModalActionConfig;
|
|
17
18
|
closeOnOverlayClick?: boolean;
|
|
18
19
|
severity?: Severity;
|
|
19
20
|
disableContentSpacing?: boolean;
|
|
21
|
+
dataCy?: string;
|
|
20
22
|
};
|
|
21
|
-
export declare function Modal({ isOpen, onRequestClose, header, content, primaryAction, secondaryAction, closeOnOverlayClick, severity, disableContentSpacing, isLoading, }: ModalProps): React.ReactNode;
|
|
23
|
+
export declare function Modal({ isOpen, onRequestClose, header, content, children, primaryAction, secondaryAction, closeOnOverlayClick, severity, disableContentSpacing, isLoading, dataCy, }: ModalProps): React.ReactNode;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { X } from 'lucide-react';
|
|
4
|
+
import { useEffect, useId, useRef } from 'react';
|
|
5
|
+
import { Button } from '../../../components/button/Button';
|
|
6
|
+
import { Headline } from '../../../components/headline/Headline';
|
|
7
|
+
import styles from './Modal.module.css';
|
|
8
|
+
export function Modal({ isOpen, onRequestClose, header, content, children, primaryAction, secondaryAction, closeOnOverlayClick = true, severity, disableContentSpacing = false, isLoading, dataCy, }) {
|
|
9
|
+
const titleId = useId();
|
|
10
|
+
const dialogRef = useRef(null);
|
|
11
|
+
const lastActiveElementRef = useRef(null);
|
|
12
|
+
// Always call the latest onRequestClose without re-running effects
|
|
13
|
+
const onRequestCloseRef = useRef(onRequestClose);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
onRequestCloseRef.current = onRequestClose;
|
|
16
|
+
}, [onRequestClose]);
|
|
17
|
+
// Track open transition so we only autofocus once per open
|
|
18
|
+
const wasOpenRef = useRef(false);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
var _a;
|
|
21
|
+
const wasOpen = wasOpenRef.current;
|
|
22
|
+
wasOpenRef.current = isOpen;
|
|
23
|
+
if (!isOpen)
|
|
24
|
+
return;
|
|
25
|
+
// Only do focus setup when opening (false -> true)
|
|
26
|
+
if (!wasOpen) {
|
|
27
|
+
lastActiveElementRef.current = document.activeElement;
|
|
28
|
+
const dialog = dialogRef.current;
|
|
29
|
+
if (dialog) {
|
|
30
|
+
const focusableSelectors = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
31
|
+
const focusable = dialog.querySelectorAll(focusableSelectors);
|
|
32
|
+
if (focusable.length > 0) {
|
|
33
|
+
// Prefer focusing the first input/select/textarea if present
|
|
34
|
+
const preferred = (_a = dialog.querySelector('input, select, textarea')) !== null && _a !== void 0 ? _a : focusable[0];
|
|
35
|
+
preferred.focus();
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
dialog.focus();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const handleKeyDown = (event) => {
|
|
43
|
+
if (event.key === 'Escape') {
|
|
44
|
+
onRequestCloseRef.current();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (event.key === 'Tab' && dialogRef.current) {
|
|
48
|
+
const focusableSelectors = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
49
|
+
const focusable = dialogRef.current.querySelectorAll(focusableSelectors);
|
|
50
|
+
if (focusable.length === 0)
|
|
51
|
+
return;
|
|
52
|
+
const first = focusable[0];
|
|
53
|
+
const last = focusable[focusable.length - 1];
|
|
54
|
+
if (event.shiftKey) {
|
|
55
|
+
if (document.activeElement === first) {
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
last.focus();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
if (document.activeElement === last) {
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
first.focus();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
69
|
+
return () => {
|
|
70
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
71
|
+
// Restore focus only when closing (true -> false) happens elsewhere
|
|
72
|
+
// so we do it when modal unmounts while open.
|
|
73
|
+
if (lastActiveElementRef.current) {
|
|
74
|
+
lastActiveElementRef.current.focus();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}, [isOpen]); // <-- IMPORTANT: only depend on isOpen
|
|
78
|
+
if (!isOpen)
|
|
79
|
+
return null;
|
|
80
|
+
const handleOverlayClick = () => {
|
|
81
|
+
if (closeOnOverlayClick) {
|
|
82
|
+
onRequestCloseRef.current();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const stopPropagation = e => {
|
|
86
|
+
e.stopPropagation();
|
|
87
|
+
};
|
|
88
|
+
const resolvedSecondaryAction = secondaryAction !== null && secondaryAction !== void 0 ? secondaryAction : (primaryAction ? { label: 'Luk', onClick: onRequestCloseRef.current } : undefined);
|
|
89
|
+
const shouldRenderFooter = Boolean(primaryAction || resolvedSecondaryAction);
|
|
90
|
+
const body = children !== null && children !== void 0 ? children : content;
|
|
91
|
+
return (_jsx("div", { className: styles.overlay, onClick: handleOverlayClick, children: _jsxs("div", { "data-cy": dataCy, ref: dialogRef, className: `${styles.modal} ${disableContentSpacing ? '' : styles.contentSpacing}`, onClick: stopPropagation, role: "dialog", "aria-modal": "true", "aria-labelledby": header ? titleId : undefined, children: [_jsxs("div", { className: styles.header, children: [header && (_jsx(Headline, { severity: severity, size: 3, disableMargin: true, children: header })), _jsx(Button, { type: "button", variant: "inline", onClick: () => onRequestCloseRef.current(), "aria-label": "Luk", children: _jsx(X, {}) })] }), _jsx("div", { className: styles.body, children: body }), shouldRenderFooter && (_jsxs("div", { className: styles.footer, children: [resolvedSecondaryAction && (_jsxs(Button, { type: "button", variant: "outlined", onClick: resolvedSecondaryAction.onClick, disabled: isLoading, children: [resolvedSecondaryAction.icon && (_jsx("span", { className: styles.icon, children: resolvedSecondaryAction.icon })), _jsx("span", { children: resolvedSecondaryAction.label })] })), primaryAction && (_jsxs(Button, { type: "button", variant: "primary", onClick: primaryAction.onClick, disabled: primaryAction.disabled || isLoading, loading: isLoading, children: [primaryAction.icon && _jsx("span", { className: styles.icon, children: primaryAction.icon }), _jsx("span", { children: primaryAction.label })] }))] }))] }) }));
|
|
92
|
+
}
|
|
@@ -4,7 +4,6 @@ type ModalConfig = Omit<ModalProps, 'isOpen' | 'onRequestClose'> & {
|
|
|
4
4
|
onRequestClose?: () => void;
|
|
5
5
|
};
|
|
6
6
|
type ConfirmModalConfig = Omit<ModalConfig, 'primaryAction' | 'secondaryAction' | 'onRequestClose'> & {
|
|
7
|
-
/** Optional labels for confirm/cancel buttons */
|
|
8
7
|
confirmLabel?: string;
|
|
9
8
|
cancelLabel?: string;
|
|
10
9
|
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useCallback, useContext, useState, useRef } from 'react';
|
|
4
|
+
import { Modal } from '../Modal';
|
|
5
|
+
const ModalContext = createContext(undefined);
|
|
6
|
+
export function ModalProvider({ children }) {
|
|
7
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
8
|
+
const [config, setConfig] = useState(null);
|
|
9
|
+
// Holds the resolver for the current "confirm" call, if any
|
|
10
|
+
const pendingResolverRef = useRef(null);
|
|
11
|
+
const resolvePending = useCallback((value) => {
|
|
12
|
+
if (pendingResolverRef.current) {
|
|
13
|
+
pendingResolverRef.current(value);
|
|
14
|
+
pendingResolverRef.current = null;
|
|
15
|
+
}
|
|
16
|
+
}, []);
|
|
17
|
+
const closeModal = useCallback(() => {
|
|
18
|
+
setIsOpen(false);
|
|
19
|
+
}, []);
|
|
20
|
+
const openModal = useCallback((newConfig) => {
|
|
21
|
+
// if a confirm was in progress, resolve it as "false" (cancelled/overridden)
|
|
22
|
+
resolvePending(false);
|
|
23
|
+
setConfig(newConfig);
|
|
24
|
+
setIsOpen(true);
|
|
25
|
+
}, [resolvePending]);
|
|
26
|
+
const handleRequestClose = useCallback(() => {
|
|
27
|
+
if (config === null || config === void 0 ? void 0 : config.onRequestClose) {
|
|
28
|
+
config.onRequestClose();
|
|
29
|
+
}
|
|
30
|
+
// Any non-explicit confirm click counts as "false"
|
|
31
|
+
resolvePending(false);
|
|
32
|
+
closeModal();
|
|
33
|
+
}, [config, closeModal, resolvePending]);
|
|
34
|
+
const confirm = useCallback((confirmConfig) => {
|
|
35
|
+
return new Promise(resolve => {
|
|
36
|
+
// cancel any previous pending confirm
|
|
37
|
+
resolvePending(false);
|
|
38
|
+
pendingResolverRef.current = resolve;
|
|
39
|
+
const { confirmLabel = 'Ok', cancelLabel = 'Annuller', ...rest } = confirmConfig;
|
|
40
|
+
const primaryAction = {
|
|
41
|
+
label: confirmLabel,
|
|
42
|
+
onClick: () => {
|
|
43
|
+
resolvePending(true);
|
|
44
|
+
closeModal();
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const secondaryAction = {
|
|
48
|
+
label: cancelLabel,
|
|
49
|
+
onClick: () => {
|
|
50
|
+
resolvePending(false);
|
|
51
|
+
closeModal();
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
setConfig({
|
|
55
|
+
...rest,
|
|
56
|
+
primaryAction,
|
|
57
|
+
secondaryAction,
|
|
58
|
+
});
|
|
59
|
+
setIsOpen(true);
|
|
60
|
+
});
|
|
61
|
+
}, [closeModal, resolvePending]);
|
|
62
|
+
return (_jsxs(ModalContext.Provider, { value: { openModal, closeModal, confirm }, children: [children, _jsx(Modal, { ...(config !== null && config !== void 0 ? config : {}), isOpen: isOpen, onRequestClose: handleRequestClose, children: config === null || config === void 0 ? void 0 : config.children })] }));
|
|
63
|
+
}
|
|
64
|
+
export function useModal() {
|
|
65
|
+
const ctx = useContext(ModalContext);
|
|
66
|
+
if (!ctx) {
|
|
67
|
+
throw new Error('useModal must be used within a ModalProvider');
|
|
68
|
+
}
|
|
69
|
+
return ctx;
|
|
70
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { Severity } from '../../../constants/severity.types';
|
|
3
|
+
interface SidePanelProps {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
header: ReactNode;
|
|
6
|
+
headerAddition?: ReactNode;
|
|
7
|
+
actions: ReactNode;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
isOpen: boolean;
|
|
10
|
+
showBackdrop?: boolean;
|
|
11
|
+
severity?: Severity;
|
|
12
|
+
showHeaderMarker?: boolean;
|
|
13
|
+
width?: number | string;
|
|
14
|
+
}
|
|
15
|
+
export declare function SidePanel({ isOpen, onClose, children, header, headerAddition, actions, showBackdrop, severity, showHeaderMarker, width, ...props }: SidePanelProps & HTMLAttributes<HTMLElement>): ReactNode;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { X } from 'lucide-react';
|
|
3
|
+
import { Button } from '../../../components/button/Button';
|
|
4
|
+
import { Headline } from '../../../components/headline/Headline';
|
|
5
|
+
import styles from './SidePanel.module.css';
|
|
6
|
+
export function SidePanel({ isOpen, onClose, children, header, headerAddition, actions, showBackdrop = true, severity, showHeaderMarker = true, width = '300px', ...props }) {
|
|
7
|
+
return (_jsxs(_Fragment, { children: [isOpen && showBackdrop && (_jsx("div", { className: styles.backdrop, onClick: () => {
|
|
8
|
+
onClose();
|
|
9
|
+
} })), _jsxs("div", { ...props, className: `${styles.sidePanel} ${isOpen ? styles.open : ''}`, style: { '--side-panel-width': width }, children: [_jsx("div", { className: styles.header, children: _jsxs("div", { className: "dbc-flex dbc-justify-between", children: [_jsx(Headline, { size: 3, disableMargin: true, severity: severity, marker: showHeaderMarker, addition: headerAddition, children: header }), _jsx(Button, { type: "button", size: "sm", variant: "inline", onClick: onClose, children: _jsx(X, {}) })] }) }), _jsx("div", { className: styles.content, children: children }), _jsx("div", { className: styles.actions, children: actions })] })] }));
|
|
10
|
+
}
|