@apicurio/common-ui-components 1.0.2 → 1.0.3
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/UrlUpload.d.ts +16 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/main.js +161 -100
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FunctionComponent } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Properties
|
|
4
|
+
*/
|
|
5
|
+
export type UrlUploadProps = {
|
|
6
|
+
id: string | "url-upload";
|
|
7
|
+
urlPlaceholder: string | "";
|
|
8
|
+
testId?: string;
|
|
9
|
+
onUrlFetch: (url: string) => Promise<string>;
|
|
10
|
+
onChange: (value: string | undefined, url: string | undefined) => void;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A control similar to the FileUpload control from patternfly that allows uploading from
|
|
14
|
+
* a URL instead of a file.
|
|
15
|
+
*/
|
|
16
|
+
export declare const UrlUpload: FunctionComponent<UrlUploadProps>;
|
package/dist/common/index.d.ts
CHANGED
package/dist/main.js
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { EmptyState as
|
|
4
|
-
import { EllipsisVIcon as
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
/* @__PURE__ */ t(
|
|
8
|
-
/* @__PURE__ */ t(
|
|
1
|
+
import { jsx as t, jsxs as g } from "react/jsx-runtime";
|
|
2
|
+
import f, { useState as u, useEffect as E } from "react";
|
|
3
|
+
import { EmptyState as k, EmptyStateVariant as U, EmptyStateHeader as j, EmptyStateBody as B, Spinner as S, Alert as M, Dropdown as R, MenuToggle as N, DropdownList as V, Divider as O, DropdownItem as $, Select as H, SelectOption as W, TextInput as _, Button as w, TextArea as z, AboutModal as K, TextContent as G, Text as x, TextVariants as y, TextList as C, TextListItem as r, Modal as p, Progress as q } from "@patternfly/react-core";
|
|
4
|
+
import { EllipsisVIcon as J } from "@patternfly/react-icons";
|
|
5
|
+
const v = ({ condition: e, children: n }) => (() => typeof e == "boolean" ? e : e())() ? /* @__PURE__ */ t(f.Fragment, { children: n }) : /* @__PURE__ */ t(f.Fragment, {}), te = ({ collection: e, emptyState: n, emptyStateTitle: a, emptyStateMessage: i, children: c }) => {
|
|
6
|
+
const d = () => !e || e.length === 0, s = n || /* @__PURE__ */ g(k, { variant: U.xs, children: [
|
|
7
|
+
/* @__PURE__ */ t(j, { titleText: a || "None found", headingLevel: "h4" }),
|
|
8
|
+
/* @__PURE__ */ t(B, { children: i || "No items found." })
|
|
9
9
|
] });
|
|
10
|
-
return
|
|
10
|
+
return d() ? /* @__PURE__ */ t(f.Fragment, { children: s }) : /* @__PURE__ */ t(f.Fragment, { children: c });
|
|
11
11
|
}, T = ({ isLoading: e, loadingComponent: n, children: a }) => {
|
|
12
|
-
const i = () => typeof e == "boolean" ? e : e(),
|
|
13
|
-
return i() ? /* @__PURE__ */ t(
|
|
14
|
-
},
|
|
15
|
-
const
|
|
16
|
-
return m || (m = /* @__PURE__ */ t("div", { style: { padding: "15px", backgroundColor: "white" }, children: /* @__PURE__ */ t(
|
|
17
|
-
/* @__PURE__ */ t(
|
|
18
|
-
/* @__PURE__ */
|
|
19
|
-
/* @__PURE__ */ t(
|
|
20
|
-
/* @__PURE__ */ t(
|
|
21
|
-
/* @__PURE__ */ t(
|
|
22
|
-
/* @__PURE__ */ t(
|
|
12
|
+
const i = () => typeof e == "boolean" ? e : e(), c = n || /* @__PURE__ */ t(S, {});
|
|
13
|
+
return i() ? /* @__PURE__ */ t(f.Fragment, { children: c }) : /* @__PURE__ */ t(f.Fragment, { children: a });
|
|
14
|
+
}, ne = ({ toolbar: e, alwaysShowToolbar: n, emptyState: a, filteredEmptyState: i, isLoading: c, isError: d, loadingComponent: s, errorComponent: m, isEmpty: l, isFiltered: o, children: h }) => {
|
|
15
|
+
const I = n || !l || o || d;
|
|
16
|
+
return m || (m = /* @__PURE__ */ t("div", { style: { padding: "15px", backgroundColor: "white" }, children: /* @__PURE__ */ t(M, { 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__ */ g(f.Fragment, { children: [
|
|
17
|
+
/* @__PURE__ */ t(v, { condition: I, children: e }),
|
|
18
|
+
/* @__PURE__ */ g(T, { isLoading: c, loadingComponent: s, children: [
|
|
19
|
+
/* @__PURE__ */ t(v, { condition: !l && !d, children: h }),
|
|
20
|
+
/* @__PURE__ */ t(v, { condition: l && o && !d, children: i }),
|
|
21
|
+
/* @__PURE__ */ t(v, { condition: l && !o && !d, children: a }),
|
|
22
|
+
/* @__PURE__ */ t(v, { condition: d, children: m })
|
|
23
23
|
] })
|
|
24
24
|
] });
|
|
25
|
-
},
|
|
26
|
-
const [n, a] =
|
|
25
|
+
}, le = (e) => {
|
|
26
|
+
const [n, a] = u(!1), i = (l, o) => {
|
|
27
27
|
a(!1);
|
|
28
|
-
const h =
|
|
28
|
+
const h = o;
|
|
29
29
|
h !== void 0 && h >= 0 ? e.onSelect(e.items[h]) : e.onSelect(void 0);
|
|
30
|
-
},
|
|
30
|
+
}, c = () => {
|
|
31
31
|
a(!n);
|
|
32
|
-
},
|
|
33
|
-
let
|
|
34
|
-
return e.itemToTestId !== void 0 && (
|
|
32
|
+
}, d = (l) => {
|
|
33
|
+
let o;
|
|
34
|
+
return e.itemToTestId !== void 0 && (o = e.itemToTestId(l)), o;
|
|
35
35
|
}, s = e.popperProps || {
|
|
36
36
|
appendTo: e.menuAppendTo
|
|
37
37
|
};
|
|
38
|
-
let m = /* @__PURE__ */ t(
|
|
39
|
-
return e.isKebab || (m = /* @__PURE__ */ t(
|
|
40
|
-
|
|
38
|
+
let m = /* @__PURE__ */ t(J, { title: e.label });
|
|
39
|
+
return e.isKebab || (m = /* @__PURE__ */ t(f.Fragment, { children: e.label })), /* @__PURE__ */ t(
|
|
40
|
+
R,
|
|
41
41
|
{
|
|
42
42
|
isOpen: n,
|
|
43
43
|
onSelect: i,
|
|
44
|
-
onOpenChange: (
|
|
45
|
-
toggle: (
|
|
46
|
-
|
|
44
|
+
onOpenChange: (l) => a(l),
|
|
45
|
+
toggle: (l) => /* @__PURE__ */ t(
|
|
46
|
+
N,
|
|
47
47
|
{
|
|
48
48
|
"data-testid": e.testId,
|
|
49
|
-
ref:
|
|
50
|
-
onClick:
|
|
49
|
+
ref: l,
|
|
50
|
+
onClick: c,
|
|
51
51
|
isExpanded: n,
|
|
52
52
|
variant: e.isKebab ? "plain" : "default",
|
|
53
53
|
children: m
|
|
@@ -56,36 +56,36 @@ const f = ({ condition: e, children: n }) => (() => typeof e == "boolean" ? e :
|
|
|
56
56
|
ouiaId: "ObjectDropdown",
|
|
57
57
|
popperProps: s,
|
|
58
58
|
shouldFocusToggleOnSelect: !0,
|
|
59
|
-
children: /* @__PURE__ */ t(
|
|
60
|
-
|
|
59
|
+
children: /* @__PURE__ */ t(V, { children: e.items.map((l, o) => e.itemIsDivider && e.itemIsDivider(l) ? /* @__PURE__ */ t(O, { component: "li" }, `divider-${o}`) : /* @__PURE__ */ t(
|
|
60
|
+
$,
|
|
61
61
|
{
|
|
62
|
-
value:
|
|
63
|
-
component: (h) => /* @__PURE__ */ t("button", { ...h, "data-testid":
|
|
64
|
-
children: e.itemToString(
|
|
62
|
+
value: o,
|
|
63
|
+
component: (h) => /* @__PURE__ */ t("button", { ...h, "data-testid": d(l) }),
|
|
64
|
+
children: e.itemToString(l)
|
|
65
65
|
},
|
|
66
|
-
`action-${
|
|
66
|
+
`action-${o}`
|
|
67
67
|
)) })
|
|
68
68
|
}
|
|
69
69
|
);
|
|
70
|
-
},
|
|
70
|
+
}, ie = (e) => {
|
|
71
71
|
var m;
|
|
72
|
-
const [n, a] =
|
|
73
|
-
a(!1), e.onSelect(e.items[
|
|
74
|
-
},
|
|
72
|
+
const [n, a] = u(!1), i = (l, o) => {
|
|
73
|
+
a(!1), e.onSelect(e.items[o]);
|
|
74
|
+
}, c = () => {
|
|
75
75
|
a(!n);
|
|
76
|
-
},
|
|
77
|
-
let
|
|
78
|
-
return e.itemToTestId !== void 0 && (
|
|
76
|
+
}, d = (l) => {
|
|
77
|
+
let o;
|
|
78
|
+
return e.itemToTestId !== void 0 && (o = e.itemToTestId(l)), o;
|
|
79
79
|
};
|
|
80
80
|
return /* @__PURE__ */ t(
|
|
81
|
-
|
|
81
|
+
H,
|
|
82
82
|
{
|
|
83
|
-
toggle: (
|
|
84
|
-
|
|
83
|
+
toggle: (l) => /* @__PURE__ */ t(
|
|
84
|
+
N,
|
|
85
85
|
{
|
|
86
|
-
ref:
|
|
86
|
+
ref: l,
|
|
87
87
|
className: e.toggleClassname || "menu-toggle",
|
|
88
|
-
onClick:
|
|
88
|
+
onClick: c,
|
|
89
89
|
"data-testid": e.testId,
|
|
90
90
|
isExpanded: n,
|
|
91
91
|
children: e.value ? e.itemToString(e.value) : e.noSelectionLabel
|
|
@@ -95,24 +95,84 @@ const f = ({ condition: e, children: n }) => (() => typeof e == "boolean" ? e :
|
|
|
95
95
|
onSelect: i,
|
|
96
96
|
onOpenChange: a,
|
|
97
97
|
isOpen: n,
|
|
98
|
-
children: (m = e.items) == null ? void 0 : m.map((
|
|
99
|
-
|
|
98
|
+
children: (m = e.items) == null ? void 0 : m.map((l, o) => e.itemIsDivider && e.itemIsDivider(l) ? /* @__PURE__ */ t(O, {}, o) : /* @__PURE__ */ t(
|
|
99
|
+
W,
|
|
100
100
|
{
|
|
101
|
-
isSelected:
|
|
102
|
-
component: (h) => /* @__PURE__ */ t("button", { ...h, "data-testid":
|
|
103
|
-
value:
|
|
104
|
-
children: e.itemToString(
|
|
101
|
+
isSelected: l === e.value,
|
|
102
|
+
component: (h) => /* @__PURE__ */ t("button", { ...h, "data-testid": d(l) }),
|
|
103
|
+
value: o,
|
|
104
|
+
children: e.itemToString(l)
|
|
105
105
|
},
|
|
106
|
-
|
|
106
|
+
o
|
|
107
107
|
))
|
|
108
108
|
}
|
|
109
109
|
);
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
}, D = {
|
|
111
|
+
padding: "5px",
|
|
112
|
+
minHeight: "128px",
|
|
113
|
+
borderRight: 0,
|
|
114
|
+
borderLeft: 0,
|
|
115
|
+
borderBottom: "1px solid #666",
|
|
116
|
+
backgroundColor: "rgb(240, 240, 240)"
|
|
117
|
+
}, Q = {
|
|
118
|
+
...D,
|
|
119
|
+
color: "red",
|
|
120
|
+
overflow: "auto"
|
|
121
|
+
}, oe = (e) => {
|
|
122
|
+
const [n, a] = u(""), [i, c] = u(""), [d, s] = u(!1), [m, l] = u(), o = (b, P) => {
|
|
123
|
+
a(P);
|
|
124
|
+
}, h = () => n != null && n.trim().length > 0, I = () => m != null && m.trim().length > 0, L = () => {
|
|
125
|
+
s(!0), e.onUrlFetch(n).then((b) => {
|
|
126
|
+
l(void 0), c(b), s(!1), e.onChange(b, n);
|
|
127
|
+
}).catch((b) => {
|
|
128
|
+
l(b.message), s(!1);
|
|
129
|
+
});
|
|
130
|
+
}, F = () => {
|
|
131
|
+
a(""), c(""), e.onChange(void 0, void 0);
|
|
132
|
+
}, A = /* @__PURE__ */ g("div", { className: "url-upload-loading", style: D, children: [
|
|
133
|
+
/* @__PURE__ */ t(S, { size: "md", className: "spinner", style: { marginRight: "5px" } }),
|
|
134
|
+
/* @__PURE__ */ t("span", { className: "spinner-message", children: "Loading URL content" })
|
|
135
|
+
] });
|
|
136
|
+
return /* @__PURE__ */ g("div", { className: "url-upload", "data-testid": e.testId, children: [
|
|
137
|
+
/* @__PURE__ */ g("div", { className: "url-upload-flex", style: { display: "flex" }, children: [
|
|
138
|
+
/* @__PURE__ */ t("div", { className: "url-upload-url", style: { flexGrow: 1 }, children: /* @__PURE__ */ t(
|
|
139
|
+
_,
|
|
140
|
+
{
|
|
141
|
+
"data-testid": `${e.testId}-input`,
|
|
142
|
+
value: n,
|
|
143
|
+
type: "text",
|
|
144
|
+
placeholder: e.urlPlaceholder,
|
|
145
|
+
id: e.id,
|
|
146
|
+
onChange: o,
|
|
147
|
+
"aria-label": "url input"
|
|
148
|
+
}
|
|
149
|
+
) }),
|
|
150
|
+
/* @__PURE__ */ t("div", { className: "url-fetch-button", children: /* @__PURE__ */ t(w, { "data-testid": `${e.testId}-fetch`, variant: "control", isDisabled: !h(), onClick: L, children: "Fetch" }) }),
|
|
151
|
+
/* @__PURE__ */ t("div", { className: "url-clear-button", children: /* @__PURE__ */ t(w, { "data-testid": `${e.testId}-clear`, variant: "control", isDisabled: !h(), onClick: F, children: "Clear" }) })
|
|
152
|
+
] }),
|
|
153
|
+
/* @__PURE__ */ t("div", { className: "url-upload-preview", children: /* @__PURE__ */ g(T, { isLoading: d, loadingComponent: A, children: [
|
|
154
|
+
/* @__PURE__ */ t(v, { condition: I, children: /* @__PURE__ */ g("div", { className: "url-upload-error", style: Q, children: [
|
|
155
|
+
/* @__PURE__ */ t("div", { children: "Error getting content from URL." }),
|
|
156
|
+
/* @__PURE__ */ t("div", { children: m })
|
|
157
|
+
] }) }),
|
|
158
|
+
/* @__PURE__ */ t(v, { condition: !I(), children: /* @__PURE__ */ t(
|
|
159
|
+
z,
|
|
160
|
+
{
|
|
161
|
+
"data-testid": `${e.testId}-preview`,
|
|
162
|
+
"aria-label": "url-content",
|
|
163
|
+
value: i,
|
|
164
|
+
readOnly: !0,
|
|
165
|
+
style: { minHeight: "128px" }
|
|
166
|
+
}
|
|
167
|
+
) })
|
|
168
|
+
] }) })
|
|
169
|
+
] });
|
|
170
|
+
}, ae = (e) => {
|
|
171
|
+
const [n, a] = u(), [i, c] = u(), d = (s) => typeof s == "string" ? s : s === void 0 ? "" : s.toDateString();
|
|
172
|
+
return E(() => {
|
|
173
|
+
e.isOpen && (typeof e.frontendInfo == "function" ? e.frontendInfo().then(a) : a(e.frontendInfo), typeof e.backendInfo == "function" ? e.backendInfo().then(c) : c(e.backendInfo));
|
|
114
174
|
}, [e.isOpen]), /* @__PURE__ */ t(
|
|
115
|
-
|
|
175
|
+
K,
|
|
116
176
|
{
|
|
117
177
|
className: "app-about-modal",
|
|
118
178
|
isOpen: e.isOpen,
|
|
@@ -121,34 +181,34 @@ const f = ({ condition: e, children: n }) => (() => typeof e == "boolean" ? e :
|
|
|
121
181
|
brandImageSrc: e.brandImageSrc,
|
|
122
182
|
brandImageAlt: e.brandImageAlt,
|
|
123
183
|
"aria-label": e.brandImageAlt,
|
|
124
|
-
children: /* @__PURE__ */
|
|
125
|
-
/* @__PURE__ */ t(
|
|
126
|
-
/* @__PURE__ */ t(T, { isLoading: n === void 0, children: /* @__PURE__ */
|
|
127
|
-
/* @__PURE__ */ t(
|
|
128
|
-
/* @__PURE__ */ t(
|
|
129
|
-
/* @__PURE__ */ t(
|
|
130
|
-
/* @__PURE__ */ t(
|
|
131
|
-
/* @__PURE__ */ t(
|
|
132
|
-
/* @__PURE__ */ t(
|
|
133
|
-
/* @__PURE__ */ t(
|
|
134
|
-
/* @__PURE__ */ t(
|
|
184
|
+
children: /* @__PURE__ */ g(G, { className: "app-about-modal-content", style: { marginTop: "-25px" }, children: [
|
|
185
|
+
/* @__PURE__ */ t(x, { component: y.h2, children: "Web console info" }),
|
|
186
|
+
/* @__PURE__ */ t(T, { isLoading: n === void 0, children: /* @__PURE__ */ g(C, { component: "dl", children: [
|
|
187
|
+
/* @__PURE__ */ t(r, { component: "dt", children: "Project" }),
|
|
188
|
+
/* @__PURE__ */ t(r, { component: "dd", children: /* @__PURE__ */ t("a", { href: n == null ? void 0 : n.url, target: "_blank", children: n == null ? void 0 : n.name }) }),
|
|
189
|
+
/* @__PURE__ */ t(r, { component: "dt", children: "Version" }),
|
|
190
|
+
/* @__PURE__ */ t(r, { component: "dd", children: n == null ? void 0 : n.version }),
|
|
191
|
+
/* @__PURE__ */ t(r, { component: "dt", children: "Built on" }),
|
|
192
|
+
/* @__PURE__ */ t(r, { component: "dd", children: d(n == null ? void 0 : n.builtOn) }),
|
|
193
|
+
/* @__PURE__ */ t(r, { component: "dt", children: "Digest" }),
|
|
194
|
+
/* @__PURE__ */ t(r, { component: "dd", children: n == null ? void 0 : n.digest })
|
|
135
195
|
] }) }),
|
|
136
|
-
/* @__PURE__ */ t(
|
|
137
|
-
/* @__PURE__ */ t(T, { isLoading: i === void 0, children: /* @__PURE__ */
|
|
138
|
-
/* @__PURE__ */ t(
|
|
139
|
-
/* @__PURE__ */ t(
|
|
140
|
-
/* @__PURE__ */ t(
|
|
141
|
-
/* @__PURE__ */ t(
|
|
142
|
-
/* @__PURE__ */ t(
|
|
143
|
-
/* @__PURE__ */ t(
|
|
144
|
-
/* @__PURE__ */ t(
|
|
145
|
-
/* @__PURE__ */ t(
|
|
196
|
+
/* @__PURE__ */ t(x, { style: { marginTop: "40px" }, component: y.h2, children: e.backendLabel }),
|
|
197
|
+
/* @__PURE__ */ t(T, { isLoading: i === void 0, children: /* @__PURE__ */ g(C, { component: "dl", children: [
|
|
198
|
+
/* @__PURE__ */ t(r, { component: "dt", children: "Name" }),
|
|
199
|
+
/* @__PURE__ */ t(r, { component: "dd", children: (i == null ? void 0 : i.name) || "" }),
|
|
200
|
+
/* @__PURE__ */ t(r, { component: "dt", children: "Description" }),
|
|
201
|
+
/* @__PURE__ */ t(r, { component: "dd", children: (i == null ? void 0 : i.description) || "" }),
|
|
202
|
+
/* @__PURE__ */ t(r, { component: "dt", children: "Version" }),
|
|
203
|
+
/* @__PURE__ */ t(r, { component: "dd", children: (i == null ? void 0 : i.version) || "" }),
|
|
204
|
+
/* @__PURE__ */ t(r, { component: "dt", children: "Built on" }),
|
|
205
|
+
/* @__PURE__ */ t(r, { component: "dd", children: d(i == null ? void 0 : i.builtOn) })
|
|
146
206
|
] }) })
|
|
147
207
|
] })
|
|
148
208
|
}
|
|
149
209
|
);
|
|
150
|
-
},
|
|
151
|
-
|
|
210
|
+
}, de = (e) => /* @__PURE__ */ g(
|
|
211
|
+
p,
|
|
152
212
|
{
|
|
153
213
|
title: "Please Wait",
|
|
154
214
|
variant: "small",
|
|
@@ -159,12 +219,12 @@ const f = ({ condition: e, children: n }) => (() => typeof e == "boolean" ? e :
|
|
|
159
219
|
"aria-label": "please-wait-modal",
|
|
160
220
|
style: { marginTop: "-15px" },
|
|
161
221
|
children: [
|
|
162
|
-
/* @__PURE__ */ t(
|
|
222
|
+
/* @__PURE__ */ t(S, { size: "md", className: "spinner" }),
|
|
163
223
|
/* @__PURE__ */ t("span", { className: "message", style: { fontSize: "15px", color: "#333", marginLeft: "10px" }, children: e.message })
|
|
164
224
|
]
|
|
165
225
|
}
|
|
166
|
-
),
|
|
167
|
-
|
|
226
|
+
), re = (e) => /* @__PURE__ */ t(
|
|
227
|
+
p,
|
|
168
228
|
{
|
|
169
229
|
title: e.title,
|
|
170
230
|
variant: "small",
|
|
@@ -173,17 +233,18 @@ const f = ({ condition: e, children: n }) => (() => typeof e == "boolean" ? e :
|
|
|
173
233
|
onClose: e.onClose,
|
|
174
234
|
className: "progress pf-m-redhat-font",
|
|
175
235
|
"aria-label": "progress-modal",
|
|
176
|
-
children: /* @__PURE__ */ t(
|
|
236
|
+
children: /* @__PURE__ */ t(q, { title: e.message, value: e.progress })
|
|
177
237
|
}
|
|
178
238
|
);
|
|
179
239
|
export {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
240
|
+
ae as AppAboutModal,
|
|
241
|
+
v as If,
|
|
242
|
+
te as IfNotEmpty,
|
|
183
243
|
T as IfNotLoading,
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
244
|
+
ne as ListWithToolbar,
|
|
245
|
+
le as ObjectDropdown,
|
|
246
|
+
ie as ObjectSelect,
|
|
247
|
+
de as PleaseWaitModal,
|
|
248
|
+
re as ProgressModal,
|
|
249
|
+
oe as UrlUpload
|
|
189
250
|
};
|