@apicurio/common-ui-components 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/IfNotEmpty.d.ts +17 -0
- package/dist/common/IfNotLoading.d.ts +15 -0
- package/dist/common/ListWithToolbar.d.ts +22 -0
- package/dist/common/ObjectDropdown.d.ts +22 -0
- package/dist/common/ObjectSelect.d.ts +20 -0
- package/dist/common/index.d.ts +6 -0
- package/dist/main.d.ts +2 -1
- package/dist/main.js +187 -4
- package/dist/modals/AppAboutModal.d.ts +25 -0
- package/dist/modals/PleaseWaitModal.d.ts +12 -0
- package/dist/modals/ProgressModal.d.ts +17 -0
- package/dist/modals/index.d.ts +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { FunctionComponent } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Properties
|
|
4
|
+
*/
|
|
5
|
+
export interface IfNotEmptyProps {
|
|
6
|
+
collection?: any[] | undefined;
|
|
7
|
+
emptyState?: React.ReactNode;
|
|
8
|
+
emptyStateTitle?: string;
|
|
9
|
+
emptyStateMessage?: string;
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Wrapper around a set of arbitrary child elements and displays them only if the
|
|
14
|
+
* provided collection is not empty. If the provided collection is empty, then
|
|
15
|
+
* an empty state control is displayed instead.
|
|
16
|
+
*/
|
|
17
|
+
export declare const IfNotEmpty: FunctionComponent<IfNotEmptyProps>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { FunctionComponent } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Properties
|
|
4
|
+
*/
|
|
5
|
+
export type IfNotLoadingProps = {
|
|
6
|
+
isLoading: boolean | (() => boolean);
|
|
7
|
+
loadingComponent?: React.ReactNode;
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Displays a Spinner control while the condition property is true. When false, the provided children
|
|
12
|
+
* are displayed. Useful when displaying content from the results of an async operation such as a REST
|
|
13
|
+
* call.
|
|
14
|
+
*/
|
|
15
|
+
export declare const IfNotLoading: FunctionComponent<IfNotLoadingProps>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { FunctionComponent } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Properties
|
|
4
|
+
*/
|
|
5
|
+
export type ListWithToolbarProps = {
|
|
6
|
+
toolbar: React.ReactNode;
|
|
7
|
+
alwaysShowToolbar?: boolean;
|
|
8
|
+
emptyState: React.ReactNode;
|
|
9
|
+
filteredEmptyState: React.ReactNode;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
loadingComponent?: React.ReactNode;
|
|
12
|
+
isError: boolean;
|
|
13
|
+
errorComponent?: React.ReactNode;
|
|
14
|
+
isFiltered: boolean;
|
|
15
|
+
isEmpty: boolean;
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Wrapper around a set of arbitrary child elements and displays them only if the
|
|
20
|
+
* indicated condition is true.
|
|
21
|
+
*/
|
|
22
|
+
export declare const ListWithToolbar: FunctionComponent<ListWithToolbarProps>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FunctionComponent } from "react";
|
|
2
|
+
import { DropdownPopperProps } from "@patternfly/react-core";
|
|
3
|
+
/**
|
|
4
|
+
* Properties
|
|
5
|
+
*/
|
|
6
|
+
export type ObjectDropdownProps = {
|
|
7
|
+
label: string;
|
|
8
|
+
items: any[];
|
|
9
|
+
onSelect: (value: any | undefined) => void;
|
|
10
|
+
itemToString: (value: any) => string;
|
|
11
|
+
itemIsDivider?: (value: any) => boolean;
|
|
12
|
+
itemToTestId?: (value: any) => string;
|
|
13
|
+
noSelectionLabel?: string;
|
|
14
|
+
menuAppendTo?: HTMLElement | (() => HTMLElement) | "inline";
|
|
15
|
+
isKebab?: boolean;
|
|
16
|
+
testId?: string;
|
|
17
|
+
popperProps?: DropdownPopperProps;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A generic control that makes it easier to create a <Select> from an array of objects.
|
|
21
|
+
*/
|
|
22
|
+
export declare const ObjectDropdown: FunctionComponent<ObjectDropdownProps>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FunctionComponent } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Properties
|
|
4
|
+
*/
|
|
5
|
+
export type ObjectSelectProps = {
|
|
6
|
+
value: any;
|
|
7
|
+
items: any[];
|
|
8
|
+
onSelect: (value: any) => void;
|
|
9
|
+
itemToString: (value: any) => string;
|
|
10
|
+
itemIsDivider?: (value: any) => boolean;
|
|
11
|
+
itemToTestId?: (value: any) => string;
|
|
12
|
+
noSelectionLabel?: string;
|
|
13
|
+
toggleId?: string;
|
|
14
|
+
toggleClassname?: string;
|
|
15
|
+
testId?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A generic control that makes it easier to create a <Select> from an array of objects.
|
|
19
|
+
*/
|
|
20
|
+
export declare const ObjectSelect: FunctionComponent<ObjectSelectProps>;
|
package/dist/main.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from "./common
|
|
1
|
+
export * from "./common";
|
|
2
|
+
export * from "./modals";
|
package/dist/main.js
CHANGED
|
@@ -1,6 +1,189 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { jsx as t, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import g, { useState as I, useEffect as C } from "react";
|
|
3
|
+
import { EmptyState as N, EmptyStateVariant as p, EmptyStateHeader as L, EmptyStateBody as A, Spinner as O, Alert as F, Dropdown as P, MenuToggle as w, DropdownList as j, Divider as y, DropdownItem as M, Select as V, SelectOption as k, AboutModal as B, TextContent as E, Text as b, TextVariants as v, TextList as S, TextListItem as d, Modal as x, Progress as W } from "@patternfly/react-core";
|
|
4
|
+
import { EllipsisVIcon as _ } from "@patternfly/react-icons";
|
|
5
|
+
const f = ({ condition: e, children: n }) => (() => typeof e == "boolean" ? e : e())() ? /* @__PURE__ */ t(g.Fragment, { children: n }) : /* @__PURE__ */ t(g.Fragment, {}), $ = ({ collection: e, emptyState: n, emptyStateTitle: a, emptyStateMessage: i, children: r }) => {
|
|
6
|
+
const c = () => !e || e.length === 0, s = n || /* @__PURE__ */ u(N, { variant: p.xs, children: [
|
|
7
|
+
/* @__PURE__ */ t(L, { titleText: a || "None found", headingLevel: "h4" }),
|
|
8
|
+
/* @__PURE__ */ t(A, { children: i || "No items found." })
|
|
9
|
+
] });
|
|
10
|
+
return c() ? /* @__PURE__ */ t(g.Fragment, { children: s }) : /* @__PURE__ */ t(g.Fragment, { children: r });
|
|
11
|
+
}, T = ({ isLoading: e, loadingComponent: n, children: a }) => {
|
|
12
|
+
const i = () => typeof e == "boolean" ? e : e(), r = n || /* @__PURE__ */ t(O, {});
|
|
13
|
+
return i() ? /* @__PURE__ */ t(g.Fragment, { children: r }) : /* @__PURE__ */ t(g.Fragment, { children: a });
|
|
14
|
+
}, q = ({ toolbar: e, alwaysShowToolbar: n, emptyState: a, filteredEmptyState: i, isLoading: r, isError: c, loadingComponent: s, errorComponent: m, isEmpty: o, isFiltered: l, children: h }) => {
|
|
15
|
+
const D = n || !o || l || c;
|
|
16
|
+
return m || (m = /* @__PURE__ */ t("div", { style: { padding: "15px", backgroundColor: "white" }, children: /* @__PURE__ */ t(F, { isInline: !0, variant: "danger", title: "Error: Something went wrong!", children: /* @__PURE__ */ t("p", { children: "Something went wrong with the action you attempted, but we're not sure what it was. Try reloading the page and hopef for a better result, or contact your admin to report the error." }) }) })), /* @__PURE__ */ u(g.Fragment, { children: [
|
|
17
|
+
/* @__PURE__ */ t(f, { condition: D, children: e }),
|
|
18
|
+
/* @__PURE__ */ u(T, { isLoading: r, loadingComponent: s, children: [
|
|
19
|
+
/* @__PURE__ */ t(f, { condition: !o && !c, children: h }),
|
|
20
|
+
/* @__PURE__ */ t(f, { condition: o && l && !c, children: i }),
|
|
21
|
+
/* @__PURE__ */ t(f, { condition: o && !l && !c, children: a }),
|
|
22
|
+
/* @__PURE__ */ t(f, { condition: c, children: m })
|
|
23
|
+
] })
|
|
24
|
+
] });
|
|
25
|
+
}, G = (e) => {
|
|
26
|
+
const [n, a] = I(!1), i = (o, l) => {
|
|
27
|
+
a(!1);
|
|
28
|
+
const h = l;
|
|
29
|
+
h !== void 0 && h >= 0 ? e.onSelect(e.items[h]) : e.onSelect(void 0);
|
|
30
|
+
}, r = () => {
|
|
31
|
+
a(!n);
|
|
32
|
+
}, c = (o) => {
|
|
33
|
+
let l;
|
|
34
|
+
return e.itemToTestId !== void 0 && (l = e.itemToTestId(o)), l;
|
|
35
|
+
}, s = e.popperProps || {
|
|
36
|
+
appendTo: e.menuAppendTo
|
|
37
|
+
};
|
|
38
|
+
let m = /* @__PURE__ */ t(_, { title: e.label });
|
|
39
|
+
return e.isKebab || (m = /* @__PURE__ */ t(g.Fragment, { children: e.label })), /* @__PURE__ */ t(
|
|
40
|
+
P,
|
|
41
|
+
{
|
|
42
|
+
isOpen: n,
|
|
43
|
+
onSelect: i,
|
|
44
|
+
onOpenChange: (o) => a(o),
|
|
45
|
+
toggle: (o) => /* @__PURE__ */ t(
|
|
46
|
+
w,
|
|
47
|
+
{
|
|
48
|
+
"data-testid": e.testId,
|
|
49
|
+
ref: o,
|
|
50
|
+
onClick: r,
|
|
51
|
+
isExpanded: n,
|
|
52
|
+
variant: e.isKebab ? "plain" : "default",
|
|
53
|
+
children: m
|
|
54
|
+
}
|
|
55
|
+
),
|
|
56
|
+
ouiaId: "ObjectDropdown",
|
|
57
|
+
popperProps: s,
|
|
58
|
+
shouldFocusToggleOnSelect: !0,
|
|
59
|
+
children: /* @__PURE__ */ t(j, { children: e.items.map((o, l) => e.itemIsDivider && e.itemIsDivider(o) ? /* @__PURE__ */ t(y, { component: "li" }, `divider-${l}`) : /* @__PURE__ */ t(
|
|
60
|
+
M,
|
|
61
|
+
{
|
|
62
|
+
value: l,
|
|
63
|
+
component: (h) => /* @__PURE__ */ t("button", { ...h, "data-testid": c(o) }),
|
|
64
|
+
children: e.itemToString(o)
|
|
65
|
+
},
|
|
66
|
+
`action-${l}`
|
|
67
|
+
)) })
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}, J = (e) => {
|
|
71
|
+
var m;
|
|
72
|
+
const [n, a] = I(!1), i = (o, l) => {
|
|
73
|
+
a(!1), e.onSelect(e.items[l]);
|
|
74
|
+
}, r = () => {
|
|
75
|
+
a(!n);
|
|
76
|
+
}, c = (o) => {
|
|
77
|
+
let l;
|
|
78
|
+
return e.itemToTestId !== void 0 && (l = e.itemToTestId(o)), l;
|
|
79
|
+
};
|
|
80
|
+
return /* @__PURE__ */ t(
|
|
81
|
+
V,
|
|
82
|
+
{
|
|
83
|
+
toggle: (o) => /* @__PURE__ */ t(
|
|
84
|
+
w,
|
|
85
|
+
{
|
|
86
|
+
ref: o,
|
|
87
|
+
className: e.toggleClassname || "menu-toggle",
|
|
88
|
+
onClick: r,
|
|
89
|
+
"data-testid": e.testId,
|
|
90
|
+
isExpanded: n,
|
|
91
|
+
children: e.value ? e.itemToString(e.value) : e.noSelectionLabel
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
id: e.toggleId,
|
|
95
|
+
onSelect: i,
|
|
96
|
+
onOpenChange: a,
|
|
97
|
+
isOpen: n,
|
|
98
|
+
children: (m = e.items) == null ? void 0 : m.map((o, l) => e.itemIsDivider && e.itemIsDivider(o) ? /* @__PURE__ */ t(y, {}, l) : /* @__PURE__ */ t(
|
|
99
|
+
k,
|
|
100
|
+
{
|
|
101
|
+
isSelected: o === e.value,
|
|
102
|
+
component: (h) => /* @__PURE__ */ t("button", { ...h, "data-testid": c(o) }),
|
|
103
|
+
value: l,
|
|
104
|
+
children: e.itemToString(o)
|
|
105
|
+
},
|
|
106
|
+
l
|
|
107
|
+
))
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
}, Q = (e) => {
|
|
111
|
+
const [n, a] = I(), [i, r] = I(), c = (s) => typeof s == "string" ? s : s === void 0 ? "" : s.toDateString();
|
|
112
|
+
return C(() => {
|
|
113
|
+
e.isOpen && (typeof e.frontendInfo == "function" ? e.frontendInfo().then(a) : a(e.frontendInfo), typeof e.backendInfo == "function" ? e.backendInfo().then(r) : r(e.backendInfo));
|
|
114
|
+
}, [e.isOpen]), /* @__PURE__ */ t(
|
|
115
|
+
B,
|
|
116
|
+
{
|
|
117
|
+
className: "app-about-modal",
|
|
118
|
+
isOpen: e.isOpen,
|
|
119
|
+
onClose: e.onClose,
|
|
120
|
+
trademark: "© 2024 Red Hat",
|
|
121
|
+
brandImageSrc: e.brandImageSrc,
|
|
122
|
+
brandImageAlt: e.brandImageAlt,
|
|
123
|
+
"aria-label": e.brandImageAlt,
|
|
124
|
+
children: /* @__PURE__ */ u(E, { className: "app-about-modal-content", style: { marginTop: "-25px" }, children: [
|
|
125
|
+
/* @__PURE__ */ t(b, { component: v.h2, children: "Web console info" }),
|
|
126
|
+
/* @__PURE__ */ t(T, { isLoading: n === void 0, children: /* @__PURE__ */ u(S, { component: "dl", children: [
|
|
127
|
+
/* @__PURE__ */ t(d, { component: "dt", children: "Project" }),
|
|
128
|
+
/* @__PURE__ */ t(d, { component: "dd", children: /* @__PURE__ */ t("a", { href: n == null ? void 0 : n.url, target: "_blank", children: n == null ? void 0 : n.name }) }),
|
|
129
|
+
/* @__PURE__ */ t(d, { component: "dt", children: "Version" }),
|
|
130
|
+
/* @__PURE__ */ t(d, { component: "dd", children: n == null ? void 0 : n.version }),
|
|
131
|
+
/* @__PURE__ */ t(d, { component: "dt", children: "Built on" }),
|
|
132
|
+
/* @__PURE__ */ t(d, { component: "dd", children: c(n == null ? void 0 : n.builtOn) }),
|
|
133
|
+
/* @__PURE__ */ t(d, { component: "dt", children: "Digest" }),
|
|
134
|
+
/* @__PURE__ */ t(d, { component: "dd", children: n == null ? void 0 : n.digest })
|
|
135
|
+
] }) }),
|
|
136
|
+
/* @__PURE__ */ t(b, { style: { marginTop: "40px" }, component: v.h2, children: e.backendLabel }),
|
|
137
|
+
/* @__PURE__ */ t(T, { isLoading: i === void 0, children: /* @__PURE__ */ u(S, { component: "dl", children: [
|
|
138
|
+
/* @__PURE__ */ t(d, { component: "dt", children: "Name" }),
|
|
139
|
+
/* @__PURE__ */ t(d, { component: "dd", children: (i == null ? void 0 : i.name) || "" }),
|
|
140
|
+
/* @__PURE__ */ t(d, { component: "dt", children: "Description" }),
|
|
141
|
+
/* @__PURE__ */ t(d, { component: "dd", children: (i == null ? void 0 : i.description) || "" }),
|
|
142
|
+
/* @__PURE__ */ t(d, { component: "dt", children: "Version" }),
|
|
143
|
+
/* @__PURE__ */ t(d, { component: "dd", children: (i == null ? void 0 : i.version) || "" }),
|
|
144
|
+
/* @__PURE__ */ t(d, { component: "dt", children: "Built on" }),
|
|
145
|
+
/* @__PURE__ */ t(d, { component: "dd", children: c(i == null ? void 0 : i.builtOn) })
|
|
146
|
+
] }) })
|
|
147
|
+
] })
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
}, U = (e) => /* @__PURE__ */ u(
|
|
151
|
+
x,
|
|
152
|
+
{
|
|
153
|
+
title: "Please Wait",
|
|
154
|
+
variant: "small",
|
|
155
|
+
isOpen: e.isOpen,
|
|
156
|
+
header: /* @__PURE__ */ t("a", { href: "#" }),
|
|
157
|
+
showClose: !1,
|
|
158
|
+
className: "please-wait pf-m-redhat-font",
|
|
159
|
+
"aria-label": "please-wait-modal",
|
|
160
|
+
style: { marginTop: "-15px" },
|
|
161
|
+
children: [
|
|
162
|
+
/* @__PURE__ */ t(O, { size: "md", className: "spinner" }),
|
|
163
|
+
/* @__PURE__ */ t("span", { className: "message", style: { fontSize: "15px", color: "#333", marginLeft: "10px" }, children: e.message })
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
), X = (e) => /* @__PURE__ */ t(
|
|
167
|
+
x,
|
|
168
|
+
{
|
|
169
|
+
title: e.title,
|
|
170
|
+
variant: "small",
|
|
171
|
+
isOpen: e.isOpen,
|
|
172
|
+
showClose: e.isCloseable,
|
|
173
|
+
onClose: e.onClose,
|
|
174
|
+
className: "progress pf-m-redhat-font",
|
|
175
|
+
"aria-label": "progress-modal",
|
|
176
|
+
children: /* @__PURE__ */ t(W, { title: e.message, value: e.progress })
|
|
177
|
+
}
|
|
178
|
+
);
|
|
4
179
|
export {
|
|
5
|
-
|
|
180
|
+
Q as AppAboutModal,
|
|
181
|
+
f as If,
|
|
182
|
+
$ as IfNotEmpty,
|
|
183
|
+
T as IfNotLoading,
|
|
184
|
+
q as ListWithToolbar,
|
|
185
|
+
G as ObjectDropdown,
|
|
186
|
+
J as ObjectSelect,
|
|
187
|
+
U as PleaseWaitModal,
|
|
188
|
+
X as ProgressModal
|
|
6
189
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FunctionComponent } from "react";
|
|
2
|
+
export type FrontendInfo = {
|
|
3
|
+
name: string;
|
|
4
|
+
url: string;
|
|
5
|
+
version: string;
|
|
6
|
+
builtOn: Date | string;
|
|
7
|
+
digest: string;
|
|
8
|
+
};
|
|
9
|
+
export type BackendInfo = {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
version: string;
|
|
13
|
+
builtOn: Date | string;
|
|
14
|
+
digest: string;
|
|
15
|
+
};
|
|
16
|
+
export type AppAboutModalProps = {
|
|
17
|
+
isOpen: boolean;
|
|
18
|
+
frontendInfo: FrontendInfo | (() => Promise<FrontendInfo>);
|
|
19
|
+
backendInfo: BackendInfo | (() => Promise<BackendInfo>);
|
|
20
|
+
backendLabel: string;
|
|
21
|
+
brandImageSrc: string;
|
|
22
|
+
brandImageAlt: string;
|
|
23
|
+
onClose: () => void;
|
|
24
|
+
};
|
|
25
|
+
export declare const AppAboutModal: FunctionComponent<AppAboutModalProps>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FunctionComponent } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Properties
|
|
4
|
+
*/
|
|
5
|
+
export type PleaseWaitModalProps = {
|
|
6
|
+
message: string;
|
|
7
|
+
isOpen: boolean;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Models the "please wait" modal. This is shown when the user performs an asynchronous operation.
|
|
11
|
+
*/
|
|
12
|
+
export declare const PleaseWaitModal: FunctionComponent<PleaseWaitModalProps>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FunctionComponent } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Properties
|
|
4
|
+
*/
|
|
5
|
+
export type ProgressModalProps = {
|
|
6
|
+
title: string;
|
|
7
|
+
isCloseable: boolean;
|
|
8
|
+
message: string;
|
|
9
|
+
isOpen: boolean;
|
|
10
|
+
progress: number | undefined;
|
|
11
|
+
onClose: () => void;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Models the "progress" modal. This is shown when the user performs an asynchronous operation
|
|
15
|
+
* with trackable progress (by percentage).
|
|
16
|
+
*/
|
|
17
|
+
export declare const ProgressModal: FunctionComponent<ProgressModalProps>;
|