@pie-element/multiple-choice 13.1.1-next.0 → 13.2.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +1972 -0
- package/CHANGELOG.md +2704 -0
- package/LICENSE.md +5 -0
- package/PRINT.md +35 -0
- package/README.md +56 -0
- package/choice.png +0 -0
- package/configure/CHANGELOG.json +1387 -0
- package/configure/CHANGELOG.md +2054 -0
- package/{src/author/defaults.ts → configure/lib/defaults.js} +90 -55
- package/configure/lib/defaults.js.map +1 -0
- package/{src/author/index.ts → configure/lib/index.js} +55 -99
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/main.js +483 -0
- package/configure/lib/main.js.map +1 -0
- package/configure/lib/utils.js +18 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +22 -0
- package/controller/CHANGELOG.json +527 -0
- package/controller/CHANGELOG.md +1394 -0
- package/{src/controller/defaults.ts → controller/lib/defaults.js} +8 -11
- package/controller/lib/defaults.js.map +1 -0
- package/{src/controller/index.ts → controller/lib/index.js} +109 -123
- package/controller/lib/index.js.map +1 -0
- package/controller/lib/utils.js +15 -0
- package/controller/lib/utils.js.map +1 -0
- package/controller/package.json +15 -0
- package/docs/config-schema.json +2993 -0
- package/docs/config-schema.json.md +2217 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +61 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +7 -0
- package/docs/pie-schema.json +1332 -0
- package/docs/pie-schema.json.md +1015 -0
- package/lib/choice-input.js +380 -0
- package/lib/choice-input.js.map +1 -0
- package/lib/choice.js +197 -0
- package/lib/choice.js.map +1 -0
- package/lib/feedback-tick.js +134 -0
- package/lib/feedback-tick.js.map +1 -0
- package/{src/delivery/index.ts → lib/index.js} +129 -211
- package/lib/index.js.map +1 -0
- package/lib/main.js +63 -0
- package/lib/main.js.map +1 -0
- package/lib/multiple-choice.js +412 -0
- package/lib/multiple-choice.js.map +1 -0
- package/lib/print.js +94 -0
- package/lib/print.js.map +1 -0
- package/{src/delivery/session-updater.ts → lib/session-updater.js} +13 -17
- package/lib/session-updater.js.map +1 -0
- package/module/configure.js +1 -0
- package/module/controller.js +3045 -0
- package/module/demo.js +86 -0
- package/module/element.js +1 -0
- package/module/index.html +21 -0
- package/module/manifest.json +14 -0
- package/module/print-demo.js +124 -0
- package/module/print.html +18 -0
- package/module/print.js +1 -0
- package/package.json +26 -58
- package/dist/author/defaults.d.ts +0 -206
- package/dist/author/defaults.d.ts.map +0 -1
- package/dist/author/defaults.js +0 -151
- package/dist/author/index.d.ts +0 -27
- package/dist/author/index.d.ts.map +0 -1
- package/dist/author/index.js +0 -116
- package/dist/author/main.d.ts +0 -35
- package/dist/author/main.d.ts.map +0 -1
- package/dist/author/main.js +0 -290
- package/dist/author/utils.d.ts +0 -10
- package/dist/author/utils.d.ts.map +0 -1
- package/dist/author/utils.js +0 -7
- package/dist/controller/defaults.d.ts +0 -36
- package/dist/controller/defaults.d.ts.map +0 -1
- package/dist/controller/defaults.js +0 -29
- package/dist/controller/index.d.ts +0 -66
- package/dist/controller/index.d.ts.map +0 -1
- package/dist/controller/index.js +0 -124
- package/dist/controller/utils.d.ts +0 -11
- package/dist/controller/utils.d.ts.map +0 -1
- package/dist/controller/utils.js +0 -8
- package/dist/delivery/choice-input.d.ts +0 -45
- package/dist/delivery/choice-input.d.ts.map +0 -1
- package/dist/delivery/choice-input.js +0 -274
- package/dist/delivery/choice.d.ts +0 -21
- package/dist/delivery/choice.d.ts.map +0 -1
- package/dist/delivery/choice.js +0 -109
- package/dist/delivery/feedback-tick.d.ts +0 -21
- package/dist/delivery/feedback-tick.d.ts.map +0 -1
- package/dist/delivery/feedback-tick.js +0 -104
- package/dist/delivery/index.d.ts +0 -38
- package/dist/delivery/index.d.ts.map +0 -1
- package/dist/delivery/index.js +0 -217
- package/dist/delivery/main.d.ts +0 -32
- package/dist/delivery/main.d.ts.map +0 -1
- package/dist/delivery/main.js +0 -51
- package/dist/delivery/multiple-choice.d.ts +0 -63
- package/dist/delivery/multiple-choice.d.ts.map +0 -1
- package/dist/delivery/multiple-choice.js +0 -252
- package/dist/delivery/session-updater.d.ts +0 -11
- package/dist/delivery/session-updater.d.ts.map +0 -1
- package/dist/delivery/session-updater.js +0 -9
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.iife.d.ts +0 -9
- package/dist/index.iife.d.ts.map +0 -1
- package/dist/index.iife.js +0 -148
- package/dist/index.js +0 -2
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Hash.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_ListCache.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Map.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_MapCache.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Set.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_SetCache.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Stack.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Symbol.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_apply.js +0 -12
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js +0 -15
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arraySome.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignMergeValue.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assocIndexOf.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignValue.js +0 -12
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js +0 -57
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseFor.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetTag.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsArguments.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqual.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqualDeep.js +0 -30
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsNative.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js +0 -12
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeysIn.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseMerge.js +0 -19
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseMergeDeep.js +0 -31
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseRest.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseSetToString.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTrim.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseUnary.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cacheHas.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneArrayBuffer.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_coreJsData.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_createAssigner.js +0 -15
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_createBaseFor.js +0 -12
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalArrays.js +0 -35
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalByTag.js +0 -35
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalObjects.js +0 -32
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_freeGlobal.js +0 -4
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getMapData.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getNative.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getRawTag.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js +0 -23
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getValue.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashClear.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashDelete.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashGet.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashHas.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashSet.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js +0 -33
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIterateeCall.js +0 -12
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKeyable.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isMasked.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheClear.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheDelete.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheGet.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheHas.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheSet.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheClear.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheDelete.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheGet.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheHas.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheSet.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapToArray.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeCreate.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_objectToString.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overRest.js +0 -13
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_root.js +0 -5
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_safeGet.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setCacheAdd.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setCacheHas.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToArray.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToString.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_shortOut.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackClear.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackDelete.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackGet.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackHas.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackSet.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toSource.js +0 -15
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_trimmedEndIndex.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/constant.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/debounce.js +0 -50
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/defaults.js +0 -16
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/eq.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/identity.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js +0 -10
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArray.js +0 -4
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLikeObject.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEmpty.js +0 -21
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEqual.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isFunction.js +0 -11
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isLength.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isMap.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObject.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isPlainObject.js +0 -14
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSet.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSymbol.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isTypedArray.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keys.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js +0 -9
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/merge.js +0 -8
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/now.js +0 -7
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js +0 -6
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toNumber.js +0 -19
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toPlainObject.js +0 -8
- package/dist/print/index.d.ts +0 -16
- package/dist/print/index.d.ts.map +0 -1
- package/dist/print/index.js +0 -44
- package/src/author/main.tsx +0 -509
- package/src/author/utils.ts +0 -25
- package/src/controller/utils.ts +0 -22
- package/src/delivery/choice-input.tsx +0 -413
- package/src/delivery/choice.tsx +0 -203
- package/src/delivery/feedback-tick.tsx +0 -156
- package/src/delivery/main.tsx +0 -85
- package/src/delivery/multiple-choice.tsx +0 -485
- package/src/index.iife.ts +0 -16
- package/src/index.ts +0 -1
- package/src/print/index.tsx +0 -112
|
@@ -1,413 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
/**
|
|
3
|
-
* @synced-from pie-elements/packages/multiple-choice/src/choice-input.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 FormControlLabel from '@mui/material/FormControlLabel';
|
|
12
|
-
import React from 'react';
|
|
13
|
-
import PropTypes from 'prop-types';
|
|
14
|
-
import { styled } from '@mui/material/styles';
|
|
15
|
-
import Box from '@mui/material/Box';
|
|
16
|
-
import Checkbox from '@mui/material/Checkbox';
|
|
17
|
-
import { Feedback as FeedbackImport, color, PreviewPrompt as PreviewPromptImport } from '@pie-lib/render-ui';
|
|
18
|
-
|
|
19
|
-
function isRenderableReactInteropType(value: any) {
|
|
20
|
-
return (
|
|
21
|
-
typeof value === 'function' ||
|
|
22
|
-
(typeof value === 'object' && value !== null && typeof value.$$typeof === 'symbol')
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function unwrapReactInteropSymbol(maybeSymbol: any, namedExport?: string) {
|
|
27
|
-
if (!maybeSymbol) return maybeSymbol;
|
|
28
|
-
if (isRenderableReactInteropType(maybeSymbol)) return maybeSymbol;
|
|
29
|
-
if (isRenderableReactInteropType(maybeSymbol.default)) return maybeSymbol.default;
|
|
30
|
-
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport])) {
|
|
31
|
-
return maybeSymbol[namedExport];
|
|
32
|
-
}
|
|
33
|
-
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport]?.default)) {
|
|
34
|
-
return maybeSymbol[namedExport].default;
|
|
35
|
-
}
|
|
36
|
-
return maybeSymbol;
|
|
37
|
-
}
|
|
38
|
-
const PreviewPrompt = unwrapReactInteropSymbol(PreviewPromptImport, 'PreviewPrompt') || unwrapReactInteropSymbol(renderUi.PreviewPrompt, 'PreviewPrompt');
|
|
39
|
-
const Feedback = unwrapReactInteropSymbol(FeedbackImport, 'Feedback') || unwrapReactInteropSymbol(renderUi.Feedback, 'Feedback');
|
|
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 Radio from '@mui/material/Radio';
|
|
48
|
-
import classNames from 'classnames';
|
|
49
|
-
|
|
50
|
-
import FeedbackTick from './feedback-tick.js';
|
|
51
|
-
|
|
52
|
-
const CLASS_NAME = 'multiple-choice-component';
|
|
53
|
-
|
|
54
|
-
const Row: any = styled(Box)({
|
|
55
|
-
display: 'flex',
|
|
56
|
-
alignItems: 'center',
|
|
57
|
-
backgroundColor: color.background(),
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const CheckboxHolder: any = styled(Box)({
|
|
61
|
-
display: 'flex',
|
|
62
|
-
alignItems: 'center',
|
|
63
|
-
backgroundColor: color.background(),
|
|
64
|
-
flex: 1,
|
|
65
|
-
'& .MuiFormControlLabel-root': {
|
|
66
|
-
marginLeft: '-14px', // to be consistent to previous versions before MUI v5 upgrade
|
|
67
|
-
},
|
|
68
|
-
'& label': {
|
|
69
|
-
color: color.text(),
|
|
70
|
-
'& > span': {
|
|
71
|
-
fontSize: 'inherit',
|
|
72
|
-
},
|
|
73
|
-
'& > .MuiButtonBase-root': {
|
|
74
|
-
padding: '12px', // to be consistent to previous versions before MUI v5 upgrade
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
const BelowSelectionComponent: any = styled('span')(({ theme }) => ({
|
|
80
|
-
display: 'flex',
|
|
81
|
-
alignItems: 'center',
|
|
82
|
-
'& > span': {
|
|
83
|
-
// visually reduce right padding, but maintain accessibility padding for checkbox indicators to be circles
|
|
84
|
-
marginLeft: `-${theme.spacing(1)}`,
|
|
85
|
-
},
|
|
86
|
-
}));
|
|
87
|
-
|
|
88
|
-
const SrOnly: any = styled('span')({
|
|
89
|
-
position: 'absolute',
|
|
90
|
-
left: '-10000px',
|
|
91
|
-
top: 'auto',
|
|
92
|
-
width: '1px',
|
|
93
|
-
height: '1px',
|
|
94
|
-
overflow: 'hidden',
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
export const StyledFormControlLabel: any = styled(FormControlLabel)({
|
|
98
|
-
'& .MuiFormControlLabel-label': {
|
|
99
|
-
color: `${color.text()} !important`,
|
|
100
|
-
backgroundColor: color.background(),
|
|
101
|
-
letterSpacing: 'normal',
|
|
102
|
-
},
|
|
103
|
-
'&.Mui-disabled *': {
|
|
104
|
-
cursor: 'not-allowed !important',
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
const colorStyle = (varName, fallback) => ({
|
|
109
|
-
[`&.${CLASS_NAME}`]: {
|
|
110
|
-
color: `var(--choice-input-${varName}, ${fallback}) !important`,
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
const getInputStyles = (correctness) => {
|
|
115
|
-
const key = (k) => (correctness ? `${correctness}-${k}` : k);
|
|
116
|
-
|
|
117
|
-
return {
|
|
118
|
-
[key('root')]: {
|
|
119
|
-
...colorStyle('color', color.text()),
|
|
120
|
-
...(correctness ? {} : {
|
|
121
|
-
'&:hover': { color: `${color.primaryLight()} !important` },
|
|
122
|
-
}),
|
|
123
|
-
...(correctness === 'correct' ? colorStyle('correct-color', color.text()) : {}),
|
|
124
|
-
...(correctness === 'incorrect' ? colorStyle('incorrect-color', color.incorrect()) : {}),
|
|
125
|
-
},
|
|
126
|
-
[key('checked')]: {
|
|
127
|
-
...(correctness === 'correct' ? colorStyle('correct-selected-color', color.correct()) : {}),
|
|
128
|
-
...(correctness === 'incorrect' ? colorStyle('incorrect-checked', color.incorrect()) : {}),
|
|
129
|
-
...(!correctness ? colorStyle('selected-color', color.primary()) : {}),
|
|
130
|
-
},
|
|
131
|
-
[key('disabled')]: {
|
|
132
|
-
...colorStyle('disabled-color', color.text()),
|
|
133
|
-
...(correctness === 'correct' ? colorStyle('correct-disabled-color', color.disabled()) : {}),
|
|
134
|
-
...(correctness === 'incorrect' ? colorStyle('incorrect-disabled-color', color.disabled()) : {}),
|
|
135
|
-
opacity: 0.6,
|
|
136
|
-
cursor: 'not-allowed !important',
|
|
137
|
-
pointerEvents: 'initial !important',
|
|
138
|
-
},
|
|
139
|
-
focusVisibleUnchecked: {
|
|
140
|
-
outline: `2px solid ${color.focusUncheckedBorder()}`,
|
|
141
|
-
backgroundColor: color.focusUnchecked(),
|
|
142
|
-
},
|
|
143
|
-
focusVisibleChecked: {
|
|
144
|
-
outline: `2px solid ${color.focusCheckedBorder()}`,
|
|
145
|
-
backgroundColor: color.focusChecked(),
|
|
146
|
-
},
|
|
147
|
-
};
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
const StyledCheckboxBase: any = styled(Checkbox, {
|
|
151
|
-
shouldForwardProp: (prop) => prop !== 'correctness',
|
|
152
|
-
})(({ correctness }) => {
|
|
153
|
-
const styles = getInputStyles(correctness);
|
|
154
|
-
const key = (k) => (correctness ? `${correctness}-${k}` : k);
|
|
155
|
-
|
|
156
|
-
return {
|
|
157
|
-
[`&.${CLASS_NAME}`]: {
|
|
158
|
-
...styles[key('root')],
|
|
159
|
-
'&.Mui-checked': styles[key('checked')],
|
|
160
|
-
'&.Mui-disabled': correctness ? {} : styles[key('disabled')],
|
|
161
|
-
},
|
|
162
|
-
'&.Mui-focusVisible': {
|
|
163
|
-
'&:not(.Mui-checked)': styles.focusVisibleUnchecked,
|
|
164
|
-
'&.Mui-checked': styles.focusVisibleChecked,
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
export const StyledCheckbox = (props) => {
|
|
170
|
-
const { correctness, checked, onChange, disabled, value, id, onKeyDown, inputRef } = props;
|
|
171
|
-
|
|
172
|
-
const miniProps = { checked, onChange, disabled, value };
|
|
173
|
-
|
|
174
|
-
return (
|
|
175
|
-
<StyledCheckboxBase
|
|
176
|
-
id={id}
|
|
177
|
-
slotProps={{ input: { ref: inputRef } }}
|
|
178
|
-
onKeyDown={onKeyDown}
|
|
179
|
-
disableRipple
|
|
180
|
-
{...miniProps}
|
|
181
|
-
correctness={correctness}
|
|
182
|
-
className={CLASS_NAME}
|
|
183
|
-
/>
|
|
184
|
-
);
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
const StyledRadioBase: any = styled(Radio, {
|
|
188
|
-
shouldForwardProp: (prop) => prop !== 'correctness',
|
|
189
|
-
})(({ correctness }) => {
|
|
190
|
-
const styles = getInputStyles(correctness);
|
|
191
|
-
const key = (k) => (correctness ? `${correctness}-${k}` : k);
|
|
192
|
-
|
|
193
|
-
return {
|
|
194
|
-
[`&.${CLASS_NAME}`]: {
|
|
195
|
-
...styles[key('root')],
|
|
196
|
-
'&.Mui-checked': styles[key('checked')],
|
|
197
|
-
'&.Mui-disabled': correctness ? {} : styles[key('disabled')],
|
|
198
|
-
},
|
|
199
|
-
'&.Mui-focusVisible': {
|
|
200
|
-
'&:not(.Mui-checked)': styles.focusVisibleUnchecked,
|
|
201
|
-
'&.Mui-checked': styles.focusVisibleChecked,
|
|
202
|
-
},
|
|
203
|
-
};
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
export const StyledRadio = (props) => {
|
|
207
|
-
const { correctness, checked, onChange, disabled, value, id, tagName, inputRef } = props;
|
|
208
|
-
|
|
209
|
-
const miniProps = { checked, onChange, disabled, value };
|
|
210
|
-
|
|
211
|
-
return (
|
|
212
|
-
<StyledRadioBase
|
|
213
|
-
id={id}
|
|
214
|
-
slotProps={{ input: { ref: inputRef } }}
|
|
215
|
-
disableRipple
|
|
216
|
-
{...miniProps}
|
|
217
|
-
correctness={correctness}
|
|
218
|
-
className={CLASS_NAME}
|
|
219
|
-
name={tagName}
|
|
220
|
-
/>
|
|
221
|
-
);
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
export class ChoiceInput extends React.Component {
|
|
225
|
-
static propTypes = {
|
|
226
|
-
choiceMode: PropTypes.oneOf(['radio', 'checkbox']),
|
|
227
|
-
displayKey: PropTypes.string,
|
|
228
|
-
checked: PropTypes.bool.isRequired,
|
|
229
|
-
correctness: PropTypes.string,
|
|
230
|
-
disabled: PropTypes.bool.isRequired,
|
|
231
|
-
feedback: PropTypes.string,
|
|
232
|
-
label: PropTypes.string.isRequired,
|
|
233
|
-
rationale: PropTypes.string,
|
|
234
|
-
onChange: PropTypes.func.isRequired,
|
|
235
|
-
value: PropTypes.string.isRequired,
|
|
236
|
-
className: PropTypes.string,
|
|
237
|
-
tagName: PropTypes.string,
|
|
238
|
-
hideTick: PropTypes.bool,
|
|
239
|
-
isEvaluateMode: PropTypes.bool,
|
|
240
|
-
choicesLayout: PropTypes.oneOf(['vertical', 'grid', 'horizontal']),
|
|
241
|
-
isSelectionButtonBelow: PropTypes.bool,
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
static defaultProps = {
|
|
245
|
-
rationale: null,
|
|
246
|
-
checked: false,
|
|
247
|
-
isEvaluateMode: false,
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
constructor(props) {
|
|
251
|
-
super(props);
|
|
252
|
-
this.onToggleChoice = this.onToggleChoice.bind(this);
|
|
253
|
-
this.choiceId = this.generateChoiceId();
|
|
254
|
-
this.descId = `${this.choiceId}-desc`;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
onToggleChoice(event) {
|
|
258
|
-
this.props.onChange(event);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
generateChoiceId() {
|
|
262
|
-
return 'choice-' + (Math.random() * 10000).toFixed();
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
handleKeyDown: any = (event) => {
|
|
266
|
-
const { choiceMode } = this.props;
|
|
267
|
-
|
|
268
|
-
if (choiceMode !== 'checkbox') return;
|
|
269
|
-
|
|
270
|
-
const isArrowDown = event.key === 'ArrowDown';
|
|
271
|
-
const isArrowUp = event.key === 'ArrowUp';
|
|
272
|
-
|
|
273
|
-
if (!isArrowDown && !isArrowUp) return;
|
|
274
|
-
|
|
275
|
-
event.preventDefault();
|
|
276
|
-
|
|
277
|
-
const currentEl = document.getElementById(this.choiceId);
|
|
278
|
-
if (!currentEl) return;
|
|
279
|
-
|
|
280
|
-
const fieldset = currentEl.closest('fieldset');
|
|
281
|
-
if (!fieldset) return;
|
|
282
|
-
|
|
283
|
-
const groupCheckboxes = Array.from(fieldset.querySelectorAll('input[type="checkbox"]'));
|
|
284
|
-
|
|
285
|
-
const currentIndex = groupCheckboxes.findIndex((el) => el === currentEl);
|
|
286
|
-
if (currentIndex === -1) return;
|
|
287
|
-
|
|
288
|
-
const nextIndex = isArrowDown ? currentIndex + 1 : currentIndex - 1;
|
|
289
|
-
const nextEl = groupCheckboxes[nextIndex];
|
|
290
|
-
|
|
291
|
-
if (nextEl) {
|
|
292
|
-
nextEl.focus();
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
render() {
|
|
297
|
-
const {
|
|
298
|
-
choiceMode,
|
|
299
|
-
disabled,
|
|
300
|
-
displayKey,
|
|
301
|
-
feedback,
|
|
302
|
-
label,
|
|
303
|
-
correctness,
|
|
304
|
-
className,
|
|
305
|
-
rationale,
|
|
306
|
-
hideTick,
|
|
307
|
-
isEvaluateMode,
|
|
308
|
-
choicesLayout,
|
|
309
|
-
value,
|
|
310
|
-
checked,
|
|
311
|
-
tagName,
|
|
312
|
-
isSelectionButtonBelow,
|
|
313
|
-
} = this.props;
|
|
314
|
-
|
|
315
|
-
const Tag = choiceMode === 'checkbox' ? StyledCheckbox : StyledRadio;
|
|
316
|
-
const classSuffix = choiceMode === 'checkbox' ? 'checkbox' : 'radio-button';
|
|
317
|
-
|
|
318
|
-
const holderSx = {
|
|
319
|
-
...(choicesLayout === 'horizontal' && {
|
|
320
|
-
[`& .${CLASS_NAME}`]: {
|
|
321
|
-
padding: '8px',
|
|
322
|
-
margin: '4px 0 4px 4px',
|
|
323
|
-
},
|
|
324
|
-
}),
|
|
325
|
-
...(isSelectionButtonBelow && choicesLayout !== 'grid' && {
|
|
326
|
-
'& > label': {
|
|
327
|
-
alignItems: 'flex-start',
|
|
328
|
-
},
|
|
329
|
-
}),
|
|
330
|
-
...(isSelectionButtonBelow && choicesLayout === 'grid' && {
|
|
331
|
-
justifyContent: 'center',
|
|
332
|
-
'& > label': {
|
|
333
|
-
alignItems: 'center',
|
|
334
|
-
},
|
|
335
|
-
}),
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
const hasMathOrImage =
|
|
339
|
-
typeof label === 'string' &&
|
|
340
|
-
(label.includes('<math') ||
|
|
341
|
-
label.includes('\\(') ||
|
|
342
|
-
label.includes('\\[') ||
|
|
343
|
-
label.includes('<img') ||
|
|
344
|
-
label.includes('data-latex') ||
|
|
345
|
-
label.includes('data-raw') ||
|
|
346
|
-
label.includes('<mjx-container'));
|
|
347
|
-
|
|
348
|
-
const screenReaderLabel = displayKey ? (
|
|
349
|
-
<SrOnly id={this.descId}>
|
|
350
|
-
{hasMathOrImage ? `Pick the answer below, ${displayKey}` : displayKey}
|
|
351
|
-
</SrOnly>
|
|
352
|
-
) : null;
|
|
353
|
-
|
|
354
|
-
const choicelabel = (
|
|
355
|
-
<>
|
|
356
|
-
{displayKey && !isSelectionButtonBelow ? (
|
|
357
|
-
<Row component="span">
|
|
358
|
-
<span aria-hidden="true">{displayKey}.{'\u00A0'}</span>
|
|
359
|
-
<PreviewPrompt className="prompt-label" prompt={label} tagName="span" />
|
|
360
|
-
</Row>
|
|
361
|
-
) : (
|
|
362
|
-
<PreviewPrompt className="prompt-label" prompt={label} tagName="span" />
|
|
363
|
-
)}
|
|
364
|
-
</>
|
|
365
|
-
);
|
|
366
|
-
|
|
367
|
-
const tagProps = {
|
|
368
|
-
disabled,
|
|
369
|
-
checked,
|
|
370
|
-
correctness,
|
|
371
|
-
tagName,
|
|
372
|
-
value,
|
|
373
|
-
id: this.choiceId,
|
|
374
|
-
onChange: this.onToggleChoice,
|
|
375
|
-
onKeyDown: this.handleKeyDown,
|
|
376
|
-
...(screenReaderLabel ? { 'aria-describedby': this.descId } : {}),
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
const control = isSelectionButtonBelow ? (
|
|
380
|
-
<BelowSelectionComponent>
|
|
381
|
-
{screenReaderLabel}
|
|
382
|
-
<Tag {...tagProps} style={{ padding: 0 }} />
|
|
383
|
-
<span aria-hidden="true">{displayKey ? `${displayKey}.` : ''}</span>
|
|
384
|
-
</BelowSelectionComponent>
|
|
385
|
-
) : (
|
|
386
|
-
<>
|
|
387
|
-
{screenReaderLabel}
|
|
388
|
-
<Tag {...tagProps} slotProps={{ input: { ref: this.props.autoFocusRef } }} />
|
|
389
|
-
</>
|
|
390
|
-
);
|
|
391
|
-
|
|
392
|
-
return (
|
|
393
|
-
<div className={classNames(className, 'corespring-' + classSuffix, 'choice-input')}>
|
|
394
|
-
<Row>
|
|
395
|
-
{!hideTick && isEvaluateMode && <FeedbackTick correctness={correctness} />}
|
|
396
|
-
<CheckboxHolder className="checkbox-holder" sx={holderSx}>
|
|
397
|
-
<StyledFormControlLabel
|
|
398
|
-
label={choicelabel}
|
|
399
|
-
value={value}
|
|
400
|
-
htmlFor={this.choiceId}
|
|
401
|
-
labelPlacement={isSelectionButtonBelow ? 'top' : undefined}
|
|
402
|
-
control={control}
|
|
403
|
-
/>
|
|
404
|
-
</CheckboxHolder>
|
|
405
|
-
</Row>
|
|
406
|
-
{rationale && <PreviewPrompt className="rationale" defaultClassName="rationale" prompt={rationale} />}
|
|
407
|
-
<Feedback feedback={feedback} correctness={correctness} />
|
|
408
|
-
</div>
|
|
409
|
-
);
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
export default ChoiceInput;
|
package/src/delivery/choice.tsx
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
/**
|
|
3
|
-
* @synced-from pie-elements/packages/multiple-choice/src/choice.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 { styled } from '@mui/material/styles';
|
|
14
|
-
import Box from '@mui/material/Box';
|
|
15
|
-
|
|
16
|
-
import ChoiceInput from './choice-input.js';
|
|
17
|
-
|
|
18
|
-
const ChoiceContainer: any = styled(Box, {
|
|
19
|
-
shouldForwardProp: (prop) => prop !== 'noBorder' && prop !== 'horizontalLayout',
|
|
20
|
-
})(({ theme, noBorder, horizontalLayout }) => ({
|
|
21
|
-
paddingTop: theme.spacing(2.5),
|
|
22
|
-
paddingBottom: `calc(${theme.spacing(1)} + 2px)`,
|
|
23
|
-
paddingLeft: `calc(${theme.spacing(1)} + 2px)`,
|
|
24
|
-
paddingRight: `calc(${theme.spacing(1)} + 2px)`,
|
|
25
|
-
borderBottom: noBorder ? 'none' : `1px solid ${theme.palette.grey[300]}`,
|
|
26
|
-
...(horizontalLayout && {
|
|
27
|
-
paddingRight: theme.spacing(2.5),
|
|
28
|
-
'& label': {
|
|
29
|
-
marginRight: theme.spacing(1),
|
|
30
|
-
},
|
|
31
|
-
}),
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
export class Choice extends React.Component {
|
|
35
|
-
static propTypes = {};
|
|
36
|
-
|
|
37
|
-
state = {
|
|
38
|
-
isHovered: false,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
handleMouseEnter: any = () => {
|
|
42
|
-
const { disabled, checked } = this.props;
|
|
43
|
-
|
|
44
|
-
if (!disabled && !checked) {
|
|
45
|
-
this.setState({ isHovered: true });
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
handleMouseLeave: any = () => {
|
|
50
|
-
this.setState({ isHovered: false });
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
onChange: any = (choice) => {
|
|
54
|
-
const { disabled, onChoiceChanged } = this.props;
|
|
55
|
-
|
|
56
|
-
if (!disabled) {
|
|
57
|
-
onChoiceChanged(choice);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
render() {
|
|
62
|
-
const {
|
|
63
|
-
choice,
|
|
64
|
-
index,
|
|
65
|
-
choicesLength,
|
|
66
|
-
showCorrect,
|
|
67
|
-
isEvaluateMode,
|
|
68
|
-
choiceMode,
|
|
69
|
-
disabled,
|
|
70
|
-
checked,
|
|
71
|
-
correctness,
|
|
72
|
-
displayKey,
|
|
73
|
-
choicesLayout,
|
|
74
|
-
gridColumns,
|
|
75
|
-
isSelectionButtonBelow,
|
|
76
|
-
selectedAnswerBackgroundColor,
|
|
77
|
-
selectedAnswerStrokeColor,
|
|
78
|
-
selectedAnswerStrokeWidth,
|
|
79
|
-
hoverAnswerBackgroundColor,
|
|
80
|
-
hoverAnswerStrokeColor,
|
|
81
|
-
hoverAnswerStrokeWidth,
|
|
82
|
-
autoFocusRef,
|
|
83
|
-
tagName
|
|
84
|
-
} = this.props;
|
|
85
|
-
|
|
86
|
-
const { isHovered } = this.state;
|
|
87
|
-
const choiceClass = 'choice' + (index === choicesLength - 1 ? ' last' : '');
|
|
88
|
-
|
|
89
|
-
const feedback = !isEvaluateMode || showCorrect ? '' : choice.feedback;
|
|
90
|
-
|
|
91
|
-
const choiceProps = {
|
|
92
|
-
...choice,
|
|
93
|
-
checked,
|
|
94
|
-
choiceMode,
|
|
95
|
-
disabled,
|
|
96
|
-
feedback,
|
|
97
|
-
correctness,
|
|
98
|
-
displayKey,
|
|
99
|
-
index,
|
|
100
|
-
choicesLayout,
|
|
101
|
-
gridColumns,
|
|
102
|
-
onChange: this.onChange,
|
|
103
|
-
isEvaluateMode,
|
|
104
|
-
isSelectionButtonBelow,
|
|
105
|
-
selectedAnswerStrokeColor,
|
|
106
|
-
selectedAnswerStrokeWidth,
|
|
107
|
-
tagName,
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const normalizeStrokeWidth = (width) => {
|
|
111
|
-
if (!width) return '2px'; // default
|
|
112
|
-
const trimmed = String(width).trim();
|
|
113
|
-
|
|
114
|
-
// add 'px' if the value is a number
|
|
115
|
-
if (/^\d+(\.\d+)?$/.test(trimmed)) {
|
|
116
|
-
return `${trimmed}px`;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return trimmed;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const hasSelectedStroke = selectedAnswerStrokeColor && selectedAnswerStrokeColor !== 'initial';
|
|
123
|
-
const hasHoverStroke = hoverAnswerStrokeColor && hoverAnswerStrokeColor !== 'initial';
|
|
124
|
-
|
|
125
|
-
let currentStrokeColor = 'transparent';
|
|
126
|
-
let currentStrokeWidth = '2px';
|
|
127
|
-
let currentBackgroundColor = 'initial';
|
|
128
|
-
|
|
129
|
-
if ((hasSelectedStroke || hasHoverStroke)) {
|
|
130
|
-
if (checked && hasSelectedStroke) {
|
|
131
|
-
// selected state takes priority when selected stroke is configured
|
|
132
|
-
currentStrokeColor = selectedAnswerStrokeColor;
|
|
133
|
-
currentStrokeWidth = selectedAnswerStrokeWidth;
|
|
134
|
-
} else if (isHovered && !disabled && hasHoverStroke) {
|
|
135
|
-
// hover state when not selected and not disabled, and hover stroke is configured
|
|
136
|
-
currentStrokeColor = hoverAnswerStrokeColor;
|
|
137
|
-
currentStrokeWidth = hoverAnswerStrokeWidth;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (checked && selectedAnswerBackgroundColor && selectedAnswerBackgroundColor !== 'initial') {
|
|
142
|
-
currentBackgroundColor = selectedAnswerBackgroundColor;
|
|
143
|
-
} else if (isHovered && !disabled && hoverAnswerBackgroundColor && hoverAnswerBackgroundColor !== 'initial') {
|
|
144
|
-
currentBackgroundColor = hoverAnswerBackgroundColor;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const hasStroke = hasSelectedStroke || hasHoverStroke;
|
|
148
|
-
const strokeStyle = hasStroke ? {
|
|
149
|
-
border: `${normalizeStrokeWidth(currentStrokeWidth)} solid ${currentStrokeColor}`,
|
|
150
|
-
borderRadius: '8px',
|
|
151
|
-
} : {};
|
|
152
|
-
|
|
153
|
-
const noBorder = index === choicesLength - 1 || choicesLayout !== 'vertical' || hasStroke;
|
|
154
|
-
const horizontalLayout = choicesLayout === 'horizontal';
|
|
155
|
-
|
|
156
|
-
const choiceBackground = currentBackgroundColor !== 'initial' ? currentBackgroundColor : 'initial';
|
|
157
|
-
|
|
158
|
-
return (
|
|
159
|
-
<div
|
|
160
|
-
className={choiceClass}
|
|
161
|
-
key={index}
|
|
162
|
-
style={{ backgroundColor: choiceBackground, ...strokeStyle }}
|
|
163
|
-
onMouseEnter={this.handleMouseEnter}
|
|
164
|
-
onMouseLeave={this.handleMouseLeave}
|
|
165
|
-
>
|
|
166
|
-
<ChoiceContainer
|
|
167
|
-
component="div"
|
|
168
|
-
noBorder={noBorder}
|
|
169
|
-
horizontalLayout={horizontalLayout}
|
|
170
|
-
>
|
|
171
|
-
<ChoiceInput {...choiceProps} autoFocusRef={autoFocusRef} />
|
|
172
|
-
</ChoiceContainer>
|
|
173
|
-
</div>
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
Choice.propTypes = {
|
|
179
|
-
choiceMode: PropTypes.oneOf(['radio', 'checkbox']),
|
|
180
|
-
choice: PropTypes.object,
|
|
181
|
-
disabled: PropTypes.bool.isRequired,
|
|
182
|
-
onChoiceChanged: PropTypes.func,
|
|
183
|
-
index: PropTypes.number,
|
|
184
|
-
choicesLength: PropTypes.number,
|
|
185
|
-
showCorrect: PropTypes.bool,
|
|
186
|
-
isEvaluateMode: PropTypes.bool,
|
|
187
|
-
checked: PropTypes.bool,
|
|
188
|
-
correctness: PropTypes.string,
|
|
189
|
-
displayKey: PropTypes.string,
|
|
190
|
-
choicesLayout: PropTypes.oneOf(['vertical', 'grid', 'horizontal']),
|
|
191
|
-
gridColumns: PropTypes.string,
|
|
192
|
-
selectedAnswerBackgroundColor: PropTypes.string,
|
|
193
|
-
selectedAnswerStrokeColor: PropTypes.string,
|
|
194
|
-
selectedAnswerStrokeWidth: PropTypes.string,
|
|
195
|
-
hoverAnswerBackgroundColor: PropTypes.string,
|
|
196
|
-
hoverAnswerStrokeColor: PropTypes.string,
|
|
197
|
-
hoverAnswerStrokeWidth: PropTypes.string,
|
|
198
|
-
tagName: PropTypes.string,
|
|
199
|
-
isSelectionButtonBelow: PropTypes.bool,
|
|
200
|
-
autoFocusRef: PropTypes.object,
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
export default Choice;
|