@xds/svelte 1.0.1 → 1.2.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.
- .diffend-unextracted-0 +2 -1
- package/dist/Accordion.svelte +7 -2
- package/dist/Avatar.svelte +10 -2
- package/dist/AvatarStack.svelte +11 -1
- package/dist/Badge.svelte +14 -3
- package/dist/Banner.svelte +6 -1
- package/dist/Breadcrumb.svelte +53 -0
- package/dist/Breadcrumb.svelte.d.ts +11 -0
- package/dist/Button.svelte +30 -2
- package/dist/Button.svelte.d.ts +10 -1
- package/dist/Card.svelte +16 -2
- package/dist/Checkbox.svelte +62 -10
- package/dist/Checkbox.svelte.d.ts +14 -3
- package/dist/Chip.svelte +3 -1
- package/dist/ChipBar.svelte +3 -2
- package/dist/Combobox.svelte +194 -0
- package/dist/Combobox.svelte.d.ts +37 -0
- package/dist/CountBadge.svelte +4 -2
- package/dist/DatePicker.svelte +16 -5
- package/dist/DateRangePicker.svelte +6 -1
- package/dist/Dialog.svelte +9 -2
- package/dist/Divider.svelte +7 -3
- package/dist/EmptyState.svelte +15 -3
- package/dist/Icon.svelte +11 -2
- package/dist/IconButton.svelte +30 -2
- package/dist/IconButton.svelte.d.ts +10 -1
- package/dist/Labels.svelte +29 -0
- package/dist/Labels.svelte.d.ts +17 -0
- package/dist/Link.svelte +86 -0
- package/dist/Link.svelte.d.ts +26 -0
- package/dist/MediaCard.svelte +4 -1
- package/dist/Menu.svelte +21 -2
- package/dist/Pagination.svelte +108 -0
- package/dist/Pagination.svelte.d.ts +14 -0
- package/dist/PlaceRow.svelte +6 -1
- package/dist/Popover.svelte +91 -0
- package/dist/Popover.svelte.d.ts +21 -0
- package/dist/PopoverSurface.svelte +77 -0
- package/dist/PopoverSurface.svelte.d.ts +21 -0
- package/dist/ProgressBar.svelte +3 -1
- package/dist/RadioGroup.svelte +23 -8
- package/dist/RadioGroup.svelte.d.ts +4 -2
- package/dist/SearchField.svelte +65 -18
- package/dist/SearchField.svelte.d.ts +14 -4
- package/dist/SectionHeader.svelte +7 -2
- package/dist/SegmentedControl.svelte +21 -7
- package/dist/SegmentedControl.svelte.d.ts +3 -2
- package/dist/Select.svelte +64 -12
- package/dist/Select.svelte.d.ts +9 -2
- package/dist/Sidebar.svelte +3 -0
- package/dist/Skeleton.svelte +10 -2
- package/dist/Slider.svelte +23 -7
- package/dist/Slider.svelte.d.ts +2 -2
- package/dist/Spinner.svelte +3 -2
- package/dist/Switch.svelte +53 -9
- package/dist/Switch.svelte.d.ts +13 -3
- package/dist/Table.svelte +92 -0
- package/dist/Table.svelte.d.ts +17 -0
- package/dist/Tabs.svelte +21 -6
- package/dist/Tabs.svelte.d.ts +2 -1
- package/dist/Text.svelte +3 -1
- package/dist/TextField.svelte +59 -14
- package/dist/TextField.svelte.d.ts +13 -3
- package/dist/Thumbnail.svelte +7 -1
- package/dist/TimePicker.svelte +222 -0
- package/dist/TimePicker.svelte.d.ts +20 -0
- package/dist/Toast.svelte +12 -2
- package/dist/ToastQueue.svelte +57 -0
- package/dist/ToastQueue.svelte.d.ts +20 -0
- package/dist/Tooltip.svelte +9 -2
- package/dist/TooltipOverlay.svelte +9 -2
- package/dist/base.d.ts +14 -0
- package/dist/base.js +27 -0
- package/dist/controllable.svelte.d.ts +28 -0
- package/dist/controllable.svelte.js +41 -0
- package/dist/index.d.ts +12 -2
- package/dist/index.js +12 -0
- package/dist/labels.svelte.d.ts +13 -0
- package/dist/labels.svelte.js +24 -0
- package/dist/modal-popover.svelte.js +5 -1
- package/dist/presence.svelte.js +5 -2
- package/dist/preview/Component.svelte +8 -3
- package/dist/preview/Preview.svelte +8 -2
- package/dist/preview/Preview.svelte.d.ts +2 -0
- package/dist/preview/components.d.ts +9 -2
- package/dist/preview/components.js +18 -1
- package/dist/preview/index.d.ts +1 -0
- package/dist/root.d.ts +4 -2
- package/eject/files/Accordion.svelte +100 -0
- package/eject/files/AccordionPanel.svelte +48 -0
- package/eject/files/Avatar.svelte +51 -0
- package/eject/files/AvatarStack.svelte +61 -0
- package/eject/files/Badge.svelte +52 -0
- package/eject/files/Banner.svelte +94 -0
- package/eject/files/Breadcrumb.svelte +52 -0
- package/eject/files/Button.svelte +126 -0
- package/eject/files/Card.svelte +112 -0
- package/eject/files/Checkbox.svelte +121 -0
- package/eject/files/Chip.svelte +51 -0
- package/eject/files/ChipBar.svelte +39 -0
- package/eject/files/Combobox.svelte +198 -0
- package/eject/files/CountBadge.svelte +51 -0
- package/eject/files/DatePicker.svelte +213 -0
- package/eject/files/DateRangePicker.svelte +294 -0
- package/eject/files/Dialog.svelte +119 -0
- package/eject/files/Divider.svelte +27 -0
- package/eject/files/EmptyState.svelte +52 -0
- package/eject/files/Icon.svelte +51 -0
- package/eject/files/IconButton.svelte +99 -0
- package/eject/files/Link.svelte +85 -0
- package/eject/files/ListRow.svelte +33 -0
- package/eject/files/MediaCard.svelte +117 -0
- package/eject/files/Menu.svelte +183 -0
- package/eject/files/Pagination.svelte +109 -0
- package/eject/files/PlaceRow.svelte +75 -0
- package/eject/files/Popover.svelte +100 -0
- package/eject/files/PopoverSurface.svelte +85 -0
- package/eject/files/ProgressBar.svelte +38 -0
- package/eject/files/RadioGroup.svelte +133 -0
- package/eject/files/SearchField.svelte +154 -0
- package/eject/files/SectionHeader.svelte +67 -0
- package/eject/files/SegmentedControl.svelte +85 -0
- package/eject/files/Select.svelte +276 -0
- package/eject/files/Sidebar.svelte +130 -0
- package/eject/files/SidebarRailButton.svelte +32 -0
- package/eject/files/Skeleton.svelte +55 -0
- package/eject/files/Slider.svelte +136 -0
- package/eject/files/Spinner.svelte +41 -0
- package/eject/files/Switch.svelte +105 -0
- package/eject/files/Table.svelte +90 -0
- package/eject/files/Tabs.svelte +85 -0
- package/eject/files/Text.svelte +43 -0
- package/eject/files/TextField.svelte +222 -0
- package/eject/files/Thumbnail.svelte +88 -0
- package/eject/files/TimePicker.svelte +237 -0
- package/eject/files/Toast.svelte +98 -0
- package/eject/files/ToastQueue.svelte +61 -0
- package/eject/files/Tooltip.svelte +51 -0
- package/eject/files/TooltipOverlay.svelte +88 -0
- package/eject/files/accordion.css +89 -0
- package/eject/files/accordion.ts +67 -0
- package/eject/files/avatar-stack.ts +57 -0
- package/eject/files/avatar.ts +42 -0
- package/eject/files/badge.ts +30 -0
- package/eject/files/banner.ts +71 -0
- package/eject/files/base.css +38 -0
- package/eject/files/breadcrumb.css +51 -0
- package/eject/files/breadcrumb.ts +42 -0
- package/eject/files/button.css +241 -0
- package/eject/files/button.ts +106 -0
- package/eject/files/card.ts +58 -0
- package/eject/files/checkbox.ts +52 -0
- package/eject/files/chip-bar.ts +16 -0
- package/eject/files/chip.ts +35 -0
- package/eject/files/combobox.css +269 -0
- package/eject/files/combobox.ts +85 -0
- package/eject/files/count-badge.ts +32 -0
- package/eject/files/date-picker.css +375 -0
- package/eject/files/date-picker.ts +280 -0
- package/eject/files/date-range-picker.ts +338 -0
- package/eject/files/dialog.css +139 -0
- package/eject/files/dialog.ts +15 -0
- package/eject/files/divider.ts +5 -0
- package/eject/files/empty-state.ts +22 -0
- package/eject/files/icon.ts +36 -0
- package/eject/files/link.css +64 -0
- package/eject/files/link.ts +63 -0
- package/eject/files/list-row.ts +66 -0
- package/eject/files/media-card.ts +66 -0
- package/eject/files/menu.css +192 -0
- package/eject/files/menu.ts +84 -0
- package/eject/files/overlay.css +40 -0
- package/eject/files/pagination.css +106 -0
- package/eject/files/pagination.ts +68 -0
- package/eject/files/parts.ts +17 -0
- package/eject/files/popover.css +101 -0
- package/eject/files/popover.ts +37 -0
- package/eject/files/progress-bar.ts +26 -0
- package/eject/files/radio-group.css +184 -0
- package/eject/files/radio-group.ts +30 -0
- package/eject/files/section-header.ts +32 -0
- package/eject/files/segmented-control.ts +33 -0
- package/eject/files/select.css +347 -0
- package/eject/files/select.ts +77 -0
- package/eject/files/sidebar.ts +75 -0
- package/eject/files/skeleton.ts +51 -0
- package/eject/files/slider.css +160 -0
- package/eject/files/slider.ts +80 -0
- package/eject/files/spinner.ts +22 -0
- package/eject/files/switch.ts +45 -0
- package/eject/files/table.css +107 -0
- package/eject/files/table.ts +84 -0
- package/eject/files/tabs.css +120 -0
- package/eject/files/tabs.ts +37 -0
- package/eject/files/text-field.css +225 -0
- package/eject/files/text-field.ts +64 -0
- package/eject/files/text.ts +38 -0
- package/eject/files/thumbnail.ts +51 -0
- package/eject/files/time-picker.ts +113 -0
- package/eject/files/toast-queue.ts +64 -0
- package/eject/files/toast.ts +31 -0
- package/eject/files/tooltip.css +111 -0
- package/eject/files/tooltip.ts +21 -0
- package/eject/manifest.json +1053 -0
- package/package.json +12 -4
- package/styles.css +1064 -169
- package/tailwind.css +1295 -218
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<!--
|
|
6
|
+
@component
|
|
7
|
+
A field for choosing a range of days, a start and an end, as for a stay. Closed, it looks like a
|
|
8
|
+
DatePicker and shows both days in the locale's medium form ("Mar 10 – 14, 2026"), or the
|
|
9
|
+
placeholder. Pressed, it opens a calendar under itself, two months side by side where the window
|
|
10
|
+
has room and one where it does not, on the start's month, or on today's while nothing is chosen.
|
|
11
|
+
|
|
12
|
+
The first day pressed starts the range, and the band previews it to the day under the pointer or
|
|
13
|
+
the keyboard's focus. The second ends it, if the days between are at least `minLength` and at
|
|
14
|
+
most `maxLength`, which leave the other days unavailable meanwhile: `onChange` gets the range and
|
|
15
|
+
the calendar closes. A day before the start starts again from there. Escape or a press outside
|
|
16
|
+
closes the calendar without a change.
|
|
17
|
+
|
|
18
|
+
The keys are DatePicker's, and Page Up and Page Down move a month whether one or two are shown.
|
|
19
|
+
Each month is a grid named by its month; every day of the range is selected, and the two ends
|
|
20
|
+
are named by `startLabel` and `endLabel` before the day.
|
|
21
|
+
-->
|
|
22
|
+
<script module lang="ts">
|
|
23
|
+
import type { RootProps } from "@xds/svelte/base";
|
|
24
|
+
import type { DateRange, DateRangePickerBaseProps } from "./date-range-picker.ts";
|
|
25
|
+
|
|
26
|
+
export type { DateRange } from "./date-range-picker.ts";
|
|
27
|
+
|
|
28
|
+
export type DateRangePickerProps = DateRangePickerBaseProps &
|
|
29
|
+
RootProps & {
|
|
30
|
+
onChange: (value: DateRange) => void;
|
|
31
|
+
};
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<script lang="ts">
|
|
35
|
+
import {
|
|
36
|
+
createPresence,
|
|
37
|
+
modalPopover,
|
|
38
|
+
Portal,
|
|
39
|
+
readCssPx,
|
|
40
|
+
rootAttributes,
|
|
41
|
+
space,
|
|
42
|
+
underlayLayerStyle,
|
|
43
|
+
useLabels,
|
|
44
|
+
} from "@xds/svelte/base";
|
|
45
|
+
import * as datePicker from "@zag-js/date-picker";
|
|
46
|
+
import { mergeProps, normalizeProps, useMachine } from "@zag-js/svelte";
|
|
47
|
+
import { untrack } from "svelte";
|
|
48
|
+
import {
|
|
49
|
+
DATE_PICKER_NAV_CLASS,
|
|
50
|
+
datePickerContentAttrs,
|
|
51
|
+
datePickerIds,
|
|
52
|
+
datePickerLocale,
|
|
53
|
+
datePickerTriggerAttrs,
|
|
54
|
+
focusOpeningDay,
|
|
55
|
+
keepCalendarFocus,
|
|
56
|
+
keepDayFocused,
|
|
57
|
+
} from "./date-picker.ts";
|
|
58
|
+
import {
|
|
59
|
+
dateRangeMachineProps,
|
|
60
|
+
endRangeChoiceOnClose,
|
|
61
|
+
formatRange,
|
|
62
|
+
keepRangePreview,
|
|
63
|
+
type RangeDraft,
|
|
64
|
+
rangeDayClick,
|
|
65
|
+
rangeGridKeyDown,
|
|
66
|
+
rangeMonths,
|
|
67
|
+
rangeMonthViews,
|
|
68
|
+
rangeSummary,
|
|
69
|
+
shownRange,
|
|
70
|
+
} from "./date-range-picker.ts";
|
|
71
|
+
import Icon from "./Icon.svelte";
|
|
72
|
+
import { classes } from "./parts.ts";
|
|
73
|
+
|
|
74
|
+
// The rest stays reactive: the machine's props read it each time it changes.
|
|
75
|
+
let { onChange, class: className, style, ...props }: DateRangePickerProps = $props();
|
|
76
|
+
|
|
77
|
+
const id = $props.id();
|
|
78
|
+
const ids = datePickerIds(id);
|
|
79
|
+
const locale = $derived(datePickerLocale(props.locale));
|
|
80
|
+
const labels = useLabels();
|
|
81
|
+
// A start alone while the end is chosen; null while the calendar shows the chosen range.
|
|
82
|
+
let draft = $state.raw<RangeDraft | null>(null);
|
|
83
|
+
let months = $state(1);
|
|
84
|
+
const shown = $derived(shownRange(props.value, draft));
|
|
85
|
+
const service = useMachine(datePicker.machine, () =>
|
|
86
|
+
dateRangeMachineProps(props, shown, {
|
|
87
|
+
id,
|
|
88
|
+
locale,
|
|
89
|
+
months,
|
|
90
|
+
onDraft: (next) => (draft = next),
|
|
91
|
+
onChange,
|
|
92
|
+
gutter: readCssPx(null, "--xds-space-1", space[1]),
|
|
93
|
+
labels: labels(),
|
|
94
|
+
}),
|
|
95
|
+
);
|
|
96
|
+
const api = $derived(datePicker.connect(service, normalizeProps));
|
|
97
|
+
const trigger = $derived(api.getTriggerProps());
|
|
98
|
+
const invalid = $derived(props.error !== undefined);
|
|
99
|
+
const summary = $derived(rangeSummary(shown, props, locale, labels()));
|
|
100
|
+
const views = $derived(rangeMonthViews(api, months));
|
|
101
|
+
let positioner = $state<HTMLDivElement>();
|
|
102
|
+
let surface = $state<HTMLDivElement>();
|
|
103
|
+
modalPopover(
|
|
104
|
+
() => api.open,
|
|
105
|
+
() => positioner,
|
|
106
|
+
);
|
|
107
|
+
const present = createPresence(
|
|
108
|
+
() => api.open,
|
|
109
|
+
() => [surface],
|
|
110
|
+
);
|
|
111
|
+
// Strings, so that the effects below run only when the focused day or the month changes, not
|
|
112
|
+
// on every change of the machine.
|
|
113
|
+
const focused = $derived(api.focusedValue.toString());
|
|
114
|
+
const month = $derived(api.visibleRange.start.toString());
|
|
115
|
+
const open = $derived(api.open);
|
|
116
|
+
$effect(() => {
|
|
117
|
+
const isOpen = open;
|
|
118
|
+
void focused;
|
|
119
|
+
void month;
|
|
120
|
+
untrack(() => keepDayFocused(isOpen, surface));
|
|
121
|
+
});
|
|
122
|
+
$effect(() => {
|
|
123
|
+
const isOpen = open;
|
|
124
|
+
untrack(() => endRangeChoiceOnClose(service, isOpen));
|
|
125
|
+
});
|
|
126
|
+
$effect(() => {
|
|
127
|
+
void focused;
|
|
128
|
+
untrack(() => keepRangePreview(service, shown, open));
|
|
129
|
+
});
|
|
130
|
+
</script>
|
|
131
|
+
|
|
132
|
+
<!-- Merged, so that the app's style joins any the machine writes on the root. -->
|
|
133
|
+
<div
|
|
134
|
+
{...mergeProps(api.getRootProps(), {
|
|
135
|
+
...rootAttributes(props),
|
|
136
|
+
class: classes("{{prefix}}-date-picker {{prefix}}-date-range-picker", className),
|
|
137
|
+
style,
|
|
138
|
+
})}
|
|
139
|
+
>
|
|
140
|
+
<!-- A span: the field is a button, which a <label> cannot point at. -->
|
|
141
|
+
<span id={ids.label} class="{{prefix}}-date-picker__label">{props.label}</span>
|
|
142
|
+
<!-- What Zag places the calendar against. -->
|
|
143
|
+
<div {...api.getControlProps()} class="{{prefix}}-date-picker__control">
|
|
144
|
+
<button
|
|
145
|
+
{...trigger}
|
|
146
|
+
{...datePickerTriggerAttrs(props, ids)}
|
|
147
|
+
type="button"
|
|
148
|
+
onclick={(event) => {
|
|
149
|
+
if (!api.open) months = rangeMonths();
|
|
150
|
+
focusOpeningDay(api, { ...props, value: props.value?.start });
|
|
151
|
+
trigger.onclick?.(event);
|
|
152
|
+
}}
|
|
153
|
+
class="{{prefix}}-date-picker__trigger"
|
|
154
|
+
>
|
|
155
|
+
<span id={ids.value} class="{{prefix}}-date-picker__value"
|
|
156
|
+
>{props.value === undefined ? props.placeholder : formatRange(props.value, locale)}</span
|
|
157
|
+
>
|
|
158
|
+
<Icon name="calendar" size="sm" class="text-xds-field-placeholder" />
|
|
159
|
+
</button>
|
|
160
|
+
</div>
|
|
161
|
+
<!-- One line under the box: the help, or the error in its place. The error stays mounted as
|
|
162
|
+
a live region so assistive technology announces it when it appears. -->
|
|
163
|
+
<div class="{{prefix}}-date-picker__footer">
|
|
164
|
+
{#if !invalid && props.description}
|
|
165
|
+
<span id={ids.description} class="{{prefix}}-date-picker__description"
|
|
166
|
+
>{props.description}</span
|
|
167
|
+
>
|
|
168
|
+
{/if}
|
|
169
|
+
<span id={ids.error} class="{{prefix}}-date-picker__error" aria-live="polite"
|
|
170
|
+
>{props.error}</span
|
|
171
|
+
>
|
|
172
|
+
</div>
|
|
173
|
+
<!-- What a form submits. Zag gives the names to its text inputs, which are not drawn. -->
|
|
174
|
+
{#if props.startName !== undefined}
|
|
175
|
+
<input type="hidden" name={props.startName} value={props.value?.start ?? ""} />
|
|
176
|
+
{/if}
|
|
177
|
+
{#if props.endName !== undefined}
|
|
178
|
+
<input type="hidden" name={props.endName} value={props.value?.end ?? ""} />
|
|
179
|
+
{/if}
|
|
180
|
+
<Portal>
|
|
181
|
+
{#if api.open}
|
|
182
|
+
<!-- Takes a press outside, which then only closes the calendar. The focus stays in the
|
|
183
|
+
calendar until it hands it back to the field. -->
|
|
184
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
185
|
+
<div
|
|
186
|
+
class="{{prefix}}-date-picker__underlay"
|
|
187
|
+
style:--layer-index={underlayLayerStyle(api.getPositionerProps().style)?.["--layer-index"]}
|
|
188
|
+
onmousedown={(event) => event.preventDefault()}
|
|
189
|
+
></div>
|
|
190
|
+
{/if}
|
|
191
|
+
<div
|
|
192
|
+
{...api.getPositionerProps()}
|
|
193
|
+
bind:this={positioner}
|
|
194
|
+
class="{{prefix}}-date-picker__positioner"
|
|
195
|
+
>
|
|
196
|
+
<!-- Shown until its exit animation ends; Zag would hide it as it closes. -->
|
|
197
|
+
<div
|
|
198
|
+
{...api.getContentProps()}
|
|
199
|
+
{...datePickerContentAttrs(ids)}
|
|
200
|
+
bind:this={surface}
|
|
201
|
+
hidden={!present()}
|
|
202
|
+
onkeydown={(event) => keepCalendarFocus(event, surface)}
|
|
203
|
+
class="{{prefix}}-date-picker__content {{prefix}}-date-range-picker__content"
|
|
204
|
+
>
|
|
205
|
+
<div class="{{prefix}}-date-range-picker__summary" aria-live="polite">
|
|
206
|
+
<span>{summary.start}</span>
|
|
207
|
+
<span>{summary.end}</span>
|
|
208
|
+
</div>
|
|
209
|
+
<div class="{{prefix}}-date-range-picker__months">
|
|
210
|
+
{#each views as view (view.index)}
|
|
211
|
+
{@const table = api.getTableProps({ view: "day", id: view.table.id })}
|
|
212
|
+
<div class="{{prefix}}-date-range-picker__month">
|
|
213
|
+
<div class="{{prefix}}-date-picker__header">
|
|
214
|
+
{#if view.index === 0}
|
|
215
|
+
<button
|
|
216
|
+
{...api.getPreviousTriggerProps()}
|
|
217
|
+
type="button"
|
|
218
|
+
class={DATE_PICKER_NAV_CLASS}
|
|
219
|
+
>
|
|
220
|
+
<Icon name="chevron-left" size="sm" />
|
|
221
|
+
</button>
|
|
222
|
+
{:else}
|
|
223
|
+
<span class="{{prefix}}-date-range-picker__nav-space"></span>
|
|
224
|
+
{/if}
|
|
225
|
+
<span {...api.getRangeTextProps()} class="{{prefix}}-date-picker__heading"
|
|
226
|
+
>{view.name}</span
|
|
227
|
+
>
|
|
228
|
+
{#if view.index === months - 1}
|
|
229
|
+
<button
|
|
230
|
+
{...api.getNextTriggerProps()}
|
|
231
|
+
type="button"
|
|
232
|
+
class={DATE_PICKER_NAV_CLASS}
|
|
233
|
+
>
|
|
234
|
+
<Icon name="chevron-right" size="sm" />
|
|
235
|
+
</button>
|
|
236
|
+
{:else}
|
|
237
|
+
<span class="{{prefix}}-date-range-picker__nav-space"></span>
|
|
238
|
+
{/if}
|
|
239
|
+
</div>
|
|
240
|
+
<table
|
|
241
|
+
{...table}
|
|
242
|
+
{...view.table}
|
|
243
|
+
onkeydown={(event) => rangeGridKeyDown(event, api, shown, props, table.onkeydown)}
|
|
244
|
+
class="{{prefix}}-date-picker__grid"
|
|
245
|
+
>
|
|
246
|
+
<thead {...api.getTableHeadProps({ view: "day" })}>
|
|
247
|
+
<tr {...api.getTableRowProps({ view: "day" })}>
|
|
248
|
+
{#each api.weekDays as weekDay (weekDay.long)}
|
|
249
|
+
<th scope="col" class="{{prefix}}-date-picker__weekday">{weekDay.narrow}</th>
|
|
250
|
+
{/each}
|
|
251
|
+
</tr>
|
|
252
|
+
</thead>
|
|
253
|
+
<tbody {...api.getTableBodyProps({ view: "day" })}>
|
|
254
|
+
<!-- Keyed by the day, as in DatePicker: a cell made anew would drop the focus it
|
|
255
|
+
holds when a move is held at `min` or `max`. -->
|
|
256
|
+
{#each view.weeks as week (week[0]?.toString())}
|
|
257
|
+
<tr {...api.getTableRowProps({ view: "day" })}>
|
|
258
|
+
{#each week as value (value.toString())}
|
|
259
|
+
{@const cell = { value, visibleRange: view.visibleRange }}
|
|
260
|
+
{@const day = api.getDayTableCellTriggerProps(cell)}
|
|
261
|
+
<td
|
|
262
|
+
{...api.getDayTableCellProps(cell)}
|
|
263
|
+
class="{{prefix}}-date-picker__cell"
|
|
264
|
+
>
|
|
265
|
+
<!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions -->
|
|
266
|
+
<div
|
|
267
|
+
{...day}
|
|
268
|
+
onclick={(event) =>
|
|
269
|
+
rangeDayClick(
|
|
270
|
+
event,
|
|
271
|
+
api,
|
|
272
|
+
shown,
|
|
273
|
+
props,
|
|
274
|
+
value,
|
|
275
|
+
view.visibleRange,
|
|
276
|
+
day.onclick,
|
|
277
|
+
)}
|
|
278
|
+
class="{{prefix}}-date-picker__day"
|
|
279
|
+
>
|
|
280
|
+
{value.day}
|
|
281
|
+
</div>
|
|
282
|
+
</td>
|
|
283
|
+
{/each}
|
|
284
|
+
</tr>
|
|
285
|
+
{/each}
|
|
286
|
+
</tbody>
|
|
287
|
+
</table>
|
|
288
|
+
</div>
|
|
289
|
+
{/each}
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
</Portal>
|
|
294
|
+
</div>
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<!--
|
|
6
|
+
@component
|
|
7
|
+
A window that interrupts the screen for a confirmation or a short task. Everything behind it is
|
|
8
|
+
dimmed and cannot be reached until it closes.
|
|
9
|
+
|
|
10
|
+
It is a modal dialog named by its title and described by its description. Focus moves into it,
|
|
11
|
+
stays inside it, and returns to where it was when it closes.
|
|
12
|
+
-->
|
|
13
|
+
<script module lang="ts">
|
|
14
|
+
import type { RootProps } from "@xds/svelte/base";
|
|
15
|
+
import type { Snippet } from "svelte";
|
|
16
|
+
import type { DialogBaseProps } from "./dialog.ts";
|
|
17
|
+
|
|
18
|
+
/** Its root is the dialog itself, while it is open, not the scrim around it. */
|
|
19
|
+
export type DialogProps = DialogBaseProps &
|
|
20
|
+
RootProps & {
|
|
21
|
+
/** Called on Escape and on a press outside the dialog. Set `open` to false in it. */
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
/** The body, between the description and the actions. It scrolls when it is too tall. */
|
|
24
|
+
children?: Snippet;
|
|
25
|
+
/** Buttons, in a row at the end edge. Put the main action last. */
|
|
26
|
+
actions?: Snippet;
|
|
27
|
+
};
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<script lang="ts">
|
|
31
|
+
import {
|
|
32
|
+
createPresence,
|
|
33
|
+
leaveEscapeToFields,
|
|
34
|
+
Portal,
|
|
35
|
+
resetTrigger,
|
|
36
|
+
rootAttributes,
|
|
37
|
+
} from "@xds/svelte/base";
|
|
38
|
+
import * as dialog from "@zag-js/dialog";
|
|
39
|
+
import { mergeProps, normalizeProps, useMachine } from "@zag-js/svelte";
|
|
40
|
+
import { classes } from "./parts.ts";
|
|
41
|
+
|
|
42
|
+
let {
|
|
43
|
+
open,
|
|
44
|
+
title,
|
|
45
|
+
description,
|
|
46
|
+
dismissible,
|
|
47
|
+
onClose,
|
|
48
|
+
class: className,
|
|
49
|
+
style,
|
|
50
|
+
children,
|
|
51
|
+
actions,
|
|
52
|
+
...rest
|
|
53
|
+
}: DialogProps = $props();
|
|
54
|
+
|
|
55
|
+
const id = $props.id();
|
|
56
|
+
let backdrop = $state<HTMLDivElement>();
|
|
57
|
+
let positioner = $state<HTMLDivElement>();
|
|
58
|
+
let content = $state<HTMLElement>();
|
|
59
|
+
const service = useMachine(dialog.machine, () => ({
|
|
60
|
+
id,
|
|
61
|
+
// The app's id names the dialog, and what Zag points at it points there.
|
|
62
|
+
ids: rest.id === undefined ? undefined : { content: rest.id },
|
|
63
|
+
open,
|
|
64
|
+
onOpenChange: (details: dialog.OpenChangeDetails) => {
|
|
65
|
+
if (!details.open) onClose();
|
|
66
|
+
},
|
|
67
|
+
closeOnEscape: dismissible ?? true,
|
|
68
|
+
closeOnInteractOutside: dismissible ?? true,
|
|
69
|
+
onEscapeKeyDown: leaveEscapeToFields,
|
|
70
|
+
// The dialog itself rather than its first field or button: a screen reader then reads the
|
|
71
|
+
// title and the description first.
|
|
72
|
+
initialFocusEl: () => content ?? null,
|
|
73
|
+
}));
|
|
74
|
+
const api = $derived(dialog.connect(service, normalizeProps));
|
|
75
|
+
const present = createPresence(
|
|
76
|
+
() => api.open,
|
|
77
|
+
() => [backdrop, positioner],
|
|
78
|
+
);
|
|
79
|
+
// Nothing inside opens an overlay from a control outside it.
|
|
80
|
+
resetTrigger();
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
{#if present()}
|
|
84
|
+
<Portal>
|
|
85
|
+
<!-- A press on the scrim keeps the focus in the dialog: a dialog that cannot be dismissed stays
|
|
86
|
+
open, and the focus would go to the page. The backdrop and the dialog stay shown until
|
|
87
|
+
their exit animation ends; Zag would hide them as the dialog closes. -->
|
|
88
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
89
|
+
<div
|
|
90
|
+
{...api.getBackdropProps()}
|
|
91
|
+
bind:this={backdrop}
|
|
92
|
+
hidden={false}
|
|
93
|
+
onmousedown={(event) => event.preventDefault()}
|
|
94
|
+
class="{{prefix}}-dialog__backdrop"
|
|
95
|
+
></div>
|
|
96
|
+
<div {...api.getPositionerProps()} bind:this={positioner} class="{{prefix}}-dialog__positioner">
|
|
97
|
+
<section
|
|
98
|
+
{...mergeProps(api.getContentProps(), {
|
|
99
|
+
...rootAttributes(rest),
|
|
100
|
+
class: classes("{{prefix}}-dialog", className),
|
|
101
|
+
style,
|
|
102
|
+
})}
|
|
103
|
+
bind:this={content}
|
|
104
|
+
hidden={false}
|
|
105
|
+
>
|
|
106
|
+
<h2 {...api.getTitleProps()} class="{{prefix}}-dialog__title">{title}</h2>
|
|
107
|
+
{#if description}
|
|
108
|
+
<p {...api.getDescriptionProps()} class="{{prefix}}-dialog__description">{description}</p>
|
|
109
|
+
{/if}
|
|
110
|
+
{#if children}
|
|
111
|
+
<div class="{{prefix}}-dialog__body">{@render children()}</div>
|
|
112
|
+
{/if}
|
|
113
|
+
{#if actions}
|
|
114
|
+
<div class="{{prefix}}-dialog__actions">{@render actions()}</div>
|
|
115
|
+
{/if}
|
|
116
|
+
</section>
|
|
117
|
+
</div>
|
|
118
|
+
</Portal>
|
|
119
|
+
{/if}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<!--
|
|
6
|
+
@component
|
|
7
|
+
A line between groups of content. Decorative lines use the low-contrast border color.
|
|
8
|
+
-->
|
|
9
|
+
<script module lang="ts">
|
|
10
|
+
import type { RootProps } from "@xds/svelte/base";
|
|
11
|
+
|
|
12
|
+
export type DividerProps = RootProps;
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<script lang="ts">
|
|
16
|
+
import { rootAttributes } from "@xds/svelte/base";
|
|
17
|
+
import { dividerClass } from "./divider.ts";
|
|
18
|
+
import { classes, rootPart } from "./parts.ts";
|
|
19
|
+
|
|
20
|
+
let { class: className, style, ...rest }: DividerProps = $props();
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<hr
|
|
24
|
+
{...rootAttributes(rest)}
|
|
25
|
+
class={classes(rootPart("Divider"), dividerClass, className)}
|
|
26
|
+
{style}
|
|
27
|
+
/>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<!--
|
|
6
|
+
@component
|
|
7
|
+
What a screen or a list says when it has nothing to show. It centers itself in its container,
|
|
8
|
+
also vertically when the container is a flex box with room to spare.
|
|
9
|
+
-->
|
|
10
|
+
<script module lang="ts">
|
|
11
|
+
import type { RootProps } from "@xds/svelte/base";
|
|
12
|
+
import type { Snippet } from "svelte";
|
|
13
|
+
import type { EmptyStateBaseProps } from "./empty-state.ts";
|
|
14
|
+
|
|
15
|
+
export type EmptyStateProps = EmptyStateBaseProps &
|
|
16
|
+
RootProps & {
|
|
17
|
+
/** The one thing to do about it, usually a Button. */
|
|
18
|
+
action?: Snippet;
|
|
19
|
+
};
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import { rootAttributes } from "@xds/svelte/base";
|
|
24
|
+
import { EMPTY_STATE_PARTS } from "./empty-state.ts";
|
|
25
|
+
import Icon from "./Icon.svelte";
|
|
26
|
+
import { classes, rootPart } from "./parts.ts";
|
|
27
|
+
|
|
28
|
+
let {
|
|
29
|
+
icon,
|
|
30
|
+
title,
|
|
31
|
+
description,
|
|
32
|
+
action,
|
|
33
|
+
class: className,
|
|
34
|
+
style,
|
|
35
|
+
...rest
|
|
36
|
+
}: EmptyStateProps = $props();
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<div
|
|
40
|
+
{...rootAttributes(rest)}
|
|
41
|
+
class={classes(rootPart("EmptyState"), EMPTY_STATE_PARTS.root, className)}
|
|
42
|
+
{style}
|
|
43
|
+
>
|
|
44
|
+
<Icon name={icon} size="xl" class={EMPTY_STATE_PARTS.icon} />
|
|
45
|
+
<p class={EMPTY_STATE_PARTS.title}>{title}</p>
|
|
46
|
+
{#if description}
|
|
47
|
+
<p class={EMPTY_STATE_PARTS.description}>{description}</p>
|
|
48
|
+
{/if}
|
|
49
|
+
{#if action}
|
|
50
|
+
<div class={EMPTY_STATE_PARTS.action}>{@render action()}</div>
|
|
51
|
+
{/if}
|
|
52
|
+
</div>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<!--
|
|
6
|
+
@component
|
|
7
|
+
An icon from design/icons. It takes the color of the text around it. An arrow or a chevron
|
|
8
|
+
mirrors itself in a right-to-left layout when given `rtl:-scale-x-100` in `class`.
|
|
9
|
+
-->
|
|
10
|
+
<script module lang="ts">
|
|
11
|
+
import type { RootProps } from "@xds/svelte/base";
|
|
12
|
+
import type { IconBaseProps } from "./icon.ts";
|
|
13
|
+
|
|
14
|
+
export type IconProps = IconBaseProps & RootProps;
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script lang="ts">
|
|
18
|
+
import { icons, rootAttributes, useDefaults } from "@xds/svelte/base";
|
|
19
|
+
import { iconClass } from "./icon.ts";
|
|
20
|
+
import { classes, rootPart } from "./parts.ts";
|
|
21
|
+
|
|
22
|
+
let {
|
|
23
|
+
name,
|
|
24
|
+
size: ownSize,
|
|
25
|
+
filled,
|
|
26
|
+
label,
|
|
27
|
+
class: className,
|
|
28
|
+
style,
|
|
29
|
+
...rest
|
|
30
|
+
}: IconProps = $props();
|
|
31
|
+
|
|
32
|
+
const defaults = useDefaults("Icon");
|
|
33
|
+
const size = $derived(ownSize ?? defaults().size);
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<svg
|
|
37
|
+
{...rootAttributes(rest)}
|
|
38
|
+
viewBox="0 0 24 24"
|
|
39
|
+
fill={filled ? "currentColor" : "none"}
|
|
40
|
+
stroke="currentColor"
|
|
41
|
+
stroke-width="2"
|
|
42
|
+
stroke-linecap="round"
|
|
43
|
+
stroke-linejoin="round"
|
|
44
|
+
class={classes(rootPart("Icon"), iconClass(size), className)}
|
|
45
|
+
{style}
|
|
46
|
+
role={label ? "img" : undefined}
|
|
47
|
+
aria-label={label || undefined}
|
|
48
|
+
aria-hidden={label ? undefined : "true"}
|
|
49
|
+
>
|
|
50
|
+
{#each icons[name] as path, index (index)}<path d={path} />{/each}
|
|
51
|
+
</svg>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<!--
|
|
6
|
+
@component
|
|
7
|
+
A button that holds only an icon, in Button's variants, sizes and states. It is a square as
|
|
8
|
+
tall as a Button of its size, and its pressable area is never smaller than the minimum target,
|
|
9
|
+
even when the square is. Like Button, it opens a Menu or a Tooltip it is the trigger of.
|
|
10
|
+
|
|
11
|
+
`focus()`, `blur()` and `element()` on the instance reach the native button.
|
|
12
|
+
-->
|
|
13
|
+
<script module lang="ts">
|
|
14
|
+
import type { RootProps } from "@xds/svelte/base";
|
|
15
|
+
import type { FocusEventHandler } from "svelte/elements";
|
|
16
|
+
import type { IconButtonBaseProps } from "./button.ts";
|
|
17
|
+
|
|
18
|
+
export type IconButtonProps = IconButtonBaseProps &
|
|
19
|
+
RootProps & {
|
|
20
|
+
onPress?: () => void;
|
|
21
|
+
onFocus?: FocusEventHandler<HTMLButtonElement>;
|
|
22
|
+
onBlur?: FocusEventHandler<HTMLButtonElement>;
|
|
23
|
+
};
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<script lang="ts">
|
|
27
|
+
import { rootAttributes, useDefaults, withTrigger } from "@xds/svelte/base";
|
|
28
|
+
import type { HTMLButtonAttributes } from "svelte/elements";
|
|
29
|
+
import { buttonClass, ICON_BUTTON_BOX, isHeld } from "./button.ts";
|
|
30
|
+
import Icon from "./Icon.svelte";
|
|
31
|
+
import { classes } from "./parts.ts";
|
|
32
|
+
import Spinner from "./Spinner.svelte";
|
|
33
|
+
|
|
34
|
+
let {
|
|
35
|
+
icon,
|
|
36
|
+
label,
|
|
37
|
+
variant: ownVariant,
|
|
38
|
+
size: ownSize,
|
|
39
|
+
selected,
|
|
40
|
+
disabled,
|
|
41
|
+
loading,
|
|
42
|
+
onPress,
|
|
43
|
+
onFocus,
|
|
44
|
+
onBlur,
|
|
45
|
+
class: className,
|
|
46
|
+
style,
|
|
47
|
+
...rest
|
|
48
|
+
}: IconButtonProps = $props();
|
|
49
|
+
|
|
50
|
+
const defaults = useDefaults("IconButton");
|
|
51
|
+
const variant = $derived(ownVariant ?? defaults().variant ?? "ghost");
|
|
52
|
+
const size = $derived(ownSize ?? defaults().size ?? "md");
|
|
53
|
+
|
|
54
|
+
const attributes = withTrigger(
|
|
55
|
+
(): HTMLButtonAttributes => ({
|
|
56
|
+
type: "button",
|
|
57
|
+
// The recipe gives the root part, `{{prefix}}-icon-button`.
|
|
58
|
+
class: classes(buttonClass({ variant, size, iconButton: true }), className),
|
|
59
|
+
style,
|
|
60
|
+
disabled,
|
|
61
|
+
"aria-disabled": loading ? "true" : undefined,
|
|
62
|
+
"data-pending": loading ? "" : undefined,
|
|
63
|
+
"aria-pressed": selected === undefined ? undefined : selected ? "true" : "false",
|
|
64
|
+
"aria-label": label,
|
|
65
|
+
onclick: () => {
|
|
66
|
+
if (!loading) onPress?.();
|
|
67
|
+
},
|
|
68
|
+
onfocus: onFocus,
|
|
69
|
+
onblur: onBlur,
|
|
70
|
+
}),
|
|
71
|
+
() => loading === true,
|
|
72
|
+
);
|
|
73
|
+
let button = $state<HTMLButtonElement>();
|
|
74
|
+
|
|
75
|
+
/** Moves the focus to the native button. */
|
|
76
|
+
export function focus(options?: FocusOptions) {
|
|
77
|
+
button?.focus(options);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Takes the focus from the native button. */
|
|
81
|
+
export function blur() {
|
|
82
|
+
button?.blur();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The native button, once it is on the page. */
|
|
86
|
+
export function element(): HTMLButtonElement | undefined {
|
|
87
|
+
return button;
|
|
88
|
+
}
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<!-- The app's id gives way to the one an overlay gives its trigger, which the overlay's own
|
|
92
|
+
parts point at. -->
|
|
93
|
+
<button {...rootAttributes(rest)} {...attributes()} bind:this={button}>
|
|
94
|
+
{#if loading}
|
|
95
|
+
<span class={ICON_BUTTON_BOX[size]}><Spinner size="sm" /></span>
|
|
96
|
+
{:else}
|
|
97
|
+
<Icon name={icon} {size} filled={isHeld({ variant, selected, disabled })} />
|
|
98
|
+
{/if}
|
|
99
|
+
</button>
|