@pie-element/select-text 13.1.1-next.1 → 13.1.1-next.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +1422 -0
- package/CHANGELOG.md +2278 -0
- package/LICENSE.md +5 -0
- package/README.md +5 -0
- package/configure/CHANGELOG.json +1032 -0
- package/configure/CHANGELOG.md +2013 -0
- package/configure/lib/defaultConfiguration.js +177 -0
- package/configure/lib/defaultConfiguration.js.map +1 -0
- package/configure/lib/design.js +406 -0
- package/configure/lib/design.js.map +1 -0
- package/configure/lib/index.js +128 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/utils.js +92 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +25 -0
- package/controller/CHANGELOG.json +442 -0
- package/controller/CHANGELOG.md +1464 -0
- package/controller/lib/defaults.js +25 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +258 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/package.json +16 -0
- package/docs/config-schema.json +2135 -0
- package/docs/config-schema.json.md +1579 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +823 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +24 -0
- package/docs/pie-schema.json +1248 -0
- package/docs/pie-schema.json.md +711 -0
- package/lib/index.js +103 -0
- package/lib/index.js.map +1 -0
- package/lib/main.js +191 -0
- package/lib/main.js.map +1 -0
- package/lib/print.js +87 -0
- package/lib/print.js.map +1 -0
- package/lib/utils.js +80 -0
- package/lib/utils.js.map +1 -0
- package/package.json +21 -60
- package/dist/author/defaultConfiguration.d.ts +0 -179
- package/dist/author/defaultConfiguration.js +0 -141
- package/dist/author/design.d.ts +0 -38
- package/dist/author/design.js +0 -264
- package/dist/author/index.d.ts +0 -27
- package/dist/author/index.js +0 -74
- package/dist/author/utils.d.ts +0 -10
- package/dist/author/utils.js +0 -50
- package/dist/controller/defaults.d.ts +0 -27
- package/dist/controller/defaults.js +0 -21
- package/dist/controller/index.d.ts +0 -25
- package/dist/controller/index.js +0 -121
- package/dist/delivery/index.d.ts +0 -19
- package/dist/delivery/index.js +0 -60
- package/dist/delivery/main.d.ts +0 -34
- package/dist/delivery/main.js +0 -136
- package/dist/delivery/utils.d.ts +0 -10
- package/dist/delivery/utils.js +0 -47
- package/dist/index.d.ts +0 -1
- package/dist/index.iife.d.ts +0 -8
- package/dist/index.iife.js +0 -167
- package/dist/index.js +0 -2
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_DataView.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Hash.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_ListCache.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Map.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_MapCache.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Promise.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Set.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Stack.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Symbol.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Uint8Array.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_WeakMap.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayEach.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayFilter.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayLikeKeys.js +0 -15
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayPush.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_assignValue.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_assocIndexOf.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssign.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssignIn.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssignValue.js +0 -12
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseClone.js +0 -57
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseCreate.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetAllKeys.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetTag.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsArguments.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsMap.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsNative.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsSet.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsTypedArray.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseKeys.js +0 -12
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseKeysIn.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseTimes.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseTrim.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseUnary.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneArrayBuffer.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneBuffer.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneDataView.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneRegExp.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneSymbol.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneTypedArray.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copyArray.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copyObject.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copySymbols.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copySymbolsIn.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_coreJsData.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_defineProperty.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_freeGlobal.js +0 -4
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getAllKeys.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getAllKeysIn.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getMapData.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getNative.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getPrototype.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getRawTag.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getSymbols.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getSymbolsIn.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getTag.js +0 -23
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getValue.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashClear.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashDelete.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashGet.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashHas.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashSet.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneArray.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneByTag.js +0 -33
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneObject.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isIndex.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isKeyable.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isMasked.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isPrototype.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheClear.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheDelete.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheGet.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheHas.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheSet.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheClear.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheDelete.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheGet.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheHas.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheSet.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeCreate.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeKeys.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeKeysIn.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nodeUtil.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_objectToString.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_overArg.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_root.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackClear.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackDelete.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackGet.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackHas.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackSet.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_toSource.js +0 -15
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_trimmedEndIndex.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/cloneDeep.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/debounce.js +0 -50
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/eq.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArguments.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArray.js +0 -4
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArrayLike.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isBuffer.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isEmpty.js +0 -21
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isFunction.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isLength.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isMap.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObject.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObjectLike.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isSet.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isSymbol.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isTypedArray.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/keys.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/keysIn.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/now.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/stubArray.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/stubFalse.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/toNumber.js +0 -19
- package/dist/print/index.d.ts +0 -15
- package/dist/print/index.js +0 -41
package/dist/author/index.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { generateModel as e } from "./utils.js";
|
|
2
|
-
import t from "./design.js";
|
|
3
|
-
import n from "./defaultConfiguration.js";
|
|
4
|
-
import r from "react";
|
|
5
|
-
import { createRoot as i } from "react-dom/client";
|
|
6
|
-
import { DeleteImageEvent as a, DeleteSoundEvent as o, InsertImageEvent as s, InsertSoundEvent as c, ModelUpdatedEvent as l } from "@pie-element/shared-configure-events";
|
|
7
|
-
//#region src/author/index.ts
|
|
8
|
-
var u = class u extends HTMLElement {
|
|
9
|
-
static createDefaultModel = (t = {}) => e({
|
|
10
|
-
...n.model,
|
|
11
|
-
...t
|
|
12
|
-
});
|
|
13
|
-
constructor() {
|
|
14
|
-
super(), this._root = null, this._model = u.createDefaultModel(), this._configuration = n.configuration;
|
|
15
|
-
}
|
|
16
|
-
set model(e) {
|
|
17
|
-
this._model = u.createDefaultModel(e), this.render();
|
|
18
|
-
}
|
|
19
|
-
set configuration(e) {
|
|
20
|
-
let t = {
|
|
21
|
-
...n.configuration,
|
|
22
|
-
...e
|
|
23
|
-
};
|
|
24
|
-
this._configuration = t, t?.language?.enabled ? t?.languageChoices?.options?.length && (this._model.language = t?.languageChoices.options[0].value) : t.language.settings && this._model.language ? (this._configuration.language.enabled = !0, (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) && (this._configuration.languageChoices.options = []), this._configuration.languageChoices.options.find((e) => e.value === this._model.language) || this._configuration.languageChoices.options.push({
|
|
25
|
-
value: this._model.language,
|
|
26
|
-
label: this._model.language
|
|
27
|
-
})) : delete this._model.language, this.render();
|
|
28
|
-
}
|
|
29
|
-
connectedCallback() {
|
|
30
|
-
this.render();
|
|
31
|
-
}
|
|
32
|
-
modelChanged(e) {
|
|
33
|
-
this._model = e, this.dispatchEvent(new l(this._model), !0), this.render();
|
|
34
|
-
}
|
|
35
|
-
onConfigurationChanged(e) {
|
|
36
|
-
this._configuration = e, this._model && this.dispatchEvent(new l(this._model), !1), this.render();
|
|
37
|
-
}
|
|
38
|
-
insertImage(e) {
|
|
39
|
-
this.dispatchEvent(new s(e));
|
|
40
|
-
}
|
|
41
|
-
onDeleteImage(e, t) {
|
|
42
|
-
this.dispatchEvent(new a(e, t));
|
|
43
|
-
}
|
|
44
|
-
insertSound(e) {
|
|
45
|
-
this.dispatchEvent(new c(e));
|
|
46
|
-
}
|
|
47
|
-
onDeleteSound(e, t) {
|
|
48
|
-
this.dispatchEvent(new o(e, t));
|
|
49
|
-
}
|
|
50
|
-
render() {
|
|
51
|
-
if (this._model) {
|
|
52
|
-
let e = r.createElement(t, {
|
|
53
|
-
model: this._model,
|
|
54
|
-
configuration: this._configuration,
|
|
55
|
-
onModelChanged: this.modelChanged.bind(this),
|
|
56
|
-
onConfigurationChanged: this.onConfigurationChanged.bind(this),
|
|
57
|
-
imageSupport: {
|
|
58
|
-
add: this.insertImage.bind(this),
|
|
59
|
-
delete: this.onDeleteImage.bind(this)
|
|
60
|
-
},
|
|
61
|
-
uploadSoundSupport: {
|
|
62
|
-
add: this.insertSound.bind(this),
|
|
63
|
-
delete: this.onDeleteSound.bind(this)
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
this._root ||= i(this), this._root.render(e);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
disconnectedCallback() {
|
|
70
|
-
this._root && this._root.unmount();
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
//#endregion
|
|
74
|
-
export { u as default };
|
package/dist/author/utils.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/select-text/configure/src/utils.js
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
export declare const generateModel: (model: any) => any;
|
|
10
|
-
export declare const generateValidationMessage: (config: any) => string;
|
package/dist/author/utils.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
//#region src/author/utils.tsx
|
|
2
|
-
var e = function() {
|
|
3
|
-
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", t = document.createElement("div");
|
|
4
|
-
return t.innerHTML = e.trim(), t;
|
|
5
|
-
}, t = function(e, t) {
|
|
6
|
-
return t ? e.innerHTML : `${e.innerHTML}
|
|
7
|
-
|
|
8
|
-
`;
|
|
9
|
-
}, n = function(e) {
|
|
10
|
-
var n = e.querySelectorAll("div[separator=true]"), r = "";
|
|
11
|
-
return n.forEach(function(e, i) {
|
|
12
|
-
r += t(e, i === n.length - 1);
|
|
13
|
-
}), r || null;
|
|
14
|
-
}, r = function(t) {
|
|
15
|
-
var r = e(t), i = document.createElement("div");
|
|
16
|
-
return i.innerHTML = `<div separator='true'>${r.innerHTML}</div>`, r = i, Array.from(r.querySelectorAll("*")).length === 0 ? t : n(r);
|
|
17
|
-
}, i = (e) => {
|
|
18
|
-
if (!e) return e;
|
|
19
|
-
let t = r(e.text || ""), n = (e.tokens || []).reduce((n, i = {}) => {
|
|
20
|
-
let a = r((e.text || "").slice(i.start, i.end));
|
|
21
|
-
if (!a) return [...n, i];
|
|
22
|
-
let o = (e) => {
|
|
23
|
-
let n = e;
|
|
24
|
-
for (; n >= 0;) {
|
|
25
|
-
let e = t.slice(n).indexOf(a);
|
|
26
|
-
if (e >= 0) return e + n;
|
|
27
|
-
n--;
|
|
28
|
-
}
|
|
29
|
-
return 0;
|
|
30
|
-
}, s = n[n.length - 1], c = o(s ? s.end : i.start), l = c + a.length;
|
|
31
|
-
return [...n, {
|
|
32
|
-
...i,
|
|
33
|
-
text: a,
|
|
34
|
-
start: c,
|
|
35
|
-
end: l,
|
|
36
|
-
oldStart: i.start,
|
|
37
|
-
oldEnd: i.end
|
|
38
|
-
}];
|
|
39
|
-
}, []);
|
|
40
|
-
return {
|
|
41
|
-
...e,
|
|
42
|
-
tokens: n,
|
|
43
|
-
text: t
|
|
44
|
-
};
|
|
45
|
-
}, a = (e) => {
|
|
46
|
-
let { minTokens: t, maxTokens: n, maxSelections: r } = e, i = `\nThere should be at least ${t} ` + (n ? `and at most ${n} ` : "") + "tokens defined.", a = "\nThere should be at least 1 " + (r ? `and at most ${r} ` : "") + "token" + (r ? "s" : "") + " selected.";
|
|
47
|
-
return "Validation requirements:" + i + a;
|
|
48
|
-
};
|
|
49
|
-
//#endregion
|
|
50
|
-
export { i as generateModel, a as generateValidationMessage };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/select-text/controller/src/defaults.js
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
declare const _default: {
|
|
10
|
-
feedbackEnabled: boolean;
|
|
11
|
-
highlightChoices: boolean;
|
|
12
|
-
maxSelections: number;
|
|
13
|
-
mode: string;
|
|
14
|
-
partialScoring: boolean;
|
|
15
|
-
prompt: string;
|
|
16
|
-
promptEnabled: boolean;
|
|
17
|
-
rationale: string;
|
|
18
|
-
rationaleEnabled: boolean;
|
|
19
|
-
scoringType: string;
|
|
20
|
-
studentInstructionsEnabled: boolean;
|
|
21
|
-
teacherInstructions: string;
|
|
22
|
-
teacherInstructionsEnabled: boolean;
|
|
23
|
-
text: string;
|
|
24
|
-
tokens: never[];
|
|
25
|
-
toolbarEditorPosition: string;
|
|
26
|
-
};
|
|
27
|
-
export default _default;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//#region src/controller/defaults.ts
|
|
2
|
-
var e = {
|
|
3
|
-
feedbackEnabled: !1,
|
|
4
|
-
highlightChoices: !1,
|
|
5
|
-
maxSelections: 0,
|
|
6
|
-
mode: "sentence",
|
|
7
|
-
partialScoring: !1,
|
|
8
|
-
prompt: "",
|
|
9
|
-
promptEnabled: !0,
|
|
10
|
-
rationale: "",
|
|
11
|
-
rationaleEnabled: !0,
|
|
12
|
-
scoringType: "auto",
|
|
13
|
-
studentInstructionsEnabled: !0,
|
|
14
|
-
teacherInstructions: "",
|
|
15
|
-
teacherInstructionsEnabled: !0,
|
|
16
|
-
text: "",
|
|
17
|
-
tokens: [],
|
|
18
|
-
toolbarEditorPosition: "bottom"
|
|
19
|
-
};
|
|
20
|
-
//#endregion
|
|
21
|
-
export { e as default };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/select-text/controller/src/index.js
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
export declare const getCorrectness: (tokens: any, selected: any) => "unknown" | "correct" | "partially-correct" | "incorrect";
|
|
10
|
-
export declare const getPartialScore: (question: any, session: any, totalCorrect: any) => number;
|
|
11
|
-
/**
|
|
12
|
-
* Generates detailed trace log for select-text scoring evaluation
|
|
13
|
-
* @param {Object} question - the question model
|
|
14
|
-
* @param {Object} session - the student session
|
|
15
|
-
* @param {Object} env - the environment
|
|
16
|
-
* @returns {Array<string>} traceLog
|
|
17
|
-
*/
|
|
18
|
-
export declare const getLogTrace: (question: any, session: any, env: any) => string[];
|
|
19
|
-
export declare const outcome: (question: any, session: any, env: any) => Promise<unknown>;
|
|
20
|
-
export declare function createDefaultModel(model?: {}): Promise<unknown>;
|
|
21
|
-
export declare const normalizeSession: (session: any) => any;
|
|
22
|
-
export declare const normalize: (question: any) => any;
|
|
23
|
-
export declare const model: (question: any, session: any, env: any) => Promise<unknown>;
|
|
24
|
-
export declare const createCorrectResponseSession: (question: any, env: any) => Promise<unknown>;
|
|
25
|
-
export declare const validate: (model?: {}, config?: {}) => {};
|
package/dist/controller/index.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import e from "../node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isEmpty.js";
|
|
2
|
-
import t from "./defaults.js";
|
|
3
|
-
import n from "debug";
|
|
4
|
-
import { getFeedbackForCorrectness as r } from "@pie-element/shared-feedback";
|
|
5
|
-
import { partialScoring as i } from "@pie-element/shared-controller-utils";
|
|
6
|
-
//#region src/controller/index.ts
|
|
7
|
-
var a = n("@pie-element:select-text:controller"), o = (e = {}, t = {}) => e?.start === t?.start && e?.end === t?.end || e?.start === t?.oldStart && e?.end === t?.oldEnd, s = (e = [], t = [], n = !1) => (e || []).map((e) => {
|
|
8
|
-
let r = !!e.correct, i = r && !(t || []).find((t) => o(e, t));
|
|
9
|
-
return {
|
|
10
|
-
...e,
|
|
11
|
-
correct: n ? r : void 0,
|
|
12
|
-
isMissing: n ? i : void 0
|
|
13
|
-
};
|
|
14
|
-
}), c = (e, t) => {
|
|
15
|
-
let n = e.filter((e) => e.correct === !0);
|
|
16
|
-
if (n.length === 0) return "unknown";
|
|
17
|
-
let r = l(e, t);
|
|
18
|
-
if (r.length === t.length) {
|
|
19
|
-
if (r.length === n.length) return "correct";
|
|
20
|
-
if (r.length > 0) return "partially-correct";
|
|
21
|
-
}
|
|
22
|
-
return r.length > 0 ? "partially-correct" : "incorrect";
|
|
23
|
-
}, l = (e, t) => (t || []).filter((t) => e.findIndex((e) => e.correct && o(e, t)) !== -1), u = (t, n, r) => {
|
|
24
|
-
if (!n || e(n)) return 0;
|
|
25
|
-
let i = l(t.tokens, n.selectedTokens).length, a = (t.tokens || []).filter((e) => e.correct === !0), o = i - (n.selectedTokens && n.selectedTokens.length > a.length ? n.selectedTokens && n.selectedTokens.length - i : 0), s = o < 0 ? 0 : o;
|
|
26
|
-
return r.length ? parseFloat((s / r.length).toFixed(2)) : 0;
|
|
27
|
-
}, d = (e, t, n) => {
|
|
28
|
-
let r = [], a = t?.selectedTokens || [], s = e?.tokens || [];
|
|
29
|
-
if (a.length === 0) return r.push("Student did not select any token."), r;
|
|
30
|
-
r.push(`Student selected ${a.length} token(s).`);
|
|
31
|
-
let c = 0, l = 0, d = 0;
|
|
32
|
-
for (let e = 0; e < s.length; e++) {
|
|
33
|
-
let t = s[e];
|
|
34
|
-
t.correct && (c++, a.some((e) => o(t, e)) ? l++ : d++);
|
|
35
|
-
}
|
|
36
|
-
let f = a.length - l;
|
|
37
|
-
l > 0 && r.push(`${l} correct token(s) selected.`), f > 0 && r.push(`${f} incorrect token(s) selected.`), d > 0 && r.push(`${d} required correct token(s) were not selected.`);
|
|
38
|
-
let p = i.enabled(e, n, !0);
|
|
39
|
-
p ? (r.push("Score calculated using partial scoring."), r.push("Score is based on the number of correct minus incorrect selections, divided by the total number of correct tokens."), f > 0 && a.length > c && r.push("Extra selected tokens beyond the correct set reduce the score.")) : (r.push("Score calculated using all-or-nothing scoring."), r.push("Student must select all correct tokens and no incorrect tokens to receive full credit."));
|
|
40
|
-
let m = u(e, t, s.filter((e) => e.correct)), h = p ? m : +(m === 1);
|
|
41
|
-
return r.push(`Final score: ${h}.`), r;
|
|
42
|
-
}, f = (t, n, r) => new Promise((a) => {
|
|
43
|
-
if ((!n || e(n)) && a({
|
|
44
|
-
score: 0,
|
|
45
|
-
empty: !0,
|
|
46
|
-
logTrace: ["Student did not select any token."]
|
|
47
|
-
}), n = m(n), r.mode !== "evaluate") a({
|
|
48
|
-
score: void 0,
|
|
49
|
-
completed: void 0,
|
|
50
|
-
logTrace: []
|
|
51
|
-
});
|
|
52
|
-
else {
|
|
53
|
-
let e = i.enabled(t, r, !0), o = t.tokens.filter((e) => e.correct), s = u(t, n, o);
|
|
54
|
-
a({
|
|
55
|
-
score: e ? s : +(s === 1),
|
|
56
|
-
logTrace: d(t, n, r)
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
function p(e = {}) {
|
|
61
|
-
return new Promise((n) => {
|
|
62
|
-
n({
|
|
63
|
-
...t,
|
|
64
|
-
...e
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
var m = (e) => ({
|
|
69
|
-
selectedTokens: [],
|
|
70
|
-
...e
|
|
71
|
-
}), h = (e) => ({
|
|
72
|
-
...t,
|
|
73
|
-
...e
|
|
74
|
-
}), g = (e, t, n) => {
|
|
75
|
-
t ||= { selectedToken: [] }, t.selectedTokens = t.selectedTokens || [];
|
|
76
|
-
let i = h(e);
|
|
77
|
-
return new Promise((e) => {
|
|
78
|
-
a("[model]", "normalizedQuestion: ", i), a("[model]", "session: ", t);
|
|
79
|
-
let o = s(i.tokens, t.selectedTokens, n.mode === "evaluate");
|
|
80
|
-
a("[model] tokens:", o);
|
|
81
|
-
let l = n.mode === "evaluate" ? c(i.tokens, t.selectedTokens) : void 0;
|
|
82
|
-
(n.mode === "evaluate" && i.feedbackEnabled ? r(l, i.feedback) : Promise.resolve(void 0)).then((t) => {
|
|
83
|
-
let r = {
|
|
84
|
-
tokens: o,
|
|
85
|
-
highlightChoices: i.highlightChoices,
|
|
86
|
-
prompt: i.promptEnabled ? i.prompt : null,
|
|
87
|
-
text: i.text,
|
|
88
|
-
disabled: n.mode !== "gather",
|
|
89
|
-
maxSelections: i.maxSelections,
|
|
90
|
-
correctness: l,
|
|
91
|
-
env: n,
|
|
92
|
-
feedback: t,
|
|
93
|
-
incorrect: n.mode === "evaluate" ? l !== "correct" : void 0,
|
|
94
|
-
language: i.language,
|
|
95
|
-
extraCSSRules: i.extraCSSRules
|
|
96
|
-
};
|
|
97
|
-
n.role === "instructor" && (n.mode === "view" || n.mode === "evaluate") ? (r.rationale = i.rationaleEnabled ? i.rationale : null, r.teacherInstructions = i.teacherInstructionsEnabled ? i.teacherInstructions : null) : (r.rationale = null, r.teacherInstructions = null), e(r);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
}, _ = (e, t) => new Promise((n) => {
|
|
101
|
-
if (t.mode !== "evaluate" && t.role === "instructor") {
|
|
102
|
-
let { tokens: t } = e;
|
|
103
|
-
n({
|
|
104
|
-
id: "1",
|
|
105
|
-
selectedTokens: t.filter((e) => e.correct)
|
|
106
|
-
});
|
|
107
|
-
} else n(null);
|
|
108
|
-
}), v = (e) => (e || "").replace(/(<(?!img|iframe|source)([^>]+)>)/gi, ""), y = (e = {}, t = {}) => {
|
|
109
|
-
let { tokens: n } = e, { minTokens: r = 2, maxTokens: i, maxSelections: a } = t, o = {}, s = (n || []).length;
|
|
110
|
-
[
|
|
111
|
-
"teacherInstructions",
|
|
112
|
-
"prompt",
|
|
113
|
-
"rationale"
|
|
114
|
-
].forEach((n) => {
|
|
115
|
-
t[n]?.required && !v(e[n]) && (o[n] = "This field is required.");
|
|
116
|
-
});
|
|
117
|
-
let c = (n || []).reduce((e, t) => t.correct ? e + 1 : e, 0);
|
|
118
|
-
return s < r ? o.tokensError = `There should be at least ${r} tokens defined.` : s > i && (o.tokensError = `No more than ${i} tokens should be defined.`), c < 1 ? o.selectionsError = "There should be at least 1 token selected." : c > a && (o.selectionsError = `No more than ${a} tokens should be selected.`), o;
|
|
119
|
-
};
|
|
120
|
-
//#endregion
|
|
121
|
-
export { _ as createCorrectResponseSession, p as createDefaultModel, c as getCorrectness, d as getLogTrace, u as getPartialScore, g as model, h as normalize, m as normalizeSession, f as outcome, y as validate };
|
package/dist/delivery/index.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/select-text/src/index.js
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
export default class SelectText extends HTMLElement {
|
|
10
|
-
constructor();
|
|
11
|
-
set model(m: any);
|
|
12
|
-
set session(s: any);
|
|
13
|
-
get session(): any;
|
|
14
|
-
isSessionComplete(): boolean;
|
|
15
|
-
selectionChanged(selection: any): void;
|
|
16
|
-
connectedCallback(): void;
|
|
17
|
-
render(): void;
|
|
18
|
-
disconnectedCallback(): void;
|
|
19
|
-
}
|
package/dist/delivery/index.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import e from "./utils.js";
|
|
2
|
-
import t from "./main.js";
|
|
3
|
-
import n from "react";
|
|
4
|
-
import { createRoot as r } from "react-dom/client";
|
|
5
|
-
import { ModelSetEvent as i, SessionChangedEvent as a } from "@pie-element/shared-player-events";
|
|
6
|
-
import { renderMath as o } from "@pie-element/shared-math-rendering-mathjax";
|
|
7
|
-
//#region src/delivery/index.ts
|
|
8
|
-
var s = class extends HTMLElement {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(), this._root = null;
|
|
11
|
-
}
|
|
12
|
-
set model(e) {
|
|
13
|
-
this._model = e, this.render(), this.dispatchEvent(new i(this.tagName.toLowerCase(), this.isSessionComplete(), this._model !== void 0));
|
|
14
|
-
}
|
|
15
|
-
set session(t) {
|
|
16
|
-
if (this._session = t, this._model) {
|
|
17
|
-
let { tokens: n } = e(this._model) || {}, { selectedTokens: r } = t || {};
|
|
18
|
-
r ||= [];
|
|
19
|
-
let i = (e) => n.find(({ start: t, end: n }) => e.start === t && e.end === n);
|
|
20
|
-
if (!r.reduce((e, t) => e && i(t), !0)) {
|
|
21
|
-
let { tokens: t } = e({
|
|
22
|
-
...this._model,
|
|
23
|
-
tokens: r
|
|
24
|
-
}) || {};
|
|
25
|
-
t && (this._session.selectedTokens = t);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
Array.isArray(this._session.selectedTokens) || (this._session.selectedTokens = []), this.render();
|
|
29
|
-
}
|
|
30
|
-
get session() {
|
|
31
|
-
return this._session;
|
|
32
|
-
}
|
|
33
|
-
isSessionComplete() {
|
|
34
|
-
let { selectedTokens: e } = this._session || {};
|
|
35
|
-
return Array.isArray(e) && e.length > 0;
|
|
36
|
-
}
|
|
37
|
-
selectionChanged(e) {
|
|
38
|
-
this._session.selectedTokens = e, this.dispatchEvent(new a(this.tagName.toLowerCase(), this.isSessionComplete()));
|
|
39
|
-
}
|
|
40
|
-
connectedCallback() {
|
|
41
|
-
this.render();
|
|
42
|
-
}
|
|
43
|
-
render() {
|
|
44
|
-
if (this._model && this._session) {
|
|
45
|
-
let e = n.createElement(t, {
|
|
46
|
-
model: this._model,
|
|
47
|
-
session: this._session,
|
|
48
|
-
onSelectionChange: this.selectionChanged.bind(this)
|
|
49
|
-
});
|
|
50
|
-
this._root ||= r(this), this._root.render(e), queueMicrotask(() => {
|
|
51
|
-
o(this);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
disconnectedCallback() {
|
|
56
|
-
this._root && this._root.unmount();
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
//#endregion
|
|
60
|
-
export { s as default };
|
package/dist/delivery/main.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/select-text/src/main.jsx
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
export declare class Main extends React.Component {
|
|
12
|
-
static propTypes: {
|
|
13
|
-
model: PropTypes.Requireable<object>;
|
|
14
|
-
session: PropTypes.Requireable<object>;
|
|
15
|
-
onSelectionChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
16
|
-
};
|
|
17
|
-
static defaultProps: {};
|
|
18
|
-
constructor(props: any);
|
|
19
|
-
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
20
|
-
toggleShowCorrect: any;
|
|
21
|
-
correctAnswer: any;
|
|
22
|
-
render(): React.JSX.Element;
|
|
23
|
-
}
|
|
24
|
-
export default class Stateful extends React.Component {
|
|
25
|
-
static propTypes: {
|
|
26
|
-
model: PropTypes.Requireable<object>;
|
|
27
|
-
session: PropTypes.Requireable<object>;
|
|
28
|
-
onSelectionChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
29
|
-
};
|
|
30
|
-
constructor(props: any);
|
|
31
|
-
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
32
|
-
change: any;
|
|
33
|
-
render(): React.JSX.Element;
|
|
34
|
-
}
|
package/dist/delivery/main.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import e from "./utils.js";
|
|
2
|
-
import t from "react";
|
|
3
|
-
import n from "prop-types";
|
|
4
|
-
import { Legend as r, TextSelect as i } from "@pie-lib/text-select";
|
|
5
|
-
import a from "@pie-lib/correct-answer-toggle";
|
|
6
|
-
import * as o from "@pie-lib/render-ui";
|
|
7
|
-
import { Collapsible as s, Feedback as c, PreviewPrompt as l, UiLayout as u, color as d, hasMedia as f, hasText as p } from "@pie-lib/render-ui";
|
|
8
|
-
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
9
|
-
import { styled as g } from "@mui/material/styles";
|
|
10
|
-
import _ from "debug";
|
|
11
|
-
//#region src/delivery/main.tsx
|
|
12
|
-
function v(e) {
|
|
13
|
-
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
14
|
-
}
|
|
15
|
-
function y(e, t) {
|
|
16
|
-
return !e || v(e) ? e : v(e.default) ? e.default : t && v(e[t]) ? e[t] : t && v(e[t]?.default) ? e[t].default : e;
|
|
17
|
-
}
|
|
18
|
-
var b = y(u, "UiLayout") || y(E.UiLayout, "UiLayout"), x = y(l, "PreviewPrompt") || y(E.PreviewPrompt, "PreviewPrompt"), S = y(s, "Collapsible") || y(E.Collapsible, "Collapsible"), C = y(c, "Feedback") || y(E.Feedback, "Feedback"), w = o, T = w.default, E = T && typeof T == "object" ? T : w, D = _("@pie-ui:select-text"), O = g(b)({
|
|
19
|
-
color: d.text(),
|
|
20
|
-
backgroundColor: d.background()
|
|
21
|
-
}), k = g(i)(({ theme: e }) => ({
|
|
22
|
-
marginBottom: e.spacing(1),
|
|
23
|
-
marginTop: e.spacing(2),
|
|
24
|
-
whiteSpace: "normal"
|
|
25
|
-
})), A = g("div")(({ theme: e }) => ({
|
|
26
|
-
verticalAlign: "middle",
|
|
27
|
-
marginBottom: e.spacing(1)
|
|
28
|
-
})), j = g(S)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), M = {
|
|
29
|
-
model: n.object,
|
|
30
|
-
session: n.object,
|
|
31
|
-
onSelectionChange: n.func.isRequired
|
|
32
|
-
}, N = class extends t.Component {
|
|
33
|
-
static propTypes = M;
|
|
34
|
-
static defaultProps = {};
|
|
35
|
-
constructor(t) {
|
|
36
|
-
super(t), this.state = {
|
|
37
|
-
showCorrectAnswer: this.props.model.alwaysShowCorrect || !1,
|
|
38
|
-
model: e(t.model)
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
UNSAFE_componentWillReceiveProps(t) {
|
|
42
|
-
this.setState({
|
|
43
|
-
showCorrectAnswer: !!t.model.alwaysShowCorrect,
|
|
44
|
-
model: e(t.model)
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
toggleShowCorrect = () => {
|
|
48
|
-
this.setState({ showCorrectAnswer: !this.state.showCorrectAnswer });
|
|
49
|
-
};
|
|
50
|
-
correctAnswer = () => {
|
|
51
|
-
let { model: e } = this.state;
|
|
52
|
-
return e.tokens.filter((e) => e.correct);
|
|
53
|
-
};
|
|
54
|
-
render() {
|
|
55
|
-
let { session: e, onSelectionChange: t } = this.props, { showCorrectAnswer: n, model: i } = this.state, { env: o, extraCSSRules: s } = i, { mode: c } = o || {}, l = n ? this.correctAnswer() : e.selectedTokens, u = i.rationale && (p(i.rationale) || f(i.rationale)), d = i.teacherInstructions && (p(i.teacherInstructions) || f(i.teacherInstructions));
|
|
56
|
-
return D("[render] selectedTokens:", l), /* @__PURE__ */ h(O, {
|
|
57
|
-
extraCSSRules: s,
|
|
58
|
-
children: [
|
|
59
|
-
d && (i.animationsDisabled ? /* @__PURE__ */ m(A, { children: /* @__PURE__ */ m(x, { prompt: i.teacherInstructions }) }) : /* @__PURE__ */ m(j, {
|
|
60
|
-
labels: {
|
|
61
|
-
hidden: "Show Teacher Instructions",
|
|
62
|
-
visible: "Hide Teacher Instructions"
|
|
63
|
-
},
|
|
64
|
-
children: /* @__PURE__ */ m(x, { prompt: i.teacherInstructions })
|
|
65
|
-
})),
|
|
66
|
-
/* @__PURE__ */ m(A, { children: /* @__PURE__ */ m(x, { prompt: i.prompt }) }),
|
|
67
|
-
!i.alwaysShowCorrect && /* @__PURE__ */ m(a, {
|
|
68
|
-
show: i.disabled && i.incorrect,
|
|
69
|
-
toggled: n,
|
|
70
|
-
onToggle: this.toggleShowCorrect,
|
|
71
|
-
language: i.language
|
|
72
|
-
}),
|
|
73
|
-
/* @__PURE__ */ m(k, {
|
|
74
|
-
disabled: i.disabled,
|
|
75
|
-
text: i.text,
|
|
76
|
-
tokens: i.tokens,
|
|
77
|
-
selectedTokens: l,
|
|
78
|
-
onChange: (e) => {
|
|
79
|
-
t(e.map((e) => i.tokens.find(({ start: t, end: n }) => e.start === t && e.end === n) || e));
|
|
80
|
-
},
|
|
81
|
-
highlightChoices: i.highlightChoices,
|
|
82
|
-
maxNoOfSelections: i.maxSelections,
|
|
83
|
-
animationsDisabled: i.animationsDisabled
|
|
84
|
-
}),
|
|
85
|
-
c === "evaluate" && /* @__PURE__ */ m(r, {
|
|
86
|
-
language: i.language,
|
|
87
|
-
showOnlyCorrect: n
|
|
88
|
-
}),
|
|
89
|
-
u && (i.animationsDisabled ? /* @__PURE__ */ m(A, { children: /* @__PURE__ */ m(x, { prompt: i.rationale }) }) : /* @__PURE__ */ m(j, {
|
|
90
|
-
labels: {
|
|
91
|
-
hidden: "Show Rationale",
|
|
92
|
-
visible: "Hide Rationale"
|
|
93
|
-
},
|
|
94
|
-
children: /* @__PURE__ */ m(x, { prompt: i.rationale })
|
|
95
|
-
})),
|
|
96
|
-
i.correctness && i.feedback && !n && /* @__PURE__ */ m(C, {
|
|
97
|
-
correctness: i.correctness,
|
|
98
|
-
feedback: i.feedback
|
|
99
|
-
})
|
|
100
|
-
]
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}, P = class extends t.Component {
|
|
104
|
-
static propTypes = M;
|
|
105
|
-
constructor(e) {
|
|
106
|
-
super(e), this.state = {
|
|
107
|
-
model: e.model,
|
|
108
|
-
session: e.session
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
UNSAFE_componentWillReceiveProps(e) {
|
|
112
|
-
this.setState({
|
|
113
|
-
model: e.model,
|
|
114
|
-
session: e.session
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
change = (e) => {
|
|
118
|
-
let t = {
|
|
119
|
-
...this.state.session,
|
|
120
|
-
selectedTokens: e
|
|
121
|
-
};
|
|
122
|
-
this.setState({ session: t }, () => {
|
|
123
|
-
this.props.onSelectionChange(this.state.session.selectedTokens);
|
|
124
|
-
});
|
|
125
|
-
};
|
|
126
|
-
render() {
|
|
127
|
-
let { model: e, session: t } = this.state;
|
|
128
|
-
return /* @__PURE__ */ m(N, {
|
|
129
|
-
model: e,
|
|
130
|
-
session: t,
|
|
131
|
-
onSelectionChange: this.change
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
//#endregion
|
|
136
|
-
export { P as default };
|
package/dist/delivery/utils.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/select-text/src/utils.js
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
declare const _default: (model: any) => any;
|
|
10
|
-
export default _default;
|
package/dist/delivery/utils.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
//#region src/delivery/utils.tsx
|
|
2
|
-
var e = function() {
|
|
3
|
-
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", t = document.createElement("div");
|
|
4
|
-
return t.innerHTML = e.trim(), t;
|
|
5
|
-
}, t = function(e, t) {
|
|
6
|
-
return t ? e.innerHTML : `${e.innerHTML}
|
|
7
|
-
|
|
8
|
-
`;
|
|
9
|
-
}, n = function(e) {
|
|
10
|
-
var n = e.querySelectorAll("div[separator=true]"), r = "";
|
|
11
|
-
return n.forEach(function(e, i) {
|
|
12
|
-
r += t(e, i === n.length - 1);
|
|
13
|
-
}), r || null;
|
|
14
|
-
}, r = function(t) {
|
|
15
|
-
var r = e(t), i = document.createElement("div");
|
|
16
|
-
return i.innerHTML = `<div separator='true'>${r.innerHTML}</div>`, r = i, Array.from(r.querySelectorAll("*")).length === 0 ? t : n(r);
|
|
17
|
-
}, i = (e) => {
|
|
18
|
-
if (!e) return e;
|
|
19
|
-
let t = r(e.text || ""), n = (e.tokens || []).reduce((n, i = {}) => {
|
|
20
|
-
let a = r((e.text || "").slice(i.start, i.end));
|
|
21
|
-
if (!a) return [...n, i];
|
|
22
|
-
let o = (e) => {
|
|
23
|
-
let n = e;
|
|
24
|
-
for (; n >= 0;) {
|
|
25
|
-
let e = t.slice(n).indexOf(a);
|
|
26
|
-
if (e >= 0) return e + n;
|
|
27
|
-
n--;
|
|
28
|
-
}
|
|
29
|
-
return 0;
|
|
30
|
-
}, s = n[n.length - 1], c = o(s ? s.end : i.start), l = c + a.length;
|
|
31
|
-
return [...n, {
|
|
32
|
-
...i,
|
|
33
|
-
text: a,
|
|
34
|
-
start: c,
|
|
35
|
-
end: l,
|
|
36
|
-
oldStart: i.start,
|
|
37
|
-
oldEnd: i.end
|
|
38
|
-
}];
|
|
39
|
-
}, []);
|
|
40
|
-
return {
|
|
41
|
-
...e,
|
|
42
|
-
tokens: n,
|
|
43
|
-
text: t
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
//#endregion
|
|
47
|
-
export { i as default };
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './delivery/index.js';
|
package/dist/index.iife.d.ts
DELETED