@instructure/ui-date-input 10.16.1 → 10.16.3

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/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [10.16.3](https://github.com/instructure/instructure-ui/compare/v10.16.1...v10.16.3) (2025-04-30)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **ui-date-input,ui-avatar:** add ref support to functional components ([6a6ba49](https://github.com/instructure/instructure-ui/commit/6a6ba493634a22a515d59b5acbecbc2d93084e0f))
12
+
13
+
14
+
15
+
16
+
17
+ ## [10.16.2](https://github.com/instructure/instructure-ui/compare/v10.16.1...v10.16.2) (2025-04-22)
18
+
19
+ **Note:** Version bump only for package @instructure/ui-date-input
20
+
21
+
22
+
23
+
24
+
6
25
  ## [10.16.1](https://github.com/instructure/instructure-ui/compare/v10.16.0...v10.16.1) (2025-04-22)
7
26
 
8
27
  **Note:** Version bump only for package @instructure/ui-date-input
@@ -108,9 +108,31 @@ describe('<DateInput2 />', () => {
108
108
  expect(calendarIcon).toBeInTheDocument();
109
109
  expect(calendarLabel).toBeInTheDocument();
110
110
  });
111
+ it('refs should return the underlying component', async () => {
112
+ const inputRef = vi.fn();
113
+ const ref = {
114
+ current: null
115
+ };
116
+ const _render4 = render(_jsx(DateInput2, {
117
+ id: "dateInput2",
118
+ inputRef: inputRef,
119
+ ref: ref,
120
+ renderLabel: LABEL_TEXT,
121
+ screenReaderLabels: {
122
+ calendarIcon: 'Calendar',
123
+ nextMonthButton: 'Next month',
124
+ prevMonthButton: 'Previous month'
125
+ }
126
+ })),
127
+ container = _render4.container;
128
+ const dateInput = container.querySelector('input');
129
+ expect(inputRef).toHaveBeenCalledWith(dateInput);
130
+ expect(ref.current.props.id).toBe('dateInput2');
131
+ expect(dateInput).toBeInTheDocument();
132
+ });
111
133
  it('should render a custom calendar icon with screen reader label', async () => {
112
134
  const iconLabel = 'Calendar icon Label';
113
- const _render4 = render(_jsx(DateInput2, {
135
+ const _render5 = render(_jsx(DateInput2, {
114
136
  renderLabel: "Choose a date",
115
137
  screenReaderLabels: {
116
138
  calendarIcon: iconLabel,
@@ -120,7 +142,7 @@ describe('<DateInput2 />', () => {
120
142
  value: "",
121
143
  renderCalendarIcon: _IconHeartLine || (_IconHeartLine = _jsx(IconHeartLine, {}))
122
144
  })),
123
- container = _render4.container;
145
+ container = _render5.container;
124
146
  const calendarIcon = container.querySelector('svg[name="IconHeart"]');
125
147
  const calendarLabel = screen.getByText(iconLabel);
126
148
  expect(calendarIcon).toBeInTheDocument();
@@ -193,7 +215,7 @@ describe('<DateInput2 />', () => {
193
215
  });
194
216
  it('should set interaction type to disabled', async () => {
195
217
  const interactionDisabled = 'disabled';
196
- const _render5 = render(_jsx(DateInput2, {
218
+ const _render6 = render(_jsx(DateInput2, {
197
219
  renderLabel: "Choose a date",
198
220
  screenReaderLabels: {
199
221
  calendarIcon: 'Calendar',
@@ -203,13 +225,13 @@ describe('<DateInput2 />', () => {
203
225
  value: "",
204
226
  interaction: interactionDisabled
205
227
  })),
206
- container = _render5.container;
228
+ container = _render6.container;
207
229
  const dateInput = container.querySelector('input');
208
230
  expect(dateInput).toHaveAttribute(interactionDisabled);
209
231
  });
210
232
  it('should set interaction type to readonly', async () => {
211
233
  const interactionReadOnly = 'readonly';
212
- const _render6 = render(_jsx(DateInput2, {
234
+ const _render7 = render(_jsx(DateInput2, {
213
235
  renderLabel: "Choose a date",
214
236
  screenReaderLabels: {
215
237
  calendarIcon: 'Calendar',
@@ -219,7 +241,7 @@ describe('<DateInput2 />', () => {
219
241
  value: "",
220
242
  interaction: interactionReadOnly
221
243
  })),
222
- container = _render6.container;
244
+ container = _render7.container;
223
245
  const dateInput = container.querySelector('input');
224
246
  const calendarButton = screen.getByRole('button');
225
247
  expect(dateInput).toHaveAttribute(interactionReadOnly);
@@ -231,7 +253,7 @@ describe('<DateInput2 />', () => {
231
253
  });
232
254
  });
233
255
  it('should set required', async () => {
234
- const _render7 = render(_jsx(DateInput2, {
256
+ const _render8 = render(_jsx(DateInput2, {
235
257
  renderLabel: "Choose a date",
236
258
  screenReaderLabels: {
237
259
  calendarIcon: 'Calendar',
@@ -241,7 +263,7 @@ describe('<DateInput2 />', () => {
241
263
  value: "",
242
264
  isRequired: true
243
265
  })),
244
- container = _render7.container;
266
+ container = _render8.container;
245
267
  const dateInput = container.querySelector('input');
246
268
  expect(dateInput).toHaveAttribute('required');
247
269
  });
@@ -24,7 +24,7 @@ var _IconCalendarMonthLin, _IconArrowOpenEndSoli, _IconArrowOpenStartSo;
24
24
  * SOFTWARE.
25
25
  */
26
26
 
27
- import { useState, useEffect, useContext } from 'react';
27
+ import { useState, useEffect, useContext, forwardRef } from 'react';
28
28
  import { Calendar } from '@instructure/ui-calendar';
29
29
  import { IconButton } from '@instructure/ui-buttons';
30
30
  import { IconCalendarMonthLine, IconArrowOpenEndSolid, IconArrowOpenStartSolid } from '@instructure/ui-icons';
@@ -110,7 +110,8 @@ function parseLocaleDate(dateString = '', locale, timeZone) {
110
110
  category: components
111
111
  ---
112
112
  **/
113
- const DateInput2 = ({
113
+ // eslint-disable-next-line react/display-name
114
+ const DateInput2 = /*#__PURE__*/forwardRef(({
114
115
  renderLabel,
115
116
  screenReaderLabels,
116
117
  isRequired = false,
@@ -133,7 +134,7 @@ const DateInput2 = ({
133
134
  margin,
134
135
  inputRef,
135
136
  ...rest
136
- }) => {
137
+ }, ref) => {
137
138
  const localeContext = useContext(ApplyLocaleContext);
138
139
  const getLocale = () => {
139
140
  if (locale) {
@@ -250,6 +251,7 @@ const DateInput2 = ({
250
251
  const selectedDate = parseDate(value)[1];
251
252
  return _jsx(TextInput, {
252
253
  ...passthroughProps(rest),
254
+ ref: ref,
253
255
  inputRef: inputRef,
254
256
  renderLabel: renderLabel,
255
257
  onChange: handleInputChange,
@@ -307,7 +309,7 @@ const DateInput2 = ({
307
309
  })
308
310
  })
309
311
  });
310
- };
312
+ });
311
313
  DateInput2.propTypes = propTypes;
312
314
  export default DateInput2;
313
315
  export { DateInput2 };
@@ -111,9 +111,31 @@ describe('<DateInput2 />', () => {
111
111
  expect(calendarIcon).toBeInTheDocument();
112
112
  expect(calendarLabel).toBeInTheDocument();
113
113
  });
114
+ it('refs should return the underlying component', async () => {
115
+ const inputRef = _vitest.vi.fn();
116
+ const ref = {
117
+ current: null
118
+ };
119
+ const _render4 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.DateInput2, {
120
+ id: "dateInput2",
121
+ inputRef: inputRef,
122
+ ref: ref,
123
+ renderLabel: LABEL_TEXT,
124
+ screenReaderLabels: {
125
+ calendarIcon: 'Calendar',
126
+ nextMonthButton: 'Next month',
127
+ prevMonthButton: 'Previous month'
128
+ }
129
+ })),
130
+ container = _render4.container;
131
+ const dateInput = container.querySelector('input');
132
+ expect(inputRef).toHaveBeenCalledWith(dateInput);
133
+ expect(ref.current.props.id).toBe('dateInput2');
134
+ expect(dateInput).toBeInTheDocument();
135
+ });
114
136
  it('should render a custom calendar icon with screen reader label', async () => {
115
137
  const iconLabel = 'Calendar icon Label';
116
- const _render4 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.DateInput2, {
138
+ const _render5 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.DateInput2, {
117
139
  renderLabel: "Choose a date",
118
140
  screenReaderLabels: {
119
141
  calendarIcon: iconLabel,
@@ -123,7 +145,7 @@ describe('<DateInput2 />', () => {
123
145
  value: "",
124
146
  renderCalendarIcon: _IconHeartLine || (_IconHeartLine = (0, _jsxRuntime.jsx)(_IconHeartLine2.IconHeartLine, {}))
125
147
  })),
126
- container = _render4.container;
148
+ container = _render5.container;
127
149
  const calendarIcon = container.querySelector('svg[name="IconHeart"]');
128
150
  const calendarLabel = _react2.screen.getByText(iconLabel);
129
151
  expect(calendarIcon).toBeInTheDocument();
@@ -196,7 +218,7 @@ describe('<DateInput2 />', () => {
196
218
  });
197
219
  it('should set interaction type to disabled', async () => {
198
220
  const interactionDisabled = 'disabled';
199
- const _render5 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.DateInput2, {
221
+ const _render6 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.DateInput2, {
200
222
  renderLabel: "Choose a date",
201
223
  screenReaderLabels: {
202
224
  calendarIcon: 'Calendar',
@@ -206,13 +228,13 @@ describe('<DateInput2 />', () => {
206
228
  value: "",
207
229
  interaction: interactionDisabled
208
230
  })),
209
- container = _render5.container;
231
+ container = _render6.container;
210
232
  const dateInput = container.querySelector('input');
211
233
  expect(dateInput).toHaveAttribute(interactionDisabled);
212
234
  });
213
235
  it('should set interaction type to readonly', async () => {
214
236
  const interactionReadOnly = 'readonly';
215
- const _render6 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.DateInput2, {
237
+ const _render7 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.DateInput2, {
216
238
  renderLabel: "Choose a date",
217
239
  screenReaderLabels: {
218
240
  calendarIcon: 'Calendar',
@@ -222,7 +244,7 @@ describe('<DateInput2 />', () => {
222
244
  value: "",
223
245
  interaction: interactionReadOnly
224
246
  })),
225
- container = _render6.container;
247
+ container = _render7.container;
226
248
  const dateInput = container.querySelector('input');
227
249
  const calendarButton = _react2.screen.getByRole('button');
228
250
  expect(dateInput).toHaveAttribute(interactionReadOnly);
@@ -234,7 +256,7 @@ describe('<DateInput2 />', () => {
234
256
  });
235
257
  });
236
258
  it('should set required', async () => {
237
- const _render7 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.DateInput2, {
259
+ const _render8 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.DateInput2, {
238
260
  renderLabel: "Choose a date",
239
261
  screenReaderLabels: {
240
262
  calendarIcon: 'Calendar',
@@ -244,7 +266,7 @@ describe('<DateInput2 />', () => {
244
266
  value: "",
245
267
  isRequired: true
246
268
  })),
247
- container = _render7.container;
269
+ container = _render8.container;
248
270
  const dateInput = container.querySelector('input');
249
271
  expect(dateInput).toHaveAttribute('required');
250
272
  });
@@ -120,7 +120,8 @@ function parseLocaleDate(dateString = '', locale, timeZone) {
120
120
  category: components
121
121
  ---
122
122
  **/
123
- const DateInput2 = ({
123
+ // eslint-disable-next-line react/display-name
124
+ const DateInput2 = exports.DateInput2 = /*#__PURE__*/(0, _react.forwardRef)(({
124
125
  renderLabel,
125
126
  screenReaderLabels,
126
127
  isRequired = false,
@@ -143,7 +144,7 @@ const DateInput2 = ({
143
144
  margin,
144
145
  inputRef,
145
146
  ...rest
146
- }) => {
147
+ }, ref) => {
147
148
  const localeContext = (0, _react.useContext)(_ApplyLocaleContext.ApplyLocaleContext);
148
149
  const getLocale = () => {
149
150
  if (locale) {
@@ -260,6 +261,7 @@ const DateInput2 = ({
260
261
  const selectedDate = parseDate(value)[1];
261
262
  return (0, _jsxRuntime.jsx)(_TextInput.TextInput, {
262
263
  ...(0, _passthroughProps.passthroughProps)(rest),
264
+ ref: ref,
263
265
  inputRef: inputRef,
264
266
  renderLabel: renderLabel,
265
267
  onChange: handleInputChange,
@@ -317,7 +319,6 @@ const DateInput2 = ({
317
319
  })
318
320
  })
319
321
  });
320
- };
321
- exports.DateInput2 = DateInput2;
322
+ });
322
323
  DateInput2.propTypes = _props.propTypes;
323
324
  var _default = exports.default = DateInput2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-date-input",
3
- "version": "10.16.1",
3
+ "version": "10.16.3",
4
4
  "description": "A UI component library made by Instructure Inc.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -23,11 +23,11 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-axe-check": "10.16.1",
27
- "@instructure/ui-babel-preset": "10.16.1",
28
- "@instructure/ui-buttons": "10.16.1",
29
- "@instructure/ui-scripts": "10.16.1",
30
- "@instructure/ui-test-utils": "10.16.1",
26
+ "@instructure/ui-axe-check": "10.16.3",
27
+ "@instructure/ui-babel-preset": "10.16.3",
28
+ "@instructure/ui-buttons": "10.16.3",
29
+ "@instructure/ui-scripts": "10.16.3",
30
+ "@instructure/ui-test-utils": "10.16.3",
31
31
  "@testing-library/jest-dom": "^6.6.3",
32
32
  "@testing-library/react": "^16.0.1",
33
33
  "@testing-library/user-event": "^14.5.2",
@@ -35,20 +35,20 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@babel/runtime": "^7.26.0",
38
- "@instructure/emotion": "10.16.1",
39
- "@instructure/shared-types": "10.16.1",
40
- "@instructure/ui-calendar": "10.16.1",
41
- "@instructure/ui-form-field": "10.16.1",
42
- "@instructure/ui-i18n": "10.16.1",
43
- "@instructure/ui-icons": "10.16.1",
44
- "@instructure/ui-popover": "10.16.1",
45
- "@instructure/ui-position": "10.16.1",
46
- "@instructure/ui-prop-types": "10.16.1",
47
- "@instructure/ui-react-utils": "10.16.1",
48
- "@instructure/ui-selectable": "10.16.1",
49
- "@instructure/ui-testable": "10.16.1",
50
- "@instructure/ui-text-input": "10.16.1",
51
- "@instructure/ui-utils": "10.16.1",
38
+ "@instructure/emotion": "10.16.3",
39
+ "@instructure/shared-types": "10.16.3",
40
+ "@instructure/ui-calendar": "10.16.3",
41
+ "@instructure/ui-form-field": "10.16.3",
42
+ "@instructure/ui-i18n": "10.16.3",
43
+ "@instructure/ui-icons": "10.16.3",
44
+ "@instructure/ui-popover": "10.16.3",
45
+ "@instructure/ui-position": "10.16.3",
46
+ "@instructure/ui-prop-types": "10.16.3",
47
+ "@instructure/ui-react-utils": "10.16.3",
48
+ "@instructure/ui-selectable": "10.16.3",
49
+ "@instructure/ui-testable": "10.16.3",
50
+ "@instructure/ui-text-input": "10.16.3",
51
+ "@instructure/ui-utils": "10.16.3",
52
52
  "moment-timezone": "^0.5.45",
53
53
  "prop-types": "^15.8.1"
54
54
  },
@@ -29,6 +29,7 @@ import '@testing-library/jest-dom'
29
29
  import { IconHeartLine } from '@instructure/ui-icons'
30
30
 
31
31
  import { DateInput2 } from '../index'
32
+ import { TextInput } from '@instructure/ui-text-input'
32
33
 
33
34
  const LABEL_TEXT = 'Choose a date'
34
35
 
@@ -124,6 +125,28 @@ describe('<DateInput2 />', () => {
124
125
  expect(calendarLabel).toBeInTheDocument()
125
126
  })
126
127
 
128
+ it('refs should return the underlying component', async () => {
129
+ const inputRef = vi.fn()
130
+ const ref: React.Ref<TextInput> = { current: null }
131
+ const { container } = render(
132
+ <DateInput2
133
+ id="dateInput2"
134
+ inputRef={inputRef}
135
+ ref={ref}
136
+ renderLabel={LABEL_TEXT}
137
+ screenReaderLabels={{
138
+ calendarIcon: 'Calendar',
139
+ nextMonthButton: 'Next month',
140
+ prevMonthButton: 'Previous month'
141
+ }}
142
+ />
143
+ )
144
+ const dateInput = container.querySelector('input')
145
+ expect(inputRef).toHaveBeenCalledWith(dateInput)
146
+ expect(ref.current!.props.id).toBe('dateInput2')
147
+ expect(dateInput).toBeInTheDocument()
148
+ })
149
+
127
150
  it('should render a custom calendar icon with screen reader label', async () => {
128
151
  const iconLabel = 'Calendar icon Label'
129
152
  const { container } = render(