@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,161 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/categorize/configure/src/design/categories/category.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
|
+
|
|
17
|
+
import InputHeader from '../input-header.js';
|
|
18
|
+
import { DeleteButton } from '../buttons.js';
|
|
19
|
+
import PlaceHolder from './droppable-placeholder.js';
|
|
20
|
+
|
|
21
|
+
const StyledCard: any = styled(Card, {
|
|
22
|
+
shouldForwardProp: (prop) => prop !== 'isDuplicated',
|
|
23
|
+
})(({ theme, isDuplicated }) => ({
|
|
24
|
+
minWidth: '196px',
|
|
25
|
+
padding: theme.spacing(1),
|
|
26
|
+
overflow: 'visible',
|
|
27
|
+
...(isDuplicated && {
|
|
28
|
+
border: '1px solid red',
|
|
29
|
+
}),
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
const StyledCardActions: any = styled(CardActions)(({ theme }) => ({
|
|
33
|
+
padding: 0,
|
|
34
|
+
paddingBottom: 0,
|
|
35
|
+
paddingTop: theme.spacing(1),
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
const CategoryHeader: any = styled('div')(({ theme }) => ({
|
|
39
|
+
padding: theme.spacing(2),
|
|
40
|
+
'& p': {
|
|
41
|
+
margin: 0,
|
|
42
|
+
},
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
const ErrorText: any = styled('div')(({ theme }) => ({
|
|
46
|
+
fontSize: theme.typography.fontSize - 2,
|
|
47
|
+
color: theme.palette.error.main,
|
|
48
|
+
paddingBottom: theme.spacing(1),
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
export class Category extends React.Component {
|
|
52
|
+
static propTypes = {
|
|
53
|
+
alternateResponseIndex: PropTypes.number,
|
|
54
|
+
category: PropTypes.object.isRequired,
|
|
55
|
+
configuration: PropTypes.object.isRequired,
|
|
56
|
+
defaultImageMaxHeight: PropTypes.number,
|
|
57
|
+
defaultImageMaxWidth: PropTypes.number,
|
|
58
|
+
deleteFocusedEl: PropTypes.func,
|
|
59
|
+
focusedEl: PropTypes.number,
|
|
60
|
+
index: PropTypes.number,
|
|
61
|
+
error: PropTypes.string,
|
|
62
|
+
isDuplicated: PropTypes.bool,
|
|
63
|
+
maxImageWidth: PropTypes.object,
|
|
64
|
+
maxImageHeight: PropTypes.object,
|
|
65
|
+
onChange: PropTypes.func,
|
|
66
|
+
onDelete: PropTypes.func,
|
|
67
|
+
onDeleteChoice: PropTypes.func,
|
|
68
|
+
imageSupport: PropTypes.shape({
|
|
69
|
+
add: PropTypes.func.isRequired,
|
|
70
|
+
delete: PropTypes.func.isRequired,
|
|
71
|
+
}),
|
|
72
|
+
toolbarOpts: PropTypes.object,
|
|
73
|
+
spellCheck: PropTypes.bool,
|
|
74
|
+
uploadSoundSupport: PropTypes.shape({
|
|
75
|
+
add: PropTypes.func.isRequired,
|
|
76
|
+
delete: PropTypes.func.isRequired,
|
|
77
|
+
}),
|
|
78
|
+
isAlternate: PropTypes.bool,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
static defaultProps = {};
|
|
82
|
+
|
|
83
|
+
changeLabel: any = (l) => {
|
|
84
|
+
const { category, onChange } = this.props;
|
|
85
|
+
category.label = l;
|
|
86
|
+
onChange(category);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
render() {
|
|
90
|
+
const {
|
|
91
|
+
alternateResponseIndex,
|
|
92
|
+
category,
|
|
93
|
+
configuration,
|
|
94
|
+
deleteFocusedEl,
|
|
95
|
+
focusedEl,
|
|
96
|
+
index,
|
|
97
|
+
error,
|
|
98
|
+
isDuplicated,
|
|
99
|
+
onDelete,
|
|
100
|
+
onDeleteChoice,
|
|
101
|
+
imageSupport,
|
|
102
|
+
spellCheck,
|
|
103
|
+
toolbarOpts,
|
|
104
|
+
maxImageWidth,
|
|
105
|
+
maxImageHeight,
|
|
106
|
+
uploadSoundSupport,
|
|
107
|
+
mathMlOptions = {},
|
|
108
|
+
} = this.props;
|
|
109
|
+
const isCategoryHeaderDisabled = !!alternateResponseIndex || alternateResponseIndex === 0;
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<StyledCard isDuplicated={isDuplicated}>
|
|
113
|
+
<span>
|
|
114
|
+
{!isCategoryHeaderDisabled ? (
|
|
115
|
+
<InputHeader
|
|
116
|
+
label={category.label}
|
|
117
|
+
focusedEl={focusedEl}
|
|
118
|
+
deleteFocusedEl={deleteFocusedEl}
|
|
119
|
+
index={index}
|
|
120
|
+
disabled={!!alternateResponseIndex || alternateResponseIndex === 0}
|
|
121
|
+
error={error}
|
|
122
|
+
onChange={this.changeLabel}
|
|
123
|
+
onDelete={onDelete}
|
|
124
|
+
imageSupport={imageSupport}
|
|
125
|
+
toolbarOpts={toolbarOpts}
|
|
126
|
+
spellCheck={spellCheck}
|
|
127
|
+
maxImageWidth={maxImageWidth}
|
|
128
|
+
maxImageHeight={maxImageHeight}
|
|
129
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
130
|
+
mathMlOptions={mathMlOptions}
|
|
131
|
+
configuration={configuration}
|
|
132
|
+
/>
|
|
133
|
+
) : (
|
|
134
|
+
<CategoryHeader
|
|
135
|
+
dangerouslySetInnerHTML={{
|
|
136
|
+
__html: category.label,
|
|
137
|
+
}}
|
|
138
|
+
/>
|
|
139
|
+
)}
|
|
140
|
+
{error && <ErrorText>{error}</ErrorText>}
|
|
141
|
+
</span>
|
|
142
|
+
<PlaceHolder
|
|
143
|
+
alternateResponseIndex={alternateResponseIndex}
|
|
144
|
+
category={category}
|
|
145
|
+
choices={category.choices}
|
|
146
|
+
onDeleteChoice={onDeleteChoice}
|
|
147
|
+
categoryId={category.id}
|
|
148
|
+
extraStyles={{ minHeight: '100px', }}
|
|
149
|
+
isAlternate={this.props.isAlternate}
|
|
150
|
+
/>
|
|
151
|
+
{onDelete && (
|
|
152
|
+
<StyledCardActions>
|
|
153
|
+
<DeleteButton label={'delete'} onClick={onDelete} />
|
|
154
|
+
</StyledCardActions>
|
|
155
|
+
)}
|
|
156
|
+
</StyledCard>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export default Category;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/categorize/configure/src/design/categories/choice-preview.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 { DraggableChoice } from '@pie-lib/drag';
|
|
15
|
+
import IconButton from '@mui/material/IconButton';
|
|
16
|
+
import RemoveCircleOutlineIcon from '@mui/icons-material/RemoveCircleOutline';
|
|
17
|
+
import { HtmlAndMath as HtmlAndMathImport } 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 HtmlAndMath = unwrapReactInteropSymbol(HtmlAndMathImport, 'HtmlAndMath') || unwrapReactInteropSymbol(renderUi.HtmlAndMath, 'HtmlAndMath');
|
|
39
|
+
import * as RenderUiNamespace from '@pie-lib/render-ui';
|
|
40
|
+
const renderUiNamespaceAny = RenderUiNamespace as any;
|
|
41
|
+
const renderUiDefaultMaybe = renderUiNamespaceAny['default'];
|
|
42
|
+
const renderUi =
|
|
43
|
+
renderUiDefaultMaybe && typeof renderUiDefaultMaybe === 'object'
|
|
44
|
+
? renderUiDefaultMaybe
|
|
45
|
+
: renderUiNamespaceAny;
|
|
46
|
+
import { color } from '@pie-lib/render-ui';
|
|
47
|
+
|
|
48
|
+
const ChoicePreviewContainer: any = styled('div')({
|
|
49
|
+
position: 'relative',
|
|
50
|
+
overflow: 'auto',
|
|
51
|
+
touchAction: 'none',
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const DeleteIconButton: any = styled(IconButton)({
|
|
55
|
+
position: 'absolute',
|
|
56
|
+
right: 0,
|
|
57
|
+
top: 0,
|
|
58
|
+
color: `${color.tertiary()} !important`,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export class ChoicePreview extends React.Component {
|
|
62
|
+
static propTypes = {
|
|
63
|
+
alternateResponseIndex: PropTypes.number,
|
|
64
|
+
category: PropTypes.object,
|
|
65
|
+
choice: PropTypes.object.isRequired,
|
|
66
|
+
choiceIndex: PropTypes.number,
|
|
67
|
+
onDelete: PropTypes.func,
|
|
68
|
+
};
|
|
69
|
+
static defaultProps = {
|
|
70
|
+
onDelete: () => {},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
delete: any = () => {
|
|
74
|
+
const { onDelete, choice } = this.props;
|
|
75
|
+
onDelete(choice);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
render() {
|
|
79
|
+
const { alternateResponseIndex, category, choice, choiceIndex } = this.props;
|
|
80
|
+
|
|
81
|
+
// Generate unique ID for each instance to distinguish multiple instances of the same choice
|
|
82
|
+
const categoryId = category && category.id;
|
|
83
|
+
const uniqueId =
|
|
84
|
+
alternateResponseIndex !== undefined
|
|
85
|
+
? `${choice.id}-${categoryId}-${choiceIndex}-alt-${alternateResponseIndex}`
|
|
86
|
+
: `${choice.id}-${categoryId}-${choiceIndex}`;
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<ChoicePreviewContainer>
|
|
90
|
+
{choice ? (
|
|
91
|
+
<DraggableChoice
|
|
92
|
+
alternateResponseIndex={alternateResponseIndex}
|
|
93
|
+
category={category}
|
|
94
|
+
choice={choice}
|
|
95
|
+
choiceIndex={choiceIndex}
|
|
96
|
+
onRemoveChoice={this.delete}
|
|
97
|
+
type={'choice-preview'}
|
|
98
|
+
id={uniqueId}
|
|
99
|
+
categoryId={categoryId}
|
|
100
|
+
>
|
|
101
|
+
<HtmlAndMath html={choice?.content} />
|
|
102
|
+
</DraggableChoice>
|
|
103
|
+
) : null}
|
|
104
|
+
<DeleteIconButton aria-label="delete" onClick={this.delete} size="large">
|
|
105
|
+
<RemoveCircleOutlineIcon />
|
|
106
|
+
</DeleteIconButton>
|
|
107
|
+
</ChoicePreviewContainer>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export default ChoicePreview;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/categorize/configure/src/design/categories/droppable-placeholder.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 ChoicePreview from './choice-preview.js';
|
|
15
|
+
import { useDroppable } from '@dnd-kit/core';
|
|
16
|
+
import { uid, PlaceHolder } from '@pie-lib/drag';
|
|
17
|
+
import debug from 'debug';
|
|
18
|
+
|
|
19
|
+
const log = debug('@pie-element:categorize:configure');
|
|
20
|
+
|
|
21
|
+
const HelperText: any = styled('div')(({ theme }) => ({
|
|
22
|
+
display: 'flex',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
fontSize: theme.typography.fontSize - 2,
|
|
25
|
+
color: `rgba(${theme.palette.common.black}, 0.4)`,
|
|
26
|
+
width: '100%',
|
|
27
|
+
height: '100%',
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
const Helper = () => <HelperText>Drag your correct answers here</HelperText>;
|
|
31
|
+
|
|
32
|
+
const DroppablePlaceholderContainer: any = styled('div')({
|
|
33
|
+
minHeight: '100px',
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const Previews = ({ alternateResponseIndex, category, choices, onDeleteChoice }) => (
|
|
37
|
+
<React.Fragment>
|
|
38
|
+
{(choices || []).map((c, index) =>
|
|
39
|
+
c && (
|
|
40
|
+
<ChoicePreview
|
|
41
|
+
alternateResponseIndex={alternateResponseIndex}
|
|
42
|
+
category={category}
|
|
43
|
+
choice={c}
|
|
44
|
+
key={index}
|
|
45
|
+
choiceIndex={index}
|
|
46
|
+
onDelete={(choice) => onDeleteChoice(choice, index)}
|
|
47
|
+
/>
|
|
48
|
+
)
|
|
49
|
+
)}
|
|
50
|
+
</React.Fragment>
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
Previews.propTypes = {
|
|
54
|
+
alternateResponseIndex: PropTypes.number,
|
|
55
|
+
category: PropTypes.object,
|
|
56
|
+
choices: PropTypes.array,
|
|
57
|
+
onDeleteChoice: PropTypes.func,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const DroppablePlaceHolder = ({
|
|
61
|
+
alternateResponseIndex,
|
|
62
|
+
category,
|
|
63
|
+
choices,
|
|
64
|
+
onDeleteChoice,
|
|
65
|
+
categoryId,
|
|
66
|
+
isAlternate
|
|
67
|
+
}) => {
|
|
68
|
+
const { setNodeRef, isOver } = useDroppable({
|
|
69
|
+
id: `${categoryId}-${isAlternate ? 'alternate' : 'standard'}`,
|
|
70
|
+
data: {
|
|
71
|
+
accepts: ['choice', 'choice-preview'],
|
|
72
|
+
alternateResponseIndex,
|
|
73
|
+
categoryId,
|
|
74
|
+
type: isAlternate ? 'category-alternate' : 'category',
|
|
75
|
+
id: categoryId,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<div ref={setNodeRef}>
|
|
81
|
+
<DroppablePlaceholderContainer>
|
|
82
|
+
<PlaceHolder
|
|
83
|
+
isOver={isOver}
|
|
84
|
+
extraStyles={{
|
|
85
|
+
width: '100%',
|
|
86
|
+
minHeight: '100px',
|
|
87
|
+
height: 'auto',
|
|
88
|
+
}}>
|
|
89
|
+
{(choices || []).length === 0 ? (
|
|
90
|
+
<Helper />
|
|
91
|
+
) : (
|
|
92
|
+
<Previews
|
|
93
|
+
alternateResponseIndex={alternateResponseIndex}
|
|
94
|
+
category={category}
|
|
95
|
+
choices={choices}
|
|
96
|
+
onDeleteChoice={onDeleteChoice}
|
|
97
|
+
/>
|
|
98
|
+
)}
|
|
99
|
+
</PlaceHolder>
|
|
100
|
+
</DroppablePlaceholderContainer>
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
DroppablePlaceHolder.propTypes = {
|
|
106
|
+
alternateResponseIndex: PropTypes.number,
|
|
107
|
+
category: PropTypes.object,
|
|
108
|
+
choices: PropTypes.array,
|
|
109
|
+
onDeleteChoice: PropTypes.func,
|
|
110
|
+
categoryId: PropTypes.string.isRequired,
|
|
111
|
+
isAlternate: PropTypes.bool,
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export default uid.withUid(DroppablePlaceHolder);
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/categorize/configure/src/design/categories/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 { choiceUtils as utils } from '@pie-lib/config-ui';
|
|
15
|
+
import Info from '@mui/icons-material/Info';
|
|
16
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
17
|
+
import {
|
|
18
|
+
removeCategory,
|
|
19
|
+
removeChoiceFromCategory,
|
|
20
|
+
} from '@pie-lib/categorize';
|
|
21
|
+
|
|
22
|
+
import Category from './category.js';
|
|
23
|
+
import Header from '../header.js';
|
|
24
|
+
import { generateValidationMessage } from '../../utils.js';
|
|
25
|
+
import { RowLabel } from './RowLabel.js';
|
|
26
|
+
|
|
27
|
+
const CategoriesContainer: any = styled('div')(({ theme }) => ({
|
|
28
|
+
marginBottom: theme.spacing(3),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
const CategoriesHolder: any = styled('div')(({ theme }) => ({
|
|
32
|
+
display: 'grid',
|
|
33
|
+
gridRowGap: `${theme.spacing(1)}px`,
|
|
34
|
+
gridColumnGap: `${theme.spacing(1)}px`,
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
const StyledTooltip: any = styled(Tooltip)(({ theme }) => ({
|
|
38
|
+
'& .MuiTooltip-tooltip': {
|
|
39
|
+
fontSize: theme.typography.fontSize - 2,
|
|
40
|
+
whiteSpace: 'pre',
|
|
41
|
+
maxWidth: '500px',
|
|
42
|
+
},
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
const ErrorText: any = styled('div')(({ theme }) => ({
|
|
46
|
+
fontSize: theme.typography.fontSize - 2,
|
|
47
|
+
color: theme.palette.error.main,
|
|
48
|
+
paddingTop: theme.spacing(0.5),
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
export class Categories extends React.Component {
|
|
52
|
+
static propTypes = {
|
|
53
|
+
defaultImageMaxHeight: PropTypes.number,
|
|
54
|
+
defaultImageMaxWidth: PropTypes.number,
|
|
55
|
+
imageSupport: PropTypes.shape({
|
|
56
|
+
add: PropTypes.func.isRequired,
|
|
57
|
+
delete: PropTypes.func.isRequired,
|
|
58
|
+
}),
|
|
59
|
+
uploadSoundSupport: PropTypes.shape({
|
|
60
|
+
add: PropTypes.func.isRequired,
|
|
61
|
+
delete: PropTypes.func.isRequired,
|
|
62
|
+
}),
|
|
63
|
+
categories: PropTypes.array,
|
|
64
|
+
onModelChanged: PropTypes.func,
|
|
65
|
+
model: PropTypes.object.isRequired,
|
|
66
|
+
configuration: PropTypes.object.isRequired,
|
|
67
|
+
toolbarOpts: PropTypes.object,
|
|
68
|
+
spellCheck: PropTypes.bool,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
state = {
|
|
72
|
+
focusedEl: null,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
add: any = () => {
|
|
76
|
+
const { model, categories: oldCategories } = this.props;
|
|
77
|
+
const { categoriesPerRow, correctResponse, allowAlternateEnabled } = model;
|
|
78
|
+
|
|
79
|
+
const id = utils.firstAvailableIndex(
|
|
80
|
+
model.categories.map((a) => a.id),
|
|
81
|
+
1,
|
|
82
|
+
);
|
|
83
|
+
const data = { id, label: 'Category ' + id };
|
|
84
|
+
const addRowLabel = model.categories.length % categoriesPerRow === 0;
|
|
85
|
+
const rowLabels = [...model.rowLabels];
|
|
86
|
+
|
|
87
|
+
if (addRowLabel) {
|
|
88
|
+
rowLabels.push('');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
this.setState(
|
|
92
|
+
{
|
|
93
|
+
focusedEl: oldCategories.length,
|
|
94
|
+
},
|
|
95
|
+
() => {
|
|
96
|
+
this.props.onModelChanged({
|
|
97
|
+
rowLabels,
|
|
98
|
+
categories: model.categories.concat([data]),
|
|
99
|
+
correctResponse: allowAlternateEnabled
|
|
100
|
+
? [...correctResponse, { category: id, choices: [], alternateResponses: [] }]
|
|
101
|
+
: correctResponse,
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
deleteFocusedEl: any = () => {
|
|
108
|
+
this.setState({
|
|
109
|
+
focusedEl: null,
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
delete: any = (category) => {
|
|
114
|
+
const { model, onModelChanged } = this.props;
|
|
115
|
+
const index = model.categories.findIndex((a) => a.id === category.id);
|
|
116
|
+
|
|
117
|
+
if (index !== -1) {
|
|
118
|
+
model.categories.splice(index, 1);
|
|
119
|
+
model.correctResponse = removeCategory(category.id, model.correctResponse);
|
|
120
|
+
onModelChanged(model);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
change: any = (c) => {
|
|
125
|
+
const { categories } = this.props;
|
|
126
|
+
const index = categories.findIndex((a) => a.id === c.id);
|
|
127
|
+
|
|
128
|
+
if (index !== -1) {
|
|
129
|
+
categories.splice(index, 1, c);
|
|
130
|
+
this.props.onModelChanged({ categories });
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
deleteChoiceFromCategory: any = (category, choice, choiceIndex) => {
|
|
135
|
+
const { model, onModelChanged } = this.props;
|
|
136
|
+
const correctResponse = removeChoiceFromCategory(choice.id, category.id, choiceIndex, model.correctResponse);
|
|
137
|
+
|
|
138
|
+
onModelChanged({ correctResponse });
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
changeRowLabel: any = (val, index) => {
|
|
142
|
+
const { model } = this.props;
|
|
143
|
+
const { rowLabels } = model;
|
|
144
|
+
const newRowLabels = [...rowLabels];
|
|
145
|
+
|
|
146
|
+
if (newRowLabels.length < index) {
|
|
147
|
+
newRowLabels.push(val);
|
|
148
|
+
} else {
|
|
149
|
+
newRowLabels[index] = val;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
this.props.onModelChanged({
|
|
153
|
+
rowLabels: newRowLabels,
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
render() {
|
|
158
|
+
const {
|
|
159
|
+
model,
|
|
160
|
+
categories,
|
|
161
|
+
imageSupport,
|
|
162
|
+
uploadSoundSupport,
|
|
163
|
+
toolbarOpts,
|
|
164
|
+
spellCheck,
|
|
165
|
+
configuration,
|
|
166
|
+
defaultImageMaxHeight,
|
|
167
|
+
defaultImageMaxWidth,
|
|
168
|
+
mathMlOptions = {},
|
|
169
|
+
} = this.props;
|
|
170
|
+
|
|
171
|
+
const { categoriesPerRow, rowLabels, errors } = model;
|
|
172
|
+
const { associationError, categoriesError, categoriesErrors } = errors || {};
|
|
173
|
+
const { maxCategories, maxImageWidth = {}, maxImageHeight = {} } = configuration || {};
|
|
174
|
+
const holderStyle = {
|
|
175
|
+
gridTemplateColumns: `repeat(${categoriesPerRow}, 1fr)`,
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const validationMessage = generateValidationMessage(configuration);
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<CategoriesContainer>
|
|
182
|
+
<Header
|
|
183
|
+
label="Categories"
|
|
184
|
+
buttonLabel="ADD A CATEGORY"
|
|
185
|
+
onAdd={this.add}
|
|
186
|
+
info={
|
|
187
|
+
<StyledTooltip
|
|
188
|
+
disableFocusListener
|
|
189
|
+
disableTouchListener
|
|
190
|
+
placement={'right'}
|
|
191
|
+
title={validationMessage}
|
|
192
|
+
>
|
|
193
|
+
<Info fontSize={'small'} color={'primary'} style={{ marginLeft: '5px' }} />
|
|
194
|
+
</StyledTooltip>
|
|
195
|
+
}
|
|
196
|
+
buttonDisabled={maxCategories && categories && maxCategories === categories.length}
|
|
197
|
+
/>
|
|
198
|
+
|
|
199
|
+
<CategoriesHolder style={holderStyle}>
|
|
200
|
+
{categories.map((category, index) => {
|
|
201
|
+
const hasRowLabel = index % categoriesPerRow === 0;
|
|
202
|
+
const rowIndex = index / categoriesPerRow;
|
|
203
|
+
|
|
204
|
+
return (
|
|
205
|
+
<React.Fragment key={index}>
|
|
206
|
+
{hasRowLabel && (
|
|
207
|
+
<RowLabel
|
|
208
|
+
categoriesPerRow={categoriesPerRow}
|
|
209
|
+
disabled={false}
|
|
210
|
+
rowIndex={rowIndex}
|
|
211
|
+
markup={rowLabels[rowIndex] || ''}
|
|
212
|
+
onChange={(val) => this.changeRowLabel(val, rowIndex)}
|
|
213
|
+
imageSupport={imageSupport}
|
|
214
|
+
toolbarOpts={toolbarOpts}
|
|
215
|
+
spellCheck={spellCheck}
|
|
216
|
+
maxImageWidth={(maxImageWidth && maxImageWidth.rowLabel) || defaultImageMaxWidth}
|
|
217
|
+
maxImageHeight={(maxImageHeight && maxImageHeight.rowLabel) || defaultImageMaxHeight}
|
|
218
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
219
|
+
mathMlOptions={mathMlOptions}
|
|
220
|
+
configuration={configuration}
|
|
221
|
+
/>
|
|
222
|
+
)}
|
|
223
|
+
|
|
224
|
+
<Category
|
|
225
|
+
imageSupport={imageSupport}
|
|
226
|
+
focusedEl={this.state.focusedEl}
|
|
227
|
+
deleteFocusedEl={this.deleteFocusedEl}
|
|
228
|
+
index={index}
|
|
229
|
+
category={category}
|
|
230
|
+
error={categoriesErrors && categoriesErrors[category.id]}
|
|
231
|
+
onChange={this.change}
|
|
232
|
+
onDelete={() => this.delete(category)}
|
|
233
|
+
toolbarOpts={toolbarOpts}
|
|
234
|
+
spellCheck={spellCheck}
|
|
235
|
+
onDeleteChoice={(choice, choiceIndex) => this.deleteChoiceFromCategory(category, choice, choiceIndex)}
|
|
236
|
+
maxImageWidth={(maxImageWidth && maxImageWidth.categoryLabel) || defaultImageMaxWidth}
|
|
237
|
+
maxImageHeight={(maxImageHeight && maxImageHeight.categoryLabel) || defaultImageMaxHeight}
|
|
238
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
239
|
+
configuration={configuration}
|
|
240
|
+
alternateResponseIndex={undefined}
|
|
241
|
+
/>
|
|
242
|
+
</React.Fragment>
|
|
243
|
+
);
|
|
244
|
+
})}
|
|
245
|
+
</CategoriesHolder>
|
|
246
|
+
|
|
247
|
+
{associationError && <ErrorText>{associationError}</ErrorText>}
|
|
248
|
+
{categoriesError && <ErrorText>{categoriesError}</ErrorText>}
|
|
249
|
+
</CategoriesContainer>
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export default Categories;
|