@atlaskit/datetime-picker 15.12.2 → 15.13.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/components/date-picker.js +639 -7
  3. package/dist/cjs/components/date-time-picker.js +379 -9
  4. package/dist/cjs/components/time-picker.js +2 -2
  5. package/dist/es2019/components/date-picker.js +570 -5
  6. package/dist/es2019/components/date-time-picker.js +347 -6
  7. package/dist/es2019/components/time-picker.js +2 -2
  8. package/dist/esm/components/date-picker.js +637 -7
  9. package/dist/esm/components/date-time-picker.js +375 -8
  10. package/dist/esm/components/time-picker.js +2 -2
  11. package/dist/types/components/date-picker.d.ts +18 -19
  12. package/dist/types/components/date-time-picker.d.ts +14 -31
  13. package/dist/types-ts4.5/components/date-picker.d.ts +18 -19
  14. package/dist/types-ts4.5/components/date-time-picker.d.ts +14 -31
  15. package/package.json +5 -8
  16. package/dist/cjs/components/date-picker-class.js +0 -685
  17. package/dist/cjs/components/date-picker-fc.js +0 -639
  18. package/dist/cjs/components/date-time-picker-class.js +0 -436
  19. package/dist/cjs/components/date-time-picker-fc.js +0 -394
  20. package/dist/cjs/internal/ff-component.js +0 -58
  21. package/dist/es2019/components/date-picker-class.js +0 -649
  22. package/dist/es2019/components/date-picker-fc.js +0 -563
  23. package/dist/es2019/components/date-time-picker-class.js +0 -400
  24. package/dist/es2019/components/date-time-picker-fc.js +0 -354
  25. package/dist/es2019/internal/ff-component.js +0 -47
  26. package/dist/esm/components/date-picker-class.js +0 -680
  27. package/dist/esm/components/date-picker-fc.js +0 -630
  28. package/dist/esm/components/date-time-picker-class.js +0 -434
  29. package/dist/esm/components/date-time-picker-fc.js +0 -384
  30. package/dist/esm/internal/ff-component.js +0 -49
  31. package/dist/types/components/date-picker-class.d.ts +0 -110
  32. package/dist/types/components/date-picker-fc.d.ts +0 -20
  33. package/dist/types/components/date-time-picker-class.d.ts +0 -85
  34. package/dist/types/components/date-time-picker-fc.d.ts +0 -15
  35. package/dist/types/internal/ff-component.d.ts +0 -34
  36. package/dist/types-ts4.5/components/date-picker-class.d.ts +0 -110
  37. package/dist/types-ts4.5/components/date-picker-fc.d.ts +0 -20
  38. package/dist/types-ts4.5/components/date-time-picker-class.d.ts +0 -85
  39. package/dist/types-ts4.5/components/date-time-picker-fc.d.ts +0 -15
  40. package/dist/types-ts4.5/internal/ff-component.d.ts +0 -34
