@pie-lib/mask-markup 3.0.4-next.32 → 3.0.4-next.34
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.
- package/CHANGELOG.json +17 -0
- package/CHANGELOG.md +1256 -0
- package/LICENSE.md +5 -0
- package/lib/choices/choice.js +116 -0
- package/lib/choices/choice.js.map +1 -0
- package/lib/choices/index.js +103 -0
- package/lib/choices/index.js.map +1 -0
- package/lib/componentize.js +21 -0
- package/lib/componentize.js.map +1 -0
- package/lib/components/blank.js +371 -0
- package/lib/components/blank.js.map +1 -0
- package/lib/components/correct-input.js +94 -0
- package/lib/components/correct-input.js.map +1 -0
- package/lib/components/dropdown.js +483 -0
- package/lib/components/dropdown.js.map +1 -0
- package/lib/components/input.js +50 -0
- package/lib/components/input.js.map +1 -0
- package/lib/constructed-response.js +101 -0
- package/lib/constructed-response.js.map +1 -0
- package/lib/customizable.js +42 -0
- package/lib/customizable.js.map +1 -0
- package/lib/drag-in-the-blank.js +254 -0
- package/lib/drag-in-the-blank.js.map +1 -0
- package/lib/index.js +55 -0
- package/lib/index.js.map +1 -0
- package/lib/inline-dropdown.js +40 -0
- package/lib/inline-dropdown.js.map +1 -0
- package/lib/mask.js +198 -0
- package/lib/mask.js.map +1 -0
- package/lib/serialization.js +261 -0
- package/lib/serialization.js.map +1 -0
- package/lib/with-mask.js +97 -0
- package/lib/with-mask.js.map +1 -0
- package/package.json +20 -39
- package/src/__tests__/drag-in-the-blank.test.js +111 -0
- package/src/__tests__/index.test.js +38 -0
- package/src/__tests__/mask.test.js +381 -0
- package/src/__tests__/serialization.test.js +54 -0
- package/src/__tests__/utils.js +1 -0
- package/src/__tests__/with-mask.test.js +76 -0
- package/src/choices/__tests__/index.test.js +75 -0
- package/src/choices/choice.jsx +97 -0
- package/src/choices/index.jsx +64 -0
- package/src/componentize.js +13 -0
- package/src/components/__tests__/blank.test.js +199 -0
- package/src/components/__tests__/correct-input.test.js +90 -0
- package/src/components/__tests__/dropdown.test.js +129 -0
- package/src/components/__tests__/input.test.js +102 -0
- package/src/components/blank.jsx +386 -0
- package/src/components/correct-input.jsx +82 -0
- package/src/components/dropdown.jsx +423 -0
- package/src/components/input.jsx +48 -0
- package/src/constructed-response.jsx +87 -0
- package/src/customizable.jsx +34 -0
- package/src/drag-in-the-blank.jsx +241 -0
- package/src/index.js +16 -0
- package/src/inline-dropdown.jsx +29 -0
- package/src/mask.jsx +172 -0
- package/src/serialization.js +260 -0
- package/src/with-mask.jsx +75 -0
- package/dist/_virtual/_rolldown/runtime.js +0 -4
- package/dist/choices/choice.d.ts +0 -24
- package/dist/choices/choice.js +0 -77
- package/dist/choices/index.d.ts +0 -25
- package/dist/choices/index.js +0 -49
- package/dist/componentize.d.ts +0 -12
- package/dist/componentize.js +0 -4
- package/dist/components/blank.d.ts +0 -39
- package/dist/components/blank.js +0 -240
- package/dist/components/correct-input.d.ts +0 -11
- package/dist/components/dropdown.d.ts +0 -37
- package/dist/components/dropdown.js +0 -320
- package/dist/components/input.d.ts +0 -37
- package/dist/constructed-response.d.ts +0 -44
- package/dist/constructed-response.js +0 -55
- package/dist/customizable.d.ts +0 -43
- package/dist/customizable.js +0 -8
- package/dist/drag-in-the-blank.d.ts +0 -37
- package/dist/drag-in-the-blank.js +0 -164
- package/dist/index.d.ts +0 -15
- package/dist/index.js +0 -7
- package/dist/inline-dropdown.d.ts +0 -44
- package/dist/inline-dropdown.js +0 -24
- package/dist/mask.d.ts +0 -30
- package/dist/mask.js +0 -99
- package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +0 -16
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/index.js +0 -17
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/cssPrefix.js +0 -9
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/cssUnitless.js +0 -26
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/hasOwn.js +0 -11
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/isFunction.js +0 -11
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/isObject.js +0 -11
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/prefixInfo.js +0 -24
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/prefixProperties.js +0 -32
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/prefixer.js +0 -29
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/camelize.js +0 -14
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/hyphenRe.js +0 -8
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/hyphenate.js +0 -12
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/separate.js +0 -11
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/toLowerFirst.js +0 -10
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/toUpperFirst.js +0 -10
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/toStyleObject.js +0 -55
- package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/toStyleString.js +0 -16
- package/dist/serialization.d.ts +0 -34
- package/dist/serialization.js +0 -132
- package/dist/with-mask.d.ts +0 -55
- package/dist/with-mask.js +0 -45
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Mask from './mask';
|
|
4
|
+
import componentize from './componentize';
|
|
5
|
+
import { deserialize } from './serialization';
|
|
6
|
+
|
|
7
|
+
export const buildLayoutFromMarkup = (markup, type) => {
|
|
8
|
+
const { markup: processed } = componentize(markup, type);
|
|
9
|
+
const value = deserialize(processed);
|
|
10
|
+
return value.document;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const withMask = (type, renderChildren) => {
|
|
14
|
+
return class WithMask extends React.Component {
|
|
15
|
+
static propTypes = {
|
|
16
|
+
/**
|
|
17
|
+
* At the start we'll probably work with markup
|
|
18
|
+
*/
|
|
19
|
+
markup: PropTypes.string,
|
|
20
|
+
/**
|
|
21
|
+
* Once we start authoring, it may make sense for use to us layout, which will be a simple js object that maps to `slate.Value`.
|
|
22
|
+
*/
|
|
23
|
+
layout: PropTypes.object,
|
|
24
|
+
value: PropTypes.object,
|
|
25
|
+
onChange: PropTypes.func,
|
|
26
|
+
customMarkMarkupComponent: PropTypes.func,
|
|
27
|
+
elementType: PropTypes.string,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
constructor(props) {
|
|
31
|
+
super(props);
|
|
32
|
+
this.containerRef = React.createRef();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
componentDidUpdate(prevProps) {
|
|
36
|
+
if (this.props.markup !== prevProps.markup) {
|
|
37
|
+
const domNode = this.containerRef.current;
|
|
38
|
+
const mathElements = domNode && domNode.querySelectorAll('[data-latex][data-math-handled="true"]');
|
|
39
|
+
|
|
40
|
+
// Clean up for fresh MathJax processing
|
|
41
|
+
(mathElements || []).forEach((el) => {
|
|
42
|
+
// Remove the MathJax container to allow for clean updates
|
|
43
|
+
const mjxContainer = el.querySelector('mjx-container');
|
|
44
|
+
|
|
45
|
+
if (mjxContainer) {
|
|
46
|
+
el.removeChild(mjxContainer);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Update the innerHTML to match the raw LaTeX data, ensuring it is reprocessed correctly
|
|
50
|
+
const latexCode = el.getAttribute('data-raw');
|
|
51
|
+
el.innerHTML = latexCode;
|
|
52
|
+
|
|
53
|
+
// Remove the attribute to signal that MathJax should reprocess this element
|
|
54
|
+
el.removeAttribute('data-math-handled');
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
render() {
|
|
60
|
+
const { markup, layout, value, onChange, elementType } = this.props;
|
|
61
|
+
|
|
62
|
+
const maskLayout = layout ? layout : buildLayoutFromMarkup(markup, type);
|
|
63
|
+
return (
|
|
64
|
+
<Mask
|
|
65
|
+
containerRef={this.containerRef}
|
|
66
|
+
elementType={elementType}
|
|
67
|
+
layout={maskLayout}
|
|
68
|
+
value={value}
|
|
69
|
+
onChange={onChange}
|
|
70
|
+
renderChildren={renderChildren(this.props)}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
};
|
package/dist/choices/choice.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-lib/packages/mask-markup/src/choices/choice.jsx
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
export declare const DRAG_TYPE = "MaskBlank";
|
|
12
|
-
declare function Choice({ choice, disabled, instanceId }: {
|
|
13
|
-
choice: any;
|
|
14
|
-
disabled: any;
|
|
15
|
-
instanceId: any;
|
|
16
|
-
}): React.JSX.Element;
|
|
17
|
-
declare namespace Choice {
|
|
18
|
-
var propTypes: {
|
|
19
|
-
choice: PropTypes.Validator<object>;
|
|
20
|
-
disabled: PropTypes.Requireable<boolean>;
|
|
21
|
-
instanceId: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export default Choice;
|
package/dist/choices/choice.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { useEffect as e, useRef as t } from "react";
|
|
2
|
-
import n from "prop-types";
|
|
3
|
-
import { styled as r } from "@mui/material/styles";
|
|
4
|
-
import { renderMath as i } from "@pie-element/shared-math-rendering-mathjax";
|
|
5
|
-
import { jsx as a } from "react/jsx-runtime";
|
|
6
|
-
import { useDraggable as o } from "@dnd-kit/core";
|
|
7
|
-
import s from "@mui/material/Chip";
|
|
8
|
-
import { color as c } from "@pie-lib/render-ui";
|
|
9
|
-
//#region src/choices/choice.tsx
|
|
10
|
-
var l = "MaskBlank", u = r("span")(({ theme: e, disabled: t }) => ({
|
|
11
|
-
border: `solid 0px ${e.palette.primary.main}`,
|
|
12
|
-
borderRadius: e.spacing(2),
|
|
13
|
-
margin: e.spacing(.5),
|
|
14
|
-
transform: "translate(0, 0)",
|
|
15
|
-
display: "inline-flex",
|
|
16
|
-
...t && {}
|
|
17
|
-
})), d = r(s)(() => ({
|
|
18
|
-
backgroundColor: c.white(),
|
|
19
|
-
border: `1px solid ${c.text()}`,
|
|
20
|
-
color: c.text(),
|
|
21
|
-
alignItems: "center",
|
|
22
|
-
display: "inline-flex",
|
|
23
|
-
height: "initial",
|
|
24
|
-
minHeight: "32px",
|
|
25
|
-
fontSize: "inherit",
|
|
26
|
-
whiteSpace: "pre-wrap",
|
|
27
|
-
maxWidth: "374px",
|
|
28
|
-
pointerEvents: "none",
|
|
29
|
-
borderRadius: "3px",
|
|
30
|
-
paddingTop: "12px",
|
|
31
|
-
paddingBottom: "12px",
|
|
32
|
-
"&.Mui-disabled": { opacity: 1 }
|
|
33
|
-
})), f = r("span")(() => ({
|
|
34
|
-
whiteSpace: "normal",
|
|
35
|
-
"& img": {
|
|
36
|
-
display: "block",
|
|
37
|
-
padding: "2px 0"
|
|
38
|
-
},
|
|
39
|
-
"& mjx-frac": { fontSize: "120% !important" }
|
|
40
|
-
}));
|
|
41
|
-
function p({ choice: n, disabled: r, instanceId: s }) {
|
|
42
|
-
let c = t(null), { attributes: p, listeners: m, setNodeRef: h, isDragging: g } = o({
|
|
43
|
-
id: `choice-${n.id}`,
|
|
44
|
-
data: {
|
|
45
|
-
choice: n,
|
|
46
|
-
instanceId: s,
|
|
47
|
-
fromChoice: !0,
|
|
48
|
-
type: l
|
|
49
|
-
},
|
|
50
|
-
disabled: r
|
|
51
|
-
});
|
|
52
|
-
return e(() => {
|
|
53
|
-
i(c.current);
|
|
54
|
-
}, [n.value]), /* @__PURE__ */ a(u, {
|
|
55
|
-
ref: h,
|
|
56
|
-
style: g ? {
|
|
57
|
-
width: c.current?.offsetWidth,
|
|
58
|
-
height: c.current?.offsetHeight
|
|
59
|
-
} : {},
|
|
60
|
-
disabled: r,
|
|
61
|
-
...m,
|
|
62
|
-
...p,
|
|
63
|
-
children: /* @__PURE__ */ a(d, {
|
|
64
|
-
clickable: !1,
|
|
65
|
-
disabled: r,
|
|
66
|
-
ref: c,
|
|
67
|
-
label: /* @__PURE__ */ a(f, { dangerouslySetInnerHTML: { __html: n.value } })
|
|
68
|
-
})
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
p.propTypes = {
|
|
72
|
-
choice: n.object.isRequired,
|
|
73
|
-
disabled: n.bool,
|
|
74
|
-
instanceId: n.oneOfType([n.string, n.number])
|
|
75
|
-
};
|
|
76
|
-
//#endregion
|
|
77
|
-
export { p as default };
|
package/dist/choices/index.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-lib/packages/mask-markup/src/choices/index.jsx
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
export default class Choices extends React.Component {
|
|
12
|
-
static propTypes: {
|
|
13
|
-
disabled: PropTypes.Requireable<boolean>;
|
|
14
|
-
duplicates: PropTypes.Requireable<boolean>;
|
|
15
|
-
choices: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
16
|
-
label: PropTypes.Requireable<string>;
|
|
17
|
-
value: PropTypes.Requireable<string>;
|
|
18
|
-
}> | null | undefined)[]>;
|
|
19
|
-
value: PropTypes.Requireable<object>;
|
|
20
|
-
choicePosition: PropTypes.Validator<string>;
|
|
21
|
-
instanceId: PropTypes.Requireable<string>;
|
|
22
|
-
};
|
|
23
|
-
getStyleForWrapper: any;
|
|
24
|
-
render(): React.JSX.Element;
|
|
25
|
-
}
|
package/dist/choices/index.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import e from "./choice.js";
|
|
2
|
-
import t from "react";
|
|
3
|
-
import n from "prop-types";
|
|
4
|
-
import { findKey as r } from "@pie-element/shared-lodash";
|
|
5
|
-
import { jsx as i } from "react/jsx-runtime";
|
|
6
|
-
import { DragDroppablePlaceholder as a } from "@pie-lib/drag";
|
|
7
|
-
//#region src/choices/index.tsx
|
|
8
|
-
var o = class extends t.Component {
|
|
9
|
-
static propTypes = {
|
|
10
|
-
disabled: n.bool,
|
|
11
|
-
duplicates: n.bool,
|
|
12
|
-
choices: n.arrayOf(n.shape({
|
|
13
|
-
label: n.string,
|
|
14
|
-
value: n.string
|
|
15
|
-
})),
|
|
16
|
-
value: n.object,
|
|
17
|
-
choicePosition: n.string.isRequired,
|
|
18
|
-
instanceId: n.string
|
|
19
|
-
};
|
|
20
|
-
getStyleForWrapper = () => {
|
|
21
|
-
let { choicePosition: e } = this.props;
|
|
22
|
-
switch (e) {
|
|
23
|
-
case "above": return { margin: "0 0 40px 0" };
|
|
24
|
-
case "below": return { margin: "40px 0 0 0" };
|
|
25
|
-
case "right": return { margin: "0 0 0 40px" };
|
|
26
|
-
default: return { margin: "0 40px 0 0" };
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
render() {
|
|
30
|
-
let { disabled: t, duplicates: n, choices: o, value: s, instanceId: c } = this.props, l = o.filter((e) => n === !0 ? !0 : r(s, (t) => t === e.id) === void 0);
|
|
31
|
-
return /* @__PURE__ */ i("div", {
|
|
32
|
-
style: {
|
|
33
|
-
...this.getStyleForWrapper(),
|
|
34
|
-
minWidth: "100px"
|
|
35
|
-
},
|
|
36
|
-
children: /* @__PURE__ */ i(a, {
|
|
37
|
-
disabled: t,
|
|
38
|
-
instanceId: c,
|
|
39
|
-
children: l.map((n, r) => /* @__PURE__ */ i(e, {
|
|
40
|
-
disabled: t,
|
|
41
|
-
choice: n,
|
|
42
|
-
instanceId: c
|
|
43
|
-
}, `${n.value}-${r}`))
|
|
44
|
-
})
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
//#endregion
|
|
49
|
-
export { o as default };
|
package/dist/componentize.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-lib/packages/mask-markup/src/componentize.js
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
declare const _default: (s: any, t: any) => {
|
|
10
|
-
markup: any;
|
|
11
|
-
};
|
|
12
|
-
export default _default;
|
package/dist/componentize.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-lib/packages/mask-markup/src/components/blank.jsx
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
declare function DragDropBlank({ id, disabled, duplicates, choice, correct, onChange, emptyResponseAreaWidth, emptyResponseAreaHeight, instanceId, }: {
|
|
12
|
-
id: any;
|
|
13
|
-
disabled: any;
|
|
14
|
-
duplicates: any;
|
|
15
|
-
choice: any;
|
|
16
|
-
correct: any;
|
|
17
|
-
onChange: any;
|
|
18
|
-
emptyResponseAreaWidth: any;
|
|
19
|
-
emptyResponseAreaHeight: any;
|
|
20
|
-
instanceId: any;
|
|
21
|
-
}): React.JSX.Element;
|
|
22
|
-
declare namespace DragDropBlank {
|
|
23
|
-
var defaultProps: {
|
|
24
|
-
emptyResponseAreaWidth: number;
|
|
25
|
-
emptyResponseAreaHeight: number;
|
|
26
|
-
};
|
|
27
|
-
var propTypes: {
|
|
28
|
-
id: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
29
|
-
disabled: PropTypes.Requireable<boolean>;
|
|
30
|
-
duplicates: PropTypes.Requireable<boolean>;
|
|
31
|
-
choice: PropTypes.Requireable<object>;
|
|
32
|
-
correct: PropTypes.Requireable<boolean>;
|
|
33
|
-
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
34
|
-
emptyResponseAreaWidth: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
35
|
-
emptyResponseAreaHeight: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
36
|
-
instanceId: PropTypes.Requireable<string>;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
export default DragDropBlank;
|
package/dist/components/blank.js
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import e from "../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
|
|
2
|
-
import t, { useEffect as n, useRef as r, useState as i } from "react";
|
|
3
|
-
import a from "prop-types";
|
|
4
|
-
import { styled as o } from "@mui/material/styles";
|
|
5
|
-
import { renderMath as s } from "@pie-element/shared-math-rendering-mathjax";
|
|
6
|
-
import c from "debug";
|
|
7
|
-
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
8
|
-
import { useDraggable as d, useDroppable as f } from "@dnd-kit/core";
|
|
9
|
-
import p from "@mui/material/Chip";
|
|
10
|
-
import { color as m } from "@pie-lib/render-ui";
|
|
11
|
-
import { CSS as h } from "@dnd-kit/utilities";
|
|
12
|
-
import { grey as g } from "@mui/material/colors";
|
|
13
|
-
//#region src/components/blank.tsx
|
|
14
|
-
c("pie-lib:mask-markup:blank");
|
|
15
|
-
var _ = o("span")(({ dragged: e, over: t }) => ({
|
|
16
|
-
border: `solid 0px ${m.primary()}`,
|
|
17
|
-
minWidth: "200px",
|
|
18
|
-
touchAction: "none",
|
|
19
|
-
overflow: "hidden",
|
|
20
|
-
whiteSpace: "nowrap",
|
|
21
|
-
opacity: 1,
|
|
22
|
-
...t && {
|
|
23
|
-
whiteSpace: "nowrap",
|
|
24
|
-
overflow: "hidden"
|
|
25
|
-
},
|
|
26
|
-
...e && { opacity: .5 }
|
|
27
|
-
})), v = o(p)(() => ({
|
|
28
|
-
backgroundColor: m.background(),
|
|
29
|
-
border: `2px dashed ${m.text()}`,
|
|
30
|
-
touchAction: "none",
|
|
31
|
-
color: m.text(),
|
|
32
|
-
fontSize: "inherit",
|
|
33
|
-
maxWidth: "374px",
|
|
34
|
-
position: "relative",
|
|
35
|
-
borderRadius: "3px",
|
|
36
|
-
"&.over": {
|
|
37
|
-
whiteSpace: "nowrap",
|
|
38
|
-
overflow: "hidden"
|
|
39
|
-
},
|
|
40
|
-
"&.parentOver": {
|
|
41
|
-
border: `1px solid ${g[500]}`,
|
|
42
|
-
backgroundColor: `${g[300]}`
|
|
43
|
-
},
|
|
44
|
-
"&.correct": { border: `solid 1px ${m.correct()}` },
|
|
45
|
-
"&.incorrect": { border: `solid 1px ${m.incorrect()}` },
|
|
46
|
-
"&.Mui-disabled": { opacity: 1 }
|
|
47
|
-
})), y = o("span")(() => ({
|
|
48
|
-
whiteSpace: "normal",
|
|
49
|
-
pointerEvents: "none",
|
|
50
|
-
"& img": {
|
|
51
|
-
display: "block",
|
|
52
|
-
padding: "2px 0"
|
|
53
|
-
},
|
|
54
|
-
"& p": {
|
|
55
|
-
marginTop: "0",
|
|
56
|
-
marginBottom: "0"
|
|
57
|
-
},
|
|
58
|
-
"& mjx-frac": { fontSize: "120% !important" },
|
|
59
|
-
"&.over": {
|
|
60
|
-
whiteSpace: "nowrap",
|
|
61
|
-
overflow: "hidden"
|
|
62
|
-
},
|
|
63
|
-
"&.hidden": {
|
|
64
|
-
color: "transparent",
|
|
65
|
-
opacity: 0
|
|
66
|
-
},
|
|
67
|
-
"&.dragged": {
|
|
68
|
-
position: "absolute",
|
|
69
|
-
left: 16,
|
|
70
|
-
maxWidth: "60px",
|
|
71
|
-
top: "50%",
|
|
72
|
-
transform: "translateY(-50%)"
|
|
73
|
-
}
|
|
74
|
-
}));
|
|
75
|
-
function b({ disabled: a, choice: o, isOver: c, isDragging: d, dragItem: f, correct: p, emptyResponseAreaWidth: m, emptyResponseAreaHeight: h }) {
|
|
76
|
-
let g = r(null), _ = r(null), b = r(null), [x, S] = i({
|
|
77
|
-
height: 0,
|
|
78
|
-
width: 0
|
|
79
|
-
}), C = () => {
|
|
80
|
-
E();
|
|
81
|
-
}, w = () => {
|
|
82
|
-
let e = _.current?.querySelector("img");
|
|
83
|
-
e ? e.onload = C : setTimeout(() => {
|
|
84
|
-
E();
|
|
85
|
-
}, 300);
|
|
86
|
-
}, T = () => _.current ? _.current.querySelector("mjx-container") && _.current.parentElement ? _.current.parentElement : _.current.querySelector("img") || _.current : null, E = () => {
|
|
87
|
-
if (_.current && g.current) {
|
|
88
|
-
g.current.style.width = "auto", g.current.style.height = "auto", g.current.offsetHeight;
|
|
89
|
-
let e = T() || _.current, t = e.getBoundingClientRect(), n = t.width || e.offsetWidth || 0, r = Math.max(t.height || 0, e.offsetHeight || 0, e.scrollHeight || 0, _.current.scrollHeight || 0), i = n + 24, a = r + 24, o = parseFloat(m) || 0, s = parseFloat(h) || 0, c = i <= o ? o : i, l = a <= s ? s : a;
|
|
90
|
-
S((e) => ({
|
|
91
|
-
width: c > o ? c : e.width,
|
|
92
|
-
height: l > s ? l : e.height
|
|
93
|
-
})), g.current.style.width = `${c}px`, g.current.style.height = `${l}px`;
|
|
94
|
-
}
|
|
95
|
-
}, D = () => {
|
|
96
|
-
let e = isNaN(parseFloat(m)) ? 0 : parseFloat(m), t = isNaN(parseFloat(h)) ? 0 : parseFloat(h);
|
|
97
|
-
return {
|
|
98
|
-
height: x.height || t,
|
|
99
|
-
width: x.width || e,
|
|
100
|
-
...e ? {} : { minWidth: 90 },
|
|
101
|
-
...t ? {} : { minHeight: 32 }
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
n(() => {
|
|
105
|
-
w();
|
|
106
|
-
}, []), n(() => {
|
|
107
|
-
g.current && s(g.current);
|
|
108
|
-
}, [
|
|
109
|
-
p,
|
|
110
|
-
c,
|
|
111
|
-
f?.choice?.value
|
|
112
|
-
]), n(() => {
|
|
113
|
-
if (!o) {
|
|
114
|
-
S({
|
|
115
|
-
height: 0,
|
|
116
|
-
width: 0
|
|
117
|
-
});
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
w();
|
|
121
|
-
}, [o]), n(() => {
|
|
122
|
-
!c && !d && (b.current = {
|
|
123
|
-
width: g.current.offsetWidth,
|
|
124
|
-
height: g.current.offsetHeight
|
|
125
|
-
});
|
|
126
|
-
}, [
|
|
127
|
-
o,
|
|
128
|
-
c,
|
|
129
|
-
d
|
|
130
|
-
]);
|
|
131
|
-
let O = f && c && f.choice && f.choice.value, k = o && o.value, A = c || d ? {
|
|
132
|
-
width: b.current?.width,
|
|
133
|
-
height: b.current?.height
|
|
134
|
-
} : D();
|
|
135
|
-
return /* @__PURE__ */ l(v, {
|
|
136
|
-
clickable: !1,
|
|
137
|
-
disabled: a,
|
|
138
|
-
ref: g,
|
|
139
|
-
component: "span",
|
|
140
|
-
label: /* @__PURE__ */ u(t.Fragment, { children: [/* @__PURE__ */ l(y, {
|
|
141
|
-
ref: _,
|
|
142
|
-
draggable: !0,
|
|
143
|
-
className: e({
|
|
144
|
-
over: c,
|
|
145
|
-
hidden: O
|
|
146
|
-
}),
|
|
147
|
-
dangerouslySetInnerHTML: { __html: k || "" }
|
|
148
|
-
}), O && /* @__PURE__ */ l(y, {
|
|
149
|
-
draggable: !0,
|
|
150
|
-
className: e({
|
|
151
|
-
over: c,
|
|
152
|
-
dragged: !0
|
|
153
|
-
}),
|
|
154
|
-
dangerouslySetInnerHTML: { __html: O || "" }
|
|
155
|
-
})] }),
|
|
156
|
-
className: e({
|
|
157
|
-
over: c,
|
|
158
|
-
parentOver: c,
|
|
159
|
-
correct: p !== void 0 && p,
|
|
160
|
-
incorrect: p !== void 0 && !p
|
|
161
|
-
}),
|
|
162
|
-
variant: a ? "outlined" : void 0,
|
|
163
|
-
style: A
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
b.defaultProps = {
|
|
167
|
-
emptyResponseAreaWidth: 0,
|
|
168
|
-
emptyResponseAreaHeight: 0
|
|
169
|
-
}, b.propTypes = {
|
|
170
|
-
id: a.oneOfType([a.string, a.number]),
|
|
171
|
-
disabled: a.bool,
|
|
172
|
-
duplicates: a.bool,
|
|
173
|
-
choice: a.object,
|
|
174
|
-
isOver: a.bool,
|
|
175
|
-
dragItem: a.object,
|
|
176
|
-
correct: a.bool,
|
|
177
|
-
onChange: a.func,
|
|
178
|
-
emptyResponseAreaWidth: a.oneOfType([a.string, a.number]),
|
|
179
|
-
emptyResponseAreaHeight: a.oneOfType([a.string, a.number]),
|
|
180
|
-
instanceId: a.string
|
|
181
|
-
};
|
|
182
|
-
function x({ id: e, disabled: t, duplicates: n, choice: r, correct: i, onChange: a, emptyResponseAreaWidth: o, emptyResponseAreaHeight: s, instanceId: c }) {
|
|
183
|
-
let { attributes: u, listeners: p, setNodeRef: m, transform: g, isDragging: v } = d({
|
|
184
|
-
id: `mask-blank-drag-${e}`,
|
|
185
|
-
disabled: t || !r,
|
|
186
|
-
data: {
|
|
187
|
-
id: e,
|
|
188
|
-
choice: r,
|
|
189
|
-
instanceId: c,
|
|
190
|
-
fromChoice: !1,
|
|
191
|
-
type: "MaskBlank"
|
|
192
|
-
}
|
|
193
|
-
}), { setNodeRef: y, isOver: x, active: S } = f({
|
|
194
|
-
id: `mask-blank-drop-${e}`,
|
|
195
|
-
data: {
|
|
196
|
-
id: e,
|
|
197
|
-
accepts: ["MaskBlank"],
|
|
198
|
-
instanceId: c
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
return /* @__PURE__ */ l(_, {
|
|
202
|
-
ref: (e) => {
|
|
203
|
-
m(e), y(e);
|
|
204
|
-
},
|
|
205
|
-
style: { transform: h.Translate.toString(g) },
|
|
206
|
-
dragged: v,
|
|
207
|
-
over: x,
|
|
208
|
-
...u,
|
|
209
|
-
...p,
|
|
210
|
-
children: /* @__PURE__ */ l(b, {
|
|
211
|
-
id: e,
|
|
212
|
-
disabled: t,
|
|
213
|
-
duplicates: n,
|
|
214
|
-
choice: r,
|
|
215
|
-
isOver: x,
|
|
216
|
-
dragItem: S?.data?.current,
|
|
217
|
-
correct: i,
|
|
218
|
-
onChange: a,
|
|
219
|
-
emptyResponseAreaWidth: o,
|
|
220
|
-
emptyResponseAreaHeight: s,
|
|
221
|
-
instanceId: c
|
|
222
|
-
})
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
x.defaultProps = {
|
|
226
|
-
emptyResponseAreaWidth: 0,
|
|
227
|
-
emptyResponseAreaHeight: 0
|
|
228
|
-
}, x.propTypes = {
|
|
229
|
-
id: a.oneOfType([a.string, a.number]),
|
|
230
|
-
disabled: a.bool,
|
|
231
|
-
duplicates: a.bool,
|
|
232
|
-
choice: a.object,
|
|
233
|
-
correct: a.bool,
|
|
234
|
-
onChange: a.func,
|
|
235
|
-
emptyResponseAreaWidth: a.oneOfType([a.string, a.number]),
|
|
236
|
-
emptyResponseAreaHeight: a.oneOfType([a.string, a.number]),
|
|
237
|
-
instanceId: a.string
|
|
238
|
-
};
|
|
239
|
-
//#endregion
|
|
240
|
-
export { x as default };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-lib/packages/mask-markup/src/components/correct-input.jsx
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
import React from 'react';
|
|
10
|
-
declare const CorrectInput: (props: any) => React.JSX.Element;
|
|
11
|
-
export default CorrectInput;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-lib/packages/mask-markup/src/components/dropdown.jsx
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
declare class Dropdown extends React.Component {
|
|
12
|
-
static propTypes: {
|
|
13
|
-
id: PropTypes.Requireable<string>;
|
|
14
|
-
value: PropTypes.Requireable<string>;
|
|
15
|
-
disabled: PropTypes.Requireable<boolean>;
|
|
16
|
-
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
17
|
-
correct: PropTypes.Requireable<boolean>;
|
|
18
|
-
choices: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
19
|
-
value: PropTypes.Requireable<string>;
|
|
20
|
-
label: PropTypes.Requireable<string>;
|
|
21
|
-
}> | null | undefined)[]>;
|
|
22
|
-
showCorrectAnswer: PropTypes.Requireable<boolean>;
|
|
23
|
-
singleQuery: PropTypes.Requireable<boolean>;
|
|
24
|
-
correctValue: PropTypes.Requireable<string>;
|
|
25
|
-
};
|
|
26
|
-
constructor(props: any);
|
|
27
|
-
componentDidMount(): void;
|
|
28
|
-
componentDidUpdate(prevProps: any, prevState: any): void;
|
|
29
|
-
handleClick: any;
|
|
30
|
-
handleClose: any;
|
|
31
|
-
handleHighlight: any;
|
|
32
|
-
handleSelect: any;
|
|
33
|
-
handleHover: any;
|
|
34
|
-
getLabel(choices: any, value: any): any;
|
|
35
|
-
render(): React.JSX.Element;
|
|
36
|
-
}
|
|
37
|
-
export default Dropdown;
|