@machinerd/js-module 0.8.0 → 0.9.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 -0
- package/dist/api-client-C0sbSOQf.mjs +1 -0
- package/dist/api-client-C3o2pO0q.cjs +1 -0
- package/dist/button-CQZuaIU7.mjs +1 -0
- package/dist/button-ChX3XGbR.cjs +1 -0
- package/dist/button-DHvx-GAg.d.cts +50 -0
- package/dist/button-DRIyBtEB.d.mts +50 -0
- package/dist/common-B8HXyhZa.cjs +1 -0
- package/dist/common-CWHkXe0F.mjs +1 -0
- package/dist/{common-Bn0Ko6B7.cjs → common-D4sUwkFd.cjs} +1 -1
- package/dist/{common-Df03Ovdm.mjs → common-ZUMpASnc.mjs} +1 -1
- package/dist/editor/index.cjs +1 -0
- package/dist/editor/index.d.cts +80 -0
- package/dist/editor/index.d.mts +80 -0
- package/dist/editor/index.mjs +1 -0
- package/dist/format-1_RTNUQv.mjs +1 -0
- package/dist/format-DEuImTYJ.cjs +1 -0
- package/dist/hooks/common/index.cjs +1 -0
- package/dist/hooks/common/index.d.cts +72 -0
- package/dist/hooks/common/index.d.mts +72 -0
- package/dist/hooks/common/index.mjs +1 -0
- package/dist/hooks/use-snackbar.cjs +1 -0
- package/dist/hooks/use-snackbar.d.cts +10 -0
- package/dist/hooks/use-snackbar.d.mts +10 -0
- package/dist/hooks/use-snackbar.mjs +1 -0
- package/dist/{index-B3fFA21M.d.mts → index-B1YNV_Vm.d.cts} +4 -0
- package/dist/{index-CeiAF-WU.d.cts → index-C8chDULk.d.mts} +4 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/providers/api-client/index.cjs +1 -0
- package/dist/providers/{index.d.cts → api-client/index.d.cts} +3 -3
- package/dist/providers/{index.d.mts → api-client/index.d.mts} +3 -3
- package/dist/providers/api-client/index.mjs +1 -0
- package/dist/providers/noti-stack/index.cjs +1 -0
- package/dist/providers/noti-stack/index.d.cts +11 -0
- package/dist/providers/noti-stack/index.d.mts +11 -0
- package/dist/providers/noti-stack/index.mjs +1 -0
- package/dist/{skeleton-DtV9S1QK.cjs → skeleton-B5ZccRFX.cjs} +1 -1
- package/dist/{skeleton-B6_oBhkl.mjs → skeleton-Y22bmaaB.mjs} +1 -1
- package/dist/src-6KfzqI9Z.cjs +1 -0
- package/dist/src-CIMlbgv1.mjs +1 -0
- package/dist/styles/editor.css +255 -0
- package/dist/styles/index.css +371 -0
- package/dist/ui/carousel/index.cjs +1 -1
- package/dist/ui/carousel/index.d.cts +9 -9
- package/dist/ui/carousel/index.d.mts +9 -9
- package/dist/ui/carousel/index.mjs +1 -1
- package/dist/ui/dialog/index.cjs +1 -1
- package/dist/ui/dialog/index.d.cts +1 -1
- package/dist/ui/dialog/index.d.mts +2 -2
- package/dist/ui/dialog/index.mjs +1 -1
- package/dist/ui/dnd/index.cjs +1 -0
- package/dist/ui/dnd/index.d.cts +17 -0
- package/dist/ui/dnd/index.d.mts +17 -0
- package/dist/ui/dnd/index.mjs +1 -0
- package/dist/ui/dropdown/index.cjs +1 -0
- package/dist/ui/dropdown/index.d.cts +72 -0
- package/dist/ui/dropdown/index.d.mts +72 -0
- package/dist/ui/dropdown/index.mjs +1 -0
- package/dist/ui/image/index.cjs +1 -1
- package/dist/ui/image/index.d.cts +8 -8
- package/dist/ui/image/index.d.mts +8 -8
- package/dist/ui/image/index.mjs +1 -1
- package/dist/ui/index.cjs +1 -1
- package/dist/ui/index.d.cts +12 -55
- package/dist/ui/index.d.mts +12 -55
- package/dist/ui/index.mjs +1 -1
- package/dist/ui/motion-dialog/index.cjs +1 -0
- package/dist/ui/motion-dialog/index.d.cts +34 -0
- package/dist/ui/motion-dialog/index.d.mts +34 -0
- package/dist/ui/motion-dialog/index.mjs +1 -0
- package/dist/ui/preserve-focus-button/index.cjs +1 -0
- package/dist/ui/preserve-focus-button/index.d.cts +12 -0
- package/dist/ui/preserve-focus-button/index.d.mts +12 -0
- package/dist/ui/preserve-focus-button/index.mjs +1 -0
- package/dist/ui/sheet/index.cjs +1 -1
- package/dist/ui/sheet/index.d.mts +2 -2
- package/dist/ui/sheet/index.mjs +1 -1
- package/dist/ui/switch/index.cjs +1 -0
- package/dist/ui/switch/index.d.cts +16 -0
- package/dist/ui/switch/index.d.mts +16 -0
- package/dist/ui/switch/index.mjs +1 -0
- package/dist/ui/tooltip/index.cjs +1 -1
- package/dist/ui/tooltip/index.d.cts +2 -2
- package/dist/ui/tooltip/index.mjs +1 -1
- package/dist/ui-Bs9PP9eC.cjs +1 -0
- package/dist/ui-D2DoC_0E.mjs +1 -0
- package/dist/use-dialog-stack-Crj8YWJl.mjs +1 -0
- package/dist/use-dialog-stack-YiLs-sNf.cjs +1 -0
- package/dist/use-drag-resize-BdeLdulk.mjs +1 -0
- package/dist/use-drag-resize-DEgcua2U.d.cts +48 -0
- package/dist/use-drag-resize-DRHPv5RK.d.mts +48 -0
- package/dist/use-drag-resize-DeDqPC4h.cjs +1 -0
- package/dist/use-subset-image-Df2fCrtH.mjs +1 -0
- package/dist/use-subset-image-Dygkyw-W.d.mts +601 -0
- package/dist/use-subset-image-bDB5TSd4.d.cts +601 -0
- package/dist/use-subset-image-o_gmC1HL.cjs +1 -0
- package/dist/util/common.cjs +1 -1
- package/dist/util/common.d.cts +9 -2
- package/dist/util/common.d.mts +9 -2
- package/dist/util/common.mjs +1 -1
- package/dist/util/editor.cjs +1 -0
- package/dist/util/editor.d.cts +21 -0
- package/dist/util/editor.d.mts +21 -0
- package/dist/util/editor.mjs +1 -0
- package/dist/util/fetcher.cjs +1 -0
- package/dist/util/fetcher.d.cts +15 -0
- package/dist/util/fetcher.d.mts +15 -0
- package/dist/util/fetcher.mjs +1 -0
- package/dist/util/file.mjs +1 -1
- package/dist/util/format.cjs +1 -1
- package/dist/util/format.d.cts +29 -1
- package/dist/util/format.d.mts +29 -1
- package/dist/util/format.mjs +1 -1
- package/package.json +104 -33
- package/dist/hooks/index.cjs +0 -1
- package/dist/hooks/index.d.cts +0 -2
- package/dist/hooks/index.d.mts +0 -2
- package/dist/hooks/index.mjs +0 -1
- package/dist/hooks--O5RcEJq.cjs +0 -1
- package/dist/hooks-C9rXWkfW.mjs +0 -1
- package/dist/index-B11XDBo5.d.cts +0 -655
- package/dist/index-dbBlRf5k.d.mts +0 -655
- package/dist/providers/index.cjs +0 -1
- package/dist/providers/index.mjs +0 -1
- package/dist/providers-CkXkdYcB.cjs +0 -1
- package/dist/providers-zftmvT1z.mjs +0 -1
- package/dist/src-CjpmdVyv.cjs +0 -1
- package/dist/src-CukOR3K2.mjs +0 -1
- package/dist/use-subset-image-D8ssrZhj.mjs +0 -1
- package/dist/use-subset-image-DC86cg6O.cjs +0 -1
- /package/dist/{file-DShNxIW4.mjs → file-B-UJkabO.mjs} +0 -0
package/dist/util/common.d.mts
CHANGED
|
@@ -31,7 +31,7 @@ declare const getI18nValue: <T extends {
|
|
|
31
31
|
}>(locale?: string, values?: T[], key?: keyof T) => string;
|
|
32
32
|
declare const comparePriorityAsc: <T extends {
|
|
33
33
|
priority: number;
|
|
34
|
-
}>(a: T, b: T) =>
|
|
34
|
+
}>(a: T, b: T) => 0 | 1 | -1;
|
|
35
35
|
declare const parseQuery: <T, F = T>(q: string | string[] | undefined | null, conv: (v: string) => T, fallback: F) => T | F;
|
|
36
36
|
declare const withoutProperty: <T, K extends keyof T>(obj: T, property: K) => Omit<T, K>;
|
|
37
37
|
declare const withoutProperties: <T extends Record<string, unknown>>(obj: T, properties: Array<keyof T>) => T;
|
|
@@ -52,5 +52,12 @@ declare const selectItemByWeight: <T extends {
|
|
|
52
52
|
}>(itemsWithWeights: T[]) => T;
|
|
53
53
|
declare const sleep: (ms: number) => Promise<unknown>;
|
|
54
54
|
declare const cn: (...classes: Array<string | false | null | undefined>) => string;
|
|
55
|
+
declare const sortI18nByPriority: <T>(data: T, fields: string, priorityLocale: string[]) => T;
|
|
56
|
+
interface ImageInfo {
|
|
57
|
+
originalWidth: number;
|
|
58
|
+
originalHeight: number;
|
|
59
|
+
originalName: string;
|
|
60
|
+
}
|
|
61
|
+
declare const getImageInfo: (file: File) => Promise<ImageInfo>;
|
|
55
62
|
//#endregion
|
|
56
|
-
export { calcPageCount, cn, comparePriorityAsc, composeKey, existLeastOne, getFirstLocationAddress, getFullAddress, getI18nKey, getI18nValue, getI18nValues, getModelName, link, loadExLib, parseQuery, productSlugify, selectItemByWeight, shuffle, sleep, slugify, withoutProperties, withoutProperty };
|
|
63
|
+
export { calcPageCount, cn, comparePriorityAsc, composeKey, existLeastOne, getFirstLocationAddress, getFullAddress, getI18nKey, getI18nValue, getI18nValues, getImageInfo, getModelName, link, loadExLib, parseQuery, productSlugify, selectItemByWeight, shuffle, sleep, slugify, sortI18nByPriority, withoutProperties, withoutProperty };
|
package/dist/util/common.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{C as e,S as t,_ as n,a as r,b as i,c as a,d as o,f as s,g as c,h as l,i as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,t as v,u as y,v as b,x,y as S}from"../common-ZUMpASnc.mjs";export{v as calcPageCount,p as cn,g as comparePriorityAsc,u as composeKey,r as existLeastOne,m as getFirstLocationAddress,_ as getFullAddress,a as getI18nKey,d as getI18nValue,y as getI18nValues,o as getImageInfo,s as getModelName,h as link,f as loadExLib,l as parseQuery,c as productSlugify,n as selectItemByWeight,b as shuffle,S as sleep,i as slugify,x as sortI18nByPriority,t as withoutProperties,e as withoutProperty};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../chunk-Bmb41Sf3.cjs`);let t=require(`@tiptap/core`);const n=(e,t)=>!e.content||!Array.isArray(e.content)?e:{...e,content:e.content.filter(e=>!t.includes(e.type)).map(e=>n(e,t))},r=(e,r=[],i)=>{if(!i||e.length===0)return i;try{return(0,t.generateHTML)(n((0,t.generateJSON)(i,r),e),r)}catch(e){return console.error(`Failed to remove Tiptap nodes:`,e),i}},i=[`description`,`desc`];function a(e,t=[],n=[],a={}){let{default:o,fields:s=i}=a,c=o!==void 0;if(e===null)return null;if(e!==void 0){if(typeof e==`string`){let i=r(n,t,e);return c?i||o:i}return Array.isArray(e)?e.map(e=>{let i={};for(let a of s){if(!(a in e))continue;let s=e[a];if(s!=null&&typeof s!=`string`)continue;let l=s==null?s:r(n,t,s);i[a]=c?l||o:l}return Object.keys(i).length>0?{...e,...i}:e}):e}}const o=.75;function s(e){let{view:n,state:r}=e,{from:i,to:a}=r.selection,o=(0,t.posToDOMRect)(n,i,a),s=n.dom.getBoundingClientRect(),c=r.doc.content.size;return i<=1&&a>=c-1||o.height>=s.height*.75}function c(e){let{view:t,state:n}=e,{from:r,to:i}=n.selection,a=t.coordsAtPos(r),o=t.coordsAtPos(i),s=t.dom.getBoundingClientRect(),c=Math.max(s.top,0),l=Math.min(s.bottom,window.innerHeight),u=Math.min(a.top,o.top),d=Math.max(a.bottom,o.bottom),f=Math.max(u,c),p=Math.min(d,l),m=s.left,h=s.right,g=(f+p)/2;return new DOMRect(m,g,Math.max(h-m,0),0)}exports.isLargeTextSelection=s,exports.parseDescription=a,exports.removeNodes=r,exports.visibleSelectionRect=c;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Editor, Extension, Node } from "@tiptap/core";
|
|
2
|
+
|
|
3
|
+
//#region src/util/editor.d.ts
|
|
4
|
+
declare const removeNodes: (nodeNames: string[], extensions?: Array<Extension | Node>, html?: string | null) => string | null | undefined;
|
|
5
|
+
interface ParseOptions {
|
|
6
|
+
default?: string | null;
|
|
7
|
+
}
|
|
8
|
+
interface ParseArrayOptions<F extends string> extends ParseOptions {
|
|
9
|
+
fields?: readonly F[];
|
|
10
|
+
}
|
|
11
|
+
declare function parseDescription(input: string, extensions: Array<Extension | Node>, excludeNodes: string[], options?: ParseOptions): string;
|
|
12
|
+
declare function parseDescription(input: null, extensions: Array<Extension | Node>, excludeNodes: string[], options?: ParseOptions): null;
|
|
13
|
+
declare function parseDescription(input: undefined, extensions: Array<Extension | Node>, excludeNodes: string[], options?: ParseOptions): undefined;
|
|
14
|
+
declare function parseDescription(input: string | null | undefined, extensions: Array<Extension | Node>, excludeNodes: string[], options?: ParseOptions): string | null | undefined;
|
|
15
|
+
declare function parseDescription(input: string | null, extensions: Array<Extension | Node>, excludeNodes: string[], options?: ParseOptions): string | null;
|
|
16
|
+
declare function parseDescription(input: string | undefined, extensions: Array<Extension | Node>, excludeNodes: string[], options?: ParseOptions): string | undefined;
|
|
17
|
+
declare function parseDescription<T extends Record<string, any>>(input: T[], extensions: Array<Extension | Node>, excludeNodes: string[], options?: ParseArrayOptions<Extract<keyof T, string>>): T[];
|
|
18
|
+
declare function isLargeTextSelection(editor: Editor): boolean;
|
|
19
|
+
declare function visibleSelectionRect(editor: Editor): DOMRect;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { isLargeTextSelection, parseDescription, removeNodes, visibleSelectionRect };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Editor, Extension, Node } from "@tiptap/core";
|
|
2
|
+
|
|
3
|
+
//#region src/util/editor.d.ts
|
|
4
|
+
declare const removeNodes: (nodeNames: string[], extensions?: Array<Extension | Node>, html?: string | null) => string | null | undefined;
|
|
5
|
+
interface ParseOptions {
|
|
6
|
+
default?: string | null;
|
|
7
|
+
}
|
|
8
|
+
interface ParseArrayOptions<F extends string> extends ParseOptions {
|
|
9
|
+
fields?: readonly F[];
|
|
10
|
+
}
|
|
11
|
+
declare function parseDescription(input: string, extensions: Array<Extension | Node>, excludeNodes: string[], options?: ParseOptions): string;
|
|
12
|
+
declare function parseDescription(input: null, extensions: Array<Extension | Node>, excludeNodes: string[], options?: ParseOptions): null;
|
|
13
|
+
declare function parseDescription(input: undefined, extensions: Array<Extension | Node>, excludeNodes: string[], options?: ParseOptions): undefined;
|
|
14
|
+
declare function parseDescription(input: string | null | undefined, extensions: Array<Extension | Node>, excludeNodes: string[], options?: ParseOptions): string | null | undefined;
|
|
15
|
+
declare function parseDescription(input: string | null, extensions: Array<Extension | Node>, excludeNodes: string[], options?: ParseOptions): string | null;
|
|
16
|
+
declare function parseDescription(input: string | undefined, extensions: Array<Extension | Node>, excludeNodes: string[], options?: ParseOptions): string | undefined;
|
|
17
|
+
declare function parseDescription<T extends Record<string, any>>(input: T[], extensions: Array<Extension | Node>, excludeNodes: string[], options?: ParseArrayOptions<Extract<keyof T, string>>): T[];
|
|
18
|
+
declare function isLargeTextSelection(editor: Editor): boolean;
|
|
19
|
+
declare function visibleSelectionRect(editor: Editor): DOMRect;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { isLargeTextSelection, parseDescription, removeNodes, visibleSelectionRect };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{generateHTML as e,generateJSON as t,posToDOMRect as n}from"@tiptap/core";const r=(e,t)=>!e.content||!Array.isArray(e.content)?e:{...e,content:e.content.filter(e=>!t.includes(e.type)).map(e=>r(e,t))},i=(n,i=[],a)=>{if(!a||n.length===0)return a;try{return e(r(t(a,i),n),i)}catch(e){return console.error(`Failed to remove Tiptap nodes:`,e),a}},a=[`description`,`desc`];function o(e,t=[],n=[],r={}){let{default:o,fields:s=a}=r,c=o!==void 0;if(e===null)return null;if(e!==void 0){if(typeof e==`string`){let r=i(n,t,e);return c?r||o:r}return Array.isArray(e)?e.map(e=>{let r={};for(let a of s){if(!(a in e))continue;let s=e[a];if(s!=null&&typeof s!=`string`)continue;let l=s==null?s:i(n,t,s);r[a]=c?l||o:l}return Object.keys(r).length>0?{...e,...r}:e}):e}}function s(e){let{view:t,state:r}=e,{from:i,to:a}=r.selection,o=n(t,i,a),s=t.dom.getBoundingClientRect(),c=r.doc.content.size;return i<=1&&a>=c-1||o.height>=s.height*.75}function c(e){let{view:t,state:n}=e,{from:r,to:i}=n.selection,a=t.coordsAtPos(r),o=t.coordsAtPos(i),s=t.dom.getBoundingClientRect(),c=Math.max(s.top,0),l=Math.min(s.bottom,window.innerHeight),u=Math.min(a.top,o.top),d=Math.max(a.bottom,o.bottom),f=Math.max(u,c),p=Math.min(d,l),m=s.left,h=s.right,g=(f+p)/2;return new DOMRect(m,g,Math.max(h-m,0),0)}export{s as isLargeTextSelection,o as parseDescription,i as removeNodes,c as visibleSelectionRect};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=(e,t,n)=>async r=>(await e({input:{filter:{...n?.filter,...r.filter},page:n?.page||r.page||1,pageSize:n?.pageSize||r.pageSize||10,sort:n?.sort||r.sort||[]}}))[t];exports.createSdkFetcher=e;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/util/fetcher.d.ts
|
|
2
|
+
interface BaseInput<Filter extends Record<string, any> = Record<string, any>> {
|
|
3
|
+
filter?: Filter;
|
|
4
|
+
page: number;
|
|
5
|
+
pageSize: number;
|
|
6
|
+
sort?: string[];
|
|
7
|
+
}
|
|
8
|
+
declare const createSdkFetcher: <TQuery extends Record<string, {
|
|
9
|
+
total: number;
|
|
10
|
+
list: any[];
|
|
11
|
+
}>, TKey extends keyof TQuery, TInput extends BaseInput = BaseInput>(func: (variables: {
|
|
12
|
+
input: TInput;
|
|
13
|
+
}) => Promise<TQuery>, key: TKey, customInput?: Partial<TInput>) => (input: TInput) => Promise<TQuery[TKey]>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { BaseInput, createSdkFetcher };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/util/fetcher.d.ts
|
|
2
|
+
interface BaseInput<Filter extends Record<string, any> = Record<string, any>> {
|
|
3
|
+
filter?: Filter;
|
|
4
|
+
page: number;
|
|
5
|
+
pageSize: number;
|
|
6
|
+
sort?: string[];
|
|
7
|
+
}
|
|
8
|
+
declare const createSdkFetcher: <TQuery extends Record<string, {
|
|
9
|
+
total: number;
|
|
10
|
+
list: any[];
|
|
11
|
+
}>, TKey extends keyof TQuery, TInput extends BaseInput = BaseInput>(func: (variables: {
|
|
12
|
+
input: TInput;
|
|
13
|
+
}) => Promise<TQuery>, key: TKey, customInput?: Partial<TInput>) => (input: TInput) => Promise<TQuery[TKey]>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { BaseInput, createSdkFetcher };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=(e,t,n)=>async r=>(await e({input:{filter:{...n?.filter,...r.filter},page:n?.page||r.page||1,pageSize:n?.pageSize||r.pageSize||10,sort:n?.sort||r.sort||[]}}))[t];export{e as createSdkFetcher};
|
package/dist/util/file.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,t as a}from"../file-
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,t as a}from"../file-B-UJkabO.mjs";export{a as formatBytes,n as getFileExtension,i as getFilename,t as isExternalSrc,e as isSrcSetCompatible,r as parsePath};
|
package/dist/util/format.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=(
|
|
1
|
+
const e=require(`../format-DEuImTYJ.cjs`);exports.computeAspectRatio=e.t,exports.formatCompactNumber=e.n,exports.formatExceedNumber=e.r,exports.formatKoNumber=e.i;
|
package/dist/util/format.d.cts
CHANGED
|
@@ -2,5 +2,33 @@
|
|
|
2
2
|
declare const formatCompactNumber: (number: number, locale?: string, options?: Intl.NumberFormatOptions) => string;
|
|
3
3
|
declare const formatExceedNumber: (number: number, threshold: number, suffix?: string) => string;
|
|
4
4
|
declare const formatKoNumber: (number?: number | string | null) => string;
|
|
5
|
+
interface ComputeAspectRatioParams {
|
|
6
|
+
min: {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
max: {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
};
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
type: 'width' | 'height';
|
|
17
|
+
currentRatio?: number;
|
|
18
|
+
}
|
|
19
|
+
type ComputeAspectRatioWarning = 'width-under-min' | 'width-over-max' | 'height-under-min';
|
|
20
|
+
interface ComputeAspectRatioResult {
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
result: ComputeAspectRatioWarning | null;
|
|
24
|
+
}
|
|
25
|
+
declare const computeAspectRatio: ({
|
|
26
|
+
min,
|
|
27
|
+
max,
|
|
28
|
+
width,
|
|
29
|
+
height,
|
|
30
|
+
type,
|
|
31
|
+
currentRatio
|
|
32
|
+
}: ComputeAspectRatioParams) => ComputeAspectRatioResult;
|
|
5
33
|
//#endregion
|
|
6
|
-
export { formatCompactNumber, formatExceedNumber, formatKoNumber };
|
|
34
|
+
export { ComputeAspectRatioWarning, computeAspectRatio, formatCompactNumber, formatExceedNumber, formatKoNumber };
|
package/dist/util/format.d.mts
CHANGED
|
@@ -2,5 +2,33 @@
|
|
|
2
2
|
declare const formatCompactNumber: (number: number, locale?: string, options?: Intl.NumberFormatOptions) => string;
|
|
3
3
|
declare const formatExceedNumber: (number: number, threshold: number, suffix?: string) => string;
|
|
4
4
|
declare const formatKoNumber: (number?: number | string | null) => string;
|
|
5
|
+
interface ComputeAspectRatioParams {
|
|
6
|
+
min: {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
max: {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
};
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
type: 'width' | 'height';
|
|
17
|
+
currentRatio?: number;
|
|
18
|
+
}
|
|
19
|
+
type ComputeAspectRatioWarning = 'width-under-min' | 'width-over-max' | 'height-under-min';
|
|
20
|
+
interface ComputeAspectRatioResult {
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
result: ComputeAspectRatioWarning | null;
|
|
24
|
+
}
|
|
25
|
+
declare const computeAspectRatio: ({
|
|
26
|
+
min,
|
|
27
|
+
max,
|
|
28
|
+
width,
|
|
29
|
+
height,
|
|
30
|
+
type,
|
|
31
|
+
currentRatio
|
|
32
|
+
}: ComputeAspectRatioParams) => ComputeAspectRatioResult;
|
|
5
33
|
//#endregion
|
|
6
|
-
export { formatCompactNumber, formatExceedNumber, formatKoNumber };
|
|
34
|
+
export { ComputeAspectRatioWarning, computeAspectRatio, formatCompactNumber, formatExceedNumber, formatKoNumber };
|
package/dist/util/format.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{i as e,n as t,r as n,t as r}from"../format-1_RTNUQv.mjs";export{r as computeAspectRatio,t as formatCompactNumber,n as formatExceedNumber,e as formatKoNumber};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@machinerd/js-module",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
],
|
|
10
10
|
"sideEffects": [
|
|
11
11
|
"**/*.css",
|
|
12
|
-
"./dist/styles/index.css"
|
|
12
|
+
"./dist/styles/index.css",
|
|
13
|
+
"./dist/styles/editor.css"
|
|
13
14
|
],
|
|
14
15
|
"exports": {
|
|
15
16
|
".": {
|
|
@@ -28,6 +29,10 @@
|
|
|
28
29
|
"import": "./dist/util/date.mjs",
|
|
29
30
|
"require": "./dist/util/date.cjs"
|
|
30
31
|
},
|
|
32
|
+
"./util/fetcher": {
|
|
33
|
+
"import": "./dist/util/fetcher.mjs",
|
|
34
|
+
"require": "./dist/util/fetcher.cjs"
|
|
35
|
+
},
|
|
31
36
|
"./util/file": {
|
|
32
37
|
"import": "./dist/util/file.mjs",
|
|
33
38
|
"require": "./dist/util/file.cjs"
|
|
@@ -44,6 +49,14 @@
|
|
|
44
49
|
"import": "./dist/util/phone.mjs",
|
|
45
50
|
"require": "./dist/util/phone.cjs"
|
|
46
51
|
},
|
|
52
|
+
"./util/editor": {
|
|
53
|
+
"import": "./dist/util/editor.mjs",
|
|
54
|
+
"require": "./dist/util/editor.cjs"
|
|
55
|
+
},
|
|
56
|
+
"./editor": {
|
|
57
|
+
"import": "./dist/editor/index.mjs",
|
|
58
|
+
"require": "./dist/editor/index.cjs"
|
|
59
|
+
},
|
|
47
60
|
"./ui/common": {
|
|
48
61
|
"import": "./dist/ui/index.mjs",
|
|
49
62
|
"require": "./dist/ui/index.cjs"
|
|
@@ -56,6 +69,22 @@
|
|
|
56
69
|
"import": "./dist/ui/dialog/index.mjs",
|
|
57
70
|
"require": "./dist/ui/dialog/index.cjs"
|
|
58
71
|
},
|
|
72
|
+
"./ui/motion-dialog": {
|
|
73
|
+
"import": "./dist/ui/motion-dialog/index.mjs",
|
|
74
|
+
"require": "./dist/ui/motion-dialog/index.cjs"
|
|
75
|
+
},
|
|
76
|
+
"./ui/dnd": {
|
|
77
|
+
"import": "./dist/ui/dnd/index.mjs",
|
|
78
|
+
"require": "./dist/ui/dnd/index.cjs"
|
|
79
|
+
},
|
|
80
|
+
"./ui/dropdown": {
|
|
81
|
+
"import": "./dist/ui/dropdown/index.mjs",
|
|
82
|
+
"require": "./dist/ui/dropdown/index.cjs"
|
|
83
|
+
},
|
|
84
|
+
"./ui/preserve-focus-button": {
|
|
85
|
+
"import": "./dist/ui/preserve-focus-button/index.mjs",
|
|
86
|
+
"require": "./dist/ui/preserve-focus-button/index.cjs"
|
|
87
|
+
},
|
|
59
88
|
"./ui/image": {
|
|
60
89
|
"import": "./dist/ui/image/index.mjs",
|
|
61
90
|
"require": "./dist/ui/image/index.cjs"
|
|
@@ -64,29 +93,49 @@
|
|
|
64
93
|
"import": "./dist/ui/sheet/index.mjs",
|
|
65
94
|
"require": "./dist/ui/sheet/index.cjs"
|
|
66
95
|
},
|
|
96
|
+
"./ui/switch": {
|
|
97
|
+
"import": "./dist/ui/switch/index.mjs",
|
|
98
|
+
"require": "./dist/ui/switch/index.cjs"
|
|
99
|
+
},
|
|
67
100
|
"./ui/tooltip": {
|
|
68
101
|
"import": "./dist/ui/tooltip/index.mjs",
|
|
69
102
|
"require": "./dist/ui/tooltip/index.cjs"
|
|
70
103
|
},
|
|
71
|
-
"./hooks": {
|
|
72
|
-
"import": "./dist/hooks/index.mjs",
|
|
73
|
-
"require": "./dist/hooks/index.cjs"
|
|
104
|
+
"./hooks/common": {
|
|
105
|
+
"import": "./dist/hooks/common/index.mjs",
|
|
106
|
+
"require": "./dist/hooks/common/index.cjs"
|
|
107
|
+
},
|
|
108
|
+
"./hooks/use-snackbar": {
|
|
109
|
+
"import": "./dist/hooks/use-snackbar.mjs",
|
|
110
|
+
"require": "./dist/hooks/use-snackbar.cjs"
|
|
74
111
|
},
|
|
75
|
-
"./providers": {
|
|
76
|
-
"import": "./dist/providers/index.mjs",
|
|
77
|
-
"require": "./dist/providers/index.cjs"
|
|
112
|
+
"./providers/api-client": {
|
|
113
|
+
"import": "./dist/providers/api-client/index.mjs",
|
|
114
|
+
"require": "./dist/providers/api-client/index.cjs"
|
|
78
115
|
},
|
|
79
|
-
"./
|
|
116
|
+
"./providers/noti-stack": {
|
|
117
|
+
"import": "./dist/providers/noti-stack/index.mjs",
|
|
118
|
+
"require": "./dist/providers/noti-stack/index.cjs"
|
|
119
|
+
},
|
|
120
|
+
"./styles/index.css": "./dist/styles/index.css",
|
|
121
|
+
"./styles/editor.css": "./dist/styles/editor.css"
|
|
80
122
|
},
|
|
81
123
|
"keywords": [],
|
|
82
124
|
"author": "KOMACHINE",
|
|
83
125
|
"license": "MIT",
|
|
84
126
|
"devDependencies": {
|
|
127
|
+
"@dnd-kit/core": "^6.3.1",
|
|
128
|
+
"@dnd-kit/modifiers": "^9.0.0",
|
|
129
|
+
"@dnd-kit/sortable": "^10.0.0",
|
|
130
|
+
"@dnd-kit/utilities": "^3.2.2",
|
|
85
131
|
"@eslint/js": "^9.39.5",
|
|
132
|
+
"@floating-ui/react": "^0.27.16",
|
|
86
133
|
"@storybook/addon-docs": "^10.3.5",
|
|
87
|
-
"@storybook/react-vite": "^10.
|
|
134
|
+
"@storybook/react-vite": "^10.5.10",
|
|
88
135
|
"@tailwindcss/postcss": "^4.1.18",
|
|
89
|
-
"@
|
|
136
|
+
"@tiptap/core": "^3.2.0",
|
|
137
|
+
"@tiptap/pm": "^3.2.0",
|
|
138
|
+
"@tiptap/react": "^3.2.0",
|
|
90
139
|
"@types/google-libphonenumber": "^7.4.30",
|
|
91
140
|
"@types/js-cookie": "^3.0.6",
|
|
92
141
|
"@types/lodash-es": "^4.17.12",
|
|
@@ -102,59 +151,81 @@
|
|
|
102
151
|
"eslint-plugin-prettier": "^5.5.6",
|
|
103
152
|
"eslint-plugin-react": "^7.37.5",
|
|
104
153
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
105
|
-
"motion": "^
|
|
154
|
+
"motion": "^13.1.1",
|
|
155
|
+
"notistack": "^3.0.0",
|
|
106
156
|
"postcss": "^8.5.6",
|
|
107
157
|
"prettier": "^3.9.6",
|
|
108
158
|
"react": "^18.3.1",
|
|
109
159
|
"react-dom": "^18.3.1",
|
|
110
|
-
"
|
|
111
|
-
"react-select": "^5.10.2",
|
|
112
|
-
"react-select-async-paginate": "^0.7.11",
|
|
113
|
-
"storybook": "^10.2.3",
|
|
160
|
+
"storybook": "^10.5.10",
|
|
114
161
|
"tailwindcss": "^4.1.18",
|
|
115
162
|
"tsdown": "0.17.0-beta.5",
|
|
116
163
|
"typescript": "^5.9.3",
|
|
117
164
|
"typescript-eslint": "^8.65.0"
|
|
118
165
|
},
|
|
119
166
|
"dependencies": {
|
|
120
|
-
"@radix-ui/react-slot": "^1.
|
|
167
|
+
"@radix-ui/react-slot": "^1.3.3",
|
|
121
168
|
"class-variance-authority": "^0.7.1",
|
|
122
169
|
"clsx": "^2.1.1",
|
|
123
|
-
"dayjs": "^1.11.
|
|
124
|
-
"google-libphonenumber": "^3.2.
|
|
125
|
-
"js-cookie": "^3.0.
|
|
126
|
-
"lodash-es": "^4.
|
|
127
|
-
"nanoid": "^
|
|
128
|
-
"query-string": "^9.
|
|
129
|
-
"slug": "^
|
|
170
|
+
"dayjs": "^1.11.23",
|
|
171
|
+
"google-libphonenumber": "^3.2.46",
|
|
172
|
+
"js-cookie": "^3.0.8",
|
|
173
|
+
"lodash-es": "^4.18.1",
|
|
174
|
+
"nanoid": "^6.0.1",
|
|
175
|
+
"query-string": "^9.5.0",
|
|
176
|
+
"slug": "^12.0.1"
|
|
130
177
|
},
|
|
131
178
|
"peerDependencies": {
|
|
179
|
+
"@dnd-kit/core": "^6.0.0",
|
|
180
|
+
"@dnd-kit/modifiers": "^9.0.0",
|
|
181
|
+
"@dnd-kit/sortable": "^10.0.0",
|
|
182
|
+
"@dnd-kit/utilities": "^3.0.0",
|
|
183
|
+
"@floating-ui/react": "^0.27.0",
|
|
184
|
+
"@tiptap/core": "^3.2.0",
|
|
185
|
+
"@tiptap/pm": "^3.2.0",
|
|
186
|
+
"@tiptap/react": "^3.2.0",
|
|
132
187
|
"embla-carousel": "^8.0.0",
|
|
133
188
|
"embla-carousel-react": "^8.0.0",
|
|
134
|
-
"
|
|
189
|
+
"notistack": "^3.0.0",
|
|
190
|
+
"motion": "^13.0.0",
|
|
135
191
|
"react": "^18.3.1 || ^19.0.0",
|
|
136
|
-
"react-dom": "^18.3.1 || ^19.0.0"
|
|
137
|
-
"react-hook-form": "^7.0.0",
|
|
138
|
-
"react-select": "^5.0.0",
|
|
139
|
-
"react-select-async-paginate": "^0.7.0"
|
|
192
|
+
"react-dom": "^18.3.1 || ^19.0.0"
|
|
140
193
|
},
|
|
141
194
|
"peerDependenciesMeta": {
|
|
195
|
+
"@dnd-kit/core": {
|
|
196
|
+
"optional": true
|
|
197
|
+
},
|
|
198
|
+
"@dnd-kit/modifiers": {
|
|
199
|
+
"optional": true
|
|
200
|
+
},
|
|
201
|
+
"@dnd-kit/sortable": {
|
|
202
|
+
"optional": true
|
|
203
|
+
},
|
|
204
|
+
"@dnd-kit/utilities": {
|
|
205
|
+
"optional": true
|
|
206
|
+
},
|
|
207
|
+
"@floating-ui/react": {
|
|
208
|
+
"optional": true
|
|
209
|
+
},
|
|
142
210
|
"embla-carousel": {
|
|
143
211
|
"optional": true
|
|
144
212
|
},
|
|
145
213
|
"embla-carousel-react": {
|
|
146
214
|
"optional": true
|
|
147
215
|
},
|
|
216
|
+
"notistack": {
|
|
217
|
+
"optional": true
|
|
218
|
+
},
|
|
148
219
|
"motion": {
|
|
149
220
|
"optional": true
|
|
150
221
|
},
|
|
151
|
-
"
|
|
222
|
+
"@tiptap/core": {
|
|
152
223
|
"optional": true
|
|
153
224
|
},
|
|
154
|
-
"
|
|
225
|
+
"@tiptap/pm": {
|
|
155
226
|
"optional": true
|
|
156
227
|
},
|
|
157
|
-
"react
|
|
228
|
+
"@tiptap/react": {
|
|
158
229
|
"optional": true
|
|
159
230
|
}
|
|
160
231
|
},
|
|
@@ -163,7 +234,7 @@
|
|
|
163
234
|
"build": "tsdown && pnpm build:css",
|
|
164
235
|
"build:pack": "pnpm build && pnpm pack",
|
|
165
236
|
"build:tsc": "pnpm tsc",
|
|
166
|
-
"build:css": "pnpm dlx @tailwindcss/cli -i src/styles/index.css -o dist/styles/index.css",
|
|
237
|
+
"build:css": "pnpm dlx @tailwindcss/cli -i src/styles/index.css -o dist/styles/index.css && cp src/styles/editor.css dist/styles/editor.css",
|
|
167
238
|
"storybook": "storybook dev -p 6006",
|
|
168
239
|
"build-storybook": "storybook build",
|
|
169
240
|
"lint": "eslint --cache --fix"
|
package/dist/hooks/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require(`../src-CjpmdVyv.cjs`),require(`../file-5mweNdAM.cjs`);const e=require(`../hooks--O5RcEJq.cjs`);require(`../providers-CkXkdYcB.cjs`);const t=require(`../use-subset-image-DC86cg6O.cjs`);exports.SUBSETS=t.t,exports.useDelayUnmount=e.o,exports.useDragScroll=e.a,exports.useOutsideClick=e.i,exports.useScrollLock=e.r,exports.useScrollTop=e.n,exports.useSubsetImage=t.n,exports.useWindowSize=e.t;
|
package/dist/hooks/index.d.cts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { a as UseSubsetImageProps, c as useScrollTop, d as UseOutsideClickProps, f as useOutsideClick, i as SUBSETS, l as UseScrollLockProps, m as useDelayUnmount, n as BaseProps, o as useSubsetImage, p as useDragScroll, r as Folder, s as UseScrollTopProps, t as useWindowSize, u as useScrollLock } from "../index-B11XDBo5.cjs";
|
|
2
|
-
export { BaseProps, Folder, SUBSETS, UseOutsideClickProps, UseScrollLockProps, UseScrollTopProps, UseSubsetImageProps, useDelayUnmount, useDragScroll, useOutsideClick, useScrollLock, useScrollTop, useSubsetImage, useWindowSize };
|
package/dist/hooks/index.d.mts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { a as UseSubsetImageProps, c as useScrollTop, d as UseOutsideClickProps, f as useOutsideClick, i as SUBSETS, l as UseScrollLockProps, m as useDelayUnmount, n as BaseProps, o as useSubsetImage, p as useDragScroll, r as Folder, s as UseScrollTopProps, t as useWindowSize, u as useScrollLock } from "../index-dbBlRf5k.mjs";
|
|
2
|
-
export { BaseProps, Folder, SUBSETS, UseOutsideClickProps, UseScrollLockProps, UseScrollTopProps, UseSubsetImageProps, useDelayUnmount, useDragScroll, useOutsideClick, useScrollLock, useScrollTop, useSubsetImage, useWindowSize };
|
package/dist/hooks/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"../src-CukOR3K2.mjs";import"../file-DShNxIW4.mjs";import{a as e,i as t,n,o as r,r as i,t as a}from"../hooks-C9rXWkfW.mjs";import"../providers-zftmvT1z.mjs";import{n as o,t as s}from"../use-subset-image-D8ssrZhj.mjs";export{s as SUBSETS,r as useDelayUnmount,e as useDragScroll,t as useOutsideClick,i as useScrollLock,n as useScrollTop,o as useSubsetImage,a as useWindowSize};
|
package/dist/hooks--O5RcEJq.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require(`./chunk-Bmb41Sf3.cjs`);let t=require(`lodash-es`),n=require(`react`);function r(e,t){let[r,i]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{let n;return e&&!r?i(!0):!e&&r&&(n=setTimeout(()=>i(!1),t)),()=>clearTimeout(n)},[e,t,r]),r}function i(e=1){let t=(0,n.useRef)(null),[r,i]=(0,n.useState)(!1),[a,o]=(0,n.useState)(0),[s,c]=(0,n.useState)(0),l=(0,n.useRef)(!1);return{ref:t,onMouseDown:e=>{t.current&&(i(!0),l.current=!1,o(e.pageX-t.current.offsetLeft),c(t.current.scrollLeft))},onMouseLeave:()=>i(!1),onMouseUp:()=>i(!1),onMouseMove:n=>{if(!r||!t.current)return;n.preventDefault();let i=(n.pageX-t.current.offsetLeft-a)*e;Math.abs(i)>10&&(l.current=!0),t.current.scrollLeft=s-i},onClickCapture:e=>{l.current&&(e.stopPropagation(),e.preventDefault())}}}function a({ref:e,setOpen:t}){let r=(0,n.useCallback)(n=>{e.current?.contains(n.target)||t(!1)},[e,t]);(0,n.useEffect)(()=>(document.addEventListener(`mousedown`,r),document.addEventListener(`touchstart`,r),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`touchstart`,r)}),[r])}const o=[`mouse`,`touch`];function s({open:e,type:t=o}){let r=(0,n.useCallback)(e=>{e.preventDefault()},[]),i=(0,n.useCallback)(e=>{e.preventDefault()},[]);(0,n.useEffect)(()=>{let n=e&&t.includes(`mouse`),a=e&&t.includes(`touch`);return n?(document.body.classList.add(`overflow-hidden`),document.addEventListener(`wheel`,i,{passive:!1})):(document.body.classList.remove(`overflow-hidden`),document.removeEventListener(`wheel`,i)),a?document.addEventListener(`touchmove`,r,{passive:!1}):document.removeEventListener(`touchmove`,r),()=>{document.body.classList.remove(`overflow-hidden`),document.removeEventListener(`touchmove`,r),document.removeEventListener(`wheel`,i)}},[e,t,r,i])}function c({enabled:e=!0,behavior:t=`smooth`}={}){let[r,i]=(0,n.useState)(!1),a=(0,n.useRef)(null),o=(0,n.useCallback)(()=>{window.scrollTo({top:0,behavior:t})},[t]);return(0,n.useEffect)(()=>{let t=a.current;if(!t||!e){i(!1);return}let n=new IntersectionObserver(e=>{let t=e[0];t&&i(!t.isIntersecting)},{root:null,rootMargin:`0px`,threshold:0});return n.observe(t),()=>n.disconnect()},[e]),{isVisible:r,handleScrolToTop:o,ref:a}}function l(e=1280){let[r,i]=(0,n.useState)(e);return(0,n.useEffect)(()=>{let e=(0,t.throttle)(()=>{let e=window.innerWidth;i(e)},200);return window.addEventListener(`resize`,e),e(),()=>window.removeEventListener(`resize`,e)},[]),{windowSize:r}}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return l}});
|
package/dist/hooks-C9rXWkfW.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{throttle as e}from"lodash-es";import{useCallback as t,useEffect as n,useRef as r,useState as i}from"react";function a(e,t){let[r,a]=i(!1);return n(()=>{let n;return e&&!r?a(!0):!e&&r&&(n=setTimeout(()=>a(!1),t)),()=>clearTimeout(n)},[e,t,r]),r}function o(e=1){let t=r(null),[n,a]=i(!1),[o,s]=i(0),[c,l]=i(0),u=r(!1);return{ref:t,onMouseDown:e=>{t.current&&(a(!0),u.current=!1,s(e.pageX-t.current.offsetLeft),l(t.current.scrollLeft))},onMouseLeave:()=>a(!1),onMouseUp:()=>a(!1),onMouseMove:r=>{if(!n||!t.current)return;r.preventDefault();let i=(r.pageX-t.current.offsetLeft-o)*e;Math.abs(i)>10&&(u.current=!0),t.current.scrollLeft=c-i},onClickCapture:e=>{u.current&&(e.stopPropagation(),e.preventDefault())}}}function s({ref:e,setOpen:r}){let i=t(t=>{e.current?.contains(t.target)||r(!1)},[e,r]);n(()=>(document.addEventListener(`mousedown`,i),document.addEventListener(`touchstart`,i),()=>{document.removeEventListener(`mousedown`,i),document.removeEventListener(`touchstart`,i)}),[i])}const c=[`mouse`,`touch`];function l({open:e,type:r=c}){let i=t(e=>{e.preventDefault()},[]),a=t(e=>{e.preventDefault()},[]);n(()=>{let t=e&&r.includes(`mouse`),n=e&&r.includes(`touch`);return t?(document.body.classList.add(`overflow-hidden`),document.addEventListener(`wheel`,a,{passive:!1})):(document.body.classList.remove(`overflow-hidden`),document.removeEventListener(`wheel`,a)),n?document.addEventListener(`touchmove`,i,{passive:!1}):document.removeEventListener(`touchmove`,i),()=>{document.body.classList.remove(`overflow-hidden`),document.removeEventListener(`touchmove`,i),document.removeEventListener(`wheel`,a)}},[e,r,i,a])}function u({enabled:e=!0,behavior:a=`smooth`}={}){let[o,s]=i(!1),c=r(null),l=t(()=>{window.scrollTo({top:0,behavior:a})},[a]);return n(()=>{let t=c.current;if(!t||!e){s(!1);return}let n=new IntersectionObserver(e=>{let t=e[0];t&&s(!t.isIntersecting)},{root:null,rootMargin:`0px`,threshold:0});return n.observe(t),()=>n.disconnect()},[e]),{isVisible:o,handleScrolToTop:l,ref:c}}function d(t=1280){let[r,a]=i(t);return n(()=>{let t=e(()=>{let e=window.innerWidth;a(e)},200);return window.addEventListener(`resize`,t),t(),()=>window.removeEventListener(`resize`,t)},[]),{windowSize:r}}export{o as a,s as i,u as n,a as o,l as r,d as t};
|