@sonamu-kit/react-components 0.4.8 → 0.4.9
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,15 +1,16 @@
|
|
|
1
1
|
import { Input as e } from "./input.js";
|
|
2
2
|
import { jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { format as n } from "date-fns";
|
|
3
4
|
//#region src/components/ui/date-input.tsx
|
|
4
|
-
function
|
|
5
|
+
function r({ value: r, onValueChange: i, ...a }) {
|
|
5
6
|
return /* @__PURE__ */ t(e, {
|
|
6
7
|
type: "datetime-local",
|
|
7
|
-
value:
|
|
8
|
-
onChange: (e) =>
|
|
9
|
-
...
|
|
8
|
+
value: r ? n(r instanceof Date ? r : new Date(r), "yyyy-MM-dd'T'HH:mm") : "",
|
|
9
|
+
onChange: (e) => i(e.target.value ? new Date(e.target.value) : null),
|
|
10
|
+
...a
|
|
10
11
|
});
|
|
11
12
|
}
|
|
12
13
|
//#endregion
|
|
13
|
-
export {
|
|
14
|
+
export { r as DateInput };
|
|
14
15
|
|
|
15
16
|
//# sourceMappingURL=date-input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-input.js","names":[],"sources":["../../../src/components/ui/date-input.tsx"],"sourcesContent":["import { type Override } from \"../../lib/types\";\nimport { Input } from \"./input\";\n\ntype DateInputProps = Override<\n React.ComponentProps<\"input\">,\n {\n value: Date | null;\n onValueChange: (value: Date | null) => void;\n }\n>;\nfunction DateInput({ value, onValueChange, ...props }: DateInputProps) {\n //
|
|
1
|
+
{"version":3,"file":"date-input.js","names":[],"sources":["../../../src/components/ui/date-input.tsx"],"sourcesContent":["import { format } from \"date-fns\";\n\nimport { type Override } from \"../../lib/types\";\nimport { Input } from \"./input\";\n\ntype DateInputProps = Override<\n React.ComponentProps<\"input\">,\n {\n value: Date | null;\n onValueChange: (value: Date | null) => void;\n }\n>;\nfunction DateInput({ value, onValueChange, ...props }: DateInputProps) {\n // 입력과 같은 현지 시각 기준으로 표시해 수정 시 시차가 생기지 않게 합니다.\n const dateValue = !value\n ? \"\"\n : format(value instanceof Date ? value : new Date(value), \"yyyy-MM-dd'T'HH:mm\");\n\n return (\n <Input\n type=\"datetime-local\"\n value={dateValue}\n onChange={(e) => onValueChange(e.target.value ? new Date(e.target.value) : null)}\n {...props}\n />\n );\n}\n\nexport { DateInput, type DateInputProps };\n"],"mappings":";;;;AAYA,SAAS,EAAU,EAAE,UAAO,kBAAe,GAAG,KAAyB;CAMrE,OACE,kBAAC,GAAD;EACE,MAAK;EACL,OAPe,IAEf,EAAO,aAAiB,OAAO,IAAQ,IAAI,KAAK,CAAK,GAAG,oBAAoB,IAD5E;EAOA,WAAW,MAAM,EAAc,EAAE,OAAO,QAAQ,IAAI,KAAK,EAAE,OAAO,KAAK,IAAI,IAAI;EAC/E,GAAI;CACL,CAAA;AAEL"}
|
package/dist/lib/base-helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { caster as e } from "./caster.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { format as t } from "date-fns";
|
|
3
|
+
import { isObject as n } from "radashi";
|
|
4
4
|
import r from "qs";
|
|
5
5
|
//#region src/lib/base-helpers.ts
|
|
6
6
|
function i(e) {
|
|
@@ -10,7 +10,7 @@ function a(t, n) {
|
|
|
10
10
|
return e(n, r.parse(t.toString()));
|
|
11
11
|
}
|
|
12
12
|
function o(e) {
|
|
13
|
-
return Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0).map(([e,
|
|
13
|
+
return Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0).map(([e, t]) => Array.isArray(t) ? [[`${e}[]`, t]] : n(t) ? Object.entries(t).map(([t, n]) => [`${e}[${t}]`, String(n)]) : [[e, String(t)]]).flat());
|
|
14
14
|
}
|
|
15
15
|
function s(e) {
|
|
16
16
|
return e === null ? null : e.slice(0, 10);
|
|
@@ -19,10 +19,10 @@ function c(e) {
|
|
|
19
19
|
return e && new Intl.NumberFormat().format(e);
|
|
20
20
|
}
|
|
21
21
|
function l(e) {
|
|
22
|
-
return e == null ? null : e instanceof Date ?
|
|
22
|
+
return e == null ? null : e instanceof Date ? t(e, "yyyy-MM-dd") : e.slice(0, 10);
|
|
23
23
|
}
|
|
24
24
|
function u(e) {
|
|
25
|
-
return e == null ? null : e instanceof Date ?
|
|
25
|
+
return e == null ? null : e instanceof Date ? t(e, "yyyy-MM-dd HH:mm:ss") : e.slice(0, 19);
|
|
26
26
|
}
|
|
27
27
|
function d(e) {
|
|
28
28
|
return e ? Array.isArray(e) ? e : [e] : [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonamu-kit/react-components",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "CartaNova <dev@cartanova.ai>",
|
|
6
6
|
"repository": {
|
|
@@ -118,7 +118,8 @@
|
|
|
118
118
|
"unplugin-icons": "0.20.2",
|
|
119
119
|
"vite": "8.0.16",
|
|
120
120
|
"vite-plugin-dts": "5.0.2",
|
|
121
|
-
"vite-tsconfig-paths": "^6.1.1"
|
|
121
|
+
"vite-tsconfig-paths": "^6.1.1",
|
|
122
|
+
"vitest": "^4.1.9"
|
|
122
123
|
},
|
|
123
124
|
"peerDependencies": {
|
|
124
125
|
"@tanstack/react-query": "^5.90.12",
|
|
@@ -131,6 +132,7 @@
|
|
|
131
132
|
"dev": "vite",
|
|
132
133
|
"build": "vite build",
|
|
133
134
|
"lint": "oxlint src",
|
|
135
|
+
"test": "vitest run --config vitest.config.ts tests/date-input.test.tsx",
|
|
134
136
|
"test:exports": "node --test tests/package-exports.test.mjs",
|
|
135
137
|
"preview": "vite preview",
|
|
136
138
|
"storybook": "storybook dev -p 6006",
|