@pie-element/multiple-choice 13.0.1 → 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/src/delivery/index.ts +489 -0
- 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 -2690
- 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 +0 -337
- package/lib/index.js.map +0 -1
- package/lib/main.js +0 -57
- package/lib/main.js.map +0 -1
- package/lib/multiple-choice.js +0 -385
- 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
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/multiple-choice/src/feedback-tick.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 { TransitionGroup, CSSTransition } from 'react-transition-group';
|
|
13
|
+
import { styled } from '@mui/material/styles';
|
|
14
|
+
import Box from '@mui/material/Box';
|
|
15
|
+
import PropTypes from 'prop-types';
|
|
16
|
+
import { color } from '@pie-lib/render-ui';
|
|
17
|
+
|
|
18
|
+
const FeedbackTickContainer: any = styled(Box)({
|
|
19
|
+
width: '33px',
|
|
20
|
+
height: '33px',
|
|
21
|
+
'& svg': {
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
display: 'inline-block',
|
|
24
|
+
width: '33px',
|
|
25
|
+
height: '33px',
|
|
26
|
+
verticalAlign: 'middle',
|
|
27
|
+
'& hide': {
|
|
28
|
+
display: 'none',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const StyledSVG: any = styled('svg')({
|
|
34
|
+
'& .incorrect-fill': {
|
|
35
|
+
fill: `var(--feedback-incorrect-bg-color, ${color.incorrect()})`,
|
|
36
|
+
},
|
|
37
|
+
'& .correct-fill': {
|
|
38
|
+
fill: `var(--feedback-correct-bg-color, ${color.correct()})`,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const TransitionWrapper: any = styled('div')({
|
|
43
|
+
position: 'relative',
|
|
44
|
+
'&.feedback-tick-enter': {
|
|
45
|
+
opacity: '0',
|
|
46
|
+
left: '-50px',
|
|
47
|
+
},
|
|
48
|
+
'&.feedback-tick-enter-active': {
|
|
49
|
+
opacity: '1',
|
|
50
|
+
left: '0px',
|
|
51
|
+
transition: 'left 500ms ease-in 200ms, opacity 500ms linear 200ms',
|
|
52
|
+
},
|
|
53
|
+
'&.feedback-tick-exit': {
|
|
54
|
+
opacity: '1',
|
|
55
|
+
left: '0px',
|
|
56
|
+
},
|
|
57
|
+
'&.feedback-tick-exit-active': {
|
|
58
|
+
opacity: '0',
|
|
59
|
+
left: '-50px',
|
|
60
|
+
transition: 'left 300ms ease-in, opacity 300ms',
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
class FeedbackTick extends React.Component {
|
|
65
|
+
static propTypes = {
|
|
66
|
+
correctness: PropTypes.string,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
constructor(props) {
|
|
70
|
+
super(props);
|
|
71
|
+
this.nodeRef = React.createRef();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
getIncorrectIcon = () => (
|
|
75
|
+
<StyledSVG
|
|
76
|
+
key="1"
|
|
77
|
+
preserveAspectRatio="xMinYMin meet"
|
|
78
|
+
x="0px"
|
|
79
|
+
y="0px"
|
|
80
|
+
viewBox="0 0 44 40"
|
|
81
|
+
style={{ enableBackground: 'new 0 0 44 40' }}
|
|
82
|
+
>
|
|
83
|
+
<g>
|
|
84
|
+
<rect
|
|
85
|
+
x="11"
|
|
86
|
+
y="17.3"
|
|
87
|
+
transform="matrix(0.7071 -0.7071 0.7071 0.7071 -7.852 19.2507)"
|
|
88
|
+
className="incorrect-fill"
|
|
89
|
+
width="16.6"
|
|
90
|
+
height="3.7"
|
|
91
|
+
/>
|
|
92
|
+
<rect
|
|
93
|
+
x="17.4"
|
|
94
|
+
y="10.7"
|
|
95
|
+
transform="matrix(0.7071 -0.7071 0.7071 0.7071 -7.8175 19.209)"
|
|
96
|
+
className="incorrect-fill"
|
|
97
|
+
width="3.7"
|
|
98
|
+
height="16.6"
|
|
99
|
+
/>
|
|
100
|
+
</g>
|
|
101
|
+
</StyledSVG>
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
getCorrectIcon = () => (
|
|
105
|
+
<StyledSVG
|
|
106
|
+
key="2"
|
|
107
|
+
preserveAspectRatio="xMinYMin meet"
|
|
108
|
+
version="1.1"
|
|
109
|
+
x="0px"
|
|
110
|
+
y="0px"
|
|
111
|
+
viewBox="0 0 44 40"
|
|
112
|
+
style={{ enableBackground: 'new 0 0 44 40' }}
|
|
113
|
+
>
|
|
114
|
+
<polygon
|
|
115
|
+
className="correct-fill"
|
|
116
|
+
points="19.1,28.6 11.8,22.3 14.4,19.2 17.9,22.1 23.9,11.4 27.5,13.4"
|
|
117
|
+
/>
|
|
118
|
+
</StyledSVG>
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
render() {
|
|
122
|
+
const { correctness } = this.props;
|
|
123
|
+
|
|
124
|
+
const icon = (() => {
|
|
125
|
+
if (correctness === 'incorrect') {
|
|
126
|
+
return this.getIncorrectIcon();
|
|
127
|
+
} else if (correctness === 'correct') {
|
|
128
|
+
return this.getCorrectIcon();
|
|
129
|
+
}
|
|
130
|
+
return null;
|
|
131
|
+
})();
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<FeedbackTickContainer>
|
|
135
|
+
<TransitionGroup>
|
|
136
|
+
{correctness && (
|
|
137
|
+
<CSSTransition
|
|
138
|
+
nodeRef={this.nodeRef}
|
|
139
|
+
classNames={{
|
|
140
|
+
enter: 'feedback-tick-enter',
|
|
141
|
+
enterActive: 'feedback-tick-enter-active',
|
|
142
|
+
exit: 'feedback-tick-exit',
|
|
143
|
+
exitActive: 'feedback-tick-exit-active',
|
|
144
|
+
}}
|
|
145
|
+
timeout={{ enter: 700, exit: 300 }}
|
|
146
|
+
>
|
|
147
|
+
<TransitionWrapper ref={this.nodeRef}>{icon}</TransitionWrapper>
|
|
148
|
+
</CSSTransition>
|
|
149
|
+
)}
|
|
150
|
+
</TransitionGroup>
|
|
151
|
+
</FeedbackTickContainer>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export default FeedbackTick;
|
|
@@ -0,0 +1,489 @@
|
|
|
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 || {};
|
|
53
|
+
|
|
54
|
+
// check audio completion if audio settings are enabled and audio actually exists
|
|
55
|
+
if (autoplayAudioEnabled && completeAudioEnabled && !audioComplete) {
|
|
56
|
+
if (elementContext) {
|
|
57
|
+
const audio = elementContext.querySelector('audio');
|
|
58
|
+
const isInsidePrompt = audio && audio.closest('#preview-prompt');
|
|
59
|
+
|
|
60
|
+
// only require audio completion if audio exists and is inside the prompt
|
|
61
|
+
if (audio && isInsidePrompt) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (!session || !session.value) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const { choiceMode, minSelections = 1, maxSelections } = model || {};
|
|
72
|
+
const selections = session.value.length || 0;
|
|
73
|
+
|
|
74
|
+
if (choiceMode === 'radio') {
|
|
75
|
+
return !!selections;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (selections < minSelections || selections > maxSelections) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return true;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
function getPlayerAttributes(element) {
|
|
86
|
+
const player =
|
|
87
|
+
element.closest('pie-player') ||
|
|
88
|
+
element.closest('pie-item-player');
|
|
89
|
+
|
|
90
|
+
if (!player) {
|
|
91
|
+
return { baseHeadingLevel: undefined, includeSrHeading: true };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const getRaw = (camelCaseName, hyphenatedName, allLowerName) => {
|
|
95
|
+
let raw = player[camelCaseName];
|
|
96
|
+
|
|
97
|
+
// fallback in case someone sets via HTML attribute manually
|
|
98
|
+
if (raw == null) {
|
|
99
|
+
raw =
|
|
100
|
+
player.getAttribute(hyphenatedName) ??
|
|
101
|
+
player.getAttribute(allLowerName);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return raw;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const levelRaw = getRaw('baseHeadingLevel', 'base-heading-level', 'baseheadinglevel');
|
|
108
|
+
const level = parseInt(levelRaw, 10);
|
|
109
|
+
const baseHeadingLevel = Number.isFinite(level) && level >= 1 && level <= 6 ? level : undefined;
|
|
110
|
+
|
|
111
|
+
const srRaw = getRaw('includeSrHeading', 'include-sr-heading', 'includesrheading');
|
|
112
|
+
const includeSrHeading = srRaw == null ? true : srRaw !== false && srRaw !== 'false';
|
|
113
|
+
|
|
114
|
+
console.log('getPlayerAttributes', { baseHeadingLevel, includeSrHeading });
|
|
115
|
+
return { baseHeadingLevel, includeSrHeading };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Resolves heading attributes for a custom element, preferring explicit instance
|
|
119
|
+
// properties (set by a parent element such as EBSR) over player-level attributes.
|
|
120
|
+
function resolveHeadingProps(element) {
|
|
121
|
+
const fromPlayer = getPlayerAttributes(element);
|
|
122
|
+
|
|
123
|
+
console.log('element._baseHeadingLevel', element._baseHeadingLevel, 'element._includeSrHeading', element._includeSrHeading);
|
|
124
|
+
return {
|
|
125
|
+
baseHeadingLevel: element._baseHeadingLevel !== undefined ? element._baseHeadingLevel : fromPlayer.baseHeadingLevel,
|
|
126
|
+
includeSrHeading: element._includeSrHeading !== undefined ? element._includeSrHeading : fromPlayer.includeSrHeading,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export default class MultipleChoice extends HTMLElement {
|
|
131
|
+
constructor() {
|
|
132
|
+
super();
|
|
133
|
+
this._model = null;
|
|
134
|
+
this._session = null;
|
|
135
|
+
this._options = null; // added for ebsr print mode detection
|
|
136
|
+
this.audioComplete = false;
|
|
137
|
+
this._boundHandleKeyDown = this.handleKeyDown.bind(this);
|
|
138
|
+
this._keyboardEventsEnabled = false;
|
|
139
|
+
this._audioInitialized = false;
|
|
140
|
+
this._root = null;
|
|
141
|
+
this._mathObserver = null;
|
|
142
|
+
this._mathRenderPending = false;
|
|
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');
|
|
176
|
+
}
|
|
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
|
+
);
|
|
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
|
+
);
|
|
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
|
+
|
|
225
|
+
_initMathObserver() {
|
|
226
|
+
if (this._mathObserver) return;
|
|
227
|
+
this._mathObserver = new MutationObserver(this._scheduleMathRender);
|
|
228
|
+
this._mathObserver.observe(this, { childList: true, subtree: true });
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
_disconnectMathObserver() {
|
|
232
|
+
if (this._mathObserver) {
|
|
233
|
+
this._mathObserver.disconnect();
|
|
234
|
+
this._mathObserver = null;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
onShowCorrectToggle() {
|
|
239
|
+
renderMath(this);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
setLangAttribute() {
|
|
243
|
+
const language = this._model && typeof this._model.language ? this._model.language : '';
|
|
244
|
+
const lang = language ? language.slice(0, 2) : 'en';
|
|
245
|
+
this.setAttribute('lang', lang);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
set model(s) {
|
|
249
|
+
this._model = s;
|
|
250
|
+
this._rerender();
|
|
251
|
+
// reset the audioInitialized to false since the model changed, and we might need to reinitialize the audio
|
|
252
|
+
this._audioInitialized = false;
|
|
253
|
+
this._dispatchModelSet();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
get session() {
|
|
257
|
+
return this._session;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
get options() {
|
|
261
|
+
return this._options;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
set options(o) {
|
|
265
|
+
this._options = o;
|
|
266
|
+
this._rerender();
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
set baseHeadingLevel(level) {
|
|
270
|
+
this._baseHeadingLevel = level;
|
|
271
|
+
this._rerender();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
set includeSrHeading(value) {
|
|
275
|
+
this._includeSrHeading = value;
|
|
276
|
+
this._rerender();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
set session(s) {
|
|
280
|
+
this._session = s;
|
|
281
|
+
this._rerender();
|
|
282
|
+
//TODO: remove this session-changed should only be emit on user change
|
|
283
|
+
this._dispatchResponseChanged();
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
_onChange(data) {
|
|
287
|
+
updateSessionValue(this._session, this._model.choiceMode, data);
|
|
288
|
+
this._dispatchResponseChanged();
|
|
289
|
+
this._rerender();
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
_createAudioInfoToast() {
|
|
293
|
+
const info = document.createElement('div');
|
|
294
|
+
info.id = 'play-audio-info';
|
|
295
|
+
|
|
296
|
+
Object.assign(info.style, {
|
|
297
|
+
position: 'absolute',
|
|
298
|
+
top: 0,
|
|
299
|
+
width: '100%',
|
|
300
|
+
height: '100%',
|
|
301
|
+
display: 'flex',
|
|
302
|
+
justifyContent: 'center',
|
|
303
|
+
alignItems: 'center',
|
|
304
|
+
background: 'white',
|
|
305
|
+
zIndex: '1000',
|
|
306
|
+
cursor: 'pointer',
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
const img = document.createElement('img');
|
|
310
|
+
img.src = EnableAudioAutoplayImage;
|
|
311
|
+
img.alt = 'Click anywhere to enable audio autoplay';
|
|
312
|
+
img.width = 500;
|
|
313
|
+
img.height = 300;
|
|
314
|
+
|
|
315
|
+
info.appendChild(img);
|
|
316
|
+
return info;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
connectedCallback() {
|
|
320
|
+
this._initMathObserver();
|
|
321
|
+
this._initPlayerObserver();
|
|
322
|
+
this._rerender();
|
|
323
|
+
|
|
324
|
+
// Observation: audio in Chrome will have the autoplay attribute,
|
|
325
|
+
// while other browsers will not have the autoplay attribute and will need a user interaction to play the audio
|
|
326
|
+
// This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox
|
|
327
|
+
const observer = new MutationObserver((mutationsList, observer) => {
|
|
328
|
+
mutationsList.forEach((mutation) => {
|
|
329
|
+
if (mutation.type === 'childList') {
|
|
330
|
+
if (this._audioInitialized) return;
|
|
331
|
+
|
|
332
|
+
const audio = this.querySelector('audio');
|
|
333
|
+
const isInsidePrompt = audio && audio.closest('#preview-prompt');
|
|
334
|
+
|
|
335
|
+
if (!this._model) return;
|
|
336
|
+
if (!this._model.autoplayAudioEnabled) return;
|
|
337
|
+
if (audio && !isInsidePrompt) return;
|
|
338
|
+
if (!audio) return;
|
|
339
|
+
|
|
340
|
+
const info = this._createAudioInfoToast();
|
|
341
|
+
const container = this.querySelector('#main-container');
|
|
342
|
+
const enableAudio = () => {
|
|
343
|
+
if (this.querySelector('#play-audio-info')) {
|
|
344
|
+
audio.play();
|
|
345
|
+
container.removeChild(info);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
document.removeEventListener('click', enableAudio);
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
// if the audio is paused, it means the user has not interacted with the page yet and the audio will not play
|
|
352
|
+
// FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked
|
|
353
|
+
setTimeout(() => {
|
|
354
|
+
if (audio.paused && !this.querySelector('#play-audio-info')) {
|
|
355
|
+
// add info message as a toast to enable audio playback
|
|
356
|
+
container.appendChild(info);
|
|
357
|
+
document.addEventListener('click', enableAudio);
|
|
358
|
+
} else {
|
|
359
|
+
document.removeEventListener('click', enableAudio);
|
|
360
|
+
}
|
|
361
|
+
}, 500);
|
|
362
|
+
|
|
363
|
+
// we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering
|
|
364
|
+
const handlePlaying = () => {
|
|
365
|
+
updateSessionMetadata(this._session, { audioStartTime: new Date().getTime() });
|
|
366
|
+
|
|
367
|
+
const info = this.querySelector('#play-audio-info');
|
|
368
|
+
if (info) {
|
|
369
|
+
container.removeChild(info);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
audio.removeEventListener('playing', handlePlaying);
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
audio.addEventListener('playing', handlePlaying);
|
|
376
|
+
|
|
377
|
+
// we need to listen for the ended event to update the isComplete state
|
|
378
|
+
const handleEnded = () => {
|
|
379
|
+
updateSessionMetadata(this._session, { audioEndTime: new Date().getTime() });
|
|
380
|
+
this.audioComplete = true;
|
|
381
|
+
this._dispatchResponseChanged();
|
|
382
|
+
audio.removeEventListener('ended', handleEnded);
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
audio.addEventListener('ended', handleEnded);
|
|
386
|
+
|
|
387
|
+
// store references to remove later
|
|
388
|
+
this._audio = audio;
|
|
389
|
+
this._handlePlaying = handlePlaying;
|
|
390
|
+
this._handleEnded = handleEnded;
|
|
391
|
+
this._enableAudio = enableAudio;
|
|
392
|
+
// set to true to prevent multiple initializations
|
|
393
|
+
this._audioInitialized = true;
|
|
394
|
+
|
|
395
|
+
observer.disconnect();
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
observer.observe(this, { childList: true, subtree: true });
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
enableKeyboardEvents() {
|
|
404
|
+
if (!this._keyboardEventsEnabled) {
|
|
405
|
+
window.addEventListener('keydown', this._boundHandleKeyDown);
|
|
406
|
+
this._keyboardEventsEnabled = true;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
_initPlayerObserver() {
|
|
411
|
+
const player = this.closest('pie-player') || this.closest('pie-item-player');
|
|
412
|
+
if (!player) return;
|
|
413
|
+
|
|
414
|
+
this._playerObserver = new MutationObserver(() => {
|
|
415
|
+
this._rerender();
|
|
416
|
+
});
|
|
417
|
+
this._playerObserver.observe(player, {
|
|
418
|
+
attributes: true,
|
|
419
|
+
attributeFilter: ['base-heading-level', 'baseheadinglevel', 'include-sr-heading', 'includesrheading'],
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
_disconnectPlayerObserver() {
|
|
424
|
+
if (this._playerObserver) {
|
|
425
|
+
this._playerObserver.disconnect();
|
|
426
|
+
this._playerObserver = null;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
disconnectedCallback() {
|
|
431
|
+
this._disconnectMathObserver();
|
|
432
|
+
this._disconnectPlayerObserver();
|
|
433
|
+
if (this._keyboardEventsEnabled) {
|
|
434
|
+
window.removeEventListener('keydown', this._boundHandleKeyDown);
|
|
435
|
+
this._keyboardEventsEnabled = false;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
document.removeEventListener('click', this._enableAudio);
|
|
439
|
+
|
|
440
|
+
if (this._audio) {
|
|
441
|
+
this._audio.removeEventListener('playing', this._handlePlaying);
|
|
442
|
+
this._audio.removeEventListener('ended', this._handleEnded);
|
|
443
|
+
this._audio = null;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
if (this._root) {
|
|
447
|
+
this._root.unmount();
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Handles global keyboard events for selecting or toggling multiple-choice answers.
|
|
453
|
+
* Maps keys (1-9, 0, a-j, A-J) to choices and updates the session state accordingly.
|
|
454
|
+
* Ensures valid key presses toggle or select the appropriate choice based on the model.
|
|
455
|
+
*/
|
|
456
|
+
handleKeyDown(event) {
|
|
457
|
+
if (!this._model || !this._session) {
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
const { mode } = this._model;
|
|
462
|
+
if (mode !== 'gather') {
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
const keyToIndex = (key) => {
|
|
467
|
+
const numOffset = key >= '1' && key <= '9' ? key - '1' : key === '0' ? 9 : -1;
|
|
468
|
+
const letterOffset = /^[a-jA-J]$/.test(key) ? key.toLowerCase().charCodeAt(0) - 'a'.charCodeAt(0) : -1;
|
|
469
|
+
return numOffset >= 0 ? numOffset : letterOffset;
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
const choiceIndex = keyToIndex(event.key);
|
|
473
|
+
|
|
474
|
+
if (choiceIndex === undefined || choiceIndex <= -1 || choiceIndex >= this._model.choices?.length) {
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
const currentValue = this._session.value || [];
|
|
479
|
+
const choiceId = this._model.choices[choiceIndex].value;
|
|
480
|
+
|
|
481
|
+
const newValue = {
|
|
482
|
+
value: choiceId,
|
|
483
|
+
selected: !currentValue.includes(choiceId),
|
|
484
|
+
selector: 'Keyboard',
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
this._onChange(newValue);
|
|
488
|
+
}
|
|
489
|
+
}
|