@machinerd/js-module 0.0.11 → 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.
@@ -62,7 +62,7 @@ declare const getI18nValue: <T extends {
62
62
  }>(locale?: string, values?: T[], key?: keyof T) => string;
63
63
  declare const comparePriorityAsc: <T extends {
64
64
  priority: number;
65
- }>(a: T, b: T) => 1 | 0 | -1;
65
+ }>(a: T, b: T) => 0 | 1 | -1;
66
66
  declare const parseQuery: <T, F = T>(q: string | string[] | undefined | null, conv: (v: string) => T, fallback: F) => T | F;
67
67
  declare const withoutProperty: <T>(obj: T, property: keyof T) => Omit<T, keyof T>;
68
68
  declare const withoutProperties: <T extends Record<string, unknown>>(obj: T, properties: Array<keyof T>) => T;
@@ -82,6 +82,7 @@ declare const selectItemByWeight: <T extends {
82
82
  weight: number;
83
83
  }>(itemsWithWeights: T[]) => T;
84
84
  declare const sleep: (ms: number) => Promise<unknown>;
85
+ declare const cn: (...classes: Array<string | false | null | undefined>) => string;
85
86
  //#endregion
86
87
  //#region src/util/file.d.ts
87
88
  declare function formatBytes(bytes: number, decimals?: number): string;
@@ -93,7 +94,7 @@ interface PathInfo {
93
94
  extension: string;
94
95
  filenameWithoutExtension: string;
95
96
  }
96
- declare const parsePath: (filepath: string, isStatic?: boolean) => PathInfo;
97
+ declare const parsePath: (filepath: string, folder?: string) => PathInfo;
97
98
  //#endregion
98
99
  //#region src/util/date.d.ts
99
100
  declare const displayDatetime: (date: string, format?: string, locale?: string) => string;
@@ -102,5 +103,17 @@ declare const displayDatetime: (date: string, format?: string, locale?: string)
102
103
  declare const randomNum: (min: number, max: number, count?: number) => number[];
103
104
  declare const genNanoID: () => string;
104
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
+ };
105
118
  //#endregion
106
- 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, sleep, 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 };
@@ -64,7 +64,7 @@ declare const getI18nValue: <T extends {
64
64
  }>(locale?: string, values?: T[], key?: keyof T) => string;
65
65
  declare const comparePriorityAsc: <T extends {
66
66
  priority: number;
67
- }>(a: T, b: T) => 1 | 0 | -1;
67
+ }>(a: T, b: T) => 0 | 1 | -1;
68
68
  declare const parseQuery: <T, F = T>(q: string | string[] | undefined | null, conv: (v: string) => T, fallback: F) => T | F;
69
69
  declare const withoutProperty: <T>(obj: T, property: keyof T) => Omit<T, keyof T>;
70
70
  declare const withoutProperties: <T extends Record<string, unknown>>(obj: T, properties: Array<keyof T>) => T;
@@ -84,6 +84,7 @@ declare const selectItemByWeight: <T extends {
84
84
  weight: number;
85
85
  }>(itemsWithWeights: T[]) => T;
86
86
  declare const sleep: (ms: number) => Promise<unknown>;
87
+ declare const cn: (...classes: Array<string | false | null | undefined>) => string;
87
88
  //#endregion
88
89
  //#region src/util/file.d.ts
89
90
  declare function formatBytes(bytes: number, decimals?: number): string;
@@ -95,7 +96,7 @@ interface PathInfo {
95
96
  extension: string;
96
97
  filenameWithoutExtension: string;
97
98
  }
98
- declare const parsePath: (filepath: string, isStatic?: boolean) => PathInfo;
99
+ declare const parsePath: (filepath: string, folder?: string) => PathInfo;
99
100
  //#endregion
100
101
  //#region src/util/date.d.ts
101
102
  declare const displayDatetime: (date: string, format?: string, locale?: string) => string;
@@ -104,5 +105,17 @@ declare const displayDatetime: (date: string, format?: string, locale?: string)
104
105
  declare const randomNum: (min: number, max: number, count?: number) => number[];
105
106
  declare const genNanoID: () => string;
106
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
+ };
107
120
  //#endregion
108
- 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, sleep, 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{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))),I=(e,t)=>n(e,t).length>0,L=e=>e.split(`:`).pop()?.split(`.`).pop(),R=(e,...t)=>[e,t].flat().join(`.`).replace(`:.`,`.`),z=(e=`en`,t)=>{if(t.length<=0)return`-`;let n=t[0];return n?B(e,n.i18n):`-`},B=(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()},V=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]},H=e=>new Promise(t=>setTimeout(t,e));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?`/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};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())};export{g as appendSearchPath,S as calcPageCount,v as clearQueryByKey,_ as clearSearchPath,M as comparePriorityAsc,R as composeKey,m as deleteAllSearchHistory,p as deleteSearchHistory,q as displayDatetime,I as existLeastOne,U as formatBytes,E as formatI18nNumber,X as genNanoID,l as getCookie,G as getFileExtension,W as getFilename,z as getFirstLocationAddress,B as getFullAddress,L as getI18nKey,j as getI18nValue,A as getI18nValues,k as getModelName,d as getSearchHistory,f as insertSearchHistory,h as isSearchPage,x as link,w as loadExLib,K as parsePath,N as parseQuery,Z as printNanoID,O as productSlugify,Y as randomNum,T as recomposeI18nNumber,V as selectItemByWeight,u as setCookies,C as shuffle,H as sleep,D as slugify,F as withoutProperties,P 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,6 +1,6 @@
1
1
  {
2
2
  "name": "@machinerd/js-module",
3
- "version": "0.0.11",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/index.mjs",
@@ -15,22 +15,42 @@
15
15
  "./util": {
16
16
  "import": "./dist/util/index.mjs",
17
17
  "require": "./dist/util/index.cjs"
18
- }
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"
19
28
  },
20
29
  "keywords": [],
21
30
  "author": "KOMACHINE",
22
31
  "license": "MIT",
23
32
  "devDependencies": {
33
+ "@storybook/react-vite": "^10.2.3",
34
+ "@tailwindcss/postcss": "^4.1.18",
24
35
  "@typed/node": "^6.7.0",
25
36
  "@types/google-libphonenumber": "^7.4.30",
26
37
  "@types/js-cookie": "^3.0.6",
27
38
  "@types/lodash-es": "^4.17.12",
28
39
  "@types/node": "^24.10.1",
40
+ "@types/react": "^18.3.27",
41
+ "@types/react-dom": "^18.3.7",
29
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",
30
48
  "tsdown": "0.17.0-beta.5",
31
49
  "typescript": "^5.9.3"
32
50
  },
33
51
  "dependencies": {
52
+ "class-variance-authority": "^0.7.1",
53
+ "clsx": "^2.1.1",
34
54
  "dayjs": "^1.11.19",
35
55
  "google-libphonenumber": "^3.2.43",
36
56
  "js-cookie": "^3.0.5",
@@ -39,9 +59,16 @@
39
59
  "query-string": "^9.3.1",
40
60
  "slug": "^11.0.1"
41
61
  },
62
+ "peerDependencies": {
63
+ "react": "^18.3.1 || ^19.0.0",
64
+ "react-dom": "^18.3.1 || ^19.0.0"
65
+ },
42
66
  "scripts": {
43
67
  "test": "echo \"Error: no test specified\" && exit 1",
44
- "build": "tsdown",
45
- "build:tsc": "pnpm tsc"
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"
46
73
  }
47
74
  }