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,14 +19,6 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
19
19
 
20
20
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
21
 
22
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
23
-
24
- 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."); }
25
-
26
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
27
-
28
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
29
-
30
22
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
31
23
 
32
24
  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."); }
@@ -39,50 +31,61 @@ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(
39
31
 
40
32
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
41
33
 
42
- // https://github.com/Swizec/useDimensions
43
- function useDimensions() {
44
- var _React$useState = React.useState({}),
45
- _React$useState2 = _slicedToArray(_React$useState, 2),
46
- dimensions = _React$useState2[0],
47
- setDimensions = _React$useState2[1];
34
+ // Measures the column header + sampled data
35
+ function MeasureColumn(_ref) {
36
+ var sampleIndexes = _ref.sampleIndexes,
37
+ column = _ref.column,
38
+ columnIndex = _ref.columnIndex,
39
+ rows = _ref.rows,
40
+ isSelectable = _ref.isSelectable,
41
+ onLayout = _ref.onLayout;
48
42
 
49
- var _React$useState3 = React.useState(null),
50
- _React$useState4 = _slicedToArray(_React$useState3, 2),
51
- node = _React$useState4[0],
52
- setNode = _React$useState4[1];
43
+ var _useStyletron = (0, _index.useStyletron)(),
44
+ _useStyletron2 = _slicedToArray(_useStyletron, 1),
45
+ css = _useStyletron2[0];
53
46
 
54
- var ref = React.useCallback(function (node) {
55
- setNode(node);
56
- }, []);
47
+ var ref = (0, React.useRef)();
57
48
  React.useEffect(function () {
58
- if (typeof document !== 'undefined') {
59
- if (node) {
60
- window.requestAnimationFrame(function () {
61
- setDimensions(node.getBoundingClientRect());
62
- });
63
- }
49
+ if (ref.current) {
50
+ onLayout(columnIndex, ref.current.getBoundingClientRect());
64
51
  }
65
- }, [node]);
66
- return [ref, dimensions];
67
- }
68
-
69
- function ElementMeasurer(props) {
70
- var onDimensionsChange = props.onDimensionsChange;
71
-
72
- var _useDimensions = useDimensions(),
73
- _useDimensions2 = _slicedToArray(_useDimensions, 2),
74
- ref = _useDimensions2[0],
75
- dimensions = _useDimensions2[1];
76
-
77
- React.useEffect(function () {
78
- onDimensionsChange(dimensions);
79
- }, [dimensions, onDimensionsChange]);
80
- return /*#__PURE__*/React.cloneElement(props.item, {
81
- ref: ref
82
- });
52
+ }, []);
53
+ return /*#__PURE__*/React.createElement("div", {
54
+ ref: ref,
55
+ className: css({
56
+ display: 'flex',
57
+ flexDirection: 'column',
58
+ width: 'fit-content'
59
+ })
60
+ }, /*#__PURE__*/React.createElement(_headerCell.default, {
61
+ index: columnIndex,
62
+ isHovered: true,
63
+ isMeasured: true,
64
+ isSelectedAll: false,
65
+ isSelectedIndeterminate: false,
66
+ onMouseEnter: function onMouseEnter() {},
67
+ onMouseLeave: function onMouseLeave() {},
68
+ onSelectAll: function onSelectAll() {},
69
+ onSelectNone: function onSelectNone() {},
70
+ onSort: function onSort(i) {},
71
+ sortable: column.sortable,
72
+ sortDirection: null,
73
+ title: column.title,
74
+ isSelectable: isSelectable
75
+ }), sampleIndexes.map(function (rowIndex, i) {
76
+ var Cell = column.renderCell;
77
+ return /*#__PURE__*/React.createElement(Cell, {
78
+ key: "measure-".concat(i),
79
+ value: column.mapDataToValue(rows[rowIndex].data),
80
+ isSelectable: isSelectable,
81
+ isMeasured: true,
82
+ sortable: column.sortable,
83
+ x: 0,
84
+ y: rowIndex
85
+ });
86
+ }));
83
87
  }
84
88
 
85
- // sample size could likely be generated based on row count, to have higher confidence
86
89
  var MAX_SAMPLE_SIZE = 50;
87
90
 
88
91
  function generateSampleIndices(inputMin, inputMax, maxSamples) {
@@ -114,57 +117,46 @@ function generateSampleIndices(inputMin, inputMax, maxSamples) {
114
117
  return indices;
115
118
  }
116
119
 
117
- function MeasureColumnWidths(_ref) {
118
- var columns = _ref.columns,
119
- rows = _ref.rows,
120
- widths = _ref.widths,
121
- isSelectable = _ref.isSelectable,
122
- onWidthsChange = _ref.onWidthsChange;
120
+ function MeasureColumnWidths(_ref2) {
121
+ var columns = _ref2.columns,
122
+ rows = _ref2.rows,
123
+ widths = _ref2.widths,
124
+ isSelectable = _ref2.isSelectable,
125
+ onWidthsChange = _ref2.onWidthsChange;
123
126
 
124
- var _useStyletron = (0, _index.useStyletron)(),
125
- _useStyletron2 = _slicedToArray(_useStyletron, 1),
126
- css = _useStyletron2[0];
127
+ var _useStyletron3 = (0, _index.useStyletron)(),
128
+ _useStyletron4 = _slicedToArray(_useStyletron3, 1),
129
+ css = _useStyletron4[0];
127
130
 
128
- var measurementCount = React.useRef(0);
129
- var dimensionsCache = React.useRef(widths);
131
+ var widthMap = React.useMemo(function () {
132
+ return new Map();
133
+ }, []);
130
134
  var sampleSize = rows.length < MAX_SAMPLE_SIZE ? rows.length : MAX_SAMPLE_SIZE;
131
135
  var finishedMeasurementCount = (sampleSize + 1) * columns.length;
132
- var sampleRowIndicesByColumn = React.useMemo(function () {
133
- measurementCount.current = 0;
134
- dimensionsCache.current = widths;
135
- var indices = generateSampleIndices(0, rows.length - 1, sampleSize);
136
- return columns.map(function () {
137
- return indices;
138
- });
136
+ var sampleIndexes = React.useMemo(function () {
137
+ return generateSampleIndices(0, rows.length - 1, sampleSize);
139
138
  }, [columns, rows, widths, sampleSize]);
140
- var handleDimensionsChange = React.useCallback(function (columnIndex, rowIndex, dimensions) {
141
- if (dimensions.width === undefined) return;
139
+ var handleDimensionsChange = React.useCallback(function (columnIndex, dimensions) {
140
+ var nextWidth = Math.min(Math.max(columns[columnIndex].minWidth || 0, widthMap.get(columnIndex) || 0, dimensions.width + 1), columns[columnIndex].maxWidth || Infinity);
142
141
 
143
- if (columns[columnIndex] === undefined || dimensionsCache.current[columnIndex] === undefined) {
144
- return;
142
+ if (nextWidth !== widthMap.get(columnIndex)) {
143
+ widthMap.set(columnIndex, nextWidth);
145
144
  }
146
145
 
147
- measurementCount.current += 1;
148
- var nextWidth = Math.min(Math.max(columns[columnIndex].minWidth || 0, dimensionsCache.current[columnIndex], dimensions.width + 1), columns[columnIndex].maxWidth || Infinity);
149
-
150
- if (nextWidth !== dimensionsCache.current[columnIndex]) {
151
- var nextWidths = _toConsumableArray(dimensionsCache.current);
152
-
153
- nextWidths[columnIndex] = nextWidth;
154
- dimensionsCache.current = nextWidths;
155
- }
156
-
157
- if (measurementCount.current >= finishedMeasurementCount) {
158
- onWidthsChange(dimensionsCache.current);
146
+ if ( // Refresh at 100% of done
147
+ widthMap.size === columns.length || // ...50%
148
+ widthMap.size === Math.floor(columns.length / 2) || // ...25%
149
+ widthMap.size === Math.floor(columns.length / 4)) {
150
+ onWidthsChange(Array.from(widthMap.values()));
159
151
  }
160
152
  }, [columns, finishedMeasurementCount, onWidthsChange]);
161
153
  var hiddenStyle = css({
162
154
  position: 'absolute',
163
155
  overflow: 'hidden',
164
156
  height: 0
165
- });
157
+ }); // Remove the measurement nodes after we are done updating our column width
166
158
 
167
- if (measurementCount.current >= finishedMeasurementCount) {
159
+ if (widthMap.size === columns.length) {
168
160
  return null;
169
161
  }
170
162
 
@@ -175,45 +167,15 @@ function MeasureColumnWidths(_ref) {
175
167
  className: hiddenStyle,
176
168
  "aria-hidden": true,
177
169
  role: "none"
178
- }, sampleRowIndicesByColumn.map(function (rowIndices, columnIndex) {
179
- var Cell = columns[columnIndex].renderCell;
180
- return rowIndices.map(function (rowIndex) {
181
- return /*#__PURE__*/React.createElement(ElementMeasurer, {
182
- key: "measure-".concat(columnIndex, "-").concat(rowIndex),
183
- onDimensionsChange: function onDimensionsChange(dimensions) {
184
- return handleDimensionsChange(columnIndex, rowIndex, dimensions);
185
- },
186
- item: /*#__PURE__*/React.createElement(Cell, {
187
- value: columns[columnIndex].mapDataToValue(rows[rowIndex].data),
188
- isMeasured: true,
189
- onSelect: isSelectable && columnIndex === 0 ? function () {} : undefined,
190
- x: columnIndex,
191
- y: rowIndex
192
- })
193
- });
194
- });
195
- }), columns.map(function (column, columnIndex) {
196
- return /*#__PURE__*/React.createElement(ElementMeasurer, {
197
- key: "measure-column-".concat(columnIndex),
198
- onDimensionsChange: function onDimensionsChange(dimensions) {
199
- return handleDimensionsChange(columnIndex, -1, dimensions);
200
- },
201
- item: /*#__PURE__*/React.createElement(_headerCell.default, {
202
- index: columnIndex,
203
- isHovered: true,
204
- isMeasured: true,
205
- isSelectable: isSelectable && columnIndex === 0,
206
- isSelectedAll: false,
207
- isSelectedIndeterminate: false,
208
- onMouseEnter: function onMouseEnter() {},
209
- onMouseLeave: function onMouseLeave() {},
210
- onSelectAll: function onSelectAll() {},
211
- onSelectNone: function onSelectNone() {},
212
- onSort: function onSort(i) {},
213
- sortable: column.sortable,
214
- sortDirection: null,
215
- title: column.title
216
- })
170
+ }, columns.map(function (column, i) {
171
+ return /*#__PURE__*/React.createElement(MeasureColumn, {
172
+ key: column.title + i,
173
+ column: column,
174
+ rows: rows,
175
+ isSelectable: isSelectable,
176
+ onLayout: handleDimensionsChange,
177
+ columnIndex: i,
178
+ sampleIndexes: sampleIndexes
217
179
  });
218
180
  }))
219
181
  );
@@ -12,46 +12,69 @@ import {useStyletron} from '../styles/index.js';
12
12
 
13
13
  import HeaderCell from './header-cell.js';
14
14
  import type {ColumnT, RowT} from './types.js';
15
+ import {useRef} from 'react';
15
16
 
16
- // https://github.com/Swizec/useDimensions
17
- function useDimensions() {
18
- const [dimensions, setDimensions] = React.useState({});
19
- const [node, setNode] = React.useState(null);
17
+ // Measures the column header + sampled data
18
+ function MeasureColumn({
19
+ sampleIndexes,
20
+ column,
21
+ columnIndex,
22
+ rows,
23
+ isSelectable,
24
+ onLayout,
25
+ }) {
26
+ const [css] = useStyletron();
20
27
 
21
- const ref = React.useCallback(node => {
22
- setNode(node);
23
- }, []);
28
+ const ref = useRef();
24
29
 
25
30
  React.useEffect(() => {
26
- if (__BROWSER__) {
27
- if (node) {
28
- window.requestAnimationFrame(() => {
29
- setDimensions(node.getBoundingClientRect());
30
- });
31
- }
31
+ if (ref.current) {
32
+ onLayout(columnIndex, ref.current.getBoundingClientRect());
32
33
  }
33
- }, [node]);
34
-
35
- return [ref, dimensions];
36
- }
37
-
38
- type ElementMeasurerPropsT = {
39
- onDimensionsChange: (dimensions: {width: number}) => void,
40
- // eslint-disable-next-line flowtype/no-weak-types
41
- item: React.Element<any>,
42
- };
43
-
44
- function ElementMeasurer(props: ElementMeasurerPropsT) {
45
- const {onDimensionsChange} = props;
46
- const [ref, dimensions] = useDimensions();
47
-
48
- React.useEffect(() => {
49
- onDimensionsChange(dimensions);
50
- }, [dimensions, onDimensionsChange]);
34
+ }, []);
51
35
 
52
- return React.cloneElement(props.item, {ref});
36
+ return (
37
+ <div
38
+ ref={ref}
39
+ className={css({
40
+ display: 'flex',
41
+ flexDirection: 'column',
42
+ width: 'fit-content',
43
+ })}
44
+ >
45
+ <HeaderCell
46
+ index={columnIndex}
47
+ isHovered
48
+ isMeasured
49
+ isSelectedAll={false}
50
+ isSelectedIndeterminate={false}
51
+ onMouseEnter={() => {}}
52
+ onMouseLeave={() => {}}
53
+ onSelectAll={() => {}}
54
+ onSelectNone={() => {}}
55
+ onSort={i => {}}
56
+ sortable={column.sortable}
57
+ sortDirection={null}
58
+ title={column.title}
59
+ isSelectable={isSelectable}
60
+ />
61
+ {sampleIndexes.map((rowIndex, i) => {
62
+ const Cell = column.renderCell;
63
+ return (
64
+ <Cell
65
+ key={`measure-${i}`}
66
+ value={column.mapDataToValue(rows[rowIndex].data)}
67
+ isSelectable={isSelectable}
68
+ isMeasured
69
+ sortable={column.sortable}
70
+ x={0}
71
+ y={rowIndex}
72
+ />
73
+ );
74
+ })}
75
+ </div>
76
+ );
53
77
  }
54
-
55
78
  type MeasureColumnWidthsPropsT = {
56
79
  columns: ColumnT<>[],
57
80
  // if selectable, measure the first column with checkbox included
@@ -61,7 +84,6 @@ type MeasureColumnWidthsPropsT = {
61
84
  widths: number[],
62
85
  };
63
86
 
64
- // sample size could likely be generated based on row count, to have higher confidence
65
87
  const MAX_SAMPLE_SIZE = 50;
66
88
 
67
89
  function generateSampleIndices(inputMin, inputMax, maxSamples) {
@@ -96,51 +118,41 @@ export default function MeasureColumnWidths({
96
118
  }: MeasureColumnWidthsPropsT) {
97
119
  const [css] = useStyletron();
98
120
 
99
- const measurementCount = React.useRef(0);
100
- const dimensionsCache = React.useRef(widths);
121
+ const widthMap = React.useMemo(() => {
122
+ return new Map();
123
+ }, []);
101
124
 
102
125
  const sampleSize =
103
126
  rows.length < MAX_SAMPLE_SIZE ? rows.length : MAX_SAMPLE_SIZE;
104
127
  const finishedMeasurementCount = (sampleSize + 1) * columns.length;
105
128
 
106
- const sampleRowIndicesByColumn = React.useMemo<number[][]>(() => {
107
- measurementCount.current = 0;
108
- dimensionsCache.current = widths;
109
-
110
- const indices = generateSampleIndices(0, rows.length - 1, sampleSize);
111
- return columns.map(() => indices);
129
+ const sampleIndexes = React.useMemo<number[]>(() => {
130
+ return generateSampleIndices(0, rows.length - 1, sampleSize);
112
131
  }, [columns, rows, widths, sampleSize]);
113
132
 
114
133
  const handleDimensionsChange = React.useCallback(
115
- (columnIndex, rowIndex, dimensions) => {
116
- if (dimensions.width === undefined) return;
117
-
118
- if (
119
- columns[columnIndex] === undefined ||
120
- dimensionsCache.current[columnIndex] === undefined
121
- ) {
122
- return;
123
- }
124
-
125
- measurementCount.current += 1;
126
-
134
+ (columnIndex, dimensions) => {
127
135
  const nextWidth = Math.min(
128
136
  Math.max(
129
137
  columns[columnIndex].minWidth || 0,
130
- dimensionsCache.current[columnIndex],
138
+ widthMap.get(columnIndex) || 0,
131
139
  dimensions.width + 1,
132
140
  ),
133
141
  columns[columnIndex].maxWidth || Infinity,
134
142
  );
135
143
 
136
- if (nextWidth !== dimensionsCache.current[columnIndex]) {
137
- const nextWidths = [...dimensionsCache.current];
138
- nextWidths[columnIndex] = nextWidth;
139
- dimensionsCache.current = nextWidths;
144
+ if (nextWidth !== widthMap.get(columnIndex)) {
145
+ widthMap.set(columnIndex, nextWidth);
140
146
  }
141
-
142
- if (measurementCount.current >= finishedMeasurementCount) {
143
- onWidthsChange(dimensionsCache.current);
147
+ if (
148
+ // Refresh at 100% of done
149
+ widthMap.size === columns.length ||
150
+ // ...50%
151
+ widthMap.size === Math.floor(columns.length / 2) ||
152
+ // ...25%
153
+ widthMap.size === Math.floor(columns.length / 4)
154
+ ) {
155
+ onWidthsChange(Array.from(widthMap.values()));
144
156
  }
145
157
  },
146
158
  [columns, finishedMeasurementCount, onWidthsChange],
@@ -152,61 +164,27 @@ export default function MeasureColumnWidths({
152
164
  height: 0,
153
165
  });
154
166
 
155
- if (measurementCount.current >= finishedMeasurementCount) {
167
+ // Remove the measurement nodes after we are done updating our column width
168
+ if (widthMap.size === columns.length) {
156
169
  return null;
157
170
  }
158
171
 
159
172
  return (
160
173
  // eslint-disable-next-line jsx-a11y/role-supports-aria-props
161
174
  <div className={hiddenStyle} aria-hidden role="none">
162
- {sampleRowIndicesByColumn.map((rowIndices, columnIndex) => {
163
- const Cell = columns[columnIndex].renderCell;
164
- return rowIndices.map(rowIndex => (
165
- <ElementMeasurer
166
- key={`measure-${columnIndex}-${rowIndex}`}
167
- onDimensionsChange={dimensions =>
168
- handleDimensionsChange(columnIndex, rowIndex, dimensions)
169
- }
170
- item={
171
- <Cell
172
- value={columns[columnIndex].mapDataToValue(rows[rowIndex].data)}
173
- isMeasured
174
- onSelect={
175
- isSelectable && columnIndex === 0 ? () => {} : undefined
176
- }
177
- x={columnIndex}
178
- y={rowIndex}
179
- />
180
- }
175
+ {columns.map((column, i) => {
176
+ return (
177
+ <MeasureColumn
178
+ key={column.title + i}
179
+ column={column}
180
+ rows={rows}
181
+ isSelectable={isSelectable}
182
+ onLayout={handleDimensionsChange}
183
+ columnIndex={i}
184
+ sampleIndexes={sampleIndexes}
181
185
  />
182
- ));
186
+ );
183
187
  })}
184
- {columns.map((column, columnIndex) => (
185
- <ElementMeasurer
186
- key={`measure-column-${columnIndex}`}
187
- onDimensionsChange={dimensions =>
188
- handleDimensionsChange(columnIndex, -1, dimensions)
189
- }
190
- item={
191
- <HeaderCell
192
- index={columnIndex}
193
- isHovered
194
- isMeasured
195
- isSelectable={isSelectable && columnIndex === 0}
196
- isSelectedAll={false}
197
- isSelectedIndeterminate={false}
198
- onMouseEnter={() => {}}
199
- onMouseLeave={() => {}}
200
- onSelectAll={() => {}}
201
- onSelectNone={() => {}}
202
- onSort={i => {}}
203
- sortable={column.sortable}
204
- sortDirection={null}
205
- title={column.title}
206
- />
207
- }
208
- />
209
- ))}
210
188
  </div>
211
189
  );
212
190
  }
@@ -502,7 +502,7 @@ var StyledDay = (0, _index.styled)('div', function (props) {
502
502
  content: '""',
503
503
  boxSizing: 'border-box',
504
504
  display: 'inline-block',
505
- boxShadow: $isFocusVisible ? "0 0 0 3px ".concat(colors.accent) : 'none',
505
+ boxShadow: $isFocusVisible && (!$outsideMonth || $peekNextMonth) ? "0 0 0 3px ".concat(colors.accent) : 'none',
506
506
  backgroundColor: $selected ? colors.calendarDayBackgroundSelectedHighlighted : $pseudoSelected && $isHighlighted ? colors.calendarDayBackgroundPseudoSelectedHighlighted : colors.calendarBackground,
507
507
  height: $hasDateLabel ? '100%' : $density === _constants.DENSITY.high ? '42px' : '50px',
508
508
  width: '100%',
@@ -496,7 +496,10 @@ export const StyledDay = styled<SharedStylePropsT>('div', props => {
496
496
  content: '""',
497
497
  boxSizing: 'border-box',
498
498
  display: 'inline-block',
499
- boxShadow: $isFocusVisible ? `0 0 0 3px ${colors.accent}` : 'none',
499
+ boxShadow:
500
+ $isFocusVisible && (!$outsideMonth || $peekNextMonth)
501
+ ? `0 0 0 3px ${colors.accent}`
502
+ : 'none',
500
503
  backgroundColor: $selected
501
504
  ? colors.calendarDayBackgroundSelectedHighlighted
502
505
  : $pseudoSelected && $isHighlighted
package/drawer/drawer.js CHANGED
@@ -340,7 +340,9 @@ var Drawer = /*#__PURE__*/function (_React$Component) {
340
340
 
341
341
  var sharedProps = this.getSharedProps();
342
342
  return /*#__PURE__*/React.createElement(_index.LocaleContext.Consumer, null, function (locale) {
343
- return /*#__PURE__*/React.createElement(_reactFocusLock.default, {
343
+ return /*#__PURE__*/React.createElement(_reactFocusLock.default // Allow focus to escape when UI is within an iframe
344
+ , {
345
+ crossFrame: false,
344
346
  returnFocus: true,
345
347
  autoFocus: autoFocus,
346
348
  noFocusGuards: true
@@ -253,7 +253,13 @@ class Drawer extends React.Component<DrawerPropsT, DrawerStateT> {
253
253
  <LocaleContext.Consumer>
254
254
  {locale => {
255
255
  return (
256
- <FocusLock returnFocus autoFocus={autoFocus} noFocusGuards={true}>
256
+ <FocusLock
257
+ // Allow focus to escape when UI is within an iframe
258
+ crossFrame={false}
259
+ returnFocus
260
+ autoFocus={autoFocus}
261
+ noFocusGuards={true}
262
+ >
257
263
  <Root
258
264
  data-baseweb="drawer"
259
265
  ref={this.getRef('Root')}
package/es/a11y/a11y.js CHANGED
@@ -9,7 +9,7 @@ LICENSE file in the root directory of this source tree.
9
9
  import * as React from 'react';
10
10
  import axe from 'axe-core';
11
11
  import { Layer, TetherBehavior, TETHER_PLACEMENT } from '../layer/index.js';
12
- import { Paragraph3, Caption1 } from '../typography/index.js';
12
+ import { ParagraphSmall, ParagraphXSmall } from '../typography/index.js';
13
13
  import { styled } from '../styles/index.js';
14
14
  import { ThemeContext } from '../styles/theme-provider.js';
15
15
 
@@ -95,7 +95,7 @@ function Violation(props) {
95
95
  ref: setPopper,
96
96
  $top: `${offset.top}px` || '0px',
97
97
  $left: `${offset.left}px` || '0px'
98
- }, /*#__PURE__*/React.createElement(Caption1, null, props.target), props.violations.map((violation, index) => /*#__PURE__*/React.createElement(Paragraph3, {
98
+ }, /*#__PURE__*/React.createElement(ParagraphXSmall, null, props.target), props.violations.map((violation, index) => /*#__PURE__*/React.createElement(ParagraphSmall, {
99
99
  key: index
100
100
  }, violation.description)))));
101
101
  }
@@ -39,8 +39,12 @@ export const BaseButton = styled('button', ({
39
39
  cursor: 'pointer',
40
40
  ':disabled': {
41
41
  cursor: 'not-allowed',
42
- backgroundColor: $kind === KIND.minimal || $kind === KIND.tertiary ? 'transparent' : $theme.colors.buttonDisabledFill,
43
- color: $theme.colors.buttonDisabledText
42
+ ...getDisabledStyles({
43
+ $theme,
44
+ $kind,
45
+ $disabled,
46
+ $isSelected
47
+ })
44
48
  },
45
49
  marginLeft: 0,
46
50
  marginTop: 0,
@@ -272,6 +276,32 @@ function getFontStyles({
272
276
  }
273
277
  }
274
278
 
279
+ function getDisabledStyles({
280
+ $theme,
281
+ $kind,
282
+ $isSelected,
283
+ $disabled
284
+ }) {
285
+ if ($disabled && $isSelected) {
286
+ if ($kind === KIND.primary || $kind === KIND.secondary) {
287
+ return {
288
+ color: $theme.colors.buttonDisabledActiveText,
289
+ backgroundColor: $theme.colors.buttonDisabledActiveFill
290
+ };
291
+ } else if ($kind === KIND.minimal || $kind === KIND.tertiary) {
292
+ return {
293
+ backgroundColor: $theme.colors.buttonTertiaryDisabledActiveFill,
294
+ color: $theme.colors.buttonTertiaryDisabledActiveText
295
+ };
296
+ }
297
+ }
298
+
299
+ return {
300
+ backgroundColor: $kind === KIND.minimal || $kind === KIND.tertiary ? 'transparent' : $theme.colors.buttonDisabledFill,
301
+ color: $theme.colors.buttonDisabledText
302
+ };
303
+ }
304
+
275
305
  function getPaddingStyles({
276
306
  $theme,
277
307
  $size,
@@ -28,6 +28,7 @@ function Combobox(props) {
28
28
  onChange,
29
29
  onFocus,
30
30
  onSubmit,
31
+ listBoxLabel,
31
32
  mapOptionToNode,
32
33
  mapOptionToString,
33
34
  id,
@@ -251,6 +252,7 @@ function Combobox(props) {
251
252
  ,
252
253
  ref: listboxRef,
253
254
  role: "listbox",
255
+ "aria-label": listBoxLabel,
254
256
  $width: listboxWidth
255
257
  }, listBoxProps), options.map((option, index) => {
256
258
  const isSelected = selectionIndex === index;
@@ -287,9 +289,8 @@ function Combobox(props) {
287
289
  role: "combobox"
288
290
  }, inputContainerProps), /*#__PURE__*/React.createElement(OverriddenInput, _extends({
289
291
  inputRef: handleInputRef,
290
- "aria-activedescendant": selectionIndex >= 0 ? activeDescendantId : undefined,
292
+ "aria-activedescendant": isOpen && selectionIndex >= 0 ? activeDescendantId : undefined,
291
293
  "aria-autocomplete": "list",
292
- "aria-controls": listboxId,
293
294
  disabled: disabled,
294
295
  error: error,
295
296
  name: name,
@@ -302,7 +303,9 @@ function Combobox(props) {
302
303
  positive: positive,
303
304
  size: size,
304
305
  value: tempValue ? tempValue : value
305
- }, restInputProps)))));
306
+ }, isOpen ? {
307
+ 'aria-controls': listboxId
308
+ } : {}, restInputProps)))));
306
309
  }
307
310
 
308
311
  export default Combobox;