@bsol-oss/react-datatable5 12.0.0-beta.25 → 12.0.0-beta.27
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 +27 -2
- package/dist/index.mjs +27 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3798,11 +3798,36 @@ const DatePicker = ({ column, schema, prefix }) => {
|
|
|
3798
3798
|
const colLabel = `${prefix}${column}`;
|
|
3799
3799
|
const [open, setOpen] = React.useState(false);
|
|
3800
3800
|
const selectedDate = watch(colLabel);
|
|
3801
|
-
|
|
3801
|
+
React.useEffect(() => {
|
|
3802
|
+
try {
|
|
3803
|
+
if (selectedDate) {
|
|
3804
|
+
// Parse the selectedDate as UTC or in a specific timezone to avoid +8 hour shift
|
|
3805
|
+
// For example, parse as UTC:
|
|
3806
|
+
const parsedDate = dayjs.utc(selectedDate);
|
|
3807
|
+
// Or if you want to parse in local timezone without shifting:
|
|
3808
|
+
// const parsedDate = dayjs.tz(selectedDate, dayjs.tz.guess());
|
|
3809
|
+
if (!parsedDate.isValid())
|
|
3810
|
+
return;
|
|
3811
|
+
console.log(selectedDate, parsedDate, parsedDate.format(dateFormat), "dkosfp");
|
|
3812
|
+
// Format according to dateFormat from schema
|
|
3813
|
+
const formatted = parsedDate.format(dateFormat);
|
|
3814
|
+
// Update the form value only if different to avoid loops
|
|
3815
|
+
if (formatted !== selectedDate) {
|
|
3816
|
+
setValue(colLabel, formatted, {
|
|
3817
|
+
shouldValidate: true,
|
|
3818
|
+
shouldDirty: true,
|
|
3819
|
+
});
|
|
3820
|
+
}
|
|
3821
|
+
}
|
|
3822
|
+
}
|
|
3823
|
+
catch (e) {
|
|
3824
|
+
console.error(e);
|
|
3825
|
+
}
|
|
3826
|
+
}, [selectedDate, dateFormat, colLabel, setValue]);
|
|
3802
3827
|
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3803
3828
|
gridRow, children: [jsxRuntime.jsxs(PopoverRoot, { open: open, onOpenChange: (e) => setOpen(e.open), closeOnInteractOutside: true, children: [jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: jsxRuntime.jsxs(Button, { size: "sm", variant: "outline", onClick: () => {
|
|
3804
3829
|
setOpen(true);
|
|
3805
|
-
}, justifyContent: "start", children: [jsxRuntime.jsx(md.MdDateRange, {}), selectedDate !== undefined ? `${
|
|
3830
|
+
}, justifyContent: "start", children: [jsxRuntime.jsx(md.MdDateRange, {}), selectedDate !== undefined ? `${selectedDate}` : ""] }) }), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs(PopoverBody, { children: [jsxRuntime.jsx(PopoverTitle, {}), jsxRuntime.jsx(DatePicker$1
|
|
3806
3831
|
// @ts-expect-error TODO: find appropriate types
|
|
3807
3832
|
, {
|
|
3808
3833
|
// @ts-expect-error TODO: find appropriate types
|
package/dist/index.mjs
CHANGED
|
@@ -3778,11 +3778,36 @@ const DatePicker = ({ column, schema, prefix }) => {
|
|
|
3778
3778
|
const colLabel = `${prefix}${column}`;
|
|
3779
3779
|
const [open, setOpen] = useState(false);
|
|
3780
3780
|
const selectedDate = watch(colLabel);
|
|
3781
|
-
|
|
3781
|
+
useEffect(() => {
|
|
3782
|
+
try {
|
|
3783
|
+
if (selectedDate) {
|
|
3784
|
+
// Parse the selectedDate as UTC or in a specific timezone to avoid +8 hour shift
|
|
3785
|
+
// For example, parse as UTC:
|
|
3786
|
+
const parsedDate = dayjs.utc(selectedDate);
|
|
3787
|
+
// Or if you want to parse in local timezone without shifting:
|
|
3788
|
+
// const parsedDate = dayjs.tz(selectedDate, dayjs.tz.guess());
|
|
3789
|
+
if (!parsedDate.isValid())
|
|
3790
|
+
return;
|
|
3791
|
+
console.log(selectedDate, parsedDate, parsedDate.format(dateFormat), "dkosfp");
|
|
3792
|
+
// Format according to dateFormat from schema
|
|
3793
|
+
const formatted = parsedDate.format(dateFormat);
|
|
3794
|
+
// Update the form value only if different to avoid loops
|
|
3795
|
+
if (formatted !== selectedDate) {
|
|
3796
|
+
setValue(colLabel, formatted, {
|
|
3797
|
+
shouldValidate: true,
|
|
3798
|
+
shouldDirty: true,
|
|
3799
|
+
});
|
|
3800
|
+
}
|
|
3801
|
+
}
|
|
3802
|
+
}
|
|
3803
|
+
catch (e) {
|
|
3804
|
+
console.error(e);
|
|
3805
|
+
}
|
|
3806
|
+
}, [selectedDate, dateFormat, colLabel, setValue]);
|
|
3782
3807
|
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3783
3808
|
gridRow, children: [jsxs(PopoverRoot, { open: open, onOpenChange: (e) => setOpen(e.open), closeOnInteractOutside: true, children: [jsx(PopoverTrigger, { asChild: true, children: jsxs(Button, { size: "sm", variant: "outline", onClick: () => {
|
|
3784
3809
|
setOpen(true);
|
|
3785
|
-
}, justifyContent: "start", children: [jsx(MdDateRange, {}), selectedDate !== undefined ? `${
|
|
3810
|
+
}, justifyContent: "start", children: [jsx(MdDateRange, {}), selectedDate !== undefined ? `${selectedDate}` : ""] }) }), jsx(PopoverContent, { children: jsxs(PopoverBody, { children: [jsx(PopoverTitle, {}), jsx(DatePicker$1
|
|
3786
3811
|
// @ts-expect-error TODO: find appropriate types
|
|
3787
3812
|
, {
|
|
3788
3813
|
// @ts-expect-error TODO: find appropriate types
|