@pie-element/match 12.1.2-next.7 → 12.1.2-next.9

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.
@@ -23,6 +23,7 @@ export declare class AnswerGrid extends React.Component {
23
23
  onRowValueChange: (rowId: any, answerIndex: any) => (event: any) => void;
24
24
  answerIsCorrect: any;
25
25
  answerIsIncorrect: any;
26
+ controlColor: any;
26
27
  render(): React.JSX.Element;
27
28
  }
28
29
  export default AnswerGrid;
@@ -50,14 +50,18 @@ var l = c("div")(({ theme: e }) => ({
50
50
  let { correctAnswers: r } = this.props;
51
51
  return r[e][n] === !0 && t === !1 || r[e][n] === !1 && t === !0;
52
52
  };
53
+ controlColor = (e, t, r) => {
54
+ let { showCorrect: i, disabled: a, view: o } = this.props, s = a && !o;
55
+ return i && t === !0 || s && this.answerIsCorrect(e, t, r) ? n.correct() : s && this.answerIsIncorrect(e, t, r) ? n.incorrect() : t === !0 && !s ? n.primary() : a ? n.disabled() : n.text();
56
+ };
53
57
  render() {
54
- let { showCorrect: e, headers: t, rows: s, choiceMode: c, answers: g, disabled: _, view: v } = this.props, y = c === "radio" ? a : o, b = _ && !v;
55
- return !s || s.length === 0 ? /* @__PURE__ */ r(l, { children: /* @__PURE__ */ r(d, {
58
+ let { headers: e, rows: t, choiceMode: s, answers: c, disabled: g } = this.props, _ = s === "radio" ? a : o;
59
+ return !t || t.length === 0 ? /* @__PURE__ */ r(l, { children: /* @__PURE__ */ r(d, {
56
60
  component: "div",
57
61
  children: "There are currently no questions to show."
58
62
  }) }) : /* @__PURE__ */ r(l, { children: /* @__PURE__ */ i(h, { children: [
59
- /* @__PURE__ */ r("colgroup", { children: (t || []).map((e, t) => /* @__PURE__ */ r("col", {}, `col-${t}`)) }),
60
- /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ r("tr", { children: (t || []).map((e, t) => /* @__PURE__ */ r(f, {
63
+ /* @__PURE__ */ r("colgroup", { children: (e || []).map((e, t) => /* @__PURE__ */ r("col", {}, `col-${t}`)) }),
64
+ /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ r("tr", { children: (e || []).map((e, t) => /* @__PURE__ */ r(f, {
61
65
  "data-colno": `${t}`,
62
66
  scope: "row",
63
67
  children: /* @__PURE__ */ r(p, {
@@ -65,33 +69,37 @@ var l = c("div")(({ theme: e }) => ({
65
69
  dangerouslySetInnerHTML: { __html: e }
66
70
  })
67
71
  }, `th-${t}`)) }) }),
68
- (s || []).map((t, a) => /* @__PURE__ */ r("tbody", {
72
+ (t || []).map((e, t) => /* @__PURE__ */ r("tbody", {
69
73
  role: "group",
70
74
  children: /* @__PURE__ */ i(m, { children: [/* @__PURE__ */ r("td", {
71
75
  "data-colno": "0",
72
76
  children: /* @__PURE__ */ r(p, {
73
77
  isQuestionText: !0,
74
- dangerouslySetInnerHTML: { __html: t.title }
78
+ dangerouslySetInnerHTML: { __html: e.title }
75
79
  })
76
- }, `td-title-${a}`), (g[t.id] || []).map((i, o) => /* @__PURE__ */ r(u, {
77
- "data-colno": `${o + 1}`,
78
- children: /* @__PURE__ */ r(p, { children: /* @__PURE__ */ r(y, {
79
- sx: {
80
- padding: "6px",
81
- color: e && i === !0 || b && this.answerIsCorrect(t.id, i, o) ? n.correct() : b && this.answerIsIncorrect(t.id, i, o) ? n.incorrect() : i === !0 && !b ? n.primary() : _ ? n.disabled() : n.text(),
82
- cursor: _ ? "not-allowed" : "pointer",
83
- pointerEvents: _ ? "initial" : "auto",
84
- opacity: _ ? .7 : 1,
85
- "& input": { width: "100% !important" },
86
- "&:hover": { color: _ ? n.disabled() : n.primaryLight() },
87
- "&.Mui-disabled": { color: `${e && i === !0 || b && this.answerIsCorrect(t.id, i, o) ? n.correct() : b && this.answerIsIncorrect(t.id, i, o) ? n.incorrect() : i === !0 && !b ? n.primary() : n.disabled()}` }
88
- },
89
- disabled: _,
90
- onChange: this.onRowValueChange(t.id, o),
91
- checked: i === !0
92
- }) })
93
- }, `td-${a}-${o}`))] })
94
- }, `row-${a}`))
80
+ }, `td-title-${t}`), (c[e.id] || []).map((i, a) => {
81
+ let o = this.controlColor(e.id, i, a);
82
+ return /* @__PURE__ */ r(u, {
83
+ "data-colno": `${a + 1}`,
84
+ children: /* @__PURE__ */ r(p, { children: /* @__PURE__ */ r(_, {
85
+ sx: {
86
+ padding: "6px",
87
+ color: o,
88
+ "&&.Mui-checked": { color: o },
89
+ "&&.Mui-disabled": { color: o },
90
+ cursor: g ? "not-allowed" : "pointer",
91
+ pointerEvents: g ? "initial" : "auto",
92
+ opacity: g ? .7 : 1,
93
+ "& input": { width: "100% !important" },
94
+ "&&:hover:not(.Mui-disabled)": { color: n.primaryLight() }
95
+ },
96
+ disabled: g,
97
+ onChange: this.onRowValueChange(e.id, a),
98
+ checked: i === !0
99
+ }) })
100
+ }, `td-${t}-${a}`);
101
+ })] })
102
+ }, `row-${t}`))
95
103
  ] }) });
96
104
  }
97
105
  };