@apicurio/common-ui-components 1.0.4 → 1.0.6

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/main.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./common";
2
2
  export * from "./modals";
3
+ export * from "./table";
package/dist/main.js CHANGED
@@ -1,89 +1,90 @@
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." })
1
+ import { jsx as t, jsxs as g, Fragment as ie } from "react/jsx-runtime";
2
+ import y, { useState as v, useEffect as D, useRef as w, useCallback as L, useMemo as j, memo as V, forwardRef as E } from "react";
3
+ import { EmptyState as re, EmptyStateVariant as be, EmptyStateHeader as oe, EmptyStateBody as pe, Spinner as A, Alert as Te, Dropdown as Se, MenuToggle as H, DropdownList as Ie, Divider as le, DropdownItem as ye, Select as G, SelectOption as K, TextInput as Ce, Button as X, TextArea as we, AboutModal as xe, TextContent as Ne, Text as Y, TextVariants as Z, TextList as ee, TextListItem as f, Modal as ae, Progress as Oe, EmptyStateIcon as Re, Pagination as _e, PaginationVariant as ke, Skeleton as Fe, SearchInput as Le, SelectList as $e, ToolbarItem as De, InputGroup as Ee, ToolbarToggleGroup as ze, ToolbarGroup as Pe, ToolbarFilter as Ae } from "@patternfly/react-core";
4
+ import { EllipsisVIcon as He, FilterIcon as ce } from "@patternfly/react-icons";
5
+ import { Tr as z, Td as q, Th as We, Table as Be, Thead as Me, Tbody as je, ActionsColumn as Ue } from "@patternfly/react-table";
6
+ const C = ({ condition: e, children: n }) => (typeof e == "boolean" ? e : e()) ? /* @__PURE__ */ t(y.Fragment, { children: n }) : /* @__PURE__ */ t(y.Fragment, {}), nt = ({ collection: e, emptyState: n, emptyStateTitle: i, emptyStateMessage: r, children: c }) => {
7
+ const d = () => !e || e.length === 0, l = n || /* @__PURE__ */ g(re, { variant: be.xs, children: [
8
+ /* @__PURE__ */ t(oe, { titleText: i || "None found", headingLevel: "h4" }),
9
+ /* @__PURE__ */ t(pe, { children: r || "No items found." })
9
10
  ] });
10
- return d() ? /* @__PURE__ */ t(f.Fragment, { children: s }) : /* @__PURE__ */ t(f.Fragment, { children: c });
11
- }, T = ({ isLoading: e, loadingComponent: n, children: a }) => {
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 })
11
+ return d() ? /* @__PURE__ */ t(y.Fragment, { children: l }) : /* @__PURE__ */ t(y.Fragment, { children: c });
12
+ }, P = ({ isLoading: e, loadingComponent: n, children: i }) => {
13
+ const r = () => typeof e == "boolean" ? e : e(), c = n || /* @__PURE__ */ t(A, {});
14
+ return r() ? /* @__PURE__ */ t(y.Fragment, { children: c }) : /* @__PURE__ */ t(y.Fragment, { children: i });
15
+ }, it = ({ toolbar: e, alwaysShowToolbar: n, emptyState: i, filteredEmptyState: r, isLoading: c, isError: d, loadingComponent: l, errorComponent: o, isEmpty: a, isFiltered: s, children: h }) => {
16
+ const b = n || !a || s || d;
17
+ return o || (o = /* @__PURE__ */ t("div", { style: { padding: "15px", backgroundColor: "white" }, children: /* @__PURE__ */ t(Te, { 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(y.Fragment, { children: [
18
+ /* @__PURE__ */ t(C, { condition: b, children: e }),
19
+ /* @__PURE__ */ g(P, { isLoading: c, loadingComponent: l, children: [
20
+ /* @__PURE__ */ t(C, { condition: !a && !d, children: h }),
21
+ /* @__PURE__ */ t(C, { condition: a && s && !d, children: r }),
22
+ /* @__PURE__ */ t(C, { condition: a && !s && !d, children: i }),
23
+ /* @__PURE__ */ t(C, { condition: d, children: o })
23
24
  ] })
24
25
  ] });
25
- }, le = (e) => {
26
- const [n, a] = u(!1), i = (l, o) => {
27
- a(!1);
28
- const h = o;
26
+ }, rt = (e) => {
27
+ const [n, i] = v(!1), r = (a, s) => {
28
+ i(!1);
29
+ const h = s;
29
30
  h !== void 0 && h >= 0 ? e.onSelect(e.items[h]) : e.onSelect(void 0);
30
31
  }, c = () => {
31
- a(!n);
32
- }, d = (l) => {
33
- let o;
34
- return e.itemToTestId !== void 0 && (o = e.itemToTestId(l)), o;
35
- }, s = e.popperProps || {
32
+ i(!n);
33
+ }, d = (a) => {
34
+ let s;
35
+ return e.itemToTestId !== void 0 && (s = e.itemToTestId(a)), s;
36
+ }, l = e.popperProps || {
36
37
  appendTo: e.menuAppendTo
37
38
  };
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,
39
+ let o = /* @__PURE__ */ t(He, { title: e.label });
40
+ return e.isKebab || (o = /* @__PURE__ */ t(y.Fragment, { children: e.label })), /* @__PURE__ */ t(
41
+ Se,
41
42
  {
42
43
  isOpen: n,
43
- onSelect: i,
44
- onOpenChange: (l) => a(l),
45
- toggle: (l) => /* @__PURE__ */ t(
46
- N,
44
+ onSelect: r,
45
+ onOpenChange: (a) => i(a),
46
+ toggle: (a) => /* @__PURE__ */ t(
47
+ H,
47
48
  {
48
49
  "data-testid": e.testId,
49
- ref: l,
50
+ ref: a,
50
51
  onClick: c,
51
52
  isExpanded: n,
52
53
  variant: e.isKebab ? "plain" : "default",
53
- children: m
54
+ children: o
54
55
  }
55
56
  ),
56
57
  ouiaId: "ObjectDropdown",
57
- popperProps: s,
58
+ popperProps: l,
58
59
  shouldFocusToggleOnSelect: !0,
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
- $,
60
+ children: /* @__PURE__ */ t(Ie, { children: e.items.map((a, s) => e.itemIsDivider && e.itemIsDivider(a) ? /* @__PURE__ */ t(le, { component: "li" }, `divider-${s}`) : /* @__PURE__ */ t(
61
+ ye,
61
62
  {
62
- value: o,
63
- component: (h) => /* @__PURE__ */ t("button", { ...h, "data-testid": d(l) }),
64
- children: e.itemToString(l)
63
+ value: s,
64
+ component: (h) => /* @__PURE__ */ t("button", { ...h, "data-testid": d(a) }),
65
+ children: e.itemToString(a)
65
66
  },
66
- `action-${o}`
67
+ `action-${s}`
67
68
  )) })
68
69
  }
69
70
  );
70
- }, ie = (e) => {
71
- var m;
72
- const [n, a] = u(!1), i = (l, o) => {
73
- a(!1), e.onSelect(e.items[o]);
71
+ }, ot = (e) => {
72
+ var o;
73
+ const [n, i] = v(!1), r = (a, s) => {
74
+ i(!1), e.onSelect(e.items[s]);
74
75
  }, c = () => {
75
- a(!n);
76
- }, d = (l) => {
77
- let o;
78
- return e.itemToTestId !== void 0 && (o = e.itemToTestId(l)), o;
76
+ i(!n);
77
+ }, d = (a) => {
78
+ let s;
79
+ return e.itemToTestId !== void 0 && (s = e.itemToTestId(a)), s;
79
80
  };
80
81
  return /* @__PURE__ */ t(
81
- H,
82
+ G,
82
83
  {
83
- toggle: (l) => /* @__PURE__ */ t(
84
- N,
84
+ toggle: (a) => /* @__PURE__ */ t(
85
+ H,
85
86
  {
86
- ref: l,
87
+ ref: a,
87
88
  className: e.toggleClassname || "menu-toggle",
88
89
  onClick: c,
89
90
  "data-testid": e.testId,
@@ -92,87 +93,87 @@ const v = ({ condition: e, children: n }) => (() => typeof e == "boolean" ? e :
92
93
  }
93
94
  ),
94
95
  id: e.toggleId,
95
- onSelect: i,
96
- onOpenChange: a,
96
+ onSelect: r,
97
+ onOpenChange: i,
97
98
  isOpen: n,
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,
99
+ children: (o = e.items) == null ? void 0 : o.map((a, s) => e.itemIsDivider && e.itemIsDivider(a) ? /* @__PURE__ */ t(le, {}, s) : /* @__PURE__ */ t(
100
+ K,
100
101
  {
101
- isSelected: l === e.value,
102
- component: (h) => /* @__PURE__ */ t("button", { ...h, "data-testid": d(l) }),
103
- value: o,
104
- children: e.itemToString(l)
102
+ isSelected: a === e.value,
103
+ component: (h) => /* @__PURE__ */ t("button", { ...h, "data-testid": d(a) }),
104
+ value: s,
105
+ children: e.itemToString(a)
105
106
  },
106
- o
107
+ s
107
108
  ))
108
109
  }
109
110
  );
110
- }, D = {
111
+ }, de = {
111
112
  padding: "5px",
112
113
  minHeight: "128px",
113
114
  borderRight: 0,
114
115
  borderLeft: 0,
115
116
  borderBottom: "1px solid #666",
116
117
  backgroundColor: "rgb(240, 240, 240)"
117
- }, Q = {
118
- ...D,
118
+ }, Ve = {
119
+ ...de,
119
120
  color: "red",
120
121
  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);
122
+ }, lt = (e) => {
123
+ const [n, i] = v(""), [r, c] = v(""), [d, l] = v(!1), [o, a] = v(), s = (p, O) => {
124
+ i(O);
125
+ }, h = () => n != null && n.trim().length > 0, b = () => o != null && o.trim().length > 0, x = () => {
126
+ l(!0), e.onUrlFetch(n).then((p) => {
127
+ a(void 0), c(p), l(!1), e.onChange(p, n);
128
+ }).catch((p) => {
129
+ a(p.message), l(!1);
129
130
  });
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" } }),
131
+ }, S = () => {
132
+ i(""), c(""), e.onChange(void 0, void 0);
133
+ }, N = /* @__PURE__ */ g("div", { className: "url-upload-loading", style: de, children: [
134
+ /* @__PURE__ */ t(A, { size: "md", className: "spinner", style: { marginRight: "5px" } }),
134
135
  /* @__PURE__ */ t("span", { className: "spinner-message", children: "Loading URL content" })
135
136
  ] });
136
137
  return /* @__PURE__ */ g("div", { className: "url-upload", "data-testid": e.testId, children: [
137
138
  /* @__PURE__ */ g("div", { className: "url-upload-flex", style: { display: "flex" }, children: [
138
139
  /* @__PURE__ */ t("div", { className: "url-upload-url", style: { flexGrow: 1 }, children: /* @__PURE__ */ t(
139
- _,
140
+ Ce,
140
141
  {
141
142
  "data-testid": `${e.testId}-input`,
142
143
  value: n,
143
144
  type: "text",
144
145
  placeholder: e.urlPlaceholder,
145
146
  id: e.id,
146
- onChange: o,
147
+ onChange: s,
147
148
  "aria-label": "url input"
148
149
  }
149
150
  ) }),
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" }) })
151
+ /* @__PURE__ */ t("div", { className: "url-fetch-button", children: /* @__PURE__ */ t(X, { "data-testid": `${e.testId}-fetch`, variant: "control", isDisabled: !h(), onClick: x, children: "Fetch" }) }),
152
+ /* @__PURE__ */ t("div", { className: "url-clear-button", children: /* @__PURE__ */ t(X, { "data-testid": `${e.testId}-clear`, variant: "control", isDisabled: !h(), onClick: S, children: "Clear" }) })
152
153
  ] }),
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: [
154
+ /* @__PURE__ */ t("div", { className: "url-upload-preview", children: /* @__PURE__ */ g(P, { isLoading: d, loadingComponent: N, children: [
155
+ /* @__PURE__ */ t(C, { condition: b, children: /* @__PURE__ */ g("div", { className: "url-upload-error", style: Ve, children: [
155
156
  /* @__PURE__ */ t("div", { children: "Error getting content from URL." }),
156
- /* @__PURE__ */ t("div", { children: m })
157
+ /* @__PURE__ */ t("div", { children: o })
157
158
  ] }) }),
158
- /* @__PURE__ */ t(v, { condition: !I(), children: /* @__PURE__ */ t(
159
- z,
159
+ /* @__PURE__ */ t(C, { condition: !b(), children: /* @__PURE__ */ t(
160
+ we,
160
161
  {
161
162
  "data-testid": `${e.testId}-preview`,
162
163
  "aria-label": "url-content",
163
- value: i,
164
+ value: r,
164
165
  readOnly: !0,
165
166
  style: { minHeight: "128px" }
166
167
  }
167
168
  ) })
168
169
  ] }) })
169
170
  ] });
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));
171
+ }, at = (e) => {
172
+ const [n, i] = v(), [r, c] = v(), d = (l) => typeof l == "string" ? l : l === void 0 ? "" : l.toDateString();
173
+ return D(() => {
174
+ e.isOpen && (typeof e.frontendInfo == "function" ? e.frontendInfo().then(i) : i(e.frontendInfo), typeof e.backendInfo == "function" ? e.backendInfo().then(c) : c(e.backendInfo));
174
175
  }, [e.isOpen]), /* @__PURE__ */ t(
175
- K,
176
+ xe,
176
177
  {
177
178
  className: "app-about-modal",
178
179
  isOpen: e.isOpen,
@@ -181,34 +182,34 @@ const v = ({ condition: e, children: n }) => (() => typeof e == "boolean" ? e :
181
182
  brandImageSrc: e.brandImageSrc,
182
183
  brandImageAlt: e.brandImageAlt,
183
184
  "aria-label": e.brandImageAlt,
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 })
185
+ children: /* @__PURE__ */ g(Ne, { className: "app-about-modal-content", style: { marginTop: "-25px" }, children: [
186
+ /* @__PURE__ */ t(Y, { component: Z.h2, children: "Web console info" }),
187
+ /* @__PURE__ */ t(P, { isLoading: n === void 0, children: /* @__PURE__ */ g(ee, { component: "dl", children: [
188
+ /* @__PURE__ */ t(f, { component: "dt", children: "Project" }),
189
+ /* @__PURE__ */ t(f, { component: "dd", children: /* @__PURE__ */ t("a", { href: n == null ? void 0 : n.url, target: "_blank", children: n == null ? void 0 : n.name }) }),
190
+ /* @__PURE__ */ t(f, { component: "dt", children: "Version" }),
191
+ /* @__PURE__ */ t(f, { component: "dd", children: n == null ? void 0 : n.version }),
192
+ /* @__PURE__ */ t(f, { component: "dt", children: "Built on" }),
193
+ /* @__PURE__ */ t(f, { component: "dd", children: d(n == null ? void 0 : n.builtOn) }),
194
+ /* @__PURE__ */ t(f, { component: "dt", children: "Digest" }),
195
+ /* @__PURE__ */ t(f, { component: "dd", children: n == null ? void 0 : n.digest })
195
196
  ] }) }),
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) })
197
+ /* @__PURE__ */ t(Y, { style: { marginTop: "40px" }, component: Z.h2, children: e.backendLabel }),
198
+ /* @__PURE__ */ t(P, { isLoading: r === void 0, children: /* @__PURE__ */ g(ee, { component: "dl", children: [
199
+ /* @__PURE__ */ t(f, { component: "dt", children: "Name" }),
200
+ /* @__PURE__ */ t(f, { component: "dd", children: (r == null ? void 0 : r.name) || "" }),
201
+ /* @__PURE__ */ t(f, { component: "dt", children: "Description" }),
202
+ /* @__PURE__ */ t(f, { component: "dd", children: (r == null ? void 0 : r.description) || "" }),
203
+ /* @__PURE__ */ t(f, { component: "dt", children: "Version" }),
204
+ /* @__PURE__ */ t(f, { component: "dd", children: (r == null ? void 0 : r.version) || "" }),
205
+ /* @__PURE__ */ t(f, { component: "dt", children: "Built on" }),
206
+ /* @__PURE__ */ t(f, { component: "dd", children: d(r == null ? void 0 : r.builtOn) })
206
207
  ] }) })
207
208
  ] })
208
209
  }
209
210
  );
210
- }, de = (e) => /* @__PURE__ */ g(
211
- p,
211
+ }, ct = (e) => /* @__PURE__ */ g(
212
+ ae,
212
213
  {
213
214
  title: "Please Wait",
214
215
  variant: "small",
@@ -219,12 +220,12 @@ const v = ({ condition: e, children: n }) => (() => typeof e == "boolean" ? e :
219
220
  "aria-label": "please-wait-modal",
220
221
  style: { marginTop: "-15px" },
221
222
  children: [
222
- /* @__PURE__ */ t(S, { size: "md", className: "spinner" }),
223
+ /* @__PURE__ */ t(A, { size: "md", className: "spinner" }),
223
224
  /* @__PURE__ */ t("span", { className: "message", style: { fontSize: "15px", color: "#333", marginLeft: "10px" }, children: e.message })
224
225
  ]
225
226
  }
226
- ), re = (e) => /* @__PURE__ */ t(
227
- p,
227
+ ), dt = (e) => /* @__PURE__ */ t(
228
+ ae,
228
229
  {
229
230
  title: e.title,
230
231
  variant: "small",
@@ -233,18 +234,506 @@ const v = ({ condition: e, children: n }) => (() => typeof e == "boolean" ? e :
233
234
  onClose: e.onClose,
234
235
  className: "progress pf-m-redhat-font",
235
236
  "aria-label": "progress-modal",
236
- children: /* @__PURE__ */ t(q, { title: e.message, value: e.progress })
237
+ children: /* @__PURE__ */ t(Oe, { title: e.message, value: e.progress })
237
238
  }
238
239
  );
240
+ function st() {
241
+ return /* @__PURE__ */ t(re, { children: /* @__PURE__ */ t(
242
+ oe,
243
+ {
244
+ titleText: "Loading",
245
+ headingLevel: "h4",
246
+ icon: /* @__PURE__ */ t(Re, { icon: A })
247
+ }
248
+ ) });
249
+ }
250
+ function ht({
251
+ itemCount: e,
252
+ page: n,
253
+ perPage: i,
254
+ isCompact: r = !1,
255
+ onChange: c,
256
+ variant: d = ke.top
257
+ }) {
258
+ return /* @__PURE__ */ t(
259
+ _e,
260
+ {
261
+ itemCount: e,
262
+ page: n,
263
+ perPage: i,
264
+ onSetPage: (l, o) => c(o, i),
265
+ onPerPageSelect: (l, o) => c(1, o),
266
+ variant: d,
267
+ isCompact: r
268
+ }
269
+ );
270
+ }
271
+ function Ge(e, n) {
272
+ var i = w(null), r = w(null);
273
+ r.current = n;
274
+ var c = w(null);
275
+ D(function() {
276
+ d();
277
+ });
278
+ var d = L(function() {
279
+ var l = c.current, o = r.current, a = l || (o ? o instanceof Element ? o : o.current : null);
280
+ i.current && i.current.element === a && i.current.subscriber === e || (i.current && i.current.cleanup && i.current.cleanup(), i.current = {
281
+ element: a,
282
+ subscriber: e,
283
+ // Only calling the subscriber, if there's an actual element to report.
284
+ // Setting cleanup to undefined unless a subscriber returns one, as an existing cleanup function would've been just called.
285
+ cleanup: a ? e(a) : void 0
286
+ });
287
+ }, [e]);
288
+ return D(function() {
289
+ return function() {
290
+ i.current && i.current.cleanup && (i.current.cleanup(), i.current = null);
291
+ };
292
+ }, []), L(function(l) {
293
+ c.current = l, d();
294
+ }, [d]);
295
+ }
296
+ function te(e, n, i) {
297
+ return e[n] ? e[n][0] ? e[n][0][i] : (
298
+ // TS complains about this, because the RO entry type follows the spec and does not reflect Firefox's current
299
+ // behaviour of returning objects instead of arrays for `borderBoxSize` and `contentBoxSize`.
300
+ // @ts-ignore
301
+ e[n][i]
302
+ ) : n === "contentBoxSize" ? e.contentRect[i === "inlineSize" ? "width" : "height"] : void 0;
303
+ }
304
+ function Ke(e) {
305
+ e === void 0 && (e = {});
306
+ var n = e.onResize, i = w(void 0);
307
+ i.current = n;
308
+ var r = e.round || Math.round, c = w(), d = v({
309
+ width: void 0,
310
+ height: void 0
311
+ }), l = d[0], o = d[1], a = w(!1);
312
+ D(function() {
313
+ return a.current = !1, function() {
314
+ a.current = !0;
315
+ };
316
+ }, []);
317
+ var s = w({
318
+ width: void 0,
319
+ height: void 0
320
+ }), h = Ge(L(function(b) {
321
+ return (!c.current || c.current.box !== e.box || c.current.round !== r) && (c.current = {
322
+ box: e.box,
323
+ round: r,
324
+ instance: new ResizeObserver(function(x) {
325
+ var S = x[0], N = e.box === "border-box" ? "borderBoxSize" : e.box === "device-pixel-content-box" ? "devicePixelContentBoxSize" : "contentBoxSize", p = te(S, N, "inlineSize"), O = te(S, N, "blockSize"), T = p ? r(p) : void 0, _ = O ? r(O) : void 0;
326
+ if (s.current.width !== T || s.current.height !== _) {
327
+ var R = {
328
+ width: T,
329
+ height: _
330
+ };
331
+ s.current.width = T, s.current.height = _, i.current ? i.current(R) : a.current || o(R);
332
+ }
333
+ })
334
+ }), c.current.instance.observe(b, {
335
+ box: e.box
336
+ }), function() {
337
+ c.current && c.current.instance.unobserve(b);
338
+ };
339
+ }, [e.box, r]), e.ref);
340
+ return j(function() {
341
+ return {
342
+ ref: h,
343
+ width: l.width,
344
+ height: l.height
345
+ };
346
+ }, [h, l.width, l.height]);
347
+ }
348
+ function qe({ columns: e, rows: n, getTd: i = () => q }) {
349
+ const r = new Array(e).fill(0).map((d, l) => {
350
+ const o = i(l);
351
+ return /* @__PURE__ */ t(o, { children: /* @__PURE__ */ t(
352
+ Fe,
353
+ {
354
+ screenreaderText: l === 0 ? "Loading data" : void 0
355
+ }
356
+ ) }, `cell_${l}`);
357
+ }), c = new Array(n).fill(0).map((d, l) => /* @__PURE__ */ t(z, { children: r }, `row_${l}`));
358
+ return /* @__PURE__ */ t(ie, { children: c });
359
+ }
360
+ const ut = ({
361
+ ariaLabel: e,
362
+ minimumColumnWidth: n = 250,
363
+ columns: i,
364
+ data: r,
365
+ renderHeader: c,
366
+ renderCell: d,
367
+ renderActions: l,
368
+ isColumnSortable: o,
369
+ isRowDeleted: a,
370
+ isRowSelected: s,
371
+ expectedLength: h = 3,
372
+ onRowClick: b,
373
+ setActionCellOuiaId: x,
374
+ setRowOuiaId: S,
375
+ tableOuiaId: N,
376
+ children: p,
377
+ variant: O
378
+ }) => {
379
+ const [T, _] = v(1e3);
380
+ let R;
381
+ const ue = ({ width: u }) => {
382
+ R && cancelAnimationFrame(R), u && (R = requestAnimationFrame(() => {
383
+ _(u);
384
+ }));
385
+ }, { ref: me } = Ke({ onResize: ue }), W = T >= 576, $ = L(
386
+ (u) => W && u !== 0 && u !== i.length - 1,
387
+ [i, W]
388
+ ), ge = j(() => i.map((u, m) => {
389
+ const I = E(
390
+ ({ children: k, ...F }, M) => /* @__PURE__ */ t(
391
+ se,
392
+ {
393
+ position: m,
394
+ tableWidth: T,
395
+ columnWidth: n,
396
+ canHide: $(m),
397
+ sort: o ? o(u) : void 0,
398
+ ...F,
399
+ ref: M,
400
+ children: k
401
+ }
402
+ )
403
+ );
404
+ return I.displayName = "ResponsiveThCurried", c({
405
+ Th: I,
406
+ key: `header_${u}`,
407
+ column: u,
408
+ colIndex: m
409
+ });
410
+ }), [
411
+ $,
412
+ i,
413
+ o,
414
+ n,
415
+ c,
416
+ T
417
+ ]), B = L(
418
+ (u) => {
419
+ const m = E(
420
+ ({ children: I, ...k }, F) => /* @__PURE__ */ t(
421
+ U,
422
+ {
423
+ position: u,
424
+ tableWidth: T,
425
+ columnWidth: n,
426
+ canHide: $(u),
427
+ ...k,
428
+ ref: F,
429
+ children: I
430
+ }
431
+ )
432
+ );
433
+ return m.displayName = "ResponsiveTdCurried", m;
434
+ },
435
+ [$, n, T]
436
+ ), fe = j(
437
+ () => i.map((u, m) => B(m)),
438
+ [i, B]
439
+ );
440
+ return /* @__PURE__ */ g(
441
+ Be,
442
+ {
443
+ "aria-label": e,
444
+ gridBreakPoint: "",
445
+ ref: me,
446
+ className: W ? "" : "pf-m-grid",
447
+ ouiaId: N,
448
+ variant: O,
449
+ children: [
450
+ /* @__PURE__ */ t(Me, { children: /* @__PURE__ */ t(z, { children: ge }) }),
451
+ /* @__PURE__ */ g(je, { children: [
452
+ r === void 0 && /* @__PURE__ */ t(
453
+ qe,
454
+ {
455
+ columns: i.length,
456
+ rows: h,
457
+ getTd: B
458
+ }
459
+ ),
460
+ r == null ? void 0 : r.map((u, m) => {
461
+ const I = a !== void 0 && a({ row: u, rowIndex: m }), k = s !== void 0 && s({ row: u, rowIndex: m }), F = !I && b ? () => b({ row: u, rowIndex: m }) : void 0, M = i.map((J, Q) => d({
462
+ Td: fe[Q],
463
+ key: `row_${m}_cell_${J}`,
464
+ column: J,
465
+ colIndex: Q,
466
+ rowIndex: m,
467
+ row: u
468
+ })), ve = !I && l && /* @__PURE__ */ t(
469
+ U,
470
+ {
471
+ position: i.length,
472
+ tableWidth: T,
473
+ columnWidth: n,
474
+ canHide: !1,
475
+ isActionCell: !0,
476
+ "data-testid": x ? x({ row: u, rowIndex: m }) : `actions-for-row-${m}`,
477
+ children: l({ rowIndex: m, row: u, ActionsColumn: Ue })
478
+ }
479
+ );
480
+ return /* @__PURE__ */ g(
481
+ he,
482
+ {
483
+ isDeleted: I,
484
+ isSelected: k,
485
+ onClick: F,
486
+ rowOuiaId: S == null ? void 0 : S({ row: u, rowIndex: m }),
487
+ children: [
488
+ M,
489
+ ve
490
+ ]
491
+ },
492
+ `row_${m}`
493
+ );
494
+ }),
495
+ (r == null ? void 0 : r.length) === 0 && /* @__PURE__ */ t(z, { children: /* @__PURE__ */ t(q, { colSpan: i.length, children: p }) })
496
+ ] })
497
+ ]
498
+ }
499
+ );
500
+ }, se = V(
501
+ E((e, n) => {
502
+ const {
503
+ tableWidth: i,
504
+ columnWidth: r,
505
+ position: c,
506
+ canHide: d,
507
+ className: l = "",
508
+ children: o,
509
+ ...a
510
+ } = e, s = d && i < r * (c + 1) ? "pf-m-hidden" : "pf-m-visible";
511
+ return /* @__PURE__ */ t(
512
+ We,
513
+ {
514
+ ref: n,
515
+ className: `${s} ${l}`,
516
+ ...a,
517
+ children: o
518
+ }
519
+ );
520
+ })
521
+ );
522
+ se.displayName = "ResponsiveTh";
523
+ const U = V(
524
+ E((e, n) => {
525
+ const {
526
+ tableWidth: i,
527
+ columnWidth: r,
528
+ position: c,
529
+ canHide: d,
530
+ className: l = "",
531
+ children: o,
532
+ ...a
533
+ } = e, s = d && i < r * (c + 1) ? "pf-m-hidden" : "pf-m-visible";
534
+ return /* @__PURE__ */ t(
535
+ q,
536
+ {
537
+ ref: n,
538
+ className: `${s} ${l}`,
539
+ ...a,
540
+ children: o
541
+ }
542
+ );
543
+ })
544
+ );
545
+ U.displayName = "ResponsiveTd";
546
+ const he = V(
547
+ ({ isDeleted: e, isSelected: n, onClick: i, children: r, rowOuiaId: c }) => /* @__PURE__ */ t(
548
+ z,
549
+ {
550
+ onRowClick: (d) => {
551
+ (d == null ? void 0 : d.target) instanceof HTMLElement && (["a", "button"].includes(d.target.tagName.toLowerCase()) || i && i());
552
+ },
553
+ ouiaId: c,
554
+ isRowSelected: n,
555
+ className: e ? "mas--ResponsiveTable__Tr--deleted" : void 0,
556
+ "data-testid": [n && "row-selected", e && "row-deleted"].filter((d) => !!d).join(" "),
557
+ role: "row",
558
+ children: r
559
+ }
560
+ )
561
+ );
562
+ he.displayName = "DeletableRow";
563
+ const Je = ({ label: e, onSearch: n }) => {
564
+ const i = (r, c, d) => {
565
+ n(c);
566
+ };
567
+ return /* @__PURE__ */ t(
568
+ Le,
569
+ {
570
+ placeholder: `Filter by ${e}`,
571
+ onSearch: i
572
+ }
573
+ );
574
+ };
575
+ function ne({
576
+ options: e,
577
+ value: n,
578
+ onChange: i,
579
+ ouiaId: r
580
+ }) {
581
+ const [c, d] = v(!1);
582
+ return /* @__PURE__ */ t(
583
+ G,
584
+ {
585
+ toggle: (o) => /* @__PURE__ */ t(
586
+ H,
587
+ {
588
+ ref: o,
589
+ onClick: () => d((a) => !a),
590
+ isExpanded: c,
591
+ variant: "plain",
592
+ children: /* @__PURE__ */ t(ce, {})
593
+ }
594
+ ),
595
+ "aria-label": "table:select_filter",
596
+ selected: n,
597
+ isOpen: c,
598
+ onSelect: (o, a) => {
599
+ i(a), d(!1);
600
+ },
601
+ ouiaId: r,
602
+ children: /* @__PURE__ */ t($e, { children: e.map((o, a) => /* @__PURE__ */ t(K, { value: o, children: o }, a)) })
603
+ }
604
+ );
605
+ }
606
+ function Qe({
607
+ label: e,
608
+ chips: n,
609
+ options: i,
610
+ onToggle: r
611
+ }) {
612
+ const [c, d] = v(!1);
613
+ return /* @__PURE__ */ t(
614
+ G,
615
+ {
616
+ "aria-label": e,
617
+ onSelect: (l, o) => {
618
+ r(o);
619
+ },
620
+ selected: n,
621
+ isOpen: c,
622
+ toggle: (l) => /* @__PURE__ */ t(
623
+ H,
624
+ {
625
+ ref: l,
626
+ onClick: () => d((o) => !o),
627
+ isExpanded: c,
628
+ style: {
629
+ width: "200px"
630
+ },
631
+ children: `Filter by ${e}`
632
+ }
633
+ ),
634
+ children: Object.entries(i).map(([l, o]) => /* @__PURE__ */ t(K, { value: l, hasCheckbox: !0, children: o }, l))
635
+ }
636
+ );
637
+ }
638
+ function mt({ filters: e, breakpoint: n = "md" }) {
639
+ const i = Object.keys(e), [r, c] = v(i[0]), d = (l, o) => {
640
+ switch (o.type) {
641
+ case "search":
642
+ return /* @__PURE__ */ t(
643
+ Je,
644
+ {
645
+ onSearch: o.onSearch,
646
+ label: l,
647
+ validate: o.validate,
648
+ errorMessage: o.errorMessage
649
+ }
650
+ );
651
+ case "checkbox":
652
+ return /* @__PURE__ */ t(
653
+ Qe,
654
+ {
655
+ chips: o.chips,
656
+ options: o.options,
657
+ onToggle: o.onToggle,
658
+ label: l
659
+ }
660
+ );
661
+ }
662
+ };
663
+ return /* @__PURE__ */ g(ie, { children: [
664
+ /* @__PURE__ */ t(
665
+ De,
666
+ {
667
+ variant: "search-filter",
668
+ visibility: { default: "hidden", [n]: "visible" },
669
+ "data-testid": "large-viewport-toolbar",
670
+ children: /* @__PURE__ */ g(Ee, { children: [
671
+ i.length > 1 && /* @__PURE__ */ t(
672
+ ne,
673
+ {
674
+ options: i,
675
+ value: r,
676
+ onChange: c,
677
+ ouiaId: "chip-filter-selector-large-viewport"
678
+ }
679
+ ),
680
+ d(r, e[r])
681
+ ] })
682
+ }
683
+ ),
684
+ /* @__PURE__ */ t(
685
+ ze,
686
+ {
687
+ toggleIcon: /* @__PURE__ */ t(ce, {}),
688
+ breakpoint: n,
689
+ visibility: { default: "visible", [n]: "hidden" },
690
+ children: /* @__PURE__ */ g(Pe, { variant: "filter-group", children: [
691
+ i.length > 1 && /* @__PURE__ */ t(
692
+ ne,
693
+ {
694
+ options: i,
695
+ value: r,
696
+ onChange: c,
697
+ ouiaId: "chip-filter-selector-small-viewport"
698
+ }
699
+ ),
700
+ Object.entries(e).map(([l, o], a) => /* @__PURE__ */ t(
701
+ Ae,
702
+ {
703
+ chips: o.type === "checkbox" ? o.chips.map((s) => ({ key: s, node: o.options[s] })) : o.chips,
704
+ deleteChip: (s, h) => o.onRemoveChip(typeof h == "string" ? h : h.key),
705
+ deleteChipGroup: o.onRemoveGroup,
706
+ categoryName: l,
707
+ showToolbarItem: l === r,
708
+ children: l === r && d(l, o)
709
+ },
710
+ a
711
+ ))
712
+ ] })
713
+ }
714
+ )
715
+ ] });
716
+ }
239
717
  export {
240
- ae as AppAboutModal,
241
- v as If,
242
- te as IfNotEmpty,
243
- T as IfNotLoading,
244
- ne as ListWithToolbar,
245
- le as ObjectDropdown,
246
- ie as ObjectSelect,
247
- de as PleaseWaitModal,
248
- re as ProgressModal,
249
- oe as UrlUpload
718
+ at as AppAboutModal,
719
+ mt as ChipFilter,
720
+ he as DeletableRow,
721
+ Qe as FilterCheckbox,
722
+ Je as FilterSearch,
723
+ ne as FilterSelector,
724
+ C as If,
725
+ nt as IfNotEmpty,
726
+ P as IfNotLoading,
727
+ it as ListWithToolbar,
728
+ st as Loading,
729
+ rt as ObjectDropdown,
730
+ ot as ObjectSelect,
731
+ ht as Pagination,
732
+ ct as PleaseWaitModal,
733
+ dt as ProgressModal,
734
+ ut as ResponsiveTable,
735
+ U as ResponsiveTd,
736
+ se as ResponsiveTh,
737
+ qe as TableSkeleton,
738
+ lt as UrlUpload
250
739
  };
@@ -2,3 +2,4 @@ export * from "./ChipFilter";
2
2
  export type { FilterType } from "./types";
3
3
  export type { CheckboxType } from "./types";
4
4
  export type { SearchType } from "./types";
5
+ export * from "./components";
@@ -1 +1,5 @@
1
+ export * from "./Loading";
2
+ export * from "./Pagination";
1
3
  export * from "./ResponsiveTable";
4
+ export * from "./TableSkeleton";
5
+ export * from "./ChipFilter";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@apicurio/common-ui-components",
3
3
  "private": false,
4
- "version": "1.0.4",
4
+ "version": "1.0.6",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",
@@ -19,10 +19,10 @@
19
19
  "@patternfly/react-core": "5.1.1",
20
20
  "@patternfly/react-icons": "5.1.1",
21
21
  "@patternfly/react-table": "5.1.1",
22
- "luxon": "3.4.3",
22
+ "luxon": "3.4.4",
23
23
  "react": "18.2.0",
24
24
  "react-dom": "18.2.0",
25
- "react-router-dom": "6.18.0",
25
+ "react-router-dom": "6.20.0",
26
26
  "use-resize-observer": "9.1.0"
27
27
  },
28
28
  "devDependencies": {
@@ -32,23 +32,23 @@
32
32
  "@patternfly/react-icons": "5.1.1",
33
33
  "@patternfly/react-table": "5.1.1",
34
34
  "@types/luxon": "3.3.5",
35
- "@types/node": "18.18.13",
35
+ "@types/node": "20.10.1",
36
36
  "@types/react": "18.2.39",
37
37
  "@types/react-dom": "18.2.17",
38
38
  "@typescript-eslint/eslint-plugin": "6.13.1",
39
- "@typescript-eslint/parser": "6.0.0",
40
- "@vitejs/plugin-react": "4.0.3",
41
- "eslint": "8.45.0",
39
+ "@typescript-eslint/parser": "6.13.1",
40
+ "@vitejs/plugin-react": "4.2.0",
41
+ "eslint": "8.54.0",
42
42
  "eslint-plugin-react-hooks": "4.6.0",
43
- "eslint-plugin-react-refresh": "0.4.3",
44
- "luxon": "3.4.3",
43
+ "eslint-plugin-react-refresh": "0.4.4",
44
+ "luxon": "3.4.4",
45
45
  "rimraf": "5.0.5",
46
- "typescript": "5.0.2",
47
- "vite": "4.4.5",
48
- "vite-plugin-dts": "3.6.3",
46
+ "typescript": "5.3.2",
47
+ "vite": "5.0.4",
48
+ "vite-plugin-dts": "3.6.4",
49
49
  "react": "18.2.0",
50
50
  "react-dom": "18.2.0",
51
- "react-router-dom": "6.18.0",
51
+ "react-router-dom": "6.20.0",
52
52
  "use-resize-observer": "9.1.0"
53
53
  }
54
54
  }