@pie-element/drag-in-the-blank 10.1.2-next.4 → 10.1.2-next.6

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,18 +1,19 @@
1
1
  import { choiceIsEmpty as e } from "./markupUtils.js";
2
2
  import "react";
3
- import t from "prop-types";
4
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
5
- import { styled as i } from "@mui/material/styles";
6
- import { useDraggable as a } from "@dnd-kit/core";
7
- import o from "@mui/icons-material/MoreVert";
8
- import s from "@mui/icons-material/Delete";
3
+ import { color as t } from "@pie-lib/render-ui";
4
+ import n from "prop-types";
5
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
6
+ import { styled as a } from "@mui/material/styles";
7
+ import { useDraggable as o } from "@dnd-kit/core";
8
+ import s from "@mui/icons-material/MoreVert";
9
+ import c from "@mui/icons-material/Delete";
9
10
  //#region src/author/choice.tsx
10
- var c = ({ style: e }) => /* @__PURE__ */ r("span", {
11
+ var l = ({ style: e }) => /* @__PURE__ */ i("span", {
11
12
  style: e,
12
- children: [/* @__PURE__ */ n(o, { style: { margin: "0 -16px" } }), /* @__PURE__ */ n(o, {})]
13
+ children: [/* @__PURE__ */ r(s, { style: { margin: "0 -16px" } }), /* @__PURE__ */ r(s, {})]
13
14
  });
14
- c.propTypes = { style: t.object };
15
- var l = i("div", { shouldForwardProp: (e) => !["error", "isDragging"].includes(e) })(({ theme: e, error: t }) => ({
15
+ l.propTypes = { style: n.object };
16
+ var u = a("div", { shouldForwardProp: (e) => !["error", "isDragging"].includes(e) })(({ theme: e, error: n }) => ({
16
17
  display: "inline-flex",
17
18
  minWidth: "178px",
18
19
  minHeight: "36px",
@@ -23,66 +24,66 @@ var l = i("div", { shouldForwardProp: (e) => !["error", "isDragging"].includes(e
23
24
  position: "relative",
24
25
  padding: "8px 35px 8px 35px",
25
26
  cursor: "grab",
26
- border: `1px solid ${t ? "#f44336" : "#C0C3CF"}`,
27
+ border: `1px solid ${n ? "#f44336" : t.border()}`,
27
28
  "& img": { display: "flex" },
28
29
  "& p": { margin: 0 },
29
30
  "& mjx-frac": { fontSize: "120% !important" }
30
- })), u = i(s)(({ theme: e }) => ({
31
+ })), d = a(c)(({ theme: e }) => ({
31
32
  position: "absolute",
32
33
  top: "6px",
33
34
  right: "0",
34
- color: e.palette.grey[500],
35
+ color: t.text(),
35
36
  zIndex: 2,
36
37
  "&:hover": {
37
38
  cursor: "pointer",
38
39
  color: e.palette.common.black
39
40
  }
40
- })), d = (t) => {
41
- let { choice: i, onClick: o, onRemoveChoice: s, error: d, instanceId: f, disabled: p } = t, { attributes: m, listeners: h, setNodeRef: g, isDragging: _ } = a({
42
- id: `choice-${i.id}-${f || "default"}`,
41
+ })), f = (n) => {
42
+ let { choice: a, onClick: s, onRemoveChoice: c, error: f, instanceId: p, disabled: m } = n, { attributes: h, listeners: g, setNodeRef: _, isDragging: v } = o({
43
+ id: `choice-${a.id}-${p || "default"}`,
43
44
  data: {
44
45
  type: "drag-in-the-blank-choice",
45
- id: i.id,
46
- value: i,
47
- instanceId: f
46
+ id: a.id,
47
+ value: a,
48
+ instanceId: p
48
49
  },
49
- disabled: p || e(i)
50
- }), v = (t) => {
51
- if (e(i)) {
50
+ disabled: m || e(a)
51
+ }), y = (t) => {
52
+ if (e(a)) {
52
53
  t.preventDefault(), alert("You need to define a value for an answer choice before it can be associated with a response area.");
53
54
  return;
54
55
  }
55
56
  };
56
- return /* @__PURE__ */ r(l, {
57
- ref: g,
58
- error: d,
59
- isDragging: _,
60
- onClick: o,
61
- ...m,
57
+ return /* @__PURE__ */ i(u, {
58
+ ref: _,
59
+ error: f,
60
+ isDragging: v,
61
+ onClick: s,
62
62
  ...h,
63
- onDragStart: v,
63
+ ...g,
64
+ onDragStart: y,
64
65
  children: [
65
- /* @__PURE__ */ n(c, { style: {
66
+ /* @__PURE__ */ r(l, { style: {
66
67
  position: "absolute",
67
68
  top: "6px",
68
69
  left: "15px",
69
- color: "#9e9e9e",
70
+ color: t.borderGray(),
70
71
  zIndex: 2
71
72
  } }),
72
- /* @__PURE__ */ n("span", { dangerouslySetInnerHTML: { __html: i.value } }),
73
- /* @__PURE__ */ n(u, { onClick: (e) => {
74
- e.preventDefault(), e.stopPropagation(), s(e);
73
+ /* @__PURE__ */ r("span", { dangerouslySetInnerHTML: { __html: a.value } }),
74
+ /* @__PURE__ */ r(d, { onClick: (e) => {
75
+ e.preventDefault(), e.stopPropagation(), c(e);
75
76
  } })
76
77
  ]
77
78
  });
78
79
  };
79
- d.propTypes = {
80
- choice: t.object.isRequired,
81
- onClick: t.func,
82
- onRemoveChoice: t.func.isRequired,
83
- error: t.bool,
84
- instanceId: t.string,
85
- disabled: t.bool
80
+ f.propTypes = {
81
+ choice: n.object.isRequired,
82
+ onClick: n.func,
83
+ onRemoveChoice: n.func.isRequired,
84
+ error: n.bool,
85
+ instanceId: n.string,
86
+ disabled: n.bool
86
87
  };
87
88
  //#endregion
88
- export { d as default };
89
+ export { f as BlankContent, f as default };
@@ -1,5 +1,5 @@
1
1
  import { choiceIsEmpty as e } from "./markupUtils.js";
2
- import t from "./choice.js";
2
+ import { BlankContent as t } from "./choice.js";
3
3
  import n from "react";
4
4
  import { renderMath as r } from "@pie-element/shared-math-rendering-mathjax";
5
5
  import i from "prop-types";
@@ -76,13 +76,16 @@ var d = s("div")(({ theme: e }) => ({
76
76
  }
77
77
  i(l);
78
78
  };
79
- onChoiceDone = (t) => {
80
- let { onChange: n, model: r } = this.props, { choices: i } = r, a = (i || []).find((e) => e.id === t);
81
- if (!a || !e(a)) {
82
- this.setState({ focusedEl: void 0 });
79
+ onChoiceDone = (t, n) => {
80
+ let { onChange: r, model: i } = this.props, { choices: a } = i, o = (a || []).find((e) => e.id === t), s = n === void 0 ? o && o.value : n;
81
+ if (!o || !e({ value: s })) {
82
+ o && o.value !== s && r((a || []).map((e) => e.id === t ? {
83
+ ...e,
84
+ value: s
85
+ } : e)), this.setState({ focusedEl: void 0 });
83
86
  return;
84
87
  }
85
- n((i || []).filter((e) => e.id !== t)), this.setState({
88
+ r((a || []).filter((e) => e.id !== t)), this.setState({
86
89
  focusedEl: void 0,
87
90
  warning: {
88
91
  open: !0,
@@ -135,8 +138,8 @@ var d = s("div")(({ theme: e }) => ({
135
138
  onChange: (e) => {
136
139
  this.preventDone || this.onChoiceChanged(n.value, e, n.id);
137
140
  },
138
- onDone: () => {
139
- this.preventDone || this.onChoiceDone(n.id);
141
+ onDone: (e) => {
142
+ this.preventDone || this.onChoiceDone(n.id, e);
140
143
  },
141
144
  onBlur: (e) => {
142
145
  let t = e.relatedTarget && e.relatedTarget.closest(".insert-character-dialog");
@@ -169,4 +172,4 @@ var d = s("div")(({ theme: e }) => ({
169
172
  }
170
173
  };
171
174
  //#endregion
172
- export { h as default };
175
+ export { h as Choices, h as default };
@@ -38,5 +38,6 @@ export default class DragInTheBlank extends HTMLElement {
38
38
  insertSound(handler: any): void;
39
39
  onDeleteSound(src: any, done: any): void;
40
40
  _render(): void;
41
+ connectedCallback(): void;
41
42
  disconnectedCallback(): void;
42
43
  }
@@ -1,5 +1,5 @@
1
1
  import { createSlateMarkup as e, processMarkup as t } from "./markupUtils.js";
2
- import n from "./main.js";
2
+ import { Main as n } from "./main.js";
3
3
  import r from "./defaults.js";
4
4
  import i from "react";
5
5
  import { createRoot as a } from "react-dom/client";
@@ -84,8 +84,11 @@ var m = p("multiple-choice:configure"), h = class p extends HTMLElement {
84
84
  o(this);
85
85
  }, 0);
86
86
  }
87
+ connectedCallback() {
88
+ this._render();
89
+ }
87
90
  disconnectedCallback() {
88
- this._root && this._root.unmount();
91
+ this._root &&= (this._root.unmount(), null);
89
92
  }
90
93
  };
91
94
  //#endregion
@@ -1,6 +1,6 @@
1
1
  import { createSlateMarkup as e } from "./markupUtils.js";
2
- import t from "./choice.js";
3
- import n from "./choices.js";
2
+ import { BlankContent as t } from "./choice.js";
3
+ import { Choices as n } from "./choices.js";
4
4
  import { generateValidationMessage as r } from "./utils.js";
5
5
  import i from "react";
6
6
  import { renderMath as a } from "@pie-element/shared-math-rendering-mathjax";
@@ -298,4 +298,4 @@ var y = v(s, "InputContainer") || v(S.InputContainer, "InputContainer"), b = o,
298
298
  }
299
299
  };
300
300
  //#endregion
301
- export { A as default };
301
+ export { A as Main, A as default };
@@ -35,4 +35,4 @@ var t = (e) => {
35
35
  return !1;
36
36
  };
37
37
  //#endregion
38
- export { l as choiceIsEmpty, c as createSlateMarkup, o as processMarkup };
38
+ export { l as choiceIsEmpty, t as createElementFromHTML, c as createSlateMarkup, o as processMarkup, a as removeUnwantedCharacters };