@instructure/platform-modules 1.13.0 → 1.14.0

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.
Files changed (47) hide show
  1. package/dist/adapters/canvasGraphql/index.d.ts.map +1 -1
  2. package/dist/adapters/canvasGraphql/queries.d.ts +13 -1
  3. package/dist/adapters/canvasGraphql/queries.d.ts.map +1 -1
  4. package/dist/chunks/ModulesProgressBar-B4fXbi-4.js +2516 -0
  5. package/dist/components/FilterSelect.d.ts.map +1 -1
  6. package/dist/components/ModuleCard.d.ts.map +1 -1
  7. package/dist/components/ModuleItemRow.d.ts +3 -4
  8. package/dist/components/ModuleItemRow.d.ts.map +1 -1
  9. package/dist/components/ModulesProgressBar.d.ts +5 -1
  10. package/dist/components/ModulesProgressBar.d.ts.map +1 -1
  11. package/dist/edit/EditModuleCard.d.ts +17 -0
  12. package/dist/edit/EditModuleCard.d.ts.map +1 -0
  13. package/dist/edit/EditModuleItemRow.d.ts +9 -0
  14. package/dist/edit/EditModuleItemRow.d.ts.map +1 -0
  15. package/dist/edit/ModulesEditActions.d.ts +7 -0
  16. package/dist/edit/ModulesEditActions.d.ts.map +1 -0
  17. package/dist/edit/ModulesEditView.d.ts +10 -0
  18. package/dist/edit/ModulesEditView.d.ts.map +1 -0
  19. package/dist/edit/ModulesEditView.stories.d.ts +16 -0
  20. package/dist/edit/ModulesEditView.stories.d.ts.map +1 -0
  21. package/dist/edit/controls/AddItemMenu.d.ts +6 -0
  22. package/dist/edit/controls/AddItemMenu.d.ts.map +1 -0
  23. package/dist/edit/controls/AddModuleButton.d.ts +6 -0
  24. package/dist/edit/controls/AddModuleButton.d.ts.map +1 -0
  25. package/dist/edit/controls/InlineRename.d.ts +5 -0
  26. package/dist/edit/controls/InlineRename.d.ts.map +1 -0
  27. package/dist/edit/controls/ItemActionsMenu.d.ts +7 -0
  28. package/dist/edit/controls/ItemActionsMenu.d.ts.map +1 -0
  29. package/dist/edit/controls/ItemPublishToggle.d.ts +6 -0
  30. package/dist/edit/controls/ItemPublishToggle.d.ts.map +1 -0
  31. package/dist/edit/controls/ModuleActionsMenu.d.ts +6 -0
  32. package/dist/edit/controls/ModuleActionsMenu.d.ts.map +1 -0
  33. package/dist/edit/controls/ModulePublishMenu.d.ts +6 -0
  34. package/dist/edit/controls/ModulePublishMenu.d.ts.map +1 -0
  35. package/dist/edit/controls/ModuleSettingsModal.d.ts +6 -0
  36. package/dist/edit/controls/ModuleSettingsModal.d.ts.map +1 -0
  37. package/dist/edit/controls/PublishAllMenu.d.ts +6 -0
  38. package/dist/edit/controls/PublishAllMenu.d.ts.map +1 -0
  39. package/dist/edit/controls/ViewAsLearnerButton.d.ts +6 -0
  40. package/dist/edit/controls/ViewAsLearnerButton.d.ts.map +1 -0
  41. package/dist/edit/index.d.ts +4 -0
  42. package/dist/edit/index.d.ts.map +1 -1
  43. package/dist/edit.js +509 -128
  44. package/dist/index.js +1218 -1986
  45. package/locales/en.json +12 -1
  46. package/package.json +1 -1
  47. package/dist/chunks/useModulesPageData-BFCZuChP.js +0 -1639
