@ssa-ui-kit/core 2.28.1 → 2.28.2

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
@@ -1480,7 +1480,22 @@ const Wrapper = /*#__PURE__*/base_default()("div", true ? {
1480
1480
  alignItems
1481
1481
  }) => alignItems ? alignItems : 'center', ";width:100%;flex-direction:", ({
1482
1482
  direction
1483
- }) => direction ? direction : 'row', ";" + ( true ? "" : 0));
1483
+ }) => direction ? direction : 'row', ";", ({
1484
+ fade,
1485
+ fadeDelay = 0.3
1486
+ }) => fade && `
1487
+ opacity: 0;
1488
+ animation: fadeInOut ${fadeDelay}s ease-in-out forwards;
1489
+
1490
+ @keyframes fadeInOut {
1491
+ 0% {
1492
+ opacity: 0;
1493
+ }
1494
+ 100% {
1495
+ opacity: 1;
1496
+ }
1497
+ }
1498
+ `, ";" + ( true ? "" : 0));
1484
1499
  /* harmony default export */ const Wrapper_Wrapper = (Wrapper);
1485
1500
  ;// ./src/components/Button/ButtonBase.tsx
1486
1501
 
@@ -14014,13 +14029,89 @@ const DatePicker = /*#__PURE__*/(0,external_react_namespaceObject.forwardRef)(Da
14014
14029
 
14015
14030
  ;// ./src/components/DateRangePicker/constants.ts
14016
14031
  const constants_DEFAULT_MASK_FORMAT = 'mm/dd/yyyy';
14032
+ const DEFAULT_MONTH_MASK_FORMAT = 'mm/yyyy';
14033
+ const DEFAULT_YEAR_MASK_FORMAT = 'yyyy';
14017
14034
  const constants_DEFAULT_MASK = '__/__/____';
14035
+ const DEFAULT_MONTH_MASK = '__/____';
14036
+ const DEFAULT_YEAR_MASK = '____';
14018
14037
  const constants_MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
14019
14038
  const constants_DATE_MIN = '01/01/1900';
14020
14039
  const constants_DATE_MAX = '01/01/2150';
14040
+ const MONTH_DATE_MIN = '01/1900';
14041
+ const MONTH_DATE_MAX = '01/2150';
14042
+ const YEAR_DATE_MIN = '1900';
14043
+ const YEAR_DATE_MAX = '2150';
14021
14044
  const constants_OUT_OF_RANGE = 'The date is out of the defined range';
14022
14045
  const constants_INVALID_DATE = 'Invalid date';
14023
14046
  const FULL_DATE_LENGTH = 10;
14047
+ const FULL_MONTH_DATE_LENGTH = 7;
14048
+ const FULL_YEAR_DATE_LENGTH = 4;
14049
+ ;// ./src/components/DateRangePicker/utils/format.ts
14050
+
14051
+ const isMonthOnlyFormat = format => {
14052
+ if (!format) return false;
14053
+ const lowerFormat = format.toLowerCase();
14054
+ const hasMonth = lowerFormat.includes('mm');
14055
+ const hasYear = lowerFormat.includes('yyyy');
14056
+ const hasDay = lowerFormat.includes('dd');
14057
+ return hasMonth && hasYear && !hasDay;
14058
+ };
14059
+ const isYearOnlyFormat = format => {
14060
+ if (!format) return false;
14061
+ const lowerFormat = format.toLowerCase();
14062
+ const hasYear = lowerFormat.includes('yyyy');
14063
+ const hasMonth = lowerFormat.includes('mm');
14064
+ const hasDay = lowerFormat.includes('dd');
14065
+ return hasYear && !hasMonth && !hasDay;
14066
+ };
14067
+ const getExpectedDateLength = format => {
14068
+ if (!format) return FULL_DATE_LENGTH;
14069
+ if (isYearOnlyFormat(format)) {
14070
+ return FULL_YEAR_DATE_LENGTH;
14071
+ }
14072
+ if (isMonthOnlyFormat(format)) {
14073
+ return FULL_MONTH_DATE_LENGTH;
14074
+ }
14075
+ return FULL_DATE_LENGTH;
14076
+ };
14077
+ const getMaskForFormat = format => {
14078
+ if (isYearOnlyFormat(format)) {
14079
+ return DEFAULT_YEAR_MASK;
14080
+ }
14081
+ if (isMonthOnlyFormat(format)) {
14082
+ return DEFAULT_MONTH_MASK;
14083
+ }
14084
+ return constants_DEFAULT_MASK;
14085
+ };
14086
+ const getDefaultDateRange = format => {
14087
+ if (isYearOnlyFormat(format)) {
14088
+ return {
14089
+ defaultMin: YEAR_DATE_MIN,
14090
+ defaultMax: YEAR_DATE_MAX
14091
+ };
14092
+ }
14093
+ if (isMonthOnlyFormat(format)) {
14094
+ return {
14095
+ defaultMin: MONTH_DATE_MIN,
14096
+ defaultMax: MONTH_DATE_MAX
14097
+ };
14098
+ }
14099
+ return {
14100
+ defaultMin: constants_DATE_MIN,
14101
+ defaultMax: constants_DATE_MAX
14102
+ };
14103
+ };
14104
+ const getFormatForRangePickerType = rangePickerType => {
14105
+ switch (rangePickerType) {
14106
+ case 'years':
14107
+ return DEFAULT_YEAR_MASK_FORMAT;
14108
+ case 'months':
14109
+ return DEFAULT_MONTH_MASK_FORMAT;
14110
+ case 'days':
14111
+ default:
14112
+ return constants_DEFAULT_MASK_FORMAT;
14113
+ }
14114
+ };
14024
14115
  ;// ./src/components/DateRangePicker/components/DatesListWrapper.tsx
14025
14116
 
14026
14117
 
@@ -14093,8 +14184,9 @@ const styles_YearsViewCell = /*#__PURE__*/base_default()("div", true ? {
14093
14184
  }) => isCalendarYear || isCalendarFirstDateSelected || isCalendarSecondDateSelected ? `linear-gradient(247.37deg, ${theme.colors.blueLighter} 14.71%, ${theme.colors.blue} 85.29%)` : 'none', ";background:", ({
14094
14185
  theme,
14095
14186
  isHighlighted,
14096
- isCalendarYear
14097
- }) => isHighlighted && !isCalendarYear && theme.colors.blueRoyal16, ";&:hover{background:", ({
14187
+ isCalendarYear,
14188
+ isCalendarSecondDateSelected
14189
+ }) => isHighlighted && !isCalendarYear && !isCalendarSecondDateSelected && theme.colors.blueRoyal16, ";&:hover{background:", ({
14098
14190
  theme
14099
14191
  }) => theme.colors.greyLighter, ";color:", ({
14100
14192
  theme
@@ -14115,24 +14207,21 @@ const styles_MonthsViewCell = /*#__PURE__*/base_default()("div", true ? {
14115
14207
  isCalendarSecondDateSelected
14116
14208
  }) => isCalendarFirstDateSelected || isCalendarSecondDateSelected ? '6px' : 0, ";font-size:14px;font-weight:500;cursor:pointer;color:", ({
14117
14209
  theme,
14118
- isCalendarMonth,
14119
14210
  isCalendarFirstDateSelected,
14120
14211
  isCalendarSecondDateSelected
14121
- }) => (isCalendarMonth || isCalendarFirstDateSelected || isCalendarSecondDateSelected) && theme.colors.white, ";user-select:none;background:", ({
14212
+ }) => (isCalendarFirstDateSelected || isCalendarSecondDateSelected) && theme.colors.white, ";user-select:none;background:", ({
14122
14213
  theme,
14123
- isCalendarMonth,
14124
14214
  isCalendarFirstDateSelected,
14125
14215
  isCalendarSecondDateSelected
14126
- }) => isCalendarMonth || isCalendarFirstDateSelected || isCalendarSecondDateSelected ? `linear-gradient(247.37deg, ${theme.colors.blueLighter} 14.71%, ${theme.colors.blue} 85.29%)` : 'none', ";&[aria-disabled='true']{cursor:default;pointer-events:none;color:", ({
14216
+ }) => isCalendarFirstDateSelected || isCalendarSecondDateSelected ? `linear-gradient(247.37deg, ${theme.colors.blueLighter} 14.71%, ${theme.colors.blue} 85.29%)` : 'none', ";&[aria-disabled='true']{cursor:default;pointer-events:none;color:", ({
14127
14217
  theme
14128
14218
  }) => theme.colors.greyDarker, ";background:", ({
14129
14219
  theme
14130
14220
  }) => theme.colors.grey, ";}&[aria-disabled='false']{background:", ({
14131
14221
  theme,
14132
14222
  isHighlighted,
14133
- isCalendarMonth,
14134
14223
  isCalendarSecondDateSelected
14135
- }) => isHighlighted && !isCalendarMonth && !isCalendarSecondDateSelected && theme.colors.blueRoyal16, ";&:hover{background:", ({
14224
+ }) => isHighlighted && !isCalendarSecondDateSelected && theme.colors.blueRoyal16, ";&:hover{background:", ({
14136
14225
  theme
14137
14226
  }) => theme.colors.greyLighter, ";color:", ({
14138
14227
  theme
@@ -14487,9 +14576,12 @@ const MonthsView_MonthsView = () => {
14487
14576
  dateMaxDT,
14488
14577
  lastFocusedElement,
14489
14578
  currentCalendarViewDT,
14579
+ rangePickerType,
14490
14580
  setCalendarType,
14491
14581
  setCalendarViewDateTime,
14492
- onMonthChange
14582
+ onMonthChange,
14583
+ setDateTime,
14584
+ setIsOpen
14493
14585
  } = useDateRangePickerContext();
14494
14586
  const {
14495
14587
  handleDateHover,
@@ -14507,20 +14599,34 @@ const MonthsView_MonthsView = () => {
14507
14599
  }
14508
14600
  const selectedMonth = target.innerHTML;
14509
14601
  const monthNumber = constants_MONTHS.findIndex(month => month === selectedMonth);
14510
- const newDate = currentCalendarViewDT?.set({
14511
- month: monthNumber + 1
14512
- });
14513
- setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, calendarViewDateTime[1]] : [calendarViewDateTime[0], newDate]);
14514
- if (newDate) {
14515
- onMonthChange?.(newDate.toJSDate());
14602
+ if (rangePickerType === 'days') {
14603
+ const newDate = currentCalendarViewDT?.set({
14604
+ month: monthNumber + 1
14605
+ });
14606
+ setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, calendarViewDateTime[1]] : [calendarViewDateTime[0], newDate]);
14607
+ if (newDate) {
14608
+ onMonthChange?.(newDate.toJSDate());
14609
+ }
14610
+ setCalendarType('days');
14611
+ } else {
14612
+ const newMonth = currentCalendarViewDT?.set({
14613
+ month: monthNumber + 1
14614
+ });
14615
+ const newDate = newMonth?.set({
14616
+ day: lastFocusedElement === 'from' ? 1 : newMonth.daysInMonth
14617
+ });
14618
+ const newDateTuple = lastFocusedElement === 'from' ? [newDate, dateTime[1]] : [dateTime[0], newDate];
14619
+ setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, dateTime[1] ? calendarViewDateTime?.[1] : newDate] : [dateTime[0] ? calendarViewDateTime?.[0] : newDate, newDate]);
14620
+ setDateTime(newDateTuple);
14621
+ if (newDateTuple[0] && newDateTuple[1]) {
14622
+ setIsOpen(false);
14623
+ }
14516
14624
  }
14517
- setCalendarType('days');
14518
14625
  };
