@oaiz/app-kit 0.0.0-stage → 0.1.4128
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 +143 -2
- package/THIRD_PARTY_NOTICES.md +76 -0
- package/package.json +139 -4
- package/registry.json +1847 -0
- package/src/components/activity-timeline.tsx +227 -0
- package/src/components/app-shell.tsx +622 -0
- package/src/components/bar-list.tsx +47 -0
- package/src/components/board.tsx +700 -0
- package/src/components/calendar-view.tsx +1388 -0
- package/src/components/card-grid.tsx +462 -0
- package/src/components/charts.tsx +701 -0
- package/src/components/chat-markdown.tsx +230 -0
- package/src/components/chat-panel.tsx +760 -0
- package/src/components/code-editor.tsx +276 -0
- package/src/components/collection-controls.tsx +226 -0
- package/src/components/command-palette.tsx +403 -0
- package/src/components/confirm-action.tsx +123 -0
- package/src/components/data-table.tsx +821 -0
- package/src/components/date-input.tsx +429 -0
- package/src/components/empty-state.tsx +31 -0
- package/src/components/error-state.tsx +37 -0
- package/src/components/file-upload.tsx +595 -0
- package/src/components/filter-bar.tsx +415 -0
- package/src/components/grouped-picker.tsx +250 -0
- package/src/components/line-items.tsx +601 -0
- package/src/components/list-view.tsx +491 -0
- package/src/components/metrics.tsx +53 -0
- package/src/components/page-header.tsx +33 -0
- package/src/components/property-picker.tsx +546 -0
- package/src/components/record-detail.tsx +416 -0
- package/src/components/record-form.tsx +295 -0
- package/src/components/record-name.tsx +85 -0
- package/src/components/save-bar.tsx +142 -0
- package/src/components/sign-in.tsx +179 -0
- package/src/components/split-view.tsx +128 -0
- package/src/components/status-dot.tsx +56 -0
- package/src/components/stepper.tsx +153 -0
- package/src/components/text-diff-model.ts +111 -0
- package/src/components/text-diff.tsx +98 -0
- package/src/components/time-zone-picker.tsx +69 -0
- package/src/components/ui/accordion.tsx +138 -0
- package/src/components/ui/alert-dialog.tsx +67 -0
- package/src/components/ui/alert.tsx +65 -0
- package/src/components/ui/avatar-group.tsx +119 -0
- package/src/components/ui/avatar.tsx +55 -0
- package/src/components/ui/badge.tsx +59 -0
- package/src/components/ui/bottom-navigation.tsx +102 -0
- package/src/components/ui/breadcrumb.tsx +117 -0
- package/src/components/ui/button.tsx +71 -0
- package/src/components/ui/card.tsx +95 -0
- package/src/components/ui/checkbox.tsx +31 -0
- package/src/components/ui/collapsible.tsx +27 -0
- package/src/components/ui/context-menu.tsx +270 -0
- package/src/components/ui/count-up.tsx +136 -0
- package/src/components/ui/detail-disclosure-section.tsx +109 -0
- package/src/components/ui/dialog.tsx +157 -0
- package/src/components/ui/dropdown-menu.tsx +273 -0
- package/src/components/ui/form-field.tsx +155 -0
- package/src/components/ui/heading.tsx +126 -0
- package/src/components/ui/hover-card.tsx +45 -0
- package/src/components/ui/input.tsx +50 -0
- package/src/components/ui/label.tsx +30 -0
- package/src/components/ui/orb-spinner.tsx +238 -0
- package/src/components/ui/popover.tsx +59 -0
- package/src/components/ui/progress-ring.tsx +125 -0
- package/src/components/ui/progress.tsx +38 -0
- package/src/components/ui/radio-group.tsx +124 -0
- package/src/components/ui/resizable.tsx +48 -0
- package/src/components/ui/scroll-fade.tsx +98 -0
- package/src/components/ui/segmented-control.tsx +70 -0
- package/src/components/ui/select.tsx +230 -0
- package/src/components/ui/separator.tsx +29 -0
- package/src/components/ui/sheet.tsx +170 -0
- package/src/components/ui/shimmer-text.tsx +87 -0
- package/src/components/ui/shortcut.tsx +39 -0
- package/src/components/ui/skeleton.tsx +15 -0
- package/src/components/ui/slider.tsx +48 -0
- package/src/components/ui/switch.tsx +44 -0
- package/src/components/ui/table.tsx +119 -0
- package/src/components/ui/tabs.tsx +80 -0
- package/src/components/ui/text.tsx +93 -0
- package/src/components/ui/textarea.tsx +51 -0
- package/src/components/ui/toast.tsx +141 -0
- package/src/components/ui/toaster.tsx +40 -0
- package/src/components/ui/tooltip.tsx +38 -0
- package/src/components/ui/top-banner.tsx +108 -0
- package/src/components/ui/tree-view.tsx +215 -0
- package/src/components/ui/use-toast.tsx +184 -0
- package/src/components/ui/voice-orb.tsx +252 -0
- package/src/hooks/oaiz-chat.tsx +530 -0
- package/src/hooks/oaiz-data.tsx +617 -0
- package/src/hooks/oaiz-session.tsx +63 -0
- package/src/hooks/use-arrivals.ts +19 -0
- package/src/hooks/use-breakpoint.ts +100 -0
- package/src/hooks/use-media-query.ts +36 -0
- package/src/hooks/use-theme.ts +67 -0
- package/src/hooks/use-url-state.ts +77 -0
- package/src/lib/breakpoints.ts +81 -0
- package/src/lib/csp-nonce.ts +15 -0
- package/src/lib/format.ts +291 -0
- package/src/lib/speech-level.ts +118 -0
- package/src/lib/utils.ts +109 -0
- package/src/styles/oaiz/app.css +21 -0
- package/src/styles/oaiz/scrollbars.css +20 -0
- package/src/styles/oaiz/tokens.css +952 -0
- package/src/styles/oaiz/voice-orb.css +39 -0
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import { useId, useState, type ReactNode } from 'react';
|
|
2
|
+
import { Temporal } from 'temporal-polyfill';
|
|
3
|
+
|
|
4
|
+
import { cn } from '../lib/utils';
|
|
5
|
+
import { FormField, FieldGroup } from './ui/form-field';
|
|
6
|
+
import { Input } from './ui/input';
|
|
7
|
+
import { Label } from './ui/label';
|
|
8
|
+
import { Text } from './ui/text';
|
|
9
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './ui/select';
|
|
10
|
+
|
|
11
|
+
export type DateInputProps = {
|
|
12
|
+
label: string;
|
|
13
|
+
/** A calendar day, YYYY-MM-DD. It is not an instant or a UTC timestamp. */
|
|
14
|
+
value: string;
|
|
15
|
+
onChange: (value: string) => void;
|
|
16
|
+
min?: string;
|
|
17
|
+
max?: string;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
error?: string;
|
|
21
|
+
hint?: ReactNode;
|
|
22
|
+
requiredLabel?: string;
|
|
23
|
+
className?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export function DateInput({
|
|
27
|
+
label,
|
|
28
|
+
value,
|
|
29
|
+
onChange,
|
|
30
|
+
min,
|
|
31
|
+
max,
|
|
32
|
+
required,
|
|
33
|
+
disabled,
|
|
34
|
+
error,
|
|
35
|
+
hint,
|
|
36
|
+
requiredLabel,
|
|
37
|
+
className,
|
|
38
|
+
}: DateInputProps) {
|
|
39
|
+
return (
|
|
40
|
+
<FormField
|
|
41
|
+
label={label}
|
|
42
|
+
hint={hint}
|
|
43
|
+
error={error}
|
|
44
|
+
required={required}
|
|
45
|
+
requiredLabel={requiredLabel}
|
|
46
|
+
className={className}
|
|
47
|
+
>
|
|
48
|
+
{(control) => (
|
|
49
|
+
<Input
|
|
50
|
+
{...control}
|
|
51
|
+
type="date"
|
|
52
|
+
value={value}
|
|
53
|
+
min={min}
|
|
54
|
+
max={max}
|
|
55
|
+
disabled={disabled}
|
|
56
|
+
onChange={(event) => onChange(event.target.value)}
|
|
57
|
+
className="tabular-nums"
|
|
58
|
+
/>
|
|
59
|
+
)}
|
|
60
|
+
</FormField>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type DateRange = { from: string; to: string };
|
|
65
|
+
export type DateRangeMessages = {
|
|
66
|
+
from: string;
|
|
67
|
+
to: string;
|
|
68
|
+
invalid: string;
|
|
69
|
+
reversed: string;
|
|
70
|
+
beforeMin: (min: string) => string;
|
|
71
|
+
afterMax: (max: string) => string;
|
|
72
|
+
};
|
|
73
|
+
const RANGE_MESSAGES: DateRangeMessages = {
|
|
74
|
+
from: 'from',
|
|
75
|
+
to: 'to',
|
|
76
|
+
invalid: 'Enter valid calendar dates.',
|
|
77
|
+
reversed: 'The end date must be on or after the start date.',
|
|
78
|
+
beforeMin: (min) => `Choose dates on or after ${min}.`,
|
|
79
|
+
afterMax: (max) => `Choose dates on or before ${max}.`,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export function dateRangeError(
|
|
83
|
+
value: DateRange,
|
|
84
|
+
min?: string,
|
|
85
|
+
max?: string,
|
|
86
|
+
messages: DateRangeMessages = RANGE_MESSAGES,
|
|
87
|
+
): string | undefined {
|
|
88
|
+
try {
|
|
89
|
+
for (const date of [value.from, value.to].filter(Boolean)) {
|
|
90
|
+
Temporal.PlainDate.from(date, { overflow: 'reject' });
|
|
91
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) return messages.invalid;
|
|
92
|
+
if (min && date < min) return messages.beforeMin(min);
|
|
93
|
+
if (max && date > max) return messages.afterMax(max);
|
|
94
|
+
}
|
|
95
|
+
} catch {
|
|
96
|
+
return messages.invalid;
|
|
97
|
+
}
|
|
98
|
+
if (value.from && value.to && value.from > value.to) return messages.reversed;
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export type DateRangeInputProps = {
|
|
103
|
+
label: string;
|
|
104
|
+
value: DateRange;
|
|
105
|
+
onChange: (value: DateRange) => void;
|
|
106
|
+
min?: string;
|
|
107
|
+
max?: string;
|
|
108
|
+
disabled?: boolean;
|
|
109
|
+
error?: string;
|
|
110
|
+
messages?: Partial<DateRangeMessages>;
|
|
111
|
+
className?: string;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/** Native limits guide the picker; explicit validation also checks controlled or typed values. */
|
|
115
|
+
export function DateRangeInput({
|
|
116
|
+
label,
|
|
117
|
+
value,
|
|
118
|
+
onChange,
|
|
119
|
+
min,
|
|
120
|
+
max,
|
|
121
|
+
disabled,
|
|
122
|
+
error,
|
|
123
|
+
messages: overrides,
|
|
124
|
+
className,
|
|
125
|
+
}: DateRangeInputProps) {
|
|
126
|
+
const messages = { ...RANGE_MESSAGES, ...overrides };
|
|
127
|
+
const [nativeInvalid, setNativeInvalid] = useState({
|
|
128
|
+
from: false,
|
|
129
|
+
to: false,
|
|
130
|
+
});
|
|
131
|
+
const problem =
|
|
132
|
+
error ??
|
|
133
|
+
(nativeInvalid.from || nativeInvalid.to
|
|
134
|
+
? messages.invalid
|
|
135
|
+
: dateRangeError(value, min, max, messages));
|
|
136
|
+
const id = useId();
|
|
137
|
+
const latestStart = [value.to, max].filter(Boolean).sort()[0];
|
|
138
|
+
const earliestEnd = [value.from, min].filter(Boolean).sort().slice(-1)[0];
|
|
139
|
+
return (
|
|
140
|
+
<FieldGroup
|
|
141
|
+
legend={label}
|
|
142
|
+
disabled={disabled}
|
|
143
|
+
className={className}
|
|
144
|
+
aria-describedby={problem ? `${id}-error` : undefined}
|
|
145
|
+
>
|
|
146
|
+
<div className="grid gap-inline mobile:grid-cols-2">
|
|
147
|
+
<div className="flex flex-col gap-1.5">
|
|
148
|
+
<Label htmlFor={`${id}-from`}>
|
|
149
|
+
{label} {messages.from}
|
|
150
|
+
</Label>
|
|
151
|
+
<Input
|
|
152
|
+
id={`${id}-from`}
|
|
153
|
+
type="date"
|
|
154
|
+
value={value.from}
|
|
155
|
+
onInput={(event) => {
|
|
156
|
+
const bad = event.currentTarget.validity.badInput;
|
|
157
|
+
setNativeInvalid((current) => ({ ...current, from: bad }));
|
|
158
|
+
}}
|
|
159
|
+
onBlur={(event) => {
|
|
160
|
+
const bad = event.currentTarget.validity.badInput;
|
|
161
|
+
setNativeInvalid((current) => ({ ...current, from: bad }));
|
|
162
|
+
}}
|
|
163
|
+
min={min}
|
|
164
|
+
max={latestStart}
|
|
165
|
+
aria-invalid={Boolean(problem) || undefined}
|
|
166
|
+
aria-describedby={problem ? `${id}-error` : undefined}
|
|
167
|
+
onChange={(event) =>
|
|
168
|
+
onChange({ ...value, from: event.target.value })
|
|
169
|
+
}
|
|
170
|
+
/>
|
|
171
|
+
</div>
|
|
172
|
+
<div className="flex flex-col gap-1.5">
|
|
173
|
+
<Label htmlFor={`${id}-to`}>
|
|
174
|
+
{label} {messages.to}
|
|
175
|
+
</Label>
|
|
176
|
+
<Input
|
|
177
|
+
id={`${id}-to`}
|
|
178
|
+
type="date"
|
|
179
|
+
value={value.to}
|
|
180
|
+
onInput={(event) => {
|
|
181
|
+
const bad = event.currentTarget.validity.badInput;
|
|
182
|
+
setNativeInvalid((current) => ({ ...current, to: bad }));
|
|
183
|
+
}}
|
|
184
|
+
onBlur={(event) => {
|
|
185
|
+
const bad = event.currentTarget.validity.badInput;
|
|
186
|
+
setNativeInvalid((current) => ({ ...current, to: bad }));
|
|
187
|
+
}}
|
|
188
|
+
min={earliestEnd}
|
|
189
|
+
max={max}
|
|
190
|
+
aria-invalid={Boolean(problem) || undefined}
|
|
191
|
+
aria-describedby={problem ? `${id}-error` : undefined}
|
|
192
|
+
onChange={(event) => onChange({ ...value, to: event.target.value })}
|
|
193
|
+
/>
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
{problem && (
|
|
197
|
+
<Text id={`${id}-error`} size="sm" variant="destructive" role="alert">
|
|
198
|
+
{problem}
|
|
199
|
+
</Text>
|
|
200
|
+
)}
|
|
201
|
+
</FieldGroup>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export type TimeInputProps = Omit<DateInputProps, 'value'> & {
|
|
206
|
+
/** A wall-clock time HH:mm, without a date or timezone conversion. */
|
|
207
|
+
value: string;
|
|
208
|
+
/** Native time input step, in seconds. */
|
|
209
|
+
step?: number;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
export function TimeInput({
|
|
213
|
+
label,
|
|
214
|
+
value,
|
|
215
|
+
onChange,
|
|
216
|
+
min,
|
|
217
|
+
max,
|
|
218
|
+
required,
|
|
219
|
+
disabled,
|
|
220
|
+
error,
|
|
221
|
+
hint,
|
|
222
|
+
requiredLabel,
|
|
223
|
+
step = 60,
|
|
224
|
+
className,
|
|
225
|
+
}: TimeInputProps) {
|
|
226
|
+
return (
|
|
227
|
+
<FormField
|
|
228
|
+
label={label}
|
|
229
|
+
hint={hint}
|
|
230
|
+
error={error}
|
|
231
|
+
required={required}
|
|
232
|
+
requiredLabel={requiredLabel}
|
|
233
|
+
className={className}
|
|
234
|
+
>
|
|
235
|
+
{(control) => (
|
|
236
|
+
<Input
|
|
237
|
+
{...control}
|
|
238
|
+
type="time"
|
|
239
|
+
value={value}
|
|
240
|
+
min={min}
|
|
241
|
+
max={max}
|
|
242
|
+
step={step}
|
|
243
|
+
disabled={disabled}
|
|
244
|
+
onChange={(event) => onChange(event.target.value)}
|
|
245
|
+
className="tabular-nums"
|
|
246
|
+
/>
|
|
247
|
+
)}
|
|
248
|
+
</FormField>
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export type DateTimeResolution =
|
|
253
|
+
| { status: 'valid'; instant: string; offset: string }
|
|
254
|
+
| { status: 'empty' | 'invalid' | 'gap' }
|
|
255
|
+
| { status: 'ambiguous'; earlier: string; later: string };
|
|
256
|
+
export type DateTimeDisambiguation = 'earlier' | 'later';
|
|
257
|
+
|
|
258
|
+
/** Resolve an IANA-zone wall time; never silently shift a gap or choose a repeated hour. */
|
|
259
|
+
export function resolveDateTime(
|
|
260
|
+
value: string,
|
|
261
|
+
timeZone: string,
|
|
262
|
+
disambiguation?: DateTimeDisambiguation,
|
|
263
|
+
): DateTimeResolution {
|
|
264
|
+
if (!value) return { status: 'empty' };
|
|
265
|
+
try {
|
|
266
|
+
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?$/.test(value))
|
|
267
|
+
return { status: 'invalid' };
|
|
268
|
+
const plain = Temporal.PlainDateTime.from(value, { overflow: 'reject' });
|
|
269
|
+
const earlier = plain.toZonedDateTime(timeZone, {
|
|
270
|
+
disambiguation: 'earlier',
|
|
271
|
+
});
|
|
272
|
+
const later = plain.toZonedDateTime(timeZone, { disambiguation: 'later' });
|
|
273
|
+
if (
|
|
274
|
+
!earlier.toPlainDateTime().equals(plain) ||
|
|
275
|
+
!later.toPlainDateTime().equals(plain)
|
|
276
|
+
)
|
|
277
|
+
return { status: 'gap' };
|
|
278
|
+
if (
|
|
279
|
+
earlier.epochMilliseconds !== later.epochMilliseconds &&
|
|
280
|
+
!disambiguation
|
|
281
|
+
) {
|
|
282
|
+
return {
|
|
283
|
+
status: 'ambiguous',
|
|
284
|
+
earlier: earlier.offset,
|
|
285
|
+
later: later.offset,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
const chosen = disambiguation === 'later' ? later : earlier;
|
|
289
|
+
return {
|
|
290
|
+
status: 'valid',
|
|
291
|
+
instant: chosen.toInstant().toString(),
|
|
292
|
+
offset: chosen.offset,
|
|
293
|
+
};
|
|
294
|
+
} catch {
|
|
295
|
+
return { status: 'invalid' };
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export type DateTimeMessages = {
|
|
300
|
+
zone: (timeZone: string) => string;
|
|
301
|
+
invalid: string;
|
|
302
|
+
gap: string;
|
|
303
|
+
ambiguous: string;
|
|
304
|
+
occurrence: string;
|
|
305
|
+
choose: string;
|
|
306
|
+
earlier: (offset: string) => string;
|
|
307
|
+
later: (offset: string) => string;
|
|
308
|
+
beforeMin: (min: string) => string;
|
|
309
|
+
afterMax: (max: string) => string;
|
|
310
|
+
};
|
|
311
|
+
const DATETIME_MESSAGES: DateTimeMessages = {
|
|
312
|
+
zone: (zone) => `Time zone: ${zone}`,
|
|
313
|
+
invalid: 'Enter a valid date, time and time zone.',
|
|
314
|
+
gap: 'This time does not exist because the clocks move forward. Choose another time.',
|
|
315
|
+
ambiguous: 'This time occurs twice. Choose which occurrence to use.',
|
|
316
|
+
occurrence: 'Occurrence',
|
|
317
|
+
choose: 'Choose an occurrence',
|
|
318
|
+
earlier: (offset) => `First occurrence (${offset})`,
|
|
319
|
+
later: (offset) => `Second occurrence (${offset})`,
|
|
320
|
+
beforeMin: (min) => `Choose a date and time on or after ${min}.`,
|
|
321
|
+
afterMax: (max) => `Choose a date and time on or before ${max}.`,
|
|
322
|
+
};
|
|
323
|
+
export type DateTimeFieldProps = DateInputProps & {
|
|
324
|
+
/** IANA timezone, e.g. Europe/Stockholm. The value stays a wall-clock datetime. */
|
|
325
|
+
timeZone: string;
|
|
326
|
+
/** Explicit choice for a repeated hour. Clear this when value or timeZone changes. */
|
|
327
|
+
disambiguation?: DateTimeDisambiguation;
|
|
328
|
+
onDisambiguationChange?: (value: DateTimeDisambiguation | undefined) => void;
|
|
329
|
+
messages?: Partial<DateTimeMessages>;
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
/** Call resolveDateTime before saving; only its valid result contains a storable instant. */
|
|
333
|
+
export function DateTimeField({
|
|
334
|
+
timeZone,
|
|
335
|
+
disambiguation,
|
|
336
|
+
onDisambiguationChange,
|
|
337
|
+
messages: overrides,
|
|
338
|
+
label,
|
|
339
|
+
value,
|
|
340
|
+
onChange,
|
|
341
|
+
min,
|
|
342
|
+
max,
|
|
343
|
+
required,
|
|
344
|
+
disabled,
|
|
345
|
+
error,
|
|
346
|
+
hint,
|
|
347
|
+
requiredLabel,
|
|
348
|
+
className,
|
|
349
|
+
}: DateTimeFieldProps) {
|
|
350
|
+
const messages = { ...DATETIME_MESSAGES, ...overrides };
|
|
351
|
+
const [badInput, setBadInput] = useState(false);
|
|
352
|
+
const resolution = resolveDateTime(value, timeZone, disambiguation);
|
|
353
|
+
const repeated = resolveDateTime(value, timeZone);
|
|
354
|
+
const problem =
|
|
355
|
+
error ??
|
|
356
|
+
(badInput || resolution.status === 'invalid'
|
|
357
|
+
? messages.invalid
|
|
358
|
+
: resolution.status === 'gap'
|
|
359
|
+
? messages.gap
|
|
360
|
+
: resolution.status === 'ambiguous'
|
|
361
|
+
? messages.ambiguous
|
|
362
|
+
: value && min && value < min
|
|
363
|
+
? messages.beforeMin(min)
|
|
364
|
+
: value && max && value > max
|
|
365
|
+
? messages.afterMax(max)
|
|
366
|
+
: undefined);
|
|
367
|
+
const id = useId();
|
|
368
|
+
return (
|
|
369
|
+
<div className={cn('flex flex-col gap-inline', className)}>
|
|
370
|
+
<FormField
|
|
371
|
+
label={label}
|
|
372
|
+
hint={
|
|
373
|
+
<>
|
|
374
|
+
{messages.zone(timeZone)}
|
|
375
|
+
{hint && <> · {hint}</>}
|
|
376
|
+
</>
|
|
377
|
+
}
|
|
378
|
+
error={problem}
|
|
379
|
+
required={required}
|
|
380
|
+
requiredLabel={requiredLabel}
|
|
381
|
+
>
|
|
382
|
+
{(control) => (
|
|
383
|
+
<Input
|
|
384
|
+
{...control}
|
|
385
|
+
type="datetime-local"
|
|
386
|
+
onInput={(event) =>
|
|
387
|
+
setBadInput(event.currentTarget.validity.badInput)
|
|
388
|
+
}
|
|
389
|
+
onBlur={(event) =>
|
|
390
|
+
setBadInput(event.currentTarget.validity.badInput)
|
|
391
|
+
}
|
|
392
|
+
value={value}
|
|
393
|
+
min={min}
|
|
394
|
+
max={max}
|
|
395
|
+
disabled={disabled}
|
|
396
|
+
onChange={(event) => {
|
|
397
|
+
onDisambiguationChange?.(undefined);
|
|
398
|
+
onChange(event.target.value);
|
|
399
|
+
}}
|
|
400
|
+
className="tabular-nums"
|
|
401
|
+
/>
|
|
402
|
+
)}
|
|
403
|
+
</FormField>
|
|
404
|
+
{repeated.status === 'ambiguous' && onDisambiguationChange && (
|
|
405
|
+
<div className="flex flex-col gap-1.5">
|
|
406
|
+
<Label htmlFor={id}>{messages.occurrence}</Label>
|
|
407
|
+
<Select
|
|
408
|
+
value={disambiguation ?? ''}
|
|
409
|
+
disabled={disabled}
|
|
410
|
+
required
|
|
411
|
+
onValueChange={(value) =>
|
|
412
|
+
onDisambiguationChange(
|
|
413
|
+
value as DateTimeDisambiguation,
|
|
414
|
+
)
|
|
415
|
+
}
|
|
416
|
+
>
|
|
417
|
+
<SelectTrigger id={id} aria-invalid={resolution.status === 'ambiguous' || undefined}>
|
|
418
|
+
<SelectValue placeholder={messages.choose} />
|
|
419
|
+
</SelectTrigger>
|
|
420
|
+
<SelectContent aria-label={messages.occurrence}>
|
|
421
|
+
<SelectItem value="earlier">{messages.earlier(repeated.earlier)}</SelectItem>
|
|
422
|
+
<SelectItem value="later">{messages.later(repeated.later)}</SelectItem>
|
|
423
|
+
</SelectContent>
|
|
424
|
+
</Select>
|
|
425
|
+
</div>
|
|
426
|
+
)}
|
|
427
|
+
</div>
|
|
428
|
+
);
|
|
429
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { cn } from '../lib/utils';
|
|
4
|
+
import { Text } from './ui/text';
|
|
5
|
+
|
|
6
|
+
export type EmptyStateProps = {
|
|
7
|
+
/** What belongs here, such as "No orders yet". */
|
|
8
|
+
title: ReactNode;
|
|
9
|
+
/** What a record here is for, or how one gets here. */
|
|
10
|
+
description?: ReactNode;
|
|
11
|
+
/** The button that adds the first record. */
|
|
12
|
+
action?: ReactNode;
|
|
13
|
+
className?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** A place with no records: says what belongs here and offers the action that adds one. */
|
|
17
|
+
export function EmptyState({ title, description, action, className }: EmptyStateProps) {
|
|
18
|
+
return (
|
|
19
|
+
<div className={cn('flex flex-col items-center gap-inline px-page py-section text-center', className)}>
|
|
20
|
+
<Text size="sm" weight="medium">
|
|
21
|
+
{title}
|
|
22
|
+
</Text>
|
|
23
|
+
{description && (
|
|
24
|
+
<Text size="sm" variant="muted">
|
|
25
|
+
{description}
|
|
26
|
+
</Text>
|
|
27
|
+
)}
|
|
28
|
+
{action && <div className="mt-1 flex items-center gap-inline">{action}</div>}
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Alert, AlertDescription } from './ui/alert';
|
|
2
|
+
import { Button } from './ui/button';
|
|
3
|
+
|
|
4
|
+
export type ErrorStateProps = {
|
|
5
|
+
error: { message: string };
|
|
6
|
+
onRetry?: () => void;
|
|
7
|
+
retrying?: boolean;
|
|
8
|
+
labels?: { retry?: string; retrying?: string };
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/** A failure and an explicit caller-owned recovery action. */
|
|
12
|
+
export function ErrorState({
|
|
13
|
+
error,
|
|
14
|
+
onRetry,
|
|
15
|
+
retrying = false,
|
|
16
|
+
labels,
|
|
17
|
+
}: ErrorStateProps) {
|
|
18
|
+
return (
|
|
19
|
+
<Alert variant="destructive" aria-busy={retrying}>
|
|
20
|
+
<AlertDescription>{error.message}</AlertDescription>
|
|
21
|
+
{onRetry && (
|
|
22
|
+
<Button
|
|
23
|
+
type="button"
|
|
24
|
+
size="sm"
|
|
25
|
+
variant="outline"
|
|
26
|
+
disabled={retrying}
|
|
27
|
+
onClick={onRetry}
|
|
28
|
+
className="mt-inline"
|
|
29
|
+
>
|
|
30
|
+
{retrying
|
|
31
|
+
? (labels?.retrying ?? 'Retrying…')
|
|
32
|
+
: (labels?.retry ?? 'Retry')}
|
|
33
|
+
</Button>
|
|
34
|
+
)}
|
|
35
|
+
</Alert>
|
|
36
|
+
);
|
|
37
|
+
}
|