@vuetify/v0 0.0.18 → 0.0.20
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 +125 -47
- package/dist/browser/index.js +1483 -1499
- package/dist/components/index.d.mts +3 -3
- package/dist/components/index.mjs +4 -4
- package/dist/{components-DRdenC8b.mjs → components-D590hSY0.mjs} +3 -3
- package/dist/composables/index.d.mts +4 -4
- package/dist/composables/index.mjs +5 -5
- package/dist/{composables-DG1MHp-R.mjs → composables-FE6B8JUW.mjs} +240 -274
- package/dist/constants/index.mjs +1 -1
- package/dist/{globals-BGVqrlN7.mjs → globals-exvZ8fiO.mjs} +1 -1
- package/dist/index-4jSy8KIt.d.mts +73 -0
- package/dist/{index-CH7DpIK8.d.mts → index-BYyEPh1S.d.mts} +127 -10
- package/dist/index-CjzlIAtF.d.mts +296 -0
- package/dist/{index-oQuVnpOj.d.mts → index-DahjxaTj.d.mts} +251 -204
- package/dist/{index-DaX9-kmY.d.mts → index-Gr6XPRWt.d.mts} +7 -5
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +6 -6
- package/dist/types/index.d.mts +1 -1
- package/dist/{useStep-DC_JvZpy.mjs → useStep-Dw7XloDM.mjs} +996 -1202
- package/dist/utilities/index.d.mts +2 -2
- package/dist/utilities/index.mjs +1 -1
- package/dist/utilities-BrFKLHFS.mjs +363 -0
- package/package.json +3 -3
- package/dist/index-B-jVvwsm.d.mts +0 -71
- package/dist/index-C5LQZd3v.d.mts +0 -11
- package/dist/utilities-JxCe-nF2.mjs +0 -139
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../index-
|
|
2
|
-
import { _ as range, a as isBoolean, c as isNull, d as isObject, f as isPrimitive, g as mergeDeep, h as isUndefined, i as isArray, l as isNullOrUndefined, m as isSymbol, n as debounce, o as isFunction, p as isString, r as genId, s as isNaN, t as clamp, u as isNumber } from "../index-
|
|
1
|
+
import "../index-4jSy8KIt.mjs";
|
|
2
|
+
import { _ as range, a as isBoolean, c as isNull, d as isObject, f as isPrimitive, g as mergeDeep, h as isUndefined, i as isArray, l as isNullOrUndefined, m as isSymbol, n as debounce, o as isFunction, p as isString, r as genId, s as isNaN, t as clamp, u as isNumber } from "../index-CjzlIAtF.mjs";
|
|
3
3
|
export { clamp, debounce, genId, isArray, isBoolean, isFunction, isNaN, isNull, isNullOrUndefined, isNumber, isObject, isPrimitive, isString, isSymbol, isUndefined, mergeDeep, range };
|
package/dist/utilities/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { _ as range, a as isBoolean, c as isNull, d as isObject, f as isPrimitive, g as mergeDeep, h as isUndefined, i as isArray, l as isNullOrUndefined, m as isSymbol, n as debounce, o as isFunction, p as isString, r as genId, s as isNaN, t as clamp, u as isNumber } from "../utilities-
|
|
1
|
+
import { _ as range, a as isBoolean, c as isNull, d as isObject, f as isPrimitive, g as mergeDeep, h as isUndefined, i as isArray, l as isNullOrUndefined, m as isSymbol, n as debounce, o as isFunction, p as isString, r as genId, s as isNaN, t as clamp, u as isNumber } from "../utilities-BrFKLHFS.mjs";
|
|
2
2
|
|
|
3
3
|
export { clamp, debounce, genId, isArray, isBoolean, isFunction, isNaN, isNull, isNullOrUndefined, isNumber, isObject, isPrimitive, isString, isSymbol, isUndefined, mergeDeep, range };
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
//#region src/utilities/helpers.ts
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a value is a function
|
|
4
|
+
*
|
|
5
|
+
* @param item The value to check
|
|
6
|
+
* @returns True if the value is a function
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* isFunction(() => {}) // true
|
|
11
|
+
* isFunction('string') // false
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
15
|
+
function isFunction(item) {
|
|
16
|
+
return typeof item === "function";
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Checks if a value is a string
|
|
20
|
+
*
|
|
21
|
+
* @param item The value to check
|
|
22
|
+
* @returns True if the value is a string
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* isString('hello') // true
|
|
27
|
+
* isString(123) // false
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
31
|
+
function isString(item) {
|
|
32
|
+
return typeof item === "string";
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Checks if a value is a number
|
|
36
|
+
*
|
|
37
|
+
* @param item The value to check
|
|
38
|
+
* @returns True if the value is a number (including NaN)
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* isNumber(123) // true
|
|
43
|
+
* isNumber(NaN) // true
|
|
44
|
+
* isNumber('123') // false
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @see {@link isNaN} to check for NaN specifically
|
|
48
|
+
*/
|
|
49
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
50
|
+
function isNumber(item) {
|
|
51
|
+
return typeof item === "number";
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Checks if a value is a boolean
|
|
55
|
+
*
|
|
56
|
+
* @param item The value to check
|
|
57
|
+
* @returns True if the value is a boolean
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* isBoolean(true) // true
|
|
62
|
+
* isBoolean(false) // true
|
|
63
|
+
* isBoolean(0) // false
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
67
|
+
function isBoolean(item) {
|
|
68
|
+
return typeof item === "boolean";
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Checks if a value is a plain object (excludes null and arrays)
|
|
72
|
+
*
|
|
73
|
+
* @param item The value to check
|
|
74
|
+
* @returns True if the value is a plain object
|
|
75
|
+
*
|
|
76
|
+
* @remarks
|
|
77
|
+
* Returns false for null and arrays, even though `typeof null === 'object'`
|
|
78
|
+
* and `typeof [] === 'object'` in JavaScript.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* isObject({}) // true
|
|
83
|
+
* isObject({ a: 1 }) // true
|
|
84
|
+
* isObject(null) // false
|
|
85
|
+
* isObject([]) // false
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @see {@link isArray} to check for arrays
|
|
89
|
+
* @see {@link isNull} to check for null
|
|
90
|
+
*/
|
|
91
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
92
|
+
function isObject(item) {
|
|
93
|
+
return typeof item === "object" && item !== null && !Array.isArray(item);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Checks if a value is an array
|
|
97
|
+
*
|
|
98
|
+
* @param item The value to check
|
|
99
|
+
* @returns True if the value is an array
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* isArray([]) // true
|
|
104
|
+
* isArray([1, 2, 3]) // true
|
|
105
|
+
* isArray('string') // false
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
109
|
+
function isArray(item) {
|
|
110
|
+
return Array.isArray(item);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Checks if a value is null
|
|
114
|
+
*
|
|
115
|
+
* @param item The value to check
|
|
116
|
+
* @returns True if the value is null
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* isNull(null) // true
|
|
121
|
+
* isNull(undefined) // false
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* @see {@link isUndefined} to check for undefined
|
|
125
|
+
* @see {@link isNullOrUndefined} to check for either
|
|
126
|
+
*/
|
|
127
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
128
|
+
function isNull(item) {
|
|
129
|
+
return item === null;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Checks if a value is null or undefined
|
|
133
|
+
*
|
|
134
|
+
* @param item The value to check
|
|
135
|
+
* @returns True if the value is null or undefined
|
|
136
|
+
*
|
|
137
|
+
* @remarks
|
|
138
|
+
* Uses loose equality (`== null`) which matches both null and undefined.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* isNullOrUndefined(null) // true
|
|
143
|
+
* isNullOrUndefined(undefined) // true
|
|
144
|
+
* isNullOrUndefined(0) // false
|
|
145
|
+
* isNullOrUndefined('') // false
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @see {@link isNull} to check for null only
|
|
149
|
+
* @see {@link isUndefined} to check for undefined only
|
|
150
|
+
*/
|
|
151
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
152
|
+
function isNullOrUndefined(item) {
|
|
153
|
+
return item == null;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Checks if a value is undefined
|
|
157
|
+
*
|
|
158
|
+
* @param item The value to check
|
|
159
|
+
* @returns True if the value is undefined
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* isUndefined(undefined) // true
|
|
164
|
+
* isUndefined(null) // false
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @see {@link isNull} to check for null
|
|
168
|
+
* @see {@link isNullOrUndefined} to check for either
|
|
169
|
+
*/
|
|
170
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
171
|
+
function isUndefined(item) {
|
|
172
|
+
return item === void 0;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Checks if a value is a primitive (string, number, or boolean)
|
|
176
|
+
*
|
|
177
|
+
* @param item The value to check
|
|
178
|
+
* @returns True if the value is a string, number, or boolean
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```ts
|
|
182
|
+
* isPrimitive('hello') // true
|
|
183
|
+
* isPrimitive(123) // true
|
|
184
|
+
* isPrimitive(true) // true
|
|
185
|
+
* isPrimitive({}) // false
|
|
186
|
+
* isPrimitive(null) // false
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
190
|
+
function isPrimitive(item) {
|
|
191
|
+
return typeof item === "string" || typeof item === "number" || typeof item === "boolean";
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Checks if a value is a symbol
|
|
195
|
+
*
|
|
196
|
+
* @param item The value to check
|
|
197
|
+
* @returns True if the value is a symbol
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* isSymbol(Symbol('test')) // true
|
|
202
|
+
* isSymbol('symbol') // false
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
206
|
+
function isSymbol(item) {
|
|
207
|
+
return typeof item === "symbol";
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Checks if a value is NaN (Not a Number)
|
|
211
|
+
*
|
|
212
|
+
* @param item The value to check
|
|
213
|
+
* @returns True if the value is NaN
|
|
214
|
+
*
|
|
215
|
+
* @remarks
|
|
216
|
+
* Uses `Number.isNaN()` which only returns true for the actual NaN value,
|
|
217
|
+
* unlike the global `isNaN()` which coerces the argument to a number first.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```ts
|
|
221
|
+
* isNaN(NaN) // true
|
|
222
|
+
* isNaN(123) // false
|
|
223
|
+
* isNaN('hello') // false (unlike global isNaN)
|
|
224
|
+
* isNaN(undefined) // false (unlike global isNaN)
|
|
225
|
+
* ```
|
|
226
|
+
*
|
|
227
|
+
* @see {@link isNumber} to check if a value is a number type
|
|
228
|
+
*/
|
|
229
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
230
|
+
function isNaN(item) {
|
|
231
|
+
return /* @__PURE__ */ isNumber(item) && Number.isNaN(item);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Deeply merges source objects into a target object
|
|
235
|
+
*
|
|
236
|
+
* @param target The target object to merge into (will be mutated)
|
|
237
|
+
* @param sources One or more source objects to merge from
|
|
238
|
+
* @returns The mutated target object
|
|
239
|
+
*
|
|
240
|
+
* @remarks
|
|
241
|
+
* - Mutates the target object in place
|
|
242
|
+
* - Nested objects are recursively merged
|
|
243
|
+
* - Arrays are replaced, not merged
|
|
244
|
+
* - Primitives from sources overwrite target values
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```ts
|
|
248
|
+
* const target = { a: 1, b: { c: 2 } }
|
|
249
|
+
* mergeDeep(target, { b: { d: 3 } })
|
|
250
|
+
* // target is now { a: 1, b: { c: 2, d: 3 } }
|
|
251
|
+
*
|
|
252
|
+
* // Multiple sources
|
|
253
|
+
* mergeDeep({}, { a: 1 }, { b: 2 }) // { a: 1, b: 2 }
|
|
254
|
+
*
|
|
255
|
+
* // Arrays are replaced
|
|
256
|
+
* mergeDeep({ arr: [1, 2] }, { arr: [3] }) // { arr: [3] }
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
260
|
+
function mergeDeep(target, ...sources) {
|
|
261
|
+
if (sources.length === 0) return target;
|
|
262
|
+
const source = sources.shift();
|
|
263
|
+
if (/* @__PURE__ */ isObject(target) && /* @__PURE__ */ isObject(source)) {
|
|
264
|
+
for (const key in source) if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
265
|
+
const sourceValue = source[key];
|
|
266
|
+
const targetValue = target[key];
|
|
267
|
+
if (/* @__PURE__ */ isObject(sourceValue)) {
|
|
268
|
+
if (!/* @__PURE__ */ isObject(targetValue)) Object.assign(target, { [key]: {} });
|
|
269
|
+
} else Object.assign(target, { [key]: sourceValue });
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return /* @__PURE__ */ mergeDeep(target, ...sources);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Generates a random 7-character alphanumeric ID
|
|
276
|
+
*
|
|
277
|
+
* @returns A random string of 7 characters (a-z, 0-9)
|
|
278
|
+
*
|
|
279
|
+
* @remarks
|
|
280
|
+
* Uses `Math.random()` converted to base-36. Not cryptographically secure.
|
|
281
|
+
* Suitable for unique keys in UI components, not for security purposes.
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```ts
|
|
285
|
+
* genId() // 'k7x9m2p'
|
|
286
|
+
* genId() // 'a3b8c1d'
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
290
|
+
function genId() {
|
|
291
|
+
return Math.random().toString(36).slice(2, 9);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Clamps a value between a minimum and maximum
|
|
295
|
+
*
|
|
296
|
+
* @param value The value to clamp
|
|
297
|
+
* @param min The minimum value (default: 0)
|
|
298
|
+
* @param max The maximum value (default: 1)
|
|
299
|
+
* @returns The clamped value
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```ts
|
|
303
|
+
* clamp(5, 0, 10) // 5
|
|
304
|
+
* clamp(-5, 0, 10) // 0
|
|
305
|
+
* clamp(15, 0, 10) // 10
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
309
|
+
function clamp(value, min = 0, max = 1) {
|
|
310
|
+
return Math.max(min, Math.min(max, value));
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Creates an array of sequential numbers
|
|
314
|
+
*
|
|
315
|
+
* @param length The length of the array to create
|
|
316
|
+
* @param start The starting index (default: 0)
|
|
317
|
+
* @returns An array of sequential numbers
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```ts
|
|
321
|
+
* range(3) // [0, 1, 2]
|
|
322
|
+
* range(3, 1) // [1, 2, 3]
|
|
323
|
+
* range(5, 10) // [10, 11, 12, 13, 14]
|
|
324
|
+
* range(0) // []
|
|
325
|
+
* ```
|
|
326
|
+
*/
|
|
327
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
328
|
+
function range(length, start = 0) {
|
|
329
|
+
return Array.from({ length }, (_, index) => start + index);
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Debounces a function call by the specified delay
|
|
333
|
+
*
|
|
334
|
+
* @param fn The function to debounce
|
|
335
|
+
* @param delay The delay in milliseconds
|
|
336
|
+
* @returns A debounced function with clear and immediate methods
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
* ```ts
|
|
340
|
+
* const debouncedFn = debounce(() => console.log('called'), 500)
|
|
341
|
+
* debouncedFn() // Will call after 500ms
|
|
342
|
+
* debouncedFn.clear() // Cancel pending call
|
|
343
|
+
* debouncedFn.immediate() // Call immediately
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
function debounce(fn, delay) {
|
|
347
|
+
let timeoutId;
|
|
348
|
+
function debounced(...args) {
|
|
349
|
+
if (!/* @__PURE__ */ isUndefined(timeoutId)) clearTimeout(timeoutId);
|
|
350
|
+
timeoutId = setTimeout(() => fn(...args), delay);
|
|
351
|
+
}
|
|
352
|
+
debounced.clear = () => {
|
|
353
|
+
if (!/* @__PURE__ */ isUndefined(timeoutId)) clearTimeout(timeoutId);
|
|
354
|
+
};
|
|
355
|
+
debounced.immediate = (...args) => {
|
|
356
|
+
debounced.clear();
|
|
357
|
+
fn(...args);
|
|
358
|
+
};
|
|
359
|
+
return debounced;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
//#endregion
|
|
363
|
+
export { range as _, isBoolean as a, isNull as c, isObject as d, isPrimitive as f, mergeDeep as g, isUndefined as h, isArray as i, isNullOrUndefined as l, isSymbol as m, debounce as n, isFunction as o, isString as p, genId as r, isNaN as s, clamp as t, isNumber as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuetify/v0",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"description": "Vuetify0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"@vue/test-utils": "^2.4.6",
|
|
41
41
|
"tsdown": "^0.16.1",
|
|
42
42
|
"typescript": "5.9.3",
|
|
43
|
-
"unplugin-vue": "^7.0
|
|
44
|
-
"vue": "
|
|
43
|
+
"unplugin-vue": "^7.1.0",
|
|
44
|
+
"vue": "3.5.24"
|
|
45
45
|
},
|
|
46
46
|
"exports": {
|
|
47
47
|
".": "./dist/index.mjs",
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { n as DeepPartial } from "./index-C5LQZd3v.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/utilities/helpers.d.ts
|
|
4
|
-
declare function isFunction(item: unknown): item is Function;
|
|
5
|
-
declare function isString(item: unknown): item is string;
|
|
6
|
-
declare function isNumber(item: unknown): item is number;
|
|
7
|
-
declare function isBoolean(item: unknown): item is boolean;
|
|
8
|
-
declare function isObject(item: unknown): item is Record<string, unknown>;
|
|
9
|
-
declare function isArray(item: unknown): item is unknown[];
|
|
10
|
-
declare function isNull(item: unknown): item is null;
|
|
11
|
-
declare function isNullOrUndefined(item: unknown): item is null | undefined;
|
|
12
|
-
declare function isUndefined(item: unknown): item is undefined;
|
|
13
|
-
declare function isPrimitive(item: unknown): item is string | number | boolean;
|
|
14
|
-
declare function isSymbol(item: unknown): item is symbol;
|
|
15
|
-
declare function isNaN(item: unknown): item is number;
|
|
16
|
-
declare function mergeDeep<T extends object>(target: T, ...sources: DeepPartial<T>[]): T;
|
|
17
|
-
declare function genId(): string;
|
|
18
|
-
/**
|
|
19
|
-
* Clamps a value between a minimum and maximum
|
|
20
|
-
*
|
|
21
|
-
* @param value The value to clamp
|
|
22
|
-
* @param min The minimum value (default: 0)
|
|
23
|
-
* @param max The maximum value (default: 1)
|
|
24
|
-
* @returns The clamped value
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```ts
|
|
28
|
-
* clamp(5, 0, 10) // 5
|
|
29
|
-
* clamp(-5, 0, 10) // 0
|
|
30
|
-
* clamp(15, 0, 10) // 10
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
declare function clamp(value: number, min?: number, max?: number): number;
|
|
34
|
-
/**
|
|
35
|
-
* Creates an array of sequential numbers
|
|
36
|
-
*
|
|
37
|
-
* @param length The length of the array to create
|
|
38
|
-
* @param start The starting index (default: 0)
|
|
39
|
-
* @returns An array of sequential numbers
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* range(3) // [0, 1, 2]
|
|
44
|
-
* range(3, 1) // [1, 2, 3]
|
|
45
|
-
* range(5, 10) // [10, 11, 12, 13, 14]
|
|
46
|
-
* range(0) // []
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
declare function range(length: number, start?: number): number[];
|
|
50
|
-
/**
|
|
51
|
-
* Debounces a function call by the specified delay
|
|
52
|
-
*
|
|
53
|
-
* @param fn The function to debounce
|
|
54
|
-
* @param delay The delay in milliseconds
|
|
55
|
-
* @returns A debounced function with clear and immediate methods
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```ts
|
|
59
|
-
* const debouncedFn = debounce(() => console.log('called'), 500)
|
|
60
|
-
* debouncedFn() // Will call after 500ms
|
|
61
|
-
* debouncedFn.clear() // Cancel pending call
|
|
62
|
-
* debouncedFn.immediate() // Call immediately
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
declare function debounce<T extends (...args: any[]) => any>(fn: T, delay: number): {
|
|
66
|
-
(...args: Parameters<T>): void;
|
|
67
|
-
clear(): void;
|
|
68
|
-
immediate(...args: Parameters<T>): void;
|
|
69
|
-
};
|
|
70
|
-
//#endregion
|
|
71
|
-
export { range as _, isBoolean as a, isNull as c, isObject as d, isPrimitive as f, mergeDeep as g, isUndefined as h, isArray as i, isNullOrUndefined as l, isSymbol as m, debounce as n, isFunction as o, isString as p, genId as r, isNaN as s, clamp as t, isNumber as u };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { h } from "vue";
|
|
2
|
-
|
|
3
|
-
//#region src/types/index.d.ts
|
|
4
|
-
type DOMElement = Parameters<typeof h>[0];
|
|
5
|
-
type GenericObject = Record<string, any>;
|
|
6
|
-
type UnknownObject = Record<string, unknown>;
|
|
7
|
-
type ID = string | number;
|
|
8
|
-
type DeepPartial<T> = T extends object ? { [P in keyof T]?: DeepPartial<T[P]> } : T;
|
|
9
|
-
type MaybeArray<T> = T | T[];
|
|
10
|
-
//#endregion
|
|
11
|
-
export { MaybeArray as a, ID as i, DeepPartial as n, UnknownObject as o, GenericObject as r, DOMElement as t };
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
//#region src/utilities/helpers.ts
|
|
2
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
3
|
-
function isFunction(item) {
|
|
4
|
-
return typeof item === "function";
|
|
5
|
-
}
|
|
6
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
7
|
-
function isString(item) {
|
|
8
|
-
return typeof item === "string";
|
|
9
|
-
}
|
|
10
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
11
|
-
function isNumber(item) {
|
|
12
|
-
return typeof item === "number";
|
|
13
|
-
}
|
|
14
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
15
|
-
function isBoolean(item) {
|
|
16
|
-
return typeof item === "boolean";
|
|
17
|
-
}
|
|
18
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
19
|
-
function isObject(item) {
|
|
20
|
-
return typeof item === "object" && item !== null && !Array.isArray(item);
|
|
21
|
-
}
|
|
22
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
23
|
-
function isArray(item) {
|
|
24
|
-
return Array.isArray(item);
|
|
25
|
-
}
|
|
26
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
27
|
-
function isNull(item) {
|
|
28
|
-
return item === null;
|
|
29
|
-
}
|
|
30
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
31
|
-
function isNullOrUndefined(item) {
|
|
32
|
-
return item == null;
|
|
33
|
-
}
|
|
34
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
35
|
-
function isUndefined(item) {
|
|
36
|
-
return item === void 0;
|
|
37
|
-
}
|
|
38
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
39
|
-
function isPrimitive(item) {
|
|
40
|
-
return typeof item === "string" || typeof item === "number" || typeof item === "boolean";
|
|
41
|
-
}
|
|
42
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
43
|
-
function isSymbol(item) {
|
|
44
|
-
return typeof item === "symbol";
|
|
45
|
-
}
|
|
46
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
47
|
-
function isNaN(item) {
|
|
48
|
-
return /* @__PURE__ */ isNumber(item) && Number.isNaN(item);
|
|
49
|
-
}
|
|
50
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
51
|
-
function mergeDeep(target, ...sources) {
|
|
52
|
-
if (sources.length === 0) return target;
|
|
53
|
-
const source = sources.shift();
|
|
54
|
-
if (/* @__PURE__ */ isObject(target) && /* @__PURE__ */ isObject(source)) {
|
|
55
|
-
for (const key in source) if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
56
|
-
const sourceValue = source[key];
|
|
57
|
-
const targetValue = target[key];
|
|
58
|
-
if (/* @__PURE__ */ isObject(sourceValue)) {
|
|
59
|
-
if (!/* @__PURE__ */ isObject(targetValue)) Object.assign(target, { [key]: {} });
|
|
60
|
-
} else Object.assign(target, { [key]: sourceValue });
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return /* @__PURE__ */ mergeDeep(target, ...sources);
|
|
64
|
-
}
|
|
65
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
66
|
-
function genId() {
|
|
67
|
-
return Math.random().toString(36).slice(2, 9);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Clamps a value between a minimum and maximum
|
|
71
|
-
*
|
|
72
|
-
* @param value The value to clamp
|
|
73
|
-
* @param min The minimum value (default: 0)
|
|
74
|
-
* @param max The maximum value (default: 1)
|
|
75
|
-
* @returns The clamped value
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* ```ts
|
|
79
|
-
* clamp(5, 0, 10) // 5
|
|
80
|
-
* clamp(-5, 0, 10) // 0
|
|
81
|
-
* clamp(15, 0, 10) // 10
|
|
82
|
-
* ```
|
|
83
|
-
*/
|
|
84
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
85
|
-
function clamp(value, min = 0, max = 1) {
|
|
86
|
-
return Math.max(min, Math.min(max, value));
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Creates an array of sequential numbers
|
|
90
|
-
*
|
|
91
|
-
* @param length The length of the array to create
|
|
92
|
-
* @param start The starting index (default: 0)
|
|
93
|
-
* @returns An array of sequential numbers
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* ```ts
|
|
97
|
-
* range(3) // [0, 1, 2]
|
|
98
|
-
* range(3, 1) // [1, 2, 3]
|
|
99
|
-
* range(5, 10) // [10, 11, 12, 13, 14]
|
|
100
|
-
* range(0) // []
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
104
|
-
function range(length, start = 0) {
|
|
105
|
-
return Array.from({ length }, (_, index) => start + index);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Debounces a function call by the specified delay
|
|
109
|
-
*
|
|
110
|
-
* @param fn The function to debounce
|
|
111
|
-
* @param delay The delay in milliseconds
|
|
112
|
-
* @returns A debounced function with clear and immediate methods
|
|
113
|
-
*
|
|
114
|
-
* @example
|
|
115
|
-
* ```ts
|
|
116
|
-
* const debouncedFn = debounce(() => console.log('called'), 500)
|
|
117
|
-
* debouncedFn() // Will call after 500ms
|
|
118
|
-
* debouncedFn.clear() // Cancel pending call
|
|
119
|
-
* debouncedFn.immediate() // Call immediately
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
function debounce(fn, delay) {
|
|
123
|
-
let timeoutId;
|
|
124
|
-
function debounced(...args) {
|
|
125
|
-
if (!/* @__PURE__ */ isUndefined(timeoutId)) clearTimeout(timeoutId);
|
|
126
|
-
timeoutId = setTimeout(() => fn(...args), delay);
|
|
127
|
-
}
|
|
128
|
-
debounced.clear = () => {
|
|
129
|
-
if (!/* @__PURE__ */ isUndefined(timeoutId)) clearTimeout(timeoutId);
|
|
130
|
-
};
|
|
131
|
-
debounced.immediate = (...args) => {
|
|
132
|
-
debounced.clear();
|
|
133
|
-
fn(...args);
|
|
134
|
-
};
|
|
135
|
-
return debounced;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
//#endregion
|
|
139
|
-
export { range as _, isBoolean as a, isNull as c, isObject as d, isPrimitive as f, mergeDeep as g, isUndefined as h, isArray as i, isNullOrUndefined as l, isSymbol as m, debounce as n, isFunction as o, isString as p, genId as r, isNaN as s, clamp as t, isNumber as u };
|