@instructure/ui-date-time-input 11.6.0 → 11.6.1-pr-snapshot-1779894247159

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 CHANGED
@@ -3,6 +3,14 @@
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.6.1-pr-snapshot-1779894247159](https://github.com/instructure/instructure-ui/compare/v11.6.0...v11.6.1-pr-snapshot-1779894247159) (2026-05-27)
7
+
8
+ **Note:** Version bump only for package @instructure/ui-date-time-input
9
+
10
+
11
+
12
+
13
+
6
14
  # [11.6.0](https://github.com/instructure/instructure-ui/compare/v11.5.0...v11.6.0) (2026-02-18)
7
15
 
8
16
  **Note:** Version bump only for package @instructure/ui-date-time-input
@@ -1,9 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.allowedProps = void 0;
7
1
  /*
8
2
  * The MIT License (MIT)
9
3
  *
@@ -28,4 +22,16 @@ exports.allowedProps = void 0;
28
22
  * SOFTWARE.
29
23
  */
30
24
 
31
- const allowedProps = exports.allowedProps = ['description', 'dateRenderLabel', 'prevMonthLabel', 'nextMonthLabel', 'datePlaceholder', 'timePlaceholder', 'dateFormat', 'interaction', 'timeRenderLabel', 'timeStep', 'timeFormat', 'locale', 'timezone', 'invalidDateTimeMessage', 'showMessages', 'messages', 'messageFormat', 'layout', 'rowSpacing', 'colSpacing', 'value', 'defaultValue', 'renderWeekdayLabels', 'isRequired', 'onChange', 'dateInputRef', 'timeInputRef', 'onBlur', 'disabledDates', 'disabledDateTimeMessage', 'allowNonStepInput', 'reset'];
25
+ module.exports = {
26
+ presets: [
27
+ [
28
+ require('@instructure/ui-babel-preset'),
29
+ {
30
+ coverage: Boolean(process.env.COVERAGE),
31
+ esModules: Boolean(process.env.ES_MODULES),
32
+ removeConsole: process.env.NODE_ENV === 'production',
33
+ transformImports: Boolean(process.env.TRANSFORM_IMPORTS)
34
+ }
35
+ ]
36
+ ]
37
+ }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@instructure/ui-date-time-input",
3
- "version": "11.6.0",
3
+ "version": "11.6.1-pr-snapshot-1779894247159",
4
+ "type": "module",
4
5
  "description": "A UI component that allows to select date and time.",
5
6
  "author": "Instructure, Inc. Engineering and Product Design",
6
7
  "module": "./es/index.js",
7
- "main": "./lib/index.js",
8
8
  "types": "./types/index.d.ts",
9
9
  "repository": {
10
10
  "type": "git",
@@ -15,25 +15,25 @@
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
17
  "@babel/runtime": "^7.27.6",
18
- "@instructure/shared-types": "11.6.0",
19
- "@instructure/console": "11.6.0",
20
- "@instructure/ui-buttons": "11.6.0",
21
- "@instructure/ui-a11y-content": "11.6.0",
22
- "@instructure/ui-calendar": "11.6.0",
23
- "@instructure/ui-date-input": "11.6.0",
24
- "@instructure/ui-i18n": "11.6.0",
25
- "@instructure/ui-form-field": "11.6.0",
26
- "@instructure/ui-icons": "11.6.0",
27
- "@instructure/ui-time-select": "11.6.0",
28
- "@instructure/ui-utils": "11.6.0",
29
- "@instructure/ui-react-utils": "11.6.0"
18
+ "@instructure/console": "11.6.1-pr-snapshot-1779894247159",
19
+ "@instructure/ui-buttons": "11.6.1-pr-snapshot-1779894247159",
20
+ "@instructure/ui-calendar": "11.6.1-pr-snapshot-1779894247159",
21
+ "@instructure/ui-a11y-content": "11.6.1-pr-snapshot-1779894247159",
22
+ "@instructure/shared-types": "11.6.1-pr-snapshot-1779894247159",
23
+ "@instructure/ui-date-input": "11.6.1-pr-snapshot-1779894247159",
24
+ "@instructure/ui-form-field": "11.6.1-pr-snapshot-1779894247159",
25
+ "@instructure/ui-i18n": "11.6.1-pr-snapshot-1779894247159",
26
+ "@instructure/ui-icons": "11.6.1-pr-snapshot-1779894247159",
27
+ "@instructure/ui-time-select": "11.6.1-pr-snapshot-1779894247159",
28
+ "@instructure/ui-utils": "11.6.1-pr-snapshot-1779894247159",
29
+ "@instructure/ui-react-utils": "11.6.1-pr-snapshot-1779894247159"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@testing-library/jest-dom": "^6.6.3",
33
33
  "@testing-library/react": "15.0.7",
34
34
  "@testing-library/user-event": "^14.6.1",
35
35
  "vitest": "^3.2.2",
36
- "@instructure/ui-babel-preset": "11.6.0"
36
+ "@instructure/ui-babel-preset": "11.6.1-pr-snapshot-1779894247159"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "react": ">=18 <=19"
@@ -46,10 +46,8 @@
46
46
  ".": {
47
47
  "types": "./types/index.d.ts",
48
48
  "import": "./es/index.js",
49
- "require": "./lib/index.js",
50
49
  "default": "./es/index.js"
51
50
  },
52
- "./lib/*": "./lib/*",
53
51
  "./es/*": "./es/*",
54
52
  "./types/*": "./types/*",
55
53
  "./package.json": "./package.json",
@@ -59,7 +57,7 @@
59
57
  "lint": "ui-scripts lint",
60
58
  "lint:fix": "ui-scripts lint --fix",
61
59
  "clean": "ui-scripts clean",
62
- "build": "ui-scripts build --modules es,cjs",
60
+ "build": "ui-scripts build",
63
61
  "build:watch": "pnpm run ts:check -- --watch & ui-scripts build --watch",
64
62
  "build:types": "tsc -p tsconfig.build.json",
65
63
  "ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
@@ -1,551 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.DateTimeInput = void 0;
7
- var _react = require("react");
8
- var _Locale = require("@instructure/ui-i18n/lib/Locale.js");
9
- var _DateTime = require("@instructure/ui-i18n/lib/DateTime.js");
10
- var _ApplyLocaleContext = require("@instructure/ui-i18n/lib/ApplyLocale/ApplyLocaleContext.js");
11
- var _FormFieldGroup = require("@instructure/ui-form-field/lib/FormFieldGroup");
12
- var _DateInput = require("@instructure/ui-date-input/lib/DateInput");
13
- var _TimeSelect = require("@instructure/ui-time-select/lib/TimeSelect");
14
- var _Calendar = require("@instructure/ui-calendar/lib/Calendar");
15
- var _AccessibleContent = require("@instructure/ui-a11y-content/lib/AccessibleContent");
16
- var _IconButton = require("@instructure/ui-buttons/lib/IconButton");
17
- var _IconArrowOpenEndSolid = require("@instructure/ui-icons/lib/IconArrowOpenEndSolid.js");
18
- var _IconArrowOpenStartSolid = require("@instructure/ui-icons/lib/IconArrowOpenStartSolid.js");
19
- var _props = require("./props");
20
- var _console = require("@instructure/console");
21
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
22
- var _DateTimeInput, _IconArrowOpenStartSo, _IconArrowOpenEndSoli;
23
- /*
24
- * The MIT License (MIT)
25
- *
26
- * Copyright (c) 2018 - present Instructure, Inc.
27
- *
28
- * Permission is hereby granted, free of charge, to any person obtaining a copy
29
- * of this software and associated documentation files (the "Software"), to deal
30
- * in the Software without restriction, including without limitation the rights
31
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
32
- * copies of the Software, and to permit persons to whom the Software is
33
- * furnished to do so, subject to the following conditions:
34
- *
35
- * The above copyright notice and this permission notice shall be included in all
36
- * copies or substantial portions of the Software.
37
- *
38
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
39
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
40
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
41
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
42
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
43
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
44
- * SOFTWARE.
45
- */
46
- /**
47
- ---
48
- category: components
49
- ---
50
- **/
51
- class DateTimeInput extends _react.Component {
52
- constructor(props) {
53
- super(props);
54
- // State needs to be calculated because render could be called before
55
- // componentDidMount()
56
- this.ref = null;
57
- // This is used by Tooltip for positioning
58
- this.handleRef = el => {
59
- this.ref = el;
60
- };
61
- this.reset = () => this.setState(this.recalculateState());
62
- // Called when the user enters text into dateInput
63
- this.handleDateTextChange = (_event, date) => {
64
- const dateParsed = this.tryParseDate(date.value);
65
- this.setState({
66
- dateInputText: date.value,
67
- dateInputTextChanged: true,
68
- calendarSelectedDate: dateParsed ? dateParsed : void 0,
69
- renderedDate: dateParsed ? dateParsed.clone() : _DateTime.DateTime.now(this.locale(), this.timezone())
70
- });
71
- };
72
- // date is returned es a ISO string, like 2021-09-14T22:00:00.000Z
73
- this.handleDayClick = (event, {
74
- date
75
- }) => {
76
- const dateParsed = _DateTime.DateTime.parse(date, this.locale(), this.timezone());
77
- this.updateStateBasedOnDateInput(dateParsed, event);
78
- };
79
- this.handleHideCalendar = event => {
80
- // prevent event pooling https://reactjs.org/docs/legacy-event-pooling.html
81
- // Remove if React 16 is no longer supported
82
- event.persist();
83
- // timeout is needed here because handleDayClick could be called in the same
84
- // frame, and it updates calendarSelectedDate which is read in here.
85
- setTimeout(() => {
86
- if (event.key === 'Enter') {
87
- // user pressed enter, use the selected value in the calendar
88
- this.updateStateBasedOnDateInput(this.state.calendarSelectedDate, event);
89
- } else {
90
- // user clicked outside/tabbed away/pressed esc, try to use the value in dateInputText
91
- const dateParsed = this.tryParseDate(this.state.dateInputText);
92
- this.updateStateBasedOnDateInput(dateParsed, event);
93
- }
94
- this.setState({
95
- isShowingCalendar: false,
96
- dateInputTextChanged: false
97
- });
98
- }, 0);
99
- };
100
- this.updateStateBasedOnTimeSelect = (event, option) => {
101
- // this.state.iso is undefined if date is invalid or not set.
102
- // in this case recalculate with the dateInput's text which will result in
103
- // an empty valid date (if isRequired is false) or an invalid date.
104
- const newValue = this.state.iso ? option.value : this.state.dateInputText;
105
- const newState = this.recalculateState(newValue, true, false);
106
- this.changeStateIfNeeded(newState, event);
107
- this.setState({
108
- timeSelectValue: option.value
109
- });
110
- };
111
- this.changeStateIfNeeded = (newState, e) => {
112
- const dateStr = newState.dateInputText;
113
- if (this.props.isRequired && !newState.iso || dateStr && dateStr.length > 0 && !newState.iso) {
114
- const text = typeof this.props.invalidDateTimeMessage === 'function' ? this.props.invalidDateTimeMessage(dateStr ? dateStr : '') : this.props.invalidDateTimeMessage;
115
- // eslint-disable-next-line no-param-reassign
116
- newState.message = {
117
- text: text,
118
- type: 'newError'
119
- };
120
- }
121
- if (this.areDifferentDates(this.state.iso, newState.iso)) {
122
- if (typeof this.props.onChange === 'function') {
123
- var _newState$iso;
124
- const newDate = (_newState$iso = newState.iso) === null || _newState$iso === void 0 ? void 0 : _newState$iso.toISOString();
125
- // Timeout is needed here because users might change value in the
126
- // onChange event lister, which might not execute properly
127
- setTimeout(() => {
128
- var _this$props$onChange, _this$props;
129
- (_this$props$onChange = (_this$props = this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, e, newDate);
130
- }, 0);
131
- }
132
- }
133
- this.setState(newState);
134
- };
135
- this.areDifferentDates = (d1, d2) => {
136
- if (!d1 && !d2) {
137
- return false;
138
- }
139
- return !d1 || !d2 || !d1.isSame(d2);
140
- };
141
- this.handleBlur = e => {
142
- // when TABbing from the DateInput to TimeInput or visa-versa, the blur
143
- // happens on the target before the relatedTarget gets focus.
144
- // The timeout gives it a moment for that to happen
145
- if (typeof this.props.onBlur === 'function') {
146
- setTimeout(() => {
147
- var _this$props$onBlur, _this$props2;
148
- (_this$props$onBlur = (_this$props2 = this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props2, e);
149
- }, 0);
150
- }
151
- };
152
- this.handleShowCalendar = _event => {
153
- this.setState({
154
- isShowingCalendar: true
155
- });
156
- };
157
- this.handleSelectNextDay = _event => {
158
- let toAlter;
159
- if (this.state.calendarSelectedDate) {
160
- toAlter = this.state.calendarSelectedDate.clone();
161
- } else if (this.state.iso) {
162
- toAlter = this.state.iso.clone();
163
- } else {
164
- toAlter = _DateTime.DateTime.now(this.locale(), this.timezone());
165
- }
166
- toAlter.add({
167
- days: 1
168
- });
169
- this.setState({
170
- calendarSelectedDate: toAlter,
171
- renderedDate: toAlter.clone()
172
- });
173
- };
174
- this.handleSelectPrevDay = _event => {
175
- let toAlter;
176
- if (this.state.calendarSelectedDate) {
177
- toAlter = this.state.calendarSelectedDate.clone();
178
- } else if (this.state.iso) {
179
- toAlter = this.state.iso.clone();
180
- } else {
181
- toAlter = _DateTime.DateTime.now(this.locale(), this.timezone());
182
- }
183
- toAlter.subtract({
184
- days: 1
185
- });
186
- this.setState({
187
- calendarSelectedDate: toAlter,
188
- renderedDate: toAlter.clone()
189
- });
190
- };
191
- this.handleRenderNextMonth = _event => {
192
- this.setState({
193
- renderedDate: this.state.renderedDate.clone().add({
194
- months: 1
195
- })
196
- });
197
- };
198
- this.handleRenderPrevMonth = _event => {
199
- this.setState({
200
- renderedDate: this.state.renderedDate.clone().subtract({
201
- months: 1
202
- })
203
- });
204
- };
205
- this.state = this.recalculateState(props.value || props.defaultValue);
206
- }
207
- componentDidMount() {
208
- var _this$props$reset, _this$props3;
209
- // we'll need to recalculate the state because the context value is
210
- // set at this point (and it might change locale & timezone)
211
- const initState = this.recalculateState(this.props.value || this.props.defaultValue);
212
- this.setState(initState);
213
- (_this$props$reset = (_this$props3 = this.props).reset) === null || _this$props$reset === void 0 ? void 0 : _this$props$reset.call(_this$props3, this.reset);
214
- }
215
- componentDidUpdate(prevProps) {
216
- const valueChanged = prevProps.value !== this.props.value || prevProps.defaultValue !== this.props.defaultValue;
217
- const isUpdated = valueChanged || prevProps.locale !== this.props.locale || prevProps.timezone !== this.props.timezone || prevProps.dateFormat !== this.props.dateFormat || prevProps.messageFormat !== this.props.messageFormat || prevProps.invalidDateTimeMessage !== this.props.invalidDateTimeMessage;
218
- if (isUpdated) {
219
- this.setState(_prevState => {
220
- return {
221
- ...this.recalculateState(this.props.value || this.props.defaultValue)
222
- };
223
- });
224
- }
225
- }
226
- recalculateState(dateStr, doNotChangeDate = false, doNotChangeTime = false) {
227
- let errorMsg;
228
- if (dateStr) {
229
- const parsed = _DateTime.DateTime.parse(dateStr, this.locale(), this.timezone());
230
- if (parsed.isValid()) {
231
- var _this$state;
232
- if (doNotChangeTime && this.state.timeSelectValue) {
233
- // There is a selected time, adjust the parsed date to its value
234
- const timeParsed = _DateTime.DateTime.parse(this.state.timeSelectValue, this.locale(), this.timezone());
235
- parsed.hour(timeParsed.hour()).minute(timeParsed.minute());
236
- }
237
- if (doNotChangeDate && this.state.iso) {
238
- parsed.date(this.state.iso.date()).month(this.state.iso.month()).year(this.state.iso.year());
239
- }
240
- if (this.props.initialTimeForNewDate && !((_this$state = this.state) !== null && _this$state !== void 0 && _this$state.timeSelectValue)) {
241
- const hour = Number(this.props.initialTimeForNewDate.slice(0, 2));
242
- const minute = Number(this.props.initialTimeForNewDate.slice(3, 5));
243
- if (isNaN(hour) || isNaN(minute)) {
244
- (0, _console.error)(false, `[DateTimeInput] initialTimeForNewDate prop is not in the correct format. Please use HH:MM format.`);
245
- } else if (hour < 0 || hour > 23 || minute > 59 || minute < 0) {
246
- (0, _console.error)(false, `[DateTimeInput] 0 <= hour < 24 and 0 <= minute < 60 for initialTimeForNewDate prop.`);
247
- } else {
248
- parsed.hour(hour).minute(minute);
249
- }
250
- }
251
- const newTimeSelectValue = parsed.toISOString();
252
- if (this.isDisabledDate(parsed)) {
253
- let text = typeof this.props.disabledDateTimeMessage === 'function' ? this.props.disabledDateTimeMessage(parsed.toISOString(true)) : this.props.disabledDateTimeMessage;
254
- if (!text) {
255
- text = typeof this.props.invalidDateTimeMessage === 'function' ? this.props.invalidDateTimeMessage(parsed.toISOString(true)) : this.props.invalidDateTimeMessage;
256
- }
257
- errorMsg = text ? {
258
- text,
259
- type: 'newError'
260
- } : void 0;
261
- return {
262
- iso: parsed.clone(),
263
- calendarSelectedDate: parsed.clone(),
264
- dateInputTextChanged: false,
265
- dateInputText: parsed.format(this.dateFormat),
266
- message: errorMsg,
267
- timeSelectValue: newTimeSelectValue,
268
- renderedDate: parsed.clone()
269
- };
270
- }
271
- return {
272
- iso: parsed.clone(),
273
- calendarSelectedDate: parsed.clone(),
274
- dateInputTextChanged: false,
275
- dateInputText: parsed.format(this.dateFormat),
276
- message: {
277
- type: 'success',
278
- text: parsed.format(this.props.messageFormat)
279
- },
280
- timeSelectValue: newTimeSelectValue,
281
- renderedDate: parsed.clone()
282
- };
283
- }
284
- }
285
- // if there is no date string clear TimeSelect value
286
- const clearTimeSelect = dateStr ? {} : {
287
- timeSelectValue: '',
288
- message: void 0
289
- };
290
- return {
291
- iso: void 0,
292
- calendarSelectedDate: void 0,
293
- dateInputText: dateStr ? dateStr : '',
294
- renderedDate: _DateTime.DateTime.now(this.locale(), this.timezone()),
295
- dateInputTextChanged: false,
296
- ...clearTimeSelect
297
- };
298
- }
299
- locale() {
300
- if (this.props.locale) {
301
- return this.props.locale;
302
- } else if (this.context && this.context.locale) {
303
- return this.context.locale;
304
- }
305
- return _Locale.Locale.browserLocale();
306
- }
307
- timezone() {
308
- if (this.props.timezone) {
309
- return this.props.timezone;
310
- } else if (this.context && this.context.timezone) {
311
- return this.context.timezone;
312
- }
313
- return _DateTime.DateTime.browserTimeZone();
314
- }
315
- get dateFormat() {
316
- return this.props.dateFormat;
317
- }
318
- isDisabledDate(date) {
319
- const disabledDates = this.props.disabledDates;
320
- if (!disabledDates) {
321
- return false;
322
- }
323
- if (Array.isArray(disabledDates)) {
324
- for (const aDisabledDate of disabledDates) {
325
- if (date.isSame(aDisabledDate, 'day')) {
326
- return true;
327
- }
328
- }
329
- return false;
330
- }
331
- return disabledDates(date.toISOString());
332
- }
333
- tryParseDate(val) {
334
- const parsed = _DateTime.DateTime.parse(val, this.locale(), this.timezone());
335
- return parsed.isValid() ? parsed : null;
336
- }
337
- updateStateBasedOnDateInput(dateParsed, event) {
338
- let newState;
339
- if (dateParsed && this.state.timeSelectValue && (!this.state.dateInputText || this.state.dateInputText == '')) {
340
- // There is already a selected time, but no date. Adjust the time too
341
- const timeParsed = _DateTime.DateTime.parse(this.state.timeSelectValue, this.locale(), this.timezone());
342
- const dateParsedAdjusted = dateParsed.set({
343
- hour: timeParsed.hour(),
344
- minute: timeParsed.minute()
345
- });
346
- newState = this.recalculateState(dateParsedAdjusted.toISOString(), false, false);
347
- } else if (!dateParsed) {
348
- // if the text in the dateInput is not readable display error
349
- newState = this.recalculateState(this.state.dateInputText, false, true);
350
- } else {
351
- newState = this.recalculateState(dateParsed === null || dateParsed === void 0 ? void 0 : dateParsed.toISOString(), false, true);
352
- }
353
- this.changeStateIfNeeded(newState, event);
354
- }
355
- renderDays() {
356
- const renderedDate = this.state.renderedDate;
357
- // Sets it to the first local day of the week counting back from the start of the month.
358
- // Note that first day depends on the locale, e.g. it's Sunday in the US and
359
- // Monday in most of the EU.
360
- const currDate = _DateTime.DateTime.getFirstDayOfWeek(renderedDate.startOf('month'));
361
- const arr = [];
362
- for (let i = 0; i < _Calendar.Calendar.DAY_COUNT; i++) {
363
- // This workaround is needed because moment's `.add({days: 1})` function has a bug that happens when the date added lands perfectly onto the DST cutoff,
364
- // in these cases adding 1 day results in 23 hours added instead,
365
- // so `moment.tz('2024-09-07T00:00:00', 'America/Santiago').add({days: 1})` results
366
- // in "Sat Sep 07 2024 23:00:00 GMT-0400" instead of "Sun Sep 08 2024 00:00:00 GMT-0400".
367
- // which would cause duplicate dates in the calendar.
368
- // More info on the bug: https://github.com/moment/moment/issues/4743
369
- // Please note that this causes one hour of time difference in the affected timezones/dates and to
370
- // fully solve this bug we need to change to something like luxon which handles this properly
371
- if (currDate.clone().format('HH') === '23') {
372
- arr.push(currDate.clone().add({
373
- hours: 1
374
- }));
375
- } else {
376
- arr.push(currDate.clone());
377
- }
378
- currDate.add({
379
- days: 1
380
- });
381
- }
382
- return arr.map(date => {
383
- const dateStr = date.toISOString();
384
- return (0, _jsxRuntime.jsx)(_DateInput.DateInput.Day, {
385
- date: dateStr,
386
- isSelected: this.state.calendarSelectedDate ? date.isSame(this.state.calendarSelectedDate, 'day') : false,
387
- isToday: date.isSame(_DateTime.DateTime.now(this.locale(), this.timezone()), 'day'),
388
- isOutsideMonth: !date.isSame(renderedDate, 'month'),
389
- label: date.format('D MMMM YYYY') // used by screen readers
390
- ,
391
- onClick: this.handleDayClick,
392
- interaction: this.isDisabledDate(date) ? 'disabled' : 'enabled',
393
- children: date.format('DD')
394
- }, dateStr);
395
- });
396
- }
397
-
398
- // The default weekdays rendered in the calendar
399
- get defaultWeekdays() {
400
- if (!this.state.isShowingCalendar) {
401
- // this is an expensive function, only execute if the calendar is open
402
- return [];
403
- }
404
- const shortDayNames = _DateTime.DateTime.getLocalDayNamesOfTheWeek(this.locale(), 'short');
405
- const longDayNames = _DateTime.DateTime.getLocalDayNamesOfTheWeek(this.locale(), 'long');
406
- return [(0, _jsxRuntime.jsx)(_AccessibleContent.AccessibleContent, {
407
- alt: longDayNames[0],
408
- children: shortDayNames[0]
409
- }, 1), (0, _jsxRuntime.jsx)(_AccessibleContent.AccessibleContent, {
410
- alt: longDayNames[1],
411
- children: shortDayNames[1]
412
- }, 2), (0, _jsxRuntime.jsx)(_AccessibleContent.AccessibleContent, {
413
- alt: longDayNames[2],
414
- children: shortDayNames[2]
415
- }, 3), (0, _jsxRuntime.jsx)(_AccessibleContent.AccessibleContent, {
416
- alt: longDayNames[3],
417
- children: shortDayNames[3]
418
- }, 4), (0, _jsxRuntime.jsx)(_AccessibleContent.AccessibleContent, {
419
- alt: longDayNames[4],
420
- children: shortDayNames[4]
421
- }, 5), (0, _jsxRuntime.jsx)(_AccessibleContent.AccessibleContent, {
422
- alt: longDayNames[5],
423
- children: shortDayNames[5]
424
- }, 6), (0, _jsxRuntime.jsx)(_AccessibleContent.AccessibleContent, {
425
- alt: longDayNames[6],
426
- children: shortDayNames[6]
427
- }, 7)];
428
- }
429
- renderNextPrevMonthButton(type) {
430
- if (!this.state.isShowingCalendar) {
431
- return;
432
- }
433
- return (0, _jsxRuntime.jsx)(_IconButton.IconButton, {
434
- size: "small",
435
- withBackground: false,
436
- withBorder: false,
437
- renderIcon: type === 'prev' ? _IconArrowOpenStartSo || (_IconArrowOpenStartSo = (0, _jsxRuntime.jsx)(_IconArrowOpenStartSolid.IconArrowOpenStartSolid, {
438
- color: "primary"
439
- })) : _IconArrowOpenEndSoli || (_IconArrowOpenEndSoli = (0, _jsxRuntime.jsx)(_IconArrowOpenEndSolid.IconArrowOpenEndSolid, {
440
- color: "primary"
441
- })),
442
- screenReaderLabel: type === 'prev' ? this.props.prevMonthLabel : this.props.nextMonthLabel
443
- });
444
- }
445
- render() {
446
- const _this$props4 = this.props,
447
- description = _this$props4.description,
448
- datePlaceholder = _this$props4.datePlaceholder,
449
- timePlaceholder = _this$props4.timePlaceholder,
450
- dateRenderLabel = _this$props4.dateRenderLabel,
451
- dateInputRef = _this$props4.dateInputRef,
452
- timeRenderLabel = _this$props4.timeRenderLabel,
453
- timeFormat = _this$props4.timeFormat,
454
- timeStep = _this$props4.timeStep,
455
- timeInputRef = _this$props4.timeInputRef,
456
- locale = _this$props4.locale,
457
- timezone = _this$props4.timezone,
458
- showMessages = _this$props4.showMessages,
459
- messages = _this$props4.messages,
460
- layout = _this$props4.layout,
461
- rowSpacing = _this$props4.rowSpacing,
462
- colSpacing = _this$props4.colSpacing,
463
- isRequired = _this$props4.isRequired,
464
- interaction = _this$props4.interaction,
465
- renderWeekdayLabels = _this$props4.renderWeekdayLabels,
466
- allowNonStepInput = _this$props4.allowNonStepInput;
467
- const allMessages = [...(showMessages && this.state.message ? [this.state.message] : []), ...(messages || [])];
468
- const hasError = allMessages.find(m => m.type === 'newError');
469
- // if the component is in error state, create an empty error message to pass down to the subcomponents (DateInput and TimeInput) so they get a red outline and red required asterisk
470
- const subComponentMessages = hasError ? [{
471
- type: 'newError',
472
- text: ''
473
- }] : [];
474
- return (0, _jsxRuntime.jsxs)(_FormFieldGroup.FormFieldGroup, {
475
- description: description,
476
- layout: layout,
477
- rowSpacing: rowSpacing,
478
- colSpacing: colSpacing,
479
- vAlign: "top",
480
- elementRef: this.handleRef,
481
- isGroup: false,
482
- messages: [...(showMessages && this.state.message ? [this.state.message] : []), ...(messages || [])],
483
- "data-cid": "DateTimeInput",
484
- children: [(0, _jsxRuntime.jsx)(_DateInput.DateInput, {
485
- display: "block",
486
- value: this.state.dateInputText,
487
- onChange: this.handleDateTextChange,
488
- onBlur: this.handleBlur,
489
- inputRef: dateInputRef,
490
- placeholder: datePlaceholder,
491
- renderLabel: dateRenderLabel,
492
- renderWeekdayLabels: renderWeekdayLabels ? renderWeekdayLabels : this.defaultWeekdays,
493
- onRequestShowCalendar: this.handleShowCalendar,
494
- onRequestHideCalendar: this.handleHideCalendar,
495
- isShowingCalendar: this.state.isShowingCalendar,
496
- renderNextMonthButton: this.renderNextPrevMonthButton('next'),
497
- renderPrevMonthButton: this.renderNextPrevMonthButton('prev'),
498
- onRequestSelectNextDay: this.handleSelectNextDay,
499
- onRequestSelectPrevDay: this.handleSelectPrevDay,
500
- onRequestRenderNextMonth: this.handleRenderNextMonth,
501
- onRequestRenderPrevMonth: this.handleRenderPrevMonth,
502
- isRequired: isRequired,
503
- messages: subComponentMessages,
504
- interaction: interaction,
505
- renderNavigationLabel: (0, _jsxRuntime.jsxs)("span", {
506
- children: [(0, _jsxRuntime.jsx)("div", {
507
- children: this.state.renderedDate.format('MMMM')
508
- }), (0, _jsxRuntime.jsx)("div", {
509
- children: this.state.renderedDate.format('y')
510
- })]
511
- }),
512
- children: this.renderDays()
513
- }), (0, _jsxRuntime.jsx)(_TimeSelect.TimeSelect, {
514
- value: this.state.timeSelectValue,
515
- onChange: this.updateStateBasedOnTimeSelect,
516
- placeholder: timePlaceholder,
517
- onBlur: this.handleBlur,
518
- renderLabel: timeRenderLabel,
519
- locale: locale,
520
- format: timeFormat,
521
- step: timeStep,
522
- timezone: timezone,
523
- inputRef: timeInputRef,
524
- interaction: interaction,
525
- allowNonStepInput: allowNonStepInput,
526
- isRequired: isRequired,
527
- messages: subComponentMessages
528
- })]
529
- });
530
- }
531
- }
532
- exports.DateTimeInput = DateTimeInput;
533
- _DateTimeInput = DateTimeInput;
534
- DateTimeInput.displayName = "DateTimeInput";
535
- // extra verbose localized date and time
536
- DateTimeInput.DEFAULT_MESSAGE_FORMAT = 'LLLL';
537
- DateTimeInput.allowedProps = _props.allowedProps;
538
- DateTimeInput.defaultProps = {
539
- layout: 'inline',
540
- colSpacing: 'medium',
541
- rowSpacing: 'small',
542
- timeStep: 30,
543
- showMessages: true,
544
- messageFormat: _DateTimeInput.DEFAULT_MESSAGE_FORMAT,
545
- isRequired: false,
546
- dateFormat: 'LL',
547
- // Localized date with full month, e.g. "August 6, 2014"
548
- allowNonStepInput: false
549
- };
550
- DateTimeInput.contextType = _ApplyLocaleContext.ApplyLocaleContext;
551
- var _default = exports.default = DateTimeInput;
package/lib/index.js DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "DateTimeInput", {
7
- enumerable: true,
8
- get: function () {
9
- return _DateTimeInput.DateTimeInput;
10
- }
11
- });
12
- var _DateTimeInput = require("./DateTimeInput");
package/lib/package.json DELETED
@@ -1 +0,0 @@
1
- {"type":"commonjs"}