@machinerd/js-module 0.0.10 → 0.1.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.
@@ -1,11 +1,21 @@
1
- //#region src/util/common.d.ts
2
- declare const displayDatetime: (date: string, format?: string, locale?: string) => string;
1
+ //#region src/util/browser.d.ts
3
2
  declare const getCookie: (key: string) => string | undefined;
4
3
  declare const setCookies: (key: string, value: string, options?: Cookies.CookieAttributes) => string | undefined;
4
+ declare const getSearchHistory: () => string[];
5
+ declare const insertSearchHistory: (item: string) => string[];
6
+ declare const deleteSearchHistory: (index: number) => string[];
7
+ declare const deleteAllSearchHistory: () => void;
8
+ declare const isSearchPage: (pathname: string) => boolean;
9
+ declare const appendSearchPath: (pathname: string) => string;
10
+ declare const clearSearchPath: (pathname: string) => string;
11
+ declare const clearQueryByKey: (query: Record<string, any>, key: string) => {
12
+ [k: string]: string;
13
+ };
14
+ //#endregion
15
+ //#region src/util/common.d.ts
5
16
  declare const link: (param: Record<string, string>, deleteKeys?: string[]) => string;
6
17
  declare const calcPageCount: (total: number, perPage: number) => number;
7
18
  declare const shuffle: <T>(arr: T[]) => T[];
8
- declare const randomNum: (min: number, max: number, count?: number) => number[];
9
19
  declare const loadExLib: (callback: () => void) => void;
10
20
  declare const recomposeI18nNumber: (locale: string, number?: string | null, i18nNumber?: string | null) => string;
