@instructure/ui-date-input 10.16.1-pr-snapshot-1744893671793 → 10.16.1-snapshot-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.
@@ -26,7 +26,8 @@ var _dec, _dec2, _class, _DateInput, _IconCalendarMonthLin;
26
26
  * SOFTWARE.
27
27
  */
28
28
 
29
- import { Children, Component } from 'react';
29
+ /** @jsx jsx */
30
+ import React, { Children, Component } from 'react';
30
31
  import { Calendar } from '@instructure/ui-calendar';
31
32
  import { IconCalendarMonthLine } from '@instructure/ui-icons';
32
33
  import { Popover } from '@instructure/ui-popover';
@@ -36,10 +37,9 @@ import { createChainedFunction } from '@instructure/ui-utils';
36
37
  import { getInteraction, callRenderProp, safeCloneElement, passthroughProps } from '@instructure/ui-react-utils';
37
38
  import { testable } from '@instructure/ui-testable';
38
39
  import { DateTime, Locale } from '@instructure/ui-i18n';
39
- import { withStyle } from '@instructure/emotion';
40
+ import { withStyle, jsx } from '@instructure/emotion';
40
41
  import generateStyle from './styles';
41
42
  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,18 +271,14 @@ let DateInput = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec
271
271
  this.handleHideCalendar(e, dateString);
272
272
  }
273
273
  };
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
- });
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));
286
282
  }
287
283
  renderInput({
288
284
  getInputProps,
@@ -311,27 +307,24 @@ let DateInput = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec
311
307
  ref = _getTriggerProps.ref,
312
308
  triggerProps = _objectWithoutProperties(_getTriggerProps, _excluded2);
313
309
  const messages = this.props.messages || this.state.messages;
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
- }),
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
+ }), {
335
328
  onKeyDown: e => {
336
329
  var _triggerProps$onKeyDo;
337
330
  if (!this.props.children) {
@@ -342,7 +335,7 @@ let DateInput = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec
342
335
  }
343
336
  (_triggerProps$onKeyDo = triggerProps.onKeyDown) === null || _triggerProps$onKeyDo === void 0 ? void 0 : _triggerProps$onKeyDo.call(triggerProps, e);
344
337
  }
345
- });
338
+ }));
346
339
  }
347
340
  render() {
348
341
  const _this$props13 = this.props,
@@ -350,46 +343,40 @@ let DateInput = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec
350
343
  assistiveText = _this$props13.assistiveText,
351
344
  styles = _this$props13.styles;
352
345
  const isShowingCalendar = this.shouldShowCalendar();
353
- return _jsx(Selectable, {
346
+ return jsx(Selectable, {
354
347
  isShowingOptions: isShowingCalendar,
355
348
  onRequestShowOptions: this.handleShowCalendar,
356
349
  onRequestHideOptions: this.handleHideCalendar,
357
350
  onRequestHighlightOption: this.handleHighlightOption,
358
351
  onRequestSelectOption: e => this.handleHideCalendar(e),
359
352
  selectedOptionId: this.selectedDateId,
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
- });
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
+ }))));
393
380
  }
