@streamscloud/kit 0.2.31 → 0.2.33
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/ui/selects/cmp.multiselect.svelte +8 -7
- package/dist/ui/selects/cmp.multiselect.svelte.d.ts +4 -0
- package/dist/ui/selects/cmp.search-multiselect.svelte +6 -5
- package/dist/ui/selects/cmp.search-multiselect.svelte.d.ts +4 -0
- package/dist/ui/selects/cmp.singleselect.svelte +5 -4
- package/dist/ui/selects/cmp.singleselect.svelte.d.ts +4 -0
- package/package.json +1 -1
|
@@ -7,11 +7,12 @@ import IconReorderDotsVertical from '@fluentui/svg-icons/icons/re_order_dots_ver
|
|
|
7
7
|
import Fuse from 'fuse.js';
|
|
8
8
|
import { dndzone } from 'svelte-dnd-action';
|
|
9
9
|
import Select from 'svelte-select';
|
|
10
|
-
let { value = null, options = [], placeholder = '', disabled = false, loading = false, creatable = null, inlineSelection = false, hideEmptyState = false, showFullItem = false, reorderable = false, on, icon, chevronIcon } = $props();
|
|
10
|
+
let { value = null, options = [], placeholder = '', disabled = false, loading = false, creatable = null, inlineSelection = false, hideEmptyState = false, showFullItem = false, reorderable = false, compareBy, floatingStrategy = 'absolute', on, icon, chevronIcon } = $props();
|
|
11
|
+
const valuesEqual = (a, b) => (compareBy ? compareBy(a) === compareBy(b) : a === b);
|
|
11
12
|
const loc = new SelectLocalization();
|
|
12
13
|
let listOpen = $state(false);
|
|
13
14
|
let filterText = $state('');
|
|
14
|
-
const floatingConfig = { strategy:
|
|
15
|
+
const floatingConfig = $derived({ strategy: floatingStrategy });
|
|
15
16
|
const flattenGroupedOptions = (opts) => {
|
|
16
17
|
const result = [];
|
|
17
18
|
for (const opt of opts) {
|
|
@@ -34,9 +35,9 @@ $effect(() => {
|
|
|
34
35
|
}
|
|
35
36
|
else {
|
|
36
37
|
selectValue = value
|
|
37
|
-
.filter((v) => flatOptions.some((o) => o.value
|
|
38
|
+
.filter((v) => flatOptions.some((o) => valuesEqual(o.value, v)))
|
|
38
39
|
.map((v) => {
|
|
39
|
-
const existent = flatOptions.find((x) => x.value
|
|
40
|
+
const existent = flatOptions.find((x) => valuesEqual(x.value, v));
|
|
40
41
|
return {
|
|
41
42
|
id: typeof existent.value === 'string' ? existent.value : JSON.stringify(existent.value),
|
|
42
43
|
label: existent.label,
|
|
@@ -100,7 +101,7 @@ const onSelectFilter = (itemsFiltered) => {
|
|
|
100
101
|
label: x.label,
|
|
101
102
|
value: x.value,
|
|
102
103
|
$isCreated: false,
|
|
103
|
-
group: flatOptions.find((f) => f.value
|
|
104
|
+
group: flatOptions.find((f) => valuesEqual(f.value, x.value))?.group
|
|
104
105
|
}))
|
|
105
106
|
];
|
|
106
107
|
}
|
|
@@ -112,11 +113,11 @@ const onSelectFilter = (itemsFiltered) => {
|
|
|
112
113
|
};
|
|
113
114
|
const onClear = (item) => {
|
|
114
115
|
const items = Array.isArray(item) ? item : [item];
|
|
115
|
-
const itemsRemaining = selectValue.filter((x) => !items.some((i) => i.value
|
|
116
|
+
const itemsRemaining = selectValue.filter((x) => !items.some((i) => !i.$isCreated && valuesEqual(i.value, x.value)));
|
|
116
117
|
on?.change?.(itemsRemaining.map((x) => x.value));
|
|
117
118
|
};
|
|
118
119
|
const removeItem = (item) => {
|
|
119
|
-
const itemsRemaining = selectValue.filter((x) => x.value
|
|
120
|
+
const itemsRemaining = selectValue.filter((x) => !valuesEqual(x.value, item.value));
|
|
120
121
|
on?.change?.(itemsRemaining.map((x) => x.value));
|
|
121
122
|
};
|
|
122
123
|
const flipDurationMs = 200;
|
|
@@ -17,6 +17,10 @@ declare function $$render<T>(): {
|
|
|
17
17
|
showFullItem?: boolean;
|
|
18
18
|
/** Enable drag-and-drop reordering of external tags */
|
|
19
19
|
reorderable?: boolean;
|
|
20
|
+
/** Custom equality comparator for option values. When provided, two values are equal if compareBy(a) === compareBy(b). */
|
|
21
|
+
compareBy?: (value: T) => string | number;
|
|
22
|
+
/** Floating UI positioning strategy. Use 'fixed' when the select is inside an overflow-hidden container. */
|
|
23
|
+
floatingStrategy?: "absolute" | "fixed";
|
|
20
24
|
on?: {
|
|
21
25
|
change?: (value: T[]) => void;
|
|
22
26
|
create?: (label: string) => void;
|
|
@@ -9,11 +9,12 @@ import Fuse from 'fuse.js';
|
|
|
9
9
|
import { nanoid } from 'nanoid';
|
|
10
10
|
import { dndzone } from 'svelte-dnd-action';
|
|
11
11
|
import Select from 'svelte-select';
|
|
12
|
-
let { value = null, loadOptions: loadOptionsFn, debounce = 350, placeholder = '', disabled = false, loading = false, creatable = null, inlineSelection = false, hideEmptyState = false, showFullItem = false, showChevron = false, maxVisibleItems = undefined, reorderable = false, on, icon, chevronIcon, optionSnippet } = $props();
|
|
12
|
+
let { value = null, loadOptions: loadOptionsFn, debounce = 350, placeholder = '', disabled = false, loading = false, creatable = null, inlineSelection = false, hideEmptyState = false, showFullItem = false, showChevron = false, maxVisibleItems = undefined, reorderable = false, compareBy, floatingStrategy = 'absolute', on, icon, chevronIcon, optionSnippet } = $props();
|
|
13
|
+
const valuesEqual = (a, b) => (compareBy ? compareBy(a) === compareBy(b) : a === b);
|
|
13
14
|
const loc = new SelectLocalization();
|
|
14
15
|
let listOpen = $state(false);
|
|
15
16
|
let filterText = $state('');
|
|
16
|
-
const floatingConfig = { strategy:
|
|
17
|
+
const floatingConfig = $derived({ strategy: floatingStrategy });
|
|
17
18
|
let loadingIndicatorShown = $state(false);
|
|
18
19
|
let loadingIndicatorTimeout = null;
|
|
19
20
|
$effect(() => {
|
|
@@ -44,7 +45,7 @@ let createOption = $state(null);
|
|
|
44
45
|
let actualOptions = $state([]);
|
|
45
46
|
const generateOptions = (selected, actual, created) => {
|
|
46
47
|
const generated = actual
|
|
47
|
-
.filter((x) => !selected.some((v) => v.value
|
|
48
|
+
.filter((x) => !selected.some((v) => valuesEqual(v.value, x.value)))
|
|
48
49
|
.map((x) => ({
|
|
49
50
|
label: x.label,
|
|
50
51
|
value: x.value,
|
|
@@ -109,11 +110,11 @@ const onSelectFilter = () => {
|
|
|
109
110
|
};
|
|
110
111
|
const onClear = (item) => {
|
|
111
112
|
const items = Array.isArray(item) ? item : [item];
|
|
112
|
-
const itemsRemaining = selectValue.filter((x) => !items.some((i) => i.value
|
|
113
|
+
const itemsRemaining = selectValue.filter((x) => !items.some((i) => !i.$isCreated && valuesEqual(i.value, x.value)));
|
|
113
114
|
on?.change?.(itemsRemaining.map((x) => ({ label: x.label, value: x.value })));
|
|
114
115
|
};
|
|
115
116
|
const removeItem = (item) => {
|
|
116
|
-
const itemsRemaining = selectValue.filter((x) => x.value
|
|
117
|
+
const itemsRemaining = selectValue.filter((x) => !valuesEqual(x.value, item.value));
|
|
117
118
|
on?.change?.(itemsRemaining.map((x) => ({ label: x.label, value: x.value })));
|
|
118
119
|
};
|
|
119
120
|
const flipDurationMs = 200;
|
|
@@ -24,6 +24,10 @@ declare function $$render<T>(): {
|
|
|
24
24
|
maxVisibleItems?: number;
|
|
25
25
|
/** Enable drag-and-drop reordering of external tags */
|
|
26
26
|
reorderable?: boolean;
|
|
27
|
+
/** Custom equality comparator for option values. When provided, two values are equal if compareBy(a) === compareBy(b). */
|
|
28
|
+
compareBy?: (value: T) => string | number;
|
|
29
|
+
/** Floating UI positioning strategy. Use 'fixed' when the select is inside an overflow-hidden container. */
|
|
30
|
+
floatingStrategy?: "absolute" | "fixed";
|
|
27
31
|
on?: {
|
|
28
32
|
change?: (value: SelectOption<T>[]) => void;
|
|
29
33
|
create?: (label: string) => void;
|
|
@@ -4,11 +4,12 @@ import IconAdd from '@fluentui/svg-icons/icons/add_16_filled.svg?raw';
|
|
|
4
4
|
import IconChevronDown from '@fluentui/svg-icons/icons/chevron_down_20_regular.svg?raw';
|
|
5
5
|
import Fuse from 'fuse.js';
|
|
6
6
|
import Select from 'svelte-select';
|
|
7
|
-
let { value = null, options = [], placeholder = '', disabled = false, loading = false, creatable = null, allowReset = false, groupHeaderSelectable = false, on, icon, optionSnippet, selectionSnippet } = $props();
|
|
7
|
+
let { value = null, options = [], placeholder = '', disabled = false, loading = false, creatable = null, allowReset = false, groupHeaderSelectable = false, compareBy, floatingStrategy = 'absolute', on, icon, optionSnippet, selectionSnippet } = $props();
|
|
8
|
+
const valuesEqual = (a, b) => (compareBy ? compareBy(a) === compareBy(b) : a === b);
|
|
8
9
|
const loc = new SelectLocalization();
|
|
9
10
|
let listOpen = $state(false);
|
|
10
11
|
let filterText = $state('');
|
|
11
|
-
const floatingConfig = { strategy:
|
|
12
|
+
const floatingConfig = $derived({ strategy: floatingStrategy });
|
|
12
13
|
const flattenGroupedOptions = (opts) => {
|
|
13
14
|
const result = [];
|
|
14
15
|
for (const opt of opts) {
|
|
@@ -26,7 +27,7 @@ const flattenGroupedOptions = (opts) => {
|
|
|
26
27
|
const flatOptions = $derived(flattenGroupedOptions(options));
|
|
27
28
|
let selectValue = $state.raw(null);
|
|
28
29
|
$effect(() => {
|
|
29
|
-
const existent = flatOptions.find((x) => x.value
|
|
30
|
+
const existent = value !== null ? flatOptions.find((x) => valuesEqual(x.value, value)) : null;
|
|
30
31
|
if (existent) {
|
|
31
32
|
selectValue = {
|
|
32
33
|
label: existent.label,
|
|
@@ -124,7 +125,7 @@ const onSelectFilter = (itemsFiltered) => {
|
|
|
124
125
|
label: x.label,
|
|
125
126
|
value: x.value,
|
|
126
127
|
$isCreated: false,
|
|
127
|
-
group: flatOptions.find((f) => f.value
|
|
128
|
+
group: flatOptions.find((f) => valuesEqual(f.value, x.value))?.group
|
|
128
129
|
}))
|
|
129
130
|
];
|
|
130
131
|
}
|
|
@@ -13,6 +13,10 @@ declare function $$render<T>(): {
|
|
|
13
13
|
allowReset?: boolean;
|
|
14
14
|
/** Allow clicking group headers to select them */
|
|
15
15
|
groupHeaderSelectable?: boolean;
|
|
16
|
+
/** Custom equality comparator for option values. When provided, two values are equal if compareBy(a) === compareBy(b). */
|
|
17
|
+
compareBy?: (value: T) => string | number;
|
|
18
|
+
/** Floating UI positioning strategy. Use 'fixed' when the select is inside an overflow-hidden container. */
|
|
19
|
+
floatingStrategy?: "absolute" | "fixed";
|
|
16
20
|
on?: {
|
|
17
21
|
change?: (value: T | null) => void;
|
|
18
22
|
create?: (label: string) => void;
|