@pie-element/multiple-choice 13.1.0 → 13.1.1-next.0
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/dist/author/defaults.d.ts +206 -0
- package/dist/author/defaults.d.ts.map +1 -0
- package/dist/author/defaults.js +151 -0
- package/dist/author/index.d.ts +27 -0
- package/dist/author/index.d.ts.map +1 -0
- package/dist/author/index.js +116 -0
- package/dist/author/main.d.ts +35 -0
- package/dist/author/main.d.ts.map +1 -0
- package/dist/author/main.js +290 -0
- package/dist/author/utils.d.ts +10 -0
- package/dist/author/utils.d.ts.map +1 -0
- package/dist/author/utils.js +7 -0
- package/dist/controller/defaults.d.ts +36 -0
- package/dist/controller/defaults.d.ts.map +1 -0
- package/dist/controller/defaults.js +29 -0
- package/dist/controller/index.d.ts +66 -0
- package/dist/controller/index.d.ts.map +1 -0
- package/dist/controller/index.js +124 -0
- package/dist/controller/utils.d.ts +11 -0
- package/dist/controller/utils.d.ts.map +1 -0
- package/dist/controller/utils.js +8 -0
- package/dist/delivery/choice-input.d.ts +45 -0
- package/dist/delivery/choice-input.d.ts.map +1 -0
- package/dist/delivery/choice-input.js +274 -0
- package/dist/delivery/choice.d.ts +21 -0
- package/dist/delivery/choice.d.ts.map +1 -0
- package/dist/delivery/choice.js +109 -0
- package/dist/delivery/feedback-tick.d.ts +21 -0
- package/dist/delivery/feedback-tick.d.ts.map +1 -0
- package/dist/delivery/feedback-tick.js +104 -0
- package/dist/delivery/index.d.ts +38 -0
- package/dist/delivery/index.d.ts.map +1 -0
- package/dist/delivery/index.js +217 -0
- package/dist/delivery/main.d.ts +32 -0
- package/dist/delivery/main.d.ts.map +1 -0
- package/dist/delivery/main.js +51 -0
- package/dist/delivery/multiple-choice.d.ts +63 -0
- package/dist/delivery/multiple-choice.d.ts.map +1 -0
- package/dist/delivery/multiple-choice.js +252 -0
- package/dist/delivery/session-updater.d.ts +11 -0
- package/dist/delivery/session-updater.d.ts.map +1 -0
- package/dist/delivery/session-updater.js +9 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.iife.d.ts +9 -0
- package/dist/index.iife.d.ts.map +1 -0
- package/dist/index.iife.js +148 -0
- package/dist/index.js +2 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Hash.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_ListCache.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Map.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_MapCache.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Set.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_SetCache.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Stack.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Symbol.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_apply.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arraySome.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignMergeValue.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assocIndexOf.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignValue.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js +57 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseFor.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetTag.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsArguments.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqual.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqualDeep.js +30 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsNative.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeysIn.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseMerge.js +19 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseMergeDeep.js +31 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseRest.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseSetToString.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTrim.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseUnary.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cacheHas.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneArrayBuffer.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_coreJsData.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_createAssigner.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_createBaseFor.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalArrays.js +35 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalByTag.js +35 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalObjects.js +32 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_freeGlobal.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getMapData.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getNative.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getRawTag.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js +23 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getValue.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashClear.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashDelete.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashGet.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashHas.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashSet.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js +33 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIterateeCall.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKeyable.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isMasked.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheClear.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheDelete.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheGet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheHas.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheSet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheClear.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheDelete.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheGet.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheHas.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheSet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapToArray.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeCreate.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_objectToString.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overRest.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_root.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_safeGet.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setCacheAdd.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setCacheHas.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToArray.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToString.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_shortOut.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackClear.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackDelete.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackGet.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackHas.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackSet.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toSource.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_trimmedEndIndex.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/constant.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/debounce.js +50 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/defaults.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/eq.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/identity.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArray.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLikeObject.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEmpty.js +21 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEqual.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isFunction.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isLength.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isMap.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObject.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isPlainObject.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSet.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSymbol.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isTypedArray.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/merge.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/now.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toNumber.js +19 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toPlainObject.js +8 -0
- package/dist/print/index.d.ts +16 -0
- package/dist/print/index.d.ts.map +1 -0
- package/dist/print/index.js +44 -0
- package/package.json +58 -26
- package/{configure/lib/defaults.js → src/author/defaults.ts} +55 -90
- package/{configure/lib/index.js → src/author/index.ts} +98 -51
- package/src/author/main.tsx +509 -0
- package/src/author/utils.ts +25 -0
- package/{controller/lib/defaults.js → src/controller/defaults.ts} +11 -8
- package/{controller/lib/index.js → src/controller/index.ts} +123 -109
- package/src/controller/utils.ts +22 -0
- package/src/delivery/choice-input.tsx +413 -0
- package/src/delivery/choice.tsx +203 -0
- package/src/delivery/feedback-tick.tsx +156 -0
- package/{lib/index.js → src/delivery/index.ts} +211 -129
- package/src/delivery/main.tsx +85 -0
- package/src/delivery/multiple-choice.tsx +485 -0
- package/{lib/session-updater.js → src/delivery/session-updater.ts} +17 -13
- package/src/index.iife.ts +16 -0
- package/src/index.ts +1 -0
- package/src/print/index.tsx +112 -0
- package/CHANGELOG.json +0 -1972
- package/CHANGELOG.md +0 -2696
- package/LICENSE.md +0 -5
- package/PRINT.md +0 -35
- package/README.md +0 -56
- package/choice.png +0 -0
- package/configure/CHANGELOG.json +0 -1387
- package/configure/CHANGELOG.md +0 -2046
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/main.js +0 -477
- package/configure/lib/main.js.map +0 -1
- package/configure/lib/utils.js +0 -18
- package/configure/lib/utils.js.map +0 -1
- package/configure/package.json +0 -22
- package/controller/CHANGELOG.json +0 -527
- package/controller/CHANGELOG.md +0 -1388
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js.map +0 -1
- package/controller/lib/utils.js +0 -15
- package/controller/lib/utils.js.map +0 -1
- package/controller/package.json +0 -15
- package/docs/config-schema.json +0 -2993
- package/docs/config-schema.json.md +0 -2217
- package/docs/demo/config.js +0 -8
- package/docs/demo/generate.js +0 -61
- package/docs/demo/index.html +0 -1
- package/docs/demo/session.js +0 -7
- package/docs/pie-schema.json +0 -1332
- package/docs/pie-schema.json.md +0 -1015
- package/lib/choice-input.js +0 -380
- package/lib/choice-input.js.map +0 -1
- package/lib/choice.js +0 -197
- package/lib/choice.js.map +0 -1
- package/lib/feedback-tick.js +0 -134
- package/lib/feedback-tick.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/main.js +0 -63
- package/lib/main.js.map +0 -1
- package/lib/multiple-choice.js +0 -412
- package/lib/multiple-choice.js.map +0 -1
- package/lib/print.js +0 -94
- package/lib/print.js.map +0 -1
- package/lib/session-updater.js.map +0 -1
- package/module/configure.js +0 -1
- package/module/controller.js +0 -3045
- package/module/demo.js +0 -86
- package/module/element.js +0 -1
- package/module/index.html +0 -21
- package/module/manifest.json +0 -14
- package/module/print-demo.js +0 -124
- package/module/print.html +0 -18
- package/module/print.js +0 -1
|
@@ -1,26 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/multiple-choice/src/index.js
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import Main from './main.js';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { createRoot } from 'react-dom/client';
|
|
14
|
+
import { debounce } from 'lodash-es';
|
|
15
|
+
import debug from 'debug';
|
|
16
|
+
import { ModelSetEvent, SessionChangedEvent } from '@pie-element/shared-player-events';
|
|
17
|
+
import { renderMath } from '@pie-element/shared-math-rendering-mathjax';
|
|
18
|
+
import { EnableAudioAutoplayImage as EnableAudioAutoplayImageImport } from '@pie-lib/render-ui';
|
|
19
|
+
|
|
20
|
+
function isRenderableReactInteropType(value: any) {
|
|
21
|
+
return (
|
|
22
|
+
typeof value === 'function' ||
|
|
23
|
+
(typeof value === 'object' && value !== null && typeof value.$$typeof === 'symbol')
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function unwrapReactInteropSymbol(maybeSymbol: any, namedExport?: string) {
|
|
28
|
+
if (!maybeSymbol) return maybeSymbol;
|
|
29
|
+
if (isRenderableReactInteropType(maybeSymbol)) return maybeSymbol;
|
|
30
|
+
if (isRenderableReactInteropType(maybeSymbol.default)) return maybeSymbol.default;
|
|
31
|
+
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport])) {
|
|
32
|
+
return maybeSymbol[namedExport];
|
|
33
|
+
}
|
|
34
|
+
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport]?.default)) {
|
|
35
|
+
return maybeSymbol[namedExport].default;
|
|
36
|
+
}
|
|
37
|
+
return maybeSymbol;
|
|
38
|
+
}
|
|
39
|
+
const EnableAudioAutoplayImage = unwrapReactInteropSymbol(EnableAudioAutoplayImageImport, 'EnableAudioAutoplayImage') || unwrapReactInteropSymbol(renderUi.EnableAudioAutoplayImage, 'EnableAudioAutoplayImage');
|
|
40
|
+
import * as RenderUiNamespace from '@pie-lib/render-ui';
|
|
41
|
+
const renderUiNamespaceAny = RenderUiNamespace as any;
|
|
42
|
+
const renderUiDefaultMaybe = renderUiNamespaceAny['default'];
|
|
43
|
+
const renderUi =
|
|
44
|
+
renderUiDefaultMaybe && typeof renderUiDefaultMaybe === 'object'
|
|
45
|
+
? renderUiDefaultMaybe
|
|
46
|
+
: renderUiNamespaceAny;
|
|
47
|
+
import { updateSessionValue, updateSessionMetadata } from './session-updater.js';
|
|
48
|
+
|
|
49
|
+
const log = debug('pie-ui:multiple-choice');
|
|
50
|
+
|
|
51
|
+
export const isComplete = (session, model, audioComplete, elementContext) => {
|
|
52
|
+
const { autoplayAudioEnabled, completeAudioEnabled } = model || {};
|
|
24
53
|
|
|
25
54
|
// check audio completion if audio settings are enabled and audio actually exists
|
|
26
55
|
if (autoplayAudioEnabled && completeAudioEnabled && !audioComplete) {
|
|
@@ -34,89 +63,73 @@ const isComplete = (session, model, audioComplete, elementContext) => {
|
|
|
34
63
|
}
|
|
35
64
|
}
|
|
36
65
|
}
|
|
66
|
+
|
|
37
67
|
if (!session || !session.value) {
|
|
38
68
|
return false;
|
|
39
69
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
minSelections = 1,
|
|
43
|
-
maxSelections
|
|
44
|
-
} = model || {};
|
|
70
|
+
|
|
71
|
+
const { choiceMode, minSelections = 1, maxSelections } = model || {};
|
|
45
72
|
const selections = session.value.length || 0;
|
|
73
|
+
|
|
46
74
|
if (choiceMode === 'radio') {
|
|
47
75
|
return !!selections;
|
|
48
76
|
}
|
|
77
|
+
|
|
49
78
|
if (selections < minSelections || selections > maxSelections) {
|
|
50
79
|
return false;
|
|
51
80
|
}
|
|
81
|
+
|
|
52
82
|
return true;
|
|
53
83
|
};
|
|
54
|
-
|
|
84
|
+
|
|
55
85
|
function getPlayerAttributes(element) {
|
|
56
|
-
const player =
|
|
86
|
+
const player =
|
|
87
|
+
element.closest('pie-player') ||
|
|
88
|
+
element.closest('pie-item-player');
|
|
89
|
+
|
|
57
90
|
if (!player) {
|
|
58
|
-
return {
|
|
59
|
-
baseHeadingLevel: undefined,
|
|
60
|
-
includeSrHeading: true
|
|
61
|
-
};
|
|
91
|
+
return { baseHeadingLevel: undefined, includeSrHeading: true };
|
|
62
92
|
}
|
|
93
|
+
|
|
63
94
|
const getRaw = (camelCaseName, hyphenatedName, allLowerName) => {
|
|
64
95
|
let raw = player[camelCaseName];
|
|
65
96
|
|
|
66
97
|
// fallback in case someone sets via HTML attribute manually
|
|
67
98
|
if (raw == null) {
|
|
68
|
-
raw =
|
|
99
|
+
raw =
|
|
100
|
+
player.getAttribute(hyphenatedName) ??
|
|
101
|
+
player.getAttribute(allLowerName);
|
|
69
102
|
}
|
|
103
|
+
|
|
70
104
|
return raw;
|
|
71
105
|
};
|
|
106
|
+
|
|
72
107
|
const levelRaw = getRaw('baseHeadingLevel', 'base-heading-level', 'baseheadinglevel');
|
|
73
108
|
const level = parseInt(levelRaw, 10);
|
|
74
109
|
const baseHeadingLevel = Number.isFinite(level) && level >= 1 && level <= 6 ? level : undefined;
|
|
110
|
+
|
|
75
111
|
const srRaw = getRaw('includeSrHeading', 'include-sr-heading', 'includesrheading');
|
|
76
112
|
const includeSrHeading = srRaw == null ? true : srRaw !== false && srRaw !== 'false';
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
});
|
|
81
|
-
return {
|
|
82
|
-
baseHeadingLevel,
|
|
83
|
-
includeSrHeading
|
|
84
|
-
};
|
|
113
|
+
|
|
114
|
+
console.log('getPlayerAttributes', { baseHeadingLevel, includeSrHeading });
|
|
115
|
+
return { baseHeadingLevel, includeSrHeading };
|
|
85
116
|
}
|
|
86
117
|
|
|
87
118
|
// Resolves heading attributes for a custom element, preferring explicit instance
|
|
88
119
|
// properties (set by a parent element such as EBSR) over player-level attributes.
|
|
89
120
|
function resolveHeadingProps(element) {
|
|
90
121
|
const fromPlayer = getPlayerAttributes(element);
|
|
122
|
+
|
|
91
123
|
console.log('element._baseHeadingLevel', element._baseHeadingLevel, 'element._includeSrHeading', element._includeSrHeading);
|
|
92
124
|
return {
|
|
93
125
|
baseHeadingLevel: element._baseHeadingLevel !== undefined ? element._baseHeadingLevel : fromPlayer.baseHeadingLevel,
|
|
94
|
-
includeSrHeading: element._includeSrHeading !== undefined ? element._includeSrHeading : fromPlayer.includeSrHeading
|
|
126
|
+
includeSrHeading: element._includeSrHeading !== undefined ? element._includeSrHeading : fromPlayer.includeSrHeading,
|
|
95
127
|
};
|
|
96
128
|
}
|
|
97
|
-
|
|
129
|
+
|
|
130
|
+
export default class MultipleChoice extends HTMLElement {
|
|
98
131
|
constructor() {
|
|
99
132
|
super();
|
|
100
|
-
(0, _defineProperty2.default)(this, "_scheduleMathRender", () => {
|
|
101
|
-
if (this._mathRenderPending) return;
|
|
102
|
-
this._mathRenderPending = true;
|
|
103
|
-
requestAnimationFrame(() => {
|
|
104
|
-
if (this._mathObserver) {
|
|
105
|
-
this._mathObserver.disconnect();
|
|
106
|
-
}
|
|
107
|
-
log('render complete - render math');
|
|
108
|
-
(0, _mathRendering.renderMath)(this);
|
|
109
|
-
this._mathRenderPending = false;
|
|
110
|
-
setTimeout(() => {
|
|
111
|
-
if (this._mathObserver) {
|
|
112
|
-
this._mathObserver.observe(this, {
|
|
113
|
-
childList: true,
|
|
114
|
-
subtree: true
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}, 50);
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
133
|
this._model = null;
|
|
121
134
|
this._session = null;
|
|
122
135
|
this._options = null; // added for ebsr print mode detection
|
|
@@ -127,68 +140,111 @@ class MultipleChoice extends HTMLElement {
|
|
|
127
140
|
this._root = null;
|
|
128
141
|
this._mathObserver = null;
|
|
129
142
|
this._mathRenderPending = false;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
this.
|
|
143
|
+
|
|
144
|
+
this._rerender = debounce(
|
|
145
|
+
() => {
|
|
146
|
+
if (this._model && this._session) {
|
|
147
|
+
var element = React.createElement(Main, {
|
|
148
|
+
model: this._model,
|
|
149
|
+
session: this._session,
|
|
150
|
+
options: this._options,
|
|
151
|
+
onChoiceChanged: this._onChange.bind(this),
|
|
152
|
+
onShowCorrectToggle: this.onShowCorrectToggle.bind(this),
|
|
153
|
+
...resolveHeadingProps(this),
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
//TODO: aria-label is set in the _rerender because we need to change it when the model.choiceMode is updated. Consider revisiting the placement of the aria-label setting in the _rerender
|
|
157
|
+
this.setAttribute(
|
|
158
|
+
'aria-label',
|
|
159
|
+
this._model.choiceMode === 'radio' ? 'Multiple Choice Question' : 'Multiple Correct Answer Question',
|
|
160
|
+
);
|
|
161
|
+
this.setAttribute('role', 'region');
|
|
162
|
+
this.setLangAttribute();
|
|
163
|
+
|
|
164
|
+
this._initMathObserver();
|
|
165
|
+
|
|
166
|
+
if (!this._root) {
|
|
167
|
+
this._root = createRoot(this);
|
|
168
|
+
}
|
|
169
|
+
this._root.render(element);
|
|
170
|
+
|
|
171
|
+
if (this._model.keyboardEventsEnabled === true && !this._keyboardEventsEnabled) {
|
|
172
|
+
this.enableKeyboardEvents();
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
log('skip');
|
|
152
176
|
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}, 50, {
|
|
166
|
-
leading: false,
|
|
167
|
-
trailing: true
|
|
177
|
+
},
|
|
178
|
+
50,
|
|
179
|
+
{ leading: false, trailing: true },
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
this._dispatchResponseChanged = debounce(() => {
|
|
183
|
+
this.dispatchEvent(
|
|
184
|
+
new SessionChangedEvent(
|
|
185
|
+
this.tagName.toLowerCase(),
|
|
186
|
+
isComplete(this._session, this._model, this.audioComplete, this),
|
|
187
|
+
),
|
|
188
|
+
);
|
|
168
189
|
});
|
|
190
|
+
|
|
191
|
+
this._dispatchModelSet = debounce(
|
|
192
|
+
() => {
|
|
193
|
+
this.dispatchEvent(
|
|
194
|
+
new ModelSetEvent(
|
|
195
|
+
this.tagName.toLowerCase(),
|
|
196
|
+
isComplete(this._session, this._model, this.audioComplete, this),
|
|
197
|
+
this._model !== undefined,
|
|
198
|
+
),
|
|
199
|
+
);
|
|
200
|
+
},
|
|
201
|
+
50,
|
|
202
|
+
{ leading: false, trailing: true },
|
|
203
|
+
);
|
|
169
204
|
}
|
|
205
|
+
|
|
206
|
+
_scheduleMathRender: any = () => {
|
|
207
|
+
if (this._mathRenderPending) return;
|
|
208
|
+
this._mathRenderPending = true;
|
|
209
|
+
|
|
210
|
+
requestAnimationFrame(() => {
|
|
211
|
+
if (this._mathObserver) {
|
|
212
|
+
this._mathObserver.disconnect();
|
|
213
|
+
}
|
|
214
|
+
log('render complete - render math');
|
|
215
|
+
renderMath(this);
|
|
216
|
+
this._mathRenderPending = false;
|
|
217
|
+
setTimeout(() => {
|
|
218
|
+
if (this._mathObserver) {
|
|
219
|
+
this._mathObserver.observe(this, { childList: true, subtree: true });
|
|
220
|
+
}
|
|
221
|
+
}, 50);
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
|
|
170
225
|
_initMathObserver() {
|
|
171
226
|
if (this._mathObserver) return;
|
|
172
227
|
this._mathObserver = new MutationObserver(this._scheduleMathRender);
|
|
173
|
-
this._mathObserver.observe(this, {
|
|
174
|
-
childList: true,
|
|
175
|
-
subtree: true
|
|
176
|
-
});
|
|
228
|
+
this._mathObserver.observe(this, { childList: true, subtree: true });
|
|
177
229
|
}
|
|
230
|
+
|
|
178
231
|
_disconnectMathObserver() {
|
|
179
232
|
if (this._mathObserver) {
|
|
180
233
|
this._mathObserver.disconnect();
|
|
181
234
|
this._mathObserver = null;
|
|
182
235
|
}
|
|
183
236
|
}
|
|
237
|
+
|
|
184
238
|
onShowCorrectToggle() {
|
|
185
|
-
|
|
239
|
+
renderMath(this);
|
|
186
240
|
}
|
|
241
|
+
|
|
187
242
|
setLangAttribute() {
|
|
188
243
|
const language = this._model && typeof this._model.language ? this._model.language : '';
|
|
189
244
|
const lang = language ? language.slice(0, 2) : 'en';
|
|
190
245
|
this.setAttribute('lang', lang);
|
|
191
246
|
}
|
|
247
|
+
|
|
192
248
|
set model(s) {
|
|
193
249
|
this._model = s;
|
|
194
250
|
this._rerender();
|
|
@@ -196,38 +252,47 @@ class MultipleChoice extends HTMLElement {
|
|
|
196
252
|
this._audioInitialized = false;
|
|
197
253
|
this._dispatchModelSet();
|
|
198
254
|
}
|
|
255
|
+
|
|
199
256
|
get session() {
|
|
200
257
|
return this._session;
|
|
201
258
|
}
|
|
259
|
+
|
|
202
260
|
get options() {
|
|
203
261
|
return this._options;
|
|
204
262
|
}
|
|
263
|
+
|
|
205
264
|
set options(o) {
|
|
206
265
|
this._options = o;
|
|
207
266
|
this._rerender();
|
|
208
267
|
}
|
|
268
|
+
|
|
209
269
|
set baseHeadingLevel(level) {
|
|
210
270
|
this._baseHeadingLevel = level;
|
|
211
271
|
this._rerender();
|
|
212
272
|
}
|
|
273
|
+
|
|
213
274
|
set includeSrHeading(value) {
|
|
214
275
|
this._includeSrHeading = value;
|
|
215
276
|
this._rerender();
|
|
216
277
|
}
|
|
278
|
+
|
|
217
279
|
set session(s) {
|
|
218
280
|
this._session = s;
|
|
219
281
|
this._rerender();
|
|
220
282
|
//TODO: remove this session-changed should only be emit on user change
|
|
221
283
|
this._dispatchResponseChanged();
|
|
222
284
|
}
|
|
285
|
+
|
|
223
286
|
_onChange(data) {
|
|
224
|
-
|
|
287
|
+
updateSessionValue(this._session, this._model.choiceMode, data);
|
|
225
288
|
this._dispatchResponseChanged();
|
|
226
289
|
this._rerender();
|
|
227
290
|
}
|
|
291
|
+
|
|
228
292
|
_createAudioInfoToast() {
|
|
229
293
|
const info = document.createElement('div');
|
|
230
294
|
info.id = 'play-audio-info';
|
|
295
|
+
|
|
231
296
|
Object.assign(info.style, {
|
|
232
297
|
position: 'absolute',
|
|
233
298
|
top: 0,
|
|
@@ -238,16 +303,19 @@ class MultipleChoice extends HTMLElement {
|
|
|
238
303
|
alignItems: 'center',
|
|
239
304
|
background: 'white',
|
|
240
305
|
zIndex: '1000',
|
|
241
|
-
cursor: 'pointer'
|
|
306
|
+
cursor: 'pointer',
|
|
242
307
|
});
|
|
308
|
+
|
|
243
309
|
const img = document.createElement('img');
|
|
244
|
-
img.src =
|
|
310
|
+
img.src = EnableAudioAutoplayImage;
|
|
245
311
|
img.alt = 'Click anywhere to enable audio autoplay';
|
|
246
312
|
img.width = 500;
|
|
247
313
|
img.height = 300;
|
|
314
|
+
|
|
248
315
|
info.appendChild(img);
|
|
249
316
|
return info;
|
|
250
317
|
}
|
|
318
|
+
|
|
251
319
|
connectedCallback() {
|
|
252
320
|
this._initMathObserver();
|
|
253
321
|
this._initPlayerObserver();
|
|
@@ -257,15 +325,18 @@ class MultipleChoice extends HTMLElement {
|
|
|
257
325
|
// while other browsers will not have the autoplay attribute and will need a user interaction to play the audio
|
|
258
326
|
// This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox
|
|
259
327
|
const observer = new MutationObserver((mutationsList, observer) => {
|
|
260
|
-
mutationsList.forEach(mutation => {
|
|
328
|
+
mutationsList.forEach((mutation) => {
|
|
261
329
|
if (mutation.type === 'childList') {
|
|
262
330
|
if (this._audioInitialized) return;
|
|
331
|
+
|
|
263
332
|
const audio = this.querySelector('audio');
|
|
264
333
|
const isInsidePrompt = audio && audio.closest('#preview-prompt');
|
|
334
|
+
|
|
265
335
|
if (!this._model) return;
|
|
266
336
|
if (!this._model.autoplayAudioEnabled) return;
|
|
267
337
|
if (audio && !isInsidePrompt) return;
|
|
268
338
|
if (!audio) return;
|
|
339
|
+
|
|
269
340
|
const info = this._createAudioInfoToast();
|
|
270
341
|
const container = this.querySelector('#main-container');
|
|
271
342
|
const enableAudio = () => {
|
|
@@ -273,6 +344,7 @@ class MultipleChoice extends HTMLElement {
|
|
|
273
344
|
audio.play();
|
|
274
345
|
container.removeChild(info);
|
|
275
346
|
}
|
|
347
|
+
|
|
276
348
|
document.removeEventListener('click', enableAudio);
|
|
277
349
|
};
|
|
278
350
|
|
|
@@ -290,26 +362,26 @@ class MultipleChoice extends HTMLElement {
|
|
|
290
362
|
|
|
291
363
|
// we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering
|
|
292
364
|
const handlePlaying = () => {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
});
|
|
365
|
+
updateSessionMetadata(this._session, { audioStartTime: new Date().getTime() });
|
|
366
|
+
|
|
296
367
|
const info = this.querySelector('#play-audio-info');
|
|
297
368
|
if (info) {
|
|
298
369
|
container.removeChild(info);
|
|
299
370
|
}
|
|
371
|
+
|
|
300
372
|
audio.removeEventListener('playing', handlePlaying);
|
|
301
373
|
};
|
|
374
|
+
|
|
302
375
|
audio.addEventListener('playing', handlePlaying);
|
|
303
376
|
|
|
304
377
|
// we need to listen for the ended event to update the isComplete state
|
|
305
378
|
const handleEnded = () => {
|
|
306
|
-
|
|
307
|
-
audioEndTime: new Date().getTime()
|
|
308
|
-
});
|
|
379
|
+
updateSessionMetadata(this._session, { audioEndTime: new Date().getTime() });
|
|
309
380
|
this.audioComplete = true;
|
|
310
381
|
this._dispatchResponseChanged();
|
|
311
382
|
audio.removeEventListener('ended', handleEnded);
|
|
312
383
|
};
|
|
384
|
+
|
|
313
385
|
audio.addEventListener('ended', handleEnded);
|
|
314
386
|
|
|
315
387
|
// store references to remove later
|
|
@@ -319,38 +391,42 @@ class MultipleChoice extends HTMLElement {
|
|
|
319
391
|
this._enableAudio = enableAudio;
|
|
320
392
|
// set to true to prevent multiple initializations
|
|
321
393
|
this._audioInitialized = true;
|
|
394
|
+
|
|
322
395
|
observer.disconnect();
|
|
323
396
|
}
|
|
324
397
|
});
|
|
325
398
|
});
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
subtree: true
|
|
329
|
-
});
|
|
399
|
+
|
|
400
|
+
observer.observe(this, { childList: true, subtree: true });
|
|
330
401
|
}
|
|
402
|
+
|
|
331
403
|
enableKeyboardEvents() {
|
|
332
404
|
if (!this._keyboardEventsEnabled) {
|
|
333
405
|
window.addEventListener('keydown', this._boundHandleKeyDown);
|
|
334
406
|
this._keyboardEventsEnabled = true;
|
|
335
407
|
}
|
|
336
408
|
}
|
|
409
|
+
|
|
337
410
|
_initPlayerObserver() {
|
|
338
411
|
const player = this.closest('pie-player') || this.closest('pie-item-player');
|
|
339
412
|
if (!player) return;
|
|
413
|
+
|
|
340
414
|
this._playerObserver = new MutationObserver(() => {
|
|
341
415
|
this._rerender();
|
|
342
416
|
});
|
|
343
417
|
this._playerObserver.observe(player, {
|
|
344
418
|
attributes: true,
|
|
345
|
-
attributeFilter: ['base-heading-level', 'baseheadinglevel', 'include-sr-heading', 'includesrheading']
|
|
419
|
+
attributeFilter: ['base-heading-level', 'baseheadinglevel', 'include-sr-heading', 'includesrheading'],
|
|
346
420
|
});
|
|
347
421
|
}
|
|
422
|
+
|
|
348
423
|
_disconnectPlayerObserver() {
|
|
349
424
|
if (this._playerObserver) {
|
|
350
425
|
this._playerObserver.disconnect();
|
|
351
426
|
this._playerObserver = null;
|
|
352
427
|
}
|
|
353
428
|
}
|
|
429
|
+
|
|
354
430
|
disconnectedCallback() {
|
|
355
431
|
this._disconnectMathObserver();
|
|
356
432
|
this._disconnectPlayerObserver();
|
|
@@ -358,12 +434,15 @@ class MultipleChoice extends HTMLElement {
|
|
|
358
434
|
window.removeEventListener('keydown', this._boundHandleKeyDown);
|
|
359
435
|
this._keyboardEventsEnabled = false;
|
|
360
436
|
}
|
|
437
|
+
|
|
361
438
|
document.removeEventListener('click', this._enableAudio);
|
|
439
|
+
|
|
362
440
|
if (this._audio) {
|
|
363
441
|
this._audio.removeEventListener('playing', this._handlePlaying);
|
|
364
442
|
this._audio.removeEventListener('ended', this._handleEnded);
|
|
365
443
|
this._audio = null;
|
|
366
444
|
}
|
|
445
|
+
|
|
367
446
|
if (this._root) {
|
|
368
447
|
this._root.unmount();
|
|
369
448
|
}
|
|
@@ -378,30 +457,33 @@ class MultipleChoice extends HTMLElement {
|
|
|
378
457
|
if (!this._model || !this._session) {
|
|
379
458
|
return;
|
|
380
459
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
} = this._model;
|
|
460
|
+
|
|
461
|
+
const { mode } = this._model;
|
|
384
462
|
if (mode !== 'gather') {
|
|
385
463
|
return;
|
|
386
464
|
}
|
|
387
|
-
|
|
465
|
+
|
|
466
|
+
const keyToIndex = (key) => {
|
|
388
467
|
const numOffset = key >= '1' && key <= '9' ? key - '1' : key === '0' ? 9 : -1;
|
|
389
468
|
const letterOffset = /^[a-jA-J]$/.test(key) ? key.toLowerCase().charCodeAt(0) - 'a'.charCodeAt(0) : -1;
|
|
390
469
|
return numOffset >= 0 ? numOffset : letterOffset;
|
|
391
470
|
};
|
|
471
|
+
|
|
392
472
|
const choiceIndex = keyToIndex(event.key);
|
|
473
|
+
|
|
393
474
|
if (choiceIndex === undefined || choiceIndex <= -1 || choiceIndex >= this._model.choices?.length) {
|
|
394
475
|
return;
|
|
395
476
|
}
|
|
477
|
+
|
|
396
478
|
const currentValue = this._session.value || [];
|
|
397
479
|
const choiceId = this._model.choices[choiceIndex].value;
|
|
480
|
+
|
|
398
481
|
const newValue = {
|
|
399
482
|
value: choiceId,
|
|
400
483
|
selected: !currentValue.includes(choiceId),
|
|
401
|
-
selector: 'Keyboard'
|
|
484
|
+
selector: 'Keyboard',
|
|
402
485
|
};
|
|
486
|
+
|
|
403
487
|
this._onChange(newValue);
|
|
404
488
|
}
|
|
405
489
|
}
|
|
406
|
-
exports.default = MultipleChoice;
|
|
407
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/multiple-choice/src/main.jsx
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import { PreviewLayout as PreviewLayoutImport } from '@pie-lib/render-ui';
|
|
14
|
+
|
|
15
|
+
function isRenderableReactInteropType(value: any) {
|
|
16
|
+
return (
|
|
17
|
+
typeof value === 'function' ||
|
|
18
|
+
(typeof value === 'object' && value !== null && typeof value.$$typeof === 'symbol')
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function unwrapReactInteropSymbol(maybeSymbol: any, namedExport?: string) {
|
|
23
|
+
if (!maybeSymbol) return maybeSymbol;
|
|
24
|
+
if (isRenderableReactInteropType(maybeSymbol)) return maybeSymbol;
|
|
25
|
+
if (isRenderableReactInteropType(maybeSymbol.default)) return maybeSymbol.default;
|
|
26
|
+
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport])) {
|
|
27
|
+
return maybeSymbol[namedExport];
|
|
28
|
+
}
|
|
29
|
+
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport]?.default)) {
|
|
30
|
+
return maybeSymbol[namedExport].default;
|
|
31
|
+
}
|
|
32
|
+
return maybeSymbol;
|
|
33
|
+
}
|
|
34
|
+
const PreviewLayout = unwrapReactInteropSymbol(PreviewLayoutImport, 'PreviewLayout') || unwrapReactInteropSymbol(renderUi.PreviewLayout, 'PreviewLayout');
|
|
35
|
+
import * as RenderUiNamespace from '@pie-lib/render-ui';
|
|
36
|
+
const renderUiNamespaceAny = RenderUiNamespace as any;
|
|
37
|
+
const renderUiDefaultMaybe = renderUiNamespaceAny['default'];
|
|
38
|
+
const renderUi =
|
|
39
|
+
renderUiDefaultMaybe && typeof renderUiDefaultMaybe === 'object'
|
|
40
|
+
? renderUiDefaultMaybe
|
|
41
|
+
: renderUiNamespaceAny;
|
|
42
|
+
import MultipleChoice from './multiple-choice.js';
|
|
43
|
+
|
|
44
|
+
class Main extends React.Component {
|
|
45
|
+
static propTypes = {
|
|
46
|
+
model: PropTypes.object,
|
|
47
|
+
session: PropTypes.object,
|
|
48
|
+
options: PropTypes.object,
|
|
49
|
+
onChoiceChanged: PropTypes.func,
|
|
50
|
+
onShowCorrectToggle: PropTypes.func,
|
|
51
|
+
extraCSSRules: PropTypes.shape({
|
|
52
|
+
names: PropTypes.arrayOf(PropTypes.string),
|
|
53
|
+
rules: PropTypes.string,
|
|
54
|
+
}),
|
|
55
|
+
baseHeadingLevel: PropTypes.number,
|
|
56
|
+
includeSrHeading: PropTypes.bool,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
static defaultProps = {
|
|
60
|
+
model: {},
|
|
61
|
+
session: {},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
render() {
|
|
65
|
+
const { model, onChoiceChanged, session, onShowCorrectToggle, options, baseHeadingLevel, includeSrHeading } = this.props;
|
|
66
|
+
const { extraCSSRules, fontSizeFactor } = model;
|
|
67
|
+
|
|
68
|
+
// model.partLabel is a property used for ebsr
|
|
69
|
+
return (
|
|
70
|
+
<PreviewLayout extraCSSRules={extraCSSRules} fontSizeFactor={fontSizeFactor} classes={{}}>
|
|
71
|
+
<MultipleChoice
|
|
72
|
+
{...model}
|
|
73
|
+
options={options}
|
|
74
|
+
session={session}
|
|
75
|
+
onChoiceChanged={onChoiceChanged}
|
|
76
|
+
onShowCorrectToggle={onShowCorrectToggle}
|
|
77
|
+
baseHeadingLevel={baseHeadingLevel}
|
|
78
|
+
includeSrHeading={includeSrHeading}
|
|
79
|
+
/>
|
|
80
|
+
</PreviewLayout>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export default Main;
|