rift-ds 1.29.0 → 1.30.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/README.md +4 -3
- package/bin/rift-ds.mjs +1 -1
- package/bin/templates/app/components/rift/ColorModeScript.tsx +7 -3
- package/bin/templates/blocks/app/settings/ProfileForm.tsx +98 -0
- package/bin/templates/blocks/app/settings/page.module.css +11 -0
- package/bin/templates/blocks/app/settings/page.tsx +84 -0
- package/bin/templates/blocks/components/blocks/AppShell.module.css +8 -41
- package/bin/templates/blocks/components/blocks/AppShell.tsx +9 -11
- package/bin/templates/blocks/registry.json +13 -0
- package/bin/templates/chat/app/api/chat/feedback/route.ts +0 -3
- package/bin/templates/chat/app/api/chat/followups/route.ts +0 -3
- package/bin/templates/chat/app/api/chat/route.ts +0 -2
- package/chat/ChatLauncher.d.ts +9 -1
- package/chat/ChatLauncher.js +3 -1
- package/components/Alert/Alert.css +12 -0
- package/components/Alert/Alert.d.ts +2 -0
- package/components/Alert/Alert.js +3 -1
- package/components/Attachment/Attachment.css +92 -0
- package/components/Attachment/FileRow.d.ts +47 -0
- package/components/Attachment/FileRow.js +38 -0
- package/components/Avatar/Avatar.css +14 -0
- package/components/Avatar/Avatar.d.ts +3 -1
- package/components/Avatar/Avatar.js +3 -2
- package/components/Chart/AreaChart.d.ts +2 -0
- package/components/Chart/AreaChart.js +2 -1
- package/components/Chart/BarChart.d.ts +2 -0
- package/components/Chart/BarChart.js +2 -1
- package/components/Chart/ComboChart.d.ts +4 -0
- package/components/Chart/ComboChart.js +4 -2
- package/components/Chart/LineChart.d.ts +2 -0
- package/components/Chart/LineChart.js +2 -1
- package/components/Chart/PieChart.d.ts +4 -4
- package/components/Chart/PieChart.js +1 -1
- package/components/Chart/ScatterChart.d.ts +2 -0
- package/components/Chart/ScatterChart.js +2 -1
- package/components/Checklist/Checklist.css +123 -0
- package/components/Checklist/Checklist.d.ts +66 -0
- package/components/Checklist/Checklist.js +115 -0
- package/components/CircularButton/CircularButton.css +39 -0
- package/components/CircularButton/CircularButton.d.ts +13 -0
- package/components/CircularButton/CircularButton.js +18 -4
- package/components/ColourSwatch/ColourSwatch.css +3 -1
- package/components/ColourSwatch/ColourSwatch.d.ts +5 -3
- package/components/ColourSwatch/ColourSwatch.js +5 -0
- package/components/Combobox/Combobox.d.ts +4 -2
- package/components/Combobox/Combobox.js +7 -3
- package/components/DataTable/DataTable.css +35 -0
- package/components/DataTable/DataTable.d.ts +34 -2
- package/components/DataTable/DataTable.js +58 -5
- package/components/DataTable/columnTypes.d.ts +1 -1
- package/components/DataTable/columnTypes.js +1 -1
- package/components/DateInput/DateInput.d.ts +4 -2
- package/components/DateInput/DateInput.js +7 -3
- package/components/DescriptionList/DescriptionList.css +28 -0
- package/components/DescriptionList/DescriptionList.d.ts +3 -1
- package/components/DescriptionList/DescriptionList.js +4 -3
- package/components/DescriptionList/DescriptionListCopy.js +2 -0
- package/components/Dropdown/Dropdown.d.ts +4 -2
- package/components/Dropdown/Dropdown.js +7 -3
- package/components/EmptyState/EmptyState.css +12 -0
- package/components/EmptyState/EmptyState.d.ts +7 -0
- package/components/EmptyState/EmptyState.js +2 -0
- package/components/EventCalendar/EventCalendar.css +59 -0
- package/components/EventCalendar/EventCalendar.d.ts +24 -2
- package/components/EventCalendar/EventCalendar.js +104 -19
- package/components/FormSection/FormSection.css +70 -0
- package/components/FormSection/FormSection.d.ts +35 -0
- package/components/FormSection/FormSection.js +35 -0
- package/components/Grid/Grid.css +52 -0
- package/components/Grid/Grid.d.ts +30 -0
- package/components/Grid/Grid.js +36 -0
- package/components/Icon/Icon.css +55 -0
- package/components/Icon/Icon.d.ts +27 -0
- package/components/Icon/Icon.js +42 -0
- package/components/NumberInput/NumberInput.d.ts +4 -2
- package/components/NumberInput/NumberInput.js +7 -3
- package/components/OrgChart/OrgChart.css +143 -0
- package/components/OrgChart/OrgChart.d.ts +44 -0
- package/components/OrgChart/OrgChart.js +26 -0
- package/components/PageHeader/PageHeader.css +74 -0
- package/components/PageHeader/PageHeader.d.ts +39 -0
- package/components/PageHeader/PageHeader.js +33 -0
- package/components/Panel/Panel.css +7 -0
- package/components/Panel/Panel.d.ts +5 -2
- package/components/Panel/Panel.js +2 -1
- package/components/ResourceTimeline/ResourceTimeline.css +194 -0
- package/components/ResourceTimeline/ResourceTimeline.d.ts +57 -0
- package/components/ResourceTimeline/ResourceTimeline.js +129 -0
- package/components/ShaderField/useShaderField.js +13 -1
- package/components/ShaderScene/ShaderScene.d.ts +3 -2
- package/components/ShaderScene/ShaderScene.js +47 -4
- package/components/Stack/Stack.css +68 -0
- package/components/Stack/Stack.d.ts +37 -0
- package/components/Stack/Stack.js +39 -0
- package/components/Stat/Stat.css +65 -0
- package/components/Stat/Stat.d.ts +7 -1
- package/components/Stat/Stat.js +16 -1
- package/components/Table/Table.css +11 -0
- package/components/Table/Table.d.ts +2 -0
- package/components/Table/Table.js +5 -1
- package/components/Tabs/Tabs.css +23 -0
- package/components/Tabs/Tabs.d.ts +9 -8
- package/components/Tabs/Tabs.js +38 -5
- package/components/Textarea/Textarea.d.ts +4 -2
- package/components/Textarea/Textarea.js +7 -3
- package/components/ThemeToggle/colorMode.d.ts +17 -1
- package/components/ThemeToggle/colorMode.js +11 -2
- package/components/Widget/Widget.css +21 -0
- package/components/Widget/Widget.d.ts +4 -0
- package/components/Widget/Widget.js +13 -5
- package/components/Wizard/Wizard.css +67 -0
- package/components/Wizard/Wizard.d.ts +54 -0
- package/components/Wizard/Wizard.js +71 -0
- package/components/registry.d.ts +25 -0
- package/components/registry.js +8 -0
- package/components/registry.json +233 -32
- package/components/registry.json.d.ts +233 -32
- package/components/registry.json.js +1 -1
- package/index.d.ts +10 -0
- package/index.js +20 -0
- package/package.json +1 -1
- package/tokens/motion.d.ts +2 -0
- package/tokens/motion.js +2 -0
- package/tokens/values.d.ts +31 -0
- package/tokens/values.js +16 -0
- package/tokens/values.json.js +1 -1
|
@@ -5,6 +5,7 @@ import { CircularButton } from "../CircularButton/CircularButton.js";
|
|
|
5
5
|
import { MOTION_FEEDBACK_RESET_MS } from "../../tokens/motion.js";
|
|
6
6
|
function writeClipboard(text) {
|
|
7
7
|
const fallback = () => {
|
|
8
|
+
const focused = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
8
9
|
const textarea = document.createElement("textarea");
|
|
9
10
|
textarea.value = text;
|
|
10
11
|
textarea.setAttribute("readonly", "");
|
|
@@ -13,6 +14,7 @@ function writeClipboard(text) {
|
|
|
13
14
|
textarea.select();
|
|
14
15
|
document.execCommand("copy");
|
|
15
16
|
document.body.removeChild(textarea);
|
|
17
|
+
focused?.focus({ preventScroll: true });
|
|
16
18
|
};
|
|
17
19
|
if (navigator.clipboard?.writeText) navigator.clipboard.writeText(text).catch(fallback);
|
|
18
20
|
else fallback();
|
|
@@ -49,10 +49,12 @@ type DropdownOwnProps = {
|
|
|
49
49
|
disabled?: boolean;
|
|
50
50
|
/** Whether the dropdown is required */
|
|
51
51
|
required?: boolean;
|
|
52
|
-
/** Error state */
|
|
52
|
+
/** Error state: marks the control invalid and, in the older form without `errorText`, recolours the helper text as the error message. */
|
|
53
53
|
error?: boolean;
|
|
54
|
-
/** Helper
|
|
54
|
+
/** Helper text displayed below the control. With the older `error` flag and no `errorText`, it doubles as the error message. */
|
|
55
55
|
helperText?: string;
|
|
56
|
+
/** The error message, shown under the control while the helper text keeps its place. Setting it marks the control invalid, so `error` is not needed alongside it; Field's spec owns the wiring. */
|
|
57
|
+
errorText?: React.ReactNode;
|
|
56
58
|
/** Called with the newly selected value */
|
|
57
59
|
onValueChange?: (value: string) => void;
|
|
58
60
|
/** Whether the list is open, controlled. Leave undefined to let the dropdown open and close itself. */
|
|
@@ -23,6 +23,7 @@ const Dropdown = React.forwardRef(
|
|
|
23
23
|
required = false,
|
|
24
24
|
error = false,
|
|
25
25
|
helperText,
|
|
26
|
+
errorText,
|
|
26
27
|
onValueChange,
|
|
27
28
|
open: openProp,
|
|
28
29
|
defaultOpen = false,
|
|
@@ -75,11 +76,13 @@ const Dropdown = React.forwardRef(
|
|
|
75
76
|
};
|
|
76
77
|
const baseClass = "ds-dropdown";
|
|
77
78
|
const isGrouped = groups && groups.length > 0;
|
|
79
|
+
const hasErrorText = errorText != null && errorText !== false && errorText !== "";
|
|
80
|
+
const invalid = error || hasErrorText;
|
|
78
81
|
const classes = [
|
|
79
82
|
baseClass,
|
|
80
83
|
size === "compact" ? `${baseClass}--compact` : "",
|
|
81
84
|
isOpen ? `${baseClass}--open` : "",
|
|
82
|
-
|
|
85
|
+
invalid ? `${baseClass}--error` : "",
|
|
83
86
|
disabled ? `${baseClass}--disabled` : "",
|
|
84
87
|
className
|
|
85
88
|
].filter(Boolean).join(" ");
|
|
@@ -194,6 +197,7 @@ const Dropdown = React.forwardRef(
|
|
|
194
197
|
ref: setRootRef,
|
|
195
198
|
label,
|
|
196
199
|
helperText,
|
|
200
|
+
errorText,
|
|
197
201
|
error,
|
|
198
202
|
required,
|
|
199
203
|
disabled,
|
|
@@ -212,8 +216,8 @@ const Dropdown = React.forwardRef(
|
|
|
212
216
|
"aria-label": ariaLabelAttr ?? ariaLabel ?? (!label ? placeholder : void 0),
|
|
213
217
|
"aria-controls": isOpen ? `${inputId}-listbox` : void 0,
|
|
214
218
|
"aria-activedescendant": activeOptionId,
|
|
215
|
-
"aria-describedby": [ariaDescribedBy, helperText ? `${inputId}-helper` : void 0].filter(Boolean).join(" ") || void 0,
|
|
216
|
-
"aria-invalid":
|
|
219
|
+
"aria-describedby": [ariaDescribedBy, hasErrorText ? `${inputId}-error` : void 0, helperText ? `${inputId}-helper` : void 0].filter(Boolean).join(" ") || void 0,
|
|
220
|
+
"aria-invalid": invalid || void 0,
|
|
217
221
|
tabIndex: disabled ? -1 : 0,
|
|
218
222
|
onClick: handleToggle,
|
|
219
223
|
onKeyDown: handleKeyDown,
|
|
@@ -40,6 +40,18 @@
|
|
|
40
40
|
--icon-size: var(--icon-size-600);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
/* Tones: the icon tile takes a status role, for a result that worked or a
|
|
44
|
+
step that failed; the copy stays in the page's text colours. */
|
|
45
|
+
.ds-empty-state--positive .ds-empty-state__icon {
|
|
46
|
+
background-color: var(--color-status-positive-bg);
|
|
47
|
+
color: var(--color-status-positive-icon);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.ds-empty-state--error .ds-empty-state__icon {
|
|
51
|
+
background-color: var(--color-status-error-bg);
|
|
52
|
+
color: var(--color-status-error-icon);
|
|
53
|
+
}
|
|
54
|
+
|
|
43
55
|
/* ============================================
|
|
44
56
|
CONTENT
|
|
45
57
|
============================================ */
|
|
@@ -19,6 +19,13 @@ type EmptyStateOwnProps = {
|
|
|
19
19
|
* dashed container, which reads better inside a card, table, or panel.
|
|
20
20
|
*/
|
|
21
21
|
variant?: 'plain' | 'bordered';
|
|
22
|
+
/**
|
|
23
|
+
* The icon tile's status colour. `default` is the quiet tile for nothing
|
|
24
|
+
* to show; `positive` is a result that worked (the end of a flow, with
|
|
25
|
+
* what happens next in the description and the action); `error` is a
|
|
26
|
+
* load or a step that failed.
|
|
27
|
+
*/
|
|
28
|
+
tone?: 'default' | 'positive' | 'error';
|
|
22
29
|
/** Additional CSS classes */
|
|
23
30
|
className?: string;
|
|
24
31
|
};
|
|
@@ -11,6 +11,7 @@ const EmptyState = React.forwardRef(
|
|
|
11
11
|
action,
|
|
12
12
|
size = "default",
|
|
13
13
|
variant = "plain",
|
|
14
|
+
tone = "default",
|
|
14
15
|
className = "",
|
|
15
16
|
...rest
|
|
16
17
|
}, ref) => {
|
|
@@ -19,6 +20,7 @@ const EmptyState = React.forwardRef(
|
|
|
19
20
|
baseClass,
|
|
20
21
|
`${baseClass}--${variant}`,
|
|
21
22
|
size === "compact" ? `${baseClass}--compact` : "",
|
|
23
|
+
tone !== "default" ? `${baseClass}--${tone}` : "",
|
|
22
24
|
className
|
|
23
25
|
].filter(Boolean).join(" ");
|
|
24
26
|
return /* @__PURE__ */ jsxs("div", { ...rest, ref, className: classes, children: [
|
|
@@ -284,6 +284,54 @@ button.ds-event-calendar__event:focus-visible {
|
|
|
284
284
|
font-variant-numeric: tabular-nums;
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
+
/* ============================================
|
|
288
|
+
SPANS — an event over several days
|
|
289
|
+
Its pill on each day squares off the side the
|
|
290
|
+
event runs on through, so the days read as one
|
|
291
|
+
bar; the dot marks the first day only.
|
|
292
|
+
============================================ */
|
|
293
|
+
|
|
294
|
+
.ds-event-calendar__event--continued {
|
|
295
|
+
border-start-start-radius: 0;
|
|
296
|
+
border-end-start-radius: 0;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.ds-event-calendar__event--continues {
|
|
300
|
+
border-start-end-radius: 0;
|
|
301
|
+
border-end-end-radius: 0;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.ds-event-calendar__event--continued .ds-event-calendar__event-dot {
|
|
305
|
+
visibility: hidden;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/* ============================================
|
|
309
|
+
LEGEND — what each event colour means
|
|
310
|
+
============================================ */
|
|
311
|
+
|
|
312
|
+
.ds-event-calendar__legend {
|
|
313
|
+
display: flex;
|
|
314
|
+
flex-wrap: wrap;
|
|
315
|
+
gap: var(--gap-200) var(--gap-400);
|
|
316
|
+
margin: var(--gap-300) 0 0;
|
|
317
|
+
padding: 0;
|
|
318
|
+
list-style: none;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.ds-event-calendar__legend-item {
|
|
322
|
+
--ds-event-accent: var(--color-status-neutral-border);
|
|
323
|
+
|
|
324
|
+
display: inline-flex;
|
|
325
|
+
align-items: center;
|
|
326
|
+
gap: var(--gap-100);
|
|
327
|
+
color: var(--color-text-secondary);
|
|
328
|
+
font-family: var(--font-paragraph-sm-family);
|
|
329
|
+
font-size: var(--font-paragraph-sm-size);
|
|
330
|
+
font-weight: var(--font-paragraph-sm-weight);
|
|
331
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
332
|
+
letter-spacing: var(--font-paragraph-sm-letter-spacing);
|
|
333
|
+
}
|
|
334
|
+
|
|
287
335
|
/* ============================================
|
|
288
336
|
EVENT ACCENTS — core accent roles only
|
|
289
337
|
============================================ */
|
|
@@ -363,3 +411,14 @@ button.ds-event-calendar__more:focus-visible {
|
|
|
363
411
|
text-align: center;
|
|
364
412
|
}
|
|
365
413
|
}
|
|
414
|
+
|
|
415
|
+
/* ============================================
|
|
416
|
+
WEEK VIEW — one week, every event shown
|
|
417
|
+
The cells take the room a week has to give,
|
|
418
|
+
so a busy day lists everything without an
|
|
419
|
+
overflow row.
|
|
420
|
+
============================================ */
|
|
421
|
+
|
|
422
|
+
.ds-event-calendar--week .ds-event-calendar__cell {
|
|
423
|
+
min-height: calc(var(--control-height-default) * 5);
|
|
424
|
+
}
|
|
@@ -4,8 +4,10 @@ export type EventCalendarColor = 'neutral' | 'coral' | 'violet' | 'cobalt' | 'am
|
|
|
4
4
|
export interface EventCalendarEvent {
|
|
5
5
|
/** Unique event identifier. */
|
|
6
6
|
id: string;
|
|
7
|
-
/** The day the event falls on (YYYY-MM-DD). */
|
|
7
|
+
/** The day the event falls on (YYYY-MM-DD), or its first day when it runs over several. */
|
|
8
8
|
date: string;
|
|
9
|
+
/** The last day of an event that runs over several days (YYYY-MM-DD, inclusive): it shows on every day from `date` to this one, its pills joined across the days and its dot on the first. */
|
|
10
|
+
endDate?: string;
|
|
9
11
|
/** Short label shown in the event pill. */
|
|
10
12
|
title: string;
|
|
11
13
|
/** Start time as already-formatted text like "09:30". Untimed events sort first. */
|
|
@@ -13,6 +15,13 @@ export interface EventCalendarEvent {
|
|
|
13
15
|
/** Accent for the pill's dot, from the core accent roles. Defaults to `neutral`. */
|
|
14
16
|
color?: EventCalendarColor;
|
|
15
17
|
}
|
|
18
|
+
/** A colour the calendar's events use, and what it means, for the legend. */
|
|
19
|
+
export interface EventCalendarLegendItem {
|
|
20
|
+
/** The accent, as an event's `color` names it. */
|
|
21
|
+
color: EventCalendarColor;
|
|
22
|
+
/** What events in this colour are ("Offsites", "Deadlines"). */
|
|
23
|
+
label: string;
|
|
24
|
+
}
|
|
16
25
|
/** Props owned by EventCalendar itself — everything else falls through to the root element. */
|
|
17
26
|
type EventCalendarOwnProps = {
|
|
18
27
|
/** The events to place on the grid, including any that fall on the visible leading and trailing days of the neighbouring months. */
|
|
@@ -40,16 +49,29 @@ type EventCalendarOwnProps = {
|
|
|
40
49
|
* consumer; pair with `onDateClick` to move it.
|
|
41
50
|
*/
|
|
42
51
|
selectedDate?: string;
|
|
52
|
+
/** The date the calendar treats as today (`YYYY-MM-DD`): it carries the today chip and picks the month shown first. Defaults to the device's date; pin it for a demo, a test or a time zone the device is not in. */
|
|
53
|
+
today?: string;
|
|
54
|
+
/** What each event colour means, shown as a row of dots and labels under the grid. Filtering by kind stays with the host, which passes the events it wants shown. */
|
|
55
|
+
legend?: EventCalendarLegendItem[];
|
|
43
56
|
/** Trailing header slot, e.g. a "New event" Button. */
|
|
44
57
|
actions?: React.ReactNode;
|
|
58
|
+
/** `month` shows the whole month, a day's overflow folded behind "+N more"; `week` shows one week in tall cells with every event, stepping a week at a time from the selected day's week (else today's), which it keeps as its own state after mount. */
|
|
59
|
+
view?: 'month' | 'week';
|
|
45
60
|
/** Accessible name of the previous-month button. */
|
|
46
61
|
previousLabel?: string;
|
|
47
62
|
/** Accessible name of the next-month button. */
|
|
48
63
|
nextLabel?: string;
|
|
64
|
+
/** Accessible name of the previous-week button, in the week view. */
|
|
65
|
+
previousWeekLabel?: string;
|
|
66
|
+
/** Accessible name of the next-week button, in the week view. */
|
|
67
|
+
nextWeekLabel?: string;
|
|
68
|
+
/** The visible text of the control that folds an expanded day back, when a day's "+N more" opens it in place (with no `onDateClick`). */
|
|
69
|
+
showLessLabel?: string;
|
|
49
70
|
/**
|
|
50
71
|
* The month heading, given the first day of the month in view: the visible
|
|
51
72
|
* title and the name of the day grid. Defaults to the month name and the
|
|
52
|
-
* year in `locale` ("January 2026" in `en-US`).
|
|
73
|
+
* year in `locale` ("January 2026" in `en-US`). Month view only; the week
|
|
74
|
+
* view's heading is the week's range in `locale`.
|
|
53
75
|
*/
|
|
54
76
|
monthLabel?: (month: Date) => string;
|
|
55
77
|
/**
|
|
@@ -5,6 +5,11 @@ import "./EventCalendar.css";
|
|
|
5
5
|
import "../../fonts/material-symbols.css";
|
|
6
6
|
import { useLocale } from "../../behaviors/LocaleProvider.js";
|
|
7
7
|
import { weekStartOf, weekdayOffset, rotateWeek, weekdayNamesIn } from "../../behaviors/locale.js";
|
|
8
|
+
function parseDay(str) {
|
|
9
|
+
const match = str ? /^(\d{4})-(\d{2})-(\d{2})$/.exec(str) : null;
|
|
10
|
+
return match ? new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3])) : null;
|
|
11
|
+
}
|
|
12
|
+
const MAX_SPAN_DAYS = 366;
|
|
8
13
|
const weekdaysOr = (labels, locale) => labels && labels.length === 7 ? labels : weekdayNamesIn(locale, "short");
|
|
9
14
|
function parseMonth(str) {
|
|
10
15
|
const [y, m] = str.split("-").map(Number);
|
|
@@ -44,9 +49,15 @@ const EventCalendar = React.forwardRef(
|
|
|
44
49
|
onEventClick,
|
|
45
50
|
onDateClick,
|
|
46
51
|
selectedDate,
|
|
52
|
+
today: todayProp,
|
|
53
|
+
legend,
|
|
47
54
|
actions,
|
|
55
|
+
view = "month",
|
|
48
56
|
previousLabel = "Previous month",
|
|
49
57
|
nextLabel = "Next month",
|
|
58
|
+
previousWeekLabel = "Previous week",
|
|
59
|
+
nextWeekLabel = "Next week",
|
|
60
|
+
showLessLabel = "Show less",
|
|
50
61
|
monthLabel: monthLabelProp,
|
|
51
62
|
overflowLabel: overflowLabelProp,
|
|
52
63
|
moreLabel = defaultMoreLabel,
|
|
@@ -57,7 +68,7 @@ const EventCalendar = React.forwardRef(
|
|
|
57
68
|
...rest
|
|
58
69
|
}, ref) => {
|
|
59
70
|
const baseClass = "ds-event-calendar";
|
|
60
|
-
const today = useMemo(() => /* @__PURE__ */ new Date(), []);
|
|
71
|
+
const today = useMemo(() => parseDay(todayProp) ?? /* @__PURE__ */ new Date(), [todayProp]);
|
|
61
72
|
const locale = useLocale(localeProp);
|
|
62
73
|
const weekStart = weekStartsOn ?? weekStartOf(locale);
|
|
63
74
|
const dayNumber = useMemo(() => new Intl.NumberFormat(locale), [locale]);
|
|
@@ -79,15 +90,52 @@ const EventCalendar = React.forwardRef(
|
|
|
79
90
|
if (!isControlled) setUncontrolledMonth(value);
|
|
80
91
|
onMonthChange?.(value);
|
|
81
92
|
};
|
|
93
|
+
const isWeek = view === "week";
|
|
94
|
+
const [weekAnchor, setWeekAnchor] = useState(() => parseDay(selectedDate) ?? today);
|
|
95
|
+
const weekStartDate = new Date(
|
|
96
|
+
weekAnchor.getFullYear(),
|
|
97
|
+
weekAnchor.getMonth(),
|
|
98
|
+
weekAnchor.getDate() - weekdayOffset(weekAnchor.getDay(), weekStart)
|
|
99
|
+
);
|
|
100
|
+
const stepWeek = (offset) => {
|
|
101
|
+
const next = new Date(weekAnchor.getFullYear(), weekAnchor.getMonth(), weekAnchor.getDate() + offset * 7);
|
|
102
|
+
setWeekAnchor(next);
|
|
103
|
+
const value = formatMonth(next.getFullYear(), next.getMonth());
|
|
104
|
+
if (value !== formatMonth(weekAnchor.getFullYear(), weekAnchor.getMonth())) {
|
|
105
|
+
if (!isControlled) setUncontrolledMonth(value);
|
|
106
|
+
onMonthChange?.(value);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const [expandedDays, setExpandedDays] = useState([]);
|
|
110
|
+
const toggleDay = (day) => setExpandedDays((current) => current.includes(day) ? current.filter((d) => d !== day) : [...current, day]);
|
|
111
|
+
const weekRangeLabel = useMemo(() => {
|
|
112
|
+
const format = new Intl.DateTimeFormat(locale, { month: "long", day: "numeric", year: "numeric" });
|
|
113
|
+
return (start) => format.formatRange(start, new Date(start.getFullYear(), start.getMonth(), start.getDate() + 6));
|
|
114
|
+
}, [locale]);
|
|
82
115
|
const eventsByDate = useMemo(() => {
|
|
83
116
|
const map = /* @__PURE__ */ new Map();
|
|
84
|
-
|
|
85
|
-
const list = map.get(
|
|
117
|
+
const add = (day, event) => {
|
|
118
|
+
const list = map.get(day) ?? [];
|
|
86
119
|
list.push(event);
|
|
87
|
-
map.set(
|
|
120
|
+
map.set(day, list);
|
|
121
|
+
};
|
|
122
|
+
for (const event of events) {
|
|
123
|
+
const start = parseDay(event.date);
|
|
124
|
+
const end = parseDay(event.endDate);
|
|
125
|
+
if (!start || !end || end <= start) {
|
|
126
|
+
add(event.date, event);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const day = new Date(start);
|
|
130
|
+
for (let i = 0; i < MAX_SPAN_DAYS && day <= end; i++) {
|
|
131
|
+
add(formatDate(day), event);
|
|
132
|
+
day.setDate(day.getDate() + 1);
|
|
133
|
+
}
|
|
88
134
|
}
|
|
135
|
+
const spans = (event) => Boolean(event.endDate && event.endDate > event.date);
|
|
89
136
|
for (const list of map.values()) {
|
|
90
137
|
list.sort((a, b) => {
|
|
138
|
+
if (spans(a) !== spans(b)) return spans(a) ? -1 : 1;
|
|
91
139
|
if (!a.time && !b.time) return 0;
|
|
92
140
|
if (!a.time) return -1;
|
|
93
141
|
if (!b.time) return 1;
|
|
@@ -96,16 +144,33 @@ const EventCalendar = React.forwardRef(
|
|
|
96
144
|
}
|
|
97
145
|
return map;
|
|
98
146
|
}, [events, locale]);
|
|
147
|
+
const formatSpan = useMemo(() => {
|
|
148
|
+
const format = new Intl.DateTimeFormat(locale, { month: "long", day: "numeric", year: "numeric" });
|
|
149
|
+
return (event) => {
|
|
150
|
+
const start = parseDay(event.date);
|
|
151
|
+
const end = parseDay(event.endDate);
|
|
152
|
+
return start && end && end > start ? format.formatRange(start, end) : null;
|
|
153
|
+
};
|
|
154
|
+
}, [locale]);
|
|
99
155
|
const firstDay = weekdayOffset(new Date(viewYear, viewMonth, 1).getDay(), weekStart);
|
|
100
156
|
const daysInMonth = new Date(viewYear, viewMonth + 1, 0).getDate();
|
|
101
157
|
const weekCount = Math.ceil((firstDay + daysInMonth) / 7);
|
|
102
158
|
const cells = [];
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
159
|
+
if (isWeek) {
|
|
160
|
+
for (let i = 0; i < 7; i++) {
|
|
161
|
+
cells.push({
|
|
162
|
+
date: new Date(weekStartDate.getFullYear(), weekStartDate.getMonth(), weekStartDate.getDate() + i),
|
|
163
|
+
inMonth: true
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
} else {
|
|
167
|
+
for (let i = 0; i < weekCount * 7; i++) {
|
|
168
|
+
const date = new Date(viewYear, viewMonth, i - firstDay + 1);
|
|
169
|
+
cells.push({ date, inMonth: date.getMonth() === viewMonth });
|
|
170
|
+
}
|
|
106
171
|
}
|
|
107
|
-
const classes = [baseClass, className].filter(Boolean).join(" ");
|
|
108
|
-
const monthTitle = monthLabel(new Date(viewYear, viewMonth, 1));
|
|
172
|
+
const classes = [baseClass, isWeek ? `${baseClass}--week` : "", className].filter(Boolean).join(" ");
|
|
173
|
+
const monthTitle = isWeek ? weekRangeLabel(weekStartDate) : monthLabel(new Date(viewYear, viewMonth, 1));
|
|
109
174
|
return /* @__PURE__ */ jsxs("div", { ...rest, ref, className: classes, children: [
|
|
110
175
|
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__header`, children: [
|
|
111
176
|
/* @__PURE__ */ jsx("span", { className: `${baseClass}__month`, children: monthTitle }),
|
|
@@ -115,8 +180,8 @@ const EventCalendar = React.forwardRef(
|
|
|
115
180
|
{
|
|
116
181
|
type: "button",
|
|
117
182
|
className: `${baseClass}__nav-btn material-symbols-rounded ds-mirror-rtl`,
|
|
118
|
-
onClick: () => navigate(-1),
|
|
119
|
-
"aria-label": previousLabel,
|
|
183
|
+
onClick: () => isWeek ? stepWeek(-1) : navigate(-1),
|
|
184
|
+
"aria-label": isWeek ? previousWeekLabel : previousLabel,
|
|
120
185
|
children: "chevron_left"
|
|
121
186
|
}
|
|
122
187
|
),
|
|
@@ -125,8 +190,8 @@ const EventCalendar = React.forwardRef(
|
|
|
125
190
|
{
|
|
126
191
|
type: "button",
|
|
127
192
|
className: `${baseClass}__nav-btn material-symbols-rounded ds-mirror-rtl`,
|
|
128
|
-
onClick: () => navigate(1),
|
|
129
|
-
"aria-label": nextLabel,
|
|
193
|
+
onClick: () => isWeek ? stepWeek(1) : navigate(1),
|
|
194
|
+
"aria-label": isWeek ? nextWeekLabel : nextLabel,
|
|
130
195
|
children: "chevron_right"
|
|
131
196
|
}
|
|
132
197
|
)
|
|
@@ -143,7 +208,8 @@ const EventCalendar = React.forwardRef(
|
|
|
143
208
|
children: cells.map(({ date, inMonth }) => {
|
|
144
209
|
const dateStr = formatDate(date);
|
|
145
210
|
const dayEvents = eventsByDate.get(dateStr) ?? [];
|
|
146
|
-
const
|
|
211
|
+
const expanded = isWeek || expandedDays.includes(dateStr);
|
|
212
|
+
const visible = expanded ? dayEvents : dayEvents.slice(0, maxEventsPerDay);
|
|
147
213
|
const overflow = dayEvents.length - visible.length;
|
|
148
214
|
const isToday = date.getFullYear() === today.getFullYear() && date.getMonth() === today.getMonth() && date.getDate() === today.getDate();
|
|
149
215
|
const dayLabel = formatDayLabel(date);
|
|
@@ -186,10 +252,14 @@ const EventCalendar = React.forwardRef(
|
|
|
186
252
|
),
|
|
187
253
|
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__events`, children: [
|
|
188
254
|
visible.map((event) => {
|
|
255
|
+
const span = formatSpan(event);
|
|
189
256
|
const pillClasses = [
|
|
190
257
|
`${baseClass}__event`,
|
|
191
|
-
`${baseClass}__event--${event.color ?? "neutral"}
|
|
192
|
-
|
|
258
|
+
`${baseClass}__event--${event.color ?? "neutral"}`,
|
|
259
|
+
span ? `${baseClass}__event--span` : "",
|
|
260
|
+
span && dateStr !== event.date ? `${baseClass}__event--continued` : "",
|
|
261
|
+
span && dateStr !== event.endDate ? `${baseClass}__event--continues` : ""
|
|
262
|
+
].filter(Boolean).join(" ");
|
|
193
263
|
const pillContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
194
264
|
/* @__PURE__ */ jsx("span", { className: `${baseClass}__event-dot`, "aria-hidden": "true" }),
|
|
195
265
|
/* @__PURE__ */ jsx("span", { className: `${baseClass}__event-title`, children: event.title }),
|
|
@@ -201,12 +271,13 @@ const EventCalendar = React.forwardRef(
|
|
|
201
271
|
type: "button",
|
|
202
272
|
className: pillClasses,
|
|
203
273
|
onClick: () => onEventClick(event),
|
|
204
|
-
"aria-label": `${event.title}${event.time ? `, ${event.time}` : ""}, ${dayLabel}`,
|
|
274
|
+
"aria-label": span ? `${event.title}, ${span}` : `${event.title}${event.time ? `, ${event.time}` : ""}, ${dayLabel}`,
|
|
205
275
|
children: pillContent
|
|
206
276
|
},
|
|
207
277
|
event.id
|
|
208
278
|
) : /* @__PURE__ */ jsx("span", { className: pillClasses, children: pillContent }, event.id);
|
|
209
279
|
}),
|
|
280
|
+
!isWeek && expandedDays.includes(dateStr) && dayEvents.length > maxEventsPerDay && /* @__PURE__ */ jsx("button", { type: "button", className: `${baseClass}__more`, onClick: () => toggleDay(dateStr), "aria-expanded": "true", children: showLessLabel }),
|
|
210
281
|
overflow > 0 && (onDateClick ? /* @__PURE__ */ jsx(
|
|
211
282
|
"button",
|
|
212
283
|
{
|
|
@@ -216,7 +287,17 @@ const EventCalendar = React.forwardRef(
|
|
|
216
287
|
"aria-label": overflowLabel(overflow, date),
|
|
217
288
|
children: moreLabel(overflow)
|
|
218
289
|
}
|
|
219
|
-
) : /* @__PURE__ */ jsx(
|
|
290
|
+
) : /* @__PURE__ */ jsx(
|
|
291
|
+
"button",
|
|
292
|
+
{
|
|
293
|
+
type: "button",
|
|
294
|
+
className: `${baseClass}__more`,
|
|
295
|
+
onClick: () => toggleDay(dateStr),
|
|
296
|
+
"aria-expanded": "false",
|
|
297
|
+
"aria-label": overflowLabel(overflow, date),
|
|
298
|
+
children: moreLabel(overflow)
|
|
299
|
+
}
|
|
300
|
+
))
|
|
220
301
|
] })
|
|
221
302
|
]
|
|
222
303
|
},
|
|
@@ -224,7 +305,11 @@ const EventCalendar = React.forwardRef(
|
|
|
224
305
|
);
|
|
225
306
|
})
|
|
226
307
|
}
|
|
227
|
-
)
|
|
308
|
+
),
|
|
309
|
+
legend && legend.length > 0 && /* @__PURE__ */ jsx("ul", { className: `${baseClass}__legend`, children: legend.map((item) => /* @__PURE__ */ jsxs("li", { className: `${baseClass}__legend-item ${baseClass}__event--${item.color}`, children: [
|
|
310
|
+
/* @__PURE__ */ jsx("span", { className: `${baseClass}__event-dot`, "aria-hidden": "true" }),
|
|
311
|
+
item.label
|
|
312
|
+
] }, `${item.color}-${item.label}`)) })
|
|
228
313
|
] });
|
|
229
314
|
}
|
|
230
315
|
);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
FORM SECTION
|
|
3
|
+
A heading and its sentence, then the fields
|
|
4
|
+
in a Grid and the section's actions. The
|
|
5
|
+
section is its own size container, so the
|
|
6
|
+
aside layout stacks by the room it has.
|
|
7
|
+
============================================ */
|
|
8
|
+
|
|
9
|
+
/* Base */
|
|
10
|
+
.ds-form-section {
|
|
11
|
+
container-type: inline-size;
|
|
12
|
+
min-width: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.ds-form-section--divider {
|
|
16
|
+
padding-block-start: var(--padding-500);
|
|
17
|
+
border-block-start: var(--border-025) solid var(--color-divider);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.ds-form-section__layout {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
gap: var(--gap-400);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.ds-form-section__intro {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
gap: var(--gap-100);
|
|
30
|
+
min-width: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.ds-form-section__title {
|
|
34
|
+
margin: 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.ds-form-section__description {
|
|
38
|
+
margin: 0;
|
|
39
|
+
font-family: var(--font-paragraph-sm-family);
|
|
40
|
+
font-size: var(--font-paragraph-sm-size);
|
|
41
|
+
font-weight: var(--font-paragraph-sm-weight);
|
|
42
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
43
|
+
letter-spacing: var(--font-paragraph-sm-letter-spacing);
|
|
44
|
+
color: var(--color-text-secondary);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.ds-form-section__body {
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
gap: var(--gap-500);
|
|
51
|
+
min-width: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* The section's own actions, at the end of the line under the fields. */
|
|
55
|
+
.ds-form-section__actions {
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-wrap: wrap;
|
|
58
|
+
justify-content: flex-end;
|
|
59
|
+
gap: var(--gap-200);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Aside: the heading in a third of the row, the fields beside it, once the
|
|
63
|
+
section has the room. */
|
|
64
|
+
@container (min-width: 721px) {
|
|
65
|
+
.ds-form-section--aside .ds-form-section__layout {
|
|
66
|
+
display: grid;
|
|
67
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
|
|
68
|
+
gap: var(--gap-1000);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** Props owned by FormSection itself; everything else falls through to the root `<section>`. */
|
|
3
|
+
type FormSectionOwnProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The section's heading.
|
|
6
|
+
* Note: this shadows the native `title` tooltip attribute, which FormSection does not expose.
|
|
7
|
+
*/
|
|
8
|
+
title: string;
|
|
9
|
+
/** A sentence on what the fields are for or what changing them does. */
|
|
10
|
+
description?: React.ReactNode;
|
|
11
|
+
/** The fields, laid out in `columns`. */
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
/** How many columns the fields run to; they fold to one as the section narrows. */
|
|
14
|
+
columns?: 1 | 2 | 3;
|
|
15
|
+
/** `stacked` puts the heading above the fields; `aside` sets it in a column beside them, the settings page's layout, stacking when the section is narrow. */
|
|
16
|
+
layout?: 'stacked' | 'aside';
|
|
17
|
+
/** The section's own controls, at the foot of the fields: a Save, a Cancel. */
|
|
18
|
+
actions?: React.ReactNode;
|
|
19
|
+
/** The heading's place in the outline. Defaults to 2, a section of a page. */
|
|
20
|
+
headingLevel?: 2 | 3 | 4;
|
|
21
|
+
/** Draws a rule above the section, for a column of sections. */
|
|
22
|
+
divider?: boolean;
|
|
23
|
+
/** Additional CSS classes */
|
|
24
|
+
className?: string;
|
|
25
|
+
};
|
|
26
|
+
export interface FormSectionProps extends FormSectionOwnProps, Omit<React.ComponentPropsWithRef<'section'>, keyof FormSectionOwnProps> {
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* One part of a form or a settings page: a heading and a sentence on what it
|
|
30
|
+
* is for, its fields in a grid that folds by the room it has, and its own
|
|
31
|
+
* actions at the foot. A column of them is a long form or a settings page.
|
|
32
|
+
* Server-renderable.
|
|
33
|
+
*/
|
|
34
|
+
export declare function FormSection({ title, description, children, columns, layout, actions, headingLevel, divider, className, ref, ...rest }: FormSectionProps): React.JSX.Element;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Grid } from "../Grid/Grid.js";
|
|
4
|
+
import { Heading } from "../Heading/Heading.js";
|
|
5
|
+
import "./FormSection.css";
|
|
6
|
+
function FormSection({
|
|
7
|
+
title,
|
|
8
|
+
description,
|
|
9
|
+
children,
|
|
10
|
+
columns = 1,
|
|
11
|
+
layout = "stacked",
|
|
12
|
+
actions,
|
|
13
|
+
headingLevel = 2,
|
|
14
|
+
divider = false,
|
|
15
|
+
className = "",
|
|
16
|
+
ref,
|
|
17
|
+
...rest
|
|
18
|
+
}) {
|
|
19
|
+
const hasDescription = description != null && description !== false && description !== "";
|
|
20
|
+
const hasActions = actions != null && actions !== false;
|
|
21
|
+
const classes = ["ds-form-section", `ds-form-section--${layout}`, divider ? "ds-form-section--divider" : "", className].filter(Boolean).join(" ");
|
|
22
|
+
return /* @__PURE__ */ jsx("section", { ...rest, ref, className: classes, children: /* @__PURE__ */ jsxs("div", { className: "ds-form-section__layout", children: [
|
|
23
|
+
/* @__PURE__ */ jsxs("div", { className: "ds-form-section__intro", children: [
|
|
24
|
+
/* @__PURE__ */ jsx(Heading, { level: headingLevel, tier: "title-body", className: "ds-form-section__title", children: title }),
|
|
25
|
+
hasDescription && /* @__PURE__ */ jsx("p", { className: "ds-form-section__description", children: description })
|
|
26
|
+
] }),
|
|
27
|
+
/* @__PURE__ */ jsxs("div", { className: "ds-form-section__body", children: [
|
|
28
|
+
/* @__PURE__ */ jsx(Grid, { columns, minColumnWidth: "14rem", gap: "400", align: "start", children }),
|
|
29
|
+
hasActions && /* @__PURE__ */ jsx("div", { className: "ds-form-section__actions", children: actions })
|
|
30
|
+
] })
|
|
31
|
+
] }) });
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
FormSection
|
|
35
|
+
};
|