@deepagents/react-formatters 7.0.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.
@@ -0,0 +1,2 @@
1
+ export declare function formatBoolean(value: boolean): string;
2
+ //# sourceMappingURL=boolean.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../src/boolean.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD"}
@@ -0,0 +1,3 @@
1
+ export declare function formatBytes(bytes: number | null | undefined): string;
2
+ export declare function formatFileSize(bytes: number | null | undefined): string;
3
+ //# sourceMappingURL=bytes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../src/bytes.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAMpE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAKvE"}
@@ -0,0 +1,4 @@
1
+ export declare const EMPTY_PLACEHOLDER = "\u2014";
2
+ export declare const NULL_PLACEHOLDER = "NULL";
3
+ export declare const NA_PLACEHOLDER = "N/A";
4
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,WAAM,CAAC;AACrC,eAAO,MAAM,gBAAgB,SAAS,CAAC;AACvC,eAAO,MAAM,cAAc,QAAQ,CAAC"}
package/dist/date.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare function isISODateString(value: unknown): value is string;
2
+ export declare function formatISODate(value: string): string;
3
+ export declare function formatAxisDate(value: string, granularity?: 'day' | 'month'): string;
4
+ //# sourceMappingURL=date.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../src/date.ts"],"names":[],"mappings":"AAKA,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE/D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOnD;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,WAAW,GAAE,KAAK,GAAG,OAAiB,GACrC,MAAM,CAMR"}
@@ -0,0 +1,3 @@
1
+ export declare function formatDurationBetween(start: Date | string, end: Date | string): string;
2
+ export declare function formatDurationFromSeconds(seconds: number): string;
3
+ //# sourceMappingURL=duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../src/duration.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,IAAI,GAAG,MAAM,EACpB,GAAG,EAAE,IAAI,GAAG,MAAM,GACjB,MAAM,CAMR;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQjE"}
@@ -0,0 +1,9 @@
1
+ export * from './boolean.ts';
2
+ export * from './bytes.ts';
3
+ export * from './constants.ts';
4
+ export * from './date.ts';
5
+ export * from './duration.ts';
6
+ export * from './number.ts';
7
+ export * from './time.ts';
8
+ export * from './value.ts';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,112 @@
1
+ import { format as e, formatRelative as t, isValid as n, parseISO as r } from "date-fns";
2
+ //#region src/boolean.ts
3
+ function i(e) {
4
+ return e ? "✓" : "✗";
5
+ }
6
+ //#endregion
7
+ //#region src/constants.ts
8
+ var a = "—", o = "NULL", s = "N/A";
9
+ //#endregion
10
+ //#region src/bytes.ts
11
+ function c(e) {
12
+ return e == null ? "—" : e >= 1e9 ? `${(e / 1e9).toFixed(1)} GB` : e >= 1e6 ? `${(e / 1e6).toFixed(1)} MB` : e >= 1e3 ? `${(e / 1e3).toFixed(1)} KB` : `${e} B`;
13
+ }
14
+ function l(e) {
15
+ return e == null ? "—" : e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / (1024 * 1024)).toFixed(1)} MB`;
16
+ }
17
+ //#endregion
18
+ //#region src/date.ts
19
+ var u = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/;
20
+ function d(e) {
21
+ return typeof e == "string" && u.test(e);
22
+ }
23
+ function f(t) {
24
+ let i = r(t);
25
+ return n(i) ? t.includes("T") && !t.endsWith("T00:00:00.000Z") ? e(i, "MMM d, yyyy, h:mm a") : e(i, "MMM d, yyyy") : t;
26
+ }
27
+ function p(t, i = "month") {
28
+ let a = r(t);
29
+ return n(a) ? i === "day" ? e(a, "MMM d") : e(a, "MMM yyyy") : t;
30
+ }
31
+ //#endregion
32
+ //#region src/duration.ts
33
+ function m(e, t) {
34
+ let n = (new Date(t).getTime() - new Date(e).getTime()) / 1e3;
35
+ if (n < 60) return `${n.toFixed(2)} s`;
36
+ let r = n / 60;
37
+ return r < 60 ? `${r.toFixed(2)} min` : `${(r / 60).toFixed(2)} h`;
38
+ }
39
+ function h(e) {
40
+ let t = Math.abs(e), n = Math.floor(t / 3600), r = Math.floor(t % 3600 / 60), i = Math.floor(t % 60);
41
+ return n > 0 ? `${n}h ${r}m` : r > 0 ? `${r}m ${i}s` : `${i}s`;
42
+ }
43
+ //#endregion
44
+ //#region src/number.ts
45
+ function g(e) {
46
+ if (!e) return {};
47
+ let t = { ...e };
48
+ return delete t.whenNullish, delete t.locale, t;
49
+ }
50
+ function _(e, t) {
51
+ return e == null || Number.isNaN(e) ? t?.whenNullish ?? "—" : new Intl.NumberFormat(t?.locale ?? "en-US", g(t)).format(e);
52
+ }
53
+ var v = _;
54
+ function y(e, t) {
55
+ return _(e, {
56
+ notation: "compact",
57
+ maximumFractionDigits: 1,
58
+ ...t
59
+ });
60
+ }
61
+ function b(e, t) {
62
+ return _(e, {
63
+ style: "currency",
64
+ currency: "USD",
65
+ ...t
66
+ });
67
+ }
68
+ function x(e, t) {
69
+ return e == null || Number.isNaN(e) ? t?.whenNullish ?? "—" : new Intl.NumberFormat(t?.locale ?? "en-US", {
70
+ style: "percent",
71
+ minimumFractionDigits: 1,
72
+ maximumFractionDigits: 1,
73
+ ...g(t)
74
+ }).format(e / 100);
75
+ }
76
+ //#endregion
77
+ //#region src/time.ts
78
+ function S(t) {
79
+ return e(t, "PPpp");
80
+ }
81
+ function C(e) {
82
+ return t(e, /* @__PURE__ */ new Date());
83
+ }
84
+ function w(t) {
85
+ return e(t, "EEE MMM dd yyyy");
86
+ }
87
+ //#endregion
88
+ //#region src/value.ts
89
+ function T(e) {
90
+ return e == null ? o : d(e) ? f(e) : typeof e == "object" ? JSON.stringify(e) : String(e);
91
+ }
92
+ function E(e, t) {
93
+ if (e == null) return "N/A";
94
+ switch (t) {
95
+ case "number": return typeof e == "number" ? _(e) : String(e);
96
+ case "currency": return typeof e == "number" ? b(e) : String(e);
97
+ case "date": {
98
+ if (d(e)) return f(e);
99
+ if (typeof e != "string" && typeof e != "number" && !(e instanceof Date)) return "N/A";
100
+ let t = new Date(e);
101
+ return Number.isNaN(t.getTime()) ? "N/A" : t.toLocaleDateString();
102
+ }
103
+ case "boolean": return typeof e == "boolean" ? i(e) : String(e);
104
+ case "email":
105
+ case "url":
106
+ case "text": return String(e);
107
+ }
108
+ }
109
+ //#endregion
110
+ export { a as EMPTY_PLACEHOLDER, s as NA_PLACEHOLDER, o as NULL_PLACEHOLDER, p as formatAxisDate, i as formatBoolean, E as formatByType, c as formatBytes, T as formatCellValue, y as formatCompactNumber, b as formatCurrency, S as formatDateTime, m as formatDurationBetween, h as formatDurationFromSeconds, l as formatFileSize, f as formatISODate, v as formatNullableNumber, _ as formatNumber, x as formatPercent, C as formatRelativeTime, w as formatShortDate, d as isISODateString };
111
+
112
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/boolean.ts","../src/constants.ts","../src/bytes.ts","../src/date.ts","../src/duration.ts","../src/number.ts","../src/time.ts","../src/value.ts"],"sourcesContent":["export function formatBoolean(value: boolean): string {\n return value ? '✓' : '✗';\n}\n","export const EMPTY_PLACEHOLDER = '—';\nexport const NULL_PLACEHOLDER = 'NULL';\nexport const NA_PLACEHOLDER = 'N/A';\n","import { EMPTY_PLACEHOLDER } from './constants.ts';\n\nexport function formatBytes(bytes: number | null | undefined): string {\n if (bytes == null) return EMPTY_PLACEHOLDER;\n if (bytes >= 1_000_000_000) return `${(bytes / 1_000_000_000).toFixed(1)} GB`;\n if (bytes >= 1_000_000) return `${(bytes / 1_000_000).toFixed(1)} MB`;\n if (bytes >= 1_000) return `${(bytes / 1_000).toFixed(1)} KB`;\n return `${bytes} B`;\n}\n\nexport function formatFileSize(bytes: number | null | undefined): string {\n if (bytes == null) return EMPTY_PLACEHOLDER;\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n","import { format, isValid, parseISO } from 'date-fns';\n\nconst ISO_DATE_RE =\n /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})?)?$/;\n\nexport function isISODateString(value: unknown): value is string {\n return typeof value === 'string' && ISO_DATE_RE.test(value);\n}\n\nexport function formatISODate(value: string): string {\n const date = parseISO(value);\n if (!isValid(date)) return value;\n const hasTime = value.includes('T') && !value.endsWith('T00:00:00.000Z');\n return hasTime\n ? format(date, 'MMM d, yyyy, h:mm a')\n : format(date, 'MMM d, yyyy');\n}\n\nexport function formatAxisDate(\n value: string,\n granularity: 'day' | 'month' = 'month',\n): string {\n const date = parseISO(value);\n if (!isValid(date)) return value;\n return granularity === 'day'\n ? format(date, 'MMM d')\n : format(date, 'MMM yyyy');\n}\n","export function formatDurationBetween(\n start: Date | string,\n end: Date | string,\n): string {\n const diffSec = (new Date(end).getTime() - new Date(start).getTime()) / 1000;\n if (diffSec < 60) return `${diffSec.toFixed(2)} s`;\n const diffMin = diffSec / 60;\n if (diffMin < 60) return `${diffMin.toFixed(2)} min`;\n return `${(diffMin / 60).toFixed(2)} h`;\n}\n\nexport function formatDurationFromSeconds(seconds: number): string {\n const total = Math.abs(seconds);\n const h = Math.floor(total / 3600);\n const m = Math.floor((total % 3600) / 60);\n const s = Math.floor(total % 60);\n if (h > 0) return `${h}h ${m}m`;\n if (m > 0) return `${m}m ${s}s`;\n return `${s}s`;\n}\n","import { EMPTY_PLACEHOLDER } from './constants.ts';\n\nexport interface NumberFormatOptions extends Intl.NumberFormatOptions {\n whenNullish?: string;\n locale?: string;\n}\n\nfunction intlOptions(opts?: NumberFormatOptions): Intl.NumberFormatOptions {\n if (!opts) return {};\n const intlOptions = { ...opts };\n delete intlOptions.whenNullish;\n delete intlOptions.locale;\n return intlOptions;\n}\n\nexport function formatNumber(\n value: number | null | undefined,\n opts?: NumberFormatOptions,\n): string {\n if (value == null || Number.isNaN(value)) {\n return opts?.whenNullish ?? EMPTY_PLACEHOLDER;\n }\n return new Intl.NumberFormat(\n opts?.locale ?? 'en-US',\n intlOptions(opts),\n ).format(value);\n}\n\nexport const formatNullableNumber = formatNumber;\n\nexport function formatCompactNumber(\n value: number | null | undefined,\n opts?: NumberFormatOptions,\n): string {\n return formatNumber(value, {\n notation: 'compact',\n maximumFractionDigits: 1,\n ...opts,\n });\n}\n\nexport function formatCurrency(\n value: number | null | undefined,\n opts?: NumberFormatOptions,\n): string {\n return formatNumber(value, {\n style: 'currency',\n currency: 'USD',\n ...opts,\n });\n}\n\nexport function formatPercent(\n value: number | null | undefined,\n opts?: NumberFormatOptions,\n): string {\n if (value == null || Number.isNaN(value)) {\n return opts?.whenNullish ?? EMPTY_PLACEHOLDER;\n }\n return new Intl.NumberFormat(opts?.locale ?? 'en-US', {\n style: 'percent',\n minimumFractionDigits: 1,\n maximumFractionDigits: 1,\n ...intlOptions(opts),\n }).format(value / 100);\n}\n","import { format, formatRelative } from 'date-fns';\n\nexport function formatDateTime(date: Date | string): string {\n return format(date, 'PPpp');\n}\n\nexport function formatRelativeTime(date: Date | string): string {\n return formatRelative(date, new Date());\n}\n\nexport function formatShortDate(date: Date | string): string {\n return format(date, 'EEE MMM dd yyyy');\n}\n","import { formatBoolean } from './boolean.ts';\nimport { NA_PLACEHOLDER, NULL_PLACEHOLDER } from './constants.ts';\nimport { formatISODate, isISODateString } from './date.ts';\nimport { formatCurrency, formatNumber } from './number.ts';\n\nexport function formatCellValue(value: unknown): string {\n if (value === null || value === undefined) return NULL_PLACEHOLDER;\n if (isISODateString(value)) return formatISODate(value);\n if (typeof value === 'object') return JSON.stringify(value);\n return String(value);\n}\n\nexport type ByTypeKind =\n 'text' | 'number' | 'date' | 'boolean' | 'currency' | 'email' | 'url';\n\nexport function formatByType(value: unknown, type: ByTypeKind): string {\n if (value == null) return NA_PLACEHOLDER;\n switch (type) {\n case 'number':\n return typeof value === 'number' ? formatNumber(value) : String(value);\n case 'currency':\n return typeof value === 'number' ? formatCurrency(value) : String(value);\n case 'date': {\n if (isISODateString(value)) return formatISODate(value);\n if (\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n !(value instanceof Date)\n ) {\n return NA_PLACEHOLDER;\n }\n const parsed = new Date(value);\n return Number.isNaN(parsed.getTime())\n ? NA_PLACEHOLDER\n : parsed.toLocaleDateString();\n }\n case 'boolean':\n return typeof value === 'boolean' ? formatBoolean(value) : String(value);\n case 'email':\n case 'url':\n case 'text':\n return String(value);\n }\n}\n"],"mappings":";;AAAA,SAAgB,EAAc,GAAwB;CACpD,OAAO,IAAQ,MAAM;AACvB;;;ACFA,IAAa,IAAoB,KACpB,IAAmB,QACnB,IAAiB;;;ACA9B,SAAgB,EAAY,GAA0C;CAKpE,OAJI,KAAS,OAAM,MACf,KAAS,MAAsB,IAAI,IAAQ,IAAA,CAAe,QAAQ,CAAC,EAAE,OACrE,KAAS,MAAkB,IAAI,IAAQ,IAAA,CAAW,QAAQ,CAAC,EAAE,OAC7D,KAAS,MAAc,IAAI,IAAQ,IAAA,CAAO,QAAQ,CAAC,EAAE,OAClD,GAAG,EAAM;AAClB;AAEA,SAAgB,EAAe,GAA0C;CAIvE,OAHI,KAAS,OAAM,MACf,IAAQ,OAAa,GAAG,EAAM,MAC9B,IAAQ,OAAO,OAAa,IAAI,IAAQ,KAAA,CAAM,QAAQ,CAAC,EAAE,OACtD,IAAI,KAAS,OAAO,MAAA,CAAO,QAAQ,CAAC,EAAE;AAC/C;;;ACbA,IAAM,IACJ;AAEF,SAAgB,EAAgB,GAAiC;CAC/D,OAAO,OAAO,KAAU,YAAY,EAAY,KAAK,CAAK;AAC5D;AAEA,SAAgB,EAAc,GAAuB;CACnD,IAAM,IAAO,EAAS,CAAK;CAG3B,OAFK,EAAQ,CAAI,IACD,EAAM,SAAS,GAAG,KAAK,CAAC,EAAM,SAAS,gBAAgB,IAEnE,EAAO,GAAM,qBAAqB,IAClC,EAAO,GAAM,aAAa,IAJH;AAK7B;AAEA,SAAgB,EACd,GACA,IAA+B,SACvB;CACR,IAAM,IAAO,EAAS,CAAK;CAE3B,OADK,EAAQ,CAAI,IACV,MAAgB,QACnB,EAAO,GAAM,OAAO,IACpB,EAAO,GAAM,UAAU,IAHA;AAI7B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umberFormatOptions extends Intl.NumberFormatOptions {
2
+ whenNullish?: string;
3
+ locale?: string;
4
+ }
5
+ export declare function formatNumber(value: number | null | undefined, opts?: NumberFormatOptions): string;
6
+ export declare const formatNullableNumber: typeof formatNumber;
7
+ export declare function formatCompactNumber(value: number | null | undefined, opts?: NumberFormatOptions): string;
8
+ export declare function formatCurrency(value: number | null | undefined, opts?: NumberFormatOptions): string;
9
+ export declare function formatPercent(value: number | null | undefined, opts?: NumberFormatOptions): string;
10
+ //# sourceMappingURL=number.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../src/number.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,mBAAmB;IACnE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAUD,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,IAAI,CAAC,EAAE,mBAAmB,GACzB,MAAM,CAQR;AAED,eAAO,MAAM,oBAAoB,qBAAe,CAAC;AAEjD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,IAAI,CAAC,EAAE,mBAAmB,GACzB,MAAM,CAMR;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,IAAI,CAAC,EAAE,mBAAmB,GACzB,MAAM,CAMR;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,IAAI,CAAC,EAAE,mBAAmB,GACzB,MAAM,CAUR"}
package/dist/time.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare function formatDateTime(date: Date | string): string;
2
+ export declare function formatRelativeTime(date: Date | string): string;
3
+ export declare function formatShortDate(date: Date | string): string;
4
+ //# sourceMappingURL=time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAEA,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAE9D;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAE3D"}
@@ -0,0 +1,4 @@
1
+ export declare function formatCellValue(value: unknown): string;
2
+ export type ByTypeKind = 'text' | 'number' | 'date' | 'boolean' | 'currency' | 'email' | 'url';
3
+ export declare function formatByType(value: unknown, type: ByTypeKind): string;
4
+ //# sourceMappingURL=value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value.d.ts","sourceRoot":"","sources":["../src/value.ts"],"names":[],"mappings":"AAKA,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKtD;AAED,MAAM,MAAM,UAAU,GACpB,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,KAAK,CAAC;AAExE,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CA4BrE"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@deepagents/react-formatters",
3
+ "version": "7.0.0",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/JanuaryLabs/deepagents",
8
+ "directory": "packages/react/formatters"
9
+ },
10
+ "type": "module",
11
+ "main": "./dist/index.js",
12
+ "module": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "files": [
15
+ "dist",
16
+ "!dist/spec/**",
17
+ "!**/*.tsbuildinfo"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "exports": {
23
+ "./package.json": "./package.json",
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js",
27
+ "default": "./dist/index.js"
28
+ }
29
+ },
30
+ "dependencies": {
31
+ "date-fns": "^4.4.0"
32
+ },
33
+ "devDependencies": {
34
+ "typescript": "6.0.3",
35
+ "vite": "8.1.5",
36
+ "vite-plugin-dts": "~4.5.0",
37
+ "vitest": "4.1.10"
38
+ },
39
+ "engines": {
40
+ "node": ">=20"
41
+ }
42
+ }