394
381
  }, _DateInput.displayName = "DateInput", _DateInput.componentId = 'DateInput', _DateInput.Day = Calendar.Day, _DateInput.propTypes = propTypes, _DateInput.allowedProps = allowedProps, _DateInput.defaultProps = {
395
382
  value: '',
@@ -23,21 +23,20 @@ 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 { useState } from 'react';
26
+ import React, { 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";
34
33
  const LABEL_TEXT = 'Choose a date';
35
34
  const DateInputExample = () => {
36
35
  const _useState = useState(''),
37
36
  _useState2 = _slicedToArray(_useState, 2),
38
37
  inputValue = _useState2[0],
39
38
  setInputValue = _useState2[1];
40
- return _jsx(DateInput2, {
39
+ return /*#__PURE__*/React.createElement(DateInput2, {
41
40
  renderLabel: LABEL_TEXT,
42
41
  screenReaderLabels: {
43
42
  calendarIcon: 'Calendar',
@@ -63,14 +62,14 @@ describe('<DateInput2 />', () => {
63
62
  consoleErrorMock.mockRestore();
64
63
  });
65
64
  it('should render an input', async () => {
66
- const _render = render(_DateInputExample || (_DateInputExample = _jsx(DateInputExample, {}))),
65
+ const _render = render(_DateInputExample || (_DateInputExample = /*#__PURE__*/React.createElement(DateInputExample, null))),
67
66
  container = _render.container;
68
67
  const dateInput = container.querySelector('input');
69
68
  expect(dateInput).toBeInTheDocument();
70
69
  expect(dateInput).toHaveAttribute('type', 'text');
71
70
  });
72
71
  it('should render an input label', async () => {
73
- const _render2 = render(_DateInputExample2 || (_DateInputExample2 = _jsx(DateInputExample, {}))),
72
+ const _render2 = render(_DateInputExample2 || (_DateInputExample2 = /*#__PURE__*/React.createElement(DateInputExample, null))),
74
73
  container = _render2.container;
75
74
  const label = container.querySelector('label');
76
75
  expect(label).toBeInTheDocument();
@@ -78,7 +77,7 @@ describe('<DateInput2 />', () => {
78
77
  });
79
78
  it('should render an input placeholder', async () => {
80
79
  const placeholder = 'Placeholder';
81
- render(_jsx(DateInput2, {
80
+ render(/*#__PURE__*/React.createElement(DateInput2, {
82
81
  renderLabel: "Choose a date",
83
82
  screenReaderLabels: {
84
83
  calendarIcon: 'Calendar',
@@ -93,7 +92,7 @@ describe('<DateInput2 />', () => {
93
92
  });
94
93
  it('should render a calendar icon with screen reader label', async () => {
95
94
  const iconLabel = 'Calendar icon Label';
96
- const _render3 = render(_jsx(DateInput2, {
95
+ const _render3 = render(/*#__PURE__*/React.createElement(DateInput2, {
97
96
  renderLabel: "Choose a date",
98
97
  screenReaderLabels: {
99
98
  calendarIcon: iconLabel,
@@ -110,7 +109,7 @@ describe('<DateInput2 />', () => {
110
109
  });
111
110
  it('should render a custom calendar icon with screen reader label', async () => {
112
111
  const iconLabel = 'Calendar icon Label';
113
- const _render4 = render(_jsx(DateInput2, {
112
+ const _render4 = render(/*#__PURE__*/React.createElement(DateInput2, {
114
113
  renderLabel: "Choose a date",
115
114
  screenReaderLabels: {
116
115
  calendarIcon: iconLabel,
@@ -118,7 +117,7 @@ describe('<DateInput2 />', () => {
118
117
  prevMonthButton: 'Previous month'
119
118
  },
120
119
  value: "",
121
- renderCalendarIcon: _IconHeartLine || (_IconHeartLine = _jsx(IconHeartLine, {}))
120
+ renderCalendarIcon: _IconHeartLine || (_IconHeartLine = /*#__PURE__*/React.createElement(IconHeartLine, null))
122
121
  })),
123
122
  container = _render4.container;
124
123
  const calendarIcon = container.querySelector('svg[name="IconHeart"]');
@@ -127,12 +126,12 @@ describe('<DateInput2 />', () => {
127
126
  expect(calendarLabel).toBeInTheDocument();
128
127
  });
129
128
  it('should not show calendar table by default', async () => {
130
- render(_DateInputExample3 || (_DateInputExample3 = _jsx(DateInputExample, {})));
129
+ render(_DateInputExample3 || (_DateInputExample3 = /*#__PURE__*/React.createElement(DateInputExample, null)));
131
130
  const calendarTable = screen.queryByRole('table');
132
131
  expect(calendarTable).not.toBeInTheDocument();
133
132
  });
134
133
  it('should show calendar table when calendar button is clicked', async () => {
135
- render(_DateInputExample4 || (_DateInputExample4 = _jsx(DateInputExample, {})));
134
+ render(_DateInputExample4 || (_DateInputExample4 = /*#__PURE__*/React.createElement(DateInputExample, null)));
136
135
  const calendarButton = screen.getByRole('button');
137
136
  expect(calendarButton).toBeInTheDocument();
138
137
  await userEvent.click(calendarButton);
@@ -144,7 +143,7 @@ describe('<DateInput2 />', () => {
144
143
  it('should render navigation arrow buttons with screen reader labels', async () => {
145
144
  const nextMonthLabel = 'Next month';
146
145
  const prevMonthLabel = 'Previous month';
147
- render(_jsx(DateInput2, {
146
+ render(/*#__PURE__*/React.createElement(DateInput2, {
148
147
  renderLabel: "Choose a date",
149
148
  screenReaderLabels: {
150
149
  calendarIcon: 'Calendar',
@@ -176,7 +175,7 @@ describe('<DateInput2 />', () => {
176
175
  });
177
176
  it('should programmatically set and render the initial value', async () => {
178
177
  const value = '26/03/2024';
179
- render(_jsx(DateInput2, {
178
+ render(/*#__PURE__*/React.createElement(DateInput2, {
180
179
  renderLabel: "Choose a date",
181
180
  screenReaderLabels: {
182
181
  calendarIcon: 'Calendar',
@@ -193,7 +192,7 @@ describe('<DateInput2 />', () => {
193
192
  });
194
193
  it('should set interaction type to disabled', async () => {
195
194
  const interactionDisabled = 'disabled';
196
- const _render5 = render(_jsx(DateInput2, {
195
+ const _render5 = render(/*#__PURE__*/React.createElement(DateInput2, {
197
196
  renderLabel: "Choose a date",
198
197
  screenReaderLabels: {
199
198
  calendarIcon: 'Calendar',
@@ -209,7 +208,7 @@ describe('<DateInput2 />', () => {
209
208
  });
210
209
  it('should set interaction type to readonly', async () => {
211
210
  const interactionReadOnly = 'readonly';
212
- const _render6 = render(_jsx(DateInput2, {
211
+ const _render6 = render(/*#__PURE__*/React.createElement(DateInput2, {
213
212
  renderLabel: "Choose a date",
214
213
  screenReaderLabels: {
215
214
  calendarIcon: 'Calendar',
@@ -231,7 +230,7 @@ describe('<DateInput2 />', () => {
231
230
  });
232
231
  });
233
232
  it('should set required', async () => {
234
- const _render7 = render(_jsx(DateInput2, {
233
+ const _render7 = render(/*#__PURE__*/React.createElement(DateInput2, {
235
234
  renderLabel: "Choose a date",
236
235
  screenReaderLabels: {
237
236
  calendarIcon: 'Calendar',
@@ -247,7 +246,7 @@ describe('<DateInput2 />', () => {
247
246
  });
248
247
  it('should call onBlur', async () => {
249
248
  const onBlur = vi.fn();
250
- render(_jsx(DateInput2, {
249
+ render(/*#__PURE__*/React.createElement(DateInput2, {
251
250
  renderLabel: "Choose a date",
252
251
  screenReaderLabels: {
253
252
  calendarIcon: 'Calendar',
@@ -270,7 +269,7 @@ describe('<DateInput2 />', () => {
270
269
  _useState4 = _slicedToArray(_useState3, 2),
271
270
  inputValue = _useState4[0],
272
271
  setInputValue = _useState4[1];
273
- return _jsx(DateInput2, {
272
+ return /*#__PURE__*/React.createElement(DateInput2, {
274
273
  renderLabel: LABEL_TEXT,
275
274
  screenReaderLabels: {
276
275
  calendarIcon: 'Calendar',
@@ -284,7 +283,7 @@ describe('<DateInput2 />', () => {
284
283
  invalidDateErrorMessage: errorMsg
285
284
  });
286
285
  };
287
- render(_jsx(Example, {}));
286
+ render(/*#__PURE__*/React.createElement(Example, null));
288
287
  expect(screen.queryByText(errorMsg)).not.toBeInTheDocument();
289
288
  const dateInput = screen.getByLabelText(LABEL_TEXT);
290
289
  await userEvent.click(dateInput);
@@ -310,7 +309,7 @@ describe('<DateInput2 />', () => {
310
309
  type: 'screenreader-only',
311
310
  text: 'Screenreader'
312
311
  }];
313
- render(_jsx(DateInput2, {
312
+ render(/*#__PURE__*/React.createElement(DateInput2, {
314
313
  renderLabel: "Choose a date",
315
314
  screenReaderLabels: {
316
315
  calendarIcon: 'Calendar',
@@ -24,6 +24,7 @@ var _IconCalendarMonthLin, _IconArrowOpenEndSoli, _IconArrowOpenStartSo;
24
24
  * SOFTWARE.
25
25
  */
26
26
 
27
+ /** @jsx jsx */
27
28
  import { useState, useEffect, useContext } from 'react';
28
29
  import { Calendar } from '@instructure/ui-calendar';
29
30
  import { IconButton } from '@instructure/ui-buttons';
@@ -32,8 +33,8 @@ import { Popover } from '@instructure/ui-popover';
32
33
  import { TextInput } from '@instructure/ui-text-input';
33
34
  import { callRenderProp, passthroughProps } from '@instructure/ui-react-utils';
34
35
  import { ApplyLocaleContext, Locale } from '@instructure/ui-i18n';
36
+ import { jsx } from '@instructure/emotion';
35
37
  import { propTypes } from './props';
36
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
37
38
  function parseLocaleDate(dateString = '', locale, timeZone) {
38
39
  // This function may seem complicated but it basically does one thing:
39
40
  // Given a dateString, a locale and a timeZone. The dateString is assumed to be formatted according
@@ -248,8 +249,7 @@ const DateInput2 = ({
248
249
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(e, value || '', utcIsoDate);
249
250
  };
250
251
  const selectedDate = parseDate(value)[1];
251
- return _jsx(TextInput, {
252
- ...passthroughProps(rest),
252
+ return jsx(TextInput, Object.assign({}, passthroughProps(rest), {
253
253
  inputRef: inputRef,
254
254
  renderLabel: renderLabel,
255
255
  onChange: handleInputChange,
@@ -262,51 +262,49 @@ 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
- children: renderCalendarIcon ? callRenderProp(renderCalendarIcon) : _IconCalendarMonthLin || (_IconCalendarMonthLin = _jsx(IconCalendarMonthLine, {}))
273
- }),
271
+ interaction: interaction
272
+ }, renderCalendarIcon ? callRenderProp(renderCalendarIcon) : _IconCalendarMonthLin || (_IconCalendarMonthLin = jsx(IconCalendarMonthLine, null))),
274
273
  isShowingContent: showPopover,
275
274
  onShowContent: () => setShowPopover(true),
276
275
  onHideContent: () => setShowPopover(false),
277
276
  on: "click",
278
277
  shouldContainFocus: true,
279
278
  shouldReturnFocus: true,
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
- })
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
307
305
  })
308
- })
309
- });
306
+ }))
307
+ }));
310
308
  };
311
309
  DateInput2.propTypes = propTypes;
312
310
  export default DateInput2;