@instructure/ui-date-input 10.16.1-snapshot-0 → 10.16.1

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.
@@ -26,8 +26,7 @@ var _dec, _dec2, _class, _DateInput, _IconCalendarMonthLin;
26
26
  * SOFTWARE.
27
27
  */
28
28
 
29
- /** @jsx jsx */
30
- import React, { Children, Component } from 'react';
29
+ import { Children, Component } from 'react';
31
30
  import { Calendar } from '@instructure/ui-calendar';
32
31
  import { IconCalendarMonthLine } from '@instructure/ui-icons';
33
32
  import { Popover } from '@instructure/ui-popover';
@@ -37,9 +36,10 @@ import { createChainedFunction } from '@instructure/ui-utils';
37
36
  import { getInteraction, callRenderProp, safeCloneElement, passthroughProps } from '@instructure/ui-react-utils';
38
37
  import { testable } from '@instructure/ui-testable';
39
38
  import { DateTime, Locale } from '@instructure/ui-i18n';
40
- import { withStyle, jsx } from '@instructure/emotion';
39
+ import { withStyle } from '@instructure/emotion';
41
40
  import generateStyle from './styles';
42
41
  import { propTypes, allowedProps } from './props';
42
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
43
43
  /**
44
44
  ---
45
45
  category: components
@@ -271,14 +271,18 @@ let DateInput = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec
271
271
  this.handleHideCalendar(e, dateString);
272
272
  }
273
273
  };
274
- return jsx(Calendar, Object.assign({}, getListProps({
275
- onRequestRenderNextMonth,
276
- onRequestRenderPrevMonth,
277
- renderNavigationLabel,
278
- renderWeekdayLabels,
279
- renderNextMonthButton: this.renderMonthNavigationButton('next'),
280
- renderPrevMonthButton: this.renderMonthNavigationButton('prev')
281
- }), noChildrenProps), this.renderDays(getOptionProps));
274
+ return _jsx(Calendar, {
275
+ ...getListProps({
276
+ onRequestRenderNextMonth,
277
+ onRequestRenderPrevMonth,
278
+ renderNavigationLabel,
279
+ renderWeekdayLabels,
280
+ renderNextMonthButton: this.renderMonthNavigationButton('next'),
281
+ renderPrevMonthButton: this.renderMonthNavigationButton('prev')
282
+ }),
283
+ ...noChildrenProps,
284
+ children: this.renderDays(getOptionProps)
285
+ });
282
286
  }
283
287
  renderInput({
284
288
  getInputProps,
@@ -307,24 +311,27 @@ let DateInput = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec
307
311
  ref = _getTriggerProps.ref,
308
312
  triggerProps = _objectWithoutProperties(_getTriggerProps, _excluded2);
309
313
  const messages = this.props.messages || this.state.messages;
310
- return jsx(TextInput, Object.assign({}, triggerProps, passthroughProps(rest), getInputProps({
311
- renderLabel: callRenderProp(renderLabel),
312
- value,
313
- placeholder,
314
- size,
315
- layout,
316
- width,
317
- messages,
318
- onChange: this.handleInputChange,
319
- onBlur: createChainedFunction(onBlur, this.handleHideCalendar),
320
- inputRef: createChainedFunction(ref, this.handleInputRef),
321
- interaction,
322
- isRequired,
323
- display: isInline ? 'inline-block' : 'block',
324
- renderAfterInput: _IconCalendarMonthLin || (_IconCalendarMonthLin = jsx(IconCalendarMonthLine, {
325
- inline: false
326
- }))
327
- }), {
314
+ return _jsx(TextInput, {
315
+ ...triggerProps,
316
+ ...passthroughProps(rest),
317
+ ...getInputProps({
318
+ renderLabel: callRenderProp(renderLabel),
319
+ value,
320
+ placeholder,
321
+ size,
322
+ layout,
323
+ width,
324
+ messages,
325
+ onChange: this.handleInputChange,
326
+ onBlur: createChainedFunction(onBlur, this.handleHideCalendar),
327
+ inputRef: createChainedFunction(ref, this.handleInputRef),
328
+ interaction,
329
+ isRequired,
330
+ display: isInline ? 'inline-block' : 'block',
331
+ renderAfterInput: _IconCalendarMonthLin || (_IconCalendarMonthLin = _jsx(IconCalendarMonthLine, {
332
+ inline: false
333
+ }))
334
+ }),
328
335
  onKeyDown: e => {
329
336
  var _triggerProps$onKeyDo;
330
337
  if (!this.props.children) {
@@ -335,7 +342,7 @@ let DateInput = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec
335
342
  }
336
343
  (_triggerProps$onKeyDo = triggerProps.onKeyDown) === null || _triggerProps$onKeyDo === void 0 ? void 0 : _triggerProps$onKeyDo.call(triggerProps, e);
337
344
  }
338
- }));
345
+ });
339
346
  }
340
347
  render() {
341
348
  const _this$props13 = this.props,
@@ -343,40 +350,46 @@ let DateInput = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec
343
350
  assistiveText = _this$props13.assistiveText,
344
351
  styles = _this$props13.styles;
345
352
  const isShowingCalendar = this.shouldShowCalendar();
346
- return jsx(Selectable, {
353
+ return _jsx(Selectable, {
347
354
  isShowingOptions: isShowingCalendar,
348
355
  onRequestShowOptions: this.handleShowCalendar,
349
356
  onRequestHideOptions: this.handleHideCalendar,
350
357
  onRequestHighlightOption: this.handleHighlightOption,
351
358
  onRequestSelectOption: e => this.handleHideCalendar(e),
352
359
  selectedOptionId: this.selectedDateId,
353
- highlightedOptionId: this.selectedDateId
354
- }, ({
355
- getRootProps,
356
- getInputProps,
357
- getTriggerProps,
358
- getListProps,
359
- getOptionProps,
360
- getDescriptionProps
361
- }) => jsx("span", Object.assign({}, getRootProps({
362
- css: styles === null || styles === void 0 ? void 0 : styles.dateInput
363
- }), {
364
- ref: el => this.ref = el
365
- }), this.renderInput({
366
- getInputProps,
367
- getTriggerProps
368
- }), jsx("span", Object.assign({}, getDescriptionProps(), {
369
- css: styles === null || styles === void 0 ? void 0 : styles.assistiveText
370
- }), assistiveText), jsx(Popover, {
371
- placement: placement,
372
- isShowingContent: isShowingCalendar,
373
- positionTarget: this._input,
374
- shouldReturnFocus: false,
375
- shouldFocusContentOnTriggerBlur: true
376
- }, this.renderCalendar({
377
- getListProps,
378
- getOptionProps
379
- }))));
360
+ highlightedOptionId: this.selectedDateId,
361
+ children: ({
362
+ getRootProps,
363
+ getInputProps,
364
+ getTriggerProps,
365
+ getListProps,
366
+ getOptionProps,
367
+ getDescriptionProps
368
+ }) => _jsxs("span", {
369
+ ...getRootProps({
370
+ css: styles === null || styles === void 0 ? void 0 : styles.dateInput
371
+ }),
372
+ ref: el => this.ref = el,
373
+ children: [this.renderInput({
374
+ getInputProps,
375
+ getTriggerProps
376
+ }), _jsx("span", {
377
+ ...getDescriptionProps(),
378
+ css: styles === null || styles === void 0 ? void 0 : styles.assistiveText,
379
+ children: assistiveText
380
+ }), _jsx(Popover, {
381
+ placement: placement,
382
+ isShowingContent: isShowingCalendar,
383
+ positionTarget: this._input,
384
+ shouldReturnFocus: false,
385
+ shouldFocusContentOnTriggerBlur: true,
386
+ children: this.renderCalendar({
387
+ getListProps,
388
+ getOptionProps
389
+ })
390
+ })]
391
+ })
392
+ });
380
393
  }
381
394
  }, _DateInput.displayName = "DateInput", _DateInput.componentId = 'DateInput', _DateInput.Day = Calendar.Day, _DateInput.propTypes = propTypes, _DateInput.allowedProps = allowedProps, _DateInput.defaultProps = {
382
395
  value: '',
@@ -23,20 +23,21 @@ var _DateInputExample, _DateInputExample2, _IconHeartLine, _DateInputExample3, _
23
23
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
24
  * SOFTWARE.
25
25
  */
