@superdispatch/dates 0.25.1 → 0.26.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.
package/dist-web/index.js CHANGED
@@ -18,12 +18,10 @@ function setDefaultTimeZone(offset) {
18
18
  Settings.defaultZoneName = offset;
19
19
  } else {
20
20
  var zone = FixedOffsetZone.instance(offset);
21
-
22
21
  if (zone.isValid) {
23
22
  Settings.defaultZoneName = zone.name;
24
23
  }
25
24
  }
26
-
27
25
  return Settings.defaultZoneName;
28
26
  }
29
27
  function useDefaultTimeZone(offset) {
@@ -58,6 +56,7 @@ function DateConfigProvider(_ref) {
58
56
  });
59
57
  }
60
58
 
59
+ //
61
60
  // Config
62
61
  //
63
62
 
@@ -87,7 +86,9 @@ var DATE_DISPLAY_VARIANTS = {
87
86
  hour: 'numeric',
88
87
  minute: 'numeric'
89
88
  }
90
- }; //
89
+ };
90
+
91
+ //
91
92
  // Date Utils
92
93
  //
93
94
 
@@ -95,72 +96,57 @@ function toPrimitiveDateInput(input) {
95
96
  if (typeof input == 'number' || typeof input == 'string') {
96
97
  return input;
97
98
  }
98
-
99
99
  if (input instanceof Date || input instanceof DateTime) {
100
100
  return input.valueOf();
101
101
  }
102
-
103
102
  return NaN;
104
103
  }
