@ansible/ansible-ui-framework 0.0.469 → 0.0.470

Sign up to get free protection for your applications and to get access to all the features.
@@ -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;
@@ -45,6 +45,7 @@ export type PageTableProps<T extends object> = {
45
45
  defaultTableView?: PageTableViewType;
46
46
  disableBodyPadding?: boolean;
47
47
  defaultSubtitle?: ReactNode;
48
+ expandedRow?: (item: T) => ReactNode;
48
49
  };
49
50
  /**
50
51
  * The PageTable component is used for adding a table to a page.
@@ -110,7 +110,7 @@ function PageTable(props) {
110
110
  }
111
111
  exports.PageTable = PageTable;
112
112
  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;
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, expandedRow = props.expandedRow;
114
114
  var t = props.t;
115
115
  t = t ? t : function (t) { return t; };
116
116
  var showSelect = props.showSelect ||
@@ -141,10 +141,10 @@ function PageTableView(props) {
141
141
  ? 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
142
  : pageItems === undefined
143
143
  ? 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') })) }))] })))] })));
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, 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
145
  }
146
146
  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;
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, expandedRow = props.expandedRow;
148
148
  var settings = (0, Settings_1.useSettings)();
149
149
  var getColumnSort = (0, react_1.useCallback)(function (columnIndex, column) {
150
150
  if (!column.sort)
@@ -164,78 +164,82 @@ function TableHead(props) {
164
164
  columnIndex: columnIndex,
165
165
  };
166
166
  }, [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
167
+ return ((0, jsx_runtime_1.jsx)(react_table_1.Thead, { children: (0, jsx_runtime_1.jsxs)(react_table_1.Tr, __assign({ style: {
168
+ backgroundColor: settings.theme === 'dark' ? 'var(--pf-global--BackgroundColor--300)' : undefined,
169
+ } }, { 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
170
  .filter(function (column) { return column.enabled !== false; })
172
171
  .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%',
172
+ return ((0, jsx_runtime_1.jsx)(react_table_1.Th, __assign({ sort: getColumnSort(index, column), style: {
173
+ minWidth: column.minWidth === 0
174
+ ? '1%'
175
+ : column.minWidth !== undefined
176
+ ? column.minWidth
177
+ : undefined,
178
+ maxWidth: column.maxWidth !== undefined ? column.maxWidth : undefined,
179
+ backgroundColor: 'inherit',
180
+ } }, { children: column.header }), column.header));
181
+ }), itemActions !== undefined && ((0, jsx_runtime_1.jsx)(react_table_1.Td, __assign({ isActionCell: true, isStickyColumn: true, stickyMinWidth: "0px", style: {
186
182
  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" })))] }) }));
183
+ padding: 0,
184
+ paddingRight: 0,
185
+ backgroundColor: 'inherit',
186
+ zIndex: 302,
187
+ }, className: props.scrollRight ? 'pf-m-border-left' : undefined }, { children: "\u00A0" })))] })) }));
189
188
  }
190
189
  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);
190
+ 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;
191
+ var _a = __read((0, react_1.useState)(false), 2), expanded = _a[0], setExpanded = _a[1];
192
+ var settings = (0, Settings_1.useSettings)();
193
+ var expandedContent = expandedRow === null || expandedRow === void 0 ? void 0 : expandedRow(item);
194
+ 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: {
195
+ boxShadow: 'unset',
196
+ borderBottom: expanded ? 'unset' : undefined,
197
+ } }, { children: [expandedRow && ((0, jsx_runtime_1.jsx)(react_table_1.Td, { expand: expandedContent
198
+ ? {
199
+ rowIndex: rowIndex,
200
+ isExpanded: expanded,
201
+ onToggle: function () { return setExpanded(function (expanded) { return !expanded; }); },
200
202
  }
201
- else {
202
- unselectItem === null || unselectItem === void 0 ? void 0 : unselectItem(item);
203
+ : undefined, style: { paddingLeft: expandedContent ? 8 : 4 } })), showSelect && ((0, jsx_runtime_1.jsx)(react_table_1.Th, { select: isItemSelected !== undefined
204
+ ? {
205
+ onSelect: function (_event, isSelecting) {
206
+ if (isSelecting) {
207
+ selectItem === null || selectItem === void 0 ? void 0 : selectItem(item);
208
+ }
209
+ else {
210
+ unselectItem === null || unselectItem === void 0 ? void 0 : unselectItem(item);
211
+ }
212
+ },
213
+ isSelected: isItemSelected,
203
214
  }
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 })] })));
215
+ : undefined, isStickyColumn: true, stickyMinWidth: "0px", hasRightBorder: props.scrollLeft })), onSelect && ((0, jsx_runtime_1.jsx)(react_table_1.Td, { select: {
216
+ rowIndex: rowIndex,
217
+ onSelect: function () {
218
+ unselectAll === null || unselectAll === void 0 ? void 0 : unselectAll();
219
+ selectItem === null || selectItem === void 0 ? void 0 : selectItem(item);
220
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect(item);
221
+ },
222
+ isSelected: isItemSelected !== null && isItemSelected !== void 0 ? isItemSelected : false,
223
+ variant: 'radio',
224
+ }, 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: {
225
+ right: 0,
226
+ padding: 0,
227
+ paddingRight: 0,
228
+ }, className: props.scrollRight ? 'pf-m-border-left' : undefined }, { children: "\u00A0" })))] })))] }));
225
229
  }
226
230
  function TableCells(props) {
227
- var columns = props.columns, item = props.item, rowActions = props.rowActions, rowIndex = props.rowIndex;
231
+ var columns = props.columns, item = props.item, rowActions = props.rowActions;
232
+ var _a = __read((0, react_1.useState)(false), 2), actionsExpanded = _a[0], setActionsExpanded = _a[1];
228
233
  return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [columns
229
234
  .filter(function (column) { return column.enabled !== false; })
230
235
  .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%',
236
+ 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));
237
+ }), rowActions !== undefined && rowActions.length > 0 && ((0, jsx_runtime_1.jsx)(react_table_1.Td, __assign({ isActionCell: true, isStickyColumn: true, stickyMinWidth: "0px", style: {
237
238
  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 }) })))] }));
239
+ padding: 0,
240
+ paddingRight: 0,
241
+ zIndex: actionsExpanded ? 301 : undefined,
242
+ }, 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
243
  }
240
244
  var TableColumnSomething;
241
245
  (function (TableColumnSomething) {
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.470",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",