baseui 10.8.0 → 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 (170) 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 +3 -1
  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 +4 -0
  62. package/es/themes/light-theme/color-component-tokens.js +4 -0
  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/esm/a11y/a11y.js +3 -3
  67. package/esm/button/styled-components.js +47 -18
  68. package/esm/combobox/combobox.js +6 -3
  69. package/esm/data-table/column-categorical.js +2 -2
  70. package/esm/data-table/column-numerical.js +304 -353
  71. package/esm/data-table/constants.js +12 -8
  72. package/esm/data-table/data-table.js +53 -50
  73. package/esm/data-table/filter-shell.js +26 -4
  74. package/esm/data-table/locale.js +4 -2
  75. package/esm/data-table/measure-column-widths.js +83 -121
  76. package/esm/datepicker/styled-components.js +1 -1
  77. package/esm/drawer/drawer.js +3 -1
  78. package/esm/index.js +1 -1
  79. package/esm/map-marker/badge-enhancer.js +79 -0
  80. package/esm/map-marker/constants.js +94 -4
  81. package/esm/map-marker/drag-shadow.js +53 -0
  82. package/esm/map-marker/fixed-marker.js +84 -80
  83. package/esm/map-marker/floating-marker.js +22 -13
  84. package/esm/map-marker/index.js +1 -1
  85. package/esm/map-marker/label-enhancer.js +60 -0
  86. package/esm/map-marker/needle.js +43 -0
  87. package/esm/map-marker/pin-head.js +77 -66
  88. package/esm/map-marker/styled-components.js +182 -51
  89. package/esm/map-marker/types.js +1 -1
  90. package/esm/menu/maybe-child-menu.js +0 -2
  91. package/esm/menu/nested-menus.js +66 -5
  92. package/esm/menu/stateful-container.js +15 -13
  93. package/esm/modal/modal.js +3 -1
  94. package/esm/popover/popover.js +3 -1
  95. package/esm/progress-bar/index.js +1 -1
  96. package/esm/progress-bar/progressbar.js +32 -10
  97. package/esm/progress-bar/styled-components.js +9 -4
  98. package/esm/select/select-component.js +2 -11
  99. package/esm/spinner/styled-components.js +35 -16
  100. package/esm/table/filter.js +3 -1
  101. package/esm/themes/dark-theme/color-component-tokens.js +4 -0
  102. package/esm/themes/light-theme/color-component-tokens.js +4 -0
  103. package/esm/timezonepicker/timezone-picker.js +64 -36
  104. package/esm/timezonepicker/tzdata.js +2 -0
  105. package/esm/timezonepicker/update-tzdata.js +160 -0
  106. package/index.js +6 -0
  107. package/index.js.flow +1 -1
  108. package/map-marker/badge-enhancer.js +90 -0
  109. package/map-marker/badge-enhancer.js.flow +86 -0
  110. package/map-marker/constants.js +103 -5
  111. package/map-marker/constants.js.flow +152 -0
  112. package/map-marker/drag-shadow.js +64 -0
  113. package/map-marker/drag-shadow.js.flow +52 -0
  114. package/map-marker/fixed-marker.js +84 -78
  115. package/map-marker/fixed-marker.js.flow +78 -66
  116. package/map-marker/floating-marker.js +22 -13
  117. package/map-marker/floating-marker.js.flow +30 -17
  118. package/map-marker/index.d.ts +125 -24
  119. package/map-marker/index.js +18 -0
  120. package/map-marker/index.js.flow +3 -0
  121. package/map-marker/label-enhancer.js +71 -0
  122. package/map-marker/label-enhancer.js.flow +63 -0
  123. package/map-marker/needle.js +54 -0
  124. package/map-marker/needle.js.flow +29 -0
  125. package/map-marker/pin-head.js +80 -69
  126. package/map-marker/pin-head.js.flow +122 -84
  127. package/map-marker/styled-components.js +200 -62
  128. package/map-marker/styled-components.js.flow +172 -22
  129. package/map-marker/types.js.flow +69 -20
  130. package/menu/index.d.ts +9 -4
  131. package/menu/maybe-child-menu.js +0 -2
  132. package/menu/maybe-child-menu.js.flow +0 -2
  133. package/menu/nested-menus.js +66 -5
  134. package/menu/nested-menus.js.flow +50 -5
  135. package/menu/stateful-container.js +15 -13
  136. package/menu/stateful-container.js.flow +19 -13
  137. package/menu/types.js.flow +7 -1
  138. package/modal/modal.js +3 -1
  139. package/modal/modal.js.flow +2 -0
  140. package/package.json +5 -4
  141. package/popover/popover.js +3 -1
  142. package/popover/popover.js.flow +2 -0
  143. package/progress-bar/index.d.ts +2 -0
  144. package/progress-bar/index.js +6 -0
  145. package/progress-bar/index.js.flow +1 -0
  146. package/progress-bar/progressbar.js +32 -10
  147. package/progress-bar/progressbar.js.flow +35 -9
  148. package/progress-bar/styled-components.js +9 -4
  149. package/progress-bar/styled-components.js.flow +15 -4
  150. package/progress-bar/types.js.flow +12 -2
  151. package/select/select-component.js +2 -11
  152. package/select/select-component.js.flow +5 -7
  153. package/spinner/styled-components.js +35 -16
  154. package/spinner/styled-components.js.flow +37 -19
  155. package/spinner/types.js.flow +10 -0
  156. package/styles/index.js.flow +1 -1
  157. package/table/filter.js +3 -1
  158. package/table/filter.js.flow +5 -1
  159. package/themes/dark-theme/color-component-tokens.js +4 -0
  160. package/themes/dark-theme/color-component-tokens.js.flow +4 -0
  161. package/themes/light-theme/color-component-tokens.js +4 -0
  162. package/themes/light-theme/color-component-tokens.js.flow +4 -0
  163. package/themes/types.js.flow +4 -0
  164. package/timezonepicker/timezone-picker.js +69 -41
  165. package/timezonepicker/timezone-picker.js.flow +52 -46
  166. package/timezonepicker/types.js.flow +1 -1
  167. package/timezonepicker/tzdata.js +10 -0
  168. package/timezonepicker/tzdata.js.flow +347 -0
  169. package/timezonepicker/update-tzdata.js +164 -0
  170. package/timezonepicker/update-tzdata.js.flow +70 -0
