@hkdigital/lib-sveltekit 0.1.76 → 0.1.78
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/assets/autospuiten/car-paint-picker.d.ts +7 -7
- package/dist/components/drag-drop/DragDropContext.svelte +26 -0
- package/dist/components/drag-drop/DragDropContext.svelte.d.ts +18 -0
- package/dist/components/drag-drop/Draggable.svelte +227 -0
- package/dist/components/drag-drop/Draggable.svelte.d.ts +76 -0
- package/dist/components/drag-drop/DropZone.svelte +377 -0
- package/dist/components/drag-drop/DropZone.svelte.d.ts +114 -0
- package/dist/components/drag-drop/drag-state.svelte.d.ts +30 -0
- package/dist/components/drag-drop/drag-state.svelte.js +50 -0
- package/dist/components/drag-drop/index.d.ts +4 -0
- package/dist/components/drag-drop/index.js +5 -0
- package/dist/components/drag-drop/util.d.ts +32 -0
- package/dist/components/drag-drop/util.js +85 -0
- package/dist/components/tab-bar/HkTabBar.state.svelte.d.ts +4 -4
- package/dist/components/tab-bar/HkTabBar.svelte +3 -3
- package/dist/components/tab-bar/HkTabBar.svelte.d.ts +2 -2
- package/dist/components/tab-bar/HkTabBarSelector.state.svelte.d.ts +3 -3
- package/dist/components/tab-bar/HkTabBarSelector.svelte +3 -3
- package/dist/components/tab-bar/HkTabBarSelector.svelte.d.ts +2 -2
- package/dist/components/tab-bar/index.d.ts +1 -0
- package/dist/components/tab-bar/typedef.d.ts +3 -1
- package/dist/components/tab-bar/typedef.js +3 -0
- package/dist/constants/state-labels/drag-states.d.ts +5 -0
- package/dist/constants/state-labels/drag-states.js +6 -0
- package/dist/constants/state-labels/drop-states.d.ts +6 -0
- package/dist/constants/state-labels/drop-states.js +6 -0
- package/dist/themes/hkdev/components/drag-drop/draggable.css +51 -0
- package/dist/themes/hkdev/components/drag-drop/dropzone.css +73 -0
- package/dist/themes/hkdev/components.css +6 -0
- package/dist/typedef/context.d.ts +3 -0
- package/dist/typedef/context.js +6 -0
- package/dist/typedef/drag.d.ts +20 -0
- package/dist/typedef/drag.js +9 -0
- package/dist/typedef/drop.d.ts +20 -0
- package/dist/typedef/drop.js +9 -0
- package/dist/typedef/{image-meta.js → image.js} +0 -1
- package/dist/typedef/index.d.ts +4 -1
- package/dist/typedef/index.js +4 -1
- package/dist/util/geo/index.d.ts +10 -0
- package/dist/util/geo/index.js +26 -0
- package/dist/util/svelte/state-context/index.d.ts +2 -1
- package/dist/util/svelte/state-context/index.js +46 -12
- package/dist/widgets/game-box/GameBox.svelte +1 -0
- package/dist/widgets/hk-app-layout/HkAppLayout.state.svelte.d.ts +3 -3
- package/dist/widgets/image-box/ImageBox.svelte +2 -4
- package/package.json +3 -1
- /package/dist/typedef/{image-meta.d.ts → image.d.ts} +0 -0
@@ -1,11 +1,11 @@
|
|
1
1
|
export const carPaintImages: {
|
2
|
-
rusty: import("../../typedef/image
|
3
|
-
"army-green": import("../../typedef/image
|
4
|
-
"electric-blue": import("../../typedef/image
|
5
|
-
"lemon-yellow": import("../../typedef/image
|
6
|
-
"opaque-purple": import("../../typedef/image
|
7
|
-
"sunset-orange": import("../../typedef/image
|
8
|
-
"tomato-red": import("../../typedef/image
|
2
|
+
rusty: import("../../typedef/image.js").ImageMeta[];
|
3
|
+
"army-green": import("../../typedef/image.js").ImageMeta[];
|
4
|
+
"electric-blue": import("../../typedef/image.js").ImageMeta[];
|
5
|
+
"lemon-yellow": import("../../typedef/image.js").ImageMeta[];
|
6
|
+
"opaque-purple": import("../../typedef/image.js").ImageMeta[];
|
7
|
+
"sunset-orange": import("../../typedef/image.js").ImageMeta[];
|
8
|
+
"tomato-red": import("../../typedef/image.js").ImageMeta[];
|
9
9
|
};
|
10
10
|
import Rusty from './car-paint-picker/rusty.jpg?preset=render&responsive';
|
11
11
|
import ArmyGreen from './car-paint-picker/army-green.jpg?preset=render&responsive';
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<script>
|
2
|
+
import { createDragState } from './drag-state.svelte.js';
|
3
|
+
|
4
|
+
/**
|
5
|
+
* @type {{
|
6
|
+
* contextKey?: import('../../typedef').ContextKey,
|
7
|
+
* base?: string,
|
8
|
+
* classes?: string,
|
9
|
+
* children: import('svelte').Snippet,
|
10
|
+
* [key: string]: any
|
11
|
+
* }}
|
12
|
+
*/
|
13
|
+
let { contextKey, base = '', classes = '', children, ...attrs } = $props();
|
14
|
+
|
15
|
+
// Create the state context at this level to ensure all children
|
16
|
+
// have access to the same state instance
|
17
|
+
const dragState = createDragState(contextKey);
|
18
|
+
</script>
|
19
|
+
|
20
|
+
<div
|
21
|
+
data-component="drag-drop-context"
|
22
|
+
class="{base} {classes}"
|
23
|
+
{...attrs}
|
24
|
+
>
|
25
|
+
{@render children()}
|
26
|
+
</div>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
export default DragDropContext;
|
2
|
+
type DragDropContext = {
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
4
|
+
$set?(props: Partial<{
|
5
|
+
[key: string]: any;
|
6
|
+
contextKey?: ContextKey;
|
7
|
+
base?: string;
|
8
|
+
classes?: string;
|
9
|
+
children: Snippet<[]>;
|
10
|
+
}>): void;
|
11
|
+
};
|
12
|
+
declare const DragDropContext: import("svelte").Component<{
|
13
|
+
[key: string]: any;
|
14
|
+
contextKey?: import("../../typedef").ContextKey;
|
15
|
+
base?: string;
|
16
|
+
classes?: string;
|
17
|
+
children: import("svelte").Snippet;
|
18
|
+
}, {}, "">;
|
@@ -0,0 +1,227 @@
|
|
1
|
+
<script>
|
2
|
+
import { toStateClasses } from '../../util/design-system/index.js';
|
3
|
+
|
4
|
+
import { createOrGetDragState } from './drag-state.svelte.js';
|
5
|
+
|
6
|
+
import { generateLocalId } from '../../util/unique';
|
7
|
+
|
8
|
+
import {
|
9
|
+
IDLE,
|
10
|
+
DRAGGING,
|
11
|
+
DRAG_PREVIEW,
|
12
|
+
DROPPING,
|
13
|
+
DRAG_DISABLED
|
14
|
+
} from '../../constants/state-labels/drag-states.js';
|
15
|
+
|
16
|
+
/**
|
17
|
+
* @type {{
|
18
|
+
* item: any,
|
19
|
+
* group?: string,
|
20
|
+
* source?: string,
|
21
|
+
* disabled?: boolean,
|
22
|
+
* dragDelay?: number,
|
23
|
+
* base?: string,
|
24
|
+
* classes?: string,
|
25
|
+
* children: import('svelte').Snippet,
|
26
|
+
* contextKey?: import('../../typedef').ContextKey,
|
27
|
+
* isDragging?: boolean,
|
28
|
+
* isDropping?: boolean,
|
29
|
+
* isDragPreview?: boolean,
|
30
|
+
* onDragStart?: (detail: {
|
31
|
+
* event: DragEvent,
|
32
|
+
* item: any,
|
33
|
+
* source: string,
|
34
|
+
* group: string
|
35
|
+
* }) => void,
|
36
|
+
* onDragging?: (detail: {
|
37
|
+
* event: DragEvent,
|
38
|
+
* item: any
|
39
|
+
* }) => void,
|
40
|
+
* onDragEnd?: (detail: {
|
41
|
+
* event: DragEvent,
|
42
|
+
* item: any,
|
43
|
+
* wasDropped: boolean
|
44
|
+
* }) => void,
|
45
|
+
* onDrop?: (detail: {
|
46
|
+
* event: DragEvent,
|
47
|
+
* item: any,
|
48
|
+
* wasDropped: boolean
|
49
|
+
* }) => void,
|
50
|
+
* canDrag?: (item: any) => boolean,
|
51
|
+
* [key: string]: any
|
52
|
+
* }}
|
53
|
+
*/
|
54
|
+
let {
|
55
|
+
item,
|
56
|
+
group = 'default',
|
57
|
+
source = 'default',
|
58
|
+
disabled = false,
|
59
|
+
dragDelay = 0,
|
60
|
+
base = '',
|
61
|
+
classes = '',
|
62
|
+
children,
|
63
|
+
contextKey,
|
64
|
+
isDragging = $bindable(false),
|
65
|
+
isDropping = $bindable(false),
|
66
|
+
isDragPreview = $bindable(false),
|
67
|
+
onDragStart,
|
68
|
+
onDragging,
|
69
|
+
onDragEnd,
|
70
|
+
onDrop,
|
71
|
+
canDrag = () => true,
|
72
|
+
...attrs
|
73
|
+
} = $props();
|
74
|
+
|
75
|
+
const dragState = createOrGetDragState(contextKey);
|
76
|
+
|
77
|
+
const draggableId = generateLocalId();
|
78
|
+
|
79
|
+
// console.debug('Draggable contextKey:', contextKey);
|
80
|
+
|
81
|
+
let dragTimeout = null;
|
82
|
+
let currentState = $state(IDLE);
|
83
|
+
|
84
|
+
// Computed state object for CSS classes
|
85
|
+
let stateObject = $derived({
|
86
|
+
idle: currentState === IDLE,
|
87
|
+
dragging: currentState === DRAGGING,
|
88
|
+
'drag-preview': currentState === DRAG_PREVIEW,
|
89
|
+
dropping: currentState === DROPPING,
|
90
|
+
'drag-disabled': disabled || !canDrag(item)
|
91
|
+
});
|
92
|
+
|
93
|
+
let stateClasses = $derived(toStateClasses(stateObject));
|
94
|
+
|
95
|
+
// Update bindable props
|
96
|
+
$effect(() => {
|
97
|
+
isDragging = currentState === DRAGGING;
|
98
|
+
isDropping = currentState === DROPPING;
|
99
|
+
isDragPreview = currentState === DRAG_PREVIEW;
|
100
|
+
});
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Handle drag start
|
104
|
+
* @param {DragEvent} event
|
105
|
+
*/
|
106
|
+
function handleDragStart(event) {
|
107
|
+
if (disabled || !canDrag(item)) {
|
108
|
+
event.preventDefault();
|
109
|
+
return;
|
110
|
+
}
|
111
|
+
|
112
|
+
// Handle drag delay
|
113
|
+
if (dragDelay > 0) {
|
114
|
+
event.preventDefault();
|
115
|
+
currentState = DRAG_PREVIEW;
|
116
|
+
|
117
|
+
dragTimeout = setTimeout(() => {
|
118
|
+
currentState = DRAGGING;
|
119
|
+
startDrag(event);
|
120
|
+
}, dragDelay);
|
121
|
+
return;
|
122
|
+
}
|
123
|
+
|
124
|
+
currentState = DRAGGING;
|
125
|
+
startDrag(event);
|
126
|
+
}
|
127
|
+
|
128
|
+
/**
|
129
|
+
* Start the drag operation
|
130
|
+
* @param {DragEvent} event
|
131
|
+
*/
|
132
|
+
function startDrag(event) {
|
133
|
+
const dragData = {
|
134
|
+
item,
|
135
|
+
source,
|
136
|
+
group,
|
137
|
+
metadata: { timestamp: Date.now() }
|
138
|
+
};
|
139
|
+
|
140
|
+
// Set shared drag state
|
141
|
+
dragState.start(draggableId, dragData);
|
142
|
+
|
143
|
+
event.dataTransfer.effectAllowed = 'move';
|
144
|
+
event.dataTransfer.setData('application/json', JSON.stringify(dragData));
|
145
|
+
|
146
|
+
// Set custom drag image if needed
|
147
|
+
if (event.dataTransfer.setDragImage) {
|
148
|
+
// Could set custom drag image here
|
149
|
+
}
|
150
|
+
|
151
|
+
onDragStart?.({ event, item, source, group });
|
152
|
+
}
|
153
|
+
|
154
|
+
/**
|
155
|
+
* Handle during drag
|
156
|
+
* @param {DragEvent} event
|
157
|
+
*/
|
158
|
+
function handleDrag(event) {
|
159
|
+
if (currentState === DRAGGING) {
|
160
|
+
onDragging?.({ event, item });
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
/**
|
165
|
+
* Handle drag end
|
166
|
+
* @param {DragEvent} event
|
167
|
+
*/
|
168
|
+
function handleDragEnd(event) {
|
169
|
+
clearTimeout(dragTimeout);
|
170
|
+
|
171
|
+
// Clear global drag state
|
172
|
+
dragState.end( draggableId );
|
173
|
+
|
174
|
+
// Check if drop was successful
|
175
|
+
const wasDropped = event.dataTransfer.dropEffect !== 'none';
|
176
|
+
|
177
|
+
if (wasDropped) {
|
178
|
+
currentState = DROPPING;
|
179
|
+
onDrop?.({ event, item, wasDropped: true });
|
180
|
+
|
181
|
+
// Brief dropping state before returning to idle
|
182
|
+
setTimeout(() => {
|
183
|
+
currentState = IDLE;
|
184
|
+
}, 100);
|
185
|
+
} else {
|
186
|
+
currentState = IDLE;
|
187
|
+
}
|
188
|
+
|
189
|
+
onDragEnd?.({ event, item, wasDropped });
|
190
|
+
}
|
191
|
+
|
192
|
+
/**
|
193
|
+
* Handle mouse down for drag delay
|
194
|
+
* @param {MouseEvent} event
|
195
|
+
*/
|
196
|
+
function handleMouseDown(event) {
|
197
|
+
if (dragDelay > 0 && !disabled && canDrag(item)) {
|
198
|
+
// Could add visual feedback here
|
199
|
+
}
|
200
|
+
}
|
201
|
+
|
202
|
+
/**
|
203
|
+
* Handle mouse up to cancel drag delay
|
204
|
+
* @param {MouseEvent} event
|
205
|
+
*/
|
206
|
+
function handleMouseUp(event) {
|
207
|
+
if (dragTimeout) {
|
208
|
+
clearTimeout(dragTimeout);
|
209
|
+
currentState = IDLE;
|
210
|
+
}
|
211
|
+
}
|
212
|
+
</script>
|
213
|
+
|
214
|
+
<div
|
215
|
+
data-component="draggable"
|
216
|
+
data-id={draggableId}
|
217
|
+
draggable={!disabled && canDrag(item)}
|
218
|
+
ondragstart={handleDragStart}
|
219
|
+
ondrag={handleDrag}
|
220
|
+
ondragend={handleDragEnd}
|
221
|
+
onmousedown={handleMouseDown}
|
222
|
+
onmouseup={handleMouseUp}
|
223
|
+
class="{base} {classes} {stateClasses}"
|
224
|
+
{...attrs}
|
225
|
+
>
|
226
|
+
{@render children()}
|
227
|
+
</div>
|
@@ -0,0 +1,76 @@
|
|
1
|
+
export default Draggable;
|
2
|
+
type Draggable = {
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
4
|
+
$set?(props: Partial<{
|
5
|
+
[key: string]: any;
|
6
|
+
item: any;
|
7
|
+
group?: string;
|
8
|
+
source?: string;
|
9
|
+
disabled?: boolean;
|
10
|
+
dragDelay?: number;
|
11
|
+
base?: string;
|
12
|
+
classes?: string;
|
13
|
+
children: Snippet<[]>;
|
14
|
+
contextKey?: ContextKey;
|
15
|
+
isDragging?: boolean;
|
16
|
+
isDropping?: boolean;
|
17
|
+
isDragPreview?: boolean;
|
18
|
+
onDragStart?: (detail: {
|
19
|
+
event: DragEvent;
|
20
|
+
item: any;
|
21
|
+
source: string;
|
22
|
+
group: string;
|
23
|
+
}) => void;
|
24
|
+
onDragging?: (detail: {
|
25
|
+
event: DragEvent;
|
26
|
+
item: any;
|
27
|
+
}) => void;
|
28
|
+
onDragEnd?: (detail: {
|
29
|
+
event: DragEvent;
|
30
|
+
item: any;
|
31
|
+
wasDropped: boolean;
|
32
|
+
}) => void;
|
33
|
+
onDrop?: (detail: {
|
34
|
+
event: DragEvent;
|
35
|
+
item: any;
|
36
|
+
wasDropped: boolean;
|
37
|
+
}) => void;
|
38
|
+
canDrag?: (item: any) => boolean;
|
39
|
+
}>): void;
|
40
|
+
};
|
41
|
+
declare const Draggable: import("svelte").Component<{
|
42
|
+
[key: string]: any;
|
43
|
+
item: any;
|
44
|
+
group?: string;
|
45
|
+
source?: string;
|
46
|
+
disabled?: boolean;
|
47
|
+
dragDelay?: number;
|
48
|
+
base?: string;
|
49
|
+
classes?: string;
|
50
|
+
children: import("svelte").Snippet;
|
51
|
+
contextKey?: import("../../typedef").ContextKey;
|
52
|
+
isDragging?: boolean;
|
53
|
+
isDropping?: boolean;
|
54
|
+
isDragPreview?: boolean;
|
55
|
+
onDragStart?: (detail: {
|
56
|
+
event: DragEvent;
|
57
|
+
item: any;
|
58
|
+
source: string;
|
59
|
+
group: string;
|
60
|
+
}) => void;
|
61
|
+
onDragging?: (detail: {
|
62
|
+
event: DragEvent;
|
63
|
+
item: any;
|
64
|
+
}) => void;
|
65
|
+
onDragEnd?: (detail: {
|
66
|
+
event: DragEvent;
|
67
|
+
item: any;
|
68
|
+
wasDropped: boolean;
|
69
|
+
}) => void;
|
70
|
+
onDrop?: (detail: {
|
71
|
+
event: DragEvent;
|
72
|
+
item: any;
|
73
|
+
wasDropped: boolean;
|
74
|
+
}) => void;
|
75
|
+
canDrag?: (item: any) => boolean;
|
76
|
+
}, {}, "isDragging" | "isDropping" | "isDragPreview">;
|