@pie-element/image-cloze-association 0.1.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 +89 -0
- package/dist/author/defaults.d.ts.map +1 -0
- package/dist/author/defaults.js +58 -0
- package/dist/author/index.d.ts +35 -0
- package/dist/author/index.d.ts.map +1 -0
- package/dist/author/index.js +71 -0
- package/dist/author/root.d.ts +15 -0
- package/dist/author/root.d.ts.map +1 -0
- package/dist/author/root.js +80 -0
- package/dist/controller/defaults.d.ts +17 -0
- package/dist/controller/defaults.d.ts.map +1 -0
- package/dist/controller/defaults.js +10 -0
- package/dist/controller/index.d.ts +24 -0
- package/dist/controller/index.d.ts.map +1 -0
- package/dist/controller/index.js +124 -0
- package/dist/controller/utils.d.ts +15 -0
- package/dist/controller/utils.d.ts.map +1 -0
- package/dist/controller/utils.js +36 -0
- package/dist/delivery/constants.d.ts +15 -0
- package/dist/delivery/constants.d.ts.map +1 -0
- package/dist/delivery/evaluation-icon.d.ts +29 -0
- package/dist/delivery/evaluation-icon.d.ts.map +1 -0
- package/dist/delivery/evaluation-icon.js +38 -0
- package/dist/delivery/image-container.d.ts +14 -0
- package/dist/delivery/image-container.d.ts.map +1 -0
- package/dist/delivery/image-container.js +61 -0
- package/dist/delivery/image-drop-target.d.ts +46 -0
- package/dist/delivery/image-drop-target.d.ts.map +1 -0
- package/dist/delivery/image-drop-target.js +90 -0
- package/dist/delivery/index.d.ts +21 -0
- package/dist/delivery/index.d.ts.map +1 -0
- package/dist/delivery/index.js +110 -0
- package/dist/delivery/interactive-section.d.ts +16 -0
- package/dist/delivery/interactive-section.d.ts.map +1 -0
- package/dist/delivery/interactive-section.js +72 -0
- package/dist/delivery/possible-response.d.ts +35 -0
- package/dist/delivery/possible-response.d.ts.map +1 -0
- package/dist/delivery/possible-response.js +100 -0
- package/dist/delivery/possible-responses.d.ts +32 -0
- package/dist/delivery/possible-responses.d.ts.map +1 -0
- package/dist/delivery/possible-responses.js +41 -0
- package/dist/delivery/root.d.ts +22 -0
- package/dist/delivery/root.d.ts.map +1 -0
- package/dist/delivery/root.js +279 -0
- package/dist/delivery/static-html-span.d.ts +15 -0
- package/dist/delivery/static-html-span.d.ts.map +1 -0
- package/dist/delivery/static-html-span.js +22 -0
- package/dist/delivery/utils-correctness.d.ts +11 -0
- package/dist/delivery/utils-correctness.d.ts.map +1 -0
- package/dist/delivery/utils-correctness.js +43 -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 +160 -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/_arrayAggregator.js +10 -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/_arrayMap.js +7 -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/_arrayShuffle.js +8 -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/_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/_baseAggregator.js +9 -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/_baseEach.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseFlatten.js +13 -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/_baseForOwn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGet.js +10 -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/_baseHasIn.js +6 -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/_baseIsMatch.js +26 -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/_baseIteratee.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/_baseMap.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseMatches.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseMatchesProperty.js +17 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseProperty.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_basePropertyDeep.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseRandom.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseShuffle.js +8 -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/_baseToString.js +15 -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/_baseValues.js +9 -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/_castPath.js +10 -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/_createAggregator.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_createBaseEach.js +12 -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/_getMatchData.js +16 -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/_hasPath.js +18 -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/_isFlattenable.js +10 -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/_isKey.js +11 -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/_isStrictComparable.js +7 -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/_matchesStrictComparable.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_memoizeCapped.js +11 -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/_root.js +5 -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/_shuffleSelf.js +12 -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/_stringToPath.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toKey.js +10 -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/cloneDeep.js +8 -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/flatMap.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/get.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/groupBy.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/hasIn.js +8 -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/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/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/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/map.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/memoize.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/property.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/shuffle.js +9 -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/toString.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/values.js +8 -0
- package/package.json +75 -0
- package/src/author/defaults.ts +69 -0
- package/src/author/index.ts +124 -0
- package/src/author/root.tsx +126 -0
- package/src/controller/defaults.ts +17 -0
- package/src/controller/index.ts +332 -0
- package/src/controller/utils.ts +82 -0
- package/src/delivery/constants.ts +15 -0
- package/src/delivery/evaluation-icon.tsx +64 -0
- package/src/delivery/image-container.tsx +100 -0
- package/src/delivery/image-drop-target.tsx +150 -0
- package/src/delivery/index.ts +283 -0
- package/src/delivery/interactive-section.tsx +104 -0
- package/src/delivery/possible-response.tsx +162 -0
- package/src/delivery/possible-responses.tsx +62 -0
- package/src/delivery/root.tsx +530 -0
- package/src/delivery/static-html-span.tsx +40 -0
- package/src/delivery/utils-correctness.ts +105 -0
- package/src/index.iife.ts +16 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/image-cloze-association/src/image-drop-target.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, { useEffect, useRef, useState } from 'react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import { useDroppable } from '@dnd-kit/core';
|
|
14
|
+
import { styled } from '@mui/material/styles';
|
|
15
|
+
import { color } from '@pie-lib/render-ui';
|
|
16
|
+
import cx from 'classnames';
|
|
17
|
+
|
|
18
|
+
import PossibleResponse from './possible-response.js';
|
|
19
|
+
|
|
20
|
+
const AnswersContainer: any = styled('div')(() => ({
|
|
21
|
+
display: 'flex',
|
|
22
|
+
flexWrap: 'wrap',
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
const ResponseContainer: any = styled('div')(() => ({
|
|
26
|
+
position: 'absolute',
|
|
27
|
+
boxSizing: 'border-box',
|
|
28
|
+
'&.active': {
|
|
29
|
+
border: `2px solid ${color.text()}`,
|
|
30
|
+
backgroundColor: 'rgba(230, 242, 252, .8)',
|
|
31
|
+
},
|
|
32
|
+
'&.dashed': {
|
|
33
|
+
border: `2px dashed ${color.text()}`,
|
|
34
|
+
},
|
|
35
|
+
'&.is-over': {
|
|
36
|
+
border: '1px solid rgb(158, 158, 158)',
|
|
37
|
+
backgroundColor: 'rgb(224, 224, 224)',
|
|
38
|
+
},
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
const ImageDropTarget = ({
|
|
42
|
+
answers,
|
|
43
|
+
canDrag,
|
|
44
|
+
containerStyle,
|
|
45
|
+
draggingElement,
|
|
46
|
+
onDragAnswerBegin,
|
|
47
|
+
onDragAnswerEnd,
|
|
48
|
+
showDashedBorder,
|
|
49
|
+
responseAreaFill,
|
|
50
|
+
responseContainerPadding = '10px',
|
|
51
|
+
imageDropTargetPadding,
|
|
52
|
+
answerChoiceTransparency,
|
|
53
|
+
maxResponsePerZone,
|
|
54
|
+
onDrop,
|
|
55
|
+
index,
|
|
56
|
+
}) => {
|
|
57
|
+
const [shouldHaveSmallPadding, setShouldHaveSmallPadding] = useState(false);
|
|
58
|
+
const dropContainerRef = useRef(null);
|
|
59
|
+
const dropContainerResponsesHeightRef = useRef(null);
|
|
60
|
+
|
|
61
|
+
const { setNodeRef, isOver } = useDroppable({
|
|
62
|
+
id: `response-container-${index}`,
|
|
63
|
+
data: {
|
|
64
|
+
containerIndex: index,
|
|
65
|
+
onDrop,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
const container = dropContainerRef.current;
|
|
71
|
+
|
|
72
|
+
if (!container) return;
|
|
73
|
+
|
|
74
|
+
const handleTouchStart = (e) => {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
container.addEventListener('touchstart', handleTouchStart, { passive: false });
|
|
79
|
+
|
|
80
|
+
return () => {
|
|
81
|
+
container.removeEventListener('touchstart', handleTouchStart);
|
|
82
|
+
};
|
|
83
|
+
}, []);
|
|
84
|
+
|
|
85
|
+
const isDraggingElement = !!draggingElement.id;
|
|
86
|
+
|
|
87
|
+
const containerClasses = cx({
|
|
88
|
+
'is-over': isOver,
|
|
89
|
+
dashed: showDashedBorder && !isDraggingElement,
|
|
90
|
+
active: isDraggingElement,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const updatedContainerStyle = {
|
|
94
|
+
padding: maxResponsePerZone === 1 ? '0' : responseContainerPadding,
|
|
95
|
+
...containerStyle,
|
|
96
|
+
...(responseAreaFill && !isDraggingElement && { backgroundColor: responseAreaFill }),
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<ResponseContainer
|
|
101
|
+
ref={(ref) => {
|
|
102
|
+
dropContainerRef.current = ref;
|
|
103
|
+
setNodeRef(ref);
|
|
104
|
+
}}
|
|
105
|
+
className={containerClasses}
|
|
106
|
+
style={updatedContainerStyle}
|
|
107
|
+
>
|
|
108
|
+
{answers.length ? (
|
|
109
|
+
<AnswersContainer
|
|
110
|
+
ref={(ref) => {
|
|
111
|
+
dropContainerResponsesHeightRef.current = ref?.getBoundingClientRect().height;
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
{answers.map((answer) => (
|
|
115
|
+
<PossibleResponse
|
|
116
|
+
key={answer.id}
|
|
117
|
+
data={answer}
|
|
118
|
+
canDrag={canDrag}
|
|
119
|
+
onDragBegin={() => onDragAnswerBegin(answer)}
|
|
120
|
+
onDragEnd={onDragAnswerEnd}
|
|
121
|
+
answerChoiceTransparency={answerChoiceTransparency}
|
|
122
|
+
containerStyle={{
|
|
123
|
+
padding: imageDropTargetPadding ? imageDropTargetPadding : shouldHaveSmallPadding ? '2px' : '6px 10px',
|
|
124
|
+
}}
|
|
125
|
+
/>
|
|
126
|
+
))}
|
|
127
|
+
</AnswersContainer>
|
|
128
|
+
) : null}
|
|
129
|
+
</ResponseContainer>
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
ImageDropTarget.propTypes = {
|
|
134
|
+
answer: PropTypes.object,
|
|
135
|
+
answers: PropTypes.array,
|
|
136
|
+
canDrag: PropTypes.bool.isRequired,
|
|
137
|
+
containerStyle: PropTypes.object.isRequired,
|
|
138
|
+
draggingElement: PropTypes.object.isRequired,
|
|
139
|
+
onDragAnswerBegin: PropTypes.func.isRequired,
|
|
140
|
+
onDragAnswerEnd: PropTypes.func.isRequired,
|
|
141
|
+
onDrop: PropTypes.func.isRequired,
|
|
142
|
+
showDashedBorder: PropTypes.bool,
|
|
143
|
+
responseAreaFill: PropTypes.string,
|
|
144
|
+
answerChoiceTransparency: PropTypes.bool,
|
|
145
|
+
responseContainerPadding: PropTypes.string,
|
|
146
|
+
imageDropTargetPadding: PropTypes.string,
|
|
147
|
+
maxResponsePerZone: PropTypes.number,
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export default ImageDropTarget;
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/image-cloze-association/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 React from 'react';
|
|
12
|
+
import { createRoot } from 'react-dom/client';
|
|
13
|
+
import { renderMath } from '@pie-element/shared-math-rendering-mathjax';
|
|
14
|
+
import { EnableAudioAutoplayImage as EnableAudioAutoplayImageImport } from '@pie-lib/render-ui';
|
|
15
|
+
|
|
16
|
+
function isRenderableReactInteropType(value: any) {
|
|
17
|
+
return (
|
|
18
|
+
typeof value === 'function' ||
|
|
19
|
+
(typeof value === 'object' && value !== null && typeof value.$$typeof === 'symbol')
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function unwrapReactInteropSymbol(maybeSymbol: any, namedExport?: string) {
|
|
24
|
+
if (!maybeSymbol) return maybeSymbol;
|
|
25
|
+
if (isRenderableReactInteropType(maybeSymbol)) return maybeSymbol;
|
|
26
|
+
if (isRenderableReactInteropType(maybeSymbol.default)) return maybeSymbol.default;
|
|
27
|
+
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport])) {
|
|
28
|
+
return maybeSymbol[namedExport];
|
|
29
|
+
}
|
|
30
|
+
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport]?.default)) {
|
|
31
|
+
return maybeSymbol[namedExport].default;
|
|
32
|
+
}
|
|
33
|
+
return maybeSymbol;
|
|
34
|
+
}
|
|
35
|
+
const EnableAudioAutoplayImage = unwrapReactInteropSymbol(EnableAudioAutoplayImageImport, 'EnableAudioAutoplayImage') || unwrapReactInteropSymbol(renderUi.EnableAudioAutoplayImage, 'EnableAudioAutoplayImage');
|
|
36
|
+
import * as RenderUiNamespace from '@pie-lib/render-ui';
|
|
37
|
+
const renderUiNamespaceAny = RenderUiNamespace as any;
|
|
38
|
+
const renderUiDefaultMaybe = renderUiNamespaceAny['default'];
|
|
39
|
+
const renderUi =
|
|
40
|
+
renderUiDefaultMaybe && typeof renderUiDefaultMaybe === 'object'
|
|
41
|
+
? renderUiDefaultMaybe
|
|
42
|
+
: renderUiNamespaceAny;
|
|
43
|
+
import { ModelSetEvent, SessionChangedEvent } from '@pie-element/shared-player-events';
|
|
44
|
+
|
|
45
|
+
import ImageClozeAssociationComponent from './root.js';
|
|
46
|
+
|
|
47
|
+
export default class ImageClozeAssociation extends HTMLElement {
|
|
48
|
+
constructor() {
|
|
49
|
+
super();
|
|
50
|
+
this._root = null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
set model(m) {
|
|
54
|
+
this._model = m;
|
|
55
|
+
|
|
56
|
+
this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), this.isComplete(), !!this._model));
|
|
57
|
+
this._render();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
isComplete() {
|
|
61
|
+
const {
|
|
62
|
+
autoplayAudioEnabled,
|
|
63
|
+
completeAudioEnabled,
|
|
64
|
+
completeResponses,
|
|
65
|
+
duplicateResponses,
|
|
66
|
+
hasUnplacedChoices,
|
|
67
|
+
maxResponsePerZone,
|
|
68
|
+
responseAreasToBeFilled,
|
|
69
|
+
} = this._model || {};
|
|
70
|
+
const elementContext = this;
|
|
71
|
+
|
|
72
|
+
// check audio completion if audio settings are enabled and audio actually exists
|
|
73
|
+
if (autoplayAudioEnabled && completeAudioEnabled && !this.audioComplete) {
|
|
74
|
+
if (elementContext) {
|
|
75
|
+
const audio = elementContext.querySelector('audio');
|
|
76
|
+
const isInsidePrompt = audio && audio.closest('#preview-prompt');
|
|
77
|
+
|
|
78
|
+
// only require audio completion if audio exists and is inside the prompt
|
|
79
|
+
if (audio && isInsidePrompt) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!this._session || !this._session.answers) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const { answers } = this._session;
|
|
90
|
+
|
|
91
|
+
if (!Array.isArray(answers)) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// filter answers by containerIndex and count the ones with content
|
|
96
|
+
const filledResponseAreas = [...new Map(answers.map((item) => [item.containerIndex, item])).values()].length;
|
|
97
|
+
// check if an answer choice was added to at least as many response areas
|
|
98
|
+
// as the number of populated response areas in the correct answer
|
|
99
|
+
const areResponseAreasFilled = filledResponseAreas >= responseAreasToBeFilled;
|
|
100
|
+
|
|
101
|
+
if (maxResponsePerZone > 1) {
|
|
102
|
+
if (duplicateResponses) {
|
|
103
|
+
// an answer choice can be used multiple times
|
|
104
|
+
return areResponseAreasFilled;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// any correct answer have any unplaced answer choices (by the author)
|
|
108
|
+
if (hasUnplacedChoices) {
|
|
109
|
+
return areResponseAreasFilled;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const allAnswersValue = answers.map((answer) => answer.value);
|
|
113
|
+
|
|
114
|
+
// check if any correct answer have any unplaced answer choices (by the student)
|
|
115
|
+
const requiredAnswersPlaced = completeResponses.some((response) =>
|
|
116
|
+
response.every((val) => allAnswersValue.includes(val)),
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
// true - all choices (required for a correct response) were placed into a response area
|
|
120
|
+
return requiredAnswersPlaced;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return areResponseAreasFilled;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
set session(s) {
|
|
127
|
+
if (s && !s.answers) {
|
|
128
|
+
s.answers = [];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
this._session = s;
|
|
132
|
+
this._render();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
get session() {
|
|
136
|
+
return this._session;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
updateAnswer(data) {
|
|
140
|
+
this._session.answers = data;
|
|
141
|
+
this._session.selector = 'Mouse';
|
|
142
|
+
|
|
143
|
+
this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));
|
|
144
|
+
|
|
145
|
+
this._render();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
_createAudioInfoToast() {
|
|
149
|
+
const info = document.createElement('div');
|
|
150
|
+
info.id = 'play-audio-info';
|
|
151
|
+
|
|
152
|
+
Object.assign(info.style, {
|
|
153
|
+
position: 'absolute',
|
|
154
|
+
top: 0,
|
|
155
|
+
width: '100%',
|
|
156
|
+
height: '100%',
|
|
157
|
+
display: 'flex',
|
|
158
|
+
justifyContent: 'center',
|
|
159
|
+
alignItems: 'center',
|
|
160
|
+
background: 'white',
|
|
161
|
+
zIndex: '1000',
|
|
162
|
+
cursor: 'pointer',
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const img = document.createElement('img');
|
|
166
|
+
img.src = EnableAudioAutoplayImage;
|
|
167
|
+
img.alt = 'Click anywhere to enable audio autoplay';
|
|
168
|
+
img.width = 500;
|
|
169
|
+
img.height = 300;
|
|
170
|
+
|
|
171
|
+
info.appendChild(img);
|
|
172
|
+
return info;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
connectedCallback() {
|
|
176
|
+
this._render();
|
|
177
|
+
|
|
178
|
+
// Observation: audio in Chrome will have the autoplay attribute,
|
|
179
|
+
// while other browsers will not have the autoplay attribute and will need a user interaction to play the audio
|
|
180
|
+
// This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox
|
|
181
|
+
const observer = new MutationObserver((mutationsList, observer) => {
|
|
182
|
+
mutationsList.forEach((mutation) => {
|
|
183
|
+
if (mutation.type === 'childList') {
|
|
184
|
+
const audio = this.querySelector('audio');
|
|
185
|
+
const isInsidePrompt = audio && audio.closest('#preview-prompt');
|
|
186
|
+
|
|
187
|
+
if (!this._model) return;
|
|
188
|
+
if (!this._model.autoplayAudioEnabled) return;
|
|
189
|
+
if (audio && !isInsidePrompt) return;
|
|
190
|
+
if (!audio) return;
|
|
191
|
+
|
|
192
|
+
const info = this._createAudioInfoToast();
|
|
193
|
+
const container = this.querySelector('#main-container');
|
|
194
|
+
const enableAudio = () => {
|
|
195
|
+
if (this.querySelector('#play-audio-info')) {
|
|
196
|
+
audio.play();
|
|
197
|
+
container.removeChild(info);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
document.removeEventListener('click', enableAudio);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
// if the audio is paused, it means the user has not interacted with the page yet and the audio will not play
|
|
204
|
+
// FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked
|
|
205
|
+
setTimeout(() => {
|
|
206
|
+
if (audio.paused && !this.querySelector('#play-audio-info')) {
|
|
207
|
+
// add info message as a toast to enable audio playback
|
|
208
|
+
container.appendChild(info);
|
|
209
|
+
document.addEventListener('click', enableAudio);
|
|
210
|
+
} else {
|
|
211
|
+
document.removeEventListener('click', enableAudio);
|
|
212
|
+
}
|
|
213
|
+
}, 500);
|
|
214
|
+
|
|
215
|
+
// we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering
|
|
216
|
+
const handlePlaying = () => {
|
|
217
|
+
const info = this.querySelector('#play-audio-info');
|
|
218
|
+
|
|
219
|
+
if (info) {
|
|
220
|
+
container.removeChild(info);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
audio.removeEventListener('playing', handlePlaying);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
audio.addEventListener('playing', handlePlaying);
|
|
227
|
+
|
|
228
|
+
// we need to listen for the ended event to update the isComplete state
|
|
229
|
+
const handleEnded = () => {
|
|
230
|
+
this.audioComplete = true;
|
|
231
|
+
this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));
|
|
232
|
+
|
|
233
|
+
audio.removeEventListener('ended', handleEnded);
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
audio.addEventListener('ended', handleEnded);
|
|
237
|
+
|
|
238
|
+
// store references to remove later
|
|
239
|
+
this._audio = audio;
|
|
240
|
+
this._handlePlaying = handlePlaying;
|
|
241
|
+
this._handleEnded = handleEnded;
|
|
242
|
+
this._enableAudio = enableAudio;
|
|
243
|
+
|
|
244
|
+
observer.disconnect();
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
observer.observe(this, { childList: true, subtree: true });
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
disconnectedCallback() {
|
|
253
|
+
document.removeEventListener('click', this._enableAudio);
|
|
254
|
+
|
|
255
|
+
if (this._audio) {
|
|
256
|
+
this._audio.removeEventListener('playing', this._handlePlaying);
|
|
257
|
+
this._audio.removeEventListener('ended', this._handleEnded);
|
|
258
|
+
this._audio = null;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (this._root) {
|
|
262
|
+
this._root.unmount();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
_render() {
|
|
267
|
+
if (this._model && this._session) {
|
|
268
|
+
const el = React.createElement(ImageClozeAssociationComponent, {
|
|
269
|
+
model: this._model,
|
|
270
|
+
session: this._session,
|
|
271
|
+
updateAnswer: this.updateAnswer.bind(this),
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
if (!this._root) {
|
|
275
|
+
this._root = createRoot(this);
|
|
276
|
+
}
|
|
277
|
+
this._root.render(el);
|
|
278
|
+
queueMicrotask(() => {
|
|
279
|
+
renderMath(this);
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/image-cloze-association/src/interactive-section.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 { color } from '@pie-lib/render-ui';
|
|
15
|
+
|
|
16
|
+
import EvaluationIcon from './evaluation-icon.js';
|
|
17
|
+
|
|
18
|
+
const StyledContainer: any = styled('div')(({ theme }) => ({
|
|
19
|
+
marginTop: theme.spacing(2),
|
|
20
|
+
display: 'flex',
|
|
21
|
+
width: 'fit-content',
|
|
22
|
+
'&.default': {
|
|
23
|
+
border: `1px solid ${color.disabled()}`,
|
|
24
|
+
},
|
|
25
|
+
'&.correct': {
|
|
26
|
+
border: `2px solid ${color.correct()}`,
|
|
27
|
+
},
|
|
28
|
+
'&.incorrect': {
|
|
29
|
+
border: `2px solid ${color.incorrect()}`,
|
|
30
|
+
},
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
class InteractiveSection extends React.Component {
|
|
34
|
+
getClassname() {
|
|
35
|
+
const { responseCorrect } = this.props;
|
|
36
|
+
let styleProp;
|
|
37
|
+
|
|
38
|
+
switch (responseCorrect) {
|
|
39
|
+
case undefined:
|
|
40
|
+
styleProp = 'default';
|
|
41
|
+
break;
|
|
42
|
+
case true:
|
|
43
|
+
styleProp = 'correct';
|
|
44
|
+
break;
|
|
45
|
+
default:
|
|
46
|
+
styleProp = 'incorrect';
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
return styleProp;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
getPositionDirection(choicePosition) {
|
|
53
|
+
let flexDirection;
|
|
54
|
+
|
|
55
|
+
switch (choicePosition) {
|
|
56
|
+
case 'left':
|
|
57
|
+
flexDirection = 'row-reverse';
|
|
58
|
+
break;
|
|
59
|
+
case 'right':
|
|
60
|
+
flexDirection = 'row';
|
|
61
|
+
break;
|
|
62
|
+
case 'top':
|
|
63
|
+
flexDirection = 'column-reverse';
|
|
64
|
+
break;
|
|
65
|
+
default:
|
|
66
|
+
// bottom
|
|
67
|
+
flexDirection = 'column';
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return flexDirection;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
render() {
|
|
75
|
+
const { children, responseCorrect, uiStyle } = this.props;
|
|
76
|
+
const classname = this.getClassname();
|
|
77
|
+
const { possibilityListPosition = 'bottom' } = uiStyle || {};
|
|
78
|
+
const style = { flexDirection: this.getPositionDirection(possibilityListPosition) };
|
|
79
|
+
const evaluationStyle = {
|
|
80
|
+
display: 'flex',
|
|
81
|
+
margin: '0 auto',
|
|
82
|
+
marginTop: -14,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<StyledContainer className={classname} style={style}>
|
|
87
|
+
<EvaluationIcon containerStyle={evaluationStyle} filled isCorrect={responseCorrect} />
|
|
88
|
+
{children}
|
|
89
|
+
</StyledContainer>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
InteractiveSection.propTypes = {
|
|
95
|
+
children: PropTypes.oneOfType([PropTypes.element, PropTypes.array]).isRequired,
|
|
96
|
+
responseCorrect: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]),
|
|
97
|
+
uiStyle: PropTypes.object,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
InteractiveSection.defaultProps = {
|
|
101
|
+
responseCorrect: undefined,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export default InteractiveSection;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/image-cloze-association/src/possible-response.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, { useEffect, useRef } from 'react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import classNames from 'classnames';
|
|
14
|
+
import { styled } from '@mui/material/styles';
|
|
15
|
+
import { useDraggable } from '@dnd-kit/core';
|
|
16
|
+
import { color } from '@pie-lib/render-ui';
|
|
17
|
+
|
|
18
|
+
import EvaluationIcon from './evaluation-icon.js';
|
|
19
|
+
import StaticHTMLSpan from './static-html-span.js';
|
|
20
|
+
|
|
21
|
+
const BaseContainer: any = styled('div')(() => ({
|
|
22
|
+
position: 'relative',
|
|
23
|
+
backgroundColor: color.white(),
|
|
24
|
+
border: `1px solid ${color.borderDark()}`,
|
|
25
|
+
display: 'flex',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
justifyContent: 'center',
|
|
28
|
+
minHeight: '28px',
|
|
29
|
+
width: 'fit-content',
|
|
30
|
+
'& span img': {
|
|
31
|
+
// Added for touch devices, for image content.
|
|
32
|
+
// This will prevent the context menu from appearing and not allowing other interactions with the image.
|
|
33
|
+
// If interactions with the image in the token will be requested we should handle only the context Menu.
|
|
34
|
+
pointerEvents: 'none',
|
|
35
|
+
},
|
|
36
|
+
'&.textAnswerChoiceStyle': {
|
|
37
|
+
padding: '0 10px',
|
|
38
|
+
margin: '4px 6px !important',
|
|
39
|
+
},
|
|
40
|
+
'&.answerChoiceTransparency': {
|
|
41
|
+
border: 'none',
|
|
42
|
+
backgroundColor: `${color.transparent()}`,
|
|
43
|
+
'&:hover': {
|
|
44
|
+
border: `1px solid ${color.borderDark()}`,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
'&.baseCorrect': {
|
|
48
|
+
border: `2px solid ${color.correct()} !important`,
|
|
49
|
+
},
|
|
50
|
+
'&.baseIncorrect': {
|
|
51
|
+
border: `2px solid ${color.incorrect()} !important`,
|
|
52
|
+
},
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
const StyledSpan: any = styled(StaticHTMLSpan)(() => ({
|
|
56
|
+
cursor: 'grab',
|
|
57
|
+
backgroundColor: color.background(),
|
|
58
|
+
'&.hiddenSpan': {
|
|
59
|
+
visibility: 'hidden',
|
|
60
|
+
},
|
|
61
|
+
}));
|
|
62
|
+
|
|
63
|
+
const PossibleResponse = ({ canDrag, containerStyle, data, onDragBegin, answerChoiceTransparency, isOverlay }) => {
|
|
64
|
+
const rootRef = useRef(null);
|
|
65
|
+
const longPressTimer = useRef(null);
|
|
66
|
+
|
|
67
|
+
const { setNodeRef, attributes, listeners, isDragging } = useDraggable({
|
|
68
|
+
id: `possible-response-${data.id}`,
|
|
69
|
+
data: {
|
|
70
|
+
id: data.id,
|
|
71
|
+
value: data.value,
|
|
72
|
+
containerIndex: data.containerIndex,
|
|
73
|
+
},
|
|
74
|
+
disabled: !canDrag,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const handleTouchEnd = () => {
|
|
78
|
+
clearTimeout(longPressTimer.current);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const handleTouchMove = () => {
|
|
82
|
+
clearTimeout(longPressTimer.current);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const handleTouchStart = (e) => {
|
|
86
|
+
e.preventDefault();
|
|
87
|
+
longPressTimer.current = setTimeout(() => {
|
|
88
|
+
if (canDrag && rootRef.current) {
|
|
89
|
+
onDragBegin(data);
|
|
90
|
+
}
|
|
91
|
+
}, 500); // start drag after 500ms (touch and hold duration) for chromebooks and other touch devices
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
const node = rootRef.current;
|
|
96
|
+
|
|
97
|
+
if (!node) return;
|
|
98
|
+
|
|
99
|
+
node.addEventListener('touchstart', handleTouchStart, { passive: false });
|
|
100
|
+
node.addEventListener('touchend', handleTouchEnd);
|
|
101
|
+
node.addEventListener('touchmove', handleTouchMove, { passive: false });
|
|
102
|
+
|
|
103
|
+
return () => {
|
|
104
|
+
node.removeEventListener('touchstart', handleTouchStart);
|
|
105
|
+
node.removeEventListener('touchend', handleTouchEnd);
|
|
106
|
+
node.removeEventListener('touchmove', handleTouchMove);
|
|
107
|
+
};
|
|
108
|
+
}, [canDrag, data]);
|
|
109
|
+
|
|
110
|
+
const { isCorrect } = data || {};
|
|
111
|
+
const evaluationStyle = {
|
|
112
|
+
fontSize: 14,
|
|
113
|
+
position: 'absolute',
|
|
114
|
+
bottom: '3px',
|
|
115
|
+
right: '3px',
|
|
116
|
+
};
|
|
117
|
+
const correctnessClass = isCorrect === true ? 'baseCorrect' : isCorrect === false ? 'baseIncorrect' : undefined;
|
|
118
|
+
|
|
119
|
+
const imgRegex = /<img[^>]+src="([^">]+)"/;
|
|
120
|
+
const containsImage = imgRegex.test(data.value);
|
|
121
|
+
|
|
122
|
+
const containerClassNames = classNames({
|
|
123
|
+
answerChoiceTransparency: answerChoiceTransparency && !isDragging,
|
|
124
|
+
[correctnessClass]: !!correctnessClass,
|
|
125
|
+
textAnswerChoiceStyle: !containsImage && !isOverlay,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const promptClassNames = classNames({ hiddenSpan: data.hidden });
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<BaseContainer
|
|
132
|
+
className={containerClassNames}
|
|
133
|
+
style={containerStyle}
|
|
134
|
+
ref={(ref) => {
|
|
135
|
+
rootRef.current = ref;
|
|
136
|
+
setNodeRef(ref);
|
|
137
|
+
}}
|
|
138
|
+
{...listeners}
|
|
139
|
+
{...attributes}
|
|
140
|
+
>
|
|
141
|
+
<StyledSpan html={data.value} className={promptClassNames} />
|
|
142
|
+
<EvaluationIcon isCorrect={data.isCorrect} containerStyle={evaluationStyle} />
|
|
143
|
+
</BaseContainer>
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
PossibleResponse.propTypes = {
|
|
148
|
+
canDrag: PropTypes.bool.isRequired,
|
|
149
|
+
containerStyle: PropTypes.object,
|
|
150
|
+
data: PropTypes.object.isRequired,
|
|
151
|
+
onDragBegin: PropTypes.func.isRequired,
|
|
152
|
+
answerChoiceTransparency: PropTypes.bool,
|
|
153
|
+
isOverlay: PropTypes.bool,
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
PossibleResponse.defaultProps = {
|
|
157
|
+
containerStyle: {},
|
|
158
|
+
answerChoiceTransparency: false,
|
|
159
|
+
isOverlay: false,
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export default PossibleResponse;
|