@bsol-oss/react-datatable5 12.0.0-beta.26 → 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 CHANGED
@@ -3798,29 +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
- const formatedDate = dayjs(selectedDate).format("YYYY-MM-DD");
3802
3801
  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
- });
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
+ }
3817
3821
  }
3818
3822
  }
3823
+ catch (e) {
3824
+ console.error(e);
3825
+ }
3819
3826
  }, [selectedDate, dateFormat, colLabel, setValue]);
3820
3827
  return (jsxRuntime.jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
3821
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: () => {
3822
3829
  setOpen(true);
3823
- }, justifyContent: "start", children: [jsxRuntime.jsx(md.MdDateRange, {}), selectedDate !== undefined ? `${formatedDate}` : ""] }) }), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs(PopoverBody, { children: [jsxRuntime.jsx(PopoverTitle, {}), jsxRuntime.jsx(DatePicker$1
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
3824
3831
  // @ts-expect-error TODO: find appropriate types
3825
3832
  , {
3826
3833
  // @ts-expect-error TODO: find appropriate types
package/dist/index.mjs CHANGED
@@ -3778,29 +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
- const formatedDate = dayjs(selectedDate).format("YYYY-MM-DD");
3782
3781
  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
- });
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
+ }
3797
3801
  }
3798
3802
  }
3803
+ catch (e) {
3804
+ console.error(e);
3805
+ }
3799
3806
  }, [selectedDate, dateFormat, colLabel, setValue]);
3800
3807
  return (jsxs(Field, { label: `${translate.t(removeIndex(`${colLabel}.field_label`))}`, required: isRequired, alignItems: "stretch", gridColumn,
3801
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: () => {
3802
3809
  setOpen(true);
3803
- }, justifyContent: "start", children: [jsx(MdDateRange, {}), selectedDate !== undefined ? `${formatedDate}` : ""] }) }), jsx(PopoverContent, { children: jsxs(PopoverBody, { children: [jsx(PopoverTitle, {}), jsx(DatePicker$1
3810
+ }, justifyContent: "start", children: [jsx(MdDateRange, {}), selectedDate !== undefined ? `${selectedDate}` : ""] }) }), jsx(PopoverContent, { children: jsxs(PopoverBody, { children: [jsx(PopoverTitle, {}), jsx(DatePicker$1
3804
3811
  // @ts-expect-error TODO: find appropriate types
3805
3812
  , {
3806
3813
  // @ts-expect-error TODO: find appropriate types
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsol-oss/react-datatable5",
3
- "version": "12.0.0-beta.26",
3
+ "version": "12.0.0-beta.27",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",