@pie-element/complex-rubric 7.1.2-next.2 → 7.1.2-next.4

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.
@@ -1,87 +1,90 @@
1
- import e from "./main.js";
2
- import t from "./defaults.js";
3
- import { ModelUpdatedEvent as n } from "@pie-element/shared-configure-events";
4
- import r from "react";
5
- import { createRoot as i } from "react-dom/client";
6
- import a from "@pie-element/rubric/author";
7
- import o from "@pie-element/multi-trait-rubric/author";
8
- import s from "debug";
9
- import { defaults as c } from "@pie-element/shared-lodash";
1
+ import { COMPLEX_RUBRIC_MULTI_TRAIT_CONFIGURE_TAG as e, COMPLEX_RUBRIC_SIMPLE_CONFIGURE_TAG as t } from "../private-tags.js";
2
+ import n from "./main.js";
3
+ import r from "./defaults.js";
4
+ import { ModelUpdatedEvent as i } from "@pie-element/shared-configure-events";
5
+ import a from "react";
6
+ import { createRoot as o } from "react-dom/client";
7
+ import s from "@pie-element/rubric/author";
8
+ import c from "@pie-element/multi-trait-rubric/author";
9
+ import l from "debug";
10
+ import { defaults as u } from "@pie-element/shared-lodash";
10
11
  //#region src/author/index.ts
