@k3-universe/react-kit 0.0.43 → 0.0.44
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.js
CHANGED
|
@@ -22532,6 +22532,15 @@ function DateField({
|
|
|
22532
22532
|
onChange,
|
|
22533
22533
|
className
|
|
22534
22534
|
}) {
|
|
22535
|
+
const parseDateValueForInput = (date2) => {
|
|
22536
|
+
if (date2 instanceof Date) {
|
|
22537
|
+
return date2.toISOString().split("T")[0];
|
|
22538
|
+
}
|
|
22539
|
+
if (typeof date2 === "string") {
|
|
22540
|
+
return parseDateValueForInput(new Date(date2));
|
|
22541
|
+
}
|
|
22542
|
+
return "";
|
|
22543
|
+
};
|
|
22535
22544
|
return /* @__PURE__ */ jsx(
|
|
22536
22545
|
Input,
|
|
22537
22546
|
{
|
|
@@ -22539,7 +22548,10 @@ function DateField({
|
|
|
22539
22548
|
disabled: field.disabled || field.readOnly,
|
|
22540
22549
|
placeholder: field.placeholder,
|
|
22541
22550
|
type: "date",
|
|
22542
|
-
value:
|
|
22551
|
+
value: parseDateValueForInput(value),
|
|
22552
|
+
defaultValue: parseDateValueForInput(value),
|
|
22553
|
+
min: parseDateValueForInput(field.minDate),
|
|
22554
|
+
max: parseDateValueForInput(field.maxDate),
|
|
22543
22555
|
onChange: (e2) => onChange(e2.target.value ? new Date(e2.target.value) : null)
|
|
22544
22556
|
}
|
|
22545
22557
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateField.d.ts","sourceRoot":"","sources":["../../../../../../src/kit/builder/form/components/fields/DateField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,QAAQ,EACR,SAAS,GACV,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"DateField.d.ts","sourceRoot":"","sources":["../../../../../../src/kit/builder/form/components/fields/DateField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,QAAQ,EACR,SAAS,GACV,EAAE,gBAAgB,2CA4BlB"}
|
package/package.json
CHANGED
|
@@ -7,17 +7,28 @@ export function DateField({
|
|
|
7
7
|
onChange,
|
|
8
8
|
className,
|
|
9
9
|
}: FieldRenderProps) {
|
|
10
|
+
const parseDateValueForInput = (date: unknown) => {
|
|
11
|
+
if (date instanceof Date) {
|
|
12
|
+
return date.toISOString().split('T')[0];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (typeof date === 'string') {
|
|
16
|
+
return parseDateValueForInput(new Date(date));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return '';
|
|
20
|
+
}
|
|
21
|
+
|
|
10
22
|
return (
|
|
11
23
|
<Input
|
|
12
24
|
className={className}
|
|
13
25
|
disabled={field.disabled || field.readOnly}
|
|
14
26
|
placeholder={field.placeholder}
|
|
15
27
|
type="date"
|
|
16
|
-
value={
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
28
|
+
value={parseDateValueForInput(value)}
|
|
29
|
+
defaultValue={parseDateValueForInput(value)}
|
|
30
|
+
min={parseDateValueForInput(field.minDate)}
|
|
31
|
+
max={parseDateValueForInput(field.maxDate)}
|
|
21
32
|
onChange={(e) =>
|
|
22
33
|
onChange(e.target.value ? new Date(e.target.value) : null)
|
|
23
34
|
}
|