14519
14626
  return (0,jsx_runtime_namespaceObject.jsx)(DatesListWrapper, {
14520
14627
  css: components_MonthsView_ref,
14521
14628
  onClick: handleMonthSelect,
14522
14629
  children: constants_MONTHS.map((month, index) => {
14523
- const isCalendarMonth = currentCalendarViewDT ? currentCalendarViewDT.month === index + 1 : false;
14524
14630
  const currentMonthDT = external_luxon_namespaceObject.DateTime.fromObject({
14525
14631
  year: currentCalendarViewDT?.year,
14526
14632
  month: index + 1,
@@ -14536,7 +14642,6 @@ const MonthsView_MonthsView = () => {
14536
14642
  isCalendarSecondDateSelected
14537
14643
  });
14538
14644
  return (0,jsx_runtime_namespaceObject.jsx)(styles_MonthsViewCell, {
14539
- isCalendarMonth: isCalendarMonth,
14540
14645
  "aria-disabled": isAriaDisabled,
14541
14646
  "aria-label": `${month}, ${currentCalendarViewDT?.year}`,
14542
14647
  isCalendarFirstDateSelected: isCalendarFirstDateSelected,
@@ -14566,6 +14671,7 @@ var components_YearsView_ref = true ? {
14566
14671
  } : 0;
14567
14672
  const YearsView_YearsView = () => {
14568
14673
  const {
14674
+ rangePickerType,
14569
14675
  dateTime,
14570
14676
  calendarViewDateTime,
14571
14677
  currentCalendarViewDT,
@@ -14575,7 +14681,9 @@ const YearsView_YearsView = () => {
14575
14681
  lastFocusedElement,
14576
14682
  setCalendarType,
14577
14683
  setCalendarViewDateTime,
14578
- onYearChange
14684
+ onYearChange,
14685
+ setDateTime,
14686
+ setIsOpen
14579
14687
  } = useDateRangePickerContext();
14580
14688
  const wrapper = (0,external_react_namespaceObject.useRef)(null);
14581
14689
  const yearsList = dates_getYearsList({
@@ -14600,13 +14708,32 @@ const YearsView_YearsView = () => {
14600
14708
  target
14601
14709
  } = event;
14602
14710
  const selectedYear = Number(target.innerHTML);
14603
- const newDate = currentCalendarViewDT.set({
14604
- year: selectedYear
14605
- });
14606
- setCalendarType('months');
14607
- setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, calendarViewDateTime[1]] : [calendarViewDateTime[0], newDate]);
14608
- if (newDate) {
14609
- onYearChange?.(newDate.toJSDate());
14711
+ if (rangePickerType !== 'years') {
14712
+ const newDate = currentCalendarViewDT.set({
14713
+ year: selectedYear
14714
+ });
14715
+ setCalendarType('months');
14716
+ setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, calendarViewDateTime[1]] : [calendarViewDateTime[0], newDate]);
14717
+ if (newDate) {
14718
+ onYearChange?.(newDate.toJSDate());
14719
+ }
14720
+ } else {
14721
+ const newYear = currentCalendarViewDT?.set({
14722
+ year: selectedYear
14723
+ });
14724
+ const newDate = newYear?.set(lastFocusedElement === 'from' ? {
14725
+ day: 1,
14726
+ month: 1
14727
+ } : {
14728
+ day: 31,
14729
+ month: 12
14730
+ });
14731
+ const newDateTuple = lastFocusedElement === 'from' ? [newDate, dateTime[1]] : [dateTime[0], newDate];
14732
+ setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, dateTime[1] ? calendarViewDateTime?.[1] : newDate] : [dateTime[0] ? calendarViewDateTime?.[0] : newDate, newDate]);
14733
+ setDateTime(newDateTuple);
14734
+ if (newDateTuple[0] && newDateTuple[1]) {
14735
+ setIsOpen(false);
14736
+ }
14610
14737
  }
14611
14738
  };
14612
14739
  return (0,jsx_runtime_namespaceObject.jsx)(DatesListWrapper, {
@@ -14644,20 +14771,21 @@ const YearsView_YearsView = () => {
14644
14771
  })
14645
14772
  });
14646
14773
  };
14647
- ;// ./src/components/DateRangePicker/components/MonthsSwitch.tsx
14774
+ ;// ./src/components/DateRangePicker/components/YearsMonthsSwitch.tsx
14648
14775
 
14649
- function MonthsSwitch_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
14776
+ function YearsMonthsSwitch_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
14650
14777
 
14651
14778
 
14652
14779
 
14653
14780
 
14654
14781
 
14655
- var MonthsSwitch_ref = true ? {
14782
+ var YearsMonthsSwitch_ref = true ? {
14656
14783
  name: "9cmux7",
14657
14784
  styles: "width:72px;gap:24px"
14658
14785
  } : 0;
14659
- const MonthsSwitch = () => {
14786
+ const YearsMonthsSwitch = () => {
14660
14787
  const {
14788
+ rangePickerType = 'days',
14661
14789
  calendarType,
14662
14790
  calendarViewDateTime,
14663
14791
  dateMinDT,
@@ -14674,40 +14802,44 @@ const MonthsSwitch = () => {
14674
14802
  });
14675
14803
  const isMinMonthReached = calendarViewDateTime ? currentCalendarViewDT?.month === dateMinDT.month && currentCalendarViewDT.year === dateMinDT.year : false;
14676
14804
  const isMaxMonthReached = calendarViewDateTime ? currentCalendarViewDT?.month === dateMaxDT.month && currentCalendarViewDT.year === dateMaxDT.year : false;
14677
- const handlePreviousMonth = () => {
14678
- const newDate = currentCalendarViewDT?.minus({
14805
+ const handlePrevious = () => {
14806
+ const newDate = currentCalendarViewDT?.minus(isDayCalendarType ? {
14679
14807
  month: 1
14808
+ } : {
14809
+ year: 1
14680
14810
  });
14681
14811
  setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, calendarViewDateTime[1]] : [calendarViewDateTime[0], newDate]);
14682
14812
  if (newDate) {
14683
14813
  onMonthChange?.(newDate.toJSDate());
14684
14814
  }
14685
14815
  };
14686
- const handleNextMonth = () => {
14687
- const newDate = currentCalendarViewDT?.plus({
14816
+ const handleNext = () => {
14817
+ const newDate = currentCalendarViewDT?.plus(isDayCalendarType ? {
14688
14818
  month: 1
14819
+ } : {
14820
+ year: 1
14689
14821
  });
14690
14822
  setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, calendarViewDateTime[1]] : [calendarViewDateTime[0], newDate]);
14691
14823
  if (newDate) {
14692
14824
  onMonthChange?.(newDate.toJSDate());
14693
14825
  }
14694
14826
  };
14695
- if (!isDayCalendarType) {
14827
+ if (rangePickerType === 'days' && calendarType !== 'days' || rangePickerType === 'months' && calendarType !== 'months' || rangePickerType === 'years') {
14696
14828
  return null;
14697
14829
  }
14698
14830
  return (0,jsx_runtime_namespaceObject.jsxs)(Wrapper_Wrapper, {
14699
- css: MonthsSwitch_ref,
14831
+ css: YearsMonthsSwitch_ref,
14700
14832
  children: [(0,jsx_runtime_namespaceObject.jsx)(Button_Button, {
14701
14833
  endIcon: (0,jsx_runtime_namespaceObject.jsx)(Icon_Icon, {
14702
14834
  name: "carrot-left",
14703
14835
  size: 14,
14704
- tooltip: "Previous month",
14836
+ tooltip: `Previous ${rangePickerType === 'days' ? 'month' : 'year'}`,
14705
14837
  color: isMinMonthReached ? theme.colors.grey : theme.colors.greyDarker
14706
14838
  }),
14707
14839
  variant: 'tertiary',
14708
- "aria-label": "Previous month",
14709
- "data-testid": "previous-month",
14710
- onClick: handlePreviousMonth,
14840
+ "aria-label": `Previous ${rangePickerType === 'days' ? 'month' : 'year'}`,
14841
+ "data-testid": "previous-year-month",
14842
+ onClick: handlePrevious,
14711
14843
  isDisabled: isMinMonthReached,
14712
14844
  css: /*#__PURE__*/(0,react_namespaceObject.css)({
14713
14845
  padding: 4,
@@ -14721,14 +14853,14 @@ const MonthsSwitch = () => {
14721
14853
  endIcon: (0,jsx_runtime_namespaceObject.jsx)(Icon_Icon, {
14722
14854
  name: "carrot-right",
14723
14855
  size: 14,
14724
- tooltip: "Next month",
14856
+ tooltip: `Next ${rangePickerType === 'days' ? 'month' : 'year'}`,
14725
14857
  color: isMaxMonthReached ? theme.colors.grey : theme.colors.greyDarker
14726
14858
  }),
14727
14859
  variant: 'tertiary',
14728
- onClick: handleNextMonth,
14860
+ onClick: handleNext,
14729
14861
  isDisabled: isMaxMonthReached,
14730
- "aria-label": "Next month",
14731
- "data-testid": "next-month",
14862
+ "aria-label": `Next ${rangePickerType === 'days' ? 'month' : 'year'}`,
14863
+ "data-testid": "next-year-month",
14732
14864
  css: /*#__PURE__*/(0,react_namespaceObject.css)({
14733
14865
  padding: 4,
14734
14866
  height: 32,
@@ -14756,28 +14888,29 @@ var Header_ref2 = true ? {
14756
14888
  } : 0;
14757
14889
  const Header_Header = () => {
14758
14890
  const {
14891
+ rangePickerType,
14759
14892
  calendarType,
14760
14893
  currentCalendarViewDT,
14761
14894
  setCalendarType
14762
14895
  } = useDateRangePickerContext();
14763
14896
  const handleCalendarTypeChange = () => {
14764
- setCalendarType(calendarType === 'days' ? 'years' : 'days');
14897
+ setCalendarType(calendarType === 'days' || calendarType === 'months' ? 'years' : rangePickerType ?? 'days');
14765
14898
  };
14766
14899
  return (0,jsx_runtime_namespaceObject.jsxs)(PopoverHeading, {
14767
14900
  css: components_Header_ref,
14768
14901
  as: 'div',
14769
14902
  children: [(0,jsx_runtime_namespaceObject.jsx)(Button_Button, {
14770
- endIcon: (0,jsx_runtime_namespaceObject.jsx)(Icon_Icon, {
14771
- name: calendarType === 'days' ? 'carrot-down' : 'carrot-up',
14903
+ endIcon: rangePickerType !== 'years' ? (0,jsx_runtime_namespaceObject.jsx)(Icon_Icon, {
14904
+ name: calendarType === 'days' || calendarType === 'months' ? 'carrot-down' : 'carrot-up',
14772
14905
  size: 14,
14773
14906
  tooltip: ""
14774
- }),
14907
+ }) : null,
14775
14908
  variant: "tertiary",
14776
14909
  onClick: handleCalendarTypeChange,
14777
14910
  "data-testid": "calendar-type-change-button",
14778
14911
  css: Header_ref2,
14779
- children: currentCalendarViewDT.toFormat('LLLL yyyy')
14780
- }), (0,jsx_runtime_namespaceObject.jsx)(MonthsSwitch, {})]
14912
+ children: currentCalendarViewDT.toFormat(rangePickerType === 'days' ? 'LLLL yyyy' : 'yyyy')
14913
+ }), (0,jsx_runtime_namespaceObject.jsx)(YearsMonthsSwitch, {})]
14781
14914
  });
14782
14915
  };
14783
14916
  ;// ./src/components/DateRangePicker/components/Calendar.tsx
@@ -15258,7 +15391,6 @@ const Content_DatePickerContent = () => {
15258
15391
  ;// ./src/components/DateRangePicker/hooks/useDatePickerMask.tsx
15259
15392
 
15260
15393
 
15261
-
15262
15394
  const useDatePickerMask_useDatePickerMask = ({
15263
15395
  maskOptions,
15264
15396
  formatIndexes,
@@ -15266,7 +15398,7 @@ const useDatePickerMask_useDatePickerMask = ({
15266
15398
  dateMaxParts
15267
15399
  }) => {
15268
15400
  const {
15269
- mask = constants_DEFAULT_MASK,
15401
+ mask,
15270
15402
  replacement = {
15271
15403
  _: /\d/
15272
15404
  },
@@ -15281,7 +15413,8 @@ const useDatePickerMask_useDatePickerMask = ({
15281
15413
  selectionEnd,
15282
15414
  value: currentValue
15283
15415
  }) => {
15284
- if (mask === constants_DEFAULT_MASK) {
15416
+ const isDateMask = typeof mask === 'string' && /^[_/]+$/.test(mask);
15417
+ if (isDateMask) {
15285
15418
  const newValue = currentValue.slice(0, selectionStart) + data + currentValue.slice(selectionEnd);
15286
15419
  const updatedValue = (0,mask_namespaceObject.format)(newValue, {
15287
15420
  mask,
@@ -15309,22 +15442,32 @@ const useDatePickerMask_useDatePickerMask = ({
15309
15442
 
15310
15443
 
15311
15444
 
15445
+
15312
15446
  const useDateRangePicker = ({
15313
- dateMin = constants_DATE_MIN,
15314
- dateMax = constants_DATE_MAX,
15447
+ dateMin,
15448
+ dateMax,
15315
15449
  name: _name,
15316
- format = 'mm/dd/yyyy',
15450
+ format: propFormat,
15317
15451
  maskOptions,
15318
15452
  isOpenState = false,
15319
15453
  defaultValue,
15454
+ rangePickerType = 'days',
15320
15455
  onOpen,
15321
15456
  onClose,
15322
15457
  onError,
15323
15458
  onChange,
15324
15459
  ...rest
15325
15460
  }) => {
15461
+ const format = propFormat || getFormatForRangePickerType(rangePickerType);
15462
+ const {
15463
+ defaultMin,
15464
+ defaultMax
15465
+ } = getDefaultDateRange(format);
15466
+ const finalDateMin = dateMin || defaultMin;
15467
+ const finalDateMax = dateMax || defaultMax;
15326
15468
  const inputFromRef = (0,external_react_namespaceObject.useRef)(null);
15327
15469
  const inputToRef = (0,external_react_namespaceObject.useRef)(null);
15470
+ const previousRangePickerType = (0,external_react_namespaceObject.useRef)(rangePickerType);
15328
15471
  const [isOpen, setIsOpen] = (0,external_react_namespaceObject.useState)(isOpenState);
15329
15472
  const [status, setStatus] = (0,external_react_namespaceObject.useState)(rest.status);
15330
15473
  const previousOpenState = (0,external_react_namespaceObject.useRef)(isOpenState);
@@ -15362,16 +15505,21 @@ const useDateRangePicker = ({
15362
15505
  month: splittedFormat.findIndex(item => item === 'mm'),
15363
15506
  year: splittedFormat.findIndex(item => item === 'yyyy')
15364
15507
  });
15365
- const [calendarType, setCalendarType] = (0,external_react_namespaceObject.useState)('days');
15508
+ const [calendarType, setCalendarType] = (0,external_react_namespaceObject.useState)(rangePickerType);
15366
15509
  const [calendarViewDateTime, setCalendarViewDateTime] = (0,external_react_namespaceObject.useState)([undefined, undefined]);
15367
15510
  const currentCalendarViewDT = calendarViewDateTime[currentIndex] || external_luxon_namespaceObject.DateTime.now().set({
15368
15511
  day: 1
15369
15512
  });
15370
15513
  const luxonFormat = format.replace('mm', 'MM');
15371
- const dateMinParts = dateMin.split('/').map(Number);
15372
- const dateMaxParts = dateMax.split('/').map(Number);
15514
+ const expectedDateLength = getExpectedDateLength(format);
15515
+ const dateMinParts = finalDateMin.split('/').map(Number);
15516
+ const dateMaxParts = finalDateMax.split('/').map(Number);
15517
+ const defaultMask = getMaskForFormat(format);
15373
15518
  const maskInputRef = useDatePickerMask_useDatePickerMask({
15374
- maskOptions,
15519
+ maskOptions: {
15520
+ mask: defaultMask,
15521
+ ...maskOptions
15522
+ },
15375
15523
  dateMaxParts,
15376
15524
  dateMinParts,
15377
15525
  formatIndexes
@@ -15379,12 +15527,12 @@ const useDateRangePicker = ({
15379
15527
  const dateMaxDT = external_luxon_namespaceObject.DateTime.fromObject({
15380
15528
  year: dateMaxParts[formatIndexes['year']],
15381
15529
  month: dateMaxParts[formatIndexes['month']],
15382
- day: dateMaxParts[formatIndexes['day']]
15530
+ day: formatIndexes['day'] !== -1 ? dateMaxParts[formatIndexes['day']] : 1
15383
15531
  });
15384
15532
  const dateMinDT = external_luxon_namespaceObject.DateTime.fromObject({
15385
15533
  year: dateMinParts[formatIndexes['year']],
15386
15534
  month: dateMinParts[formatIndexes['month']],
15387
- day: dateMinParts[formatIndexes['day']]
15535
+ day: formatIndexes['day'] !== -1 ? dateMinParts[formatIndexes['day']] : 1
15388
15536
  });
15389
15537
  const safeOnChange = newDateTime => {
15390
15538
  const _newDateTime = newDateTime ? newDateTime.startOf('day') : undefined;
@@ -15420,7 +15568,7 @@ const useDateRangePicker = ({
15420
15568
  const processValue = (newValue, elementName) => {
15421
15569
  const currentElementType = elementName || lastFocusedElement;
15422
15570
  const currentName = currentElementType === 'from' ? nameFrom : nameTo;
15423
- const newDateTime = typeof newValue === 'string' && newValue.length === FULL_DATE_LENGTH ? external_luxon_namespaceObject.DateTime.fromFormat(newValue, luxonFormat) : undefined;
15571
+ const newDateTime = typeof newValue === 'string' && newValue.length === expectedDateLength ? external_luxon_namespaceObject.DateTime.fromFormat(newValue, luxonFormat) : undefined;
15424
15572
  const newDateTimeIfInvalid = [currentElementType === 'from' ? undefined : dateTime?.[0], currentElementType === 'to' ? undefined : dateTime?.[1]];
15425
15573
  const newDateTimeIfValid = [currentElementType === 'from' ? newDateTime : dateTime?.[0], currentElementType === 'to' ? newDateTime : dateTime?.[1]];
15426
15574
  if (!newDateTime?.isValid) {
@@ -15465,14 +15613,14 @@ const useDateRangePicker = ({
15465
15613
  const processInputValue = (inputValue, elementName) => {
15466
15614
  const currentElementType = elementName || lastFocusedElement;
15467
15615
  const currentName = currentElementType === 'from' ? nameFrom : nameTo;
15468
- if (typeof inputValue === 'string' && inputValue.length && inputValue.length < FULL_DATE_LENGTH) {
15616
+ if (typeof inputValue === 'string' && inputValue.length && inputValue.length < expectedDateLength) {
15469
15617
  setIsOpen(false);
15470
15618
  setTimeout(() => {
15471
15619
  maskInputRef.current.focus();
15472
15620
  }, 10);
15473
15621
  }
15474
15622
  let newDateTime;
15475
- if (typeof inputValue === 'string' && inputValue.length === FULL_DATE_LENGTH) {
15623
+ if (typeof inputValue === 'string' && inputValue.length === expectedDateLength) {
15476
15624
  newDateTime = external_luxon_namespaceObject.DateTime.fromFormat(inputValue, luxonFormat);
15477
15625
  setValue(currentName, inputValue);
15478
15626
  processValue(inputValue, elementName);
@@ -15506,16 +15654,19 @@ const useDateRangePicker = ({
15506
15654
  setCalendarViewDateTime(currentElementType === 'from' ? [newCalendarViewDateTime, calendarViewDateTime[1]] : [calendarViewDateTime[0], newCalendarViewDateTime]);
15507
15655
  }
15508
15656
  };
15657
+ (0,external_react_namespaceObject.useEffect)(() => {
15658
+ setCalendarType(rangePickerType);
15659
+ }, [rangePickerType]);
15509
15660
  (0,external_react_namespaceObject.useEffect)(() => {
15510
15661
  processInputValue(lastFocusedElement === 'from' ? inputValueFrom : inputValueTo);
15511
15662
  }, [lastFocusedElement]);
15512
15663
  (0,external_react_namespaceObject.useEffect)(() => {
15513
- if (inputValueFrom && inputValueFrom.length === FULL_DATE_LENGTH) {
15664
+ if (inputValueFrom && inputValueFrom.length === expectedDateLength) {
15514
15665
  processInputValue(lastFocusedElement === 'from' ? inputValueFrom : inputValueTo);
15515
15666
  }
15516
15667
  }, [inputValueFrom]);
15517
15668
  (0,external_react_namespaceObject.useEffect)(() => {
15518
- if (inputValueTo && inputValueTo.length === FULL_DATE_LENGTH) {
15669
+ if (inputValueTo && inputValueTo.length === expectedDateLength) {
15519
15670
  processInputValue(lastFocusedElement === 'from' ? inputValueFrom : inputValueTo);
15520
15671
  }
15521
15672
  }, [inputValueTo]);
@@ -15531,18 +15682,31 @@ const useDateRangePicker = ({
15531
15682
  }, [dateTime, lastFocusedElement, currentName]);
15532
15683
  (0,external_react_namespaceObject.useEffect)(() => {
15533
15684
  if (dateTime[0] && dateTime[1] && dateTime[0] > dateTime[1]) {
15534
- resetField(nameFrom);
15535
- resetField(nameTo);
15536
- setDateTime([dateTime[1], undefined]);
15537
- setLastChangedDate([dateTime[1].toJSDate(), undefined]);
15538
- setValue(nameFrom, dateTime[1].toFormat(luxonFormat));
15539
- setLastFocusedElement('to');
15540
- setTimeout(() => {
15541
- setFocus(nameTo, {
15542
- shouldSelect: true
15543
- });
15544
- }, 50);
15545
- setIsOpen(true);
15685
+ if (lastFocusedElement === 'from') {
15686
+ resetField(nameTo);
15687
+ setDateTime([dateTime[0], undefined]);
15688
+ setLastChangedDate([dateTime[0].toJSDate(), undefined]);
15689
+ setValue(nameTo, undefined);
15690
+ setLastFocusedElement('to');
15691
+ setTimeout(() => {
15692
+ setFocus(nameTo, {
15693
+ shouldSelect: true
15694
+ });
15695
+ }, 50);
15696
+ setIsOpen(true);
15697
+ } else {
15698
+ resetField(nameFrom);
15699
+ setDateTime([undefined, dateTime[1]]);
15700
+ setLastChangedDate([undefined, dateTime[1].toJSDate()]);
15701
+ setValue(nameFrom, undefined);
15702
+ setLastFocusedElement('from');
15703
+ setTimeout(() => {
15704
+ setFocus(nameFrom, {
15705
+ shouldSelect: true
15706
+ });
15707
+ }, 50);
15708
+ setIsOpen(true);
15709
+ }
15546
15710
  }
15547
15711
  }, [dateTime]);
15548
15712
  (0,external_react_namespaceObject.useEffect)(() => {
@@ -15551,7 +15715,7 @@ const useDateRangePicker = ({
15551
15715
  onOpen?.();
15552
15716
  } else {
15553
15717
  onClose?.();
15554
- setCalendarType('days');
15718
+ setCalendarType(rangePickerType);
15555
15719
  setCalendarViewDateTime([dateTime[0], dateTime[1]]);
15556
15720
  }
15557
15721
  previousOpenState.current = isOpen;
@@ -15565,10 +15729,24 @@ const useDateRangePicker = ({
15565
15729
  year: splittedFormat.findIndex(item => item === 'yyyy')
15566
15730
  });
15567
15731
  }, [format]);
15732
+ (0,external_react_namespaceObject.useEffect)(() => {
15733
+ if (previousRangePickerType.current !== rangePickerType) {
15734
+ if (dateTime[0] || dateTime[1]) {
15735
+ const newLuxonFormat = format.replace('mm', 'MM');
15736
+ if (dateTime[0]) {
15737
+ setValue(nameFrom, dateTime[0].toFormat(newLuxonFormat));
15738
+ }
15739
+ if (dateTime[1]) {
15740
+ setValue(nameTo, dateTime[1].toFormat(newLuxonFormat));
15741
+ }
15742
+ }
15743
+ previousRangePickerType.current = rangePickerType;
15744
+ }
15745
+ }, [rangePickerType, format, dateTime, nameFrom, nameTo, setValue]);
15568
15746
  (0,external_react_namespaceObject.useEffect)(() => {
15569
15747
  if (Array.isArray(rest.value)) {
15570
- const newDateTimeFrom = typeof rest.value[0] === 'string' && rest.value[0].length === FULL_DATE_LENGTH ? external_luxon_namespaceObject.DateTime.fromFormat(rest.value[0], luxonFormat) : undefined;
15571
- const newDateTimeTo = typeof rest.value[1] === 'string' && rest.value[1].length === FULL_DATE_LENGTH ? external_luxon_namespaceObject.DateTime.fromFormat(rest.value[1], luxonFormat) : undefined;
15748
+ const newDateTimeFrom = typeof rest.value[0] === 'string' && rest.value[0].length === expectedDateLength ? external_luxon_namespaceObject.DateTime.fromFormat(rest.value[0], luxonFormat) : undefined;
15749
+ const newDateTimeTo = typeof rest.value[1] === 'string' && rest.value[1].length === expectedDateLength ? external_luxon_namespaceObject.DateTime.fromFormat(rest.value[1], luxonFormat) : undefined;
15572
15750
  const newDateTime = [newDateTimeFrom?.isValid ? newDateTimeFrom : undefined, newDateTimeTo?.isValid ? newDateTimeTo : undefined];
15573
15751
  setDateTime(newDateTime);
15574
15752
  setLastChangedDate([newDateTime[0]?.toJSDate(), newDateTime[1]?.toJSDate()]);
@@ -15694,19 +15872,24 @@ const DateRangePickerProvider = ({
15694
15872
 
15695
15873
 
15696
15874
  const DateRangePicker = ({
15697
- format = constants_DEFAULT_MASK_FORMAT,
15875
+ format,
15698
15876
  openCalendarMode = 'icon',
15699
15877
  showCalendarIcon = true,
15700
15878
  showStatusArea = true,
15879
+ rangePickerType = 'days',
15701
15880
  ...rest
15702
- }) => (0,jsx_runtime_namespaceObject.jsx)(DateRangePickerProvider, {
15703
- format: format,
15704
- openCalendarMode: openCalendarMode,
15705
- showCalendarIcon: showCalendarIcon,
15706
- showStatusArea: showStatusArea,
15707
- ...rest,
15708
- children: (0,jsx_runtime_namespaceObject.jsx)(Content_DatePickerContent, {})
15709
- });
15881
+ }) => {
15882
+ const actualFormat = format || getFormatForRangePickerType(rangePickerType);
15883
+ return (0,jsx_runtime_namespaceObject.jsx)(DateRangePickerProvider, {
15884
+ format: actualFormat,
15885
+ openCalendarMode: openCalendarMode,
15886
+ showCalendarIcon: showCalendarIcon,
15887
+ showStatusArea: showStatusArea,
15888
+ rangePickerType: rangePickerType,
15889
+ ...rest,
15890
+ children: (0,jsx_runtime_namespaceObject.jsx)(Content_DatePickerContent, {})
15891
+ });
15892
+ };
15710
15893
  ;// ./src/components/DateRangePicker/index.ts
15711
15894
 
15712
15895
  ;// ./src/components/Drawer/DrawerProvider.tsx
@@ -20351,17 +20534,49 @@ const SelectWidget = props => {
20351
20534
  onChange,
20352
20535
  onBlur,
20353
20536
  onFocus,
20537
+ value,
20354
20538
  onChangeOverride,
20355
- value
20539
+ multiple
20356
20540
  } = props;
20357
20541
  const {
20358
20542
  enumOptions = [],
20359
20543
  enumDisabled = []
20360
20544
  } = options;
20361
- const selectedIndex = (0,external_rjsf_utils_namespaceObject.enumOptionsIndexForValue)(value, enumOptions);
20545
+ const isMultiple = !!multiple || Array.isArray(value);
20546
+ const items = Array.isArray(enumOptions) ? enumOptions : [];
20362
20547
  const handleChange = onChangeOverride ? onChangeOverride : value => {
20363
20548
  onChange(value);
20364
20549
  };
20550
+ const getSelectedItems = () => {
20551
+ if (isMultiple) {
20552
+ if (Array.isArray(value)) return value;
20553
+ if (value !== undefined) return [value];
20554
+ return [];
20555
+ }
20556
+ if (value === undefined || value === null) return [];
20557
+ const index = (0,external_rjsf_utils_namespaceObject.enumOptionsIndexForValue)(value, enumOptions);
20558
+ return index !== undefined ? [value] : [];
20559
+ };
20560
+ const selectedItems = getSelectedItems();
20561
+ const handleFormChange = newValue => {
20562
+ if (isMultiple) {
20563
+ const arrayValue = Array.isArray(newValue) ? newValue : [newValue];
20564
+ handleChange(arrayValue);
20565
+ } else {
20566
+ const singleValue = Array.isArray(newValue) ? newValue[0] : newValue;
20567
+ handleChange(singleValue);
20568
+ }
20569
+ };
20570
+ const handleTypeaheadChange = (changedValue, isAdded) => {
20571
+ if (isMultiple) {
20572
+ const currentSelected = Array.isArray(selectedItems) ? selectedItems : [];
20573
+ const newSelected = isAdded ? [...currentSelected, changedValue] : currentSelected.filter(item => item !== changedValue);
20574
+ handleFormChange(newSelected);
20575
+ } else {
20576
+ const newValue = isAdded ? changedValue : undefined;
20577
+ handleFormChange(newValue);
20578
+ }
20579
+ };
20365
20580
  const handleBlur = ({
20366
20581
  target
20367
20582
  }) => onBlur(id, target && target.value);
@@ -20370,11 +20585,21 @@ const SelectWidget = props => {
20370
20585
  }) => onFocus(id, target && target.value);
20371
20586
  const onEmptyChange = isEmpty => {
20372
20587
  if (isEmpty) {
20373
- handleChange();
20588
+ handleChange(isMultiple ? [] : undefined);
20589
+ }
20590
+ };
20591
+ const onClearAll = () => {
20592
+ handleChange(isMultiple ? [] : undefined);
20593
+ };
20594
+ const onRemoveSelectedClick = removedValue => {
20595
+ if (isMultiple) {
20596
+ const currentSelected = Array.isArray(selectedItems) ? selectedItems : [];
20597
+ const newSelected = currentSelected.filter(item => item !== removedValue);
20598
+ handleChange(newSelected);
20599
+ } else {
20600
+ handleChange(undefined);
20374
20601
  }
20375
20602
  };
20376
- const items = Array.isArray(enumOptions) ? enumOptions : [];
20377
- const selectedItems = selectedIndex ? [items[Number(selectedIndex)].value] : [];
20378
20603
  return (0,jsx_runtime_namespaceObject.jsx)("div", {
20379
20604
  id: id,
20380
20605
  onBlur: handleBlur,
@@ -20383,12 +20608,13 @@ const SelectWidget = props => {
20383
20608
  width: "100%",
20384
20609
  selectedItems: selectedItems,
20385
20610
  isDisabled: disabled,
20386
- name: name
20387
- // RJSF provides placeholder as empty string
20388
- ,
20611
+ name: name,
20612
+ isMultiple: isMultiple,
20389
20613
  placeholder: placeholder || undefined,
20390
- onChange: handleChange,
20614
+ onChange: handleTypeaheadChange,
20391
20615
  onEmptyChange: onEmptyChange,
20616
+ onClearAll: onClearAll,
20617
+ onRemoveSelectedClick: onRemoveSelectedClick,
20392
20618
  renderOption: ({
20393
20619
  label,
20394
20620
  input