@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,71 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
/** What .stat is made of, classified. */
|
|
3
|
+
export const PREFIX = 'stat';
|
|
4
|
+
|
|
5
|
+
export const AXES = {
|
|
6
|
+
size: ['xs', 'sm', 'md', 'lg', 'xl']
|
|
7
|
+
} as const;
|
|
8
|
+
|
|
9
|
+
export const FLAGS = {} as const;
|
|
10
|
+
export const PARTS = ['title', 'value', 'desc', 'figure', 'actions'] as const;
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
/**
|
|
15
|
+
* A figure worth a glance: a title, a value, a description, and optionally
|
|
16
|
+
* a figure on the side and a row of actions.
|
|
17
|
+
*
|
|
18
|
+
* The three text parts take a string — the common case — or a snippet.
|
|
19
|
+
* Put several in a `Stats` to line them up in one frame.
|
|
20
|
+
*/
|
|
21
|
+
import type { Snippet } from 'svelte';
|
|
22
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
23
|
+
import { applyAxes, cx, type AxisProps } from '../variants.js';
|
|
24
|
+
|
|
25
|
+
/* `title` is an HTML attribute too, and a tooltip is not a label — so the
|
|
26
|
+
DOM one is dropped rather than shadowed silently. */
|
|
27
|
+
interface Props
|
|
28
|
+
extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>,
|
|
29
|
+
Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
30
|
+
/** The small label above the value. */
|
|
31
|
+
title?: string | Snippet;
|
|
32
|
+
/** The number itself. */
|
|
33
|
+
value?: string | Snippet;
|
|
34
|
+
/** A line under the value: a trend, a period. */
|
|
35
|
+
desc?: string | Snippet;
|
|
36
|
+
/** An icon or a picture, beside the text. */
|
|
37
|
+
figure?: Snippet;
|
|
38
|
+
/** A row of buttons, under the text. */
|
|
39
|
+
actions?: Snippet;
|
|
40
|
+
class?: string;
|
|
41
|
+
/** Anything else, after the description. */
|
|
42
|
+
children?: Snippet;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let {
|
|
46
|
+
title,
|
|
47
|
+
value,
|
|
48
|
+
desc,
|
|
49
|
+
figure,
|
|
50
|
+
actions,
|
|
51
|
+
class: klass = '',
|
|
52
|
+
children,
|
|
53
|
+
...axes
|
|
54
|
+
}: Props = $props();
|
|
55
|
+
|
|
56
|
+
let applied = $derived(applyAxes(PREFIX, AXES, FLAGS, axes));
|
|
57
|
+
let classes = $derived(cx(PREFIX, applied.classes, klass));
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
{#snippet text(part: string | Snippet)}
|
|
61
|
+
{#if typeof part === 'string'}{part}{:else}{@render part()}{/if}
|
|
62
|
+
{/snippet}
|
|
63
|
+
|
|
64
|
+
<div class={classes} {...applied.rest}>
|
|
65
|
+
{#if figure}<div class="stat-figure">{@render figure()}</div>{/if}
|
|
66
|
+
{#if title}<div class="stat-title">{@render text(title)}</div>{/if}
|
|
67
|
+
{#if value}<div class="stat-value">{@render text(value)}</div>{/if}
|
|
68
|
+
{#if desc}<div class="stat-desc">{@render text(desc)}</div>{/if}
|
|
69
|
+
{@render children?.()}
|
|
70
|
+
{#if actions}<div class="stat-actions">{@render actions()}</div>{/if}
|
|
71
|
+
</div>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** What .stat is made of, classified. */
|
|
2
|
+
export declare const PREFIX = "stat";
|
|
3
|
+
export declare const AXES: {
|
|
4
|
+
readonly size: readonly ["xs", "sm", "md", "lg", "xl"];
|
|
5
|
+
};
|
|
6
|
+
export declare const FLAGS: {};
|
|
7
|
+
export declare const PARTS: readonly ["title", "value", "desc", "figure", "actions"];
|
|
8
|
+
/**
|
|
9
|
+
* A figure worth a glance: a title, a value, a description, and optionally
|
|
10
|
+
* a figure on the side and a row of actions.
|
|
11
|
+
*
|
|
12
|
+
* The three text parts take a string — the common case — or a snippet.
|
|
13
|
+
* Put several in a `Stats` to line them up in one frame.
|
|
14
|
+
*/
|
|
15
|
+
import type { Snippet } from 'svelte';
|
|
16
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
17
|
+
import { type AxisProps } from '../variants.js';
|
|
18
|
+
interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
19
|
+
/** The small label above the value. */
|
|
20
|
+
title?: string | Snippet;
|
|
21
|
+
/** The number itself. */
|
|
22
|
+
value?: string | Snippet;
|
|
23
|
+
/** A line under the value: a trend, a period. */
|
|
24
|
+
desc?: string | Snippet;
|
|
25
|
+
/** An icon or a picture, beside the text. */
|
|
26
|
+
figure?: Snippet;
|
|
27
|
+
/** A row of buttons, under the text. */
|
|
28
|
+
actions?: Snippet;
|
|
29
|
+
class?: string;
|
|
30
|
+
/** Anything else, after the description. */
|
|
31
|
+
children?: Snippet;
|
|
32
|
+
}
|
|
33
|
+
declare const Stat: import("svelte").Component<Props, {}, "">;
|
|
34
|
+
type Stat = ReturnType<typeof Stat>;
|
|
35
|
+
export default Stat;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
/** What .stats is made of, classified. */
|
|
3
|
+
export const PREFIX = 'stats';
|
|
4
|
+
|
|
5
|
+
export const AXES = {
|
|
6
|
+
direction: ['horizontal', 'vertical']
|
|
7
|
+
} as const;
|
|
8
|
+
|
|
9
|
+
export const FLAGS = {} as const;
|
|
10
|
+
export const PARTS = [] as const;
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
/**
|
|
15
|
+
* Several stats in one frame, a divider between each. The stats inside put
|
|
16
|
+
* their own frame down; a row by default.
|
|
17
|
+
*/
|
|
18
|
+
import type { Snippet } from 'svelte';
|
|
19
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
20
|
+
import { applyAxes, cx, type AxisProps } from '../variants.js';
|
|
21
|
+
|
|
22
|
+
interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, HTMLAttributes<HTMLDivElement> {
|
|
23
|
+
class?: string;
|
|
24
|
+
/** The `Stat`s. */
|
|
25
|
+
children?: Snippet;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let {
|
|
29
|
+
class: klass = '',
|
|
30
|
+
children,
|
|
31
|
+
...axes
|
|
32
|
+
}: Props = $props();
|
|
33
|
+
|
|
34
|
+
let applied = $derived(applyAxes(PREFIX, AXES, FLAGS, axes));
|
|
35
|
+
let classes = $derived(cx(PREFIX, applied.classes, klass));
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<div class={classes} {...applied.rest}>{@render children?.()}</div>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** What .stats is made of, classified. */
|
|
2
|
+
export declare const PREFIX = "stats";
|
|
3
|
+
export declare const AXES: {
|
|
4
|
+
readonly direction: readonly ["horizontal", "vertical"];
|
|
5
|
+
};
|
|
6
|
+
export declare const FLAGS: {};
|
|
7
|
+
export declare const PARTS: readonly [];
|
|
8
|
+
/**
|
|
9
|
+
* Several stats in one frame, a divider between each. The stats inside put
|
|
10
|
+
* their own frame down; a row by default.
|
|
11
|
+
*/
|
|
12
|
+
import type { Snippet } from 'svelte';
|
|
13
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
14
|
+
import { type AxisProps } from '../variants.js';
|
|
15
|
+
interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, HTMLAttributes<HTMLDivElement> {
|
|
16
|
+
class?: string;
|
|
17
|
+
/** The `Stat`s. */
|
|
18
|
+
children?: Snippet;
|
|
19
|
+
}
|
|
20
|
+
declare const Stats: import("svelte").Component<Props, {}, "">;
|
|
21
|
+
type Stats = ReturnType<typeof Stats>;
|
|
22
|
+
export default Stats;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
/** What .steps is made of, classified. The props follow the
|
|
3
|
+
families the project registers (variants.ts, ADR 0015). */
|
|
4
|
+
export const PREFIX = 'steps';
|
|
5
|
+
|
|
6
|
+
export const AXES = {
|
|
7
|
+
direction: ['horizontal', 'vertical'],
|
|
8
|
+
color: ['primary', 'secondary', 'accent', 'neutral', 'info', 'success', 'warning', 'error'],
|
|
9
|
+
size: ['xs', 'sm', 'md', 'lg', 'xl']
|
|
10
|
+
} as const;
|
|
11
|
+
|
|
12
|
+
export const FLAGS = {
|
|
13
|
+
compact: 'No markers nor labels: the bars, and a heading above them (small screens).'
|
|
14
|
+
} as const;
|
|
15
|
+
export const PARTS = [
|
|
16
|
+
'heading',
|
|
17
|
+
'list',
|
|
18
|
+
'item',
|
|
19
|
+
'track',
|
|
20
|
+
'marker',
|
|
21
|
+
'segment',
|
|
22
|
+
'label',
|
|
23
|
+
'issue',
|
|
24
|
+
'sublabel'
|
|
25
|
+
] as const;
|
|
26
|
+
|
|
27
|
+
/** A stage of the journey. Its sub-steps go one level deep, no further. */
|
|
28
|
+
export interface Step {
|
|
29
|
+
id: string | number;
|
|
30
|
+
label?: string;
|
|
31
|
+
/** The sub-steps. A step without any is a stage of its own. */
|
|
32
|
+
steps?: Step[];
|
|
33
|
+
/** Declared done by the app. Visiting a step does not complete it. */
|
|
34
|
+
complete?: boolean;
|
|
35
|
+
/** Shown once the step has been reached. */
|
|
36
|
+
error?: string;
|
|
37
|
+
warning?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** current · visited (reached before) · complete (declared) · unknown (not reached). */
|
|
41
|
+
export type StepState = 'current' | 'visited' | 'complete' | 'unknown';
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<script lang="ts">
|
|
45
|
+
/**
|
|
46
|
+
* Where the user is in a journey: one column per step, one bar per sub-step.
|
|
47
|
+
*
|
|
48
|
+
* The component moves nothing: a click calls `onStep` with the step, and
|
|
49
|
+
* the app decides whether to change `current`. A step is clickable once it
|
|
50
|
+
* has been reached (current, visited or complete) — a step's own marker
|
|
51
|
+
* leads to its first sub-step. `clickable={false}` or `disabled` turns that
|
|
52
|
+
* off.
|
|
53
|
+
*
|
|
54
|
+
* `explored` is the first leaf never reached; every leaf before it counts
|
|
55
|
+
* as visited. Without it, everything up to `current` does.
|
|
56
|
+
*/
|
|
57
|
+
import type { Snippet } from 'svelte';
|
|
58
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
59
|
+
import { applyAxes, cx, type AxisProps } from '../variants.js';
|
|
60
|
+
|
|
61
|
+
interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, Omit<HTMLAttributes<HTMLElement>, 'color'> {
|
|
62
|
+
steps: Step[];
|
|
63
|
+
/** The id of the current leaf (a sub-step, or a step without any). */
|
|
64
|
+
current?: Step['id'];
|
|
65
|
+
/** The id of the first leaf never reached. */
|
|
66
|
+
explored?: Step['id'];
|
|
67
|
+
/** Reached steps answer clicks. */
|
|
68
|
+
clickable?: boolean;
|
|
69
|
+
disabled?: boolean;
|
|
70
|
+
/** A reached step was clicked: a leaf, or the first leaf of a step. */
|
|
71
|
+
onStep?: (step: Step) => void;
|
|
72
|
+
/** The line above the bars in compact mode. Defaults to "label · sub-label n/total". */
|
|
73
|
+
heading?: Snippet<[{ step: Step | undefined; parent: Step | undefined; index: number; total: number }]>;
|
|
74
|
+
/** The nav's accessible name. */
|
|
75
|
+
label?: string;
|
|
76
|
+
class?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// The axes are deliberately NOT destructured: they travel in `axes` and are
|
|
80
|
+
// resolved by name, so an axis a family drops changes nothing down here.
|
|
81
|
+
let {
|
|
82
|
+
steps,
|
|
83
|
+
current,
|
|
84
|
+
explored,
|
|
85
|
+
clickable = true,
|
|
86
|
+
disabled = false,
|
|
87
|
+
onStep,
|
|
88
|
+
heading,
|
|
89
|
+
label = 'Progress',
|
|
90
|
+
class: klass = '',
|
|
91
|
+
...axes
|
|
92
|
+
}: Props = $props();
|
|
93
|
+
|
|
94
|
+
let applied = $derived(applyAxes(PREFIX, AXES, FLAGS, axes));
|
|
95
|
+
let classes = $derived(cx(PREFIX, applied.classes, klass));
|
|
96
|
+
/* Read back from the classes, the one place the axes are resolved. */
|
|
97
|
+
let condensed = $derived(classes.includes(`${PREFIX}-compact`));
|
|
98
|
+
|
|
99
|
+
const leavesOf = (s: Step) => (s.steps?.length ? s.steps : [s]);
|
|
100
|
+
let leaves = $derived(steps.flatMap(leavesOf));
|
|
101
|
+
let currentAt = $derived(leaves.findIndex((l) => l.id === current));
|
|
102
|
+
let exploredAt = $derived.by(() => {
|
|
103
|
+
const i = explored === undefined ? -1 : leaves.findIndex((l) => l.id === explored);
|
|
104
|
+
return i >= 0 ? i : currentAt + 1;
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
function leafState(leaf: Step): StepState {
|
|
108
|
+
if (leaf.id === current) return 'current';
|
|
109
|
+
if (leaf.complete) return 'complete';
|
|
110
|
+
return leaves.indexOf(leaf) < exploredAt ? 'visited' : 'unknown';
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function stepState(step: Step): StepState {
|
|
114
|
+
const states = leavesOf(step).map(leafState);
|
|
115
|
+
if (states.includes('current')) return 'current';
|
|
116
|
+
if (states.every((s) => s === 'complete')) return 'complete';
|
|
117
|
+
return states.some((s) => s !== 'unknown') ? 'visited' : 'unknown';
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The issue a reached leaf carries. */
|
|
121
|
+
const issueOf = (leaf: Step, state: StepState) =>
|
|
122
|
+
state === 'unknown' ? undefined : leaf.error ? 'error' : leaf.warning ? 'warning' : undefined;
|
|
123
|
+
|
|
124
|
+
const reachable = (state: StepState) => clickable && !disabled && state !== 'unknown';
|
|
125
|
+
|
|
126
|
+
let currentParent = $derived(steps.find((s) => leavesOf(s).some((l) => l.id === current)));
|
|
127
|
+
let currentLeaf = $derived(leaves[currentAt]);
|
|
128
|
+
</script>
|
|
129
|
+
|
|
130
|
+
{#snippet issueIcon(kind: 'error' | 'warning', text: string)}
|
|
131
|
+
<span class="steps-issue" data-issue={kind} title={text} role="img" aria-label={text}>
|
|
132
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
|
133
|
+
<path d="M12 3 2 20h20L12 3Z" /><path d="M12 10v4M12 17h.01" />
|
|
134
|
+
</svg>
|
|
135
|
+
</span>
|
|
136
|
+
{/snippet}
|
|
137
|
+
|
|
138
|
+
<nav {...applied.rest} class={classes} aria-label={label}>
|
|
139
|
+
{#if condensed}
|
|
140
|
+
<div class="steps-heading">
|
|
141
|
+
{#if heading}
|
|
142
|
+
{@render heading({ step: currentLeaf, parent: currentParent, index: steps.indexOf(currentParent!) + 1, total: steps.length })}
|
|
143
|
+
{:else}
|
|
144
|
+
<span>
|
|
145
|
+
{currentParent?.label ?? ''}{#if currentParent && currentLeaf && currentLeaf !== currentParent && currentLeaf.label}{' · '}{currentLeaf.label}{/if}
|
|
146
|
+
</span>
|
|
147
|
+
<span>{steps.indexOf(currentParent!) + 1}/{steps.length}</span>
|
|
148
|
+
{/if}
|
|
149
|
+
</div>
|
|
150
|
+
{/if}
|
|
151
|
+
<ol class="steps-list">
|
|
152
|
+
{#each steps as step, n (step.id)}
|
|
153
|
+
{@const state = stepState(step)}
|
|
154
|
+
{@const own = leavesOf(step)}
|
|
155
|
+
{@const issues = own
|
|
156
|
+
.map((l) => ({ kind: issueOf(l, leafState(l)), text: l.error ?? l.warning ?? '' }))
|
|
157
|
+
.filter((i) => i.kind)}
|
|
158
|
+
<li class="steps-item" data-state={state}>
|
|
159
|
+
<div class="steps-track">
|
|
160
|
+
{#if !condensed}
|
|
161
|
+
<button
|
|
162
|
+
type="button"
|
|
163
|
+
class="steps-marker"
|
|
164
|
+
aria-label={step.label ?? `${n + 1}`}
|
|
165
|
+
disabled={!reachable(state)}
|
|
166
|
+
onclick={() => onStep?.(own[0]!)}
|
|
167
|
+
>
|
|
168
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="m5 12.5 4.5 4.5L19 7.5" /></svg>
|
|
169
|
+
</button>
|
|
170
|
+
{/if}
|
|
171
|
+
{#each own as leaf, i (leaf.id)}
|
|
172
|
+
{@const ls = leafState(leaf)}
|
|
173
|
+
<button
|
|
174
|
+
type="button"
|
|
175
|
+
class="steps-segment"
|
|
176
|
+
data-state={ls}
|
|
177
|
+
data-issue={issueOf(leaf, ls)}
|
|
178
|
+
title={(issueOf(leaf, ls) && (leaf.error ?? leaf.warning)) || leaf.label}
|
|
179
|
+
aria-label={leaf.label ?? `${n + 1}${own.length > 1 ? `.${i + 1}` : ''}`}
|
|
180
|
+
aria-current={ls === 'current' ? 'step' : undefined}
|
|
181
|
+
disabled={!reachable(ls)}
|
|
182
|
+
onclick={() => onStep?.(leaf)}
|
|
183
|
+
>
|
|
184
|
+
<span></span>
|
|
185
|
+
</button>
|
|
186
|
+
{/each}
|
|
187
|
+
</div>
|
|
188
|
+
{#if !condensed && (step.label || issues.length)}
|
|
189
|
+
<p class="steps-label">
|
|
190
|
+
{#if step.label}<span>{step.label}</span>{/if}
|
|
191
|
+
{#if issues.some((i) => i.kind === 'error')}
|
|
192
|
+
{@render issueIcon('error', issues.filter((i) => i.kind === 'error').map((i) => i.text).join('\n'))}
|
|
193
|
+
{:else if issues.length}
|
|
194
|
+
{@render issueIcon('warning', issues.map((i) => i.text).join('\n'))}
|
|
195
|
+
{/if}
|
|
196
|
+
</p>
|
|
197
|
+
{/if}
|
|
198
|
+
{#if !condensed && state === 'current' && own.length > 1 && currentLeaf?.label}
|
|
199
|
+
<p class="steps-sublabel">{currentLeaf.label}</p>
|
|
200
|
+
{/if}
|
|
201
|
+
</li>
|
|
202
|
+
{/each}
|
|
203
|
+
</ol>
|
|
204
|
+
</nav>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** What .steps is made of, classified. The props follow the
|
|
2
|
+
families the project registers (variants.ts, ADR 0015). */
|
|
3
|
+
export declare const PREFIX = "steps";
|
|
4
|
+
export declare const AXES: {
|
|
5
|
+
readonly direction: readonly ["horizontal", "vertical"];
|
|
6
|
+
readonly color: readonly ["primary", "secondary", "accent", "neutral", "info", "success", "warning", "error"];
|
|
7
|
+
readonly size: readonly ["xs", "sm", "md", "lg", "xl"];
|
|
8
|
+
};
|
|
9
|
+
export declare const FLAGS: {
|
|
10
|
+
readonly compact: "No markers nor labels: the bars, and a heading above them (small screens).";
|
|
11
|
+
};
|
|
12
|
+
export declare const PARTS: readonly ["heading", "list", "item", "track", "marker", "segment", "label", "issue", "sublabel"];
|
|
13
|
+
/** A stage of the journey. Its sub-steps go one level deep, no further. */
|
|
14
|
+
export interface Step {
|
|
15
|
+
id: string | number;
|
|
16
|
+
label?: string;
|
|
17
|
+
/** The sub-steps. A step without any is a stage of its own. */
|
|
18
|
+
steps?: Step[];
|
|
19
|
+
/** Declared done by the app. Visiting a step does not complete it. */
|
|
20
|
+
complete?: boolean;
|
|
21
|
+
/** Shown once the step has been reached. */
|
|
22
|
+
error?: string;
|
|
23
|
+
warning?: string;
|
|
24
|
+
}
|
|
25
|
+
/** current · visited (reached before) · complete (declared) · unknown (not reached). */
|
|
26
|
+
export type StepState = 'current' | 'visited' | 'complete' | 'unknown';
|
|
27
|
+
/**
|
|
28
|
+
* Where the user is in a journey: one column per step, one bar per sub-step.
|
|
29
|
+
*
|
|
30
|
+
* The component moves nothing: a click calls `onStep` with the step, and
|
|
31
|
+
* the app decides whether to change `current`. A step is clickable once it
|
|
32
|
+
* has been reached (current, visited or complete) — a step's own marker
|
|
33
|
+
* leads to its first sub-step. `clickable={false}` or `disabled` turns that
|
|
34
|
+
* off.
|
|
35
|
+
*
|
|
36
|
+
* `explored` is the first leaf never reached; every leaf before it counts
|
|
37
|
+
* as visited. Without it, everything up to `current` does.
|
|
38
|
+
*/
|
|
39
|
+
import type { Snippet } from 'svelte';
|
|
40
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
41
|
+
import { type AxisProps } from '../variants.js';
|
|
42
|
+
interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, Omit<HTMLAttributes<HTMLElement>, 'color'> {
|
|
43
|
+
steps: Step[];
|
|
44
|
+
/** The id of the current leaf (a sub-step, or a step without any). */
|
|
45
|
+
current?: Step['id'];
|
|
46
|
+
/** The id of the first leaf never reached. */
|
|
47
|
+
explored?: Step['id'];
|
|
48
|
+
/** Reached steps answer clicks. */
|
|
49
|
+
clickable?: boolean;
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
/** A reached step was clicked: a leaf, or the first leaf of a step. */
|
|
52
|
+
onStep?: (step: Step) => void;
|
|
53
|
+
/** The line above the bars in compact mode. Defaults to "label · sub-label n/total". */
|
|
54
|
+
heading?: Snippet<[{
|
|
55
|
+
step: Step | undefined;
|
|
56
|
+
parent: Step | undefined;
|
|
57
|
+
index: number;
|
|
58
|
+
total: number;
|
|
59
|
+
}]>;
|
|
60
|
+
/** The nav's accessible name. */
|
|
61
|
+
label?: string;
|
|
62
|
+
class?: string;
|
|
63
|
+
}
|
|
64
|
+
declare const Steps: import("svelte").Component<Props, {}, "">;
|
|
65
|
+
type Steps = ReturnType<typeof Steps>;
|
|
66
|
+
export default Steps;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
/** What .subtitle is made of, classified. */
|
|
3
|
+
export const PREFIX = 'subtitle';
|
|
4
|
+
|
|
5
|
+
/* Two sizes, and they are the class suffix under a friendlier name: the
|
|
6
|
+
map form of an axis exists for exactly this (see variants.ts). */
|
|
7
|
+
export const AXES = {
|
|
8
|
+
s: ['1', '2'],
|
|
9
|
+
color: ['primary', 'secondary', 'accent', 'neutral', 'info', 'success', 'warning', 'error']
|
|
10
|
+
} as const;
|
|
11
|
+
|
|
12
|
+
export const FLAGS = {} as const;
|
|
13
|
+
export const PARTS = [] as const;
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<script lang="ts">
|
|
17
|
+
/**
|
|
18
|
+
* A heading under the title.
|
|
19
|
+
*
|
|
20
|
+
* `s` is the look, `level` is the tag. They are independent on purpose —
|
|
21
|
+
* see Title.svelte.
|
|
22
|
+
*/
|
|
23
|
+
import type { Snippet } from 'svelte';
|
|
24
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
25
|
+
import { applyAxes, cx, type AxisProps } from '../variants.js';
|
|
26
|
+
|
|
27
|
+
interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, Omit<HTMLAttributes<HTMLHeadingElement>, 'color'> {
|
|
28
|
+
/** Which heading tag to render. Purely semantic; the look never moves. */
|
|
29
|
+
level?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
30
|
+
class?: string;
|
|
31
|
+
children?: Snippet;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* `s` is defaulted here rather than left out, because `.subtitle` alone is
|
|
35
|
+
not a class — the size IS the base class. */
|
|
36
|
+
let { level = 2, s = '1', class: klass = '', children, ...axes }: Props = $props();
|
|
37
|
+
|
|
38
|
+
let applied = $derived(applyAxes(PREFIX, AXES, FLAGS, { ...axes, s }));
|
|
39
|
+
let classes = $derived(cx(applied.classes, klass));
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<svelte:element this={`h${level}`} class={classes} {...applied.rest}>
|
|
43
|
+
{@render children?.()}
|
|
44
|
+
</svelte:element>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** What .subtitle is made of, classified. */
|
|
2
|
+
export declare const PREFIX = "subtitle";
|
|
3
|
+
export declare const AXES: {
|
|
4
|
+
readonly s: readonly ["1", "2"];
|
|
5
|
+
readonly color: readonly ["primary", "secondary", "accent", "neutral", "info", "success", "warning", "error"];
|
|
6
|
+
};
|
|
7
|
+
export declare const FLAGS: {};
|
|
8
|
+
export declare const PARTS: readonly [];
|
|
9
|
+
/**
|
|
10
|
+
* A heading under the title.
|
|
11
|
+
*
|
|
12
|
+
* `s` is the look, `level` is the tag. They are independent on purpose —
|
|
13
|
+
* see Title.svelte.
|
|
14
|
+
*/
|
|
15
|
+
import type { Snippet } from 'svelte';
|
|
16
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
17
|
+
import { type AxisProps } from '../variants.js';
|
|
18
|
+
interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, Omit<HTMLAttributes<HTMLHeadingElement>, 'color'> {
|
|
19
|
+
/** Which heading tag to render. Purely semantic; the look never moves. */
|
|
20
|
+
level?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
21
|
+
class?: string;
|
|
22
|
+
children?: Snippet;
|
|
23
|
+
}
|
|
24
|
+
declare const Subtitle: import("svelte").Component<Props, {}, "">;
|
|
25
|
+
type Subtitle = ReturnType<typeof Subtitle>;
|
|
26
|
+
export default Subtitle;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
/** What .swatch is made of, classified. The props follow the
|
|
3
|
+
families the project registers (variants.ts, ADR 0015). */
|
|
4
|
+
export const PREFIX = 'swatch';
|
|
5
|
+
|
|
6
|
+
export const AXES = {
|
|
7
|
+
color: ['primary', 'secondary', 'accent', 'neutral', 'info', 'success', 'warning', 'error'],
|
|
8
|
+
size: ['xs', 'sm', 'md', 'lg', 'xl'],
|
|
9
|
+
shape: ['circle']
|
|
10
|
+
} as const;
|
|
11
|
+
|
|
12
|
+
export const FLAGS = {
|
|
13
|
+
active: 'Mark it as the chosen one.'
|
|
14
|
+
} as const;
|
|
15
|
+
export const PARTS = ['disabled'] as const;
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<script lang="ts">
|
|
19
|
+
import type { Snippet } from 'svelte';
|
|
20
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
21
|
+
import { applyAxes, cx, type AxisProps } from '../variants.js';
|
|
22
|
+
|
|
23
|
+
interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, Omit<HTMLAttributes<HTMLSpanElement>, 'color'> {
|
|
24
|
+
/** The colour to show. It is DATA, not a theme value, so it is written
|
|
25
|
+
here at the call site and never by the family. */
|
|
26
|
+
sample?: string;
|
|
27
|
+
/** Grey it out. `.swatch` may be a span, which cannot carry `disabled`. */
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
class?: string;
|
|
30
|
+
children?: Snippet;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// The axes are deliberately NOT destructured: they travel in `axes` and are
|
|
34
|
+
// resolved by name, so an axis a family drops changes nothing down here.
|
|
35
|
+
let {
|
|
36
|
+
sample,
|
|
37
|
+
disabled = false,
|
|
38
|
+
class: klass = '',
|
|
39
|
+
children,
|
|
40
|
+
...axes
|
|
41
|
+
}: Props = $props();
|
|
42
|
+
|
|
43
|
+
let applied = $derived(applyAxes(PREFIX, AXES, FLAGS, axes));
|
|
44
|
+
let classes = $derived(
|
|
45
|
+
cx(
|
|
46
|
+
PREFIX,
|
|
47
|
+
applied.classes,
|
|
48
|
+
disabled && `${PREFIX}-disabled`,
|
|
49
|
+
klass
|
|
50
|
+
)
|
|
51
|
+
);
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<span
|
|
55
|
+
{...applied.rest}
|
|
56
|
+
class={classes}
|
|
57
|
+
style:--swatch-color={sample}
|
|
58
|
+
aria-disabled={disabled ? 'true' : undefined}
|
|
59
|
+
>
|
|
60
|
+
{@render children?.()}
|
|
61
|
+
</span>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** What .swatch is made of, classified. The props follow the
|
|
2
|
+
families the project registers (variants.ts, ADR 0015). */
|
|
3
|
+
export declare const PREFIX = "swatch";
|
|
4
|
+
export declare const AXES: {
|
|
5
|
+
readonly color: readonly ["primary", "secondary", "accent", "neutral", "info", "success", "warning", "error"];
|
|
6
|
+
readonly size: readonly ["xs", "sm", "md", "lg", "xl"];
|
|
7
|
+
readonly shape: readonly ["circle"];
|
|
8
|
+
};
|
|
9
|
+
export declare const FLAGS: {
|
|
10
|
+
readonly active: "Mark it as the chosen one.";
|
|
11
|
+
};
|
|
12
|
+
export declare const PARTS: readonly ["disabled"];
|
|
13
|
+
import type { Snippet } from 'svelte';
|
|
14
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
15
|
+
import { type AxisProps } from '../variants.js';
|
|
16
|
+
interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, Omit<HTMLAttributes<HTMLSpanElement>, 'color'> {
|
|
17
|
+
/** The colour to show. It is DATA, not a theme value, so it is written
|
|
18
|
+
here at the call site and never by the family. */
|
|
19
|
+
sample?: string;
|
|
20
|
+
/** Grey it out. `.swatch` may be a span, which cannot carry `disabled`. */
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
class?: string;
|
|
23
|
+
children?: Snippet;
|
|
24
|
+
}
|
|
25
|
+
declare const Swatch: import("svelte").Component<Props, {}, "">;
|
|
26
|
+
type Swatch = ReturnType<typeof Swatch>;
|
|
27
|
+
export default Swatch;
|