baseui 10.7.2 → 10.9.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/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/combobox/combobox.js +6 -3
- package/combobox/combobox.js.flow +4 -2
- package/combobox/types.js.flow +2 -0
- package/data-table/column-categorical.js +1 -1
- package/data-table/column-categorical.js.flow +2 -2
- package/data-table/column-numerical.js +307 -355
- package/data-table/column-numerical.js.flow +273 -287
- package/data-table/constants.js +17 -11
- package/data-table/constants.js.flow +11 -8
- package/data-table/data-table.js +53 -50
- package/data-table/data-table.js.flow +18 -13
- package/data-table/filter-shell.js +27 -4
- package/data-table/filter-shell.js.flow +33 -9
- package/data-table/locale.js +4 -2
- package/data-table/locale.js.flow +6 -2
- package/data-table/measure-column-widths.js +83 -121
- package/data-table/measure-column-widths.js.flow +87 -109
- package/datepicker/styled-components.js +1 -1
- package/datepicker/styled-components.js.flow +4 -1
- 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/combobox/combobox.js +6 -3
- package/es/data-table/column-categorical.js +2 -2
- package/es/data-table/column-numerical.js +245 -317
- package/es/data-table/constants.js +12 -8
- package/es/data-table/data-table.js +18 -16
- package/es/data-table/filter-shell.js +26 -4
- package/es/data-table/locale.js +4 -2
- package/es/data-table/measure-column-widths.js +75 -86
- package/es/datepicker/styled-components.js +1 -1
- package/es/drawer/drawer.js +3 -1
- 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/menu/maybe-child-menu.js +0 -2
- package/es/menu/nested-menus.js +49 -3
- package/es/menu/stateful-container.js +13 -12
- package/es/modal/modal.js +3 -1
- package/es/popover/popover.js +7 -3
- package/es/progress-bar/index.js +1 -1
- package/es/progress-bar/progressbar.js +25 -10
- package/es/progress-bar/styled-components.js +9 -5
- package/es/select/select-component.js +2 -10
- package/es/spinner/styled-components.js +34 -16
- package/es/table/filter.js +3 -1
- package/es/themes/dark-theme/color-component-tokens.js +19 -10
- package/es/themes/light-theme/color-component-tokens.js +19 -10
- 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/toast/styled-components.js +18 -7
- package/esm/a11y/a11y.js +3 -3
- package/esm/button/styled-components.js +47 -18
- package/esm/combobox/combobox.js +6 -3
- package/esm/data-table/column-categorical.js +2 -2
- package/esm/data-table/column-numerical.js +304 -353
- package/esm/data-table/constants.js +12 -8
- package/esm/data-table/data-table.js +53 -50
- package/esm/data-table/filter-shell.js +26 -4
- package/esm/data-table/locale.js +4 -2
- package/esm/data-table/measure-column-widths.js +83 -121
- package/esm/datepicker/styled-components.js +1 -1
- package/esm/drawer/drawer.js +3 -1
- 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/menu/maybe-child-menu.js +0 -2
- package/esm/menu/nested-menus.js +66 -5
- package/esm/menu/stateful-container.js +15 -13
- package/esm/modal/modal.js +3 -1
- package/esm/popover/popover.js +7 -3
- package/esm/progress-bar/index.js +1 -1
- package/esm/progress-bar/progressbar.js +32 -10
- package/esm/progress-bar/styled-components.js +9 -4
- package/esm/select/select-component.js +2 -11
- package/esm/spinner/styled-components.js +35 -16
- package/esm/table/filter.js +3 -1
- package/esm/themes/dark-theme/color-component-tokens.js +19 -10
- package/esm/themes/light-theme/color-component-tokens.js +19 -10
- 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/toast/styled-components.js +13 -5
- 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/menu/index.d.ts +9 -4
- package/menu/maybe-child-menu.js +0 -2
- package/menu/maybe-child-menu.js.flow +0 -2
- package/menu/nested-menus.js +66 -5
- package/menu/nested-menus.js.flow +50 -5
- package/menu/stateful-container.js +15 -13
- package/menu/stateful-container.js.flow +19 -13
- package/menu/types.js.flow +7 -1
- package/modal/modal.js +3 -1
- package/modal/modal.js.flow +2 -0
- package/package.json +5 -4
- package/popover/popover.js +7 -3
- package/popover/popover.js.flow +23 -17
- 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 +32 -10
- package/progress-bar/progressbar.js.flow +35 -9
- 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/select/select-component.js +2 -11
- package/select/select-component.js.flow +5 -7
- package/spinner/styled-components.js +35 -16
- package/spinner/styled-components.js.flow +37 -19
- package/spinner/types.js.flow +10 -0
- 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 +19 -10
- package/themes/dark-theme/color-component-tokens.js.flow +19 -10
- package/themes/light-theme/color-component-tokens.js +19 -10
- package/themes/light-theme/color-component-tokens.js.flow +19 -10
- package/themes/types.js.flow +9 -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/toast/styled-components.js +13 -5
- package/toast/styled-components.js.flow +17 -7
|
@@ -19,13 +19,6 @@ export const NUMERICAL_FORMATS = Object.freeze({
|
|
|
19
19
|
ACCOUNTING: 'ACCOUNTING',
|
|
20
20
|
PERCENTAGE: 'PERCENTAGE'
|
|
21
21
|
});
|
|
22
|
-
export const NUMERICAL_OPERATIONS = Object.freeze({
|
|
23
|
-
EQ: 'EQ',
|
|
24
|
-
GT: 'GT',
|
|
25
|
-
GTE: 'GTE',
|
|
26
|
-
LT: 'LT',
|
|
27
|
-
LTE: 'LTE'
|
|
28
|
-
});
|
|
29
22
|
export const DATETIME_OPERATIONS = Object.freeze({
|
|
30
23
|
RANGE_DATETIME: 'RANGE_DATETIME',
|
|
31
24
|
RANGE_DATE: 'RANGE_DATE',
|
|
@@ -39,4 +32,15 @@ export const DATETIME_OPERATIONS = Object.freeze({
|
|
|
39
32
|
export const SORT_DIRECTIONS = Object.freeze({
|
|
40
33
|
ASC: 'ASC',
|
|
41
34
|
DESC: 'DESC'
|
|
42
|
-
});
|
|
35
|
+
}); // If modifying this, take a look at the histogram and adjust. see HISTOGRAM_SIZE
|
|
36
|
+
|
|
37
|
+
export const FILTER_SHELL_WIDTH = '320px'; // Depends on FILTER_SHELL_WIDTH
|
|
38
|
+
|
|
39
|
+
export const HISTOGRAM_SIZE = {
|
|
40
|
+
width: 308,
|
|
41
|
+
height: 120
|
|
42
|
+
}; // Arguably visually appealing within the given width.
|
|
43
|
+
// Smaller and we don't have enough detail per bar.
|
|
44
|
+
// Larger and the bars are too granular and don't align well with the slider steps
|
|
45
|
+
|
|
46
|
+
export const MAX_BIN_COUNT = 50;
|
|
@@ -17,6 +17,8 @@ import { LocaleContext } from '../locale/index.js'; // consider pulling this out
|
|
|
17
17
|
|
|
18
18
|
const HEADER_ROW_HEIGHT = 48;
|
|
19
19
|
|
|
20
|
+
const sum = ns => ns.reduce((s, n) => s + n, 0);
|
|
21
|
+
|
|
20
22
|
function CellPlacement({
|
|
21
23
|
columnIndex,
|
|
22
24
|
rowIndex,
|
|
@@ -255,7 +257,7 @@ function Header(props) {
|
|
|
255
257
|
}))));
|
|
256
258
|
}
|
|
257
259
|
|
|
258
|
-
function Headers(
|
|
260
|
+
function Headers() {
|
|
259
261
|
const [css, theme] = useStyletron();
|
|
260
262
|
const locale = React.useContext(LocaleContext);
|
|
261
263
|
const ctx = React.useContext(HeaderContext);
|
|
@@ -265,7 +267,7 @@ function Headers(props) {
|
|
|
265
267
|
position: 'sticky',
|
|
266
268
|
top: 0,
|
|
267
269
|
left: 0,
|
|
268
|
-
width: `${ctx.widths
|
|
270
|
+
width: `${sum(ctx.widths)}px`,
|
|
269
271
|
height: `${HEADER_ROW_HEIGHT}px`,
|
|
270
272
|
display: 'flex',
|
|
271
273
|
// this feels bad.. the absolutely positioned children elements
|
|
@@ -467,8 +469,10 @@ export function DataTable({
|
|
|
467
469
|
}
|
|
468
470
|
|
|
469
471
|
return rowHeight;
|
|
470
|
-
}, [rowHeight]);
|
|
471
|
-
|
|
472
|
+
}, [rowHeight]); // We use state for our ref, to allow hooks to update when the ref changes.
|
|
473
|
+
// eslint-disable-next-line flowtype/no-weak-types
|
|
474
|
+
|
|
475
|
+
const [gridRef, setGridRef] = React.useState(null);
|
|
472
476
|
const [measuredWidths, setMeasuredWidths] = React.useState(columns.map(() => 0));
|
|
473
477
|
const [resizeDeltas, setResizeDeltas] = React.useState(columns.map(() => 0));
|
|
474
478
|
React.useEffect(() => {
|
|
@@ -480,11 +484,11 @@ export function DataTable({
|
|
|
480
484
|
});
|
|
481
485
|
}, [columns]);
|
|
482
486
|
const resetAfterColumnIndex = React.useCallback(columnIndex => {
|
|
483
|
-
if (gridRef
|
|
487
|
+
if (gridRef) {
|
|
484
488
|
// $FlowFixMe trigger react-window to layout the elements again
|
|
485
|
-
gridRef.
|
|
489
|
+
gridRef.resetAfterColumnIndex(columnIndex, true);
|
|
486
490
|
}
|
|
487
|
-
}, [gridRef
|
|
491
|
+
}, [gridRef]);
|
|
488
492
|
const handleWidthsChange = React.useCallback(nextWidths => {
|
|
489
493
|
setMeasuredWidths(nextWidths);
|
|
490
494
|
resetAfterColumnIndex(0);
|
|
@@ -594,13 +598,10 @@ export function DataTable({
|
|
|
594
598
|
}, [sortedIndices, filteredIndices, onIncludedRowsChange, allRows]);
|
|
595
599
|
const [browserScrollbarWidth, setBrowserScrollbarWidth] = React.useState(0);
|
|
596
600
|
const normalizedWidths = React.useMemo(() => {
|
|
597
|
-
const sum = ns => ns.reduce((s, n) => s + n, 0);
|
|
598
|
-
|
|
599
601
|
const resizedWidths = measuredWidths.map((w, i) => Math.floor(w) + Math.floor(resizeDeltas[i]));
|
|
600
602
|
|
|
601
|
-
if (gridRef
|
|
602
|
-
|
|
603
|
-
const gridProps = gridRef.current.props;
|
|
603
|
+
if (gridRef) {
|
|
604
|
+
const gridProps = gridRef.props;
|
|
604
605
|
let isContentTallerThanContainer = false;
|
|
605
606
|
let visibleRowHeight = 0;
|
|
606
607
|
|
|
@@ -635,7 +636,7 @@ export function DataTable({
|
|
|
635
636
|
}
|
|
636
637
|
|
|
637
638
|
return resizedWidths;
|
|
638
|
-
}, [measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
|
|
639
|
+
}, [gridRef, measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
|
|
639
640
|
const isSelectable = batchActions ? !!batchActions.length : false;
|
|
640
641
|
const isSelectedAll = React.useMemo(() => {
|
|
641
642
|
if (!selectedRowIds) {
|
|
@@ -684,10 +685,10 @@ export function DataTable({
|
|
|
684
685
|
function handleRowHighlightIndexChange(nextIndex) {
|
|
685
686
|
setRowHighlightIndex(nextIndex);
|
|
686
687
|
|
|
687
|
-
if (gridRef
|
|
688
|
+
if (gridRef) {
|
|
688
689
|
if (nextIndex >= 0) {
|
|
689
690
|
// $FlowFixMe - unable to get react-window types
|
|
690
|
-
gridRef.
|
|
691
|
+
gridRef.scrollToItem({
|
|
691
692
|
rowIndex: nextIndex
|
|
692
693
|
});
|
|
693
694
|
}
|
|
@@ -776,8 +777,9 @@ export function DataTable({
|
|
|
776
777
|
}
|
|
777
778
|
}, /*#__PURE__*/React.createElement(VariableSizeGrid // eslint-disable-next-line flowtype/no-weak-types
|
|
778
779
|
, {
|
|
779
|
-
ref:
|
|
780
|
+
ref: setGridRef,
|
|
780
781
|
overscanRowCount: 10,
|
|
782
|
+
overscanColumnCount: 5,
|
|
781
783
|
innerElementType: InnerTableElement,
|
|
782
784
|
columnCount: columns.length,
|
|
783
785
|
columnWidth: columnIndex => normalizedWidths[columnIndex],
|
|
@@ -9,10 +9,26 @@ import { Button, SIZE as BUTTON_SIZE } from '../button/index.js';
|
|
|
9
9
|
import { Checkbox, STYLE_TYPE } from '../checkbox/index.js';
|
|
10
10
|
import { useStyletron } from '../styles/index.js';
|
|
11
11
|
import { LocaleContext } from '../locale/index.js';
|
|
12
|
+
import { FILTER_SHELL_WIDTH } from './constants.js';
|
|
12
13
|
|
|
13
14
|
function FilterShell(props) {
|
|
14
15
|
const [css, theme] = useStyletron();
|
|
15
16
|
const locale = React.useContext(LocaleContext);
|
|
17
|
+
let excludeText;
|
|
18
|
+
|
|
19
|
+
switch (props.excludeKind) {
|
|
20
|
+
case 'value':
|
|
21
|
+
excludeText = locale.datatable.filterExcludeValue;
|
|
22
|
+
break;
|
|
23
|
+
|
|
24
|
+
case 'range':
|
|
25
|
+
excludeText = locale.datatable.filterExcludeRange;
|
|
26
|
+
break;
|
|
27
|
+
|
|
28
|
+
default:
|
|
29
|
+
excludeText = locale.datatable.filterExclude;
|
|
30
|
+
}
|
|
31
|
+
|
|
16
32
|
return /*#__PURE__*/React.createElement("form", {
|
|
17
33
|
className: css({
|
|
18
34
|
backgroundColor: theme.colors.backgroundPrimary,
|
|
@@ -20,7 +36,7 @@ function FilterShell(props) {
|
|
|
20
36
|
paddingRight: theme.sizing.scale600,
|
|
21
37
|
paddingBottom: theme.sizing.scale600,
|
|
22
38
|
paddingLeft: theme.sizing.scale600,
|
|
23
|
-
width:
|
|
39
|
+
width: FILTER_SHELL_WIDTH
|
|
24
40
|
}),
|
|
25
41
|
onSubmit: event => {
|
|
26
42
|
event.preventDefault();
|
|
@@ -28,17 +44,23 @@ function FilterShell(props) {
|
|
|
28
44
|
}
|
|
29
45
|
}, props.children, /*#__PURE__*/React.createElement("div", {
|
|
30
46
|
className: css({
|
|
31
|
-
alignItems: 'center',
|
|
32
47
|
display: 'flex',
|
|
48
|
+
flexDirection: 'column',
|
|
33
49
|
justifyContent: 'space-between',
|
|
34
|
-
|
|
50
|
+
alignItems: 'flex-end',
|
|
51
|
+
marginTop: theme.sizing.scale600,
|
|
52
|
+
gap: theme.sizing.scale200
|
|
53
|
+
})
|
|
54
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
55
|
+
className: css({
|
|
56
|
+
alignSelf: 'flex-start'
|
|
35
57
|
})
|
|
36
58
|
}, /*#__PURE__*/React.createElement(Checkbox, {
|
|
37
59
|
checked: props.exclude,
|
|
38
60
|
onChange: props.onExcludeChange,
|
|
39
61
|
checkmarkType: STYLE_TYPE.toggle_round,
|
|
40
62
|
labelPlacement: "right"
|
|
41
|
-
},
|
|
63
|
+
}, excludeText)), /*#__PURE__*/React.createElement(Button, {
|
|
42
64
|
size: BUTTON_SIZE.compact,
|
|
43
65
|
type: "submit"
|
|
44
66
|
}, locale.datatable.filterApply)));
|
package/es/data-table/locale.js
CHANGED
|
@@ -6,18 +6,20 @@ LICENSE file in the root directory of this source tree.
|
|
|
6
6
|
*/
|
|
7
7
|
const locale = {
|
|
8
8
|
emptyState: 'No rows match the filter criteria defined. Please remove one or more filters to view more data.',
|
|
9
|
-
loadingState: 'Loading
|
|
9
|
+
loadingState: 'Loading rows.',
|
|
10
10
|
searchAriaLabel: 'Search by text',
|
|
11
11
|
filterAdd: 'Add Filter',
|
|
12
12
|
filterExclude: 'Exclude',
|
|
13
13
|
filterApply: 'Apply',
|
|
14
|
+
filterExcludeRange: 'Exclude range',
|
|
15
|
+
filterExcludeValue: 'Exclude value',
|
|
14
16
|
filterAppliedTo: 'filter applied to',
|
|
15
17
|
optionsLabel: 'Select column to filter by',
|
|
16
18
|
optionsSearch: 'Search for a column to filter by...',
|
|
17
19
|
optionsEmpty: 'No columns available.',
|
|
18
20
|
categoricalFilterSelectAll: 'Select All',
|
|
19
21
|
categoricalFilterSelectClear: 'Clear',
|
|
20
|
-
categoricalFilterEmpty: 'No
|
|
22
|
+
categoricalFilterEmpty: 'No categories found',
|
|
21
23
|
datetimeFilterRange: 'Range',
|
|
22
24
|
datetimeFilterRangeDatetime: 'Date, Time',
|
|
23
25
|
datetimeFilterRangeDate: 'Date',
|
|
@@ -7,40 +7,59 @@ LICENSE file in the root directory of this source tree.
|
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import { useStyletron } from '../styles/index.js';
|
|
9
9
|
import HeaderCell from './header-cell.js';
|
|
10
|
+
import { useRef } from 'react'; // Measures the column header + sampled data
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
function MeasureColumn({
|
|
13
|
+
sampleIndexes,
|
|
14
|
+
column,
|
|
15
|
+
columnIndex,
|
|
16
|
+
rows,
|
|
17
|
+
isSelectable,
|
|
18
|
+
onLayout
|
|
19
|
+
}) {
|
|
20
|
+
const [css] = useStyletron();
|
|
21
|
+
const ref = useRef();
|
|
18
22
|
React.useEffect(() => {
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
window.requestAnimationFrame(() => {
|
|
22
|
-
setDimensions(node.getBoundingClientRect());
|
|
23
|
-
});
|
|
24
|
-
}
|
|
23
|
+
if (ref.current) {
|
|
24
|
+
onLayout(columnIndex, ref.current.getBoundingClientRect());
|
|
25
25
|
}
|
|
26
|
-
}, [
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
}, []);
|
|
27
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
28
|
+
ref: ref,
|
|
29
|
+
className: css({
|
|
30
|
+
display: 'flex',
|
|
31
|
+
flexDirection: 'column',
|
|
32
|
+
width: 'fit-content'
|
|
33
|
+
})
|
|
34
|
+
}, /*#__PURE__*/React.createElement(HeaderCell, {
|
|
35
|
+
index: columnIndex,
|
|
36
|
+
isHovered: true,
|
|
37
|
+
isMeasured: true,
|
|
38
|
+
isSelectedAll: false,
|
|
39
|
+
isSelectedIndeterminate: false,
|
|
40
|
+
onMouseEnter: () => {},
|
|
41
|
+
onMouseLeave: () => {},
|
|
42
|
+
onSelectAll: () => {},
|
|
43
|
+
onSelectNone: () => {},
|
|
44
|
+
onSort: i => {},
|
|
45
|
+
sortable: column.sortable,
|
|
46
|
+
sortDirection: null,
|
|
47
|
+
title: column.title,
|
|
48
|
+
isSelectable: isSelectable
|
|
49
|
+
}), sampleIndexes.map((rowIndex, i) => {
|
|
50
|
+
const Cell = column.renderCell;
|
|
51
|
+
return /*#__PURE__*/React.createElement(Cell, {
|
|
52
|
+
key: `measure-${i}`,
|
|
53
|
+
value: column.mapDataToValue(rows[rowIndex].data),
|
|
54
|
+
isSelectable: isSelectable,
|
|
55
|
+
isMeasured: true,
|
|
56
|
+
sortable: column.sortable,
|
|
57
|
+
x: 0,
|
|
58
|
+
y: rowIndex
|
|
59
|
+
});
|
|
60
|
+
}));
|
|
41
61
|
}
|
|
42
62
|
|
|
43
|
-
// sample size could likely be generated based on row count, to have higher confidence
|
|
44
63
|
const MAX_SAMPLE_SIZE = 50;
|
|
45
64
|
|
|
46
65
|
function generateSampleIndices(inputMin, inputMax, maxSamples) {
|
|
@@ -77,43 +96,35 @@ export default function MeasureColumnWidths({
|
|
|
77
96
|
onWidthsChange
|
|
78
97
|
}) {
|
|
79
98
|
const [css] = useStyletron();
|
|
80
|
-
const
|
|
81
|
-
|
|
99
|
+
const widthMap = React.useMemo(() => {
|
|
100
|
+
return new Map();
|
|
101
|
+
}, []);
|
|
82
102
|
const sampleSize = rows.length < MAX_SAMPLE_SIZE ? rows.length : MAX_SAMPLE_SIZE;
|
|
83
103
|
const finishedMeasurementCount = (sampleSize + 1) * columns.length;
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
dimensionsCache.current = widths;
|
|
87
|
-
const indices = generateSampleIndices(0, rows.length - 1, sampleSize);
|
|
88
|
-
return columns.map(() => indices);
|
|
104
|
+
const sampleIndexes = React.useMemo(() => {
|
|
105
|
+
return generateSampleIndices(0, rows.length - 1, sampleSize);
|
|
89
106
|
}, [columns, rows, widths, sampleSize]);
|
|
90
|
-
const handleDimensionsChange = React.useCallback((columnIndex,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (columns[columnIndex] === undefined || dimensionsCache.current[columnIndex] === undefined) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
measurementCount.current += 1;
|
|
98
|
-
const nextWidth = Math.min(Math.max(columns[columnIndex].minWidth || 0, dimensionsCache.current[columnIndex], dimensions.width + 1), columns[columnIndex].maxWidth || Infinity);
|
|
107
|
+
const handleDimensionsChange = React.useCallback((columnIndex, dimensions) => {
|
|
108
|
+
const nextWidth = Math.min(Math.max(columns[columnIndex].minWidth || 0, widthMap.get(columnIndex) || 0, dimensions.width + 1), columns[columnIndex].maxWidth || Infinity);
|
|
99
109
|
|
|
100
|
-
if (nextWidth !==
|
|
101
|
-
|
|
102
|
-
nextWidths[columnIndex] = nextWidth;
|
|
103
|
-
dimensionsCache.current = nextWidths;
|
|
110
|
+
if (nextWidth !== widthMap.get(columnIndex)) {
|
|
111
|
+
widthMap.set(columnIndex, nextWidth);
|
|
104
112
|
}
|
|
105
113
|
|
|
106
|
-
if (
|
|
107
|
-
|
|
114
|
+
if ( // Refresh at 100% of done
|
|
115
|
+
widthMap.size === columns.length || // ...50%
|
|
116
|
+
widthMap.size === Math.floor(columns.length / 2) || // ...25%
|
|
117
|
+
widthMap.size === Math.floor(columns.length / 4)) {
|
|
118
|
+
onWidthsChange(Array.from(widthMap.values()));
|
|
108
119
|
}
|
|
109
120
|
}, [columns, finishedMeasurementCount, onWidthsChange]);
|
|
110
121
|
const hiddenStyle = css({
|
|
111
122
|
position: 'absolute',
|
|
112
123
|
overflow: 'hidden',
|
|
113
124
|
height: 0
|
|
114
|
-
});
|
|
125
|
+
}); // Remove the measurement nodes after we are done updating our column width
|
|
115
126
|
|
|
116
|
-
if (
|
|
127
|
+
if (widthMap.size === columns.length) {
|
|
117
128
|
return null;
|
|
118
129
|
}
|
|
119
130
|
|
|
@@ -124,38 +135,16 @@ export default function MeasureColumnWidths({
|
|
|
124
135
|
className: hiddenStyle,
|
|
125
136
|
"aria-hidden": true,
|
|
126
137
|
role: "none"
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
})
|
|
139
|
-
}));
|
|
140
|
-
}), columns.map((column, columnIndex) => /*#__PURE__*/React.createElement(ElementMeasurer, {
|
|
141
|
-
key: `measure-column-${columnIndex}`,
|
|
142
|
-
onDimensionsChange: dimensions => handleDimensionsChange(columnIndex, -1, dimensions),
|
|
143
|
-
item: /*#__PURE__*/React.createElement(HeaderCell, {
|
|
144
|
-
index: columnIndex,
|
|
145
|
-
isHovered: true,
|
|
146
|
-
isMeasured: true,
|
|
147
|
-
isSelectable: isSelectable && columnIndex === 0,
|
|
148
|
-
isSelectedAll: false,
|
|
149
|
-
isSelectedIndeterminate: false,
|
|
150
|
-
onMouseEnter: () => {},
|
|
151
|
-
onMouseLeave: () => {},
|
|
152
|
-
onSelectAll: () => {},
|
|
153
|
-
onSelectNone: () => {},
|
|
154
|
-
onSort: i => {},
|
|
155
|
-
sortable: column.sortable,
|
|
156
|
-
sortDirection: null,
|
|
157
|
-
title: column.title
|
|
158
|
-
})
|
|
159
|
-
})))
|
|
138
|
+
}, columns.map((column, i) => {
|
|
139
|
+
return /*#__PURE__*/React.createElement(MeasureColumn, {
|
|
140
|
+
key: column.title + i,
|
|
141
|
+
column: column,
|
|
142
|
+
rows: rows,
|
|
143
|
+
isSelectable: isSelectable,
|
|
144
|
+
onLayout: handleDimensionsChange,
|
|
145
|
+
columnIndex: i,
|
|
146
|
+
sampleIndexes: sampleIndexes
|
|
147
|
+
});
|
|
148
|
+
}))
|
|
160
149
|
);
|
|
161
150
|
}
|
|
@@ -503,7 +503,7 @@ export const StyledDay = styled('div', props => {
|
|
|
503
503
|
content: '""',
|
|
504
504
|
boxSizing: 'border-box',
|
|
505
505
|
display: 'inline-block',
|
|
506
|
-
boxShadow: $isFocusVisible ? `0 0 0 3px ${colors.accent}` : 'none',
|
|
506
|
+
boxShadow: $isFocusVisible && (!$outsideMonth || $peekNextMonth) ? `0 0 0 3px ${colors.accent}` : 'none',
|
|
507
507
|
backgroundColor: $selected ? colors.calendarDayBackgroundSelectedHighlighted : $pseudoSelected && $isHighlighted ? colors.calendarDayBackgroundPseudoSelectedHighlighted : colors.calendarBackground,
|
|
508
508
|
height: $hasDateLabel ? '100%' : $density === DENSITY.high ? '42px' : '50px',
|
|
509
509
|
width: '100%',
|
package/es/drawer/drawer.js
CHANGED
|
@@ -250,7 +250,9 @@ class Drawer extends React.Component {
|
|
|
250
250
|
const [Close, closeProps] = getOverrides(CloseOverride, StyledClose);
|
|
251
251
|
const sharedProps = this.getSharedProps();
|
|
252
252
|
return /*#__PURE__*/React.createElement(LocaleContext.Consumer, null, locale => {
|
|
253
|
-
return /*#__PURE__*/React.createElement(FocusLock
|
|
253
|
+
return /*#__PURE__*/React.createElement(FocusLock // Allow focus to escape when UI is within an iframe
|
|
254
|
+
, {
|
|
255
|
+
crossFrame: false,
|
|
254
256
|
returnFocus: true,
|
|
255
257
|
autoFocus: autoFocus,
|
|
256
258
|
noFocusGuards: true
|
package/es/index.js
CHANGED
|
@@ -8,4 +8,4 @@ export { styled, withStyle, withWrapper, useStyletron, createThemedStyled, creat
|
|
|
8
8
|
export { createTheme, createDarkTheme, createLightTheme, lightThemePrimitives, darkThemePrimitives, darkThemeOverrides, DarkTheme, DarkThemeMove, LightTheme, LightThemeMove } from './themes/index.js';
|
|
9
9
|
export { default as LocaleProvider } from './locale/index.js';
|
|
10
10
|
export { default as BaseProvider } from './helpers/base-provider.js';
|
|
11
|
-
export { mergeOverrides } from './helpers/overrides.js';
|
|
11
|
+
export { getOverrides, mergeOverrides } from './helpers/overrides.js';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Copyright (c) Uber Technologies, Inc.
|
|
5
|
+
|
|
6
|
+
This source code is licensed under the MIT license found in the
|
|
7
|
+
LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { getOverrides } from '../helpers/overrides.js';
|
|
11
|
+
import { StyledBadgeEnhancerRoot } from './styled-components.js';
|
|
12
|
+
import { PINHEAD_TYPES, BADGE_ENHANCER_SIZES, BADGE_ENHANCER_POSITIONS, BADGE_ENHANCER_CONTENT_SIZE } from './constants.js';
|
|
13
|
+
|
|
14
|
+
const BadgeEnhancer = ({
|
|
15
|
+
pinHeadSize,
|
|
16
|
+
markerType,
|
|
17
|
+
badgeEnhancerSize = BADGE_ENHANCER_SIZES.none,
|
|
18
|
+
badgeEnhancerContent: BadgeEnhancerContent,
|
|
19
|
+
overrides = {}
|
|
20
|
+
}) => {
|
|
21
|
+
if (badgeEnhancerSize === null || badgeEnhancerSize == BADGE_ENHANCER_SIZES.none) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (badgeEnhancerSize !== BADGE_ENHANCER_SIZES.xSmall && !BadgeEnhancerContent) {
|
|
26
|
+
if (process.env.NODE_ENV !== "production") {
|
|
27
|
+
console.warn(`Badges (except for size ${BADGE_ENHANCER_SIZES.xSmall}) must contain content`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (markerType === PINHEAD_TYPES.floating) {
|
|
34
|
+
if (process.env.NODE_ENV !== "production") {
|
|
35
|
+
console.warn(`Badges can only be rendered on fixed markers`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const positions = BADGE_ENHANCER_POSITIONS[pinHeadSize];
|
|
42
|
+
const position = positions ? positions[badgeEnhancerSize] : null;
|
|
43
|
+
|
|
44
|
+
if (!position) {
|
|
45
|
+
if (process.env.NODE_ENV !== "production") {
|
|
46
|
+
console.warn(`Badge size ${badgeEnhancerSize} cannot be rendered with pinhead size ${pinHeadSize}`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const [BadgeEnhancerRoot, badgeEnhancerRootProps] = getOverrides(overrides.BadgeEnhancer, StyledBadgeEnhancerRoot);
|
|
53
|
+
return /*#__PURE__*/React.createElement(BadgeEnhancerRoot, _extends({
|
|
54
|
+
$size: badgeEnhancerSize,
|
|
55
|
+
$position: position
|
|
56
|
+
}, badgeEnhancerRootProps), BadgeEnhancerContent && badgeEnhancerSize !== BADGE_ENHANCER_SIZES.xSmall && /*#__PURE__*/React.createElement(BadgeEnhancerContent, {
|
|
57
|
+
size: BADGE_ENHANCER_CONTENT_SIZE[badgeEnhancerSize]
|
|
58
|
+
}));
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default BadgeEnhancer;
|
|
@@ -17,6 +17,8 @@ export const NEEDLE_HEIGHTS = Object.freeze({
|
|
|
17
17
|
[NEEDLE_SIZES.tall]: 20
|
|
18
18
|
});
|
|
19
19
|
export const PINHEAD_SIZES_SHAPES = Object.freeze({
|
|
20
|
+
xxSmallCircle: 'xx-small-circle',
|
|
21
|
+
xxSmallSquare: 'xx-small-square',
|
|
20
22
|
xSmallCircle: 'x-small-circle',
|
|
21
23
|
xSmallSquare: 'x-small-square',
|
|
22
24
|
small: 'small',
|
|
@@ -27,7 +29,13 @@ export const xSmallPinheadDimension = {
|
|
|
27
29
|
height: 16,
|
|
28
30
|
icon: 4
|
|
29
31
|
};
|
|
32
|
+
export const xxSmallPinheadDimension = {
|
|
33
|
+
height: 8,
|
|
34
|
+
icon: 4
|
|
35
|
+
};
|
|
30
36
|
export const PINHEAD_DIMENSIONS = Object.freeze({
|
|
37
|
+
[PINHEAD_SIZES_SHAPES.xxSmallSquare]: xxSmallPinheadDimension,
|
|
38
|
+
[PINHEAD_SIZES_SHAPES.xxSmallCircle]: xxSmallPinheadDimension,
|
|
31
39
|
[PINHEAD_SIZES_SHAPES.xSmallSquare]: xSmallPinheadDimension,
|
|
32
40
|
[PINHEAD_SIZES_SHAPES.xSmallCircle]: xSmallPinheadDimension,
|
|
33
41
|
[PINHEAD_SIZES_SHAPES.small]: {
|
|
@@ -61,9 +69,145 @@ export const FLOATING_MARKER_ANCHOR_POSITIONS = Object.freeze({
|
|
|
61
69
|
});
|
|
62
70
|
export const FLOATING_MARKER_ANCHOR_TYPES = Object.freeze({
|
|
63
71
|
circle: 'circle',
|
|
64
|
-
square: 'square'
|
|
72
|
+
square: 'square',
|
|
73
|
+
xxSmallCircle: 'xx-small-circle',
|
|
74
|
+
xxSmallSquare: 'xx-small-square'
|
|
65
75
|
});
|
|
66
76
|
export const dragShadowHeight = 4;
|
|
67
77
|
export const dragShadowMarginTop = 6;
|
|
68
78
|
export const dragShadowWidth = 6;
|
|
69
|
-
export const anchorSize = 16;
|
|
79
|
+
export const anchorSize = 16;
|
|
80
|
+
const labelSmall = 'LabelSmall';
|
|
81
|
+
export const LABEL_SIZES = {
|
|
82
|
+
[PINHEAD_SIZES_SHAPES.xxSmallCircle]: labelSmall,
|
|
83
|
+
[PINHEAD_SIZES_SHAPES.xxSmallSquare]: labelSmall,
|
|
84
|
+
[PINHEAD_SIZES_SHAPES.xSmallCircle]: labelSmall,
|
|
85
|
+
[PINHEAD_SIZES_SHAPES.xSmallSquare]: labelSmall,
|
|
86
|
+
[PINHEAD_SIZES_SHAPES.small]: labelSmall,
|
|
87
|
+
[PINHEAD_SIZES_SHAPES.medium]: 'LabelMedium',
|
|
88
|
+
[PINHEAD_SIZES_SHAPES.large]: 'LabelLarge'
|
|
89
|
+
};
|
|
90
|
+
export const LABEL_ENHANCER_POSITIONS = Object.freeze({
|
|
91
|
+
none: 'none',
|
|
92
|
+
top: 'top',
|
|
93
|
+
left: 'left',
|
|
94
|
+
right: 'right',
|
|
95
|
+
bottom: 'bottom'
|
|
96
|
+
});
|
|
97
|
+
export const BADGE_ENHANCER_SIZES = Object.freeze({
|
|
98
|
+
none: 'none',
|
|
99
|
+
xSmall: 'x-small',
|
|
100
|
+
small: 'small',
|
|
101
|
+
mediumText: 'medium-text',
|
|
102
|
+
mediumIcon: 'medium-icon'
|
|
103
|
+
});
|
|
104
|
+
const xSmallPinheadBadge = {
|
|
105
|
+
[BADGE_ENHANCER_SIZES.none]: null,
|
|
106
|
+
[BADGE_ENHANCER_SIZES.xSmall]: {
|
|
107
|
+
x: -5,
|
|
108
|
+
y: -3
|
|
109
|
+
},
|
|
110
|
+
[BADGE_ENHANCER_SIZES.small]: null,
|
|
111
|
+
[BADGE_ENHANCER_SIZES.mediumText]: null,
|
|
112
|
+
[BADGE_ENHANCER_SIZES.mediumIcon]: null
|
|
113
|
+
};
|
|
114
|
+
export const BADGE_ENHANCER_POSITIONS = {
|
|
115
|
+
[PINHEAD_SIZES_SHAPES.xxSmallSquare]: null,
|
|
116
|
+
[PINHEAD_SIZES_SHAPES.xxSmallCircle]: null,
|
|
117
|
+
[PINHEAD_SIZES_SHAPES.xSmallSquare]: xSmallPinheadBadge,
|
|
118
|
+
[PINHEAD_SIZES_SHAPES.xSmallCircle]: xSmallPinheadBadge,
|
|
119
|
+
[PINHEAD_SIZES_SHAPES.small]: {
|
|
120
|
+
[BADGE_ENHANCER_SIZES.none]: null,
|
|
121
|
+
[BADGE_ENHANCER_SIZES.xSmall]: {
|
|
122
|
+
x: -7,
|
|
123
|
+
y: -1
|
|
124
|
+
},
|
|
125
|
+
[BADGE_ENHANCER_SIZES.small]: {
|
|
126
|
+
x: -8,
|
|
127
|
+
y: -8
|
|
128
|
+
},
|
|
129
|
+
[BADGE_ENHANCER_SIZES.mediumText]: null,
|
|
130
|
+
[BADGE_ENHANCER_SIZES.mediumIcon]: null
|
|
131
|
+
},
|
|
132
|
+
[PINHEAD_SIZES_SHAPES.medium]: {
|
|
133
|
+
[BADGE_ENHANCER_SIZES.none]: null,
|
|
134
|
+
[BADGE_ENHANCER_SIZES.xSmall]: {
|
|
135
|
+
x: -9,
|
|
136
|
+
y: 1
|
|
137
|
+
},
|
|
138
|
+
[BADGE_ENHANCER_SIZES.small]: {
|
|
139
|
+
x: -10,
|
|
140
|
+
y: -4
|
|
141
|
+
},
|
|
142
|
+
[BADGE_ENHANCER_SIZES.mediumText]: {
|
|
143
|
+
x: -12,
|
|
144
|
+
y: -8
|
|
145
|
+
},
|
|
146
|
+
[BADGE_ENHANCER_SIZES.mediumIcon]: {
|
|
147
|
+
x: -12,
|
|
148
|
+
y: -8
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
[PINHEAD_SIZES_SHAPES.large]: {
|
|
152
|
+
[BADGE_ENHANCER_SIZES.none]: null,
|
|
153
|
+
[BADGE_ENHANCER_SIZES.xSmall]: {
|
|
154
|
+
x: -11,
|
|
155
|
+
y: 3
|
|
156
|
+
},
|
|
157
|
+
[BADGE_ENHANCER_SIZES.small]: null,
|
|
158
|
+
[BADGE_ENHANCER_SIZES.mediumText]: {
|
|
159
|
+
x: -14,
|
|
160
|
+
y: -6
|
|
161
|
+
},
|
|
162
|
+
[BADGE_ENHANCER_SIZES.mediumIcon]: {
|
|
163
|
+
x: -14,
|
|
164
|
+
y: -6
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
export const BADGE_ENHANCER_STYLES = {
|
|
169
|
+
[BADGE_ENHANCER_SIZES.none]: {},
|
|
170
|
+
[BADGE_ENHANCER_SIZES.xSmall]: {
|
|
171
|
+
height: '8px',
|
|
172
|
+
width: '8px',
|
|
173
|
+
borderRadius: '50%'
|
|
174
|
+
},
|
|
175
|
+
[BADGE_ENHANCER_SIZES.small]: {
|
|
176
|
+
height: '16px',
|
|
177
|
+
width: '16px',
|
|
178
|
+
borderRadius: '50%',
|
|
179
|
+
display: 'flex',
|
|
180
|
+
alignItems: 'center',
|
|
181
|
+
justifyContent: 'center',
|
|
182
|
+
fontSize: '10px'
|
|
183
|
+
},
|
|
184
|
+
[BADGE_ENHANCER_SIZES.mediumText]: {
|
|
185
|
+
borderRadius: '10px',
|
|
186
|
+
height: '20px',
|
|
187
|
+
padding: '0px 8px',
|
|
188
|
+
display: 'flex',
|
|
189
|
+
alignItems: 'center',
|
|
190
|
+
boxSizing: 'border-box'
|
|
191
|
+
},
|
|
192
|
+
[BADGE_ENHANCER_SIZES.mediumIcon]: {
|
|
193
|
+
height: '20px',
|
|
194
|
+
width: '20px',
|
|
195
|
+
borderRadius: '50%',
|
|
196
|
+
display: 'flex',
|
|
197
|
+
alignItems: 'center',
|
|
198
|
+
justifyContent: 'center',
|
|
199
|
+
boxSizing: 'border-box'
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
export const BADGE_ENHANCER_CONTENT_SIZE = {
|
|
203
|
+
[BADGE_ENHANCER_SIZES.none]: 0,
|
|
204
|
+
[BADGE_ENHANCER_SIZES.xSmall]: 0,
|
|
205
|
+
[BADGE_ENHANCER_SIZES.small]: 10,
|
|
206
|
+
[BADGE_ENHANCER_SIZES.mediumText]: 12,
|
|
207
|
+
[BADGE_ENHANCER_SIZES.mediumIcon]: 12
|
|
208
|
+
};
|
|
209
|
+
export const KIND = Object.freeze({
|
|
210
|
+
default: 'default',
|
|
211
|
+
accent: 'accent',
|
|
212
|
+
negative: 'negative'
|
|
213
|
+
});
|