svelte-select-5 6.1.2 → 6.1.4

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 CHANGED
@@ -195,7 +195,11 @@
195
195
  label: value,
196
196
  };
197
197
  } else if (multiple && Array.isArray(value) && value.length > 0) {
198
- value = value.map((item) => (typeof item === 'string' ? { value: item, label: item } : item));
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
 
@@ -282,12 +286,8 @@
282
286
  }
283
287
 
284
288
  function setupMulti() {
285
- if (value) {
286
- if (Array.isArray(value)) {
287
- value = [...value];
288
- } else {
289
- value = [value];
290
- }
289
+ if (value && !Array.isArray(value)) {
290
+ value = [value];
291
291
  }
292
292
  }
293
293
 
@@ -385,9 +385,24 @@
385
385
  if (!value || (multiple ? value.some((selection) => !selection || !selection[itemId]) : !value[itemId])) return;
386
386
 
387
387
  if (Array.isArray(value)) {
388
- value = value.map((selection) => findItem(selection) || selection);
388
+ // Only update if items actually changed
389
+ let needsUpdate = false;
390
+ const newValue = value.map((selection) => {
391
+ const found = findItem(selection);
392
+ if (found && found !== selection) {
393
+ needsUpdate = true;
394
+ return found;
395
+ }
396
+ return selection;
397
+ });
398
+ if (needsUpdate) {
399
+ value = newValue;
400
+ }
389
401
  } else {
390
- value = findItem() || value;
402
+ const found = findItem();
403
+ if (found && found !== value) {
404
+ value = found;
405
+ }
391
406
  }
392
407
  }
393
408
 
@@ -195,7 +195,11 @@
195
195
  label: value,
196
196
  };
197
197
  } else if (multiple && Array.isArray(value) && value.length > 0) {
198
- value = value.map((item) => (typeof item === 'string' ? { value: item, label: item } : item));
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
 
@@ -282,12 +286,8 @@
282
286
  }
283
287
 
284
288
  function setupMulti() {
285
- if (value) {
286
- if (Array.isArray(value)) {
287
- value = [...value];
288
- } else {
289
- value = [value];
290
- }
289
+ if (value && !Array.isArray(value)) {
290
+ value = [value];
291
291
  }
292
292
  }
293
293
 
@@ -385,9 +385,24 @@
385
385
  if (!value || (multiple ? value.some((selection) => !selection || !selection[itemId]) : !value[itemId])) return;
386
386
 
387
387
  if (Array.isArray(value)) {
388
- value = value.map((selection) => findItem(selection) || selection);
388
+ // Only update if items actually changed
389
+ let needsUpdate = false;
390
+ const newValue = value.map((selection) => {
391
+ const found = findItem(selection);
392
+ if (found && found !== selection) {
393
+ needsUpdate = true;
394
+ return found;
395
+ }
396
+ return selection;
397
+ });
398
+ if (needsUpdate) {
399
+ value = newValue;
400
+ }
389
401
  } else {
390
- value = findItem() || value;
402
+ const found = findItem();
403
+ if (found && found !== value) {
404
+ value = found;
405
+ }
391
406
  }
392
407
  }
393
408
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-select-5",
3
- "version": "6.1.2",
3
+ "version": "6.1.4",
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)",