11
- var l = n.TYPE, u = "rubric-configure", d = "multi-trait-rubric-configure", f = class extends a {}, p = class extends o {};
12
- customElements.get(u) || customElements.define(u, f), customElements.get(d) || customElements.define(d, p);
13
- var m = (e, n) => ({
14
- configuration: c(e, t.configuration),
15
- model: n
16
- }), h = class a extends HTMLElement {
17
- static createDefaultModel = ({ rubrics: { simpleRubric: e = {}, rubricless: n = {}, multiTraitRubric: r = {} } = {
12
+ var d = i.TYPE, f = t, p = e, m = class extends s {}, h = class extends c {};
13
+ customElements.get(f) || customElements.define(f, m), customElements.get(p) || customElements.define(p, h);
14
+ var g = (e, t) => ({
15
+ configuration: u(e, r.configuration),
16
+ model: t
17
+ }), _ = class e extends HTMLElement {
18
+ static createDefaultModel = ({ rubrics: { simpleRubric: e = {}, rubricless: t = {}, multiTraitRubric: n = {} } = {
18
19
  simpleRubric: {},
19
20
  rubricless: {},
20
21
  multiTraitRubric: {}
21
22
  }, ...i } = {}, a = {}) => ({
22
- ...t?.model || {},
23
+ ...r?.model || {},
23
24
  ...a,
24
25
  ...i,
25
26
  rubrics: {
26
27
  simpleRubric: {
27
- ...(t?.model?.rubrics || {}).simpleRubric,
28
+ ...(r?.model?.rubrics || {}).simpleRubric,
28
29
  ...(a.rubrics || {}).simpleRubric,
29
30
  ...e
30
31
  },
31
32
  multiTraitRubric: {
32
- ...(t?.model?.rubrics || {}).multiTraitRubric,
33
+ ...(r?.model?.rubrics || {}).multiTraitRubric,
33
34
  ...(a.rubrics || {}).multiTraitRubric,
34
- ...r
35
+ ...n
35
36
  },
36
37
  rubricless: {
37
- ...(t?.model?.rubrics || {}).rubricless,
38
+ ...(r?.model?.rubrics || {}).rubricless,
38
39
  ...(a.rubrics || {}).rubricless,
39
- ...n
40
+ ...t
40
41
  }
41
42
  }
42
43
  });
43
44
  constructor() {
44
- super(), this._root = null, this.canUpdateModel = !1, s.log("constructor called"), this._model = a.createDefaultModel(), this._configuration = t.configuration, this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
45
+ super(), this._root = null, this.canUpdateModel = !1, l.log("constructor called"), this._model = e.createDefaultModel(), this._configuration = r.configuration, this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
45
46
  }
46
- set model(e) {
47
- this._model = a.createDefaultModel(e, this._model), this.canUpdateModel = !0, this._render();
47
+ set model(t) {
48
+ this._model = e.createDefaultModel(t, this._model), this.canUpdateModel = !0, this._render();
48
49
  }
49
50
  dispatchModelUpdated(e) {
50
51
  let t = !!e;
51
- this.dispatchEvent(new n(this._model, t));
52
+ this.dispatchEvent(new i(this._model, t));
52
53
  }
53
- onModelChanged = (e, t) => {
54
- this._model = a.createDefaultModel(e, this._model), this.dispatchModelUpdated(t), this._render();
54
+ onModelChanged = (t, n) => {
55
+ this._model = e.createDefaultModel(t, this._model), this.dispatchModelUpdated(n), this._render();
55
56
  };
56
57
  set configuration(e) {
57
- let t = m(e, this._model);
58
+ let t = g(e, this._model);
58
59
  this._configuration = t.configuration, this._render();
59
60
  }
60
61
  onConfigurationChanged(e) {
61
- this._configuration = m(e, this._model).configuration, this._model && this.onModelChanged(this._model), this._render();
62
+ this._configuration = g(e, this._model).configuration, this._model && this.onModelChanged(this._model), this._render();
62
63
  }
63
64
  onModelUpdated = (e) => {
64
65
  if (e.target === this) return;
65
66
  e.preventDefault(), e.stopImmediatePropagation();
66
67
  let t = e.target && e.target.getAttribute("id");
67
- t && (e.update && (this._model.rubrics[t] = e.update), this.dispatchEvent(new n(this._model)));
68
+ t && (e.update && (this._model.rubrics[t] = e.update), this.dispatchEvent(new i(this._model)));
68
69
  };
69
70
  connectedCallback() {
70
- this.addEventListener(l, this.onModelUpdated), this._render();
71
+ this.addEventListener(d, this.onModelUpdated), this._render();
71
72
  }
72
73
  _render() {
73
- let t = r.createElement(e, {
74
+ let e = a.createElement(n, {
74
75
  model: this._model,
75
76
  configuration: this._configuration,
77
+ multiTraitRubricTagName: p,
76
78
  onModelChanged: this.onModelChanged,
77
79
  onConfigurationChanged: this.onConfigurationChanged,
80
+ simpleRubricTagName: f,
78
81
  canUpdateModel: this.canUpdateModel
79
82
  });
80
- this._root ||= i(this), this._root.render(t);
83
+ this._root ||= o(this), this._root.render(e);
81
84
  }
82
85
  disconnectedCallback() {
83
- this.removeEventListener(l, this.onModelUpdated), this._root && this._root.unmount();
86
+ this.removeEventListener(d, this.onModelUpdated), this._root && this._root.unmount();
84
87
  }
85
88
  };
86
89
  //#endregion
87
- export { h as default };
90
+ export { _ as default };
@@ -12,9 +12,11 @@ export declare class Main extends React.Component {
12
12
  static propTypes: {
13
13
  canUpdateModel: PropTypes.Requireable<boolean>;
14
14
  configuration: PropTypes.Requireable<object>;
15
+ multiTraitRubricTagName: PropTypes.Requireable<string>;
15
16
  model: PropTypes.Requireable<object>;
16
17
  onModelChanged: PropTypes.Requireable<(...args: any[]) => any>;
17
18
  onConfigurationChanged: PropTypes.Requireable<(...args: any[]) => any>;
19
+ simpleRubricTagName: PropTypes.Requireable<string>;
18
20
  };
19
21
  onModelChanged: any;
20
22
  onChangeRubricType: any;
@@ -1,30 +1,33 @@
1
- import { RUBRIC_TYPES as e } from "@pie-lib/rubric";
2
- import t from "react";
3
- import n from "prop-types";
4
- import { layout as r } from "@pie-lib/config-ui";
5
- import i from "@mui/material/Radio";
6
- import a from "@mui/material/RadioGroup";
7
- import o from "@mui/material/FormControlLabel";
8
- import { styled as s } from "@mui/material/styles";
9
- import { color as c } from "@pie-lib/render-ui";
10
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
1
+ import { COMPLEX_RUBRIC_MULTI_TRAIT_CONFIGURE_TAG as e, COMPLEX_RUBRIC_SIMPLE_CONFIGURE_TAG as t } from "../private-tags.js";
2
+ import { RUBRIC_TYPES as n } from "@pie-lib/rubric";
3
+ import r from "react";
4
+ import i from "prop-types";
5
+ import { layout as a } from "@pie-lib/config-ui";
6
+ import o from "@mui/material/Radio";
7
+ import s from "@mui/material/RadioGroup";
8
+ import c from "@mui/material/FormControlLabel";
9
+ import { styled as l } from "@mui/material/styles";
10
+ import { color as u } from "@pie-lib/render-ui";
11
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
11
12
  //#region src/author/main.tsx
12
- var d = s(o)({ "&.MuiFormControlLabel-root": {
13
+ var p = l(c)({ "&.MuiFormControlLabel-root": {
13
14
  width: "fit-content",
14
15
  paddingRight: "24px",
15
16
  boxSizing: "border-box",
16
17
  "&:hover": { background: "var(--pie-secondary-background, rgba(241,241,241,1))" }
17
- } }), f = s(i)({ "&.MuiRadio-root": { color: `${c.tertiary()} !important` } }), p = {
18
- [e.MULTI_TRAIT_RUBRIC]: "Multi Trait Rubric",
19
- [e.SIMPLE_RUBRIC]: "Simple Rubric",
20
- [e.RUBRICLESS]: "Rubricless"
21
- }, m = class extends t.Component {
18
+ } }), m = l(o)({ "&.MuiRadio-root": { color: `${u.tertiary()} !important` } }), h = {
19
+ [n.MULTI_TRAIT_RUBRIC]: "Multi Trait Rubric",
20
+ [n.SIMPLE_RUBRIC]: "Simple Rubric",
21
+ [n.RUBRICLESS]: "Rubricless"
22
+ }, g = class extends r.Component {
22
23
  static propTypes = {
23
- canUpdateModel: n.bool,
24
- configuration: n.object,
25
- model: n.object,
26
- onModelChanged: n.func,
27
- onConfigurationChanged: n.func
24
+ canUpdateModel: i.bool,
25
+ configuration: i.object,
26
+ multiTraitRubricTagName: i.string,
27
+ model: i.object,
28
+ onModelChanged: i.func,
29
+ onConfigurationChanged: i.func,
30
+ simpleRubricTagName: i.string
28
31
  };
29
32
  onModelChanged = (e) => {
30
33
  let { onModelChanged: t } = this.props;
@@ -38,69 +41,69 @@ var d = s(o)({ "&.MuiFormControlLabel-root": {
38
41
  });
39
42
  };
40
43
  render() {
41
- let { model: t, configuration: n, canUpdateModel: i } = this.props, { extraCSSRules: o, rubrics: s = {} } = t || {}, { rubricType: c } = t, { contentDimensions: m = {}, rubricOptions: h = [], multiTraitRubric: g, simpleRubric: _, rubricless: v, width: y } = n, b = "";
42
- c ||= e.SIMPLE_RUBRIC;
43
- let x = h.indexOf(c) > -1;
44
- if (i) switch (c) {
45
- case e.SIMPLE_RUBRIC:
44
+ let { model: r, configuration: i, canUpdateModel: o, multiTraitRubricTagName: c = e, simpleRubricTagName: l = t } = this.props, u = c, g = l, { extraCSSRules: _, rubrics: v = {} } = r || {}, { rubricType: y } = r, { contentDimensions: b = {}, rubricOptions: x = [], multiTraitRubric: S, simpleRubric: C, rubricless: w, width: T } = i, E = "";
45
+ y ||= n.SIMPLE_RUBRIC;
46
+ let D = x.indexOf(y) > -1;
47
+ if (o) switch (y) {
48
+ case n.SIMPLE_RUBRIC:
46
49
  default:
47
- b = /* @__PURE__ */ l("rubric-configure", {
50
+ E = /* @__PURE__ */ d(g, {
48
51
  id: "simpleRubric",
49
52
  ref: (e) => {
50
53
  e && (this.simpleRubric = e, this.simpleRubric.model = {
51
- ...s.simpleRubric,
52
- errors: t.errors || {}
54
+ ...v.simpleRubric,
55
+ errors: r.errors || {}
53
56
  }, this.simpleRubric.configuration = {
54
- ..._,
55
- width: y
57
+ ...C,
58
+ width: T
56
59
  });
57
60
  }
58
61
  }, "simple-rubric");
59
62
  break;
60
- case e.MULTI_TRAIT_RUBRIC:
61
- b = /* @__PURE__ */ l("multi-trait-rubric-configure", {
63
+ case n.MULTI_TRAIT_RUBRIC:
64
+ E = /* @__PURE__ */ d(u, {
62
65
  id: "multiTraitRubric",
63
66
  ref: (e) => {
64
67
  e && (this.multiTraitRubric = e, this.multiTraitRubric.model = {
65
- ...s.multiTraitRubric,
66
- errors: t.errors || {}
68
+ ...v.multiTraitRubric,
69
+ errors: r.errors || {}
67
70
  }, this.multiTraitRubric.configuration = {
68
- ...g,
69
- width: y || g.width
71
+ ...S,
72
+ width: T || S.width
70
73
  });
71
74
  }
72
75
  }, "multi-trait-rubric");
73
76
  break;
74
- case e.RUBRICLESS:
75
- b = /* @__PURE__ */ l("rubric-configure", {
77
+ case n.RUBRICLESS:
78
+ E = /* @__PURE__ */ d(g, {
76
79
  id: "rubricless",
77
80
  ref: (e) => {
78
- e && (this.rubricless = e, this.rubricless.model = s.rubricless, this.rubricless.configuration = {
79
- ...v,
80
- width: y
81
+ e && (this.rubricless = e, this.rubricless.model = v.rubricless, this.rubricless.configuration = {
82
+ ...w,
83
+ width: T
81
84
  });
82
85
  }
83
86
  }, "rubricless");
84
87
  break;
85
88
  }
86
- return /* @__PURE__ */ u(r.ConfigLayout, {
87
- extraCSSRules: o,
88
- dimensions: m,
89
+ return /* @__PURE__ */ f(a.ConfigLayout, {
90
+ extraCSSRules: _,
91
+ dimensions: b,
89
92
  hideSettings: !0,
90
93
  settings: null,
91
- children: [/* @__PURE__ */ l(a, {
94
+ children: [/* @__PURE__ */ d(s, {
92
95
  "aria-label": "rubric-type",
93
96
  name: "rubricType",
94
- value: t.rubricType,
97
+ value: r.rubricType,
95
98
  onChange: this.onChangeRubricType,
96
- children: h.length > 1 && h.map((e, t) => /* @__PURE__ */ l(d, {
99
+ children: x.length > 1 && x.map((e, t) => /* @__PURE__ */ d(p, {
97
100
  value: e,
98
- control: /* @__PURE__ */ l(f, { checked: c === e }),
99
- label: p[e]
101
+ control: /* @__PURE__ */ d(m, { checked: y === e }),
102
+ label: h[e]
100
103
  }, t))
101
- }), x && b]
104
+ }), D && E]
102
105
  });
103
106
  }
104
107
  };
105
108
  //#endregion
106
- export { m as default };
109
+ export { g as default };