@casinogate/ui 2.0.1 → 2.0.2
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/composed/combobox/creatable/combobox.creatable.svelte +1 -1
- package/dist/composed/combobox/types.d.ts +12 -12
- package/dist/primitives/combobox/components/combobox.item.svelte +10 -24
- package/dist/primitives/combobox/components/combobox.root.svelte +1 -16
- package/dist/primitives/combobox/components/combobox.svelte.d.ts +1 -1
- package/dist/primitives/combobox/types.d.ts +7 -35
- package/package.json +1 -1
|
@@ -103,12 +103,12 @@
|
|
|
103
103
|
async function onSelectItem(nextValue: string | string[], item: TItem | null) {
|
|
104
104
|
if (isCreateOption(item)) {
|
|
105
105
|
const currentValue = Array.isArray(value) ? value : [];
|
|
106
|
+
searchValue = '';
|
|
106
107
|
const createdItem = await onCreate(item.inputValue);
|
|
107
108
|
const createdValue = isMultiple ? [...currentValue, createdItem.value] : createdItem.value;
|
|
108
109
|
|
|
109
110
|
createdItems = [...createdItems.filter((created) => created.value !== createdItem.value), createdItem];
|
|
110
111
|
value = createdValue;
|
|
111
|
-
searchValue = '';
|
|
112
112
|
onSelect(createdValue, createdItem);
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { SELECTION_TYPE } from '../../internal/constants/selection-type.js';
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
1
|
import type { CommandGroup, CommandItem, CommandProps } from '../command/index.js';
|
|
2
|
+
import type { SELECTION_TYPE } from '../../internal/constants/selection-type.js';
|
|
4
3
|
import type { PrimitivePopoverRootProps } from '../../primitives/popover/types.js';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
5
|
import type { ComboboxTriggerVariantsProps } from './styles.js';
|
|
6
6
|
export type ComboboxRootProps = PrimitivePopoverRootProps;
|
|
7
7
|
export type ComboboxItem = CommandItem & {
|
|
@@ -41,11 +41,11 @@ type ComboboxBaseProps<TItem extends ComboboxItem = ComboboxItem> = PrimitivePop
|
|
|
41
41
|
/** Callback when selection changes */
|
|
42
42
|
onSelect?: (value: string | string[], item: TItem | null) => void;
|
|
43
43
|
};
|
|
44
|
-
type ComboboxSingleProps<TItem extends ComboboxItem = ComboboxItem> = ComboboxBaseProps<TItem> & {
|
|
45
|
-
type
|
|
44
|
+
export type ComboboxSingleProps<TItem extends ComboboxItem = ComboboxItem> = ComboboxBaseProps<TItem> & {
|
|
45
|
+
type: typeof SELECTION_TYPE.SINGLE;
|
|
46
46
|
value?: string;
|
|
47
47
|
};
|
|
48
|
-
type ComboboxMultipleProps<TItem extends ComboboxItem = ComboboxItem> = ComboboxBaseProps<TItem> & {
|
|
48
|
+
export type ComboboxMultipleProps<TItem extends ComboboxItem = ComboboxItem> = ComboboxBaseProps<TItem> & {
|
|
49
49
|
type: typeof SELECTION_TYPE.MULTIPLE;
|
|
50
50
|
value?: string[];
|
|
51
51
|
};
|
|
@@ -55,11 +55,11 @@ type ComboboxCreatableBaseProps<TItem extends ComboboxItem = ComboboxItem> = Com
|
|
|
55
55
|
isCreatable?: (inputValue: string, items: TItem[]) => boolean;
|
|
56
56
|
onCreate: (inputValue: string) => TItem | Promise<TItem>;
|
|
57
57
|
};
|
|
58
|
-
type ComboboxCreatableSingleProps<TItem extends ComboboxItem = ComboboxItem> = ComboboxCreatableBaseProps<TItem> & {
|
|
59
|
-
type
|
|
58
|
+
export type ComboboxCreatableSingleProps<TItem extends ComboboxItem = ComboboxItem> = ComboboxCreatableBaseProps<TItem> & {
|
|
59
|
+
type: typeof SELECTION_TYPE.SINGLE;
|
|
60
60
|
value?: string;
|
|
61
61
|
};
|
|
62
|
-
type ComboboxCreatableMultipleProps<TItem extends ComboboxItem = ComboboxItem> = ComboboxCreatableBaseProps<TItem> & {
|
|
62
|
+
export type ComboboxCreatableMultipleProps<TItem extends ComboboxItem = ComboboxItem> = ComboboxCreatableBaseProps<TItem> & {
|
|
63
63
|
type: typeof SELECTION_TYPE.MULTIPLE;
|
|
64
64
|
value?: string[];
|
|
65
65
|
};
|
|
@@ -115,12 +115,12 @@ type ComboboxAsyncBaseProps<TItem extends ComboboxItem> = Omit<ComboboxBaseProps
|
|
|
115
115
|
clearOnDependencyChange?: boolean;
|
|
116
116
|
onDependencyChange?: (value: unknown) => void;
|
|
117
117
|
};
|
|
118
|
-
type ComboboxAsyncSingleProps<TItem extends ComboboxItem> = ComboboxAsyncBaseProps<TItem> & {
|
|
119
|
-
/** Selection mode
|
|
120
|
-
type
|
|
118
|
+
export type ComboboxAsyncSingleProps<TItem extends ComboboxItem> = ComboboxAsyncBaseProps<TItem> & {
|
|
119
|
+
/** Selection mode */
|
|
120
|
+
type: 'single';
|
|
121
121
|
value?: string;
|
|
122
122
|
};
|
|
123
|
-
type ComboboxAsyncMultipleProps<TItem extends ComboboxItem> = ComboboxAsyncBaseProps<TItem> & {
|
|
123
|
+
export type ComboboxAsyncMultipleProps<TItem extends ComboboxItem> = ComboboxAsyncBaseProps<TItem> & {
|
|
124
124
|
/** Selection mode */
|
|
125
125
|
type: 'multiple';
|
|
126
126
|
value?: string[];
|
|
@@ -7,30 +7,16 @@
|
|
|
7
7
|
let { item, children: childSnippet }: ComboboxItemProps<TItem> = $props();
|
|
8
8
|
|
|
9
9
|
const rootState = ComboboxRootState.get<TItem>();
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
preventSelect: _____,
|
|
21
|
-
__creatable: ______,
|
|
22
|
-
inputValue: _______,
|
|
23
|
-
...restItem
|
|
24
|
-
} = item;
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
value,
|
|
28
|
-
onSelect: () => {
|
|
29
|
-
onSelect?.();
|
|
30
|
-
rootState.selectItem(item);
|
|
31
|
-
},
|
|
32
|
-
...restItem,
|
|
33
|
-
};
|
|
10
|
+
const selected = $derived(rootState.isSelected(item.value));
|
|
11
|
+
const itemAttrs = $derived({
|
|
12
|
+
value: item.value,
|
|
13
|
+
keywords: item.keywords,
|
|
14
|
+
disabled: item.disabled,
|
|
15
|
+
class: item.class,
|
|
16
|
+
onSelect: () => {
|
|
17
|
+
item.onSelect?.();
|
|
18
|
+
rootState.selectItem(item);
|
|
19
|
+
},
|
|
34
20
|
});
|
|
35
21
|
</script>
|
|
36
22
|
|
|
@@ -13,24 +13,9 @@
|
|
|
13
13
|
searchValue = $bindable(''),
|
|
14
14
|
type,
|
|
15
15
|
items = [],
|
|
16
|
-
groups: _groups = [],
|
|
17
|
-
empty: _empty,
|
|
18
16
|
placeholder = 'Select an option',
|
|
19
|
-
searchPlaceholder: _searchPlaceholder,
|
|
20
|
-
portalDisabled: _portalDisabled,
|
|
21
17
|
allowDeselect = true,
|
|
22
|
-
triggerClass: _triggerClass,
|
|
23
|
-
contentClass: _contentClass,
|
|
24
18
|
closeOnSelect,
|
|
25
|
-
maxContentHeight: _maxContentHeight,
|
|
26
|
-
clearable: _clearable,
|
|
27
|
-
trigger: _triggerSnippet,
|
|
28
|
-
item: _itemSnippet,
|
|
29
|
-
label: _labelSnippet,
|
|
30
|
-
size: _size,
|
|
31
|
-
variant: _variant,
|
|
32
|
-
rounded: _rounded,
|
|
33
|
-
fullWidth: _fullWidth,
|
|
34
19
|
onSelect = noop,
|
|
35
20
|
children,
|
|
36
21
|
...restProps
|
|
@@ -60,7 +45,7 @@
|
|
|
60
45
|
placeholder: boxWith(() => placeholder),
|
|
61
46
|
allowDeselect: boxWith(() => allowDeselect),
|
|
62
47
|
closeOnSelect: boxWith(() => closeOnSelect),
|
|
63
|
-
onSelect,
|
|
48
|
+
onSelect: onSelect as unknown as (value: string | string[], item: TItem | null) => void,
|
|
64
49
|
});
|
|
65
50
|
|
|
66
51
|
if (value === undefined) {
|
|
@@ -6,7 +6,7 @@ type ComboboxRootStateOpts<TItem extends ComboboxItem> = WritableBoxedValues<{
|
|
|
6
6
|
value: string | string[] | undefined;
|
|
7
7
|
searchValue: string;
|
|
8
8
|
}> & ReadableBoxedValues<{
|
|
9
|
-
type: typeof SELECTION_TYPE.SINGLE | typeof SELECTION_TYPE.MULTIPLE
|
|
9
|
+
type: typeof SELECTION_TYPE.SINGLE | typeof SELECTION_TYPE.MULTIPLE;
|
|
10
10
|
items: TItem[];
|
|
11
11
|
placeholder: string;
|
|
12
12
|
allowDeselect: boolean;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { SELECTION_TYPE } from '../../internal/constants/selection-type.js';
|
|
2
2
|
import type { Component, Snippet } from 'svelte';
|
|
3
3
|
import type { CommandEmptyProps, CommandGroupHeadingProps, CommandGroupItemsProps, CommandGroupProps, CommandInputProps, CommandListProps, CommandSeparatorProps, CommandViewportProps } from '../command/types.js';
|
|
4
|
-
import type { PrimitivePopoverContentProps, PrimitivePopoverPortalProps } from '../popover/types.js';
|
|
5
|
-
import type { PrimitivePopoverRootProps } from '../popover/types.js';
|
|
4
|
+
import type { PrimitivePopoverContentProps, PrimitivePopoverPortalProps, PrimitivePopoverRootProps } from '../popover/types.js';
|
|
6
5
|
import type { ComboboxTriggerVariantsProps } from './styles.js';
|
|
7
6
|
export type ComboboxItem = {
|
|
8
7
|
value: string;
|
|
@@ -19,53 +18,26 @@ export type ComboboxItem = {
|
|
|
19
18
|
key?: string | number;
|
|
20
19
|
preventSelect?: boolean;
|
|
21
20
|
onSelect?: () => void;
|
|
22
|
-
[key: string]: unknown;
|
|
23
|
-
};
|
|
24
|
-
export type ComboboxGroup = {
|
|
25
|
-
value: string;
|
|
26
|
-
label?: string;
|
|
27
|
-
order?: number;
|
|
28
|
-
separator?: boolean;
|
|
29
21
|
};
|
|
30
22
|
export type ComboboxEmptySnippet = Snippet<[{
|
|
31
23
|
props: Record<string, unknown>;
|
|
32
24
|
}]>;
|
|
33
|
-
type ComboboxBaseProps<TItem extends ComboboxItem = ComboboxItem> = PrimitivePopoverRootProps &
|
|
25
|
+
type ComboboxBaseProps<TItem extends ComboboxItem = ComboboxItem> = PrimitivePopoverRootProps & {
|
|
34
26
|
items?: TItem[];
|
|
35
|
-
groups?: ComboboxGroup[];
|
|
36
|
-
empty?: ComboboxEmptySnippet | string;
|
|
37
27
|
placeholder?: string;
|
|
38
|
-
searchPlaceholder?: string;
|
|
39
28
|
searchValue?: string;
|
|
40
|
-
portalDisabled?: boolean;
|
|
41
29
|
allowDeselect?: boolean;
|
|
42
|
-
triggerClass?: string;
|
|
43
|
-
contentClass?: string;
|
|
44
30
|
closeOnSelect?: boolean;
|
|
45
|
-
maxContentHeight?: string;
|
|
46
|
-
clearable?: boolean;
|
|
47
|
-
trigger?: Snippet<[{
|
|
48
|
-
props: Record<string, unknown>;
|
|
49
|
-
displayValue: string;
|
|
50
|
-
}]>;
|
|
51
|
-
item?: Snippet<[{
|
|
52
|
-
item: TItem;
|
|
53
|
-
props: Record<string, unknown>;
|
|
54
|
-
}]>;
|
|
55
|
-
label?: Snippet<[{
|
|
56
|
-
placeholder: string;
|
|
57
|
-
value: string | string[];
|
|
58
|
-
selectedItems: TItem[];
|
|
59
|
-
}]>;
|
|
60
|
-
onSelect?: (value: string | string[], item: TItem | null) => void;
|
|
61
31
|
};
|
|
62
|
-
type ComboboxSingleProps<TItem extends ComboboxItem = ComboboxItem> = ComboboxBaseProps<TItem> & {
|
|
63
|
-
type
|
|
32
|
+
export type ComboboxSingleProps<TItem extends ComboboxItem = ComboboxItem> = ComboboxBaseProps<TItem> & {
|
|
33
|
+
type: typeof SELECTION_TYPE.SINGLE;
|
|
64
34
|
value?: string;
|
|
35
|
+
onSelect?: (value: string, item: TItem | null) => void;
|
|
65
36
|
};
|
|
66
|
-
type ComboboxMultipleProps<TItem extends ComboboxItem = ComboboxItem> = ComboboxBaseProps<TItem> & {
|
|
37
|
+
export type ComboboxMultipleProps<TItem extends ComboboxItem = ComboboxItem> = ComboboxBaseProps<TItem> & {
|
|
67
38
|
type: typeof SELECTION_TYPE.MULTIPLE;
|
|
68
39
|
value?: string[];
|
|
40
|
+
onSelect?: (value: string[], item: TItem | null) => void;
|
|
69
41
|
};
|
|
70
42
|
export type ComboboxRootProps<TItem extends ComboboxItem = ComboboxItem> = ComboboxSingleProps<TItem> | ComboboxMultipleProps<TItem>;
|
|
71
43
|
export type ComboboxTriggerProps = ComboboxTriggerVariantsProps & {
|