svelte-ant-design 0.2.1 → 0.4.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 CHANGED
@@ -18,7 +18,7 @@ Ant Design.
18
18
 
19
19
  ## Status
20
20
 
21
- Version `0.2.1`. Available components: `Button`, `Switch`. More components are planned.
21
+ Version `0.4.0`. Available components: `Button`, `Checkbox` (with `CheckboxGroup`), `Input` (with `InputTextArea`, `InputPassword`, `InputSearch` and `InputOTP`), `Switch`. More components are planned.
22
22
 
23
23
  ## Installation
24
24
 
@@ -49,24 +49,28 @@ Import components by name. The package is ESM and declares `sideEffects: ["**/*.
49
49
  bundler that supports tree shaking leaves out the components you do not use. This is checked with
50
50
  Vite in `tests/packaging`; other bundlers are not covered.
51
51
 
52
- See the [Button](https://prostreyd.github.io/ant-design-svelte/components/button/) and
52
+ See the [Button](https://prostreyd.github.io/ant-design-svelte/components/button/),
53
+ [Checkbox](https://prostreyd.github.io/ant-design-svelte/components/checkbox/),
54
+ [Input](https://prostreyd.github.io/ant-design-svelte/components/input/) and
53
55
  [Switch](https://prostreyd.github.io/ant-design-svelte/components/switch/) pages of the documentation site for
54
- examples and the API tables, or [`src/lib/Button/README.md`](./src/lib/Button/README.md) and
56
+ examples and the API tables, or [`src/lib/Button/README.md`](./src/lib/Button/README.md),
57
+ [`src/lib/Checkbox/README.md`](./src/lib/Checkbox/README.md),
58
+ [`src/lib/Input/README.md`](./src/lib/Input/README.md) and
55
59
  [`src/lib/Switch/README.md`](./src/lib/Switch/README.md) in the repository.
56
60
 
57
61
  ### Colors and contrast
58
62
 
59
63
  In the light theme the colors are the values of the Ant Design token documentation, so the components look
60
64
  like Ant Design. Those values do not reach WCAG AA for text: white on the primary fill is 4.10:1 and on the
61
- danger fill 3.27:1 (4.5:1 is needed), and the off track of a switch is 1.84:1 against a white page (3:1 is
62
- needed). For a contrast guarantee import one more file after the tokens:
65
+ danger fill 3.27:1 (4.5:1 is needed), the off track of a switch is 1.84:1 against a white page and the border of
66
+ an unchecked checkbox or the border of an input 1.41:1 (3:1 is needed). For a contrast guarantee import one more file after the tokens:
63
67
 
64
68
  ```ts
65
69
  import 'svelte-ant-design/tokens.css';
66
70
  import 'svelte-ant-design/tokens-accessible.css';
