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.
- package/a11y/a11y.js +2 -2
- package/a11y/a11y.js.flow +3 -3
- package/button/styled-components.js +47 -18
- package/button/styled-components.js.flow +25 -5
- package/combobox/combobox.js +6 -3
- package/combobox/combobox.js.flow +4 -2
- package/combobox/types.js.flow +2 -0
- package/data-table/column-categorical.js +1 -1
- package/data-table/column-categorical.js.flow +2 -2
- package/data-table/column-numerical.js +307 -355
- package/data-table/column-numerical.js.flow +273 -287
- package/data-table/constants.js +17 -11
- package/data-table/constants.js.flow +11 -8
- package/data-table/data-table.js +53 -50
- package/data-table/data-table.js.flow +18 -13
- package/data-table/filter-shell.js +27 -4
- package/data-table/filter-shell.js.flow +33 -9
- package/data-table/locale.js +4 -2
- package/data-table/locale.js.flow +6 -2
- package/data-table/measure-column-widths.js +83 -121
- package/data-table/measure-column-widths.js.flow +87 -109
- package/datepicker/styled-components.js +1 -1
- package/datepicker/styled-components.js.flow +4 -1
- package/drawer/drawer.js +3 -1
- package/drawer/drawer.js.flow +7 -1
- package/es/a11y/a11y.js +2 -2
- package/es/button/styled-components.js +32 -2
- package/es/combobox/combobox.js +6 -3
- package/es/data-table/column-categorical.js +2 -2
- package/es/data-table/column-numerical.js +245 -317
- package/es/data-table/constants.js +12 -8
- package/es/data-table/data-table.js +18 -16
- package/es/data-table/filter-shell.js +26 -4
- package/es/data-table/locale.js +4 -2
- package/es/data-table/measure-column-widths.js +75 -86
- package/es/datepicker/styled-components.js +1 -1
- package/es/drawer/drawer.js +3 -1
- package/es/index.js +1 -1
- package/es/map-marker/badge-enhancer.js +61 -0
- package/es/map-marker/constants.js +146 -2
- package/es/map-marker/drag-shadow.js +32 -0
- package/es/map-marker/fixed-marker.js +54 -48
- package/es/map-marker/floating-marker.js +21 -12
- package/es/map-marker/index.js +1 -1
- package/es/map-marker/label-enhancer.js +39 -0
- package/es/map-marker/needle.js +26 -0
- package/es/map-marker/pin-head.js +42 -40
- package/es/map-marker/styled-components.js +177 -32
- package/es/map-marker/types.js +1 -1
- package/es/menu/maybe-child-menu.js +0 -2
- package/es/menu/nested-menus.js +49 -3
- package/es/menu/stateful-container.js +13 -12
- package/es/modal/modal.js +3 -1
- package/es/popover/popover.js +3 -1
- package/es/progress-bar/index.js +1 -1
- package/es/progress-bar/progressbar.js +25 -10
- package/es/progress-bar/styled-components.js +9 -5
- package/es/select/select-component.js +2 -10
- package/es/spinner/styled-components.js +34 -16
- package/es/table/filter.js +3 -1
- package/es/themes/dark-theme/color-component-tokens.js +4 -0
- package/es/themes/light-theme/color-component-tokens.js +4 -0
- package/es/timezonepicker/timezone-picker.js +53 -36
- package/es/timezonepicker/tzdata.js +2 -0
- package/es/timezonepicker/update-tzdata.js +69 -0
- package/esm/a11y/a11y.js +3 -3
- package/esm/button/styled-components.js +47 -18
- package/esm/combobox/combobox.js +6 -3
- package/esm/data-table/column-categorical.js +2 -2
- package/esm/data-table/column-numerical.js +304 -353
- package/esm/data-table/constants.js +12 -8
- package/esm/data-table/data-table.js +53 -50
- package/esm/data-table/filter-shell.js +26 -4
- package/esm/data-table/locale.js +4 -2
- package/esm/data-table/measure-column-widths.js +83 -121
- package/esm/datepicker/styled-components.js +1 -1
- package/esm/drawer/drawer.js +3 -1
- package/esm/index.js +1 -1
- package/esm/map-marker/badge-enhancer.js +79 -0
- package/esm/map-marker/constants.js +94 -4
- package/esm/map-marker/drag-shadow.js +53 -0
- package/esm/map-marker/fixed-marker.js +84 -80
- package/esm/map-marker/floating-marker.js +22 -13
- package/esm/map-marker/index.js +1 -1
- package/esm/map-marker/label-enhancer.js +60 -0
- package/esm/map-marker/needle.js +43 -0
- package/esm/map-marker/pin-head.js +77 -66
- package/esm/map-marker/styled-components.js +182 -51
- package/esm/map-marker/types.js +1 -1
- package/esm/menu/maybe-child-menu.js +0 -2
- package/esm/menu/nested-menus.js +66 -5
- package/esm/menu/stateful-container.js +15 -13
- package/esm/modal/modal.js +3 -1
- package/esm/popover/popover.js +3 -1
- package/esm/progress-bar/index.js +1 -1
- package/esm/progress-bar/progressbar.js +32 -10
- package/esm/progress-bar/styled-components.js +9 -4
- package/esm/select/select-component.js +2 -11
- package/esm/spinner/styled-components.js +35 -16
- package/esm/table/filter.js +3 -1
- package/esm/themes/dark-theme/color-component-tokens.js +4 -0
- package/esm/themes/light-theme/color-component-tokens.js +4 -0
- package/esm/timezonepicker/timezone-picker.js +64 -36
- package/esm/timezonepicker/tzdata.js +2 -0
- package/esm/timezonepicker/update-tzdata.js +160 -0
- package/index.js +6 -0
- package/index.js.flow +1 -1
- package/map-marker/badge-enhancer.js +90 -0
- package/map-marker/badge-enhancer.js.flow +86 -0
- package/map-marker/constants.js +103 -5
- package/map-marker/constants.js.flow +152 -0
- package/map-marker/drag-shadow.js +64 -0
- package/map-marker/drag-shadow.js.flow +52 -0
- package/map-marker/fixed-marker.js +84 -78
- package/map-marker/fixed-marker.js.flow +78 -66
- package/map-marker/floating-marker.js +22 -13
- package/map-marker/floating-marker.js.flow +30 -17
- package/map-marker/index.d.ts +125 -24
- package/map-marker/index.js +18 -0
- package/map-marker/index.js.flow +3 -0
- package/map-marker/label-enhancer.js +71 -0
- package/map-marker/label-enhancer.js.flow +63 -0
- package/map-marker/needle.js +54 -0
- package/map-marker/needle.js.flow +29 -0
- package/map-marker/pin-head.js +80 -69
- package/map-marker/pin-head.js.flow +122 -84
- package/map-marker/styled-components.js +200 -62
- package/map-marker/styled-components.js.flow +172 -22
- package/map-marker/types.js.flow +69 -20
- package/menu/index.d.ts +9 -4
- package/menu/maybe-child-menu.js +0 -2
- package/menu/maybe-child-menu.js.flow +0 -2
- package/menu/nested-menus.js +66 -5
- package/menu/nested-menus.js.flow +50 -5
- package/menu/stateful-container.js +15 -13
- package/menu/stateful-container.js.flow +19 -13
- package/menu/types.js.flow +7 -1
- package/modal/modal.js +3 -1
- package/modal/modal.js.flow +2 -0
- package/package.json +5 -4
- package/popover/popover.js +3 -1
- package/popover/popover.js.flow +2 -0
- package/progress-bar/index.d.ts +2 -0
- package/progress-bar/index.js +6 -0
- package/progress-bar/index.js.flow +1 -0
- package/progress-bar/progressbar.js +32 -10
- package/progress-bar/progressbar.js.flow +35 -9
- package/progress-bar/styled-components.js +9 -4
- package/progress-bar/styled-components.js.flow +15 -4
- package/progress-bar/types.js.flow +12 -2
- package/select/select-component.js +2 -11
- package/select/select-component.js.flow +5 -7
- package/spinner/styled-components.js +35 -16
- package/spinner/styled-components.js.flow +37 -19
- package/spinner/types.js.flow +10 -0
- package/styles/index.js.flow +1 -1
- package/table/filter.js +3 -1
- package/table/filter.js.flow +5 -1
- package/themes/dark-theme/color-component-tokens.js +4 -0
- package/themes/dark-theme/color-component-tokens.js.flow +4 -0
- package/themes/light-theme/color-component-tokens.js +4 -0
- package/themes/light-theme/color-component-tokens.js.flow +4 -0
- package/themes/types.js.flow +4 -0
- package/timezonepicker/timezone-picker.js +69 -41
- package/timezonepicker/timezone-picker.js.flow +52 -46
- package/timezonepicker/types.js.flow +1 -1
- package/timezonepicker/tzdata.js +10 -0
- package/timezonepicker/tzdata.js.flow +347 -0
- package/timezonepicker/update-tzdata.js +164 -0
- package/timezonepicker/update-tzdata.js.flow +70 -0
|
@@ -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
|
-
//
|
|
43
|
-
function
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
|
50
|
-
|
|
51
|
-
|
|
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.
|
|
55
|
-
setNode(node);
|
|
56
|
-
}, []);
|
|
47
|
+
var ref = (0, React.useRef)();
|
|
57
48
|
React.useEffect(function () {
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
window.requestAnimationFrame(function () {
|
|
61
|
-
setDimensions(node.getBoundingClientRect());
|
|
62
|
-
});
|
|
63
|
-
}
|
|
49
|
+
if (ref.current) {
|
|
50
|
+
onLayout(columnIndex, ref.current.getBoundingClientRect());
|
|
64
51
|
}
|
|
65
|
-
}, [
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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(
|
|
118
|
-
var columns =
|
|
119
|
-
rows =
|
|
120
|
-
widths =
|
|
121
|
-
isSelectable =
|
|
122
|
-
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
|
|
125
|
-
|
|
126
|
-
css =
|
|
127
|
+
var _useStyletron3 = (0, _index.useStyletron)(),
|
|
128
|
+
_useStyletron4 = _slicedToArray(_useStyletron3, 1),
|
|
129
|
+
css = _useStyletron4[0];
|
|
127
130
|
|
|
128
|
-
var
|
|
129
|
-
|
|
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
|
|
133
|
-
|
|
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,
|
|
141
|
-
|
|
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 (
|
|
144
|
-
|
|
142
|
+
if (nextWidth !== widthMap.get(columnIndex)) {
|
|
143
|
+
widthMap.set(columnIndex, nextWidth);
|
|
145
144
|
}
|
|
146
145
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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 (
|
|
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
|
-
},
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
//
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
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 =
|
|
22
|
-
setNode(node);
|
|
23
|
-
}, []);
|
|
28
|
+
const ref = useRef();
|
|
24
29
|
|
|
25
30
|
React.useEffect(() => {
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
window.requestAnimationFrame(() => {
|
|
29
|
-
setDimensions(node.getBoundingClientRect());
|
|
30
|
-
});
|
|
31
|
-
}
|
|
31
|
+
if (ref.current) {
|
|
32
|
+
onLayout(columnIndex, ref.current.getBoundingClientRect());
|
|
32
33
|
}
|
|
33
|
-
}, [
|
|
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
|
|
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
|
|
100
|
-
|
|
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
|
|
107
|
-
|
|
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,
|
|
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
|
-
|
|
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 !==
|
|
137
|
-
|
|
138
|
-
nextWidths[columnIndex] = nextWidth;
|
|
139
|
-
dimensionsCache.current = nextWidths;
|
|
144
|
+
if (nextWidth !== widthMap.get(columnIndex)) {
|
|
145
|
+
widthMap.set(columnIndex, nextWidth);
|
|
140
146
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
|
|
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
|
-
{
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
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:
|
|
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
|
package/drawer/drawer.js.flow
CHANGED
|
@@ -253,7 +253,13 @@ class Drawer extends React.Component<DrawerPropsT, DrawerStateT> {
|
|
|
253
253
|
<LocaleContext.Consumer>
|
|
254
254
|
{locale => {
|
|
255
255
|
return (
|
|
256
|
-
<FocusLock
|
|
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 {
|
|
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(
|
|
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
|
-
|
|
43
|
-
|
|
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,
|
package/es/combobox/combobox.js
CHANGED
|
@@ -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
|
-
},
|
|
306
|
+
}, isOpen ? {
|
|
307
|
+
'aria-controls': listboxId
|
|
308
|
+
} : {}, restInputProps)))));
|
|
306
309
|
}
|
|
307
310
|
|
|
308
311
|
export default Combobox;
|