hia-frontend-utils 0.0.1
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/index.d.mts +25 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +29 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +36 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ClassValue } from 'clsx';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 클래스명을 조건부로 합치는 유틸리티
|
|
5
|
+
* @example cn('base', isActive && 'active', { disabled: isDisabled })
|
|
6
|
+
*/
|
|
7
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 숫자를 천 단위 콤마 형식으로 변환
|
|
11
|
+
* @example formatNumber(1234567) => '1,234,567'
|
|
12
|
+
*/
|
|
13
|
+
declare function formatNumber(value: number): string;
|
|
14
|
+
/**
|
|
15
|
+
* Date 객체를 한국어 날짜 문자열로 변환
|
|
16
|
+
* @example formatDate(new Date()) => '2024. 1. 1.'
|
|
17
|
+
*/
|
|
18
|
+
declare function formatDate(date: Date, options?: Intl.DateTimeFormatOptions): string;
|
|
19
|
+
/**
|
|
20
|
+
* 바이트 크기를 사람이 읽기 좋은 형식으로 변환
|
|
21
|
+
* @example formatBytes(1024) => '1 KB'
|
|
22
|
+
*/
|
|
23
|
+
declare function formatBytes(bytes: number, decimals?: number): string;
|
|
24
|
+
|
|
25
|
+
export { cn, formatBytes, formatDate, formatNumber };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ClassValue } from 'clsx';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 클래스명을 조건부로 합치는 유틸리티
|
|
5
|
+
* @example cn('base', isActive && 'active', { disabled: isDisabled })
|
|
6
|
+
*/
|
|
7
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 숫자를 천 단위 콤마 형식으로 변환
|
|
11
|
+
* @example formatNumber(1234567) => '1,234,567'
|
|
12
|
+
*/
|
|
13
|
+
declare function formatNumber(value: number): string;
|
|
14
|
+
/**
|
|
15
|
+
* Date 객체를 한국어 날짜 문자열로 변환
|
|
16
|
+
* @example formatDate(new Date()) => '2024. 1. 1.'
|
|
17
|
+
*/
|
|
18
|
+
declare function formatDate(date: Date, options?: Intl.DateTimeFormatOptions): string;
|
|
19
|
+
/**
|
|
20
|
+
* 바이트 크기를 사람이 읽기 좋은 형식으로 변환
|
|
21
|
+
* @example formatBytes(1024) => '1 KB'
|
|
22
|
+
*/
|
|
23
|
+
declare function formatBytes(bytes: number, decimals?: number): string;
|
|
24
|
+
|
|
25
|
+
export { cn, formatBytes, formatDate, formatNumber };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
cn: () => cn,
|
|
24
|
+
formatBytes: () => formatBytes,
|
|
25
|
+
formatDate: () => formatDate,
|
|
26
|
+
formatNumber: () => formatNumber
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
|
|
30
|
+
// src/cn/cn.ts
|
|
31
|
+
var import_clsx = require("clsx");
|
|
32
|
+
function cn(...inputs) {
|
|
33
|
+
return (0, import_clsx.clsx)(inputs);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/format/format.ts
|
|
37
|
+
function formatNumber(value) {
|
|
38
|
+
return new Intl.NumberFormat("ko-KR").format(value);
|
|
39
|
+
}
|
|
40
|
+
function formatDate(date, options) {
|
|
41
|
+
return new Intl.DateTimeFormat("ko-KR", options).format(date);
|
|
42
|
+
}
|
|
43
|
+
function formatBytes(bytes, decimals = 2) {
|
|
44
|
+
if (bytes === 0) {
|
|
45
|
+
return "0 Bytes";
|
|
46
|
+
}
|
|
47
|
+
const k = 1024;
|
|
48
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
|
|
49
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
50
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(decimals))} ${sizes[i]}`;
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
cn,
|
|
55
|
+
formatBytes,
|
|
56
|
+
formatDate,
|
|
57
|
+
formatNumber
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/cn/cn.ts","../src/format/format.ts"],"sourcesContent":["export * from './cn';\nexport * from './format';\n","import { clsx, type ClassValue } from 'clsx';\n\n/**\n * 클래스명을 조건부로 합치는 유틸리티\n * @example cn('base', isActive && 'active', { disabled: isDisabled })\n */\nexport function cn(...inputs: ClassValue[]): string {\n return clsx(inputs);\n}\n","/**\n * 숫자를 천 단위 콤마 형식으로 변환\n * @example formatNumber(1234567) => '1,234,567'\n */\nexport function formatNumber(value: number): string {\n return new Intl.NumberFormat('ko-KR').format(value);\n}\n\n/**\n * Date 객체를 한국어 날짜 문자열로 변환\n * @example formatDate(new Date()) => '2024. 1. 1.'\n */\nexport function formatDate(date: Date, options?: Intl.DateTimeFormatOptions): string {\n return new Intl.DateTimeFormat('ko-KR', options).format(date);\n}\n\n/**\n * 바이트 크기를 사람이 읽기 좋은 형식으로 변환\n * @example formatBytes(1024) => '1 KB'\n */\nexport function formatBytes(bytes: number, decimals = 2): string {\n if (bytes === 0) {\n return '0 Bytes';\n }\n const k = 1024;\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n\n return `${parseFloat((bytes / Math.pow(k, i)).toFixed(decimals))} ${sizes[i]}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAsC;AAM/B,SAAS,MAAM,QAA8B;AAClD,aAAO,kBAAK,MAAM;AACpB;;;ACJO,SAAS,aAAa,OAAuB;AAClD,SAAO,IAAI,KAAK,aAAa,OAAO,EAAE,OAAO,KAAK;AACpD;AAMO,SAAS,WAAW,MAAY,SAA8C;AACnF,SAAO,IAAI,KAAK,eAAe,SAAS,OAAO,EAAE,OAAO,IAAI;AAC9D;AAMO,SAAS,YAAY,OAAe,WAAW,GAAW;AAC/D,MAAI,UAAU,GAAG;AACf,WAAO;AAAA,EACT;AACA,QAAM,IAAI;AACV,QAAM,QAAQ,CAAC,SAAS,MAAM,MAAM,MAAM,IAAI;AAC9C,QAAM,IAAI,KAAK,MAAM,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,CAAC,CAAC;AAElD,SAAO,GAAG,YAAY,QAAQ,KAAK,IAAI,GAAG,CAAC,GAAG,QAAQ,QAAQ,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC;AAC9E;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/cn/cn.ts
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
function cn(...inputs) {
|
|
4
|
+
return clsx(inputs);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// src/format/format.ts
|
|
8
|
+
function formatNumber(value) {
|
|
9
|
+
return new Intl.NumberFormat("ko-KR").format(value);
|
|
10
|
+
}
|
|
11
|
+
function formatDate(date, options) {
|
|
12
|
+
return new Intl.DateTimeFormat("ko-KR", options).format(date);
|
|
13
|
+
}
|
|
14
|
+
function formatBytes(bytes, decimals = 2) {
|
|
15
|
+
if (bytes === 0) {
|
|
16
|
+
return "0 Bytes";
|
|
17
|
+
}
|
|
18
|
+
const k = 1024;
|
|
19
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
|
|
20
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
21
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(decimals))} ${sizes[i]}`;
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
cn,
|
|
25
|
+
formatBytes,
|
|
26
|
+
formatDate,
|
|
27
|
+
formatNumber
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cn/cn.ts","../src/format/format.ts"],"sourcesContent":["import { clsx, type ClassValue } from 'clsx';\n\n/**\n * 클래스명을 조건부로 합치는 유틸리티\n * @example cn('base', isActive && 'active', { disabled: isDisabled })\n */\nexport function cn(...inputs: ClassValue[]): string {\n return clsx(inputs);\n}\n","/**\n * 숫자를 천 단위 콤마 형식으로 변환\n * @example formatNumber(1234567) => '1,234,567'\n */\nexport function formatNumber(value: number): string {\n return new Intl.NumberFormat('ko-KR').format(value);\n}\n\n/**\n * Date 객체를 한국어 날짜 문자열로 변환\n * @example formatDate(new Date()) => '2024. 1. 1.'\n */\nexport function formatDate(date: Date, options?: Intl.DateTimeFormatOptions): string {\n return new Intl.DateTimeFormat('ko-KR', options).format(date);\n}\n\n/**\n * 바이트 크기를 사람이 읽기 좋은 형식으로 변환\n * @example formatBytes(1024) => '1 KB'\n */\nexport function formatBytes(bytes: number, decimals = 2): string {\n if (bytes === 0) {\n return '0 Bytes';\n }\n const k = 1024;\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n\n return `${parseFloat((bytes / Math.pow(k, i)).toFixed(decimals))} ${sizes[i]}`;\n}\n"],"mappings":";AAAA,SAAS,YAA6B;AAM/B,SAAS,MAAM,QAA8B;AAClD,SAAO,KAAK,MAAM;AACpB;;;ACJO,SAAS,aAAa,OAAuB;AAClD,SAAO,IAAI,KAAK,aAAa,OAAO,EAAE,OAAO,KAAK;AACpD;AAMO,SAAS,WAAW,MAAY,SAA8C;AACnF,SAAO,IAAI,KAAK,eAAe,SAAS,OAAO,EAAE,OAAO,IAAI;AAC9D;AAMO,SAAS,YAAY,OAAe,WAAW,GAAW;AAC/D,MAAI,UAAU,GAAG;AACf,WAAO;AAAA,EACT;AACA,QAAM,IAAI;AACV,QAAM,QAAQ,CAAC,SAAS,MAAM,MAAM,MAAM,IAAI;AAC9C,QAAM,IAAI,KAAK,MAAM,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,CAAC,CAAC;AAElD,SAAO,GAAG,YAAY,QAAQ,KAAK,IAAI,GAAG,CAAC,GAAG,QAAQ,QAAQ,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC;AAC9E;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hia-frontend-utils",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "HIA 공통 유틸리티 함수",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"clsx": "^2.1.1"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"tsup": "^8.0.0",
|
|
23
|
+
"typescript": "^5.8.3",
|
|
24
|
+
"hia-frontend-typescript-config": "0.0.1"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsup",
|
|
31
|
+
"dev": "tsup --watch",
|
|
32
|
+
"lint": "eslint src --ext .ts",
|
|
33
|
+
"clean": "rm -rf dist",
|
|
34
|
+
"check-types": "tsc --noEmit"
|
|
35
|
+
}
|
|
36
|
+
}
|