@instructure/ui-date-time-input 11.7.3-snapshot-29 → 11.7.3-snapshot-31

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.
@@ -0,0 +1,52 @@
1
+ import { Component, SyntheticEvent } from 'react';
2
+ import { ApplyLocaleContext } from '@instructure/ui-i18n';
3
+ import type { Moment } from '@instructure/ui-i18n';
4
+ import type { DateTimeInputProps, DateTimeInputState } from './props';
5
+ /**
6
+ ---
7
+ category: components
8
+ ---
9
+ **/
10
+ declare class DateTimeInput extends Component<DateTimeInputProps, DateTimeInputState> {
11
+ private static readonly DEFAULT_MESSAGE_FORMAT;
12
+ static allowedProps: readonly (keyof DateTimeInputProps)[];
13
+ static defaultProps: {
14
+ readonly layout: "inline";
15
+ readonly colSpacing: "medium";
16
+ readonly rowSpacing: "small";
17
+ readonly timeStep: 30;
18
+ readonly showMessages: true;
19
+ readonly messageFormat: "LLLL";
20
+ readonly isRequired: false;
21
+ readonly allowNonStepInput: false;
22
+ };
23
+ context: React.ContextType<typeof ApplyLocaleContext>;
24
+ static contextType: import("react").Context<{
25
+ locale?: string;
26
+ timezone?: string;
27
+ }>;
28
+ ref: Element | null;
29
+ handleRef: (el: Element | null) => void;
30
+ constructor(props: DateTimeInputProps);
31
+ componentDidMount(): void;
32
+ componentDidUpdate(prevProps: Readonly<DateTimeInputProps>): void;
33
+ recalculateState(dateStr?: string, doNotChangeDate?: boolean, doNotChangeTime?: boolean): DateTimeInputState;
34
+ reset: () => void;
35
+ locale(): string;
36
+ timezone(): string;
37
+ private formatDateInput;
38
+ isDisabledDate(date: Moment): boolean;
39
+ handleDateTextChange: (_event: SyntheticEvent, inputValue: string, _utcDateString: string) => void;
40
+ handleDateValidated: (event: SyntheticEvent, _inputValue: string, utcDateString: string) => void;
41
+ updateStateBasedOnTimeSelect: (event: SyntheticEvent, option: {
42
+ value?: string;
43
+ inputText: string;
44
+ }) => void;
45
+ changeStateIfNeeded: (newState: DateTimeInputState, e: SyntheticEvent) => void;
46
+ areDifferentDates: (d1?: Moment, d2?: Moment) => boolean;
47
+ handleBlur: (e: SyntheticEvent) => void;
48
+ render(): import("@emotion/react/jsx-runtime").JSX.Element;
49
+ }
50
+ export default DateTimeInput;
51
+ export { DateTimeInput };
52
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/DateTimeInput/v2/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACjD,OAAO,EAAoB,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAMlD,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAIrE;;;;GAIG;AACH,cAAM,aAAc,SAAQ,SAAS,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAE3E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CAAS;IACvD,MAAM,CAAC,YAAY,wCAAe;IAClC,MAAM,CAAC,YAAY;;;;;;;;;MAST;IAEF,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAA;IAC7D,MAAM,CAAC,WAAW;;;OAAqB;IAEvC,GAAG,EAAE,OAAO,GAAG,IAAI,CAAO;IAE1B,SAAS,GAAI,IAAI,OAAO,GAAG,IAAI,UAE9B;gBAEW,KAAK,EAAE,kBAAkB;IAOrC,iBAAiB;IAUjB,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GAAG,IAAI;IAqBjE,gBAAgB,CACd,OAAO,CAAC,EAAE,MAAM,EAChB,eAAe,UAAQ,EACvB,eAAe,UAAQ,GACtB,kBAAkB;IAkFrB,KAAK,aAA+C;IAEpD,MAAM,IAAI,MAAM;IAShB,QAAQ;IASR,OAAO,CAAC,eAAe;IAevB,cAAc,CAAC,IAAI,EAAE,MAAM;IAgB3B,oBAAoB,GAClB,QAAQ,cAAc,EACtB,YAAY,MAAM,EAClB,gBAAgB,MAAM,UAGvB;IAED,mBAAmB,GACjB,OAAO,cAAc,EACrB,aAAa,MAAM,EACnB,eAAe,MAAM,UAkCtB;IAED,4BAA4B,GAC1B,OAAO,cAAc,EACrB,QAAQ;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,UAS9C;IAED,mBAAmB,GAAI,UAAU,kBAAkB,EAAE,GAAG,cAAc,UAwBrE;IAED,iBAAiB,GAAI,KAAK,MAAM,EAAE,KAAK,MAAM,aAK5C;IAED,UAAU,GAAI,GAAG,cAAc,UAS9B;IAED,MAAM;CA2FP;AAED,eAAe,aAAa,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,CAAA"}
@@ -0,0 +1,226 @@
1
+ import { SyntheticEvent } from 'react';
2
+ import type { FormMessage } from '@instructure/ui-form-field/latest';
3
+ import type { InteractionType } from '@instructure/ui-react-utils';
4
+ import type { Moment } from '@instructure/ui-i18n';
5
+ import type { Renderable } from '@instructure/shared-types';
6
+ type DateTimeInputProps = {
7
+ /**
8
+ * The label over the composite `DateTimeInput` component
9
+ **/
10
+ description: React.ReactNode;
11
+ /**
12
+ * The label over the DateInput
13
+ **/
14
+ dateRenderLabel: Renderable;
15
+ /**
16
+ * Accessible labels for the calendar icon button, month navigation buttons, and date picker dialog.
17
+ */
18
+ screenReaderLabels: {
19
+ calendarIcon: string;
20
+ prevMonthButton: string;
21
+ nextMonthButton: string;
22
+ datePickerDialog?: string;
23
+ };
24
+ /**
25
+ * HTML placeholder text to display when the date input has no value.
26
+ * This should be hint text, not a label replacement.
27
+ **/
28
+ datePlaceholder?: string;
29
+ /**
30
+ * HTML placeholder text to display when the time input has no value.
31
+ * This should be hint text, not a label replacement.
32
+ **/
33
+ timePlaceholder?: string;
34
+ /**
35
+ * Controls how the date is displayed in the input and parsed when the user types.
36
+ * When omitted, the locale determines the format.
37
+ * Pass a locale string (e.g. `"en-US"`) to use an alternate locale's format,
38
+ * or pass `{ parser, formatter }` functions for fully custom behaviour.
39
+ **/
40
+ dateFormat?: {
41
+ parser: (input: string) => Date | null;
42
+ formatter: (date: Date) => string;
43
+ } | string;
44
+ /**
45
+ * The label over the time input
46
+ **/
47
+ timeRenderLabel: Renderable;
48
+ /**
49
+ * The number of minutes to increment by when generating the allowable time options.
50
+ */
51
+ timeStep?: 5 | 10 | 15 | 20 | 30 | 60;
52
+ /**
53
+ * The format of the time shown in the `TimeSelect` when a time is selected.
54
+ * Valid formats are compatible with
55
+ * [Moment formats](https://momentjs.com/docs/#/displaying/format/),
56
+ * including localized formats.
57
+ *
58
+ * If omitted, defers to the underlying `TimeSelect`'s default.
59
+ **/
60
+ timeFormat?: string;
61
+ /**
62
+ * A standard language identifier.
63
+ *
64
+ * See [Moment.js](https://momentjs.com/timezone/docs/#/using-timezones/parsing-in-zone/) for
65
+ * more details.
66
+ *
67
+ * This property can also be set via a context property and if both are set
68
+ * then the component property takes precedence over the context property.
69
+ *
70
+ * The web browser's locale will be used if no value is set via a component
71
+ * property or a context property.
72
+ **/
73
+ locale?: string;
74
+ /**
75
+ * A timezone identifier in the format: *Area/Location*
76
+ *
77
+ * See [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) for the list
78
+ * of possible options.
79
+ *
80
+ * This property can also be set via a context property and if both are set
81
+ * then the component property takes precedence over the context property.
82
+ *
83
+ * The web browser's timezone will be used if no value is set via a component
84
+ * property or a context property.
85
+ **/
86
+ timezone?: string;
87
+ /**
88
+ * The message shown to the user when the data is invalid.
89
+ * If a string, shown to the user anytime the input is invalid.
90
+ *
91
+ * If a function, receives a single parameter:
92
+ * - *rawDateValue*: the string entered as a date by the user.
93
+ *
94
+ * Currently, times must be selected from a list, it can never be incorrect,
95
+ * Though `invalidDateTimeMessage()` will be called if the user selects a time without
96
+ * setting the date.
97
+ **/
98
+ invalidDateTimeMessage: string | ((rawDateValue: string) => string);
99
+ /**
100
+ * Toggles whether to show built-in messages (the date/time, or the
101
+ * `invalidDateTimeMessage`). Even when set to `false` the component will
102
+ * show user supplied messages by the `messages` prop.
103
+ * @default true
104
+ */
105
+ showMessages?: boolean;
106
+ /**
107
+ * Extra message(s) to be displayed.
108
+ */
109
+ messages?: FormMessage[];
110
+ /**
111
+ * This format of the composite date-time when displayed in messages.
112
+ * Valid formats are defined in the
113
+ * [Moment docs](https://momentjs.com/docs/#/displaying/format/)
114
+ **/
115
+ messageFormat?: string;
116
+ /**
117
+ * The layout of this component.
118
+ * Vertically stacked, horizontally arranged in 2 columns, or inline (default).
119
+ * See [FormFieldGroup](FormFieldGroup) for details.
120
+ **/
121
+ layout?: 'stacked' | 'columns' | 'inline';
122
+ /**
123
+ * Controls the spacing between the inputs when they are in a vertical layout.
124
+ **/
125
+ rowSpacing?: 'none' | 'small' | 'medium' | 'large';
126
+ /**
127
+ * Controls the spacing between the inputs when they are in a horizontal layout.
128
+ **/
129
+ colSpacing?: 'none' | 'small' | 'medium' | 'large';
130
+ /**
131
+ * An ISO 8601 formatted date string representing the current date-time
132
+ * (must be accompanied by an onChange prop).
133
+ **/
134
+ value?: string;
135
+ /**
136
+ * An ISO 8601 formatted date string to use if `value` isn't provided.
137
+ **/
138
+ defaultValue?: string;
139
+ /**
140
+ * If set, years can be picked from a dropdown in the calendar.
141
+ * screenReaderLabel: string // e.g.: i18n("pick a year")
142
+ * onRequestYearChange?: (e: React.SyntheticEvent, requestedYear: number) => void
143
+ * startYear: number // e.g.: 2001, sets the start year of the selectable list
144
+ * endYear: number // e.g.: 2030, sets the end year of the selectable list
145
+ */
146
+ withYearPicker?: {
147
+ screenReaderLabel: string;
148
+ onRequestYearChange?: (e: SyntheticEvent, requestedYear: number) => void;
149
+ startYear: number;
150
+ endYear: number;
151
+ };
152
+ /**
153
+ * Specifies if the input is required (its passed down to the native DOM
154
+ * elements). If its `true` then an empty input will produce an error message
155
+ * (`invalidDateTimeMessage`)
156
+ */
157
+ isRequired?: boolean;
158
+ /**
159
+ * Specifies if interaction with the input is enabled, disabled, or readonly.
160
+ * When "disabled", the input changes visibly to indicate that it cannot
161
+ * receive user interactions. When "readonly" the input still cannot receive
162
+ * user interactions but it keeps the same styles as if it were enabled.
163
+ */
164
+ interaction?: InteractionType;
165
+ /**
166
+ * Called when the date-time value has changed.
167
+ * The passed in parameters are:
168
+ * - *event*: The triggering event (which may be from the underlying
169
+ * `DateInput` or `TimeSelect`)
170
+ * - *isoValue*: The new date value in ISO8601 format, undefined if its invalid
171
+ **/
172
+ onChange?: (event: SyntheticEvent, isoValue?: string) => void;
173
+ /**
174
+ * The HTML `input` element where the date is entered.
175
+ **/
176
+ dateInputRef?: (el: HTMLInputElement | null) => void;
177
+ /**
178
+ * The HTML `input` element where the time is entered.
179
+ **/
180
+ timeInputRef?: (el: HTMLInputElement | null) => void;
181
+ /**
182
+ * onBlur event handler for when focus leaves DateTimeInput.
183
+ * Does not fire when focus moves between DateInput and TimeSelect within the
184
+ * component
185
+ */
186
+ onBlur?: (e: SyntheticEvent) => void;
187
+ disabledDates?: string[] | ((isoDateToCheck: string) => boolean);
188
+ /**
189
+ * Error message shown to the user if they enter a date that is disabled.
190
+ * If not specified the component will show the `invalidDateTimeMessage`.
191
+ */
192
+ disabledDateTimeMessage?: string | ((rawDateValue: string) => string);
193
+ /**
194
+ * Whether to allow the user to enter non-step divisible values in the time
195
+ * input field. Note that even if this is set to false one can enter non-step
196
+ * divisible values programmatically. The user will need to enter the value
197
+ * exactly (except for lower/uppercase) as specified by the `timeFormat` prop
198
+ * for it to be accepted.
199
+ * Default is `undefined` which equals to `false`
200
+ */
201
+ allowNonStepInput?: boolean;
202
+ /**
203
+ * The default time to be prefilled if a day is selected. The time input has to be empty for this to be applied.
204
+ * An error is thrown if the time format is not HH:MM.
205
+ */
206
+ initialTimeForNewDate?: string;
207
+ /**
208
+ * Used for getting the internal reset function of DateTimeInput. If that
209
+ * function is called, the component will reset to its default inner state.
210
+ * The callback function will be called in componentDidMount
211
+ * NOTE: this won't call onChange, so you have to reset the value manually when calling reset
212
+ */
213
+ reset?: (reset: () => void) => void;
214
+ };
215
+ type DateTimeInputState = {
216
+ iso?: Moment;
217
+ dateInputText: string;
218
+ timeSelectValue?: string;
219
+ message?: FormMessage;
220
+ };
221
+ type PropKeys = keyof DateTimeInputProps;
222
+ type AllowedPropKeys = Readonly<Array<PropKeys>>;
223
+ declare const allowedProps: AllowedPropKeys;
224
+ export type { DateTimeInputProps, DateTimeInputState };
225
+ export { allowedProps };
226
+ //# sourceMappingURL=props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/DateTimeInput/v2/props.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAE3D,KAAK,kBAAkB,GAAG;IACxB;;QAEI;IACJ,WAAW,EAAE,KAAK,CAAC,SAAS,CAAA;IAC5B;;QAEI;IACJ,eAAe,EAAE,UAAU,CAAA;IAC3B;;OAEG;IACH,kBAAkB,EAAE;QAClB,YAAY,EAAE,MAAM,CAAA;QACpB,eAAe,EAAE,MAAM,CAAA;QACvB,eAAe,EAAE,MAAM,CAAA;QACvB,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAC1B,CAAA;IACD;;;QAGI;IACJ,eAAe,CAAC,EAAE,MAAM,CAAA;IAExB;;;QAGI;IACJ,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;;QAKI;IACJ,UAA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,CAAA;AACxC,KAAK,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEhD,QAAA,MAAM,YAAY,EAAE,eAgCnB,CAAA;AAED,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { DateTimeInput } from '../DateTimeInput/v2';
2
+ //# sourceMappingURL=b.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"b.d.ts","sourceRoot":"","sources":["../../src/exports/b.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA"}