@@ -19,13 +19,6 @@ export var NUMERICAL_FORMATS = Object.freeze({
19
19
  ACCOUNTING: 'ACCOUNTING',
20
20
  PERCENTAGE: 'PERCENTAGE'
21
21
  });
22
- export var NUMERICAL_OPERATIONS = Object.freeze({
23
- EQ: 'EQ',
24
- GT: 'GT',
25
- GTE: 'GTE',
26
- LT: 'LT',
27
- LTE: 'LTE'
28
- });
29
22
  export var DATETIME_OPERATIONS = Object.freeze({
30
23
  RANGE_DATETIME: 'RANGE_DATETIME',
31
24
  RANGE_DATE: 'RANGE_DATE',
@@ -39,4 +32,15 @@ export var DATETIME_OPERATIONS = Object.freeze({
39
32
  export var 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 var FILTER_SHELL_WIDTH = '320px'; // Depends on FILTER_SHELL_WIDTH
38
+
39
+ export var 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 var MAX_BIN_COUNT = 50;
@@ -43,6 +43,12 @@ import { LocaleContext } from '../locale/index.js'; // consider pulling this out
43
43
 
44
44
  var HEADER_ROW_HEIGHT = 48;
45
45
 
46
+ var sum = function sum(ns) {
47
+ return ns.reduce(function (s, n) {
48
+ return s + n;
49
+ }, 0);
50
+ };
51
+
46
52
  function CellPlacement(_ref) {
47
53
  var columnIndex = _ref.columnIndex,
48
54
  rowIndex = _ref.rowIndex,
@@ -301,7 +307,7 @@ function Header(props) {
301
307
  }))));
302
308
  }
303
309
 
