@pie-element/categorize 6.7.2 → 6.7.3-next.1016
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/CHANGELOG.md +160 -0
- package/configure/CHANGELOG.md +117 -0
- package/configure/lib/defaults.js +27 -1
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/design/builder.js +1 -1
- package/configure/lib/design/buttons.js +6 -4
- package/configure/lib/design/buttons.js.map +1 -1
- package/configure/lib/design/categories/alternateResponses.js +4 -2
- package/configure/lib/design/categories/alternateResponses.js.map +1 -1
- package/configure/lib/design/categories/category.js +13 -4
- package/configure/lib/design/categories/category.js.map +1 -1
- package/configure/lib/design/categories/choice-preview.js +4 -4
- package/configure/lib/design/categories/choice-preview.js.map +1 -1
- package/configure/lib/design/categories/droppable-placeholder.js +3 -3
- package/configure/lib/design/categories/droppable-placeholder.js.map +1 -1
- package/configure/lib/design/categories/index.js +84 -11
- package/configure/lib/design/categories/index.js.map +1 -1
- package/configure/lib/design/choices/choice.js +25 -6
- package/configure/lib/design/choices/choice.js.map +1 -1
- package/configure/lib/design/choices/config.js +5 -3
- package/configure/lib/design/choices/config.js.map +1 -1
- package/configure/lib/design/choices/index.js +42 -8
- package/configure/lib/design/choices/index.js.map +1 -1
- package/configure/lib/design/header.js +15 -5
- package/configure/lib/design/header.js.map +1 -1
- package/configure/lib/design/index.js +57 -11
- package/configure/lib/design/index.js.map +1 -1
- package/configure/lib/design/input-header.js +16 -4
- package/configure/lib/design/input-header.js.map +1 -1
- package/configure/lib/index.js +3 -3
- package/configure/lib/main.js +1 -1
- package/configure/lib/main.js.map +1 -1
- package/configure/lib/utils.js +20 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +4 -4
- package/controller/CHANGELOG.md +16 -0
- package/controller/lib/index.js +83 -3
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/docs/config-schema.json +139 -0
- package/docs/config-schema.json.md +109 -1
- package/docs/demo/generate.js +1 -0
- package/docs/pie-schema.json +52 -0
- package/docs/pie-schema.json.md +43 -0
- package/lib/categorize/categories.js +9 -4
- package/lib/categorize/categories.js.map +1 -1
- package/lib/categorize/category.js +4 -4
- package/lib/categorize/category.js.map +1 -1
- package/lib/categorize/choice.js +5 -4
- package/lib/categorize/choice.js.map +1 -1
- package/lib/categorize/choices.js +12 -5
- package/lib/categorize/choices.js.map +1 -1
- package/lib/categorize/droppable-placeholder.js +2 -2
- package/lib/categorize/droppable-placeholder.js.map +1 -1
- package/lib/categorize/grid-content.js +3 -3
- package/lib/categorize/grid-content.js.map +1 -1
- package/lib/categorize/index.js +11 -15
- package/lib/categorize/index.js.map +1 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
- package/docs/demo/.pie/.configure/package.json +0 -10
- package/docs/demo/.pie/.configure/yarn.lock +0 -1128
- package/docs/demo/.pie/.controllers/package.json +0 -10
- package/docs/demo/.pie/.controllers/yarn.lock +0 -43
- package/docs/demo/.pie/info.entry.js +0 -89
- package/docs/demo/.pie/info.webpack.config.js +0 -108
- package/docs/demo/.pie/package.json +0 -10
- package/docs/demo/.pie/yarn.lock +0 -579
- package/module/configure.js +0 -3155
- package/module/controller.js +0 -19950
- package/module/demo.js +0 -118
- package/module/element.js +0 -1470
- package/module/index.html +0 -16
- package/module/manifest.json +0 -10
package/docs/pie-schema.json.md
CHANGED
|
@@ -150,6 +150,10 @@ Indicates if Feedback is enabled
|
|
|
150
150
|
|
|
151
151
|
Indicates if Rationale are enabled
|
|
152
152
|
|
|
153
|
+
# `spellCheckEnabled` (boolean, required)
|
|
154
|
+
|
|
155
|
+
Indicates if spellcheck is enabled for the author. Default value is true
|
|
156
|
+
|
|
153
157
|
# `studentInstructionsEnabled` (boolean, required)
|
|
154
158
|
|
|
155
159
|
Indicates if Student Instructions are enabled
|
|
@@ -162,6 +166,17 @@ Indicates if Teacher Instructions are enabled
|
|
|
162
166
|
|
|
163
167
|
Indicates the note for the answer
|
|
164
168
|
|
|
169
|
+
# `toolbarEditorPosition` (string, enum)
|
|
170
|
+
|
|
171
|
+
Indicates the editor's toolbar position which can be 'bottom' or 'top'
|
|
172
|
+
|
|
173
|
+
This element must be one of the following enum values:
|
|
174
|
+
|
|
175
|
+
* `bottom`
|
|
176
|
+
* `top`
|
|
177
|
+
|
|
178
|
+
Default: `": 'bottom'"`
|
|
179
|
+
|
|
165
180
|
# `id` (string, required)
|
|
166
181
|
|
|
167
182
|
Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.
|
|
@@ -188,6 +203,34 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
188
203
|
|
|
189
204
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
190
205
|
|
|
206
|
+
## `ConfigureMaxImageDimensionsProp` (object)
|
|
207
|
+
|
|
208
|
+
Properties of the `ConfigureMaxImageDimensionsProp` object:
|
|
209
|
+
|
|
210
|
+
### `teacherInstructions` (number)
|
|
211
|
+
|
|
212
|
+
Indicates the max dimension for images in teacher instructions
|
|
213
|
+
|
|
214
|
+
### `prompt` (number)
|
|
215
|
+
|
|
216
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
217
|
+
|
|
218
|
+
### `rationale` (number)
|
|
219
|
+
|
|
220
|
+
Indicates the max dimension for images in rationale
|
|
221
|
+
|
|
222
|
+
### `choices` (number)
|
|
223
|
+
|
|
224
|
+
Indicates the max dimension for images in choices
|
|
225
|
+
|
|
226
|
+
### `rowLabel` (number)
|
|
227
|
+
|
|
228
|
+
Indicates the max dimension for images in row labels
|
|
229
|
+
|
|
230
|
+
### `categoryLabel` (number)
|
|
231
|
+
|
|
232
|
+
Indicates the max dimension for images in category labels
|
|
233
|
+
|
|
191
234
|
## `CategoryChoice` (object)
|
|
192
235
|
|
|
193
236
|
Properties of the `CategoryChoice` object:
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
-
|
|
5
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
+
exports.Categories = void 0;
|
|
10
11
|
Object.defineProperty(exports, "CategoryType", {
|
|
11
12
|
enumerable: true,
|
|
12
13
|
get: function get() {
|
|
13
14
|
return _category.CategoryType;
|
|
14
15
|
}
|
|
15
16
|
});
|
|
16
|
-
exports["default"] =
|
|
17
|
+
exports["default"] = void 0;
|
|
17
18
|
|
|
18
19
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
19
20
|
|
|
@@ -45,9 +46,13 @@ var _gridContent = _interopRequireDefault(require("./grid-content"));
|
|
|
45
46
|
|
|
46
47
|
var _category = _interopRequireWildcard(require("./category"));
|
|
47
48
|
|
|
49
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
50
|
+
|
|
51
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
52
|
+
|
|
48
53
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
49
54
|
|
|
50
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
55
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
51
56
|
|
|
52
57
|
var Categories = /*#__PURE__*/function (_React$Component) {
|
|
53
58
|
(0, _inherits2["default"])(Categories, _React$Component);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/categorize/categories.jsx"],"names":["Categories","props","classes","categories","model","disabled","onDropChoice","onRemoveChoice","categoriesPerRow","chunkedCategories","Math","ceil","length","map","cat","rowIndex","items","forEach","c","columnIndex","push","label","__html","concat","Array","fill","h","id","category","React","Component","PropTypes","object","isRequired","arrayOf","shape","CategoryType","number","bool","func","styles","theme","flex","color","text","backgroundColor","background","fontSize","typography","textAlign","paddingTop","spacing","unit"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/categorize/categories.jsx"],"names":["Categories","props","classes","categories","model","disabled","onDropChoice","onRemoveChoice","categoriesPerRow","chunkedCategories","Math","ceil","length","map","cat","rowIndex","items","forEach","c","columnIndex","push","label","__html","concat","Array","fill","h","id","category","React","Component","PropTypes","object","isRequired","arrayOf","shape","CategoryType","number","bool","func","styles","theme","flex","color","text","backgroundColor","background","fontSize","typography","textAlign","paddingTop","spacing","unit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;;;;;;;;;IAIaA,U;;;;;;;;;;;;WAkBX,kBAAS;AACP,wBAOI,KAAKC,KAPT;AAAA,UACEC,OADF,eACEA,OADF;AAAA,UAEEC,UAFF,eAEEA,UAFF;AAAA,UAGEC,KAHF,eAGEA,KAHF;AAAA,UAIEC,QAJF,eAIEA,QAJF;AAAA,UAKEC,aALF,eAKEA,YALF;AAAA,UAMEC,cANF,eAMEA,cANF;AAQA,UAAQC,gBAAR,GAA6BJ,KAA7B,CAAQI,gBAAR,CATO,CAWP;AACA;;AACA,UAAMC,iBAAiB,GAAG,uBAAMN,UAAN,EAAkBK,gBAAlB,CAA1B;AAEA,0BACE,gCAAC,uBAAD;AACE,QAAA,OAAO,EAAEA,gBADX;AAEE,QAAA,SAAS,EAAEN,OAAO,CAACC,UAFrB;AAGE,QAAA,IAAI,EAAEO,IAAI,CAACC,IAAL,CAAUR,UAAU,CAACS,MAAX,GAAoBJ,gBAA9B,IAAkD;AAH1D,SAMIC,iBAAiB,CAACI,GAAlB,CAAsB,UAACC,GAAD,EAAMC,QAAN,EAAmB;AACvC,YAAIC,KAAK,GAAG,EAAZ,CADuC,CAGvC;;AACAF,QAAAA,GAAG,CAACG,OAAJ,CAAY,UAACC,CAAD,EAAIC,WAAJ,EAAoB;AAC9BH,UAAAA,KAAK,CAACI,IAAN,eACE,gCAAC,sBAAD;AAAY,YAAA,SAAS,EAAElB,OAAO,CAACmB,KAA/B;AAAsC,YAAA,GAAG,2BAAoBN,QAApB,cAAgCI,WAAhC;AAAzC,0BACE;AAAM,YAAA,uBAAuB,EAAE;AAAEG,cAAAA,MAAM,EAAEJ,CAAC,CAACG;AAAZ;AAA/B,YADF,CADF;AAID,SALD,EAJuC,CA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APZ;AAQjB1B,EAAAA,cAAc,EAAEwB,sBAAUQ,IAAV,CAAeN;AARd,C;iCADRjC,U,kBAYW;AACpBI,EAAAA,KAAK,EAAE;AACLI,IAAAA,gBAAgB,EAAE;AADb;AADa,C;;AAiExB,IAAMgC,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBtC,IAAAA,UAAU,EAAE;AACVuC,MAAAA,IAAI,EAAE;AADI,KADW;AAIvBrB,IAAAA,KAAK,EAAE;AACLsB,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADF;AAELC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN,EAFZ;AAGLC,MAAAA,QAAQ,EAAEN,KAAK,CAACO,UAAN,CAAiBD,QAHtB;AAILE,MAAAA,SAAS,EAAE,QAJN;AAKLC,MAAAA,UAAU,EAAET,KAAK,CAACU,OAAN,CAAcC;AALrB;AAJgB,GAAL;AAAA,CAApB;;eAYe,wBAAWZ,MAAX,EAAmBxC,UAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport { color } from '@pie-lib/render-ui';\n\nimport chunk from 'lodash/chunk';\n\nimport GridContent from './grid-content';\nimport Category, { CategoryType } from './category';\n\nexport { CategoryType };\n\nexport class Categories extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n categories: PropTypes.arrayOf(PropTypes.shape(CategoryType)),\n model: PropTypes.shape({\n categoriesPerRow: PropTypes.number\n }),\n disabled: PropTypes.bool,\n onDropChoice: PropTypes.func.isRequired,\n onRemoveChoice: PropTypes.func.isRequired,\n };\n\n static defaultProps = {\n model: {\n categoriesPerRow: 1\n }\n };\n\n render() {\n const {\n classes,\n categories,\n model,\n disabled,\n onDropChoice,\n onRemoveChoice,\n } = this.props;\n const { categoriesPerRow } = model;\n\n // split categories into an array of arrays (inner array),\n // where each inner array represents how many categories should be displayed on one row\n const chunkedCategories = chunk(categories, categoriesPerRow);\n\n return (\n <GridContent\n columns={categoriesPerRow}\n className={classes.categories}\n rows={Math.ceil(categories.length / categoriesPerRow) * 2}\n >\n {\n chunkedCategories.map((cat, rowIndex) => {\n let items = [];\n\n // for each inner array of categories, create a row with category titles\n cat.forEach((c, columnIndex) => {\n items.push((\n <Typography className={classes.label} key={`category-label-${rowIndex}-${columnIndex}`}>\n <span dangerouslySetInnerHTML={{ __html: c.label }}/>\n </Typography>));\n });\n\n // if the last row has less categories than max on a row, fill the spaces with divs\n items = items.concat(Array(categoriesPerRow - cat.length).fill(<div/>));\n\n // for each inner array of categories, create a row with category containers\n cat.forEach((c, columnIndex) => {\n items.push(<Category\n onDropChoice={h => onDropChoice(c.id, h)}\n onRemoveChoice={onRemoveChoice}\n disabled={disabled}\n className={classes.category}\n key={`category-element-${rowIndex}-${columnIndex}`}\n {...c}\n />);\n });\n\n // if the last row has less categories than max on a row, fill the spaces with divs\n items = items.concat(Array(categoriesPerRow - cat.length).fill(<div/>));\n\n return items;\n })\n }\n </GridContent>\n );\n }\n}\n\nconst styles = theme => ({\n categories: {\n flex: 1\n },\n label: {\n color: color.text(),\n backgroundColor: color.background(),\n fontSize: theme.typography.fontSize,\n textAlign: 'center',\n paddingTop: theme.spacing.unit\n }\n});\nexport default withStyles(styles)(Categories);\n"],"file":"categories.js"}
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports["default"] = exports.
|
|
8
|
+
exports["default"] = exports.CategoryType = exports.Category = void 0;
|
|
9
9
|
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
|
|
@@ -35,13 +35,13 @@ var _droppablePlaceholder = _interopRequireDefault(require("./droppable-placehol
|
|
|
35
35
|
|
|
36
36
|
var _renderUi = require("@pie-lib/render-ui");
|
|
37
37
|
|
|
38
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
38
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
39
39
|
|
|
40
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
40
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
41
41
|
|
|
42
42
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
43
43
|
|
|
44
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
44
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
45
45
|
|
|
46
46
|
var CategoryType = {
|
|
47
47
|
id: _propTypes["default"].string.isRequired,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/categorize/category.jsx"],"names":["CategoryType","id","PropTypes","string","isRequired","categoryId","Category","props","classes","className","choices","disabled","onDropChoice","onRemoveChoice","correct","names","category","placeholderNames","placeholder","incorrect","map","c","index","React","Component","bool","object","func","styles","theme","border","color","minHeight","padding","spacing","unit","borderRadius","gridColumnGap","gridRowGap","display","flexWrap","justifyContent","alignItems","alignContent","flexDirection"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEO,IAAMA,YAAY,GAAG;AAC1BC,EAAAA,EAAE,EAAEC,sBAAUC,MAAV,CAAiBC,UADK;AAE1BC,EAAAA,UAAU,EAAEH,sBAAUC;AAFI,CAArB;;;IAKMG,Q;;;;;;;;;;;;WAYX,kBAAS;
|
|
1
|
+
{"version":3,"sources":["../../src/categorize/category.jsx"],"names":["CategoryType","id","PropTypes","string","isRequired","categoryId","Category","props","classes","className","choices","disabled","onDropChoice","onRemoveChoice","correct","names","category","placeholderNames","placeholder","incorrect","map","c","index","React","Component","bool","object","func","styles","theme","border","color","minHeight","padding","spacing","unit","borderRadius","gridColumnGap","gridRowGap","display","flexWrap","justifyContent","alignItems","alignContent","flexDirection"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEO,IAAMA,YAAY,GAAG;AAC1BC,EAAAA,EAAE,EAAEC,sBAAUC,MAAV,CAAiBC,UADK;AAE1BC,EAAAA,UAAU,EAAEH,sBAAUC;AAFI,CAArB;;;IAKMG,Q;;;;;;;;;;;;WAYX,kBAAS;AACP,wBASI,KAAKC,KATT;AAAA,UACEC,OADF,eACEA,OADF;AAAA,UAEEC,SAFF,eAEEA,SAFF;AAAA,4CAGEC,OAHF;AAAA,UAGEA,OAHF,oCAG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AN,EAAf;AADG,KADc;AAIzBD,IAAAA,WAAW,EAAE;AACXc,MAAAA,SAAS,EAAE,MADA;AAEXC,MAAAA,OAAO,EAAEJ,KAAK,CAACK,OAAN,CAAcC,IAAd,GAAqB,CAFnB;AAGXC,MAAAA,YAAY,EAAEP,KAAK,CAACK,OAAN,CAAcC,IAAd,GAAqB,CAHxB;AAIXE,MAAAA,aAAa,EAAE,CAJJ;AAKXC,MAAAA,UAAU,EAAE,CALD;AAMXC,MAAAA,OAAO,EAAE,MANE;AAOXC,MAAAA,QAAQ,EAAE,MAPC;AAQXC,MAAAA,cAAc,EAAE,QARL;AASXC,MAAAA,UAAU,EAAE,QATD;AAUXC,MAAAA,YAAY,EAAE;AAVH,KAJY;AAgBzB3B,IAAAA,QAAQ,EAAE;AACRuB,MAAAA,OAAO,EAAE,MADD;AAERK,MAAAA,aAAa,EAAE;AAFP;AAhBe,GAAZ;AAAA,CAAf;;eAsBe,wBAAWhB,MAAX,EAAmBtB,QAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport Choice from './choice';\nimport PlaceHolder from './droppable-placeholder';\nimport { color } from '@pie-lib/render-ui';\n\nexport const CategoryType = {\n id: PropTypes.string.isRequired,\n categoryId: PropTypes.string,\n};\n\nexport class Category extends React.Component {\n static propTypes = {\n ...CategoryType,\n className: PropTypes.string,\n disabled: PropTypes.bool,\n classes: PropTypes.object.isRequired,\n onDropChoice: PropTypes.func,\n onRemoveChoice: PropTypes.func,\n };\n\n static defaultProps = {};\n\n render() {\n const {\n classes,\n className,\n choices = [],\n disabled,\n onDropChoice,\n onRemoveChoice,\n id,\n correct,\n } = this.props;\n\n const names = classNames(classes.category, className);\n const placeholderNames = classNames(\n classes.placeholder,\n correct === false && classes.incorrect\n );\n\n return (\n <div className={names}>\n <PlaceHolder\n onDropChoice={onDropChoice}\n disabled={disabled}\n className={placeholderNames}\n >\n {choices.map((c, index) => (\n <Choice\n onRemoveChoice={onRemoveChoice}\n disabled={disabled}\n key={index}\n choiceIndex={index}\n categoryId={id}\n {...c}\n />\n ))}\n </PlaceHolder>\n </div>\n );\n }\n}\n\nconst styles = (theme) => ({\n incorrect: {\n border: `solid 2px ${color.incorrect()}`,\n },\n placeholder: {\n minHeight: '80px',\n padding: theme.spacing.unit / 2,\n borderRadius: theme.spacing.unit / 2,\n gridColumnGap: 0,\n gridRowGap: 0,\n display: 'flex',\n flexWrap: 'wrap',\n justifyContent: 'center',\n alignItems: 'center',\n alignContent: 'flex-start'\n },\n category: {\n display: 'flex',\n flexDirection: 'column',\n },\n});\n\nexport default withStyles(styles)(Category);\n"],"file":"category.js"}
|
package/lib/categorize/choice.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports["default"] = exports.
|
|
8
|
+
exports.spec = exports["default"] = exports.Layout = exports.ChoiceType = exports.Choice = void 0;
|
|
9
9
|
|
|
10
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
11
|
|
|
@@ -39,13 +39,13 @@ var _renderUi = require("@pie-lib/render-ui");
|
|
|
39
39
|
|
|
40
40
|
var _debug = _interopRequireDefault(require("debug"));
|
|
41
41
|
|
|
42
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
42
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
43
43
|
|
|
44
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
44
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
45
45
|
|
|
46
46
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
47
47
|
|
|
48
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
48
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
49
49
|
|
|
50
50
|
var log = (0, _debug["default"])('@pie-ui:categorize:choice');
|
|
51
51
|
var ChoiceType = {
|
|
@@ -105,6 +105,7 @@ exports.Layout = Layout;
|
|
|
105
105
|
var styles = function styles(theme) {
|
|
106
106
|
return {
|
|
107
107
|
choice: {
|
|
108
|
+
direction: 'initial',
|
|
108
109
|
cursor: 'pointer',
|
|
109
110
|
width: '100%',
|
|
110
111
|
'&.correct': {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/categorize/choice.jsx"],"names":["log","ChoiceType","content","PropTypes","string","isRequired","id","Layout","props","classes","className","isDragging","disabled","correct","rootNames","choice","dragging","cardNames","card","root","cardRoot","__html","React","Component","object","bool","styles","theme","cursor","width","border","color","incorrect","borderRadius","text","backgroundColor","background","fontSize","typography","paddingBottom","spacing","unit","opacity","Styled","Choice","connectDragSource","extraStyle","margin","func","spec","canDrag","beginDrag","out","categoryId","choiceIndex","endDrag","monitor","didDrop","item","getItem","onRemoveChoice","DraggableChoice","uid","connect","dragSource","withUid"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,2BAAN,CAAZ;AAEO,IAAMC,UAAU,GAAG;AACxBC,EAAAA,OAAO,EAAEC,sBAAUC,MAAV,CAAiBC,UADF;AAExBC,EAAAA,EAAE,EAAEH,sBAAUC;AAFU,CAAnB;;;IAKMG,M;;;;;;;;;;;;WASX,kBAAS;
|
|
1
|
+
{"version":3,"sources":["../../src/categorize/choice.jsx"],"names":["log","ChoiceType","content","PropTypes","string","isRequired","id","Layout","props","classes","className","isDragging","disabled","correct","rootNames","choice","dragging","cardNames","card","root","cardRoot","__html","React","Component","object","bool","styles","theme","direction","cursor","width","border","color","incorrect","borderRadius","text","backgroundColor","background","fontSize","typography","paddingBottom","spacing","unit","opacity","Styled","Choice","connectDragSource","extraStyle","margin","func","spec","canDrag","beginDrag","out","categoryId","choiceIndex","endDrag","monitor","didDrop","item","getItem","onRemoveChoice","DraggableChoice","uid","connect","dragSource","withUid"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,2BAAN,CAAZ;AAEO,IAAMC,UAAU,GAAG;AACxBC,EAAAA,OAAO,EAAEC,sBAAUC,MAAV,CAAiBC,UADF;AAExBC,EAAAA,EAAE,EAAEH,sBAAUC;AAFU,CA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D;AACF;AACF;AAnBiB,CAAb;;AAsBP,IAAMG,eAAe,GAAG,0BACtB;AAAA,MAAGC,GAAH,QAAGA,GAAH;AAAA,SAAaA,GAAb;AAAA,CADsB,EAEtBb,IAFsB,EAGtB,UAACc,OAAD,EAAUP,OAAV;AAAA,SAAuB;AACrBX,IAAAA,iBAAiB,EAAEkB,OAAO,CAACC,UAAR,EADE;AAErBtD,IAAAA,UAAU,EAAE8C,OAAO,CAAC9C,UAAR;AAFS,GAAvB;AAAA,CAHsB,EAOtBkC,MAPsB,CAAxB;;eASekB,UAAIG,OAAJ,CAAYJ,eAAZ,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport { DragSource } from 'react-dnd';\nimport { uid } from '@pie-lib/drag';\nimport Card from '@material-ui/core/Card';\nimport CardContent from '@material-ui/core/CardContent';\nimport { color } from '@pie-lib/render-ui';\nimport debug from 'debug';\n\nconst log = debug('@pie-ui:categorize:choice');\n\nexport const ChoiceType = {\n content: PropTypes.string.isRequired,\n id: PropTypes.string\n};\n\nexport class Layout extends React.Component {\n static propTypes = {\n ...ChoiceType,\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n disabled: PropTypes.bool,\n correct: PropTypes.bool\n };\n static defaultProps = {};\n render() {\n const {\n classes,\n className,\n content,\n isDragging,\n disabled,\n correct\n } = this.props;\n\n const rootNames = classNames(\n correct === true && 'correct',\n correct === false && 'incorrect',\n classes.choice,\n isDragging && classes.dragging,\n disabled && classes.disabled,\n className\n );\n const cardNames = classNames(classes.card);\n return (\n <div className={rootNames}>\n <Card className={cardNames}>\n <CardContent classes={{ root: classes.cardRoot }} dangerouslySetInnerHTML={{ __html: content }} />\n </Card>\n </div>\n );\n }\n}\n\nconst styles = theme => ({\n choice: {\n direction: 'initial',\n cursor: 'pointer',\n width: '100%',\n '&.correct': {\n border: `solid 2px ${color.correct()}`\n },\n '&.incorrect': {\n border: `solid 2px ${color.incorrect()}`\n },\n borderRadius: '6px'\n },\n cardRoot: {\n color: color.text(),\n backgroundColor: color.background(),\n fontSize: theme.typography.fontSize + 2,\n '&:last-child': {\n paddingBottom: theme.spacing.unit * 2\n },\n borderRadius: '4px',\n border: '1px solid'\n },\n disabled: {\n cursor: 'not-allowed',\n opacity: '0.6'\n },\n dragging: {\n cursor: 'move'\n },\n card: {\n color: color.text(),\n backgroundColor: color.background(),\n width: '100%'\n }\n});\n\nconst Styled = withStyles(styles)(Layout);\n\nexport class Choice extends React.Component {\n static propTypes = {\n ...ChoiceType,\n extraStyle: PropTypes.object,\n connectDragSource: PropTypes.func.isRequired\n };\n\n render() {\n const {\n connectDragSource,\n id,\n content,\n disabled,\n isDragging,\n correct,\n extraStyle\n } = this.props;\n\n return connectDragSource(\n <div style={{ margin: '4px', ...extraStyle }}>\n <Styled\n id={id}\n content={content}\n disabled={disabled}\n correct={correct}\n isDragging={isDragging}\n />\n </div>\n );\n }\n}\n\nexport const spec = {\n canDrag: props => !props.disabled,\n beginDrag: props => {\n const out = {\n id: props.id,\n categoryId: props.categoryId,\n choiceIndex: props.choiceIndex\n };\n log('[beginDrag] out:', out);\n return out;\n },\n endDrag: (props, monitor) => {\n if (!monitor.didDrop()) {\n const item = monitor.getItem();\n if (item.categoryId) {\n log('wasnt droppped - what to do?');\n props.onRemoveChoice(item);\n }\n }\n }\n};\n\nconst DraggableChoice = DragSource(\n ({ uid }) => uid,\n spec,\n (connect, monitor) => ({\n connectDragSource: connect.dragSource(),\n isDragging: monitor.isDragging()\n })\n)(Choice);\n\nexport default uid.withUid(DraggableChoice);\n"],"file":"choice.js"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
-
|
|
5
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
@@ -37,9 +37,13 @@ var _styles = require("@material-ui/core/styles");
|
|
|
37
37
|
|
|
38
38
|
var _choice = _interopRequireWildcard(require("./choice"));
|
|
39
39
|
|
|
40
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
41
|
+
|
|
42
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
43
|
+
|
|
40
44
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
41
45
|
|
|
42
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
46
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
43
47
|
|
|
44
48
|
var Blank = function Blank() {
|
|
45
49
|
return /*#__PURE__*/_react["default"].createElement("div", null);
|
|
@@ -76,8 +80,11 @@ var Choices = /*#__PURE__*/function (_React$Component) {
|
|
|
76
80
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
77
81
|
className: classes.wrapper
|
|
78
82
|
}, model.choicesLabel && model.choicesLabel !== '' && /*#__PURE__*/_react["default"].createElement("div", {
|
|
79
|
-
className: classes.labelHolder
|
|
80
|
-
|
|
83
|
+
className: classes.labelHolder,
|
|
84
|
+
dangerouslySetInnerHTML: {
|
|
85
|
+
__html: model.choicesLabel
|
|
86
|
+
}
|
|
87
|
+
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
81
88
|
className: classes.choices,
|
|
82
89
|
style: style
|
|
83
90
|
}, choices.map(function (c, index) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/categorize/choices.jsx"],"names":["Blank","Choices","props","classes","choices","model","disabled","choicePosition","style","textAlign","direction","wrapper","choicesLabel","labelHolder","map","c","index","empty","choice","maxWidth","categoriesPerRow","React","Component","PropTypes","object","isRequired","arrayOf","oneOfType","shape","ChoiceType","bool","number","string","styles","theme","flex","padding","spacing","unit","display","justifyContent","alignItems","flexWrap","margin","paddingTop"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA
|
|
1
|
+
{"version":3,"sources":["../../src/categorize/choices.jsx"],"names":["Blank","Choices","props","classes","choices","model","disabled","choicePosition","style","textAlign","direction","wrapper","choicesLabel","labelHolder","__html","map","c","index","empty","choice","maxWidth","categoriesPerRow","React","Component","PropTypes","object","isRequired","arrayOf","oneOfType","shape","ChoiceType","bool","number","string","styles","theme","flex","padding","spacing","unit","display","justifyContent","alignItems","flexWrap","margin","paddingTop"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;AAGA,IAAMA,KAAK,GAAG,SAARA,KAAQ;AAAA,sBAAM,4CAAN;AAAA,CAAd;;IAEaC,O;;;;;;;;;;;;WAwBX,kBAAS;AACP,wBAMI,KAAKC,KANT;AAAA,UACEC,OADF,eACEA,OADF;AAAA,4CAEEC,OAFF;AAAA,UAEEA,OAFF,oCAEY,EAFZ;AAAA,UAGEC,KAHF,eAGEA,KAHF;AAAA,UAIEC,QAJF,eAIEA,QAJF;AAAA,UAKEC,cALF,eAKEA,cALF;AAOA,UAAIC,KAAK,GAAG;AACVC,QAAAA,SAAS,EAAE;AADD,OAAZ;;AAIA,UAAIF,cAAc,KAAK,MAAvB,EAA+B;AAC7BC,QAAAA,KAAK,CAACE,SAAN,GAAkB,KAAlB;AACD;;AAED,0BACE;AAAK,QAAA,SAAS,EAAEP,OAAO,CAACQ;AAAxB,SACGN,KAAK,CAACO,YAAN,IAAsBP,KAAK,CAACO,YAAN,KAAuB,EAA7C,iBACC;AAAK,QAAA,SAAS,EAAET,OAAO,CAACU,WAAxB;AAAqC,QAAA,uBAAuB,EAAE;AAACC,UAAAA,MAAM,EAAET,KAAK,CAACO;AAAf;AAA9D,QAFJ,eAIE;AAAK,QAAA,SAAS,EAAET,OAAO,CAACC,OAAxB;AAAiC,QAAA,KAAK,EAAEI;AAAxC,SACGJ,OAAO,CAACW,GAAR,CAAY,UAACC,CAAD,EAAIC,KAAJ,EAAc;AACzB,eAAOD,CAAC,CAACE,KAAF,gBACL,gCAAC,KAAD;AAAO,UAAA,GAAG,EAAED;AAAZ,UADK,gBAGL,gCAAC,kBAAD;AACE,UAAA,QAAQ,EAAEX,QADZ;AAEE,UAAA,SAAS,EAAEH,OAAO,CAACgB,MAFrB;AAGE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UAAU,EAAE,QAJL;AAKPC,MAAAA,QAAQ,EAAE;AALH,KALgB;AAYzB9B,IAAAA,WAAW,EAAE;AACX+B,MAAAA,MAAM,EAAE,QADG;AAEXnC,MAAAA,SAAS,EAAE,QAFA;AAGXoC,MAAAA,UAAU,EAAEV,KAAK,CAACG,OAAN,CAAcC;AAHf;AAZY,GAAZ;AAAA,CAAf;;eAmBe,wBAAWL,MAAX,EAAmBjC,OAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport Choice, { ChoiceType } from './choice';\nexport { ChoiceType };\n\nconst Blank = () => <div />;\n\nexport class Choices extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n choices: PropTypes.arrayOf(\n PropTypes.oneOfType([\n PropTypes.shape(ChoiceType),\n PropTypes.shape({ empty: PropTypes.bool }),\n ])\n ),\n model: PropTypes.shape({\n categoriesPerRow: PropTypes.number,\n choicesLabel: PropTypes.string,\n }),\n disabled: PropTypes.bool,\n choicePosition: PropTypes.string,\n };\n\n static defaultProps = {\n model: {\n categoriesPerRow: 1,\n choicesLabel: '',\n },\n };\n\n render() {\n const {\n classes,\n choices = [],\n model,\n disabled,\n choicePosition,\n } = this.props;\n let style = {\n textAlign: 'center',\n };\n\n if (choicePosition === 'left') {\n style.direction = 'rtl';\n }\n\n return (\n <div className={classes.wrapper}>\n {model.choicesLabel && model.choicesLabel !== '' && (\n <div className={classes.labelHolder} dangerouslySetInnerHTML={{__html: model.choicesLabel}}></div>\n )}\n <div className={classes.choices} style={style}>\n {choices.map((c, index) => {\n return c.empty ? (\n <Blank key={index} />\n ) : (\n <Choice\n disabled={disabled}\n className={classes.choice}\n key={index}\n extraStyle={{ maxWidth: `${95 / model.categoriesPerRow}%` }}\n {...c}\n />\n );\n })}\n </div>\n </div>\n );\n }\n}\n\nconst styles = (theme) => ({\n wrapper: {\n flex: 1,\n padding: theme.spacing.unit,\n },\n choices: {\n padding: theme.spacing.unit / 2,\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'wrap'\n },\n labelHolder: {\n margin: '0 auto',\n textAlign: 'center',\n paddingTop: theme.spacing.unit,\n },\n});\n\nexport default withStyles(styles)(Choices);\n"],"file":"choices.js"}
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports["default"] = exports.
|
|
8
|
+
exports.spec = exports["default"] = exports.DroppablePlaceholder = void 0;
|
|
9
9
|
|
|
10
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
11
|
|
|
@@ -31,7 +31,7 @@ var _debug = _interopRequireDefault(require("debug"));
|
|
|
31
31
|
|
|
32
32
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
33
33
|
|
|
34
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
34
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
35
35
|
|
|
36
36
|
var log = (0, _debug["default"])('@pie-ui:categorize:droppable-placeholder');
|
|
37
37
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/categorize/droppable-placeholder.jsx"],"names":["log","DroppablePlaceholder","props","children","connectDropTarget","isOver","className","grid","disabled","flex","React","Component","PropTypes","func","isRequired","bool","oneOfType","arrayOf","node","string","object","spec","drop","monitor","item","getItem","onDropChoice","canDrop","WithTarget","uid","connect","dropTarget","withUid"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,0CAAN,CAAZ;;IAEaC,oB;;;;;;;;;;;;WAYX,kBAAS;
|
|
1
|
+
{"version":3,"sources":["../../src/categorize/droppable-placeholder.jsx"],"names":["log","DroppablePlaceholder","props","children","connectDropTarget","isOver","className","grid","disabled","flex","React","Component","PropTypes","func","isRequired","bool","oneOfType","arrayOf","node","string","object","spec","drop","monitor","item","getItem","onDropChoice","canDrop","WithTarget","uid","connect","dropTarget","withUid"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,0CAAN,CAAZ;;IAEaC,oB;;;;;;;;;;;;WAYX,kBAAS;AACP,wBAOI,KAAKC,KAPT;AAAA,UACEC,QADF,eACEA,QADF;AAAA,UAEEC,iBAFF,eAEEA,iBAFF;AAAA,UAGEC,MAHF,eAGEA,MAHF;AAAA,UAIEC,SAJF,eAIEA,SAJF;AAAA,UAKEC,IALF,eAKEA,IALF;AAAA,UAMEC,QANF,eAMEA,QANF;AASA,aAAOJ,iBAAiB,eACtB;AAAK,QAAA,KAAK,EAAE;AAAEK,UAAAA,IAAI,EAAE;AAAR;AAAZ,sBACE,gCAAC,iBAAD;AACE,QAAA,SAAS,EAAEH,SADb;AAEE,QAAA,MAAM,EAAED,MAFV;AAGE,QAAA,IAAI,EAAEE,IAHR;AAIE,QAAA,QAAQ,EAAEC;AAJZ,SAMGL,QANH,CADF,CADsB,CAAxB;AAYD;;;EAlCuCO,kBAAMC,S;;;iCAAnCV,oB,eACQ;AACjBG,EAAAA,iBAAiB,EAAEQ,sBAAUC,IAAV,CAAeC,UADjB;AAEjBT,EAAAA,MAAM,EAAEO,sBAAUG,IAFD;AAGjBZ,EAAAA,QAAQ,EAAES,sBAAUI,SAAV,CAAoB,CAC5BJ,sBAAUK,OAAV,CAAkBL,sBAAUM,IAA5B,CAD4B,EAE5BN,sBAAUM,IAFkB,CAApB,EAGPJ,UANc;AAOjBR,EAAAA,SAAS,EAAEM,sBAAUO,MAPJ;AAQjBZ,EAAAA,IAAI,EAAEK,sBAAUQ,MARC;AASjBZ,EAAAA,QAAQ,EAAEI,sBAAUG;AATH,C;AAoCd,IAAMM,IAAI,GAAG;AAClBC,EAAAA,IAAI,EAAE,cAACpB,KAAD,EAAQqB,OAAR,EAAoB;AACxBvB,IAAAA,GAAG,CAAC,gBAAD,EAAmBE,KAAnB,CAAH;AACA,QAAMsB,IAAI,GAAGD,OAAO,CAACE,OAAR,EAAb;AACAvB,IAAAA,KAAK,CAACwB,YAAN,CAAmBF,IAAnB;AACD,GALiB;AAMlBG,EAAAA,OAAO,EAAE,iBAACzB;AAAM;AAAP,IAAyB;AAChC,WAAO,CAACA,KAAK,CAACM,QAAd;AACD;AARiB,CAAb;;AAWP,IAAMoB,UAAU,GAAG,0BAAW;AAAA,MAAGC,GAAH,QAAGA,GAAH;AAAA,SAAaA,GAAb;AAAA,CAAX,EAA6BR,IAA7B,EAAmC,UAACS,OAAD,EAAUP,OAAV;AAAA,SAAuB;AAC3EnB,IAAAA,iBAAiB,EAAE0B,OAAO,CAACC,UAAR,EADwD;AAE3E1B,IAAAA,MAAM,EAAEkB,OAAO,CAAClB,MAAR;AAFmE,GAAvB;AAAA,CAAnC,EAGfJ,oBAHe,CAAnB;;eAKe4B,UAAIG,OAAJ,CAAYJ,UAAZ,C","sourcesContent":["import React from 'react';\nimport { PlaceHolder } from '@pie-lib/drag';\nimport PropTypes from 'prop-types';\nimport { DropTarget } from 'react-dnd';\nimport { uid } from '@pie-lib/drag';\nimport debug from 'debug';\n\nconst log = debug('@pie-ui:categorize:droppable-placeholder');\n\nexport class DroppablePlaceholder extends React.Component {\n static propTypes = {\n connectDropTarget: PropTypes.func.isRequired,\n isOver: PropTypes.bool,\n children: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.node),\n PropTypes.node\n ]).isRequired,\n className: PropTypes.string,\n grid: PropTypes.object,\n disabled: PropTypes.bool\n };\n render() {\n const {\n children,\n connectDropTarget,\n isOver,\n className,\n grid,\n disabled\n } = this.props;\n\n return connectDropTarget(\n <div style={{ flex: 1 }}>\n <PlaceHolder\n className={className}\n isOver={isOver}\n grid={grid}\n disabled={disabled}\n >\n {children}\n </PlaceHolder>\n </div>\n );\n }\n}\n\nexport const spec = {\n drop: (props, monitor) => {\n log('[drop] props: ', props);\n const item = monitor.getItem();\n props.onDropChoice(item);\n },\n canDrop: (props /*, monitor*/) => {\n return !props.disabled;\n }\n};\n\nconst WithTarget = DropTarget(({ uid }) => uid, spec, (connect, monitor) => ({\n connectDropTarget: connect.dropTarget(),\n isOver: monitor.isOver()\n}))(DroppablePlaceholder);\n\nexport default uid.withUid(WithTarget);\n"],"file":"droppable-placeholder.js"}
|
|
@@ -27,13 +27,13 @@ var _styles = require("@material-ui/core/styles");
|
|
|
27
27
|
|
|
28
28
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
29
29
|
|
|
30
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
30
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
31
|
|
|
32
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
32
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
33
|
|
|
34
34
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
35
35
|
|
|
36
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
36
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
37
37
|
|
|
38
38
|
var GridContent = /*#__PURE__*/function (_React$Component) {
|
|
39
39
|
(0, _inherits2["default"])(GridContent, _React$Component);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/categorize/grid-content.jsx"],"names":["GridContent","props","classes","className","children","columns","extraStyle","rows","style","gridTemplateColumns","gridTemplateRows","gridContent","React","Component","PropTypes","object","isRequired","string","oneOfType","arrayOf","node","number","styles","theme","display","columnGap","spacing","unit","gridColumnGap","rowGap","gridRowGap","gridAutoRows"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;IAEaA,W;;;;;;;;;;;;WAiBX,kBAAS;
|
|
1
|
+
{"version":3,"sources":["../../src/categorize/grid-content.jsx"],"names":["GridContent","props","classes","className","children","columns","extraStyle","rows","style","gridTemplateColumns","gridTemplateRows","gridContent","React","Component","PropTypes","object","isRequired","string","oneOfType","arrayOf","node","number","styles","theme","display","columnGap","spacing","unit","gridColumnGap","rowGap","gridRowGap","gridAutoRows"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;IAEaA,W;;;;;;;;;;;;WAiBX,kBAAS;AACP,wBAAoE,KAAKC,KAAzE;AAAA,UAAQC,OAAR,eAAQA,OAAR;AAAA,UAAiBC,SAAjB,eAAiBA,SAAjB;AAAA,UAA4BC,QAA5B,eAA4BA,QAA5B;AAAA,UAAsCC,OAAtC,eAAsCA,OAAtC;AAAA,UAA+CC,UAA/C,eAA+CA,UAA/C;AAAA,UAA2DC,IAA3D,eAA2DA,IAA3D;;AACA,UAAMC,KAAK;AACTC,QAAAA,mBAAmB,mBAAYJ,OAAZ,WADV;AAETK,QAAAA,gBAAgB,mBAAYH,IAAZ;AAFP,SAGND,UAHM,CAAX;;AAMA,0BACE;AAAK,QAAA,KAAK,EAAEE,KAAZ;AAAmB,QAAA,SAAS,EAAE,4BAAWN,OAAO,CAACS,WAAnB,EAAgCR,SAAhC;AAA9B,SACGC,QADH,CADF;AAKD;;;EA9B8BQ,kBAAMC,S;;;iCAA1Bb,W,eACQ;AACjBE,EAAAA,OAAO,EAAEY,sBAAUC,MAAV,CAAiBC,UADT;AAEjBb,EAAAA,SAAS,EAAEW,sBAAUG,MAFJ;AAGjBb,EAAAA,QAAQ,EAAEU,sBAAUI,SAAV,CAAoB,CAC5BJ,sBAAUK,OAAV,CAAkBL,sBAAUM,IAA5B,CAD4B,EAE5BN,sBAAUM,IAFkB,CAApB,EAGPJ,UANc;AAOjBX,EAAAA,OAAO,EAAES,sBAAUO,MAPF;AAQjBd,EAAAA,IAAI,EAAEO,sBAAUO,MARC;AASjBf,EAAAA,UAAU,EAAEQ,sBAAUC;AATL,C;iCADRf,W,kBAYW;AACpBK,EAAAA,OAAO,EAAE,CADW;AAEpBE,EAAAA,IAAI,EAAE;AAFc,C;;AAqBxB,IAAMe,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBZ,IAAAA,WAAW,EAAE;AACXa,MAAAA,OAAO,EAAE,MADE;AAEXC,MAAAA,SAAS,YAAKF,KAAK,CAACG,OAAN,CAAcC,IAAnB,OAFE;AAGXC,MAAAA,aAAa,YAAKL,KAAK,CAACG,OAAN,CAAcC,IAAnB,OAHF;AAIXE,MAAAA,MAAM,YAAKN,KAAK,CAACG,OAAN,CAAcC,IAAnB,OAJK;AAKXG,MAAAA,UAAU,YAAKP,KAAK,CAACG,OAAN,CAAcC,IAAnB,OALC;AAMXI,MAAAA,YAAY,EAAE;AANH;AADU,GAAL;AAAA,CAApB;;eAWe,wBAAWT,MAAX,EAAmBtB,WAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\n\nexport class GridContent extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n children: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.node),\n PropTypes.node\n ]).isRequired,\n columns: PropTypes.number,\n rows: PropTypes.number,\n extraStyle: PropTypes.object\n };\n static defaultProps = {\n columns: 2,\n rows: 2,\n };\n\n render() {\n const { classes, className, children, columns, extraStyle, rows } = this.props;\n const style = {\n gridTemplateColumns: `repeat(${columns}, 1fr)`,\n gridTemplateRows: `repeat(${rows}, auto)`,\n ...extraStyle\n };\n\n return (\n <div style={style} className={classNames(classes.gridContent, className)}>\n {children}\n </div>\n );\n }\n}\n\nconst styles = theme => ({\n gridContent: {\n display: 'grid',\n columnGap: `${theme.spacing.unit}px`,\n gridColumnGap: `${theme.spacing.unit}px`,\n rowGap: `${theme.spacing.unit}px`,\n gridRowGap: `${theme.spacing.unit}px`,\n gridAutoRows: '1fr'\n }\n});\n\nexport default withStyles(styles)(GridContent);\n"],"file":"grid-content.js"}
|
package/lib/categorize/index.js
CHANGED
|
@@ -43,7 +43,7 @@ var _debug = _interopRequireDefault(require("debug"));
|
|
|
43
43
|
|
|
44
44
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
45
45
|
|
|
46
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
46
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
47
47
|
|
|
48
48
|
var log = (0, _debug["default"])('@pie-ui:categorize');
|
|
49
49
|
|
|
@@ -164,25 +164,23 @@ var Categorize = /*#__PURE__*/function (_React$Component) {
|
|
|
164
164
|
visible: 'Hide Teacher Instructions'
|
|
165
165
|
},
|
|
166
166
|
className: classes.collapsible
|
|
167
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
168
|
-
|
|
169
|
-
__html: model.teacherInstructions
|
|
170
|
-
}
|
|
167
|
+
}, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
|
|
168
|
+
prompt: model.teacherInstructions
|
|
171
169
|
})), /*#__PURE__*/_react["default"].createElement("br", null)), /*#__PURE__*/_react["default"].createElement(_correctAnswerToggle["default"], {
|
|
172
170
|
show: showCorrect || correct === false,
|
|
173
171
|
toggled: showCorrect,
|
|
174
172
|
onToggle: this.toggleShowCorrect
|
|
175
173
|
}), model.prompt && removeHTMLTags(model.prompt) && /*#__PURE__*/_react["default"].createElement("div", {
|
|
176
|
-
className: classes.prompt
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
174
|
+
className: classes.prompt
|
|
175
|
+
}, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
|
|
176
|
+
prompt: model.prompt
|
|
177
|
+
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
181
178
|
className: classes.categorize,
|
|
182
179
|
style: style
|
|
183
180
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
184
181
|
style: {
|
|
185
|
-
display: 'flex'
|
|
182
|
+
display: 'flex',
|
|
183
|
+
flex: 1
|
|
186
184
|
}
|
|
187
185
|
}, rowLabels && nbOfRows && /*#__PURE__*/_react["default"].createElement("div", {
|
|
188
186
|
style: {
|
|
@@ -223,10 +221,8 @@ var Categorize = /*#__PURE__*/function (_React$Component) {
|
|
|
223
221
|
visible: 'Hide Rationale'
|
|
224
222
|
},
|
|
225
223
|
className: classes.collapsible
|
|
226
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
227
|
-
|
|
228
|
-
__html: model.rationale
|
|
229
|
-
}
|
|
224
|
+
}, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
|
|
225
|
+
prompt: model.rationale
|
|
230
226
|
})), model.correctness && model.feedback && !showCorrect && /*#__PURE__*/_react["default"].createElement(_renderUi.Feedback, {
|
|
231
227
|
correctness: model.correctness,
|
|
232
228
|
feedback: model.feedback
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/categorize/index.jsx"],"names":["log","removeHTMLTags","html","tmp","document","createElement","innerHTML","value","textContent","innerText","trim","Categorize","props","categoryId","draggedChoice","session","onAnswersChange","answers","id","choiceIndex","c","setState","showCorrect","state","onShowCorrectToggle","choicePosition","flexDirection","classes","model","choicesPosition","note","showNote","env","mode","role","style","getPositionDirection","categories","choices","correctResponse","correct","disabled","rowLabels","categoriesPerRow","nbOfRows","Math","ceil","length","displayNote","mainContainer","teacherInstructions","hidden","visible","collapsible","__html","toggleShowCorrect","prompt","categorize","display","marginRight","slice","map","label","index","alignItems","justifyContent","dropChoice","removeChoice","rationale","correctness","feedback","React","Component","PropTypes","object","isRequired","shape","arrayOf","choice","string","category","func","CategorizeProvider","uid","generateId","styles","theme","padding","spacing","unit","color","text","backgroundColor","background","marginBottom","verticalAlign","paddingBottom"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,oBAAN,CAAZ;;AAEA,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAAAC,IAAI,EAAI;AAC7B,MAAMC,GAAG,GAAGC,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAAZ;AAEAF,EAAAA,GAAG,CAACG,SAAJ,GAAgBJ,IAAhB;AAEA,MAAMK,KAAK,GAAGJ,GAAG,CAACK,WAAJ,IAAmBL,GAAG,CAACM,SAAvB,IAAoC,EAAlD;AAEA,SAAOF,KAAK,CAACG,IAAN,EAAP;AACD,CARD;;IAUaC,U;;;;;AAoBX,sBAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,mGAQN,UAACC,UAAD,EAAaC,aAAb,EAA+B;AAAA,wBACL,MAAKF,KADA;AAAA,UAClCG,OADkC,eAClCA,OADkC;AAAA,UACzBC,eADyB,eACzBA,eADyB;AAE1ChB,MAAAA,GAAG,CACD,yBADC,EAEDc,aAAa,CAACD,UAFb,EAGD,UAHC,EAIDC,aAJC,CAAH;AAOA,UAAMG,OAAO,GAAG,sCACdH,aAAa,CAACI,EADA,EAEdJ,aAAa,CAACD,UAFA,EAGdA,UAHc,EAIdC,aAAa,CAACK,WAJA,EAKdJ,OAA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F,gBAAMG,UAAN;AAHJ,KADU;AAMzBrC,IAAAA,MAAM,EAAE;AACNsC,MAAAA,YAAY,EAAE,MADR;AAENC,MAAAA,aAAa,EAAE;AAFT,KANiB;AAUzBjE,IAAAA,IAAI,EAAE;AACJyD,MAAAA,OAAO,EAAE;AADL,KAVmB;AAazB9B,IAAAA,UAAU,EAAE;AACVqC,MAAAA,YAAY,EAAER,KAAK,CAACE,OAAN,CAAcC,IADlB;AAEV/B,MAAAA,OAAO,EAAE,MAFC;AAGVhC,MAAAA,aAAa,EAAE;AAHL,KAba;AAkBzB2B,IAAAA,WAAW,EAAE;AACX2C,MAAAA,aAAa,EAAEV,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB;AADzB;AAlBY,GAAZ;AAAA,CAAf;;eAuBe,2BAAgB,wBAAWJ,MAAX,EAAmBH,kBAAnB,CAAhB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Choices from './choices';\nimport Categories from './categories';\nimport CorrectAnswerToggle from '@pie-lib/correct-answer-toggle';\nimport { withStyles } from '@material-ui/core/styles';\nimport {\n buildState,\n removeChoiceFromCategory,\n moveChoiceToCategory\n} from '@pie-lib/categorize';\nimport { withDragContext, uid } from '@pie-lib/drag';\nimport { color, Feedback, Collapsible, hasText } from '@pie-lib/render-ui';\nimport debug from 'debug';\n\nconst log = debug('@pie-ui:categorize');\n\nconst removeHTMLTags = html => {\n const tmp = document.createElement('DIV');\n\n tmp.innerHTML = html;\n\n const value = tmp.textContent || tmp.innerText || '';\n\n return value.trim();\n};\n\nexport class Categorize extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n model: PropTypes.object,\n session: PropTypes.shape({\n answers: PropTypes.arrayOf(\n PropTypes.shape({\n choice: PropTypes.string,\n category: PropTypes.string\n })\n )\n }),\n onAnswersChange: PropTypes.func.isRequired,\n onShowCorrectToggle: PropTypes.func.isRequired\n };\n\n static defaultProps = {\n disabled: false\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n showCorrect: false\n };\n }\n\n dropChoice = (categoryId, draggedChoice) => {\n const { session, onAnswersChange } = this.props;\n log(\n '[dropChoice] category: ',\n draggedChoice.categoryId,\n 'choice: ',\n draggedChoice\n );\n\n const answers = moveChoiceToCategory(\n draggedChoice.id,\n draggedChoice.categoryId,\n categoryId,\n draggedChoice.choiceIndex,\n session.answers\n );\n\n onAnswersChange(answers);\n };\n\n removeChoice = c => {\n log('[removeChoice]: ', c);\n const { onAnswersChange, session } = this.props;\n const answers = removeChoiceFromCategory(\n c.id,\n c.categoryId,\n c.choiceIndex,\n session.answers\n );\n onAnswersChange(answers);\n };\n\n UNSAFE_componentWillReceiveProps() {\n this.setState({ showCorrect: false });\n }\n\n toggleShowCorrect = () =>\n this.setState({ showCorrect: !this.state.showCorrect }, () => {\n this.props.onShowCorrectToggle();\n });\n\n getPositionDirection = (choicePosition) => {\n let flexDirection;\n\n switch (choicePosition) {\n case 'left':\n flexDirection = 'row-reverse';\n break;\n case 'right':\n flexDirection = 'row';\n break;\n case 'below':\n flexDirection = 'column';\n break;\n default:\n // above\n flexDirection = 'column-reverse';\n break;\n }\n\n return flexDirection;\n };\n\n render() {\n const { classes, model, session } = this.props;\n const { showCorrect } = this.state;\n const { choicesPosition, note, showNote, env } = model;\n const { mode, role } = env || {};\n const choicePosition = choicesPosition || 'above';\n\n const style = {\n flexDirection: this.getPositionDirection(choicePosition)\n };\n\n const { categories, choices, correct } = buildState(\n model.categories,\n model.choices,\n showCorrect ? model.correctResponse : session.answers,\n model.correctResponse\n );\n\n log('[render] disabled: ', model.disabled);\n\n const { rowLabels, categoriesPerRow } = model;\n const nbOfRows = categories && Math.ceil(categories.length / categoriesPerRow) || 0;\n const displayNote = (showCorrect || mode === 'view' && role === 'instructor') && showNote && note;\n\n return (\n <div className={classes.mainContainer}>\n {\n model.teacherInstructions && hasText(model.teacherInstructions) && (\n <React.Fragment>\n <Collapsible\n labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}\n className={classes.collapsible}\n >\n <div dangerouslySetInnerHTML={{ __html: model.teacherInstructions }}/>\n </Collapsible>\n <br />\n </React.Fragment>\n )\n }\n <CorrectAnswerToggle\n show={showCorrect || correct === false}\n toggled={showCorrect}\n onToggle={this.toggleShowCorrect}\n />\n {\n model.prompt && removeHTMLTags(model.prompt) &&\n <div\n className={classes.prompt}\n dangerouslySetInnerHTML={{ __html: model.prompt }}\n />\n }\n <div className={classes.categorize} style={style}>\n <div style={{ display: 'flex' }}>\n {\n rowLabels && nbOfRows && (\n <div style={{ display: 'grid', marginRight: '20px' }}>\n {rowLabels.slice(0, nbOfRows).map((label, index) => (\n <div\n key={index}\n style={{\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'center'\n }}\n dangerouslySetInnerHTML={{\n __html: label\n }}\n />\n ))}\n </div>\n )\n }\n <Categories\n model={model}\n disabled={model.disabled}\n categories={categories}\n onDropChoice={this.dropChoice}\n onRemoveChoice={this.removeChoice}\n />\n </div>\n <Choices\n disabled={model.disabled}\n model={model}\n choices={choices}\n choicePosition={choicePosition}\n />\n </div>\n {displayNote && (\n <div\n className={classes.note}\n dangerouslySetInnerHTML={{ __html: `<strong>Note:</strong> ${note}` }}\n />\n )}\n {\n model.rationale && hasText(model.rationale) && (\n <Collapsible\n labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}\n className={classes.collapsible}\n >\n <div dangerouslySetInnerHTML={{ __html: model.rationale }}/>\n </Collapsible>\n )\n }\n {\n model.correctness &&\n model.feedback &&\n !showCorrect && (\n <Feedback\n correctness={model.correctness}\n feedback={model.feedback}\n />\n )\n }\n </div>\n );\n }\n}\n\nclass CategorizeProvider extends React.Component {\n constructor(props) {\n super(props);\n this.uid = uid.generateId();\n }\n\n render() {\n return (\n <uid.Provider value={this.uid}>\n <Categorize { ...this.props } />\n </uid.Provider>\n );\n }\n}\n\nconst styles = (theme) => ({\n mainContainer: {\n padding: theme.spacing.unit,\n color: color.text(),\n backgroundColor: color.background()\n },\n prompt: {\n marginBottom: '35px',\n verticalAlign: 'middle'\n },\n note: {\n padding: '5px 0'\n },\n categorize: {\n marginBottom: theme.spacing.unit,\n display: 'flex',\n flexDirection: 'column'\n },\n collapsible: {\n paddingBottom: theme.spacing.unit * 2\n }\n});\n\nexport default withDragContext(withStyles(styles)(CategorizeProvider));\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/categorize/index.jsx"],"names":["log","removeHTMLTags","html","tmp","document","createElement","innerHTML","value","textContent","innerText","trim","Categorize","props","categoryId","draggedChoice","session","onAnswersChange","answers","id","choiceIndex","c","setState","showCorrect","state","onShowCorrectToggle","choicePosition","flexDirection","classes","model","choicesPosition","note","showNote","env","mode","role","style","getPositionDirection","categories","choices","correctResponse","correct","disabled","rowLabels","categoriesPerRow","nbOfRows","Math","ceil","length","displayNote","mainContainer","teacherInstructions","hidden","visible","collapsible","toggleShowCorrect","prompt","categorize","display","flex","marginRight","slice","map","label","index","alignItems","justifyContent","__html","dropChoice","removeChoice","rationale","correctness","feedback","React","Component","PropTypes","object","isRequired","shape","arrayOf","choice","string","category","func","CategorizeProvider","uid","generateId","styles","theme","padding","spacing","unit","color","text","backgroundColor","background","marginBottom","verticalAlign","paddingBottom"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,oBAAN,CAAZ;;AAEA,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAAAC,IAAI,EAAI;AAC7B,MAAMC,GAAG,GAAGC,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAAZ;AAEAF,EAAAA,GAAG,CAACG,SAAJ,GAAgBJ,IAAhB;AAEA,MAAMK,KAAK,GAAGJ,GAAG,CAACK,WAAJ,IAAmBL,GAAG,CAACM,SAAvB,IAAoC,EAAlD;AAEA,SAAOF,KAAK,CAACG,IAAN,EAAP;AACD,CARD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AL,GAAWA,UAAIC,UAAJ,EAAX;AAFiB;AAGlB;;;;WAED,kBAAS;AACP,0BACE,gCAAC,SAAD,CAAK,QAAL;AAAc,QAAA,KAAK,EAAE,KAAKD;AAA1B,sBACE,gCAAC,UAAD,EAAiB,KAAKxE,KAAtB,CADF,CADF;AAKD;;;EAZ8B4D,kBAAMC,S;;AAevC,IAAMa,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBtC,IAAAA,aAAa,EAAE;AACbuC,MAAAA,OAAO,EAAED,KAAK,CAACE,OAAN,CAAcC,IADV;AAEbC,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EAFM;AAGbC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN;AAHJ,KADU;AAMzBvC,IAAAA,MAAM,EAAE;AACNwC,MAAAA,YAAY,EAAE,MADR;AAENC,MAAAA,aAAa,EAAE;AAFT,KANiB;AAUzBlE,IAAAA,IAAI,EAAE;AACJ0D,MAAAA,OAAO,EAAE;AADL,KAVmB;AAazBhC,IAAAA,UAAU,EAAE;AACVuC,MAAAA,YAAY,EAAER,KAAK,CAACE,OAAN,CAAcC,IADlB;AAEVjC,MAAAA,OAAO,EAAE,MAFC;AAGV/B,MAAAA,aAAa,EAAE;AAHL,KAba;AAkBzB2B,IAAAA,WAAW,EAAE;AACX4C,MAAAA,aAAa,EAAEV,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB;AADzB;AAlBY,GAAZ;AAAA,CAAf;;eAuBe,2BAAgB,wBAAWJ,MAAX,EAAmBH,kBAAnB,CAAhB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Choices from './choices';\nimport Categories from './categories';\nimport CorrectAnswerToggle from '@pie-lib/correct-answer-toggle';\nimport { withStyles } from '@material-ui/core/styles';\nimport {\n buildState,\n removeChoiceFromCategory,\n moveChoiceToCategory\n} from '@pie-lib/categorize';\nimport { withDragContext, uid } from '@pie-lib/drag';\nimport {color, Feedback, Collapsible, hasText, PreviewPrompt} from '@pie-lib/render-ui';\nimport debug from 'debug';\n\nconst log = debug('@pie-ui:categorize');\n\nconst removeHTMLTags = html => {\n const tmp = document.createElement('DIV');\n\n tmp.innerHTML = html;\n\n const value = tmp.textContent || tmp.innerText || '';\n\n return value.trim();\n};\n\nexport class Categorize extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n model: PropTypes.object,\n session: PropTypes.shape({\n answers: PropTypes.arrayOf(\n PropTypes.shape({\n choice: PropTypes.string,\n category: PropTypes.string\n })\n )\n }),\n onAnswersChange: PropTypes.func.isRequired,\n onShowCorrectToggle: PropTypes.func.isRequired\n };\n\n static defaultProps = {\n disabled: false\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n showCorrect: false\n };\n }\n\n dropChoice = (categoryId, draggedChoice) => {\n const { session, onAnswersChange } = this.props;\n log(\n '[dropChoice] category: ',\n draggedChoice.categoryId,\n 'choice: ',\n draggedChoice\n );\n\n const answers = moveChoiceToCategory(\n draggedChoice.id,\n draggedChoice.categoryId,\n categoryId,\n draggedChoice.choiceIndex,\n session.answers\n );\n\n onAnswersChange(answers);\n };\n\n removeChoice = c => {\n log('[removeChoice]: ', c);\n const { onAnswersChange, session } = this.props;\n const answers = removeChoiceFromCategory(\n c.id,\n c.categoryId,\n c.choiceIndex,\n session.answers\n );\n onAnswersChange(answers);\n };\n\n UNSAFE_componentWillReceiveProps() {\n this.setState({ showCorrect: false });\n }\n\n toggleShowCorrect = () =>\n this.setState({ showCorrect: !this.state.showCorrect }, () => {\n this.props.onShowCorrectToggle();\n });\n\n getPositionDirection = (choicePosition) => {\n let flexDirection;\n\n switch (choicePosition) {\n case 'left':\n flexDirection = 'row-reverse';\n break;\n case 'right':\n flexDirection = 'row';\n break;\n case 'below':\n flexDirection = 'column';\n break;\n default:\n // above\n flexDirection = 'column-reverse';\n break;\n }\n\n return flexDirection;\n };\n\n render() {\n const { classes, model, session } = this.props;\n const { showCorrect } = this.state;\n const { choicesPosition, note, showNote, env } = model;\n const { mode, role } = env || {};\n const choicePosition = choicesPosition || 'above';\n\n const style = {\n flexDirection: this.getPositionDirection(choicePosition)\n };\n\n const { categories, choices, correct } = buildState(\n model.categories,\n model.choices,\n showCorrect ? model.correctResponse : session.answers,\n model.correctResponse\n );\n\n log('[render] disabled: ', model.disabled);\n\n const { rowLabels, categoriesPerRow } = model;\n const nbOfRows = categories && Math.ceil(categories.length / categoriesPerRow) || 0;\n const displayNote = (showCorrect || mode === 'view' && role === 'instructor') && showNote && note;\n\n return (\n <div className={classes.mainContainer}>\n {\n model.teacherInstructions && hasText(model.teacherInstructions) && (\n <React.Fragment>\n <Collapsible\n labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}\n className={classes.collapsible}\n >\n <PreviewPrompt prompt={model.teacherInstructions} />\n </Collapsible>\n <br />\n </React.Fragment>\n )\n }\n <CorrectAnswerToggle\n show={showCorrect || correct === false}\n toggled={showCorrect}\n onToggle={this.toggleShowCorrect}\n />\n {\n model.prompt && removeHTMLTags(model.prompt) &&\n <div\n className={classes.prompt}\n >\n <PreviewPrompt prompt={model.prompt} />\n </div>\n }\n <div className={classes.categorize} style={style}>\n <div style={{ display: 'flex', flex: 1 }}>\n {\n rowLabels && nbOfRows && (\n <div style={{ display: 'grid', marginRight: '20px' }}>\n {rowLabels.slice(0, nbOfRows).map((label, index) => (\n <div\n key={index}\n style={{\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'center'\n }}\n dangerouslySetInnerHTML={{\n __html: label\n }}\n />\n ))}\n </div>\n )\n }\n <Categories\n model={model}\n disabled={model.disabled}\n categories={categories}\n onDropChoice={this.dropChoice}\n onRemoveChoice={this.removeChoice}\n />\n </div>\n <Choices\n disabled={model.disabled}\n model={model}\n choices={choices}\n choicePosition={choicePosition}\n />\n </div>\n {displayNote && (\n <div\n className={classes.note}\n dangerouslySetInnerHTML={{ __html: `<strong>Note:</strong> ${note}` }}\n />\n )}\n {\n model.rationale && hasText(model.rationale) && (\n <Collapsible\n labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}\n className={classes.collapsible}\n >\n <PreviewPrompt prompt={model.rationale} />\n </Collapsible>\n )\n }\n {\n model.correctness &&\n model.feedback &&\n !showCorrect && (\n <Feedback\n correctness={model.correctness}\n feedback={model.feedback}\n />\n )\n }\n </div>\n );\n }\n}\n\nclass CategorizeProvider extends React.Component {\n constructor(props) {\n super(props);\n this.uid = uid.generateId();\n }\n\n render() {\n return (\n <uid.Provider value={this.uid}>\n <Categorize { ...this.props } />\n </uid.Provider>\n );\n }\n}\n\nconst styles = (theme) => ({\n mainContainer: {\n padding: theme.spacing.unit,\n color: color.text(),\n backgroundColor: color.background()\n },\n prompt: {\n marginBottom: '35px',\n verticalAlign: 'middle'\n },\n note: {\n padding: '5px 0'\n },\n categorize: {\n marginBottom: theme.spacing.unit,\n display: 'flex',\n flexDirection: 'column'\n },\n collapsible: {\n paddingBottom: theme.spacing.unit * 2\n }\n});\n\nexport default withDragContext(withStyles(styles)(CategorizeProvider));\n"],"file":"index.js"}
|