@@ -1,384 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
- var _excluded = ["selectProps"],
6
- _excluded2 = ["selectProps"];
7
- 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; }
8
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
- import React, { forwardRef, useCallback, useEffect, useState } from 'react';
10
- import { format, isValid, parseISO } from 'date-fns';
11
- import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
12
- import { IconButton } from '@atlaskit/button/new';
13
- import SelectClearIcon from '@atlaskit/icon/utility/migration/cross-circle--select-clear';
14
- import { fg } from '@atlaskit/platform-feature-flags';
15
- import { Box, Inline, xcss } from '@atlaskit/primitives';
16
- import { mergeStyles } from '@atlaskit/select';
17
- import { formatDateTimeZoneIntoIso } from '../internal';
18
- import { DateTimePickerContainer } from '../internal/date-time-picker-container';
19
- import { componentWithCondition } from '../internal/ff-component';
20
- import { convertTokens } from '../internal/parse-tokens';
21
- import DatePickerOld from './date-picker-class';
22
- import DatePickerNew from './date-picker-fc';
23
- import TimePicker from './time-picker';
24
- var DatePicker = componentWithCondition(
25
- // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
26
- function () {
27
- return fg('dst-date-picker-use-functional-component');
28
- }, DatePickerNew, DatePickerOld);
29
- var packageName = "@atlaskit/datetime-picker";
30
- var packageVersion = "15.12.2";
31
- var analyticsAttributes = {
32
- componentName: 'dateTimePicker',
33
- packageName: packageName,
34
- packageVersion: packageVersion
35
- };
36
-
37
- // Make DatePicker 50% the width of DateTimePicker
38
- // If rendering an icon container, shrink the TimePicker
39
- var datePickerContainerStyles = xcss({
40
- flexBasis: '50%',
41
- flexGrow: 1,
42
- flexShrink: 0
43
- });
44
- var timePickerContainerStyles = xcss({
45
- flexBasis: '50%',
46
- flexGrow: 1
47
- });
48
- var iconContainerStyles = xcss({
49
- display: 'flex',
50
- alignItems: 'center',
51
- flexBasis: 'inherit'
52
- });
53
-
54
- // react-select overrides (via @atlaskit/select).
55
- var styles = {
56
- control: function control(style) {
57
- return _objectSpread(_objectSpread({}, style), {}, {
58
- backgroundColor: 'transparent',
59
- border: 2,
60
- borderRadius: 0,
61
- paddingLeft: 0,
62
- ':hover': {
63
- backgroundColor: 'transparent',
64
- cursor: 'inherit'
65
- }
66
- });
67
- }
68
- };
69
- export var datePickerDefaultAriaLabel = 'Date';
70
- export var timePickerDefaultAriaLabel = 'Time';
71
-
72
- /**
73
- * __Date time picker__
74
- *
75
- * A date time picker allows the user to select an associated date and time.
76
- *
77
- * - [Examples](https://atlassian.design/components/datetime-picker/examples)
78
- * - [Code](https://atlassian.design/components/datetime-picker/code)
79
- * - [Usage](https://atlassian.design/components/datetime-picker/usage)
80
- */
81
- var DateTimePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
82
- var ariaDescribedBy = _ref['aria-describedby'],
83
- _ref$appearance = _ref.appearance,
84
- appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
85
- _ref$autoFocus = _ref.autoFocus,
86
- autoFocus = _ref$autoFocus === void 0 ? false : _ref$autoFocus,
87
- _ref$clearControlLabe = _ref.clearControlLabel,
88
- clearControlLabel = _ref$clearControlLabe === void 0 ? 'clear' : _ref$clearControlLabe,
89
- _ref$datePickerProps = _ref.datePickerProps,
90
- datePickerPropsWithSelectProps = _ref$datePickerProps === void 0 ? {} : _ref$datePickerProps,
91
- _ref$defaultValue = _ref.defaultValue,
92
- defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
93
- _ref$id = _ref.id,
94
- id = _ref$id === void 0 ? '' : _ref$id,
95
- _ref$innerProps = _ref.innerProps,
96
- innerProps = _ref$innerProps === void 0 ? {} : _ref$innerProps,
97
- _ref$isDisabled = _ref.isDisabled,
98
- isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
99
- _ref$isInvalid = _ref.isInvalid,
100
- isInvalid = _ref$isInvalid === void 0 ? false : _ref$isInvalid,
101
- _ref$isRequired = _ref.isRequired,
102
- isRequired = _ref$isRequired === void 0 ? false : _ref$isRequired,
103
- _ref$name = _ref.name,
104
- name = _ref$name === void 0 ? '' : _ref$name,
105
- _ref$onBlur = _ref.onBlur,
106
- onBlur = _ref$onBlur === void 0 ? function (_event) {} : _ref$onBlur,
107
- _ref$onChange = _ref.onChange,
108
- onChangeProp = _ref$onChange === void 0 ? function (_value) {} : _ref$onChange,
109
- _ref$onFocus = _ref.onFocus,
110
- onFocus = _ref$onFocus === void 0 ? function (_event) {} : _ref$onFocus,
111
- providedParseValue = _ref.parseValue,
112
- _ref$spacing = _ref.spacing,
113
- spacing = _ref$spacing === void 0 ? 'default' : _ref$spacing,
114
- _ref$locale = _ref.locale,
115
- locale = _ref$locale === void 0 ? 'en-US' : _ref$locale,
116
- testId = _ref.testId,
117
- _ref$timePickerProps = _ref.timePickerProps,
118
- timePickerPropsWithSelectProps = _ref$timePickerProps === void 0 ? {} : _ref$timePickerProps,
119
- providedValue = _ref.value;
120
- var _useState = useState((datePickerPropsWithSelectProps === null || datePickerPropsWithSelectProps === void 0 ? void 0 : datePickerPropsWithSelectProps.defaultValue) || ''),
121
- _useState2 = _slicedToArray(_useState, 2),
122
- dateValue = _useState2[0],
123
- setDateValue = _useState2[1];
124
- var _useState3 = useState(false),
125
- _useState4 = _slicedToArray(_useState3, 2),
126
- isFocused = _useState4[0],
127
- setIsFocused = _useState4[1];
128
- var _useState5 = useState((timePickerPropsWithSelectProps === null || timePickerPropsWithSelectProps === void 0 ? void 0 : timePickerPropsWithSelectProps.defaultValue) || ''),
129
- _useState6 = _slicedToArray(_useState5, 2),
130
- timeValue = _useState6[0],
131
- setTimeValue = _useState6[1];
132
- var _useState7 = useState(defaultValue || ''),
133
- _useState8 = _slicedToArray(_useState7, 2),
134
- value = _useState8[0],
135
- setValue = _useState8[1];
136
- var _useState9 = useState(''),
137
- _useState10 = _slicedToArray(_useState9, 2),
138
- zoneValue = _useState10[0],
139
- setZoneValue = _useState10[1];
140
- useEffect(function () {
141
- if (providedValue) {
142
- setValue(providedValue);
143
- }
144
- }, [providedValue]);
145
- var parseValue = useCallback(function (value, providedDateValue, providedTimeValue, providedZoneValue) {
146
- if (providedParseValue) {
147
- var parsedFromFn = providedParseValue(value, providedDateValue, providedTimeValue, providedZoneValue);
148
- // This handles cases found in Jira where the parse function actually does
149
- // nothing and returns undefined. The previous `getSafeState` function
150
- // just spread the values over the state, but if it returned `undefined`,
151
- // it would just rely on the previous state values. Considering this is
152
- // what is input to this function anyway, this is a safe way to handle
153
- // this, colocate the behavior, and not rely on `getSafeState`.
154
- return parsedFromFn || {
155
- dateValue: providedDateValue,
156
- timeValue: providedTimeValue,
157
- zoneValue: providedZoneValue
158
- };
159
- }
160
- var parsed = parseISO(value);
161
- return isValid(parsed) ? {
162
- dateValue: format(parsed, convertTokens('YYYY-MM-DD')),
163
- timeValue: format(parsed, convertTokens('HH:mm')),
164
- zoneValue: format(parsed, convertTokens('ZZ'))
165
- } : {
166
- dateValue: dateValue,
167
- timeValue: timeValue,
168
- zoneValue: zoneValue
169
- };
170
- }, [providedParseValue, dateValue, timeValue, zoneValue]);
171
- useEffect(function () {
172
- var parsedValues = parseValue(value, dateValue, timeValue, zoneValue);
173
- setDateValue(parsedValues.dateValue);
174
- setTimeValue(parsedValues.timeValue);
175
- setZoneValue(parsedValues.zoneValue);
176
- }, [value, dateValue, timeValue, zoneValue, parseValue]);
177
- var onDateBlur = function onDateBlur(event) {
178
- setIsFocused(false);
179
- onBlur(event);
180
- if (datePickerPropsWithSelectProps !== null && datePickerPropsWithSelectProps !== void 0 && datePickerPropsWithSelectProps.onBlur) {
181
- datePickerPropsWithSelectProps.onBlur(event);
182
- }
183
- };
184
- var onTimeBlur = function onTimeBlur(event) {
185
- setIsFocused(false);
186
- onBlur(event);
187
- if (timePickerPropsWithSelectProps !== null && timePickerPropsWithSelectProps !== void 0 && timePickerPropsWithSelectProps.onBlur) {
188
- timePickerPropsWithSelectProps.onBlur(event);
189
- }
190
- };
191
- var onDateFocus = function onDateFocus(event) {
192
- setIsFocused(false);
193
- onFocus(event);
194
- if (datePickerPropsWithSelectProps !== null && datePickerPropsWithSelectProps !== void 0 && datePickerPropsWithSelectProps.onFocus) {
195
- datePickerPropsWithSelectProps.onFocus(event);
196
- }
197
- };
198
- var onTimeFocus = function onTimeFocus(event) {
199
- setIsFocused(false);
200
- onFocus(event);
201
- if (timePickerPropsWithSelectProps !== null && timePickerPropsWithSelectProps !== void 0 && timePickerPropsWithSelectProps.onFocus) {
202
- timePickerPropsWithSelectProps.onFocus(event);
203
- }
204
- };
205
- var onDateChange = function onDateChange(dateValue) {
206
- var parsedValues = parseValue(value, dateValue, timeValue, zoneValue);
207
- onValueChange({
208
- providedDateValue: dateValue,
209
- providedTimeValue: parsedValues.timeValue,
210
- providedZoneValue: parsedValues.zoneValue
211
- });
212
- if (datePickerPropsWithSelectProps !== null && datePickerPropsWithSelectProps !== void 0 && datePickerPropsWithSelectProps.onChange) {
213
- datePickerPropsWithSelectProps.onChange(dateValue);
214
- }
215
- };
216
- var onTimeChange = function onTimeChange(timeValue) {
217
- var parsedValues = parseValue(value, dateValue, timeValue, zoneValue);
218
- onValueChange({
219
- providedDateValue: parsedValues.dateValue,
220
- providedTimeValue: timeValue,
221
- providedZoneValue: parsedValues.zoneValue
222
- });
223
- if (timePickerPropsWithSelectProps !== null && timePickerPropsWithSelectProps !== void 0 && timePickerPropsWithSelectProps.onChange) {
224
- timePickerPropsWithSelectProps.onChange(timeValue);
225
- }
226
- };
227
- var onClear = function onClear() {
228
- var parsedValues = parseValue(value, dateValue, timeValue, zoneValue);
229
- onValueChange({
230
- providedDateValue: '',
231
- providedTimeValue: '',
232
- providedZoneValue: parsedValues.zoneValue
233
- });
234
- if (datePickerPropsWithSelectProps !== null && datePickerPropsWithSelectProps !== void 0 && datePickerPropsWithSelectProps.onChange) {
235
- datePickerPropsWithSelectProps.onChange('');
236
- }
237
- if (timePickerPropsWithSelectProps !== null && timePickerPropsWithSelectProps !== void 0 && timePickerPropsWithSelectProps.onChange) {
238
- timePickerPropsWithSelectProps.onChange('');
239
- }
240
- };
241
- var onChangePropWithAnalytics = usePlatformLeafEventHandler(_objectSpread({
242
- fn: onChangeProp,
243
- action: 'selectedDate',
244
- actionSubject: 'datePicker'
245
- }, analyticsAttributes));
246
- var onValueChange = function onValueChange(_ref2) {
247
- var providedDateValue = _ref2.providedDateValue,
248
- providedTimeValue = _ref2.providedTimeValue,
249
- providedZoneValue = _ref2.providedZoneValue;
250
- setDateValue(providedDateValue);
251
- setTimeValue(providedTimeValue);
252
- setZoneValue(providedZoneValue);
253
- if (providedDateValue && providedTimeValue) {
254
- var _value2 = formatDateTimeZoneIntoIso(providedDateValue, providedTimeValue, providedZoneValue);
255
- var _parseValue = parseValue(_value2, providedDateValue, providedTimeValue, providedZoneValue),
256
- parsedZone = _parseValue.zoneValue;
257
- var valueWithValidZone = formatDateTimeZoneIntoIso(providedDateValue, providedTimeValue, parsedZone);
258
- setValue(valueWithValidZone);
259
- onChangePropWithAnalytics(valueWithValidZone);
260
- // If the date or time value was cleared when there is an existing datetime value, then clear the value.
261
- } else if (value) {
262
- setValue('');
263
- onChangePropWithAnalytics('');
264
- }
265
- };
266
- var datePickerSelectProps = datePickerPropsWithSelectProps.selectProps,
267
- datePickerProps = _objectWithoutProperties(datePickerPropsWithSelectProps, _excluded);
268
- var datePickerAriaDescribedBy = datePickerProps['aria-describedby'] || ariaDescribedBy;
269
- var datePickerLabel = datePickerProps.label || datePickerDefaultAriaLabel;
270
- var mergedDatePickerSelectProps = _objectSpread(_objectSpread({}, datePickerSelectProps), {}, {
271
- styles: mergeStyles(styles, datePickerSelectProps === null || datePickerSelectProps === void 0 ? void 0 : datePickerSelectProps.styles)
272
- });
273
- var timePickerSelectProps = timePickerPropsWithSelectProps.selectProps,
274
- timePickerProps = _objectWithoutProperties(timePickerPropsWithSelectProps, _excluded2);
275
- var timePickerAriaDescribedBy = timePickerProps['aria-describedby'] || ariaDescribedBy;
276
- var timePickerLabel = timePickerProps.label || timePickerDefaultAriaLabel;
277
- var mergedTimePickerSelectProps = _objectSpread(_objectSpread({}, timePickerSelectProps), {}, {
278
- styles: mergeStyles(styles, timePickerSelectProps === null || timePickerSelectProps === void 0 ? void 0 : timePickerSelectProps.styles)
279
- });
280
-
281
- // Render DateTimePicker's IconContainer when a value has been filled
282
- // Don't use Date or TimePicker's because they can't be customised
283
- var isClearable = Boolean(dateValue || timeValue);
284
- return /*#__PURE__*/React.createElement(DateTimePickerContainer, {
285
- appearance: appearance,
286
- isDisabled: isDisabled,
287
- isFocused: isFocused,
288
- isInvalid: isInvalid,
289
- testId: testId,
290
- innerProps: innerProps
291
- }, /*#__PURE__*/React.createElement("input", {
292
- name: name,
293
- type: "hidden",
294
- value: value,
295
- "data-testid": testId && "".concat(testId, "--input")
296
- }), /*#__PURE__*/React.createElement(Box, {
297
- xcss: datePickerContainerStyles
298
- }, /*#__PURE__*/React.createElement(DatePicker, {
299
- appearance: appearance,
300
- "aria-describedby": datePickerAriaDescribedBy,
301
- autoFocus: datePickerProps.autoFocus || autoFocus,
302
- dateFormat: datePickerProps.dateFormat,
303
- defaultIsOpen: datePickerProps.defaultIsOpen,
304
- defaultValue: datePickerProps.defaultValue,
305
- disabled: datePickerProps.disabled,
306
- disabledDateFilter: datePickerProps.disabledDateFilter,
307
- formatDisplayLabel: datePickerProps.formatDisplayLabel,
308
- hideIcon: datePickerProps.hideIcon || true,
309
- icon: datePickerProps.icon,
310
- id: datePickerProps.id || id,
311
- innerProps: datePickerProps.innerProps,
312
- inputLabel: datePickerProps.inputLabel,
313
- inputLabelId: datePickerProps.inputLabelId,
314
- isDisabled: datePickerProps.isDisabled || isDisabled,
315
- isInvalid: datePickerProps.isInvalid || isInvalid,
316
- isOpen: datePickerProps.isOpen,
317
- isRequired: datePickerProps.isRequired || isRequired,
318
- label: datePickerLabel,
319
- locale: datePickerProps.locale || locale,
320
- maxDate: datePickerProps.maxDate,
321
- minDate: datePickerProps.minDate,
322
- name: datePickerProps.name,
323
- nextMonthLabel: datePickerProps.nextMonthLabel,
324
- onBlur: onDateBlur,
325
- onChange: onDateChange,
326
- onFocus: onDateFocus,
327
- openCalendarLabel: datePickerProps.openCalendarLabel,
328
- parseInputValue: datePickerProps.parseInputValue,
329
- placeholder: datePickerProps.placeholder,
330
- previousMonthLabel: datePickerProps.previousMonthLabel,
331
- selectProps: mergedDatePickerSelectProps,
332
- shouldShowCalendarButton: datePickerProps.shouldShowCalendarButton,
333
- spacing: datePickerProps.spacing || spacing,
334
- testId: testId && "".concat(testId, "--datepicker") || datePickerProps.testId,
335
- value: dateValue,
336
- weekStartDay: datePickerProps.weekStartDay
337
- })), /*#__PURE__*/React.createElement(Box, {
338
- xcss: timePickerContainerStyles
339
- }, /*#__PURE__*/React.createElement(TimePicker, {
340
- appearance: timePickerProps.appearance || appearance,
341
- "aria-describedby": timePickerAriaDescribedBy,
342
- autoFocus: timePickerProps.autoFocus,
343
- defaultIsOpen: timePickerProps.defaultIsOpen,
344
- defaultValue: timePickerProps.defaultValue,
345
- formatDisplayLabel: timePickerProps.formatDisplayLabel,
346
- hideIcon: timePickerProps.hideIcon || true,
347
- id: timePickerProps.id,
348
- innerProps: timePickerProps.innerProps,
349
- isDisabled: timePickerProps.isDisabled || isDisabled,
350
- isInvalid: timePickerProps.isInvalid || isInvalid,
351
- isOpen: timePickerProps.isOpen,
352
- isRequired: timePickerProps.isRequired || isRequired,
353
- label: timePickerLabel,
354
- locale: timePickerProps.locale || locale,
355
- name: timePickerProps.name,
356
- onBlur: onTimeBlur,
357
- onChange: onTimeChange,
358
- onFocus: onTimeFocus,
359
- parseInputValue: timePickerProps.parseInputValue,
360
- placeholder: timePickerProps.placeholder,
361
- selectProps: mergedTimePickerSelectProps,
362
- spacing: timePickerProps.spacing || spacing,
363
- testId: timePickerProps.testId || testId && "".concat(testId, "--timepicker"),
364
- timeFormat: timePickerProps.timeFormat,
365
- timeIsEditable: timePickerProps.timeIsEditable,
366
- times: timePickerProps.times,
367
- value: timeValue
368
- })), isClearable && !isDisabled ? /*#__PURE__*/React.createElement(Inline, {
369
- xcss: iconContainerStyles
370
- }, /*#__PURE__*/React.createElement(IconButton, {
371
- appearance: "subtle",
372
- label: clearControlLabel,
373
- icon: function icon(iconProps) {
374
- return /*#__PURE__*/React.createElement(SelectClearIcon, _extends({}, iconProps, {
375
- color: "var(--ds-text-subtlest, #626F86)",
376
- LEGACY_size: "small"
377
- }));
378
- },
379
- onClick: onClear,
380
- testId: testId && "".concat(testId, "--icon--container"),
381
- tabIndex: -1
382
- })) : null);
383
- });
384
- export default DateTimePicker;
@@ -1,49 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import React, { forwardRef } from 'react';
3
-
4
- /**
5
- * Gets all available ref types from two prop sets and returns
6
- * them in a ref prop
7
- *
8
- * @example
9
- * ```
10
- * type P1 = { ref: Ref(HTMLDivElement), ... };
11
- * type P2 = { ref: Ref(HTMLSpanElement), ... };
12
- *
13
- * GetRefAttributes(P1, P2) // {ref: Ref(HTMLDivElement | HTMLSpanElement)}
14
- * ```
15
- */
16
-
17
- /**
18
- * Returns one of components depending on a boolean condition.
19
- * The result component will be a union of the two props and
20
- * an or on both ref types.
21
- *
22
- * @example
23
- * ```
24
- * const Component = componentWithCondition(
25
- * isBooleanConditionMet,
26
- * ComponentWithConditionMet,
27
- * ComponentWithConditionNotMet,
28
- * );
29
- *
30
- * @param condition Function returning boolean value
31
- * @param componentTrue Component that will be returned if conditionGetter is "true"
32
- * @param componentFalse Component that will be returned if conditionGetter is "false"
33
- * @returns Component Depending on a Condition result
34
- */
35
- export function componentWithCondition(condition, ComponentTrue, ComponentFalse) {
36
- var ComponentWithCondition = /*#__PURE__*/forwardRef(function (props, ref) {
37
- return condition() ? /*#__PURE__*/React.createElement(ComponentTrue, _extends({}, props, {
38
- ref: ref
39
- })) : /*#__PURE__*/React.createElement(ComponentFalse, _extends({}, props, {
40
- ref: ref
41
- }));
42
- });
43
- if (ComponentTrue.name !== '') {
44
- ComponentWithCondition.displayName = "ComponentWithCondition[".concat(condition.name, "]");
45
- }
46
-
47
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
48
- return ComponentWithCondition;
49
- }
@@ -1,110 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
- import { Component } from 'react';
6
- import { jsx } from '@emotion/react';
7
- import { type LocalizationProvider } from '@atlaskit/locale';
8
- import { type ActionMeta, type InputActionMeta } from '@atlaskit/select';
9
- import { type DatePickerBaseProps } from '../types';
10
- type DatePickerProps = typeof datePickerDefaultProps & DatePickerBaseProps;
11
- interface State {
12
- isKeyDown: boolean;
13
- isOpen: boolean;
14
- /**
15
- * When being cleared from the icon the DatePicker is blurred.
16
- * This variable defines whether the default onSelectBlur or onSelectFocus
17
- * events should behave as normal.
18
- */
19
- isFocused: boolean;
20
- clearingFromIcon: boolean;
21
- value: string;
22
- calendarValue: string;
23
- selectInputValue: string;
24
- l10n: LocalizationProvider;
25
- locale: string;
26
- shouldSetFocusOnCurrentDay: boolean;
27
- wasOpenedFromCalendarButton: boolean;
28
- }
29
- declare const datePickerDefaultProps: {
30
- defaultIsOpen: boolean;
31
- defaultValue: string;
32
- disabled: string[];
33
- disabledDateFilter: (_: string) => boolean;
34
- locale: string;
35
- onBlur: (_event: React.FocusEvent<HTMLInputElement>) => void;
36
- onChange: (_value: string) => void;
37
- onFocus: (_event: React.FocusEvent<HTMLInputElement>) => void;
38
- };
39
- declare class DatePickerComponent extends Component<DatePickerProps, State> {
40
- static defaultProps: {
41
- defaultIsOpen: boolean;
42
- defaultValue: string;
43
- disabled: string[];
44
- disabledDateFilter: (_: string) => boolean;
45
- locale: string;
46
- onBlur: (_event: import("react").FocusEvent<HTMLInputElement, Element>) => void;
47
- onChange: (_value: string) => void;
48
- onFocus: (_event: import("react").FocusEvent<HTMLInputElement, Element>) => void;
49
- };
50
- containerRef: HTMLElement | null;
51
- calendarRef: React.RefObject<HTMLDivElement | null>;
52
- calendarButtonRef: React.RefObject<HTMLButtonElement>;
53
- constructor(props: any);
54
- static getDerivedStateFromProps(nextProps: Readonly<DatePickerProps>, prevState: State): {
55
- l10n: LocalizationProvider;
56
- locale: string;
57
- } | null;
58
- getValue: () => string;
59
- getIsOpen: () => boolean;
60
- onCalendarChange: ({ iso }: {
61
- iso: string;
62
- }) => void;
63
- onCalendarSelect: ({ iso }: {
64
- iso: string;
65
- }) => void;
66
- onInputClick: () => void;
67
- onContainerBlur: (event: React.FocusEvent<HTMLInputElement>) => void;
68
- onContainerFocus: () => void;
69
- onSelectBlur: (event: React.FocusEvent<HTMLInputElement>) => void;
70
- onSelectFocus: (event: React.FocusEvent<HTMLInputElement>) => void;
71
- onTextInput: (event: React.ChangeEvent<HTMLInputElement>) => void;
72
- onInputKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;
73
- onCalendarButtonKeyDown: (e: React.KeyboardEvent<HTMLButtonElement>) => void;
74
- onCalendarButtonClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
75
- onClear: () => void;
76
- onSelectChange: (_value: unknown, action: ActionMeta) => void;
77
- handleSelectInputChange: (selectInputValue: string, actionMeta: InputActionMeta) => void;
78
- getContainerRef: (ref: HTMLElement | null) => void;
79
- render(): jsx.JSX.Element;
80
- }
81
- export { DatePickerComponent as DatePickerWithoutAnalytics };
82
- /**
83
- * __Date picker__
84
- *
85
- * A date picker allows the user to select a particular date.
86
- *
87
- * - [Examples](https://atlassian.design/components/datetime-picker/date-picker/examples)
88
- * - [Code](https://atlassian.design/components/datetime-picker/date-picker/code)
89
- * - [Usage](https://atlassian.design/components/datetime-picker/date-picker/usage)
90
- */
91
- declare const DatePicker: import("react").ForwardRefExoticComponent<Omit<Pick<Omit<{
92
- defaultIsOpen: boolean;
93
- defaultValue: string;
94
- disabled: string[];
95
- disabledDateFilter: (_: string) => boolean;
96
- locale: string;
97
- onBlur: (_event: React.FocusEvent<HTMLInputElement>) => void;
98
- onChange: (_value: string) => void;
99
- onFocus: (_event: React.FocusEvent<HTMLInputElement>) => void;
100
- } & DatePickerBaseProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "label" | "parseInputValue" | "dateFormat" | "formatDisplayLabel" | "placeholder" | "appearance" | "isDisabled" | "innerProps" | "selectProps" | "autoFocus" | "id" | "aria-describedby" | "value" | "testId" | "icon" | "maxDate" | "minDate" | "nextMonthLabel" | "previousMonthLabel" | "weekStartDay" | "clearControlLabel" | "isInvalid" | "isRequired" | "name" | "spacing" | "isOpen" | "inputLabel" | "inputLabelId" | "openCalendarLabel" | "shouldShowCalendarButton" | "hideIcon"> & {
101
- disabled?: string[] | undefined;
102
- defaultValue?: string | undefined;
103
- onFocus?: (((_event: React.FocusEvent<HTMLInputElement>) => void) & import("react").FocusEventHandler<HTMLInputElement>) | undefined;
104
- onBlur?: (((_event: React.FocusEvent<HTMLInputElement>) => void) & import("react").FocusEventHandler<HTMLInputElement>) | undefined;
105
- onChange?: (((_value: string) => void) & ((value: string) => void)) | undefined;
106
- disabledDateFilter?: (((_: string) => boolean) & ((date: string) => boolean)) | undefined;
107
- locale?: string | undefined;
108
- defaultIsOpen?: boolean | undefined;
109
- } & {} & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "ref"> & import("react").RefAttributes<any>>;
110
- export default DatePicker;
@@ -1,20 +0,0 @@
1
- /// <reference types="react" />
2
- import { type DropdownIndicatorProps, type OptionType } from '@atlaskit/select';
3
- import { type DatePickerBaseProps, type DateTimePickerSelectProps } from '../types';
4
- export type DatePickerProps = DatePickerBaseProps & {
5
- icon?: React.ComponentType<DropdownIndicatorProps<OptionType>>;
6
- selectProps?: DateTimePickerSelectProps & {
7
- inputValue?: string;
8
- };
9
- };
10
- /**
11
- * __Date picker__
12
- *
13
- * A date picker allows the user to select a particular date.
14
- *
15
- * - [Examples](https://atlassian.design/components/datetime-picker/date-picker/examples)
16
- * - [Code](https://atlassian.design/components/datetime-picker/date-picker/code)
17
- * - [Usage](https://atlassian.design/components/datetime-picker/date-picker/usage)
18
- */
19
- declare const DatePicker: import("react").ForwardRefExoticComponent<Omit<DatePickerProps, "ref"> & import("react").RefAttributes<unknown>>;
20
- export default DatePicker;
@@ -1,85 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
- import React from 'react';
6
- import { jsx } from '@emotion/react';
7
- import { type DateTimePickerBaseProps } from '../types';
8
- interface State {
9
- dateValue: string;
10
- isFocused: boolean;
11
- timeValue: string;
12
- value: string;
13
- zoneValue: string;
14
- }
15
- export declare const datePickerDefaultAriaLabel = "Date";
16
- export declare const timePickerDefaultAriaLabel = "Time";
17
- declare class DateTimePickerComponent extends React.Component<DateTimePickerBaseProps, State> {
18
- static defaultProps: DateTimePickerBaseProps;
19
- state: State;
20
- getParsedValues: () => {
21
- dateValue: string;
22
- timeValue: string;
23
- zoneValue: string;
24
- };
25
- getValue: () => string;
26
- parseValue(value: string, dateValue: string, timeValue: string, zoneValue: string): {
27
- dateValue: string;
28
- timeValue: string;
29
- zoneValue: string;
30
- };
31
- onDateBlur: (event: React.FocusEvent<HTMLInputElement>) => void;
32
- onTimeBlur: (event: React.FocusEvent<HTMLInputElement>) => void;
33
- onDateFocus: (event: React.FocusEvent<HTMLInputElement>) => void;
34
- onTimeFocus: (event: React.FocusEvent<HTMLInputElement>) => void;
35
- onDateChange: (dateValue: string) => void;
36
- onTimeChange: (timeValue: string) => void;
37
- onClear: () => void;
38
- onValueChange({ dateValue, timeValue, zoneValue, }: {
39
- dateValue: string;
40
- timeValue: string;
41
- zoneValue: string;
42
- }): void;
43
- render(): jsx.JSX.Element;
44
- }
45
- export { DateTimePickerComponent as DateTimePickerWithoutAnalytics };
46
- /**
47
- * __Date time picker__
48
- *
49
- * A date time picker allows the user to select an associated date and time.
50
- *
51
- * - [Examples](https://atlassian.design/components/datetime-picker/examples)
52
- * - [Code](https://atlassian.design/components/datetime-picker/code)
53
- * - [Usage](https://atlassian.design/components/datetime-picker/usage)
54
- */
55
- declare const DateTimePicker: React.ForwardRefExoticComponent<Omit<Omit<Pick<Omit<DateTimePickerBaseProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, never> & {
56
- appearance?: import("../types").Appearance | undefined;
57
- isDisabled?: boolean | undefined;
58
- innerProps?: React.AllHTMLAttributes<HTMLElement> | undefined;
59
- defaultValue?: string | undefined;
60
- autoFocus?: boolean | undefined;
61
- id?: string | undefined;
62
- 'aria-describedby'?: string | undefined;
63
- onFocus?: React.FocusEventHandler<HTMLInputElement> | undefined;
64
- onBlur?: React.FocusEventHandler<HTMLInputElement> | undefined;
65
- onChange?: ((value: string) => void) | undefined;
66
- value?: string | undefined;
67
- testId?: string | undefined;
68
- locale?: string | undefined;
69
- clearControlLabel?: string | undefined;
70
- isInvalid?: boolean | undefined;
71
- isRequired?: boolean | undefined;
72
- name?: string | undefined;
73
- spacing?: import("../types").Spacing | undefined;
74
- datePickerProps?: import("../types").DatePickerBaseProps | undefined;
75
- timePickerProps?: import("../types").TimePickerBaseProps | undefined;
76
- parseValue?: ((dateTimeValue: string, date: string, time: string, timezone: string) => {
77
- dateValue: string;
78
- timeValue: string;
79
- zoneValue: string;
80
- }) | undefined;
81
- } & {
82
- ref?: React.Ref<any> | undefined;
83
- createAnalyticsEvent?: import("@atlaskit/analytics-next").CreateUIAnalyticsEvent | undefined;
84
- }, "ref"> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "ref"> & React.RefAttributes<any>>;
85
- export default DateTimePicker;
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- import { type DateTimePickerBaseProps } from '../types';
3
- export declare const datePickerDefaultAriaLabel = "Date";
4
- export declare const timePickerDefaultAriaLabel = "Time";
5
- /**
6
- * __Date time picker__
7
- *
8
- * A date time picker allows the user to select an associated date and time.
9
- *
10
- * - [Examples](https://atlassian.design/components/datetime-picker/examples)
11
- * - [Code](https://atlassian.design/components/datetime-picker/code)
12
- * - [Usage](https://atlassian.design/components/datetime-picker/usage)
13
- */
14
- declare const DateTimePicker: React.ForwardRefExoticComponent<Omit<DateTimePickerBaseProps, "ref"> & React.RefAttributes<unknown>>;
15
- export default DateTimePicker;