@react-hive/honey-utils 3.14.0 → 3.16.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/README.md +6 -1
- package/dist/README.md +6 -1
- package/dist/file.d.ts +1 -17
- package/dist/geometry/apply-inertia-step.d.ts +134 -0
- package/dist/geometry/index.d.ts +2 -0
- package/dist/geometry/resolve-bounded-delta.d.ts +79 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +325 -29
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/string/find-char-indices.d.ts +15 -0
- package/dist/string/for-each-char.d.ts +43 -0
- package/dist/string/index.d.ts +3 -0
- package/dist/string/parse-file-name.d.ts +16 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -553,6 +553,9 @@ function divide(a: number, b: number): number {
|
|
|
553
553
|
- `toKebabCase(input: string): string` - Converts a string to kebab-case.
|
|
554
554
|
- `camelToDashCase(input: string): string` - Converts camelCase to dash-case.
|
|
555
555
|
- `splitStringIntoWords(input: string): string[]` - Splits a string into an array of words.
|
|
556
|
+
- `parseFileName(fileName: string): [baseName: string, extension: string]` - Splits a file name into its base name and extension using the last `.` as the separator. Handles edge cases such as hidden files (`.gitignore`), multi-dot names (`archive.tar.gz`), and names ending with a dot (`"file."`). The extension is returned in lowercase.
|
|
557
|
+
- `forEachChar(inputString: string, onChar: CharHandler, shouldSkipChar?: CharPredicate): void` - Iterates over each character of a string (UTF-16 code units) and invokes a callback for each character. Provides contextual information such as the character index and adjacent characters, and supports optional conditional skipping via a predicate.
|
|
558
|
+
- `findCharIndices(inputString: string, targetChar: string): number[]` - Returns all zero-based indices where a given single character occurs in the input string. Operates on UTF-16 code units and returns an empty array if the character is not found.
|
|
556
559
|
|
|
557
560
|
### Object Utilities
|
|
558
561
|
|
|
@@ -631,6 +634,9 @@ function divide(a: number, b: number): number {
|
|
|
631
634
|
|
|
632
635
|
---
|
|
633
636
|
|
|
637
|
+
- `resolveBoundedDelta(options: ResolveBoundedDeltaOptions): Nullable<number>` – Resolves the next numeric value by consuming a delta within fixed bounds. Prevents overshoot, partially consumes deltas at boundaries, and returns `null` when movement in the given direction is no longer possible. Useful for drag constraints, sliders, synthetic scrolling, and inertia systems.
|
|
638
|
+
- `applyInertiaStep(options: ApplyInertiaStepOptions): Nullable<{ value: number; velocity: number }>` – Applies a single inertia step on top of bounded delta resolution using velocity integration and exponential friction. Intended to be called from an animation loop (e.g. `requestAnimationFrame`) to implement momentum-based scrolling, sliders, or carousels. Returns updated value and velocity, or `null` when inertia has completed.
|
|
639
|
+
|
|
634
640
|
#### Layout
|
|
635
641
|
|
|
636
642
|
- `calculateCenterOffset(options: CalculateCenterOffsetOptions): number` - Calculates a clamped offset value that centers an element within a container along a single axis. Returns a negative value suitable for use in a CSS `translate` transform, or `0` when no overflow exists.
|
|
@@ -665,7 +671,6 @@ function divide(a: number, b: number): number {
|
|
|
665
671
|
---
|
|
666
672
|
|
|
667
673
|
- `isFile(value: unknown): value is File` - Checks if a value is a `File`.
|
|
668
|
-
- `parseFileName(fileName: string): [baseName: string, extension: string]` - Splits a file name into its base name and extension using the last `.` as the separator. Handles edge cases such as hidden files (`.gitignore`), multi-dot names (`archive.tar.gz`), and names ending with a dot (`"file."`). The extension is returned in lowercase.
|
|
669
674
|
- `fileListToFiles(fileList: FileList | null): File[]` - Converts a `FileList` object (such as the one returned from an `<input type="file">`) into a standard array of `File` objects. Returns an empty array when the input is `null`.
|
|
670
675
|
- `blobToFile(blob: Blob, fileName: string): File` - Converts a Blob object into a File object with the specified name.
|
|
671
676
|
- `traverseFileSystemDirectory(directoryEntry: FileSystemDirectoryEntry, options?: TraverseDirectoryOptions): Promise<File[]>` — Recursively scans a directory using the File System API and returns all nested files as `File` objects. Supports skipping system files.
|
package/dist/README.md
CHANGED
|
@@ -553,6 +553,9 @@ function divide(a: number, b: number): number {
|
|
|
553
553
|
- `toKebabCase(input: string): string` - Converts a string to kebab-case.
|
|
554
554
|
- `camelToDashCase(input: string): string` - Converts camelCase to dash-case.
|
|
555
555
|
- `splitStringIntoWords(input: string): string[]` - Splits a string into an array of words.
|
|
556
|
+
- `parseFileName(fileName: string): [baseName: string, extension: string]` - Splits a file name into its base name and extension using the last `.` as the separator. Handles edge cases such as hidden files (`.gitignore`), multi-dot names (`archive.tar.gz`), and names ending with a dot (`"file."`). The extension is returned in lowercase.
|
|
557
|
+
- `forEachChar(inputString: string, onChar: CharHandler, shouldSkipChar?: CharPredicate): void` - Iterates over each character of a string (UTF-16 code units) and invokes a callback for each character. Provides contextual information such as the character index and adjacent characters, and supports optional conditional skipping via a predicate.
|
|
558
|
+
- `findCharIndices(inputString: string, targetChar: string): number[]` - Returns all zero-based indices where a given single character occurs in the input string. Operates on UTF-16 code units and returns an empty array if the character is not found.
|
|
556
559
|
|
|
557
560
|
### Object Utilities
|
|
558
561
|
|
|
@@ -631,6 +634,9 @@ function divide(a: number, b: number): number {
|
|
|
631
634
|
|
|
632
635
|
---
|
|
633
636
|
|
|
637
|
+
- `resolveBoundedDelta(options: ResolveBoundedDeltaOptions): Nullable<number>` – Resolves the next numeric value by consuming a delta within fixed bounds. Prevents overshoot, partially consumes deltas at boundaries, and returns `null` when movement in the given direction is no longer possible. Useful for drag constraints, sliders, synthetic scrolling, and inertia systems.
|
|
638
|
+
- `applyInertiaStep(options: ApplyInertiaStepOptions): Nullable<{ value: number; velocity: number }>` – Applies a single inertia step on top of bounded delta resolution using velocity integration and exponential friction. Intended to be called from an animation loop (e.g. `requestAnimationFrame`) to implement momentum-based scrolling, sliders, or carousels. Returns updated value and velocity, or `null` when inertia has completed.
|
|
639
|
+
|
|
634
640
|
#### Layout
|
|
635
641
|
|
|
636
642
|
- `calculateCenterOffset(options: CalculateCenterOffsetOptions): number` - Calculates a clamped offset value that centers an element within a container along a single axis. Returns a negative value suitable for use in a CSS `translate` transform, or `0` when no overflow exists.
|
|
@@ -665,7 +671,6 @@ function divide(a: number, b: number): number {
|
|
|
665
671
|
---
|
|
666
672
|
|
|
667
673
|
- `isFile(value: unknown): value is File` - Checks if a value is a `File`.
|
|
668
|
-
- `parseFileName(fileName: string): [baseName: string, extension: string]` - Splits a file name into its base name and extension using the last `.` as the separator. Handles edge cases such as hidden files (`.gitignore`), multi-dot names (`archive.tar.gz`), and names ending with a dot (`"file."`). The extension is returned in lowercase.
|
|
669
674
|
- `fileListToFiles(fileList: FileList | null): File[]` - Converts a `FileList` object (such as the one returned from an `<input type="file">`) into a standard array of `File` objects. Returns an empty array when the input is `null`.
|
|
670
675
|
- `blobToFile(blob: Blob, fileName: string): File` - Converts a Blob object into a File object with the specified name.
|
|
671
676
|
- `traverseFileSystemDirectory(directoryEntry: FileSystemDirectoryEntry, options?: TraverseDirectoryOptions): Promise<File[]>` — Recursively scans a directory using the File System API and returns all nested files as `File` objects. Supports skipping system files.
|
package/dist/file.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Nullable } from '
|
|
1
|
+
import type { Nullable } from '~/types';
|
|
2
2
|
/**
|
|
3
3
|
* Checks if a value is a `File` object.
|
|
4
4
|
*
|
|
@@ -7,22 +7,6 @@ import type { Nullable } from './types';
|
|
|
7
7
|
* @returns `true` if the value is a `File` object; otherwise, `false`.
|
|
8
8
|
*/
|
|
9
9
|
export declare const isFile: (value: unknown) => value is File;
|
|
10
|
-
/**
|
|
11
|
-
* Splits a file name into its base name and extension.
|
|
12
|
-
*
|
|
13
|
-
* Special cases:
|
|
14
|
-
* - Files without a dot return `[fileName, ""]`
|
|
15
|
-
* - Hidden files like `.gitignore` return `[".gitignore", ""]`
|
|
16
|
-
* - Names ending with a trailing dot (e.g., `"file."`) return `["file.", ""]`
|
|
17
|
-
* - Multi-dot names (e.g., `"archive.tar.gz"`) split on the last dot
|
|
18
|
-
*
|
|
19
|
-
* @param fileName - The full file name to parse.
|
|
20
|
-
*
|
|
21
|
-
* @returns A tuple where:
|
|
22
|
-
* - index 0 is the base name
|
|
23
|
-
* - index 1 is the file extension (lowercased), or an empty string if none exists
|
|
24
|
-
*/
|
|
25
|
-
export declare const parseFileName: (fileName: string) => string[];
|
|
26
10
|
/**
|
|
27
11
|
* Converts a `FileList` object to an array of `File` objects.
|
|
28
12
|
*
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { Nullable } from '~/types';
|
|
2
|
+
export interface InertiaOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Current velocity of the motion, expressed in units per millisecond.
|
|
5
|
+
*
|
|
6
|
+
* The unit depends on the context in which inertia is applied:
|
|
7
|
+
* - `px/ms` for scrolling or dragging
|
|
8
|
+
* - arbitrary units for sliders or timelines
|
|
9
|
+
*
|
|
10
|
+
* The sign indicates direction (positive or negative).
|
|
11
|
+
*/
|
|
12
|
+
velocity: number;
|
|
13
|
+
/**
|
|
14
|
+
* Time elapsed since the previous inertia step, in milliseconds.
|
|
15
|
+
*
|
|
16
|
+
* This value is typically derived from a high-resolution clock such as `performance.now()`
|
|
17
|
+
* and allows inertia behavior to remain frame-rate independent.
|
|
18
|
+
*/
|
|
19
|
+
deltaTime: number;
|
|
20
|
+
/**
|
|
21
|
+
* Exponential friction coefficient controlling how quickly velocity decays over time.
|
|
22
|
+
*
|
|
23
|
+
* This value is applied per millisecond and produces smooth, natural-feeling
|
|
24
|
+
* deceleration when used with an exponential decay model.
|
|
25
|
+
*
|
|
26
|
+
* Smaller values result in a longer glide; larger values cause inertia
|
|
27
|
+
* to stop more quickly.
|
|
28
|
+
*
|
|
29
|
+
* Typical values:
|
|
30
|
+
* - `0.001` – very long, floaty motion
|
|
31
|
+
* - `0.002` – balanced, natural decay (default)
|
|
32
|
+
* - `0.005` – quick stop
|
|
33
|
+
*
|
|
34
|
+
* @default 0.002
|
|
35
|
+
*/
|
|
36
|
+
friction?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Minimum absolute velocity below which inertia is considered complete.
|
|
39
|
+
*
|
|
40
|
+
* When the absolute value of the current velocity drops below this threshold,
|
|
41
|
+
* no further movement is applied and inertia terminates.
|
|
42
|
+
*
|
|
43
|
+
* This prevents unnecessary micro-updates and jitter near rest.
|
|
44
|
+
*
|
|
45
|
+
* @default 0.01
|
|
46
|
+
*/
|
|
47
|
+
minVelocity?: number;
|
|
48
|
+
}
|
|
49
|
+
interface ApplyInertiaStepOptions extends InertiaOptions {
|
|
50
|
+
/**
|
|
51
|
+
* Current value before applying the inertia step.
|
|
52
|
+
*
|
|
53
|
+
* This typically represents a translated position (e.g. scroll offset),
|
|
54
|
+
* but may be any bounded numeric value.
|
|
55
|
+
*/
|
|
56
|
+
value: number;
|
|
57
|
+
/**
|
|
58
|
+
* Lower bound for the value (inclusive).
|
|
59
|
+
*/
|
|
60
|
+
min: number;
|
|
61
|
+
/**
|
|
62
|
+
* Upper bound for the value (inclusive).
|
|
63
|
+
*/
|
|
64
|
+
max: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Advances a value by one inertia step using velocity, friction, and hard bounds.
|
|
68
|
+
*
|
|
69
|
+
* This utility models **inertial motion** (momentum + decay) on top of
|
|
70
|
+
* {@link resolveBoundedDelta}, which acts as the authoritative constraint layer.
|
|
71
|
+
*
|
|
72
|
+
* The function:
|
|
73
|
+
* - Integrates velocity over the elapsed time to produce a movement delta
|
|
74
|
+
* - Resolves that delta against fixed bounds
|
|
75
|
+
* - Applies exponential friction to gradually reduce velocity
|
|
76
|
+
* - Stops immediately when a bound is hit or velocity falls below a threshold
|
|
77
|
+
*
|
|
78
|
+
* ⚠️ This function performs **one step only** and is intended to be called
|
|
79
|
+
* repeatedly from an animation loop (e.g. `requestAnimationFrame`).
|
|
80
|
+
*
|
|
81
|
+
* ### Common use cases
|
|
82
|
+
* - Synthetic scrolling with momentum
|
|
83
|
+
* - Carousels and sliders
|
|
84
|
+
* - Timelines and scrubbers
|
|
85
|
+
* - Drag-to-scroll interactions with inertia
|
|
86
|
+
*
|
|
87
|
+
* @param value - Current value before applying inertia (e.g. translate position).
|
|
88
|
+
* @param min - Minimum allowed value (inclusive).
|
|
89
|
+
* @param max - Maximum allowed value (inclusive).
|
|
90
|
+
* @param velocity - Current velocity in units per millisecond (e.g. px/ms).
|
|
91
|
+
* @param deltaTime - Time elapsed since the previous step, in milliseconds.
|
|
92
|
+
* @param friction - Exponential friction coefficient controlling decay rate.
|
|
93
|
+
* @param minVelocity - Minimum velocity below which inertia stops.
|
|
94
|
+
*
|
|
95
|
+
* @returns An object containing the updated value and velocity,
|
|
96
|
+
* or `null` when inertia has completed or movement is no longer possible.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* let value = translateX;
|
|
101
|
+
* let velocity = releaseVelocity; // px/ms from drag end
|
|
102
|
+
* let lastTime = performance.now();
|
|
103
|
+
*
|
|
104
|
+
* const step = (time: number) => {
|
|
105
|
+
* const deltaTime = time - lastTime;
|
|
106
|
+
* lastTime = time;
|
|
107
|
+
*
|
|
108
|
+
* const result = applyInertiaStep({
|
|
109
|
+
* value,
|
|
110
|
+
* velocity,
|
|
111
|
+
* min: -maxOverflow,
|
|
112
|
+
* max: 0,
|
|
113
|
+
* deltaTime,
|
|
114
|
+
* });
|
|
115
|
+
*
|
|
116
|
+
* if (!result) {
|
|
117
|
+
* return; // inertia finished
|
|
118
|
+
* }
|
|
119
|
+
*
|
|
120
|
+
* value = result.value;
|
|
121
|
+
* velocity = result.velocity;
|
|
122
|
+
*
|
|
123
|
+
* container.style.transform = `translateX(${value}px)`;
|
|
124
|
+
* requestAnimationFrame(step);
|
|
125
|
+
* };
|
|
126
|
+
*
|
|
127
|
+
* requestAnimationFrame(step);
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export declare const applyInertiaStep: ({ value, min, max, velocity, deltaTime, friction, minVelocity, }: ApplyInertiaStepOptions) => Nullable<{
|
|
131
|
+
value: number;
|
|
132
|
+
velocity: number;
|
|
133
|
+
}>;
|
|
134
|
+
export {};
|
package/dist/geometry/index.d.ts
CHANGED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Nullable } from '~/types';
|
|
2
|
+
interface ResolveBoundedDeltaOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Incremental change to apply to the current value.
|
|
5
|
+
*
|
|
6
|
+
* The sign of this value determines the direction of movement:
|
|
7
|
+
* - Negative values move toward the minimum bound
|
|
8
|
+
* - Positive values move toward the maximum bound
|
|
9
|
+
*/
|
|
10
|
+
delta: number;
|
|
11
|
+
/**
|
|
12
|
+
* Current numeric value before applying the delta.
|
|
13
|
+
*/
|
|
14
|
+
value: number;
|
|
15
|
+
/**
|
|
16
|
+
* Minimum allowed value (inclusive).
|
|
17
|
+
*
|
|
18
|
+
* Movement beyond this boundary is prevented.
|
|
19
|
+
*/
|
|
20
|
+
min: number;
|
|
21
|
+
/**
|
|
22
|
+
* Maximum allowed value (inclusive).
|
|
23
|
+
*
|
|
24
|
+
* Movement beyond this boundary is prevented.
|
|
25
|
+
*/
|
|
26
|
+
max: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolves the next value by consuming a delta within fixed numeric bounds.
|
|
30
|
+
*
|
|
31
|
+
* This function applies **bounded delta consumption** rather than naive clamping:
|
|
32
|
+
*
|
|
33
|
+
* - The delta is applied in the given direction as long as movement is possible.
|
|
34
|
+
* - If the delta would overshoot a bound, it is partially consumed so the
|
|
35
|
+
* resulting value lands exactly on the boundary.
|
|
36
|
+
* - If movement in the given direction is no longer possible, `null` is returned.
|
|
37
|
+
*
|
|
38
|
+
* This behavior mirrors how native scroll engines and drag constraints
|
|
39
|
+
* handle fast input without jitter or overshoot.
|
|
40
|
+
*
|
|
41
|
+
* ### Key characteristics
|
|
42
|
+
* - Direction-aware (positive and negative deltas behave independently)
|
|
43
|
+
* - Prevents overshoot while preserving remaining movement
|
|
44
|
+
* - Does **not** clamp unconditionally
|
|
45
|
+
* - Side-effect free and fully deterministic
|
|
46
|
+
*
|
|
47
|
+
* ### Common use cases
|
|
48
|
+
* - Synthetic scrolling
|
|
49
|
+
* - Drag constraints
|
|
50
|
+
* - Sliders and carousels
|
|
51
|
+
* - Timelines and scrubbers
|
|
52
|
+
* - Inertia and momentum systems
|
|
53
|
+
*
|
|
54
|
+
* @param delta - Incremental change to apply to the current value.
|
|
55
|
+
* The sign determines the movement direction.
|
|
56
|
+
* @param value - Current numeric value before applying the delta.
|
|
57
|
+
* @param min - Minimum allowed value (inclusive).
|
|
58
|
+
* @param max - Maximum allowed value (inclusive).
|
|
59
|
+
*
|
|
60
|
+
* @returns The next resolved value after applying the delta,
|
|
61
|
+
* or `null` if movement in the given direction is not possible.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* // Simple bounded movement
|
|
66
|
+
* resolveBoundedDelta({ value: 10, delta: -5, min: 0, max: 100 });
|
|
67
|
+
* // → 5
|
|
68
|
+
*
|
|
69
|
+
* // Overshoot is clamped to the boundary
|
|
70
|
+
* resolveBoundedDelta({ value: 2, delta: -10, min: 0, max: 100 });
|
|
71
|
+
* // → 0
|
|
72
|
+
*
|
|
73
|
+
* // Movement blocked at the boundary
|
|
74
|
+
* resolveBoundedDelta({ value: 0, delta: -5, min: 0, max: 100 });
|
|
75
|
+
* // → null
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare const resolveBoundedDelta: ({ delta, value, min, max, }: ResolveBoundedDeltaOptions) => Nullable<number>;
|
|
79
|
+
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e,t){if(!e)throw new Error(t)}e.r(t),e.d(t,{FOCUSABLE_HTML_TAGS:()=>
|
|
1
|
+
(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e,t){if(!e)throw new Error(t)}e.r(t),e.d(t,{FOCUSABLE_HTML_TAGS:()=>Te,applyInertiaStep:()=>Me,assert:()=>n,blobToFile:()=>ve,calculateCenterOffset:()=>ge,calculateEuclideanDistance:()=>re,calculateMovingSpeed:()=>ie,calculatePercentage:()=>le,camelToDashCase:()=>G,camelToWords:()=>Z,centerElementInContainer:()=>pe,chunk:()=>M,cloneBlob:()=>oe,compact:()=>O,compose:()=>P,definedProps:()=>Oe,delay:()=>B,difference:()=>F,downloadFile:()=>fe,everyAsync:()=>H,fileListToFiles:()=>Se,filterParallel:()=>Y,filterSequential:()=>X,findAsync:()=>W,findCharIndices:()=>ee,forEachChar:()=>te,getDOMRectIntersectionRatio:()=>Ce,getElementOffsetRect:()=>se,getFocusableHtmlElements:()=>ke,getLocalStorageCapabilities:()=>Le,getXOverflowWidth:()=>de,getYOverflowHeight:()=>ye,hasXOverflow:()=>he,hasYOverflow:()=>me,hashString:()=>ae,intersection:()=>C,invokeIfFunction:()=>ne,isAnchorHtmlElement:()=>ce,isArray:()=>x,isBlob:()=>h,isBool:()=>s,isContentEditableHtmlElement:()=>ue,isDate:()=>f,isDecimal:()=>v,isDefined:()=>l,isEmptyArray:()=>A,isEmptyObject:()=>u,isError:()=>d,isFile:()=>be,isFiniteNumber:()=>b,isFunction:()=>_,isHtmlElementFocusable:()=>Pe,isInteger:()=>S,isLocalStorageReadable:()=>De,isMap:()=>g,isNil:()=>i,isNilOrEmptyString:()=>J,isNull:()=>r,isNumber:()=>o,isObject:()=>c,isPromise:()=>I,isRegExp:()=>y,isSet:()=>p,isString:()=>q,isSymbol:()=>w,isUndefined:()=>a,isValidDate:()=>m,moveFocusWithinContainer:()=>_e,noop:()=>k,not:()=>D,once:()=>L,parse2DMatrix:()=>we,parseFileName:()=>Q,pipe:()=>T,readFilesFromDataTransfer:()=>Ae,reduceAsync:()=>z,resolveAxisDelta:()=>Fe,resolveBoundedDelta:()=>Ee,retry:()=>$,runParallel:()=>R,runSequential:()=>N,someAsync:()=>j,splitStringIntoWords:()=>K,timeout:()=>U,toKebabCase:()=>V,traverseFileSystemDirectory:()=>xe,unique:()=>E});const r=e=>null===e,i=e=>null==e,l=e=>null!=e,a=e=>void 0===e,o=e=>"number"==typeof e,s=e=>"boolean"==typeof e,c=e=>"object"==typeof e,u=e=>c(e)&&!r(e)&&0===Object.keys(e).length,f=e=>e instanceof Date,h=e=>e instanceof Blob,d=e=>e instanceof Error,m=e=>f(e)&&!isNaN(e.getTime()),y=e=>e instanceof RegExp,g=e=>e instanceof Map,p=e=>e instanceof Set,w=e=>"symbol"==typeof e,b=e=>o(e)&&isFinite(e),S=e=>o(e)&&Number.isInteger(e),v=e=>b(e)&&!Number.isInteger(e),x=e=>Array.isArray(e),A=e=>x(e)&&0===e.length,O=e=>e.filter(Boolean),E=e=>[...new Set(e)],M=(e,t)=>(n(t>0,"Chunk size must be greater than 0"),Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t))),C=(...e)=>{if(0===e.length)return[];if(1===e.length)return[...e[0]];const[t,...n]=e;return E(t).filter(e=>n.every(t=>t.includes(e)))},F=(e,t)=>e.filter(e=>!t.includes(e)),T=(...e)=>t=>e.reduce((e,t)=>t(e),t),P=(...e)=>t=>e.reduceRight((e,t)=>t(e),t),k=()=>{},_=e=>"function"==typeof e,D=e=>(...t)=>!e(...t),L=e=>{let t,n=!1;return function(...r){return n||(n=!0,t=e.apply(this,r)),t}},I=e=>_(e?.then),N=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++)n.push(await t(e[r],r,e));return n},R=async(e,t)=>Promise.all(e.map(t)),X=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++){const i=e[r];await t(i,r,e)&&n.push(i)}return n},Y=async(e,t)=>{const n=await R(e,async(e,n,r)=>!!await t(e,n,r)&&e);return O(n)},j=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return!0;return!1},H=async(e,t)=>{for(let n=0;n<e.length;n++)if(!await t(e[n],n,e))return!1;return!0},z=async(e,t,n)=>{let r=n;for(let n=0;n<e.length;n++)r=await t(r,e[n],n,e);return r},W=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return e[n];return null},B=e=>new Promise(t=>setTimeout(t,e)),U=async(e,t,n="Operation timed out")=>{try{return await Promise.race([e,B(t).then(()=>Promise.reject(new Error(n)))])}finally{}},$=(e,{maxAttempts:t=3,delayMs:n=300,backoff:r=!0,onRetry:i}={})=>async(...l)=>{let a;for(let o=1;o<=t;o++)try{return await e(...l)}catch(e){if(a=e,o<t){i?.(o,e);const t=r?n*2**(o-1):n;await B(t)}}throw a},q=e=>"string"==typeof e,V=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),G=e=>{const t=e.charAt(0),n=e.slice(1);return t.toLowerCase()+n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)},Z=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),K=e=>e.split(" ").filter(Boolean),J=e=>""===e||i(e),Q=e=>{const t=e.lastIndexOf(".");return t<=0||t===e.length-1?[e,""]:[e.slice(0,t),e.slice(t+1).toLowerCase()]},ee=(e,t)=>{if(0===e.length)return[];const n=t.charCodeAt(0),r=[];for(let t=0;t<e.length;t++)e.charCodeAt(t)===n&&r.push(t);return r},te=(e,t,n)=>{if(0===e.length)return;const r=e.length;for(let i=0;i<r;i++){const l=e[i],a={charIndex:i,prevChar:i>0?e[i-1]:null,nextChar:i<r-1?e[i+1]:null};n?.(l,a)||t(l,a)}},ne=(e,...t)=>"function"==typeof e?e(...t):e,re=(e,t,n,r)=>{const i=n-e,l=r-t;return Math.hypot(i,l)},ie=(e,t)=>Math.abs(e/t),le=(e,t)=>e*t/100,ae=e=>{let t=5381;for(let n=0;n<e.length;n++)t=33*t^e.charCodeAt(n);return(t>>>0).toString(36)},oe=e=>new Blob([e],{type:e.type}),se=e=>new DOMRect(e.offsetLeft,e.offsetTop,e.clientWidth,e.clientHeight),ce=e=>"A"===e.tagName,ue=e=>"true"===e.getAttribute("contenteditable"),fe=(e,{fileName:t,target:r}={})=>{if(a(document))return;const i=document.createElement("a");let l=null;try{const n=q(e)?e:l=URL.createObjectURL(e);i.href=n,t&&(i.download=t),r&&(i.target=r),document.body.appendChild(i),i.click()}finally{i.remove(),l&&setTimeout(()=>{n(l,"Object URL should not be null"),URL.revokeObjectURL(l)},0)}},he=e=>e.scrollWidth>e.clientWidth,de=e=>Math.max(0,e.scrollWidth-e.clientWidth),me=e=>e.scrollHeight>e.clientHeight,ye=e=>Math.max(0,e.scrollHeight-e.clientHeight),ge=({overflowSize:e,containerSize:t,elementOffset:n,elementSize:r})=>{if(e<=0)return 0;const i=n+r/2-t/2;return-Math.max(0,Math.min(i,e))},pe=(e,t,{axis:n="both"}={})=>{let r=0,i=0;"x"!==n&&"both"!==n||(r=ge({overflowSize:de(e),containerSize:e.clientWidth,elementOffset:t.offsetLeft,elementSize:t.clientWidth})),"y"!==n&&"both"!==n||(i=ge({overflowSize:ye(e),containerSize:e.clientHeight,elementOffset:t.offsetTop,elementSize:t.clientHeight})),e.style.transform=`translate(${r}px, ${i}px)`},we=e=>{const t=window.getComputedStyle(e).getPropertyValue("transform").match(/^matrix\((.+)\)$/);if(!t)return{translateX:0,translateY:0,scaleX:1,scaleY:1,skewX:0,skewY:0};const[n,r,i,l,a,o]=t[1].split(", ").map(parseFloat);return{translateX:a,translateY:o,scaleX:n,scaleY:l,skewX:i,skewY:r}},be=e=>e instanceof File,Se=e=>{if(!e)return[];const t=[];for(let n=0;n<e.length;n++)t.push(e[n]);return t},ve=(e,t)=>new File([e],t,{type:e.type}),xe=async(e,{skipFiles:t=[".DS_Store","Thumbs.db","desktop.ini","ehthumbs.db",".Spotlight-V100",".Trashes",".fseventsd","__MACOSX"]}={})=>{const n=new Set(t),r=await(async e=>{const t=e.createReader(),n=async()=>new Promise((e,r)=>{t.readEntries(async t=>{if(t.length)try{const r=await n();e([...t,...r])}catch(e){r(e)}else e([])},r)});return n()})(e);return(await R(r,async e=>e.isDirectory?xe(e,{skipFiles:t}):n.has(e.name)?[]:[await new Promise((t,n)=>{e.file(t,n)})])).flat()},Ae=async(e,t={})=>{const n=e?.items;if(!n)return[];const r=[];for(let e=0;e<n.length;e++){const i=n[e];if("webkitGetAsEntry"in i){const e=i.webkitGetAsEntry?.();if(e?.isDirectory){r.push(xe(e,t));continue}if(e?.isFile){r.push(new Promise((t,n)=>e.file(e=>t([e]),n)));continue}}const l=i.getAsFile();l&&r.push(Promise.resolve([l]))}return(await Promise.all(r)).flat()},Oe=e=>Object.entries(e).reduce((e,[t,n])=>(void 0!==n&&(e[t]=n),e),{}),Ee=({delta:e,value:t,min:n,max:r})=>{if(0===e)return null;const i=t+e;return e<0?t<=n?null:Math.max(i,n):e>0?t>=r?null:Math.min(i,r):null},Me=({value:e,min:t,max:n,velocity:r,deltaTime:i,friction:l=.002,minVelocity:a=.01})=>{if(Math.abs(r)<a)return null;const o=Ee({delta:r*i,value:e,min:t,max:n});return null===o?null:{value:o,velocity:r*Math.exp(-l*i)}},Ce=(e,t)=>Math.max(0,Math.min(e.right,t.right)-Math.max(e.left,t.left))*Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top))/(t.width*t.height),Fe=(e,t,{allowFallback:n=!0,invert:r=!0}={})=>{const i=r?-1:1;switch(t){case"x":return{deltaX:i*(0!==e.deltaX?e.deltaX:n?e.deltaY:0),deltaY:0};case"y":return{deltaX:0,deltaY:i*e.deltaY};default:return{deltaX:i*e.deltaX,deltaY:i*e.deltaY}}},Te=["INPUT","SELECT","TEXTAREA","BUTTON","A"],Pe=e=>{if(!e)return!1;const t=window.getComputedStyle(e);if("hidden"===t.visibility||"none"===t.display)return!1;if("disabled"in e&&e.disabled)return!1;const n=e.getAttribute("tabindex");return"-1"!==n&&(Te.includes(e.tagName)?!ce(e)||""!==e.href:!!ue(e)||null!==n)},ke=e=>Array.from(e.querySelectorAll("*")).filter(Pe),_e=(e,t=null,{wrap:n=!0,getNextIndex:r}={})=>{const i=document.activeElement,l=t??i?.parentElement;if(!i||!l)return;const a=ke(l);if(0===a.length)return;const o=a.indexOf(i);if(-1===o)return;let s;r?s=r(o,e,a):"next"===e?(s=o+1,s>=a.length&&(s=n?0:null)):(s=o-1,s<0&&(s=n?a.length-1:null)),null!==s&&a[s]?.focus()},De=()=>{if("undefined"==typeof window||!window.localStorage)return!1;try{return window.localStorage.getItem("__non_existing_key__"),!0}catch{return!1}},Le=()=>{if(!De())return{readable:!1,writable:!1};try{const e="__test_write__";return window.localStorage.setItem(e,"1"),window.localStorage.removeItem(e),{readable:!0,writable:!0}}catch{}return{readable:!0,writable:!1}};module.exports=t})();
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|