baseui 11.0.1 → 11.1.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/a11y/index.d.ts +1 -1
- package/accordion/index.d.ts +25 -28
- package/app-nav-bar/app-nav-bar.js +33 -40
- package/app-nav-bar/app-nav-bar.js.flow +46 -62
- package/app-nav-bar/index.d.ts +9 -8
- package/app-nav-bar/styled-components.js +49 -29
- package/app-nav-bar/styled-components.js.flow +25 -8
- package/app-nav-bar/types.js.flow +2 -0
- package/aspect-ratio-box/index.d.ts +2 -4
- package/avatar/index.d.ts +6 -12
- package/badge/badge.js +109 -0
- package/badge/badge.js.flow +91 -0
- package/badge/constants.js +54 -0
- package/badge/constants.js.flow +52 -0
- package/badge/hint-dot.js +96 -0
- package/badge/hint-dot.js.flow +68 -0
- package/badge/index.d.ts +97 -0
- package/badge/index.js +80 -0
- package/badge/index.js.flow +20 -0
- package/badge/notification-circle.js +103 -0
- package/badge/notification-circle.js.flow +81 -0
- package/badge/package.json +4 -0
- package/badge/styled-components.js +242 -0
- package/badge/styled-components.js.flow +325 -0
- package/badge/types.js +11 -0
- package/badge/types.js.flow +59 -0
- package/badge/utils.js +33 -0
- package/badge/utils.js.flow +23 -0
- package/banner/banner.js +283 -0
- package/banner/banner.js.flow +253 -0
- package/banner/constants.js +35 -0
- package/banner/constants.js.flow +33 -0
- package/banner/index.d.ts +75 -0
- package/banner/index.js +44 -0
- package/banner/index.js.flow +16 -0
- package/banner/package.json +4 -0
- package/banner/styled-components.js +131 -0
- package/banner/styled-components.js.flow +119 -0
- package/banner/types.js +11 -0
- package/banner/types.js.flow +66 -0
- package/block/index.d.ts +4 -4
- package/breadcrumbs/breadcrumbs.js +5 -1
- package/breadcrumbs/breadcrumbs.js.flow +2 -2
- package/breadcrumbs/index.d.ts +5 -5
- package/button/button.js +2 -1
- package/button/button.js.flow +1 -0
- package/button/index.d.ts +19 -29
- package/button-group/index.d.ts +18 -24
- package/card/index.d.ts +16 -14
- package/checkbox/index.d.ts +17 -21
- package/combobox/index.d.ts +7 -11
- package/data-table/index.d.ts +7 -10
- package/datepicker/calendar.js +16 -11
- package/datepicker/calendar.js.flow +12 -9
- package/datepicker/datepicker.js +58 -58
- package/datepicker/datepicker.js.flow +51 -34
- package/datepicker/index.d.ts +42 -63
- package/datepicker/stateful-calendar.js +6 -1
- package/datepicker/stateful-calendar.js.flow +8 -1
- package/datepicker/stateful-container.js +23 -2
- package/datepicker/stateful-container.js.flow +17 -4
- package/datepicker/stateful-datepicker.js +6 -1
- package/datepicker/stateful-datepicker.js.flow +7 -1
- package/datepicker/types.js.flow +21 -43
- package/datepicker/utils/date-helpers.js +1 -1
- package/datepicker/utils/date-helpers.js.flow +1 -1
- package/dnd-list/index.d.ts +22 -35
- package/drawer/index.d.ts +22 -27
- package/es/app-nav-bar/app-nav-bar.js +9 -19
- package/es/app-nav-bar/styled-components.js +32 -13
- package/es/badge/badge.js +70 -0
- package/es/badge/constants.js +42 -0
- package/es/badge/hint-dot.js +55 -0
- package/es/badge/index.js +11 -0
- package/es/badge/notification-circle.js +65 -0
- package/es/badge/styled-components.js +296 -0
- package/es/badge/types.js +8 -0
- package/es/badge/utils.js +17 -0
- package/es/banner/banner.js +213 -0
- package/es/banner/constants.js +24 -0
- package/es/banner/index.js +9 -0
- package/es/banner/styled-components.js +122 -0
- package/es/banner/types.js +8 -0
- package/es/breadcrumbs/breadcrumbs.js +5 -1
- package/es/button/button.js +1 -0
- package/es/datepicker/calendar.js +15 -10
- package/es/datepicker/datepicker.js +52 -52
- package/es/datepicker/stateful-calendar.js +6 -1
- package/es/datepicker/stateful-container.js +22 -2
- package/es/datepicker/stateful-datepicker.js +6 -1
- package/es/datepicker/utils/date-helpers.js +1 -1
- package/es/helper/helper-steps.js +3 -1
- package/es/input/base-input.js +18 -11
- package/es/input/input.js +15 -10
- package/es/input/masked-input.js +5 -2
- package/es/input/utils.js +4 -2
- package/es/locale/tr_TR.js +115 -0
- package/es/notification/notification.js +16 -1
- package/es/payment-card/custom-cards.config.js +22 -0
- package/es/payment-card/icons/uatp.js +52 -0
- package/es/payment-card/payment-card.js +8 -3
- package/es/popover/popover.js +2 -1
- package/es/popover/stateful-container.js +2 -0
- package/es/popover/styled-components.js +2 -1
- package/es/progress-steps/numbered-step.js +2 -2
- package/es/select/select-component.js +48 -23
- package/es/select/utils/default-filter-options.js +1 -1
- package/es/snackbar/snackbar-context.js +1 -1
- package/es/table-semantic/styled-components.js +14 -0
- package/es/table-semantic/table-builder.js +12 -5
- package/es/textarea/textarea.js +15 -9
- package/es/themes/dark-theme/color-component-tokens.js +8 -0
- package/es/themes/light-theme/color-component-tokens.js +8 -0
- package/es/tree-view/tree-label.js +9 -1
- package/esm/app-nav-bar/app-nav-bar.js +32 -38
- package/esm/app-nav-bar/styled-components.js +46 -28
- package/esm/badge/badge.js +97 -0
- package/esm/badge/constants.js +42 -0
- package/esm/badge/hint-dot.js +83 -0
- package/esm/badge/index.js +11 -0
- package/esm/badge/notification-circle.js +91 -0
- package/esm/badge/styled-components.js +235 -0
- package/esm/badge/types.js +8 -0
- package/esm/badge/utils.js +17 -0
- package/esm/banner/banner.js +271 -0
- package/esm/banner/constants.js +24 -0
- package/esm/banner/index.js +9 -0
- package/esm/banner/styled-components.js +113 -0
- package/esm/banner/types.js +8 -0
- package/esm/breadcrumbs/breadcrumbs.js +5 -1
- package/esm/button/button.js +2 -1
- package/esm/datepicker/calendar.js +16 -11
- package/esm/datepicker/datepicker.js +58 -58
- package/esm/datepicker/stateful-calendar.js +6 -1
- package/esm/datepicker/stateful-container.js +23 -2
- package/esm/datepicker/stateful-datepicker.js +6 -1
- package/esm/datepicker/utils/date-helpers.js +1 -1
- package/esm/helper/helper-steps.js +3 -1
- package/esm/input/base-input.js +18 -11
- package/esm/input/input.js +15 -10
- package/esm/input/masked-input.js +6 -3
- package/esm/input/utils.js +4 -2
- package/esm/locale/tr_TR.js +115 -0
- package/esm/notification/notification.js +17 -1
- package/esm/payment-card/custom-cards.config.js +22 -0
- package/esm/payment-card/icons/uatp.js +53 -0
- package/esm/payment-card/payment-card.js +9 -7
- package/esm/popover/popover.js +2 -1
- package/esm/popover/stateful-container.js +2 -0
- package/esm/popover/styled-components.js +3 -2
- package/esm/progress-steps/numbered-step.js +2 -2
- package/esm/select/select-component.js +85 -59
- package/esm/select/utils/default-filter-options.js +1 -1
- package/esm/snackbar/snackbar-context.js +1 -1
- package/esm/table-semantic/styled-components.js +31 -18
- package/esm/table-semantic/table-builder.js +34 -23
- package/esm/textarea/textarea.js +15 -9
- package/esm/themes/dark-theme/color-component-tokens.js +8 -0
- package/esm/themes/light-theme/color-component-tokens.js +8 -0
- package/esm/tree-view/tree-label.js +10 -2
- package/file-uploader/index.d.ts +11 -11
- package/flex-grid/index.d.ts +3 -3
- package/form-control/index.d.ts +7 -19
- package/header-navigation/index.d.ts +8 -9
- package/heading/index.d.ts +3 -4
- package/helper/helper-steps.js +19 -13
- package/helper/helper-steps.js.flow +3 -1
- package/helper/index.d.ts +7 -7
- package/helpers/base-provider.d.ts +16 -0
- package/helpers/overrides.d.ts +23 -0
- package/icon/index.d.ts +32 -32
- package/index.d.ts +34 -114
- package/input/base-input.js +18 -11
- package/input/base-input.js.flow +18 -6
- package/input/index.d.ts +29 -32
- package/input/input.js +15 -10
- package/input/input.js.flow +10 -5
- package/input/masked-input.js +6 -3
- package/input/masked-input.js.flow +3 -0
- package/input/types.js.flow +4 -0
- package/input/utils.js +4 -2
- package/input/utils.js.flow +2 -1
- package/layer/index.d.ts +6 -11
- package/layout-grid/index.d.ts +25 -7
- package/link/index.d.ts +2 -2
- package/list/index.d.ts +26 -31
- package/{locale.ts → locale/index.d.ts} +8 -0
- package/locale/tr_TR.js +123 -0
- package/locale/tr_TR.js.flow +124 -0
- package/map-marker/index.d.ts +41 -47
- package/menu/index.d.ts +27 -37
- package/modal/index.d.ts +28 -38
- package/notification/index.d.ts +2 -3
- package/notification/notification.js +18 -1
- package/notification/notification.js.flow +15 -1
- package/overrides.ts +2 -22
- package/package.json +26 -17
- package/pagination/index.d.ts +22 -26
- package/payment-card/custom-cards.config.js +30 -0
- package/payment-card/custom-cards.config.js.flow +29 -0
- package/payment-card/icons/uatp.js +67 -0
- package/payment-card/icons/uatp.js.flow +62 -0
- package/payment-card/index.d.ts +8 -8
- package/payment-card/payment-card.js +12 -7
- package/payment-card/payment-card.js.flow +12 -0
- package/phone-input/index.d.ts +261 -269
- package/pin-code/index.d.ts +11 -18
- package/popover/index.d.ts +39 -55
- package/popover/popover.js +2 -1
- package/popover/popover.js.flow +2 -1
- package/popover/stateful-container.js +2 -0
- package/popover/stateful-container.js.flow +2 -0
- package/popover/styled-components.js +3 -2
- package/popover/styled-components.js.flow +2 -1
- package/popover/types.js.flow +1 -0
- package/progress-bar/index.d.ts +11 -12
- package/progress-steps/index.d.ts +16 -16
- package/progress-steps/numbered-step.js.flow +2 -2
- package/radio/index.d.ts +12 -15
- package/rating/index.d.ts +9 -12
- package/select/index.d.ts +34 -36
- package/select/select-component.js +82 -56
- package/select/select-component.js.flow +46 -34
- package/select/types.js.flow +1 -0
- package/select/utils/default-filter-options.js +1 -1
- package/select/utils/default-filter-options.js.flow +1 -1
- package/side-navigation/index.d.ts +11 -13
- package/skeleton/index.d.ts +1 -1
- package/slider/index.d.ts +17 -26
- package/snackbar/index.d.ts +8 -8
- package/snackbar/snackbar-context.js +1 -1
- package/snackbar/snackbar-context.js.flow +1 -1
- package/spinner/index.d.ts +4 -3
- package/styles/index.d.ts +82 -2
- package/table/index.d.ts +16 -16
- package/table-grid/index.d.ts +6 -8
- package/table-semantic/index.d.ts +26 -32
- package/table-semantic/styled-components.js +33 -19
- package/table-semantic/styled-components.js.flow +12 -0
- package/table-semantic/table-builder.js +38 -22
- package/table-semantic/table-builder.js.flow +32 -17
- package/table-semantic/types.js.flow +1 -0
- package/tabs/index.d.ts +20 -23
- package/tabs-motion/index.d.ts +23 -23
- package/tag/index.d.ts +14 -18
- package/tag/types.js.flow +1 -1
- package/textarea/index.d.ts +11 -14
- package/textarea/textarea.js +15 -9
- package/textarea/textarea.js.flow +11 -5
- package/textarea/types.js.flow +1 -0
- package/theme.ts +36 -777
- package/themes/dark-theme/color-component-tokens.js +8 -0
- package/themes/dark-theme/color-component-tokens.js.flow +9 -0
- package/themes/index.d.ts +765 -0
- package/themes/light-theme/color-component-tokens.js +8 -0
- package/themes/light-theme/color-component-tokens.js.flow +9 -0
- package/themes/types.js.flow +9 -0
- package/timepicker/index.d.ts +5 -8
- package/timezonepicker/index.d.ts +5 -8
- package/toast/index.d.ts +26 -40
- package/tokens/index.d.ts +1 -1
- package/tooltip/index.d.ts +7 -9
- package/tree-view/index.d.ts +15 -19
- package/tree-view/tree-label.js +10 -2
- package/tree-view/tree-label.js.flow +4 -4
- package/typography/index.d.ts +37 -37
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
StyledStartDate,
|
|
20
20
|
StyledEndDate,
|
|
21
21
|
} from './styled-components.js';
|
|
22
|
-
import type { DatepickerPropsT,
|
|
22
|
+
import type { DatepickerPropsT, InputRoleT } from './types.js';
|
|
23
23
|
import DateHelpers from './utils/date-helpers.js';
|
|
24
24
|
import dateFnsAdapter from './utils/date-fns-adapter.js';
|
|
25
25
|
import type { LocaleT } from '../locale/types.js';
|
|
@@ -78,7 +78,31 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
handleChange: (?T | $ReadOnlyArray<?T>) => void = (date) => {
|
|
82
|
+
const onChange = this.props.onChange;
|
|
83
|
+
const onRangeChange = this.props.onRangeChange;
|
|
84
|
+
|
|
85
|
+
if (Array.isArray(date)) {
|
|
86
|
+
if (onChange && date.every(Boolean)) {
|
|
87
|
+
// flowlint-next-line unclear-type:off
|
|
88
|
+
onChange({ date: ((date: any): Array<T>) });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (onRangeChange) {
|
|
92
|
+
onRangeChange({ date: [...date] });
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
if (onChange) {
|
|
96
|
+
onChange({ date });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (onRangeChange) {
|
|
100
|
+
onRangeChange({ date });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
onCalendarSelect: ({ +date: ?T | Array<?T> }) => void = (data) => {
|
|
82
106
|
let isOpen = false;
|
|
83
107
|
let isPseudoFocused = false;
|
|
84
108
|
let calendarFocused = false;
|
|
@@ -150,14 +174,14 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
150
174
|
inputValue: this.formatDisplayValue(nextDate),
|
|
151
175
|
});
|
|
152
176
|
|
|
153
|
-
this.
|
|
177
|
+
this.handleChange(nextDate);
|
|
154
178
|
};
|
|
155
179
|
|
|
156
180
|
getNullDatePlaceholder(formatString: string) {
|
|
157
181
|
return (this.getMask() || formatString).split(INPUT_DELIMITER)[0].replace(/[0-9]|[a-z]/g, ' ');
|
|
158
182
|
}
|
|
159
183
|
|
|
160
|
-
formatDate(date:
|
|
184
|
+
formatDate(date: ?T | $ReadOnlyArray<?T>, formatString: string) {
|
|
161
185
|
const format = (date: T) => {
|
|
162
186
|
if (formatString === DEFAULT_DATE_FORMAT) {
|
|
163
187
|
return this.dateHelpers.format(date, 'slashDate', this.props.locale);
|
|
@@ -180,7 +204,7 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
180
204
|
}
|
|
181
205
|
}
|
|
182
206
|
|
|
183
|
-
formatDisplayValue: (
|
|
207
|
+
formatDisplayValue: (?T | $ReadOnlyArray<?T>) => string = (date) => {
|
|
184
208
|
const { displayValueAtRangeIndex, formatDisplayValue, range } = this.props;
|
|
185
209
|
const formatString = this.normalizeDashes(this.props.formatString);
|
|
186
210
|
|
|
@@ -278,12 +302,10 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
278
302
|
(typeof mask === 'string' && inputValue === mask.replace(/9/g, ' ')) ||
|
|
279
303
|
inputValue.length === 0
|
|
280
304
|
) {
|
|
281
|
-
if (this.props.
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
this.props.onChange({ date: null });
|
|
286
|
-
}
|
|
305
|
+
if (this.props.range) {
|
|
306
|
+
this.handleChange([]);
|
|
307
|
+
} else {
|
|
308
|
+
this.handleChange(null);
|
|
287
309
|
}
|
|
288
310
|
}
|
|
289
311
|
|
|
@@ -307,18 +329,15 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
307
329
|
endDate = parseDateString(right);
|
|
308
330
|
}
|
|
309
331
|
|
|
310
|
-
const
|
|
311
|
-
if (onChange) {
|
|
312
|
-
const datesValid = this.dateHelpers.isValid(startDate) && this.dateHelpers.isValid(endDate);
|
|
332
|
+
const datesValid = this.dateHelpers.isValid(startDate) && this.dateHelpers.isValid(endDate);
|
|
313
333
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
334
|
+
// added equal case so that times within the same day can be expressed
|
|
335
|
+
const rangeValid =
|
|
336
|
+
this.dateHelpers.isAfter(endDate, startDate) ||
|
|
337
|
+
this.dateHelpers.isEqual(startDate, endDate);
|
|
318
338
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
339
|
+
if (datesValid && rangeValid) {
|
|
340
|
+
this.handleChange([startDate, endDate]);
|
|
322
341
|
}
|
|
323
342
|
} else {
|
|
324
343
|
const dateString = this.normalizeDashes(inputValue);
|
|
@@ -333,41 +352,41 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
333
352
|
date = parseDateString(dateString);
|
|
334
353
|
}
|
|
335
354
|
|
|
336
|
-
const { displayValueAtRangeIndex,
|
|
337
|
-
if (date && this.dateHelpers.isValid(date)
|
|
355
|
+
const { displayValueAtRangeIndex, range, value } = this.props;
|
|
356
|
+
if (date && this.dateHelpers.isValid(date)) {
|
|
338
357
|
if (range && Array.isArray(value) && typeof displayValueAtRangeIndex === 'number') {
|
|
339
358
|
let [left, right] = value;
|
|
340
359
|
if (displayValueAtRangeIndex === 0) {
|
|
341
360
|
left = date;
|
|
342
361
|
if (!right) {
|
|
343
|
-
|
|
362
|
+
this.handleChange([left]);
|
|
344
363
|
} else {
|
|
345
364
|
if (this.dateHelpers.isAfter(right, left) || this.dateHelpers.isEqual(left, right)) {
|
|
346
|
-
|
|
365
|
+
this.handleChange([left, right]);
|
|
347
366
|
} else {
|
|
348
367
|
// Is resetting back to previous value appropriate? Invalid range is not
|
|
349
368
|
// communicated to the user, but if it was not reset the text value would
|
|
350
369
|
// show one value and date value another. This seems a bit better but clearly
|
|
351
370
|
// has a downside.
|
|
352
|
-
|
|
371
|
+
this.handleChange([...value]);
|
|
353
372
|
}
|
|
354
373
|
}
|
|
355
374
|
} else if (displayValueAtRangeIndex === 1) {
|
|
356
375
|
right = date;
|
|
357
376
|
if (!left) {
|
|
358
377
|
// If start value is not defined, set start/end to the same day.
|
|
359
|
-
|
|
378
|
+
this.handleChange([right, right]);
|
|
360
379
|
} else {
|
|
361
380
|
if (this.dateHelpers.isAfter(right, left) || this.dateHelpers.isEqual(left, right)) {
|
|
362
|
-
|
|
381
|
+
this.handleChange([left, right]);
|
|
363
382
|
} else {
|
|
364
383
|
// See comment above about resetting dates on invalid range
|
|
365
|
-
|
|
384
|
+
this.handleChange([...value]);
|
|
366
385
|
}
|
|
367
386
|
}
|
|
368
387
|
}
|
|
369
388
|
} else {
|
|
370
|
-
|
|
389
|
+
this.handleChange(date);
|
|
371
390
|
}
|
|
372
391
|
}
|
|
373
392
|
}
|
|
@@ -439,8 +458,6 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
439
458
|
? endDate
|
|
440
459
|
: this.state.inputValue;
|
|
441
460
|
|
|
442
|
-
const onChange = (event) => this.handleInputChange(event, inputRole);
|
|
443
|
-
|
|
444
461
|
return (
|
|
445
462
|
<InputComponent
|
|
446
463
|
aria-disabled={this.props.disabled}
|
|
@@ -459,7 +476,7 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
459
476
|
onFocus={() => this.open(inputRole)}
|
|
460
477
|
onBlur={this.handleInputBlur}
|
|
461
478
|
onKeyDown={this.handleKeyDown}
|
|
462
|
-
onChange={
|
|
479
|
+
onChange={(event) => this.handleInputChange(event, inputRole)}
|
|
463
480
|
placeholder={placeholder}
|
|
464
481
|
mask={this.getMask()}
|
|
465
482
|
required={this.props.required}
|
|
@@ -499,7 +516,7 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
|
|
|
499
516
|
trapTabbing={true}
|
|
500
517
|
value={this.props.value}
|
|
501
518
|
{...this.props}
|
|
502
|
-
onChange={this.
|
|
519
|
+
onChange={this.onCalendarSelect}
|
|
503
520
|
selectedInput={this.state.selectedInput}
|
|
504
521
|
hasLockedBehavior={this.hasLockedBehavior()}
|
|
505
522
|
/>
|
package/datepicker/index.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {Override} from '../overrides';
|
|
6
|
-
import {Locale} from '../locale';
|
|
7
|
-
import {any} from 'prop-types';
|
|
2
|
+
import { Option } from '../select';
|
|
3
|
+
import { SIZE } from '../input';
|
|
4
|
+
import { Override } from '../overrides';
|
|
8
5
|
|
|
9
|
-
export
|
|
6
|
+
export declare const STATE_CHANGE_TYPE: {
|
|
10
7
|
change: 'change';
|
|
11
8
|
moveUp: 'moveUp';
|
|
12
9
|
moveDown: 'moveDown';
|
|
@@ -14,18 +11,18 @@ export interface STATE_CHANGE_TYPE {
|
|
|
14
11
|
moveRight: 'moveRight';
|
|
15
12
|
mouseOver: 'mouseOver';
|
|
16
13
|
mouseLeave: 'mouseLeave';
|
|
17
|
-
}
|
|
14
|
+
};
|
|
18
15
|
|
|
19
|
-
export
|
|
16
|
+
export declare const ORIENTATION: {
|
|
20
17
|
horizontal: 'horizontal';
|
|
21
18
|
vertical: 'vertical';
|
|
22
|
-
}
|
|
19
|
+
};
|
|
23
20
|
|
|
24
|
-
export type onChange = (args: {date: Date | Date[]}) => any;
|
|
21
|
+
export type onChange = (args: { date: Date | Date[] }) => any;
|
|
25
22
|
export type StateReducer = (
|
|
26
|
-
stateType: STATE_CHANGE_TYPE[keyof STATE_CHANGE_TYPE],
|
|
23
|
+
stateType: typeof STATE_CHANGE_TYPE[keyof typeof STATE_CHANGE_TYPE],
|
|
27
24
|
nextState: ContainerState,
|
|
28
|
-
currentState: ContainerState
|
|
25
|
+
currentState: ContainerState
|
|
29
26
|
) => ContainerState;
|
|
30
27
|
|
|
31
28
|
export interface ContainerState {
|
|
@@ -42,10 +39,10 @@ export class StatefulContainer extends React.Component<
|
|
|
42
39
|
StatefulContainerProps<CalendarProps | DatepickerProps>,
|
|
43
40
|
ContainerState
|
|
44
41
|
> {
|
|
45
|
-
onChange(data: {date: Date | Date[]}): void;
|
|
42
|
+
onChange(data: { date: Date | Date[] }): void;
|
|
46
43
|
internalSetState(
|
|
47
|
-
type: STATE_CHANGE_TYPE[keyof STATE_CHANGE_TYPE],
|
|
48
|
-
changes: ContainerState
|
|
44
|
+
type: typeof STATE_CHANGE_TYPE[keyof typeof STATE_CHANGE_TYPE],
|
|
45
|
+
changes: ContainerState
|
|
49
46
|
): void;
|
|
50
47
|
}
|
|
51
48
|
|
|
@@ -70,14 +67,14 @@ export interface CalendarProps {
|
|
|
70
67
|
maxDate?: Date;
|
|
71
68
|
minDate?: Date;
|
|
72
69
|
monthsShown?: number;
|
|
73
|
-
onDayClick?: (args: {date: Date; event: Event}) => any;
|
|
74
|
-
onDayMouseOver?: (args: {date: Date; event: Event}) => any;
|
|
75
|
-
onDayMouseLeave?: (args: {date: Date; event: Event}) => any;
|
|
76
|
-
onMonthChange?: (args: {date: Date}) => any;
|
|
77
|
-
onYearChange?: (args: {date: Date}) => any;
|
|
70
|
+
onDayClick?: (args: { date: Date; event: Event }) => any;
|
|
71
|
+
onDayMouseOver?: (args: { date: Date; event: Event }) => any;
|
|
72
|
+
onDayMouseLeave?: (args: { date: Date; event: Event }) => any;
|
|
73
|
+
onMonthChange?: (args: { date: Date }) => any;
|
|
74
|
+
onYearChange?: (args: { date: Date }) => any;
|
|
78
75
|
onChange?: onChange;
|
|
79
76
|
onQuickSelectChange?: (option?: QuickSelectOption) => any;
|
|
80
|
-
orientation?: ORIENTATION[keyof ORIENTATION];
|
|
77
|
+
orientation?: typeof ORIENTATION[keyof typeof ORIENTATION];
|
|
81
78
|
overrides?: DatepickerOverrides<SharedStylePropsT>;
|
|
82
79
|
peekNextMonth?: boolean;
|
|
83
80
|
timeSelectStart?: boolean;
|
|
@@ -97,28 +94,25 @@ export class Calendar extends React.Component<CalendarProps, CalendarState> {
|
|
|
97
94
|
getDateInView(): Date;
|
|
98
95
|
handleMonthChange(date: Date): void;
|
|
99
96
|
handleYearChange(date: Date): void;
|
|
100
|
-
changeMonth({date}: {date: Date}): void;
|
|
101
|
-
changeYear({date}: {date: Date}): void;
|
|
97
|
+
changeMonth({ date }: { date: Date }): void;
|
|
98
|
+
changeYear({ date }: { date: Date }): void;
|
|
102
99
|
renderCalendarHeader(date: Date, order: number): React.ReactNode;
|
|
103
100
|
onKeyDown(event: KeyboardEvent): void;
|
|
104
101
|
handleArrowKey(key: string): void;
|
|
105
102
|
focusCalendar(): void;
|
|
106
103
|
blurCalendar(): void;
|
|
107
104
|
handleTabbing(event: KeyboardEvent): void;
|
|
108
|
-
onDayMouseOver(data: {event: Event; date: Date}): void;
|
|
109
|
-
onDayMouseLeave(data: {event: Event; date: Date}): void;
|
|
110
|
-
handleDateChange(data: {date: Date | Date[]}): void;
|
|
105
|
+
onDayMouseOver(data: { event: Event; date: Date }): void;
|
|
106
|
+
onDayMouseLeave(data: { event: Event; date: Date }): void;
|
|
107
|
+
handleDateChange(data: { date: Date | Date[] }): void;
|
|
111
108
|
handleTimeChange(time: Date, index: number): void;
|
|
112
109
|
setHighlightedDate(date: Date): void;
|
|
113
110
|
renderMonths(): React.ReactNode[];
|
|
114
|
-
renderTimeSelect(
|
|
115
|
-
value: Date,
|
|
116
|
-
onChange: (...args: any) => any,
|
|
117
|
-
): React.ReactNode;
|
|
111
|
+
renderTimeSelect(value: Date, onChange: (...args: any) => any): React.ReactNode;
|
|
118
112
|
renderQuickSelect(): React.ReactNode;
|
|
119
113
|
}
|
|
120
114
|
|
|
121
|
-
export const StatefulCalendar: React.FC<StatefulDatepickerProps<CalendarProps>>;
|
|
115
|
+
export declare const StatefulCalendar: React.FC<StatefulDatepickerProps<CalendarProps>>;
|
|
122
116
|
|
|
123
117
|
export interface DatepickerOverrides<T> {
|
|
124
118
|
Root?: Override<T>;
|
|
@@ -158,7 +152,7 @@ export type DatepickerProps = CalendarProps & {
|
|
|
158
152
|
'aria-describedby'?: string;
|
|
159
153
|
disabled?: boolean;
|
|
160
154
|
clearable?: boolean;
|
|
161
|
-
size?: SIZE[keyof SIZE];
|
|
155
|
+
size?: typeof SIZE[keyof typeof SIZE];
|
|
162
156
|
error?: boolean;
|
|
163
157
|
positive?: boolean;
|
|
164
158
|
placeholder?: string;
|
|
@@ -181,18 +175,12 @@ export interface DatepickerState {
|
|
|
181
175
|
lastActiveElm?: HTMLElement;
|
|
182
176
|
}
|
|
183
177
|
|
|
184
|
-
declare function formatDate(
|
|
185
|
-
date: Date | Date[],
|
|
186
|
-
formatString: string,
|
|
187
|
-
): string | string[];
|
|
178
|
+
declare function formatDate(date: Date | Date[], formatString: string): string | string[];
|
|
188
179
|
|
|
189
|
-
export {formatDate};
|
|
180
|
+
export { formatDate };
|
|
190
181
|
|
|
191
|
-
export class Datepicker extends React.Component<
|
|
192
|
-
|
|
193
|
-
DatepickerState
|
|
194
|
-
> {
|
|
195
|
-
onChange(data: {date: Date | Date[]}): void;
|
|
182
|
+
export class Datepicker extends React.Component<DatepickerProps, DatepickerState> {
|
|
183
|
+
onChange(data: { date: Date | Date[] }): void;
|
|
196
184
|
formatDate(date: Date | Date[], formatString: string): string | string[];
|
|
197
185
|
formatDisplayValue(date: Date | Date[]): string;
|
|
198
186
|
open(): void;
|
|
@@ -202,15 +190,13 @@ export class Datepicker extends React.Component<
|
|
|
202
190
|
handleKeyDown(event: KeyboardEvent): void;
|
|
203
191
|
focusCalendar(): void;
|
|
204
192
|
}
|
|
205
|
-
export {Datepicker as DatePicker};
|
|
193
|
+
export { Datepicker as DatePicker };
|
|
206
194
|
|
|
207
195
|
export type StatefulDatepickerProps<T> = T &
|
|
208
|
-
StatefulContainerProps<T> & {children?: (args: T) => React.ReactNode};
|
|
209
|
-
export const StatefulDatepicker: React.FC<
|
|
210
|
-
StatefulDatepickerProps<DatepickerProps>
|
|
211
|
-
>;
|
|
196
|
+
StatefulContainerProps<T> & { children?: (args: T) => React.ReactNode };
|
|
197
|
+
export declare const StatefulDatepicker: React.FC<StatefulDatepickerProps<DatepickerProps>>;
|
|
212
198
|
|
|
213
|
-
export {StatefulDatepicker as StatefulDatePicker};
|
|
199
|
+
export { StatefulDatepicker as StatefulDatePicker };
|
|
214
200
|
|
|
215
201
|
export interface TimezonePickerProps {
|
|
216
202
|
date?: Date;
|
|
@@ -218,30 +204,23 @@ export interface TimezonePickerProps {
|
|
|
218
204
|
positive?: boolean;
|
|
219
205
|
error?: boolean;
|
|
220
206
|
mapLabels?: (args: Option) => React.ReactNode;
|
|
221
|
-
onChange?: (value: {id: string; label: string; offset: number}) => any;
|
|
222
|
-
overrides?: {Select?: Override<any>};
|
|
207
|
+
onChange?: (value: { id: string; label: string; offset: number }) => any;
|
|
208
|
+
overrides?: { Select?: Override<any> };
|
|
223
209
|
value?: string;
|
|
224
210
|
}
|
|
225
211
|
export interface TimezonePickerState {
|
|
226
212
|
timezones: Option[];
|
|
227
213
|
value?: string;
|
|
228
214
|
}
|
|
229
|
-
export class TimezonePicker extends React.Component<
|
|
230
|
-
TimezonePickerProps,
|
|
231
|
-
TimezonePickerState
|
|
232
|
-
> {
|
|
215
|
+
export class TimezonePicker extends React.Component<TimezonePickerProps, TimezonePickerState> {
|
|
233
216
|
buildTimezones(compareDate: Date): string[];
|
|
234
217
|
}
|
|
235
218
|
|
|
236
|
-
export const DISPLAY_FORMAT: 'L';
|
|
237
|
-
export const ISO_FORMAT: 'YYYY-MM-DD';
|
|
238
|
-
export const ISO_MONTH_FORMAT: 'YYYY-MM';
|
|
239
|
-
|
|
240
|
-
export const STATE_CHANGE_TYPE: STATE_CHANGE_TYPE;
|
|
241
|
-
|
|
242
|
-
export const ORIENTATION: ORIENTATION;
|
|
219
|
+
export declare const DISPLAY_FORMAT: 'L';
|
|
220
|
+
export declare const ISO_FORMAT: 'YYYY-MM-DD';
|
|
221
|
+
export declare const ISO_MONTH_FORMAT: 'YYYY-MM';
|
|
243
222
|
|
|
244
|
-
export const WEEKDAYS: [0, 1, 2, 3, 4, 5, 6];
|
|
223
|
+
export declare const WEEKDAYS: [0, 1, 2, 3, 4, 5, 6];
|
|
245
224
|
|
|
246
225
|
export type SharedStylePropsT = {
|
|
247
226
|
$date: Date;
|
|
@@ -19,6 +19,8 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
19
19
|
|
|
20
20
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
21
|
|
|
22
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
23
|
+
|
|
22
24
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
25
|
|
|
24
26
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -56,7 +58,10 @@ var StatefulComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
56
58
|
key: "render",
|
|
57
59
|
value: function render() {
|
|
58
60
|
return /*#__PURE__*/React.createElement(_statefulContainer.default, this.props, function (extendedProps) {
|
|
59
|
-
return /*#__PURE__*/React.createElement(_calendar.default, extendedProps
|
|
61
|
+
return /*#__PURE__*/React.createElement(_calendar.default, _extends({}, extendedProps, {
|
|
62
|
+
// flowlint-next-line unclear-type:off
|
|
63
|
+
onChange: extendedProps.onChange
|
|
64
|
+
}));
|
|
60
65
|
});
|
|
61
66
|
}
|
|
62
67
|
}]);
|
|
@@ -18,10 +18,17 @@ class StatefulComponent<T = Date> extends React.Component<PropsT<T>> {
|
|
|
18
18
|
stateReducer: (type, nextState) => nextState,
|
|
19
19
|
onSelect: () => {},
|
|
20
20
|
};
|
|
21
|
+
|
|
21
22
|
render() {
|
|
22
23
|
return (
|
|
23
24
|
<StatefulContainer {...this.props}>
|
|
24
|
-
{(extendedProps) =>
|
|
25
|
+
{(extendedProps) => (
|
|
26
|
+
<Calendar
|
|
27
|
+
{...extendedProps}
|
|
28
|
+
// flowlint-next-line unclear-type:off
|
|
29
|
+
onChange={(extendedProps.onChange: any)}
|
|
30
|
+
/>
|
|
31
|
+
)}
|
|
25
32
|
</StatefulContainer>
|
|
26
33
|
);
|
|
27
34
|
}
|
|
@@ -64,8 +64,29 @@ var StatefulContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
64
64
|
value: date
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
var onChange = _this.props.onChange;
|
|
68
|
+
|
|
69
|
+
if (onChange) {
|
|
70
|
+
if (Array.isArray(date)) {
|
|
71
|
+
if (date.every(Boolean)) {
|
|
72
|
+
// flowlint-next-line unclear-type:off
|
|
73
|
+
onChange({
|
|
74
|
+
date: date
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
onChange({
|
|
79
|
+
date: date
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
var onRangeChange = _this.props.onRangeChange;
|
|
85
|
+
|
|
86
|
+
if (onRangeChange) {
|
|
87
|
+
onRangeChange({
|
|
88
|
+
date: date
|
|
89
|
+
});
|
|
69
90
|
}
|
|
70
91
|
});
|
|
71
92
|
|
|
@@ -14,7 +14,6 @@ import type {
|
|
|
14
14
|
StatefulContainerPropsT,
|
|
15
15
|
StateChangeTypeT,
|
|
16
16
|
StateReducerT,
|
|
17
|
-
DateValueT,
|
|
18
17
|
} from './types.js';
|
|
19
18
|
|
|
20
19
|
type InputProps<T> = CalendarPropsT<T> | DatepickerPropsT<T>;
|
|
@@ -34,11 +33,25 @@ class StatefulContainer<T = Date> extends React.Component<PropsT<T>, ContainerSt
|
|
|
34
33
|
this.state = { value, ...props.initialState };
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
onChange: ({ date:
|
|
36
|
+
onChange: ({ +date: ?T | Array<?T> }) => mixed = (data) => {
|
|
38
37
|
const { date } = data;
|
|
39
38
|
this.internalSetState(STATE_CHANGE_TYPE.change, { value: date });
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
|
|
40
|
+
const onChange = this.props.onChange;
|
|
41
|
+
if (onChange) {
|
|
42
|
+
if (Array.isArray(date)) {
|
|
43
|
+
if (date.every(Boolean)) {
|
|
44
|
+
// flowlint-next-line unclear-type:off
|
|
45
|
+
onChange({ date: ((date: any): Array<T>) });
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
onChange({ date });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const onRangeChange = this.props.onRangeChange;
|
|
53
|
+
if (onRangeChange) {
|
|
54
|
+
onRangeChange({ date });
|
|
42
55
|
}
|
|
43
56
|
};
|
|
44
57
|
|
|
@@ -19,6 +19,8 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
19
19
|
|
|
20
20
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
21
|
|
|
22
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
23
|
+
|
|
22
24
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
25
|
|
|
24
26
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -56,7 +58,10 @@ var StatefulComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
56
58
|
key: "render",
|
|
57
59
|
value: function render() {
|
|
58
60
|
return /*#__PURE__*/React.createElement(_statefulContainer.default, this.props, function (extendedProps) {
|
|
59
|
-
return /*#__PURE__*/React.createElement(_datepicker.default, extendedProps
|
|
61
|
+
return /*#__PURE__*/React.createElement(_datepicker.default, _extends({}, extendedProps, {
|
|
62
|
+
// flowlint-next-line unclear-type:off
|
|
63
|
+
onChange: extendedProps.onChange
|
|
64
|
+
}));
|
|
60
65
|
});
|
|
61
66
|
}
|
|
62
67
|
}]);
|
|
@@ -21,7 +21,13 @@ class StatefulComponent<T = Date> extends React.Component<PropsT<T>> {
|
|
|
21
21
|
render() {
|
|
22
22
|
return (
|
|
23
23
|
<StatefulContainer {...this.props}>
|
|
24
|
-
{(extendedProps) =>
|
|
24
|
+
{(extendedProps) => (
|
|
25
|
+
<Datepicker
|
|
26
|
+
{...extendedProps}
|
|
27
|
+
// flowlint-next-line unclear-type:off
|
|
28
|
+
onChange={(extendedProps.onChange: any)}
|
|
29
|
+
/>
|
|
30
|
+
)}
|
|
25
31
|
</StatefulContainer>
|
|
26
32
|
);
|
|
27
33
|
}
|