@pie-lib/drag 2.2.3-next.0 → 2.2.3-next.5

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.
@@ -27,30 +27,52 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
27
27
 
28
28
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
29
 
30
- var MaskBlankStyle = {
31
- border: '1px solid black',
32
- color: 'black',
33
- minWidth: '90px',
34
- minHeight: '32px',
35
- height: 'auto',
36
- maxWidth: '374px',
37
- display: 'flex',
38
- padding: '4px',
39
- alignItems: 'center',
40
- justifyContent: 'center',
41
- borderRadius: '16px'
42
- };
43
- var ICAStyle = {
44
- backgroundColor: _renderUi.color.background(),
45
- border: "1px solid ".concat(_renderUi.color.text()),
46
- display: 'flex',
47
- alignItems: 'center',
48
- justifyContent: 'center',
49
- minHeight: '28px',
50
- padding: '0 3px',
51
- marginLeft: 2,
52
- marginTop: 2,
53
- width: 'fit-content'
30
+ var styles = {
31
+ maskBlank: {
32
+ border: '1px solid black',
33
+ color: 'black',
34
+ minWidth: '90px',
35
+ minHeight: '32px',
36
+ height: 'auto',
37
+ maxWidth: '374px',
38
+ display: 'flex',
39
+ padding: '4px',
40
+ alignItems: 'center',
41
+ justifyContent: 'center',
42
+ borderRadius: '16px'
43
+ },
44
+ ica: {
45
+ backgroundColor: _renderUi.color.background(),
46
+ border: "1px solid ".concat(_renderUi.color.text()),
47
+ display: 'flex',
48
+ alignItems: 'center',
49
+ justifyContent: 'center',
50
+ minHeight: '28px',
51
+ padding: '0 3px',
52
+ marginLeft: 2,
53
+ marginTop: 2,
54
+ width: 'fit-content'
55
+ },
56
+ categorize: {
57
+ color: _renderUi.color.text(),
58
+ backgroundColor: _renderUi.color.background(),
59
+ padding: '16px',
60
+ borderRadius: '4px',
61
+ border: '1px solid'
62
+ },
63
+ matchList: {
64
+ color: _renderUi.color.text(),
65
+ backgroundColor: _renderUi.color.background(),
66
+ padding: '10px',
67
+ boxSizing: 'border-box',
68
+ border: '1px solid #D1D1D1'
69
+ },
70
+ placementOrdering: {
71
+ padding: '10px',
72
+ boxSizing: 'border-box',
73
+ border: '1px solid #D1D1D1',
74
+ backgroundColor: _renderUi.color.background()
75
+ }
54
76
  };
55
77
 
56
78
  var getPrompt = function getPrompt(itemType, item) {
@@ -64,12 +86,26 @@ var getPrompt = function getPrompt(itemType, item) {
64
86
 
65
87
  case 'react-dnd-response':
66
88
  return item === null || item === void 0 ? void 0 : item.value;
89
+ // MATCH-LIST
90
+
91
+ case 'Answer':
92
+ return item === null || item === void 0 ? void 0 : item.value;
93
+ // PLACEMENT-ORDERING
94
+
95
+ case 'Tile':
96
+ return item === null || item === void 0 ? void 0 : item.value;
67
97
 
68
98
  default:
69
- return undefined;
99
+ return (item === null || item === void 0 ? void 0 : item.itemType) === 'categorize' ? item === null || item === void 0 ? void 0 : item.value : undefined;
70
100
  }
71
101
  };
72
102
 
103
+ var getCustomStyle = function getCustomStyle(itemType, item, style) {
104
+ var baseStyle = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, style), itemType === 'MaskBlank' ? styles.maskBlank : {}), (item === null || item === void 0 ? void 0 : item.itemType) === 'categorize' ? styles.categorize : {}), itemType === 'Answer' ? styles.matchList : {}), itemType === 'Tile' ? styles.placementOrdering : {});
105
+
106
+ return baseStyle;
107
+ };
108
+
73
109
  var PreviewComponent = function PreviewComponent() {
74
110
  var _item$choice2;
75
111
 
@@ -89,8 +125,7 @@ var PreviewComponent = function PreviewComponent() {
89
125
  return null;
90
126
  }
91
127
 
92
- var customStyle = _objectSpread(_objectSpread({}, style), itemType === 'MaskBlank' ? MaskBlankStyle : {});
93
-
128
+ var customStyle = getCustomStyle(itemType, item, style);
94
129
  var prompt = getPrompt(itemType, item);
95
130
  return /*#__PURE__*/_react["default"].createElement("div", {
96
131
  ref: root,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/preview-component.jsx"],"names":["MaskBlankStyle","border","color","minWidth","minHeight","height","maxWidth","display","padding","alignItems","justifyContent","borderRadius","ICAStyle","backgroundColor","background","text","marginLeft","marginTop","width","getPrompt","itemType","item","choice","value","undefined","PreviewComponent","preview","style","root","current","customStyle","prompt"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;AAGA,IAAMA,cAAc,GAAG;AACrBC,EAAAA,MAAM,EAAE,iBADa;AAErBC,EAAAA,KAAK,EAAE,OAFc;AAGrBC,EAAAA,QAAQ,EAAE,MAHW;AAIrBC,EAAAA,SAAS,EAAE,MAJU;AAKrBC,EAAAA,MAAM,EAAE,MALa;AAMrBC,EAAAA,QAAQ,EAAE,OANW;AAOrBC,EAAAA,OAAO,EAAE,MAPY;AAQrBC,EAAAA,OAAO,EAAE,KARY;AASrBC,EAAAA,UAAU,EAAE,QATS;AAUrBC,EAAAA,cAAc,EAAE,QAVK;AAWrBC,EAAAA,YAAY,EAAE;AAXO,CAAvB;AAcA,IAAMC,QAAQ,GAAG;AACfC,EAAAA,eAAe,EAAEX,gBAAMY,UAAN,EADF;AAEfb,EAAAA,MAAM,sBAAeC,gBAAMa,IAAN,EAAf,CAFS;AAGfR,EAAAA,OAAO,EAAE,MAHM;AAIfE,EAAAA,UAAU,EAAE,QAJG;AAKfC,EAAAA,cAAc,EAAE,QALD;AAMfN,EAAAA,SAAS,EAAE,MANI;AAOfI,EAAAA,OAAO,EAAE,OAPM;AAQfQ,EAAAA,UAAU,EAAE,CARG;AASfC,EAAAA,SAAS,EAAE,CATI;AAUfC,EAAAA,KAAK,EAAE;AAVQ,CAAjB;;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,GAAG,EAAEO,IAAV;AAAgB,IAAA,KAAK,EAAEE;AAAvB,kBACE,gCAAC,uBAAD;AAAe,IAAA,SAAS,EAAC,OAAzB;AAAiC,IAAA,MAAM,EAAEC,MAAzC;AAAiD,IAAA,OAAO,EAAC;AAAzD,IADF,CADF;AAKD,CA9BD;;eAgCeN,gB","sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport { usePreview } from 'react-dnd-multi-backend';\nimport { PreviewPrompt } from '@pie-lib/render-ui';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { color } from '@pie-lib/render-ui';\n\nconst MaskBlankStyle = {\n border: '1px solid black',\n color: 'black',\n minWidth: '90px',\n minHeight: '32px',\n height: 'auto',\n maxWidth: '374px',\n display: 'flex',\n padding: '4px',\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: '16px',\n};\n\nconst ICAStyle = {\n backgroundColor: color.background(),\n border: `1px solid ${color.text()}`,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: '28px',\n padding: '0 3px',\n marginLeft: 2,\n marginTop: 2,\n width: 'fit-content',\n};\n\nconst getPrompt = (itemType, item) => {\n switch (itemType) {\n // DRAG-IN-THE-BLANK\n case 'MaskBlank':\n return item?.choice?.value;\n // IMAGE-CLOZE-ASSOCIATION\n case 'react-dnd-response':\n return item?.value;\n default:\n return undefined;\n }\n};\n\nconst PreviewComponent = () => {\n const preview = usePreview();\n const { itemType, item, style, display } = preview;\n\n let root = useRef(null);\n\n useEffect(() => {\n if (display && root.current) {\n renderMath(root.current);\n }\n }, [display, item?.choice?.value, item?.value, itemType, item]);\n\n if (!display) {\n return null;\n }\n\n const customStyle = {\n ...style,\n ...(itemType === 'MaskBlank' ? MaskBlankStyle : {}),\n // TODO: In the image-cloze-association component, there's a noticeable delay in the image rendering process. This results in a brief display of an empty image placeholder before the actual image appears after a few seconds. This issue also impacts the correct rendering of the preview feature, thereby negatively affecting the user experience. This needs to be addressed promptly.\n //...(itemType === 'react-dnd-response' ? ICAStyle : {}),\n };\n\n const prompt = getPrompt(itemType, item);\n\n return (\n <div ref={root} style={customStyle}>\n <PreviewPrompt className=\"label\" prompt={prompt} tagName=\"span\" />\n </div>\n );\n};\n\nexport default PreviewComponent;\n"],"file":"preview-component.js"}
1
+ {"version":3,"sources":["../src/preview-component.jsx"],"names":["styles","maskBlank","border","color","minWidth","minHeight","height","maxWidth","display","padding","alignItems","justifyContent","borderRadius","ica","backgroundColor","background","text","marginLeft","marginTop","width","categorize","matchList","boxSizing","placementOrdering","getPrompt","itemType","item","choice","value","undefined","getCustomStyle","style","baseStyle","PreviewComponent","preview","root","current","customStyle","prompt"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;AAGA,IAAMA,MAAM,GAAG;AACbC,EAAAA,SAAS,EAAE;AACTC,IAAAA,MAAM,EAAE,iBADC;AAETC,IAAAA,KAAK,EAAE,OAFE;AAGTC,IAAAA,QAAQ,EAAE,MAHD;AAITC,IAAAA,SAAS,EAAE,MAJF;AAKTC,IAAAA,MAAM,EAAE,MALC;AAMTC,IAAAA,QAAQ,EAAE,OAND;AAOTC,IAAAA,OAAO,EAAE,MAPA;AAQTC,IAAAA,OAAO,EAAE,KARA;AASTC,IAAAA,UAAU,EAAE,QATH;AAUTC,IAAAA,cAAc,EAAE,QAVP;AAWTC,IAAAA,YAAY,EAAE;AAXL,GADE;AAcbC,EAAAA,GAAG,EAAE;AACHC,IAAAA,eAAe,EAAEX,gBAAMY,UAAN,EADd;AAEHb,IAAAA,MAAM,sBAAeC,gBAAMa,IAAN,EAAf,CAFH;AAGHR,IAAAA,OAAO,EAAE,MAHN;AAIHE,IAAAA,UAAU,EAAE,QAJT;AAKHC,IAAAA,cAAc,EAAE,QALb;AAMHN,IAAAA,SAAS,EAAE,MANR;AAOHI,IAAAA,OAAO,EAAE,OAPN;AAQHQ,IAAAA,UAAU,EAAE,CART;AASHC,IAAAA,SAAS,EAAE,CATR;AAUHC,IAAAA,KAAK,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AAsDC,IAAtD,CAJH;;AAMA,MAAI,CAAClB,OAAL,EAAc;AACZ,WAAO,IAAP;AACD;;AAED,MAAM6B,WAAW,GAAGP,cAAc,CAACL,QAAD,EAAWC,IAAX,EAAiBK,KAAjB,CAAlC;AAEA,MAAMO,MAAM,GAAGd,SAAS,CAACC,QAAD,EAAWC,IAAX,CAAxB;AAEA,sBACE;AAAK,IAAA,GAAG,EAAES,IAAV;AAAgB,IAAA,KAAK,EAAEE;AAAvB,kBACE,gCAAC,uBAAD;AAAe,IAAA,SAAS,EAAC,OAAzB;AAAiC,IAAA,MAAM,EAAEC,MAAzC;AAAiD,IAAA,OAAO,EAAC;AAAzD,IADF,CADF;AAKD,CAzBD;;eA2BeL,gB","sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport { usePreview } from 'react-dnd-multi-backend';\nimport { PreviewPrompt } from '@pie-lib/render-ui';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { color } from '@pie-lib/render-ui';\n\nconst styles = {\n maskBlank: {\n border: '1px solid black',\n color: 'black',\n minWidth: '90px',\n minHeight: '32px',\n height: 'auto',\n maxWidth: '374px',\n display: 'flex',\n padding: '4px',\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: '16px',\n },\n ica: {\n backgroundColor: color.background(),\n border: `1px solid ${color.text()}`,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: '28px',\n padding: '0 3px',\n marginLeft: 2,\n marginTop: 2,\n width: 'fit-content',\n },\n categorize: {\n color: color.text(),\n backgroundColor: color.background(),\n padding: '16px',\n borderRadius: '4px',\n border: '1px solid',\n },\n matchList: {\n color: color.text(),\n backgroundColor: color.background(),\n padding: '10px',\n boxSizing: 'border-box',\n border: '1px solid #D1D1D1',\n },\n placementOrdering: {\n padding: '10px',\n boxSizing: 'border-box',\n border: '1px solid #D1D1D1',\n backgroundColor: color.background(),\n },\n};\n\nconst getPrompt = (itemType, item) => {\n switch (itemType) {\n // DRAG-IN-THE-BLANK\n case 'MaskBlank':\n return item?.choice?.value;\n // IMAGE-CLOZE-ASSOCIATION\n case 'react-dnd-response':\n return item?.value;\n // MATCH-LIST\n case 'Answer':\n return item?.value;\n // PLACEMENT-ORDERING\n case 'Tile':\n return item?.value;\n default:\n return item?.itemType === 'categorize' ? item?.value : undefined;\n }\n};\n\nconst getCustomStyle = (itemType, item, style) => {\n const baseStyle = {\n ...style,\n ...(itemType === 'MaskBlank' ? styles.maskBlank : {}),\n ...(item?.itemType === 'categorize' ? styles.categorize : {}),\n ...(itemType === 'Answer' ? styles.matchList : {}),\n ...(itemType === 'Tile' ? styles.placementOrdering : {}),\n // TODO: In the image-cloze-association component, there's a noticeable delay in the image rendering process. This results in a brief display of an empty image placeholder before the actual image appears after a few seconds. This issue also impacts the correct rendering of the preview feature, thereby negatively affecting the user experience. This needs to be addressed promptly.\n //...(itemType === 'react-dnd-response' ? styles.ica : {}),\n };\n\n return baseStyle;\n};\n\nconst PreviewComponent = () => {\n const preview = usePreview();\n const { itemType, item, style, display } = preview;\n\n const root = useRef(null);\n\n useEffect(() => {\n if (display && root.current) {\n renderMath(root.current);\n }\n }, [display, item?.choice?.value, item?.value, itemType, item]);\n\n if (!display) {\n return null;\n }\n\n const customStyle = getCustomStyle(itemType, item, style);\n\n const prompt = getPrompt(itemType, item);\n\n return (\n <div ref={root} style={customStyle}>\n <PreviewPrompt className=\"label\" prompt={prompt} tagName=\"span\" />\n </div>\n );\n};\n\nexport default PreviewComponent;\n"],"file":"preview-component.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/drag",
3
- "version": "2.2.3-next.0+0d6a88e7",
3
+ "version": "2.2.3-next.5+4343aa3e",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "src/index.js",
@@ -19,5 +19,5 @@
19
19
  "scripts": {},
20
20
  "author": "",
21
21
  "license": "ISC",
22
- "gitHead": "0d6a88e73b9db47c4fe07377d5e8dfb8d9dd06a1"
22
+ "gitHead": "4343aa3e2c9dd8fc83c467eea4d7742663a5ce65"
23
23
  }
@@ -4,31 +4,52 @@ import { PreviewPrompt } from '@pie-lib/render-ui';
4
4
  import { renderMath } from '@pie-lib/math-rendering';
5
5
  import { color } from '@pie-lib/render-ui';
6
6
 
7
- const MaskBlankStyle = {
8
- border: '1px solid black',
9
- color: 'black',
10
- minWidth: '90px',
11
- minHeight: '32px',
12
- height: 'auto',
13
- maxWidth: '374px',
14
- display: 'flex',
15
- padding: '4px',
16
- alignItems: 'center',
17
- justifyContent: 'center',
18
- borderRadius: '16px',
19
- };
20
-
21
- const ICAStyle = {
22
- backgroundColor: color.background(),
23
- border: `1px solid ${color.text()}`,
24
- display: 'flex',
25
- alignItems: 'center',
26
- justifyContent: 'center',
27
- minHeight: '28px',
28
- padding: '0 3px',
29
- marginLeft: 2,
30
- marginTop: 2,
31
- width: 'fit-content',
7
+ const styles = {
8
+ maskBlank: {
9
+ border: '1px solid black',
10
+ color: 'black',
11
+ minWidth: '90px',
12
+ minHeight: '32px',
13
+ height: 'auto',
14
+ maxWidth: '374px',
15
+ display: 'flex',
16
+ padding: '4px',
17
+ alignItems: 'center',
18
+ justifyContent: 'center',
19
+ borderRadius: '16px',
20
+ },
21
+ ica: {
22
+ backgroundColor: color.background(),
23
+ border: `1px solid ${color.text()}`,
24
+ display: 'flex',
25
+ alignItems: 'center',
26
+ justifyContent: 'center',
27
+ minHeight: '28px',
28
+ padding: '0 3px',
29
+ marginLeft: 2,
30
+ marginTop: 2,
31
+ width: 'fit-content',
32
+ },
33
+ categorize: {
34
+ color: color.text(),
35
+ backgroundColor: color.background(),
36
+ padding: '16px',
37
+ borderRadius: '4px',
38
+ border: '1px solid',
39
+ },
40
+ matchList: {
41
+ color: color.text(),
42
+ backgroundColor: color.background(),
43
+ padding: '10px',
44
+ boxSizing: 'border-box',
45
+ border: '1px solid #D1D1D1',
46
+ },
47
+ placementOrdering: {
48
+ padding: '10px',
49
+ boxSizing: 'border-box',
50
+ border: '1px solid #D1D1D1',
51
+ backgroundColor: color.background(),
52
+ },
32
53
  };
33
54
 
34
55
  const getPrompt = (itemType, item) => {
@@ -39,16 +60,36 @@ const getPrompt = (itemType, item) => {
39
60
  // IMAGE-CLOZE-ASSOCIATION
40
61
  case 'react-dnd-response':
41
62
  return item?.value;
63
+ // MATCH-LIST
64
+ case 'Answer':
65
+ return item?.value;
66
+ // PLACEMENT-ORDERING
67
+ case 'Tile':
68
+ return item?.value;
42
69
  default:
43
- return undefined;
70
+ return item?.itemType === 'categorize' ? item?.value : undefined;
44
71
  }
45
72
  };
46
73
 
74
+ const getCustomStyle = (itemType, item, style) => {
75
+ const baseStyle = {
76
+ ...style,
77
+ ...(itemType === 'MaskBlank' ? styles.maskBlank : {}),
78
+ ...(item?.itemType === 'categorize' ? styles.categorize : {}),
79
+ ...(itemType === 'Answer' ? styles.matchList : {}),
80
+ ...(itemType === 'Tile' ? styles.placementOrdering : {}),
81
+ // TODO: In the image-cloze-association component, there's a noticeable delay in the image rendering process. This results in a brief display of an empty image placeholder before the actual image appears after a few seconds. This issue also impacts the correct rendering of the preview feature, thereby negatively affecting the user experience. This needs to be addressed promptly.
82
+ //...(itemType === 'react-dnd-response' ? styles.ica : {}),
83
+ };
84
+
85
+ return baseStyle;
86
+ };
87
+
47
88
  const PreviewComponent = () => {
48
89
  const preview = usePreview();
49
90
  const { itemType, item, style, display } = preview;
50
91
 
51
- let root = useRef(null);
92
+ const root = useRef(null);
52
93
 
53
94
  useEffect(() => {
54
95
  if (display && root.current) {
@@ -60,12 +101,7 @@ const PreviewComponent = () => {
60
101
  return null;
61
102
  }
62
103
 
63
- const customStyle = {
64
- ...style,
65
- ...(itemType === 'MaskBlank' ? MaskBlankStyle : {}),
66
- // TODO: In the image-cloze-association component, there's a noticeable delay in the image rendering process. This results in a brief display of an empty image placeholder before the actual image appears after a few seconds. This issue also impacts the correct rendering of the preview feature, thereby negatively affecting the user experience. This needs to be addressed promptly.
67
- //...(itemType === 'react-dnd-response' ? ICAStyle : {}),
68
- };
104
+ const customStyle = getCustomStyle(itemType, item, style);
69
105
 
70
106
  const prompt = getPrompt(itemType, item);
71
107