@apexcura/ui-components 0.0.14-Beta276 → 0.0.14-Beta278

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
@@ -878,14 +878,20 @@ var DateRangePickerElement = (props) => {
878
878
  const { value } = props;
879
879
  const { RangePicker } = import_antd15.DatePicker;
880
880
  const dateValues = value ? value.map((date) => (0, import_dayjs2.default)(date, "DD-MM-YYYY")) : null;
881
+ const today = (0, import_dayjs2.default)();
881
882
  const handleChange = (dates, dateStrings) => {
882
883
  if (dates) {
883
- props.onChange && props.onChange(dateStrings);
884
+ if (props.weekrange) {
885
+ const updatedDates = [today, dates[1] || dates[0]];
886
+ const updatedDateStrings = updatedDates.map((date) => date && date.format("DD-MM-YYYY"));
887
+ props.onChange && props.onChange(updatedDateStrings);
888
+ } else {
889
+ props.onChange && props.onChange(dateStrings);
890
+ }
884
891
  } else {
885
892
  props.onChange && props.onChange("");
886
893
  }
887
894
  };
888
- const today = (0, import_dayjs2.default)();
889
895
  let rangePresets = [
890
896
  { label: "Last 7 Days", value: [(0, import_dayjs2.default)().subtract(6, "d"), today] },
891
897
  { label: "Last 14 Days", value: [(0, import_dayjs2.default)().subtract(13, "d"), today] },
@@ -905,13 +911,16 @@ var DateRangePickerElement = (props) => {
905
911
  ];
906
912
  }
907
913
  const disabledDate = (current) => {
914
+ if (props.weekrange) {
915
+ return current && (current < today.subtract(7, "d") || current > today.add(7, "d"));
916
+ }
908
917
  return current && (current > today.add(7, "d") || current < today.subtract(7, "d"));
909
918
  };
910
919
  return /* @__PURE__ */ import_react21.default.createElement(import_antd15.Space, { direction: "vertical", size: 12 }, /* @__PURE__ */ import_react21.default.createElement(
911
920
  RangePicker,
912
921
  {
913
922
  disabledDate,
914
- presets: rangePresets,
923
+ ...!props.weekrange && { presets: rangePresets },
915
924
  format: "DD-MM-YYYY",
916
925
  onChange: handleChange,
917
926
  value: dateValues
package/dist/index.mjs CHANGED
@@ -811,14 +811,20 @@ var DateRangePickerElement = (props) => {
811
811
  const { value } = props;
812
812
  const { RangePicker } = DatePicker2;
813
813
  const dateValues = value ? value.map((date) => dayjs2(date, "DD-MM-YYYY")) : null;
814
+ const today = dayjs2();
814
815
  const handleChange = (dates, dateStrings) => {
815
816
  if (dates) {
816
- props.onChange && props.onChange(dateStrings);
817
+ if (props.weekrange) {
818
+ const updatedDates = [today, dates[1] || dates[0]];
819
+ const updatedDateStrings = updatedDates.map((date) => date && date.format("DD-MM-YYYY"));
820
+ props.onChange && props.onChange(updatedDateStrings);
821
+ } else {
822
+ props.onChange && props.onChange(dateStrings);
823
+ }
817
824
  } else {
818
825
  props.onChange && props.onChange("");
819
826
  }
820
827
  };
821
- const today = dayjs2();
822
828
  let rangePresets = [
823
829
  { label: "Last 7 Days", value: [dayjs2().subtract(6, "d"), today] },
824
830
  { label: "Last 14 Days", value: [dayjs2().subtract(13, "d"), today] },
@@ -838,13 +844,16 @@ var DateRangePickerElement = (props) => {
838
844
  ];
839
845
  }
840
846
  const disabledDate = (current) => {
847
+ if (props.weekrange) {
848
+ return current && (current < today.subtract(7, "d") || current > today.add(7, "d"));
849
+ }
841
850
  return current && (current > today.add(7, "d") || current < today.subtract(7, "d"));
842
851
  };
843
852
  return /* @__PURE__ */ React21.createElement(Space, { direction: "vertical", size: 12 }, /* @__PURE__ */ React21.createElement(
844
853
  RangePicker,
845
854
  {
846
855
  disabledDate,
847
- presets: rangePresets,
856
+ ...!props.weekrange && { presets: rangePresets },
848
857
  format: "DD-MM-YYYY",
849
858
  onChange: handleChange,
850
859
  value: dateValues
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.14-Beta276",
3
+ "version": "0.0.14-Beta278",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",