@instructure/platform-rubrics 0.7.2 → 1.0.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 (39) hide show
  1. package/dist/_internal/RubricAssessment/components/TraditionalViewCriterionPoints.d.ts.map +1 -1
  2. package/dist/_internal/ViewRubrics/useRubricsQuery.d.ts.map +1 -1
  3. package/dist/_internal/ViewRubrics/useViewRubrics.d.ts.map +1 -1
  4. package/dist/_internal/constants/i18n.d.ts +49 -0
  5. package/dist/_internal/constants/i18n.d.ts.map +1 -1
  6. package/dist/canvas.js +6169 -10802
  7. package/dist/chunks/ErrorShip-DEitKD2c.js +5340 -0
  8. package/dist/chunks/{errorPage-CMPx9rIp.js → errorPage-Jon3K-u6.js} +65 -55
  9. package/dist/chunks/useLocalStorage-BoUaI48x.js +41 -0
  10. package/dist/foundation/RubricBuilder/RubricBuilder.d.ts +11 -0
  11. package/dist/foundation/RubricBuilder/RubricBuilder.d.ts.map +1 -0
  12. package/dist/foundation/RubricBuilder/components/ConfirmModal.d.ts +12 -0
  13. package/dist/foundation/RubricBuilder/components/ConfirmModal.d.ts.map +1 -0
  14. package/dist/foundation/RubricBuilder/components/CriteriaSection.d.ts +9 -0
  15. package/dist/foundation/RubricBuilder/components/CriteriaSection.d.ts.map +1 -0
  16. package/dist/foundation/RubricBuilder/components/RubricBuilderFooter.d.ts +7 -0
  17. package/dist/foundation/RubricBuilder/components/RubricBuilderFooter.d.ts.map +1 -0
  18. package/dist/foundation/RubricBuilder/components/RubricBuilderHeader.d.ts +7 -0
  19. package/dist/foundation/RubricBuilder/components/RubricBuilderHeader.d.ts.map +1 -0
  20. package/dist/foundation/RubricBuilder/components/RubricDetailsCard.d.ts +10 -0
  21. package/dist/foundation/RubricBuilder/components/RubricDetailsCard.d.ts.map +1 -0
  22. package/dist/foundation/RubricBuilder/components/criteria/CriteriaList.d.ts +18 -0
  23. package/dist/foundation/RubricBuilder/components/criteria/CriteriaList.d.ts.map +1 -0
  24. package/dist/foundation/RubricBuilder/components/criteria/CriterionCard.d.ts +21 -0
  25. package/dist/foundation/RubricBuilder/components/criteria/CriterionCard.d.ts.map +1 -0
  26. package/dist/foundation/RubricBuilder/components/criteria/PointsPossibleField.d.ts +6 -0
  27. package/dist/foundation/RubricBuilder/components/criteria/PointsPossibleField.d.ts.map +1 -0
  28. package/dist/foundation/RubricBuilder/components/criteria/RatingList.d.ts +11 -0
  29. package/dist/foundation/RubricBuilder/components/criteria/RatingList.d.ts.map +1 -0
  30. package/dist/foundation/RubricBuilder/components/criteria/RatingRow.d.ts +16 -0
  31. package/dist/foundation/RubricBuilder/components/criteria/RatingRow.d.ts.map +1 -0
  32. package/dist/foundation/index.d.ts +3 -0
  33. package/dist/foundation/index.d.ts.map +1 -1
  34. package/dist/foundation.js +828 -59
  35. package/dist/index.js +8 -8
  36. package/locales/en.json +49 -0
  37. package/package.json +4 -4
  38. package/dist/chunks/helloWorld-DAP1kQju.js +0 -53
  39. package/dist/chunks/useRubricsPlatformUiContext-BNQd8FbG.js +0 -585
@@ -1,19 +1,30 @@
1
- import { g as v } from "./chunks/helloWorld-DAP1kQju.js";
2
- import { D as J, a as Z } from "./chunks/helloWorld-DAP1kQju.js";
1
+ import { g as Le, u as De, R as Pe, r as Te, e as ie, b as Ee } from "./chunks/errorPage-Jon3K-u6.js";
2
+ import { D as ti, a as ni } from "./chunks/errorPage-Jon3K-u6.js";
3
3
  import "@instructure/platform-provider";
