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.
Files changed (174) hide show
  1. package/a11y/a11y.js +2 -2
  2. package/a11y/a11y.js.flow +3 -3
  3. package/button/styled-components.js +47 -18
  4. package/button/styled-components.js.flow +25 -5
  5. package/combobox/combobox.js +6 -3
  6. package/combobox/combobox.js.flow +4 -2
  7. package/combobox/types.js.flow +2 -0
  8. package/data-table/column-categorical.js +1 -1
  9. package/data-table/column-categorical.js.flow +2 -2
  10. package/data-table/column-numerical.js +307 -355
  11. package/data-table/column-numerical.js.flow +273 -287
  12. package/data-table/constants.js +17 -11
  13. package/data-table/constants.js.flow +11 -8
  14. package/data-table/data-table.js +53 -50
  15. package/data-table/data-table.js.flow +18 -13
  16. package/data-table/filter-shell.js +27 -4
  17. package/data-table/filter-shell.js.flow +33 -9
  18. package/data-table/locale.js +4 -2
  19. package/data-table/locale.js.flow +6 -2
  20. package/data-table/measure-column-widths.js +83 -121
  21. package/data-table/measure-column-widths.js.flow +87 -109
  22. package/datepicker/styled-components.js +1 -1
  23. package/datepicker/styled-components.js.flow +4 -1
  24. package/drawer/drawer.js +3 -1
  25. package/drawer/drawer.js.flow +7 -1
  26. package/es/a11y/a11y.js +2 -2
  27. package/es/button/styled-components.js +32 -2
  28. package/es/combobox/combobox.js +6 -3
  29. package/es/data-table/column-categorical.js +2 -2
  30. package/es/data-table/column-numerical.js +245 -317
  31. package/es/data-table/constants.js +12 -8
  32. package/es/data-table/data-table.js +18 -16
  33. package/es/data-table/filter-shell.js +26 -4
  34. package/es/data-table/locale.js +4 -2
  35. package/es/data-table/measure-column-widths.js +75 -86
  36. package/es/datepicker/styled-components.js +1 -1
  37. package/es/drawer/drawer.js +3 -1
  38. package/es/index.js +1 -1
  39. package/es/map-marker/badge-enhancer.js +61 -0
  40. package/es/map-marker/constants.js +146 -2
  41. package/es/map-marker/drag-shadow.js +32 -0
  42. package/es/map-marker/fixed-marker.js +54 -48
  43. package/es/map-marker/floating-marker.js +21 -12
  44. package/es/map-marker/index.js +1 -1
  45. package/es/map-marker/label-enhancer.js +39 -0
  46. package/es/map-marker/needle.js +26 -0
  47. package/es/map-marker/pin-head.js +42 -40
  48. package/es/map-marker/styled-components.js +177 -32
  49. package/es/map-marker/types.js +1 -1
  50. package/es/menu/maybe-child-menu.js +0 -2
  51. package/es/menu/nested-menus.js +49 -3
  52. package/es/menu/stateful-container.js +13 -12
  53. package/es/modal/modal.js +3 -1
  54. package/es/popover/popover.js +7 -3
  55. package/es/progress-bar/index.js +1 -1
  56. package/es/progress-bar/progressbar.js +25 -10
  57. package/es/progress-bar/styled-components.js +9 -5
  58. package/es/select/select-component.js +2 -10
  59. package/es/spinner/styled-components.js +34 -16
  60. package/es/table/filter.js +3 -1
  61. package/es/themes/dark-theme/color-component-tokens.js +19 -10
  62. package/es/themes/light-theme/color-component-tokens.js +19 -10
  63. package/es/timezonepicker/timezone-picker.js +53 -36
  64. package/es/timezonepicker/tzdata.js +2 -0
  65. package/es/timezonepicker/update-tzdata.js +69 -0
  66. package/es/toast/styled-components.js +18 -7
  67. package/esm/a11y/a11y.js +3 -3
  68. package/esm/button/styled-components.js +47 -18
  69. package/esm/combobox/combobox.js +6 -3
  70. package/esm/data-table/column-categorical.js +2 -2
  71. package/esm/data-table/column-numerical.js +304 -353
  72. package/esm/data-table/constants.js +12 -8
  73. package/esm/data-table/data-table.js +53 -50
  74. package/esm/data-table/filter-shell.js +26 -4
  75. package/esm/data-table/locale.js +4 -2
  76. package/esm/data-table/measure-column-widths.js +83 -121
  77. package/esm/datepicker/styled-components.js +1 -1
  78. package/esm/drawer/drawer.js +3 -1
  79. package/esm/index.js +1 -1
  80. package/esm/map-marker/badge-enhancer.js +79 -0
  81. package/esm/map-marker/constants.js +94 -4
  82. package/esm/map-marker/drag-shadow.js +53 -0
  83. package/esm/map-marker/fixed-marker.js +84 -80
  84. package/esm/map-marker/floating-marker.js +22 -13
  85. package/esm/map-marker/index.js +1 -1
  86. package/esm/map-marker/label-enhancer.js +60 -0
  87. package/esm/map-marker/needle.js +43 -0
  88. package/esm/map-marker/pin-head.js +77 -66
  89. package/esm/map-marker/styled-components.js +182 -51
  90. package/esm/map-marker/types.js +1 -1
  91. package/esm/menu/maybe-child-menu.js +0 -2
  92. package/esm/menu/nested-menus.js +66 -5
  93. package/esm/menu/stateful-container.js +15 -13
  94. package/esm/modal/modal.js +3 -1
  95. package/esm/popover/popover.js +7 -3
  96. package/esm/progress-bar/index.js +1 -1
  97. package/esm/progress-bar/progressbar.js +32 -10
  98. package/esm/progress-bar/styled-components.js +9 -4
  99. package/esm/select/select-component.js +2 -11
  100. package/esm/spinner/styled-components.js +35 -16
  101. package/esm/table/filter.js +3 -1
  102. package/esm/themes/dark-theme/color-component-tokens.js +19 -10
  103. package/esm/themes/light-theme/color-component-tokens.js +19 -10
  104. package/esm/timezonepicker/timezone-picker.js +64 -36
  105. package/esm/timezonepicker/tzdata.js +2 -0
  106. package/esm/timezonepicker/update-tzdata.js +160 -0
  107. package/esm/toast/styled-components.js +13 -5
  108. package/index.js +6 -0
  109. package/index.js.flow +1 -1
  110. package/map-marker/badge-enhancer.js +90 -0
  111. package/map-marker/badge-enhancer.js.flow +86 -0
  112. package/map-marker/constants.js +103 -5
  113. package/map-marker/constants.js.flow +152 -0
  114. package/map-marker/drag-shadow.js +64 -0
  115. package/map-marker/drag-shadow.js.flow +52 -0
  116. package/map-marker/fixed-marker.js +84 -78
  117. package/map-marker/fixed-marker.js.flow +78 -66
  118. package/map-marker/floating-marker.js +22 -13
  119. package/map-marker/floating-marker.js.flow +30 -17
  120. package/map-marker/index.d.ts +125 -24
  121. package/map-marker/index.js +18 -0
  122. package/map-marker/index.js.flow +3 -0
  123. package/map-marker/label-enhancer.js +71 -0
  124. package/map-marker/label-enhancer.js.flow +63 -0
  125. package/map-marker/needle.js +54 -0
  126. package/map-marker/needle.js.flow +29 -0
  127. package/map-marker/pin-head.js +80 -69
  128. package/map-marker/pin-head.js.flow +122 -84
  129. package/map-marker/styled-components.js +200 -62
  130. package/map-marker/styled-components.js.flow +172 -22
  131. package/map-marker/types.js.flow +69 -20
  132. package/menu/index.d.ts +9 -4
  133. package/menu/maybe-child-menu.js +0 -2
  134. package/menu/maybe-child-menu.js.flow +0 -2
  135. package/menu/nested-menus.js +66 -5
  136. package/menu/nested-menus.js.flow +50 -5
  137. package/menu/stateful-container.js +15 -13
  138. package/menu/stateful-container.js.flow +19 -13
  139. package/menu/types.js.flow +7 -1
  140. package/modal/modal.js +3 -1
  141. package/modal/modal.js.flow +2 -0
  142. package/package.json +5 -4
  143. package/popover/popover.js +7 -3
  144. package/popover/popover.js.flow +23 -17
  145. package/progress-bar/index.d.ts +2 -0
  146. package/progress-bar/index.js +6 -0
  147. package/progress-bar/index.js.flow +1 -0
  148. package/progress-bar/progressbar.js +32 -10
  149. package/progress-bar/progressbar.js.flow +35 -9
  150. package/progress-bar/styled-components.js +9 -4
  151. package/progress-bar/styled-components.js.flow +15 -4
  152. package/progress-bar/types.js.flow +12 -2
  153. package/select/select-component.js +2 -11
  154. package/select/select-component.js.flow +5 -7
  155. package/spinner/styled-components.js +35 -16
  156. package/spinner/styled-components.js.flow +37 -19
  157. package/spinner/types.js.flow +10 -0
  158. package/styles/index.js.flow +1 -1
  159. package/table/filter.js +3 -1
  160. package/table/filter.js.flow +5 -1
  161. package/themes/dark-theme/color-component-tokens.js +19 -10
  162. package/themes/dark-theme/color-component-tokens.js.flow +19 -10
  163. package/themes/light-theme/color-component-tokens.js +19 -10
  164. package/themes/light-theme/color-component-tokens.js.flow +19 -10
  165. package/themes/types.js.flow +9 -0
  166. package/timezonepicker/timezone-picker.js +69 -41
  167. package/timezonepicker/timezone-picker.js.flow +52 -46
  168. package/timezonepicker/types.js.flow +1 -1
  169. package/timezonepicker/tzdata.js +10 -0
  170. package/timezonepicker/tzdata.js.flow +347 -0
  171. package/timezonepicker/update-tzdata.js +164 -0
  172. package/timezonepicker/update-tzdata.js.flow +70 -0
  173. package/toast/styled-components.js +13 -5
  174. 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(props) {
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.reduce((sum, w) => sum + w, 0)}px`,
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
- const gridRef = React.useRef(null);
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.current) {
487
+ if (gridRef) {
484
488
  // $FlowFixMe trigger react-window to layout the elements again
485
- gridRef.current.resetAfterColumnIndex(columnIndex, true);
489
+ gridRef.resetAfterColumnIndex(columnIndex, true);
486
490
  }
487
- }, [gridRef.current]);
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.current) {
602
- // $FlowFixMe
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.current) {
688
+ if (gridRef) {
688
689
  if (nextIndex >= 0) {
689
690
  // $FlowFixMe - unable to get react-window types
690
- gridRef.current.scrollToItem({
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: gridRef,
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: '320px'
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
- marginTop: theme.sizing.scale600
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
- }, locale.datatable.filterExclude), /*#__PURE__*/React.createElement(Button, {
63
+ }, excludeText)), /*#__PURE__*/React.createElement(Button, {
42
64
  size: BUTTON_SIZE.compact,
43
65
  type: "submit"
44
66
  }, locale.datatable.filterApply)));
@@ -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 Rows.',
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 Categories Found',
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
- // https://github.com/Swizec/useDimensions
12
- function useDimensions() {
13
- const [dimensions, setDimensions] = React.useState({});
14
- const [node, setNode] = React.useState(null);
15
- const ref = React.useCallback(node => {
16
- setNode(node);
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 (typeof document !== 'undefined') {
20
- if (node) {
21
- window.requestAnimationFrame(() => {
22
- setDimensions(node.getBoundingClientRect());
23
- });
24
- }
23
+ if (ref.current) {
24
+ onLayout(columnIndex, ref.current.getBoundingClientRect());
25
25
  }
26
- }, [node]);
27
- return [ref, dimensions];
28
- }
29
-
30
- function ElementMeasurer(props) {
31
- const {
32
- onDimensionsChange
33
- } = props;
34
- const [ref, dimensions] = useDimensions();
35
- React.useEffect(() => {
36
- onDimensionsChange(dimensions);
37
- }, [dimensions, onDimensionsChange]);
38
- return /*#__PURE__*/React.cloneElement(props.item, {
39
- ref
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 measurementCount = React.useRef(0);
81
- const dimensionsCache = React.useRef(widths);
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 sampleRowIndicesByColumn = React.useMemo(() => {
85
- measurementCount.current = 0;
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, rowIndex, dimensions) => {
91
- if (dimensions.width === undefined) return;
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 !== dimensionsCache.current[columnIndex]) {
101
- const nextWidths = [...dimensionsCache.current];
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 (measurementCount.current >= finishedMeasurementCount) {
107
- onWidthsChange(dimensionsCache.current);
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 (measurementCount.current >= finishedMeasurementCount) {
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
- }, sampleRowIndicesByColumn.map((rowIndices, columnIndex) => {
128
- const Cell = columns[columnIndex].renderCell;
129
- return rowIndices.map(rowIndex => /*#__PURE__*/React.createElement(ElementMeasurer, {
130
- key: `measure-${columnIndex}-${rowIndex}`,
131
- onDimensionsChange: dimensions => handleDimensionsChange(columnIndex, rowIndex, dimensions),
132
- item: /*#__PURE__*/React.createElement(Cell, {
133
- value: columns[columnIndex].mapDataToValue(rows[rowIndex].data),
134
- isMeasured: true,
135
- onSelect: isSelectable && columnIndex === 0 ? () => {} : undefined,
136
- x: columnIndex,
137
- y: rowIndex
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%',
@@ -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
+ });