UNPKG

@elastic/eui

Version:

Elastic UI Component Library

802 lines (790 loc) 104 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _typeof = require("@babel/runtime/helpers/typeof"); Object.defineProperty(exports, "__esModule", { value: true }); exports.EuiInMemoryTable = void 0; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); var _propTypes = _interopRequireDefault(require("prop-types")); var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _react = _interopRequireWildcard(require("react")); var _basic_table = require("./basic_table"); var _predicate = require("../../services/predicate"); var _sort2 = require("../../services/sort"); var _search_bar = require("../search_bar/search_bar"); var _search_box = require("../search_bar/search_box"); var _spacer = require("../spacer"); var _table_pagination = require("../table/table_pagination"); var _component_defaults = require("../provider/component_defaults"); var _react2 = require("@emotion/react"); var _excluded = ["schema"], _excluded2 = ["onChange"], _excluded3 = ["columns", "loading", "noItemsMessage", "error", "selection", "compressed", "pagination", "sorting", "itemIdToExpandedRowMap", "itemId", "rowProps", "cellProps", "tableLayout", "items", "search", "searchFormat", "onTableChange", "executeQueryOptions", "allowNeutralSort", "childrenBetween"]; 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); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(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; } function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } 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; } 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; } /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ function isEuiSearchBarProps(x) { return typeof x !== 'boolean'; } /** * Extracts and formats a query from search props based on the search format * @param search - The search configuration * @param defaultQuery - Whether to use the defaultQuery property as fallback * @param searchFormat - The search format: 'eql' for parsed queries, 'text' for plain text * @returns Formatted query string or Query object */ var getQueryFromSearch = function getQueryFromSearch(search, defaultQuery, searchFormat) { var _ref, _searchProps$defaultQ, _searchProps$query; if (!search) { return searchFormat === 'text' ? '""' : ''; } var searchProps = search; var queryString = defaultQuery ? (_ref = (_searchProps$defaultQ = searchProps.defaultQuery) !== null && _searchProps$defaultQ !== void 0 ? _searchProps$defaultQ : searchProps.query) !== null && _ref !== void 0 ? _ref : '' : (_searchProps$query = searchProps.query) !== null && _searchProps$query !== void 0 ? _searchProps$query : ''; if (searchFormat === 'text') { return "\"".concat(queryString, "\""); } return (0, _predicate.isString)(queryString) ? _search_bar.EuiSearchBar.Query.parse(queryString) : queryString; }; var getInitialPagination = function getInitialPagination(pagination, consumerDefaults) { var _ref3, _pagination$pageIndex, _ref4, _pagination$pageSize; if (!pagination) { return { pageIndex: undefined, pageSize: undefined }; } var defaults = _objectSpread(_objectSpread({}, _table_pagination.euiTablePaginationDefaults), consumerDefaults); var _ref2 = pagination, _ref2$pageSizeOptions = _ref2.pageSizeOptions, pageSizeOptions = _ref2$pageSizeOptions === void 0 ? defaults.itemsPerPageOptions : _ref2$pageSizeOptions, _ref2$showPerPageOpti = _ref2.showPerPageOptions, showPerPageOptions = _ref2$showPerPageOpti === void 0 ? defaults.showPerPageOptions : _ref2$showPerPageOpti; var defaultPageSize = pageSizeOptions !== null && pageSizeOptions !== void 0 && pageSizeOptions.includes(defaults.itemsPerPage) ? defaults.itemsPerPage : pageSizeOptions[0]; var initialPageIndex = pagination === true ? 0 : (_ref3 = (_pagination$pageIndex = pagination.pageIndex) !== null && _pagination$pageIndex !== void 0 ? _pagination$pageIndex : pagination.initialPageIndex) !== null && _ref3 !== void 0 ? _ref3 : 0; var initialPageSize = pagination === true ? defaultPageSize : (_ref4 = (_pagination$pageSize = pagination.pageSize) !== null && _pagination$pageSize !== void 0 ? _pagination$pageSize : pagination.initialPageSize) !== null && _ref4 !== void 0 ? _ref4 : defaultPageSize; if (showPerPageOptions && initialPageSize != null && !(pageSizeOptions !== null && pageSizeOptions !== void 0 && pageSizeOptions.includes(initialPageSize))) { throw new Error("EuiInMemoryTable received initialPageSize ".concat(initialPageSize, ", which wasn't provided within pageSizeOptions.")); } return { pageIndex: initialPageIndex, pageSize: initialPageSize, pageSizeOptions: pageSizeOptions, showPerPageOptions: showPerPageOptions }; }; function findColumnByProp(columns, prop, value) { for (var i = 0; i < columns.length; i++) { var column = columns[i]; if (column[prop] === value) { return column; } } } function findColumnByFieldOrName(columns, value) { // The passed value can be a column's `field` or its `name` // for backwards compatibility `field` must be checked first var column = findColumnByProp(columns, 'field', value); if (column == null) { column = findColumnByProp(columns, 'name', value); } return column; } function getInitialSorting(columns, sorting) { if (!sorting || !sorting.sort) { return { sortName: undefined, sortDirection: undefined }; } var _sort = sorting.sort, sortable = _sort.field, sortDirection = _sort.direction; var sortColumn = findColumnByFieldOrName(columns, sortable); if (sortColumn == null) { return { sortName: undefined, sortDirection: undefined }; } var sortName = sortColumn.name; return { sortName: sortName, sortDirection: sortDirection }; } var EuiInMemoryTable = exports.EuiInMemoryTable = /*#__PURE__*/function (_Component) { function EuiInMemoryTable(props, context) { var _props$searchFormat; var _this; (0, _classCallCheck2.default)(this, EuiInMemoryTable); _this = _callSuper(this, EuiInMemoryTable, [props]); (0, _defineProperty2.default)(_this, "onTableChange", function (_ref5) { var page = _ref5.page, sort = _ref5.sort; var _ref6 = page || {}, pageIndex = _ref6.index, pageSize = _ref6.size; // don't apply pagination changes that are otherwise controlled // `page` is left unchanged as it goes to the consumer's `onTableChange` callback, allowing the app to respond var pagination = _this.props.pagination; if (pagination != null && typeof pagination !== 'boolean') { if (pagination.pageSize != null) pageSize = pagination.pageSize; if (pagination.pageIndex != null) pageIndex = pagination.pageIndex; } var _ref7 = sort || {}, sortName = _ref7.field, sortDirection = _ref7.direction; // To keep backwards compatibility reportedSortName needs to be tracked separately // from sortName; sortName gets stored internally while reportedSortName is sent to the callback var reportedSortName = sortName; // EuiBasicTable returns the column's `field` instead of `name` on sort // and the column's `name` instead of `field` on pagination if (sortName) { var sortColumn = findColumnByFieldOrName(_this.props.columns, sortName); if (sortColumn) { // Ensure sortName uses `name` sortName = sortColumn.name; // Ensure reportedSortName uses `field` if it exists var sortField = sortColumn.field; if (sortField) reportedSortName = sortField; } } // Allow going back to 'neutral' sorting if (_this.state.allowNeutralSort && _this.state.sortName === sortName && _this.state.sortDirection === 'desc' && sortDirection === 'asc') { sortName = ''; reportedSortName = ''; sortDirection = 'asc'; // Default sort direction. } if (_this.props.onTableChange) { _this.props.onTableChange({ // @ts-ignore complex relationship between pagination's existence and criteria, the code logic ensures this is correctly maintained page: page, sort: { field: reportedSortName, direction: sortDirection } }); } _this.setState({ pageIndex: pageIndex, pageSize: pageSize, sortName: sortName, sortDirection: sortDirection }); }); (0, _defineProperty2.default)(_this, "onQueryChange", function (_ref8) { var query = _ref8.query, queryText = _ref8.queryText, error = _ref8.error; var search = _this.props.search; if (isEuiSearchBarProps(search)) { if (search.onChange) { var shouldQueryInMemory = error == null ? search.onChange({ query: query, queryText: queryText, error: null }) : search.onChange({ query: null, queryText: queryText, error: error }); if (!shouldQueryInMemory) { return; } } } // Reset pagination state. _this.setState(function (state) { return { prevProps: _objectSpread(_objectSpread({}, state.prevProps), {}, { search: search }), query: query, pageIndex: 0 }; }); }); // Alternative to onQueryChange - allows consumers to specify they want the // search bar to ignore EQL syntax and only use the searchbar for plain text (0, _defineProperty2.default)(_this, "onPlainTextSearch", function (searchValue) { var escapedQueryText = searchValue.replace(/["\\]/g, '\\$&'); var search = _this.props.search; if (isEuiSearchBarProps(search)) { if (search.onChange) { var shouldQueryInMemory = search.onChange({ query: null, queryText: escapedQueryText, error: null }); if (!shouldQueryInMemory) { return; } } } _this.setState({ query: "\"".concat(escapedQueryText, "\"") }); }); var columns = props.columns, _search = props.search, _pagination = props.pagination, sorting = props.sorting, allowNeutralSort = props.allowNeutralSort; var _getInitialPagination = getInitialPagination(_pagination, context.EuiTablePagination), _pageIndex = _getInitialPagination.pageIndex, _pageSize = _getInitialPagination.pageSize, pageSizeOptions = _getInitialPagination.pageSizeOptions, showPerPageOptions = _getInitialPagination.showPerPageOptions; var _getInitialSorting = getInitialSorting(columns, sorting), _sortName = _getInitialSorting.sortName, _sortDirection = _getInitialSorting.sortDirection; _this.state = { prevProps: { items: props.items, sortName: _sortName, sortDirection: _sortDirection, search: _search }, search: _search, query: getQueryFromSearch(_search, true, (_props$searchFormat = props.searchFormat) !== null && _props$searchFormat !== void 0 ? _props$searchFormat : 'eql'), pageIndex: _pageIndex || 0, pageSize: _pageSize, pageSizeOptions: pageSizeOptions, sortName: _sortName, sortDirection: _sortDirection, allowNeutralSort: allowNeutralSort !== false, showPerPageOptions: showPerPageOptions }; return _this; } (0, _inherits2.default)(EuiInMemoryTable, _Component); return (0, _createClass2.default)(EuiInMemoryTable, [{ key: "renderSearchBar", value: function renderSearchBar() { var _this$props = this.props, search = _this$props.search, searchFormat = _this$props.searchFormat; if (!search) return; var searchBar; if (searchFormat === 'text') { var _ref9 = search, _ref9$box = _ref9.box, box = _ref9$box === void 0 ? {} : _ref9$box, query = _ref9.query, defaultQuery = _ref9.defaultQuery; var schema = box.schema, searchBoxProps = (0, _objectWithoutProperties2.default)(box, _excluded); // in the unexpected case a Query object is passed with searchFormat=text if (process.env.NODE_ENV === 'development') { if (query != null && !(0, _predicate.isString)(query)) { console.warn('EuiInMemoryTable: `query` should be a string when using searchFormat="text". Query objects are only supported with searchFormat="eql".'); } if (defaultQuery != null && !(0, _predicate.isString)(defaultQuery)) { console.warn('EuiInMemoryTable: `defaultQuery` should be a string when using searchFormat="text". Query objects are only supported with searchFormat="eql".'); } } // use only string values, ignore Query objects var displayQuery = (0, _predicate.isString)(query) ? query : (0, _predicate.isString)(defaultQuery) ? defaultQuery : ''; searchBar = (0, _react2.jsx)(_search_box.EuiSearchBox, (0, _extends2.default)({}, searchBoxProps, { query: displayQuery, onSearch: this.onPlainTextSearch })); } else { var searchBarProps = {}; if (isEuiSearchBarProps(search)) { var onChange = search.onChange, _searchBarProps = (0, _objectWithoutProperties2.default)(search, _excluded2); searchBarProps = _searchBarProps; if (searchBarProps.box && searchBarProps.box.schema === true) { searchBarProps.box = _objectSpread(_objectSpread({}, searchBarProps.box), {}, { schema: this.resolveSearchSchema() }); } } searchBar = (0, _react2.jsx)(_search_bar.EuiSearchBar, (0, _extends2.default)({ onChange: this.onQueryChange }, searchBarProps)); } return (0, _react2.jsx)(_react.default.Fragment, null, searchBar, (0, _react2.jsx)(_spacer.EuiSpacer, { size: "l" })); } }, { key: "resolveSearchSchema", value: function resolveSearchSchema() { var columns = this.props.columns; return columns.reduce(function (schema, column) { var _ref10 = column, field = _ref10.field, dataType = _ref10.dataType; if (field) { var type = dataType || 'string'; schema.fields[field] = { type: type }; } return schema; }, { strict: true, fields: {} }); } }, { key: "getItemSorter", value: function getItemSorter() { var _this$state = this.state, sortName = _this$state.sortName, sortDirection = _this$state.sortDirection; var columns = this.props.columns; var sortColumn = columns.find(function (_ref11) { var name = _ref11.name; return name === sortName; }); if (sortColumn == null) { // can't return a non-function so return a function that says everything is the same return function () { return 0; }; } var sortable = sortColumn.sortable; if (typeof sortable === 'function') { return _sort2.Comparators.value(sortable, _sort2.Comparators.default(sortDirection)); } return _sort2.Comparators.property(sortColumn.field, _sort2.Comparators.default(sortDirection)); } }, { key: "getItems", value: function getItems() { var executeQueryOptions = this.props.executeQueryOptions; var items = this.state.prevProps.items; if (!items.length) { return { items: [], totalItemCount: 0 }; } var _this$state2 = this.state, query = _this$state2.query, sortName = _this$state2.sortName, pageIndex = _this$state2.pageIndex, pageSize = _this$state2.pageSize; var matchingItems = query !== null && (executeQueryOptions === null || executeQueryOptions === void 0 ? void 0 : executeQueryOptions.enabled) !== false ? _search_bar.EuiSearchBar.Query.execute(query, items, executeQueryOptions) : items; var sortedItems = sortName ? matchingItems.slice(0) // avoid mutating the source array .sort(this.getItemSorter()) // sort, causes mutation : matchingItems; var visibleItems = pageSize && this.props.pagination ? function () { var startIndex = pageIndex * pageSize; return sortedItems.slice(startIndex, Math.min(startIndex + pageSize, sortedItems.length)); }() : sortedItems; return { items: visibleItems, totalItemCount: matchingItems.length }; } }, { key: "render", value: function render() { var _this$props2 = this.props, columns = _this$props2.columns, loading = _this$props2.loading, noItemsMessage = _this$props2.noItemsMessage, error = _this$props2.error, selection = _this$props2.selection, compressed = _this$props2.compressed, hasPagination = _this$props2.pagination, hasSorting = _this$props2.sorting, itemIdToExpandedRowMap = _this$props2.itemIdToExpandedRowMap, itemId = _this$props2.itemId, rowProps = _this$props2.rowProps, cellProps = _this$props2.cellProps, tableLayout = _this$props2.tableLayout, _unuseditems = _this$props2.items, search = _this$props2.search, searchFormat = _this$props2.searchFormat, onTableChange = _this$props2.onTableChange, executeQueryOptions = _this$props2.executeQueryOptions, allowNeutralSort = _this$props2.allowNeutralSort, childrenBetween = _this$props2.childrenBetween, rest = (0, _objectWithoutProperties2.default)(_this$props2, _excluded3); var _this$state3 = this.state, pageIndex = _this$state3.pageIndex, pageSize = _this$state3.pageSize, pageSizeOptions = _this$state3.pageSizeOptions, sortName = _this$state3.sortName, sortDirection = _this$state3.sortDirection, showPerPageOptions = _this$state3.showPerPageOptions; var _this$getItems = this.getItems(), items = _this$getItems.items, totalItemCount = _this$getItems.totalItemCount; var pagination = !hasPagination ? undefined : { pageIndex: pageIndex, pageSize: pageSize !== null && pageSize !== void 0 ? pageSize : 1, pageSizeOptions: pageSizeOptions, totalItemCount: totalItemCount, showPerPageOptions: showPerPageOptions }; // Data loaded from a server can have a default sort order which is meaningful to the // user, but can't be reproduced with client-side sort logic. So we allow the table to display // rows in the order in which they're initially loaded by providing an undefined sorting prop. var sorting = !hasSorting ? undefined : { sort: !sortName && !sortDirection ? undefined : { field: sortName, direction: sortDirection }, allowNeutralSort: this.state.allowNeutralSort }; var searchBar = this.renderSearchBar(); var table = // @ts-ignore complex relationship between pagination's existence and criteria, the code logic ensures this is correctly maintained (0, _react2.jsx)(_basic_table.EuiBasicTable, (0, _extends2.default)({ items: items, itemId: itemId, rowProps: rowProps, cellProps: cellProps, columns: columns, pagination: pagination, sorting: sorting, selection: selection, onChange: this.onTableChange, error: error, loading: loading, noItemsMessage: noItemsMessage, tableLayout: tableLayout, compressed: compressed, itemIdToExpandedRowMap: itemIdToExpandedRowMap }, rest)); if (!searchBar) { return table; } return (0, _react2.jsx)("div", null, searchBar, childrenBetween, table); } }], [{ key: "getDerivedStateFromProps", value: function getDerivedStateFromProps(nextProps, prevState) { var updatedPrevState = prevState; if (nextProps.items !== prevState.prevProps.items) { // We have new items because an external search has completed, so reset pagination state. var nextPageIndex = 0; if (nextProps.pagination != null && typeof nextProps.pagination !== 'boolean') { nextPageIndex = nextProps.pagination.pageIndex || 0; } updatedPrevState = _objectSpread(_objectSpread({}, updatedPrevState), {}, { prevProps: _objectSpread(_objectSpread({}, updatedPrevState.prevProps), {}, { items: nextProps.items }), pageIndex: nextPageIndex }); } // apply changes to controlled pagination if (nextProps.pagination != null && typeof nextProps.pagination !== 'boolean') { if (nextProps.pagination.pageSize != null && nextProps.pagination.pageSize !== updatedPrevState.pageIndex) { updatedPrevState = _objectSpread(_objectSpread({}, updatedPrevState), {}, { pageSize: nextProps.pagination.pageSize }); } if (nextProps.pagination.pageIndex != null && nextProps.pagination.pageIndex !== updatedPrevState.pageIndex) { updatedPrevState = _objectSpread(_objectSpread({}, updatedPrevState), {}, { pageIndex: nextProps.pagination.pageIndex }); } } var _getInitialSorting2 = getInitialSorting(nextProps.columns, nextProps.sorting), sortName = _getInitialSorting2.sortName, sortDirection = _getInitialSorting2.sortDirection; if (sortName !== prevState.prevProps.sortName || sortDirection !== prevState.prevProps.sortDirection) { updatedPrevState = _objectSpread(_objectSpread({}, updatedPrevState), {}, { prevProps: _objectSpread(_objectSpread({}, updatedPrevState.prevProps), {}, { sortName: sortName, sortDirection: sortDirection }), sortName: sortName, sortDirection: sortDirection }); } var nextQuery = nextProps.search ? nextProps.search.query : ''; var prevQuery = prevState.prevProps.search ? prevState.prevProps.search.query : ''; if (nextQuery !== prevQuery) { var _nextProps$searchForm; updatedPrevState = _objectSpread(_objectSpread({}, updatedPrevState), {}, { prevProps: _objectSpread(_objectSpread({}, updatedPrevState.prevProps), {}, { search: nextProps.search }), query: getQueryFromSearch(nextProps.search, false, (_nextProps$searchForm = nextProps.searchFormat) !== null && _nextProps$searchForm !== void 0 ? _nextProps$searchForm : 'eql') }); } if (updatedPrevState !== prevState) { return updatedPrevState; } return null; } }]); }(_react.Component); (0, _defineProperty2.default)(EuiInMemoryTable, "contextType", _component_defaults.EuiComponentDefaultsContext); (0, _defineProperty2.default)(EuiInMemoryTable, "defaultProps", { tableLayout: 'fixed', searchFormat: 'eql' }); EuiInMemoryTable.propTypes = { className: _propTypes.default.oneOfType([_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.string]), _propTypes.default.string]), "aria-label": _propTypes.default.oneOfType([_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.string]), _propTypes.default.string]), "data-test-subj": _propTypes.default.oneOfType([_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.string]), _propTypes.default.string]), css: _propTypes.default.oneOfType([_propTypes.default.oneOfType([_propTypes.default.any, _propTypes.default.any]), _propTypes.default.any]), /** * Describes how to extract a unique ID from each item, used for selections & expanded rows */ /** * Describes how to extract a unique ID from each item, used for selections & expanded rows */ itemId: _propTypes.default.oneOfType([_propTypes.default.string.isRequired, _propTypes.default.number.isRequired, _propTypes.default.func.isRequired]), /** * Row expansion uses the itemId prop to identify each row */ /** * Row expansion uses the itemId prop to identify each row */ itemIdToExpandedRowMap: _propTypes.default.shape({}), /** * A list of objects to appear in the table - an item per row */ /** * A list of objects to appear in the table - an item per row */ items: _propTypes.default.arrayOf(_propTypes.default.any.isRequired), /** * Applied to `EuiTableRowCell` */ /** * Applied to `EuiTableRowCell` */ cellProps: _propTypes.default.oneOfType([_propTypes.default.any.isRequired, _propTypes.default.func.isRequired]), /** * An array of one of the objects: {@link EuiTableFieldDataColumnType}, {@link EuiTableComputedColumnType} or {@link EuiTableActionsColumnType}. */ /** * An array of one of the objects: {@link EuiTableFieldDataColumnType}, {@link EuiTableComputedColumnType} or {@link EuiTableActionsColumnType}. */ columns: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.shape({ /** * A field of the item (may be a nested field) */ // type hack used for better autocomplete support // https://github.com/microsoft/TypeScript/issues/29729 field: _propTypes.default.oneOfType([_propTypes.default.any.isRequired, _propTypes.default.any.isRequired]).isRequired, // supports outer.inner key paths /** * The display name of the column */ name: _propTypes.default.node.isRequired, /** * Allows adding an icon with a tooltip displayed next to the name */ nameTooltip: _propTypes.default.shape({ /** The main content of the tooltip */content: _propTypes.default.node.isRequired, /** * The icon type to display * @default 'question' */ icon: _propTypes.default.oneOfType([_propTypes.default.oneOf(["accessibility", "addDataApp", "addToDashboard", "advancedSettingsApp", "agentApp", "aggregate", "alignBottom", "alignBottomLeft", "alignBottomRight", "alignCenterHorizontal", "alignCenterVertical", "alignLeft", "alignRight", "alignTop", "alignTopLeft", "alignTopRight", "alert", "analyzeEvent", "annotation", "anomalyChart", "chartAnomaly", "anomalySwimLane", "apmApp", "apmTrace", "chartWaterfall", "appSearchApp", "apps", "arrowDown", "chevronSingleDown", "arrowLeft", "chevronSingleLeft", "arrowRight", "chevronSingleRight", "arrowUp", "chevronSingleUp", "arrowStart", "chevronLimitLeft", "arrowEnd", "chevronLimitRight", "article", "asterisk", "at", "archive", "axisX", "axisYLeft", "axisYRight", "auditbeatApp", "backgroundTask", "beaker", "bell", "bellSlash", "beta", "bolt", "boxesHorizontal", "boxesVertical", "branch", "briefcase", "branchUser", "broom", "brush", "bug", "bulb", "bullseye", "calendar", "canvasApp", "casesApp", "changePointDetection", "chartChangePoint", "chartArea", "chartAreaStack", "chartBarHorizontal", "chartBarHorizontalStack", "chartBarVertical", "chartBarVerticalStack", "chartGauge", "chartHeatmap", "chartLine", "chartPie", "chartTagCloud", "chartThreshold", "check", "checkCircle", "checkInCircleFilled", "checkCircleFill", "cheer", "popper", "classificationJob", "clickLeft", "clickRight", "clock", "clockCounter", "clockControl", "cloud", "cloudDrizzle", "cloudStormy", "cloudSunny", "cluster", "code", "codeApp", "color", "paintBucket", "commandLine", "comment", "compare", "compute", "processor", "console", "consoleApp", "container", "continuityAbove", "continuityAboveBelow", "continuityBelow", "continuityWithin", "contrast", "contrastHigh", "contrastFill", "controls", "controlsHorizontal", "controlsVertical", "copy", "copyClipboard", "crossProjectSearch", "createAdvancedJob", "createGenericJob", "createGeoJob", "createMultiMetricJob", "createPopulationJob", "createSingleMetricJob", "cross", "crossClusterReplicationApp", "crossInCircle", "crossCircle", "crosshair", "crosshairs", "currency", "money", "cut", "scissors", "dashboardApp", "dashedCircle", "dataVisualizer", "database", "desktop", "display", "devToolsApp", "diff", "discoverApp", "distributeHorizontal", "distributeVertical", "download", "drag", "dragHorizontal", "dragVertical", "discuss", "document", "documentEdit", "documentation", "documents", "dot", "dotInCircle", "doubleArrowLeft", "chevronDoubleLeft", "doubleArrowRight", "chevronDoubleRight", "ellipsis", "editorAlignCenter", "textAlignCenter", "editorAlignLeft", "textAlignLeft", "editorAlignRight", "textAlignRight", "editorBold", "textBold", "editorChecklist", "listCheck", "editorCodeBlock", "editorComment", "editorDistributeHorizontal", "editorDistributeVertical", "editorHeading", "textHeading", "editorItalic", "textItalic", "editorItemAlignBottom", "editorItemAlignCenter", "editorItemAlignLeft", "editorItemAlignMiddle", "editorItemAlignRight", "editorItemAlignTop", "editorLink", "editorOrderedList", "listNumber", "editorPositionBottomLeft", "editorPositionBottomRight", "editorPositionTopLeft", "editorPositionTopRight", "editorRedo", "redo", "editorStrike", "textStrike", "editorTable", "table", "editorUnderline", "textUnderline", "editorUndo", "undo", "editorUnorderedList", "listBullet", "email", "mail", "empty", "emsApp", "endpoint", "eql", "query", "eraser", "error", "errorFilled", "errorFill", "esqlVis", "exit", "logOut", "expand", "maximize", "expandMini", "export", "exportAction", "upload", "external", "eye", "eyeClosed", "eyeSlash", "faceHappy", "faceNeutral", "faceSad", "fieldStatistics", "tableInfo", "filebeatApp", "filter", "filterExclude", "filterIgnore", "filterInclude", "filterInCircle", "flask", "flag", "fleetApp", "fold", "folder", "folderClosed", "folderClose", "folderCheck", "folderExclamation", "folderOpen", "folderOpened", "frameNext", "framePrevious", "fullScreen", "fullScreenExit", "function", "gear", "gisApp", "glasses", "globe", "grab", "grabHorizontal", "grabOmnidirectional", "gradient", "graphApp", "grid", "grokApp", "heart", "heartbeatApp", "heatmap", "help", "home", "hourglass", "if", "info", "image", "importAction", "index", "indexClose", "indexEdit", "indexFlush", "indexManagementApp", "indexMapping", "mapping", "indexOpen", "indexPatternApp", "indexRollupApp", "indexRuntime", "indexSettings", "indexTemporary", "tableTime", "infinity", "inputOutput", "inspect", "invert", "ip", "key", "keyboard", "kqlField", "queryField", "kqlFunction", "kqlOperand", "queryOperand", "kqlSelector", "querySelector", "kqlValue", "queryValue", "kubernetesNode", "kubernetesPod", "launch", "rocket", "layers", "lensApp", "lettering", "text", "lineBreak", "lineBreakSlash", "lineDash", "lineDashed", "lineDot", "lineDotted", "lineSolid", "link", "linkSlash", "list", "listAdd", "lock", "lockOpen", "logPatternAnalysis", "pattern", "logRateAnalysis", "logoAWS", "logoAWSMono", "logoAerospike", "logoApache", "logoAppSearch", "logoAzure", "logoAzureMono", "logoBeats", "logoBusinessAnalytics", "logoCeph", "logoCloud", "logoCloudEnterprise", "logoCode", "logoCodesandbox", "logoCouchbase", "logoDocker", "logoDropwizard", "logoElastic", "logoElasticStack", "logoElasticsearch", "logoEnterpriseSearch", "logoEtcd", "logoGCP", "logoGCPMono", "logoGithub", "logoGmail", "logoGolang", "logoGoogleG", "logoHAproxy", "logoIBM", "logoIBMMono", "logoKafka", "logoKibana", "logoKubernetes", "logoLogging", "logoLogstash", "logoMaps", "logoMemcached", "logoMetrics", "logoMongodb", "logoMySQL", "logoNginx", "logoObservability", "logoOsquery", "logoPhp", "logoPostgres", "logoPrometheus", "logoRabbitmq", "logoRedis", "logoSecurity", "logoSiteSearch", "logoSketch", "logoSlack", "logoUptime", "logoVectorDB", "logoVulnerabilityManagement", "logoWebhook", "logoWindows", "logoWorkplaceSearch", "logsApp", "logstashFilter", "logstashIf", "logstashInput", "logstashOutput", "logstashQueue", "queue", "machineLearningApp", "magnet", "magnify", "magnifyExclamation", "magnifyMinus", "magnifyPlus", "magnifyWithExclamation", "magnifyWithMinus", "magnifyWithPlus", "managementApp", "map", "mapMarker", "waypoint", "megaphone", "memory", "menu", "menuDown", "menuLeft", "menuRight", "menuUp", "merge", "metricbeatApp", "metricsApp", "minimize", "minus", "minusCircle", "minusInCircle", "minusInCircleFilled", "minusInSquare", "minusSquare", "mobile", "monitoringApp", "moon", "move", "namespace", "nested", "newChat", "node", "vectorTriangle", "notebookApp", "number", "offline", "wifiSlash", "online", "wifi", "outlierDetectionJob", "package", "packetbeatApp", "pageSelect", "pagesSelect", "palette", "paperClip", "partial", "pause", "payment", "pencil", "percent", "pin", "pinFill", "pinFilled", "pipeBreaks", "pipelineApp", "pipeNoBreaks", "pivot", "play", "playFilled", "plugs", "plus", "plusCircle", "plusInCircle", "plusInCircleFilled", "plusInSquare", "plusSquare", "popout", "presentation", "productRobot", "productAgent", "productCloudInfra", "productDashboard", "productDiscover", "productML", "productStreamsClassic", "productStreamsWired", "push", "send", "question", "quote", "radar", "readOnly", "recentlyViewedApp", "refresh", "regressionJob", "reporter", "reportingApp", "return", "returnKey", "save", "savedObjectsApp", "scale", "search", "searchProfilerApp", "section", "securityAnalyticsApp", "securityApp", "securitySignal", "securitySignalDetected", "securitySignalResolved", "server", "sessionViewer", "shard", "share", "significantEvents", "singleMetricViewer", "snowflake", "sortAscending", "sortDescending", "sortDown", "sortLeft", "sortRight", "sortUp", "sortable", "spaces", "spacesApp", "sparkles", "sqlApp", "star", "starEmpty", "starEmptySpace", "starFill", "starFilled", "starFillSpace", "starFilledSpace", "starMinusEmpty", "starMinusFill", "starMinusFilled", "starPlusEmpty", "starPlusFill", "starPlusFilled", "stats", "stop", "stopFill", "stopFilled", "stopSlash", "storage", "streamsClassic", "streamsWired", "string", "submodule", "sun", "swatchInput", "symlink", "tableDensityCompact", "tableDensityHigh", "tableDensityExpanded", "tableDensityLow", "tableDensityNormal", "tableOfContents", "tag", "tear", "temperature", "thermometer", "thumbDown", "thumbUp", "timeline", "timelineWithArrow", "timelionApp", "timeRefresh", "refreshTime", "timeslider", "training", "transitionBottomIn", "transitionBottomOut", "transitionLeftIn", "transitionLeftOut", "transitionTopIn", "transitionTopOut", "trash", "unfold", "unlink", "upgradeAssistantApp", "uptimeApp", "user", "userAvatar", "users", "usersRolesApp", "unarchive", "vector", "vectorSquare", "videoPlayer", "visArea", "visAreaStacked", "visBarHorizontal", "visBarHorizontalStacked", "visBarVertical", "visBarVerticalStacked", "visGauge", "visGoal", "visLine", "visMapCoordinate", "visMapRegion", "visMetric", "chartMetric", "visPie", "visTable", "visTagCloud", "visText", "visTimelion", "visVega", "visVisualBuilder", "visualizeApp", "vulnerabilityManagementApp", "warning", "warningFilled", "warningFill", "watchesApp", "web", "wordWrap", "wordWrapDisabled", "workflowsApp", "workflow", "workplaceSearchApp", "wrench", "tokenAlias", "tokenAnnotation", "tokenArray", "tokenBinary", "tokenBoolean", "tokenClass", "tokenCompletionSuggester", "tokenConstant", "tokenDate", "tokenDimension", "tokenElement", "tokenEnum", "tokenEnumMember", "tokenEvent", "tokenException", "tokenField", "tokenFile", "tokenFlattened", "tokenFunction", "tokenGeo", "tokenHistogram", "tokenInterface", "tokenIP", "tokenJoin", "tokenKey", "tokenKeyword", "tokenMethod", "tokenMetricCounter", "tokenMetricGauge", "tokenModule", "tokenNamespace", "tokenNested", "tokenNull", "tokenNumber", "tokenObject", "tokenOperator", "tokenPackage", "tokenParameter", "tokenPercolator", "tokenProperty", "tokenRange", "tokenRankFeature", "tokenRankFeatures", "tokenRepo", "tokenSearchType", "tokenSemanticText", "tokenShape", "tokenString", "tokenStruct", "tokenSymbol", "tokenTag", "tokenText", "tokenTokenCount", "tokenVariable", "tokenVectorDense", "tokenDenseVector", "tokenVectorSparse"]).isRequired, _propTypes.default.string.isRequired, _propTypes.default.elementType.isRequired]), /** Additional props for EuiIcon */iconProps: _propTypes.default.any, /** Additional props for the EuiToolTip */tooltipProps: _propTypes.default.shape({ /** * Passes onto the span wrapping the trigger. */ anchorClassName: _propTypes.default.string, /** * Passes onto the span wrapping the trigger. */ anchorProps: _propTypes.default.shape({ className: _propTypes.default.string, "aria-label": _propTypes.default.string, "data-test-subj": _propTypes.default.string, css: _propTypes.default.any }), /** * Passes onto the tooltip itself, not the trigger. */ className: _propTypes.default.string, /** * The main content of your tooltip. */ content: _propTypes.default.node, /** * Common display alternatives for the anchor wrapper */ display: _propTypes.default.any, /** * An optional title for your tooltip. */ title: _propTypes.default.node, /** * Unless you provide one, this will be randomly generated. */ id: _propTypes.default.string, /** * When `true`, the tooltip's position is re-calculated when the user * scrolls. This supports having fixed-position tooltip anchors. * * When nesting an `EuiTooltip` in a scrollable container, `repositionOnScroll` should be `true` */ repositionOnScroll: _propTypes.default.bool, /** * Disables the tooltip content being read by screen readers when focusing the trigger element. * Do not use when the trigger `aria-label` and tooltip `content` can be rephrased to be standalone * information (action & additional information). * Enable this prop only when the trigger has a descriptive label that either duplicates or includes * the tooltip content and would result in repetitive output. * @default false */ disableScreenReaderOutput: _propTypes.default.bool, /** * If supplied, called when mouse movement causes the tool tip to be * hidden. */ onMouseOut: _propTypes.default.func, /** * If supplied, called when the trigger loses focus. */ onBlur: _propTypes.default.func, /** * Offset in pixels from the anchor. Defaults to 16. */ offset: _propTypes.default.number, "aria-label": _propTypes.default.string, "data-test-subj": _propTypes.default.string, css: _propTypes.default.any, position: _propTypes.default.any }) }), /** * A description of the column (will be presented as a title over the column header) */ description: _propTypes.default.string, /** * Describes the data types of the displayed value (serves as a rendering hint for the table) */ dataType: _propTypes.default.oneOf(["auto", "string", "number", "boolean", "date"]), /** * Requested width of the column. * * Exact width settings are not guaranteed in certain table layouts * or configurations, and may be adjusted by browser's algorithm. * Consider this value a guidance. * * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/table-layout#values|table-layout algorithms on MDN} */ width: _propTypes.default.string, /** * Requested minimum width of the column. * * Exact width settings are not guaranteed in certain table layouts * or configurations, and may be adjusted by browser's algorithm. * Consider this value a guidance. * * This property takes effect only when `tableLayout="auto"` is set on the table. */ minWidth: _propTypes.default.string, /** * Requested maximum width of the column. * * Exact width settings are not guaranteed in certain table layouts * or configurations, and may be adjusted by browser's algorithm. * Consider this value a guidance. * * This property takes effect only when `tableLayout="auto"` is set on the table. */ maxWidth: _propTypes.default.string, /** * Defines whether the user can sort on this column. If a function is provided, this function returns the value to sort against */ sortable: _propTypes.default.oneOfType([_propTypes.default.bool.isRequired, _propTypes.default.func.isRequired]), /** * Disables the user's ability to change the sort, but will still * show the current sort direction in the column header */ readOnly: _propTypes.default.bool, /** * Defines the horizontal alignment of the column * @default left */ align: _propTypes.default.any, /** * Creates a text wrapper around cell content that helps word break or truncate * long text correctly. * @default true */ textOnly: _propTypes.default.bool, /** * Indicates whether this column should truncate overflowing text content. * - Set to `true` to enable single-line truncation. * - To enable multi-line truncation, use a configuration object with `lines` * set to a number of lines to truncate to. */ truncateText: _propTypes.default.oneOfType([_propTypes.default.bool.isRequired, _propTypes.default.shape({ lines: _propTypes.default.number.isRequired }).isRequired]), /** * Allows configuring custom render options or appearances for column cells * when the table responsively collapses into a mobile-friendly view */ mobileOptions: _propTypes.default.shape({ render: _propTypes.default.func }), /** * A custom renderer for this column's cell content. * Unlike computed columns or `mobileOptions.render`, this function receives: * - `value`: The value of the specified field for this row * - `item`: The full data item (row object) */ render: _propTypes.default.func, /** * Content to display in the footer beneath this column */ footer: _propTypes.default.oneOfType([_propTypes.default.string.isRequired, _propTypes.default.element.isRequired, _propTypes.default.func.isRequired]), /** * If passing `itemIdToExpandedRowMap` to your table, set this flag to `true` * for the custom column or cell used to toggle the expanded row. */ isExpander: _propTypes.default.bool, className: _propTypes.default.string, "aria-label": _propTypes.default.string, "data-test-subj": _propTypes.default.string, css: _propTypes.default.any }).isRequired, _propTypes.default.shape({ className: _propTypes.default.string, "aria-label": _propTypes.default.string, "data-test-subj": _propTypes.default.string, css: _propTypes.default.any, /** * A function that computes the value for each item and renders it */ render: _propTypes.default.func.isRequired, /** * The display name of the column */ name: _propTypes.default.node, /** * Allows configuring an icon with a tooltip, to be displayed next to the name */ nameTooltip: _propTypes.default.shape({ /** The main content of the tooltip */content: _propTypes.default.node.isRequired, /** * The icon type to display * @default 'question' */ icon: _propTypes.default.oneOfType([_propTypes.default.oneOf(["accessibility", "addDataApp", "addToDashboard", "advancedSettingsApp", "agentApp", "aggregate", "alignBottom", "alignBottomLeft", "alignBottomRight", "alignCenterHorizontal", "alignCenterVertical", "alignLeft", "alignRight", "alignTop", "alignTopLeft", "alignTopRight", "alert", "analyzeEvent", "annotation", "anomalyChart", "chartAnomaly", "anomalySwimLane", "apmApp", "apmTrace", "chartWaterfall", "appSearchApp", "apps", "arrowDown", "chevronSingleDown", "arrowLeft", "chevronSingleLeft", "arrowRight", "chevronSingleRight", "arrowUp", "chevronSingleUp", "arrowStart", "chevronLimitLeft", "arrowEnd", "chevronLimitRight", "article", "asterisk", "at", "archive", "axisX", "axisYLeft", "axisYRight", "auditbeatApp", "backgroundTask", "beaker", "bell", "bellSlash", "beta", "bolt", "boxesHorizontal", "boxesVertical", "branch", "briefcase", "branchUser", "broom", "brush", "bug", "bulb", "bullseye", "calendar", "canvasApp", "casesApp", "changePointDetection", "chartChangePoint", "chartArea", "chartAreaStack", "chartBarHorizontal", "chartBarHorizontalStack", "chartBarVertical", "chartBarVerticalStack", "chartGauge", "chartHeatmap", "chartLine", "chartPie", "chartTagCloud", "chartThreshold", "check", "checkCircle", "checkInCircleFilled", "checkCircleFill", "cheer", "popper", "classificationJob", "clickLeft", "clickRight", "clock", "clockCounter", "clockControl", "cloud", "cloudDrizzle", "cloudStormy", "cloudSunny", "cluster", "code", "codeApp", "color", "paintBucket", "commandLine", "comment", "compare", "compute", "processor", "console", "consoleApp", "container", "continuityAbove", "continuityAboveBelow", "continuityBelow", "continuityWithin", "contrast", "contrastHigh", "contrastFill", "controls", "controlsHorizontal", "controlsVertical", "copy", "copyClipboard", "crossProjectSearch", "createAdvancedJob", "createGenericJob", "createGeoJob", "createMultiMetricJob", "createPopulationJob", "createSingleMetricJob", "cross", "crossClusterReplicationApp", "crossInCircle", "crossCircle", "crosshair", "crosshairs", "currency", "money", "cut", "scissors", "dashboardApp", "dashedCircle", "dataVisualizer", "database", "desktop", "display", "devToolsApp", "diff", "discoverApp", "distributeHorizontal", "distributeVertical", "download", "drag", "dragHorizontal", "dragVertical", "discuss", "document", "documentEdit", "documentation", "documents", "dot", "dotInCircle", "doubleArrowLeft", "chevronDoubleLeft", "doubleArrowRight", "chevronDoubleRight", "ellipsis", "editorAlignCenter", "textAlignCenter", "editorAlignLeft", "textAlignLeft", "editorAlignRight", "textAlignRight", "editorBold", "textBold", "editorChecklist", "listCheck", "editorCodeBlock", "editorComment", "editorDistributeHorizontal", "editorDistributeVertical", "editorHeading", "textHeading", "editorItalic", "textItalic", "editorItemAlignBottom", "editorItemAlignCenter", "editorItemAlignLeft", "editorItemAlignMiddle", "editorItemAlignRight", "editorItemAlignTop", "editorLink", "editorOrderedList", "listNumber", "editorPositionBottomLeft", "editorPositionBottomRight", "editorPositionTopLeft", "editorPositionTopRight", "editorRedo", "redo", "editorStrike", "textStrike", "editorTable", "table", "editorUnderline", "textUnderline", "editorUndo", "undo", "editorUnordered