@react-hive/honey-utils 3.10.0 → 3.12.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 +2 -0
- package/dist/README.md +2 -0
- package/dist/async.d.ts +2 -1
- package/dist/dom.d.ts +88 -1
- package/dist/file.d.ts +3 -2
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +119 -0
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -619,6 +619,7 @@ function divide(a: number, b: number): number {
|
|
|
619
619
|
- `isContentEditableHtmlElement(element: HTMLElement): boolean` - Returns `true` if the element has `contenteditable="true"`, making it user-editable and implicitly focusable.
|
|
620
620
|
- `isHtmlElementFocusable(element: Nullable<HTMLElement>): boolean` - Checks whether an element is considered focusable according to browser rules. Factors include: visibility, `display`, `disabled`, `tabindex`, native focusable tags, `contenteditable`, and presence of a non-null `tabindex`.
|
|
621
621
|
- `getFocusableHtmlElements(container: HTMLElement): HTMLElement[]` - Returns all focusable descendant elements within a container, using `isHtmlElementFocusable` to filter them.
|
|
622
|
+
- `moveFocusWithinContainer(direction: FocusMoveDirection, container?: Nullable<HTMLElement>, options?: MoveFocusWithinContainerOptions): void` - Moves focus to the next or previous focusable element within a container. Supports cyclic navigation, optional wrapping control, and custom focus index resolution for advanced keyboard navigation patterns (e.g. roving tabindex).
|
|
622
623
|
- `hasXOverflow(element: HTMLElement): boolean` - Checks whether an element has horizontal overflow. Returns `true` if the content overflows beyond the visible width.
|
|
623
624
|
- `getXOverflowWidth(element: HTMLElement): number` - Calculates the horizontal overflow width of an element. Returns the number of pixels by which the content exceeds the visible width, or `0` when no horizontal overflow exists.
|
|
624
625
|
- `hasYOverflow(element: HTMLElement): boolean` - Checks whether an element has vertical overflow. Returns `true` if the content overflows beyond the visible height.
|
|
@@ -627,6 +628,7 @@ function divide(a: number, b: number): number {
|
|
|
627
628
|
- `centerElementInContainer(containerElement: HTMLElement, elementToCenter: HTMLElement, options?: CenterElementInContainerOptions): void` - Translates a container so that a target element is visually centered within its visible bounds using CSS transforms. Centering is applied independently per axis and only when an overflow exists.
|
|
628
629
|
- `isLocalStorageReadable(): boolean` - Determines whether `localStorage` can be safely read from. This check works even when writes fail (e.g., due to `QuotaExceededError`) and ensures that calling `getItem()` does not throw in restricted environments.
|
|
629
630
|
- `getLocalStorageCapabilities(): LocalStorageCapabilities` - Detects the browser's read and write capabilities for `localStorage`. Readability is determined by safe execution of `getItem()`, while writability requires successful `setItem()` and `removeItem()`.
|
|
631
|
+
- `downloadFile(file: Downloadable, options?: DownloadFileOptions): void` - Initiates a file download in a browser environment from a URL string or binary source (`Blob` / `MediaSource`). Automatically creates and revokes object URLs when required and safely no-ops in non-DOM environments (e.g. SSR).
|
|
630
632
|
|
|
631
633
|
### File Utilities
|
|
632
634
|
|
package/dist/README.md
CHANGED
|
@@ -619,6 +619,7 @@ function divide(a: number, b: number): number {
|
|
|
619
619
|
- `isContentEditableHtmlElement(element: HTMLElement): boolean` - Returns `true` if the element has `contenteditable="true"`, making it user-editable and implicitly focusable.
|
|
620
620
|
- `isHtmlElementFocusable(element: Nullable<HTMLElement>): boolean` - Checks whether an element is considered focusable according to browser rules. Factors include: visibility, `display`, `disabled`, `tabindex`, native focusable tags, `contenteditable`, and presence of a non-null `tabindex`.
|
|
621
621
|
- `getFocusableHtmlElements(container: HTMLElement): HTMLElement[]` - Returns all focusable descendant elements within a container, using `isHtmlElementFocusable` to filter them.
|
|
622
|
+
- `moveFocusWithinContainer(direction: FocusMoveDirection, container?: Nullable<HTMLElement>, options?: MoveFocusWithinContainerOptions): void` - Moves focus to the next or previous focusable element within a container. Supports cyclic navigation, optional wrapping control, and custom focus index resolution for advanced keyboard navigation patterns (e.g. roving tabindex).
|
|
622
623
|
- `hasXOverflow(element: HTMLElement): boolean` - Checks whether an element has horizontal overflow. Returns `true` if the content overflows beyond the visible width.
|
|
623
624
|
- `getXOverflowWidth(element: HTMLElement): number` - Calculates the horizontal overflow width of an element. Returns the number of pixels by which the content exceeds the visible width, or `0` when no horizontal overflow exists.
|
|
624
625
|
- `hasYOverflow(element: HTMLElement): boolean` - Checks whether an element has vertical overflow. Returns `true` if the content overflows beyond the visible height.
|
|
@@ -627,6 +628,7 @@ function divide(a: number, b: number): number {
|
|
|
627
628
|
- `centerElementInContainer(containerElement: HTMLElement, elementToCenter: HTMLElement, options?: CenterElementInContainerOptions): void` - Translates a container so that a target element is visually centered within its visible bounds using CSS transforms. Centering is applied independently per axis and only when an overflow exists.
|
|
628
629
|
- `isLocalStorageReadable(): boolean` - Determines whether `localStorage` can be safely read from. This check works even when writes fail (e.g., due to `QuotaExceededError`) and ensures that calling `getItem()` does not throw in restricted environments.
|
|
629
630
|
- `getLocalStorageCapabilities(): LocalStorageCapabilities` - Detects the browser's read and write capabilities for `localStorage`. Readability is determined by safe execution of `getItem()`, while writability requires successful `setItem()` and `removeItem()`.
|
|
631
|
+
- `downloadFile(file: Downloadable, options?: DownloadFileOptions): void` - Initiates a file download in a browser environment from a URL string or binary source (`Blob` / `MediaSource`). Automatically creates and revokes object URLs when required and safely no-ops in non-DOM environments (e.g. SSR).
|
|
630
632
|
|
|
631
633
|
### File Utilities
|
|
632
634
|
|
package/dist/async.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Nullable } from './types';
|
|
1
2
|
/**
|
|
2
3
|
* Checks if a value is a Promise.
|
|
3
4
|
*
|
|
@@ -144,4 +145,4 @@ export declare const reduceAsync: <Item, Accumulator>(array: Item[], fn: (accumu
|
|
|
144
145
|
*
|
|
145
146
|
* @returns A promise that resolves to the found item or null if none match.
|
|
146
147
|
*/
|
|
147
|
-
export declare const findAsync: <Item>(array: Item[], predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>) => Promise<Item
|
|
148
|
+
export declare const findAsync: <Item>(array: Item[], predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>) => Promise<Nullable<Item>>;
|
package/dist/dom.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Nullable } from './types';
|
|
1
2
|
export declare const FOCUSABLE_HTML_TAGS: string[];
|
|
2
3
|
interface HTMLElementTransformationValues {
|
|
3
4
|
translateX: number;
|
|
@@ -95,7 +96,7 @@ export declare const isContentEditableHtmlElement: (element: HTMLElement) => boo
|
|
|
95
96
|
*
|
|
96
97
|
* @returns Whether the element is focusable.
|
|
97
98
|
*/
|
|
98
|
-
export declare const isHtmlElementFocusable: (element: HTMLElement
|
|
99
|
+
export declare const isHtmlElementFocusable: (element: Nullable<HTMLElement>) => boolean;
|
|
99
100
|
/**
|
|
100
101
|
* Collects all focusable descendant elements within a container.
|
|
101
102
|
*
|
|
@@ -108,6 +109,57 @@ export declare const isHtmlElementFocusable: (element: HTMLElement | null) => bo
|
|
|
108
109
|
* @returns An array of focusable HTMLElements in DOM order.
|
|
109
110
|
*/
|
|
110
111
|
export declare const getFocusableHtmlElements: (container: HTMLElement) => HTMLElement[];
|
|
112
|
+
export type FocusMoveDirection = 'next' | 'previous';
|
|
113
|
+
export interface MoveFocusWithinContainerOptions {
|
|
114
|
+
/**
|
|
115
|
+
* Whether focus navigation should wrap around when reaching
|
|
116
|
+
* the beginning or end of the focusable elements list.
|
|
117
|
+
*
|
|
118
|
+
* When enabled, moving past the last element focuses the first,
|
|
119
|
+
* and moving before the first focuses the last.
|
|
120
|
+
*
|
|
121
|
+
* @default true
|
|
122
|
+
*/
|
|
123
|
+
wrap?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Custom resolver for determining the next focus index.
|
|
126
|
+
*
|
|
127
|
+
* When provided, this function overrides the default navigation logic
|
|
128
|
+
* and receives full control over how the focus moves.
|
|
129
|
+
*
|
|
130
|
+
* @param currentIndex - Index of the currently focused element.
|
|
131
|
+
* @param direction - Direction in which focus is moving.
|
|
132
|
+
* @param elements - Ordered list of focusable elements within the container.
|
|
133
|
+
*
|
|
134
|
+
* @returns The index of the element to focus next, or `null` to prevent focus movement.
|
|
135
|
+
*/
|
|
136
|
+
getNextIndex?: (currentIndex: number, direction: FocusMoveDirection, elements: HTMLElement[]) => Nullable<number>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Moves focus to the next or previous focusable element within a container.
|
|
140
|
+
*
|
|
141
|
+
* This utility is commonly used to implement accessible keyboard navigation patterns such as:
|
|
142
|
+
* - roving tabindex
|
|
143
|
+
* - custom dropdowns
|
|
144
|
+
* - tablists
|
|
145
|
+
* - menus
|
|
146
|
+
* - horizontal or vertical navigation groups
|
|
147
|
+
*
|
|
148
|
+
* Focus movement is scoped to a container and operates on the list of
|
|
149
|
+
* focusable descendants returned by `getFocusableHtmlElements`.
|
|
150
|
+
*
|
|
151
|
+
* @param direction - Direction in which focus should move (`'next'` or `'previous'`).
|
|
152
|
+
* @param container - Optional container that defines the focus scope.
|
|
153
|
+
* If omitted, the parent element of the currently focused element is used.
|
|
154
|
+
* @param options - Optional configuration controlling wrapping behavior and custom index resolution.
|
|
155
|
+
*
|
|
156
|
+
* @remarks
|
|
157
|
+
* - This function reads from and mutates the document's focus state.
|
|
158
|
+
* - If no active element exists, no container can be resolved,
|
|
159
|
+
* or the active element is not part of the focusable set, no action is taken.
|
|
160
|
+
* - When `getNextIndex` is provided, it fully overrides the default wrapping and directional logic.
|
|
161
|
+
*/
|
|
162
|
+
export declare const moveFocusWithinContainer: (direction: FocusMoveDirection, container?: Nullable<HTMLElement>, { wrap, getNextIndex }?: MoveFocusWithinContainerOptions) => void;
|
|
111
163
|
/**
|
|
112
164
|
* Checks whether an element has horizontal overflow.
|
|
113
165
|
*
|
|
@@ -253,4 +305,39 @@ interface LocalStorageCapabilities {
|
|
|
253
305
|
* @returns An object describing the detected `localStorage` capabilities.
|
|
254
306
|
*/
|
|
255
307
|
export declare const getLocalStorageCapabilities: () => LocalStorageCapabilities;
|
|
308
|
+
export type Downloadable = Blob | MediaSource | string;
|
|
309
|
+
export interface DownloadFileOptions {
|
|
310
|
+
/**
|
|
311
|
+
* Suggested filename for the downloaded file.
|
|
312
|
+
*
|
|
313
|
+
* When provided, the browser will attempt to save the file using this name.
|
|
314
|
+
* If omitted and the source is a URL string, the browser may infer the name
|
|
315
|
+
* from the URL.
|
|
316
|
+
*/
|
|
317
|
+
fileName?: string;
|
|
318
|
+
/**
|
|
319
|
+
* Target browsing context for the download link.
|
|
320
|
+
*/
|
|
321
|
+
target?: '_self' | '_blank';
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Initiates a file download in a browser environment.
|
|
325
|
+
*
|
|
326
|
+
* This utility supports downloading from:
|
|
327
|
+
* - a URL string
|
|
328
|
+
* - a `Blob`
|
|
329
|
+
* - a `MediaSource`
|
|
330
|
+
*
|
|
331
|
+
* For non-string inputs, an object URL is created temporarily and
|
|
332
|
+
* automatically revoked after the download is triggered.
|
|
333
|
+
*
|
|
334
|
+
* @remarks
|
|
335
|
+
* - This function performs direct DOM manipulation and must be executed in a browser environment.
|
|
336
|
+
* - In non-DOM contexts (e.g. SSR), the function exits without side effects.
|
|
337
|
+
* - Object URLs are revoked asynchronously to avoid Safari-related issues.
|
|
338
|
+
*
|
|
339
|
+
* @param file - The file source to download (URL string or binary object).
|
|
340
|
+
* @param options - Optional configuration controlling filename and link target.
|
|
341
|
+
*/
|
|
342
|
+
export declare const downloadFile: (file: Downloadable, { fileName, target }?: DownloadFileOptions) => void;
|
|
256
343
|
export {};
|
package/dist/file.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Nullable } from './types';
|
|
1
2
|
/**
|
|
2
3
|
* Checks if a value is a `File` object.
|
|
3
4
|
*
|
|
@@ -29,7 +30,7 @@ export declare const parseFileName: (fileName: string) => string[];
|
|
|
29
30
|
*
|
|
30
31
|
* @returns An array of `File` objects.
|
|
31
32
|
*/
|
|
32
|
-
export declare const fileListToFiles: (fileList: FileList
|
|
33
|
+
export declare const fileListToFiles: (fileList: Nullable<FileList>) => File[];
|
|
33
34
|
/**
|
|
34
35
|
* Converts a `Blob` object into a `File` object with the specified name.
|
|
35
36
|
*
|
|
@@ -92,5 +93,5 @@ export declare const traverseFileSystemDirectory: (directoryEntry: FileSystemDir
|
|
|
92
93
|
* - files extracted from directory entries via `webkitGetAsEntry`,
|
|
93
94
|
* - and files found recursively within nested subdirectories.
|
|
94
95
|
*/
|
|
95
|
-
export declare const readFilesFromDataTransfer: (dataTransfer: DataTransfer
|
|
96
|
+
export declare const readFilesFromDataTransfer: (dataTransfer: Nullable<DataTransfer>, traverseOptions?: TraverseDirectoryOptions) => Promise<File[]>;
|
|
96
97
|
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{"use strict";var e={d:(t,
|
|
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:()=>ie,assert:()=>n,blobToFile:()=>Me,calculateCenterOffset:()=>we,calculateEuclideanDistance:()=>te,calculateMovingSpeed:()=>ne,calculatePercentage:()=>re,camelToDashCase:()=>K,camelToWords:()=>J,centerElementInContainer:()=>be,chunk:()=>M,cloneBlob:()=>le,compact:()=>v,compose:()=>C,definedProps:()=>Pe,delay:()=>R,difference:()=>T,downloadFile:()=>Oe,everyAsync:()=>Y,fileListToFiles:()=>xe,filterParallel:()=>B,filterSequential:()=>X,findAsync:()=>q,getDOMRectIntersectionRatio:()=>oe,getElementOffsetRect:()=>se,getFocusableHtmlElements:()=>me,getLocalStorageCapabilities:()=>Ae,getXOverflowWidth:()=>ye,getYOverflowHeight:()=>pe,hasXOverflow:()=>de,hasYOverflow:()=>ge,hashString:()=>ee,intersection:()=>F,invokeIfFunction:()=>N,isAnchorHtmlElement:()=>ce,isArray:()=>O,isBlob:()=>m,isBool:()=>s,isContentEditableHtmlElement:()=>ue,isDate:()=>f,isDecimal:()=>A,isDefined:()=>a,isEmptyArray:()=>E,isEmptyObject:()=>u,isError:()=>h,isFile:()=>Ee,isFiniteNumber:()=>b,isFunction:()=>k,isHtmlElementFocusable:()=>fe,isInteger:()=>S,isLocalStorageReadable:()=>Se,isMap:()=>g,isNil:()=>i,isNilOrEmptyString:()=>V,isNull:()=>r,isNumber:()=>o,isObject:()=>c,isPromise:()=>I,isRegExp:()=>y,isSet:()=>p,isString:()=>G,isSymbol:()=>w,isUndefined:()=>l,isValidDate:()=>d,moveFocusWithinContainer:()=>he,noop:()=>_,not:()=>L,once:()=>H,parse2DMatrix:()=>ae,parseFileName:()=>ve,pipe:()=>P,readFilesFromDataTransfer:()=>Te,reduceAsync:()=>$,retry:()=>j,runParallel:()=>W,runSequential:()=>z,someAsync:()=>U,splitStringIntoWords:()=>Q,timeout:()=>D,toKebabCase:()=>Z,traverseFileSystemDirectory:()=>Fe,unique:()=>x});const r=e=>null===e,i=e=>null==e,a=e=>null!=e,l=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,m=e=>e instanceof Blob,h=e=>e instanceof Error,d=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),A=e=>b(e)&&!Number.isInteger(e),O=e=>Array.isArray(e),E=e=>O(e)&&0===e.length,v=e=>e.filter(Boolean),x=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))),F=(...e)=>{if(0===e.length)return[];if(1===e.length)return[...e[0]];const[t,...n]=e;return x(t).filter(e=>n.every(t=>t.includes(e)))},T=(e,t)=>e.filter(e=>!t.includes(e)),P=(...e)=>t=>e.reduce((e,t)=>t(e),t),C=(...e)=>t=>e.reduceRight((e,t)=>t(e),t),_=()=>{},k=e=>"function"==typeof e,L=e=>(...t)=>!e(...t),N=(e,...t)=>"function"==typeof e?e(...t):e,R=e=>new Promise(t=>setTimeout(t,e)),D=async(e,t,n="Operation timed out")=>{try{return await Promise.race([e,R(t).then(()=>Promise.reject(new Error(n)))])}finally{}},j=(e,{maxAttempts:t=3,delayMs:n=300,backoff:r=!0,onRetry:i}={})=>async(...a)=>{let l;for(let o=1;o<=t;o++)try{return await e(...a)}catch(e){if(l=e,o<t){i?.(o,e);const t=r?n*2**(o-1):n;await R(t)}}throw l},H=e=>{let t,n=!1;return function(...r){return n||(n=!0,t=e.apply(this,r)),t}},I=e=>k(e?.then),z=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++)n.push(await t(e[r],r,e));return n},W=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},B=async(e,t)=>{const n=await W(e,async(e,n,r)=>!!await t(e,n,r)&&e);return v(n)},U=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return!0;return!1},Y=async(e,t)=>{for(let n=0;n<e.length;n++)if(!await t(e[n],n,e))return!1;return!0},$=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},q=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return e[n];return null},G=e=>"string"==typeof e,V=e=>""===e||i(e),Z=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),K=e=>{const t=e.charAt(0),n=e.slice(1);return t.toLowerCase()+n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)},J=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),Q=e=>e.split(" ").filter(Boolean),ee=e=>{let t=5381;for(let n=0;n<e.length;n++)t=33*t^e.charCodeAt(n);return(t>>>0).toString(36)},te=(e,t,n,r)=>{const i=n-e,a=r-t;return Math.hypot(i,a)},ne=(e,t)=>Math.abs(e/t),re=(e,t)=>e*t/100,ie=["INPUT","SELECT","TEXTAREA","BUTTON","A"],ae=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,a,l,o]=t[1].split(", ").map(parseFloat);return{translateX:l,translateY:o,scaleX:n,scaleY:a,skewX:i,skewY:r}},le=e=>new Blob([e],{type:e.type}),oe=(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),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=>{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&&(ie.includes(e.tagName)?!ce(e)||""!==e.href:!!ue(e)||null!==n)},me=e=>Array.from(e.querySelectorAll("*")).filter(fe),he=(e,t=null,{wrap:n=!0,getNextIndex:r}={})=>{const i=document.activeElement,a=t??i?.parentElement;if(!i||!a)return;const l=me(a);if(0===l.length)return;const o=l.indexOf(i);if(-1===o)return;let s;r?s=r(o,e,l):"next"===e?(s=o+1,s>=l.length&&(s=n?0:null)):(s=o-1,s<0&&(s=n?l.length-1:null)),null!==s&&l[s]?.focus()},de=e=>e.scrollWidth>e.clientWidth,ye=e=>Math.max(0,e.scrollWidth-e.clientWidth),ge=e=>e.scrollHeight>e.clientHeight,pe=e=>Math.max(0,e.scrollHeight-e.clientHeight),we=({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))},be=(e,t,{axis:n="both"}={})=>{let r=0,i=0;"x"!==n&&"both"!==n||(r=we({overflowSize:ye(e),containerSize:e.clientWidth,elementOffset:t.offsetLeft,elementSize:t.clientWidth})),"y"!==n&&"both"!==n||(i=we({overflowSize:pe(e),containerSize:e.clientHeight,elementOffset:t.offsetTop,elementSize:t.clientHeight})),e.style.transform=`translate(${r}px, ${i}px)`},Se=()=>{if("undefined"==typeof window||!window.localStorage)return!1;try{return window.localStorage.getItem("__non_existing_key__"),!0}catch{return!1}},Ae=()=>{if(!Se())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}},Oe=(e,{fileName:t,target:r}={})=>{if(l(document))return;const i=document.createElement("a");let a=null;try{const n=G(e)?e:a=URL.createObjectURL(e);i.href=n,t&&(i.download=t),r&&(i.target=r),document.body.appendChild(i),i.click()}finally{i.remove(),a&&setTimeout(()=>{n(a,"Object URL should not be null"),URL.revokeObjectURL(a)},0)}},Ee=e=>e instanceof File,ve=e=>{const t=e.lastIndexOf(".");return t<=0||t===e.length-1?[e,""]:[e.slice(0,t),e.slice(t+1).toLowerCase()]},xe=e=>{if(!e)return[];const t=[];for(let n=0;n<e.length;n++)t.push(e[n]);return t},Me=(e,t)=>new File([e],t,{type:e.type}),Fe=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 W(r,async e=>e.isDirectory?Fe(e,{skipFiles:t}):n.has(e.name)?[]:[await new Promise((t,n)=>{e.file(t,n)})])).flat()},Te=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(Fe(e,t));continue}if(e?.isFile){r.push(new Promise((t,n)=>e.file(e=>t([e]),n)));continue}}const a=i.getAsFile();a&&r.push(Promise.resolve([a]))}return(await Promise.all(r)).flat()},Pe=e=>Object.entries(e).reduce((e,[t,n])=>(void 0!==n&&(e[t]=n),e),{});module.exports=t})();
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|