@sveltier/ui 0.0.0-stage → 0.1.0-alpha.1
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 +82 -2
- package/dist/components/Accordion/Accordion.svelte +74 -0
- package/dist/components/Accordion/Accordion.svelte.d.ts +25 -0
- package/dist/components/Accordion/accordion.css +88 -0
- package/dist/components/Accordion/index.d.ts +2 -0
- package/dist/components/Accordion/index.js +1 -0
- package/dist/components/Accordion/types.d.ts +64 -0
- package/dist/components/Accordion/types.js +1 -0
- package/dist/components/Alert/Alert.svelte +88 -0
- package/dist/components/Alert/Alert.svelte.d.ts +4 -0
- package/dist/components/Alert/alert.css +78 -0
- package/dist/components/Alert/index.d.ts +2 -0
- package/dist/components/Alert/index.js +1 -0
- package/dist/components/Alert/types.d.ts +67 -0
- package/dist/components/Alert/types.js +1 -0
- package/dist/components/Avatar/Avatar.svelte +47 -0
- package/dist/components/Avatar/Avatar.svelte.d.ts +4 -0
- package/dist/components/Avatar/avatar.css +34 -0
- package/dist/components/Avatar/index.d.ts +2 -0
- package/dist/components/Avatar/index.js +1 -0
- package/dist/components/Avatar/types.d.ts +47 -0
- package/dist/components/Avatar/types.js +1 -0
- package/dist/components/Badge/Badge.svelte +53 -0
- package/dist/components/Badge/Badge.svelte.d.ts +4 -0
- package/dist/components/Badge/badge.css +57 -0
- package/dist/components/Badge/index.d.ts +2 -0
- package/dist/components/Badge/index.js +1 -0
- package/dist/components/Badge/types.d.ts +43 -0
- package/dist/components/Badge/types.js +1 -0
- package/dist/components/Button/Button.svelte +85 -0
- package/dist/components/Button/Button.svelte.d.ts +4 -0
- package/dist/components/Button/button.css +132 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/Button/index.js +1 -0
- package/dist/components/Button/types.d.ts +76 -0
- package/dist/components/Button/types.js +1 -0
- package/dist/components/ButtonGroup/ButtonGroup.svelte +61 -0
- package/dist/components/ButtonGroup/ButtonGroup.svelte.d.ts +4 -0
- package/dist/components/ButtonGroup/button-group.css +39 -0
- package/dist/components/ButtonGroup/index.d.ts +2 -0
- package/dist/components/ButtonGroup/index.js +1 -0
- package/dist/components/ButtonGroup/types.d.ts +48 -0
- package/dist/components/ButtonGroup/types.js +1 -0
- package/dist/components/Card/Card.svelte +53 -0
- package/dist/components/Card/Card.svelte.d.ts +4 -0
- package/dist/components/Card/card.css +62 -0
- package/dist/components/Card/index.d.ts +2 -0
- package/dist/components/Card/index.js +1 -0
- package/dist/components/Card/types.d.ts +56 -0
- package/dist/components/Card/types.js +1 -0
- package/dist/components/Checkbox/Checkbox.svelte +105 -0
- package/dist/components/Checkbox/Checkbox.svelte.d.ts +4 -0
- package/dist/components/Checkbox/checkbox.css +138 -0
- package/dist/components/Checkbox/index.d.ts +2 -0
- package/dist/components/Checkbox/index.js +1 -0
- package/dist/components/Checkbox/types.d.ts +76 -0
- package/dist/components/Checkbox/types.js +1 -0
- package/dist/components/Chip/Chip.svelte +109 -0
- package/dist/components/Chip/Chip.svelte.d.ts +4 -0
- package/dist/components/Chip/chip.css +101 -0
- package/dist/components/Chip/index.d.ts +2 -0
- package/dist/components/Chip/index.js +1 -0
- package/dist/components/Chip/types.d.ts +69 -0
- package/dist/components/Chip/types.js +1 -0
- package/dist/components/Choice/Choice.svelte +60 -0
- package/dist/components/Choice/Choice.svelte.d.ts +4 -0
- package/dist/components/Choice/choice.css +75 -0
- package/dist/components/Choice/types.d.ts +43 -0
- package/dist/components/Choice/types.js +1 -0
- package/dist/components/Dialog/Dialog.svelte +36 -0
- package/dist/components/Dialog/Dialog.svelte.d.ts +4 -0
- package/dist/components/Dialog/index.d.ts +2 -0
- package/dist/components/Dialog/index.js +1 -0
- package/dist/components/Dialog/types.d.ts +50 -0
- package/dist/components/Dialog/types.js +1 -0
- package/dist/components/Divider/Divider.svelte +19 -0
- package/dist/components/Divider/Divider.svelte.d.ts +4 -0
- package/dist/components/Divider/divider.css +23 -0
- package/dist/components/Divider/index.d.ts +2 -0
- package/dist/components/Divider/index.js +1 -0
- package/dist/components/Divider/types.d.ts +10 -0
- package/dist/components/Divider/types.js +1 -0
- package/dist/components/Field/Field.svelte +95 -0
- package/dist/components/Field/Field.svelte.d.ts +4 -0
- package/dist/components/Field/field.css +210 -0
- package/dist/components/Field/index.d.ts +3 -0
- package/dist/components/Field/index.js +2 -0
- package/dist/components/Field/types.d.ts +109 -0
- package/dist/components/Field/types.js +2 -0
- package/dist/components/Form/Form.svelte +93 -0
- package/dist/components/Form/Form.svelte.d.ts +8 -0
- package/dist/components/Form/form.css +16 -0
- package/dist/components/Form/index.d.ts +2 -0
- package/dist/components/Form/index.js +1 -0
- package/dist/components/Form/types.d.ts +38 -0
- package/dist/components/Form/types.js +1 -0
- package/dist/components/Icon/Icon.svelte +38 -0
- package/dist/components/Icon/Icon.svelte.d.ts +4 -0
- package/dist/components/Icon/icon.css +33 -0
- package/dist/components/Icon/index.d.ts +2 -0
- package/dist/components/Icon/index.js +1 -0
- package/dist/components/Icon/types.d.ts +34 -0
- package/dist/components/Icon/types.js +1 -0
- package/dist/components/List/List.svelte +39 -0
- package/dist/components/List/List.svelte.d.ts +4 -0
- package/dist/components/List/ListItem.svelte +57 -0
- package/dist/components/List/ListItem.svelte.d.ts +4 -0
- package/dist/components/List/index.d.ts +3 -0
- package/dist/components/List/index.js +2 -0
- package/dist/components/List/list.css +127 -0
- package/dist/components/List/types.d.ts +67 -0
- package/dist/components/List/types.js +1 -0
- package/dist/components/Menu/Menu.svelte +195 -0
- package/dist/components/Menu/Menu.svelte.d.ts +4 -0
- package/dist/components/Menu/index.d.ts +2 -0
- package/dist/components/Menu/index.js +1 -0
- package/dist/components/Menu/menu.css +103 -0
- package/dist/components/Menu/types.d.ts +90 -0
- package/dist/components/Menu/types.js +1 -0
- package/dist/components/Modal/Modal.svelte +146 -0
- package/dist/components/Modal/Modal.svelte.d.ts +4 -0
- package/dist/components/Modal/modal.css +150 -0
- package/dist/components/Modal/types.d.ts +54 -0
- package/dist/components/Modal/types.js +1 -0
- package/dist/components/NativeSelect/NativeSelect.svelte +110 -0
- package/dist/components/NativeSelect/NativeSelect.svelte.d.ts +25 -0
- package/dist/components/NativeSelect/index.d.ts +2 -0
- package/dist/components/NativeSelect/index.js +1 -0
- package/dist/components/NativeSelect/native-select.css +45 -0
- package/dist/components/NativeSelect/types.d.ts +58 -0
- package/dist/components/NativeSelect/types.js +1 -0
- package/dist/components/NumberField/NumberField.svelte +246 -0
- package/dist/components/NumberField/NumberField.svelte.d.ts +4 -0
- package/dist/components/NumberField/index.d.ts +2 -0
- package/dist/components/NumberField/index.js +1 -0
- package/dist/components/NumberField/number-field.css +74 -0
- package/dist/components/NumberField/types.d.ts +73 -0
- package/dist/components/NumberField/types.js +1 -0
- package/dist/components/Popover/Popover.svelte +115 -0
- package/dist/components/Popover/Popover.svelte.d.ts +4 -0
- package/dist/components/Popover/index.d.ts +2 -0
- package/dist/components/Popover/index.js +1 -0
- package/dist/components/Popover/popover.css +67 -0
- package/dist/components/Popover/types.d.ts +83 -0
- package/dist/components/Popover/types.js +1 -0
- package/dist/components/Progress/ProgressCircular.svelte +61 -0
- package/dist/components/Progress/ProgressCircular.svelte.d.ts +4 -0
- package/dist/components/Progress/ProgressLinear.svelte +44 -0
- package/dist/components/Progress/ProgressLinear.svelte.d.ts +4 -0
- package/dist/components/Progress/index.d.ts +3 -0
- package/dist/components/Progress/index.js +2 -0
- package/dist/components/Progress/progress-circular.css +61 -0
- package/dist/components/Progress/progress-linear.css +67 -0
- package/dist/components/Progress/types.d.ts +53 -0
- package/dist/components/Progress/types.js +1 -0
- package/dist/components/RadioGroup/RadioGroup.svelte +149 -0
- package/dist/components/RadioGroup/RadioGroup.svelte.d.ts +25 -0
- package/dist/components/RadioGroup/index.d.ts +2 -0
- package/dist/components/RadioGroup/index.js +1 -0
- package/dist/components/RadioGroup/radio-group.css +139 -0
- package/dist/components/RadioGroup/types.d.ts +93 -0
- package/dist/components/RadioGroup/types.js +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.svelte +70 -0
- package/dist/components/SegmentedControl/SegmentedControl.svelte.d.ts +25 -0
- package/dist/components/SegmentedControl/index.d.ts +2 -0
- package/dist/components/SegmentedControl/index.js +1 -0
- package/dist/components/SegmentedControl/segmented-control.css +68 -0
- package/dist/components/SegmentedControl/types.d.ts +60 -0
- package/dist/components/SegmentedControl/types.js +1 -0
- package/dist/components/Sheet/Sheet.svelte +56 -0
- package/dist/components/Sheet/Sheet.svelte.d.ts +4 -0
- package/dist/components/Sheet/index.d.ts +2 -0
- package/dist/components/Sheet/index.js +2 -0
- package/dist/components/Sheet/sheet.css +61 -0
- package/dist/components/Sheet/types.d.ts +51 -0
- package/dist/components/Sheet/types.js +1 -0
- package/dist/components/Skeleton/Skeleton.svelte +33 -0
- package/dist/components/Skeleton/Skeleton.svelte.d.ts +4 -0
- package/dist/components/Skeleton/index.d.ts +2 -0
- package/dist/components/Skeleton/index.js +1 -0
- package/dist/components/Skeleton/skeleton.css +70 -0
- package/dist/components/Skeleton/types.d.ts +25 -0
- package/dist/components/Skeleton/types.js +1 -0
- package/dist/components/Slider/Slider.svelte +153 -0
- package/dist/components/Slider/Slider.svelte.d.ts +4 -0
- package/dist/components/Slider/index.d.ts +2 -0
- package/dist/components/Slider/index.js +1 -0
- package/dist/components/Slider/slider.css +206 -0
- package/dist/components/Slider/types.d.ts +102 -0
- package/dist/components/Slider/types.js +1 -0
- package/dist/components/Switch/Switch.svelte +94 -0
- package/dist/components/Switch/Switch.svelte.d.ts +4 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/Switch/index.js +1 -0
- package/dist/components/Switch/switch.css +118 -0
- package/dist/components/Switch/types.d.ts +67 -0
- package/dist/components/Switch/types.js +1 -0
- package/dist/components/Tabs/Tabs.svelte +93 -0
- package/dist/components/Tabs/Tabs.svelte.d.ts +25 -0
- package/dist/components/Tabs/index.d.ts +2 -0
- package/dist/components/Tabs/index.js +1 -0
- package/dist/components/Tabs/tabs.css +73 -0
- package/dist/components/Tabs/types.d.ts +59 -0
- package/dist/components/Tabs/types.js +1 -0
- package/dist/components/TextField/TextField.svelte +115 -0
- package/dist/components/TextField/TextField.svelte.d.ts +4 -0
- package/dist/components/TextField/index.d.ts +2 -0
- package/dist/components/TextField/index.js +1 -0
- package/dist/components/TextField/types.d.ts +57 -0
- package/dist/components/TextField/types.js +1 -0
- package/dist/components/Textarea/Textarea.svelte +116 -0
- package/dist/components/Textarea/Textarea.svelte.d.ts +4 -0
- package/dist/components/Textarea/index.d.ts +2 -0
- package/dist/components/Textarea/index.js +1 -0
- package/dist/components/Textarea/textarea.css +35 -0
- package/dist/components/Textarea/types.d.ts +60 -0
- package/dist/components/Textarea/types.js +1 -0
- package/dist/components/Tooltip/Tooltip.svelte +161 -0
- package/dist/components/Tooltip/Tooltip.svelte.d.ts +4 -0
- package/dist/components/Tooltip/index.d.ts +2 -0
- package/dist/components/Tooltip/index.js +1 -0
- package/dist/components/Tooltip/tooltip.css +44 -0
- package/dist/components/Tooltip/types.d.ts +55 -0
- package/dist/components/Tooltip/types.js +1 -0
- package/dist/core/defaults/DefaultsProvider.svelte +30 -0
- package/dist/core/defaults/DefaultsProvider.svelte.d.ts +13 -0
- package/dist/core/defaults/context.d.ts +45 -0
- package/dist/core/defaults/context.js +38 -0
- package/dist/core/display/display.d.ts +39 -0
- package/dist/core/display/display.js +53 -0
- package/dist/core/errors/codes.d.ts +124 -0
- package/dist/core/errors/codes.js +108 -0
- package/dist/core/errors/errors.d.ts +8 -0
- package/dist/core/errors/errors.js +7 -0
- package/dist/core/form/constraints.d.ts +15 -0
- package/dist/core/form/constraints.js +42 -0
- package/dist/core/form/context.d.ts +19 -0
- package/dist/core/form/context.js +4 -0
- package/dist/core/form/field.svelte.d.ts +34 -0
- package/dist/core/form/field.svelte.js +66 -0
- package/dist/core/form/number.d.ts +24 -0
- package/dist/core/form/number.js +71 -0
- package/dist/core/form/types.d.ts +22 -0
- package/dist/core/form/types.js +1 -0
- package/dist/core/locale/locale.d.ts +56 -0
- package/dist/core/locale/locale.js +82 -0
- package/dist/core/overlay/types.d.ts +33 -0
- package/dist/core/overlay/types.js +1 -0
- package/dist/core/props/classes.d.ts +21 -0
- package/dist/core/props/classes.js +44 -0
- package/dist/core/props/element.d.ts +18 -0
- package/dist/core/props/element.js +1 -0
- package/dist/core/props/types.d.ts +47 -0
- package/dist/core/props/types.js +16 -0
- package/dist/core/provider/UIProvider.svelte +63 -0
- package/dist/core/provider/UIProvider.svelte.d.ts +29 -0
- package/dist/core/theme/ThemeProvider.svelte +178 -0
- package/dist/core/theme/ThemeProvider.svelte.d.ts +25 -0
- package/dist/core/theme/color.d.ts +23 -0
- package/dist/core/theme/color.js +54 -0
- package/dist/core/theme/context.d.ts +25 -0
- package/dist/core/theme/context.js +14 -0
- package/dist/core/theme/css.d.ts +25 -0
- package/dist/core/theme/css.js +73 -0
- package/dist/core/theme/define.d.ts +11 -0
- package/dist/core/theme/define.js +21 -0
- package/dist/core/theme/resolve.d.ts +6 -0
- package/dist/core/theme/resolve.js +18 -0
- package/dist/core/theme/theme-provider.css +13 -0
- package/dist/core/theme/types.d.ts +35 -0
- package/dist/core/theme/types.js +61 -0
- package/dist/core/toast/ToastOutlet.svelte +192 -0
- package/dist/core/toast/ToastOutlet.svelte.d.ts +11 -0
- package/dist/core/toast/ToastProvider.svelte +39 -0
- package/dist/core/toast/ToastProvider.svelte.d.ts +19 -0
- package/dist/core/toast/toast.css +134 -0
- package/dist/core/toast/toast.svelte.d.ts +117 -0
- package/dist/core/toast/toast.svelte.js +133 -0
- package/dist/dev/off.d.ts +5 -0
- package/dist/dev/off.js +4 -0
- package/dist/dev/on.d.ts +20 -0
- package/dist/dev/on.js +49 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +83 -0
- package/dist/primitives/anchored/anchored.d.ts +39 -0
- package/dist/primitives/anchored/anchored.js +104 -0
- package/dist/primitives/anchored/fallback.d.ts +31 -0
- package/dist/primitives/anchored/fallback.js +73 -0
- package/dist/primitives/focus/focus-trap.d.ts +25 -0
- package/dist/primitives/focus/focus-trap.js +86 -0
- package/dist/primitives/focus/roving-focus.d.ts +22 -0
- package/dist/primitives/focus/roving-focus.js +86 -0
- package/dist/primitives/focus/tabbable.d.ts +9 -0
- package/dist/primitives/focus/tabbable.js +75 -0
- package/dist/primitives/inert/inert-others.d.ts +12 -0
- package/dist/primitives/inert/inert-others.js +44 -0
- package/dist/primitives/keyboard/keymap.d.ts +17 -0
- package/dist/primitives/keyboard/keymap.js +39 -0
- package/dist/primitives/keyboard/typeahead.d.ts +18 -0
- package/dist/primitives/keyboard/typeahead.js +50 -0
- package/dist/primitives/layer/dismissable.d.ts +32 -0
- package/dist/primitives/layer/dismissable.js +91 -0
- package/dist/primitives/motion/easing.d.ts +9 -0
- package/dist/primitives/motion/easing.js +46 -0
- package/dist/primitives/motion/motion.d.ts +59 -0
- package/dist/primitives/motion/motion.js +80 -0
- package/dist/primitives/portal/Portal.svelte +37 -0
- package/dist/primitives/portal/Portal.svelte.d.ts +9 -0
- package/dist/primitives/portal/PortalContent.svelte +15 -0
- package/dist/primitives/portal/PortalContent.svelte.d.ts +9 -0
- package/dist/primitives/portal/portal.css +8 -0
- package/dist/primitives/scroll-lock/scroll-lock.d.ts +10 -0
- package/dist/primitives/scroll-lock/scroll-lock.js +33 -0
- package/dist/primitives/virtual/virtual-list.svelte.d.ts +65 -0
- package/dist/primitives/virtual/virtual-list.svelte.js +291 -0
- package/dist/styles/base.css +44 -0
- package/dist/styles/props.css +140 -0
- package/dist/styles/tokens.css +84 -0
- package/dist/styles/visually-hidden.css +16 -0
- package/dist/themes/aurora.d.ts +13 -0
- package/dist/themes/aurora.js +103 -0
- package/dist/themes/heritage.d.ts +13 -0
- package/dist/themes/heritage.js +102 -0
- package/dist/themes/maison.d.ts +13 -0
- package/dist/themes/maison.js +99 -0
- package/dist/themes/milano.d.ts +13 -0
- package/dist/themes/milano.js +101 -0
- package/dist/themes/monolith.d.ts +13 -0
- package/dist/themes/monolith.js +101 -0
- package/package.json +87 -5
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { HTMLFieldsetAttributes } from 'svelte/elements';
|
|
2
|
+
import type { FieldError, Rule, ValidateOn } from '../../core/form/types.js';
|
|
3
|
+
import type { ElementProps } from '../../core/props/element.js';
|
|
4
|
+
import type { Color, Density, Size } from '../../core/props/types.js';
|
|
5
|
+
/** The RadioGroup props that `DefaultsProvider` and `UIProvider` can set for a subtree. */
|
|
6
|
+
export interface RadioGroupDefaults {
|
|
7
|
+
/**
|
|
8
|
+
* The colour of the chosen radio. An invalid group uses `error`.
|
|
9
|
+
* @default 'primary'
|
|
10
|
+
*/
|
|
11
|
+
color: Color;
|
|
12
|
+
/**
|
|
13
|
+
* The size of the radios and their labels.
|
|
14
|
+
* @default 'md'
|
|
15
|
+
*/
|
|
16
|
+
size: Size;
|
|
17
|
+
/**
|
|
18
|
+
* Multiplies the height of each row, never the text.
|
|
19
|
+
* @default 'default'
|
|
20
|
+
*/
|
|
21
|
+
density: Density;
|
|
22
|
+
/**
|
|
23
|
+
* Mutes the group and disables every radio in it.
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
disabled: boolean;
|
|
27
|
+
}
|
|
28
|
+
declare module '../../core/defaults/context.js' {
|
|
29
|
+
interface ComponentDefaults {
|
|
30
|
+
RadioGroup: RadioGroupDefaults;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** One choice of a RadioGroup. */
|
|
34
|
+
export interface RadioGroupOption<T extends string | number = string> {
|
|
35
|
+
/** The value the group binds to when this radio is chosen. */
|
|
36
|
+
value: T;
|
|
37
|
+
/** What the radio says. */
|
|
38
|
+
label: string;
|
|
39
|
+
/** Help under the label, read out with the radio. */
|
|
40
|
+
hint?: string;
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
}
|
|
43
|
+
type RadioGroupOwnProps<T extends string | number> = Partial<RadioGroupDefaults> & {
|
|
44
|
+
/** The choices, in order. */
|
|
45
|
+
options: readonly RadioGroupOption<T>[];
|
|
46
|
+
/** The chosen value, or `null` for none. Bindable. */
|
|
47
|
+
value?: T | null;
|
|
48
|
+
/** The question the radios answer, as the group's legend. Without it, use `aria-label`. */
|
|
49
|
+
label?: string;
|
|
50
|
+
/** Help under the radios. An error replaces it. */
|
|
51
|
+
hint?: string;
|
|
52
|
+
/**
|
|
53
|
+
* An error from outside the group, such as the server's answer: a message, a list of which
|
|
54
|
+
* the first is shown, or `true` for an invalid state described elsewhere.
|
|
55
|
+
*/
|
|
56
|
+
error?: FieldError;
|
|
57
|
+
/** Checks run in order after `required`, with the chosen value. The first message is shown. */
|
|
58
|
+
rules?: readonly Rule<T>[];
|
|
59
|
+
/** When the message shows. Defaults to the form's setting, else `'blur'`. */
|
|
60
|
+
validateOn?: ValidateOn;
|
|
61
|
+
/**
|
|
62
|
+
* A choice must be made. Adds an asterisk to the legend.
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
required?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Lays the radios side by side, wrapping when they run out of room.
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
70
|
+
inline?: boolean;
|
|
71
|
+
/** The name the radios submit their value under. Generated when not given. */
|
|
72
|
+
name?: string;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* One choice among a few options, all shown: native radios sharing a name in a `<fieldset>`,
|
|
76
|
+
* whose `<legend>` is the label. The arrow keys move the choice, as the platform does. `class`,
|
|
77
|
+
* `style`, `ref` and other attributes go to the `<fieldset>`. For many options, use a
|
|
78
|
+
* NativeSelect.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* <RadioGroup
|
|
82
|
+
* label="Pay out"
|
|
83
|
+
* name="payout"
|
|
84
|
+
* required
|
|
85
|
+
* options={[
|
|
86
|
+
* { value: 'daily', label: 'Every day' },
|
|
87
|
+
* { value: 'weekly', label: 'Every Monday', hint: 'Fewer, larger transfers' }
|
|
88
|
+
* ]}
|
|
89
|
+
* bind:value={payout}
|
|
90
|
+
* />
|
|
91
|
+
*/
|
|
92
|
+
export type RadioGroupProps<T extends string | number = string> = ElementProps<HTMLFieldSetElement, Omit<HTMLFieldsetAttributes, 'children'>, RadioGroupOwnProps<T>>;
|
|
93
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<script lang="ts" generics="T extends string | number">
|
|
2
|
+
// One choice among a few, as a radio group. See SegmentedControlProps for the props.
|
|
3
|
+
import { useDefaults } from '../../core/defaults/context.js';
|
|
4
|
+
import { sharedClasses } from '../../core/props/classes.js';
|
|
5
|
+
import { rovingFocus } from '../../primitives/focus/roving-focus.js';
|
|
6
|
+
import './segmented-control.css';
|
|
7
|
+
import type {
|
|
8
|
+
SegmentedControlDefaults,
|
|
9
|
+
SegmentedControlOption,
|
|
10
|
+
SegmentedControlProps
|
|
11
|
+
} from './types.js';
|
|
12
|
+
|
|
13
|
+
let {
|
|
14
|
+
variant,
|
|
15
|
+
color,
|
|
16
|
+
size,
|
|
17
|
+
density,
|
|
18
|
+
rounded,
|
|
19
|
+
options,
|
|
20
|
+
value = $bindable(),
|
|
21
|
+
onchange,
|
|
22
|
+
disabled = false,
|
|
23
|
+
class: className,
|
|
24
|
+
ref = $bindable(null),
|
|
25
|
+
...rest
|
|
26
|
+
}: SegmentedControlProps<T> = $props();
|
|
27
|
+
|
|
28
|
+
const resolve = useDefaults<SegmentedControlDefaults>('SegmentedControl', {
|
|
29
|
+
variant: 'elevated',
|
|
30
|
+
color: 'neutral',
|
|
31
|
+
size: 'md',
|
|
32
|
+
density: 'default',
|
|
33
|
+
rounded: true
|
|
34
|
+
});
|
|
35
|
+
const p = $derived(resolve({ variant, color, size, density, rounded }));
|
|
36
|
+
const index = $derived(options.findIndex((option) => option.value === value));
|
|
37
|
+
|
|
38
|
+
// Selection follows focus, as in a radio group: arrows move and pick.
|
|
39
|
+
function pick(option: SegmentedControlOption<T>) {
|
|
40
|
+
if (disabled || option.disabled || option.value === value) return;
|
|
41
|
+
value = option.value;
|
|
42
|
+
onchange?.(option.value);
|
|
43
|
+
}
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<div
|
|
47
|
+
bind:this={ref}
|
|
48
|
+
{...rest}
|
|
49
|
+
role="radiogroup"
|
|
50
|
+
class={['sv-segmented', sharedClasses(p, 'SegmentedControl'), className]}
|
|
51
|
+
style:--sv-segments={options.length}
|
|
52
|
+
style:--sv-segment={index}
|
|
53
|
+
{@attach rovingFocus({ orientation: 'horizontal' })}
|
|
54
|
+
>
|
|
55
|
+
{#if index >= 0}<span class="sv-segmented__thumb" aria-hidden="true"></span>{/if}
|
|
56
|
+
{#each options as option (option.value)}
|
|
57
|
+
<button
|
|
58
|
+
type="button"
|
|
59
|
+
role="radio"
|
|
60
|
+
class="sv-segmented__option"
|
|
61
|
+
data-sv-item
|
|
62
|
+
aria-checked={option.value === value}
|
|
63
|
+
disabled={disabled || option.disabled}
|
|
64
|
+
onclick={() => pick(option)}
|
|
65
|
+
onfocus={() => pick(option)}
|
|
66
|
+
>
|
|
67
|
+
{option.label}
|
|
68
|
+
</button>
|
|
69
|
+
{/each}
|
|
70
|
+
</div>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { SegmentedControlProps } from './types.js';
|
|
2
|
+
declare function $$render<T extends string | number>(): {
|
|
3
|
+
props: SegmentedControlProps<T>;
|
|
4
|
+
exports: {};
|
|
5
|
+
bindings: "ref" | "value";
|
|
6
|
+
slots: {};
|
|
7
|
+
events: {};
|
|
8
|
+
};
|
|
9
|
+
declare class __sveltets_Render<T extends string | number> {
|
|
10
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
11
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
12
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
13
|
+
bindings(): "ref" | "value";
|
|
14
|
+
exports(): {};
|
|
15
|
+
}
|
|
16
|
+
interface $$IsomorphicComponent {
|
|
17
|
+
new <T extends string | number>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
18
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
19
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
20
|
+
<T extends string | number>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
21
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
22
|
+
}
|
|
23
|
+
declare const SegmentedControl: $$IsomorphicComponent;
|
|
24
|
+
type SegmentedControl<T extends string | number> = InstanceType<typeof SegmentedControl<T>>;
|
|
25
|
+
export default SegmentedControl;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SegmentedControl } from './SegmentedControl.svelte';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
@layer sv.tokens, sv.base, sv.components, sv.utilities;
|
|
2
|
+
|
|
3
|
+
@layer sv.components {
|
|
4
|
+
/*
|
|
5
|
+
* Segments share the width of the widest, so the thumb moves one segment per step with
|
|
6
|
+
* translate alone. The selected segment is painted by the variant classes.
|
|
7
|
+
*/
|
|
8
|
+
.sv-segmented {
|
|
9
|
+
--sv-segmented-pad: var(--sv-space-3);
|
|
10
|
+
position: relative;
|
|
11
|
+
isolation: isolate;
|
|
12
|
+
display: inline-grid;
|
|
13
|
+
grid-auto-columns: 1fr;
|
|
14
|
+
grid-auto-flow: column;
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
max-inline-size: 100%;
|
|
17
|
+
block-size: calc(var(--sv-size-height) * var(--sv-density));
|
|
18
|
+
padding: var(--sv-segmented-pad);
|
|
19
|
+
border-radius: var(--sv-rounded, var(--sv-radius-md));
|
|
20
|
+
background-color: var(--sv-color-surface-raised);
|
|
21
|
+
vertical-align: middle;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.sv-segmented__thumb {
|
|
25
|
+
position: absolute;
|
|
26
|
+
inset-block: var(--sv-segmented-pad);
|
|
27
|
+
inset-inline-start: var(--sv-segmented-pad);
|
|
28
|
+
z-index: -1;
|
|
29
|
+
inline-size: calc((100% - 2 * var(--sv-segmented-pad)) / var(--sv-segments));
|
|
30
|
+
border: var(--sv-hairline) solid var(--sv-variant-border);
|
|
31
|
+
border-radius: calc(var(--sv-rounded, var(--sv-radius-md)) - var(--sv-segmented-pad));
|
|
32
|
+
box-sizing: border-box;
|
|
33
|
+
background-color: var(--sv-variant-bg);
|
|
34
|
+
box-shadow: var(--sv-variant-shadow);
|
|
35
|
+
translate: calc(var(--sv-segment) * 100%) 0;
|
|
36
|
+
transition: translate var(--sv-duration-normal) var(--sv-ease);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* An attribute selector, as minifiers rewrite :dir() into language guesses. */
|
|
40
|
+
:where([dir='rtl']) .sv-segmented__thumb {
|
|
41
|
+
translate: calc(var(--sv-segment) * -100%) 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.sv-segmented__option {
|
|
45
|
+
min-inline-size: 0;
|
|
46
|
+
margin: 0;
|
|
47
|
+
padding: 0 calc(var(--sv-size-height) * var(--sv-density) * 0.382);
|
|
48
|
+
overflow: hidden;
|
|
49
|
+
border: 0;
|
|
50
|
+
border-radius: calc(var(--sv-rounded, var(--sv-radius-md)) - var(--sv-segmented-pad));
|
|
51
|
+
background: transparent;
|
|
52
|
+
color: var(--sv-color-text-muted);
|
|
53
|
+
font: var(--sv-weight-medium) var(--sv-size-text) / 1 var(--sv-font-ui);
|
|
54
|
+
text-overflow: ellipsis;
|
|
55
|
+
white-space: nowrap;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
-webkit-tap-highlight-color: transparent;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.sv-segmented__option[aria-checked='true'] {
|
|
61
|
+
color: var(--sv-variant-fg);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.sv-segmented__option:disabled {
|
|
65
|
+
opacity: 0.382;
|
|
66
|
+
cursor: not-allowed;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { ElementProps } from '../../core/props/element.js';
|
|
3
|
+
import type { Color, Density, Rounded, Size, Variant } from '../../core/props/types.js';
|
|
4
|
+
/** The SegmentedControl props that `DefaultsProvider` and `UIProvider` can set for a subtree. */
|
|
5
|
+
export interface SegmentedControlDefaults {
|
|
6
|
+
/**
|
|
7
|
+
* How the selected segment is painted: a raised surface by default.
|
|
8
|
+
* @default 'elevated'
|
|
9
|
+
*/
|
|
10
|
+
variant: Variant;
|
|
11
|
+
/**
|
|
12
|
+
* The colour of the selected segment.
|
|
13
|
+
* @default 'neutral'
|
|
14
|
+
*/
|
|
15
|
+
color: Color;
|
|
16
|
+
/**
|
|
17
|
+
* Height and text size.
|
|
18
|
+
* @default 'md'
|
|
19
|
+
*/
|
|
20
|
+
size: Size;
|
|
21
|
+
/**
|
|
22
|
+
* Multiplies the height and padding, never the text.
|
|
23
|
+
* @default 'default'
|
|
24
|
+
*/
|
|
25
|
+
density: Density;
|
|
26
|
+
/**
|
|
27
|
+
* Corner rounding. `true` keeps the theme's radius.
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
30
|
+
rounded: Rounded;
|
|
31
|
+
}
|
|
32
|
+
declare module '../../core/defaults/context.js' {
|
|
33
|
+
interface ComponentDefaults {
|
|
34
|
+
SegmentedControl: SegmentedControlDefaults;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** One choice of a SegmentedControl. */
|
|
38
|
+
export interface SegmentedControlOption<T extends string | number = string> {
|
|
39
|
+
value: T;
|
|
40
|
+
/** What the segment says. */
|
|
41
|
+
label: string;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* One choice among a few options, side by side, as a radio group with one tab stop. Name it
|
|
46
|
+
* with `aria-label`.
|
|
47
|
+
*/
|
|
48
|
+
export type SegmentedControlProps<T extends string | number = string> = ElementProps<HTMLDivElement, HTMLAttributes<HTMLDivElement>, Partial<SegmentedControlDefaults> & {
|
|
49
|
+
/** The choices, in order. */
|
|
50
|
+
options: readonly SegmentedControlOption<T>[];
|
|
51
|
+
/** The chosen value. Bindable. */
|
|
52
|
+
value?: T;
|
|
53
|
+
/** Called with the value the user picks. */
|
|
54
|
+
onchange?: (value: T) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Disables every option.
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
disabled?: boolean;
|
|
60
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// A modal panel against an edge of the screen, on the shared modal shell. See SheetProps.
|
|
3
|
+
import type { TransitionConfig } from 'svelte/transition';
|
|
4
|
+
import { checkValue, DEV } from '#dev';
|
|
5
|
+
import { useDefaults } from '../../core/defaults/context.js';
|
|
6
|
+
import { sharedClasses } from '../../core/props/classes.js';
|
|
7
|
+
import { easing, motion } from '../../primitives/motion/motion.js';
|
|
8
|
+
import Modal from '../Modal/Modal.svelte';
|
|
9
|
+
import './sheet.css';
|
|
10
|
+
import { SHEET_SIDES, type SheetDefaults, type SheetProps } from './types.js';
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
size,
|
|
14
|
+
density,
|
|
15
|
+
rounded,
|
|
16
|
+
side = 'end',
|
|
17
|
+
open = $bindable(false),
|
|
18
|
+
class: className,
|
|
19
|
+
ref = $bindable(null),
|
|
20
|
+
...rest
|
|
21
|
+
}: SheetProps = $props();
|
|
22
|
+
|
|
23
|
+
const resolve = useDefaults<SheetDefaults>('Sheet', {
|
|
24
|
+
size: 'sm',
|
|
25
|
+
density: 'default',
|
|
26
|
+
rounded: true
|
|
27
|
+
});
|
|
28
|
+
const p = $derived(resolve({ size, density, rounded }));
|
|
29
|
+
|
|
30
|
+
if (DEV) $effect(() => checkValue('Sheet', 'side', side, SHEET_SIDES));
|
|
31
|
+
|
|
32
|
+
// The panel slides in from its edge, with the theme's timing; start and end follow the
|
|
33
|
+
// writing direction.
|
|
34
|
+
function slide(node: Element): TransitionConfig {
|
|
35
|
+
const timing = motion(node);
|
|
36
|
+
const rtl = getComputedStyle(node).direction === 'rtl';
|
|
37
|
+
const axis = side === 'top' || side === 'bottom' ? 'Y' : 'X';
|
|
38
|
+
const sign = side === 'bottom' ? 1 : side === 'top' ? -1 : (side === 'end') !== rtl ? 1 : -1;
|
|
39
|
+
return {
|
|
40
|
+
duration: timing.normal,
|
|
41
|
+
easing: easing(timing.ease),
|
|
42
|
+
css: (_, u) => `transform: translate${axis}(${sign * u * 100}%)`
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<Modal
|
|
48
|
+
{...rest}
|
|
49
|
+
component="Sheet"
|
|
50
|
+
placement={side}
|
|
51
|
+
panelClass={sharedClasses(p, 'Sheet')}
|
|
52
|
+
enter={slide}
|
|
53
|
+
class={['sv-sheet', className]}
|
|
54
|
+
bind:open
|
|
55
|
+
bind:ref
|
|
56
|
+
/>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
@layer sv.tokens, sv.base, sv.components, sv.utilities;
|
|
2
|
+
|
|
3
|
+
@layer sv.components {
|
|
4
|
+
/*
|
|
5
|
+
* Sheets: the panel against one edge, the full length of it, rounded on its inner corners only.
|
|
6
|
+
* A sheet from the start or the end is as wide as its size; one from the top or the bottom is
|
|
7
|
+
* as wide as its size at most, and as tall as its content allows.
|
|
8
|
+
*/
|
|
9
|
+
.sv-modal:not(.sv-modal--center) {
|
|
10
|
+
padding: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.sv-modal--start,
|
|
14
|
+
.sv-modal--end {
|
|
15
|
+
align-items: stretch;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.sv-modal--start {
|
|
19
|
+
justify-items: start;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.sv-modal--end {
|
|
23
|
+
justify-items: end;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.sv-modal--top {
|
|
27
|
+
align-items: start;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.sv-modal--bottom {
|
|
31
|
+
align-items: end;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
:is(.sv-modal--start, .sv-modal--end) > .sv-modal__panel {
|
|
35
|
+
block-size: 100%;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
:is(.sv-modal--top, .sv-modal--bottom) > .sv-modal__panel {
|
|
39
|
+
max-block-size: calc(100% - var(--sv-space-34));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.sv-modal--start > .sv-modal__panel {
|
|
43
|
+
border-start-start-radius: 0;
|
|
44
|
+
border-end-start-radius: 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.sv-modal--end > .sv-modal__panel {
|
|
48
|
+
border-start-end-radius: 0;
|
|
49
|
+
border-end-end-radius: 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.sv-modal--top > .sv-modal__panel {
|
|
53
|
+
border-start-start-radius: 0;
|
|
54
|
+
border-start-end-radius: 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.sv-modal--bottom > .sv-modal__panel {
|
|
58
|
+
border-end-start-radius: 0;
|
|
59
|
+
border-end-end-radius: 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { HTMLDialogAttributes } from 'svelte/elements';
|
|
2
|
+
import type { ElementProps } from '../../core/props/element.js';
|
|
3
|
+
import type { Density, Rounded, Size } from '../../core/props/types.js';
|
|
4
|
+
import type { ModalContentProps } from '../Modal/types.js';
|
|
5
|
+
/** The Sheet props that `DefaultsProvider` and `UIProvider` can set for a subtree. */
|
|
6
|
+
export interface SheetDefaults {
|
|
7
|
+
/**
|
|
8
|
+
* The width of the panel, from `xs` (21rem) to `xl` (55rem); for a sheet from the top or the
|
|
9
|
+
* bottom, the most it spans.
|
|
10
|
+
* @default 'sm'
|
|
11
|
+
*/
|
|
12
|
+
size: Size;
|
|
13
|
+
/**
|
|
14
|
+
* Multiplies the padding, never the text.
|
|
15
|
+
* @default 'default'
|
|
16
|
+
*/
|
|
17
|
+
density: Density;
|
|
18
|
+
/**
|
|
19
|
+
* Corner rounding of the inner corners. `true` keeps the theme's radius for large surfaces.
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
rounded: Rounded;
|
|
23
|
+
}
|
|
24
|
+
declare module '../../core/defaults/context.js' {
|
|
25
|
+
interface ComponentDefaults {
|
|
26
|
+
Sheet: SheetDefaults;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export declare const SHEET_SIDES: readonly ["start", "end", "top", "bottom"];
|
|
30
|
+
/** The edge a sheet comes from. `start` and `end` follow the writing direction. */
|
|
31
|
+
export type SheetSide = (typeof SHEET_SIDES)[number];
|
|
32
|
+
/**
|
|
33
|
+
* A modal panel that slides in from an edge of the screen: a drawer from the start or the end,
|
|
34
|
+
* a sheet from the bottom or the top. It is a Dialog in every other way: the platform's own
|
|
35
|
+
* `<dialog>`, focus moved in and given back, Escape and the backdrop close it. `class`, `style`,
|
|
36
|
+
* `ref` and other attributes go to the `<dialog>`.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* <Sheet title="Filters" side="end">
|
|
40
|
+
* {#snippet trigger(attributes)}<Button {...attributes} variant="outlined">Filters</Button>{/snippet}
|
|
41
|
+
* <Checkbox label="Pending only" bind:checked={pending} />
|
|
42
|
+
* {#snippet actions({ close })}<Button onclick={close}>Show results</Button>{/snippet}
|
|
43
|
+
* </Sheet>
|
|
44
|
+
*/
|
|
45
|
+
export type SheetProps = ElementProps<HTMLDialogElement, Omit<HTMLDialogAttributes, 'open' | 'title' | 'children'>, Partial<SheetDefaults> & ModalContentProps & {
|
|
46
|
+
/**
|
|
47
|
+
* The edge it slides in from.
|
|
48
|
+
* @default 'end'
|
|
49
|
+
*/
|
|
50
|
+
side?: SheetSide;
|
|
51
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const SHEET_SIDES = ['start', 'end', 'top', 'bottom'];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// A loading placeholder. See SkeletonProps for the props.
|
|
3
|
+
import { sharedClasses } from '../../core/props/classes.js';
|
|
4
|
+
import './skeleton.css';
|
|
5
|
+
import type { SkeletonProps } from './types.js';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
type = 'text',
|
|
9
|
+
lines = 1,
|
|
10
|
+
size = 'md',
|
|
11
|
+
class: className,
|
|
12
|
+
ref = $bindable(null),
|
|
13
|
+
...rest
|
|
14
|
+
}: SkeletonProps = $props();
|
|
15
|
+
|
|
16
|
+
const count = $derived(Math.max(1, Math.trunc(lines) || 1));
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<span
|
|
20
|
+
bind:this={ref}
|
|
21
|
+
{...rest}
|
|
22
|
+
aria-hidden="true"
|
|
23
|
+
class={[
|
|
24
|
+
'sv-skeleton',
|
|
25
|
+
`sv-skeleton--${type}`,
|
|
26
|
+
type === 'circle' && sharedClasses({ size }, 'Skeleton'),
|
|
27
|
+
className
|
|
28
|
+
]}
|
|
29
|
+
>
|
|
30
|
+
{#if type === 'text'}
|
|
31
|
+
{#each { length: count }, line (line)}<span class="sv-skeleton__line"></span>{/each}
|
|
32
|
+
{/if}
|
|
33
|
+
</span>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Skeleton } from './Skeleton.svelte';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
@layer sv.tokens, sv.base, sv.components, sv.utilities;
|
|
2
|
+
|
|
3
|
+
@layer sv.components {
|
|
4
|
+
.sv-skeleton,
|
|
5
|
+
.sv-skeleton__line {
|
|
6
|
+
position: relative;
|
|
7
|
+
display: block;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
border-radius: var(--sv-radius-sm);
|
|
10
|
+
background-color: var(--sv-color-surface-raised);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* Lines as tall as the text around them, a φ⁻¹ gap apart. */
|
|
14
|
+
.sv-skeleton--text {
|
|
15
|
+
display: grid;
|
|
16
|
+
gap: 0.618em;
|
|
17
|
+
overflow: visible;
|
|
18
|
+
background-color: transparent;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.sv-skeleton__line {
|
|
22
|
+
block-size: 1em;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.sv-skeleton__line:last-child:not(:first-child) {
|
|
26
|
+
inline-size: 61.8%;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.sv-skeleton--rect {
|
|
30
|
+
inline-size: 100%;
|
|
31
|
+
aspect-ratio: 1.618;
|
|
32
|
+
/* The control radius, never rounder than a card, even where controls are pills. */
|
|
33
|
+
border-radius: min(var(--sv-radius-md), var(--sv-radius-lg));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.sv-skeleton--circle {
|
|
37
|
+
inline-size: var(--sv-size-height);
|
|
38
|
+
block-size: var(--sv-size-height);
|
|
39
|
+
border-radius: 50%;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* A highlight sweeps across: transform only, and none under reduced motion. */
|
|
43
|
+
.sv-skeleton:not(.sv-skeleton--text)::after,
|
|
44
|
+
.sv-skeleton__line::after {
|
|
45
|
+
content: '';
|
|
46
|
+
position: absolute;
|
|
47
|
+
inset: 0;
|
|
48
|
+
background: linear-gradient(
|
|
49
|
+
90deg,
|
|
50
|
+
transparent,
|
|
51
|
+
color-mix(in oklch, var(--sv-color-surface) 61.8%, transparent),
|
|
52
|
+
transparent
|
|
53
|
+
);
|
|
54
|
+
transform: translateX(-100%);
|
|
55
|
+
animation: sv-skeleton-sweep 1618ms var(--sv-ease) infinite;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@media (prefers-reduced-motion: reduce) {
|
|
59
|
+
.sv-skeleton::after,
|
|
60
|
+
.sv-skeleton__line::after {
|
|
61
|
+
display: none;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@keyframes sv-skeleton-sweep {
|
|
66
|
+
to {
|
|
67
|
+
transform: translateX(100%);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { ElementProps } from '../../core/props/element.js';
|
|
3
|
+
import type { Size } from '../../core/props/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* A placeholder in the shape of content that is still loading. Hidden from assistive
|
|
6
|
+
* technology: mark the region that is loading with `aria-busy="true"` instead.
|
|
7
|
+
*/
|
|
8
|
+
export type SkeletonProps = ElementProps<HTMLSpanElement, HTMLAttributes<HTMLSpanElement>, {
|
|
9
|
+
/**
|
|
10
|
+
* Lines of text, a golden rectangle that fills the width (an image, a chart), or a circle
|
|
11
|
+
* (an avatar).
|
|
12
|
+
* @default 'text'
|
|
13
|
+
*/
|
|
14
|
+
type?: 'text' | 'rect' | 'circle';
|
|
15
|
+
/**
|
|
16
|
+
* Lines of text; the last of several is φ⁻¹ as wide.
|
|
17
|
+
* @default 1
|
|
18
|
+
*/
|
|
19
|
+
lines?: number;
|
|
20
|
+
/**
|
|
21
|
+
* The diameter of a circle: the control height of the size.
|
|
22
|
+
* @default 'md'
|
|
23
|
+
*/
|
|
24
|
+
size?: Size;
|
|
25
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|