@instructure/platform-modules 1.14.0 → 1.16.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 (44) hide show
  1. package/dist/adapters/canvasGraphql/normalize.d.ts +1 -0
  2. package/dist/adapters/canvasGraphql/normalize.d.ts.map +1 -1
  3. package/dist/adapters/canvasGraphql/queries.d.ts.map +1 -1
  4. package/dist/adapters/inMemory.d.ts.map +1 -1
  5. package/dist/chunks/ModulesProgressBar-B1oRo549.js +2548 -0
  6. package/dist/components/FilterSelect.d.ts.map +1 -1
  7. package/dist/components/ModuleCard.d.ts.map +1 -1
  8. package/dist/components/ModuleCard.stories.d.ts +2 -0
  9. package/dist/components/ModuleCard.stories.d.ts.map +1 -1
  10. package/dist/components/ModuleItemRow.d.ts.map +1 -1
  11. package/dist/components/ModulesList.d.ts.map +1 -1
  12. package/dist/components/ModulesList.stories.d.ts +1 -1
  13. package/dist/components/ModulesList.stories.d.ts.map +1 -1
  14. package/dist/components/ModulesProgressBar.d.ts +9 -0
  15. package/dist/components/ModulesProgressBar.d.ts.map +1 -1
  16. package/dist/components/StatusPill.d.ts +2 -0
  17. package/dist/components/StatusPill.d.ts.map +1 -1
  18. package/dist/edit/EditModuleCard.d.ts +5 -3
  19. package/dist/edit/EditModuleCard.d.ts.map +1 -1
  20. package/dist/edit/EditModuleItemRow.d.ts +2 -1
  21. package/dist/edit/EditModuleItemRow.d.ts.map +1 -1
  22. package/dist/edit/ModulesEditView.d.ts.map +1 -1
  23. package/dist/edit/ModulesEditView.stories.d.ts +3 -2
  24. package/dist/edit/ModulesEditView.stories.d.ts.map +1 -1
  25. package/dist/edit/controls/DragHandle.d.ts +12 -0
  26. package/dist/edit/controls/DragHandle.d.ts.map +1 -0
  27. package/dist/edit/dnd/EditDndProvider.d.ts +18 -0
  28. package/dist/edit/dnd/EditDndProvider.d.ts.map +1 -0
  29. package/dist/edit/dnd/announcements.d.ts +24 -0
  30. package/dist/edit/dnd/announcements.d.ts.map +1 -0
  31. package/dist/edit/dnd/ids.d.ts +41 -0
  32. package/dist/edit/dnd/ids.d.ts.map +1 -0
  33. package/dist/edit/index.d.ts +2 -0
  34. package/dist/edit/index.d.ts.map +1 -1
  35. package/dist/edit.js +610 -328
  36. package/dist/hooks/useItemsMode.d.ts.map +1 -1
  37. package/dist/hooks/useModulesPageData.d.ts.map +1 -1
  38. package/dist/index.js +732 -724
  39. package/dist/types/domain.d.ts +2 -0
  40. package/dist/types/domain.d.ts.map +1 -1
  41. package/dist/types/schemas.d.ts.map +1 -1
  42. package/locales/en.json +14 -2
  43. package/package.json +4 -2
  44. package/dist/chunks/ModulesProgressBar-B4fXbi-4.js +0 -2516
package/dist/edit.js CHANGED
@@ -1,125 +1,128 @@
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";
1
+ import { Q as fe, a8 as Ie, R as Me, k as K, ax as ve, i as be, c as ye, u as w, q as Y, z as G, v as Pe, ao as Ce, al as ke, aI as B, B as De, C as V, n as Q, aJ as Ae, aK as Le, A as we, p as Re } from "./chunks/ModulesProgressBar-B1oRo549.js";
2
+ import { useQueryClient as Se, useMutation as Ee } from "@tanstack/react-query";
3
+ import { useMemo as T, createContext as Oe, useState as X, useContext as Te, Fragment as J } from "react";
4
+ import { jsx as n, jsxs as v, Fragment as Z } from "react/jsx-runtime";
5
+ import { politeAnnounce as ee, TruncateWithTooltip as Be, getLiveRegion as te } from "@instructure/platform-instui-bindings";
6
+ import { Alert as ne } from "@instructure/ui-alerts/v11_7";
7
+ import { Heading as ie } from "@instructure/ui-heading/v11_7";
8
+ import { Pagination as oe } from "@instructure/ui-pagination/v11_7";
9
+ import { Spinner as re } from "@instructure/ui-spinner/v11_7";
10
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";
11
+ import { View as k } from "@instructure/ui-view/v11_7";
12
+ import { useSensors as Ne, useSensor as $, PointerSensor as qe, KeyboardSensor as xe, DndContext as Fe, DragOverlay as _e, rectIntersection as $e, closestCenter as ze } from "@dnd-kit/core";
13
+ import { SortableContext as de, verticalListSortingStrategy as se, useSortable as He, sortableKeyboardCoordinates as Ue, arrayMove as z } from "@dnd-kit/sortable";
14
+ import { CSS as je } from "@dnd-kit/utilities";
15
+ import { ScreenReaderContent as We } from "@instructure/ui-a11y-content";
16
+ import { IconButton as ae, Button as Ke } from "@instructure/ui-buttons/v11_7";
14
17
  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));
