@robr0/design-system 0.1.0
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/LICENSE +21 -0
- package/README.md +127 -0
- package/charts.d.ts +14 -0
- package/charts.js +20 -0
- package/components/Accordion/Accordion.css +119 -0
- package/components/Accordion/Accordion.d.ts +24 -0
- package/components/Accordion/Accordion.js +76 -0
- package/components/Alert/Alert.css +252 -0
- package/components/Alert/Alert.d.ts +24 -0
- package/components/Alert/Alert.js +53 -0
- package/components/AlertDialog/AlertDialog.css +131 -0
- package/components/AlertDialog/AlertDialog.d.ts +29 -0
- package/components/AlertDialog/AlertDialog.js +143 -0
- package/components/AppLayout/AppLayout.css +52 -0
- package/components/AppLayout/AppLayout.d.ts +27 -0
- package/components/AppLayout/AppLayout.js +45 -0
- package/components/AppSidebar/AppSidebar.css +434 -0
- package/components/AppSidebar/AppSidebar.d.ts +67 -0
- package/components/AppSidebar/AppSidebar.js +272 -0
- package/components/Avatar/Avatar.css +133 -0
- package/components/Avatar/Avatar.d.ts +20 -0
- package/components/Avatar/Avatar.js +56 -0
- package/components/Avatar/demoAvatars.d.ts +14 -0
- package/components/Avatar/demoAvatars.js +16 -0
- package/components/Badge/Badge.css +68 -0
- package/components/Badge/Badge.d.ts +13 -0
- package/components/Badge/Badge.js +15 -0
- package/components/Breadcrumb/Breadcrumb.css +92 -0
- package/components/Breadcrumb/Breadcrumb.d.ts +19 -0
- package/components/Breadcrumb/Breadcrumb.js +39 -0
- package/components/Button/Button.css +381 -0
- package/components/Button/Button.d.ts +39 -0
- package/components/Button/Button.js +71 -0
- package/components/ButtonGroup/ButtonGroup.css +39 -0
- package/components/ButtonGroup/ButtonGroup.d.ts +13 -0
- package/components/ButtonGroup/ButtonGroup.js +37 -0
- package/components/Card/Card.css +169 -0
- package/components/Card/Card.d.ts +30 -0
- package/components/Card/Card.js +90 -0
- package/components/Carousel/Carousel.css +112 -0
- package/components/Carousel/Carousel.d.ts +25 -0
- package/components/Carousel/Carousel.js +126 -0
- package/components/Chart/AreaChart.d.ts +36 -0
- package/components/Chart/AreaChart.js +99 -0
- package/components/Chart/BarChart.d.ts +34 -0
- package/components/Chart/BarChart.js +107 -0
- package/components/Chart/Chart.css +176 -0
- package/components/Chart/LineChart.d.ts +34 -0
- package/components/Chart/LineChart.js +90 -0
- package/components/Chart/PieChart.d.ts +34 -0
- package/components/Chart/PieChart.js +106 -0
- package/components/Chart/RadarChart.d.ts +34 -0
- package/components/Chart/RadarChart.js +91 -0
- package/components/Chart/RadialChart.d.ts +37 -0
- package/components/Chart/RadialChart.js +119 -0
- package/components/Chart/ScatterChart.d.ts +36 -0
- package/components/Chart/ScatterChart.js +109 -0
- package/components/Chart/StackedBarChart.d.ts +34 -0
- package/components/Chart/StackedBarChart.js +111 -0
- package/components/Chart/Treemap.d.ts +33 -0
- package/components/Chart/Treemap.js +109 -0
- package/components/Checkbox/Checkbox.css +164 -0
- package/components/Checkbox/Checkbox.d.ts +45 -0
- package/components/Checkbox/Checkbox.js +125 -0
- package/components/Chip/Chip.css +195 -0
- package/components/Chip/Chip.d.ts +27 -0
- package/components/Chip/Chip.js +80 -0
- package/components/CircularButton/CircularButton.css +206 -0
- package/components/CircularButton/CircularButton.d.ts +30 -0
- package/components/CircularButton/CircularButton.js +54 -0
- package/components/CodeBlock/CodeBlock.css +180 -0
- package/components/CodeBlock/CodeBlock.d.ts +23 -0
- package/components/CodeBlock/CodeBlock.js +85 -0
- package/components/ColourSwatch/ColourSwatch.css +88 -0
- package/components/ColourSwatch/ColourSwatch.d.ts +34 -0
- package/components/ColourSwatch/ColourSwatch.js +42 -0
- package/components/Combobox/Combobox.css +411 -0
- package/components/Combobox/Combobox.d.ts +73 -0
- package/components/Combobox/Combobox.js +312 -0
- package/components/CommandPalette/CommandPalette.css +310 -0
- package/components/CommandPalette/CommandPalette.d.ts +60 -0
- package/components/CommandPalette/CommandPalette.js +263 -0
- package/components/ContactCard/ContactCard.css +123 -0
- package/components/ContactCard/ContactCard.d.ts +23 -0
- package/components/ContactCard/ContactCard.js +78 -0
- package/components/ContributionGraph/ContributionGraph.css +142 -0
- package/components/ContributionGraph/ContributionGraph.d.ts +26 -0
- package/components/ContributionGraph/ContributionGraph.js +125 -0
- package/components/DateInput/DateInput.css +163 -0
- package/components/DateInput/DateInput.d.ts +43 -0
- package/components/DateInput/DateInput.js +69 -0
- package/components/DatePicker/DatePicker.css +198 -0
- package/components/DatePicker/DatePicker.d.ts +22 -0
- package/components/DatePicker/DatePicker.js +170 -0
- package/components/Dialog/Dialog.css +176 -0
- package/components/Dialog/Dialog.d.ts +28 -0
- package/components/Dialog/Dialog.js +132 -0
- package/components/Divider/Divider.css +100 -0
- package/components/Divider/Divider.d.ts +18 -0
- package/components/Divider/Divider.js +31 -0
- package/components/Drawer/Drawer.css +262 -0
- package/components/Drawer/Drawer.d.ts +30 -0
- package/components/Drawer/Drawer.js +134 -0
- package/components/Dropdown/Dropdown.css +300 -0
- package/components/Dropdown/Dropdown.d.ts +48 -0
- package/components/Dropdown/Dropdown.js +196 -0
- package/components/DropdownMenu/DropdownMenu.css +303 -0
- package/components/DropdownMenu/DropdownMenu.d.ts +42 -0
- package/components/DropdownMenu/DropdownMenu.js +322 -0
- package/components/EmptyState/EmptyState.css +115 -0
- package/components/EmptyState/EmptyState.d.ts +27 -0
- package/components/EmptyState/EmptyState.js +32 -0
- package/components/EntityCard/EntityCard.css +69 -0
- package/components/EntityCard/EntityCard.d.ts +18 -0
- package/components/EntityCard/EntityCard.js +26 -0
- package/components/Figure/Figure.css +61 -0
- package/components/Figure/Figure.d.ts +17 -0
- package/components/Figure/Figure.js +35 -0
- package/components/FileInput/FileInput.css +308 -0
- package/components/FileInput/FileInput.d.ts +54 -0
- package/components/FileInput/FileInput.js +177 -0
- package/components/Input/Input.css +193 -0
- package/components/Input/Input.d.ts +40 -0
- package/components/Input/Input.js +71 -0
- package/components/Instructions/Instructions.css +216 -0
- package/components/Instructions/Instructions.d.ts +28 -0
- package/components/Instructions/Instructions.js +32 -0
- package/components/LinkList/LinkList.css +71 -0
- package/components/LinkList/LinkList.d.ts +20 -0
- package/components/LinkList/LinkList.js +41 -0
- package/components/MotionSwatch/MotionSwatch.css +176 -0
- package/components/MotionSwatch/MotionSwatch.d.ts +25 -0
- package/components/MotionSwatch/MotionSwatch.js +74 -0
- package/components/Nav/Nav.css +51 -0
- package/components/Nav/Nav.d.ts +19 -0
- package/components/Nav/Nav.js +26 -0
- package/components/Pagination/Pagination.css +126 -0
- package/components/Pagination/Pagination.d.ts +22 -0
- package/components/Pagination/Pagination.js +83 -0
- package/components/Popover/Popover.css +99 -0
- package/components/Popover/Popover.d.ts +28 -0
- package/components/Popover/Popover.js +102 -0
- package/components/ProgressBar/ProgressBar.css +60 -0
- package/components/ProgressBar/ProgressBar.d.ts +16 -0
- package/components/ProgressBar/ProgressBar.js +27 -0
- package/components/Quote/Quote.css +79 -0
- package/components/Quote/Quote.d.ts +18 -0
- package/components/Quote/Quote.js +26 -0
- package/components/RadioButton/RadioButton.css +132 -0
- package/components/RadioButton/RadioButton.d.ts +43 -0
- package/components/RadioButton/RadioButton.js +77 -0
- package/components/SectionTitle/SectionTitle.css +37 -0
- package/components/SectionTitle/SectionTitle.d.ts +10 -0
- package/components/SectionTitle/SectionTitle.js +17 -0
- package/components/SegmentedControl/SegmentedControl.css +129 -0
- package/components/SegmentedControl/SegmentedControl.d.ts +33 -0
- package/components/SegmentedControl/SegmentedControl.js +91 -0
- package/components/SelectionCard/SelectionCard.css +251 -0
- package/components/SelectionCard/SelectionCard.d.ts +26 -0
- package/components/SelectionCard/SelectionCard.js +85 -0
- package/components/Skeleton/Skeleton.css +79 -0
- package/components/Skeleton/Skeleton.d.ts +16 -0
- package/components/Skeleton/Skeleton.js +30 -0
- package/components/Slider/Slider.css +86 -0
- package/components/Slider/Slider.d.ts +25 -0
- package/components/Slider/Slider.js +46 -0
- package/components/SpacingSwatch/SpacingSwatch.css +108 -0
- package/components/SpacingSwatch/SpacingSwatch.d.ts +20 -0
- package/components/SpacingSwatch/SpacingSwatch.js +50 -0
- package/components/Spinner/Spinner.css +73 -0
- package/components/Spinner/Spinner.d.ts +14 -0
- package/components/Spinner/Spinner.js +42 -0
- package/components/Stat/Stat.css +78 -0
- package/components/Stat/Stat.d.ts +19 -0
- package/components/Stat/Stat.js +30 -0
- package/components/Table/Table.css +186 -0
- package/components/Table/Table.d.ts +45 -0
- package/components/Table/Table.js +65 -0
- package/components/Tabs/Tabs.css +140 -0
- package/components/Tabs/Tabs.d.ts +28 -0
- package/components/Tabs/Tabs.js +77 -0
- package/components/Textarea/Textarea.css +152 -0
- package/components/Textarea/Textarea.d.ts +40 -0
- package/components/Textarea/Textarea.js +74 -0
- package/components/Timeline/Timeline.css +339 -0
- package/components/Timeline/Timeline.d.ts +63 -0
- package/components/Timeline/Timeline.js +69 -0
- package/components/Toast/Toast.css +342 -0
- package/components/Toast/Toast.d.ts +63 -0
- package/components/Toast/Toast.js +213 -0
- package/components/ToggleGroup/ToggleGroup.css +84 -0
- package/components/ToggleGroup/ToggleGroup.d.ts +30 -0
- package/components/ToggleGroup/ToggleGroup.js +53 -0
- package/components/ToggleSwitch/ToggleSwitch.css +139 -0
- package/components/ToggleSwitch/ToggleSwitch.d.ts +23 -0
- package/components/ToggleSwitch/ToggleSwitch.js +50 -0
- package/components/Tooltip/Tooltip.css +122 -0
- package/components/Tooltip/Tooltip.d.ts +21 -0
- package/components/Tooltip/Tooltip.js +63 -0
- package/components/TypographySwatch/TypographySwatch.css +81 -0
- package/components/TypographySwatch/TypographySwatch.d.ts +24 -0
- package/components/TypographySwatch/TypographySwatch.js +40 -0
- package/components/registry.d.ts +20 -0
- package/components/registry.js +7 -0
- package/components/registry.json +67 -0
- package/components/registry.json.d.ts +70 -0
- package/components/registry.json.js +8 -0
- package/fonts/MaterialSymbolsRounded-VariableFont_FILL,GRAD,opsz,wght.woff2 +0 -0
- package/fonts/material-symbols.css +94 -0
- package/index.d.ts +62 -0
- package/index.js +123 -0
- package/package.json +63 -0
- package/tokens/registry.d.ts +22 -0
- package/tokens/registry.js +14 -0
- package/tokens/registry.json +203 -0
- package/tokens/registry.json.d.ts +206 -0
- package/tokens/registry.json.js +8 -0
- package/tokens/tokens-dark.css +119 -0
- package/tokens/tokens-light.css +159 -0
- package/tokens/tokens-motion.css +68 -0
- package/tokens/tokens-primitives.css +176 -0
- package/tokens/tokens-typography.css +116 -0
- package/tokens/tokens.css +11 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import "./Alert.css";
|
|
3
|
+
import "../../fonts/material-symbols.css";
|
|
4
|
+
const defaultIcons = {
|
|
5
|
+
info: "info",
|
|
6
|
+
positive: "check_circle",
|
|
7
|
+
warning: "warning",
|
|
8
|
+
error: "error",
|
|
9
|
+
neutral: "info"
|
|
10
|
+
};
|
|
11
|
+
const Alert = ({
|
|
12
|
+
title,
|
|
13
|
+
description,
|
|
14
|
+
variant = "info",
|
|
15
|
+
size = "default",
|
|
16
|
+
dismissible = false,
|
|
17
|
+
icon,
|
|
18
|
+
onDismiss,
|
|
19
|
+
className = ""
|
|
20
|
+
}) => {
|
|
21
|
+
const baseClass = "ds-alert";
|
|
22
|
+
const variantClass = `${baseClass}--${variant}`;
|
|
23
|
+
const sizeClass = `${baseClass}--${size}`;
|
|
24
|
+
const classes = [baseClass, variantClass, sizeClass, className].filter(Boolean).join(" ");
|
|
25
|
+
const iconName = icon || defaultIcons[variant];
|
|
26
|
+
return /* @__PURE__ */ jsxs("div", { className: classes, role: "alert", children: [
|
|
27
|
+
/* @__PURE__ */ jsx(
|
|
28
|
+
"span",
|
|
29
|
+
{
|
|
30
|
+
className: `${baseClass}__icon material-symbols-rounded`,
|
|
31
|
+
"aria-hidden": "true",
|
|
32
|
+
children: iconName
|
|
33
|
+
}
|
|
34
|
+
),
|
|
35
|
+
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__content`, children: [
|
|
36
|
+
title && /* @__PURE__ */ jsx("p", { className: `${baseClass}__title`, children: title }),
|
|
37
|
+
description && /* @__PURE__ */ jsx("p", { className: `${baseClass}__description`, children: description })
|
|
38
|
+
] }),
|
|
39
|
+
dismissible && /* @__PURE__ */ jsx(
|
|
40
|
+
"button",
|
|
41
|
+
{
|
|
42
|
+
type: "button",
|
|
43
|
+
className: `${baseClass}__dismiss`,
|
|
44
|
+
onClick: onDismiss,
|
|
45
|
+
"aria-label": "Dismiss alert",
|
|
46
|
+
children: /* @__PURE__ */ jsx("span", { className: "material-symbols-rounded", "aria-hidden": "true", children: "close" })
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
] });
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
Alert
|
|
53
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
ALERT DIALOG COMPONENT
|
|
3
|
+
Modal confirmation with backdrop overlay
|
|
4
|
+
============================================ */
|
|
5
|
+
|
|
6
|
+
.ds-alert-dialog {
|
|
7
|
+
position: fixed;
|
|
8
|
+
inset: 0;
|
|
9
|
+
z-index: 100;
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
opacity: 0;
|
|
14
|
+
pointer-events: none;
|
|
15
|
+
transition: opacity var(--motion-duration-base) var(--motion-ease-standard);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.ds-alert-dialog--open {
|
|
19
|
+
opacity: 1;
|
|
20
|
+
pointer-events: auto;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* ============================================
|
|
24
|
+
BACKDROP
|
|
25
|
+
============================================ */
|
|
26
|
+
|
|
27
|
+
.ds-alert-dialog__backdrop {
|
|
28
|
+
position: absolute;
|
|
29
|
+
inset: 0;
|
|
30
|
+
background-color: var(--color-scrim);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* ============================================
|
|
34
|
+
PANEL
|
|
35
|
+
============================================ */
|
|
36
|
+
|
|
37
|
+
.ds-alert-dialog__panel {
|
|
38
|
+
position: relative;
|
|
39
|
+
z-index: 1;
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
gap: var(--gap-md); /* 16px */
|
|
43
|
+
min-width: 320px;
|
|
44
|
+
max-width: 480px;
|
|
45
|
+
padding: var(--padding-lg); /* 20px */
|
|
46
|
+
border: var(--border-xs) solid var(--color-bg-container-border);
|
|
47
|
+
border-radius: var(--radius-md); /* 12px */
|
|
48
|
+
background-color: var(--color-bg-page-primary);
|
|
49
|
+
box-shadow: var(--shadow-modal);
|
|
50
|
+
transform: scale(0.96);
|
|
51
|
+
transition: transform var(--motion-duration-base) var(--motion-ease-standard);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.ds-alert-dialog--open .ds-alert-dialog__panel {
|
|
55
|
+
transform: scale(1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* ============================================
|
|
59
|
+
HEADER
|
|
60
|
+
============================================ */
|
|
61
|
+
|
|
62
|
+
.ds-alert-dialog__header {
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
gap: var(--gap-sm); /* 8px */
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.ds-alert-dialog__icon {
|
|
69
|
+
flex-shrink: 0;
|
|
70
|
+
--icon-size: var(--icon-size-md);
|
|
71
|
+
line-height: 1;
|
|
72
|
+
color: var(--color-icon-primary);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.ds-alert-dialog--destructive .ds-alert-dialog__icon {
|
|
76
|
+
color: var(--color-status-error-border);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* ============================================
|
|
80
|
+
TITLE
|
|
81
|
+
============================================ */
|
|
82
|
+
|
|
83
|
+
.ds-alert-dialog__title {
|
|
84
|
+
font-family: var(--font-heading-6-family);
|
|
85
|
+
font-size: var(--font-heading-6-size);
|
|
86
|
+
font-weight: var(--font-heading-6-weight);
|
|
87
|
+
line-height: var(--font-heading-6-line-height);
|
|
88
|
+
letter-spacing: var(--font-heading-6-letter-spacing);
|
|
89
|
+
color: var(--color-text-primary);
|
|
90
|
+
margin: 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.ds-alert-dialog--destructive .ds-alert-dialog__title {
|
|
94
|
+
color: var(--color-status-error-border);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* ============================================
|
|
98
|
+
DESCRIPTION
|
|
99
|
+
============================================ */
|
|
100
|
+
|
|
101
|
+
.ds-alert-dialog__description {
|
|
102
|
+
font-family: var(--font-paragraph-family);
|
|
103
|
+
font-size: var(--font-paragraph-size);
|
|
104
|
+
font-weight: var(--font-paragraph-weight);
|
|
105
|
+
line-height: var(--font-paragraph-line-height);
|
|
106
|
+
letter-spacing: var(--font-paragraph-letter-spacing);
|
|
107
|
+
color: var(--color-text-secondary);
|
|
108
|
+
margin: 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* ============================================
|
|
112
|
+
ACTIONS
|
|
113
|
+
============================================ */
|
|
114
|
+
|
|
115
|
+
.ds-alert-dialog__actions {
|
|
116
|
+
display: flex;
|
|
117
|
+
justify-content: flex-end;
|
|
118
|
+
gap: var(--gap-sm); /* 8px */
|
|
119
|
+
padding-top: var(--padding-xs); /* 6px */
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* ============================================
|
|
123
|
+
RESPONSIVE
|
|
124
|
+
============================================ */
|
|
125
|
+
|
|
126
|
+
@media (max-width: 480px) {
|
|
127
|
+
.ds-alert-dialog__panel {
|
|
128
|
+
min-width: auto;
|
|
129
|
+
margin: var(--padding-md);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface AlertDialogProps {
|
|
2
|
+
/** Whether the dialog is open */
|
|
3
|
+
open: boolean;
|
|
4
|
+
/** Callback when dialog requests to close */
|
|
5
|
+
onOpenChange: (open: boolean) => void;
|
|
6
|
+
/** Dialog title */
|
|
7
|
+
title: string;
|
|
8
|
+
/** Dialog description / body text */
|
|
9
|
+
description?: string;
|
|
10
|
+
/** Confirm button label */
|
|
11
|
+
confirmLabel?: string;
|
|
12
|
+
/** Cancel button label */
|
|
13
|
+
cancelLabel?: string;
|
|
14
|
+
/** Callback when confirm is clicked */
|
|
15
|
+
onConfirm?: () => void;
|
|
16
|
+
/** Callback when cancel is clicked */
|
|
17
|
+
onCancel?: () => void;
|
|
18
|
+
/** Destructive variant for dangerous actions */
|
|
19
|
+
variant?: 'default' | 'destructive';
|
|
20
|
+
/** Additional CSS classes */
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* AlertDialog component for important confirmations.
|
|
25
|
+
* Renders a modal overlay with title, description,
|
|
26
|
+
* and confirm / cancel actions. Traps focus and
|
|
27
|
+
* supports ESC key dismissal.
|
|
28
|
+
*/
|
|
29
|
+
export declare const AlertDialog: ({ open, onOpenChange, title, description, confirmLabel, cancelLabel, onConfirm, onCancel, variant, className, }: AlertDialogProps) => import('react').ReactPortal | null;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useId, useSyncExternalStore, useCallback, useEffect } from "react";
|
|
3
|
+
import ReactDOM from "react-dom";
|
|
4
|
+
import { Button } from "../Button/Button.js";
|
|
5
|
+
import "./AlertDialog.css";
|
|
6
|
+
import "../../fonts/material-symbols.css";
|
|
7
|
+
const emptySubscribe = () => () => {
|
|
8
|
+
};
|
|
9
|
+
const AlertDialog = ({
|
|
10
|
+
open,
|
|
11
|
+
onOpenChange,
|
|
12
|
+
title,
|
|
13
|
+
description,
|
|
14
|
+
confirmLabel = "Confirm",
|
|
15
|
+
cancelLabel = "Cancel",
|
|
16
|
+
onConfirm,
|
|
17
|
+
onCancel,
|
|
18
|
+
variant = "default",
|
|
19
|
+
className = ""
|
|
20
|
+
}) => {
|
|
21
|
+
const panelRef = useRef(null);
|
|
22
|
+
const previousFocusRef = useRef(null);
|
|
23
|
+
const titleId = useId();
|
|
24
|
+
const descId = useId();
|
|
25
|
+
const baseClass = "ds-alert-dialog";
|
|
26
|
+
const mounted = useSyncExternalStore(emptySubscribe, () => true, () => false);
|
|
27
|
+
const handleCancel = useCallback(() => {
|
|
28
|
+
onCancel?.();
|
|
29
|
+
onOpenChange(false);
|
|
30
|
+
}, [onCancel, onOpenChange]);
|
|
31
|
+
const handleConfirm = useCallback(() => {
|
|
32
|
+
onConfirm?.();
|
|
33
|
+
onOpenChange(false);
|
|
34
|
+
}, [onConfirm, onOpenChange]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (open) {
|
|
37
|
+
previousFocusRef.current = document.activeElement;
|
|
38
|
+
}
|
|
39
|
+
}, [open]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!open) return;
|
|
42
|
+
const panel = panelRef.current;
|
|
43
|
+
if (panel) {
|
|
44
|
+
const cancelBtn = panel.querySelector(
|
|
45
|
+
`.${baseClass}__actions button:first-child`
|
|
46
|
+
);
|
|
47
|
+
cancelBtn?.focus();
|
|
48
|
+
}
|
|
49
|
+
const handleKeyDown = (e) => {
|
|
50
|
+
if (e.key === "Escape") {
|
|
51
|
+
handleCancel();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (e.key === "Tab" && panel) {
|
|
55
|
+
const focusable = panel.querySelectorAll(
|
|
56
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
57
|
+
);
|
|
58
|
+
if (focusable.length === 0) return;
|
|
59
|
+
const first = focusable[0];
|
|
60
|
+
const last = focusable[focusable.length - 1];
|
|
61
|
+
if (e.shiftKey && document.activeElement === first) {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
last.focus();
|
|
64
|
+
} else if (!e.shiftKey && document.activeElement === last) {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
first.focus();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
71
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
72
|
+
}, [open, handleCancel]);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (!open && previousFocusRef.current) {
|
|
75
|
+
previousFocusRef.current.focus();
|
|
76
|
+
previousFocusRef.current = null;
|
|
77
|
+
}
|
|
78
|
+
}, [open]);
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (open) {
|
|
81
|
+
document.body.style.overflow = "hidden";
|
|
82
|
+
} else {
|
|
83
|
+
document.body.style.overflow = "";
|
|
84
|
+
}
|
|
85
|
+
return () => {
|
|
86
|
+
document.body.style.overflow = "";
|
|
87
|
+
};
|
|
88
|
+
}, [open]);
|
|
89
|
+
const variantClass = variant !== "default" ? `${baseClass}--${variant}` : "";
|
|
90
|
+
const openClass = open ? `${baseClass}--open` : "";
|
|
91
|
+
const containerClasses = [baseClass, variantClass, openClass, className].filter(Boolean).join(" ");
|
|
92
|
+
const dialog = /* @__PURE__ */ jsxs("div", { className: containerClasses, children: [
|
|
93
|
+
/* @__PURE__ */ jsx("div", { className: `${baseClass}__backdrop`, onClick: handleCancel }),
|
|
94
|
+
/* @__PURE__ */ jsxs(
|
|
95
|
+
"div",
|
|
96
|
+
{
|
|
97
|
+
className: `${baseClass}__panel`,
|
|
98
|
+
ref: panelRef,
|
|
99
|
+
role: "alertdialog",
|
|
100
|
+
"aria-modal": "true",
|
|
101
|
+
"aria-labelledby": titleId,
|
|
102
|
+
"aria-describedby": description ? descId : void 0,
|
|
103
|
+
children: [
|
|
104
|
+
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__header`, children: [
|
|
105
|
+
/* @__PURE__ */ jsx(
|
|
106
|
+
"span",
|
|
107
|
+
{
|
|
108
|
+
className: `${baseClass}__icon material-symbols-rounded`,
|
|
109
|
+
"aria-hidden": "true",
|
|
110
|
+
children: variant === "destructive" ? "warning" : "info"
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
/* @__PURE__ */ jsx("h2", { className: `${baseClass}__title`, id: titleId, children: title })
|
|
114
|
+
] }),
|
|
115
|
+
description && /* @__PURE__ */ jsx("p", { className: `${baseClass}__description`, id: descId, children: description }),
|
|
116
|
+
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__actions`, children: [
|
|
117
|
+
/* @__PURE__ */ jsx(
|
|
118
|
+
Button,
|
|
119
|
+
{
|
|
120
|
+
label: cancelLabel,
|
|
121
|
+
priority: "tertiary",
|
|
122
|
+
onClick: handleCancel
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
/* @__PURE__ */ jsx(
|
|
126
|
+
Button,
|
|
127
|
+
{
|
|
128
|
+
label: confirmLabel,
|
|
129
|
+
priority: variant === "destructive" ? "destructive" : "primary",
|
|
130
|
+
onClick: handleConfirm
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
] })
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
] });
|
|
138
|
+
if (!mounted) return null;
|
|
139
|
+
return ReactDOM.createPortal(dialog, document.body);
|
|
140
|
+
};
|
|
141
|
+
export {
|
|
142
|
+
AlertDialog
|
|
143
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
APP LAYOUT — full-page template
|
|
3
|
+
Sidebar rail on the left, centered content area
|
|
4
|
+
============================================ */
|
|
5
|
+
|
|
6
|
+
.ds-app-layout {
|
|
7
|
+
display: flex;
|
|
8
|
+
min-height: 100vh;
|
|
9
|
+
background-color: var(--color-bg-page-primary);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/* ============================================
|
|
13
|
+
MAIN CONTENT AREA
|
|
14
|
+
============================================ */
|
|
15
|
+
.ds-app-layout__main {
|
|
16
|
+
flex: 1;
|
|
17
|
+
display: flex;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
margin-left: 64px;
|
|
20
|
+
padding: var(--padding-xl) var(--padding-lg);
|
|
21
|
+
transition: margin-left var(--motion-duration-slow) var(--motion-ease-emphasized);
|
|
22
|
+
min-width: 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.ds-app-layout--expanded .ds-app-layout__main {
|
|
26
|
+
margin-left: 280px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* ============================================
|
|
30
|
+
CENTERED CONTENT WRAPPER
|
|
31
|
+
============================================ */
|
|
32
|
+
.ds-app-layout__content {
|
|
33
|
+
width: 100%;
|
|
34
|
+
max-width: 1120px;
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
gap: var(--gap-xl);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* ============================================
|
|
41
|
+
RESPONSIVE
|
|
42
|
+
============================================ */
|
|
43
|
+
@media (max-width: 768px) {
|
|
44
|
+
.ds-app-layout__main {
|
|
45
|
+
margin-left: 0;
|
|
46
|
+
padding: var(--padding-lg) var(--padding-md);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.ds-app-layout--expanded .ds-app-layout__main {
|
|
50
|
+
margin-left: 0;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { AppSidebarSection, AppSidebarProfile } from '../AppSidebar/AppSidebar';
|
|
3
|
+
export interface AppLayoutProps {
|
|
4
|
+
/** Sidebar navigation sections */
|
|
5
|
+
sections: AppSidebarSection[];
|
|
6
|
+
/** Sidebar profile */
|
|
7
|
+
profile?: AppSidebarProfile;
|
|
8
|
+
/** Active nav item key */
|
|
9
|
+
activeKey?: string;
|
|
10
|
+
/** Active sub-item key */
|
|
11
|
+
activeSubKey?: string;
|
|
12
|
+
/** Whether sidebar starts expanded */
|
|
13
|
+
defaultExpanded?: boolean;
|
|
14
|
+
/** Logo text next to icon */
|
|
15
|
+
logoText?: string;
|
|
16
|
+
/** Custom logo element */
|
|
17
|
+
logo?: React.ReactNode;
|
|
18
|
+
/** Page content — centred in the main area */
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
/** Additional CSS classes on outer wrapper */
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* AppLayout — full-page template with a collapsible sidebar
|
|
25
|
+
* and a centred content area.
|
|
26
|
+
*/
|
|
27
|
+
export declare const AppLayout: ({ sections, profile, activeKey, activeSubKey, defaultExpanded, logoText, logo, children, className, }: AppLayoutProps) => React.JSX.Element;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useCallback } from "react";
|
|
3
|
+
import { AppSidebar } from "../AppSidebar/AppSidebar.js";
|
|
4
|
+
import "./AppLayout.css";
|
|
5
|
+
const AppLayout = ({
|
|
6
|
+
sections,
|
|
7
|
+
profile,
|
|
8
|
+
activeKey,
|
|
9
|
+
activeSubKey,
|
|
10
|
+
defaultExpanded = true,
|
|
11
|
+
logoText,
|
|
12
|
+
logo,
|
|
13
|
+
children,
|
|
14
|
+
className = ""
|
|
15
|
+
}) => {
|
|
16
|
+
const baseClass = "ds-app-layout";
|
|
17
|
+
const [expanded, setExpanded] = useState(defaultExpanded);
|
|
18
|
+
const handleExpandedChange = useCallback((next) => {
|
|
19
|
+
setExpanded(next);
|
|
20
|
+
}, []);
|
|
21
|
+
const classes = [
|
|
22
|
+
baseClass,
|
|
23
|
+
expanded ? `${baseClass}--expanded` : "",
|
|
24
|
+
className
|
|
25
|
+
].filter(Boolean).join(" ");
|
|
26
|
+
return /* @__PURE__ */ jsxs("div", { className: classes, "data-theme": "dark", children: [
|
|
27
|
+
/* @__PURE__ */ jsx(
|
|
28
|
+
AppSidebar,
|
|
29
|
+
{
|
|
30
|
+
sections,
|
|
31
|
+
profile,
|
|
32
|
+
activeKey,
|
|
33
|
+
activeSubKey,
|
|
34
|
+
expanded,
|
|
35
|
+
onExpandedChange: handleExpandedChange,
|
|
36
|
+
logoText,
|
|
37
|
+
logo
|
|
38
|
+
}
|
|
39
|
+
),
|
|
40
|
+
/* @__PURE__ */ jsx("main", { className: `${baseClass}__main`, children: /* @__PURE__ */ jsx("div", { className: `${baseClass}__content`, children }) })
|
|
41
|
+
] });
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
AppLayout
|
|
45
|
+
};
|