@instructure/ui-date-input 11.7.3-snapshot-7 → 11.7.3-snapshot-26

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.
@@ -1,5 +1,3 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- var _CalendarInstUIIcon, _ChevronRightInstUIIc, _ChevronLeftInstUIIco;
3
1
  /*
4
2
  * The MIT License (MIT)
5
3
  *
@@ -131,23 +129,15 @@ const DateInput2 = /*#__PURE__*/forwardRef(({
131
129
  }, ref) => {
132
130
  const userLocale = locale || getLocale();
133
131
  const userTimezone = timezone || getTimezone();
134
- const _useState = useState(messages || []),
135
- _useState2 = _slicedToArray(_useState, 2),
136
- inputMessages = _useState2[0],
137
- setInputMessages = _useState2[1];
138
- const _useState3 = useState(false),
139
- _useState4 = _slicedToArray(_useState3, 2),
140
- showPopover = _useState4[0],
141
- setShowPopover = _useState4[1];
132
+ const [inputMessages, setInputMessages] = useState(messages || []);
133
+ const [showPopover, setShowPopover] = useState(false);
142
134
  useEffect(() => {
143
135
  // don't set input messages if there is an internal error set already
144
136
  if (inputMessages.find(m => m.text === invalidDateErrorMessage)) return;
145
137
  setInputMessages(messages || []);
146
138
  }, [messages]);
147
139
  useEffect(() => {
148
- const _parseDate = parseDate(value),
149
- _parseDate2 = _slicedToArray(_parseDate, 2),
150
- utcIsoDate = _parseDate2[1];
140
+ const [, utcIsoDate] = parseDate(value);
151
141
  // clear error messages if date becomes valid
152
142
  if (utcIsoDate || !value) {
153
143
  setInputMessages(messages || []);
@@ -170,7 +160,7 @@ const DateInput2 = /*#__PURE__*/forwardRef(({
170
160
  };
171
161
  const formatDate = (date, timeZone = userTimezone) => {
172
162
  // use formatter function if provided
173
- if (typeof dateFormat !== 'string' && dateFormat !== null && dateFormat !== void 0 && dateFormat.formatter) {
163
+ if (typeof dateFormat !== 'string' && dateFormat?.formatter) {
174
164
  return dateFormat.formatter(date);
175
165
  }
176
166
  // if dateFormat set to a locale, use that, otherwise default to the user's locale
@@ -196,25 +186,20 @@ const DateInput2 = /*#__PURE__*/forwardRef(({
196
186
  return formattedDate.replace(regex(year), match => 'Y'.repeat(match.length)).replace(regex(month), match => 'M'.repeat(match.length)).replace(regex(day), match => 'D'.repeat(match.length));
197
187
  };
198
188
  const handleInputChange = (e, newValue) => {
199
- const _parseDate3 = parseDate(newValue),
200
- _parseDate4 = _slicedToArray(_parseDate3, 2),
201
- utcIsoDate = _parseDate4[1];
202
- onChange === null || onChange === void 0 ? void 0 : onChange(e, newValue, utcIsoDate);
189
+ const [, utcIsoDate] = parseDate(newValue);
190
+ onChange?.(e, newValue, utcIsoDate);
203
191
  };
204
192
  const handleDateSelected = (dateString, _momentDate, e) => {
205
193
  setShowPopover(false);
206
194
  const newValue = formatDate(new Date(dateString));
207
- onChange === null || onChange === void 0 ? void 0 : onChange(e, newValue, dateString);
208
- onRequestValidateDate === null || onRequestValidateDate === void 0 ? void 0 : onRequestValidateDate(e, newValue, dateString);
195
+ onChange?.(e, newValue, dateString);
196
+ onRequestValidateDate?.(e, newValue, dateString);
209
197
  };
210
198
  const handleBlur = e => {
211
- const _parseDate5 = parseDate(value),
212
- _parseDate6 = _slicedToArray(_parseDate5, 2),
213
- localeDate = _parseDate6[0],
214
- utcIsoDate = _parseDate6[1];
199
+ const [localeDate, utcIsoDate] = parseDate(value);
215
200
  if (localeDate) {
216
201
  if (localeDate !== value) {
217
- onChange === null || onChange === void 0 ? void 0 : onChange(e, localeDate, utcIsoDate);
202
+ onChange?.(e, localeDate, utcIsoDate);
218
203
  }
219
204
  } else if (value && invalidDateErrorMessage) {
220
205
  setInputMessages([{
@@ -222,8 +207,8 @@ const DateInput2 = /*#__PURE__*/forwardRef(({
222
207
  text: invalidDateErrorMessage
223
208
  }]);
224
209
  }
225
- onRequestValidateDate === null || onRequestValidateDate === void 0 ? void 0 : onRequestValidateDate(e, value || '', utcIsoDate);
226
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(e, value || '', utcIsoDate);
210
+ onRequestValidateDate?.(e, value || '', utcIsoDate);
211
+ onBlur?.(e, value || '', utcIsoDate);
227
212
  };
228
213
  const selectedDate = parseDate(value)[1];
229
214
  return _jsx(TextInput, {
@@ -236,7 +221,7 @@ const DateInput2 = /*#__PURE__*/forwardRef(({
236
221
  onBlur: handleBlur,
237
222
  isRequired: isRequired,
238
223
  value: value,
239
- placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : getDateFormatHint(),
224
+ placeholder: placeholder ?? getDateFormatHint(),
240
225
  width: width,
241
226
  display: isInline ? 'inline-block' : 'block',
242
227
  messages: inputMessages,
@@ -248,9 +233,9 @@ const DateInput2 = /*#__PURE__*/forwardRef(({
248
233
  withBorder: false,
249
234
  screenReaderLabel: screenReaderLabels.calendarIcon,
250
235
  interaction: interaction,
251
- children: renderCalendarIcon ? callRenderProp(renderCalendarIcon) : _CalendarInstUIIcon || (_CalendarInstUIIcon = _jsx(CalendarInstUIIcon, {
236
+ children: renderCalendarIcon ? callRenderProp(renderCalendarIcon) : _jsx(CalendarInstUIIcon, {
252
237
  color: "baseColor"
253
- }))
238
+ })
254
239
  }),
255
240
  isShowingContent: showPopover,
256
241
  onShowContent: () => setShowPopover(true),
@@ -272,18 +257,18 @@ const DateInput2 = /*#__PURE__*/forwardRef(({
272
257
  size: "small",
273
258
  withBackground: false,
274
259
  withBorder: false,
275
- renderIcon: _ChevronRightInstUIIc || (_ChevronRightInstUIIc = _jsx(ChevronRightInstUIIcon, {
260
+ renderIcon: _jsx(ChevronRightInstUIIcon, {
276
261
  color: "baseColor"
277
- })),
262
+ }),
278
263
  screenReaderLabel: screenReaderLabels.nextMonthButton
279
264
  }),
280
265
  renderPrevMonthButton: _jsx(IconButton, {
281
266
  size: "small",
282
267
  withBackground: false,
283
268
  withBorder: false,
284
- renderIcon: _ChevronLeftInstUIIco || (_ChevronLeftInstUIIco = _jsx(ChevronLeftInstUIIcon, {
269
+ renderIcon: _jsx(ChevronLeftInstUIIcon, {
285
270
  color: "baseColor"
286
- })),
271
+ }),
287
272
  screenReaderLabel: screenReaderLabels.prevMonthButton
288
273
  })
289
274
  })
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = exports.DateInput = void 0;
8
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
8
  var _react = require("react");
10
9
  var _v11_ = require("@instructure/ui-calendar/v11_6");
11
10
  var _IconCalendarMonthLine = require("@instructure/ui-icons/lib/generated/IconCalendarMonthLine.js");
@@ -21,11 +20,9 @@ var _DateTime = require("@instructure/ui-i18n/lib/DateTime.js");
21
20
  var _Locale = require("@instructure/ui-i18n/lib/Locale.js");
22
21
  var _emotion = require("@instructure/emotion");
23
22
  var _styles = _interopRequireDefault(require("./styles"));
24
- var _props2 = require("./props");
23
+ var _props = require("./props");
25
24
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
26
- const _excluded = ["renderLabel", "value", "placeholder", "onBlur", "isRequired", "size", "isInline", "layout", "width", "onRequestValidateDate", "onRequestShowCalendar", "onRequestHideCalendar", "onRequestSelectNextDay", "onRequestSelectPrevDay", "onRequestRenderNextMonth", "onRequestRenderPrevMonth"],
27
- _excluded2 = ["ref"];
28
- var _dec, _class, _DateInput, _IconCalendarMonthLin;
25
+ var _dec, _class;
29
26
  /*
30
27
  * The MIT License (MIT)
31
28
  *
@@ -54,135 +51,31 @@ var _dec, _class, _DateInput, _IconCalendarMonthLin;
54
51
  category: components
55
52
  ---
56
53
  **/
57
- let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, null), _dec(_class = (_DateInput = class DateInput extends _react.Component {
58
- constructor(...args) {
59
- super(...args);
60
- this.state = {
61
- hasInputRef: false,
62
- isShowingCalendar: false,
63
- validatedDate: void 0,
64
- messages: []
65
- };
66
- this._input = void 0;
67
- this.ref = null;
68
- this.formatDateId = date => {
69
- // ISO8601 strings may contain a space. Remove any spaces before using the
70
- // date as the id.
71
- return date.replace(/\s/g, '');
72
- };
73
- this.handleInputRef = el => {
74
- var _this$props$inputRef, _this$props;
75
- // Ensures that we position the Calendar with respect to the input correctly
76
- // if the Calendar is open on mount
77
- if (!this.state.hasInputRef) {
78
- this.setState({
79
- hasInputRef: true
80
- });
81
- }
82
- this._input = el;
83
- (_this$props$inputRef = (_this$props = this.props).inputRef) === null || _this$props$inputRef === void 0 ? void 0 : _this$props$inputRef.call(_this$props, el);
84
- };
85
- this.handleInputChange = (event, value) => {
86
- var _this$props$onChange, _this$props2;
87
- (_this$props$onChange = (_this$props2 = this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props2, event, {
88
- value
89
- });
90
- this.handleShowCalendar(event);
91
- };
92
- this.handleShowCalendar = event => {
93
- if (!this.props.children) {
94
- this.setState({
95
- isShowingCalendar: true
96
- });
97
- } else if (this.interaction === 'enabled' && this.props.children) {
98
- var _this$props$onRequest, _this$props3;
99
- (_this$props$onRequest = (_this$props3 = this.props).onRequestShowCalendar) === null || _this$props$onRequest === void 0 ? void 0 : _this$props$onRequest.call(_this$props3, event);
100
- }
101
- };
102
- this.validateDate = date => {
103
- const invalidDateErrorMessage = this.props.invalidDateErrorMessage;
104
- const disabledDateErrorMessage = this.props.disabledDateErrorMessage || invalidDateErrorMessage;
105
- const messages = [];
106
- // check if date is enabled
107
- const disabledDates = this.props.disabledDates;
108
- if (typeof disabledDates === 'function' && disabledDates(date) || Array.isArray(disabledDates) && disabledDates.find(dateString => _DateTime.DateTime.parse(dateString, this.locale(), this.timezone()).isSame(_DateTime.DateTime.parse(date, this.locale(), this.timezone()), 'day'))) {
109
- messages.push(typeof disabledDateErrorMessage === 'function' ? disabledDateErrorMessage(date) : {
110
- type: 'error',
111
- text: disabledDateErrorMessage
112
- });
113
- }
114
-
115
- // check if date is valid
116
- if (!_DateTime.DateTime.parse(date, this.locale(), this.timezone(), [_DateTime.DateTime.momentISOFormat, 'llll', 'LLLL', 'lll', 'LLL', 'll', 'LL', 'l', 'L'], true).isValid()) {
117
- messages.push(typeof invalidDateErrorMessage === 'function' ? invalidDateErrorMessage(date) : {
118
- type: 'error',
119
- text: invalidDateErrorMessage
120
- });
121
- }
122
- return messages;
123
- };
124
- this.handleHideCalendar = (event, setectedDate) => {
125
- if (!this.props.children) {
126
- const dateString = setectedDate || this.props.value;
127
- const messages = [];
128
- if (this.props.onRequestValidateDate) {
129
- var _this$props$onRequest2, _this$props4;
130
- const userValidatedDate = (_this$props$onRequest2 = (_this$props4 = this.props).onRequestValidateDate) === null || _this$props$onRequest2 === void 0 ? void 0 : _this$props$onRequest2.call(_this$props4, event, dateString || '', this.validateDate(dateString || ''));
131
- messages.push(...(userValidatedDate || []));
132
- } else {
133
- if (dateString) {
134
- messages.push(...this.validateDate(dateString));
135
- }
136
- }
137
- this.setState({
138
- messages,
139
- isShowingCalendar: false
140
- });
141
- } else {
142
- var _this$props$onRequest3, _this$props5, _this$props$onRequest4, _this$props6;
143
- (_this$props$onRequest3 = (_this$props5 = this.props).onRequestValidateDate) === null || _this$props$onRequest3 === void 0 ? void 0 : _this$props$onRequest3.call(_this$props5, event);
144
- (_this$props$onRequest4 = (_this$props6 = this.props).onRequestHideCalendar) === null || _this$props$onRequest4 === void 0 ? void 0 : _this$props$onRequest4.call(_this$props6, event);
145
- }
146
- };
147
- this.handleHighlightOption = (event, {
148
- direction
149
- }) => {
150
- const _this$props7 = this.props,
151
- onRequestSelectNextDay = _this$props7.onRequestSelectNextDay,
152
- onRequestSelectPrevDay = _this$props7.onRequestSelectPrevDay,
153
- onChange = _this$props7.onChange,
154
- value = _this$props7.value,
155
- currentDate = _this$props7.currentDate;
156
- const isValueValid = value && _DateTime.DateTime.parse(value, this.locale(), this.timezone()).isValid();
157
- if (direction === -1) {
158
- if (onRequestSelectPrevDay) {
159
- onRequestSelectPrevDay === null || onRequestSelectPrevDay === void 0 ? void 0 : onRequestSelectPrevDay(event);
160
- } else {
161
- // @ts-expect-error TODO
162
- onChange(event, {
163
- value: _DateTime.DateTime.parse(isValueValid ? value : currentDate, this.locale(), this.timezone()).subtract(1, 'day').format('MMMM D, YYYY')
164
- });
165
- this.setState({
166
- messages: []
167
- });
168
- }
169
- }
170
- if (direction === 1) {
171
- if (onRequestSelectNextDay) {
172
- onRequestSelectNextDay === null || onRequestSelectNextDay === void 0 ? void 0 : onRequestSelectNextDay(event);
173
- } else {
174
- // @ts-expect-error TODO
175
- onChange(event, {
176
- value: _DateTime.DateTime.parse(isValueValid ? value : currentDate, this.locale(), this.timezone()).add(1, 'day').format('MMMM D, YYYY')
177
- });
178
- this.setState({
179
- messages: []
180
- });
181
- }
182
- }
183
- };
184
- this.shouldShowCalendar = () => this.props.children ? this.props.isShowingCalendar : this.state.isShowingCalendar;
185
- }
54
+ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, null), _dec(_class = class DateInput extends _react.Component {
55
+ static displayName = "DateInput";
56
+ static componentId = 'DateInput';
57
+ static Day = _v11_.Calendar.Day;
58
+ static allowedProps = _props.allowedProps;
59
+ static defaultProps = {
60
+ value: '',
61
+ size: 'medium',
62
+ onBlur: () => {},
63
+ // must have a default so createChainedFunction works
64
+ isRequired: false,
65
+ isInline: false,
66
+ layout: 'stacked',
67
+ display: 'inline-block',
68
+ placement: 'bottom center',
69
+ isShowingCalendar: false
70
+ };
71
+ state = {
72
+ hasInputRef: false,
73
+ isShowingCalendar: false,
74
+ validatedDate: undefined,
75
+ messages: []
76
+ };
77
+ _input = undefined;
78
+ ref = null;
186
79
  locale() {
187
80
  if (this.props.locale) {
188
81
  return this.props.locale;
@@ -200,19 +93,18 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyleLegacy)(_style
200
93
  return _DateTime.DateTime.browserTimeZone();
201
94
  }
202
95
  componentDidMount() {
203
- var _this$props$makeStyle, _this$props8;
204
- (_this$props$makeStyle = (_this$props8 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props8);
96
+ this.props.makeStyles?.();
205
97
  }
206
98
  componentDidUpdate() {
207
- var _this$props$makeStyle2, _this$props9;
208
- (_this$props$makeStyle2 = (_this$props9 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props9);
99
+ this.props.makeStyles?.();
209
100
  }
210
101
  get selectedDateId() {
211
102
  let selectedDateId;
212
103
  _react.Children.toArray(this.props.children).forEach(day => {
213
- const _props = day.props,
214
- date = _props.date,
215
- isSelected = _props.isSelected;
104
+ const {
105
+ date,
106
+ isSelected
107
+ } = day.props;
216
108
  if (isSelected) {
217
109
  selectedDateId = this.formatDateId(date);
218
110
  }
@@ -224,10 +116,127 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyleLegacy)(_style
224
116
  props: this.props
225
117
  });
226
118
  }
119
+ formatDateId = date => {
120
+ // ISO8601 strings may contain a space. Remove any spaces before using the
121
+ // date as the id.
122
+ return date.replace(/\s/g, '');
123
+ };
124
+ handleInputRef = el => {
125
+ // Ensures that we position the Calendar with respect to the input correctly
126
+ // if the Calendar is open on mount
127
+ if (!this.state.hasInputRef) {
128
+ this.setState({
129
+ hasInputRef: true
130
+ });
131
+ }
132
+ this._input = el;
133
+ this.props.inputRef?.(el);
134
+ };
135
+ handleInputChange = (event, value) => {
136
+ this.props.onChange?.(event, {
137
+ value
138
+ });
139
+ this.handleShowCalendar(event);
140
+ };
141
+ handleShowCalendar = event => {
142
+ if (!this.props.children) {
143
+ this.setState({
144
+ isShowingCalendar: true
145
+ });
146
+ } else if (this.interaction === 'enabled' && this.props.children) {
147
+ this.props.onRequestShowCalendar?.(event);
148
+ }
149
+ };
150
+ validateDate = date => {
151
+ const {
152
+ invalidDateErrorMessage
153
+ } = this.props;
154
+ const disabledDateErrorMessage = this.props.disabledDateErrorMessage || invalidDateErrorMessage;
155
+ const messages = [];
156
+ // check if date is enabled
157
+ const {
158
+ disabledDates
159
+ } = this.props;
160
+ if (typeof disabledDates === 'function' && disabledDates(date) || Array.isArray(disabledDates) && disabledDates.find(dateString => _DateTime.DateTime.parse(dateString, this.locale(), this.timezone()).isSame(_DateTime.DateTime.parse(date, this.locale(), this.timezone()), 'day'))) {
161
+ messages.push(typeof disabledDateErrorMessage === 'function' ? disabledDateErrorMessage(date) : {
162
+ type: 'error',
163
+ text: disabledDateErrorMessage
164
+ });
165
+ }
166
+
167
+ // check if date is valid
168
+ if (!_DateTime.DateTime.parse(date, this.locale(), this.timezone(), [_DateTime.DateTime.momentISOFormat, 'llll', 'LLLL', 'lll', 'LLL', 'll', 'LL', 'l', 'L'], true).isValid()) {
169
+ messages.push(typeof invalidDateErrorMessage === 'function' ? invalidDateErrorMessage(date) : {
170
+ type: 'error',
171
+ text: invalidDateErrorMessage
172
+ });
173
+ }
174
+ return messages;
175
+ };
176
+ handleHideCalendar = (event, setectedDate) => {
177
+ if (!this.props.children) {
178
+ const dateString = setectedDate || this.props.value;
179
+ const messages = [];
180
+ if (this.props.onRequestValidateDate) {
181
+ const userValidatedDate = this.props.onRequestValidateDate?.(event, dateString || '', this.validateDate(dateString || ''));
182
+ messages.push(...(userValidatedDate || []));
183
+ } else {
184
+ if (dateString) {
185
+ messages.push(...this.validateDate(dateString));
186
+ }
187
+ }
188
+ this.setState({
189
+ messages,
190
+ isShowingCalendar: false
191
+ });
192
+ } else {
193
+ this.props.onRequestValidateDate?.(event);
194
+ this.props.onRequestHideCalendar?.(event);
195
+ }
196
+ };
197
+ handleHighlightOption = (event, {
198
+ direction
199
+ }) => {
200
+ const {
201
+ onRequestSelectNextDay,
202
+ onRequestSelectPrevDay,
203
+ onChange,
204
+ value,
205
+ currentDate
206
+ } = this.props;
207
+ const isValueValid = value && _DateTime.DateTime.parse(value, this.locale(), this.timezone()).isValid();
208
+ if (direction === -1) {
209
+ if (onRequestSelectPrevDay) {
210
+ onRequestSelectPrevDay?.(event);
211
+ } else {
212
+ // @ts-expect-error TODO
213
+ onChange(event, {
214
+ value: _DateTime.DateTime.parse(isValueValid ? value : currentDate, this.locale(), this.timezone()).subtract(1, 'day').format('MMMM D, YYYY')
215
+ });
216
+ this.setState({
217
+ messages: []
218
+ });
219
+ }
220
+ }
221
+ if (direction === 1) {
222
+ if (onRequestSelectNextDay) {
223
+ onRequestSelectNextDay?.(event);
224
+ } else {
225
+ // @ts-expect-error TODO
226
+ onChange(event, {
227
+ value: _DateTime.DateTime.parse(isValueValid ? value : currentDate, this.locale(), this.timezone()).add(1, 'day').format('MMMM D, YYYY')
228
+ });
229
+ this.setState({
230
+ messages: []
231
+ });
232
+ }
233
+ }
234
+ };
227
235
  renderMonthNavigationButton(type = 'prev') {
228
- const _this$props0 = this.props,
229
- renderPrevMonthButton = _this$props0.renderPrevMonthButton,
230
- renderNextMonthButton = _this$props0.renderNextMonthButton;
236
+ const {
237
+ renderPrevMonthButton,
238
+ renderNextMonthButton
239
+ } = this.props;
231
240
  const button = type === 'prev' ? renderPrevMonthButton : renderNextMonthButton;
232
241
  return button && (0, _safeCloneElement.safeCloneElement)((0, _callRenderProp.callRenderProp)(button), {
233
242
  tabIndex: -1
@@ -237,9 +246,10 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyleLegacy)(_style
237
246
  const children = this.props.children;
238
247
  if (!children) return;
239
248
  return _react.Children.map(children, day => {
240
- const _day$props = day.props,
241
- date = _day$props.date,
242
- isOutsideMonth = _day$props.isOutsideMonth;
249
+ const {
250
+ date,
251
+ isOutsideMonth
252
+ } = day.props;
243
253
  const props = {
244
254
  tabIndex: -1,
245
255
  id: this.formatDateId(date)
@@ -257,24 +267,25 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyleLegacy)(_style
257
267
  getListProps,
258
268
  getOptionProps
259
269
  }) {
260
- const _this$props1 = this.props,
261
- onRequestRenderNextMonth = _this$props1.onRequestRenderNextMonth,
262
- onRequestRenderPrevMonth = _this$props1.onRequestRenderPrevMonth,
263
- renderNavigationLabel = _this$props1.renderNavigationLabel,
264
- renderWeekdayLabels = _this$props1.renderWeekdayLabels,
265
- value = _this$props1.value,
266
- onChange = _this$props1.onChange,
267
- disabledDates = _this$props1.disabledDates,
268
- currentDate = _this$props1.currentDate;
270
+ const {
271
+ onRequestRenderNextMonth,
272
+ onRequestRenderPrevMonth,
273
+ renderNavigationLabel,
274
+ renderWeekdayLabels,
275
+ value,
276
+ onChange,
277
+ disabledDates,
278
+ currentDate
279
+ } = this.props;
269
280
  const isValidDate = value ? _DateTime.DateTime.parse(value, this.locale(), this.timezone()).isValid() : false;
270
281
  const noChildrenProps = this.props.children ? {} : {
271
282
  disabledDates,
272
283
  currentDate,
273
- selectedDate: isValidDate ? value : void 0,
274
- visibleMonth: isValidDate ? value : void 0,
284
+ selectedDate: isValidDate ? value : undefined,
285
+ visibleMonth: isValidDate ? value : undefined,
275
286
  onDateSelected: (dateString, momentDate, e) => {
276
287
  // @ts-expect-error TODO
277
- onChange === null || onChange === void 0 ? void 0 : onChange(e, {
288
+ onChange?.(e, {
278
289
  value: `${momentDate.format('MMMM')} ${momentDate.format('D')}, ${momentDate.format('YYYY')}`
279
290
  });
280
291
  this.handleHideCalendar(e, dateString);
@@ -297,28 +308,33 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyleLegacy)(_style
297
308
  getInputProps,
298
309
  getTriggerProps
299
310
  }) {
300
- const _this$props10 = this.props,
301
- renderLabel = _this$props10.renderLabel,
302
- value = _this$props10.value,
303
- placeholder = _this$props10.placeholder,
304
- onBlur = _this$props10.onBlur,
305
- isRequired = _this$props10.isRequired,
306
- size = _this$props10.size,
307
- isInline = _this$props10.isInline,
308
- layout = _this$props10.layout,
309
- width = _this$props10.width,
310
- onRequestValidateDate = _this$props10.onRequestValidateDate,
311
- onRequestShowCalendar = _this$props10.onRequestShowCalendar,
312
- onRequestHideCalendar = _this$props10.onRequestHideCalendar,
313
- onRequestSelectNextDay = _this$props10.onRequestSelectNextDay,
314
- onRequestSelectPrevDay = _this$props10.onRequestSelectPrevDay,
315
- onRequestRenderNextMonth = _this$props10.onRequestRenderNextMonth,
316
- onRequestRenderPrevMonth = _this$props10.onRequestRenderPrevMonth,
317
- rest = (0, _objectWithoutProperties2.default)(_this$props10, _excluded);
318
- const interaction = this.interaction;
319
- const _getTriggerProps = getTriggerProps(),
320
- ref = _getTriggerProps.ref,
321
- triggerProps = (0, _objectWithoutProperties2.default)(_getTriggerProps, _excluded2);
311
+ const {
312
+ renderLabel,
313
+ value,
314
+ placeholder,
315
+ onBlur,
316
+ isRequired,
317
+ size,
318
+ isInline,
319
+ layout,
320
+ width,
321
+ onRequestValidateDate,
322
+ onRequestShowCalendar,
323
+ onRequestHideCalendar,
324
+ onRequestSelectNextDay,
325
+ onRequestSelectPrevDay,
326
+ onRequestRenderNextMonth,
327
+ onRequestRenderPrevMonth,
328
+ ...rest
329
+ } = this.props;
330
+ const {
331
+ interaction
332
+ } = this;
333
+ const {
334
+ ref,
335
+ // Apply this to the actual inputRef
336
+ ...triggerProps
337
+ } = getTriggerProps();
322
338
  const messages = this.props.messages || this.state.messages;
323
339
  return (0, _jsxRuntime.jsx)(_v11_3.TextInput, {
324
340
  ...triggerProps,
@@ -337,27 +353,28 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyleLegacy)(_style
337
353
  interaction,
338
354
  isRequired,
339
355
  display: isInline ? 'inline-block' : 'block',
340
- renderAfterInput: _IconCalendarMonthLin || (_IconCalendarMonthLin = (0, _jsxRuntime.jsx)(_IconCalendarMonthLine.IconCalendarMonthLine, {
356
+ renderAfterInput: (0, _jsxRuntime.jsx)(_IconCalendarMonthLine.IconCalendarMonthLine, {
341
357
  inline: false
342
- }))
358
+ })
343
359
  }),
344
360
  onKeyDown: e => {
345
- var _triggerProps$onKeyDo;
346
361
  if (!this.props.children) {
347
362
  if (e.key === 'Enter') {
348
363
  // @ts-expect-error TODO
349
364
  this.handleHideCalendar(e);
350
365
  }
351
366
  }
352
- (_triggerProps$onKeyDo = triggerProps.onKeyDown) === null || _triggerProps$onKeyDo === void 0 ? void 0 : _triggerProps$onKeyDo.call(triggerProps, e);
367
+ triggerProps.onKeyDown?.(e);
353
368
  }
354
369
  });
355
370
  }
371
+ shouldShowCalendar = () => this.props.children ? this.props.isShowingCalendar : this.state.isShowingCalendar;
356
372
  render() {
357
- const _this$props11 = this.props,
358
- placement = _this$props11.placement,
359
- assistiveText = _this$props11.assistiveText,
360
- styles = _this$props11.styles;
373
+ const {
374
+ placement,
375
+ assistiveText,
376
+ styles
377
+ } = this.props;
361
378
  const isShowingCalendar = this.shouldShowCalendar();
362
379
  return (0, _jsxRuntime.jsx)(_Selectable.Selectable, {
363
380
  isShowingOptions: isShowingCalendar,
@@ -376,7 +393,7 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyleLegacy)(_style
376
393
  getDescriptionProps
377
394
  }) => (0, _jsxRuntime.jsxs)("span", {
378
395
  ...getRootProps({
379
- css: styles === null || styles === void 0 ? void 0 : styles.dateInput
396
+ css: styles?.dateInput
380
397
  }),
381
398
  ref: el => {
382
399
  this.ref = el;
@@ -387,7 +404,7 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyleLegacy)(_style
387
404
  getTriggerProps
388
405
  }), (0, _jsxRuntime.jsx)("span", {
389
406
  ...getDescriptionProps(),
390
- css: styles === null || styles === void 0 ? void 0 : styles.assistiveText,
407
+ css: styles?.assistiveText,
391
408
  children: assistiveText
392
409
  }), (0, _jsxRuntime.jsx)(_v11_2.Popover, {
393
410
  placement: placement,
@@ -403,16 +420,5 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyleLegacy)(_style
403
420
  })
404
421
  });
405
422
  }
406
- }, _DateInput.displayName = "DateInput", _DateInput.componentId = 'DateInput', _DateInput.Day = _v11_.Calendar.Day, _DateInput.allowedProps = _props2.allowedProps, _DateInput.defaultProps = {
407
- value: '',
408
- size: 'medium',
409
- onBlur: () => {},
410
- // must have a default so createChainedFunction works
411
- isRequired: false,
412
- isInline: false,
413
- layout: 'stacked',
414
- display: 'inline-block',
415
- placement: 'bottom center',
416
- isShowingCalendar: false
417
- }, _DateInput)) || _class);
423
+ }) || _class);
418
424
  var _default = exports.default = DateInput;