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
|
@@ -13,6 +13,13 @@
|
|
|
13
13
|
padding: var(--padding-500);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/* The Widget tile's edge, for a theme whose page fill matches the panel's.
|
|
17
|
+
Box-sizing keeps a bordered panel the size of a plain one beside it. */
|
|
18
|
+
.ds-panel--bordered {
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
border: var(--border-025) solid var(--color-bg-container-border);
|
|
21
|
+
}
|
|
22
|
+
|
|
16
23
|
/* ============================================
|
|
17
24
|
PADDING VARIANTS
|
|
18
25
|
============================================ */
|
|
@@ -3,6 +3,8 @@ import { default as React } from 'react';
|
|
|
3
3
|
type PanelOwnProps = {
|
|
4
4
|
/** Interior padding: 'default' uses --padding-500, 'compact' uses --padding-400, 'none' removes it */
|
|
5
5
|
padding?: 'default' | 'compact' | 'none';
|
|
6
|
+
/** Draws the container border the Widget tile wears, so the panel keeps a visible edge in a theme whose page fill matches the panel's. */
|
|
7
|
+
bordered?: boolean;
|
|
6
8
|
/** Additional CSS classes */
|
|
7
9
|
className?: string;
|
|
8
10
|
/** Panel content */
|
|
@@ -12,8 +14,9 @@ export interface PanelProps extends PanelOwnProps, Omit<React.ComponentPropsWith
|
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
14
16
|
* Panel component: the plain dashboard surface.
|
|
15
|
-
* A rounded container on the primary container background with no
|
|
16
|
-
* no
|
|
17
|
+
* A rounded container on the primary container background with no shadow and,
|
|
18
|
+
* unless `bordered`, no border: just the surface, ready for whatever a
|
|
19
|
+
* dashboard region holds.
|
|
17
20
|
* Content stacks vertically with a medium gap.
|
|
18
21
|
*
|
|
19
22
|
* Forwards a ref to the `<div>` element and spreads unrecognised props onto it.
|
|
@@ -2,12 +2,13 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import "./Panel.css";
|
|
4
4
|
const Panel = React.forwardRef(
|
|
5
|
-
({ padding = "default", className = "", children, ...rest }, ref) => {
|
|
5
|
+
({ padding = "default", bordered = false, className = "", children, ...rest }, ref) => {
|
|
6
6
|
const baseClass = "ds-panel";
|
|
7
7
|
const classes = [
|
|
8
8
|
baseClass,
|
|
9
9
|
padding === "compact" ? `${baseClass}--compact` : "",
|
|
10
10
|
padding === "none" ? `${baseClass}--flush` : "",
|
|
11
|
+
bordered ? `${baseClass}--bordered` : "",
|
|
11
12
|
className
|
|
12
13
|
].filter(Boolean).join(" ");
|
|
13
14
|
return /* @__PURE__ */ jsx("div", { ...rest, ref, className: classes, children });
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
RESOURCE TIMELINE
|
|
3
|
+
A label column and a track of hours. Bars sit
|
|
4
|
+
on the track by their start and length as a
|
|
5
|
+
share of the day shown, on logical insets, so
|
|
6
|
+
the day runs from the reading direction's
|
|
7
|
+
start. A bar wears the calendar's event pill:
|
|
8
|
+
the event fill with an accent edge and the
|
|
9
|
+
label in the primary text colour, so it reads
|
|
10
|
+
on every theme whatever the accent.
|
|
11
|
+
============================================ */
|
|
12
|
+
|
|
13
|
+
/* Base */
|
|
14
|
+
.ds-resource-timeline {
|
|
15
|
+
--ds-resource-timeline-label: 9rem;
|
|
16
|
+
/* The narrowest an hour gets before the timeline scrolls: wide enough that
|
|
17
|
+
the first tick, held inside the axis, clears the centred one after it. */
|
|
18
|
+
--ds-resource-timeline-hour: calc(var(--gap-1000) + var(--gap-500));
|
|
19
|
+
|
|
20
|
+
min-width: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* A narrow column scrolls the day sideways; ScrollRegion makes it a
|
|
24
|
+
keyboard stop only while it does. */
|
|
25
|
+
.ds-resource-timeline__scroll {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
overflow-x: auto;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* Header: the label column's title and the hour ticks */
|
|
32
|
+
.ds-resource-timeline__head {
|
|
33
|
+
display: grid;
|
|
34
|
+
grid-template-columns: var(--ds-resource-timeline-label) minmax(0, 1fr);
|
|
35
|
+
min-width: calc(var(--ds-resource-timeline-label) + var(--ds-resource-timeline-hours, 16) * var(--ds-resource-timeline-hour));
|
|
36
|
+
padding-block-end: var(--padding-200);
|
|
37
|
+
border-block-end: var(--border-025) solid var(--color-divider);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.ds-resource-timeline__row-header,
|
|
41
|
+
.ds-resource-timeline__tick {
|
|
42
|
+
font-family: var(--font-caption-family);
|
|
43
|
+
font-size: var(--font-caption-size);
|
|
44
|
+
font-weight: var(--font-caption-weight);
|
|
45
|
+
line-height: var(--font-caption-line-height);
|
|
46
|
+
letter-spacing: var(--font-caption-letter-spacing);
|
|
47
|
+
color: var(--color-text-tertiary);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.ds-resource-timeline__axis {
|
|
51
|
+
position: relative;
|
|
52
|
+
min-height: var(--font-caption-line-height);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.ds-resource-timeline__tick {
|
|
56
|
+
position: absolute;
|
|
57
|
+
inset-block-start: 0;
|
|
58
|
+
transform: translateX(calc(-50% * var(--ds-inline-sign, 1)));
|
|
59
|
+
white-space: nowrap;
|
|
60
|
+
font-variant-numeric: tabular-nums;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* The ticks centre on their hour; the first and last sit inside the axis
|
|
64
|
+
so neither hangs past the track's ends. */
|
|
65
|
+
.ds-resource-timeline__tick:first-child {
|
|
66
|
+
transform: none;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.ds-resource-timeline__tick:last-child {
|
|
70
|
+
transform: translateX(calc(-100% * var(--ds-inline-sign, 1)));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Rows */
|
|
74
|
+
.ds-resource-timeline__rows {
|
|
75
|
+
display: flex;
|
|
76
|
+
flex-direction: column;
|
|
77
|
+
margin: 0;
|
|
78
|
+
padding: 0;
|
|
79
|
+
list-style: none;
|
|
80
|
+
min-width: calc(var(--ds-resource-timeline-label) + var(--ds-resource-timeline-hours, 16) * var(--ds-resource-timeline-hour));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.ds-resource-timeline__row {
|
|
84
|
+
display: grid;
|
|
85
|
+
grid-template-columns: var(--ds-resource-timeline-label) minmax(0, 1fr);
|
|
86
|
+
align-items: center;
|
|
87
|
+
min-height: var(--control-height-default);
|
|
88
|
+
border-block-end: var(--border-025) solid var(--color-divider);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.ds-resource-timeline__label {
|
|
92
|
+
overflow: hidden;
|
|
93
|
+
text-overflow: ellipsis;
|
|
94
|
+
white-space: nowrap;
|
|
95
|
+
padding-inline-end: var(--padding-300);
|
|
96
|
+
font-family: var(--font-paragraph-sm-family);
|
|
97
|
+
font-size: var(--font-paragraph-sm-size);
|
|
98
|
+
font-weight: var(--font-paragraph-sm-weight);
|
|
99
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
100
|
+
letter-spacing: var(--font-paragraph-sm-letter-spacing);
|
|
101
|
+
color: var(--color-text-primary);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.ds-resource-timeline__track {
|
|
105
|
+
position: relative;
|
|
106
|
+
align-self: stretch;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* Each hour's line sits on the hour, its width back over it, so the last
|
|
110
|
+
one stays inside the track's end. */
|
|
111
|
+
.ds-resource-timeline__gridline {
|
|
112
|
+
position: absolute;
|
|
113
|
+
inset-block: 0;
|
|
114
|
+
margin-inline-start: calc(var(--border-025) * -1);
|
|
115
|
+
border-inline-start: var(--border-025) solid var(--color-divider);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* The time now: a line across the row in the error role, the convention
|
|
119
|
+
for a live marker on a schedule. */
|
|
120
|
+
.ds-resource-timeline__now {
|
|
121
|
+
position: absolute;
|
|
122
|
+
inset-block: 0;
|
|
123
|
+
border-inline-start: var(--border-050) solid var(--color-status-error-border);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* Bars */
|
|
127
|
+
.ds-resource-timeline__bar {
|
|
128
|
+
--ds-resource-timeline-accent: var(--color-status-neutral-border);
|
|
129
|
+
|
|
130
|
+
position: absolute;
|
|
131
|
+
inset-block: var(--padding-100);
|
|
132
|
+
display: flex;
|
|
133
|
+
align-items: center;
|
|
134
|
+
min-width: 0;
|
|
135
|
+
margin: 0;
|
|
136
|
+
padding: 0 var(--padding-150);
|
|
137
|
+
overflow: hidden;
|
|
138
|
+
background-color: var(--color-calendar-event-bg);
|
|
139
|
+
border: var(--border-025) solid var(--color-calendar-event-border);
|
|
140
|
+
border-inline-start: var(--border-050) solid var(--ds-resource-timeline-accent);
|
|
141
|
+
border-radius: var(--radius-100);
|
|
142
|
+
text-align: start;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
button.ds-resource-timeline__bar {
|
|
146
|
+
cursor: pointer;
|
|
147
|
+
transition: background-color var(--motion-duration-fast) var(--motion-ease-standard);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
button.ds-resource-timeline__bar:hover {
|
|
151
|
+
background-color: var(--color-calendar-event-bg-hover);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
button.ds-resource-timeline__bar:focus-visible {
|
|
155
|
+
outline: 2px solid var(--color-action-primary-bg);
|
|
156
|
+
outline-offset: 2px;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.ds-resource-timeline__bar-label {
|
|
160
|
+
overflow: hidden;
|
|
161
|
+
text-overflow: ellipsis;
|
|
162
|
+
white-space: nowrap;
|
|
163
|
+
font-family: var(--font-paragraph-sm-emphasis-family);
|
|
164
|
+
font-size: var(--font-paragraph-sm-emphasis-size);
|
|
165
|
+
font-weight: var(--font-paragraph-sm-emphasis-weight);
|
|
166
|
+
line-height: var(--font-paragraph-sm-emphasis-line-height);
|
|
167
|
+
letter-spacing: var(--font-paragraph-sm-emphasis-letter-spacing);
|
|
168
|
+
color: var(--color-text-primary);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* Accents: the core accent roles, never the action colour */
|
|
172
|
+
.ds-resource-timeline__bar--coral {
|
|
173
|
+
--ds-resource-timeline-accent: var(--color-core-accent-coral);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.ds-resource-timeline__bar--violet {
|
|
177
|
+
--ds-resource-timeline-accent: var(--color-core-accent-violet);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.ds-resource-timeline__bar--cobalt {
|
|
181
|
+
--ds-resource-timeline-accent: var(--color-core-accent-cobalt);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.ds-resource-timeline__bar--amber {
|
|
185
|
+
--ds-resource-timeline-accent: var(--color-core-accent-amber);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.ds-resource-timeline__bar--gold {
|
|
189
|
+
--ds-resource-timeline-accent: var(--color-core-accent-gold);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.ds-resource-timeline__bar--mint {
|
|
193
|
+
--ds-resource-timeline-accent: var(--color-core-accent-mint);
|
|
194
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** The accents a bar can take, the core accent roles the calendar's events use. */
|
|
3
|
+
export type ResourceTimelineColor = "neutral" | "coral" | "violet" | "cobalt" | "amber" | "gold" | "mint";
|
|
4
|
+
/** One stretch of time on a row: a booking, a meeting, a run. */
|
|
5
|
+
export interface ResourceTimelineBar {
|
|
6
|
+
/** A stable id for the bar. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** When it starts, as 24-hour `HH:MM`. */
|
|
9
|
+
start: string;
|
|
10
|
+
/** When it ends, as 24-hour `HH:MM`. */
|
|
11
|
+
end: string;
|
|
12
|
+
/** A short label on the bar ("Front desk", "Break"). */
|
|
13
|
+
label?: string;
|
|
14
|
+
/** The bar's accent. Defaults to `neutral`. */
|
|
15
|
+
color?: ResourceTimelineColor;
|
|
16
|
+
}
|
|
17
|
+
/** One row of the timeline: a person, a room, a machine. */
|
|
18
|
+
export interface ResourceTimelineRow {
|
|
19
|
+
/** A stable id for the row. */
|
|
20
|
+
id: string;
|
|
21
|
+
/** What the row is, shown in the label column. */
|
|
22
|
+
label: string;
|
|
23
|
+
/** The row's bars, in any order. */
|
|
24
|
+
bars: ResourceTimelineBar[];
|
|
25
|
+
}
|
|
26
|
+
/** Props owned by ResourceTimeline itself; everything else falls through to the root `<div>`. */
|
|
27
|
+
type ResourceTimelineOwnProps = {
|
|
28
|
+
/** The rows, top to bottom. */
|
|
29
|
+
rows: ResourceTimelineRow[];
|
|
30
|
+
/** The first hour the axis shows, 0 to 23. Defaults to 6. */
|
|
31
|
+
startHour?: number;
|
|
32
|
+
/** The hour the axis ends at, 1 to 24. Defaults to 22. */
|
|
33
|
+
endHour?: number;
|
|
34
|
+
/** A line at this time (`HH:MM`), such as the time now. */
|
|
35
|
+
now?: string;
|
|
36
|
+
/** The timeline's name, read before its rows ("Bookings, Tuesday 4 March"). */
|
|
37
|
+
label: string;
|
|
38
|
+
/** The header of the label column. Defaults to "Name". */
|
|
39
|
+
rowHeaderLabel?: string;
|
|
40
|
+
/** Called with the bar and its row when a bar is pressed; bars are buttons only when it is set. */
|
|
41
|
+
onBarClick?: (bar: ResourceTimelineBar, row: ResourceTimelineRow) => void;
|
|
42
|
+
/** The BCP 47 locale the times are written in, such as `de-DE`. Defaults to `en-US`. This component can render from a Server Component, so it takes the prop alone and reads no LocaleProvider. */
|
|
43
|
+
locale?: string;
|
|
44
|
+
/** Additional CSS classes */
|
|
45
|
+
className?: string;
|
|
46
|
+
};
|
|
47
|
+
export interface ResourceTimelineProps extends ResourceTimelineOwnProps, Omit<React.ComponentPropsWithRef<"div">, keyof ResourceTimelineOwnProps | "children"> {
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Hours within one day: a row per person or resource, a bar from each
|
|
51
|
+
* start to its end, on an axis of hours in the reader's locale. Room
|
|
52
|
+
* bookings, a team's meetings, a machine's runs. Each bar is named with its row and its times,
|
|
53
|
+
* and its label sits on the calendar's event fill, so it reads in every
|
|
54
|
+
* theme whatever the accent. Server-renderable.
|
|
55
|
+
*/
|
|
56
|
+
export declare function ResourceTimeline({ rows, startHour, endHour, now, label, rowHeaderLabel, onBarClick, locale, className, style, ref, ...rest }: ResourceTimelineProps): React.JSX.Element;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { DEFAULT_LOCALE } from "../../behaviors/locale.js";
|
|
4
|
+
import { ScrollRegion } from "../../behaviors/ScrollRegion.js";
|
|
5
|
+
import "../../behaviors/visually-hidden.css";
|
|
6
|
+
import "../../behaviors/direction.css";
|
|
7
|
+
import "./ResourceTimeline.css";
|
|
8
|
+
const minutesOf = (time) => {
|
|
9
|
+
const match = /^(\d{1,2}):(\d{2})$/.exec(time);
|
|
10
|
+
if (!match) return null;
|
|
11
|
+
return Number(match[1]) * 60 + Number(match[2]);
|
|
12
|
+
};
|
|
13
|
+
function ResourceTimeline({
|
|
14
|
+
rows,
|
|
15
|
+
startHour = 6,
|
|
16
|
+
endHour = 22,
|
|
17
|
+
now,
|
|
18
|
+
label,
|
|
19
|
+
rowHeaderLabel = "Name",
|
|
20
|
+
onBarClick,
|
|
21
|
+
locale = DEFAULT_LOCALE,
|
|
22
|
+
className = "",
|
|
23
|
+
style,
|
|
24
|
+
ref,
|
|
25
|
+
...rest
|
|
26
|
+
}) {
|
|
27
|
+
const from = Math.max(0, Math.min(23, startHour)) * 60;
|
|
28
|
+
const to = Math.max(from / 60 + 1, Math.min(24, endHour)) * 60;
|
|
29
|
+
const span = to - from;
|
|
30
|
+
const at = (minutes) => (Math.min(Math.max(minutes, from), to) - from) / span * 100;
|
|
31
|
+
const hourFormat = new Intl.DateTimeFormat(locale, { hour: "numeric" });
|
|
32
|
+
const timeFormat = new Intl.DateTimeFormat(locale, {
|
|
33
|
+
hour: "numeric",
|
|
34
|
+
minute: "2-digit"
|
|
35
|
+
});
|
|
36
|
+
const asDate = (minutes) => new Date(2e3, 0, 1, Math.floor(minutes / 60), minutes % 60);
|
|
37
|
+
const range = (start, end) => timeFormat.formatRange(asDate(start), asDate(end));
|
|
38
|
+
const hours = [];
|
|
39
|
+
for (let h = from / 60; h <= to / 60; h++) hours.push(h);
|
|
40
|
+
const nowMinutes = now ? minutesOf(now) : null;
|
|
41
|
+
const classes = ["ds-resource-timeline", className].filter(Boolean).join(" ");
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
43
|
+
"div",
|
|
44
|
+
{
|
|
45
|
+
role: "group",
|
|
46
|
+
"aria-label": label,
|
|
47
|
+
...rest,
|
|
48
|
+
ref,
|
|
49
|
+
className: classes,
|
|
50
|
+
style: {
|
|
51
|
+
...style,
|
|
52
|
+
"--ds-resource-timeline-hours": hours.length - 1
|
|
53
|
+
},
|
|
54
|
+
children: /* @__PURE__ */ jsxs(ScrollRegion, { className: "ds-resource-timeline__scroll", children: [
|
|
55
|
+
/* @__PURE__ */ jsxs("div", { className: "ds-resource-timeline__head", "aria-hidden": "true", children: [
|
|
56
|
+
/* @__PURE__ */ jsx("span", { className: "ds-resource-timeline__row-header", children: rowHeaderLabel }),
|
|
57
|
+
/* @__PURE__ */ jsx("div", { className: "ds-resource-timeline__axis", children: hours.map((h) => /* @__PURE__ */ jsx(
|
|
58
|
+
"span",
|
|
59
|
+
{
|
|
60
|
+
className: "ds-resource-timeline__tick",
|
|
61
|
+
style: { insetInlineStart: `${at(h * 60)}%` },
|
|
62
|
+
children: h < 24 ? hourFormat.format(asDate(h * 60)) : ""
|
|
63
|
+
},
|
|
64
|
+
h
|
|
65
|
+
)) })
|
|
66
|
+
] }),
|
|
67
|
+
/* @__PURE__ */ jsx("ul", { className: "ds-resource-timeline__rows", children: rows.map((row) => /* @__PURE__ */ jsxs("li", { className: "ds-resource-timeline__row", children: [
|
|
68
|
+
/* @__PURE__ */ jsx("span", { className: "ds-resource-timeline__label", children: row.label }),
|
|
69
|
+
/* @__PURE__ */ jsxs("div", { className: "ds-resource-timeline__track", children: [
|
|
70
|
+
hours.map((h) => /* @__PURE__ */ jsx(
|
|
71
|
+
"span",
|
|
72
|
+
{
|
|
73
|
+
className: "ds-resource-timeline__gridline",
|
|
74
|
+
style: { insetInlineStart: `${at(h * 60)}%` },
|
|
75
|
+
"aria-hidden": "true"
|
|
76
|
+
},
|
|
77
|
+
h
|
|
78
|
+
)),
|
|
79
|
+
nowMinutes !== null && nowMinutes >= from && nowMinutes <= to && /* @__PURE__ */ jsx(
|
|
80
|
+
"span",
|
|
81
|
+
{
|
|
82
|
+
className: "ds-resource-timeline__now",
|
|
83
|
+
style: { insetInlineStart: `${at(nowMinutes)}%` },
|
|
84
|
+
"aria-hidden": "true"
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
row.bars.map((bar) => {
|
|
88
|
+
const start = minutesOf(bar.start);
|
|
89
|
+
const end = minutesOf(bar.end);
|
|
90
|
+
if (start === null || end === null || end <= start)
|
|
91
|
+
return null;
|
|
92
|
+
const name = `${row.label}, ${bar.label ? `${bar.label}, ` : ""}${range(start, end)}`;
|
|
93
|
+
const barClass = `ds-resource-timeline__bar ds-resource-timeline__bar--${bar.color ?? "neutral"}`;
|
|
94
|
+
const barStyle = {
|
|
95
|
+
insetInlineStart: `${at(start)}%`,
|
|
96
|
+
inlineSize: `${at(end) - at(start)}%`
|
|
97
|
+
};
|
|
98
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
99
|
+
/* @__PURE__ */ jsx(
|
|
100
|
+
"span",
|
|
101
|
+
{
|
|
102
|
+
className: "ds-resource-timeline__bar-label",
|
|
103
|
+
"aria-hidden": "true",
|
|
104
|
+
children: bar.label ?? range(start, end)
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
/* @__PURE__ */ jsx("span", { className: "ds-visually-hidden", children: name })
|
|
108
|
+
] });
|
|
109
|
+
return onBarClick ? /* @__PURE__ */ jsx(
|
|
110
|
+
"button",
|
|
111
|
+
{
|
|
112
|
+
type: "button",
|
|
113
|
+
className: barClass,
|
|
114
|
+
style: barStyle,
|
|
115
|
+
onClick: () => onBarClick(bar, row),
|
|
116
|
+
children: content
|
|
117
|
+
},
|
|
118
|
+
bar.id
|
|
119
|
+
) : /* @__PURE__ */ jsx("span", { className: barClass, style: barStyle, children: content }, bar.id);
|
|
120
|
+
})
|
|
121
|
+
] })
|
|
122
|
+
] }, row.id)) })
|
|
123
|
+
] })
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
export {
|
|
128
|
+
ResourceTimeline
|
|
129
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useState, useRef, useEffect } from "react";
|
|
3
3
|
import { BLOB_COUNT, vertexSource, fragmentSource } from "./field.glsl.js";
|
|
4
|
-
import { MOTION_CONTEXT_RESTORE_WAIT_MS, MOTION_SHADER_COLOR_FADE_MS } from "../../tokens/motion.js";
|
|
4
|
+
import { MOTION_CONTEXT_RESTORE_WAIT_MS, MOTION_SHADER_COLOR_CHECK_MS, MOTION_SHADER_COLOR_FADE_MS } from "../../tokens/motion.js";
|
|
5
5
|
const DEFAULT_SHADER_PARAMS = {
|
|
6
6
|
intensity: 0.5,
|
|
7
7
|
warp: 0.14,
|
|
@@ -32,6 +32,7 @@ const FRAME_MS = 1e3 / 30;
|
|
|
32
32
|
const FRAME_MS_ACTIVE = 1e3 / 60;
|
|
33
33
|
const WAKE_IDLE = 0.015;
|
|
34
34
|
const COLOR_FADE_MS = MOTION_SHADER_COLOR_FADE_MS;
|
|
35
|
+
const COLOR_CHECK_MS = MOTION_SHADER_COLOR_CHECK_MS;
|
|
35
36
|
function parseColor(value) {
|
|
36
37
|
const v = value.trim();
|
|
37
38
|
const hex = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(v);
|
|
@@ -169,8 +170,15 @@ function useShaderField(canvasRef, params, enabled = true) {
|
|
|
169
170
|
const colorCurrent = new Float32Array(BLOB_COUNT * 3);
|
|
170
171
|
const colorTarget = new Float32Array(BLOB_COUNT * 3);
|
|
171
172
|
let colorFadeT = COLOR_FADE_MS;
|
|
173
|
+
let colorSignature = "";
|
|
174
|
+
let colorsChecked = 0;
|
|
175
|
+
function readSignature() {
|
|
176
|
+
const style = getComputedStyle(canvas);
|
|
177
|
+
return paramsRef.current.blobs.slice(0, BLOB_COUNT).map((b) => style.getPropertyValue(b.token).trim()).join("|");
|
|
178
|
+
}
|
|
172
179
|
function readColors(into) {
|
|
173
180
|
const style = getComputedStyle(canvas);
|
|
181
|
+
colorSignature = readSignature();
|
|
174
182
|
into.fill(0);
|
|
175
183
|
paramsRef.current.blobs.slice(0, BLOB_COUNT).forEach((b, i) => {
|
|
176
184
|
const parsed = parseColor(style.getPropertyValue(b.token));
|
|
@@ -283,6 +291,10 @@ function useShaderField(canvasRef, params, enabled = true) {
|
|
|
283
291
|
if (elapsed < frameBudget - 1) return;
|
|
284
292
|
const dt = Math.min(elapsed, 100);
|
|
285
293
|
lastDraw = now;
|
|
294
|
+
if (now - colorsChecked >= COLOR_CHECK_MS) {
|
|
295
|
+
colorsChecked = now;
|
|
296
|
+
if (readSignature() !== colorSignature) colorsDirty = true;
|
|
297
|
+
}
|
|
286
298
|
fieldTime += dt / 1e3 * paramsRef.current.speed;
|
|
287
299
|
draw(dt);
|
|
288
300
|
}
|
|
@@ -5,8 +5,9 @@ export type ShaderSceneId = 'horizon' | 'rift' | 'glyphs' | 'prism' | 'meteors'
|
|
|
5
5
|
/**
|
|
6
6
|
* How the scene resolved, the same three states ShaderField reports.
|
|
7
7
|
* `pending` while the GL context comes up (bounded by a watchdog), `active`
|
|
8
|
-
* once a frame has painted, `unavailable` when it is disabled
|
|
9
|
-
* cannot run it
|
|
8
|
+
* once a frame has painted, `unavailable` when it is disabled, WebGL2
|
|
9
|
+
* cannot run it or its context is lost (it returns to `active` when the
|
|
10
|
+
* context comes back).
|
|
10
11
|
*/
|
|
11
12
|
export type ShaderSceneStatus = 'pending' | 'active' | 'unavailable';
|
|
12
13
|
/** One finishing pass's setting: whether it runs, and its own settings. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { MOTION_RENDERER_WATCHDOG_MS } from "../../tokens/motion.js";
|
|
4
|
+
import { MOTION_RENDERER_WATCHDOG_MS, MOTION_SHADER_COLOR_CHECK_MS } from "../../tokens/motion.js";
|
|
5
5
|
import { PASSES } from "./passes.js";
|
|
6
6
|
import { warnOnce } from "../../behaviors/devWarning.js";
|
|
7
7
|
import { sceneProblems } from "./assemble.js";
|
|
@@ -12,6 +12,7 @@ import { defaultsFor } from "./types.js";
|
|
|
12
12
|
import "./ShaderScene.css";
|
|
13
13
|
const MAX_PIXEL_RATIO = 1;
|
|
14
14
|
const FRAME_MS = 1e3 / 30;
|
|
15
|
+
const COLOUR_CHECK_MS = MOTION_SHADER_COLOR_CHECK_MS;
|
|
15
16
|
const DEFAULT_SPEED = 1.6;
|
|
16
17
|
function ShaderScene({
|
|
17
18
|
scene = "horizon",
|
|
@@ -78,6 +79,7 @@ function ShaderScene({
|
|
|
78
79
|
}, [merged]);
|
|
79
80
|
const [gl, setGl] = React.useState("pending");
|
|
80
81
|
const [gaveUp, setGaveUp] = React.useState(false);
|
|
82
|
+
const [restored, setRestored] = React.useState(0);
|
|
81
83
|
React.useEffect(() => {
|
|
82
84
|
if (!enabled || gl !== "pending") return;
|
|
83
85
|
const timer = window.setTimeout(() => setGaveUp(true), MOTION_RENDERER_WATCHDOG_MS);
|
|
@@ -113,11 +115,41 @@ function ShaderScene({
|
|
|
113
115
|
console.warn(log);
|
|
114
116
|
reportError.current?.(log);
|
|
115
117
|
}) : null;
|
|
118
|
+
let lost = false;
|
|
119
|
+
const onContextLost = (event) => {
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
lost = true;
|
|
122
|
+
setGl("failed");
|
|
123
|
+
};
|
|
124
|
+
const onContextRestored = () => {
|
|
125
|
+
setGl("pending");
|
|
126
|
+
setRestored((count) => count + 1);
|
|
127
|
+
};
|
|
128
|
+
canvas?.addEventListener("webglcontextlost", onContextLost);
|
|
129
|
+
canvas?.addEventListener("webglcontextrestored", onContextRestored);
|
|
130
|
+
const unlisten = () => {
|
|
131
|
+
canvas?.removeEventListener("webglcontextlost", onContextLost);
|
|
132
|
+
canvas?.removeEventListener("webglcontextrestored", onContextRestored);
|
|
133
|
+
};
|
|
116
134
|
if (!host || !canvas || !renderer) {
|
|
117
135
|
const failed = requestAnimationFrame(() => setGl("failed"));
|
|
118
|
-
return () =>
|
|
136
|
+
return () => {
|
|
137
|
+
cancelAnimationFrame(failed);
|
|
138
|
+
unlisten();
|
|
139
|
+
};
|
|
119
140
|
}
|
|
141
|
+
const colourTokens = ["--color-bg-page-primary", ...definition.colours];
|
|
142
|
+
const colourSignature = () => {
|
|
143
|
+
const styles = getComputedStyle(host);
|
|
144
|
+
return [
|
|
145
|
+
document.documentElement.getAttribute("data-theme"),
|
|
146
|
+
...colourTokens.map((token) => styles.getPropertyValue(token).trim())
|
|
147
|
+
].join("|");
|
|
148
|
+
};
|
|
149
|
+
let appliedColours = "";
|
|
150
|
+
let coloursChecked = 0;
|
|
120
151
|
const applyColours = () => {
|
|
152
|
+
appliedColours = colourSignature();
|
|
121
153
|
renderer.setColours(coloursFor(host, definition));
|
|
122
154
|
renderer.setGlyphs(glyphFontFor(host));
|
|
123
155
|
};
|
|
@@ -137,7 +169,12 @@ function ShaderScene({
|
|
|
137
169
|
let painted = false;
|
|
138
170
|
const draw = (now) => {
|
|
139
171
|
frame = requestAnimationFrame(draw);
|
|
172
|
+
if (lost) return;
|
|
140
173
|
if (painted && now - last < FRAME_MS - 1) return;
|
|
174
|
+
if (now - coloursChecked >= COLOUR_CHECK_MS) {
|
|
175
|
+
coloursChecked = now;
|
|
176
|
+
if (colourSignature() !== appliedColours) applyColours();
|
|
177
|
+
}
|
|
141
178
|
const values = liveRef?.current ?? mergedRef.current;
|
|
142
179
|
const dt = Math.min(0.1, (now - last) / 1e3);
|
|
143
180
|
last = now;
|
|
@@ -174,7 +211,7 @@ function ShaderScene({
|
|
|
174
211
|
);
|
|
175
212
|
visibilityObserver?.observe(host);
|
|
176
213
|
const sizeObserver = new ResizeObserver(() => {
|
|
177
|
-
if (frame) return;
|
|
214
|
+
if (frame || lost) return;
|
|
178
215
|
fit();
|
|
179
216
|
renderer.draw(liveRef?.current ?? mergedRef.current, time, canvas.width, canvas.height, ratio);
|
|
180
217
|
});
|
|
@@ -184,15 +221,21 @@ function ShaderScene({
|
|
|
184
221
|
attributes: true,
|
|
185
222
|
attributeFilter: ["data-theme", "data-brand", "style"]
|
|
186
223
|
});
|
|
224
|
+
const onSheetLoad = (event) => {
|
|
225
|
+
if (event.target instanceof HTMLLinkElement && colourSignature() !== appliedColours) applyColours();
|
|
226
|
+
};
|
|
227
|
+
document.addEventListener("load", onSheetLoad, true);
|
|
187
228
|
return () => {
|
|
188
229
|
mounted = false;
|
|
230
|
+
unlisten();
|
|
231
|
+
document.removeEventListener("load", onSheetLoad, true);
|
|
189
232
|
stop();
|
|
190
233
|
visibilityObserver?.disconnect();
|
|
191
234
|
sizeObserver.disconnect();
|
|
192
235
|
themeObserver.disconnect();
|
|
193
236
|
renderer.dispose();
|
|
194
237
|
};
|
|
195
|
-
}, [definition, custom, liveRef, enabled]);
|
|
238
|
+
}, [definition, custom, liveRef, enabled, restored]);
|
|
196
239
|
const classes = ["ds-shader-scene", className].filter(Boolean).join(" ");
|
|
197
240
|
return /* @__PURE__ */ jsx("div", { ...rest, ref: setRef, className: classes, "data-status": status, "aria-hidden": "true", children: enabled && /* @__PURE__ */ jsx("canvas", { ref: canvasRef, className: "ds-shader-scene__canvas" }) });
|
|
198
241
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
STACK
|
|
3
|
+
Children in one direction, a gap from the
|
|
4
|
+
scale between them. The gap arrives as
|
|
5
|
+
--ds-stack-gap, set from the `gap` prop.
|
|
6
|
+
============================================ */
|
|
7
|
+
|
|
8
|
+
/* Base */
|
|
9
|
+
.ds-stack {
|
|
10
|
+
display: flex;
|
|
11
|
+
gap: var(--ds-stack-gap, var(--gap-400));
|
|
12
|
+
min-width: 0;
|
|
13
|
+
margin: 0;
|
|
14
|
+
padding: 0;
|
|
15
|
+
border: 0;
|
|
16
|
+
list-style: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/* Direction */
|
|
20
|
+
.ds-stack--column {
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.ds-stack--row {
|
|
25
|
+
flex-direction: row;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.ds-stack--wrap {
|
|
29
|
+
flex-wrap: wrap;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Alignment across the stack */
|
|
33
|
+
.ds-stack--align-start {
|
|
34
|
+
align-items: flex-start;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.ds-stack--align-center {
|
|
38
|
+
align-items: center;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.ds-stack--align-end {
|
|
42
|
+
align-items: flex-end;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.ds-stack--align-baseline {
|
|
46
|
+
align-items: baseline;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.ds-stack--align-stretch {
|
|
50
|
+
align-items: stretch;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* Spread along the stack */
|
|
54
|
+
.ds-stack--justify-start {
|
|
55
|
+
justify-content: flex-start;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.ds-stack--justify-center {
|
|
59
|
+
justify-content: center;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.ds-stack--justify-end {
|
|
63
|
+
justify-content: flex-end;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.ds-stack--justify-between {
|
|
67
|
+
justify-content: space-between;
|
|
68
|
+
}
|