4
- import "react";
5
- import { jsx as e, jsxs as n } from "react/jsx-runtime";
6
- import { Heading as x } from "@instructure/ui-heading";
7
- import { View as o } from "@instructure/ui-view";
8
- import { Button as T } from "@instructure/ui-buttons";
9
- import { Flex as f } from "@instructure/ui-flex";
10
- import { SimpleSelect as h } from "@instructure/ui-simple-select";
11
- import { Spinner as C } from "@instructure/ui-spinner";
12
- import { Text as m } from "@instructure/ui-text";
13
- import { useQuery as I } from "@tanstack/react-query";
14
- import { u as R, T as y, t as _, i as E, a as L } from "./chunks/useRubricsPlatformUiContext-BNQd8FbG.js";
15
- import U from "graphql-tag";
16
- const K = () => /* @__PURE__ */ e(o, { as: "div", padding: "small", children: /* @__PURE__ */ e(x, { level: "h2", children: v("foundation") }) }), A = U`
4
+ import { useState as x, useEffect as F, useRef as Z, useCallback as xe } from "react";
5
+ import { jsx as e, jsxs as c, Fragment as ke } from "react/jsx-runtime";
6
+ import { Heading as _ } from "@instructure/ui-heading";
7
+ import { View as h } from "@instructure/ui-view";
8
+ import { Button as N, CloseButton as Ae, IconButton as X } from "@instructure/ui-buttons";
9
+ import { Flex as C } from "@instructure/ui-flex";
10
+ import { SimpleSelect as J } from "@instructure/ui-simple-select";
11
+ import { Spinner as Oe } from "@instructure/ui-spinner";
12
+ import { Text as D } from "@instructure/ui-text";
13
+ import { useQuery as Ne } from "@tanstack/react-query";
14
+ import { u as Me, T as le, t as oe, i as se, a as L, p as _e, b as de, c as te, C as ce, d as ne, e as He, f as ue, g as Y, s as me, K as be, P as ge, r as Ue, D as he, S as pe, v as fe, h as qe, j as Fe, k as ze, l as Ge, m as We, n as $e, o as je, w as ae, q as Ke, x as Qe, y as Ve, z as Xe, A as Ye, B as Je, E as Ze, F as er } from "./chunks/ErrorShip-DEitKD2c.js";
15
+ import rr from "graphql-tag";
16
+ import { LoadingIndicator as ir } from "@instructure/platform-loading-indicator";
17
+ import { Alert as tr } from "@instructure/ui-alerts";
18
+ import { IconDragHandleLine as Ce, IconTrashLine as ve, IconAddLine as Re, IconArrowOpenDownLine as nr, IconArrowOpenEndLine as ar, IconCommentLine as lr, IconDuplicateLine as or } from "@instructure/ui-icons";
19
+ import { Modal as Q } from "@instructure/ui-modal";
20
+ import { ScreenReaderContent as sr } from "@instructure/ui-a11y-content";
21
+ import { Checkbox as dr } from "@instructure/ui-checkbox";
22
+ import { Pill as Be } from "@instructure/ui-pill";
23
+ import { TextArea as cr } from "@instructure/ui-text-area";
24
+ import { TextInput as z } from "@instructure/ui-text-input";
25
+ import { NumberInput as ur } from "@instructure/ui-number-input";
26
+ import { RadioInputGroup as mr, RadioInput as br } from "@instructure/ui-radio-input";
27
+ const Jr = () => /* @__PURE__ */ e(h, { as: "div", padding: "small", children: /* @__PURE__ */ e(_, { level: "h2", children: Le("foundation") }) }), gr = rr`
17
28
  query CourseRubricsList($courseId: ID!, $first: Int) {
18
29
  course(id: $courseId) {
19
30
  rubricsConnection(first: $first) {
@@ -31,74 +42,832 @@ const K = () => /* @__PURE__ */ e(o, { as: "div", padding: "small", children: /*
31
42
  }
32
43
  }
33
44
  `;
34
- function w(t) {
35
- const { executeQuery: a } = R();
36
- return I({
37
- queryKey: ["courseRubrics", t],
45
+ function hr(r) {
46
+ const { executeQuery: a } = Me();
47
+ return Ne({
48
+ queryKey: ["courseRubrics", r],
38
49
  queryFn: async () => {
39
- var i;
40
- const { course: s } = await a(A, {
41
- courseId: t,
50
+ var n;
51
+ const { course: s } = await a(gr, {
52
+ courseId: r,
42
53
  first: 50
43
- }), r = s == null ? void 0 : s.rubricsConnection;
54
+ }), i = s == null ? void 0 : s.rubricsConnection;
44
55
  return {
45
- rubrics: ((r == null ? void 0 : r.nodes) ?? []).filter(
46
- (u) => u != null
56
+ rubrics: ((i == null ? void 0 : i.nodes) ?? []).filter(
57
+ (t) => t != null
47
58
  ),
48
- hasMore: ((i = r == null ? void 0 : r.pageInfo) == null ? void 0 : i.hasNextPage) ?? !1
59
+ hasMore: ((n = i == null ? void 0 : i.pageInfo) == null ? void 0 : n.hasNextPage) ?? !1
49
60
  };
50
61
  },
51
- enabled: !!t
62
+ enabled: !!r
52
63
  });
53
64
  }
54
- const X = (t) => /* @__PURE__ */ e(y, { translations: E, translate: _, children: /* @__PURE__ */ e(z, { ...t }) }), z = ({
55
- courseId: t,
65
+ const Zr = (r) => /* @__PURE__ */ e(le, { translations: se, translate: oe, children: /* @__PURE__ */ e(pr, { ...r }) }), pr = ({
66
+ courseId: r,
56
67
  value: a,
57
68
  onChange: s
58
69
  }) => {
59
- const { translations: r } = L(), { data: i, isLoading: u, isError: b, refetch: g } = w(t), c = i == null ? void 0 : i.rubrics;
60
- return u ? /* @__PURE__ */ n(o, { as: "div", role: "status", "aria-live": "polite", margin: "0 0 medium", children: [
61
- /* @__PURE__ */ e(C, { renderTitle: r.rubricSelectorLoading, size: "x-small" }),
62
- /* @__PURE__ */ e(o, { as: "span", padding: "0 0 0 x-small", children: /* @__PURE__ */ e(m, { size: "small", children: r.rubricSelectorLoading }) })
63
- ] }) : b ? /* @__PURE__ */ e(o, { as: "div", margin: "0 0 medium", children: /* @__PURE__ */ n(f, { gap: "small", alignItems: "center", wrap: "wrap", children: [
64
- /* @__PURE__ */ e(f.Item, { children: /* @__PURE__ */ n(m, { size: "small", color: "danger", children: [
65
- r.rubricSelectorErrorTitle,
70
+ const { translations: i } = L(), { data: n, isLoading: t, isError: l, refetch: o } = hr(r), u = n == null ? void 0 : n.rubrics;
71
+ return t ? /* @__PURE__ */ c(h, { as: "div", role: "status", "aria-live": "polite", margin: "0 0 medium", children: [
72
+ /* @__PURE__ */ e(Oe, { renderTitle: i.rubricSelectorLoading, size: "x-small" }),
73
+ /* @__PURE__ */ e(h, { as: "span", padding: "0 0 0 x-small", children: /* @__PURE__ */ e(D, { size: "small", children: i.rubricSelectorLoading }) })
74
+ ] }) : l ? /* @__PURE__ */ e(h, { as: "div", margin: "0 0 medium", children: /* @__PURE__ */ c(C, { gap: "small", alignItems: "center", wrap: "wrap", children: [
75
+ /* @__PURE__ */ e(C.Item, { children: /* @__PURE__ */ c(D, { size: "small", color: "danger", children: [
76
+ i.rubricSelectorErrorTitle,
66
77
  ". ",
67
- r.rubricSelectorErrorBody
78
+ i.rubricSelectorErrorBody
68
79
  ] }) }),
69
- /* @__PURE__ */ e(f.Item, { children: /* @__PURE__ */ e(T, { size: "small", onClick: () => g(), children: r.rubricSelectorRetry }) })
70
- ] }) }) : !c || c.length === 0 ? /* @__PURE__ */ e(o, { as: "div", margin: "0 0 medium", children: /* @__PURE__ */ e(m, { size: "small", children: r.rubricSelectorEmpty }) }) : /* @__PURE__ */ n(o, { as: "div", margin: "0 0 medium", maxWidth: "360px", children: [
71
- /* @__PURE__ */ n(
72
- h,
80
+ /* @__PURE__ */ e(C.Item, { children: /* @__PURE__ */ e(N, { size: "small", onClick: () => o(), children: i.rubricSelectorRetry }) })
81
+ ] }) }) : !u || u.length === 0 ? /* @__PURE__ */ e(h, { as: "div", margin: "0 0 medium", children: /* @__PURE__ */ e(D, { size: "small", children: i.rubricSelectorEmpty }) }) : /* @__PURE__ */ c(h, { as: "div", margin: "0 0 medium", maxWidth: "360px", children: [
82
+ /* @__PURE__ */ c(
83
+ J,
73
84
  {
74
- renderLabel: r.rubricSelectorLabel,
75
- assistiveText: r.rubricSelectorAssistiveText,
85
+ renderLabel: i.rubricSelectorLabel,
86
+ assistiveText: i.rubricSelectorAssistiveText,
76
87
  value: a ?? "",
77
- onChange: (l, { value: d }) => {
78
- if (typeof d != "string" || !d) return;
79
- const p = c.find((S) => S.id === d);
80
- s(d, (p == null ? void 0 : p.title) ?? "");
88
+ onChange: (b, { value: p }) => {
89
+ if (typeof p != "string" || !p) return;
90
+ const g = u.find((d) => d.id === p);
91
+ s(p, (g == null ? void 0 : g.title) ?? "");
81
92
  },
82
93
  children: [
83
- a === void 0 && /* @__PURE__ */ e(h.Option, { id: "rubrics-rubric-selector-placeholder", value: "", children: r.rubricSelectorPlaceholder }),
84
- c.map((l) => /* @__PURE__ */ e(
85
- h.Option,
94
+ a === void 0 && /* @__PURE__ */ e(J.Option, { id: "rubrics-rubric-selector-placeholder", value: "", children: i.rubricSelectorPlaceholder }),
95
+ u.map((b) => /* @__PURE__ */ e(
96
+ J.Option,
86
97
  {
87
- id: `rubrics-rubric-selector-option-${l.id}`,
88
- value: l.id,
89
- children: l.title || r.rubricSelectorUntitled
98
+ id: `rubrics-rubric-selector-option-${b.id}`,
99
+ value: b.id,
100
+ children: b.title || i.rubricSelectorUntitled
90
101
  },
91
- l.id
102
+ b.id
92
103
  ))
93
104
  ]
94
105
  }
95
106
  ),
96
- (i == null ? void 0 : i.hasMore) && /* @__PURE__ */ e(o, { as: "div", padding: "xx-small 0 0", children: /* @__PURE__ */ e(m, { size: "x-small", color: "secondary", children: r.rubricSelectorTruncated }) })
107
+ (n == null ? void 0 : n.hasMore) && /* @__PURE__ */ e(h, { as: "div", padding: "xx-small 0 0", children: /* @__PURE__ */ e(D, { size: "x-small", color: "secondary", children: i.rubricSelectorTruncated }) })
108
+ ] });
109
+ }, ee = ({
110
+ isOpen: r,
111
+ heading: a,
112
+ body: s,
113
+ confirmLabel: i,
114
+ cancelLabel: n,
115
+ onConfirm: t,
116
+ onDismiss: l,
117
+ "data-testid": o
118
+ }) => {
119
+ const { translations: u } = L();
120
+ return /* @__PURE__ */ c(Q, { open: r, onDismiss: l, size: "small", label: a, "data-testid": o, children: [
121
+ /* @__PURE__ */ c(Q.Header, { children: [
122
+ /* @__PURE__ */ e(
123
+ Ae,
124
+ {
125
+ placement: "end",
126
+ offset: "small",
127
+ onClick: l,
128
+ screenReaderLabel: u.close
129
+ }
130
+ ),
131
+ /* @__PURE__ */ e(_, { level: "h2", children: a })
132
+ ] }),
133
+ /* @__PURE__ */ e(Q.Body, { children: /* @__PURE__ */ e(D, { children: s }) }),
134
+ /* @__PURE__ */ c(Q.Footer, { children: [
135
+ /* @__PURE__ */ e(N, { onClick: l, margin: "0 x-small 0 0", children: n }),
136
+ /* @__PURE__ */ e(N, { color: "primary", onClick: t, "data-testid": "confirm-modal-confirm", children: i })
137
+ ] })
138
+ ] });
139
+ }, fr = ({
140
+ criteriaCount: r,
141
+ showMissingCriteriaError: a,
142
+ actions: s,
143
+ children: i
144
+ }) => {
145
+ const { translations: n } = L();
146
+ return /* @__PURE__ */ c(h, { as: "section", "aria-labelledby": "rubric-builder-criteria-heading", children: [
147
+ /* @__PURE__ */ c(C, { justifyItems: "space-between", alignItems: "center", wrap: "wrap", gap: "small", children: [
148
+ /* @__PURE__ */ e(_, { level: "h3", id: "rubric-builder-criteria-heading", children: n.rubricBuilderCriteriaHeading }),
149
+ s && /* @__PURE__ */ e(C, { gap: "small", wrap: "wrap", children: s })
150
+ ] }),
151
+ /* @__PURE__ */ e(h, { as: "div", margin: "small 0 0", children: r === 0 ? /* @__PURE__ */ e(D, { color: "secondary", children: n.rubricBuilderCriteriaEmpty }) : i }),
152
+ /* @__PURE__ */ e("div", { "aria-live": "polite", children: a && r === 0 && /* @__PURE__ */ e(D, { color: "danger", "data-testid": "rubric-builder-criteria-error", children: n.rubricBuilderAddCriterionError }) })
153
+ ] });
154
+ }, Cr = ({ points: r, onCommit: a }) => {
155
+ const { translations: s } = L(), [i, n] = x(String(r));
156
+ return F(() => {
157
+ n(String(r));
158
+ }, [r]), /* @__PURE__ */ e(
159
+ z,
160
+ {
161
+ renderLabel: s.rubricBuilderPointsPossibleLabel,
162
+ width: "8rem",
163
+ value: i,
164
+ onChange: (t) => n(t.target.value),
165
+ onBlur: (t) => {
166
+ const l = _e(t.target.value);
167
+ n(String(l)), l !== r && a(l);
168
+ },
169
+ "data-testid": "rubric-builder-points-possible"
170
+ }
171
+ );
172
+ }, vr = ({
173
+ rating: r,
174
+ sortableId: a,
175
+ position: s,
176
+ rangeStart: i,
177
+ useRange: n,
178
+ hidePoints: t,
179
+ showNameError: l,
180
+ canRemove: o,
181
+ onChange: u,
182
+ onPointsBlur: b,
183
+ onRemove: p
184
+ }) => {
185
+ const { translations: g, translate: d } = L(), { attributes: v, listeners: y, setNodeRef: f, transform: I, transition: k } = de({
186
+ id: a
187
+ }), [T, S] = x(String(r.points));
188
+ F(() => {
189
+ te(T) !== r.points && S(String(r.points));
190
+ }, [r.points]);
191
+ const B = (R, P) => {
192
+ S(P), u({ ...r, points: R });
193
+ };
194
+ return /* @__PURE__ */ e(
195
+ "div",
196
+ {
197
+ ref: f,
198
+ style: { transform: ce.Transform.toString(I), transition: k },
199
+ "data-testid": "rubric-builder-rating-row",
200
+ children: /* @__PURE__ */ c(C, { gap: "small", alignItems: "start", wrap: "wrap", margin: "0 0 small", children: [
201
+ /* @__PURE__ */ e(
202
+ h,
203
+ {
204
+ as: "div",
205
+ cursor: "grab",
206
+ margin: "medium 0 0",
207
+ "aria-label": d("rubricBuilderReorderRating", { position: s }),
208
+ ...v,
209
+ ...y,
210
+ children: /* @__PURE__ */ e(Ce, { "aria-hidden": "true" })
211
+ }
212
+ ),
213
+ /* @__PURE__ */ e(h, { as: "div", minWidth: "1.5rem", margin: "medium 0 0", children: /* @__PURE__ */ e(D, { weight: "bold", "aria-hidden": "true", children: s }) }),
214
+ !t && /* @__PURE__ */ c(C, { gap: "x-small", alignItems: "end", children: [
215
+ n && i !== void 0 && /* @__PURE__ */ e(h, { as: "div", margin: "0 0 x-small", children: /* @__PURE__ */ e(D, { children: d("rangeStartPrefix", { rangeStart: i }) }) }),
216
+ /* @__PURE__ */ e(
217
+ ur,
218
+ {
219
+ renderLabel: n ? g.rubricBuilderPointRangeLabel : g.rubricBuilderPointsLabel,
220
+ allowStringValue: !0,
221
+ showArrows: !1,
222
+ width: "6rem",
223
+ value: T,
224
+ onChange: (R, P) => {
225
+ He(P) && B(te(P), P);
226
+ },
227
+ onIncrement: () => {
228
+ const R = ne(Math.floor(r.points) + 1);
229
+ B(R, String(R));
230
+ },
231
+ onDecrement: () => {
232
+ const R = ne(Math.floor(r.points) - 1);
233
+ B(R, String(R));
234
+ },
235
+ onBlur: b,
236
+ "data-testid": "rubric-builder-rating-points"
237
+ }
238
+ )
239
+ ] }),
240
+ /* @__PURE__ */ e(C.Item, { shouldGrow: !0, shouldShrink: !0, size: "10rem", children: /* @__PURE__ */ e(
241
+ z,
242
+ {
243
+ renderLabel: g.rubricBuilderRatingNameLabel,
244
+ isRequired: !0,
245
+ value: r.description,
246
+ onChange: (R) => u({ ...r, description: R.target.value }),
247
+ messages: l ? [{ text: g.rubricBuilderRatingNameRequired, type: "error" }] : [],
248
+ "data-testid": "rubric-builder-rating-name"
249
+ }
250
+ ) }),
251
+ /* @__PURE__ */ e(C.Item, { shouldGrow: !0, shouldShrink: !0, size: "14rem", children: /* @__PURE__ */ e(
252
+ z,
253
+ {
254
+ renderLabel: g.rubricBuilderRatingDescriptionLabel,
255
+ value: r.longDescription,
256
+ onChange: (R) => u({ ...r, longDescription: R.target.value }),
257
+ "data-testid": "rubric-builder-rating-description"
258
+ }
259
+ ) }),
260
+ o && /* @__PURE__ */ e(h, { as: "div", margin: "medium 0 0", children: /* @__PURE__ */ e(
261
+ X,
262
+ {
263
+ screenReaderLabel: d("rubricBuilderRemoveRating", { position: s }),
264
+ withBackground: !1,
265
+ withBorder: !1,
266
+ onClick: p,
267
+ "data-testid": "rubric-builder-remove-rating",
268
+ children: /* @__PURE__ */ e(ve, {})
269
+ }
270
+ ) })
271
+ ] })
272
+ }
273
+ );
274
+ }, Rr = ({
275
+ ratings: r,
276
+ useRange: a,
277
+ hidePoints: s,
278
+ ratingOrder: i,
279
+ ratingNamesRequired: n,
280
+ onChange: t
281
+ }) => {
282
+ const { translations: l } = L(), o = ue(
283
+ Y(ge, { activationConstraint: { distance: 8 } }),
284
+ Y(be, { coordinateGetter: me })
285
+ ), u = r.map(Ue), b = i === "ascending", p = r.map((d, v) => b ? r.length - 1 - v : v);
286
+ return /* @__PURE__ */ c(h, { as: "div", children: [
287
+ /* @__PURE__ */ e(he, { sensors: o, onDragEnd: ({ active: d, over: v }) => {
288
+ if (!v || d.id === v.id) return;
289
+ const y = u.indexOf(String(d.id)), f = u.indexOf(String(v.id));
290
+ y === -1 || f === -1 || t($e({ list: r, startIndex: y, endIndex: f }));
291
+ }, children: /* @__PURE__ */ e(
292
+ pe,
293
+ {
294
+ items: p.map((d) => u[d]),
295
+ strategy: fe,
296
+ children: p.map((d, v) => /* @__PURE__ */ e(
297
+ vr,
298
+ {
299
+ rating: r[d],
300
+ sortableId: u[d],
301
+ position: v + 1,
302
+ rangeStart: qe(r, d),
303
+ useRange: a,
304
+ hidePoints: s,
305
+ showNameError: n.includes(d),
306
+ canRemove: r.length > 1,
307
+ onChange: (y) => t(Ge(r, d, y)),
308
+ onPointsBlur: () => t(ze(r)),
309
+ onRemove: () => t(Fe(r, d))
310
+ },
311
+ u[d]
312
+ ))
313
+ }
314
+ ) }),
315
+ /* @__PURE__ */ e(
316
+ N,
317
+ {
318
+ renderIcon: /* @__PURE__ */ e(Re, {}),
319
+ withBackground: !1,
320
+ onClick: () => t(We(r, b ? 0 : r.length)),
321
+ "data-testid": "rubric-builder-add-rating",
322
+ children: l.rubricBuilderAddRatingLevel
323
+ }
324
+ )
325
+ ] });
326
+ }, Br = ({
327
+ criterion: r,
328
+ sortableId: a,
329
+ position: s,
330
+ hidePoints: i,
331
+ freeFormCriterionComments: n,
332
+ ratingOrder: t,
333
+ errors: l,
334
+ showErrors: o,
335
+ shouldFocusName: u,
336
+ shouldFocusHandle: b,
337
+ onNameFocused: p,
338
+ onHandleFocused: g,
339
+ onChange: d,
340
+ onDuplicate: v,
341
+ onDelete: y
342
+ }) => {
343
+ const { translations: f, translate: I } = L(), { rubricCriterionRange: k } = De(), { attributes: T, listeners: S, setNodeRef: B, transform: R, transition: P, isDragging: H } = de({
344
+ id: a
345
+ }), [E, G] = x(!r.description.trim()), [W, M] = x(!1), $ = Z(null), j = Z(null), U = o && je(l), K = I("rubricBuilderCriterionHeading", { position: s }), A = r.description.trim(), O = A || K, q = `rubric-builder-criterion-body-${a}`;
346
+ return F(() => {
347
+ U && G(!0);
348
+ }, [U]), F(() => {
349
+ var m;
350
+ u && E && ((m = $.current) == null || m.focus(), p());
351
+ }, [u, E, p]), F(() => {
352
+ var m;
353
+ b && ((m = j.current) == null || m.focus(), g());
354
+ }, [b, g]), /* @__PURE__ */ c(
355
+ "div",
356
+ {
357
+ ref: B,
358
+ style: { transform: ce.Transform.toString(R), transition: P },
359
+ "data-testid": "rubric-builder-criterion-card",
360
+ children: [
361
+ /* @__PURE__ */ c(
362
+ h,
363
+ {
364
+ as: "section",
365
+ "aria-label": O,
366
+ borderWidth: "small",
367
+ borderRadius: "medium",
368
+ padding: "small medium",
369
+ margin: "0 0 small",
370
+ background: "primary",
371
+ shadow: H ? "above" : "none",
372
+ children: [
373
+ /* @__PURE__ */ c(C, { gap: "small", alignItems: "center", wrap: "wrap", children: [
374
+ /* @__PURE__ */ e(
375
+ "div",
376
+ {
377
+ ref: j,
378
+ "aria-label": I("rubricBuilderReorderCriterion", { name: O }),
379
+ "data-testid": "rubric-builder-criterion-drag-handle",
380
+ ...T,
381
+ ...S,
382
+ children: /* @__PURE__ */ e(Ce, { "aria-hidden": "true" })
383
+ }
384
+ ),
385
+ /* @__PURE__ */ e(
386
+ X,
387
+ {
388
+ screenReaderLabel: I(
389
+ E ? "rubricBuilderCollapseCriterion" : "rubricBuilderExpandCriterion",
390
+ { name: O }
391
+ ),
392
+ "aria-expanded": E,
393
+ "aria-controls": q,
394
+ withBackground: !1,
395
+ withBorder: !1,
396
+ size: "small",
397
+ onClick: () => G((m) => !m),
398
+ "data-testid": "rubric-builder-criterion-toggle",
399
+ children: E ? /* @__PURE__ */ e(nr, {}) : /* @__PURE__ */ e(ar, {})
400
+ }
401
+ ),
402
+ n && /* @__PURE__ */ e(
403
+ lr,
404
+ {
405
+ title: f.rubricBuilderWrittenFeedback,
406
+ "data-testid": "rubric-builder-criterion-written-icon"
407
+ }
408
+ ),
409
+ /* @__PURE__ */ e(C.Item, { shouldGrow: !0, shouldShrink: !0, children: /* @__PURE__ */ c(_, { level: "h4", children: [
410
+ K,
411
+ A && /* @__PURE__ */ e(D, { weight: "normal", "data-testid": "rubric-builder-criterion-name", children: `: ${A}` })
412
+ ] }) }),
413
+ !i && /* @__PURE__ */ e(Be, { "data-testid": "rubric-builder-criterion-max", children: I("rubricBuilderCriterionMaxPoints", { count: r.points }) }),
414
+ /* @__PURE__ */ e(
415
+ X,
416
+ {
417
+ screenReaderLabel: I("rubricBuilderDuplicateCriterion", { name: O }),
418
+ withBackground: !1,
419
+ withBorder: !1,
420
+ onClick: v,
421
+ "data-testid": "rubric-builder-duplicate-criterion",
422
+ children: /* @__PURE__ */ e(or, {})
423
+ }
424
+ ),
425
+ /* @__PURE__ */ e(
426
+ X,
427
+ {
428
+ screenReaderLabel: I("rubricBuilderDeleteCriterion", { name: O }),
429
+ withBackground: !1,
430
+ withBorder: !1,
431
+ onClick: () => M(!0),
432
+ "data-testid": "rubric-builder-delete-criterion",
433
+ children: /* @__PURE__ */ e(ve, {})
434
+ }
435
+ )
436
+ ] }),
437
+ E && /* @__PURE__ */ e(h, { as: "div", id: q, margin: "medium 0 0", children: /* @__PURE__ */ c(C, { direction: "column", gap: "medium", children: [
438
+ /* @__PURE__ */ e(
439
+ z,
440
+ {
441
+ renderLabel: f.rubricBuilderCriterionNameLabel,
442
+ isRequired: !0,
443
+ value: r.description,
444
+ inputRef: (m) => {
445
+ $.current = m;
446
+ },
447
+ onChange: (m) => d({ ...r, description: m.target.value }),
448
+ messages: o && l.nameRequired ? [{ text: f.rubricBuilderCriterionNameRequired, type: "error" }] : [],
449
+ "data-testid": "rubric-builder-criterion-name-input"
450
+ }
451
+ ),
452
+ /* @__PURE__ */ e(
453
+ cr,
454
+ {
455
+ label: f.rubricBuilderCriterionDescriptionLabel,
456
+ value: r.longDescription ?? "",
457
+ onChange: (m) => d({ ...r, longDescription: m.target.value }),
458
+ "data-testid": "rubric-builder-criterion-description"
459
+ }
460
+ ),
461
+ k && !i && !n && /* @__PURE__ */ e(
462
+ dr,
463
+ {
464
+ variant: "toggle",
465
+ label: f.rubricBuilderEnableRange,
466
+ checked: r.criterionUseRange,
467
+ onChange: (m) => d({ ...r, criterionUseRange: m.target.checked }),
468
+ "data-testid": "rubric-builder-enable-range"
469
+ }
470
+ ),
471
+ n ? !i && /* @__PURE__ */ e(
472
+ Cr,
473
+ {
474
+ points: r.points,
475
+ onCommit: (m) => d(
476
+ ae(
477
+ r,
478
+ Ke(r.ratings, m)
479
+ )
480
+ )
481
+ }
482
+ ) : /* @__PURE__ */ e(
483
+ Rr,
484
+ {
485
+ ratings: r.ratings,
486
+ useRange: r.criterionUseRange && !i,
487
+ hidePoints: i,
488
+ ratingOrder: t,
489
+ ratingNamesRequired: o ? l.ratingNamesRequired : [],
490
+ onChange: (m) => d(ae(r, m))
491
+ }
492
+ )
493
+ ] }) })
494
+ ]
495
+ }
496
+ ),
497
+ /* @__PURE__ */ e(
498
+ ee,
499
+ {
500
+ isOpen: W,
501
+ heading: f.rubricBuilderCriterionDeleteHeading,
502
+ body: f.rubricBuilderCriterionDeleteBody,
503
+ confirmLabel: f.delete,
504
+ cancelLabel: f.cancel,
505
+ onConfirm: () => {
506
+ M(!1), y();
507
+ },
508
+ onDismiss: () => M(!1),
509
+ "data-testid": "rubric-builder-delete-criterion-modal"
510
+ }
511
+ )
512
+ ]
513
+ }
514
+ );
515
+ }, Sr = ({
516
+ criteria: r,
517
+ hidePoints: a,
518
+ freeFormCriterionComments: s,
519
+ ratingOrder: i,
520
+ criteriaValidationErrors: n,
521
+ showErrors: t,
522
+ focusNameCriterionId: l,
523
+ onFocusedName: o,
524
+ onChangeCriterion: u,
525
+ onDuplicateCriterion: b,
526
+ onDeleteCriterion: p,
527
+ onReorderCriteria: g
528
+ }) => {
529
+ const {
530
+ sortableIds: d,
531
+ movedCriterionId: v,
532
+ clearMovedCriterion: y,
533
+ srAnnouncement: f,
534
+ moveCriterionBySortableId: I
535
+ } = Qe({ criteria: r, onReorderCriteria: g }), k = ue(
536
+ Y(ge, { activationConstraint: { distance: 8 } }),
537
+ Y(be, { coordinateGetter: me })
538
+ );
539
+ return /* @__PURE__ */ c(ke, { children: [
540
+ /* @__PURE__ */ e(sr, { children: /* @__PURE__ */ e("div", { "aria-live": "polite", "aria-atomic": "true", children: f }) }),
541
+ /* @__PURE__ */ e(he, { sensors: k, onDragEnd: ({ active: S, over: B }) => {
542
+ B && I(S.id, B.id);
543
+ }, children: /* @__PURE__ */ e(pe, { items: d, strategy: fe, children: r.map((S, B) => /* @__PURE__ */ e(
544
+ Br,
545
+ {
546
+ criterion: S,
547
+ sortableId: d[B],
548
+ position: B + 1,
549
+ hidePoints: a,
550
+ freeFormCriterionComments: s,
551
+ ratingOrder: i,
552
+ errors: n[B],
553
+ showErrors: t,
554
+ shouldFocusName: S.id === l,
555
+ shouldFocusHandle: S.id === v,
556
+ onNameFocused: o,
557
+ onHandleFocused: y,
558
+ onChange: u,
559
+ onDuplicate: () => b(S),
560
+ onDelete: () => p(S)
561
+ },
562
+ d[B]
563
+ )) }) })
564
+ ] });
565
+ }, yr = ({
566
+ savePending: r,
567
+ onDiscard: a,
568
+ onSave: s
569
+ }) => {
570
+ const { translations: i } = L();
571
+ return /* @__PURE__ */ e(
572
+ h,
573
+ {
574
+ as: "footer",
575
+ position: "sticky",
576
+ insetBlockEnd: "0",
577
+ background: "primary",
578
+ borderWidth: "small none none none",
579
+ padding: "small 0",
580
+ stacking: "above",
581
+ children: /* @__PURE__ */ c(C, { justifyItems: "end", gap: "small", wrap: "wrap", children: [
582
+ /* @__PURE__ */ e(N, { onClick: a, "data-testid": "rubric-builder-discard", children: i.rubricBuilderDiscard }),
583
+ /* @__PURE__ */ e(
584
+ N,
585
+ {
586
+ color: "primary",
587
+ onClick: s,
588
+ interaction: r ? "disabled" : "enabled",
589
+ "data-testid": "rubric-builder-save",
590
+ children: i.rubricBuilderSave
591
+ }
592
+ )
593
+ ] })
594
+ }
595
+ );
596
+ }, Ir = ({
597
+ isNewRubric: r,
598
+ pointsPossible: a,
599
+ hidePoints: s
600
+ }) => {
601
+ const { translations: i, translate: n } = L();
602
+ return /* @__PURE__ */ c(C, { as: "header", justifyItems: "space-between", alignItems: "center", wrap: "wrap", gap: "small", children: [
603
+ /* @__PURE__ */ e(_, { level: "h2", children: r ? i.rubricBuilderCreateTitle : i.rubricBuilderEditTitle }),
604
+ !s && /* @__PURE__ */ e(Be, { "data-testid": "rubric-builder-current-total", children: n("rubricBuilderCurrentTotal", { count: a }) })
605
+ ] });
606
+ }, V = ({ name: r, label: a, value: s, options: i, onChange: n }) => /* @__PURE__ */ e(
607
+ mr,
608
+ {
609
+ name: r,
610
+ description: a,
611
+ variant: "toggle",
612
+ layout: "columns",
613
+ value: s,
614
+ onChange: (t, l) => n(l),
615
+ children: i.map((t) => /* @__PURE__ */ e(br, { value: t.value, label: t.label }, t.value))
616
+ }
617
+ ), wr = ({
618
+ rubricForm: r,
619
+ setRubricFormField: a,
620
+ validateTitle: s,
621
+ titleError: i,
622
+ titleInputRef: n
623
+ }) => {
624
+ const { translations: t } = L(), l = (o) => {
625
+ if (o === "unscored" === r.hidePoints) return;
626
+ const { hidePoints: u, hideScoreTotal: b, useForGrading: p, buttonDisplay: g } = Ve(
627
+ r.hidePoints
628
+ );
629
+ a("hidePoints", u), a("hideScoreTotal", b), a("useForGrading", p), g && a("buttonDisplay", g);
630
+ };
631
+ return /* @__PURE__ */ c(
632
+ h,
633
+ {
634
+ as: "section",
635
+ "aria-labelledby": "rubric-builder-details-heading",
636
+ borderWidth: "small",
637
+ borderRadius: "medium",
638
+ padding: "medium",
639
+ children: [
640
+ /* @__PURE__ */ e(_, { level: "h3", id: "rubric-builder-details-heading", margin: "0 0 medium", children: t.rubricBuilderDetailsHeading }),
641
+ /* @__PURE__ */ c(C, { direction: "column", gap: "medium", children: [
642
+ /* @__PURE__ */ e(
643
+ z,
644
+ {
645
+ "data-testid": "rubric-builder-name",
646
+ renderLabel: t.rubricBuilderNameLabel,
647
+ isRequired: !0,
648
+ value: r.title,
649
+ inputRef: n,
650
+ onChange: (o) => a("title", o.target.value),
651
+ onBlur: (o) => s(o.target.value),
652
+ messages: i ? [{ text: i, type: "error" }] : []
653
+ }
654
+ ),
655
+ /* @__PURE__ */ c(C, { gap: "medium", wrap: "wrap", children: [
656
+ /* @__PURE__ */ e(
657
+ V,
658
+ {
659
+ name: "rubric-builder-scoring",
660
+ label: t.scoringTypeSelectLabel,
661
+ value: r.hidePoints ? "unscored" : "scored",
662
+ options: [
663
+ { value: "scored", label: t.scoringTypeScored },
664
+ { value: "unscored", label: t.scoringTypeUnscored }
665
+ ],
666
+ onChange: l
667
+ }
668
+ ),
669
+ !r.hidePoints && !r.freeFormCriterionComments && /* @__PURE__ */ e(
670
+ V,
671
+ {
672
+ name: "rubric-builder-display",
673
+ label: t.rubricBuilderDisplayLabel,
674
+ value: r.buttonDisplay,
675
+ options: [
676
+ { value: "points", label: t.ratingDisplayPoints },
677
+ { value: "numeric", label: t.ratingDisplayLevel }
678
+ ],
679
+ onChange: (o) => a("buttonDisplay", o)
680
+ }
681
+ ),
682
+ /* @__PURE__ */ e(
683
+ V,
684
+ {
685
+ name: "rubric-builder-feedback",
686
+ label: t.rubricBuilderFeedbackLabel,
687
+ value: r.freeFormCriterionComments ? "freeForm" : "scale",
688
+ options: [
689
+ { value: "scale", label: t.gradingTypeScale },
690
+ { value: "freeForm", label: t.rubricBuilderFeedbackWrittenOnly }
691
+ ],
692
+ onChange: (o) => a("freeFormCriterionComments", o === "freeForm")
693
+ }
694
+ ),
695
+ !r.freeFormCriterionComments && /* @__PURE__ */ e(
696
+ V,
697
+ {
698
+ name: "rubric-builder-rating-order",
699
+ label: t.rubricBuilderRatingOrderLabel,
700
+ value: r.ratingOrder,
701
+ options: [
702
+ { value: "ascending", label: t.rubricBuilderRatingOrderLowToHigh },
703
+ { value: "descending", label: t.rubricBuilderRatingOrderHighToLow }
704
+ ],
705
+ onChange: (o) => a("ratingOrder", o)
706
+ }
707
+ )
708
+ ] })
709
+ ] })
710
+ ]
711
+ }
712
+ );
713
+ }, ei = (r) => /* @__PURE__ */ e(le, { translations: se, translate: oe, children: /* @__PURE__ */ e(
714
+ Pe,
715
+ {
716
+ courseId: r.courseId,
717
+ accountId: r.accountId,
718
+ featureFlags: r.featureFlags,
719
+ aiLimits: r.aiLimits,
720
+ children: /* @__PURE__ */ e(Lr, { ...r })
721
+ }
722
+ ) }), Lr = ({
723
+ rubricId: r,
724
+ accountId: a,
725
+ courseId: s,
726
+ canManageRubrics: i,
727
+ onSaveRubric: n,
728
+ onDiscard: t
729
+ }) => {
730
+ var re;
731
+ const { translations: l } = L(), {
732
+ rubricForm: o,
733
+ setRubricFormField: u,
734
+ validateField: b,
735
+ validationErrors: p,
736
+ isNewRubric: g,
737
+ load: { data: d, isLoading: v, isError: y, isSuccess: f },
738
+ savePending: I,
739
+ saveError: k,
740
+ save: T,
741
+ saveAction: S,
742
+ isDirty: B,
743
+ criteriaValid: R,
744
+ criteriaValidationErrors: P,
745
+ saveCriterion: H,
746
+ deleteCriterion: E,
747
+ reorderCriteria: G
748
+ } = Xe({ rubricId: r, accountId: a, courseId: s, canManageRubrics: i, onSaveRubric: n }), W = Z(null), [M, $] = x(!1), [j, U] = x(!1), [K, A] = x(!1), [O, q] = x(), m = Ye(), Se = xe(() => q(void 0), []);
749
+ if (r && v)
750
+ return /* @__PURE__ */ e(ir, {});
751
+ if (r && y)
752
+ return Te({
753
+ errorImageUrl: Je,
754
+ errorCategory: l.rubricErrorPageCategory,
755
+ translations: ie(l)
756
+ });
757
+ if (r && f && !d)
758
+ return Ee({ translations: ie(l) });
759
+ const ye = () => {
760
+ var w;
761
+ if ($(!0), !b("title", o.title)) {
762
+ (w = W.current) == null || w.focus();
763
+ return;
764
+ }
765
+ o.criteria.length === 0 || !R || (S === "confirmSave" ? A(!0) : T());
766
+ }, Ie = () => {
767
+ const w = er(m());
768
+ H(w), q(w.id);
769
+ }, we = () => {
770
+ B ? U(!0) : t();
771
+ };
772
+ return /* @__PURE__ */ c(h, { as: "div", "data-testid": "rubric-builder", children: [
773
+ /* @__PURE__ */ c(C, { direction: "column", gap: "medium", padding: "medium 0", children: [
774
+ /* @__PURE__ */ e(
775
+ Ir,
776
+ {
777
+ isNewRubric: g,
778
+ pointsPossible: o.pointsPossible,
779
+ hidePoints: o.hidePoints
780
+ }
781
+ ),
782
+ k && /* @__PURE__ */ e(tr, { variant: "error", margin: "0", children: l.rubricFormSaveError }),
783
+ /* @__PURE__ */ e(
784
+ wr,
785
+ {
786
+ rubricForm: o,
787
+ setRubricFormField: u,
788
+ validateTitle: (w) => b("title", w),
789
+ titleError: (re = p.title) == null ? void 0 : re.message,
790
+ titleInputRef: (w) => {
791
+ W.current = w;
792
+ }
793
+ }
794
+ ),
795
+ /* @__PURE__ */ e(
796
+ fr,
797
+ {
798
+ criteriaCount: o.criteria.length,
799
+ showMissingCriteriaError: M,
800
+ actions: /* @__PURE__ */ e(
801
+ N,
802
+ {
803
+ renderIcon: /* @__PURE__ */ e(Re, {}),
804
+ onClick: Ie,
805
+ "data-testid": "rubric-builder-add-criterion",
806
+ children: l.rubricBuilderAddCriterion
807
+ }
808
+ ),
809
+ children: /* @__PURE__ */ e(
810
+ Sr,
811
+ {
812
+ criteria: o.criteria,
813
+ hidePoints: o.hidePoints,
814
+ freeFormCriterionComments: o.freeFormCriterionComments,
815
+ ratingOrder: o.ratingOrder,
816
+ criteriaValidationErrors: P,
817
+ showErrors: M,
818
+ focusNameCriterionId: O,
819
+ onFocusedName: Se,
820
+ onChangeCriterion: H,
821
+ onDuplicateCriterion: (w) => H(Ze(w)),
822
+ onDeleteCriterion: E,
823
+ onReorderCriteria: G
824
+ }
825
+ )
826
+ }
827
+ )
828
+ ] }),
829
+ /* @__PURE__ */ e(
830
+ yr,
831
+ {
832
+ savePending: I,
833
+ onDiscard: we,
834
+ onSave: ye
835
+ }
836
+ ),
837
+ /* @__PURE__ */ e(
838
+ ee,
839
+ {
840
+ isOpen: j,
841
+ heading: l.rubricBuilderDiscardHeading,
842
+ body: l.rubricBuilderDiscardBody,
843
+ confirmLabel: l.rubricBuilderDiscard,
844
+ cancelLabel: l.rubricBuilderKeepEditing,
845
+ onConfirm: t,
846
+ onDismiss: () => U(!1),
847
+ "data-testid": "rubric-builder-discard-modal"
848
+ }
849
+ ),
850
+ /* @__PURE__ */ e(
851
+ ee,
852
+ {
853
+ isOpen: K,
854
+ heading: l.confirmToContinueHeader,
855
+ body: l.gradingHistoryWarning,
856
+ confirmLabel: l.saveConfirmModalSave,
857
+ cancelLabel: l.cancel,
858
+ onConfirm: () => {
859
+ A(!1), T();
860
+ },
861
+ onDismiss: () => A(!1),
862
+ "data-testid": "rubric-builder-save-confirm-modal"
863
+ }
864
+ )
97
865
  ] });
98
866
  };
99
867
  export {
100
- J as DEFAULT_AI_MAX_CRITERION_COUNT,
101
- Z as DEFAULT_AI_MAX_RATING_COUNT,
102
- K as HelloWorld,
103
- X as RubricSelector
868
+ ti as DEFAULT_AI_MAX_CRITERION_COUNT,
869
+ ni as DEFAULT_AI_MAX_RATING_COUNT,
870
+ Jr as HelloWorld,
871
+ ei as RubricBuilder,
872
+ Zr as RubricSelector
104
873
  };