@atlaskit/datetime-picker 13.11.2 → 14.0.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 +19 -0
- package/codemods/14.0.0-remove-duplicate-and-unused-props.tsx +432 -0
- package/codemods/__tests__/next-remove-duplicate-and-unused-props.tsx +1225 -0
- package/codemods/utils/helpers.tsx +306 -0
- package/dist/cjs/components/date-picker.js +22 -24
- package/dist/cjs/components/date-time-picker.js +73 -68
- package/dist/cjs/components/time-picker.js +13 -11
- package/dist/es2019/components/date-picker.js +21 -22
- package/dist/es2019/components/date-time-picker.js +66 -72
- package/dist/es2019/components/time-picker.js +13 -14
- package/dist/esm/components/date-picker.js +22 -24
- package/dist/esm/components/date-time-picker.js +73 -68
- package/dist/esm/components/time-picker.js +13 -11
- package/dist/types/components/date-picker.d.ts +2 -12
- package/dist/types/components/date-time-picker.d.ts +3 -6
- package/dist/types/components/time-picker.d.ts +2 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types.d.ts +43 -31
- package/dist/types-ts4.5/components/date-picker.d.ts +2 -12
- package/dist/types-ts4.5/components/date-time-picker.d.ts +3 -6
- package/dist/types-ts4.5/components/time-picker.d.ts +2 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +43 -31
- package/package.json +6 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
4
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
@@ -6,6 +6,8 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
+
var _excluded = ["selectProps"],
|
|
10
|
+
_excluded2 = ["selectProps"];
|
|
9
11
|
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
12
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
13
|
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; }
|
|
@@ -19,7 +21,6 @@ import React from 'react';
|
|
|
19
21
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
20
22
|
import { css, jsx } from '@emotion/react';
|
|
21
23
|
import { format, isValid, parseISO } from 'date-fns';
|
|
22
|
-
import pick from 'lodash/pick';
|
|
23
24
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
24
25
|
import SelectClearIcon from '@atlaskit/icon/glyph/select-clear';
|
|
25
26
|
import { mergeStyles } from '@atlaskit/select';
|
|
@@ -30,7 +31,7 @@ import { convertTokens } from '../internal/parse-tokens';
|
|
|
30
31
|
import DatePicker from './date-picker';
|
|
31
32
|
import TimePicker from './time-picker';
|
|
32
33
|
var packageName = "@atlaskit/datetime-picker";
|
|
33
|
-
var packageVersion = "
|
|
34
|
+
var packageVersion = "14.0.0";
|
|
34
35
|
// Make DatePicker 50% the width of DateTimePicker
|
|
35
36
|
// If rendering an icon container, shrink the TimePicker
|
|
36
37
|
var datePickerContainerStyles = css({
|
|
@@ -94,8 +95,6 @@ var dateTimePickerDefaultProps = {
|
|
|
94
95
|
isInvalid: false,
|
|
95
96
|
datePickerProps: {},
|
|
96
97
|
timePickerProps: {},
|
|
97
|
-
datePickerSelectProps: {},
|
|
98
|
-
timePickerSelectProps: {},
|
|
99
98
|
times: defaultTimes,
|
|
100
99
|
spacing: 'default',
|
|
101
100
|
locale: 'en-US'
|
|
@@ -123,9 +122,12 @@ var DateTimePickerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
123
122
|
});
|
|
124
123
|
// All state needs to be accessed via this function so that the state is mapped from props
|
|
125
124
|
// correctly to allow controlled/uncontrolled usage.
|
|
126
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
_defineProperty(_assertThisInitialized(_this), "getParsedValues", function () {
|
|
126
|
+
return _this.parseValue(_this.getValue(), _this.state.dateValue, _this.state.timeValue, _this.state.zoneValue);
|
|
127
|
+
});
|
|
128
|
+
_defineProperty(_assertThisInitialized(_this), "getValue", function () {
|
|
129
|
+
var _this$props$value;
|
|
130
|
+
return (_this$props$value = _this.props.value) !== null && _this$props$value !== void 0 ? _this$props$value : _this.state.value;
|
|
129
131
|
});
|
|
130
132
|
_defineProperty(_assertThisInitialized(_this), "onBlur", function (event) {
|
|
131
133
|
_this.setState({
|
|
@@ -140,20 +142,28 @@ var DateTimePickerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
140
142
|
_this.props.onFocus(event);
|
|
141
143
|
});
|
|
142
144
|
_defineProperty(_assertThisInitialized(_this), "onDateChange", function (dateValue) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
var parsedValues = _this.getParsedValues();
|
|
146
|
+
_this.onValueChange({
|
|
147
|
+
dateValue: dateValue,
|
|
148
|
+
timeValue: parsedValues.timeValue,
|
|
149
|
+
zoneValue: parsedValues.zoneValue
|
|
150
|
+
});
|
|
146
151
|
});
|
|
147
152
|
_defineProperty(_assertThisInitialized(_this), "onTimeChange", function (timeValue) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
153
|
+
var parsedValues = _this.getParsedValues();
|
|
154
|
+
_this.onValueChange({
|
|
155
|
+
dateValue: parsedValues.dateValue,
|
|
156
|
+
timeValue: timeValue,
|
|
157
|
+
zoneValue: parsedValues.zoneValue
|
|
158
|
+
});
|
|
151
159
|
});
|
|
152
160
|
_defineProperty(_assertThisInitialized(_this), "onClear", function () {
|
|
153
|
-
|
|
161
|
+
var parsedValues = _this.getParsedValues();
|
|
162
|
+
_this.onValueChange({
|
|
163
|
+
dateValue: '',
|
|
154
164
|
timeValue: '',
|
|
155
|
-
|
|
156
|
-
})
|
|
165
|
+
zoneValue: parsedValues.zoneValue
|
|
166
|
+
});
|
|
157
167
|
});
|
|
158
168
|
return _this;
|
|
159
169
|
}
|
|
@@ -161,7 +171,18 @@ var DateTimePickerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
161
171
|
key: "parseValue",
|
|
162
172
|
value: function parseValue(value, dateValue, timeValue, zoneValue) {
|
|
163
173
|
if (this.props.parseValue) {
|
|
164
|
-
|
|
174
|
+
var parsedFromFn = this.props.parseValue(value, dateValue, timeValue, zoneValue);
|
|
175
|
+
// This handles cases found in Jira where the parse function actually does
|
|
176
|
+
// nothing and returns undefined. The previous `getSafeState` function
|
|
177
|
+
// just spread the values over the state, but if it returned `undefined`,
|
|
178
|
+
// it would just rely on the previous state values. Considering this is
|
|
179
|
+
// what is input to this function anyway, this is a safe way to handle
|
|
180
|
+
// this, colocate the behavior, and not rely on `getSafeState`.
|
|
181
|
+
return parsedFromFn || {
|
|
182
|
+
dateValue: dateValue,
|
|
183
|
+
timeValue: timeValue,
|
|
184
|
+
zoneValue: zoneValue
|
|
185
|
+
};
|
|
165
186
|
}
|
|
166
187
|
var parsed = parseISO(value);
|
|
167
188
|
return isValid(parsed) ? {
|
|
@@ -195,7 +216,7 @@ var DateTimePickerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
195
216
|
});
|
|
196
217
|
this.props.onChange(valueWithValidZone);
|
|
197
218
|
// If the date or time value was cleared when there is an existing datetime value, then clear the value.
|
|
198
|
-
} else if (this.
|
|
219
|
+
} else if (this.getValue()) {
|
|
199
220
|
this.setState({
|
|
200
221
|
value: ''
|
|
201
222
|
});
|
|
@@ -209,9 +230,7 @@ var DateTimePickerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
209
230
|
ariaDescribedBy = _this$props['aria-describedby'],
|
|
210
231
|
appearance = _this$props.appearance,
|
|
211
232
|
autoFocus = _this$props.autoFocus,
|
|
212
|
-
|
|
213
|
-
datePickerProps = _this$props.datePickerProps,
|
|
214
|
-
datePickerSelectProps = _this$props.datePickerSelectProps,
|
|
233
|
+
datePickerPropsWithSelectProps = _this$props.datePickerProps,
|
|
215
234
|
id = _this$props.id,
|
|
216
235
|
innerProps = _this$props.innerProps,
|
|
217
236
|
isDisabled = _this$props.isDisabled,
|
|
@@ -220,29 +239,25 @@ var DateTimePickerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
220
239
|
name = _this$props.name,
|
|
221
240
|
spacing = _this$props.spacing,
|
|
222
241
|
testId = _this$props.testId,
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
var
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
var _datePickerSelectProp = datePickerSelectProps.styles,
|
|
234
|
-
datePickerStyles = _datePickerSelectProp === void 0 ? {} : _datePickerSelectProp;
|
|
235
|
-
var _timePickerSelectProp = timePickerSelectProps.styles,
|
|
236
|
-
timePickerStyles = _timePickerSelectProp === void 0 ? {} : _timePickerSelectProp;
|
|
242
|
+
timePickerPropsWithSelectProps = _this$props.timePickerProps;
|
|
243
|
+
var value = this.getValue();
|
|
244
|
+
var isFocused = this.state.isFocused;
|
|
245
|
+
var parsedValues = this.getParsedValues();
|
|
246
|
+
var dateValue = parsedValues === null || parsedValues === void 0 ? void 0 : parsedValues.dateValue;
|
|
247
|
+
var timeValue = parsedValues === null || parsedValues === void 0 ? void 0 : parsedValues.timeValue;
|
|
248
|
+
var datePickerSelectProps = datePickerPropsWithSelectProps.selectProps,
|
|
249
|
+
datePickerProps = _objectWithoutProperties(datePickerPropsWithSelectProps, _excluded);
|
|
250
|
+
var datePickerAriaDescribedBy = datePickerProps['aria-describedby'] || ariaDescribedBy;
|
|
251
|
+
var datePickerLabel = datePickerProps.label || datePickerDefaultAriaLabel;
|
|
237
252
|
var mergedDatePickerSelectProps = _objectSpread(_objectSpread({}, datePickerSelectProps), {}, {
|
|
238
|
-
|
|
239
|
-
'aria-label': datePickerProps['label'] || datePickerSelectProps['aria-label'] || datePickerDefaultAriaLabel,
|
|
240
|
-
styles: mergeStyles(styles, datePickerStyles)
|
|
253
|
+
styles: mergeStyles(styles, datePickerSelectProps === null || datePickerSelectProps === void 0 ? void 0 : datePickerSelectProps.styles)
|
|
241
254
|
});
|
|
255
|
+
var timePickerSelectProps = timePickerPropsWithSelectProps.selectProps,
|
|
256
|
+
timePickerProps = _objectWithoutProperties(timePickerPropsWithSelectProps, _excluded2);
|
|
257
|
+
var timePickerAriaDescribedBy = timePickerProps['aria-describedby'] || ariaDescribedBy;
|
|
258
|
+
var timePickerLabel = timePickerProps.label || timePickerDefaultAriaLabel;
|
|
242
259
|
var mergedTimePickerSelectProps = _objectSpread(_objectSpread({}, timePickerSelectProps), {}, {
|
|
243
|
-
|
|
244
|
-
'aria-label': timePickerProps['label'] || timePickerSelectProps['aria-label'] || timePickerDefaultAriaLabel,
|
|
245
|
-
styles: mergeStyles(styles, timePickerStyles)
|
|
260
|
+
styles: mergeStyles(styles, timePickerSelectProps === null || timePickerSelectProps === void 0 ? void 0 : timePickerSelectProps.styles)
|
|
246
261
|
});
|
|
247
262
|
|
|
248
263
|
// Render DateTimePicker's IconContainer when a value has been filled
|
|
@@ -262,10 +277,11 @@ var DateTimePickerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
262
277
|
"data-testid": testId && "".concat(testId, "--input")
|
|
263
278
|
}), jsx("div", {
|
|
264
279
|
css: datePickerContainerStyles
|
|
265
|
-
}, jsx(DatePicker,
|
|
280
|
+
}, jsx(DatePicker, {
|
|
266
281
|
appearance: appearance,
|
|
282
|
+
"aria-describedby": datePickerAriaDescribedBy,
|
|
267
283
|
autoFocus: datePickerProps.autoFocus || autoFocus,
|
|
268
|
-
dateFormat: datePickerProps.dateFormat
|
|
284
|
+
dateFormat: datePickerProps.dateFormat,
|
|
269
285
|
defaultIsOpen: datePickerProps.defaultIsOpen,
|
|
270
286
|
defaultValue: datePickerProps.defaultValue,
|
|
271
287
|
disabled: datePickerProps.disabled,
|
|
@@ -276,15 +292,9 @@ var DateTimePickerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
276
292
|
id: datePickerProps.id || id,
|
|
277
293
|
innerProps: datePickerProps.innerProps,
|
|
278
294
|
isDisabled: datePickerProps.isDisabled || isDisabled,
|
|
279
|
-
isInvalid: datePickerProps.isInvalid || isInvalid
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
// `isOpen` to `undefined` forever. I believe this has to do with
|
|
283
|
-
// the `getSafeState` function in the picker, since it overwrites
|
|
284
|
-
// state with values from the props.
|
|
285
|
-
}, datePickerProps.isOpen ? {
|
|
286
|
-
isOpen: datePickerProps.isOpen
|
|
287
|
-
} : {}, {
|
|
295
|
+
isInvalid: datePickerProps.isInvalid || isInvalid,
|
|
296
|
+
isOpen: datePickerProps.isOpen,
|
|
297
|
+
label: datePickerLabel,
|
|
288
298
|
locale: datePickerProps.locale || locale,
|
|
289
299
|
maxDate: datePickerProps.maxDate,
|
|
290
300
|
minDate: datePickerProps.minDate,
|
|
@@ -301,10 +311,11 @@ var DateTimePickerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
301
311
|
testId: testId && "".concat(testId, "--datepicker") || datePickerProps.testId,
|
|
302
312
|
value: dateValue,
|
|
303
313
|
weekStartDay: datePickerProps.weekStartDay
|
|
304
|
-
}))
|
|
314
|
+
})), jsx("div", {
|
|
305
315
|
css: timePickerContainerStyles
|
|
306
|
-
}, jsx(TimePicker,
|
|
316
|
+
}, jsx(TimePicker, {
|
|
307
317
|
appearance: timePickerProps.appearance || appearance,
|
|
318
|
+
"aria-describedby": timePickerAriaDescribedBy,
|
|
308
319
|
autoFocus: timePickerProps.autoFocus,
|
|
309
320
|
defaultIsOpen: timePickerProps.defaultIsOpen,
|
|
310
321
|
defaultValue: timePickerProps.defaultValue,
|
|
@@ -313,15 +324,9 @@ var DateTimePickerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
313
324
|
id: timePickerProps.id,
|
|
314
325
|
innerProps: timePickerProps.innerProps,
|
|
315
326
|
isDisabled: timePickerProps.isDisabled || isDisabled,
|
|
316
|
-
isInvalid: timePickerProps.isInvalid || isInvalid
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
// `isOpen` to `undefined` forever. I believe this has to do with
|
|
320
|
-
// the `getSafeState` function in the picker, since it overwrites
|
|
321
|
-
// state with values from the props.
|
|
322
|
-
}, timePickerProps.isOpen ? {
|
|
323
|
-
isOpen: timePickerProps.isOpen
|
|
324
|
-
} : {}, {
|
|
327
|
+
isInvalid: timePickerProps.isInvalid || isInvalid,
|
|
328
|
+
isOpen: timePickerProps.isOpen,
|
|
329
|
+
label: timePickerLabel,
|
|
325
330
|
locale: timePickerProps.locale || locale,
|
|
326
331
|
name: timePickerProps.name,
|
|
327
332
|
onBlur: timePickerProps.onBlur || this.onBlur,
|
|
@@ -332,11 +337,11 @@ var DateTimePickerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
332
337
|
selectProps: mergedTimePickerSelectProps,
|
|
333
338
|
spacing: timePickerProps.spacing || spacing,
|
|
334
339
|
testId: timePickerProps.testId || testId && "".concat(testId, "--timepicker"),
|
|
335
|
-
timeFormat: timePickerProps.timeFormat
|
|
336
|
-
timeIsEditable: timePickerProps.timeIsEditable
|
|
337
|
-
times: timePickerProps.times
|
|
340
|
+
timeFormat: timePickerProps.timeFormat,
|
|
341
|
+
timeIsEditable: timePickerProps.timeIsEditable,
|
|
342
|
+
times: timePickerProps.times,
|
|
338
343
|
value: timeValue
|
|
339
|
-
}))
|
|
344
|
+
})), isClearable && !isDisabled ? jsx("button", {
|
|
340
345
|
css: iconContainerStyles,
|
|
341
346
|
onClick: this.onClear,
|
|
342
347
|
"data-testid": testId && "".concat(testId, "--icon--container"),
|
|
@@ -16,7 +16,6 @@ import React from 'react';
|
|
|
16
16
|
|
|
17
17
|
// eslint-disable-next-line no-restricted-imports
|
|
18
18
|
import { format, isValid } from 'date-fns';
|
|
19
|
-
import pick from 'lodash/pick';
|
|
20
19
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
21
20
|
import { createLocalizationProvider } from '@atlaskit/locale';
|
|
22
21
|
import Select, { CreatableSelect, mergeStyles } from '@atlaskit/select';
|
|
@@ -28,7 +27,7 @@ import parseTime from '../internal/parse-time';
|
|
|
28
27
|
import { convertTokens } from '../internal/parse-tokens';
|
|
29
28
|
import { makeSingleValue } from '../internal/single-value';
|
|
30
29
|
var packageName = "@atlaskit/datetime-picker";
|
|
31
|
-
var packageVersion = "
|
|
30
|
+
var packageVersion = "14.0.0";
|
|
32
31
|
var menuStyles = {
|
|
33
32
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
34
33
|
position: 'static',
|
|
@@ -86,8 +85,13 @@ var TimePickerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
86
85
|
});
|
|
87
86
|
// All state needs to be accessed via this function so that the state is mapped from props
|
|
88
87
|
// correctly to allow controlled/uncontrolled usage.
|
|
89
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
90
|
-
|
|
88
|
+
_defineProperty(_assertThisInitialized(_this), "getValue", function () {
|
|
89
|
+
var _this$props$value;
|
|
90
|
+
return (_this$props$value = _this.props.value) !== null && _this$props$value !== void 0 ? _this$props$value : _this.state.value;
|
|
91
|
+
});
|
|
92
|
+
_defineProperty(_assertThisInitialized(_this), "getIsOpen", function () {
|
|
93
|
+
var _this$props$isOpen;
|
|
94
|
+
return (_this$props$isOpen = _this.props.isOpen) !== null && _this$props$isOpen !== void 0 ? _this$props$isOpen : _this.state.isOpen;
|
|
91
95
|
});
|
|
92
96
|
_defineProperty(_assertThisInitialized(_this), "onChange", function (newValue, action) {
|
|
93
97
|
var rawValue = newValue ? newValue.value || newValue : '';
|
|
@@ -130,7 +134,7 @@ var TimePickerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
130
134
|
});
|
|
131
135
|
_defineProperty(_assertThisInitialized(_this), "onMenuOpen", function () {
|
|
132
136
|
// Don't open menu after the user has clicked clear
|
|
133
|
-
if (_this.
|
|
137
|
+
if (_this.state.clearingFromIcon) {
|
|
134
138
|
_this.setState({
|
|
135
139
|
clearingFromIcon: false
|
|
136
140
|
});
|
|
@@ -142,7 +146,7 @@ var TimePickerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
142
146
|
});
|
|
143
147
|
_defineProperty(_assertThisInitialized(_this), "onMenuClose", function () {
|
|
144
148
|
// Don't close menu after the user has clicked clear
|
|
145
|
-
if (_this.
|
|
149
|
+
if (_this.state.clearingFromIcon) {
|
|
146
150
|
_this.setState({
|
|
147
151
|
clearingFromIcon: false
|
|
148
152
|
});
|
|
@@ -176,7 +180,7 @@ var TimePickerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
176
180
|
_defineProperty(_assertThisInitialized(_this), "onSelectKeyDown", function (event) {
|
|
177
181
|
var key = event.key;
|
|
178
182
|
var keyPressed = key.toLowerCase();
|
|
179
|
-
if (_this.
|
|
183
|
+
if (_this.state.clearingFromIcon && (keyPressed === 'backspace' || keyPressed === 'delete')) {
|
|
180
184
|
// If being cleared from keyboard, don't change behaviour
|
|
181
185
|
_this.setState({
|
|
182
186
|
clearingFromIcon: false
|
|
@@ -211,10 +215,8 @@ var TimePickerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
211
215
|
times = _this$props2.times;
|
|
212
216
|
var ICON_PADDING = 2;
|
|
213
217
|
var l10n = createLocalizationProvider(locale);
|
|
214
|
-
var
|
|
215
|
-
|
|
216
|
-
value = _this$getSafeState$va === void 0 ? '' : _this$getSafeState$va,
|
|
217
|
-
isOpen = _this$getSafeState.isOpen;
|
|
218
|
+
var value = this.getValue() || '';
|
|
219
|
+
var isOpen = this.getIsOpen();
|
|
218
220
|
var _selectProps$styles = selectProps.styles,
|
|
219
221
|
selectStyles = _selectProps$styles === void 0 ? {} : _selectProps$styles,
|
|
220
222
|
otherSelectProps = _objectWithoutProperties(selectProps, _excluded);
|
|
@@ -77,18 +77,8 @@ declare class DatePickerComponent extends Component<DatePickerProps, State> {
|
|
|
77
77
|
l10n: LocalizationProvider;
|
|
78
78
|
locale: string;
|
|
79
79
|
} | null;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
value: string;
|
|
83
|
-
isOpen: boolean;
|
|
84
|
-
isFocused: boolean;
|
|
85
|
-
clearingFromIcon: boolean;
|
|
86
|
-
calendarValue: string;
|
|
87
|
-
selectInputValue: string;
|
|
88
|
-
l10n: LocalizationProvider;
|
|
89
|
-
locale: string;
|
|
90
|
-
shouldSetFocusOnCurrentDay: boolean;
|
|
91
|
-
};
|
|
80
|
+
getValue: () => string;
|
|
81
|
+
getIsOpen: () => boolean;
|
|
92
82
|
isDateDisabled: (date: string) => boolean;
|
|
93
83
|
onCalendarChange: ({ iso }: {
|
|
94
84
|
iso: string;
|
|
@@ -28,8 +28,6 @@ declare const dateTimePickerDefaultProps: {
|
|
|
28
28
|
isInvalid: boolean;
|
|
29
29
|
datePickerProps: {};
|
|
30
30
|
timePickerProps: {};
|
|
31
|
-
datePickerSelectProps: {};
|
|
32
|
-
timePickerSelectProps: {};
|
|
33
31
|
times: string[];
|
|
34
32
|
spacing: NonNullable<import("../types").Spacing | undefined>;
|
|
35
33
|
locale: string;
|
|
@@ -39,13 +37,12 @@ export declare const timePickerDefaultAriaLabel = "Time";
|
|
|
39
37
|
declare class DateTimePickerComponent extends React.Component<DateTimePickerProps, State> {
|
|
40
38
|
static defaultProps: DateTimePickerProps;
|
|
41
39
|
state: State;
|
|
42
|
-
|
|
40
|
+
getParsedValues: () => {
|
|
43
41
|
dateValue: string;
|
|
44
42
|
timeValue: string;
|
|
45
43
|
zoneValue: string;
|
|
46
|
-
value: string;
|
|
47
|
-
isFocused: boolean;
|
|
48
44
|
};
|
|
45
|
+
getValue: () => string;
|
|
49
46
|
parseValue(value: string, dateValue: string, timeValue: string, zoneValue: string): {
|
|
50
47
|
dateValue: string;
|
|
51
48
|
timeValue: string;
|
|
@@ -73,5 +70,5 @@ export { DateTimePickerComponent as DateTimePickerWithoutAnalytics };
|
|
|
73
70
|
* - [Code](https://atlassian.design/components/datetime-picker/code)
|
|
74
71
|
* - [Usage](https://atlassian.design/components/datetime-picker/usage)
|
|
75
72
|
*/
|
|
76
|
-
declare const DateTimePicker: React.ForwardRefExoticComponent<Pick<Pick<Pick<Omit<DateTimePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, never> & Partial<Pick<Omit<DateTimePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "times" | "testId" | "appearance" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "value" | "autoFocus" | "name" | "spacing" | "isInvalid" | "
|
|
73
|
+
declare const DateTimePicker: React.ForwardRefExoticComponent<Pick<Pick<Pick<Omit<DateTimePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, never> & Partial<Pick<Omit<DateTimePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "times" | "testId" | "appearance" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "value" | "autoFocus" | "name" | "spacing" | "isInvalid" | "timeIsEditable" | "datePickerProps" | "timePickerProps" | "parseValue">> & Partial<Pick<DateTimePickerProps, "ref" | "createAnalyticsEvent">>, "times" | "testId" | "appearance" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "createAnalyticsEvent" | "value" | "autoFocus" | "name" | "spacing" | "isInvalid" | "timeIsEditable" | "datePickerProps" | "timePickerProps" | "parseValue"> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "times" | "testId" | "appearance" | "innerProps" | "isDisabled" | "key" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "analyticsContext" | "createAnalyticsEvent" | "value" | "autoFocus" | "name" | "spacing" | "isInvalid" | "timeIsEditable" | "datePickerProps" | "timePickerProps" | "parseValue"> & React.RefAttributes<any>>;
|
|
77
74
|
export default DateTimePicker;
|
|
@@ -65,7 +65,8 @@ declare class TimePickerComponent extends React.Component<TimePickerProps, State
|
|
|
65
65
|
value: string;
|
|
66
66
|
isFocused: boolean;
|
|
67
67
|
};
|
|
68
|
-
|
|
68
|
+
getValue: () => string;
|
|
69
|
+
getIsOpen: () => boolean;
|
|
69
70
|
onChange: (newValue: ValueType<OptionType> | string, action?: ActionMeta<OptionType>) => void;
|
|
70
71
|
/**
|
|
71
72
|
* Only allow custom times if timeIsEditable prop is true
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as DatePicker } from './components/date-picker';
|
|
2
2
|
export { default as TimePicker } from './components/time-picker';
|
|
3
3
|
export { default as DateTimePicker } from './components/date-time-picker';
|
|
4
|
-
export type { Appearance, Spacing, DatePickerBaseProps as DatePickerProps, TimePickerBaseProps as TimePickerProps, DateTimePickerBaseProps as DateTimePickerProps, } from './types';
|
|
4
|
+
export type { Appearance, Spacing, DatePickerBaseProps as DatePickerProps, TimePickerBaseProps as TimePickerProps, DateTimePickerBaseProps as DateTimePickerProps, DateTimePickerSelectProps, } from './types';
|
package/dist/types/types.d.ts
CHANGED
|
@@ -4,12 +4,48 @@ import { type DropdownIndicatorProps, type OptionType, type SelectProps } from '
|
|
|
4
4
|
export type Appearance = 'default' | 'subtle' | 'none';
|
|
5
5
|
export type Spacing = 'compact' | 'default';
|
|
6
6
|
type Combine<First, Second> = Omit<First, keyof Second> & Second;
|
|
7
|
+
/**
|
|
8
|
+
* Props to apply to the select. These include all of [the props from our
|
|
9
|
+
* `Select` component](/components/select). For the following properties, use
|
|
10
|
+
* the top-level prop alternatives:
|
|
11
|
+
*
|
|
12
|
+
* - `aria-describedby`, use `aria-describedby` prop
|
|
13
|
+
* - `aria-label`, use `label` prop
|
|
14
|
+
* - `inputId`, use `id` prop
|
|
15
|
+
* - `placeholder`, use `placeholder` prop
|
|
16
|
+
*
|
|
17
|
+
* Example:
|
|
18
|
+
*
|
|
19
|
+
* ```tsx
|
|
20
|
+
* // Don't do this
|
|
21
|
+
* <DatePicker selectProps={{
|
|
22
|
+
* 'aria-describedby': 'helper-id'
|
|
23
|
+
* }} />
|
|
24
|
+
*
|
|
25
|
+
* // Do this
|
|
26
|
+
* <DatePicker aria-describedby="helper-id" />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export type DateTimePickerSelectProps = Combine<SelectProps<OptionType>, {
|
|
30
|
+
/**
|
|
31
|
+
* Use the `aria-describedby` prop on the picker..
|
|
32
|
+
*/
|
|
33
|
+
'aria-describedby'?: never;
|
|
34
|
+
/**
|
|
35
|
+
* Use the `label` prop on the picker..
|
|
36
|
+
*/
|
|
37
|
+
'aria-label'?: never;
|
|
38
|
+
/**
|
|
39
|
+
* Use the `id` prop on the picker.`.
|
|
40
|
+
*/
|
|
41
|
+
inputId?: never;
|
|
42
|
+
/**
|
|
43
|
+
* Use the `placeholder` prop on the picker.
|
|
44
|
+
*/
|
|
45
|
+
placeholder?: never;
|
|
46
|
+
}>;
|
|
7
47
|
interface PickerSelectProps {
|
|
8
|
-
|
|
9
|
-
* Props to apply to the select. These include all of [the props from our
|
|
10
|
-
* `Select` component](/components/select).
|
|
11
|
-
*/
|
|
12
|
-
selectProps?: Combine<SelectProps<OptionType>, {}>;
|
|
48
|
+
selectProps?: DateTimePickerSelectProps;
|
|
13
49
|
}
|
|
14
50
|
export interface DatePickerBaseProps extends WithAnalyticsEventsProps, PickerSelectProps {
|
|
15
51
|
/**
|
|
@@ -298,8 +334,8 @@ export interface DateTimePickerBaseProps extends WithAnalyticsEventsProps {
|
|
|
298
334
|
/**
|
|
299
335
|
* Used to associate accessible descriptions to both the date and time
|
|
300
336
|
* picker. If you want to associate individual accessible descriptions, this
|
|
301
|
-
* should be done through the `
|
|
302
|
-
* `
|
|
337
|
+
* should be done through the `aria-describedby` props on the
|
|
338
|
+
* `datePickerProps` and `timePickerProps`.
|
|
303
339
|
*/
|
|
304
340
|
'aria-describedby'?: string;
|
|
305
341
|
/**
|
|
@@ -345,18 +381,10 @@ export interface DateTimePickerBaseProps extends WithAnalyticsEventsProps {
|
|
|
345
381
|
* The ISO time that should be used as the input value.
|
|
346
382
|
*/
|
|
347
383
|
value?: string;
|
|
348
|
-
/**
|
|
349
|
-
* Set if users can edit the input, allowing them to add custom times.
|
|
350
|
-
*/
|
|
351
|
-
timeIsEditable?: boolean;
|
|
352
384
|
/**
|
|
353
385
|
* Set if the picker has an invalid value.
|
|
354
386
|
*/
|
|
355
387
|
isInvalid?: boolean;
|
|
356
|
-
/**
|
|
357
|
-
* Format the date with a string that is accepted by [date-fns's format function](https://date-fns.org/v1.29.0/docs/format).
|
|
358
|
-
*/
|
|
359
|
-
dateFormat?: string;
|
|
360
388
|
/**
|
|
361
389
|
* Props applied to the `DatePicker`.
|
|
362
390
|
*/
|
|
@@ -373,22 +401,6 @@ export interface DateTimePickerBaseProps extends WithAnalyticsEventsProps {
|
|
|
373
401
|
timeValue: string;
|
|
374
402
|
zoneValue: string;
|
|
375
403
|
};
|
|
376
|
-
/**
|
|
377
|
-
* [Select props](/components/select) to pass onto the `DatePicker` component's `Select`. This can be used to set options such as placeholder text.
|
|
378
|
-
*/
|
|
379
|
-
datePickerSelectProps?: SelectProps<any>;
|
|
380
|
-
/**
|
|
381
|
-
* [Select props](/components/select) to pass onto the `TimePicker` component's `Select`. This can be used to set options such as placeholder text.
|
|
382
|
-
*/
|
|
383
|
-
timePickerSelectProps?: SelectProps<any>;
|
|
384
|
-
/**
|
|
385
|
-
* The times shown by the `TimePicker`.
|
|
386
|
-
*/
|
|
387
|
-
times?: Array<string>;
|
|
388
|
-
/**
|
|
389
|
-
* The format that times are displayed in. Values should be those accepted by [date-fns's format function](https://date-fns.org/v1.29.0/docs/format).
|
|
390
|
-
*/
|
|
391
|
-
timeFormat?: string;
|
|
392
404
|
/**
|
|
393
405
|
* The spacing for the select control.
|
|
394
406
|
*
|
|
@@ -77,18 +77,8 @@ declare class DatePickerComponent extends Component<DatePickerProps, State> {
|
|
|
77
77
|
l10n: LocalizationProvider;
|
|
78
78
|
locale: string;
|
|
79
79
|
} | null;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
value: string;
|
|
83
|
-
isOpen: boolean;
|
|
84
|
-
isFocused: boolean;
|
|
85
|
-
clearingFromIcon: boolean;
|
|
86
|
-
calendarValue: string;
|
|
87
|
-
selectInputValue: string;
|
|
88
|
-
l10n: LocalizationProvider;
|
|
89
|
-
locale: string;
|
|
90
|
-
shouldSetFocusOnCurrentDay: boolean;
|
|
91
|
-
};
|
|
80
|
+
getValue: () => string;
|
|
81
|
+
getIsOpen: () => boolean;
|
|
92
82
|
isDateDisabled: (date: string) => boolean;
|
|
93
83
|
onCalendarChange: ({ iso }: {
|
|
94
84
|
iso: string;
|
|
@@ -28,8 +28,6 @@ declare const dateTimePickerDefaultProps: {
|
|
|
28
28
|
isInvalid: boolean;
|
|
29
29
|
datePickerProps: {};
|
|
30
30
|
timePickerProps: {};
|
|
31
|
-
datePickerSelectProps: {};
|
|
32
|
-
timePickerSelectProps: {};
|
|
33
31
|
times: string[];
|
|
34
32
|
spacing: NonNullable<import("../types").Spacing | undefined>;
|
|
35
33
|
locale: string;
|
|
@@ -39,13 +37,12 @@ export declare const timePickerDefaultAriaLabel = "Time";
|
|
|
39
37
|
declare class DateTimePickerComponent extends React.Component<DateTimePickerProps, State> {
|
|
40
38
|
static defaultProps: DateTimePickerProps;
|
|
41
39
|
state: State;
|
|
42
|
-
|
|
40
|
+
getParsedValues: () => {
|
|
43
41
|
dateValue: string;
|
|
44
42
|
timeValue: string;
|
|
45
43
|
zoneValue: string;
|
|
46
|
-
value: string;
|
|
47
|
-
isFocused: boolean;
|
|
48
44
|
};
|
|
45
|
+
getValue: () => string;
|
|
49
46
|
parseValue(value: string, dateValue: string, timeValue: string, zoneValue: string): {
|
|
50
47
|
dateValue: string;
|
|
51
48
|
timeValue: string;
|
|
@@ -73,5 +70,5 @@ export { DateTimePickerComponent as DateTimePickerWithoutAnalytics };
|
|
|
73
70
|
* - [Code](https://atlassian.design/components/datetime-picker/code)
|
|
74
71
|
* - [Usage](https://atlassian.design/components/datetime-picker/usage)
|
|
75
72
|
*/
|
|
76
|
-
declare const DateTimePicker: React.ForwardRefExoticComponent<Pick<Pick<Pick<Omit<DateTimePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, never> & Partial<Pick<Omit<DateTimePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "times" | "testId" | "appearance" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "value" | "autoFocus" | "name" | "spacing" | "isInvalid" | "
|
|
73
|
+
declare const DateTimePicker: React.ForwardRefExoticComponent<Pick<Pick<Pick<Omit<DateTimePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, never> & Partial<Pick<Omit<DateTimePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "times" | "testId" | "appearance" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "value" | "autoFocus" | "name" | "spacing" | "isInvalid" | "timeIsEditable" | "datePickerProps" | "timePickerProps" | "parseValue">> & Partial<Pick<DateTimePickerProps, "ref" | "createAnalyticsEvent">>, "times" | "testId" | "appearance" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "createAnalyticsEvent" | "value" | "autoFocus" | "name" | "spacing" | "isInvalid" | "timeIsEditable" | "datePickerProps" | "timePickerProps" | "parseValue"> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "times" | "testId" | "appearance" | "innerProps" | "isDisabled" | "key" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "analyticsContext" | "createAnalyticsEvent" | "value" | "autoFocus" | "name" | "spacing" | "isInvalid" | "timeIsEditable" | "datePickerProps" | "timePickerProps" | "parseValue"> & React.RefAttributes<any>>;
|
|
77
74
|
export default DateTimePicker;
|
|
@@ -65,7 +65,8 @@ declare class TimePickerComponent extends React.Component<TimePickerProps, State
|
|
|
65
65
|
value: string;
|
|
66
66
|
isFocused: boolean;
|
|
67
67
|
};
|
|
68
|
-
|
|
68
|
+
getValue: () => string;
|
|
69
|
+
getIsOpen: () => boolean;
|
|
69
70
|
onChange: (newValue: ValueType<OptionType> | string, action?: ActionMeta<OptionType>) => void;
|
|
70
71
|
/**
|
|
71
72
|
* Only allow custom times if timeIsEditable prop is true
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as DatePicker } from './components/date-picker';
|
|
2
2
|
export { default as TimePicker } from './components/time-picker';
|
|
3
3
|
export { default as DateTimePicker } from './components/date-time-picker';
|
|
4
|
-
export type { Appearance, Spacing, DatePickerBaseProps as DatePickerProps, TimePickerBaseProps as TimePickerProps, DateTimePickerBaseProps as DateTimePickerProps, } from './types';
|
|
4
|
+
export type { Appearance, Spacing, DatePickerBaseProps as DatePickerProps, TimePickerBaseProps as TimePickerProps, DateTimePickerBaseProps as DateTimePickerProps, DateTimePickerSelectProps, } from './types';
|