@ansible/ansible-ui-framework 0.0.190
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -0
- package/cjs/framework/BulkActionDialog.js +217 -0
- package/cjs/framework/BulkProgressDialog.js +240 -0
- package/cjs/framework/FilterDrawer.js +64 -0
- package/cjs/framework/PageBody.js +47 -0
- package/cjs/framework/PageCatalog.js +178 -0
- package/cjs/framework/PageCells.js +141 -0
- package/cjs/framework/PageColumnModal.js +130 -0
- package/cjs/framework/PageDataList.js +61 -0
- package/cjs/framework/PageDialog.js +28 -0
- package/cjs/framework/PageForm.js +376 -0
- package/cjs/framework/PageFramework.js +11 -0
- package/cjs/framework/PageHeader.js +96 -0
- package/cjs/framework/PageLayout.js +41 -0
- package/cjs/framework/PagePagination.js +28 -0
- package/cjs/framework/PageTable.js +205 -0
- package/cjs/framework/PageTabs.js +82 -0
- package/cjs/framework/PageToolbar.js +209 -0
- package/cjs/framework/Settings.js +122 -0
- package/cjs/framework/TypedActions.js +303 -0
- package/cjs/framework/components/BulkSelector.js +89 -0
- package/cjs/framework/components/Collapse.js +22 -0
- package/cjs/framework/components/DetailInfo.js +23 -0
- package/cjs/framework/components/Details.js +88 -0
- package/cjs/framework/components/Dotted.js +19 -0
- package/cjs/framework/components/DropdownControlled.js +28 -0
- package/cjs/framework/components/ErrorBoundary.js +45 -0
- package/cjs/framework/components/Grid.js +64 -0
- package/cjs/framework/components/Help.js +24 -0
- package/cjs/framework/components/IconWrapper.js +55 -0
- package/cjs/framework/components/LoadingPage.js +14 -0
- package/cjs/framework/components/Masonry.js +113 -0
- package/cjs/framework/components/Scrollable.js +87 -0
- package/cjs/framework/components/SingleSelect.js +70 -0
- package/cjs/framework/components/patternfly-colors.js +32 -0
- package/cjs/framework/components/useBreakPoint.js +145 -0
- package/cjs/framework/components/useOpen.js +36 -0
- package/cjs/framework/components/useWindowLocation.js +70 -0
- package/cjs/framework/index.js +39 -0
- package/cjs/framework/useFrameworkTranslations.js +38 -0
- package/cjs/framework/useSelectDialog.js +81 -0
- package/cjs/framework/useSelectMultipleDialog.js +62 -0
- package/cjs/framework/useTableItems.js +485 -0
- package/cjs/framework/useView.js +155 -0
- package/cjs/framework/utils/compare.js +59 -0
- package/cjs/framework/utils/download-file.js +23 -0
- package/cjs/framework/utils/random-string.js +17 -0
- package/cjs/frontend/controller/access/organizations/Organization.js +2 -0
- package/mjs/framework/BulkActionDialog.d.ts +25 -0
- package/mjs/framework/BulkActionDialog.js +104 -0
- package/mjs/framework/BulkProgressDialog.d.ts +20 -0
- package/mjs/framework/BulkProgressDialog.js +131 -0
- package/mjs/framework/FilterDrawer.d.ts +8 -0
- package/mjs/framework/FilterDrawer.js +24 -0
- package/mjs/framework/PageBody.d.ts +4 -0
- package/mjs/framework/PageBody.js +29 -0
- package/mjs/framework/PageCatalog.d.ts +113 -0
- package/mjs/framework/PageCatalog.js +140 -0
- package/mjs/framework/PageCells.d.ts +35 -0
- package/mjs/framework/PageCells.js +102 -0
- package/mjs/framework/PageColumnModal.d.ts +7 -0
- package/mjs/framework/PageColumnModal.js +64 -0
- package/mjs/framework/PageDataList.d.ts +46 -0
- package/mjs/framework/PageDataList.js +45 -0
- package/mjs/framework/PageDialog.d.ts +10 -0
- package/mjs/framework/PageDialog.js +12 -0
- package/mjs/framework/PageForm.d.ts +147 -0
- package/mjs/framework/PageForm.js +316 -0
- package/mjs/framework/PageFramework.d.ts +4 -0
- package/mjs/framework/PageFramework.js +7 -0
- package/mjs/framework/PageHeader.d.ts +45 -0
- package/mjs/framework/PageHeader.js +80 -0
- package/mjs/framework/PageLayout.d.ts +15 -0
- package/mjs/framework/PageLayout.js +23 -0
- package/mjs/framework/PagePagination.d.ts +10 -0
- package/mjs/framework/PagePagination.js +22 -0
- package/mjs/framework/PageTable.d.ts +68 -0
- package/mjs/framework/PageTable.js +170 -0
- package/mjs/framework/PageTabs.d.ts +15 -0
- package/mjs/framework/PageTabs.js +45 -0
- package/mjs/framework/PageToolbar.d.ts +57 -0
- package/mjs/framework/PageToolbar.js +148 -0
- package/mjs/framework/Settings.d.ts +19 -0
- package/mjs/framework/Settings.js +87 -0
- package/mjs/framework/TypedActions.d.ts +80 -0
- package/mjs/framework/TypedActions.js +251 -0
- package/mjs/framework/components/BulkSelector.d.ts +11 -0
- package/mjs/framework/components/BulkSelector.js +56 -0
- package/mjs/framework/components/Collapse.d.ts +5 -0
- package/mjs/framework/components/Collapse.js +7 -0
- package/mjs/framework/components/DetailInfo.d.ts +5 -0
- package/mjs/framework/components/DetailInfo.js +8 -0
- package/mjs/framework/components/Details.d.ts +38 -0
- package/mjs/framework/components/Details.js +68 -0
- package/mjs/framework/components/Dotted.d.ts +4 -0
- package/mjs/framework/components/Dotted.js +4 -0
- package/mjs/framework/components/DropdownControlled.d.ts +4 -0
- package/mjs/framework/components/DropdownControlled.js +8 -0
- package/mjs/framework/components/ErrorBoundary.d.ts +15 -0
- package/mjs/framework/components/ErrorBoundary.js +25 -0
- package/mjs/framework/components/Grid.d.ts +6 -0
- package/mjs/framework/components/Grid.js +27 -0
- package/mjs/framework/components/Help.d.ts +5 -0
- package/mjs/framework/components/Help.js +9 -0
- package/mjs/framework/components/IconWrapper.d.ts +8 -0
- package/mjs/framework/components/IconWrapper.js +40 -0
- package/mjs/framework/components/LoadingPage.d.ts +6 -0
- package/mjs/framework/components/LoadingPage.js +9 -0
- package/mjs/framework/components/Masonry.d.ts +6 -0
- package/mjs/framework/components/Masonry.js +69 -0
- package/mjs/framework/components/Scrollable.d.ts +7 -0
- package/mjs/framework/components/Scrollable.js +60 -0
- package/mjs/framework/components/SingleSelect.d.ts +18 -0
- package/mjs/framework/components/SingleSelect.js +37 -0
- package/mjs/framework/components/patternfly-colors.d.ts +13 -0
- package/mjs/framework/components/patternfly-colors.js +28 -0
- package/mjs/framework/components/useBreakPoint.d.ts +5 -0
- package/mjs/framework/components/useBreakPoint.js +118 -0
- package/mjs/framework/components/useOpen.d.ts +4 -0
- package/mjs/framework/components/useOpen.js +16 -0
- package/mjs/framework/components/useWindowLocation.d.ts +6 -0
- package/mjs/framework/components/useWindowLocation.js +48 -0
- package/mjs/framework/index.d.ts +23 -0
- package/mjs/framework/index.js +23 -0
- package/mjs/framework/useFrameworkTranslations.d.ts +17 -0
- package/mjs/framework/useFrameworkTranslations.js +22 -0
- package/mjs/framework/useSelectDialog.d.ts +30 -0
- package/mjs/framework/useSelectDialog.js +49 -0
- package/mjs/framework/useSelectMultipleDialog.d.ts +21 -0
- package/mjs/framework/useSelectMultipleDialog.js +29 -0
- package/mjs/framework/useTableItems.d.ts +76 -0
- package/mjs/framework/useTableItems.js +371 -0
- package/mjs/framework/useView.d.ts +15 -0
- package/mjs/framework/useView.js +108 -0
- package/mjs/framework/utils/compare.d.ts +3 -0
- package/mjs/framework/utils/compare.js +53 -0
- package/mjs/framework/utils/download-file.d.ts +2 -0
- package/mjs/framework/utils/download-file.js +18 -0
- package/mjs/framework/utils/random-string.d.ts +1 -0
- package/mjs/framework/utils/random-string.js +12 -0
- package/mjs/frontend/controller/access/organizations/Organization.d.ts +44 -0
- package/mjs/frontend/controller/access/organizations/Organization.js +1 -0
- package/package.json +39 -0
@@ -0,0 +1,251 @@
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { Button, ButtonVariant, Dropdown, DropdownItem, DropdownSeparator, DropdownToggle, KebabToggle, Split, SplitItem, Tooltip, } from '@patternfly/react-core';
|
3
|
+
import { CircleIcon } from '@patternfly/react-icons';
|
4
|
+
import { Fragment, useCallback, useMemo, useState } from 'react';
|
5
|
+
import { useBreakpoint } from './components/useBreakPoint';
|
6
|
+
export var TypedActionType;
|
7
|
+
(function (TypedActionType) {
|
8
|
+
TypedActionType["seperator"] = "seperator";
|
9
|
+
TypedActionType["button"] = "button";
|
10
|
+
TypedActionType["single"] = "single";
|
11
|
+
TypedActionType["bulk"] = "bulk";
|
12
|
+
TypedActionType["dropdown"] = "dropdown";
|
13
|
+
})(TypedActionType || (TypedActionType = {}));
|
14
|
+
export function TypedActionsDropdown(props) {
|
15
|
+
const { actions, label, isPrimary = false, selectedItems } = props;
|
16
|
+
const [dropdownOpen, setDropdownOpen] = useState(false);
|
17
|
+
const hasItemActions = useMemo(() => !actions.every((action) => action.type !== TypedActionType.bulk), [actions]);
|
18
|
+
const hasIcons = useMemo(() => actions.find((action) => action.type !== TypedActionType.seperator && action.icon !== undefined) !== undefined, [actions]);
|
19
|
+
if (actions.length === 0)
|
20
|
+
return _jsx(_Fragment, {});
|
21
|
+
const Toggle = label ? DropdownToggle : KebabToggle;
|
22
|
+
return (_jsx(Dropdown, { onSelect: () => setDropdownOpen(false), toggle: _jsx(Toggle, { id: "toggle-kebab", onToggle: () => setDropdownOpen(!dropdownOpen), toggleVariant: hasItemActions && selectedItems?.length ? 'primary' : undefined, isPrimary: isPrimary, style: isPrimary && !label
|
23
|
+
? {
|
24
|
+
color: 'var(--pf-global--Color--light-100)',
|
25
|
+
}
|
26
|
+
: {}, children: label }), isOpen: dropdownOpen, isPlain: !label, dropdownItems: actions.map((action, index) => {
|
27
|
+
switch (action.type) {
|
28
|
+
case TypedActionType.button:
|
29
|
+
case TypedActionType.bulk: {
|
30
|
+
let Icon = action.icon;
|
31
|
+
if (!Icon && hasIcons)
|
32
|
+
Icon = TransparentIcon;
|
33
|
+
let tooltip = action.tooltip;
|
34
|
+
let isDisabled = false;
|
35
|
+
if (action.type === TypedActionType.bulk && (!selectedItems || !selectedItems.length)) {
|
36
|
+
tooltip = 'No selections';
|
37
|
+
isDisabled = true;
|
38
|
+
}
|
39
|
+
return (_jsx(Tooltip, { content: tooltip, trigger: tooltip ? undefined : 'manual', children: _jsx(DropdownItem, { onClick: () => action.onClick(selectedItems ?? []), isAriaDisabled: isDisabled, icon: Icon ? (_jsx("span", { style: { paddingRight: 4 }, children: _jsx(Icon, {}) })) : undefined,
|
40
|
+
// style={{ color: 'var(--pf-global--primary-color--100)' }}
|
41
|
+
style: {
|
42
|
+
color: action.isDanger && !isDisabled
|
43
|
+
? 'var(--pf-global--danger-color--100)'
|
44
|
+
: undefined,
|
45
|
+
}, children: action.label }) }, action.label));
|
46
|
+
}
|
47
|
+
case TypedActionType.dropdown:
|
48
|
+
return (_jsx(TypedActionsDropdown, { label: action.label, actions: action.options }, action.label));
|
49
|
+
case TypedActionType.seperator:
|
50
|
+
return _jsx(DropdownSeparator, {}, `separator-${index}`);
|
51
|
+
}
|
52
|
+
}), position: props.position, style: { zIndex: 201 } }));
|
53
|
+
}
|
54
|
+
export function TypedActionsButtons(props) {
|
55
|
+
const { actions, selectedItems, wrapper } = props;
|
56
|
+
if (actions.length === 0)
|
57
|
+
return _jsx(_Fragment, {});
|
58
|
+
return (_jsx(Split, { hasGutter: true, children: actions.map((action, index) => (_jsx(TypedActionButton, { action: action, selectedItems: selectedItems, wrapper: wrapper }, index))) }));
|
59
|
+
}
|
60
|
+
export function TypedActionButton(props) {
|
61
|
+
const { action, selectedItems, selectedItem, wrapper, noPrimary } = props;
|
62
|
+
const Wrapper = wrapper ?? Fragment;
|
63
|
+
switch (action.type) {
|
64
|
+
case TypedActionType.seperator: {
|
65
|
+
return _jsx(_Fragment, {});
|
66
|
+
}
|
67
|
+
case TypedActionType.single: {
|
68
|
+
const Icon = action.icon;
|
69
|
+
const tooltip = action.tooltip;
|
70
|
+
const isDisabled = false;
|
71
|
+
let variant = action.variant ?? ButtonVariant.secondary;
|
72
|
+
if (variant === ButtonVariant.primary && noPrimary) {
|
73
|
+
variant = ButtonVariant.secondary;
|
74
|
+
}
|
75
|
+
if (variant === ButtonVariant.primary && action.isDanger) {
|
76
|
+
variant = ButtonVariant.danger;
|
77
|
+
}
|
78
|
+
if (props.iconOnly) {
|
79
|
+
variant = ButtonVariant.plain;
|
80
|
+
}
|
81
|
+
return (_jsx(Wrapper, { children: _jsx(Tooltip, { content: tooltip, trigger: tooltip ? undefined : 'manual', children: _jsx(Button, { variant: variant, icon: Icon ? (_jsx("span", { style: { marginLeft: -4, paddingRight: 4 }, children: _jsx(Icon, {}) })) : undefined, isAriaDisabled: isDisabled, onClick: () => selectedItem && action.onClick(selectedItem), isDanger: action.isDanger, children: props.iconOnly && Icon ? (_jsx(Icon, {})) : action.shortLabel ? (action.shortLabel) : (action.label) }) }) }));
|
82
|
+
}
|
83
|
+
case TypedActionType.bulk: {
|
84
|
+
const Icon = action.icon;
|
85
|
+
let tooltip = action.tooltip;
|
86
|
+
let isDisabled = false;
|
87
|
+
let variant = action.variant ?? ButtonVariant.secondary;
|
88
|
+
if (variant === ButtonVariant.primary && noPrimary) {
|
89
|
+
variant = ButtonVariant.secondary;
|
90
|
+
}
|
91
|
+
if (variant === ButtonVariant.primary && action.isDanger) {
|
92
|
+
variant = ButtonVariant.danger;
|
93
|
+
}
|
94
|
+
if (!selectedItems || !selectedItems.length) {
|
95
|
+
tooltip = 'No selections';
|
96
|
+
isDisabled = true;
|
97
|
+
}
|
98
|
+
return (_jsx(Wrapper, { children: _jsx(Tooltip, { content: tooltip, trigger: tooltip ? undefined : 'manual', children: _jsx(Button, { variant: variant, icon: Icon ? (_jsx("span", { style: { paddingRight: 4 }, children: _jsx(Icon, {}) })) : undefined, isAriaDisabled: isDisabled, onClick: () => action.onClick(selectedItems ?? []), isDanger: action.isDanger, children: action.shortLabel ? action.shortLabel : action.label }) }) }));
|
99
|
+
}
|
100
|
+
case TypedActionType.button: {
|
101
|
+
const Icon = action.icon;
|
102
|
+
const tooltip = action.tooltip;
|
103
|
+
const isDisabled = false;
|
104
|
+
let variant = action.variant ?? ButtonVariant.secondary;
|
105
|
+
if (selectedItems && selectedItems.length) {
|
106
|
+
switch (variant) {
|
107
|
+
case ButtonVariant.danger:
|
108
|
+
case ButtonVariant.primary:
|
109
|
+
variant = ButtonVariant.secondary;
|
110
|
+
break;
|
111
|
+
}
|
112
|
+
}
|
113
|
+
if (variant === ButtonVariant.primary && noPrimary) {
|
114
|
+
variant = ButtonVariant.secondary;
|
115
|
+
}
|
116
|
+
if (variant === ButtonVariant.primary && action.isDanger) {
|
117
|
+
variant = ButtonVariant.danger;
|
118
|
+
}
|
119
|
+
return (_jsx(Wrapper, { children: _jsx(Tooltip, { content: tooltip, trigger: tooltip ? undefined : 'manual', children: _jsx(Button, { variant: variant, isDanger: action.isDanger, icon: Icon ? (_jsx("span", { style: { paddingRight: 4 }, children: _jsx(Icon, {}) })) : undefined, isAriaDisabled: isDisabled, onClick: action.onClick, children: action.shortLabel ? action.shortLabel : action.label }) }) }));
|
120
|
+
}
|
121
|
+
case TypedActionType.dropdown: {
|
122
|
+
return (_jsx(TypedActionsDropdown, { actions: action.options, label: action.label, isPrimary: action.variant === ButtonVariant.primary && !selectedItems?.length }));
|
123
|
+
}
|
124
|
+
}
|
125
|
+
}
|
126
|
+
export function TypedActions(props) {
|
127
|
+
const { actions } = props;
|
128
|
+
const collapseButtons = !useBreakpoint(props.collapse ?? 'lg');
|
129
|
+
const isButtonAction = useCallback((action) => {
|
130
|
+
const actionVariants = [
|
131
|
+
ButtonVariant.primary,
|
132
|
+
ButtonVariant.secondary,
|
133
|
+
ButtonVariant.danger,
|
134
|
+
];
|
135
|
+
return action.type !== TypedActionType.seperator && actionVariants.includes(action.variant);
|
136
|
+
}, []);
|
137
|
+
const buttonActions = useMemo(() => {
|
138
|
+
if (collapseButtons) {
|
139
|
+
return [];
|
140
|
+
}
|
141
|
+
return actions?.filter(isButtonAction) ?? [];
|
142
|
+
}, [collapseButtons, actions, isButtonAction]);
|
143
|
+
const dropdownActions = useMemo(() => {
|
144
|
+
if (collapseButtons) {
|
145
|
+
return actions ?? [];
|
146
|
+
}
|
147
|
+
const dropdownActions = actions?.filter((action) => !isButtonAction(action)) ?? [];
|
148
|
+
while (dropdownActions.length && dropdownActions[0].type === TypedActionType.seperator)
|
149
|
+
dropdownActions.shift();
|
150
|
+
while (dropdownActions.length &&
|
151
|
+
dropdownActions[dropdownActions.length - 1].type === TypedActionType.seperator)
|
152
|
+
dropdownActions.pop();
|
153
|
+
return dropdownActions;
|
154
|
+
}, [collapseButtons, actions, isButtonAction]);
|
155
|
+
return (_jsxs(Split, { hasGutter: true, children: [_jsx(TypedActionsButtons, { ...props, actions: buttonActions }), _jsx(TypedActionsDropdown, { ...props, actions: dropdownActions, position: props.position, isPrimary: !!props.selectedItems?.length })] }));
|
156
|
+
}
|
157
|
+
const TransparentIcon = () => _jsx(CircleIcon, { style: { opacity: 0 } });
|
158
|
+
export function useTypedActionsToTableActions(props) {
|
159
|
+
const { actions } = props;
|
160
|
+
const collapseButtons = !useBreakpoint(props.collapse ?? 'lg');
|
161
|
+
const buttonActions = useMemo(() => {
|
162
|
+
if (collapseButtons) {
|
163
|
+
return [];
|
164
|
+
}
|
165
|
+
else {
|
166
|
+
const buttonActions = actions?.filter((action) => (action.type === TypedActionType.button ||
|
167
|
+
action.type === TypedActionType.bulk ||
|
168
|
+
action.type === TypedActionType.single) &&
|
169
|
+
(action.variant === ButtonVariant.primary ||
|
170
|
+
action.variant === ButtonVariant.secondary ||
|
171
|
+
action.variant === ButtonVariant.danger));
|
172
|
+
return buttonActions ?? [];
|
173
|
+
}
|
174
|
+
}, [collapseButtons, actions]);
|
175
|
+
const dropdownActions = useMemo(() => {
|
176
|
+
if (collapseButtons) {
|
177
|
+
return actions ?? [];
|
178
|
+
}
|
179
|
+
else {
|
180
|
+
let dropdownActions = actions?.filter((action) => !((action.type === TypedActionType.button ||
|
181
|
+
action.type === TypedActionType.bulk ||
|
182
|
+
action.type === TypedActionType.single) &&
|
183
|
+
(action.variant === ButtonVariant.primary ||
|
184
|
+
action.variant === ButtonVariant.secondary ||
|
185
|
+
action.variant === ButtonVariant.danger)));
|
186
|
+
dropdownActions = dropdownActions ?? [];
|
187
|
+
while (dropdownActions.length && dropdownActions[0].type === TypedActionType.seperator)
|
188
|
+
dropdownActions.shift();
|
189
|
+
while (dropdownActions.length &&
|
190
|
+
dropdownActions[dropdownActions.length - 1].type === TypedActionType.seperator)
|
191
|
+
dropdownActions.pop();
|
192
|
+
return dropdownActions;
|
193
|
+
}
|
194
|
+
}, [collapseButtons, actions]);
|
195
|
+
return [
|
196
|
+
...buttonActions.map((buttonAction) => {
|
197
|
+
switch (buttonAction.type) {
|
198
|
+
case TypedActionType.button:
|
199
|
+
return {
|
200
|
+
title: _jsx(TypedActionButton, { action: buttonAction }),
|
201
|
+
isOutsideDropdown: true,
|
202
|
+
};
|
203
|
+
case TypedActionType.single:
|
204
|
+
return {
|
205
|
+
title: (_jsx(TypedActionButton, { action: { ...buttonAction, tooltip: buttonAction.label }, selectedItem: props.item, iconOnly: true })),
|
206
|
+
isOutsideDropdown: true,
|
207
|
+
};
|
208
|
+
case TypedActionType.bulk:
|
209
|
+
return {
|
210
|
+
title: (_jsx(TypedActionButton, { action: buttonAction, selectedItems: props.item ? [props.item] : [] })),
|
211
|
+
isOutsideDropdown: true,
|
212
|
+
};
|
213
|
+
default:
|
214
|
+
return null;
|
215
|
+
}
|
216
|
+
}),
|
217
|
+
...dropdownActions.map((buttonAction) => {
|
218
|
+
switch (buttonAction.type) {
|
219
|
+
case TypedActionType.button: {
|
220
|
+
const Icon = buttonAction.icon;
|
221
|
+
return {
|
222
|
+
title: (_jsxs(Split, { hasGutter: true, children: [Icon && (_jsx(SplitItem, { children: _jsx(Icon, {}) })), _jsx(SplitItem, { children: buttonAction.label })] })),
|
223
|
+
onClick: () => {
|
224
|
+
buttonAction.onClick();
|
225
|
+
},
|
226
|
+
};
|
227
|
+
}
|
228
|
+
case TypedActionType.single: {
|
229
|
+
const Icon = buttonAction.icon;
|
230
|
+
return {
|
231
|
+
title: (_jsxs(Split, { hasGutter: true, children: [Icon && (_jsx(SplitItem, { children: _jsx(Icon, {}) })), _jsx(SplitItem, { children: buttonAction.label })] })),
|
232
|
+
onClick: () => {
|
233
|
+
buttonAction.onClick(props.item);
|
234
|
+
},
|
235
|
+
};
|
236
|
+
}
|
237
|
+
case TypedActionType.bulk: {
|
238
|
+
const Icon = buttonAction.icon;
|
239
|
+
return {
|
240
|
+
title: (_jsxs(Split, { hasGutter: true, children: [Icon && (_jsx(SplitItem, { children: _jsx(Icon, {}) })), _jsx(SplitItem, { children: buttonAction.label })] })),
|
241
|
+
onClick: () => {
|
242
|
+
buttonAction.onClick([props.item]);
|
243
|
+
},
|
244
|
+
};
|
245
|
+
}
|
246
|
+
default:
|
247
|
+
return { isSeparator: true };
|
248
|
+
}
|
249
|
+
}),
|
250
|
+
].filter((i) => i !== null);
|
251
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
export interface BulkSelectorProps<T> {
|
3
|
+
itemCount?: number;
|
4
|
+
pageItems?: T[];
|
5
|
+
selectedItems?: T[];
|
6
|
+
selectItems?: (items: T[]) => void;
|
7
|
+
unselectAll?: () => void;
|
8
|
+
keyFn: (item: T) => string | number;
|
9
|
+
selectNoneText?: string;
|
10
|
+
}
|
11
|
+
export declare function BulkSelector<T extends object>(props: BulkSelectorProps<T>): JSX.Element;
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { Dropdown, DropdownItem, DropdownToggle, DropdownToggleCheckbox, } from '@patternfly/react-core';
|
3
|
+
import { useCallback, useMemo, useState } from 'react';
|
4
|
+
import { useBreakpoint } from './useBreakPoint';
|
5
|
+
export function BulkSelector(props) {
|
6
|
+
const [isOpen, setIsOpen] = useState(false);
|
7
|
+
const isSmallOrLarger = useBreakpoint('sm');
|
8
|
+
const { pageItems, selectedItems, selectItems, unselectAll } = props;
|
9
|
+
const allPageItemsSelected = props.itemCount !== undefined &&
|
10
|
+
props.itemCount > 0 &&
|
11
|
+
pageItems &&
|
12
|
+
pageItems.length > 0 &&
|
13
|
+
(pageItems ?? []).every((item) => selectedItems?.includes(item));
|
14
|
+
const onToggleCheckbox = useCallback(() => {
|
15
|
+
if (allPageItemsSelected) {
|
16
|
+
unselectAll?.();
|
17
|
+
}
|
18
|
+
else {
|
19
|
+
selectItems?.(pageItems ?? []);
|
20
|
+
}
|
21
|
+
}, [allPageItemsSelected, unselectAll, selectItems, pageItems]);
|
22
|
+
const toggleText = useMemo(() => {
|
23
|
+
if (isSmallOrLarger) {
|
24
|
+
if (selectedItems && selectedItems.length > 0) {
|
25
|
+
return `${selectedItems.length} selected`;
|
26
|
+
}
|
27
|
+
return '';
|
28
|
+
}
|
29
|
+
else {
|
30
|
+
if (selectedItems && selectedItems.length > 0) {
|
31
|
+
return `${selectedItems.length}`;
|
32
|
+
}
|
33
|
+
return '';
|
34
|
+
}
|
35
|
+
}, [isSmallOrLarger, selectedItems]);
|
36
|
+
const toggle = useMemo(() => {
|
37
|
+
const selectedCount = selectedItems ? selectedItems.length : 0;
|
38
|
+
return (_jsx(DropdownToggle, { splitButtonItems: [
|
39
|
+
_jsx(DropdownToggleCheckbox, { id: "select-all", "aria-label": "Select all", isChecked: allPageItemsSelected ? true : selectedCount > 0 ? null : false, onChange: onToggleCheckbox, children: toggleText }, "select-all"),
|
40
|
+
], onToggle: (isOpen) => setIsOpen(isOpen) }));
|
41
|
+
}, [selectedItems, allPageItemsSelected, onToggleCheckbox, toggleText]);
|
42
|
+
const selectNoneDropdownItem = useMemo(() => {
|
43
|
+
return (_jsx(DropdownItem, { id: "select-none", onClick: () => {
|
44
|
+
unselectAll?.();
|
45
|
+
setIsOpen(false);
|
46
|
+
}, children: props.selectNoneText ?? 'Select none' }, "select-none"));
|
47
|
+
}, [props.selectNoneText, unselectAll]);
|
48
|
+
const selectPageDropdownItem = useMemo(() => {
|
49
|
+
return (_jsx(DropdownItem, { id: "select-page", onClick: () => {
|
50
|
+
selectItems?.(pageItems ?? []);
|
51
|
+
setIsOpen(false);
|
52
|
+
}, children: `Select ${pageItems?.length ?? 0} page items` }, "select-page"));
|
53
|
+
}, [selectItems, pageItems]);
|
54
|
+
const dropdownItems = useMemo(() => [selectNoneDropdownItem, selectPageDropdownItem], [selectNoneDropdownItem, selectPageDropdownItem]);
|
55
|
+
return (_jsx(Dropdown, { isOpen: isOpen, toggle: toggle, dropdownItems: dropdownItems, style: { zIndex: 302 } }));
|
56
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { PageSection } from '@patternfly/react-core';
|
3
|
+
export function DetailInfo(props) {
|
4
|
+
return (_jsx(PageSection, { className: "pf-c-alert pf-m-inline pf-m-info", style: {
|
5
|
+
border: 0,
|
6
|
+
paddingTop: props.disablePaddingTop ? 0 : undefined,
|
7
|
+
}, children: props.children }));
|
8
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { ComponentClass, ReactNode } from 'react';
|
2
|
+
export interface IDetailText {
|
3
|
+
label: string;
|
4
|
+
icon?: ComponentClass;
|
5
|
+
text?: string;
|
6
|
+
helpTitle?: string;
|
7
|
+
help?: ReactNode;
|
8
|
+
to?: string;
|
9
|
+
link?: string;
|
10
|
+
color?: string;
|
11
|
+
copy?: boolean;
|
12
|
+
since?: boolean;
|
13
|
+
}
|
14
|
+
export declare function isDetailText(detail: IDetail): detail is IDetailText;
|
15
|
+
export interface IDetailList {
|
16
|
+
label: string;
|
17
|
+
icon?: ComponentClass;
|
18
|
+
items: IDetailListItem[];
|
19
|
+
}
|
20
|
+
export declare function isDetailList(detail: IDetail): detail is IDetailList;
|
21
|
+
export interface IDetailListItem {
|
22
|
+
icon?: ComponentClass;
|
23
|
+
text: string;
|
24
|
+
helpTitle?: string;
|
25
|
+
help?: ReactNode;
|
26
|
+
}
|
27
|
+
export declare type IDetail = IDetailText | IDetailList;
|
28
|
+
export declare function Details(props: {
|
29
|
+
details: IDetail[];
|
30
|
+
}): JSX.Element;
|
31
|
+
export declare function DetailsList(props: {
|
32
|
+
children?: ReactNode;
|
33
|
+
}): JSX.Element;
|
34
|
+
export declare function Detail(props: {
|
35
|
+
label: string;
|
36
|
+
children?: ReactNode;
|
37
|
+
}): JSX.Element;
|
38
|
+
export declare function DetailsSkeleton(): JSX.Element;
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { DescriptionList, DescriptionListDescription, DescriptionListGroup, DescriptionListTerm, Skeleton, Split, SplitItem, Stack, } from '@patternfly/react-core';
|
3
|
+
import { Link } from 'react-router-dom';
|
4
|
+
import { CopyCell, SinceCell } from '../PageCells';
|
5
|
+
import { useSettings } from '../Settings';
|
6
|
+
import { Help } from './Help';
|
7
|
+
import { IconWrapper } from './IconWrapper';
|
8
|
+
export function isDetailText(detail) {
|
9
|
+
return 'label' in detail && !('items' in detail);
|
10
|
+
}
|
11
|
+
export function isDetailList(detail) {
|
12
|
+
return 'items' in detail && 'label' in detail;
|
13
|
+
}
|
14
|
+
export function Details(props) {
|
15
|
+
const { details } = props;
|
16
|
+
return (_jsx(DescriptionList, { orientation: {
|
17
|
+
sm: 'vertical',
|
18
|
+
md: 'horizontal',
|
19
|
+
lg: 'horizontal',
|
20
|
+
xl: 'horizontal',
|
21
|
+
'2xl': 'horizontal',
|
22
|
+
}, children: details.map((detail, index) => {
|
23
|
+
if (isDetailText(detail)) {
|
24
|
+
if (!detail.text)
|
25
|
+
return _jsx(_Fragment, {});
|
26
|
+
const Icon = detail.icon;
|
27
|
+
return (_jsxs(DescriptionListGroup, { children: [_jsx(DescriptionListTerm, { children: detail.label }), _jsx(DescriptionListDescription, { id: detail.label.toLowerCase().split(' ').join('-'), children: _jsxs(Split, { children: [Icon && (_jsx(IconWrapper, { size: "sm", children: _jsx(Icon, {}) })), detail.to ? (_jsx(Link, { to: detail.to, children: detail.text })) : detail.link ? (_jsx("a", { href: detail.link, target: "_blank", rel: "noreferrer", children: detail.text })) : detail.color ? (_jsx("span", { style: { color: detail.color }, children: detail.text })) : detail.copy ? (_jsx(CopyCell, { text: detail.text })) : detail.since ? (_jsx(SinceCell, { value: detail.text })) : (detail.text), detail.help && _jsx(Help, { title: detail.helpTitle, help: detail.help })] }, index) })] }, index));
|
28
|
+
}
|
29
|
+
else if (isDetailList(detail)) {
|
30
|
+
return (_jsxs(DescriptionListGroup, { children: [_jsx(DescriptionListTerm, { children: detail.label }), _jsx(DescriptionListDescription, { id: detail.label.toLowerCase().split(' ').join('-'), children: _jsx(Stack, { hasGutter: true, children: detail.items.map((item, index) => {
|
31
|
+
const Icon = item.icon;
|
32
|
+
return (_jsxs(Split, { hasGutter: true, children: [Icon && _jsx(SplitItem, { children: item.icon }), _jsx(SplitItem, { children: item.text }), item.help && _jsx(Help, { title: item.helpTitle, help: item.help })] }, index));
|
33
|
+
}) }) })] }, index));
|
34
|
+
}
|
35
|
+
else
|
36
|
+
return _jsx(_Fragment, {});
|
37
|
+
}) }));
|
38
|
+
}
|
39
|
+
export function DetailsList(props) {
|
40
|
+
const settings = useSettings();
|
41
|
+
const orientation = settings.formLayout;
|
42
|
+
const columns = settings.formColumns;
|
43
|
+
const isCompact = false;
|
44
|
+
return (_jsx(DescriptionList, { orientation: {
|
45
|
+
sm: orientation,
|
46
|
+
md: orientation,
|
47
|
+
lg: orientation,
|
48
|
+
xl: orientation,
|
49
|
+
'2xl': orientation,
|
50
|
+
}, columnModifier: columns === 'multiple'
|
51
|
+
? {
|
52
|
+
default: '1Col',
|
53
|
+
sm: '1Col',
|
54
|
+
md: '2Col',
|
55
|
+
lg: '2Col',
|
56
|
+
xl: '3Col',
|
57
|
+
'2xl': '3Col',
|
58
|
+
}
|
59
|
+
: undefined, style: { maxWidth: 1200, padding: isCompact ? undefined : 8 }, isCompact: isCompact, children: props.children }));
|
60
|
+
}
|
61
|
+
export function Detail(props) {
|
62
|
+
if (!props.children)
|
63
|
+
return _jsx(_Fragment, {});
|
64
|
+
return (_jsxs(DescriptionListGroup, { children: [_jsx(DescriptionListTerm, { children: props.label }), _jsx(DescriptionListDescription, { id: props.label.toLowerCase().split(' ').join('-'), children: props.children })] }));
|
65
|
+
}
|
66
|
+
export function DetailsSkeleton() {
|
67
|
+
return (_jsxs(Stack, { hasGutter: true, children: [_jsx(Skeleton, {}), _jsx(Skeleton, {}), _jsx(Skeleton, {}), _jsx(Skeleton, {})] }));
|
68
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { Dropdown, KebabToggle } from '@patternfly/react-core';
|
3
|
+
import { useCallback, useState } from 'react';
|
4
|
+
export function DropdownControlled(props) {
|
5
|
+
const [open, setOpen] = useState(false);
|
6
|
+
const onToggle = useCallback(() => setOpen((open) => !open), []);
|
7
|
+
return (_jsx(Dropdown, { toggle: _jsx(KebabToggle, { onToggle: onToggle }), isOpen: open, isPlain: true, dropdownItems: props.items }));
|
8
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { Component, ErrorInfo, ReactNode } from 'react';
|
2
|
+
interface Props {
|
3
|
+
message: string;
|
4
|
+
children?: ReactNode;
|
5
|
+
}
|
6
|
+
interface State {
|
7
|
+
hasError: boolean;
|
8
|
+
}
|
9
|
+
declare class ErrorBoundary extends Component<Props, State> {
|
10
|
+
state: State;
|
11
|
+
static getDerivedStateFromError(_: Error): State;
|
12
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
13
|
+
render(): ReactNode;
|
14
|
+
}
|
15
|
+
export default ErrorBoundary;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { Component } from 'react';
|
3
|
+
class ErrorBoundary extends Component {
|
4
|
+
constructor() {
|
5
|
+
super(...arguments);
|
6
|
+
this.state = {
|
7
|
+
hasError: false,
|
8
|
+
};
|
9
|
+
}
|
10
|
+
static getDerivedStateFromError(_) {
|
11
|
+
// Update state so the next render will show the fallback UI.
|
12
|
+
return { hasError: true };
|
13
|
+
}
|
14
|
+
componentDidCatch(error, errorInfo) {
|
15
|
+
// eslint-disable-next-line no-console
|
16
|
+
console.error('Uncaught error:', error, errorInfo);
|
17
|
+
}
|
18
|
+
render() {
|
19
|
+
if (this.state.hasError) {
|
20
|
+
return _jsx("h1", { children: this.props.message });
|
21
|
+
}
|
22
|
+
return this.props.children;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
export default ErrorBoundary;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import useResizeObserver from '@react-hook/resize-observer';
|
3
|
+
import { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
4
|
+
import { useBreakpoint } from './useBreakPoint';
|
5
|
+
export function Grid(props) {
|
6
|
+
const size = props.size ?? 350;
|
7
|
+
const target = useRef(null);
|
8
|
+
const [gridTemplateColumns, setGridTemplateColumns] = useState('1fr');
|
9
|
+
const resize = useCallback((width) => {
|
10
|
+
let columns = Math.min(props.maxColumns ?? 12, Math.max(Math.floor(width / size), 1));
|
11
|
+
if (columns < 1)
|
12
|
+
columns = 1;
|
13
|
+
setGridTemplateColumns(() => new Array(columns).fill('1fr').join(' '));
|
14
|
+
}, [props.maxColumns, size]);
|
15
|
+
useResizeObserver(target, (entry) => resize(entry.contentRect.width));
|
16
|
+
useLayoutEffect(() => {
|
17
|
+
resize(target.current?.clientWidth ?? 0);
|
18
|
+
}, [resize]);
|
19
|
+
const isMd = !useBreakpoint('lg');
|
20
|
+
const isXS = !useBreakpoint('xs');
|
21
|
+
let gap = 24;
|
22
|
+
if (isMd)
|
23
|
+
gap = 16;
|
24
|
+
if (isXS)
|
25
|
+
gap = 8;
|
26
|
+
return (_jsx("div", { ref: target, style: { display: 'grid', gridAutoRows: '1fr', gridTemplateColumns, gap }, children: props.children }));
|
27
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { Button, Popover } from '@patternfly/react-core';
|
3
|
+
import { OutlinedQuestionCircleIcon } from '@patternfly/react-icons';
|
4
|
+
export function Help(props) {
|
5
|
+
const { help, title } = props;
|
6
|
+
if (!help)
|
7
|
+
return _jsx(_Fragment, {});
|
8
|
+
return (_jsx(Popover, { headerContent: title, bodyContent: help, removeFindDomNode: true, children: _jsx(Button, { variant: "link", style: { padding: 0, marginLeft: '8px', verticalAlign: 'middle' }, children: _jsx(OutlinedQuestionCircleIcon, {}) }) }));
|
9
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { Children, cloneElement, isValidElement } from 'react';
|
3
|
+
import { getPatternflyColor } from './patternfly-colors';
|
4
|
+
export function IconWrapper(props) {
|
5
|
+
const newProps = {};
|
6
|
+
if (props.color) {
|
7
|
+
newProps.color = getPatternflyColor(props.color);
|
8
|
+
}
|
9
|
+
let marginOffset = undefined;
|
10
|
+
let marginRight = undefined;
|
11
|
+
if (props.size) {
|
12
|
+
newProps.size = props.size;
|
13
|
+
switch (props.size) {
|
14
|
+
case 'sm':
|
15
|
+
marginRight = 6;
|
16
|
+
break;
|
17
|
+
case 'md':
|
18
|
+
marginOffset = -2;
|
19
|
+
marginRight = 6;
|
20
|
+
break;
|
21
|
+
case 'lg':
|
22
|
+
marginOffset = -6;
|
23
|
+
marginRight = 6;
|
24
|
+
break;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
if (props.noPadding) {
|
28
|
+
marginRight = undefined;
|
29
|
+
}
|
30
|
+
const newChildren = Children.toArray(props.children).map((child) => {
|
31
|
+
if (isValidElement(child)) {
|
32
|
+
const newChild = cloneElement(child, newProps);
|
33
|
+
return newChild;
|
34
|
+
}
|
35
|
+
else {
|
36
|
+
return child;
|
37
|
+
}
|
38
|
+
});
|
39
|
+
return (_jsx("div", { style: { marginTop: marginOffset, marginBottom: marginOffset, marginRight }, children: newChildren }));
|
40
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { PageSection, Skeleton } from '@patternfly/react-core';
|
3
|
+
import { Fragment } from 'react';
|
4
|
+
import { PageHeader } from '../PageHeader';
|
5
|
+
export function LoadingPage(props) {
|
6
|
+
return (_jsxs(Fragment, { children: [_jsx(PageHeader, { breadcrumbs: props.breadcrumbs, title: props.title ?? (_jsx(Skeleton, { width: "200px" })) }), _jsx(PageSection
|
7
|
+
// variant={theme === ThemeE.Dark ? undefined : 'light'}
|
8
|
+
, {})] }));
|
9
|
+
}
|