package/dist/edit.js CHANGED
@@ -1,110 +1,125 @@
1
- import { C as P, X as w, D as C, u as E, ae as A, i as q, c as B } from "./chunks/useModulesPageData-BFCZuChP.js";
2
- import { useQueryClient as S, useMutation as $ } from "@tanstack/react-query";
3
- import { useMemo as j } from "react";
4
- const b = (o) => o.map((a, r) => ({ ...a, position: r + 1 })), f = (o, a, r) => {
5
- const l = r === void 0 ? o.length : Math.min(Math.max(r - 1, 0), o.length);
6
- return [...o.slice(0, l), a, ...o.slice(l)];
7
- }, v = (o, a) => {
8
- const r = new Map(a.map((l, u) => [l, u]));
9
- return [...o].sort((l, u) => (r.get(l.id) ?? a.length) - (r.get(u.id) ?? a.length));
1
+ import { P as X, a7 as Y, Q as J, k as N, aw as K, i as Z, c as ee, u as w, q as D, y as O, v as te, an as ne, ak as ie, aH as E, A as oe, B as $, n as z, aI as le, aJ as re, z as se, p as ae } from "./chunks/ModulesProgressBar-B4fXbi-4.js";
2
+ import { useQueryClient as de, useMutation as ue } from "@tanstack/react-query";
3
+ import { useMemo as j, Fragment as U, useState as ce } from "react";
4
+ import { jsx as t, jsxs as f, Fragment as W } from "react/jsx-runtime";
5
+ import { TruncateWithTooltip as me, getLiveRegion as H, politeAnnounce as pe } from "@instructure/platform-instui-bindings";
6
+ import { Alert as x } from "@instructure/ui-alerts/v11_7";
7
+ import { Heading as G } from "@instructure/ui-heading/v11_7";
8
+ import { Pagination as V } from "@instructure/ui-pagination/v11_7";
9
+ import { Spinner as Q } from "@instructure/ui-spinner/v11_7";
10
+ import { Text as L } from "@instructure/ui-text/v11_7";
11
+ import { View as y } from "@instructure/ui-view/v11_7";
12
+ import { ScreenReaderContent as ge } from "@instructure/ui-a11y-content";
13
+ import { IconButton as he, Button as Me } from "@instructure/ui-buttons/v11_7";
14
+ import { Flex as b } from "@instructure/ui-flex/v11_7";
15
+ import { CornerDownRightInstUIIcon as Ie, IconArrowOpenUpLine as fe, IconArrowOpenDownLine as ve, LayersInstUIIcon as be, ListChecksInstUIIcon as ye, ClockInstUIIcon as Pe, LockInstUIIcon as Ae } from "@instructure/ui-icons";
16
+ import { List as Le, ListItem as ke } from "@instructure/ui-list/v11_7";
17
+ import { Pill as we } from "@instructure/ui-pill/v11_7";
18
+ import { Link as Ce } from "@instructure/ui-link/v11_7";
19
+ const k = (e) => e.map((o, l) => ({ ...o, position: l + 1 })), B = (e, o, l) => {
20
+ const r = l === void 0 ? e.length : Math.min(Math.max(l - 1, 0), e.length);
21
+ return [...e.slice(0, r), o, ...e.slice(r)];
22
+ }, S = (e, o) => {
23
+ const l = new Map(o.map((r, s) => [r, s]));
24
+ return [...e].sort((r, s) => (l.get(r.id) ?? o.length) - (l.get(s.id) ?? o.length));
10
25
  };
11
- function k(o, a = {}) {
12
- const r = (t) => {
13
- if (t !== o.courseId)
14
- throw new w(o.courseId, t);
15
- }, l = (t) => {
16
- const e = o.modules.findIndex((s) => s.id === t);
17
- if (e === -1) throw new Error(`in-memory adapter has no module ${t}`);
18
- return e;
19
- }, u = (t) => o.itemsByModuleId[t] ?? [], M = (t, e) => {
20
- o.itemsByModuleId[t] = b(e.map((s) => ({ ...s, moduleId: t })));
21
- }, m = (t) => String(t.reduce((e, s) => Math.max(e, Number(s) || 0), 0) + 1);
26
+ function at(e, o = {}) {
27
+ const l = (n) => {
28
+ if (n !== e.courseId)
29
+ throw new Y(e.courseId, n);
30
+ }, r = (n) => {
31
+ const i = e.modules.findIndex((a) => a.id === n);
32
+ if (i === -1) throw new Error(`in-memory adapter has no module ${n}`);
33
+ return i;
34
+ }, s = (n) => e.itemsByModuleId[n] ?? [], u = (n, i) => {
35
+ e.itemsByModuleId[n] = k(i.map((a) => ({ ...a, moduleId: n })));
36
+ }, c = (n) => String(n.reduce((i, a) => Math.max(i, Number(a) || 0), 0) + 1);
22
37
  return {
23
- ...P(o, a),
24
- async createModule({ courseId: t, name: e, position: s }) {
25
- r(t);
26
- const i = {
27
- id: m(o.modules.map((d) => d.id)),
28
- name: e,
38
+ ...X(e, o),
39
+ async createModule({ courseId: n, name: i, position: a }) {
40
+ l(n);
41
+ const p = {
42
+ id: c(e.modules.map((d) => d.id)),
43
+ name: i,
29
44
  position: 0,
30
45
  published: !1,
31
46
  itemCount: 0,
32
47
  prerequisiteModules: [],
33
48
  requireSequentialProgress: !1
34
49
  };
35
- return o.modules = b(f(o.modules, i, s)), o.itemsByModuleId[i.id] = [], o.modules[l(i.id)];
50
+ return e.modules = k(B(e.modules, p, a)), e.itemsByModuleId[p.id] = [], e.modules[r(p.id)];
36
51
  },
37
- async updateModule({ courseId: t, moduleId: e, patch: s }) {
38
- r(t);
39
- const { prerequisiteModuleIds: i, position: d, ...n } = s, p = o.modules[l(e)], h = { ...p, ...n };
40
- i && (h.prerequisiteModules = i.map((c) => ({
41
- id: c,
42
- name: o.modules[l(c)].name
52
+ async updateModule({ courseId: n, moduleId: i, patch: a }) {
53
+ l(n);
54
+ const { prerequisiteModuleIds: p, position: d, ...m } = a, h = e.modules[r(i)], M = { ...h, ...m };
55
+ p && (M.prerequisiteModules = p.map((I) => ({
56
+ id: I,
57
+ name: e.modules[r(I)].name
43
58
  })));
44
- const g = o.modules.filter((c) => c.id !== e);
45
- return o.modules = b(f(g, h, d ?? p.position)), o.modules[l(e)];
59
+ const P = e.modules.filter((I) => I.id !== i);
60
+ return e.modules = k(B(P, M, d ?? h.position)), e.modules[r(i)];
46
61
  },
47
- async deleteModule({ courseId: t, moduleId: e }) {
48
- r(t), l(e), o.modules = b(o.modules.filter((s) => s.id !== e)), delete o.itemsByModuleId[e];
62
+ async deleteModule({ courseId: n, moduleId: i }) {
63
+ l(n), r(i), e.modules = k(e.modules.filter((a) => a.id !== i)), delete e.itemsByModuleId[i];
49
64
  },
50
- async reorderModules({ courseId: t, moduleIds: e }) {
51
- r(t), o.modules = b(v(o.modules, e));
65
+ async reorderModules({ courseId: n, moduleIds: i }) {
66
+ l(n), e.modules = k(S(e.modules, i));
52
67
  },
53
- async setModulesPublished({ courseId: t, moduleIds: e, published: s, includeItems: i }) {
54
- r(t);
68
+ async setModulesPublished({ courseId: n, moduleIds: i, published: a, includeItems: p }) {
69
+ l(n);
55
70
  const d = new Set(
56
- e === "all" ? o.modules.map((n) => n.id) : e
71
+ i === "all" ? e.modules.map((m) => m.id) : i
57
72
  );
58
- if (o.modules = o.modules.map(
59
- (n) => d.has(n.id) ? { ...n, published: s } : n
60
- ), !!i)
61
- for (const n of d)
62
- M(
63
- n,
64
- u(n).map((p) => ({ ...p, published: s }))
73
+ if (e.modules = e.modules.map(
74
+ (m) => d.has(m.id) ? { ...m, published: a } : m
75
+ ), !!p)
76
+ for (const m of d)
77
+ u(
78
+ m,
79
+ s(m).map((h) => ({ ...h, published: a }))
65
80
  );
66
81
  },
67
- async createModuleItem({ courseId: t, moduleId: e, type: s, title: i, position: d, indent: n = 0, extensions: p }) {
68
- r(t), l(e);
69
- const h = Object.values(o.itemsByModuleId).flatMap(
70
- (c) => c.map((y) => y.id)
71
- ), g = {
72
- id: m(h),
73
- moduleId: e,
74
- title: i,
75
- type: s,
82
+ async createModuleItem({ courseId: n, moduleId: i, type: a, title: p, position: d, indent: m = 0, extensions: h }) {
83
+ l(n), r(i);
84
+ const M = Object.values(e.itemsByModuleId).flatMap(
85
+ (I) => I.map((v) => v.id)
86
+ ), P = {
87
+ id: c(M),
88
+ moduleId: i,
89
+ title: p,
90
+ type: a,
76
91
  position: 0,
77
- indent: n,
92
+ indent: m,
78
93
  published: !1,
79
- ...p ? { extensions: p } : {}
94
+ ...h ? { extensions: h } : {}
80
95
  };
81
- return M(e, f(u(e), g, d)), u(e).find((c) => c.id === g.id);
96
+ return u(i, B(s(i), P, d)), s(i).find((I) => I.id === P.id);
82
97
  },
83
- async updateModuleItem({ courseId: t, moduleId: e, itemId: s, patch: i }) {
84
- r(t);
85
- const { moduleId: d = e, position: n, ...p } = i;
86
- l(d);
87
- const h = u(e).find((y) => y.id === s);
88
- if (!h) throw new Error(`in-memory adapter has no item ${s} in module ${e}`);
89
- M(
90
- e,
91
- u(e).filter((y) => y.id !== s)
98
+ async updateModuleItem({ courseId: n, moduleId: i, itemId: a, patch: p }) {
99
+ l(n);
100
+ const { moduleId: d = i, position: m, ...h } = p;
101
+ r(d);
102
+ const M = s(i).find((v) => v.id === a);
103
+ if (!M) throw new Error(`in-memory adapter has no item ${a} in module ${i}`);
104
+ u(
105
+ i,
106
+ s(i).filter((v) => v.id !== a)
92
107
  );
93
- const c = n ?? (d !== e ? void 0 : h.position);
94
- return M(d, f(u(d), { ...h, ...p }, c)), u(d).find((y) => y.id === s);
108
+ const I = m ?? (d !== i ? void 0 : M.position);
109
+ return u(d, B(s(d), { ...M, ...h }, I)), s(d).find((v) => v.id === a);
95
110
  },
96
- async deleteModuleItem({ courseId: t, moduleId: e, itemId: s }) {
97
- r(t), M(
98
- e,
99
- u(e).filter((i) => i.id !== s)
111
+ async deleteModuleItem({ courseId: n, moduleId: i, itemId: a }) {
112
+ l(n), u(
113
+ i,
114
+ s(i).filter((p) => p.id !== a)
100
115
  );
101
116
  },
102
- async reorderModuleItems({ courseId: t, moduleId: e, itemIds: s }) {
103
- r(t), M(e, v(u(e), s));
117
+ async reorderModuleItems({ courseId: n, moduleId: i, itemIds: a }) {
118
+ l(n), u(i, S(s(i), a));
104
119
  }
105
120
  };
106
121
  }
107
- const D = [
122
+ const Te = [
108
123
  "createModule",
109
124
  "updateModule",
110
125
  "deleteModule",
@@ -115,75 +130,441 @@ const D = [
115
130
  "deleteModuleItem",
116
131
  "reorderModuleItems"
117
132
  ];
118
- function I(o, a, r, l, u) {
119
- return $({
120
- mutationFn: (M) => !a[o] || !l ? Promise.reject(new Error(`${o} is not available to this editor`)) : l({ ...M, courseId: r }),
133
+ function A(e, o, l, r, s) {
134
+ return ue({
135
+ mutationFn: (u) => !o[e] || !r ? Promise.reject(new Error(`${e} is not available to this editor`)) : r({ ...u, courseId: l }),
121
136
  // Settled, not success: a bulk write that fails partway has still committed part of itself.
122
- onSettled: (M, m, t) => u(t)
137
+ onSettled: (u, c, n) => s(n)
123
138
  });
124
139
  }
125
- function F(o) {
126
- const { adapter: a, courseId: r } = o, l = C({ ...o, view: "teacher" }), u = S(), { permissions: M } = E(), m = j(
140
+ function dt(e) {
141
+ const { adapter: o, courseId: l } = e, r = J({ ...e, view: "teacher" }), s = de(), { permissions: u } = N(), c = j(
127
142
  () => Object.fromEntries(
128
- D.map((d) => [
143
+ Te.map((d) => [
129
144
  d,
130
- typeof a[d] == "function" && M[d] !== !1
145
+ typeof o[d] == "function" && u[d] !== !1
131
146
  ])
132
147
  ),
133
- [a, M]
134
- ), t = () => q(u, r), e = (...d) => Promise.all([
135
- t(),
136
- ...d.map((n) => B(u, r, n))
137
- ]), s = (d) => {
138
- var n;
139
- return (n = a[d]) == null ? void 0 : n.bind(a);
140
- }, i = {
141
- createModule: I("createModule", m, r, s("createModule"), t),
142
- updateModule: I("updateModule", m, r, s("updateModule"), t),
143
- deleteModule: I("deleteModule", m, r, s("deleteModule"), t),
144
- reorderModules: I("reorderModules", m, r, s("reorderModules"), t),
145
- setModulesPublished: I(
148
+ [o, u]
149
+ ), n = () => Z(s, l), i = (...d) => Promise.all([
150
+ n(),
151
+ ...d.map((m) => ee(s, l, m))
152
+ ]), a = (d) => {
153
+ var m;
154
+ return (m = o[d]) == null ? void 0 : m.bind(o);
155
+ }, p = {
156
+ createModule: A("createModule", c, l, a("createModule"), n),
157
+ updateModule: A("updateModule", c, l, a("updateModule"), n),
158
+ deleteModule: A("deleteModule", c, l, a("deleteModule"), n),
159
+ reorderModules: A("reorderModules", c, l, a("reorderModules"), n),
160
+ setModulesPublished: A(
146
161
  "setModulesPublished",
147
- m,
148
- r,
149
- s("setModulesPublished"),
150
- ({ includeItems: d }) => d ? A(u, r) : t()
162
+ c,
163
+ l,
164
+ a("setModulesPublished"),
165
+ ({ includeItems: d }) => d ? K(s, l) : n()
151
166
  ),
152
- createModuleItem: I(
167
+ createModuleItem: A(
153
168
  "createModuleItem",
154
- m,
155
- r,
156
- s("createModuleItem"),
157
- ({ moduleId: d }) => e(d)
169
+ c,
170
+ l,
171
+ a("createModuleItem"),
172
+ ({ moduleId: d }) => i(d)
158
173
  ),
159
- updateModuleItem: I(
174
+ updateModuleItem: A(
160
175
  "updateModuleItem",
161
- m,
162
- r,
163
- s("updateModuleItem"),
164
- ({ moduleId: d, patch: n }) => e(
176
+ c,
177
+ l,
178
+ a("updateModuleItem"),
179
+ ({ moduleId: d, patch: m }) => i(
165
180
  d,
166
- ...n.moduleId && n.moduleId !== d ? [n.moduleId] : []
181
+ ...m.moduleId && m.moduleId !== d ? [m.moduleId] : []
167
182
  )
168
183
  ),
169
- deleteModuleItem: I(
184
+ deleteModuleItem: A(
170
185
  "deleteModuleItem",
171
- m,
172
- r,
173
- s("deleteModuleItem"),
174
- ({ moduleId: d }) => e(d)
186
+ c,
187
+ l,
188
+ a("deleteModuleItem"),
189
+ ({ moduleId: d }) => i(d)
175
190
  ),
176
- reorderModuleItems: I(
191
+ reorderModuleItems: A(
177
192
  "reorderModuleItems",
178
- m,
179
- r,
180
- s("reorderModuleItems"),
181
- ({ moduleId: d }) => e(d)
193
+ c,
194
+ l,
195
+ a("reorderModuleItems"),
196
+ ({ moduleId: d }) => i(d)
182
197
  )
183
198
  };
184
- return { ...l, can: m, mutations: i };
199
+ return { ...r, can: c, mutations: p };
200
+ }
201
+ function Be(e) {
202
+ return null;
203
+ }
204
+ function q(e) {
205
+ return null;
206
+ }
207
+ function Re(e) {
208
+ return null;
209
+ }
210
+ function Ee(e) {
211
+ return null;
212
+ }
213
+ function qe(e) {
214
+ return null;
215
+ }
216
+ function Fe(e) {
217
+ return null;
218
+ }
219
+ function Se(e) {
220
+ return null;
221
+ }
222
+ function _e({ item: e, module: o, today: l }) {
223
+ var C, T;
224
+ const { t: r, locale: s, timezone: u } = w(), c = D(), n = N(), i = O(), a = j(() => te(n.itemMeta), [n.itemMeta]), p = e.title || r("itemUntitled"), d = /* @__PURE__ */ f(W, { children: [
225
+ /* @__PURE__ */ t(Fe, { module: o, item: e }),
226
+ /* @__PURE__ */ t(Se, { item: e })
227
+ ] });
228
+ if (e.type === "sub_header")
229
+ return /* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(
230
+ y,
231
+ {
232
+ as: "div",
233
+ padding: "x-small small",
234
+ borderWidth: "small 0 0 0",
235
+ "data-testid": `edit-item-${e.id}`,
236
+ children: /* @__PURE__ */ f(b, { alignItems: "center", gap: "small", children: [
237
+ /* @__PURE__ */ f(b.Item, { shouldGrow: !0, shouldShrink: !0, children: [
238
+ /* @__PURE__ */ t(L, { weight: "bold", "data-testid": "edit-item-title", children: p }),
239
+ /* @__PURE__ */ t(q, { name: p })
240
+ ] }),
241
+ d
242
+ ] })
243
+ }
244
+ ) });
245
+ const m = ne(n.itemTypes, e.type), h = m != null && m.renderIcon ? m.renderIcon({ item: e }) : m == null ? void 0 : m.icon, M = ((T = (C = n.navigation).getItemEditHref) == null ? void 0 : T.call(C, e)) ?? null, P = { item: e, t: r, today: l, locale: s, timezone: u, formatters: c, config: n }, I = a.map((g) => ({
246
+ key: g.key,
247
+ node: g.render(P),
248
+ icon: g.key === ie ? null : g.renderIcon ? g.renderIcon(P) : g.icon
249
+ })).filter((g) => !E(g.node)), v = /* @__PURE__ */ t(L, { weight: "bold", "data-testid": "edit-item-title", children: p });
250
+ return /* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(y, { as: "div", padding: "small", borderWidth: "small 0 0 0", "data-testid": `edit-item-${e.id}`, children: /* @__PURE__ */ t("div", { style: { paddingInlineStart: `${Math.max(e.indent - 1, 0) * le}rem` }, children: /* @__PURE__ */ f(b, { alignItems: "center", gap: "small", children: [
251
+ e.indent > 0 ? /* @__PURE__ */ t(b.Item, { "data-testid": "edit-item-nest-arrow", children: /* @__PURE__ */ t(Ie, { size: "md", color: "mutedColor" }) }) : null,
252
+ E(h) ? null : /* @__PURE__ */ t(b.Item, { "aria-hidden": "true", children: h }),
253
+ /* @__PURE__ */ f(b.Item, { shouldGrow: !0, shouldShrink: !0, children: [
254
+ M ? /* @__PURE__ */ t(Ce, { href: M, forceButtonRole: !1, "data-testid": "edit-item-link", children: v }) : v,
255
+ /* @__PURE__ */ t(q, { name: p }),
256
+ I.length > 0 ? /* @__PURE__ */ t("div", { style: oe, children: /* @__PURE__ */ t(
257
+ L,
258
+ {
259
+ size: "small",
260
+ lineHeight: "default",
261
+ color: "secondary",
262
+ "data-testid": "edit-item-meta",
263
+ children: I.map((g, F) => /* @__PURE__ */ f(U, { children: [
264
+ F > 0 ? /* @__PURE__ */ t("span", { style: $, children: " " }) : null,
265
+ /* @__PURE__ */ f("span", { style: F > 0 ? i : void 0, children: [
266
+ E(g.icon) ? null : /* @__PURE__ */ t("span", { style: z, "aria-hidden": "true", children: g.icon }),
267
+ g.node
268
+ ] })
269
+ ] }, g.key))
270
+ }
271
+ ) }) : null
272
+ ] }),
273
+ /* @__PURE__ */ t(b.Item, { children: /* @__PURE__ */ t(we, { "data-testid": "edit-item-requirement", children: e.completionRequirement ? r("itemRequiredTag") : r("itemOptionalTag") }) }),
274
+ d
275
+ ] }) }) }) });
276
+ }
277
+ const Ne = re("grey"), _ = (e) => `platform-modules-edit-panel-${e}`, R = { size: "sm", color: "onColor" };
278
+ function De(e, o, l, r) {
279
+ const s = [
280
+ {
281
+ key: "items",
282
+ icon: /* @__PURE__ */ t(be, { ...R }),
283
+ text: l("moduleItemCount", { count: e.itemCount })
284
+ }
285
+ ], u = [];
286
+ e.unlockAt && new Date(e.unlockAt) > o && u.push(r.unlockByline(e.unlockAt, o));
287
+ const c = e.prerequisiteModules.map((i) => i.name.trim()).filter(Boolean);
288
+ c.length === 1 ? u.push(l("lockedByPrerequisiteByline", { name: c[0] })) : c.length > 1 && u.push(
289
+ l("lockedByPrerequisitesByline", {
290
+ count: c.length,
291
+ prerequisites: c.join(", ")
292
+ })
293
+ ), u.length > 0 && s.push({ key: "lock", icon: /* @__PURE__ */ t(Ae, { ...R }), text: u.join(" ") }), e.completionRequirements && e.completionRequirements.length > 0 && s.push({
294
+ key: "requirement",
295
+ icon: /* @__PURE__ */ t(ye, { ...R }),
296
+ text: e.requireSequentialProgress ? l("moduleRequirementAllInOrder") : e.requirementCount === 1 ? l("moduleRequirementOne") : l("moduleRequirementAll")
297
+ });
298
+ const n = se(e.items);
299
+ return n !== null && s.push({
300
+ key: "duration",
301
+ icon: /* @__PURE__ */ t(Pe, { ...R }),
302
+ text: r.estimatedDurationByline(n)
303
+ }), s;
304
+ }
305
+ function Oe({
306
+ module: e,
307
+ state: o,
308
+ today: l
309
+ }) {
310
+ const { t: r } = w();
311
+ if (o.error)
312
+ return /* @__PURE__ */ t(y, { as: "div", padding: "small", children: /* @__PURE__ */ t(
313
+ x,
314
+ {
315
+ variant: "error",
316
+ margin: "0",
317
+ liveRegion: H,
318
+ liveRegionPoliteness: "assertive",
319
+ "data-testid": "edit-items-error",
320
+ children: r("itemsLoadErrorAlert", { message: o.error.message })
321
+ }
322
+ ) });
323
+ if (o.isLoading)
324
+ return /* @__PURE__ */ t(y, { as: "div", padding: "small", "data-testid": "edit-items-loading", children: /* @__PURE__ */ t(Q, { size: "x-small", renderTitle: r("itemsLoadingSpinnerLabel") }) });
325
+ if (o.items.length === 0)
326
+ return /* @__PURE__ */ t(y, { as: "div", padding: "small", "data-testid": "edit-items-empty", children: /* @__PURE__ */ t(L, { size: "small", color: "secondary", children: r("noItemsEmptyState") }) });
327
+ const s = (u) => {
328
+ u === 1 ? o.goToFirstPage() : u === o.page - 1 ? o.goToPreviousPage() : u === o.page + 1 ? o.goToNextPage() : u === o.pageCount && o.goToLastPage();
329
+ };
330
+ return /* @__PURE__ */ f(W, { children: [
331
+ /* @__PURE__ */ t(Le, { isUnstyled: !0, margin: "none", "data-testid": "edit-items-list", children: o.items.map((u) => /* @__PURE__ */ t(ke, { children: /* @__PURE__ */ t(_e, { item: u, module: e, today: l }) }, u.id)) }),
332
+ o.pageCount > 1 ? /* @__PURE__ */ t(
333
+ V,
334
+ {
335
+ as: "nav",
336
+ variant: "compact",
337
+ withFirstAndLastButton: !0,
338
+ margin: "small",
339
+ label: /* @__PURE__ */ t(ge, { children: r("itemsPaginationLabel", { name: e.name }) }),
340
+ labelFirst: r("paginationFirstPage"),
341
+ labelPrev: r("paginationPreviousPage"),
342
+ labelNext: r("paginationNextPage"),
343
+ labelLast: r("paginationLastPage"),
344
+ screenReaderLabelPageButton: (u) => r("paginationPageLabel", { page: u }),
345
+ ellipsis: r("paginationEllipsis"),
346
+ totalPageNumber: o.pageCount,
347
+ currentPage: o.page,
348
+ disabled: o.isRefreshing,
349
+ onPageChange: s,
350
+ "data-testid": "edit-items-pagination"
351
+ }
352
+ ) : null
353
+ ] });
354
+ }
355
+ function $e({
356
+ module: e,
357
+ expanded: o,
358
+ onToggle: l,
359
+ itemsState: r,
360
+ today: s,
361
+ headingLevel: u = "h3"
362
+ }) {
363
+ var m;
364
+ const { t: c } = w(), n = D(), i = O(), a = ((m = n.moduleLabel(e.position, e)) == null ? void 0 : m.trim()) || null, p = a ? c("moduleNameWithLabel", { label: a, name: e.name }) : e.name, d = De(e, s, c, n);
365
+ return /* @__PURE__ */ f(
366
+ y,
367
+ {
368
+ as: "div",
369
+ background: "primary",
370
+ borderRadius: "card.sm",
371
+ borderWidth: "small",
372
+ shadow: "resting",
373
+ margin: "0 0 small 0",
374
+ overflowX: "hidden",
375
+ overflowY: "hidden",
376
+ "data-testid": `edit-module-card-${e.id}`,
377
+ children: [
378
+ /* @__PURE__ */ t(
379
+ y,
380
+ {
381
+ as: "div",
382
+ background: e.published ? "success" : "primary-inverse",
383
+ themeOverride: e.published ? void 0 : Ne,
384
+ padding: "small",
385
+ "data-testid": "edit-module-header",
386
+ "data-published": e.published ? "true" : "false",
387
+ children: /* @__PURE__ */ f(b, { alignItems: "start", gap: "small", children: [
388
+ /* @__PURE__ */ t(b.Item, { children: /* @__PURE__ */ t(
389
+ he,
390
+ {
391
+ size: "small",
392
+ withBackground: !1,
393
+ withBorder: !1,
394
+ color: "primary-inverse",
395
+ screenReaderLabel: o ? c("collapseModule", { name: e.name }) : c("expandModule", { name: e.name }),
396
+ "aria-expanded": o,
397
+ "aria-controls": _(e.id),
398
+ onClick: () => l(e.id),
399
+ "data-testid": `edit-toggle-module-${e.id}`,
400
+ children: o ? /* @__PURE__ */ t(fe, {}) : /* @__PURE__ */ t(ve, {})
401
+ }
402
+ ) }),
403
+ /* @__PURE__ */ f(b.Item, { shouldGrow: !0, shouldShrink: !0, children: [
404
+ /* @__PURE__ */ t(
405
+ G,
406
+ {
407
+ level: u,
408
+ variant: "titleCardMini",
409
+ color: "primary-on",
410
+ "aria-label": p,
411
+ "data-testid": "edit-module-name",
412
+ children: /* @__PURE__ */ t(me, { linesAllowed: 2, children: p })
413
+ }
414
+ ),
415
+ /* @__PURE__ */ t(q, { name: e.name }),
416
+ /* @__PURE__ */ t(y, { as: "div", margin: "xx-small 0 0 0", children: /* @__PURE__ */ t(L, { size: "small", color: "primary-on", "data-testid": "edit-module-meta", children: d.map((h, M) => /* @__PURE__ */ f(U, { children: [
417
+ M > 0 ? /* @__PURE__ */ t("span", { style: $, children: " " }) : null,
418
+ /* @__PURE__ */ f("span", { style: M > 0 ? i : void 0, children: [
419
+ /* @__PURE__ */ t("span", { style: z, "aria-hidden": "true", children: h.icon }),
420
+ h.text
421
+ ] })
422
+ ] }, h.key)) }) })
423
+ ] }),
424
+ /* @__PURE__ */ t(Be, { module: e }),
425
+ /* @__PURE__ */ t(qe, { module: e }),
426
+ /* @__PURE__ */ t(Re, { module: e }),
427
+ /* @__PURE__ */ t(Ee, { module: e })
428
+ ] })
429
+ }
430
+ ),
431
+ /* @__PURE__ */ t("div", { id: _(e.id), role: "group", "aria-label": e.name, hidden: !o, children: o ? /* @__PURE__ */ t(Oe, { module: e, state: r, today: s }) : null })
432
+ ]
433
+ }
434
+ );
435
+ }
436
+ function ze({
437
+ data: e,
438
+ today: o,
439
+ cardHeadingLevel: l
440
+ }) {
441
+ const { modules: r, expandedModuleIds: s, toggleModule: u, getItems: c } = e;
442
+ return /* @__PURE__ */ t("ul", { style: { listStyle: "none", margin: 0, padding: 0 }, "data-testid": "edit-modules-stack", children: r.map((n) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
443
+ $e,
444
+ {
445
+ module: n,
446
+ expanded: s.includes(n.id),
447
+ onToggle: u,
448
+ itemsState: c(n.id),
449
+ today: o,
450
+ headingLevel: l
451
+ }
452
+ ) }, n.id)) });
453
+ }
454
+ function ut({
455
+ data: e,
456
+ today: o,
457
+ as: l = "div",
458
+ headingLevel: r = "h2"
459
+ }) {
460
+ const { t: s } = w(), {
461
+ modules: u,
462
+ page: c,
463
+ pageCount: n,
464
+ goToFirstPage: i,
465
+ goToPreviousPage: a,
466
+ goToNextPage: p,
467
+ goToLastPage: d,
468
+ isLoading: m,
469
+ isRefreshing: h,
470
+ error: M
471
+ } = e, [P] = ce(() => /* @__PURE__ */ new Date()), I = r === "h1" ? "h2" : "h3", v = m || h && u.length === 0, C = u.length === 0 && !v && !M, T = (g) => {
472
+ g === 1 ? i() : g === c - 1 ? a() : g === c + 1 ? p() : g === n && d();
473
+ };
474
+ return /* @__PURE__ */ f(y, { as: l, display: "block", "data-testid": "modules-edit-view", children: [
475
+ M ? /* @__PURE__ */ t(
476
+ x,
477
+ {
478
+ variant: "error",
479
+ margin: "0 0 small 0",
480
+ liveRegion: H,
481
+ liveRegionPoliteness: "assertive",
482
+ "data-testid": "edit-modules-error",
483
+ children: s("modulesLoadErrorAlert", { message: M.message })
484
+ }
485
+ ) : null,
486
+ v ? /* @__PURE__ */ t(y, { as: "div", padding: "large", textAlign: "center", "data-testid": "edit-modules-loading", children: /* @__PURE__ */ t(Q, { renderTitle: s("modulesLoadingSpinnerLabel") }) }) : null,
487
+ C ? /* @__PURE__ */ f(
488
+ y,
489
+ {
490
+ as: "div",
491
+ background: "primary",
492
+ borderRadius: "card.lg",
493
+ borderWidth: "small",
494
+ shadow: "resting",
495
+ padding: "medium",
496
+ textAlign: "center",
497
+ "data-testid": "edit-modules-empty",
498
+ children: [
499
+ /* @__PURE__ */ t(G, { level: I, variant: "titleCardLarge", margin: "0 0 x-small 0", children: s("editNoModulesTitle") }),
500
+ /* @__PURE__ */ t(L, { color: "secondary", children: s("editNoModulesDescription") })
501
+ ]
502
+ }
503
+ ) : null,
504
+ /* @__PURE__ */ t(
505
+ ze,
506
+ {
507
+ data: e,
508
+ today: o ?? P,
509
+ cardHeadingLevel: I
510
+ }
511
+ ),
512
+ n > 1 && !v ? /* @__PURE__ */ t(
513
+ V,
514
+ {
515
+ as: "nav",
516
+ variant: "compact",
517
+ withFirstAndLastButton: !0,
518
+ margin: "small 0 0 0",
519
+ labelFirst: s("paginationFirstPage"),
520
+ labelPrev: s("paginationPreviousPage"),
521
+ labelNext: s("paginationNextPage"),
522
+ labelLast: s("paginationLastPage"),
523
+ screenReaderLabelPageButton: (g) => s("paginationPageLabel", { page: g }),
524
+ ellipsis: s("paginationEllipsis"),
525
+ totalPageNumber: n,
526
+ currentPage: c,
527
+ disabled: h,
528
+ onPageChange: T,
529
+ "data-testid": "edit-modules-pagination"
530
+ }
531
+ ) : null
532
+ ] });
533
+ }
534
+ function je(e) {
535
+ return null;
536
+ }
537
+ function Ue(e) {
538
+ return null;
539
+ }
540
+ function We(e) {
541
+ return null;
542
+ }
543
+ function ct({ data: e }) {
544
+ const { t: o } = w(), l = ae(), { expandedModuleIds: r, collapseAllModules: s, isPersistingCollapsed: u } = e, c = r.length, n = () => {
545
+ l("collapse-all"), s(), pe(o("modulesCollapsedAnnouncement", { count: c }));
546
+ };
547
+ return /* @__PURE__ */ f(b, { gap: "x-small", wrap: "wrap", justifyItems: "end", "data-testid": "modules-edit-actions", children: [
548
+ /* @__PURE__ */ t(b.Item, { children: /* @__PURE__ */ t(
549
+ Me,
550
+ {
551
+ size: "small",
552
+ onClick: n,
553
+ interaction: c === 0 || u ? "disabled" : "enabled",
554
+ "data-testid": "edit-collapse-all",
555
+ children: o("collapseAllModules")
556
+ }
557
+ ) }),
558
+ /* @__PURE__ */ t(We, { data: e }),
559
+ /* @__PURE__ */ t(je, { data: e }),
560
+ /* @__PURE__ */ t(Ue, { data: e })
561
+ ] });
185
562
  }
186
563
  export {
187
- k as createInMemoryEditAdapter,
188
- F as useModulesEditData
564
+ $e as EditModuleCard,
565
+ _e as EditModuleItemRow,
566
+ ct as ModulesEditActions,
567
+ ut as ModulesEditView,
568
+ at as createInMemoryEditAdapter,
569
+ dt as useModulesEditData
189
570
  };