67
71
  ```
68
72
 
69
- It darkens the fills, the link and text colors and the switch tracks; every text pair is then at least 4.5:1.
73
+ It darkens the fills, the link and text colors, the switch tracks, the checkbox border and the input border, placeholder and count; every text pair is then at least 4.5:1.
70
74
  The dark theme needs no extra file. The contrast tests run with the accessible file.
71
75
 
72
76
  ### Dark theme
@@ -0,0 +1,324 @@
1
+ <script lang="ts">
2
+ import { onDestroy, type Snippet } from 'svelte';
3
+ import type { HTMLInputAttributes } from 'svelte/elements';
4
+ import type { CheckboxClassNames, CheckboxStyles, CheckboxValue } from './types.js';
5
+ import { getCheckboxGroup } from './context.js';
6
+ import { isProduction } from '../internal/env.js';
7
+ import { classList, styleText } from '../internal/semantic.js';
8
+
9
+ type CheckboxProps = Omit<
10
+ HTMLInputAttributes,
11
+ | 'children'
12
+ | 'class'
13
+ | 'style'
14
+ | 'type'
15
+ | 'checked'
16
+ | 'indeterminate'
17
+ | 'value'
18
+ | 'disabled'
19
+ | 'name'
20
+ | 'title'
21
+ | 'onchange'
22
+ > & {
23
+ /**
24
+ * Whether the checkbox is checked. Use `bind:checked` for two-way binding. Inside a
25
+ * `CheckboxGroup` the state comes from the group's `value` and this prop is ignored.
26
+ */
27
+ checked?: boolean;
28
+ /**
29
+ * The "partly checked" look of a "check all" control. It changes only the appearance and the
30
+ * state assistive technology reads (`mixed`); `checked` stays the value that is reported.
31
+ */
32
+ indeterminate?: boolean;
33
+ /** Whether the checkbox is disabled. A group's `disabled` applies as well. */
34
+ disabled?: boolean;
35
+ /** Identity inside a `CheckboxGroup` and the native `value` of the input. */
36
+ value?: CheckboxValue;
37
+ /** Native `name` of the input. Inside a group the group's `name` wins. */
38
+ name?: string;
39
+ /** Label content; it is the accessible name of the checkbox. */
40
+ children?: Snippet;
41
+ /** Called once per user toggle, after the state changed, with the new value and the native `change` event. */
42
+ onchange?: (checked: boolean, event: Event) => void;
43
+ /** Extra classes for the `root`, `icon` and `label` parts. */
44
+ classNames?: CheckboxClassNames;
45
+ /** Inline styles for the `root`, `icon` and `label` parts. */
46
+ styles?: CheckboxStyles;
47
+ /** Additional CSS class appended to the root classes. */
48
+ class?: string;
49
+ /** Inline style of the root; `styles.root` is applied after it. */
50
+ style?: string;
51
+ /** Native `title` of the root label, so the tooltip covers the box and the text. */
52
+ title?: string;
53
+ };
54
+
55
+ let {
56
+ checked = $bindable(false),
57
+ indeterminate = false,
58
+ disabled = false,
59
+ value = undefined,
60
+ name = undefined,
61
+ children,
62
+ onchange,
63
+ classNames,
64
+ styles,
65
+ class: customClass,
66
+ style: customStyle,
67
+ title = undefined,
68
+ ...rest
69
+ }: CheckboxProps = $props();
70
+
71
+ const group = getCheckboxGroup();
72
+
73
+ // A checkbox takes part in its group only with a value: the group tells the items apart by it.
74
+ // Without one it keeps its own state (and throws while developing, so the mistake is found early).
75
+ const member = $derived.by(() => {
76
+ if (!group) return false;
77
+ if (value !== undefined) return true;
78
+ if (!isProduction()) throw new TypeError('Checkbox inside a CheckboxGroup needs a value.');
79
+ return false;
80
+ });
81
+
82
+ // Registered in the order of mounting, which is the order of the values of the group.
83
+ if (group) onDestroy(group.register(() => value));
84
+
85
+ let input: HTMLInputElement | undefined = $state();
86
+
87
+ const isChecked = $derived(member ? group!.isChecked(value!) : checked);
88
+ const isDisabled = $derived(disabled || Boolean(group?.disabled));
89
+ const inputName = $derived(group?.name ?? name);
90
+
91
+ const rootClass = $derived(
92
+ classList(
93
+ 'ads-checkbox',
94
+ isChecked && 'ads-checkbox-checked',
95
+ indeterminate && 'ads-checkbox-indeterminate',
96
+ isDisabled && 'ads-checkbox-disabled',
97
+ customClass,
98
+ classNames?.root,
99
+ group?.classNames?.item
100
+ )
101
+ );
102
+ const iconClass = $derived(classList('ads-checkbox-icon', classNames?.icon, group?.classNames?.itemIcon));
103
+ const labelClass = $derived(
104
+ classList('ads-checkbox-label', classNames?.label, group?.classNames?.itemLabel)
105
+ );
106
+
107
+ const rootStyle = $derived(styleText(group?.styles?.item, customStyle, styles?.root));
108
+ const iconStyle = $derived(styleText(group?.styles?.itemIcon, styles?.icon));
109
+ const labelStyle = $derived(styleText(group?.styles?.itemLabel, styles?.label));
110
+
111
+ // A native form reset puts the input back to its default checkedness behind the state's back (it leaves
112
+ // `indeterminate` alone). The state is the truth (the parent resets it in `onreset`), so the view is
113
+ // restored to it once the reset has run.
114
+ $effect(() => {
115
+ const form = input?.form;
116
+ if (!form) return;
117
+ const restore = () => {
118
+ setTimeout(() => {
119
+ if (!input) return;
120
+ input.checked = isChecked;
121
+ });
122
+ };
123
+ form.addEventListener('reset', restore);
124
+ return () => form.removeEventListener('reset', restore);
125
+ });
126
+
127
+ function handleChange(event: Event): void {
128
+ const target = event.currentTarget as HTMLInputElement;
129
+ const next = target.checked;
130
+ if (member) {
131
+ onchange?.(next, event);
132
+ group!.toggle(value!, next, event);
133
+ } else {
134
+ checked = next;
135
+ onchange?.(next, event);
136
+ }
137
+ // The input owns its state. Writing the props back reverts a change the parent refused
138
+ // (function binding) and restores the indeterminate flag, which the browser clears on a click.
139
+ target.checked = isChecked;
140
+ target.indeterminate = indeterminate;
141
+ }
142
+
143
+ /** Moves focus to the checkbox. */
144
+ export function focus(options?: FocusOptions): void {
145
+ input?.focus(options);
146
+ }
147
+
148
+ /** Removes focus from the checkbox. */
149
+ export function blur(): void {
150
+ input?.blur();
151
+ }
152
+ </script>
153
+
154
+ <!--
155
+ A native input inside a label: the role, the checked and mixed states, Space, the Tab order, the
156
+ click on the text and form participation come from the platform. The input is laid over the
157
+ box, invisible, so the focus ring and the hit area are those of a real control.
158
+ -->
159
+ <label class={rootClass} style={rootStyle} {title}>
160
+ <span class="ads-checkbox-control">
161
+ <input
162
+ {...rest}
163
+ bind:this={input}
164
+ type="checkbox"
165
+ class="ads-checkbox-input"
166
+ checked={isChecked}
167
+ {indeterminate}
168
+ disabled={isDisabled}
169
+ name={inputName}
170
+ value={value ?? 'on'}
171
+ onchange={handleChange}
172
+ />
173
+ <span class={iconClass} style={iconStyle} aria-hidden="true"></span>
174
+ </span>
175
+ {#if children}
176
+ <span class={labelClass} style={labelStyle}>{@render children()}</span>
177
+ {/if}
178
+ </label>
179
+
180
+ <style>
181
+ /*
182
+ * The states only set the private `--_*` variables; the rules that paint the box read them, so
183
+ * checked, indeterminate, hover and disabled combine without fighting over specificity. The
184
+ * colors come from the `--ads-checkbox-*` tokens. Positions use logical properties, so the
185
+ * checkbox mirrors in right-to-left layouts.
186
+ */
187
+ .ads-checkbox {
188
+ --_size: var(--ads-checkbox-size);
189
+ --_border: var(--ads-checkbox-border);
190
+ --_bg: var(--ads-checkbox-bg);
191
+ --_mark: var(--ads-checkbox-check-color);
192
+ --_bar: var(--ads-checkbox-indeterminate-color);
193
+
194
+ position: relative;
195
+ display: inline-flex;
196
+ align-items: flex-start;
197
+ box-sizing: border-box;
198
+ margin: 0;
199
+ color: var(--ads-color-text);
200
+ font-family: var(--ads-font-family);
201
+ font-size: var(--ads-checkbox-font-size);
202
+ line-height: var(--ads-checkbox-line-height);
203
+ cursor: pointer;
204
+ }
205
+
206
+ .ads-checkbox-control {
207
+ position: relative;
208
+ flex: none;
209
+ width: var(--_size);
210
+ height: var(--_size);
211
+ /* Centered in the first line of the text, so a multi-line label keeps the box at the top. */
212
+ margin-block: calc(
213
+ (var(--ads-checkbox-line-height) * var(--ads-checkbox-font-size) - var(--_size)) / 2
214
+ );
215
+ }
216
+
217
+ .ads-checkbox-input {
218
+ position: absolute;
219
+ inset: 0;
220
+ z-index: 1;
221
+ box-sizing: border-box;
222
+ width: 100%;
223
+ height: 100%;
224
+ margin: 0;
225
+ padding: 0;
226
+ opacity: 0;
227
+ cursor: inherit;
228
+ }
229
+
230
+ .ads-checkbox-icon {
231
+ position: absolute;
232
+ inset: 0;
233
+ box-sizing: border-box;
234
+ border: var(--ads-checkbox-border-width) solid var(--_border);
235
+ border-radius: var(--ads-checkbox-radius);
236
+ background-color: var(--_bg);
237
+ transition:
238
+ border-color var(--ads-motion-duration-fast) var(--ads-motion-ease),
239
+ background-color var(--ads-motion-duration-fast) var(--ads-motion-ease);
240
+ }
241
+
242
+ /* The check mark is a rotated corner, drawn with borders; the indeterminate bar reuses the same box. */
243
+ .ads-checkbox-icon::after {
244
+ content: '';
245
+ position: absolute;
246
+ top: 50%;
247
+ left: 50%;
248
+ box-sizing: border-box;
249
+ width: calc(var(--_size) * 0.3125);
250
+ height: calc(var(--_size) * 0.5625);
251
+ border: solid var(--_mark);
252
+ border-width: 0 var(--ads-checkbox-check-width) var(--ads-checkbox-check-width) 0;
253
+ transform: translate(-50%, -58%) rotate(45deg) scale(0);
254
+ opacity: 0;
255
+ transition:
256
+ opacity var(--ads-motion-duration-fast) var(--ads-motion-ease),
257
+ transform var(--ads-motion-duration-slow) var(--ads-motion-ease-out-back);
258
+ }
259
+
260
+ .ads-checkbox-checked .ads-checkbox-icon {
261
+ --_border: var(--ads-checkbox-checked-bg);
262
+ --_bg: var(--ads-checkbox-checked-bg);
263
+ }
264
+
265
+ .ads-checkbox-checked .ads-checkbox-icon::after {
266
+ transform: translate(-50%, -58%) rotate(45deg) scale(1);
267
+ opacity: 1;
268
+ }
269
+
270
+ /* The bar replaces the check mark whatever the checked state. */
271
+ .ads-checkbox-indeterminate .ads-checkbox-icon {
272
+ --_border: var(--ads-checkbox-border);
273
+ --_bg: var(--ads-checkbox-bg);
274
+ }
275
+
276
+ .ads-checkbox-indeterminate .ads-checkbox-icon::after {
277
+ width: calc(var(--_size) / 2);
278
+ height: calc(var(--_size) / 2);
279
+ border: 0;
280
+ background-color: var(--_bar);
281
+ transform: translate(-50%, -50%);
282
+ opacity: 1;
283
+ }
284
+
285
+ /* Hover anywhere over the label, box or text. */
286
+ .ads-checkbox:not(.ads-checkbox-disabled):hover .ads-checkbox-icon {
287
+ --_border: var(--ads-checkbox-border-hover);
288
+ }
289
+
290
+ .ads-checkbox-checked:not(.ads-checkbox-disabled, .ads-checkbox-indeterminate):hover
291
+ .ads-checkbox-icon {
292
+ --_border: var(--ads-checkbox-checked-bg-hover);
293
+ --_bg: var(--ads-checkbox-checked-bg-hover);
294
+ }
295
+
296
+ .ads-checkbox-input:focus-visible + .ads-checkbox-icon {
297
+ outline: var(--ads-focus-outline-width) solid var(--ads-color-focus-outline);
298
+ outline-offset: var(--ads-focus-outline-offset);
299
+ }
300
+
301
+ .ads-checkbox-label {
302
+ padding-inline: var(--ads-checkbox-label-padding);
303
+ }
304
+
305
+ /* Last, so the disabled colors win over the checked and indeterminate ones. */
306
+ .ads-checkbox-disabled {
307
+ color: var(--ads-color-text-disabled);
308
+ cursor: not-allowed;
309
+ }
310
+
311
+ .ads-checkbox-disabled .ads-checkbox-icon {
312
+ --_border: var(--ads-checkbox-disabled-border);
313
+ --_bg: var(--ads-checkbox-disabled-bg);
314
+ --_mark: var(--ads-checkbox-disabled-check-color);
315
+ --_bar: var(--ads-checkbox-disabled-check-color);
316
+ }
317
+
318
+ @media (prefers-reduced-motion: reduce) {
319
+ .ads-checkbox-icon,
320
+ .ads-checkbox-icon::after {
321
+ transition: none;
322
+ }
323
+ }
324
+ </style>
@@ -0,0 +1,41 @@
1
+ import { type Snippet } from 'svelte';
2
+ import type { HTMLInputAttributes } from 'svelte/elements';
3
+ import type { CheckboxClassNames, CheckboxStyles, CheckboxValue } from './types.js';
4
+ type CheckboxProps = Omit<HTMLInputAttributes, 'children' | 'class' | 'style' | 'type' | 'checked' | 'indeterminate' | 'value' | 'disabled' | 'name' | 'title' | 'onchange'> & {
5
+ /**
6
+ * Whether the checkbox is checked. Use `bind:checked` for two-way binding. Inside a
7
+ * `CheckboxGroup` the state comes from the group's `value` and this prop is ignored.
8
+ */
9
+ checked?: boolean;
10
+ /**
11
+ * The "partly checked" look of a "check all" control. It changes only the appearance and the
12
+ * state assistive technology reads (`mixed`); `checked` stays the value that is reported.
13
+ */
14
+ indeterminate?: boolean;
15
+ /** Whether the checkbox is disabled. A group's `disabled` applies as well. */
16
+ disabled?: boolean;
17
+ /** Identity inside a `CheckboxGroup` and the native `value` of the input. */
18
+ value?: CheckboxValue;
19
+ /** Native `name` of the input. Inside a group the group's `name` wins. */
20
+ name?: string;
21
+ /** Label content; it is the accessible name of the checkbox. */
22
+ children?: Snippet;
23
+ /** Called once per user toggle, after the state changed, with the new value and the native `change` event. */
24
+ onchange?: (checked: boolean, event: Event) => void;
25
+ /** Extra classes for the `root`, `icon` and `label` parts. */
26
+ classNames?: CheckboxClassNames;
27
+ /** Inline styles for the `root`, `icon` and `label` parts. */
28
+ styles?: CheckboxStyles;
29
+ /** Additional CSS class appended to the root classes. */
30
+ class?: string;
31
+ /** Inline style of the root; `styles.root` is applied after it. */
32
+ style?: string;
33
+ /** Native `title` of the root label, so the tooltip covers the box and the text. */
34
+ title?: string;
35
+ };
36
+ declare const Checkbox: import("svelte").Component<CheckboxProps, {
37
+ focus: (options?: FocusOptions) => void;
38
+ blur: () => void;
39
+ }, "checked">;
40
+ type Checkbox = ReturnType<typeof Checkbox>;
41
+ export default Checkbox;
@@ -0,0 +1,146 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+ import type {
5
+ CheckboxGroupClassNames,
6
+ CheckboxGroupStyles,
7
+ CheckboxOption,
8
+ CheckboxValue
9
+ } from './types.js';
10
+ import Checkbox from './Checkbox.svelte';
11
+ import { setCheckboxGroup } from './context.js';
12
+ import { classList, styleText } from '../internal/semantic.js';
13
+
14
+ type CheckboxGroupProps = Omit<
15
+ HTMLAttributes<HTMLDivElement>,
16
+ 'children' | 'class' | 'style' | 'role' | 'onchange'
17
+ > & {
18
+ /** The selected values. Use `bind:value` for two-way binding. */
19
+ value?: CheckboxValue[];
20
+ /** Renders one checkbox per entry. A string or a number is both the value and the label. */
21
+ options?: ReadonlyArray<CheckboxValue | CheckboxOption>;
22
+ /** Custom markup with `Checkbox` elements inside; ignored when `options` has entries. */
23
+ children?: Snippet;
24
+ /** Disables every checkbox of the group. */
25
+ disabled?: boolean;
26
+ /** Native `name` of every input of the group. */
27
+ name?: string;
28
+ /** Called once per user toggle with the new array and the `change` event of the toggled input. */
29
+ onchange?: (value: CheckboxValue[], event: Event) => void;
30
+ /** Extra classes for the `root`, `item`, `itemIcon` and `itemLabel` parts. */
31
+ classNames?: CheckboxGroupClassNames;
32
+ /** Inline styles for the `root`, `item`, `itemIcon` and `itemLabel` parts. */
33
+ styles?: CheckboxGroupStyles;
34
+ /** Additional CSS class appended to the root classes. */
35
+ class?: string;
36
+ /** Inline style of the root; `styles.root` is applied after it. */
37
+ style?: string;
38
+ };
39
+
40
+ let {
41
+ value = $bindable([]),
42
+ options = [],
43
+ children,
44
+ disabled = false,
45
+ name = undefined,
46
+ onchange,
47
+ classNames,
48
+ styles,
49
+ class: customClass,
50
+ style: customStyle,
51
+ ...rest
52
+ }: CheckboxGroupProps = $props();
53
+
54
+ const normalized = $derived<CheckboxOption[]>(
55
+ options.map((option) =>
56
+ typeof option === 'object' ? option : { label: String(option), value: option }
57
+ )
58
+ );
59
+ const hasOptions = $derived(normalized.length > 0);
60
+
61
+ // The checkboxes inside, in the order of mounting; with `options` their order is the options' order.
62
+ let registered: Array<() => CheckboxValue | undefined> = [];
63
+
64
+ /** The place of a value among the options or the mounted checkboxes; -1 for an unknown value. */
65
+ function orderOf(item: CheckboxValue): number {
66
+ if (hasOptions) return normalized.findIndex((option) => option.value === item);
67
+ return registered.findIndex((read) => read() === item);
68
+ }
69
+
70
+ /** Known values in their order, then the unknown ones in the order they had. */
71
+ function sorted(values: CheckboxValue[]): CheckboxValue[] {
72
+ const known = values.filter((item) => orderOf(item) >= 0).sort((a, b) => orderOf(a) - orderOf(b));
73
+ const unknown = values.filter((item) => orderOf(item) < 0);
74
+ return [...known, ...unknown];
75
+ }
76
+
77
+ function toggle(item: CheckboxValue, checked: boolean, event: Event): void {
78
+ const current = value;
79
+ const next = checked
80
+ ? current.includes(item)
81
+ ? current
82
+ : [...current, item]
83
+ : current.filter((other) => other !== item);
84
+ const ordered = sorted(next);
85
+ value = ordered;
86
+ onchange?.(ordered, event);
87
+ }
88
+
89
+ setCheckboxGroup({
90
+ isChecked: (item) => value.includes(item),
91
+ get disabled() {
92
+ return disabled;
93
+ },
94
+ get name() {
95
+ return name;
96
+ },
97
+ get classNames() {
98
+ return classNames;
99
+ },
100
+ get styles() {
101
+ return styles;
102
+ },
103
+ toggle,
104
+ register(read) {
105
+ registered = [...registered, read];
106
+ return () => {
107
+ registered = registered.filter((other) => other !== read);
108
+ };
109
+ }
110
+ });
111
+
112
+ const rootClass = $derived(classList('ads-checkbox-group', customClass, classNames?.root));
113
+ const rootStyle = $derived(styleText(customStyle, styles?.root));
114
+ </script>
115
+
116
+ <div {...rest} role="group" class={rootClass} style={rootStyle}>
117
+ {#if hasOptions}
118
+ {#each normalized as option (option.value)}
119
+ <Checkbox
120
+ value={option.value}
121
+ disabled={option.disabled}
122
+ title={option.title}
123
+ class={option.class}
124
+ style={option.style}
125
+ onchange={option.onchange}
126
+ >
127
+ {#if typeof option.label === 'string'}{option.label}{:else}{@render option.label()}{/if}
128
+ </Checkbox>
129
+ {/each}
130
+ {:else}
131
+ {@render children?.()}
132
+ {/if}
133
+ </div>
134
+
135
+ <style>
136
+ .ads-checkbox-group {
137
+ display: inline-flex;
138
+ flex-wrap: wrap;
139
+ column-gap: var(--ads-checkbox-group-gap);
140
+ box-sizing: border-box;
141
+ color: var(--ads-color-text);
142
+ font-family: var(--ads-font-family);
143
+ font-size: var(--ads-checkbox-font-size);
144
+ line-height: var(--ads-checkbox-line-height);
145
+ }
146
+ </style>
@@ -0,0 +1,28 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import type { CheckboxGroupClassNames, CheckboxGroupStyles, CheckboxOption, CheckboxValue } from './types.js';
4
+ type CheckboxGroupProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class' | 'style' | 'role' | 'onchange'> & {
5
+ /** The selected values. Use `bind:value` for two-way binding. */
6
+ value?: CheckboxValue[];
7
+ /** Renders one checkbox per entry. A string or a number is both the value and the label. */
8
+ options?: ReadonlyArray<CheckboxValue | CheckboxOption>;
9
+ /** Custom markup with `Checkbox` elements inside; ignored when `options` has entries. */
10
+ children?: Snippet;
11
+ /** Disables every checkbox of the group. */
12
+ disabled?: boolean;
13
+ /** Native `name` of every input of the group. */
14
+ name?: string;
15
+ /** Called once per user toggle with the new array and the `change` event of the toggled input. */
16
+ onchange?: (value: CheckboxValue[], event: Event) => void;
17
+ /** Extra classes for the `root`, `item`, `itemIcon` and `itemLabel` parts. */
18
+ classNames?: CheckboxGroupClassNames;
19
+ /** Inline styles for the `root`, `item`, `itemIcon` and `itemLabel` parts. */
20
+ styles?: CheckboxGroupStyles;
21
+ /** Additional CSS class appended to the root classes. */
22
+ class?: string;
23
+ /** Inline style of the root; `styles.root` is applied after it. */
24
+ style?: string;
25
+ };
26
+ declare const CheckboxGroup: import("svelte").Component<CheckboxGroupProps, {}, "value">;
27
+ type CheckboxGroup = ReturnType<typeof CheckboxGroup>;
28
+ export default CheckboxGroup;