@pie-element/categorize 13.1.2-next.2 → 13.1.2

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.
Files changed (158) hide show
  1. package/CHANGELOG.json +1637 -0
  2. package/CHANGELOG.md +2542 -0
  3. package/LICENSE.md +5 -0
  4. package/README.md +5 -0
  5. package/configure/CHANGELOG.json +1202 -0
  6. package/configure/CHANGELOG.md +2125 -0
  7. package/configure/lib/defaults.js +222 -0
  8. package/configure/lib/defaults.js.map +1 -0
  9. package/configure/lib/design/builder.js +55 -0
  10. package/configure/lib/design/builder.js.map +1 -0
  11. package/configure/lib/design/buttons.js +59 -0
  12. package/configure/lib/design/buttons.js.map +1 -0
  13. package/configure/lib/design/categories/RowLabel.js +66 -0
  14. package/configure/lib/design/categories/RowLabel.js.map +1 -0
  15. package/configure/lib/design/categories/alternateResponses.js +116 -0
  16. package/configure/lib/design/categories/alternateResponses.js.map +1 -0
  17. package/configure/lib/design/categories/category.js +153 -0
  18. package/configure/lib/design/categories/category.js.map +1 -0
  19. package/configure/lib/design/categories/choice-preview.js +79 -0
  20. package/configure/lib/design/categories/choice-preview.js.map +1 -0
  21. package/configure/lib/design/categories/droppable-placeholder.js +93 -0
  22. package/configure/lib/design/categories/droppable-placeholder.js.map +1 -0
  23. package/configure/lib/design/categories/index.js +256 -0
  24. package/configure/lib/design/categories/index.js.map +1 -0
  25. package/configure/lib/design/choices/choice.js +187 -0
  26. package/configure/lib/design/choices/choice.js.map +1 -0
  27. package/configure/lib/design/choices/config.js +58 -0
  28. package/configure/lib/design/choices/config.js.map +1 -0
  29. package/configure/lib/design/choices/index.js +197 -0
  30. package/configure/lib/design/choices/index.js.map +1 -0
  31. package/configure/lib/design/header.js +71 -0
  32. package/configure/lib/design/header.js.map +1 -0
  33. package/configure/lib/design/index.js +727 -0
  34. package/configure/lib/design/index.js.map +1 -0
  35. package/configure/lib/design/input-header.js +105 -0
  36. package/configure/lib/design/input-header.js.map +1 -0
  37. package/configure/lib/design/utils.js +12 -0
  38. package/configure/lib/design/utils.js.map +1 -0
  39. package/configure/lib/index.js +147 -0
  40. package/configure/lib/index.js.map +1 -0
  41. package/configure/lib/main.js +44 -0
  42. package/configure/lib/main.js.map +1 -0
  43. package/configure/lib/utils.js +43 -0
  44. package/configure/lib/utils.js.map +1 -0
  45. package/configure/package.json +32 -0
  46. package/controller/CHANGELOG.json +452 -0
  47. package/controller/CHANGELOG.md +1377 -0
  48. package/controller/lib/defaults.js +33 -0
  49. package/controller/lib/defaults.js.map +1 -0
  50. package/controller/lib/index.js +479 -0
  51. package/controller/lib/index.js.map +1 -0
  52. package/controller/lib/utils.js +69 -0
  53. package/controller/lib/utils.js.map +1 -0
  54. package/controller/package.json +18 -0
  55. package/docs/config-schema.json +2897 -0
  56. package/docs/config-schema.json.md +2138 -0
  57. package/docs/demo/config.js +8 -0
  58. package/docs/demo/generate.js +357 -0
  59. package/docs/demo/index.html +1 -0
  60. package/docs/demo/session.js +12 -0
  61. package/docs/pie-schema.json +1784 -0
  62. package/docs/pie-schema.json.md +1046 -0
  63. package/lib/categorize/categories.js +135 -0
  64. package/lib/categorize/categories.js.map +1 -0
  65. package/lib/categorize/category.js +67 -0
  66. package/lib/categorize/category.js.map +1 -0
  67. package/lib/categorize/choice.js +140 -0
  68. package/lib/categorize/choice.js.map +1 -0
  69. package/lib/categorize/choices.js +99 -0
  70. package/lib/categorize/choices.js.map +1 -0
  71. package/lib/categorize/droppable-placeholder.js +84 -0
  72. package/lib/categorize/droppable-placeholder.js.map +1 -0
  73. package/lib/categorize/grid-content.js +55 -0
  74. package/lib/categorize/grid-content.js.map +1 -0
  75. package/lib/categorize/index.js +450 -0
  76. package/lib/categorize/index.js.map +1 -0
  77. package/lib/index.js +316 -0
  78. package/lib/index.js.map +1 -0
  79. package/package.json +22 -85
  80. package/configure.js +0 -2
  81. package/controller.js +0 -1
  82. package/dist/author/defaults.d.ts +0 -223
  83. package/dist/author/defaults.js +0 -170
  84. package/dist/author/design/builder.d.ts +0 -10
  85. package/dist/author/design/builder.js +0 -24
  86. package/dist/author/design/buttons.d.ts +0 -28
  87. package/dist/author/design/buttons.js +0 -36
  88. package/dist/author/design/categories/RowLabel.d.ts +0 -23
  89. package/dist/author/design/categories/RowLabel.js +0 -47
  90. package/dist/author/design/categories/alternateResponses.d.ts +0 -31
  91. package/dist/author/design/categories/alternateResponses.js +0 -62
  92. package/dist/author/design/categories/category.d.ts +0 -44
  93. package/dist/author/design/categories/category.js +0 -98
  94. package/dist/author/design/categories/choice-preview.d.ts +0 -25
  95. package/dist/author/design/categories/choice-preview.js +0 -60
  96. package/dist/author/design/categories/droppable-placeholder.d.ts +0 -11
  97. package/dist/author/design/categories/droppable-placeholder.js +0 -71
  98. package/dist/author/design/categories/index.d.ts +0 -41
  99. package/dist/author/design/categories/index.js +0 -146
  100. package/dist/author/design/choices/choice.d.ts +0 -11
  101. package/dist/author/design/choices/choice.js +0 -129
  102. package/dist/author/design/choices/config.d.ts +0 -21
  103. package/dist/author/design/choices/config.js +0 -33
  104. package/dist/author/design/choices/index.d.ts +0 -41
  105. package/dist/author/design/choices/index.js +0 -110
  106. package/dist/author/design/header.d.ts +0 -24
  107. package/dist/author/design/header.js +0 -49
  108. package/dist/author/design/index.d.ts +0 -52
  109. package/dist/author/design/index.js +0 -417
  110. package/dist/author/design/input-header.d.ts +0 -39
  111. package/dist/author/design/input-header.js +0 -69
  112. package/dist/author/design/utils.d.ts +0 -9
  113. package/dist/author/design/utils.js +0 -7
  114. package/dist/author/index.d.ts +0 -51
  115. package/dist/author/index.js +0 -87
  116. package/dist/author/main.d.ts +0 -23
  117. package/dist/author/main.js +0 -30
  118. package/dist/author/utils.d.ts +0 -16
  119. package/dist/author/utils.js +0 -17
  120. package/dist/browser/author/index.js +0 -2041
  121. package/dist/browser/author/index.js.map +0 -1
  122. package/dist/browser/categorize.css +0 -2
  123. package/dist/browser/controller/index.js +0 -299
  124. package/dist/browser/controller/index.js.map +0 -1
  125. package/dist/browser/delivery/index.js +0 -1051
  126. package/dist/browser/delivery/index.js.map +0 -1
  127. package/dist/browser/dist-BINEJ0Vp.js +0 -1954
  128. package/dist/browser/dist-BINEJ0Vp.js.map +0 -1
  129. package/dist/browser/dist-DDCLQ8jp.js +0 -49802
  130. package/dist/browser/dist-DDCLQ8jp.js.map +0 -1
  131. package/dist/controller/defaults.d.ts +0 -34
  132. package/dist/controller/defaults.js +0 -29
  133. package/dist/controller/index.d.ts +0 -61
  134. package/dist/controller/index.js +0 -155
  135. package/dist/controller/utils.d.ts +0 -20
  136. package/dist/controller/utils.js +0 -35
  137. package/dist/delivery/categorize/categories.d.ts +0 -34
  138. package/dist/delivery/categorize/categories.js +0 -66
  139. package/dist/delivery/categorize/category.d.ts +0 -28
  140. package/dist/delivery/categorize/category.js +0 -48
  141. package/dist/delivery/categorize/choice.d.ts +0 -27
  142. package/dist/delivery/categorize/choice.js +0 -94
  143. package/dist/delivery/categorize/choices.d.ts +0 -39
  144. package/dist/delivery/categorize/choices.js +0 -51
  145. package/dist/delivery/categorize/droppable-placeholder.d.ts +0 -32
  146. package/dist/delivery/categorize/droppable-placeholder.js +0 -64
  147. package/dist/delivery/categorize/grid-content.d.ts +0 -25
  148. package/dist/delivery/categorize/grid-content.js +0 -39
  149. package/dist/delivery/categorize/index.d.ts +0 -57
  150. package/dist/delivery/categorize/index.js +0 -260
  151. package/dist/delivery/index.d.ts +0 -27
  152. package/dist/delivery/index.js +0 -152
  153. package/dist/index.d.ts +0 -1
  154. package/dist/index.iife.d.ts +0 -8
  155. package/dist/index.iife.js +0 -152
  156. package/dist/index.js +0 -2
  157. package/dist/runtime-support.d.ts +0 -12
  158. package/dist/runtime-support.js +0 -12
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_configUi","_Info","_Tooltip","_categorize","_category","_header","_utils","_RowLabel","CategoriesContainer","styled","theme","marginBottom","spacing","CategoriesHolder","display","gridRowGap","gridColumnGap","StyledTooltip","Tooltip","fontSize","typography","whiteSpace","maxWidth","ErrorText","color","palette","error","main","paddingTop","Categories","React","Component","constructor","args","_defineProperty2","default","focusedEl","model","categories","oldCategories","props","categoriesPerRow","correctResponse","allowAlternateEnabled","id","utils","firstAvailableIndex","map","a","data","label","addRowLabel","length","rowLabels","push","setState","onModelChanged","concat","category","choices","alternateResponses","index","findIndex","splice","removeCategory","c","choice","choiceIndex","removeChoiceFromCategory","val","newRowLabels","render","imageSupport","uploadSoundSupport","toolbarOpts","spellCheck","configuration","defaultImageMaxHeight","defaultImageMaxWidth","mathMlOptions","errors","associationError","categoriesError","categoriesErrors","maxCategories","maxImageWidth","maxImageHeight","holderStyle","gridTemplateColumns","validationMessage","generateValidationMessage","createElement","buttonLabel","onAdd","add","info","disableFocusListener","disableTouchListener","placement","title","style","marginLeft","buttonDisabled","hasRowLabel","rowIndex","Fragment","key","RowLabel","disabled","markup","onChange","changeRowLabel","rowLabel","state","deleteFocusedEl","change","onDelete","delete","onDeleteChoice","deleteChoiceFromCategory","categoryLabel","alternateResponseIndex","undefined","exports","PropTypes","number","shape","func","isRequired","array","object","bool","_default"],"sources":["../../../src/design/categories/index.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport { choiceUtils as utils } from '@pie-lib/config-ui';\nimport Info from '@mui/icons-material/Info';\nimport Tooltip from '@mui/material/Tooltip';\nimport {\n removeCategory,\n removeChoiceFromCategory,\n} from '@pie-lib/categorize';\n\nimport Category from './category';\nimport Header from '../header';\nimport { generateValidationMessage } from '../../utils';\nimport { RowLabel } from './RowLabel';\n\nconst CategoriesContainer = styled('div')(({ theme }) => ({\n marginBottom: theme.spacing(3),\n}));\n\nconst CategoriesHolder = styled('div')(({ theme }) => ({\n display: 'grid',\n gridRowGap: theme.spacing(1),\n gridColumnGap: theme.spacing(1),\n}));\n\nconst StyledTooltip = styled(Tooltip)(({ theme }) => ({\n '& .MuiTooltip-tooltip': {\n fontSize: theme.typography.fontSize - 2,\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n}));\n\nconst ErrorText = styled('div')(({ theme }) => ({\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing(0.5),\n}));\n\nexport class Categories extends React.Component {\n static propTypes = {\n defaultImageMaxHeight: PropTypes.number,\n defaultImageMaxWidth: PropTypes.number,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n uploadSoundSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n categories: PropTypes.array,\n onModelChanged: PropTypes.func,\n model: PropTypes.object.isRequired,\n configuration: PropTypes.object.isRequired,\n toolbarOpts: PropTypes.object,\n spellCheck: PropTypes.bool,\n };\n\n state = {\n focusedEl: null,\n };\n\n add = () => {\n const { model, categories: oldCategories } = this.props;\n const { categoriesPerRow, correctResponse, allowAlternateEnabled } = model;\n\n const id = utils.firstAvailableIndex(\n model.categories.map((a) => a.id),\n 1,\n );\n const data = { id, label: 'Category ' + id };\n const addRowLabel = model.categories.length % categoriesPerRow === 0;\n const rowLabels = [...model.rowLabels];\n\n if (addRowLabel) {\n rowLabels.push('');\n }\n\n this.setState(\n {\n focusedEl: oldCategories.length,\n },\n () => {\n this.props.onModelChanged({\n rowLabels,\n categories: model.categories.concat([data]),\n correctResponse: allowAlternateEnabled\n ? [...correctResponse, { category: id, choices: [], alternateResponses: [] }]\n : correctResponse,\n });\n },\n );\n };\n\n deleteFocusedEl = () => {\n this.setState({\n focusedEl: null,\n });\n };\n\n delete = (category) => {\n const { model, onModelChanged } = this.props;\n const index = model.categories.findIndex((a) => a.id === category.id);\n\n if (index !== -1) {\n model.categories.splice(index, 1);\n model.correctResponse = removeCategory(category.id, model.correctResponse);\n onModelChanged(model);\n }\n };\n\n change = (c) => {\n const { categories } = this.props;\n const index = categories.findIndex((a) => a.id === c.id);\n\n if (index !== -1) {\n categories.splice(index, 1, c);\n this.props.onModelChanged({ categories });\n }\n };\n\n deleteChoiceFromCategory = (category, choice, choiceIndex) => {\n const { model, onModelChanged } = this.props;\n const correctResponse = removeChoiceFromCategory(choice.id, category.id, choiceIndex, model.correctResponse);\n\n onModelChanged({ correctResponse });\n };\n\n changeRowLabel = (val, index) => {\n const { model } = this.props;\n const { rowLabels } = model;\n const newRowLabels = [...rowLabels];\n\n if (newRowLabels.length < index) {\n newRowLabels.push(val);\n } else {\n newRowLabels[index] = val;\n }\n\n this.props.onModelChanged({\n rowLabels: newRowLabels,\n });\n };\n\n render() {\n const {\n model,\n categories,\n imageSupport,\n uploadSoundSupport,\n toolbarOpts,\n spellCheck,\n configuration,\n defaultImageMaxHeight,\n defaultImageMaxWidth,\n mathMlOptions = {},\n } = this.props;\n\n const { categoriesPerRow, rowLabels, errors } = model;\n const { associationError, categoriesError, categoriesErrors } = errors || {};\n const { maxCategories, maxImageWidth = {}, maxImageHeight = {} } = configuration || {};\n const holderStyle = {\n gridTemplateColumns: `repeat(${categoriesPerRow}, 1fr)`,\n };\n\n const validationMessage = generateValidationMessage(configuration);\n\n return (\n <CategoriesContainer>\n <Header\n label=\"Categories\"\n buttonLabel=\"ADD A CATEGORY\"\n onAdd={this.add}\n info={\n <StyledTooltip\n disableFocusListener\n disableTouchListener\n placement={'right'}\n title={validationMessage}\n >\n <Info fontSize={'small'} color={'primary'} style={{ marginLeft: '5px' }} />\n </StyledTooltip>\n }\n buttonDisabled={maxCategories && categories && maxCategories === categories.length}\n />\n\n <CategoriesHolder style={holderStyle}>\n {categories.map((category, index) => {\n const hasRowLabel = index % categoriesPerRow === 0;\n const rowIndex = index / categoriesPerRow;\n\n return (\n <React.Fragment key={index}>\n {hasRowLabel && (\n <RowLabel\n categoriesPerRow={categoriesPerRow}\n disabled={false}\n rowIndex={rowIndex}\n markup={rowLabels[rowIndex] || ''}\n onChange={(val) => this.changeRowLabel(val, rowIndex)}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n maxImageWidth={(maxImageWidth && maxImageWidth.rowLabel) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.rowLabel) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n mathMlOptions={mathMlOptions}\n configuration={configuration}\n />\n )}\n\n <Category\n imageSupport={imageSupport}\n focusedEl={this.state.focusedEl}\n deleteFocusedEl={this.deleteFocusedEl}\n index={index}\n category={category}\n error={categoriesErrors && categoriesErrors[category.id]}\n onChange={this.change}\n onDelete={() => this.delete(category)}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n onDeleteChoice={(choice, choiceIndex) => this.deleteChoiceFromCategory(category, choice, choiceIndex)}\n maxImageWidth={(maxImageWidth && maxImageWidth.categoryLabel) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.categoryLabel) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n configuration={configuration}\n alternateResponseIndex={undefined}\n />\n </React.Fragment>\n );\n })}\n </CategoriesHolder>\n\n {associationError && <ErrorText>{associationError}</ErrorText>}\n {categoriesError && <ErrorText>{categoriesError}</ErrorText>}\n </CategoriesContainer>\n );\n }\n}\n\nexport default Categories;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,QAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAKA,IAAAO,SAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,OAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,SAAA,GAA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interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+ var _styles = require("@mui/material/styles");
12
+ var _Card = _interopRequireDefault(require("@mui/material/Card"));
13
+ var _CardActions = _interopRequireDefault(require("@mui/material/CardActions"));
14
+ var _inputHeader = _interopRequireDefault(require("../input-header"));
15
+ var _configUi = require("@pie-lib/config-ui");
16
+ var _buttons = require("../buttons");
17
+ var _DragHandle = _interopRequireDefault(require("@mui/icons-material/DragHandle"));
18
+ var _core = require("@dnd-kit/core");
19
+ var _debug = _interopRequireDefault(require("debug"));
20
+ var _drag = require("@pie-lib/drag");
21
+ var _utils = require("../../utils");
22
+ const log = (0, _debug.default)('@pie-element:categorize:configure:choice');
23
+ const canDrag = props => {
24
+ if (props.lockChoiceOrder) {
25
+ return true;
26
+ }
27
+ const count = props.choice.categoryCount || 0;
28
+ if (count === 0) {
29
+ return true;
30
+ } else {
31
+ return props.correctResponseCount < count;
32
+ }
33
+ };
34
+ const StyledCard = (0, _styles.styled)(_Card.default)(({
35
+ theme
36
+ }) => ({
37
+ minWidth: '196px',
38
+ padding: theme.spacing(1),
39
+ overflow: 'visible'
40
+ }));
41
+ const StyledCardActions = (0, _styles.styled)(_CardActions.default)({
42
+ padding: 0,
43
+ justifyContent: 'space-between'
44
+ });
45
+ const DragHandleContainer = (0, _styles.styled)('span', {
46
+ shouldForwardProp: prop => prop !== 'draggable'
47
+ })(({
48
+ draggable
49
+ }) => ({
50
+ cursor: draggable ? 'move' : 'inherit',
51
+ touchAction: 'none'
52
+ }));
53
+ const ErrorText = (0, _styles.styled)('div')(({
54
+ theme
55
+ }) => ({
56
+ fontSize: theme.typography.fontSize - 2,
57
+ color: theme.palette.error.main,
58
+ paddingBottom: theme.spacing(1)
59
+ }));
60
+ const Choice = ({
61
+ allowMultiplePlacements,
62
+ configuration,
63
+ choice,
64
+ deleteFocusedEl,
65
+ focusedEl,
66
+ index,
67
+ onDelete,
68
+ onChange,
69
+ correctResponseCount,
70
+ lockChoiceOrder,
71
+ imageSupport,
72
+ spellCheck,
73
+ toolbarOpts,
74
+ error,
75
+ maxImageWidth,
76
+ maxImageHeight,
77
+ uploadSoundSupport
78
+ }) => {
79
+ const draggable = canDrag({
80
+ choice,
81
+ correctResponseCount,
82
+ lockChoiceOrder
83
+ });
84
+ const {
85
+ attributes: dragAttributes,
86
+ listeners: dragListeners,
87
+ setNodeRef: setDragNodeRef,
88
+ isDragging
89
+ } = (0, _core.useDraggable)({
90
+ id: `choice-${choice.id}`,
91
+ data: {
92
+ id: choice.id,
93
+ index,
94
+ type: 'choice'
95
+ },
96
+ disabled: !draggable
97
+ });
98
+ const {
99
+ setNodeRef: setDropNodeRef
100
+ } = (0, _core.useDroppable)({
101
+ id: `choice-drop-${choice.id}`,
102
+ data: {
103
+ id: choice.id,
104
+ index,
105
+ type: 'choice'
106
+ }
107
+ });
108
+ const changeContent = content => {
109
+ choice.content = content;
110
+ onChange(choice);
111
+ };
112
+ const changeCategoryCount = () => {
113
+ if (choice.categoryCount === 1) {
114
+ choice.categoryCount = 0;
115
+ } else {
116
+ choice.categoryCount = 1;
117
+ }
118
+ onChange(choice);
119
+ };
120
+ const isCheckboxShown = allowMultiplePlacements => allowMultiplePlacements === _utils.multiplePlacements.perChoice;
121
+ const showRemoveAfterPlacing = isCheckboxShown(allowMultiplePlacements);
122
+ const setNodeRef = element => {
123
+ setDragNodeRef(element);
124
+ setDropNodeRef(element);
125
+ };
126
+ return /*#__PURE__*/_react.default.createElement(StyledCard, {
127
+ ref: setNodeRef,
128
+ style: {
129
+ opacity: isDragging ? 0.5 : 1
130
+ }
131
+ }, /*#__PURE__*/_react.default.createElement(StyledCardActions, null, /*#__PURE__*/_react.default.createElement(DragHandleContainer, (0, _extends2.default)({
132
+ draggable: draggable
133
+ }, dragAttributes, dragListeners), /*#__PURE__*/_react.default.createElement(_DragHandle.default, {
134
+ color: draggable ? 'primary' : 'disabled'
135
+ }))), /*#__PURE__*/_react.default.createElement(_inputHeader.default, {
136
+ imageSupport: imageSupport,
137
+ focusedEl: focusedEl,
138
+ deleteFocusedEl: deleteFocusedEl,
139
+ index: index,
140
+ label: choice.content,
141
+ onChange: changeContent,
142
+ onDelete: onDelete,
143
+ toolbarOpts: toolbarOpts,
144
+ spellCheck: spellCheck,
145
+ error: error,
146
+ maxImageWidth: maxImageWidth,
147
+ maxImageHeight: maxImageHeight,
148
+ uploadSoundSupport: uploadSoundSupport,
149
+ configuration: configuration
150
+ }), error && /*#__PURE__*/_react.default.createElement(ErrorText, null, error), /*#__PURE__*/_react.default.createElement(StyledCardActions, null, /*#__PURE__*/_react.default.createElement(_buttons.DeleteButton, {
151
+ label: 'delete',
152
+ onClick: onDelete
153
+ }), showRemoveAfterPlacing && /*#__PURE__*/_react.default.createElement(_configUi.Checkbox, {
154
+ mini: true,
155
+ label: 'Remove after placing',
156
+ checked: choice.categoryCount === 1,
157
+ onChange: changeCategoryCount
158
+ })));
159
+ };
160
+ Choice.propTypes = {
161
+ allowMultiplePlacements: _propTypes.default.string,
162
+ configuration: _propTypes.default.object.isRequired,
163
+ choice: _propTypes.default.object.isRequired,
164
+ deleteFocusedEl: _propTypes.default.func,
165
+ focusedEl: _propTypes.default.number,
166
+ index: _propTypes.default.number,
167
+ lockChoiceOrder: _propTypes.default.bool,
168
+ maxImageHeight: _propTypes.default.object,
169
+ maxImageWidth: _propTypes.default.object,
170
+ onChange: _propTypes.default.func.isRequired,
171
+ onDelete: _propTypes.default.func.isRequired,
172
+ correctResponseCount: _propTypes.default.number.isRequired,
173
+ imageSupport: _propTypes.default.shape({
174
+ add: _propTypes.default.func.isRequired,
175
+ delete: _propTypes.default.func.isRequired
176
+ }),
177
+ toolbarOpts: _propTypes.default.object,
178
+ error: _propTypes.default.string,
179
+ uploadSoundSupport: _propTypes.default.shape({
180
+ add: _propTypes.default.func.isRequired,
181
+ delete: _propTypes.default.func.isRequired
182
+ }),
183
+ spellCheck: _propTypes.default.bool,
184
+ rearrangeChoices: _propTypes.default.func
185
+ };
186
+ var _default = exports.default = _drag.uid.withUid(Choice);
187
+ //# sourceMappingURL=choice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choice.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_Card","_CardActions","_inputHeader","_configUi","_buttons","_DragHandle","_core","_debug","_drag","_utils","log","debug","canDrag","props","lockChoiceOrder","count","choice","categoryCount","correctResponseCount","StyledCard","styled","Card","theme","minWidth","padding","spacing","overflow","StyledCardActions","CardActions","justifyContent","DragHandleContainer","shouldForwardProp","prop","draggable","cursor","touchAction","ErrorText","fontSize","typography","color","palette","error","main","paddingBottom","Choice","allowMultiplePlacements","configuration","deleteFocusedEl","focusedEl","index","onDelete","onChange","imageSupport","spellCheck","toolbarOpts","maxImageWidth","maxImageHeight","uploadSoundSupport","attributes","dragAttributes","listeners","dragListeners","setNodeRef","setDragNodeRef","isDragging","useDraggable","id","data","type","disabled","setDropNodeRef","useDroppable","changeContent","content","changeCategoryCount","isCheckboxShown","multiplePlacements","perChoice","showRemoveAfterPlacing","element","default","createElement","ref","style","opacity","_extends2","label","DeleteButton","onClick","Checkbox","mini","checked","propTypes","PropTypes","string","object","isRequired","func","number","bool","shape","add","delete","rearrangeChoices","_default","exports","uid","withUid"],"sources":["../../../src/design/choices/choice.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport Card from '@mui/material/Card';\nimport CardActions from '@mui/material/CardActions';\nimport InputHeader from '../input-header';\nimport { Checkbox } from '@pie-lib/config-ui';\nimport { DeleteButton } from '../buttons';\nimport DragHandle from '@mui/icons-material/DragHandle';\nimport { useDraggable, useDroppable } from '@dnd-kit/core';\nimport debug from 'debug';\nimport { uid } from '@pie-lib/drag';\nimport { multiplePlacements } from '../../utils';\n\nconst log = debug('@pie-element:categorize:configure:choice');\n\nconst canDrag = (props) => {\n if (props.lockChoiceOrder) {\n return true;\n }\n const count = props.choice.categoryCount || 0;\n if (count === 0) {\n return true;\n } else {\n return props.correctResponseCount < count;\n }\n};\n\nconst StyledCard = styled(Card)(({ theme }) => ({\n minWidth: '196px',\n padding: theme.spacing(1),\n overflow: 'visible',\n}));\n\nconst StyledCardActions = styled(CardActions)({\n padding: 0,\n justifyContent: 'space-between',\n});\n\nconst DragHandleContainer = styled('span', {\n shouldForwardProp: (prop) => prop !== 'draggable',\n})(({ draggable }) => ({\n cursor: draggable ? 'move' : 'inherit',\n touchAction: 'none',\n}));\n\nconst ErrorText = styled('div')(({ theme }) => ({\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingBottom: theme.spacing(1),\n}));\n\nconst Choice = ({\n allowMultiplePlacements,\n configuration,\n choice,\n deleteFocusedEl,\n focusedEl,\n index,\n onDelete,\n onChange,\n correctResponseCount,\n lockChoiceOrder,\n imageSupport,\n spellCheck,\n toolbarOpts,\n error,\n maxImageWidth,\n maxImageHeight,\n uploadSoundSupport,\n}) => {\n const draggable = canDrag({ choice, correctResponseCount, lockChoiceOrder });\n\n const {\n attributes: dragAttributes,\n listeners: dragListeners,\n setNodeRef: setDragNodeRef,\n isDragging,\n } = useDraggable({\n id: `choice-${choice.id}`,\n data: {\n id: choice.id,\n index,\n type: 'choice',\n },\n disabled: !draggable,\n });\n\n const {\n setNodeRef: setDropNodeRef,\n } = useDroppable({\n id: `choice-drop-${choice.id}`,\n data: {\n id: choice.id,\n index,\n type: 'choice',\n },\n });\n\n const changeContent = (content) => {\n choice.content = content;\n onChange(choice);\n };\n\n const changeCategoryCount = () => {\n if (choice.categoryCount === 1) {\n choice.categoryCount = 0;\n } else {\n choice.categoryCount = 1;\n }\n onChange(choice);\n };\n\n const isCheckboxShown = (allowMultiplePlacements) => allowMultiplePlacements === multiplePlacements.perChoice;\n\n const showRemoveAfterPlacing = isCheckboxShown(allowMultiplePlacements);\n\n const setNodeRef = (element) => {\n setDragNodeRef(element);\n setDropNodeRef(element);\n };\n\n return (\n <StyledCard ref={setNodeRef} style={{ opacity: isDragging ? 0.5 : 1 }}>\n <StyledCardActions>\n <DragHandleContainer draggable={draggable} {...dragAttributes} {...dragListeners}>\n <DragHandle color={draggable ? 'primary' : 'disabled'} />\n </DragHandleContainer>\n </StyledCardActions>\n <InputHeader\n imageSupport={imageSupport}\n focusedEl={focusedEl}\n deleteFocusedEl={deleteFocusedEl}\n index={index}\n label={choice.content}\n onChange={changeContent}\n onDelete={onDelete}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n error={error}\n maxImageWidth={maxImageWidth}\n maxImageHeight={maxImageHeight}\n uploadSoundSupport={uploadSoundSupport}\n configuration={configuration}\n />\n {error && <ErrorText>{error}</ErrorText>}\n\n <StyledCardActions>\n <DeleteButton label={'delete'} onClick={onDelete} />\n {showRemoveAfterPlacing && (\n <Checkbox\n mini\n label={'Remove after placing'}\n checked={choice.categoryCount === 1}\n onChange={changeCategoryCount}\n />\n )}\n </StyledCardActions>\n </StyledCard>\n );\n};\n\nChoice.propTypes = {\n allowMultiplePlacements: PropTypes.string,\n configuration: PropTypes.object.isRequired,\n choice: PropTypes.object.isRequired,\n deleteFocusedEl: PropTypes.func,\n focusedEl: PropTypes.number,\n index: PropTypes.number,\n lockChoiceOrder: PropTypes.bool,\n maxImageHeight: PropTypes.object,\n maxImageWidth: PropTypes.object,\n onChange: PropTypes.func.isRequired,\n onDelete: PropTypes.func.isRequired,\n correctResponseCount: PropTypes.number.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n toolbarOpts: PropTypes.object,\n error: PropTypes.string,\n uploadSoundSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n spellCheck: PropTypes.bool,\n rearrangeChoices: PropTypes.func,\n};\n\nexport default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strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.Config = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+ var _styles = require("@mui/material/styles");
12
+ var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
13
+ const ConfigContainer = (0, _styles.styled)('div')(({
14
+ theme
15
+ }) => ({
16
+ paddingTop: theme.spacing(1),
17
+ marginBottom: theme.spacing(1)
18
+ }));
19
+ const StyledTextField = (0, _styles.styled)(_TextField.default)({
20
+ width: '100%'
21
+ });
22
+ class Config extends _react.default.Component {
23
+ constructor(...args) {
24
+ super(...args);
25
+ (0, _defineProperty2.default)(this, "changeLabel", ({
26
+ target
27
+ }) => {
28
+ this.props.onModelChanged({
29
+ choicesLabel: target.value
30
+ });
31
+ });
32
+ }
33
+ render() {
34
+ const {
35
+ config,
36
+ spellCheck
37
+ } = this.props;
38
+ return /*#__PURE__*/_react.default.createElement(ConfigContainer, null, /*#__PURE__*/_react.default.createElement(StyledTextField, {
39
+ InputLabelProps: {
40
+ shrink: true
41
+ },
42
+ variant: "outlined",
43
+ label: "Label",
44
+ value: config.choicesLabel,
45
+ onChange: this.changeLabel,
46
+ spellCheck: spellCheck
47
+ }));
48
+ }
49
+ }
50
+ exports.Config = Config;
51
+ (0, _defineProperty2.default)(Config, "propTypes", {
52
+ config: _propTypes.default.object,
53
+ onModelChanged: _propTypes.default.func,
54
+ spellCheck: _propTypes.default.bool
55
+ });
56
+ (0, _defineProperty2.default)(Config, "defaultProps", {});
57
+ var _default = exports.default = Config;
58
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_TextField","ConfigContainer","styled","theme","paddingTop","spacing","marginBottom","StyledTextField","TextField","width","Config","React","Component","constructor","args","_defineProperty2","default","target","props","onModelChanged","choicesLabel","value","render","config","spellCheck","createElement","InputLabelProps","shrink","variant","label","onChange","changeLabel","exports","PropTypes","object","func","bool","_default"],"sources":["../../../src/design/choices/config.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport TextField from '@mui/material/TextField';\n\nconst ConfigContainer = styled('div')(({ theme }) => ({\n paddingTop: theme.spacing(1),\n marginBottom: theme.spacing(1),\n}));\n\nconst StyledTextField = styled(TextField)({\n width: '100%',\n});\n\nexport class Config extends React.Component {\n static propTypes = {\n config: PropTypes.object,\n onModelChanged: PropTypes.func,\n spellCheck: PropTypes.bool,\n };\n\n static defaultProps = {};\n\n changeLabel = ({ target }) => {\n this.props.onModelChanged({ choicesLabel: target.value });\n };\n\n render() {\n const { config, spellCheck } = this.props;\n\n return (\n <ConfigContainer>\n <StyledTextField\n InputLabelProps={{\n shrink: true,\n }}\n variant=\"outlined\"\n label=\"Label\"\n value={config.choicesLabel}\n onChange={this.changeLabel}\n spellCheck={spellCheck}\n />\n </ConfigContainer>\n );\n }\n}\n\nexport default Config;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEA,MAAMI,eAAe,GAAG,IAAAC,cAAM,EAAC,KAAK,CAAC,CAAC,CAAC;EAAEC;AAAM,CAAC,MAAM;EACpDC,UAAU,EAAED,KAAK,CAACE,OAAO,CAAC,CAAC,CAAC;EAC5BC,YAAY,EAAEH,KAAK,CAACE,OAAO,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEH,MAAME,eAAe,GAAG,IAAAL,cAAM,EAACM,kBAAS,CAAC,CAAC;EACxCC,KAAK,EAAE;AACT,CAAC,CAAC;AAEK,MAAMC,MAAM,SAASC,cAAK,CAACC,SAAS,CAAC;EAAAC,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,uBAS5B,CAAC;MAAEC;IAAO,CAAC,KAAK;MAC5B,IAAI,CAACC,KAAK,CAACC,cAAc,CAAC;QAAEC,YAAY,EAAEH,MAAM,CAACI;MAAM,CAAC,CAAC;IAC3D,CAAC;EAAA;EAEDC,MAAMA,CAAA,EAAG;IACP,MAAM;MAAEC,MAAM;MAAEC;IAAW,CAAC,GAAG,IAAI,CAACN,KAAK;IAEzC,oBACEvB,MAAA,CAAAqB,OAAA,CAAAS,aAAA,CAACxB,eAAe,qBACdN,MAAA,CAAAqB,OAAA,CAAAS,aAAA,CAAClB,eAAe;MACdmB,eAAe,EAAE;QACfC,MAAM,EAAE;MACV,CAAE;MACFC,OAAO,EAAC,UAAU;MAClBC,KAAK,EAAC,OAAO;MACbR,KAAK,EAAEE,MAAM,CAACH,YAAa;MAC3BU,QAAQ,EAAE,IAAI,CAACC,WAAY;MAC3BP,UAAU,EAAEA;IAAW,CACxB,CACc,CAAC;EAEtB;AACF;AAACQ,OAAA,CAAAtB,MAAA,GAAAA,MAAA;AAAA,IAAAK,gBAAA,CAAAC,OAAA,EA/BYN,MAAM,eACE;EACjBa,MAAM,EAAEU,kBAAS,CAACC,MAAM;EACxBf,cAAc,EAAEc,kBAAS,CAACE,IAAI;EAC9BX,UAAU,EAAES,kBAAS,CAACG;AACxB,CAAC;AAAA,IAAArB,gBAAA,CAAAC,OAAA,EALUN,MAAM,kBAOK,CAAC,CAAC;AAAA,IAAA2B,QAAA,GAAAL,OAAA,CAAAhB,OAAA,GA0BXN,MAAM","ignoreList":[]}
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.Choices = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+ var _styles = require("@mui/material/styles");
12
+ var _choice = _interopRequireDefault(require("./choice"));
13
+ var _header = _interopRequireDefault(require("../header"));
14
+ var _config = _interopRequireDefault(require("./config"));
15
+ var _configUi = require("@pie-lib/config-ui");
16
+ var _categorize = require("@pie-lib/categorize");
17
+ const ChoicesContainer = (0, _styles.styled)('div')(({
18
+ theme
19
+ }) => ({
20
+ marginBottom: theme.spacing(2.5)
21
+ }));
22
+ const ChoiceHolder = (0, _styles.styled)('div')(({
23
+ theme
24
+ }) => ({
25
+ paddingTop: theme.spacing(1),
26
+ paddingBottom: theme.spacing(1),
27
+ display: 'grid',
28
+ gridRowGap: theme.spacing(1),
29
+ gridColumnGap: theme.spacing(1)
30
+ }));
31
+ const ErrorText = (0, _styles.styled)('div')(({
32
+ theme
33
+ }) => ({
34
+ fontSize: theme.typography.fontSize - 2,
35
+ color: theme.palette.error.main,
36
+ paddingTop: theme.spacing(0.5)
37
+ }));
38
+ class Choices extends _react.default.Component {
39
+ constructor(...args) {
40
+ super(...args);
41
+ (0, _defineProperty2.default)(this, "state", {
42
+ focusedEl: null
43
+ });
44
+ (0, _defineProperty2.default)(this, "changeChoice", choice => {
45
+ const {
46
+ choices,
47
+ onModelChanged
48
+ } = this.props;
49
+ const index = choices.findIndex(h => h.id === choice.id);
50
+ if (index !== -1) {
51
+ choices.splice(index, 1, choice);
52
+ onModelChanged({
53
+ choices
54
+ });
55
+ }
56
+ });
57
+ (0, _defineProperty2.default)(this, "allChoicesHaveCount", count => {
58
+ const {
59
+ choices
60
+ } = this.props;
61
+ return Array.isArray(choices) && choices.every(c => c.categoryCount === count);
62
+ });
63
+ (0, _defineProperty2.default)(this, "addChoice", () => {
64
+ const {
65
+ onModelChanged,
66
+ model,
67
+ choices: oldChoices
68
+ } = this.props;
69
+ let {
70
+ maxAnswerChoices
71
+ } = model || {};
72
+ if (maxAnswerChoices && model.choices?.length >= maxAnswerChoices) {
73
+ return;
74
+ }
75
+ const id = _configUi.choiceUtils.firstAvailableIndex(model.choices.map(a => a.id), 1);
76
+ const data = {
77
+ id,
78
+ content: 'Choice ' + id
79
+ };
80
+ this.setState({
81
+ focusedEl: oldChoices.length
82
+ }, () => {
83
+ onModelChanged({
84
+ choices: model.choices.concat([data])
85
+ });
86
+ });
87
+ });
88
+ (0, _defineProperty2.default)(this, "deleteFocusedEl", () => {
89
+ this.setState({
90
+ focusedEl: null
91
+ });
92
+ });
93
+ (0, _defineProperty2.default)(this, "deleteChoice", choice => {
94
+ const {
95
+ model,
96
+ onModelChanged
97
+ } = this.props;
98
+ const index = model.choices.findIndex(a => a.id === choice.id);
99
+ if (index !== -1) {
100
+ model.choices.splice(index, 1);
101
+ model.correctResponse = (0, _categorize.removeAllChoices)(choice.id, model.correctResponse);
102
+ onModelChanged(model);
103
+ }
104
+ });
105
+ }
106
+ render() {
107
+ const {
108
+ focusedEl
109
+ } = this.state;
110
+ const {
111
+ choices,
112
+ model,
113
+ imageSupport,
114
+ uploadSoundSupport,
115
+ onModelChanged,
116
+ spellCheck,
117
+ toolbarOpts,
118
+ configuration,
119
+ defaultImageMaxWidth,
120
+ defaultImageMaxHeight
121
+ } = this.props;
122
+ const {
123
+ errors,
124
+ allowMultiplePlacementsEnabled,
125
+ lockChoiceOrder,
126
+ maxAnswerChoices
127
+ } = model;
128
+ const {
129
+ choicesError,
130
+ choicesErrors
131
+ } = errors || {};
132
+ const {
133
+ maxImageWidth = {},
134
+ maxImageHeight = {}
135
+ } = configuration || {};
136
+ const choiceHolderStyle = {
137
+ gridTemplateColumns: `repeat(${model.categoriesPerRow}, 1fr)`
138
+ };
139
+ const addChoiceButtonTooltip = maxAnswerChoices && choices?.length >= maxAnswerChoices ? `Only ${maxAnswerChoices} allowed maximum` : '';
140
+ return /*#__PURE__*/_react.default.createElement(ChoicesContainer, null, /*#__PURE__*/_react.default.createElement(_header.default, {
141
+ label: "Choices",
142
+ buttonLabel: "ADD A CHOICE",
143
+ onAdd: this.addChoice,
144
+ buttonDisabled: maxAnswerChoices && choices && choices?.length >= maxAnswerChoices,
145
+ tooltip: addChoiceButtonTooltip
146
+ }), /*#__PURE__*/_react.default.createElement(_config.default, {
147
+ config: model,
148
+ onModelChanged: onModelChanged,
149
+ spellCheck: spellCheck
150
+ }), /*#__PURE__*/_react.default.createElement(ChoiceHolder, {
151
+ style: choiceHolderStyle
152
+ }, choices.map((h, index) => {
153
+ return /*#__PURE__*/_react.default.createElement(_choice.default, {
154
+ key: h.id,
155
+ choice: h,
156
+ focusedEl: focusedEl,
157
+ deleteFocusedEl: this.deleteFocusedEl,
158
+ correctResponseCount: h.correctResponseCount,
159
+ allowMultiplePlacements: allowMultiplePlacementsEnabled,
160
+ lockChoiceOrder: lockChoiceOrder,
161
+ index: index,
162
+ imageSupport: imageSupport,
163
+ onChange: this.changeChoice,
164
+ onDelete: () => this.deleteChoice(h),
165
+ toolbarOpts: toolbarOpts,
166
+ spellCheck: spellCheck,
167
+ error: choicesErrors && choicesErrors[h.id],
168
+ maxImageWidth: maxImageWidth && maxImageWidth.choice || defaultImageMaxWidth,
169
+ maxImageHeight: maxImageHeight && maxImageHeight.choice || defaultImageMaxHeight,
170
+ uploadSoundSupport: uploadSoundSupport,
171
+ configuration: configuration
172
+ });
173
+ })), choicesError && /*#__PURE__*/_react.default.createElement(ErrorText, null, choicesError));
174
+ }
175
+ }
176
+ exports.Choices = Choices;
177
+ (0, _defineProperty2.default)(Choices, "propTypes", {
178
+ model: _propTypes.default.object.isRequired,
179
+ configuration: _propTypes.default.object.isRequired,
180
+ choices: _propTypes.default.array.isRequired,
181
+ defaultImageMaxWidth: _propTypes.default.number,
182
+ defaultImageMaxHeight: _propTypes.default.number,
183
+ onModelChanged: _propTypes.default.func.isRequired,
184
+ imageSupport: _propTypes.default.shape({
185
+ add: _propTypes.default.func.isRequired,
186
+ delete: _propTypes.default.func.isRequired
187
+ }),
188
+ uploadSoundSupport: _propTypes.default.shape({
189
+ add: _propTypes.default.func.isRequired,
190
+ delete: _propTypes.default.func.isRequired
191
+ }),
192
+ toolbarOpts: _propTypes.default.object,
193
+ spellCheck: _propTypes.default.bool
194
+ });
195
+ (0, _defineProperty2.default)(Choices, "defaultProps", {});
196
+ var _default = exports.default = Choices;
197
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_choice","_header","_config","_configUi","_categorize","ChoicesContainer","styled","theme","marginBottom","spacing","ChoiceHolder","paddingTop","paddingBottom","display","gridRowGap","gridColumnGap","ErrorText","fontSize","typography","color","palette","error","main","Choices","React","Component","constructor","args","_defineProperty2","default","focusedEl","choice","choices","onModelChanged","props","index","findIndex","h","id","splice","count","Array","isArray","every","c","categoryCount","model","oldChoices","maxAnswerChoices","length","utils","firstAvailableIndex","map","a","data","content","setState","concat","correctResponse","removeAllChoices","render","state","imageSupport","uploadSoundSupport","spellCheck","toolbarOpts","configuration","defaultImageMaxWidth","defaultImageMaxHeight","errors","allowMultiplePlacementsEnabled","lockChoiceOrder","choicesError","choicesErrors","maxImageWidth","maxImageHeight","choiceHolderStyle","gridTemplateColumns","categoriesPerRow","addChoiceButtonTooltip","createElement","label","buttonLabel","onAdd","addChoice","buttonDisabled","tooltip","config","style","key","deleteFocusedEl","correctResponseCount","allowMultiplePlacements","onChange","changeChoice","onDelete","deleteChoice","exports","PropTypes","object","isRequired","array","number","func","shape","add","delete","bool","_default"],"sources":["../../../src/design/choices/index.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport Choice from './choice';\nimport Header from '../header';\nimport Config from './config';\nimport { choiceUtils as utils } from '@pie-lib/config-ui';\nimport { removeAllChoices } from '@pie-lib/categorize';\n\nconst ChoicesContainer = styled('div')(({ theme }) => ({\n marginBottom: theme.spacing(2.5),\n}));\n\nconst ChoiceHolder = styled('div')(({ theme }) => ({\n paddingTop: theme.spacing(1),\n paddingBottom: theme.spacing(1),\n display: 'grid',\n gridRowGap: theme.spacing(1),\n gridColumnGap: theme.spacing(1),\n}));\n\nconst ErrorText = styled('div')(({ theme }) => ({\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing(0.5),\n}));\n\nexport class Choices extends React.Component {\n static propTypes = {\n model: PropTypes.object.isRequired,\n configuration: PropTypes.object.isRequired,\n choices: PropTypes.array.isRequired,\n defaultImageMaxWidth: PropTypes.number,\n defaultImageMaxHeight: PropTypes.number,\n onModelChanged: PropTypes.func.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n uploadSoundSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n toolbarOpts: PropTypes.object,\n spellCheck: PropTypes.bool,\n };\n\n static defaultProps = {};\n\n state = {\n focusedEl: null,\n };\n\n changeChoice = (choice) => {\n const { choices, onModelChanged } = this.props;\n const index = choices.findIndex((h) => h.id === choice.id);\n if (index !== -1) {\n choices.splice(index, 1, choice);\n onModelChanged({ choices });\n }\n };\n\n allChoicesHaveCount = (count) => {\n const { choices } = this.props;\n return Array.isArray(choices) && choices.every((c) => c.categoryCount === count);\n };\n\n addChoice = () => {\n const { onModelChanged, model, choices: oldChoices } = this.props;\n let { maxAnswerChoices } = model || {};\n\n if (maxAnswerChoices && model.choices?.length >= maxAnswerChoices) {\n return;\n }\n\n const id = utils.firstAvailableIndex(\n model.choices.map((a) => a.id),\n 1,\n );\n const data = { id, content: 'Choice ' + id };\n\n this.setState(\n {\n focusedEl: oldChoices.length,\n },\n () => {\n onModelChanged({ choices: model.choices.concat([data]) });\n },\n );\n };\n\n deleteFocusedEl = () => {\n this.setState({\n focusedEl: null,\n });\n };\n\n deleteChoice = (choice) => {\n const { model, onModelChanged } = this.props;\n const index = model.choices.findIndex((a) => a.id === choice.id);\n if (index !== -1) {\n model.choices.splice(index, 1);\n model.correctResponse = removeAllChoices(choice.id, model.correctResponse);\n onModelChanged(model);\n }\n };\n\n render() {\n const { focusedEl } = this.state;\n const {\n choices,\n model,\n imageSupport,\n uploadSoundSupport,\n onModelChanged,\n spellCheck,\n toolbarOpts,\n configuration,\n defaultImageMaxWidth,\n defaultImageMaxHeight,\n } = this.props;\n const { errors, allowMultiplePlacementsEnabled, lockChoiceOrder, maxAnswerChoices } = model;\n const { choicesError, choicesErrors } = errors || {};\n const { maxImageWidth = {}, maxImageHeight = {} } = configuration || {};\n const choiceHolderStyle = {\n gridTemplateColumns: `repeat(${model.categoriesPerRow}, 1fr)`,\n };\n const addChoiceButtonTooltip =\n maxAnswerChoices && choices?.length >= maxAnswerChoices ? `Only ${maxAnswerChoices} allowed maximum` : '';\n\n return (\n <ChoicesContainer>\n <Header\n label=\"Choices\"\n buttonLabel=\"ADD A CHOICE\"\n onAdd={this.addChoice}\n buttonDisabled={maxAnswerChoices && choices && choices?.length >= maxAnswerChoices}\n tooltip={addChoiceButtonTooltip}\n />\n\n <Config config={model} onModelChanged={onModelChanged} spellCheck={spellCheck} />\n\n <ChoiceHolder style={choiceHolderStyle}>\n {choices.map((h, index) => {\n return (\n <Choice\n key={h.id}\n choice={h}\n focusedEl={focusedEl}\n deleteFocusedEl={this.deleteFocusedEl}\n correctResponseCount={h.correctResponseCount}\n allowMultiplePlacements={allowMultiplePlacementsEnabled}\n lockChoiceOrder={lockChoiceOrder}\n index={index}\n imageSupport={imageSupport}\n onChange={this.changeChoice}\n onDelete={() => this.deleteChoice(h)}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheck}\n error={choicesErrors && choicesErrors[h.id]}\n maxImageWidth={(maxImageWidth && maxImageWidth.choice) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.choice) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n configuration={configuration}\n />\n );\n })}\n </ChoiceHolder>\n {choicesError && <ErrorText>{choicesError}</ErrorText>}\n </ChoicesContainer>\n );\n }\n}\n\nexport default Choices;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,OAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAEA,MAAMQ,gBAAgB,GAAG,IAAAC,cAAM,EAAC,KAAK,CAAC,CAAC,CAAC;EAAEC;AAAM,CAAC,MAAM;EACrDC,YAAY,EAAED,KAAK,CAACE,OAAO,CAAC,GAAG;AACjC,CAAC,CAAC,CAAC;AAEH,MAAMC,YAAY,GAAG,IAAAJ,cAAM,EAAC,KAAK,CAAC,CAAC,CAAC;EAAEC;AAAM,CAAC,MAAM;EACjDI,UAAU,EAAEJ,KAAK,CAACE,OAAO,CAAC,CAAC,CAAC;EAC5BG,aAAa,EAAEL,KAAK,CAACE,OAAO,CAAC,CAAC,CAAC;EAC/BI,OAAO,EAAE,MAAM;EACfC,UAAU,EAAEP,KAAK,CAACE,OAAO,CAAC,CAAC,CAAC;EAC5BM,aAAa,EAAER,KAAK,CAACE,OAAO,CAAC,CAAC;AAChC,CAAC,CAAC,CAAC;AAEH,MAAMO,SAAS,GAAG,IAAAV,cAAM,EAAC,KAAK,CAAC,CAAC,CAAC;EAAEC;AAAM,CAAC,MAAM;EAC9CU,QAAQ,EAAEV,KAAK,CAACW,UAAU,CAACD,QAAQ,GAAG,CAAC;EACvCE,KAAK,EAAEZ,KAAK,CAACa,OAAO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AAS,CAACC,MAAM,CAACC,UAAU;EAC1CpE,OAAO,EAAEkE,kBAAS,CAACG,KAAK,CAACD,UAAU;EACnCjC,oBAAoB,EAAE+B,kBAAS,CAACI,MAAM;EACtClC,qBAAqB,EAAE8B,kBAAS,CAACI,MAAM;EACvCrE,cAAc,EAAEiE,kBAAS,CAACK,IAAI,CAACH,UAAU;EACzCtC,YAAY,EAAEoC,kBAAS,CAACM,KAAK,CAAC;IAC5BC,GAAG,EAAEP,kBAAS,CAACK,IAAI,CAACH,UAAU;IAC9BM,MAAM,EAAER,kBAAS,CAACK,IAAI,CAACH;EACzB,CAAC,CAAC;EACFrC,kBAAkB,EAAEmC,kBAAS,CAACM,KAAK,CAAC;IAClCC,GAAG,EAAEP,kBAAS,CAACK,IAAI,CAACH,UAAU;IAC9BM,MAAM,EAAER,kBAAS,CAACK,IAAI,CAACH;EACzB,CAAC,CAAC;EACFnC,WAAW,EAAEiC,kBAAS,CAACC,MAAM;EAC7BnC,UAAU,EAAEkC,kBAAS,CAACS;AACxB,CAAC;AAAA,IAAA/E,gBAAA,CAAAC,OAAA,EAlBUN,OAAO,kBAoBI,CAAC,CAAC;AAAA,IAAAqF,QAAA,GAAAX,OAAA,CAAApE,OAAA,GA+HXN,OAAO","ignoreList":[]}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.Header = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+ var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
12
+ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
13
+ var _styles = require("@mui/material/styles");
14
+ var _buttons = require("./buttons");
15
+ const HeaderContainer = (0, _styles.styled)('div')(({
16
+ theme
17
+ }) => ({
18
+ display: 'flex',
19
+ justifyContent: 'space-between',
20
+ marginBottom: theme.spacing(1)
21
+ }));
22
+ const TitleContainer = (0, _styles.styled)('div')({
23
+ display: 'flex',
24
+ alignItems: 'center'
25
+ });
26
+ const StyledTooltip = (0, _styles.styled)(_Tooltip.default)(({
27
+ theme
28
+ }) => ({
29
+ '& .MuiTooltip-tooltip': {
30
+ fontSize: theme.typography.fontSize - 2,
31
+ whiteSpace: 'pre',
32
+ maxWidth: '500px'
33
+ }
34
+ }));
35
+ class Header extends _react.default.Component {
36
+ render() {
37
+ const {
38
+ onAdd,
39
+ label,
40
+ buttonLabel,
41
+ info,
42
+ buttonDisabled,
43
+ variant,
44
+ tooltip
45
+ } = this.props;
46
+ return /*#__PURE__*/_react.default.createElement(HeaderContainer, null, /*#__PURE__*/_react.default.createElement(TitleContainer, null, /*#__PURE__*/_react.default.createElement(_Typography.default, {
47
+ variant: variant || 'title'
48
+ }, label), info), /*#__PURE__*/_react.default.createElement(StyledTooltip, {
49
+ title: tooltip || '',
50
+ enterTouchDelay: 50,
51
+ leaveTouchDelay: 3000
52
+ }, /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement(_buttons.AddButton, {
53
+ onClick: onAdd,
54
+ label: buttonLabel,
55
+ disabled: buttonDisabled
56
+ }))));
57
+ }
58
+ }
59
+ exports.Header = Header;
60
+ (0, _defineProperty2.default)(Header, "propTypes", {
61
+ buttonLabel: _propTypes.default.string,
62
+ onAdd: _propTypes.default.func.isRequired,
63
+ label: _propTypes.default.string.isRequired,
64
+ info: _propTypes.default.any,
65
+ buttonDisabled: _propTypes.default.bool,
66
+ variant: _propTypes.default.string,
67
+ tooltip: _propTypes.default.string
68
+ });
69
+ (0, _defineProperty2.default)(Header, "defaultProps", {});
70
+ var _default = exports.default = Header;
71
+ //# sourceMappingURL=header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"header.js","names":["_react","_interopRequireDefault","require","_propTypes","_Tooltip","_Typography","_styles","_buttons","HeaderContainer","styled","theme","display","justifyContent","marginBottom","spacing","TitleContainer","alignItems","StyledTooltip","Tooltip","fontSize","typography","whiteSpace","maxWidth","Header","React","Component","render","onAdd","label","buttonLabel","info","buttonDisabled","variant","tooltip","props","default","createElement","title","enterTouchDelay","leaveTouchDelay","AddButton","onClick","disabled","exports","_defineProperty2","PropTypes","string","func","isRequired","any","bool","_default"],"sources":["../../src/design/header.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Tooltip from '@mui/material/Tooltip';\nimport Typography from '@mui/material/Typography';\nimport { styled } from '@mui/material/styles';\nimport { AddButton } from './buttons';\n\nconst HeaderContainer = styled('div')(({ theme }) => ({\n display: 'flex',\n justifyContent: 'space-between',\n marginBottom: theme.spacing(1),\n}));\n\nconst TitleContainer = styled('div')({\n display: 'flex',\n alignItems: 'center',\n});\n\nconst StyledTooltip = styled(Tooltip)(({ theme }) => ({\n '& .MuiTooltip-tooltip': {\n fontSize: theme.typography.fontSize - 2,\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n}));\n\nexport class Header extends React.Component {\n static propTypes = {\n buttonLabel: PropTypes.string,\n onAdd: PropTypes.func.isRequired,\n label: PropTypes.string.isRequired,\n info: PropTypes.any,\n buttonDisabled: PropTypes.bool,\n variant: PropTypes.string,\n tooltip: PropTypes.string,\n };\n\n static defaultProps = {};\n\n render() {\n const { onAdd, label, buttonLabel, info, buttonDisabled, variant, tooltip } = this.props;\n return (\n <HeaderContainer>\n <TitleContainer>\n <Typography variant={variant || 'title'}>\n {label}\n </Typography>\n {info}\n </TitleContainer>\n <StyledTooltip\n title={tooltip || ''}\n enterTouchDelay={50}\n leaveTouchDelay={3000}\n >\n <span>\n <AddButton onClick={onAdd} label={buttonLabel} disabled={buttonDisabled} />\n </span>\n </StyledTooltip>\n </HeaderContainer>\n );\n }\n}\n\nexport default Header;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAA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