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.esm.js CHANGED
@@ -636,21 +636,41 @@ const ChervronLeftIcon = _ref => {
636
636
 
637
637
  const CalendarIcon = _ref => {
638
638
  let {
639
- clicked,
640
639
  width = "14",
641
640
  height = "14",
642
- fill = "#212121",
643
- color
641
+ color = "#212121"
644
642
  } = _ref;
645
643
  return /*#__PURE__*/React$1.createElement("svg", {
646
644
  width: width,
647
645
  height: height,
648
- viewBox: "0 0 11 12",
646
+ viewBox: "0 0 24 24",
649
647
  fill: "none",
650
- xmlns: "http://www.w3.org/2000/svg"
651
- }, /*#__PURE__*/React$1.createElement("path", {
652
- 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",
653
- fill: color || fill
648
+ stroke: color,
649
+ strokeWidth: "2",
650
+ strokeLinecap: "round",
651
+ strokeLinejoin: "round"
652
+ }, /*#__PURE__*/React$1.createElement("rect", {
653
+ x: "3",
654
+ y: "4",
655
+ width: "18",
656
+ height: "18",
657
+ rx: "2",
658
+ ry: "2"
659
+ }), /*#__PURE__*/React$1.createElement("line", {
660
+ x1: "16",
661
+ y1: "2",
662
+ x2: "16",
663
+ y2: "6"
664
+ }), /*#__PURE__*/React$1.createElement("line", {
665
+ x1: "8",
666
+ y1: "2",
667
+ x2: "8",
668
+ y2: "6"
669
+ }), /*#__PURE__*/React$1.createElement("line", {
670
+ x1: "3",
671
+ y1: "10",
672
+ x2: "21",
673
+ y2: "10"
654
674
  }));
655
675
  };
656
676
 
@@ -9015,28 +9035,27 @@ const IconContainer$5 = styled.div`
9015
9035
  cursor: pointer;
9016
9036
  `;
9017
9037
 
9018
- const DropdownSingleNew = _ref => {
9019
- let {
9020
- label,
9021
- labelEmptyValue,
9022
- options,
9023
- selectedValue,
9024
- onChange,
9025
- required,
9026
- disabled,
9027
- width,
9028
- height,
9029
- minHeight,
9030
- withMarginBottom = true,
9031
- error,
9032
- errorMessage,
9033
- xIconShow,
9034
- labelColor,
9035
- showLabelOnTop,
9036
- orderBy,
9037
- placeHolder = "",
9038
- elementType
9039
- } = _ref;
9038
+ const DropdownSingleNew = ({
9039
+ label,
9040
+ labelEmptyValue,
9041
+ options,
9042
+ selectedValue,
9043
+ onChange,
9044
+ required,
9045
+ disabled,
9046
+ width,
9047
+ height,
9048
+ minHeight,
9049
+ withMarginBottom = true,
9050
+ error,
9051
+ errorMessage,
9052
+ xIconShow,
9053
+ labelColor,
9054
+ showLabelOnTop,
9055
+ orderBy,
9056
+ placeHolder = "",
9057
+ elementType
9058
+ }) => {
9040
9059
  const [isFocused, setIsFocused] = useState(false);
9041
9060
  const [showOptions, setShowOptions] = useState(false);
9042
9061
  const [showAbove, setShowAbove] = useState(false);
@@ -9571,29 +9590,28 @@ const IconContainer$4 = styled.div`
9571
9590
  cursor: pointer;
9572
9591
  `;
9573
9592
 
9574
- const DropdownMultiNew = _ref => {
9575
- let {
9576
- label,
9577
- labelEmptyValue,
9578
- options,
9579
- selectedValue,
9580
- onChange,
9581
- required,
9582
- disabled,
9583
- width,
9584
- height,
9585
- minHeight,
9586
- withMarginBottom = true,
9587
- error,
9588
- errorMessage,
9589
- labelColor,
9590
- xIconShow,
9591
- checkBoxColor,
9592
- showLabelOnTop,
9593
- orderBy,
9594
- elementType,
9595
- showSelectAll = false
9596
- } = _ref;
9593
+ const DropdownMultiNew = ({
9594
+ label,
9595
+ labelEmptyValue,
9596
+ options,
9597
+ selectedValue,
9598
+ onChange,
9599
+ required,
9600
+ disabled,
9601
+ width,
9602
+ height,
9603
+ minHeight,
9604
+ withMarginBottom = true,
9605
+ error,
9606
+ errorMessage,
9607
+ labelColor,
9608
+ xIconShow,
9609
+ checkBoxColor,
9610
+ showLabelOnTop,
9611
+ orderBy,
9612
+ elementType,
9613
+ showSelectAll = false
9614
+ }) => {
9597
9615
  const [isFocused, setIsFocused] = useState(false);
9598
9616
  const [showOptions, setShowOptions] = useState(false);
9599
9617
  const [showAbove, setShowAbove] = useState(false);
@@ -10240,9 +10258,12 @@ const DatePicker = ({
10240
10258
  if (value === '' || value === undefined) {
10241
10259
  setStartDate(null);
10242
10260
  setEndDate(null);
10261
+ setCurrentStartDate(new Date());
10243
10262
  } else {
10244
- setStartDate(new Date(startDateValue));
10263
+ const parsedStart = new Date(startDateValue);
10264
+ setStartDate(parsedStart);
10245
10265
  setEndDate(new Date(endDateValue));
10266
+ setCurrentStartDate(parsedStart);
10246
10267
  }
10247
10268
  }, [value, isOpen]);
10248
10269
  const renderDatePicker = () => {
@@ -10356,48 +10377,61 @@ const RangePicker = _ref => {
10356
10377
  const [startDateValue, setStartDateValue] = useState(null); // Added value state
10357
10378
  const [endDateValue, setEndDateValue] = useState(null); // Added value state
10358
10379
 
10359
- const [hoverInputContainer, setHoverInputContainer] = useState(false);
10360
- const [hoverOptionsContainer, setHoverOptionsContainer] = useState(false);
10361
- const inputRef = useRef(null);
10380
+ const containerRef = useRef(null);
10362
10381
  useEffect(() => {
10363
10382
  const handleClickOutside = event => {
10364
- if (inputRef.current && !inputRef.current.contains(event.target)) {
10383
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
10365
10384
  setIsFocused(false);
10385
+ setIsOpen(false);
10366
10386
  }
10367
10387
  };
10368
-
10369
- // Add event listener for clicks on the document
10370
10388
  document.addEventListener('mousedown', handleClickOutside);
10371
-
10372
- // Cleanup event listener on component unmount
10373
10389
  return () => {
10374
10390
  document.removeEventListener('mousedown', handleClickOutside);
10375
10391
  };
10376
10392
  }, []);
10377
10393
  useEffect(() => {
10378
- if (selectedValue && selectedValue.includes('-')) {
10379
- const dateArray = selectedValue.split('-');
10380
- const startDate = new Date(dateArray[0]);
10381
- const endDate = new Date(dateArray[1]);
10394
+ if (!selectedValue) return;
10395
+ if (selectedValue.includes(' - ')) {
10396
+ // DD/MM/YYYY - DD/MM/YYYY format
10397
+ const parts = selectedValue.split(' - ');
10398
+ if (parts.length !== 2) return;
10399
+ const startDate = moment(parts[0].trim(), 'DD/MM/YYYY', true);
10400
+ const endDate = moment(parts[1].trim(), 'DD/MM/YYYY', true);
10401
+ if (!startDate.isValid() || !endDate.isValid()) return;
10402
+ setStartDateValue(startDate.format('MM/DD/YYYY'));
10403
+ setEndDateValue(endDate.format('MM/DD/YYYY'));
10404
+ setValue(selectedValue);
10405
+ } else if (selectedValue.includes('-')) {
10406
+ // MM/DD/YYYY-MM/DD/YYYY format
10407
+ const parts = selectedValue.split('-');
10408
+ if (parts.length !== 2) return;
10409
+ const startDate = new Date(parts[0].trim());
10410
+ const endDate = new Date(parts[1].trim());
10411
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) return;
10382
10412
  setStartDateValue(moment(startDate).format('MM/DD/YYYY'));
10383
10413
  setEndDateValue(moment(endDate).format('MM/DD/YYYY'));
10384
10414
  setValue(selectedValue);
10385
10415
  }
10386
10416
  }, [selectedValue]);
10387
- useEffect(() => {
10388
- if (!hoverInputContainer && !hoverOptionsContainer) {
10389
- setIsFocused(false);
10390
- setIsOpen(false);
10391
- }
10392
- }, [hoverInputContainer, hoverOptionsContainer]);
10417
+ const getDisplayValue = val => {
10418
+ if (!val) return '';
10419
+ if (val.includes(' - ')) return val; // already DD/MM/YYYY - DD/MM/YYYY
10420
+ const parts = val.split('-');
10421
+ if (parts.length !== 2) return val;
10422
+ const start = moment(parts[0].trim(), 'MM/DD/YYYY', true);
10423
+ const end = moment(parts[1].trim(), 'MM/DD/YYYY', true);
10424
+ if (!start.isValid() || !end.isValid()) return val;
10425
+ return `${start.format('DD/MM/YYYY')} - ${end.format('DD/MM/YYYY')}`;
10426
+ };
10393
10427
  const onChangeDate = (startDate, endDate) => {
10394
10428
  if (startDate && endDate) {
10395
10429
  setIsOpen(!isOpen);
10396
10430
  setIsFocused(false);
10397
10431
  setStartDateValue(startDate);
10398
10432
  setEndDateValue(endDate);
10399
- onChange(`${moment(startDate).format('MM/DD/YYYY')} - ${moment(endDate).format('MM/DD/YYYY')}`);
10400
- setValue(`${moment(startDate).format('MM/DD/YYYY')} - ${moment(endDate).format('MM/DD/YYYY')}`);
10433
+ onChange(`${moment(startDate).format('MM/DD/YYYY')}-${moment(endDate).format('MM/DD/YYYY')}`);
10434
+ setValue(`${moment(startDate).format('MM/DD/YYYY')}-${moment(endDate).format('MM/DD/YYYY')}`);
10401
10435
  }
10402
10436
  };
10403
10437
  const onChangeEvent = e => {
@@ -10422,6 +10456,7 @@ const RangePicker = _ref => {
10422
10456
  };
10423
10457
  return /*#__PURE__*/React$1.createElement(RangePickerContainer, {
10424
10458
  className: "RangePickerContainer",
10459
+ ref: containerRef,
10425
10460
  onClick: handleFocus,
10426
10461
  width: width,
10427
10462
  height: height
@@ -10432,22 +10467,19 @@ const RangePicker = _ref => {
10432
10467
  disabled: disabled,
10433
10468
  textColor: textColor,
10434
10469
  borderColor: borderColor,
10435
- borderColorFocus: borderColorFocus,
10436
- onMouseEnter: () => setHoverInputContainer(true),
10437
- onMouseLeave: () => setHoverInputContainer(false)
10470
+ borderColorFocus: borderColorFocus
10438
10471
  }, /*#__PURE__*/React$1.createElement(StyledLabel$3, {
10439
10472
  className: "StyledLabel",
10440
10473
  onClick: handleFocus,
10441
10474
  isFocused: isFocused,
10442
- hasValue: value,
10475
+ hasValue: getDisplayValue(value),
10443
10476
  disabled: disabled,
10444
10477
  textColor: textColor,
10445
10478
  borderColor: borderColor,
10446
10479
  borderColorFocus: borderColorFocus
10447
10480
  }, label, required && /*#__PURE__*/React$1.createElement(RequiredIndicator$3, null, "*")), /*#__PURE__*/React$1.createElement(StyledInput$6, {
10448
10481
  className: "StyledInput",
10449
- ref: inputRef,
10450
- value: value,
10482
+ value: getDisplayValue(value),
10451
10483
  isFocused: isFocused,
10452
10484
  onChange: onChangeEvent,
10453
10485
  onFocus: handleFocus,
@@ -10470,9 +10502,7 @@ const RangePicker = _ref => {
10470
10502
  className: "Calendar",
10471
10503
  fill: calendarIconColor
10472
10504
  }))), /*#__PURE__*/React$1.createElement(OptionsContainer$5, {
10473
- className: "OptionsContainer",
10474
- onMouseEnter: () => setHoverOptionsContainer(true),
10475
- onMouseLeave: () => setHoverOptionsContainer(false)
10505
+ className: "OptionsContainer"
10476
10506
  }, /*#__PURE__*/React$1.createElement(DatePicker, {
10477
10507
  className: "DatePicker",
10478
10508
  isOpen: isOpen,