svelte-select-5 6.1.1 → 6.1.3
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/Select.svelte +16 -2
- package/no-styles/Select.svelte +16 -2
- package/package.json +1 -1
package/Select.svelte
CHANGED
|
@@ -195,7 +195,11 @@
|
|
|
195
195
|
label: value,
|
|
196
196
|
};
|
|
197
197
|
} else if (multiple && Array.isArray(value) && value.length > 0) {
|
|
198
|
-
|
|
198
|
+
// Only transform if there are string items that need conversion
|
|
199
|
+
const hasStringItems = value.some(item => typeof item === 'string');
|
|
200
|
+
if (hasStringItems) {
|
|
201
|
+
value = value.map((item) => (typeof item === 'string' ? { value: item, label: item } : item));
|
|
202
|
+
}
|
|
199
203
|
}
|
|
200
204
|
}
|
|
201
205
|
|
|
@@ -760,12 +764,17 @@
|
|
|
760
764
|
});
|
|
761
765
|
|
|
762
766
|
// Handle external changes to justValue (allows setting value via justValue)
|
|
767
|
+
// Also handles case where justValue is set before items are loaded
|
|
763
768
|
$effect(() => {
|
|
764
769
|
const computed = computeJustValue();
|
|
765
770
|
const isExternalChange = justValue !== prevJustValue &&
|
|
766
771
|
JSON.stringify(justValue) !== JSON.stringify(computed);
|
|
767
772
|
|
|
768
|
-
if
|
|
773
|
+
// Update value if: external justValue change, OR items loaded while justValue is set but value is empty
|
|
774
|
+
const needsValueUpdate = isExternalChange ||
|
|
775
|
+
(items && justValue != null && !value && JSON.stringify(justValue) !== JSON.stringify(computed));
|
|
776
|
+
|
|
777
|
+
if (needsValueUpdate && items) {
|
|
769
778
|
if (multiple) {
|
|
770
779
|
value = justValue
|
|
771
780
|
? items.filter(item => justValue.includes(item[itemId]))
|
|
@@ -782,6 +791,9 @@
|
|
|
782
791
|
// Read-only props - always reflect current state, external changes are ignored
|
|
783
792
|
$effect(() => {
|
|
784
793
|
readonlyValue = value;
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
$effect(() => {
|
|
785
797
|
readonlyId = computeJustValue();
|
|
786
798
|
});
|
|
787
799
|
|
|
@@ -834,6 +846,8 @@
|
|
|
834
846
|
});
|
|
835
847
|
|
|
836
848
|
onDestroy(() => {
|
|
849
|
+
clearTimeout(timeout);
|
|
850
|
+
clearTimeout(isScrollingTimer);
|
|
837
851
|
list?.remove();
|
|
838
852
|
});
|
|
839
853
|
</script>
|
package/no-styles/Select.svelte
CHANGED
|
@@ -195,7 +195,11 @@
|
|
|
195
195
|
label: value,
|
|
196
196
|
};
|
|
197
197
|
} else if (multiple && Array.isArray(value) && value.length > 0) {
|
|
198
|
-
|
|
198
|
+
// Only transform if there are string items that need conversion
|
|
199
|
+
const hasStringItems = value.some(item => typeof item === 'string');
|
|
200
|
+
if (hasStringItems) {
|
|
201
|
+
value = value.map((item) => (typeof item === 'string' ? { value: item, label: item } : item));
|
|
202
|
+
}
|
|
199
203
|
}
|
|
200
204
|
}
|
|
201
205
|
|
|
@@ -760,12 +764,17 @@
|
|
|
760
764
|
});
|
|
761
765
|
|
|
762
766
|
// Handle external changes to justValue (allows setting value via justValue)
|
|
767
|
+
// Also handles case where justValue is set before items are loaded
|
|
763
768
|
$effect(() => {
|
|
764
769
|
const computed = computeJustValue();
|
|
765
770
|
const isExternalChange = justValue !== prevJustValue &&
|
|
766
771
|
JSON.stringify(justValue) !== JSON.stringify(computed);
|
|
767
772
|
|
|
768
|
-
if
|
|
773
|
+
// Update value if: external justValue change, OR items loaded while justValue is set but value is empty
|
|
774
|
+
const needsValueUpdate = isExternalChange ||
|
|
775
|
+
(items && justValue != null && !value && JSON.stringify(justValue) !== JSON.stringify(computed));
|
|
776
|
+
|
|
777
|
+
if (needsValueUpdate && items) {
|
|
769
778
|
if (multiple) {
|
|
770
779
|
value = justValue
|
|
771
780
|
? items.filter(item => justValue.includes(item[itemId]))
|
|
@@ -782,6 +791,9 @@
|
|
|
782
791
|
// Read-only props - always reflect current state, external changes are ignored
|
|
783
792
|
$effect(() => {
|
|
784
793
|
readonlyValue = value;
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
$effect(() => {
|
|
785
797
|
readonlyId = computeJustValue();
|
|
786
798
|
});
|
|
787
799
|
|
|
@@ -834,6 +846,8 @@
|
|
|
834
846
|
});
|
|
835
847
|
|
|
836
848
|
onDestroy(() => {
|
|
849
|
+
clearTimeout(timeout);
|
|
850
|
+
clearTimeout(isScrollingTimer);
|
|
837
851
|
list?.remove();
|
|
838
852
|
});
|
|
839
853
|
</script>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-select-5",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.3",
|
|
4
4
|
"description": "A <Select> component for Svelte 5 apps (fork of svelte-select)",
|
|
5
5
|
"repository": "https://github.com/Dbone29/svelte-select-5.git",
|
|
6
6
|
"author": "Robert Balfré <rob.balfre@gmail.com> (https://github.com/rob-balfre)",
|