compote-ui 0.9.0 → 0.11.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/dist/components/combobox/combobox.svelte +5 -10
- package/dist/components/combobox/combobox.svelte.d.ts +7 -6
- package/dist/components/combobox/types.d.ts +2 -6
- package/dist/components/fieldset/fieldset-error-text.svelte +11 -0
- package/dist/components/fieldset/fieldset-error-text.svelte.d.ts +4 -0
- package/dist/components/fieldset/fieldset-helper-text.svelte +11 -0
- package/dist/components/fieldset/fieldset-helper-text.svelte.d.ts +4 -0
- package/dist/components/fieldset/fieldset-legend.svelte +17 -0
- package/dist/components/fieldset/fieldset-legend.svelte.d.ts +4 -0
- package/dist/components/fieldset/fieldset.svelte +11 -0
- package/dist/components/fieldset/fieldset.svelte.d.ts +5 -0
- package/dist/components/fieldset/index.d.ts +5 -0
- package/dist/components/fieldset/index.js +4 -0
- package/dist/components/fieldset/types.d.ts +13 -0
- package/dist/components/fieldset/types.js +1 -0
- package/dist/components/listbox/listbox.svelte +4 -3
- package/dist/components/listbox/listbox.svelte.d.ts +1 -1
- package/dist/components/listbox/types.d.ts +3 -8
- package/dist/components/select/select.svelte +5 -10
- package/dist/components/select/select.svelte.d.ts +7 -6
- package/dist/components/select/types.d.ts +2 -6
- package/dist/components/tree-view/tree-view.svelte +5 -10
- package/dist/components/tree-view/tree-view.svelte.d.ts +7 -6
- package/dist/components/tree-view/types.d.ts +2 -7
- package/dist/index.d.ts +4 -5
- package/dist/index.js +2 -2
- package/dist/utils/collections.d.ts +15 -0
- package/dist/utils/collections.js +17 -0
- package/package.json +2 -1
- package/dist/components/switch/index.d.ts +0 -2
- package/dist/components/switch/index.js +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
<script lang="ts" generics="T extends
|
|
2
|
-
import { Combobox
|
|
1
|
+
<script lang="ts" generics="T extends ListItem">
|
|
2
|
+
import { Combobox } from '@ark-ui/svelte/combobox';
|
|
3
3
|
import { Field } from '@ark-ui/svelte/field';
|
|
4
4
|
import { useFilter } from '@ark-ui/svelte/locale';
|
|
5
5
|
import { Portal } from '@ark-ui/svelte/portal';
|
|
6
|
-
import type {
|
|
6
|
+
import type { ComboboxProps } from './types';
|
|
7
|
+
import { createListCollection, type ListItem } from '../../utils/collections';
|
|
7
8
|
import { cn } from 'tailwind-variants';
|
|
8
9
|
import PhCaretDown from '../../icons/PhCaretDown.svelte';
|
|
9
10
|
import PhCheck from '../../icons/PhCheck.svelte';
|
|
@@ -27,13 +28,7 @@
|
|
|
27
28
|
const filters = useFilter({ sensitivity: 'base' });
|
|
28
29
|
|
|
29
30
|
// Base collection — only rebuilds when items prop changes
|
|
30
|
-
const baseCollection = $derived(
|
|
31
|
-
createListCollection({
|
|
32
|
-
items,
|
|
33
|
-
itemToString: (item) => item?.label ?? '',
|
|
34
|
-
itemToValue: (item) => item?.value?.toString() ?? ''
|
|
35
|
-
})
|
|
36
|
-
);
|
|
31
|
+
const baseCollection = $derived(createListCollection(items));
|
|
37
32
|
|
|
38
33
|
// Filtered view — lightweight .filter() on keystroke, full collection when empty
|
|
39
34
|
const collection = $derived(
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Combobox } from '@ark-ui/svelte/combobox';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { ComboboxProps } from './types';
|
|
3
|
+
import { type ListItem } from '../../utils/collections';
|
|
4
|
+
declare function $$render<T extends ListItem>(): {
|
|
4
5
|
props: ComboboxProps<T>;
|
|
5
6
|
exports: {};
|
|
6
7
|
bindings: "value";
|
|
7
8
|
slots: {};
|
|
8
9
|
events: {};
|
|
9
10
|
};
|
|
10
|
-
declare class __sveltets_Render<T extends
|
|
11
|
+
declare class __sveltets_Render<T extends ListItem> {
|
|
11
12
|
props(): ReturnType<typeof $$render<T>>['props'];
|
|
12
13
|
events(): ReturnType<typeof $$render<T>>['events'];
|
|
13
14
|
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
@@ -15,12 +16,12 @@ declare class __sveltets_Render<T extends ComboboxItem> {
|
|
|
15
16
|
exports(): {};
|
|
16
17
|
}
|
|
17
18
|
interface $$IsomorphicComponent {
|
|
18
|
-
new <T extends
|
|
19
|
+
new <T extends ListItem>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
19
20
|
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
20
21
|
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
21
|
-
<T extends
|
|
22
|
+
<T extends ListItem>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
22
23
|
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
23
24
|
}
|
|
24
25
|
declare const Combobox: $$IsomorphicComponent;
|
|
25
|
-
type Combobox<T extends
|
|
26
|
+
type Combobox<T extends ListItem> = InstanceType<typeof Combobox<T>>;
|
|
26
27
|
export default Combobox;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type { ComboboxRootBaseProps } from '@ark-ui/svelte/combobox';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
label: string;
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export interface ComboboxProps<T extends ComboboxItem> extends Omit<ComboboxRootBaseProps<T>, 'value' | 'collection'> {
|
|
2
|
+
import type { ListItem } from '../../utils/collections';
|
|
3
|
+
export interface ComboboxProps<T extends ListItem> extends Omit<ComboboxRootBaseProps<T>, 'value' | 'collection'> {
|
|
8
4
|
value?: number | string | null | (number | string)[];
|
|
9
5
|
items: T[];
|
|
10
6
|
label?: string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Fieldset } from '@ark-ui/svelte/fieldset';
|
|
3
|
+
import type { FieldsetErrorTextProps } from './types';
|
|
4
|
+
import { cn } from 'tailwind-variants';
|
|
5
|
+
|
|
6
|
+
let { class: className, children, ...rest }: FieldsetErrorTextProps = $props();
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<Fieldset.ErrorText {...rest} class={cn('text-xs font-medium text-danger', className)}>
|
|
10
|
+
{@render children?.()}
|
|
11
|
+
</Fieldset.ErrorText>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Fieldset } from '@ark-ui/svelte/fieldset';
|
|
3
|
+
import type { FieldsetHelperTextProps } from './types';
|
|
4
|
+
import { cn } from 'tailwind-variants';
|
|
5
|
+
|
|
6
|
+
let { class: className, children, ...rest }: FieldsetHelperTextProps = $props();
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<Fieldset.HelperText {...rest} class={cn('text-sm text-ink-dim', className)}>
|
|
10
|
+
{@render children?.()}
|
|
11
|
+
</Fieldset.HelperText>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Fieldset } from '@ark-ui/svelte/fieldset';
|
|
3
|
+
import type { FieldsetLegendProps } from './types';
|
|
4
|
+
import { cn } from 'tailwind-variants';
|
|
5
|
+
|
|
6
|
+
let { class: className, children, ...rest }: FieldsetLegendProps = $props();
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<Fieldset.Legend
|
|
10
|
+
{...rest}
|
|
11
|
+
class={cn(
|
|
12
|
+
'mb-1 font-semibold data-disabled:cursor-not-allowed data-disabled:opacity-70',
|
|
13
|
+
className
|
|
14
|
+
)}
|
|
15
|
+
>
|
|
16
|
+
{@render children?.()}
|
|
17
|
+
</Fieldset.Legend>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Fieldset } from '@ark-ui/svelte/fieldset';
|
|
3
|
+
import type { FieldsetRootProps } from './types';
|
|
4
|
+
import { cn } from 'tailwind-variants';
|
|
5
|
+
|
|
6
|
+
let { class: className, children, ...rest }: FieldsetRootProps = $props();
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<Fieldset.Root {...rest} class={cn('m-0 flex min-w-0 flex-col gap-3 border-0 p-0', className)}>
|
|
10
|
+
{@render children?.()}
|
|
11
|
+
</Fieldset.Root>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as Root } from './fieldset.svelte';
|
|
2
|
+
export { default as Legend } from './fieldset-legend.svelte';
|
|
3
|
+
export { default as HelperText } from './fieldset-helper-text.svelte';
|
|
4
|
+
export { default as ErrorText } from './fieldset-error-text.svelte';
|
|
5
|
+
export type { FieldsetRootProps, FieldsetLegendProps, FieldsetHelperTextProps, FieldsetErrorTextProps } from './types';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FieldsetRootBaseProps, FieldsetLegendBaseProps, FieldsetHelperTextBaseProps, FieldsetErrorTextBaseProps } from '@ark-ui/svelte/fieldset';
|
|
2
|
+
export interface FieldsetRootProps extends FieldsetRootBaseProps {
|
|
3
|
+
class?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface FieldsetLegendProps extends FieldsetLegendBaseProps {
|
|
6
|
+
class?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface FieldsetHelperTextProps extends FieldsetHelperTextBaseProps {
|
|
9
|
+
class?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface FieldsetErrorTextProps extends FieldsetErrorTextBaseProps {
|
|
12
|
+
class?: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<script module>
|
|
2
2
|
// eslint-disable-next-line no-import-assign
|
|
3
|
-
export type {
|
|
3
|
+
export type { ListboxProps } from './types';
|
|
4
4
|
</script>
|
|
5
5
|
|
|
6
6
|
<script lang="ts" generics="T extends number | string = number | string">
|
|
7
7
|
import { Listbox, createListCollection } from '@ark-ui/svelte/listbox';
|
|
8
8
|
import { useFilter } from '@ark-ui/svelte/locale';
|
|
9
|
-
import type {
|
|
9
|
+
import type { ListboxProps } from './types';
|
|
10
|
+
import type { ListItem } from '../../utils/collections';
|
|
10
11
|
import { cn } from 'tailwind-variants';
|
|
11
12
|
import PhCheck from '../../icons/PhCheck.svelte';
|
|
12
13
|
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
items,
|
|
34
35
|
itemToValue: (item) => item.value.toString(),
|
|
35
36
|
isItemDisabled: (item) => item.disabled === true,
|
|
36
|
-
...(hasGroups ? { groupBy: (item:
|
|
37
|
+
...(hasGroups ? { groupBy: (item: ListItem<T>) => item.group ?? '' } : {})
|
|
37
38
|
})
|
|
38
39
|
);
|
|
39
40
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type { ListboxProps } from './types';
|
|
2
2
|
import { Listbox } from '@ark-ui/svelte/listbox';
|
|
3
3
|
import type { ListboxProps } from './types';
|
|
4
4
|
declare function $$render<T extends number | string = number | string>(): {
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import type { ListboxRootBaseProps } from '@ark-ui/svelte/listbox';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
group?: string;
|
|
7
|
-
}
|
|
8
|
-
export interface ListboxProps<T extends number | string = number | string> extends Omit<ListboxRootBaseProps<ListboxItem<T>>, 'collection' | 'value'> {
|
|
9
|
-
items: ListboxItem<T>[];
|
|
2
|
+
import type { ListItem } from '../../utils/collections';
|
|
3
|
+
export interface ListboxProps<T extends number | string = number | string> extends Omit<ListboxRootBaseProps<ListItem<T>>, 'collection' | 'value'> {
|
|
4
|
+
items: ListItem<T>[];
|
|
10
5
|
value?: T[];
|
|
11
6
|
label?: string;
|
|
12
7
|
name?: string;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
<script lang="ts" generics="T extends
|
|
1
|
+
<script lang="ts" generics="T extends ListItem">
|
|
2
2
|
import { Field } from '@ark-ui/svelte/field';
|
|
3
3
|
import { Portal } from '@ark-ui/svelte/portal';
|
|
4
|
-
import { Select
|
|
5
|
-
import type {
|
|
4
|
+
import { Select } from '@ark-ui/svelte/select';
|
|
5
|
+
import type { SelectProps } from './types';
|
|
6
|
+
import { createListCollection, type ListItem } from '../../utils/collections';
|
|
6
7
|
import { cn } from 'tailwind-variants';
|
|
7
8
|
import PhCaretDown from '../../icons/PhCaretDown.svelte';
|
|
8
9
|
import PhCheck from '../../icons/PhCheck.svelte';
|
|
@@ -20,13 +21,7 @@
|
|
|
20
21
|
layout === 'horizontal' ? 'flex items-center gap-1.5' : 'grid gap-1.5'
|
|
21
22
|
);
|
|
22
23
|
|
|
23
|
-
const collection = $derived(
|
|
24
|
-
createListCollection<T>({
|
|
25
|
-
items: items,
|
|
26
|
-
itemToValue: (item) => item.value.toString(),
|
|
27
|
-
isItemDisabled: (item) => item.disabled === true
|
|
28
|
-
})
|
|
29
|
-
);
|
|
24
|
+
const collection = $derived(createListCollection(items));
|
|
30
25
|
</script>
|
|
31
26
|
|
|
32
27
|
<Select.Root
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Select } from '@ark-ui/svelte/select';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { SelectProps } from './types';
|
|
3
|
+
import { type ListItem } from '../../utils/collections';
|
|
4
|
+
declare function $$render<T extends ListItem>(): {
|
|
4
5
|
props: SelectProps<T>;
|
|
5
6
|
exports: {};
|
|
6
7
|
bindings: "value";
|
|
7
8
|
slots: {};
|
|
8
9
|
events: {};
|
|
9
10
|
};
|
|
10
|
-
declare class __sveltets_Render<T extends
|
|
11
|
+
declare class __sveltets_Render<T extends ListItem> {
|
|
11
12
|
props(): ReturnType<typeof $$render<T>>['props'];
|
|
12
13
|
events(): ReturnType<typeof $$render<T>>['events'];
|
|
13
14
|
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
@@ -15,12 +16,12 @@ declare class __sveltets_Render<T extends SelectItem> {
|
|
|
15
16
|
exports(): {};
|
|
16
17
|
}
|
|
17
18
|
interface $$IsomorphicComponent {
|
|
18
|
-
new <T extends
|
|
19
|
+
new <T extends ListItem>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
19
20
|
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
20
21
|
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
21
|
-
<T extends
|
|
22
|
+
<T extends ListItem>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
22
23
|
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
23
24
|
}
|
|
24
25
|
declare const Select: $$IsomorphicComponent;
|
|
25
|
-
type Select<T extends
|
|
26
|
+
type Select<T extends ListItem> = InstanceType<typeof Select<T>>;
|
|
26
27
|
export default Select;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type { SelectRootBaseProps } from '@ark-ui/svelte/select';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
label: string;
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export interface SelectProps<T extends SelectItem> extends Omit<SelectRootBaseProps<T>, 'value' | 'collection'> {
|
|
2
|
+
import type { ListItem } from '../../utils/collections';
|
|
3
|
+
export interface SelectProps<T extends ListItem> extends Omit<SelectRootBaseProps<T>, 'value' | 'collection'> {
|
|
8
4
|
value?: number | string | null;
|
|
9
5
|
items: T[];
|
|
10
6
|
label?: string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
<script lang="ts" generics="T extends
|
|
2
|
-
import { TreeView
|
|
1
|
+
<script lang="ts" generics="T extends TreeItem">
|
|
2
|
+
import { TreeView } from '@ark-ui/svelte/tree-view';
|
|
3
3
|
import { useFilter } from '@ark-ui/svelte/locale';
|
|
4
|
-
import type {
|
|
4
|
+
import type { TreeViewProps } from './types';
|
|
5
|
+
import { createTreeCollection, type TreeItem } from '../../utils/collections';
|
|
5
6
|
import { Debounced } from 'runed';
|
|
6
7
|
import PhX from '../../icons/PhX.svelte';
|
|
7
8
|
import PhCaretRight from '../../icons/PhCaretRight.svelte';
|
|
@@ -30,13 +31,7 @@
|
|
|
30
31
|
const filterFns = useFilter({ sensitivity: 'base' });
|
|
31
32
|
let searchTerm: string | undefined = $state();
|
|
32
33
|
const debouncedSearchTerm = new Debounced(() => searchTerm, 250);
|
|
33
|
-
const baseCollection = $derived(
|
|
34
|
-
createTreeCollection<T>({
|
|
35
|
-
nodeToValue: (node) => node.value.toString(),
|
|
36
|
-
nodeToString: (node) => node.label,
|
|
37
|
-
rootNode: { value: 'ROOT', label: '', children: items } as unknown as T
|
|
38
|
-
})
|
|
39
|
-
);
|
|
34
|
+
const baseCollection = $derived(createTreeCollection(items));
|
|
40
35
|
const collection = $derived.by(() => {
|
|
41
36
|
const term = debouncedSearchTerm.current ?? '';
|
|
42
37
|
return term.length > 0
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { TreeView } from '@ark-ui/svelte/tree-view';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { TreeViewProps } from './types';
|
|
3
|
+
import { type TreeItem } from '../../utils/collections';
|
|
4
|
+
declare function $$render<T extends TreeItem>(): {
|
|
4
5
|
props: TreeViewProps<T>;
|
|
5
6
|
exports: {};
|
|
6
7
|
bindings: "selectedValue" | "checkedValue" | "contextNode";
|
|
7
8
|
slots: {};
|
|
8
9
|
events: {};
|
|
9
10
|
};
|
|
10
|
-
declare class __sveltets_Render<T extends
|
|
11
|
+
declare class __sveltets_Render<T extends TreeItem> {
|
|
11
12
|
props(): ReturnType<typeof $$render<T>>['props'];
|
|
12
13
|
events(): ReturnType<typeof $$render<T>>['events'];
|
|
13
14
|
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
@@ -15,12 +16,12 @@ declare class __sveltets_Render<T extends TreeNode> {
|
|
|
15
16
|
exports(): {};
|
|
16
17
|
}
|
|
17
18
|
interface $$IsomorphicComponent {
|
|
18
|
-
new <T extends
|
|
19
|
+
new <T extends TreeItem>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
19
20
|
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
20
21
|
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
21
|
-
<T extends
|
|
22
|
+
<T extends TreeItem>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
22
23
|
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
23
24
|
}
|
|
24
25
|
declare const TreeView: $$IsomorphicComponent;
|
|
25
|
-
type TreeView<T extends
|
|
26
|
+
type TreeView<T extends TreeItem> = InstanceType<typeof TreeView<T>>;
|
|
26
27
|
export default TreeView;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import type { UseTreeViewProps } from '@ark-ui/svelte/tree-view';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
label: string;
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
children?: TreeNode[];
|
|
7
|
-
}
|
|
8
|
-
export interface TreeViewProps<T extends TreeNode> extends Omit<UseTreeViewProps<T>, 'collection'> {
|
|
2
|
+
import type { TreeItem } from '../../utils/collections';
|
|
3
|
+
export interface TreeViewProps<T extends TreeItem> extends Omit<UseTreeViewProps<T>, 'collection'> {
|
|
9
4
|
items?: T[];
|
|
10
5
|
label?: string;
|
|
11
6
|
contextNode?: string | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -25,9 +25,8 @@ export { default as Switch } from './components/switch/switch.svelte';
|
|
|
25
25
|
export * as Tabs from './components/tabs';
|
|
26
26
|
export * as Menu from './components/menu';
|
|
27
27
|
export * as Field from './components/field';
|
|
28
|
+
export * as Fieldset from './components/fieldset';
|
|
28
29
|
export { default as TreeView } from './components/tree-view/tree-view.svelte';
|
|
29
|
-
export
|
|
30
|
-
export {
|
|
31
|
-
export type {
|
|
32
|
-
export { createTreeCollection } from '@ark-ui/svelte/collection';
|
|
33
|
-
export type { TreeCollection, TreeCollectionOptions } from '@ark-ui/svelte/collection';
|
|
30
|
+
export { createListCollection, createTreeCollection } from './utils/collections';
|
|
31
|
+
export type { ListItem, TreeItem } from './utils/collections';
|
|
32
|
+
export type { ListCollection, TreeCollection } from '@ark-ui/svelte/collection';
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,6 @@ export { default as Switch } from './components/switch/switch.svelte';
|
|
|
19
19
|
export * as Tabs from './components/tabs';
|
|
20
20
|
export * as Menu from './components/menu';
|
|
21
21
|
export * as Field from './components/field';
|
|
22
|
+
export * as Fieldset from './components/fieldset';
|
|
22
23
|
export { default as TreeView } from './components/tree-view/tree-view.svelte';
|
|
23
|
-
export { createListCollection } from '
|
|
24
|
-
export { createTreeCollection } from '@ark-ui/svelte/collection';
|
|
24
|
+
export { createListCollection, createTreeCollection } from './utils/collections';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ListCollection, TreeCollection } from '@ark-ui/svelte/collection';
|
|
2
|
+
export interface ListItem<T = number | string> {
|
|
3
|
+
value: T;
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
group?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface TreeItem {
|
|
9
|
+
value: number | string;
|
|
10
|
+
label: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
children?: TreeItem[];
|
|
13
|
+
}
|
|
14
|
+
export declare function createListCollection<T extends ListItem>(items: T[]): ListCollection<T>;
|
|
15
|
+
export declare function createTreeCollection<T extends TreeItem>(items: T[]): TreeCollection<T>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createListCollection as arkCreateListCollection, createTreeCollection as arkCreateTreeCollection } from '@ark-ui/svelte/collection';
|
|
2
|
+
export function createListCollection(items) {
|
|
3
|
+
return arkCreateListCollection({
|
|
4
|
+
items,
|
|
5
|
+
itemToValue: (item) => item.value.toString(),
|
|
6
|
+
itemToString: (item) => item.label,
|
|
7
|
+
isItemDisabled: (item) => item.disabled === true
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export function createTreeCollection(items) {
|
|
11
|
+
return arkCreateTreeCollection({
|
|
12
|
+
nodeToValue: (node) => node.value.toString(),
|
|
13
|
+
nodeToString: (node) => node.label,
|
|
14
|
+
nodeToChildren: (node) => (node.children ?? []),
|
|
15
|
+
rootNode: { value: 'ROOT', label: '', children: items }
|
|
16
|
+
});
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Switch } from './switch.svelte';
|