@edifice.io/collect-frontend 0.2.0-develop-pedago.0 → 0.2.2-develop-pedago.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.
@@ -0,0 +1,361 @@
1
+ import { r as d, c as I, j as e, d as g, e as U, A as R, f as D, H as _, g as F, B as w, u as v, h as T, a as N, W as L, i as P, k as V, l as W, m as O, T as $, D as b, F as y, n as q, N as G, G as M, O as K, L as J } from "./index-Dt9ykSDF.js";
2
+ const Q = /* @__PURE__ */ d.forwardRef(({
3
+ children: s,
4
+ render: t,
5
+ isFullscreen: n = !1,
6
+ ...l
7
+ }, a) => {
8
+ const u = I("d-flex flex-wrap p-16 gap-8 border-bottom bg-white", {
9
+ "justify-content-between": t,
10
+ "mx-n16": !n,
11
+ "z-3 top-0 start-0 end-0": n
12
+ });
13
+ return /* @__PURE__ */ e.jsxs("div", { ref: a, className: u, ...l, children: [
14
+ s,
15
+ t ? /* @__PURE__ */ e.jsx("div", { className: "d-flex align-items-center ms-auto gap-8", children: t() }) : null
16
+ ] });
17
+ }), C = /* @__PURE__ */ d.forwardRef(({
18
+ children: s,
19
+ className: t,
20
+ ...n
21
+ }, l) => {
22
+ const a = I("breadcrumb-item", t);
23
+ return /* @__PURE__ */ e.jsx("li", { ref: l, className: a, ...n, children: s });
24
+ }), X = /* @__PURE__ */ d.forwardRef(({
25
+ children: s,
26
+ className: t
27
+ }, n) => {
28
+ const l = I("breadcrumb d-flex flex-nowrap align-items-center mb-0", t);
29
+ return /* @__PURE__ */ e.jsx("ol", { ref: n, className: l, children: s });
30
+ }), Y = /* @__PURE__ */ d.forwardRef(({
31
+ children: s,
32
+ app: t,
33
+ className: n
34
+ }, l) => {
35
+ const {
36
+ t: a
37
+ } = g(), {
38
+ getIconClass: u
39
+ } = U(), m = I("d-flex align-items-center mb-0", u(t), n), h = {
40
+ "--edifice-breadcrumb-divider": "-"
41
+ };
42
+ return /* @__PURE__ */ e.jsx("nav", { ref: l, className: m, "aria-label": a("breadcrumb"), style: h, children: s });
43
+ }), Z = /* @__PURE__ */ d.forwardRef(({
44
+ app: s,
45
+ name: t
46
+ }, n) => {
47
+ const {
48
+ t: l
49
+ } = g();
50
+ return /* @__PURE__ */ e.jsx(Y, { app: s, ref: n, className: "mw-100", children: /* @__PURE__ */ e.jsx(X, { className: "gap-12 mw-100", children: t ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
51
+ /* @__PURE__ */ e.jsx(C, { children: /* @__PURE__ */ e.jsx("a", { href: s == null ? void 0 : s.address, className: "d-flex", "aria-label": l(s == null ? void 0 : s.displayName), children: /* @__PURE__ */ e.jsx(R, { app: s, size: "40" }) }) }),
52
+ /* @__PURE__ */ e.jsx(C, { children: /* @__PURE__ */ e.jsx(D, { color: "var(--edifice-gray-600)", width: 20, height: 20 }) }),
53
+ /* @__PURE__ */ e.jsx(C, { className: "text-truncate", children: /* @__PURE__ */ e.jsx(_, { level: "h1", headingStyle: "h3", className: "text-truncate", children: t }) })
54
+ ] }) : /* @__PURE__ */ e.jsxs(C, { className: "gap-12 d-flex align-items-center", children: [
55
+ /* @__PURE__ */ e.jsx("a", { href: s == null ? void 0 : s.address, className: "d-flex", "aria-label": l(s == null ? void 0 : s.displayName), children: /* @__PURE__ */ e.jsx(R, { app: s, size: "40" }) }),
56
+ /* @__PURE__ */ e.jsx(_, { level: "h1", headingStyle: "h3", className: "d-none d-md-flex", children: l(s == null ? void 0 : s.displayName) })
57
+ ] }) }) });
58
+ }), ee = () => {
59
+ const s = d.useRef(null), t = d.useRef(/* @__PURE__ */ new Set()).current, [n, l] = d.useState(0), a = F(n) ?? 0;
60
+ d.useEffect(() => {
61
+ var c, o;
62
+ if (n !== a) {
63
+ const x = Array.from(t), j = (c = x[n]) == null ? void 0 : c.firstChild, E = (o = x[a]) == null ? void 0 : o.firstChild;
64
+ E == null || E.setAttribute("tabindex", "-1"), j == null || j.setAttribute("tabindex", "0"), j == null || j.focus({
65
+ preventScroll: !0
66
+ });
67
+ }
68
+ }, [n, a, t]);
69
+ const u = () => l(0), m = () => l(t.size - 1), h = () => {
70
+ const c = n === t.size - 1 ? 0 : n + 1;
71
+ l(c);
72
+ }, S = () => {
73
+ const c = n === 0 ? t.size - 1 : n - 1;
74
+ l(c);
75
+ }, f = (c) => {
76
+ switch (c.stopPropagation(), c.code) {
77
+ case "ArrowUp":
78
+ c.preventDefault(), S();
79
+ break;
80
+ case "ArrowDown":
81
+ c.preventDefault(), h();
82
+ break;
83
+ }
84
+ switch (c.code) {
85
+ case "End":
86
+ c.preventDefault(), m();
87
+ break;
88
+ case "Home":
89
+ c.preventDefault(), u();
90
+ break;
91
+ }
92
+ }, i = d.useMemo(() => ({
93
+ "data-menubar-menuitem": "",
94
+ role: "menuitem"
95
+ }), []);
96
+ return {
97
+ menuRef: s,
98
+ menuItems: t,
99
+ childProps: i,
100
+ onKeyDown: f
101
+ };
102
+ }, B = /* @__PURE__ */ d.createContext(null);
103
+ function A() {
104
+ const s = d.useContext(B);
105
+ if (!s)
106
+ throw new Error("Cannot be rendered outside the Menu component");
107
+ return s;
108
+ }
109
+ const se = (s) => {
110
+ const {
111
+ selected: t,
112
+ leftIcon: n,
113
+ rightIcon: l,
114
+ onClick: a,
115
+ children: u,
116
+ className: m,
117
+ size: h
118
+ } = s, {
119
+ childProps: S
120
+ } = A();
121
+ return /* @__PURE__ */ e.jsx(w, { variant: "ghost", color: "tertiary", className: I("stack w-100 overflow-hidden", {
122
+ selected: t,
123
+ "menu-button-lg": h === "lg"
124
+ }, m), leftIcon: n, rightIcon: l, onClick: a, ...S, style: h === "lg" ? {
125
+ height: "auto"
126
+ } : void 0, children: /* @__PURE__ */ e.jsx("div", { className: I("text-truncate w-100 text-start", {
127
+ "text-truncate-2 text-start ms-0": h === "lg"
128
+ }), style: {
129
+ overflowWrap: "break-word"
130
+ }, children: u }) });
131
+ }, te = ({
132
+ children: s
133
+ }) => {
134
+ const t = d.useRef(null), n = d.useId(), {
135
+ menuItems: l
136
+ } = A();
137
+ return d.useEffect(() => {
138
+ const a = t.current;
139
+ return a && l.add(a), () => {
140
+ a && l.delete(a);
141
+ };
142
+ }, [l]), /* @__PURE__ */ e.jsx("li", { ref: t, id: n, role: "none", "data-menubar-listitem": !0, children: s });
143
+ }, p = ({
144
+ label: s,
145
+ children: t
146
+ }) => {
147
+ const {
148
+ menuRef: n,
149
+ childProps: l,
150
+ menuItems: a,
151
+ onKeyDown: u
152
+ } = ee(), m = d.useMemo(() => ({
153
+ menuRef: n,
154
+ menuItems: a,
155
+ childProps: l
156
+ }), [l, a, n]);
157
+ return /* @__PURE__ */ e.jsx(B.Provider, { value: m, children: /* @__PURE__ */ e.jsx("nav", { "aria-label": s, className: "menu", children: /* @__PURE__ */ e.jsx("ul", { ref: n, role: "menubar", "aria-label": s, onKeyDown: u, "data-menubar-list": !0, className: "list-unstyled d-flex flex-column gap-4", children: t }) }) });
158
+ };
159
+ p.Item = te;
160
+ p.Button = se;
161
+ const k = ({
162
+ title: s,
163
+ titleId: t,
164
+ ...n
165
+ }) => /* @__PURE__ */ e.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", viewBox: "0 0 20 20", "aria-hidden": "true", "aria-labelledby": t, ...n, children: [
166
+ s ? /* @__PURE__ */ e.jsx("title", { id: t, children: s }) : null,
167
+ /* @__PURE__ */ e.jsx("path", { fill: "currentColor", d: "M14.988 1.667c.852 0 1.619.519 1.935 1.31l1.352 3.38q.008.02.013.04.006.015.01.03l.012.043.015.08.005.039.003.06.001.018v9.382a2.26 2.26 0 0 1-.693 1.625c-.44.425-1.03.659-1.64.659h-12c-.61 0-1.2-.234-1.64-.66a2.26 2.26 0 0 1-.693-1.624v-9.4l.003-.06.005-.04.015-.08.008-.03.006-.02a1 1 0 0 1 .028-.077L3.08 2.977a2.08 2.08 0 0 1 1.934-1.31zM3.334 16.049c0 .154.063.31.186.428.123.119.296.19.481.19h12a.7.7 0 0 0 .481-.19.6.6 0 0 0 .186-.428V7.5H3.334zm8.334-6.882a.833.833 0 0 1 0 1.666H8.334a.833.833 0 0 1 0-1.666zM5.014 3.333a.42.42 0 0 0-.386.263l-.896 2.237h12.539l-.896-2.237a.42.42 0 0 0-.387-.263z" })
168
+ ] }), ne = ({
169
+ title: s,
170
+ titleId: t,
171
+ ...n
172
+ }) => /* @__PURE__ */ e.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", viewBox: "0 0 24 24", "aria-hidden": "true", "aria-labelledby": t, ...n, children: [
173
+ s ? /* @__PURE__ */ e.jsx("title", { id: t, children: s }) : null,
174
+ /* @__PURE__ */ e.jsx("path", { fill: "currentColor", fillRule: "evenodd", d: "M1 12a1 1 0 0 1 1-1h6a1 1 0 0 1 .832.445L10.535 14h2.93l1.703-2.555A1 1 0 0 1 16 11h6a1 1 0 1 1 0 2h-5.465l-1.703 2.555A1 1 0 0 1 14 16h-4a1 1 0 0 1-.832-.445L7.465 13H2a1 1 0 0 1-1-1", clipRule: "evenodd" }),
175
+ /* @__PURE__ */ e.jsx("path", { fill: "currentColor", fillRule: "evenodd", d: "M12 1a1 1 0 0 1 1 1v6.201l1.312-1.243a1 1 0 1 1 1.376 1.452l-3 2.842a1 1 0 0 1-1.376 0l-3-2.842a1 1 0 1 1 1.376-1.452L11 8.201V2a1 1 0 0 1 1-1M7.24 3.842H8a1 1 0 1 1 0 2h-.76c-.196 0-.386.053-.546.147a.94.94 0 0 0-.358.37l-.002.002L3 12.669v5.436c0 .22.091.442.274.614.183.174.444.281.726.281h16c.282 0 .543-.107.727-.28a.85.85 0 0 0 .273-.615V12.67l-3.334-6.308-.002-.003a.94.94 0 0 0-.358-.37 1.1 1.1 0 0 0-.546-.146H16a1 1 0 1 1 0-2h.76c.547 0 1.087.145 1.56.422a2.94 2.94 0 0 1 1.116 1.165l3.448 6.525a1 1 0 0 1 .116.467v5.684c0 .786-.33 1.528-.898 2.066A3.06 3.06 0 0 1 20 21H4a3.06 3.06 0 0 1-2.102-.829A2.85 2.85 0 0 1 1 18.105v-5.684a1 1 0 0 1 .116-.467l3.448-6.525.001-.001a2.94 2.94 0 0 1 1.116-1.164 3.1 3.1 0 0 1 1.559-.422", clipRule: "evenodd" })
176
+ ] }), H = ({
177
+ title: s,
178
+ titleId: t,
179
+ ...n
180
+ }) => /* @__PURE__ */ e.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", viewBox: "0 0 20 20", "aria-hidden": "true", "aria-labelledby": t, ...n, children: [
181
+ s ? /* @__PURE__ */ e.jsx("title", { id: t, children: s }) : null,
182
+ /* @__PURE__ */ e.jsx("path", { fill: "currentColor", d: "M14.583 1.667c1.15 0 2.083.933 2.083 2.083v5.542q.432-.117.864-.053a2.05 2.05 0 0 1 1.369.87c.595.856.597 2.194-.462 3.041-1.04.832-2.047 1.71-3.063 2.548-.99.818-1.975 1.587-2.875 2.107-.425.245-.906.351-1.367.395-.464.044-.962.03-1.453-.002-1.037-.067-2-.202-3.013-.202-.851 0-1.428.492-1.742 1.179a.833.833 0 1 1-1.516-.693c.52-1.137 1.61-2.153 3.258-2.153 1.071 0 2.253.151 3.12.207.462.03.857.037 1.189.005.334-.032.552-.098.691-.179.768-.443 1.658-1.132 2.647-1.949.963-.795 2.039-1.728 3.083-2.563.29-.233.293-.562.135-.79a.39.39 0 0 0-.254-.173c-.078-.012-.255-.008-.528.197-1.205.904-3.4 2.484-4.368 3.362-.471.428-1.058.554-1.548.554h-2.5a.834.834 0 0 1 0-1.666h2.5c.228 0 .36-.06.428-.122a.37.37 0 0 0 .097-.183.5.5 0 0 0-.003-.268.3.3 0 0 0-.116-.164c-.053-.039-.17-.097-.406-.097-.833 0-2.184-.224-3.285-.372a18 18 0 0 0-1.534-.155 4 4 0 0 0-.508.004c-.118.012-.155.028-.143.023-.698.351-1.412.978-2.037 1.67-.622.69-1.107 1.392-1.353 1.823a.834.834 0 0 1-1.447-.827c.309-.541.866-1.34 1.563-2.112.58-.643 1.293-1.306 2.077-1.79V3.75c0-1.15.933-2.083 2.083-2.083zM6.25 3.333a.417.417 0 0 0-.416.417v6.552q.124 0 .25.005c.508.02 1.102.091 1.687.17 1.228.164 2.378.357 3.063.357.524 0 .994.135 1.374.406.271.194.47.439.607.705.728-.56 1.527-1.152 2.185-1.64V3.75a.417.417 0 0 0-.416-.417zM11.666 5a.833.833 0 0 1 0 1.667h-2.5a.834.834 0 0 1 0-1.667z" })
183
+ ] });
184
+ function le() {
185
+ const { appCode: s } = v(), { t } = g(s), n = T(), l = N(L.COLLECTION_CREATE);
186
+ return /* @__PURE__ */ e.jsxs("div", { className: "d-flex flex-fill align-items-center justify-content-end gap-12 align-self-end", children: [
187
+ /* @__PURE__ */ e.jsx(
188
+ w,
189
+ {
190
+ type: "button",
191
+ color: "primary",
192
+ variant: "outline",
193
+ leftIcon: /* @__PURE__ */ e.jsx(ne, {}),
194
+ onClick: () => {
195
+ },
196
+ children: t("collection.appHeaderAction.button.toCollection")
197
+ }
198
+ ),
199
+ l && /* @__PURE__ */ e.jsx(
200
+ w,
201
+ {
202
+ "data-testid": "collect-collection-app-header-create-collection-button",
203
+ type: "button",
204
+ color: "primary",
205
+ leftIcon: /* @__PURE__ */ e.jsx(P, {}),
206
+ onClick: () => n("/create/form"),
207
+ children: t("collection.appHeaderAction.button.newCollection")
208
+ }
209
+ )
210
+ ] });
211
+ }
212
+ const r = {
213
+ LIST_COLLECTIONS: "list-collections",
214
+ LIST_SUBMISSIONS: "list-submissions"
215
+ }, ae = W((s) => ({
216
+ mobileMenuOpen: !1,
217
+ selectedMenu: "list-collections",
218
+ setMobileMenuOpen: (t) => s({ mobileMenuOpen: t }),
219
+ setSelectedMenu: (t) => s({ selectedMenu: t })
220
+ })), z = V(ae), ce = () => {
221
+ const s = T(), { pathname: t } = O(), { appCode: n } = v(), { t: l } = g(n), a = z.use.setSelectedMenu(), u = N(L.COLLECTION_CREATE), m = [
222
+ ...u ? [
223
+ {
224
+ id: r.LIST_COLLECTIONS,
225
+ name: l("collection.collection")
226
+ }
227
+ ] : [],
228
+ {
229
+ id: r.LIST_SUBMISSIONS,
230
+ name: l("collection.submission")
231
+ }
232
+ ], h = (i) => {
233
+ switch (i) {
234
+ case r.LIST_COLLECTIONS:
235
+ return /* @__PURE__ */ e.jsx(k, {});
236
+ case r.LIST_SUBMISSIONS:
237
+ return /* @__PURE__ */ e.jsx(H, {});
238
+ default:
239
+ return null;
240
+ }
241
+ }, S = (i) => {
242
+ a(i), s(`/${i}`);
243
+ }, f = () => {
244
+ const c = {
245
+ "/": r.LIST_COLLECTIONS,
246
+ "/list-collections": r.LIST_COLLECTIONS,
247
+ "/list-submissions": r.LIST_SUBMISSIONS
248
+ }[t] || null;
249
+ return !u && c === r.LIST_COLLECTIONS ? r.LIST_SUBMISSIONS : c;
250
+ };
251
+ return /* @__PURE__ */ e.jsxs("div", { className: "border-end p-16 h-100 ps-0", children: [
252
+ /* @__PURE__ */ e.jsx("p", { className: "caption text-uppercase fw-semibold text-gray-700", children: l("collection.title") }),
253
+ /* @__PURE__ */ e.jsxs(p, { label: l("collection.title"), children: [
254
+ /* @__PURE__ */ e.jsx(p.Item, { children: /* @__PURE__ */ e.jsx("div", { className: "treeview ps-16 pt-16", children: /* @__PURE__ */ e.jsx(
255
+ $,
256
+ {
257
+ nodes: m,
258
+ selectedNodeId: f(),
259
+ showIcon: !1,
260
+ renderNode: ({ node: i }) => /* @__PURE__ */ e.jsxs("div", { className: "d-flex align-items-center gap-8", children: [
261
+ h(i.id),
262
+ /* @__PURE__ */ e.jsx("span", { children: i.name })
263
+ ] }),
264
+ onTreeItemClick: S
265
+ }
266
+ ) }) }),
267
+ /* @__PURE__ */ e.jsx(p.Item, { children: /* @__PURE__ */ e.jsx("div", { className: "separator-dashed w-100 mt-12 my-12" }) })
268
+ ] })
269
+ ] });
270
+ }, oe = () => {
271
+ const s = T(), { pathname: t } = O(), { appCode: n } = v(), { t: l } = g(n), a = N(L.COLLECTION_CREATE), { setSelectedMenu: u, setMobileMenuOpen: m } = z((o) => ({
272
+ setSelectedMenu: o.setSelectedMenu,
273
+ setMobileMenuOpen: o.setMobileMenuOpen
274
+ })), h = [
275
+ ...a ? [
276
+ {
277
+ id: "collection",
278
+ label: l("collection.collection"),
279
+ icon: /* @__PURE__ */ e.jsx(k, {}),
280
+ path: "/list-collections",
281
+ filterMenu: r.LIST_COLLECTIONS
282
+ }
283
+ ] : [],
284
+ {
285
+ id: "submission",
286
+ label: l("collection.submission"),
287
+ icon: /* @__PURE__ */ e.jsx(H, {}),
288
+ path: "/list-submissions",
289
+ filterMenu: r.LIST_SUBMISSIONS
290
+ }
291
+ ], f = (() => {
292
+ const x = {
293
+ "/": r.LIST_COLLECTIONS,
294
+ "/list-collections": r.LIST_COLLECTIONS,
295
+ "/list-submissions": r.LIST_SUBMISSIONS
296
+ }[t] || r.LIST_SUBMISSIONS;
297
+ return !a && x === r.LIST_COLLECTIONS ? r.LIST_SUBMISSIONS : x;
298
+ })(), i = h.find(
299
+ (o) => o.filterMenu === f
300
+ ), c = (o, x) => {
301
+ u(x), s(o);
302
+ };
303
+ return /* @__PURE__ */ e.jsx("div", { className: "position-relative w-100 p-16", children: /* @__PURE__ */ e.jsxs(b, { block: !0, onToggle: (o) => m(o), children: [
304
+ /* @__PURE__ */ e.jsx(
305
+ b.Trigger,
306
+ {
307
+ label: /* @__PURE__ */ e.jsxs(y, { align: "center", gap: "8", children: [
308
+ i == null ? void 0 : i.icon,
309
+ (i == null ? void 0 : i.label) || l("collection.title")
310
+ ] })
311
+ }
312
+ ),
313
+ /* @__PURE__ */ e.jsx(b.Menu, { children: h.map((o) => /* @__PURE__ */ e.jsx(
314
+ b.Item,
315
+ {
316
+ onClick: () => c(o.path, o.filterMenu),
317
+ icon: o.icon,
318
+ className: f === o.filterMenu ? "active" : "",
319
+ children: /* @__PURE__ */ e.jsx("span", { children: o.label })
320
+ },
321
+ o.id
322
+ )) })
323
+ ] }) });
324
+ }, ie = async () => null, de = () => {
325
+ const { currentApp: s } = v(), { lg: t } = q(), { pathname: n } = O(), l = N(L.COLLECTION_CREATE), a = n === "/" || n === `/${r.LIST_COLLECTIONS}`;
326
+ return l !== void 0 && !l && a ? /* @__PURE__ */ e.jsx(G, { to: `/${r.LIST_SUBMISSIONS}`, replace: !0 }) : /* @__PURE__ */ e.jsxs(y, { direction: "column", className: "flex-grow-1", children: [
327
+ /* @__PURE__ */ e.jsx(Q, { render: le, children: /* @__PURE__ */ e.jsx(Z, { app: s }) }),
328
+ /* @__PURE__ */ e.jsxs(M, { className: "flex-grow-1", children: [
329
+ /* @__PURE__ */ e.jsx(
330
+ M.Col,
331
+ {
332
+ sm: "3",
333
+ md: "3",
334
+ lg: "2",
335
+ xl: "3",
336
+ className: "d-none d-lg-block",
337
+ as: "aside",
338
+ children: /* @__PURE__ */ e.jsx(ce, {})
339
+ }
340
+ ),
341
+ /* @__PURE__ */ e.jsxs(
342
+ M.Col,
343
+ {
344
+ sm: "4",
345
+ md: "8",
346
+ lg: "6",
347
+ xl: "9",
348
+ className: `${t ? "cancel-gap" : ""}`,
349
+ children: [
350
+ !t && /* @__PURE__ */ e.jsx(oe, {}),
351
+ /* @__PURE__ */ e.jsx(d.Suspense, { fallback: /* @__PURE__ */ e.jsx(J, {}), children: /* @__PURE__ */ e.jsx(K, {}) })
352
+ ]
353
+ }
354
+ )
355
+ ] })
356
+ ] });
357
+ };
358
+ export {
359
+ de as Component,
360
+ ie as loader
361
+ };
@@ -0,0 +1,315 @@
1
+ import { j as e, k as P, l as T, o as v, C, p as D, r as m, q as E, h as I, F as w, s as B, I as b, t as A, v as F, f as R, u as f, d as S, w as M, x as k, E as O, L as $, y as G, z as Q } from "./index-Dt9ykSDF.js";
2
+ import { S as V } from "./SearchBarCollect-BAnLCwAC.js";
3
+ import { T as h, D as _ } from "./DeleteCollectionModal-Dzsn2899.js";
4
+ import { E as z } from "./emptyscreen-list-collection-CWGxO4Ss.js";
5
+ import { D as H } from "./DropdownActionTable-BLHrdk4t.js";
6
+ const W = ({
7
+ title: s,
8
+ titleId: t,
9
+ ...i
10
+ }) => /* @__PURE__ */ e.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", viewBox: "0 0 24 24", "aria-hidden": "true", "aria-labelledby": t, ...i, children: [
11
+ s ? /* @__PURE__ */ e.jsx("title", { id: t, children: s }) : null,
12
+ /* @__PURE__ */ e.jsx("path", { fill: "currentColor", fillRule: "evenodd", d: "M6.5 3a1 1 0 0 1 .713.298l4.5 4.572a1 1 0 0 1-1.426 1.403L7.5 6.44V20a1 1 0 1 1-2 0V6.441L2.713 9.273A1 1 0 0 1 1.287 7.87l4.5-4.572A1 1 0 0 1 6.5 3M17.5 3a1 1 0 0 1 1 1v13.559l2.787-2.832a1 1 0 0 1 1.426 1.403l-4.5 4.572a1 1 0 0 1-1.426 0l-4.5-4.572a1 1 0 0 1 1.426-1.403L16.5 17.56V4a1 1 0 0 1 1-1", clipRule: "evenodd" })
13
+ ] }), q = ({
14
+ title: s,
15
+ titleId: t,
16
+ ...i
17
+ }) => /* @__PURE__ */ e.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", viewBox: "0 0 24 24", "aria-hidden": "true", "aria-labelledby": t, ...i, children: [
18
+ s ? /* @__PURE__ */ e.jsx("title", { id: t, children: s }) : null,
19
+ /* @__PURE__ */ e.jsx("path", { fill: "currentColor", fillRule: "evenodd", d: "M16.129 4.012a1.5 1.5 0 0 1-.141 2.117L9.278 12l6.71 5.871a1.5 1.5 0 0 1-1.976 2.258l-8-7a1.5 1.5 0 0 1 0-2.258l8-7a1.5 1.5 0 0 1 2.117.141", clipRule: "evenodd" })
20
+ ] }), K = {
21
+ search: "",
22
+ sortBy: C.DEADLINE,
23
+ sortDirection: v.DESC
24
+ }, y = P(
25
+ T((s) => ({
26
+ ...K,
27
+ setSearch: (t) => s({ search: t }),
28
+ setFilters: (t) => s(t),
29
+ setSortCollectionList: (t, i) => s({ sortBy: t, sortDirection: i })
30
+ }))
31
+ ), U = () => {
32
+ const { search: s, sortBy: t, sortDirection: i } = y(), { data: n, fetchNextPage: d, hasNextPage: l, isFetchingNextPage: r, isLoading: g } = D({
33
+ search: s || void 0,
34
+ sortBy: t,
35
+ sortDirection: i
36
+ }), [o, a] = m.useState(1), c = m.useMemo(() => {
37
+ var j, u;
38
+ const x = (j = n == null ? void 0 : n.pages) == null ? void 0 : j[n.pages.length - 1];
39
+ return ((u = x == null ? void 0 : x.meta) == null ? void 0 : u.totalPages) ?? 1;
40
+ }, [n]), p = m.useMemo(() => {
41
+ var x;
42
+ if ((x = n == null ? void 0 : n.pages) != null && x.length)
43
+ return n.pages.find((j) => {
44
+ var u;
45
+ return ((u = j.meta) == null ? void 0 : u.currentPage) === o;
46
+ }) ?? n.pages[o - 1];
47
+ }, [n, o]);
48
+ return {
49
+ items: (p == null ? void 0 : p.items) ?? [],
50
+ page: o,
51
+ totalPages: c,
52
+ isLoading: g,
53
+ isFetchingNextPage: r,
54
+ handlePagePrevious: () => {
55
+ a((x) => Math.max(1, x - 1));
56
+ },
57
+ handlePageNext: async () => {
58
+ var u;
59
+ if (o >= c || r) return;
60
+ const x = o + 1;
61
+ !((u = n == null ? void 0 : n.pages) == null ? void 0 : u.some(
62
+ (L) => {
63
+ var N;
64
+ return ((N = L.meta) == null ? void 0 : N.currentPage) === x;
65
+ }
66
+ )) && l && await d(), a(x);
67
+ },
68
+ canGoPrevious: o > 1,
69
+ canGoNext: o < c
70
+ };
71
+ }, Y = () => {
72
+ const [s, t] = m.useState(
73
+ null
74
+ );
75
+ return {
76
+ isHovered: (l) => s === l.id,
77
+ setHoveredCollectionId: t,
78
+ getBgColor: (l) => s === l.id ? "bg-gray-300" : "",
79
+ getColorByPercentage: (l, r) => {
80
+ if (r === 0) return "danger";
81
+ const g = l / r * 100;
82
+ return g >= 0 && g < 33 ? "danger" : g >= 33 && g < 66 ? "warning" : g >= 66 && g <= 100 ? "success" : "warning";
83
+ }
84
+ };
85
+ }, Z = ({
86
+ collections: s
87
+ }) => {
88
+ const { fromNow: t, formatDate: i } = E(), n = I(), {
89
+ isHovered: d,
90
+ setHoveredCollectionId: l,
91
+ getBgColor: r,
92
+ getColorByPercentage: g
93
+ } = Y();
94
+ return /* @__PURE__ */ e.jsx(e.Fragment, { children: s.map((o, a) => {
95
+ const c = r(o);
96
+ return /* @__PURE__ */ e.jsxs(
97
+ h.Tr,
98
+ {
99
+ "data-testid": "collect-collection-list-row",
100
+ onMouseEnter: () => l(o.id),
101
+ onMouseLeave: () => l(null),
102
+ children: [
103
+ /* @__PURE__ */ e.jsx(h.Td, { className: c, style: { maxWidth: "350px" }, children: /* @__PURE__ */ e.jsx(w, { align: "center", gap: "8", children: /* @__PURE__ */ e.jsx(
104
+ "span",
105
+ {
106
+ className: "fw-bold text-truncate c-pointer",
107
+ "data-testid": "collect-collection-list-row-name",
108
+ onClick: () => {
109
+ n(`/list-collections/id/${o.id}`);
110
+ },
111
+ children: o.name
112
+ }
113
+ ) }) }),
114
+ /* @__PURE__ */ e.jsx(h.Td, { className: c, children: /* @__PURE__ */ e.jsx("em", { className: "text-gray-700", children: t(o.createdAt) }) }),
115
+ /* @__PURE__ */ e.jsx(h.Td, { className: c, children: i(o.deadline, "short") }),
116
+ /* @__PURE__ */ e.jsx(h.Td, { className: c, children: /* @__PURE__ */ e.jsxs(
117
+ B,
118
+ {
119
+ variant: {
120
+ type: "notification",
121
+ level: g(
122
+ o.contribCount,
123
+ o.submissionCount
124
+ )
125
+ },
126
+ className: "fw-normal",
127
+ children: [
128
+ o.contribCount,
129
+ " / ",
130
+ o.submissionCount
131
+ ]
132
+ }
133
+ ) }),
134
+ /* @__PURE__ */ e.jsx(h.Td, { className: c, children: /* @__PURE__ */ e.jsx(H, { collectionId: o.id, children: (p) => /* @__PURE__ */ e.jsx(
135
+ b,
136
+ {
137
+ ...p,
138
+ "data-testid": "collect-collection-list-row-actions",
139
+ className: "icon-button-hover-no-transition bg-white",
140
+ type: "button",
141
+ "aria-label": F("collection.table.th.action"),
142
+ color: "tertiary",
143
+ variant: "filled",
144
+ icon: /* @__PURE__ */ e.jsx(A, {}),
145
+ style: {
146
+ visibility: d(o) ? "visible" : "hidden"
147
+ }
148
+ }
149
+ ) }) })
150
+ ]
151
+ },
152
+ `${o == null ? void 0 : o.id}-${a}`
153
+ );
154
+ }) });
155
+ }, J = ({
156
+ page: s,
157
+ totalPages: t,
158
+ canGoPrevious: i,
159
+ canGoNext: n,
160
+ isLoading: d = !1,
161
+ isFetchingNextPage: l = !1,
162
+ onPagePrevious: r,
163
+ onPageNext: g
164
+ }) => /* @__PURE__ */ e.jsxs(w, { justify: "center", align: "center", gap: "8", children: [
165
+ /* @__PURE__ */ e.jsx(
166
+ b,
167
+ {
168
+ variant: "ghost",
169
+ color: "tertiary",
170
+ icon: /* @__PURE__ */ e.jsx(q, {}),
171
+ disabled: !i || d,
172
+ onClick: r
173
+ }
174
+ ),
175
+ /* @__PURE__ */ e.jsxs("span", { "aria-label": `Page ${s} of ${t}`, children: [
176
+ s,
177
+ " / ",
178
+ t
179
+ ] }),
180
+ /* @__PURE__ */ e.jsx(
181
+ b,
182
+ {
183
+ variant: "ghost",
184
+ color: "tertiary",
185
+ icon: /* @__PURE__ */ e.jsx(R, {}),
186
+ disabled: !n || d || l,
187
+ onClick: g
188
+ }
189
+ )
190
+ ] }), X = () => {
191
+ const { appCode: s } = f(), { t } = S(s), { sortBy: i, sortDirection: n, setSortCollectionList: d } = y((a) => ({
192
+ sortBy: a.sortBy,
193
+ sortDirection: a.sortDirection,
194
+ setSortCollectionList: a.setSortCollectionList
195
+ })), l = [
196
+ {
197
+ label: t("collection.table.th.collect"),
198
+ sortField: C.NAME
199
+ },
200
+ {
201
+ label: t("collection.table.th.date"),
202
+ sortField: C.CREATION_DATE
203
+ },
204
+ {
205
+ label: t("collection.table.th.deadline"),
206
+ sortField: C.DEADLINE
207
+ },
208
+ {
209
+ label: t("collection.table.th.render")
210
+ // FIXME: No sort field for render, we should add one in the backend
211
+ },
212
+ {
213
+ label: t("collection.table.th.action")
214
+ }
215
+ ], r = (a) => a.sortField && a.sortField === i, g = (a) => {
216
+ let c = /* @__PURE__ */ e.jsx(W, { width: 16, height: 16 });
217
+ return r(a) && (n === v.ASC ? c = /* @__PURE__ */ e.jsx(M, {}) : c = /* @__PURE__ */ e.jsx(k, {})), c;
218
+ }, o = m.useCallback(
219
+ (a) => {
220
+ let c = v.ASC;
221
+ i === a && n === v.ASC && (c = v.DESC), d(a, c);
222
+ },
223
+ [i, n, d]
224
+ );
225
+ return {
226
+ listHeads: l,
227
+ getSortIcon: g,
228
+ handleSort: o,
229
+ isSortActive: r
230
+ };
231
+ }, ee = () => {
232
+ const { listHeads: s, getSortIcon: t, handleSort: i, isSortActive: n } = X(), { appCode: d } = f(), { t: l } = S(d);
233
+ return s.map((r) => /* @__PURE__ */ e.jsxs(
234
+ h.Th,
235
+ {
236
+ className: r.sortField ? void 0 : "align-content-center text-center",
237
+ children: [
238
+ l(r.label),
239
+ r.sortField && /* @__PURE__ */ e.jsx(
240
+ b,
241
+ {
242
+ variant: "ghost",
243
+ color: "tertiary",
244
+ size: "sm",
245
+ className: `members-table-sort-btn ms-4 ${n(r) ? "text-gray-800" : "text-gray-600"}`,
246
+ icon: t(r),
247
+ onClick: () => i(r.sortField)
248
+ }
249
+ )
250
+ ]
251
+ },
252
+ r.label
253
+ ));
254
+ }, te = () => {
255
+ const { appCode: s } = f(), { t } = S(s), {
256
+ items: i,
257
+ page: n,
258
+ totalPages: d,
259
+ isLoading: l,
260
+ isFetchingNextPage: r,
261
+ handlePagePrevious: g,
262
+ handlePageNext: o,
263
+ canGoPrevious: a,
264
+ canGoNext: c
265
+ } = U();
266
+ return i.length === 0 && !l ? /* @__PURE__ */ e.jsx("div", { className: "py-24", children: /* @__PURE__ */ e.jsx(
267
+ O,
268
+ {
269
+ imageSrc: z,
270
+ title: t("collection.collectionList.emptyScreen.title"),
271
+ text: t("collection.collectionList.emptyScreen.description")
272
+ }
273
+ ) }) : /* @__PURE__ */ e.jsxs(
274
+ "div",
275
+ {
276
+ className: "table-collections",
277
+ "data-testid": "collect-collection-list-table",
278
+ children: [
279
+ /* @__PURE__ */ e.jsxs(h, { children: [
280
+ /* @__PURE__ */ e.jsx(h.Thead, { children: /* @__PURE__ */ e.jsx(h.Tr, { children: /* @__PURE__ */ e.jsx(ee, {}) }) }),
281
+ /* @__PURE__ */ e.jsxs(h.Tbody, { children: [
282
+ l && /* @__PURE__ */ e.jsx(h.Tr, { children: /* @__PURE__ */ e.jsx("td", { colSpan: 5, children: /* @__PURE__ */ e.jsx($, {}) }) }),
283
+ /* @__PURE__ */ e.jsx(Z, { collections: i }),
284
+ d !== void 0 && d >= 1 && /* @__PURE__ */ e.jsx(h.Tr, { children: /* @__PURE__ */ e.jsx("td", { colSpan: 5, children: /* @__PURE__ */ e.jsx(
285
+ J,
286
+ {
287
+ page: n,
288
+ totalPages: d,
289
+ canGoPrevious: a,
290
+ canGoNext: c,
291
+ isLoading: l,
292
+ isFetchingNextPage: r,
293
+ onPagePrevious: g,
294
+ onPageNext: o
295
+ }
296
+ ) }) })
297
+ ] })
298
+ ] }),
299
+ /* @__PURE__ */ e.jsx(_, {})
300
+ ]
301
+ }
302
+ );
303
+ }, de = async (s) => (await s.prefetchInfiniteQuery(Q({})), null), ge = () => {
304
+ const s = y((t) => t.setSearch);
305
+ return m.useEffect(() => {
306
+ localStorage.removeItem(G);
307
+ }, []), /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
308
+ /* @__PURE__ */ e.jsx("div", { className: "bg-gray-200 px-24 py-16", children: /* @__PURE__ */ e.jsx(V, { setSearch: s }) }),
309
+ /* @__PURE__ */ e.jsx(te, {})
310
+ ] });
311
+ };
312
+ export {
313
+ ge as CollectionsList,
314
+ de as loader
315
+ };