@proyecto-viviana/solid-stately 0.4.0 → 0.4.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/calendar/createDateFieldState.d.ts +56 -18
- package/dist/calendar/createRangeCalendarState.d.ts +10 -0
- package/dist/calendar/createTimeFieldState.d.ts +38 -67
- package/dist/calendar/intl/index.d.ts +10 -0
- package/dist/collections/ListCollection.d.ts +8 -0
- package/dist/collections/createListState.d.ts +12 -0
- package/dist/collections/getChildNodes.d.ts +8 -0
- package/dist/collections/index.d.ts +2 -2
- package/dist/collections/types.d.ts +9 -0
- package/dist/color/intl/index.d.ts +14 -0
- package/dist/dnd/createDroppableCollectionState.d.ts +17 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3444 -1304
- package/dist/index.js.map +1 -1
- package/dist/selection/SelectionManager.d.ts +9 -0
- package/package.json +1 -1
- package/src/calendar/createCalendarState.ts +26 -4
- package/src/calendar/createDateFieldState.ts +614 -459
- package/src/calendar/createRangeCalendarState.ts +212 -11
- package/src/calendar/createTimeFieldState.ts +179 -467
- package/src/calendar/intl/index.ts +364 -0
- package/src/collections/ListCollection.ts +31 -0
- package/src/collections/createListState.ts +92 -1
- package/src/collections/getChildNodes.ts +31 -0
- package/src/collections/index.ts +3 -0
- package/src/collections/types.ts +10 -0
- package/src/color/Color.ts +104 -133
- package/src/color/intl/index.ts +1409 -0
- package/src/combobox/createComboBoxState.ts +30 -13
- package/src/dnd/createDroppableCollectionState.ts +125 -6
- package/src/index.ts +3 -0
- package/src/selection/SelectionManager.ts +15 -0
- package/src/steplist/createStepListState.ts +27 -4
|
@@ -107,4 +107,13 @@ export declare class SelectionManager<T = unknown> {
|
|
|
107
107
|
isLink(key: Key): boolean;
|
|
108
108
|
getItemProps(key: Key): Record<string, unknown> | undefined;
|
|
109
109
|
withCollection(collection: Collection<T>): SelectionManager<T>;
|
|
110
|
+
/**
|
|
111
|
+
* Like {@link withCollection}, but the collection is supplied as a live
|
|
112
|
+
* accessor so the returned manager stays reactive as the collection recomputes
|
|
113
|
+
* (e.g. an Autocomplete filter narrowing the list as the user types). The
|
|
114
|
+
* shared underlying selection/focus state is preserved, and the original
|
|
115
|
+
* (unfiltered) collection is retained as `fullCollection` so a select-all
|
|
116
|
+
* still materializes the filtered-out keys.
|
|
117
|
+
*/
|
|
118
|
+
withCollectionAccessor(collection: () => Collection<T>): SelectionManager<T>;
|
|
110
119
|
}
|
package/package.json
CHANGED
|
@@ -287,7 +287,10 @@ export function createCalendarState<
|
|
|
287
287
|
const [visibleRangeStart, setVisibleRangeStart] = createSignal<CalendarDate>(
|
|
288
288
|
alignVisibleRangeStart(initialFocusedDate),
|
|
289
289
|
);
|
|
290
|
-
|
|
290
|
+
// Init from autoFocus, mirroring @react-stately useCalendarState
|
|
291
|
+
// (`useState(props.autoFocus || false)`). Without autoFocus the calendar
|
|
292
|
+
// mounts unfocused and never steals DOM focus.
|
|
293
|
+
const [isFocused, setFocused] = createSignal(props.autoFocus ?? false);
|
|
291
294
|
const [isPaginating, setIsPaginating] = createSignal(false);
|
|
292
295
|
|
|
293
296
|
// Controlled vs uncontrolled value
|
|
@@ -457,9 +460,13 @@ export function createCalendarState<
|
|
|
457
460
|
return isSameDay(target, toDisplayCalendarDate(v));
|
|
458
461
|
};
|
|
459
462
|
|
|
460
|
-
// Check if a date is focused
|
|
463
|
+
// Check if a date is focused. Mirrors @react-stately/calendar isCellFocused
|
|
464
|
+
// (`isFocused && focusedDate && isSameDay(date, focusedDate)`): the
|
|
465
|
+
// calendar-level `isFocused` flag gates cell focus so the calendar does NOT
|
|
466
|
+
// steal DOM focus on mount. The roving tabbable cell is tracked separately by
|
|
467
|
+
// the cell's `tabIndex` (isSameDay against focusedDate, ungated).
|
|
461
468
|
const isCellFocused = (date: DateValue): boolean => {
|
|
462
|
-
return isSameDay(toDisplayCalendarDate(date), focusedDate());
|
|
469
|
+
return isFocused() && isSameDay(toDisplayCalendarDate(date), focusedDate());
|
|
463
470
|
};
|
|
464
471
|
|
|
465
472
|
// Check if a date is unavailable
|
|
@@ -476,6 +483,15 @@ export function createCalendarState<
|
|
|
476
483
|
const maxValue = access(props.maxValue);
|
|
477
484
|
const calDate = toDisplayCalendarDate(date);
|
|
478
485
|
|
|
486
|
+
// Dates outside the visible range are disabled, mirroring
|
|
487
|
+
// @react-stately/calendar isCellDisabled (`date.compare(startDate) < 0 ||
|
|
488
|
+
// date.compare(endDate) > 0` over the visible range). This is what marks the
|
|
489
|
+
// leading/trailing padding cells (days from the adjacent months that fill out
|
|
490
|
+
// the first/last grid weeks) as aria-disabled.
|
|
491
|
+
const range = visibleRange();
|
|
492
|
+
if (calDate.compare(toDisplayCalendarDate(range.start)) < 0) return true;
|
|
493
|
+
if (calDate.compare(toDisplayCalendarDate(range.end)) > 0) return true;
|
|
494
|
+
|
|
479
495
|
if (minValue && calDate.compare(toDisplayCalendarDate(minValue)) < 0) return true;
|
|
480
496
|
if (maxValue && calDate.compare(toDisplayCalendarDate(maxValue)) > 0) return true;
|
|
481
497
|
|
|
@@ -557,8 +573,14 @@ export function createCalendarState<
|
|
|
557
573
|
};
|
|
558
574
|
|
|
559
575
|
const selectDate = (date: CalendarDate) => {
|
|
576
|
+
// Mirror @react-stately/calendar `selectDate(date) { setValue(date); }`:
|
|
577
|
+
// no isCellDisabled/isCellUnavailable guard here. Upstream gates selection
|
|
578
|
+
// at the cell layer (createCalendarCell handlePointerDown/handleClick guard
|
|
579
|
+
// on isDisabled/isUnavailable before calling selectDate); the state method
|
|
580
|
+
// only refuses when the whole calendar is disabled/readOnly (setValue's
|
|
581
|
+
// guard). Double-guarding here also broke programmatic selection of dates
|
|
582
|
+
// outside the current visible range.
|
|
560
583
|
if (isReadOnly() || isDisabled()) return;
|
|
561
|
-
if (isCellDisabled(date) || isCellUnavailable(date)) return;
|
|
562
584
|
|
|
563
585
|
if (selectionMode() === "multiple") {
|
|
564
586
|
const current = value();
|