baseui 0.0.0-alpha-3a96a5e → 0.0.0-alpha-bcb33da
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/a11y.js +2 -2
- package/a11y/a11y.js.flow +3 -3
- package/button/styled-components.js +47 -18
- package/button/styled-components.js.flow +25 -5
- package/data-table/column-categorical.js +1 -1
- package/data-table/column-categorical.js.flow +2 -2
- package/data-table/column-datetime.js +1 -1
- package/data-table/column-datetime.js.flow +1 -1
- package/data-table/column-numerical.js +1 -1
- package/data-table/column-numerical.js.flow +3 -3
- package/datepicker/calendar.js +6 -12
- package/datepicker/calendar.js.flow +12 -23
- package/datepicker/datepicker.js +5 -16
- package/datepicker/datepicker.js.flow +10 -25
- package/datepicker/day.js +30 -58
- package/datepicker/day.js.flow +51 -103
- package/datepicker/stateful-container.js.flow +1 -2
- package/datepicker/types.js.flow +9 -11
- package/drawer/drawer.js +3 -1
- package/drawer/drawer.js.flow +7 -1
- package/es/a11y/a11y.js +2 -2
- package/es/button/styled-components.js +32 -2
- package/es/data-table/column-categorical.js +2 -2
- package/es/data-table/column-datetime.js +1 -1
- package/es/data-table/column-numerical.js +2 -2
- package/es/datepicker/calendar.js +6 -12
- package/es/datepicker/datepicker.js +5 -15
- package/es/datepicker/day.js +30 -51
- package/es/drawer/drawer.js +3 -1
- package/es/form-control/form-control.js +58 -7
- package/es/form-control/styled-components.js +27 -6
- package/es/index.js +1 -1
- package/es/map-marker/badge-enhancer.js +61 -0
- package/es/map-marker/constants.js +146 -2
- package/es/map-marker/drag-shadow.js +32 -0
- package/es/map-marker/fixed-marker.js +54 -48
- package/es/map-marker/floating-marker.js +21 -12
- package/es/map-marker/index.js +1 -1
- package/es/map-marker/label-enhancer.js +39 -0
- package/es/map-marker/needle.js +26 -0
- package/es/map-marker/pin-head.js +42 -40
- package/es/map-marker/styled-components.js +177 -32
- package/es/map-marker/types.js +1 -1
- package/es/modal/modal.js +3 -1
- package/es/popover/popover.js +4 -2
- package/es/progress-bar/index.js +1 -1
- package/es/progress-bar/progressbar.js +15 -7
- package/es/progress-bar/styled-components.js +9 -5
- package/es/table/filter.js +3 -1
- package/es/themes/dark-theme/color-component-tokens.js +4 -0
- package/es/themes/light-theme/color-component-tokens.js +4 -0
- package/es/timezonepicker/timezone-picker.js +53 -36
- package/es/timezonepicker/tzdata.js +2 -0
- package/es/timezonepicker/update-tzdata.js +69 -0
- package/esm/a11y/a11y.js +3 -3
- package/esm/button/styled-components.js +47 -18
- package/esm/data-table/column-categorical.js +2 -2
- package/esm/data-table/column-datetime.js +1 -1
- package/esm/data-table/column-numerical.js +2 -2
- package/esm/datepicker/calendar.js +6 -12
- package/esm/datepicker/datepicker.js +5 -16
- package/esm/datepicker/day.js +30 -58
- package/esm/drawer/drawer.js +3 -1
- package/esm/form-control/form-control.js +60 -9
- package/esm/form-control/styled-components.js +23 -3
- package/esm/index.js +1 -1
- package/esm/map-marker/badge-enhancer.js +79 -0
- package/esm/map-marker/constants.js +94 -4
- package/esm/map-marker/drag-shadow.js +53 -0
- package/esm/map-marker/fixed-marker.js +84 -80
- package/esm/map-marker/floating-marker.js +22 -13
- package/esm/map-marker/index.js +1 -1
- package/esm/map-marker/label-enhancer.js +60 -0
- package/esm/map-marker/needle.js +43 -0
- package/esm/map-marker/pin-head.js +77 -66
- package/esm/map-marker/styled-components.js +182 -51
- package/esm/map-marker/types.js +1 -1
- package/esm/modal/modal.js +3 -1
- package/esm/popover/popover.js +4 -2
- package/esm/progress-bar/index.js +1 -1
- package/esm/progress-bar/progressbar.js +17 -8
- package/esm/progress-bar/styled-components.js +9 -4
- package/esm/table/filter.js +3 -1
- package/esm/themes/dark-theme/color-component-tokens.js +4 -0
- package/esm/themes/light-theme/color-component-tokens.js +4 -0
- package/esm/timezonepicker/timezone-picker.js +64 -36
- package/esm/timezonepicker/tzdata.js +2 -0
- package/esm/timezonepicker/update-tzdata.js +160 -0
- package/form-control/form-control.js +61 -8
- package/form-control/form-control.js.flow +82 -10
- package/form-control/index.d.ts +1 -0
- package/form-control/styled-components.js +27 -5
- package/form-control/styled-components.js.flow +25 -3
- package/form-control/types.js.flow +20 -8
- package/index.js +6 -0
- package/index.js.flow +1 -1
- package/map-marker/badge-enhancer.js +90 -0
- package/map-marker/badge-enhancer.js.flow +86 -0
- package/map-marker/constants.js +103 -5
- package/map-marker/constants.js.flow +152 -0
- package/map-marker/drag-shadow.js +64 -0
- package/map-marker/drag-shadow.js.flow +52 -0
- package/map-marker/fixed-marker.js +84 -78
- package/map-marker/fixed-marker.js.flow +78 -66
- package/map-marker/floating-marker.js +22 -13
- package/map-marker/floating-marker.js.flow +30 -17
- package/map-marker/index.d.ts +125 -24
- package/map-marker/index.js +18 -0
- package/map-marker/index.js.flow +3 -0
- package/map-marker/label-enhancer.js +71 -0
- package/map-marker/label-enhancer.js.flow +63 -0
- package/map-marker/needle.js +54 -0
- package/map-marker/needle.js.flow +29 -0
- package/map-marker/pin-head.js +80 -69
- package/map-marker/pin-head.js.flow +122 -84
- package/map-marker/styled-components.js +200 -62
- package/map-marker/styled-components.js.flow +172 -22
- package/map-marker/types.js.flow +69 -20
- package/modal/modal.js +3 -1
- package/modal/modal.js.flow +2 -0
- package/package.json +4 -4
- package/popover/popover.js +4 -2
- package/popover/popover.js.flow +3 -1
- package/progress-bar/index.d.ts +2 -0
- package/progress-bar/index.js +6 -0
- package/progress-bar/index.js.flow +1 -0
- package/progress-bar/progressbar.js +17 -8
- package/progress-bar/progressbar.js.flow +19 -7
- package/progress-bar/styled-components.js +9 -4
- package/progress-bar/styled-components.js.flow +15 -4
- package/progress-bar/types.js.flow +12 -2
- package/styles/index.js.flow +1 -1
- package/table/filter.js +3 -1
- package/table/filter.js.flow +5 -1
- package/themes/dark-theme/color-component-tokens.js +4 -0
- package/themes/dark-theme/color-component-tokens.js.flow +4 -0
- package/themes/light-theme/color-component-tokens.js +4 -0
- package/themes/light-theme/color-component-tokens.js.flow +4 -0
- package/themes/types.js.flow +4 -0
- package/timezonepicker/timezone-picker.js +69 -41
- package/timezonepicker/timezone-picker.js.flow +52 -46
- package/timezonepicker/types.js.flow +1 -1
- package/timezonepicker/tzdata.js +10 -0
- package/timezonepicker/tzdata.js.flow +347 -0
- package/timezonepicker/update-tzdata.js +164 -0
- package/timezonepicker/update-tzdata.js.flow +70 -0
package/a11y/a11y.js
CHANGED
|
@@ -140,8 +140,8 @@ function Violation(props) {
|
|
|
140
140
|
ref: setPopper,
|
|
141
141
|
$top: "".concat(offset.top, "px") || '0px',
|
|
142
142
|
$left: "".concat(offset.left, "px") || '0px'
|
|
143
|
-
}, /*#__PURE__*/React.createElement(_index2.
|
|
144
|
-
return /*#__PURE__*/React.createElement(_index2.
|
|
143
|
+
}, /*#__PURE__*/React.createElement(_index2.ParagraphXSmall, null, props.target), props.violations.map(function (violation, index) {
|
|
144
|
+
return /*#__PURE__*/React.createElement(_index2.ParagraphSmall, {
|
|
145
145
|
key: index
|
|
146
146
|
}, violation.description);
|
|
147
147
|
}))));
|
package/a11y/a11y.js.flow
CHANGED
|
@@ -11,7 +11,7 @@ import * as React from 'react';
|
|
|
11
11
|
import axe from 'axe-core';
|
|
12
12
|
|
|
13
13
|
import {Layer, TetherBehavior, TETHER_PLACEMENT} from '../layer/index.js';
|
|
14
|
-
import {
|
|
14
|
+
import {ParagraphSmall, ParagraphXSmall} from '../typography/index.js';
|
|
15
15
|
import {styled} from '../styles/index.js';
|
|
16
16
|
import {ThemeContext} from '../styles/theme-provider.js';
|
|
17
17
|
|
|
@@ -101,9 +101,9 @@ function Violation(props: ViolationPropsT) {
|
|
|
101
101
|
$top={`${offset.top}px` || '0px'}
|
|
102
102
|
$left={`${offset.left}px` || '0px'}
|
|
103
103
|
>
|
|
104
|
-
<
|
|
104
|
+
<ParagraphXSmall>{props.target}</ParagraphXSmall>
|
|
105
105
|
{props.violations.map((violation, index) => (
|
|
106
|
-
<
|
|
106
|
+
<ParagraphSmall key={index}>{violation.description}</ParagraphSmall>
|
|
107
107
|
))}
|
|
108
108
|
</ViolationContainer>
|
|
109
109
|
</TetherBehavior>
|
|
@@ -46,11 +46,14 @@ var BaseButton = (0, _index.styled)('button', function (_ref) {
|
|
|
46
46
|
transitionDuration: $theme.animation.timing200,
|
|
47
47
|
transitionTimingFunction: $theme.animation.linearCurve,
|
|
48
48
|
cursor: 'pointer',
|
|
49
|
-
':disabled': {
|
|
50
|
-
cursor: 'not-allowed'
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
':disabled': _objectSpread({
|
|
50
|
+
cursor: 'not-allowed'
|
|
51
|
+
}, getDisabledStyles({
|
|
52
|
+
$theme: $theme,
|
|
53
|
+
$kind: $kind,
|
|
54
|
+
$disabled: $disabled,
|
|
55
|
+
$isSelected: $isSelected
|
|
56
|
+
})),
|
|
54
57
|
marginLeft: 0,
|
|
55
58
|
marginTop: 0,
|
|
56
59
|
marginRight: 0,
|
|
@@ -275,10 +278,36 @@ function getFontStyles(_ref10) {
|
|
|
275
278
|
}
|
|
276
279
|
}
|
|
277
280
|
|
|
278
|
-
function
|
|
281
|
+
function getDisabledStyles(_ref11) {
|
|
279
282
|
var $theme = _ref11.$theme,
|
|
280
|
-
$
|
|
281
|
-
$
|
|
283
|
+
$kind = _ref11.$kind,
|
|
284
|
+
$isSelected = _ref11.$isSelected,
|
|
285
|
+
$disabled = _ref11.$disabled;
|
|
286
|
+
|
|
287
|
+
if ($disabled && $isSelected) {
|
|
288
|
+
if ($kind === _constants.KIND.primary || $kind === _constants.KIND.secondary) {
|
|
289
|
+
return {
|
|
290
|
+
color: $theme.colors.buttonDisabledActiveText,
|
|
291
|
+
backgroundColor: $theme.colors.buttonDisabledActiveFill
|
|
292
|
+
};
|
|
293
|
+
} else if ($kind === _constants.KIND.minimal || $kind === _constants.KIND.tertiary) {
|
|
294
|
+
return {
|
|
295
|
+
backgroundColor: $theme.colors.buttonTertiaryDisabledActiveFill,
|
|
296
|
+
color: $theme.colors.buttonTertiaryDisabledActiveText
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return {
|
|
302
|
+
backgroundColor: $kind === _constants.KIND.minimal || $kind === _constants.KIND.tertiary ? 'transparent' : $theme.colors.buttonDisabledFill,
|
|
303
|
+
color: $theme.colors.buttonDisabledText
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function getPaddingStyles(_ref12) {
|
|
308
|
+
var $theme = _ref12.$theme,
|
|
309
|
+
$size = _ref12.$size,
|
|
310
|
+
$shape = _ref12.$shape;
|
|
282
311
|
var iconShape = $shape === _constants.SHAPE.square || $shape === _constants.SHAPE.circle || $shape === _constants.SHAPE.round;
|
|
283
312
|
|
|
284
313
|
switch ($size) {
|
|
@@ -316,12 +345,12 @@ function getPaddingStyles(_ref11) {
|
|
|
316
345
|
}
|
|
317
346
|
}
|
|
318
347
|
|
|
319
|
-
function getKindStyles(
|
|
320
|
-
var $theme =
|
|
321
|
-
$isLoading =
|
|
322
|
-
$isSelected =
|
|
323
|
-
$kind =
|
|
324
|
-
$disabled =
|
|
348
|
+
function getKindStyles(_ref13) {
|
|
349
|
+
var $theme = _ref13.$theme,
|
|
350
|
+
$isLoading = _ref13.$isLoading,
|
|
351
|
+
$isSelected = _ref13.$isSelected,
|
|
352
|
+
$kind = _ref13.$kind,
|
|
353
|
+
$disabled = _ref13.$disabled;
|
|
325
354
|
|
|
326
355
|
if ($disabled) {
|
|
327
356
|
return Object.freeze({});
|
|
@@ -409,10 +438,10 @@ function getKindStyles(_ref12) {
|
|
|
409
438
|
}
|
|
410
439
|
}
|
|
411
440
|
|
|
412
|
-
function getShapeStyles(
|
|
413
|
-
var $theme =
|
|
414
|
-
$shape =
|
|
415
|
-
$size =
|
|
441
|
+
function getShapeStyles(_ref14) {
|
|
442
|
+
var $theme = _ref14.$theme,
|
|
443
|
+
$shape = _ref14.$shape,
|
|
444
|
+
$size = _ref14.$size;
|
|
416
445
|
|
|
417
446
|
if ($shape === _constants.SHAPE.circle || $shape === _constants.SHAPE.square) {
|
|
418
447
|
var height, width;
|
|
@@ -46,11 +46,7 @@ export const BaseButton = styled<SharedStylePropsT>(
|
|
|
46
46
|
cursor: 'pointer',
|
|
47
47
|
':disabled': {
|
|
48
48
|
cursor: 'not-allowed',
|
|
49
|
-
|
|
50
|
-
$kind === KIND.minimal || $kind === KIND.tertiary
|
|
51
|
-
? 'transparent'
|
|
52
|
-
: $theme.colors.buttonDisabledFill,
|
|
53
|
-
color: $theme.colors.buttonDisabledText,
|
|
49
|
+
...getDisabledStyles({$theme, $kind, $disabled, $isSelected}),
|
|
54
50
|
},
|
|
55
51
|
marginLeft: 0,
|
|
56
52
|
marginTop: 0,
|
|
@@ -229,6 +225,30 @@ function getFontStyles({$theme, $size}) {
|
|
|
229
225
|
}
|
|
230
226
|
}
|
|
231
227
|
|
|
228
|
+
function getDisabledStyles({$theme, $kind, $isSelected, $disabled}) {
|
|
229
|
+
if ($disabled && $isSelected) {
|
|
230
|
+
if ($kind === KIND.primary || $kind === KIND.secondary) {
|
|
231
|
+
return {
|
|
232
|
+
color: $theme.colors.buttonDisabledActiveText,
|
|
233
|
+
backgroundColor: $theme.colors.buttonDisabledActiveFill,
|
|
234
|
+
};
|
|
235
|
+
} else if ($kind === KIND.minimal || $kind === KIND.tertiary) {
|
|
236
|
+
return {
|
|
237
|
+
backgroundColor: $theme.colors.buttonTertiaryDisabledActiveFill,
|
|
238
|
+
color: $theme.colors.buttonTertiaryDisabledActiveText,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return {
|
|
244
|
+
backgroundColor:
|
|
245
|
+
$kind === KIND.minimal || $kind === KIND.tertiary
|
|
246
|
+
? 'transparent'
|
|
247
|
+
: $theme.colors.buttonDisabledFill,
|
|
248
|
+
color: $theme.colors.buttonDisabledText,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
232
252
|
function getPaddingStyles({$theme, $size, $shape}) {
|
|
233
253
|
const iconShape =
|
|
234
254
|
$shape === SHAPE.square ||
|
|
@@ -208,7 +208,7 @@ function CategoricalFilter(props) {
|
|
|
208
208
|
overflowY: 'auto',
|
|
209
209
|
marginTop: theme.sizing.scale600
|
|
210
210
|
})
|
|
211
|
-
}, !filteredCategories.length && /*#__PURE__*/React.createElement(_index6.
|
|
211
|
+
}, !filteredCategories.length && /*#__PURE__*/React.createElement(_index6.LabelSmall, null, locale.datatable.categoricalFilterEmpty), Boolean(filteredCategories.length) && filteredCategories.map(function (category, i) {
|
|
212
212
|
return /*#__PURE__*/React.createElement("div", {
|
|
213
213
|
className: checkboxStyles,
|
|
214
214
|
key: i
|
|
@@ -14,7 +14,7 @@ import {Checkbox, StyledLabel} from '../checkbox/index.js';
|
|
|
14
14
|
import Search from '../icon/search.js';
|
|
15
15
|
import {Input, SIZE as INPUT_SIZE} from '../input/index.js';
|
|
16
16
|
import {useStyletron, withStyle} from '../styles/index.js';
|
|
17
|
-
import {
|
|
17
|
+
import {LabelSmall} from '../typography/index.js';
|
|
18
18
|
|
|
19
19
|
import Column from './column.js';
|
|
20
20
|
import {COLUMNS} from './constants.js';
|
|
@@ -184,7 +184,7 @@ export function CategoricalFilter(props: CategoricalFilterProps) {
|
|
|
184
184
|
})}
|
|
185
185
|
>
|
|
186
186
|
{!filteredCategories.length && (
|
|
187
|
-
<
|
|
187
|
+
<LabelSmall>{locale.datatable.categoricalFilterEmpty}</LabelSmall>
|
|
188
188
|
)}
|
|
189
189
|
|
|
190
190
|
{Boolean(filteredCategories.length) &&
|
|
@@ -456,7 +456,7 @@ function DatetimeFilter(props) {
|
|
|
456
456
|
if (Array.isArray(date)) {
|
|
457
457
|
if (!date.length) return;
|
|
458
458
|
var nextDates = date.map(function (d, i) {
|
|
459
|
-
return
|
|
459
|
+
return (0, _index13.applyDateToTime)(rangeDates[i], d);
|
|
460
460
|
});
|
|
461
461
|
setRangeDates(nextDates);
|
|
462
462
|
}
|
|
@@ -410,7 +410,7 @@ function DatetimeFilter(props) {
|
|
|
410
410
|
if (Array.isArray(date)) {
|
|
411
411
|
if (!date.length) return;
|
|
412
412
|
const nextDates = date.map((d, i) =>
|
|
413
|
-
|
|
413
|
+
applyDateToTime(rangeDates[i], d),
|
|
414
414
|
);
|
|
415
415
|
setRangeDates(nextDates);
|
|
416
416
|
}
|
|
@@ -493,7 +493,7 @@ function NumericalFilter(props) {
|
|
|
493
493
|
marginLeft: theme.sizing.scale300,
|
|
494
494
|
marginRight: theme.sizing.scale300
|
|
495
495
|
})
|
|
496
|
-
}, /*#__PURE__*/React.createElement(_index5.
|
|
496
|
+
}, /*#__PURE__*/React.createElement(_index5.ParagraphXSmall, null, format(min, props.options)), ' ', /*#__PURE__*/React.createElement(_index5.ParagraphXSmall, null, format(max, props.options))), /*#__PURE__*/React.createElement("div", {
|
|
497
497
|
className: css({
|
|
498
498
|
display: 'flex',
|
|
499
499
|
justifyContent: 'space-between'
|
|
@@ -12,7 +12,7 @@ import {Button, SIZE} from '../button/index.js';
|
|
|
12
12
|
import {ButtonGroup, MODE} from '../button-group/index.js';
|
|
13
13
|
import {Input, SIZE as INPUT_SIZE} from '../input/index.js';
|
|
14
14
|
import {useStyletron} from '../styles/index.js';
|
|
15
|
-
import {
|
|
15
|
+
import {ParagraphXSmall} from '../typography/index.js';
|
|
16
16
|
|
|
17
17
|
import Column from './column.js';
|
|
18
18
|
import {COLUMNS, NUMERICAL_FORMATS, NUMERICAL_OPERATIONS} from './constants.js';
|
|
@@ -388,8 +388,8 @@ function NumericalFilter(props) {
|
|
|
388
388
|
marginRight: theme.sizing.scale300,
|
|
389
389
|
})}
|
|
390
390
|
>
|
|
391
|
-
<
|
|
392
|
-
<
|
|
391
|
+
<ParagraphXSmall>{format(min, props.options)}</ParagraphXSmall>{' '}
|
|
392
|
+
<ParagraphXSmall>{format(max, props.options)}</ParagraphXSmall>
|
|
393
393
|
</div>
|
|
394
394
|
|
|
395
395
|
<div className={css({display: 'flex', justifyContent: 'space-between'})}>
|
package/datepicker/calendar.js
CHANGED
|
@@ -339,16 +339,10 @@ var Calendar = /*#__PURE__*/function (_React$Component) {
|
|
|
339
339
|
|
|
340
340
|
|
|
341
341
|
if (Array.isArray(data.date)) {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
if (end) {
|
|
347
|
-
updatedDate = [start, end];
|
|
348
|
-
newTimeState[1] = end;
|
|
349
|
-
} else {
|
|
350
|
-
updatedDate = [start];
|
|
351
|
-
}
|
|
342
|
+
updatedDate = data.date.map(function (date, index) {
|
|
343
|
+
newTimeState[index] = _this.dateHelpers.applyDateToTime(newTimeState[index], date);
|
|
344
|
+
return newTimeState[index];
|
|
345
|
+
});
|
|
352
346
|
} else if (!Array.isArray(_this.props.value) && data.date) {
|
|
353
347
|
newTimeState[0] = _this.dateHelpers.applyDateToTime(newTimeState[0], data.date);
|
|
354
348
|
updatedDate = newTimeState[0];
|
|
@@ -380,7 +374,7 @@ var Calendar = /*#__PURE__*/function (_React$Component) {
|
|
|
380
374
|
|
|
381
375
|
if (Array.isArray(_this.props.value)) {
|
|
382
376
|
var dates = _this.props.value.map(function (date, i) {
|
|
383
|
-
if (
|
|
377
|
+
if (index === i) {
|
|
384
378
|
return _this.dateHelpers.applyTimeToDate(date, time);
|
|
385
379
|
}
|
|
386
380
|
|
|
@@ -388,7 +382,7 @@ var Calendar = /*#__PURE__*/function (_React$Component) {
|
|
|
388
382
|
});
|
|
389
383
|
|
|
390
384
|
onChange({
|
|
391
|
-
date:
|
|
385
|
+
date: dates
|
|
392
386
|
});
|
|
393
387
|
} else {
|
|
394
388
|
var date = _this.dateHelpers.applyTimeToDate(_this.props.value, time);
|
|
@@ -22,11 +22,7 @@ import {
|
|
|
22
22
|
import dateFnsAdapter from './utils/date-fns-adapter.js';
|
|
23
23
|
import DateHelpers from './utils/date-helpers.js';
|
|
24
24
|
import {getOverrides, mergeOverrides} from '../helpers/overrides.js';
|
|
25
|
-
import type {
|
|
26
|
-
CalendarPropsT,
|
|
27
|
-
CalendarInternalState,
|
|
28
|
-
DateValueT,
|
|
29
|
-
} from './types.js';
|
|
25
|
+
import type {CalendarPropsT, CalendarInternalState} from './types.js';
|
|
30
26
|
import {DENSITY, ORIENTATION} from './constants.js';
|
|
31
27
|
|
|
32
28
|
export default class Calendar<T = Date> extends React.Component<
|
|
@@ -144,7 +140,7 @@ export default class Calendar<T = Date> extends React.Component<
|
|
|
144
140
|
return monthDelta >= 0 && monthDelta < (this.props.monthsShown || 1);
|
|
145
141
|
}
|
|
146
142
|
|
|
147
|
-
getSingleDate(value:
|
|
143
|
+
getSingleDate(value: ?T | Array<T>): ?T {
|
|
148
144
|
// need to check this.props.range but flow would complain
|
|
149
145
|
// at the return value in the else clause
|
|
150
146
|
if (Array.isArray(value)) {
|
|
@@ -350,26 +346,20 @@ export default class Calendar<T = Date> extends React.Component<
|
|
|
350
346
|
this.props.onDayMouseLeave && this.props.onDayMouseLeave(data);
|
|
351
347
|
};
|
|
352
348
|
|
|
353
|
-
handleDateChange: ({date:
|
|
349
|
+
handleDateChange: ({date: ?T | Array<T>}) => void = data => {
|
|
354
350
|
const {onChange = params => {}} = this.props;
|
|
355
351
|
let updatedDate = data.date;
|
|
356
352
|
// We'll need to update the date in time values of internal state
|
|
357
353
|
const newTimeState = [...this.state.time];
|
|
358
354
|
// Apply the currently selected time values (saved in state) to the updated date
|
|
359
355
|
if (Array.isArray(data.date)) {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
if (end) {
|
|
368
|
-
updatedDate = [start, end];
|
|
369
|
-
newTimeState[1] = end;
|
|
370
|
-
} else {
|
|
371
|
-
updatedDate = [start];
|
|
372
|
-
}
|
|
356
|
+
updatedDate = data.date.map((date, index) => {
|
|
357
|
+
newTimeState[index] = this.dateHelpers.applyDateToTime(
|
|
358
|
+
newTimeState[index],
|
|
359
|
+
date,
|
|
360
|
+
);
|
|
361
|
+
return newTimeState[index];
|
|
362
|
+
});
|
|
373
363
|
} else if (!Array.isArray(this.props.value) && data.date) {
|
|
374
364
|
newTimeState[0] = this.dateHelpers.applyDateToTime(
|
|
375
365
|
newTimeState[0],
|
|
@@ -377,7 +367,6 @@ export default class Calendar<T = Date> extends React.Component<
|
|
|
377
367
|
);
|
|
378
368
|
updatedDate = newTimeState[0];
|
|
379
369
|
}
|
|
380
|
-
|
|
381
370
|
// Update the date in time values of internal state
|
|
382
371
|
this.setState({time: newTimeState});
|
|
383
372
|
onChange({date: updatedDate});
|
|
@@ -396,12 +385,12 @@ export default class Calendar<T = Date> extends React.Component<
|
|
|
396
385
|
// with the date value set to the date with updated time
|
|
397
386
|
if (Array.isArray(this.props.value)) {
|
|
398
387
|
const dates = this.props.value.map((date, i) => {
|
|
399
|
-
if (
|
|
388
|
+
if (index === i) {
|
|
400
389
|
return this.dateHelpers.applyTimeToDate(date, time);
|
|
401
390
|
}
|
|
402
391
|
return date;
|
|
403
392
|
});
|
|
404
|
-
onChange({date:
|
|
393
|
+
onChange({date: dates});
|
|
405
394
|
} else {
|
|
406
395
|
const date = this.dateHelpers.applyTimeToDate(this.props.value, time);
|
|
407
396
|
onChange({date});
|
package/datepicker/datepicker.js
CHANGED
|
@@ -98,7 +98,6 @@ var combineSeparatedInputs = function combineSeparatedInputs(newInputValue) {
|
|
|
98
98
|
prevEndDate = _prevCombinedInputVal4 === void 0 ? '' : _prevCombinedInputVal4;
|
|
99
99
|
|
|
100
100
|
if (separatedInput === 'startDate' && prevEndDate) {
|
|
101
|
-
// TODO(LUKE): use INPUT_DELIMITER below
|
|
102
101
|
inputValue = "".concat(inputValue, " \u2013 ").concat(prevEndDate);
|
|
103
102
|
}
|
|
104
103
|
|
|
@@ -132,11 +131,11 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
132
131
|
var nextDate = data.date;
|
|
133
132
|
|
|
134
133
|
if (Array.isArray(nextDate) && _this.props.range) {
|
|
135
|
-
if (
|
|
134
|
+
if (nextDate.length < 2) {
|
|
136
135
|
isOpen = true;
|
|
137
136
|
isPseudoFocused = true;
|
|
138
137
|
calendarFocused = null;
|
|
139
|
-
} else if (nextDate
|
|
138
|
+
} else if (nextDate.length === 2) {
|
|
140
139
|
var _nextDate = nextDate,
|
|
141
140
|
_nextDate2 = _slicedToArray(_nextDate, 2),
|
|
142
141
|
start = _nextDate2[0],
|
|
@@ -283,7 +282,6 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
283
282
|
}
|
|
284
283
|
|
|
285
284
|
if (range && !separateRangeInputs) {
|
|
286
|
-
// TODO(LUKE): use INPUT_DELIMITER below
|
|
287
285
|
return '9999/99/99 – 9999/99/99';
|
|
288
286
|
}
|
|
289
287
|
|
|
@@ -471,11 +469,6 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
471
469
|
}
|
|
472
470
|
|
|
473
471
|
_createClass(Datepicker, [{
|
|
474
|
-
key: "getNullDatePlaceholder",
|
|
475
|
-
value: function getNullDatePlaceholder(formatString) {
|
|
476
|
-
return (this.getMask() || formatString).split('–')[0].replace(/[0-9]|[a-z]/g, ' ');
|
|
477
|
-
}
|
|
478
|
-
}, {
|
|
479
472
|
key: "formatDate",
|
|
480
473
|
value: function formatDate(date, formatString) {
|
|
481
474
|
var _this2 = this;
|
|
@@ -492,13 +485,9 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
492
485
|
return '';
|
|
493
486
|
} else if (Array.isArray(date) && !date[0] && !date[1]) {
|
|
494
487
|
return '';
|
|
495
|
-
} else if (Array.isArray(date) && !date[0] && date[1]) {
|
|
496
|
-
var endDate = format(date[1]);
|
|
497
|
-
var startDate = this.getNullDatePlaceholder(formatString);
|
|
498
|
-
return [startDate, endDate].join(INPUT_DELIMITER);
|
|
499
488
|
} else if (Array.isArray(date)) {
|
|
500
489
|
return date.map(function (day) {
|
|
501
|
-
return
|
|
490
|
+
return format(day);
|
|
502
491
|
}).join(INPUT_DELIMITER);
|
|
503
492
|
} else {
|
|
504
493
|
return format(date);
|
|
@@ -650,11 +639,11 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
650
639
|
clipPath: 'inset(100%)'
|
|
651
640
|
}
|
|
652
641
|
}, // No date selected
|
|
653
|
-
!_this4.props.value || Array.isArray(_this4.props.value) && !_this4.props.value
|
|
642
|
+
!_this4.props.value || Array.isArray(_this4.props.value) && !_this4.props.value.length ? '' : // Date selected in a non-range picker
|
|
654
643
|
!Array.isArray(_this4.props.value) ? (0, _i18nInterpolation.default)(locale.datepicker.selectedDate, {
|
|
655
644
|
date: _this4.state.inputValue || ''
|
|
656
645
|
}) : // Start and end dates are selected in a range picker
|
|
657
|
-
_this4.props.value
|
|
646
|
+
_this4.props.value.length > 1 ? (0, _i18nInterpolation.default)(locale.datepicker.selectedDateRange, {
|
|
658
647
|
startDate: _this4.formatDisplayValue(_this4.props.value[0]),
|
|
659
648
|
endDate: _this4.formatDisplayValue( // $FlowFixMe
|
|
660
649
|
_this4.props.value[1])
|
|
@@ -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} 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';
|
|
@@ -38,7 +38,6 @@ const combineSeparatedInputs = (
|
|
|
38
38
|
INPUT_DELIMITER,
|
|
39
39
|
);
|
|
40
40
|
if (separatedInput === 'startDate' && prevEndDate) {
|
|
41
|
-
// TODO(LUKE): use INPUT_DELIMITER below
|
|
42
41
|
inputValue = `${inputValue} – ${prevEndDate}`;
|
|
43
42
|
}
|
|
44
43
|
if (separatedInput === 'endDate') {
|
|
@@ -82,18 +81,18 @@ export default class Datepicker<T = Date> extends React.Component<
|
|
|
82
81
|
};
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
onChange: ({date:
|
|
84
|
+
onChange: ({date: ?T | Array<T>}) => void = data => {
|
|
86
85
|
let isOpen = false;
|
|
87
86
|
let isPseudoFocused = false;
|
|
88
87
|
let calendarFocused = false;
|
|
89
88
|
let nextDate = data.date;
|
|
90
89
|
|
|
91
90
|
if (Array.isArray(nextDate) && this.props.range) {
|
|
92
|
-
if (
|
|
91
|
+
if (nextDate.length < 2) {
|
|
93
92
|
isOpen = true;
|
|
94
93
|
isPseudoFocused = true;
|
|
95
94
|
calendarFocused = null;
|
|
96
|
-
} else if (nextDate
|
|
95
|
+
} else if (nextDate.length === 2) {
|
|
97
96
|
const [start, end] = nextDate;
|
|
98
97
|
if (this.dateHelpers.isAfter(start, end)) {
|
|
99
98
|
nextDate = [start, start];
|
|
@@ -144,36 +143,25 @@ export default class Datepicker<T = Date> extends React.Component<
|
|
|
144
143
|
this.props.onChange && this.props.onChange({date: nextDate});
|
|
145
144
|
};
|
|
146
145
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
.split('–')[0]
|
|
150
|
-
.replace(/[0-9]|[a-z]/g, ' ');
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
formatDate(date: DateValueT<T>, formatString: string) {
|
|
154
|
-
const format = (date: T) => {
|
|
146
|
+
formatDate(date: ?T | Array<T>, formatString: string) {
|
|
147
|
+
const format = date => {
|
|
155
148
|
if (formatString === DEFAULT_DATE_FORMAT) {
|
|
156
149
|
return this.dateHelpers.format(date, 'slashDate', this.props.locale);
|
|
157
150
|
}
|
|
158
151
|
return this.dateHelpers.formatDate(date, formatString, this.props.locale);
|
|
159
152
|
};
|
|
160
|
-
|
|
161
153
|
if (!date) {
|
|
162
154
|
return '';
|
|
163
155
|
} else if (Array.isArray(date) && !date[0] && !date[1]) {
|
|
164
156
|
return '';
|
|
165
|
-
} else if (Array.isArray(date) && !date[0] && date[1]) {
|
|
166
|
-
const endDate = format(date[1]);
|
|
167
|
-
const startDate = this.getNullDatePlaceholder(formatString);
|
|
168
|
-
return [startDate, endDate].join(INPUT_DELIMITER);
|
|
169
157
|
} else if (Array.isArray(date)) {
|
|
170
|
-
return date.map(day =>
|
|
158
|
+
return date.map(day => format(day)).join(INPUT_DELIMITER);
|
|
171
159
|
} else {
|
|
172
160
|
return format(date);
|
|
173
161
|
}
|
|
174
162
|
}
|
|
175
163
|
|
|
176
|
-
formatDisplayValue: (
|
|
164
|
+
formatDisplayValue: (?T | Array<T>) => string = (date: ?T | Array<T>) => {
|
|
177
165
|
const {displayValueAtRangeIndex, formatDisplayValue, range} = this.props;
|
|
178
166
|
const formatString = this.normalizeDashes(this.props.formatString);
|
|
179
167
|
|
|
@@ -253,7 +241,6 @@ export default class Datepicker<T = Date> extends React.Component<
|
|
|
253
241
|
}
|
|
254
242
|
|
|
255
243
|
if (range && !separateRangeInputs) {
|
|
256
|
-
// TODO(LUKE): use INPUT_DELIMITER below
|
|
257
244
|
return '9999/99/99 – 9999/99/99';
|
|
258
245
|
}
|
|
259
246
|
|
|
@@ -613,9 +600,7 @@ export default class Datepicker<T = Date> extends React.Component<
|
|
|
613
600
|
>
|
|
614
601
|
{// No date selected
|
|
615
602
|
!this.props.value ||
|
|
616
|
-
(Array.isArray(this.props.value) &&
|
|
617
|
-
!this.props.value[0] &&
|
|
618
|
-
!this.props.value[1])
|
|
603
|
+
(Array.isArray(this.props.value) && !this.props.value.length)
|
|
619
604
|
? ''
|
|
620
605
|
: // Date selected in a non-range picker
|
|
621
606
|
!Array.isArray(this.props.value)
|
|
@@ -623,7 +608,7 @@ export default class Datepicker<T = Date> extends React.Component<
|
|
|
623
608
|
date: this.state.inputValue || '',
|
|
624
609
|
})
|
|
625
610
|
: // Start and end dates are selected in a range picker
|
|
626
|
-
this.props.value
|
|
611
|
+
this.props.value.length > 1
|
|
627
612
|
? getInterpolatedString(locale.datepicker.selectedDateRange, {
|
|
628
613
|
startDate: this.formatDisplayValue(this.props.value[0]),
|
|
629
614
|
endDate: this.formatDisplayValue(
|