@sepale/components 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +65 -3
- package/dist/components/Accordion.svelte +48 -0
- package/dist/components/Accordion.svelte.d.ts +24 -0
- package/dist/components/Alert.svelte +107 -0
- package/dist/components/Alert.svelte.d.ts +40 -0
- package/dist/components/Avatar.svelte +75 -0
- package/dist/components/Avatar.svelte.d.ts +37 -0
- package/dist/components/Badge.svelte +46 -0
- package/dist/components/Badge.svelte.d.ts +22 -0
- package/dist/components/Breadcrumbs.svelte +36 -0
- package/dist/components/Breadcrumbs.svelte.d.ts +18 -0
- package/dist/components/Bubble.svelte +43 -0
- package/dist/components/Bubble.svelte.d.ts +23 -0
- package/dist/components/Button.svelte +132 -0
- package/dist/components/Button.svelte.d.ts +40 -0
- package/dist/components/Calendar.svelte +193 -0
- package/dist/components/Calendar.svelte.d.ts +60 -0
- package/dist/components/Card.svelte +69 -0
- package/dist/components/Card.svelte.d.ts +37 -0
- package/dist/components/Carousel.svelte +550 -0
- package/dist/components/Carousel.svelte.d.ts +124 -0
- package/dist/components/Checkbox.svelte +48 -0
- package/dist/components/Checkbox.svelte.d.ts +26 -0
- package/dist/components/Chip.svelte +60 -0
- package/dist/components/Chip.svelte.d.ts +26 -0
- package/dist/components/ChipsInput.svelte +158 -0
- package/dist/components/ChipsInput.svelte.d.ts +64 -0
- package/dist/components/Collapse.svelte +101 -0
- package/dist/components/Collapse.svelte.d.ts +46 -0
- package/dist/components/ColorPicker.svelte +135 -0
- package/dist/components/ColorPicker.svelte.d.ts +44 -0
- package/dist/components/Combobox.svelte +496 -0
- package/dist/components/Combobox.svelte.d.ts +96 -0
- package/dist/components/DataControl.svelte +754 -0
- package/dist/components/DataControl.svelte.d.ts +143 -0
- package/dist/components/DataHandler.svelte +67 -0
- package/dist/components/DataHandler.svelte.d.ts +44 -0
- package/dist/components/DatePicker.svelte +185 -0
- package/dist/components/DatePicker.svelte.d.ts +56 -0
- package/dist/components/Dialog.svelte +194 -0
- package/dist/components/Dialog.svelte.d.ts +51 -0
- package/dist/components/Divider.svelte +54 -0
- package/dist/components/Divider.svelte.d.ts +27 -0
- package/dist/components/Dock.svelte +34 -0
- package/dist/components/Dock.svelte.d.ts +18 -0
- package/dist/components/Drawer.svelte +174 -0
- package/dist/components/Drawer.svelte.d.ts +51 -0
- package/dist/components/Dropdown.svelte +183 -0
- package/dist/components/Dropdown.svelte.d.ts +52 -0
- package/dist/components/Editable.svelte +292 -0
- package/dist/components/Editable.svelte.d.ts +113 -0
- package/dist/components/EmptyState.svelte +64 -0
- package/dist/components/EmptyState.svelte.d.ts +29 -0
- package/dist/components/Fieldset.svelte +42 -0
- package/dist/components/Fieldset.svelte.d.ts +20 -0
- package/dist/components/FileDropzone.svelte +154 -0
- package/dist/components/FileDropzone.svelte.d.ts +45 -0
- package/dist/components/FileExplorer.svelte +643 -0
- package/dist/components/FileExplorer.svelte.d.ts +114 -0
- package/dist/components/FileInput.svelte +125 -0
- package/dist/components/FileInput.svelte.d.ts +51 -0
- package/dist/components/FloatingLabel.svelte +38 -0
- package/dist/components/FloatingLabel.svelte.d.ts +24 -0
- package/dist/components/Footer.svelte +68 -0
- package/dist/components/Footer.svelte.d.ts +37 -0
- package/dist/components/Grid.svelte +122 -0
- package/dist/components/Grid.svelte.d.ts +72 -0
- package/dist/components/Hero.svelte +62 -0
- package/dist/components/Hero.svelte.d.ts +33 -0
- package/dist/components/Input.svelte +184 -0
- package/dist/components/Input.svelte.d.ts +65 -0
- package/dist/components/Join.svelte +38 -0
- package/dist/components/Join.svelte.d.ts +21 -0
- package/dist/components/Kanban.svelte +284 -0
- package/dist/components/Kanban.svelte.d.ts +93 -0
- package/dist/components/Label.svelte +32 -0
- package/dist/components/Label.svelte.d.ts +21 -0
- package/dist/components/LaptopFrame.svelte +44 -0
- package/dist/components/LaptopFrame.svelte.d.ts +21 -0
- package/dist/components/List.svelte +95 -0
- package/dist/components/List.svelte.d.ts +69 -0
- package/dist/components/Loading.svelte +37 -0
- package/dist/components/Loading.svelte.d.ts +17 -0
- package/dist/components/Menu.svelte +144 -0
- package/dist/components/Menu.svelte.d.ts +53 -0
- package/dist/components/MobileFrame.svelte +41 -0
- package/dist/components/MobileFrame.svelte.d.ts +21 -0
- package/dist/components/Navbar.svelte +49 -0
- package/dist/components/Navbar.svelte.d.ts +25 -0
- package/dist/components/NumberInput.svelte +255 -0
- package/dist/components/NumberInput.svelte.d.ts +68 -0
- package/dist/components/Pagination.svelte +169 -0
- package/dist/components/Pagination.svelte.d.ts +50 -0
- package/dist/components/Progress.svelte +65 -0
- package/dist/components/Progress.svelte.d.ts +28 -0
- package/dist/components/RadialProgress.svelte +48 -0
- package/dist/components/RadialProgress.svelte.d.ts +20 -0
- package/dist/components/Radio.svelte +50 -0
- package/dist/components/Radio.svelte.d.ts +28 -0
- package/dist/components/Range.svelte +53 -0
- package/dist/components/Range.svelte.d.ts +26 -0
- package/dist/components/Rating.svelte +90 -0
- package/dist/components/Rating.svelte.d.ts +41 -0
- package/dist/components/Select.svelte +338 -0
- package/dist/components/Select.svelte.d.ts +74 -0
- package/dist/components/Sidebar.svelte +100 -0
- package/dist/components/Sidebar.svelte.d.ts +54 -0
- package/dist/components/Skeleton.svelte +40 -0
- package/dist/components/Skeleton.svelte.d.ts +18 -0
- package/dist/components/Stat.svelte +71 -0
- package/dist/components/Stat.svelte.d.ts +35 -0
- package/dist/components/Stats.svelte +38 -0
- package/dist/components/Stats.svelte.d.ts +22 -0
- package/dist/components/Steps.svelte +204 -0
- package/dist/components/Steps.svelte.d.ts +66 -0
- package/dist/components/Subtitle.svelte +44 -0
- package/dist/components/Subtitle.svelte.d.ts +26 -0
- package/dist/components/Swatch.svelte +61 -0
- package/dist/components/Swatch.svelte.d.ts +27 -0
- package/dist/components/Switch.svelte +105 -0
- package/dist/components/Switch.svelte.d.ts +44 -0
- package/dist/components/Table.svelte +243 -0
- package/dist/components/Table.svelte.d.ts +121 -0
- package/dist/components/Tabs.svelte +142 -0
- package/dist/components/Tabs.svelte.d.ts +80 -0
- package/dist/components/Text.svelte +43 -0
- package/dist/components/Text.svelte.d.ts +25 -0
- package/dist/components/Textarea.svelte +76 -0
- package/dist/components/Textarea.svelte.d.ts +39 -0
- package/dist/components/Title.svelte +46 -0
- package/dist/components/Title.svelte.d.ts +29 -0
- package/dist/components/Toast.svelte +154 -0
- package/dist/components/Toast.svelte.d.ts +49 -0
- package/dist/components/Toggle.svelte +48 -0
- package/dist/components/Toggle.svelte.d.ts +25 -0
- package/dist/components/Tooltip.svelte +70 -0
- package/dist/components/Tooltip.svelte.d.ts +34 -0
- package/dist/components/WindowFrame.svelte +53 -0
- package/dist/components/WindowFrame.svelte.d.ts +24 -0
- package/dist/components/accordion-context.d.ts +8 -0
- package/dist/components/accordion-context.js +25 -0
- package/dist/components/color.d.ts +39 -0
- package/dist/components/color.js +92 -0
- package/dist/components/data-handler.svelte.d.ts +362 -0
- package/dist/components/data-handler.svelte.js +690 -0
- package/dist/components/file-icons.d.ts +25 -0
- package/dist/components/file-icons.js +46 -0
- package/dist/family-types.d.ts +45 -0
- package/dist/family-types.js +73 -0
- package/dist/generated/classes.d.ts +17 -0
- package/dist/generated/classes.js +2511 -0
- package/dist/generated/components.d.ts +39 -0
- package/dist/generated/components.js +28666 -0
- package/dist/generated/registry.d.ts +35 -0
- package/dist/generated/registry.js +2658 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.js +99 -0
- package/dist/sepale-types.d.ts +8 -0
- package/dist/sepale-types.js +200 -0
- package/dist/theme.d.ts +123 -0
- package/dist/theme.js +226 -0
- package/dist/variants.d.ts +124 -0
- package/dist/variants.js +70 -0
- package/dist/vendor/air-datepicker/LICENSE.md +21 -0
- package/dist/vendor/air-datepicker/README.md +19 -0
- package/dist/vendor/air-datepicker/buttonPresets.d.ts +13 -0
- package/dist/vendor/air-datepicker/buttonPresets.js +12 -0
- package/dist/vendor/air-datepicker/consts.d.ts +18 -0
- package/dist/vendor/air-datepicker/consts.js +35 -0
- package/dist/vendor/air-datepicker/datepicker.d.ts +289 -0
- package/dist/vendor/air-datepicker/datepicker.js +1435 -0
- package/dist/vendor/air-datepicker/datepickerBody.d.ts +46 -0
- package/dist/vendor/air-datepicker/datepickerBody.js +386 -0
- package/dist/vendor/air-datepicker/datepickerButtons.d.ts +25 -0
- package/dist/vendor/air-datepicker/datepickerButtons.js +85 -0
- package/dist/vendor/air-datepicker/datepickerCell.d.ts +35 -0
- package/dist/vendor/air-datepicker/datepickerCell.js +297 -0
- package/dist/vendor/air-datepicker/datepickerKeyboard.d.ts +26 -0
- package/dist/vendor/air-datepicker/datepickerKeyboard.js +207 -0
- package/dist/vendor/air-datepicker/datepickerNav.d.ts +31 -0
- package/dist/vendor/air-datepicker/datepickerNav.js +200 -0
- package/dist/vendor/air-datepicker/datepickerTime.d.ts +60 -0
- package/dist/vendor/air-datepicker/datepickerTime.js +276 -0
- package/dist/vendor/air-datepicker/defaults.d.ts +65 -0
- package/dist/vendor/air-datepicker/defaults.js +79 -0
- package/dist/vendor/air-datepicker/index.d.ts +168 -0
- package/dist/vendor/air-datepicker/index.js +3 -0
- package/dist/vendor/air-datepicker/locale/ar.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/ar.js +14 -0
- package/dist/vendor/air-datepicker/locale/bg.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/bg.js +14 -0
- package/dist/vendor/air-datepicker/locale/ca.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/ca.js +14 -0
- package/dist/vendor/air-datepicker/locale/cs.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/cs.js +14 -0
- package/dist/vendor/air-datepicker/locale/da.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/da.js +14 -0
- package/dist/vendor/air-datepicker/locale/de.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/de.js +14 -0
- package/dist/vendor/air-datepicker/locale/el.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/el.js +14 -0
- package/dist/vendor/air-datepicker/locale/en.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/en.js +14 -0
- package/dist/vendor/air-datepicker/locale/es.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/es.js +14 -0
- package/dist/vendor/air-datepicker/locale/eu.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/eu.js +14 -0
- package/dist/vendor/air-datepicker/locale/fi.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/fi.js +14 -0
- package/dist/vendor/air-datepicker/locale/fr.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/fr.js +14 -0
- package/dist/vendor/air-datepicker/locale/hr.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/hr.js +14 -0
- package/dist/vendor/air-datepicker/locale/hu.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/hu.js +14 -0
- package/dist/vendor/air-datepicker/locale/id.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/id.js +14 -0
- package/dist/vendor/air-datepicker/locale/it.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/it.js +14 -0
- package/dist/vendor/air-datepicker/locale/ja.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/ja.js +14 -0
- package/dist/vendor/air-datepicker/locale/ko.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/ko.js +14 -0
- package/dist/vendor/air-datepicker/locale/nb.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/nb.js +14 -0
- package/dist/vendor/air-datepicker/locale/nl.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/nl.js +14 -0
- package/dist/vendor/air-datepicker/locale/pl.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/pl.js +14 -0
- package/dist/vendor/air-datepicker/locale/pt-BR.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/pt-BR.js +14 -0
- package/dist/vendor/air-datepicker/locale/pt.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/pt.js +14 -0
- package/dist/vendor/air-datepicker/locale/ro.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/ro.js +14 -0
- package/dist/vendor/air-datepicker/locale/ru.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/ru.js +14 -0
- package/dist/vendor/air-datepicker/locale/si.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/si.js +14 -0
- package/dist/vendor/air-datepicker/locale/sk.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/sk.js +14 -0
- package/dist/vendor/air-datepicker/locale/sl.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/sl.js +14 -0
- package/dist/vendor/air-datepicker/locale/sv.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/sv.js +14 -0
- package/dist/vendor/air-datepicker/locale/th.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/th.js +14 -0
- package/dist/vendor/air-datepicker/locale/tr.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/tr.js +16 -0
- package/dist/vendor/air-datepicker/locale/uk.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/uk.js +14 -0
- package/dist/vendor/air-datepicker/locale/zh.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/zh.js +14 -0
- package/dist/vendor/air-datepicker/typedefs.d.ts +3 -0
- package/dist/vendor/air-datepicker/typedefs.js +15 -0
- package/dist/vendor/air-datepicker/utils.d.ts +155 -0
- package/dist/vendor/air-datepicker/utils.js +395 -0
- package/dist/vendor/air-datepicker/withEvents.d.ts +1 -0
- package/dist/vendor/air-datepicker/withEvents.js +39 -0
- package/package.json +44 -3
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
/** What .dialog is made of, classified. The props follow the
|
|
3
|
+
families the project registers (variants.ts, ADR 0015).
|
|
4
|
+
|
|
5
|
+
The dialog draws its own box, title, body, actions and close button:
|
|
6
|
+
they are PARTS. */
|
|
7
|
+
export const PREFIX = 'dialog';
|
|
8
|
+
|
|
9
|
+
export const AXES = {
|
|
10
|
+
size: ['xs', 'sm', 'md', 'lg', 'xl'],
|
|
11
|
+
/* Where the box sits: centred unless told otherwise. */
|
|
12
|
+
placement: ['top', 'bottom']
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
export const FLAGS = {} as const;
|
|
16
|
+
export const PARTS = ['box', 'title', 'body', 'actions', 'close'] as const;
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script lang="ts">
|
|
20
|
+
/**
|
|
21
|
+
* A box over the page, on the native <dialog>. Modal by default —
|
|
22
|
+
* `showModal()`: the page behind is inert, focus stays inside, Escape
|
|
23
|
+
* closes it — or not (`modal={false}`), and the page stays usable.
|
|
24
|
+
*
|
|
25
|
+
* The actions sit in a `<form method="dialog">`: a button closes the
|
|
26
|
+
* dialog and its `value` becomes the dialog's return value, handed to
|
|
27
|
+
* `onClose`. The opening and closing are animated here, not in the CSS.
|
|
28
|
+
*/
|
|
29
|
+
import type { Snippet } from 'svelte';
|
|
30
|
+
import type { HTMLDialogAttributes } from 'svelte/elements';
|
|
31
|
+
import { scale } from 'svelte/transition';
|
|
32
|
+
import { applyAxes, cx, type AxisProps } from '../variants.js';
|
|
33
|
+
|
|
34
|
+
// `open` and `title` are ours: the first is driven through the element's
|
|
35
|
+
// methods, the second is a heading. Component events are `onXxx`; the
|
|
36
|
+
// native lowercase ones still pass through.
|
|
37
|
+
interface Props
|
|
38
|
+
extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>,
|
|
39
|
+
Omit<HTMLDialogAttributes, 'open' | 'title'> {
|
|
40
|
+
/** Whether it is shown. Bindable: closing from inside sets it back. */
|
|
41
|
+
open?: boolean;
|
|
42
|
+
/** Block the page behind it (`showModal`). Default true. */
|
|
43
|
+
modal?: boolean;
|
|
44
|
+
/** Draw a close button in the corner. Default true. */
|
|
45
|
+
closable?: boolean;
|
|
46
|
+
/** Close on Escape and on a click outside the box. Default true. */
|
|
47
|
+
dismissible?: boolean;
|
|
48
|
+
/** Animate opening and closing. Ignored when the visitor asks for reduced motion. */
|
|
49
|
+
animated?: boolean;
|
|
50
|
+
/** The heading, as text or as a snippet. */
|
|
51
|
+
title?: string | Snippet;
|
|
52
|
+
/** Buttons, inside the `<form method="dialog">`: each one closes with its `value`. */
|
|
53
|
+
actions?: Snippet;
|
|
54
|
+
/** After it closed, with the value of the button that closed it ('' otherwise). */
|
|
55
|
+
onClose?: (value: string) => void;
|
|
56
|
+
/** The accessible name of the close button. */
|
|
57
|
+
closeLabel?: string;
|
|
58
|
+
/** The `<dialog>` itself. Bindable. */
|
|
59
|
+
element?: HTMLDialogElement;
|
|
60
|
+
class?: string;
|
|
61
|
+
children?: Snippet;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let {
|
|
65
|
+
open = $bindable(false),
|
|
66
|
+
modal = true,
|
|
67
|
+
closable = true,
|
|
68
|
+
dismissible = true,
|
|
69
|
+
animated = true,
|
|
70
|
+
title,
|
|
71
|
+
actions,
|
|
72
|
+
onClose,
|
|
73
|
+
closeLabel = 'Close',
|
|
74
|
+
element = $bindable(),
|
|
75
|
+
class: klass = '',
|
|
76
|
+
children,
|
|
77
|
+
...axes
|
|
78
|
+
}: Props = $props();
|
|
79
|
+
|
|
80
|
+
let applied = $derived(applyAxes(PREFIX, AXES, FLAGS, axes));
|
|
81
|
+
let classes = $derived(cx(PREFIX, applied.classes, klass));
|
|
82
|
+
|
|
83
|
+
const uid = $props.id();
|
|
84
|
+
|
|
85
|
+
/** The box is in the DOM. Lags `open` while the closing transition runs. */
|
|
86
|
+
let shown = $state(false);
|
|
87
|
+
/** The value the dialog will close with, once the box has gone. */
|
|
88
|
+
let pending = '';
|
|
89
|
+
|
|
90
|
+
const reduced = () =>
|
|
91
|
+
typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
92
|
+
let duration = $derived(animated ? 150 : 0);
|
|
93
|
+
|
|
94
|
+
/* `open` drives the element. Opening is immediate; closing waits for the
|
|
95
|
+
box's outro (outroend → finish), unless there is nothing to wait for. */
|
|
96
|
+
$effect(() => {
|
|
97
|
+
if (!element) return;
|
|
98
|
+
if (open && !element.open) {
|
|
99
|
+
if (modal) element.showModal();
|
|
100
|
+
else element.show();
|
|
101
|
+
shown = true;
|
|
102
|
+
} else if (!open && element.open && shown) {
|
|
103
|
+
if (!animated || reduced()) finish();
|
|
104
|
+
else shown = false;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
/** Ask to close with a value; the transition runs, then the element closes. */
|
|
109
|
+
function request(value = '') {
|
|
110
|
+
pending = value;
|
|
111
|
+
open = false;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function finish() {
|
|
115
|
+
shown = false;
|
|
116
|
+
element?.close(pending);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* The element closed — by us, or by the browser on its own. */
|
|
120
|
+
function closed() {
|
|
121
|
+
const value = element?.returnValue ?? pending;
|
|
122
|
+
pending = '';
|
|
123
|
+
shown = false;
|
|
124
|
+
open = false;
|
|
125
|
+
if (element) element.returnValue = '';
|
|
126
|
+
onClose?.(value);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* Escape: the browser would close at once, skipping the transition. */
|
|
130
|
+
function cancel(e: Event) {
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
if (dismissible) request();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* A form with method="dialog" closes the element as it submits; the
|
|
136
|
+
value is taken here and the closing goes through the transition. */
|
|
137
|
+
function submit(e: SubmitEvent) {
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
const by = e.submitter as HTMLButtonElement | null;
|
|
140
|
+
request(by?.value ?? '');
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/* A click outside the box lands on the <dialog> itself. Only one that
|
|
144
|
+
also STARTED there counts: a text selection dragged out of the box
|
|
145
|
+
must not close it. */
|
|
146
|
+
let downOnOverlay = false;
|
|
147
|
+
function pointerdown(e: PointerEvent) {
|
|
148
|
+
downOnOverlay = e.target === element;
|
|
149
|
+
}
|
|
150
|
+
function click(e: MouseEvent) {
|
|
151
|
+
if (dismissible && downOnOverlay && e.target === element) request();
|
|
152
|
+
downOnOverlay = false;
|
|
153
|
+
}
|
|
154
|
+
</script>
|
|
155
|
+
|
|
156
|
+
<dialog
|
|
157
|
+
{...applied.rest}
|
|
158
|
+
bind:this={element}
|
|
159
|
+
class={classes}
|
|
160
|
+
aria-labelledby={title ? `${uid}-title` : undefined}
|
|
161
|
+
oncancel={cancel}
|
|
162
|
+
onclose={closed}
|
|
163
|
+
onpointerdown={pointerdown}
|
|
164
|
+
onclick={click}
|
|
165
|
+
>
|
|
166
|
+
{#if shown}
|
|
167
|
+
<div
|
|
168
|
+
class={`${PREFIX}-box`}
|
|
169
|
+
transition:scale={{ start: 0.95, duration: reduced() ? 0 : duration }}
|
|
170
|
+
onoutroend={finish}
|
|
171
|
+
>
|
|
172
|
+
{#if closable}
|
|
173
|
+
<form method="dialog" onsubmit={submit}>
|
|
174
|
+
<button type="submit" class={`${PREFIX}-close`} aria-label={closeLabel} value="">
|
|
175
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M18 6 6 18M6 6l12 12" /></svg>
|
|
176
|
+
</button>
|
|
177
|
+
</form>
|
|
178
|
+
{/if}
|
|
179
|
+
{#if title}
|
|
180
|
+
<h2 id={`${uid}-title`} class={`${PREFIX}-title`}>
|
|
181
|
+
{#if typeof title === 'function'}{@render title()}{:else}{title}{/if}
|
|
182
|
+
</h2>
|
|
183
|
+
{/if}
|
|
184
|
+
{#if children}
|
|
185
|
+
<div class={`${PREFIX}-body`}>{@render children()}</div>
|
|
186
|
+
{/if}
|
|
187
|
+
{#if actions}
|
|
188
|
+
<form method="dialog" class={`${PREFIX}-actions`} onsubmit={submit}>
|
|
189
|
+
{@render actions()}
|
|
190
|
+
</form>
|
|
191
|
+
{/if}
|
|
192
|
+
</div>
|
|
193
|
+
{/if}
|
|
194
|
+
</dialog>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** What .dialog is made of, classified. The props follow the
|
|
2
|
+
families the project registers (variants.ts, ADR 0015).
|
|
3
|
+
|
|
4
|
+
The dialog draws its own box, title, body, actions and close button:
|
|
5
|
+
they are PARTS. */
|
|
6
|
+
export declare const PREFIX = "dialog";
|
|
7
|
+
export declare const AXES: {
|
|
8
|
+
readonly size: readonly ["xs", "sm", "md", "lg", "xl"];
|
|
9
|
+
readonly placement: readonly ["top", "bottom"];
|
|
10
|
+
};
|
|
11
|
+
export declare const FLAGS: {};
|
|
12
|
+
export declare const PARTS: readonly ["box", "title", "body", "actions", "close"];
|
|
13
|
+
/**
|
|
14
|
+
* A box over the page, on the native <dialog>. Modal by default —
|
|
15
|
+
* `showModal()`: the page behind is inert, focus stays inside, Escape
|
|
16
|
+
* closes it — or not (`modal={false}`), and the page stays usable.
|
|
17
|
+
*
|
|
18
|
+
* The actions sit in a `<form method="dialog">`: a button closes the
|
|
19
|
+
* dialog and its `value` becomes the dialog's return value, handed to
|
|
20
|
+
* `onClose`. The opening and closing are animated here, not in the CSS.
|
|
21
|
+
*/
|
|
22
|
+
import type { Snippet } from 'svelte';
|
|
23
|
+
import type { HTMLDialogAttributes } from 'svelte/elements';
|
|
24
|
+
import { type AxisProps } from '../variants.js';
|
|
25
|
+
interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, Omit<HTMLDialogAttributes, 'open' | 'title'> {
|
|
26
|
+
/** Whether it is shown. Bindable: closing from inside sets it back. */
|
|
27
|
+
open?: boolean;
|
|
28
|
+
/** Block the page behind it (`showModal`). Default true. */
|
|
29
|
+
modal?: boolean;
|
|
30
|
+
/** Draw a close button in the corner. Default true. */
|
|
31
|
+
closable?: boolean;
|
|
32
|
+
/** Close on Escape and on a click outside the box. Default true. */
|
|
33
|
+
dismissible?: boolean;
|
|
34
|
+
/** Animate opening and closing. Ignored when the visitor asks for reduced motion. */
|
|
35
|
+
animated?: boolean;
|
|
36
|
+
/** The heading, as text or as a snippet. */
|
|
37
|
+
title?: string | Snippet;
|
|
38
|
+
/** Buttons, inside the `<form method="dialog">`: each one closes with its `value`. */
|
|
39
|
+
actions?: Snippet;
|
|
40
|
+
/** After it closed, with the value of the button that closed it ('' otherwise). */
|
|
41
|
+
onClose?: (value: string) => void;
|
|
42
|
+
/** The accessible name of the close button. */
|
|
43
|
+
closeLabel?: string;
|
|
44
|
+
/** The `<dialog>` itself. Bindable. */
|
|
45
|
+
element?: HTMLDialogElement;
|
|
46
|
+
class?: string;
|
|
47
|
+
children?: Snippet;
|
|
48
|
+
}
|
|
49
|
+
declare const Dialog: import("svelte").Component<Props, {}, "element" | "open">;
|
|
50
|
+
type Dialog = ReturnType<typeof Dialog>;
|
|
51
|
+
export default Dialog;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
/** What .divider is made of, classified. The props follow the
|
|
3
|
+
families the project registers (variants.ts, ADR 0015). */
|
|
4
|
+
export const PREFIX = 'divider';
|
|
5
|
+
|
|
6
|
+
export const AXES = {
|
|
7
|
+
direction: ['horizontal', 'vertical'],
|
|
8
|
+
/* Where the content sits along the line. */
|
|
9
|
+
align: ['start', 'center', 'end'],
|
|
10
|
+
color: ['primary', 'secondary', 'accent', 'neutral', 'info', 'success', 'warning', 'error'],
|
|
11
|
+
/* The line's shape. Each family ships its own, or none. */
|
|
12
|
+
variant: ['dashed', 'dotted', 'thick', 'fade']
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
export const FLAGS = {} as const;
|
|
16
|
+
export const PARTS = ['content'] as const;
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script lang="ts">
|
|
20
|
+
/**
|
|
21
|
+
* A rule between two things, optionally carrying a word or two.
|
|
22
|
+
*
|
|
23
|
+
* Without children it is an `<hr>`. With children it is a `separator` whose
|
|
24
|
+
* content sits between two lines.
|
|
25
|
+
*/
|
|
26
|
+
import type { Snippet } from 'svelte';
|
|
27
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
28
|
+
import { applyAxes, cx, type AxisProps } from '../variants.js';
|
|
29
|
+
|
|
30
|
+
interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, Omit<HTMLAttributes<HTMLElement>, 'color'> {
|
|
31
|
+
class?: string;
|
|
32
|
+
children?: Snippet;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// The axes are deliberately NOT destructured: they travel in `axes` and are
|
|
36
|
+
// resolved by name, so an axis a family drops changes nothing down here.
|
|
37
|
+
let {
|
|
38
|
+
class: klass = '',
|
|
39
|
+
children,
|
|
40
|
+
...axes
|
|
41
|
+
}: Props = $props();
|
|
42
|
+
|
|
43
|
+
let applied = $derived(applyAxes(PREFIX, AXES, FLAGS, axes));
|
|
44
|
+
let classes = $derived(cx(PREFIX, applied.classes, klass));
|
|
45
|
+
let vertical = $derived(classes.includes(`${PREFIX}-vertical`));
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
{#if children}
|
|
49
|
+
<div {...applied.rest} class={classes} role="separator" aria-orientation={vertical ? 'vertical' : 'horizontal'}>
|
|
50
|
+
<span class="divider-content">{@render children()}</span>
|
|
51
|
+
</div>
|
|
52
|
+
{:else}
|
|
53
|
+
<hr {...applied.rest} class={classes} aria-orientation={vertical ? 'vertical' : undefined} />
|
|
54
|
+
{/if}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** What .divider is made of, classified. The props follow the
|
|
2
|
+
families the project registers (variants.ts, ADR 0015). */
|
|
3
|
+
export declare const PREFIX = "divider";
|
|
4
|
+
export declare const AXES: {
|
|
5
|
+
readonly direction: readonly ["horizontal", "vertical"];
|
|
6
|
+
readonly align: readonly ["start", "center", "end"];
|
|
7
|
+
readonly color: readonly ["primary", "secondary", "accent", "neutral", "info", "success", "warning", "error"];
|
|
8
|
+
readonly variant: readonly ["dashed", "dotted", "thick", "fade"];
|
|
9
|
+
};
|
|
10
|
+
export declare const FLAGS: {};
|
|
11
|
+
export declare const PARTS: readonly ["content"];
|
|
12
|
+
/**
|
|
13
|
+
* A rule between two things, optionally carrying a word or two.
|
|
14
|
+
*
|
|
15
|
+
* Without children it is an `<hr>`. With children it is a `separator` whose
|
|
16
|
+
* content sits between two lines.
|
|
17
|
+
*/
|
|
18
|
+
import type { Snippet } from 'svelte';
|
|
19
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
20
|
+
import { type AxisProps } from '../variants.js';
|
|
21
|
+
interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, Omit<HTMLAttributes<HTMLElement>, 'color'> {
|
|
22
|
+
class?: string;
|
|
23
|
+
children?: Snippet;
|
|
24
|
+
}
|
|
25
|
+
declare const Divider: import("svelte").Component<Props, {}, "">;
|
|
26
|
+
type Divider = ReturnType<typeof Divider>;
|
|
27
|
+
export default Divider;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
/** What .dock is made of, classified. The props follow the
|
|
3
|
+
families the project registers (variants.ts, ADR 0015). */
|
|
4
|
+
export const PREFIX = 'dock';
|
|
5
|
+
|
|
6
|
+
export const AXES = {
|
|
7
|
+
size: ['xs', 'sm', 'md', 'lg', 'xl']
|
|
8
|
+
} as const;
|
|
9
|
+
|
|
10
|
+
export const FLAGS = {} as const;
|
|
11
|
+
export const PARTS = ['active', 'label'] as const;
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
import type { Snippet } from 'svelte';
|
|
16
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
17
|
+
import { applyAxes, cx, type AxisProps } from '../variants.js';
|
|
18
|
+
|
|
19
|
+
interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, HTMLAttributes<HTMLElement> {
|
|
20
|
+
class?: string;
|
|
21
|
+
children?: Snippet;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let {
|
|
25
|
+
class: klass = '',
|
|
26
|
+
children,
|
|
27
|
+
...axes
|
|
28
|
+
}: Props = $props();
|
|
29
|
+
|
|
30
|
+
let applied = $derived(applyAxes(PREFIX, AXES, FLAGS, axes));
|
|
31
|
+
let classes = $derived(cx(PREFIX, applied.classes, klass));
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<nav {...applied.rest} class={classes}>{@render children?.()}</nav>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** What .dock is made of, classified. The props follow the
|
|
2
|
+
families the project registers (variants.ts, ADR 0015). */
|
|
3
|
+
export declare const PREFIX = "dock";
|
|
4
|
+
export declare const AXES: {
|
|
5
|
+
readonly size: readonly ["xs", "sm", "md", "lg", "xl"];
|
|
6
|
+
};
|
|
7
|
+
export declare const FLAGS: {};
|
|
8
|
+
export declare const PARTS: readonly ["active", "label"];
|
|
9
|
+
import type { Snippet } from 'svelte';
|
|
10
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
11
|
+
import { type AxisProps } from '../variants.js';
|
|
12
|
+
interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, HTMLAttributes<HTMLElement> {
|
|
13
|
+
class?: string;
|
|
14
|
+
children?: Snippet;
|
|
15
|
+
}
|
|
16
|
+
declare const Dock: import("svelte").Component<Props, {}, "">;
|
|
17
|
+
type Dock = ReturnType<typeof Dock>;
|
|
18
|
+
export default Dock;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
/** What .drawer is made of, classified. The props follow the
|
|
3
|
+
families the project registers (variants.ts, ADR 0015). */
|
|
4
|
+
export const PREFIX = 'drawer';
|
|
5
|
+
|
|
6
|
+
export const AXES = {
|
|
7
|
+
/* The edge it slides from. Left when none is given. */
|
|
8
|
+
side: ['left', 'right', 'top', 'bottom']
|
|
9
|
+
} as const;
|
|
10
|
+
|
|
11
|
+
export const FLAGS = {} as const;
|
|
12
|
+
export const PARTS = ['content', 'handle'] as const;
|
|
13
|
+
|
|
14
|
+
/** hidden: out of view · peek: its last --drawer-peek in view · open: all of it. */
|
|
15
|
+
export type DrawerState = 'hidden' | 'peek' | 'open';
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<script lang="ts">
|
|
19
|
+
/**
|
|
20
|
+
* A panel sliding in from any side, in three states: hidden, peek, open.
|
|
21
|
+
*
|
|
22
|
+
* `state` is where it starts, read once. From then on the drawer is driven
|
|
23
|
+
* by its methods — `bind:this={d}`, then `d.open()`, `d.peek()`, `d.hide()`,
|
|
24
|
+
* `d.toggle()` — and reports every change through `onState`. It moves by
|
|
25
|
+
* itself only to fall back to its rest state (`peek` if it started peeking,
|
|
26
|
+
* else `hidden`): on Escape, or a click on the backdrop. A click on a
|
|
27
|
+
* peeking drawer opens it.
|
|
28
|
+
*
|
|
29
|
+
* `as` picks the element. `dialog` makes `open` modal (backdrop, focus kept
|
|
30
|
+
* inside, page inert) while `peek` stays non-modal; `aside`, `nav` and the
|
|
31
|
+
* default `div` never block the page — a collapsible menu is a `nav`.
|
|
32
|
+
*/
|
|
33
|
+
import { onMount, untrack, type Snippet } from 'svelte';
|
|
34
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
35
|
+
import { applyAxes, cx, type AxisProps } from '../variants.js';
|
|
36
|
+
|
|
37
|
+
interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, HTMLAttributes<HTMLElement> {
|
|
38
|
+
/** The element. `dialog` makes the open state modal. */
|
|
39
|
+
as?: 'div' | 'aside' | 'nav' | 'dialog';
|
|
40
|
+
/** Where it starts. Read once: use the methods afterwards. */
|
|
41
|
+
state?: DrawerState;
|
|
42
|
+
/** Where Escape and the backdrop send it. Defaults to `peek` if it starts peeking, else `hidden`. */
|
|
43
|
+
rest?: 'hidden' | 'peek';
|
|
44
|
+
/** After every change of state. */
|
|
45
|
+
onState?: (state: DrawerState) => void;
|
|
46
|
+
/** Draw a grip on the inner edge that toggles open and the rest state. */
|
|
47
|
+
handle?: boolean;
|
|
48
|
+
handleLabel?: string;
|
|
49
|
+
class?: string;
|
|
50
|
+
children?: Snippet;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// The axes are deliberately NOT destructured: they travel in `axes` and are
|
|
54
|
+
// resolved by name, so an axis a family drops changes nothing down here.
|
|
55
|
+
let {
|
|
56
|
+
as = 'div',
|
|
57
|
+
state: initial = 'hidden',
|
|
58
|
+
rest: restProp,
|
|
59
|
+
onState,
|
|
60
|
+
handle = false,
|
|
61
|
+
handleLabel = 'Toggle panel',
|
|
62
|
+
class: klass = '',
|
|
63
|
+
children,
|
|
64
|
+
...axes
|
|
65
|
+
}: Props = $props();
|
|
66
|
+
|
|
67
|
+
let applied = $derived(applyAxes(PREFIX, AXES, FLAGS, axes));
|
|
68
|
+
let classes = $derived(cx(PREFIX, applied.classes, klass));
|
|
69
|
+
|
|
70
|
+
/* Where it starts, read once: afterwards the methods own it. */
|
|
71
|
+
let current: DrawerState = $state(untrack(() => initial));
|
|
72
|
+
let restState = $derived(restProp ?? (untrack(() => initial) === 'peek' ? 'peek' : 'hidden'));
|
|
73
|
+
|
|
74
|
+
let element: HTMLElement | undefined = $state();
|
|
75
|
+
const dialog = () => (as === 'dialog' ? (element as HTMLDialogElement | undefined) : undefined);
|
|
76
|
+
|
|
77
|
+
/** Puts a <dialog> in the mode the state needs. Hiding waits for the slide. */
|
|
78
|
+
function sync(next: DrawerState) {
|
|
79
|
+
const d = dialog();
|
|
80
|
+
if (!d) return;
|
|
81
|
+
if (next === 'open') {
|
|
82
|
+
if (d.open) d.close();
|
|
83
|
+
d.showModal();
|
|
84
|
+
} else if (next === 'peek') {
|
|
85
|
+
if (d.open) d.close();
|
|
86
|
+
d.show();
|
|
87
|
+
} else {
|
|
88
|
+
const done = () => {
|
|
89
|
+
if (current === 'hidden' && d.open) d.close();
|
|
90
|
+
};
|
|
91
|
+
d.addEventListener('transitionend', done, { once: true });
|
|
92
|
+
setTimeout(done, 500);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function go(next: DrawerState) {
|
|
97
|
+
if (next === current) return;
|
|
98
|
+
current = next;
|
|
99
|
+
sync(next);
|
|
100
|
+
onState?.(next);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function open() {
|
|
104
|
+
go('open');
|
|
105
|
+
}
|
|
106
|
+
export function peek() {
|
|
107
|
+
go('peek');
|
|
108
|
+
}
|
|
109
|
+
export function hide() {
|
|
110
|
+
go('hidden');
|
|
111
|
+
}
|
|
112
|
+
/** Open, or back to the rest state when open. */
|
|
113
|
+
export function toggle() {
|
|
114
|
+
go(current === 'open' ? restState : 'open');
|
|
115
|
+
}
|
|
116
|
+
export function getState(): DrawerState {
|
|
117
|
+
return current;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
onMount(() => {
|
|
121
|
+
if (current !== 'hidden') sync(current);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
/* A dialog's Escape: the browser would close it outright. */
|
|
125
|
+
function cancel(e: Event) {
|
|
126
|
+
e.preventDefault();
|
|
127
|
+
go(restState);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function keydown(e: KeyboardEvent) {
|
|
131
|
+
if (e.key === 'Escape' && current === 'open' && as !== 'dialog') {
|
|
132
|
+
e.stopPropagation();
|
|
133
|
+
go(restState);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function click(e: MouseEvent) {
|
|
138
|
+
if (e.defaultPrevented || !element) return;
|
|
139
|
+
/* A modal dialog's backdrop: the click lands on the element, outside its box. */
|
|
140
|
+
if (as === 'dialog' && current === 'open' && e.target === element) {
|
|
141
|
+
const r = element.getBoundingClientRect();
|
|
142
|
+
const inside = e.clientX >= r.left && e.clientX <= r.right && e.clientY >= r.top && e.clientY <= r.bottom;
|
|
143
|
+
if (!inside) return go(restState);
|
|
144
|
+
}
|
|
145
|
+
if (current === 'peek') go('open');
|
|
146
|
+
}
|
|
147
|
+
</script>
|
|
148
|
+
|
|
149
|
+
<svelte:element
|
|
150
|
+
this={as}
|
|
151
|
+
{...applied.rest}
|
|
152
|
+
bind:this={element}
|
|
153
|
+
class={classes}
|
|
154
|
+
data-state={current}
|
|
155
|
+
inert={current === 'hidden' && as !== 'dialog' ? true : undefined}
|
|
156
|
+
oncancel={as === 'dialog' ? cancel : undefined}
|
|
157
|
+
onkeydown={keydown}
|
|
158
|
+
onclick={click}
|
|
159
|
+
role={as === 'div' ? 'region' : undefined}
|
|
160
|
+
>
|
|
161
|
+
<div class="drawer-content">{@render children?.()}</div>
|
|
162
|
+
{#if handle}
|
|
163
|
+
<button
|
|
164
|
+
type="button"
|
|
165
|
+
class="drawer-handle"
|
|
166
|
+
aria-label={handleLabel}
|
|
167
|
+
aria-expanded={current === 'open'}
|
|
168
|
+
onclick={(e) => {
|
|
169
|
+
e.preventDefault();
|
|
170
|
+
toggle();
|
|
171
|
+
}}
|
|
172
|
+
></button>
|
|
173
|
+
{/if}
|
|
174
|
+
</svelte:element>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** What .drawer is made of, classified. The props follow the
|
|
2
|
+
families the project registers (variants.ts, ADR 0015). */
|
|
3
|
+
export declare const PREFIX = "drawer";
|
|
4
|
+
export declare const AXES: {
|
|
5
|
+
readonly side: readonly ["left", "right", "top", "bottom"];
|
|
6
|
+
};
|
|
7
|
+
export declare const FLAGS: {};
|
|
8
|
+
export declare const PARTS: readonly ["content", "handle"];
|
|
9
|
+
/** hidden: out of view · peek: its last --drawer-peek in view · open: all of it. */
|
|
10
|
+
export type DrawerState = 'hidden' | 'peek' | 'open';
|
|
11
|
+
/**
|
|
12
|
+
* A panel sliding in from any side, in three states: hidden, peek, open.
|
|
13
|
+
*
|
|
14
|
+
* `state` is where it starts, read once. From then on the drawer is driven
|
|
15
|
+
* by its methods — `bind:this={d}`, then `d.open()`, `d.peek()`, `d.hide()`,
|
|
16
|
+
* `d.toggle()` — and reports every change through `onState`. It moves by
|
|
17
|
+
* itself only to fall back to its rest state (`peek` if it started peeking,
|
|
18
|
+
* else `hidden`): on Escape, or a click on the backdrop. A click on a
|
|
19
|
+
* peeking drawer opens it.
|
|
20
|
+
*
|
|
21
|
+
* `as` picks the element. `dialog` makes `open` modal (backdrop, focus kept
|
|
22
|
+
* inside, page inert) while `peek` stays non-modal; `aside`, `nav` and the
|
|
23
|
+
* default `div` never block the page — a collapsible menu is a `nav`.
|
|
24
|
+
*/
|
|
25
|
+
import { type Snippet } from 'svelte';
|
|
26
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
27
|
+
import { type AxisProps } from '../variants.js';
|
|
28
|
+
interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, HTMLAttributes<HTMLElement> {
|
|
29
|
+
/** The element. `dialog` makes the open state modal. */
|
|
30
|
+
as?: 'div' | 'aside' | 'nav' | 'dialog';
|
|
31
|
+
/** Where it starts. Read once: use the methods afterwards. */
|
|
32
|
+
state?: DrawerState;
|
|
33
|
+
/** Where Escape and the backdrop send it. Defaults to `peek` if it starts peeking, else `hidden`. */
|
|
34
|
+
rest?: 'hidden' | 'peek';
|
|
35
|
+
/** After every change of state. */
|
|
36
|
+
onState?: (state: DrawerState) => void;
|
|
37
|
+
/** Draw a grip on the inner edge that toggles open and the rest state. */
|
|
38
|
+
handle?: boolean;
|
|
39
|
+
handleLabel?: string;
|
|
40
|
+
class?: string;
|
|
41
|
+
children?: Snippet;
|
|
42
|
+
}
|
|
43
|
+
declare const Drawer: import("svelte").Component<Props, {
|
|
44
|
+
open: () => void;
|
|
45
|
+
peek: () => void;
|
|
46
|
+
hide: () => void;
|
|
47
|
+
toggle: () => void;
|
|
48
|
+
getState: () => DrawerState;
|
|
49
|
+
}, "">;
|
|
50
|
+
type Drawer = ReturnType<typeof Drawer>;
|
|
51
|
+
export default Drawer;
|