@atlaskit/datetime-picker 12.8.0 → 12.8.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 +12 -0
- package/dist/cjs/components/date-picker.js +22 -17
- package/dist/cjs/components/date-time-picker.js +7 -7
- package/dist/cjs/components/time-picker.js +68 -90
- package/dist/cjs/internal/fixed-layer.js +2 -2
- package/dist/cjs/internal/index.js +3 -2
- package/dist/es2019/components/date-picker.js +15 -12
- package/dist/es2019/components/date-time-picker.js +5 -7
- package/dist/es2019/components/time-picker.js +47 -68
- package/dist/es2019/internal/index.js +3 -2
- package/dist/esm/components/date-picker.js +21 -18
- package/dist/esm/components/date-time-picker.js +7 -9
- package/dist/esm/components/time-picker.js +67 -88
- package/dist/esm/internal/fixed-layer.js +2 -2
- package/dist/esm/internal/index.js +3 -2
- package/dist/types/components/date-picker.d.ts +6 -1
- package/dist/types/components/date-time-picker.d.ts +0 -2
- package/dist/types/components/time-picker.d.ts +0 -18
- package/dist/types/internal/index.d.ts +3 -0
- package/dist/types-ts4.5/components/date-picker.d.ts +6 -1
- package/dist/types-ts4.5/components/date-time-picker.d.ts +0 -2
- package/dist/types-ts4.5/components/time-picker.d.ts +0 -18
- package/dist/types-ts4.5/internal/index.d.ts +3 -0
- package/package.json +4 -4
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
-
/* eslint-disable @repo/internal/react/use-noop */
|
|
4
3
|
import React from 'react';
|
|
5
4
|
|
|
6
5
|
// eslint-disable-next-line no-restricted-imports
|
|
@@ -17,10 +16,7 @@ import parseTime from '../internal/parse-time';
|
|
|
17
16
|
import { makeSingleValue } from '../internal/single-value';
|
|
18
17
|
import { convertTokens } from './utils';
|
|
19
18
|
const packageName = "@atlaskit/datetime-picker";
|
|
20
|
-
const packageVersion = "12.8.
|
|
21
|
-
|
|
22
|
-
/* eslint-disable react/no-unused-prop-types */
|
|
23
|
-
|
|
19
|
+
const packageVersion = "12.8.2";
|
|
24
20
|
const menuStyles = {
|
|
25
21
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
26
22
|
position: 'static',
|
|
@@ -51,9 +47,13 @@ const timePickerDefaultProps = {
|
|
|
51
47
|
isDisabled: false,
|
|
52
48
|
isInvalid: false,
|
|
53
49
|
name: '',
|
|
50
|
+
// These disables are here for proper typing when used as defaults. They
|
|
51
|
+
// should *not* use the `noop` function.
|
|
52
|
+
/* eslint-disable @repo/internal/react/use-noop */
|
|
54
53
|
onBlur: event => {},
|
|
55
54
|
onChange: value => {},
|
|
56
55
|
onFocus: event => {},
|
|
56
|
+
/* eslint-enable @repo/internal/react/use-noop */
|
|
57
57
|
parseInputValue: (time, timeFormat) => parseTime(time),
|
|
58
58
|
selectProps: {},
|
|
59
59
|
spacing: 'default',
|
|
@@ -72,8 +72,7 @@ class TimePicker extends React.Component {
|
|
|
72
72
|
isOpen: this.props.defaultIsOpen,
|
|
73
73
|
clearingFromIcon: false,
|
|
74
74
|
value: this.props.defaultValue,
|
|
75
|
-
isFocused: false
|
|
76
|
-
l10n: createLocalizationProvider(this.props.locale)
|
|
75
|
+
isFocused: false
|
|
77
76
|
});
|
|
78
77
|
// All state needs to be accessed via this function so that the state is mapped from props
|
|
79
78
|
// correctly to allow controlled/uncontrolled usage.
|
|
@@ -180,6 +179,39 @@ class TimePicker extends React.Component {
|
|
|
180
179
|
});
|
|
181
180
|
}
|
|
182
181
|
});
|
|
182
|
+
}
|
|
183
|
+
render() {
|
|
184
|
+
const {
|
|
185
|
+
appearance,
|
|
186
|
+
autoFocus,
|
|
187
|
+
formatDisplayLabel,
|
|
188
|
+
hideIcon,
|
|
189
|
+
id,
|
|
190
|
+
innerProps,
|
|
191
|
+
isDisabled,
|
|
192
|
+
locale,
|
|
193
|
+
name,
|
|
194
|
+
placeholder,
|
|
195
|
+
selectProps,
|
|
196
|
+
spacing,
|
|
197
|
+
testId,
|
|
198
|
+
isInvalid,
|
|
199
|
+
timeIsEditable,
|
|
200
|
+
timeFormat,
|
|
201
|
+
times
|
|
202
|
+
} = this.props;
|
|
203
|
+
const ICON_PADDING = 2;
|
|
204
|
+
const l10n = createLocalizationProvider(locale);
|
|
205
|
+
const {
|
|
206
|
+
value = '',
|
|
207
|
+
isOpen
|
|
208
|
+
} = this.getSafeState();
|
|
209
|
+
const {
|
|
210
|
+
styles: selectStyles = {},
|
|
211
|
+
...otherSelectProps
|
|
212
|
+
} = selectProps;
|
|
213
|
+
const SelectComponent = timeIsEditable ? CreatableSelect : Select;
|
|
214
|
+
|
|
183
215
|
/**
|
|
184
216
|
* There are multiple props that can change how the time is formatted.
|
|
185
217
|
* The priority of props used is:
|
|
@@ -187,14 +219,7 @@ class TimePicker extends React.Component {
|
|
|
187
219
|
* 2. timeFormat
|
|
188
220
|
* 3. locale
|
|
189
221
|
*/
|
|
190
|
-
|
|
191
|
-
const {
|
|
192
|
-
formatDisplayLabel,
|
|
193
|
-
timeFormat
|
|
194
|
-
} = this.props;
|
|
195
|
-
const {
|
|
196
|
-
l10n
|
|
197
|
-
} = this.getSafeState();
|
|
222
|
+
const formatTime = time => {
|
|
198
223
|
if (formatDisplayLabel) {
|
|
199
224
|
return formatDisplayLabel(time, timeFormat || defaultTimeFormat);
|
|
200
225
|
}
|
|
@@ -209,61 +234,15 @@ class TimePicker extends React.Component {
|
|
|
209
234
|
return format(date, convertTokens(timeFormat));
|
|
210
235
|
}
|
|
211
236
|
return l10n.formatTime(date);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
const {
|
|
215
|
-
placeholder
|
|
216
|
-
} = this.props;
|
|
217
|
-
if (placeholder) {
|
|
218
|
-
return placeholder;
|
|
219
|
-
}
|
|
220
|
-
const {
|
|
221
|
-
l10n
|
|
222
|
-
} = this.getSafeState();
|
|
223
|
-
return l10n.formatTime(placeholderDatetime);
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
227
|
-
if (this.props.locale !== nextProps.locale) {
|
|
228
|
-
this.setState({
|
|
229
|
-
l10n: createLocalizationProvider(nextProps.locale)
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
getOptions() {
|
|
234
|
-
return this.props.times.map(time => {
|
|
237
|
+
};
|
|
238
|
+
const options = times.map(time => {
|
|
235
239
|
return {
|
|
236
|
-
label:
|
|
240
|
+
label: formatTime(time),
|
|
237
241
|
value: time
|
|
238
242
|
};
|
|
239
243
|
});
|
|
240
|
-
}
|
|
241
|
-
render() {
|
|
242
|
-
const {
|
|
243
|
-
autoFocus,
|
|
244
|
-
hideIcon,
|
|
245
|
-
id,
|
|
246
|
-
innerProps,
|
|
247
|
-
isDisabled,
|
|
248
|
-
name,
|
|
249
|
-
selectProps,
|
|
250
|
-
spacing,
|
|
251
|
-
testId,
|
|
252
|
-
isInvalid,
|
|
253
|
-
timeIsEditable
|
|
254
|
-
} = this.props;
|
|
255
|
-
const ICON_PADDING = 2;
|
|
256
|
-
const {
|
|
257
|
-
value = '',
|
|
258
|
-
isOpen
|
|
259
|
-
} = this.getSafeState();
|
|
260
|
-
const {
|
|
261
|
-
styles: selectStyles = {},
|
|
262
|
-
...otherSelectProps
|
|
263
|
-
} = selectProps;
|
|
264
|
-
const SelectComponent = timeIsEditable ? CreatableSelect : Select;
|
|
265
244
|
const labelAndValue = value && {
|
|
266
|
-
label:
|
|
245
|
+
label: formatTime(value),
|
|
267
246
|
value
|
|
268
247
|
};
|
|
269
248
|
const SingleValue = makeSingleValue({
|
|
@@ -305,7 +284,7 @@ class TimePicker extends React.Component {
|
|
|
305
284
|
"data-testid": testId && `${testId}--input`,
|
|
306
285
|
onKeyDown: this.onSelectKeyDown
|
|
307
286
|
}), /*#__PURE__*/React.createElement(SelectComponent, _extends({
|
|
308
|
-
appearance:
|
|
287
|
+
appearance: appearance,
|
|
309
288
|
autoFocus: autoFocus,
|
|
310
289
|
components: selectComponents,
|
|
311
290
|
instanceId: id,
|
|
@@ -317,11 +296,11 @@ class TimePicker extends React.Component {
|
|
|
317
296
|
onBlur: this.onBlur,
|
|
318
297
|
onCreateOption: this.onCreateOption,
|
|
319
298
|
onChange: this.onChange,
|
|
320
|
-
options:
|
|
299
|
+
options: options,
|
|
321
300
|
onFocus: this.onFocus,
|
|
322
301
|
onMenuOpen: this.onMenuOpen,
|
|
323
302
|
onMenuClose: this.onMenuClose,
|
|
324
|
-
placeholder:
|
|
303
|
+
placeholder: placeholder || l10n.formatTime(placeholderDatetime),
|
|
325
304
|
styles: mergedStyles,
|
|
326
305
|
value: labelAndValue,
|
|
327
306
|
spacing: spacing
|
|
@@ -7,15 +7,13 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
9
|
import _extends from "@babel/runtime/helpers/extends";
|
|
10
|
-
function ownKeys(
|
|
11
|
-
function _objectSpread(
|
|
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
12
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
13
13
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
14
|
-
/* eslint-disable @repo/internal/react/use-noop */
|
|
15
14
|
/** @jsx jsx */
|
|
16
15
|
import { Component } from 'react';
|
|
17
16
|
import { css, jsx } from '@emotion/react';
|
|
18
|
-
// eslint-disable-next-line no-restricted-imports
|
|
19
17
|
import { format, isValid, lastDayOfMonth, parseISO } from 'date-fns';
|
|
20
18
|
import pick from 'lodash/pick';
|
|
21
19
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
@@ -31,10 +29,7 @@ import FixedLayer from '../internal/fixed-layer';
|
|
|
31
29
|
import { makeSingleValue } from '../internal/single-value';
|
|
32
30
|
import { convertTokens } from './utils';
|
|
33
31
|
var packageName = "@atlaskit/datetime-picker";
|
|
34
|
-
var packageVersion = "12.8.
|
|
35
|
-
|
|
36
|
-
/* eslint-disable react/no-unused-prop-types */
|
|
37
|
-
|
|
32
|
+
var packageVersion = "12.8.2";
|
|
38
33
|
function getValidDate(iso) {
|
|
39
34
|
var date = parseISO(iso);
|
|
40
35
|
return isValid(date) ? {
|
|
@@ -96,9 +91,13 @@ var datePickerDefaultProps = {
|
|
|
96
91
|
isDisabled: false,
|
|
97
92
|
isInvalid: false,
|
|
98
93
|
name: '',
|
|
94
|
+
// These disables are here for proper typing when used as defaults. They
|
|
95
|
+
// should *not* use the `noop` function.
|
|
96
|
+
/* eslint-disable @repo/internal/react/use-noop */
|
|
99
97
|
onBlur: function onBlur(event) {},
|
|
100
98
|
onChange: function onChange(value) {},
|
|
101
99
|
onFocus: function onFocus(event) {},
|
|
100
|
+
/* eslint-enable @repo/internal/react/use-noop */
|
|
102
101
|
selectProps: {},
|
|
103
102
|
spacing: 'default',
|
|
104
103
|
locale: 'en-US'
|
|
@@ -407,20 +406,12 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
407
406
|
selectInputValue: _this.props.selectProps.inputValue,
|
|
408
407
|
value: _this.props.value || _this.props.defaultValue,
|
|
409
408
|
calendarValue: _this.props.value || _this.props.defaultValue || getShortISOString(new Date()),
|
|
410
|
-
l10n: createLocalizationProvider(_this.props.locale)
|
|
409
|
+
l10n: createLocalizationProvider(_this.props.locale),
|
|
410
|
+
locale: _this.props.locale
|
|
411
411
|
};
|
|
412
412
|
return _this;
|
|
413
413
|
}
|
|
414
414
|
_createClass(DatePicker, [{
|
|
415
|
-
key: "UNSAFE_componentWillReceiveProps",
|
|
416
|
-
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
417
|
-
if (this.props.locale !== nextProps.locale) {
|
|
418
|
-
this.setState({
|
|
419
|
-
l10n: createLocalizationProvider(nextProps.locale)
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}, {
|
|
424
415
|
key: "render",
|
|
425
416
|
value: function render() {
|
|
426
417
|
var _this$props3 = this.props,
|
|
@@ -546,6 +537,18 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
546
537
|
})))
|
|
547
538
|
);
|
|
548
539
|
}
|
|
540
|
+
}], [{
|
|
541
|
+
key: "getDerivedStateFromProps",
|
|
542
|
+
value: function getDerivedStateFromProps(nextProps, prevState) {
|
|
543
|
+
if (nextProps.locale !== prevState.locale) {
|
|
544
|
+
return {
|
|
545
|
+
l10n: createLocalizationProvider(nextProps.locale),
|
|
546
|
+
locale: nextProps.locale
|
|
547
|
+
};
|
|
548
|
+
} else {
|
|
549
|
+
return null;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
549
552
|
}]);
|
|
550
553
|
return DatePicker;
|
|
551
554
|
}(Component);
|
|
@@ -8,13 +8,11 @@ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
9
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
10
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
-
function ownKeys(
|
|
12
|
-
function _objectSpread(
|
|
13
|
-
/* eslint-disable @repo/internal/react/use-noop */
|
|
11
|
+
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; }
|
|
12
|
+
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; }
|
|
14
13
|
/** @jsx jsx */
|
|
15
14
|
import React from 'react';
|
|
16
15
|
import { css, jsx } from '@emotion/react';
|
|
17
|
-
// eslint-disable-next-line no-restricted-imports
|
|
18
16
|
import { format, isValid, parseISO } from 'date-fns';
|
|
19
17
|
import pick from 'lodash/pick';
|
|
20
18
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
@@ -27,10 +25,7 @@ import DatePicker from './date-picker';
|
|
|
27
25
|
import TimePicker from './time-picker';
|
|
28
26
|
import { convertTokens } from './utils';
|
|
29
27
|
var packageName = "@atlaskit/datetime-picker";
|
|
30
|
-
var packageVersion = "12.8.
|
|
31
|
-
|
|
32
|
-
/* eslint-disable react/no-unused-prop-types */
|
|
33
|
-
|
|
28
|
+
var packageVersion = "12.8.2";
|
|
34
29
|
var isInvalidBorderStyles = css({
|
|
35
30
|
borderColor: "var(--ds-border-danger, ".concat(R400, ")")
|
|
36
31
|
});
|
|
@@ -133,9 +128,13 @@ var dateTimePickerDefaultProps = {
|
|
|
133
128
|
autoFocus: false,
|
|
134
129
|
isDisabled: false,
|
|
135
130
|
name: '',
|
|
131
|
+
// These disables are here for proper typing when used as defaults. They
|
|
132
|
+
// should *not* use the `noop` function.
|
|
133
|
+
/* eslint-disable @repo/internal/react/use-noop */
|
|
136
134
|
onBlur: function onBlur(event) {},
|
|
137
135
|
onChange: function onChange(value) {},
|
|
138
136
|
onFocus: function onFocus(event) {},
|
|
137
|
+
/* eslint-enable @repo/internal/react/use-noop */
|
|
139
138
|
innerProps: {},
|
|
140
139
|
id: '',
|
|
141
140
|
defaultValue: '',
|
|
@@ -165,7 +164,6 @@ var DateTimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
165
164
|
}
|
|
166
165
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
167
166
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
168
|
-
active: 0,
|
|
169
167
|
dateValue: '',
|
|
170
168
|
isFocused: false,
|
|
171
169
|
timeValue: '',
|
|
@@ -9,11 +9,10 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
9
9
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
10
10
|
var _excluded = ["selectProps"],
|
|
11
11
|
_excluded2 = ["styles"];
|
|
12
|
-
function ownKeys(
|
|
13
|
-
function _objectSpread(
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
14
14
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
15
15
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
16
|
-
/* eslint-disable @repo/internal/react/use-noop */
|
|
17
16
|
import React from 'react';
|
|
18
17
|
|
|
19
18
|
// eslint-disable-next-line no-restricted-imports
|
|
@@ -30,10 +29,7 @@ import parseTime from '../internal/parse-time';
|
|
|
30
29
|
import { makeSingleValue } from '../internal/single-value';
|
|
31
30
|
import { convertTokens } from './utils';
|
|
32
31
|
var packageName = "@atlaskit/datetime-picker";
|
|
33
|
-
var packageVersion = "12.8.
|
|
34
|
-
|
|
35
|
-
/* eslint-disable react/no-unused-prop-types */
|
|
36
|
-
|
|
32
|
+
var packageVersion = "12.8.2";
|
|
37
33
|
var menuStyles = {
|
|
38
34
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
39
35
|
position: 'static',
|
|
@@ -65,9 +61,13 @@ var timePickerDefaultProps = {
|
|
|
65
61
|
isDisabled: false,
|
|
66
62
|
isInvalid: false,
|
|
67
63
|
name: '',
|
|
64
|
+
// These disables are here for proper typing when used as defaults. They
|
|
65
|
+
// should *not* use the `noop` function.
|
|
66
|
+
/* eslint-disable @repo/internal/react/use-noop */
|
|
68
67
|
onBlur: function onBlur(event) {},
|
|
69
68
|
onChange: function onChange(value) {},
|
|
70
69
|
onFocus: function onFocus(event) {},
|
|
70
|
+
/* eslint-enable @repo/internal/react/use-noop */
|
|
71
71
|
parseInputValue: function parseInputValue(time, timeFormat) {
|
|
72
72
|
return parseTime(time);
|
|
73
73
|
},
|
|
@@ -94,8 +94,7 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
94
94
|
isOpen: _this.props.defaultIsOpen,
|
|
95
95
|
clearingFromIcon: false,
|
|
96
96
|
value: _this.props.defaultValue,
|
|
97
|
-
isFocused: false
|
|
98
|
-
l10n: createLocalizationProvider(_this.props.locale)
|
|
97
|
+
isFocused: false
|
|
99
98
|
});
|
|
100
99
|
// All state needs to be accessed via this function so that the state is mapped from props
|
|
101
100
|
// correctly to allow controlled/uncontrolled usage.
|
|
@@ -195,92 +194,72 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
195
194
|
});
|
|
196
195
|
}
|
|
197
196
|
});
|
|
198
|
-
/**
|
|
199
|
-
* There are multiple props that can change how the time is formatted.
|
|
200
|
-
* The priority of props used is:
|
|
201
|
-
* 1. formatDisplayLabel
|
|
202
|
-
* 2. timeFormat
|
|
203
|
-
* 3. locale
|
|
204
|
-
*/
|
|
205
|
-
_defineProperty(_assertThisInitialized(_this), "formatTime", function (time) {
|
|
206
|
-
var _this$props2 = _this.props,
|
|
207
|
-
formatDisplayLabel = _this$props2.formatDisplayLabel,
|
|
208
|
-
timeFormat = _this$props2.timeFormat;
|
|
209
|
-
var _this$getSafeState = _this.getSafeState(),
|
|
210
|
-
l10n = _this$getSafeState.l10n;
|
|
211
|
-
if (formatDisplayLabel) {
|
|
212
|
-
return formatDisplayLabel(time, timeFormat || defaultTimeFormat);
|
|
213
|
-
}
|
|
214
|
-
var date = parseTime(time);
|
|
215
|
-
if (!(date instanceof Date)) {
|
|
216
|
-
return '';
|
|
217
|
-
}
|
|
218
|
-
if (!isValid(date)) {
|
|
219
|
-
return time;
|
|
220
|
-
}
|
|
221
|
-
if (timeFormat) {
|
|
222
|
-
return format(date, convertTokens(timeFormat));
|
|
223
|
-
}
|
|
224
|
-
return l10n.formatTime(date);
|
|
225
|
-
});
|
|
226
|
-
_defineProperty(_assertThisInitialized(_this), "getPlaceholder", function () {
|
|
227
|
-
var placeholder = _this.props.placeholder;
|
|
228
|
-
if (placeholder) {
|
|
229
|
-
return placeholder;
|
|
230
|
-
}
|
|
231
|
-
var _this$getSafeState2 = _this.getSafeState(),
|
|
232
|
-
l10n = _this$getSafeState2.l10n;
|
|
233
|
-
return l10n.formatTime(placeholderDatetime);
|
|
234
|
-
});
|
|
235
197
|
return _this;
|
|
236
198
|
}
|
|
237
199
|
_createClass(TimePicker, [{
|
|
238
|
-
key: "UNSAFE_componentWillReceiveProps",
|
|
239
|
-
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
240
|
-
if (this.props.locale !== nextProps.locale) {
|
|
241
|
-
this.setState({
|
|
242
|
-
l10n: createLocalizationProvider(nextProps.locale)
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}, {
|
|
247
|
-
key: "getOptions",
|
|
248
|
-
value: function getOptions() {
|
|
249
|
-
var _this2 = this;
|
|
250
|
-
return this.props.times.map(function (time) {
|
|
251
|
-
return {
|
|
252
|
-
label: _this2.formatTime(time),
|
|
253
|
-
value: time
|
|
254
|
-
};
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
}, {
|
|
258
200
|
key: "render",
|
|
259
201
|
value: function render() {
|
|
260
|
-
var
|
|
261
|
-
var _this$
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
202
|
+
var _this2 = this;
|
|
203
|
+
var _this$props2 = this.props,
|
|
204
|
+
appearance = _this$props2.appearance,
|
|
205
|
+
autoFocus = _this$props2.autoFocus,
|
|
206
|
+
formatDisplayLabel = _this$props2.formatDisplayLabel,
|
|
207
|
+
hideIcon = _this$props2.hideIcon,
|
|
208
|
+
id = _this$props2.id,
|
|
209
|
+
innerProps = _this$props2.innerProps,
|
|
210
|
+
isDisabled = _this$props2.isDisabled,
|
|
211
|
+
locale = _this$props2.locale,
|
|
212
|
+
name = _this$props2.name,
|
|
213
|
+
placeholder = _this$props2.placeholder,
|
|
214
|
+
selectProps = _this$props2.selectProps,
|
|
215
|
+
spacing = _this$props2.spacing,
|
|
216
|
+
testId = _this$props2.testId,
|
|
217
|
+
isInvalid = _this$props2.isInvalid,
|
|
218
|
+
timeIsEditable = _this$props2.timeIsEditable,
|
|
219
|
+
timeFormat = _this$props2.timeFormat,
|
|
220
|
+
times = _this$props2.times;
|
|
273
221
|
var ICON_PADDING = 2;
|
|
274
|
-
var
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
222
|
+
var l10n = createLocalizationProvider(locale);
|
|
223
|
+
var _this$getSafeState = this.getSafeState(),
|
|
224
|
+
_this$getSafeState$va = _this$getSafeState.value,
|
|
225
|
+
value = _this$getSafeState$va === void 0 ? '' : _this$getSafeState$va,
|
|
226
|
+
isOpen = _this$getSafeState.isOpen;
|
|
278
227
|
var _selectProps$styles = selectProps.styles,
|
|
279
228
|
selectStyles = _selectProps$styles === void 0 ? {} : _selectProps$styles,
|
|
280
229
|
otherSelectProps = _objectWithoutProperties(selectProps, _excluded2);
|
|
281
230
|
var SelectComponent = timeIsEditable ? CreatableSelect : Select;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* There are multiple props that can change how the time is formatted.
|
|
234
|
+
* The priority of props used is:
|
|
235
|
+
* 1. formatDisplayLabel
|
|
236
|
+
* 2. timeFormat
|
|
237
|
+
* 3. locale
|
|
238
|
+
*/
|
|
239
|
+
var formatTime = function formatTime(time) {
|
|
240
|
+
if (formatDisplayLabel) {
|
|
241
|
+
return formatDisplayLabel(time, timeFormat || defaultTimeFormat);
|
|
242
|
+
}
|
|
243
|
+
var date = parseTime(time);
|
|
244
|
+
if (!(date instanceof Date)) {
|
|
245
|
+
return '';
|
|
246
|
+
}
|
|
247
|
+
if (!isValid(date)) {
|
|
248
|
+
return time;
|
|
249
|
+
}
|
|
250
|
+
if (timeFormat) {
|
|
251
|
+
return format(date, convertTokens(timeFormat));
|
|
252
|
+
}
|
|
253
|
+
return l10n.formatTime(date);
|
|
254
|
+
};
|
|
255
|
+
var options = times.map(function (time) {
|
|
256
|
+
return {
|
|
257
|
+
label: formatTime(time),
|
|
258
|
+
value: time
|
|
259
|
+
};
|
|
260
|
+
});
|
|
282
261
|
var labelAndValue = value && {
|
|
283
|
-
label:
|
|
262
|
+
label: formatTime(value),
|
|
284
263
|
value: value
|
|
285
264
|
};
|
|
286
265
|
var SingleValue = makeSingleValue({
|
|
@@ -302,7 +281,7 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
302
281
|
return _objectSpread(_objectSpread(_objectSpread({}, base), menuStyles), {}, {
|
|
303
282
|
// Fixed positioned elements no longer inherit width from their parent, so we must explicitly set the
|
|
304
283
|
// menu width to the width of our container
|
|
305
|
-
width:
|
|
284
|
+
width: _this2.containerRef ? _this2.containerRef.getBoundingClientRect().width : 'auto'
|
|
306
285
|
});
|
|
307
286
|
},
|
|
308
287
|
indicatorsContainer: function indicatorsContainer(base) {
|
|
@@ -322,7 +301,7 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
322
301
|
"data-testid": testId && "".concat(testId, "--input"),
|
|
323
302
|
onKeyDown: this.onSelectKeyDown
|
|
324
303
|
}), /*#__PURE__*/React.createElement(SelectComponent, _extends({
|
|
325
|
-
appearance:
|
|
304
|
+
appearance: appearance,
|
|
326
305
|
autoFocus: autoFocus,
|
|
327
306
|
components: selectComponents,
|
|
328
307
|
instanceId: id,
|
|
@@ -334,11 +313,11 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
334
313
|
onBlur: this.onBlur,
|
|
335
314
|
onCreateOption: this.onCreateOption,
|
|
336
315
|
onChange: this.onChange,
|
|
337
|
-
options:
|
|
316
|
+
options: options,
|
|
338
317
|
onFocus: this.onFocus,
|
|
339
318
|
onMenuOpen: this.onMenuOpen,
|
|
340
319
|
onMenuClose: this.onMenuClose,
|
|
341
|
-
placeholder:
|
|
320
|
+
placeholder: placeholder || l10n.formatTime(placeholderDatetime),
|
|
342
321
|
styles: mergedStyles,
|
|
343
322
|
value: labelAndValue,
|
|
344
323
|
spacing: spacing
|
|
@@ -5,8 +5,8 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
function ownKeys(
|
|
9
|
-
function _objectSpread(
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
11
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
12
|
import React from 'react';
|
|
@@ -166,6 +166,7 @@ interface State {
|
|
|
166
166
|
calendarValue: string;
|
|
167
167
|
selectInputValue: string;
|
|
168
168
|
l10n: LocalizationProvider;
|
|
169
|
+
locale: string;
|
|
169
170
|
}
|
|
170
171
|
declare const datePickerDefaultProps: {
|
|
171
172
|
appearance: Appearance;
|
|
@@ -213,7 +214,10 @@ declare class DatePicker extends Component<DatePickerProps, State> {
|
|
|
213
214
|
calendarRef: CalendarRef | null;
|
|
214
215
|
containerRef: HTMLElement | null;
|
|
215
216
|
constructor(props: any);
|
|
216
|
-
|
|
217
|
+
static getDerivedStateFromProps(nextProps: Readonly<DatePickerProps>, prevState: State): {
|
|
218
|
+
l10n: LocalizationProvider;
|
|
219
|
+
locale: string;
|
|
220
|
+
} | null;
|
|
217
221
|
getSafeState: () => {
|
|
218
222
|
inputValue: any;
|
|
219
223
|
value: string;
|
|
@@ -223,6 +227,7 @@ declare class DatePicker extends Component<DatePickerProps, State> {
|
|
|
223
227
|
calendarValue: string;
|
|
224
228
|
selectInputValue: string;
|
|
225
229
|
l10n: LocalizationProvider;
|
|
230
|
+
locale: string;
|
|
226
231
|
};
|
|
227
232
|
isDateDisabled: (date: string) => boolean;
|
|
228
233
|
onCalendarChange: ({ iso }: {
|
|
@@ -117,7 +117,6 @@ export interface DateTimePickerBaseProps extends WithAnalyticsEventsProps {
|
|
|
117
117
|
}
|
|
118
118
|
type DateTimePickerProps = typeof dateTimePickerDefaultProps & DateTimePickerBaseProps;
|
|
119
119
|
interface State {
|
|
120
|
-
active: 0 | 1 | 2;
|
|
121
120
|
dateValue: string;
|
|
122
121
|
isFocused: boolean;
|
|
123
122
|
timeValue: string;
|
|
@@ -175,7 +174,6 @@ declare class DateTimePicker extends React.Component<DateTimePickerProps, State>
|
|
|
175
174
|
timeValue: string;
|
|
176
175
|
zoneValue: string;
|
|
177
176
|
value: string;
|
|
178
|
-
active: 0 | 1 | 2;
|
|
179
177
|
isFocused: boolean;
|
|
180
178
|
};
|
|
181
179
|
parseValue(value: string, dateValue: string, timeValue: string, zoneValue: string): {
|