@proyecto-viviana/solid-stately 0.2.7 → 0.3.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 +30 -283
- package/dist/autocomplete/createAutocompleteState.d.ts +2 -2
- package/dist/autocomplete/index.d.ts +1 -1
- package/dist/calendar/createCalendarState.d.ts +22 -7
- package/dist/calendar/createDateFieldState.d.ts +30 -7
- package/dist/calendar/createDatePickerState.d.ts +60 -0
- package/dist/calendar/createRangeCalendarState.d.ts +27 -8
- package/dist/calendar/createTimeFieldState.d.ts +34 -7
- package/dist/calendar/index.d.ts +7 -6
- package/dist/checkbox/createCheckboxGroupState.d.ts +6 -6
- package/dist/checkbox/index.d.ts +1 -1
- package/dist/collections/ListCollection.d.ts +1 -1
- package/dist/collections/createListState.d.ts +8 -8
- package/dist/collections/createMenuState.d.ts +7 -7
- package/dist/collections/createSelectionState.d.ts +5 -5
- package/dist/collections/index.d.ts +5 -5
- package/dist/collections/types.d.ts +12 -12
- package/dist/color/Color.d.ts +1 -1
- package/dist/color/createColorAreaState.d.ts +4 -2
- package/dist/color/createColorFieldState.d.ts +38 -12
- package/dist/color/createColorSliderState.d.ts +9 -2
- package/dist/color/createColorWheelState.d.ts +13 -2
- package/dist/color/getColorChannels.d.ts +1 -1
- package/dist/color/index.d.ts +6 -6
- package/dist/color/types.d.ts +4 -4
- package/dist/combobox/createComboBoxState.d.ts +27 -13
- package/dist/combobox/index.d.ts +1 -1
- package/dist/data/createAsyncList.d.ts +4 -4
- package/dist/data/createListData.d.ts +2 -2
- package/dist/data/createTreeData.d.ts +6 -2
- package/dist/data/index.d.ts +3 -3
- package/dist/datepicker/index.d.ts +2 -4
- package/dist/disclosure/createDisclosureState.d.ts +2 -2
- package/dist/disclosure/index.d.ts +1 -1
- package/dist/dnd/createDragState.d.ts +2 -2
- package/dist/dnd/createDraggableCollectionState.d.ts +2 -2
- package/dist/dnd/createDropState.d.ts +2 -2
- package/dist/dnd/createDroppableCollectionState.d.ts +3 -3
- package/dist/dnd/index.d.ts +5 -5
- package/dist/dnd/types.d.ts +16 -16
- package/dist/form/createFormValidationState.d.ts +3 -3
- package/dist/form/index.d.ts +1 -1
- package/dist/grid/createGridState.d.ts +2 -2
- package/dist/grid/index.d.ts +2 -2
- package/dist/grid/types.d.ts +13 -11
- package/dist/index.d.ts +31 -30
- package/dist/index.js +7924 -7238
- package/dist/index.js.map +1 -1
- package/dist/menu/index.d.ts +2 -2
- package/dist/numberfield/createNumberFieldState.d.ts +2 -2
- package/dist/numberfield/index.d.ts +1 -1
- package/dist/overlays/createOverlayTriggerState.d.ts +2 -2
- package/dist/overlays/index.d.ts +1 -1
- package/dist/radio/createRadioGroupState.d.ts +7 -7
- package/dist/radio/index.d.ts +1 -1
- package/dist/searchfield/createSearchFieldState.d.ts +2 -2
- package/dist/searchfield/index.d.ts +2 -2
- package/dist/select/createSelectState.d.ts +8 -8
- package/dist/select/index.d.ts +1 -1
- package/dist/selection/index.d.ts +5 -5
- package/dist/slider/createSliderState.d.ts +3 -3
- package/dist/slider/index.d.ts +2 -2
- package/dist/steplist/createStepListState.d.ts +48 -0
- package/dist/steplist/index.d.ts +1 -0
- package/dist/table/TableCollection.d.ts +3 -3
- package/dist/table/createTableColumnResizeState.d.ts +54 -0
- package/dist/table/createTableState.d.ts +2 -2
- package/dist/table/index.d.ts +5 -3
- package/dist/table/types.d.ts +10 -10
- package/dist/tabs/createTabListState.d.ts +5 -5
- package/dist/tabs/index.d.ts +1 -1
- package/dist/textfield/createTextFieldState.d.ts +2 -2
- package/dist/textfield/index.d.ts +1 -1
- package/dist/toast/createToastState.d.ts +8 -2
- package/dist/toast/index.d.ts +1 -1
- package/dist/toggle/createToggleGroupState.d.ts +4 -4
- package/dist/toggle/createToggleState.d.ts +2 -2
- package/dist/toggle/index.d.ts +2 -2
- package/dist/tooltip/createTooltipTriggerState.d.ts +2 -2
- package/dist/tooltip/index.d.ts +1 -1
- package/dist/tree/TreeCollection.d.ts +2 -2
- package/dist/tree/createTreeState.d.ts +2 -2
- package/dist/tree/index.d.ts +3 -3
- package/dist/tree/types.d.ts +19 -13
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/reactivity.d.ts +1 -1
- package/package.json +29 -30
- package/src/autocomplete/createAutocompleteState.d.ts +19 -17
- package/src/autocomplete/createAutocompleteState.ts +24 -30
- package/src/autocomplete/index.d.ts +6 -2
- package/src/autocomplete/index.ts +1 -1
- package/src/calendar/createCalendarState.d.ts +139 -117
- package/src/calendar/createCalendarState.ts +221 -74
- package/src/calendar/createDateFieldState.d.ts +130 -95
- package/src/calendar/createDateFieldState.ts +263 -151
- package/src/calendar/createDatePickerState.ts +347 -0
- package/src/calendar/createRangeCalendarState.d.ts +154 -129
- package/src/calendar/createRangeCalendarState.ts +293 -79
- package/src/calendar/createTimeFieldState.d.ts +81 -79
- package/src/calendar/createTimeFieldState.ts +187 -108
- package/src/calendar/index.d.ts +80 -7
- package/src/calendar/index.ts +21 -12
- package/src/checkbox/createCheckboxGroupState.d.ts +57 -55
- package/src/checkbox/createCheckboxGroupState.ts +20 -29
- package/src/checkbox/index.d.ts +6 -2
- package/src/checkbox/index.ts +1 -1
- package/src/collections/ListCollection.d.ts +25 -22
- package/src/collections/ListCollection.ts +6 -6
- package/src/collections/createListState.d.ts +73 -58
- package/src/collections/createListState.ts +19 -18
- package/src/collections/createMenuState.d.ts +36 -31
- package/src/collections/createMenuState.ts +18 -12
- package/src/collections/createSelectionState.d.ts +78 -65
- package/src/collections/createSelectionState.ts +36 -32
- package/src/collections/index.d.ts +38 -6
- package/src/collections/index.ts +5 -10
- package/src/collections/types.d.ts +101 -101
- package/src/collections/types.ts +12 -12
- package/src/color/Color.d.ts +20 -5
- package/src/color/Color.ts +357 -254
- package/src/color/createColorAreaState.d.ts +67 -65
- package/src/color/createColorAreaState.ts +21 -13
- package/src/color/createColorFieldState.d.ts +46 -44
- package/src/color/createColorFieldState.ts +285 -149
- package/src/color/createColorSliderState.d.ts +58 -56
- package/src/color/createColorSliderState.ts +45 -14
- package/src/color/createColorWheelState.d.ts +42 -40
- package/src/color/createColorWheelState.ts +101 -64
- package/src/color/getColorChannels.ts +7 -5
- package/src/color/index.d.ts +36 -7
- package/src/color/index.ts +6 -9
- package/src/color/types.d.ts +68 -63
- package/src/color/types.ts +11 -19
- package/src/combobox/createComboBoxState.d.ts +107 -105
- package/src/combobox/createComboBoxState.ts +176 -89
- package/src/combobox/index.d.ts +10 -2
- package/src/combobox/index.ts +1 -1
- package/src/data/createAsyncList.ts +89 -63
- package/src/data/createListData.ts +67 -67
- package/src/data/createTreeData.ts +304 -91
- package/src/data/index.ts +3 -3
- package/src/datepicker/index.ts +6 -10
- package/src/disclosure/createDisclosureState.d.ts +47 -43
- package/src/disclosure/createDisclosureState.ts +7 -21
- package/src/disclosure/index.d.ts +10 -2
- package/src/disclosure/index.ts +1 -1
- package/src/dnd/createDragState.d.ts +51 -42
- package/src/dnd/createDragState.ts +12 -14
- package/src/dnd/createDraggableCollectionState.d.ts +52 -41
- package/src/dnd/createDraggableCollectionState.ts +14 -21
- package/src/dnd/createDropState.d.ts +64 -45
- package/src/dnd/createDropState.ts +22 -32
- package/src/dnd/createDroppableCollectionState.d.ts +88 -59
- package/src/dnd/createDroppableCollectionState.ts +40 -43
- package/src/dnd/index.d.ts +54 -6
- package/src/dnd/index.ts +5 -18
- package/src/dnd/types.d.ts +167 -156
- package/src/dnd/types.ts +20 -21
- package/src/form/createFormValidationState.d.ts +47 -45
- package/src/form/createFormValidationState.ts +30 -63
- package/src/form/index.d.ts +16 -2
- package/src/form/index.ts +1 -1
- package/src/grid/createGridState.d.ts +7 -4
- package/src/grid/createGridState.ts +44 -51
- package/src/grid/index.d.ts +3 -3
- package/src/grid/index.ts +2 -8
- package/src/grid/types.d.ts +136 -129
- package/src/grid/types.ts +20 -18
- package/src/index.d.ts +310 -26
- package/src/index.ts +48 -89
- package/src/menu/index.ts +2 -4
- package/src/numberfield/createNumberFieldState.d.ts +56 -54
- package/src/numberfield/createNumberFieldState.ts +26 -31
- package/src/numberfield/index.d.ts +6 -2
- package/src/numberfield/index.ts +1 -1
- package/src/overlays/createOverlayTriggerState.d.ts +22 -20
- package/src/overlays/createOverlayTriggerState.ts +3 -4
- package/src/overlays/index.d.ts +6 -2
- package/src/overlays/index.ts +1 -1
- package/src/radio/createRadioGroupState.d.ts +54 -52
- package/src/radio/createRadioGroupState.ts +27 -29
- package/src/radio/index.d.ts +7 -2
- package/src/radio/index.ts +1 -1
- package/src/searchfield/createSearchFieldState.d.ts +16 -14
- package/src/searchfield/createSearchFieldState.ts +5 -11
- package/src/searchfield/index.d.ts +3 -3
- package/src/searchfield/index.ts +2 -5
- package/src/select/createSelectState.d.ts +63 -61
- package/src/select/createSelectState.ts +27 -27
- package/src/select/index.d.ts +2 -2
- package/src/select/index.ts +1 -5
- package/src/selection/index.ts +6 -7
- package/src/slider/createSliderState.d.ts +60 -60
- package/src/slider/createSliderState.ts +55 -33
- package/src/slider/index.d.ts +3 -3
- package/src/slider/index.ts +2 -6
- package/src/ssr/index.d.ts +1 -1
- package/src/ssr/index.ts +2 -2
- package/src/steplist/createStepListState.ts +191 -0
- package/src/steplist/index.ts +5 -0
- package/src/table/TableCollection.d.ts +42 -40
- package/src/table/TableCollection.ts +61 -64
- package/src/table/createTableColumnResizeState.ts +242 -0
- package/src/table/createTableState.d.ts +7 -4
- package/src/table/createTableState.ts +10 -7
- package/src/table/index.d.ts +14 -4
- package/src/table/index.ts +10 -3
- package/src/table/types.d.ts +98 -92
- package/src/table/types.ts +17 -13
- package/src/tabs/createTabListState.d.ts +59 -57
- package/src/tabs/createTabListState.ts +24 -31
- package/src/tabs/index.d.ts +8 -2
- package/src/tabs/index.ts +1 -1
- package/src/textfield/createTextFieldState.d.ts +16 -14
- package/src/textfield/createTextFieldState.ts +7 -18
- package/src/textfield/index.d.ts +6 -2
- package/src/textfield/index.ts +1 -1
- package/src/toast/createToastState.d.ts +92 -86
- package/src/toast/createToastState.ts +48 -43
- package/src/toast/index.d.ts +12 -2
- package/src/toast/index.ts +1 -1
- package/src/toggle/createToggleGroupState.ts +11 -21
- package/src/toggle/createToggleState.d.ts +19 -19
- package/src/toggle/createToggleState.ts +2 -16
- package/src/toggle/index.d.ts +2 -2
- package/src/toggle/index.ts +2 -6
- package/src/tooltip/createTooltipTriggerState.d.ts +17 -17
- package/src/tooltip/createTooltipTriggerState.ts +12 -11
- package/src/tooltip/index.d.ts +7 -2
- package/src/tooltip/index.ts +1 -1
- package/src/tree/TreeCollection.d.ts +26 -23
- package/src/tree/TreeCollection.ts +29 -22
- package/src/tree/createTreeState.d.ts +7 -4
- package/src/tree/createTreeState.ts +39 -41
- package/src/tree/index.d.ts +10 -4
- package/src/tree/index.ts +3 -3
- package/src/tree/types.d.ts +131 -126
- package/src/tree/types.ts +22 -13
- package/src/utils/index.d.ts +2 -2
- package/src/utils/index.ts +1 -1
- package/src/utils/reactivity.d.ts +2 -2
- package/src/utils/reactivity.ts +3 -3
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Provides reactive state for accepting drops onto a collection.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { createSignal, createMemo, type Accessor } from
|
|
7
|
+
import { createSignal, createMemo, type Accessor } from "solid-js";
|
|
8
8
|
import type {
|
|
9
9
|
DropItem,
|
|
10
10
|
DropTarget,
|
|
@@ -20,21 +20,21 @@ import type {
|
|
|
20
20
|
DroppableCollectionOnItemDropEvent,
|
|
21
21
|
DroppableCollectionReorderEvent,
|
|
22
22
|
ItemDropTarget,
|
|
23
|
-
} from
|
|
23
|
+
} from "./types";
|
|
24
24
|
|
|
25
25
|
export interface DroppableCollectionStateOptions {
|
|
26
26
|
/**
|
|
27
27
|
* The drag types that the droppable collection accepts.
|
|
28
28
|
* @default 'all'
|
|
29
29
|
*/
|
|
30
|
-
acceptedDragTypes?:
|
|
30
|
+
acceptedDragTypes?: "all" | Array<string | symbol>;
|
|
31
31
|
/**
|
|
32
32
|
* A function returning the drop operation to be performed.
|
|
33
33
|
*/
|
|
34
34
|
getDropOperation?: (
|
|
35
35
|
target: DropTarget,
|
|
36
36
|
types: DragTypes,
|
|
37
|
-
allowedOperations: DropOperation[]
|
|
37
|
+
allowedOperations: DropOperation[],
|
|
38
38
|
) => DropOperation;
|
|
39
39
|
/** Handler that is called when a valid drag enters a drop target. */
|
|
40
40
|
onDropEnter?: (e: DroppableCollectionEnterEvent) => void;
|
|
@@ -84,13 +84,13 @@ export interface DroppableCollectionState {
|
|
|
84
84
|
items: DropItem[],
|
|
85
85
|
dropOperation: DropOperation,
|
|
86
86
|
isInternal: boolean,
|
|
87
|
-
draggingKeys?: Set<string | number
|
|
87
|
+
draggingKeys?: Set<string | number>,
|
|
88
88
|
): void;
|
|
89
89
|
/** Get the drop operation for a target. */
|
|
90
90
|
getDropOperation(
|
|
91
91
|
target: DropTarget,
|
|
92
92
|
types: DragTypes,
|
|
93
|
-
allowedOperations: DropOperation[]
|
|
93
|
+
allowedOperations: DropOperation[],
|
|
94
94
|
): DropOperation;
|
|
95
95
|
/** Check if an item drop should be accepted. */
|
|
96
96
|
shouldAcceptItemDrop(target: ItemDropTarget, types: DragTypes): boolean;
|
|
@@ -99,7 +99,7 @@ export interface DroppableCollectionState {
|
|
|
99
99
|
/**
|
|
100
100
|
* Symbol for directory drag type.
|
|
101
101
|
*/
|
|
102
|
-
export const DIRECTORY_DRAG_TYPE: symbol = Symbol(
|
|
102
|
+
export const DIRECTORY_DRAG_TYPE: symbol = Symbol("directory");
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
* Creates state for accepting drops onto a collection.
|
|
@@ -108,7 +108,7 @@ export const DIRECTORY_DRAG_TYPE: symbol = Symbol('directory');
|
|
|
108
108
|
* @returns Droppable collection state object
|
|
109
109
|
*/
|
|
110
110
|
export function createDroppableCollectionState(
|
|
111
|
-
props: Accessor<DroppableCollectionStateOptions
|
|
111
|
+
props: Accessor<DroppableCollectionStateOptions>,
|
|
112
112
|
): DroppableCollectionState {
|
|
113
113
|
const getProps = createMemo(() => props());
|
|
114
114
|
|
|
@@ -117,9 +117,9 @@ export function createDroppableCollectionState(
|
|
|
117
117
|
|
|
118
118
|
const isAccepted = (types: DragTypes): boolean => {
|
|
119
119
|
const p = getProps();
|
|
120
|
-
const acceptedTypes = p.acceptedDragTypes ??
|
|
120
|
+
const acceptedTypes = p.acceptedDragTypes ?? "all";
|
|
121
121
|
|
|
122
|
-
if (acceptedTypes ===
|
|
122
|
+
if (acceptedTypes === "all") {
|
|
123
123
|
return true;
|
|
124
124
|
}
|
|
125
125
|
|
|
@@ -139,9 +139,9 @@ export function createDroppableCollectionState(
|
|
|
139
139
|
setIsDropTarget(true);
|
|
140
140
|
setTarget(dropTarget);
|
|
141
141
|
|
|
142
|
-
if (typeof p.onDropEnter ===
|
|
142
|
+
if (typeof p.onDropEnter === "function") {
|
|
143
143
|
p.onDropEnter({
|
|
144
|
-
type:
|
|
144
|
+
type: "dropenter",
|
|
145
145
|
x,
|
|
146
146
|
y,
|
|
147
147
|
target: dropTarget,
|
|
@@ -158,18 +158,18 @@ export function createDroppableCollectionState(
|
|
|
158
158
|
|
|
159
159
|
// Fire exit/enter events if target changed
|
|
160
160
|
if (prevTarget && !targetsEqual(prevTarget, dropTarget)) {
|
|
161
|
-
if (typeof p.onDropExit ===
|
|
161
|
+
if (typeof p.onDropExit === "function") {
|
|
162
162
|
p.onDropExit({
|
|
163
|
-
type:
|
|
163
|
+
type: "dropexit",
|
|
164
164
|
x,
|
|
165
165
|
y,
|
|
166
166
|
target: prevTarget,
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
if (typeof p.onDropEnter ===
|
|
170
|
+
if (typeof p.onDropEnter === "function") {
|
|
171
171
|
p.onDropEnter({
|
|
172
|
-
type:
|
|
172
|
+
type: "dropenter",
|
|
173
173
|
x,
|
|
174
174
|
y,
|
|
175
175
|
target: dropTarget,
|
|
@@ -185,9 +185,9 @@ export function createDroppableCollectionState(
|
|
|
185
185
|
setIsDropTarget(false);
|
|
186
186
|
setTarget(null);
|
|
187
187
|
|
|
188
|
-
if (currentTarget && typeof p.onDropExit ===
|
|
188
|
+
if (currentTarget && typeof p.onDropExit === "function") {
|
|
189
189
|
p.onDropExit({
|
|
190
|
-
type:
|
|
190
|
+
type: "dropexit",
|
|
191
191
|
x,
|
|
192
192
|
y,
|
|
193
193
|
target: currentTarget,
|
|
@@ -200,9 +200,9 @@ export function createDroppableCollectionState(
|
|
|
200
200
|
const currentTarget = target();
|
|
201
201
|
if (p.isDisabled || !currentTarget) return;
|
|
202
202
|
|
|
203
|
-
if (typeof p.onDropActivate ===
|
|
203
|
+
if (typeof p.onDropActivate === "function") {
|
|
204
204
|
p.onDropActivate({
|
|
205
|
-
type:
|
|
205
|
+
type: "dropactivate",
|
|
206
206
|
x,
|
|
207
207
|
y,
|
|
208
208
|
target: currentTarget,
|
|
@@ -214,7 +214,7 @@ export function createDroppableCollectionState(
|
|
|
214
214
|
items: DropItem[],
|
|
215
215
|
dropOperation: DropOperation,
|
|
216
216
|
isInternal: boolean,
|
|
217
|
-
draggingKeys?: Set<string | number
|
|
217
|
+
draggingKeys?: Set<string | number>,
|
|
218
218
|
) => {
|
|
219
219
|
const p = getProps();
|
|
220
220
|
const currentTarget = target();
|
|
@@ -224,9 +224,9 @@ export function createDroppableCollectionState(
|
|
|
224
224
|
setTarget(null);
|
|
225
225
|
|
|
226
226
|
// Call the generic onDrop handler
|
|
227
|
-
if (typeof p.onDrop ===
|
|
227
|
+
if (typeof p.onDrop === "function") {
|
|
228
228
|
p.onDrop({
|
|
229
|
-
type:
|
|
229
|
+
type: "drop",
|
|
230
230
|
x: 0,
|
|
231
231
|
y: 0,
|
|
232
232
|
items,
|
|
@@ -236,18 +236,18 @@ export function createDroppableCollectionState(
|
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
// Call specific handlers based on the drop type
|
|
239
|
-
if (currentTarget.type ===
|
|
240
|
-
if (typeof p.onRootDrop ===
|
|
239
|
+
if (currentTarget.type === "root") {
|
|
240
|
+
if (typeof p.onRootDrop === "function") {
|
|
241
241
|
p.onRootDrop({
|
|
242
242
|
items,
|
|
243
243
|
dropOperation,
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
|
-
} else if (currentTarget.type ===
|
|
246
|
+
} else if (currentTarget.type === "item") {
|
|
247
247
|
if (isInternal && draggingKeys) {
|
|
248
248
|
// Reorder or move within the same collection
|
|
249
|
-
if (currentTarget.dropPosition ===
|
|
250
|
-
if (typeof p.onMove ===
|
|
249
|
+
if (currentTarget.dropPosition === "on") {
|
|
250
|
+
if (typeof p.onMove === "function") {
|
|
251
251
|
p.onMove({
|
|
252
252
|
keys: draggingKeys,
|
|
253
253
|
dropOperation,
|
|
@@ -255,7 +255,7 @@ export function createDroppableCollectionState(
|
|
|
255
255
|
});
|
|
256
256
|
}
|
|
257
257
|
} else {
|
|
258
|
-
if (typeof p.onReorder ===
|
|
258
|
+
if (typeof p.onReorder === "function") {
|
|
259
259
|
p.onReorder({
|
|
260
260
|
keys: draggingKeys,
|
|
261
261
|
dropOperation,
|
|
@@ -265,8 +265,8 @@ export function createDroppableCollectionState(
|
|
|
265
265
|
}
|
|
266
266
|
} else {
|
|
267
267
|
// External drop
|
|
268
|
-
if (currentTarget.dropPosition ===
|
|
269
|
-
if (typeof p.onItemDrop ===
|
|
268
|
+
if (currentTarget.dropPosition === "on") {
|
|
269
|
+
if (typeof p.onItemDrop === "function") {
|
|
270
270
|
p.onItemDrop({
|
|
271
271
|
items,
|
|
272
272
|
dropOperation,
|
|
@@ -275,7 +275,7 @@ export function createDroppableCollectionState(
|
|
|
275
275
|
});
|
|
276
276
|
}
|
|
277
277
|
} else {
|
|
278
|
-
if (typeof p.onInsert ===
|
|
278
|
+
if (typeof p.onInsert === "function") {
|
|
279
279
|
p.onInsert({
|
|
280
280
|
items,
|
|
281
281
|
dropOperation,
|
|
@@ -290,32 +290,29 @@ export function createDroppableCollectionState(
|
|
|
290
290
|
const getDropOperation = (
|
|
291
291
|
dropTarget: DropTarget,
|
|
292
292
|
types: DragTypes,
|
|
293
|
-
allowedOperations: DropOperation[]
|
|
293
|
+
allowedOperations: DropOperation[],
|
|
294
294
|
): DropOperation => {
|
|
295
295
|
const p = getProps();
|
|
296
296
|
|
|
297
297
|
if (!isAccepted(types)) {
|
|
298
|
-
return
|
|
298
|
+
return "cancel";
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
if (typeof p.getDropOperation ===
|
|
301
|
+
if (typeof p.getDropOperation === "function") {
|
|
302
302
|
return p.getDropOperation(dropTarget, types, allowedOperations);
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
return allowedOperations[0] ??
|
|
305
|
+
return allowedOperations[0] ?? "cancel";
|
|
306
306
|
};
|
|
307
307
|
|
|
308
|
-
const shouldAcceptItemDrop = (
|
|
309
|
-
dropTarget: ItemDropTarget,
|
|
310
|
-
types: DragTypes
|
|
311
|
-
): boolean => {
|
|
308
|
+
const shouldAcceptItemDrop = (dropTarget: ItemDropTarget, types: DragTypes): boolean => {
|
|
312
309
|
const p = getProps();
|
|
313
310
|
|
|
314
311
|
if (!isAccepted(types)) {
|
|
315
312
|
return false;
|
|
316
313
|
}
|
|
317
314
|
|
|
318
|
-
if (typeof p.shouldAcceptItemDrop ===
|
|
315
|
+
if (typeof p.shouldAcceptItemDrop === "function") {
|
|
319
316
|
return p.shouldAcceptItemDrop(dropTarget, types);
|
|
320
317
|
}
|
|
321
318
|
|
|
@@ -349,8 +346,8 @@ export function createDroppableCollectionState(
|
|
|
349
346
|
*/
|
|
350
347
|
function targetsEqual(a: DropTarget, b: DropTarget): boolean {
|
|
351
348
|
if (a.type !== b.type) return false;
|
|
352
|
-
if (a.type ===
|
|
353
|
-
if (a.type ===
|
|
349
|
+
if (a.type === "root" && b.type === "root") return true;
|
|
350
|
+
if (a.type === "item" && b.type === "item") {
|
|
354
351
|
return a.key === b.key && a.dropPosition === b.dropPosition;
|
|
355
352
|
}
|
|
356
353
|
return false;
|
package/src/dnd/index.d.ts
CHANGED
|
@@ -3,9 +3,57 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Exports for DnD functionality.
|
|
5
5
|
*/
|
|
6
|
-
export type {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
export type {
|
|
7
|
+
DropOperation,
|
|
8
|
+
DragItem,
|
|
9
|
+
DragDropEvent,
|
|
10
|
+
DragStartEvent,
|
|
11
|
+
DragMoveEvent,
|
|
12
|
+
DragEndEvent,
|
|
13
|
+
DropEnterEvent,
|
|
14
|
+
DropMoveEvent,
|
|
15
|
+
DropActivateEvent,
|
|
16
|
+
DropExitEvent,
|
|
17
|
+
TextDropItem,
|
|
18
|
+
FileDropItem,
|
|
19
|
+
DirectoryDropItem,
|
|
20
|
+
DropItem,
|
|
21
|
+
DropEvent,
|
|
22
|
+
DropPosition,
|
|
23
|
+
RootDropTarget,
|
|
24
|
+
ItemDropTarget,
|
|
25
|
+
DropTarget,
|
|
26
|
+
DroppableCollectionEnterEvent,
|
|
27
|
+
DroppableCollectionMoveEvent,
|
|
28
|
+
DroppableCollectionActivateEvent,
|
|
29
|
+
DroppableCollectionExitEvent,
|
|
30
|
+
DroppableCollectionDropEvent,
|
|
31
|
+
DroppableCollectionInsertDropEvent,
|
|
32
|
+
DroppableCollectionRootDropEvent,
|
|
33
|
+
DroppableCollectionOnItemDropEvent,
|
|
34
|
+
DroppableCollectionReorderEvent,
|
|
35
|
+
DragTypes,
|
|
36
|
+
DropTargetDelegate,
|
|
37
|
+
DraggableCollectionStartEvent,
|
|
38
|
+
DraggableCollectionMoveEvent,
|
|
39
|
+
DraggableCollectionEndEvent,
|
|
40
|
+
DragPreviewRenderer,
|
|
41
|
+
DroppableCollectionUtilityOptions,
|
|
42
|
+
DroppableCollectionBaseProps,
|
|
43
|
+
DroppableCollectionProps,
|
|
44
|
+
DraggableCollectionProps,
|
|
45
|
+
} from "./types";
|
|
46
|
+
export { createDragState, type DragStateOptions, type DragState } from "./createDragState";
|
|
47
|
+
export { createDropState, type DropStateOptions, type DropState } from "./createDropState";
|
|
48
|
+
export {
|
|
49
|
+
createDraggableCollectionState,
|
|
50
|
+
type DraggableCollectionStateOptions,
|
|
51
|
+
type DraggableCollectionState,
|
|
52
|
+
} from "./createDraggableCollectionState";
|
|
53
|
+
export {
|
|
54
|
+
createDroppableCollectionState,
|
|
55
|
+
DIRECTORY_DRAG_TYPE,
|
|
56
|
+
type DroppableCollectionStateOptions,
|
|
57
|
+
type DroppableCollectionState,
|
|
58
|
+
} from "./createDroppableCollectionState";
|
|
59
|
+
//# sourceMappingURL=index.d.ts.map
|
package/src/dnd/index.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* Exports for DnD functionality.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
// Types
|
|
8
7
|
export type {
|
|
9
8
|
DropOperation,
|
|
10
9
|
DragItem,
|
|
@@ -44,33 +43,21 @@ export type {
|
|
|
44
43
|
DroppableCollectionBaseProps,
|
|
45
44
|
DroppableCollectionProps,
|
|
46
45
|
DraggableCollectionProps,
|
|
47
|
-
} from
|
|
46
|
+
} from "./types";
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
export {
|
|
51
|
-
createDragState,
|
|
52
|
-
type DragStateOptions,
|
|
53
|
-
type DragState,
|
|
54
|
-
} from './createDragState';
|
|
48
|
+
export { createDragState, type DragStateOptions, type DragState } from "./createDragState";
|
|
55
49
|
|
|
56
|
-
|
|
57
|
-
export {
|
|
58
|
-
createDropState,
|
|
59
|
-
type DropStateOptions,
|
|
60
|
-
type DropState,
|
|
61
|
-
} from './createDropState';
|
|
50
|
+
export { createDropState, type DropStateOptions, type DropState } from "./createDropState";
|
|
62
51
|
|
|
63
|
-
// Draggable collection state
|
|
64
52
|
export {
|
|
65
53
|
createDraggableCollectionState,
|
|
66
54
|
type DraggableCollectionStateOptions,
|
|
67
55
|
type DraggableCollectionState,
|
|
68
|
-
} from
|
|
56
|
+
} from "./createDraggableCollectionState";
|
|
69
57
|
|
|
70
|
-
// Droppable collection state
|
|
71
58
|
export {
|
|
72
59
|
createDroppableCollectionState,
|
|
73
60
|
DIRECTORY_DRAG_TYPE,
|
|
74
61
|
type DroppableCollectionStateOptions,
|
|
75
62
|
type DroppableCollectionState,
|
|
76
|
-
} from
|
|
63
|
+
} from "./createDroppableCollectionState";
|