@instructure/ui-date-time-input 10.26.1-snapshot-2 → 10.26.1
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 +2 -23
- package/es/DateTimeInput/index.js +6 -13
- package/es/DateTimeInput/props.js +49 -1
- package/lib/DateTimeInput/index.js +5 -13
- package/lib/DateTimeInput/props.js +50 -1
- package/package.json +19 -16
- package/src/DateTimeInput/index.tsx +4 -2
- package/src/DateTimeInput/props.ts +75 -2
- package/tsconfig.build.json +2 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/DateTimeInput/index.d.ts +1 -0
- package/types/DateTimeInput/index.d.ts.map +1 -1
- package/types/DateTimeInput/props.d.ts +3 -2
- package/types/DateTimeInput/props.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,30 +3,9 @@
|
|
|
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
|
-
## [10.26.1
|
|
6
|
+
## [10.26.1](https://github.com/instructure/instructure-ui/compare/v10.26.0...v10.26.1) (2025-10-06)
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
### Features
|
|
10
|
-
|
|
11
|
-
* **many:** instUI v11 release ([36f5438](https://github.com/instructure/instructure-ui/commit/36f54382669186227ba24798bbf7201ef2f5cd4c))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
### BREAKING CHANGES
|
|
15
|
-
|
|
16
|
-
* **many:** InstUI v11 contains the following breaking changes:
|
|
17
|
-
- React 16 and 17 are no longer supported
|
|
18
|
-
- remove `PropTypes` from all packages
|
|
19
|
-
- remove `CodeEditor` component
|
|
20
|
-
- remove `@instui/theme-registry` package
|
|
21
|
-
- remove `@testable`, `@experimental`, `@hack` decorators
|
|
22
|
-
- InstUISettingsProvider's `as` prop is removed
|
|
23
|
-
- `canvas.use()`, `canvasHighContrast.use()` functions are removed
|
|
24
|
-
- `canvasThemeLocal`, `canvasHighContrastThemeLocal` are removed
|
|
25
|
-
- `variables` field on theme objects are removed
|
|
26
|
-
- remove deprecated props from Table: Row's `isStacked`, Body's
|
|
27
|
-
`isStacked`, `hover`, and `headers`
|
|
28
|
-
- `Table`'s `caption` prop is now required
|
|
29
|
-
- `ui-dom-utils`'s `getComputedStyle` can now return `undefined`
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-date-time-input
|
|
30
9
|
|
|
31
10
|
|
|
32
11
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _DateTimeInput, _IconArrowOpenStartSo, _IconArrowOpenEndSoli;
|
|
1
|
+
var _dec, _class, _DateTimeInput, _IconArrowOpenStartSo, _IconArrowOpenEndSoli;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -29,10 +29,11 @@ import { FormFieldGroup } from '@instructure/ui-form-field';
|
|
|
29
29
|
import { DateInput } from '@instructure/ui-date-input';
|
|
30
30
|
import { TimeSelect } from '@instructure/ui-time-select';
|
|
31
31
|
import { Calendar } from '@instructure/ui-calendar';
|
|
32
|
+
import { testable } from '@instructure/ui-testable';
|
|
32
33
|
import { AccessibleContent } from '@instructure/ui-a11y-content';
|
|
33
34
|
import { IconButton } from '@instructure/ui-buttons';
|
|
34
35
|
import { IconArrowOpenEndSolid, IconArrowOpenStartSolid } from '@instructure/ui-icons';
|
|
35
|
-
import { allowedProps } from './props';
|
|
36
|
+
import { propTypes, allowedProps } from './props';
|
|
36
37
|
import { error } from '@instructure/console';
|
|
37
38
|
|
|
38
39
|
/**
|
|
@@ -41,7 +42,7 @@ category: components
|
|
|
41
42
|
---
|
|
42
43
|
**/
|
|
43
44
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
44
|
-
class DateTimeInput extends Component {
|
|
45
|
+
let DateTimeInput = (_dec = testable(), _dec(_class = (_DateTimeInput = class DateTimeInput extends Component {
|
|
45
46
|
constructor(props) {
|
|
46
47
|
super(props);
|
|
47
48
|
// State needs to be calculated because render could be called before
|
|
@@ -473,7 +474,6 @@ class DateTimeInput extends Component {
|
|
|
473
474
|
elementRef: this.handleRef,
|
|
474
475
|
isGroup: false,
|
|
475
476
|
messages: [...(showMessages && this.state.message ? [this.state.message] : []), ...(messages || [])],
|
|
476
|
-
"data-cid": "DateTimeInput",
|
|
477
477
|
children: [_jsx(DateInput, {
|
|
478
478
|
display: "block",
|
|
479
479
|
value: this.state.dateInputText,
|
|
@@ -521,13 +521,7 @@ class DateTimeInput extends Component {
|
|
|
521
521
|
})]
|
|
522
522
|
});
|
|
523
523
|
}
|
|
524
|
-
}
|
|
525
|
-
_DateTimeInput = DateTimeInput;
|
|
526
|
-
DateTimeInput.displayName = "DateTimeInput";
|
|
527
|
-
// extra verbose localized date and time
|
|
528
|
-
DateTimeInput.DEFAULT_MESSAGE_FORMAT = 'LLLL';
|
|
529
|
-
DateTimeInput.allowedProps = allowedProps;
|
|
530
|
-
DateTimeInput.defaultProps = {
|
|
524
|
+
}, _DateTimeInput.displayName = "DateTimeInput", _DateTimeInput.DEFAULT_MESSAGE_FORMAT = 'LLLL', _DateTimeInput.propTypes = propTypes, _DateTimeInput.allowedProps = allowedProps, _DateTimeInput.defaultProps = {
|
|
531
525
|
layout: 'inline',
|
|
532
526
|
colSpacing: 'medium',
|
|
533
527
|
rowSpacing: 'small',
|
|
@@ -538,7 +532,6 @@ DateTimeInput.defaultProps = {
|
|
|
538
532
|
dateFormat: 'LL',
|
|
539
533
|
// Localized date with full month, e.g. "August 6, 2014"
|
|
540
534
|
allowNonStepInput: false
|
|
541
|
-
};
|
|
542
|
-
DateTimeInput.contextType = ApplyLocaleContext;
|
|
535
|
+
}, _DateTimeInput.contextType = ApplyLocaleContext, _DateTimeInput)) || _class);
|
|
543
536
|
export default DateTimeInput;
|
|
544
537
|
export { DateTimeInput };
|
|
@@ -22,5 +22,53 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
import { FormPropTypes } from '@instructure/ui-form-field';
|
|
26
|
+
import { I18nPropTypes } from '@instructure/ui-i18n';
|
|
27
|
+
import PropTypes from 'prop-types';
|
|
28
|
+
import { controllable } from '@instructure/ui-prop-types';
|
|
29
|
+
const hourMinuteValidator = function (props, propName, componentName, location) {
|
|
30
|
+
const propValue = props[propName];
|
|
31
|
+
if (typeof propValue === 'undefined' || propValue === '') return null;
|
|
32
|
+
const hourMinuteRegex = /^\d{2}:\d{2}$/;
|
|
33
|
+
if (typeof propValue === 'string' && !propValue.match(hourMinuteRegex)) {
|
|
34
|
+
return new Error(`Invalid ${location} \`${propName}\` \`${propValue}\` supplied to \`${componentName}\`, expected ` + `a HH:MM formatted string.`);
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
};
|
|
38
|
+
const propTypes = {
|
|
39
|
+
description: PropTypes.node.isRequired,
|
|
40
|
+
dateRenderLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.node]).isRequired,
|
|
41
|
+
prevMonthLabel: PropTypes.string.isRequired,
|
|
42
|
+
nextMonthLabel: PropTypes.string.isRequired,
|
|
43
|
+
datePlaceholder: PropTypes.string,
|
|
44
|
+
timePlaceholder: PropTypes.string,
|
|
45
|
+
dateFormat: PropTypes.string,
|
|
46
|
+
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
47
|
+
timeRenderLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.node]).isRequired,
|
|
48
|
+
timeStep: PropTypes.oneOf([5, 10, 15, 20, 30, 60]),
|
|
49
|
+
timeFormat: PropTypes.string,
|
|
50
|
+
locale: PropTypes.string,
|
|
51
|
+
timezone: PropTypes.string,
|
|
52
|
+
invalidDateTimeMessage: PropTypes.oneOfType([PropTypes.string, PropTypes.func]).isRequired,
|
|
53
|
+
showMessages: PropTypes.bool,
|
|
54
|
+
messages: PropTypes.arrayOf(FormPropTypes.message),
|
|
55
|
+
messageFormat: PropTypes.string,
|
|
56
|
+
layout: PropTypes.oneOf(['stacked', 'columns', 'inline']),
|
|
57
|
+
rowSpacing: PropTypes.oneOf(['none', 'small', 'medium', 'large']),
|
|
58
|
+
colSpacing: PropTypes.oneOf(['none', 'small', 'medium', 'large']),
|
|
59
|
+
value: controllable(I18nPropTypes.iso8601, 'onChange'),
|
|
60
|
+
defaultValue: I18nPropTypes.iso8601,
|
|
61
|
+
renderWeekdayLabels: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.node])),
|
|
62
|
+
isRequired: PropTypes.bool,
|
|
63
|
+
onChange: PropTypes.func,
|
|
64
|
+
dateInputRef: PropTypes.func,
|
|
65
|
+
timeInputRef: PropTypes.func,
|
|
66
|
+
onBlur: PropTypes.func,
|
|
67
|
+
disabledDates: PropTypes.oneOfType([PropTypes.func, PropTypes.arrayOf(PropTypes.string)]),
|
|
68
|
+
disabledDateTimeMessage: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
|
69
|
+
allowNonStepInput: PropTypes.bool,
|
|
70
|
+
reset: PropTypes.func,
|
|
71
|
+
initialTimeForNewDate: hourMinuteValidator
|
|
72
|
+
};
|
|
25
73
|
const 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'];
|
|
26
|
-
export { allowedProps };
|
|
74
|
+
export { propTypes, allowedProps };
|
|
@@ -12,6 +12,7 @@ var _FormFieldGroup = require("@instructure/ui-form-field/lib/FormFieldGroup");
|
|
|
12
12
|
var _DateInput = require("@instructure/ui-date-input/lib/DateInput");
|
|
13
13
|
var _TimeSelect = require("@instructure/ui-time-select/lib/TimeSelect");
|
|
14
14
|
var _Calendar = require("@instructure/ui-calendar/lib/Calendar");
|
|
15
|
+
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
15
16
|
var _AccessibleContent = require("@instructure/ui-a11y-content/lib/AccessibleContent");
|
|
16
17
|
var _IconButton = require("@instructure/ui-buttons/lib/IconButton");
|
|
17
18
|
var _IconArrowOpenEndSolid = require("@instructure/ui-icons/lib/IconArrowOpenEndSolid.js");
|
|
@@ -19,7 +20,7 @@ var _IconArrowOpenStartSolid = require("@instructure/ui-icons/lib/IconArrowOpenS
|
|
|
19
20
|
var _props = require("./props");
|
|
20
21
|
var _console = require("@instructure/console");
|
|
21
22
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
22
|
-
var _DateTimeInput, _IconArrowOpenStartSo, _IconArrowOpenEndSoli;
|
|
23
|
+
var _dec, _class, _DateTimeInput, _IconArrowOpenStartSo, _IconArrowOpenEndSoli;
|
|
23
24
|
/*
|
|
24
25
|
* The MIT License (MIT)
|
|
25
26
|
*
|
|
@@ -48,7 +49,7 @@ var _DateTimeInput, _IconArrowOpenStartSo, _IconArrowOpenEndSoli;
|
|
|
48
49
|
category: components
|
|
49
50
|
---
|
|
50
51
|
**/
|
|
51
|
-
class DateTimeInput extends _react.Component {
|
|
52
|
+
let DateTimeInput = exports.DateTimeInput = (_dec = (0, _testable.testable)(), _dec(_class = (_DateTimeInput = class DateTimeInput extends _react.Component {
|
|
52
53
|
constructor(props) {
|
|
53
54
|
super(props);
|
|
54
55
|
// State needs to be calculated because render could be called before
|
|
@@ -480,7 +481,6 @@ class DateTimeInput extends _react.Component {
|
|
|
480
481
|
elementRef: this.handleRef,
|
|
481
482
|
isGroup: false,
|
|
482
483
|
messages: [...(showMessages && this.state.message ? [this.state.message] : []), ...(messages || [])],
|
|
483
|
-
"data-cid": "DateTimeInput",
|
|
484
484
|
children: [(0, _jsxRuntime.jsx)(_DateInput.DateInput, {
|
|
485
485
|
display: "block",
|
|
486
486
|
value: this.state.dateInputText,
|
|
@@ -528,14 +528,7 @@ class DateTimeInput extends _react.Component {
|
|
|
528
528
|
})]
|
|
529
529
|
});
|
|
530
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 = {
|
|
531
|
+
}, _DateTimeInput.displayName = "DateTimeInput", _DateTimeInput.DEFAULT_MESSAGE_FORMAT = 'LLLL', _DateTimeInput.propTypes = _props.propTypes, _DateTimeInput.allowedProps = _props.allowedProps, _DateTimeInput.defaultProps = {
|
|
539
532
|
layout: 'inline',
|
|
540
533
|
colSpacing: 'medium',
|
|
541
534
|
rowSpacing: 'small',
|
|
@@ -546,6 +539,5 @@ DateTimeInput.defaultProps = {
|
|
|
546
539
|
dateFormat: 'LL',
|
|
547
540
|
// Localized date with full month, e.g. "August 6, 2014"
|
|
548
541
|
allowNonStepInput: false
|
|
549
|
-
};
|
|
550
|
-
DateTimeInput.contextType = _ApplyLocaleContext.ApplyLocaleContext;
|
|
542
|
+
}, _DateTimeInput.contextType = _ApplyLocaleContext.ApplyLocaleContext, _DateTimeInput)) || _class);
|
|
551
543
|
var _default = exports.default = DateTimeInput;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.allowedProps = void 0;
|
|
7
|
+
exports.propTypes = exports.allowedProps = void 0;
|
|
8
|
+
var _FormPropTypes = require("@instructure/ui-form-field/lib/FormPropTypes.js");
|
|
9
|
+
var _I18nPropTypes = require("@instructure/ui-i18n/lib/I18nPropTypes.js");
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
var _controllable = require("@instructure/ui-prop-types/lib/controllable.js");
|
|
7
12
|
/*
|
|
8
13
|
* The MIT License (MIT)
|
|
9
14
|
*
|
|
@@ -28,4 +33,48 @@ exports.allowedProps = void 0;
|
|
|
28
33
|
* SOFTWARE.
|
|
29
34
|
*/
|
|
30
35
|
|
|
36
|
+
const hourMinuteValidator = function (props, propName, componentName, location) {
|
|
37
|
+
const propValue = props[propName];
|
|
38
|
+
if (typeof propValue === 'undefined' || propValue === '') return null;
|
|
39
|
+
const hourMinuteRegex = /^\d{2}:\d{2}$/;
|
|
40
|
+
if (typeof propValue === 'string' && !propValue.match(hourMinuteRegex)) {
|
|
41
|
+
return new Error(`Invalid ${location} \`${propName}\` \`${propValue}\` supplied to \`${componentName}\`, expected ` + `a HH:MM formatted string.`);
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
};
|
|
45
|
+
const propTypes = exports.propTypes = {
|
|
46
|
+
description: _propTypes.default.node.isRequired,
|
|
47
|
+
dateRenderLabel: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]).isRequired,
|
|
48
|
+
prevMonthLabel: _propTypes.default.string.isRequired,
|
|
49
|
+
nextMonthLabel: _propTypes.default.string.isRequired,
|
|
50
|
+
datePlaceholder: _propTypes.default.string,
|
|
51
|
+
timePlaceholder: _propTypes.default.string,
|
|
52
|
+
dateFormat: _propTypes.default.string,
|
|
53
|
+
interaction: _propTypes.default.oneOf(['enabled', 'disabled', 'readonly']),
|
|
54
|
+
timeRenderLabel: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]).isRequired,
|
|
55
|
+
timeStep: _propTypes.default.oneOf([5, 10, 15, 20, 30, 60]),
|
|
56
|
+
timeFormat: _propTypes.default.string,
|
|
57
|
+
locale: _propTypes.default.string,
|
|
58
|
+
timezone: _propTypes.default.string,
|
|
59
|
+
invalidDateTimeMessage: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]).isRequired,
|
|
60
|
+
showMessages: _propTypes.default.bool,
|
|
61
|
+
messages: _propTypes.default.arrayOf(_FormPropTypes.FormPropTypes.message),
|
|
62
|
+
messageFormat: _propTypes.default.string,
|
|
63
|
+
layout: _propTypes.default.oneOf(['stacked', 'columns', 'inline']),
|
|
64
|
+
rowSpacing: _propTypes.default.oneOf(['none', 'small', 'medium', 'large']),
|
|
65
|
+
colSpacing: _propTypes.default.oneOf(['none', 'small', 'medium', 'large']),
|
|
66
|
+
value: (0, _controllable.controllable)(_I18nPropTypes.I18nPropTypes.iso8601, 'onChange'),
|
|
67
|
+
defaultValue: _I18nPropTypes.I18nPropTypes.iso8601,
|
|
68
|
+
renderWeekdayLabels: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node])),
|
|
69
|
+
isRequired: _propTypes.default.bool,
|
|
70
|
+
onChange: _propTypes.default.func,
|
|
71
|
+
dateInputRef: _propTypes.default.func,
|
|
72
|
+
timeInputRef: _propTypes.default.func,
|
|
73
|
+
onBlur: _propTypes.default.func,
|
|
74
|
+
disabledDates: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
75
|
+
disabledDateTimeMessage: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]),
|
|
76
|
+
allowNonStepInput: _propTypes.default.bool,
|
|
77
|
+
reset: _propTypes.default.func,
|
|
78
|
+
initialTimeForNewDate: hourMinuteValidator
|
|
79
|
+
};
|
|
31
80
|
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'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-date-time-input",
|
|
3
|
-
"version": "10.26.1
|
|
3
|
+
"version": "10.26.1",
|
|
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,29 +23,32 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-babel-preset": "10.26.1
|
|
26
|
+
"@instructure/ui-babel-preset": "10.26.1",
|
|
27
27
|
"@testing-library/jest-dom": "^6.6.3",
|
|
28
|
-
"@testing-library/react": "
|
|
28
|
+
"@testing-library/react": "^16.0.1",
|
|
29
29
|
"@testing-library/user-event": "^14.6.1",
|
|
30
30
|
"vitest": "^3.2.2"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.27.6",
|
|
34
|
-
"@instructure/console": "10.26.1
|
|
35
|
-
"@instructure/shared-types": "10.26.1
|
|
36
|
-
"@instructure/ui-a11y-content": "10.26.1
|
|
37
|
-
"@instructure/ui-buttons": "10.26.1
|
|
38
|
-
"@instructure/ui-calendar": "10.26.1
|
|
39
|
-
"@instructure/ui-date-input": "10.26.1
|
|
40
|
-
"@instructure/ui-form-field": "10.26.1
|
|
41
|
-
"@instructure/ui-i18n": "10.26.1
|
|
42
|
-
"@instructure/ui-icons": "10.26.1
|
|
43
|
-
"@instructure/ui-
|
|
44
|
-
"@instructure/ui-
|
|
45
|
-
"@instructure/ui-
|
|
34
|
+
"@instructure/console": "10.26.1",
|
|
35
|
+
"@instructure/shared-types": "10.26.1",
|
|
36
|
+
"@instructure/ui-a11y-content": "10.26.1",
|
|
37
|
+
"@instructure/ui-buttons": "10.26.1",
|
|
38
|
+
"@instructure/ui-calendar": "10.26.1",
|
|
39
|
+
"@instructure/ui-date-input": "10.26.1",
|
|
40
|
+
"@instructure/ui-form-field": "10.26.1",
|
|
41
|
+
"@instructure/ui-i18n": "10.26.1",
|
|
42
|
+
"@instructure/ui-icons": "10.26.1",
|
|
43
|
+
"@instructure/ui-prop-types": "10.26.1",
|
|
44
|
+
"@instructure/ui-react-utils": "10.26.1",
|
|
45
|
+
"@instructure/ui-testable": "10.26.1",
|
|
46
|
+
"@instructure/ui-time-select": "10.26.1",
|
|
47
|
+
"@instructure/ui-utils": "10.26.1",
|
|
48
|
+
"prop-types": "^15.8.1"
|
|
46
49
|
},
|
|
47
50
|
"peerDependencies": {
|
|
48
|
-
"react": ">=
|
|
51
|
+
"react": ">=16.14 <=18"
|
|
49
52
|
},
|
|
50
53
|
"publishConfig": {
|
|
51
54
|
"access": "public"
|
|
@@ -31,6 +31,7 @@ import type { FormMessage } from '@instructure/ui-form-field'
|
|
|
31
31
|
import { DateInput } from '@instructure/ui-date-input'
|
|
32
32
|
import { TimeSelect } from '@instructure/ui-time-select'
|
|
33
33
|
import { Calendar } from '@instructure/ui-calendar'
|
|
34
|
+
import { testable } from '@instructure/ui-testable'
|
|
34
35
|
import { AccessibleContent } from '@instructure/ui-a11y-content'
|
|
35
36
|
import { IconButton } from '@instructure/ui-buttons'
|
|
36
37
|
import {
|
|
@@ -38,7 +39,7 @@ import {
|
|
|
38
39
|
IconArrowOpenStartSolid
|
|
39
40
|
} from '@instructure/ui-icons'
|
|
40
41
|
import type { DateTimeInputProps, DateTimeInputState } from './props'
|
|
41
|
-
import { allowedProps } from './props'
|
|
42
|
+
import { propTypes, allowedProps } from './props'
|
|
42
43
|
import { error } from '@instructure/console'
|
|
43
44
|
|
|
44
45
|
/**
|
|
@@ -46,9 +47,11 @@ import { error } from '@instructure/console'
|
|
|
46
47
|
category: components
|
|
47
48
|
---
|
|
48
49
|
**/
|
|
50
|
+
@testable()
|
|
49
51
|
class DateTimeInput extends Component<DateTimeInputProps, DateTimeInputState> {
|
|
50
52
|
// extra verbose localized date and time
|
|
51
53
|
private static readonly DEFAULT_MESSAGE_FORMAT = 'LLLL'
|
|
54
|
+
static propTypes = propTypes
|
|
52
55
|
static allowedProps = allowedProps
|
|
53
56
|
static defaultProps = {
|
|
54
57
|
layout: 'inline',
|
|
@@ -588,7 +591,6 @@ class DateTimeInput extends Component<DateTimeInputProps, DateTimeInputState> {
|
|
|
588
591
|
...(showMessages && this.state.message ? [this.state.message] : []),
|
|
589
592
|
...(messages || [])
|
|
590
593
|
]}
|
|
591
|
-
data-cid="DateTimeInput"
|
|
592
594
|
>
|
|
593
595
|
<DateInput
|
|
594
596
|
display="block"
|
|
@@ -23,10 +23,14 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import { SyntheticEvent } from 'react'
|
|
26
|
+
import { FormPropTypes } from '@instructure/ui-form-field'
|
|
26
27
|
import type { FormMessage } from '@instructure/ui-form-field'
|
|
27
28
|
import type { InteractionType } from '@instructure/ui-react-utils'
|
|
29
|
+
import { I18nPropTypes } from '@instructure/ui-i18n'
|
|
28
30
|
import type { Moment } from '@instructure/ui-i18n'
|
|
29
|
-
import
|
|
31
|
+
import PropTypes, { Validator } from 'prop-types'
|
|
32
|
+
import { controllable } from '@instructure/ui-prop-types'
|
|
33
|
+
import type { PropValidators, Renderable } from '@instructure/shared-types'
|
|
30
34
|
|
|
31
35
|
type DateTimeInputProps = {
|
|
32
36
|
/**
|
|
@@ -277,6 +281,75 @@ type DateTimeInputState = {
|
|
|
277
281
|
type PropKeys = keyof DateTimeInputProps
|
|
278
282
|
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
279
283
|
|
|
284
|
+
const hourMinuteValidator: Validator<string> = function (
|
|
285
|
+
props,
|
|
286
|
+
propName,
|
|
287
|
+
componentName,
|
|
288
|
+
location
|
|
289
|
+
) {
|
|
290
|
+
const propValue = props[propName]
|
|
291
|
+
if (typeof propValue === 'undefined' || propValue === '') return null
|
|
292
|
+
|
|
293
|
+
const hourMinuteRegex = /^\d{2}:\d{2}$/
|
|
294
|
+
|
|
295
|
+
if (typeof propValue === 'string' && !propValue.match(hourMinuteRegex)) {
|
|
296
|
+
return new Error(
|
|
297
|
+
`Invalid ${location} \`${propName}\` \`${propValue}\` supplied to \`${componentName}\`, expected ` +
|
|
298
|
+
`a HH:MM formatted string.`
|
|
299
|
+
)
|
|
300
|
+
}
|
|
301
|
+
return null
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
305
|
+
description: PropTypes.node.isRequired,
|
|
306
|
+
dateRenderLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.node])
|
|
307
|
+
.isRequired,
|
|
308
|
+
prevMonthLabel: PropTypes.string.isRequired,
|
|
309
|
+
nextMonthLabel: PropTypes.string.isRequired,
|
|
310
|
+
datePlaceholder: PropTypes.string,
|
|
311
|
+
timePlaceholder: PropTypes.string,
|
|
312
|
+
dateFormat: PropTypes.string,
|
|
313
|
+
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
314
|
+
timeRenderLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.node])
|
|
315
|
+
.isRequired,
|
|
316
|
+
timeStep: PropTypes.oneOf([5, 10, 15, 20, 30, 60]),
|
|
317
|
+
timeFormat: PropTypes.string,
|
|
318
|
+
locale: PropTypes.string,
|
|
319
|
+
timezone: PropTypes.string,
|
|
320
|
+
invalidDateTimeMessage: PropTypes.oneOfType([
|
|
321
|
+
PropTypes.string,
|
|
322
|
+
PropTypes.func
|
|
323
|
+
]).isRequired,
|
|
324
|
+
showMessages: PropTypes.bool,
|
|
325
|
+
messages: PropTypes.arrayOf(FormPropTypes.message),
|
|
326
|
+
messageFormat: PropTypes.string,
|
|
327
|
+
layout: PropTypes.oneOf(['stacked', 'columns', 'inline']),
|
|
328
|
+
rowSpacing: PropTypes.oneOf(['none', 'small', 'medium', 'large']),
|
|
329
|
+
colSpacing: PropTypes.oneOf(['none', 'small', 'medium', 'large']),
|
|
330
|
+
value: controllable(I18nPropTypes.iso8601, 'onChange'),
|
|
331
|
+
defaultValue: I18nPropTypes.iso8601,
|
|
332
|
+
renderWeekdayLabels: PropTypes.arrayOf(
|
|
333
|
+
PropTypes.oneOfType([PropTypes.func, PropTypes.node])
|
|
334
|
+
),
|
|
335
|
+
isRequired: PropTypes.bool,
|
|
336
|
+
onChange: PropTypes.func,
|
|
337
|
+
dateInputRef: PropTypes.func,
|
|
338
|
+
timeInputRef: PropTypes.func,
|
|
339
|
+
onBlur: PropTypes.func,
|
|
340
|
+
disabledDates: PropTypes.oneOfType([
|
|
341
|
+
PropTypes.func,
|
|
342
|
+
PropTypes.arrayOf(PropTypes.string)
|
|
343
|
+
]),
|
|
344
|
+
disabledDateTimeMessage: PropTypes.oneOfType([
|
|
345
|
+
PropTypes.string,
|
|
346
|
+
PropTypes.func
|
|
347
|
+
]),
|
|
348
|
+
allowNonStepInput: PropTypes.bool,
|
|
349
|
+
reset: PropTypes.func,
|
|
350
|
+
initialTimeForNewDate: hourMinuteValidator
|
|
351
|
+
}
|
|
352
|
+
|
|
280
353
|
const allowedProps: AllowedPropKeys = [
|
|
281
354
|
'description',
|
|
282
355
|
'dateRenderLabel',
|
|
@@ -313,4 +386,4 @@ const allowedProps: AllowedPropKeys = [
|
|
|
313
386
|
]
|
|
314
387
|
|
|
315
388
|
export type { DateTimeInputProps, DateTimeInputState }
|
|
316
|
-
export { allowedProps }
|
|
389
|
+
export { propTypes, allowedProps }
|
package/tsconfig.build.json
CHANGED
|
@@ -15,8 +15,10 @@
|
|
|
15
15
|
{ "path": "../ui-i18n/tsconfig.build.json" },
|
|
16
16
|
{ "path": "../ui-icons/tsconfig.build.json" },
|
|
17
17
|
{ "path": "../ui-a11y-content/tsconfig.build.json" },
|
|
18
|
+
{ "path": "../ui-prop-types/tsconfig.build.json" },
|
|
18
19
|
{ "path": "../ui-react-utils/tsconfig.build.json" },
|
|
19
20
|
{ "path": "../shared-types/tsconfig.build.json" },
|
|
21
|
+
{ "path": "../ui-testable/tsconfig.build.json" },
|
|
20
22
|
{ "path": "../ui-time-select/tsconfig.build.json" },
|
|
21
23
|
{ "path": "../ui-utils/tsconfig.build.json" },
|
|
22
24
|
{ "path": "../console/tsconfig.build.json" }
|