@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.
Files changed (242) hide show
  1. package/README.md +30 -283
  2. package/dist/autocomplete/createAutocompleteState.d.ts +2 -2
  3. package/dist/autocomplete/index.d.ts +1 -1
  4. package/dist/calendar/createCalendarState.d.ts +22 -7
  5. package/dist/calendar/createDateFieldState.d.ts +30 -7
  6. package/dist/calendar/createDatePickerState.d.ts +60 -0
  7. package/dist/calendar/createRangeCalendarState.d.ts +27 -8
  8. package/dist/calendar/createTimeFieldState.d.ts +34 -7
  9. package/dist/calendar/index.d.ts +7 -6
  10. package/dist/checkbox/createCheckboxGroupState.d.ts +6 -6
  11. package/dist/checkbox/index.d.ts +1 -1
  12. package/dist/collections/ListCollection.d.ts +1 -1
  13. package/dist/collections/createListState.d.ts +8 -8
  14. package/dist/collections/createMenuState.d.ts +7 -7
  15. package/dist/collections/createSelectionState.d.ts +5 -5
  16. package/dist/collections/index.d.ts +5 -5
  17. package/dist/collections/types.d.ts +12 -12
  18. package/dist/color/Color.d.ts +1 -1
  19. package/dist/color/createColorAreaState.d.ts +4 -2
  20. package/dist/color/createColorFieldState.d.ts +38 -12
  21. package/dist/color/createColorSliderState.d.ts +9 -2
  22. package/dist/color/createColorWheelState.d.ts +13 -2
  23. package/dist/color/getColorChannels.d.ts +1 -1
  24. package/dist/color/index.d.ts +6 -6
  25. package/dist/color/types.d.ts +4 -4
  26. package/dist/combobox/createComboBoxState.d.ts +27 -13
  27. package/dist/combobox/index.d.ts +1 -1
  28. package/dist/data/createAsyncList.d.ts +4 -4
  29. package/dist/data/createListData.d.ts +2 -2
  30. package/dist/data/createTreeData.d.ts +6 -2
  31. package/dist/data/index.d.ts +3 -3
  32. package/dist/datepicker/index.d.ts +2 -4
  33. package/dist/disclosure/createDisclosureState.d.ts +2 -2
  34. package/dist/disclosure/index.d.ts +1 -1
  35. package/dist/dnd/createDragState.d.ts +2 -2
  36. package/dist/dnd/createDraggableCollectionState.d.ts +2 -2
  37. package/dist/dnd/createDropState.d.ts +2 -2
  38. package/dist/dnd/createDroppableCollectionState.d.ts +3 -3
  39. package/dist/dnd/index.d.ts +5 -5
  40. package/dist/dnd/types.d.ts +16 -16
  41. package/dist/form/createFormValidationState.d.ts +3 -3
  42. package/dist/form/index.d.ts +1 -1
  43. package/dist/grid/createGridState.d.ts +2 -2
  44. package/dist/grid/index.d.ts +2 -2
  45. package/dist/grid/types.d.ts +13 -11
  46. package/dist/index.d.ts +31 -30
  47. package/dist/index.js +7924 -7238
  48. package/dist/index.js.map +1 -1
  49. package/dist/menu/index.d.ts +2 -2
  50. package/dist/numberfield/createNumberFieldState.d.ts +2 -2
  51. package/dist/numberfield/index.d.ts +1 -1
  52. package/dist/overlays/createOverlayTriggerState.d.ts +2 -2
  53. package/dist/overlays/index.d.ts +1 -1
  54. package/dist/radio/createRadioGroupState.d.ts +7 -7
  55. package/dist/radio/index.d.ts +1 -1
  56. package/dist/searchfield/createSearchFieldState.d.ts +2 -2
  57. package/dist/searchfield/index.d.ts +2 -2
  58. package/dist/select/createSelectState.d.ts +8 -8
  59. package/dist/select/index.d.ts +1 -1
  60. package/dist/selection/index.d.ts +5 -5
  61. package/dist/slider/createSliderState.d.ts +3 -3
  62. package/dist/slider/index.d.ts +2 -2
  63. package/dist/steplist/createStepListState.d.ts +48 -0
  64. package/dist/steplist/index.d.ts +1 -0
  65. package/dist/table/TableCollection.d.ts +3 -3
  66. package/dist/table/createTableColumnResizeState.d.ts +54 -0
  67. package/dist/table/createTableState.d.ts +2 -2
  68. package/dist/table/index.d.ts +5 -3
  69. package/dist/table/types.d.ts +10 -10
  70. package/dist/tabs/createTabListState.d.ts +5 -5
  71. package/dist/tabs/index.d.ts +1 -1
  72. package/dist/textfield/createTextFieldState.d.ts +2 -2
  73. package/dist/textfield/index.d.ts +1 -1
  74. package/dist/toast/createToastState.d.ts +8 -2
  75. package/dist/toast/index.d.ts +1 -1
  76. package/dist/toggle/createToggleGroupState.d.ts +4 -4
  77. package/dist/toggle/createToggleState.d.ts +2 -2
  78. package/dist/toggle/index.d.ts +2 -2
  79. package/dist/tooltip/createTooltipTriggerState.d.ts +2 -2
  80. package/dist/tooltip/index.d.ts +1 -1
  81. package/dist/tree/TreeCollection.d.ts +2 -2
  82. package/dist/tree/createTreeState.d.ts +2 -2
  83. package/dist/tree/index.d.ts +3 -3
  84. package/dist/tree/types.d.ts +19 -13
  85. package/dist/utils/index.d.ts +1 -1
  86. package/dist/utils/reactivity.d.ts +1 -1
  87. package/package.json +29 -30
  88. package/src/autocomplete/createAutocompleteState.d.ts +19 -17
  89. package/src/autocomplete/createAutocompleteState.ts +24 -30
  90. package/src/autocomplete/index.d.ts +6 -2
  91. package/src/autocomplete/index.ts +1 -1
  92. package/src/calendar/createCalendarState.d.ts +139 -117
  93. package/src/calendar/createCalendarState.ts +221 -74
  94. package/src/calendar/createDateFieldState.d.ts +130 -95
  95. package/src/calendar/createDateFieldState.ts +263 -151
  96. package/src/calendar/createDatePickerState.ts +347 -0
  97. package/src/calendar/createRangeCalendarState.d.ts +154 -129
  98. package/src/calendar/createRangeCalendarState.ts +293 -79
  99. package/src/calendar/createTimeFieldState.d.ts +81 -79
  100. package/src/calendar/createTimeFieldState.ts +187 -108
  101. package/src/calendar/index.d.ts +80 -7
  102. package/src/calendar/index.ts +21 -12
  103. package/src/checkbox/createCheckboxGroupState.d.ts +57 -55
  104. package/src/checkbox/createCheckboxGroupState.ts +20 -29
  105. package/src/checkbox/index.d.ts +6 -2
  106. package/src/checkbox/index.ts +1 -1
  107. package/src/collections/ListCollection.d.ts +25 -22
  108. package/src/collections/ListCollection.ts +6 -6
  109. package/src/collections/createListState.d.ts +73 -58
  110. package/src/collections/createListState.ts +19 -18
  111. package/src/collections/createMenuState.d.ts +36 -31
  112. package/src/collections/createMenuState.ts +18 -12
  113. package/src/collections/createSelectionState.d.ts +78 -65
  114. package/src/collections/createSelectionState.ts +36 -32
  115. package/src/collections/index.d.ts +38 -6
  116. package/src/collections/index.ts +5 -10
  117. package/src/collections/types.d.ts +101 -101
  118. package/src/collections/types.ts +12 -12
  119. package/src/color/Color.d.ts +20 -5
  120. package/src/color/Color.ts +357 -254
  121. package/src/color/createColorAreaState.d.ts +67 -65
  122. package/src/color/createColorAreaState.ts +21 -13
  123. package/src/color/createColorFieldState.d.ts +46 -44
  124. package/src/color/createColorFieldState.ts +285 -149
  125. package/src/color/createColorSliderState.d.ts +58 -56
  126. package/src/color/createColorSliderState.ts +45 -14
  127. package/src/color/createColorWheelState.d.ts +42 -40
  128. package/src/color/createColorWheelState.ts +101 -64
  129. package/src/color/getColorChannels.ts +7 -5
  130. package/src/color/index.d.ts +36 -7
  131. package/src/color/index.ts +6 -9
  132. package/src/color/types.d.ts +68 -63
  133. package/src/color/types.ts +11 -19
  134. package/src/combobox/createComboBoxState.d.ts +107 -105
  135. package/src/combobox/createComboBoxState.ts +176 -89
  136. package/src/combobox/index.d.ts +10 -2
  137. package/src/combobox/index.ts +1 -1
  138. package/src/data/createAsyncList.ts +89 -63
  139. package/src/data/createListData.ts +67 -67
  140. package/src/data/createTreeData.ts +304 -91
  141. package/src/data/index.ts +3 -3
  142. package/src/datepicker/index.ts +6 -10
  143. package/src/disclosure/createDisclosureState.d.ts +47 -43
  144. package/src/disclosure/createDisclosureState.ts +7 -21
  145. package/src/disclosure/index.d.ts +10 -2
  146. package/src/disclosure/index.ts +1 -1
  147. package/src/dnd/createDragState.d.ts +51 -42
  148. package/src/dnd/createDragState.ts +12 -14
  149. package/src/dnd/createDraggableCollectionState.d.ts +52 -41
  150. package/src/dnd/createDraggableCollectionState.ts +14 -21
  151. package/src/dnd/createDropState.d.ts +64 -45
  152. package/src/dnd/createDropState.ts +22 -32
  153. package/src/dnd/createDroppableCollectionState.d.ts +88 -59
  154. package/src/dnd/createDroppableCollectionState.ts +40 -43
  155. package/src/dnd/index.d.ts +54 -6
  156. package/src/dnd/index.ts +5 -18
  157. package/src/dnd/types.d.ts +167 -156
  158. package/src/dnd/types.ts +20 -21
  159. package/src/form/createFormValidationState.d.ts +47 -45
  160. package/src/form/createFormValidationState.ts +30 -63
  161. package/src/form/index.d.ts +16 -2
  162. package/src/form/index.ts +1 -1
  163. package/src/grid/createGridState.d.ts +7 -4
  164. package/src/grid/createGridState.ts +44 -51
  165. package/src/grid/index.d.ts +3 -3
  166. package/src/grid/index.ts +2 -8
  167. package/src/grid/types.d.ts +136 -129
  168. package/src/grid/types.ts +20 -18
  169. package/src/index.d.ts +310 -26
  170. package/src/index.ts +48 -89
  171. package/src/menu/index.ts +2 -4
  172. package/src/numberfield/createNumberFieldState.d.ts +56 -54
  173. package/src/numberfield/createNumberFieldState.ts +26 -31
  174. package/src/numberfield/index.d.ts +6 -2
  175. package/src/numberfield/index.ts +1 -1
  176. package/src/overlays/createOverlayTriggerState.d.ts +22 -20
  177. package/src/overlays/createOverlayTriggerState.ts +3 -4
  178. package/src/overlays/index.d.ts +6 -2
  179. package/src/overlays/index.ts +1 -1
  180. package/src/radio/createRadioGroupState.d.ts +54 -52
  181. package/src/radio/createRadioGroupState.ts +27 -29
  182. package/src/radio/index.d.ts +7 -2
  183. package/src/radio/index.ts +1 -1
  184. package/src/searchfield/createSearchFieldState.d.ts +16 -14
  185. package/src/searchfield/createSearchFieldState.ts +5 -11
  186. package/src/searchfield/index.d.ts +3 -3
  187. package/src/searchfield/index.ts +2 -5
  188. package/src/select/createSelectState.d.ts +63 -61
  189. package/src/select/createSelectState.ts +27 -27
  190. package/src/select/index.d.ts +2 -2
  191. package/src/select/index.ts +1 -5
  192. package/src/selection/index.ts +6 -7
  193. package/src/slider/createSliderState.d.ts +60 -60
  194. package/src/slider/createSliderState.ts +55 -33
  195. package/src/slider/index.d.ts +3 -3
  196. package/src/slider/index.ts +2 -6
  197. package/src/ssr/index.d.ts +1 -1
  198. package/src/ssr/index.ts +2 -2
  199. package/src/steplist/createStepListState.ts +191 -0
  200. package/src/steplist/index.ts +5 -0
  201. package/src/table/TableCollection.d.ts +42 -40
  202. package/src/table/TableCollection.ts +61 -64
  203. package/src/table/createTableColumnResizeState.ts +242 -0
  204. package/src/table/createTableState.d.ts +7 -4
  205. package/src/table/createTableState.ts +10 -7
  206. package/src/table/index.d.ts +14 -4
  207. package/src/table/index.ts +10 -3
  208. package/src/table/types.d.ts +98 -92
  209. package/src/table/types.ts +17 -13
  210. package/src/tabs/createTabListState.d.ts +59 -57
  211. package/src/tabs/createTabListState.ts +24 -31
  212. package/src/tabs/index.d.ts +8 -2
  213. package/src/tabs/index.ts +1 -1
  214. package/src/textfield/createTextFieldState.d.ts +16 -14
  215. package/src/textfield/createTextFieldState.ts +7 -18
  216. package/src/textfield/index.d.ts +6 -2
  217. package/src/textfield/index.ts +1 -1
  218. package/src/toast/createToastState.d.ts +92 -86
  219. package/src/toast/createToastState.ts +48 -43
  220. package/src/toast/index.d.ts +12 -2
  221. package/src/toast/index.ts +1 -1
  222. package/src/toggle/createToggleGroupState.ts +11 -21
  223. package/src/toggle/createToggleState.d.ts +19 -19
  224. package/src/toggle/createToggleState.ts +2 -16
  225. package/src/toggle/index.d.ts +2 -2
  226. package/src/toggle/index.ts +2 -6
  227. package/src/tooltip/createTooltipTriggerState.d.ts +17 -17
  228. package/src/tooltip/createTooltipTriggerState.ts +12 -11
  229. package/src/tooltip/index.d.ts +7 -2
  230. package/src/tooltip/index.ts +1 -1
  231. package/src/tree/TreeCollection.d.ts +26 -23
  232. package/src/tree/TreeCollection.ts +29 -22
  233. package/src/tree/createTreeState.d.ts +7 -4
  234. package/src/tree/createTreeState.ts +39 -41
  235. package/src/tree/index.d.ts +10 -4
  236. package/src/tree/index.ts +3 -3
  237. package/src/tree/types.d.ts +131 -126
  238. package/src/tree/types.ts +22 -13
  239. package/src/utils/index.d.ts +2 -2
  240. package/src/utils/index.ts +1 -1
  241. package/src/utils/reactivity.d.ts +2 -2
  242. 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 'solid-js';
