@pie-element/passage 6.0.0-beta.1 → 6.0.0-next.42
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/package.json +4 -4
- package/module/configure.js +1 -0
- package/module/controller.js +1068 -0
- package/module/demo.js +57 -0
- package/module/element.js +1 -0
- package/module/index.html +21 -0
- package/module/manifest.json +14 -0
- package/module/print-demo.js +95 -0
- package/module/print.html +18 -0
- package/package.json +5 -5
package/configure/package.json
CHANGED
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"@mui/icons-material": "^7.3.4",
|
|
14
14
|
"@mui/material": "^7.3.4",
|
|
15
15
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
16
|
-
"@pie-lib/config-ui": "12.1.
|
|
17
|
-
"@pie-lib/editable-html-tip-tap": "1.1.
|
|
18
|
-
"lodash": "^4.17.
|
|
19
|
-
"prop-types": "^15.
|
|
16
|
+
"@pie-lib/config-ui": "12.1.1-next.0",
|
|
17
|
+
"@pie-lib/editable-html-tip-tap": "1.1.1-next.0",
|
|
18
|
+
"lodash": "^4.17.23",
|
|
19
|
+
"prop-types": "^15.8.1",
|
|
20
20
|
"react": "18.2.0",
|
|
21
21
|
"react-dom": "18.2.0"
|
|
22
22
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_dll_react_dom as e,_dll_prop_types as t,_dll_mui__material_styles as a,_dll_react as n,_dll_mui__material as i,_dll_mui__icons_material as s}from"../../../@pie-lib/shared-module@^3.0.5/module/index.js";import{_dll_pie_lib__config_ui as o}from"../../../@pie-lib/config-module@^3.0.0/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as l}from"../../../@pie-lib/editable-html-module@^6.0.5/module/index.js";var r,d=e;r=d.createRoot,d.hydrateRoot;var u={};Object.defineProperty(u,"__esModule",{value:!0});class c extends CustomEvent{constructor(e,t=!1){super(c.TYPE,{bubbles:!0,detail:{update:e,reset:t}}),this.update=e,this.reset=t}}c.TYPE="model.updated";var g=u.ModelUpdatedEvent=c;class p extends CustomEvent{constructor(e,t){super(p.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}p.TYPE="delete.image";var h=u.DeleteImageEvent=p;class m extends CustomEvent{constructor(e){super(m.TYPE,{bubbles:!0,detail:e}),this.handler=e}}m.TYPE="insert.image";var b=u.InsertImageEvent=m;class _ extends CustomEvent{constructor(e,t){super(_.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}_.TYPE="delete.sound";var C=u.DeleteSoundEvent=_;class E extends CustomEvent{constructor(e){super(E.TYPE,{bubbles:!0,detail:e}),this.handler=e}}E.TYPE="insert.sound";var f=u.InsertSoundEvent=E;const x=n,S=t,{styled:I}=a,{Button:v}=i,{Dialog:P}=i,{DialogTitle:y}=i,{DialogContent:T}=i,{DialogContentText:R}=i,{DialogActions:q}=i,{RemoveCircle:D}=s,{AddCircle:k}=s,A=I(({label:e,type:t="add",onClick:a})=>{const n="add"===t?k:D;return x.createElement(v,{color:"primary",size:"small",onClick:a},x.createElement(n,{fontSize:"small",color:"primary",style:{marginRight:4}}),e)})({textDecoration:"underline","&:hover":{textDecoration:"underline",backgroundColor:"transparent"},display:"flex",alignItems:"center"}),M=({content:e,cancel:t,title:a,ok:n,open:i,onOk:s,onCancel:o})=>x.createElement(P,{open:i},x.createElement(y,null,a),x.createElement(T,null,x.createElement(R,null,e)),x.createElement(q,null,s&&x.createElement(v,{onClick:s,color:"primary"},n),o&&x.createElement(v,{onClick:o,color:"primary"},t)));M.propTypes={content:S.string.isRequired,title:S.string.isRequired,cancel:S.string.isRequired,ok:S.string.isRequired,open:S.bool.isRequired,onCancel:S.func.isRequired,onOk:S.func.isRequired};const w=n,j=t,{styled:O}=a,{InputContainer:Y}=o,L=l,{ALL_PLUGINS:H}=l;function W(e){let t,a=e[0],n=1;for(;n<e.length;){const i=e[n],s=e[n+1];if(n+=2,("optionalAccess"===i||"optionalCall"===i)&&null==a)return;"access"===i||"optionalAccess"===i?(t=a,a=s(a)):"call"!==i&&"optionalCall"!==i||(a=s((...e)=>a.call(t,...e)),t=void 0)}return a}const z=O(Y)(({theme:e})=>({paddingTop:e.spacing(2),marginBottom:e.spacing(2),width:"100%"})),B=O("div")(({theme:e})=>({fontSize:e.typography.fontSize-2,color:e.palette.error.main,paddingTop:e.spacing(1)}));class $ extends w.Component{static __initStatic(){this.propTypes={onModelChanged:j.func.isRequired,model:j.object.isRequired,configuration:j.object.isRequired,imageSupport:j.object.isRequired,passageIndex:j.number.isRequired,uploadSoundSupport:j.object.isRequired}}static __initStatic2(){this.defaultProps={passageIndex:0}}constructor(e){super(e),$.prototype.__init.call(this)}__init(){this.handleChange=(e,t)=>{const{model:a,onModelChanged:n,passageIndex:i}=this.props;if(!a.passages||i<0||i>=a.passages.length)return;const s=[...a.passages];s[i]={...s[i],[e]:t},n({...a,passages:s})}}render(){const{model:e,configuration:t,imageSupport:a,passageIndex:n,uploadSoundSupport:i}=this.props,{maxImageWidth:s={},maxImageHeight:o={},mathMlOptions:l={},baseInputConfiguration:r={},teacherInstructions:d={},title:u={},subtitle:c={},text:g={},author:p={}}=t||{},{errors:h={},passages:m=[],teacherInstructionsEnabled:b,titleEnabled:_,subtitleEnabled:C,authorEnabled:E,textEnabled:f}=e||{},{passages:x}=h||{},{teacherInstructions:S,title:I,subtitle:v,author:P,text:y}=x&&x[n]||{},T=s&&s.prompt,R=o&&o.prompt,q=e=>({...r,...e});return w.createElement(w.Fragment,null,b&&w.createElement(z,{label:d.label},w.createElement(L,{activePlugins:H,markup:m[n].teacherInstructions||"",onChange:e=>this.handleChange("teacherInstructions",e),nonEmpty:!1,error:S,maxImageWidth:s&&s.teacherInstructions||T,maxImageHeight:o&&o.teacherInstructions||R,mathMlOptions:l,languageCharactersProps:[{language:"spanish"},{language:"special"}],pluginProps:q(W([d,"optionalAccess",e=>e.inputConfiguration]))}),S&&w.createElement(B,null,S)),_&&w.createElement(z,{label:u.label},w.createElement(L,{activePlugins:H,markup:m[n].title||"",onChange:e=>this.handleChange("title",e),nonEmpty:!1,error:I,mathMlOptions:l,languageCharactersProps:[{language:"spanish"},{language:"special"}],pluginProps:q(W([u,"optionalAccess",e=>e.inputConfiguration]))}),I&&w.createElement(B,null,I)),C&&w.createElement(z,{label:c.label},w.createElement(L,{activePlugins:H,markup:m[n].subtitle||"",onChange:e=>this.handleChange("subtitle",e),nonEmpty:!1,error:v,mathMlOptions:l,languageCharactersProps:[{language:"spanish"},{language:"special"}],pluginProps:q(W([c,"optionalAccess",e=>e.inputConfiguration]))}),v&&w.createElement(B,null,v)),E&&w.createElement(z,{label:p.label},w.createElement(L,{activePlugins:H,markup:m[n].author||"",onChange:e=>this.handleChange("author",e),nonEmpty:!1,error:P,mathMlOptions:l,languageCharactersProps:[{language:"spanish"},{language:"special"}],pluginProps:q(W([p,"optionalAccess",e=>e.inputConfiguration]))}),P&&w.createElement(B,null,P)),f&&w.createElement(z,{label:g.label},w.createElement(L,{activePlugins:H,markup:m[n].text||"",onChange:e=>this.handleChange("text",e),imageSupport:a,uploadSoundSupport:i,nonEmpty:!1,error:y,maxImageWidth:s&&s.text||T,maxImageHeight:o&&o.text||R,mathMlOptions:l,languageCharactersProps:[{language:"spanish"},{language:"special"}],pluginProps:q(W([g,"optionalAccess",e=>e.inputConfiguration]))}),y&&w.createElement(B,null,y)))}}$.__initStatic(),$.__initStatic2();const F=n,U=t,{styled:G}=a,{Typography:N}=i,{settings:J}=o,{layout:K}=o,{Panel:Q,toggle:V,dropdown:X}=J,Z=G(N)(({theme:e})=>({paddingTop:e.spacing(2),marginBottom:e.spacing(2)}));class ee extends F.Component{static __initStatic(){this.propTypes={onModelChanged:U.func.isRequired,onConfigurationChanged:U.func,model:U.object.isRequired,configuration:U.object.isRequired,imageSupport:U.object.isRequired,uploadSoundSupport:U.object.isRequired,classes:U.object.isRequired}}constructor(e){super(e),ee.prototype.__init.call(this),ee.prototype.__init2.call(this),ee.prototype.__init3.call(this),ee.prototype.__init4.call(this),this.state={showConfirmationDialog:!1,indexToRemove:-1}}__init(){this.getInnerText=e=>(e||"").replaceAll(/<[^>]*>/g,"")}__init2(){this.onDelete=(e,t,a)=>{let n=e.passages;n.splice(t,1),a({...e,passages:n}),this.setState({showConfirmationDialog:!1,indexToRemove:-1})}}__init3(){this.removeAdditionalPassage=e=>{const{model:t={},onModelChanged:a}=this.props,{passages:n=[]}=t,{teacherInstructions:i="",title:s="",subtitle:o="",author:l="",text:r=""}=n[e];this.getInnerText(i).trim()||this.getInnerText(s).trim()||this.getInnerText(o).trim()||this.getInnerText(l).trim()||this.getInnerText(r).trim()?this.setState({showConfirmationDialog:!0,indexToRemove:e}):this.onDelete(t,e,a)}}__init4(){this.addAdditionalPassage=()=>{const{model:e,onModelChanged:t}=this.props,a=[...e.passages,{teacherInstructions:"",title:"",subtitle:"",author:"",text:""}];t({...e,passages:a})}}render(){const{model:e,configuration:t,imageSupport:a,onConfigurationChanged:n,onModelChanged:i,uploadSoundSupport:s}=this.props,{settingsPanelDisabled:o,language:l={},languageChoices:r={},teacherInstructions:d={},title:u={},subtitle:c={},text:g={},author:p={},additionalPassage:h={}}=t||{},{extraCSSRules:m,passages:b}=e||{},_={titleEnabled:u&&u.settings&&V(u.label),subtitleEnabled:c&&c.settings&&V(c.label),authorEnabled:p&&p.settings&&V(p.label),textEnabled:g&&g.settings&&V(g.label),"additionalPassage.enabled":h&&h.settings&&V(h.label,!0)},C={teacherInstructionsEnabled:d&&d.settings&&V(d.label),"language.enabled":l&&l.settings&&V(l.label,!0),language:l&&l.settings&&l.enabled&&X(r.label,r.options)},E=`${h.label} will be deleted`,{indexToRemove:f,showConfirmationDialog:x}=this.state;return F.createElement(K.ConfigLayout,{extraCSSRules:m,hideSettings:o,settings:F.createElement(Q,{model:e,configuration:t,onChangeModel:e=>i(e),onChangeConfiguration:e=>n(e),groups:{Settings:_,Properties:C}})},b.map((n,o)=>F.createElement(F.Fragment,{key:o},o>0&&F.createElement(Z,{variant:"h5"},h.label),F.createElement($,{imageSupport:a,uploadSoundSupport:s,model:e,configuration:t,passageIndex:o,onModelChanged:i}),o>0&&h.enabled&&F.createElement(A,{type:"remove",label:`Remove ${h.label}`,onClick:()=>this.removeAdditionalPassage(o)}),0===o&&h.enabled&&b.length<2&&F.createElement(A,{label:`Add ${h.label}`,onClick:this.addAdditionalPassage}))),F.createElement(M,{open:x,title:"Warning",content:E,cancel:"Cancel",ok:"Ok",onCancel:()=>this.setState({showConfirmationDialog:!1}),onOk:()=>this.onDelete(e,f,i)}))}}ee.__initStatic();var te={authorEnabled:!0,passages:[{teacherInstructions:"",title:"",subtitle:"",author:"",text:""}],subtitleEnabled:!0,teacherInstructionsEnabled:!0,textEnabled:!0,titleEnabled:!0},ae={baseInputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1},h3:{disabled:!0},blockquote:{disabled:!0},textAlign:{disabled:!0},showParagraphs:{disabled:!1},separateParagraphs:{disabled:!0}},settingsPanelDisabled:!1,title:{settings:!0,label:"Title",inputConfiguration:{audio:{disabled:!0},video:{disabled:!0},image:{disabled:!0},textAlign:{disabled:!1}},required:!0},subtitle:{settings:!0,label:"Subtitle",inputConfiguration:{audio:{disabled:!0},video:{disabled:!0},image:{disabled:!0},textAlign:{disabled:!1}},required:!1},author:{settings:!0,label:"Author",inputConfiguration:{audio:{disabled:!0},video:{disabled:!0},image:{disabled:!0}},required:!1},text:{settings:!0,label:"Text",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1},h3:{disabled:!1},blockquote:{disabled:!1},textAlign:{disabled:!1}},required:!0},teacherInstructions:{settings:!0,label:"Teacher Instructions",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},maxImageWidth:{teacherInstructions:300,text:300},maxImageHeight:{teacherInstructions:300,text:300},mathMlOptions:{mmlOutput:!1,mmlEditing:!1},language:{settings:!1,label:"Specify Language",enabled:!1},languageChoices:{label:"Language Choices",options:[]},additionalPassage:{settings:!0,label:"Additional Passage",enabled:!1}};const ne=n;class ie extends HTMLElement{static __initStatic(){this.createDefaultModel=(e={})=>({...te,...e})}constructor(){super(),this._root=null,this._model=ie.createDefaultModel(),this._configuration=ae}set model(e){this._model=ie.createDefaultModel(e),this.render()}set configuration(e){this._configuration=e,this.render()}connectedCallback(){this.render()}modelChanged(e){this._model=e,this.dispatchEvent(new g(this._model),!0),this.render()}onConfigurationChanged(e){this._configuration=e,this.render()}insertImage(e){this.dispatchEvent(new b(e))}onDeleteImage(e,t){this.dispatchEvent(new h(e,t))}insertSound(e){this.dispatchEvent(new f(e))}onDeleteSound(e,t){this.dispatchEvent(new C(e,t))}render(){if(this._model){const e=ne.createElement(ee,{model:this._model,configuration:this._configuration,onModelChanged:this.modelChanged.bind(this),onConfigurationChanged:this.onConfigurationChanged.bind(this),imageSupport:{add:this.insertImage.bind(this),delete:this.onDeleteImage.bind(this)},uploadSoundSupport:{add:this.insertSound.bind(this),delete:this.onDeleteSound.bind(this)}});this._root||(this._root=r(this)),this._root.render(e)}}disconnectedCallback(){this._root&&this._root.unmount()}}ie.__initStatic();export{ie as default};
|
|
@@ -0,0 +1,1068 @@
|
|
|
1
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2
|
+
|
|
3
|
+
/** Used for built-in method references. */
|
|
4
|
+
|
|
5
|
+
var objectProto$6 = Object.prototype;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Checks if `value` is likely a prototype object.
|
|
9
|
+
*
|
|
10
|
+
* @private
|
|
11
|
+
* @param {*} value The value to check.
|
|
12
|
+
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
|
|
13
|
+
*/
|
|
14
|
+
function isPrototype$2(value) {
|
|
15
|
+
var Ctor = value && value.constructor,
|
|
16
|
+
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$6;
|
|
17
|
+
|
|
18
|
+
return value === proto;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var _isPrototype = isPrototype$2;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates a unary function that invokes `func` with its argument transformed.
|
|
25
|
+
*
|
|
26
|
+
* @private
|
|
27
|
+
* @param {Function} func The function to wrap.
|
|
28
|
+
* @param {Function} transform The argument transform.
|
|
29
|
+
* @returns {Function} Returns the new function.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
function overArg$1(func, transform) {
|
|
33
|
+
return function(arg) {
|
|
34
|
+
return func(transform(arg));
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var _overArg = overArg$1;
|
|
39
|
+
|
|
40
|
+
var overArg = _overArg;
|
|
41
|
+
|
|
42
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
43
|
+
var nativeKeys$1 = overArg(Object.keys, Object);
|
|
44
|
+
|
|
45
|
+
var _nativeKeys = nativeKeys$1;
|
|
46
|
+
|
|
47
|
+
var isPrototype$1 = _isPrototype,
|
|
48
|
+
nativeKeys = _nativeKeys;
|
|
49
|
+
|
|
50
|
+
/** Used for built-in method references. */
|
|
51
|
+
var objectProto$5 = Object.prototype;
|
|
52
|
+
|
|
53
|
+
/** Used to check objects for own properties. */
|
|
54
|
+
var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
|
|
58
|
+
*
|
|
59
|
+
* @private
|
|
60
|
+
* @param {Object} object The object to query.
|
|
61
|
+
* @returns {Array} Returns the array of property names.
|
|
62
|
+
*/
|
|
63
|
+
function baseKeys$1(object) {
|
|
64
|
+
if (!isPrototype$1(object)) {
|
|
65
|
+
return nativeKeys(object);
|
|
66
|
+
}
|
|
67
|
+
var result = [];
|
|
68
|
+
for (var key in Object(object)) {
|
|
69
|
+
if (hasOwnProperty$4.call(object, key) && key != 'constructor') {
|
|
70
|
+
result.push(key);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var _baseKeys = baseKeys$1;
|
|
77
|
+
|
|
78
|
+
/** Detect free variable `global` from Node.js. */
|
|
79
|
+
|
|
80
|
+
var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
81
|
+
|
|
82
|
+
var _freeGlobal = freeGlobal$1;
|
|
83
|
+
|
|
84
|
+
var freeGlobal = _freeGlobal;
|
|
85
|
+
|
|
86
|
+
/** Detect free variable `self`. */
|
|
87
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
88
|
+
|
|
89
|
+
/** Used as a reference to the global object. */
|
|
90
|
+
var root$7 = freeGlobal || freeSelf || Function('return this')();
|
|
91
|
+
|
|
92
|
+
var _root = root$7;
|
|
93
|
+
|
|
94
|
+
var root$6 = _root;
|
|
95
|
+
|
|
96
|
+
/** Built-in value references. */
|
|
97
|
+
var Symbol$2 = root$6.Symbol;
|
|
98
|
+
|
|
99
|
+
var _Symbol = Symbol$2;
|
|
100
|
+
|
|
101
|
+
var Symbol$1 = _Symbol;
|
|
102
|
+
|
|
103
|
+
/** Used for built-in method references. */
|
|
104
|
+
var objectProto$4 = Object.prototype;
|
|
105
|
+
|
|
106
|
+
/** Used to check objects for own properties. */
|
|
107
|
+
var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Used to resolve the
|
|
111
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
112
|
+
* of values.
|
|
113
|
+
*/
|
|
114
|
+
var nativeObjectToString$1 = objectProto$4.toString;
|
|
115
|
+
|
|
116
|
+
/** Built-in value references. */
|
|
117
|
+
var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
121
|
+
*
|
|
122
|
+
* @private
|
|
123
|
+
* @param {*} value The value to query.
|
|
124
|
+
* @returns {string} Returns the raw `toStringTag`.
|
|
125
|
+
*/
|
|
126
|
+
function getRawTag$1(value) {
|
|
127
|
+
var isOwn = hasOwnProperty$3.call(value, symToStringTag$1),
|
|
128
|
+
tag = value[symToStringTag$1];
|
|
129
|
+
|
|
130
|
+
try {
|
|
131
|
+
value[symToStringTag$1] = undefined;
|
|
132
|
+
var unmasked = true;
|
|
133
|
+
} catch (e) {}
|
|
134
|
+
|
|
135
|
+
var result = nativeObjectToString$1.call(value);
|
|
136
|
+
if (unmasked) {
|
|
137
|
+
if (isOwn) {
|
|
138
|
+
value[symToStringTag$1] = tag;
|
|
139
|
+
} else {
|
|
140
|
+
delete value[symToStringTag$1];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
var _getRawTag = getRawTag$1;
|
|
147
|
+
|
|
148
|
+
/** Used for built-in method references. */
|
|
149
|
+
|
|
150
|
+
var objectProto$3 = Object.prototype;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Used to resolve the
|
|
154
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
155
|
+
* of values.
|
|
156
|
+
*/
|
|
157
|
+
var nativeObjectToString = objectProto$3.toString;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Converts `value` to a string using `Object.prototype.toString`.
|
|
161
|
+
*
|
|
162
|
+
* @private
|
|
163
|
+
* @param {*} value The value to convert.
|
|
164
|
+
* @returns {string} Returns the converted string.
|
|
165
|
+
*/
|
|
166
|
+
function objectToString$1(value) {
|
|
167
|
+
return nativeObjectToString.call(value);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
var _objectToString = objectToString$1;
|
|
171
|
+
|
|
172
|
+
var Symbol = _Symbol,
|
|
173
|
+
getRawTag = _getRawTag,
|
|
174
|
+
objectToString = _objectToString;
|
|
175
|
+
|
|
176
|
+
/** `Object#toString` result references. */
|
|
177
|
+
var nullTag = '[object Null]',
|
|
178
|
+
undefinedTag = '[object Undefined]';
|
|
179
|
+
|
|
180
|
+
/** Built-in value references. */
|
|
181
|
+
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
185
|
+
*
|
|
186
|
+
* @private
|
|
187
|
+
* @param {*} value The value to query.
|
|
188
|
+
* @returns {string} Returns the `toStringTag`.
|
|
189
|
+
*/
|
|
190
|
+
function baseGetTag$4(value) {
|
|
191
|
+
if (value == null) {
|
|
192
|
+
return value === undefined ? undefinedTag : nullTag;
|
|
193
|
+
}
|
|
194
|
+
return (symToStringTag && symToStringTag in Object(value))
|
|
195
|
+
? getRawTag(value)
|
|
196
|
+
: objectToString(value);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
var _baseGetTag = baseGetTag$4;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Checks if `value` is the
|
|
203
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
204
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
205
|
+
*
|
|
206
|
+
* @static
|
|
207
|
+
* @memberOf _
|
|
208
|
+
* @since 0.1.0
|
|
209
|
+
* @category Lang
|
|
210
|
+
* @param {*} value The value to check.
|
|
211
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
212
|
+
* @example
|
|
213
|
+
*
|
|
214
|
+
* _.isObject({});
|
|
215
|
+
* // => true
|
|
216
|
+
*
|
|
217
|
+
* _.isObject([1, 2, 3]);
|
|
218
|
+
* // => true
|
|
219
|
+
*
|
|
220
|
+
* _.isObject(_.noop);
|
|
221
|
+
* // => true
|
|
222
|
+
*
|
|
223
|
+
* _.isObject(null);
|
|
224
|
+
* // => false
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
function isObject$2(value) {
|
|
228
|
+
var type = typeof value;
|
|
229
|
+
return value != null && (type == 'object' || type == 'function');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
var isObject_1 = isObject$2;
|
|
233
|
+
|
|
234
|
+
var baseGetTag$3 = _baseGetTag,
|
|
235
|
+
isObject$1 = isObject_1;
|
|
236
|
+
|
|
237
|
+
/** `Object#toString` result references. */
|
|
238
|
+
var asyncTag = '[object AsyncFunction]',
|
|
239
|
+
funcTag$1 = '[object Function]',
|
|
240
|
+
genTag = '[object GeneratorFunction]',
|
|
241
|
+
proxyTag = '[object Proxy]';
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Checks if `value` is classified as a `Function` object.
|
|
245
|
+
*
|
|
246
|
+
* @static
|
|
247
|
+
* @memberOf _
|
|
248
|
+
* @since 0.1.0
|
|
249
|
+
* @category Lang
|
|
250
|
+
* @param {*} value The value to check.
|
|
251
|
+
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
252
|
+
* @example
|
|
253
|
+
*
|
|
254
|
+
* _.isFunction(_);
|
|
255
|
+
* // => true
|
|
256
|
+
*
|
|
257
|
+
* _.isFunction(/abc/);
|
|
258
|
+
* // => false
|
|
259
|
+
*/
|
|
260
|
+
function isFunction$2(value) {
|
|
261
|
+
if (!isObject$1(value)) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
265
|
+
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
266
|
+
var tag = baseGetTag$3(value);
|
|
267
|
+
return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
var isFunction_1 = isFunction$2;
|
|
271
|
+
|
|
272
|
+
var root$5 = _root;
|
|
273
|
+
|
|
274
|
+
/** Used to detect overreaching core-js shims. */
|
|
275
|
+
var coreJsData$1 = root$5['__core-js_shared__'];
|
|
276
|
+
|
|
277
|
+
var _coreJsData = coreJsData$1;
|
|
278
|
+
|
|
279
|
+
var coreJsData = _coreJsData;
|
|
280
|
+
|
|
281
|
+
/** Used to detect methods masquerading as native. */
|
|
282
|
+
var maskSrcKey = (function() {
|
|
283
|
+
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
|
284
|
+
return uid ? ('Symbol(src)_1.' + uid) : '';
|
|
285
|
+
}());
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Checks if `func` has its source masked.
|
|
289
|
+
*
|
|
290
|
+
* @private
|
|
291
|
+
* @param {Function} func The function to check.
|
|
292
|
+
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
293
|
+
*/
|
|
294
|
+
function isMasked$1(func) {
|
|
295
|
+
return !!maskSrcKey && (maskSrcKey in func);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
var _isMasked = isMasked$1;
|
|
299
|
+
|
|
300
|
+
/** Used for built-in method references. */
|
|
301
|
+
|
|
302
|
+
var funcProto$1 = Function.prototype;
|
|
303
|
+
|
|
304
|
+
/** Used to resolve the decompiled source of functions. */
|
|
305
|
+
var funcToString$1 = funcProto$1.toString;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Converts `func` to its source code.
|
|
309
|
+
*
|
|
310
|
+
* @private
|
|
311
|
+
* @param {Function} func The function to convert.
|
|
312
|
+
* @returns {string} Returns the source code.
|
|
313
|
+
*/
|
|
314
|
+
function toSource$2(func) {
|
|
315
|
+
if (func != null) {
|
|
316
|
+
try {
|
|
317
|
+
return funcToString$1.call(func);
|
|
318
|
+
} catch (e) {}
|
|
319
|
+
try {
|
|
320
|
+
return (func + '');
|
|
321
|
+
} catch (e) {}
|
|
322
|
+
}
|
|
323
|
+
return '';
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
var _toSource = toSource$2;
|
|
327
|
+
|
|
328
|
+
var isFunction$1 = isFunction_1,
|
|
329
|
+
isMasked = _isMasked,
|
|
330
|
+
isObject = isObject_1,
|
|
331
|
+
toSource$1 = _toSource;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Used to match `RegExp`
|
|
335
|
+
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
336
|
+
*/
|
|
337
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
338
|
+
|
|
339
|
+
/** Used to detect host constructors (Safari). */
|
|
340
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
341
|
+
|
|
342
|
+
/** Used for built-in method references. */
|
|
343
|
+
var funcProto = Function.prototype,
|
|
344
|
+
objectProto$2 = Object.prototype;
|
|
345
|
+
|
|
346
|
+
/** Used to resolve the decompiled source of functions. */
|
|
347
|
+
var funcToString = funcProto.toString;
|
|
348
|
+
|
|
349
|
+
/** Used to check objects for own properties. */
|
|
350
|
+
var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
|
|
351
|
+
|
|
352
|
+
/** Used to detect if a method is native. */
|
|
353
|
+
var reIsNative = RegExp('^' +
|
|
354
|
+
funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
|
|
355
|
+
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* The base implementation of `_.isNative` without bad shim checks.
|
|
360
|
+
*
|
|
361
|
+
* @private
|
|
362
|
+
* @param {*} value The value to check.
|
|
363
|
+
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
364
|
+
* else `false`.
|
|
365
|
+
*/
|
|
366
|
+
function baseIsNative$1(value) {
|
|
367
|
+
if (!isObject(value) || isMasked(value)) {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
|
|
371
|
+
return pattern.test(toSource$1(value));
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
var _baseIsNative = baseIsNative$1;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Gets the value at `key` of `object`.
|
|
378
|
+
*
|
|
379
|
+
* @private
|
|
380
|
+
* @param {Object} [object] The object to query.
|
|
381
|
+
* @param {string} key The key of the property to get.
|
|
382
|
+
* @returns {*} Returns the property value.
|
|
383
|
+
*/
|
|
384
|
+
|
|
385
|
+
function getValue$1(object, key) {
|
|
386
|
+
return object == null ? undefined : object[key];
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
var _getValue = getValue$1;
|
|
390
|
+
|
|
391
|
+
var baseIsNative = _baseIsNative,
|
|
392
|
+
getValue = _getValue;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Gets the native function at `key` of `object`.
|
|
396
|
+
*
|
|
397
|
+
* @private
|
|
398
|
+
* @param {Object} object The object to query.
|
|
399
|
+
* @param {string} key The key of the method to get.
|
|
400
|
+
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
401
|
+
*/
|
|
402
|
+
function getNative$5(object, key) {
|
|
403
|
+
var value = getValue(object, key);
|
|
404
|
+
return baseIsNative(value) ? value : undefined;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
var _getNative = getNative$5;
|
|
408
|
+
|
|
409
|
+
var getNative$4 = _getNative,
|
|
410
|
+
root$4 = _root;
|
|
411
|
+
|
|
412
|
+
/* Built-in method references that are verified to be native. */
|
|
413
|
+
var DataView$1 = getNative$4(root$4, 'DataView');
|
|
414
|
+
|
|
415
|
+
var _DataView = DataView$1;
|
|
416
|
+
|
|
417
|
+
var getNative$3 = _getNative,
|
|
418
|
+
root$3 = _root;
|
|
419
|
+
|
|
420
|
+
/* Built-in method references that are verified to be native. */
|
|
421
|
+
var Map$1 = getNative$3(root$3, 'Map');
|
|
422
|
+
|
|
423
|
+
var _Map = Map$1;
|
|
424
|
+
|
|
425
|
+
var getNative$2 = _getNative,
|
|
426
|
+
root$2 = _root;
|
|
427
|
+
|
|
428
|
+
/* Built-in method references that are verified to be native. */
|
|
429
|
+
var Promise$2 = getNative$2(root$2, 'Promise');
|
|
430
|
+
|
|
431
|
+
var _Promise = Promise$2;
|
|
432
|
+
|
|
433
|
+
var getNative$1 = _getNative,
|
|
434
|
+
root$1 = _root;
|
|
435
|
+
|
|
436
|
+
/* Built-in method references that are verified to be native. */
|
|
437
|
+
var Set$1 = getNative$1(root$1, 'Set');
|
|
438
|
+
|
|
439
|
+
var _Set = Set$1;
|
|
440
|
+
|
|
441
|
+
var getNative = _getNative,
|
|
442
|
+
root = _root;
|
|
443
|
+
|
|
444
|
+
/* Built-in method references that are verified to be native. */
|
|
445
|
+
var WeakMap$1 = getNative(root, 'WeakMap');
|
|
446
|
+
|
|
447
|
+
var _WeakMap = WeakMap$1;
|
|
448
|
+
|
|
449
|
+
var DataView = _DataView,
|
|
450
|
+
Map = _Map,
|
|
451
|
+
Promise$1 = _Promise,
|
|
452
|
+
Set = _Set,
|
|
453
|
+
WeakMap = _WeakMap,
|
|
454
|
+
baseGetTag$2 = _baseGetTag,
|
|
455
|
+
toSource = _toSource;
|
|
456
|
+
|
|
457
|
+
/** `Object#toString` result references. */
|
|
458
|
+
var mapTag$2 = '[object Map]',
|
|
459
|
+
objectTag$1 = '[object Object]',
|
|
460
|
+
promiseTag = '[object Promise]',
|
|
461
|
+
setTag$2 = '[object Set]',
|
|
462
|
+
weakMapTag$1 = '[object WeakMap]';
|
|
463
|
+
|
|
464
|
+
var dataViewTag$1 = '[object DataView]';
|
|
465
|
+
|
|
466
|
+
/** Used to detect maps, sets, and weakmaps. */
|
|
467
|
+
var dataViewCtorString = toSource(DataView),
|
|
468
|
+
mapCtorString = toSource(Map),
|
|
469
|
+
promiseCtorString = toSource(Promise$1),
|
|
470
|
+
setCtorString = toSource(Set),
|
|
471
|
+
weakMapCtorString = toSource(WeakMap);
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Gets the `toStringTag` of `value`.
|
|
475
|
+
*
|
|
476
|
+
* @private
|
|
477
|
+
* @param {*} value The value to query.
|
|
478
|
+
* @returns {string} Returns the `toStringTag`.
|
|
479
|
+
*/
|
|
480
|
+
var getTag$1 = baseGetTag$2;
|
|
481
|
+
|
|
482
|
+
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
|
|
483
|
+
if ((DataView && getTag$1(new DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
|
|
484
|
+
(Map && getTag$1(new Map) != mapTag$2) ||
|
|
485
|
+
(Promise$1 && getTag$1(Promise$1.resolve()) != promiseTag) ||
|
|
486
|
+
(Set && getTag$1(new Set) != setTag$2) ||
|
|
487
|
+
(WeakMap && getTag$1(new WeakMap) != weakMapTag$1)) {
|
|
488
|
+
getTag$1 = function(value) {
|
|
489
|
+
var result = baseGetTag$2(value),
|
|
490
|
+
Ctor = result == objectTag$1 ? value.constructor : undefined,
|
|
491
|
+
ctorString = Ctor ? toSource(Ctor) : '';
|
|
492
|
+
|
|
493
|
+
if (ctorString) {
|
|
494
|
+
switch (ctorString) {
|
|
495
|
+
case dataViewCtorString: return dataViewTag$1;
|
|
496
|
+
case mapCtorString: return mapTag$2;
|
|
497
|
+
case promiseCtorString: return promiseTag;
|
|
498
|
+
case setCtorString: return setTag$2;
|
|
499
|
+
case weakMapCtorString: return weakMapTag$1;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return result;
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
var _getTag = getTag$1;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
510
|
+
* and has a `typeof` result of "object".
|
|
511
|
+
*
|
|
512
|
+
* @static
|
|
513
|
+
* @memberOf _
|
|
514
|
+
* @since 4.0.0
|
|
515
|
+
* @category Lang
|
|
516
|
+
* @param {*} value The value to check.
|
|
517
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
518
|
+
* @example
|
|
519
|
+
*
|
|
520
|
+
* _.isObjectLike({});
|
|
521
|
+
* // => true
|
|
522
|
+
*
|
|
523
|
+
* _.isObjectLike([1, 2, 3]);
|
|
524
|
+
* // => true
|
|
525
|
+
*
|
|
526
|
+
* _.isObjectLike(_.noop);
|
|
527
|
+
* // => false
|
|
528
|
+
*
|
|
529
|
+
* _.isObjectLike(null);
|
|
530
|
+
* // => false
|
|
531
|
+
*/
|
|
532
|
+
|
|
533
|
+
function isObjectLike$3(value) {
|
|
534
|
+
return value != null && typeof value == 'object';
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
var isObjectLike_1 = isObjectLike$3;
|
|
538
|
+
|
|
539
|
+
var baseGetTag$1 = _baseGetTag,
|
|
540
|
+
isObjectLike$2 = isObjectLike_1;
|
|
541
|
+
|
|
542
|
+
/** `Object#toString` result references. */
|
|
543
|
+
var argsTag$1 = '[object Arguments]';
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* The base implementation of `_.isArguments`.
|
|
547
|
+
*
|
|
548
|
+
* @private
|
|
549
|
+
* @param {*} value The value to check.
|
|
550
|
+
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
551
|
+
*/
|
|
552
|
+
function baseIsArguments$1(value) {
|
|
553
|
+
return isObjectLike$2(value) && baseGetTag$1(value) == argsTag$1;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
var _baseIsArguments = baseIsArguments$1;
|
|
557
|
+
|
|
558
|
+
var baseIsArguments = _baseIsArguments,
|
|
559
|
+
isObjectLike$1 = isObjectLike_1;
|
|
560
|
+
|
|
561
|
+
/** Used for built-in method references. */
|
|
562
|
+
var objectProto$1 = Object.prototype;
|
|
563
|
+
|
|
564
|
+
/** Used to check objects for own properties. */
|
|
565
|
+
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|
566
|
+
|
|
567
|
+
/** Built-in value references. */
|
|
568
|
+
var propertyIsEnumerable = objectProto$1.propertyIsEnumerable;
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Checks if `value` is likely an `arguments` object.
|
|
572
|
+
*
|
|
573
|
+
* @static
|
|
574
|
+
* @memberOf _
|
|
575
|
+
* @since 0.1.0
|
|
576
|
+
* @category Lang
|
|
577
|
+
* @param {*} value The value to check.
|
|
578
|
+
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
579
|
+
* else `false`.
|
|
580
|
+
* @example
|
|
581
|
+
*
|
|
582
|
+
* _.isArguments(function() { return arguments; }());
|
|
583
|
+
* // => true
|
|
584
|
+
*
|
|
585
|
+
* _.isArguments([1, 2, 3]);
|
|
586
|
+
* // => false
|
|
587
|
+
*/
|
|
588
|
+
var isArguments$1 = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
|
|
589
|
+
return isObjectLike$1(value) && hasOwnProperty$1.call(value, 'callee') &&
|
|
590
|
+
!propertyIsEnumerable.call(value, 'callee');
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
var isArguments_1 = isArguments$1;
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Checks if `value` is classified as an `Array` object.
|
|
597
|
+
*
|
|
598
|
+
* @static
|
|
599
|
+
* @memberOf _
|
|
600
|
+
* @since 0.1.0
|
|
601
|
+
* @category Lang
|
|
602
|
+
* @param {*} value The value to check.
|
|
603
|
+
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
604
|
+
* @example
|
|
605
|
+
*
|
|
606
|
+
* _.isArray([1, 2, 3]);
|
|
607
|
+
* // => true
|
|
608
|
+
*
|
|
609
|
+
* _.isArray(document.body.children);
|
|
610
|
+
* // => false
|
|
611
|
+
*
|
|
612
|
+
* _.isArray('abc');
|
|
613
|
+
* // => false
|
|
614
|
+
*
|
|
615
|
+
* _.isArray(_.noop);
|
|
616
|
+
* // => false
|
|
617
|
+
*/
|
|
618
|
+
|
|
619
|
+
var isArray$1 = Array.isArray;
|
|
620
|
+
|
|
621
|
+
var isArray_1 = isArray$1;
|
|
622
|
+
|
|
623
|
+
/** Used as references for various `Number` constants. */
|
|
624
|
+
|
|
625
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Checks if `value` is a valid array-like length.
|
|
629
|
+
*
|
|
630
|
+
* **Note:** This method is loosely based on
|
|
631
|
+
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|
632
|
+
*
|
|
633
|
+
* @static
|
|
634
|
+
* @memberOf _
|
|
635
|
+
* @since 4.0.0
|
|
636
|
+
* @category Lang
|
|
637
|
+
* @param {*} value The value to check.
|
|
638
|
+
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|
639
|
+
* @example
|
|
640
|
+
*
|
|
641
|
+
* _.isLength(3);
|
|
642
|
+
* // => true
|
|
643
|
+
*
|
|
644
|
+
* _.isLength(Number.MIN_VALUE);
|
|
645
|
+
* // => false
|
|
646
|
+
*
|
|
647
|
+
* _.isLength(Infinity);
|
|
648
|
+
* // => false
|
|
649
|
+
*
|
|
650
|
+
* _.isLength('3');
|
|
651
|
+
* // => false
|
|
652
|
+
*/
|
|
653
|
+
function isLength$2(value) {
|
|
654
|
+
return typeof value == 'number' &&
|
|
655
|
+
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
var isLength_1 = isLength$2;
|
|
659
|
+
|
|
660
|
+
var isFunction = isFunction_1,
|
|
661
|
+
isLength$1 = isLength_1;
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Checks if `value` is array-like. A value is considered array-like if it's
|
|
665
|
+
* not a function and has a `value.length` that's an integer greater than or
|
|
666
|
+
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
|
667
|
+
*
|
|
668
|
+
* @static
|
|
669
|
+
* @memberOf _
|
|
670
|
+
* @since 4.0.0
|
|
671
|
+
* @category Lang
|
|
672
|
+
* @param {*} value The value to check.
|
|
673
|
+
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
|
674
|
+
* @example
|
|
675
|
+
*
|
|
676
|
+
* _.isArrayLike([1, 2, 3]);
|
|
677
|
+
* // => true
|
|
678
|
+
*
|
|
679
|
+
* _.isArrayLike(document.body.children);
|
|
680
|
+
* // => true
|
|
681
|
+
*
|
|
682
|
+
* _.isArrayLike('abc');
|
|
683
|
+
* // => true
|
|
684
|
+
*
|
|
685
|
+
* _.isArrayLike(_.noop);
|
|
686
|
+
* // => false
|
|
687
|
+
*/
|
|
688
|
+
function isArrayLike$1(value) {
|
|
689
|
+
return value != null && isLength$1(value.length) && !isFunction(value);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
var isArrayLike_1 = isArrayLike$1;
|
|
693
|
+
|
|
694
|
+
var isBuffer$1 = {exports: {}};
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* This method returns `false`.
|
|
698
|
+
*
|
|
699
|
+
* @static
|
|
700
|
+
* @memberOf _
|
|
701
|
+
* @since 4.13.0
|
|
702
|
+
* @category Util
|
|
703
|
+
* @returns {boolean} Returns `false`.
|
|
704
|
+
* @example
|
|
705
|
+
*
|
|
706
|
+
* _.times(2, _.stubFalse);
|
|
707
|
+
* // => [false, false]
|
|
708
|
+
*/
|
|
709
|
+
|
|
710
|
+
function stubFalse() {
|
|
711
|
+
return false;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
var stubFalse_1 = stubFalse;
|
|
715
|
+
|
|
716
|
+
(function (module, exports) {
|
|
717
|
+
var root = _root,
|
|
718
|
+
stubFalse = stubFalse_1;
|
|
719
|
+
|
|
720
|
+
/** Detect free variable `exports`. */
|
|
721
|
+
var freeExports = exports && !exports.nodeType && exports;
|
|
722
|
+
|
|
723
|
+
/** Detect free variable `module`. */
|
|
724
|
+
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
|
725
|
+
|
|
726
|
+
/** Detect the popular CommonJS extension `module.exports`. */
|
|
727
|
+
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
728
|
+
|
|
729
|
+
/** Built-in value references. */
|
|
730
|
+
var Buffer = moduleExports ? root.Buffer : undefined;
|
|
731
|
+
|
|
732
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
733
|
+
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* Checks if `value` is a buffer.
|
|
737
|
+
*
|
|
738
|
+
* @static
|
|
739
|
+
* @memberOf _
|
|
740
|
+
* @since 4.3.0
|
|
741
|
+
* @category Lang
|
|
742
|
+
* @param {*} value The value to check.
|
|
743
|
+
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
|
744
|
+
* @example
|
|
745
|
+
*
|
|
746
|
+
* _.isBuffer(new Buffer(2));
|
|
747
|
+
* // => true
|
|
748
|
+
*
|
|
749
|
+
* _.isBuffer(new Uint8Array(2));
|
|
750
|
+
* // => false
|
|
751
|
+
*/
|
|
752
|
+
var isBuffer = nativeIsBuffer || stubFalse;
|
|
753
|
+
|
|
754
|
+
module.exports = isBuffer;
|
|
755
|
+
}(isBuffer$1, isBuffer$1.exports));
|
|
756
|
+
|
|
757
|
+
var baseGetTag = _baseGetTag,
|
|
758
|
+
isLength = isLength_1,
|
|
759
|
+
isObjectLike = isObjectLike_1;
|
|
760
|
+
|
|
761
|
+
/** `Object#toString` result references. */
|
|
762
|
+
var argsTag = '[object Arguments]',
|
|
763
|
+
arrayTag = '[object Array]',
|
|
764
|
+
boolTag = '[object Boolean]',
|
|
765
|
+
dateTag = '[object Date]',
|
|
766
|
+
errorTag = '[object Error]',
|
|
767
|
+
funcTag = '[object Function]',
|
|
768
|
+
mapTag$1 = '[object Map]',
|
|
769
|
+
numberTag = '[object Number]',
|
|
770
|
+
objectTag = '[object Object]',
|
|
771
|
+
regexpTag = '[object RegExp]',
|
|
772
|
+
setTag$1 = '[object Set]',
|
|
773
|
+
stringTag = '[object String]',
|
|
774
|
+
weakMapTag = '[object WeakMap]';
|
|
775
|
+
|
|
776
|
+
var arrayBufferTag = '[object ArrayBuffer]',
|
|
777
|
+
dataViewTag = '[object DataView]',
|
|
778
|
+
float32Tag = '[object Float32Array]',
|
|
779
|
+
float64Tag = '[object Float64Array]',
|
|
780
|
+
int8Tag = '[object Int8Array]',
|
|
781
|
+
int16Tag = '[object Int16Array]',
|
|
782
|
+
int32Tag = '[object Int32Array]',
|
|
783
|
+
uint8Tag = '[object Uint8Array]',
|
|
784
|
+
uint8ClampedTag = '[object Uint8ClampedArray]',
|
|
785
|
+
uint16Tag = '[object Uint16Array]',
|
|
786
|
+
uint32Tag = '[object Uint32Array]';
|
|
787
|
+
|
|
788
|
+
/** Used to identify `toStringTag` values of typed arrays. */
|
|
789
|
+
var typedArrayTags = {};
|
|
790
|
+
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
|
|
791
|
+
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
|
|
792
|
+
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
|
|
793
|
+
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
|
|
794
|
+
typedArrayTags[uint32Tag] = true;
|
|
795
|
+
typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
|
|
796
|
+
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
|
|
797
|
+
typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
|
|
798
|
+
typedArrayTags[errorTag] = typedArrayTags[funcTag] =
|
|
799
|
+
typedArrayTags[mapTag$1] = typedArrayTags[numberTag] =
|
|
800
|
+
typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
|
|
801
|
+
typedArrayTags[setTag$1] = typedArrayTags[stringTag] =
|
|
802
|
+
typedArrayTags[weakMapTag] = false;
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* The base implementation of `_.isTypedArray` without Node.js optimizations.
|
|
806
|
+
*
|
|
807
|
+
* @private
|
|
808
|
+
* @param {*} value The value to check.
|
|
809
|
+
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
810
|
+
*/
|
|
811
|
+
function baseIsTypedArray$1(value) {
|
|
812
|
+
return isObjectLike(value) &&
|
|
813
|
+
isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
var _baseIsTypedArray = baseIsTypedArray$1;
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* The base implementation of `_.unary` without support for storing metadata.
|
|
820
|
+
*
|
|
821
|
+
* @private
|
|
822
|
+
* @param {Function} func The function to cap arguments for.
|
|
823
|
+
* @returns {Function} Returns the new capped function.
|
|
824
|
+
*/
|
|
825
|
+
|
|
826
|
+
function baseUnary$1(func) {
|
|
827
|
+
return function(value) {
|
|
828
|
+
return func(value);
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
var _baseUnary = baseUnary$1;
|
|
833
|
+
|
|
834
|
+
var _nodeUtil = {exports: {}};
|
|
835
|
+
|
|
836
|
+
(function (module, exports) {
|
|
837
|
+
var freeGlobal = _freeGlobal;
|
|
838
|
+
|
|
839
|
+
/** Detect free variable `exports`. */
|
|
840
|
+
var freeExports = exports && !exports.nodeType && exports;
|
|
841
|
+
|
|
842
|
+
/** Detect free variable `module`. */
|
|
843
|
+
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
|
844
|
+
|
|
845
|
+
/** Detect the popular CommonJS extension `module.exports`. */
|
|
846
|
+
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
847
|
+
|
|
848
|
+
/** Detect free variable `process` from Node.js. */
|
|
849
|
+
var freeProcess = moduleExports && freeGlobal.process;
|
|
850
|
+
|
|
851
|
+
/** Used to access faster Node.js helpers. */
|
|
852
|
+
var nodeUtil = (function() {
|
|
853
|
+
try {
|
|
854
|
+
// Use `util.types` for Node.js 10+.
|
|
855
|
+
var types = freeModule && freeModule.require && freeModule.require('util').types;
|
|
856
|
+
|
|
857
|
+
if (types) {
|
|
858
|
+
return types;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
// Legacy `process.binding('util')` for Node.js < 10.
|
|
862
|
+
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
|
863
|
+
} catch (e) {}
|
|
864
|
+
}());
|
|
865
|
+
|
|
866
|
+
module.exports = nodeUtil;
|
|
867
|
+
}(_nodeUtil, _nodeUtil.exports));
|
|
868
|
+
|
|
869
|
+
var baseIsTypedArray = _baseIsTypedArray,
|
|
870
|
+
baseUnary = _baseUnary,
|
|
871
|
+
nodeUtil = _nodeUtil.exports;
|
|
872
|
+
|
|
873
|
+
/* Node.js helper references. */
|
|
874
|
+
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* Checks if `value` is classified as a typed array.
|
|
878
|
+
*
|
|
879
|
+
* @static
|
|
880
|
+
* @memberOf _
|
|
881
|
+
* @since 3.0.0
|
|
882
|
+
* @category Lang
|
|
883
|
+
* @param {*} value The value to check.
|
|
884
|
+
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
885
|
+
* @example
|
|
886
|
+
*
|
|
887
|
+
* _.isTypedArray(new Uint8Array);
|
|
888
|
+
* // => true
|
|
889
|
+
*
|
|
890
|
+
* _.isTypedArray([]);
|
|
891
|
+
* // => false
|
|
892
|
+
*/
|
|
893
|
+
var isTypedArray$1 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
|
894
|
+
|
|
895
|
+
var isTypedArray_1 = isTypedArray$1;
|
|
896
|
+
|
|
897
|
+
var baseKeys = _baseKeys,
|
|
898
|
+
getTag = _getTag,
|
|
899
|
+
isArguments = isArguments_1,
|
|
900
|
+
isArray = isArray_1,
|
|
901
|
+
isArrayLike = isArrayLike_1,
|
|
902
|
+
isBuffer = isBuffer$1.exports,
|
|
903
|
+
isPrototype = _isPrototype,
|
|
904
|
+
isTypedArray = isTypedArray_1;
|
|
905
|
+
|
|
906
|
+
/** `Object#toString` result references. */
|
|
907
|
+
var mapTag = '[object Map]',
|
|
908
|
+
setTag = '[object Set]';
|
|
909
|
+
|
|
910
|
+
/** Used for built-in method references. */
|
|
911
|
+
var objectProto = Object.prototype;
|
|
912
|
+
|
|
913
|
+
/** Used to check objects for own properties. */
|
|
914
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Checks if `value` is an empty object, collection, map, or set.
|
|
918
|
+
*
|
|
919
|
+
* Objects are considered empty if they have no own enumerable string keyed
|
|
920
|
+
* properties.
|
|
921
|
+
*
|
|
922
|
+
* Array-like values such as `arguments` objects, arrays, buffers, strings, or
|
|
923
|
+
* jQuery-like collections are considered empty if they have a `length` of `0`.
|
|
924
|
+
* Similarly, maps and sets are considered empty if they have a `size` of `0`.
|
|
925
|
+
*
|
|
926
|
+
* @static
|
|
927
|
+
* @memberOf _
|
|
928
|
+
* @since 0.1.0
|
|
929
|
+
* @category Lang
|
|
930
|
+
* @param {*} value The value to check.
|
|
931
|
+
* @returns {boolean} Returns `true` if `value` is empty, else `false`.
|
|
932
|
+
* @example
|
|
933
|
+
*
|
|
934
|
+
* _.isEmpty(null);
|
|
935
|
+
* // => true
|
|
936
|
+
*
|
|
937
|
+
* _.isEmpty(true);
|
|
938
|
+
* // => true
|
|
939
|
+
*
|
|
940
|
+
* _.isEmpty(1);
|
|
941
|
+
* // => true
|
|
942
|
+
*
|
|
943
|
+
* _.isEmpty([1, 2, 3]);
|
|
944
|
+
* // => false
|
|
945
|
+
*
|
|
946
|
+
* _.isEmpty({ 'a': 1 });
|
|
947
|
+
* // => false
|
|
948
|
+
*/
|
|
949
|
+
function isEmpty(value) {
|
|
950
|
+
if (value == null) {
|
|
951
|
+
return true;
|
|
952
|
+
}
|
|
953
|
+
if (isArrayLike(value) &&
|
|
954
|
+
(isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
|
|
955
|
+
isBuffer(value) || isTypedArray(value) || isArguments(value))) {
|
|
956
|
+
return !value.length;
|
|
957
|
+
}
|
|
958
|
+
var tag = getTag(value);
|
|
959
|
+
if (tag == mapTag || tag == setTag) {
|
|
960
|
+
return !value.size;
|
|
961
|
+
}
|
|
962
|
+
if (isPrototype(value)) {
|
|
963
|
+
return !baseKeys(value).length;
|
|
964
|
+
}
|
|
965
|
+
for (var key in value) {
|
|
966
|
+
if (hasOwnProperty.call(value, key)) {
|
|
967
|
+
return false;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
return true;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
var isEmpty_1 = isEmpty;
|
|
974
|
+
|
|
975
|
+
// TODO: also update '../../configure/src/defaults.js' and '../../src/print.js' when updating defaults
|
|
976
|
+
var defaults = {
|
|
977
|
+
authorEnabled: false, // TODO: should be set to true when all Studio content is updated
|
|
978
|
+
passages: [
|
|
979
|
+
{
|
|
980
|
+
teacherInstructions: '',
|
|
981
|
+
title: '',
|
|
982
|
+
subtitle: '',
|
|
983
|
+
author: '',
|
|
984
|
+
text: '',
|
|
985
|
+
},
|
|
986
|
+
],
|
|
987
|
+
subtitleEnabled: true,
|
|
988
|
+
teacherInstructionsEnabled: true,
|
|
989
|
+
textEnabled: true,
|
|
990
|
+
titleEnabled: true,
|
|
991
|
+
};
|
|
992
|
+
|
|
993
|
+
const getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
|
|
994
|
+
|
|
995
|
+
const checkNullish = (value) => value !== null && value !== undefined;
|
|
996
|
+
|
|
997
|
+
const isEnabled = (value, defaultValue) => (checkNullish(value) ? value : defaultValue);
|
|
998
|
+
|
|
999
|
+
function createDefaultModel(model = {}) {
|
|
1000
|
+
return new Promise((resolve) => {
|
|
1001
|
+
resolve({ ...defaults, ...model });
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
const normalize = (question) => ({ ...defaults, ...question });
|
|
1006
|
+
|
|
1007
|
+
const normalizeTeacherInstructions = (instructions, env) => {
|
|
1008
|
+
const { role, mode } = env;
|
|
1009
|
+
|
|
1010
|
+
if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
|
|
1011
|
+
return instructions || '';
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
return '';
|
|
1015
|
+
};
|
|
1016
|
+
|
|
1017
|
+
/**
|
|
1018
|
+
*
|
|
1019
|
+
* @param {*} question
|
|
1020
|
+
* @param {*} session
|
|
1021
|
+
* @param {*} env
|
|
1022
|
+
*/
|
|
1023
|
+
async function model(question, session, env) {
|
|
1024
|
+
const normalizedQuestion = normalize(question);
|
|
1025
|
+
|
|
1026
|
+
const normalizedPassages = normalizedQuestion.passages.map((passage, index) => ({
|
|
1027
|
+
teacherInstructions: isEnabled(passage.teacherInstructionsEnabled, normalizedQuestion.teacherInstructionsEnabled)
|
|
1028
|
+
? normalizeTeacherInstructions(passage.teacherInstructions, env)
|
|
1029
|
+
: '',
|
|
1030
|
+
label: getContent(passage.title) ? passage.title : `Passage ${index + 1}`,
|
|
1031
|
+
title: isEnabled(passage.titleEnabled, normalizedQuestion.titleEnabled) ? passage.title || '' : '',
|
|
1032
|
+
subtitle: isEnabled(passage.subtitleEnabled, normalizedQuestion.subtitleEnabled) ? passage.subtitle || '' : '',
|
|
1033
|
+
author: isEnabled(passage.authorEnabled, normalizedQuestion.authorEnabled) ? passage.author || '' : '',
|
|
1034
|
+
text: isEnabled(passage.textEnabled, normalizedQuestion.textEnabled) ? passage.text || '' : '',
|
|
1035
|
+
}));
|
|
1036
|
+
|
|
1037
|
+
return {
|
|
1038
|
+
...normalizedQuestion,
|
|
1039
|
+
passages: normalizedPassages,
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
const validate = (model = {}, config = {}) => {
|
|
1044
|
+
const errors = {};
|
|
1045
|
+
const passagesErrors = {};
|
|
1046
|
+
|
|
1047
|
+
(model.passages || []).forEach((passage, index) => {
|
|
1048
|
+
const err = {};
|
|
1049
|
+
|
|
1050
|
+
['teacherInstructions', 'title', 'subtitle', 'author', 'text'].forEach((field) => {
|
|
1051
|
+
if (config[field]?.required && !getContent(passage[field])) {
|
|
1052
|
+
err[field] = 'This field is required.';
|
|
1053
|
+
}
|
|
1054
|
+
});
|
|
1055
|
+
|
|
1056
|
+
if (!isEmpty_1(err)) {
|
|
1057
|
+
passagesErrors[index] = err;
|
|
1058
|
+
}
|
|
1059
|
+
});
|
|
1060
|
+
|
|
1061
|
+
if (!isEmpty_1(passagesErrors)) {
|
|
1062
|
+
errors.passages = passagesErrors;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
return errors;
|
|
1066
|
+
};
|
|
1067
|
+
|
|
1068
|
+
export { createDefaultModel, model, normalize, validate };
|
package/module/demo.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
passages: [
|
|
11
|
+
{
|
|
12
|
+
teacherInstructions: 'Teacher instructions for first tab',
|
|
13
|
+
title: 'Hope Is the Thing with Feathers',
|
|
14
|
+
subtitle: 'from <em>The Complete Poems of Emily Dickinson</em>',
|
|
15
|
+
author: 'by Emily Dickinson',
|
|
16
|
+
text: '<p><font style="visibility:hidden">00000</font>Hope is the thing with feathers<br /><font style="visibility:hidden">00000</font>That perches in the soul,<br /><font style="visibility:hidden">00000</font>And sings the tune without the words,<br /><font style="visibility:hidden">00000</font>And never stops at all,</p><p>5<font style="visibility:hidden">0000</font>And sweetest in the gale is heard;<br /><font style="visibility:hidden">00000</font>And sore must be the storm<br /><font style="visibility:hidden">00000</font>That could abash the little bird<br /><font style="visibility:hidden">00000</font>That kept so many warm.</p><p><font style="visibility:hidden">00000</font>I’ve heard it in the chillest land,<br />10<font style="visibility:hidden">000</font>And on the strangest sea;<br /><font style="visibility:hidden">00000</font>Yet, never, in extremity,<br /><font style="visibility:hidden">00000</font>It asked a crumb of me.</p>',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
title: 'Ineskeen Road, July Evening',
|
|
20
|
+
text: `The bicycles go by in twos and threes -<br/>
|
|
21
|
+
There's a dance in Billy Brennan's barn tonight,<br/>
|
|
22
|
+
And there's the half-talk code of mysteries<br/>
|
|
23
|
+
And the wink-and-elbow language of delight.<br/>
|
|
24
|
+
Half-past eight and there is not a spot<br/>
|
|
25
|
+
Upon a mile of road, no shadow thrown<br/>
|
|
26
|
+
That might turn out a man or woman, not<br/>
|
|
27
|
+
A footfall tapping secrecies of stone. <br/>
|
|
28
|
+
<p/>
|
|
29
|
+
I have what every poet hates in spite<br/>
|
|
30
|
+
Of all the solemn talk of contemplation.<br/>
|
|
31
|
+
Oh, Alexander Selkirk knew the plight<br/>
|
|
32
|
+
Of being king and government and nation.<br/>
|
|
33
|
+
A road, a mile of kingdom. I am king<br/>
|
|
34
|
+
Of banks and stones and every blooming thing.<br/>
|
|
35
|
+
`,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const { model } = generate;
|
|
41
|
+
|
|
42
|
+
var config = {
|
|
43
|
+
elements: {
|
|
44
|
+
'passage-element': '../..',
|
|
45
|
+
},
|
|
46
|
+
models: [model('1', 'passage-element')],
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//Note: demo-el is a custom element loaded in the markup.
|
|
50
|
+
customElements.whenDefined("demo-el").then(() => {
|
|
51
|
+
config.models.forEach((m) => {
|
|
52
|
+
const de = document.createElement("demo-el");
|
|
53
|
+
document.body.appendChild(de);
|
|
54
|
+
de.def = { tagName: m.element, Element, Configure, controller };
|
|
55
|
+
de.model = m;
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_dll_pie_lib__math_rendering as e}from"../../../@pie-lib/math-rendering-module@^4.0.5/module/index.js";import{_dll_react_dom as t,_dll_prop_types as r,_dll_mui__material as n,_dll_mui__material_styles as o,_dll_pie_lib__render_ui as s}from"../../../@pie-lib/shared-module@^3.0.5/module/index.js";var a={};Object.defineProperty(a,"__esModule",{value:!0});class i extends CustomEvent{constructor(e,t,r){super(i.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e,hasModel:r}}),this.component=e,this.complete=t}}i.TYPE="model-set";var u=a.ModelSetEvent=i;class l extends CustomEvent{constructor(e,t){super(l.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e}}),this.component=e,this.complete=t}}l.TYPE="session-changed",a.SessionChangedEvent=l;var c={exports:{}},d={},p=Symbol.for("react.element"),f=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),y=Symbol.for("react.provider"),_=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),E=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),x=Symbol.iterator;var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,T={};function w(e,t,r){this.props=e,this.context=t,this.refs=T,this.updater=r||C}function R(){}function $(e,t,r){this.props=e,this.context=t,this.refs=T,this.updater=r||C}w.prototype.isReactComponent={},w.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},w.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},R.prototype=w.prototype;var I=$.prototype=new R;I.constructor=$,k(I,w.prototype),I.isPureReactComponent=!0;var A=Array.isArray,P=Object.prototype.hasOwnProperty,j={current:null},M={key:!0,ref:!0,__self:!0,__source:!0};function L(e,t,r){var n,o={},s=null,a=null;if(null!=t)for(n in void 0!==t.ref&&(a=t.ref),void 0!==t.key&&(s=""+t.key),t)P.call(t,n)&&!M.hasOwnProperty(n)&&(o[n]=t[n]);var i=arguments.length-2;if(1===i)o.children=r;else if(1<i){for(var u=Array(i),l=0;l<i;l++)u[l]=arguments[l+2];o.children=u}if(e&&e.defaultProps)for(n in i=e.defaultProps)void 0===o[n]&&(o[n]=i[n]);return{$$typeof:p,type:e,key:s,ref:a,props:o,_owner:j.current}}function O(e){return"object"==typeof e&&null!==e&&e.$$typeof===p}var q=/\/+/g;function H(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(e){return t[e]})}(""+e.key):t.toString(36)}function N(e,t,r,n,o){var s=typeof e;"undefined"!==s&&"boolean"!==s||(e=null);var a=!1;if(null===e)a=!0;else switch(s){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case p:case f:a=!0}}if(a)return o=o(a=e),e=""===n?"."+H(a,0):n,A(o)?(r="",null!=e&&(r=e.replace(q,"$&/")+"/"),N(o,t,r,"",function(e){return e})):null!=o&&(O(o)&&(o=function(e,t){return{$$typeof:p,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(o,r+(!o.key||a&&a.key===o.key?"":(""+o.key).replace(q,"$&/")+"/")+e)),t.push(o)),1;if(a=0,n=""===n?".":n+":",A(e))for(var i=0;i<e.length;i++){var u=n+H(s=e[i],i);a+=N(s,t,r,u,o)}else if(u=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=x&&e[x]||e["@@iterator"])?e:null}(e),"function"==typeof u)for(e=u.call(e),i=0;!(s=e.next()).done;)a+=N(s=s.value,t,r,u=n+H(s,i++),o);else if("object"===s)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return a}function D(e,t,r){if(null==e)return e;var n=[],o=0;return N(e,n,"","",function(e){return t.call(r,e,o++)}),n}function F(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var U={current:null},V={transition:null},z={ReactCurrentDispatcher:U,ReactCurrentBatchConfig:V,ReactCurrentOwner:j};function Y(){throw Error("act(...) is not supported in production builds of React.")}d.Children={map:D,forEach:function(e,t,r){D(e,function(){t.apply(this,arguments)},r)},count:function(e){var t=0;return D(e,function(){t++}),t},toArray:function(e){return D(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},d.Component=w,d.Fragment=h,d.Profiler=b,d.PureComponent=$,d.StrictMode=m,d.Suspense=v,d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=z,d.act=Y,d.cloneElement=function(e,t,r){if(null==e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var n=k({},e.props),o=e.key,s=e.ref,a=e._owner;if(null!=t){if(void 0!==t.ref&&(s=t.ref,a=j.current),void 0!==t.key&&(o=""+t.key),e.type&&e.type.defaultProps)var i=e.type.defaultProps;for(u in t)P.call(t,u)&&!M.hasOwnProperty(u)&&(n[u]=void 0===t[u]&&void 0!==i?i[u]:t[u])}var u=arguments.length-2;if(1===u)n.children=r;else if(1<u){i=Array(u);for(var l=0;l<u;l++)i[l]=arguments[l+2];n.children=i}return{$$typeof:p,type:e.type,key:o,ref:s,props:n,_owner:a}},d.createContext=function(e){return(e={$$typeof:_,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:y,_context:e},e.Consumer=e},d.createElement=L,d.createFactory=function(e){var t=L.bind(null,e);return t.type=e,t},d.createRef=function(){return{current:null}},d.forwardRef=function(e){return{$$typeof:g,render:e}},d.isValidElement=O,d.lazy=function(e){return{$$typeof:S,_payload:{_status:-1,_result:e},_init:F}},d.memo=function(e,t){return{$$typeof:E,type:e,compare:void 0===t?null:t}},d.startTransition=function(e){var t=V.transition;V.transition={};try{e()}finally{V.transition=t}},d.unstable_act=Y,d.useCallback=function(e,t){return U.current.useCallback(e,t)},d.useContext=function(e){return U.current.useContext(e)},d.useDebugValue=function(){},d.useDeferredValue=function(e){return U.current.useDeferredValue(e)},d.useEffect=function(e,t){return U.current.useEffect(e,t)},d.useId=function(){return U.current.useId()},d.useImperativeHandle=function(e,t,r){return U.current.useImperativeHandle(e,t,r)},d.useInsertionEffect=function(e,t){return U.current.useInsertionEffect(e,t)},d.useLayoutEffect=function(e,t){return U.current.useLayoutEffect(e,t)},d.useMemo=function(e,t){return U.current.useMemo(e,t)},d.useReducer=function(e,t,r){return U.current.useReducer(e,t,r)},d.useRef=function(e){return U.current.useRef(e)},d.useState=function(e){return U.current.useState(e)},d.useSyncExternalStore=function(e,t,r){return U.current.useSyncExternalStore(e,t,r)},d.useTransition=function(){return U.current.useTransition()},d.version="18.3.1",c.exports=d;var B=c.exports;var J,K=t;J=K.createRoot,K.hydrateRoot;const G=r,{Tabs:W}=n,{Tab:Q}=n,{styled:X}=o,{Collapsible:Z}=s,{color:ee}=s,{PreviewPrompt:te}=s,{Purpose:re}=s,{UiLayout:ne}=s;const oe=X("div")({flexGrow:1,backgroundColor:ee.background(),color:ee.text(),"&:not(.MathJax) table":{borderCollapse:"collapse"},"&:not(.MathJax) table td, &:not(.MathJax) table th":{padding:".6em 1em",textAlign:"left"}}),se=X("div")(({theme:e})=>({backgroundColor:ee.background(),color:ee.text(),padding:e.spacing(2)})),ae=X("div")({fontSize:"1.75rem"}),ie=X("div")({fontSize:"1.5rem"}),ue=X("div")({fontSize:"1.25rem"}),le=X(Q)(({theme:e})=>({background:e.palette.common.white,fontSize:"inherit",color:e.palette.common.black}));class ce extends B.Component{constructor(...e){super(...e),ce.prototype.__init.call(this),ce.prototype.__init2.call(this),ce.prototype.__init3.call(this),ce.prototype.__init4.call(this)}__init(){this.state={activeTab:0}}__init2(){this.handleChange=(e,t)=>{this.setState(()=>({activeTab:t})),setTimeout(()=>{const e=new CustomEvent("pie-ui-passage-tabChanged",{detail:{tab:t}});window.dispatchEvent(e)})}}__init3(){this.handleKeyDown=(e,t)=>{const{key:r}=e,{tabs:n}=this.props;let o=-1;const s=n.findIndex(e=>e.id===t);switch(r){case"ArrowRight":o=(s+1)%n.length;break;case"ArrowLeft":o=(s-1+n.length)%n.length;break;case"Home":o=0;break;case"End":o=n.length-1;break;case"Enter":case" ":o=s}-1!==o&&(e.preventDefault(),this.handleChange(e,n[o].id),document.getElementById(`button-${n[o].id}`).focus())}}__init4(){this.parsedText=(e="")=>{const t=document.createElement("div");t.innerHTML=e.replace(/(<br\/>\n)/g,"<br/>");const r=t.querySelector("audio");if(r){const e=document.createElement("source");e.setAttribute("type","audio/mp3"),e.setAttribute("src",r.getAttribute("src")),r.removeAttribute("src"),r.appendChild(e)}return t.innerHTML}}renderInstructions(e,t=!1){if(!e)return;const r=B.createElement(te,{tagName:"div",className:"prompt",defaultClassName:"teacher-instructions",prompt:e});return t?r:B.createElement(Z,{labels:{hidden:"Show Teacher Instructions",visible:"Hide Teacher Instructions"}},r)}renderTab(e,t){return B.createElement(se,{key:e.id,id:`tabpanel-${e.id}`,role:"tabpanel","aria-labelledby":`button-${e.id}`},this.renderInstructions(e.teacherInstructions,t),(e.title||e.subtitle)&&B.createElement("h2",null,e.title&&B.createElement(re,{purpose:"passage-title"},B.createElement(ae,{dangerouslySetInnerHTML:{__html:this.parsedText(e.title)}})),e.subtitle&&B.createElement(re,{purpose:"passage-subtitle"},B.createElement(ie,{dangerouslySetInnerHTML:{__html:this.parsedText(e.subtitle)}}))),e.author&&B.createElement(re,{purpose:"passage-author"},B.createElement(ue,{className:"author",dangerouslySetInnerHTML:{__html:this.parsedText(e.author)}})),e.text&&B.createElement(re,{purpose:"passage-text"},B.createElement("div",{key:e.id,className:"text",dangerouslySetInnerHTML:{__html:this.parsedText(e.text)}})))}render(){const{model:e,tabs:t,disabledTabs:r}=this.props,{activeTab:n}=this.state;if(!function(e){let t,r=e[0],n=1;for(;n<e.length;){const o=e[n],s=e[n+1];if(n+=2,("optionalAccess"===o||"optionalCall"===o)&&null==r)return;"access"===o||"optionalAccess"===o?(t=r,r=s(r)):"call"!==o&&"optionalCall"!==o||(r=s((...e)=>r.call(t,...e)),t=void 0)}return r}([t,"optionalAccess",e=>e.length]))return;const{extraCSSRules:o}=e||{},s=(t||[]).find(e=>e.id===n);return B.createElement(ne,{extraCSSRules:o},B.createElement(oe,{className:"passages"},r||1===t.length?t.map(e=>this.renderTab(e,r)):B.createElement(B.Fragment,null,B.createElement(W,{sx:{position:"sticky",top:0,background:ee.background(),color:ee.text()},value:n,onChange:this.handleChange},t.map(e=>B.createElement(le,{key:e.id,id:`button-${e.id}`,label:B.createElement(re,{purpose:"passage-label"},B.createElement("span",{dangerouslySetInnerHTML:{__html:this.parsedText(e.label)}})),value:e.id,tabIndex:n===e.id?0:-1,"aria-controls":`tabpanel-${e.id}`,"aria-selected":n===e.id,onFocus:()=>this.handleChange(null,e.id),onKeyDown:t=>this.handleKeyDown(t,e.id)}))),s?this.renderTab(s,r):null)))}}ce.propTypes={tabs:G.arrayOf(G.shape({id:G.number.isRequired,label:G.string.isRequired,title:G.string.isRequired,subtitle:G.string,author:G.string,text:G.string.isRequired,teacherInstructions:G.string}).isRequired).isRequired,disabledTabs:G.bool,model:G.object};const{renderMath:de}=e;class pe extends HTMLElement{constructor(){super(),this._model={passages:[]},this._session=null,this._root=null}setLangAttribute(){const e=this._model&&(this._model.language,1)?this._model.language:"",t=e?e.slice(0,2):"en";this.setAttribute("lang",t)}set model(e){this._model=e,this.dispatchEvent(new u(this.tagName.toLowerCase(),this._session,!!this._model)),this.setLangAttribute(),this._render()}set session(e){this._session=e}connectedCallback(){this.setAttribute("aria-label","Passage"),this.setAttribute("role","region"),this._render()}_render(){const{passages:e=[]}=this._model;if(this._model.passages.length>0){const t=e.map((e,t)=>({id:t,...e})),r=B.createElement(ce,{tabs:t});this._root||(this._root=J(this)),this._root.render(r),queueMicrotask(()=>{de(this)})}}disconnectedCallback(){this._root&&this._root.unmount()}}export{pe as default};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
<!doctype html>
|
|
3
|
+
<html>
|
|
4
|
+
<head>
|
|
5
|
+
<title>@pie-element/passage@6.0.0-beta.1</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,95 @@
|
|
|
1
|
+
import PrintElement from './print.js';
|
|
2
|
+
|
|
3
|
+
var generate = {};
|
|
4
|
+
|
|
5
|
+
generate.model = (id, element) => ({
|
|
6
|
+
id,
|
|
7
|
+
element,
|
|
8
|
+
passages: [
|
|
9
|
+
{
|
|
10
|
+
teacherInstructions: 'Teacher instructions for first tab',
|
|
11
|
+
title: 'Hope Is the Thing with Feathers',
|
|
12
|
+
subtitle: 'from <em>The Complete Poems of Emily Dickinson</em>',
|
|
13
|
+
author: 'by Emily Dickinson',
|
|
14
|
+
text: '<p><font style="visibility:hidden">00000</font>Hope is the thing with feathers<br /><font style="visibility:hidden">00000</font>That perches in the soul,<br /><font style="visibility:hidden">00000</font>And sings the tune without the words,<br /><font style="visibility:hidden">00000</font>And never stops at all,</p><p>5<font style="visibility:hidden">0000</font>And sweetest in the gale is heard;<br /><font style="visibility:hidden">00000</font>And sore must be the storm<br /><font style="visibility:hidden">00000</font>That could abash the little bird<br /><font style="visibility:hidden">00000</font>That kept so many warm.</p><p><font style="visibility:hidden">00000</font>I’ve heard it in the chillest land,<br />10<font style="visibility:hidden">000</font>And on the strangest sea;<br /><font style="visibility:hidden">00000</font>Yet, never, in extremity,<br /><font style="visibility:hidden">00000</font>It asked a crumb of me.</p>',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
title: 'Ineskeen Road, July Evening',
|
|
18
|
+
text: `The bicycles go by in twos and threes -<br/>
|
|
19
|
+
There's a dance in Billy Brennan's barn tonight,<br/>
|
|
20
|
+
And there's the half-talk code of mysteries<br/>
|
|
21
|
+
And the wink-and-elbow language of delight.<br/>
|
|
22
|
+
Half-past eight and there is not a spot<br/>
|
|
23
|
+
Upon a mile of road, no shadow thrown<br/>
|
|
24
|
+
That might turn out a man or woman, not<br/>
|
|
25
|
+
A footfall tapping secrecies of stone. <br/>
|
|
26
|
+
<p/>
|
|
27
|
+
I have what every poet hates in spite<br/>
|
|
28
|
+
Of all the solemn talk of contemplation.<br/>
|
|
29
|
+
Oh, Alexander Selkirk knew the plight<br/>
|
|
30
|
+
Of being king and government and nation.<br/>
|
|
31
|
+
A road, a mile of kingdom. I am king<br/>
|
|
32
|
+
Of banks and stones and every blooming thing.<br/>
|
|
33
|
+
`,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const { model } = generate;
|
|
39
|
+
|
|
40
|
+
var config = {
|
|
41
|
+
elements: {
|
|
42
|
+
'passage-element': '../..',
|
|
43
|
+
},
|
|
44
|
+
models: [model('1', 'passage-element')],
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// new init - just shows off print!
|
|
48
|
+
|
|
49
|
+
const init = async () => {
|
|
50
|
+
console.log('define the element...');
|
|
51
|
+
await Promise.all(
|
|
52
|
+
config.models.map(async (m) => {
|
|
53
|
+
try {
|
|
54
|
+
const printTag = `${m.element}-print`;
|
|
55
|
+
if (customElements.get(printTag)) {
|
|
56
|
+
return true;
|
|
57
|
+
} else {
|
|
58
|
+
customElements.define(printTag, PrintElement);
|
|
59
|
+
await customElements.whenDefined(printTag);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
} catch (e) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
console.log('now apply the model...');
|
|
69
|
+
config.models.forEach((m) => {
|
|
70
|
+
const printTag = `${m.element}-print`;
|
|
71
|
+
const h3s = document.createElement('h3');
|
|
72
|
+
h3s.textContent = 'student mode';
|
|
73
|
+
document.body.appendChild(h3s);
|
|
74
|
+
const de = document.createElement(printTag);
|
|
75
|
+
document.body.appendChild(de);
|
|
76
|
+
de.options = {};
|
|
77
|
+
de.model = m;
|
|
78
|
+
|
|
79
|
+
const h3 = document.createElement('h3');
|
|
80
|
+
h3.textContent = 'instructor mode';
|
|
81
|
+
document.body.appendChild(h3);
|
|
82
|
+
const instr = document.createElement(printTag);
|
|
83
|
+
document.body.appendChild(instr);
|
|
84
|
+
instr.options = { mode: 'instructor' };
|
|
85
|
+
instr.model = JSON.parse(JSON.stringify(m));
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
init()
|
|
90
|
+
.then(() => {
|
|
91
|
+
console.log('ready');
|
|
92
|
+
})
|
|
93
|
+
.catch((e) => {
|
|
94
|
+
console.error(e);
|
|
95
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
<!doctype html>
|
|
3
|
+
<html>
|
|
4
|
+
<head>
|
|
5
|
+
<title>@pie-element/passage@6.0.0-beta.1</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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/passage",
|
|
3
|
-
"version": "6.0.0-
|
|
3
|
+
"version": "6.0.0-next.42+bb1f3eb4e",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"@mui/icons-material": "^7.3.4",
|
|
15
15
|
"@mui/material": "^7.3.4",
|
|
16
16
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
17
|
-
"@pie-lib/math-rendering": "4.1.
|
|
18
|
-
"@pie-lib/render-ui": "5.1.
|
|
19
|
-
"prop-types": "^15.
|
|
17
|
+
"@pie-lib/math-rendering": "4.1.1-next.0",
|
|
18
|
+
"@pie-lib/render-ui": "5.1.1-next.0",
|
|
19
|
+
"prop-types": "^15.8.1",
|
|
20
20
|
"react": "18.2.0",
|
|
21
21
|
"react-dom": "18.2.0"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "bb1f3eb4e3b5b1cb15024d459ffd6e94bf419712",
|
|
24
24
|
"scripts": {
|
|
25
25
|
"postpublish": "../../scripts/postpublish"
|
|
26
26
|
},
|