@pie-element/categorize 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 +224 -0
- package/dist/author/defaults.d.ts.map +1 -0
- package/dist/author/defaults.js +170 -0
- package/dist/author/design/builder.d.ts +11 -0
- package/dist/author/design/builder.d.ts.map +1 -0
- package/dist/author/design/builder.js +24 -0
- package/dist/author/design/buttons.d.ts +29 -0
- package/dist/author/design/buttons.d.ts.map +1 -0
- package/dist/author/design/buttons.js +36 -0
- package/dist/author/design/categories/RowLabel.d.ts +24 -0
- package/dist/author/design/categories/RowLabel.d.ts.map +1 -0
- package/dist/author/design/categories/RowLabel.js +46 -0
- package/dist/author/design/categories/alternateResponses.d.ts +32 -0
- package/dist/author/design/categories/alternateResponses.d.ts.map +1 -0
- package/dist/author/design/categories/alternateResponses.js +62 -0
- package/dist/author/design/categories/category.d.ts +45 -0
- package/dist/author/design/categories/category.d.ts.map +1 -0
- package/dist/author/design/categories/category.js +102 -0
- package/dist/author/design/categories/choice-preview.d.ts +26 -0
- package/dist/author/design/categories/choice-preview.d.ts.map +1 -0
- package/dist/author/design/categories/choice-preview.js +60 -0
- package/dist/author/design/categories/droppable-placeholder.d.ts +11 -0
- package/dist/author/design/categories/droppable-placeholder.d.ts.map +1 -0
- package/dist/author/design/categories/droppable-placeholder.js +70 -0
- package/dist/author/design/categories/index.d.ts +42 -0
- package/dist/author/design/categories/index.d.ts.map +1 -0
- package/dist/author/design/categories/index.js +146 -0
- package/dist/author/design/choices/choice.d.ts +11 -0
- package/dist/author/design/choices/choice.d.ts.map +1 -0
- package/dist/author/design/choices/choice.js +129 -0
- package/dist/author/design/choices/config.d.ts +22 -0
- package/dist/author/design/choices/config.d.ts.map +1 -0
- package/dist/author/design/choices/config.js +33 -0
- package/dist/author/design/choices/index.d.ts +42 -0
- package/dist/author/design/choices/index.d.ts.map +1 -0
- package/dist/author/design/choices/index.js +110 -0
- package/dist/author/design/header.d.ts +25 -0
- package/dist/author/design/header.d.ts.map +1 -0
- package/dist/author/design/header.js +49 -0
- package/dist/author/design/index.d.ts +53 -0
- package/dist/author/design/index.d.ts.map +1 -0
- package/dist/author/design/index.js +410 -0
- package/dist/author/design/input-header.d.ts +40 -0
- package/dist/author/design/input-header.d.ts.map +1 -0
- package/dist/author/design/input-header.js +69 -0
- package/dist/author/design/utils.d.ts +10 -0
- package/dist/author/design/utils.d.ts.map +1 -0
- package/dist/author/design/utils.js +7 -0
- package/dist/author/index.d.ts +52 -0
- package/dist/author/index.d.ts.map +1 -0
- package/dist/author/index.js +87 -0
- package/dist/author/main.d.ts +24 -0
- package/dist/author/main.d.ts.map +1 -0
- package/dist/author/main.js +30 -0
- package/dist/author/utils.d.ts +17 -0
- package/dist/author/utils.d.ts.map +1 -0
- package/dist/author/utils.js +17 -0
- package/dist/controller/defaults.d.ts +35 -0
- package/dist/controller/defaults.d.ts.map +1 -0
- package/dist/controller/defaults.js +29 -0
- package/dist/controller/index.d.ts +62 -0
- package/dist/controller/index.d.ts.map +1 -0
- package/dist/controller/index.js +155 -0
- package/dist/controller/utils.d.ts +21 -0
- package/dist/controller/utils.d.ts.map +1 -0
- package/dist/controller/utils.js +35 -0
- package/dist/delivery/categorize/categories.d.ts +35 -0
- package/dist/delivery/categorize/categories.d.ts.map +1 -0
- package/dist/delivery/categorize/categories.js +66 -0
- package/dist/delivery/categorize/category.d.ts +29 -0
- package/dist/delivery/categorize/category.d.ts.map +1 -0
- package/dist/delivery/categorize/category.js +48 -0
- package/dist/delivery/categorize/choice.d.ts +28 -0
- package/dist/delivery/categorize/choice.d.ts.map +1 -0
- package/dist/delivery/categorize/choice.js +94 -0
- package/dist/delivery/categorize/choices.d.ts +40 -0
- package/dist/delivery/categorize/choices.d.ts.map +1 -0
- package/dist/delivery/categorize/choices.js +51 -0
- package/dist/delivery/categorize/droppable-placeholder.d.ts +33 -0
- package/dist/delivery/categorize/droppable-placeholder.d.ts.map +1 -0
- package/dist/delivery/categorize/droppable-placeholder.js +64 -0
- package/dist/delivery/categorize/grid-content.d.ts +26 -0
- package/dist/delivery/categorize/grid-content.d.ts.map +1 -0
- package/dist/delivery/categorize/grid-content.js +39 -0
- package/dist/delivery/categorize/index.d.ts +58 -0
- package/dist/delivery/categorize/index.d.ts.map +1 -0
- package/dist/delivery/categorize/index.js +260 -0
- package/dist/delivery/index.d.ts +28 -0
- package/dist/delivery/index.d.ts.map +1 -0
- package/dist/delivery/index.js +152 -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 +152 -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/_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/_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/_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/_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/_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/_baseTimes.js +7 -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/_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/_defineProperty.js +10 -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/_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/_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/_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/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/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/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/stubArray.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js +6 -0
- package/package.json +74 -0
- package/src/author/defaults.ts +182 -0
- package/src/author/design/builder.ts +63 -0
- package/src/author/design/buttons.tsx +60 -0
- package/src/author/design/categories/RowLabel.tsx +91 -0
- package/src/author/design/categories/alternateResponses.tsx +127 -0
- package/src/author/design/categories/category.tsx +161 -0
- package/src/author/design/categories/choice-preview.tsx +112 -0
- package/src/author/design/categories/droppable-placeholder.tsx +114 -0
- package/src/author/design/categories/index.tsx +254 -0
- package/src/author/design/choices/choice.tsx +200 -0
- package/src/author/design/choices/config.tsx +58 -0
- package/src/author/design/choices/index.tsx +185 -0
- package/src/author/design/header.tsx +74 -0
- package/src/author/design/index.tsx +764 -0
- package/src/author/design/input-header.tsx +109 -0
- package/src/author/design/utils.ts +14 -0
- package/src/author/index.ts +171 -0
- package/src/author/main.tsx +45 -0
- package/src/author/utils.ts +46 -0
- package/src/controller/defaults.ts +37 -0
- package/src/controller/index.ts +469 -0
- package/src/controller/utils.ts +79 -0
- package/src/delivery/categorize/categories.tsx +139 -0
- package/src/delivery/categorize/category.tsx +78 -0
- package/src/delivery/categorize/choice.tsx +117 -0
- package/src/delivery/categorize/choices.tsx +95 -0
- package/src/delivery/categorize/droppable-placeholder.tsx +95 -0
- package/src/delivery/categorize/grid-content.tsx +53 -0
- package/src/delivery/categorize/index.tsx +515 -0
- package/src/delivery/index.ts +390 -0
- package/src/index.iife.ts +16 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/categorize/configure/src/design/choices/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 Card from '@mui/material/Card';
|
|
15
|
+
import CardActions from '@mui/material/CardActions';
|
|
16
|
+
import InputHeader from '../input-header.js';
|
|
17
|
+
import { Checkbox } from '@pie-lib/config-ui';
|
|
18
|
+
import { DeleteButton } from '../buttons.js';
|
|
19
|
+
import DragHandle from '@mui/icons-material/DragHandle';
|
|
20
|
+
import { useDraggable, useDroppable } from '@dnd-kit/core';
|
|
21
|
+
import debug from 'debug';
|
|
22
|
+
import { uid } from '@pie-lib/drag';
|
|
23
|
+
import { multiplePlacements } from '../../utils.js';
|
|
24
|
+
|
|
25
|
+
const log = debug('@pie-element:categorize:configure:choice');
|
|
26
|
+
|
|
27
|
+
const canDrag = (props) => {
|
|
28
|
+
if (props.lockChoiceOrder) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
const count = props.choice.categoryCount || 0;
|
|
32
|
+
if (count === 0) {
|
|
33
|
+
return true;
|
|
34
|
+
} else {
|
|
35
|
+
return props.correctResponseCount < count;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const StyledCard: any = styled(Card)(({ theme }) => ({
|
|
40
|
+
minWidth: '196px',
|
|
41
|
+
padding: theme.spacing(1),
|
|
42
|
+
overflow: 'visible',
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
const StyledCardActions: any = styled(CardActions)({
|
|
46
|
+
padding: 0,
|
|
47
|
+
justifyContent: 'space-between',
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const DragHandleContainer: any = styled('span', {
|
|
51
|
+
shouldForwardProp: (prop) => prop !== 'draggable',
|
|
52
|
+
})(({ draggable }) => ({
|
|
53
|
+
cursor: draggable ? 'move' : 'inherit',
|
|
54
|
+
touchAction: 'none',
|
|
55
|
+
}));
|
|
56
|
+
|
|
57
|
+
const ErrorText: any = styled('div')(({ theme }) => ({
|
|
58
|
+
fontSize: theme.typography.fontSize - 2,
|
|
59
|
+
color: theme.palette.error.main,
|
|
60
|
+
paddingBottom: theme.spacing(1),
|
|
61
|
+
}));
|
|
62
|
+
|
|
63
|
+
const Choice = ({
|
|
64
|
+
allowMultiplePlacements,
|
|
65
|
+
configuration,
|
|
66
|
+
choice,
|
|
67
|
+
deleteFocusedEl,
|
|
68
|
+
focusedEl,
|
|
69
|
+
index,
|
|
70
|
+
onDelete,
|
|
71
|
+
onChange,
|
|
72
|
+
correctResponseCount,
|
|
73
|
+
lockChoiceOrder,
|
|
74
|
+
imageSupport,
|
|
75
|
+
spellCheck,
|
|
76
|
+
toolbarOpts,
|
|
77
|
+
error,
|
|
78
|
+
maxImageWidth,
|
|
79
|
+
maxImageHeight,
|
|
80
|
+
uploadSoundSupport,
|
|
81
|
+
}) => {
|
|
82
|
+
const draggable = canDrag({ choice, correctResponseCount, lockChoiceOrder });
|
|
83
|
+
|
|
84
|
+
const {
|
|
85
|
+
attributes: dragAttributes,
|
|
86
|
+
listeners: dragListeners,
|
|
87
|
+
setNodeRef: setDragNodeRef,
|
|
88
|
+
isDragging,
|
|
89
|
+
} = useDraggable({
|
|
90
|
+
id: `choice-${choice.id}`,
|
|
91
|
+
data: {
|
|
92
|
+
id: choice.id,
|
|
93
|
+
index,
|
|
94
|
+
type: 'choice',
|
|
95
|
+
},
|
|
96
|
+
disabled: !draggable,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const {
|
|
100
|
+
setNodeRef: setDropNodeRef,
|
|
101
|
+
} = useDroppable({
|
|
102
|
+
id: `choice-drop-${choice.id}`,
|
|
103
|
+
data: {
|
|
104
|
+
id: choice.id,
|
|
105
|
+
index,
|
|
106
|
+
type: 'choice',
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const changeContent = (content) => {
|
|
111
|
+
choice.content = content;
|
|
112
|
+
onChange(choice);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const changeCategoryCount = () => {
|
|
116
|
+
if (choice.categoryCount === 1) {
|
|
117
|
+
choice.categoryCount = 0;
|
|
118
|
+
} else {
|
|
119
|
+
choice.categoryCount = 1;
|
|
120
|
+
}
|
|
121
|
+
onChange(choice);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const isCheckboxShown = (allowMultiplePlacements) => allowMultiplePlacements === multiplePlacements.perChoice;
|
|
125
|
+
|
|
126
|
+
const showRemoveAfterPlacing = isCheckboxShown(allowMultiplePlacements);
|
|
127
|
+
|
|
128
|
+
const setNodeRef = (element) => {
|
|
129
|
+
setDragNodeRef(element);
|
|
130
|
+
setDropNodeRef(element);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<StyledCard ref={setNodeRef} style={{ opacity: isDragging ? 0.5 : 1 }}>
|
|
135
|
+
<StyledCardActions>
|
|
136
|
+
<DragHandleContainer draggable={draggable} {...dragAttributes} {...dragListeners}>
|
|
137
|
+
<DragHandle color={draggable ? 'primary' : 'disabled'} />
|
|
138
|
+
</DragHandleContainer>
|
|
139
|
+
</StyledCardActions>
|
|
140
|
+
<InputHeader
|
|
141
|
+
imageSupport={imageSupport}
|
|
142
|
+
focusedEl={focusedEl}
|
|
143
|
+
deleteFocusedEl={deleteFocusedEl}
|
|
144
|
+
index={index}
|
|
145
|
+
label={choice.content}
|
|
146
|
+
onChange={changeContent}
|
|
147
|
+
onDelete={onDelete}
|
|
148
|
+
toolbarOpts={toolbarOpts}
|
|
149
|
+
spellCheck={spellCheck}
|
|
150
|
+
error={error}
|
|
151
|
+
maxImageWidth={maxImageWidth}
|
|
152
|
+
maxImageHeight={maxImageHeight}
|
|
153
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
154
|
+
configuration={configuration}
|
|
155
|
+
/>
|
|
156
|
+
{error && <ErrorText>{error}</ErrorText>}
|
|
157
|
+
|
|
158
|
+
<StyledCardActions>
|
|
159
|
+
<DeleteButton label={'delete'} onClick={onDelete} />
|
|
160
|
+
{showRemoveAfterPlacing && (
|
|
161
|
+
<Checkbox
|
|
162
|
+
mini
|
|
163
|
+
label={'Remove after placing'}
|
|
164
|
+
checked={choice.categoryCount === 1}
|
|
165
|
+
onChange={changeCategoryCount}
|
|
166
|
+
/>
|
|
167
|
+
)}
|
|
168
|
+
</StyledCardActions>
|
|
169
|
+
</StyledCard>
|
|
170
|
+
);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
Choice.propTypes = {
|
|
174
|
+
allowMultiplePlacements: PropTypes.string,
|
|
175
|
+
configuration: PropTypes.object.isRequired,
|
|
176
|
+
choice: PropTypes.object.isRequired,
|
|
177
|
+
deleteFocusedEl: PropTypes.func,
|
|
178
|
+
focusedEl: PropTypes.number,
|
|
179
|
+
index: PropTypes.number,
|
|
180
|
+
lockChoiceOrder: PropTypes.bool,
|
|
181
|
+
maxImageHeight: PropTypes.object,
|
|
182
|
+
maxImageWidth: PropTypes.object,
|
|
183
|
+
onChange: PropTypes.func.isRequired,
|
|
184
|
+
onDelete: PropTypes.func.isRequired,
|
|
185
|
+
correctResponseCount: PropTypes.number.isRequired,
|
|
186
|
+
imageSupport: PropTypes.shape({
|
|
187
|
+
add: PropTypes.func.isRequired,
|
|
188
|
+
delete: PropTypes.func.isRequired,
|
|
189
|
+
}),
|
|
190
|
+
toolbarOpts: PropTypes.object,
|
|
191
|
+
error: PropTypes.string,
|
|
192
|
+
uploadSoundSupport: PropTypes.shape({
|
|
193
|
+
add: PropTypes.func.isRequired,
|
|
194
|
+
delete: PropTypes.func.isRequired,
|
|
195
|
+
}),
|
|
196
|
+
spellCheck: PropTypes.bool,
|
|
197
|
+
rearrangeChoices: PropTypes.func,
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export default uid.withUid(Choice);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/categorize/configure/src/design/choices/config.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 TextField from '@mui/material/TextField';
|
|
15
|
+
|
|
16
|
+
const ConfigContainer: any = styled('div')(({ theme }) => ({
|
|
17
|
+
paddingTop: theme.spacing(1),
|
|
18
|
+
marginBottom: theme.spacing(1),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
const StyledTextField: any = styled(TextField)({
|
|
22
|
+
width: '100%',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export class Config extends React.Component {
|
|
26
|
+
static propTypes = {
|
|
27
|
+
config: PropTypes.object,
|
|
28
|
+
onModelChanged: PropTypes.func,
|
|
29
|
+
spellCheck: PropTypes.bool,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
static defaultProps = {};
|
|
33
|
+
|
|
34
|
+
changeLabel: any = ({ target }) => {
|
|
35
|
+
this.props.onModelChanged({ choicesLabel: target.value });
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
render() {
|
|
39
|
+
const { config, spellCheck } = this.props;
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<ConfigContainer>
|
|
43
|
+
<StyledTextField
|
|
44
|
+
InputLabelProps={{
|
|
45
|
+
shrink: true,
|
|
46
|
+
}}
|
|
47
|
+
variant="outlined"
|
|
48
|
+
label="Label"
|
|
49
|
+
value={config.choicesLabel}
|
|
50
|
+
onChange={this.changeLabel}
|
|
51
|
+
spellCheck={spellCheck}
|
|
52
|
+
/>
|
|
53
|
+
</ConfigContainer>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export default Config;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/categorize/configure/src/design/choices/index.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 Choice from './choice.js';
|
|
15
|
+
import Header from '../header.js';
|
|
16
|
+
import Config from './config.js';
|
|
17
|
+
import { choiceUtils as utils } from '@pie-lib/config-ui';
|
|
18
|
+
import { removeAllChoices } from '@pie-lib/categorize';
|
|
19
|
+
|
|
20
|
+
const ChoicesContainer: any = styled('div')(({ theme }) => ({
|
|
21
|
+
marginBottom: theme.spacing(2.5),
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
const ChoiceHolder: any = styled('div')(({ theme }) => ({
|
|
25
|
+
paddingTop: theme.spacing(1),
|
|
26
|
+
paddingBottom: theme.spacing(1),
|
|
27
|
+
display: 'grid',
|
|
28
|
+
gridRowGap: `${theme.spacing(1)}px`,
|
|
29
|
+
gridColumnGap: `${theme.spacing(1)}px`,
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
const ErrorText: any = styled('div')(({ theme }) => ({
|
|
33
|
+
fontSize: theme.typography.fontSize - 2,
|
|
34
|
+
color: theme.palette.error.main,
|
|
35
|
+
paddingTop: theme.spacing(0.5),
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
export class Choices extends React.Component {
|
|
39
|
+
static propTypes = {
|
|
40
|
+
model: PropTypes.object.isRequired,
|
|
41
|
+
configuration: PropTypes.object.isRequired,
|
|
42
|
+
choices: PropTypes.array.isRequired,
|
|
43
|
+
defaultImageMaxWidth: PropTypes.number,
|
|
44
|
+
defaultImageMaxHeight: PropTypes.number,
|
|
45
|
+
onModelChanged: PropTypes.func.isRequired,
|
|
46
|
+
imageSupport: PropTypes.shape({
|
|
47
|
+
add: PropTypes.func.isRequired,
|
|
48
|
+
delete: PropTypes.func.isRequired,
|
|
49
|
+
}),
|
|
50
|
+
uploadSoundSupport: PropTypes.shape({
|
|
51
|
+
add: PropTypes.func.isRequired,
|
|
52
|
+
delete: PropTypes.func.isRequired,
|
|
53
|
+
}),
|
|
54
|
+
toolbarOpts: PropTypes.object,
|
|
55
|
+
spellCheck: PropTypes.bool,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
static defaultProps = {};
|
|
59
|
+
|
|
60
|
+
state = {
|
|
61
|
+
focusedEl: null,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
changeChoice: any = (choice) => {
|
|
65
|
+
const { choices, onModelChanged } = this.props;
|
|
66
|
+
const index = choices.findIndex((h) => h.id === choice.id);
|
|
67
|
+
if (index !== -1) {
|
|
68
|
+
choices.splice(index, 1, choice);
|
|
69
|
+
onModelChanged({ choices });
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
allChoicesHaveCount: any = (count) => {
|
|
74
|
+
const { choices } = this.props;
|
|
75
|
+
return Array.isArray(choices) && choices.every((c) => c.categoryCount === count);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
addChoice: any = () => {
|
|
79
|
+
const { onModelChanged, model, choices: oldChoices } = this.props;
|
|
80
|
+
let { maxAnswerChoices } = model || {};
|
|
81
|
+
|
|
82
|
+
if (maxAnswerChoices && model.choices?.length >= maxAnswerChoices) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const id = utils.firstAvailableIndex(
|
|
87
|
+
model.choices.map((a) => a.id),
|
|
88
|
+
1,
|
|
89
|
+
);
|
|
90
|
+
const data = { id, content: 'Choice ' + id };
|
|
91
|
+
|
|
92
|
+
this.setState(
|
|
93
|
+
{
|
|
94
|
+
focusedEl: oldChoices.length,
|
|
95
|
+
},
|
|
96
|
+
() => {
|
|
97
|
+
onModelChanged({ choices: model.choices.concat([data]) });
|
|
98
|
+
},
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
deleteFocusedEl: any = () => {
|
|
103
|
+
this.setState({
|
|
104
|
+
focusedEl: null,
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
deleteChoice: any = (choice) => {
|
|
109
|
+
const { model, onModelChanged } = this.props;
|
|
110
|
+
const index = model.choices.findIndex((a) => a.id === choice.id);
|
|
111
|
+
if (index !== -1) {
|
|
112
|
+
model.choices.splice(index, 1);
|
|
113
|
+
model.correctResponse = removeAllChoices(choice.id, model.correctResponse);
|
|
114
|
+
onModelChanged(model);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
render() {
|
|
119
|
+
const { focusedEl } = this.state;
|
|
120
|
+
const {
|
|
121
|
+
choices,
|
|
122
|
+
model,
|
|
123
|
+
imageSupport,
|
|
124
|
+
uploadSoundSupport,
|
|
125
|
+
onModelChanged,
|
|
126
|
+
spellCheck,
|
|
127
|
+
toolbarOpts,
|
|
128
|
+
configuration,
|
|
129
|
+
defaultImageMaxWidth,
|
|
130
|
+
defaultImageMaxHeight,
|
|
131
|
+
} = this.props;
|
|
132
|
+
const { errors, allowMultiplePlacementsEnabled, lockChoiceOrder, maxAnswerChoices } = model;
|
|
133
|
+
const { choicesError, choicesErrors } = errors || {};
|
|
134
|
+
const { maxImageWidth = {}, maxImageHeight = {} } = configuration || {};
|
|
135
|
+
const choiceHolderStyle = {
|
|
136
|
+
gridTemplateColumns: `repeat(${model.categoriesPerRow}, 1fr)`,
|
|
137
|
+
};
|
|
138
|
+
const addChoiceButtonTooltip =
|
|
139
|
+
maxAnswerChoices && choices?.length >= maxAnswerChoices ? `Only ${maxAnswerChoices} allowed maximum` : '';
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<ChoicesContainer>
|
|
143
|
+
<Header
|
|
144
|
+
label="Choices"
|
|
145
|
+
buttonLabel="ADD A CHOICE"
|
|
146
|
+
onAdd={this.addChoice}
|
|
147
|
+
buttonDisabled={maxAnswerChoices && choices && choices?.length >= maxAnswerChoices}
|
|
148
|
+
tooltip={addChoiceButtonTooltip}
|
|
149
|
+
/>
|
|
150
|
+
|
|
151
|
+
<Config config={model} onModelChanged={onModelChanged} spellCheck={spellCheck} />
|
|
152
|
+
|
|
153
|
+
<ChoiceHolder style={choiceHolderStyle}>
|
|
154
|
+
{choices.map((h, index) => {
|
|
155
|
+
return (
|
|
156
|
+
<Choice
|
|
157
|
+
key={h.id}
|
|
158
|
+
choice={h}
|
|
159
|
+
focusedEl={focusedEl}
|
|
160
|
+
deleteFocusedEl={this.deleteFocusedEl}
|
|
161
|
+
correctResponseCount={h.correctResponseCount}
|
|
162
|
+
allowMultiplePlacements={allowMultiplePlacementsEnabled}
|
|
163
|
+
lockChoiceOrder={lockChoiceOrder}
|
|
164
|
+
index={index}
|
|
165
|
+
imageSupport={imageSupport}
|
|
166
|
+
onChange={this.changeChoice}
|
|
167
|
+
onDelete={() => this.deleteChoice(h)}
|
|
168
|
+
toolbarOpts={toolbarOpts}
|
|
169
|
+
spellCheck={spellCheck}
|
|
170
|
+
error={choicesErrors && choicesErrors[h.id]}
|
|
171
|
+
maxImageWidth={(maxImageWidth && maxImageWidth.choice) || defaultImageMaxWidth}
|
|
172
|
+
maxImageHeight={(maxImageHeight && maxImageHeight.choice) || defaultImageMaxHeight}
|
|
173
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
174
|
+
configuration={configuration}
|
|
175
|
+
/>
|
|
176
|
+
);
|
|
177
|
+
})}
|
|
178
|
+
</ChoiceHolder>
|
|
179
|
+
{choicesError && <ErrorText>{choicesError}</ErrorText>}
|
|
180
|
+
</ChoicesContainer>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export default Choices;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/categorize/configure/src/design/header.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 Tooltip from '@mui/material/Tooltip';
|
|
14
|
+
import Typography from '@mui/material/Typography';
|
|
15
|
+
import { styled } from '@mui/material/styles';
|
|
16
|
+
import { AddButton } from './buttons.js';
|
|
17
|
+
|
|
18
|
+
const HeaderContainer: any = styled('div')(({ theme }) => ({
|
|
19
|
+
display: 'flex',
|
|
20
|
+
justifyContent: 'space-between',
|
|
21
|
+
marginBottom: theme.spacing(1),
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
const TitleContainer: any = styled('div')({
|
|
25
|
+
display: 'flex',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const StyledTooltip: any = styled(Tooltip)(({ theme }) => ({
|
|
30
|
+
'& .MuiTooltip-tooltip': {
|
|
31
|
+
fontSize: theme.typography.fontSize - 2,
|
|
32
|
+
whiteSpace: 'pre',
|
|
33
|
+
maxWidth: '500px',
|
|
34
|
+
},
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
export class Header extends React.Component {
|
|
38
|
+
static propTypes = {
|
|
39
|
+
buttonLabel: PropTypes.string,
|
|
40
|
+
onAdd: PropTypes.func.isRequired,
|
|
41
|
+
label: PropTypes.string.isRequired,
|
|
42
|
+
info: PropTypes.any,
|
|
43
|
+
buttonDisabled: PropTypes.bool,
|
|
44
|
+
variant: PropTypes.string,
|
|
45
|
+
tooltip: PropTypes.string,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
static defaultProps = {};
|
|
49
|
+
|
|
50
|
+
render() {
|
|
51
|
+
const { onAdd, label, buttonLabel, info, buttonDisabled, variant, tooltip } = this.props;
|
|
52
|
+
return (
|
|
53
|
+
<HeaderContainer>
|
|
54
|
+
<TitleContainer>
|
|
55
|
+
<Typography variant={variant || 'title'}>
|
|
56
|
+
{label}
|
|
57
|
+
</Typography>
|
|
58
|
+
{info}
|
|
59
|
+
</TitleContainer>
|
|
60
|
+
<StyledTooltip
|
|
61
|
+
title={tooltip || ''}
|
|
62
|
+
enterTouchDelay={50}
|
|
63
|
+
leaveTouchDelay={3000}
|
|
64
|
+
>
|
|
65
|
+
<span>
|
|
66
|
+
<AddButton onClick={onAdd} label={buttonLabel} disabled={buttonDisabled} />
|
|
67
|
+
</span>
|
|
68
|
+
</StyledTooltip>
|
|
69
|
+
</HeaderContainer>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default Header;
|