18
+ import { IconDragHandleLine as Ye, CornerDownRightInstUIIcon as Ge, IconArrowOpenUpLine as Ve, IconArrowOpenDownLine as Qe, LayersInstUIIcon as Xe, ListChecksInstUIIcon as Je, ClockInstUIIcon as Ze, LockInstUIIcon as et } from "@instructure/ui-icons";
19
+ import { List as tt, ListItem as nt } from "@instructure/ui-list/v11_7";
20
+ import { Pill as it } from "@instructure/ui-pill/v11_7";
21
+ import { Link as ot } from "@instructure/ui-link/v11_7";
22
+ const S = (e) => e.map((t, i) => ({ ...t, position: i + 1 })), E = (e, t, i) => {
23
+ const a = i === void 0 ? e.length : Math.min(Math.max(i - 1, 0), e.length);
24
+ return [...e.slice(0, a), t, ...e.slice(a)];
25
+ }, H = (e, t) => {
26
+ const i = new Map(t.map((a, o) => [a, o]));
27
+ return [...e].sort((a, o) => (i.get(a.id) ?? t.length) - (i.get(o.id) ?? t.length));
25
28
  };
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);
29
+ function Jt(e, t = {}) {
30
+ const i = (r) => {
31
+ if (r !== e.courseId)
32
+ throw new Ie(e.courseId, r);
33
+ }, a = (r) => {
34
+ const d = e.modules.findIndex((l) => l.id === r);
35
+ if (d === -1) throw new Error(`in-memory adapter has no module ${r}`);
36
+ return d;
37
+ }, o = (r) => e.itemsByModuleId[r] ?? [], u = (r, d) => {
38
+ e.itemsByModuleId[r] = S(d.map((l) => ({ ...l, moduleId: r })));
39
+ }, s = (r) => String(r.reduce((d, l) => Math.max(d, Number(l) || 0), 0) + 1);
37
40
  return {
38
- ...X(e, o),
39
- async createModule({ courseId: n, name: i, position: a }) {
40
- l(n);
41
+ ...fe(e, t),
42
+ async createModule({ courseId: r, name: d, position: l }) {
43
+ i(r);
41
44
  const p = {
42
- id: c(e.modules.map((d) => d.id)),
43
- name: i,
45
+ id: s(e.modules.map((c) => c.id)),
46
+ name: d,
44
47
  position: 0,
45
48
  published: !1,
46
49
  itemCount: 0,
47
50
  prerequisiteModules: [],
48
51
  requireSequentialProgress: !1
49
52
  };
50
- return e.modules = k(B(e.modules, p, a)), e.itemsByModuleId[p.id] = [], e.modules[r(p.id)];
53
+ return e.modules = S(E(e.modules, p, l)), e.itemsByModuleId[p.id] = [], e.modules[a(p.id)];
51
54
  },
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
55
+ async updateModule({ courseId: r, moduleId: d, patch: l }) {
56
+ i(r);
57
+ const { prerequisiteModuleIds: p, position: c, ...m } = l, M = e.modules[a(d)], f = { ...M, ...m };
58
+ p && (f.prerequisiteModules = p.map((g) => ({
59
+ id: g,
60
+ name: e.modules[a(g)].name
58
61
  })));
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)];
62
+ const I = e.modules.filter((g) => g.id !== d);
63
+ return e.modules = S(E(I, f, c ?? M.position)), e.modules[a(d)];
61
64
  },
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];
65
+ async deleteModule({ courseId: r, moduleId: d }) {
66
+ i(r), a(d), e.modules = S(e.modules.filter((l) => l.id !== d)), delete e.itemsByModuleId[d];
64
67
  },
