@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,125 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import "./ContributionGraph.css";
|
|
3
|
+
const MONTH_LABELS = [
|
|
4
|
+
"Jan",
|
|
5
|
+
"Feb",
|
|
6
|
+
"Mar",
|
|
7
|
+
"Apr",
|
|
8
|
+
"May",
|
|
9
|
+
"Jun",
|
|
10
|
+
"Jul",
|
|
11
|
+
"Aug",
|
|
12
|
+
"Sep",
|
|
13
|
+
"Oct",
|
|
14
|
+
"Nov",
|
|
15
|
+
"Dec"
|
|
16
|
+
];
|
|
17
|
+
const parseDay = (date) => /* @__PURE__ */ new Date(`${date}T00:00:00`);
|
|
18
|
+
const formatTooltip = (day) => {
|
|
19
|
+
const formatted = parseDay(day.date).toLocaleDateString("en-US", {
|
|
20
|
+
month: "short",
|
|
21
|
+
day: "numeric",
|
|
22
|
+
year: "numeric"
|
|
23
|
+
});
|
|
24
|
+
if (day.count === 0) return `No contributions on ${formatted}`;
|
|
25
|
+
if (day.count === 1) return `1 contribution on ${formatted}`;
|
|
26
|
+
return `${day.count} contributions on ${formatted}`;
|
|
27
|
+
};
|
|
28
|
+
const buildWeeks = (days) => {
|
|
29
|
+
const weeks = [];
|
|
30
|
+
let week = [];
|
|
31
|
+
days.forEach((day, index) => {
|
|
32
|
+
if (index === 0) {
|
|
33
|
+
week = Array(parseDay(day.date).getDay()).fill(null);
|
|
34
|
+
}
|
|
35
|
+
week.push(day);
|
|
36
|
+
if (week.length === 7) {
|
|
37
|
+
weeks.push(week);
|
|
38
|
+
week = [];
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
if (week.length > 0) weeks.push(week);
|
|
42
|
+
return weeks;
|
|
43
|
+
};
|
|
44
|
+
const buildMonthLabels = (weeks) => {
|
|
45
|
+
const labels = [];
|
|
46
|
+
let previousMonth = -1;
|
|
47
|
+
weeks.forEach((week, weekIndex) => {
|
|
48
|
+
const firstDay = week.find((day) => day !== null);
|
|
49
|
+
if (!firstDay) return;
|
|
50
|
+
const month = parseDay(firstDay.date).getMonth();
|
|
51
|
+
if (month !== previousMonth) {
|
|
52
|
+
if (weekIndex < weeks.length - 2 || labels.length === 0) {
|
|
53
|
+
labels.push({ weekIndex, label: MONTH_LABELS[month] });
|
|
54
|
+
}
|
|
55
|
+
previousMonth = month;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
if (labels.length > 1 && labels[1].weekIndex - labels[0].weekIndex < 3) {
|
|
59
|
+
labels.shift();
|
|
60
|
+
}
|
|
61
|
+
return labels;
|
|
62
|
+
};
|
|
63
|
+
const ContributionGraph = ({
|
|
64
|
+
days,
|
|
65
|
+
caption,
|
|
66
|
+
showMonthLabels = true,
|
|
67
|
+
showLegend = true,
|
|
68
|
+
className = ""
|
|
69
|
+
}) => {
|
|
70
|
+
const weeks = buildWeeks(days);
|
|
71
|
+
const monthLabels = buildMonthLabels(weeks);
|
|
72
|
+
const classes = ["ds-contribution-graph", className].filter(Boolean).join(" ");
|
|
73
|
+
const columnTemplate = `repeat(${weeks.length}, minmax(var(--ds-contribution-cell), 1fr))`;
|
|
74
|
+
return /* @__PURE__ */ jsxs("div", { className: classes, children: [
|
|
75
|
+
/* @__PURE__ */ jsxs("div", { className: "ds-contribution-graph__scroll", children: [
|
|
76
|
+
showMonthLabels && /* @__PURE__ */ jsx(
|
|
77
|
+
"div",
|
|
78
|
+
{
|
|
79
|
+
className: "ds-contribution-graph__months",
|
|
80
|
+
style: { gridTemplateColumns: columnTemplate },
|
|
81
|
+
"aria-hidden": "true",
|
|
82
|
+
children: monthLabels.map(({ weekIndex, label }) => /* @__PURE__ */ jsx(
|
|
83
|
+
"span",
|
|
84
|
+
{
|
|
85
|
+
className: "ds-contribution-graph__month-label",
|
|
86
|
+
style: { gridColumnStart: weekIndex + 1 },
|
|
87
|
+
children: label
|
|
88
|
+
},
|
|
89
|
+
`${label}-${weekIndex}`
|
|
90
|
+
))
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
/* @__PURE__ */ jsx(
|
|
94
|
+
"div",
|
|
95
|
+
{
|
|
96
|
+
className: "ds-contribution-graph__grid",
|
|
97
|
+
style: { gridTemplateColumns: columnTemplate },
|
|
98
|
+
role: "img",
|
|
99
|
+
"aria-label": caption ?? "Contribution activity",
|
|
100
|
+
children: weeks.map((week, weekIndex) => /* @__PURE__ */ jsx("div", { className: "ds-contribution-graph__week", children: week.map(
|
|
101
|
+
(day, dayIndex) => day ? /* @__PURE__ */ jsx(
|
|
102
|
+
"div",
|
|
103
|
+
{
|
|
104
|
+
className: `ds-contribution-graph__cell ds-contribution-graph__cell--level-${day.level}`,
|
|
105
|
+
title: formatTooltip(day)
|
|
106
|
+
},
|
|
107
|
+
day.date
|
|
108
|
+
) : /* @__PURE__ */ jsx("div", { className: "ds-contribution-graph__cell ds-contribution-graph__cell--empty" }, `pad-${dayIndex}`)
|
|
109
|
+
) }, weekIndex))
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
] }),
|
|
113
|
+
(caption || showLegend) && /* @__PURE__ */ jsxs("div", { className: "ds-contribution-graph__footer", children: [
|
|
114
|
+
caption && /* @__PURE__ */ jsx("span", { className: "ds-contribution-graph__caption", children: caption }),
|
|
115
|
+
showLegend && /* @__PURE__ */ jsxs("div", { className: "ds-contribution-graph__legend", "aria-hidden": "true", children: [
|
|
116
|
+
/* @__PURE__ */ jsx("span", { className: "ds-contribution-graph__legend-label", children: "Less" }),
|
|
117
|
+
[0, 1, 2, 3, 4].map((level) => /* @__PURE__ */ jsx("div", { className: `ds-contribution-graph__cell ds-contribution-graph__cell--level-${level}` }, level)),
|
|
118
|
+
/* @__PURE__ */ jsx("span", { className: "ds-contribution-graph__legend-label", children: "More" })
|
|
119
|
+
] })
|
|
120
|
+
] })
|
|
121
|
+
] });
|
|
122
|
+
};
|
|
123
|
+
export {
|
|
124
|
+
ContributionGraph
|
|
125
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
DATE INPUT COMPONENT
|
|
3
|
+
Date input with calendar icon and label
|
|
4
|
+
============================================ */
|
|
5
|
+
|
|
6
|
+
.ds-date-input {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
gap: var(--gap-sm); /* 8px */
|
|
10
|
+
width: 100%;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* ============================================
|
|
14
|
+
LABEL
|
|
15
|
+
============================================ */
|
|
16
|
+
|
|
17
|
+
.ds-date-input__label {
|
|
18
|
+
font-family: var(--font-paragraph-em-family);
|
|
19
|
+
font-size: var(--font-paragraph-em-size);
|
|
20
|
+
font-weight: var(--font-paragraph-em-weight);
|
|
21
|
+
line-height: var(--font-paragraph-em-line-height);
|
|
22
|
+
letter-spacing: var(--font-paragraph-em-letter-spacing);
|
|
23
|
+
color: var(--color-text-primary);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.ds-date-input__required {
|
|
27
|
+
color: var(--color-core-accent-coral);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* ============================================
|
|
31
|
+
FIELD WRAPPER
|
|
32
|
+
============================================ */
|
|
33
|
+
|
|
34
|
+
.ds-date-input__field-wrapper {
|
|
35
|
+
position: relative;
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* ============================================
|
|
41
|
+
ICON
|
|
42
|
+
============================================ */
|
|
43
|
+
|
|
44
|
+
.ds-date-input__icon {
|
|
45
|
+
position: absolute;
|
|
46
|
+
left: var(--padding-md); /* 16px */
|
|
47
|
+
top: 50%;
|
|
48
|
+
transform: translateY(-50%);
|
|
49
|
+
--icon-size: var(--icon-size-md);
|
|
50
|
+
color: var(--color-icon-primary);
|
|
51
|
+
pointer-events: none;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* ============================================
|
|
55
|
+
FIELD
|
|
56
|
+
============================================ */
|
|
57
|
+
|
|
58
|
+
.ds-date-input__field {
|
|
59
|
+
width: 100%;
|
|
60
|
+
padding: var(--padding-sm) var(--padding-md); /* 8px 16px */
|
|
61
|
+
padding-left: calc(var(--padding-md) + 24px + var(--gap-sm)); /* 16px + 24px icon + 8px gap */
|
|
62
|
+
border: var(--border-xs) solid var(--color-input-border-primary);
|
|
63
|
+
border-radius: var(--radius-md); /* 12px */
|
|
64
|
+
background-color: var(--color-input-bg-primary);
|
|
65
|
+
|
|
66
|
+
/* Typography */
|
|
67
|
+
font-family: var(--font-paragraph-family);
|
|
68
|
+
font-size: var(--font-paragraph-size);
|
|
69
|
+
font-weight: var(--font-paragraph-weight);
|
|
70
|
+
line-height: var(--font-paragraph-line-height);
|
|
71
|
+
letter-spacing: var(--font-paragraph-letter-spacing);
|
|
72
|
+
color: var(--color-input-text-primary);
|
|
73
|
+
|
|
74
|
+
/* Transitions */
|
|
75
|
+
transition: border-color var(--motion-duration-base) var(--motion-ease-standard), background-color var(--motion-duration-base) var(--motion-ease-standard);
|
|
76
|
+
outline: none;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* Hide the default calendar icon in WebKit browsers */
|
|
80
|
+
.ds-date-input__field::-webkit-calendar-picker-indicator {
|
|
81
|
+
opacity: 0;
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.ds-date-input__field:hover:not(:focus):not(:disabled) {
|
|
86
|
+
border-color: var(--color-input-border-hover);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.ds-date-input__field:focus {
|
|
90
|
+
border-color: var(--color-input-border-selected);
|
|
91
|
+
background-color: var(--color-input-bg-primary);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* ============================================
|
|
95
|
+
SIZE — COMPACT
|
|
96
|
+
============================================ */
|
|
97
|
+
|
|
98
|
+
.ds-date-input--compact .ds-date-input__field {
|
|
99
|
+
padding: var(--padding-xs) var(--padding-sm-md); /* 6px 12px */
|
|
100
|
+
padding-left: calc(var(--padding-sm-md) + 20px + var(--gap-sm)); /* 12px + 20px icon + 8px gap */
|
|
101
|
+
font-size: var(--font-paragraph-sm-size);
|
|
102
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
103
|
+
letter-spacing: var(--font-paragraph-sm-letter-spacing);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.ds-date-input--compact .ds-date-input__icon {
|
|
107
|
+
left: var(--padding-sm-md); /* 12px */
|
|
108
|
+
--icon-size: var(--icon-size-sm);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.ds-date-input--compact .ds-date-input__label {
|
|
112
|
+
font-size: var(--font-paragraph-sm-size);
|
|
113
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* ============================================
|
|
117
|
+
HELPER TEXT
|
|
118
|
+
============================================ */
|
|
119
|
+
|
|
120
|
+
.ds-date-input__helper {
|
|
121
|
+
font-family: var(--font-paragraph-sm-family);
|
|
122
|
+
font-size: var(--font-paragraph-sm-size);
|
|
123
|
+
font-weight: var(--font-paragraph-sm-weight);
|
|
124
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
125
|
+
letter-spacing: var(--font-paragraph-sm-letter-spacing);
|
|
126
|
+
color: var(--color-text-tertiary);
|
|
127
|
+
margin: 0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* ============================================
|
|
131
|
+
ERROR STATE
|
|
132
|
+
============================================ */
|
|
133
|
+
|
|
134
|
+
.ds-date-input--error .ds-date-input__field {
|
|
135
|
+
border-color: var(--color-status-error-border);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.ds-date-input--error .ds-date-input__field:focus {
|
|
139
|
+
border-color: var(--color-status-error-border);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.ds-date-input--error .ds-date-input__helper {
|
|
143
|
+
color: var(--color-status-error-border);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* ============================================
|
|
147
|
+
DISABLED STATE
|
|
148
|
+
============================================ */
|
|
149
|
+
|
|
150
|
+
.ds-date-input--disabled .ds-date-input__label {
|
|
151
|
+
color: var(--color-input-text-disabled);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.ds-date-input--disabled .ds-date-input__field {
|
|
155
|
+
background-color: var(--color-input-bg-disabled);
|
|
156
|
+
border-color: var(--color-input-border-disabled);
|
|
157
|
+
color: var(--color-input-text-disabled);
|
|
158
|
+
cursor: not-allowed;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.ds-date-input--disabled .ds-date-input__icon {
|
|
162
|
+
color: var(--color-input-text-disabled);
|
|
163
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface DateInputProps {
|
|
3
|
+
/** Input label text */
|
|
4
|
+
label?: string;
|
|
5
|
+
/** Current value (YYYY-MM-DD format) */
|
|
6
|
+
value?: string;
|
|
7
|
+
/** Placeholder text */
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
/** Component size */
|
|
10
|
+
size?: 'default' | 'compact';
|
|
11
|
+
/** Whether the input is disabled */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** Whether the input is required */
|
|
14
|
+
required?: boolean;
|
|
15
|
+
/** Error state */
|
|
16
|
+
error?: boolean;
|
|
17
|
+
/** Helper or error message */
|
|
18
|
+
helperText?: string;
|
|
19
|
+
/** Minimum selectable date (YYYY-MM-DD) */
|
|
20
|
+
min?: string;
|
|
21
|
+
/** Maximum selectable date (YYYY-MM-DD) */
|
|
22
|
+
max?: string;
|
|
23
|
+
/** Callback when value changes */
|
|
24
|
+
onChange?: (value: string) => void;
|
|
25
|
+
/** Callback on focus */
|
|
26
|
+
onFocus?: () => void;
|
|
27
|
+
/** Callback on blur */
|
|
28
|
+
onBlur?: () => void;
|
|
29
|
+
/** Additional CSS classes */
|
|
30
|
+
className?: string;
|
|
31
|
+
/** Accessible name override */
|
|
32
|
+
ariaLabel?: string;
|
|
33
|
+
/** HTML name attribute */
|
|
34
|
+
name?: string;
|
|
35
|
+
/** HTML id attribute */
|
|
36
|
+
id?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Date input component with native date picker.
|
|
40
|
+
* Uses the browser's built-in date input with custom styling,
|
|
41
|
+
* calendar icon, label, and validation states.
|
|
42
|
+
*/
|
|
43
|
+
export declare const DateInput: ({ label, value, placeholder, size, disabled, required, error, helperText, min, max, onChange, onFocus, onBlur, className, ariaLabel, name, id, }: DateInputProps) => React.JSX.Element;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import "./DateInput.css";
|
|
4
|
+
import "../../fonts/material-symbols.css";
|
|
5
|
+
const DateInput = ({
|
|
6
|
+
label,
|
|
7
|
+
value,
|
|
8
|
+
placeholder,
|
|
9
|
+
size = "default",
|
|
10
|
+
disabled = false,
|
|
11
|
+
required = false,
|
|
12
|
+
error = false,
|
|
13
|
+
helperText,
|
|
14
|
+
min,
|
|
15
|
+
max,
|
|
16
|
+
onChange,
|
|
17
|
+
onFocus,
|
|
18
|
+
onBlur,
|
|
19
|
+
className = "",
|
|
20
|
+
ariaLabel,
|
|
21
|
+
name,
|
|
22
|
+
id
|
|
23
|
+
}) => {
|
|
24
|
+
const baseClass = "ds-date-input";
|
|
25
|
+
const errorClass = error ? `${baseClass}--error` : "";
|
|
26
|
+
const disabledClass = disabled ? `${baseClass}--disabled` : "";
|
|
27
|
+
const sizeClass = `${baseClass}--${size}`;
|
|
28
|
+
const classes = [baseClass, sizeClass, errorClass, disabledClass, className].filter(Boolean).join(" ");
|
|
29
|
+
const handleChange = (e) => {
|
|
30
|
+
if (onChange) {
|
|
31
|
+
onChange(e.target.value);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const inputId = id || name || label?.toLowerCase().replace(/\s+/g, "-");
|
|
35
|
+
return /* @__PURE__ */ jsxs("div", { className: classes, children: [
|
|
36
|
+
label && /* @__PURE__ */ jsxs("label", { className: `${baseClass}__label`, htmlFor: inputId, children: [
|
|
37
|
+
label,
|
|
38
|
+
required && /* @__PURE__ */ jsx("span", { className: `${baseClass}__required`, "aria-hidden": "true", children: " *" })
|
|
39
|
+
] }),
|
|
40
|
+
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__field-wrapper`, children: [
|
|
41
|
+
/* @__PURE__ */ jsx("span", { className: `${baseClass}__icon material-symbols-rounded`, "aria-hidden": "true", children: "calendar_today" }),
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
"input",
|
|
44
|
+
{
|
|
45
|
+
className: `${baseClass}__field`,
|
|
46
|
+
type: "date",
|
|
47
|
+
id: inputId,
|
|
48
|
+
name,
|
|
49
|
+
value,
|
|
50
|
+
placeholder,
|
|
51
|
+
disabled,
|
|
52
|
+
required,
|
|
53
|
+
min,
|
|
54
|
+
max,
|
|
55
|
+
"aria-label": ariaLabel || label,
|
|
56
|
+
"aria-invalid": error,
|
|
57
|
+
"aria-describedby": helperText ? `${inputId}-helper` : void 0,
|
|
58
|
+
onChange: handleChange,
|
|
59
|
+
onFocus,
|
|
60
|
+
onBlur
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
] }),
|
|
64
|
+
helperText && /* @__PURE__ */ jsx("p", { className: `${baseClass}__helper`, id: `${inputId}-helper`, children: helperText })
|
|
65
|
+
] });
|
|
66
|
+
};
|
|
67
|
+
export {
|
|
68
|
+
DateInput
|
|
69
|
+
};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
DATE PICKER COMPONENT
|
|
3
|
+
Inline calendar with month navigation
|
|
4
|
+
============================================ */
|
|
5
|
+
|
|
6
|
+
.ds-date-picker {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
gap: var(--gap-sm); /* 8px */
|
|
10
|
+
padding: var(--padding-md); /* 16px */
|
|
11
|
+
border: var(--border-xs) solid var(--color-input-border-primary);
|
|
12
|
+
border-radius: var(--radius-md); /* 12px */
|
|
13
|
+
background-color: var(--color-input-bg-primary);
|
|
14
|
+
user-select: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* ============================================
|
|
18
|
+
HEADER
|
|
19
|
+
============================================ */
|
|
20
|
+
|
|
21
|
+
.ds-date-picker__header {
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
justify-content: space-between;
|
|
25
|
+
gap: var(--gap-sm); /* 8px */
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.ds-date-picker__month-year {
|
|
29
|
+
font-family: var(--font-title-body-family);
|
|
30
|
+
font-size: var(--font-title-body-size);
|
|
31
|
+
font-weight: var(--font-title-body-weight);
|
|
32
|
+
line-height: var(--font-title-body-line-height);
|
|
33
|
+
letter-spacing: var(--font-title-body-letter-spacing);
|
|
34
|
+
color: var(--color-text-primary);
|
|
35
|
+
text-align: center;
|
|
36
|
+
flex: 1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.ds-date-picker__nav-btn {
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
justify-content: center;
|
|
43
|
+
width: 32px;
|
|
44
|
+
height: 32px;
|
|
45
|
+
padding: 0;
|
|
46
|
+
border: none;
|
|
47
|
+
border-radius: var(--radius-full);
|
|
48
|
+
background-color: transparent;
|
|
49
|
+
color: var(--color-text-secondary);
|
|
50
|
+
font-size: 24px;
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
transition: background-color var(--motion-duration-base) var(--motion-ease-standard);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.ds-date-picker__nav-btn:hover:not(:disabled) {
|
|
56
|
+
background-color: var(--color-action-passive-bg-hover);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.ds-date-picker__nav-btn:active:not(:disabled) {
|
|
60
|
+
background-color: var(--color-action-passive-bg-active);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.ds-date-picker__nav-btn:disabled {
|
|
64
|
+
opacity: 0.4;
|
|
65
|
+
cursor: not-allowed;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.ds-date-picker__nav-btn:focus-visible {
|
|
69
|
+
outline: 2px solid var(--color-action-primary-bg);
|
|
70
|
+
outline-offset: 2px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* ============================================
|
|
74
|
+
GRID
|
|
75
|
+
============================================ */
|
|
76
|
+
|
|
77
|
+
.ds-date-picker__grid {
|
|
78
|
+
display: grid;
|
|
79
|
+
grid-template-columns: repeat(7, 1fr);
|
|
80
|
+
gap: var(--gap-xxs); /* 2px */
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* ============================================
|
|
84
|
+
DAY HEADERS
|
|
85
|
+
============================================ */
|
|
86
|
+
|
|
87
|
+
.ds-date-picker__day-header {
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
justify-content: center;
|
|
91
|
+
height: 36px;
|
|
92
|
+
font-family: var(--font-paragraph-sm-family);
|
|
93
|
+
font-size: var(--font-paragraph-sm-size);
|
|
94
|
+
font-weight: var(--font-title-body-weight); /* 600 — semibold for headers */
|
|
95
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
96
|
+
color: var(--color-text-tertiary);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* ============================================
|
|
100
|
+
CELLS
|
|
101
|
+
============================================ */
|
|
102
|
+
|
|
103
|
+
.ds-date-picker__cell {
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
justify-content: center;
|
|
107
|
+
width: 36px;
|
|
108
|
+
height: 36px;
|
|
109
|
+
padding: 0;
|
|
110
|
+
border: none;
|
|
111
|
+
border-radius: var(--radius-full);
|
|
112
|
+
background-color: transparent;
|
|
113
|
+
cursor: pointer;
|
|
114
|
+
transition: background-color var(--motion-duration-base) var(--motion-ease-standard), color var(--motion-duration-base) var(--motion-ease-standard);
|
|
115
|
+
|
|
116
|
+
/* Typography — paragraph sm em for clickable cells */
|
|
117
|
+
font-family: var(--font-paragraph-sm-em-family);
|
|
118
|
+
font-size: var(--font-paragraph-sm-em-size);
|
|
119
|
+
font-weight: var(--font-paragraph-sm-em-weight);
|
|
120
|
+
line-height: 1;
|
|
121
|
+
color: var(--color-text-primary);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.ds-date-picker__cell:hover:not(:disabled):not(.ds-date-picker__cell--selected) {
|
|
125
|
+
background-color: var(--color-action-passive-bg-hover);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.ds-date-picker__cell:focus-visible {
|
|
129
|
+
outline: 2px solid var(--color-action-primary-bg);
|
|
130
|
+
outline-offset: 2px;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* Outside current month */
|
|
134
|
+
.ds-date-picker__cell--outside {
|
|
135
|
+
color: var(--color-text-tertiary);
|
|
136
|
+
opacity: 0.5;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* Today indicator */
|
|
140
|
+
.ds-date-picker__cell--today {
|
|
141
|
+
border: var(--border-xs) solid var(--color-action-primary-bg);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/* Selected */
|
|
145
|
+
.ds-date-picker__cell--selected {
|
|
146
|
+
background-color: var(--color-action-primary-bg);
|
|
147
|
+
color: var(--color-action-primary-text);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.ds-date-picker__cell--selected:hover:not(:disabled) {
|
|
151
|
+
background-color: var(--color-action-primary-bg-hover);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* Disabled */
|
|
155
|
+
.ds-date-picker__cell--disabled {
|
|
156
|
+
opacity: 0.4;
|
|
157
|
+
cursor: not-allowed;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* ============================================
|
|
161
|
+
SIZE — COMPACT
|
|
162
|
+
============================================ */
|
|
163
|
+
|
|
164
|
+
.ds-date-picker--compact {
|
|
165
|
+
padding: var(--padding-sm); /* 8px */
|
|
166
|
+
gap: var(--gap-xxs); /* 2px */
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.ds-date-picker--compact .ds-date-picker__month-year {
|
|
170
|
+
font-size: var(--font-paragraph-sm-size);
|
|
171
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.ds-date-picker--compact .ds-date-picker__nav-btn {
|
|
175
|
+
width: 28px;
|
|
176
|
+
height: 28px;
|
|
177
|
+
font-size: 20px;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.ds-date-picker--compact .ds-date-picker__day-header {
|
|
181
|
+
height: 28px;
|
|
182
|
+
font-size: 12px;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.ds-date-picker--compact .ds-date-picker__cell {
|
|
186
|
+
width: 28px;
|
|
187
|
+
height: 28px;
|
|
188
|
+
font-size: 12px;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* ============================================
|
|
192
|
+
DISABLED STATE
|
|
193
|
+
============================================ */
|
|
194
|
+
|
|
195
|
+
.ds-date-picker--disabled {
|
|
196
|
+
opacity: 0.4;
|
|
197
|
+
pointer-events: none;
|
|
198
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface DatePickerProps {
|
|
2
|
+
/** Currently selected date (YYYY-MM-DD) */
|
|
3
|
+
value?: string;
|
|
4
|
+
/** Component size */
|
|
5
|
+
size?: 'default' | 'compact';
|
|
6
|
+
/** Whether the picker is disabled */
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
/** Minimum selectable date (YYYY-MM-DD) */
|
|
9
|
+
min?: string;
|
|
10
|
+
/** Maximum selectable date (YYYY-MM-DD) */
|
|
11
|
+
max?: string;
|
|
12
|
+
/** Callback when a date is selected */
|
|
13
|
+
onDateSelect?: (date: string) => void;
|
|
14
|
+
/** Additional CSS classes */
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Inline date picker calendar component.
|
|
19
|
+
* Displays a full month grid with navigation,
|
|
20
|
+
* day headers, and selectable date cells.
|
|
21
|
+
*/
|
|
22
|
+
export declare const DatePicker: ({ value, size, disabled, min, max, onDateSelect, className, }: DatePickerProps) => import("react").JSX.Element;
|