@proyecto-viviana/solid-stately 0.0.5 → 0.1.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/README.md +312 -0
- package/dist/index.d.ts +3363 -6
- package/dist/index.js +6194 -19
- package/dist/index.js.map +1 -1
- package/package.json +52 -48
- package/src/autocomplete/createAutocompleteState.d.ts +46 -0
- package/src/autocomplete/createAutocompleteState.d.ts.map +1 -0
- package/src/autocomplete/createAutocompleteState.ts +90 -0
- package/src/autocomplete/index.d.ts +2 -0
- package/src/autocomplete/index.d.ts.map +1 -0
- package/src/autocomplete/index.ts +5 -0
- package/src/calendar/createCalendarState.d.ts +130 -0
- package/src/calendar/createCalendarState.d.ts.map +1 -0
- package/src/calendar/createCalendarState.ts +461 -0
- package/src/calendar/createDateFieldState.d.ts +110 -0
- package/src/calendar/createDateFieldState.d.ts.map +1 -0
- package/src/calendar/createDateFieldState.ts +562 -0
- package/src/calendar/createRangeCalendarState.d.ts +146 -0
- package/src/calendar/createRangeCalendarState.d.ts.map +1 -0
- package/src/calendar/createRangeCalendarState.ts +535 -0
- package/src/calendar/createTimeFieldState.d.ts +95 -0
- package/src/calendar/createTimeFieldState.d.ts.map +1 -0
- package/src/calendar/createTimeFieldState.ts +483 -0
- package/src/calendar/index.d.ts +7 -0
- package/src/calendar/index.d.ts.map +1 -0
- package/src/calendar/index.ts +81 -0
- package/{dist → src}/checkbox/createCheckboxGroupState.d.ts +1 -0
- package/src/checkbox/createCheckboxGroupState.d.ts.map +1 -0
- package/{dist → src}/checkbox/index.d.ts +1 -0
- package/src/checkbox/index.d.ts.map +1 -0
- package/src/collections/ListCollection.d.ts +37 -0
- package/src/collections/ListCollection.d.ts.map +1 -0
- package/src/collections/ListCollection.ts +146 -0
- package/src/collections/createListState.d.ts +79 -0
- package/src/collections/createListState.d.ts.map +1 -0
- package/src/collections/createListState.ts +264 -0
- package/src/collections/createMenuState.d.ts +50 -0
- package/src/collections/createMenuState.d.ts.map +1 -0
- package/src/collections/createMenuState.ts +106 -0
- package/src/collections/createSelectionState.d.ts +76 -0
- package/src/collections/createSelectionState.d.ts.map +1 -0
- package/src/collections/createSelectionState.ts +336 -0
- package/src/collections/index.d.ts +6 -0
- package/src/collections/index.d.ts.map +1 -0
- package/src/collections/index.ts +46 -0
- package/src/collections/types.d.ts +147 -0
- package/src/collections/types.d.ts.map +1 -0
- package/src/collections/types.ts +169 -0
- package/src/color/Color.d.ts +28 -0
- package/src/color/Color.d.ts.map +1 -0
- package/src/color/Color.ts +951 -0
- package/src/color/createColorAreaState.d.ts +76 -0
- package/src/color/createColorAreaState.d.ts.map +1 -0
- package/src/color/createColorAreaState.ts +293 -0
- package/src/color/createColorFieldState.d.ts +55 -0
- package/src/color/createColorFieldState.d.ts.map +1 -0
- package/src/color/createColorFieldState.ts +292 -0
- package/src/color/createColorSliderState.d.ts +67 -0
- package/src/color/createColorSliderState.d.ts.map +1 -0
- package/src/color/createColorSliderState.ts +241 -0
- package/src/color/createColorWheelState.d.ts +51 -0
- package/src/color/createColorWheelState.d.ts.map +1 -0
- package/src/color/createColorWheelState.ts +211 -0
- package/src/color/index.d.ts +10 -0
- package/src/color/index.d.ts.map +1 -0
- package/src/color/index.ts +47 -0
- package/src/color/types.d.ts +106 -0
- package/src/color/types.d.ts.map +1 -0
- package/src/color/types.ts +127 -0
- package/src/combobox/createComboBoxState.d.ts +125 -0
- package/src/combobox/createComboBoxState.d.ts.map +1 -0
- package/src/combobox/createComboBoxState.ts +703 -0
- package/src/combobox/index.d.ts +5 -0
- package/src/combobox/index.d.ts.map +1 -0
- package/src/combobox/index.ts +13 -0
- package/src/disclosure/createDisclosureState.d.ts +64 -0
- package/src/disclosure/createDisclosureState.d.ts.map +1 -0
- package/src/disclosure/createDisclosureState.ts +193 -0
- package/src/disclosure/index.d.ts +2 -0
- package/src/disclosure/index.d.ts.map +1 -0
- package/src/disclosure/index.ts +9 -0
- package/src/dnd/createDragState.d.ts +59 -0
- package/src/dnd/createDragState.d.ts.map +1 -0
- package/src/dnd/createDragState.ts +153 -0
- package/src/dnd/createDraggableCollectionState.d.ts +57 -0
- package/src/dnd/createDraggableCollectionState.d.ts.map +1 -0
- package/src/dnd/createDraggableCollectionState.ts +165 -0
- package/src/dnd/createDropState.d.ts +61 -0
- package/src/dnd/createDropState.d.ts.map +1 -0
- package/src/dnd/createDropState.ts +212 -0
- package/src/dnd/createDroppableCollectionState.d.ts +78 -0
- package/src/dnd/createDroppableCollectionState.d.ts.map +1 -0
- package/src/dnd/createDroppableCollectionState.ts +357 -0
- package/src/dnd/index.d.ts +11 -0
- package/src/dnd/index.d.ts.map +1 -0
- package/src/dnd/index.ts +76 -0
- package/src/dnd/types.d.ts +264 -0
- package/src/dnd/types.d.ts.map +1 -0
- package/src/dnd/types.ts +317 -0
- package/src/form/createFormValidationState.d.ts +100 -0
- package/src/form/createFormValidationState.d.ts.map +1 -0
- package/src/form/createFormValidationState.ts +389 -0
- package/src/form/index.d.ts +2 -0
- package/src/form/index.d.ts.map +1 -0
- package/src/form/index.ts +15 -0
- package/src/grid/createGridState.d.ts +12 -0
- package/src/grid/createGridState.d.ts.map +1 -0
- package/src/grid/createGridState.ts +327 -0
- package/src/grid/index.d.ts +7 -0
- package/src/grid/index.d.ts.map +1 -0
- package/src/grid/index.ts +13 -0
- package/src/grid/types.d.ts +156 -0
- package/src/grid/types.d.ts.map +1 -0
- package/src/grid/types.ts +179 -0
- package/src/index.d.ts +26 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.ts +350 -1
- package/src/numberfield/createNumberFieldState.d.ts +65 -0
- package/src/numberfield/createNumberFieldState.d.ts.map +1 -0
- package/src/numberfield/createNumberFieldState.ts +383 -0
- package/src/numberfield/index.d.ts +2 -0
- package/src/numberfield/index.d.ts.map +1 -0
- package/src/numberfield/index.ts +5 -0
- package/src/overlays/createOverlayTriggerState.d.ts +32 -0
- package/src/overlays/createOverlayTriggerState.d.ts.map +1 -0
- package/src/overlays/createOverlayTriggerState.ts +67 -0
- package/src/overlays/index.d.ts +2 -0
- package/src/overlays/index.d.ts.map +1 -0
- package/src/overlays/index.ts +5 -0
- package/{dist → src}/radio/createRadioGroupState.d.ts +1 -0
- package/src/radio/createRadioGroupState.d.ts.map +1 -0
- package/{dist → src}/radio/index.d.ts +1 -0
- package/src/radio/index.d.ts.map +1 -0
- package/src/searchfield/createSearchFieldState.d.ts +25 -0
- package/src/searchfield/createSearchFieldState.d.ts.map +1 -0
- package/src/searchfield/createSearchFieldState.ts +62 -0
- package/src/searchfield/index.d.ts +3 -0
- package/src/searchfield/index.d.ts.map +1 -0
- package/src/searchfield/index.ts +5 -0
- package/src/select/createSelectState.d.ts +73 -0
- package/src/select/createSelectState.d.ts.map +1 -0
- package/src/select/createSelectState.ts +181 -0
- package/src/select/index.d.ts +2 -0
- package/src/select/index.d.ts.map +1 -0
- package/src/select/index.ts +5 -0
- package/src/slider/createSliderState.d.ts +72 -0
- package/src/slider/createSliderState.d.ts.map +1 -0
- package/src/slider/createSliderState.ts +211 -0
- package/src/slider/index.d.ts +3 -0
- package/src/slider/index.d.ts.map +1 -0
- package/src/slider/index.ts +6 -0
- package/{dist → src}/ssr/index.d.ts +5 -0
- package/src/ssr/index.d.ts.map +1 -0
- package/src/ssr/index.ts +6 -1
- package/src/table/TableCollection.d.ts +52 -0
- package/src/table/TableCollection.d.ts.map +1 -0
- package/src/table/TableCollection.ts +388 -0
- package/src/table/createTableState.d.ts +12 -0
- package/src/table/createTableState.d.ts.map +1 -0
- package/src/table/createTableState.ts +127 -0
- package/src/table/index.d.ts +8 -0
- package/src/table/index.d.ts.map +1 -0
- package/src/table/index.ts +18 -0
- package/src/table/types.d.ts +139 -0
- package/src/table/types.d.ts.map +1 -0
- package/src/table/types.ts +150 -0
- package/src/tabs/createTabListState.d.ts +68 -0
- package/src/tabs/createTabListState.d.ts.map +1 -0
- package/src/tabs/createTabListState.ts +240 -0
- package/src/tabs/index.d.ts +2 -0
- package/src/tabs/index.d.ts.map +1 -0
- package/src/tabs/index.ts +7 -0
- package/{dist → src}/textfield/createTextFieldState.d.ts +1 -0
- package/src/textfield/createTextFieldState.d.ts.map +1 -0
- package/{dist → src}/textfield/index.d.ts +1 -0
- package/src/textfield/index.d.ts.map +1 -0
- package/src/toast/createToastState.d.ts +118 -0
- package/src/toast/createToastState.d.ts.map +1 -0
- package/src/toast/createToastState.ts +316 -0
- package/src/toast/index.d.ts +2 -0
- package/src/toast/index.d.ts.map +1 -0
- package/src/toast/index.ts +11 -0
- package/{dist → src}/toggle/createToggleState.d.ts +1 -0
- package/src/toggle/createToggleState.d.ts.map +1 -0
- package/{dist → src}/toggle/index.d.ts +1 -0
- package/src/toggle/index.d.ts.map +1 -0
- package/src/tooltip/createTooltipTriggerState.d.ts +39 -0
- package/src/tooltip/createTooltipTriggerState.d.ts.map +1 -0
- package/src/tooltip/createTooltipTriggerState.ts +183 -0
- package/src/tooltip/index.d.ts +2 -0
- package/src/tooltip/index.d.ts.map +1 -0
- package/src/tooltip/index.ts +6 -0
- package/src/tree/TreeCollection.d.ts +40 -0
- package/src/tree/TreeCollection.d.ts.map +1 -0
- package/src/tree/TreeCollection.ts +175 -0
- package/src/tree/createTreeState.d.ts +14 -0
- package/src/tree/createTreeState.d.ts.map +1 -0
- package/src/tree/createTreeState.ts +392 -0
- package/src/tree/index.d.ts +7 -0
- package/src/tree/index.d.ts.map +1 -0
- package/src/tree/index.ts +13 -0
- package/src/tree/types.d.ts +157 -0
- package/src/tree/types.d.ts.map +1 -0
- package/src/tree/types.ts +174 -0
- package/{dist → src}/utils/index.d.ts +1 -0
- package/src/utils/index.d.ts.map +1 -0
- package/{dist → src}/utils/reactivity.d.ts +1 -0
- package/src/utils/reactivity.d.ts.map +1 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drag and Drop types for solid-stately.
|
|
3
|
+
*
|
|
4
|
+
* Core types for drag and drop operations, matching React Aria's DnD API.
|
|
5
|
+
*/
|
|
6
|
+
/** The type of drop operation to perform. */
|
|
7
|
+
export type DropOperation = 'copy' | 'link' | 'move' | 'cancel';
|
|
8
|
+
/** Drag item data as key-value pairs where keys are MIME types or custom types. */
|
|
9
|
+
export interface DragItem {
|
|
10
|
+
[type: string]: string;
|
|
11
|
+
}
|
|
12
|
+
/** Base event for drag/drop operations with coordinates. */
|
|
13
|
+
export interface DragDropEvent {
|
|
14
|
+
/** The x coordinate of the event, relative to the target element. */
|
|
15
|
+
x: number;
|
|
16
|
+
/** The y coordinate of the event, relative to the target element. */
|
|
17
|
+
y: number;
|
|
18
|
+
}
|
|
19
|
+
/** Event fired when a drag operation starts. */
|
|
20
|
+
export interface DragStartEvent extends DragDropEvent {
|
|
21
|
+
/** The event type. */
|
|
22
|
+
type: 'dragstart';
|
|
23
|
+
}
|
|
24
|
+
/** Event fired as a drag moves. */
|
|
25
|
+
export interface DragMoveEvent extends DragDropEvent {
|
|
26
|
+
/** The event type. */
|
|
27
|
+
type: 'dragmove';
|
|
28
|
+
}
|
|
29
|
+
/** Event fired when a drag operation ends. */
|
|
30
|
+
export interface DragEndEvent extends DragDropEvent {
|
|
31
|
+
/** The event type. */
|
|
32
|
+
type: 'dragend';
|
|
33
|
+
/** The drop operation that occurred. */
|
|
34
|
+
dropOperation: DropOperation;
|
|
35
|
+
}
|
|
36
|
+
/** Event fired when a drag enters a drop target. */
|
|
37
|
+
export interface DropEnterEvent extends DragDropEvent {
|
|
38
|
+
/** The event type. */
|
|
39
|
+
type: 'dropenter';
|
|
40
|
+
}
|
|
41
|
+
/** Event fired as a drag moves within a drop target. */
|
|
42
|
+
export interface DropMoveEvent extends DragDropEvent {
|
|
43
|
+
/** The event type. */
|
|
44
|
+
type: 'dropmove';
|
|
45
|
+
}
|
|
46
|
+
/** Event fired when a drag is held over a drop target. */
|
|
47
|
+
export interface DropActivateEvent extends DragDropEvent {
|
|
48
|
+
/** The event type. */
|
|
49
|
+
type: 'dropactivate';
|
|
50
|
+
}
|
|
51
|
+
/** Event fired when a drag exits a drop target. */
|
|
52
|
+
export interface DropExitEvent extends DragDropEvent {
|
|
53
|
+
/** The event type. */
|
|
54
|
+
type: 'dropexit';
|
|
55
|
+
}
|
|
56
|
+
/** A text item in a drop operation. */
|
|
57
|
+
export interface TextDropItem {
|
|
58
|
+
/** The item kind. */
|
|
59
|
+
kind: 'text';
|
|
60
|
+
/** The drag types available for this item. */
|
|
61
|
+
types: Set<string>;
|
|
62
|
+
/** Returns the data for the given type as a string. */
|
|
63
|
+
getText(type: string): Promise<string>;
|
|
64
|
+
}
|
|
65
|
+
/** A file item in a drop operation. */
|
|
66
|
+
export interface FileDropItem {
|
|
67
|
+
/** The item kind. */
|
|
68
|
+
kind: 'file';
|
|
69
|
+
/** The file type (usually a mime type). */
|
|
70
|
+
type: string;
|
|
71
|
+
/** The file name. */
|
|
72
|
+
name: string;
|
|
73
|
+
/** Returns the contents of the file as a blob. */
|
|
74
|
+
getFile(): Promise<File>;
|
|
75
|
+
/** Returns the contents of the file as a string. */
|
|
76
|
+
getText(): Promise<string>;
|
|
77
|
+
}
|
|
78
|
+
/** A directory item in a drop operation. */
|
|
79
|
+
export interface DirectoryDropItem {
|
|
80
|
+
/** The item kind. */
|
|
81
|
+
kind: 'directory';
|
|
82
|
+
/** The directory name. */
|
|
83
|
+
name: string;
|
|
84
|
+
/** Returns the entries contained within the directory. */
|
|
85
|
+
getEntries(): AsyncIterable<FileDropItem | DirectoryDropItem>;
|
|
86
|
+
}
|
|
87
|
+
/** Union of all drop item types. */
|
|
88
|
+
export type DropItem = TextDropItem | FileDropItem | DirectoryDropItem;
|
|
89
|
+
/** Event fired when items are dropped. */
|
|
90
|
+
export interface DropEvent extends DragDropEvent {
|
|
91
|
+
/** The event type. */
|
|
92
|
+
type: 'drop';
|
|
93
|
+
/** The drop operation that should occur. */
|
|
94
|
+
dropOperation: DropOperation;
|
|
95
|
+
/** The dropped items. */
|
|
96
|
+
items: DropItem[];
|
|
97
|
+
}
|
|
98
|
+
/** Position relative to an item for drop operations. */
|
|
99
|
+
export type DropPosition = 'on' | 'before' | 'after';
|
|
100
|
+
/** Drop target representing the root of a collection. */
|
|
101
|
+
export interface RootDropTarget {
|
|
102
|
+
/** The drop target type. */
|
|
103
|
+
type: 'root';
|
|
104
|
+
}
|
|
105
|
+
/** Drop target representing an item in a collection. */
|
|
106
|
+
export interface ItemDropTarget {
|
|
107
|
+
/** The drop target type. */
|
|
108
|
+
type: 'item';
|
|
109
|
+
/** The item key. */
|
|
110
|
+
key: string | number;
|
|
111
|
+
/** The drop position relative to the item. */
|
|
112
|
+
dropPosition: DropPosition;
|
|
113
|
+
}
|
|
114
|
+
/** Union of drop target types. */
|
|
115
|
+
export type DropTarget = RootDropTarget | ItemDropTarget;
|
|
116
|
+
/** Event fired when a drag enters a droppable collection. */
|
|
117
|
+
export interface DroppableCollectionEnterEvent extends DropEnterEvent {
|
|
118
|
+
/** The drop target. */
|
|
119
|
+
target: DropTarget;
|
|
120
|
+
}
|
|
121
|
+
/** Event fired as a drag moves within a droppable collection. */
|
|
122
|
+
export interface DroppableCollectionMoveEvent extends DropMoveEvent {
|
|
123
|
+
/** The drop target. */
|
|
124
|
+
target: DropTarget;
|
|
125
|
+
}
|
|
126
|
+
/** Event fired when a drag is held over a droppable collection item. */
|
|
127
|
+
export interface DroppableCollectionActivateEvent extends DropActivateEvent {
|
|
128
|
+
/** The drop target. */
|
|
129
|
+
target: DropTarget;
|
|
130
|
+
}
|
|
131
|
+
/** Event fired when a drag exits a droppable collection. */
|
|
132
|
+
export interface DroppableCollectionExitEvent extends DropExitEvent {
|
|
133
|
+
/** The drop target. */
|
|
134
|
+
target: DropTarget;
|
|
135
|
+
}
|
|
136
|
+
/** Event fired when items are dropped on a droppable collection. */
|
|
137
|
+
export interface DroppableCollectionDropEvent extends DropEvent {
|
|
138
|
+
/** The drop target. */
|
|
139
|
+
target: DropTarget;
|
|
140
|
+
}
|
|
141
|
+
/** Event for inserting items between existing collection items. */
|
|
142
|
+
export interface DroppableCollectionInsertDropEvent {
|
|
143
|
+
/** The dropped items. */
|
|
144
|
+
items: DropItem[];
|
|
145
|
+
/** The drop operation that should occur. */
|
|
146
|
+
dropOperation: DropOperation;
|
|
147
|
+
/** The drop target. */
|
|
148
|
+
target: ItemDropTarget;
|
|
149
|
+
}
|
|
150
|
+
/** Event for dropping on the root of a collection. */
|
|
151
|
+
export interface DroppableCollectionRootDropEvent {
|
|
152
|
+
/** The dropped items. */
|
|
153
|
+
items: DropItem[];
|
|
154
|
+
/** The drop operation that should occur. */
|
|
155
|
+
dropOperation: DropOperation;
|
|
156
|
+
}
|
|
157
|
+
/** Event for dropping on a specific item. */
|
|
158
|
+
export interface DroppableCollectionOnItemDropEvent {
|
|
159
|
+
/** The dropped items. */
|
|
160
|
+
items: DropItem[];
|
|
161
|
+
/** The drop operation that should occur. */
|
|
162
|
+
dropOperation: DropOperation;
|
|
163
|
+
/** Whether the drag originated within the same collection as the drop. */
|
|
164
|
+
isInternal: boolean;
|
|
165
|
+
/** The drop target. */
|
|
166
|
+
target: ItemDropTarget;
|
|
167
|
+
}
|
|
168
|
+
/** Event for reordering items within a collection. */
|
|
169
|
+
export interface DroppableCollectionReorderEvent {
|
|
170
|
+
/** The keys of the items that were reordered. */
|
|
171
|
+
keys: Set<string | number>;
|
|
172
|
+
/** The drop operation that should occur. */
|
|
173
|
+
dropOperation: DropOperation;
|
|
174
|
+
/** The drop target. */
|
|
175
|
+
target: ItemDropTarget;
|
|
176
|
+
}
|
|
177
|
+
/** Interface for checking drag types. */
|
|
178
|
+
export interface DragTypes {
|
|
179
|
+
/** Returns whether the drag contains data of the given type. */
|
|
180
|
+
has(type: string | symbol): boolean;
|
|
181
|
+
}
|
|
182
|
+
/** Delegate for determining drop targets within a collection. */
|
|
183
|
+
export interface DropTargetDelegate {
|
|
184
|
+
/**
|
|
185
|
+
* Returns a drop target within a collection for the given coordinates.
|
|
186
|
+
* @param x - X coordinate relative to the collection container
|
|
187
|
+
* @param y - Y coordinate relative to the collection container
|
|
188
|
+
* @param isValidDropTarget - Function to check if a target is valid
|
|
189
|
+
*/
|
|
190
|
+
getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget | null;
|
|
191
|
+
}
|
|
192
|
+
/** Event fired when a collection drag starts. */
|
|
193
|
+
export interface DraggableCollectionStartEvent extends DragStartEvent {
|
|
194
|
+
/** The keys of the items that were dragged. */
|
|
195
|
+
keys: Set<string | number>;
|
|
196
|
+
}
|
|
197
|
+
/** Event fired as a collection drag moves. */
|
|
198
|
+
export interface DraggableCollectionMoveEvent extends DragMoveEvent {
|
|
199
|
+
/** The keys of the items that were dragged. */
|
|
200
|
+
keys: Set<string | number>;
|
|
201
|
+
}
|
|
202
|
+
/** Event fired when a collection drag ends. */
|
|
203
|
+
export interface DraggableCollectionEndEvent extends DragEndEvent {
|
|
204
|
+
/** The keys of the items that were dragged. */
|
|
205
|
+
keys: Set<string | number>;
|
|
206
|
+
/** Whether the drop ended within the same collection as it originated. */
|
|
207
|
+
isInternal: boolean;
|
|
208
|
+
}
|
|
209
|
+
/** Function to render a custom drag preview. */
|
|
210
|
+
export type DragPreviewRenderer = (items: DragItem[], callback: (node: HTMLElement | null, x?: number, y?: number) => void) => void;
|
|
211
|
+
/** Props for droppable collection utility handlers. */
|
|
212
|
+
export interface DroppableCollectionUtilityOptions {
|
|
213
|
+
/**
|
|
214
|
+
* The drag types that the droppable collection accepts.
|
|
215
|
+
* @default 'all'
|
|
216
|
+
*/
|
|
217
|
+
acceptedDragTypes?: 'all' | Array<string | symbol>;
|
|
218
|
+
/** Handler that is called when external items are dropped "between" items. */
|
|
219
|
+
onInsert?: (e: DroppableCollectionInsertDropEvent) => void;
|
|
220
|
+
/** Handler that is called when external items are dropped on the collection's root. */
|
|
221
|
+
onRootDrop?: (e: DroppableCollectionRootDropEvent) => void;
|
|
222
|
+
/** Handler that is called when items are dropped "on" an item. */
|
|
223
|
+
onItemDrop?: (e: DroppableCollectionOnItemDropEvent) => void;
|
|
224
|
+
/** Handler that is called when items are reordered within the collection. */
|
|
225
|
+
onReorder?: (e: DroppableCollectionReorderEvent) => void;
|
|
226
|
+
/** Handler that is called when items are moved within the source collection. */
|
|
227
|
+
onMove?: (e: DroppableCollectionReorderEvent) => void;
|
|
228
|
+
/** A function returning whether a given target is a valid "on" drop target. */
|
|
229
|
+
shouldAcceptItemDrop?: (target: ItemDropTarget, types: DragTypes) => boolean;
|
|
230
|
+
}
|
|
231
|
+
/** Base props for droppable collections. */
|
|
232
|
+
export interface DroppableCollectionBaseProps {
|
|
233
|
+
/** Handler that is called when a valid drag enters a drop target. */
|
|
234
|
+
onDropEnter?: (e: DroppableCollectionEnterEvent) => void;
|
|
235
|
+
/** Handler that is called after a valid drag is held over a drop target. */
|
|
236
|
+
onDropActivate?: (e: DroppableCollectionActivateEvent) => void;
|
|
237
|
+
/** Handler that is called when a valid drag exits a drop target. */
|
|
238
|
+
onDropExit?: (e: DroppableCollectionExitEvent) => void;
|
|
239
|
+
/** Handler that is called when a valid drag is dropped on a drop target. */
|
|
240
|
+
onDrop?: (e: DroppableCollectionDropEvent) => void;
|
|
241
|
+
/** A function returning the drop operation to be performed. */
|
|
242
|
+
getDropOperation?: (target: DropTarget, types: DragTypes, allowedOperations: DropOperation[]) => DropOperation;
|
|
243
|
+
}
|
|
244
|
+
/** Combined props for droppable collections. */
|
|
245
|
+
export interface DroppableCollectionProps extends DroppableCollectionUtilityOptions, DroppableCollectionBaseProps {
|
|
246
|
+
}
|
|
247
|
+
/** Props for draggable collections. */
|
|
248
|
+
export interface DraggableCollectionProps<T = object> {
|
|
249
|
+
/** Handler that is called when a drag operation is started. */
|
|
250
|
+
onDragStart?: (e: DraggableCollectionStartEvent) => void;
|
|
251
|
+
/** Handler that is called when the drag is moved. */
|
|
252
|
+
onDragMove?: (e: DraggableCollectionMoveEvent) => void;
|
|
253
|
+
/** Handler that is called when the drag operation ends. */
|
|
254
|
+
onDragEnd?: (e: DraggableCollectionEndEvent) => void;
|
|
255
|
+
/** A function that returns the items being dragged. */
|
|
256
|
+
getItems: (keys: Set<string | number>, items: T[]) => DragItem[];
|
|
257
|
+
/** The ref of the element that will be rendered as the drag preview. */
|
|
258
|
+
preview?: {
|
|
259
|
+
current: DragPreviewRenderer | null;
|
|
260
|
+
};
|
|
261
|
+
/** Function that returns the allowed drop operations. */
|
|
262
|
+
getAllowedDropOperations?: () => DropOperation[];
|
|
263
|
+
}
|
|
264
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,6CAA6C;AAC7C,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEhE,mFAAmF;AACnF,MAAM,WAAW,QAAQ;IACvB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED,4DAA4D;AAC5D,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,CAAC,EAAE,MAAM,CAAC;IACV,qEAAqE;IACrE,CAAC,EAAE,MAAM,CAAC;CACX;AAED,gDAAgD;AAChD,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,sBAAsB;IACtB,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,mCAAmC;AACnC,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,sBAAsB;IACtB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,8CAA8C;AAC9C,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,sBAAsB;IACtB,IAAI,EAAE,SAAS,CAAC;IAChB,wCAAwC;IACxC,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,oDAAoD;AACpD,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,sBAAsB;IACtB,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,wDAAwD;AACxD,MAAM,WAAW,aAAc,SAAQ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,IAAI,CAAC;IAC/D,oEAAoE;IACpE,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,4BAA4B,KAAK,IAAI,CAAC;IACvD,4EAA4E;IAC5E,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,4BAA4B,KAAK,IAAI,CAAC;IACnD,+DAA+D;IAC/D,gBAAgB,CAAC,EAAE,CACjB,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,SAAS,EAChB,iBAAiB,EAAE,aAAa,EAAE,KAC/B,aAAa,CAAC;CACpB;AAED,gDAAgD;AAChD,MAAM,WAAW,wBACf,SAAQ,iCAAiC,EACvC,4BAA4B;CAAG;AAEnC,uCAAuC;AACvC,MAAM,WAAW,wBAAwB,CAAC,CAAC,GAAG,MAAM;IAClD,+DAA+D;IAC/D,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,6BAA6B,KAAK,IAAI,CAAC;IACzD,qDAAqD;IACrD,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,4BAA4B,KAAK,IAAI,CAAC;IACvD,2DAA2D;IAC3D,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,2BAA2B,KAAK,IAAI,CAAC;IACrD,uDAAuD;IACvD,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;IACjE,wEAAwE;IACxE,OAAO,CAAC,EAAE;QAAE,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAAA;KAAE,CAAC;IAClD,yDAAyD;IACzD,wBAAwB,CAAC,EAAE,MAAM,aAAa,EAAE,CAAC;CAClD"}
|
package/src/dnd/types.ts
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drag and Drop types for solid-stately.
|
|
3
|
+
*
|
|
4
|
+
* Core types for drag and drop operations, matching React Aria's DnD API.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** The type of drop operation to perform. */
|
|
8
|
+
export type DropOperation = 'copy' | 'link' | 'move' | 'cancel';
|
|
9
|
+
|
|
10
|
+
/** Drag item data as key-value pairs where keys are MIME types or custom types. */
|
|
11
|
+
export interface DragItem {
|
|
12
|
+
[type: string]: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Base event for drag/drop operations with coordinates. */
|
|
16
|
+
export interface DragDropEvent {
|
|
17
|
+
/** The x coordinate of the event, relative to the target element. */
|
|
18
|
+
x: number;
|
|
19
|
+
/** The y coordinate of the event, relative to the target element. */
|
|
20
|
+
y: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Event fired when a drag operation starts. */
|
|
24
|
+
export interface DragStartEvent extends DragDropEvent {
|
|
25
|
+
/** The event type. */
|
|
26
|
+
type: 'dragstart';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Event fired as a drag moves. */
|
|
30
|
+
export interface DragMoveEvent extends DragDropEvent {
|
|
31
|
+
/** The event type. */
|
|
32
|
+
type: 'dragmove';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Event fired when a drag operation ends. */
|
|
36
|
+
export interface DragEndEvent extends DragDropEvent {
|
|
37
|
+
/** The event type. */
|
|
38
|
+
type: 'dragend';
|
|
39
|
+
/** The drop operation that occurred. */
|
|
40
|
+
dropOperation: DropOperation;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Event fired when a drag enters a drop target. */
|
|
44
|
+
export interface DropEnterEvent extends DragDropEvent {
|
|
45
|
+
/** The event type. */
|
|
46
|
+
type: 'dropenter';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Event fired as a drag moves within a drop target. */
|
|
50
|
+
export interface DropMoveEvent extends DragDropEvent {
|
|
51
|
+
/** The event type. */
|
|
52
|
+
type: 'dropmove';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Event fired when a drag is held over a drop target. */
|
|
56
|
+
export interface DropActivateEvent extends DragDropEvent {
|
|
57
|
+
/** The event type. */
|
|
58
|
+
type: 'dropactivate';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Event fired when a drag exits a drop target. */
|
|
62
|
+
export interface DropExitEvent extends DragDropEvent {
|
|
63
|
+
/** The event type. */
|
|
64
|
+
type: 'dropexit';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** A text item in a drop operation. */
|
|
68
|
+
export interface TextDropItem {
|
|
69
|
+
/** The item kind. */
|
|
70
|
+
kind: 'text';
|
|
71
|
+
/** The drag types available for this item. */
|
|
72
|
+
types: Set<string>;
|
|
73
|
+
/** Returns the data for the given type as a string. */
|
|
74
|
+
getText(type: string): Promise<string>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** A file item in a drop operation. */
|
|
78
|
+
export interface FileDropItem {
|
|
79
|
+
/** The item kind. */
|
|
80
|
+
kind: 'file';
|
|
81
|
+
/** The file type (usually a mime type). */
|
|
82
|
+
type: string;
|
|
83
|
+
/** The file name. */
|
|
84
|
+
name: string;
|
|
85
|
+
/** Returns the contents of the file as a blob. */
|
|
86
|
+
getFile(): Promise<File>;
|
|
87
|
+
/** Returns the contents of the file as a string. */
|
|
88
|
+
getText(): Promise<string>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** A directory item in a drop operation. */
|
|
92
|
+
export interface DirectoryDropItem {
|
|
93
|
+
/** The item kind. */
|
|
94
|
+
kind: 'directory';
|
|
95
|
+
/** The directory name. */
|
|
96
|
+
name: string;
|
|
97
|
+
/** Returns the entries contained within the directory. */
|
|
98
|
+
getEntries(): AsyncIterable<FileDropItem | DirectoryDropItem>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Union of all drop item types. */
|
|
102
|
+
export type DropItem = TextDropItem | FileDropItem | DirectoryDropItem;
|
|
103
|
+
|
|
104
|
+
/** Event fired when items are dropped. */
|
|
105
|
+
export interface DropEvent extends DragDropEvent {
|
|
106
|
+
/** The event type. */
|
|
107
|
+
type: 'drop';
|
|
108
|
+
/** The drop operation that should occur. */
|
|
109
|
+
dropOperation: DropOperation;
|
|
110
|
+
/** The dropped items. */
|
|
111
|
+
items: DropItem[];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Position relative to an item for drop operations. */
|
|
115
|
+
export type DropPosition = 'on' | 'before' | 'after';
|
|
116
|
+
|
|
117
|
+
/** Drop target representing the root of a collection. */
|
|
118
|
+
export interface RootDropTarget {
|
|
119
|
+
/** The drop target type. */
|
|
120
|
+
type: 'root';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Drop target representing an item in a collection. */
|
|
124
|
+
export interface ItemDropTarget {
|
|
125
|
+
/** The drop target type. */
|
|
126
|
+
type: 'item';
|
|
127
|
+
/** The item key. */
|
|
128
|
+
key: string | number;
|
|
129
|
+
/** The drop position relative to the item. */
|
|
130
|
+
dropPosition: DropPosition;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Union of drop target types. */
|
|
134
|
+
export type DropTarget = RootDropTarget | ItemDropTarget;
|
|
135
|
+
|
|
136
|
+
// Collection drag/drop events
|
|
137
|
+
|
|
138
|
+
/** Event fired when a drag enters a droppable collection. */
|
|
139
|
+
export interface DroppableCollectionEnterEvent extends DropEnterEvent {
|
|
140
|
+
/** The drop target. */
|
|
141
|
+
target: DropTarget;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Event fired as a drag moves within a droppable collection. */
|
|
145
|
+
export interface DroppableCollectionMoveEvent extends DropMoveEvent {
|
|
146
|
+
/** The drop target. */
|
|
147
|
+
target: DropTarget;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Event fired when a drag is held over a droppable collection item. */
|
|
151
|
+
export interface DroppableCollectionActivateEvent extends DropActivateEvent {
|
|
152
|
+
/** The drop target. */
|
|
153
|
+
target: DropTarget;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Event fired when a drag exits a droppable collection. */
|
|
157
|
+
export interface DroppableCollectionExitEvent extends DropExitEvent {
|
|
158
|
+
/** The drop target. */
|
|
159
|
+
target: DropTarget;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Event fired when items are dropped on a droppable collection. */
|
|
163
|
+
export interface DroppableCollectionDropEvent extends DropEvent {
|
|
164
|
+
/** The drop target. */
|
|
165
|
+
target: DropTarget;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Event for inserting items between existing collection items. */
|
|
169
|
+
export interface DroppableCollectionInsertDropEvent {
|
|
170
|
+
/** The dropped items. */
|
|
171
|
+
items: DropItem[];
|
|
172
|
+
/** The drop operation that should occur. */
|
|
173
|
+
dropOperation: DropOperation;
|
|
174
|
+
/** The drop target. */
|
|
175
|
+
target: ItemDropTarget;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** Event for dropping on the root of a collection. */
|
|
179
|
+
export interface DroppableCollectionRootDropEvent {
|
|
180
|
+
/** The dropped items. */
|
|
181
|
+
items: DropItem[];
|
|
182
|
+
/** The drop operation that should occur. */
|
|
183
|
+
dropOperation: DropOperation;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Event for dropping on a specific item. */
|
|
187
|
+
export interface DroppableCollectionOnItemDropEvent {
|
|
188
|
+
/** The dropped items. */
|
|
189
|
+
items: DropItem[];
|
|
190
|
+
/** The drop operation that should occur. */
|
|
191
|
+
dropOperation: DropOperation;
|
|
192
|
+
/** Whether the drag originated within the same collection as the drop. */
|
|
193
|
+
isInternal: boolean;
|
|
194
|
+
/** The drop target. */
|
|
195
|
+
target: ItemDropTarget;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Event for reordering items within a collection. */
|
|
199
|
+
export interface DroppableCollectionReorderEvent {
|
|
200
|
+
/** The keys of the items that were reordered. */
|
|
201
|
+
keys: Set<string | number>;
|
|
202
|
+
/** The drop operation that should occur. */
|
|
203
|
+
dropOperation: DropOperation;
|
|
204
|
+
/** The drop target. */
|
|
205
|
+
target: ItemDropTarget;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** Interface for checking drag types. */
|
|
209
|
+
export interface DragTypes {
|
|
210
|
+
/** Returns whether the drag contains data of the given type. */
|
|
211
|
+
has(type: string | symbol): boolean;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** Delegate for determining drop targets within a collection. */
|
|
215
|
+
export interface DropTargetDelegate {
|
|
216
|
+
/**
|
|
217
|
+
* Returns a drop target within a collection for the given coordinates.
|
|
218
|
+
* @param x - X coordinate relative to the collection container
|
|
219
|
+
* @param y - Y coordinate relative to the collection container
|
|
220
|
+
* @param isValidDropTarget - Function to check if a target is valid
|
|
221
|
+
*/
|
|
222
|
+
getDropTargetFromPoint(
|
|
223
|
+
x: number,
|
|
224
|
+
y: number,
|
|
225
|
+
isValidDropTarget: (target: DropTarget) => boolean
|
|
226
|
+
): DropTarget | null;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// Draggable collection types
|
|
230
|
+
|
|
231
|
+
/** Event fired when a collection drag starts. */
|
|
232
|
+
export interface DraggableCollectionStartEvent extends DragStartEvent {
|
|
233
|
+
/** The keys of the items that were dragged. */
|
|
234
|
+
keys: Set<string | number>;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** Event fired as a collection drag moves. */
|
|
238
|
+
export interface DraggableCollectionMoveEvent extends DragMoveEvent {
|
|
239
|
+
/** The keys of the items that were dragged. */
|
|
240
|
+
keys: Set<string | number>;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** Event fired when a collection drag ends. */
|
|
244
|
+
export interface DraggableCollectionEndEvent extends DragEndEvent {
|
|
245
|
+
/** The keys of the items that were dragged. */
|
|
246
|
+
keys: Set<string | number>;
|
|
247
|
+
/** Whether the drop ended within the same collection as it originated. */
|
|
248
|
+
isInternal: boolean;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** Function to render a custom drag preview. */
|
|
252
|
+
export type DragPreviewRenderer = (
|
|
253
|
+
items: DragItem[],
|
|
254
|
+
callback: (node: HTMLElement | null, x?: number, y?: number) => void
|
|
255
|
+
) => void;
|
|
256
|
+
|
|
257
|
+
// Props interfaces
|
|
258
|
+
|
|
259
|
+
/** Props for droppable collection utility handlers. */
|
|
260
|
+
export interface DroppableCollectionUtilityOptions {
|
|
261
|
+
/**
|
|
262
|
+
* The drag types that the droppable collection accepts.
|
|
263
|
+
* @default 'all'
|
|
264
|
+
*/
|
|
265
|
+
acceptedDragTypes?: 'all' | Array<string | symbol>;
|
|
266
|
+
/** Handler that is called when external items are dropped "between" items. */
|
|
267
|
+
onInsert?: (e: DroppableCollectionInsertDropEvent) => void;
|
|
268
|
+
/** Handler that is called when external items are dropped on the collection's root. */
|
|
269
|
+
onRootDrop?: (e: DroppableCollectionRootDropEvent) => void;
|
|
270
|
+
/** Handler that is called when items are dropped "on" an item. */
|
|
271
|
+
onItemDrop?: (e: DroppableCollectionOnItemDropEvent) => void;
|
|
272
|
+
/** Handler that is called when items are reordered within the collection. */
|
|
273
|
+
onReorder?: (e: DroppableCollectionReorderEvent) => void;
|
|
274
|
+
/** Handler that is called when items are moved within the source collection. */
|
|
275
|
+
onMove?: (e: DroppableCollectionReorderEvent) => void;
|
|
276
|
+
/** A function returning whether a given target is a valid "on" drop target. */
|
|
277
|
+
shouldAcceptItemDrop?: (target: ItemDropTarget, types: DragTypes) => boolean;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Base props for droppable collections. */
|
|
281
|
+
export interface DroppableCollectionBaseProps {
|
|
282
|
+
/** Handler that is called when a valid drag enters a drop target. */
|
|
283
|
+
onDropEnter?: (e: DroppableCollectionEnterEvent) => void;
|
|
284
|
+
/** Handler that is called after a valid drag is held over a drop target. */
|
|
285
|
+
onDropActivate?: (e: DroppableCollectionActivateEvent) => void;
|
|
286
|
+
/** Handler that is called when a valid drag exits a drop target. */
|
|
287
|
+
onDropExit?: (e: DroppableCollectionExitEvent) => void;
|
|
288
|
+
/** Handler that is called when a valid drag is dropped on a drop target. */
|
|
289
|
+
onDrop?: (e: DroppableCollectionDropEvent) => void;
|
|
290
|
+
/** A function returning the drop operation to be performed. */
|
|
291
|
+
getDropOperation?: (
|
|
292
|
+
target: DropTarget,
|
|
293
|
+
types: DragTypes,
|
|
294
|
+
allowedOperations: DropOperation[]
|
|
295
|
+
) => DropOperation;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** Combined props for droppable collections. */
|
|
299
|
+
export interface DroppableCollectionProps
|
|
300
|
+
extends DroppableCollectionUtilityOptions,
|
|
301
|
+
DroppableCollectionBaseProps {}
|
|
302
|
+
|
|
303
|
+
/** Props for draggable collections. */
|
|
304
|
+
export interface DraggableCollectionProps<T = object> {
|
|
305
|
+
/** Handler that is called when a drag operation is started. */
|
|
306
|
+
onDragStart?: (e: DraggableCollectionStartEvent) => void;
|
|
307
|
+
/** Handler that is called when the drag is moved. */
|
|
308
|
+
onDragMove?: (e: DraggableCollectionMoveEvent) => void;
|
|
309
|
+
/** Handler that is called when the drag operation ends. */
|
|
310
|
+
onDragEnd?: (e: DraggableCollectionEndEvent) => void;
|
|
311
|
+
/** A function that returns the items being dragged. */
|
|
312
|
+
getItems: (keys: Set<string | number>, items: T[]) => DragItem[];
|
|
313
|
+
/** The ref of the element that will be rendered as the drag preview. */
|
|
314
|
+
preview?: { current: DragPreviewRenderer | null };
|
|
315
|
+
/** Function that returns the allowed drop operations. */
|
|
316
|
+
getAllowedDropOperations?: () => DropOperation[];
|
|
317
|
+
}
|