@pie-element/categorize 6.5.19-next.85 → 6.6.1-beta.587
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 +549 -0
- package/configure/CHANGELOG.md +485 -0
- package/configure/lib/defaults.js +56 -5
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/design/builder.js +8 -5
- package/configure/lib/design/builder.js.map +1 -1
- package/configure/lib/design/buttons.js +6 -4
- package/configure/lib/design/buttons.js.map +1 -1
- package/configure/lib/design/categories/RowLabel.js +68 -0
- package/configure/lib/design/categories/RowLabel.js.map +1 -0
- package/configure/lib/design/categories/alternateResponses.js +122 -18
- package/configure/lib/design/categories/alternateResponses.js.map +1 -1
- package/configure/lib/design/categories/category.js +53 -6
- package/configure/lib/design/categories/category.js.map +1 -1
- package/configure/lib/design/categories/choice-preview.js +19 -6
- package/configure/lib/design/categories/choice-preview.js.map +1 -1
- package/configure/lib/design/categories/droppable-placeholder.js +25 -5
- package/configure/lib/design/categories/droppable-placeholder.js.map +1 -1
- package/configure/lib/design/categories/index.js +172 -82
- package/configure/lib/design/categories/index.js.map +1 -1
- package/configure/lib/design/choices/choice.js +83 -13
- package/configure/lib/design/choices/choice.js.map +1 -1
- package/configure/lib/design/choices/config.js +10 -136
- package/configure/lib/design/choices/config.js.map +1 -1
- package/configure/lib/design/choices/index.js +89 -13
- package/configure/lib/design/choices/index.js.map +1 -1
- package/configure/lib/design/header.js +18 -6
- package/configure/lib/design/header.js.map +1 -1
- package/configure/lib/design/index.js +165 -50
- package/configure/lib/design/index.js.map +1 -1
- package/configure/lib/design/input-header.js +69 -11
- package/configure/lib/design/input-header.js.map +1 -1
- package/configure/lib/index.js +18 -4
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +4 -2
- package/configure/lib/main.js.map +1 -1
- package/configure/lib/utils.js +27 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +9 -9
- package/controller/CHANGELOG.md +128 -0
- package/controller/lib/defaults.js +20 -1
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +173 -30
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js +60 -0
- package/controller/lib/utils.js.map +1 -0
- package/controller/package.json +4 -4
- package/docs/config-schema.json +181 -0
- package/docs/config-schema.json.md +141 -1
- package/docs/demo/config.js +2 -2
- package/docs/demo/generate.js +5 -8
- package/docs/demo/index.html +1 -1
- package/docs/pie-schema.json +63 -11
- package/docs/pie-schema.json.md +51 -11
- package/lib/categorize/categories.js +30 -24
- package/lib/categorize/categories.js.map +1 -1
- package/lib/categorize/category.js +15 -12
- package/lib/categorize/category.js.map +1 -1
- package/lib/categorize/choice.js +19 -12
- package/lib/categorize/choice.js.map +1 -1
- package/lib/categorize/choices.js +35 -16
- package/lib/categorize/choices.js.map +1 -1
- package/lib/categorize/droppable-placeholder.js +6 -4
- 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 +71 -37
- package/lib/categorize/index.js.map +1 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/package.json +9 -8
|
@@ -33,13 +33,13 @@ var _drag = require("@pie-lib/drag");
|
|
|
33
33
|
|
|
34
34
|
var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
|
|
35
35
|
|
|
36
|
-
var
|
|
36
|
+
var _RemoveCircleOutline = _interopRequireDefault(require("@material-ui/icons/RemoveCircleOutline"));
|
|
37
37
|
|
|
38
38
|
var _renderUi = require("@pie-lib/render-ui");
|
|
39
39
|
|
|
40
40
|
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
41
|
|
|
42
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
42
|
+
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
43
|
|
|
44
44
|
var ChoicePreview = /*#__PURE__*/function (_React$Component) {
|
|
45
45
|
(0, _inherits2["default"])(ChoicePreview, _React$Component);
|
|
@@ -68,20 +68,33 @@ var ChoicePreview = /*#__PURE__*/function (_React$Component) {
|
|
|
68
68
|
(0, _createClass2["default"])(ChoicePreview, [{
|
|
69
69
|
key: "render",
|
|
70
70
|
value: function render() {
|
|
71
|
+
var _this2 = this;
|
|
72
|
+
|
|
71
73
|
var _this$props2 = this.props,
|
|
74
|
+
alternateResponseIndex = _this$props2.alternateResponseIndex,
|
|
75
|
+
category = _this$props2.category,
|
|
72
76
|
classes = _this$props2.classes,
|
|
73
77
|
className = _this$props2.className,
|
|
74
|
-
choice = _this$props2.choice
|
|
78
|
+
choice = _this$props2.choice,
|
|
79
|
+
choiceIndex = _this$props2.choiceIndex;
|
|
75
80
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
76
81
|
className: (0, _classnames["default"])(classes.choicePreview, className)
|
|
77
|
-
}, /*#__PURE__*/_react["default"].createElement(_drag.Choice,
|
|
78
|
-
|
|
82
|
+
}, choice ? /*#__PURE__*/_react["default"].createElement(_drag.Choice, {
|
|
83
|
+
alternateResponseIndex: alternateResponseIndex,
|
|
84
|
+
category: category,
|
|
85
|
+
choice: choice,
|
|
86
|
+
choiceIndex: choiceIndex,
|
|
87
|
+
onRemoveChoice: function onRemoveChoice() {
|
|
88
|
+
return _this2["delete"]();
|
|
89
|
+
}
|
|
90
|
+
}, /*#__PURE__*/_react["default"].createElement(_renderUi.HtmlAndMath, {
|
|
91
|
+
html: choice === null || choice === void 0 ? void 0 : choice.content
|
|
79
92
|
}), /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
|
|
80
93
|
color: "secondary",
|
|
81
94
|
"aria-label": "delete",
|
|
82
95
|
className: classes["delete"],
|
|
83
96
|
onClick: this["delete"]
|
|
84
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
97
|
+
}, /*#__PURE__*/_react["default"].createElement(_RemoveCircleOutline["default"], null))) : null);
|
|
85
98
|
}
|
|
86
99
|
}]);
|
|
87
100
|
return ChoicePreview;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/design/categories/choice-preview.jsx"],"names":["ChoicePreview","props","onDelete","choice","classes","className","choicePreview","content","React","Component","PropTypes","object","isRequired","string","func","styles","position","right","top"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEaA,a;;;;;;;;;;;;;;;+FASF,YAAM;
|
|
1
|
+
{"version":3,"sources":["../../../src/design/categories/choice-preview.jsx"],"names":["ChoicePreview","props","onDelete","choice","alternateResponseIndex","category","classes","className","choiceIndex","choicePreview","content","React","Component","PropTypes","object","isRequired","string","func","styles","position","right","top"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEaA,a;;;;;;;;;;;;;;;+FASF,YAAM;AACb,wBAA6B,MAAKC,KAAlC;AAAA,UAAQC,QAAR,eAAQA,QAAR;AAAA,UAAkBC,MAAlB,eAAkBA,MAAlB;AACAD,MAAAA,QAAQ,CAACC,MAAD,CAAR;AACD,K;;;;;;WAED,kBAAS;AAAA;;AACP,yBAAsF,KAAKF,KAA3F;AAAA,UAAQG,sBAAR,gBAAQA,sBAAR;AAAA,UAAgCC,QAAhC,gBAAgCA,Q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J;AAENC,MAAAA,KAAK,EAAE,CAFD;AAGNC,MAAAA,GAAG,EAAE;AAHC;AAJY,GAAP;AAAA,CAAf;;eAUe,wBAAWH,MAAX,EAAmBlB,aAAnB,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 '@pie-lib/drag';\nimport IconButton from '@material-ui/core/IconButton';\nimport RemoveCircleOutlineIcon from '@material-ui/icons/RemoveCircleOutline';\nimport { HtmlAndMath } from '@pie-lib/render-ui';\n\nexport class ChoicePreview extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n choice: PropTypes.object.isRequired,\n onDelete: PropTypes.func.isRequired,\n };\n static defaultProps = {};\n\n delete = () => {\n const { onDelete, choice } = this.props;\n onDelete(choice);\n };\n\n render() {\n const { alternateResponseIndex, category, classes, className, choice, choiceIndex } = this.props;\n return (\n <div className={classNames(classes.choicePreview, className)}>\n {choice ? (\n <Choice alternateResponseIndex={alternateResponseIndex} category={category} choice={choice} choiceIndex={choiceIndex} onRemoveChoice={() => this.delete()}>\n <HtmlAndMath html={choice?.content} />\n <IconButton color=\"secondary\" aria-label=\"delete\" className={classes.delete} onClick={this.delete}>\n <RemoveCircleOutlineIcon />\n </IconButton>\n </Choice>\n ) : null}\n </div>\n );\n }\n}\nconst styles = () => ({\n choicePreview: {\n position: 'relative',\n },\n delete: {\n position: 'absolute',\n right: 0,\n top: 0,\n },\n});\nexport default withStyles(styles)(ChoicePreview);\n"],"file":"choice-preview.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
|
|
|
@@ -37,7 +37,7 @@ var _debug = _interopRequireDefault(require("debug"));
|
|
|
37
37
|
|
|
38
38
|
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); }; }
|
|
39
39
|
|
|
40
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
40
|
+
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; } }
|
|
41
41
|
|
|
42
42
|
var log = (0, _debug["default"])('@pie-element:categorize:configure');
|
|
43
43
|
var Helper = (0, _styles.withStyles)(function () {
|
|
@@ -59,12 +59,17 @@ var Helper = (0, _styles.withStyles)(function () {
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
var Previews = function Previews(_ref2) {
|
|
62
|
-
var
|
|
62
|
+
var alternateResponseIndex = _ref2.alternateResponseIndex,
|
|
63
|
+
category = _ref2.category,
|
|
64
|
+
choices = _ref2.choices,
|
|
63
65
|
onDeleteChoice = _ref2.onDeleteChoice;
|
|
64
66
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, choices.map(function (c, index) {
|
|
65
|
-
return /*#__PURE__*/_react["default"].createElement(_choicePreview["default"], {
|
|
67
|
+
return c && /*#__PURE__*/_react["default"].createElement(_choicePreview["default"], {
|
|
68
|
+
alternateResponseIndex: alternateResponseIndex,
|
|
69
|
+
category: category,
|
|
66
70
|
choice: c,
|
|
67
71
|
key: index,
|
|
72
|
+
choiceIndex: index,
|
|
68
73
|
onDelete: function onDelete(choice) {
|
|
69
74
|
return onDeleteChoice(choice, index);
|
|
70
75
|
}
|
|
@@ -73,6 +78,8 @@ var Previews = function Previews(_ref2) {
|
|
|
73
78
|
};
|
|
74
79
|
|
|
75
80
|
Previews.propTypes = {
|
|
81
|
+
alternateResponseIndex: _propTypes["default"].number,
|
|
82
|
+
category: _propTypes["default"].object,
|
|
76
83
|
choices: _propTypes["default"].array,
|
|
77
84
|
onDeleteChoice: _propTypes["default"].func
|
|
78
85
|
};
|
|
@@ -91,7 +98,9 @@ var DroppablePlaceHolder = /*#__PURE__*/function (_React$Component) {
|
|
|
91
98
|
key: "render",
|
|
92
99
|
value: function render() {
|
|
93
100
|
var _this$props = this.props,
|
|
101
|
+
alternateResponseIndex = _this$props.alternateResponseIndex,
|
|
94
102
|
isOver = _this$props.isOver,
|
|
103
|
+
category = _this$props.category,
|
|
95
104
|
choices = _this$props.choices,
|
|
96
105
|
classes = _this$props.classes,
|
|
97
106
|
className = _this$props.className,
|
|
@@ -103,6 +112,8 @@ var DroppablePlaceHolder = /*#__PURE__*/function (_React$Component) {
|
|
|
103
112
|
isOver: isOver,
|
|
104
113
|
className: classes.placeHolder
|
|
105
114
|
}, (choices || []).length === 0 ? /*#__PURE__*/_react["default"].createElement(Helper, null) : /*#__PURE__*/_react["default"].createElement(Previews, {
|
|
115
|
+
alternateResponseIndex: alternateResponseIndex,
|
|
116
|
+
category: category,
|
|
106
117
|
choices: choices,
|
|
107
118
|
onDeleteChoice: onDeleteChoice
|
|
108
119
|
}))));
|
|
@@ -113,11 +124,14 @@ var DroppablePlaceHolder = /*#__PURE__*/function (_React$Component) {
|
|
|
113
124
|
|
|
114
125
|
exports.DroppablePlaceHolder = DroppablePlaceHolder;
|
|
115
126
|
(0, _defineProperty2["default"])(DroppablePlaceHolder, "propTypes", {
|
|
127
|
+
alternateResponseIndex: _propTypes["default"].number,
|
|
128
|
+
category: _propTypes["default"].object,
|
|
116
129
|
classes: _propTypes["default"].object.isRequired,
|
|
117
130
|
className: _propTypes["default"].string,
|
|
118
131
|
connectDropTarget: _propTypes["default"].func.isRequired,
|
|
119
132
|
choices: _propTypes["default"].array,
|
|
120
133
|
onDropChoice: _propTypes["default"].func.isRequired,
|
|
134
|
+
onMoveChoice: _propTypes["default"].func,
|
|
121
135
|
isOver: _propTypes["default"].bool,
|
|
122
136
|
onDeleteChoice: _propTypes["default"].func,
|
|
123
137
|
categoryId: _propTypes["default"].string.isRequired
|
|
@@ -142,7 +156,13 @@ var spec = {
|
|
|
142
156
|
drop: function drop(props, monitor) {
|
|
143
157
|
log('[drop] props: ', props);
|
|
144
158
|
var item = monitor.getItem();
|
|
145
|
-
|
|
159
|
+
|
|
160
|
+
if (item.from && item.alternateResponseIndex === props.alternateResponseIndex) {
|
|
161
|
+
props.onMoveChoice(item.choiceId, item.from, props.categoryId, item.choiceIndex, item.alternateResponseIndex);
|
|
162
|
+
} else if (!item.from) {
|
|
163
|
+
// avoid dropping choice when user tries to move it to an alternate with other index
|
|
164
|
+
props.onDropChoice(item, props.categoryId);
|
|
165
|
+
}
|
|
146
166
|
},
|
|
147
167
|
canDrop: function canDrop(props
|
|
148
168
|
/*, monitor*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/design/categories/droppable-placeholder.jsx"],"names":["log","Helper","helper","display","alignItems","fontSize","color","width","height","classes","Previews","choices","onDeleteChoice","map","c","index","choice","propTypes","PropTypes","array","func","DroppablePlaceHolder","props","isOver","className","connectDropTarget","droppablePlaceholder","placeHolder","length","React","Component","
|
|
1
|
+
{"version":3,"sources":["../../../src/design/categories/droppable-placeholder.jsx"],"names":["log","Helper","helper","display","alignItems","fontSize","color","width","height","classes","Previews","alternateResponseIndex","category","choices","onDeleteChoice","map","c","index","choice","propTypes","PropTypes","number","object","array","func","DroppablePlaceHolder","props","isOver","className","connectDropTarget","droppablePlaceholder","placeHolder","length","React","Component","isRequired","string","onDropChoice","onMoveChoice","bool","categoryId","styles","minHeight","Styled","spec","drop","monitor","item","getItem","from","choiceId","choiceIndex","canDrop","disabled","WithTarget","uid","connect","dropTarget","withUid"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,mCAAN,CAAZ;AAEA,IAAMC,MAAM,GAAG,wBAAW;AAAA,SAAO;AAC/BC,IAAAA,MAAM,EAAE;AACNC,MAAAA,OAAO,EAAE,MADH;AAENC,MAAAA,UAAU,EAAE,QAFN;AAGNC,MAAAA,QAAQ,EAAE,MAHJ;AAINC,MAAAA,KAAK,EAAE,iBAJD;AAKNC,MAAAA,KAAK,EAAE,MALD;AAMNC,MAAAA,MAAM,EAAE;AANF;AADuB,GAAP;AAAA,CAAX,EASX;AAAA,MAAGC,OAAH,QAAGA,OAAH;AAAA,sBAAiB;AAAK,IAAA,SAAS,EAAEA,OAAO,CAACP;AAAxB,sCAAjB;AAAA,CATW,CAAf;;AAWA,IAAMQ,QAAQ,GAAG,SAAXA,QAAW;AAAA,MAAGC,sBAAH,SAAGA,sBAAH;AAAA,MAA2BC,QAA3B,SAA2BA,QAA3B;AAAA,MAAqCC,OAArC,SAAqCA,OAArC;AAAA,MAA8CC,cAA9C,SAA8CA,cAA9C;AAAA,sBACf,gCAAC,iBAAD,CAAO,QAAP,QACGD,OAAO,CAACE,GAAR,CACC,UAACC,CAAD,EAAIC,KAAJ;AAAA,WACED,CAAC,iBACC,gCAAC,yBAAD;AACE,MAAA,sBAAsB,EAAEL,sBAD1B;AAEE,MAAA,QAAQ,EAAEC,QAFZ;AAGE,MAAA,MAAM,EAAEI,CAHV;AAIE,MAAA,GAAG,EAAEC,KAJP;AAKE,MAAA,WAAW,EAAEA,KALf;AAME,MAAA,QAAQ,EAAE,kBAACC,MAAD;AAAA,eAAYJ,cAAc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,EAA6CvB,KAAK,CAACc,UAAnD,EAA+DO,IAAI,CAACI,WAApE,EAAiFJ,IAAI,CAACpC,sBAAtF;AACD,KAFD,MAEO,IAAI,CAACoC,IAAI,CAACE,IAAV,EAAe;AACpB;AACAvB,MAAAA,KAAK,CAACW,YAAN,CAAmBU,IAAnB,EAAyBrB,KAAK,CAACc,UAA/B;AACD;AACF,GAXiB;AAYlBY,EAAAA,OAAO,EAAE,iBAAC1B;AAAM;AAAP,IAAyB;AAChC,WAAO,CAACA,KAAK,CAAC2B,QAAd;AACD;AAdiB,CAAb;;AAiBP,IAAMC,UAAU,GAAG,0BACjB;AAAA,MAAGC,GAAH,SAAGA,GAAH;AAAA,SAAaA,GAAb;AAAA,CADiB,EAEjBX,IAFiB,EAGjB,UAACY,OAAD,EAAUV,OAAV;AAAA,SAAuB;AACrBjB,IAAAA,iBAAiB,EAAE2B,OAAO,CAACC,UAAR,EADE;AAErB9B,IAAAA,MAAM,EAAEmB,OAAO,CAACnB,MAAR;AAFa,GAAvB;AAAA,CAHiB,EAOjBgB,MAPiB,CAAnB;;eASeY,UAAIG,OAAJ,CAAYJ,UAAZ,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport ChoicePreview from './choice-preview';\nimport { DropTarget } from 'react-dnd';\nimport { uid, PlaceHolder } from '@pie-lib/drag';\nimport debug from 'debug';\n\nconst log = debug('@pie-element:categorize:configure');\n\nconst Helper = withStyles(() => ({\n helper: {\n display: 'flex',\n alignItems: 'center',\n fontSize: '12px',\n color: 'rgba(0,0,0,0.4)',\n width: '100%',\n height: '100%',\n },\n}))(({ classes }) => <div className={classes.helper}>Drag your correct answers here</div>);\n\nconst Previews = ({ alternateResponseIndex, category, choices, onDeleteChoice }) => (\n <React.Fragment>\n {choices.map(\n (c, index) =>\n c && (\n <ChoicePreview\n alternateResponseIndex={alternateResponseIndex}\n category={category}\n choice={c}\n key={index}\n choiceIndex={index}\n onDelete={(choice) => onDeleteChoice(choice, index)}\n />\n ),\n )}\n </React.Fragment>\n);\n\nPreviews.propTypes = {\n alternateResponseIndex: PropTypes.number,\n category: PropTypes.object,\n choices: PropTypes.array,\n onDeleteChoice: PropTypes.func,\n};\n\nexport class DroppablePlaceHolder extends React.Component {\n static propTypes = {\n alternateResponseIndex: PropTypes.number,\n category: PropTypes.object,\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n connectDropTarget: PropTypes.func.isRequired,\n choices: PropTypes.array,\n onDropChoice: PropTypes.func.isRequired,\n onMoveChoice: PropTypes.func,\n isOver: PropTypes.bool,\n onDeleteChoice: PropTypes.func,\n categoryId: PropTypes.string.isRequired,\n };\n\n static defaultProps = {};\n render() {\n const { alternateResponseIndex, isOver, category, choices, classes, className, connectDropTarget, onDeleteChoice } =\n this.props;\n\n return connectDropTarget(\n <div className={classNames(classes.droppablePlaceholder, className)}>\n <PlaceHolder isOver={isOver} className={classes.placeHolder}>\n {(choices || []).length === 0 ? (\n <Helper />\n ) : (\n <Previews\n alternateResponseIndex={alternateResponseIndex}\n category={category}\n choices={choices}\n onDeleteChoice={onDeleteChoice}\n />\n )}\n </PlaceHolder>\n </div>,\n );\n }\n}\nconst styles = () => ({\n droppablePlaceholder: {\n minHeight: '100px',\n },\n placeHolder: {\n width: '100%',\n minHeight: '100px',\n height: 'auto',\n },\n});\n\nconst Styled = withStyles(styles)(DroppablePlaceHolder);\n\nexport const spec = {\n drop: (props, monitor) => {\n log('[drop] props: ', props);\n const item = monitor.getItem();\n\n if (item.from && item.alternateResponseIndex === props.alternateResponseIndex) {\n props.onMoveChoice(item.choiceId, item.from, props.categoryId, item.choiceIndex, item.alternateResponseIndex);\n } else if (!item.from){\n // avoid dropping choice when user tries to move it to an alternate with other index\n props.onDropChoice(item, props.categoryId);\n }\n },\n canDrop: (props /*, monitor*/) => {\n return !props.disabled;\n },\n};\n\nconst WithTarget = DropTarget(\n ({ uid }) => uid,\n spec,\n (connect, monitor) => ({\n connectDropTarget: connect.dropTarget(),\n isOver: monitor.isOver(),\n }),\n)(Styled);\n\nexport default uid.withUid(WithTarget);\n"],"file":"droppable-placeholder.js"}
|
|
@@ -39,15 +39,23 @@ var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
|
|
|
39
39
|
|
|
40
40
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
41
41
|
|
|
42
|
+
var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
|
|
43
|
+
|
|
44
|
+
var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
|
|
45
|
+
|
|
46
|
+
var _categorize = require("@pie-lib/categorize");
|
|
47
|
+
|
|
42
48
|
var _category = _interopRequireDefault(require("./category"));
|
|
43
49
|
|
|
44
50
|
var _header = _interopRequireDefault(require("../header"));
|
|
45
51
|
|
|
46
|
-
var
|
|
52
|
+
var _utils = require("../../utils");
|
|
53
|
+
|
|
54
|
+
var _RowLabel = require("./RowLabel");
|
|
47
55
|
|
|
48
56
|
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
57
|
|
|
50
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
58
|
+
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
59
|
|
|
52
60
|
var styles = function styles(theme) {
|
|
53
61
|
return {
|
|
@@ -73,32 +81,20 @@ var styles = function styles(theme) {
|
|
|
73
81
|
},
|
|
74
82
|
rowLabelHolder: {
|
|
75
83
|
width: '100%'
|
|
84
|
+
},
|
|
85
|
+
tooltip: {
|
|
86
|
+
fontSize: '12px',
|
|
87
|
+
whiteSpace: 'pre',
|
|
88
|
+
maxWidth: '500px'
|
|
89
|
+
},
|
|
90
|
+
errorText: {
|
|
91
|
+
fontSize: '12px',
|
|
92
|
+
color: 'red',
|
|
93
|
+
padding: '5px 0'
|
|
76
94
|
}
|
|
77
95
|
};
|
|
78
96
|
};
|
|
79
97
|
|
|
80
|
-
var RowLabel = (0, _styles.withStyles)(styles)(function (_ref) {
|
|
81
|
-
var categoriesPerRow = _ref.categoriesPerRow,
|
|
82
|
-
classes = _ref.classes,
|
|
83
|
-
markup = _ref.markup,
|
|
84
|
-
imageSupport = _ref.imageSupport,
|
|
85
|
-
onChange = _ref.onChange;
|
|
86
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
87
|
-
style: {
|
|
88
|
-
gridColumn: "1/".concat(categoriesPerRow + 1),
|
|
89
|
-
width: '100%'
|
|
90
|
-
}
|
|
91
|
-
}, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
92
|
-
className: classes.text
|
|
93
|
-
}, "Row Label"), /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
|
|
94
|
-
className: classes.rowLabelHolder,
|
|
95
|
-
markup: markup,
|
|
96
|
-
onChange: onChange,
|
|
97
|
-
imageSupport: imageSupport,
|
|
98
|
-
nonEmpty: false
|
|
99
|
-
}));
|
|
100
|
-
});
|
|
101
|
-
|
|
102
98
|
var Categories = /*#__PURE__*/function (_React$Component) {
|
|
103
99
|
(0, _inherits2["default"])(Categories, _React$Component);
|
|
104
100
|
|
|
@@ -114,17 +110,13 @@ var Categories = /*#__PURE__*/function (_React$Component) {
|
|
|
114
110
|
}
|
|
115
111
|
|
|
116
112
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
117
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (numberValue && numberValue >= 1 && numberValue <= 4) {
|
|
121
|
-
_this.props.onModelChanged({
|
|
122
|
-
categoriesPerRow: numberValue
|
|
123
|
-
});
|
|
124
|
-
}
|
|
113
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
|
|
114
|
+
focusedEl: null
|
|
125
115
|
});
|
|
126
116
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "add", function () {
|
|
127
|
-
var
|
|
117
|
+
var _this$props = _this.props,
|
|
118
|
+
model = _this$props.model,
|
|
119
|
+
oldCategories = _this$props.categories;
|
|
128
120
|
var categoriesPerRow = model.categoriesPerRow;
|
|
129
121
|
|
|
130
122
|
var id = _configUi.choiceUtils.firstAvailableIndex(model.categories.map(function (a) {
|
|
@@ -142,15 +134,24 @@ var Categories = /*#__PURE__*/function (_React$Component) {
|
|
|
142
134
|
rowLabels.push('');
|
|
143
135
|
}
|
|
144
136
|
|
|
145
|
-
_this.
|
|
146
|
-
|
|
147
|
-
|
|
137
|
+
_this.setState({
|
|
138
|
+
focusedEl: oldCategories.length
|
|
139
|
+
}, function () {
|
|
140
|
+
_this.props.onModelChanged({
|
|
141
|
+
rowLabels: rowLabels,
|
|
142
|
+
categories: model.categories.concat([data])
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "deleteFocusedEl", function () {
|
|
147
|
+
_this.setState({
|
|
148
|
+
focusedEl: null
|
|
148
149
|
});
|
|
149
150
|
});
|
|
150
151
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "delete", function (category) {
|
|
151
|
-
var _this$
|
|
152
|
-
model = _this$
|
|
153
|
-
onModelChanged = _this$
|
|
152
|
+
var _this$props2 = _this.props,
|
|
153
|
+
model = _this$props2.model,
|
|
154
|
+
onModelChanged = _this$props2.onModelChanged;
|
|
154
155
|
var index = model.categories.findIndex(function (a) {
|
|
155
156
|
return a.id === category.id;
|
|
156
157
|
});
|
|
@@ -175,24 +176,68 @@ var Categories = /*#__PURE__*/function (_React$Component) {
|
|
|
175
176
|
});
|
|
176
177
|
}
|
|
177
178
|
});
|
|
178
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "addChoiceToCategory", function (
|
|
179
|
-
var _this$
|
|
180
|
-
model = _this$
|
|
181
|
-
onModelChanged = _this$
|
|
182
|
-
|
|
179
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "addChoiceToCategory", function (addedChoice, categoryId) {
|
|
180
|
+
var _this$props3 = _this.props,
|
|
181
|
+
model = _this$props3.model,
|
|
182
|
+
onModelChanged = _this$props3.onModelChanged;
|
|
183
|
+
|
|
184
|
+
var _ref = model || {},
|
|
185
|
+
_ref$choices = _ref.choices,
|
|
186
|
+
choices = _ref$choices === void 0 ? [] : _ref$choices,
|
|
187
|
+
_ref$correctResponse = _ref.correctResponse,
|
|
188
|
+
correctResponse = _ref$correctResponse === void 0 ? [] : _ref$correctResponse;
|
|
189
|
+
|
|
190
|
+
var choice = (choices || []).find(function (choice) {
|
|
191
|
+
return choice.id === addedChoice.id;
|
|
192
|
+
});
|
|
193
|
+
correctResponse = (0, _categorize.moveChoiceToCategory)(addedChoice.id, undefined, categoryId, 0, model.correctResponse); // if multiplePlacements not allowed, ensure the consistency in the other categories
|
|
194
|
+
|
|
195
|
+
if (choice.categoryCount !== 0) {
|
|
196
|
+
correctResponse = (0, _categorize.verifyAllowMultiplePlacements)(addedChoice, categoryId, correctResponse);
|
|
197
|
+
}
|
|
198
|
+
|
|
183
199
|
onModelChanged({
|
|
184
200
|
correctResponse: correctResponse
|
|
185
201
|
});
|
|
186
202
|
});
|
|
187
203
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "deleteChoiceFromCategory", function (category, choice, choiceIndex) {
|
|
188
|
-
var _this$
|
|
189
|
-
model = _this$
|
|
190
|
-
onModelChanged = _this$
|
|
204
|
+
var _this$props4 = _this.props,
|
|
205
|
+
model = _this$props4.model,
|
|
206
|
+
onModelChanged = _this$props4.onModelChanged;
|
|
191
207
|
var correctResponse = (0, _categorize.removeChoiceFromCategory)(choice.id, category.id, choiceIndex, model.correctResponse);
|
|
192
208
|
onModelChanged({
|
|
193
209
|
correctResponse: correctResponse
|
|
194
210
|
});
|
|
195
211
|
});
|
|
212
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "moveChoice", function (choiceId, from, to, choiceIndex) {
|
|
213
|
+
var _this$props5 = _this.props,
|
|
214
|
+
model = _this$props5.model,
|
|
215
|
+
onModelChanged = _this$props5.onModelChanged;
|
|
216
|
+
|
|
217
|
+
var _ref2 = model || {},
|
|
218
|
+
choices = _ref2.choices,
|
|
219
|
+
_ref2$correctResponse = _ref2.correctResponse,
|
|
220
|
+
correctResponse = _ref2$correctResponse === void 0 ? [] : _ref2$correctResponse;
|
|
221
|
+
|
|
222
|
+
var choice = (choices || []).find(function (choice) {
|
|
223
|
+
return choice.id === choiceId;
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
if (to === from || !choice) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (choice.categoryCount !== 0) {
|
|
231
|
+
correctResponse = (0, _categorize.moveChoiceToCategory)(choice.id, from, to, choiceIndex, correctResponse);
|
|
232
|
+
correctResponse = (0, _categorize.verifyAllowMultiplePlacements)(choice, to, correctResponse);
|
|
233
|
+
} else if (choice.categoryCount === 0) {
|
|
234
|
+
correctResponse = (0, _categorize.moveChoiceToCategory)(choice.id, undefined, to, 0, correctResponse);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
onModelChanged({
|
|
238
|
+
correctResponse: correctResponse
|
|
239
|
+
});
|
|
240
|
+
});
|
|
196
241
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeRowLabel", function (val, index) {
|
|
197
242
|
var model = _this.props.model;
|
|
198
243
|
var rowLabels = model.rowLabels;
|
|
@@ -216,71 +261,110 @@ var Categories = /*#__PURE__*/function (_React$Component) {
|
|
|
216
261
|
value: function render() {
|
|
217
262
|
var _this2 = this;
|
|
218
263
|
|
|
219
|
-
var _this$
|
|
220
|
-
model = _this$
|
|
221
|
-
classes = _this$
|
|
222
|
-
className = _this$
|
|
223
|
-
categories = _this$
|
|
224
|
-
imageSupport = _this$
|
|
264
|
+
var _this$props6 = this.props,
|
|
265
|
+
model = _this$props6.model,
|
|
266
|
+
classes = _this$props6.classes,
|
|
267
|
+
className = _this$props6.className,
|
|
268
|
+
categories = _this$props6.categories,
|
|
269
|
+
imageSupport = _this$props6.imageSupport,
|
|
270
|
+
uploadSoundSupport = _this$props6.uploadSoundSupport,
|
|
271
|
+
toolbarOpts = _this$props6.toolbarOpts,
|
|
272
|
+
spellCheck = _this$props6.spellCheck,
|
|
273
|
+
configuration = _this$props6.configuration,
|
|
274
|
+
defaultImageMaxHeight = _this$props6.defaultImageMaxHeight,
|
|
275
|
+
defaultImageMaxWidth = _this$props6.defaultImageMaxWidth;
|
|
225
276
|
var categoriesPerRow = model.categoriesPerRow,
|
|
226
|
-
rowLabels = model.rowLabels
|
|
277
|
+
rowLabels = model.rowLabels,
|
|
278
|
+
errors = model.errors;
|
|
279
|
+
|
|
280
|
+
var _ref3 = errors || {},
|
|
281
|
+
associationError = _ref3.associationError,
|
|
282
|
+
categoriesError = _ref3.categoriesError,
|
|
283
|
+
categoriesErrors = _ref3.categoriesErrors;
|
|
284
|
+
|
|
285
|
+
var _ref4 = configuration || {},
|
|
286
|
+
maxCategories = _ref4.maxCategories,
|
|
287
|
+
_ref4$maxImageWidth = _ref4.maxImageWidth,
|
|
288
|
+
maxImageWidth = _ref4$maxImageWidth === void 0 ? {} : _ref4$maxImageWidth,
|
|
289
|
+
_ref4$maxImageHeight = _ref4.maxImageHeight,
|
|
290
|
+
maxImageHeight = _ref4$maxImageHeight === void 0 ? {} : _ref4$maxImageHeight;
|
|
291
|
+
|
|
227
292
|
var holderStyle = {
|
|
228
293
|
gridTemplateColumns: "repeat(".concat(categoriesPerRow, ", 1fr)")
|
|
229
294
|
};
|
|
230
|
-
var
|
|
295
|
+
var validationMessage = (0, _utils.generateValidationMessage)(configuration);
|
|
231
296
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
232
297
|
className: (0, _classnames["default"])(classes.categories, className)
|
|
233
298
|
}, /*#__PURE__*/_react["default"].createElement(_header["default"], {
|
|
234
299
|
label: "Categories",
|
|
235
300
|
buttonLabel: "ADD A CATEGORY",
|
|
236
|
-
onAdd: this.add
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
},
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
301
|
+
onAdd: this.add,
|
|
302
|
+
info: /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
|
|
303
|
+
classes: {
|
|
304
|
+
tooltip: classes.tooltip
|
|
305
|
+
},
|
|
306
|
+
disableFocusListener: true,
|
|
307
|
+
disableTouchListener: true,
|
|
308
|
+
placement: 'right',
|
|
309
|
+
title: validationMessage
|
|
310
|
+
}, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
|
|
311
|
+
fontSize: 'small',
|
|
312
|
+
color: 'primary',
|
|
313
|
+
style: {
|
|
314
|
+
marginLeft: '5px'
|
|
315
|
+
}
|
|
316
|
+
})),
|
|
317
|
+
buttonDisabled: maxCategories && categories && maxCategories === categories.length
|
|
318
|
+
}), associationError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
319
|
+
className: classes.errorText
|
|
320
|
+
}, associationError), categoriesError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
321
|
+
className: classes.errorText
|
|
322
|
+
}, categoriesError), /*#__PURE__*/_react["default"].createElement("div", {
|
|
249
323
|
className: classes.categoriesHolder,
|
|
250
324
|
style: holderStyle
|
|
251
325
|
}, categories.map(function (category, index) {
|
|
252
|
-
var hasRowLabel = index
|
|
253
|
-
var rowIndex =
|
|
326
|
+
var hasRowLabel = index % categoriesPerRow === 0;
|
|
327
|
+
var rowIndex = index / categoriesPerRow;
|
|
254
328
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, {
|
|
255
329
|
key: index
|
|
256
|
-
}, hasRowLabel && /*#__PURE__*/_react["default"].createElement(RowLabel, {
|
|
330
|
+
}, hasRowLabel && /*#__PURE__*/_react["default"].createElement(_RowLabel.RowLabel, {
|
|
257
331
|
categoriesPerRow: categoriesPerRow,
|
|
332
|
+
disabled: false,
|
|
258
333
|
rowIndex: rowIndex,
|
|
259
334
|
markup: rowLabels[rowIndex] || '',
|
|
260
335
|
onChange: function onChange(val) {
|
|
261
336
|
return _this2.changeRowLabel(val, rowIndex);
|
|
262
337
|
},
|
|
263
|
-
imageSupport: imageSupport
|
|
338
|
+
imageSupport: imageSupport,
|
|
339
|
+
toolbarOpts: toolbarOpts,
|
|
340
|
+
spellCheck: spellCheck,
|
|
341
|
+
maxImageWidth: maxImageWidth && maxImageWidth.rowLabel || defaultImageMaxWidth,
|
|
342
|
+
maxImageHeight: maxImageHeight && maxImageHeight.rowLabel || defaultImageMaxHeight,
|
|
343
|
+
uploadSoundSupport: uploadSoundSupport
|
|
264
344
|
}), /*#__PURE__*/_react["default"].createElement(_category["default"], {
|
|
265
345
|
imageSupport: imageSupport,
|
|
346
|
+
focusedEl: _this2.state.focusedEl,
|
|
347
|
+
deleteFocusedEl: _this2.deleteFocusedEl,
|
|
348
|
+
index: index,
|
|
266
349
|
category: category,
|
|
350
|
+
error: categoriesErrors && categoriesErrors[category.id],
|
|
267
351
|
onChange: _this2.change,
|
|
268
352
|
onDelete: function onDelete() {
|
|
269
353
|
return _this2["delete"](category);
|
|
270
354
|
},
|
|
271
355
|
onAddChoice: _this2.addChoiceToCategory,
|
|
356
|
+
onMoveChoice: function onMoveChoice(choiceId, from, to, choiceIndex) {
|
|
357
|
+
return _this2.moveChoice(choiceId, from, to, choiceIndex);
|
|
358
|
+
},
|
|
359
|
+
toolbarOpts: toolbarOpts,
|
|
360
|
+
spellCheck: spellCheck,
|
|
272
361
|
onDeleteChoice: function onDeleteChoice(choice, choiceIndex) {
|
|
273
362
|
return _this2.deleteChoiceFromCategory(category, choice, choiceIndex);
|
|
274
|
-
}
|
|
363
|
+
},
|
|
364
|
+
maxImageWidth: maxImageWidth && maxImageWidth.categoryLabel || defaultImageMaxWidth,
|
|
365
|
+
maxImageHeight: maxImageHeight && maxImageHeight.categoryLabel || defaultImageMaxHeight,
|
|
366
|
+
uploadSoundSupport: uploadSoundSupport
|
|
275
367
|
}));
|
|
276
|
-
}), /*#__PURE__*/_react["default"].createElement(RowLabel, {
|
|
277
|
-
categoriesPerRow: categoriesPerRow,
|
|
278
|
-
rowIndex: lastRowLabelIndex,
|
|
279
|
-
markup: rowLabels[lastRowLabelIndex] || '',
|
|
280
|
-
onChange: function onChange(val) {
|
|
281
|
-
return _this2.changeRowLabel(val, lastRowLabelIndex);
|
|
282
|
-
},
|
|
283
|
-
imageSupport: imageSupport
|
|
284
368
|
})));
|
|
285
369
|
}
|
|
286
370
|
}]);
|
|
@@ -293,11 +377,17 @@ exports.Categories = Categories;
|
|
|
293
377
|
add: _propTypes["default"].func.isRequired,
|
|
294
378
|
"delete": _propTypes["default"].func.isRequired
|
|
295
379
|
}),
|
|
380
|
+
uploadSoundSupport: _propTypes["default"].shape({
|
|
381
|
+
add: _propTypes["default"].func.isRequired,
|
|
382
|
+
"delete": _propTypes["default"].func.isRequired
|
|
383
|
+
}),
|
|
296
384
|
classes: _propTypes["default"].object.isRequired,
|
|
297
385
|
className: _propTypes["default"].string,
|
|
298
386
|
categories: _propTypes["default"].array,
|
|
299
387
|
onModelChanged: _propTypes["default"].func,
|
|
300
|
-
model: _propTypes["default"].object.isRequired
|
|
388
|
+
model: _propTypes["default"].object.isRequired,
|
|
389
|
+
configuration: _propTypes["default"].object.isRequired,
|
|
390
|
+
toolbarOpts: _propTypes["default"].object
|
|
301
391
|
});
|
|
302
392
|
|
|
303
393
|
var _default = (0, _styles.withStyles)(styles)(Categories);
|