@ansible/ansible-ui-framework 0.0.469 → 0.0.471

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.
@@ -23,5 +23,6 @@ export declare function PageActions<T extends object>(props: {
23
23
  position?: DropdownPosition;
24
24
  /** Indicates if only to show the icon when not collapsed */
25
25
  iconOnly?: boolean;
26
+ onOpen?: (open: boolean) => void;
26
27
  }): JSX.Element;
27
28
  export declare function isHiddenAction<T extends object>(action: IPageAction<T>, selectedItem: T | undefined): boolean;
@@ -43,7 +43,7 @@ function PageActions(props) {
43
43
  return visibleActions;
44
44
  return (_a = visibleActions === null || visibleActions === void 0 ? void 0 : visibleActions.filter(function (action) { return !isPinnedAction(action); })) !== null && _a !== void 0 ? _a : [];
45
45
  }, [collapseButtons, visibleActions]);
46
- return ((0, jsx_runtime_1.jsxs)(react_core_1.Split, __assign({ hasGutter: (!iconOnly && selectedItem !== undefined) || (selectedItems && selectedItems.length > 0) }, { children: [pinnedActions !== undefined && pinnedActions.length > 0 && ((0, jsx_runtime_1.jsx)(PagePinnedActions_1.PagePinnedActions, __assign({}, props, { actions: pinnedActions }))), dropdownActions.length > 0 && ((0, jsx_runtime_1.jsx)(react_core_1.SplitItem, __assign({ isFilled: true, style: { display: 'flex', justifyContent: 'flex-end' } }, { children: (0, jsx_runtime_1.jsx)(PageDropdownAction_1.PageDropdownAction, __assign({}, props, { actions: dropdownActions })) })))] })));
46
+ return ((0, jsx_runtime_1.jsxs)(react_core_1.Split, __assign({ hasGutter: (!iconOnly && selectedItem !== undefined) || (selectedItems && selectedItems.length > 0) }, { children: [pinnedActions !== undefined && pinnedActions.length > 0 && ((0, jsx_runtime_1.jsx)(PagePinnedActions_1.PagePinnedActions, __assign({}, props, { actions: pinnedActions }))), dropdownActions.length > 0 && ((0, jsx_runtime_1.jsx)(react_core_1.SplitItem, __assign({ isFilled: true, style: { display: 'flex', justifyContent: 'flex-end' } }, { children: (0, jsx_runtime_1.jsx)(PageDropdownAction_1.PageDropdownAction, __assign({}, props, { actions: dropdownActions, onOpen: props.onOpen })) })))] })));
47
47
  }
48
48
  exports.PageActions = PageActions;
