@apexcura/ui-components 0.0.14-Beta277 → 0.0.14-Beta279

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
@@ -874,13 +874,23 @@ var DatePickerElement = (props) => {
874
874
  var import_react21 = __toESM(require("react"));
875
875
  var import_antd15 = require("antd");
876
876
  var import_dayjs2 = __toESM(require("dayjs"));
877
+ var import_moment2 = __toESM(require("moment"));
877
878
  var DateRangePickerElement = (props) => {
878
879
  const { value } = props;
879
880
  const { RangePicker } = import_antd15.DatePicker;
880
881
  const dateValues = value ? value.map((date) => (0, import_dayjs2.default)(date, "DD-MM-YYYY")) : null;
881
882
  const handleChange = (dates, dateStrings) => {
882
883
  if (dates) {
883
- props.onChange && props.onChange(dateStrings);
884
+ let [start, end] = dates;
885
+ const today2 = (0, import_dayjs2.default)();
886
+ if (end && end.isAfter(today2)) {
887
+ start = today2;
888
+ }
889
+ if (start && start.isBefore(today2)) {
890
+ end = today2;
891
+ }
892
+ const adjustedDates = [start, end].map((date) => date ? date.format("DD-MM-YYYY") : null);
893
+ props.onChange && props.onChange(adjustedDates);
884
894
  } else {
885
895
  props.onChange && props.onChange("");
886
896
  }
@@ -892,24 +902,19 @@ var DateRangePickerElement = (props) => {
892
902
  { label: "Last 30 Days", value: [(0, import_dayjs2.default)().subtract(29, "d"), today] },
893
903
  { label: "Last 90 Days", value: [(0, import_dayjs2.default)().subtract(89, "d"), today] }
894
904
  ];
905
+ let disabledDate;
895
906
  if (props.weekrange) {
896
- rangePresets = [
897
- {
898
- label: "This Week",
899
- value: [today.startOf("week"), today.endOf("week")]
900
- },
901
- {
902
- label: "Last Week",
903
- value: [today.startOf("week").subtract(1, "week"), today.endOf("week").subtract(1, "week")]
907
+ disabledDate = (current) => {
908
+ if (props.weekrange) {
909
+ return current && (current < today.subtract(7, "d") || current > today.add(7, "d"));
904
910
  }
905
- ];
911
+ return current && (current > today.add(7, "d") || current < today.subtract(7, "d"));
912
+ };
913
+ } else {
914
+ disabledDate = (current) => {
915
+ return current && current > (0, import_moment2.default)();
916
+ };
906
917
  }
907
- const disabledDate = (current) => {
908
- if (props.weekrange) {
909
- return current && (current < today.subtract(7, "d") || current > today.add(7, "d"));
910
- }
911
- return current && (current > today.add(7, "d") || current < today.subtract(7, "d"));
912
- };
913
918
  return /* @__PURE__ */ import_react21.default.createElement(import_antd15.Space, { direction: "vertical", size: 12 }, /* @__PURE__ */ import_react21.default.createElement(
914
919
  RangePicker,
915
920
  {
package/dist/index.mjs CHANGED
@@ -807,13 +807,23 @@ var DatePickerElement = (props) => {
807
807
  import React21 from "react";
808
808
  import { DatePicker as DatePicker2, Space } from "antd";
809
809
  import dayjs2 from "dayjs";
810
+ import moment2 from "moment";
810
811
  var DateRangePickerElement = (props) => {
811
812
  const { value } = props;
812
813
  const { RangePicker } = DatePicker2;
813
814
  const dateValues = value ? value.map((date) => dayjs2(date, "DD-MM-YYYY")) : null;
814
815
  const handleChange = (dates, dateStrings) => {
815
816
  if (dates) {
816
- props.onChange && props.onChange(dateStrings);
817
+ let [start, end] = dates;
818
+ const today2 = dayjs2();
819
+ if (end && end.isAfter(today2)) {
820
+ start = today2;
821
+ }
822
+ if (start && start.isBefore(today2)) {
823
+ end = today2;
824
+ }
825
+ const adjustedDates = [start, end].map((date) => date ? date.format("DD-MM-YYYY") : null);
826
+ props.onChange && props.onChange(adjustedDates);
817
827
  } else {
818
828
  props.onChange && props.onChange("");
819
829
  }
@@ -825,24 +835,19 @@ var DateRangePickerElement = (props) => {
825
835
  { label: "Last 30 Days", value: [dayjs2().subtract(29, "d"), today] },
826
836
  { label: "Last 90 Days", value: [dayjs2().subtract(89, "d"), today] }
827
837
  ];
838
+ let disabledDate;
828
839
  if (props.weekrange) {
829
- rangePresets = [
830
- {
831
- label: "This Week",
832
- value: [today.startOf("week"), today.endOf("week")]
833
- },
834
- {
835
- label: "Last Week",
836
- value: [today.startOf("week").subtract(1, "week"), today.endOf("week").subtract(1, "week")]
840
+ disabledDate = (current) => {
841
+ if (props.weekrange) {
842
+ return current && (current < today.subtract(7, "d") || current > today.add(7, "d"));
837
843
  }
838
- ];
844
+ return current && (current > today.add(7, "d") || current < today.subtract(7, "d"));
845
+ };
846
+ } else {
847
+ disabledDate = (current) => {
848
+ return current && current > moment2();
849
+ };
839
850
  }
840
- const disabledDate = (current) => {
841
- if (props.weekrange) {
842
- return current && (current < today.subtract(7, "d") || current > today.add(7, "d"));
843
- }
844
- return current && (current > today.add(7, "d") || current < today.subtract(7, "d"));
845
- };
846
851
  return /* @__PURE__ */ React21.createElement(Space, { direction: "vertical", size: 12 }, /* @__PURE__ */ React21.createElement(
847
852
  RangePicker,
848
853
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.14-Beta277",
3
+ "version": "0.0.14-Beta279",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",