65
- async reorderModules({ courseId: n, moduleIds: i }) {
66
- l(n), e.modules = k(S(e.modules, i));
68
+ async reorderModules({ courseId: r, moduleIds: d }) {
69
+ i(r), e.modules = S(H(e.modules, d));
67
70
  },
68
- async setModulesPublished({ courseId: n, moduleIds: i, published: a, includeItems: p }) {
69
- l(n);
70
- const d = new Set(
71
- i === "all" ? e.modules.map((m) => m.id) : i
71
+ async setModulesPublished({ courseId: r, moduleIds: d, published: l, includeItems: p }) {
72
+ i(r);
73
+ const c = new Set(
74
+ d === "all" ? e.modules.map((m) => m.id) : d
72
75
  );
73
76
  if (e.modules = e.modules.map(
74
- (m) => d.has(m.id) ? { ...m, published: a } : m
77
+ (m) => c.has(m.id) ? { ...m, published: l } : m
75
78
  ), !!p)
76
- for (const m of d)
79
+ for (const m of c)
77
80
  u(
78
81
  m,
79
- s(m).map((h) => ({ ...h, published: a }))
82
+ o(m).map((M) => ({ ...M, published: l }))
80
83
  );
81
84
  },
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,
85
+ async createModuleItem({ courseId: r, moduleId: d, type: l, title: p, position: c, indent: m = 0, extensions: M }) {
86
+ i(r), a(d);
87
+ const f = Object.values(e.itemsByModuleId).flatMap(
88
+ (g) => g.map((h) => h.id)
89
+ ), I = {
90
+ id: s(f),
91
+ moduleId: d,
89
92
  title: p,
90
- type: a,
93
+ type: l,
91
94
  position: 0,
92
95
  indent: m,
93
96
  published: !1,
94
- ...h ? { extensions: h } : {}
97
+ ...M ? { extensions: M } : {}
95
98
  };
96
- return u(i, B(s(i), P, d)), s(i).find((I) => I.id === P.id);
99
+ return u(d, E(o(d), I, c)), o(d).find((g) => g.id === I.id);
97
100
  },
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}`);
101
+ async updateModuleItem({ courseId: r, moduleId: d, itemId: l, patch: p }) {
102
+ i(r);
103
+ const { moduleId: c = d, position: m, ...M } = p;
104
+ a(c);
105
+ const f = o(d).find((h) => h.id === l);
106
+ if (!f) throw new Error(`in-memory adapter has no item ${l} in module ${d}`);
104
107
  u(
105
- i,
106
- s(i).filter((v) => v.id !== a)
108
+ d,
109
+ o(d).filter((h) => h.id !== l)
107
110
  );
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);
111
+ const g = m ?? (c !== d ? void 0 : f.position);
112
+ return u(c, E(o(c), { ...f, ...M }, g)), o(c).find((h) => h.id === l);
110
113
  },
111
- async deleteModuleItem({ courseId: n, moduleId: i, itemId: a }) {
112
- l(n), u(
113
- i,
114
- s(i).filter((p) => p.id !== a)
114
+ async deleteModuleItem({ courseId: r, moduleId: d, itemId: l }) {
115
+ i(r), u(
116
+ d,
117
+ o(d).filter((p) => p.id !== l)
115
118
  );
116
119
  },
117
- async reorderModuleItems({ courseId: n, moduleId: i, itemIds: a }) {
118
- l(n), u(i, S(s(i), a));
120
+ async reorderModuleItems({ courseId: r, moduleId: d, itemIds: l }) {
121
+ i(r), u(d, H(o(d), l));
119
122
  }
120
123
  };
121
124
  }
122
- const Te = [
125
+ const rt = [
123
126
  "createModule",
124
127
  "updateModule",
125
128
  "deleteModule",
@@ -130,240 +133,492 @@ const Te = [
130
133
  "deleteModuleItem",
131
134
  "reorderModuleItems"
132
135
  ];
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 }),
136
+ function A(e, t, i, a, o) {
137
+ return Ee({
138
+ mutationFn: (u) => !t[e] || !a ? Promise.reject(new Error(`${e} is not available to this editor`)) : a({ ...u, courseId: i }),
136
139
  // Settled, not success: a bulk write that fails partway has still committed part of itself.
137
- onSettled: (u, c, n) => s(n)
140
+ onSettled: (u, s, r) => o(r)
138
141
  });
139
142
  }
140
- function dt(e) {
141
- const { adapter: o, courseId: l } = e, r = J({ ...e, view: "teacher" }), s = de(), { permissions: u } = N(), c = j(
143
+ function Zt(e) {
144
+ const { adapter: t, courseId: i } = e, a = Me({ ...e, view: "teacher" }), o = Se(), { permissions: u } = K(), s = T(
142
145
  () => Object.fromEntries(
143
- Te.map((d) => [
144
- d,
145
- typeof o[d] == "function" && u[d] !== !1
146
+ rt.map((c) => [
147
+ c,
148
+ typeof t[c] == "function" && u[c] !== !1
146
149
  ])
147
150
  ),
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) => {
151
+ [t, u]
152
+ ), r = () => be(o, i), d = (...c) => Promise.all([
153
+ r(),
154
+ ...c.map((m) => ye(o, i, m))
155
+ ]), l = (c) => {
153
156
  var m;
154
- return (m = o[d]) == null ? void 0 : m.bind(o);
157
+ return (m = t[c]) == null ? void 0 : m.bind(t);
155
158
  }, 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),
159
+ createModule: A("createModule", s, i, l("createModule"), r),
160
+ updateModule: A("updateModule", s, i, l("updateModule"), r),
161
+ deleteModule: A("deleteModule", s, i, l("deleteModule"), r),
162
+ reorderModules: A("reorderModules", s, i, l("reorderModules"), r),
160
163
  setModulesPublished: A(
161
164
  "setModulesPublished",
162
- c,
163
- l,
164
- a("setModulesPublished"),
165
- ({ includeItems: d }) => d ? K(s, l) : n()
165
+ s,
166
+ i,
167
+ l("setModulesPublished"),
168
+ ({ includeItems: c }) => c ? ve(o, i) : r()
166
169
  ),
167
170
  createModuleItem: A(
168
171
  "createModuleItem",
169
- c,
170
- l,
171
- a("createModuleItem"),
172
- ({ moduleId: d }) => i(d)
172
+ s,
173
+ i,
174
+ l("createModuleItem"),
175
+ ({ moduleId: c }) => d(c)
173
176
  ),
174
177
  updateModuleItem: A(
175
178
  "updateModuleItem",
176
- c,
177
- l,
178
- a("updateModuleItem"),
179
- ({ moduleId: d, patch: m }) => i(
180
- d,
181
- ...m.moduleId && m.moduleId !== d ? [m.moduleId] : []
179
+ s,
180
+ i,
181
+ l("updateModuleItem"),
182
+ ({ moduleId: c, patch: m }) => d(
183
+ c,
184
+ ...m.moduleId && m.moduleId !== c ? [m.moduleId] : []
182
185
  )
183
186
  ),
184
187
  deleteModuleItem: A(
185
188
  "deleteModuleItem",
186
- c,
187
- l,
188
- a("deleteModuleItem"),
189
- ({ moduleId: d }) => i(d)
189
+ s,
190
+ i,
191
+ l("deleteModuleItem"),
192
+ ({ moduleId: c }) => d(c)
190
193
  ),
191
194
  reorderModuleItems: A(
192
195
  "reorderModuleItems",
193
- c,
194
- l,
195
- a("reorderModuleItems"),
196
- ({ moduleId: d }) => i(d)
196
+ s,
197
+ i,
198
+ l("reorderModuleItems"),
199
+ ({ moduleId: c }) => d(c)
197
200
  )
198
201
  };
199
- return { ...r, can: c, mutations: p };
202
+ return { ...a, can: s, mutations: p };
203
+ }
204
+ const le = (e) => `module:${e}`, ce = (e) => `item:${e}`, en = (e) => `external:${e}`, dt = (e) => `items:${e}`;
205
+ function D(e) {
206
+ const t = e == null ? void 0 : e.data.current, i = t == null ? void 0 : t.kind;
207
+ return i === "module" || i === "item" || i === "external" ? t : void 0;
208
+ }
209
+ function ue(e) {
210
+ var t;
211
+ return (t = e == null ? void 0 : e.data.current) == null ? void 0 : t.sortable;
212
+ }
213
+ const me = (e, t) => (e == null ? void 0 : e.kind) === "item" && (t == null ? void 0 : t.kind) === "item" && e.moduleId !== t.moduleId, U = (e) => e.top + e.height / 2, q = (e, t) => e !== null && U(e) > U(t.rect);
214
+ function j(e, t) {
215
+ const i = D(t), a = ue(t);
216
+ if (!(!t || !i || !a))
217
+ return i.kind === "item" && me(D(e), i) ? {
218
+ position: a.index + (q(e.rect.current.translated, t) ? 2 : 1),
219
+ count: a.items.length + 1,
220
+ module: i.moduleName
221
+ } : {
222
+ position: a.index + 1,
223
+ count: a.items.length,
224
+ module: i.kind === "item" ? i.moduleName : void 0
225
+ };
226
+ }
227
+ function st(e) {
228
+ const t = (s) => (r) => {
229
+ var l;
230
+ const d = (l = D(r.active)) == null ? void 0 : l.name;
231
+ return d === void 0 ? void 0 : s(d, r);
232
+ }, i = t((s, { active: r, over: d }) => {
233
+ const l = j(r, d);
234
+ if (!l) return e("dragOverNothing", { name: s });
235
+ const { position: p, count: c, module: m } = l;
236
+ return m === void 0 ? e("dragOverPosition", { name: s, position: p, count: c }) : e("dragOverPositionInModule", { name: s, position: p, count: c, module: m });
237
+ });
238
+ let a = !1, o, u;
239
+ return {
240
+ onDragStart: t((s) => (a = !0, e("dragPickedUp", { name: s }))),
241
+ onDragOver: (s) => {
242
+ var d, l;
243
+ const r = a && ((d = s.over) == null ? void 0 : d.id) === s.active.id;
244
+ return a = !1, o = (l = s.over) == null ? void 0 : l.id, u = i(s), r ? void 0 : u;
245
+ },
246
+ // Crossing the middle of an item in another module changes where it lands, but not `over`.
247
+ onDragMove: (s) => {
248
+ if (!s.over || s.over.id !== o) return;
249
+ const r = i(s);
250
+ if (r !== u)
251
+ return u = r, r;
252
+ },
253
+ onDragEnd: t((s, { active: r, over: d }) => {
254
+ const l = j(r, d);
255
+ if (!l) return e("dragDroppedNowhere", { name: s });
256
+ const { position: p, count: c, module: m } = l;
257
+ return m === void 0 ? e("dragDroppedPosition", { name: s, position: p, count: c }) : e("dragDroppedPositionInModule", { name: s, position: p, count: c, module: m });
258
+ }),
259
+ onDragCancel: t((s) => e("dragCanceled", { name: s }))
260
+ };
261
+ }
262
+ function at(e) {
263
+ const t = st(e), i = (a) => (o) => {
264
+ const u = a(o);
265
+ u && ee(u);
266
+ };
267
+ return {
268
+ announcements: {
269
+ onDragStart: i(t.onDragStart),
270
+ onDragOver: i(t.onDragOver),
271
+ onDragMove: i(t.onDragMove),
272
+ onDragEnd: i(t.onDragEnd),
273
+ onDragCancel: i(t.onDragCancel)
274
+ },
275
+ screenReaderInstructions: { draggable: e("dragInstructions") }
276
+ };
277
+ }
278
+ const ge = Oe(null);
279
+ function lt() {
280
+ return Te(ge);
281
+ }
282
+ function pe(e, t, i) {
283
+ const { t: a } = w(), o = He({
284
+ id: e,
285
+ data: { ...t },
286
+ disabled: !i,
287
+ attributes: { roleDescription: a("dragRoleDescription") }
288
+ }), u = {
289
+ transform: je.Translate.toString(o.transform),
290
+ transition: o.transition,
291
+ opacity: o.isDragging ? ct : void 0
292
+ };
293
+ return { ...o, style: u };
294
+ }
295
+ const ct = 0.4, ut = (e) => e === "module" ? "module" : "item", mt = (e) => {
296
+ var a;
297
+ const t = ut((a = D(e.active)) == null ? void 0 : a.kind), i = {
298
+ ...e,
299
+ droppableContainers: e.droppableContainers.filter(
300
+ (o) => {
301
+ var u;
302
+ return ((u = D(o)) == null ? void 0 : u.kind) === t;
303
+ }
304
+ )
305
+ };
306
+ return t === "item" && $e(i).length === 0 ? [] : ze(i);
307
+ }, gt = (e, t) => {
308
+ const { active: i, over: a, collisionRect: o } = t.context, u = ue(a);
309
+ if (a !== null && o !== null && u !== void 0 && u.index === u.items.length - 1 && me(D(i), D(a))) {
310
+ const r = q(o, a);
311
+ if (e.code === "ArrowDown" && !r)
312
+ return e.preventDefault(), { x: a.rect.left, y: a.rect.bottom - o.height / 2 };
313
+ if (e.code === "ArrowUp" && r)
314
+ return e.preventDefault(), { x: a.rect.left, y: a.rect.top };
315
+ }
316
+ return Ue(e, t);
317
+ }, pt = { cursor: "grabbing" };
318
+ function ht({ data: e, children: t }) {
319
+ const { t: i } = w(), { modules: a, getItems: o, can: u, mutations: s } = e, [r, d] = X(null), l = T(() => at(i), [i]), p = Ne(
320
+ $(qe, { activationConstraint: { distance: 8 } }),
321
+ $(xe, { coordinateGetter: gt })
322
+ ), c = T(() => a.map((f) => le(f.id)), [a]), m = ({ active: f }) => {
323
+ d(D(f) ?? null);
324
+ }, M = ({ active: f, over: I }) => {
325
+ d(null);
326
+ const g = D(f), h = D(I);
327
+ if (!g || !h || !I) return;
328
+ if (g.kind === "module" && h.kind === "module") {
329
+ if (g.moduleId === h.moduleId) return;
330
+ const C = a.map((y) => y.id);
331
+ s.reorderModules.mutate({
332
+ moduleIds: z(C, C.indexOf(g.moduleId), C.indexOf(h.moduleId))
333
+ });
334
+ return;
335
+ }
336
+ if (g.kind !== "item" || h.kind !== "item" || g.itemId === h.itemId) return;
337
+ if (g.moduleId === h.moduleId) {
338
+ const C = o(g.moduleId).items.map((y) => y.id);
339
+ s.reorderModuleItems.mutate({
340
+ moduleId: g.moduleId,
341
+ itemIds: z(C, C.indexOf(g.itemId), C.indexOf(h.itemId))
342
+ });
343
+ return;
344
+ }
345
+ if (!u.updateModuleItem) return;
346
+ const R = q(f.rect.current.translated, I);
347
+ s.updateModuleItem.mutate({
348
+ moduleId: g.moduleId,
349
+ itemId: g.itemId,
350
+ patch: { moduleId: h.moduleId, position: h.position + (R ? 1 : 0) }
351
+ });
352
+ };
353
+ return /* @__PURE__ */ n(ge.Provider, { value: (r == null ? void 0 : r.kind) ?? null, children: /* @__PURE__ */ v(
354
+ Fe,
355
+ {
356
+ sensors: p,
357
+ collisionDetection: mt,
358
+ accessibility: l,
359
+ onDragStart: m,
360
+ onDragEnd: M,
361
+ onDragCancel: () => d(null),
362
+ children: [
363
+ /* @__PURE__ */ n(de, { items: c, strategy: se, children: t }),
364
+ /* @__PURE__ */ n(_e, { children: r ? /* @__PURE__ */ n("div", { style: pt, children: /* @__PURE__ */ n(
365
+ k,
366
+ {
367
+ as: "div",
368
+ background: "primary",
369
+ borderRadius: "card.sm",
370
+ borderWidth: "small",
371
+ shadow: "topmost",
372
+ padding: "small",
373
+ "data-testid": "edit-drag-overlay",
374
+ children: /* @__PURE__ */ n(L, { weight: "bold", children: r.name })
375
+ }
376
+ ) }) : null })
377
+ ]
378
+ }
379
+ ) });
200
380
  }
201
- function Be(e) {
381
+ function ft(e) {
202
382
  return null;
203
383
  }
204
- function q(e) {
384
+ function he({
385
+ label: e,
386
+ attributes: t,
387
+ listeners: i,
388
+ activatorRef: a,
389
+ color: o = "primary",
390
+ "data-testid": u
391
+ }) {
392
+ return /* @__PURE__ */ n(
393
+ ae,
394
+ {
395
+ ...t,
396
+ ...i,
397
+ elementRef: (s) => a(s),
398
+ size: "small",
399
+ withBackground: !1,
400
+ withBorder: !1,
401
+ color: o,
402
+ cursor: "grab",
403
+ screenReaderLabel: e,
404
+ "data-testid": u,
405
+ children: /* @__PURE__ */ n(Ye, {})
406
+ }
407
+ );
408
+ }
409
+ function N(e) {
205
410
  return null;
206
411
  }
207
- function Re(e) {
412
+ function It(e) {
208
413
  return null;
209
414
  }
210
- function Ee(e) {
415
+ function Mt(e) {
211
416
  return null;
212
417
  }
213
- function qe(e) {
418
+ function vt(e) {
214
419
  return null;
215
420
  }
216
- function Fe(e) {
421
+ function bt(e) {
217
422
  return null;
218
423
  }
219
- function Se(e) {
424
+ function yt(e) {
220
425
  return null;
221
426
  }
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 })
427
+ function Pt({
428
+ item: e,
429
+ module: t,
430
+ today: i,
431
+ canReorder: a
432
+ }) {
433
+ var x, F;
434
+ const { t: o, locale: u, timezone: s } = w(), r = Y(), d = K(), l = G(), p = T(() => Pe(d.itemMeta), [d.itemMeta]), c = e.title || o("itemUntitled"), m = pe(
435
+ ce(e.id),
436
+ {
437
+ kind: "item",
438
+ moduleId: t.id,
439
+ moduleName: t.name,
440
+ itemId: e.id,
441
+ name: c,
442
+ position: e.position
443
+ },
444
+ a
445
+ ), M = a ? /* @__PURE__ */ n(b.Item, { children: /* @__PURE__ */ n(
446
+ he,
447
+ {
448
+ label: o("dragHandleLabel", { name: c }),
449
+ attributes: m.attributes,
450
+ listeners: m.listeners,
451
+ activatorRef: m.setActivatorNodeRef,
452
+ "data-testid": `item-drag-handle-${e.id}`
453
+ }
454
+ ) }) : null, f = /* @__PURE__ */ v(Z, { children: [
455
+ /* @__PURE__ */ n(bt, { module: t, item: e }),
456
+ /* @__PURE__ */ n(yt, { item: e })
227
457
  ] });
228
458
  if (e.type === "sub_header")
229
- return /* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(
230
- y,
459
+ return /* @__PURE__ */ n("div", { ref: m.setNodeRef, style: m.style, children: /* @__PURE__ */ n(
460
+ k,
231
461
  {
232
462
  as: "div",
233
463
  padding: "x-small small",
234
464
  borderWidth: "small 0 0 0",
235
465
  "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 })
466
+ children: /* @__PURE__ */ v(b, { alignItems: "center", gap: "small", children: [
467
+ M,
468
+ /* @__PURE__ */ v(b.Item, { shouldGrow: !0, shouldShrink: !0, children: [
469
+ /* @__PURE__ */ n(L, { weight: "bold", "data-testid": "edit-item-title", children: c }),
470
+ /* @__PURE__ */ n(N, { name: c })
240
471
  ] }),
241
- d
472
+ f
242
473
  ] })
243
474
  }
244
475
  ) });
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(
476
+ const I = Ce(d.itemTypes, e.type), g = I != null && I.renderIcon ? I.renderIcon({ item: e }) : I == null ? void 0 : I.icon, h = ((F = (x = d.navigation).getItemEditHref) == null ? void 0 : F.call(x, e)) ?? null, R = { item: e, t: o, today: i, locale: u, timezone: s, formatters: r, config: d }, C = p.map((P) => ({
477
+ key: P.key,
478
+ node: P.render(R),
479
+ icon: P.key === ke ? null : P.renderIcon ? P.renderIcon(R) : P.icon
480
+ })).filter((P) => !B(P.node)), y = /* @__PURE__ */ n(L, { weight: "bold", "data-testid": "edit-item-title", children: c });
481
+ return /* @__PURE__ */ n("div", { ref: m.setNodeRef, style: m.style, children: /* @__PURE__ */ n(k, { as: "div", padding: "small", borderWidth: "small 0 0 0", "data-testid": `edit-item-${e.id}`, children: /* @__PURE__ */ n("div", { style: { paddingInlineStart: `${Math.max(e.indent - 1, 0) * Ae}rem` }, children: /* @__PURE__ */ v(b, { alignItems: "center", gap: "small", children: [
482
+ M,
483
+ e.indent > 0 ? /* @__PURE__ */ n(b.Item, { "data-testid": "edit-item-nest-arrow", children: /* @__PURE__ */ n(Ge, { size: "md", color: "mutedColor" }) }) : null,
484
+ B(g) ? null : /* @__PURE__ */ n(b.Item, { "aria-hidden": "true", children: g }),
485
+ /* @__PURE__ */ v(b.Item, { shouldGrow: !0, shouldShrink: !0, children: [
486
+ h ? /* @__PURE__ */ n(ot, { href: h, forceButtonRole: !1, "data-testid": "edit-item-link", children: y }) : y,
487
+ /* @__PURE__ */ n(N, { name: c }),
488
+ C.length > 0 ? /* @__PURE__ */ n("div", { style: De, children: /* @__PURE__ */ n(
257
489
  L,
258
490
  {
259
491
  size: "small",
260
492
  lineHeight: "default",
261
493
  color: "secondary",
262
494
  "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
495
+ children: C.map((P, _) => /* @__PURE__ */ v(J, { children: [
496
+ _ > 0 ? /* @__PURE__ */ n("span", { style: V, children: " " }) : null,
497
+ /* @__PURE__ */ v("span", { style: _ > 0 ? l : void 0, children: [
498
+ B(P.icon) ? null : /* @__PURE__ */ n("span", { style: Q, "aria-hidden": "true", children: P.icon }),
499
+ P.node
268
500
  ] })
269
- ] }, g.key))
501
+ ] }, P.key))
270
502
  }
271
503
  ) }) : null
272
504
  ] }),
273
- /* @__PURE__ */ t(b.Item, { children: /* @__PURE__ */ t(we, { "data-testid": "edit-item-requirement", children: e.completionRequirement ? r("itemRequiredTag") : r("itemOptionalTag") }) }),
274
- d
505
+ /* @__PURE__ */ n(b.Item, { children: /* @__PURE__ */ n(it, { "data-testid": "edit-item-requirement", children: e.completionRequirement ? o("itemRequiredTag") : o("itemOptionalTag") }) }),
506
+ f
275
507
  ] }) }) }) });
276
508
  }
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 = [
509
+ const Ct = Le("grey"), W = (e) => `platform-modules-edit-panel-${e}`, O = { size: "sm", color: "onColor" };
510
+ function kt(e, t, i, a) {
511
+ const o = [
280
512
  {
281
513
  key: "items",
282
- icon: /* @__PURE__ */ t(be, { ...R }),
283
- text: l("moduleItemCount", { count: e.itemCount })
514
+ icon: /* @__PURE__ */ n(Xe, { ...O }),
515
+ text: i("moduleItemCount", { count: e.itemCount })
284
516
  }
285
517
  ], 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(", ")
518
+ e.unlockAt && new Date(e.unlockAt) > t && u.push(a.unlockByline(e.unlockAt, t));
519
+ const s = e.prerequisiteModules.map((d) => d.name.trim()).filter(Boolean);
520
+ s.length === 1 ? u.push(i("lockedByPrerequisiteByline", { name: s[0] })) : s.length > 1 && u.push(
521
+ i("lockedByPrerequisitesByline", {
522
+ count: s.length,
523
+ prerequisites: s.join(", ")
292
524
  })
293
- ), u.length > 0 && s.push({ key: "lock", icon: /* @__PURE__ */ t(Ae, { ...R }), text: u.join(" ") }), e.completionRequirements && e.completionRequirements.length > 0 && s.push({
525
+ ), u.length > 0 && o.push({ key: "lock", icon: /* @__PURE__ */ n(et, { ...O }), text: u.join(" ") }), e.completionRequirements && e.completionRequirements.length > 0 && o.push({
294
526
  key: "requirement",
295
- icon: /* @__PURE__ */ t(ye, { ...R }),
296
- text: e.requireSequentialProgress ? l("moduleRequirementAllInOrder") : e.requirementCount === 1 ? l("moduleRequirementOne") : l("moduleRequirementAll")
527
+ icon: /* @__PURE__ */ n(Je, { ...O }),
528
+ text: e.requireSequentialProgress ? i("moduleRequirementAllInOrder") : e.requirementCount === 1 ? i("moduleRequirementOne") : i("moduleRequirementAll")
297
529
  });
298
- const n = se(e.items);
299
- return n !== null && s.push({
530
+ const r = we(e.items);
531
+ return r !== null && o.push({
300
532
  key: "duration",
301
- icon: /* @__PURE__ */ t(Pe, { ...R }),
302
- text: r.estimatedDurationByline(n)
303
- }), s;
533
+ icon: /* @__PURE__ */ n(Ze, { ...O }),
534
+ text: a.estimatedDurationByline(r)
535
+ }), o;
304
536
  }
305
- function Oe({
537
+ function Dt({
306
538
  module: e,
307
- state: o,
308
- today: l
539
+ state: t,
540
+ today: i,
541
+ canReorder: a
309
542
  }) {
310
- const { t: r } = w();
311
- if (o.error)
312
- return /* @__PURE__ */ t(y, { as: "div", padding: "small", children: /* @__PURE__ */ t(
313
- x,
543
+ const { t: o } = w();
544
+ if (t.error)
545
+ return /* @__PURE__ */ n(k, { as: "div", padding: "small", children: /* @__PURE__ */ n(
546
+ ne,
314
547
  {
315
548
  variant: "error",
316
549
  margin: "0",
317
- liveRegion: H,
550
+ liveRegion: te,
318
551
  liveRegionPoliteness: "assertive",
319
552
  "data-testid": "edit-items-error",
320
- children: r("itemsLoadErrorAlert", { message: o.error.message })
553
+ children: o("itemsLoadErrorAlert", { message: t.error.message })
321
554
  }
322
555
  ) });
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();
556
+ if (t.isLoading)
557
+ return /* @__PURE__ */ n(k, { as: "div", padding: "small", "data-testid": "edit-items-loading", children: /* @__PURE__ */ n(re, { size: "x-small", renderTitle: o("itemsLoadingSpinnerLabel") }) });
558
+ if (t.items.length === 0)
559
+ return /* @__PURE__ */ n(k, { as: "div", padding: "small", "data-testid": "edit-items-empty", children: /* @__PURE__ */ n(L, { size: "small", color: "secondary", children: o("noItemsEmptyState") }) });
560
+ const u = (s) => {
561
+ s === 1 ? t.goToFirstPage() : s === t.page - 1 ? t.goToPreviousPage() : s === t.page + 1 ? t.goToNextPage() : s === t.pageCount && t.goToLastPage();
329
562
  };
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,
563
+ return /* @__PURE__ */ v(Z, { children: [
564
+ /* @__PURE__ */ n(
565
+ de,
566
+ {
567
+ id: dt(e.id),
568
+ items: t.items.map((s) => ce(s.id)),
569
+ strategy: se,
570
+ children: /* @__PURE__ */ n(tt, { isUnstyled: !0, margin: "none", "data-testid": "edit-items-list", children: t.items.map((s) => /* @__PURE__ */ n(nt, { children: /* @__PURE__ */ n(
571
+ Pt,
572
+ {
573
+ item: s,
574
+ module: e,
575
+ today: i,
576
+ canReorder: a
577
+ }
578
+ ) }, s.id)) })
579
+ }
580
+ ),
581
+ t.pageCount > 1 ? /* @__PURE__ */ n(
582
+ oe,
334
583
  {
335
584
  as: "nav",
336
585
  variant: "compact",
337
586
  withFirstAndLastButton: !0,
338
587
  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,
588
+ label: /* @__PURE__ */ n(We, { children: o("itemsPaginationLabel", { name: e.name }) }),
589
+ labelFirst: o("paginationFirstPage"),
590
+ labelPrev: o("paginationPreviousPage"),
591
+ labelNext: o("paginationNextPage"),
592
+ labelLast: o("paginationLastPage"),
593
+ screenReaderLabelPageButton: (s) => o("paginationPageLabel", { page: s }),
594
+ ellipsis: o("paginationEllipsis"),
595
+ totalPageNumber: t.pageCount,
596
+ currentPage: t.page,
597
+ disabled: t.isRefreshing,
598
+ onPageChange: u,
350
599
  "data-testid": "edit-items-pagination"
351
600
  }
352
601
  ) : null
353
602
  ] });
354
603
  }
355
- function $e({
604
+ function At({
356
605
  module: e,
357
- expanded: o,
358
- onToggle: l,
359
- itemsState: r,
360
- today: s,
361
- headingLevel: u = "h3"
606
+ expanded: t,
607
+ onToggle: i,
608
+ itemsState: a,
609
+ today: o,
610
+ canReorderModules: u,
611
+ canReorderItems: s,
612
+ headingLevel: r = "h3"
362
613
  }) {
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,
614
+ var I;
615
+ const { t: d } = w(), l = Y(), p = G(), c = pe(
616
+ le(e.id),
617
+ { kind: "module", moduleId: e.id, name: e.name },
618
+ u
619
+ ), m = ((I = l.moduleLabel(e.position, e)) == null ? void 0 : I.trim()) || null, M = m ? d("moduleNameWithLabel", { label: m, name: e.name }) : e.name, f = kt(e, o, d, l);
620
+ return /* @__PURE__ */ n("div", { ref: c.setNodeRef, style: c.style, children: /* @__PURE__ */ v(
621
+ k,
367
622
  {
368
623
  as: "div",
369
624
  background: "primary",
@@ -375,117 +630,138 @@ function $e({
375
630
  overflowY: "hidden",
376
631
  "data-testid": `edit-module-card-${e.id}`,
377
632
  children: [
378
- /* @__PURE__ */ t(
379
- y,
633
+ /* @__PURE__ */ n(
634
+ k,
380
635
  {
381
636
  as: "div",
382
637
  background: e.published ? "success" : "primary-inverse",
383
- themeOverride: e.published ? void 0 : Ne,
638
+ themeOverride: e.published ? void 0 : Ct,
384
639
  padding: "small",
385
640
  "data-testid": "edit-module-header",
386
641
  "data-published": e.published ? "true" : "false",
387
- children: /* @__PURE__ */ f(b, { alignItems: "start", gap: "small", children: [
388
- /* @__PURE__ */ t(b.Item, { children: /* @__PURE__ */ t(
642
+ children: /* @__PURE__ */ v(b, { alignItems: "start", gap: "small", children: [
643
+ u ? /* @__PURE__ */ n(b.Item, { children: /* @__PURE__ */ n(
389
644
  he,
645
+ {
646
+ label: d("dragHandleLabel", { name: e.name }),
647
+ attributes: c.attributes,
648
+ listeners: c.listeners,
649
+ activatorRef: c.setActivatorNodeRef,
650
+ color: "primary-inverse",
651
+ "data-testid": `module-drag-handle-${e.id}`
652
+ }
653
+ ) }) : null,
654
+ /* @__PURE__ */ n(b.Item, { children: /* @__PURE__ */ n(
655
+ ae,
390
656
  {
391
657
  size: "small",
392
658
  withBackground: !1,
393
659
  withBorder: !1,
394
660
  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),
661
+ screenReaderLabel: t ? d("collapseModule", { name: e.name }) : d("expandModule", { name: e.name }),
662
+ "aria-expanded": t,
663
+ "aria-controls": W(e.id),
664
+ onClick: () => i(e.id),
399
665
  "data-testid": `edit-toggle-module-${e.id}`,
400
- children: o ? /* @__PURE__ */ t(fe, {}) : /* @__PURE__ */ t(ve, {})
666
+ children: t ? /* @__PURE__ */ n(Ve, {}) : /* @__PURE__ */ n(Qe, {})
401
667
  }
402
668
  ) }),
403
- /* @__PURE__ */ f(b.Item, { shouldGrow: !0, shouldShrink: !0, children: [
404
- /* @__PURE__ */ t(
405
- G,
669
+ /* @__PURE__ */ v(b.Item, { shouldGrow: !0, shouldShrink: !0, children: [
670
+ /* @__PURE__ */ n(
671
+ ie,
406
672
  {
407
- level: u,
673
+ level: r,
408
674
  variant: "titleCardMini",
409
675
  color: "primary-on",
410
- "aria-label": p,
676
+ "aria-label": M,
411
677
  "data-testid": "edit-module-name",
412
- children: /* @__PURE__ */ t(me, { linesAllowed: 2, children: p })
678
+ children: /* @__PURE__ */ n(Be, { linesAllowed: 2, children: M })
413
679
  }
414
680
  ),
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
681
+ /* @__PURE__ */ n(N, { name: e.name }),
682
+ /* @__PURE__ */ n(k, { as: "div", margin: "xx-small 0 0 0", children: /* @__PURE__ */ n(L, { size: "small", color: "primary-on", "data-testid": "edit-module-meta", children: f.map((g, h) => /* @__PURE__ */ v(J, { children: [
683
+ h > 0 ? /* @__PURE__ */ n("span", { style: V, children: " " }) : null,
684
+ /* @__PURE__ */ v("span", { style: h > 0 ? p : void 0, children: [
685
+ /* @__PURE__ */ n("span", { style: Q, "aria-hidden": "true", children: g.icon }),
686
+ g.text
421
687
  ] })
422
- ] }, h.key)) }) })
688
+ ] }, g.key)) }) })
423
689
  ] }),
424
- /* @__PURE__ */ t(Be, { module: e }),
425
- /* @__PURE__ */ t(qe, { module: e }),
426
- /* @__PURE__ */ t(Re, { module: e }),
427
- /* @__PURE__ */ t(Ee, { module: e })
690
+ /* @__PURE__ */ n(ft, { module: e }),
691
+ /* @__PURE__ */ n(vt, { module: e }),
692
+ /* @__PURE__ */ n(It, { module: e }),
693
+ /* @__PURE__ */ n(Mt, { module: e })
428
694
  ] })
429
695
  }
430
696
  ),
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 })
697
+ /* @__PURE__ */ n("div", { id: W(e.id), role: "group", "aria-label": e.name, hidden: !t, children: t ? /* @__PURE__ */ n(
698
+ Dt,
699
+ {
700
+ module: e,
701
+ state: a,
702
+ today: o,
703
+ canReorder: s
704
+ }
705
+ ) : null })
432
706
  ]
433
707
  }
434
- );
708
+ ) });
435
709
  }
436
- function ze({
710
+ function Lt({
437
711
  data: e,
438
- today: o,
439
- cardHeadingLevel: l
712
+ today: t,
713
+ cardHeadingLevel: i
440
714
  }) {
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,
715
+ const { modules: a, expandedModuleIds: o, toggleModule: u, getItems: s, can: r } = e, d = lt() === "module";
716
+ return /* @__PURE__ */ n("ul", { style: { listStyle: "none", margin: 0, padding: 0 }, "data-testid": "edit-modules-stack", children: a.map((l) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ n(
717
+ At,
444
718
  {
445
- module: n,
446
- expanded: s.includes(n.id),
719
+ module: l,
720
+ expanded: !d && o.includes(l.id),
447
721
  onToggle: u,
448
- itemsState: c(n.id),
449
- today: o,
450
- headingLevel: l
722
+ itemsState: s(l.id),
723
+ today: t,
724
+ canReorderModules: r.reorderModules,
725
+ canReorderItems: r.reorderModuleItems,
726
+ headingLevel: i
451
727
  }
452
- ) }, n.id)) });
728
+ ) }, l.id)) });
453
729
  }
454
- function ut({
730
+ function tn({
455
731
  data: e,
456
- today: o,
457
- as: l = "div",
458
- headingLevel: r = "h2"
732
+ today: t,
733
+ as: i = "div",
734
+ headingLevel: a = "h2"
459
735
  }) {
460
- const { t: s } = w(), {
736
+ const { t: o } = w(), {
461
737
  modules: u,
462
- page: c,
463
- pageCount: n,
464
- goToFirstPage: i,
465
- goToPreviousPage: a,
738
+ page: s,
739
+ pageCount: r,
740
+ goToFirstPage: d,
741
+ goToPreviousPage: l,
466
742
  goToNextPage: p,
467
- goToLastPage: d,
743
+ goToLastPage: c,
468
744
  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();
745
+ isRefreshing: M,
746
+ error: f
747
+ } = e, [I] = X(() => /* @__PURE__ */ new Date()), g = a === "h1" ? "h2" : "h3", h = m || M && u.length === 0, R = u.length === 0 && !h && !f, C = (y) => {
748
+ y === 1 ? d() : y === s - 1 ? l() : y === s + 1 ? p() : y === r && c();
473
749
  };
474
- return /* @__PURE__ */ f(y, { as: l, display: "block", "data-testid": "modules-edit-view", children: [
475
- M ? /* @__PURE__ */ t(
476
- x,
750
+ return /* @__PURE__ */ v(k, { as: i, display: "block", "data-testid": "modules-edit-view", children: [
751
+ f ? /* @__PURE__ */ n(
752
+ ne,
477
753
  {
478
754
  variant: "error",
479
755
  margin: "0 0 small 0",
480
- liveRegion: H,
756
+ liveRegion: te,
481
757
  liveRegionPoliteness: "assertive",
482
758
  "data-testid": "edit-modules-error",
483
- children: s("modulesLoadErrorAlert", { message: M.message })
759
+ children: o("modulesLoadErrorAlert", { message: f.message })
484
760
  }
485
761
  ) : 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,
762
+ h ? /* @__PURE__ */ n(k, { as: "div", padding: "large", textAlign: "center", "data-testid": "edit-modules-loading", children: /* @__PURE__ */ n(re, { renderTitle: o("modulesLoadingSpinnerLabel") }) }) : null,
763
+ R ? /* @__PURE__ */ v(
764
+ k,
489
765
  {
490
766
  as: "div",
491
767
  background: "primary",
@@ -496,75 +772,81 @@ function ut({
496
772
  textAlign: "center",
497
773
  "data-testid": "edit-modules-empty",
498
774
  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") })
775
+ /* @__PURE__ */ n(ie, { level: g, variant: "titleCardLarge", margin: "0 0 x-small 0", children: o("editNoModulesTitle") }),
776
+ /* @__PURE__ */ n(L, { color: "secondary", children: o("editNoModulesDescription") })
501
777
  ]
502
778
  }
503
779
  ) : null,
504
- /* @__PURE__ */ t(
505
- ze,
780
+ /* @__PURE__ */ n(ht, { data: e, children: /* @__PURE__ */ n(
781
+ Lt,
506
782
  {
507
783
  data: e,
508
- today: o ?? P,
509
- cardHeadingLevel: I
784
+ today: t ?? I,
785
+ cardHeadingLevel: g
510
786
  }
511
- ),
512
- n > 1 && !v ? /* @__PURE__ */ t(
513
- V,
787
+ ) }),
788
+ r > 1 && !h ? /* @__PURE__ */ n(
789
+ oe,
514
790
  {
515
791
  as: "nav",
516
792
  variant: "compact",
517
793
  withFirstAndLastButton: !0,
518
794
  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,
795
+ labelFirst: o("paginationFirstPage"),
796
+ labelPrev: o("paginationPreviousPage"),
797
+ labelNext: o("paginationNextPage"),
798
+ labelLast: o("paginationLastPage"),
799
+ screenReaderLabelPageButton: (y) => o("paginationPageLabel", { page: y }),
800
+ ellipsis: o("paginationEllipsis"),
801
+ totalPageNumber: r,
802
+ currentPage: s,
803
+ disabled: M,
804
+ onPageChange: C,
529
805
  "data-testid": "edit-modules-pagination"
530
806
  }
531
807
  ) : null
532
808
  ] });
533
809
  }
534
- function je(e) {
810
+ function wt(e) {
535
811
  return null;
536
812
  }
537
- function Ue(e) {
813
+ function Rt(e) {
538
814
  return null;
539
815
  }
540
- function We(e) {
816
+ function St(e) {
541
817
  return null;
542
818
  }
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 }));
819
+ function nn({ data: e }) {
820
+ const { t } = w(), i = Re(), { expandedModuleIds: a, collapseAllModules: o, isPersistingCollapsed: u } = e, s = a.length, r = () => {
821
+ i("collapse-all"), o(), ee(t("modulesCollapsedAnnouncement", { count: s }));
546
822
  };
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,
823
+ return /* @__PURE__ */ v(b, { gap: "x-small", wrap: "wrap", justifyItems: "end", "data-testid": "modules-edit-actions", children: [
824
+ /* @__PURE__ */ n(b.Item, { children: /* @__PURE__ */ n(
825
+ Ke,
550
826
  {
551
827
  size: "small",
552
- onClick: n,
553
- interaction: c === 0 || u ? "disabled" : "enabled",
828
+ onClick: r,
829
+ interaction: s === 0 || u ? "disabled" : "enabled",
554
830
  "data-testid": "edit-collapse-all",
555
- children: o("collapseAllModules")
831
+ children: t("collapseAllModules")
556
832
  }
557
833
  ) }),
558
- /* @__PURE__ */ t(We, { data: e }),
559
- /* @__PURE__ */ t(je, { data: e }),
560
- /* @__PURE__ */ t(Ue, { data: e })
834
+ /* @__PURE__ */ n(St, { data: e }),
835
+ /* @__PURE__ */ n(wt, { data: e }),
836
+ /* @__PURE__ */ n(Rt, { data: e })
561
837
  ] });
562
838
  }
563
839
  export {
564
- $e as EditModuleCard,
565
- _e as EditModuleItemRow,
566
- ct as ModulesEditActions,
567
- ut as ModulesEditView,
568
- at as createInMemoryEditAdapter,
569
- dt as useModulesEditData
840
+ ht as EditDndProvider,
841
+ At as EditModuleCard,
842
+ Pt as EditModuleItemRow,
843
+ nn as ModulesEditActions,
844
+ tn as ModulesEditView,
845
+ Jt as createInMemoryEditAdapter,
846
+ D as dragDataOf,
847
+ en as externalDragId,
848
+ ce as itemDragId,
849
+ le as moduleDragId,
850
+ lt as useActiveDragKind,
851
+ Zt as useModulesEditData
570
852
  };