@proyecto-viviana/solid-stately 0.4.1 → 0.5.1
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/collections/types.d.ts +3 -0
- package/dist/index.js +994 -992
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
- package/src/calendar/createDateFieldState.ts +15 -11
- package/src/calendar/createRangeCalendarState.ts +2 -1
- package/src/calendar/intl/index.ts +168 -140
- package/src/collections/ListCollection.ts +9 -1
- package/src/collections/createListState.ts +13 -1
- package/src/collections/types.ts +3 -0
- package/src/color/Color.ts +5 -7
- package/src/color/intl/index.ts +852 -852
- package/src/combobox/createComboBoxState.ts +18 -3
- package/src/tabs/createTabListState.ts +9 -1
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* either type to filter options or select from a list.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { createSignal, createMemo, createEffect, type Accessor } from "solid-js";
|
|
9
|
+
import { createSignal, createMemo, createEffect, untrack, type Accessor } from "solid-js";
|
|
10
10
|
import { access, type MaybeAccessor } from "../utils";
|
|
11
11
|
import { createListState } from "../collections/createListState";
|
|
12
12
|
import { createOverlayTriggerState } from "../overlays";
|
|
@@ -569,7 +569,22 @@ export function createComboBoxState<T = unknown>(
|
|
|
569
569
|
}
|
|
570
570
|
});
|
|
571
571
|
|
|
572
|
-
//
|
|
572
|
+
// Keep the input text in sync with the selected item (single mode only).
|
|
573
|
+
//
|
|
574
|
+
// This effect must react to the SELECTION and the COLLECTION — when the
|
|
575
|
+
// selected key changes, or when its item (and thus textValue) resolves as
|
|
576
|
+
// items load — but it must NOT react to the input value itself. The previous
|
|
577
|
+
// port compared `textValue !== inputValue()`, reading `inputValue()` inside
|
|
578
|
+
// the effect; in Solid that subscribes the effect to the input signal, so it
|
|
579
|
+
// re-ran on every keystroke and — while any selection was active — immediately
|
|
580
|
+
// reset the input back to the selected item's text. The result: the user
|
|
581
|
+
// could neither type nor delete in the field.
|
|
582
|
+
//
|
|
583
|
+
// The comparison is unchanged, but `inputValue()` is now read via `untrack`,
|
|
584
|
+
// so it is used only to decide whether a reset is needed and never becomes a
|
|
585
|
+
// dependency. `originalCollection()` stays tracked (the unfiltered collection
|
|
586
|
+
// only changes when `items` change, never on filtering) so a preset selection
|
|
587
|
+
// still gets its text once async items arrive.
|
|
573
588
|
createEffect(() => {
|
|
574
589
|
if (isMultiple()) return;
|
|
575
590
|
const key = selectedKey();
|
|
@@ -578,7 +593,7 @@ export function createComboBoxState<T = unknown>(
|
|
|
578
593
|
|
|
579
594
|
// Only update if selection changed and not fully controlled
|
|
580
595
|
if (!isInputControlled() || !isSelectionControlled()) {
|
|
581
|
-
if (key != null && textValue !== inputValue
|
|
596
|
+
if (key != null && textValue !== untrack(inputValue)) {
|
|
582
597
|
setInputValue(textValue);
|
|
583
598
|
setLastValue(textValue);
|
|
584
599
|
}
|
|
@@ -88,7 +88,15 @@ export function createTabListState<T = unknown>(
|
|
|
88
88
|
const nodes: CollectionNode<T>[] = items.map((item, index) => {
|
|
89
89
|
const o = item as CollectionItemLike;
|
|
90
90
|
const key = p.getKey?.(item) ?? o.key ?? o.id ?? index;
|
|
91
|
-
|
|
91
|
+
// See createListState: `String(item)` yields "[object Object]" for a plain
|
|
92
|
+
// object, so widen to name/title and fall back to the key for object items.
|
|
93
|
+
const textValue =
|
|
94
|
+
p.getTextValue?.(item) ??
|
|
95
|
+
o.textValue ??
|
|
96
|
+
o.label ??
|
|
97
|
+
o.name ??
|
|
98
|
+
o.title ??
|
|
99
|
+
(item != null && typeof item === "object" ? String(key) : String(item));
|
|
92
100
|
const isDisabled = p.getDisabled?.(item) ?? o.isDisabled ?? false;
|
|
93
101
|
|
|
94
102
|
return {
|