@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,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
/**
|
|
4
3
|
* @jsxRuntime classic
|
|
@@ -9,7 +8,6 @@ import React from 'react';
|
|
|
9
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
10
9
|
import { css, jsx } from '@emotion/react';
|
|
11
10
|
import { format, isValid, parseISO } from 'date-fns';
|
|
12
|
-
import pick from 'lodash/pick';
|
|
13
11
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
14
12
|
import SelectClearIcon from '@atlaskit/icon/glyph/select-clear';
|
|
15
13
|
import { mergeStyles } from '@atlaskit/select';
|
|
@@ -20,7 +18,7 @@ import { convertTokens } from '../internal/parse-tokens';
|
|
|
20
18
|
import DatePicker from './date-picker';
|
|
21
19
|
import TimePicker from './time-picker';
|
|
22
20
|
const packageName = "@atlaskit/datetime-picker";
|
|
23
|
-
const packageVersion = "
|
|
21
|
+
const packageVersion = "14.0.0";
|
|
24
22
|
// Make DatePicker 50% the width of DateTimePicker
|
|
25
23
|
// If rendering an icon container, shrink the TimePicker
|
|
26
24
|
const datePickerContainerStyles = css({
|
|
@@ -83,8 +81,6 @@ const dateTimePickerDefaultProps = {
|
|
|
83
81
|
isInvalid: false,
|
|
84
82
|
datePickerProps: {},
|
|
85
83
|
timePickerProps: {},
|
|
86
|
-
datePickerSelectProps: {},
|
|
87
|
-
timePickerSelectProps: {},
|
|
88
84
|
times: defaultTimes,
|
|
89
85
|
spacing: 'default',
|
|
90
86
|
locale: 'en-US'
|
|
@@ -105,15 +101,10 @@ class DateTimePickerComponent extends React.Component {
|
|
|
105
101
|
});
|
|
106
102
|
// All state needs to be accessed via this function so that the state is mapped from props
|
|
107
103
|
// correctly to allow controlled/uncontrolled usage.
|
|
108
|
-
_defineProperty(this, "
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
};
|
|
113
|
-
return {
|
|
114
|
-
...mappedState,
|
|
115
|
-
...this.parseValue(mappedState.value, mappedState.dateValue, mappedState.timeValue, mappedState.zoneValue)
|
|
116
|
-
};
|
|
104
|
+
_defineProperty(this, "getParsedValues", () => this.parseValue(this.getValue(), this.state.dateValue, this.state.timeValue, this.state.zoneValue));
|
|
105
|
+
_defineProperty(this, "getValue", () => {
|
|
106
|
+
var _this$props$value;
|
|
107
|
+
return (_this$props$value = this.props.value) !== null && _this$props$value !== void 0 ? _this$props$value : this.state.value;
|
|
117
108
|
});
|
|
118
109
|
_defineProperty(this, "onBlur", event => {
|
|
119
110
|
this.setState({
|
|
@@ -128,28 +119,44 @@ class DateTimePickerComponent extends React.Component {
|
|
|
128
119
|
this.props.onFocus(event);
|
|
129
120
|
});
|
|
130
121
|
_defineProperty(this, "onDateChange", dateValue => {
|
|
122
|
+
const parsedValues = this.getParsedValues();
|
|
131
123
|
this.onValueChange({
|
|
132
|
-
|
|
133
|
-
|
|
124
|
+
dateValue,
|
|
125
|
+
timeValue: parsedValues.timeValue,
|
|
126
|
+
zoneValue: parsedValues.zoneValue
|
|
134
127
|
});
|
|
135
128
|
});
|
|
136
129
|
_defineProperty(this, "onTimeChange", timeValue => {
|
|
130
|
+
const parsedValues = this.getParsedValues();
|
|
137
131
|
this.onValueChange({
|
|
138
|
-
|
|
139
|
-
timeValue
|
|
132
|
+
dateValue: parsedValues.dateValue,
|
|
133
|
+
timeValue,
|
|
134
|
+
zoneValue: parsedValues.zoneValue
|
|
140
135
|
});
|
|
141
136
|
});
|
|
142
137
|
_defineProperty(this, "onClear", () => {
|
|
138
|
+
const parsedValues = this.getParsedValues();
|
|
143
139
|
this.onValueChange({
|
|
144
|
-
|
|
140
|
+
dateValue: '',
|
|
145
141
|
timeValue: '',
|
|
146
|
-
|
|
142
|
+
zoneValue: parsedValues.zoneValue
|
|
147
143
|
});
|
|
148
144
|
});
|
|
149
145
|
}
|
|
150
146
|
parseValue(value, dateValue, timeValue, zoneValue) {
|
|
151
147
|
if (this.props.parseValue) {
|
|
152
|
-
|
|
148
|
+
const parsedFromFn = this.props.parseValue(value, dateValue, timeValue, zoneValue);
|
|
149
|
+
// This handles cases found in Jira where the parse function actually does
|
|
150
|
+
// nothing and returns undefined. The previous `getSafeState` function
|
|
151
|
+
// just spread the values over the state, but if it returned `undefined`,
|
|
152
|
+
// it would just rely on the previous state values. Considering this is
|
|
153
|
+
// what is input to this function anyway, this is a safe way to handle
|
|
154
|
+
// this, colocate the behavior, and not rely on `getSafeState`.
|
|
155
|
+
return parsedFromFn || {
|
|
156
|
+
dateValue,
|
|
157
|
+
timeValue,
|
|
158
|
+
zoneValue
|
|
159
|
+
};
|
|
153
160
|
}
|
|
154
161
|
const parsed = parseISO(value);
|
|
155
162
|
return isValid(parsed) ? {
|
|
@@ -183,7 +190,7 @@ class DateTimePickerComponent extends React.Component {
|
|
|
183
190
|
});
|
|
184
191
|
this.props.onChange(valueWithValidZone);
|
|
185
192
|
// If the date or time value was cleared when there is an existing datetime value, then clear the value.
|
|
186
|
-
} else if (this.
|
|
193
|
+
} else if (this.getValue()) {
|
|
187
194
|
this.setState({
|
|
188
195
|
value: ''
|
|
189
196
|
});
|
|
@@ -195,9 +202,7 @@ class DateTimePickerComponent extends React.Component {
|
|
|
195
202
|
'aria-describedby': ariaDescribedBy,
|
|
196
203
|
appearance,
|
|
197
204
|
autoFocus,
|
|
198
|
-
|
|
199
|
-
datePickerProps,
|
|
200
|
-
datePickerSelectProps,
|
|
205
|
+
datePickerProps: datePickerPropsWithSelectProps,
|
|
201
206
|
id,
|
|
202
207
|
innerProps,
|
|
203
208
|
isDisabled,
|
|
@@ -206,35 +211,34 @@ class DateTimePickerComponent extends React.Component {
|
|
|
206
211
|
name,
|
|
207
212
|
spacing,
|
|
208
213
|
testId,
|
|
209
|
-
|
|
210
|
-
timeIsEditable,
|
|
211
|
-
timePickerProps,
|
|
212
|
-
timePickerSelectProps,
|
|
213
|
-
times
|
|
214
|
+
timePickerProps: timePickerPropsWithSelectProps
|
|
214
215
|
} = this.props;
|
|
216
|
+
const value = this.getValue();
|
|
215
217
|
const {
|
|
216
|
-
isFocused
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const {
|
|
222
|
-
styles: datePickerStyles = {}
|
|
223
|
-
} = datePickerSelectProps;
|
|
218
|
+
isFocused
|
|
219
|
+
} = this.state;
|
|
220
|
+
const parsedValues = this.getParsedValues();
|
|
221
|
+
const dateValue = parsedValues === null || parsedValues === void 0 ? void 0 : parsedValues.dateValue;
|
|
222
|
+
const timeValue = parsedValues === null || parsedValues === void 0 ? void 0 : parsedValues.timeValue;
|
|
224
223
|
const {
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
selectProps: datePickerSelectProps,
|
|
225
|
+
...datePickerProps
|
|
226
|
+
} = datePickerPropsWithSelectProps;
|
|
227
|
+
const datePickerAriaDescribedBy = datePickerProps['aria-describedby'] || ariaDescribedBy;
|
|
228
|
+
const datePickerLabel = datePickerProps.label || datePickerDefaultAriaLabel;
|
|
227
229
|
const mergedDatePickerSelectProps = {
|
|
228
230
|
...datePickerSelectProps,
|
|
229
|
-
|
|
230
|
-
'aria-label': datePickerProps['label'] || datePickerSelectProps['aria-label'] || datePickerDefaultAriaLabel,
|
|
231
|
-
styles: mergeStyles(styles, datePickerStyles)
|
|
231
|
+
styles: mergeStyles(styles, datePickerSelectProps === null || datePickerSelectProps === void 0 ? void 0 : datePickerSelectProps.styles)
|
|
232
232
|
};
|
|
233
|
+
const {
|
|
234
|
+
selectProps: timePickerSelectProps,
|
|
235
|
+
...timePickerProps
|
|
236
|
+
} = timePickerPropsWithSelectProps;
|
|
237
|
+
const timePickerAriaDescribedBy = timePickerProps['aria-describedby'] || ariaDescribedBy;
|
|
238
|
+
const timePickerLabel = timePickerProps.label || timePickerDefaultAriaLabel;
|
|
233
239
|
const mergedTimePickerSelectProps = {
|
|
234
240
|
...timePickerSelectProps,
|
|
235
|
-
|
|
236
|
-
'aria-label': timePickerProps['label'] || timePickerSelectProps['aria-label'] || timePickerDefaultAriaLabel,
|
|
237
|
-
styles: mergeStyles(styles, timePickerStyles)
|
|
241
|
+
styles: mergeStyles(styles, timePickerSelectProps === null || timePickerSelectProps === void 0 ? void 0 : timePickerSelectProps.styles)
|
|
238
242
|
};
|
|
239
243
|
|
|
240
244
|
// Render DateTimePicker's IconContainer when a value has been filled
|
|
@@ -254,10 +258,11 @@ class DateTimePickerComponent extends React.Component {
|
|
|
254
258
|
"data-testid": testId && `${testId}--input`
|
|
255
259
|
}), jsx("div", {
|
|
256
260
|
css: datePickerContainerStyles
|
|
257
|
-
}, jsx(DatePicker,
|
|
261
|
+
}, jsx(DatePicker, {
|
|
258
262
|
appearance: appearance,
|
|
263
|
+
"aria-describedby": datePickerAriaDescribedBy,
|
|
259
264
|
autoFocus: datePickerProps.autoFocus || autoFocus,
|
|
260
|
-
dateFormat: datePickerProps.dateFormat
|
|
265
|
+
dateFormat: datePickerProps.dateFormat,
|
|
261
266
|
defaultIsOpen: datePickerProps.defaultIsOpen,
|
|
262
267
|
defaultValue: datePickerProps.defaultValue,
|
|
263
268
|
disabled: datePickerProps.disabled,
|
|
@@ -268,15 +273,9 @@ class DateTimePickerComponent extends React.Component {
|
|
|
268
273
|
id: datePickerProps.id || id,
|
|
269
274
|
innerProps: datePickerProps.innerProps,
|
|
270
275
|
isDisabled: datePickerProps.isDisabled || isDisabled,
|
|
271
|
-
isInvalid: datePickerProps.isInvalid || isInvalid
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
// `isOpen` to `undefined` forever. I believe this has to do with
|
|
275
|
-
// the `getSafeState` function in the picker, since it overwrites
|
|
276
|
-
// state with values from the props.
|
|
277
|
-
}, datePickerProps.isOpen ? {
|
|
278
|
-
isOpen: datePickerProps.isOpen
|
|
279
|
-
} : {}, {
|
|
276
|
+
isInvalid: datePickerProps.isInvalid || isInvalid,
|
|
277
|
+
isOpen: datePickerProps.isOpen,
|
|
278
|
+
label: datePickerLabel,
|
|
280
279
|
locale: datePickerProps.locale || locale,
|
|
281
280
|
maxDate: datePickerProps.maxDate,
|
|
282
281
|
minDate: datePickerProps.minDate,
|
|
@@ -293,10 +292,11 @@ class DateTimePickerComponent extends React.Component {
|
|
|
293
292
|
testId: testId && `${testId}--datepicker` || datePickerProps.testId,
|
|
294
293
|
value: dateValue,
|
|
295
294
|
weekStartDay: datePickerProps.weekStartDay
|
|
296
|
-
}))
|
|
295
|
+
})), jsx("div", {
|
|
297
296
|
css: timePickerContainerStyles
|
|
298
|
-
}, jsx(TimePicker,
|
|
297
|
+
}, jsx(TimePicker, {
|
|
299
298
|
appearance: timePickerProps.appearance || appearance,
|
|
299
|
+
"aria-describedby": timePickerAriaDescribedBy,
|
|
300
300
|
autoFocus: timePickerProps.autoFocus,
|
|
301
301
|
defaultIsOpen: timePickerProps.defaultIsOpen,
|
|
302
302
|
defaultValue: timePickerProps.defaultValue,
|
|
@@ -305,15 +305,9 @@ class DateTimePickerComponent extends React.Component {
|
|
|
305
305
|
id: timePickerProps.id,
|
|
306
306
|
innerProps: timePickerProps.innerProps,
|
|
307
307
|
isDisabled: timePickerProps.isDisabled || isDisabled,
|
|
308
|
-
isInvalid: timePickerProps.isInvalid || isInvalid
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
// `isOpen` to `undefined` forever. I believe this has to do with
|
|
312
|
-
// the `getSafeState` function in the picker, since it overwrites
|
|
313
|
-
// state with values from the props.
|
|
314
|
-
}, timePickerProps.isOpen ? {
|
|
315
|
-
isOpen: timePickerProps.isOpen
|
|
316
|
-
} : {}, {
|
|
308
|
+
isInvalid: timePickerProps.isInvalid || isInvalid,
|
|
309
|
+
isOpen: timePickerProps.isOpen,
|
|
310
|
+
label: timePickerLabel,
|
|
317
311
|
locale: timePickerProps.locale || locale,
|
|
318
312
|
name: timePickerProps.name,
|
|
319
313
|
onBlur: timePickerProps.onBlur || this.onBlur,
|
|
@@ -324,11 +318,11 @@ class DateTimePickerComponent extends React.Component {
|
|
|
324
318
|
selectProps: mergedTimePickerSelectProps,
|
|
325
319
|
spacing: timePickerProps.spacing || spacing,
|
|
326
320
|
testId: timePickerProps.testId || testId && `${testId}--timepicker`,
|
|
327
|
-
timeFormat: timePickerProps.timeFormat
|
|
328
|
-
timeIsEditable: timePickerProps.timeIsEditable
|
|
329
|
-
times: timePickerProps.times
|
|
321
|
+
timeFormat: timePickerProps.timeFormat,
|
|
322
|
+
timeIsEditable: timePickerProps.timeIsEditable,
|
|
323
|
+
times: timePickerProps.times,
|
|
330
324
|
value: timeValue
|
|
331
|
-
}))
|
|
325
|
+
})), isClearable && !isDisabled ? jsx("button", {
|
|
332
326
|
css: iconContainerStyles,
|
|
333
327
|
onClick: this.onClear,
|
|
334
328
|
"data-testid": testId && `${testId}--icon--container`,
|
|
@@ -4,7 +4,6 @@ import React from 'react';
|
|
|
4
4
|
|
|
5
5
|
// eslint-disable-next-line no-restricted-imports
|
|
6
6
|
import { format, isValid } from 'date-fns';
|
|
7
|
-
import pick from 'lodash/pick';
|
|
8
7
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
9
8
|
import { createLocalizationProvider } from '@atlaskit/locale';
|
|
10
9
|
import Select, { CreatableSelect, mergeStyles } from '@atlaskit/select';
|
|
@@ -16,7 +15,7 @@ import parseTime from '../internal/parse-time';
|
|
|
16
15
|
import { convertTokens } from '../internal/parse-tokens';
|
|
17
16
|
import { makeSingleValue } from '../internal/single-value';
|
|
18
17
|
const packageName = "@atlaskit/datetime-picker";
|
|
19
|
-
const packageVersion = "
|
|
18
|
+
const packageVersion = "14.0.0";
|
|
20
19
|
const menuStyles = {
|
|
21
20
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
22
21
|
position: 'static',
|
|
@@ -65,11 +64,13 @@ class TimePickerComponent extends React.Component {
|
|
|
65
64
|
});
|
|
66
65
|
// All state needs to be accessed via this function so that the state is mapped from props
|
|
67
66
|
// correctly to allow controlled/uncontrolled usage.
|
|
68
|
-
_defineProperty(this, "
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
_defineProperty(this, "getValue", () => {
|
|
68
|
+
var _this$props$value;
|
|
69
|
+
return (_this$props$value = this.props.value) !== null && _this$props$value !== void 0 ? _this$props$value : this.state.value;
|
|
70
|
+
});
|
|
71
|
+
_defineProperty(this, "getIsOpen", () => {
|
|
72
|
+
var _this$props$isOpen;
|
|
73
|
+
return (_this$props$isOpen = this.props.isOpen) !== null && _this$props$isOpen !== void 0 ? _this$props$isOpen : this.state.isOpen;
|
|
73
74
|
});
|
|
74
75
|
_defineProperty(this, "onChange", (newValue, action) => {
|
|
75
76
|
const rawValue = newValue ? newValue.value || newValue : '';
|
|
@@ -114,7 +115,7 @@ class TimePickerComponent extends React.Component {
|
|
|
114
115
|
});
|
|
115
116
|
_defineProperty(this, "onMenuOpen", () => {
|
|
116
117
|
// Don't open menu after the user has clicked clear
|
|
117
|
-
if (this.
|
|
118
|
+
if (this.state.clearingFromIcon) {
|
|
118
119
|
this.setState({
|
|
119
120
|
clearingFromIcon: false
|
|
120
121
|
});
|
|
@@ -126,7 +127,7 @@ class TimePickerComponent extends React.Component {
|
|
|
126
127
|
});
|
|
127
128
|
_defineProperty(this, "onMenuClose", () => {
|
|
128
129
|
// Don't close menu after the user has clicked clear
|
|
129
|
-
if (this.
|
|
130
|
+
if (this.state.clearingFromIcon) {
|
|
130
131
|
this.setState({
|
|
131
132
|
clearingFromIcon: false
|
|
132
133
|
});
|
|
@@ -162,7 +163,7 @@ class TimePickerComponent extends React.Component {
|
|
|
162
163
|
key
|
|
163
164
|
} = event;
|
|
164
165
|
const keyPressed = key.toLowerCase();
|
|
165
|
-
if (this.
|
|
166
|
+
if (this.state.clearingFromIcon && (keyPressed === 'backspace' || keyPressed === 'delete')) {
|
|
166
167
|
// If being cleared from keyboard, don't change behaviour
|
|
167
168
|
this.setState({
|
|
168
169
|
clearingFromIcon: false
|
|
@@ -194,10 +195,8 @@ class TimePickerComponent extends React.Component {
|
|
|
194
195
|
} = this.props;
|
|
195
196
|
const ICON_PADDING = 2;
|
|
196
197
|
const l10n = createLocalizationProvider(locale);
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
isOpen
|
|
200
|
-
} = this.getSafeState();
|
|
198
|
+
const value = this.getValue() || '';
|
|
199
|
+
const isOpen = this.getIsOpen();
|
|
201
200
|
const {
|
|
202
201
|
styles: selectStyles = {},
|
|
203
202
|
...otherSelectProps
|
|
@@ -20,7 +20,6 @@ import { Component } from 'react';
|
|
|
20
20
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
21
21
|
import { jsx } from '@emotion/react';
|
|
22
22
|
import { format, isValid, lastDayOfMonth, parseISO } from 'date-fns';
|
|
23
|
-
import pick from 'lodash/pick';
|
|
24
23
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
25
24
|
import CalendarIcon from '@atlaskit/icon/glyph/calendar';
|
|
26
25
|
import { createLocalizationProvider } from '@atlaskit/locale';
|
|
@@ -31,7 +30,7 @@ import { getSafeCalendarValue, getShortISOString } from '../internal/parse-date'
|
|
|
31
30
|
import { convertTokens } from '../internal/parse-tokens';
|
|
32
31
|
import { makeSingleValue } from '../internal/single-value';
|
|
33
32
|
var packageName = "@atlaskit/datetime-picker";
|
|
34
|
-
var packageVersion = "
|
|
33
|
+
var packageVersion = "14.0.0";
|
|
35
34
|
var datePickerDefaultProps = {
|
|
36
35
|
appearance: 'default',
|
|
37
36
|
autoFocus: false,
|
|
@@ -73,8 +72,13 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
73
72
|
_defineProperty(_assertThisInitialized(_this), "containerRef", null);
|
|
74
73
|
// All state needs to be accessed via this function so that the state is mapped from props
|
|
75
74
|
// correctly to allow controlled/uncontrolled usage.
|
|
76
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
77
|
-
|
|
75
|
+
_defineProperty(_assertThisInitialized(_this), "getValue", function () {
|
|
76
|
+
var _this$props$value;
|
|
77
|
+
return (_this$props$value = _this.props.value) !== null && _this$props$value !== void 0 ? _this$props$value : _this.state.value;
|
|
78
|
+
});
|
|
79
|
+
_defineProperty(_assertThisInitialized(_this), "getIsOpen", function () {
|
|
80
|
+
var _this$props$isOpen;
|
|
81
|
+
return (_this$props$isOpen = _this.props.isOpen) !== null && _this$props$isOpen !== void 0 ? _this$props$isOpen : _this.state.isOpen;
|
|
78
82
|
});
|
|
79
83
|
_defineProperty(_assertThisInitialized(_this), "isDateDisabled", function (date) {
|
|
80
84
|
return _this.props.disabled.indexOf(date) > -1;
|
|
@@ -124,7 +128,7 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
124
128
|
});
|
|
125
129
|
});
|
|
126
130
|
_defineProperty(_assertThisInitialized(_this), "onInputClick", function () {
|
|
127
|
-
if (!_this.props.isDisabled && !_this.
|
|
131
|
+
if (!_this.props.isDisabled && !_this.getIsOpen()) {
|
|
128
132
|
_this.setState({
|
|
129
133
|
isOpen: true
|
|
130
134
|
});
|
|
@@ -149,7 +153,7 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
149
153
|
_defineProperty(_assertThisInitialized(_this), "onSelectBlur", function (event) {
|
|
150
154
|
var _this$containerRef3;
|
|
151
155
|
var newlyFocusedElement = event.relatedTarget;
|
|
152
|
-
if (_this.
|
|
156
|
+
if (_this.state.clearingFromIcon) {
|
|
153
157
|
// Don't close menu if blurring after the user has clicked clear
|
|
154
158
|
_this.setState({
|
|
155
159
|
clearingFromIcon: false
|
|
@@ -164,9 +168,8 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
164
168
|
}
|
|
165
169
|
});
|
|
166
170
|
_defineProperty(_assertThisInitialized(_this), "onSelectFocus", function (event) {
|
|
167
|
-
var
|
|
168
|
-
|
|
169
|
-
value = _this$getSafeState.value;
|
|
171
|
+
var clearingFromIcon = _this.state.clearingFromIcon;
|
|
172
|
+
var value = _this.getValue();
|
|
170
173
|
if (clearingFromIcon) {
|
|
171
174
|
// Don't open menu if focussing after the user has clicked clear
|
|
172
175
|
_this.setState({
|
|
@@ -200,9 +203,8 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
200
203
|
});
|
|
201
204
|
_defineProperty(_assertThisInitialized(_this), "onInputKeyDown", function (event) {
|
|
202
205
|
var _this$containerRef4;
|
|
203
|
-
var
|
|
204
|
-
|
|
205
|
-
calendarValue = _this$getSafeState2.calendarValue;
|
|
206
|
+
var calendarValue = _this.state.calendarValue;
|
|
207
|
+
var value = _this.getValue();
|
|
206
208
|
var keyPressed = event.key.toLowerCase();
|
|
207
209
|
|
|
208
210
|
// If the input is focused and the calendar is not visible, handle space and enter clicks
|
|
@@ -330,8 +332,7 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
330
332
|
if (parseInputValue) {
|
|
331
333
|
return parseInputValue(date, dateFormat || defaultDateFormat);
|
|
332
334
|
}
|
|
333
|
-
var
|
|
334
|
-
l10n = _this$getSafeState3.l10n;
|
|
335
|
+
var l10n = _this.state.l10n;
|
|
335
336
|
return l10n.parseDate(date);
|
|
336
337
|
});
|
|
337
338
|
/**
|
|
@@ -345,8 +346,7 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
345
346
|
var _this$props2 = _this.props,
|
|
346
347
|
formatDisplayLabel = _this$props2.formatDisplayLabel,
|
|
347
348
|
dateFormat = _this$props2.dateFormat;
|
|
348
|
-
var
|
|
349
|
-
l10n = _this$getSafeState4.l10n;
|
|
349
|
+
var l10n = _this.state.l10n;
|
|
350
350
|
if (formatDisplayLabel) {
|
|
351
351
|
return formatDisplayLabel(value, dateFormat || defaultDateFormat);
|
|
352
352
|
}
|
|
@@ -358,8 +358,7 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
358
358
|
if (placeholder) {
|
|
359
359
|
return placeholder;
|
|
360
360
|
}
|
|
361
|
-
var
|
|
362
|
-
l10n = _this$getSafeState5.l10n;
|
|
361
|
+
var l10n = _this.state.l10n;
|
|
363
362
|
return l10n.formatDate(placeholderDatetime);
|
|
364
363
|
});
|
|
365
364
|
_this.state = {
|
|
@@ -401,14 +400,13 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
401
400
|
locale = _this$props3.locale,
|
|
402
401
|
testId = _this$props3.testId,
|
|
403
402
|
weekStartDay = _this$props3.weekStartDay;
|
|
404
|
-
var _this$
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
selectInputValue = _this$getSafeState6.selectInputValue;
|
|
403
|
+
var _this$state = this.state,
|
|
404
|
+
calendarValue = _this$state.calendarValue,
|
|
405
|
+
selectInputValue = _this$state.selectInputValue;
|
|
406
|
+
var value = this.getValue();
|
|
409
407
|
var actualSelectInputValue;
|
|
410
408
|
actualSelectInputValue = selectInputValue;
|
|
411
|
-
var menuIsOpen =
|
|
409
|
+
var menuIsOpen = this.getIsOpen() && !isDisabled;
|
|
412
410
|
var showClearIndicator = Boolean((value || selectInputValue) && !hideIcon);
|
|
413
411
|
var dropDownIcon = appearance === 'subtle' || hideIcon || showClearIndicator ? null : icon;
|
|
414
412
|
var SingleValue = makeSingleValue({
|