@instructure/ui-date-input 10.12.1-snapshot-0 → 10.12.1-snapshot-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.
- package/CHANGELOG.md +6 -1
- package/es/DateInput2/index.js +4 -2
- package/es/DateInput2/props.js +3 -1
- package/lib/DateInput2/index.js +4 -2
- package/lib/DateInput2/props.js +3 -1
- package/package.json +20 -20
- package/src/DateInput/README.md +1 -1
- package/src/DateInput2/README.md +35 -0
- package/src/DateInput2/index.tsx +5 -2
- package/src/DateInput2/props.ts +14 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/DateInput2/index.d.ts +3 -3
- package/types/DateInput2/index.d.ts.map +1 -1
- package/types/DateInput2/props.d.ts +5 -0
- package/types/DateInput2/props.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
@@ -3,7 +3,7 @@
|
|
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.12.1-snapshot-
|
6
|
+
## [10.12.1-snapshot-1](https://github.com/instructure/instructure-ui/compare/v10.12.0...v10.12.1-snapshot-1) (2025-03-03)
|
7
7
|
|
8
8
|
|
9
9
|
### Bug Fixes
|
@@ -11,6 +11,11 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
11
11
|
* **many:** fix form label not read by NVDA in hover mode and other layout issues ([ef77281](https://github.com/instructure/instructure-ui/commit/ef77281890511e8eea794196445d3ef2454537ba))
|
12
12
|
|
13
13
|
|
14
|
+
### Features
|
15
|
+
|
16
|
+
* **ui-date-input:** add feature to disable dates and access the input's ref ([411219e](https://github.com/instructure/instructure-ui/commit/411219e4347c75ed2ffeda320b33c591ffc05329))
|
17
|
+
|
18
|
+
|
14
19
|
|
15
20
|
|
16
21
|
|
package/es/DateInput2/index.js
CHANGED
@@ -110,8 +110,6 @@ function parseLocaleDate(dateString = '', locale, timeZone) {
|
|
110
110
|
---
|
111
111
|
category: components
|
112
112
|
---
|
113
|
-
|
114
|
-
@module experimental
|
115
113
|
**/
|
116
114
|
const DateInput2 = ({
|
117
115
|
renderLabel,
|
@@ -131,8 +129,10 @@ const DateInput2 = ({
|
|
131
129
|
placeholder,
|
132
130
|
dateFormat,
|
133
131
|
onRequestValidateDate,
|
132
|
+
disabledDates,
|
134
133
|
renderCalendarIcon,
|
135
134
|
margin,
|
135
|
+
inputRef,
|
136
136
|
...rest
|
137
137
|
}) => {
|
138
138
|
const localeContext = useContext(ApplyLocaleContext);
|
@@ -250,6 +250,7 @@ const DateInput2 = ({
|
|
250
250
|
};
|
251
251
|
const selectedDate = parseDate(value)[1];
|
252
252
|
return jsx(TextInput, Object.assign({}, passthroughProps(rest), {
|
253
|
+
inputRef: inputRef,
|
253
254
|
renderLabel: renderLabel,
|
254
255
|
onChange: handleInputChange,
|
255
256
|
onBlur: handleBlur,
|
@@ -280,6 +281,7 @@ const DateInput2 = ({
|
|
280
281
|
withYearPicker: withYearPicker,
|
281
282
|
onDateSelected: handleDateSelected,
|
282
283
|
selectedDate: selectedDate,
|
284
|
+
disabledDates: disabledDates,
|
283
285
|
visibleMonth: selectedDate,
|
284
286
|
locale: getLocale(),
|
285
287
|
timezone: getTimezone(),
|
package/es/DateInput2/props.js
CHANGED
@@ -44,6 +44,8 @@ const propTypes = {
|
|
44
44
|
dateFormat: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
45
45
|
onRequestValidateDate: PropTypes.func,
|
46
46
|
renderCalendarIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
47
|
-
margin: PropTypes.string
|
47
|
+
margin: PropTypes.string,
|
48
|
+
disabledDates: PropTypes.oneOfType([PropTypes.array, PropTypes.func]),
|
49
|
+
inputRef: PropTypes.func
|
48
50
|
};
|
49
51
|
export { propTypes };
|
package/lib/DateInput2/index.js
CHANGED
@@ -120,8 +120,6 @@ function parseLocaleDate(dateString = '', locale, timeZone) {
|
|
120
120
|
---
|
121
121
|
category: components
|
122
122
|
---
|
123
|
-
|
124
|
-
@module experimental
|
125
123
|
**/
|
126
124
|
const DateInput2 = ({
|
127
125
|
renderLabel,
|
@@ -141,8 +139,10 @@ const DateInput2 = ({
|
|
141
139
|
placeholder,
|
142
140
|
dateFormat,
|
143
141
|
onRequestValidateDate,
|
142
|
+
disabledDates,
|
144
143
|
renderCalendarIcon,
|
145
144
|
margin,
|
145
|
+
inputRef,
|
146
146
|
...rest
|
147
147
|
}) => {
|
148
148
|
const localeContext = (0, _react.useContext)(_ApplyLocaleContext.ApplyLocaleContext);
|
@@ -260,6 +260,7 @@ const DateInput2 = ({
|
|
260
260
|
};
|
261
261
|
const selectedDate = parseDate(value)[1];
|
262
262
|
return (0, _emotion.jsx)(_TextInput.TextInput, Object.assign({}, (0, _passthroughProps.passthroughProps)(rest), {
|
263
|
+
inputRef: inputRef,
|
263
264
|
renderLabel: renderLabel,
|
264
265
|
onChange: handleInputChange,
|
265
266
|
onBlur: handleBlur,
|
@@ -290,6 +291,7 @@ const DateInput2 = ({
|
|
290
291
|
withYearPicker: withYearPicker,
|
291
292
|
onDateSelected: handleDateSelected,
|
292
293
|
selectedDate: selectedDate,
|
294
|
+
disabledDates: disabledDates,
|
293
295
|
visibleMonth: selectedDate,
|
294
296
|
locale: getLocale(),
|
295
297
|
timezone: getTimezone(),
|
package/lib/DateInput2/props.js
CHANGED
@@ -51,5 +51,7 @@ const propTypes = exports.propTypes = {
|
|
51
51
|
dateFormat: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object]),
|
52
52
|
onRequestValidateDate: _propTypes.default.func,
|
53
53
|
renderCalendarIcon: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
54
|
-
margin: _propTypes.default.string
|
54
|
+
margin: _propTypes.default.string,
|
55
|
+
disabledDates: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.func]),
|
56
|
+
inputRef: _propTypes.default.func
|
55
57
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@instructure/ui-date-input",
|
3
|
-
"version": "10.12.1-snapshot-
|
3
|
+
"version": "10.12.1-snapshot-1",
|
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.12.1-snapshot-
|
27
|
-
"@instructure/ui-babel-preset": "10.12.1-snapshot-
|
28
|
-
"@instructure/ui-buttons": "10.12.1-snapshot-
|
29
|
-
"@instructure/ui-scripts": "10.12.1-snapshot-
|
30
|
-
"@instructure/ui-test-utils": "10.12.1-snapshot-
|
26
|
+
"@instructure/ui-axe-check": "10.12.1-snapshot-1",
|
27
|
+
"@instructure/ui-babel-preset": "10.12.1-snapshot-1",
|
28
|
+
"@instructure/ui-buttons": "10.12.1-snapshot-1",
|
29
|
+
"@instructure/ui-scripts": "10.12.1-snapshot-1",
|
30
|
+
"@instructure/ui-test-utils": "10.12.1-snapshot-1",
|
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.12.1-snapshot-
|
39
|
-
"@instructure/shared-types": "10.12.1-snapshot-
|
40
|
-
"@instructure/ui-calendar": "10.12.1-snapshot-
|
41
|
-
"@instructure/ui-form-field": "10.12.1-snapshot-
|
42
|
-
"@instructure/ui-i18n": "10.12.1-snapshot-
|
43
|
-
"@instructure/ui-icons": "10.12.1-snapshot-
|
44
|
-
"@instructure/ui-popover": "10.12.1-snapshot-
|
45
|
-
"@instructure/ui-position": "10.12.1-snapshot-
|
46
|
-
"@instructure/ui-prop-types": "10.12.1-snapshot-
|
47
|
-
"@instructure/ui-react-utils": "10.12.1-snapshot-
|
48
|
-
"@instructure/ui-selectable": "10.12.1-snapshot-
|
49
|
-
"@instructure/ui-testable": "10.12.1-snapshot-
|
50
|
-
"@instructure/ui-text-input": "10.12.1-snapshot-
|
51
|
-
"@instructure/ui-utils": "10.12.1-snapshot-
|
38
|
+
"@instructure/emotion": "10.12.1-snapshot-1",
|
39
|
+
"@instructure/shared-types": "10.12.1-snapshot-1",
|
40
|
+
"@instructure/ui-calendar": "10.12.1-snapshot-1",
|
41
|
+
"@instructure/ui-form-field": "10.12.1-snapshot-1",
|
42
|
+
"@instructure/ui-i18n": "10.12.1-snapshot-1",
|
43
|
+
"@instructure/ui-icons": "10.12.1-snapshot-1",
|
44
|
+
"@instructure/ui-popover": "10.12.1-snapshot-1",
|
45
|
+
"@instructure/ui-position": "10.12.1-snapshot-1",
|
46
|
+
"@instructure/ui-prop-types": "10.12.1-snapshot-1",
|
47
|
+
"@instructure/ui-react-utils": "10.12.1-snapshot-1",
|
48
|
+
"@instructure/ui-selectable": "10.12.1-snapshot-1",
|
49
|
+
"@instructure/ui-testable": "10.12.1-snapshot-1",
|
50
|
+
"@instructure/ui-text-input": "10.12.1-snapshot-1",
|
51
|
+
"@instructure/ui-utils": "10.12.1-snapshot-1",
|
52
52
|
"moment-timezone": "^0.5.45",
|
53
53
|
"prop-types": "^15.8.1"
|
54
54
|
},
|
package/src/DateInput/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
describes: DateInput
|
3
3
|
---
|
4
4
|
|
5
|
-
> _Note:_
|
5
|
+
> _Note:_ we recommend to update to the new [`DateInput2`](/#DateInput2) which is easier to configure for developers, has a better UX, better accessibility features and a year picker. `DateInput` will be deprecated in the future.
|
6
6
|
|
7
7
|
The `DateInput` component provides a visual interface for inputting date data.
|
8
8
|
|
package/src/DateInput2/README.md
CHANGED
@@ -305,3 +305,38 @@ render(<Example />)
|
|
305
305
|
### Date format hint
|
306
306
|
|
307
307
|
If the `placeholder` property is undefined it will display a hint for the date format (like `DD/MM/YYYY`). Usually it is recommended to leave it as it is for a better user experience.
|
308
|
+
|
309
|
+
### Disabling dates
|
310
|
+
|
311
|
+
You can use the `disabledDates` prop to disable specific dates. It accepts either an array of ISO8601 date strings or a function. Keep in mind that this will only disable the dates in the calendar and does not prevent the user the enter them into the input field. To validate those values please use the `onRequestValidateDate` prop.
|
312
|
+
|
313
|
+
```js
|
314
|
+
---
|
315
|
+
type: example
|
316
|
+
---
|
317
|
+
const Example = () => {
|
318
|
+
const [inputValue, setInputValue] = useState('2/5/2025')
|
319
|
+
const [dateString, setDateString] = useState('')
|
320
|
+
return (
|
321
|
+
<DateInput2
|
322
|
+
renderLabel="Choose a date"
|
323
|
+
disabledDates={['2025-02-11', '2025-02-12', '2025-02-13']}
|
324
|
+
screenReaderLabels={{
|
325
|
+
calendarIcon: 'Calendar',
|
326
|
+
nextMonthButton: 'Next month',
|
327
|
+
prevMonthButton: 'Previous month'
|
328
|
+
}}
|
329
|
+
value={inputValue}
|
330
|
+
locale="en-us"
|
331
|
+
width="20rem"
|
332
|
+
onChange={(e, inputValue, dateString) => {
|
333
|
+
setInputValue(inputValue)
|
334
|
+
setDateString(dateString)
|
335
|
+
}}
|
336
|
+
invalidDateErrorMessage="Invalid date"
|
337
|
+
/>
|
338
|
+
)
|
339
|
+
}
|
340
|
+
|
341
|
+
render(<Example />)
|
342
|
+
```
|
package/src/DateInput2/index.tsx
CHANGED
@@ -131,8 +131,6 @@ function parseLocaleDate(
|
|
131
131
|
---
|
132
132
|
category: components
|
133
133
|
---
|
134
|
-
|
135
|
-
@module experimental
|
136
134
|
**/
|
137
135
|
const DateInput2 = ({
|
138
136
|
renderLabel,
|
@@ -152,8 +150,10 @@ const DateInput2 = ({
|
|
152
150
|
placeholder,
|
153
151
|
dateFormat,
|
154
152
|
onRequestValidateDate,
|
153
|
+
disabledDates,
|
155
154
|
renderCalendarIcon,
|
156
155
|
margin,
|
156
|
+
inputRef,
|
157
157
|
...rest
|
158
158
|
}: DateInput2Props) => {
|
159
159
|
const localeContext = useContext(ApplyLocaleContext)
|
@@ -275,9 +275,11 @@ const DateInput2 = ({
|
|
275
275
|
}
|
276
276
|
|
277
277
|
const selectedDate = parseDate(value)[1]
|
278
|
+
|
278
279
|
return (
|
279
280
|
<TextInput
|
280
281
|
{...passthroughProps(rest)}
|
282
|
+
inputRef={inputRef}
|
281
283
|
renderLabel={renderLabel}
|
282
284
|
onChange={handleInputChange}
|
283
285
|
onBlur={handleBlur}
|
@@ -318,6 +320,7 @@ const DateInput2 = ({
|
|
318
320
|
withYearPicker={withYearPicker}
|
319
321
|
onDateSelected={handleDateSelected}
|
320
322
|
selectedDate={selectedDate}
|
323
|
+
disabledDates={disabledDates}
|
321
324
|
visibleMonth={selectedDate}
|
322
325
|
locale={getLocale()}
|
323
326
|
timezone={getTimezone()}
|
package/src/DateInput2/props.ts
CHANGED
@@ -175,6 +175,17 @@ type DateInput2OwnProps = {
|
|
175
175
|
* Margin around the component. Accepts a `Spacing` token. See token values and example usage in [this guide](https://instructure.design/#layout-spacing).
|
176
176
|
*/
|
177
177
|
margin?: Spacing
|
178
|
+
/*
|
179
|
+
* Specify which date(s) will be shown as disabled in the calendar.
|
180
|
+
* You can either supply an array of ISO8601 timeDate strings or
|
181
|
+
* a function that will be called for each date shown in the calendar.
|
182
|
+
*/
|
183
|
+
disabledDates?: string[] | ((isoDateToCheck: string) => boolean)
|
184
|
+
|
185
|
+
/**
|
186
|
+
* A function that provides a reference to the inner input element
|
187
|
+
*/
|
188
|
+
inputRef?: (inputElement: HTMLInputElement | null) => void
|
178
189
|
}
|
179
190
|
|
180
191
|
type PropKeys = keyof DateInput2OwnProps
|
@@ -207,7 +218,9 @@ const propTypes: PropValidators<PropKeys> = {
|
|
207
218
|
dateFormat: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
208
219
|
onRequestValidateDate: PropTypes.func,
|
209
220
|
renderCalendarIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
210
|
-
margin: PropTypes.string
|
221
|
+
margin: PropTypes.string,
|
222
|
+
disabledDates: PropTypes.oneOfType([PropTypes.array, PropTypes.func]),
|
223
|
+
inputRef: PropTypes.func
|
211
224
|
}
|
212
225
|
|
213
226
|
export type { DateInput2Props }
|