@ssa-ui-kit/core 2.3.0 → 2.5.0

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.
Files changed (32) hide show
  1. package/dist/components/DatePicker/types.d.ts +1 -2
  2. package/dist/components/DateRangePicker/DateRangePicker.d.ts +1 -1
  3. package/dist/components/DateRangePicker/DateRangePickerContext.d.ts +2 -0
  4. package/dist/components/DateRangePicker/DateRangePickerProvider.d.ts +2 -0
  5. package/dist/components/DateRangePicker/components/Calendar.d.ts +1 -0
  6. package/dist/components/DateRangePicker/components/Content.d.ts +1 -0
  7. package/dist/components/DateRangePicker/components/DatesListWrapper.d.ts +10 -0
  8. package/dist/components/DateRangePicker/components/DaysView.d.ts +1 -0
  9. package/dist/components/DateRangePicker/components/Header.d.ts +1 -0
  10. package/dist/components/DateRangePicker/components/MonthsSwitch.d.ts +1 -0
  11. package/dist/components/DateRangePicker/components/MonthsView.d.ts +1 -0
  12. package/dist/components/DateRangePicker/components/Trigger.d.ts +1 -0
  13. package/dist/components/DateRangePicker/components/TriggerInput.d.ts +6 -0
  14. package/dist/components/DateRangePicker/components/YearsView.d.ts +1 -0
  15. package/dist/components/DateRangePicker/components/index.d.ts +9 -0
  16. package/dist/components/DateRangePicker/constants.d.ts +1 -0
  17. package/dist/components/DateRangePicker/helpers/ClassnameArray.d.ts +3 -0
  18. package/dist/components/DateRangePicker/helpers/index.d.ts +1 -0
  19. package/dist/components/DateRangePicker/hooks/index.d.ts +3 -0
  20. package/dist/components/DateRangePicker/hooks/useDatePickerMask.d.ts +10 -0
  21. package/dist/components/DateRangePicker/hooks/useDateRangePicker.d.ts +40 -0
  22. package/dist/components/DateRangePicker/hooks/useRangeHighlighting.d.ts +10 -0
  23. package/dist/components/DateRangePicker/styles.d.ts +34 -0
  24. package/dist/components/DateRangePicker/types.d.ts +35 -9
  25. package/dist/components/DateRangePicker/useDateRangePickerContext.d.ts +1 -0
  26. package/dist/components/DateRangePicker/utils/dates.d.ts +11 -0
  27. package/dist/components/DateRangePicker/utils/index.d.ts +1 -0
  28. package/dist/components/FormHelperText/types.d.ts +1 -0
  29. package/dist/index.js +1632 -386
  30. package/dist/index.js.map +1 -1
  31. package/dist/types/emotion.d.ts +1 -0
  32. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -943,6 +943,8 @@ const main = {
943
943
  // #ffffff
944
944
  greyLighter: 'rgba(238, 241, 247, 1)',
945
945
  // #eef1f7
946
+ greyLighter20: 'rgba(238, 241, 247, 0.2)',
947
+ //#eef1f766
946
948
  greyLighter40: 'rgba(238, 241, 247, 0.4)',
947
949
  //#eef1f766
948
950
  greyLighter60: 'rgba(238, 241, 247, 0.6)',
@@ -8592,10 +8594,11 @@ const CollapsibleNavBarPopover = ({
8592
8594
  padding: 0,
8593
8595
  background: navBarTheme === 'default' ? theme.colors.greyGraphite : '#F4F5F9',
8594
8596
  borderRadius: 5,
8595
- width: 85,
8597
+ minWidth: 85,
8596
8598
  '& > a': {
8597
8599
  color: navBarTheme === 'default' ? theme.colors.white : theme.colors.greyDarker80,
8598
8600
  padding: 5,
8601
+ whiteSpace: 'nowrap',
8599
8602
  fontSize: 12,
8600
8603
  fontWeight: navBarTheme === 'default' ? 400 : 500,
8601
8604
  '&.active': {
@@ -9447,11 +9450,6 @@ const DatePickerProvider = ({
9447
9450
  restHook.handleBlur(e);
9448
9451
  rest.onBlur?.(e);
9449
9452
  };
9450
- (0,external_react_namespaceObject.useEffect)(() => {
9451
- if (typeof rest.isOpenToggle === 'boolean') {
9452
- restHook.setIsOpen(current => !current);
9453
- }
9454
- }, [rest.isOpenToggle]);
9455
9453
  return (0,jsx_runtime_namespaceObject.jsx)(DatePickerContext.Provider, {
9456
9454
  value: {
9457
9455
  ...rest,
@@ -10056,205 +10054,367 @@ const DatePickerInner = ({
10056
10054
  format = DEFAULT_MASK_FORMAT,
10057
10055
  openCalendarMode = 'icon',
10058
10056
  showCalendarIcon = true,
10059
- isOpenToggle,
10060
10057
  ...rest
10061
10058
  }, inputRef) => (0,jsx_runtime_namespaceObject.jsx)(DatePickerProvider, {
10062
10059
  format: format,
10063
10060
  openCalendarMode: openCalendarMode,
10064
10061
  inputRef: inputRef,
10065
10062
  showCalendarIcon: showCalendarIcon,
10066
- isOpenToggle: isOpenToggle,
10067
10063
  ...rest,
10068
10064
  children: (0,jsx_runtime_namespaceObject.jsx)(DatePickerContent, {})
10069
10065
  });
10070
10066
  const DatePicker = /*#__PURE__*/(0,external_react_namespaceObject.forwardRef)(DatePickerInner);
10071
10067
  ;// ./src/components/DatePicker/index.ts
10072
10068
 
10073
- ;// ./src/components/Field/FieldProvider.ts
10074
-
10075
- const [FieldProvider, useFieldContext] = (0,hooks_namespaceObject.createSafeContext)('useFieldContext must be used within a FieldProvider');
10076
- ;// ./src/components/Field/FieldRoot.tsx
10077
-
10078
-
10079
-
10080
- const FieldRoot = ({
10081
- children,
10082
- ...props
10083
- }) => {
10084
- const {
10085
- disabled = false,
10086
- status = 'basic',
10087
- forwardFocus = true,
10088
- asChild = false,
10089
- ...divProps
10090
- } = props;
10091
- const Wrapper = asChild ? external_react_namespaceObject.Fragment : 'div';
10092
- const wrapperProps = asChild ? {} : divProps;
10093
- return (0,jsx_runtime_namespaceObject.jsx)(Wrapper, {
10094
- ...wrapperProps,
10095
- children: (0,jsx_runtime_namespaceObject.jsx)(FieldProvider, {
10096
- value: {
10097
- disabled,
10098
- status,
10099
- forwardFocus
10100
- },
10101
- children: children
10102
- })
10103
- });
10104
- };
10105
- ;// ./src/components/Field/FieldLabel.tsx
10106
-
10107
-
10108
-
10109
- const FieldLabel = ({
10110
- children,
10111
- ...props
10112
- }) => {
10113
- const ctx = useFieldContext();
10114
- return (0,jsx_runtime_namespaceObject.jsx)(Label_Label, {
10115
- isDisabled: ctx.disabled,
10116
- ...props,
10117
- children: children
10118
- });
10119
- };
10120
- ;// ./src/components/Field/FieldControl.tsx
10069
+ ;// ./src/components/DateRangePicker/constants.ts
10070
+ const constants_DEFAULT_MASK_FORMAT = 'mm/dd/yyyy';
10071
+ const constants_DEFAULT_MASK = '__/__/____';
10072
+ const constants_MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
10073
+ const constants_DATE_MIN = '01/01/1900';
10074
+ const constants_DATE_MAX = '01/01/2150';
10075
+ const constants_OUT_OF_RANGE = 'The date is out of the defined range';
10076
+ const constants_INVALID_DATE = 'Invalid date';
10077
+ const FULL_DATE_LENGTH = 10;
10078
+ ;// ./src/components/DateRangePicker/components/DatesListWrapper.tsx
10121
10079
 
10122
10080
 
10081
+ const DatesListWrapper = /*#__PURE__*/base_default()(Wrapper_Wrapper, true ? {
10082
+ target: "e10i52w40"
10083
+ } : 0)("flex-wrap:wrap;&>div.hover-range-from.date-hovered,&>div.hover-range-to.date-hovered{background:", ({
10084
+ theme
10085
+ }) => theme.colors.greyLighter, ";border-left:none;border-top-left-radius:6px;border-bottom-left-radius:6px;}&>div.hover-range-from:not(.selected-range-from, .date-hovered),&>div.hover-range-to:not(.selected-range-to, .date-hovered){background:", ({
10086
+ theme
10087
+ }) => theme.colors.greyLighter60, ";border-radius:0;}&>div.hover-range-from.selected-range-from::after,&>div.hover-range-from.date-hovered::after,&>div.hover-range-to.selected-range-to::after,&>div.hover-range-to.date-hovered::after{content:'';position:absolute;width:10px;height:40px;z-index:-1;background:", ({
10088
+ theme
10089
+ }) => theme.colors.greyLighter60, ";}&>div.hover-range-from.selected-range-from::after,&>div.hover-range-to.date-hovered::after{left:0;}&>div.hover-range-from.date-hovered::after,&>div.hover-range-to.selected-range-to::after{right:0;}&>div.hover-range-form.selected-range-from:has(~ div.date-hovered)::after,&>div.hover-range-to.selected-range-to:has(+ div.date-hovered)::after,&>div.date-hovered:has(+ div.selected-range-from)::after,&>div.hover-range-to.selected-range-to+div.date-hovered::after,&>div.date-hovered+div.selected-range-from::after{background:", ({
10090
+ theme
10091
+ }) => theme.colors.greyLighter, ";}" + ( true ? "" : 0));
10092
+ ;// ./src/components/DateRangePicker/styles.ts
10123
10093
 
10124
10094
 
10125
- const FieldControlBase = /*#__PURE__*/base_default()("div", true ? {
10126
- target: "e1lr2tz0"
10127
- } : 0)("display:flex;align-items:center;min-height:44px;height:auto;border-radius:8px;overflow:hidden;border:1px solid ", ({
10128
- status,
10095
+ const styles_DaysViewCell = /*#__PURE__*/base_default()(Wrapper_Wrapper, true ? {
10096
+ target: "e19l41fq2"
10097
+ } : 0)("position:relative;width:40px;height:40px;justify-content:center;font-size:14px;font-weight:500;border-radius:", ({
10098
+ isHighlighted
10099
+ }) => isHighlighted ? 0 : '6px', ";border:", ({
10100
+ theme,
10101
+ isCalendarDateNow
10102
+ }) => isCalendarDateNow ? `1px solid ${theme.colors.greyFocused}` : 'none', ";color:", ({
10103
+ theme,
10104
+ isCalendarDateSelected
10105
+ }) => isCalendarDateSelected ? theme.colors.white : theme.colors.greyDarker, ";background:", ({
10106
+ theme,
10107
+ isCalendarDateSelected
10108
+ }) => isCalendarDateSelected && `linear-gradient(247deg, ${theme.colors.blueLighter} 14.71%, ${theme.colors.blue} 85.29%)`, ";cursor:pointer;user-select:none;&[aria-disabled='true']{color:", ({
10129
10109
  theme
10130
- }) => {
10131
- if (status === 'error') return theme.colors.red;
10132
- if (status === 'success') return theme.colors.greenLighter;
10133
- return theme.colors.grey;
10134
- }, ";background:", ({
10135
- disabled,
10110
+ }) => theme.colors.grey, ";cursor:default;pointer-events:none;}&[aria-disabled='false']{background:", ({
10111
+ theme,
10112
+ isCalendarDateSelected,
10113
+ isHighlighted
10114
+ }) => isHighlighted && !isCalendarDateSelected && theme.colors.blueRoyal16, ";&:hover{background:", ({
10136
10115
  theme
10137
- }) => disabled ? theme.colors.greyLighter : theme.colors.white, ";&>*{background:transparent;}&:active,&:hover{background:", ({
10138
- disabled,
10116
+ }) => theme.colors.greyLighter, ";color:", ({
10139
10117
  theme
10140
- }) => disabled ? theme.colors.greyLighter : theme.colors.white, ";box-shadow:none;}&:hover{cursor:", ({
10141
- disabled
10142
- }) => disabled ? 'default' : 'pointer', ";}&:focus-within,&:active{border-color:", ({
10143
- status,
10144
- disabled,
10118
+ }) => theme.colors.greyDarker, ";}&::before{content:'';display:", ({
10119
+ isCalendarFirstDateSelected,
10120
+ isCalendarSecondDateSelected
10121
+ }) => isCalendarFirstDateSelected || isCalendarSecondDateSelected ? 'block' : 'none', ";position:absolute;width:10px;height:40px;left:", ({
10122
+ isCalendarSecondDateSelected
10123
+ }) => isCalendarSecondDateSelected ? '0' : 'auto', ";right:", ({
10124
+ isCalendarFirstDateSelected
10125
+ }) => isCalendarFirstDateSelected ? '0' : 'auto', ";z-index:-1;background:", ({
10145
10126
  theme
10146
- }) => {
10147
- if (disabled) return theme.colors.grey;
10148
- if (status === 'error') return theme.colors.red;
10149
- if (status === 'success') return theme.colors.greenLighter;
10150
- return theme.colors.blueRoyal;
10151
- }, ";}" + ( true ? "" : 0));
10152
- const isForwardRefComponent = component => {
10153
- if (typeof component.type === 'object' && component.type.$$typeof?.toString() === 'Symbol(react.forward_ref)') {
10154
- return true;
10127
+ }) => theme.colors.blueRoyal16, ";}}&:hover{border:", ({
10128
+ theme,
10129
+ isCalendarDateNow
10130
+ }) => isCalendarDateNow && `1px solid ${theme.colors.greyFocused}`, ";}" + ( true ? "" : 0));
10131
+ const styles_YearsViewCell = /*#__PURE__*/base_default()("div", true ? {
10132
+ target: "e19l41fq1"
10133
+ } : 0)("display:flex;justify-content:center;position:relative;align-items:center;width:70px;height:40px;border-radius:", ({
10134
+ isCalendarFirstDateSelected,
10135
+ isCalendarSecondDateSelected
10136
+ }) => isCalendarFirstDateSelected || isCalendarSecondDateSelected ? '6px' : 0, ";font-size:14px;font-weight:500px;user-select:none;cursor:pointer;color:", ({
10137
+ theme,
10138
+ isCalendarYear,
10139
+ isCalendarFirstDateSelected,
10140
+ isCalendarSecondDateSelected
10141
+ }) => (isCalendarYear || isCalendarFirstDateSelected || isCalendarSecondDateSelected) && theme.colors.white, ";background:", ({
10142
+ theme,
10143
+ isCalendarYear,
10144
+ isCalendarFirstDateSelected,
10145
+ isCalendarSecondDateSelected
10146
+ }) => isCalendarYear || isCalendarFirstDateSelected || isCalendarSecondDateSelected ? `linear-gradient(247.37deg, ${theme.colors.blueLighter} 14.71%, ${theme.colors.blue} 85.29%)` : 'none', ";background:", ({
10147
+ theme,
10148
+ isHighlighted,
10149
+ isCalendarYear
10150
+ }) => isHighlighted && !isCalendarYear && theme.colors.blueRoyal16, ";&:hover{background:", ({
10151
+ theme
10152
+ }) => theme.colors.greyLighter, ";color:", ({
10153
+ theme
10154
+ }) => theme.colors.greyDarker, ";border-radius:6px;}&::before{content:'';display:", ({
10155
+ isCalendarFirstDateSelected,
10156
+ isCalendarSecondDateSelected
10157
+ }) => isCalendarFirstDateSelected || isCalendarSecondDateSelected ? 'block' : 'none', ";position:absolute;width:10px;height:40px;left:", ({
10158
+ isCalendarSecondDateSelected
10159
+ }) => isCalendarSecondDateSelected ? '0' : 'auto', ";right:", ({
10160
+ isCalendarFirstDateSelected
10161
+ }) => isCalendarFirstDateSelected ? '0' : 'auto', ";z-index:-1;background:", ({
10162
+ theme
10163
+ }) => theme.colors.blueRoyal16, ";}" + ( true ? "" : 0));
10164
+ const styles_MonthsViewCell = /*#__PURE__*/base_default()("div", true ? {
10165
+ target: "e19l41fq0"
10166
+ } : 0)("display:flex;justify-content:center;position:relative;align-items:center;width:99px;height:40px;border-radius:", ({
10167
+ isCalendarFirstDateSelected,
10168
+ isCalendarSecondDateSelected
10169
+ }) => isCalendarFirstDateSelected || isCalendarSecondDateSelected ? '6px' : 0, ";font-size:14px;font-weight:500;cursor:pointer;color:", ({
10170
+ theme,
10171
+ isCalendarMonth,
10172
+ isCalendarFirstDateSelected,
10173
+ isCalendarSecondDateSelected
10174
+ }) => (isCalendarMonth || isCalendarFirstDateSelected || isCalendarSecondDateSelected) && theme.colors.white, ";user-select:none;background:", ({
10175
+ theme,
10176
+ isCalendarMonth,
10177
+ isCalendarFirstDateSelected,
10178
+ isCalendarSecondDateSelected
10179
+ }) => 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:", ({
10180
+ theme
10181
+ }) => theme.colors.greyDarker, ";background:", ({
10182
+ theme
10183
+ }) => theme.colors.grey, ";}&[aria-disabled='false']{background:", ({
10184
+ theme,
10185
+ isHighlighted,
10186
+ isCalendarMonth,
10187
+ isCalendarSecondDateSelected
10188
+ }) => isHighlighted && !isCalendarMonth && !isCalendarSecondDateSelected && theme.colors.blueRoyal16, ";&:hover{background:", ({
10189
+ theme
10190
+ }) => theme.colors.greyLighter, ";color:", ({
10191
+ theme
10192
+ }) => theme.colors.greyDarker, ";}&::before{content:'';display:", ({
10193
+ isCalendarFirstDateSelected,
10194
+ isCalendarSecondDateSelected
10195
+ }) => isCalendarFirstDateSelected || isCalendarSecondDateSelected ? 'block' : 'none', ";position:absolute;width:10px;height:40px;left:", ({
10196
+ isCalendarSecondDateSelected
10197
+ }) => isCalendarSecondDateSelected ? '0' : 'auto', ";right:", ({
10198
+ isCalendarFirstDateSelected
10199
+ }) => isCalendarFirstDateSelected ? '0' : 'auto', ";z-index:-1;background:", ({
10200
+ theme
10201
+ }) => theme.colors.blueRoyal16, ";}}" + ( true ? "" : 0));
10202
+ ;// ./src/components/DateRangePicker/utils/dates.ts
10203
+
10204
+ const dates_getDaysForCalendarMonth = date => {
10205
+ if (!date) {
10206
+ return [];
10155
10207
  }
10156
- return false;
10157
- };
10158
- const FieldControl = /*#__PURE__*/external_react_default().forwardRef(function FieldControl({
10159
- children,
10160
- controlRef,
10161
- ...props
10162
- }, ref) {
10163
- const ctx = useFieldContext();
10164
- const baseProps = {
10165
- ...props,
10166
- ...ctx
10167
- };
10168
- const internalRef = (0,external_react_namespaceObject.useRef)(null);
10169
- let _children = typeof children === 'function' ? children(ctx) : children;
10170
- if (ctx.forwardFocus && /*#__PURE__*/(0,external_react_namespaceObject.isValidElement)(_children) && isForwardRefComponent(_children)) {
10171
- const setRef = defaultRef => element => {
10172
- internalRef.current = element;
10173
- if (defaultRef) {
10174
- if (typeof defaultRef === 'function') {
10175
- defaultRef(element);
10176
- } else {
10177
- defaultRef.current = element;
10178
- }
10179
- }
10180
- };
10181
- _children = /*#__PURE__*/(0,external_react_namespaceObject.cloneElement)(_children, {
10182
- ref: setRef(children.ref)
10208
+ const firstDayOfMonth = external_luxon_namespaceObject.DateTime.fromJSDate(date).startOf('month');
10209
+ const firstDayOfCal = firstDayOfMonth.startOf('week');
10210
+ const lastDayOfMonth = firstDayOfMonth.endOf('month');
10211
+ const lastDayOfCal = lastDayOfMonth.endOf('week');
10212
+ const days = [firstDayOfCal.toJSDate()];
10213
+ let temp = firstDayOfCal;
10214
+ while (temp.toMillis() < lastDayOfCal.toMillis() && days.length < 42) {
10215
+ temp = temp.plus({
10216
+ days: 1
10183
10217
  });
10218
+ days.push(temp.toJSDate());
10184
10219
  }
10185
- return (0,jsx_runtime_namespaceObject.jsx)(FieldControlBase, {
10186
- ...baseProps,
10187
- ref: ref,
10188
- onClick: event => {
10189
- baseProps.onClick?.(event);
10190
- if (controlRef) {
10191
- controlRef.current?.focus?.();
10192
- } else if (internalRef.current) {
10193
- internalRef.current?.focus?.();
10194
- }
10195
- },
10196
- children: _children
10197
- });
10198
- });
10199
- ;// ./src/components/Field/FieldDescription.tsx
10200
-
10201
-
10202
-
10203
- const FieldDescription = ({
10204
- children
10205
- }) => {
10206
- const ctx = useFieldContext();
10207
- if (ctx.status !== 'basic') {
10208
- return null;
10220
+ while (days.length < 42) {
10221
+ temp = temp.plus({
10222
+ days: 1
10223
+ });
10224
+ days.push(temp.toJSDate());
10209
10225
  }
10210
- return (0,jsx_runtime_namespaceObject.jsx)(FormHelperText_FormHelperText, {
10211
- status: "basic",
10212
- children: children
10213
- });
10226
+ return days;
10214
10227
  };
10215
- ;// ./src/components/Field/FieldError.tsx
10216
-
10217
-
10218
-
10219
- const FieldError = ({
10220
- children
10221
- }) => {
10222
- const ctx = useFieldContext();
10223
- if (ctx.status !== 'error') {
10224
- return null;
10228
+ const dates_getWeekDays = () => {
10229
+ const firstDayOfMonth = external_luxon_namespaceObject.DateTime.fromJSDate(new Date()).startOf('month');
10230
+ const firstDayOfWeek = firstDayOfMonth.startOf('week');
10231
+ const lastDayOfWeek = firstDayOfMonth.endOf('week');
10232
+ const days = [firstDayOfWeek.toFormat('ccccc')];
10233
+ let temp = firstDayOfWeek;
10234
+ while (temp.toMillis() < lastDayOfWeek.toMillis()) {
10235
+ temp = temp.plus({
10236
+ days: 1
10237
+ });
10238
+ days.push(temp.toFormat('ccccc'));
10225
10239
  }
10226
- return (0,jsx_runtime_namespaceObject.jsx)(FormHelperText_FormHelperText, {
10227
- status: "error",
10228
- children: children
10229
- });
10240
+ days.pop();
10241
+ return days;
10230
10242
  };
10231
- ;// ./src/components/Field/FieldSuccess.tsx
10243
+ const dates_getYearsList = props => {
10244
+ const {
10245
+ yearsFrom = 1900,
10246
+ yearsCount = 250
10247
+ } = props || {};
10248
+ return Array.from({
10249
+ length: yearsCount
10250
+ }, (value, index) => yearsFrom + index);
10251
+ };
10252
+ const dates_processDate = (dateParts, yearMin, yearMax) => {
10253
+ const yearMinStr = yearMin.toString();
10254
+ const yearMaxStr = yearMax.toString();
10255
+ const {
10256
+ day,
10257
+ month,
10258
+ year
10259
+ } = dateParts;
10260
+ if (typeof month === 'string' && month.length === 2) {
10261
+ const monthN = Number(month);
10262
+ if (monthN < 1 || monthN > 12) {
10263
+ return false;
10264
+ }
10265
+ }
10266
+ if (typeof day === 'string' && day.length === 2) {
10267
+ const dayN = Number(day);
10268
+ if (dayN < 1 || dayN > 31) {
10269
+ return false;
10270
+ }
10271
+ }
10272
+ if (typeof year === 'string' && year.length > 0) {
10273
+ const yearN = Number(year);
10274
+ const yearMinPart = Number(yearMinStr.slice(0, year.length));
10275
+ const yearMaxPart = Number(yearMaxStr.slice(0, year.length));
10276
+ if (yearN < yearMinPart || yearN > yearMaxPart) {
10277
+ return false;
10278
+ }
10279
+ }
10280
+ return true;
10281
+ };
10282
+ ;// ./src/components/DateRangePicker/DateRangePickerContext.tsx
10232
10283
 
10233
10284
 
10234
10285
 
10235
- const FieldSuccess = ({
10236
- children
10237
- }) => {
10238
- const ctx = useFieldContext();
10239
- if (ctx.status !== 'success') {
10240
- return null;
10286
+ const DateRangePickerContext = /*#__PURE__*/(0,external_react_namespaceObject.createContext)({
10287
+ format: constants_DEFAULT_MASK_FORMAT,
10288
+ name: '',
10289
+ nameFrom: '',
10290
+ nameTo: '',
10291
+ maskOptions: {},
10292
+ openCalendarMode: 'icon',
10293
+ inputFromRef: {
10294
+ current: null
10295
+ },
10296
+ inputToRef: {
10297
+ current: null
10298
+ },
10299
+ inputProps: {},
10300
+ isOpen: false,
10301
+ isOpenState: false,
10302
+ calendarType: 'days',
10303
+ inputValueFrom: undefined,
10304
+ inputValueTo: undefined,
10305
+ dateTime: [undefined, undefined],
10306
+ calendarViewDateTime: [undefined, undefined],
10307
+ dateMinParts: constants_DATE_MIN.split('/').map(Number),
10308
+ dateMaxParts: constants_DATE_MAX.split('/').map(Number),
10309
+ dateMinDT: external_luxon_namespaceObject.DateTime.fromFormat(constants_DATE_MIN, constants_DEFAULT_MASK_FORMAT),
10310
+ dateMaxDT: external_luxon_namespaceObject.DateTime.fromFormat(constants_DATE_MAX, constants_DEFAULT_MASK_FORMAT),
10311
+ formatIndexes: {
10312
+ day: 1,
10313
+ month: 0,
10314
+ year: 2
10315
+ },
10316
+ lastFocusedElement: 'from',
10317
+ currentCalendarViewDT: external_luxon_namespaceObject.DateTime.now().set({
10318
+ day: 1
10319
+ }),
10320
+ currentIndex: 0,
10321
+ handleSetIsOpen: () => {
10322
+ // no-op
10323
+ },
10324
+ handleToggleOpen: () => {
10325
+ // no-op
10326
+ },
10327
+ setIsOpen: () => {
10328
+ // no-op
10329
+ },
10330
+ setCalendarType: () => {
10331
+ // no-op
10332
+ },
10333
+ setCalendarViewDateTime: () => {
10334
+ // no-op
10335
+ },
10336
+ setDateTime: () => {
10337
+ // no-op
10338
+ },
10339
+ setLastFocusedElement: () => {
10340
+ // no-op
10241
10341
  }
10242
- return (0,jsx_runtime_namespaceObject.jsx)(FormHelperText_FormHelperText, {
10243
- status: "success",
10244
- children: children
10245
- });
10342
+ });
10343
+ ;// ./src/components/DateRangePicker/useDateRangePickerContext.tsx
10344
+
10345
+
10346
+ const useDateRangePickerContext = () => (0,external_react_namespaceObject.useContext)(DateRangePickerContext);
10347
+ ;// ./src/components/DateRangePicker/helpers/ClassnameArray.ts
10348
+ class ClassnameArray extends Array {
10349
+ toggle(className, condition) {
10350
+ const index = this.indexOf(className);
10351
+ if (condition) {
10352
+ if (index === -1) {
10353
+ this.push(className);
10354
+ }
10355
+ } else {
10356
+ if (index > -1) {
10357
+ this.splice(index, 1);
10358
+ }
10359
+ }
10360
+ return this;
10361
+ }
10362
+ }
10363
+ ;// ./src/components/DateRangePicker/hooks/useRangeHighlighting.ts
10364
+
10365
+
10366
+
10367
+ const useRangeHighlighting = () => {
10368
+ const [hoveredDate, setHoveredDate] = (0,external_react_namespaceObject.useState)(null);
10369
+ const {
10370
+ dateTime,
10371
+ lastFocusedElement
10372
+ } = useDateRangePickerContext();
10373
+ const handleDateHover = currentDT => {
10374
+ setHoveredDate(currentDT);
10375
+ };
10376
+ const getClassNames = (currentDT, {
10377
+ isCalendarFirstDateSelected,
10378
+ isCalendarSecondDateSelected
10379
+ }) => {
10380
+ const classNames = new ClassnameArray();
10381
+ let isHoverRangeHighlightFrom = false;
10382
+ let isHoverRangeHighlightTo = false;
10383
+ if (hoveredDate !== null) {
10384
+ if (dateTime[0] && lastFocusedElement === 'from' && hoveredDate < dateTime[0]) {
10385
+ isHoverRangeHighlightFrom = currentDT >= hoveredDate && currentDT <= dateTime[0];
10386
+ }
10387
+ if (dateTime[1] && lastFocusedElement === 'to' && hoveredDate > dateTime[1]) {
10388
+ isHoverRangeHighlightTo = currentDT <= hoveredDate && currentDT >= dateTime[1];
10389
+ }
10390
+ }
10391
+ classNames.toggle('hover-range-from', isHoverRangeHighlightFrom);
10392
+ classNames.toggle('hover-range-to', isHoverRangeHighlightTo);
10393
+ classNames.toggle('selected-range-from', isCalendarFirstDateSelected);
10394
+ classNames.toggle('selected-range-to', isCalendarSecondDateSelected);
10395
+ classNames.toggle('date-hovered', hoveredDate?.toISODate() === currentDT.toISODate());
10396
+ return classNames.values().toArray();
10397
+ };
10398
+ const isHighlightDate = currentDT => {
10399
+ if (dateTime[0] && dateTime[1]) {
10400
+ return currentDT > dateTime[0] && currentDT < dateTime[1];
10401
+ } else if (dateTime[0] && hoveredDate) {
10402
+ return currentDT > dateTime[0] && currentDT < hoveredDate;
10403
+ } else if (dateTime[1] && hoveredDate) {
10404
+ return currentDT < dateTime[1] && currentDT > hoveredDate;
10405
+ }
10406
+ return false;
10407
+ };
10408
+ return {
10409
+ handleDateHover,
10410
+ getClassNames,
10411
+ isHighlightDate,
10412
+ hoveredDate
10413
+ };
10246
10414
  };
10247
- ;// ./src/components/DateRangePicker/constants.ts
10248
- const constants_DEFAULT_MASK_FORMAT = 'mm/dd/yyyy';
10249
- const constants_DEFAULT_MASK = '__/__/____';
10250
- const constants_MONTHS = (/* unused pure expression or super */ null && (['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']));
10251
- const constants_DATE_MIN = '01/01/1900';
10252
- const constants_DATE_MAX = '01/01/2150';
10253
- const constants_OUT_OF_RANGE = 'The date is out of the defined range';
10254
- const constants_INVALID_DATE = 'Invalid date';
10255
- ;// ./src/components/DateRangePicker/DateRangePicker.tsx
10415
+ ;// ./src/components/DateRangePicker/components/DaysView.tsx
10416
+ function components_DaysView_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)."; }
10256
10417
 
10257
- function DateRangePicker_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)."; }
10258
10418
 
10259
10419
 
10260
10420
 
@@ -10262,234 +10422,1320 @@ function DateRangePicker_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tri
10262
10422
 
10263
10423
 
10264
10424
 
10265
- // keep the same place for datepicker (from / to)
10266
- // don't close the datepicker while switching between from / to
10267
- // add errors (date to less than date from...)
10268
- // add a logic to reset date to when date to less than date from
10269
- // create subcomponents
10270
- // hover daterange effect for the datepicker (from design)
10271
10425
 
10272
- var DateRangePicker_ref = true ? {
10273
- name: "mwgsbg",
10274
- styles: "& input{border:none !important;}"
10426
+ var components_DaysView_ref = true ? {
10427
+ name: "hisq2i",
10428
+ styles: "padding-left:9px"
10275
10429
  } : 0;
10276
- var DateRangePicker_ref2 = true ? {
10277
- name: "jpxugn",
10278
- styles: "margin:0 14px"
10430
+ var components_DaysView_ref2 = true ? {
10431
+ name: "yzljcr",
10432
+ styles: "width:40px;height:40px;justify-content:center;font-size:12px;font-weight:600;cursor:default;user-select:none"
10279
10433
  } : 0;
10280
- var DateRangePicker_ref3 = true ? {
10281
- name: "ud49p1",
10282
- styles: "color:inherit;&::first-letter{text-transform:uppercase;}"
10434
+ var components_DaysView_ref3 = true ? {
10435
+ name: "hisq2i",
10436
+ styles: "padding-left:9px"
10283
10437
  } : 0;
10284
- const DateRangePicker = ({
10285
- format = constants_DEFAULT_MASK_FORMAT,
10286
- openCalendarMode = 'both',
10287
- name,
10288
- label,
10289
- value,
10290
- defaultValue,
10291
- ...rest
10292
- }) => {
10293
- const theme = (0,react_namespaceObject.useTheme)();
10294
- // const [_value, _setValue] = useState(value || []);
10295
- const formContext = (0,external_react_hook_form_namespaceObject.useFormContext)();
10296
- const [currentStatus, setCurrentStatus] = (0,external_react_namespaceObject.useState)(rest.status);
10297
- const errorsFrom = formContext.formState.errors[`${name}From`]?.message;
10298
- const errorsTo = formContext.formState.errors[`${name}To`]?.message;
10299
- const errorMessage = [errorsFrom, errorsTo].filter(Boolean);
10438
+ const DaysView_DaysView = () => {
10439
+ const weekDays = dates_getWeekDays();
10300
10440
  const {
10301
- disabled
10302
- } = rest;
10303
- const [fromOpenToggle, setFromOpenToggle] = (0,external_react_namespaceObject.useState)();
10304
- const [toOpenToggle, setToOpenToggle] = (0,external_react_namespaceObject.useState)();
10305
- const [changedDate, setChangedDate] = (0,external_react_namespaceObject.useState)([null, null]);
10306
- const [lastFocusedElement, setLastFocusedElement] = (0,external_react_namespaceObject.useState)('from');
10307
- const [valueFrom, valueTo] = value || [];
10308
- const [defaultValueFrom, defaultValueTo] = defaultValue || [];
10309
- const datepickerFromRef = (0,external_react_namespaceObject.useRef)(null);
10310
- const datepickerToRef = (0,external_react_namespaceObject.useRef)(null);
10311
-
10312
- // const datepickerFromAdditionalProps = {};
10313
- // const datepickerToAdditionalProps = {};
10314
-
10315
- // useEffect(() => {
10316
- // _setValue(value || []);
10317
- // }, [value]);
10318
-
10319
- (0,external_react_namespaceObject.useEffect)(() => {
10320
- setCurrentStatus(rest.status);
10321
- }, [rest.status]);
10322
- (0,external_react_namespaceObject.useEffect)(() => {
10323
- if (errorMessage.length) {
10324
- setCurrentStatus('error');
10325
- } else {
10326
- setCurrentStatus(rest.status || 'basic');
10327
- }
10328
- }, [errorMessage]);
10329
- const toggleOpen = () => {
10330
- if (lastFocusedElement === 'from') {
10331
- setFromOpenToggle(current => !current);
10332
- setTimeout(() => datepickerFromRef.current?.focus(), 5);
10333
- } else {
10334
- setToOpenToggle(current => !current);
10335
- setTimeout(() => datepickerToRef.current?.focus(), 5);
10336
- }
10337
- };
10338
- const handleToggleOpen = e => {
10339
- const tagName = e.currentTarget.tagName.toLowerCase();
10340
- if (openCalendarMode === 'both' || openCalendarMode === 'input' && tagName === 'input' || openCalendarMode === 'icon' && tagName === 'button') {
10341
- toggleOpen();
10342
- }
10343
- if (tagName === 'input' && rest.inputProps?.inputProps?.onClick) {
10344
- rest.inputProps.inputProps.onClick(e);
10345
- }
10346
- };
10347
- const handleFocus = e => {
10441
+ dateTime,
10442
+ calendarViewDateTime,
10443
+ dateMinDT,
10444
+ dateMaxDT,
10445
+ lastFocusedElement,
10446
+ currentCalendarViewDT,
10447
+ setCalendarViewDateTime,
10448
+ setDateTime,
10449
+ setIsOpen
10450
+ } = useDateRangePickerContext();
10451
+ const currentDate = currentCalendarViewDT.toJSDate();
10452
+ const currentMonth = currentDate?.getMonth();
10453
+ const dates = dates_getDaysForCalendarMonth(currentDate);
10454
+ const nowDate = external_luxon_namespaceObject.DateTime.fromJSDate(new Date()).toFormat('D');
10455
+ const {
10456
+ handleDateHover,
10457
+ getClassNames,
10458
+ isHighlightDate
10459
+ } = useRangeHighlighting();
10460
+ const handleDaySelect = event => {
10348
10461
  const {
10349
- name
10350
- } = e.currentTarget;
10351
- setLastFocusedElement(name.endsWith('From') ? 'from' : 'to');
10352
- rest.inputProps?.inputProps?.onFocus?.(e);
10353
- };
10354
- const onChangeFrom = date => {
10355
- const newDate = date || null;
10356
- if (newDate !== changedDate?.[0]) {
10357
- const changedData = [newDate, changedDate ? changedDate[1] : null];
10358
- setChangedDate(changedData);
10359
- if (!changedDate?.[1]) {
10360
- setLastFocusedElement('to');
10361
- setToOpenToggle(true);
10362
- }
10363
- rest.onChange?.(changedData);
10364
- }
10365
- };
10366
- const onChangeTo = date => {
10367
- const newDate = date || null;
10368
- if (changedDate[0] && newDate) {
10369
- const selectedDateFromDT = external_luxon_namespaceObject.DateTime.fromJSDate(changedDate[0]);
10370
- const selectedDateToDT = external_luxon_namespaceObject.DateTime.fromJSDate(newDate);
10371
- if (selectedDateFromDT > selectedDateToDT) {
10372
- const changedData = [newDate, null];
10373
- setChangedDate(changedData);
10374
-
10375
- // const dateStr = DateTime.fromJSDate(newDate).toFormat(
10376
- // format.replace('mm', 'MM'),
10377
- // );
10378
- // _setValue([dateStr, _value[1] === undefined ? '' : undefined]);
10379
- // _setValue([dateStr, undefined]);
10380
- datepickerToRef.current?.focus();
10381
- rest.onChange?.(changedData);
10382
- return;
10462
+ target
10463
+ } = event;
10464
+ const selectedDay = Number(target.innerHTML);
10465
+ const isEnabled = target.getAttribute('aria-disabled') === 'false';
10466
+ if (isEnabled) {
10467
+ const newDate = currentCalendarViewDT.set({
10468
+ day: selectedDay
10469
+ });
10470
+ const newDateTuple = lastFocusedElement === 'from' ? [newDate, dateTime[1]] : [dateTime[0], newDate];
10471
+ setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, dateTime[1] ? calendarViewDateTime?.[1] : newDate] : [dateTime[0] ? calendarViewDateTime?.[0] : newDate, newDate]);
10472
+ setDateTime(newDateTuple);
10473
+ if (newDateTuple[0] && newDateTuple[1]) {
10474
+ setIsOpen(false);
10383
10475
  }
10384
10476
  }
10385
- if (newDate !== changedDate?.[1]) {
10386
- const changedData = [changedDate ? changedDate[0] : null, newDate];
10387
- setChangedDate(changedData);
10388
- datepickerToRef.current?.focus();
10389
- rest.onChange?.(changedData);
10390
- }
10391
10477
  };
10392
-
10393
- // TODO: change status dynamically
10394
- return (0,jsx_runtime_namespaceObject.jsxs)(FieldRoot, {
10395
- status: currentStatus,
10396
- disabled: rest.disabled,
10397
- children: [(0,jsx_runtime_namespaceObject.jsx)(FieldLabel, {
10398
- htmlFor: lastFocusedElement === 'from' ? `${name}From` : `${name}To`,
10399
- children: label
10400
- }), (0,jsx_runtime_namespaceObject.jsx)(FieldControl, {
10401
- children: (0,jsx_runtime_namespaceObject.jsxs)(Wrapper_Wrapper, {
10402
- css: DateRangePicker_ref,
10403
- children: [(0,jsx_runtime_namespaceObject.jsx)(DatePicker, {
10404
- format: format,
10405
- openCalendarMode: openCalendarMode,
10406
- isOpenToggle: fromOpenToggle,
10407
- name: `${name}From`,
10408
- value: valueFrom,
10409
- defaultValue: defaultValueFrom,
10410
- label: '',
10411
- showCalendarIcon: false,
10412
- ...rest,
10413
- ref: datepickerFromRef,
10414
- onChange: onChangeFrom,
10415
- highlightDates: {
10416
- enabled: true,
10417
- mode: 'dateFrom',
10418
- otherDate: changedDate[1]
10419
- },
10420
- inputProps: {
10421
- showStatusIcon: false,
10422
- ...rest.inputProps,
10423
- inputProps: {
10424
- ...rest.inputProps?.inputProps,
10425
- onFocus: handleFocus,
10426
- onClick: handleToggleOpen
10427
- }
10478
+ return (0,jsx_runtime_namespaceObject.jsxs)((external_react_default()).Fragment, {
10479
+ children: [(0,jsx_runtime_namespaceObject.jsx)(Wrapper_Wrapper, {
10480
+ css: components_DaysView_ref,
10481
+ children: weekDays.map((weekDay, index) => (0,jsx_runtime_namespaceObject.jsx)(Wrapper_Wrapper, {
10482
+ css: components_DaysView_ref2,
10483
+ children: weekDay
10484
+ }, `week-day-${weekDay}-${index}`))
10485
+ }), (0,jsx_runtime_namespaceObject.jsx)(DatesListWrapper, {
10486
+ css: components_DaysView_ref3,
10487
+ onClick: handleDaySelect,
10488
+ children: dates.map((currentDate, index) => {
10489
+ const currentDT = external_luxon_namespaceObject.DateTime.fromJSDate(currentDate);
10490
+ const calendarDate = currentDT.toFormat('D');
10491
+ const calendarDay = currentDate.getDate();
10492
+ const calendarMonth = currentDate.getMonth();
10493
+ const ariaLabel = currentDT.toLocaleString(external_luxon_namespaceObject.DateTime.DATE_HUGE);
10494
+ const isCalendarDateNow = nowDate === calendarDate;
10495
+ const isCalendarMonth = currentMonth === calendarMonth;
10496
+ const isCalendarFirstDateSelected = calendarDate === dateTime[0]?.toFormat('D');
10497
+ const isCalendarSecondDateSelected = calendarDate === dateTime[1]?.toFormat('D');
10498
+ const isCalendarDateSelected = isCalendarFirstDateSelected || isCalendarSecondDateSelected;
10499
+ let isAriaDisabled = false;
10500
+ if (dateMinDT && dateMaxDT) {
10501
+ isAriaDisabled = currentDT < dateMinDT || currentDT > dateMaxDT || !isCalendarMonth;
10502
+ } else {
10503
+ if (dateMinDT) {
10504
+ isAriaDisabled = currentDT < dateMinDT || !isCalendarMonth;
10428
10505
  }
10429
- }), (0,jsx_runtime_namespaceObject.jsx)(Icon_Icon, {
10430
- name: "carrot-right",
10431
- size: 18,
10432
- color: theme.colors.greyDarker80,
10433
- css: DateRangePicker_ref2
10434
- }), (0,jsx_runtime_namespaceObject.jsx)(DatePicker, {
10435
- format: format,
10436
- openCalendarMode: openCalendarMode,
10437
- isOpenToggle: toOpenToggle,
10438
- name: `${name}To`,
10439
- value: valueTo,
10440
- defaultValue: defaultValueTo,
10441
- label: '',
10442
- showCalendarIcon: false,
10443
- ...rest,
10444
- ref: datepickerToRef,
10445
- onChange: onChangeTo,
10446
- highlightDates: {
10447
- enabled: true,
10448
- mode: 'dateTo',
10449
- otherDate: changedDate[0]
10450
- },
10451
- inputProps: {
10452
- showStatusIcon: false,
10453
- ...rest.inputProps,
10454
- inputProps: {
10455
- ...rest.inputProps?.inputProps,
10456
- onFocus: handleFocus,
10457
- onClick: handleToggleOpen
10458
- }
10506
+ if (dateMaxDT) {
10507
+ isAriaDisabled = currentDT > dateMaxDT || !isCalendarMonth;
10459
10508
  }
10460
- }), (0,jsx_runtime_namespaceObject.jsx)(Button_Button, {
10461
- endIcon: (0,jsx_runtime_namespaceObject.jsx)(Icon_Icon, {
10462
- name: "calendar",
10463
- size: 16,
10464
- color: disabled ? theme.colors.grey : theme.colors.greyDarker
10465
- }),
10466
- "data-testid": 'daterangepicker-button',
10467
- onClick: handleToggleOpen,
10468
- variant: "tertiary",
10469
- "aria-label": "Calendar",
10470
- isDisabled: disabled,
10471
- css: /*#__PURE__*/(0,react_namespaceObject.css)({
10472
- padding: 0,
10473
- margin: '0 8px 0 14px',
10474
- cursor: openCalendarMode === 'input' || disabled ? 'default' : 'pointer',
10475
- '&:focus::before': {
10476
- display: 'none'
10477
- }
10478
- }, true ? "" : 0, true ? "" : 0)
10479
- })]
10509
+ }
10510
+ const classNames = getClassNames(currentDT, {
10511
+ isCalendarFirstDateSelected,
10512
+ isCalendarSecondDateSelected
10513
+ });
10514
+ return (0,jsx_runtime_namespaceObject.jsx)(styles_DaysViewCell, {
10515
+ "aria-disabled": isAriaDisabled,
10516
+ "aria-label": ariaLabel,
10517
+ "data-day": calendarDate,
10518
+ isCalendarDateNow: isCalendarDateNow,
10519
+ isCalendarDateSelected: isCalendarDateSelected,
10520
+ isCalendarFirstDateSelected: isCalendarFirstDateSelected,
10521
+ isCalendarSecondDateSelected: isCalendarSecondDateSelected,
10522
+ isHighlighted: isHighlightDate(currentDT),
10523
+ className: classNames.join(' '),
10524
+ onMouseEnter: () => handleDateHover(currentDT),
10525
+ onMouseLeave: () => handleDateHover(null),
10526
+ children: calendarDay
10527
+ }, `day-${currentDate.getFullYear()}-${currentDate.getMonth()}-${currentDate.getDate()}-${index}`);
10480
10528
  })
10481
- }), (0,jsx_runtime_namespaceObject.jsx)(FieldDescription, {
10482
- children: rest.helperText
10483
- }), (0,jsx_runtime_namespaceObject.jsx)(FieldError, {
10484
- children: errorMessage ? errorMessage.map((error, index) => (0,jsx_runtime_namespaceObject.jsx)("span", {
10485
- css: DateRangePicker_ref3,
10486
- children: error
10487
- }, `error-${index}`)) : rest.helperText
10488
- }), (0,jsx_runtime_namespaceObject.jsx)(FieldSuccess, {
10489
- children: rest.helperText
10490
10529
  })]
10491
10530
  });
10492
10531
  };
10532
+ ;// ./src/components/DateRangePicker/components/MonthsView.tsx
10533
+ function components_MonthsView_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)."; }
10534
+
10535
+
10536
+
10537
+
10538
+
10539
+
10540
+
10541
+ var components_MonthsView_ref = true ? {
10542
+ name: "icns00",
10543
+ styles: "padding-top:10px"
10544
+ } : 0;
10545
+ const MonthsView_MonthsView = () => {
10546
+ const {
10547
+ dateTime,
10548
+ calendarViewDateTime,
10549
+ dateMinDT,
10550
+ dateMaxDT,
10551
+ lastFocusedElement,
10552
+ currentCalendarViewDT,
10553
+ setCalendarType,
10554
+ setCalendarViewDateTime,
10555
+ onMonthChange
10556
+ } = useDateRangePickerContext();
10557
+ const {
10558
+ handleDateHover,
10559
+ getClassNames,
10560
+ isHighlightDate
10561
+ } = useRangeHighlighting();
10562
+ const handleMonthSelect = event => {
10563
+ const {
10564
+ target
10565
+ } = event;
10566
+ if (target.getAttribute('aria-disabled') === null) {
10567
+ event.stopPropagation();
10568
+ event.preventDefault();
10569
+ return;
10570
+ }
10571
+ const selectedMonth = target.innerHTML;
10572
+ const monthNumber = constants_MONTHS.findIndex(month => month === selectedMonth);
10573
+ const newDate = currentCalendarViewDT?.set({
10574
+ month: monthNumber + 1
10575
+ });
10576
+ setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, calendarViewDateTime[1]] : [calendarViewDateTime[0], newDate]);
10577
+ if (newDate) {
10578
+ onMonthChange?.(newDate.toJSDate());
10579
+ }
10580
+ setCalendarType('days');
10581
+ };
10582
+ return (0,jsx_runtime_namespaceObject.jsx)(DatesListWrapper, {
10583
+ css: components_MonthsView_ref,
10584
+ onClick: handleMonthSelect,
10585
+ children: constants_MONTHS.map((month, index) => {
10586
+ const isCalendarMonth = currentCalendarViewDT ? currentCalendarViewDT.month === index + 1 : false;
10587
+ const currentMonthDT = external_luxon_namespaceObject.DateTime.fromObject({
10588
+ year: currentCalendarViewDT?.year,
10589
+ month: index + 1,
10590
+ day: 1
10591
+ });
10592
+ const isMinMonthReached = dateMinDT ? currentMonthDT.month < dateMinDT.month && currentMonthDT.year === dateMinDT.year : false;
10593
+ const isMaxMonthReached = dateMaxDT ? currentMonthDT.month > dateMaxDT.month && currentMonthDT.year === dateMaxDT.year : false;
10594
+ const isAriaDisabled = isMinMonthReached || isMaxMonthReached;
10595
+ const isCalendarFirstDateSelected = currentMonthDT.toFormat('yyyy-MM') === dateTime[0]?.toFormat('yyyy-MM');
10596
+ const isCalendarSecondDateSelected = currentMonthDT.toFormat('yyyy-MM') === dateTime[1]?.toFormat('yyyy-MM');
10597
+ const classNames = getClassNames(currentMonthDT, {
10598
+ isCalendarFirstDateSelected,
10599
+ isCalendarSecondDateSelected
10600
+ });
10601
+ return (0,jsx_runtime_namespaceObject.jsx)(styles_MonthsViewCell, {
10602
+ isCalendarMonth: isCalendarMonth,
10603
+ "aria-disabled": isAriaDisabled,
10604
+ "aria-label": `${month}, ${currentCalendarViewDT?.year}`,
10605
+ isCalendarFirstDateSelected: isCalendarFirstDateSelected,
10606
+ isCalendarSecondDateSelected: isCalendarSecondDateSelected,
10607
+ isHighlighted: isHighlightDate(currentMonthDT),
10608
+ className: classNames.join(' '),
10609
+ onMouseEnter: () => handleDateHover(currentMonthDT),
10610
+ onMouseLeave: () => handleDateHover(null),
10611
+ children: month
10612
+ }, month);
10613
+ })
10614
+ });
10615
+ };
10616
+ ;// ./src/components/DateRangePicker/components/YearsView.tsx
10617
+ function components_YearsView_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)."; }
10618
+
10619
+
10620
+
10621
+
10622
+
10623
+
10624
+
10625
+
10626
+ var components_YearsView_ref = true ? {
10627
+ name: "1lqam8u",
10628
+ styles: "overflow-y:auto;height:280px;align-content:flex-start"
10629
+ } : 0;
10630
+ const YearsView_YearsView = () => {
10631
+ const {
10632
+ dateTime,
10633
+ calendarViewDateTime,
10634
+ currentCalendarViewDT,
10635
+ dateMinParts,
10636
+ dateMaxParts,
10637
+ formatIndexes,
10638
+ lastFocusedElement,
10639
+ setCalendarType,
10640
+ setCalendarViewDateTime,
10641
+ onYearChange
10642
+ } = useDateRangePickerContext();
10643
+ const wrapper = (0,external_react_namespaceObject.useRef)(null);
10644
+ const yearsList = dates_getYearsList({
10645
+ yearsFrom: dateMinParts[formatIndexes['year']],
10646
+ yearsCount: dateMaxParts[formatIndexes['year']] - dateMinParts[formatIndexes['year']] + 1
10647
+ });
10648
+ const {
10649
+ handleDateHover,
10650
+ getClassNames,
10651
+ isHighlightDate
10652
+ } = useRangeHighlighting();
10653
+ (0,external_react_namespaceObject.useEffect)(() => {
10654
+ if (currentCalendarViewDT && wrapper.current) {
10655
+ wrapper.current.querySelector('[aria-current=date]')?.scrollIntoView({
10656
+ behavior: 'instant',
10657
+ block: 'center'
10658
+ });
10659
+ }
10660
+ }, [calendarViewDateTime, lastFocusedElement]);
10661
+ const handleYearSelect = event => {
10662
+ const {
10663
+ target
10664
+ } = event;
10665
+ const selectedYear = Number(target.innerHTML);
10666
+ const newDate = currentCalendarViewDT.set({
10667
+ year: selectedYear
10668
+ });
10669
+ setCalendarType('months');
10670
+ setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, calendarViewDateTime[1]] : [calendarViewDateTime[0], newDate]);
10671
+ if (newDate) {
10672
+ onYearChange?.(newDate.toJSDate());
10673
+ }
10674
+ };
10675
+ return (0,jsx_runtime_namespaceObject.jsx)(DatesListWrapper, {
10676
+ css: components_YearsView_ref,
10677
+ ref: wrapper,
10678
+ onClick: handleYearSelect,
10679
+ children: yearsList.map(year => {
10680
+ const additionalProps = {};
10681
+ const currentYearDT = external_luxon_namespaceObject.DateTime.fromObject({
10682
+ year,
10683
+ month: 1,
10684
+ day: 1
10685
+ });
10686
+ const isCalendarYear = currentCalendarViewDT ? currentCalendarViewDT.year === year : false;
10687
+ if (isCalendarYear) {
10688
+ additionalProps['aria-current'] = 'date';
10689
+ }
10690
+ const isCalendarFirstDateSelected = year.toString() === dateTime[0]?.toFormat('yyyy');
10691
+ const isCalendarSecondDateSelected = year.toString() === dateTime[1]?.toFormat('yyyy');
10692
+ const classNames = getClassNames(currentYearDT, {
10693
+ isCalendarFirstDateSelected,
10694
+ isCalendarSecondDateSelected
10695
+ });
10696
+ return (0,jsx_runtime_namespaceObject.jsx)(styles_YearsViewCell, {
10697
+ className: classNames.join(' '),
10698
+ isCalendarYear: isCalendarYear,
10699
+ isCalendarFirstDateSelected: isCalendarFirstDateSelected,
10700
+ isCalendarSecondDateSelected: isCalendarSecondDateSelected,
10701
+ isHighlighted: isHighlightDate(currentYearDT),
10702
+ onMouseEnter: () => handleDateHover(currentYearDT),
10703
+ onMouseLeave: () => handleDateHover(null),
10704
+ ...additionalProps,
10705
+ children: year
10706
+ }, `year-${year}`);
10707
+ })
10708
+ });
10709
+ };
10710
+ ;// ./src/components/DateRangePicker/components/MonthsSwitch.tsx
10711
+
10712
+ 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)."; }
10713
+
10714
+
10715
+
10716
+
10717
+
10718
+ var MonthsSwitch_ref = true ? {
10719
+ name: "9cmux7",
10720
+ styles: "width:72px;gap:24px"
10721
+ } : 0;
10722
+ const MonthsSwitch = () => {
10723
+ const {
10724
+ calendarType,
10725
+ calendarViewDateTime,
10726
+ dateMinDT,
10727
+ dateMaxDT,
10728
+ lastFocusedElement,
10729
+ setCalendarViewDateTime,
10730
+ onMonthChange
10731
+ } = useDateRangePickerContext();
10732
+ const theme = (0,react_namespaceObject.useTheme)();
10733
+ const isDayCalendarType = calendarType === 'days';
10734
+ const currentIndex = lastFocusedElement === 'from' ? 0 : 1;
10735
+ const currentCalendarViewDT = calendarViewDateTime[currentIndex] || external_luxon_namespaceObject.DateTime.now().set({
10736
+ day: 1
10737
+ });
10738
+ const isMinMonthReached = calendarViewDateTime ? currentCalendarViewDT?.month === dateMinDT.month && currentCalendarViewDT.year === dateMinDT.year : false;
10739
+ const isMaxMonthReached = calendarViewDateTime ? currentCalendarViewDT?.month === dateMaxDT.month && currentCalendarViewDT.year === dateMaxDT.year : false;
10740
+ const handlePreviousMonth = () => {
10741
+ const newDate = currentCalendarViewDT?.minus({
10742
+ month: 1
10743
+ });
10744
+ setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, calendarViewDateTime[1]] : [calendarViewDateTime[0], newDate]);
10745
+ if (newDate) {
10746
+ onMonthChange?.(newDate.toJSDate());
10747
+ }
10748
+ };
10749
+ const handleNextMonth = () => {
10750
+ const newDate = currentCalendarViewDT?.plus({
10751
+ month: 1
10752
+ });
10753
+ setCalendarViewDateTime(lastFocusedElement === 'from' ? [newDate, calendarViewDateTime[1]] : [calendarViewDateTime[0], newDate]);
10754
+ if (newDate) {
10755
+ onMonthChange?.(newDate.toJSDate());
10756
+ }
10757
+ };
10758
+ if (!isDayCalendarType) {
10759
+ return null;
10760
+ }
10761
+ return (0,jsx_runtime_namespaceObject.jsxs)(Wrapper_Wrapper, {
10762
+ css: MonthsSwitch_ref,
10763
+ children: [(0,jsx_runtime_namespaceObject.jsx)(Button_Button, {
10764
+ endIcon: (0,jsx_runtime_namespaceObject.jsx)(Icon_Icon, {
10765
+ name: "carrot-left",
10766
+ size: 14,
10767
+ tooltip: "Previous month",
10768
+ color: isMinMonthReached ? theme.colors.grey : theme.colors.greyDarker
10769
+ }),
10770
+ variant: 'tertiary',
10771
+ "aria-label": "Previous month",
10772
+ "data-testid": "previous-month",
10773
+ onClick: handlePreviousMonth,
10774
+ isDisabled: isMinMonthReached,
10775
+ css: /*#__PURE__*/(0,react_namespaceObject.css)({
10776
+ padding: 4,
10777
+ height: 32,
10778
+ cursor: isMinMonthReached ? 'default' : 'pointer',
10779
+ '&:focus::before': {
10780
+ display: 'none'
10781
+ }
10782
+ }, true ? "" : 0, true ? "" : 0)
10783
+ }), (0,jsx_runtime_namespaceObject.jsx)(Button_Button, {
10784
+ endIcon: (0,jsx_runtime_namespaceObject.jsx)(Icon_Icon, {
10785
+ name: "carrot-right",
10786
+ size: 14,
10787
+ tooltip: "Next month",
10788
+ color: isMaxMonthReached ? theme.colors.grey : theme.colors.greyDarker
10789
+ }),
10790
+ variant: 'tertiary',
10791
+ onClick: handleNextMonth,
10792
+ isDisabled: isMaxMonthReached,
10793
+ "aria-label": "Next month",
10794
+ "data-testid": "next-month",
10795
+ css: /*#__PURE__*/(0,react_namespaceObject.css)({
10796
+ padding: 4,
10797
+ height: 32,
10798
+ cursor: isMaxMonthReached ? 'default' : 'pointer',
10799
+ '&:focus::before': {
10800
+ display: 'none'
10801
+ }
10802
+ }, true ? "" : 0, true ? "" : 0)
10803
+ })]
10804
+ });
10805
+ };
10806
+ ;// ./src/components/DateRangePicker/components/Header.tsx
10807
+ function components_Header_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)."; }
10808
+
10809
+
10810
+
10811
+
10812
+ var components_Header_ref = true ? {
10813
+ name: "ugcp8m",
10814
+ styles: "display:flex;justify-content:space-between;width:100%;height:32px;margin-bottom:12px"
10815
+ } : 0;
10816
+ var Header_ref2 = true ? {
10817
+ name: "1bk2bba",
10818
+ styles: "padding:0;font-size:18px;font-weight:700;line-height:24px;height:32px;gap:16px;&:focus::before{display:none;}"
10819
+ } : 0;
10820
+ const Header_Header = () => {
10821
+ const {
10822
+ calendarType,
10823
+ currentCalendarViewDT,
10824
+ setCalendarType
10825
+ } = useDateRangePickerContext();
10826
+ const handleCalendarTypeChange = () => {
10827
+ setCalendarType(calendarType === 'days' ? 'years' : 'days');
10828
+ };
10829
+ return (0,jsx_runtime_namespaceObject.jsxs)(PopoverHeading, {
10830
+ css: components_Header_ref,
10831
+ as: 'div',
10832
+ children: [(0,jsx_runtime_namespaceObject.jsx)(Button_Button, {
10833
+ endIcon: (0,jsx_runtime_namespaceObject.jsx)(Icon_Icon, {
10834
+ name: calendarType === 'days' ? 'carrot-down' : 'carrot-up',
10835
+ size: 14,
10836
+ tooltip: ""
10837
+ }),
10838
+ variant: "tertiary",
10839
+ onClick: handleCalendarTypeChange,
10840
+ "data-testid": "calendar-type-change-button",
10841
+ css: Header_ref2,
10842
+ children: currentCalendarViewDT.toFormat('LLLL yyyy')
10843
+ }), (0,jsx_runtime_namespaceObject.jsx)(MonthsSwitch, {})]
10844
+ });
10845
+ };
10846
+ ;// ./src/components/DateRangePicker/components/Calendar.tsx
10847
+ function Calendar_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)."; }
10848
+
10849
+
10850
+
10851
+
10852
+
10853
+ var Calendar_ref = true ? {
10854
+ name: "14ggdrv",
10855
+ styles: "height:100%;display:flex;flex-direction:column;justify-content:space-between"
10856
+ } : 0;
10857
+ const Calendar_DatePickerCalendar = () => {
10858
+ const theme = (0,react_namespaceObject.useTheme)();
10859
+ const components = {
10860
+ days: DaysView_DaysView,
10861
+ months: MonthsView_MonthsView,
10862
+ years: YearsView_YearsView
10863
+ };
10864
+ const {
10865
+ calendarType,
10866
+ calendarClassname
10867
+ } = useDateRangePickerContext();
10868
+ const Component = components[calendarType];
10869
+ return (0,jsx_runtime_namespaceObject.jsxs)(PopoverContent, {
10870
+ className: ['popover', calendarClassname].filter(Boolean).join(' '),
10871
+ "data-testid": "daterangepicker-calendar",
10872
+ css: /*#__PURE__*/(0,react_namespaceObject.css)({
10873
+ background: theme.colors.white,
10874
+ boxShadow: `-4px 4px 14px 0px ${theme.colors.greyDarker14}`,
10875
+ borderRadius: 16,
10876
+ padding: 24,
10877
+ paddingTop: 16,
10878
+ width: 346,
10879
+ height: 370,
10880
+ alignItems: 'flex-start'
10881
+ }, true ? "" : 0, true ? "" : 0),
10882
+ children: [(0,jsx_runtime_namespaceObject.jsx)(Header_Header, {}), (0,jsx_runtime_namespaceObject.jsx)(PopoverDescription, {
10883
+ as: "div",
10884
+ css: Calendar_ref,
10885
+ children: (0,jsx_runtime_namespaceObject.jsx)(Component, {})
10886
+ })]
10887
+ });
10888
+ };
10889
+ ;// ./src/components/Field/FieldProvider.ts
10890
+
10891
+ const [FieldProvider, useFieldContext] = (0,hooks_namespaceObject.createSafeContext)('useFieldContext must be used within a FieldProvider');
10892
+ ;// ./src/components/Field/FieldRoot.tsx
10893
+
10894
+
10895
+
10896
+ const FieldRoot = ({
10897
+ children,
10898
+ ...props
10899
+ }) => {
10900
+ const {
10901
+ disabled = false,
10902
+ status = 'basic',
10903
+ forwardFocus = true,
10904
+ asChild = false,
10905
+ ...divProps
10906
+ } = props;
10907
+ const Wrapper = asChild ? external_react_namespaceObject.Fragment : 'div';
10908
+ const wrapperProps = asChild ? {} : divProps;
10909
+ return (0,jsx_runtime_namespaceObject.jsx)(Wrapper, {
10910
+ ...wrapperProps,
10911
+ children: (0,jsx_runtime_namespaceObject.jsx)(FieldProvider, {
10912
+ value: {
10913
+ disabled,
10914
+ status,
10915
+ forwardFocus
10916
+ },
10917
+ children: children
10918
+ })
10919
+ });
10920
+ };
10921
+ ;// ./src/components/Field/FieldLabel.tsx
10922
+
10923
+
10924
+
10925
+ const FieldLabel = ({
10926
+ children,
10927
+ ...props
10928
+ }) => {
10929
+ const ctx = useFieldContext();
10930
+ return (0,jsx_runtime_namespaceObject.jsx)(Label_Label, {
10931
+ isDisabled: ctx.disabled,
10932
+ ...props,
10933
+ children: children
10934
+ });
10935
+ };
10936
+ ;// ./src/components/Field/FieldControl.tsx
10937
+
10938
+
10939
+
10940
+
10941
+ const FieldControlBase = /*#__PURE__*/base_default()("div", true ? {
10942
+ target: "e1lr2tz0"
10943
+ } : 0)("display:flex;align-items:center;min-height:44px;height:auto;border-radius:8px;overflow:hidden;border:1px solid ", ({
10944
+ status,
10945
+ theme
10946
+ }) => {
10947
+ if (status === 'error') return theme.colors.red;
10948
+ if (status === 'success') return theme.colors.greenLighter;
10949
+ return theme.colors.grey;
10950
+ }, ";background:", ({
10951
+ disabled,
10952
+ theme
10953
+ }) => disabled ? theme.colors.greyLighter : theme.colors.white, ";&>*{background:transparent;}&:active,&:hover{background:", ({
10954
+ disabled,
10955
+ theme
10956
+ }) => disabled ? theme.colors.greyLighter : theme.colors.white, ";box-shadow:none;}&:hover{cursor:", ({
10957
+ disabled
10958
+ }) => disabled ? 'default' : 'pointer', ";}&:focus-within,&:active{border-color:", ({
10959
+ status,
10960
+ disabled,
10961
+ theme
10962
+ }) => {
10963
+ if (disabled) return theme.colors.grey;
10964
+ if (status === 'error') return theme.colors.red;
10965
+ if (status === 'success') return theme.colors.greenLighter;
10966
+ return theme.colors.blueRoyal;
10967
+ }, ";}" + ( true ? "" : 0));
10968
+ const isForwardRefComponent = component => {
10969
+ if (typeof component.type === 'object' && component.type.$$typeof?.toString() === 'Symbol(react.forward_ref)') {
10970
+ return true;
10971
+ }
10972
+ return false;
10973
+ };
10974
+ const FieldControl = /*#__PURE__*/external_react_default().forwardRef(function FieldControl({
10975
+ children,
10976
+ controlRef,
10977
+ ...props
10978
+ }, ref) {
10979
+ const ctx = useFieldContext();
10980
+ const baseProps = {
10981
+ ...props,
10982
+ ...ctx
10983
+ };
10984
+ const internalRef = (0,external_react_namespaceObject.useRef)(null);
10985
+ let _children = typeof children === 'function' ? children(ctx) : children;
10986
+ if (ctx.forwardFocus && /*#__PURE__*/(0,external_react_namespaceObject.isValidElement)(_children) && isForwardRefComponent(_children)) {
10987
+ const setRef = defaultRef => element => {
10988
+ internalRef.current = element;
10989
+ if (defaultRef) {
10990
+ if (typeof defaultRef === 'function') {
10991
+ defaultRef(element);
10992
+ } else {
10993
+ defaultRef.current = element;
10994
+ }
10995
+ }
10996
+ };
10997
+ _children = /*#__PURE__*/(0,external_react_namespaceObject.cloneElement)(_children, {
10998
+ ref: setRef(children.ref)
10999
+ });
11000
+ }
11001
+ return (0,jsx_runtime_namespaceObject.jsx)(FieldControlBase, {
11002
+ ...baseProps,
11003
+ ref: ref,
11004
+ onClick: event => {
11005
+ baseProps.onClick?.(event);
11006
+ if (controlRef) {
11007
+ controlRef.current?.focus?.();
11008
+ } else if (internalRef.current) {
11009
+ internalRef.current?.focus?.();
11010
+ }
11011
+ },
11012
+ children: _children
11013
+ });
11014
+ });
11015
+ ;// ./src/components/Field/FieldDescription.tsx
11016
+
11017
+
11018
+
11019
+ const FieldDescription = ({
11020
+ children
11021
+ }) => {
11022
+ const ctx = useFieldContext();
11023
+ if (ctx.status !== 'basic') {
11024
+ return null;
11025
+ }
11026
+ return (0,jsx_runtime_namespaceObject.jsx)(FormHelperText_FormHelperText, {
11027
+ status: "basic",
11028
+ children: children
11029
+ });
11030
+ };
11031
+ ;// ./src/components/Field/FieldError.tsx
11032
+
11033
+
11034
+
11035
+ const FieldError = ({
11036
+ children
11037
+ }) => {
11038
+ const ctx = useFieldContext();
11039
+ if (ctx.status !== 'error') {
11040
+ return null;
11041
+ }
11042
+ return (0,jsx_runtime_namespaceObject.jsx)(FormHelperText_FormHelperText, {
11043
+ status: "error",
11044
+ "data-testid": "field-error",
11045
+ children: children
11046
+ });
11047
+ };
11048
+ ;// ./src/components/Field/FieldSuccess.tsx
11049
+
11050
+
11051
+
11052
+ const FieldSuccess = ({
11053
+ children
11054
+ }) => {
11055
+ const ctx = useFieldContext();
11056
+ if (ctx.status !== 'success') {
11057
+ return null;
11058
+ }
11059
+ return (0,jsx_runtime_namespaceObject.jsx)(FormHelperText_FormHelperText, {
11060
+ status: "success",
11061
+ children: children
11062
+ });
11063
+ };
11064
+ ;// ./src/components/DateRangePicker/components/TriggerInput.tsx
11065
+ function TriggerInput_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)."; }
11066
+
11067
+
11068
+
11069
+
11070
+
11071
+
11072
+ const WithTriggerPopover = ({
11073
+ isEnabled,
11074
+ children
11075
+ }) => {
11076
+ return isEnabled ? (0,jsx_runtime_namespaceObject.jsx)(PopoverTrigger, {
11077
+ asChild: true,
11078
+ children: /*#__PURE__*/external_react_default().cloneElement(children, {
11079
+ ...children.props
11080
+ })
11081
+ }) : (/*#__PURE__*/external_react_default().cloneElement(children, {
11082
+ ...children.props
11083
+ }));
11084
+ };
11085
+ const TriggerInput = ({
11086
+ datepickerType,
11087
+ withPopover = false,
11088
+ onClick
11089
+ }) => {
11090
+ const {
11091
+ format,
11092
+ nameFrom,
11093
+ nameTo,
11094
+ inputFromRef,
11095
+ inputToRef,
11096
+ inputProps,
11097
+ disabled,
11098
+ helperText,
11099
+ setLastFocusedElement,
11100
+ onBlur: handleBlur
11101
+ } = useDateRangePickerContext();
11102
+ const formContext = (0,external_react_hook_form_namespaceObject.useFormContext)(); // Using FormProvider from react-hook-form
11103
+ const useFormResult = (0,external_react_hook_form_namespaceObject.useForm)();
11104
+ const currentName = datepickerType === 'from' ? nameFrom : nameTo;
11105
+ const hookFormResult = formContext ?? useFormResult;
11106
+ const {
11107
+ register,
11108
+ formState: {
11109
+ errors
11110
+ }
11111
+ } = hookFormResult;
11112
+ const {
11113
+ inputProps: inputElementProps,
11114
+ ...restInputProps
11115
+ } = inputProps || {};
11116
+ const fieldError = errors[currentName];
11117
+ const fieldStatus = fieldError?.message ? 'error' : 'basic';
11118
+ const handleFocus = e => {
11119
+ setLastFocusedElement(datepickerType);
11120
+ inputProps?.inputProps?.onFocus?.(e);
11121
+ };
11122
+ const handleOpen = event => {
11123
+ onClick?.(event);
11124
+ };
11125
+ return (0,jsx_runtime_namespaceObject.jsx)(WithTriggerPopover, {
11126
+ isEnabled: withPopover,
11127
+ children: (0,jsx_runtime_namespaceObject.jsx)(Input_Input, {
11128
+ name: currentName,
11129
+ placeholder: format,
11130
+ ref: datepickerType === 'from' ? inputFromRef : inputToRef,
11131
+ disabled: disabled,
11132
+ register: register,
11133
+ inputProps: {
11134
+ onBlur: handleBlur,
11135
+ onClick: handleOpen,
11136
+ onFocus: handleFocus,
11137
+ id: inputProps?.inputProps?.id || currentName,
11138
+ 'data-testid': `daterangepicker-input-${datepickerType}`,
11139
+ autoComplete: 'off',
11140
+ className: /*#__PURE__*/(0,css_namespaceObject.css)( true ? {
11141
+ name: "150iz59",
11142
+ styles: "border:none!important"
11143
+ } : 0),
11144
+ ...inputElementProps
11145
+ },
11146
+ showStatusIcon: false,
11147
+ errors: fieldError,
11148
+ status: fieldStatus,
11149
+ helperText: helperText,
11150
+ helperClassName: /*#__PURE__*/(0,css_namespaceObject.css)( true ? {
11151
+ name: "lhoo11",
11152
+ styles: "&>span::first-letter{text-transform:uppercase;}"
11153
+ } : 0),
11154
+ ...restInputProps
11155
+ })
11156
+ });
11157
+ };
11158
+ ;// ./src/components/DateRangePicker/components/Trigger.tsx
11159
+
11160
+ function Trigger_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)."; }
11161
+
11162
+
11163
+
11164
+
11165
+
11166
+
11167
+
11168
+
11169
+ var Trigger_ref = true ? {
11170
+ name: "jpxugn",
11171
+ styles: "margin:0 14px"
11172
+ } : 0;
11173
+ var Trigger_ref2 = true ? {
11174
+ name: "ud49p1",
11175
+ styles: "color:inherit;&::first-letter{text-transform:uppercase;}"
11176
+ } : 0;
11177
+ const Trigger = () => {
11178
+ const {
11179
+ nameFrom,
11180
+ nameTo,
11181
+ label,
11182
+ lastFocusedElement,
11183
+ disabled,
11184
+ status,
11185
+ helperText,
11186
+ openCalendarMode,
11187
+ isOpen,
11188
+ showCalendarIcon,
11189
+ triggerClassname,
11190
+ setIsOpen,
11191
+ handleToggleOpen
11192
+ } = useDateRangePickerContext();
11193
+ const theme = (0,react_namespaceObject.useTheme)();
11194
+ const formContext = (0,external_react_hook_form_namespaceObject.useFormContext)();
11195
+ const wrapperRef = (0,external_react_namespaceObject.useRef)(null);
11196
+ (0,hooks_namespaceObject.useClickOutside)(wrapperRef, event => {
11197
+ const {
11198
+ target
11199
+ } = event;
11200
+ const closestPopover = target.closest('div.popover');
11201
+ if (isOpen && !closestPopover) {
11202
+ setIsOpen(false);
11203
+ }
11204
+ });
11205
+ const errorsFrom = formContext.formState.errors[nameFrom]?.message;
11206
+ const errorsTo = formContext.formState.errors[nameTo]?.message;
11207
+ const errorMessage = [errorsFrom, errorsTo].filter(Boolean);
11208
+ return (0,jsx_runtime_namespaceObject.jsxs)(FieldRoot, {
11209
+ status: status,
11210
+ disabled: disabled,
11211
+ "data-testid": "daterangepicker",
11212
+ className: triggerClassname,
11213
+ children: [(0,jsx_runtime_namespaceObject.jsx)(FieldLabel, {
11214
+ htmlFor: lastFocusedElement === 'from' ? nameFrom : nameTo,
11215
+ children: label
11216
+ }), (0,jsx_runtime_namespaceObject.jsx)(FieldControl, {
11217
+ children: (0,jsx_runtime_namespaceObject.jsxs)(Wrapper_Wrapper, {
11218
+ ref: wrapperRef,
11219
+ children: [(0,jsx_runtime_namespaceObject.jsx)(TriggerInput, {
11220
+ withPopover: true,
11221
+ datepickerType: "from",
11222
+ onClick: () => {
11223
+ if (!isOpen) {
11224
+ setIsOpen(true);
11225
+ }
11226
+ }
11227
+ }), (0,jsx_runtime_namespaceObject.jsx)(Icon_Icon, {
11228
+ name: "carrot-right",
11229
+ size: 18,
11230
+ color: theme.colors.greyDarker80,
11231
+ css: Trigger_ref
11232
+ }), (0,jsx_runtime_namespaceObject.jsx)(TriggerInput, {
11233
+ datepickerType: "to",
11234
+ onClick: () => {
11235
+ if (!isOpen) {
11236
+ setIsOpen(true);
11237
+ }
11238
+ }
11239
+ }), showCalendarIcon && (0,jsx_runtime_namespaceObject.jsx)(Button_Button, {
11240
+ endIcon: (0,jsx_runtime_namespaceObject.jsx)(Icon_Icon, {
11241
+ name: "calendar",
11242
+ size: 16,
11243
+ color: disabled ? theme.colors.grey : theme.colors.greyDarker
11244
+ }),
11245
+ "data-testid": 'daterangepicker-button',
11246
+ onClick: handleToggleOpen,
11247
+ variant: "tertiary",
11248
+ "aria-label": "Calendar",
11249
+ isDisabled: disabled,
11250
+ css: /*#__PURE__*/(0,react_namespaceObject.css)({
11251
+ padding: 0,
11252
+ margin: '0 8px 0 14px',
11253
+ cursor: openCalendarMode === 'input' || disabled ? 'default' : 'pointer',
11254
+ '&:focus::before': {
11255
+ display: 'none'
11256
+ }
11257
+ }, true ? "" : 0, true ? "" : 0)
11258
+ })]
11259
+ })
11260
+ }), (0,jsx_runtime_namespaceObject.jsx)(FieldDescription, {
11261
+ children: helperText
11262
+ }), (0,jsx_runtime_namespaceObject.jsx)(FieldError, {
11263
+ children: errorMessage ? errorMessage.map((error, index) => (0,jsx_runtime_namespaceObject.jsx)("span", {
11264
+ css: Trigger_ref2,
11265
+ children: error
11266
+ }, `error-${index}`)) : helperText
11267
+ }), (0,jsx_runtime_namespaceObject.jsx)(FieldSuccess, {
11268
+ children: helperText
11269
+ })]
11270
+ });
11271
+ };
11272
+ ;// ./src/components/DateRangePicker/components/Content.tsx
11273
+
11274
+
11275
+
11276
+
11277
+
11278
+ const Content_DatePickerContent = () => {
11279
+ const {
11280
+ isOpen
11281
+ } = useDateRangePickerContext();
11282
+ return (0,jsx_runtime_namespaceObject.jsxs)(Popover, {
11283
+ interactionsEnabled: 'click',
11284
+ placement: 'top-start',
11285
+ open: isOpen,
11286
+ children: [(0,jsx_runtime_namespaceObject.jsx)(Trigger, {}), (0,jsx_runtime_namespaceObject.jsx)(Calendar_DatePickerCalendar, {})]
11287
+ });
11288
+ };
11289
+ ;// ./src/components/DateRangePicker/hooks/useDatePickerMask.tsx
11290
+
11291
+
11292
+
11293
+ const useDatePickerMask_useDatePickerMask = ({
11294
+ maskOptions,
11295
+ formatIndexes,
11296
+ dateMinParts,
11297
+ dateMaxParts
11298
+ }) => {
11299
+ const {
11300
+ mask = constants_DEFAULT_MASK,
11301
+ replacement = {
11302
+ _: /\d/
11303
+ },
11304
+ ...restMaskOptions
11305
+ } = maskOptions || {};
11306
+ const useMaskResult = (0,mask_namespaceObject.useMask)({
11307
+ mask,
11308
+ replacement,
11309
+ track: ({
11310
+ data,
11311
+ selectionStart,
11312
+ selectionEnd,
11313
+ value: currentValue
11314
+ }) => {
11315
+ if (mask === constants_DEFAULT_MASK) {
11316
+ const newValue = currentValue.slice(0, selectionStart) + data + currentValue.slice(selectionEnd);
11317
+ const updatedValue = (0,mask_namespaceObject.format)(newValue, {
11318
+ mask,
11319
+ replacement
11320
+ });
11321
+ const splittedValue = updatedValue.split('/');
11322
+ const isChecked = dates_processDate({
11323
+ day: splittedValue[formatIndexes['day']],
11324
+ month: splittedValue[formatIndexes['month']],
11325
+ year: splittedValue[formatIndexes['year']]
11326
+ }, dateMinParts[formatIndexes['year']], dateMaxParts[formatIndexes['year']]);
11327
+ return isChecked ? data : '';
11328
+ } else {
11329
+ return data;
11330
+ }
11331
+ },
11332
+ ...restMaskOptions
11333
+ });
11334
+ return useMaskResult;
11335
+ };
11336
+ ;// ./src/components/DateRangePicker/hooks/useDateRangePicker.ts
11337
+
11338
+
11339
+
11340
+
11341
+
11342
+
11343
+ const useDateRangePicker = ({
11344
+ dateMin = constants_DATE_MIN,
11345
+ dateMax = constants_DATE_MAX,
11346
+ name: _name,
11347
+ format = 'mm/dd/yyyy',
11348
+ maskOptions,
11349
+ isOpenState = false,
11350
+ defaultValue,
11351
+ onOpen,
11352
+ onClose,
11353
+ onError,
11354
+ onChange,
11355
+ ...rest
11356
+ }) => {
11357
+ const inputFromRef = (0,external_react_namespaceObject.useRef)(null);
11358
+ const inputToRef = (0,external_react_namespaceObject.useRef)(null);
11359
+ const [isOpen, setIsOpen] = (0,external_react_namespaceObject.useState)(isOpenState);
11360
+ const [status, setStatus] = (0,external_react_namespaceObject.useState)(rest.status);
11361
+ const previousOpenState = (0,external_react_namespaceObject.useRef)(isOpenState);
11362
+ const handleSetIsOpen = open => {
11363
+ setIsOpen(open);
11364
+ };
11365
+ const {
11366
+ clearErrors,
11367
+ setError,
11368
+ setValue,
11369
+ resetField,
11370
+ setFocus
11371
+ } = (0,external_react_hook_form_namespaceObject.useFormContext)();
11372
+ const nameFrom = `${_name}From`;
11373
+ const nameTo = `${_name}To`;
11374
+ const inputValueFrom = (0,external_react_hook_form_namespaceObject.useWatch)({
11375
+ name: nameFrom
11376
+ });
11377
+ const inputValueTo = (0,external_react_hook_form_namespaceObject.useWatch)({
11378
+ name: nameTo
11379
+ });
11380
+ const [dateTime, setDateTime] = (0,external_react_namespaceObject.useState)([undefined, undefined]);
11381
+ const [lastChangedDate, setLastChangedDate] = (0,external_react_namespaceObject.useState)([undefined, undefined]);
11382
+ const [lastFocusedElement, setLastFocusedElement] = (0,external_react_namespaceObject.useState)('from');
11383
+ const currentIndex = lastFocusedElement === 'from' ? 0 : 1;
11384
+ const currentName = lastFocusedElement === 'from' ? nameFrom : nameTo;
11385
+ const [dateTimeForChangeEvent, setDateTimeForChangeEvent] = (0,external_react_namespaceObject.useState)(undefined);
11386
+ const [currentError, setCurrentError] = (0,external_react_namespaceObject.useState)({
11387
+ date: null,
11388
+ error: null
11389
+ });
11390
+ const splittedFormat = format.split('/');
11391
+ const [formatIndexes, setFormatIndexes] = (0,external_react_namespaceObject.useState)({
11392
+ day: splittedFormat.findIndex(item => item === 'dd'),
11393
+ month: splittedFormat.findIndex(item => item === 'mm'),
11394
+ year: splittedFormat.findIndex(item => item === 'yyyy')
11395
+ });
11396
+ const [calendarType, setCalendarType] = (0,external_react_namespaceObject.useState)('days');
11397
+ const [calendarViewDateTime, setCalendarViewDateTime] = (0,external_react_namespaceObject.useState)([undefined, undefined]);
11398
+ const currentCalendarViewDT = calendarViewDateTime[currentIndex] || external_luxon_namespaceObject.DateTime.now().set({
11399
+ day: 1
11400
+ });
11401
+ const luxonFormat = format.replace('mm', 'MM');
11402
+ const dateMinParts = dateMin.split('/').map(Number);
11403
+ const dateMaxParts = dateMax.split('/').map(Number);
11404
+ const maskInputRef = useDatePickerMask_useDatePickerMask({
11405
+ maskOptions,
11406
+ dateMaxParts,
11407
+ dateMinParts,
11408
+ formatIndexes
11409
+ });
11410
+ const dateMaxDT = external_luxon_namespaceObject.DateTime.fromObject({
11411
+ year: dateMaxParts[formatIndexes['year']],
11412
+ month: dateMaxParts[formatIndexes['month']],
11413
+ day: dateMaxParts[formatIndexes['day']]
11414
+ });
11415
+ const dateMinDT = external_luxon_namespaceObject.DateTime.fromObject({
11416
+ year: dateMinParts[formatIndexes['year']],
11417
+ month: dateMinParts[formatIndexes['month']],
11418
+ day: dateMinParts[formatIndexes['day']]
11419
+ });
11420
+ const safeOnChange = newDateTime => {
11421
+ const _newDateTime = newDateTime ? newDateTime.startOf('day') : undefined;
11422
+ const _dateTimeForChangeEvent = dateTimeForChangeEvent ? dateTimeForChangeEvent.startOf('day') : undefined;
11423
+ if (_newDateTime?.toMillis() !== _dateTimeForChangeEvent?.toMillis()) {
11424
+ setDateTimeForChangeEvent(newDateTime);
11425
+ if (_newDateTime) {
11426
+ const _newDateTimeJS = _newDateTime.toJSDate();
11427
+ if (lastFocusedElement === 'from') {
11428
+ setLastChangedDate([_newDateTimeJS, lastChangedDate[1]]);
11429
+ onChange?.([_newDateTimeJS, lastChangedDate[1] || null]);
11430
+ } else {
11431
+ setLastChangedDate([lastChangedDate[0], _newDateTimeJS]);
11432
+ onChange?.([lastChangedDate[0] || null, _newDateTimeJS]);
11433
+ }
11434
+ } else {
11435
+ setLastChangedDate([lastFocusedElement === 'from' ? undefined : lastChangedDate[0], lastFocusedElement === 'to' ? undefined : lastChangedDate[1]]);
11436
+ onChange?.();
11437
+ }
11438
+ }
11439
+ };
11440
+
11441
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11442
+ const safeOnError = (date, error) => {
11443
+ if (currentError.date !== date && currentError.error !== error) {
11444
+ setCurrentError({
11445
+ date,
11446
+ error
11447
+ });
11448
+ onError?.(date, error);
11449
+ }
11450
+ };
11451
+ const processValue = (newValue, elementName) => {
11452
+ const currentElementType = elementName || lastFocusedElement;
11453
+ const currentName = currentElementType === 'from' ? nameFrom : nameTo;
11454
+ const newDateTime = typeof newValue === 'string' && newValue.length === FULL_DATE_LENGTH ? external_luxon_namespaceObject.DateTime.fromFormat(newValue, luxonFormat) : undefined;
11455
+ const newDateTimeIfInvalid = [currentElementType === 'from' ? undefined : dateTime?.[0], currentElementType === 'to' ? undefined : dateTime?.[1]];
11456
+ const newDateTimeIfValid = [currentElementType === 'from' ? newDateTime : dateTime?.[0], currentElementType === 'to' ? newDateTime : dateTime?.[1]];
11457
+ if (!newDateTime?.isValid) {
11458
+ const errorMessage = newDateTime?.invalidExplanation || constants_INVALID_DATE;
11459
+ setError(currentName, {
11460
+ message: errorMessage
11461
+ }, {
11462
+ shouldFocus: true
11463
+ });
11464
+ setStatus('error');
11465
+ setDateTime(newDateTimeIfInvalid);
11466
+ safeOnError?.(newValue, errorMessage);
11467
+ safeOnChange();
11468
+ } else if (newDateTime !== undefined) {
11469
+ if (newDateTime < dateMinDT || newDateTime > dateMaxDT) {
11470
+ const errorMessage = constants_OUT_OF_RANGE;
11471
+ setError(currentName, {
11472
+ message: errorMessage
11473
+ }, {
11474
+ shouldFocus: true
11475
+ });
11476
+ setStatus('error');
11477
+ setDateTime(newDateTimeIfInvalid);
11478
+ safeOnError?.(newValue, errorMessage);
11479
+ safeOnChange();
11480
+ } else {
11481
+ setDateTime(newDateTimeIfValid);
11482
+ clearErrors();
11483
+ setStatus('basic');
11484
+ safeOnError?.(null);
11485
+ safeOnChange?.(newDateTime);
11486
+ }
11487
+ }
11488
+ };
11489
+ const handleBlur = event => {
11490
+ event.preventDefault();
11491
+ const blurredValue = event.currentTarget.value;
11492
+ if (blurredValue.length > 0) {
11493
+ processValue(blurredValue);
11494
+ }
11495
+ };
11496
+ const processInputValue = (inputValue, elementName) => {
11497
+ const currentElementType = elementName || lastFocusedElement;
11498
+ const currentName = currentElementType === 'from' ? nameFrom : nameTo;
11499
+ if (typeof inputValue === 'string' && inputValue.length && inputValue.length < FULL_DATE_LENGTH) {
11500
+ setIsOpen(false);
11501
+ setTimeout(() => {
11502
+ maskInputRef.current.focus();
11503
+ }, 10);
11504
+ }
11505
+ let newDateTime;
11506
+ if (typeof inputValue === 'string' && inputValue.length === FULL_DATE_LENGTH) {
11507
+ newDateTime = external_luxon_namespaceObject.DateTime.fromFormat(inputValue, luxonFormat);
11508
+ setValue(currentName, inputValue);
11509
+ processValue(inputValue, elementName);
11510
+ }
11511
+ const newCalendarViewDateTime = newDateTime && newDateTime.isValid ? newDateTime : undefined;
11512
+ if (newCalendarViewDateTime) {
11513
+ if (newCalendarViewDateTime < dateMinDT) {
11514
+ const {
11515
+ year,
11516
+ month,
11517
+ day
11518
+ } = dateMinDT;
11519
+ newCalendarViewDateTime.set({
11520
+ year,
11521
+ month,
11522
+ day
11523
+ });
11524
+ }
11525
+ if (newCalendarViewDateTime > dateMaxDT) {
11526
+ const {
11527
+ year,
11528
+ month,
11529
+ day
11530
+ } = dateMaxDT;
11531
+ newCalendarViewDateTime.set({
11532
+ year,
11533
+ month,
11534
+ day
11535
+ });
11536
+ }
11537
+ setCalendarViewDateTime(currentElementType === 'from' ? [newCalendarViewDateTime, calendarViewDateTime[1]] : [calendarViewDateTime[0], newCalendarViewDateTime]);
11538
+ }
11539
+ };
11540
+ (0,external_react_namespaceObject.useEffect)(() => {
11541
+ processInputValue(lastFocusedElement === 'from' ? inputValueFrom : inputValueTo);
11542
+ }, [lastFocusedElement]);
11543
+ (0,external_react_namespaceObject.useEffect)(() => {
11544
+ if (inputValueFrom && inputValueFrom.length === FULL_DATE_LENGTH) {
11545
+ processInputValue(lastFocusedElement === 'from' ? inputValueFrom : inputValueTo);
11546
+ }
11547
+ }, [inputValueFrom]);
11548
+ (0,external_react_namespaceObject.useEffect)(() => {
11549
+ if (inputValueTo && inputValueTo.length === FULL_DATE_LENGTH) {
11550
+ processInputValue(lastFocusedElement === 'from' ? inputValueFrom : inputValueTo);
11551
+ }
11552
+ }, [inputValueTo]);
11553
+ (0,external_react_namespaceObject.useEffect)(() => {
11554
+ const currentIndex = lastFocusedElement === 'from' ? 0 : 1;
11555
+ const currentInputValue = currentIndex === 0 ? inputValueFrom : inputValueTo;
11556
+ if (dateTime?.[currentIndex]) {
11557
+ const newValue = dateTime[currentIndex].toFormat(luxonFormat);
11558
+ if (currentInputValue !== newValue) {
11559
+ setValue(currentName, newValue);
11560
+ }
11561
+ }
11562
+ }, [dateTime, lastFocusedElement, currentName]);
11563
+ (0,external_react_namespaceObject.useEffect)(() => {
11564
+ if (dateTime[0] && dateTime[1] && dateTime[0] > dateTime[1]) {
11565
+ resetField(nameFrom);
11566
+ resetField(nameTo);
11567
+ setDateTime([dateTime[1], undefined]);
11568
+ setLastChangedDate([dateTime[1].toJSDate(), undefined]);
11569
+ setValue(nameFrom, dateTime[1].toFormat(luxonFormat));
11570
+ setLastFocusedElement('to');
11571
+ setTimeout(() => {
11572
+ setFocus(nameTo, {
11573
+ shouldSelect: true
11574
+ });
11575
+ }, 50);
11576
+ setIsOpen(true);
11577
+ }
11578
+ }, [dateTime]);
11579
+ (0,external_react_namespaceObject.useEffect)(() => {
11580
+ if (previousOpenState.current !== isOpen) {
11581
+ if (isOpen) {
11582
+ onOpen?.();
11583
+ } else {
11584
+ onClose?.();
11585
+ setCalendarType('days');
11586
+ setCalendarViewDateTime([dateTime[0], dateTime[1]]);
11587
+ }
11588
+ previousOpenState.current = isOpen;
11589
+ }
11590
+ }, [isOpen]);
11591
+ (0,external_react_namespaceObject.useEffect)(() => {
11592
+ const splittedFormat = format.split('/');
11593
+ setFormatIndexes({
11594
+ day: splittedFormat.findIndex(item => item === 'dd'),
11595
+ month: splittedFormat.findIndex(item => item === 'mm'),
11596
+ year: splittedFormat.findIndex(item => item === 'yyyy')
11597
+ });
11598
+ }, [format]);
11599
+ (0,external_react_namespaceObject.useEffect)(() => {
11600
+ if (Array.isArray(rest.value)) {
11601
+ const newDateTimeFrom = typeof rest.value[0] === 'string' && rest.value[0].length === FULL_DATE_LENGTH ? external_luxon_namespaceObject.DateTime.fromFormat(rest.value[0], luxonFormat) : undefined;
11602
+ const newDateTimeTo = typeof rest.value[1] === 'string' && rest.value[1].length === FULL_DATE_LENGTH ? external_luxon_namespaceObject.DateTime.fromFormat(rest.value[1], luxonFormat) : undefined;
11603
+ const newDateTime = [newDateTimeFrom?.isValid ? newDateTimeFrom : undefined, newDateTimeTo?.isValid ? newDateTimeTo : undefined];
11604
+ setDateTime(newDateTime);
11605
+ setLastChangedDate([newDateTime[0]?.toJSDate(), newDateTime[1]?.toJSDate()]);
11606
+ setValue(nameFrom, newDateTime[0]?.toFormat(luxonFormat));
11607
+ setValue(nameTo, newDateTime[1]?.toFormat(luxonFormat));
11608
+ }
11609
+ }, [rest.value]);
11610
+ (0,external_react_namespaceObject.useEffect)(() => {
11611
+ setStatus(rest.status);
11612
+ }, [rest.status]);
11613
+ (0,external_react_namespaceObject.useEffect)(() => {
11614
+ if (lastChangedDate[0] || lastChangedDate[1]) {
11615
+ if (lastFocusedElement === 'from' && !lastChangedDate[1]) {
11616
+ setFocus(nameTo);
11617
+ }
11618
+ if (lastFocusedElement === 'to' && !lastChangedDate[0]) {
11619
+ setFocus(nameFrom);
11620
+ inputFromRef.current?.focus();
11621
+ }
11622
+ }
11623
+ }, [lastChangedDate]);
11624
+ (0,external_react_namespaceObject.useEffect)(() => {
11625
+ if (calendarViewDateTime[0] && !calendarViewDateTime[1]) {
11626
+ setCalendarViewDateTime([calendarViewDateTime[0], calendarViewDateTime[0]]);
11627
+ }
11628
+ if (calendarViewDateTime[1] && !calendarViewDateTime[0]) {
11629
+ setCalendarViewDateTime([calendarViewDateTime[1], calendarViewDateTime[1]]);
11630
+ }
11631
+ }, [calendarViewDateTime]);
11632
+ (0,external_react_namespaceObject.useEffect)(() => {
11633
+ if (isOpenState !== isOpen) {
11634
+ setIsOpen(isOpenState);
11635
+ }
11636
+ }, [isOpenState]);
11637
+ (0,external_react_namespaceObject.useEffect)(() => {
11638
+ if (defaultValue) {
11639
+ setValue(nameFrom, defaultValue[0]);
11640
+ setValue(nameTo, defaultValue[1]);
11641
+ }
11642
+ }, []);
11643
+ return {
11644
+ formatIndexes,
11645
+ dateMinParts,
11646
+ dateMaxParts,
11647
+ dateMinDT,
11648
+ dateMaxDT,
11649
+ dateTime,
11650
+ inputValueFrom,
11651
+ inputValueTo,
11652
+ calendarViewDateTime,
11653
+ maskInputRef,
11654
+ calendarType,
11655
+ lastChangedDate,
11656
+ luxonFormat,
11657
+ lastFocusedElement,
11658
+ nameFrom,
11659
+ nameTo,
11660
+ currentIndex,
11661
+ currentCalendarViewDT,
11662
+ isOpen,
11663
+ status,
11664
+ inputFromRef: (0,external_floating_ui_react_namespaceObject.useMergeRefs)([maskInputRef, inputFromRef]),
11665
+ inputToRef: (0,external_floating_ui_react_namespaceObject.useMergeRefs)([maskInputRef, inputToRef]),
11666
+ setIsOpen,
11667
+ handleSetIsOpen,
11668
+ setLastFocusedElement,
11669
+ safeOnChange,
11670
+ setCalendarType,
11671
+ setCalendarViewDateTime,
11672
+ setDateTime,
11673
+ handleBlur
11674
+ };
11675
+ };
11676
+ ;// ./src/components/DateRangePicker/DateRangePickerProvider.tsx
11677
+
11678
+
11679
+
11680
+ const DateRangePickerProvider = ({
11681
+ children,
11682
+ ...rest
11683
+ }) => {
11684
+ const {
11685
+ formatIndexes,
11686
+ inputFromRef,
11687
+ inputToRef,
11688
+ ...restHook
11689
+ } = useDateRangePicker({
11690
+ ...rest,
11691
+ isOpenState: rest.isOpenState
11692
+ });
11693
+ const handleBlur = e => {
11694
+ restHook.handleBlur(e);
11695
+ rest.onBlur?.(e);
11696
+ };
11697
+ const toggleOpen = () => {
11698
+ restHook.setIsOpen(current => !current);
11699
+ };
11700
+ const handleToggleOpen = e => {
11701
+ const tagName = e.currentTarget.tagName.toLowerCase();
11702
+ if (rest.openCalendarMode === 'both' || rest.openCalendarMode === 'input' && tagName === 'input' || rest.openCalendarMode === 'icon' && tagName === 'button') {
11703
+ toggleOpen();
11704
+ }
11705
+ if (tagName === 'input' && rest.inputProps?.inputProps?.onClick) {
11706
+ rest.inputProps.inputProps.onClick(e);
11707
+ }
11708
+ };
11709
+ return (0,jsx_runtime_namespaceObject.jsx)(DateRangePickerContext.Provider, {
11710
+ value: {
11711
+ ...rest,
11712
+ ...restHook,
11713
+ formatIndexes,
11714
+ inputFromRef,
11715
+ inputToRef,
11716
+ handleToggleOpen,
11717
+ onBlur: handleBlur
11718
+ },
11719
+ children: children
11720
+ });
11721
+ };
11722
+ ;// ./src/components/DateRangePicker/DateRangePicker.tsx
11723
+
11724
+
11725
+
11726
+
11727
+ const DateRangePicker = ({
11728
+ format = constants_DEFAULT_MASK_FORMAT,
11729
+ openCalendarMode = 'icon',
11730
+ showCalendarIcon = true,
11731
+ ...rest
11732
+ }) => (0,jsx_runtime_namespaceObject.jsx)(DateRangePickerProvider, {
11733
+ format: format,
11734
+ openCalendarMode: openCalendarMode,
11735
+ showCalendarIcon: showCalendarIcon,
11736
+ ...rest,
11737
+ children: (0,jsx_runtime_namespaceObject.jsx)(Content_DatePickerContent, {})
11738
+ });
10493
11739
  ;// ./src/components/DateRangePicker/index.ts
10494
11740
 
10495
11741
  ;// ./src/components/Drawer/DrawerProvider.tsx
@@ -12483,7 +13729,7 @@ const WithNestedTableRow = ({
12483
13729
  setIsCollapsed: setIsCollapsed,
12484
13730
  isSubHeader: isSubHeader,
12485
13731
  childRowsCount: childRowsCount,
12486
- children: /*#__PURE__*/(0,external_react_namespaceObject.cloneElement)(child)
13732
+ children: child
12487
13733
  });
12488
13734
  }
12489
13735
  });