@instructure/ui-date-time-input 11.7.3-snapshot-29 → 11.7.3-snapshot-30
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 +27 -1
- package/es/DateTimeInput/v2/index.js +343 -0
- package/es/DateTimeInput/v2/props.js +26 -0
- package/es/exports/b.js +24 -0
- package/lib/DateTimeInput/v2/index.js +349 -0
- package/lib/DateTimeInput/v2/props.js +31 -0
- package/lib/exports/b.js +12 -0
- package/package.json +24 -24
- package/src/DateTimeInput/v2/README.md +261 -0
- package/src/DateTimeInput/v2/index.tsx +439 -0
- package/src/DateTimeInput/v2/props.ts +299 -0
- package/src/exports/b.ts +25 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/DateTimeInput/v2/index.d.ts +52 -0
- package/types/DateTimeInput/v2/index.d.ts.map +1 -0
- package/types/DateTimeInput/v2/props.d.ts +226 -0
- package/types/DateTimeInput/v2/props.d.ts.map +1 -0
- package/types/exports/b.d.ts +2 -0
- package/types/exports/b.d.ts.map +1 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { SyntheticEvent } from 'react'
|
|
26
|
+
import type { FormMessage } from '@instructure/ui-form-field/latest'
|
|
27
|
+
import type { InteractionType } from '@instructure/ui-react-utils'
|
|
28
|
+
import type { Moment } from '@instructure/ui-i18n'
|
|
29
|
+
import type { Renderable } from '@instructure/shared-types'
|
|
30
|
+
|
|
31
|
+
type DateTimeInputProps = {
|
|
32
|
+
/**
|
|
33
|
+
* The label over the composite `DateTimeInput` component
|
|
34
|
+
**/
|
|
35
|
+
description: React.ReactNode
|
|
36
|
+
/**
|
|
37
|
+
* The label over the DateInput
|
|
38
|
+
**/
|
|
39
|
+
dateRenderLabel: Renderable
|
|
40
|
+
/**
|
|
41
|
+
* Accessible labels for the calendar icon button, month navigation buttons, and date picker dialog.
|
|
42
|
+
*/
|
|
43
|
+
screenReaderLabels: {
|
|
44
|
+
calendarIcon: string
|
|
45
|
+
prevMonthButton: string
|
|
46
|
+
nextMonthButton: string
|
|
47
|
+
datePickerDialog?: string
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* HTML placeholder text to display when the date input has no value.
|
|
51
|
+
* This should be hint text, not a label replacement.
|
|
52
|
+
**/
|
|
53
|
+
datePlaceholder?: string
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* HTML placeholder text to display when the time input has no value.
|
|
57
|
+
* This should be hint text, not a label replacement.
|
|
58
|
+
**/
|
|
59
|
+
timePlaceholder?: string
|
|
60
|
+
/**
|
|
61
|
+
* Controls how the date is displayed in the input and parsed when the user types.
|
|
62
|
+
* When omitted, the locale determines the format.
|
|
63
|
+
* Pass a locale string (e.g. `"en-US"`) to use an alternate locale's format,
|
|
64
|
+
* or pass `{ parser, formatter }` functions for fully custom behaviour.
|
|
65
|
+
**/
|
|
66
|
+
dateFormat?:
|
|
67
|
+
| {
|
|
68
|
+
parser: (input: string) => Date | null
|
|
69
|
+
formatter: (date: Date) => string
|
|
70
|
+
}
|
|
71
|
+
| string
|
|
72
|
+
/**
|
|
73
|
+
* The label over the time input
|
|
74
|
+
**/
|
|
75
|
+
timeRenderLabel: Renderable
|
|
76
|
+
/**
|
|
77
|
+
* The number of minutes to increment by when generating the allowable time options.
|
|
78
|
+
*/
|
|
79
|
+
timeStep?: 5 | 10 | 15 | 20 | 30 | 60
|
|
80
|
+
/**
|
|
81
|
+
* The format of the time shown in the `TimeSelect` when a time is selected.
|
|
82
|
+
* Valid formats are compatible with
|
|
83
|
+
* [Moment formats](https://momentjs.com/docs/#/displaying/format/),
|
|
84
|
+
* including localized formats.
|
|
85
|
+
*
|
|
86
|
+
* If omitted, defers to the underlying `TimeSelect`'s default.
|
|
87
|
+
**/
|
|
88
|
+
timeFormat?: string
|
|
89
|
+
/**
|
|
90
|
+
* A standard language identifier.
|
|
91
|
+
*
|
|
92
|
+
* See [Moment.js](https://momentjs.com/timezone/docs/#/using-timezones/parsing-in-zone/) for
|
|
93
|
+
* more details.
|
|
94
|
+
*
|
|
95
|
+
* This property can also be set via a context property and if both are set
|
|
96
|
+
* then the component property takes precedence over the context property.
|
|
97
|
+
*
|
|
98
|
+
* The web browser's locale will be used if no value is set via a component
|
|
99
|
+
* property or a context property.
|
|
100
|
+
**/
|
|
101
|
+
locale?: string
|
|
102
|
+
/**
|
|
103
|
+
* A timezone identifier in the format: *Area/Location*
|
|
104
|
+
*
|
|
105
|
+
* See [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) for the list
|
|
106
|
+
* of possible options.
|
|
107
|
+
*
|
|
108
|
+
* This property can also be set via a context property and if both are set
|
|
109
|
+
* then the component property takes precedence over the context property.
|
|
110
|
+
*
|
|
111
|
+
* The web browser's timezone will be used if no value is set via a component
|
|
112
|
+
* property or a context property.
|
|
113
|
+
**/
|
|
114
|
+
timezone?: string
|
|
115
|
+
/**
|
|
116
|
+
* The message shown to the user when the data is invalid.
|
|
117
|
+
* If a string, shown to the user anytime the input is invalid.
|
|
118
|
+
*
|
|
119
|
+
* If a function, receives a single parameter:
|
|
120
|
+
* - *rawDateValue*: the string entered as a date by the user.
|
|
121
|
+
*
|
|
122
|
+
* Currently, times must be selected from a list, it can never be incorrect,
|
|
123
|
+
* Though `invalidDateTimeMessage()` will be called if the user selects a time without
|
|
124
|
+
* setting the date.
|
|
125
|
+
**/
|
|
126
|
+
invalidDateTimeMessage: string | ((rawDateValue: string) => string)
|
|
127
|
+
/**
|
|
128
|
+
* Toggles whether to show built-in messages (the date/time, or the
|
|
129
|
+
* `invalidDateTimeMessage`). Even when set to `false` the component will
|
|
130
|
+
* show user supplied messages by the `messages` prop.
|
|
131
|
+
* @default true
|
|
132
|
+
*/
|
|
133
|
+
showMessages?: boolean
|
|
134
|
+
/**
|
|
135
|
+
* Extra message(s) to be displayed.
|
|
136
|
+
*/
|
|
137
|
+
messages?: FormMessage[]
|
|
138
|
+
/**
|
|
139
|
+
* This format of the composite date-time when displayed in messages.
|
|
140
|
+
* Valid formats are defined in the
|
|
141
|
+
* [Moment docs](https://momentjs.com/docs/#/displaying/format/)
|
|
142
|
+
**/
|
|
143
|
+
messageFormat?: string
|
|
144
|
+
/**
|
|
145
|
+
* The layout of this component.
|
|
146
|
+
* Vertically stacked, horizontally arranged in 2 columns, or inline (default).
|
|
147
|
+
* See [FormFieldGroup](FormFieldGroup) for details.
|
|
148
|
+
**/
|
|
149
|
+
layout?: 'stacked' | 'columns' | 'inline'
|
|
150
|
+
/**
|
|
151
|
+
* Controls the spacing between the inputs when they are in a vertical layout.
|
|
152
|
+
**/
|
|
153
|
+
rowSpacing?: 'none' | 'small' | 'medium' | 'large'
|
|
154
|
+
/**
|
|
155
|
+
* Controls the spacing between the inputs when they are in a horizontal layout.
|
|
156
|
+
**/
|
|
157
|
+
colSpacing?: 'none' | 'small' | 'medium' | 'large'
|
|
158
|
+
/**
|
|
159
|
+
* An ISO 8601 formatted date string representing the current date-time
|
|
160
|
+
* (must be accompanied by an onChange prop).
|
|
161
|
+
**/
|
|
162
|
+
value?: string // TODO: controllable(I18nPropTypes.iso8601, 'onChange')
|
|
163
|
+
/**
|
|
164
|
+
* An ISO 8601 formatted date string to use if `value` isn't provided.
|
|
165
|
+
**/
|
|
166
|
+
defaultValue?: string
|
|
167
|
+
/**
|
|
168
|
+
* If set, years can be picked from a dropdown in the calendar.
|
|
169
|
+
* screenReaderLabel: string // e.g.: i18n("pick a year")
|
|
170
|
+
* onRequestYearChange?: (e: React.SyntheticEvent, requestedYear: number) => void
|
|
171
|
+
* startYear: number // e.g.: 2001, sets the start year of the selectable list
|
|
172
|
+
* endYear: number // e.g.: 2030, sets the end year of the selectable list
|
|
173
|
+
*/
|
|
174
|
+
withYearPicker?: {
|
|
175
|
+
screenReaderLabel: string
|
|
176
|
+
onRequestYearChange?: (e: SyntheticEvent, requestedYear: number) => void
|
|
177
|
+
startYear: number
|
|
178
|
+
endYear: number
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Specifies if the input is required (its passed down to the native DOM
|
|
182
|
+
* elements). If its `true` then an empty input will produce an error message
|
|
183
|
+
* (`invalidDateTimeMessage`)
|
|
184
|
+
*/
|
|
185
|
+
isRequired?: boolean
|
|
186
|
+
/**
|
|
187
|
+
* Specifies if interaction with the input is enabled, disabled, or readonly.
|
|
188
|
+
* When "disabled", the input changes visibly to indicate that it cannot
|
|
189
|
+
* receive user interactions. When "readonly" the input still cannot receive
|
|
190
|
+
* user interactions but it keeps the same styles as if it were enabled.
|
|
191
|
+
*/
|
|
192
|
+
interaction?: InteractionType
|
|
193
|
+
/**
|
|
194
|
+
* Called when the date-time value has changed.
|
|
195
|
+
* The passed in parameters are:
|
|
196
|
+
* - *event*: The triggering event (which may be from the underlying
|
|
197
|
+
* `DateInput` or `TimeSelect`)
|
|
198
|
+
* - *isoValue*: The new date value in ISO8601 format, undefined if its invalid
|
|
199
|
+
**/
|
|
200
|
+
onChange?: (event: SyntheticEvent, isoValue?: string) => void
|
|
201
|
+
/**
|
|
202
|
+
* The HTML `input` element where the date is entered.
|
|
203
|
+
**/
|
|
204
|
+
dateInputRef?: (el: HTMLInputElement | null) => void
|
|
205
|
+
/**
|
|
206
|
+
* The HTML `input` element where the time is entered.
|
|
207
|
+
**/
|
|
208
|
+
timeInputRef?: (el: HTMLInputElement | null) => void
|
|
209
|
+
/**
|
|
210
|
+
* onBlur event handler for when focus leaves DateTimeInput.
|
|
211
|
+
* Does not fire when focus moves between DateInput and TimeSelect within the
|
|
212
|
+
* component
|
|
213
|
+
*/
|
|
214
|
+
onBlur?: (e: SyntheticEvent) => void
|
|
215
|
+
/*
|
|
216
|
+
* Specify which date(s) will be shown as disabled in the calendar.
|
|
217
|
+
* You can either supply an array of ISO8601 timeDate strings or
|
|
218
|
+
* a function that will be called for each date shown in the calendar.
|
|
219
|
+
*/
|
|
220
|
+
disabledDates?: string[] | ((isoDateToCheck: string) => boolean)
|
|
221
|
+
/**
|
|
222
|
+
* Error message shown to the user if they enter a date that is disabled.
|
|
223
|
+
* If not specified the component will show the `invalidDateTimeMessage`.
|
|
224
|
+
*/
|
|
225
|
+
disabledDateTimeMessage?: string | ((rawDateValue: string) => string)
|
|
226
|
+
/**
|
|
227
|
+
* Whether to allow the user to enter non-step divisible values in the time
|
|
228
|
+
* input field. Note that even if this is set to false one can enter non-step
|
|
229
|
+
* divisible values programmatically. The user will need to enter the value
|
|
230
|
+
* exactly (except for lower/uppercase) as specified by the `timeFormat` prop
|
|
231
|
+
* for it to be accepted.
|
|
232
|
+
* Default is `undefined` which equals to `false`
|
|
233
|
+
*/
|
|
234
|
+
allowNonStepInput?: boolean
|
|
235
|
+
/**
|
|
236
|
+
* The default time to be prefilled if a day is selected. The time input has to be empty for this to be applied.
|
|
237
|
+
* An error is thrown if the time format is not HH:MM.
|
|
238
|
+
*/
|
|
239
|
+
initialTimeForNewDate?: string
|
|
240
|
+
/**
|
|
241
|
+
* Used for getting the internal reset function of DateTimeInput. If that
|
|
242
|
+
* function is called, the component will reset to its default inner state.
|
|
243
|
+
* The callback function will be called in componentDidMount
|
|
244
|
+
* NOTE: this won't call onChange, so you have to reset the value manually when calling reset
|
|
245
|
+
*/
|
|
246
|
+
reset?: (reset: () => void) => void
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
type DateTimeInputState = {
|
|
250
|
+
// the time and date currently selected
|
|
251
|
+
iso?: Moment
|
|
252
|
+
// The value currently displayed in the dateInput component.
|
|
253
|
+
// Just the date part is visible
|
|
254
|
+
dateInputText: string
|
|
255
|
+
// The value currently displayed in the timeSelect component as ISO datetime
|
|
256
|
+
timeSelectValue?: string
|
|
257
|
+
// The message (success/error) shown below the component
|
|
258
|
+
message?: FormMessage
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
type PropKeys = keyof DateTimeInputProps
|
|
262
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
263
|
+
|
|
264
|
+
const allowedProps: AllowedPropKeys = [
|
|
265
|
+
'description',
|
|
266
|
+
'dateRenderLabel',
|
|
267
|
+
'screenReaderLabels',
|
|
268
|
+
'datePlaceholder',
|
|
269
|
+
'timePlaceholder',
|
|
270
|
+
'dateFormat',
|
|
271
|
+
'interaction',
|
|
272
|
+
'timeRenderLabel',
|
|
273
|
+
'timeStep',
|
|
274
|
+
'timeFormat',
|
|
275
|
+
'locale',
|
|
276
|
+
'timezone',
|
|
277
|
+
'invalidDateTimeMessage',
|
|
278
|
+
'showMessages',
|
|
279
|
+
'messages',
|
|
280
|
+
'messageFormat',
|
|
281
|
+
'layout',
|
|
282
|
+
'rowSpacing',
|
|
283
|
+
'colSpacing',
|
|
284
|
+
'value',
|
|
285
|
+
'defaultValue',
|
|
286
|
+
'isRequired',
|
|
287
|
+
'onChange',
|
|
288
|
+
'dateInputRef',
|
|
289
|
+
'timeInputRef',
|
|
290
|
+
'onBlur',
|
|
291
|
+
'disabledDates',
|
|
292
|
+
'disabledDateTimeMessage',
|
|
293
|
+
'allowNonStepInput',
|
|
294
|
+
'reset',
|
|
295
|
+
'withYearPicker'
|
|
296
|
+
]
|
|
297
|
+
|
|
298
|
+
export type { DateTimeInputProps, DateTimeInputState }
|
|
299
|
+
export { allowedProps }
|
package/src/exports/b.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export { DateTimeInput } from '../DateTimeInput/v2'
|