@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,78 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/categorize/src/categorize/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
|
+
|
|
15
|
+
import Choice from './choice.js';
|
|
16
|
+
import PlaceHolder from './droppable-placeholder.js';
|
|
17
|
+
|
|
18
|
+
export const CategoryType = {
|
|
19
|
+
id: PropTypes.string.isRequired,
|
|
20
|
+
categoryId: PropTypes.string,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export class Category extends React.Component {
|
|
24
|
+
static propTypes = {
|
|
25
|
+
...CategoryType,
|
|
26
|
+
className: PropTypes.string,
|
|
27
|
+
disabled: PropTypes.bool,
|
|
28
|
+
onDropChoice: PropTypes.func,
|
|
29
|
+
onRemoveChoice: PropTypes.func,
|
|
30
|
+
minRowHeight: PropTypes.string,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
static defaultProps = {};
|
|
34
|
+
|
|
35
|
+
render() {
|
|
36
|
+
const {
|
|
37
|
+
className,
|
|
38
|
+
choices = [],
|
|
39
|
+
disabled,
|
|
40
|
+
onDropChoice,
|
|
41
|
+
onRemoveChoice,
|
|
42
|
+
id,
|
|
43
|
+
correct,
|
|
44
|
+
minRowHeight,
|
|
45
|
+
} = this.props;
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<StyledDiv className={className} id={id}>
|
|
49
|
+
<PlaceHolder
|
|
50
|
+
id={id}
|
|
51
|
+
onDropChoice={onDropChoice}
|
|
52
|
+
disabled={disabled}
|
|
53
|
+
correct={correct}
|
|
54
|
+
minRowHeight={minRowHeight}
|
|
55
|
+
>
|
|
56
|
+
{choices.map((c, index) => (
|
|
57
|
+
<Choice
|
|
58
|
+
onRemoveChoice={onRemoveChoice}
|
|
59
|
+
disabled={disabled}
|
|
60
|
+
key={index}
|
|
61
|
+
choiceIndex={index}
|
|
62
|
+
categoryId={id}
|
|
63
|
+
{...c}
|
|
64
|
+
/>
|
|
65
|
+
))}
|
|
66
|
+
</PlaceHolder>
|
|
67
|
+
</StyledDiv>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const StyledDiv: any = styled('div')(({ theme }) => ({
|
|
73
|
+
display: 'flex',
|
|
74
|
+
flexDirection: 'column',
|
|
75
|
+
flex: 2,
|
|
76
|
+
}));
|
|
77
|
+
|
|
78
|
+
export default Category;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/categorize/src/categorize/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 debug from 'debug';
|
|
14
|
+
import { styled } from '@mui/material/styles';
|
|
15
|
+
import { useDraggable } from '@dnd-kit/core';
|
|
16
|
+
import { uid } from '@pie-lib/drag';
|
|
17
|
+
import Card from '@mui/material/Card';
|
|
18
|
+
import CardContent from '@mui/material/CardContent';
|
|
19
|
+
import { color } from '@pie-lib/render-ui';
|
|
20
|
+
|
|
21
|
+
const log = debug('@pie-ui:categorize:choice');
|
|
22
|
+
|
|
23
|
+
export const ChoiceType = {
|
|
24
|
+
content: PropTypes.string.isRequired,
|
|
25
|
+
id: PropTypes.string,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const ChoiceContainer: any = styled('div', {
|
|
29
|
+
shouldForwardProp: (prop) => !['isDragging', 'disabled', 'correct'].includes(prop),
|
|
30
|
+
})(({ isDragging, disabled, correct }) => ({
|
|
31
|
+
direction: 'initial',
|
|
32
|
+
cursor: disabled ? 'not-allowed' : isDragging ? 'move' : 'pointer',
|
|
33
|
+
width: '100%',
|
|
34
|
+
borderRadius: '6px',
|
|
35
|
+
...(correct === true && {
|
|
36
|
+
border: `solid 2px ${color.correct()}`,
|
|
37
|
+
}),
|
|
38
|
+
...(correct === false && {
|
|
39
|
+
border: `solid 2px ${color.incorrect()}`,
|
|
40
|
+
}),
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
const StyledCard: any = styled(Card)({
|
|
44
|
+
color: color.text(),
|
|
45
|
+
backgroundColor: color.background(),
|
|
46
|
+
width: '100%',
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const StyledCardContent: any = styled(CardContent)(({ theme }) => ({
|
|
50
|
+
color: color.text(),
|
|
51
|
+
backgroundColor: color.white(),
|
|
52
|
+
'&:last-child': {
|
|
53
|
+
paddingBottom: theme.spacing(2),
|
|
54
|
+
},
|
|
55
|
+
borderRadius: '4px',
|
|
56
|
+
border: '1px solid',
|
|
57
|
+
'& p': {
|
|
58
|
+
margin: '0px',
|
|
59
|
+
},
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
export class Layout extends React.Component {
|
|
63
|
+
static propTypes = {
|
|
64
|
+
...ChoiceType,
|
|
65
|
+
disabled: PropTypes.bool,
|
|
66
|
+
correct: PropTypes.bool,
|
|
67
|
+
isDragging: PropTypes.bool,
|
|
68
|
+
};
|
|
69
|
+
static defaultProps = {};
|
|
70
|
+
render() {
|
|
71
|
+
const { content, isDragging, disabled, correct } = this.props;
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<ChoiceContainer isDragging={isDragging} disabled={disabled} correct={correct}>
|
|
75
|
+
<StyledCard>
|
|
76
|
+
<StyledCardContent dangerouslySetInnerHTML={{ __html: content }} />
|
|
77
|
+
</StyledCard>
|
|
78
|
+
</ChoiceContainer>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const DraggableChoice = ({ id, content, disabled, correct, extraStyle, categoryId, choiceIndex }) => {
|
|
84
|
+
// Generate unique draggable ID for each instance
|
|
85
|
+
// If in choices board (categoryId is undefined), use 'board' suffix
|
|
86
|
+
// If in a category, include categoryId and choiceIndex to make it unique
|
|
87
|
+
const draggableId = categoryId !== undefined ? `choice-${id}-${categoryId}-${choiceIndex}` : `choice-${id}-board`;
|
|
88
|
+
|
|
89
|
+
const { attributes, listeners, setNodeRef, isDragging } = useDraggable({
|
|
90
|
+
id: draggableId,
|
|
91
|
+
data: {
|
|
92
|
+
id,
|
|
93
|
+
categoryId,
|
|
94
|
+
choiceIndex,
|
|
95
|
+
value: content,
|
|
96
|
+
itemType: 'categorize',
|
|
97
|
+
type: 'choice',
|
|
98
|
+
},
|
|
99
|
+
disabled,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<div ref={setNodeRef} style={{ margin: '4px', ...extraStyle }} {...listeners} {...attributes}>
|
|
104
|
+
<Layout id={id} content={content} disabled={disabled} correct={correct} isDragging={isDragging} />
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
DraggableChoice.propTypes = {
|
|
110
|
+
...ChoiceType,
|
|
111
|
+
extraStyle: PropTypes.object,
|
|
112
|
+
categoryId: PropTypes.string,
|
|
113
|
+
choiceIndex: PropTypes.number,
|
|
114
|
+
onRemoveChoice: PropTypes.func,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export default uid.withUid(DraggableChoice);
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/categorize/src/categorize/choices.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, { ChoiceType } from './choice.js';
|
|
15
|
+
import DroppablePlaceholder from './droppable-placeholder.js';
|
|
16
|
+
export { ChoiceType };
|
|
17
|
+
|
|
18
|
+
const Wrapper: any = styled('div')({
|
|
19
|
+
flex: 1,
|
|
20
|
+
touchAction: 'none',
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const LabelHolder: any = styled('div')(({ theme }) => ({
|
|
24
|
+
margin: '0 auto',
|
|
25
|
+
textAlign: 'center',
|
|
26
|
+
paddingTop: theme.spacing(1),
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
export class Choices extends React.Component {
|
|
30
|
+
static propTypes = {
|
|
31
|
+
choices: PropTypes.arrayOf(
|
|
32
|
+
PropTypes.oneOfType([PropTypes.shape(ChoiceType), PropTypes.shape({ empty: PropTypes.bool })]),
|
|
33
|
+
),
|
|
34
|
+
model: PropTypes.shape({
|
|
35
|
+
categoriesPerRow: PropTypes.number,
|
|
36
|
+
choicesLabel: PropTypes.string,
|
|
37
|
+
}),
|
|
38
|
+
disabled: PropTypes.bool,
|
|
39
|
+
choicePosition: PropTypes.string,
|
|
40
|
+
onDropChoice: PropTypes.func,
|
|
41
|
+
onRemoveChoice: PropTypes.func,
|
|
42
|
+
correct: PropTypes.boolean,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
static defaultProps = {
|
|
46
|
+
model: {
|
|
47
|
+
categoriesPerRow: 1,
|
|
48
|
+
choicesLabel: '',
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
render() {
|
|
53
|
+
const { choices = [], model, disabled, onDropChoice, onRemoveChoice, choicePosition, correct } = this.props;
|
|
54
|
+
|
|
55
|
+
let style = {
|
|
56
|
+
textAlign: 'center',
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
if (choicePosition === 'left') {
|
|
60
|
+
style.direction = 'rtl';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<Wrapper>
|
|
65
|
+
<DroppablePlaceholder
|
|
66
|
+
id="choices-board"
|
|
67
|
+
onDropChoice={onDropChoice}
|
|
68
|
+
onRemoveChoice={onRemoveChoice}
|
|
69
|
+
disabled={disabled}
|
|
70
|
+
style={{ background: 'none' }}
|
|
71
|
+
choiceBoard={true}
|
|
72
|
+
correct={correct}
|
|
73
|
+
>
|
|
74
|
+
{model.choicesLabel && model.choicesLabel !== '' && (
|
|
75
|
+
<LabelHolder dangerouslySetInnerHTML={{ __html: model.choicesLabel }} />
|
|
76
|
+
)}
|
|
77
|
+
{choices.map((c, index) => {
|
|
78
|
+
return c.empty ? (
|
|
79
|
+
<div key={index} />
|
|
80
|
+
) : (
|
|
81
|
+
<Choice
|
|
82
|
+
disabled={disabled}
|
|
83
|
+
key={index}
|
|
84
|
+
extraStyle={{ maxWidth: `${95 / model.categoriesPerRow}%` }}
|
|
85
|
+
{...c}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
})}
|
|
89
|
+
</DroppablePlaceholder>
|
|
90
|
+
</Wrapper>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export default Choices;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/categorize/src/categorize/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 debug from 'debug';
|
|
14
|
+
import { useTheme } from '@mui/material/styles';
|
|
15
|
+
import { useDroppable } from '@dnd-kit/core';
|
|
16
|
+
import { PlaceHolder } from '@pie-lib/drag';
|
|
17
|
+
import { color } from '@pie-lib/render-ui';
|
|
18
|
+
|
|
19
|
+
const log = debug('@pie-ui:categorize:droppable-placeholder');
|
|
20
|
+
|
|
21
|
+
const DroppablePlaceholder = ({
|
|
22
|
+
children,
|
|
23
|
+
grid,
|
|
24
|
+
disabled,
|
|
25
|
+
choiceBoard,
|
|
26
|
+
minRowHeight,
|
|
27
|
+
id,
|
|
28
|
+
correct
|
|
29
|
+
}) => {
|
|
30
|
+
const theme = useTheme();
|
|
31
|
+
const { setNodeRef, isOver } = useDroppable({
|
|
32
|
+
id,
|
|
33
|
+
data: {
|
|
34
|
+
itemType: 'categorize',
|
|
35
|
+
categoryId: id
|
|
36
|
+
},
|
|
37
|
+
disabled,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const extraStyles = {
|
|
41
|
+
padding: theme.spacing(0.5),
|
|
42
|
+
borderRadius: theme.spacing(0.5),
|
|
43
|
+
gridColumnGap: 0,
|
|
44
|
+
gridRowGap: 0,
|
|
45
|
+
display: 'flex',
|
|
46
|
+
flexWrap: 'wrap',
|
|
47
|
+
justifyContent: 'center',
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
alignContent: 'flex-start',
|
|
50
|
+
width: '100%',
|
|
51
|
+
height: '100%',
|
|
52
|
+
...(correct === false && !choiceBoard && {
|
|
53
|
+
border: `solid 2px ${color.incorrect()}`,
|
|
54
|
+
}),
|
|
55
|
+
...(correct === true && !choiceBoard && {
|
|
56
|
+
border: `solid 2px ${color.correct()}`,
|
|
57
|
+
}),
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<div
|
|
62
|
+
ref={setNodeRef}
|
|
63
|
+
style={{
|
|
64
|
+
flex: 1,
|
|
65
|
+
minHeight: minRowHeight || '80px',
|
|
66
|
+
position: 'relative',
|
|
67
|
+
touchAction: 'none',
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
<PlaceHolder
|
|
71
|
+
isOver={isOver}
|
|
72
|
+
grid={grid}
|
|
73
|
+
disabled={disabled}
|
|
74
|
+
choiceBoard={choiceBoard}
|
|
75
|
+
isCategorize
|
|
76
|
+
extraStyles={extraStyles}
|
|
77
|
+
>
|
|
78
|
+
{children}
|
|
79
|
+
</PlaceHolder>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
DroppablePlaceholder.propTypes = {
|
|
85
|
+
choiceBoard: PropTypes.bool,
|
|
86
|
+
children: PropTypes.node.isRequired,
|
|
87
|
+
grid: PropTypes.object,
|
|
88
|
+
disabled: PropTypes.bool,
|
|
89
|
+
minRowHeight: PropTypes.string,
|
|
90
|
+
onDropChoice: PropTypes.func,
|
|
91
|
+
id: PropTypes.string.isRequired,
|
|
92
|
+
correct: PropTypes.bool
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export default DroppablePlaceholder;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/categorize/src/categorize/grid-content.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
|
+
|
|
15
|
+
export class GridContent extends React.Component {
|
|
16
|
+
static propTypes = {
|
|
17
|
+
className: PropTypes.string,
|
|
18
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
19
|
+
columns: PropTypes.number,
|
|
20
|
+
rows: PropTypes.number,
|
|
21
|
+
extraStyle: PropTypes.object,
|
|
22
|
+
};
|
|
23
|
+
static defaultProps = {
|
|
24
|
+
columns: 2,
|
|
25
|
+
rows: 2,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
render() {
|
|
29
|
+
const { className, children, columns, extraStyle, rows } = this.props;
|
|
30
|
+
const style = {
|
|
31
|
+
gridTemplateColumns: `repeat(${columns}, 1fr)`,
|
|
32
|
+
gridTemplateRows: rows === 2 ? 'auto 1fr' : `repeat(${rows}, auto)`,
|
|
33
|
+
...extraStyle,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<StyledDiv style={style} className={className}>
|
|
38
|
+
{children}
|
|
39
|
+
</StyledDiv>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const StyledDiv: any = styled('div')(({ theme }) => ({
|
|
45
|
+
display: 'grid',
|
|
46
|
+
columnGap: theme.spacing(1),
|
|
47
|
+
gridColumnGap: theme.spacing(1),
|
|
48
|
+
rowGap: theme.spacing(1),
|
|
49
|
+
gridRowGap: theme.spacing(1),
|
|
50
|
+
gridAutoRows: '1fr',
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
export default GridContent;
|