@elastic/eui 97.2.0 → 97.3.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/es/components/context_menu/context_menu_panel.js +17 -1
- package/es/components/datagrid/body/cell/data_grid_cell.js +31 -8
- package/es/components/datagrid/body/data_grid_body.js +8 -0
- package/es/components/datagrid/body/data_grid_body_custom.js +8 -1
- package/es/components/datagrid/body/data_grid_body_virtualized.js +8 -1
- package/es/components/datagrid/controls/data_grid_toolbar.styles.js +2 -2
- package/es/components/datagrid/controls/display_selector.js +277 -207
- package/es/components/datagrid/data_grid.stories.utils.js +28 -2
- package/es/components/datagrid/data_grid.styles.js +1 -1
- package/es/components/datagrid/utils/grid_height_width.js +1 -1
- package/es/components/datagrid/utils/row_heights.js +29 -13
- package/es/components/header/header.styles.js +8 -1
- package/es/services/hooks/useDeepEqual.js +18 -6
- package/eui.d.ts +38 -10
- package/i18ntokens.json +88 -106
- package/lib/components/context_menu/context_menu_panel.js +17 -1
- package/lib/components/datagrid/body/cell/data_grid_cell.js +31 -8
- package/lib/components/datagrid/body/data_grid_body.js +8 -0
- package/lib/components/datagrid/body/data_grid_body_custom.js +8 -1
- package/lib/components/datagrid/body/data_grid_body_virtualized.js +8 -1
- package/lib/components/datagrid/controls/data_grid_toolbar.styles.js +2 -2
- package/lib/components/datagrid/controls/display_selector.js +275 -204
- package/lib/components/datagrid/data_grid.stories.utils.js +28 -2
- package/lib/components/datagrid/data_grid.styles.js +1 -1
- package/lib/components/datagrid/utils/grid_height_width.js +1 -1
- package/lib/components/datagrid/utils/row_heights.js +29 -13
- package/lib/components/header/header.styles.js +8 -1
- package/lib/services/hooks/useDeepEqual.js +17 -7
- package/optimize/es/components/context_menu/context_menu_panel.js +11 -1
- package/optimize/es/components/datagrid/body/cell/data_grid_cell.js +15 -8
- package/optimize/es/components/datagrid/body/data_grid_body_custom.js +0 -1
- package/optimize/es/components/datagrid/body/data_grid_body_virtualized.js +0 -1
- package/optimize/es/components/datagrid/controls/data_grid_toolbar.styles.js +2 -2
- package/optimize/es/components/datagrid/controls/display_selector.js +277 -207
- package/optimize/es/components/datagrid/data_grid.styles.js +1 -1
- package/optimize/es/components/datagrid/utils/grid_height_width.js +1 -1
- package/optimize/es/components/datagrid/utils/row_heights.js +29 -13
- package/optimize/es/components/header/header.styles.js +8 -1
- package/optimize/es/services/hooks/useDeepEqual.js +13 -6
- package/optimize/lib/components/context_menu/context_menu_panel.js +11 -1
- package/optimize/lib/components/datagrid/body/cell/data_grid_cell.js +15 -8
- package/optimize/lib/components/datagrid/body/data_grid_body_custom.js +0 -1
- package/optimize/lib/components/datagrid/body/data_grid_body_virtualized.js +0 -1
- package/optimize/lib/components/datagrid/controls/data_grid_toolbar.styles.js +2 -2
- package/optimize/lib/components/datagrid/controls/display_selector.js +274 -204
- package/optimize/lib/components/datagrid/data_grid.styles.js +1 -1
- package/optimize/lib/components/datagrid/utils/grid_height_width.js +1 -1
- package/optimize/lib/components/datagrid/utils/row_heights.js +29 -13
- package/optimize/lib/components/header/header.styles.js +8 -1
- package/optimize/lib/services/hooks/useDeepEqual.js +12 -5
- package/package.json +1 -1
- package/test-env/components/context_menu/context_menu_panel.js +17 -1
- package/test-env/components/datagrid/body/cell/data_grid_cell.js +31 -8
- package/test-env/components/datagrid/body/data_grid_body.js +8 -0
- package/test-env/components/datagrid/body/data_grid_body_custom.js +8 -1
- package/test-env/components/datagrid/body/data_grid_body_virtualized.js +8 -1
- package/test-env/components/datagrid/controls/data_grid_toolbar.styles.js +2 -2
- package/test-env/components/datagrid/controls/display_selector.js +274 -204
- package/test-env/components/datagrid/data_grid.stories.utils.js +28 -2
- package/test-env/components/datagrid/data_grid.styles.js +1 -1
- package/test-env/components/datagrid/utils/grid_height_width.js +1 -1
- package/test-env/components/datagrid/utils/row_heights.js +29 -13
- package/test-env/components/header/header.styles.js +8 -1
- package/test-env/services/hooks/useDeepEqual.js +12 -5
|
@@ -8,9 +8,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.useDataGridDisplaySelector = exports.startingStyles = void 0;
|
|
9
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
11
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
14
15
|
var _global_styling = require("../../../global_styling");
|
|
15
16
|
var _services = require("../../../services");
|
|
16
17
|
var _i18n = require("../../i18n");
|
|
@@ -27,7 +28,8 @@ var _excluded = ["onChange"],
|
|
|
27
28
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
28
29
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
29
30
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
30
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
31
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
32
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; } /*
|
|
31
33
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
32
34
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
33
35
|
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
@@ -44,8 +46,12 @@ var startingStyles = exports.startingStyles = {
|
|
|
44
46
|
footer: 'overline',
|
|
45
47
|
stickyFooter: true
|
|
46
48
|
};
|
|
49
|
+
var emptyRowHeightsOptions = {};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Cell density
|
|
53
|
+
*/
|
|
47
54
|
|
|
48
|
-
// These are the available options. They power the gridDensity hook and also the options in the render
|
|
49
55
|
var densityOptions = ['compact', 'normal', 'expanded'];
|
|
50
56
|
var densityStyles = {
|
|
51
57
|
expanded: {
|
|
@@ -67,143 +73,274 @@ var convertGridStylesToSelection = function convertGridStylesToSelection(gridSty
|
|
|
67
73
|
if (gridStyles.fontSize === 'l' && gridStyles.cellPadding === 'l') return 'expanded';
|
|
68
74
|
return '';
|
|
69
75
|
};
|
|
76
|
+
var DensityControl = function DensityControl(_ref) {
|
|
77
|
+
var gridStyles = _ref.gridStyles,
|
|
78
|
+
onChange = _ref.onChange;
|
|
79
|
+
var getDensity = (0, _react.useMemo)(function () {
|
|
80
|
+
return convertGridStylesToSelection(gridStyles);
|
|
81
|
+
}, [gridStyles]);
|
|
82
|
+
var setDensity = (0, _react.useCallback)(function (density) {
|
|
83
|
+
onChange(densityStyles[density]);
|
|
84
|
+
}, [onChange]);
|
|
85
|
+
return (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
86
|
+
tokens: ['euiDisplaySelector.densityLabel', 'euiDisplaySelector.labelCompact', 'euiDisplaySelector.labelNormal', 'euiDisplaySelector.labelExpanded'],
|
|
87
|
+
defaults: ['Density', 'Compact', 'Normal', 'Expanded']
|
|
88
|
+
}, function (_ref2) {
|
|
89
|
+
var _ref3 = (0, _slicedToArray2.default)(_ref2, 4),
|
|
90
|
+
densityLabel = _ref3[0],
|
|
91
|
+
labelCompact = _ref3[1],
|
|
92
|
+
labelNormal = _ref3[2],
|
|
93
|
+
labelExpanded = _ref3[3];
|
|
94
|
+
return (0, _react2.jsx)(_form.EuiFormRow, {
|
|
95
|
+
label: densityLabel,
|
|
96
|
+
display: "columnCompressed"
|
|
97
|
+
}, (0, _react2.jsx)(_button.EuiButtonGroup, {
|
|
98
|
+
legend: densityLabel,
|
|
99
|
+
buttonSize: "compressed",
|
|
100
|
+
isFullWidth: true,
|
|
101
|
+
options: [{
|
|
102
|
+
id: densityOptions[0],
|
|
103
|
+
label: labelCompact
|
|
104
|
+
}, {
|
|
105
|
+
id: densityOptions[1],
|
|
106
|
+
label: labelNormal
|
|
107
|
+
}, {
|
|
108
|
+
id: densityOptions[2],
|
|
109
|
+
label: labelExpanded
|
|
110
|
+
}],
|
|
111
|
+
onChange: setDensity,
|
|
112
|
+
idSelected: getDensity,
|
|
113
|
+
"data-test-subj": "densityButtonGroup"
|
|
114
|
+
}));
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Row heights
|
|
120
|
+
*/
|
|
70
121
|
|
|
71
|
-
|
|
72
|
-
var rowHeightButtonOptions = ['undefined', 'auto', 'lineCount'];
|
|
122
|
+
var rowHeightSelectionOptions = ['auto', 'static'];
|
|
73
123
|
var convertRowHeightsOptionsToSelection = function convertRowHeightsOptionsToSelection(rowHeightsOptions) {
|
|
74
124
|
var defaultHeight = rowHeightsOptions.defaultHeight;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
if ((0, _typeof2.default)(defaultHeight) === 'object' && defaultHeight !== null && defaultHeight !== void 0 && defaultHeight.lineCount) {
|
|
79
|
-
return rowHeightButtonOptions[2];
|
|
80
|
-
}
|
|
125
|
+
|
|
126
|
+
// Custom pixel row height values don't have a corresponding UI element
|
|
81
127
|
if (typeof defaultHeight === 'number' || (0, _typeof2.default)(defaultHeight) === 'object' && defaultHeight.height) {
|
|
82
128
|
return '';
|
|
83
129
|
}
|
|
84
|
-
|
|
130
|
+
if (defaultHeight === 'auto') {
|
|
131
|
+
return rowHeightSelectionOptions[0];
|
|
132
|
+
}
|
|
133
|
+
return rowHeightSelectionOptions[1];
|
|
134
|
+
};
|
|
135
|
+
var _ref7 = process.env.NODE_ENV === "production" ? {
|
|
136
|
+
name: "ueqtrq-RowHeightControl",
|
|
137
|
+
styles: "flex-shrink:0;flex-basis:66.6%;label:RowHeightControl;"
|
|
138
|
+
} : {
|
|
139
|
+
name: "ueqtrq-RowHeightControl",
|
|
140
|
+
styles: "flex-shrink:0;flex-basis:66.6%;label:RowHeightControl;",
|
|
141
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
85
142
|
};
|
|
86
|
-
var
|
|
87
|
-
var
|
|
88
|
-
|
|
89
|
-
var
|
|
143
|
+
var RowHeightControl = function RowHeightControl(_ref4) {
|
|
144
|
+
var rowHeightsOptions = _ref4.rowHeightsOptions,
|
|
145
|
+
onChange = _ref4.onChange;
|
|
146
|
+
var autoBelowLineCount = rowHeightsOptions.autoBelowLineCount;
|
|
147
|
+
var _useState = (0, _react.useState)(1),
|
|
90
148
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
var
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
setUserRowHeightsOptions = _useState6[1];
|
|
107
|
-
|
|
108
|
-
// Density logic
|
|
109
|
-
var setGridStyles = (0, _react.useCallback)(function (density) {
|
|
110
|
-
setUserGridStyles(densityStyles[density]);
|
|
111
|
-
}, []);
|
|
149
|
+
lineCountInput = _useState2[0],
|
|
150
|
+
setLineCountInput = _useState2[1];
|
|
151
|
+
var setLineCountHeight = (0, _react.useCallback)(function (event) {
|
|
152
|
+
var newLineCount = Number(event.currentTarget.value);
|
|
153
|
+
setLineCountInput(newLineCount);
|
|
154
|
+
onChange({
|
|
155
|
+
rowHeights: {},
|
|
156
|
+
// Unset all row-specific line counts
|
|
157
|
+
defaultHeight: newLineCount > 1 ? {
|
|
158
|
+
lineCount: newLineCount
|
|
159
|
+
} : undefined // lineCount: 1 is the same as undefined, and this helps correctly display the reset button
|
|
160
|
+
});
|
|
161
|
+
}, [onChange]);
|
|
162
|
+
(0, _react.useEffect)(function () {
|
|
163
|
+
var passedLineCount = (0, _typeof2.default)(rowHeightsOptions === null || rowHeightsOptions === void 0 ? void 0 : rowHeightsOptions.defaultHeight) === 'object' ? rowHeightsOptions.defaultHeight.lineCount : undefined;
|
|
112
164
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
165
|
+
// If lineCount updates come in from consumer changes, update the input to reflect that
|
|
166
|
+
if (passedLineCount) {
|
|
167
|
+
setLineCountInput(passedLineCount);
|
|
168
|
+
}
|
|
169
|
+
// If set back to undefined/single line height (typically from the reset button)
|
|
170
|
+
if ((rowHeightsOptions === null || rowHeightsOptions === void 0 ? void 0 : rowHeightsOptions.defaultHeight) === undefined) {
|
|
171
|
+
setLineCountInput(1);
|
|
172
|
+
}
|
|
173
|
+
}, [rowHeightsOptions === null || rowHeightsOptions === void 0 ? void 0 : rowHeightsOptions.defaultHeight]);
|
|
174
|
+
var rowHeightSelection = (0, _react.useMemo)(function () {
|
|
175
|
+
return convertRowHeightsOptionsToSelection(rowHeightsOptions);
|
|
176
|
+
}, [rowHeightsOptions]);
|
|
118
177
|
var setRowHeight = (0, _react.useCallback)(function (option) {
|
|
119
178
|
var rowHeightsOptions = {
|
|
120
179
|
rowHeights: {} // Unset all row-specific heights
|
|
121
180
|
};
|
|
122
|
-
if (option ===
|
|
181
|
+
if (option === rowHeightSelectionOptions[0]) {
|
|
123
182
|
rowHeightsOptions.defaultHeight = 'auto';
|
|
124
|
-
} else if (option ===
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
setLineCountInput(event.currentTarget.value);
|
|
135
|
-
var newLineCount = Number(event.currentTarget.value);
|
|
136
|
-
|
|
137
|
-
// Don't let users set a 0 or negative line count
|
|
138
|
-
if (newLineCount > 0) {
|
|
139
|
-
setUserRowHeightsOptions({
|
|
140
|
-
rowHeights: {},
|
|
141
|
-
// Unset all row-specific line counts
|
|
142
|
-
defaultHeight: {
|
|
143
|
-
lineCount: newLineCount
|
|
144
|
-
}
|
|
145
|
-
});
|
|
183
|
+
} else if (option === rowHeightSelectionOptions[1]) {
|
|
184
|
+
var lineCount = Number(lineCountInput);
|
|
185
|
+
if (lineCount > 1) {
|
|
186
|
+
rowHeightsOptions.defaultHeight = {
|
|
187
|
+
lineCount: lineCount
|
|
188
|
+
};
|
|
189
|
+
} else {
|
|
190
|
+
// lineCount: 1 is the same as single/undefined
|
|
191
|
+
rowHeightsOptions.defaultHeight = undefined;
|
|
192
|
+
}
|
|
146
193
|
}
|
|
147
|
-
|
|
194
|
+
onChange(rowHeightsOptions);
|
|
195
|
+
}, [lineCountInput, onChange]);
|
|
196
|
+
return (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
197
|
+
tokens: ['euiDisplaySelector.rowHeightLabel', 'euiDisplaySelector.labelAuto', 'euiDisplaySelector.labelStatic', 'euiDisplaySelector.labelMax'],
|
|
198
|
+
defaults: ['Lines per row', 'Auto', 'Static', 'Max']
|
|
199
|
+
}, function (_ref5) {
|
|
200
|
+
var _ref6 = (0, _slicedToArray2.default)(_ref5, 4),
|
|
201
|
+
rowHeightLabel = _ref6[0],
|
|
202
|
+
labelAuto = _ref6[1],
|
|
203
|
+
labelStatic = _ref6[2],
|
|
204
|
+
labelMax = _ref6[3];
|
|
205
|
+
return (0, _react2.jsx)(_form.EuiFormRow, {
|
|
206
|
+
label: rowHeightLabel,
|
|
207
|
+
display: "columnCompressed"
|
|
208
|
+
}, (0, _react2.jsx)(_flex.EuiFlexGroup, {
|
|
209
|
+
gutterSize: "s",
|
|
210
|
+
responsive: false
|
|
211
|
+
}, (0, _react2.jsx)(_button.EuiButtonGroup, {
|
|
212
|
+
legend: rowHeightLabel,
|
|
213
|
+
css: _ref7,
|
|
214
|
+
buttonSize: "compressed",
|
|
215
|
+
isFullWidth: true,
|
|
216
|
+
options: [{
|
|
217
|
+
id: rowHeightSelectionOptions[0],
|
|
218
|
+
label: labelAuto
|
|
219
|
+
}, {
|
|
220
|
+
id: rowHeightSelectionOptions[1],
|
|
221
|
+
label: autoBelowLineCount ? labelMax : labelStatic
|
|
222
|
+
}],
|
|
223
|
+
onChange: setRowHeight,
|
|
224
|
+
idSelected: rowHeightSelection,
|
|
225
|
+
"data-test-subj": "rowHeightButtonGroup"
|
|
226
|
+
}), (0, _react2.jsx)(_form.EuiFieldNumber, {
|
|
227
|
+
"aria-label": rowHeightLabel,
|
|
228
|
+
compressed: true,
|
|
229
|
+
min: 1,
|
|
230
|
+
max: 20,
|
|
231
|
+
disabled: rowHeightSelection !== rowHeightSelectionOptions[1],
|
|
232
|
+
value: lineCountInput,
|
|
233
|
+
onChange: setLineCountHeight,
|
|
234
|
+
"data-test-subj": "lineCountNumber"
|
|
235
|
+
})));
|
|
236
|
+
});
|
|
237
|
+
};
|
|
148
238
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}, [initialStyles, userGridStyles]);
|
|
153
|
-
var rowHeightsOptions = (0, _react.useMemo)(function () {
|
|
154
|
-
return _objectSpread(_objectSpread({}, initialRowHeightsOptions), userRowHeightsOptions);
|
|
155
|
-
}, [initialRowHeightsOptions, userRowHeightsOptions]);
|
|
239
|
+
/**
|
|
240
|
+
* Display settings/selector popover
|
|
241
|
+
*/
|
|
156
242
|
|
|
157
|
-
|
|
158
|
-
var
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
// @ts-ignore - optional chaining operator handles types & cases that aren't lineCount
|
|
168
|
-
(rowHeightsOptions === null || rowHeightsOptions === void 0 || (_rowHeightsOptions$de = rowHeightsOptions.defaultHeight) === null || _rowHeightsOptions$de === void 0 ? void 0 : _rowHeightsOptions$de.lineCount) || defaultLineCountValue);
|
|
169
|
-
// @ts-ignore - same as above
|
|
170
|
-
}, [rowHeightsOptions === null || rowHeightsOptions === void 0 || (_rowHeightsOptions$de2 = rowHeightsOptions.defaultHeight) === null || _rowHeightsOptions$de2 === void 0 ? void 0 : _rowHeightsOptions$de2.lineCount]);
|
|
243
|
+
var useDataGridDisplaySelector = exports.useDataGridDisplaySelector = function useDataGridDisplaySelector(showDisplaySelector, passedGridStyles) {
|
|
244
|
+
var _showDisplaySelector$;
|
|
245
|
+
var passedRowHeightsOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : emptyRowHeightsOptions;
|
|
246
|
+
/**
|
|
247
|
+
* Grid style changes
|
|
248
|
+
*/
|
|
249
|
+
var _useState3 = (0, _react.useState)(passedGridStyles),
|
|
250
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
251
|
+
gridStyles = _useState4[0],
|
|
252
|
+
setGridStyles = _useState4[1];
|
|
171
253
|
|
|
172
|
-
//
|
|
173
|
-
|
|
174
|
-
var _useState9 = (0, _react.useState)(false),
|
|
175
|
-
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
176
|
-
showResetButton = _useState10[0],
|
|
177
|
-
setShowResetButton = _useState10[1];
|
|
254
|
+
// Update if consumers pass new grid style configurations
|
|
255
|
+
var stablePassedGridStyles = (0, _services.useDeepEqual)(passedGridStyles);
|
|
178
256
|
(0, _services.useUpdateEffect)(function () {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
257
|
+
setGridStyles(stablePassedGridStyles);
|
|
258
|
+
}, [stablePassedGridStyles]);
|
|
259
|
+
|
|
260
|
+
// Update on user display selector change
|
|
261
|
+
var onUserGridStyleChange = (0, _react.useCallback)(function (styles) {
|
|
262
|
+
return setGridStyles(function (prevStyles) {
|
|
263
|
+
var changedStyles = _objectSpread(_objectSpread({}, prevStyles), styles);
|
|
264
|
+
var onChange = changedStyles.onChange,
|
|
265
|
+
rest = (0, _objectWithoutProperties2.default)(changedStyles, _excluded);
|
|
266
|
+
onChange === null || onChange === void 0 || onChange(rest);
|
|
267
|
+
return changedStyles;
|
|
268
|
+
});
|
|
269
|
+
}, []);
|
|
270
|
+
var densityControl = (0, _react.useMemo)(function () {
|
|
271
|
+
var show = (0, _data_grid_toolbar.getNestedObjectOptions)(showDisplaySelector, 'allowDensity');
|
|
272
|
+
return show ? (0, _react2.jsx)(DensityControl, {
|
|
273
|
+
gridStyles: gridStyles,
|
|
274
|
+
onChange: onUserGridStyleChange
|
|
275
|
+
}) : null;
|
|
276
|
+
}, [showDisplaySelector, gridStyles, onUserGridStyleChange]);
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Row height changes
|
|
280
|
+
*/
|
|
281
|
+
var _useState5 = (0, _react.useState)(passedRowHeightsOptions),
|
|
282
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
283
|
+
rowHeightsOptions = _useState6[0],
|
|
284
|
+
setRowHeightsOptions = _useState6[1];
|
|
285
|
+
|
|
286
|
+
// Update if consumers pass new row height configurations
|
|
287
|
+
var stablePassedRowHeights = (0, _services.useDeepEqual)(passedRowHeightsOptions);
|
|
188
288
|
(0, _services.useUpdateEffect)(function () {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
var hasUserChanges = Object.keys(userRowHeightsOptions).length > 0;
|
|
192
|
-
if (hasUserChanges) setShowResetButton(true);
|
|
193
|
-
}
|
|
194
|
-
var onChange = rowHeightsOptions.onChange,
|
|
195
|
-
currentRowHeightsOptions = (0, _objectWithoutProperties2.default)(rowHeightsOptions, _excluded2);
|
|
196
|
-
initialRowHeightsOptions === null || initialRowHeightsOptions === void 0 || (_initialRowHeightsOpt = initialRowHeightsOptions.onChange) === null || _initialRowHeightsOpt === void 0 || _initialRowHeightsOpt.call(initialRowHeightsOptions, currentRowHeightsOptions);
|
|
197
|
-
}, [userRowHeightsOptions, allowResetButton]);
|
|
289
|
+
setRowHeightsOptions(stablePassedRowHeights);
|
|
290
|
+
}, [stablePassedRowHeights]);
|
|
198
291
|
|
|
199
|
-
//
|
|
292
|
+
// Update on user display selector change
|
|
293
|
+
var onUserRowHeightChange = (0, _react.useCallback)(function (options) {
|
|
294
|
+
return setRowHeightsOptions(function (prevOptions) {
|
|
295
|
+
var changedOptions = _objectSpread(_objectSpread({}, prevOptions), options);
|
|
296
|
+
var onChange = changedOptions.onChange,
|
|
297
|
+
rest = (0, _objectWithoutProperties2.default)(changedOptions, _excluded2);
|
|
298
|
+
onChange === null || onChange === void 0 || onChange(rest);
|
|
299
|
+
return changedOptions;
|
|
300
|
+
});
|
|
301
|
+
}, []);
|
|
302
|
+
var rowHeightControl = (0, _react.useMemo)(function () {
|
|
303
|
+
var show = (0, _data_grid_toolbar.getNestedObjectOptions)(showDisplaySelector, 'allowRowHeight');
|
|
304
|
+
return show ? (0, _react2.jsx)(RowHeightControl, {
|
|
305
|
+
rowHeightsOptions: rowHeightsOptions,
|
|
306
|
+
onChange: onUserRowHeightChange
|
|
307
|
+
}) : null;
|
|
308
|
+
}, [showDisplaySelector, rowHeightsOptions, onUserRowHeightChange]);
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Reset button
|
|
312
|
+
*/
|
|
313
|
+
var _useState7 = (0, _react.useState)(false),
|
|
314
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
315
|
+
showResetButton = _useState8[0],
|
|
316
|
+
setShowResetButton = _useState8[1];
|
|
317
|
+
var initialGridStyles = (0, _react.useRef)(passedGridStyles);
|
|
318
|
+
var initialRowHeightsOptions = (0, _react.useRef)(passedRowHeightsOptions);
|
|
200
319
|
var resetToInitialState = (0, _react.useCallback)(function () {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
setShowResetButton(false);
|
|
320
|
+
setGridStyles(initialGridStyles.current);
|
|
321
|
+
setRowHeightsOptions(initialRowHeightsOptions.current);
|
|
204
322
|
}, []);
|
|
323
|
+
(0, _services.useUpdateEffect)(function () {
|
|
324
|
+
setShowResetButton(!(0, _isEqual.default)(rowHeightsOptions.defaultHeight, initialRowHeightsOptions.current.defaultHeight) || gridStyles.fontSize !== initialGridStyles.current.fontSize || gridStyles.cellPadding !== initialGridStyles.current.cellPadding);
|
|
325
|
+
}, [rowHeightsOptions.defaultHeight, gridStyles.fontSize, gridStyles.cellPadding]);
|
|
326
|
+
var resetButton = (0, _react.useMemo)(function () {
|
|
327
|
+
var allowed = (0, _data_grid_toolbar.getNestedObjectOptions)(showDisplaySelector, 'allowResetButton');
|
|
328
|
+
if (!allowed || !showResetButton) return null;
|
|
329
|
+
return (0, _react2.jsx)(ResetButton, {
|
|
330
|
+
onClick: resetToInitialState
|
|
331
|
+
});
|
|
332
|
+
}, [showDisplaySelector, showResetButton, resetToInitialState]);
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Display settings popover
|
|
336
|
+
*/
|
|
337
|
+
var _useState9 = (0, _react.useState)(false),
|
|
338
|
+
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
339
|
+
isOpen = _useState10[0],
|
|
340
|
+
setIsOpen = _useState10[1];
|
|
205
341
|
var buttonLabel = (0, _i18n.useEuiI18n)('euiDisplaySelector.buttonText', 'Display options');
|
|
206
|
-
var
|
|
342
|
+
var additionalDisplaySettings = typeof showDisplaySelector === 'boolean' ? null : (_showDisplaySelector$ = showDisplaySelector === null || showDisplaySelector === void 0 ? void 0 : showDisplaySelector.additionalDisplaySettings) !== null && _showDisplaySelector$ !== void 0 ? _showDisplaySelector$ : null;
|
|
343
|
+
var customRender = typeof showDisplaySelector === 'boolean' ? undefined : showDisplaySelector === null || showDisplaySelector === void 0 ? void 0 : showDisplaySelector.customRender;
|
|
207
344
|
var euiTheme = (0, _services.useEuiTheme)();
|
|
208
345
|
var displaySelector = (0, _react.useMemo)(function () {
|
|
209
346
|
var paddingSize = 's';
|
|
@@ -211,7 +348,7 @@ var useDataGridDisplaySelector = exports.useDataGridDisplaySelector = function u
|
|
|
211
348
|
var popoverWidth = (0, _global_styling.mathWithUnits)([formMaxWidth, euiTheme.euiTheme.size[paddingSize]], function (x, y) {
|
|
212
349
|
return x + y * 2;
|
|
213
350
|
});
|
|
214
|
-
return
|
|
351
|
+
return densityControl || rowHeightControl || additionalDisplaySettings ? (0, _react2.jsx)(_popover.EuiPopover, {
|
|
215
352
|
"data-test-subj": "dataGridDisplaySelectorPopover",
|
|
216
353
|
isOpen: isOpen,
|
|
217
354
|
closePopover: function closePopover() {
|
|
@@ -236,92 +373,25 @@ var useDataGridDisplaySelector = exports.useDataGridDisplaySelector = function u
|
|
|
236
373
|
},
|
|
237
374
|
"aria-label": buttonLabel
|
|
238
375
|
}))
|
|
239
|
-
},
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
labelNormal = _ref2[2],
|
|
247
|
-
labelExpanded = _ref2[3];
|
|
248
|
-
return (0, _react2.jsx)(_form.EuiFormRow, {
|
|
249
|
-
label: densityLabel,
|
|
250
|
-
display: "columnCompressed"
|
|
251
|
-
}, (0, _react2.jsx)(_button.EuiButtonGroup, {
|
|
252
|
-
legend: densityLabel,
|
|
253
|
-
buttonSize: "compressed",
|
|
254
|
-
isFullWidth: true,
|
|
255
|
-
options: [{
|
|
256
|
-
id: densityOptions[0],
|
|
257
|
-
label: labelCompact
|
|
258
|
-
}, {
|
|
259
|
-
id: densityOptions[1],
|
|
260
|
-
label: labelNormal
|
|
261
|
-
}, {
|
|
262
|
-
id: densityOptions[2],
|
|
263
|
-
label: labelExpanded
|
|
264
|
-
}],
|
|
265
|
-
onChange: setGridStyles,
|
|
266
|
-
idSelected: gridDensity,
|
|
267
|
-
"data-test-subj": "densityButtonGroup"
|
|
268
|
-
}));
|
|
269
|
-
}), showRowHeightControls && (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
270
|
-
tokens: ['euiDisplaySelector.rowHeightLabel', 'euiDisplaySelector.labelSingle', 'euiDisplaySelector.labelAuto', 'euiDisplaySelector.labelCustom', 'euiDisplaySelector.lineCountLabel'],
|
|
271
|
-
defaults: ['Row height', 'Single', 'Auto fit', 'Custom', 'Lines per row']
|
|
272
|
-
}, function (_ref3) {
|
|
273
|
-
var _ref4 = (0, _slicedToArray2.default)(_ref3, 5),
|
|
274
|
-
rowHeightLabel = _ref4[0],
|
|
275
|
-
labelSingle = _ref4[1],
|
|
276
|
-
labelAuto = _ref4[2],
|
|
277
|
-
labelCustom = _ref4[3],
|
|
278
|
-
lineCountLabel = _ref4[4];
|
|
279
|
-
return (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)(_form.EuiFormRow, {
|
|
280
|
-
label: rowHeightLabel,
|
|
281
|
-
display: "columnCompressed"
|
|
282
|
-
}, (0, _react2.jsx)(_button.EuiButtonGroup, {
|
|
283
|
-
legend: rowHeightLabel,
|
|
284
|
-
buttonSize: "compressed",
|
|
285
|
-
isFullWidth: true,
|
|
286
|
-
options: [{
|
|
287
|
-
id: rowHeightButtonOptions[0],
|
|
288
|
-
label: labelSingle
|
|
289
|
-
}, {
|
|
290
|
-
id: rowHeightButtonOptions[1],
|
|
291
|
-
label: labelAuto
|
|
292
|
-
}, {
|
|
293
|
-
id: rowHeightButtonOptions[2],
|
|
294
|
-
label: labelCustom
|
|
295
|
-
}],
|
|
296
|
-
onChange: setRowHeight,
|
|
297
|
-
idSelected: rowHeightSelection,
|
|
298
|
-
"data-test-subj": "rowHeightButtonGroup"
|
|
299
|
-
})), rowHeightSelection === rowHeightButtonOptions[2] && (0, _react2.jsx)(_form.EuiFormRow, {
|
|
300
|
-
label: lineCountLabel,
|
|
301
|
-
display: "columnCompressed"
|
|
302
|
-
}, (0, _react2.jsx)(_form.EuiRange, {
|
|
303
|
-
compressed: true,
|
|
304
|
-
fullWidth: true,
|
|
305
|
-
showInput: true,
|
|
306
|
-
min: 1,
|
|
307
|
-
max: 20,
|
|
308
|
-
step: 1,
|
|
309
|
-
required: true,
|
|
310
|
-
value: lineCountInput,
|
|
311
|
-
onChange: setLineCountHeight,
|
|
312
|
-
"data-test-subj": "lineCountNumber"
|
|
313
|
-
})));
|
|
314
|
-
}), additionalDisplaySettings, showResetButton && (0, _react2.jsx)(_popover.EuiPopoverFooter, null, (0, _react2.jsx)(_flex.EuiFlexGroup, {
|
|
315
|
-
justifyContent: "flexEnd",
|
|
316
|
-
responsive: false
|
|
317
|
-
}, (0, _react2.jsx)(_flex.EuiFlexItem, {
|
|
318
|
-
grow: false
|
|
319
|
-
}, (0, _react2.jsx)("div", null, (0, _react2.jsx)(_button.EuiButtonEmpty, {
|
|
320
|
-
flush: "both",
|
|
321
|
-
size: "xs",
|
|
322
|
-
onClick: resetToInitialState,
|
|
323
|
-
"data-test-subj": "resetDisplaySelector"
|
|
324
|
-
}, resetButtonLabel)))))) : null;
|
|
325
|
-
}, [euiTheme, additionalDisplaySettings, buttonLabel, isOpen, resetButtonLabel, showDensityControls, showResetButton, showRowHeightControls, gridDensity, rowHeightSelection, lineCountInput, setGridStyles, setRowHeight, setLineCountHeight, resetToInitialState]);
|
|
376
|
+
}, customRender ? customRender({
|
|
377
|
+
densityControl: densityControl,
|
|
378
|
+
rowHeightControl: rowHeightControl,
|
|
379
|
+
additionalDisplaySettings: additionalDisplaySettings,
|
|
380
|
+
resetButton: resetButton
|
|
381
|
+
}) : (0, _react2.jsx)(_react.default.Fragment, null, densityControl, rowHeightControl, additionalDisplaySettings, resetButton)) : null;
|
|
382
|
+
}, [euiTheme, densityControl, rowHeightControl, additionalDisplaySettings, resetButton, customRender, buttonLabel, isOpen]);
|
|
326
383
|
return [displaySelector, gridStyles, rowHeightsOptions];
|
|
384
|
+
};
|
|
385
|
+
var ResetButton = function ResetButton(_ref8) {
|
|
386
|
+
var onClick = _ref8.onClick;
|
|
387
|
+
var resetButtonLabel = (0, _i18n.useEuiI18n)('euiDisplaySelector.resetButtonText', 'Reset to default');
|
|
388
|
+
return (0, _react2.jsx)(_popover.EuiPopoverFooter, null, (0, _react2.jsx)(_flex.EuiFlexGroup, {
|
|
389
|
+
justifyContent: "flexEnd",
|
|
390
|
+
responsive: false
|
|
391
|
+
}, (0, _react2.jsx)(_button.EuiButtonEmpty, {
|
|
392
|
+
flush: "both",
|
|
393
|
+
size: "xs",
|
|
394
|
+
onClick: onClick,
|
|
395
|
+
"data-test-subj": "resetDisplaySelector"
|
|
396
|
+
}, resetButtonLabel)));
|
|
327
397
|
};
|
|
@@ -53,7 +53,7 @@ var euiDataGridStyles = exports.euiDataGridStyles = function euiDataGridStyles(e
|
|
|
53
53
|
euiDataGrid: /*#__PURE__*/(0, _react.css)("display:flex;flex-direction:column;align-items:stretch;", (0, _global_styling.logicalCSS)('height', '100%'), " overflow:hidden;*:where(& .euiDataGridRow){background-color:", euiTheme.colors.emptyShade, ";}*:where(&.euiDataGrid--stripes .euiDataGridRow--striped){background-color:", euiTheme.colors.lightestShade, ";}*:where(&.euiDataGrid--rowHoverHighlight .euiDataGridRow:hover){background-color:", euiTheme.colors.highlight, ";};label:euiDataGrid;"),
|
|
54
54
|
cellPadding: {
|
|
55
55
|
cellPadding: function cellPadding(size) {
|
|
56
|
-
return /*#__PURE__*/(0, _react.css)(".euiDataGridHeaderCell,.euiDataGridRowCell__content{padding:", _cellPadding[size], ";}/* Workaround to trim line-clamp and padding - @see https://github.com/elastic/eui/issues/7780 */.euiDataGridRowCell__content--lineCountHeight{", (0, _global_styling.logicalCSS)('padding-bottom', 0), " ", (0, _global_styling.logicalCSS)('border-bottom', "".concat(_cellPadding[size], " solid transparent")), ";}.euiDataGridHeaderCell__button{margin-block:-", _cellPadding[size], ";};label:cellPadding;");
|
|
56
|
+
return /*#__PURE__*/(0, _react.css)(".euiDataGridHeaderCell,.euiDataGridRowCell__content{padding:", _cellPadding[size], ";}/* Workaround to trim line-clamp and padding - @see https://github.com/elastic/eui/issues/7780 */.euiDataGridRowCell__content--lineCountHeight,.euiDataGridRowCell__content--autoBelowLineCountHeight{", (0, _global_styling.logicalCSS)('padding-bottom', 0), " ", (0, _global_styling.logicalCSS)('border-bottom', "".concat(_cellPadding[size], " solid transparent")), ";}.euiDataGridHeaderCell__button{margin-block:-", _cellPadding[size], ";};label:cellPadding;");
|
|
57
57
|
},
|
|
58
58
|
get s() {
|
|
59
59
|
return /*#__PURE__*/(0, _react.css)(this.cellPadding('s'), ";label:s;");
|
|
@@ -109,7 +109,7 @@ var useUnconstrainedHeight = exports.useUnconstrainedHeight = function useUncons
|
|
|
109
109
|
if (rowHeightOption) {
|
|
110
110
|
// this row's height is known
|
|
111
111
|
knownRowCount++;
|
|
112
|
-
knownHeight += rowHeightUtils.getCalculatedHeight(rowHeightOption, defaultRowHeight, correctRowIndex,
|
|
112
|
+
knownHeight += rowHeightUtils.getCalculatedHeight(rowHeightOption, defaultRowHeight, correctRowIndex, rowHeightsOptions);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|