105
104
  function parseDate(input) {
106
105
  var {
107
106
  format
108
107
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultDateConfig;
109
-
110
108
  if (input instanceof DateTime) {
111
109
  var {
112
110
  defaultZone
113
111
  } = Settings;
114
-
115
112
  if (!defaultZone.equals(input.zone)) {
116
113
  return input.setZone(defaultZone);
117
114
  }
118
-
119
115
  return input;
120
116
  }
121
-
122
117
  if (input instanceof Date) {
123
118
  return DateTime.fromJSDate(input);
124
119
  }
125
-
126
120
  if (typeof input === 'number') {
127
121
  return DateTime.fromMillis(input);
128
122
  }
129
-
130
123
  if (typeof input == 'string') {
131
124
  switch (format) {
132
125
  case 'DateISO':
133
126
  case 'DateTimeISO':
134
127
  return DateTime.fromISO(input);
135
-
136
128
  default:
137
129
  return DateTime.fromFormat(input, DATE_FORMATS[format]);
138
130
  }
139
131
  }
140
-
141
132
  return DateTime.invalid('invalid input');
142
133
  }
143
134
  function stringifyDate(input) {
144
135
  var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultDateConfig;
145
136
  var date = parseDate(input, config);
146
-
147
137
  if (date.isValid) {
148
138
  var {
149
139
  format
150
140
  } = config;
151
-
152
141
  switch (format) {
153
142
  case 'DateISO':
154
143
  return date.toISODate();
155
-
156
144
  case 'DateTimeISO':
157
145
  return date.toISO();
158
-
159
146
  default:
160
147
  return date.toFormat(DATE_FORMATS[format]);
161
148
  }
162
149
  }
163
-
164
150
  return null;
165
151
  }
166
152
  function formatDate(input, _ref) {
@@ -170,24 +156,19 @@ function formatDate(input, _ref) {
170
156
  } = _ref;
171
157
  var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultDateConfig;
172
158
  var date = parseDate(input, config);
173
-
174
159
  if (!date.isValid) {
175
160
  return fallback;
176
161
  }
177
-
178
162
  return date.toLocaleString(DATE_DISPLAY_VARIANTS[variant]);
179
163
  }
180
-
181
164
  function formatUnit(unit) {
182
165
  switch (unit) {
183
166
  case 'months':
184
167
  return 'mo';
185
-
186
168
  default:
187
169
  return unit.charAt(0);
188
170
  }
189
171
  }
190
-
191
172
  function formatRelativeTime(input) {
192
173
  var {
193
174
  round = true,
@@ -200,36 +181,28 @@ function formatRelativeTime(input) {
200
181
  var base = baseOption == null ? DateTime.now() : parseDate(baseOption, config);
201
182
  var date = parseDate(input, config);
202
183
  var padding = paddingOption ? date < base ? -paddingOption : paddingOption : 0;
203
-
204
184
  function format(value, unit) {
205
185
  var isPast = Object.is(value, -0) || value < 0;
206
186
  var diff = Math.abs(!round ? value : Math.trunc(value));
207
187
  var formattedUnit = formatUnit(unit);
208
188
  return isPast ? "".concat(diff).concat(formattedUnit, " ago") : "in ".concat(diff).concat(formattedUnit);
209
189
  }
210
-
211
190
  function differ(unit) {
212
191
  return date.plus(padding).diff(base, unit).get(unit);
213
192
  }
214
-
215
193
  if (date.isValid && base.isValid) {
216
194
  var units = ['years', 'months', 'days', 'hours', 'minutes', 'seconds'];
217
-
218
195
  if (unitOption) {
219
196
  return format(differ(unitOption), unitOption);
220
197
  }
221
-
222
198
  for (var unit of units) {
223
199
  var diff = differ(unit);
224
-
225
200
  if (Math.abs(diff) >= 1) {
226
201
  return format(diff, unit);
227
202
  }
228
203
  }
229
-
230
204
  return format(0, 'seconds');
231
205
  }
232
-
233
206
  return fallback;
234
207
  }
235
208
  function toDatePayload(input) {
@@ -240,7 +213,9 @@ function toDatePayload(input) {
240
213
  dateValue,
241
214
  stringValue: stringifyDate(dateValue, config)
242
215
  };
243
- } //
216
+ }
217
+
218
+ //
244
219
  // Date Range Utils
245
220
  //
246
221
 
@@ -248,17 +223,14 @@ function toPrimitiveDateRangeInput(input) {
248
223
  if (!Array.isArray(input)) {
249
224
  return [undefined, undefined];
250
225
  }
251
-
252
226
  return [toPrimitiveDateInput(input[0]), toPrimitiveDateInput(input[1])];
253
227
  }
254
228
  function parseDateRange(input, config) {
255
229
  var start = null;
256
230
  var finish = null;
257
-
258
231
  if (Array.isArray(input)) {
259
232
  [start = null, finish = null] = input.map(value => parseDate(value, config)).filter(date => date.isValid).sort((a, b) => a.valueOf() - b.valueOf());
260
233
  }
261
-
262
234
  return [start, finish];
263
235
  }
264
236
  function stringifyDateRange(input, config) {
@@ -271,11 +243,9 @@ function formatDateRange(input, _ref2) {
271
243
  } = _ref2;
272
244
  var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultDateConfig;
273
245
  var [start, finish] = parseDateRange(input, config);
274
-
275
246
  if (!start) {
276
247
  return fallback;
277
248
  }
278
-
279
249
  var startVariant = !(finish !== null && finish !== void 0 && finish.hasSame(start, 'year')) ? 'Date' : 'ShortDate';
280
250
  var startText = formatDate(start, {
281
251
  variant: startVariant
@@ -300,14 +270,12 @@ function useDateTime(input, options) {
300
270
  var primitiveInput = toPrimitiveDateInput(input);
301
271
  return useMemo(() => {
302
272
  var date = parseDate(primitiveInput, config);
303
-
304
273
  if (process.env.NODE_ENV !== 'production') {
305
274
  if (!date.isValid && typeof primitiveInput === 'string') {
306
275
  // eslint-disable-next-line no-console
307
276
  console.error("[useDateTime] Failed to parse \"".concat(primitiveInput, "\" string with \"").concat(config.format, "\" format."));
308
277
  }
309
278
  }
310
-
311
279
  return date;
312
280
  }, [config, primitiveInput]);
313
281
  }
@@ -586,18 +554,20 @@ var useStyles = /*#__PURE__*/makeStyles(theme => ({
586
554
  todayButton: {}
587
555
  }), {
588
556
  name: 'SD-Calendar'
589
- }); //
557
+ });
558
+
559
+ //
590
560
  // Utility Types
591
561
  //
592
562
 
593
563
  //
594
564
  // Internal Utils
595
565
  //
566
+
596
567
  function toDayPickerModifier(config, modifier) {
597
568
  if (!modifier) {
598
569
  return undefined;
599
570
  }
600
-
601
571
  return localDate => {
602
572
  var dateValue = DateTime.fromObject({
603
573
  year: localDate.getFullYear(),
@@ -615,12 +585,10 @@ function toDayPickerModifier(config, modifier) {
615
585
  });
616
586
  };
617
587
  }
618
-
619
588
  function toDayPickerHandler(config, classes, initialTime, handler) {
620
589
  if (!handler) {
621
590
  return undefined;
622
591
  }
623
-
624
592
  return (localDate, modifiers) => {
625
593
  var dateValue = DateTime.fromObject({
626
594
  year: localDate.getFullYear(),
@@ -639,35 +607,35 @@ function toDayPickerHandler(config, classes, initialTime, handler) {
639
607
  stringValue: stringifyDate(dateValue, config)
640
608
  });
641
609
  };
642
- } //
610
+ }
611
+
612
+ //
643
613
  // Calendar
644
614
  //
645
615
 
646
-
647
616
  var Calendar = /*#__PURE__*/forwardRef((_ref, ref) => {
648
617
  var {
649
- footer,
650
- classes,
651
- direction,
652
- quickSelection,
653
- selectedDays,
654
- disabledDays,
655
- onDayClick,
656
- onDayKeyDown,
657
- onDayMouseEnter,
658
- onDayMouseLeave,
659
- onDayMouseDown,
660
- onDayMouseUp,
661
- onDayTouchEnd,
662
- onDayTouchStart,
663
- modifiers,
664
- highlightedDays,
665
- format: formatProp,
666
- initialTime: initialTimeInputProp,
667
- initialMonth: initialMonthInputProp
668
- } = _ref,
669
- dayPickerProps = _objectWithoutProperties(_ref, _excluded);
670
-
618
+ footer,
619
+ classes,
620
+ direction,
621
+ quickSelection,
622
+ selectedDays,
623
+ disabledDays,
624
+ onDayClick,
625
+ onDayKeyDown,
626
+ onDayMouseEnter,
627
+ onDayMouseLeave,
628
+ onDayMouseDown,
629
+ onDayMouseUp,
630
+ onDayTouchEnd,
631
+ onDayTouchStart,
632
+ modifiers,
633
+ highlightedDays,
634
+ format: formatProp,
635
+ initialTime: initialTimeInputProp,
636
+ initialMonth: initialMonthInputProp
637
+ } = _ref,
638
+ dayPickerProps = _objectWithoutProperties(_ref, _excluded);
671
639
  var styles = useStyles({
672
640
  classes
673
641
  });
@@ -679,15 +647,12 @@ var Calendar = /*#__PURE__*/forwardRef((_ref, ref) => {
679
647
  var [initialTime, initialMonth] = useMemo(() => {
680
648
  var time = initialTimeInput;
681
649
  var month = initialMonthInput;
682
-
683
650
  if (!month.isValid) {
684
651
  month = DateTime.local().startOf('month');
685
652
  }
686
-
687
653
  if (!time.isValid) {
688
654
  time = month;
689
655
  }
690
-
691
656
  return [time, new Date(month.year, month.month - 1, month.day, month.hour, month.minute, month.second, month.millisecond)];
692
657
  }, [initialTimeInput, initialMonthInput]);
693
658
  var wrapModifier = toDayPickerModifier.bind(null, config);
@@ -706,19 +671,16 @@ var Calendar = /*#__PURE__*/forwardRef((_ref, ref) => {
706
671
  return dateValue.day === dateValue.daysInMonth;
707
672
  })
708
673
  };
709
-
710
674
  if (modifiers) {
711
675
  for (var [key, modifier] of Object.entries(modifiers)) {
712
676
  dayPickerModifiers[key] = wrapModifier(modifier);
713
677
  }
714
678
  }
715
-
716
679
  if (highlightedDays) {
717
680
  for (var [_key, _modifier] of Object.entries(highlightedDays)) {
718
681
  dayPickerModifiers[styles[_key]] = wrapModifier(_modifier);
719
682
  }
720
683
  }
721
-
722
684
  return /*#__PURE__*/jsxs(Grid, {
723
685
  ref: ref,
724
686
  container: true,
@@ -816,41 +778,38 @@ var Popover = /*#__PURE__*/styled(Popover$1).withConfig({
816
778
  })([".MuiPaper-rounded{border:1px solid ", ";box-shadow:0px 0px 4px 0px rgba(0,0,0,0.05),0px 4px 8px 0px rgba(0,0,0,0.12);}"], Color.Silver400);
817
779
  var BaseDatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
818
780
  var {
819
- id,
820
- api,
821
- onClear,
822
- onClick: _onClick,
823
- onClose,
824
- onKeyDown: _onKeyDown,
825
- disabled,
826
- children,
827
- enableClearable,
828
- inputRef: inputRefProp,
829
- InputProps: inputProps
830
- } = _ref,
831
- textFieldProps = _objectWithoutProperties(_ref, _excluded$1);
832
-
781
+ id,
782
+ api,
783
+ onClear,
784
+ onClick: _onClick,
785
+ onClose,
786
+ onKeyDown: _onKeyDown,
787
+ disabled,
788
+ children,
789
+ enableClearable,
790
+ inputRef: inputRefProp,
791
+ InputProps: inputProps
792
+ } = _ref,
793
+ textFieldProps = _objectWithoutProperties(_ref, _excluded$1);
833
794
  var uid = useUID(id);
834
795
  var labelID = "".concat(uid, "-label");
835
796
  var clearIconID = "".concat(uid, "-clear-icon");
836
797
  var inputRef = useRef(null);
837
798
  var textFieldRef = useRef(null);
838
799
  var [popoverAnchor, setPopoverAnchor] = useState(null);
839
-
840
800
  function handleOpen() {
841
801
  if (!disabled && textFieldRef.current) {
842
802
  setPopoverAnchor(textFieldRef.current);
843
803
  }
844
804
  }
845
-
846
805
  function handleClose() {
847
806
  setPopoverAnchor(null);
848
807
  }
849
-
850
808
  useImperativeHandle(api, () => ({
851
809
  close: handleClose
852
- })); // We want to trigger close event only when UI will be ready after updates.
810
+ }));
853
811
 
812
+ // We want to trigger close event only when UI will be ready after updates.
854
813
  useValueObserver(popoverAnchor, () => {
855
814
  if (!popoverAnchor) {
856
815
  onClose === null || onClose === void 0 ? void 0 : onClose();
@@ -877,14 +836,12 @@ var BaseDatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
877
836
  inputRef: mergeRefs(inputRef, inputRefProp),
878
837
  onClick: event => {
879
838
  _onClick === null || _onClick === void 0 ? void 0 : _onClick(event);
880
-
881
839
  if (!event.defaultPrevented) {
882
840
  handleOpen();
883
841
  }
884
842
  },
885
843
  onKeyDown: event => {
886
844
  _onKeyDown === null || _onKeyDown === void 0 ? void 0 : _onKeyDown(event);
887
-
888
845
  if (!event.defaultPrevented && (event.key === ' ' || event.key === 'Enter')) {
889
846
  handleOpen();
890
847
  }
@@ -923,14 +880,13 @@ var BaseDatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
923
880
  if (process.env.NODE_ENV !== "production") BaseDatePicker.displayName = "BaseDatePicker";
924
881
 
925
882
  var _excluded$2 = ["variant", "fallback"],
926
- _excluded2 = ["date", "fallback"];
883
+ _excluded2 = ["date", "fallback"];
927
884
  function useFormattedDate(input, _ref) {
928
885
  var {
929
- variant,
930
- fallback
931
- } = _ref,
932
- dateConfig = _objectWithoutProperties(_ref, _excluded$2);
933
-
886
+ variant,
887
+ fallback
888
+ } = _ref,
889
+ dateConfig = _objectWithoutProperties(_ref, _excluded$2);
934
890
  var config = useDateConfig(dateConfig);
935
891
  var date = useDateTime(input, config);
936
892
  return useMemo(() => formatDate(date, {
@@ -940,11 +896,10 @@ function useFormattedDate(input, _ref) {
940
896
  }
941
897
  function FormattedDate(_ref2) {
942
898
  var {
943
- date,
944
- fallback = 'Invalid Date'
945
- } = _ref2,
946
- options = _objectWithoutProperties(_ref2, _excluded2);
947
-
899
+ date,
900
+ fallback = 'Invalid Date'
901
+ } = _ref2,
902
+ options = _objectWithoutProperties(_ref2, _excluded2);
948
903
  var formatted = useFormattedDate(date, _objectSpread(_objectSpread({}, options), {}, {
949
904
  fallback: ''
950
905
  }));
@@ -952,27 +907,26 @@ function FormattedDate(_ref2) {
952
907
  }
953
908
 
954
909
  var _excluded$3 = ["onDayClick"],
955
- _excluded2$1 = ["onBlur", "onFocus", "onChange", "renderFooter", "renderQuickSelection", "value", "format", "fallback", "variant", "enableClearable", "disableCloseOnSelect", "CalendarProps"];
910
+ _excluded2$1 = ["onBlur", "onFocus", "onChange", "renderFooter", "renderQuickSelection", "value", "format", "fallback", "variant", "enableClearable", "disableCloseOnSelect", "CalendarProps"];
956
911
  var DateField = /*#__PURE__*/forwardRef((_ref, ref) => {
957
912
  var {
958
- onBlur,
959
- onFocus,
960
- onChange,
961
- renderFooter,
962
- renderQuickSelection,
963
- value: valueProp,
964
- format: formatProp,
965
- fallback = '',
966
- variant = 'Date',
967
- enableClearable,
968
- disableCloseOnSelect,
969
- CalendarProps: {
970
- onDayClick: _onDayClick
971
- } = {}
972
- } = _ref,
973
- calendarProps = _objectWithoutProperties(_ref.CalendarProps, _excluded$3),
974
- textFieldProps = _objectWithoutProperties(_ref, _excluded2$1);
975
-
913
+ onBlur,
914
+ onFocus,
915
+ onChange,
916
+ renderFooter,
917
+ renderQuickSelection,
918
+ value: valueProp,
919
+ format: formatProp,
920
+ fallback = '',
921
+ variant = 'Date',
922
+ enableClearable,
923
+ disableCloseOnSelect,
924
+ CalendarProps: {
925
+ onDayClick: _onDayClick
926
+ } = {}
927
+ } = _ref,
928
+ calendarProps = _objectWithoutProperties(_ref.CalendarProps, _excluded$3),
929
+ textFieldProps = _objectWithoutProperties(_ref, _excluded2$1);
976
930
  var config = useDateConfig({
977
931
  format: formatProp
978
932
  });
@@ -983,23 +937,18 @@ var DateField = /*#__PURE__*/forwardRef((_ref, ref) => {
983
937
  fallback
984
938
  }, config));
985
939
  var dateString = useMemo(() => stringifyDate(date, config), [date, config]);
986
-
987
940
  function handleClose() {
988
941
  var _apiRef$current;
989
-
990
942
  (_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 ? void 0 : _apiRef$current.close();
991
943
  }
992
-
993
944
  function handleChange(nextInput) {
994
945
  if (onChange) {
995
946
  onChange(toDatePayload(nextInput, config));
996
947
  }
997
-
998
948
  if (!disableCloseOnSelect) {
999
949
  handleClose();
1000
950
  }
1001
951
  }
1002
-
1003
952
  var api = {
1004
953
  config,
1005
954
  dateValue: date,
@@ -1028,7 +977,6 @@ var DateField = /*#__PURE__*/forwardRef((_ref, ref) => {
1028
977
  },
1029
978
  onDayClick: event => {
1030
979
  _onDayClick === null || _onDayClick === void 0 ? void 0 : _onDayClick(event);
1031
-
1032
980
  if (!event.disabled) {
1033
981
  handleChange(event.dateValue);
1034
982
  }
@@ -1047,8 +995,8 @@ function useDateTimeRange(input, options) {
1047
995
  }
1048
996
 
1049
997
  var _excluded$4 = ["modifiers", "onDayClick", "onDayMouseEnter"],
1050
- _excluded2$2 = ["onBlur", "onFocus", "onChange", "renderFooter", "renderQuickSelection", "value", "format", "fallback", "enableClearable", "disableCloseOnSelect", "CalendarProps"],
1051
- _excluded3 = ["rangeStart", "rangeFinish"];
998
+ _excluded2$2 = ["onBlur", "onFocus", "onChange", "renderFooter", "renderQuickSelection", "value", "format", "fallback", "enableClearable", "disableCloseOnSelect", "CalendarProps"],
999
+ _excluded3 = ["rangeStart", "rangeFinish"];
1052
1000
  var useStyles$1 = /*#__PURE__*/makeStyles(theme => ({
1053
1001
  rangeStart: {},
1054
1002
  rangeFinish: {},
@@ -1086,34 +1034,31 @@ var useStyles$1 = /*#__PURE__*/makeStyles(theme => ({
1086
1034
  });
1087
1035
  var DateRangeField = /*#__PURE__*/forwardRef((_ref, ref) => {
1088
1036
  var {
1089
- onBlur,
1090
- onFocus,
1091
- onChange,
1092
- renderFooter,
1093
- renderQuickSelection,
1094
- value: valueProp,
1095
- format: formatProp,
1096
- fallback = '',
1097
- enableClearable,
1098
- disableCloseOnSelect,
1099
- CalendarProps: {
1100
- modifiers,
1101
- onDayClick: _onDayClick,
1102
- onDayMouseEnter: _onDayMouseEnter
1103
- } = {}
1104
- } = _ref,
1105
- calendarProps = _objectWithoutProperties(_ref.CalendarProps, _excluded$4),
1106
- textFieldProps = _objectWithoutProperties(_ref, _excluded2$2);
1107
-
1037
+ onBlur,
1038
+ onFocus,
1039
+ onChange,
1040
+ renderFooter,
1041
+ renderQuickSelection,
1042
+ value: valueProp,
1043
+ format: formatProp,
1044
+ fallback = '',
1045
+ enableClearable,
1046
+ disableCloseOnSelect,
1047
+ CalendarProps: {
1048
+ modifiers,
1049
+ onDayClick: _onDayClick,
1050
+ onDayMouseEnter: _onDayMouseEnter
1051
+ } = {}
1052
+ } = _ref,
1053
+ calendarProps = _objectWithoutProperties(_ref.CalendarProps, _excluded$4),
1054
+ textFieldProps = _objectWithoutProperties(_ref, _excluded2$2);
1108
1055
  var apiRef = useRef(null);
1109
-
1110
1056
  var _useStyles = useStyles$1({}),
1111
- {
1112
- rangeStart,
1113
- rangeFinish
1114
- } = _useStyles,
1115
- styles = _objectWithoutProperties(_useStyles, _excluded3);
1116
-
1057
+ {
1058
+ rangeStart,
1059
+ rangeFinish
1060
+ } = _useStyles,
1061
+ styles = _objectWithoutProperties(_useStyles, _excluded3);
1117
1062
  var config = useDateConfig({
1118
1063
  format: formatProp
1119
1064
  });
@@ -1127,18 +1072,13 @@ var DateRangeField = /*#__PURE__*/forwardRef((_ref, ref) => {
1127
1072
  var [nextCalendarStartDate, nextCalendarFinishDate] = parseDateRange([startDate, finishDate || hoveredDate], config);
1128
1073
  return [nextCalendarStartDate === null || nextCalendarStartDate === void 0 ? void 0 : nextCalendarStartDate.startOf('day'), nextCalendarFinishDate === null || nextCalendarFinishDate === void 0 ? void 0 : nextCalendarFinishDate.endOf('day')];
1129
1074
  }, [config, startDate, finishDate, hoveredDate]);
1130
-
1131
1075
  function handleClose() {
1132
1076
  var _apiRef$current;
1133
-
1134
1077
  (_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 ? void 0 : _apiRef$current.close();
1135
1078
  }
1136
-
1137
1079
  function handleChange(nextValue) {
1138
1080
  var _nextFinishDate;
1139
-
1140
1081
  var [nextStartDate, nextFinishDate] = parseDateRange(nextValue, config);
1141
-
1142
1082
  if (onChange) {
1143
1083
  if (nextStartDate) {
1144
1084
  if (startDate) {
@@ -1152,19 +1092,15 @@ var DateRangeField = /*#__PURE__*/forwardRef((_ref, ref) => {
1152
1092
  nextStartDate = nextStartDate.startOf('day');
1153
1093
  }
1154
1094
  }
1155
-
1156
1095
  if (nextFinishDate) {
1157
1096
  nextFinishDate = nextFinishDate.endOf('day');
1158
1097
  }
1159
-
1160
1098
  onChange(toDateRangePayload([nextStartDate, nextFinishDate], config));
1161
1099
  }
1162
-
1163
1100
  if (!disableCloseOnSelect && (_nextFinishDate = nextFinishDate) !== null && _nextFinishDate !== void 0 && _nextFinishDate.isValid) {
1164
1101
  handleClose();
1165
1102
  }
1166
1103
  }
1167
-
1168
1104
  var api = {
1169
1105
  config,
1170
1106
  close: handleClose,
@@ -1207,15 +1143,12 @@ var DateRangeField = /*#__PURE__*/forwardRef((_ref, ref) => {
1207
1143
  var {
1208
1144
  dateValue
1209
1145
  } = _ref4;
1210
-
1211
1146
  if (calendarStartDate) {
1212
1147
  if (!calendarFinishDate) {
1213
1148
  return calendarStartDate.hasSame(dateValue, 'day');
1214
1149
  }
1215
-
1216
1150
  return calendarStartDate <= dateValue && dateValue <= calendarFinishDate;
1217
1151
  }
1218
-
1219
1152
  return false;
1220
1153
  },
1221
1154
  footer: renderFooter === null || renderFooter === void 0 ? void 0 : renderFooter(api),
@@ -1226,7 +1159,6 @@ var DateRangeField = /*#__PURE__*/forwardRef((_ref, ref) => {
1226
1159
  },
1227
1160
  onDayClick: event => {
1228
1161
  _onDayClick === null || _onDayClick === void 0 ? void 0 : _onDayClick(event);
1229
-
1230
1162
  if (!event.disabled) {
1231
1163
  if (startDate && !finishDate) {
1232
1164
  handleChange([startDateString, event.stringValue]);
@@ -1242,66 +1174,87 @@ if (process.env.NODE_ENV !== "production") DateRangeField.displayName = "DateRan
1242
1174
 
1243
1175
  /** @deprecated */
1244
1176
 
1177
+ /** @deprecated */
1178
+
1179
+ /** @deprecated */
1180
+
1181
+ /** @deprecated */
1182
+
1183
+ /** @deprecated */
1184
+
1185
+ /** @deprecated */
1186
+
1187
+ /** @deprecated */
1188
+
1189
+ /** @deprecated */
1190
+
1191
+ /** @deprecated */
1192
+
1193
+ /** @deprecated */
1194
+
1245
1195
  /** @deprecated */
1246
1196
  function toDateTime(value) {
1247
1197
  return typeof value === 'number' ? DateTime.fromMillis(value) : DateTime.fromJSDate(value);
1248
1198
  }
1249
- /** @deprecated */
1250
-
1251
1199
 
1200
+ /** @deprecated */
1252
1201
  function isDate(value) {
1253
1202
  return value != null && value instanceof Date;
1254
1203
  }
1255
- /** @deprecated */
1256
1204
 
1205
+ /** @deprecated */
1257
1206
  function isDateLike(value) {
1258
1207
  return isDate(value) || typeof value === 'number' && Number.isInteger(value);
1259
1208
  }
1260
- /** @deprecated */
1261
1209
 
1210
+ /** @deprecated */
1262
1211
  function isValidDate(value) {
1263
1212
  return isDate(value) && Number.isFinite(value.getTime());
1264
1213
  }
1265
- /** @deprecated */
1266
1214
 
1215
+ /** @deprecated */
1267
1216
  function checkRange(range, validator) {
1268
1217
  if (!Array.isArray(range) || range.length > 2) {
1269
1218
  return false;
1270
1219
  }
1271
-
1272
1220
  var [start, finish] = range;
1273
1221
  return (start == null || validator(start)) && (finish == null || validator(finish));
1274
1222
  }
1275
- /** @deprecated */
1276
-
1277
1223
 
1224
+ /** @deprecated */
1278
1225
  function isDateRange(range) {
1279
1226
  return checkRange(range, isDate);
1280
1227
  }
1281
- /** @deprecated */
1282
1228
 
1229
+ /** @deprecated */
1283
1230
  function isDateRangeLike(range) {
1284
1231
  return checkRange(range, isDateLike);
1285
1232
  }
1286
- /** @deprecated */
1287
1233
 
1234
+ /** @deprecated */
1288
1235
  function isValidDateRange(range) {
1289
1236
  return checkRange(range, isValidDate);
1290
1237
  }
1291
- /** @deprecated */
1292
1238
 
1239
+ /** @deprecated */
1293
1240
  function toDate(value) {
1294
1241
  return !isDateLike(value) ? new Date(NaN) : new Date(value);
1295
1242
  }
1296
- /** @deprecated */
1297
1243
 
1244
+ /** @deprecated */
1298
1245
  function toDateRange(range) {
1299
1246
  if (range == null || !isDateRangeLike(range)) {
1300
1247
  return [];
1301
1248
  }
1302
-
1303
1249
  return range.filter(x => x != null).map(x => x == null ? undefined : toDate(x)).sort((a, b) => !isValidDate(a) ? -1 : !isValidDate(b) ? 1 : a.valueOf() - b.valueOf());
1304
1250
  }
1251
+
1252
+ /** @deprecated */
1253
+
1254
+ /** @deprecated */
1255
+
1256
+ /** @deprecated */
1257
+
1305
1258
  /** @deprecated */
1306
1259
 
1307
1260
  /** @deprecated */
@@ -1329,9 +1282,8 @@ class DateUtils {
1329
1282
  millisecond
1330
1283
  };
1331
1284
  }
1332
- /** @deprecated */
1333
-
1334
1285
 
1286
+ /** @deprecated */
1335
1287
  fromObject(_ref) {
1336
1288
  var {
1337
1289
  year = 0,
@@ -1342,11 +1294,9 @@ class DateUtils {
1342
1294
  second = 0,
1343
1295
  millisecond = 0
1344
1296
  } = _ref;
1345
-
1346
1297
  if (Number.isNaN(year) || Number.isNaN(month) || Number.isNaN(day) || Number.isNaN(hour) || Number.isNaN(minute) || Number.isNaN(second) || Number.isNaN(millisecond)) {
1347
1298
  return new Date(NaN);
1348
1299
  }
1349
-
1350
1300
  return DateTime.fromObject({
1351
1301
  year,
1352
1302
  month,
@@ -1357,15 +1307,13 @@ class DateUtils {
1357
1307
  millisecond
1358
1308
  }).toJSDate();
1359
1309
  }
1360
- /** @deprecated */
1361
-
1362
1310
 
1311
+ /** @deprecated */
1363
1312
  update(value, values) {
1364
1313
  return toDateTime(value).set(values).toJSDate();
1365
1314
  }
1366
- /** @deprecated */
1367
-
1368
1315
 
1316
+ /** @deprecated */
1369
1317
  mergeDateAndTime(date, time) {
1370
1318
  var {
1371
1319
  hour,
@@ -1373,11 +1321,9 @@ class DateUtils {
1373
1321
  second,
1374
1322
  millisecond
1375
1323
  } = this.toObject(time);
1376
-
1377
1324
  if (Number.isNaN(hour) || Number.isNaN(minute) || Number.isNaN(second) || Number.isNaN(millisecond)) {
1378
1325
  return new Date(NaN);
1379
1326
  }
1380
-
1381
1327
  return this.update(date, {
1382
1328
  hour,
1383
1329
  minute,
@@ -1385,73 +1331,61 @@ class DateUtils {
1385
1331
  millisecond
1386
1332
  });
1387
1333
  }
1388
- /** @deprecated */
1389
-
1390
1334
 
1335
+ /** @deprecated */
1391
1336
  startOf(value, unit) {
1392
1337
  return toDateTime(value).startOf(unit).toJSDate();
1393
1338
  }
1394
- /** @deprecated */
1395
-
1396
1339
 
1340
+ /** @deprecated */
1397
1341
  endOf(value, unit) {
1398
1342
  return toDateTime(value).endOf(unit).toJSDate();
1399
1343
  }
1400
- /** @deprecated */
1401
-
1402
1344
 
1345
+ /** @deprecated */
1403
1346
  plus(value, values) {
1404
1347
  return toDateTime(value).plus(values).toJSDate();
1405
1348
  }
1406
- /** @deprecated */
1407
-
1408
1349
 
1350
+ /** @deprecated */
1409
1351
  minus(value, values) {
1410
1352
  return toDateTime(value).minus(values).toJSDate();
1411
1353
  }
1412
- /** @deprecated */
1413
-
1414
1354
 
1355
+ /** @deprecated */
1415
1356
  isSameDate(value, compare) {
1416
1357
  var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'millisecond';
1417
-
1418
1358
  if (value == null && compare == null) {
1419
1359
  return true;
1420
1360
  }
1421
-
1422
1361
  if (value == null || compare == null) {
1423
1362
  return false;
1424
1363
  }
1425
-
1426
1364
  var dateTimeValue = toDateTime(value);
1427
1365
  var dateTimeCompare = toDateTime(compare);
1428
1366
  return dateTimeValue.isValid && dateTimeCompare.isValid && dateTimeValue.startOf(unit).equals(dateTimeCompare.startOf(unit));
1429
1367
  }
1430
- /** @deprecated */
1431
-
1432
1368
 
1369
+ /** @deprecated */
1433
1370
  isSameDateRange(value, compare, unit) {
1434
1371
  var range1 = toDateRange(value);
1435
1372
  var range2 = toDateRange(compare);
1436
1373
  return !range1.some((date, idx) => !this.isSameDate(date, range2[idx], unit));
1437
1374
  }
1438
- /** @deprecated */
1439
-
1440
1375
 
1376
+ /** @deprecated */
1441
1377
  diff(value, compare, unit) {
1442
1378
  var valueDateTime = toDateTime(value);
1443
1379
  var compareDateTime = toDateTime(compare);
1444
1380
  return valueDateTime.diff(compareDateTime, unit).as(unit);
1445
1381
  }
1446
- /** @deprecated */
1447
-
1448
1382
 
1383
+ /** @deprecated */
1449
1384
  toLocaleString(value, options) {
1450
1385
  return toDateTime(value).toLocaleString(options);
1451
1386
  }
1452
- /** @deprecated */
1453
-
1454
1387
 
1388
+ /** @deprecated */
1455
1389
  format(value, variant) {
1456
1390
  return this.toLocaleString(value, variant === 'date' ? {
1457
1391
  day: '2-digit',
@@ -1471,30 +1405,24 @@ class DateUtils {
1471
1405
  minute: 'numeric'
1472
1406
  });
1473
1407
  }
1474
- /** @deprecated */
1475
-
1476
1408
 
1409
+ /** @deprecated */
1477
1410
  formatRange(value) {
1478
1411
  var emptyText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1479
1412
  var range = toDateRange(value);
1480
-
1481
1413
  if (!isValidDateRange(range)) {
1482
1414
  return 'Invalid Date Range';
1483
1415
  }
1484
-
1485
1416
  var [start, finish] = range;
1486
-
1487
1417
  if (!start) {
1488
1418
  return emptyText;
1489
1419
  }
1490
-
1491
1420
  var startText = this.format(start, !this.isSameDate(start, finish, 'year') ? 'date' : 'shortDate');
1492
1421
  var finishText = !finish ? '…' : this.format(finish, 'date');
1493
1422
  return "".concat(startText, " - ").concat(finishText);
1494
1423
  }
1495
- /** @deprecated */
1496
-
1497
1424
 
1425
+ /** @deprecated */
1498
1426
  formatRelativeTime(value) {
1499
1427
  var {
1500
1428
  style = 'long',
@@ -1507,25 +1435,23 @@ class DateUtils {
1507
1435
  base: compareDateTime
1508
1436
  });
1509
1437
  }
1510
-
1511
1438
  }
1512
1439
  function useDateUtils() {
1513
1440
  return useMemo(() => new DateUtils(), []);
1514
1441
  }
1515
1442
 
1516
1443
  var _excluded$5 = ["unit", "round", "padding", "fallback", "base"],
1517
- _excluded2$3 = ["date", "fallback"];
1444
+ _excluded2$3 = ["date", "fallback"];
1518
1445
  function useFormattedRelativeTime(input) {
1519
1446
  var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
1520
- {
1521
- unit,
1522
- round,
1523
- padding,
1524
- fallback,
1525
- base: baseOption
1526
- } = _ref,
1527
- dateConfig = _objectWithoutProperties(_ref, _excluded$5);
1528
-
1447
+ {
1448
+ unit,
1449
+ round,
1450
+ padding,
1451
+ fallback,
1452
+ base: baseOption
1453
+ } = _ref,
1454
+ dateConfig = _objectWithoutProperties(_ref, _excluded$5);
1529
1455
  var config = useDateConfig(dateConfig);
1530
1456
  var date = useDateTime(input, config);
1531
1457
  var baseOptionDate = useDateTime(baseOption, config);
@@ -1540,11 +1466,10 @@ function useFormattedRelativeTime(input) {
1540
1466
  }
1541
1467
  function FormattedRelativeTime(_ref2) {
1542
1468
  var {
1543
- date,
1544
- fallback = 'Invalid Date'
1545
- } = _ref2,
1546
- options = _objectWithoutProperties(_ref2, _excluded2$3);
1547
-
1469
+ date,
1470
+ fallback = 'Invalid Date'
1471
+ } = _ref2,
1472
+ options = _objectWithoutProperties(_ref2, _excluded2$3);
1548
1473
  var formatted = useFormattedRelativeTime(date, _objectSpread(_objectSpread({}, options), {}, {
1549
1474
  fallback: ''
1550
1475
  }));
@@ -1553,7 +1478,6 @@ function FormattedRelativeTime(_ref2) {
1553
1478
 
1554
1479
  var _excluded$6 = ["disabled", "onChange", "value", "format"];
1555
1480
  var TIME_MATCH_FORMATS = ['h:mm a', 'h:mma', 'H:mm', 'h:mm', 'hmm', 'Hmm', 'h', 'H'];
1556
-
1557
1481
  function toTimeFieldOption(date, config) {
1558
1482
  return {
1559
1483
  value: date.valueOf(),
@@ -1563,52 +1487,42 @@ function toTimeFieldOption(date, config) {
1563
1487
  pattern: new RegExp("^(".concat(TIME_MATCH_FORMATS.map(format => date.toFormat(format)).join('|'), ")"), 'i')
1564
1488
  };
1565
1489
  }
1566
-
1567
1490
  function normalizeInputValue(inputValue) {
1568
1491
  return inputValue.replace(/[\s]/g, '').toLowerCase();
1569
1492
  }
1570
-
1571
1493
  function makeOptions(config) {
1572
1494
  var options = [];
1573
1495
  var now = DateTime.local().startOf('day');
1574
-
1575
1496
  for (var i = 0; i < 96; i++) {
1576
1497
  options.push(toTimeFieldOption(now.set({
1577
1498
  minute: i * 15
1578
1499
  }), config));
1579
1500
  }
1580
-
1581
1501
  var cache = new Map();
1582
1502
  return [options, (_, _ref) => {
1583
1503
  var {
1584
1504
  inputValue
1585
1505
  } = _ref;
1586
1506
  var query = normalizeInputValue(inputValue);
1587
-
1588
1507
  if (!query) {
1589
1508
  return options;
1590
1509
  }
1591
-
1592
1510
  var filtered = cache.get(query);
1593
-
1594
1511
  if (!filtered) {
1595
1512
  filtered = options.filter(option => option.pattern.test(query));
1596
1513
  cache.set(query, filtered);
1597
1514
  }
1598
-
1599
1515
  return filtered;
1600
1516
  }];
1601
1517
  }
1602
-
1603
1518
  var TimeField = /*#__PURE__*/forwardRef((_ref2, ref) => {
1604
1519
  var {
1605
- disabled,
1606
- onChange,
1607
- value: valueProp,
1608
- format: formatProp
1609
- } = _ref2,
1610
- props = _objectWithoutProperties(_ref2, _excluded$6);
1611
-
1520
+ disabled,
1521
+ onChange,
1522
+ value: valueProp,
1523
+ format: formatProp
1524
+ } = _ref2,
1525
+ props = _objectWithoutProperties(_ref2, _excluded$6);
1612
1526
  var config = useDateConfig({
1613
1527
  format: formatProp
1614
1528
  });
@@ -1616,19 +1530,15 @@ var TimeField = /*#__PURE__*/forwardRef((_ref2, ref) => {
1616
1530
  var selectedOption = useMemo(() => !date.isValid ? undefined : toTimeFieldOption(date, config), [date, config]);
1617
1531
  var [options, filterOptions] = useMemo(() => makeOptions(config), [config]);
1618
1532
  var [inputValue, setInputValue] = useState('');
1619
-
1620
1533
  function handleChange(nextValue) {
1621
1534
  if (onChange) {
1622
1535
  onChange(toDatePayload(nextValue, config));
1623
1536
  }
1624
1537
  }
1625
-
1626
1538
  function handleType(text) {
1627
1539
  text = normalizeInputValue(text);
1628
-
1629
1540
  for (var timeFormat of TIME_MATCH_FORMATS) {
1630
1541
  var nextDate = DateTime.fromFormat(text, timeFormat);
1631
-
1632
1542
  if (nextDate.isValid) {
1633
1543
  if (onChange) {
1634
1544
  if (date.isValid) {
@@ -1638,17 +1548,13 @@ var TimeField = /*#__PURE__*/forwardRef((_ref2, ref) => {
1638
1548
  day: date.day
1639
1549
  });
1640
1550
  }
1641
-
1642
1551
  onChange(toDatePayload(nextDate, config));
1643
1552
  }
1644
-
1645
1553
  return;
1646
1554
  }
1647
1555
  }
1648
-
1649
1556
  setInputValue((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || '');
1650
1557
  }
1651
-
1652
1558
  useEffect(() => {
1653
1559
  if (!date.isValid) {
1654
1560
  setInputValue('');