sag_components 2.0.0-beta343 → 2.0.0-beta344

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
@@ -646,21 +646,41 @@ const ChervronLeftIcon = _ref => {
646
646
 
647
647
  const CalendarIcon = _ref => {
648
648
  let {
649
- clicked,
650
649
  width = "14",
651
650
  height = "14",
652
- fill = "#212121",
653
- color
651
+ color = "#212121"
654
652
  } = _ref;
655
653
  return /*#__PURE__*/React__default["default"].createElement("svg", {
656
654
  width: width,
657
655
  height: height,
658
- viewBox: "0 0 11 12",
656
+ viewBox: "0 0 24 24",
659
657
  fill: "none",
660
- xmlns: "http://www.w3.org/2000/svg"
661
- }, /*#__PURE__*/React__default["default"].createElement("path", {
662
- d: "M2.625 0C2.8125 0 3 0.1875 3 0.375V1.5H7.5V0.375C7.5 0.1875 7.66406 0 7.875 0C8.0625 0 8.25 0.1875 8.25 0.375V1.5H9C9.82031 1.5 10.5 2.17969 10.5 3V3.75V4.5V10.5C10.5 11.3438 9.82031 12 9 12H1.5C0.65625 12 0 11.3438 0 10.5V4.5V3.75V3C0 2.17969 0.65625 1.5 1.5 1.5H2.25V0.375C2.25 0.1875 2.41406 0 2.625 0ZM9.75 4.5H7.3125V6.1875H9.75V4.5ZM9.75 6.9375H7.3125V8.8125H9.75V6.9375ZM9.75 9.5625H7.3125V11.25H9C9.39844 11.25 9.75 10.9219 9.75 10.5V9.5625ZM6.5625 8.8125V6.9375H3.9375V8.8125H6.5625ZM3.9375 9.5625V11.25H6.5625V9.5625H3.9375ZM3.1875 8.8125V6.9375H0.75V8.8125H3.1875ZM0.75 9.5625V10.5C0.75 10.9219 1.07812 11.25 1.5 11.25H3.1875V9.5625H0.75ZM0.75 6.1875H3.1875V4.5H0.75V6.1875ZM3.9375 6.1875H6.5625V4.5H3.9375V6.1875ZM9 2.25H1.5C1.07812 2.25 0.75 2.60156 0.75 3V3.75H9.75V3C9.75 2.60156 9.39844 2.25 9 2.25Z",
663
- fill: color || fill
658
+ stroke: color,
659
+ strokeWidth: "2",
660
+ strokeLinecap: "round",
661
+ strokeLinejoin: "round"
662
+ }, /*#__PURE__*/React__default["default"].createElement("rect", {
663
+ x: "3",
664
+ y: "4",
665
+ width: "18",
666
+ height: "18",
667
+ rx: "2",
668
+ ry: "2"
669
+ }), /*#__PURE__*/React__default["default"].createElement("line", {
670
+ x1: "16",
671
+ y1: "2",
672
+ x2: "16",
673
+ y2: "6"
674
+ }), /*#__PURE__*/React__default["default"].createElement("line", {
675
+ x1: "8",
676
+ y1: "2",
677
+ x2: "8",
678
+ y2: "6"
679
+ }), /*#__PURE__*/React__default["default"].createElement("line", {
680
+ x1: "3",
681
+ y1: "10",
682
+ x2: "21",
683
+ y2: "10"
664
684
  }));
665
685
  };
666
686
 
@@ -9025,28 +9045,27 @@ const IconContainer$5 = styled__default["default"].div`
9025
9045
  cursor: pointer;
9026
9046
  `;
9027
9047
 
9028
- const DropdownSingleNew = _ref => {
9029
- let {
9030
- label,
9031
- labelEmptyValue,
9032
- options,
9033
- selectedValue,
9034
- onChange,
9035
- required,
9036
- disabled,
9037
- width,
9038
- height,
9039
- minHeight,
9040
- withMarginBottom = true,
9041
- error,
9042
- errorMessage,
9043
- xIconShow,
9044
- labelColor,
9045
- showLabelOnTop,
9046
- orderBy,
9047
- placeHolder = "",
9048
- elementType
9049
- } = _ref;
9048
+ const DropdownSingleNew = ({
9049
+ label,
9050
+ labelEmptyValue,
9051
+ options,
9052
+ selectedValue,
9053
+ onChange,
9054
+ required,
9055
+ disabled,
9056
+ width,
9057
+ height,
9058
+ minHeight,
9059
+ withMarginBottom = true,
9060
+ error,
9061
+ errorMessage,
9062
+ xIconShow,
9063
+ labelColor,
9064
+ showLabelOnTop,
9065
+ orderBy,
9066
+ placeHolder = "",
9067
+ elementType
9068
+ }) => {
9050
9069
  const [isFocused, setIsFocused] = React$1.useState(false);
9051
9070
  const [showOptions, setShowOptions] = React$1.useState(false);
9052
9071
  const [showAbove, setShowAbove] = React$1.useState(false);
@@ -9581,29 +9600,28 @@ const IconContainer$4 = styled__default["default"].div`
9581
9600
  cursor: pointer;
9582
9601
  `;
9583
9602
 
9584
- const DropdownMultiNew = _ref => {
9585
- let {
9586
- label,
9587
- labelEmptyValue,
9588
- options,
9589
- selectedValue,
9590
- onChange,
9591
- required,
9592
- disabled,
9593
- width,
9594
- height,
9595
- minHeight,
9596
- withMarginBottom = true,
9597
- error,
9598
- errorMessage,
9599
- labelColor,
9600
- xIconShow,
9601
- checkBoxColor,
9602
- showLabelOnTop,
9603
- orderBy,
9604
- elementType,
9605
- showSelectAll = false
9606
- } = _ref;
9603
+ const DropdownMultiNew = ({
9604
+ label,
9605
+ labelEmptyValue,
9606
+ options,
9607
+ selectedValue,
9608
+ onChange,
9609
+ required,
9610
+ disabled,
9611
+ width,
9612
+ height,
9613
+ minHeight,
9614
+ withMarginBottom = true,
9615
+ error,
9616
+ errorMessage,
9617
+ labelColor,
9618
+ xIconShow,
9619
+ checkBoxColor,
9620
+ showLabelOnTop,
9621
+ orderBy,
9622
+ elementType,
9623
+ showSelectAll = false
9624
+ }) => {
9607
9625
  const [isFocused, setIsFocused] = React$1.useState(false);
9608
9626
  const [showOptions, setShowOptions] = React$1.useState(false);
9609
9627
  const [showAbove, setShowAbove] = React$1.useState(false);
@@ -10250,9 +10268,12 @@ const DatePicker = ({
10250
10268
  if (value === '' || value === undefined) {
10251
10269
  setStartDate(null);
10252
10270
  setEndDate(null);
10271
+ setCurrentStartDate(new Date());
10253
10272
  } else {
10254
- setStartDate(new Date(startDateValue));
10273
+ const parsedStart = new Date(startDateValue);
10274
+ setStartDate(parsedStart);
10255
10275
  setEndDate(new Date(endDateValue));
10276
+ setCurrentStartDate(parsedStart);
10256
10277
  }
10257
10278
  }, [value, isOpen]);
10258
10279
  const renderDatePicker = () => {
@@ -10366,48 +10387,61 @@ const RangePicker = _ref => {
10366
10387
  const [startDateValue, setStartDateValue] = React$1.useState(null); // Added value state
10367
10388
  const [endDateValue, setEndDateValue] = React$1.useState(null); // Added value state
10368
10389
 
10369
- const [hoverInputContainer, setHoverInputContainer] = React$1.useState(false);
10370
- const [hoverOptionsContainer, setHoverOptionsContainer] = React$1.useState(false);
10371
- const inputRef = React$1.useRef(null);
10390
+ const containerRef = React$1.useRef(null);
10372
10391
  React$1.useEffect(() => {
10373
10392
  const handleClickOutside = event => {
10374
- if (inputRef.current && !inputRef.current.contains(event.target)) {
10393
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
10375
10394
  setIsFocused(false);
10395
+ setIsOpen(false);
10376
10396
  }
10377
10397
  };
10378
-
10379
- // Add event listener for clicks on the document
10380
10398
  document.addEventListener('mousedown', handleClickOutside);
10381
-
10382
- // Cleanup event listener on component unmount
10383
10399
  return () => {
10384
10400
  document.removeEventListener('mousedown', handleClickOutside);
10385
10401
  };
10386
10402
  }, []);
10387
10403
  React$1.useEffect(() => {
10388
- if (selectedValue && selectedValue.includes('-')) {
10389
- const dateArray = selectedValue.split('-');
10390
- const startDate = new Date(dateArray[0]);
10391
- const endDate = new Date(dateArray[1]);
10404
+ if (!selectedValue) return;
10405
+ if (selectedValue.includes(' - ')) {
10406
+ // DD/MM/YYYY - DD/MM/YYYY format
10407
+ const parts = selectedValue.split(' - ');
10408
+ if (parts.length !== 2) return;
10409
+ const startDate = moment(parts[0].trim(), 'DD/MM/YYYY', true);
10410
+ const endDate = moment(parts[1].trim(), 'DD/MM/YYYY', true);
10411
+ if (!startDate.isValid() || !endDate.isValid()) return;
10412
+ setStartDateValue(startDate.format('MM/DD/YYYY'));
10413
+ setEndDateValue(endDate.format('MM/DD/YYYY'));
10414
+ setValue(selectedValue);
10415
+ } else if (selectedValue.includes('-')) {
10416
+ // MM/DD/YYYY-MM/DD/YYYY format
10417
+ const parts = selectedValue.split('-');
10418
+ if (parts.length !== 2) return;
10419
+ const startDate = new Date(parts[0].trim());
10420
+ const endDate = new Date(parts[1].trim());
10421
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) return;
10392
10422
  setStartDateValue(moment(startDate).format('MM/DD/YYYY'));
10393
10423
  setEndDateValue(moment(endDate).format('MM/DD/YYYY'));
10394
10424
  setValue(selectedValue);
10395
10425
  }
10396
10426
  }, [selectedValue]);
10397
- React$1.useEffect(() => {
10398
- if (!hoverInputContainer && !hoverOptionsContainer) {
10399
- setIsFocused(false);
10400
- setIsOpen(false);
10401
- }
10402
- }, [hoverInputContainer, hoverOptionsContainer]);
10427
+ const getDisplayValue = val => {
10428
+ if (!val) return '';
10429
+ if (val.includes(' - ')) return val; // already DD/MM/YYYY - DD/MM/YYYY
10430
+ const parts = val.split('-');
10431
+ if (parts.length !== 2) return val;
10432
+ const start = moment(parts[0].trim(), 'MM/DD/YYYY', true);
10433
+ const end = moment(parts[1].trim(), 'MM/DD/YYYY', true);
10434
+ if (!start.isValid() || !end.isValid()) return val;
10435
+ return `${start.format('DD/MM/YYYY')} - ${end.format('DD/MM/YYYY')}`;
10436
+ };
10403
10437
  const onChangeDate = (startDate, endDate) => {
10404
10438
  if (startDate && endDate) {
10405
10439
  setIsOpen(!isOpen);
10406
10440
  setIsFocused(false);
10407
10441
  setStartDateValue(startDate);
10408
10442
  setEndDateValue(endDate);
10409
- onChange(`${moment(startDate).format('MM/DD/YYYY')} - ${moment(endDate).format('MM/DD/YYYY')}`);
10410
- setValue(`${moment(startDate).format('MM/DD/YYYY')} - ${moment(endDate).format('MM/DD/YYYY')}`);
10443
+ onChange(`${moment(startDate).format('MM/DD/YYYY')}-${moment(endDate).format('MM/DD/YYYY')}`);
10444
+ setValue(`${moment(startDate).format('MM/DD/YYYY')}-${moment(endDate).format('MM/DD/YYYY')}`);
10411
10445
  }
10412
10446
  };
10413
10447
  const onChangeEvent = e => {
@@ -10432,6 +10466,7 @@ const RangePicker = _ref => {
10432
10466
  };
10433
10467
  return /*#__PURE__*/React__default["default"].createElement(RangePickerContainer, {
10434
10468
  className: "RangePickerContainer",
10469
+ ref: containerRef,
10435
10470
  onClick: handleFocus,
10436
10471
  width: width,
10437
10472
  height: height
@@ -10442,22 +10477,19 @@ const RangePicker = _ref => {
10442
10477
  disabled: disabled,
10443
10478
  textColor: textColor,
10444
10479
  borderColor: borderColor,
10445
- borderColorFocus: borderColorFocus,
10446
- onMouseEnter: () => setHoverInputContainer(true),
10447
- onMouseLeave: () => setHoverInputContainer(false)
10480
+ borderColorFocus: borderColorFocus
10448
10481
  }, /*#__PURE__*/React__default["default"].createElement(StyledLabel$3, {
10449
10482
  className: "StyledLabel",
10450
10483
  onClick: handleFocus,
10451
10484
  isFocused: isFocused,
10452
- hasValue: value,
10485
+ hasValue: getDisplayValue(value),
10453
10486
  disabled: disabled,
10454
10487
  textColor: textColor,
10455
10488
  borderColor: borderColor,
10456
10489
  borderColorFocus: borderColorFocus
10457
10490
  }, label, required && /*#__PURE__*/React__default["default"].createElement(RequiredIndicator$3, null, "*")), /*#__PURE__*/React__default["default"].createElement(StyledInput$6, {
10458
10491
  className: "StyledInput",
10459
- ref: inputRef,
10460
- value: value,
10492
+ value: getDisplayValue(value),
10461
10493
  isFocused: isFocused,
10462
10494
  onChange: onChangeEvent,
10463
10495
  onFocus: handleFocus,
@@ -10480,9 +10512,7 @@ const RangePicker = _ref => {
10480
10512
  className: "Calendar",
10481
10513
  fill: calendarIconColor
10482
10514
  }))), /*#__PURE__*/React__default["default"].createElement(OptionsContainer$5, {
10483
- className: "OptionsContainer",
10484
- onMouseEnter: () => setHoverOptionsContainer(true),
10485
- onMouseLeave: () => setHoverOptionsContainer(false)
10515
+ className: "OptionsContainer"
10486
10516
  }, /*#__PURE__*/React__default["default"].createElement(DatePicker, {
10487
10517
  className: "DatePicker",
10488
10518
  isOpen: isOpen,