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