sv5ui 1.3.0 → 1.5.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/README.md +16 -11
- package/dist/Checkbox/Checkbox.svelte +2 -11
- package/dist/CheckboxGroup/CheckboxGroup.svelte +2 -11
- package/dist/Collapsible/Collapsible.svelte +69 -0
- package/dist/Collapsible/Collapsible.svelte.d.ts +6 -0
- package/dist/Collapsible/CollapsibleTestWrapper.svelte +17 -0
- package/dist/Collapsible/CollapsibleTestWrapper.svelte.d.ts +4 -0
- package/dist/Collapsible/collapsible.types.d.ts +75 -0
- package/dist/Collapsible/collapsible.types.js +1 -0
- package/dist/Collapsible/collapsible.variants.d.ts +53 -0
- package/dist/Collapsible/collapsible.variants.js +21 -0
- package/dist/Collapsible/index.d.ts +2 -0
- package/dist/Collapsible/index.js +1 -0
- package/dist/Command/Command.svelte +183 -0
- package/dist/Command/Command.svelte.d.ts +6 -0
- package/dist/Command/CommandTestWrapper.svelte +13 -0
- package/dist/Command/CommandTestWrapper.svelte.d.ts +4 -0
- package/dist/Command/command.types.d.ts +98 -0
- package/dist/Command/command.types.js +1 -0
- package/dist/Command/command.variants.d.ts +226 -0
- package/dist/Command/command.variants.js +86 -0
- package/dist/Command/index.d.ts +2 -0
- package/dist/Command/index.js +1 -0
- package/dist/FormField/FormField.svelte +2 -6
- package/dist/Input/Input.svelte +2 -10
- package/dist/PinInput/PinInput.svelte +2 -11
- package/dist/RadioGroup/RadioGroup.svelte +2 -11
- package/dist/Select/Select.svelte +2 -10
- package/dist/Select/select.variants.js +1 -1
- package/dist/SelectMenu/SelectMenu.svelte +2 -10
- package/dist/SelectMenu/select-menu.variants.js +1 -1
- package/dist/Slider/Slider.svelte +2 -11
- package/dist/Switch/Switch.svelte +2 -11
- package/dist/Table/Table.svelte +752 -0
- package/dist/Table/Table.svelte.d.ts +26 -0
- package/dist/Table/index.d.ts +2 -0
- package/dist/Table/index.js +1 -0
- package/dist/Table/table.types.d.ts +199 -0
- package/dist/Table/table.types.js +1 -0
- package/dist/Table/table.utils.d.ts +51 -0
- package/dist/Table/table.utils.js +166 -0
- package/dist/Table/table.variants.d.ts +205 -0
- package/dist/Table/table.variants.js +126 -0
- package/dist/Textarea/Textarea.svelte +2 -10
- package/dist/Toast/Toaster.svelte +618 -0
- package/dist/Toast/Toaster.svelte.d.ts +5 -0
- package/dist/Toast/index.d.ts +4 -0
- package/dist/Toast/index.js +2 -0
- package/dist/Toast/toast.d.ts +38 -0
- package/dist/Toast/toast.js +73 -0
- package/dist/Toast/toast.types.d.ts +19 -0
- package/dist/Toast/toast.types.js +1 -0
- package/dist/Toast/toast.variants.d.ts +7 -0
- package/dist/Toast/toast.variants.js +5 -0
- package/dist/config.d.ts +4 -0
- package/dist/config.js +5 -1
- package/dist/hooks/index.d.ts +14 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/useClickOutside.svelte.d.ts +31 -0
- package/dist/hooks/useClickOutside.svelte.js +37 -0
- package/dist/hooks/useClipboard.svelte.d.ts +30 -0
- package/dist/hooks/useClipboard.svelte.js +45 -0
- package/dist/hooks/useDebounce.svelte.d.ts +36 -0
- package/dist/hooks/useDebounce.svelte.js +56 -0
- package/dist/hooks/useEscapeKeydown.svelte.d.ts +31 -0
- package/dist/hooks/useEscapeKeydown.svelte.js +37 -0
- package/dist/hooks/useFormField.svelte.d.ts +21 -0
- package/dist/hooks/useFormField.svelte.js +17 -0
- package/dist/hooks/useInfiniteScroll.svelte.d.ts +57 -0
- package/dist/hooks/useInfiniteScroll.svelte.js +69 -0
- package/dist/hooks/useMediaQuery.svelte.d.ts +31 -0
- package/dist/hooks/useMediaQuery.svelte.js +38 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -0
- package/dist/theme.css +36 -0
- package/package.json +2 -1
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
2
|
+
export declare const commandVariants: import("tailwind-variants").TVReturnType<{
|
|
3
|
+
size: {
|
|
4
|
+
xs: {
|
|
5
|
+
inputIcon: string;
|
|
6
|
+
input: string;
|
|
7
|
+
inputWrapper: string;
|
|
8
|
+
item: string;
|
|
9
|
+
itemIcon: string;
|
|
10
|
+
groupHeading: string;
|
|
11
|
+
empty: string;
|
|
12
|
+
loading: string;
|
|
13
|
+
};
|
|
14
|
+
sm: {
|
|
15
|
+
inputIcon: string;
|
|
16
|
+
input: string;
|
|
17
|
+
inputWrapper: string;
|
|
18
|
+
item: string;
|
|
19
|
+
itemIcon: string;
|
|
20
|
+
groupHeading: string;
|
|
21
|
+
empty: string;
|
|
22
|
+
loading: string;
|
|
23
|
+
};
|
|
24
|
+
md: {
|
|
25
|
+
inputIcon: string;
|
|
26
|
+
input: string;
|
|
27
|
+
inputWrapper: string;
|
|
28
|
+
item: string;
|
|
29
|
+
itemIcon: string;
|
|
30
|
+
groupHeading: string;
|
|
31
|
+
empty: string;
|
|
32
|
+
loading: string;
|
|
33
|
+
};
|
|
34
|
+
lg: {
|
|
35
|
+
inputIcon: string;
|
|
36
|
+
input: string;
|
|
37
|
+
inputWrapper: string;
|
|
38
|
+
item: string;
|
|
39
|
+
itemIcon: string;
|
|
40
|
+
groupHeading: string;
|
|
41
|
+
empty: string;
|
|
42
|
+
loading: string;
|
|
43
|
+
};
|
|
44
|
+
xl: {
|
|
45
|
+
inputIcon: string;
|
|
46
|
+
input: string;
|
|
47
|
+
inputWrapper: string;
|
|
48
|
+
item: string;
|
|
49
|
+
itemIcon: string;
|
|
50
|
+
groupHeading: string;
|
|
51
|
+
empty: string;
|
|
52
|
+
loading: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
}, {
|
|
56
|
+
root: string;
|
|
57
|
+
inputWrapper: string;
|
|
58
|
+
inputIcon: string;
|
|
59
|
+
input: string;
|
|
60
|
+
list: string;
|
|
61
|
+
empty: string;
|
|
62
|
+
loading: string;
|
|
63
|
+
group: string;
|
|
64
|
+
groupHeading: string;
|
|
65
|
+
groupItems: string;
|
|
66
|
+
separator: string;
|
|
67
|
+
item: string;
|
|
68
|
+
itemIcon: string;
|
|
69
|
+
itemWrapper: string;
|
|
70
|
+
itemLabel: string;
|
|
71
|
+
itemDescription: string;
|
|
72
|
+
itemTrailing: string;
|
|
73
|
+
footer: string;
|
|
74
|
+
}, undefined, {
|
|
75
|
+
size: {
|
|
76
|
+
xs: {
|
|
77
|
+
inputIcon: string;
|
|
78
|
+
input: string;
|
|
79
|
+
inputWrapper: string;
|
|
80
|
+
item: string;
|
|
81
|
+
itemIcon: string;
|
|
82
|
+
groupHeading: string;
|
|
83
|
+
empty: string;
|
|
84
|
+
loading: string;
|
|
85
|
+
};
|
|
86
|
+
sm: {
|
|
87
|
+
inputIcon: string;
|
|
88
|
+
input: string;
|
|
89
|
+
inputWrapper: string;
|
|
90
|
+
item: string;
|
|
91
|
+
itemIcon: string;
|
|
92
|
+
groupHeading: string;
|
|
93
|
+
empty: string;
|
|
94
|
+
loading: string;
|
|
95
|
+
};
|
|
96
|
+
md: {
|
|
97
|
+
inputIcon: string;
|
|
98
|
+
input: string;
|
|
99
|
+
inputWrapper: string;
|
|
100
|
+
item: string;
|
|
101
|
+
itemIcon: string;
|
|
102
|
+
groupHeading: string;
|
|
103
|
+
empty: string;
|
|
104
|
+
loading: string;
|
|
105
|
+
};
|
|
106
|
+
lg: {
|
|
107
|
+
inputIcon: string;
|
|
108
|
+
input: string;
|
|
109
|
+
inputWrapper: string;
|
|
110
|
+
item: string;
|
|
111
|
+
itemIcon: string;
|
|
112
|
+
groupHeading: string;
|
|
113
|
+
empty: string;
|
|
114
|
+
loading: string;
|
|
115
|
+
};
|
|
116
|
+
xl: {
|
|
117
|
+
inputIcon: string;
|
|
118
|
+
input: string;
|
|
119
|
+
inputWrapper: string;
|
|
120
|
+
item: string;
|
|
121
|
+
itemIcon: string;
|
|
122
|
+
groupHeading: string;
|
|
123
|
+
empty: string;
|
|
124
|
+
loading: string;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
}, {
|
|
128
|
+
root: string;
|
|
129
|
+
inputWrapper: string;
|
|
130
|
+
inputIcon: string;
|
|
131
|
+
input: string;
|
|
132
|
+
list: string;
|
|
133
|
+
empty: string;
|
|
134
|
+
loading: string;
|
|
135
|
+
group: string;
|
|
136
|
+
groupHeading: string;
|
|
137
|
+
groupItems: string;
|
|
138
|
+
separator: string;
|
|
139
|
+
item: string;
|
|
140
|
+
itemIcon: string;
|
|
141
|
+
itemWrapper: string;
|
|
142
|
+
itemLabel: string;
|
|
143
|
+
itemDescription: string;
|
|
144
|
+
itemTrailing: string;
|
|
145
|
+
footer: string;
|
|
146
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
147
|
+
size: {
|
|
148
|
+
xs: {
|
|
149
|
+
inputIcon: string;
|
|
150
|
+
input: string;
|
|
151
|
+
inputWrapper: string;
|
|
152
|
+
item: string;
|
|
153
|
+
itemIcon: string;
|
|
154
|
+
groupHeading: string;
|
|
155
|
+
empty: string;
|
|
156
|
+
loading: string;
|
|
157
|
+
};
|
|
158
|
+
sm: {
|
|
159
|
+
inputIcon: string;
|
|
160
|
+
input: string;
|
|
161
|
+
inputWrapper: string;
|
|
162
|
+
item: string;
|
|
163
|
+
itemIcon: string;
|
|
164
|
+
groupHeading: string;
|
|
165
|
+
empty: string;
|
|
166
|
+
loading: string;
|
|
167
|
+
};
|
|
168
|
+
md: {
|
|
169
|
+
inputIcon: string;
|
|
170
|
+
input: string;
|
|
171
|
+
inputWrapper: string;
|
|
172
|
+
item: string;
|
|
173
|
+
itemIcon: string;
|
|
174
|
+
groupHeading: string;
|
|
175
|
+
empty: string;
|
|
176
|
+
loading: string;
|
|
177
|
+
};
|
|
178
|
+
lg: {
|
|
179
|
+
inputIcon: string;
|
|
180
|
+
input: string;
|
|
181
|
+
inputWrapper: string;
|
|
182
|
+
item: string;
|
|
183
|
+
itemIcon: string;
|
|
184
|
+
groupHeading: string;
|
|
185
|
+
empty: string;
|
|
186
|
+
loading: string;
|
|
187
|
+
};
|
|
188
|
+
xl: {
|
|
189
|
+
inputIcon: string;
|
|
190
|
+
input: string;
|
|
191
|
+
inputWrapper: string;
|
|
192
|
+
item: string;
|
|
193
|
+
itemIcon: string;
|
|
194
|
+
groupHeading: string;
|
|
195
|
+
empty: string;
|
|
196
|
+
loading: string;
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
}, {
|
|
200
|
+
root: string;
|
|
201
|
+
inputWrapper: string;
|
|
202
|
+
inputIcon: string;
|
|
203
|
+
input: string;
|
|
204
|
+
list: string;
|
|
205
|
+
empty: string;
|
|
206
|
+
loading: string;
|
|
207
|
+
group: string;
|
|
208
|
+
groupHeading: string;
|
|
209
|
+
groupItems: string;
|
|
210
|
+
separator: string;
|
|
211
|
+
item: string;
|
|
212
|
+
itemIcon: string;
|
|
213
|
+
itemWrapper: string;
|
|
214
|
+
itemLabel: string;
|
|
215
|
+
itemDescription: string;
|
|
216
|
+
itemTrailing: string;
|
|
217
|
+
footer: string;
|
|
218
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
219
|
+
export type CommandVariantProps = VariantProps<typeof commandVariants>;
|
|
220
|
+
export type CommandSlots = keyof ReturnType<typeof commandVariants>;
|
|
221
|
+
export declare const commandDefaults: {
|
|
222
|
+
defaultVariants: {
|
|
223
|
+
size: NonNullable<CommandVariantProps["size"]>;
|
|
224
|
+
};
|
|
225
|
+
slots: Partial<Record<CommandSlots, string>>;
|
|
226
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const commandVariants = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
root: 'flex flex-col overflow-hidden',
|
|
5
|
+
inputWrapper: 'flex items-center border-b border-outline-variant px-3',
|
|
6
|
+
inputIcon: 'mr-2 shrink-0 opacity-50',
|
|
7
|
+
input: 'flex h-12 w-full bg-transparent text-sm outline-none placeholder:text-on-surface-variant/50 disabled:cursor-not-allowed disabled:opacity-50',
|
|
8
|
+
list: 'scroll-py-1 overflow-y-auto overflow-x-hidden scrollbar-thin',
|
|
9
|
+
empty: 'py-6 text-center text-sm text-on-surface-variant',
|
|
10
|
+
loading: 'py-6 text-center text-sm text-on-surface-variant',
|
|
11
|
+
group: 'overflow-hidden p-1',
|
|
12
|
+
groupHeading: 'px-2 py-1.5 text-xs font-semibold text-on-surface-variant',
|
|
13
|
+
groupItems: '',
|
|
14
|
+
separator: '-mx-1 h-px bg-outline-variant',
|
|
15
|
+
item: 'relative flex w-full cursor-default select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[selected]:bg-surface-container-highest',
|
|
16
|
+
itemIcon: 'size-4 shrink-0',
|
|
17
|
+
itemWrapper: 'flex min-w-0 flex-1 flex-col',
|
|
18
|
+
itemLabel: 'truncate',
|
|
19
|
+
itemDescription: 'truncate text-xs text-on-surface-variant',
|
|
20
|
+
itemTrailing: 'ms-auto flex items-center gap-1',
|
|
21
|
+
footer: 'border-t border-outline-variant p-1'
|
|
22
|
+
},
|
|
23
|
+
variants: {
|
|
24
|
+
size: {
|
|
25
|
+
xs: {
|
|
26
|
+
inputIcon: 'size-3.5',
|
|
27
|
+
input: 'h-9 text-xs',
|
|
28
|
+
inputWrapper: 'px-2',
|
|
29
|
+
item: 'px-1.5 py-1 text-xs gap-1.5',
|
|
30
|
+
itemIcon: 'size-3.5',
|
|
31
|
+
groupHeading: 'px-1.5 py-1 text-[10px]',
|
|
32
|
+
empty: 'py-4 text-xs',
|
|
33
|
+
loading: 'py-4 text-xs'
|
|
34
|
+
},
|
|
35
|
+
sm: {
|
|
36
|
+
inputIcon: 'size-3.5',
|
|
37
|
+
input: 'h-10 text-xs',
|
|
38
|
+
inputWrapper: 'px-2.5',
|
|
39
|
+
item: 'px-1.5 py-1 text-xs gap-1.5',
|
|
40
|
+
itemIcon: 'size-4',
|
|
41
|
+
groupHeading: 'px-1.5 py-1 text-[10px]',
|
|
42
|
+
empty: 'py-5 text-xs',
|
|
43
|
+
loading: 'py-5 text-xs'
|
|
44
|
+
},
|
|
45
|
+
md: {
|
|
46
|
+
inputIcon: 'size-4',
|
|
47
|
+
input: 'h-12 text-sm',
|
|
48
|
+
inputWrapper: 'px-3',
|
|
49
|
+
item: 'px-2 py-1.5 text-sm gap-2',
|
|
50
|
+
itemIcon: 'size-4',
|
|
51
|
+
groupHeading: 'px-2 py-1.5 text-xs',
|
|
52
|
+
empty: 'py-6 text-sm',
|
|
53
|
+
loading: 'py-6 text-sm'
|
|
54
|
+
},
|
|
55
|
+
lg: {
|
|
56
|
+
inputIcon: 'size-5',
|
|
57
|
+
input: 'h-13 text-sm',
|
|
58
|
+
inputWrapper: 'px-3.5',
|
|
59
|
+
item: 'px-2.5 py-2 text-sm gap-2',
|
|
60
|
+
itemIcon: 'size-5',
|
|
61
|
+
groupHeading: 'px-2.5 py-2 text-xs',
|
|
62
|
+
empty: 'py-7 text-sm',
|
|
63
|
+
loading: 'py-7 text-sm'
|
|
64
|
+
},
|
|
65
|
+
xl: {
|
|
66
|
+
inputIcon: 'size-5',
|
|
67
|
+
input: 'h-14 text-base',
|
|
68
|
+
inputWrapper: 'px-4',
|
|
69
|
+
item: 'px-3 py-2 text-base gap-2.5',
|
|
70
|
+
itemIcon: 'size-5',
|
|
71
|
+
groupHeading: 'px-3 py-2 text-sm',
|
|
72
|
+
empty: 'py-8 text-base',
|
|
73
|
+
loading: 'py-8 text-base'
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
defaultVariants: {
|
|
78
|
+
size: 'md'
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
export const commandDefaults = {
|
|
82
|
+
defaultVariants: {
|
|
83
|
+
size: 'md'
|
|
84
|
+
},
|
|
85
|
+
slots: {}
|
|
86
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Command } from './Command.svelte';
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { formFieldVariants, formFieldDefaults } from './form-field.variants.js'
|
|
10
10
|
import { getComponentConfig } from '../config.js'
|
|
11
11
|
import { setContext } from 'svelte'
|
|
12
|
+
import type { FormFieldContext } from '../hooks/useFormField.svelte.js'
|
|
12
13
|
|
|
13
14
|
const config = getComponentConfig('formField', formFieldDefaults)
|
|
14
15
|
|
|
@@ -57,12 +58,7 @@
|
|
|
57
58
|
const hasError = $derived(error !== undefined && error !== false)
|
|
58
59
|
const errorMessage = $derived(typeof error === 'string' ? error : undefined)
|
|
59
60
|
|
|
60
|
-
setContext<{
|
|
61
|
-
name?: string
|
|
62
|
-
size: NonNullable<FormFieldProps['size']>
|
|
63
|
-
error?: string | boolean
|
|
64
|
-
ariaId: string
|
|
65
|
-
}>('formField', {
|
|
61
|
+
setContext<FormFieldContext>('formField', {
|
|
66
62
|
get name() {
|
|
67
63
|
return name
|
|
68
64
|
},
|
package/dist/Input/Input.svelte
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import Icon from '../Icon/Icon.svelte'
|
|
16
16
|
import Avatar from '../Avatar/Avatar.svelte'
|
|
17
17
|
import type { AvatarSize } from '../Avatar/avatar.types.js'
|
|
18
|
-
import
|
|
18
|
+
import { useFormField } from '../hooks/useFormField.svelte.js'
|
|
19
19
|
|
|
20
20
|
const config = getComponentConfig('input', inputDefaults)
|
|
21
21
|
const icons = getComponentConfig('icons', iconsDefaults)
|
|
@@ -45,15 +45,7 @@
|
|
|
45
45
|
...restProps
|
|
46
46
|
}: Props = $props()
|
|
47
47
|
|
|
48
|
-
const formFieldContext =
|
|
49
|
-
| {
|
|
50
|
-
name?: string
|
|
51
|
-
size: NonNullable<FormFieldProps['size']>
|
|
52
|
-
error?: string | boolean
|
|
53
|
-
ariaId: string
|
|
54
|
-
}
|
|
55
|
-
| undefined
|
|
56
|
-
>('formField')
|
|
48
|
+
const formFieldContext = useFormField()
|
|
57
49
|
|
|
58
50
|
const fieldGroupContext = getContext<
|
|
59
51
|
| {
|
|
@@ -6,10 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
<script lang="ts">
|
|
8
8
|
import { PinInput, useId } from 'bits-ui'
|
|
9
|
-
import { getContext } from 'svelte'
|
|
10
9
|
import { pinInputVariants, pinInputDefaults } from './pin-input.variants.js'
|
|
11
10
|
import { getComponentConfig } from '../config.js'
|
|
12
|
-
import
|
|
11
|
+
import { useFormField } from '../hooks/useFormField.svelte.js'
|
|
13
12
|
|
|
14
13
|
const config = getComponentConfig('pinInput', pinInputDefaults)
|
|
15
14
|
|
|
@@ -43,15 +42,7 @@
|
|
|
43
42
|
...restProps
|
|
44
43
|
}: Props = $props()
|
|
45
44
|
|
|
46
|
-
const formFieldContext =
|
|
47
|
-
| {
|
|
48
|
-
name?: string
|
|
49
|
-
size: NonNullable<FormFieldProps['size']>
|
|
50
|
-
error?: string | boolean
|
|
51
|
-
ariaId: string
|
|
52
|
-
}
|
|
53
|
-
| undefined
|
|
54
|
-
>('formField')
|
|
45
|
+
const formFieldContext = useFormField()
|
|
55
46
|
|
|
56
47
|
const autoInputId = useId()
|
|
57
48
|
const hasError = $derived(
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
import { RadioGroup, Label, useId } from 'bits-ui'
|
|
9
9
|
import { radioGroupVariants, radioGroupDefaults } from './radio-group.variants.js'
|
|
10
10
|
import { getComponentConfig, iconsDefaults } from '../config.js'
|
|
11
|
-
import { getContext } from 'svelte'
|
|
12
11
|
import Icon from '../Icon/Icon.svelte'
|
|
13
|
-
import
|
|
12
|
+
import { useFormField } from '../hooks/useFormField.svelte.js'
|
|
14
13
|
import type { RadioGroupItem } from './radio-group.types.js'
|
|
15
14
|
|
|
16
15
|
const config = getComponentConfig('radioGroup', radioGroupDefaults)
|
|
@@ -43,15 +42,7 @@
|
|
|
43
42
|
...restProps
|
|
44
43
|
}: Props = $props()
|
|
45
44
|
|
|
46
|
-
const formFieldContext =
|
|
47
|
-
| {
|
|
48
|
-
name?: string
|
|
49
|
-
size: NonNullable<FormFieldProps['size']>
|
|
50
|
-
error?: string | boolean
|
|
51
|
-
ariaId: string
|
|
52
|
-
}
|
|
53
|
-
| undefined
|
|
54
|
-
>('formField')
|
|
45
|
+
const formFieldContext = useFormField()
|
|
55
46
|
|
|
56
47
|
const hasError = $derived(
|
|
57
48
|
formFieldContext?.error !== undefined && formFieldContext?.error !== false
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import Icon from '../Icon/Icon.svelte'
|
|
17
17
|
import Avatar from '../Avatar/Avatar.svelte'
|
|
18
18
|
import type { AvatarSize } from '../Avatar/avatar.types.js'
|
|
19
|
-
import
|
|
19
|
+
import { useFormField } from '../hooks/useFormField.svelte.js'
|
|
20
20
|
|
|
21
21
|
const config = getComponentConfig('select', selectDefaults)
|
|
22
22
|
const icons = getComponentConfig('icons', iconsDefaults)
|
|
@@ -68,15 +68,7 @@
|
|
|
68
68
|
}: Props = $props()
|
|
69
69
|
|
|
70
70
|
// ---- Form context ----
|
|
71
|
-
const formFieldContext =
|
|
72
|
-
| {
|
|
73
|
-
name?: string
|
|
74
|
-
size: NonNullable<FormFieldProps['size']>
|
|
75
|
-
error?: string | boolean
|
|
76
|
-
ariaId: string
|
|
77
|
-
}
|
|
78
|
-
| undefined
|
|
79
|
-
>('formField')
|
|
71
|
+
const formFieldContext = useFormField()
|
|
80
72
|
|
|
81
73
|
const fieldGroupContext = getContext<
|
|
82
74
|
| {
|
|
@@ -26,7 +26,7 @@ export const selectVariants = tv({
|
|
|
26
26
|
'focus:outline-none',
|
|
27
27
|
'overflow-hidden'
|
|
28
28
|
],
|
|
29
|
-
viewport: 'p-1',
|
|
29
|
+
viewport: 'p-1 max-h-60 overflow-y-auto scrollbar-thin',
|
|
30
30
|
group: '',
|
|
31
31
|
groupLabel: 'px-2 py-1.5 text-xs font-semibold text-on-surface-variant',
|
|
32
32
|
item: [
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
import Avatar from '../Avatar/Avatar.svelte'
|
|
22
22
|
import Input from '../Input/Input.svelte'
|
|
23
23
|
import type { AvatarSize } from '../Avatar/avatar.types.js'
|
|
24
|
-
import
|
|
24
|
+
import { useFormField } from '../hooks/useFormField.svelte.js'
|
|
25
25
|
|
|
26
26
|
const config = getComponentConfig('selectMenu', selectMenuDefaults)
|
|
27
27
|
const icons = getComponentConfig('icons', iconsDefaults)
|
|
@@ -77,15 +77,7 @@
|
|
|
77
77
|
}: Props = $props()
|
|
78
78
|
|
|
79
79
|
// ---- Form context ----
|
|
80
|
-
const formFieldContext =
|
|
81
|
-
| {
|
|
82
|
-
name?: string
|
|
83
|
-
size: NonNullable<FormFieldProps['size']>
|
|
84
|
-
error?: string | boolean
|
|
85
|
-
ariaId: string
|
|
86
|
-
}
|
|
87
|
-
| undefined
|
|
88
|
-
>('formField')
|
|
80
|
+
const formFieldContext = useFormField()
|
|
89
81
|
|
|
90
82
|
const fieldGroupContext = getContext<
|
|
91
83
|
| {
|
|
@@ -14,7 +14,7 @@ export const selectMenuVariants = tv({
|
|
|
14
14
|
'flex flex-col'
|
|
15
15
|
],
|
|
16
16
|
input: 'border-b border-outline-variant',
|
|
17
|
-
viewport: 'p-1 flex-1 overflow-y-auto',
|
|
17
|
+
viewport: 'p-1 flex-1 overflow-y-auto scrollbar-thin',
|
|
18
18
|
empty: 'text-center text-on-surface-variant'
|
|
19
19
|
},
|
|
20
20
|
variants: {
|
|
@@ -6,10 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
<script lang="ts">
|
|
8
8
|
import { Slider, useId } from 'bits-ui'
|
|
9
|
-
import { getContext } from 'svelte'
|
|
10
9
|
import { sliderVariants, sliderDefaults } from './slider.variants.js'
|
|
11
10
|
import { getComponentConfig } from '../config.js'
|
|
12
|
-
import
|
|
11
|
+
import { useFormField } from '../hooks/useFormField.svelte.js'
|
|
13
12
|
|
|
14
13
|
const config = getComponentConfig('slider', sliderDefaults)
|
|
15
14
|
|
|
@@ -37,15 +36,7 @@
|
|
|
37
36
|
...restProps
|
|
38
37
|
}: Props = $props()
|
|
39
38
|
|
|
40
|
-
const formFieldContext =
|
|
41
|
-
| {
|
|
42
|
-
name?: string
|
|
43
|
-
size: NonNullable<FormFieldProps['size']>
|
|
44
|
-
error?: string | boolean
|
|
45
|
-
ariaId: string
|
|
46
|
-
}
|
|
47
|
-
| undefined
|
|
48
|
-
>('formField')
|
|
39
|
+
const formFieldContext = useFormField()
|
|
49
40
|
|
|
50
41
|
const autoId = useId()
|
|
51
42
|
const hasError = $derived(
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
import { Switch, Label, useId } from 'bits-ui'
|
|
9
9
|
import { switchVariants, switchDefaults } from './switch.variants.js'
|
|
10
10
|
import { getComponentConfig, iconsDefaults } from '../config.js'
|
|
11
|
-
import { getContext } from 'svelte'
|
|
12
11
|
import Icon from '../Icon/Icon.svelte'
|
|
13
|
-
import
|
|
12
|
+
import { useFormField } from '../hooks/useFormField.svelte.js'
|
|
14
13
|
|
|
15
14
|
const config = getComponentConfig('switch', switchDefaults)
|
|
16
15
|
const icons = getComponentConfig('icons', iconsDefaults)
|
|
@@ -39,15 +38,7 @@
|
|
|
39
38
|
...restProps
|
|
40
39
|
}: Props = $props()
|
|
41
40
|
|
|
42
|
-
const formFieldContext =
|
|
43
|
-
| {
|
|
44
|
-
name?: string
|
|
45
|
-
size: NonNullable<FormFieldProps['size']>
|
|
46
|
-
error?: string | boolean
|
|
47
|
-
ariaId: string
|
|
48
|
-
}
|
|
49
|
-
| undefined
|
|
50
|
-
>('formField')
|
|
41
|
+
const formFieldContext = useFormField()
|
|
51
42
|
|
|
52
43
|
const hasError = $derived(
|
|
53
44
|
formFieldContext?.error !== undefined && formFieldContext?.error !== false
|