@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,41 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Button } from '../button/Button';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { X } from 'lucide-react';
|
|
4
3
|
import styles from './Toast.module.css';
|
|
4
|
+
import { Button } from '../button/Button';
|
|
5
5
|
import { Headline } from '../headline/Headline';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
title,
|
|
9
|
-
message,
|
|
10
|
-
severity = "info",
|
|
11
|
-
action,
|
|
12
|
-
onClose
|
|
13
|
-
}) {
|
|
14
|
-
return /* @__PURE__ */ jsxs("div", { className: `${styles.toast} ${styles[severity]}`, role: "status", children: [
|
|
15
|
-
/* @__PURE__ */ jsxs("div", { className: styles.content, children: [
|
|
16
|
-
/* @__PURE__ */ jsx(
|
|
17
|
-
Headline,
|
|
18
|
-
{
|
|
19
|
-
size: 4,
|
|
20
|
-
severity: title ? severity : void 0,
|
|
21
|
-
disableMargin: true,
|
|
22
|
-
addition: onClose && /* @__PURE__ */ jsx("div", { style: { marginLeft: "auto" }, children: /* @__PURE__ */ jsx(
|
|
23
|
-
Button,
|
|
24
|
-
{
|
|
25
|
-
type: "button",
|
|
26
|
-
variant: "inline",
|
|
27
|
-
"aria-label": "Dismiss notification",
|
|
28
|
-
onClick: onClose,
|
|
29
|
-
children: /* @__PURE__ */ jsx(X, { className: styles.closeIcon, "aria-hidden": "true" })
|
|
30
|
-
}
|
|
31
|
-
) }),
|
|
32
|
-
children: title
|
|
33
|
-
}
|
|
34
|
-
),
|
|
35
|
-
message && /* @__PURE__ */ jsx("div", { className: styles.message, children: message })
|
|
36
|
-
] }),
|
|
37
|
-
/* @__PURE__ */ jsx("div", { className: styles.actions, children: action && /* @__PURE__ */ jsx(Button, { type: "button", variant: "primary", onClick: action.onClick, children: action.label }) })
|
|
38
|
-
] });
|
|
6
|
+
export function Toast({ title, message, severity = 'info', action, onClose, }) {
|
|
7
|
+
return (_jsxs("div", { className: `${styles.toast} ${styles[severity]}`, role: "status", children: [_jsxs("div", { className: styles.content, children: [_jsx(Headline, { size: 4, severity: title ? severity : undefined, disableMargin: true, addition: onClose && (_jsx("div", { style: { marginLeft: 'auto' }, children: _jsx(Button, { type: "button", variant: "inline", "aria-label": "Dismiss notification", onClick: onClose, children: _jsx(X, { className: styles.closeIcon, "aria-hidden": "true" }) }) })), children: title }), message && _jsx("div", { className: styles.message, children: message })] }), _jsx("div", { className: styles.actions, children: action && (_jsx(Button, { type: "button", variant: "primary", onClick: action.onClick, children: action.label })) })] }));
|
|
39
8
|
}
|
|
40
|
-
|
|
41
|
-
export { Toast };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
+
import { Severity } from '../../../constants/severity.types';
|
|
2
3
|
import { ToastActionConfig } from '../Toast';
|
|
3
|
-
import { Severity } from '@/constants/severity.types';
|
|
4
4
|
export type ToastConfig = {
|
|
5
5
|
id?: string;
|
|
6
6
|
title?: ReactNode;
|
|
@@ -1,91 +1,64 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createContext, useState, useRef,
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useState, useRef, useEffect, } from 'react';
|
|
3
3
|
import { Toast } from '../Toast';
|
|
4
4
|
import styles from '../Toast.module.css';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
[
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
);
|
|
58
|
-
return /* @__PURE__ */ jsxs(ToastContext.Provider, { value: { showToast, hideToast, clearToasts }, children: [
|
|
59
|
-
children,
|
|
60
|
-
toasts.length > 0 && /* @__PURE__ */ jsx("div", { className: styles.container, "aria-live": "polite", "aria-atomic": "false", children: toasts.map((toast) => {
|
|
61
|
-
var _a;
|
|
62
|
-
return /* @__PURE__ */ jsx(
|
|
63
|
-
Toast,
|
|
64
|
-
{
|
|
65
|
-
title: toast.title,
|
|
66
|
-
message: toast.message,
|
|
67
|
-
severity: (_a = toast.severity) != null ? _a : "info",
|
|
68
|
-
action: toast.action && {
|
|
69
|
-
label: toast.action.label,
|
|
70
|
-
onClick: () => {
|
|
71
|
-
var _a2, _b;
|
|
72
|
-
(_b = (_a2 = toast.action) == null ? void 0 : _a2.onClick) == null ? void 0 : _b.call(_a2);
|
|
73
|
-
hideToast(toast.id);
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
onClose: () => hideToast(toast.id)
|
|
77
|
-
},
|
|
78
|
-
toast.id
|
|
79
|
-
);
|
|
80
|
-
}) })
|
|
81
|
-
] });
|
|
5
|
+
const ToastContext = createContext(undefined);
|
|
6
|
+
export function ToastProvider({ children, defaultDuration = 4000, }) {
|
|
7
|
+
const [toasts, setToasts] = useState([]);
|
|
8
|
+
const timeouts = useRef(new Map());
|
|
9
|
+
const clearTimeoutForId = (id) => {
|
|
10
|
+
const timeoutId = timeouts.current.get(id);
|
|
11
|
+
if (timeoutId) {
|
|
12
|
+
window.clearTimeout(timeoutId);
|
|
13
|
+
timeouts.current.delete(id);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const hideToast = useCallback((id) => {
|
|
17
|
+
clearTimeoutForId(id);
|
|
18
|
+
setToasts(prev => prev.filter(t => t.id !== id));
|
|
19
|
+
}, []);
|
|
20
|
+
const scheduleAutoDismiss = useCallback((toast) => {
|
|
21
|
+
var _a;
|
|
22
|
+
const duration = (_a = toast.duration) !== null && _a !== void 0 ? _a : defaultDuration;
|
|
23
|
+
if (!duration || duration <= 0)
|
|
24
|
+
return;
|
|
25
|
+
clearTimeoutForId(toast.id);
|
|
26
|
+
const timeoutId = window.setTimeout(() => {
|
|
27
|
+
hideToast(toast.id);
|
|
28
|
+
}, duration);
|
|
29
|
+
timeouts.current.set(toast.id, timeoutId);
|
|
30
|
+
}, [defaultDuration, hideToast]);
|
|
31
|
+
const showToast = useCallback((config) => {
|
|
32
|
+
var _a, _b, _c;
|
|
33
|
+
const id = (_c = (_a = config.id) !== null && _a !== void 0 ? _a : (_b = crypto.randomUUID) === null || _b === void 0 ? void 0 : _b.call(crypto)) !== null && _c !== void 0 ? _c : `${Date.now()}-${Math.random()}`;
|
|
34
|
+
const toast = { ...config, id };
|
|
35
|
+
setToasts(prev => [...prev, toast]);
|
|
36
|
+
scheduleAutoDismiss(toast);
|
|
37
|
+
return id;
|
|
38
|
+
}, [scheduleAutoDismiss]);
|
|
39
|
+
const clearToasts = useCallback(() => {
|
|
40
|
+
toasts.forEach(t => clearTimeoutForId(t.id));
|
|
41
|
+
setToasts([]);
|
|
42
|
+
}, [toasts]);
|
|
43
|
+
useEffect(() => () => {
|
|
44
|
+
toasts.forEach(t => clearTimeoutForId(t.id));
|
|
45
|
+
}, [toasts]);
|
|
46
|
+
return (_jsxs(ToastContext.Provider, { value: { showToast, hideToast, clearToasts }, children: [children, toasts.length > 0 && (_jsx("div", { className: styles.container, "aria-live": "polite", "aria-atomic": "false", children: toasts.map(toast => {
|
|
47
|
+
var _a;
|
|
48
|
+
return (_jsx(Toast, { title: toast.title, message: toast.message, severity: (_a = toast.severity) !== null && _a !== void 0 ? _a : 'info', action: toast.action && {
|
|
49
|
+
label: toast.action.label,
|
|
50
|
+
onClick: () => {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
(_b = (_a = toast.action) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
53
|
+
hideToast(toast.id);
|
|
54
|
+
},
|
|
55
|
+
}, onClose: () => hideToast(toast.id) }, toast.id));
|
|
56
|
+
}) }))] }));
|
|
82
57
|
}
|
|
83
|
-
function useToast() {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
58
|
+
export function useToast() {
|
|
59
|
+
const ctx = useContext(ToastContext);
|
|
60
|
+
if (!ctx) {
|
|
61
|
+
throw new Error('useToast must be used within a ToastProvider');
|
|
62
|
+
}
|
|
63
|
+
return ctx;
|
|
89
64
|
}
|
|
90
|
-
|
|
91
|
-
export { ToastProvider, useToast };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
1
2
|
interface UserDisplayProps {
|
|
2
3
|
id?: string;
|
|
3
4
|
name?: string;
|
|
@@ -5,5 +6,5 @@ interface UserDisplayProps {
|
|
|
5
6
|
role?: string;
|
|
6
7
|
avatarUrl?: string;
|
|
7
8
|
}
|
|
8
|
-
export declare function UserDisplay({
|
|
9
|
+
export declare function UserDisplay({ name, email, role, avatarUrl }: UserDisplayProps): ReactNode;
|
|
9
10
|
export {};
|
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Avatar } from '../avatar/Avatar';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import styles from './UserDisplay.module.css';
|
|
4
|
-
|
|
5
|
-
function UserDisplay({
|
|
6
|
-
|
|
7
|
-
name,
|
|
8
|
-
email,
|
|
9
|
-
role,
|
|
10
|
-
avatarUrl
|
|
11
|
-
}) {
|
|
12
|
-
return /* @__PURE__ */ jsxs("div", { className: styles.container, children: [
|
|
13
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Avatar, { imgSrc: avatarUrl, imgAlt: name, fullName: name, size: "xl" }) }),
|
|
14
|
-
/* @__PURE__ */ jsxs("div", { className: styles.userInfo, children: [
|
|
15
|
-
/* @__PURE__ */ jsx("h4", { children: name }),
|
|
16
|
-
/* @__PURE__ */ jsx("p", { children: email }),
|
|
17
|
-
/* @__PURE__ */ jsx("p", { children: role })
|
|
18
|
-
] })
|
|
19
|
-
] });
|
|
3
|
+
import { Avatar } from '../avatar/Avatar';
|
|
4
|
+
export function UserDisplay({ name, email, role, avatarUrl }) {
|
|
5
|
+
return (_jsxs("div", { className: styles.container, children: [_jsx("div", { children: _jsx(Avatar, { imgSrc: avatarUrl, imgAlt: name, fullName: name, size: "xl" }) }), _jsxs("div", { className: styles.userInfo, children: [_jsx("h4", { children: name }), _jsx("p", { children: email }), _jsx("p", { children: role })] })] }));
|
|
20
6
|
}
|
|
21
|
-
|
|
22
|
-
export { UserDisplay };
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
const SeverityBgColor = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export const SeverityBgColor = {
|
|
2
|
+
neutral: 'var(--color-neutral-strong)',
|
|
3
|
+
brand: 'var(--color-brand)',
|
|
4
|
+
success: 'var(--color-status-success)',
|
|
5
|
+
error: 'var(--color-status-error)',
|
|
6
|
+
info: 'var(--color-status-info)',
|
|
7
|
+
warning: 'var(--color-status-warning)',
|
|
8
8
|
};
|
|
9
|
-
const SeverityTextColor = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
export const SeverityTextColor = {
|
|
10
|
+
neutral: 'var(--color-neutral-strong-fg)',
|
|
11
|
+
brand: 'var(--color-fg-on-brand)',
|
|
12
|
+
success: 'var(--color-status-success-fg)',
|
|
13
|
+
error: 'var(--color-status-error-fg)',
|
|
14
|
+
info: 'var(--color-status-info-fg)',
|
|
15
|
+
warning: 'var(--color-status-warning-fg)',
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
export { SeverityBgColor, SeverityTextColor };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type Severity =
|
|
1
|
+
export type Severity = 'neutral' | 'brand' | 'success' | 'error' | 'info' | 'warning';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
package/dist/constants/sizes.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
const sizes = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export const sizes = {
|
|
2
|
+
xs: 'var(--component-size-xs)',
|
|
3
|
+
sm: 'var(--component-size-sm)',
|
|
4
|
+
md: 'var(--component-size-md)',
|
|
5
|
+
lg: 'var(--component-size-lg)',
|
|
6
|
+
xl: 'var(--component-size-xl)',
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
export { sizes };
|
|
@@ -1,86 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
function clamp(n, min, max) {
|
|
4
|
-
|
|
4
|
+
return Math.max(min, Math.min(max, n));
|
|
5
5
|
}
|
|
6
|
-
function usePagination({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
onStateChange,
|
|
12
|
-
resetOnDataChange = false
|
|
13
|
-
}) {
|
|
14
|
-
const isControlled = state != null;
|
|
15
|
-
const [uncontrolled, setUncontrolled] = useState(() => ({
|
|
16
|
-
skip: Math.max(0, skip),
|
|
17
|
-
take: Math.max(1, take)
|
|
18
|
-
}));
|
|
19
|
-
const didInitRef = useRef(false);
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
if (isControlled) return;
|
|
22
|
-
if (!didInitRef.current) {
|
|
23
|
-
didInitRef.current = true;
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
setUncontrolled((prev) => ({
|
|
27
|
-
skip: prev.skip,
|
|
28
|
-
take: Math.max(1, take)
|
|
6
|
+
export function usePagination({ data = [], skip = 0, take = 10, state, onStateChange, resetOnDataChange = false, }) {
|
|
7
|
+
const isControlled = state != null;
|
|
8
|
+
const [uncontrolled, setUncontrolled] = useState(() => ({
|
|
9
|
+
skip: Math.max(0, skip),
|
|
10
|
+
take: Math.max(1, take),
|
|
29
11
|
}));
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
12
|
+
// Keep initial props in sync ONLY for uncontrolled if props change.
|
|
13
|
+
// (For controlled, parent owns state.)
|
|
14
|
+
const didInitRef = useRef(false);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (isControlled)
|
|
17
|
+
return;
|
|
18
|
+
if (!didInitRef.current) {
|
|
19
|
+
didInitRef.current = true;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
setUncontrolled(prev => ({
|
|
23
|
+
skip: prev.skip,
|
|
24
|
+
take: Math.max(1, take),
|
|
25
|
+
}));
|
|
26
|
+
}, [isControlled, take]);
|
|
27
|
+
const paginationState = (isControlled ? state : uncontrolled);
|
|
28
|
+
const totalCount = data.length;
|
|
29
|
+
const safeTake = Math.max(1, paginationState.take);
|
|
30
|
+
const maxSkip = Math.max(0, totalCount === 0 ? 0 : Math.floor((totalCount - 1) / safeTake) * safeTake);
|
|
31
|
+
const safeSkip = clamp(Math.max(0, paginationState.skip), 0, maxSkip);
|
|
32
|
+
const setPagination = useCallback((next) => {
|
|
33
|
+
const normalized = {
|
|
34
|
+
take: Math.max(1, next.take),
|
|
35
|
+
skip: Math.max(0, next.skip),
|
|
36
|
+
};
|
|
37
|
+
if (isControlled)
|
|
38
|
+
onStateChange === null || onStateChange === void 0 ? void 0 : onStateChange(normalized);
|
|
39
|
+
else
|
|
40
|
+
setUncontrolled(normalized);
|
|
41
|
+
}, [isControlled, onStateChange]);
|
|
42
|
+
const onPageChange = useCallback((pageEvent) => {
|
|
43
|
+
const nextTake = Math.max(1, pageEvent.take);
|
|
44
|
+
const nextSkip = Math.max(0, (pageEvent.page - 1) * nextTake);
|
|
45
|
+
setPagination({ skip: nextSkip, take: nextTake });
|
|
46
|
+
}, [setPagination]);
|
|
47
|
+
const resetPage = useCallback(() => {
|
|
48
|
+
setPagination({ skip: 0, take: safeTake });
|
|
49
|
+
}, [setPagination, safeTake]);
|
|
50
|
+
// Optional: reset page when data reference changes (after sort/filter).
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (!resetOnDataChange)
|
|
53
|
+
return;
|
|
54
|
+
resetPage();
|
|
55
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
|
+
}, [resetOnDataChange, data]);
|
|
57
|
+
const paginatedData = useMemo(() => {
|
|
58
|
+
// Use safeSkip to avoid slicing past end if data shrinks.
|
|
59
|
+
return data.slice(safeSkip, safeSkip + safeTake);
|
|
60
|
+
}, [data, safeSkip, safeTake]);
|
|
61
|
+
const page = useMemo(() => Math.floor(safeSkip / safeTake) + 1, [safeSkip, safeTake]);
|
|
62
|
+
// If uncontrolled and data shrinks such that skip becomes invalid, clamp it once.
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (isControlled)
|
|
65
|
+
return;
|
|
66
|
+
if (safeSkip !== paginationState.skip) {
|
|
67
|
+
setUncontrolled(prev => ({ ...prev, skip: safeSkip }));
|
|
68
|
+
}
|
|
69
|
+
}, [isControlled, safeSkip, paginationState.skip]);
|
|
70
|
+
return {
|
|
71
|
+
paginatedData,
|
|
72
|
+
paginationState: { skip: safeSkip, take: safeTake },
|
|
73
|
+
onPageChange,
|
|
74
|
+
setPagination,
|
|
75
|
+
resetPage,
|
|
76
|
+
page,
|
|
77
|
+
totalCount,
|
|
78
|
+
};
|
|
84
79
|
}
|
|
85
|
-
|
|
86
|
-
export { usePagination };
|