7
- import type { DropItem, DropEnterEvent, DropMoveEvent, DropExitEvent, DropActivateEvent, DropEvent, DropOperation, DragTypes } from './types';
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
- * A function returning the drop operation to be performed.
11
- */
12
- getDropOperation?: (types: DragTypes, allowedOperations: DropOperation[]) => DropOperation;
13
- /**
14
- * A function returning the drop operation for a specific point.
15
- */
16
- getDropOperationForPoint?: (types: DragTypes, allowedOperations: DropOperation[], x: number, y: number) => DropOperation;
17
- /** Handler that is called when a valid drag enters the drop target. */
18
- onDropEnter?: (e: DropEnterEvent) => void;
19
- /** Handler that is called when a valid drag is moved within the drop target. */
20
- onDropMove?: (e: DropMoveEvent) => void;
21
- /** Handler that is called after a valid drag is held over the drop target. */
22
- onDropActivate?: (e: DropActivateEvent) => void;
23
- /** Handler that is called when a valid drag exits the drop target. */
24
- onDropExit?: (e: DropExitEvent) => void;
25
- /** Handler that is called when a valid drag is dropped on the drop target. */
26
- onDrop?: (e: DropEvent) => void;
27
- /** Whether there is a separate drop button affordance. */
28
- hasDropButton?: boolean;
29
- /** Whether the drop target is disabled. */
30
- isDisabled?: boolean;
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
- /** Whether the drop target is currently being hovered or focused. */
34
- readonly isDropTarget: boolean;
35
- /** Whether the drop target is disabled. */
36
- readonly isDisabled: boolean;
37
- /** Whether there is a drop button. */
38
- readonly hasDropButton: boolean;
39
- /** Enter the drop target. */
40
- enterTarget(x: number, y: number): void;
41
- /** Move within the drop target. */
42
- moveInTarget(x: number, y: number): void;
43
- /** Exit the drop target. */
44
- exitTarget(x: number, y: number): void;
45
- /** Activate the drop target (after holding). */
46
- activateTarget(x: number, y: number): void;
47
- /** Perform a drop on the target. */
48
- drop(x: number, y: number, items: DropItem[], dropOperation: DropOperation): void;
49
- /** Get the drop operation for given types. */
50
- getDropOperation(types: DragTypes, allowedOperations: DropOperation[]): DropOperation;
51
- /** Get the drop operation for a specific point. */
52
- getDropOperationForPoint(types: DragTypes, allowedOperations: DropOperation[], x: number, y: number): DropOperation;
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 'solid-js';
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 './types';
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 === 'function') {
94
+ if (typeof p.onDropEnter === "function") {
100
95
  p.onDropEnter({
101
- type: 'dropenter',
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 === 'function') {
107
+ if (typeof p.onDropMove === "function") {
113
108
  p.onDropMove({
114
- type: 'dropmove',
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 === 'function') {
121
+ if (typeof p.onDropExit === "function") {
127
122
  p.onDropExit({
128
- type: 'dropexit',
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 === 'function') {
134
+ if (typeof p.onDropActivate === "function") {
140
135
  p.onDropActivate({
141
- type: 'dropactivate',
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 === 'function') {
149
+ if (typeof p.onDrop === "function") {
160
150
  p.onDrop({
161
- type: 'drop',
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 === 'function') {
165
+ if (typeof p.getDropOperation === "function") {
176
166
  return p.getDropOperation(types, allowedOperations);
177
167
  }
178
- return allowedOperations[0] ?? 'cancel';
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 === 'function') {
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 'solid-js';
7
- import type { DropItem, DropTarget, DropOperation, DragTypes, DroppableCollectionEnterEvent, DroppableCollectionActivateEvent, DroppableCollectionExitEvent, DroppableCollectionDropEvent, DroppableCollectionInsertDropEvent, DroppableCollectionRootDropEvent, DroppableCollectionOnItemDropEvent, DroppableCollectionReorderEvent, ItemDropTarget } from './types';
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
- * The drag types that the droppable collection accepts.
11
- * @default 'all'
12
- */
13
- acceptedDragTypes?: 'all' | Array<string | symbol>;
14
- /**
15
- * A function returning the drop operation to be performed.
16
- */
17
- getDropOperation?: (target: DropTarget, types: DragTypes, allowedOperations: DropOperation[]) => DropOperation;
18
- /** Handler that is called when a valid drag enters a drop target. */
19
- onDropEnter?: (e: DroppableCollectionEnterEvent) => void;
20
- /** Handler that is called after a valid drag is held over a drop target. */
21
- onDropActivate?: (e: DroppableCollectionActivateEvent) => void;
22
- /** Handler that is called when a valid drag exits a drop target. */
23
- onDropExit?: (e: DroppableCollectionExitEvent) => void;
24
- /** Handler that is called when a valid drag is dropped. */
25
- onDrop?: (e: DroppableCollectionDropEvent) => void;
26
- /** Handler that is called when external items are dropped "between" items. */
27
- onInsert?: (e: DroppableCollectionInsertDropEvent) => void;
28
- /** Handler that is called when external items are dropped on the collection's root. */
29
- onRootDrop?: (e: DroppableCollectionRootDropEvent) => void;
30
- /** Handler that is called when items are dropped "on" an item. */
31
- onItemDrop?: (e: DroppableCollectionOnItemDropEvent) => void;
32
- /** Handler that is called when items are reordered within the collection. */
33
- onReorder?: (e: DroppableCollectionReorderEvent) => void;
34
- /** Handler that is called when items are moved within the source collection. */
35
- onMove?: (e: DroppableCollectionReorderEvent) => void;
36
- /** A function returning whether a given target is a valid "on" drop target. */
37
- shouldAcceptItemDrop?: (target: ItemDropTarget, types: DragTypes) => boolean;
38
- /** Whether the droppable collection is disabled. */
39
- isDisabled?: boolean;
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
- /** Whether a drag is currently over the collection. */
43
- readonly isDropTarget: boolean;
44
- /** The current drop target within the collection. */
45
- readonly target: DropTarget | null;
46
- /** Whether the collection is disabled for drops. */
47
- readonly isDisabled: boolean;
48
- /** Set the current drop target. */
49
- setTarget(target: DropTarget | null): void;
50
- /** Check if a drag type is accepted. */
51
- isAccepted(types: DragTypes): boolean;
52
- /** Enter the collection with a drop target. */
53
- enterTarget(target: DropTarget, x: number, y: number): void;
54
- /** Move to a new target within the collection. */
55
- moveToTarget(target: DropTarget, x: number, y: number): void;
56
- /** Exit the collection. */
57
- exitTarget(x: number, y: number): void;
58
- /** Activate the current target. */
59
- activateTarget(x: number, y: number): void;
60
- /** Perform a drop on the collection. */
61
- drop(items: DropItem[], dropOperation: DropOperation, isInternal: boolean, draggingKeys?: Set<string | number>): void;
62
- /** Get the drop operation for a target. */
63
- getDropOperation(target: DropTarget, types: DragTypes, allowedOperations: DropOperation[]): DropOperation;
64
- /** Check if an item drop should be accepted. */
65
- shouldAcceptItemDrop(target: ItemDropTarget, types: DragTypes): boolean;
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(props: Accessor<DroppableCollectionStateOptions>): DroppableCollectionState;
78
- //# sourceMappingURL=createDroppableCollectionState.d.ts.map
104
+ export declare function createDroppableCollectionState(
105
+ props: Accessor<DroppableCollectionStateOptions>,
106
+ ): DroppableCollectionState;
107
+ //# sourceMappingURL=createDroppableCollectionState.d.ts.map