@instructure/ui-date-time-input 11.0.1-snapshot-0 → 11.0.1-snapshot-2
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 +1 -1
- package/package.json +14 -14
- package/src/DateTimeInput/README.md +25 -202
- package/tsconfig.build.tsbuildinfo +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
|
-
## [11.0.1-snapshot-
|
|
6
|
+
## [11.0.1-snapshot-2](https://github.com/instructure/instructure-ui/compare/v11.0.0...v11.0.1-snapshot-2) (2025-10-10)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-date-time-input
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-date-time-input",
|
|
3
|
-
"version": "11.0.1-snapshot-
|
|
3
|
+
"version": "11.0.1-snapshot-2",
|
|
4
4
|
"description": "A UI component that allows to select date and time.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-babel-preset": "11.0.1-snapshot-
|
|
26
|
+
"@instructure/ui-babel-preset": "11.0.1-snapshot-2",
|
|
27
27
|
"@testing-library/jest-dom": "^6.6.3",
|
|
28
28
|
"@testing-library/react": "15.0.7",
|
|
29
29
|
"@testing-library/user-event": "^14.6.1",
|
|
@@ -31,18 +31,18 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.27.6",
|
|
34
|
-
"@instructure/console": "11.0.1-snapshot-
|
|
35
|
-
"@instructure/shared-types": "11.0.1-snapshot-
|
|
36
|
-
"@instructure/ui-a11y-content": "11.0.1-snapshot-
|
|
37
|
-
"@instructure/ui-buttons": "11.0.1-snapshot-
|
|
38
|
-
"@instructure/ui-calendar": "11.0.1-snapshot-
|
|
39
|
-
"@instructure/ui-date-input": "11.0.1-snapshot-
|
|
40
|
-
"@instructure/ui-form-field": "11.0.1-snapshot-
|
|
41
|
-
"@instructure/ui-i18n": "11.0.1-snapshot-
|
|
42
|
-
"@instructure/ui-icons": "11.0.1-snapshot-
|
|
43
|
-
"@instructure/ui-react-utils": "11.0.1-snapshot-
|
|
44
|
-
"@instructure/ui-time-select": "11.0.1-snapshot-
|
|
45
|
-
"@instructure/ui-utils": "11.0.1-snapshot-
|
|
34
|
+
"@instructure/console": "11.0.1-snapshot-2",
|
|
35
|
+
"@instructure/shared-types": "11.0.1-snapshot-2",
|
|
36
|
+
"@instructure/ui-a11y-content": "11.0.1-snapshot-2",
|
|
37
|
+
"@instructure/ui-buttons": "11.0.1-snapshot-2",
|
|
38
|
+
"@instructure/ui-calendar": "11.0.1-snapshot-2",
|
|
39
|
+
"@instructure/ui-date-input": "11.0.1-snapshot-2",
|
|
40
|
+
"@instructure/ui-form-field": "11.0.1-snapshot-2",
|
|
41
|
+
"@instructure/ui-i18n": "11.0.1-snapshot-2",
|
|
42
|
+
"@instructure/ui-icons": "11.0.1-snapshot-2",
|
|
43
|
+
"@instructure/ui-react-utils": "11.0.1-snapshot-2",
|
|
44
|
+
"@instructure/ui-time-select": "11.0.1-snapshot-2",
|
|
45
|
+
"@instructure/ui-utils": "11.0.1-snapshot-2"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": ">=18 <=19"
|
|
@@ -19,30 +19,10 @@ The component is localized via its `locale` and `timezone` parameters. Both are
|
|
|
19
19
|
|
|
20
20
|
#### A DateTimeInput with `columns` layout and a default value:
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<div style={{ height: '15rem' }}>
|
|
27
|
-
<DateTimeInput
|
|
28
|
-
description="Pick a date and time"
|
|
29
|
-
datePlaceholder="Choose a date"
|
|
30
|
-
dateRenderLabel="Date"
|
|
31
|
-
timeRenderLabel="Time"
|
|
32
|
-
invalidDateTimeMessage="Invalid date!"
|
|
33
|
-
prevMonthLabel="Previous month"
|
|
34
|
-
nextMonthLabel="Next month"
|
|
35
|
-
defaultValue="2018-01-18T13:30"
|
|
36
|
-
layout="columns"
|
|
37
|
-
/>
|
|
38
|
-
</div>
|
|
39
|
-
)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
render(<Example />)
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
- ```js
|
|
22
|
+
```js
|
|
23
|
+
---
|
|
24
|
+
type: example
|
|
25
|
+
---
|
|
46
26
|
const Example = () => {
|
|
47
27
|
return (
|
|
48
28
|
<div style={{ height: '15rem' }}>
|
|
@@ -62,75 +42,16 @@ The component is localized via its `locale` and `timezone` parameters. Both are
|
|
|
62
42
|
}
|
|
63
43
|
|
|
64
44
|
render(<Example />)
|
|
65
|
-
|
|
45
|
+
```
|
|
66
46
|
|
|
67
47
|
#### A required DateInput with `stacked` layout that warns if the value in the past:
|
|
68
48
|
|
|
69
49
|
This sample code also allows the user to enter an arbitrary time value by setting `allowNonStepInput` to `true`.
|
|
70
50
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.state = {
|
|
76
|
-
value: undefined,
|
|
77
|
-
messages: []
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
onChange = (e, isoDate) => {
|
|
82
|
-
let messages = []
|
|
83
|
-
if (!isoDate) {
|
|
84
|
-
// this happens if an invalid date is entered
|
|
85
|
-
this.setState({ messages: messages, value: undefined })
|
|
86
|
-
return
|
|
87
|
-
}
|
|
88
|
-
const now = new Date()
|
|
89
|
-
const newValue = new Date(isoDate)
|
|
90
|
-
if (newValue.valueOf() <= now.valueOf()) {
|
|
91
|
-
messages = [{ text: 'That date-time is in the past', type: 'hint' }]
|
|
92
|
-
}
|
|
93
|
-
this.setState({ value: isoDate, messages })
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
render() {
|
|
97
|
-
const text = this.state.value
|
|
98
|
-
? new Date(this.state.value).toString()
|
|
99
|
-
: 'N/A'
|
|
100
|
-
return (
|
|
101
|
-
<div>
|
|
102
|
-
<div style={{ marginBottom: '1em', fontStyle: 'italic' }}>
|
|
103
|
-
You entered:
|
|
104
|
-
<br />
|
|
105
|
-
{text}
|
|
106
|
-
</div>
|
|
107
|
-
<div style={{ height: '14rem' }}>
|
|
108
|
-
<DateTimeInput
|
|
109
|
-
description={
|
|
110
|
-
<ScreenReaderContent>Pick a date and time</ScreenReaderContent>
|
|
111
|
-
}
|
|
112
|
-
datePlaceholder="Choose"
|
|
113
|
-
dateRenderLabel="Date"
|
|
114
|
-
timeRenderLabel="Time"
|
|
115
|
-
prevMonthLabel="Previous month"
|
|
116
|
-
nextMonthLabel="Next month"
|
|
117
|
-
onChange={this.onChange}
|
|
118
|
-
layout="stacked"
|
|
119
|
-
value={this.state.value}
|
|
120
|
-
invalidDateTimeMessage="Invalid date!"
|
|
121
|
-
messages={this.state.messages}
|
|
122
|
-
allowNonStepInput={true}
|
|
123
|
-
isRequired
|
|
124
|
-
/>
|
|
125
|
-
</div>
|
|
126
|
-
</div>
|
|
127
|
-
)
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
render(<Example />)
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
- ```js
|
|
51
|
+
```js
|
|
52
|
+
---
|
|
53
|
+
type: example
|
|
54
|
+
---
|
|
134
55
|
const Example = () => {
|
|
135
56
|
const [value, setValue] = useState(undefined)
|
|
136
57
|
const [messages, setMessages] = useState([])
|
|
@@ -185,7 +106,7 @@ This sample code also allows the user to enter an arbitrary time value by settin
|
|
|
185
106
|
}
|
|
186
107
|
|
|
187
108
|
render(<Example />)
|
|
188
|
-
|
|
109
|
+
```
|
|
189
110
|
|
|
190
111
|
#### A disabled DateTimeInput:
|
|
191
112
|
|
|
@@ -209,34 +130,10 @@ type: example
|
|
|
209
130
|
|
|
210
131
|
#### A DateTimeInput in a different locale and timezone where these are set from the React `context`:
|
|
211
132
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
<ApplyLocale locale="fr" timezone="Africa/Nairobi">
|
|
217
|
-
<div style={{ height: '14rem' }}>
|
|
218
|
-
<DateTimeInput
|
|
219
|
-
description="Pick a date and time"
|
|
220
|
-
datePlaceholder="Choose a date"
|
|
221
|
-
dateRenderLabel="Date"
|
|
222
|
-
timeRenderLabel="Time"
|
|
223
|
-
prevMonthLabel="Previous month"
|
|
224
|
-
nextMonthLabel="Next month"
|
|
225
|
-
invalidDateTimeMessage={(dvalue) => {
|
|
226
|
-
return `'${dvalue} is not valid.`
|
|
227
|
-
}}
|
|
228
|
-
layout="columns"
|
|
229
|
-
defaultValue="2018-01-18T16:00"
|
|
230
|
-
/>
|
|
231
|
-
</div>
|
|
232
|
-
</ApplyLocale>
|
|
233
|
-
)
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
render(<Example />)
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
- ```js
|
|
133
|
+
```js
|
|
134
|
+
---
|
|
135
|
+
type: example
|
|
136
|
+
---
|
|
240
137
|
const Example = () => {
|
|
241
138
|
return (
|
|
242
139
|
<ApplyLocale locale="fr" timezone="Africa/Nairobi">
|
|
@@ -260,7 +157,7 @@ type: example
|
|
|
260
157
|
}
|
|
261
158
|
|
|
262
159
|
render(<Example />)
|
|
263
|
-
|
|
160
|
+
```
|
|
264
161
|
|
|
265
162
|
#### A `DateTimeInput` with some disabled dates that are supplied via a `string` array:
|
|
266
163
|
|
|
@@ -287,52 +184,10 @@ type: example
|
|
|
287
184
|
|
|
288
185
|
#### A `DateTimeInput` with some disabled dates that are supplied via a `function`:
|
|
289
186
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
class Example extends React.Component {
|
|
295
|
-
getDisabledDates(isoDateToCheck) {
|
|
296
|
-
const parsed = moment.tz(
|
|
297
|
-
isoDateToCheck,
|
|
298
|
-
[moment.ISO_8601],
|
|
299
|
-
locale,
|
|
300
|
-
timezone
|
|
301
|
-
)
|
|
302
|
-
const now = moment().locale(locale).tz(timezone)
|
|
303
|
-
return parsed.isBefore(now)
|
|
304
|
-
}
|
|
305
|
-
render() {
|
|
306
|
-
return (
|
|
307
|
-
<div style={{ height: '15rem' }}>
|
|
308
|
-
<DateTimeInput
|
|
309
|
-
description="Pick a date and time"
|
|
310
|
-
datePlaceholder="Choose a date"
|
|
311
|
-
dateRenderLabel="Date"
|
|
312
|
-
timeRenderLabel="Time"
|
|
313
|
-
invalidDateTimeMessage={(rawDateValue) =>
|
|
314
|
-
'Invalid date: ' + rawDateValue
|
|
315
|
-
}
|
|
316
|
-
disabledDateTimeMessage={(rawDateValue) =>
|
|
317
|
-
'Disabled date: ' + rawDateValue
|
|
318
|
-
}
|
|
319
|
-
prevMonthLabel="Previous month"
|
|
320
|
-
nextMonthLabel="Next month"
|
|
321
|
-
defaultValue="2022-04-08T13:30"
|
|
322
|
-
layout="columns"
|
|
323
|
-
disabledDates={this.getDisabledDates}
|
|
324
|
-
locale={locale}
|
|
325
|
-
timezone={timezone}
|
|
326
|
-
/>
|
|
327
|
-
</div>
|
|
328
|
-
)
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
render(<Example />)
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
- ```js
|
|
187
|
+
```js
|
|
188
|
+
---
|
|
189
|
+
type: example
|
|
190
|
+
---
|
|
336
191
|
const Example = () => {
|
|
337
192
|
const locale = 'en-us'
|
|
338
193
|
const timezone = 'America/Denver'
|
|
@@ -374,48 +229,16 @@ type: example
|
|
|
374
229
|
}
|
|
375
230
|
|
|
376
231
|
render(<Example />)
|
|
377
|
-
|
|
232
|
+
```
|
|
378
233
|
|
|
379
234
|
#### Programatically reset `DateTimeInput`
|
|
380
235
|
|
|
381
236
|
Due to `onChange` not being called on every typing event, and `value` isn't representing the inner value-state of the component, it's not possible to reset the `DateTimeInput` by setting the `value` to `undefined`. Instead, you can use the `reset` function that is passed to the `DateTimeInput` as a prop.
|
|
382
237
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
this.state = {
|
|
388
|
-
date: ''
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
resetFn = null
|
|
393
|
-
|
|
394
|
-
render() {
|
|
395
|
-
return (
|
|
396
|
-
<div>
|
|
397
|
-
<DateTimeInput
|
|
398
|
-
description="Pick a date and time"
|
|
399
|
-
datePlaceholder="Choose a date"
|
|
400
|
-
dateRenderLabel="Date"
|
|
401
|
-
timeRenderLabel="Time"
|
|
402
|
-
invalidDateTimeMessage="Invalid date!"
|
|
403
|
-
prevMonthLabel="Previous month"
|
|
404
|
-
nextMonthLabel="Next month"
|
|
405
|
-
value={this.state.date}
|
|
406
|
-
onChange={(e, newDate) => this.setState({ date: newDate })}
|
|
407
|
-
reset={(reset) => (this.resetFn = reset)}
|
|
408
|
-
/>
|
|
409
|
-
<Button onClick={() => this.resetFn()}>Clear</Button>
|
|
410
|
-
<p>{this.state.date}</p>
|
|
411
|
-
</div>
|
|
412
|
-
)
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
render(<Example />)
|
|
416
|
-
```
|
|
417
|
-
|
|
418
|
-
- ```js
|
|
238
|
+
```js
|
|
239
|
+
---
|
|
240
|
+
type: example
|
|
241
|
+
---
|
|
419
242
|
const Example = () => {
|
|
420
243
|
const [date, setDate] = useState('')
|
|
421
244
|
const resetFn = useRef()
|
|
@@ -440,4 +263,4 @@ Due to `onChange` not being called on every typing event, and `value` isn't repr
|
|
|
440
263
|
)
|
|
441
264
|
}
|
|
442
265
|
render(<Example />)
|
|
443
|
-
|
|
266
|
+
```
|