304
- function Headers(props) {
310
+ function Headers() {
305
311
  var _useStyletron5 = useStyletron(),
306
312
  _useStyletron6 = _slicedToArray(_useStyletron5, 2),
307
313
  css = _useStyletron6[0],
@@ -320,9 +326,7 @@ function Headers(props) {
320
326
  position: 'sticky',
321
327
  top: 0,
322
328
  left: 0,
323
- width: "".concat(ctx.widths.reduce(function (sum, w) {
324
- return sum + w;
325
- }, 0), "px"),
329
+ width: "".concat(sum(ctx.widths), "px"),
326
330
  height: "".concat(HEADER_ROW_HEIGHT, "px"),
327
331
  display: 'flex',
328
332
  // this feels bad.. the absolutely positioned children elements
@@ -545,22 +549,27 @@ export function DataTable(_ref2) {
545
549
  }
546
550
 
547
551
  return rowHeight;
548
- }, [rowHeight]);
549
- var gridRef = React.useRef(null);
552
+ }, [rowHeight]); // We use state for our ref, to allow hooks to update when the ref changes.
553
+ // eslint-disable-next-line flowtype/no-weak-types
550
554
 
551
- var _React$useState7 = React.useState(columns.map(function () {
552
- return 0;
553
- })),
555
+ var _React$useState7 = React.useState(null),
554
556
  _React$useState8 = _slicedToArray(_React$useState7, 2),
555
- measuredWidths = _React$useState8[0],
556
- setMeasuredWidths = _React$useState8[1];
557
+ gridRef = _React$useState8[0],
558
+ setGridRef = _React$useState8[1];
557
559
 
558
560
  var _React$useState9 = React.useState(columns.map(function () {
559
561
  return 0;
560
562
  })),
561
563
  _React$useState10 = _slicedToArray(_React$useState9, 2),
562
- resizeDeltas = _React$useState10[0],
563
- setResizeDeltas = _React$useState10[1];
564
+ measuredWidths = _React$useState10[0],
565
+ setMeasuredWidths = _React$useState10[1];
566
+
567
+ var _React$useState11 = React.useState(columns.map(function () {
568
+ return 0;
569
+ })),
570
+ _React$useState12 = _slicedToArray(_React$useState11, 2),
571
+ resizeDeltas = _React$useState12[0],
572
+ setResizeDeltas = _React$useState12[1];
564
573
 
