baseui 0.0.0-alpha-5f4bc37 → 0.0.0-alpha-2158d09
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/data-table/data-table.js +53 -50
- package/data-table/data-table.js.flow +18 -13
- package/data-table/measure-column-widths.js +83 -121
- package/data-table/measure-column-widths.js.flow +87 -109
- 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/data-table/data-table.js +18 -16
- package/es/data-table/measure-column-widths.js +75 -86
- 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/es/utils/lcg.js +14 -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/data-table/data-table.js +53 -50
- package/esm/data-table/measure-column-widths.js +83 -121
- 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/esm/utils/lcg.js +16 -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/utils/lcg.js +24 -0
- package/utils/lcg.js.flow +21 -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/data-table/data-table.js
CHANGED
|
@@ -62,6 +62,12 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
62
62
|
// consider pulling this out to a prop if useful.
|
|
63
63
|
var HEADER_ROW_HEIGHT = 48;
|
|
64
64
|
|
|
65
|
+
var sum = function sum(ns) {
|
|
66
|
+
return ns.reduce(function (s, n) {
|
|
67
|
+
return s + n;
|
|
68
|
+
}, 0);
|
|
69
|
+
};
|
|
70
|
+
|
|
65
71
|
function CellPlacement(_ref) {
|
|
66
72
|
var columnIndex = _ref.columnIndex,
|
|
67
73
|
rowIndex = _ref.rowIndex,
|
|
@@ -320,7 +326,7 @@ function Header(props) {
|
|
|
320
326
|
}))));
|
|
321
327
|
}
|
|
322
328
|
|
|
323
|
-
function Headers(
|
|
329
|
+
function Headers() {
|
|
324
330
|
var _useStyletron5 = (0, _index2.useStyletron)(),
|
|
325
331
|
_useStyletron6 = _slicedToArray(_useStyletron5, 2),
|
|
326
332
|
css = _useStyletron6[0],
|
|
@@ -339,9 +345,7 @@ function Headers(props) {
|
|
|
339
345
|
position: 'sticky',
|
|
340
346
|
top: 0,
|
|
341
347
|
left: 0,
|
|
342
|
-
width: "".concat(ctx.widths
|
|
343
|
-
return sum + w;
|
|
344
|
-
}, 0), "px"),
|
|
348
|
+
width: "".concat(sum(ctx.widths), "px"),
|
|
345
349
|
height: "".concat(HEADER_ROW_HEIGHT, "px"),
|
|
346
350
|
display: 'flex',
|
|
347
351
|
// this feels bad.. the absolutely positioned children elements
|
|
@@ -564,22 +568,27 @@ function DataTable(_ref2) {
|
|
|
564
568
|
}
|
|
565
569
|
|
|
566
570
|
return rowHeight;
|
|
567
|
-
}, [rowHeight]);
|
|
568
|
-
|
|
571
|
+
}, [rowHeight]); // We use state for our ref, to allow hooks to update when the ref changes.
|
|
572
|
+
// eslint-disable-next-line flowtype/no-weak-types
|
|
569
573
|
|
|
570
|
-
var _React$useState7 = React.useState(
|
|
571
|
-
return 0;
|
|
572
|
-
})),
|
|
574
|
+
var _React$useState7 = React.useState(null),
|
|
573
575
|
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
574
|
-
|
|
575
|
-
|
|
576
|
+
gridRef = _React$useState8[0],
|
|
577
|
+
setGridRef = _React$useState8[1];
|
|
576
578
|
|
|
577
579
|
var _React$useState9 = React.useState(columns.map(function () {
|
|
578
580
|
return 0;
|
|
579
581
|
})),
|
|
580
582
|
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
581
|
-
|
|
582
|
-
|
|
583
|
+
measuredWidths = _React$useState10[0],
|
|
584
|
+
setMeasuredWidths = _React$useState10[1];
|
|
585
|
+
|
|
586
|
+
var _React$useState11 = React.useState(columns.map(function () {
|
|
587
|
+
return 0;
|
|
588
|
+
})),
|
|
589
|
+
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
590
|
+
resizeDeltas = _React$useState12[0],
|
|
591
|
+
setResizeDeltas = _React$useState12[1];
|
|
583
592
|
|
|
584
593
|
React.useEffect(function () {
|
|
585
594
|
setMeasuredWidths(function (prev) {
|
|
@@ -594,11 +603,11 @@ function DataTable(_ref2) {
|
|
|
594
603
|
});
|
|
595
604
|
}, [columns]);
|
|
596
605
|
var resetAfterColumnIndex = React.useCallback(function (columnIndex) {
|
|
597
|
-
if (gridRef
|
|
606
|
+
if (gridRef) {
|
|
598
607
|
// $FlowFixMe trigger react-window to layout the elements again
|
|
599
|
-
gridRef.
|
|
608
|
+
gridRef.resetAfterColumnIndex(columnIndex, true);
|
|
600
609
|
}
|
|
601
|
-
}, [gridRef
|
|
610
|
+
}, [gridRef]);
|
|
602
611
|
var handleWidthsChange = React.useCallback(function (nextWidths) {
|
|
603
612
|
setMeasuredWidths(nextWidths);
|
|
604
613
|
resetAfterColumnIndex(0);
|
|
@@ -611,20 +620,20 @@ function DataTable(_ref2) {
|
|
|
611
620
|
resetAfterColumnIndex(columnIndex);
|
|
612
621
|
}, [setResizeDeltas, resetAfterColumnIndex]);
|
|
613
622
|
|
|
614
|
-
var _React$
|
|
615
|
-
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
616
|
-
scrollLeft = _React$useState12[0],
|
|
617
|
-
setScrollLeft = _React$useState12[1];
|
|
618
|
-
|
|
619
|
-
var _React$useState13 = React.useState(false),
|
|
623
|
+
var _React$useState13 = React.useState(0),
|
|
620
624
|
_React$useState14 = _slicedToArray(_React$useState13, 2),
|
|
621
|
-
|
|
622
|
-
|
|
625
|
+
scrollLeft = _React$useState14[0],
|
|
626
|
+
setScrollLeft = _React$useState14[1];
|
|
623
627
|
|
|
624
628
|
var _React$useState15 = React.useState(false),
|
|
625
629
|
_React$useState16 = _slicedToArray(_React$useState15, 2),
|
|
626
|
-
|
|
627
|
-
|
|
630
|
+
isScrollingX = _React$useState16[0],
|
|
631
|
+
setIsScrollingX = _React$useState16[1];
|
|
632
|
+
|
|
633
|
+
var _React$useState17 = React.useState(false),
|
|
634
|
+
_React$useState18 = _slicedToArray(_React$useState17, 2),
|
|
635
|
+
recentlyScrolledX = _React$useState18[0],
|
|
636
|
+
setRecentlyScrolledX = _React$useState18[1];
|
|
628
637
|
|
|
629
638
|
React.useLayoutEffect(function () {
|
|
630
639
|
if (recentlyScrolledX !== isScrollingX) {
|
|
@@ -746,25 +755,18 @@ function DataTable(_ref2) {
|
|
|
746
755
|
return result;
|
|
747
756
|
}, [sortedIndices, filteredIndices, onIncludedRowsChange, allRows]);
|
|
748
757
|
|
|
749
|
-
var _React$
|
|
750
|
-
_React$
|
|
751
|
-
browserScrollbarWidth = _React$
|
|
752
|
-
setBrowserScrollbarWidth = _React$
|
|
758
|
+
var _React$useState19 = React.useState(0),
|
|
759
|
+
_React$useState20 = _slicedToArray(_React$useState19, 2),
|
|
760
|
+
browserScrollbarWidth = _React$useState20[0],
|
|
761
|
+
setBrowserScrollbarWidth = _React$useState20[1];
|
|
753
762
|
|
|
754
763
|
var normalizedWidths = React.useMemo(function () {
|
|
755
|
-
var sum = function sum(ns) {
|
|
756
|
-
return ns.reduce(function (s, n) {
|
|
757
|
-
return s + n;
|
|
758
|
-
}, 0);
|
|
759
|
-
};
|
|
760
|
-
|
|
761
764
|
var resizedWidths = measuredWidths.map(function (w, i) {
|
|
762
765
|
return Math.floor(w) + Math.floor(resizeDeltas[i]);
|
|
763
766
|
});
|
|
764
767
|
|
|
765
|
-
if (gridRef
|
|
766
|
-
|
|
767
|
-
var gridProps = gridRef.current.props;
|
|
768
|
+
if (gridRef) {
|
|
769
|
+
var gridProps = gridRef.props;
|
|
768
770
|
var isContentTallerThanContainer = false;
|
|
769
771
|
var visibleRowHeight = 0;
|
|
770
772
|
|
|
@@ -801,7 +803,7 @@ function DataTable(_ref2) {
|
|
|
801
803
|
}
|
|
802
804
|
|
|
803
805
|
return resizedWidths;
|
|
804
|
-
}, [measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
|
|
806
|
+
}, [gridRef, measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
|
|
805
807
|
var isSelectable = batchActions ? !!batchActions.length : false;
|
|
806
808
|
var isSelectedAll = React.useMemo(function () {
|
|
807
809
|
if (!selectedRowIds) {
|
|
@@ -845,23 +847,23 @@ function DataTable(_ref2) {
|
|
|
845
847
|
}
|
|
846
848
|
}, [onSort]);
|
|
847
849
|
|
|
848
|
-
var _React$useState19 = React.useState(-1),
|
|
849
|
-
_React$useState20 = _slicedToArray(_React$useState19, 2),
|
|
850
|
-
columnHighlightIndex = _React$useState20[0],
|
|
851
|
-
setColumnHighlightIndex = _React$useState20[1];
|
|
852
|
-
|
|
853
850
|
var _React$useState21 = React.useState(-1),
|
|
854
851
|
_React$useState22 = _slicedToArray(_React$useState21, 2),
|
|
855
|
-
|
|
856
|
-
|
|
852
|
+
columnHighlightIndex = _React$useState22[0],
|
|
853
|
+
setColumnHighlightIndex = _React$useState22[1];
|
|
854
|
+
|
|
855
|
+
var _React$useState23 = React.useState(-1),
|
|
856
|
+
_React$useState24 = _slicedToArray(_React$useState23, 2),
|
|
857
|
+
rowHighlightIndex = _React$useState24[0],
|
|
858
|
+
setRowHighlightIndex = _React$useState24[1];
|
|
857
859
|
|
|
858
860
|
function handleRowHighlightIndexChange(nextIndex) {
|
|
859
861
|
setRowHighlightIndex(nextIndex);
|
|
860
862
|
|
|
861
|
-
if (gridRef
|
|
863
|
+
if (gridRef) {
|
|
862
864
|
if (nextIndex >= 0) {
|
|
863
865
|
// $FlowFixMe - unable to get react-window types
|
|
864
|
-
gridRef.
|
|
866
|
+
gridRef.scrollToItem({
|
|
865
867
|
rowIndex: nextIndex
|
|
866
868
|
});
|
|
867
869
|
}
|
|
@@ -952,8 +954,9 @@ function DataTable(_ref2) {
|
|
|
952
954
|
}
|
|
953
955
|
}, /*#__PURE__*/React.createElement(_reactWindow.VariableSizeGrid // eslint-disable-next-line flowtype/no-weak-types
|
|
954
956
|
, {
|
|
955
|
-
ref:
|
|
957
|
+
ref: setGridRef,
|
|
956
958
|
overscanRowCount: 10,
|
|
959
|
+
overscanColumnCount: 5,
|
|
957
960
|
innerElementType: InnerTableElement,
|
|
958
961
|
columnCount: columns.length,
|
|
959
962
|
columnWidth: function columnWidth(columnIndex) {
|
|
@@ -87,6 +87,8 @@ type CellPlacementPropsT = {
|
|
|
87
87
|
},
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
+
const sum = ns => ns.reduce((s, n) => s + n, 0);
|
|
91
|
+
|
|
90
92
|
function CellPlacement({columnIndex, rowIndex, data, style}) {
|
|
91
93
|
const [css, theme] = useStyletron();
|
|
92
94
|
|
|
@@ -411,7 +413,7 @@ function Header(props: HeaderProps) {
|
|
|
411
413
|
);
|
|
412
414
|
}
|
|
413
415
|
|
|
414
|
-
function Headers(
|
|
416
|
+
function Headers() {
|
|
415
417
|
const [css, theme] = useStyletron();
|
|
416
418
|
const locale = React.useContext(LocaleContext);
|
|
417
419
|
const ctx = React.useContext(HeaderContext);
|
|
@@ -423,7 +425,7 @@ function Headers(props: {||}) {
|
|
|
423
425
|
position: 'sticky',
|
|
424
426
|
top: 0,
|
|
425
427
|
left: 0,
|
|
426
|
-
width: `${ctx.widths
|
|
428
|
+
width: `${sum(ctx.widths)}px`,
|
|
427
429
|
height: `${HEADER_ROW_HEIGHT}px`,
|
|
428
430
|
display: 'flex',
|
|
429
431
|
// this feels bad.. the absolutely positioned children elements
|
|
@@ -696,7 +698,10 @@ export function DataTable({
|
|
|
696
698
|
},
|
|
697
699
|
[rowHeight],
|
|
698
700
|
);
|
|
699
|
-
|
|
701
|
+
|
|
702
|
+
// We use state for our ref, to allow hooks to update when the ref changes.
|
|
703
|
+
// eslint-disable-next-line flowtype/no-weak-types
|
|
704
|
+
const [gridRef, setGridRef] = React.useState<?VariableSizeGrid<any>>(null);
|
|
700
705
|
const [measuredWidths, setMeasuredWidths] = React.useState(
|
|
701
706
|
columns.map(() => 0),
|
|
702
707
|
);
|
|
@@ -712,12 +717,12 @@ export function DataTable({
|
|
|
712
717
|
|
|
713
718
|
const resetAfterColumnIndex = React.useCallback(
|
|
714
719
|
columnIndex => {
|
|
715
|
-
if (gridRef
|
|
720
|
+
if (gridRef) {
|
|
716
721
|
// $FlowFixMe trigger react-window to layout the elements again
|
|
717
|
-
gridRef.
|
|
722
|
+
gridRef.resetAfterColumnIndex(columnIndex, true);
|
|
718
723
|
}
|
|
719
724
|
},
|
|
720
|
-
[gridRef
|
|
725
|
+
[gridRef],
|
|
721
726
|
);
|
|
722
727
|
const handleWidthsChange = React.useCallback(
|
|
723
728
|
nextWidths => {
|
|
@@ -843,13 +848,11 @@ export function DataTable({
|
|
|
843
848
|
|
|
844
849
|
const [browserScrollbarWidth, setBrowserScrollbarWidth] = React.useState(0);
|
|
845
850
|
const normalizedWidths = React.useMemo(() => {
|
|
846
|
-
const sum = ns => ns.reduce((s, n) => s + n, 0);
|
|
847
851
|
const resizedWidths = measuredWidths.map(
|
|
848
852
|
(w, i) => Math.floor(w) + Math.floor(resizeDeltas[i]),
|
|
849
853
|
);
|
|
850
|
-
if (gridRef
|
|
851
|
-
|
|
852
|
-
const gridProps = gridRef.current.props;
|
|
854
|
+
if (gridRef) {
|
|
855
|
+
const gridProps = gridRef.props;
|
|
853
856
|
|
|
854
857
|
let isContentTallerThanContainer = false;
|
|
855
858
|
let visibleRowHeight = 0;
|
|
@@ -886,6 +889,7 @@ export function DataTable({
|
|
|
886
889
|
}
|
|
887
890
|
return resizedWidths;
|
|
888
891
|
}, [
|
|
892
|
+
gridRef,
|
|
889
893
|
measuredWidths,
|
|
890
894
|
resizeDeltas,
|
|
891
895
|
browserScrollbarWidth,
|
|
@@ -948,10 +952,10 @@ export function DataTable({
|
|
|
948
952
|
|
|
949
953
|
function handleRowHighlightIndexChange(nextIndex) {
|
|
950
954
|
setRowHighlightIndex(nextIndex);
|
|
951
|
-
if (gridRef
|
|
955
|
+
if (gridRef) {
|
|
952
956
|
if (nextIndex >= 0) {
|
|
953
957
|
// $FlowFixMe - unable to get react-window types
|
|
954
|
-
gridRef.
|
|
958
|
+
gridRef.scrollToItem({rowIndex: nextIndex});
|
|
955
959
|
}
|
|
956
960
|
if (onRowHighlightChange) {
|
|
957
961
|
onRowHighlightChange(nextIndex, rows[nextIndex - 1]);
|
|
@@ -1051,8 +1055,9 @@ export function DataTable({
|
|
|
1051
1055
|
>
|
|
1052
1056
|
<VariableSizeGrid
|
|
1053
1057
|
// eslint-disable-next-line flowtype/no-weak-types
|
|
1054
|
-
ref={(
|
|
1058
|
+
ref={(setGridRef: any)}
|
|
1055
1059
|
overscanRowCount={10}
|
|
1060
|
+
overscanColumnCount={5}
|
|
1056
1061
|
innerElementType={InnerTableElement}
|
|
1057
1062
|
columnCount={columns.length}
|
|
1058
1063
|
columnWidth={columnIndex => normalizedWidths[columnIndex]}
|