49
49
  function isPinnedAction(action) {
@@ -11,5 +11,6 @@ export declare function PageDropdownAction<T extends object>(props: {
11
11
  selectedItem?: T;
12
12
  position?: DropdownPosition;
13
13
  iconOnly?: boolean;
14
+ onOpen?: (open: boolean) => void;
14
15
  }): JSX.Element;
15
16
  export declare function filterActionSeperators<T extends object>(actions: IPageAction<T>[]): IPageAction<T>[];
@@ -53,6 +53,10 @@ function PageDropdownAction(props) {
53
53
  var hasIcons = (0, react_1.useMemo)(function () {
54
54
  return actions.find(function (action) { return action.type !== PageActionType_1.PageActionType.seperator && action.icon !== undefined; }) !== undefined;
55
55
  }, [actions]);
56
+ (0, react_1.useEffect)(function () {
57
+ var _a;
58
+ (_a = props.onOpen) === null || _a === void 0 ? void 0 : _a.call(props, dropdownOpen);
59
+ }, [dropdownOpen, props]);
56
60
  if (actions.length === 0)
57
61
  return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
58
62
  var Icon = icon;
@@ -42,9 +42,11 @@ export type PageTableProps<T extends object> = {
42
42
  disableTableView?: boolean;
43
43
  disableListView?: boolean;
44
44
  disableCardView?: boolean;
45
+ disableColumnManagement?: boolean;
45
46
  defaultTableView?: PageTableViewType;
46
47
  disableBodyPadding?: boolean;
47
48
  defaultSubtitle?: ReactNode;
49
+ expandedRow?: (item: T) => ReactNode;
48
50
  };
49
51
  /**
50
52
  * The PageTable component is used for adding a table to a page.
@@ -72,11 +72,12 @@ function PageTable(props) {
72
72
  // const { disableBodyPadding } = props
73
73
  var toolbarActions = props.toolbarActions, filters = props.filters, error = props.error, itemCount = props.itemCount;
74
74
  var _b = (0, PageColumnModal_1.useColumnModal)(props.tableColumns), openColumnModal = _b.openColumnModal, columnModal = _b.columnModal, managedColumns = _b.managedColumns;
75
- var showSelect = (toolbarActions === null || toolbarActions === void 0 ? void 0 : toolbarActions.find(function (toolbarAction) { return PageActionType_1.PageActionType.bulk === toolbarAction.type; })) !==
76
- undefined;
75
+ var showSelect = props.showSelect ||
76
+ (toolbarActions === null || toolbarActions === void 0 ? void 0 : toolbarActions.find(function (toolbarAction) { return PageActionType_1.PageActionType.bulk === toolbarAction.type; })) !==
77
+ undefined;
77
78
  var hasTableViewType = !props.disableTableView;
78
79
  var hasListViewType = !props.disableListView;
79
- // const hasCardViewType = !props.disableCardView
80
+ // const hasCardViewType = !props.disableCardView;
80
81
  var _c = __read((0, react_1.useState)(function () {
81
82
  var _a;
82
83
  return (_a = props.defaultTableView) !== null && _a !== void 0 ? _a : (hasTableViewType
@@ -110,7 +111,7 @@ function PageTable(props) {
110
111
  }
111
112
  exports.PageTable = PageTable;
112
113
  function PageTableView(props) {
113
- var tableColumns = props.tableColumns, pageItems = props.pageItems, selectItem = props.selectItem, unselectItem = props.unselectItem, isSelected = props.isSelected, keyFn = props.keyFn, rowActions = props.rowActions, toolbarActions = props.toolbarActions, itemCount = props.itemCount, perPage = props.perPage, clearAllFilters = props.clearAllFilters, onSelect = props.onSelect, unselectAll = props.unselectAll;
114
+ var tableColumns = props.tableColumns, pageItems = props.pageItems, selectItem = props.selectItem, unselectItem = props.unselectItem, isSelected = props.isSelected, keyFn = props.keyFn, rowActions = props.rowActions, toolbarActions = props.toolbarActions, itemCount = props.itemCount, perPage = props.perPage, clearAllFilters = props.clearAllFilters, onSelect = props.onSelect, unselectAll = props.unselectAll, expandedRow = props.expandedRow;
114
115
  var t = props.t;
115
116
  t = t ? t : function (t) { return t; };
116
117
  var showSelect = props.showSelect ||
@@ -141,10 +142,10 @@ function PageTableView(props) {
141
142
  ? new Array(perPage).fill(0).map(function (_, index) { return ((0, jsx_runtime_1.jsx)(react_table_1.Tr, { children: (0, jsx_runtime_1.jsx)(react_table_1.Td, { children: (0, jsx_runtime_1.jsx)("div", __assign({ style: { paddingTop: 5, paddingBottom: 5 } }, { children: (0, jsx_runtime_1.jsx)(react_core_1.Skeleton, { height: "27px" }) })) }) }, index)); })
142
143
  : pageItems === undefined
143
144
  ? new Array(Math.min(perPage, itemCount)).fill(0).map(function (_, index) { return ((0, jsx_runtime_1.jsxs)(react_table_1.Tr, { children: [showSelect && (0, jsx_runtime_1.jsx)(react_table_1.Td, {}), (0, jsx_runtime_1.jsx)(react_table_1.Td, __assign({ colSpan: tableColumns.length }, { children: (0, jsx_runtime_1.jsx)("div", __assign({ style: { paddingTop: 5, paddingBottom: 5 } }, { children: (0, jsx_runtime_1.jsx)(react_core_1.Skeleton, { height: "27px" }) })) }))] }, index)); })
144
- : pageItems === null || pageItems === void 0 ? void 0 : pageItems.map(function (item, rowIndex) { return ((0, jsx_runtime_1.jsx)(TableRow, { columns: tableColumns, item: item, isItemSelected: isSelected === null || isSelected === void 0 ? void 0 : isSelected(item), selectItem: selectItem, unselectItem: unselectItem, rowActions: rowActions, rowIndex: rowIndex, showSelect: showSelect, scrollLeft: scroll.left > 0, scrollRight: scroll.right > 1, unselectAll: unselectAll, onSelect: onSelect }, keyFn ? keyFn(item) : rowIndex)); }) })] })), itemCount === 0 && ((0, jsx_runtime_1.jsxs)(react_core_1.EmptyState, __assign({ style: { paddingTop: 48 } }, { children: [(0, jsx_runtime_1.jsx)(react_core_1.EmptyStateIcon, { icon: react_icons_1.SearchIcon }), (0, jsx_runtime_1.jsx)(react_core_1.Title, __assign({ headingLevel: "h2", size: "lg" }, { children: t('No results found') })), (0, jsx_runtime_1.jsx)(react_core_1.EmptyStateBody, { children: t('No results match this filter criteria. Adjust your filters and try again.') }), clearAllFilters && ((0, jsx_runtime_1.jsx)(react_core_1.EmptyStateSecondaryActions, { children: (0, jsx_runtime_1.jsx)(react_core_1.Button, __assign({ variant: "link", onClick: clearAllFilters }, { children: t('Clear all filters') })) }))] })))] })));
145
+ : pageItems === null || pageItems === void 0 ? void 0 : pageItems.map(function (item, rowIndex) { return ((0, jsx_runtime_1.jsx)(TableRow, { columns: tableColumns, item: item, isItemSelected: isSelected === null || isSelected === void 0 ? void 0 : isSelected(item), selectItem: selectItem, unselectItem: unselectItem, rowActions: rowActions, rowIndex: rowIndex, showSelect: showSelect, scrollLeft: scroll.left > 0, scrollRight: scroll.right > 1, unselectAll: unselectAll, onSelect: onSelect, expandedRow: expandedRow }, keyFn ? keyFn(item) : rowIndex)); }) })] })), itemCount === 0 && ((0, jsx_runtime_1.jsxs)(react_core_1.EmptyState, __assign({ style: { paddingTop: 48 } }, { children: [(0, jsx_runtime_1.jsx)(react_core_1.EmptyStateIcon, { icon: react_icons_1.SearchIcon }), (0, jsx_runtime_1.jsx)(react_core_1.Title, __assign({ headingLevel: "h2", size: "lg" }, { children: t('No results found') })), (0, jsx_runtime_1.jsx)(react_core_1.EmptyStateBody, { children: t('No results match this filter criteria. Adjust your filters and try again.') }), clearAllFilters && ((0, jsx_runtime_1.jsx)(react_core_1.EmptyStateSecondaryActions, { children: (0, jsx_runtime_1.jsx)(react_core_1.Button, __assign({ variant: "link", onClick: clearAllFilters }, { children: t('Clear all filters') })) }))] })))] })));
145
146
  }
146
147
  function TableHead(props) {
147
- var columns = props.tableColumns, itemActions = props.rowActions, sort = props.sort, setSort = props.setSort, sortDirection = props.sortDirection, setSortDirection = props.setSortDirection, showSelect = props.showSelect, onSelect = props.onSelect;
148
+ var columns = props.tableColumns, itemActions = props.rowActions, sort = props.sort, setSort = props.setSort, sortDirection = props.sortDirection, setSortDirection = props.setSortDirection, showSelect = props.showSelect, onSelect = props.onSelect, expandedRow = props.expandedRow;
148
149
  var settings = (0, Settings_1.useSettings)();
149
150
  var getColumnSort = (0, react_1.useCallback)(function (columnIndex, column) {
150
151
  if (!column.sort)
@@ -164,78 +165,82 @@ function TableHead(props) {
164
165
  columnIndex: columnIndex,
165
166
  };
166
167
  }, [setSort, setSortDirection, sort, sortDirection]);
167
- return ((0, jsx_runtime_1.jsx)(react_table_1.Thead, { children: (0, jsx_runtime_1.jsxs)(react_table_1.Tr, { children: [(showSelect || onSelect) && ((0, jsx_runtime_1.jsx)(react_table_1.Th, __assign({ isStickyColumn: true, style: {
168
- width: '0%',
169
- backgroundColor: settings.theme === 'dark' ? 'var(--pf-global--BackgroundColor--300)' : undefined,
170
- }, stickyMinWidth: "45px", hasRightBorder: props.scrollLeft }, { children: "\u00A0" }))), columns
168
+ return ((0, jsx_runtime_1.jsx)(react_table_1.Thead, { children: (0, jsx_runtime_1.jsxs)(react_table_1.Tr, __assign({ style: {
169
+ backgroundColor: settings.theme === 'dark' ? 'var(--pf-global--BackgroundColor--300)' : undefined,
170
+ } }, { children: [expandedRow && (0, jsx_runtime_1.jsx)(react_table_1.Th, { style: { padding: 0, backgroundColor: 'inherit' } }), (showSelect || onSelect) && ((0, jsx_runtime_1.jsx)(react_table_1.Th, __assign({ isStickyColumn: true, stickyMinWidth: "0px", hasRightBorder: props.scrollLeft, style: { backgroundColor: 'inherit' } }, { children: "\u00A0" }))), columns
171
171
  .filter(function (column) { return column.enabled !== false; })
172
172
  .map(function (column, index) {
173
- var _a;
174
- return ((0, jsx_runtime_1.jsx)(react_table_1.Th, __assign({ modifier: "fitContent", style: {
175
- minWidth: (_a = column.minWidth) !== null && _a !== void 0 ? _a : 0,
176
- maxWidth: column.maxWidth,
177
- backgroundColor: settings.theme === 'dark'
178
- ? 'var(--pf-global--BackgroundColor--300)'
179
- : undefined,
180
- width: column.isIdColumn ? '0%' : undefined,
181
- }, sort: getColumnSort(index, column) }, { children: column.header }), column.header));
182
- }), itemActions !== undefined && ((0, jsx_runtime_1.jsx)(react_table_1.Th, __assign({ style: {
183
- paddingRight: 8,
184
- paddingLeft: 0,
185
- width: '0%',
173
+ return ((0, jsx_runtime_1.jsx)(react_table_1.Th, __assign({ sort: getColumnSort(index, column), style: {
174
+ minWidth: column.minWidth === 0
175
+ ? '1%'
176
+ : column.minWidth !== undefined
177
+ ? column.minWidth
178
+ : undefined,
179
+ maxWidth: column.maxWidth !== undefined ? column.maxWidth : undefined,
180
+ backgroundColor: 'inherit',
181
+ } }, { children: column.header }), column.header));
182
+ }), itemActions !== undefined && ((0, jsx_runtime_1.jsx)(react_table_1.Td, __assign({ isActionCell: true, isStickyColumn: true, stickyMinWidth: "0px", style: {
186
183
  right: 0,
187
- backgroundColor: settings.theme === 'dark' ? 'var(--pf-global--BackgroundColor--300)' : undefined,
188
- }, isStickyColumn: true, stickyMinWidth: "45px", className: props.scrollRight ? 'pf-m-border-left' : undefined }, { children: "\u00A0" })))] }) }));
184
+ padding: 0,
185
+ paddingRight: 0,
186
+ backgroundColor: 'inherit',
187
+ zIndex: 302,
188
+ }, className: props.scrollRight ? 'pf-m-border-left' : undefined }, { children: "\u00A0" })))] })) }));
189
189
  }
190
190
  function TableRow(props) {
191
- var columns = props.columns, selectItem = props.selectItem, unselectItem = props.unselectItem, unselectAll = props.unselectAll, isItemSelected = props.isItemSelected, item = props.item, rowActions = props.rowActions, rowIndex = props.rowIndex, showSelect = props.showSelect, onSelect = props.onSelect;
192
- var md = (0, useBreakPoint_1.useBreakpoint)('xl');
193
- return ((0, jsx_runtime_1.jsxs)(react_table_1.Tr, __assign({ className: isItemSelected ? 'selected' : undefined,
194
- // style={{ backgroundColor: theme === ThemeE.Dark ? 'transparent' : undefined }}
195
- isRowSelected: isItemSelected, style: { boxShadow: 'unset' } }, { children: [showSelect && ((0, jsx_runtime_1.jsx)(react_table_1.Th, { select: isItemSelected !== undefined
196
- ? {
197
- onSelect: function (_event, isSelecting) {
198
- if (isSelecting) {
199
- selectItem === null || selectItem === void 0 ? void 0 : selectItem(item);
191
+ var columns = props.columns, selectItem = props.selectItem, unselectItem = props.unselectItem, unselectAll = props.unselectAll, isItemSelected = props.isItemSelected, item = props.item, rowActions = props.rowActions, rowIndex = props.rowIndex, showSelect = props.showSelect, onSelect = props.onSelect, expandedRow = props.expandedRow;
192
+ var _a = __read((0, react_1.useState)(false), 2), expanded = _a[0], setExpanded = _a[1];
193
+ var settings = (0, Settings_1.useSettings)();
194
+ var expandedContent = expandedRow === null || expandedRow === void 0 ? void 0 : expandedRow(item);
195
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(react_table_1.Tr, __assign({ className: isItemSelected ? 'selected' : undefined, isRowSelected: expanded, style: {
196
+ boxShadow: 'unset',
197
+ borderBottom: expanded ? 'unset' : undefined,
198
+ } }, { children: [expandedRow && ((0, jsx_runtime_1.jsx)(react_table_1.Td, { expand: expandedContent
199
+ ? {
200
+ rowIndex: rowIndex,
201
+ isExpanded: expanded,
202
+ onToggle: function () { return setExpanded(function (expanded) { return !expanded; }); },
200
203
  }
201
- else {
202
- unselectItem === null || unselectItem === void 0 ? void 0 : unselectItem(item);
204
+ : undefined, style: { paddingLeft: expandedContent ? 8 : 4 } })), showSelect && ((0, jsx_runtime_1.jsx)(react_table_1.Th, { select: isItemSelected !== undefined
205
+ ? {
206
+ onSelect: function (_event, isSelecting) {
207
+ if (isSelecting) {
208
+ selectItem === null || selectItem === void 0 ? void 0 : selectItem(item);
209
+ }
210
+ else {
211
+ unselectItem === null || unselectItem === void 0 ? void 0 : unselectItem(item);
212
+ }
213
+ },
214
+ isSelected: isItemSelected,
203
215
  }
204
- },
205
- isSelected: isItemSelected,
206
- }
207
- : undefined, style: { width: '0%', paddingLeft: md ? undefined : 20, paddingRight: 16 }, isStickyColumn: true, stickyMinWidth: "0px", hasRightBorder: props.scrollLeft })), onSelect && ((0, jsx_runtime_1.jsx)(react_table_1.Td, { select: {
208
- rowIndex: rowIndex,
209
- onSelect: function () {
210
- unselectAll === null || unselectAll === void 0 ? void 0 : unselectAll();
211
- selectItem === null || selectItem === void 0 ? void 0 : selectItem(item);
212
- onSelect === null || onSelect === void 0 ? void 0 : onSelect(item);
213
- },
214
- isSelected: isItemSelected !== null && isItemSelected !== void 0 ? isItemSelected : false,
215
- // disable: !isRepoSelectable(repo),
216
- variant: 'radio',
217
- }, style: {
218
- width: '0%',
219
- paddingLeft: md ? undefined : 20,
220
- position: 'sticky',
221
- left: 0,
222
- background: 'var(--pf-c-table__sticky-column--BackgroundColor)',
223
- zIndex: 1,
224
- } })), (0, jsx_runtime_1.jsx)(TableCells, { rowIndex: rowIndex, columns: columns, item: item, rowActions: rowActions, scrollLeft: props.scrollLeft, scrollRight: props.scrollRight })] })));
216
+ : undefined, isStickyColumn: true, stickyMinWidth: "0px", hasRightBorder: props.scrollLeft })), onSelect && ((0, jsx_runtime_1.jsx)(react_table_1.Td, { select: {
217
+ rowIndex: rowIndex,
218
+ onSelect: function () {
219
+ unselectAll === null || unselectAll === void 0 ? void 0 : unselectAll();
220
+ selectItem === null || selectItem === void 0 ? void 0 : selectItem(item);
221
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect(item);
222
+ },
223
+ isSelected: isItemSelected !== null && isItemSelected !== void 0 ? isItemSelected : false,
224
+ variant: 'radio',
225
+ }, isStickyColumn: true, stickyMinWidth: "0px", hasRightBorder: props.scrollLeft })), (0, jsx_runtime_1.jsx)(TableCells, { columns: columns, item: item, rowActions: rowActions, scrollLeft: props.scrollLeft, scrollRight: props.scrollRight })] })), expandedRow && expanded && expandedContent && ((0, jsx_runtime_1.jsxs)(react_table_1.Tr, __assign({ className: isItemSelected ? 'selected' : undefined, isExpanded: expanded, style: { boxShadow: 'unset' } }, { children: [(0, jsx_runtime_1.jsx)(react_table_1.Td, {}), showSelect && ((0, jsx_runtime_1.jsx)(react_table_1.Th, { isStickyColumn: true, stickyMinWidth: "0px", hasRightBorder: props.scrollLeft })), onSelect && (0, jsx_runtime_1.jsx)(react_table_1.Td, { isStickyColumn: true, stickyMinWidth: "0px", hasRightBorder: props.scrollLeft }), (0, jsx_runtime_1.jsx)(react_table_1.Td, __assign({ colSpan: columns.filter(function (column) { return column.enabled !== false; }).length, style: { paddingBottom: settings.tableLayout === 'compact' ? 12 : 24, paddingTop: 0 } }, { children: (0, jsx_runtime_1.jsx)(react_table_1.CollapseColumn, { children: expandedContent }) })), rowActions !== undefined && rowActions.length > 0 && ((0, jsx_runtime_1.jsx)(react_table_1.Td, __assign({ isActionCell: true, isStickyColumn: true, stickyMinWidth: "0px", style: {
226
+ right: 0,
227
+ padding: 0,
228
+ paddingRight: 0,
229
+ }, className: props.scrollRight ? 'pf-m-border-left' : undefined }, { children: "\u00A0" })))] })))] }));
225
230
  }
226
231
  function TableCells(props) {
227
- var columns = props.columns, item = props.item, rowActions = props.rowActions, rowIndex = props.rowIndex;
232
+ var columns = props.columns, item = props.item, rowActions = props.rowActions;
233
+ var _a = __read((0, react_1.useState)(false), 2), actionsExpanded = _a[0], setActionsExpanded = _a[1];
228
234
  return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [columns
229
235
  .filter(function (column) { return column.enabled !== false; })
230
236
  .map(function (column) {
231
- return ((0, jsx_runtime_1.jsx)(react_table_1.Td, __assign({ dataLabel: column.header, modifier: "nowrap" }, { children: (0, jsx_runtime_1.jsx)(TableColumnCell, { item: item, column: column }) }), column.header));
232
- }), rowActions !== undefined && rowActions.length > 0 && ((0, jsx_runtime_1.jsx)(react_table_1.Th, __assign({ style: {
233
- zIndex: 100 - rowIndex,
234
- paddingRight: 8,
235
- paddingLeft: 8,
236
- width: '0%',
237
+ return ((0, jsx_runtime_1.jsx)(react_table_1.Td, __assign({ dataLabel: column.header, modifier: "nowrap", style: { width: column.minWidth === 0 ? '0%' : undefined } }, { children: (0, jsx_runtime_1.jsx)(TableColumnCell, { item: item, column: column }) }), column.header));
238
+ }), rowActions !== undefined && rowActions.length > 0 && ((0, jsx_runtime_1.jsx)(react_table_1.Td, __assign({ isActionCell: true, isStickyColumn: true, stickyMinWidth: "0px", style: {
237
239
  right: 0,
238
- }, isStickyColumn: true, stickyMinWidth: "0px", className: props.scrollRight ? 'pf-m-border-left' : undefined }, { children: (0, jsx_runtime_1.jsx)(PageActions_1.PageActions, { actions: rowActions, selectedItem: item, position: react_core_1.DropdownPosition.right, iconOnly: true }) })))] }));
240
+ padding: 0,
241
+ paddingRight: 0,
242
+ zIndex: actionsExpanded ? 301 : undefined,
243
+ }, className: props.scrollRight ? 'pf-m-border-left' : undefined }, { children: (0, jsx_runtime_1.jsx)(PageActions_1.PageActions, { actions: rowActions, selectedItem: item, position: react_core_1.DropdownPosition.right, iconOnly: true, onOpen: setActionsExpanded }) })))] }));
239
244
  }
240
245
  var TableColumnSomething;
241
246
  (function (TableColumnSomething) {
@@ -56,5 +56,9 @@ export type PagetableToolbarProps<T extends object> = {
56
56
  showSelect?: boolean;
57
57
  viewType: PageTableViewType;
58
58
  setViewType: (viewType: PageTableViewType) => void;
59
+ disableTableView?: boolean;
60
+ disableListView?: boolean;
61
+ disableCardView?: boolean;
62
+ disableColumnManagement?: boolean;
59
63
  };
60
64
  export declare function PageTableToolbar<T extends object>(props: PagetableToolbarProps<T>): JSX.Element;
@@ -92,6 +92,13 @@ function PageTableToolbar(props) {
92
92
  return toolbarFilters ? ((toolbarFilters === null || toolbarFilters === void 0 ? void 0 : toolbarFilters.length) > 0 ? toolbarFilters[0].key : '') : '';
93
93
  }), 2), selectedFilter = _b[0], setSeletedFilter = _b[1];
94
94
  var settings = (0, Settings_1.useSettings)();
95
+ var viewTypeCount = 0;
96
+ if (!props.disableTableView)
97
+ viewTypeCount++;
98
+ if (!props.disableCardView)
99
+ viewTypeCount++;
100
+ if (!props.disableListView)
101
+ viewTypeCount++;
95
102
  if (!showToolbar) {
96
103
  return (0, jsx_runtime_1.jsx)(react_1.Fragment, {});
97
104
  }
@@ -159,7 +166,13 @@ function PageTableToolbar(props) {
159
166
  return newState;
160
167
  });
161
168
  }, showToolbarItem: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}) }), filter.label));
162
- })] })) }))), (0, jsx_runtime_1.jsx)(react_core_1.ToolbarGroup, __assign({ variant: "button-group", style: { zIndex: 302 } }, { children: (0, jsx_runtime_1.jsx)(PageActions_1.PageActions, { actions: toolbarActions, selectedItems: selectedItems, wrapper: react_core_1.ToolbarItem }) })), (0, jsx_runtime_1.jsx)("div", { style: { flexGrow: 1 } }), (0, jsx_runtime_1.jsxs)(react_core_1.ToolbarGroup, __assign({ variant: "button-group", style: { zIndex: 302 } }, { children: [openColumnModal && viewType === 'table' && ((0, jsx_runtime_1.jsx)(react_core_1.ToolbarItem, { children: (0, jsx_runtime_1.jsx)(react_core_1.Tooltip, __assign({ content: 'Manage columns' }, { children: (0, jsx_runtime_1.jsx)(react_core_1.Button, { variant: "plain", icon: (0, jsx_runtime_1.jsx)(react_icons_1.ColumnsIcon, {}), onClick: openColumnModal }) })) })), (0, jsx_runtime_1.jsx)(react_core_1.ToolbarItem, { children: (0, jsx_runtime_1.jsx)(react_core_1.ToggleGroup, __assign({ "aria-label": "table view toggle" }, { children: [PageTableViewType_1.PageTableViewTypeE.Table, PageTableViewType_1.PageTableViewTypeE.List, PageTableViewType_1.PageTableViewTypeE.Cards].map(function (vt) {
169
+ })] })) }))), (0, jsx_runtime_1.jsx)(react_core_1.ToolbarGroup, __assign({ variant: "button-group", style: { zIndex: 302 } }, { children: (0, jsx_runtime_1.jsx)(PageActions_1.PageActions, { actions: toolbarActions, selectedItems: selectedItems, wrapper: react_core_1.ToolbarItem }) })), (0, jsx_runtime_1.jsx)("div", { style: { flexGrow: 1 } }), (0, jsx_runtime_1.jsxs)(react_core_1.ToolbarGroup, __assign({ variant: "button-group", style: { zIndex: 302 } }, { children: [!props.disableColumnManagement && openColumnModal && viewType === 'table' && ((0, jsx_runtime_1.jsx)(react_core_1.ToolbarItem, { children: (0, jsx_runtime_1.jsx)(react_core_1.Tooltip, __assign({ content: 'Manage columns' }, { children: (0, jsx_runtime_1.jsx)(react_core_1.Button, { variant: "plain", icon: (0, jsx_runtime_1.jsx)(react_icons_1.ColumnsIcon, {}), onClick: openColumnModal }) })) })), viewTypeCount > 1 && ((0, jsx_runtime_1.jsx)(react_core_1.ToolbarItem, { children: (0, jsx_runtime_1.jsx)(react_core_1.ToggleGroup, __assign({ "aria-label": "table view toggle" }, { children: [
170
+ !props.disableTableView && PageTableViewType_1.PageTableViewTypeE.Table,
171
+ !props.disableListView && PageTableViewType_1.PageTableViewTypeE.List,
172
+ !props.disableCardView && PageTableViewType_1.PageTableViewTypeE.Cards,
173
+ ]
174
+ .filter(function (i) { return i; })
175
+ .map(function (vt) {
163
176
  switch (vt) {
164
177
  case PageTableViewType_1.PageTableViewTypeE.Cards:
165
178
  return ((0, jsx_runtime_1.jsx)(react_core_1.Tooltip, __assign({ content: 'Card view', position: "top-end", enableFlip: false }, { children: (0, jsx_runtime_1.jsx)(react_core_1.ToggleGroupItem, { icon: (0, jsx_runtime_1.jsx)(react_icons_1.ThLargeIcon, {}), isSelected: viewType === PageTableViewType_1.PageTableViewTypeE.Cards, onClick: function () { return setViewType === null || setViewType === void 0 ? void 0 : setViewType(PageTableViewType_1.PageTableViewTypeE.Cards); }, "aria-label": "card view" }) }), vt));
@@ -168,7 +181,7 @@ function PageTableToolbar(props) {
168
181
  case PageTableViewType_1.PageTableViewTypeE.Table:
169
182
  return ((0, jsx_runtime_1.jsx)(react_core_1.Tooltip, __assign({ content: 'Table view', position: "top-end", enableFlip: false }, { children: (0, jsx_runtime_1.jsx)(react_core_1.ToggleGroupItem, { icon: (0, jsx_runtime_1.jsx)(react_icons_1.TableIcon, {}), isSelected: viewType === PageTableViewType_1.PageTableViewTypeE.Table, onClick: function () { return setViewType === null || setViewType === void 0 ? void 0 : setViewType(PageTableViewType_1.PageTableViewTypeE.Table); }, "aria-label": "table view" }) }), vt));
170
183
  }
171
- }) })) })] })), (0, jsx_runtime_1.jsx)(react_core_1.ToolbarItem, __assign({ visibility: { default: 'hidden', '2xl': 'visible' } }, { children: (0, jsx_runtime_1.jsx)(react_core_1.Pagination, { variant: react_core_1.PaginationVariant.top, isCompact: true, itemCount: itemCount, perPage: perPage, page: page, onSetPage: onSetPage, onPerPageSelect: onPerPageSelect, style: { marginTop: -8, marginBottom: -8 } }) }))] }) })));
184
+ }) })) }))] })), (0, jsx_runtime_1.jsx)(react_core_1.ToolbarItem, __assign({ visibility: { default: 'hidden', '2xl': 'visible' } }, { children: (0, jsx_runtime_1.jsx)(react_core_1.Pagination, { variant: react_core_1.PaginationVariant.top, isCompact: true, itemCount: itemCount, perPage: perPage, page: page, onSetPage: onSetPage, onPerPageSelect: onPerPageSelect, style: { marginTop: -8, marginBottom: -8 } }) }))] }) })));
172
185
  }
173
186
  exports.PageTableToolbar = PageTableToolbar;
174
187
  function ToolbarFilterInput(props) {
@@ -76,6 +76,6 @@ function SelectDialog(props) {
76
76
  flexDirection: 'column',
77
77
  maxHeight: 400,
78
78
  overflow: 'hidden',
79
- } }, { children: (0, jsx_runtime_1.jsx)(PageTable_1.PageTable, __assign({ tableColumns: tableColumns, toolbarFilters: toolbarFilters, emptyStateTitle: "No organizations found", errorStateTitle: "Error loading organizations" }, view, { onSelect: function () { return null; } })) })) }))] })));
79
+ } }, { children: (0, jsx_runtime_1.jsx)(PageTable_1.PageTable, __assign({ tableColumns: tableColumns, toolbarFilters: toolbarFilters, emptyStateTitle: "No organizations found", errorStateTitle: "Error loading organizations" }, view, { onSelect: function () { return null; }, disableCardView: true, disableListView: true, disableColumnManagement: true })) })) }))] })));
80
80
  }
81
81
  exports.SelectDialog = SelectDialog;
@@ -51,7 +51,7 @@ function SelectMultipleDialog(props) {
51
51
  flexDirection: 'column',
52
52
  maxHeight: 500,
53
53
  overflow: 'hidden',
54
- } }, { children: (0, jsx_runtime_1.jsx)(PageTable_1.PageTable, __assign({ tableColumns: tableColumns, toolbarFilters: toolbarFilters }, view, { emptyStateTitle: (_a = props.emptyStateTitle) !== null && _a !== void 0 ? _a : translations.noItemsFound, errorStateTitle: (_b = props.errorStateTitle) !== null && _b !== void 0 ? _b : translations.errorText, showSelect: true })) })) })));
54
+ } }, { children: (0, jsx_runtime_1.jsx)(PageTable_1.PageTable, __assign({ tableColumns: tableColumns, toolbarFilters: toolbarFilters }, view, { emptyStateTitle: (_a = props.emptyStateTitle) !== null && _a !== void 0 ? _a : translations.noItemsFound, errorStateTitle: (_b = props.errorStateTitle) !== null && _b !== void 0 ? _b : translations.errorText, showSelect: true, disableCardView: true, disableListView: true, disableColumnManagement: true })) })) })));
55
55
  }
56
56
  exports.SelectMultipleDialog = SelectMultipleDialog;
57
57
  function useSelectMultipleDialog() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ansible/ansible-ui-framework",
3
3
  "description": "A framework for building applications using PatternFly.",
4
- "version": "0.0.469",
4
+ "version": "0.0.471",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",