@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
|
@@ -3,53 +3,72 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides reactive state for drop target operations.
|
|
5
5
|
*/
|
|
6
|
-
import { type Accessor } from
|
|
7
|
-
import type {
|
|
6
|
+
import { type Accessor } from "solid-js";
|
|
7
|
+
import type {
|
|
8
|
+
DropItem,
|
|
9
|
+
DropEnterEvent,
|
|
10
|
+
DropMoveEvent,
|
|
11
|
+
DropExitEvent,
|
|
12
|
+
DropActivateEvent,
|
|
13
|
+
DropEvent,
|
|
14
|
+
DropOperation,
|
|
15
|
+
DragTypes,
|
|
16
|
+
} from "./types";
|
|
8
17
|
export interface DropStateOptions {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
/**
|
|
19
|
+
* A function returning the drop operation to be performed.
|
|
20
|
+
*/
|
|
21
|
+
getDropOperation?: (types: DragTypes, allowedOperations: DropOperation[]) => DropOperation;
|
|
22
|
+
/**
|
|
23
|
+
* A function returning the drop operation for a specific point.
|
|
24
|
+
*/
|
|
25
|
+
getDropOperationForPoint?: (
|
|
26
|
+
types: DragTypes,
|
|
27
|
+
allowedOperations: DropOperation[],
|
|
28
|
+
x: number,
|
|
29
|
+
y: number,
|
|
30
|
+
) => DropOperation;
|
|
31
|
+
/** Handler that is called when a valid drag enters the drop target. */
|
|
32
|
+
onDropEnter?: (e: DropEnterEvent) => void;
|
|
33
|
+
/** Handler that is called when a valid drag is moved within the drop target. */
|
|
34
|
+
onDropMove?: (e: DropMoveEvent) => void;
|
|
35
|
+
/** Handler that is called after a valid drag is held over the drop target. */
|
|
36
|
+
onDropActivate?: (e: DropActivateEvent) => void;
|
|
37
|
+
/** Handler that is called when a valid drag exits the drop target. */
|
|
38
|
+
onDropExit?: (e: DropExitEvent) => void;
|
|
39
|
+
/** Handler that is called when a valid drag is dropped on the drop target. */
|
|
40
|
+
onDrop?: (e: DropEvent) => void;
|
|
41
|
+
/** Whether there is a separate drop button affordance. */
|
|
42
|
+
hasDropButton?: boolean;
|
|
43
|
+
/** Whether the drop target is disabled. */
|
|
44
|
+
isDisabled?: boolean;
|
|
31
45
|
}
|
|
32
46
|
export interface DropState {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
/** Whether the drop target is currently being hovered or focused. */
|
|
48
|
+
readonly isDropTarget: boolean;
|
|
49
|
+
/** Whether the drop target is disabled. */
|
|
50
|
+
readonly isDisabled: boolean;
|
|
51
|
+
/** Whether there is a drop button. */
|
|
52
|
+
readonly hasDropButton: boolean;
|
|
53
|
+
/** Enter the drop target. */
|
|
54
|
+
enterTarget(x: number, y: number): void;
|
|
55
|
+
/** Move within the drop target. */
|
|
56
|
+
moveInTarget(x: number, y: number): void;
|
|
57
|
+
/** Exit the drop target. */
|
|
58
|
+
exitTarget(x: number, y: number): void;
|
|
59
|
+
/** Activate the drop target (after holding). */
|
|
60
|
+
activateTarget(x: number, y: number): void;
|
|
61
|
+
/** Perform a drop on the target. */
|
|
62
|
+
drop(x: number, y: number, items: DropItem[], dropOperation: DropOperation): void;
|
|
63
|
+
/** Get the drop operation for given types. */
|
|
64
|
+
getDropOperation(types: DragTypes, allowedOperations: DropOperation[]): DropOperation;
|
|
65
|
+
/** Get the drop operation for a specific point. */
|
|
66
|
+
getDropOperationForPoint(
|
|
67
|
+
types: DragTypes,
|
|
68
|
+
allowedOperations: DropOperation[],
|
|
69
|
+
x: number,
|
|
70
|
+
y: number,
|
|
71
|
+
): DropOperation;
|
|
53
72
|
}
|
|
54
73
|
/**
|
|
55
74
|
* Creates drop state for managing drop target operations.
|
|
@@ -58,4 +77,4 @@ export interface DropState {
|
|
|
58
77
|
* @returns Drop state object
|
|
59
78
|
*/
|
|
60
79
|
export declare function createDropState(props: Accessor<DropStateOptions>): DropState;
|
|
61
|
-
//# sourceMappingURL=createDropState.d.ts.map
|
|
80
|
+
//# sourceMappingURL=createDropState.d.ts.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Provides reactive state for drop target operations.
|
|
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
|
DropEnterEvent,
|
|
@@ -14,16 +14,13 @@ import type {
|
|
|
14
14
|
DropEvent,
|
|
15
15
|
DropOperation,
|
|
16
16
|
DragTypes,
|
|
17
|
-
} from
|
|
17
|
+
} from "./types";
|
|
18
18
|
|
|
19
19
|
export interface DropStateOptions {
|
|
20
20
|
/**
|
|
21
21
|
* A function returning the drop operation to be performed.
|
|
22
22
|
*/
|
|
23
|
-
getDropOperation?: (
|
|
24
|
-
types: DragTypes,
|
|
25
|
-
allowedOperations: DropOperation[]
|
|
26
|
-
) => DropOperation;
|
|
23
|
+
getDropOperation?: (types: DragTypes, allowedOperations: DropOperation[]) => DropOperation;
|
|
27
24
|
/**
|
|
28
25
|
* A function returning the drop operation for a specific point.
|
|
29
26
|
*/
|
|
@@ -31,7 +28,7 @@ export interface DropStateOptions {
|
|
|
31
28
|
types: DragTypes,
|
|
32
29
|
allowedOperations: DropOperation[],
|
|
33
30
|
x: number,
|
|
34
|
-
y: number
|
|
31
|
+
y: number,
|
|
35
32
|
) => DropOperation;
|
|
36
33
|
/** Handler that is called when a valid drag enters the drop target. */
|
|
37
34
|
onDropEnter?: (e: DropEnterEvent) => void;
|
|
@@ -73,7 +70,7 @@ export interface DropState {
|
|
|
73
70
|
types: DragTypes,
|
|
74
71
|
allowedOperations: DropOperation[],
|
|
75
72
|
x: number,
|
|
76
|
-
y: number
|
|
73
|
+
y: number,
|
|
77
74
|
): DropOperation;
|
|
78
75
|
}
|
|
79
76
|
|
|
@@ -83,9 +80,7 @@ export interface DropState {
|
|
|
83
80
|
* @param props - Accessor returning drop state options
|
|
84
81
|
* @returns Drop state object
|
|
85
82
|
*/
|
|
86
|
-
export function createDropState(
|
|
87
|
-
props: Accessor<DropStateOptions>
|
|
88
|
-
): DropState {
|
|
83
|
+
export function createDropState(props: Accessor<DropStateOptions>): DropState {
|
|
89
84
|
const getProps = createMemo(() => props());
|
|
90
85
|
|
|
91
86
|
const [isDropTarget, setIsDropTarget] = createSignal(false);
|
|
@@ -96,9 +91,9 @@ export function createDropState(
|
|
|
96
91
|
|
|
97
92
|
setIsDropTarget(true);
|
|
98
93
|
|
|
99
|
-
if (typeof p.onDropEnter ===
|
|
94
|
+
if (typeof p.onDropEnter === "function") {
|
|
100
95
|
p.onDropEnter({
|
|
101
|
-
type:
|
|
96
|
+
type: "dropenter",
|
|
102
97
|
x,
|
|
103
98
|
y,
|
|
104
99
|
});
|
|
@@ -109,9 +104,9 @@ export function createDropState(
|
|
|
109
104
|
const p = getProps();
|
|
110
105
|
if (!isDropTarget() || p.isDisabled) return;
|
|
111
106
|
|
|
112
|
-
if (typeof p.onDropMove ===
|
|
107
|
+
if (typeof p.onDropMove === "function") {
|
|
113
108
|
p.onDropMove({
|
|
114
|
-
type:
|
|
109
|
+
type: "dropmove",
|
|
115
110
|
x,
|
|
116
111
|
y,
|
|
117
112
|
});
|
|
@@ -123,9 +118,9 @@ export function createDropState(
|
|
|
123
118
|
|
|
124
119
|
setIsDropTarget(false);
|
|
125
120
|
|
|
126
|
-
if (typeof p.onDropExit ===
|
|
121
|
+
if (typeof p.onDropExit === "function") {
|
|
127
122
|
p.onDropExit({
|
|
128
|
-
type:
|
|
123
|
+
type: "dropexit",
|
|
129
124
|
x,
|
|
130
125
|
y,
|
|
131
126
|
});
|
|
@@ -136,29 +131,24 @@ export function createDropState(
|
|
|
136
131
|
const p = getProps();
|
|
137
132
|
if (p.isDisabled) return;
|
|
138
133
|
|
|
139
|
-
if (typeof p.onDropActivate ===
|
|
134
|
+
if (typeof p.onDropActivate === "function") {
|
|
140
135
|
p.onDropActivate({
|
|
141
|
-
type:
|
|
136
|
+
type: "dropactivate",
|
|
142
137
|
x,
|
|
143
138
|
y,
|
|
144
139
|
});
|
|
145
140
|
}
|
|
146
141
|
};
|
|
147
142
|
|
|
148
|
-
const drop = (
|
|
149
|
-
x: number,
|
|
150
|
-
y: number,
|
|
151
|
-
items: DropItem[],
|
|
152
|
-
dropOperation: DropOperation
|
|
153
|
-
) => {
|
|
143
|
+
const drop = (x: number, y: number, items: DropItem[], dropOperation: DropOperation) => {
|
|
154
144
|
const p = getProps();
|
|
155
145
|
if (p.isDisabled) return;
|
|
156
146
|
|
|
157
147
|
setIsDropTarget(false);
|
|
158
148
|
|
|
159
|
-
if (typeof p.onDrop ===
|
|
149
|
+
if (typeof p.onDrop === "function") {
|
|
160
150
|
p.onDrop({
|
|
161
|
-
type:
|
|
151
|
+
type: "drop",
|
|
162
152
|
x,
|
|
163
153
|
y,
|
|
164
154
|
items,
|
|
@@ -169,23 +159,23 @@ export function createDropState(
|
|
|
169
159
|
|
|
170
160
|
const getDropOperation = (
|
|
171
161
|
types: DragTypes,
|
|
172
|
-
allowedOperations: DropOperation[]
|
|
162
|
+
allowedOperations: DropOperation[],
|
|
173
163
|
): DropOperation => {
|
|
174
164
|
const p = getProps();
|
|
175
|
-
if (typeof p.getDropOperation ===
|
|
165
|
+
if (typeof p.getDropOperation === "function") {
|
|
176
166
|
return p.getDropOperation(types, allowedOperations);
|
|
177
167
|
}
|
|
178
|
-
return allowedOperations[0] ??
|
|
168
|
+
return allowedOperations[0] ?? "cancel";
|
|
179
169
|
};
|
|
180
170
|
|
|
181
171
|
const getDropOperationForPoint = (
|
|
182
172
|
types: DragTypes,
|
|
183
173
|
allowedOperations: DropOperation[],
|
|
184
174
|
x: number,
|
|
185
|
-
y: number
|
|
175
|
+
y: number,
|
|
186
176
|
): DropOperation => {
|
|
187
177
|
const p = getProps();
|
|
188
|
-
if (typeof p.getDropOperationForPoint ===
|
|
178
|
+
if (typeof p.getDropOperationForPoint === "function") {
|
|
189
179
|
return p.getDropOperationForPoint(types, allowedOperations, x, y);
|
|
190
180
|
}
|
|
191
181
|
return getDropOperation(types, allowedOperations);
|
|
@@ -3,66 +3,93 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides reactive state for accepting drops onto a collection.
|
|
5
5
|
*/
|
|
6
|
-
import { type Accessor } from
|
|
7
|
-
import type {
|
|
6
|
+
import { type Accessor } from "solid-js";
|
|
7
|
+
import type {
|
|
8
|
+
DropItem,
|
|
9
|
+
DropTarget,
|
|
10
|
+
DropOperation,
|
|
11
|
+
DragTypes,
|
|
12
|
+
DroppableCollectionEnterEvent,
|
|
13
|
+
DroppableCollectionActivateEvent,
|
|
14
|
+
DroppableCollectionExitEvent,
|
|
15
|
+
DroppableCollectionDropEvent,
|
|
16
|
+
DroppableCollectionInsertDropEvent,
|
|
17
|
+
DroppableCollectionRootDropEvent,
|
|
18
|
+
DroppableCollectionOnItemDropEvent,
|
|
19
|
+
DroppableCollectionReorderEvent,
|
|
20
|
+
ItemDropTarget,
|
|
21
|
+
} from "./types";
|
|
8
22
|
export interface DroppableCollectionStateOptions {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
23
|
+
/**
|
|
24
|
+
* The drag types that the droppable collection accepts.
|
|
25
|
+
* @default 'all'
|
|
26
|
+
*/
|
|
27
|
+
acceptedDragTypes?: "all" | Array<string | symbol>;
|
|
28
|
+
/**
|
|
29
|
+
* A function returning the drop operation to be performed.
|
|
30
|
+
*/
|
|
31
|
+
getDropOperation?: (
|
|
32
|
+
target: DropTarget,
|
|
33
|
+
types: DragTypes,
|
|
34
|
+
allowedOperations: DropOperation[],
|
|
35
|
+
) => DropOperation;
|
|
36
|
+
/** Handler that is called when a valid drag enters a drop target. */
|
|
37
|
+
onDropEnter?: (e: DroppableCollectionEnterEvent) => void;
|
|
38
|
+
/** Handler that is called after a valid drag is held over a drop target. */
|
|
39
|
+
onDropActivate?: (e: DroppableCollectionActivateEvent) => void;
|
|
40
|
+
/** Handler that is called when a valid drag exits a drop target. */
|
|
41
|
+
onDropExit?: (e: DroppableCollectionExitEvent) => void;
|
|
42
|
+
/** Handler that is called when a valid drag is dropped. */
|
|
43
|
+
onDrop?: (e: DroppableCollectionDropEvent) => void;
|
|
44
|
+
/** Handler that is called when external items are dropped "between" items. */
|
|
45
|
+
onInsert?: (e: DroppableCollectionInsertDropEvent) => void;
|
|
46
|
+
/** Handler that is called when external items are dropped on the collection's root. */
|
|
47
|
+
onRootDrop?: (e: DroppableCollectionRootDropEvent) => void;
|
|
48
|
+
/** Handler that is called when items are dropped "on" an item. */
|
|
49
|
+
onItemDrop?: (e: DroppableCollectionOnItemDropEvent) => void;
|
|
50
|
+
/** Handler that is called when items are reordered within the collection. */
|
|
51
|
+
onReorder?: (e: DroppableCollectionReorderEvent) => void;
|
|
52
|
+
/** Handler that is called when items are moved within the source collection. */
|
|
53
|
+
onMove?: (e: DroppableCollectionReorderEvent) => void;
|
|
54
|
+
/** A function returning whether a given target is a valid "on" drop target. */
|
|
55
|
+
shouldAcceptItemDrop?: (target: ItemDropTarget, types: DragTypes) => boolean;
|
|
56
|
+
/** Whether the droppable collection is disabled. */
|
|
57
|
+
isDisabled?: boolean;
|
|
40
58
|
}
|
|
41
59
|
export interface DroppableCollectionState {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
/** Whether a drag is currently over the collection. */
|
|
61
|
+
readonly isDropTarget: boolean;
|
|
62
|
+
/** The current drop target within the collection. */
|
|
63
|
+
readonly target: DropTarget | null;
|
|
64
|
+
/** Whether the collection is disabled for drops. */
|
|
65
|
+
readonly isDisabled: boolean;
|
|
66
|
+
/** Set the current drop target. */
|
|
67
|
+
setTarget(target: DropTarget | null): void;
|
|
68
|
+
/** Check if a drag type is accepted. */
|
|
69
|
+
isAccepted(types: DragTypes): boolean;
|
|
70
|
+
/** Enter the collection with a drop target. */
|
|
71
|
+
enterTarget(target: DropTarget, x: number, y: number): void;
|
|
72
|
+
/** Move to a new target within the collection. */
|
|
73
|
+
moveToTarget(target: DropTarget, x: number, y: number): void;
|
|
74
|
+
/** Exit the collection. */
|
|
75
|
+
exitTarget(x: number, y: number): void;
|
|
76
|
+
/** Activate the current target. */
|
|
77
|
+
activateTarget(x: number, y: number): void;
|
|
78
|
+
/** Perform a drop on the collection. */
|
|
79
|
+
drop(
|
|
80
|
+
items: DropItem[],
|
|
81
|
+
dropOperation: DropOperation,
|
|
82
|
+
isInternal: boolean,
|
|
83
|
+
draggingKeys?: Set<string | number>,
|
|
84
|
+
): void;
|
|
85
|
+
/** Get the drop operation for a target. */
|
|
86
|
+
getDropOperation(
|
|
87
|
+
target: DropTarget,
|
|
88
|
+
types: DragTypes,
|
|
89
|
+
allowedOperations: DropOperation[],
|
|
90
|
+
): DropOperation;
|
|
91
|
+
/** Check if an item drop should be accepted. */
|
|
92
|
+
shouldAcceptItemDrop(target: ItemDropTarget, types: DragTypes): boolean;
|
|
66
93
|
}
|
|
67
94
|
/**
|
|
68
95
|
* Symbol for directory drag type.
|
|
@@ -74,5 +101,7 @@ export declare const DIRECTORY_DRAG_TYPE: symbol;
|
|
|
74
101
|
* @param props - Accessor returning droppable collection options
|
|
75
102
|
* @returns Droppable collection state object
|
|
76
103
|
*/
|
|
77
|
-
export declare function createDroppableCollectionState(
|
|
78
|
-
|
|
104
|
+
export declare function createDroppableCollectionState(
|
|
105
|
+
props: Accessor<DroppableCollectionStateOptions>,
|
|
106
|
+
): DroppableCollectionState;
|
|
107
|
+
//# sourceMappingURL=createDroppableCollectionState.d.ts.map
|