26
- import React, { useState } from 'react';
26
+ import { useState } from 'react';
27
27
  import { fireEvent, render, screen, waitFor } from '@testing-library/react';
28
28
  import { vi } from 'vitest';
29
29
  import userEvent from '@testing-library/user-event';
30
30
  import '@testing-library/jest-dom';
31
31
  import { IconHeartLine } from '@instructure/ui-icons';
32
32
  import { DateInput2 } from '../index';
33
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
33
34
  const LABEL_TEXT = 'Choose a date';
34
35
  const DateInputExample = () => {
35
36
  const _useState = useState(''),
36
37
  _useState2 = _slicedToArray(_useState, 2),
37
38
  inputValue = _useState2[0],
38
39
  setInputValue = _useState2[1];
39
- return /*#__PURE__*/React.createElement(DateInput2, {
40
+ return _jsx(DateInput2, {
40
41
  renderLabel: LABEL_TEXT,
41
42
  screenReaderLabels: {
42
43
  calendarIcon: 'Calendar',
@@ -62,14 +63,14 @@ describe('<DateInput2 />', () => {
62
63
  consoleErrorMock.mockRestore();
63
64
  });
64
65
  it('should render an input', async () => {
65
- const _render = render(_DateInputExample || (_DateInputExample = /*#__PURE__*/React.createElement(DateInputExample, null))),
66
+ const _render = render(_DateInputExample || (_DateInputExample = _jsx(DateInputExample, {}))),
66
67
  container = _render.container;
67
68
  const dateInput = container.querySelector('input');
68
69
  expect(dateInput).toBeInTheDocument();
69
70
  expect(dateInput).toHaveAttribute('type', 'text');
70
71
  });
71
72
  it('should render an input label', async () => {
72
- const _render2 = render(_DateInputExample2 || (_DateInputExample2 = /*#__PURE__*/React.createElement(DateInputExample, null))),
73
+ const _render2 = render(_DateInputExample2 || (_DateInputExample2 = _jsx(DateInputExample, {}))),
73
74
  container = _render2.container;
74
75
  const label = container.querySelector('label');
75
76
  expect(label).toBeInTheDocument();
@@ -77,7 +78,7 @@ describe('<DateInput2 />', () => {
77
78
  });
78
79
  it('should render an input placeholder', async () => {
79
80
  const placeholder = 'Placeholder';
80
- render(/*#__PURE__*/React.createElement(DateInput2, {
81
+ render(_jsx(DateInput2, {
81
82
  renderLabel: "Choose a date",
82
83
  screenReaderLabels: {
83
84
  calendarIcon: 'Calendar',
@@ -92,7 +93,7 @@ describe('<DateInput2 />', () => {
92
93
  });
93
94
  it('should render a calendar icon with screen reader label', async () => {
94
95
  const iconLabel = 'Calendar icon Label';
95
- const _render3 = render(/*#__PURE__*/React.createElement(DateInput2, {
96
+ const _render3 = render(_jsx(DateInput2, {
96
97
  renderLabel: "Choose a date",
97
98
  screenReaderLabels: {
98
99
  calendarIcon: iconLabel,
@@ -109,7 +110,7 @@ describe('<DateInput2 />', () => {
109
110
  });
110
111
  it('should render a custom calendar icon with screen reader label', async () => {
111
112
  const iconLabel = 'Calendar icon Label';
112
- const _render4 = render(/*#__PURE__*/React.createElement(DateInput2, {
113
+ const _render4 = render(_jsx(DateInput2, {
113
114
  renderLabel: "Choose a date",
114
115
  screenReaderLabels: {
115
116
  calendarIcon: iconLabel,
@@ -117,7 +118,7 @@ describe('<DateInput2 />', () => {
117
118
  prevMonthButton: 'Previous month'
118
119
  },
119
120
  value: "",
120
- renderCalendarIcon: _IconHeartLine || (_IconHeartLine = /*#__PURE__*/React.createElement(IconHeartLine, null))
121
+ renderCalendarIcon: _IconHeartLine || (_IconHeartLine = _jsx(IconHeartLine, {}))
121
122
  })),
122
123
  container = _render4.container;
123
124
  const calendarIcon = container.querySelector('svg[name="IconHeart"]');
@@ -126,12 +127,12 @@ describe('<DateInput2 />', () => {
126
127
  expect(calendarLabel).toBeInTheDocument();
127
128
  });
128
129
  it('should not show calendar table by default', async () => {
129
- render(_DateInputExample3 || (_DateInputExample3 = /*#__PURE__*/React.createElement(DateInputExample, null)));
130
+ render(_DateInputExample3 || (_DateInputExample3 = _jsx(DateInputExample, {})));
130
131
  const calendarTable = screen.queryByRole('table');
131
132
  expect(calendarTable).not.toBeInTheDocument();
132
133
  });
133
134
  it('should show calendar table when calendar button is clicked', async () => {
134
- render(_DateInputExample4 || (_DateInputExample4 = /*#__PURE__*/React.createElement(DateInputExample, null)));
135
+ render(_DateInputExample4 || (_DateInputExample4 = _jsx(DateInputExample, {})));
135
136
  const calendarButton = screen.getByRole('button');
136
137
  expect(calendarButton).toBeInTheDocument();
137
138
  await userEvent.click(calendarButton);
@@ -143,7 +144,7 @@ describe('<DateInput2 />', () => {
143
144
  it('should render navigation arrow buttons with screen reader labels', async () => {
144
145
  const nextMonthLabel = 'Next month';
145
146
  const prevMonthLabel = 'Previous month';
146
- render(/*#__PURE__*/React.createElement(DateInput2, {
147
+ render(_jsx(DateInput2, {
147
148
  renderLabel: "Choose a date",
148
149
  screenReaderLabels: {
149
150
  calendarIcon: 'Calendar',
@@ -175,7 +176,7 @@ describe('<DateInput2 />', () => {
175
176
  });
176
177
  it('should programmatically set and render the initial value', async () => {
177
178
  const value = '26/03/2024';
178
- render(/*#__PURE__*/React.createElement(DateInput2, {
179
+ render(_jsx(DateInput2, {
179
180
  renderLabel: "Choose a date",
180
181
  screenReaderLabels: {
181
182
  calendarIcon: 'Calendar',
@@ -192,7 +193,7 @@ describe('<DateInput2 />', () => {
192
193
  });
193
194
  it('should set interaction type to disabled', async () => {
194
195
  const interactionDisabled = 'disabled';
195
- const _render5 = render(/*#__PURE__*/React.createElement(DateInput2, {
196
+ const _render5 = render(_jsx(DateInput2, {
196
197
  renderLabel: "Choose a date",
197
198
  screenReaderLabels: {
198
199
  calendarIcon: 'Calendar',
@@ -208,7 +209,7 @@ describe('<DateInput2 />', () => {
208
209
  });
209
210
  it('should set interaction type to readonly', async () => {
210
211
  const interactionReadOnly = 'readonly';
211
- const _render6 = render(/*#__PURE__*/React.createElement(DateInput2, {
212
+ const _render6 = render(_jsx(DateInput2, {
212
213
  renderLabel: "Choose a date",
213
214
  screenReaderLabels: {
214
215
  calendarIcon: 'Calendar',
@@ -230,7 +231,7 @@ describe('<DateInput2 />', () => {
230
231
  });
231
232
  });
232
233
  it('should set required', async () => {
233
- const _render7 = render(/*#__PURE__*/React.createElement(DateInput2, {
234
+ const _render7 = render(_jsx(DateInput2, {
234
235
  renderLabel: "Choose a date",
235
236
  screenReaderLabels: {
236
237
  calendarIcon: 'Calendar',
@@ -246,7 +247,7 @@ describe('<DateInput2 />', () => {
246
247
  });
247
248
  it('should call onBlur', async () => {
248
249
  const onBlur = vi.fn();
249
- render(/*#__PURE__*/React.createElement(DateInput2, {
250
+ render(_jsx(DateInput2, {
250
251
  renderLabel: "Choose a date",
251
252
  screenReaderLabels: {
252
253
  calendarIcon: 'Calendar',
@@ -269,7 +270,7 @@ describe('<DateInput2 />', () => {
269
270
  _useState4 = _slicedToArray(_useState3, 2),
270
271
  inputValue = _useState4[0],
271
272
  setInputValue = _useState4[1];
272
- return /*#__PURE__*/React.createElement(DateInput2, {
273
+ return _jsx(DateInput2, {
273
274
  renderLabel: LABEL_TEXT,
274
275
  screenReaderLabels: {
275
276
  calendarIcon: 'Calendar',
@@ -283,7 +284,7 @@ describe('<DateInput2 />', () => {
283
284
  invalidDateErrorMessage: errorMsg
284
285
  });
285
286
  };
286
- render(/*#__PURE__*/React.createElement(Example, null));
287
+ render(_jsx(Example, {}));
287
288
  expect(screen.queryByText(errorMsg)).not.toBeInTheDocument();
288
289
  const dateInput = screen.getByLabelText(LABEL_TEXT);
289
290
  await userEvent.click(dateInput);
@@ -309,7 +310,7 @@ describe('<DateInput2 />', () => {
309
310
  type: 'screenreader-only',
310
311
  text: 'Screenreader'
311
312
  }];
312
- render(/*#__PURE__*/React.createElement(DateInput2, {
313
+ render(_jsx(DateInput2, {
313
314
  renderLabel: "Choose a date",
314
315
  screenReaderLabels: {
315
316
  calendarIcon: 'Calendar',
@@ -24,7 +24,6 @@ var _IconCalendarMonthLin, _IconArrowOpenEndSoli, _IconArrowOpenStartSo;
24
24
  * SOFTWARE.
25
25
  */
26
26
 
27
- /** @jsx jsx */
28
27
  import { useState, useEffect, useContext } from 'react';
29
28
  import { Calendar } from '@instructure/ui-calendar';
30
29
  import { IconButton } from '@instructure/ui-buttons';
@@ -33,8 +32,8 @@ import { Popover } from '@instructure/ui-popover';
33
32
  import { TextInput } from '@instructure/ui-text-input';
34
33
  import { callRenderProp, passthroughProps } from '@instructure/ui-react-utils';
35
34
  import { ApplyLocaleContext, Locale } from '@instructure/ui-i18n';
36
- import { jsx } from '@instructure/emotion';
37
35
  import { propTypes } from './props';
36
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
38
37
  function parseLocaleDate(dateString = '', locale, timeZone) {
39
38
  // This function may seem complicated but it basically does one thing:
40
39
  // Given a dateString, a locale and a timeZone. The dateString is assumed to be formatted according
@@ -249,7 +248,8 @@ const DateInput2 = ({
249
248
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(e, value || '', utcIsoDate);
250
249
  };
251
250
  const selectedDate = parseDate(value)[1];
252
- return jsx(TextInput, Object.assign({}, passthroughProps(rest), {
251
+ return _jsx(TextInput, {
252
+ ...passthroughProps(rest),
253
253
  inputRef: inputRef,
254
254
  renderLabel: renderLabel,
255
255
  onChange: handleInputChange,
@@ -262,49 +262,51 @@ const DateInput2 = ({
262
262
  messages: inputMessages,
263
263
  interaction: interaction,
264
264
  margin: margin,
265
- renderAfterInput: jsx(Popover, {
266
- renderTrigger: jsx(IconButton, {
265
+ renderAfterInput: _jsx(Popover, {
266
+ renderTrigger: _jsx(IconButton, {
267
267
  withBackground: false,
268
268
  withBorder: false,
269
269
  screenReaderLabel: screenReaderLabels.calendarIcon,
270
270
  shape: "circle",
271
- interaction: interaction
272
- }, renderCalendarIcon ? callRenderProp(renderCalendarIcon) : _IconCalendarMonthLin || (_IconCalendarMonthLin = jsx(IconCalendarMonthLine, null))),
271
+ interaction: interaction,
272
+ children: renderCalendarIcon ? callRenderProp(renderCalendarIcon) : _IconCalendarMonthLin || (_IconCalendarMonthLin = _jsx(IconCalendarMonthLine, {}))
273
+ }),
273
274
  isShowingContent: showPopover,
274
275
  onShowContent: () => setShowPopover(true),
275
276
  onHideContent: () => setShowPopover(false),
276
277
  on: "click",
277
278
  shouldContainFocus: true,
278
279
  shouldReturnFocus: true,
279
- shouldCloseOnDocumentClick: true
280
- }, jsx(Calendar, {
281
- withYearPicker: withYearPicker,
282
- onDateSelected: handleDateSelected,
283
- selectedDate: selectedDate,
284
- disabledDates: disabledDates,
285
- visibleMonth: selectedDate,
286
- locale: getLocale(),
287
- timezone: getTimezone(),
288
- renderNextMonthButton: jsx(IconButton, {
289
- size: "small",
290
- withBackground: false,
291
- withBorder: false,
292
- renderIcon: _IconArrowOpenEndSoli || (_IconArrowOpenEndSoli = jsx(IconArrowOpenEndSolid, {
293
- color: "primary"
294
- })),
295
- screenReaderLabel: screenReaderLabels.nextMonthButton
296
- }),
297
- renderPrevMonthButton: jsx(IconButton, {
298
- size: "small",
299
- withBackground: false,
300
- withBorder: false,
301
- renderIcon: _IconArrowOpenStartSo || (_IconArrowOpenStartSo = jsx(IconArrowOpenStartSolid, {
302
- color: "primary"
303
- })),
304
- screenReaderLabel: screenReaderLabels.prevMonthButton
280
+ shouldCloseOnDocumentClick: true,
281
+ children: _jsx(Calendar, {
282
+ withYearPicker: withYearPicker,
283
+ onDateSelected: handleDateSelected,
284
+ selectedDate: selectedDate,
285
+ disabledDates: disabledDates,
286
+ visibleMonth: selectedDate,
287
+ locale: getLocale(),
288
+ timezone: getTimezone(),
289
+ renderNextMonthButton: _jsx(IconButton, {
290
+ size: "small",
291
+ withBackground: false,
292
+ withBorder: false,
293
+ renderIcon: _IconArrowOpenEndSoli || (_IconArrowOpenEndSoli = _jsx(IconArrowOpenEndSolid, {
294
+ color: "primary"
295
+ })),
296
+ screenReaderLabel: screenReaderLabels.nextMonthButton
297
+ }),
298
+ renderPrevMonthButton: _jsx(IconButton, {
299
+ size: "small",
300
+ withBackground: false,
301
+ withBorder: false,
302
+ renderIcon: _IconArrowOpenStartSo || (_IconArrowOpenStartSo = _jsx(IconArrowOpenStartSolid, {
303
+ color: "primary"
304
+ })),
305
+ screenReaderLabel: screenReaderLabels.prevMonthButton
306
+ })
305
307
  })
306
- }))
307
- }));
308
+ })
309
+ });
308
310
  };
309
311
  DateInput2.propTypes = propTypes;
310
312
  export default DateInput2;