@hkdigital/lib-sveltekit 0.1.85 → 0.1.87
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/classes/data/Selector.d.ts +2 -2
- package/dist/classes/data/Selector.js +1 -1
- package/dist/components/drag-drop/Draggable.svelte +5 -8
- package/dist/components/drag-drop/DropZone.svelte +57 -64
- package/dist/components/drag-drop/drag-state.svelte.d.ts +3 -3
- package/dist/components/tab-bar/HkTabBar.state.svelte.d.ts +3 -3
- package/dist/components/tab-bar/HkTabBarSelector.state.svelte.d.ts +3 -3
- package/dist/features/hk-app-layout/HkAppLayout.state.svelte.d.ts +3 -3
- package/dist/themes/hkdev/components/buttons/button.css +6 -2
- package/dist/typedef/drag.d.ts +1 -8
- package/dist/typedef/drag.js +1 -2
- package/dist/util/array/index.d.ts +7 -7
- package/dist/util/array/index.js +12 -31
- package/dist/util/svelte/state-context/index.d.ts +1 -1
- package/dist/util/svelte/state-context/index.js +4 -4
- package/package.json +5 -1
@@ -23,8 +23,8 @@ export default class Selector {
|
|
23
23
|
* @template {object} T
|
24
24
|
* @param {T[]|null} items
|
25
25
|
*
|
26
|
-
* @returns {T|null} item or null if not found
|
26
|
+
* @returns {T[]|null} item or null if not found
|
27
27
|
*/
|
28
|
-
findAll<T extends unknown>(items: T[] | null): T | null;
|
28
|
+
findAll<T extends unknown>(items: T[] | null): T[] | null;
|
29
29
|
#private;
|
30
30
|
}
|
@@ -174,24 +174,22 @@ function startDrag(event) {
|
|
174
174
|
dragOffsetX = event.clientX - rect.left;
|
175
175
|
dragOffsetY = event.clientY - rect.top;
|
176
176
|
|
177
|
-
// Create drag data with
|
177
|
+
// Create drag data with draggableId included
|
178
178
|
const dragData = {
|
179
|
+
draggableId,
|
179
180
|
offsetX: dragOffsetX,
|
180
181
|
offsetY: dragOffsetY,
|
181
182
|
item,
|
182
183
|
source,
|
183
|
-
group
|
184
|
-
metadata: {
|
185
|
-
timestamp: Date.now()
|
186
|
-
}
|
184
|
+
group
|
187
185
|
};
|
188
186
|
|
189
187
|
// Set shared drag state
|
190
188
|
dragState.start(draggableId, dragData);
|
191
189
|
|
192
|
-
// Set data transfer for browser drag and drop API
|
190
|
+
// Set minimal data transfer for browser drag and drop API
|
193
191
|
event.dataTransfer.effectAllowed = 'move';
|
194
|
-
event.dataTransfer.setData('application/json', JSON.stringify(
|
192
|
+
event.dataTransfer.setData('application/json', JSON.stringify({ draggableId }));
|
195
193
|
|
196
194
|
// Create the preview controller
|
197
195
|
const previewController = new DragController(event);
|
@@ -308,7 +306,6 @@ function startDrag(event) {
|
|
308
306
|
|
309
307
|
<div
|
310
308
|
data-component="draggable"
|
311
|
-
data-id={draggableId}
|
312
309
|
bind:this={draggableElement}
|
313
310
|
draggable={!disabled && canDrag(item)}
|
314
311
|
ondragstart={handleDragStart}
|
@@ -6,18 +6,11 @@
|
|
6
6
|
|
7
7
|
import { GridLayers } from '../layout';
|
8
8
|
|
9
|
-
import {
|
10
|
-
// findDraggableSource,
|
11
|
-
getDraggableIdFromEvent
|
12
|
-
// processDropWithData
|
13
|
-
} from './util.js';
|
14
|
-
|
15
9
|
import {
|
16
10
|
READY,
|
17
11
|
DRAG_OVER,
|
18
12
|
CAN_DROP,
|
19
13
|
CANNOT_DROP
|
20
|
-
// DROP_DISABLED
|
21
14
|
} from '../../constants/state-labels/drop-states.js';
|
22
15
|
|
23
16
|
/** @typedef {import('../../typedef').DragData} DragData */
|
@@ -92,8 +85,6 @@
|
|
92
85
|
|
93
86
|
const dragState = createOrGetDragState(contextKey);
|
94
87
|
|
95
|
-
// console.debug('DropZone contextKey:', contextKey);
|
96
|
-
|
97
88
|
let currentState = $state(READY);
|
98
89
|
let dropzoneElement; // Reference to the dropzone DOM element
|
99
90
|
|
@@ -148,15 +139,47 @@
|
|
148
139
|
* @returns {boolean}
|
149
140
|
*/
|
150
141
|
function canAcceptDrop(data) {
|
151
|
-
// console.debug('canAcceptDrop', data, {group});
|
152
|
-
|
153
142
|
if (disabled) return false;
|
154
143
|
if (!data) return false;
|
155
|
-
if (data
|
156
|
-
if (!accepts(data.item)) return false;
|
144
|
+
if (!accepts(data)) return false;
|
157
145
|
return true;
|
158
146
|
}
|
159
147
|
|
148
|
+
/**
|
149
|
+
* Get drag data from either drag state or handle file drops
|
150
|
+
* @param {DragEvent} event
|
151
|
+
* @returns {Object|null} The drag data, or null for file drops
|
152
|
+
*/
|
153
|
+
function getDragData(event) {
|
154
|
+
// Check if this is a file drop
|
155
|
+
if (event.dataTransfer.types.includes('Files')) {
|
156
|
+
// Handle file drop - you can extend this based on your needs
|
157
|
+
console.log('File drop detected:', event.dataTransfer.files);
|
158
|
+
return null; // Return null to indicate this is not an internal drag
|
159
|
+
}
|
160
|
+
|
161
|
+
// Handle internal drag operations
|
162
|
+
try {
|
163
|
+
const jsonData = event.dataTransfer.getData('application/json');
|
164
|
+
if (jsonData) {
|
165
|
+
const transferData = JSON.parse(jsonData);
|
166
|
+
const draggableId = transferData.draggableId;
|
167
|
+
|
168
|
+
if (draggableId) {
|
169
|
+
// Get the original instance from drag state
|
170
|
+
const dragData = dragState.getDraggable(draggableId);
|
171
|
+
if (dragData) {
|
172
|
+
return dragData;
|
173
|
+
}
|
174
|
+
}
|
175
|
+
}
|
176
|
+
} catch (error) {
|
177
|
+
console.error('Error getting drag data:', error);
|
178
|
+
}
|
179
|
+
|
180
|
+
return null;
|
181
|
+
}
|
182
|
+
|
160
183
|
/**
|
161
184
|
* Handle drag enter with improved DOM traversal check
|
162
185
|
* @param {DragEvent} event
|
@@ -171,28 +194,14 @@
|
|
171
194
|
// Now we're over this dropzone
|
172
195
|
isCurrentlyOver = true;
|
173
196
|
|
174
|
-
// Get the
|
175
|
-
const
|
176
|
-
|
177
|
-
if (draggableId) {
|
178
|
-
// Get the drag data for this specific draggable
|
179
|
-
const dragData = dragState.getDraggable(draggableId);
|
197
|
+
// Get the drag data
|
198
|
+
const dragData = getDragData(event);
|
180
199
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
} else {
|
185
|
-
currentState = DRAG_OVER;
|
186
|
-
}
|
200
|
+
// Update state based on acceptance
|
201
|
+
if (dragData) {
|
202
|
+
currentState = canAcceptDrop(dragData) ? CAN_DROP : CANNOT_DROP;
|
187
203
|
} else {
|
188
|
-
|
189
|
-
const dragData = dragState.current;
|
190
|
-
|
191
|
-
if (dragData) {
|
192
|
-
currentState = canAcceptDrop(dragData) ? CAN_DROP : CANNOT_DROP;
|
193
|
-
} else {
|
194
|
-
currentState = DRAG_OVER;
|
195
|
-
}
|
204
|
+
currentState = DRAG_OVER;
|
196
205
|
}
|
197
206
|
|
198
207
|
// Notify listeners
|
@@ -214,17 +223,8 @@
|
|
214
223
|
return;
|
215
224
|
}
|
216
225
|
|
217
|
-
// Get the
|
218
|
-
const
|
219
|
-
let dragData;
|
220
|
-
|
221
|
-
if (draggableId) {
|
222
|
-
// Get the drag data for this specific draggable
|
223
|
-
dragData = dragState.getDraggable(draggableId);
|
224
|
-
} else {
|
225
|
-
// Fallback to the current drag data (for compatibility)
|
226
|
-
dragData = dragState.current;
|
227
|
-
}
|
226
|
+
// Get the drag data
|
227
|
+
const dragData = getDragData(event);
|
228
228
|
|
229
229
|
// Re-evaluate acceptance
|
230
230
|
if (dragData && [DRAG_OVER, CAN_DROP, CANNOT_DROP].includes(currentState)) {
|
@@ -276,23 +276,20 @@
|
|
276
276
|
isCurrentlyOver = false;
|
277
277
|
|
278
278
|
try {
|
279
|
-
//
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
279
|
+
// Check if this is a file drop first
|
280
|
+
if (event.dataTransfer.types.includes('Files')) {
|
281
|
+
// Handle file drops
|
282
|
+
const files = Array.from(event.dataTransfer.files);
|
283
|
+
console.log('Files dropped:', files);
|
284
|
+
|
285
|
+
// You can add custom file handling here
|
286
|
+
// For now, just reset state and return
|
287
|
+
currentState = READY;
|
288
|
+
return;
|
286
289
|
}
|
287
290
|
|
288
|
-
//
|
289
|
-
|
290
|
-
// Parse the JSON data from the dataTransfer object (only works during drop)
|
291
|
-
const jsonData = event.dataTransfer.getData('application/json');
|
292
|
-
if (jsonData) {
|
293
|
-
dragData = JSON.parse(jsonData);
|
294
|
-
}
|
295
|
-
}
|
291
|
+
// Get drag data for internal drag operations
|
292
|
+
const dragData = getDragData(event);
|
296
293
|
|
297
294
|
// Check if we can accept this drop
|
298
295
|
if (dragData && canAcceptDrop(dragData)) {
|
@@ -309,7 +306,6 @@
|
|
309
306
|
const dropzoneRect = dropzoneElement.getBoundingClientRect();
|
310
307
|
|
311
308
|
// Calculate position with both dragData.offsetX/Y adjustment and border adjustment
|
312
|
-
// This combines your current approach with the border adjustment
|
313
309
|
const offsetX =
|
314
310
|
event.clientX -
|
315
311
|
dropzoneRect.left -
|
@@ -322,16 +318,13 @@
|
|
322
318
|
borderTopWidth -
|
323
319
|
(dragData.offsetY ?? 0);
|
324
320
|
|
325
|
-
// console.debug("dragData", dragData);
|
326
|
-
|
327
321
|
const dropResult = onDrop?.({
|
328
322
|
event,
|
329
323
|
offsetX,
|
330
324
|
offsetY,
|
331
325
|
zone,
|
332
326
|
item: dragData.item,
|
333
|
-
source: dragData.source
|
334
|
-
metadata: dragData.metadata
|
327
|
+
source: dragData.source
|
335
328
|
});
|
336
329
|
|
337
330
|
// Handle async or sync results
|
@@ -1,6 +1,6 @@
|
|
1
|
-
export const createOrGetDragState: (contextKey
|
2
|
-
export const createDragState: (contextKey
|
3
|
-
export const getDragState: (contextKey
|
1
|
+
export const createOrGetDragState: (contextKey?: import("../../typedef").ContextKey) => DragState;
|
2
|
+
export const createDragState: (contextKey?: import("../../typedef").ContextKey) => DragState;
|
3
|
+
export const getDragState: (contextKey?: import("../../typedef").ContextKey) => DragState;
|
4
4
|
declare class DragState {
|
5
5
|
draggables: Map<any, any>;
|
6
6
|
/**
|
@@ -48,7 +48,7 @@ export class HkTabBarState {
|
|
48
48
|
*/
|
49
49
|
linkTab(index: number, tabElement: HTMLElement): void;
|
50
50
|
}
|
51
|
-
export const createOrGetState: (contextKey
|
52
|
-
export const createState: (contextKey
|
53
|
-
export const getState: (contextKey
|
51
|
+
export const createOrGetState: (contextKey?: import("../../typedef/context.js").ContextKey) => HkTabBarState;
|
52
|
+
export const createState: (contextKey?: import("../../typedef/context.js").ContextKey) => HkTabBarState;
|
53
|
+
export const getState: (contextKey?: import("../../typedef/context.js").ContextKey) => HkTabBarState;
|
54
54
|
export type Tab = import("./typedef.js").Tab;
|
@@ -14,6 +14,6 @@ export class HkTabBarSelectorState {
|
|
14
14
|
tabBarState: any;
|
15
15
|
#private;
|
16
16
|
}
|
17
|
-
export const createOrGetState: (contextKey
|
18
|
-
export const createState: (contextKey
|
19
|
-
export const getState: (contextKey
|
17
|
+
export const createOrGetState: (contextKey?: import("../../typedef/context.js").ContextKey) => HkTabBarSelectorState;
|
18
|
+
export const createState: (contextKey?: import("../../typedef/context.js").ContextKey) => HkTabBarSelectorState;
|
19
|
+
export const getState: (contextKey?: import("../../typedef/context.js").ContextKey) => HkTabBarSelectorState;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
export class AppLayoutState {
|
2
2
|
landscapeOnSmallScreen: boolean;
|
3
3
|
}
|
4
|
-
export const createOrGetState: (contextKey
|
5
|
-
export const createState: (contextKey
|
6
|
-
export const getState: (contextKey
|
4
|
+
export const createOrGetState: (contextKey?: import("../../typedef").ContextKey) => AppLayoutState;
|
5
|
+
export const createState: (contextKey?: import("../../typedef").ContextKey) => AppLayoutState;
|
6
|
+
export const getState: (contextKey?: import("../../typedef").ContextKey) => AppLayoutState;
|
@@ -10,9 +10,11 @@
|
|
10
10
|
--btn-primary-bg: var(--color-primary-500);
|
11
11
|
--btn-primary-text: var(--color-primary-50);
|
12
12
|
--btn-primary-border: var(--color-primary-500);
|
13
|
+
|
13
14
|
--btn-primary-selected-bg: var(--color-primary-700);
|
14
|
-
--btn-primary-selected-border: var(--color-primary-800);
|
15
15
|
--btn-primary-selected-text: var(--color-primary-50);
|
16
|
+
--btn-primary-selected-border: var(--color-primary-800);
|
17
|
+
|
16
18
|
--btn-primary-hover-bg: var(--color-primary-600);
|
17
19
|
--btn-primary-hover-border: var(--color-primary-600);
|
18
20
|
--btn-primary-focus-outline: var(--color-primary-800);
|
@@ -21,9 +23,11 @@
|
|
21
23
|
--btn-secondary-bg: transparent;
|
22
24
|
--btn-secondary-text: var(--color-secondary-500);
|
23
25
|
--btn-secondary-border: var(--color-secondary-500);
|
26
|
+
|
24
27
|
--btn-secondary-selected-bg: var(--color-secondary-100);
|
25
|
-
--btn-secondary-selected-border: var(--color-secondary-600);
|
26
28
|
--btn-secondary-selected-text: var(--color-secondary-800);
|
29
|
+
--btn-secondary-selected-border: var(--color-secondary-600);
|
30
|
+
|
27
31
|
--btn-secondary-hover-bg: var(--color-secondary-50);
|
28
32
|
--btn-secondary-hover-border: var(--color-secondary-500);
|
29
33
|
--btn-secondary-focus-outline: var(--color-secondary-800);
|
package/dist/typedef/drag.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
declare const _default: {};
|
2
2
|
export default _default;
|
3
3
|
export type DragData = {
|
4
|
+
draggableId: string;
|
4
5
|
offsetX: number;
|
5
6
|
offsetY: number;
|
6
7
|
/**
|
@@ -11,12 +12,4 @@ export type DragData = {
|
|
11
12
|
* - Source identifier
|
12
13
|
*/
|
13
14
|
source?: string;
|
14
|
-
/**
|
15
|
-
* - Drag group
|
16
|
-
*/
|
17
|
-
group?: string;
|
18
|
-
/**
|
19
|
-
* - Additional metadata
|
20
|
-
*/
|
21
|
-
metadata?: any;
|
22
15
|
};
|
package/dist/typedef/drag.js
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
/**
|
2
2
|
* @typedef {Object} DragData
|
3
|
+
* @property {string} draggableId
|
3
4
|
* @property {number} offsetX
|
4
5
|
* @property {number} offsetY
|
5
6
|
* @property {any} item - The item being dragged
|
6
7
|
* @property {string} [source] - Source identifier
|
7
|
-
* @property {string} [group] - Drag group
|
8
|
-
* @property {any} [metadata] - Additional metadata
|
9
8
|
*/
|
10
9
|
|
11
10
|
export default {}
|
@@ -27,12 +27,12 @@ export function toArray(value: any, start?: number, end?: number): any[];
|
|
27
27
|
* Convert an async iterator to an array
|
28
28
|
* - If no async iterator is passed, the value will be processed by `from()`
|
29
29
|
*
|
30
|
-
* @param {AsyncIterator|
|
30
|
+
* @param {AsyncIterator|any} value
|
31
31
|
* Async iterator or value to convert to array
|
32
32
|
*
|
33
|
-
* @returns {Array} list of items returned by the iterator
|
33
|
+
* @returns {Promise<Array>} list of items returned by the iterator
|
34
34
|
*/
|
35
|
-
export function toArrayAsync(value: AsyncIterator<any, any, any> |
|
35
|
+
export function toArrayAsync(value: AsyncIterator<any, any, any> | any): Promise<any[]>;
|
36
36
|
/**
|
37
37
|
* Convert a path string to an array path
|
38
38
|
* - The path string will be spit at the `pathSeparator` token
|
@@ -51,13 +51,13 @@ export function toArrayPath(path: string | string[], pathSeparator?: string): st
|
|
51
51
|
/**
|
52
52
|
* Push a value to an array if it is not null, undefined or an empty string
|
53
53
|
*
|
54
|
-
* @template {
|
54
|
+
* @template {array} T
|
55
55
|
* @param {T} arr
|
56
56
|
* @param {any} value
|
57
57
|
*
|
58
58
|
* @returns {T} arr
|
59
59
|
*/
|
60
|
-
export function pushNotEmpty<T extends
|
60
|
+
export function pushNotEmpty<T extends any[]>(arr: T, value: any): T;
|
61
61
|
/**
|
62
62
|
* Loop over the supplied array and call the callback for every element
|
63
63
|
* - The callback will receive the current element of the array as
|
@@ -86,12 +86,12 @@ export function loop(arr: any[], callback: Function, additionalArguments: any[])
|
|
86
86
|
*
|
87
87
|
*
|
88
88
|
*
|
89
|
-
* @returns {
|
89
|
+
* @returns {any[]|Set<any>} values
|
90
90
|
*/
|
91
91
|
export function pathValues(items: object[], path: any, options?: {
|
92
92
|
outputAsSet?: boolean;
|
93
93
|
pathSeparator?: string;
|
94
|
-
}):
|
94
|
+
}): any[] | Set<any>;
|
95
95
|
/**
|
96
96
|
* Sort function that sorts a list of objects by values encountered at the
|
97
97
|
* specified key values of the object.
|
package/dist/util/array/index.js
CHANGED
@@ -21,8 +21,6 @@ export { smallestFirst, largestFirst };
|
|
21
21
|
|
22
22
|
export { arraySlice, arrayConcat };
|
23
23
|
|
24
|
-
// -----------------------------------------------------------------------------
|
25
|
-
|
26
24
|
/**
|
27
25
|
* Convert a value to an array
|
28
26
|
* - Converts an Arguments object to plain JS array
|
@@ -83,23 +81,24 @@ export function toArray(value, start, end) {
|
|
83
81
|
//
|
84
82
|
return Array.from(value);
|
85
83
|
} else {
|
86
|
-
return arraySlice(value, start, end);
|
84
|
+
return arraySlice.call(value, start, end);
|
87
85
|
}
|
88
86
|
}
|
89
87
|
|
90
|
-
// -----------------------------------------------------------------------------
|
91
|
-
|
92
88
|
/**
|
93
89
|
* Convert an async iterator to an array
|
94
90
|
* - If no async iterator is passed, the value will be processed by `from()`
|
95
91
|
*
|
96
|
-
* @param {AsyncIterator|
|
92
|
+
* @param {AsyncIterator|any} value
|
97
93
|
* Async iterator or value to convert to array
|
98
94
|
*
|
99
|
-
* @returns {Array} list of items returned by the iterator
|
95
|
+
* @returns {Promise<Array>} list of items returned by the iterator
|
100
96
|
*/
|
101
97
|
export async function toArrayAsync(value) {
|
102
|
-
if (
|
98
|
+
if (
|
99
|
+
value instanceof Object &&
|
100
|
+
typeof value[Symbol.asyncIterator] === 'function'
|
101
|
+
) {
|
103
102
|
// value is an async iterator
|
104
103
|
|
105
104
|
const arr = [];
|
@@ -116,8 +115,6 @@ export async function toArrayAsync(value) {
|
|
116
115
|
}
|
117
116
|
}
|
118
117
|
|
119
|
-
// -----------------------------------------------------------------------------
|
120
|
-
|
121
118
|
/**
|
122
119
|
* Convert a path string to an array path
|
123
120
|
* - The path string will be spit at the `pathSeparator` token
|
@@ -139,16 +136,16 @@ export function toArrayPath(path, pathSeparator = PATH_SEPARATOR) {
|
|
139
136
|
// path is already an array
|
140
137
|
return path;
|
141
138
|
} else {
|
142
|
-
throw new Error(
|
139
|
+
throw new Error(
|
140
|
+
'Missing or invalid parameter [path] (expected string or array)'
|
141
|
+
);
|
143
142
|
}
|
144
143
|
}
|
145
144
|
|
146
|
-
// -----------------------------------------------------------------------------
|
147
|
-
|
148
145
|
/**
|
149
146
|
* Push a value to an array if it is not null, undefined or an empty string
|
150
147
|
*
|
151
|
-
* @template {
|
148
|
+
* @template {array} T
|
152
149
|
* @param {T} arr
|
153
150
|
* @param {any} value
|
154
151
|
*
|
@@ -164,8 +161,6 @@ export function pushNotEmpty(arr, value) {
|
|
164
161
|
return arr;
|
165
162
|
}
|
166
163
|
|
167
|
-
// -----------------------------------------------------------------------------
|
168
|
-
|
169
164
|
/**
|
170
165
|
* Loop over the supplied array and call the callback for every element
|
171
166
|
* - The callback will receive the current element of the array as
|
@@ -213,8 +208,6 @@ export function loop(arr, callback, additionalArguments) {
|
|
213
208
|
}
|
214
209
|
}
|
215
210
|
|
216
|
-
// -----------------------------------------------------------------------------
|
217
|
-
|
218
211
|
/**
|
219
212
|
* Get a list of all values from the items in the array at the
|
220
213
|
* specified path
|
@@ -231,7 +224,7 @@ export function loop(arr, callback, additionalArguments) {
|
|
231
224
|
*
|
232
225
|
*
|
233
226
|
*
|
234
|
-
* @returns {
|
227
|
+
* @returns {any[]|Set<any>} values
|
235
228
|
*/
|
236
229
|
export function pathValues(items, path, options = {}) {
|
237
230
|
// == Process parameters
|
@@ -277,8 +270,6 @@ export function pathValues(items, path, options = {}) {
|
|
277
270
|
return values;
|
278
271
|
}
|
279
272
|
|
280
|
-
// -----------------------------------------------------------------------------
|
281
|
-
|
282
273
|
/**
|
283
274
|
* Sort function that sorts a list of objects by values encountered at the
|
284
275
|
* specified key values of the object.
|
@@ -306,8 +297,6 @@ export function sortByKeyValue(items, key, compareFn = smallestFirst) {
|
|
306
297
|
});
|
307
298
|
}
|
308
299
|
|
309
|
-
// -----------------------------------------------------------------------------
|
310
|
-
|
311
300
|
/**
|
312
301
|
* Sort function that sorts a list of objects by values encountered at the
|
313
302
|
* specified key values of the object.
|
@@ -335,8 +324,6 @@ export function sortByKeyValueReversed(items, key, compareFn = largestFirst) {
|
|
335
324
|
});
|
336
325
|
}
|
337
326
|
|
338
|
-
// -----------------------------------------------------------------------------
|
339
|
-
|
340
327
|
/**
|
341
328
|
* Sort function that sorts a list of objects by values encountered at the
|
342
329
|
* specified object path.
|
@@ -393,8 +380,6 @@ export function sortByPathValue(items, path, compareFn = smallestFirst) {
|
|
393
380
|
cache.clear();
|
394
381
|
}
|
395
382
|
|
396
|
-
// -----------------------------------------------------------------------------
|
397
|
-
|
398
383
|
/**
|
399
384
|
* Find the first item in the list of objects that matches the selector
|
400
385
|
* - All items in the supplied array must be objects
|
@@ -411,8 +396,6 @@ export function findFirst(arr, selector) {
|
|
411
396
|
return selectorObj.findFirst(arr);
|
412
397
|
}
|
413
398
|
|
414
|
-
// -----------------------------------------------------------------------------
|
415
|
-
|
416
399
|
/**
|
417
400
|
* Returns all items from the list of items that match the selector
|
418
401
|
* - All items in the supplied array must be objects
|
@@ -429,8 +412,6 @@ export function findAll(arr, selector) {
|
|
429
412
|
return selectorObj.findAll(arr);
|
430
413
|
}
|
431
414
|
|
432
|
-
// -----------------------------------------------------------------------------
|
433
|
-
|
434
415
|
/**
|
435
416
|
* Convert array to an object using a list of keys for each index
|
436
417
|
*
|
@@ -14,5 +14,5 @@
|
|
14
14
|
* getState
|
15
15
|
* ]}
|
16
16
|
*/
|
17
|
-
export function defineStateContext<T>(State: new () => T): [(contextKey
|
17
|
+
export function defineStateContext<T>(State: new () => T): [(contextKey?: import("../../../typedef").ContextKey) => T, (contextKey?: import("../../../typedef").ContextKey) => T, (contextKey?: import("../../../typedef").ContextKey) => T];
|
18
18
|
export const DEFAULT_CONTEXT_KEY: "default";
|
@@ -30,7 +30,7 @@ export function defineStateContext(State) {
|
|
30
30
|
/**
|
31
31
|
* Internal function to get the supplied key or the shared key
|
32
32
|
*
|
33
|
-
* @param {import('../../../typedef').ContextKey} contextKey
|
33
|
+
* @param {import('../../../typedef').ContextKey} [contextKey]
|
34
34
|
*
|
35
35
|
* @returns {Symbol} key
|
36
36
|
*/
|
@@ -55,7 +55,7 @@ export function defineStateContext(State) {
|
|
55
55
|
/**
|
56
56
|
* Create component state
|
57
57
|
*
|
58
|
-
* @param {import('../../../typedef').ContextKey} contextKey
|
58
|
+
* @param {import('../../../typedef').ContextKey} [contextKey]
|
59
59
|
*
|
60
60
|
* @returns {T} state
|
61
61
|
*/
|
@@ -80,7 +80,7 @@ export function defineStateContext(State) {
|
|
80
80
|
/**
|
81
81
|
* Get component state or create a new state if it does not yet exist
|
82
82
|
*
|
83
|
-
* @param {import('../../../typedef').ContextKey} contextKey
|
83
|
+
* @param {import('../../../typedef').ContextKey} [contextKey]
|
84
84
|
*
|
85
85
|
* @returns {T} state
|
86
86
|
*/
|
@@ -99,7 +99,7 @@ export function defineStateContext(State) {
|
|
99
99
|
*
|
100
100
|
* @throws Will throw an error if the state-context does not exist
|
101
101
|
*
|
102
|
-
* @param {import('../../../typedef').ContextKey} contextKey
|
102
|
+
* @param {import('../../../typedef').ContextKey} [contextKey]
|
103
103
|
*
|
104
104
|
* @returns {T} state
|
105
105
|
*/
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hkdigital/lib-sveltekit",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.87",
|
4
4
|
"author": {
|
5
5
|
"name": "HKdigital",
|
6
6
|
"url": "https://hkdigital.nl"
|
@@ -57,8 +57,10 @@
|
|
57
57
|
"./typedef": "./dist/typedef/index.js"
|
58
58
|
},
|
59
59
|
"peerDependencies": {
|
60
|
+
"@eslint/js": "^9.27.0",
|
60
61
|
"@steeze-ui/heroicons": "^2.4.2",
|
61
62
|
"@sveltejs/kit": "^2.15.2",
|
63
|
+
"eslint-plugin-import": "^2.31.0",
|
62
64
|
"pino": "^9.6.0",
|
63
65
|
"pino-pretty": "^13.0.0",
|
64
66
|
"runed": "^0.23.0",
|
@@ -68,6 +70,7 @@
|
|
68
70
|
"zod": "^3.24.2"
|
69
71
|
},
|
70
72
|
"devDependencies": {
|
73
|
+
"@eslint/js": "^9.27.0",
|
71
74
|
"@playwright/test": "^1.50.1",
|
72
75
|
"@skeletonlabs/skeleton": "3.0.0-next.2",
|
73
76
|
"@skeletonlabs/skeleton-svelte": "1.0.0-next.4",
|
@@ -82,6 +85,7 @@
|
|
82
85
|
"autoprefixer": "^10.4.20",
|
83
86
|
"eslint": "^9.21.0",
|
84
87
|
"eslint-config-prettier": "^10.0.2",
|
88
|
+
"eslint-plugin-import": "^2.31.0",
|
85
89
|
"eslint-plugin-svelte": "^3.0.2",
|
86
90
|
"fake-indexeddb": "^6.0.0",
|
87
91
|
"globals": "^16.0.0",
|