@instructure/ui-date-input 11.6.0 → 11.6.1-snapshot-129
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 +48 -309
- package/es/DateInput/{index.js → v1/index.js} +4 -4
- package/es/DateInput/v2/index.js +407 -0
- package/es/DateInput/v2/props.js +26 -0
- package/es/DateInput/v2/styles.js +46 -0
- package/es/DateInput2/{index.js → v1/index.js} +13 -11
- package/es/{index.js → exports/a.js} +2 -2
- package/{src/index.ts → es/exports/b.js} +2 -5
- package/lib/DateInput/{index.js → v1/index.js} +9 -9
- package/lib/DateInput/v2/index.js +416 -0
- package/lib/DateInput/v2/props.js +31 -0
- package/lib/DateInput/v2/styles.js +52 -0
- package/lib/DateInput2/{index.js → v1/index.js} +19 -19
- package/lib/{index.js → exports/a.js} +4 -4
- package/lib/exports/b.js +19 -0
- package/package.json +45 -23
- package/src/DateInput/{index.tsx → v1/index.tsx} +10 -7
- package/src/DateInput/{props.ts → v1/props.ts} +2 -2
- package/src/DateInput/v2/README.md +315 -0
- package/src/DateInput/v2/index.tsx +498 -0
- package/src/DateInput/v2/props.ts +316 -0
- package/src/DateInput/v2/styles.ts +52 -0
- package/src/DateInput2/{README.md → v1/README.md} +9 -9
- package/src/DateInput2/{index.tsx → v1/index.tsx} +11 -11
- package/src/DateInput2/{props.ts → v1/props.ts} +1 -1
- package/src/exports/a.ts +28 -0
- package/src/exports/b.ts +28 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/DateInput/{index.d.ts → v1/index.d.ts} +4 -4
- package/types/DateInput/v1/index.d.ts.map +1 -0
- package/types/DateInput/{props.d.ts → v1/props.d.ts} +2 -2
- package/types/DateInput/v1/props.d.ts.map +1 -0
- package/types/DateInput/v1/styles.d.ts.map +1 -0
- package/types/DateInput/v2/index.d.ts +109 -0
- package/types/DateInput/v2/index.d.ts.map +1 -0
- package/types/DateInput/v2/props.d.ts +234 -0
- package/types/DateInput/v2/props.d.ts.map +1 -0
- package/types/DateInput/v2/styles.d.ts +13 -0
- package/types/DateInput/v2/styles.d.ts.map +1 -0
- package/types/DateInput2/{index.d.ts → v1/index.d.ts} +2 -2
- package/types/DateInput2/v1/index.d.ts.map +1 -0
- package/types/DateInput2/{props.d.ts → v1/props.d.ts} +1 -1
- package/types/DateInput2/v1/props.d.ts.map +1 -0
- package/types/exports/a.d.ts +5 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +5 -0
- package/types/exports/b.d.ts.map +1 -0
- package/types/DateInput/index.d.ts.map +0 -1
- package/types/DateInput/props.d.ts.map +0 -1
- package/types/DateInput/styles.d.ts.map +0 -1
- package/types/DateInput2/index.d.ts.map +0 -1
- package/types/DateInput2/props.d.ts.map +0 -1
- package/types/index.d.ts +0 -5
- package/types/index.d.ts.map +0 -1
- /package/es/DateInput/{props.js → v1/props.js} +0 -0
- /package/es/DateInput/{styles.js → v1/styles.js} +0 -0
- /package/es/DateInput2/{props.js → v1/props.js} +0 -0
- /package/lib/DateInput/{props.js → v1/props.js} +0 -0
- /package/lib/DateInput/{styles.js → v1/styles.js} +0 -0
- /package/lib/DateInput2/{props.js → v1/props.js} +0 -0
- /package/src/DateInput/{README.md → v1/README.md} +0 -0
- /package/src/DateInput/{styles.ts → v1/styles.ts} +0 -0
- /package/types/DateInput/{styles.d.ts → v1/styles.d.ts} +0 -0
|
@@ -0,0 +1,316 @@
|
|
|
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 type { CalendarDayProps } from '@instructure/ui-calendar/latest'
|
|
26
|
+
import type { FormMessage } from '@instructure/ui-form-field/latest'
|
|
27
|
+
import type { PlacementPropValues } from '@instructure/ui-position'
|
|
28
|
+
import type { Renderable, OtherHTMLAttributes } from '@instructure/shared-types'
|
|
29
|
+
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
30
|
+
import { InputHTMLAttributes, ReactElement, SyntheticEvent } from 'react'
|
|
31
|
+
|
|
32
|
+
type DateInputOwnProps = {
|
|
33
|
+
/**
|
|
34
|
+
* Specifies the input label.
|
|
35
|
+
*/
|
|
36
|
+
renderLabel: Renderable
|
|
37
|
+
/**
|
|
38
|
+
* Specifies the input value.
|
|
39
|
+
*/
|
|
40
|
+
value?: string // TODO: controllable(PropTypes.string)
|
|
41
|
+
/**
|
|
42
|
+
* Specifies the input size.
|
|
43
|
+
*/
|
|
44
|
+
size?: 'small' | 'medium' | 'large'
|
|
45
|
+
/**
|
|
46
|
+
* Html placeholder text to display when the input has no value. This should
|
|
47
|
+
* be hint text, not a label replacement.
|
|
48
|
+
*/
|
|
49
|
+
placeholder?: string
|
|
50
|
+
/**
|
|
51
|
+
* Callback executed when the input fires a change event.
|
|
52
|
+
* @param {Object} event - the event object
|
|
53
|
+
* @param {Object} data - additional data
|
|
54
|
+
* @param data.value - the new value
|
|
55
|
+
*/
|
|
56
|
+
onChange?: (
|
|
57
|
+
event: React.ChangeEvent<HTMLInputElement>,
|
|
58
|
+
value: { value: string }
|
|
59
|
+
) => void
|
|
60
|
+
/**
|
|
61
|
+
* Callback executed when the input fires a blur event.
|
|
62
|
+
*/
|
|
63
|
+
onBlur?: (event: React.SyntheticEvent) => void
|
|
64
|
+
/**
|
|
65
|
+
* Specifies if interaction with the input is enabled, disabled, or readonly.
|
|
66
|
+
* When "disabled", the input changes visibly to indicate that it cannot
|
|
67
|
+
* receive user interactions. When "readonly" the input still cannot receive
|
|
68
|
+
* user interactions but it keeps the same styles as if it were enabled.
|
|
69
|
+
*/
|
|
70
|
+
interaction?: 'enabled' | 'disabled' | 'readonly'
|
|
71
|
+
/**
|
|
72
|
+
* Specifies if the input is required.
|
|
73
|
+
*/
|
|
74
|
+
isRequired?: boolean
|
|
75
|
+
/**
|
|
76
|
+
* Controls whether the input is rendered inline with other elements or if it
|
|
77
|
+
* is rendered as a block level element.
|
|
78
|
+
*/
|
|
79
|
+
isInline?: boolean
|
|
80
|
+
/**
|
|
81
|
+
* Additional helpful text to provide to screen readers about the operation
|
|
82
|
+
* of the component.
|
|
83
|
+
*/
|
|
84
|
+
assistiveText?: string
|
|
85
|
+
/**
|
|
86
|
+
* Controls the layout. When set to `stacked`, the label rests on top of the
|
|
87
|
+
* input. When set to `inline` the label is next to the input.
|
|
88
|
+
*/
|
|
89
|
+
layout?: 'stacked' | 'inline'
|
|
90
|
+
/**
|
|
91
|
+
* Specifies the width of the input.
|
|
92
|
+
*/
|
|
93
|
+
width?: string
|
|
94
|
+
/**
|
|
95
|
+
* Specifies the display property of the container.
|
|
96
|
+
*/
|
|
97
|
+
display?: 'inline-block' | 'block'
|
|
98
|
+
/**
|
|
99
|
+
* Provides a ref to the underlying input element.
|
|
100
|
+
*/
|
|
101
|
+
inputRef?: (element: HTMLInputElement | null) => void
|
|
102
|
+
/**
|
|
103
|
+
* Displays informational and error messages, used for input validation,
|
|
104
|
+
* can also display screenreader-only messages.
|
|
105
|
+
* Also changes the border color of the component on success/error.
|
|
106
|
+
* This is automatically set to `invalidDateErrorMessage` when the date is invalid
|
|
107
|
+
*/
|
|
108
|
+
messages?: FormMessage[]
|
|
109
|
+
/**
|
|
110
|
+
* The placement of the calendar in relation to the input.
|
|
111
|
+
*/
|
|
112
|
+
placement?: PlacementPropValues
|
|
113
|
+
/**
|
|
114
|
+
* Controls whether the calendar is showing.
|
|
115
|
+
*/
|
|
116
|
+
isShowingCalendar?: boolean
|
|
117
|
+
/**
|
|
118
|
+
* Callback fired when the input is blurred. Feedback should be provided
|
|
119
|
+
* to the user when this function is called if the selected date or input
|
|
120
|
+
* value is not valid. The component calculates date validity and if it's
|
|
121
|
+
* disabled or nor and passes that information to this callback.
|
|
122
|
+
*/
|
|
123
|
+
onRequestValidateDate?: (
|
|
124
|
+
event: SyntheticEvent,
|
|
125
|
+
dateString?: string,
|
|
126
|
+
validation?: FormMessage[]
|
|
127
|
+
) => void | FormMessage[]
|
|
128
|
+
/**
|
|
129
|
+
* Callback fired requesting the calendar be shown.
|
|
130
|
+
*/
|
|
131
|
+
onRequestShowCalendar?: (event: SyntheticEvent) => void
|
|
132
|
+
/**
|
|
133
|
+
* Callback fired requesting the calendar be hidden.
|
|
134
|
+
*/
|
|
135
|
+
onRequestHideCalendar?: (event: SyntheticEvent) => void
|
|
136
|
+
/**
|
|
137
|
+
* Callback fired requesting the next day be selected. If no date is currently
|
|
138
|
+
* selected should default to the first day of the currently rendered month.
|
|
139
|
+
*/
|
|
140
|
+
onRequestSelectNextDay?: (event: SyntheticEvent) => void
|
|
141
|
+
/**
|
|
142
|
+
* Callback fired requesting the previous day be selected. If no date is currently
|
|
143
|
+
* selected should default to the first day of the currently rendered month.
|
|
144
|
+
*/
|
|
145
|
+
onRequestSelectPrevDay?: (event: SyntheticEvent) => void
|
|
146
|
+
/**
|
|
147
|
+
* Callback fired requesting the next month be rendered.
|
|
148
|
+
*/
|
|
149
|
+
onRequestRenderNextMonth?: (e: React.MouseEvent) => void
|
|
150
|
+
/**
|
|
151
|
+
* Callback fired requesting the previous month be rendered.
|
|
152
|
+
*/
|
|
153
|
+
onRequestRenderPrevMonth?: (e: React.MouseEvent) => void
|
|
154
|
+
/**
|
|
155
|
+
* Content to render in the calendar navigation header. The recommendation is
|
|
156
|
+
* to include the name of the current rendered month along with the year.
|
|
157
|
+
*/
|
|
158
|
+
renderNavigationLabel?: React.ReactNode | (() => React.ReactNode)
|
|
159
|
+
/**
|
|
160
|
+
* An array of labels containing the name of each day of the week. The visible
|
|
161
|
+
* portion of the label should be abbreviated (no longer than three characters).
|
|
162
|
+
* Note that screen readers will read this content preceding each date as the
|
|
163
|
+
* `<Calendar />` is navigated. Consider using
|
|
164
|
+
* [AccessibleContent](AccessibleContent) with the `alt` prop containing the
|
|
165
|
+
* full day name for assistive technologies and the children containing the
|
|
166
|
+
* abbreviation. ex. `[<AccessibleContent alt="Sunday">Sun</AccessibleContent>, ...]`
|
|
167
|
+
*/
|
|
168
|
+
renderWeekdayLabels?: (React.ReactNode | (() => React.ReactNode))[]
|
|
169
|
+
/**
|
|
170
|
+
* A button to render in the calendar navigation header. The recommendation is
|
|
171
|
+
* to compose it with the [Button](Button) component, setting the `variant`
|
|
172
|
+
* prop to `icon`, the `size` prop to `small`, and setting the `icon` prop to
|
|
173
|
+
* [IconArrowOpenEnd](icons).
|
|
174
|
+
*/
|
|
175
|
+
renderNextMonthButton?: Renderable
|
|
176
|
+
/**
|
|
177
|
+
* A button to render in the calendar navigation header. The recommendation is
|
|
178
|
+
* to compose it with the [Button](Button) component, setting the `variant`
|
|
179
|
+
* prop to `icon`, the `size` prop to `small`, and setting the `icon` prop to
|
|
180
|
+
* [IconArrowOpenStart](icons).
|
|
181
|
+
*/
|
|
182
|
+
renderPrevMonthButton?: Renderable
|
|
183
|
+
/**
|
|
184
|
+
* children of type `<DateInput.Day />` There should be exactly 42 provided (6
|
|
185
|
+
* weeks).
|
|
186
|
+
*/
|
|
187
|
+
children?: ReactElement<CalendarDayProps>[] // TODO: oneOf([Calendar.Day])
|
|
188
|
+
/*
|
|
189
|
+
* Specify which date(s) will be shown as disabled in the calendar.
|
|
190
|
+
* You can either supply an array of ISO8601 timeDate strings or
|
|
191
|
+
* a function that will be called for each date shown in the calendar.
|
|
192
|
+
*/
|
|
193
|
+
disabledDates?: string[] | ((isoDateToCheck: string) => boolean)
|
|
194
|
+
/**
|
|
195
|
+
* ISO date string for the current date if necessary. Defaults to the current
|
|
196
|
+
* date in the user's timezone.
|
|
197
|
+
*/
|
|
198
|
+
currentDate?: string
|
|
199
|
+
/**
|
|
200
|
+
* The message shown to the user when the data is invalid.
|
|
201
|
+
* If a string, shown to the user anytime the input is invalid.
|
|
202
|
+
*
|
|
203
|
+
* If a function, receives a single parameter:
|
|
204
|
+
* - *rawDateValue*: the string entered as a date by the user.
|
|
205
|
+
**/
|
|
206
|
+
invalidDateErrorMessage?: string | ((rawDateValue: string) => FormMessage)
|
|
207
|
+
/**
|
|
208
|
+
* Error message shown to the user if they enter a date that is disabled.
|
|
209
|
+
* If not specified the component will show the `invalidDateTimeMessage`.
|
|
210
|
+
*/
|
|
211
|
+
disabledDateErrorMessage?: string | ((rawDateValue: string) => FormMessage)
|
|
212
|
+
/**
|
|
213
|
+
* A standard language identifier.
|
|
214
|
+
*
|
|
215
|
+
* See [Moment.js](https://momentjs.com/timezone/docs/#/using-timezones/parsing-in-zone/) for
|
|
216
|
+
* more details.
|
|
217
|
+
*
|
|
218
|
+
* This property can also be set via a context property and if both are set
|
|
219
|
+
* then the component property takes precedence over the context property.
|
|
220
|
+
*
|
|
221
|
+
* The web browser's locale will be used if no value is set via a component
|
|
222
|
+
* property or a context property.
|
|
223
|
+
**/
|
|
224
|
+
locale?: string
|
|
225
|
+
/**
|
|
226
|
+
* A timezone identifier in the format: *Area/Location*
|
|
227
|
+
*
|
|
228
|
+
* See [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) for the list
|
|
229
|
+
* of possible options.
|
|
230
|
+
*
|
|
231
|
+
* This property can also be set via a context property and if both are set
|
|
232
|
+
* then the component property takes precedence over the context property.
|
|
233
|
+
*
|
|
234
|
+
* The web browser's timezone will be used if no value is set via a component
|
|
235
|
+
* property or a context property.
|
|
236
|
+
**/
|
|
237
|
+
timezone?: string
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* If set, years can be picked from a dropdown.
|
|
241
|
+
* It accepts an object.
|
|
242
|
+
* screenReaderLabel: string // e.g.: i18n("pick a year")
|
|
243
|
+
*
|
|
244
|
+
* onRequestYearChange?:(e: React.MouseEvent,requestedYear: number): void // if set, on year change, only this will be called and no internal change will take place
|
|
245
|
+
*
|
|
246
|
+
* startYear: number // e.g.: 2001, sets the start year of the selectable list
|
|
247
|
+
*
|
|
248
|
+
* endYear: number // e.g.: 2030, sets the end year of the selectable list
|
|
249
|
+
*/
|
|
250
|
+
withYearPicker?: {
|
|
251
|
+
screenReaderLabel: string
|
|
252
|
+
onRequestYearChange?: (e: any, requestedYear: number) => void
|
|
253
|
+
startYear: number
|
|
254
|
+
endYear: number
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
type PropKeys = keyof DateInputOwnProps
|
|
259
|
+
|
|
260
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
261
|
+
|
|
262
|
+
type DateInputProps = DateInputOwnProps &
|
|
263
|
+
WithStyleProps<null, DateInputStyle> &
|
|
264
|
+
OtherHTMLAttributes<
|
|
265
|
+
DateInputOwnProps,
|
|
266
|
+
InputHTMLAttributes<DateInputOwnProps & Element>
|
|
267
|
+
>
|
|
268
|
+
|
|
269
|
+
type DateInputStyle = ComponentStyle<'dateInput' | 'assistiveText'>
|
|
270
|
+
const allowedProps: AllowedPropKeys = [
|
|
271
|
+
'renderLabel',
|
|
272
|
+
'value',
|
|
273
|
+
'size',
|
|
274
|
+
'placeholder',
|
|
275
|
+
'onChange',
|
|
276
|
+
'onBlur',
|
|
277
|
+
'interaction',
|
|
278
|
+
'isRequired',
|
|
279
|
+
'isInline',
|
|
280
|
+
'assistiveText',
|
|
281
|
+
'layout',
|
|
282
|
+
'width',
|
|
283
|
+
'display',
|
|
284
|
+
'inputRef',
|
|
285
|
+
'messages',
|
|
286
|
+
'placement',
|
|
287
|
+
'isShowingCalendar',
|
|
288
|
+
'onRequestValidateDate',
|
|
289
|
+
'onRequestShowCalendar',
|
|
290
|
+
'onRequestHideCalendar',
|
|
291
|
+
'onRequestSelectNextDay',
|
|
292
|
+
'onRequestSelectPrevDay',
|
|
293
|
+
'onRequestRenderNextMonth',
|
|
294
|
+
'onRequestRenderPrevMonth',
|
|
295
|
+
'renderNavigationLabel',
|
|
296
|
+
'renderWeekdayLabels',
|
|
297
|
+
'renderNextMonthButton',
|
|
298
|
+
'renderPrevMonthButton',
|
|
299
|
+
'children',
|
|
300
|
+
'disabledDates',
|
|
301
|
+
'currentDate',
|
|
302
|
+
'disabledDateErrorMessage',
|
|
303
|
+
'invalidDateErrorMessage',
|
|
304
|
+
'locale',
|
|
305
|
+
'timezone'
|
|
306
|
+
]
|
|
307
|
+
|
|
308
|
+
type DateInputState = {
|
|
309
|
+
hasInputRef: boolean
|
|
310
|
+
isShowingCalendar: boolean
|
|
311
|
+
validatedDate?: string
|
|
312
|
+
messages: FormMessage[]
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export type { DateInputProps, DateInputStyle, DateInputState }
|
|
316
|
+
export { allowedProps }
|
|
@@ -0,0 +1,52 @@
|
|
|
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 type { DateInputProps, DateInputStyle } from './props'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* ---
|
|
29
|
+
* private: true
|
|
30
|
+
* ---
|
|
31
|
+
* Generates the style object from the theme and provided additional information
|
|
32
|
+
* @param _componentTheme The theme variable object.
|
|
33
|
+
* @param props the props of the component, the style is applied to
|
|
34
|
+
* @return The final style object, which will be used in the component
|
|
35
|
+
*/
|
|
36
|
+
const generateStyle = (
|
|
37
|
+
_componentTheme: null,
|
|
38
|
+
props: DateInputProps
|
|
39
|
+
): DateInputStyle => {
|
|
40
|
+
return {
|
|
41
|
+
dateInput: {
|
|
42
|
+
label: 'dateInput',
|
|
43
|
+
display: props.display
|
|
44
|
+
},
|
|
45
|
+
assistiveText: {
|
|
46
|
+
label: 'dateInput__assistiveText',
|
|
47
|
+
display: 'none'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default generateStyle
|
|
@@ -32,9 +32,9 @@ type: example
|
|
|
32
32
|
invalidDateErrorMessage="Invalid date"
|
|
33
33
|
/>
|
|
34
34
|
<p>
|
|
35
|
-
Input Value:
|
|
35
|
+
<Text>Input Value: </Text><code>{inputValue}</code>
|
|
36
36
|
<br />
|
|
37
|
-
UTC Date String:
|
|
37
|
+
<Text>UTC Date String: </Text><code>{dateString}</code>
|
|
38
38
|
</p>
|
|
39
39
|
</div>
|
|
40
40
|
)
|
|
@@ -64,7 +64,7 @@ const Example = () => {
|
|
|
64
64
|
|
|
65
65
|
return (
|
|
66
66
|
<div>
|
|
67
|
-
<p>US locale with default format:</
|
|
67
|
+
<Text as="p">US locale with default format:</Text>
|
|
68
68
|
<DateInput2
|
|
69
69
|
renderLabel="Choose a date"
|
|
70
70
|
screenReaderLabels={{
|
|
@@ -78,7 +78,7 @@ const Example = () => {
|
|
|
78
78
|
locale="en-us"
|
|
79
79
|
onChange={(e, value) => setValue(value)}
|
|
80
80
|
/>
|
|
81
|
-
<p>US locale with german date format:</
|
|
81
|
+
<Text as="p">US locale with german date format:</Text>
|
|
82
82
|
<DateInput2
|
|
83
83
|
renderLabel="Choose a date"
|
|
84
84
|
screenReaderLabels={{
|
|
@@ -93,7 +93,7 @@ const Example = () => {
|
|
|
93
93
|
dateFormat="de-de"
|
|
94
94
|
onChange={(e, value) => setValue2(value)}
|
|
95
95
|
/>
|
|
96
|
-
<p>US locale with ISO date format:</
|
|
96
|
+
<Text as="p">US locale with ISO date format:</Text>
|
|
97
97
|
<DateInput2
|
|
98
98
|
renderLabel="Choose a date"
|
|
99
99
|
screenReaderLabels={{
|
|
@@ -168,9 +168,9 @@ type: example
|
|
|
168
168
|
}}
|
|
169
169
|
/>
|
|
170
170
|
<p>
|
|
171
|
-
Input Value:
|
|
171
|
+
<Text>Input Value: </Text><code>{inputValue}</code>
|
|
172
172
|
<br />
|
|
173
|
-
UTC Date String:
|
|
173
|
+
<Text>UTC Date String: </Text><code>{dateString}</code>
|
|
174
174
|
</p>
|
|
175
175
|
</div>
|
|
176
176
|
)
|
|
@@ -202,12 +202,12 @@ const Example = () => {
|
|
|
202
202
|
// don't validate empty input
|
|
203
203
|
if (!utcIsoDate && inputValue.length > 0) {
|
|
204
204
|
setMessages([{
|
|
205
|
-
type: '
|
|
205
|
+
type: 'error',
|
|
206
206
|
text: 'This is not a valid date'
|
|
207
207
|
}])
|
|
208
208
|
} else if (date < new Date('1990-01-01')) {
|
|
209
209
|
setMessages([{
|
|
210
|
-
type: '
|
|
210
|
+
type: 'error',
|
|
211
211
|
text: 'Select date after January 1, 1990'
|
|
212
212
|
}])
|
|
213
213
|
} else {
|
|
@@ -24,20 +24,20 @@
|
|
|
24
24
|
|
|
25
25
|
import { useState, useEffect, forwardRef, ForwardedRef } from 'react'
|
|
26
26
|
import type { SyntheticEvent } from 'react'
|
|
27
|
-
import { Calendar } from '@instructure/ui-calendar'
|
|
28
|
-
import { IconButton } from '@instructure/ui-buttons'
|
|
27
|
+
import { Calendar } from '@instructure/ui-calendar/v11_6'
|
|
28
|
+
import { IconButton } from '@instructure/ui-buttons/v11_6'
|
|
29
29
|
import {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
CalendarInstUIIcon,
|
|
31
|
+
ChevronLeftInstUIIcon,
|
|
32
|
+
ChevronRightInstUIIcon
|
|
33
33
|
} from '@instructure/ui-icons'
|
|
34
|
-
import { Popover } from '@instructure/ui-popover'
|
|
35
|
-
import { TextInput } from '@instructure/ui-text-input'
|
|
34
|
+
import { Popover } from '@instructure/ui-popover/v11_6'
|
|
35
|
+
import { TextInput } from '@instructure/ui-text-input/v11_6'
|
|
36
36
|
import { callRenderProp, passthroughProps } from '@instructure/ui-react-utils'
|
|
37
37
|
import { getLocale, getTimezone } from '@instructure/ui-i18n'
|
|
38
38
|
|
|
39
39
|
import type { DateInput2Props } from './props'
|
|
40
|
-
import type { FormMessage } from '@instructure/ui-form-field'
|
|
40
|
+
import type { FormMessage } from '@instructure/ui-form-field/v11_6'
|
|
41
41
|
import type { Moment } from '@instructure/ui-i18n'
|
|
42
42
|
|
|
43
43
|
function parseLocaleDate(
|
|
@@ -287,7 +287,7 @@ const DateInput2 = forwardRef(
|
|
|
287
287
|
{renderCalendarIcon ? (
|
|
288
288
|
callRenderProp(renderCalendarIcon)
|
|
289
289
|
) : (
|
|
290
|
-
<
|
|
290
|
+
<CalendarInstUIIcon color="baseColor" />
|
|
291
291
|
)}
|
|
292
292
|
</IconButton>
|
|
293
293
|
}
|
|
@@ -313,7 +313,7 @@ const DateInput2 = forwardRef(
|
|
|
313
313
|
size="small"
|
|
314
314
|
withBackground={false}
|
|
315
315
|
withBorder={false}
|
|
316
|
-
renderIcon={<
|
|
316
|
+
renderIcon={<ChevronRightInstUIIcon color="baseColor" />}
|
|
317
317
|
screenReaderLabel={screenReaderLabels.nextMonthButton}
|
|
318
318
|
/>
|
|
319
319
|
}
|
|
@@ -322,7 +322,7 @@ const DateInput2 = forwardRef(
|
|
|
322
322
|
size="small"
|
|
323
323
|
withBackground={false}
|
|
324
324
|
withBorder={false}
|
|
325
|
-
renderIcon={<
|
|
325
|
+
renderIcon={<ChevronLeftInstUIIcon color="baseColor" />}
|
|
326
326
|
screenReaderLabel={screenReaderLabels.prevMonthButton}
|
|
327
327
|
/>
|
|
328
328
|
}
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import type { SyntheticEvent, InputHTMLAttributes } from 'react'
|
|
26
|
-
import type { FormMessage } from '@instructure/ui-form-field'
|
|
26
|
+
import type { FormMessage } from '@instructure/ui-form-field/v11_6'
|
|
27
27
|
import type { OtherHTMLAttributes, Renderable } from '@instructure/shared-types'
|
|
28
28
|
import type { Spacing } from '@instructure/emotion'
|
|
29
29
|
|
package/src/exports/a.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
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 { DateInput } from '../DateInput/v1'
|
|
26
|
+
export { DateInput2 } from '../DateInput2/v1'
|
|
27
|
+
export type { DateInputProps } from '../DateInput/v1/props'
|
|
28
|
+
export type { DateInput2Props } from '../DateInput2/v1/props'
|
package/src/exports/b.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
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 { DateInput } from '../DateInput/v2'
|
|
26
|
+
export { DateInput2 } from '../DateInput2/v1'
|
|
27
|
+
export type { DateInputProps } from '../DateInput/v2/props'
|
|
28
|
+
export type { DateInput2Props } from '../DateInput2/v1/props'
|