@react-hive/honey-utils 3.28.0 → 3.30.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 CHANGED
@@ -584,6 +584,7 @@ function divide(a: number, b: number): number {
584
584
  - `difference<T>(array: T[], exclude: T[]): T[]` - Returns a new array that contains items from `array` that are not present in `exclude`.
585
585
  - `pipe(...fns: Function[]): Function` - Composes unary functions left-to-right. Returns a new function that applies all given functions in a sequence.
586
586
  - `compose(...fns: Function[]): Function` - Composes unary functions **right-to-left**. Same as `pipe`, but applies functions in reverse order.
587
+ - `getAdjacentItems<T>(items: Nullable<T[]> | undefined, targetItem: Nullable<T> | undefined, isSameItem: (item: T, targetItem: T) => boolean): AdjacentItems` - Returns the previous, current, and next items for the matched item in the array. If the target is not found, all returned values are `null`.
587
588
 
588
589
  ### Function Utilities
589
590
 
package/dist/README.md CHANGED
@@ -584,6 +584,7 @@ function divide(a: number, b: number): number {
584
584
  - `difference<T>(array: T[], exclude: T[]): T[]` - Returns a new array that contains items from `array` that are not present in `exclude`.
585
585
  - `pipe(...fns: Function[]): Function` - Composes unary functions left-to-right. Returns a new function that applies all given functions in a sequence.
586
586
  - `compose(...fns: Function[]): Function` - Composes unary functions **right-to-left**. Same as `pipe`, but applies functions in reverse order.
587
+ - `getAdjacentItems<T>(items: Nullable<T[]> | undefined, targetItem: Nullable<T> | undefined, isSameItem: (item: T, targetItem: T) => boolean): AdjacentItems` - Returns the previous, current, and next items for the matched item in the array. If the target is not found, all returned values are `null`.
587
588
 
588
589
  ### Function Utilities
589
590
 
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Splits an array into chunks of the specified size.
3
+ *
4
+ * Useful for pagination, batch processing, or creating grid layouts.
5
+ *
6
+ * @template T - The type of the items in the array.
7
+ *
8
+ * @param array - The input array to be chunked.
9
+ * @param size - The size of each chunk. Must be greater than 0.
10
+ *
11
+ * @returns An array of chunks, where each chunk is an array of the specified size
12
+ * (except possibly the last chunk, which may be smaller).
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
17
+ * chunk(['a', 'b', 'c', 'd'], 3); // [['a', 'b', 'c'], ['d']]
18
+ * ```
19
+ */
20
+ export declare const chunk: <T>(array: T[], size: number) => T[][];
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Represents all falsy values.
3
+ */
4
+ type Falsy = false | null | undefined | 0 | '';
5
+ /**
6
+ * Removes all falsy values from an array.
7
+ *
8
+ * Falsy values include: `false`, `0`, `''` (empty string), `null`, `undefined`, and `NaN`.
9
+ *
10
+ * Useful for cleaning up arrays with optional, nullable, or conditionally included items.
11
+ *
12
+ * @template T - The type of the truthy items.
13
+ *
14
+ * @param array - An array possibly containing falsy values.
15
+ *
16
+ * @returns A new array containing only truthy values of type `T`.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * compact([0, 1, false, 2, '', 3, null, undefined, NaN]); // [1, 2, 3]
21
+ * ```
22
+ */
23
+ export declare const compact: <T>(array: (T | Falsy)[]) => T[];
24
+ export {};
@@ -0,0 +1,31 @@
1
+ type ComposeFn = (arg: unknown) => unknown;
2
+ type Compose = {
3
+ <A, R>(fn1: (a: A) => R): (a: A) => R;
4
+ <A, B, R>(fn1: (b: B) => R, fn2: (a: A) => B): (a: A) => R;
5
+ <A, B, C, R>(fn1: (c: C) => R, fn2: (b: B) => C, fn3: (a: A) => B): (a: A) => R;
6
+ <A, B, C, D, R>(fn1: (d: D) => R, fn2: (c: C) => D, fn3: (b: B) => C, fn4: (a: A) => B): (a: A) => R;
7
+ <A, B, C, D, E, R>(fn1: (e: E) => R, fn2: (d: D) => E, fn3: (c: C) => D, fn4: (b: B) => C, fn5: (a: A) => B): (a: A) => R;
8
+ (...fns: ComposeFn[]): (arg: unknown) => unknown;
9
+ };
10
+ /**
11
+ * Composes multiple unary functions into a single function, applying them from **right to left**.
12
+ *
13
+ * Often used for building functional pipelines where the innermost function runs first.
14
+ * Types are inferred up to 5 chained functions for full type safety.
15
+ *
16
+ * @param fns - A list of unary functions to compose.
17
+ *
18
+ * @returns A new function that applies all functions from right to left.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * const add = (x: number) => x + 1;
23
+ * const double = (x: number) => x * 2;
24
+ * const toStr = (x: number) => `Result: ${x}`;
25
+ *
26
+ * const result = compose(toStr, double, add)(2);
27
+ * // => 'Result: 6'
28
+ * ```
29
+ */
30
+ export declare const compose: Compose;
31
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Returns elements from the first array that don't exist in the second array.
3
+ *
4
+ * @template T - The type of the items in the arrays.
5
+ *
6
+ * @param array - The source array.
7
+ * @param exclude - The array containing elements to exclude.
8
+ *
9
+ * @returns A new array with elements from the first array that don't exist in the second array.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * difference([1, 2, 3, 4], [2, 4]); // [1, 3]
14
+ * difference(['a', 'b', 'c'], ['b']); // ['a', 'c']
15
+ * ```
16
+ */
17
+ export declare const difference: <T>(array: T[], exclude: T[]) => T[];
@@ -0,0 +1,16 @@
1
+ import type { Nullable } from '~/types';
2
+ export interface AdjacentItems<T> {
3
+ previousItem: Nullable<T>;
4
+ currentItem: Nullable<T>;
5
+ nextItem: Nullable<T>;
6
+ }
7
+ /**
8
+ * Returns previous, current, and next items for the matched item.
9
+ *
10
+ * @param items - Source items.
11
+ * @param targetItem - Item to find in the source array.
12
+ * @param isSameItem - Comparator used to match items.
13
+ *
14
+ * @returns Adjacent items around the matched item.
15
+ */
16
+ export declare const getAdjacentItems: <T>(items: Nullable<T[]> | undefined, targetItem: Nullable<T> | undefined, isSameItem: (item: T, targetItem: T) => boolean) => AdjacentItems<T>;
@@ -0,0 +1,10 @@
1
+ export * from './pipe';
2
+ export * from './compose';
3
+ export * from './difference';
4
+ export * from './intersection';
5
+ export * from './chunk';
6
+ export * from './unique';
7
+ export * from './compact';
8
+ export * from './is-array';
9
+ export * from './is-empty-array';
10
+ export * from './get-adjacent-items';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Returns an array containing elements that exist in all provided arrays.
3
+ *
4
+ * @template T - The type of the items in the arrays.
5
+ *
6
+ * @param arrays - Two or more arrays to find common elements from.
7
+ *
8
+ * @returns A new array containing only the elements that exist in all input arrays.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * intersection([1, 2, 3], [2, 3, 4]); // [2, 3]
13
+ * intersection(['a', 'b', 'c'], ['b', 'c', 'd'], ['b', 'e']); // ['b']
14
+ * ```
15
+ */
16
+ export declare const intersection: <T>(...arrays: T[][]) => T[];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks if a value is an array.
3
+ *
4
+ * @param value - The value to check.
5
+ *
6
+ * @returns `true` if the value is an array; otherwise, `false`.
7
+ */
8
+ export declare const isArray: (value: unknown) => value is unknown[];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks if a value is an empty array.
3
+ *
4
+ * @param value - The value to check.
5
+ *
6
+ * @returns `true` if the value is an empty array; otherwise, `false`.
7
+ */
8
+ export declare const isEmptyArray: (value: unknown) => value is [];
@@ -0,0 +1,32 @@
1
+ type PipeFn = (arg: unknown) => unknown;
2
+ type Pipe = {
3
+ <A, B>(fn1: (a: A) => B): (a: A) => B;
4
+ <A, B, C>(fn1: (a: A) => B, fn2: (b: B) => C): (a: A) => C;
5
+ <A, B, C, D>(fn1: (a: A) => B, fn2: (b: B) => C, fn3: (c: C) => D): (a: A) => D;
6
+ <A, B, C, D, E>(fn1: (a: A) => B, fn2: (b: B) => C, fn3: (c: C) => D, fn4: (d: D) => E): (a: A) => E;
7
+ <A, B, C, D, E, F>(fn1: (a: A) => B, fn2: (b: B) => C, fn3: (c: C) => D, fn4: (d: D) => E, fn5: (e: E) => F): (a: A) => F;
8
+ (...fns: PipeFn[]): (arg: unknown) => unknown;
9
+ };
10
+ /**
11
+ * Composes multiple unary functions into a single function, applying them from left to right.
12
+ *
13
+ * Useful for building a data processing pipeline where the output of one function becomes the input of the next.
14
+ *
15
+ * Types are inferred up to 5 chained functions for full type safety. Beyond that, it falls back to the unknown.
16
+ *
17
+ * @param fns - A list of unary functions to compose.
18
+ *
19
+ * @returns A new function that applies all functions from left to right.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * const add = (x: number) => x + 1;
24
+ * const double = (x: number) => x * 2;
25
+ * const toStr = (x: number) => `Result: ${x}`;
26
+ *
27
+ * const result = pipe(add, double, toStr)(2);
28
+ * // => 'Result: 6'
29
+ * ```
30
+ */
31
+ export declare const pipe: Pipe;
32
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Returns a new array with duplicate values removed.
3
+ *
4
+ * Uses Set for efficient duplicate removal while preserving the original order.
5
+ *
6
+ * @template T - The type of the items in the array.
7
+ *
8
+ * @param array - The input array that may contain duplicate values.
9
+ *
10
+ * @returns A new array with only unique values, maintaining the original order.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * unique([1, 2, 2, 3, 1, 4]); // [1, 2, 3, 4]
15
+ * unique(['a', 'b', 'a', 'c']); // ['a', 'b', 'c']
16
+ * ```
17
+ */
18
+ export declare const unique: <T>(array: T[]) => T[];
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={};e.r(t),e.d(t,{DATA_TRANSFER_JSON_MIME:()=>te,FOCUSABLE_HTML_TAGS:()=>l,applyInertiaStep:()=>Ae,assert:()=>u,blobToFile:()=>ye,calculateCenterOffset:()=>ue,calculateEuclideanDistance:()=>Oe,calculateMovingSpeed:()=>Ce,calculatePercentage:()=>Te,camelToDashCase:()=>De,camelToWords:()=>_e,centerElementInContainer:()=>he,chunk:()=>L,cloneBlob:()=>n,compact:()=>D,compose:()=>j,definedProps:()=>Fe,delay:()=>K,difference:()=>k,downloadFile:()=>ie,everyAsync:()=>V,fileListToFiles:()=>ge,filterParallel:()=>J,filterSequential:()=>B,findAsync:()=>Z,findCharIndices:()=>Re,flattenTree:()=>Ye,forEachChar:()=>je,generateEphemeralId:()=>Me,getDOMRectIntersectionRatio:()=>xe,getDataTransferJson:()=>re,getElementOffsetRect:()=>r,getFocusableHtmlElements:()=>s,getLocalStorageCapabilities:()=>me,getTreeChildren:()=>$e,getWordsInitials:()=>Xe,getXOverflowWidth:()=>oe,getYOverflowHeight:()=>ce,hasXOverflow:()=>le,hasYOverflow:()=>se,hashString:()=>Ie,hexWithAlpha:()=>ze,intersection:()=>N,invokeIfFunction:()=>Se,isAnchorHtmlElement:()=>a,isArray:()=>F,isBlob:()=>S,isBool:()=>g,isContentEditableHtmlElement:()=>i,isDate:()=>b,isDecimal:()=>I,isDefined:()=>d,isEmptyArray:()=>P,isEmptyObject:()=>w,isError:()=>v,isFile:()=>pe,isFiniteNumber:()=>C,isFunction:()=>W,isHtmlElementFocusable:()=>o,isInteger:()=>T,isLocalStorageReadable:()=>de,isMap:()=>x,isNil:()=>f,isNilOrEmptyString:()=>Ne,isNull:()=>h,isNumber:()=>p,isObject:()=>y,isPromise:()=>H,isRegExp:()=>M,isSet:()=>E,isString:()=>ae,isSymbol:()=>O,isUndefined:()=>m,isValidDate:()=>A,moveFocusWithinContainer:()=>c,noop:()=>X,not:()=>Y,once:()=>$,parse2DMatrix:()=>fe,parseFileName:()=>ke,pipe:()=>R,readFilesFromDataTransfer:()=>be,reduceAsync:()=>G,resolveAxisDelta:()=>Ee,resolveBoundedDelta:()=>ve,retry:()=>ee,runParallel:()=>U,runSequential:()=>z,searchTree:()=>He,setDataTransferJson:()=>ne,someAsync:()=>q,splitMapJoin:()=>We,splitStringIntoWords:()=>Le,timeout:()=>Q,toKebabCase:()=>Pe,traverseFileSystemDirectory:()=>we,unique:()=>_});const n=e=>new Blob([e],{type:e.type}),r=e=>new DOMRect(e.offsetLeft,e.offsetTop,e.clientWidth,e.clientHeight),a=e=>"A"===e.tagName,i=e=>"true"===e.getAttribute("contenteditable"),l=["INPUT","SELECT","TEXTAREA","BUTTON","A"],o=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&&(l.includes(e.tagName)?!a(e)||""!==e.href:!!i(e)||null!==n)},s=e=>Array.from(e.querySelectorAll("*")).filter(o),c=(e,t=null,{wrap:n=!0,getNextIndex:r}={})=>{const a=document.activeElement,i=t??a?.parentElement;if(!a||!i)return;const l=s(i);if(0===l.length)return;const o=l.indexOf(a);if(-1===o)return;let c;r?c=r(o,e,l):"next"===e?(c=o+1,c>=l.length&&(c=n?0:null)):(c=o-1,c<0&&(c=n?l.length-1:null)),null!==c&&l[c]?.focus()};function u(e,t){if(!e)throw new Error(t)}const h=e=>null===e,f=e=>null==e,d=e=>null!=e,m=e=>void 0===e,p=e=>"number"==typeof e,g=e=>"boolean"==typeof e,y=e=>"object"==typeof e,w=e=>y(e)&&!h(e)&&0===Object.keys(e).length,b=e=>e instanceof Date,S=e=>e instanceof Blob,v=e=>e instanceof Error,A=e=>b(e)&&!isNaN(e.getTime()),M=e=>e instanceof RegExp,x=e=>e instanceof Map,E=e=>e instanceof Set,O=e=>"symbol"==typeof e,C=e=>p(e)&&isFinite(e),T=e=>p(e)&&Number.isInteger(e),I=e=>C(e)&&!Number.isInteger(e),F=e=>Array.isArray(e),P=e=>F(e)&&0===e.length,D=e=>e.filter(Boolean),_=e=>[...new Set(e)],L=(e,t)=>(u(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))),N=(...e)=>{if(0===e.length)return[];if(1===e.length)return[...e[0]];const[t,...n]=e;return _(t).filter(e=>n.every(t=>t.includes(e)))},k=(e,t)=>e.filter(e=>!t.includes(e)),R=(...e)=>t=>e.reduce((e,t)=>t(e),t),j=(...e)=>t=>e.reduceRight((e,t)=>t(e),t),X=()=>{},W=e=>"function"==typeof e,Y=e=>(...t)=>!e(...t),$=e=>{let t,n=!1;return function(...r){return n||(n=!0,t=e.apply(this,r)),t}},H=e=>W(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},U=async(e,t)=>Promise.all(e.map(t)),B=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++){const a=e[r];await t(a,r,e)&&n.push(a)}return n},J=async(e,t)=>{const n=await U(e,async(e,n,r)=>!!await t(e,n,r)&&e);return D(n)},q=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return!0;return!1},V=async(e,t)=>{for(let n=0;n<e.length;n++)if(!await t(e[n],n,e))return!1;return!0},G=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},Z=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return e[n];return null},K=e=>new Promise(t=>setTimeout(t,e)),Q=async(e,t,n="Operation timed out")=>{try{return await Promise.race([e,K(t).then(()=>Promise.reject(new Error(n)))])}finally{}},ee=(e,{maxAttempts:t=3,delayMs:n=300,backoff:r=!0,onRetry:a}={})=>async(...i)=>{let l;for(let o=1;o<=t;o++)try{return await e(...i)}catch(e){if(l=e,o<t){a?.(o,e);const t=r?n*2**(o-1):n;await K(t)}}throw l},te="application/json",ne=(e,t)=>{e.setData(te,JSON.stringify(t))},re=e=>{const t=e.getData(te);if(t)try{return JSON.parse(t)}catch{return}},ae=e=>"string"==typeof e,ie=(e,{fileName:t,target:n}={})=>{if(m(document))return;const r=document.createElement("a");let a=null;try{const i=ae(e)?e:a=URL.createObjectURL(e);r.href=i,t&&(r.download=t),n&&(r.target=n),document.body.appendChild(r),r.click()}finally{r.remove(),a&&setTimeout(()=>{u(a,"Object URL should not be null"),URL.revokeObjectURL(a)},0)}},le=e=>e.scrollWidth>e.clientWidth,oe=e=>Math.max(0,e.scrollWidth-e.clientWidth),se=e=>e.scrollHeight>e.clientHeight,ce=e=>Math.max(0,e.scrollHeight-e.clientHeight),ue=({overflowSize:e,containerSize:t,elementOffset:n,elementSize:r})=>{if(e<=0)return 0;const a=n+r/2-t/2;return-Math.max(0,Math.min(a,e))},he=(e,t,{axis:n="both"}={})=>{let r=0,a=0;"x"!==n&&"both"!==n||(r=ue({overflowSize:oe(e),containerSize:e.clientWidth,elementOffset:t.offsetLeft,elementSize:t.clientWidth})),"y"!==n&&"both"!==n||(a=ue({overflowSize:ce(e),containerSize:e.clientHeight,elementOffset:t.offsetTop,elementSize:t.clientHeight})),e.style.transform=`translate(${r}px, ${a}px)`},fe=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,a,i,l,o]=t[1].split(", ").map(parseFloat);return{translateX:l,translateY:o,scaleX:n,scaleY:i,skewX:a,skewY:r}},de=()=>{if("undefined"==typeof window||!window.localStorage)return!1;try{return window.localStorage.getItem("__non_existing_key__"),!0}catch{return!1}},me=()=>{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}},pe=e=>e instanceof File,ge=e=>{if(!e)return[];const t=[];for(let n=0;n<e.length;n++)t.push(e[n]);return t},ye=(e,t)=>new File([e],t,{type:e.type}),we=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 U(r,async e=>e.isDirectory?we(e,{skipFiles:t}):n.has(e.name)?[]:[await new Promise((t,n)=>{e.file(t,n)})])).flat()},be=async(e,t={})=>{const n=e?.items;if(!n)return[];const r=[];for(let e=0;e<n.length;e++){const a=n[e];if("webkitGetAsEntry"in a){const e=a.webkitGetAsEntry?.();if(e?.isDirectory){r.push(we(e,t));continue}if(e?.isFile){r.push(new Promise((t,n)=>e.file(e=>t([e]),n)));continue}}const i=a.getAsFile();i&&r.push(Promise.resolve([i]))}return(await Promise.all(r)).flat()},Se=(e,...t)=>"function"==typeof e?e(...t):e,ve=({delta:e,value:t,min:n,max:r})=>{if(0===e)return null;const a=t+e;return e<0?t<=n?null:Math.max(a,n):e>0?t>=r?null:Math.min(a,r):null},Ae=({value:e,min:t,max:n,velocityPxMs:r,deltaTimeMs:a,friction:i=.002,minVelocityPxMs:l=.01,emaAlpha:o=.2})=>{if(Math.abs(r)<l)return null;const s=ve({delta:r*a,value:e,min:t,max:n});if(null===s)return null;const c=r*Math.exp(-i*a),u=o>0?r*(1-o)+c*o:c;return Math.abs(u)<l?null:{value:s,velocityPxMs:u}},Me=()=>`${Math.floor(1e3*performance.now()).toString(36)}${Math.random().toString(36).slice(2,10)}`,xe=(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),Ee=(e,t,{allowFallback:n=!0,invert:r=!0}={})=>{const a=r?-1:1;switch(t){case"x":return{deltaX:a*(0!==e.deltaX?e.deltaX:n?e.deltaY:0),deltaY:0};case"y":return{deltaX:0,deltaY:a*e.deltaY};default:return{deltaX:a*e.deltaX,deltaY:a*e.deltaY}}},Oe=(e,t,n,r)=>{const a=n-e,i=r-t;return Math.hypot(a,i)},Ce=(e,t)=>Math.abs(e/t),Te=(e,t)=>e*t/100,Ie=e=>{let t=5381;for(let n=0;n<e.length;n++)t=33*t^e.charCodeAt(n);return(t>>>0).toString(36)},Fe=e=>Object.entries(e).reduce((e,[t,n])=>(void 0!==n&&(e[t]=n),e),{}),Pe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),De=e=>{const t=e.charAt(0),n=e.slice(1);return t.toLowerCase()+n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)},_e=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),Le=e=>0===e.length?[]:e.split(" ").filter(Boolean),Ne=e=>""===e||f(e),ke=e=>{const t=e.lastIndexOf(".");return t<=0||t===e.length-1?[e,""]:[e.slice(0,t),e.slice(t+1).toLowerCase()]},Re=(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},je=(e,t,n)=>{if(0===e.length)return;const r=e.length;for(let a=0;a<r;a++){const i=e[a],l={charIndex:a,prevChar:a>0?e[a-1]:null,nextChar:a<r-1?e[a+1]:null};n?.(i,l)||t(i,l)}},Xe=(e,t=1/0)=>0===e.length?"":Le(e).slice(0,t).map(e=>e[0]).join("").toUpperCase(),We=(e,t,n,r=t)=>e.split(t).map((e,t)=>n(e.trim(),t)).join(r),Ye=(e,t,n,r=[],a=void 0,i=0)=>(e?.forEach(e=>{const{[n]:l,...o}=e,s=e[n],c=Array.isArray(s);if(r.push({...o,parentId:a,depthLevel:i,childCount:c?s.length:0}),c){const a=e[t];Ye(s,t,n,r,a,i+1)}}),r),$e=(e,t,n)=>e.filter(e=>e.parentId===t&&(!n||n(e))),He=(e,t,n,r)=>{const a=Le(r.toLowerCase());if(!a.length)return e;const i=e.reduce((e,n,r)=>(e[n[t]]=r,e),{});return e.reduce((r,l)=>{const o=l[n];if(!o)return r;if(r.some(e=>e[t]===l[t]))return r;const s=Le(o.toLowerCase());if(a.every(e=>s.some(t=>t.startsWith(e))))if(m(l.parentId)){r.push(l);const n=a=>{a.childCount&&e.forEach(e=>{e.parentId===a[t]&&(r.push(e),n(e))})};n(l)}else{const t=n=>{const a=i[n.parentId],l=e[a];m(l.parentId)||t(l);const o=r.length?r[r.length-1].parentId:null;(h(o)||o!==n.parentId)&&(u(l,"[@react-hive/honey-utils]: Parent node was not found."),r.push(l))};t(l),r.push(l)}return r},[])},ze=(e,t)=>{u(t>=0&&t<=1,`[@react-hive/honey-utils]: Alpha "${t}" must be a number between 0 and 1.`);const n=e.match(/^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/);u(n,`[@react-hive/honey-utils]: Invalid hex format: ${e}`);const r=n[1];return`#${(3===r.length?r[0]+r[0]+r[1]+r[1]+r[2]+r[2]:r)+Math.round(255*t).toString(16).toUpperCase().padStart(2,"0")}`};module.exports=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={};e.r(t),e.d(t,{DATA_TRANSFER_JSON_MIME:()=>ne,FOCUSABLE_HTML_TAGS:()=>i,applyInertiaStep:()=>xe,assert:()=>p,blobToFile:()=>we,calculateCenterOffset:()=>he,calculateEuclideanDistance:()=>Oe,calculateMovingSpeed:()=>Ce,calculatePercentage:()=>Te,camelToDashCase:()=>_e,camelToWords:()=>Le,centerElementInContainer:()=>fe,chunk:()=>N,cloneBlob:()=>n,compact:()=>k,compose:()=>h,definedProps:()=>Pe,delay:()=>Q,difference:()=>f,downloadFile:()=>ie,everyAsync:()=>G,fileListToFiles:()=>ye,filterParallel:()=>q,filterSequential:()=>J,findAsync:()=>K,findCharIndices:()=>je,flattenTree:()=>$e,forEachChar:()=>Xe,generateEphemeralId:()=>Ie,getAdjacentItems:()=>X,getDOMRectIntersectionRatio:()=>Me,getDataTransferJson:()=>ae,getElementOffsetRect:()=>r,getFocusableHtmlElements:()=>s,getLocalStorageCapabilities:()=>pe,getTreeChildren:()=>He,getWordsInitials:()=>We,getXOverflowWidth:()=>se,getYOverflowHeight:()=>ue,hasXOverflow:()=>oe,hasYOverflow:()=>ce,hashString:()=>Fe,hexWithAlpha:()=>Ue,intersection:()=>m,invokeIfFunction:()=>ve,isAnchorHtmlElement:()=>a,isArray:()=>R,isBlob:()=>M,isBool:()=>v,isContentEditableHtmlElement:()=>l,isDate:()=>I,isDecimal:()=>L,isDefined:()=>w,isEmptyArray:()=>j,isEmptyObject:()=>x,isError:()=>E,isFile:()=>ge,isFiniteNumber:()=>D,isFunction:()=>Y,isHtmlElementFocusable:()=>o,isInteger:()=>_,isLocalStorageReadable:()=>me,isMap:()=>T,isNil:()=>y,isNilOrEmptyString:()=>ke,isNull:()=>g,isNumber:()=>S,isObject:()=>A,isPromise:()=>z,isRegExp:()=>C,isSet:()=>F,isString:()=>le,isSymbol:()=>P,isUndefined:()=>b,isValidDate:()=>O,moveFocusWithinContainer:()=>c,noop:()=>W,not:()=>$,once:()=>H,parse2DMatrix:()=>de,parseFileName:()=>Re,pipe:()=>u,readFilesFromDataTransfer:()=>Se,reduceAsync:()=>Z,resolveAxisDelta:()=>Ee,resolveBoundedDelta:()=>Ae,retry:()=>te,runParallel:()=>B,runSequential:()=>U,searchTree:()=>ze,setDataTransferJson:()=>re,someAsync:()=>V,splitMapJoin:()=>Ye,splitStringIntoWords:()=>Ne,timeout:()=>ee,toKebabCase:()=>De,traverseFileSystemDirectory:()=>be,unique:()=>d});const n=e=>new Blob([e],{type:e.type}),r=e=>new DOMRect(e.offsetLeft,e.offsetTop,e.clientWidth,e.clientHeight),a=e=>"A"===e.tagName,l=e=>"true"===e.getAttribute("contenteditable"),i=["INPUT","SELECT","TEXTAREA","BUTTON","A"],o=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&&(i.includes(e.tagName)?!a(e)||""!==e.href:!!l(e)||null!==n)},s=e=>Array.from(e.querySelectorAll("*")).filter(o),c=(e,t=null,{wrap:n=!0,getNextIndex:r}={})=>{const a=document.activeElement,l=t??a?.parentElement;if(!a||!l)return;const i=s(l);if(0===i.length)return;const o=i.indexOf(a);if(-1===o)return;let c;r?c=r(o,e,i):"next"===e?(c=o+1,c>=i.length&&(c=n?0:null)):(c=o-1,c<0&&(c=n?i.length-1:null)),null!==c&&i[c]?.focus()},u=(...e)=>t=>e.reduce((e,t)=>t(e),t),h=(...e)=>t=>e.reduceRight((e,t)=>t(e),t),f=(e,t)=>e.filter(e=>!t.includes(e)),d=e=>[...new Set(e)],m=(...e)=>{if(0===e.length)return[];if(1===e.length)return[...e[0]];const[t,...n]=e;return d(t).filter(e=>n.every(t=>t.includes(e)))};function p(e,t){if(!e)throw new Error(t)}const g=e=>null===e,y=e=>null==e,w=e=>null!=e,b=e=>void 0===e,S=e=>"number"==typeof e,v=e=>"boolean"==typeof e,A=e=>"object"==typeof e,x=e=>A(e)&&!g(e)&&0===Object.keys(e).length,I=e=>e instanceof Date,M=e=>e instanceof Blob,E=e=>e instanceof Error,O=e=>I(e)&&!isNaN(e.getTime()),C=e=>e instanceof RegExp,T=e=>e instanceof Map,F=e=>e instanceof Set,P=e=>"symbol"==typeof e,D=e=>S(e)&&isFinite(e),_=e=>S(e)&&Number.isInteger(e),L=e=>D(e)&&!Number.isInteger(e),N=(e,t)=>(p(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))),k=e=>e.filter(Boolean),R=e=>Array.isArray(e),j=e=>R(e)&&0===e.length,X=(e,t,n)=>{if(!e?.length||!t)return{previousItem:null,currentItem:null,nextItem:null};const r=e.findIndex(e=>n(e,t));return-1===r?{previousItem:null,currentItem:null,nextItem:null}:{previousItem:r>0?e[r-1]:null,currentItem:e[r],nextItem:r<e.length-1?e[r+1]:null}},W=()=>{},Y=e=>"function"==typeof e,$=e=>(...t)=>!e(...t),H=e=>{let t,n=!1;return function(...r){return n||(n=!0,t=e.apply(this,r)),t}},z=e=>Y(e?.then),U=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++)n.push(await t(e[r],r,e));return n},B=async(e,t)=>Promise.all(e.map(t)),J=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++){const a=e[r];await t(a,r,e)&&n.push(a)}return n},q=async(e,t)=>{const n=await B(e,async(e,n,r)=>!!await t(e,n,r)&&e);return k(n)},V=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return!0;return!1},G=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},K=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return e[n];return null},Q=e=>new Promise(t=>setTimeout(t,e)),ee=async(e,t,n="Operation timed out")=>{try{return await Promise.race([e,Q(t).then(()=>Promise.reject(new Error(n)))])}finally{}},te=(e,{maxAttempts:t=3,delayMs:n=300,backoff:r=!0,onRetry:a}={})=>async(...l)=>{let i;for(let o=1;o<=t;o++)try{return await e(...l)}catch(e){if(i=e,o<t){a?.(o,e);const t=r?n*2**(o-1):n;await Q(t)}}throw i},ne="application/json",re=(e,t)=>{e.setData(ne,JSON.stringify(t))},ae=e=>{const t=e.getData(ne);if(t)try{return JSON.parse(t)}catch{return}},le=e=>"string"==typeof e,ie=(e,{fileName:t,target:n}={})=>{if(b(document))return;const r=document.createElement("a");let a=null;try{const l=le(e)?e:a=URL.createObjectURL(e);r.href=l,t&&(r.download=t),n&&(r.target=n),document.body.appendChild(r),r.click()}finally{r.remove(),a&&setTimeout(()=>{p(a,"Object URL should not be null"),URL.revokeObjectURL(a)},0)}},oe=e=>e.scrollWidth>e.clientWidth,se=e=>Math.max(0,e.scrollWidth-e.clientWidth),ce=e=>e.scrollHeight>e.clientHeight,ue=e=>Math.max(0,e.scrollHeight-e.clientHeight),he=({overflowSize:e,containerSize:t,elementOffset:n,elementSize:r})=>{if(e<=0)return 0;const a=n+r/2-t/2;return-Math.max(0,Math.min(a,e))},fe=(e,t,{axis:n="both"}={})=>{let r=0,a=0;"x"!==n&&"both"!==n||(r=he({overflowSize:se(e),containerSize:e.clientWidth,elementOffset:t.offsetLeft,elementSize:t.clientWidth})),"y"!==n&&"both"!==n||(a=he({overflowSize:ue(e),containerSize:e.clientHeight,elementOffset:t.offsetTop,elementSize:t.clientHeight})),e.style.transform=`translate(${r}px, ${a}px)`},de=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,a,l,i,o]=t[1].split(", ").map(parseFloat);return{translateX:i,translateY:o,scaleX:n,scaleY:l,skewX:a,skewY:r}},me=()=>{if("undefined"==typeof window||!window.localStorage)return!1;try{return window.localStorage.getItem("__non_existing_key__"),!0}catch{return!1}},pe=()=>{if(!me())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}},ge=e=>e instanceof File,ye=e=>{if(!e)return[];const t=[];for(let n=0;n<e.length;n++)t.push(e[n]);return t},we=(e,t)=>new File([e],t,{type:e.type}),be=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 B(r,async e=>e.isDirectory?be(e,{skipFiles:t}):n.has(e.name)?[]:[await new Promise((t,n)=>{e.file(t,n)})])).flat()},Se=async(e,t={})=>{const n=e?.items;if(!n)return[];const r=[];for(let e=0;e<n.length;e++){const a=n[e];if("webkitGetAsEntry"in a){const e=a.webkitGetAsEntry?.();if(e?.isDirectory){r.push(be(e,t));continue}if(e?.isFile){r.push(new Promise((t,n)=>e.file(e=>t([e]),n)));continue}}const l=a.getAsFile();l&&r.push(Promise.resolve([l]))}return(await Promise.all(r)).flat()},ve=(e,...t)=>"function"==typeof e?e(...t):e,Ae=({delta:e,value:t,min:n,max:r})=>{if(0===e)return null;const a=t+e;return e<0?t<=n?null:Math.max(a,n):e>0?t>=r?null:Math.min(a,r):null},xe=({value:e,min:t,max:n,velocityPxMs:r,deltaTimeMs:a,friction:l=.002,minVelocityPxMs:i=.01,emaAlpha:o=.2})=>{if(Math.abs(r)<i)return null;const s=Ae({delta:r*a,value:e,min:t,max:n});if(null===s)return null;const c=r*Math.exp(-l*a),u=o>0?r*(1-o)+c*o:c;return Math.abs(u)<i?null:{value:s,velocityPxMs:u}},Ie=()=>`${Math.floor(1e3*performance.now()).toString(36)}${Math.random().toString(36).slice(2,10)}`,Me=(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),Ee=(e,t,{allowFallback:n=!0,invert:r=!0}={})=>{const a=r?-1:1;switch(t){case"x":return{deltaX:a*(0!==e.deltaX?e.deltaX:n?e.deltaY:0),deltaY:0};case"y":return{deltaX:0,deltaY:a*e.deltaY};default:return{deltaX:a*e.deltaX,deltaY:a*e.deltaY}}},Oe=(e,t,n,r)=>{const a=n-e,l=r-t;return Math.hypot(a,l)},Ce=(e,t)=>Math.abs(e/t),Te=(e,t)=>e*t/100,Fe=e=>{let t=5381;for(let n=0;n<e.length;n++)t=33*t^e.charCodeAt(n);return(t>>>0).toString(36)},Pe=e=>Object.entries(e).reduce((e,[t,n])=>(void 0!==n&&(e[t]=n),e),{}),De=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),_e=e=>{const t=e.charAt(0),n=e.slice(1);return t.toLowerCase()+n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)},Le=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),Ne=e=>0===e.length?[]:e.split(" ").filter(Boolean),ke=e=>""===e||y(e),Re=e=>{const t=e.lastIndexOf(".");return t<=0||t===e.length-1?[e,""]:[e.slice(0,t),e.slice(t+1).toLowerCase()]},je=(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},Xe=(e,t,n)=>{if(0===e.length)return;const r=e.length;for(let a=0;a<r;a++){const l=e[a],i={charIndex:a,prevChar:a>0?e[a-1]:null,nextChar:a<r-1?e[a+1]:null};n?.(l,i)||t(l,i)}},We=(e,t=1/0)=>0===e.length?"":Ne(e).slice(0,t).map(e=>e[0]).join("").toUpperCase(),Ye=(e,t,n,r=t)=>e.split(t).map((e,t)=>n(e.trim(),t)).join(r),$e=(e,t,n,r=[],a=void 0,l=0)=>(e?.forEach(e=>{const{[n]:i,...o}=e,s=e[n],c=Array.isArray(s);if(r.push({...o,parentId:a,depthLevel:l,childCount:c?s.length:0}),c){const a=e[t];$e(s,t,n,r,a,l+1)}}),r),He=(e,t,n)=>e.filter(e=>e.parentId===t&&(!n||n(e))),ze=(e,t,n,r)=>{const a=Ne(r.toLowerCase());if(!a.length)return e;const l=e.reduce((e,n,r)=>(e[n[t]]=r,e),{});return e.reduce((r,i)=>{const o=i[n];if(!o)return r;if(r.some(e=>e[t]===i[t]))return r;const s=Ne(o.toLowerCase());if(a.every(e=>s.some(t=>t.startsWith(e))))if(b(i.parentId)){r.push(i);const n=a=>{a.childCount&&e.forEach(e=>{e.parentId===a[t]&&(r.push(e),n(e))})};n(i)}else{const t=n=>{const a=l[n.parentId],i=e[a];b(i.parentId)||t(i);const o=r.length?r[r.length-1].parentId:null;(g(o)||o!==n.parentId)&&(p(i,"[@react-hive/honey-utils]: Parent node was not found."),r.push(i))};t(i),r.push(i)}return r},[])},Ue=(e,t)=>{p(t>=0&&t<=1,`[@react-hive/honey-utils]: Alpha "${t}" must be a number between 0 and 1.`);const n=e.match(/^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/);p(n,`[@react-hive/honey-utils]: Invalid hex format: ${e}`);const r=n[1];return`#${(3===r.length?r[0]+r[0]+r[1]+r[1]+r[2]+r[2]:r)+Math.round(255*t).toString(16).toUpperCase().padStart(2,"0")}`};module.exports=t})();
2
2
  //# sourceMappingURL=index.cjs.map