@svelte-atoms/core 1.0.0-alpha.33 → 1.0.0-alpha.34
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/dist/components/atom/html-atom.svelte +95 -93
- package/dist/components/atom/html-atom.svelte.d.ts +1 -1
- package/dist/components/button/button.svelte +31 -31
- package/dist/components/chip/chip.svelte +41 -0
- package/dist/components/chip/chip.svelte.d.ts +6 -0
- package/dist/components/chip/index.d.ts +1 -0
- package/dist/components/chip/index.js +1 -0
- package/dist/components/chip/types.d.ts +11 -0
- package/dist/components/chip/types.js +1 -0
- package/dist/components/combobox/atoms.d.ts +2 -1
- package/dist/components/combobox/atoms.js +2 -1
- package/dist/components/combobox/bond.svelte.d.ts +16 -13
- package/dist/components/combobox/bond.svelte.js +57 -13
- package/dist/components/combobox/combobox-control.svelte +27 -13
- package/dist/components/combobox/combobox-control.svelte.d.ts +2 -10
- package/dist/components/combobox/combobox-item.svelte +3 -3
- package/dist/components/combobox/combobox-root.svelte +65 -65
- package/dist/components/combobox/combobox-root.svelte.d.ts +4 -4
- package/dist/components/combobox/combobox-selections.svelte +17 -0
- package/dist/components/combobox/combobox-selections.svelte.d.ts +4 -0
- package/dist/components/combobox/combobox.stories.svelte +25 -12
- package/dist/components/combobox/types.d.ts +17 -3
- package/dist/components/dropdown/atoms.d.ts +2 -3
- package/dist/components/dropdown/atoms.js +3 -3
- package/dist/components/dropdown/bond.svelte.d.ts +4 -4
- package/dist/components/dropdown/bond.svelte.js +10 -11
- package/dist/components/dropdown/dropdown-query.svelte +43 -54
- package/dist/components/dropdown/dropdown-query.svelte.d.ts +3 -34
- package/dist/components/dropdown/dropdown-root.svelte +15 -2
- package/dist/components/dropdown/dropdown-root.svelte.d.ts +4 -16
- package/dist/components/dropdown/dropdown-selection.svelte +55 -0
- package/dist/components/dropdown/{dropdown-value.svelte.d.ts → dropdown-selection.svelte.d.ts} +5 -15
- package/dist/components/dropdown/dropdown-selections.svelte +62 -0
- package/dist/components/dropdown/dropdown-selections.svelte.d.ts +5 -0
- package/dist/components/dropdown/dropdown.stories.svelte +93 -49
- package/dist/components/dropdown/index.d.ts +5 -1
- package/dist/components/dropdown/index.js +5 -1
- package/dist/components/dropdown/item/controller.svelte.d.ts +1 -1
- package/dist/components/dropdown/item/controller.svelte.js +2 -2
- package/dist/components/dropdown/item/dropdown-item.svelte +0 -2
- package/dist/components/dropdown/runes.svelte.d.ts +6 -2
- package/dist/components/dropdown/runes.svelte.js +1 -1
- package/dist/components/dropdown/types.d.ts +34 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/menu/bond.svelte.js +4 -2
- package/dist/components/menu/item/controller.svelte.d.ts +1 -0
- package/dist/components/menu/item/controller.svelte.js +5 -0
- package/dist/components/popover/bond.svelte.js +1 -2
- package/dist/components/root/root.css +119 -119
- package/dist/components/stepper/README.md +38 -0
- package/dist/components/stepper/atoms.d.ts +5 -0
- package/dist/components/stepper/atoms.js +5 -0
- package/dist/components/stepper/attachments.svelte.d.ts +2 -0
- package/dist/components/stepper/attachments.svelte.js +5 -0
- package/dist/components/stepper/bond.svelte.d.ts +56 -0
- package/dist/components/stepper/bond.svelte.js +99 -0
- package/dist/components/stepper/index.d.ts +3 -0
- package/dist/components/stepper/index.js +3 -0
- package/dist/components/stepper/step/README.md +97 -0
- package/dist/components/stepper/step/atoms.d.ts +7 -0
- package/dist/components/stepper/step/atoms.js +7 -0
- package/dist/components/stepper/step/attachments.svelte.d.ts +2 -0
- package/dist/components/stepper/step/attachments.svelte.js +5 -0
- package/dist/components/stepper/step/bond.svelte.d.ts +99 -0
- package/dist/components/stepper/step/bond.svelte.js +153 -0
- package/dist/components/stepper/step/index.d.ts +3 -0
- package/dist/components/stepper/step/index.js +2 -0
- package/dist/components/stepper/step/step-body.svelte +39 -0
- package/dist/components/stepper/step/step-body.svelte.d.ts +26 -0
- package/dist/components/stepper/step/step-description.svelte +33 -0
- package/dist/components/stepper/step/step-description.svelte.d.ts +26 -0
- package/dist/components/stepper/step/step-header.svelte +34 -0
- package/dist/components/stepper/step/step-header.svelte.d.ts +26 -0
- package/dist/components/stepper/step/step-indicator.svelte +63 -0
- package/dist/components/stepper/step/step-indicator.svelte.d.ts +26 -0
- package/dist/components/stepper/step/step-root.svelte +42 -0
- package/dist/components/stepper/step/step-root.svelte.d.ts +31 -0
- package/dist/components/stepper/step/step-separator.svelte +48 -0
- package/dist/components/stepper/step/step-separator.svelte.d.ts +26 -0
- package/dist/components/stepper/step/step-title.svelte +33 -0
- package/dist/components/stepper/step/step-title.svelte.d.ts +26 -0
- package/dist/components/stepper/step/types.d.ts +91 -0
- package/dist/components/stepper/step/types.js +1 -0
- package/dist/components/stepper/stepper-body.svelte +43 -0
- package/dist/components/stepper/stepper-body.svelte.d.ts +26 -0
- package/dist/components/stepper/stepper-content.svelte +45 -0
- package/dist/components/stepper/stepper-content.svelte.d.ts +26 -0
- package/dist/components/stepper/stepper-footer.svelte +31 -0
- package/dist/components/stepper/stepper-footer.svelte.d.ts +26 -0
- package/dist/components/stepper/stepper-header.svelte +39 -0
- package/dist/components/stepper/stepper-header.svelte.d.ts +26 -0
- package/dist/components/stepper/stepper-root.svelte +60 -0
- package/dist/components/stepper/stepper-root.svelte.d.ts +31 -0
- package/dist/components/stepper/stepper.stories.svelte +264 -0
- package/dist/components/stepper/stepper.stories.svelte.d.ts +4 -0
- package/dist/components/stepper/types.d.ts +63 -0
- package/dist/components/stepper/types.js +1 -0
- package/dist/components/tabs/atoms.d.ts +1 -0
- package/dist/components/tabs/atoms.js +1 -0
- package/dist/components/tabs/bond.svelte.d.ts +18 -5
- package/dist/components/tabs/bond.svelte.js +13 -0
- package/dist/components/tabs/tab/bond.svelte.d.ts +7 -7
- package/dist/components/tabs/tab/bond.svelte.js +9 -15
- package/dist/components/tabs/tab/tab-body.svelte +43 -52
- package/dist/components/tabs/tab/tab-description.svelte +33 -41
- package/dist/components/tabs/tab/tab-header.svelte +61 -71
- package/dist/components/tabs/tab/tab-header.svelte.d.ts +1 -1
- package/dist/components/tabs/tab/tab-root.svelte +51 -86
- package/dist/components/tabs/tab/tab-root.svelte.d.ts +1 -7
- package/dist/components/tabs/tabs-body.svelte +35 -41
- package/dist/components/tabs/tabs-body.svelte.d.ts +2 -11
- package/dist/components/tabs/tabs-content.svelte +51 -0
- package/dist/components/tabs/tabs-content.svelte.d.ts +26 -0
- package/dist/components/tabs/tabs-header.svelte +32 -40
- package/dist/components/tabs/tabs-header.svelte.d.ts +2 -10
- package/dist/components/tabs/tabs-root.svelte +55 -66
- package/dist/components/tabs/tabs-root.svelte.d.ts +5 -16
- package/dist/components/tabs/tabs.stories.svelte +70 -56
- package/dist/components/tabs/types.d.ts +24 -29
- package/dist/context/preset.svelte.d.ts +1 -1
- package/package.json +33 -6
- package/dist/components/dropdown/dropdown-value.svelte +0 -60
- package/dist/components/dropdown/dropdown-values.svelte +0 -17
- package/dist/components/dropdown/dropdown-values.svelte.d.ts +0 -5
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
<script lang="ts" generics="D">
|
|
2
|
-
import type { ComboboxRootProps } from './types';
|
|
3
|
-
import { defineProperty, defineState } from '../../utils';
|
|
4
|
-
import { ComboboxBond, ComboboxBondState, type ComboboxBondProps } from './bond.svelte';
|
|
5
|
-
|
|
6
|
-
let {
|
|
7
|
-
open = $bindable(false),
|
|
8
|
-
value = $bindable(),
|
|
9
|
-
values = $bindable(),
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
multiple = false,
|
|
13
|
-
disabled = false,
|
|
14
|
-
placements = ['bottom-start', 'bottom-end', 'top-start', 'top-end'],
|
|
15
|
-
placement = 'bottom-start',
|
|
16
|
-
offset = 1,
|
|
17
|
-
factory = _factory,
|
|
18
|
-
children = undefined,
|
|
19
|
-
...restProps
|
|
20
|
-
}: ComboboxRootProps = $props();
|
|
21
|
-
|
|
22
|
-
const bondProps = defineState<ComboboxBondProps>(
|
|
23
|
-
[
|
|
24
|
-
defineProperty(
|
|
25
|
-
'open',
|
|
26
|
-
() => open,
|
|
27
|
-
(v) => {
|
|
28
|
-
open = v;
|
|
29
|
-
}
|
|
30
|
-
),
|
|
31
|
-
defineProperty(
|
|
32
|
-
'values',
|
|
33
|
-
() => (multiple ? values : [value]),
|
|
34
|
-
(v) => {
|
|
35
|
-
values = v;
|
|
36
|
-
value = v[0];
|
|
37
|
-
}
|
|
38
|
-
),
|
|
39
|
-
defineProperty(
|
|
40
|
-
'
|
|
41
|
-
() =>
|
|
42
|
-
(v) => (
|
|
43
|
-
),
|
|
44
|
-
defineProperty(
|
|
45
|
-
'
|
|
46
|
-
() =>
|
|
47
|
-
(v) => (
|
|
48
|
-
)
|
|
49
|
-
],
|
|
50
|
-
() => ({ disabled, multiple, placements, offset, placement: 'bottom-start', ...restProps })
|
|
51
|
-
);
|
|
52
|
-
const bond = factory(bondProps).share();
|
|
53
|
-
|
|
54
|
-
function _factory(props: typeof bondProps) {
|
|
55
|
-
const bondState = new ComboboxBondState<D>(() => props);
|
|
56
|
-
|
|
57
|
-
return new ComboboxBond(bondState).share();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function getBond() {
|
|
61
|
-
return bond;
|
|
62
|
-
}
|
|
63
|
-
</script>
|
|
64
|
-
|
|
65
|
-
{@render children?.({ combobox: bond })}
|
|
1
|
+
<script lang="ts" generics="D">
|
|
2
|
+
import type { ComboboxRootProps } from './types';
|
|
3
|
+
import { defineProperty, defineState } from '../../utils';
|
|
4
|
+
import { ComboboxBond, ComboboxBondState, type ComboboxBondProps } from './bond.svelte';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
open = $bindable(false),
|
|
8
|
+
value = $bindable(),
|
|
9
|
+
values = $bindable(),
|
|
10
|
+
label = $bindable(),
|
|
11
|
+
labels = $bindable(),
|
|
12
|
+
multiple = false,
|
|
13
|
+
disabled = false,
|
|
14
|
+
placements = ['bottom-start', 'bottom-end', 'top-start', 'top-end'],
|
|
15
|
+
placement = 'bottom-start',
|
|
16
|
+
offset = 1,
|
|
17
|
+
factory = _factory,
|
|
18
|
+
children = undefined,
|
|
19
|
+
...restProps
|
|
20
|
+
}: ComboboxRootProps = $props();
|
|
21
|
+
|
|
22
|
+
const bondProps = defineState<ComboboxBondProps>(
|
|
23
|
+
[
|
|
24
|
+
defineProperty(
|
|
25
|
+
'open',
|
|
26
|
+
() => open,
|
|
27
|
+
(v) => {
|
|
28
|
+
open = v;
|
|
29
|
+
}
|
|
30
|
+
),
|
|
31
|
+
defineProperty(
|
|
32
|
+
'values',
|
|
33
|
+
() => (multiple ? values : [value]),
|
|
34
|
+
(v) => {
|
|
35
|
+
values = v;
|
|
36
|
+
value = v[0];
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
defineProperty(
|
|
40
|
+
'label',
|
|
41
|
+
() => label,
|
|
42
|
+
(v) => (label = v)
|
|
43
|
+
),
|
|
44
|
+
defineProperty(
|
|
45
|
+
'labels',
|
|
46
|
+
() => labels,
|
|
47
|
+
(v) => (labels = v)
|
|
48
|
+
)
|
|
49
|
+
],
|
|
50
|
+
() => ({ disabled, multiple, placements, offset, placement: 'bottom-start', ...restProps })
|
|
51
|
+
);
|
|
52
|
+
const bond = factory(bondProps).share();
|
|
53
|
+
|
|
54
|
+
function _factory(props: typeof bondProps) {
|
|
55
|
+
const bondState = new ComboboxBondState<D>(() => props);
|
|
56
|
+
|
|
57
|
+
return new ComboboxBond(bondState).share();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function getBond() {
|
|
61
|
+
return bond;
|
|
62
|
+
}
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
{@render children?.({ combobox: bond })}
|
|
@@ -3,9 +3,9 @@ import { ComboboxBond } from './bond.svelte';
|
|
|
3
3
|
declare function $$render<D>(): {
|
|
4
4
|
props: ComboboxRootProps;
|
|
5
5
|
exports: {
|
|
6
|
-
getBond: () => ComboboxBond
|
|
6
|
+
getBond: () => ComboboxBond;
|
|
7
7
|
};
|
|
8
|
-
bindings: "values" | "value" | "
|
|
8
|
+
bindings: "values" | "value" | "label" | "open" | "labels";
|
|
9
9
|
slots: {};
|
|
10
10
|
events: {};
|
|
11
11
|
};
|
|
@@ -13,9 +13,9 @@ declare class __sveltets_Render<D> {
|
|
|
13
13
|
props(): ReturnType<typeof $$render<D>>['props'];
|
|
14
14
|
events(): ReturnType<typeof $$render<D>>['events'];
|
|
15
15
|
slots(): ReturnType<typeof $$render<D>>['slots'];
|
|
16
|
-
bindings(): "values" | "value" | "
|
|
16
|
+
bindings(): "values" | "value" | "label" | "open" | "labels";
|
|
17
17
|
exports(): {
|
|
18
|
-
getBond: () => ComboboxBond
|
|
18
|
+
getBond: () => ComboboxBond;
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
interface $$IsomorphicComponent {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ComboboxBond } from './bond.svelte';
|
|
3
|
+
import { Selections } from '../dropdown/atoms';
|
|
4
|
+
import type { ComboboxSelectionsProps } from './types';
|
|
5
|
+
|
|
6
|
+
const bond = ComboboxBond.get();
|
|
7
|
+
|
|
8
|
+
if (!bond) {
|
|
9
|
+
throw new Error('ComboboxSelections must be used within a Combobox');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let { ...restProps }: ComboboxSelectionsProps = $props();
|
|
13
|
+
|
|
14
|
+
let selections = $derived(bond.state.allSelections);
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<Selections getSelections={() => selections} {...restProps} />
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { Combobox as ACombobox } from '.';
|
|
4
4
|
import { Input } from '../input';
|
|
5
5
|
import { Divider } from '../divider';
|
|
6
|
+
import { filterDropdownData } from '../dropdown';
|
|
6
7
|
|
|
7
8
|
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
8
9
|
const { Story } = defineMeta({
|
|
@@ -19,8 +20,6 @@
|
|
|
19
20
|
|
|
20
21
|
<script lang="ts">
|
|
21
22
|
let open = $state(false);
|
|
22
|
-
let value = $state<string | undefined>('usd');
|
|
23
|
-
let query = $state('');
|
|
24
23
|
let array = $state([
|
|
25
24
|
{ value: 'usd', label: 'US Dollar' },
|
|
26
25
|
{ value: 'eur', label: 'Euro' },
|
|
@@ -29,22 +28,36 @@
|
|
|
29
28
|
{ value: 'cny', label: 'Chinese Yuan' }
|
|
30
29
|
]);
|
|
31
30
|
|
|
32
|
-
const filteredItems =
|
|
33
|
-
|
|
31
|
+
const filteredItems = filterDropdownData(
|
|
32
|
+
() => array,
|
|
33
|
+
(query, item) => item.label.toLowerCase().includes(query.toLowerCase())
|
|
34
34
|
);
|
|
35
|
+
|
|
36
|
+
let selectedLabels = $state([]);
|
|
35
37
|
</script>
|
|
36
38
|
|
|
37
39
|
<Story name="Combobox" args={{}}>
|
|
38
|
-
<ACombobox.Root bind:open bind:
|
|
39
|
-
<ACombobox.Trigger
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
<ACombobox.Root bind:open bind:labels={selectedLabels} multiple>
|
|
41
|
+
<ACombobox.Trigger
|
|
42
|
+
base={Input.Root}
|
|
43
|
+
class="flex h-auto min-h-10 min-w-sm flex-col items-start gap-2"
|
|
44
|
+
>
|
|
45
|
+
<div class="flex">
|
|
46
|
+
<Input.Icon class="text-foreground/50">$</Input.Icon>
|
|
47
|
+
<Divider class="mx-1" vertical />
|
|
48
|
+
<ACombobox.Control class="px-1" placeholder="Select a language" />
|
|
49
|
+
</div>
|
|
50
|
+
<ACombobox.Selections />
|
|
43
51
|
</ACombobox.Trigger>
|
|
44
|
-
<ACombobox.
|
|
45
|
-
|
|
52
|
+
<ACombobox.Content>
|
|
53
|
+
<input
|
|
54
|
+
bind:value={filteredItems.query}
|
|
55
|
+
class="border-border border-b px-4 py-3"
|
|
56
|
+
placeholder="Type to filter..."
|
|
57
|
+
/>
|
|
58
|
+
{#each filteredItems.current as item (item.value)}
|
|
46
59
|
<ACombobox.Item value={item.value}>{item.label}</ACombobox.Item>
|
|
47
60
|
{/each}
|
|
48
|
-
</ACombobox.
|
|
61
|
+
</ACombobox.Content>
|
|
49
62
|
</ACombobox.Root>
|
|
50
63
|
</Story>
|
|
@@ -2,17 +2,19 @@ import type { Snippet } from 'svelte';
|
|
|
2
2
|
import type { HtmlAtomProps, Base } from '../atom';
|
|
3
3
|
import type { Factory } from '../../types';
|
|
4
4
|
import type { ComboboxBond } from './bond.svelte';
|
|
5
|
+
import type { DropdownSelectionProps, DropdownSelectionsProps } from '../dropdown';
|
|
6
|
+
import type { InputControlProps } from '../input';
|
|
5
7
|
/**
|
|
6
8
|
* Extend this interface to add custom combobox properties in your application.
|
|
7
9
|
*/
|
|
8
10
|
export interface ComboboxExtendProps {
|
|
9
11
|
}
|
|
10
|
-
export interface ComboboxRootProps<E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base> extends
|
|
12
|
+
export interface ComboboxRootProps<E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base> extends HtmlAtomProps<E, B>, ComboboxExtendProps {
|
|
11
13
|
open?: boolean;
|
|
12
14
|
value?: unknown;
|
|
13
15
|
values?: unknown[];
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
label?: string;
|
|
17
|
+
labels?: string[];
|
|
16
18
|
multiple?: boolean;
|
|
17
19
|
disabled?: boolean;
|
|
18
20
|
placements?: string[];
|
|
@@ -23,3 +25,15 @@ export interface ComboboxRootProps<E extends keyof HTMLElementTagNameMap = 'div'
|
|
|
23
25
|
combobox: ComboboxBond;
|
|
24
26
|
}]>;
|
|
25
27
|
}
|
|
28
|
+
export interface ComboboxSelectionsProps extends DropdownSelectionsProps {
|
|
29
|
+
}
|
|
30
|
+
export interface ComboboxSelectionProps extends DropdownSelectionProps {
|
|
31
|
+
}
|
|
32
|
+
export interface ComboboxControlProps extends InputControlProps {
|
|
33
|
+
}
|
|
34
|
+
export interface ComboboxSelection {
|
|
35
|
+
id: string;
|
|
36
|
+
label: string;
|
|
37
|
+
createdAt: Date;
|
|
38
|
+
unselect: () => void;
|
|
39
|
+
}
|
|
@@ -2,8 +2,7 @@ export { default as Root } from './dropdown-root.svelte';
|
|
|
2
2
|
export { default as Item } from './item/dropdown-item.svelte';
|
|
3
3
|
export { default as Trigger } from './dropdown-trigger.svelte';
|
|
4
4
|
export { default as Placeholder } from './dropdown-placeholder.svelte';
|
|
5
|
-
export { default as
|
|
6
|
-
export { default as
|
|
7
|
-
export { default as Values } from './dropdown-values.svelte';
|
|
5
|
+
export { default as Selection } from './dropdown-selection.svelte';
|
|
6
|
+
export { default as Selections } from './dropdown-selections.svelte';
|
|
8
7
|
export { Arrow, Indicator } from '../popover/atoms';
|
|
9
8
|
export { Content, List, Divider, Title, Group } from '../menu/atoms';
|
|
@@ -2,8 +2,8 @@ export { default as Root } from './dropdown-root.svelte';
|
|
|
2
2
|
export { default as Item } from './item/dropdown-item.svelte';
|
|
3
3
|
export { default as Trigger } from './dropdown-trigger.svelte';
|
|
4
4
|
export { default as Placeholder } from './dropdown-placeholder.svelte';
|
|
5
|
-
export { default as Query } from './dropdown-query.svelte';
|
|
6
|
-
export { default as
|
|
7
|
-
export { default as
|
|
5
|
+
// export { default as Query } from './dropdown-query.svelte';
|
|
6
|
+
export { default as Selection } from './dropdown-selection.svelte';
|
|
7
|
+
export { default as Selections } from './dropdown-selections.svelte';
|
|
8
8
|
export { Arrow, Indicator } from '../popover/atoms';
|
|
9
9
|
export { Content, List, Divider, Title, Group } from '../menu/atoms';
|
|
@@ -3,9 +3,10 @@ import type { DropdownItemController } from './item/controller.svelte';
|
|
|
3
3
|
export type DropdownStateProps = MenuBondProps & {
|
|
4
4
|
values?: string[];
|
|
5
5
|
value?: string;
|
|
6
|
+
labels?: string[];
|
|
7
|
+
label?: string;
|
|
6
8
|
multiple?: boolean;
|
|
7
9
|
keys?: string[];
|
|
8
|
-
onquerychange?: (query: string) => void;
|
|
9
10
|
};
|
|
10
11
|
export type DropdownBondElements = MenuBondElements & {
|
|
11
12
|
placeholder?: HTMLElement;
|
|
@@ -44,9 +45,8 @@ export declare class DropdownBond<Props extends DropdownStateProps = DropdownSta
|
|
|
44
45
|
export declare class DropdownBondState<Props extends DropdownStateProps = DropdownStateProps> extends MenuBondState<Props> {
|
|
45
46
|
#private;
|
|
46
47
|
constructor(props: () => Props);
|
|
47
|
-
get
|
|
48
|
-
get query(): string;
|
|
49
|
-
set query(value: string);
|
|
48
|
+
get selections(): DropdownItemController<unknown>[];
|
|
50
49
|
select(ids: string[]): void;
|
|
51
50
|
unselect(ids: string[]): void;
|
|
51
|
+
protected updateLabels(): void;
|
|
52
52
|
}
|
|
@@ -51,22 +51,14 @@ export class DropdownBond extends MenuBond {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
export class DropdownBondState extends MenuBondState {
|
|
54
|
-
#
|
|
54
|
+
#selections = $derived(this.props.values
|
|
55
55
|
?.map((value) => this.items.get(value))
|
|
56
56
|
.filter(Boolean) ?? []);
|
|
57
|
-
#query = $state('');
|
|
58
57
|
constructor(props) {
|
|
59
58
|
super(props);
|
|
60
59
|
}
|
|
61
|
-
get
|
|
62
|
-
return this.#
|
|
63
|
-
}
|
|
64
|
-
get query() {
|
|
65
|
-
return this.#query;
|
|
66
|
-
}
|
|
67
|
-
set query(value) {
|
|
68
|
-
this.#query = value;
|
|
69
|
-
this.props.onquerychange?.(value);
|
|
60
|
+
get selections() {
|
|
61
|
+
return this.#selections;
|
|
70
62
|
}
|
|
71
63
|
select(ids) {
|
|
72
64
|
if (untrack(() => this.props.multiple)) {
|
|
@@ -78,6 +70,7 @@ export class DropdownBondState extends MenuBondState {
|
|
|
78
70
|
const value = ids[0];
|
|
79
71
|
this.props.values = value ? [value] : [];
|
|
80
72
|
}
|
|
73
|
+
this.updateLabels();
|
|
81
74
|
}
|
|
82
75
|
unselect(ids) {
|
|
83
76
|
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
@@ -86,5 +79,11 @@ export class DropdownBondState extends MenuBondState {
|
|
|
86
79
|
sequence.delete(v);
|
|
87
80
|
}
|
|
88
81
|
this.props.values = [...sequence];
|
|
82
|
+
this.updateLabels();
|
|
83
|
+
}
|
|
84
|
+
updateLabels() {
|
|
85
|
+
const labels = this.#selections.map((s) => s.label);
|
|
86
|
+
this.props.labels = labels;
|
|
87
|
+
this.props.label = labels[0] ?? '';
|
|
89
88
|
}
|
|
90
89
|
}
|
|
@@ -1,54 +1,43 @@
|
|
|
1
|
-
<script lang="ts"
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class: klass = '',
|
|
15
|
-
children = undefined,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
{bond}
|
|
45
|
-
preset="dropdown.query"
|
|
46
|
-
class={['inline-flex h-auto w-auto flex-1 py-1', '$preset', klass]}
|
|
47
|
-
onmount={onmount?.bind(bond.state)}
|
|
48
|
-
ondestroy={ondestroy?.bind(bond.state)}
|
|
49
|
-
enter={enter?.bind(bond.state)}
|
|
50
|
-
exit={exit?.bind(bond.state)}
|
|
51
|
-
initial={initial?.bind(bond.state)}
|
|
52
|
-
animate={animate?.bind(bond.state)}
|
|
53
|
-
{...restProps}
|
|
54
|
-
/>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { DropdownBond } from './bond.svelte';
|
|
3
|
+
import { Input } from '../input';
|
|
4
|
+
import type { DropdownQueryProps } from './types';
|
|
5
|
+
|
|
6
|
+
const bond = DropdownBond.get() as DropdownBond;
|
|
7
|
+
|
|
8
|
+
if (!bond) {
|
|
9
|
+
throw new Error('Dropdown atom was not found');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
value = $bindable(),
|
|
14
|
+
class: klass = '',
|
|
15
|
+
children = undefined,
|
|
16
|
+
onmount = undefined,
|
|
17
|
+
ondestroy = undefined,
|
|
18
|
+
animate = undefined,
|
|
19
|
+
enter = undefined,
|
|
20
|
+
exit = undefined,
|
|
21
|
+
initial = undefined,
|
|
22
|
+
...restProps
|
|
23
|
+
}: DropdownQueryProps = $props();
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<Input.Control
|
|
27
|
+
bind:value={
|
|
28
|
+
() => value,
|
|
29
|
+
(v) => {
|
|
30
|
+
value = v;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
{bond}
|
|
34
|
+
preset="dropdown.query"
|
|
35
|
+
class={['inline-flex h-auto w-auto flex-1 py-1', '$preset', klass]}
|
|
36
|
+
onmount={onmount?.bind(bond.state)}
|
|
37
|
+
ondestroy={ondestroy?.bind(bond.state)}
|
|
38
|
+
enter={enter?.bind(bond.state)}
|
|
39
|
+
exit={exit?.bind(bond.state)}
|
|
40
|
+
initial={initial?.bind(bond.state)}
|
|
41
|
+
animate={animate?.bind(bond.state)}
|
|
42
|
+
{...restProps}
|
|
43
|
+
/>
|
|
@@ -1,35 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare
|
|
3
|
-
|
|
4
|
-
class?: string;
|
|
5
|
-
children?: any;
|
|
6
|
-
onpointerdown: any;
|
|
7
|
-
onmount?: any;
|
|
8
|
-
ondestroy?: any;
|
|
9
|
-
animate?: any;
|
|
10
|
-
enter?: any;
|
|
11
|
-
exit?: any;
|
|
12
|
-
initial?: any;
|
|
13
|
-
} & Record<string, any>;
|
|
14
|
-
exports: {};
|
|
15
|
-
bindings: "";
|
|
16
|
-
slots: {};
|
|
17
|
-
events: {};
|
|
18
|
-
};
|
|
19
|
-
declare class __sveltets_Render<T extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base> {
|
|
20
|
-
props(): ReturnType<typeof $$render<T, B>>['props'];
|
|
21
|
-
events(): ReturnType<typeof $$render<T, B>>['events'];
|
|
22
|
-
slots(): ReturnType<typeof $$render<T, B>>['slots'];
|
|
23
|
-
bindings(): "";
|
|
24
|
-
exports(): {};
|
|
25
|
-
}
|
|
26
|
-
interface $$IsomorphicComponent {
|
|
27
|
-
new <T extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T, B>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T, B>['props']>, ReturnType<__sveltets_Render<T, B>['events']>, ReturnType<__sveltets_Render<T, B>['slots']>> & {
|
|
28
|
-
$$bindings?: ReturnType<__sveltets_Render<T, B>['bindings']>;
|
|
29
|
-
} & ReturnType<__sveltets_Render<T, B>['exports']>;
|
|
30
|
-
<T extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base>(internal: unknown, props: ReturnType<__sveltets_Render<T, B>['props']> & {}): ReturnType<__sveltets_Render<T, B>['exports']>;
|
|
31
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
32
|
-
}
|
|
33
|
-
declare const DropdownQuery: $$IsomorphicComponent;
|
|
34
|
-
type DropdownQuery<T extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base> = InstanceType<typeof DropdownQuery<T, B>>;
|
|
1
|
+
import type { DropdownQueryProps } from './types';
|
|
2
|
+
declare const DropdownQuery: import("svelte").Component<DropdownQueryProps, {}, "value">;
|
|
3
|
+
type DropdownQuery = ReturnType<typeof DropdownQuery>;
|
|
35
4
|
export default DropdownQuery;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
<script lang="ts" generics="T">
|
|
2
2
|
import { defineProperty, defineState } from '../../utils';
|
|
3
3
|
import { DropdownBond, DropdownBondState, type DropdownStateProps } from './bond.svelte';
|
|
4
|
+
import type { DropdownRootProps } from './types';
|
|
4
5
|
|
|
5
6
|
let {
|
|
6
7
|
open = $bindable(false),
|
|
7
8
|
value = $bindable(),
|
|
8
9
|
values = $bindable(),
|
|
10
|
+
labels = $bindable(),
|
|
11
|
+
label = $bindable(),
|
|
9
12
|
multiple = false,
|
|
10
13
|
disabled = false,
|
|
11
14
|
placements = ['bottom-start', 'bottom-end', 'top-start', 'top-end'],
|
|
@@ -16,7 +19,7 @@
|
|
|
16
19
|
children = undefined,
|
|
17
20
|
onquerychange = undefined,
|
|
18
21
|
...restProps
|
|
19
|
-
} = $props();
|
|
22
|
+
}: DropdownRootProps<T> = $props();
|
|
20
23
|
|
|
21
24
|
const bondProps = defineState<DropdownStateProps>(
|
|
22
25
|
[
|
|
@@ -35,6 +38,16 @@
|
|
|
35
38
|
value = v[0];
|
|
36
39
|
}
|
|
37
40
|
),
|
|
41
|
+
defineProperty(
|
|
42
|
+
'label',
|
|
43
|
+
() => label,
|
|
44
|
+
(v) => (label = v)
|
|
45
|
+
),
|
|
46
|
+
defineProperty(
|
|
47
|
+
'labels',
|
|
48
|
+
() => labels,
|
|
49
|
+
(v) => (labels = v)
|
|
50
|
+
),
|
|
38
51
|
defineProperty('multiple', () => multiple),
|
|
39
52
|
defineProperty('disabled', () => disabled),
|
|
40
53
|
defineProperty('placement', () => placement),
|
|
@@ -42,7 +55,7 @@
|
|
|
42
55
|
defineProperty('placements', () => placements ?? []),
|
|
43
56
|
defineProperty('keys', () => keys ?? [])
|
|
44
57
|
],
|
|
45
|
-
() => ({
|
|
58
|
+
() => ({})
|
|
46
59
|
);
|
|
47
60
|
const bond = factory(bondProps).share();
|
|
48
61
|
|
|
@@ -1,23 +1,11 @@
|
|
|
1
1
|
import { DropdownBond, DropdownBondState, type DropdownStateProps } from './bond.svelte';
|
|
2
|
+
import type { DropdownRootProps } from './types';
|
|
2
3
|
declare function $$render<T>(): {
|
|
3
|
-
props:
|
|
4
|
-
open?: boolean;
|
|
5
|
-
value?: any;
|
|
6
|
-
values?: any;
|
|
7
|
-
multiple?: boolean;
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
placements?: any[];
|
|
10
|
-
placement?: string;
|
|
11
|
-
offset?: number;
|
|
12
|
-
keys?: any[];
|
|
13
|
-
factory?: (props: DropdownStateProps) => DropdownBond<DropdownStateProps, DropdownBondState<DropdownStateProps>, import("./bond.svelte").DropdownBondElements>;
|
|
14
|
-
children?: any;
|
|
15
|
-
onquerychange?: any;
|
|
16
|
-
} & Record<string, any>;
|
|
4
|
+
props: DropdownRootProps<T>;
|
|
17
5
|
exports: {
|
|
18
6
|
getBond: () => DropdownBond<DropdownStateProps, DropdownBondState<DropdownStateProps>, import("./bond.svelte").DropdownBondElements>;
|
|
19
7
|
};
|
|
20
|
-
bindings: "values" | "value" | "open";
|
|
8
|
+
bindings: "values" | "value" | "label" | "open" | "labels";
|
|
21
9
|
slots: {};
|
|
22
10
|
events: {};
|
|
23
11
|
};
|
|
@@ -25,7 +13,7 @@ declare class __sveltets_Render<T> {
|
|
|
25
13
|
props(): ReturnType<typeof $$render<T>>['props'];
|
|
26
14
|
events(): ReturnType<typeof $$render<T>>['events'];
|
|
27
15
|
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
28
|
-
bindings(): "values" | "value" | "open";
|
|
16
|
+
bindings(): "values" | "value" | "label" | "open" | "labels";
|
|
29
17
|
exports(): {
|
|
30
18
|
getBond: () => DropdownBond<DropdownStateProps, DropdownBondState<DropdownStateProps>, import("./bond.svelte").DropdownBondElements>;
|
|
31
19
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script lang="ts" generics="T extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
+
import { type Base } from '../atom';
|
|
3
|
+
import { DropdownBond } from './bond.svelte';
|
|
4
|
+
import type { DropdownSelectionProps } from './types';
|
|
5
|
+
import { Chip } from '../chip';
|
|
6
|
+
import { HtmlAtom as Atom } from '../atom';
|
|
7
|
+
|
|
8
|
+
const bond = DropdownBond.get();
|
|
9
|
+
|
|
10
|
+
if (!bond) {
|
|
11
|
+
throw new Error('DropdownValue must be used within a Dropdown');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const isMultiple = $derived(bond.state.props.multiple);
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
class: klass = '',
|
|
18
|
+
as = 'div' as T,
|
|
19
|
+
base = undefined,
|
|
20
|
+
selection,
|
|
21
|
+
children,
|
|
22
|
+
onclose,
|
|
23
|
+
...restProps
|
|
24
|
+
}: DropdownSelectionProps<T, B> = $props();
|
|
25
|
+
|
|
26
|
+
const _base = $derived((base ?? isMultiple) ? Chip : undefined);
|
|
27
|
+
|
|
28
|
+
function handleClose(ev: Event) {
|
|
29
|
+
onclose?.(ev);
|
|
30
|
+
|
|
31
|
+
if (ev.defaultPrevented) return;
|
|
32
|
+
|
|
33
|
+
selection.unselect();
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<Atom
|
|
38
|
+
{as}
|
|
39
|
+
{bond}
|
|
40
|
+
base={_base}
|
|
41
|
+
preset="dropdown.value"
|
|
42
|
+
class={[
|
|
43
|
+
'dropdown-value border-border inline-flex h-6 flex-nowrap items-center gap-1 rounded-sm px-2 whitespace-nowrap',
|
|
44
|
+
'$preset',
|
|
45
|
+
klass
|
|
46
|
+
]}
|
|
47
|
+
onclose={handleClose}
|
|
48
|
+
{...restProps}
|
|
49
|
+
>
|
|
50
|
+
{#if children}
|
|
51
|
+
{@render children?.()}
|
|
52
|
+
{:else}
|
|
53
|
+
{selection.label}
|
|
54
|
+
{/if}
|
|
55
|
+
</Atom>
|