@pie-element/boilerplate-item-type 2.0.4-next.4 → 2.0.5-next.1
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/configure/lib/design.js +2 -2
- package/configure/lib/design.js.map +1 -1
- package/configure/package.json +1 -1
- package/controller/package.json +1 -1
- package/lib/main.js +1 -1
- package/lib/main.js.map +1 -1
- package/lib/print.js +109 -0
- package/lib/print.js.map +1 -0
- package/module/demo.js +30 -0
- package/module/element.js +128 -0
- package/module/index.html +21 -0
- package/module/manifest.json +10 -0
- package/module/print-demo.js +68 -0
- package/module/print.html +18 -0
- package/module/print.js +92 -0
- package/package.json +4 -3
package/configure/lib/design.js
CHANGED
|
@@ -31,7 +31,7 @@ var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
|
31
31
|
|
|
32
32
|
var _configUi = require("@pie-lib/pie-toolbox/config-ui");
|
|
33
33
|
|
|
34
|
-
var _editableHtml =
|
|
34
|
+
var _editableHtml = require("@pie-lib/pie-toolbox/editable-html");
|
|
35
35
|
|
|
36
36
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
37
37
|
|
|
@@ -110,7 +110,7 @@ var Design = /*#__PURE__*/function (_React$Component) {
|
|
|
110
110
|
}, promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
|
|
111
111
|
label: prompt.label || '',
|
|
112
112
|
className: classes.promptHolder
|
|
113
|
-
}, /*#__PURE__*/_react["default"].createElement(_editableHtml
|
|
113
|
+
}, /*#__PURE__*/_react["default"].createElement(_editableHtml.EditableHtml, {
|
|
114
114
|
className: classes.prompt,
|
|
115
115
|
markup: model.prompt,
|
|
116
116
|
onChange: this.onPromptChanged,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/design.jsx"],"names":["Panel","settings","toggle","Design","prompt","props","onModelChanged","model","update","classes","configuration","imageSupport","onConfigurationChanged","uploadSoundSupport","contentDimensions","settingsPanelDisabled","promptEnabled","panelSettings","panelProperties","label","Settings","Properties","promptHolder","onPromptChanged","language","React","Component","PropTypes","object","isRequired","func","shape","add","theme","width","paddingTop","spacing","unit","marginBottom"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAQA,KAAR,GAA0BC,kBAA1B,CAAQD,KAAR;AAAA,IAAeE,MAAf,GAA0BD,kBAA1B,CAAeC,MAAf;;IAEaC,M;;;;;;;;;;;;;;;wGAgBO,UAACC,MAAD,EAAY;AAC5B,wBAAkC,MAAKC,KAAvC;AAAA,UAAQC,cAAR,eAAQA,cAAR;AAAA,UAAwBC,KAAxB,eAAwBA,KAAxB;AACA,UAAMC,MAAM,GAAG,2BAAUD,KAAV,CAAf;AAEAC,MAAAA,MAAM,CAACJ,MAAP,GAAgBA,MAAhB;AACAE,MAAAA,cAAc,CAACE,MAAD,CAAd;AACD,K;;;;;;WAED,kBAAS;AACP,yBACE,KAAKH,KADP;AAAA,UAAQI,OAAR,gBAAQA,OAAR;AAAA,UAAiBC,aAAjB,gBAAiBA,aAAjB;AAAA,UAAgCC,YAAhC,gBAAgCA,YAAhC;AAAA,UAA8CJ,KAA9C,gBAA8CA,KAA9C;AAAA,UAAqDK,sBAArD,gBAAqDA,sBAArD;AAAA,UAA6EN,cAA7E,gBAA6EA,cAA7E;AAAA,UAA6FO,kBAA7F,gBAA6FA,kBAA7F;;AAEA,iBAIIH,aAAa,IAAI,EAJrB;AAAA,uCACEI,iBADF;AAAA,UACEA,iBADF,sCACsB,EADtB;AAAA,6BAEEV,MAFF;AAAA,UAEEA,MAFF,4BAEW,EAFX;AAAA,UAGEW,qBAHF,QAGEA,qBAHF;;AAKA,kBAA0BR,KAAK,IAAI,EAAnC;AAAA,UAAQS,aAAR,SAAQA,aAAR;;AAEA,UAAMC,aAAa,GAAG,EAAtB;AAEA,UAAMC,eAAe,GAAG;AACtBF,QAAAA,aAAa,EAAEZ,MAAM,CAACH,QAAP,IAAmBC,MAAM,CAACE,MAAM,CAACe,KAAR;AADlB,OAAxB;AAIA,0BACE,gCAAC,gBAAD,CAAQ,YAAR;AACE,QAAA,UAAU,EAAEL,iBADd;AAEE,QAAA,YAAY,EAAEC,qBAFhB;AAGE,QAAA,QAAQ,eACN,gCAAC,KAAD;AACE,UAAA,KAAK,EAAER,KADT;AAEE,UAAA,aAAa,EAAEG,aAFjB;AAGE,UAAA,aAAa,EAAE,uBAACH,KAAD;AAAA,mBAAWD,cAAc,CAACC,KAAD,CAAzB;AAAA,WAHjB;AAIE,UAAA,qBAAqB,EAAEK,sBAJzB;AAKE,UAAA,MAAM,EAAE;AACNQ,YAAAA,QAAQ,EAAEH,aADJ;AAENI,YAAAA,UAAU,EAAEH;AAFN;AALV;AAJJ,SAgBGF,aAAa,iBACZ,gCAAC,wBAAD;AAAgB,QAAA,KAAK,EAAEZ,MAAM,CAACe,KAAP,IAAgB,EAAvC;AAA2C,QAAA,SAAS,EAAEV,OAAO,CAACa;AAA9D,sBACE,gCAAC,
|
|
1
|
+
{"version":3,"sources":["../src/design.jsx"],"names":["Panel","settings","toggle","Design","prompt","props","onModelChanged","model","update","classes","configuration","imageSupport","onConfigurationChanged","uploadSoundSupport","contentDimensions","settingsPanelDisabled","promptEnabled","panelSettings","panelProperties","label","Settings","Properties","promptHolder","onPromptChanged","language","React","Component","PropTypes","object","isRequired","func","shape","add","theme","width","paddingTop","spacing","unit","marginBottom"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAQA,KAAR,GAA0BC,kBAA1B,CAAQD,K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AAUG,IAAV,CAAeD;AAFK,GAAhB,CANG;AAUjBhB,EAAAA,kBAAkB,EAAEc,sBAAUC;AAVb,C;iCADRzB,M,kBAcW,E;;eA4DT,wBAAW,UAAC8B,KAAD;AAAA,SAAY;AACpCX,IAAAA,YAAY,EAAE;AACZY,MAAAA,KAAK,EAAE,MADK;AAEZC,MAAAA,UAAU,EAAEF,KAAK,CAACG,OAAN,CAAcC,IAAd,GAAqB,CAFrB;AAGZC,MAAAA,YAAY,EAAEL,KAAK,CAACG,OAAN,CAAcC,IAAd,GAAqB;AAHvB;AADsB,GAAZ;AAAA,CAAX,EAMXlC,MANW,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport cloneDeep from 'lodash/cloneDeep';\nimport { InputContainer, settings, layout } from '@pie-lib/pie-toolbox/config-ui';\nimport {EditableHtml} from '@pie-lib/pie-toolbox/editable-html';\n\nconst { Panel, toggle } = settings;\n\nexport class Design extends React.Component {\n static propTypes = {\n model: PropTypes.object.isRequired,\n configuration: PropTypes.object.isRequired,\n classes: PropTypes.object.isRequired,\n onModelChanged: PropTypes.func.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n uploadSoundSupport: PropTypes.object,\n };\n\n static defaultProps = {};\n\n onPromptChanged = (prompt) => {\n const { onModelChanged, model } = this.props;\n const update = cloneDeep(model);\n\n update.prompt = prompt;\n onModelChanged(update);\n };\n\n render() {\n const { classes, configuration, imageSupport, model, onConfigurationChanged, onModelChanged, uploadSoundSupport } =\n this.props;\n const {\n contentDimensions = {},\n prompt = {},\n settingsPanelDisabled,\n } = configuration || {};\n const { promptEnabled } = model || {};\n\n const panelSettings = {};\n\n const panelProperties = {\n promptEnabled: prompt.settings && toggle(prompt.label),\n };\n\n return (\n <layout.ConfigLayout\n dimensions={contentDimensions}\n hideSettings={settingsPanelDisabled}\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={(model) => onModelChanged(model)}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n Settings: panelSettings,\n Properties: panelProperties,\n }}\n />\n }\n >\n {promptEnabled && (\n <InputContainer label={prompt.label || ''} className={classes.promptHolder}>\n <EditableHtml\n className={classes.prompt}\n markup={model.prompt}\n onChange={this.onPromptChanged}\n imageSupport={imageSupport}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n />\n </InputContainer>\n )}\n </layout.ConfigLayout>\n );\n }\n}\n\nexport default withStyles((theme) => ({\n promptHolder: {\n width: '100%',\n paddingTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n }\n}))(Design);\n"],"file":"design.js"}
|
package/configure/package.json
CHANGED
package/controller/package.json
CHANGED
package/lib/main.js
CHANGED
|
@@ -43,7 +43,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
43
43
|
key: "render",
|
|
44
44
|
value: function render() {
|
|
45
45
|
var model = this.props.model;
|
|
46
|
-
return /*#__PURE__*/_react["default"].createElement("div", null, model.prompt && /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
|
|
46
|
+
return /*#__PURE__*/_react["default"].createElement("div", null, model.prompt && /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("p", null, "Boilerplate Item"), /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
|
|
47
47
|
prompt: model.prompt
|
|
48
48
|
})));
|
|
49
49
|
}
|
package/lib/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/main.jsx"],"names":["Main","model","props","prompt","React","Component","PropTypes","object","session","onSessionChange","func","isRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;;;;;IAEqBA,I;;;;;;;;;;;;WASnB,kBAAS;AACP,UAAQC,KAAR,GAAkB,KAAKC,KAAvB,CAAQD,KAAR;AAEA,0BACE,6CACGA,KAAK,CAACE,MAAN,iBACC,0DACE,gCAAC,uBAAD;AAAe,QAAA,MAAM,EAAEF,KAAK,CAACE;AAA7B,
|
|
1
|
+
{"version":3,"sources":["../src/main.jsx"],"names":["Main","model","props","prompt","React","Component","PropTypes","object","session","onSessionChange","func","isRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;;;;;IAEqBA,I;;;;;;;;;;;;WASnB,kBAAS;AACP,UAAQC,KAAR,GAAkB,KAAKC,KAAvB,CAAQD,KAAR;AAEA,0BACE,6CACGA,KAAK,CAACE,MAAN,iBACC,0DACE,8DADF,eAEE,gCAAC,uBAAD;AAAe,QAAA,MAAM,EAAEF,KAAK,CAACE;AAA7B,QAFF,CAFJ,CADF;AAUD;;;EAtB+BC,kBAAMC,S;;;iCAAnBL,I,eACA;AACjBC,EAAAA,KAAK,EAAEK,sBAAUC,MADA;AAEjBC,EAAAA,OAAO,EAAEF,sBAAUC,MAFF;AAGjBE,EAAAA,eAAe,EAAEH,sBAAUI,IAAV,CAAeC;AAHf,C;iCADAX,I,kBAOG,E","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { PreviewPrompt } from '@pie-lib/pie-toolbox/render-ui';\n\nexport default class Main extends React.Component {\n static propTypes = {\n model: PropTypes.object,\n session: PropTypes.object,\n onSessionChange: PropTypes.func.isRequired,\n };\n\n static defaultProps = {};\n\n render() {\n const { model } = this.props;\n\n return (\n <div>\n {model.prompt && (\n <div>\n <p>Boilerplate Item</p>\n <PreviewPrompt prompt={model.prompt}/>\n </div>\n )}\n </div>\n );\n }\n}\n"],"file":"main.js"}
|
package/lib/print.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
22
|
+
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
|
|
23
|
+
|
|
24
|
+
var _react = _interopRequireDefault(require("react"));
|
|
25
|
+
|
|
26
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
27
|
+
|
|
28
|
+
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
29
|
+
|
|
30
|
+
var _main = _interopRequireDefault(require("./main"));
|
|
31
|
+
|
|
32
|
+
var _mathRendering = require("@pie-lib/pie-toolbox/math-rendering");
|
|
33
|
+
|
|
34
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
35
|
+
|
|
36
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
37
|
+
|
|
38
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
|
+
|
|
40
|
+
var log = (0, _debug["default"])('pie-element:multiple-choice:print');
|
|
41
|
+
/**
|
|
42
|
+
* Live in same package as main element - so we can access some of the shared comps!
|
|
43
|
+
*
|
|
44
|
+
* - update pslb to build print if src/print.js is there
|
|
45
|
+
* - update demo el
|
|
46
|
+
* - get configure/controller building
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
var preparePrintModel = function preparePrintModel(model, opts) {
|
|
50
|
+
return model;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var BoilerPlateItemTypePrint = /*#__PURE__*/function (_HTMLElement) {
|
|
54
|
+
(0, _inherits2["default"])(BoilerPlateItemTypePrint, _HTMLElement);
|
|
55
|
+
|
|
56
|
+
var _super = _createSuper(BoilerPlateItemTypePrint);
|
|
57
|
+
|
|
58
|
+
function BoilerPlateItemTypePrint() {
|
|
59
|
+
var _this;
|
|
60
|
+
|
|
61
|
+
(0, _classCallCheck2["default"])(this, BoilerPlateItemTypePrint);
|
|
62
|
+
_this = _super.call(this);
|
|
63
|
+
_this._options = null;
|
|
64
|
+
_this._model = null;
|
|
65
|
+
_this._session = [];
|
|
66
|
+
_this._rerender = (0, _debounce["default"])(function () {
|
|
67
|
+
if (_this._model && _this._session) {
|
|
68
|
+
var printModel = preparePrintModel(_this._model, _this._options);
|
|
69
|
+
|
|
70
|
+
var element = _this._options && /*#__PURE__*/_react["default"].createElement(_main["default"], {
|
|
71
|
+
model: printModel,
|
|
72
|
+
session: {}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
_reactDom["default"].render(element, (0, _assertThisInitialized2["default"])(_this), function () {
|
|
76
|
+
log('render complete - render math');
|
|
77
|
+
(0, _mathRendering.renderMath)((0, _assertThisInitialized2["default"])(_this));
|
|
78
|
+
});
|
|
79
|
+
} else {
|
|
80
|
+
log('skip');
|
|
81
|
+
}
|
|
82
|
+
}, 50, {
|
|
83
|
+
leading: false,
|
|
84
|
+
trailing: true
|
|
85
|
+
});
|
|
86
|
+
return _this;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
(0, _createClass2["default"])(BoilerPlateItemTypePrint, [{
|
|
90
|
+
key: "options",
|
|
91
|
+
set: function set(o) {
|
|
92
|
+
this._options = o;
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
key: "model",
|
|
96
|
+
set: function set(s) {
|
|
97
|
+
this._model = s;
|
|
98
|
+
|
|
99
|
+
this._rerender();
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
key: "connectedCallback",
|
|
103
|
+
value: function connectedCallback() {}
|
|
104
|
+
}]);
|
|
105
|
+
return BoilerPlateItemTypePrint;
|
|
106
|
+
}( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(HTMLElement));
|
|
107
|
+
|
|
108
|
+
exports["default"] = BoilerPlateItemTypePrint;
|
|
109
|
+
//# sourceMappingURL=print.js.map
|
package/lib/print.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/print.js"],"names":["log","preparePrintModel","model","opts","BoilerPlateItemTypePrint","_options","_model","_session","_rerender","printModel","element","React","createElement","Main","session","ReactDOM","render","leading","trailing","o","s","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,mCAAN,CAAZ;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,KAAD,EAAQC,IAAR,EAAiB;AACzC,SAAOD,KAAP;AACD,CAFD;;IAIqBE,wB;;;;;AACnB,sCAAc;AAAA;;AAAA;AACZ;AACA,UAAKC,QAAL,GAAgB,IAAhB;AACA,UAAKC,MAAL,GAAc,IAAd;AACA,UAAKC,QAAL,GAAgB,EAAhB;AACA,UAAKC,SAAL,GAAiB,0BACf,YAAM;AACJ,UAAI,MAAKF,MAAL,IAAe,MAAKC,QAAxB,EAAkC;AAChC,YAAME,UAAU,GAAGR,iBAAiB,CAAC,MAAKK,MAAN,EAAc,MAAKD,QAAnB,CAApC;;AAEA,YAAMK,OAAO,GACX,MAAKL,QAAL,iBACAM,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACxBX,UAAAA,KAAK,EAAEO,UADiB;AAExBK,UAAAA,OAAO,EAAE;AAFe,SAA1B,CAFF;;AAOAC,6BAASC,MAAT,CAAgBN,OAAhB,kDAA+B,YAAM;AACnCV,UAAAA,GAAG,CAAC,+BAAD,CAAH;AACA;AACD,SAHD;AAID,OAdD,MAcO;AACLA,QAAAA,GAAG,CAAC,MAAD,CAAH;AACD;AACF,KAnBc,EAoBf,EApBe,EAqBf;AAAEiB,MAAAA,OAAO,EAAE,KAAX;AAAkBC,MAAAA,QAAQ,EAAE;AAA5B,KArBe,CAAjB;AALY;AA4Bb;;;;SACD,aAAYC,CAAZ,EAAe;AACb,WAAKd,QAAL,GAAgBc,CAAhB;AACD;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKd,MAAL,GAAcc,CAAd;;AACA,WAAKZ,SAAL;AACD;;;WAED,6BAAoB,CAAE;;;kDAvC8Ba,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport debounce from 'lodash/debounce';\nimport Main from './main';\nimport { renderMath } from '@pie-lib/pie-toolbox/math-rendering';\nimport debug from 'debug';\n\nconst log = debug('pie-element:multiple-choice:print');\n\n/**\n * Live in same package as main element - so we can access some of the shared comps!\n *\n * - update pslb to build print if src/print.js is there\n * - update demo el\n * - get configure/controller building\n */\n\nconst preparePrintModel = (model, opts) => {\n return model;\n};\n\nexport default class BoilerPlateItemTypePrint extends HTMLElement {\n constructor() {\n super();\n this._options = null;\n this._model = null;\n this._session = [];\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n const printModel = preparePrintModel(this._model, this._options);\n\n const element =\n this._options &&\n React.createElement(Main, {\n model: printModel,\n session: {},\n });\n\n ReactDOM.render(element, this, () => {\n log('render complete - render math');\n renderMath(this);\n });\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true },\n );\n }\n set options(o) {\n this._options = o;\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n }\n\n connectedCallback() {}\n}\n"],"file":"print.js"}
|
package/module/demo.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Configure from './configure.js';
|
|
2
|
+
import Element from './element.js';
|
|
3
|
+
import * as controller from './controller.js';
|
|
4
|
+
|
|
5
|
+
var generate = {};
|
|
6
|
+
|
|
7
|
+
generate.model = (id, element) => ({
|
|
8
|
+
id,
|
|
9
|
+
element,
|
|
10
|
+
prompt: 'Custom Prompt'
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const { model } = generate;
|
|
14
|
+
|
|
15
|
+
var config = {
|
|
16
|
+
elements: {
|
|
17
|
+
'boilerplate-item-type': '../..',
|
|
18
|
+
},
|
|
19
|
+
models: [model('1', 'boilerplate-item-type')],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//Note: demo-el is a custom element loaded in the markup.
|
|
23
|
+
customElements.whenDefined("demo-el").then(() => {
|
|
24
|
+
config.models.forEach((m) => {
|
|
25
|
+
const de = document.createElement("demo-el");
|
|
26
|
+
document.body.appendChild(de);
|
|
27
|
+
de.def = { tagName: m.element, Element, Configure, controller };
|
|
28
|
+
de.model = m;
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {_dll_react, _dll_prop_types, _dll_pie_lib__pie_toolbox_render_ui, _dll_react_dom, _dll_pie_lib__pie_toolbox_math_rendering} from "../../../@pie-lib/pie-toolbox-module@1.3.3/module/index.js";
|
|
2
|
+
var lib = {};
|
|
3
|
+
Object.defineProperty(lib, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
class ModelSetEvent extends CustomEvent {
|
|
7
|
+
constructor(component, complete, hasModel) {
|
|
8
|
+
super(ModelSetEvent.TYPE, {
|
|
9
|
+
bubbles: true,
|
|
10
|
+
composed: true,
|
|
11
|
+
detail: {
|
|
12
|
+
complete,
|
|
13
|
+
component,
|
|
14
|
+
hasModel
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
this.component = component;
|
|
18
|
+
this.complete = complete;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
ModelSetEvent.TYPE = 'model-set';
|
|
22
|
+
var ModelSetEvent_1 = lib.ModelSetEvent = ModelSetEvent;
|
|
23
|
+
class SessionChangedEvent extends CustomEvent {
|
|
24
|
+
constructor(component, complete) {
|
|
25
|
+
super(SessionChangedEvent.TYPE, {
|
|
26
|
+
bubbles: true,
|
|
27
|
+
composed: true,
|
|
28
|
+
detail: {
|
|
29
|
+
complete,
|
|
30
|
+
component
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
this.component = component;
|
|
34
|
+
this.complete = complete;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
SessionChangedEvent.TYPE = 'session-changed';
|
|
38
|
+
var SessionChangedEvent_1 = lib.SessionChangedEvent = SessionChangedEvent;
|
|
39
|
+
const React$1 = _dll_react;
|
|
40
|
+
const PropTypes = _dll_prop_types;
|
|
41
|
+
const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__pie_toolbox_render_ui;
|
|
42
|
+
const _jsxFileName = "/Users/andreeapescar/WORK/pie/pie-elements/packages/boilerplate-item-type/src/main.jsx";
|
|
43
|
+
class Main extends React$1.Component {
|
|
44
|
+
static __initStatic() {
|
|
45
|
+
this.propTypes = {
|
|
46
|
+
model: PropTypes.object,
|
|
47
|
+
session: PropTypes.object,
|
|
48
|
+
onSessionChange: PropTypes.func.isRequired
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
static __initStatic2() {
|
|
52
|
+
this.defaultProps = {};
|
|
53
|
+
}
|
|
54
|
+
render() {
|
|
55
|
+
const {model} = this.props;
|
|
56
|
+
return React$1.createElement('div', {
|
|
57
|
+
__self: this,
|
|
58
|
+
__source: {
|
|
59
|
+
fileName: _jsxFileName,
|
|
60
|
+
lineNumber: 18
|
|
61
|
+
}
|
|
62
|
+
}, model.prompt && React$1.createElement('div', {
|
|
63
|
+
__self: this,
|
|
64
|
+
__source: {
|
|
65
|
+
fileName: _jsxFileName,
|
|
66
|
+
lineNumber: 20
|
|
67
|
+
}
|
|
68
|
+
}, React$1.createElement('p', {
|
|
69
|
+
__self: this,
|
|
70
|
+
__source: {
|
|
71
|
+
fileName: _jsxFileName,
|
|
72
|
+
lineNumber: 21
|
|
73
|
+
}
|
|
74
|
+
}, "Boilerplate Item"), React$1.createElement(PreviewPrompt, {
|
|
75
|
+
prompt: model.prompt,
|
|
76
|
+
__self: this,
|
|
77
|
+
__source: {
|
|
78
|
+
fileName: _jsxFileName,
|
|
79
|
+
lineNumber: 22
|
|
80
|
+
}
|
|
81
|
+
})));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
Main.__initStatic();
|
|
85
|
+
Main.__initStatic2();
|
|
86
|
+
const React = _dll_react;
|
|
87
|
+
const ReactDOM = _dll_react_dom;
|
|
88
|
+
const {renderMath: renderMath} = _dll_pie_lib__pie_toolbox_math_rendering;
|
|
89
|
+
class BoilerplateItemType extends HTMLElement {
|
|
90
|
+
set model(m) {
|
|
91
|
+
this._model = m;
|
|
92
|
+
this.render();
|
|
93
|
+
this.dispatchEvent(new ModelSetEvent_1(this.tagName.toLowerCase(), this.isSessionComplete(), this._model !== undefined));
|
|
94
|
+
}
|
|
95
|
+
get model() {
|
|
96
|
+
return this._model;
|
|
97
|
+
}
|
|
98
|
+
set session(s) {
|
|
99
|
+
this._session = s;
|
|
100
|
+
this.render();
|
|
101
|
+
}
|
|
102
|
+
get session() {
|
|
103
|
+
return this._session;
|
|
104
|
+
}
|
|
105
|
+
isSessionComplete() {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
onSessionChange(session) {
|
|
109
|
+
this._session = session;
|
|
110
|
+
this.dispatchEvent(new SessionChangedEvent_1(this.tagName.toLowerCase(), this.isSessionComplete()));
|
|
111
|
+
}
|
|
112
|
+
connectedCallback() {
|
|
113
|
+
this.render();
|
|
114
|
+
}
|
|
115
|
+
render() {
|
|
116
|
+
if (this._model && this._session) {
|
|
117
|
+
const el = React.createElement(Main, {
|
|
118
|
+
model: this._model,
|
|
119
|
+
session: this._session,
|
|
120
|
+
onSessionChange: this.onSessionChange.bind(this)
|
|
121
|
+
});
|
|
122
|
+
ReactDOM.render(el, this, () => {
|
|
123
|
+
renderMath(this);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
export {BoilerplateItemType as default};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
<!doctype html>
|
|
3
|
+
<html>
|
|
4
|
+
<head>
|
|
5
|
+
<title>@pie-element/boilerplate-item-type@2.0.5</title>
|
|
6
|
+
<script
|
|
7
|
+
type="module"
|
|
8
|
+
src="https://cdn.jsdelivr.net/npm/@pslb/demo-el@^1.0.0/dist/demo-el/demo-el.esm.js"></script>
|
|
9
|
+
|
|
10
|
+
<link
|
|
11
|
+
href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
|
|
12
|
+
rel="stylesheet"
|
|
13
|
+
/>
|
|
14
|
+
<style>
|
|
15
|
+
html, body {
|
|
16
|
+
font-family: 'Roboto', sans-serif;
|
|
17
|
+
}
|
|
18
|
+
</style>
|
|
19
|
+
<script type="module" src="./demo.js"></script>
|
|
20
|
+
</head>
|
|
21
|
+
</html>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import PrintElement from './print.js';
|
|
2
|
+
|
|
3
|
+
var generate = {};
|
|
4
|
+
|
|
5
|
+
generate.model = (id, element) => ({
|
|
6
|
+
id,
|
|
7
|
+
element,
|
|
8
|
+
prompt: 'Custom Prompt'
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const { model } = generate;
|
|
12
|
+
|
|
13
|
+
var config = {
|
|
14
|
+
elements: {
|
|
15
|
+
'boilerplate-item-type': '../..',
|
|
16
|
+
},
|
|
17
|
+
models: [model('1', 'boilerplate-item-type')],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// new init - just shows off print!
|
|
21
|
+
|
|
22
|
+
const init = async () => {
|
|
23
|
+
console.log('define the element...');
|
|
24
|
+
await Promise.all(
|
|
25
|
+
config.models.map(async (m) => {
|
|
26
|
+
try {
|
|
27
|
+
const printTag = `${m.element}-print`;
|
|
28
|
+
if (customElements.get(printTag)) {
|
|
29
|
+
return true;
|
|
30
|
+
} else {
|
|
31
|
+
customElements.define(printTag, PrintElement);
|
|
32
|
+
await customElements.whenDefined(printTag);
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
} catch (e) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
console.log('now apply the model...');
|
|
42
|
+
config.models.forEach((m) => {
|
|
43
|
+
const printTag = `${m.element}-print`;
|
|
44
|
+
const h3s = document.createElement('h3');
|
|
45
|
+
h3s.textContent = 'student mode';
|
|
46
|
+
document.body.appendChild(h3s);
|
|
47
|
+
const de = document.createElement(printTag);
|
|
48
|
+
document.body.appendChild(de);
|
|
49
|
+
de.options = {};
|
|
50
|
+
de.model = m;
|
|
51
|
+
|
|
52
|
+
const h3 = document.createElement('h3');
|
|
53
|
+
h3.textContent = 'instructor mode';
|
|
54
|
+
document.body.appendChild(h3);
|
|
55
|
+
const instr = document.createElement(printTag);
|
|
56
|
+
document.body.appendChild(instr);
|
|
57
|
+
instr.options = { mode: 'instructor' };
|
|
58
|
+
instr.model = JSON.parse(JSON.stringify(m));
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
init()
|
|
63
|
+
.then(() => {
|
|
64
|
+
console.log('ready');
|
|
65
|
+
})
|
|
66
|
+
.catch((e) => {
|
|
67
|
+
console.error(e);
|
|
68
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
<!doctype html>
|
|
3
|
+
<html>
|
|
4
|
+
<head>
|
|
5
|
+
<title>@pie-element/boilerplate-item-type@2.0.5</title>
|
|
6
|
+
<link
|
|
7
|
+
href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
|
|
8
|
+
rel="stylesheet"
|
|
9
|
+
/>
|
|
10
|
+
<style>
|
|
11
|
+
html, body {
|
|
12
|
+
font-family: 'Roboto', sans-serif;
|
|
13
|
+
}
|
|
14
|
+
</style>
|
|
15
|
+
<script type="module" src="./print-demo.js"></script>
|
|
16
|
+
</head>
|
|
17
|
+
<body></body>
|
|
18
|
+
</html>
|
package/module/print.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {_dll_react, _dll_prop_types, _dll_pie_lib__pie_toolbox_render_ui, _dll_react_dom, _dll_lodash, _dll_pie_lib__pie_toolbox_math_rendering, _dll_debug} from "../../../@pie-lib/pie-toolbox-module@1.3.3/module/index.js";
|
|
2
|
+
const React$1 = _dll_react;
|
|
3
|
+
const PropTypes = _dll_prop_types;
|
|
4
|
+
const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__pie_toolbox_render_ui;
|
|
5
|
+
const _jsxFileName = "/Users/andreeapescar/WORK/pie/pie-elements/packages/boilerplate-item-type/src/main.jsx";
|
|
6
|
+
class Main extends React$1.Component {
|
|
7
|
+
static __initStatic() {
|
|
8
|
+
this.propTypes = {
|
|
9
|
+
model: PropTypes.object,
|
|
10
|
+
session: PropTypes.object,
|
|
11
|
+
onSessionChange: PropTypes.func.isRequired
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
static __initStatic2() {
|
|
15
|
+
this.defaultProps = {};
|
|
16
|
+
}
|
|
17
|
+
render() {
|
|
18
|
+
const {model} = this.props;
|
|
19
|
+
return React$1.createElement('div', {
|
|
20
|
+
__self: this,
|
|
21
|
+
__source: {
|
|
22
|
+
fileName: _jsxFileName,
|
|
23
|
+
lineNumber: 18
|
|
24
|
+
}
|
|
25
|
+
}, model.prompt && React$1.createElement('div', {
|
|
26
|
+
__self: this,
|
|
27
|
+
__source: {
|
|
28
|
+
fileName: _jsxFileName,
|
|
29
|
+
lineNumber: 20
|
|
30
|
+
}
|
|
31
|
+
}, React$1.createElement('p', {
|
|
32
|
+
__self: this,
|
|
33
|
+
__source: {
|
|
34
|
+
fileName: _jsxFileName,
|
|
35
|
+
lineNumber: 21
|
|
36
|
+
}
|
|
37
|
+
}, "Boilerplate Item"), React$1.createElement(PreviewPrompt, {
|
|
38
|
+
prompt: model.prompt,
|
|
39
|
+
__self: this,
|
|
40
|
+
__source: {
|
|
41
|
+
fileName: _jsxFileName,
|
|
42
|
+
lineNumber: 22
|
|
43
|
+
}
|
|
44
|
+
})));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
Main.__initStatic();
|
|
48
|
+
Main.__initStatic2();
|
|
49
|
+
const React = _dll_react;
|
|
50
|
+
const ReactDOM = _dll_react_dom;
|
|
51
|
+
const {debounce: debounce} = _dll_lodash;
|
|
52
|
+
const {renderMath: renderMath} = _dll_pie_lib__pie_toolbox_math_rendering;
|
|
53
|
+
const debug = _dll_debug;
|
|
54
|
+
const log = debug('pie-element:multiple-choice:print');
|
|
55
|
+
const preparePrintModel = (model, opts) => {
|
|
56
|
+
return model;
|
|
57
|
+
};
|
|
58
|
+
class BoilerPlateItemTypePrint extends HTMLElement {
|
|
59
|
+
constructor() {
|
|
60
|
+
super();
|
|
61
|
+
this._options = null;
|
|
62
|
+
this._model = null;
|
|
63
|
+
this._session = [];
|
|
64
|
+
this._rerender = debounce(() => {
|
|
65
|
+
if (this._model && this._session) {
|
|
66
|
+
const printModel = preparePrintModel(this._model, this._options);
|
|
67
|
+
const element = this._options && React.createElement(Main, {
|
|
68
|
+
model: printModel,
|
|
69
|
+
session: {}
|
|
70
|
+
});
|
|
71
|
+
ReactDOM.render(element, this, () => {
|
|
72
|
+
log('render complete - render math');
|
|
73
|
+
renderMath(this);
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
log('skip');
|
|
77
|
+
}
|
|
78
|
+
}, 50, {
|
|
79
|
+
leading: false,
|
|
80
|
+
trailing: true
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
set options(o) {
|
|
84
|
+
this._options = o;
|
|
85
|
+
}
|
|
86
|
+
set model(s) {
|
|
87
|
+
this._model = s;
|
|
88
|
+
this._rerender();
|
|
89
|
+
}
|
|
90
|
+
connectedCallback() {}
|
|
91
|
+
}
|
|
92
|
+
export {BoilerPlateItemTypePrint as default};
|
package/package.json
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"repository": "pie-framework/pie-elements",
|
|
7
|
-
"version": "2.0.
|
|
7
|
+
"version": "2.0.5-next.1",
|
|
8
8
|
"description": "",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@material-ui/core": "^3.9.2",
|
|
11
11
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
12
|
-
"@pie-lib/pie-toolbox": "1.2.
|
|
12
|
+
"@pie-lib/pie-toolbox": "1.2.4",
|
|
13
13
|
"prop-types": "^15.6.1",
|
|
14
14
|
"react": "^16.8.1",
|
|
15
15
|
"react-dom": "^16.8.1"
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"main": "lib/index.js",
|
|
24
24
|
"module": "src/index.js",
|
|
25
25
|
"exports": {
|
|
26
|
-
".": "./src/index.js"
|
|
26
|
+
".": "./src/index.js",
|
|
27
|
+
"./print": "./src/print.js"
|
|
27
28
|
}
|
|
28
29
|
}
|