@atlaskit/datetime-picker 12.0.0 → 12.1.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 +31 -0
- package/dist/cjs/components/{DatePicker.js → date-picker.js} +43 -27
- package/dist/cjs/components/{DateTimePicker.js → date-time-picker.js} +16 -10
- package/dist/cjs/components/{TimePicker.js → time-picker.js} +17 -9
- package/dist/cjs/index.js +6 -6
- package/dist/cjs/internal/{FixedLayer.js → fixed-layer.js} +3 -1
- package/dist/cjs/internal/index.js +1 -0
- package/dist/cjs/internal/{parseTime.js → parse-time.js} +2 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/{DatePicker.js → date-picker.js} +33 -15
- package/dist/es2019/components/{DateTimePicker.js → date-time-picker.js} +16 -8
- package/dist/es2019/components/{TimePicker.js → time-picker.js} +18 -8
- package/dist/es2019/index.js +3 -3
- package/dist/es2019/internal/{FixedLayer.js → fixed-layer.js} +2 -1
- package/dist/es2019/internal/index.js +1 -0
- package/dist/es2019/internal/{parseTime.js → parse-time.js} +2 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/{DatePicker.js → date-picker.js} +44 -26
- package/dist/esm/components/{DateTimePicker.js → date-time-picker.js} +16 -8
- package/dist/esm/components/{TimePicker.js → time-picker.js} +17 -8
- package/dist/esm/index.js +3 -3
- package/dist/esm/internal/{FixedLayer.js → fixed-layer.js} +2 -1
- package/dist/esm/internal/index.js +1 -0
- package/dist/esm/internal/{parseTime.js → parse-time.js} +2 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/components/{DatePicker.d.ts → date-picker.d.ts} +99 -45
- package/dist/types/components/{DateTimePicker.d.ts → date-time-picker.d.ts} +67 -29
- package/dist/types/components/{TimePicker.d.ts → time-picker.d.ts} +76 -33
- package/dist/types/index.d.ts +6 -6
- package/dist/types/internal/{FixedLayer.d.ts → fixed-layer.d.ts} +7 -5
- package/dist/types/internal/{parseTime.d.ts → parse-time.d.ts} +0 -0
- package/extract-react-types/date-picker-props.tsx +2 -2
- package/extract-react-types/datetime-picker-props.tsx +2 -2
- package/extract-react-types/time-picker-props.tsx +2 -2
- package/package.json +7 -4
- package/report.api.md +636 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
|
|
4
|
+
/* eslint-disable @repo/internal/react/use-noop */
|
|
5
|
+
|
|
4
6
|
/** @jsx jsx */
|
|
5
7
|
import React from 'react';
|
|
6
8
|
import { css, jsx } from '@emotion/core'; // eslint-disable-next-line no-restricted-imports
|
|
@@ -13,11 +15,11 @@ import { mergeStyles } from '@atlaskit/select';
|
|
|
13
15
|
import { B100, N0, N20, N30, N500, N70, R400 } from '@atlaskit/theme/colors';
|
|
14
16
|
import { borderRadius, gridSize } from '@atlaskit/theme/constants';
|
|
15
17
|
import { defaultTimes, formatDateTimeZoneIntoIso } from '../internal';
|
|
16
|
-
import DatePicker from './
|
|
17
|
-
import TimePicker from './
|
|
18
|
+
import DatePicker from './date-picker';
|
|
19
|
+
import TimePicker from './time-picker';
|
|
18
20
|
import { convertTokens } from './utils';
|
|
19
21
|
const packageName = "@atlaskit/datetime-picker";
|
|
20
|
-
const packageVersion = "12.
|
|
22
|
+
const packageVersion = "12.1.2";
|
|
21
23
|
/* eslint-disable react/no-unused-prop-types */
|
|
22
24
|
|
|
23
25
|
const isInvalidBorderStyles = css({
|
|
@@ -27,16 +29,20 @@ const isFocusedBorderStyles = css({
|
|
|
27
29
|
borderColor: `var(--ds-border-focused, ${B100})`
|
|
28
30
|
});
|
|
29
31
|
const isFocusedStyles = css({
|
|
30
|
-
backgroundColor: `var(--ds-
|
|
32
|
+
backgroundColor: `var(--ds-background-input-pressed, ${N0})`
|
|
31
33
|
});
|
|
32
34
|
const subtleBgStyles = css({
|
|
33
35
|
backgroundColor: 'transparent',
|
|
34
36
|
borderColor: 'transparent'
|
|
35
37
|
});
|
|
38
|
+
const subtleFocusedBgStyles = css({
|
|
39
|
+
backgroundColor: "var(--ds-background-input-pressed, transparent)",
|
|
40
|
+
borderColor: 'transparent'
|
|
41
|
+
});
|
|
36
42
|
const hoverStyles = css({
|
|
37
43
|
'&:hover': {
|
|
38
44
|
backgroundColor: `var(--ds-background-input-hovered, ${N30})`,
|
|
39
|
-
borderColor: `var(--ds-border, ${N30})`
|
|
45
|
+
borderColor: `var(--ds-border-input, ${N30})`
|
|
40
46
|
}
|
|
41
47
|
});
|
|
42
48
|
const isInvalidHoverStyles = css({
|
|
@@ -52,8 +58,8 @@ const isDisabledStyles = css({
|
|
|
52
58
|
});
|
|
53
59
|
const baseContainerStyles = css({
|
|
54
60
|
display: 'flex',
|
|
55
|
-
backgroundColor: `var(--ds-background-
|
|
56
|
-
border: `2px solid ${`var(--ds-border, ${N20})`}`,
|
|
61
|
+
backgroundColor: `var(--ds-background-input, ${N20})`,
|
|
62
|
+
border: `2px solid ${`var(--ds-border-input, ${N20})`}`,
|
|
57
63
|
borderRadius: `${borderRadius()}px`,
|
|
58
64
|
transition: 'background-color 200ms ease-in-out, border-color 200ms ease-in-out',
|
|
59
65
|
'&:hover': {
|
|
@@ -273,11 +279,13 @@ class DateTimePicker extends React.Component {
|
|
|
273
279
|
|
|
274
280
|
const isClearable = Boolean(dateValue || timeValue);
|
|
275
281
|
const notFocusedOrIsDisabled = !(isFocused || isDisabled);
|
|
282
|
+
const labelId = (datePickerSelectProps === null || datePickerSelectProps === void 0 ? void 0 : datePickerSelectProps.inputId) || (timePickerSelectProps === null || timePickerSelectProps === void 0 ? void 0 : timePickerSelectProps.inputId) || '';
|
|
276
283
|
return jsx("div", _extends({
|
|
277
|
-
css: [baseContainerStyles, isDisabled && isDisabledStyles, isFocused && isFocusedStyles, bothProps.appearance === 'subtle' && subtleBgStyles, isFocused && isFocusedBorderStyles, bothProps.isInvalid && isInvalidBorderStyles, notFocusedOrIsDisabled && (bothProps.isInvalid ? isInvalidHoverStyles : hoverStyles)]
|
|
284
|
+
css: [baseContainerStyles, isDisabled && isDisabledStyles, isFocused && isFocusedStyles, bothProps.appearance === 'subtle' && (isFocused ? subtleFocusedBgStyles : subtleBgStyles), isFocused && isFocusedBorderStyles, bothProps.isInvalid && isInvalidBorderStyles, notFocusedOrIsDisabled && (bothProps.isInvalid ? isInvalidHoverStyles : hoverStyles)]
|
|
278
285
|
}, innerProps, {
|
|
279
286
|
"data-testid": testId
|
|
280
287
|
}), jsx("input", {
|
|
288
|
+
id: labelId,
|
|
281
289
|
name: name,
|
|
282
290
|
type: "hidden",
|
|
283
291
|
value: value
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
|
|
4
|
+
/* eslint-disable @repo/internal/react/use-noop */
|
|
3
5
|
import React from 'react'; // eslint-disable-next-line no-restricted-imports
|
|
4
6
|
|
|
5
7
|
import { format, isValid } from 'date-fns';
|
|
@@ -10,11 +12,11 @@ import Select, { components, CreatableSelect, mergeStyles } from '@atlaskit/sele
|
|
|
10
12
|
import { B100 } from '@atlaskit/theme/colors';
|
|
11
13
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
12
14
|
import { defaultTimeFormat, defaultTimes, DropdownIndicator, EmptyClearIndicator, placeholderDatetime } from '../internal';
|
|
13
|
-
import FixedLayer from '../internal/
|
|
14
|
-
import parseTime from '../internal/
|
|
15
|
+
import FixedLayer from '../internal/fixed-layer';
|
|
16
|
+
import parseTime from '../internal/parse-time';
|
|
15
17
|
import { convertTokens } from './utils';
|
|
16
18
|
const packageName = "@atlaskit/datetime-picker";
|
|
17
|
-
const packageVersion = "12.
|
|
19
|
+
const packageVersion = "12.1.2";
|
|
18
20
|
const menuStyles = {
|
|
19
21
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
20
22
|
position: 'static',
|
|
@@ -104,7 +106,15 @@ class TimePicker extends React.Component {
|
|
|
104
106
|
parseInputValue,
|
|
105
107
|
timeFormat
|
|
106
108
|
} = this.props;
|
|
107
|
-
|
|
109
|
+
let sanitizedInput;
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
sanitizedInput = parseInputValue(inputValue, timeFormat || defaultTimeFormat);
|
|
113
|
+
} catch (e) {
|
|
114
|
+
return; // do nothing, the main validation should happen in the form
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const formattedValue = format(sanitizedInput, 'HH:mm') || '';
|
|
108
118
|
this.setState({
|
|
109
119
|
value: formattedValue
|
|
110
120
|
});
|
|
@@ -180,7 +190,7 @@ class TimePicker extends React.Component {
|
|
|
180
190
|
|
|
181
191
|
_defineProperty(this, "getSubtleControlStyles", selectStyles => !selectStyles.control ? {
|
|
182
192
|
border: `2px solid ${this.getSafeState().isFocused ? `var(--ds-border-focused, ${B100})` : `transparent`}`,
|
|
183
|
-
backgroundColor: 'transparent',
|
|
193
|
+
backgroundColor: this.getSafeState().isFocused ? "var(--ds-background-input-pressed, transparent)" : 'transparent',
|
|
184
194
|
padding: '1px'
|
|
185
195
|
} : {});
|
|
186
196
|
|
|
@@ -262,7 +272,6 @@ class TimePicker extends React.Component {
|
|
|
262
272
|
testId
|
|
263
273
|
} = this.props;
|
|
264
274
|
const ICON_PADDING = 2;
|
|
265
|
-
const BORDER_WIDTH = 2;
|
|
266
275
|
const {
|
|
267
276
|
value = '',
|
|
268
277
|
isOpen
|
|
@@ -287,7 +296,7 @@ class TimePicker extends React.Component {
|
|
|
287
296
|
selectComponents.ClearIndicator = EmptyClearIndicator;
|
|
288
297
|
}
|
|
289
298
|
|
|
290
|
-
const renderIconContainer = Boolean(hideIcon && value);
|
|
299
|
+
const renderIconContainer = Boolean(!hideIcon && value);
|
|
291
300
|
const mergedStyles = mergeStyles(selectStyles, {
|
|
292
301
|
control: base => ({ ...base,
|
|
293
302
|
...controlStyles
|
|
@@ -300,7 +309,7 @@ class TimePicker extends React.Component {
|
|
|
300
309
|
}),
|
|
301
310
|
indicatorsContainer: base => ({ ...base,
|
|
302
311
|
paddingLeft: renderIconContainer ? ICON_PADDING : 0,
|
|
303
|
-
paddingRight: renderIconContainer ? gridSize() -
|
|
312
|
+
paddingRight: renderIconContainer ? gridSize() - ICON_PADDING : 0
|
|
304
313
|
})
|
|
305
314
|
});
|
|
306
315
|
return (
|
|
@@ -311,6 +320,7 @@ class TimePicker extends React.Component {
|
|
|
311
320
|
"data-testid": testId && `${testId}--container`,
|
|
312
321
|
onKeyDown: this.onSelectKeyDown
|
|
313
322
|
}), /*#__PURE__*/React.createElement("input", {
|
|
323
|
+
id: selectProps.inputId,
|
|
314
324
|
name: name,
|
|
315
325
|
type: "hidden",
|
|
316
326
|
value: value
|
package/dist/es2019/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as DatePicker } from './components/
|
|
2
|
-
export { default as TimePicker } from './components/
|
|
3
|
-
export { default as DateTimePicker } from './components/
|
|
1
|
+
export { default as DatePicker } from './components/date-picker';
|
|
2
|
+
export { default as TimePicker } from './components/time-picker';
|
|
3
|
+
export { default as DateTimePicker } from './components/date-time-picker';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import ScrollLock from 'react-scrolllock';
|
|
4
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
4
5
|
import { sizes } from '@atlaskit/icon';
|
|
5
6
|
import { Manager, Popper, Reference } from '@atlaskit/popper';
|
|
6
7
|
import { gridSize, layers } from '@atlaskit/theme/constants';
|
|
@@ -14,7 +15,7 @@ export default class FixedLayer extends React.Component {
|
|
|
14
15
|
constructor(...args) {
|
|
15
16
|
super(...args);
|
|
16
17
|
|
|
17
|
-
_defineProperty(this, "update",
|
|
18
|
+
_defineProperty(this, "update", noop);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
componentDidUpdate(prevProps) {
|
|
@@ -102,14 +102,14 @@ export default function (time) {
|
|
|
102
102
|
const trimmedTime = time.toString().trim();
|
|
103
103
|
|
|
104
104
|
if (!isValid(trimmedTime)) {
|
|
105
|
-
|
|
105
|
+
throw RangeError('invalid time format');
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
const time1 = removeSpacer(trimmedTime);
|
|
109
109
|
const time2 = convertTo24hrTime(time1);
|
|
110
110
|
|
|
111
111
|
if (!time2) {
|
|
112
|
-
|
|
112
|
+
throw RangeError('invalid time format');
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
return assignToDate(time2);
|
package/dist/es2019/version.json
CHANGED
|
@@ -16,6 +16,8 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
16
16
|
|
|
17
17
|
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; } }
|
|
18
18
|
|
|
19
|
+
/* eslint-disable @repo/internal/react/use-noop */
|
|
20
|
+
|
|
19
21
|
/** @jsx jsx */
|
|
20
22
|
import { Component } from 'react';
|
|
21
23
|
import { css, jsx } from '@emotion/core'; // eslint-disable-next-line no-restricted-imports
|
|
@@ -30,10 +32,10 @@ import Select, { mergeStyles } from '@atlaskit/select';
|
|
|
30
32
|
import { B100, N20, N50A, N60A } from '@atlaskit/theme/colors';
|
|
31
33
|
import { borderRadius, gridSize, layers } from '@atlaskit/theme/constants';
|
|
32
34
|
import { defaultDateFormat, EmptyClearIndicator, padToTwo, placeholderDatetime } from '../internal';
|
|
33
|
-
import FixedLayer from '../internal/
|
|
35
|
+
import FixedLayer from '../internal/fixed-layer';
|
|
34
36
|
import { convertTokens } from './utils';
|
|
35
37
|
var packageName = "@atlaskit/datetime-picker";
|
|
36
|
-
var packageVersion = "12.
|
|
38
|
+
var packageVersion = "12.1.2";
|
|
37
39
|
/* eslint-disable react/no-unused-prop-types */
|
|
38
40
|
|
|
39
41
|
function getDateObj(date) {
|
|
@@ -51,9 +53,10 @@ function getValidDate(iso) {
|
|
|
51
53
|
|
|
52
54
|
var menuStyles = css({
|
|
53
55
|
zIndex: layers.dialog(),
|
|
54
|
-
backgroundColor: "var(--ds-surface, ".concat(N20, ")"),
|
|
56
|
+
backgroundColor: "var(--ds-surface-overlay, ".concat(N20, ")"),
|
|
55
57
|
borderRadius: "".concat(borderRadius(), "px"),
|
|
56
|
-
boxShadow: "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(N50A, ", 0 0 1px ").concat(N60A), ")")
|
|
58
|
+
boxShadow: "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(N50A, ", 0 0 1px ").concat(N60A), ")"),
|
|
59
|
+
overflow: 'hidden'
|
|
57
60
|
});
|
|
58
61
|
|
|
59
62
|
var Menu = function Menu(_ref) {
|
|
@@ -77,7 +80,8 @@ var Menu = function Menu(_ref) {
|
|
|
77
80
|
selected: [selectProps.calendarValue],
|
|
78
81
|
locale: selectProps.calendarLocale,
|
|
79
82
|
testId: selectProps.testId && "".concat(selectProps.testId, "--calendar"),
|
|
80
|
-
weekStartDay: selectProps.calendarWeekStartDay
|
|
83
|
+
weekStartDay: selectProps.calendarWeekStartDay,
|
|
84
|
+
tabIndex: -1
|
|
81
85
|
}))),
|
|
82
86
|
testId: selectProps.testId
|
|
83
87
|
});
|
|
@@ -189,7 +193,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
189
193
|
});
|
|
190
194
|
} else {
|
|
191
195
|
_this.setState({
|
|
192
|
-
isOpen: false
|
|
196
|
+
isOpen: false,
|
|
197
|
+
isFocused: false
|
|
193
198
|
});
|
|
194
199
|
}
|
|
195
200
|
|
|
@@ -209,7 +214,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
209
214
|
} else {
|
|
210
215
|
_this.setState({
|
|
211
216
|
isOpen: true,
|
|
212
|
-
view: value
|
|
217
|
+
view: value,
|
|
218
|
+
isFocused: true
|
|
213
219
|
});
|
|
214
220
|
}
|
|
215
221
|
|
|
@@ -292,12 +298,21 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
292
298
|
break;
|
|
293
299
|
|
|
294
300
|
case 'enter':
|
|
295
|
-
|
|
301
|
+
if (!_this.state.isOpen) {
|
|
302
|
+
return;
|
|
303
|
+
} // Prevent form submission when a date is selected
|
|
296
304
|
// using enter. See https://product-fabric.atlassian.net/browse/DSP-2501
|
|
297
305
|
// for more details.
|
|
306
|
+
|
|
307
|
+
|
|
298
308
|
event.preventDefault();
|
|
299
309
|
|
|
300
310
|
if (!_this.isDateDisabled(view)) {
|
|
311
|
+
var _this$getSafeState3 = _this.getSafeState(),
|
|
312
|
+
_value = _this$getSafeState3.value;
|
|
313
|
+
|
|
314
|
+
var valueChanged = view !== _value;
|
|
315
|
+
|
|
301
316
|
_this.setState({
|
|
302
317
|
inputValue: '',
|
|
303
318
|
isOpen: false,
|
|
@@ -306,7 +321,9 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
306
321
|
view: view
|
|
307
322
|
});
|
|
308
323
|
|
|
309
|
-
|
|
324
|
+
if (valueChanged) {
|
|
325
|
+
_this.props.onChange(view);
|
|
326
|
+
}
|
|
310
327
|
}
|
|
311
328
|
|
|
312
329
|
break;
|
|
@@ -368,10 +385,10 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
368
385
|
}
|
|
369
386
|
});
|
|
370
387
|
|
|
371
|
-
_defineProperty(_assertThisInitialized(_this), "getSubtleControlStyles", function (
|
|
388
|
+
_defineProperty(_assertThisInitialized(_this), "getSubtleControlStyles", function () {
|
|
372
389
|
return {
|
|
373
|
-
border: "2px solid ".concat(
|
|
374
|
-
backgroundColor: 'transparent',
|
|
390
|
+
border: "2px solid ".concat(_this.getSafeState().isFocused ? "var(--ds-border-focused, ".concat(B100, ")") : "transparent"),
|
|
391
|
+
backgroundColor: _this.getSafeState().isOpen ? "var(--ds-background-input-pressed, transparent)" : 'transparent',
|
|
375
392
|
padding: '1px'
|
|
376
393
|
};
|
|
377
394
|
});
|
|
@@ -385,8 +402,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
385
402
|
return parseInputValue(date, dateFormat || defaultDateFormat);
|
|
386
403
|
}
|
|
387
404
|
|
|
388
|
-
var _this$
|
|
389
|
-
l10n = _this$
|
|
405
|
+
var _this$getSafeState4 = _this.getSafeState(),
|
|
406
|
+
l10n = _this$getSafeState4.l10n;
|
|
390
407
|
|
|
391
408
|
return l10n.parseDate(date);
|
|
392
409
|
});
|
|
@@ -396,8 +413,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
396
413
|
formatDisplayLabel = _this$props2.formatDisplayLabel,
|
|
397
414
|
dateFormat = _this$props2.dateFormat;
|
|
398
415
|
|
|
399
|
-
var _this$
|
|
400
|
-
l10n = _this$
|
|
416
|
+
var _this$getSafeState5 = _this.getSafeState(),
|
|
417
|
+
l10n = _this$getSafeState5.l10n;
|
|
401
418
|
|
|
402
419
|
if (formatDisplayLabel) {
|
|
403
420
|
return formatDisplayLabel(value, dateFormat || defaultDateFormat);
|
|
@@ -414,8 +431,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
414
431
|
return placeholder;
|
|
415
432
|
}
|
|
416
433
|
|
|
417
|
-
var _this$
|
|
418
|
-
l10n = _this$
|
|
434
|
+
var _this$getSafeState6 = _this.getSafeState(),
|
|
435
|
+
l10n = _this$getSafeState6.l10n;
|
|
419
436
|
|
|
420
437
|
return l10n.formatDate(placeholderDatetime);
|
|
421
438
|
});
|
|
@@ -427,6 +444,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
427
444
|
|
|
428
445
|
_this.state = {
|
|
429
446
|
isOpen: _this.props.defaultIsOpen,
|
|
447
|
+
isFocused: false,
|
|
430
448
|
clearingFromIcon: false,
|
|
431
449
|
inputValue: _this.props.selectProps.inputValue,
|
|
432
450
|
selectedValue: _this.props.value || _this.props.defaultValue,
|
|
@@ -472,14 +490,13 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
472
490
|
locale = _this$props3.locale,
|
|
473
491
|
testId = _this$props3.testId,
|
|
474
492
|
weekStartDay = _this$props3.weekStartDay;
|
|
475
|
-
var BORDER_WIDTH = 2;
|
|
476
493
|
var ICON_PADDING = 2;
|
|
477
494
|
|
|
478
|
-
var _this$
|
|
479
|
-
value = _this$
|
|
480
|
-
view = _this$
|
|
481
|
-
isOpen = _this$
|
|
482
|
-
inputValue = _this$
|
|
495
|
+
var _this$getSafeState7 = this.getSafeState(),
|
|
496
|
+
value = _this$getSafeState7.value,
|
|
497
|
+
view = _this$getSafeState7.view,
|
|
498
|
+
isOpen = _this$getSafeState7.isOpen,
|
|
499
|
+
inputValue = _this$getSafeState7.inputValue;
|
|
483
500
|
|
|
484
501
|
var menuIsOpen = isOpen && !isDisabled;
|
|
485
502
|
var showClearIndicator = Boolean((value || inputValue) && !hideIcon);
|
|
@@ -495,7 +512,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
495
512
|
|
|
496
513
|
var _selectProps$styles = selectProps.styles,
|
|
497
514
|
selectStyles = _selectProps$styles === void 0 ? {} : _selectProps$styles;
|
|
498
|
-
var controlStyles = appearance === 'subtle' ? this.getSubtleControlStyles(
|
|
515
|
+
var controlStyles = appearance === 'subtle' ? this.getSubtleControlStyles() : {};
|
|
499
516
|
var disabledStyle = isDisabled ? {
|
|
500
517
|
pointerEvents: 'none'
|
|
501
518
|
} : {};
|
|
@@ -523,6 +540,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
523
540
|
ref: this.getContainerRef,
|
|
524
541
|
"data-testid": testId && "".concat(testId, "--container")
|
|
525
542
|
}), jsx("input", {
|
|
543
|
+
id: selectProps.inputId,
|
|
526
544
|
name: name,
|
|
527
545
|
type: "hidden",
|
|
528
546
|
value: value,
|
|
@@ -547,7 +565,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
547
565
|
indicatorsContainer: function indicatorsContainer(base) {
|
|
548
566
|
return _objectSpread(_objectSpread({}, base), {}, {
|
|
549
567
|
paddingLeft: ICON_PADDING,
|
|
550
|
-
paddingRight: gridSize() -
|
|
568
|
+
paddingRight: gridSize() - ICON_PADDING
|
|
551
569
|
});
|
|
552
570
|
}
|
|
553
571
|
}),
|
|
@@ -15,6 +15,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
15
15
|
|
|
16
16
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
17
|
|
|
18
|
+
/* eslint-disable @repo/internal/react/use-noop */
|
|
19
|
+
|
|
18
20
|
/** @jsx jsx */
|
|
19
21
|
import React from 'react';
|
|
20
22
|
import { css, jsx } from '@emotion/core'; // eslint-disable-next-line no-restricted-imports
|
|
@@ -27,11 +29,11 @@ import { mergeStyles } from '@atlaskit/select';
|
|
|
27
29
|
import { B100, N0, N20, N30, N500, N70, R400 } from '@atlaskit/theme/colors';
|
|
28
30
|
import { borderRadius, gridSize } from '@atlaskit/theme/constants';
|
|
29
31
|
import { defaultTimes, formatDateTimeZoneIntoIso } from '../internal';
|
|
30
|
-
import DatePicker from './
|
|
31
|
-
import TimePicker from './
|
|
32
|
+
import DatePicker from './date-picker';
|
|
33
|
+
import TimePicker from './time-picker';
|
|
32
34
|
import { convertTokens } from './utils';
|
|
33
35
|
var packageName = "@atlaskit/datetime-picker";
|
|
34
|
-
var packageVersion = "12.
|
|
36
|
+
var packageVersion = "12.1.2";
|
|
35
37
|
/* eslint-disable react/no-unused-prop-types */
|
|
36
38
|
|
|
37
39
|
var isInvalidBorderStyles = css({
|
|
@@ -41,16 +43,20 @@ var isFocusedBorderStyles = css({
|
|
|
41
43
|
borderColor: "var(--ds-border-focused, ".concat(B100, ")")
|
|
42
44
|
});
|
|
43
45
|
var isFocusedStyles = css({
|
|
44
|
-
backgroundColor: "var(--ds-
|
|
46
|
+
backgroundColor: "var(--ds-background-input-pressed, ".concat(N0, ")")
|
|
45
47
|
});
|
|
46
48
|
var subtleBgStyles = css({
|
|
47
49
|
backgroundColor: 'transparent',
|
|
48
50
|
borderColor: 'transparent'
|
|
49
51
|
});
|
|
52
|
+
var subtleFocusedBgStyles = css({
|
|
53
|
+
backgroundColor: "var(--ds-background-input-pressed, transparent)",
|
|
54
|
+
borderColor: 'transparent'
|
|
55
|
+
});
|
|
50
56
|
var hoverStyles = css({
|
|
51
57
|
'&:hover': {
|
|
52
58
|
backgroundColor: "var(--ds-background-input-hovered, ".concat(N30, ")"),
|
|
53
|
-
borderColor: "var(--ds-border, ".concat(N30, ")")
|
|
59
|
+
borderColor: "var(--ds-border-input, ".concat(N30, ")")
|
|
54
60
|
}
|
|
55
61
|
});
|
|
56
62
|
var isInvalidHoverStyles = css({
|
|
@@ -66,8 +72,8 @@ var isDisabledStyles = css({
|
|
|
66
72
|
});
|
|
67
73
|
var baseContainerStyles = css({
|
|
68
74
|
display: 'flex',
|
|
69
|
-
backgroundColor: "var(--ds-background-
|
|
70
|
-
border: "2px solid ".concat("var(--ds-border, ".concat(N20, ")")),
|
|
75
|
+
backgroundColor: "var(--ds-background-input, ".concat(N20, ")"),
|
|
76
|
+
border: "2px solid ".concat("var(--ds-border-input, ".concat(N20, ")")),
|
|
71
77
|
borderRadius: "".concat(borderRadius(), "px"),
|
|
72
78
|
transition: 'background-color 200ms ease-in-out, border-color 200ms ease-in-out',
|
|
73
79
|
'&:hover': {
|
|
@@ -307,11 +313,13 @@ var DateTimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
307
313
|
|
|
308
314
|
var isClearable = Boolean(dateValue || timeValue);
|
|
309
315
|
var notFocusedOrIsDisabled = !(isFocused || isDisabled);
|
|
316
|
+
var labelId = (datePickerSelectProps === null || datePickerSelectProps === void 0 ? void 0 : datePickerSelectProps.inputId) || (timePickerSelectProps === null || timePickerSelectProps === void 0 ? void 0 : timePickerSelectProps.inputId) || '';
|
|
310
317
|
return jsx("div", _extends({
|
|
311
|
-
css: [baseContainerStyles, isDisabled && isDisabledStyles, isFocused && isFocusedStyles, bothProps.appearance === 'subtle' && subtleBgStyles, isFocused && isFocusedBorderStyles, bothProps.isInvalid && isInvalidBorderStyles, notFocusedOrIsDisabled && (bothProps.isInvalid ? isInvalidHoverStyles : hoverStyles)]
|
|
318
|
+
css: [baseContainerStyles, isDisabled && isDisabledStyles, isFocused && isFocusedStyles, bothProps.appearance === 'subtle' && (isFocused ? subtleFocusedBgStyles : subtleBgStyles), isFocused && isFocusedBorderStyles, bothProps.isInvalid && isInvalidBorderStyles, notFocusedOrIsDisabled && (bothProps.isInvalid ? isInvalidHoverStyles : hoverStyles)]
|
|
312
319
|
}, innerProps, {
|
|
313
320
|
"data-testid": testId
|
|
314
321
|
}), jsx("input", {
|
|
322
|
+
id: labelId,
|
|
315
323
|
name: name,
|
|
316
324
|
type: "hidden",
|
|
317
325
|
value: value
|
|
@@ -18,6 +18,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
18
18
|
|
|
19
19
|
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; } }
|
|
20
20
|
|
|
21
|
+
/* eslint-disable @repo/internal/react/use-noop */
|
|
21
22
|
import React from 'react'; // eslint-disable-next-line no-restricted-imports
|
|
22
23
|
|
|
23
24
|
import { format, isValid } from 'date-fns';
|
|
@@ -28,11 +29,11 @@ import Select, { components, CreatableSelect, mergeStyles } from '@atlaskit/sele
|
|
|
28
29
|
import { B100 } from '@atlaskit/theme/colors';
|
|
29
30
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
30
31
|
import { defaultTimeFormat, defaultTimes, DropdownIndicator, EmptyClearIndicator, placeholderDatetime } from '../internal';
|
|
31
|
-
import FixedLayer from '../internal/
|
|
32
|
-
import parseTime from '../internal/
|
|
32
|
+
import FixedLayer from '../internal/fixed-layer';
|
|
33
|
+
import parseTime from '../internal/parse-time';
|
|
33
34
|
import { convertTokens } from './utils';
|
|
34
35
|
var packageName = "@atlaskit/datetime-picker";
|
|
35
|
-
var packageVersion = "12.
|
|
36
|
+
var packageVersion = "12.1.2";
|
|
36
37
|
var menuStyles = {
|
|
37
38
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
38
39
|
position: 'static',
|
|
@@ -136,7 +137,15 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
136
137
|
var _this$props = _this.props,
|
|
137
138
|
parseInputValue = _this$props.parseInputValue,
|
|
138
139
|
_timeFormat = _this$props.timeFormat;
|
|
139
|
-
var
|
|
140
|
+
var sanitizedInput;
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
sanitizedInput = parseInputValue(inputValue, _timeFormat || defaultTimeFormat);
|
|
144
|
+
} catch (e) {
|
|
145
|
+
return; // do nothing, the main validation should happen in the form
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
var formattedValue = format(sanitizedInput, 'HH:mm') || '';
|
|
140
149
|
|
|
141
150
|
_this.setState({
|
|
142
151
|
value: formattedValue
|
|
@@ -215,7 +224,7 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
215
224
|
_defineProperty(_assertThisInitialized(_this), "getSubtleControlStyles", function (selectStyles) {
|
|
216
225
|
return !selectStyles.control ? {
|
|
217
226
|
border: "2px solid ".concat(_this.getSafeState().isFocused ? "var(--ds-border-focused, ".concat(B100, ")") : "transparent"),
|
|
218
|
-
backgroundColor: 'transparent',
|
|
227
|
+
backgroundColor: _this.getSafeState().isFocused ? "var(--ds-background-input-pressed, transparent)" : 'transparent',
|
|
219
228
|
padding: '1px'
|
|
220
229
|
} : {};
|
|
221
230
|
});
|
|
@@ -304,7 +313,6 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
304
313
|
spacing = _this$props3.spacing,
|
|
305
314
|
testId = _this$props3.testId;
|
|
306
315
|
var ICON_PADDING = 2;
|
|
307
|
-
var BORDER_WIDTH = 2;
|
|
308
316
|
|
|
309
317
|
var _this$getSafeState3 = this.getSafeState(),
|
|
310
318
|
_this$getSafeState3$v = _this$getSafeState3.value,
|
|
@@ -332,7 +340,7 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
332
340
|
selectComponents.ClearIndicator = EmptyClearIndicator;
|
|
333
341
|
}
|
|
334
342
|
|
|
335
|
-
var renderIconContainer = Boolean(hideIcon && value);
|
|
343
|
+
var renderIconContainer = Boolean(!hideIcon && value);
|
|
336
344
|
var mergedStyles = mergeStyles(selectStyles, {
|
|
337
345
|
control: function control(base) {
|
|
338
346
|
return _objectSpread(_objectSpread({}, base), controlStyles);
|
|
@@ -347,7 +355,7 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
347
355
|
indicatorsContainer: function indicatorsContainer(base) {
|
|
348
356
|
return _objectSpread(_objectSpread({}, base), {}, {
|
|
349
357
|
paddingLeft: renderIconContainer ? ICON_PADDING : 0,
|
|
350
|
-
paddingRight: renderIconContainer ? gridSize() -
|
|
358
|
+
paddingRight: renderIconContainer ? gridSize() - ICON_PADDING : 0
|
|
351
359
|
});
|
|
352
360
|
}
|
|
353
361
|
});
|
|
@@ -359,6 +367,7 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
359
367
|
"data-testid": testId && "".concat(testId, "--container"),
|
|
360
368
|
onKeyDown: this.onSelectKeyDown
|
|
361
369
|
}), /*#__PURE__*/React.createElement("input", {
|
|
370
|
+
id: selectProps.inputId,
|
|
362
371
|
name: name,
|
|
363
372
|
type: "hidden",
|
|
364
373
|
value: value
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as DatePicker } from './components/
|
|
2
|
-
export { default as TimePicker } from './components/
|
|
3
|
-
export { default as DateTimePicker } from './components/
|
|
1
|
+
export { default as DatePicker } from './components/date-picker';
|
|
2
|
+
export { default as TimePicker } from './components/time-picker';
|
|
3
|
+
export { default as DateTimePicker } from './components/date-time-picker';
|
|
@@ -16,6 +16,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
16
16
|
|
|
17
17
|
import React from 'react';
|
|
18
18
|
import ScrollLock from 'react-scrolllock';
|
|
19
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
19
20
|
import { sizes } from '@atlaskit/icon';
|
|
20
21
|
import { Manager, Popper, Reference } from '@atlaskit/popper';
|
|
21
22
|
import { gridSize, layers } from '@atlaskit/theme/constants';
|
|
@@ -41,7 +42,7 @@ var FixedLayer = /*#__PURE__*/function (_React$Component) {
|
|
|
41
42
|
|
|
42
43
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
43
44
|
|
|
44
|
-
_defineProperty(_assertThisInitialized(_this), "update",
|
|
45
|
+
_defineProperty(_assertThisInitialized(_this), "update", noop);
|
|
45
46
|
|
|
46
47
|
return _this;
|
|
47
48
|
}
|
|
@@ -102,14 +102,14 @@ export default function (time) {
|
|
|
102
102
|
var trimmedTime = time.toString().trim();
|
|
103
103
|
|
|
104
104
|
if (!isValid(trimmedTime)) {
|
|
105
|
-
|
|
105
|
+
throw RangeError('invalid time format');
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
var time1 = removeSpacer(trimmedTime);
|
|
109
109
|
var time2 = convertTo24hrTime(time1);
|
|
110
110
|
|
|
111
111
|
if (!time2) {
|
|
112
|
-
|
|
112
|
+
throw RangeError('invalid time format');
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
return assignToDate(time2);
|
package/dist/esm/version.json
CHANGED