rattail 1.3.1 → 1.4.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.
- package/lib/index.cjs +154 -73
- package/lib/index.d.cts +46 -1
- package/lib/index.d.ts +46 -1
- package/lib/index.global.js +152 -73
- package/lib/index.js +154 -73
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -76,6 +76,7 @@ __export(src_exports, {
|
|
|
76
76
|
duration: () => duration,
|
|
77
77
|
ensurePrefix: () => ensurePrefix,
|
|
78
78
|
ensureSuffix: () => ensureSuffix,
|
|
79
|
+
enumOf: () => enumOf,
|
|
79
80
|
find: () => find,
|
|
80
81
|
floor: () => floor,
|
|
81
82
|
genNumberKey: () => genNumberKey,
|
|
@@ -862,6 +863,7 @@ __export(util_exports, {
|
|
|
862
863
|
doubleRaf: () => doubleRaf,
|
|
863
864
|
download: () => download,
|
|
864
865
|
duration: () => duration,
|
|
866
|
+
enumOf: () => enumOf,
|
|
865
867
|
getAllParentScroller: () => getAllParentScroller,
|
|
866
868
|
getParentScroller: () => getParentScroller,
|
|
867
869
|
getRect: () => getRect,
|
|
@@ -1171,6 +1173,157 @@ function download(val, filename = "file") {
|
|
|
1171
1173
|
document.body.removeChild(a);
|
|
1172
1174
|
}
|
|
1173
1175
|
|
|
1176
|
+
// src/function/call.ts
|
|
1177
|
+
function call(fn, ...args) {
|
|
1178
|
+
if (isArray(fn)) {
|
|
1179
|
+
return fn.map((f) => f(...args));
|
|
1180
|
+
}
|
|
1181
|
+
if (fn) {
|
|
1182
|
+
return fn(...args);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
// src/function/once.ts
|
|
1187
|
+
function once(fn) {
|
|
1188
|
+
let called = false;
|
|
1189
|
+
let result;
|
|
1190
|
+
return function(...args) {
|
|
1191
|
+
if (called) {
|
|
1192
|
+
return result;
|
|
1193
|
+
}
|
|
1194
|
+
called = true;
|
|
1195
|
+
result = fn.apply(this, args);
|
|
1196
|
+
return result;
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
// src/function/debounce.ts
|
|
1201
|
+
function debounce(fn, delay2 = 0) {
|
|
1202
|
+
let timer;
|
|
1203
|
+
return function(...args) {
|
|
1204
|
+
if (timer) {
|
|
1205
|
+
clearTimeout(timer);
|
|
1206
|
+
}
|
|
1207
|
+
timer = setTimeout(() => {
|
|
1208
|
+
fn.apply(this, args);
|
|
1209
|
+
}, delay2);
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
// src/function/throttle.ts
|
|
1214
|
+
function throttle(fn, delay2 = 200) {
|
|
1215
|
+
let timer;
|
|
1216
|
+
let start = 0;
|
|
1217
|
+
return function loop(...args) {
|
|
1218
|
+
const now = performance.now();
|
|
1219
|
+
const elapsed = now - start;
|
|
1220
|
+
if (!start) {
|
|
1221
|
+
start = now;
|
|
1222
|
+
}
|
|
1223
|
+
if (timer) {
|
|
1224
|
+
clearTimeout(timer);
|
|
1225
|
+
}
|
|
1226
|
+
if (elapsed >= delay2) {
|
|
1227
|
+
fn.apply(this, args);
|
|
1228
|
+
start = now;
|
|
1229
|
+
} else {
|
|
1230
|
+
timer = setTimeout(() => {
|
|
1231
|
+
loop.apply(this, args);
|
|
1232
|
+
}, delay2 - elapsed);
|
|
1233
|
+
}
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
// src/function/NOOP.ts
|
|
1238
|
+
function NOOP() {
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
// src/function/callOrReturn.ts
|
|
1242
|
+
function callOrReturn(fnOrValue, ...args) {
|
|
1243
|
+
if (isFunction(fnOrValue)) {
|
|
1244
|
+
return fnOrValue(...args);
|
|
1245
|
+
}
|
|
1246
|
+
return fnOrValue;
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
// src/util/enumOf.ts
|
|
1250
|
+
function enumOf(config) {
|
|
1251
|
+
const extractValues = Object.entries(config).reduce((result, [key3, value]) => {
|
|
1252
|
+
result[key3] = isPlainObject(value) ? value.value : value;
|
|
1253
|
+
return result;
|
|
1254
|
+
}, {});
|
|
1255
|
+
const configValues = Object.values(config);
|
|
1256
|
+
function label(v) {
|
|
1257
|
+
const valueObject = getValueObject(v);
|
|
1258
|
+
return (valueObject == null ? void 0 : valueObject.label) ? callOrReturn(valueObject.label) : "";
|
|
1259
|
+
}
|
|
1260
|
+
function description(v) {
|
|
1261
|
+
const valueObject = getValueObject(v);
|
|
1262
|
+
return (valueObject == null ? void 0 : valueObject.description) ? callOrReturn(valueObject.description) : "";
|
|
1263
|
+
}
|
|
1264
|
+
function values() {
|
|
1265
|
+
return configValues.map((option2) => isPlainObject(option2) ? option2.value : option2);
|
|
1266
|
+
}
|
|
1267
|
+
function labels() {
|
|
1268
|
+
return configValues.map((option2) => {
|
|
1269
|
+
if (isPlainObject(option2)) {
|
|
1270
|
+
return option2.label ? callOrReturn(option2.label) : "";
|
|
1271
|
+
}
|
|
1272
|
+
return "";
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
function descriptions() {
|
|
1276
|
+
return configValues.map((option2) => {
|
|
1277
|
+
if (isPlainObject(option2)) {
|
|
1278
|
+
return option2.description ? callOrReturn(option2.description) : "";
|
|
1279
|
+
}
|
|
1280
|
+
return "";
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
function resolveOption(option2) {
|
|
1284
|
+
const result = {};
|
|
1285
|
+
for (const key3 of Object.keys(option2)) {
|
|
1286
|
+
result[key3] = callOrReturn(option2[key3]);
|
|
1287
|
+
}
|
|
1288
|
+
return result;
|
|
1289
|
+
}
|
|
1290
|
+
function option(v) {
|
|
1291
|
+
const valueObject = getValueObject(v);
|
|
1292
|
+
if (valueObject) {
|
|
1293
|
+
return resolveOption(valueObject);
|
|
1294
|
+
}
|
|
1295
|
+
return {
|
|
1296
|
+
value: v,
|
|
1297
|
+
label: "",
|
|
1298
|
+
description: ""
|
|
1299
|
+
};
|
|
1300
|
+
}
|
|
1301
|
+
function options() {
|
|
1302
|
+
return configValues.map((option2) => {
|
|
1303
|
+
if (isPlainObject(option2)) {
|
|
1304
|
+
return resolveOption(option2);
|
|
1305
|
+
}
|
|
1306
|
+
return {
|
|
1307
|
+
value: option2,
|
|
1308
|
+
label: "",
|
|
1309
|
+
description: ""
|
|
1310
|
+
};
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
function getValueObject(v) {
|
|
1314
|
+
return configValues.find((option2) => isPlainObject(option2) && option2.value === v);
|
|
1315
|
+
}
|
|
1316
|
+
return __spreadProps(__spreadValues({}, extractValues), {
|
|
1317
|
+
values,
|
|
1318
|
+
label,
|
|
1319
|
+
description,
|
|
1320
|
+
labels,
|
|
1321
|
+
descriptions,
|
|
1322
|
+
option,
|
|
1323
|
+
options
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1174
1327
|
// src/util/motion.ts
|
|
1175
1328
|
function motion(options) {
|
|
1176
1329
|
const {
|
|
@@ -1347,79 +1500,6 @@ var import_mitt = __toESM(require("mitt"), 1);
|
|
|
1347
1500
|
// src/index.ts
|
|
1348
1501
|
__reExport(src_exports, util_exports, module.exports);
|
|
1349
1502
|
|
|
1350
|
-
// src/function/call.ts
|
|
1351
|
-
function call(fn, ...args) {
|
|
1352
|
-
if (isArray(fn)) {
|
|
1353
|
-
return fn.map((f) => f(...args));
|
|
1354
|
-
}
|
|
1355
|
-
if (fn) {
|
|
1356
|
-
return fn(...args);
|
|
1357
|
-
}
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
// src/function/once.ts
|
|
1361
|
-
function once(fn) {
|
|
1362
|
-
let called = false;
|
|
1363
|
-
let result;
|
|
1364
|
-
return function(...args) {
|
|
1365
|
-
if (called) {
|
|
1366
|
-
return result;
|
|
1367
|
-
}
|
|
1368
|
-
called = true;
|
|
1369
|
-
result = fn.apply(this, args);
|
|
1370
|
-
return result;
|
|
1371
|
-
};
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
// src/function/debounce.ts
|
|
1375
|
-
function debounce(fn, delay2 = 0) {
|
|
1376
|
-
let timer;
|
|
1377
|
-
return function(...args) {
|
|
1378
|
-
if (timer) {
|
|
1379
|
-
clearTimeout(timer);
|
|
1380
|
-
}
|
|
1381
|
-
timer = setTimeout(() => {
|
|
1382
|
-
fn.apply(this, args);
|
|
1383
|
-
}, delay2);
|
|
1384
|
-
};
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
// src/function/throttle.ts
|
|
1388
|
-
function throttle(fn, delay2 = 200) {
|
|
1389
|
-
let timer;
|
|
1390
|
-
let start = 0;
|
|
1391
|
-
return function loop(...args) {
|
|
1392
|
-
const now = performance.now();
|
|
1393
|
-
const elapsed = now - start;
|
|
1394
|
-
if (!start) {
|
|
1395
|
-
start = now;
|
|
1396
|
-
}
|
|
1397
|
-
if (timer) {
|
|
1398
|
-
clearTimeout(timer);
|
|
1399
|
-
}
|
|
1400
|
-
if (elapsed >= delay2) {
|
|
1401
|
-
fn.apply(this, args);
|
|
1402
|
-
start = now;
|
|
1403
|
-
} else {
|
|
1404
|
-
timer = setTimeout(() => {
|
|
1405
|
-
loop.apply(this, args);
|
|
1406
|
-
}, delay2 - elapsed);
|
|
1407
|
-
}
|
|
1408
|
-
};
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1411
|
-
// src/function/NOOP.ts
|
|
1412
|
-
function NOOP() {
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
// src/function/callOrReturn.ts
|
|
1416
|
-
function callOrReturn(fnOrValue, ...args) {
|
|
1417
|
-
if (isFunction(fnOrValue)) {
|
|
1418
|
-
return fnOrValue(...args);
|
|
1419
|
-
}
|
|
1420
|
-
return fnOrValue;
|
|
1421
|
-
}
|
|
1422
|
-
|
|
1423
1503
|
// src/collection/cloneDeepWith.ts
|
|
1424
1504
|
function cloneDeepWith(value, fn) {
|
|
1425
1505
|
const cache = /* @__PURE__ */ new WeakMap();
|
|
@@ -1712,6 +1792,7 @@ function ceil(val, precision = 0) {
|
|
|
1712
1792
|
duration,
|
|
1713
1793
|
ensurePrefix,
|
|
1714
1794
|
ensureSuffix,
|
|
1795
|
+
enumOf,
|
|
1715
1796
|
find,
|
|
1716
1797
|
floor,
|
|
1717
1798
|
genNumberKey,
|
package/lib/index.d.cts
CHANGED
|
@@ -120,6 +120,51 @@ declare function tryParseJSON<T>(json: string): T | undefined;
|
|
|
120
120
|
|
|
121
121
|
declare function download(val: string | Blob | File, filename?: string): void;
|
|
122
122
|
|
|
123
|
+
type ValueOf<T> = T[keyof T];
|
|
124
|
+
type EnumOfValue = string | number | boolean;
|
|
125
|
+
type EnumOfStringOrGetter = string | (() => string);
|
|
126
|
+
type EnumOfValueObject = {
|
|
127
|
+
value: EnumOfValue;
|
|
128
|
+
label?: EnumOfStringOrGetter;
|
|
129
|
+
description?: EnumOfStringOrGetter;
|
|
130
|
+
};
|
|
131
|
+
type EnumOfConfigValue = EnumOfValue | (EnumOfValueObject & Record<string, unknown>);
|
|
132
|
+
type EnumOfNormalizeToOption<V> = V extends {
|
|
133
|
+
value: unknown;
|
|
134
|
+
} ? V : {
|
|
135
|
+
value: V;
|
|
136
|
+
label?: EnumOfStringOrGetter;
|
|
137
|
+
description?: EnumOfStringOrGetter;
|
|
138
|
+
};
|
|
139
|
+
type EnumOfResolvedField<V> = V extends (...args: any[]) => infer R ? R : V;
|
|
140
|
+
type EnumOfResolvedOption<O> = O extends unknown ? {
|
|
141
|
+
[K in keyof O]: EnumOfResolvedField<O[K]>;
|
|
142
|
+
} : never;
|
|
143
|
+
type EnumOfExtractOptionShape<T extends Record<string, EnumOfConfigValue>> = EnumOfResolvedOption<EnumOfNormalizeToOption<ValueOf<T>>>;
|
|
144
|
+
type EnumOfExtractValues<T extends object> = {
|
|
145
|
+
[P in keyof T]: T[P] extends {
|
|
146
|
+
value: infer V;
|
|
147
|
+
} ? V : T[P];
|
|
148
|
+
};
|
|
149
|
+
type EnumOfKeyForValue<T extends object, V> = {
|
|
150
|
+
[K in keyof T]: EnumOfExtractValues<T>[K] extends V ? (V extends EnumOfExtractValues<T>[K] ? K : never) : never;
|
|
151
|
+
}[keyof T];
|
|
152
|
+
type EnumOfOptionForValue<T extends Record<string, EnumOfConfigValue>, Value> = Value extends infer V ? EnumOfKeyForValue<T, V> extends keyof T ? EnumOfResolvedOption<EnumOfNormalizeToOption<T[EnumOfKeyForValue<T, V>]>> : EnumOfExtractOptionShape<T> : never;
|
|
153
|
+
type EnumOfResultMethods<V, T extends Record<string, EnumOfConfigValue>> = {
|
|
154
|
+
values(): V[];
|
|
155
|
+
label(v: V): string;
|
|
156
|
+
labels(): string[];
|
|
157
|
+
description(v: V): string;
|
|
158
|
+
descriptions(): string[];
|
|
159
|
+
option<Value extends V>(v: Value): EnumOfOptionForValue<T, Value>;
|
|
160
|
+
options(): EnumOfExtractOptionShape<T>[];
|
|
161
|
+
};
|
|
162
|
+
type EnumOfResult<T extends Record<string, EnumOfConfigValue>> = EnumOfExtractValues<T> & EnumOfResultMethods<ValueOf<EnumOfExtractValues<T>>, T>;
|
|
163
|
+
declare function enumOf<const T extends Record<string, EnumOfConfigValue>>(config: T): EnumOfResult<T>;
|
|
164
|
+
type EnumOf<T extends {
|
|
165
|
+
values: () => any[];
|
|
166
|
+
}> = ReturnType<T['values']>[number];
|
|
167
|
+
|
|
123
168
|
interface MotionOptions {
|
|
124
169
|
from: number;
|
|
125
170
|
to: number;
|
|
@@ -339,4 +384,4 @@ declare function floor(val: number, precision?: number): number;
|
|
|
339
384
|
|
|
340
385
|
declare function ceil(val: number, precision?: number): number;
|
|
341
386
|
|
|
342
|
-
export { type BEM, type ClassName, type Classes, type CreateCacheManagerOptions, type DurationContext, type Motion, type MotionOptions, type MotionState, NOOP, type PromiseWithResolvers, type Storage, assert, at, baseRound, call, callOrReturn, camelize, cancelAnimationFrame, ceil, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createCacheManager, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, download, duration, ensurePrefix, ensureSuffix, find, floor, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, hasDuplicates, hasDuplicatesBy, hasOwn, inBrowser, inMobile, inViewport, intersection, intersectionWith, isArray, isArrayBuffer, isBlob, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEmptyPlainObject, isEqual, isEqualWith, isError, isFile, isFunction, isMap, isNonEmptyArray, isNullish, isNumber, isNumeric, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isTruthy, isTypedArray, isWeakMap, isWeakSet, isWindow, kebabCase, localStorage, lowerFirst, mapObject, maxBy, mean, meanBy, merge, mergeWith, minBy, motion, normalizeToArray, objectEntries, objectKeys, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, promiseWithResolvers, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, removeItemBy, removeItemsBy, requestAnimationFrame, round, sample, sessionStorage, set, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst, xor, xorWith };
|
|
387
|
+
export { type BEM, type ClassName, type Classes, type CreateCacheManagerOptions, type DurationContext, type EnumOf, type EnumOfConfigValue, type EnumOfExtractOptionShape, type EnumOfExtractValues, type EnumOfKeyForValue, type EnumOfNormalizeToOption, type EnumOfOptionForValue, type EnumOfResolvedField, type EnumOfResolvedOption, type EnumOfResult, type EnumOfResultMethods, type EnumOfStringOrGetter, type EnumOfValue, type EnumOfValueObject, type Motion, type MotionOptions, type MotionState, NOOP, type PromiseWithResolvers, type Storage, assert, at, baseRound, call, callOrReturn, camelize, cancelAnimationFrame, ceil, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createCacheManager, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, download, duration, ensurePrefix, ensureSuffix, enumOf, find, floor, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, hasDuplicates, hasDuplicatesBy, hasOwn, inBrowser, inMobile, inViewport, intersection, intersectionWith, isArray, isArrayBuffer, isBlob, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEmptyPlainObject, isEqual, isEqualWith, isError, isFile, isFunction, isMap, isNonEmptyArray, isNullish, isNumber, isNumeric, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isTruthy, isTypedArray, isWeakMap, isWeakSet, isWindow, kebabCase, localStorage, lowerFirst, mapObject, maxBy, mean, meanBy, merge, mergeWith, minBy, motion, normalizeToArray, objectEntries, objectKeys, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, promiseWithResolvers, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, removeItemBy, removeItemsBy, requestAnimationFrame, round, sample, sessionStorage, set, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst, xor, xorWith };
|
package/lib/index.d.ts
CHANGED
|
@@ -120,6 +120,51 @@ declare function tryParseJSON<T>(json: string): T | undefined;
|
|
|
120
120
|
|
|
121
121
|
declare function download(val: string | Blob | File, filename?: string): void;
|
|
122
122
|
|
|
123
|
+
type ValueOf<T> = T[keyof T];
|
|
124
|
+
type EnumOfValue = string | number | boolean;
|
|
125
|
+
type EnumOfStringOrGetter = string | (() => string);
|
|
126
|
+
type EnumOfValueObject = {
|
|
127
|
+
value: EnumOfValue;
|
|
128
|
+
label?: EnumOfStringOrGetter;
|
|
129
|
+
description?: EnumOfStringOrGetter;
|
|
130
|
+
};
|
|
131
|
+
type EnumOfConfigValue = EnumOfValue | (EnumOfValueObject & Record<string, unknown>);
|
|
132
|
+
type EnumOfNormalizeToOption<V> = V extends {
|
|
133
|
+
value: unknown;
|
|
134
|
+
} ? V : {
|
|
135
|
+
value: V;
|
|
136
|
+
label?: EnumOfStringOrGetter;
|
|
137
|
+
description?: EnumOfStringOrGetter;
|
|
138
|
+
};
|
|
139
|
+
type EnumOfResolvedField<V> = V extends (...args: any[]) => infer R ? R : V;
|
|
140
|
+
type EnumOfResolvedOption<O> = O extends unknown ? {
|
|
141
|
+
[K in keyof O]: EnumOfResolvedField<O[K]>;
|
|
142
|
+
} : never;
|
|
143
|
+
type EnumOfExtractOptionShape<T extends Record<string, EnumOfConfigValue>> = EnumOfResolvedOption<EnumOfNormalizeToOption<ValueOf<T>>>;
|
|
144
|
+
type EnumOfExtractValues<T extends object> = {
|
|
145
|
+
[P in keyof T]: T[P] extends {
|
|
146
|
+
value: infer V;
|
|
147
|
+
} ? V : T[P];
|
|
148
|
+
};
|
|
149
|
+
type EnumOfKeyForValue<T extends object, V> = {
|
|
150
|
+
[K in keyof T]: EnumOfExtractValues<T>[K] extends V ? (V extends EnumOfExtractValues<T>[K] ? K : never) : never;
|
|
151
|
+
}[keyof T];
|
|
152
|
+
type EnumOfOptionForValue<T extends Record<string, EnumOfConfigValue>, Value> = Value extends infer V ? EnumOfKeyForValue<T, V> extends keyof T ? EnumOfResolvedOption<EnumOfNormalizeToOption<T[EnumOfKeyForValue<T, V>]>> : EnumOfExtractOptionShape<T> : never;
|
|
153
|
+
type EnumOfResultMethods<V, T extends Record<string, EnumOfConfigValue>> = {
|
|
154
|
+
values(): V[];
|
|
155
|
+
label(v: V): string;
|
|
156
|
+
labels(): string[];
|
|
157
|
+
description(v: V): string;
|
|
158
|
+
descriptions(): string[];
|
|
159
|
+
option<Value extends V>(v: Value): EnumOfOptionForValue<T, Value>;
|
|
160
|
+
options(): EnumOfExtractOptionShape<T>[];
|
|
161
|
+
};
|
|
162
|
+
type EnumOfResult<T extends Record<string, EnumOfConfigValue>> = EnumOfExtractValues<T> & EnumOfResultMethods<ValueOf<EnumOfExtractValues<T>>, T>;
|
|
163
|
+
declare function enumOf<const T extends Record<string, EnumOfConfigValue>>(config: T): EnumOfResult<T>;
|
|
164
|
+
type EnumOf<T extends {
|
|
165
|
+
values: () => any[];
|
|
166
|
+
}> = ReturnType<T['values']>[number];
|
|
167
|
+
|
|
123
168
|
interface MotionOptions {
|
|
124
169
|
from: number;
|
|
125
170
|
to: number;
|
|
@@ -339,4 +384,4 @@ declare function floor(val: number, precision?: number): number;
|
|
|
339
384
|
|
|
340
385
|
declare function ceil(val: number, precision?: number): number;
|
|
341
386
|
|
|
342
|
-
export { type BEM, type ClassName, type Classes, type CreateCacheManagerOptions, type DurationContext, type Motion, type MotionOptions, type MotionState, NOOP, type PromiseWithResolvers, type Storage, assert, at, baseRound, call, callOrReturn, camelize, cancelAnimationFrame, ceil, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createCacheManager, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, download, duration, ensurePrefix, ensureSuffix, find, floor, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, hasDuplicates, hasDuplicatesBy, hasOwn, inBrowser, inMobile, inViewport, intersection, intersectionWith, isArray, isArrayBuffer, isBlob, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEmptyPlainObject, isEqual, isEqualWith, isError, isFile, isFunction, isMap, isNonEmptyArray, isNullish, isNumber, isNumeric, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isTruthy, isTypedArray, isWeakMap, isWeakSet, isWindow, kebabCase, localStorage, lowerFirst, mapObject, maxBy, mean, meanBy, merge, mergeWith, minBy, motion, normalizeToArray, objectEntries, objectKeys, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, promiseWithResolvers, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, removeItemBy, removeItemsBy, requestAnimationFrame, round, sample, sessionStorage, set, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst, xor, xorWith };
|
|
387
|
+
export { type BEM, type ClassName, type Classes, type CreateCacheManagerOptions, type DurationContext, type EnumOf, type EnumOfConfigValue, type EnumOfExtractOptionShape, type EnumOfExtractValues, type EnumOfKeyForValue, type EnumOfNormalizeToOption, type EnumOfOptionForValue, type EnumOfResolvedField, type EnumOfResolvedOption, type EnumOfResult, type EnumOfResultMethods, type EnumOfStringOrGetter, type EnumOfValue, type EnumOfValueObject, type Motion, type MotionOptions, type MotionState, NOOP, type PromiseWithResolvers, type Storage, assert, at, baseRound, call, callOrReturn, camelize, cancelAnimationFrame, ceil, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createCacheManager, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, download, duration, ensurePrefix, ensureSuffix, enumOf, find, floor, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, hasDuplicates, hasDuplicatesBy, hasOwn, inBrowser, inMobile, inViewport, intersection, intersectionWith, isArray, isArrayBuffer, isBlob, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEmptyPlainObject, isEqual, isEqualWith, isError, isFile, isFunction, isMap, isNonEmptyArray, isNullish, isNumber, isNumeric, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isTruthy, isTypedArray, isWeakMap, isWeakSet, isWindow, kebabCase, localStorage, lowerFirst, mapObject, maxBy, mean, meanBy, merge, mergeWith, minBy, motion, normalizeToArray, objectEntries, objectKeys, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, promiseWithResolvers, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, removeItemBy, removeItemsBy, requestAnimationFrame, round, sample, sessionStorage, set, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst, xor, xorWith };
|
package/lib/index.global.js
CHANGED
|
@@ -66,6 +66,7 @@ var Rattail = (() => {
|
|
|
66
66
|
duration: () => duration,
|
|
67
67
|
ensurePrefix: () => ensurePrefix,
|
|
68
68
|
ensureSuffix: () => ensureSuffix,
|
|
69
|
+
enumOf: () => enumOf,
|
|
69
70
|
find: () => find,
|
|
70
71
|
floor: () => floor,
|
|
71
72
|
genNumberKey: () => genNumberKey,
|
|
@@ -1130,6 +1131,157 @@ var Rattail = (() => {
|
|
|
1130
1131
|
document.body.removeChild(a);
|
|
1131
1132
|
}
|
|
1132
1133
|
|
|
1134
|
+
// src/function/call.ts
|
|
1135
|
+
function call(fn, ...args) {
|
|
1136
|
+
if (isArray(fn)) {
|
|
1137
|
+
return fn.map((f) => f(...args));
|
|
1138
|
+
}
|
|
1139
|
+
if (fn) {
|
|
1140
|
+
return fn(...args);
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
// src/function/once.ts
|
|
1145
|
+
function once(fn) {
|
|
1146
|
+
let called = false;
|
|
1147
|
+
let result;
|
|
1148
|
+
return function(...args) {
|
|
1149
|
+
if (called) {
|
|
1150
|
+
return result;
|
|
1151
|
+
}
|
|
1152
|
+
called = true;
|
|
1153
|
+
result = fn.apply(this, args);
|
|
1154
|
+
return result;
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
// src/function/debounce.ts
|
|
1159
|
+
function debounce(fn, delay2 = 0) {
|
|
1160
|
+
let timer;
|
|
1161
|
+
return function(...args) {
|
|
1162
|
+
if (timer) {
|
|
1163
|
+
clearTimeout(timer);
|
|
1164
|
+
}
|
|
1165
|
+
timer = setTimeout(() => {
|
|
1166
|
+
fn.apply(this, args);
|
|
1167
|
+
}, delay2);
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
// src/function/throttle.ts
|
|
1172
|
+
function throttle(fn, delay2 = 200) {
|
|
1173
|
+
let timer;
|
|
1174
|
+
let start = 0;
|
|
1175
|
+
return function loop(...args) {
|
|
1176
|
+
const now = performance.now();
|
|
1177
|
+
const elapsed = now - start;
|
|
1178
|
+
if (!start) {
|
|
1179
|
+
start = now;
|
|
1180
|
+
}
|
|
1181
|
+
if (timer) {
|
|
1182
|
+
clearTimeout(timer);
|
|
1183
|
+
}
|
|
1184
|
+
if (elapsed >= delay2) {
|
|
1185
|
+
fn.apply(this, args);
|
|
1186
|
+
start = now;
|
|
1187
|
+
} else {
|
|
1188
|
+
timer = setTimeout(() => {
|
|
1189
|
+
loop.apply(this, args);
|
|
1190
|
+
}, delay2 - elapsed);
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
// src/function/NOOP.ts
|
|
1196
|
+
function NOOP() {
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
// src/function/callOrReturn.ts
|
|
1200
|
+
function callOrReturn(fnOrValue, ...args) {
|
|
1201
|
+
if (isFunction(fnOrValue)) {
|
|
1202
|
+
return fnOrValue(...args);
|
|
1203
|
+
}
|
|
1204
|
+
return fnOrValue;
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
// src/util/enumOf.ts
|
|
1208
|
+
function enumOf(config) {
|
|
1209
|
+
const extractValues = Object.entries(config).reduce((result, [key3, value]) => {
|
|
1210
|
+
result[key3] = isPlainObject(value) ? value.value : value;
|
|
1211
|
+
return result;
|
|
1212
|
+
}, {});
|
|
1213
|
+
const configValues = Object.values(config);
|
|
1214
|
+
function label(v) {
|
|
1215
|
+
const valueObject = getValueObject(v);
|
|
1216
|
+
return (valueObject == null ? void 0 : valueObject.label) ? callOrReturn(valueObject.label) : "";
|
|
1217
|
+
}
|
|
1218
|
+
function description(v) {
|
|
1219
|
+
const valueObject = getValueObject(v);
|
|
1220
|
+
return (valueObject == null ? void 0 : valueObject.description) ? callOrReturn(valueObject.description) : "";
|
|
1221
|
+
}
|
|
1222
|
+
function values() {
|
|
1223
|
+
return configValues.map((option2) => isPlainObject(option2) ? option2.value : option2);
|
|
1224
|
+
}
|
|
1225
|
+
function labels() {
|
|
1226
|
+
return configValues.map((option2) => {
|
|
1227
|
+
if (isPlainObject(option2)) {
|
|
1228
|
+
return option2.label ? callOrReturn(option2.label) : "";
|
|
1229
|
+
}
|
|
1230
|
+
return "";
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
function descriptions() {
|
|
1234
|
+
return configValues.map((option2) => {
|
|
1235
|
+
if (isPlainObject(option2)) {
|
|
1236
|
+
return option2.description ? callOrReturn(option2.description) : "";
|
|
1237
|
+
}
|
|
1238
|
+
return "";
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
function resolveOption(option2) {
|
|
1242
|
+
const result = {};
|
|
1243
|
+
for (const key3 of Object.keys(option2)) {
|
|
1244
|
+
result[key3] = callOrReturn(option2[key3]);
|
|
1245
|
+
}
|
|
1246
|
+
return result;
|
|
1247
|
+
}
|
|
1248
|
+
function option(v) {
|
|
1249
|
+
const valueObject = getValueObject(v);
|
|
1250
|
+
if (valueObject) {
|
|
1251
|
+
return resolveOption(valueObject);
|
|
1252
|
+
}
|
|
1253
|
+
return {
|
|
1254
|
+
value: v,
|
|
1255
|
+
label: "",
|
|
1256
|
+
description: ""
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
function options() {
|
|
1260
|
+
return configValues.map((option2) => {
|
|
1261
|
+
if (isPlainObject(option2)) {
|
|
1262
|
+
return resolveOption(option2);
|
|
1263
|
+
}
|
|
1264
|
+
return {
|
|
1265
|
+
value: option2,
|
|
1266
|
+
label: "",
|
|
1267
|
+
description: ""
|
|
1268
|
+
};
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
function getValueObject(v) {
|
|
1272
|
+
return configValues.find((option2) => isPlainObject(option2) && option2.value === v);
|
|
1273
|
+
}
|
|
1274
|
+
return __spreadProps(__spreadValues({}, extractValues), {
|
|
1275
|
+
values,
|
|
1276
|
+
label,
|
|
1277
|
+
description,
|
|
1278
|
+
labels,
|
|
1279
|
+
descriptions,
|
|
1280
|
+
option,
|
|
1281
|
+
options
|
|
1282
|
+
});
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1133
1285
|
// src/util/motion.ts
|
|
1134
1286
|
function motion(options) {
|
|
1135
1287
|
const {
|
|
@@ -1317,79 +1469,6 @@ var Rattail = (() => {
|
|
|
1317
1469
|
} };
|
|
1318
1470
|
}
|
|
1319
1471
|
|
|
1320
|
-
// src/function/call.ts
|
|
1321
|
-
function call(fn, ...args) {
|
|
1322
|
-
if (isArray(fn)) {
|
|
1323
|
-
return fn.map((f) => f(...args));
|
|
1324
|
-
}
|
|
1325
|
-
if (fn) {
|
|
1326
|
-
return fn(...args);
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
// src/function/once.ts
|
|
1331
|
-
function once(fn) {
|
|
1332
|
-
let called = false;
|
|
1333
|
-
let result;
|
|
1334
|
-
return function(...args) {
|
|
1335
|
-
if (called) {
|
|
1336
|
-
return result;
|
|
1337
|
-
}
|
|
1338
|
-
called = true;
|
|
1339
|
-
result = fn.apply(this, args);
|
|
1340
|
-
return result;
|
|
1341
|
-
};
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
|
-
// src/function/debounce.ts
|
|
1345
|
-
function debounce(fn, delay2 = 0) {
|
|
1346
|
-
let timer;
|
|
1347
|
-
return function(...args) {
|
|
1348
|
-
if (timer) {
|
|
1349
|
-
clearTimeout(timer);
|
|
1350
|
-
}
|
|
1351
|
-
timer = setTimeout(() => {
|
|
1352
|
-
fn.apply(this, args);
|
|
1353
|
-
}, delay2);
|
|
1354
|
-
};
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
// src/function/throttle.ts
|
|
1358
|
-
function throttle(fn, delay2 = 200) {
|
|
1359
|
-
let timer;
|
|
1360
|
-
let start = 0;
|
|
1361
|
-
return function loop(...args) {
|
|
1362
|
-
const now = performance.now();
|
|
1363
|
-
const elapsed = now - start;
|
|
1364
|
-
if (!start) {
|
|
1365
|
-
start = now;
|
|
1366
|
-
}
|
|
1367
|
-
if (timer) {
|
|
1368
|
-
clearTimeout(timer);
|
|
1369
|
-
}
|
|
1370
|
-
if (elapsed >= delay2) {
|
|
1371
|
-
fn.apply(this, args);
|
|
1372
|
-
start = now;
|
|
1373
|
-
} else {
|
|
1374
|
-
timer = setTimeout(() => {
|
|
1375
|
-
loop.apply(this, args);
|
|
1376
|
-
}, delay2 - elapsed);
|
|
1377
|
-
}
|
|
1378
|
-
};
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
// src/function/NOOP.ts
|
|
1382
|
-
function NOOP() {
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
|
-
// src/function/callOrReturn.ts
|
|
1386
|
-
function callOrReturn(fnOrValue, ...args) {
|
|
1387
|
-
if (isFunction(fnOrValue)) {
|
|
1388
|
-
return fnOrValue(...args);
|
|
1389
|
-
}
|
|
1390
|
-
return fnOrValue;
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
1472
|
// src/collection/cloneDeepWith.ts
|
|
1394
1473
|
function cloneDeepWith(value, fn) {
|
|
1395
1474
|
const cache = /* @__PURE__ */ new WeakMap();
|
package/lib/index.js
CHANGED
|
@@ -64,6 +64,7 @@ __export(src_exports, {
|
|
|
64
64
|
duration: () => duration,
|
|
65
65
|
ensurePrefix: () => ensurePrefix,
|
|
66
66
|
ensureSuffix: () => ensureSuffix,
|
|
67
|
+
enumOf: () => enumOf,
|
|
67
68
|
find: () => find,
|
|
68
69
|
floor: () => floor,
|
|
69
70
|
genNumberKey: () => genNumberKey,
|
|
@@ -849,6 +850,7 @@ __export(util_exports, {
|
|
|
849
850
|
doubleRaf: () => doubleRaf,
|
|
850
851
|
download: () => download,
|
|
851
852
|
duration: () => duration,
|
|
853
|
+
enumOf: () => enumOf,
|
|
852
854
|
getAllParentScroller: () => getAllParentScroller,
|
|
853
855
|
getParentScroller: () => getParentScroller,
|
|
854
856
|
getRect: () => getRect,
|
|
@@ -1158,6 +1160,157 @@ function download(val, filename = "file") {
|
|
|
1158
1160
|
document.body.removeChild(a);
|
|
1159
1161
|
}
|
|
1160
1162
|
|
|
1163
|
+
// src/function/call.ts
|
|
1164
|
+
function call(fn, ...args) {
|
|
1165
|
+
if (isArray(fn)) {
|
|
1166
|
+
return fn.map((f) => f(...args));
|
|
1167
|
+
}
|
|
1168
|
+
if (fn) {
|
|
1169
|
+
return fn(...args);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
// src/function/once.ts
|
|
1174
|
+
function once(fn) {
|
|
1175
|
+
let called = false;
|
|
1176
|
+
let result;
|
|
1177
|
+
return function(...args) {
|
|
1178
|
+
if (called) {
|
|
1179
|
+
return result;
|
|
1180
|
+
}
|
|
1181
|
+
called = true;
|
|
1182
|
+
result = fn.apply(this, args);
|
|
1183
|
+
return result;
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
// src/function/debounce.ts
|
|
1188
|
+
function debounce(fn, delay2 = 0) {
|
|
1189
|
+
let timer;
|
|
1190
|
+
return function(...args) {
|
|
1191
|
+
if (timer) {
|
|
1192
|
+
clearTimeout(timer);
|
|
1193
|
+
}
|
|
1194
|
+
timer = setTimeout(() => {
|
|
1195
|
+
fn.apply(this, args);
|
|
1196
|
+
}, delay2);
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
// src/function/throttle.ts
|
|
1201
|
+
function throttle(fn, delay2 = 200) {
|
|
1202
|
+
let timer;
|
|
1203
|
+
let start = 0;
|
|
1204
|
+
return function loop(...args) {
|
|
1205
|
+
const now = performance.now();
|
|
1206
|
+
const elapsed = now - start;
|
|
1207
|
+
if (!start) {
|
|
1208
|
+
start = now;
|
|
1209
|
+
}
|
|
1210
|
+
if (timer) {
|
|
1211
|
+
clearTimeout(timer);
|
|
1212
|
+
}
|
|
1213
|
+
if (elapsed >= delay2) {
|
|
1214
|
+
fn.apply(this, args);
|
|
1215
|
+
start = now;
|
|
1216
|
+
} else {
|
|
1217
|
+
timer = setTimeout(() => {
|
|
1218
|
+
loop.apply(this, args);
|
|
1219
|
+
}, delay2 - elapsed);
|
|
1220
|
+
}
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
// src/function/NOOP.ts
|
|
1225
|
+
function NOOP() {
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
// src/function/callOrReturn.ts
|
|
1229
|
+
function callOrReturn(fnOrValue, ...args) {
|
|
1230
|
+
if (isFunction(fnOrValue)) {
|
|
1231
|
+
return fnOrValue(...args);
|
|
1232
|
+
}
|
|
1233
|
+
return fnOrValue;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
// src/util/enumOf.ts
|
|
1237
|
+
function enumOf(config) {
|
|
1238
|
+
const extractValues = Object.entries(config).reduce((result, [key3, value]) => {
|
|
1239
|
+
result[key3] = isPlainObject(value) ? value.value : value;
|
|
1240
|
+
return result;
|
|
1241
|
+
}, {});
|
|
1242
|
+
const configValues = Object.values(config);
|
|
1243
|
+
function label(v) {
|
|
1244
|
+
const valueObject = getValueObject(v);
|
|
1245
|
+
return (valueObject == null ? void 0 : valueObject.label) ? callOrReturn(valueObject.label) : "";
|
|
1246
|
+
}
|
|
1247
|
+
function description(v) {
|
|
1248
|
+
const valueObject = getValueObject(v);
|
|
1249
|
+
return (valueObject == null ? void 0 : valueObject.description) ? callOrReturn(valueObject.description) : "";
|
|
1250
|
+
}
|
|
1251
|
+
function values() {
|
|
1252
|
+
return configValues.map((option2) => isPlainObject(option2) ? option2.value : option2);
|
|
1253
|
+
}
|
|
1254
|
+
function labels() {
|
|
1255
|
+
return configValues.map((option2) => {
|
|
1256
|
+
if (isPlainObject(option2)) {
|
|
1257
|
+
return option2.label ? callOrReturn(option2.label) : "";
|
|
1258
|
+
}
|
|
1259
|
+
return "";
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
function descriptions() {
|
|
1263
|
+
return configValues.map((option2) => {
|
|
1264
|
+
if (isPlainObject(option2)) {
|
|
1265
|
+
return option2.description ? callOrReturn(option2.description) : "";
|
|
1266
|
+
}
|
|
1267
|
+
return "";
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
function resolveOption(option2) {
|
|
1271
|
+
const result = {};
|
|
1272
|
+
for (const key3 of Object.keys(option2)) {
|
|
1273
|
+
result[key3] = callOrReturn(option2[key3]);
|
|
1274
|
+
}
|
|
1275
|
+
return result;
|
|
1276
|
+
}
|
|
1277
|
+
function option(v) {
|
|
1278
|
+
const valueObject = getValueObject(v);
|
|
1279
|
+
if (valueObject) {
|
|
1280
|
+
return resolveOption(valueObject);
|
|
1281
|
+
}
|
|
1282
|
+
return {
|
|
1283
|
+
value: v,
|
|
1284
|
+
label: "",
|
|
1285
|
+
description: ""
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
function options() {
|
|
1289
|
+
return configValues.map((option2) => {
|
|
1290
|
+
if (isPlainObject(option2)) {
|
|
1291
|
+
return resolveOption(option2);
|
|
1292
|
+
}
|
|
1293
|
+
return {
|
|
1294
|
+
value: option2,
|
|
1295
|
+
label: "",
|
|
1296
|
+
description: ""
|
|
1297
|
+
};
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1300
|
+
function getValueObject(v) {
|
|
1301
|
+
return configValues.find((option2) => isPlainObject(option2) && option2.value === v);
|
|
1302
|
+
}
|
|
1303
|
+
return __spreadProps(__spreadValues({}, extractValues), {
|
|
1304
|
+
values,
|
|
1305
|
+
label,
|
|
1306
|
+
description,
|
|
1307
|
+
labels,
|
|
1308
|
+
descriptions,
|
|
1309
|
+
option,
|
|
1310
|
+
options
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1161
1314
|
// src/util/motion.ts
|
|
1162
1315
|
function motion(options) {
|
|
1163
1316
|
const {
|
|
@@ -1335,79 +1488,6 @@ import { default as default2 } from "mitt";
|
|
|
1335
1488
|
// src/index.ts
|
|
1336
1489
|
__reExport(src_exports, util_exports);
|
|
1337
1490
|
|
|
1338
|
-
// src/function/call.ts
|
|
1339
|
-
function call(fn, ...args) {
|
|
1340
|
-
if (isArray(fn)) {
|
|
1341
|
-
return fn.map((f) => f(...args));
|
|
1342
|
-
}
|
|
1343
|
-
if (fn) {
|
|
1344
|
-
return fn(...args);
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
|
|
1348
|
-
// src/function/once.ts
|
|
1349
|
-
function once(fn) {
|
|
1350
|
-
let called = false;
|
|
1351
|
-
let result;
|
|
1352
|
-
return function(...args) {
|
|
1353
|
-
if (called) {
|
|
1354
|
-
return result;
|
|
1355
|
-
}
|
|
1356
|
-
called = true;
|
|
1357
|
-
result = fn.apply(this, args);
|
|
1358
|
-
return result;
|
|
1359
|
-
};
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
// src/function/debounce.ts
|
|
1363
|
-
function debounce(fn, delay2 = 0) {
|
|
1364
|
-
let timer;
|
|
1365
|
-
return function(...args) {
|
|
1366
|
-
if (timer) {
|
|
1367
|
-
clearTimeout(timer);
|
|
1368
|
-
}
|
|
1369
|
-
timer = setTimeout(() => {
|
|
1370
|
-
fn.apply(this, args);
|
|
1371
|
-
}, delay2);
|
|
1372
|
-
};
|
|
1373
|
-
}
|
|
1374
|
-
|
|
1375
|
-
// src/function/throttle.ts
|
|
1376
|
-
function throttle(fn, delay2 = 200) {
|
|
1377
|
-
let timer;
|
|
1378
|
-
let start = 0;
|
|
1379
|
-
return function loop(...args) {
|
|
1380
|
-
const now = performance.now();
|
|
1381
|
-
const elapsed = now - start;
|
|
1382
|
-
if (!start) {
|
|
1383
|
-
start = now;
|
|
1384
|
-
}
|
|
1385
|
-
if (timer) {
|
|
1386
|
-
clearTimeout(timer);
|
|
1387
|
-
}
|
|
1388
|
-
if (elapsed >= delay2) {
|
|
1389
|
-
fn.apply(this, args);
|
|
1390
|
-
start = now;
|
|
1391
|
-
} else {
|
|
1392
|
-
timer = setTimeout(() => {
|
|
1393
|
-
loop.apply(this, args);
|
|
1394
|
-
}, delay2 - elapsed);
|
|
1395
|
-
}
|
|
1396
|
-
};
|
|
1397
|
-
}
|
|
1398
|
-
|
|
1399
|
-
// src/function/NOOP.ts
|
|
1400
|
-
function NOOP() {
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
// src/function/callOrReturn.ts
|
|
1404
|
-
function callOrReturn(fnOrValue, ...args) {
|
|
1405
|
-
if (isFunction(fnOrValue)) {
|
|
1406
|
-
return fnOrValue(...args);
|
|
1407
|
-
}
|
|
1408
|
-
return fnOrValue;
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1411
1491
|
// src/collection/cloneDeepWith.ts
|
|
1412
1492
|
function cloneDeepWith(value, fn) {
|
|
1413
1493
|
const cache = /* @__PURE__ */ new WeakMap();
|
|
@@ -1699,6 +1779,7 @@ export {
|
|
|
1699
1779
|
duration,
|
|
1700
1780
|
ensurePrefix,
|
|
1701
1781
|
ensureSuffix,
|
|
1782
|
+
enumOf,
|
|
1702
1783
|
find,
|
|
1703
1784
|
floor,
|
|
1704
1785
|
genNumberKey,
|