@hkdigital/lib-core 0.4.65 → 0.4.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui/components/drag-drop/DropZone.svelte +90 -10
- package/dist/ui/components/drag-drop/DropZone.svelte.d.ts +4 -2
- package/dist/ui/components/drag-drop/DropZoneArea.svelte +4 -1
- package/dist/ui/components/drag-drop/DropZoneArea.svelte.d.ts +10 -2
- package/dist/ui/components/drag-drop/DropZoneList.svelte +4 -1
- package/dist/ui/components/drag-drop/DropZoneList.svelte.d.ts +10 -2
- package/dist/ui/components/drag-drop/typedef/drag.d.ts +4 -0
- package/dist/ui/components/drag-drop/typedef/drag.js +1 -0
- package/package.json +1 -1
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
* zone?: string,
|
|
19
19
|
* group?: string,
|
|
20
20
|
* disabled?: boolean,
|
|
21
|
-
* accepts?: (dragData:
|
|
21
|
+
* accepts?: (dragData: DragData, target: { zone:string, group: string }) => boolean,
|
|
22
|
+
* enableDebug?: boolean,
|
|
22
23
|
* base?: string,
|
|
23
24
|
* classes?: string,
|
|
24
25
|
* minHeight?: string,
|
|
@@ -63,6 +64,7 @@
|
|
|
63
64
|
group = 'default',
|
|
64
65
|
disabled = false,
|
|
65
66
|
accepts = () => true,
|
|
67
|
+
enableDebug = false,
|
|
66
68
|
base = '',
|
|
67
69
|
classes = '',
|
|
68
70
|
minHeight = '',
|
|
@@ -86,7 +88,9 @@
|
|
|
86
88
|
const dropZoneId = generateLocalId();
|
|
87
89
|
|
|
88
90
|
let currentState = $state(READY);
|
|
89
|
-
|
|
91
|
+
|
|
92
|
+
/** @type {HTMLElement|undefined} */
|
|
93
|
+
let dropZoneElement = $state();
|
|
90
94
|
|
|
91
95
|
// Computed height classes based on mode
|
|
92
96
|
let heightClasses = $derived.by(() => {
|
|
@@ -137,24 +141,91 @@
|
|
|
137
141
|
dragState.registerDropZone(dropZoneId, {
|
|
138
142
|
zone,
|
|
139
143
|
group,
|
|
140
|
-
accepts: (dragData) => {
|
|
141
|
-
if (
|
|
142
|
-
|
|
144
|
+
accepts: (/** @type {DragData} */ dragData) => {
|
|
145
|
+
if (enableDebug) {
|
|
146
|
+
console.debug(
|
|
147
|
+
`[DropZone] accepts() called for zone="${zone}", group="${group}"`,
|
|
148
|
+
{
|
|
149
|
+
disabled,
|
|
150
|
+
dragData: dragData
|
|
151
|
+
? {
|
|
152
|
+
group: dragData.group,
|
|
153
|
+
source: dragData.source,
|
|
154
|
+
item: dragData.item
|
|
155
|
+
}
|
|
156
|
+
: null
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (disabled) {
|
|
162
|
+
if (enableDebug) console.debug(`[DropZone] Rejected: disabled`);
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
if (!dragData) {
|
|
166
|
+
if (enableDebug) console.debug(`[DropZone] Rejected: no dragData`);
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const result = accepts(dragData, { zone, group });
|
|
171
|
+
|
|
172
|
+
if (enableDebug) {
|
|
173
|
+
console.debug(`[DropZone] User accepts() result: ${result}`, {
|
|
174
|
+
dragGroup: dragData.group,
|
|
175
|
+
targetGroup: group,
|
|
176
|
+
groupsMatch: dragData.group === group
|
|
177
|
+
});
|
|
178
|
+
}
|
|
143
179
|
|
|
144
|
-
return
|
|
180
|
+
return result;
|
|
145
181
|
},
|
|
146
|
-
onDragEnter: (
|
|
182
|
+
onDragEnter: (
|
|
183
|
+
/** @type {{ event: DragEvent, zone: string, canDrop: boolean }} */ detail
|
|
184
|
+
) => {
|
|
185
|
+
if (enableDebug) {
|
|
186
|
+
console.debug(
|
|
187
|
+
`[DropZone] onDragEnter zone="${zone}", group="${group}"`,
|
|
188
|
+
{
|
|
189
|
+
canDrop: detail.canDrop,
|
|
190
|
+
newState: detail.canDrop ? 'CAN_DROP' : 'CANNOT_DROP'
|
|
191
|
+
}
|
|
192
|
+
);
|
|
193
|
+
}
|
|
147
194
|
currentState = detail.canDrop ? CAN_DROP : CANNOT_DROP;
|
|
148
195
|
onDragEnter?.(detail);
|
|
149
196
|
},
|
|
150
|
-
onDragOver: (
|
|
197
|
+
onDragOver: (
|
|
198
|
+
/** @type {{ event: DragEvent, zone: string }} */ detail
|
|
199
|
+
) => {
|
|
151
200
|
onDragOver?.(detail);
|
|
152
201
|
},
|
|
153
|
-
onDragLeave: (
|
|
202
|
+
onDragLeave: (
|
|
203
|
+
/** @type {{ event: DragEvent, zone: string }} */ detail
|
|
204
|
+
) => {
|
|
205
|
+
if (enableDebug) {
|
|
206
|
+
console.debug(
|
|
207
|
+
`[DropZone] onDragLeave zone="${zone}", group="${group}"`
|
|
208
|
+
);
|
|
209
|
+
}
|
|
154
210
|
currentState = READY;
|
|
155
211
|
onDragLeave?.(detail);
|
|
156
212
|
},
|
|
157
213
|
onDrop: async (dropData) => {
|
|
214
|
+
if (enableDebug) {
|
|
215
|
+
console.debug(
|
|
216
|
+
`[DropZone] onDrop zone="${zone}", group="${group}"`,
|
|
217
|
+
{
|
|
218
|
+
dropData: {
|
|
219
|
+
zone: dropData.zone,
|
|
220
|
+
source: dropData.source,
|
|
221
|
+
item: dropData.item,
|
|
222
|
+
x: dropData.x,
|
|
223
|
+
y: dropData.y
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
158
229
|
currentState = READY;
|
|
159
230
|
|
|
160
231
|
try {
|
|
@@ -166,6 +237,10 @@
|
|
|
166
237
|
|
|
167
238
|
const result = await onDrop?.(dropData);
|
|
168
239
|
|
|
240
|
+
if (enableDebug) {
|
|
241
|
+
console.debug(`[DropZone] onDrop completed successfully`);
|
|
242
|
+
}
|
|
243
|
+
|
|
169
244
|
onDropEnd?.({
|
|
170
245
|
event: dropData.drop.event,
|
|
171
246
|
zone: dropData.zone,
|
|
@@ -175,13 +250,18 @@
|
|
|
175
250
|
|
|
176
251
|
return result;
|
|
177
252
|
} catch (error) {
|
|
253
|
+
if (enableDebug) {
|
|
254
|
+
console.debug(`[DropZone] onDrop failed:`, error);
|
|
255
|
+
}
|
|
256
|
+
|
|
178
257
|
onDropEnd?.({
|
|
179
258
|
event: dropData.drop.event,
|
|
180
259
|
zone: dropData.zone,
|
|
181
260
|
data: dropData.drag,
|
|
182
261
|
success: false,
|
|
183
|
-
error
|
|
262
|
+
error: /** @type {Error} */ (error)
|
|
184
263
|
});
|
|
264
|
+
|
|
185
265
|
throw error;
|
|
186
266
|
}
|
|
187
267
|
},
|
|
@@ -6,10 +6,11 @@ type DropZone = {
|
|
|
6
6
|
zone?: string | undefined;
|
|
7
7
|
group?: string | undefined;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
|
-
accepts?: ((dragData:
|
|
9
|
+
accepts?: ((dragData: DragData, target: {
|
|
10
10
|
zone: string;
|
|
11
11
|
group: string;
|
|
12
12
|
}) => boolean) | undefined;
|
|
13
|
+
enableDebug?: boolean | undefined;
|
|
13
14
|
base?: string | undefined;
|
|
14
15
|
classes?: string | undefined;
|
|
15
16
|
minHeight?: string | undefined;
|
|
@@ -53,10 +54,11 @@ declare const DropZone: import("svelte").Component<{
|
|
|
53
54
|
zone?: string;
|
|
54
55
|
group?: string;
|
|
55
56
|
disabled?: boolean;
|
|
56
|
-
accepts?: (dragData:
|
|
57
|
+
accepts?: (dragData: import("../../typedef.js").DragData, target: {
|
|
57
58
|
zone: string;
|
|
58
59
|
group: string;
|
|
59
60
|
}) => boolean;
|
|
61
|
+
enableDebug?: boolean;
|
|
60
62
|
base?: string;
|
|
61
63
|
classes?: string;
|
|
62
64
|
minHeight?: string;
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* zone?: string,
|
|
7
7
|
* group?: string,
|
|
8
8
|
* disabled?: boolean,
|
|
9
|
-
* accepts?: (
|
|
9
|
+
* accepts?: (dragData: import('./typedef.js').DragData, target: { zone: string, group: string }) => boolean,
|
|
10
|
+
* enableDebug?: boolean,
|
|
10
11
|
* fillContainer?: boolean,
|
|
11
12
|
* aspectRatio?: string,
|
|
12
13
|
* overflow?: 'auto' | 'hidden' | 'visible' | 'scroll',
|
|
@@ -51,6 +52,7 @@
|
|
|
51
52
|
group = 'default',
|
|
52
53
|
disabled = false,
|
|
53
54
|
accepts = () => true,
|
|
55
|
+
enableDebug = false,
|
|
54
56
|
fillContainer = true,
|
|
55
57
|
aspectRatio = '',
|
|
56
58
|
overflow = 'hidden',
|
|
@@ -98,6 +100,7 @@
|
|
|
98
100
|
{group}
|
|
99
101
|
{disabled}
|
|
100
102
|
{accepts}
|
|
103
|
+
{enableDebug}
|
|
101
104
|
heightMode={fillContainer ? 'fill' : 'fixed'}
|
|
102
105
|
{base}
|
|
103
106
|
classes={combinedClasses}
|
|
@@ -6,7 +6,11 @@ type DropZoneArea = {
|
|
|
6
6
|
zone?: string | undefined;
|
|
7
7
|
group?: string | undefined;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
|
-
accepts?: ((
|
|
9
|
+
accepts?: ((dragData: DragData, target: {
|
|
10
|
+
zone: string;
|
|
11
|
+
group: string;
|
|
12
|
+
}) => boolean) | undefined;
|
|
13
|
+
enableDebug?: boolean | undefined;
|
|
10
14
|
fillContainer?: boolean | undefined;
|
|
11
15
|
aspectRatio?: string | undefined;
|
|
12
16
|
overflow?: "scroll" | "auto" | "hidden" | "visible" | undefined;
|
|
@@ -50,7 +54,11 @@ declare const DropZoneArea: import("svelte").Component<{
|
|
|
50
54
|
zone?: string;
|
|
51
55
|
group?: string;
|
|
52
56
|
disabled?: boolean;
|
|
53
|
-
accepts?: (
|
|
57
|
+
accepts?: (dragData: import("./typedef.js").DragData, target: {
|
|
58
|
+
zone: string;
|
|
59
|
+
group: string;
|
|
60
|
+
}) => boolean;
|
|
61
|
+
enableDebug?: boolean;
|
|
54
62
|
fillContainer?: boolean;
|
|
55
63
|
aspectRatio?: string;
|
|
56
64
|
overflow?: "auto" | "hidden" | "visible" | "scroll";
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* zone?: string,
|
|
7
7
|
* group?: string,
|
|
8
8
|
* disabled?: boolean,
|
|
9
|
-
* accepts?: (
|
|
9
|
+
* accepts?: (dragData: import('./typedef.js').DragData, target: { zone: string, group: string }) => boolean,
|
|
10
|
+
* enableDebug?: boolean,
|
|
10
11
|
* minHeight?: string,
|
|
11
12
|
* maxHeight?: string,
|
|
12
13
|
* gap?: string,
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
group = 'default',
|
|
53
54
|
disabled = false,
|
|
54
55
|
accepts = () => true,
|
|
56
|
+
enableDebug = false,
|
|
55
57
|
minHeight = 'min-h-[200px]',
|
|
56
58
|
maxHeight = '',
|
|
57
59
|
gap = 'gap-2',
|
|
@@ -102,6 +104,7 @@
|
|
|
102
104
|
{group}
|
|
103
105
|
{disabled}
|
|
104
106
|
{accepts}
|
|
107
|
+
{enableDebug}
|
|
105
108
|
{minHeight}
|
|
106
109
|
{maxHeight}
|
|
107
110
|
heightMode="flexible"
|
|
@@ -6,7 +6,11 @@ type DropZoneList = {
|
|
|
6
6
|
zone?: string | undefined;
|
|
7
7
|
group?: string | undefined;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
|
-
accepts?: ((
|
|
9
|
+
accepts?: ((dragData: DragData, target: {
|
|
10
|
+
zone: string;
|
|
11
|
+
group: string;
|
|
12
|
+
}) => boolean) | undefined;
|
|
13
|
+
enableDebug?: boolean | undefined;
|
|
10
14
|
minHeight?: string | undefined;
|
|
11
15
|
maxHeight?: string | undefined;
|
|
12
16
|
gap?: string | undefined;
|
|
@@ -51,7 +55,11 @@ declare const DropZoneList: import("svelte").Component<{
|
|
|
51
55
|
zone?: string;
|
|
52
56
|
group?: string;
|
|
53
57
|
disabled?: boolean;
|
|
54
|
-
accepts?: (
|
|
58
|
+
accepts?: (dragData: import("./typedef.js").DragData, target: {
|
|
59
|
+
zone: string;
|
|
60
|
+
group: string;
|
|
61
|
+
}) => boolean;
|
|
62
|
+
enableDebug?: boolean;
|
|
55
63
|
minHeight?: string;
|
|
56
64
|
maxHeight?: string;
|
|
57
65
|
gap?: string;
|
|
@@ -12,6 +12,10 @@ export type DragData = {
|
|
|
12
12
|
* - Source identifier
|
|
13
13
|
*/
|
|
14
14
|
source?: string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* - Group identifier
|
|
17
|
+
*/
|
|
18
|
+
group?: string | undefined;
|
|
15
19
|
};
|
|
16
20
|
export type SimulatedDragEvent = {
|
|
17
21
|
type: "dragstart" | "dragover" | "dragleave" | "drop" | "dragend";
|