@atlaskit/datetime-picker 12.8.1 → 12.9.0
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 +16 -12
- package/dist/cjs/components/date-time-picker.js +1 -1
- package/dist/cjs/components/time-picker.js +61 -82
- package/dist/es2019/components/date-picker.js +12 -8
- package/dist/es2019/components/date-time-picker.js +1 -1
- package/dist/es2019/components/time-picker.js +43 -64
- package/dist/esm/components/date-picker.js +16 -12
- package/dist/esm/components/date-time-picker.js +1 -1
- package/dist/esm/components/time-picker.js +61 -82
- package/dist/types/components/date-picker.d.ts +11 -6
- package/dist/types/components/time-picker.d.ts +0 -18
- package/dist/types/types.d.ts +0 -1
- package/dist/types-ts4.5/components/date-picker.d.ts +11 -6
- package/dist/types-ts4.5/components/time-picker.d.ts +0 -18
- package/dist/types-ts4.5/types.d.ts +0 -1
- package/package.json +2 -2
- package/report.api.md +5 -8
- package/tmp/api-report-tmp.d.ts +5 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/datetime-picker
|
|
2
2
|
|
|
3
|
+
## 12.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`4afff68f652`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4afff68f652) - Make typing more complete and accurate for date picker.
|
|
8
|
+
|
|
9
|
+
## 12.8.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`829d92bcf37`](https://bitbucket.org/atlassian/atlassian-frontend/commits/829d92bcf37) - Remove out of date lifecycle methods in favor of up to date methods.
|
|
14
|
+
|
|
3
15
|
## 12.8.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -38,7 +38,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
38
38
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
39
39
|
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; } } /** @jsx jsx */
|
|
40
40
|
var packageName = "@atlaskit/datetime-picker";
|
|
41
|
-
var packageVersion = "12.
|
|
41
|
+
var packageVersion = "12.9.0";
|
|
42
42
|
function getValidDate(iso) {
|
|
43
43
|
var date = (0, _dateFns.parseISO)(iso);
|
|
44
44
|
return (0, _dateFns.isValid)(date) ? {
|
|
@@ -412,23 +412,15 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
412
412
|
isOpen: _this.props.defaultIsOpen,
|
|
413
413
|
isFocused: false,
|
|
414
414
|
clearingFromIcon: false,
|
|
415
|
-
selectInputValue: _this.props.selectProps.inputValue,
|
|
415
|
+
selectInputValue: _this.props.selectProps.inputValue || '',
|
|
416
416
|
value: _this.props.value || _this.props.defaultValue,
|
|
417
417
|
calendarValue: _this.props.value || _this.props.defaultValue || getShortISOString(new Date()),
|
|
418
|
-
l10n: (0, _locale.createLocalizationProvider)(_this.props.locale)
|
|
418
|
+
l10n: (0, _locale.createLocalizationProvider)(_this.props.locale),
|
|
419
|
+
locale: _this.props.locale
|
|
419
420
|
};
|
|
420
421
|
return _this;
|
|
421
422
|
}
|
|
422
423
|
(0, _createClass2.default)(DatePicker, [{
|
|
423
|
-
key: "UNSAFE_componentWillReceiveProps",
|
|
424
|
-
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
425
|
-
if (this.props.locale !== nextProps.locale) {
|
|
426
|
-
this.setState({
|
|
427
|
-
l10n: (0, _locale.createLocalizationProvider)(nextProps.locale)
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}, {
|
|
432
424
|
key: "render",
|
|
433
425
|
value: function render() {
|
|
434
426
|
var _this$props3 = this.props,
|
|
@@ -554,6 +546,18 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
554
546
|
})))
|
|
555
547
|
);
|
|
556
548
|
}
|
|
549
|
+
}], [{
|
|
550
|
+
key: "getDerivedStateFromProps",
|
|
551
|
+
value: function getDerivedStateFromProps(nextProps, prevState) {
|
|
552
|
+
if (nextProps.locale !== prevState.locale) {
|
|
553
|
+
return {
|
|
554
|
+
l10n: (0, _locale.createLocalizationProvider)(nextProps.locale),
|
|
555
|
+
locale: nextProps.locale
|
|
556
|
+
};
|
|
557
|
+
} else {
|
|
558
|
+
return null;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
557
561
|
}]);
|
|
558
562
|
return DatePicker;
|
|
559
563
|
}(_react.Component);
|
|
@@ -31,7 +31,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
31
31
|
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; }
|
|
32
32
|
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; } /** @jsx jsx */
|
|
33
33
|
var packageName = "@atlaskit/datetime-picker";
|
|
34
|
-
var packageVersion = "12.
|
|
34
|
+
var packageVersion = "12.9.0";
|
|
35
35
|
var isInvalidBorderStyles = (0, _react2.css)({
|
|
36
36
|
borderColor: "var(--ds-border-danger, ".concat(_colors.R400, ")")
|
|
37
37
|
});
|
|
@@ -37,7 +37,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
37
37
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
38
38
|
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; } }
|
|
39
39
|
var packageName = "@atlaskit/datetime-picker";
|
|
40
|
-
var packageVersion = "12.
|
|
40
|
+
var packageVersion = "12.9.0";
|
|
41
41
|
var menuStyles = {
|
|
42
42
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
43
43
|
position: 'static',
|
|
@@ -102,8 +102,7 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
102
102
|
isOpen: _this.props.defaultIsOpen,
|
|
103
103
|
clearingFromIcon: false,
|
|
104
104
|
value: _this.props.defaultValue,
|
|
105
|
-
isFocused: false
|
|
106
|
-
l10n: (0, _locale.createLocalizationProvider)(_this.props.locale)
|
|
105
|
+
isFocused: false
|
|
107
106
|
});
|
|
108
107
|
// All state needs to be accessed via this function so that the state is mapped from props
|
|
109
108
|
// correctly to allow controlled/uncontrolled usage.
|
|
@@ -203,92 +202,72 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
203
202
|
});
|
|
204
203
|
}
|
|
205
204
|
});
|
|
206
|
-
/**
|
|
207
|
-
* There are multiple props that can change how the time is formatted.
|
|
208
|
-
* The priority of props used is:
|
|
209
|
-
* 1. formatDisplayLabel
|
|
210
|
-
* 2. timeFormat
|
|
211
|
-
* 3. locale
|
|
212
|
-
*/
|
|
213
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "formatTime", function (time) {
|
|
214
|
-
var _this$props2 = _this.props,
|
|
215
|
-
formatDisplayLabel = _this$props2.formatDisplayLabel,
|
|
216
|
-
timeFormat = _this$props2.timeFormat;
|
|
217
|
-
var _this$getSafeState = _this.getSafeState(),
|
|
218
|
-
l10n = _this$getSafeState.l10n;
|
|
219
|
-
if (formatDisplayLabel) {
|
|
220
|
-
return formatDisplayLabel(time, timeFormat || _internal.defaultTimeFormat);
|
|
221
|
-
}
|
|
222
|
-
var date = (0, _parseTime.default)(time);
|
|
223
|
-
if (!(date instanceof Date)) {
|
|
224
|
-
return '';
|
|
225
|
-
}
|
|
226
|
-
if (!(0, _dateFns.isValid)(date)) {
|
|
227
|
-
return time;
|
|
228
|
-
}
|
|
229
|
-
if (timeFormat) {
|
|
230
|
-
return (0, _dateFns.format)(date, (0, _utils.convertTokens)(timeFormat));
|
|
231
|
-
}
|
|
232
|
-
return l10n.formatTime(date);
|
|
233
|
-
});
|
|
234
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getPlaceholder", function () {
|
|
235
|
-
var placeholder = _this.props.placeholder;
|
|
236
|
-
if (placeholder) {
|
|
237
|
-
return placeholder;
|
|
238
|
-
}
|
|
239
|
-
var _this$getSafeState2 = _this.getSafeState(),
|
|
240
|
-
l10n = _this$getSafeState2.l10n;
|
|
241
|
-
return l10n.formatTime(_internal.placeholderDatetime);
|
|
242
|
-
});
|
|
243
205
|
return _this;
|
|
244
206
|
}
|
|
245
207
|
(0, _createClass2.default)(TimePicker, [{
|
|
246
|
-
key: "UNSAFE_componentWillReceiveProps",
|
|
247
|
-
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
248
|
-
if (this.props.locale !== nextProps.locale) {
|
|
249
|
-
this.setState({
|
|
250
|
-
l10n: (0, _locale.createLocalizationProvider)(nextProps.locale)
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}, {
|
|
255
|
-
key: "getOptions",
|
|
256
|
-
value: function getOptions() {
|
|
257
|
-
var _this2 = this;
|
|
258
|
-
return this.props.times.map(function (time) {
|
|
259
|
-
return {
|
|
260
|
-
label: _this2.formatTime(time),
|
|
261
|
-
value: time
|
|
262
|
-
};
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
}, {
|
|
266
208
|
key: "render",
|
|
267
209
|
value: function render() {
|
|
268
|
-
var
|
|
269
|
-
var _this$
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
210
|
+
var _this2 = this;
|
|
211
|
+
var _this$props2 = this.props,
|
|
212
|
+
appearance = _this$props2.appearance,
|
|
213
|
+
autoFocus = _this$props2.autoFocus,
|
|
214
|
+
formatDisplayLabel = _this$props2.formatDisplayLabel,
|
|
215
|
+
hideIcon = _this$props2.hideIcon,
|
|
216
|
+
id = _this$props2.id,
|
|
217
|
+
innerProps = _this$props2.innerProps,
|
|
218
|
+
isDisabled = _this$props2.isDisabled,
|
|
219
|
+
locale = _this$props2.locale,
|
|
220
|
+
name = _this$props2.name,
|
|
221
|
+
placeholder = _this$props2.placeholder,
|
|
222
|
+
selectProps = _this$props2.selectProps,
|
|
223
|
+
spacing = _this$props2.spacing,
|
|
224
|
+
testId = _this$props2.testId,
|
|
225
|
+
isInvalid = _this$props2.isInvalid,
|
|
226
|
+
timeIsEditable = _this$props2.timeIsEditable,
|
|
227
|
+
timeFormat = _this$props2.timeFormat,
|
|
228
|
+
times = _this$props2.times;
|
|
281
229
|
var ICON_PADDING = 2;
|
|
282
|
-
var
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
230
|
+
var l10n = (0, _locale.createLocalizationProvider)(locale);
|
|
231
|
+
var _this$getSafeState = this.getSafeState(),
|
|
232
|
+
_this$getSafeState$va = _this$getSafeState.value,
|
|
233
|
+
value = _this$getSafeState$va === void 0 ? '' : _this$getSafeState$va,
|
|
234
|
+
isOpen = _this$getSafeState.isOpen;
|
|
286
235
|
var _selectProps$styles = selectProps.styles,
|
|
287
236
|
selectStyles = _selectProps$styles === void 0 ? {} : _selectProps$styles,
|
|
288
237
|
otherSelectProps = (0, _objectWithoutProperties2.default)(selectProps, _excluded2);
|
|
289
238
|
var SelectComponent = timeIsEditable ? _select.CreatableSelect : _select.default;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* There are multiple props that can change how the time is formatted.
|
|
242
|
+
* The priority of props used is:
|
|
243
|
+
* 1. formatDisplayLabel
|
|
244
|
+
* 2. timeFormat
|
|
245
|
+
* 3. locale
|
|
246
|
+
*/
|
|
247
|
+
var formatTime = function formatTime(time) {
|
|
248
|
+
if (formatDisplayLabel) {
|
|
249
|
+
return formatDisplayLabel(time, timeFormat || _internal.defaultTimeFormat);
|
|
250
|
+
}
|
|
251
|
+
var date = (0, _parseTime.default)(time);
|
|
252
|
+
if (!(date instanceof Date)) {
|
|
253
|
+
return '';
|
|
254
|
+
}
|
|
255
|
+
if (!(0, _dateFns.isValid)(date)) {
|
|
256
|
+
return time;
|
|
257
|
+
}
|
|
258
|
+
if (timeFormat) {
|
|
259
|
+
return (0, _dateFns.format)(date, (0, _utils.convertTokens)(timeFormat));
|
|
260
|
+
}
|
|
261
|
+
return l10n.formatTime(date);
|
|
262
|
+
};
|
|
263
|
+
var options = times.map(function (time) {
|
|
264
|
+
return {
|
|
265
|
+
label: formatTime(time),
|
|
266
|
+
value: time
|
|
267
|
+
};
|
|
268
|
+
});
|
|
290
269
|
var labelAndValue = value && {
|
|
291
|
-
label:
|
|
270
|
+
label: formatTime(value),
|
|
292
271
|
value: value
|
|
293
272
|
};
|
|
294
273
|
var SingleValue = (0, _singleValue.makeSingleValue)({
|
|
@@ -310,7 +289,7 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
310
289
|
return _objectSpread(_objectSpread(_objectSpread({}, base), menuStyles), {}, {
|
|
311
290
|
// Fixed positioned elements no longer inherit width from their parent, so we must explicitly set the
|
|
312
291
|
// menu width to the width of our container
|
|
313
|
-
width:
|
|
292
|
+
width: _this2.containerRef ? _this2.containerRef.getBoundingClientRect().width : 'auto'
|
|
314
293
|
});
|
|
315
294
|
},
|
|
316
295
|
indicatorsContainer: function indicatorsContainer(base) {
|
|
@@ -330,7 +309,7 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
330
309
|
"data-testid": testId && "".concat(testId, "--input"),
|
|
331
310
|
onKeyDown: this.onSelectKeyDown
|
|
332
311
|
}), /*#__PURE__*/_react.default.createElement(SelectComponent, (0, _extends2.default)({
|
|
333
|
-
appearance:
|
|
312
|
+
appearance: appearance,
|
|
334
313
|
autoFocus: autoFocus,
|
|
335
314
|
components: selectComponents,
|
|
336
315
|
instanceId: id,
|
|
@@ -342,11 +321,11 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
342
321
|
onBlur: this.onBlur,
|
|
343
322
|
onCreateOption: this.onCreateOption,
|
|
344
323
|
onChange: this.onChange,
|
|
345
|
-
options:
|
|
324
|
+
options: options,
|
|
346
325
|
onFocus: this.onFocus,
|
|
347
326
|
onMenuOpen: this.onMenuOpen,
|
|
348
327
|
onMenuClose: this.onMenuClose,
|
|
349
|
-
placeholder:
|
|
328
|
+
placeholder: placeholder || l10n.formatTime(_internal.placeholderDatetime),
|
|
350
329
|
styles: mergedStyles,
|
|
351
330
|
value: labelAndValue,
|
|
352
331
|
spacing: spacing
|
|
@@ -18,7 +18,7 @@ import FixedLayer from '../internal/fixed-layer';
|
|
|
18
18
|
import { makeSingleValue } from '../internal/single-value';
|
|
19
19
|
import { convertTokens } from './utils';
|
|
20
20
|
const packageName = "@atlaskit/datetime-picker";
|
|
21
|
-
const packageVersion = "12.
|
|
21
|
+
const packageVersion = "12.9.0";
|
|
22
22
|
function getValidDate(iso) {
|
|
23
23
|
const date = parseISO(iso);
|
|
24
24
|
return isValid(date) ? {
|
|
@@ -401,17 +401,21 @@ class DatePicker extends Component {
|
|
|
401
401
|
isOpen: this.props.defaultIsOpen,
|
|
402
402
|
isFocused: false,
|
|
403
403
|
clearingFromIcon: false,
|
|
404
|
-
selectInputValue: this.props.selectProps.inputValue,
|
|
404
|
+
selectInputValue: this.props.selectProps.inputValue || '',
|
|
405
405
|
value: this.props.value || this.props.defaultValue,
|
|
406
406
|
calendarValue: this.props.value || this.props.defaultValue || getShortISOString(new Date()),
|
|
407
|
-
l10n: createLocalizationProvider(this.props.locale)
|
|
407
|
+
l10n: createLocalizationProvider(this.props.locale),
|
|
408
|
+
locale: this.props.locale
|
|
408
409
|
};
|
|
409
410
|
}
|
|
410
|
-
|
|
411
|
-
if (
|
|
412
|
-
|
|
413
|
-
l10n: createLocalizationProvider(nextProps.locale)
|
|
414
|
-
|
|
411
|
+
static getDerivedStateFromProps(nextProps, prevState) {
|
|
412
|
+
if (nextProps.locale !== prevState.locale) {
|
|
413
|
+
return {
|
|
414
|
+
l10n: createLocalizationProvider(nextProps.locale),
|
|
415
|
+
locale: nextProps.locale
|
|
416
|
+
};
|
|
417
|
+
} else {
|
|
418
|
+
return null;
|
|
415
419
|
}
|
|
416
420
|
}
|
|
417
421
|
render() {
|
|
@@ -15,7 +15,7 @@ import DatePicker from './date-picker';
|
|
|
15
15
|
import TimePicker from './time-picker';
|
|
16
16
|
import { convertTokens } from './utils';
|
|
17
17
|
const packageName = "@atlaskit/datetime-picker";
|
|
18
|
-
const packageVersion = "12.
|
|
18
|
+
const packageVersion = "12.9.0";
|
|
19
19
|
const isInvalidBorderStyles = css({
|
|
20
20
|
borderColor: `var(--ds-border-danger, ${R400})`
|
|
21
21
|
});
|
|
@@ -16,7 +16,7 @@ import parseTime from '../internal/parse-time';
|
|
|
16
16
|
import { makeSingleValue } from '../internal/single-value';
|
|
17
17
|
import { convertTokens } from './utils';
|
|
18
18
|
const packageName = "@atlaskit/datetime-picker";
|
|
19
|
-
const packageVersion = "12.
|
|
19
|
+
const packageVersion = "12.9.0";
|
|
20
20
|
const menuStyles = {
|
|
21
21
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
22
22
|
position: 'static',
|
|
@@ -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
|
|
@@ -29,7 +29,7 @@ import FixedLayer from '../internal/fixed-layer';
|
|
|
29
29
|
import { makeSingleValue } from '../internal/single-value';
|
|
30
30
|
import { convertTokens } from './utils';
|
|
31
31
|
var packageName = "@atlaskit/datetime-picker";
|
|
32
|
-
var packageVersion = "12.
|
|
32
|
+
var packageVersion = "12.9.0";
|
|
33
33
|
function getValidDate(iso) {
|
|
34
34
|
var date = parseISO(iso);
|
|
35
35
|
return isValid(date) ? {
|
|
@@ -403,23 +403,15 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
403
403
|
isOpen: _this.props.defaultIsOpen,
|
|
404
404
|
isFocused: false,
|
|
405
405
|
clearingFromIcon: false,
|
|
406
|
-
selectInputValue: _this.props.selectProps.inputValue,
|
|
406
|
+
selectInputValue: _this.props.selectProps.inputValue || '',
|
|
407
407
|
value: _this.props.value || _this.props.defaultValue,
|
|
408
408
|
calendarValue: _this.props.value || _this.props.defaultValue || getShortISOString(new Date()),
|
|
409
|
-
l10n: createLocalizationProvider(_this.props.locale)
|
|
409
|
+
l10n: createLocalizationProvider(_this.props.locale),
|
|
410
|
+
locale: _this.props.locale
|
|
410
411
|
};
|
|
411
412
|
return _this;
|
|
412
413
|
}
|
|
413
414
|
_createClass(DatePicker, [{
|
|
414
|
-
key: "UNSAFE_componentWillReceiveProps",
|
|
415
|
-
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
416
|
-
if (this.props.locale !== nextProps.locale) {
|
|
417
|
-
this.setState({
|
|
418
|
-
l10n: createLocalizationProvider(nextProps.locale)
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}, {
|
|
423
415
|
key: "render",
|
|
424
416
|
value: function render() {
|
|
425
417
|
var _this$props3 = this.props,
|
|
@@ -545,6 +537,18 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
545
537
|
})))
|
|
546
538
|
);
|
|
547
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
|
+
}
|
|
548
552
|
}]);
|
|
549
553
|
return DatePicker;
|
|
550
554
|
}(Component);
|
|
@@ -25,7 +25,7 @@ import DatePicker from './date-picker';
|
|
|
25
25
|
import TimePicker from './time-picker';
|
|
26
26
|
import { convertTokens } from './utils';
|
|
27
27
|
var packageName = "@atlaskit/datetime-picker";
|
|
28
|
-
var packageVersion = "12.
|
|
28
|
+
var packageVersion = "12.9.0";
|
|
29
29
|
var isInvalidBorderStyles = css({
|
|
30
30
|
borderColor: "var(--ds-border-danger, ".concat(R400, ")")
|
|
31
31
|
});
|
|
@@ -29,7 +29,7 @@ import parseTime from '../internal/parse-time';
|
|
|
29
29
|
import { makeSingleValue } from '../internal/single-value';
|
|
30
30
|
import { convertTokens } from './utils';
|
|
31
31
|
var packageName = "@atlaskit/datetime-picker";
|
|
32
|
-
var packageVersion = "12.
|
|
32
|
+
var packageVersion = "12.9.0";
|
|
33
33
|
var menuStyles = {
|
|
34
34
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
35
35
|
position: 'static',
|
|
@@ -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
|
|
@@ -4,8 +4,8 @@ import { jsx } from '@emotion/react';
|
|
|
4
4
|
import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
5
5
|
import { CalendarRef } from '@atlaskit/calendar';
|
|
6
6
|
import { LocalizationProvider } from '@atlaskit/locale';
|
|
7
|
-
import { ActionMeta, DropdownIndicatorProps, OptionType, ValueType } from '@atlaskit/select';
|
|
8
|
-
import { Appearance,
|
|
7
|
+
import { ActionMeta, DropdownIndicatorProps, InputActionMeta, OptionType, SelectProps, ValueType } from '@atlaskit/select';
|
|
8
|
+
import { Appearance, Spacing } from '../types';
|
|
9
9
|
export interface DatePickerBaseProps extends WithAnalyticsEventsProps {
|
|
10
10
|
/**
|
|
11
11
|
* Set the appearance of the picker.
|
|
@@ -103,7 +103,7 @@ export interface DatePickerBaseProps extends WithAnalyticsEventsProps {
|
|
|
103
103
|
* Props to apply to the select. This can be used to set options such as placeholder text.
|
|
104
104
|
* See [the `Select` documentation for further information](/components/select).
|
|
105
105
|
*/
|
|
106
|
-
selectProps?: SelectProps
|
|
106
|
+
selectProps?: SelectProps<any>;
|
|
107
107
|
/**
|
|
108
108
|
* The spacing for the select control.
|
|
109
109
|
*
|
|
@@ -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,9 +214,12 @@ 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
|
-
inputValue
|
|
222
|
+
inputValue?: string | undefined;
|
|
219
223
|
value: string;
|
|
220
224
|
isOpen: boolean;
|
|
221
225
|
isFocused: boolean;
|
|
@@ -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 }: {
|
|
@@ -241,7 +246,7 @@ declare class DatePicker extends Component<DatePickerProps, State> {
|
|
|
241
246
|
onClear: () => void;
|
|
242
247
|
onSelectChange: (value: ValueType<OptionType>, action: ActionMeta) => void;
|
|
243
248
|
refCalendar: (ref: CalendarRef | null) => void;
|
|
244
|
-
handleSelectInputChange: (selectInputValue: string, actionMeta:
|
|
249
|
+
handleSelectInputChange: (selectInputValue: string, actionMeta: InputActionMeta) => void;
|
|
245
250
|
getContainerRef: (ref: HTMLElement | null) => void;
|
|
246
251
|
/**
|
|
247
252
|
* There are two props that can change how the date is parsed.
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
3
|
-
import { LocalizationProvider } from '@atlaskit/locale';
|
|
4
3
|
import { ActionMeta, OptionType, SelectProps, ValueType } from '@atlaskit/select';
|
|
5
4
|
import { Appearance, Spacing } from '../types';
|
|
6
|
-
interface Option {
|
|
7
|
-
label: string;
|
|
8
|
-
value: string;
|
|
9
|
-
}
|
|
10
5
|
export interface TimePickerBaseProps extends WithAnalyticsEventsProps {
|
|
11
6
|
/**
|
|
12
7
|
* Set the appearance of the picker.
|
|
@@ -123,7 +118,6 @@ interface State {
|
|
|
123
118
|
clearingFromIcon: boolean;
|
|
124
119
|
value: string;
|
|
125
120
|
isFocused: boolean;
|
|
126
|
-
l10n: LocalizationProvider;
|
|
127
121
|
}
|
|
128
122
|
declare const timePickerDefaultProps: {
|
|
129
123
|
appearance: Appearance;
|
|
@@ -174,11 +168,8 @@ declare class TimePicker extends React.Component<TimePickerProps, State> {
|
|
|
174
168
|
clearingFromIcon: boolean;
|
|
175
169
|
value: string;
|
|
176
170
|
isFocused: boolean;
|
|
177
|
-
l10n: LocalizationProvider;
|
|
178
171
|
};
|
|
179
|
-
UNSAFE_componentWillReceiveProps(nextProps: TimePickerProps): void;
|
|
180
172
|
getSafeState: () => State;
|
|
181
|
-
getOptions(): Array<Option>;
|
|
182
173
|
onChange: (newValue: ValueType<OptionType> | string, action?: ActionMeta<OptionType>) => void;
|
|
183
174
|
/**
|
|
184
175
|
* Only allow custom times if timeIsEditable prop is true
|
|
@@ -190,15 +181,6 @@ declare class TimePicker extends React.Component<TimePickerProps, State> {
|
|
|
190
181
|
onBlur: (event: React.FocusEvent<HTMLElement>) => void;
|
|
191
182
|
onFocus: (event: React.FocusEvent<HTMLElement>) => void;
|
|
192
183
|
onSelectKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
193
|
-
/**
|
|
194
|
-
* There are multiple props that can change how the time is formatted.
|
|
195
|
-
* The priority of props used is:
|
|
196
|
-
* 1. formatDisplayLabel
|
|
197
|
-
* 2. timeFormat
|
|
198
|
-
* 3. locale
|
|
199
|
-
*/
|
|
200
|
-
formatTime: (time: string) => string;
|
|
201
|
-
getPlaceholder: () => string;
|
|
202
184
|
render(): JSX.Element;
|
|
203
185
|
}
|
|
204
186
|
export { TimePicker as TimePickerWithoutAnalytics };
|
package/dist/types/types.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { jsx } from '@emotion/react';
|
|
|
4
4
|
import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
5
5
|
import { CalendarRef } from '@atlaskit/calendar';
|
|
6
6
|
import { LocalizationProvider } from '@atlaskit/locale';
|
|
7
|
-
import { ActionMeta, DropdownIndicatorProps, OptionType, ValueType } from '@atlaskit/select';
|
|
8
|
-
import { Appearance,
|
|
7
|
+
import { ActionMeta, DropdownIndicatorProps, InputActionMeta, OptionType, SelectProps, ValueType } from '@atlaskit/select';
|
|
8
|
+
import { Appearance, Spacing } from '../types';
|
|
9
9
|
export interface DatePickerBaseProps extends WithAnalyticsEventsProps {
|
|
10
10
|
/**
|
|
11
11
|
* Set the appearance of the picker.
|
|
@@ -103,7 +103,7 @@ export interface DatePickerBaseProps extends WithAnalyticsEventsProps {
|
|
|
103
103
|
* Props to apply to the select. This can be used to set options such as placeholder text.
|
|
104
104
|
* See [the `Select` documentation for further information](/components/select).
|
|
105
105
|
*/
|
|
106
|
-
selectProps?: SelectProps
|
|
106
|
+
selectProps?: SelectProps<any>;
|
|
107
107
|
/**
|
|
108
108
|
* The spacing for the select control.
|
|
109
109
|
*
|
|
@@ -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,9 +214,12 @@ 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
|
-
inputValue
|
|
222
|
+
inputValue?: string | undefined;
|
|
219
223
|
value: string;
|
|
220
224
|
isOpen: boolean;
|
|
221
225
|
isFocused: boolean;
|
|
@@ -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 }: {
|
|
@@ -241,7 +246,7 @@ declare class DatePicker extends Component<DatePickerProps, State> {
|
|
|
241
246
|
onClear: () => void;
|
|
242
247
|
onSelectChange: (value: ValueType<OptionType>, action: ActionMeta) => void;
|
|
243
248
|
refCalendar: (ref: CalendarRef | null) => void;
|
|
244
|
-
handleSelectInputChange: (selectInputValue: string, actionMeta:
|
|
249
|
+
handleSelectInputChange: (selectInputValue: string, actionMeta: InputActionMeta) => void;
|
|
245
250
|
getContainerRef: (ref: HTMLElement | null) => void;
|
|
246
251
|
/**
|
|
247
252
|
* There are two props that can change how the date is parsed.
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
3
|
-
import { LocalizationProvider } from '@atlaskit/locale';
|
|
4
3
|
import { ActionMeta, OptionType, SelectProps, ValueType } from '@atlaskit/select';
|
|
5
4
|
import { Appearance, Spacing } from '../types';
|
|
6
|
-
interface Option {
|
|
7
|
-
label: string;
|
|
8
|
-
value: string;
|
|
9
|
-
}
|
|
10
5
|
export interface TimePickerBaseProps extends WithAnalyticsEventsProps {
|
|
11
6
|
/**
|
|
12
7
|
* Set the appearance of the picker.
|
|
@@ -123,7 +118,6 @@ interface State {
|
|
|
123
118
|
clearingFromIcon: boolean;
|
|
124
119
|
value: string;
|
|
125
120
|
isFocused: boolean;
|
|
126
|
-
l10n: LocalizationProvider;
|
|
127
121
|
}
|
|
128
122
|
declare const timePickerDefaultProps: {
|
|
129
123
|
appearance: Appearance;
|
|
@@ -174,11 +168,8 @@ declare class TimePicker extends React.Component<TimePickerProps, State> {
|
|
|
174
168
|
clearingFromIcon: boolean;
|
|
175
169
|
value: string;
|
|
176
170
|
isFocused: boolean;
|
|
177
|
-
l10n: LocalizationProvider;
|
|
178
171
|
};
|
|
179
|
-
UNSAFE_componentWillReceiveProps(nextProps: TimePickerProps): void;
|
|
180
172
|
getSafeState: () => State;
|
|
181
|
-
getOptions(): Array<Option>;
|
|
182
173
|
onChange: (newValue: ValueType<OptionType> | string, action?: ActionMeta<OptionType>) => void;
|
|
183
174
|
/**
|
|
184
175
|
* Only allow custom times if timeIsEditable prop is true
|
|
@@ -190,15 +181,6 @@ declare class TimePicker extends React.Component<TimePickerProps, State> {
|
|
|
190
181
|
onBlur: (event: React.FocusEvent<HTMLElement>) => void;
|
|
191
182
|
onFocus: (event: React.FocusEvent<HTMLElement>) => void;
|
|
192
183
|
onSelectKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
193
|
-
/**
|
|
194
|
-
* There are multiple props that can change how the time is formatted.
|
|
195
|
-
* The priority of props used is:
|
|
196
|
-
* 1. formatDisplayLabel
|
|
197
|
-
* 2. timeFormat
|
|
198
|
-
* 3. locale
|
|
199
|
-
*/
|
|
200
|
-
formatTime: (time: string) => string;
|
|
201
|
-
getPlaceholder: () => string;
|
|
202
184
|
render(): JSX.Element;
|
|
203
185
|
}
|
|
204
186
|
export { TimePicker as TimePickerWithoutAnalytics };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/datetime-picker",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.9.0",
|
|
4
4
|
"description": "A date time picker allows the user to select an associated date and time.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@atlaskit/popper": "^5.5.0",
|
|
42
42
|
"@atlaskit/select": "^16.5.0",
|
|
43
43
|
"@atlaskit/theme": "^12.6.0",
|
|
44
|
-
"@atlaskit/tokens": "^1.
|
|
44
|
+
"@atlaskit/tokens": "^1.20.0",
|
|
45
45
|
"@babel/runtime": "^7.0.0",
|
|
46
46
|
"@emotion/react": "^11.7.1",
|
|
47
47
|
"date-fns": "^2.17.0",
|
package/report.api.md
CHANGED
|
@@ -23,7 +23,7 @@ import { GroupType } from '@atlaskit/select';
|
|
|
23
23
|
import { OptionType } from '@atlaskit/select';
|
|
24
24
|
import { default as React_2 } from 'react';
|
|
25
25
|
import { RefAttributes } from 'react';
|
|
26
|
-
import { SelectProps
|
|
26
|
+
import { SelectProps } from '@atlaskit/select';
|
|
27
27
|
import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
28
28
|
import { WithContextProps } from '@atlaskit/analytics-next';
|
|
29
29
|
|
|
@@ -192,7 +192,7 @@ export interface DatePickerProps extends WithAnalyticsEventsProps {
|
|
|
192
192
|
parseInputValue?: (date: string, dateFormat: string) => Date;
|
|
193
193
|
placeholder?: string;
|
|
194
194
|
previousMonthLabel?: string;
|
|
195
|
-
selectProps?: SelectProps
|
|
195
|
+
selectProps?: SelectProps<any>;
|
|
196
196
|
spacing?: Spacing;
|
|
197
197
|
testId?: string;
|
|
198
198
|
value?: string;
|
|
@@ -320,7 +320,7 @@ export interface DateTimePickerProps extends WithAnalyticsEventsProps {
|
|
|
320
320
|
autoFocus?: boolean;
|
|
321
321
|
dateFormat?: string;
|
|
322
322
|
datePickerProps?: DatePickerProps;
|
|
323
|
-
datePickerSelectProps?:
|
|
323
|
+
datePickerSelectProps?: SelectProps<any>;
|
|
324
324
|
defaultValue?: string;
|
|
325
325
|
id?: string;
|
|
326
326
|
innerProps?: React_2.AllHTMLAttributes<HTMLElement>;
|
|
@@ -346,7 +346,7 @@ export interface DateTimePickerProps extends WithAnalyticsEventsProps {
|
|
|
346
346
|
timeFormat?: string;
|
|
347
347
|
timeIsEditable?: boolean;
|
|
348
348
|
timePickerProps?: TimePickerProps;
|
|
349
|
-
timePickerSelectProps?:
|
|
349
|
+
timePickerSelectProps?: SelectProps<any>;
|
|
350
350
|
times?: Array<string>;
|
|
351
351
|
value?: string;
|
|
352
352
|
}
|
|
@@ -355,9 +355,6 @@ export interface DateTimePickerProps extends WithAnalyticsEventsProps {
|
|
|
355
355
|
type DateTimePickerProps_2 = typeof dateTimePickerDefaultProps &
|
|
356
356
|
DateTimePickerProps;
|
|
357
357
|
|
|
358
|
-
// @public (undocumented)
|
|
359
|
-
type SelectProps = any;
|
|
360
|
-
|
|
361
358
|
// @public (undocumented)
|
|
362
359
|
export type Spacing = 'compact' | 'default';
|
|
363
360
|
|
|
@@ -503,7 +500,7 @@ export interface TimePickerProps extends WithAnalyticsEventsProps {
|
|
|
503
500
|
// (undocumented)
|
|
504
501
|
parseInputValue?: (time: string, timeFormat: string) => Date | string;
|
|
505
502
|
placeholder?: string;
|
|
506
|
-
selectProps?:
|
|
503
|
+
selectProps?: SelectProps<any>;
|
|
507
504
|
spacing?: Spacing;
|
|
508
505
|
testId?: string;
|
|
509
506
|
timeFormat?: string;
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { GroupType } from '@atlaskit/select';
|
|
|
12
12
|
import { OptionType } from '@atlaskit/select';
|
|
13
13
|
import { default as React_2 } from 'react';
|
|
14
14
|
import { RefAttributes } from 'react';
|
|
15
|
-
import { SelectProps
|
|
15
|
+
import { SelectProps } from '@atlaskit/select';
|
|
16
16
|
import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
17
17
|
import { WithContextProps } from '@atlaskit/analytics-next';
|
|
18
18
|
|
|
@@ -93,7 +93,7 @@ export interface DatePickerProps extends WithAnalyticsEventsProps {
|
|
|
93
93
|
parseInputValue?: (date: string, dateFormat: string) => Date;
|
|
94
94
|
placeholder?: string;
|
|
95
95
|
previousMonthLabel?: string;
|
|
96
|
-
selectProps?: SelectProps
|
|
96
|
+
selectProps?: SelectProps<any>;
|
|
97
97
|
spacing?: Spacing;
|
|
98
98
|
testId?: string;
|
|
99
99
|
value?: string;
|
|
@@ -155,7 +155,7 @@ export interface DateTimePickerProps extends WithAnalyticsEventsProps {
|
|
|
155
155
|
autoFocus?: boolean;
|
|
156
156
|
dateFormat?: string;
|
|
157
157
|
datePickerProps?: DatePickerProps;
|
|
158
|
-
datePickerSelectProps?:
|
|
158
|
+
datePickerSelectProps?: SelectProps<any>;
|
|
159
159
|
defaultValue?: string;
|
|
160
160
|
id?: string;
|
|
161
161
|
innerProps?: React_2.AllHTMLAttributes<HTMLElement>;
|
|
@@ -176,7 +176,7 @@ export interface DateTimePickerProps extends WithAnalyticsEventsProps {
|
|
|
176
176
|
timeFormat?: string;
|
|
177
177
|
timeIsEditable?: boolean;
|
|
178
178
|
timePickerProps?: TimePickerProps;
|
|
179
|
-
timePickerSelectProps?:
|
|
179
|
+
timePickerSelectProps?: SelectProps<any>;
|
|
180
180
|
times?: Array<string>;
|
|
181
181
|
value?: string;
|
|
182
182
|
}
|
|
@@ -184,9 +184,6 @@ export interface DateTimePickerProps extends WithAnalyticsEventsProps {
|
|
|
184
184
|
// @public (undocumented)
|
|
185
185
|
type DateTimePickerProps_2 = typeof dateTimePickerDefaultProps & DateTimePickerProps;
|
|
186
186
|
|
|
187
|
-
// @public (undocumented)
|
|
188
|
-
type SelectProps = any;
|
|
189
|
-
|
|
190
187
|
// @public (undocumented)
|
|
191
188
|
export type Spacing = 'compact' | 'default';
|
|
192
189
|
|
|
@@ -257,7 +254,7 @@ export interface TimePickerProps extends WithAnalyticsEventsProps {
|
|
|
257
254
|
// (undocumented)
|
|
258
255
|
parseInputValue?: (time: string, timeFormat: string) => Date | string;
|
|
259
256
|
placeholder?: string;
|
|
260
|
-
selectProps?:
|
|
257
|
+
selectProps?: SelectProps<any>;
|
|
261
258
|
spacing?: Spacing;
|
|
262
259
|
testId?: string;
|
|
263
260
|
timeFormat?: string;
|