@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,101 @@
|
|
|
1
|
+
@layer sv.tokens, sv.base, sv.components, sv.utilities;
|
|
2
|
+
|
|
3
|
+
@layer sv.components {
|
|
4
|
+
/* A pill a control tall; text follows size only. */
|
|
5
|
+
.sv-chip {
|
|
6
|
+
position: relative;
|
|
7
|
+
isolation: isolate;
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
gap: 0.382em;
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
max-inline-size: 100%;
|
|
13
|
+
block-size: calc(var(--sv-size-height) * var(--sv-density));
|
|
14
|
+
margin: 0;
|
|
15
|
+
padding: 0 calc(var(--sv-size-height) * var(--sv-density) * 0.382);
|
|
16
|
+
border: var(--sv-hairline) solid var(--sv-variant-border);
|
|
17
|
+
border-radius: var(--sv-rounded, var(--sv-radius-full));
|
|
18
|
+
background-color: var(--sv-variant-bg);
|
|
19
|
+
box-shadow: var(--sv-variant-shadow);
|
|
20
|
+
color: var(--sv-variant-fg);
|
|
21
|
+
font: var(--sv-weight-medium) var(--sv-size-text) / 1 var(--sv-font-ui);
|
|
22
|
+
text-decoration: none;
|
|
23
|
+
white-space: nowrap;
|
|
24
|
+
vertical-align: middle;
|
|
25
|
+
-webkit-tap-highlight-color: transparent;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* Pressable chips use the same state layer as Button. */
|
|
29
|
+
.sv-chip--action {
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
user-select: none;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.sv-chip--action::before {
|
|
35
|
+
content: '';
|
|
36
|
+
position: absolute;
|
|
37
|
+
inset: calc(var(--sv-hairline) * -1);
|
|
38
|
+
z-index: -1;
|
|
39
|
+
border-radius: inherit;
|
|
40
|
+
background-color: currentColor;
|
|
41
|
+
opacity: 0;
|
|
42
|
+
pointer-events: none;
|
|
43
|
+
transition: opacity var(--sv-duration-fast) var(--sv-ease);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@media (hover: hover) {
|
|
47
|
+
.sv-chip--action:where(:not(.sv-chip--disabled)):hover::before {
|
|
48
|
+
opacity: var(--sv-state-hover);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.sv-chip--action:where(:not(.sv-chip--disabled)):active::before {
|
|
53
|
+
opacity: var(--sv-state-press);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.sv-chip--disabled {
|
|
57
|
+
opacity: 0.382;
|
|
58
|
+
cursor: not-allowed;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.sv-chip__label {
|
|
62
|
+
overflow: hidden;
|
|
63
|
+
text-overflow: ellipsis;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.sv-chip__prepend,
|
|
67
|
+
.sv-chip__append {
|
|
68
|
+
display: inline-flex;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:where(.sv-chip) svg {
|
|
72
|
+
inline-size: 1.272em;
|
|
73
|
+
block-size: 1.272em;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* The close button: a round target at the end, tinted on hover. */
|
|
77
|
+
.sv-chip__close {
|
|
78
|
+
display: inline-grid;
|
|
79
|
+
place-items: center;
|
|
80
|
+
inline-size: 1.618em;
|
|
81
|
+
block-size: 1.618em;
|
|
82
|
+
margin-inline-end: -0.382em;
|
|
83
|
+
padding: 0;
|
|
84
|
+
border: 0;
|
|
85
|
+
border-radius: 50%;
|
|
86
|
+
background: transparent;
|
|
87
|
+
color: inherit;
|
|
88
|
+
cursor: pointer;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@media (hover: hover) {
|
|
92
|
+
.sv-chip__close:hover {
|
|
93
|
+
background-color: color-mix(in oklch, currentColor var(--sv-state-hover), transparent);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.sv-chip__close svg {
|
|
98
|
+
inline-size: 1em;
|
|
99
|
+
block-size: 1em;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Chip } from './Chip.svelte';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAnchorAttributes, HTMLAttributes, HTMLButtonAttributes } from 'svelte/elements';
|
|
3
|
+
import type { ElementProps } from '../../core/props/element.js';
|
|
4
|
+
import type { Color, Density, Rounded, Size, Variant } from '../../core/props/types.js';
|
|
5
|
+
/** The Chip props that `DefaultsProvider` and `UIProvider` can set for a subtree. */
|
|
6
|
+
export interface ChipDefaults {
|
|
7
|
+
/**
|
|
8
|
+
* Visual weight. A selected chip is `flat`.
|
|
9
|
+
* @default 'tonal'
|
|
10
|
+
*/
|
|
11
|
+
variant: Variant;
|
|
12
|
+
/**
|
|
13
|
+
* Height and text size.
|
|
14
|
+
* @default 'sm'
|
|
15
|
+
*/
|
|
16
|
+
size: Size;
|
|
17
|
+
/**
|
|
18
|
+
* Multiplies the height and padding, never the text.
|
|
19
|
+
* @default 'default'
|
|
20
|
+
*/
|
|
21
|
+
density: Density;
|
|
22
|
+
/**
|
|
23
|
+
* The colour the variant is painted with.
|
|
24
|
+
* @default 'neutral'
|
|
25
|
+
*/
|
|
26
|
+
color: Color;
|
|
27
|
+
/**
|
|
28
|
+
* Corner rounding. `true` keeps the pill.
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
rounded: Rounded;
|
|
32
|
+
/**
|
|
33
|
+
* A disabled chip cannot be pressed; a disabled link loses its `href`.
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
disabled: boolean;
|
|
37
|
+
}
|
|
38
|
+
declare module '../../core/defaults/context.js' {
|
|
39
|
+
interface ComponentDefaults {
|
|
40
|
+
Chip: ChipDefaults;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A compact label: a tag (optionally `closable`), a filter that toggles (`selected`), an
|
|
45
|
+
* action (`onclick`) or a link (`href`).
|
|
46
|
+
*/
|
|
47
|
+
export type ChipProps = ElementProps<HTMLSpanElement | HTMLButtonElement | HTMLAnchorElement, HTMLAttributes<HTMLSpanElement> & HTMLButtonAttributes & HTMLAnchorAttributes, Partial<ChipDefaults> & {
|
|
48
|
+
/**
|
|
49
|
+
* Makes the chip a toggle button (`aria-pressed`) that flips it when pressed: a filter.
|
|
50
|
+
* Bindable. Shows a check while selected.
|
|
51
|
+
*/
|
|
52
|
+
selected?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Adds a button that removes the chip by calling `onclose`. Only for chips that are not
|
|
55
|
+
* themselves buttons or links.
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
closable?: boolean;
|
|
59
|
+
/** The name of the close button, such as `Remove Euro`. Defaults to the locale's `close`. */
|
|
60
|
+
closeLabel?: string;
|
|
61
|
+
/** Called by the close button. */
|
|
62
|
+
onclose?: () => void;
|
|
63
|
+
/** Content before the label, usually an icon or an avatar. */
|
|
64
|
+
prepend?: Snippet;
|
|
65
|
+
/** Content after the label. */
|
|
66
|
+
append?: Snippet;
|
|
67
|
+
/** The label. */
|
|
68
|
+
children?: Snippet;
|
|
69
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// A control beside its label, with a hint or an error under them: the layout Checkbox and
|
|
3
|
+
// Switch share. See ChoiceProps.
|
|
4
|
+
import './choice.css';
|
|
5
|
+
import type { ChoiceProps } from './types.js';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
id: idProp,
|
|
9
|
+
label,
|
|
10
|
+
hint,
|
|
11
|
+
error = false,
|
|
12
|
+
required = false,
|
|
13
|
+
disabled = false,
|
|
14
|
+
children,
|
|
15
|
+
class: className,
|
|
16
|
+
ref = $bindable(null),
|
|
17
|
+
...rest
|
|
18
|
+
}: ChoiceProps = $props();
|
|
19
|
+
|
|
20
|
+
const uid = $props.id();
|
|
21
|
+
const id = $derived(idProp ?? uid);
|
|
22
|
+
const message = $derived(typeof error === 'string' ? error : undefined);
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<div
|
|
26
|
+
bind:this={ref}
|
|
27
|
+
{...rest}
|
|
28
|
+
class={[
|
|
29
|
+
'sv-choice',
|
|
30
|
+
error !== false && 'sv-choice--invalid',
|
|
31
|
+
disabled && 'sv-choice--disabled',
|
|
32
|
+
className
|
|
33
|
+
]}
|
|
34
|
+
>
|
|
35
|
+
<!-- The label wraps the control, so a press anywhere on it toggles the control. -->
|
|
36
|
+
<label class="sv-choice__row">
|
|
37
|
+
{@render children({
|
|
38
|
+
id,
|
|
39
|
+
'aria-describedby': message ? `${id}-error` : hint ? `${id}-hint` : undefined,
|
|
40
|
+
'aria-invalid': error !== false || undefined,
|
|
41
|
+
required,
|
|
42
|
+
disabled
|
|
43
|
+
})}
|
|
44
|
+
{#if label}
|
|
45
|
+
<span class="sv-choice__label"
|
|
46
|
+
>{#if typeof label === 'string'}{label}{:else}{@render label()}{/if}{#if required}<span
|
|
47
|
+
class="sv-choice__required"
|
|
48
|
+
aria-hidden="true">*</span
|
|
49
|
+
>{/if}</span
|
|
50
|
+
>
|
|
51
|
+
{/if}
|
|
52
|
+
</label>
|
|
53
|
+
<div class="sv-choice__messages">
|
|
54
|
+
{#if hint && !message}<p class="sv-choice__hint" id="{id}-hint">{hint}</p>{/if}
|
|
55
|
+
<!-- Announces an error that appears after the user has moved on. -->
|
|
56
|
+
<div aria-live="polite">
|
|
57
|
+
{#if message}<p class="sv-choice__error" id="{id}-error">{message}</p>{/if}
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
@layer sv.tokens, sv.base, sv.components, sv.utilities;
|
|
2
|
+
|
|
3
|
+
@layer sv.components {
|
|
4
|
+
/*
|
|
5
|
+
* A control beside its label, with a hint or an error under them. The row is the label, so a
|
|
6
|
+
* press anywhere on it toggles the control. It is at least 24px tall (WCAG 2.5.8) and grows
|
|
7
|
+
* with the size and density. The control sets --sv-choice-control to its width, so the
|
|
8
|
+
* messages line up with the label text.
|
|
9
|
+
*/
|
|
10
|
+
.sv-choice {
|
|
11
|
+
--sv-choice-gap: 0.618em;
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
align-items: flex-start;
|
|
15
|
+
min-inline-size: 0;
|
|
16
|
+
color: var(--sv-color-text);
|
|
17
|
+
font-family: var(--sv-font-ui);
|
|
18
|
+
font-size: var(--sv-size-text);
|
|
19
|
+
line-height: var(--sv-leading-snug);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.sv-choice__row {
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
gap: var(--sv-choice-gap);
|
|
25
|
+
align-items: flex-start;
|
|
26
|
+
max-inline-size: 100%;
|
|
27
|
+
padding-block: max(
|
|
28
|
+
0px,
|
|
29
|
+
(max(1.5rem, var(--sv-size-height) * var(--sv-density) * 0.618) - 1lh) / 2
|
|
30
|
+
);
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.sv-choice__label {
|
|
35
|
+
min-inline-size: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.sv-choice__required {
|
|
39
|
+
margin-inline-start: 0.236em;
|
|
40
|
+
color: var(--sv-color-error);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.sv-choice__messages {
|
|
44
|
+
padding-inline-start: calc(var(--sv-choice-control) + var(--sv-choice-gap));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.sv-choice__hint,
|
|
48
|
+
.sv-choice__error {
|
|
49
|
+
margin: 0;
|
|
50
|
+
font-size: var(--sv-text-xs);
|
|
51
|
+
line-height: var(--sv-leading-snug);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.sv-choice__hint {
|
|
55
|
+
color: var(--sv-color-text-muted);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.sv-choice__error {
|
|
59
|
+
color: var(--sv-color-error);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.sv-choice--invalid {
|
|
63
|
+
--sv-color: var(--sv-color-error);
|
|
64
|
+
--sv-on-color: var(--sv-on-error);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/*
|
|
68
|
+
* The control and its label are muted at φ⁻², as a disabled Button. The hint stays legible:
|
|
69
|
+
* it often says why the control is off.
|
|
70
|
+
*/
|
|
71
|
+
.sv-choice--disabled > .sv-choice__row {
|
|
72
|
+
opacity: 0.382;
|
|
73
|
+
cursor: not-allowed;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { FieldError } from '../../core/form/types.js';
|
|
4
|
+
import type { ElementProps } from '../../core/props/element.js';
|
|
5
|
+
/** The props of a choice's label, help and error, shared by Checkbox and Switch. */
|
|
6
|
+
export interface ChoiceContentProps {
|
|
7
|
+
/**
|
|
8
|
+
* The label beside the control: text, or a snippet when it holds a link. A press anywhere on
|
|
9
|
+
* it toggles the control. Without it, name the control with `aria-label`.
|
|
10
|
+
*/
|
|
11
|
+
label?: string | Snippet;
|
|
12
|
+
/** Help under the label. An error replaces it. */
|
|
13
|
+
hint?: string;
|
|
14
|
+
/**
|
|
15
|
+
* An error from outside the control, such as the server's answer: a message, a list of which
|
|
16
|
+
* the first is shown, or `true` for an invalid state described elsewhere.
|
|
17
|
+
*/
|
|
18
|
+
error?: FieldError;
|
|
19
|
+
}
|
|
20
|
+
/** What a Choice passes to the control it lays out. Spread it onto the `<input>`. */
|
|
21
|
+
export interface ChoiceControlAttributes {
|
|
22
|
+
/** The id the hint and the error are named after. */
|
|
23
|
+
id: string;
|
|
24
|
+
/** The hint or the error, whichever is shown. */
|
|
25
|
+
'aria-describedby': string | undefined;
|
|
26
|
+
/** Set while the choice shows an error. */
|
|
27
|
+
'aria-invalid': true | undefined;
|
|
28
|
+
required: boolean;
|
|
29
|
+
disabled: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** A control beside its label, with a hint or an error under them. Internal. */
|
|
32
|
+
export type ChoiceProps = ElementProps<HTMLDivElement, HTMLAttributes<HTMLDivElement>, Omit<ChoiceContentProps, 'error'> & {
|
|
33
|
+
/** The id of the control. Generated when not given. */
|
|
34
|
+
id?: string | null;
|
|
35
|
+
/** What the choice shows: a message, `true` for an invalid state without one, or `false`. */
|
|
36
|
+
error?: string | boolean;
|
|
37
|
+
/** Adds an asterisk to the label. */
|
|
38
|
+
required?: boolean;
|
|
39
|
+
/** Mutes the choice. The control carries `disabled` itself. */
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
/** The control, drawn at the start of the label. */
|
|
42
|
+
children: Snippet<[ChoiceControlAttributes]>;
|
|
43
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// A modal dialog in the middle of the screen, on the shared modal shell. See DialogProps.
|
|
3
|
+
import { useDefaults } from '../../core/defaults/context.js';
|
|
4
|
+
import { sharedClasses } from '../../core/props/classes.js';
|
|
5
|
+
import { pop } from '../../primitives/motion/motion.js';
|
|
6
|
+
import Modal from '../Modal/Modal.svelte';
|
|
7
|
+
import type { DialogDefaults, DialogProps } from './types.js';
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
size,
|
|
11
|
+
density,
|
|
12
|
+
rounded,
|
|
13
|
+
open = $bindable(false),
|
|
14
|
+
class: className,
|
|
15
|
+
ref = $bindable(null),
|
|
16
|
+
...rest
|
|
17
|
+
}: DialogProps = $props();
|
|
18
|
+
|
|
19
|
+
const resolve = useDefaults<DialogDefaults>('Dialog', {
|
|
20
|
+
size: 'md',
|
|
21
|
+
density: 'default',
|
|
22
|
+
rounded: true
|
|
23
|
+
});
|
|
24
|
+
const p = $derived(resolve({ size, density, rounded }));
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<Modal
|
|
28
|
+
{...rest}
|
|
29
|
+
component="Dialog"
|
|
30
|
+
placement="center"
|
|
31
|
+
panelClass={sharedClasses(p, 'Dialog')}
|
|
32
|
+
enter={pop}
|
|
33
|
+
class={['sv-dialog', className]}
|
|
34
|
+
bind:open
|
|
35
|
+
bind:ref
|
|
36
|
+
/>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Dialog } from './Dialog.svelte';
|
|
@@ -0,0 +1,50 @@
|
|
|
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 Dialog props that `DefaultsProvider` and `UIProvider` can set for a subtree. */
|
|
6
|
+
export interface DialogDefaults {
|
|
7
|
+
/**
|
|
8
|
+
* The width of the panel, from `xs` (21rem) to `xl` (55rem).
|
|
9
|
+
* @default 'md'
|
|
10
|
+
*/
|
|
11
|
+
size: Size;
|
|
12
|
+
/**
|
|
13
|
+
* Multiplies the padding, never the text.
|
|
14
|
+
* @default 'default'
|
|
15
|
+
*/
|
|
16
|
+
density: Density;
|
|
17
|
+
/**
|
|
18
|
+
* Corner rounding. `true` keeps the theme's radius for large surfaces.
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
rounded: Rounded;
|
|
22
|
+
}
|
|
23
|
+
declare module '../../core/defaults/context.js' {
|
|
24
|
+
interface ComponentDefaults {
|
|
25
|
+
Dialog: DialogDefaults;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A modal dialog: the platform's own `<dialog>`, in the top layer, with the rest of the page
|
|
30
|
+
* inert and still. Focus moves into it and returns to the control that opened it; Escape and a
|
|
31
|
+
* press on the backdrop close it unless it is `persistent`. `class`, `style`, `ref` and other
|
|
32
|
+
* attributes go to the `<dialog>`.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* <Dialog title="Delete this card?" bind:open>
|
|
36
|
+
* {#snippet trigger(attributes)}<Button {...attributes} color="error">Delete</Button>{/snippet}
|
|
37
|
+
* The card stops working at once. Payments already made are kept.
|
|
38
|
+
* {#snippet actions({ close })}
|
|
39
|
+
* <Button variant="text" onclick={close}>Keep it</Button>
|
|
40
|
+
* <Button color="error" onclick={remove}>Delete</Button>
|
|
41
|
+
* {/snippet}
|
|
42
|
+
* </Dialog>
|
|
43
|
+
*/
|
|
44
|
+
export type DialogProps = ElementProps<HTMLDialogElement, Omit<HTMLDialogAttributes, 'open' | 'title' | 'children'>, Partial<DialogDefaults> & ModalContentProps & {
|
|
45
|
+
/**
|
|
46
|
+
* The panel fills the screen, as on a phone.
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
fullscreen?: boolean;
|
|
50
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// A hairline separator. See DividerProps for the props.
|
|
3
|
+
import './divider.css';
|
|
4
|
+
import type { DividerProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
vertical = false,
|
|
8
|
+
class: className,
|
|
9
|
+
ref = $bindable(null),
|
|
10
|
+
...rest
|
|
11
|
+
}: DividerProps = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<hr
|
|
15
|
+
bind:this={ref}
|
|
16
|
+
{...rest}
|
|
17
|
+
aria-orientation={vertical ? 'vertical' : undefined}
|
|
18
|
+
class={['sv-divider', vertical && 'sv-divider--vertical', className]}
|
|
19
|
+
/>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@layer sv.tokens, sv.base, sv.components, sv.utilities;
|
|
2
|
+
|
|
3
|
+
@layer sv.components {
|
|
4
|
+
.sv-divider {
|
|
5
|
+
flex: none;
|
|
6
|
+
align-self: stretch;
|
|
7
|
+
block-size: 0;
|
|
8
|
+
margin: 0;
|
|
9
|
+
border: 0;
|
|
10
|
+
border-block-start: var(--sv-hairline) solid var(--sv-color-border);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* Stretches in a flex row; standing alone in text, it is one line tall. */
|
|
14
|
+
.sv-divider--vertical {
|
|
15
|
+
display: inline-block;
|
|
16
|
+
inline-size: 0;
|
|
17
|
+
block-size: auto;
|
|
18
|
+
min-block-size: 1em;
|
|
19
|
+
border-block-start: 0;
|
|
20
|
+
border-inline-start: var(--sv-hairline) solid var(--sv-color-border);
|
|
21
|
+
vertical-align: middle;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Divider } from './Divider.svelte';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { ElementProps } from '../../core/props/element.js';
|
|
3
|
+
/** A hairline between groups of content: an `<hr>`, which assistive technology reads as a separator. */
|
|
4
|
+
export type DividerProps = ElementProps<HTMLHRElement, HTMLAttributes<HTMLHRElement>, {
|
|
5
|
+
/**
|
|
6
|
+
* Runs top to bottom, between items in a row, and stretches to the row's height.
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
|
+
vertical?: boolean;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// A label, a box for a control, and its hint or error. See FieldProps for the props.
|
|
3
|
+
import { useDefaults } from '../../core/defaults/context.js';
|
|
4
|
+
import { readError } from '../../core/form/field.svelte.js';
|
|
5
|
+
import { sharedClasses } from '../../core/props/classes.js';
|
|
6
|
+
import './field.css';
|
|
7
|
+
import { FIELD_VARIANTS, type FieldDefaults, type FieldProps } from './types.js';
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
variant,
|
|
11
|
+
color,
|
|
12
|
+
size,
|
|
13
|
+
density,
|
|
14
|
+
rounded,
|
|
15
|
+
disabled,
|
|
16
|
+
id: idProp,
|
|
17
|
+
label,
|
|
18
|
+
hint,
|
|
19
|
+
error,
|
|
20
|
+
required = false,
|
|
21
|
+
readonly = false,
|
|
22
|
+
prepend,
|
|
23
|
+
append,
|
|
24
|
+
children,
|
|
25
|
+
class: className,
|
|
26
|
+
ref = $bindable(null),
|
|
27
|
+
...rest
|
|
28
|
+
}: FieldProps = $props();
|
|
29
|
+
|
|
30
|
+
const uid = $props.id();
|
|
31
|
+
const id = $derived(idProp ?? uid);
|
|
32
|
+
const resolve = useDefaults<FieldDefaults>('Field', {
|
|
33
|
+
variant: 'outlined',
|
|
34
|
+
color: 'primary',
|
|
35
|
+
size: 'md',
|
|
36
|
+
density: 'default',
|
|
37
|
+
rounded: true,
|
|
38
|
+
disabled: false
|
|
39
|
+
});
|
|
40
|
+
const p = $derived(resolve({ variant, color, size, density, rounded, disabled }));
|
|
41
|
+
const shown = $derived(readError(error));
|
|
42
|
+
const message = $derived(typeof shown === 'string' ? shown : undefined);
|
|
43
|
+
|
|
44
|
+
// A press anywhere in the box focuses the control, as a press on the label does, except on
|
|
45
|
+
// something that takes focus itself (the control, a button in `append`).
|
|
46
|
+
const FOCUSABLE = 'input, textarea, select, button, a[href], [tabindex]';
|
|
47
|
+
|
|
48
|
+
function press(event: PointerEvent) {
|
|
49
|
+
const box = event.currentTarget as HTMLElement;
|
|
50
|
+
const hit = (event.target as Element).closest(FOCUSABLE);
|
|
51
|
+
const control = box.querySelector<HTMLElement>('.sv-field__control');
|
|
52
|
+
if ((hit && box.contains(hit)) || !control || p.disabled) return;
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
control.focus();
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<div
|
|
59
|
+
bind:this={ref}
|
|
60
|
+
{...rest}
|
|
61
|
+
class={[
|
|
62
|
+
'sv-field',
|
|
63
|
+
sharedClasses(p, 'Field', FIELD_VARIANTS),
|
|
64
|
+
shown !== false && 'sv-field--invalid',
|
|
65
|
+
p.disabled && 'sv-field--disabled',
|
|
66
|
+
readonly && 'sv-field--readonly',
|
|
67
|
+
className
|
|
68
|
+
]}
|
|
69
|
+
>
|
|
70
|
+
{#if label}
|
|
71
|
+
<label class="sv-field__label" for={id} id="{id}-label"
|
|
72
|
+
>{label}{#if required}<span class="sv-field__required" aria-hidden="true">*</span>{/if}</label
|
|
73
|
+
>
|
|
74
|
+
{/if}
|
|
75
|
+
<!-- The label and the control are the accessible targets; this only widens the pointer target. -->
|
|
76
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
77
|
+
<div class="sv-field__box" onpointerdown={press}>
|
|
78
|
+
{#if prepend}<span class="sv-field__prepend">{@render prepend()}</span>{/if}
|
|
79
|
+
{@render children({
|
|
80
|
+
id,
|
|
81
|
+
class: 'sv-field__control',
|
|
82
|
+
'aria-describedby': message ? `${id}-error` : hint ? `${id}-hint` : undefined,
|
|
83
|
+
'aria-invalid': shown !== false || undefined,
|
|
84
|
+
required,
|
|
85
|
+
disabled: p.disabled,
|
|
86
|
+
readonly
|
|
87
|
+
})}
|
|
88
|
+
{#if append}<span class="sv-field__append">{@render append()}</span>{/if}
|
|
89
|
+
</div>
|
|
90
|
+
{#if hint && !message}<p class="sv-field__hint" id="{id}-hint">{hint}</p>{/if}
|
|
91
|
+
<!-- Announces an error that appears after the user has moved on. -->
|
|
92
|
+
<div class="sv-field__alert" aria-live="polite">
|
|
93
|
+
{#if message}<p class="sv-field__error" id="{id}-error">{message}</p>{/if}
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|