@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.
Files changed (33) hide show
  1. package/dist/calendar/createDateFieldState.d.ts +56 -18
  2. package/dist/calendar/createRangeCalendarState.d.ts +10 -0
  3. package/dist/calendar/createTimeFieldState.d.ts +38 -67
  4. package/dist/calendar/intl/index.d.ts +10 -0
  5. package/dist/collections/ListCollection.d.ts +8 -0
  6. package/dist/collections/createListState.d.ts +12 -0
  7. package/dist/collections/getChildNodes.d.ts +8 -0
  8. package/dist/collections/index.d.ts +2 -2
  9. package/dist/collections/types.d.ts +9 -0
  10. package/dist/color/intl/index.d.ts +14 -0
  11. package/dist/dnd/createDroppableCollectionState.d.ts +17 -2
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.js +3444 -1304
  14. package/dist/index.js.map +1 -1
  15. package/dist/selection/SelectionManager.d.ts +9 -0
  16. package/package.json +1 -1
  17. package/src/calendar/createCalendarState.ts +26 -4
  18. package/src/calendar/createDateFieldState.ts +614 -459
  19. package/src/calendar/createRangeCalendarState.ts +212 -11
  20. package/src/calendar/createTimeFieldState.ts +179 -467
  21. package/src/calendar/intl/index.ts +364 -0
  22. package/src/collections/ListCollection.ts +31 -0
  23. package/src/collections/createListState.ts +92 -1
  24. package/src/collections/getChildNodes.ts +31 -0
  25. package/src/collections/index.ts +3 -0
  26. package/src/collections/types.ts +10 -0
  27. package/src/color/Color.ts +104 -133
  28. package/src/color/intl/index.ts +1409 -0
  29. package/src/combobox/createComboBoxState.ts +30 -13
  30. package/src/dnd/createDroppableCollectionState.ts +125 -6
  31. package/src/index.ts +3 -0
  32. package/src/selection/SelectionManager.ts +15 -0
  33. 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proyecto-viviana/solid-stately",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "A 1-1 SolidJS port of React Stately - headless state management for UI components",
5
5
  "keywords": [
6
6
  "headless",
@@ -287,7 +287,10 @@ export function createCalendarState<
287
287
  const [visibleRangeStart, setVisibleRangeStart] = createSignal<CalendarDate>(
288
288
  alignVisibleRangeStart(initialFocusedDate),
289
289
  );
290
- const [isFocused, setFocused] = createSignal(false);
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();