@m1kapp/kit 0.0.24 → 0.0.26

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/dist/utils.d.ts CHANGED
@@ -5,5 +5,21 @@ declare function formatNumber(n: number): string;
5
5
  declare function formatPrice(amount: number, currency?: string, locale?: string): string;
6
6
 
7
7
  declare function cn(...inputs: ClassValue[]): string;
8
+ declare function formatDuration(ms: number, opts?: {
9
+ style?: "short" | "clock";
10
+ }): string;
11
+ interface DayGroup<T> {
12
+ /** YYYY-MM-DD */
13
+ date: string;
14
+ /** 오늘 / 어제 / "M월 D일 (요일)" */
15
+ label: string;
16
+ items: T[];
17
+ }
18
+ /**
19
+ * Korean day label relative to today: "오늘" / "어제" / "4월 19일 (토)".
20
+ * Shared by `groupByDay` and `MessageList`'s day dividers.
21
+ */
22
+ declare function formatDayLabel(time: number | string | Date): string;
23
+ declare function groupByDay<T>(items: T[], getTime: (item: T) => number | string | Date): DayGroup<T>[];
8
24
 
9
- export { cn, formatNumber, formatPrice, relativeTime };
25
+ export { type DayGroup, cn, formatDayLabel, formatDuration, formatNumber, formatPrice, groupByDay, relativeTime };
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- "use strict";var i=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var m=(t,r)=>{for(var n in r)i(t,n,{get:r[n],enumerable:!0})},l=(t,r,n,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of s(r))!c.call(t,o)&&o!==n&&i(t,o,{get:()=>r[o],enumerable:!(e=f(r,o))||e.enumerable});return t};var _=t=>l(i({},"__esModule",{value:!0}),t);var b={};m(b,{cn:()=>x,formatNumber:()=>g,formatPrice:()=>p,relativeTime:()=>$});module.exports=_(b);var a=require("clsx"),u=require("tailwind-merge");function $(t){let r=new Date(t),n=Date.now()-r.getTime(),e=Math.floor(n/1e3);return e<60?"\uBC29\uAE08 \uC804":e<3600?`${Math.floor(e/60)}\uBD84 \uC804`:e<86400?`${Math.floor(e/3600)}\uC2DC\uAC04 \uC804`:e<86400*2?"\uC5B4\uC81C":e<86400*7?`${Math.floor(e/86400)}\uC77C \uC804`:e<86400*30?`${Math.floor(e/(86400*7))}\uC8FC \uC804`:r.toLocaleDateString("ko-KR",{year:"numeric",month:"long",day:"numeric"})}function g(t){let r=Math.abs(t),n=t<0?"-":"";return r>=1e8?`${n}${(r/1e8).toFixed(1).replace(/\.0$/,"")}\uC5B5`:r>=1e4?`${n}${(r/1e4).toFixed(1).replace(/\.0$/,"")}\uB9CC`:r>=1e3?`${n}${(r/1e3).toFixed(1).replace(/\.0$/,"")}\uCC9C`:t.toLocaleString("ko-KR")}function p(t,r="KRW",n="ko-KR"){return new Intl.NumberFormat(n,{style:"currency",currency:r,maximumFractionDigits:r==="KRW"?0:2}).format(t)}function x(...t){return(0,u.twMerge)((0,a.clsx)(t))}0&&(module.exports={cn,formatNumber,formatPrice,relativeTime});
1
+ "use strict";var f=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var _=(r,t)=>{for(var n in t)f(r,n,{get:t[n],enumerable:!0})},h=(r,t,n,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of p(t))!D.call(r,o)&&o!==n&&f(r,o,{get:()=>t[o],enumerable:!(e=$(t,o))||e.enumerable});return r};var y=r=>h(f({},"__esModule",{value:!0}),r);var K={};_(K,{cn:()=>b,formatDayLabel:()=>l,formatDuration:()=>S,formatNumber:()=>x,formatPrice:()=>M,groupByDay:()=>T,relativeTime:()=>d});module.exports=y(K);var g=require("clsx"),m=require("tailwind-merge");function d(r){let t=new Date(r),n=Date.now()-t.getTime(),e=Math.floor(n/1e3);return e<60?"\uBC29\uAE08 \uC804":e<3600?`${Math.floor(e/60)}\uBD84 \uC804`:e<86400?`${Math.floor(e/3600)}\uC2DC\uAC04 \uC804`:e<86400*2?"\uC5B4\uC81C":e<86400*7?`${Math.floor(e/86400)}\uC77C \uC804`:e<86400*30?`${Math.floor(e/(86400*7))}\uC8FC \uC804`:t.toLocaleDateString("ko-KR",{year:"numeric",month:"long",day:"numeric"})}function x(r){let t=Math.abs(r),n=r<0?"-":"";return t>=1e8?`${n}${(t/1e8).toFixed(1).replace(/\.0$/,"")}\uC5B5`:t>=1e4?`${n}${(t/1e4).toFixed(1).replace(/\.0$/,"")}\uB9CC`:t>=1e3?`${n}${(t/1e3).toFixed(1).replace(/\.0$/,"")}\uCC9C`:r.toLocaleString("ko-KR")}function M(r,t="KRW",n="ko-KR"){return new Intl.NumberFormat(n,{style:"currency",currency:t,maximumFractionDigits:t==="KRW"?0:2}).format(r)}function b(...r){return(0,m.twMerge)((0,g.clsx)(r))}function S(r,t={}){let{style:n="short"}=t,e=Math.max(0,Math.floor(r/1e3)),o=Math.floor(e/3600),a=Math.floor(e%3600/60),i=e%60;return n==="clock"?o>0?`${o}:${String(a).padStart(2,"0")}:${String(i).padStart(2,"0")}`:`${a}:${String(i).padStart(2,"0")}`:o>0?a>0?`${o}\uC2DC\uAC04 ${a}\uBD84`:`${o}\uC2DC\uAC04`:a>0?i>0?`${a}\uBD84 ${i}\uCD08`:`${a}\uBD84`:`${i}\uCD08`}var w=["\uC77C","\uC6D4","\uD654","\uC218","\uBAA9","\uAE08","\uD1A0"];function c(r){return`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}function l(r){let t=new Date(r),n=c(t);return n===c(new Date)?"\uC624\uB298":n===c(new Date(Date.now()-864e5))?"\uC5B4\uC81C":`${t.getMonth()+1}\uC6D4 ${t.getDate()}\uC77C (${w[t.getDay()]})`}function T(r,t){let n=[],e=new Map;for(let o of r){let a=t(o),i=new Date(a),s=c(i),u=e.get(s);u||(u={date:s,label:l(a),items:[]},e.set(s,u),n.push(s)),u.items.push(o)}return n.map(o=>e.get(o))}0&&(module.exports={cn,formatDayLabel,formatDuration,formatNumber,formatPrice,groupByDay,relativeTime});
package/dist/utils.mjs CHANGED
@@ -1 +1 @@
1
- import{clsx as o}from"clsx";import{twMerge as i}from"tailwind-merge";function a(e){let r=new Date(e),n=Date.now()-r.getTime(),t=Math.floor(n/1e3);return t<60?"\uBC29\uAE08 \uC804":t<3600?`${Math.floor(t/60)}\uBD84 \uC804`:t<86400?`${Math.floor(t/3600)}\uC2DC\uAC04 \uC804`:t<86400*2?"\uC5B4\uC81C":t<86400*7?`${Math.floor(t/86400)}\uC77C \uC804`:t<86400*30?`${Math.floor(t/(86400*7))}\uC8FC \uC804`:r.toLocaleDateString("ko-KR",{year:"numeric",month:"long",day:"numeric"})}function u(e){let r=Math.abs(e),n=e<0?"-":"";return r>=1e8?`${n}${(r/1e8).toFixed(1).replace(/\.0$/,"")}\uC5B5`:r>=1e4?`${n}${(r/1e4).toFixed(1).replace(/\.0$/,"")}\uB9CC`:r>=1e3?`${n}${(r/1e3).toFixed(1).replace(/\.0$/,"")}\uCC9C`:e.toLocaleString("ko-KR")}function f(e,r="KRW",n="ko-KR"){return new Intl.NumberFormat(n,{style:"currency",currency:r,maximumFractionDigits:r==="KRW"?0:2}).format(e)}function m(...e){return i(o(e))}export{m as cn,u as formatNumber,f as formatPrice,a as relativeTime};
1
+ import{clsx as f}from"clsx";import{twMerge as g}from"tailwind-merge";function $(r){let t=new Date(r),n=Date.now()-t.getTime(),e=Math.floor(n/1e3);return e<60?"\uBC29\uAE08 \uC804":e<3600?`${Math.floor(e/60)}\uBD84 \uC804`:e<86400?`${Math.floor(e/3600)}\uC2DC\uAC04 \uC804`:e<86400*2?"\uC5B4\uC81C":e<86400*7?`${Math.floor(e/86400)}\uC77C \uC804`:e<86400*30?`${Math.floor(e/(86400*7))}\uC8FC \uC804`:t.toLocaleDateString("ko-KR",{year:"numeric",month:"long",day:"numeric"})}function p(r){let t=Math.abs(r),n=r<0?"-":"";return t>=1e8?`${n}${(t/1e8).toFixed(1).replace(/\.0$/,"")}\uC5B5`:t>=1e4?`${n}${(t/1e4).toFixed(1).replace(/\.0$/,"")}\uB9CC`:t>=1e3?`${n}${(t/1e3).toFixed(1).replace(/\.0$/,"")}\uCC9C`:r.toLocaleString("ko-KR")}function D(r,t="KRW",n="ko-KR"){return new Intl.NumberFormat(n,{style:"currency",currency:t,maximumFractionDigits:t==="KRW"?0:2}).format(r)}function y(...r){return g(f(r))}function d(r,t={}){let{style:n="short"}=t,e=Math.max(0,Math.floor(r/1e3)),o=Math.floor(e/3600),a=Math.floor(e%3600/60),i=e%60;return n==="clock"?o>0?`${o}:${String(a).padStart(2,"0")}:${String(i).padStart(2,"0")}`:`${a}:${String(i).padStart(2,"0")}`:o>0?a>0?`${o}\uC2DC\uAC04 ${a}\uBD84`:`${o}\uC2DC\uAC04`:a>0?i>0?`${a}\uBD84 ${i}\uCD08`:`${a}\uBD84`:`${i}\uCD08`}var m=["\uC77C","\uC6D4","\uD654","\uC218","\uBAA9","\uAE08","\uD1A0"];function c(r){return`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}function l(r){let t=new Date(r),n=c(t);return n===c(new Date)?"\uC624\uB298":n===c(new Date(Date.now()-864e5))?"\uC5B4\uC81C":`${t.getMonth()+1}\uC6D4 ${t.getDate()}\uC77C (${m[t.getDay()]})`}function x(r,t){let n=[],e=new Map;for(let o of r){let a=t(o),i=new Date(a),s=c(i),u=e.get(s);u||(u={date:s,label:l(a),items:[]},e.set(s,u),n.push(s)),u.items.push(o)}return n.map(o=>e.get(o))}export{y as cn,l as formatDayLabel,d as formatDuration,p as formatNumber,D as formatPrice,x as groupByDay,$ as relativeTime};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m1kapp/kit",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "description": "UI, SEO, and PWA utilities for side projects",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",