@ssa-ui-kit/core 2.28.1 → 2.28.3
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/components/DatePicker/styles.d.ts +3 -0
- package/dist/components/DateRangePicker/DateRangePicker.d.ts +1 -1
- package/dist/components/DateRangePicker/components/DatesListWrapper.d.ts +3 -0
- package/dist/components/DateRangePicker/components/YearsMonthsSwitch.d.ts +1 -0
- package/dist/components/DateRangePicker/components/index.d.ts +1 -1
- package/dist/components/DateRangePicker/constants.d.ts +10 -0
- package/dist/components/DateRangePicker/hooks/useDateRangePicker.d.ts +1 -1
- package/dist/components/DateRangePicker/styles.d.ts +6 -1
- package/dist/components/DateRangePicker/types.d.ts +4 -1
- package/dist/components/DateRangePicker/utils/format.d.ts +10 -0
- package/dist/components/DateRangePicker/utils/index.d.ts +1 -0
- package/dist/components/Filters/FilterBlockWrapper.d.ts +3 -0
- package/dist/components/Tag/Tag.d.ts +1 -1
- package/dist/components/Tag/types.d.ts +9 -0
- package/dist/components/Typeahead/styles.d.ts +3 -0
- package/dist/components/Wrapper/Wrapper.d.ts +3 -0
- package/dist/index.js +352 -109
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/components/DateRangePicker/components/MonthsSwitch.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -1480,7 +1480,27 @@ 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', ";"
|
|
1483
|
+
}) => direction ? direction : 'row', ";", ({
|
|
1484
|
+
isVisible = true,
|
|
1485
|
+
fade,
|
|
1486
|
+
fadeDelay = 0.3
|
|
1487
|
+
}) => {
|
|
1488
|
+
const baseStyles = `
|
|
1489
|
+
opacity: ${isVisible ? 1 : 0};
|
|
1490
|
+
`;
|
|
1491
|
+
if (fade) {
|
|
1492
|
+
return `
|
|
1493
|
+
${baseStyles}
|
|
1494
|
+
transition: opacity ${fadeDelay}s ease-in-out, visibility ${fadeDelay}s ease-in-out;
|
|
1495
|
+
visibility: ${isVisible ? 'visible' : 'hidden'};
|
|
1496
|
+
${!isVisible ? `transition-delay: 0s, ${fadeDelay}s;` : ''}
|
|
1497
|
+
`;
|
|
1498
|
+
}
|
|
1499
|
+
return `
|
|
1500
|
+
${baseStyles}
|
|
1501
|
+
visibility: ${isVisible ? 'visible' : 'hidden'};
|
|
1502
|
+
`;
|
|
1503
|
+
}, ";" + ( true ? "" : 0));
|
|
1484
1504
|
/* harmony default export */ const Wrapper_Wrapper = (Wrapper);
|
|
1485
1505
|
;// ./src/components/Button/ButtonBase.tsx
|
|
1486
1506
|
|
|
@@ -8026,6 +8046,7 @@ const styles_blueLight = theme => /*#__PURE__*/(0,react_namespaceObject.css)("co
|
|
|
8026
8046
|
|
|
8027
8047
|
|
|
8028
8048
|
|
|
8049
|
+
|
|
8029
8050
|
const Tag_mapColors = {
|
|
8030
8051
|
pink: [styles_pink, pinkBorder],
|
|
8031
8052
|
yellow: [styles_yellow, yellowBorder],
|
|
@@ -8036,18 +8057,29 @@ const Tag_mapColors = {
|
|
|
8036
8057
|
blue: [styles_blue, blueBorder],
|
|
8037
8058
|
yellowWarm: [styles_yellowWarm, yellowWarmBorder]
|
|
8038
8059
|
};
|
|
8060
|
+
const createCustomStyles = customStyles => {
|
|
8061
|
+
if (!customStyles) return [];
|
|
8062
|
+
const styles = [/*#__PURE__*/(0,react_namespaceObject.css)(customStyles.color && `color: ${customStyles.color};`, " ", customStyles.background && `background: ${customStyles.background};`, " ", customStyles.border && `border: ${customStyles.border};`, " ", customStyles.boxShadow && `box-shadow: ${customStyles.boxShadow};`, ";" + ( true ? "" : 0), true ? "" : 0)];
|
|
8063
|
+
return customStyles.css ? [styles, customStyles.css] : [styles];
|
|
8064
|
+
};
|
|
8039
8065
|
const Tag = ({
|
|
8040
8066
|
color = 'purple',
|
|
8041
8067
|
size = 'medium',
|
|
8042
8068
|
className,
|
|
8043
|
-
children
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8069
|
+
children,
|
|
8070
|
+
customStyles
|
|
8071
|
+
}) => {
|
|
8072
|
+
const hasCustomStyles = customStyles && Object.keys(customStyles).length > 0;
|
|
8073
|
+
const defaultStyles = hasCustomStyles ? null : Tag_mapColors[color];
|
|
8074
|
+
const customStylesArray = createCustomStyles(customStyles);
|
|
8075
|
+
return (0,jsx_runtime_namespaceObject.jsx)(Badge_Badge, {
|
|
8076
|
+
color: hasCustomStyles ? 'transparent' : color,
|
|
8077
|
+
size: size,
|
|
8078
|
+
css: [defaultStyles, ...(customStylesArray || []), true ? "" : 0],
|
|
8079
|
+
className: className,
|
|
8080
|
+
children: children
|
|
8081
|
+
});
|
|
8082
|
+
};
|
|
8051
8083
|
/* harmony default export */ const Tag_Tag = (Tag);
|
|
8052
8084
|
;// ./src/components/Textarea/TextareaBase.tsx
|
|
8053
8085
|
|
|
@@ -14014,13 +14046,89 @@ const DatePicker = /*#__PURE__*/(0,external_react_namespaceObject.forwardRef)(Da
|
|
|
14014
14046
|
|
|
14015
14047
|
;// ./src/components/DateRangePicker/constants.ts
|
|
14016
14048
|
const constants_DEFAULT_MASK_FORMAT = 'mm/dd/yyyy';
|
|
14049
|
+
const DEFAULT_MONTH_MASK_FORMAT = 'mm/yyyy';
|
|
14050
|
+
const DEFAULT_YEAR_MASK_FORMAT = 'yyyy';
|
|
14017
14051
|
const constants_DEFAULT_MASK = '__/__/____';
|
|
14052
|
+
const DEFAULT_MONTH_MASK = '__/____';
|
|
14053
|
+
const DEFAULT_YEAR_MASK = '____';
|
|
14018
14054
|
const constants_MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
14019
14055
|
const constants_DATE_MIN = '01/01/1900';
|
|
14020
14056
|
const constants_DATE_MAX = '01/01/2150';
|
|
14057
|
+
const MONTH_DATE_MIN = '01/1900';
|
|
14058
|
+
const MONTH_DATE_MAX = '01/2150';
|
|
14059
|
+
const YEAR_DATE_MIN = '1900';
|
|
14060
|
+
const YEAR_DATE_MAX = '2150';
|
|
14021
14061
|
const constants_OUT_OF_RANGE = 'The date is out of the defined range';
|
|
14022
14062
|
const constants_INVALID_DATE = 'Invalid date';
|
|
14023
14063
|
const FULL_DATE_LENGTH = 10;
|
|
14064
|
+
const FULL_MONTH_DATE_LENGTH = 7;
|
|
14065
|
+
const FULL_YEAR_DATE_LENGTH = 4;
|
|
14066
|
+
;// ./src/components/DateRangePicker/utils/format.ts
|
|
14067
|
+
|
|
14068
|
+
const isMonthOnlyFormat = format => {
|
|
14069
|
+
if (!format) return false;
|
|
14070
|
+
const lowerFormat = format.toLowerCase();
|
|
14071
|
+
const hasMonth = lowerFormat.includes('mm');
|
|
14072
|
+
const hasYear = lowerFormat.includes('yyyy');
|
|
14073
|
+
const hasDay = lowerFormat.includes('dd');
|
|
14074
|
+
return hasMonth && hasYear && !hasDay;
|
|
14075
|
+
};
|
|
14076
|
+
const isYearOnlyFormat = format => {
|
|
14077
|
+
if (!format) return false;
|
|
14078
|
+
const lowerFormat = format.toLowerCase();
|
|
14079
|
+
const hasYear = lowerFormat.includes('yyyy');
|
|
14080
|
+
const hasMonth = lowerFormat.includes('mm');
|
|
14081
|
+
const hasDay = lowerFormat.includes('dd');
|
|
14082
|
+
return hasYear && !hasMonth && !hasDay;
|
|
14083
|
+
};
|
|
14084
|
+
const getExpectedDateLength = format => {
|
|
14085
|
+
if (!format) return FULL_DATE_LENGTH;
|
|
14086
|
+
if (isYearOnlyFormat(format)) {
|
|
14087
|
+
return FULL_YEAR_DATE_LENGTH;
|
|
14088
|
+
}
|
|
14089
|
+
if (isMonthOnlyFormat(format)) {
|
|
14090
|
+
return FULL_MONTH_DATE_LENGTH;
|
|
14091
|
+
}
|
|
14092
|
+
return FULL_DATE_LENGTH;
|
|
14093
|
+
};
|
|
14094
|
+
const getMaskForFormat = format => {
|
|
14095
|
+
if (isYearOnlyFormat(format)) {
|
|
14096
|
+
return DEFAULT_YEAR_MASK;
|
|
14097
|
+
}
|
|
14098
|
+
if (isMonthOnlyFormat(format)) {
|
|
14099
|
+
return DEFAULT_MONTH_MASK;
|
|
14100
|
+
}
|
|
14101
|
+
return constants_DEFAULT_MASK;
|
|
14102
|
+
};
|
|
14103
|
+
const getDefaultDateRange = format => {
|
|
14104
|
+
if (isYearOnlyFormat(format)) {
|
|
14105
|
+
return {
|
|
14106
|
+
defaultMin: YEAR_DATE_MIN,
|
|
14107
|
+
defaultMax: YEAR_DATE_MAX
|
|
14108
|
+
};
|
|
14109
|
+
}
|
|
14110
|
+
if (isMonthOnlyFormat(format)) {
|
|
14111
|
+
return {
|
|
14112
|
+
defaultMin: MONTH_DATE_MIN,
|
|
14113
|
+
defaultMax: MONTH_DATE_MAX
|
|
14114
|
+
};
|
|
14115
|
+
}
|
|
14116
|
+
return {
|
|
14117
|
+
defaultMin: constants_DATE_MIN,
|
|
14118
|
+
defaultMax: constants_DATE_MAX
|
|
14119
|
+
};
|
|
14120
|
+
};
|
|
14121
|
+
const getFormatForRangePickerType = rangePickerType => {
|
|
14122
|
+
switch (rangePickerType) {
|
|
14123
|
+
case 'years':
|
|
14124
|
+
return DEFAULT_YEAR_MASK_FORMAT;
|
|
14125
|
+
case 'months':
|
|
14126
|
+
return DEFAULT_MONTH_MASK_FORMAT;
|
|
14127
|
+
case 'days':
|
|
14128
|
+
default:
|
|
14129
|
+
return constants_DEFAULT_MASK_FORMAT;
|
|
14130
|
+
}
|
|
14131
|
+
};
|
|
14024
14132
|
;// ./src/components/DateRangePicker/components/DatesListWrapper.tsx
|
|
14025
14133
|
|
|
14026
14134
|
|
|
@@ -14093,8 +14201,9 @@ const styles_YearsViewCell = /*#__PURE__*/base_default()("div", true ? {
|
|
|
14093
14201
|
}) => isCalendarYear || isCalendarFirstDateSelected || isCalendarSecondDateSelected ? `linear-gradient(247.37deg, ${theme.colors.blueLighter} 14.71%, ${theme.colors.blue} 85.29%)` : 'none', ";background:", ({
|
|
14094
14202
|
theme,
|
|
14095
14203
|
isHighlighted,
|
|
14096
|
-
isCalendarYear
|
|
14097
|
-
|
|
14204
|
+
isCalendarYear,
|
|
14205
|
+
isCalendarSecondDateSelected
|
|
14206
|
+
}) => isHighlighted && !isCalendarYear && !isCalendarSecondDateSelected && theme.colors.blueRoyal16, ";&:hover{background:", ({
|
|
14098
14207
|
theme
|
|
14099
14208
|
}) => theme.colors.greyLighter, ";color:", ({
|
|
14100
14209
|
theme
|
|
@@ -14115,24 +14224,21 @@ const styles_MonthsViewCell = /*#__PURE__*/base_default()("div", true ? {
|
|
|
14115
14224
|
isCalendarSecondDateSelected
|
|
14116
14225
|
}) => isCalendarFirstDateSelected || isCalendarSecondDateSelected ? '6px' : 0, ";font-size:14px;font-weight:500;cursor:pointer;color:", ({
|
|
14117
14226
|
theme,
|
|
14118
|
-
isCalendarMonth,
|
|
14119
14227
|
isCalendarFirstDateSelected,
|
|
14120
14228
|
isCalendarSecondDateSelected
|
|
14121
|
-
}) => (
|
|
14229
|
+
}) => (isCalendarFirstDateSelected || isCalendarSecondDateSelected) && theme.colors.white, ";user-select:none;background:", ({
|
|
14122
14230
|
theme,
|
|
14123
|
-
isCalendarMonth,
|
|
14124
14231
|
isCalendarFirstDateSelected,
|
|
14125
14232
|
isCalendarSecondDateSelected
|
|
14126
|
-
}) =>
|
|
14233
|
+
}) => 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
14234
|
theme
|
|
14128
14235
|
}) => theme.colors.greyDarker, ";background:", ({
|
|
14129
14236
|
theme
|
|
14130
14237
|
}) => theme.colors.grey, ";}&[aria-disabled='false']{background:", ({
|
|
14131
14238
|
theme,
|
|
14132
14239
|
isHighlighted,
|
|
14133
|
-
isCalendarMonth,
|
|
14134
14240
|
isCalendarSecondDateSelected
|
|
14135
|
-
}) => isHighlighted && !
|
|
14241
|
+
}) => isHighlighted && !isCalendarSecondDateSelected && theme.colors.blueRoyal16, ";&:hover{background:", ({
|
|
14136
14242
|
theme
|
|
14137
14243
|
}) => theme.colors.greyLighter, ";color:", ({
|
|
14138
14244
|
theme
|
|
@@ -14487,9 +14593,12 @@ const MonthsView_MonthsView = () => {
|
|
|
14487
14593
|
dateMaxDT,
|
|
14488
14594
|
lastFocusedElement,
|
|
14489
14595
|
currentCalendarViewDT,
|
|
14596
|
+
rangePickerType,
|
|
14490
14597
|
setCalendarType,
|
|
14491
14598
|
setCalendarViewDateTime,
|
|
14492
|
-
onMonthChange
|
|
14599
|
+
onMonthChange,
|
|
14600
|
+
setDateTime,
|
|
14601
|
+
setIsOpen
|
|
14493
14602
|
} = useDateRangePickerContext();
|
|
14494
14603
|
const {
|
|
14495
14604
|
handleDateHover,
|
|
@@ -14507,20 +14616,34 @@ const MonthsView_MonthsView = () => {
|
|
|
14507
14616
|
}
|
|
14508
14617
|
const selectedMonth = target.innerHTML;
|
|
14509
14618
|
const monthNumber = constants_MONTHS.findIndex(month => month === selectedMonth);
|
|
14510
|
-
|
|
14511
|
-
|
|
14512
|
-
|
|
14513
|
-
|
|
14514
|
-
|
|
14515
|
-
|
|
14619
|
+
if (rangePickerType === 'days') {
|
|
14620
|
+
const newDate = currentCalendarViewDT?.set({
|
|
14621
|
+
month: monthNumber + 1
|
|
14622
|
+
});
|
|
14623
|
+
setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, calendarViewDateTime[1]] : [calendarViewDateTime[0], newDate]);
|
|
14624
|
+
if (newDate) {
|
|
14625
|
+
onMonthChange?.(newDate.toJSDate());
|
|
14626
|
+
}
|
|
14627
|
+
setCalendarType('days');
|
|
14628
|
+
} else {
|
|
14629
|
+
const newMonth = currentCalendarViewDT?.set({
|
|
14630
|
+
month: monthNumber + 1
|
|
14631
|
+
});
|
|
14632
|
+
const newDate = newMonth?.set({
|
|
14633
|
+
day: lastFocusedElement === 'from' ? 1 : newMonth.daysInMonth
|
|
14634
|
+
});
|
|
14635
|
+
const newDateTuple = lastFocusedElement === 'from' ? [newDate, dateTime[1]] : [dateTime[0], newDate];
|
|
14636
|
+
setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, dateTime[1] ? calendarViewDateTime?.[1] : newDate] : [dateTime[0] ? calendarViewDateTime?.[0] : newDate, newDate]);
|
|
14637
|
+
setDateTime(newDateTuple);
|
|
14638
|
+
if (newDateTuple[0] && newDateTuple[1]) {
|
|
14639
|
+
setIsOpen(false);
|
|
14640
|
+
}
|
|
14516
14641
|
}
|
|
14517
|
-
setCalendarType('days');
|
|
14518
14642
|
};
|
|
14519
14643
|
return (0,jsx_runtime_namespaceObject.jsx)(DatesListWrapper, {
|
|
14520
14644
|
css: components_MonthsView_ref,
|
|
14521
14645
|
onClick: handleMonthSelect,
|
|
14522
14646
|
children: constants_MONTHS.map((month, index) => {
|
|
14523
|
-
const isCalendarMonth = currentCalendarViewDT ? currentCalendarViewDT.month === index + 1 : false;
|
|
14524
14647
|
const currentMonthDT = external_luxon_namespaceObject.DateTime.fromObject({
|
|
14525
14648
|
year: currentCalendarViewDT?.year,
|
|
14526
14649
|
month: index + 1,
|
|
@@ -14536,7 +14659,6 @@ const MonthsView_MonthsView = () => {
|
|
|
14536
14659
|
isCalendarSecondDateSelected
|
|
14537
14660
|
});
|
|
14538
14661
|
return (0,jsx_runtime_namespaceObject.jsx)(styles_MonthsViewCell, {
|
|
14539
|
-
isCalendarMonth: isCalendarMonth,
|
|
14540
14662
|
"aria-disabled": isAriaDisabled,
|
|
14541
14663
|
"aria-label": `${month}, ${currentCalendarViewDT?.year}`,
|
|
14542
14664
|
isCalendarFirstDateSelected: isCalendarFirstDateSelected,
|
|
@@ -14566,6 +14688,7 @@ var components_YearsView_ref = true ? {
|
|
|
14566
14688
|
} : 0;
|
|
14567
14689
|
const YearsView_YearsView = () => {
|
|
14568
14690
|
const {
|
|
14691
|
+
rangePickerType,
|
|
14569
14692
|
dateTime,
|
|
14570
14693
|
calendarViewDateTime,
|
|
14571
14694
|
currentCalendarViewDT,
|
|
@@ -14575,7 +14698,9 @@ const YearsView_YearsView = () => {
|
|
|
14575
14698
|
lastFocusedElement,
|
|
14576
14699
|
setCalendarType,
|
|
14577
14700
|
setCalendarViewDateTime,
|
|
14578
|
-
onYearChange
|
|
14701
|
+
onYearChange,
|
|
14702
|
+
setDateTime,
|
|
14703
|
+
setIsOpen
|
|
14579
14704
|
} = useDateRangePickerContext();
|
|
14580
14705
|
const wrapper = (0,external_react_namespaceObject.useRef)(null);
|
|
14581
14706
|
const yearsList = dates_getYearsList({
|
|
@@ -14600,13 +14725,32 @@ const YearsView_YearsView = () => {
|
|
|
14600
14725
|
target
|
|
14601
14726
|
} = event;
|
|
14602
14727
|
const selectedYear = Number(target.innerHTML);
|
|
14603
|
-
|
|
14604
|
-
|
|
14605
|
-
|
|
14606
|
-
|
|
14607
|
-
|
|
14608
|
-
|
|
14609
|
-
|
|
14728
|
+
if (rangePickerType !== 'years') {
|
|
14729
|
+
const newDate = currentCalendarViewDT.set({
|
|
14730
|
+
year: selectedYear
|
|
14731
|
+
});
|
|
14732
|
+
setCalendarType('months');
|
|
14733
|
+
setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, calendarViewDateTime[1]] : [calendarViewDateTime[0], newDate]);
|
|
14734
|
+
if (newDate) {
|
|
14735
|
+
onYearChange?.(newDate.toJSDate());
|
|
14736
|
+
}
|
|
14737
|
+
} else {
|
|
14738
|
+
const newYear = currentCalendarViewDT?.set({
|
|
14739
|
+
year: selectedYear
|
|
14740
|
+
});
|
|
14741
|
+
const newDate = newYear?.set(lastFocusedElement === 'from' ? {
|
|
14742
|
+
day: 1,
|
|
14743
|
+
month: 1
|
|
14744
|
+
} : {
|
|
14745
|
+
day: 31,
|
|
14746
|
+
month: 12
|
|
14747
|
+
});
|
|
14748
|
+
const newDateTuple = lastFocusedElement === 'from' ? [newDate, dateTime[1]] : [dateTime[0], newDate];
|
|
14749
|
+
setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, dateTime[1] ? calendarViewDateTime?.[1] : newDate] : [dateTime[0] ? calendarViewDateTime?.[0] : newDate, newDate]);
|
|
14750
|
+
setDateTime(newDateTuple);
|
|
14751
|
+
if (newDateTuple[0] && newDateTuple[1]) {
|
|
14752
|
+
setIsOpen(false);
|
|
14753
|
+
}
|
|
14610
14754
|
}
|
|
14611
14755
|
};
|
|
14612
14756
|
return (0,jsx_runtime_namespaceObject.jsx)(DatesListWrapper, {
|
|
@@ -14644,20 +14788,21 @@ const YearsView_YearsView = () => {
|
|
|
14644
14788
|
})
|
|
14645
14789
|
});
|
|
14646
14790
|
};
|
|
14647
|
-
;// ./src/components/DateRangePicker/components/
|
|
14791
|
+
;// ./src/components/DateRangePicker/components/YearsMonthsSwitch.tsx
|
|
14648
14792
|
|
|
14649
|
-
function
|
|
14793
|
+
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
14794
|
|
|
14651
14795
|
|
|
14652
14796
|
|
|
14653
14797
|
|
|
14654
14798
|
|
|
14655
|
-
var
|
|
14799
|
+
var YearsMonthsSwitch_ref = true ? {
|
|
14656
14800
|
name: "9cmux7",
|
|
14657
14801
|
styles: "width:72px;gap:24px"
|
|
14658
14802
|
} : 0;
|
|
14659
|
-
const
|
|
14803
|
+
const YearsMonthsSwitch = () => {
|
|
14660
14804
|
const {
|
|
14805
|
+
rangePickerType = 'days',
|
|
14661
14806
|
calendarType,
|
|
14662
14807
|
calendarViewDateTime,
|
|
14663
14808
|
dateMinDT,
|
|
@@ -14674,40 +14819,44 @@ const MonthsSwitch = () => {
|
|
|
14674
14819
|
});
|
|
14675
14820
|
const isMinMonthReached = calendarViewDateTime ? currentCalendarViewDT?.month === dateMinDT.month && currentCalendarViewDT.year === dateMinDT.year : false;
|
|
14676
14821
|
const isMaxMonthReached = calendarViewDateTime ? currentCalendarViewDT?.month === dateMaxDT.month && currentCalendarViewDT.year === dateMaxDT.year : false;
|
|
14677
|
-
const
|
|
14678
|
-
const newDate = currentCalendarViewDT?.minus({
|
|
14822
|
+
const handlePrevious = () => {
|
|
14823
|
+
const newDate = currentCalendarViewDT?.minus(isDayCalendarType ? {
|
|
14679
14824
|
month: 1
|
|
14825
|
+
} : {
|
|
14826
|
+
year: 1
|
|
14680
14827
|
});
|
|
14681
14828
|
setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, calendarViewDateTime[1]] : [calendarViewDateTime[0], newDate]);
|
|
14682
14829
|
if (newDate) {
|
|
14683
14830
|
onMonthChange?.(newDate.toJSDate());
|
|
14684
14831
|
}
|
|
14685
14832
|
};
|
|
14686
|
-
const
|
|
14687
|
-
const newDate = currentCalendarViewDT?.plus({
|
|
14833
|
+
const handleNext = () => {
|
|
14834
|
+
const newDate = currentCalendarViewDT?.plus(isDayCalendarType ? {
|
|
14688
14835
|
month: 1
|
|
14836
|
+
} : {
|
|
14837
|
+
year: 1
|
|
14689
14838
|
});
|
|
14690
14839
|
setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, calendarViewDateTime[1]] : [calendarViewDateTime[0], newDate]);
|
|
14691
14840
|
if (newDate) {
|
|
14692
14841
|
onMonthChange?.(newDate.toJSDate());
|
|
14693
14842
|
}
|
|
14694
14843
|
};
|
|
14695
|
-
if (
|
|
14844
|
+
if (rangePickerType === 'days' && calendarType !== 'days' || rangePickerType === 'months' && calendarType !== 'months' || rangePickerType === 'years') {
|
|
14696
14845
|
return null;
|
|
14697
14846
|
}
|
|
14698
14847
|
return (0,jsx_runtime_namespaceObject.jsxs)(Wrapper_Wrapper, {
|
|
14699
|
-
css:
|
|
14848
|
+
css: YearsMonthsSwitch_ref,
|
|
14700
14849
|
children: [(0,jsx_runtime_namespaceObject.jsx)(Button_Button, {
|
|
14701
14850
|
endIcon: (0,jsx_runtime_namespaceObject.jsx)(Icon_Icon, {
|
|
14702
14851
|
name: "carrot-left",
|
|
14703
14852
|
size: 14,
|
|
14704
|
-
tooltip:
|
|
14853
|
+
tooltip: `Previous ${rangePickerType === 'days' ? 'month' : 'year'}`,
|
|
14705
14854
|
color: isMinMonthReached ? theme.colors.grey : theme.colors.greyDarker
|
|
14706
14855
|
}),
|
|
14707
14856
|
variant: 'tertiary',
|
|
14708
|
-
"aria-label":
|
|
14709
|
-
"data-testid": "previous-month",
|
|
14710
|
-
onClick:
|
|
14857
|
+
"aria-label": `Previous ${rangePickerType === 'days' ? 'month' : 'year'}`,
|
|
14858
|
+
"data-testid": "previous-year-month",
|
|
14859
|
+
onClick: handlePrevious,
|
|
14711
14860
|
isDisabled: isMinMonthReached,
|
|
14712
14861
|
css: /*#__PURE__*/(0,react_namespaceObject.css)({
|
|
14713
14862
|
padding: 4,
|
|
@@ -14721,14 +14870,14 @@ const MonthsSwitch = () => {
|
|
|
14721
14870
|
endIcon: (0,jsx_runtime_namespaceObject.jsx)(Icon_Icon, {
|
|
14722
14871
|
name: "carrot-right",
|
|
14723
14872
|
size: 14,
|
|
14724
|
-
tooltip:
|
|
14873
|
+
tooltip: `Next ${rangePickerType === 'days' ? 'month' : 'year'}`,
|
|
14725
14874
|
color: isMaxMonthReached ? theme.colors.grey : theme.colors.greyDarker
|
|
14726
14875
|
}),
|
|
14727
14876
|
variant: 'tertiary',
|
|
14728
|
-
onClick:
|
|
14877
|
+
onClick: handleNext,
|
|
14729
14878
|
isDisabled: isMaxMonthReached,
|
|
14730
|
-
"aria-label":
|
|
14731
|
-
"data-testid": "next-month",
|
|
14879
|
+
"aria-label": `Next ${rangePickerType === 'days' ? 'month' : 'year'}`,
|
|
14880
|
+
"data-testid": "next-year-month",
|
|
14732
14881
|
css: /*#__PURE__*/(0,react_namespaceObject.css)({
|
|
14733
14882
|
padding: 4,
|
|
14734
14883
|
height: 32,
|
|
@@ -14756,28 +14905,29 @@ var Header_ref2 = true ? {
|
|
|
14756
14905
|
} : 0;
|
|
14757
14906
|
const Header_Header = () => {
|
|
14758
14907
|
const {
|
|
14908
|
+
rangePickerType,
|
|
14759
14909
|
calendarType,
|
|
14760
14910
|
currentCalendarViewDT,
|
|
14761
14911
|
setCalendarType
|
|
14762
14912
|
} = useDateRangePickerContext();
|
|
14763
14913
|
const handleCalendarTypeChange = () => {
|
|
14764
|
-
setCalendarType(calendarType === 'days' ? 'years' : 'days');
|
|
14914
|
+
setCalendarType(calendarType === 'days' || calendarType === 'months' ? 'years' : rangePickerType ?? 'days');
|
|
14765
14915
|
};
|
|
14766
14916
|
return (0,jsx_runtime_namespaceObject.jsxs)(PopoverHeading, {
|
|
14767
14917
|
css: components_Header_ref,
|
|
14768
14918
|
as: 'div',
|
|
14769
14919
|
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',
|
|
14920
|
+
endIcon: rangePickerType !== 'years' ? (0,jsx_runtime_namespaceObject.jsx)(Icon_Icon, {
|
|
14921
|
+
name: calendarType === 'days' || calendarType === 'months' ? 'carrot-down' : 'carrot-up',
|
|
14772
14922
|
size: 14,
|
|
14773
14923
|
tooltip: ""
|
|
14774
|
-
}),
|
|
14924
|
+
}) : null,
|
|
14775
14925
|
variant: "tertiary",
|
|
14776
14926
|
onClick: handleCalendarTypeChange,
|
|
14777
14927
|
"data-testid": "calendar-type-change-button",
|
|
14778
14928
|
css: Header_ref2,
|
|
14779
|
-
children: currentCalendarViewDT.toFormat('LLLL yyyy')
|
|
14780
|
-
}), (0,jsx_runtime_namespaceObject.jsx)(
|
|
14929
|
+
children: currentCalendarViewDT.toFormat(rangePickerType === 'days' ? 'LLLL yyyy' : 'yyyy')
|
|
14930
|
+
}), (0,jsx_runtime_namespaceObject.jsx)(YearsMonthsSwitch, {})]
|
|
14781
14931
|
});
|
|
14782
14932
|
};
|
|
14783
14933
|
;// ./src/components/DateRangePicker/components/Calendar.tsx
|
|
@@ -15258,7 +15408,6 @@ const Content_DatePickerContent = () => {
|
|
|
15258
15408
|
;// ./src/components/DateRangePicker/hooks/useDatePickerMask.tsx
|
|
15259
15409
|
|
|
15260
15410
|
|
|
15261
|
-
|
|
15262
15411
|
const useDatePickerMask_useDatePickerMask = ({
|
|
15263
15412
|
maskOptions,
|
|
15264
15413
|
formatIndexes,
|
|
@@ -15266,7 +15415,7 @@ const useDatePickerMask_useDatePickerMask = ({
|
|
|
15266
15415
|
dateMaxParts
|
|
15267
15416
|
}) => {
|
|
15268
15417
|
const {
|
|
15269
|
-
mask
|
|
15418
|
+
mask,
|
|
15270
15419
|
replacement = {
|
|
15271
15420
|
_: /\d/
|
|
15272
15421
|
},
|
|
@@ -15281,7 +15430,8 @@ const useDatePickerMask_useDatePickerMask = ({
|
|
|
15281
15430
|
selectionEnd,
|
|
15282
15431
|
value: currentValue
|
|
15283
15432
|
}) => {
|
|
15284
|
-
|
|
15433
|
+
const isDateMask = typeof mask === 'string' && /^[_/]+$/.test(mask);
|
|
15434
|
+
if (isDateMask) {
|
|
15285
15435
|
const newValue = currentValue.slice(0, selectionStart) + data + currentValue.slice(selectionEnd);
|
|
15286
15436
|
const updatedValue = (0,mask_namespaceObject.format)(newValue, {
|
|
15287
15437
|
mask,
|
|
@@ -15309,22 +15459,32 @@ const useDatePickerMask_useDatePickerMask = ({
|
|
|
15309
15459
|
|
|
15310
15460
|
|
|
15311
15461
|
|
|
15462
|
+
|
|
15312
15463
|
const useDateRangePicker = ({
|
|
15313
|
-
dateMin
|
|
15314
|
-
dateMax
|
|
15464
|
+
dateMin,
|
|
15465
|
+
dateMax,
|
|
15315
15466
|
name: _name,
|
|
15316
|
-
format
|
|
15467
|
+
format: propFormat,
|
|
15317
15468
|
maskOptions,
|
|
15318
15469
|
isOpenState = false,
|
|
15319
15470
|
defaultValue,
|
|
15471
|
+
rangePickerType = 'days',
|
|
15320
15472
|
onOpen,
|
|
15321
15473
|
onClose,
|
|
15322
15474
|
onError,
|
|
15323
15475
|
onChange,
|
|
15324
15476
|
...rest
|
|
15325
15477
|
}) => {
|
|
15478
|
+
const format = propFormat || getFormatForRangePickerType(rangePickerType);
|
|
15479
|
+
const {
|
|
15480
|
+
defaultMin,
|
|
15481
|
+
defaultMax
|
|
15482
|
+
} = getDefaultDateRange(format);
|
|
15483
|
+
const finalDateMin = dateMin || defaultMin;
|
|
15484
|
+
const finalDateMax = dateMax || defaultMax;
|
|
15326
15485
|
const inputFromRef = (0,external_react_namespaceObject.useRef)(null);
|
|
15327
15486
|
const inputToRef = (0,external_react_namespaceObject.useRef)(null);
|
|
15487
|
+
const previousRangePickerType = (0,external_react_namespaceObject.useRef)(rangePickerType);
|
|
15328
15488
|
const [isOpen, setIsOpen] = (0,external_react_namespaceObject.useState)(isOpenState);
|
|
15329
15489
|
const [status, setStatus] = (0,external_react_namespaceObject.useState)(rest.status);
|
|
15330
15490
|
const previousOpenState = (0,external_react_namespaceObject.useRef)(isOpenState);
|
|
@@ -15362,16 +15522,21 @@ const useDateRangePicker = ({
|
|
|
15362
15522
|
month: splittedFormat.findIndex(item => item === 'mm'),
|
|
15363
15523
|
year: splittedFormat.findIndex(item => item === 'yyyy')
|
|
15364
15524
|
});
|
|
15365
|
-
const [calendarType, setCalendarType] = (0,external_react_namespaceObject.useState)(
|
|
15525
|
+
const [calendarType, setCalendarType] = (0,external_react_namespaceObject.useState)(rangePickerType);
|
|
15366
15526
|
const [calendarViewDateTime, setCalendarViewDateTime] = (0,external_react_namespaceObject.useState)([undefined, undefined]);
|
|
15367
15527
|
const currentCalendarViewDT = calendarViewDateTime[currentIndex] || external_luxon_namespaceObject.DateTime.now().set({
|
|
15368
15528
|
day: 1
|
|
15369
15529
|
});
|
|
15370
15530
|
const luxonFormat = format.replace('mm', 'MM');
|
|
15371
|
-
const
|
|
15372
|
-
const
|
|
15531
|
+
const expectedDateLength = getExpectedDateLength(format);
|
|
15532
|
+
const dateMinParts = finalDateMin.split('/').map(Number);
|
|
15533
|
+
const dateMaxParts = finalDateMax.split('/').map(Number);
|
|
15534
|
+
const defaultMask = getMaskForFormat(format);
|
|
15373
15535
|
const maskInputRef = useDatePickerMask_useDatePickerMask({
|
|
15374
|
-
maskOptions
|
|
15536
|
+
maskOptions: {
|
|
15537
|
+
mask: defaultMask,
|
|
15538
|
+
...maskOptions
|
|
15539
|
+
},
|
|
15375
15540
|
dateMaxParts,
|
|
15376
15541
|
dateMinParts,
|
|
15377
15542
|
formatIndexes
|
|
@@ -15379,12 +15544,12 @@ const useDateRangePicker = ({
|
|
|
15379
15544
|
const dateMaxDT = external_luxon_namespaceObject.DateTime.fromObject({
|
|
15380
15545
|
year: dateMaxParts[formatIndexes['year']],
|
|
15381
15546
|
month: dateMaxParts[formatIndexes['month']],
|
|
15382
|
-
day: dateMaxParts[formatIndexes['day']]
|
|
15547
|
+
day: formatIndexes['day'] !== -1 ? dateMaxParts[formatIndexes['day']] : 1
|
|
15383
15548
|
});
|
|
15384
15549
|
const dateMinDT = external_luxon_namespaceObject.DateTime.fromObject({
|
|
15385
15550
|
year: dateMinParts[formatIndexes['year']],
|
|
15386
15551
|
month: dateMinParts[formatIndexes['month']],
|
|
15387
|
-
day: dateMinParts[formatIndexes['day']]
|
|
15552
|
+
day: formatIndexes['day'] !== -1 ? dateMinParts[formatIndexes['day']] : 1
|
|
15388
15553
|
});
|
|
15389
15554
|
const safeOnChange = newDateTime => {
|
|
15390
15555
|
const _newDateTime = newDateTime ? newDateTime.startOf('day') : undefined;
|
|
@@ -15420,7 +15585,7 @@ const useDateRangePicker = ({
|
|
|
15420
15585
|
const processValue = (newValue, elementName) => {
|
|
15421
15586
|
const currentElementType = elementName || lastFocusedElement;
|
|
15422
15587
|
const currentName = currentElementType === 'from' ? nameFrom : nameTo;
|
|
15423
|
-
const newDateTime = typeof newValue === 'string' && newValue.length ===
|
|
15588
|
+
const newDateTime = typeof newValue === 'string' && newValue.length === expectedDateLength ? external_luxon_namespaceObject.DateTime.fromFormat(newValue, luxonFormat) : undefined;
|
|
15424
15589
|
const newDateTimeIfInvalid = [currentElementType === 'from' ? undefined : dateTime?.[0], currentElementType === 'to' ? undefined : dateTime?.[1]];
|
|
15425
15590
|
const newDateTimeIfValid = [currentElementType === 'from' ? newDateTime : dateTime?.[0], currentElementType === 'to' ? newDateTime : dateTime?.[1]];
|
|
15426
15591
|
if (!newDateTime?.isValid) {
|
|
@@ -15465,14 +15630,14 @@ const useDateRangePicker = ({
|
|
|
15465
15630
|
const processInputValue = (inputValue, elementName) => {
|
|
15466
15631
|
const currentElementType = elementName || lastFocusedElement;
|
|
15467
15632
|
const currentName = currentElementType === 'from' ? nameFrom : nameTo;
|
|
15468
|
-
if (typeof inputValue === 'string' && inputValue.length && inputValue.length <
|
|
15633
|
+
if (typeof inputValue === 'string' && inputValue.length && inputValue.length < expectedDateLength) {
|
|
15469
15634
|
setIsOpen(false);
|
|
15470
15635
|
setTimeout(() => {
|
|
15471
15636
|
maskInputRef.current.focus();
|
|
15472
15637
|
}, 10);
|
|
15473
15638
|
}
|
|
15474
15639
|
let newDateTime;
|
|
15475
|
-
if (typeof inputValue === 'string' && inputValue.length ===
|
|
15640
|
+
if (typeof inputValue === 'string' && inputValue.length === expectedDateLength) {
|
|
15476
15641
|
newDateTime = external_luxon_namespaceObject.DateTime.fromFormat(inputValue, luxonFormat);
|
|
15477
15642
|
setValue(currentName, inputValue);
|
|
15478
15643
|
processValue(inputValue, elementName);
|
|
@@ -15506,16 +15671,19 @@ const useDateRangePicker = ({
|
|
|
15506
15671
|
setCalendarViewDateTime(currentElementType === 'from' ? [newCalendarViewDateTime, calendarViewDateTime[1]] : [calendarViewDateTime[0], newCalendarViewDateTime]);
|
|
15507
15672
|
}
|
|
15508
15673
|
};
|
|
15674
|
+
(0,external_react_namespaceObject.useEffect)(() => {
|
|
15675
|
+
setCalendarType(rangePickerType);
|
|
15676
|
+
}, [rangePickerType]);
|
|
15509
15677
|
(0,external_react_namespaceObject.useEffect)(() => {
|
|
15510
15678
|
processInputValue(lastFocusedElement === 'from' ? inputValueFrom : inputValueTo);
|
|
15511
15679
|
}, [lastFocusedElement]);
|
|
15512
15680
|
(0,external_react_namespaceObject.useEffect)(() => {
|
|
15513
|
-
if (inputValueFrom && inputValueFrom.length ===
|
|
15681
|
+
if (inputValueFrom && inputValueFrom.length === expectedDateLength) {
|
|
15514
15682
|
processInputValue(lastFocusedElement === 'from' ? inputValueFrom : inputValueTo);
|
|
15515
15683
|
}
|
|
15516
15684
|
}, [inputValueFrom]);
|
|
15517
15685
|
(0,external_react_namespaceObject.useEffect)(() => {
|
|
15518
|
-
if (inputValueTo && inputValueTo.length ===
|
|
15686
|
+
if (inputValueTo && inputValueTo.length === expectedDateLength) {
|
|
15519
15687
|
processInputValue(lastFocusedElement === 'from' ? inputValueFrom : inputValueTo);
|
|
15520
15688
|
}
|
|
15521
15689
|
}, [inputValueTo]);
|
|
@@ -15531,18 +15699,31 @@ const useDateRangePicker = ({
|
|
|
15531
15699
|
}, [dateTime, lastFocusedElement, currentName]);
|
|
15532
15700
|
(0,external_react_namespaceObject.useEffect)(() => {
|
|
15533
15701
|
if (dateTime[0] && dateTime[1] && dateTime[0] > dateTime[1]) {
|
|
15534
|
-
|
|
15535
|
-
|
|
15536
|
-
|
|
15537
|
-
|
|
15538
|
-
|
|
15539
|
-
|
|
15540
|
-
|
|
15541
|
-
|
|
15542
|
-
|
|
15543
|
-
|
|
15544
|
-
|
|
15545
|
-
|
|
15702
|
+
if (lastFocusedElement === 'from') {
|
|
15703
|
+
resetField(nameTo);
|
|
15704
|
+
setDateTime([dateTime[0], undefined]);
|
|
15705
|
+
setLastChangedDate([dateTime[0].toJSDate(), undefined]);
|
|
15706
|
+
setValue(nameTo, undefined);
|
|
15707
|
+
setLastFocusedElement('to');
|
|
15708
|
+
setTimeout(() => {
|
|
15709
|
+
setFocus(nameTo, {
|
|
15710
|
+
shouldSelect: true
|
|
15711
|
+
});
|
|
15712
|
+
}, 50);
|
|
15713
|
+
setIsOpen(true);
|
|
15714
|
+
} else {
|
|
15715
|
+
resetField(nameFrom);
|
|
15716
|
+
setDateTime([undefined, dateTime[1]]);
|
|
15717
|
+
setLastChangedDate([undefined, dateTime[1].toJSDate()]);
|
|
15718
|
+
setValue(nameFrom, undefined);
|
|
15719
|
+
setLastFocusedElement('from');
|
|
15720
|
+
setTimeout(() => {
|
|
15721
|
+
setFocus(nameFrom, {
|
|
15722
|
+
shouldSelect: true
|
|
15723
|
+
});
|
|
15724
|
+
}, 50);
|
|
15725
|
+
setIsOpen(true);
|
|
15726
|
+
}
|
|
15546
15727
|
}
|
|
15547
15728
|
}, [dateTime]);
|
|
15548
15729
|
(0,external_react_namespaceObject.useEffect)(() => {
|
|
@@ -15551,7 +15732,7 @@ const useDateRangePicker = ({
|
|
|
15551
15732
|
onOpen?.();
|
|
15552
15733
|
} else {
|
|
15553
15734
|
onClose?.();
|
|
15554
|
-
setCalendarType(
|
|
15735
|
+
setCalendarType(rangePickerType);
|
|
15555
15736
|
setCalendarViewDateTime([dateTime[0], dateTime[1]]);
|
|
15556
15737
|
}
|
|
15557
15738
|
previousOpenState.current = isOpen;
|
|
@@ -15565,10 +15746,24 @@ const useDateRangePicker = ({
|
|
|
15565
15746
|
year: splittedFormat.findIndex(item => item === 'yyyy')
|
|
15566
15747
|
});
|
|
15567
15748
|
}, [format]);
|
|
15749
|
+
(0,external_react_namespaceObject.useEffect)(() => {
|
|
15750
|
+
if (previousRangePickerType.current !== rangePickerType) {
|
|
15751
|
+
if (dateTime[0] || dateTime[1]) {
|
|
15752
|
+
const newLuxonFormat = format.replace('mm', 'MM');
|
|
15753
|
+
if (dateTime[0]) {
|
|
15754
|
+
setValue(nameFrom, dateTime[0].toFormat(newLuxonFormat));
|
|
15755
|
+
}
|
|
15756
|
+
if (dateTime[1]) {
|
|
15757
|
+
setValue(nameTo, dateTime[1].toFormat(newLuxonFormat));
|
|
15758
|
+
}
|
|
15759
|
+
}
|
|
15760
|
+
previousRangePickerType.current = rangePickerType;
|
|
15761
|
+
}
|
|
15762
|
+
}, [rangePickerType, format, dateTime, nameFrom, nameTo, setValue]);
|
|
15568
15763
|
(0,external_react_namespaceObject.useEffect)(() => {
|
|
15569
15764
|
if (Array.isArray(rest.value)) {
|
|
15570
|
-
const newDateTimeFrom = typeof rest.value[0] === 'string' && rest.value[0].length ===
|
|
15571
|
-
const newDateTimeTo = typeof rest.value[1] === 'string' && rest.value[1].length ===
|
|
15765
|
+
const newDateTimeFrom = typeof rest.value[0] === 'string' && rest.value[0].length === expectedDateLength ? external_luxon_namespaceObject.DateTime.fromFormat(rest.value[0], luxonFormat) : undefined;
|
|
15766
|
+
const newDateTimeTo = typeof rest.value[1] === 'string' && rest.value[1].length === expectedDateLength ? external_luxon_namespaceObject.DateTime.fromFormat(rest.value[1], luxonFormat) : undefined;
|
|
15572
15767
|
const newDateTime = [newDateTimeFrom?.isValid ? newDateTimeFrom : undefined, newDateTimeTo?.isValid ? newDateTimeTo : undefined];
|
|
15573
15768
|
setDateTime(newDateTime);
|
|
15574
15769
|
setLastChangedDate([newDateTime[0]?.toJSDate(), newDateTime[1]?.toJSDate()]);
|
|
@@ -15694,19 +15889,24 @@ const DateRangePickerProvider = ({
|
|
|
15694
15889
|
|
|
15695
15890
|
|
|
15696
15891
|
const DateRangePicker = ({
|
|
15697
|
-
format
|
|
15892
|
+
format,
|
|
15698
15893
|
openCalendarMode = 'icon',
|
|
15699
15894
|
showCalendarIcon = true,
|
|
15700
15895
|
showStatusArea = true,
|
|
15896
|
+
rangePickerType = 'days',
|
|
15701
15897
|
...rest
|
|
15702
|
-
}) =>
|
|
15703
|
-
format
|
|
15704
|
-
|
|
15705
|
-
|
|
15706
|
-
|
|
15707
|
-
|
|
15708
|
-
|
|
15709
|
-
|
|
15898
|
+
}) => {
|
|
15899
|
+
const actualFormat = format || getFormatForRangePickerType(rangePickerType);
|
|
15900
|
+
return (0,jsx_runtime_namespaceObject.jsx)(DateRangePickerProvider, {
|
|
15901
|
+
format: actualFormat,
|
|
15902
|
+
openCalendarMode: openCalendarMode,
|
|
15903
|
+
showCalendarIcon: showCalendarIcon,
|
|
15904
|
+
showStatusArea: showStatusArea,
|
|
15905
|
+
rangePickerType: rangePickerType,
|
|
15906
|
+
...rest,
|
|
15907
|
+
children: (0,jsx_runtime_namespaceObject.jsx)(Content_DatePickerContent, {})
|
|
15908
|
+
});
|
|
15909
|
+
};
|
|
15710
15910
|
;// ./src/components/DateRangePicker/index.ts
|
|
15711
15911
|
|
|
15712
15912
|
;// ./src/components/Drawer/DrawerProvider.tsx
|
|
@@ -20351,17 +20551,49 @@ const SelectWidget = props => {
|
|
|
20351
20551
|
onChange,
|
|
20352
20552
|
onBlur,
|
|
20353
20553
|
onFocus,
|
|
20554
|
+
value,
|
|
20354
20555
|
onChangeOverride,
|
|
20355
|
-
|
|
20556
|
+
multiple
|
|
20356
20557
|
} = props;
|
|
20357
20558
|
const {
|
|
20358
20559
|
enumOptions = [],
|
|
20359
20560
|
enumDisabled = []
|
|
20360
20561
|
} = options;
|
|
20361
|
-
const
|
|
20562
|
+
const isMultiple = !!multiple || Array.isArray(value);
|
|
20563
|
+
const items = Array.isArray(enumOptions) ? enumOptions : [];
|
|
20362
20564
|
const handleChange = onChangeOverride ? onChangeOverride : value => {
|
|
20363
20565
|
onChange(value);
|
|
20364
20566
|
};
|
|
20567
|
+
const getSelectedItems = () => {
|
|
20568
|
+
if (isMultiple) {
|
|
20569
|
+
if (Array.isArray(value)) return value;
|
|
20570
|
+
if (value !== undefined) return [value];
|
|
20571
|
+
return [];
|
|
20572
|
+
}
|
|
20573
|
+
if (value === undefined || value === null) return [];
|
|
20574
|
+
const index = (0,external_rjsf_utils_namespaceObject.enumOptionsIndexForValue)(value, enumOptions);
|
|
20575
|
+
return index !== undefined ? [value] : [];
|
|
20576
|
+
};
|
|
20577
|
+
const selectedItems = getSelectedItems();
|
|
20578
|
+
const handleFormChange = newValue => {
|
|
20579
|
+
if (isMultiple) {
|
|
20580
|
+
const arrayValue = Array.isArray(newValue) ? newValue : [newValue];
|
|
20581
|
+
handleChange(arrayValue);
|
|
20582
|
+
} else {
|
|
20583
|
+
const singleValue = Array.isArray(newValue) ? newValue[0] : newValue;
|
|
20584
|
+
handleChange(singleValue);
|
|
20585
|
+
}
|
|
20586
|
+
};
|
|
20587
|
+
const handleTypeaheadChange = (changedValue, isAdded) => {
|
|
20588
|
+
if (isMultiple) {
|
|
20589
|
+
const currentSelected = Array.isArray(selectedItems) ? selectedItems : [];
|
|
20590
|
+
const newSelected = isAdded ? [...currentSelected, changedValue] : currentSelected.filter(item => item !== changedValue);
|
|
20591
|
+
handleFormChange(newSelected);
|
|
20592
|
+
} else {
|
|
20593
|
+
const newValue = isAdded ? changedValue : undefined;
|
|
20594
|
+
handleFormChange(newValue);
|
|
20595
|
+
}
|
|
20596
|
+
};
|
|
20365
20597
|
const handleBlur = ({
|
|
20366
20598
|
target
|
|
20367
20599
|
}) => onBlur(id, target && target.value);
|
|
@@ -20370,11 +20602,21 @@ const SelectWidget = props => {
|
|
|
20370
20602
|
}) => onFocus(id, target && target.value);
|
|
20371
20603
|
const onEmptyChange = isEmpty => {
|
|
20372
20604
|
if (isEmpty) {
|
|
20373
|
-
handleChange();
|
|
20605
|
+
handleChange(isMultiple ? [] : undefined);
|
|
20606
|
+
}
|
|
20607
|
+
};
|
|
20608
|
+
const onClearAll = () => {
|
|
20609
|
+
handleChange(isMultiple ? [] : undefined);
|
|
20610
|
+
};
|
|
20611
|
+
const onRemoveSelectedClick = removedValue => {
|
|
20612
|
+
if (isMultiple) {
|
|
20613
|
+
const currentSelected = Array.isArray(selectedItems) ? selectedItems : [];
|
|
20614
|
+
const newSelected = currentSelected.filter(item => item !== removedValue);
|
|
20615
|
+
handleChange(newSelected);
|
|
20616
|
+
} else {
|
|
20617
|
+
handleChange(undefined);
|
|
20374
20618
|
}
|
|
20375
20619
|
};
|
|
20376
|
-
const items = Array.isArray(enumOptions) ? enumOptions : [];
|
|
20377
|
-
const selectedItems = selectedIndex ? [items[Number(selectedIndex)].value] : [];
|
|
20378
20620
|
return (0,jsx_runtime_namespaceObject.jsx)("div", {
|
|
20379
20621
|
id: id,
|
|
20380
20622
|
onBlur: handleBlur,
|
|
@@ -20383,12 +20625,13 @@ const SelectWidget = props => {
|
|
|
20383
20625
|
width: "100%",
|
|
20384
20626
|
selectedItems: selectedItems,
|
|
20385
20627
|
isDisabled: disabled,
|
|
20386
|
-
name: name
|
|
20387
|
-
|
|
20388
|
-
,
|
|
20628
|
+
name: name,
|
|
20629
|
+
isMultiple: isMultiple,
|
|
20389
20630
|
placeholder: placeholder || undefined,
|
|
20390
|
-
onChange:
|
|
20631
|
+
onChange: handleTypeaheadChange,
|
|
20391
20632
|
onEmptyChange: onEmptyChange,
|
|
20633
|
+
onClearAll: onClearAll,
|
|
20634
|
+
onRemoveSelectedClick: onRemoveSelectedClick,
|
|
20392
20635
|
renderOption: ({
|
|
20393
20636
|
label,
|
|
20394
20637
|
input
|