@atlaskit/datetime-picker 15.5.0 → 15.5.2
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 +19 -0
- package/dist/cjs/components/date-picker-class.js +11 -3
- package/dist/cjs/components/date-picker-fc.js +11 -3
- package/dist/cjs/components/date-time-picker-class.js +439 -0
- package/dist/cjs/components/date-time-picker-fc.js +398 -0
- package/dist/cjs/components/date-time-picker.js +7 -430
- package/dist/cjs/components/time-picker.js +1 -1
- package/dist/cjs/internal/date-time-picker-container.js +21 -20
- package/dist/cjs/internal/indicators-container.js +31 -0
- package/dist/es2019/components/date-picker-class.js +9 -1
- package/dist/es2019/components/date-picker-fc.js +9 -1
- package/dist/es2019/components/date-time-picker-class.js +400 -0
- package/dist/es2019/components/date-time-picker-fc.js +363 -0
- package/dist/es2019/components/date-time-picker.js +4 -397
- package/dist/es2019/components/time-picker.js +1 -1
- package/dist/es2019/internal/date-time-picker-container.js +8 -7
- package/dist/es2019/internal/indicators-container.js +22 -0
- package/dist/esm/components/date-picker-class.js +11 -3
- package/dist/esm/components/date-picker-fc.js +11 -3
- package/dist/esm/components/date-time-picker-class.js +437 -0
- package/dist/esm/components/date-time-picker-fc.js +391 -0
- package/dist/esm/components/date-time-picker.js +6 -434
- package/dist/esm/components/time-picker.js +1 -1
- package/dist/esm/internal/date-time-picker-container.js +8 -7
- package/dist/esm/internal/indicators-container.js +25 -0
- package/dist/types/components/date-picker-class.d.ts +2 -2
- package/dist/types/components/date-picker-fc.d.ts +1 -1
- package/dist/types/components/date-picker.d.ts +3 -3
- package/dist/types/components/date-time-picker-class.d.ts +56 -0
- package/dist/types/components/date-time-picker-fc.d.ts +19 -0
- package/dist/types/components/date-time-picker.d.ts +2 -55
- package/dist/types/components/time-picker.d.ts +1 -1
- package/dist/types/internal/date-time-picker-container.d.ts +10 -12
- package/dist/types/internal/indicators-container.d.ts +9 -0
- package/dist/types-ts4.5/components/date-picker-class.d.ts +2 -2
- package/dist/types-ts4.5/components/date-picker-fc.d.ts +1 -1
- package/dist/types-ts4.5/components/date-picker.d.ts +3 -3
- package/dist/types-ts4.5/components/date-time-picker-class.d.ts +56 -0
- package/dist/types-ts4.5/components/date-time-picker-fc.d.ts +19 -0
- package/dist/types-ts4.5/components/date-time-picker.d.ts +2 -55
- package/dist/types-ts4.5/components/time-picker.d.ts +1 -1
- package/dist/types-ts4.5/internal/date-time-picker-container.d.ts +10 -12
- package/dist/types-ts4.5/internal/indicators-container.d.ts +9 -0
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/datetime-picker
|
|
2
2
|
|
|
3
|
+
## 15.5.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 15.5.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#156121](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/156121)
|
|
14
|
+
[`6e87dd7dd8d3a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6e87dd7dd8d3a) -
|
|
15
|
+
When `shouldShowCalendarButton` is `true`, ensures that input text properly overflows via
|
|
16
|
+
controlling an underlying select component.
|
|
17
|
+
- [#156147](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/156147)
|
|
18
|
+
[`a5c2ba68d297d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a5c2ba68d297d) -
|
|
19
|
+
We are testing converting the datetime picker from a class component to a functional component
|
|
20
|
+
behind a feature flag. If this fix is successful it will be available in a later release.
|
|
21
|
+
|
|
3
22
|
## 15.5.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -27,6 +27,7 @@ var _colors = require("@atlaskit/theme/colors");
|
|
|
27
27
|
var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
|
|
28
28
|
var _internal = require("../internal");
|
|
29
29
|
var _datePickerMigration = require("../internal/date-picker-migration");
|
|
30
|
+
var _indicatorsContainer = require("../internal/indicators-container");
|
|
30
31
|
var _menu = require("../internal/menu");
|
|
31
32
|
var _parseDate = require("../internal/parse-date");
|
|
32
33
|
var _singleValue = require("../internal/single-value");
|
|
@@ -43,7 +44,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
43
44
|
// version very soon from converting this to functional. And also React 18 is on
|
|
44
45
|
// the horizon
|
|
45
46
|
var packageName = "@atlaskit/datetime-picker";
|
|
46
|
-
var packageVersion = "15.5.
|
|
47
|
+
var packageVersion = "15.5.2";
|
|
47
48
|
var datePickerDefaultProps = {
|
|
48
49
|
defaultIsOpen: false,
|
|
49
50
|
defaultValue: '',
|
|
@@ -470,8 +471,15 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
470
471
|
var SingleValue = (0, _singleValue.makeSingleValue)({
|
|
471
472
|
lang: this.props.locale
|
|
472
473
|
});
|
|
473
|
-
var selectComponents = _objectSpread({
|
|
474
|
-
DropdownIndicator: shouldShowCalendarButton ? _internal.EmptyComponent : dropDownIcon
|
|
474
|
+
var selectComponents = _objectSpread(_objectSpread({
|
|
475
|
+
DropdownIndicator: shouldShowCalendarButton ? _internal.EmptyComponent : dropDownIcon
|
|
476
|
+
}, shouldShowCalendarButton ? {
|
|
477
|
+
IndicatorsContainer: function IndicatorsContainer(props) {
|
|
478
|
+
return (0, _react2.jsx)(_indicatorsContainer.IndicatorsContainer, (0, _extends2.default)({}, props, {
|
|
479
|
+
showClearIndicator: showClearIndicator
|
|
480
|
+
}));
|
|
481
|
+
}
|
|
482
|
+
} : {}), {}, {
|
|
475
483
|
Menu: _menu.Menu,
|
|
476
484
|
SingleValue: SingleValue
|
|
477
485
|
}, !showClearIndicator && {
|
|
@@ -23,6 +23,7 @@ var _colors = require("@atlaskit/theme/colors");
|
|
|
23
23
|
var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
|
|
24
24
|
var _internal = require("../internal");
|
|
25
25
|
var _datePickerMigration = require("../internal/date-picker-migration");
|
|
26
|
+
var _indicatorsContainer = require("../internal/indicators-container");
|
|
26
27
|
var _menu = require("../internal/menu");
|
|
27
28
|
var _parseDate = require("../internal/parse-date");
|
|
28
29
|
var _singleValue = require("../internal/single-value");
|
|
@@ -40,7 +41,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
40
41
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
41
42
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
42
43
|
var packageName = "@atlaskit/datetime-picker";
|
|
43
|
-
var packageVersion = "15.5.
|
|
44
|
+
var packageVersion = "15.5.2";
|
|
44
45
|
var analyticsAttributes = {
|
|
45
46
|
componentName: 'datePicker',
|
|
46
47
|
packageName: packageName,
|
|
@@ -461,8 +462,15 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, forwardedR
|
|
|
461
462
|
var SingleValue = (0, _singleValue.makeSingleValue)({
|
|
462
463
|
lang: propLocale
|
|
463
464
|
});
|
|
464
|
-
var selectComponents = _objectSpread({
|
|
465
|
-
DropdownIndicator: shouldShowCalendarButton ? _internal.EmptyComponent : dropDownIcon
|
|
465
|
+
var selectComponents = _objectSpread(_objectSpread({
|
|
466
|
+
DropdownIndicator: shouldShowCalendarButton ? _internal.EmptyComponent : dropDownIcon
|
|
467
|
+
}, shouldShowCalendarButton ? {
|
|
468
|
+
IndicatorsContainer: function IndicatorsContainer(props) {
|
|
469
|
+
return (0, _react2.jsx)(_indicatorsContainer.IndicatorsContainer, (0, _extends2.default)({}, props, {
|
|
470
|
+
showClearIndicator: showClearIndicator
|
|
471
|
+
}));
|
|
472
|
+
}
|
|
473
|
+
} : {}), {}, {
|
|
466
474
|
Menu: _menu.Menu,
|
|
467
475
|
SingleValue: SingleValue
|
|
468
476
|
}, !showClearIndicator && {
|
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.timePickerDefaultAriaLabel = exports.default = exports.datePickerDefaultAriaLabel = exports.DateTimePickerWithoutAnalytics = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
11
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
+
var _react = _interopRequireDefault(require("react"));
|
|
16
|
+
var _react2 = require("@emotion/react");
|
|
17
|
+
var _dateFns = require("date-fns");
|
|
18
|
+
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
19
|
+
var _selectClear = _interopRequireDefault(require("@atlaskit/icon/glyph/select-clear"));
|
|
20
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
|
+
var _select = require("@atlaskit/select");
|
|
22
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
23
|
+
var _internal = require("../internal");
|
|
24
|
+
var _dateTimePickerContainer = require("../internal/date-time-picker-container");
|
|
25
|
+
var _ffComponent = require("../internal/ff-component");
|
|
26
|
+
var _parseTokens = require("../internal/parse-tokens");
|
|
27
|
+
var _datePickerClass = _interopRequireDefault(require("./date-picker-class"));
|
|
28
|
+
var _datePickerFc = _interopRequireDefault(require("./date-picker-fc"));
|
|
29
|
+
var _timePicker = _interopRequireDefault(require("./time-picker"));
|
|
30
|
+
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2.default)(t); if (r) { var s = (0, _getPrototypeOf2.default)(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2.default)(this, e); }; }
|
|
31
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
32
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
33
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
|
|
34
|
+
* @jsxRuntime classic
|
|
35
|
+
* @jsx jsx
|
|
36
|
+
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
37
|
+
var DatePicker = (0, _ffComponent.componentWithCondition)(function () {
|
|
38
|
+
return (0, _platformFeatureFlags.fg)('dst-date-picker-use-functional-component');
|
|
39
|
+
}, _datePickerFc.default, _datePickerClass.default);
|
|
40
|
+
var packageName = "@atlaskit/datetime-picker";
|
|
41
|
+
var packageVersion = "15.5.2";
|
|
42
|
+
// Make DatePicker 50% the width of DateTimePicker
|
|
43
|
+
// If rendering an icon container, shrink the TimePicker
|
|
44
|
+
var datePickerContainerStyles = (0, _react2.css)({
|
|
45
|
+
flexBasis: '50%',
|
|
46
|
+
flexGrow: 1,
|
|
47
|
+
flexShrink: 0
|
|
48
|
+
});
|
|
49
|
+
var timePickerContainerStyles = (0, _react2.css)({
|
|
50
|
+
flexBasis: '50%',
|
|
51
|
+
flexGrow: 1
|
|
52
|
+
});
|
|
53
|
+
var iconContainerStyles = (0, _react2.css)({
|
|
54
|
+
display: 'flex',
|
|
55
|
+
margin: "var(--ds-border-width, 1px)",
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
flexBasis: 'inherit',
|
|
58
|
+
backgroundColor: 'inherit',
|
|
59
|
+
border: 'none',
|
|
60
|
+
color: "var(--ds-text-subtlest, ".concat(_colors.N70, ")"),
|
|
61
|
+
paddingBlockEnd: "var(--ds-space-075, 6px)",
|
|
62
|
+
paddingBlockStart: "var(--ds-space-075, 6px)",
|
|
63
|
+
paddingInlineEnd: "var(--ds-space-100, 8px)",
|
|
64
|
+
paddingInlineStart: "var(--ds-space-050, 4px)",
|
|
65
|
+
transition: "color 150ms",
|
|
66
|
+
'&:hover': {
|
|
67
|
+
color: "var(--ds-text-subtle, ".concat(_colors.N500, ")")
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// react-select overrides (via @atlaskit/select).
|
|
72
|
+
var styles = {
|
|
73
|
+
control: function control(style) {
|
|
74
|
+
return _objectSpread(_objectSpread({}, style), {}, {
|
|
75
|
+
backgroundColor: 'transparent',
|
|
76
|
+
border: 2,
|
|
77
|
+
borderRadius: 0,
|
|
78
|
+
paddingLeft: 0,
|
|
79
|
+
':hover': {
|
|
80
|
+
backgroundColor: 'transparent',
|
|
81
|
+
cursor: 'inherit'
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var dateTimePickerDefaultProps = {
|
|
87
|
+
// These disables are here for proper typing when used as defaults. They
|
|
88
|
+
// should *not* use the `noop` function.
|
|
89
|
+
/* eslint-disable @repo/internal/react/use-noop */
|
|
90
|
+
onBlur: function onBlur(_event) {},
|
|
91
|
+
onChange: function onChange(_value) {},
|
|
92
|
+
onFocus: function onFocus(_event) {}
|
|
93
|
+
/* eslint-enable @repo/internal/react/use-noop */
|
|
94
|
+
// Not including a default prop for value as it will
|
|
95
|
+
// Make the component a controlled component
|
|
96
|
+
};
|
|
97
|
+
var datePickerDefaultAriaLabel = exports.datePickerDefaultAriaLabel = 'Date';
|
|
98
|
+
var timePickerDefaultAriaLabel = exports.timePickerDefaultAriaLabel = 'Time';
|
|
99
|
+
var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE__*/function (_React$Component) {
|
|
100
|
+
(0, _inherits2.default)(DateTimePickerComponent, _React$Component);
|
|
101
|
+
var _super = _createSuper(DateTimePickerComponent);
|
|
102
|
+
function DateTimePickerComponent() {
|
|
103
|
+
var _this$props$datePicke, _this$props$timePicke;
|
|
104
|
+
var _this;
|
|
105
|
+
(0, _classCallCheck2.default)(this, DateTimePickerComponent);
|
|
106
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
107
|
+
args[_key] = arguments[_key];
|
|
108
|
+
}
|
|
109
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
110
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
|
|
111
|
+
dateValue: ((_this$props$datePicke = _this.props.datePickerProps) === null || _this$props$datePicke === void 0 ? void 0 : _this$props$datePicke.defaultValue) || '',
|
|
112
|
+
isFocused: false,
|
|
113
|
+
timeValue: ((_this$props$timePicke = _this.props.timePickerProps) === null || _this$props$timePicke === void 0 ? void 0 : _this$props$timePicke.defaultValue) || '',
|
|
114
|
+
value: _this.props.defaultValue || '',
|
|
115
|
+
zoneValue: ''
|
|
116
|
+
});
|
|
117
|
+
// All state needs to be accessed via this function so that the state is mapped from props
|
|
118
|
+
// correctly to allow controlled/uncontrolled usage.
|
|
119
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getParsedValues", function () {
|
|
120
|
+
return _this.parseValue(_this.getValue(), _this.state.dateValue, _this.state.timeValue, _this.state.zoneValue);
|
|
121
|
+
});
|
|
122
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getValue", function () {
|
|
123
|
+
var _this$props$value;
|
|
124
|
+
return (_this$props$value = _this.props.value) !== null && _this$props$value !== void 0 ? _this$props$value : _this.state.value;
|
|
125
|
+
});
|
|
126
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onDateBlur", function (event) {
|
|
127
|
+
var _this$props$onBlur, _this$props, _this$props$datePicke2;
|
|
128
|
+
_this.setState({
|
|
129
|
+
isFocused: false
|
|
130
|
+
});
|
|
131
|
+
(_this$props$onBlur = (_this$props = _this.props).onBlur) === null || _this$props$onBlur === void 0 || _this$props$onBlur.call(_this$props, event);
|
|
132
|
+
if ((_this$props$datePicke2 = _this.props.datePickerProps) !== null && _this$props$datePicke2 !== void 0 && _this$props$datePicke2.onBlur) {
|
|
133
|
+
_this.props.datePickerProps.onBlur(event);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onTimeBlur", function (event) {
|
|
137
|
+
var _this$props$onBlur2, _this$props2, _this$props$timePicke2;
|
|
138
|
+
_this.setState({
|
|
139
|
+
isFocused: false
|
|
140
|
+
});
|
|
141
|
+
(_this$props$onBlur2 = (_this$props2 = _this.props).onBlur) === null || _this$props$onBlur2 === void 0 || _this$props$onBlur2.call(_this$props2, event);
|
|
142
|
+
if ((_this$props$timePicke2 = _this.props.timePickerProps) !== null && _this$props$timePicke2 !== void 0 && _this$props$timePicke2.onBlur) {
|
|
143
|
+
_this.props.timePickerProps.onBlur(event);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onDateFocus", function (event) {
|
|
147
|
+
var _this$props$onFocus, _this$props3, _this$props$datePicke3;
|
|
148
|
+
_this.setState({
|
|
149
|
+
isFocused: true
|
|
150
|
+
});
|
|
151
|
+
(_this$props$onFocus = (_this$props3 = _this.props).onFocus) === null || _this$props$onFocus === void 0 || _this$props$onFocus.call(_this$props3, event);
|
|
152
|
+
if ((_this$props$datePicke3 = _this.props.datePickerProps) !== null && _this$props$datePicke3 !== void 0 && _this$props$datePicke3.onFocus) {
|
|
153
|
+
_this.props.datePickerProps.onFocus(event);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onTimeFocus", function (event) {
|
|
157
|
+
var _this$props$onFocus2, _this$props4, _this$props$timePicke3;
|
|
158
|
+
_this.setState({
|
|
159
|
+
isFocused: true
|
|
160
|
+
});
|
|
161
|
+
(_this$props$onFocus2 = (_this$props4 = _this.props).onFocus) === null || _this$props$onFocus2 === void 0 || _this$props$onFocus2.call(_this$props4, event);
|
|
162
|
+
if ((_this$props$timePicke3 = _this.props.timePickerProps) !== null && _this$props$timePicke3 !== void 0 && _this$props$timePicke3.onFocus) {
|
|
163
|
+
_this.props.timePickerProps.onFocus(event);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onDateChange", function (dateValue) {
|
|
167
|
+
var _this$props$datePicke4;
|
|
168
|
+
var parsedValues = _this.getParsedValues();
|
|
169
|
+
_this.onValueChange({
|
|
170
|
+
dateValue: dateValue,
|
|
171
|
+
timeValue: parsedValues.timeValue,
|
|
172
|
+
zoneValue: parsedValues.zoneValue
|
|
173
|
+
});
|
|
174
|
+
if ((_this$props$datePicke4 = _this.props.datePickerProps) !== null && _this$props$datePicke4 !== void 0 && _this$props$datePicke4.onChange) {
|
|
175
|
+
_this.props.datePickerProps.onChange(dateValue);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onTimeChange", function (timeValue) {
|
|
179
|
+
var _this$props$timePicke4;
|
|
180
|
+
var parsedValues = _this.getParsedValues();
|
|
181
|
+
_this.onValueChange({
|
|
182
|
+
dateValue: parsedValues.dateValue,
|
|
183
|
+
timeValue: timeValue,
|
|
184
|
+
zoneValue: parsedValues.zoneValue
|
|
185
|
+
});
|
|
186
|
+
if ((_this$props$timePicke4 = _this.props.timePickerProps) !== null && _this$props$timePicke4 !== void 0 && _this$props$timePicke4.onChange) {
|
|
187
|
+
_this.props.timePickerProps.onChange(timeValue);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onClear", function () {
|
|
191
|
+
var _this$props$datePicke5, _this$props$timePicke5;
|
|
192
|
+
var parsedValues = _this.getParsedValues();
|
|
193
|
+
_this.onValueChange({
|
|
194
|
+
dateValue: '',
|
|
195
|
+
timeValue: '',
|
|
196
|
+
zoneValue: parsedValues.zoneValue
|
|
197
|
+
});
|
|
198
|
+
if ((_this$props$datePicke5 = _this.props.datePickerProps) !== null && _this$props$datePicke5 !== void 0 && _this$props$datePicke5.onChange) {
|
|
199
|
+
_this.props.datePickerProps.onChange('');
|
|
200
|
+
}
|
|
201
|
+
if ((_this$props$timePicke5 = _this.props.timePickerProps) !== null && _this$props$timePicke5 !== void 0 && _this$props$timePicke5.onChange) {
|
|
202
|
+
_this.props.timePickerProps.onChange('');
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
return _this;
|
|
206
|
+
}
|
|
207
|
+
(0, _createClass2.default)(DateTimePickerComponent, [{
|
|
208
|
+
key: "parseValue",
|
|
209
|
+
value: function parseValue(value, dateValue, timeValue, zoneValue) {
|
|
210
|
+
if (this.props.parseValue) {
|
|
211
|
+
var parsedFromFn = this.props.parseValue(value, dateValue, timeValue, zoneValue);
|
|
212
|
+
// This handles cases found in Jira where the parse function actually does
|
|
213
|
+
// nothing and returns undefined. The previous `getSafeState` function
|
|
214
|
+
// just spread the values over the state, but if it returned `undefined`,
|
|
215
|
+
// it would just rely on the previous state values. Considering this is
|
|
216
|
+
// what is input to this function anyway, this is a safe way to handle
|
|
217
|
+
// this, colocate the behavior, and not rely on `getSafeState`.
|
|
218
|
+
return parsedFromFn || {
|
|
219
|
+
dateValue: dateValue,
|
|
220
|
+
timeValue: timeValue,
|
|
221
|
+
zoneValue: zoneValue
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
var parsed = (0, _dateFns.parseISO)(value);
|
|
225
|
+
return (0, _dateFns.isValid)(parsed) ? {
|
|
226
|
+
dateValue: (0, _dateFns.format)(parsed, (0, _parseTokens.convertTokens)('YYYY-MM-DD')),
|
|
227
|
+
timeValue: (0, _dateFns.format)(parsed, (0, _parseTokens.convertTokens)('HH:mm')),
|
|
228
|
+
zoneValue: (0, _dateFns.format)(parsed, (0, _parseTokens.convertTokens)('ZZ'))
|
|
229
|
+
} : {
|
|
230
|
+
dateValue: dateValue,
|
|
231
|
+
timeValue: timeValue,
|
|
232
|
+
zoneValue: zoneValue
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}, {
|
|
236
|
+
key: "onValueChange",
|
|
237
|
+
value: function onValueChange(_ref) {
|
|
238
|
+
var dateValue = _ref.dateValue,
|
|
239
|
+
timeValue = _ref.timeValue,
|
|
240
|
+
zoneValue = _ref.zoneValue;
|
|
241
|
+
this.setState({
|
|
242
|
+
dateValue: dateValue,
|
|
243
|
+
timeValue: timeValue,
|
|
244
|
+
zoneValue: zoneValue
|
|
245
|
+
});
|
|
246
|
+
if (dateValue && timeValue) {
|
|
247
|
+
var _this$props$onChange, _this$props5;
|
|
248
|
+
var value = (0, _internal.formatDateTimeZoneIntoIso)(dateValue, timeValue, zoneValue);
|
|
249
|
+
var _this$parseValue = this.parseValue(value, dateValue, timeValue, zoneValue),
|
|
250
|
+
parsedZone = _this$parseValue.zoneValue;
|
|
251
|
+
var valueWithValidZone = (0, _internal.formatDateTimeZoneIntoIso)(dateValue, timeValue, parsedZone);
|
|
252
|
+
this.setState({
|
|
253
|
+
value: valueWithValidZone
|
|
254
|
+
});
|
|
255
|
+
(_this$props$onChange = (_this$props5 = this.props).onChange) === null || _this$props$onChange === void 0 || _this$props$onChange.call(_this$props5, valueWithValidZone);
|
|
256
|
+
// If the date or time value was cleared when there is an existing datetime value, then clear the value.
|
|
257
|
+
} else if (this.getValue()) {
|
|
258
|
+
var _this$props$onChange2, _this$props6;
|
|
259
|
+
this.setState({
|
|
260
|
+
value: ''
|
|
261
|
+
});
|
|
262
|
+
(_this$props$onChange2 = (_this$props6 = this.props).onChange) === null || _this$props$onChange2 === void 0 || _this$props$onChange2.call(_this$props6, '');
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}, {
|
|
266
|
+
key: "render",
|
|
267
|
+
value: function render() {
|
|
268
|
+
var _this$props7 = this.props,
|
|
269
|
+
ariaDescribedBy = _this$props7['aria-describedby'],
|
|
270
|
+
_this$props7$appearan = _this$props7.appearance,
|
|
271
|
+
appearance = _this$props7$appearan === void 0 ? 'default' : _this$props7$appearan,
|
|
272
|
+
_this$props7$autoFocu = _this$props7.autoFocus,
|
|
273
|
+
autoFocus = _this$props7$autoFocu === void 0 ? false : _this$props7$autoFocu,
|
|
274
|
+
_this$props7$clearCon = _this$props7.clearControlLabel,
|
|
275
|
+
clearControlLabel = _this$props7$clearCon === void 0 ? 'clear' : _this$props7$clearCon,
|
|
276
|
+
_this$props7$datePick = _this$props7.datePickerProps,
|
|
277
|
+
datePickerProps = _this$props7$datePick === void 0 ? {} : _this$props7$datePick,
|
|
278
|
+
_this$props7$id = _this$props7.id,
|
|
279
|
+
id = _this$props7$id === void 0 ? '' : _this$props7$id,
|
|
280
|
+
_this$props7$innerPro = _this$props7.innerProps,
|
|
281
|
+
innerProps = _this$props7$innerPro === void 0 ? {} : _this$props7$innerPro,
|
|
282
|
+
_this$props7$isDisabl = _this$props7.isDisabled,
|
|
283
|
+
isDisabled = _this$props7$isDisabl === void 0 ? false : _this$props7$isDisabl,
|
|
284
|
+
_this$props7$isInvali = _this$props7.isInvalid,
|
|
285
|
+
isInvalid = _this$props7$isInvali === void 0 ? false : _this$props7$isInvali,
|
|
286
|
+
_this$props7$isRequir = _this$props7.isRequired,
|
|
287
|
+
isRequired = _this$props7$isRequir === void 0 ? false : _this$props7$isRequir,
|
|
288
|
+
_this$props7$locale = _this$props7.locale,
|
|
289
|
+
locale = _this$props7$locale === void 0 ? 'en-US' : _this$props7$locale,
|
|
290
|
+
_this$props7$name = _this$props7.name,
|
|
291
|
+
name = _this$props7$name === void 0 ? '' : _this$props7$name,
|
|
292
|
+
_this$props7$spacing = _this$props7.spacing,
|
|
293
|
+
spacing = _this$props7$spacing === void 0 ? 'default' : _this$props7$spacing,
|
|
294
|
+
testId = _this$props7.testId,
|
|
295
|
+
_this$props7$timePick = _this$props7.timePickerProps,
|
|
296
|
+
timePickerProps = _this$props7$timePick === void 0 ? {} : _this$props7$timePick;
|
|
297
|
+
var value = this.getValue();
|
|
298
|
+
var isFocused = this.state.isFocused;
|
|
299
|
+
var parsedValues = this.getParsedValues();
|
|
300
|
+
var dateValue = parsedValues === null || parsedValues === void 0 ? void 0 : parsedValues.dateValue;
|
|
301
|
+
var timeValue = parsedValues === null || parsedValues === void 0 ? void 0 : parsedValues.timeValue;
|
|
302
|
+
var datePickerSelectProps = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.selectProps;
|
|
303
|
+
var datePickerAriaDescribedBy = datePickerProps['aria-describedby'] || ariaDescribedBy;
|
|
304
|
+
var datePickerLabel = datePickerProps.label || datePickerDefaultAriaLabel;
|
|
305
|
+
var mergedDatePickerSelectProps = _objectSpread(_objectSpread({}, datePickerSelectProps), {}, {
|
|
306
|
+
styles: (0, _select.mergeStyles)(styles, datePickerSelectProps === null || datePickerSelectProps === void 0 ? void 0 : datePickerSelectProps.styles)
|
|
307
|
+
});
|
|
308
|
+
var timePickerSelectProps = timePickerProps === null || timePickerProps === void 0 ? void 0 : timePickerProps.selectProps;
|
|
309
|
+
var timePickerAriaDescribedBy = timePickerProps['aria-describedby'] || ariaDescribedBy;
|
|
310
|
+
var timePickerLabel = timePickerProps.label || timePickerDefaultAriaLabel;
|
|
311
|
+
var mergedTimePickerSelectProps = _objectSpread(_objectSpread({}, timePickerSelectProps), {}, {
|
|
312
|
+
styles: (0, _select.mergeStyles)(styles, timePickerSelectProps === null || timePickerSelectProps === void 0 ? void 0 : timePickerSelectProps.styles)
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
// Render DateTimePicker's IconContainer when a value has been filled
|
|
316
|
+
// Don't use Date or TimePicker's because they can't be customised
|
|
317
|
+
var isClearable = Boolean(dateValue || timeValue);
|
|
318
|
+
return (0, _react2.jsx)(_dateTimePickerContainer.DateTimePickerContainer, {
|
|
319
|
+
appearance: appearance,
|
|
320
|
+
isDisabled: isDisabled,
|
|
321
|
+
isFocused: isFocused,
|
|
322
|
+
isInvalid: isInvalid,
|
|
323
|
+
testId: testId,
|
|
324
|
+
innerProps: innerProps
|
|
325
|
+
}, (0, _react2.jsx)("input", {
|
|
326
|
+
name: name,
|
|
327
|
+
type: "hidden",
|
|
328
|
+
value: value,
|
|
329
|
+
"data-testid": testId && "".concat(testId, "--input")
|
|
330
|
+
}), (0, _react2.jsx)("div", {
|
|
331
|
+
css: datePickerContainerStyles
|
|
332
|
+
}, (0, _react2.jsx)(DatePicker, {
|
|
333
|
+
appearance: appearance,
|
|
334
|
+
"aria-describedby": datePickerAriaDescribedBy,
|
|
335
|
+
autoFocus: datePickerProps.autoFocus || autoFocus,
|
|
336
|
+
dateFormat: datePickerProps.dateFormat,
|
|
337
|
+
defaultIsOpen: datePickerProps.defaultIsOpen,
|
|
338
|
+
defaultValue: datePickerProps.defaultValue,
|
|
339
|
+
disabled: datePickerProps.disabled,
|
|
340
|
+
disabledDateFilter: datePickerProps.disabledDateFilter,
|
|
341
|
+
formatDisplayLabel: datePickerProps.formatDisplayLabel,
|
|
342
|
+
hideIcon: datePickerProps.hideIcon || true,
|
|
343
|
+
icon: datePickerProps.icon,
|
|
344
|
+
id: datePickerProps.id || id,
|
|
345
|
+
innerProps: datePickerProps.innerProps,
|
|
346
|
+
isDisabled: datePickerProps.isDisabled || isDisabled,
|
|
347
|
+
isInvalid: datePickerProps.isInvalid || isInvalid,
|
|
348
|
+
isRequired: datePickerProps.isRequired || isRequired,
|
|
349
|
+
isOpen: datePickerProps.isOpen,
|
|
350
|
+
label: datePickerLabel,
|
|
351
|
+
locale: datePickerProps.locale || locale,
|
|
352
|
+
maxDate: datePickerProps.maxDate,
|
|
353
|
+
minDate: datePickerProps.minDate,
|
|
354
|
+
name: datePickerProps.name,
|
|
355
|
+
nextMonthLabel: datePickerProps.nextMonthLabel,
|
|
356
|
+
onBlur: this.onDateBlur,
|
|
357
|
+
onChange: this.onDateChange,
|
|
358
|
+
onFocus: this.onDateFocus,
|
|
359
|
+
parseInputValue: datePickerProps.parseInputValue,
|
|
360
|
+
placeholder: datePickerProps.placeholder,
|
|
361
|
+
previousMonthLabel: datePickerProps.previousMonthLabel,
|
|
362
|
+
selectProps: mergedDatePickerSelectProps,
|
|
363
|
+
shouldShowCalendarButton: datePickerProps.shouldShowCalendarButton,
|
|
364
|
+
spacing: datePickerProps.spacing || spacing,
|
|
365
|
+
testId: testId && "".concat(testId, "--datepicker") || datePickerProps.testId,
|
|
366
|
+
value: dateValue,
|
|
367
|
+
weekStartDay: datePickerProps.weekStartDay
|
|
368
|
+
})), (0, _react2.jsx)("div", {
|
|
369
|
+
css: timePickerContainerStyles
|
|
370
|
+
}, (0, _react2.jsx)(_timePicker.default, {
|
|
371
|
+
appearance: timePickerProps.appearance || appearance,
|
|
372
|
+
"aria-describedby": timePickerAriaDescribedBy,
|
|
373
|
+
autoFocus: timePickerProps.autoFocus,
|
|
374
|
+
defaultIsOpen: timePickerProps.defaultIsOpen,
|
|
375
|
+
defaultValue: timePickerProps.defaultValue,
|
|
376
|
+
formatDisplayLabel: timePickerProps.formatDisplayLabel,
|
|
377
|
+
hideIcon: timePickerProps.hideIcon || true,
|
|
378
|
+
id: timePickerProps.id,
|
|
379
|
+
innerProps: timePickerProps.innerProps,
|
|
380
|
+
isDisabled: timePickerProps.isDisabled || isDisabled,
|
|
381
|
+
isInvalid: timePickerProps.isInvalid || isInvalid,
|
|
382
|
+
isOpen: timePickerProps.isOpen,
|
|
383
|
+
isRequired: timePickerProps.isRequired || isRequired,
|
|
384
|
+
label: timePickerLabel,
|
|
385
|
+
locale: timePickerProps.locale || locale,
|
|
386
|
+
name: timePickerProps.name,
|
|
387
|
+
onBlur: this.onTimeBlur,
|
|
388
|
+
onChange: this.onTimeChange,
|
|
389
|
+
onFocus: this.onTimeFocus,
|
|
390
|
+
parseInputValue: timePickerProps.parseInputValue,
|
|
391
|
+
placeholder: timePickerProps.placeholder,
|
|
392
|
+
selectProps: mergedTimePickerSelectProps,
|
|
393
|
+
spacing: timePickerProps.spacing || spacing,
|
|
394
|
+
testId: timePickerProps.testId || testId && "".concat(testId, "--timepicker"),
|
|
395
|
+
timeFormat: timePickerProps.timeFormat,
|
|
396
|
+
timeIsEditable: timePickerProps.timeIsEditable,
|
|
397
|
+
times: timePickerProps.times,
|
|
398
|
+
value: timeValue
|
|
399
|
+
})), isClearable && !isDisabled ? (0, _react2.jsx)("button", {
|
|
400
|
+
css: iconContainerStyles,
|
|
401
|
+
onClick: this.onClear,
|
|
402
|
+
"data-testid": testId && "".concat(testId, "--icon--container"),
|
|
403
|
+
tabIndex: -1,
|
|
404
|
+
type: "button"
|
|
405
|
+
}, (0, _react2.jsx)(_selectClear.default, {
|
|
406
|
+
size: "small",
|
|
407
|
+
primaryColor: "inherit",
|
|
408
|
+
label: clearControlLabel
|
|
409
|
+
})) : null);
|
|
410
|
+
}
|
|
411
|
+
}]);
|
|
412
|
+
return DateTimePickerComponent;
|
|
413
|
+
}(_react.default.Component);
|
|
414
|
+
(0, _defineProperty2.default)(DateTimePickerComponent, "defaultProps", dateTimePickerDefaultProps);
|
|
415
|
+
/**
|
|
416
|
+
* __Date time picker__
|
|
417
|
+
*
|
|
418
|
+
* A date time picker allows the user to select an associated date and time.
|
|
419
|
+
*
|
|
420
|
+
* - [Examples](https://atlassian.design/components/datetime-picker/examples)
|
|
421
|
+
* - [Code](https://atlassian.design/components/datetime-picker/code)
|
|
422
|
+
* - [Usage](https://atlassian.design/components/datetime-picker/usage)
|
|
423
|
+
*/
|
|
424
|
+
var DateTimePicker = (0, _analyticsNext.withAnalyticsContext)({
|
|
425
|
+
componentName: 'dateTimePicker',
|
|
426
|
+
packageName: packageName,
|
|
427
|
+
packageVersion: packageVersion
|
|
428
|
+
})((0, _analyticsNext.withAnalyticsEvents)({
|
|
429
|
+
onChange: (0, _analyticsNext.createAndFireEvent)('atlaskit')({
|
|
430
|
+
action: 'changed',
|
|
431
|
+
actionSubject: 'dateTimePicker',
|
|
432
|
+
attributes: {
|
|
433
|
+
componentName: 'dateTimePicker',
|
|
434
|
+
packageName: packageName,
|
|
435
|
+
packageVersion: packageVersion
|
|
436
|
+
}
|
|
437
|
+
})
|
|
438
|
+
})(DateTimePickerComponent));
|
|
439
|
+
var _default = exports.default = DateTimePicker;
|