@proyecto-viviana/solid-stately 0.3.0 → 0.4.0
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/IncompleteDate.d.ts +61 -0
- package/dist/calendar/createCalendarState.d.ts +20 -10
- package/dist/calendar/createDateFieldState.d.ts +10 -3
- package/dist/calendar/createRangeCalendarState.d.ts +10 -2
- package/dist/calendar/index.d.ts +1 -1
- package/dist/collections/createListState.d.ts +4 -1
- package/dist/collections/createSelectionState.d.ts +17 -5
- package/dist/collections/getChildNodes.d.ts +11 -0
- package/dist/collections/index.d.ts +2 -1
- package/dist/combobox/createComboBoxState.d.ts +7 -0
- package/dist/dnd/index.d.ts +1 -1
- package/dist/dnd/types.d.ts +3 -1
- package/dist/grid/types.d.ts +17 -3
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1570 -425
- package/dist/index.js.map +1 -1
- package/dist/select/createSelectState.d.ts +6 -0
- package/dist/selection/Selection.d.ts +16 -0
- package/dist/selection/SelectionManager.d.ts +110 -0
- package/dist/selection/createMultipleSelectionState.d.ts +59 -0
- package/dist/selection/index.d.ts +1 -0
- package/dist/table/TableCollection.d.ts +30 -0
- package/dist/table/createTreeGridState.d.ts +15 -0
- package/dist/table/index.d.ts +2 -1
- package/dist/table/types.d.ts +58 -0
- package/dist/toast/createToastState.d.ts +16 -0
- package/dist/toast/index.d.ts +1 -1
- package/dist/tree/types.d.ts +14 -6
- package/package.json +1 -1
- package/src/calendar/IncompleteDate.ts +430 -0
- package/src/calendar/createCalendarState.ts +104 -37
- package/src/calendar/createDateFieldState.ts +262 -261
- package/src/calendar/createRangeCalendarState.ts +131 -19
- package/src/calendar/index.ts +2 -0
- package/src/collections/createListState.ts +50 -19
- package/src/collections/createMenuState.ts +3 -0
- package/src/collections/createSelectionState.ts +38 -28
- package/src/collections/getChildNodes.ts +98 -0
- package/src/collections/index.ts +9 -0
- package/src/combobox/createComboBoxState.ts +8 -0
- package/src/dnd/index.d.ts +1 -0
- package/src/dnd/index.ts +1 -0
- package/src/dnd/types.d.ts +3 -1
- package/src/dnd/types.ts +4 -1
- package/src/grid/createGridState.ts +36 -2
- package/src/grid/types.ts +17 -3
- package/src/index.d.ts +1 -0
- package/src/index.ts +11 -0
- package/src/select/createSelectState.ts +15 -2
- package/src/selection/Selection.ts +28 -0
- package/src/selection/SelectionManager.ts +526 -0
- package/src/selection/createMultipleSelectionState.ts +247 -0
- package/src/selection/index.ts +6 -0
- package/src/table/TableCollection.ts +213 -43
- package/src/table/createTableState.ts +20 -0
- package/src/table/createTreeGridState.ts +146 -0
- package/src/table/index.ts +3 -0
- package/src/table/types.ts +66 -0
- package/src/tabs/createTabListState.ts +11 -9
- package/src/toast/createToastState.ts +43 -10
- package/src/toast/index.ts +1 -0
- package/src/tree/createTreeState.ts +37 -6
- package/src/tree/types.ts +14 -6
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IncompleteDate for Solid-Stately
|
|
3
|
+
*
|
|
4
|
+
* Represents a date that is incomplete or otherwise invalid as a result of user
|
|
5
|
+
* editing (for example February 31st, if the day is edited before the month).
|
|
6
|
+
* This lets a date field hold an invalid intermediate value while typing and
|
|
7
|
+
* only constrain it on blur, matching upstream behavior.
|
|
8
|
+
*
|
|
9
|
+
* Based on @react-stately/datepicker IncompleteDate
|
|
10
|
+
*/
|
|
11
|
+
import { type AnyDateTime, type Calendar, type DateValue } from "@internationalized/date";
|
|
12
|
+
import type { DateSegmentType } from "./createDateFieldState";
|
|
13
|
+
type HourCycle = "h12" | "h11" | "h23" | "h24";
|
|
14
|
+
/**
|
|
15
|
+
* This class represents a date that is incomplete or otherwise invalid as a result of user editing.
|
|
16
|
+
* For example, it can represent temporary dates such as February 31st if the user edits the day
|
|
17
|
+
* before the month. Times are represented according to an hour cycle rather than always in 24 hour
|
|
18
|
+
* time. This enables the user to adjust the day period (e.g. am/pm) independently from the hour.
|
|
19
|
+
*/
|
|
20
|
+
export declare class IncompleteDate {
|
|
21
|
+
calendar: Calendar;
|
|
22
|
+
era: string | null;
|
|
23
|
+
year: number | null;
|
|
24
|
+
month: number | null;
|
|
25
|
+
day: number | null;
|
|
26
|
+
hour: number | null;
|
|
27
|
+
hourCycle: HourCycle;
|
|
28
|
+
dayPeriod: number | null;
|
|
29
|
+
minute: number | null;
|
|
30
|
+
second: number | null;
|
|
31
|
+
millisecond: number | null;
|
|
32
|
+
offset: number | null;
|
|
33
|
+
constructor(calendar: Calendar, hourCycle: HourCycle, dateValue?: Partial<Omit<AnyDateTime, "copy">> | null);
|
|
34
|
+
copy(): IncompleteDate;
|
|
35
|
+
/** Checks whether all the specified segments have a value. */
|
|
36
|
+
isComplete(segments: DateSegmentType[]): boolean;
|
|
37
|
+
/** Checks whether the given date value matches this value for the specified segments. */
|
|
38
|
+
validate(dt: DateValue, segments: DateSegmentType[]): boolean;
|
|
39
|
+
/** Checks if the date is empty (i.e. all specified segments are null). */
|
|
40
|
+
isCleared(segments: DateSegmentType[]): boolean;
|
|
41
|
+
/** Sets the given field. */
|
|
42
|
+
set(field: DateSegmentType, value: number | string, placeholder: DateValue): IncompleteDate;
|
|
43
|
+
/** Sets the given field to null. */
|
|
44
|
+
clear(field: DateSegmentType): IncompleteDate;
|
|
45
|
+
/**
|
|
46
|
+
* Increments or decrements the given field. If it is null, then it is set to the placeholder
|
|
47
|
+
* value.
|
|
48
|
+
*/
|
|
49
|
+
cycle(field: DateSegmentType, amount: number, placeholder: DateValue, displaySegments: DateSegmentType[]): IncompleteDate;
|
|
50
|
+
/**
|
|
51
|
+
* Converts the incomplete date to a full date value, using the provided value for any unset
|
|
52
|
+
* fields.
|
|
53
|
+
*/
|
|
54
|
+
toValue(value: DateValue): DateValue;
|
|
55
|
+
getSegmentLimits(type: string): {
|
|
56
|
+
value: number | null;
|
|
57
|
+
minValue: number;
|
|
58
|
+
maxValue: number;
|
|
59
|
+
} | undefined;
|
|
60
|
+
}
|
|
61
|
+
export {};
|
|
@@ -11,13 +11,17 @@ export type ValidationState = "valid" | "invalid";
|
|
|
11
11
|
export type CalendarPageBehavior = "single" | "visible";
|
|
12
12
|
export type CalendarSelectionAlignment = "start" | "center" | "end";
|
|
13
13
|
export type CalendarDayOfWeek = "sun" | "mon" | "tue" | "wed" | "thu" | "fri" | "sat";
|
|
14
|
-
export
|
|
14
|
+
export type CalendarSelectionMode = "single" | "multiple";
|
|
15
|
+
export type CalendarValueType<T, M extends CalendarSelectionMode> = M extends "single" ? T : readonly T[];
|
|
16
|
+
export interface CalendarStateProps<T extends DateValue = DateValue, M extends CalendarSelectionMode = "single"> {
|
|
15
17
|
/** The current value (controlled). */
|
|
16
|
-
value?: MaybeAccessor<T | null>;
|
|
18
|
+
value?: MaybeAccessor<CalendarValueType<T | null, M> | undefined>;
|
|
17
19
|
/** The default value (uncontrolled). */
|
|
18
|
-
defaultValue?: T | null;
|
|
20
|
+
defaultValue?: CalendarValueType<T | null, M> | null;
|
|
19
21
|
/** Handler called when the value changes. */
|
|
20
|
-
onChange?: (value: T | null) => void;
|
|
22
|
+
onChange?: (value: CalendarValueType<T | null, M>) => void;
|
|
23
|
+
/** Whether single or multiple date selection is enabled. */
|
|
24
|
+
selectionMode?: MaybeAccessor<M>;
|
|
21
25
|
/** The minimum allowed date. */
|
|
22
26
|
minValue?: MaybeAccessor<DateValue | undefined>;
|
|
23
27
|
/** The maximum allowed date. */
|
|
@@ -57,15 +61,21 @@ export interface CalendarStateProps<T extends DateValue = DateValue> {
|
|
|
57
61
|
/** The first day of the week (0 = Sunday, 1 = Monday, etc.). */
|
|
58
62
|
firstDayOfWeek?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
59
63
|
}
|
|
60
|
-
export interface CalendarState<T extends DateValue = DateValue> {
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
|
|
64
|
+
export interface CalendarState<T extends DateValue = DateValue, M extends CalendarSelectionMode = "single"> {
|
|
65
|
+
/** Whether single or multiple selection is enabled. */
|
|
66
|
+
selectionMode: Accessor<CalendarSelectionMode>;
|
|
67
|
+
/** The currently selected date(s). */
|
|
68
|
+
value: Accessor<CalendarValueType<T | null, M>>;
|
|
69
|
+
/** Sets the selected date(s). */
|
|
70
|
+
setValue: (value: CalendarValueType<T | null, M>) => void;
|
|
65
71
|
/** The currently focused date. */
|
|
66
72
|
focusedDate: Accessor<CalendarDate>;
|
|
67
73
|
/** Sets the focused date. */
|
|
68
74
|
setFocusedDate: (date: CalendarDate) => void;
|
|
75
|
+
/** The minimum allowed date that a user may select. */
|
|
76
|
+
minValue: Accessor<DateValue | null>;
|
|
77
|
+
/** The maximum allowed date that a user may select. */
|
|
78
|
+
maxValue: Accessor<DateValue | null>;
|
|
69
79
|
/** Whether the calendar is disabled. */
|
|
70
80
|
isDisabled: Accessor<boolean>;
|
|
71
81
|
/** Whether the calendar is read-only. */
|
|
@@ -141,4 +151,4 @@ export interface CalendarState<T extends DateValue = DateValue> {
|
|
|
141
151
|
/**
|
|
142
152
|
* Provides state management for a calendar component.
|
|
143
153
|
*/
|
|
144
|
-
export declare function createCalendarState<T extends DateValue = CalendarDate>(props?: CalendarStateProps<T>): CalendarState<T>;
|
|
154
|
+
export declare function createCalendarState<T extends DateValue = CalendarDate, M extends CalendarSelectionMode = "single">(props?: CalendarStateProps<T, M>): CalendarState<T, M>;
|
|
@@ -3,9 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides state management for date field components with segment-based editing.
|
|
5
5
|
* Based on @react-stately/datepicker useDateFieldState
|
|
6
|
+
*
|
|
7
|
+
* Editing is modeled with an {@link IncompleteDate} display value so that invalid
|
|
8
|
+
* intermediate dates (e.g. February 31st, produced by editing the day before the
|
|
9
|
+
* month) are held as-typed while the field is focused and only constrained on blur
|
|
10
|
+
* via `confirmPlaceholder`, matching upstream behavior. Out-of-range values are
|
|
11
|
+
* never snapped to `minValue`/`maxValue`; they are kept and reported as invalid.
|
|
6
12
|
*/
|
|
7
13
|
import { type Accessor } from "solid-js";
|
|
8
|
-
import {
|
|
14
|
+
import { type CalendarDateTime, type DateValue } from "@internationalized/date";
|
|
9
15
|
import { type MaybeAccessor } from "../utils";
|
|
10
16
|
import type { ValidationState } from "./createCalendarState";
|
|
11
17
|
import { type ValidationBehavior, type ValidationFunction, type ValidationResult } from "../form";
|
|
@@ -16,7 +22,7 @@ export interface DateSegment {
|
|
|
16
22
|
/** The text content of the segment. */
|
|
17
23
|
text: string;
|
|
18
24
|
/** The numeric value of the segment (if applicable). */
|
|
19
|
-
value?: number;
|
|
25
|
+
value?: number | null;
|
|
20
26
|
/** The minimum value for the segment. */
|
|
21
27
|
minValue?: number;
|
|
22
28
|
/** The maximum value for the segment. */
|
|
@@ -129,4 +135,5 @@ export interface DateFieldState<T extends DateValue = DateValue> {
|
|
|
129
135
|
/**
|
|
130
136
|
* Provides state management for a date field component.
|
|
131
137
|
*/
|
|
132
|
-
export declare function createDateFieldState<T extends DateValue =
|
|
138
|
+
export declare function createDateFieldState<T extends DateValue = DateValue>(props?: DateFieldStateProps<T>): DateFieldState<T>;
|
|
139
|
+
export type { CalendarDateTime };
|
|
@@ -43,8 +43,12 @@ export interface RangeCalendarStateProps<T extends DateValue = DateValue> {
|
|
|
43
43
|
locale?: MaybeAccessor<string | undefined>;
|
|
44
44
|
/** Creates a calendar object for a locale calendar identifier. */
|
|
45
45
|
createCalendar?: (identifier: CalendarIdentifier) => InternationalizedCalendar;
|
|
46
|
-
/**
|
|
47
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Callback that determines if a date is unavailable. The second argument is the
|
|
48
|
+
* current selection anchor (the first selected date), so availability can be
|
|
49
|
+
* derived from it. Mirrors @react-stately/calendar 1.18.
|
|
50
|
+
*/
|
|
51
|
+
isDateUnavailable?: (date: DateValue, anchorDate: CalendarDate | null) => boolean;
|
|
48
52
|
/** The number of months to display at once. */
|
|
49
53
|
visibleMonths?: MaybeAccessor<number | undefined>;
|
|
50
54
|
/** Controls how the initial visible months are aligned around the current value. */
|
|
@@ -69,6 +73,10 @@ export interface RangeCalendarState<T extends DateValue = DateValue> {
|
|
|
69
73
|
focusedDate: Accessor<CalendarDate>;
|
|
70
74
|
/** Sets the focused date. */
|
|
71
75
|
setFocusedDate: (date: CalendarDate) => void;
|
|
76
|
+
/** The minimum allowed date that a user may select. */
|
|
77
|
+
minValue: Accessor<DateValue | null>;
|
|
78
|
+
/** The maximum allowed date that a user may select. */
|
|
79
|
+
maxValue: Accessor<DateValue | null>;
|
|
72
80
|
/** The anchor date when selecting a range (first click). */
|
|
73
81
|
anchorDate: Accessor<CalendarDate | null>;
|
|
74
82
|
/** Sets the anchor date. */
|
package/dist/calendar/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createCalendarState, type CalendarStateProps, type CalendarState, type ValidationState, type CalendarPageBehavior, type CalendarSelectionAlignment, type CalendarDayOfWeek, } from "./createCalendarState";
|
|
1
|
+
export { createCalendarState, type CalendarStateProps, type CalendarState, type CalendarSelectionMode, type CalendarValueType, type ValidationState, type CalendarPageBehavior, type CalendarSelectionAlignment, type CalendarDayOfWeek, } from "./createCalendarState";
|
|
2
2
|
export { createRangeCalendarState, type RangeCalendarStateProps, type RangeCalendarState, type DateRange, type RangeValue, } from "./createRangeCalendarState";
|
|
3
3
|
export { createDateFieldState, type DateFieldStateProps, type DateFieldState, type DateSegment, type DateSegmentType, } from "./createDateFieldState";
|
|
4
4
|
export { createTimeFieldState, type TimeFieldStateProps, type TimeFieldState, type TimeSegment, type TimeSegmentType, type TimeValue, } from "./createTimeFieldState";
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { type Accessor } from "solid-js";
|
|
7
7
|
import { type MaybeAccessor } from "../utils";
|
|
8
|
-
import {
|
|
8
|
+
import type { SelectionState } from "./createSelectionState";
|
|
9
|
+
import { SelectionManager } from "../selection/SelectionManager";
|
|
9
10
|
import type { Collection, CollectionNode, DisabledBehavior, FocusStrategy, Key, SelectionBehavior, SelectionMode } from "./types";
|
|
10
11
|
export interface ListStateProps<T = unknown> {
|
|
11
12
|
/** The items in the list (for dynamic rendering). */
|
|
@@ -38,6 +39,8 @@ export interface ListStateProps<T = unknown> {
|
|
|
38
39
|
export interface ListState<T = unknown> extends SelectionState {
|
|
39
40
|
/** The collection of items. */
|
|
40
41
|
readonly collection: Accessor<Collection<T>>;
|
|
42
|
+
/** The collection-aware selection manager (single source of truth for selection). */
|
|
43
|
+
readonly selectionManager: SelectionManager<T>;
|
|
41
44
|
/** Whether the collection is focused. */
|
|
42
45
|
readonly isFocused: Accessor<boolean>;
|
|
43
46
|
/** Set the focused state. */
|
|
@@ -63,11 +63,23 @@ export interface SelectionState {
|
|
|
63
63
|
/** Extend selection to a key (for shift-click). */
|
|
64
64
|
extendSelection(toKey: Key, collection: Collection): void;
|
|
65
65
|
/** Select a key based on interaction. */
|
|
66
|
-
select(key: Key, e?:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
select(key: Key, e?: SelectionPressEvent): void;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The press/pointer interaction consulted by {@link SelectionState.select}.
|
|
70
|
+
* Mirrors react-stately's `SelectionManager.select(e)`: only `pointerType` is
|
|
71
|
+
* read here (touch / virtual force toggle, since those devices have no modifier
|
|
72
|
+
* keys). Modifier keys (ctrl / meta / shift) are resolved one layer up in the
|
|
73
|
+
* aria-layer `onSelect` (solidaria `selectItem`), matching upstream's split
|
|
74
|
+
* between react-stately and react-aria. The modifier fields are accepted so a
|
|
75
|
+
* full press/pointer event is assignable, but they are not read here.
|
|
76
|
+
*/
|
|
77
|
+
export interface SelectionPressEvent {
|
|
78
|
+
pointerType?: "mouse" | "pen" | "touch" | "keyboard" | "virtual";
|
|
79
|
+
shiftKey?: boolean;
|
|
80
|
+
ctrlKey?: boolean;
|
|
81
|
+
metaKey?: boolean;
|
|
82
|
+
altKey?: boolean;
|
|
71
83
|
}
|
|
72
84
|
/**
|
|
73
85
|
* Creates selection state for a collection.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for traversing collection nodes and comparing their document order.
|
|
3
|
+
*
|
|
4
|
+
* Based on @react-stately/collections.
|
|
5
|
+
*/
|
|
6
|
+
import type { Collection, CollectionNode } from "./types";
|
|
7
|
+
export declare function getChildNodes<T>(node: CollectionNode<T>, collection: Collection<T>): Iterable<CollectionNode<T>>;
|
|
8
|
+
export declare function getFirstItem<T>(iterable: Iterable<T>): T | undefined;
|
|
9
|
+
export declare function getNthItem<T>(iterable: Iterable<T>, index: number): T | undefined;
|
|
10
|
+
export declare function getLastItem<T>(iterable: Iterable<T>): T | undefined;
|
|
11
|
+
export declare function compareNodeOrder<T>(collection: Collection<T>, a: CollectionNode<T>, b: CollectionNode<T>): number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type { Key, SelectionMode, SelectionBehavior, Selection, FocusStrategy, DisabledBehavior, CollectionNode, Collection, ItemProps, SectionProps, CollectionBase, SingleSelection, MultipleSelection, } from "./types";
|
|
2
2
|
export { ListCollection, createListCollection } from "./ListCollection";
|
|
3
|
-
export {
|
|
3
|
+
export { getChildNodes, getFirstItem, getNthItem, getLastItem, compareNodeOrder, } from "./getChildNodes";
|
|
4
|
+
export { createSelectionState, type SelectionStateProps, type SelectionState, type SelectionPressEvent, } from "./createSelectionState";
|
|
4
5
|
export { createListState, createSingleSelectListState, type ListStateProps, type ListState, type SingleSelectListStateProps, type SingleSelectListState, } from "./createListState";
|
|
5
6
|
export { createMenuState, createMenuTriggerState, type MenuStateProps, type MenuState, type MenuTriggerStateProps, type MenuTriggerState, } from "./createMenuState";
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { type Accessor } from "solid-js";
|
|
9
9
|
import { type MaybeAccessor } from "../utils";
|
|
10
10
|
import type { Key, CollectionNode, Collection, FocusStrategy } from "../collections/types";
|
|
11
|
+
import type { SelectionManager } from "../selection/SelectionManager";
|
|
11
12
|
export type MenuTriggerAction = "focus" | "input" | "manual";
|
|
12
13
|
export type { FocusStrategy } from "../collections/types";
|
|
13
14
|
export type FilterFn = (textValue: string, inputValue: string) => boolean;
|
|
@@ -70,6 +71,12 @@ export interface ComboBoxStateProps<T = unknown> {
|
|
|
70
71
|
export interface ComboBoxState<T = unknown> {
|
|
71
72
|
/** The collection of items (may be filtered). */
|
|
72
73
|
readonly collection: Accessor<Collection<T>>;
|
|
74
|
+
/**
|
|
75
|
+
* The collection-aware selection manager. Mirrors upstream `useComboBoxState`,
|
|
76
|
+
* which returns the `useListState` selection manager bound to the unfiltered
|
|
77
|
+
* collection (selection spans all items; filtering is display-only).
|
|
78
|
+
*/
|
|
79
|
+
readonly selectionManager: SelectionManager<T>;
|
|
73
80
|
/** Whether the combobox dropdown is open. */
|
|
74
81
|
readonly isOpen: Accessor<boolean>;
|
|
75
82
|
/** Open the combobox dropdown. */
|
package/dist/dnd/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Exports for DnD functionality.
|
|
5
5
|
*/
|
|
6
|
-
export type { DropOperation, DragItem, DragDropEvent, DragStartEvent, DragMoveEvent, DragEndEvent, DropEnterEvent, DropMoveEvent, DropActivateEvent, DropExitEvent, TextDropItem, FileDropItem, DirectoryDropItem, DropItem, DropEvent, DropPosition, RootDropTarget, ItemDropTarget, DropTarget, DroppableCollectionEnterEvent, DroppableCollectionMoveEvent, DroppableCollectionActivateEvent, DroppableCollectionExitEvent, DroppableCollectionDropEvent, DroppableCollectionInsertDropEvent, DroppableCollectionRootDropEvent, DroppableCollectionOnItemDropEvent, DroppableCollectionReorderEvent, DragTypes, DropTargetDelegate, DraggableCollectionStartEvent, DraggableCollectionMoveEvent, DraggableCollectionEndEvent, DragPreviewRenderer, DroppableCollectionUtilityOptions, DroppableCollectionBaseProps, DroppableCollectionProps, DraggableCollectionProps, } from "./types";
|
|
6
|
+
export type { DropOperation, DragItem, DragDropEvent, DragStartEvent, DragMoveEvent, DragEndEvent, DropEnterEvent, DropMoveEvent, DropActivateEvent, DropExitEvent, TextDropItem, FileDropItem, DirectoryDropItem, DropItem, DropEvent, DropPosition, RootDropTarget, ItemDropTarget, DropTarget, DroppableCollectionEnterEvent, DroppableCollectionMoveEvent, DroppableCollectionActivateEvent, DroppableCollectionExitEvent, DroppableCollectionDropEvent, DroppableCollectionInsertDropEvent, DroppableCollectionRootDropEvent, DroppableCollectionOnItemDropEvent, DroppableCollectionReorderEvent, DragType, DragTypes, DropTargetDelegate, DraggableCollectionStartEvent, DraggableCollectionMoveEvent, DraggableCollectionEndEvent, DragPreviewRenderer, DroppableCollectionUtilityOptions, DroppableCollectionBaseProps, DroppableCollectionProps, DraggableCollectionProps, } from "./types";
|
|
7
7
|
export { createDragState, type DragStateOptions, type DragState } from "./createDragState";
|
|
8
8
|
export { createDropState, type DropStateOptions, type DropState } from "./createDropState";
|
|
9
9
|
export { createDraggableCollectionState, type DraggableCollectionStateOptions, type DraggableCollectionState, } from "./createDraggableCollectionState";
|
package/dist/dnd/types.d.ts
CHANGED
|
@@ -174,10 +174,12 @@ export interface DroppableCollectionReorderEvent {
|
|
|
174
174
|
/** The drop target. */
|
|
175
175
|
target: ItemDropTarget;
|
|
176
176
|
}
|
|
177
|
+
/** A drag type: either a MIME type string or a symbol such as the directory drag type. */
|
|
178
|
+
export type DragType = string | symbol;
|
|
177
179
|
/** Interface for checking drag types. */
|
|
178
180
|
export interface DragTypes {
|
|
179
181
|
/** Returns whether the drag contains data of the given type. */
|
|
180
|
-
has(type:
|
|
182
|
+
has(type: DragType | DragType[]): boolean;
|
|
181
183
|
}
|
|
182
184
|
/** Delegate for determining drop targets within a collection. */
|
|
183
185
|
export interface DropTargetDelegate {
|
package/dist/grid/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Grid collection types for Table and GridList components.
|
|
3
3
|
* Based on @react-types/grid.
|
|
4
4
|
*/
|
|
5
|
-
import type { Key, FocusStrategy } from "../collections/types";
|
|
5
|
+
import type { Key, FocusStrategy, Selection, SelectionBehavior } from "../collections/types";
|
|
6
6
|
/**
|
|
7
7
|
* Represents the type of a grid node.
|
|
8
8
|
*/
|
|
@@ -31,6 +31,10 @@ export interface GridNode<T = unknown> {
|
|
|
31
31
|
prevKey?: Key | null;
|
|
32
32
|
/** Next sibling key (visible order). */
|
|
33
33
|
nextKey?: Key | null;
|
|
34
|
+
/** Key of the first child node, if any (used by tree grids). */
|
|
35
|
+
firstChildKey?: Key | null;
|
|
36
|
+
/** Key of the last child node, if any (used by tree grids). */
|
|
37
|
+
lastChildKey?: Key | null;
|
|
34
38
|
/** Whether this node has child nodes. */
|
|
35
39
|
hasChildNodes: boolean;
|
|
36
40
|
/** Child nodes (cells for rows, rows for sections). */
|
|
@@ -99,6 +103,8 @@ export interface GridState<T, C extends GridCollection<T> = GridCollection<T>> {
|
|
|
99
103
|
readonly collection: C;
|
|
100
104
|
/** Keys of disabled rows. */
|
|
101
105
|
readonly disabledKeys: Set<Key>;
|
|
106
|
+
/** Whether `disabledKeys` applies to all interactions, or only selection. */
|
|
107
|
+
readonly disabledBehavior: "selection" | "all";
|
|
102
108
|
/** Whether keyboard navigation is disabled. */
|
|
103
109
|
readonly isKeyboardNavigationDisabled: boolean;
|
|
104
110
|
/** Currently focused key. */
|
|
@@ -110,7 +116,9 @@ export interface GridState<T, C extends GridCollection<T> = GridCollection<T>> {
|
|
|
110
116
|
/** The selection mode. */
|
|
111
117
|
readonly selectionMode: "none" | "single" | "multiple";
|
|
112
118
|
/** The selection behavior. */
|
|
113
|
-
readonly selectionBehavior:
|
|
119
|
+
readonly selectionBehavior: SelectionBehavior;
|
|
120
|
+
/** Whether empty selection is disallowed. */
|
|
121
|
+
readonly disallowEmptySelection: boolean;
|
|
114
122
|
/** The currently selected keys. */
|
|
115
123
|
readonly selectedKeys: "all" | Set<Key>;
|
|
116
124
|
/** Check if a key is selected. */
|
|
@@ -121,10 +129,14 @@ export interface GridState<T, C extends GridCollection<T> = GridCollection<T>> {
|
|
|
121
129
|
setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy): void;
|
|
122
130
|
/** Set focused state. */
|
|
123
131
|
setFocused(isFocused: boolean): void;
|
|
132
|
+
/** Set the selection behavior. */
|
|
133
|
+
setSelectionBehavior(behavior: SelectionBehavior): void;
|
|
124
134
|
/** Toggle selection for a key. */
|
|
125
135
|
toggleSelection(key: Key): void;
|
|
126
136
|
/** Replace selection with a key. */
|
|
127
137
|
replaceSelection(key: Key): void;
|
|
138
|
+
/** Set multiple selected keys. */
|
|
139
|
+
setSelectedKeys(keys: Selection | Iterable<Key>): void;
|
|
128
140
|
/** Extend selection to a key (shift-click). */
|
|
129
141
|
extendSelection(toKey: Key): void;
|
|
130
142
|
/** Select all rows. */
|
|
@@ -144,12 +156,14 @@ export interface GridStateOptions<T, C extends GridCollection<T> = GridCollectio
|
|
|
144
156
|
collection: C;
|
|
145
157
|
/** Keys of disabled rows. */
|
|
146
158
|
disabledKeys?: Iterable<Key>;
|
|
159
|
+
/** Whether `disabledKeys` applies to all interactions, or only selection. @default "all" */
|
|
160
|
+
disabledBehavior?: "selection" | "all";
|
|
147
161
|
/** Focus mode: 'row' or 'cell'. */
|
|
148
162
|
focusMode?: "row" | "cell";
|
|
149
163
|
/** Selection mode. */
|
|
150
164
|
selectionMode?: "none" | "single" | "multiple";
|
|
151
165
|
/** Selection behavior. */
|
|
152
|
-
selectionBehavior?:
|
|
166
|
+
selectionBehavior?: SelectionBehavior;
|
|
153
167
|
/** Whether empty selection is disallowed. */
|
|
154
168
|
disallowEmptySelection?: boolean;
|
|
155
169
|
/** Currently selected keys (controlled). */
|
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export { createTextFieldState, type TextFieldStateOptions, type TextFieldState }
|
|
|
4
4
|
export { createCheckboxGroupState, type CheckboxGroupProps, type CheckboxGroupState, } from "./checkbox";
|
|
5
5
|
export { createRadioGroupState, radioGroupSyncVersion, type RadioGroupProps, type RadioGroupState, } from "./radio";
|
|
6
6
|
export { createOverlayTriggerState, type OverlayTriggerProps, type OverlayTriggerState, } from "./overlays";
|
|
7
|
-
export { type Key, type SelectionMode, type SelectionBehavior, type Selection, type FocusStrategy, type DisabledBehavior, type CollectionNode, type Collection, type ItemProps, type SectionProps, type CollectionBase, type SingleSelection, type MultipleSelection, ListCollection, createListCollection, createSelectionState, type SelectionStateProps, type SelectionState, createListState, createSingleSelectListState, type ListStateProps, type ListState, type SingleSelectListStateProps, type SingleSelectListState, createMenuState, createMenuTriggerState, type MenuStateProps, type MenuState, type MenuTriggerStateProps, type MenuTriggerState, } from "./collections";
|
|
8
|
-
export { useMultipleSelectionState, type MultipleSelectionStateProps, type MultipleSelectionState, } from "./selection";
|
|
7
|
+
export { type Key, type SelectionMode, type SelectionBehavior, type Selection, type FocusStrategy, type DisabledBehavior, type CollectionNode, type Collection, type ItemProps, type SectionProps, type CollectionBase, type SingleSelection, type MultipleSelection, ListCollection, createListCollection, createSelectionState, type SelectionStateProps, type SelectionState, type SelectionPressEvent, createListState, createSingleSelectListState, type ListStateProps, type ListState, type SingleSelectListStateProps, type SingleSelectListState, createMenuState, createMenuTriggerState, type MenuStateProps, type MenuState, type MenuTriggerStateProps, type MenuTriggerState, } from "./collections";
|
|
8
|
+
export { useMultipleSelectionState, type MultipleSelectionStateProps, type MultipleSelectionState, SelectionManager, type SelectionManagerOptions, type LayoutDelegate, } from "./selection";
|
|
9
9
|
export { useMenuTriggerState } from "./menu";
|
|
10
10
|
export { useDateFieldState, useDatePickerState, useDateRangePickerState, useTimeFieldState, type DateFieldStateOptions, type DatePickerStateOptions, type DateRangePickerStateOptions, type TimeFieldStateOptions, type SegmentType, } from "./datepicker";
|
|
11
11
|
export { createSelectState, type SelectStateProps, type SelectState } from "./select";
|
|
@@ -15,14 +15,14 @@ export { createNumberFieldState, type NumberFieldStateProps, type NumberFieldSta
|
|
|
15
15
|
export { createSearchFieldState, type SearchFieldStateProps, type SearchFieldState, } from "./searchfield";
|
|
16
16
|
export { createSliderState, type SliderStateProps, type SliderState, type SliderOrientation, } from "./slider";
|
|
17
17
|
export { createTooltipTriggerState, resetTooltipState, type TooltipTriggerProps, type TooltipTriggerState, } from "./tooltip";
|
|
18
|
-
export { createToastState, createToastQueue, ToastQueue, Timer, type ToastOptions, type QueuedToast, type ToastQueueOptions, type ToastStateProps, type ToastState, } from "./toast";
|
|
18
|
+
export { createToastState, createToastQueue, ToastQueue, Timer, type ToastOptions, type QueuedToast, type ToastQueueOptions, type ToastAction, type ToastStateProps, type ToastState, } from "./toast";
|
|
19
19
|
export { createDisclosureState, createDisclosureGroupState, type DisclosureStateProps, type DisclosureState, type DisclosureGroupStateProps, type DisclosureGroupState, type Key as DisclosureKey, } from "./disclosure";
|
|
20
|
-
export { createCalendarState, type CalendarStateProps, type CalendarState, type ValidationState, type CalendarPageBehavior, type CalendarSelectionAlignment, type CalendarDayOfWeek, createRangeCalendarState, type RangeCalendarStateProps, type RangeCalendarState, type DateRange, type RangeValue, createDateFieldState, type DateFieldStateProps, type DateFieldState, type DateSegment, type DateSegmentType, createTimeFieldState, type TimeFieldStateProps, type TimeFieldState, type TimeSegment, type TimeSegmentType, type TimeValue, createDatePickerState, type DatePickerState, type CalendarDate, type CalendarDateTime, type ZonedDateTime, type DateValue, type Time, type Calendar, type CalendarIdentifier, type AnyCalendarDate, createCalendar, GregorianCalendar, today, now, getLocalTimeZone, parseDate, parseDateTime, parseTime, parseAbsolute, parseAbsoluteToLocal, parseZonedDateTime, toCalendarDate, toCalendarDateTime, toZoned, toTime, CalendarDateClass, CalendarDateTimeClass, ZonedDateTimeClass, TimeClass, DateFormatter, isSameDay, isSameMonth, isSameYear, isToday, isWeekend, startOfMonth, endOfMonth, startOfWeek, endOfWeek, startOfYear, endOfYear, getWeeksInMonth, getDayOfWeek, toCalendar, minDate, maxDate, } from "./calendar";
|
|
20
|
+
export { createCalendarState, type CalendarStateProps, type CalendarState, type CalendarSelectionMode, type CalendarValueType, type ValidationState, type CalendarPageBehavior, type CalendarSelectionAlignment, type CalendarDayOfWeek, createRangeCalendarState, type RangeCalendarStateProps, type RangeCalendarState, type DateRange, type RangeValue, createDateFieldState, type DateFieldStateProps, type DateFieldState, type DateSegment, type DateSegmentType, createTimeFieldState, type TimeFieldStateProps, type TimeFieldState, type TimeSegment, type TimeSegmentType, type TimeValue, createDatePickerState, type DatePickerState, type CalendarDate, type CalendarDateTime, type ZonedDateTime, type DateValue, type Time, type Calendar, type CalendarIdentifier, type AnyCalendarDate, createCalendar, GregorianCalendar, today, now, getLocalTimeZone, parseDate, parseDateTime, parseTime, parseAbsolute, parseAbsoluteToLocal, parseZonedDateTime, toCalendarDate, toCalendarDateTime, toZoned, toTime, CalendarDateClass, CalendarDateTimeClass, ZonedDateTimeClass, TimeClass, DateFormatter, isSameDay, isSameMonth, isSameYear, isToday, isWeekend, startOfMonth, endOfMonth, startOfWeek, endOfWeek, startOfYear, endOfYear, getWeeksInMonth, getDayOfWeek, toCalendar, minDate, maxDate, } from "./calendar";
|
|
21
21
|
export { createGridState, type GridState, type GridStateOptions, type GridCollection, type GridNode, type GridNodeType, } from "./grid";
|
|
22
|
-
export { createTableState, createTableColumnResizeState, TableCollection, createTableCollection, type TableState, type TableStateOptions, type ITableCollection, type SortDescriptor, type SortDirection, type Sortable, type ColumnDefinition, type RowDefinition, type TableCollectionOptions, type ColumnSize, type ColumnResizeDefinition, type TableColumnResizeStateProps, type TableColumnResizeState, } from "./table";
|
|
22
|
+
export { createTableState, createTreeGridState, createTableColumnResizeState, TableCollection, createTableCollection, type TableState, type TableStateOptions, type ITableCollection, type TreeGridState, type TreeGridStateOptions, type SortDescriptor, type SortDirection, type Sortable, type ColumnDefinition, type RowDefinition, type TableCollectionOptions, type ColumnSize, type ColumnResizeDefinition, type TableColumnResizeStateProps, type TableColumnResizeState, } from "./table";
|
|
23
23
|
export { createTreeState, TreeCollection, createTreeCollection, type TreeState, type TreeStateOptions, type TreeCollectionInterface, type TreeNode, type TreeItemData, } from "./tree";
|
|
24
24
|
export { type Color, type ColorFormat, type ColorSpace, type ColorChannel, type ColorChannelRange, type ColorAxes, parseColor, normalizeColor, createRGBColor, createHSLColor, createHSBColor, createColorSliderState, type ColorSliderStateOptions, type ColorSliderState, createColorAreaState, type ColorAreaStateOptions, type ColorAreaState, createColorWheelState, type ColorWheelStateOptions, type ColorWheelState, createColorFieldState, type ColorFieldStateOptions, type ColorFieldState, } from "./color";
|
|
25
|
-
export { type DropOperation, type DragItem, type DragDropEvent, type DragStartEvent, type DragMoveEvent, type DragEndEvent, type DropEnterEvent, type DropMoveEvent, type DropActivateEvent, type DropExitEvent, type TextDropItem, type FileDropItem, type DirectoryDropItem, type DropItem, type DropEvent, type DropPosition, type RootDropTarget, type ItemDropTarget, type DropTarget, type DroppableCollectionEnterEvent, type DroppableCollectionMoveEvent, type DroppableCollectionActivateEvent, type DroppableCollectionExitEvent, type DroppableCollectionDropEvent, type DroppableCollectionInsertDropEvent, type DroppableCollectionRootDropEvent, type DroppableCollectionOnItemDropEvent, type DroppableCollectionReorderEvent, type DragTypes, type DropTargetDelegate, type DraggableCollectionStartEvent, type DraggableCollectionMoveEvent, type DraggableCollectionEndEvent, type DragPreviewRenderer, type DroppableCollectionUtilityOptions, type DroppableCollectionBaseProps, type DroppableCollectionProps, type DraggableCollectionProps, createDragState, type DragStateOptions, type DragState, createDropState, type DropStateOptions, type DropState, createDraggableCollectionState, type DraggableCollectionStateOptions, type DraggableCollectionState, createDroppableCollectionState, DIRECTORY_DRAG_TYPE, type DroppableCollectionStateOptions, type DroppableCollectionState, } from "./dnd";
|
|
25
|
+
export { type DropOperation, type DragItem, type DragDropEvent, type DragStartEvent, type DragMoveEvent, type DragEndEvent, type DropEnterEvent, type DropMoveEvent, type DropActivateEvent, type DropExitEvent, type TextDropItem, type FileDropItem, type DirectoryDropItem, type DropItem, type DropEvent, type DropPosition, type RootDropTarget, type ItemDropTarget, type DropTarget, type DroppableCollectionEnterEvent, type DroppableCollectionMoveEvent, type DroppableCollectionActivateEvent, type DroppableCollectionExitEvent, type DroppableCollectionDropEvent, type DroppableCollectionInsertDropEvent, type DroppableCollectionRootDropEvent, type DroppableCollectionOnItemDropEvent, type DroppableCollectionReorderEvent, type DragType, type DragTypes, type DropTargetDelegate, type DraggableCollectionStartEvent, type DraggableCollectionMoveEvent, type DraggableCollectionEndEvent, type DragPreviewRenderer, type DroppableCollectionUtilityOptions, type DroppableCollectionBaseProps, type DroppableCollectionProps, type DraggableCollectionProps, createDragState, type DragStateOptions, type DragState, createDropState, type DropStateOptions, type DropState, createDraggableCollectionState, type DraggableCollectionStateOptions, type DraggableCollectionState, createDroppableCollectionState, DIRECTORY_DRAG_TYPE, type DroppableCollectionStateOptions, type DroppableCollectionState, } from "./dnd";
|
|
26
26
|
export { createFormValidationState, mergeValidation, FormValidationContext, privateValidationStateProp, VALID_VALIDITY_STATE, DEFAULT_VALIDATION_RESULT, type FormValidationState, type FormValidationProps, type ValidationResult, type ValidationErrors, type ValidationFunction, type ValidationBehavior, type ValidityState, } from "./form";
|
|
27
27
|
export { createIsSSR, createId, canUseDOM, isServer } from "./ssr";
|
|
28
28
|
export { createListData, type ListOptions, type ListData, createTreeData, type TreeOptions, type TreeData, type TreeDataNode, createAsyncList, type AsyncListOptions, type AsyncListData, type AsyncListLoadFunction, type AsyncListLoadOptions, type AsyncListStateUpdate, type LoadingState, } from "./data";
|