11
21
  interface Country {
@@ -53,34 +63,12 @@ declare const getI18nValue: <T extends {
53
63
  declare const comparePriorityAsc: <T extends {
54
64
  priority: number;
55
65
  }>(a: T, b: T) => 0 | 1 | -1;
56
- declare const genNanoID: () => string;
57
- declare const printNanoID: (cnt: number) => void;
58
- declare const getSearchHistory: () => string[];
59
- declare const insertSearchHistory: (item: string) => string[];
60
- declare const deleteSearchHistory: (index: number) => string[];
61
- declare const deleteAllSearchHistory: () => void;
62
66
  declare const parseQuery: <T, F = T>(q: string | string[] | undefined | null, conv: (v: string) => T, fallback: F) => T | F;
63
67
  declare const withoutProperty: <T>(obj: T, property: keyof T) => Omit<T, keyof T>;
64
68
  declare const withoutProperties: <T extends Record<string, unknown>>(obj: T, properties: Array<keyof T>) => T;
65
69
  declare const existLeastOne: <T>(a: T[], b: T[]) => boolean;
66
- declare const isSearchPage: (pathname: string) => boolean;
67
- declare const appendSearchPath: (pathname: string) => string;
68
- declare const clearSearchPath: (pathname: string) => string;
69
- declare const clearQueryByKey: (query: Record<string, any>, key: string) => {
70
- [k: string]: string;
71
- };
72
70
  declare const getI18nKey: (key: string) => string | undefined;
73
71
  declare const composeKey: (prefix?: Array<string | number> | string, ...keys: Array<string | number>) => string;
74
- declare function formatBytes(bytes: number, decimals?: number): string;
75
- declare const getFilename: (s: string) => string;
76
- declare const getFileExtension: (s: string) => string | undefined;
77
- interface PathInfo {
78
- directory: string;
79
- filename: string;
80
- extension: string;
81
- filenameWithoutExtension: string;
82
- }
83
- declare const parsePath: (filepath: string, isStatic?: boolean) => PathInfo;
84
72
  interface Location<I extends LocationI18n = LocationI18n> {
85
73
  i18n: I[];
86
74
  }
@@ -93,5 +81,39 @@ declare const getFullAddress: (locale: string | undefined, values: LocationI18n[
93
81
  declare const selectItemByWeight: <T extends {
94
82
  weight: number;
95
83
  }>(itemsWithWeights: T[]) => T;
84
+ declare const sleep: (ms: number) => Promise<unknown>;
85
+ declare const cn: (...classes: Array<string | false | null | undefined>) => string;
86
+ //#endregion
87
+ //#region src/util/file.d.ts
88
+ declare function formatBytes(bytes: number, decimals?: number): string;
89
+ declare const getFilename: (s: string) => string;
90
+ declare const getFileExtension: (s: string) => string | undefined;
91
+ interface PathInfo {
92
+ directory: string;
93
+ filename: string;
94
+ extension: string;
95
+ filenameWithoutExtension: string;
96
+ }
97
+ declare const parsePath: (filepath: string, folder?: string) => PathInfo;
98
+ //#endregion
99
+ //#region src/util/date.d.ts
100
+ declare const displayDatetime: (date: string, format?: string, locale?: string) => string;
101
+ //#endregion
102
+ //#region src/util/generator.d.ts
103
+ declare const randomNum: (min: number, max: number, count?: number) => number[];
104
+ declare const genNanoID: () => string;
105
+ declare const printNanoID: (cnt: number) => void;
106
+ declare const generatePage: (count: number, page: number, pagePerView: number) => {
107
+ current: number;
108
+ start: number;
109
+ end: number;
110
+ };
111
+ declare const generatePageGroup: (count: number, page: number, pagePerView: number) => {
112
+ prev: number;
113
+ next: number;
114
+ isPrev: boolean;
115
+ isNext: boolean;
116
+ items: number[];
117
+ };
96
118
  //#endregion
97
- export { I18nNumberProps, appendSearchPath, calcPageCount, clearQueryByKey, clearSearchPath, comparePriorityAsc, composeKey, deleteAllSearchHistory, deleteSearchHistory, displayDatetime, existLeastOne, formatBytes, formatI18nNumber, genNanoID, getCookie, getFileExtension, getFilename, getFirstLocationAddress, getFullAddress, getI18nKey, getI18nValue, getI18nValues, getModelName, getSearchHistory, insertSearchHistory, isSearchPage, link, loadExLib, parsePath, parseQuery, printNanoID, productSlugify, randomNum, recomposeI18nNumber, selectItemByWeight, setCookies, shuffle, slugify, withoutProperties, withoutProperty };
119
+ export { I18nNumberProps, appendSearchPath, calcPageCount, clearQueryByKey, clearSearchPath, cn, comparePriorityAsc, composeKey, deleteAllSearchHistory, deleteSearchHistory, displayDatetime, existLeastOne, formatBytes, formatI18nNumber, genNanoID, generatePage, generatePageGroup, getCookie, getFileExtension, getFilename, getFirstLocationAddress, getFullAddress, getI18nKey, getI18nValue, getI18nValues, getModelName, getSearchHistory, insertSearchHistory, isSearchPage, link, loadExLib, parsePath, parseQuery, printNanoID, productSlugify, randomNum, recomposeI18nNumber, selectItemByWeight, setCookies, shuffle, sleep, slugify, withoutProperties, withoutProperty };
@@ -1,13 +1,23 @@
1
1
  import "dayjs/locale/ko.js";
2
2
 
3
- //#region src/util/common.d.ts
4
- declare const displayDatetime: (date: string, format?: string, locale?: string) => string;
3
+ //#region src/util/browser.d.ts
5
4
  declare const getCookie: (key: string) => string | undefined;
6
5
  declare const setCookies: (key: string, value: string, options?: Cookies.CookieAttributes) => string | undefined;
6
+ declare const getSearchHistory: () => string[];
7
+ declare const insertSearchHistory: (item: string) => string[];
8
+ declare const deleteSearchHistory: (index: number) => string[];
9
+ declare const deleteAllSearchHistory: () => void;
10
+ declare const isSearchPage: (pathname: string) => boolean;
11
+ declare const appendSearchPath: (pathname: string) => string;
12
+ declare const clearSearchPath: (pathname: string) => string;
13
+ declare const clearQueryByKey: (query: Record<string, any>, key: string) => {
14
+ [k: string]: string;
15
+ };
16
+ //#endregion
17
+ //#region src/util/common.d.ts
7
18
  declare const link: (param: Record<string, string>, deleteKeys?: string[]) => string;
8
19
  declare const calcPageCount: (total: number, perPage: number) => number;
9
20
  declare const shuffle: <T>(arr: T[]) => T[];
10
- declare const randomNum: (min: number, max: number, count?: number) => number[];
11
21
  declare const loadExLib: (callback: () => void) => void;
12
22
  declare const recomposeI18nNumber: (locale: string, number?: string | null, i18nNumber?: string | null) => string;
13
23
  interface Country {
@@ -55,34 +65,12 @@ declare const getI18nValue: <T extends {
55
65
  declare const comparePriorityAsc: <T extends {
56
66
  priority: number;
57
67
  }>(a: T, b: T) => 0 | 1 | -1;
58
- declare const genNanoID: () => string;
59
- declare const printNanoID: (cnt: number) => void;
60
- declare const getSearchHistory: () => string[];
61
- declare const insertSearchHistory: (item: string) => string[];
62
- declare const deleteSearchHistory: (index: number) => string[];
63
- declare const deleteAllSearchHistory: () => void;
64
68
  declare const parseQuery: <T, F = T>(q: string | string[] | undefined | null, conv: (v: string) => T, fallback: F) => T | F;
65
69
  declare const withoutProperty: <T>(obj: T, property: keyof T) => Omit<T, keyof T>;
66
70
  declare const withoutProperties: <T extends Record<string, unknown>>(obj: T, properties: Array<keyof T>) => T;
67
71
  declare const existLeastOne: <T>(a: T[], b: T[]) => boolean;
68
- declare const isSearchPage: (pathname: string) => boolean;
69
- declare const appendSearchPath: (pathname: string) => string;
70
- declare const clearSearchPath: (pathname: string) => string;
71
- declare const clearQueryByKey: (query: Record<string, any>, key: string) => {
72
- [k: string]: string;
73
- };
74
72
  declare const getI18nKey: (key: string) => string | undefined;
75
73
  declare const composeKey: (prefix?: Array<string | number> | string, ...keys: Array<string | number>) => string;
76
- declare function formatBytes(bytes: number, decimals?: number): string;
77
- declare const getFilename: (s: string) => string;
78
- declare const getFileExtension: (s: string) => string | undefined;
79
- interface PathInfo {
80
- directory: string;
81
- filename: string;
82
- extension: string;
83
- filenameWithoutExtension: string;
84
- }
85
- declare const parsePath: (filepath: string, isStatic?: boolean) => PathInfo;
86
74
  interface Location<I extends LocationI18n = LocationI18n> {
87
75
  i18n: I[];
88
76
  }
@@ -95,5 +83,39 @@ declare const getFullAddress: (locale: string | undefined, values: LocationI18n[
95
83
  declare const selectItemByWeight: <T extends {
96
84
  weight: number;
97
85
  }>(itemsWithWeights: T[]) => T;
86
+ declare const sleep: (ms: number) => Promise<unknown>;
87
+ declare const cn: (...classes: Array<string | false | null | undefined>) => string;
88
+ //#endregion
89
+ //#region src/util/file.d.ts
90
+ declare function formatBytes(bytes: number, decimals?: number): string;
91
+ declare const getFilename: (s: string) => string;
92
+ declare const getFileExtension: (s: string) => string | undefined;
93
+ interface PathInfo {
94
+ directory: string;
95
+ filename: string;
96
+ extension: string;
97
+ filenameWithoutExtension: string;
98
+ }
99
+ declare const parsePath: (filepath: string, folder?: string) => PathInfo;
100
+ //#endregion
101
+ //#region src/util/date.d.ts
102
+ declare const displayDatetime: (date: string, format?: string, locale?: string) => string;
103
+ //#endregion
104
+ //#region src/util/generator.d.ts
105
+ declare const randomNum: (min: number, max: number, count?: number) => number[];
106
+ declare const genNanoID: () => string;
107
+ declare const printNanoID: (cnt: number) => void;
108
+ declare const generatePage: (count: number, page: number, pagePerView: number) => {
109
+ current: number;
110
+ start: number;
111
+ end: number;
112
+ };
113
+ declare const generatePageGroup: (count: number, page: number, pagePerView: number) => {
114
+ prev: number;
115
+ next: number;
116
+ isPrev: boolean;
117
+ isNext: boolean;
118
+ items: number[];
119
+ };
98
120
  //#endregion
99
- export { I18nNumberProps, appendSearchPath, calcPageCount, clearQueryByKey, clearSearchPath, comparePriorityAsc, composeKey, deleteAllSearchHistory, deleteSearchHistory, displayDatetime, existLeastOne, formatBytes, formatI18nNumber, genNanoID, getCookie, getFileExtension, getFilename, getFirstLocationAddress, getFullAddress, getI18nKey, getI18nValue, getI18nValues, getModelName, getSearchHistory, insertSearchHistory, isSearchPage, link, loadExLib, parsePath, parseQuery, printNanoID, productSlugify, randomNum, recomposeI18nNumber, selectItemByWeight, setCookies, shuffle, slugify, withoutProperties, withoutProperty };
121
+ export { I18nNumberProps, appendSearchPath, calcPageCount, clearQueryByKey, clearSearchPath, cn, comparePriorityAsc, composeKey, deleteAllSearchHistory, deleteSearchHistory, displayDatetime, existLeastOne, formatBytes, formatI18nNumber, genNanoID, generatePage, generatePageGroup, getCookie, getFileExtension, getFilename, getFirstLocationAddress, getFullAddress, getI18nKey, getI18nValue, getI18nValues, getModelName, getSearchHistory, insertSearchHistory, isSearchPage, link, loadExLib, parsePath, parseQuery, printNanoID, productSlugify, randomNum, recomposeI18nNumber, selectItemByWeight, setCookies, shuffle, sleep, slugify, withoutProperties, withoutProperty };
@@ -1 +1 @@
1
- import e from"js-cookie";import t from"query-string";import n from"dayjs";import"dayjs/locale/ko.js";import r from"dayjs/plugin/relativeTime.js";import{intersection as i,uniq as a}from"lodash-es";import{customAlphabet as o}from"nanoid";import s from"slug";import c from"google-libphonenumber";const l=c.PhoneNumberFormat,u=c.PhoneNumberUtil.getInstance();n.extend(r),s.extend({'"':`-`,"”":`-`,"“":`-`,"•":`----`}),s.setLocale(`en`);const d=(e,t=`YYYY-MM-DD`,r=`en`)=>{let i=n(e).locale(r);return n().diff(i,`hour`)<12?i.fromNow():i.format(t)},f=t=>e.get(t),p=(t,n,r)=>e.set(t,n,r),m=(e,n=[])=>{if(typeof window>`u`)return``;let{hash:r,search:i}=window.location,a=t.parse(i);Object.keys(e).forEach(t=>{e[t]?a[t]=e[t]:delete a[t]});let o={...a};return Object.keys(a).forEach(e=>{n.includes(e)&&delete o[e]}),`?${t.stringify(o,{encode:!0})}${r}`},h=(e,t)=>{let n=0;return e%t===0&&(n=e/t),n=Math.ceil(e/t),n<1&&(n=1),n},g=e=>{let t=[...e];for(let e=t.length-1;e>0;e--){let n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t},_=(e,t)=>{let n=[];for(let r=e;r<t;r++)n.push(r);return n},v=(e,t,n=1)=>{let r=[],i=_(e,t);for(;r.length<n;){let t=Math.ceil(e),n=Math.floor(i.length),a=Math.floor(Math.random()*(n-t))+t,o=i.splice(a,1);r.push(o[0])}return[...r]},y=e=>{let t=document.getElementById(`naverMapLib`);if(!t){let t=document.createElement(`script`);t.src=`https://oapi.map.naver.com/openapi/v3/maps.js?ncpKeyId=ecs1pyoo9b`,t.id=`naverMapLib`,document.body.appendChild(t),t.onload=()=>{e&&e()}}t&&e&&e()},b=(e,t,n)=>t?e===`ko`&&n&&n!==`82`||e!==`ko`&&n?`+${n}-${t.replace(/^0/,``)}`:t:`-`,x=({phone:e,country:t={callingCode:`82`,alpha2Code:`KR`},format:n=l.INTERNATIONAL,locale:r})=>{if(!e||e===`-`)return`-`;try{let i=u.parseAndKeepRawInput(e,t?.alpha2Code||`KR`),a=i.getCountryCode();return r===`ko`&&t?.alpha2Code===`KR`&&a===82?u.format(i,l.NATIONAL):u.format(i,n)}catch{return b(r||`en`,e,t?.callingCode)}},S=(e,...t)=>{let n=`${e}`;return t.forEach(e=>{e&&(n=`${n}-${s(e)}`)}),n},C=e=>{let t=[];e.i18n?.forEach(e=>{e.locale===`en`&&e.name&&t.push(e.name)});let n=e.series?.i18n.find(e=>e.locale===`en`);return n?.name&&t.push(n.name.toLowerCase()),e.stockNo&&t.push(e.stockNo[0]),S(e.id,...t)},w=e=>{let t=e;return t.length>0?t[0].trim():``},T=(e=`en`,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(D);if(e){let t=r.findIndex(t=>t.locale===e);if(t){let e=r.splice(t,1);r.unshift(e[0])}}for(let e of r){let t=e[n];if(!(Array.isArray(t)&&t.length===0)&&t)return t}return``},E=(e,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(D);if(e){let t=r.findIndex(t=>t.locale===e);if(t){let e=r.splice(t,1);r.unshift(e[0])}}let i=``;for(let e of r){let t=e[n];if(t){i=String(t);break}}return i},D=(e,t)=>e.priority<t.priority?-1:e.priority>t.priority?1:0,O=()=>o(`0123456789abcdefghijklmnopqrstuvwxyz`,5)(),k=e=>{for(let t=0;t<e;t++)console.log(O())},A=()=>typeof window>`u`?[]:JSON.parse(localStorage.getItem(`search-history`)||`[]`),j=e=>{let t=a([e,...A()]).slice(0,10);return localStorage.setItem(`search-history`,JSON.stringify(t)),t},M=e=>{let t=A();return t.splice(e,1),localStorage.setItem(`search-history`,JSON.stringify(t)),t},N=()=>{localStorage.setItem(`search-history`,JSON.stringify([]))},P=(e,t,n)=>{if(e){let r;r=Array.isArray(e)?e[0]:e;try{return t(r)}catch{return n}}return n},F=(e,t)=>{let{[t]:n,...r}=e;return r},I=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e))),L=(e,t)=>i(e,t).length>0,R=e=>e.endsWith(`/search`),z=e=>R(e)?e:`${e}/search`.replace(`//`,`/`),B=e=>e.replace(`/search`,``).replace(`//`,`/`),V=(e,t)=>{let n=new URLSearchParams(e);return n.delete(t),Object.fromEntries(n)},H=e=>e.split(`:`).pop()?.split(`.`).pop(),U=(e,...t)=>[e,t].flat().join(`.`).replace(`:.`,`.`);function W(e,t=0){if(e==0)return`0 Bytes`;let n=1024,r=t,i=[`Bytes`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],a=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/n**+a).toFixed(r))+` `+i[a]}const G=e=>e.split(`.`).slice(0,-1).join(`.`),K=e=>e.split(`.`).pop(),q=(e,t)=>{let n={directory:``,filename:``,extension:``,filenameWithoutExtension:``},r=e.lastIndexOf(`/`),i=r>=0?e.substring(r+1):e,a=i.lastIndexOf(`.`),o=a>0?i.substring(a+1):``,s=a>0?i.substring(0,a):i;if(n.filename=i,n.extension=o,n.filenameWithoutExtension=s,e.startsWith(`http`)){let r=t?`/static/`:`/media/`,i=e.indexOf(r);if(i!==-1){let t=e.substring(i+r.length),a=t.lastIndexOf(`/`);return n.directory=a===-1?``:t.substring(0,a),n}}return n.directory=r===-1?``:e.substring(0,r),n},J=(e=`en`,t)=>{if(t.length<=0)return`-`;let n=t[0];return n?Y(e,n.i18n):`-`},Y=(e=`en`,t)=>{if(t.length===0)return``;let n=T(e,t,`address1`)?.replace(`대한민국`,``)||``,r=t.find(t=>t.locale===e)?.address2,i=[n];return e===`ko`?i.push(r):i.unshift(r),i.filter(Boolean).join(`, `).trim()},X=e=>{let t=0;for(let n of e)t+=n.weight;let n=Math.random()*t,r=0;for(let t of e)if(r+=t.weight,n<r)return t;return e[e.length-1]};export{z as appendSearchPath,h as calcPageCount,V as clearQueryByKey,B as clearSearchPath,D as comparePriorityAsc,U as composeKey,N as deleteAllSearchHistory,M as deleteSearchHistory,d as displayDatetime,L as existLeastOne,W as formatBytes,x as formatI18nNumber,O as genNanoID,f as getCookie,K as getFileExtension,G as getFilename,J as getFirstLocationAddress,Y as getFullAddress,H as getI18nKey,E as getI18nValue,T as getI18nValues,w as getModelName,A as getSearchHistory,j as insertSearchHistory,R as isSearchPage,m as link,y as loadExLib,q as parsePath,P as parseQuery,k as printNanoID,C as productSlugify,v as randomNum,b as recomposeI18nNumber,X as selectItemByWeight,p as setCookies,g as shuffle,S as slugify,I as withoutProperties,F as withoutProperty};
1
+ import{A as e,B as t,C as n,D as r,E as i,F as a,H as o,I as s,L as c,M as l,N as u,O as d,P as f,R as p,S as m,T as h,U as g,V as _,_ as v,a as y,b,c as x,d as S,f as C,g as w,h as T,i as E,j as D,k as O,l as k,m as A,n as j,o as M,p as N,r as P,s as F,t as I,u as L,v as R,w as z,x as B,y as V,z as H}from"../util-DCPr_-5a.mjs";export{f as appendSearchPath,S as calcPageCount,a as clearQueryByKey,s as clearSearchPath,C as cn,N as comparePriorityAsc,A as composeKey,c as deleteAllSearchHistory,p as deleteSearchHistory,M as displayDatetime,T as existLeastOne,F as formatBytes,w as formatI18nNumber,I as genNanoID,j as generatePage,P as generatePageGroup,H as getCookie,x as getFileExtension,k as getFilename,v as getFirstLocationAddress,R as getFullAddress,V as getI18nKey,b as getI18nValue,B as getI18nValues,m as getModelName,t as getSearchHistory,_ as insertSearchHistory,o as isSearchPage,n as link,z as loadExLib,L as parsePath,h as parseQuery,E as printNanoID,i as productSlugify,y as randomNum,r as recomposeI18nNumber,d as selectItemByWeight,g as setCookies,O as shuffle,e as sleep,D as slugify,l as withoutProperties,u as withoutProperty};
@@ -0,0 +1 @@
1
+ const e=require(`./chunk-Bmb41Sf3.cjs`);let t=require(`js-cookie`);t=e.t(t);let n=require(`query-string`);n=e.t(n);let r=require(`lodash-es`),i=require(`slug`);i=e.t(i);let a=require(`google-libphonenumber`);a=e.t(a);let o=require(`dayjs`);o=e.t(o),require(`dayjs/locale/ko.js`);let s=require(`dayjs/plugin/relativeTime.js`);s=e.t(s);let c=require(`nanoid`);const l=e=>t.default.get(e),u=(e,n,r)=>t.default.set(e,n,r),d=()=>typeof window>`u`?[]:JSON.parse(localStorage.getItem(`search-history`)||`[]`),f=e=>{let t=(0,r.uniq)([e,...d()]).slice(0,10);return localStorage.setItem(`search-history`,JSON.stringify(t)),t},p=e=>{let t=d();return t.splice(e,1),localStorage.setItem(`search-history`,JSON.stringify(t)),t},m=()=>{localStorage.setItem(`search-history`,JSON.stringify([]))},h=e=>e.endsWith(`/search`),g=e=>h(e)?e:`${e}/search`.replace(`//`,`/`),_=e=>e.replace(`/search`,``).replace(`//`,`/`),v=(e,t)=>{let n=new URLSearchParams(e);return n.delete(t),Object.fromEntries(n)},y=a.default.PhoneNumberFormat,b=a.default.PhoneNumberUtil.getInstance();i.default.extend({'"':`-`,"”":`-`,"“":`-`,"•":`----`}),i.default.setLocale(`en`);const x=(e,t=[])=>{if(typeof window>`u`)return``;let{hash:r,search:i}=window.location,a=n.default.parse(i);Object.keys(e).forEach(t=>{e[t]?a[t]=e[t]:delete a[t]});let o={...a};return Object.keys(a).forEach(e=>{t.includes(e)&&delete o[e]}),`?${n.default.stringify(o,{encode:!0})}${r}`},S=(e,t)=>{let n=0;return e%t===0&&(n=e/t),n=Math.ceil(e/t),n<1&&(n=1),n},C=e=>{let t=[...e];for(let e=t.length-1;e>0;e--){let n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t},w=e=>{let t=document.getElementById(`naverMapLib`);if(!t){let t=document.createElement(`script`);t.src=`https://oapi.map.naver.com/openapi/v3/maps.js?ncpKeyId=ecs1pyoo9b`,t.id=`naverMapLib`,document.body.appendChild(t),t.onload=()=>{e&&e()}}t&&e&&e()},T=(e,t,n)=>t?e===`ko`&&n&&n!==`82`||e!==`ko`&&n?`+${n}-${t.replace(/^0/,``)}`:t:`-`,E=({phone:e,country:t={callingCode:`82`,alpha2Code:`KR`},format:n=y.INTERNATIONAL,locale:r})=>{if(!e||e===`-`)return`-`;try{let i=b.parseAndKeepRawInput(e,t?.alpha2Code||`KR`),a=i.getCountryCode();return r===`ko`&&t?.alpha2Code===`KR`&&a===82?b.format(i,y.NATIONAL):b.format(i,n)}catch{return T(r||`en`,e,t?.callingCode)}},D=(e,...t)=>{let n=`${e}`;return t.forEach(e=>{e&&(n=`${n}-${(0,i.default)(e)}`)}),n},O=e=>{let t=[];e.i18n?.forEach(e=>{e.locale===`en`&&e.name&&t.push(e.name)});let n=e.series?.i18n.find(e=>e.locale===`en`);return n?.name&&t.push(n.name.toLowerCase()),e.stockNo&&t.push(e.stockNo[0]),D(e.id,...t)},k=e=>{let t=e;return t.length>0?t[0].trim():``},A=(e=`en`,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(M);if(e){let t=r.findIndex(t=>t.locale===e);if(t){let e=r.splice(t,1);r.unshift(e[0])}}for(let e of r){let t=e[n];if(!(Array.isArray(t)&&t.length===0)&&t)return t}return``},j=(e,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(M);if(e){let t=r.findIndex(t=>t.locale===e);if(t){let e=r.splice(t,1);r.unshift(e[0])}}let i=``;for(let e of r){let t=e[n];if(t){i=String(t);break}}return i},M=(e,t)=>e.priority<t.priority?-1:e.priority>t.priority?1:0,N=(e,t,n)=>{if(e){let r;r=Array.isArray(e)?e[0]:e;try{return t(r)}catch{return n}}return n},P=(e,t)=>{let{[t]:n,...r}=e;return r},F=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e))),ee=(e,t)=>(0,r.intersection)(e,t).length>0,I=e=>e.split(`:`).pop()?.split(`.`).pop(),L=(e,...t)=>[e,t].flat().join(`.`).replace(`:.`,`.`),R=(e=`en`,t)=>{if(t.length<=0)return`-`;let n=t[0];return n?z(e,n.i18n):`-`},z=(e=`en`,t)=>{if(t.length===0)return``;let n=A(e,t,`address1`)?.replace(`대한민국`,``)||``,r=t.find(t=>t.locale===e)?.address2,i=[n];return e===`ko`?i.push(r):i.unshift(r),i.filter(Boolean).join(`, `).trim()},B=e=>{let t=0;for(let n of e)t+=n.weight;let n=Math.random()*t,r=0;for(let t of e)if(r+=t.weight,n<r)return t;return e[e.length-1]},V=e=>new Promise(t=>setTimeout(t,e)),H=(...e)=>e.filter(Boolean).join(` `);function U(e,t=0){if(e==0)return`0 Bytes`;let n=1024,r=t,i=[`Bytes`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],a=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/n**+a).toFixed(r))+` `+i[a]}const W=e=>e.split(`.`).slice(0,-1).join(`.`),G=e=>e.split(`.`).pop(),K=(e,t)=>{let n={directory:``,filename:``,extension:``,filenameWithoutExtension:``},r=e.lastIndexOf(`/`),i=r>=0?e.substring(r+1):e,a=i.lastIndexOf(`.`),o=a>0?i.substring(a+1):``,s=a>0?i.substring(0,a):i;if(n.filename=i,n.extension=o,n.filenameWithoutExtension=s,e.startsWith(`http`)){let r=t?`/${t}/`:`/`,i=e.indexOf(r);if(i!==-1){let t=e.substring(i+r.length),a=t.lastIndexOf(`/`);return n.directory=a===-1?``:t.substring(0,a),n}}return n.directory=r===-1?``:e.substring(0,r),n};o.default.extend(s.default);const q=(e,t=`YYYY-MM-DD`,n=`en`)=>{let r=(0,o.default)(e).locale(n);return(0,o.default)().diff(r,`hour`)<12?r.fromNow():r.format(t)},J=(e,t)=>{let n=[];for(let r=e;r<t;r++)n.push(r);return n},Y=(e,t,n=1)=>{let r=[],i=J(e,t);for(;r.length<n;){let t=Math.ceil(e),n=Math.floor(i.length),a=Math.floor(Math.random()*(n-t))+t,o=i.splice(a,1);r.push(o[0])}return[...r]},X=()=>(0,c.customAlphabet)(`0123456789abcdefghijklmnopqrstuvwxyz`,5)(),Z=e=>{for(let t=0;t<e;t++)console.log(X())},Q=(e,t,n)=>{let r=Math.floor((t-1)/n),i=r*n+1;return{current:r,start:i,end:Math.min(i+n-1,e)}},$=(e,t,n)=>{let{start:r,end:i}=Q(e,t,n),a=r-1<1?1:r-1,o=i+1>e?e:i+1,s=Array.from({length:i-r+1},(e,t)=>r+t);return{prev:a,next:o,isPrev:a!==1,isNext:i<e,items:s}};Object.defineProperty(exports,`A`,{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,`B`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`D`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`F`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`H`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`I`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`L`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`M`,{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,`N`,{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,`O`,{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,`P`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`R`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,`U`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`V`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,`j`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`k`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,`z`,{enumerable:!0,get:function(){return l}});
@@ -0,0 +1 @@
1
+ import e from"js-cookie";import t from"query-string";import{intersection as n,uniq as r}from"lodash-es";import i from"slug";import a from"google-libphonenumber";import o from"dayjs";import"dayjs/locale/ko.js";import s from"dayjs/plugin/relativeTime.js";import{customAlphabet as c}from"nanoid";const l=t=>e.get(t),u=(t,n,r)=>e.set(t,n,r),d=()=>typeof window>`u`?[]:JSON.parse(localStorage.getItem(`search-history`)||`[]`),f=e=>{let t=r([e,...d()]).slice(0,10);return localStorage.setItem(`search-history`,JSON.stringify(t)),t},p=e=>{let t=d();return t.splice(e,1),localStorage.setItem(`search-history`,JSON.stringify(t)),t},m=()=>{localStorage.setItem(`search-history`,JSON.stringify([]))},h=e=>e.endsWith(`/search`),g=e=>h(e)?e:`${e}/search`.replace(`//`,`/`),_=e=>e.replace(`/search`,``).replace(`//`,`/`),v=(e,t)=>{let n=new URLSearchParams(e);return n.delete(t),Object.fromEntries(n)},y=a.PhoneNumberFormat,b=a.PhoneNumberUtil.getInstance();i.extend({'"':`-`,"”":`-`,"“":`-`,"•":`----`}),i.setLocale(`en`);const x=(e,n=[])=>{if(typeof window>`u`)return``;let{hash:r,search:i}=window.location,a=t.parse(i);Object.keys(e).forEach(t=>{e[t]?a[t]=e[t]:delete a[t]});let o={...a};return Object.keys(a).forEach(e=>{n.includes(e)&&delete o[e]}),`?${t.stringify(o,{encode:!0})}${r}`},S=(e,t)=>{let n=0;return e%t===0&&(n=e/t),n=Math.ceil(e/t),n<1&&(n=1),n},C=e=>{let t=[...e];for(let e=t.length-1;e>0;e--){let n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t},w=e=>{let t=document.getElementById(`naverMapLib`);if(!t){let t=document.createElement(`script`);t.src=`https://oapi.map.naver.com/openapi/v3/maps.js?ncpKeyId=ecs1pyoo9b`,t.id=`naverMapLib`,document.body.appendChild(t),t.onload=()=>{e&&e()}}t&&e&&e()},T=(e,t,n)=>t?e===`ko`&&n&&n!==`82`||e!==`ko`&&n?`+${n}-${t.replace(/^0/,``)}`:t:`-`,E=({phone:e,country:t={callingCode:`82`,alpha2Code:`KR`},format:n=y.INTERNATIONAL,locale:r})=>{if(!e||e===`-`)return`-`;try{let i=b.parseAndKeepRawInput(e,t?.alpha2Code||`KR`),a=i.getCountryCode();return r===`ko`&&t?.alpha2Code===`KR`&&a===82?b.format(i,y.NATIONAL):b.format(i,n)}catch{return T(r||`en`,e,t?.callingCode)}},D=(e,...t)=>{let n=`${e}`;return t.forEach(e=>{e&&(n=`${n}-${i(e)}`)}),n},O=e=>{let t=[];e.i18n?.forEach(e=>{e.locale===`en`&&e.name&&t.push(e.name)});let n=e.series?.i18n.find(e=>e.locale===`en`);return n?.name&&t.push(n.name.toLowerCase()),e.stockNo&&t.push(e.stockNo[0]),D(e.id,...t)},k=e=>{let t=e;return t.length>0?t[0].trim():``},A=(e=`en`,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(M);if(e){let t=r.findIndex(t=>t.locale===e);if(t){let e=r.splice(t,1);r.unshift(e[0])}}for(let e of r){let t=e[n];if(!(Array.isArray(t)&&t.length===0)&&t)return t}return``},j=(e,t,n)=>{if(!t||!n||t.length<=0)return``;let r=[...t].sort(M);if(e){let t=r.findIndex(t=>t.locale===e);if(t){let e=r.splice(t,1);r.unshift(e[0])}}let i=``;for(let e of r){let t=e[n];if(t){i=String(t);break}}return i},M=(e,t)=>e.priority<t.priority?-1:e.priority>t.priority?1:0,N=(e,t,n)=>{if(e){let r;r=Array.isArray(e)?e[0]:e;try{return t(r)}catch{return n}}return n},P=(e,t)=>{let{[t]:n,...r}=e;return r},F=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e))),ee=(e,t)=>n(e,t).length>0,I=e=>e.split(`:`).pop()?.split(`.`).pop(),L=(e,...t)=>[e,t].flat().join(`.`).replace(`:.`,`.`),R=(e=`en`,t)=>{if(t.length<=0)return`-`;let n=t[0];return n?z(e,n.i18n):`-`},z=(e=`en`,t)=>{if(t.length===0)return``;let n=A(e,t,`address1`)?.replace(`대한민국`,``)||``,r=t.find(t=>t.locale===e)?.address2,i=[n];return e===`ko`?i.push(r):i.unshift(r),i.filter(Boolean).join(`, `).trim()},B=e=>{let t=0;for(let n of e)t+=n.weight;let n=Math.random()*t,r=0;for(let t of e)if(r+=t.weight,n<r)return t;return e[e.length-1]},V=e=>new Promise(t=>setTimeout(t,e)),H=(...e)=>e.filter(Boolean).join(` `);function U(e,t=0){if(e==0)return`0 Bytes`;let n=1024,r=t,i=[`Bytes`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],a=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/n**+a).toFixed(r))+` `+i[a]}const W=e=>e.split(`.`).slice(0,-1).join(`.`),G=e=>e.split(`.`).pop(),K=(e,t)=>{let n={directory:``,filename:``,extension:``,filenameWithoutExtension:``},r=e.lastIndexOf(`/`),i=r>=0?e.substring(r+1):e,a=i.lastIndexOf(`.`),o=a>0?i.substring(a+1):``,s=a>0?i.substring(0,a):i;if(n.filename=i,n.extension=o,n.filenameWithoutExtension=s,e.startsWith(`http`)){let r=t?`/${t}/`:`/`,i=e.indexOf(r);if(i!==-1){let t=e.substring(i+r.length),a=t.lastIndexOf(`/`);return n.directory=a===-1?``:t.substring(0,a),n}}return n.directory=r===-1?``:e.substring(0,r),n};o.extend(s);const q=(e,t=`YYYY-MM-DD`,n=`en`)=>{let r=o(e).locale(n);return o().diff(r,`hour`)<12?r.fromNow():r.format(t)},J=(e,t)=>{let n=[];for(let r=e;r<t;r++)n.push(r);return n},Y=(e,t,n=1)=>{let r=[],i=J(e,t);for(;r.length<n;){let t=Math.ceil(e),n=Math.floor(i.length),a=Math.floor(Math.random()*(n-t))+t,o=i.splice(a,1);r.push(o[0])}return[...r]},X=()=>c(`0123456789abcdefghijklmnopqrstuvwxyz`,5)(),Z=e=>{for(let t=0;t<e;t++)console.log(X())},Q=(e,t,n)=>{let r=Math.floor((t-1)/n),i=r*n+1;return{current:r,start:i,end:Math.min(i+n-1,e)}},$=(e,t,n)=>{let{start:r,end:i}=Q(e,t,n),a=r-1<1?1:r-1,o=i+1>e?e:i+1,s=Array.from({length:i-r+1},(e,t)=>r+t);return{prev:a,next:o,isPrev:a!==1,isNext:i<e,items:s}};export{V as A,d as B,x as C,T as D,O as E,v as F,h as H,_ as I,m as L,F as M,P as N,B as O,g as P,p as R,k as S,N as T,u as U,f as V,R as _,Y as a,j as b,G as c,S as d,H as f,E as g,ee as h,Z as i,D as j,C as k,W as l,L as m,Q as n,q as o,M as p,$ as r,U as s,X as t,K as u,z as v,w,A as x,I as y,l as z};
package/package.json CHANGED
@@ -1,17 +1,12 @@
1
1
  {
2
2
  "name": "@machinerd/js-module",
3
- "version": "0.0.10",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/index.mjs",
7
7
  "files": [
8
8
  "dist"
9
9
  ],
10
- "scripts": {
11
- "test": "echo \"Error: no test specified\" && exit 1",
12
- "build": "tsdown",
13
- "build:tsc": "pnpm tsc"
14
- },
15
10
  "exports": {
16
11
  ".": {
17
12
  "import": "./dist/index.mjs",
@@ -20,23 +15,42 @@
20
15
  "./util": {
21
16
  "import": "./dist/util/index.mjs",
22
17
  "require": "./dist/util/index.cjs"
23
- }
18
+ },
19
+ "./ui": {
20
+ "import": "./dist/ui/index.mjs",
21
+ "require": "./dist/ui/index.cjs"
22
+ },
23
+ "./hooks": {
24
+ "import": "./dist/hooks/index.mjs",
25
+ "require": "./dist/hooks/index.cjs"
26
+ },
27
+ "./styles/index.css": "./dist/styles/index.css"
24
28
  },
25
29
  "keywords": [],
26
30
  "author": "KOMACHINE",
27
31
  "license": "MIT",
28
- "packageManager": "pnpm@10.25.0",
29
32
  "devDependencies": {
33
+ "@storybook/react-vite": "^10.2.3",
34
+ "@tailwindcss/postcss": "^4.1.18",
30
35
  "@typed/node": "^6.7.0",
31
36
  "@types/google-libphonenumber": "^7.4.30",
32
37
  "@types/js-cookie": "^3.0.6",
33
38
  "@types/lodash-es": "^4.17.12",
34
39
  "@types/node": "^24.10.1",
40
+ "@types/react": "^18.3.27",
41
+ "@types/react-dom": "^18.3.7",
35
42
  "@types/slug": "^5.0.9",
43
+ "postcss": "^8.5.6",
44
+ "react": "^18.3.1",
45
+ "react-dom": "^18.3.1",
46
+ "storybook": "^10.2.3",
47
+ "tailwindcss": "^4.1.18",
36
48
  "tsdown": "0.17.0-beta.5",
37
49
  "typescript": "^5.9.3"
38
50
  },
39
51
  "dependencies": {
52
+ "class-variance-authority": "^0.7.1",
53
+ "clsx": "^2.1.1",
40
54
  "dayjs": "^1.11.19",
41
55
  "google-libphonenumber": "^3.2.43",
42
56
  "js-cookie": "^3.0.5",
@@ -44,5 +58,17 @@
44
58
  "nanoid": "^5.1.6",
45
59
  "query-string": "^9.3.1",
46
60
  "slug": "^11.0.1"
61
+ },
62
+ "peerDependencies": {
63
+ "react": "^18.3.1 || ^19.0.0",
64
+ "react-dom": "^18.3.1 || ^19.0.0"
65
+ },
66
+ "scripts": {
67
+ "test": "echo \"Error: no test specified\" && exit 1",
68
+ "build": "tsdown && pnpm build:css",
69
+ "build:tsc": "pnpm tsc",
70
+ "build:css": "pnpm dlx @tailwindcss/cli -i src/styles/index.css -o dist/styles/index.css",
71
+ "storybook": "storybook dev -p 6006",
72
+ "build-storybook": "storybook build"
47
73
  }
48
- }
74
+ }