565
574
  React.useEffect(function () {
566
575
  setMeasuredWidths(function (prev) {
@@ -575,11 +584,11 @@ export function DataTable(_ref2) {
575
584
  });
576
585
  }, [columns]);
577
586
  var resetAfterColumnIndex = React.useCallback(function (columnIndex) {
578
- if (gridRef.current) {
587
+ if (gridRef) {
579
588
  // $FlowFixMe trigger react-window to layout the elements again
580
- gridRef.current.resetAfterColumnIndex(columnIndex, true);
589
+ gridRef.resetAfterColumnIndex(columnIndex, true);
581
590
  }
582
- }, [gridRef.current]);
591
+ }, [gridRef]);
583
592
  var handleWidthsChange = React.useCallback(function (nextWidths) {
584
593
  setMeasuredWidths(nextWidths);
585
594
  resetAfterColumnIndex(0);
@@ -592,20 +601,20 @@ export function DataTable(_ref2) {
592
601
  resetAfterColumnIndex(columnIndex);
593
602
  }, [setResizeDeltas, resetAfterColumnIndex]);
594
603
 
595
- var _React$useState11 = React.useState(0),
596
- _React$useState12 = _slicedToArray(_React$useState11, 2),
597
- scrollLeft = _React$useState12[0],
598
- setScrollLeft = _React$useState12[1];
599
-
600
- var _React$useState13 = React.useState(false),
604
+ var _React$useState13 = React.useState(0),
601
605
  _React$useState14 = _slicedToArray(_React$useState13, 2),
602
- isScrollingX = _React$useState14[0],
603
- setIsScrollingX = _React$useState14[1];
606
+ scrollLeft = _React$useState14[0],
607
+ setScrollLeft = _React$useState14[1];
604
608
 
605
609
  var _React$useState15 = React.useState(false),
606
610
  _React$useState16 = _slicedToArray(_React$useState15, 2),
607
- recentlyScrolledX = _React$useState16[0],
608
- setRecentlyScrolledX = _React$useState16[1];
611
+ isScrollingX = _React$useState16[0],
612
+ setIsScrollingX = _React$useState16[1];
613
+
614
+ var _React$useState17 = React.useState(false),
615
+ _React$useState18 = _slicedToArray(_React$useState17, 2),
616
+ recentlyScrolledX = _React$useState18[0],
617
+ setRecentlyScrolledX = _React$useState18[1];
609
618
 
610
619
  React.useLayoutEffect(function () {
611
620
  if (recentlyScrolledX !== isScrollingX) {
@@ -727,25 +736,18 @@ export function DataTable(_ref2) {
727
736
  return result;
728
737
  }, [sortedIndices, filteredIndices, onIncludedRowsChange, allRows]);
729
738
 
730
- var _React$useState17 = React.useState(0),
731
- _React$useState18 = _slicedToArray(_React$useState17, 2),
732
- browserScrollbarWidth = _React$useState18[0],
733
- setBrowserScrollbarWidth = _React$useState18[1];
739
+ var _React$useState19 = React.useState(0),
740
+ _React$useState20 = _slicedToArray(_React$useState19, 2),
741
+ browserScrollbarWidth = _React$useState20[0],
742
+ setBrowserScrollbarWidth = _React$useState20[1];
734
743
 
735
744
  var normalizedWidths = React.useMemo(function () {
736
- var sum = function sum(ns) {
737
- return ns.reduce(function (s, n) {
738
- return s + n;
739
- }, 0);
740
- };
741
-
742
745
  var resizedWidths = measuredWidths.map(function (w, i) {
743
746
  return Math.floor(w) + Math.floor(resizeDeltas[i]);
744
747
  });
745
748
 
746
- if (gridRef.current) {
747
- // $FlowFixMe
748
- var gridProps = gridRef.current.props;
749
+ if (gridRef) {
750
+ var gridProps = gridRef.props;
749
751
  var isContentTallerThanContainer = false;
750
752
  var visibleRowHeight = 0;
751
753
 
@@ -782,7 +784,7 @@ export function DataTable(_ref2) {
782
784
  }
783
785
 
784
786
  return resizedWidths;
785
- }, [measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
787
+ }, [gridRef, measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
786
788
  var isSelectable = batchActions ? !!batchActions.length : false;
787
789
  var isSelectedAll = React.useMemo(function () {
788
790
  if (!selectedRowIds) {
@@ -826,23 +828,23 @@ export function DataTable(_ref2) {
826
828
  }
827
829
  }, [onSort]);
828
830
 
829
- var _React$useState19 = React.useState(-1),
830
- _React$useState20 = _slicedToArray(_React$useState19, 2),
831
- columnHighlightIndex = _React$useState20[0],
832
- setColumnHighlightIndex = _React$useState20[1];
833
-
834
831
  var _React$useState21 = React.useState(-1),
835
832
  _React$useState22 = _slicedToArray(_React$useState21, 2),
836
- rowHighlightIndex = _React$useState22[0],
837
- setRowHighlightIndex = _React$useState22[1];
833
+ columnHighlightIndex = _React$useState22[0],
834
+ setColumnHighlightIndex = _React$useState22[1];
835
+
836
+ var _React$useState23 = React.useState(-1),
837
+ _React$useState24 = _slicedToArray(_React$useState23, 2),
838
+ rowHighlightIndex = _React$useState24[0],
839
+ setRowHighlightIndex = _React$useState24[1];
838
840
 
839
841
  function handleRowHighlightIndexChange(nextIndex) {
840
842
  setRowHighlightIndex(nextIndex);
841
843
 
842
- if (gridRef.current) {
844
+ if (gridRef) {
843
845
  if (nextIndex >= 0) {
844
846
  // $FlowFixMe - unable to get react-window types
845
- gridRef.current.scrollToItem({
847
+ gridRef.scrollToItem({
846
848
  rowIndex: nextIndex
847
849
  });
848
850
  }
@@ -933,8 +935,9 @@ export function DataTable(_ref2) {
933
935
  }
934
936
  }, /*#__PURE__*/React.createElement(VariableSizeGrid // eslint-disable-next-line flowtype/no-weak-types
935
937
  , {
936
- ref: gridRef,
938
+ ref: setGridRef,
937
939
  overscanRowCount: 10,
940
+ overscanColumnCount: 5,
938
941
  innerElementType: InnerTableElement,
939
942
  columnCount: columns.length,
940
943
  columnWidth: function columnWidth(columnIndex) {
@@ -21,6 +21,7 @@ import { Button, SIZE as BUTTON_SIZE } from '../button/index.js';
21
21
  import { Checkbox, STYLE_TYPE } from '../checkbox/index.js';
22
22
  import { useStyletron } from '../styles/index.js';
23
23
  import { LocaleContext } from '../locale/index.js';
24
+ import { FILTER_SHELL_WIDTH } from './constants.js';
24
25
 
25
26
  function FilterShell(props) {
26
27
  var _useStyletron = useStyletron(),
@@ -29,6 +30,21 @@ function FilterShell(props) {
29
30
  theme = _useStyletron2[1];
30
31
 
31
32
  var locale = React.useContext(LocaleContext);
33
+ var excludeText;
34
+
35
+ switch (props.excludeKind) {
36
+ case 'value':
37
+ excludeText = locale.datatable.filterExcludeValue;
38
+ break;
39
+
40
+ case 'range':
41
+ excludeText = locale.datatable.filterExcludeRange;
42
+ break;
43
+
44
+ default:
45
+ excludeText = locale.datatable.filterExclude;
46
+ }
47
+
32
48
  return /*#__PURE__*/React.createElement("form", {
33
49
  className: css({
34
50
  backgroundColor: theme.colors.backgroundPrimary,
@@ -36,7 +52,7 @@ function FilterShell(props) {
36
52
  paddingRight: theme.sizing.scale600,
37
53
  paddingBottom: theme.sizing.scale600,
38
54
  paddingLeft: theme.sizing.scale600,
39
- width: '320px'
55
+ width: FILTER_SHELL_WIDTH
40
56
  }),
41
57
  onSubmit: function onSubmit(event) {
42
58
  event.preventDefault();
@@ -44,17 +60,23 @@ function FilterShell(props) {
44
60
  }
45
61
  }, props.children, /*#__PURE__*/React.createElement("div", {
46
62
  className: css({
47
- alignItems: 'center',
48
63
  display: 'flex',
64
+ flexDirection: 'column',
49
65
  justifyContent: 'space-between',
50
- marginTop: theme.sizing.scale600
66
+ alignItems: 'flex-end',
67
+ marginTop: theme.sizing.scale600,
68
+ gap: theme.sizing.scale200
69
+ })
70
+ }, /*#__PURE__*/React.createElement("div", {
71
+ className: css({
72
+ alignSelf: 'flex-start'
51
73
  })
52
74
  }, /*#__PURE__*/React.createElement(Checkbox, {
53
75
  checked: props.exclude,
54
76
  onChange: props.onExcludeChange,
55
77
  checkmarkType: STYLE_TYPE.toggle_round,
56
78
  labelPlacement: "right"
57
- }, locale.datatable.filterExclude), /*#__PURE__*/React.createElement(Button, {
79
+ }, excludeText)), /*#__PURE__*/React.createElement(Button, {
58
80
  size: BUTTON_SIZE.compact,
59
81
  type: "submit"
60
82
  }, locale.datatable.filterApply)));
@@ -6,18 +6,20 @@ LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  var 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',
@@ -1,11 +1,3 @@
1
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
-
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
-
5
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
6
-
7
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
-
9
1
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
2
 
11
3
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -27,51 +19,62 @@ LICENSE file in the root directory of this source tree.
27
19
  import * as React from 'react';
28
20
  import { useStyletron } from '../styles/index.js';
29
21
  import HeaderCell from './header-cell.js';
22
+ import { useRef } from 'react'; // Measures the column header + sampled data
30
23
 
31
- // https://github.com/Swizec/useDimensions
32
- function useDimensions() {
33
- var _React$useState = React.useState({}),
34
- _React$useState2 = _slicedToArray(_React$useState, 2),
35
- dimensions = _React$useState2[0],
36
- setDimensions = _React$useState2[1];
24
+ function MeasureColumn(_ref) {
25
+ var sampleIndexes = _ref.sampleIndexes,
26
+ column = _ref.column,
27
+ columnIndex = _ref.columnIndex,
28
+ rows = _ref.rows,
29
+ isSelectable = _ref.isSelectable,
30
+ onLayout = _ref.onLayout;
37
31
 
38
- var _React$useState3 = React.useState(null),
39
- _React$useState4 = _slicedToArray(_React$useState3, 2),
40
- node = _React$useState4[0],
41
- setNode = _React$useState4[1];
32
+ var _useStyletron = useStyletron(),
33
+ _useStyletron2 = _slicedToArray(_useStyletron, 1),
34
+ css = _useStyletron2[0];
42
35
 
43
- var ref = React.useCallback(function (node) {
44
- setNode(node);
45
- }, []);
36
+ var ref = useRef();
46
37
  React.useEffect(function () {
47
- if (typeof document !== 'undefined') {
48
- if (node) {
49
- window.requestAnimationFrame(function () {
50
- setDimensions(node.getBoundingClientRect());
51
- });
52
- }
38
+ if (ref.current) {
39
+ onLayout(columnIndex, ref.current.getBoundingClientRect());
53
40
  }
54
- }, [node]);
55
- return [ref, dimensions];
56
- }
57
-
58
- function ElementMeasurer(props) {
59
- var onDimensionsChange = props.onDimensionsChange;
60
-
61
- var _useDimensions = useDimensions(),
62
- _useDimensions2 = _slicedToArray(_useDimensions, 2),
63
- ref = _useDimensions2[0],
64
- dimensions = _useDimensions2[1];
65
-
66
- React.useEffect(function () {
67
- onDimensionsChange(dimensions);
68
- }, [dimensions, onDimensionsChange]);
69
- return /*#__PURE__*/React.cloneElement(props.item, {
70
- ref: ref
71
- });
41
+ }, []);
42
+ return /*#__PURE__*/React.createElement("div", {
43
+ ref: ref,
44
+ className: css({
45
+ display: 'flex',
46
+ flexDirection: 'column',
47
+ width: 'fit-content'
48
+ })
49
+ }, /*#__PURE__*/React.createElement(HeaderCell, {
50
+ index: columnIndex,
51
+ isHovered: true,
52
+ isMeasured: true,
53
+ isSelectedAll: false,
54
+ isSelectedIndeterminate: false,
55
+ onMouseEnter: function onMouseEnter() {},
56
+ onMouseLeave: function onMouseLeave() {},
57
+ onSelectAll: function onSelectAll() {},
58
+ onSelectNone: function onSelectNone() {},
59
+ onSort: function onSort(i) {},
60
+ sortable: column.sortable,
61
+ sortDirection: null,
62
+ title: column.title,
63
+ isSelectable: isSelectable
64
+ }), sampleIndexes.map(function (rowIndex, i) {
65
+ var Cell = column.renderCell;
66
+ return /*#__PURE__*/React.createElement(Cell, {
67
+ key: "measure-".concat(i),
68
+ value: column.mapDataToValue(rows[rowIndex].data),
69
+ isSelectable: isSelectable,
70
+ isMeasured: true,
71
+ sortable: column.sortable,
72
+ x: 0,
73
+ y: rowIndex
74
+ });
75
+ }));
72
76
  }
73
77
 
74
- // sample size could likely be generated based on row count, to have higher confidence
75
78
  var MAX_SAMPLE_SIZE = 50;
76
79
 
77
80
  function generateSampleIndices(inputMin, inputMax, maxSamples) {
@@ -103,57 +106,46 @@ function generateSampleIndices(inputMin, inputMax, maxSamples) {
103
106
  return indices;
104
107
  }
105
108
 
106
- export default function MeasureColumnWidths(_ref) {
107
- var columns = _ref.columns,
108
- rows = _ref.rows,
109
- widths = _ref.widths,
110
- isSelectable = _ref.isSelectable,
111
- onWidthsChange = _ref.onWidthsChange;
109
+ export default function MeasureColumnWidths(_ref2) {
110
+ var columns = _ref2.columns,
111
+ rows = _ref2.rows,
112
+ widths = _ref2.widths,
113
+ isSelectable = _ref2.isSelectable,
114
+ onWidthsChange = _ref2.onWidthsChange;
112
115
 
113
- var _useStyletron = useStyletron(),
114
- _useStyletron2 = _slicedToArray(_useStyletron, 1),
115
- css = _useStyletron2[0];
116
+ var _useStyletron3 = useStyletron(),
117
+ _useStyletron4 = _slicedToArray(_useStyletron3, 1),
118
+ css = _useStyletron4[0];
116
119
 
117
- var measurementCount = React.useRef(0);
118
- var dimensionsCache = React.useRef(widths);
120
+ var widthMap = React.useMemo(function () {
121
+ return new Map();
122
+ }, []);
119
123
  var sampleSize = rows.length < MAX_SAMPLE_SIZE ? rows.length : MAX_SAMPLE_SIZE;
120
124
  var finishedMeasurementCount = (sampleSize + 1) * columns.length;
121
- var sampleRowIndicesByColumn = React.useMemo(function () {
122
- measurementCount.current = 0;
123
- dimensionsCache.current = widths;
124
- var indices = generateSampleIndices(0, rows.length - 1, sampleSize);
125
- return columns.map(function () {
126
- return indices;
127
- });
125
+ var sampleIndexes = React.useMemo(function () {
126
+ return generateSampleIndices(0, rows.length - 1, sampleSize);
128
127
  }, [columns, rows, widths, sampleSize]);
129
- var handleDimensionsChange = React.useCallback(function (columnIndex, rowIndex, dimensions) {
130
- if (dimensions.width === undefined) return;
128
+ var handleDimensionsChange = React.useCallback(function (columnIndex, dimensions) {
129
+ var nextWidth = Math.min(Math.max(columns[columnIndex].minWidth || 0, widthMap.get(columnIndex) || 0, dimensions.width + 1), columns[columnIndex].maxWidth || Infinity);
131
130
 
132
- if (columns[columnIndex] === undefined || dimensionsCache.current[columnIndex] === undefined) {
133
- return;
131
+ if (nextWidth !== widthMap.get(columnIndex)) {
132
+ widthMap.set(columnIndex, nextWidth);
134
133
  }
135
134
 
136
- measurementCount.current += 1;
137
- var nextWidth = Math.min(Math.max(columns[columnIndex].minWidth || 0, dimensionsCache.current[columnIndex], dimensions.width + 1), columns[columnIndex].maxWidth || Infinity);
138
-
139
- if (nextWidth !== dimensionsCache.current[columnIndex]) {
140
- var nextWidths = _toConsumableArray(dimensionsCache.current);
141
-
142
- nextWidths[columnIndex] = nextWidth;
143
- dimensionsCache.current = nextWidths;
144
- }
145
-
146
- if (measurementCount.current >= finishedMeasurementCount) {
147
- onWidthsChange(dimensionsCache.current);
135
+ if ( // Refresh at 100% of done
136
+ widthMap.size === columns.length || // ...50%
137
+ widthMap.size === Math.floor(columns.length / 2) || // ...25%
138
+ widthMap.size === Math.floor(columns.length / 4)) {
139
+ onWidthsChange(Array.from(widthMap.values()));
148
140
  }
149
141
  }, [columns, finishedMeasurementCount, onWidthsChange]);
150
142
  var hiddenStyle = css({
151
143
  position: 'absolute',
152
144
  overflow: 'hidden',
153
145
  height: 0
154
- });
146
+ }); // Remove the measurement nodes after we are done updating our column width
155
147
 
156
- if (measurementCount.current >= finishedMeasurementCount) {
148
+ if (widthMap.size === columns.length) {
157
149
  return null;
158
150
  }
159
151
 
@@ -164,45 +156,15 @@ export default function MeasureColumnWidths(_ref) {
164
156
  className: hiddenStyle,
165
157
  "aria-hidden": true,
166
158
  role: "none"
167
- }, sampleRowIndicesByColumn.map(function (rowIndices, columnIndex) {
168
- var Cell = columns[columnIndex].renderCell;
169
- return rowIndices.map(function (rowIndex) {
170
- return /*#__PURE__*/React.createElement(ElementMeasurer, {
171
- key: "measure-".concat(columnIndex, "-").concat(rowIndex),
172
- onDimensionsChange: function onDimensionsChange(dimensions) {
173
- return handleDimensionsChange(columnIndex, rowIndex, dimensions);
174
- },
175
- item: /*#__PURE__*/React.createElement(Cell, {
176
- value: columns[columnIndex].mapDataToValue(rows[rowIndex].data),
177
- isMeasured: true,
178
- onSelect: isSelectable && columnIndex === 0 ? function () {} : undefined,
179
- x: columnIndex,
180
- y: rowIndex
181
- })
182
- });
183
- });
184
- }), columns.map(function (column, columnIndex) {
185
- return /*#__PURE__*/React.createElement(ElementMeasurer, {
186
- key: "measure-column-".concat(columnIndex),
187
- onDimensionsChange: function onDimensionsChange(dimensions) {
188
- return handleDimensionsChange(columnIndex, -1, dimensions);
189
- },
190
- item: /*#__PURE__*/React.createElement(HeaderCell, {
191
- index: columnIndex,
192
- isHovered: true,
193
- isMeasured: true,
194
- isSelectable: isSelectable && columnIndex === 0,
195
- isSelectedAll: false,
196
- isSelectedIndeterminate: false,
197
- onMouseEnter: function onMouseEnter() {},
198
- onMouseLeave: function onMouseLeave() {},
199
- onSelectAll: function onSelectAll() {},
200
- onSelectNone: function onSelectNone() {},
201
- onSort: function onSort(i) {},
202
- sortable: column.sortable,
203
- sortDirection: null,
204
- title: column.title
205
- })
159
+ }, columns.map(function (column, i) {
160
+ return /*#__PURE__*/React.createElement(MeasureColumn, {
161
+ key: column.title + i,
162
+ column: column,
163
+ rows: rows,
164
+ isSelectable: isSelectable,
165
+ onLayout: handleDimensionsChange,
166
+ columnIndex: i,
167
+ sampleIndexes: sampleIndexes
206
168
  });
207
169
  }))
208
170
  );
@@ -481,7 +481,7 @@ export var StyledDay = styled('div', function (props) {
481
481
  content: '""',
482
482
  boxSizing: 'border-box',
483
483
  display: 'inline-block',
484
- boxShadow: $isFocusVisible ? "0 0 0 3px ".concat(colors.accent) : 'none',
484
+ boxShadow: $isFocusVisible && (!$outsideMonth || $peekNextMonth) ? "0 0 0 3px ".concat(colors.accent) : 'none',
485
485
  backgroundColor: $selected ? colors.calendarDayBackgroundSelectedHighlighted : $pseudoSelected && $isHighlighted ? colors.calendarDayBackgroundPseudoSelectedHighlighted : colors.calendarBackground,
486
486
  height: $hasDateLabel ? '100%' : $density === DENSITY.high ? '42px' : '50px',
487
487
  width: '100%',
@@ -329,7 +329,9 @@ var Drawer = /*#__PURE__*/function (_React$Component) {
329
329
 
330
330
  var sharedProps = this.getSharedProps();
331
331
  return /*#__PURE__*/React.createElement(LocaleContext.Consumer, null, function (locale) {
332
- return /*#__PURE__*/React.createElement(FocusLock, {
332
+ return /*#__PURE__*/React.createElement(FocusLock // Allow focus to escape when UI is within an iframe
333
+ , {
334
+ crossFrame: false,
333
335
  returnFocus: true,
334
336
  autoFocus: autoFocus,
335
337
  noFocusGuards: true
package/esm/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';