@bsol-oss/react-datatable5 12.0.0-beta.25 → 12.0.0-beta.26
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 +18 -0
- package/dist/index.mjs +18 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3799,6 +3799,24 @@ const DatePicker = ({ column, schema, prefix }) => {
|
|
|
3799
3799
|
const [open, setOpen] = React.useState(false);
|
|
3800
3800
|
const selectedDate = watch(colLabel);
|
|
3801
3801
|
const formatedDate = dayjs(selectedDate).format("YYYY-MM-DD");
|
|
3802
|
+
React.useEffect(() => {
|
|
3803
|
+
if (selectedDate) {
|
|
3804
|
+
// Parse the selectedDate with dayjs
|
|
3805
|
+
const parsedDate = dayjs(selectedDate);
|
|
3806
|
+
// If invalid date, do nothing
|
|
3807
|
+
if (!parsedDate.isValid())
|
|
3808
|
+
return;
|
|
3809
|
+
// Format according to dateFormat from schema
|
|
3810
|
+
const formatted = parsedDate.format(dateFormat);
|
|
3811
|
+
// Update the form value only if different to avoid loops
|
|
3812
|
+
if (formatted !== selectedDate) {
|
|
3813
|
+
setValue(colLabel, formatted, {
|
|
3814
|
+
shouldValidate: true,
|
|
3815
|
+
shouldDirty: true,
|
|
3816
|
+
});
|
|
3817
|
+
}
|
|
3818
|
+
}
|
|
3819
|
+
}, [selectedDate, dateFormat, colLabel, setValue]);
|
|
3802
3820
|
return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3803
3821
|
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
3822
|
setOpen(true);
|
package/dist/index.mjs
CHANGED
|
@@ -3779,6 +3779,24 @@ const DatePicker = ({ column, schema, prefix }) => {
|
|
|
3779
3779
|
const [open, setOpen] = useState(false);
|
|
3780
3780
|
const selectedDate = watch(colLabel);
|
|
3781
3781
|
const formatedDate = dayjs(selectedDate).format("YYYY-MM-DD");
|
|
3782
|
+
useEffect(() => {
|
|
3783
|
+
if (selectedDate) {
|
|
3784
|
+
// Parse the selectedDate with dayjs
|
|
3785
|
+
const parsedDate = dayjs(selectedDate);
|
|
3786
|
+
// If invalid date, do nothing
|
|
3787
|
+
if (!parsedDate.isValid())
|
|
3788
|
+
return;
|
|
3789
|
+
// Format according to dateFormat from schema
|
|
3790
|
+
const formatted = parsedDate.format(dateFormat);
|
|
3791
|
+
// Update the form value only if different to avoid loops
|
|
3792
|
+
if (formatted !== selectedDate) {
|
|
3793
|
+
setValue(colLabel, formatted, {
|
|
3794
|
+
shouldValidate: true,
|
|
3795
|
+
shouldDirty: true,
|
|
3796
|
+
});
|
|
3797
|
+
}
|
|
3798
|
+
}
|
|
3799
|
+
}, [selectedDate, dateFormat, colLabel, setValue]);
|
|
3782
3800
|
return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
3783
3801
|
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
3802
|
setOpen(true);
|