@pie-element/categorize 11.0.5-esm.1 → 11.2.0-mui-update.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/configure/CHANGELOG.md +74 -0
  3. package/configure/lib/defaults.js +2 -5
  4. package/configure/lib/defaults.js.map +1 -1
  5. package/configure/lib/design/builder.js +15 -33
  6. package/configure/lib/design/builder.js.map +1 -1
  7. package/configure/lib/design/buttons.js +44 -95
  8. package/configure/lib/design/buttons.js.map +1 -1
  9. package/configure/lib/design/categories/RowLabel.js +32 -45
  10. package/configure/lib/design/categories/RowLabel.js.map +1 -1
  11. package/configure/lib/design/categories/alternateResponses.js +102 -251
  12. package/configure/lib/design/categories/alternateResponses.js.map +1 -1
  13. package/configure/lib/design/categories/category.js +138 -208
  14. package/configure/lib/design/categories/category.js.map +1 -1
  15. package/configure/lib/design/categories/choice-preview.js +59 -126
  16. package/configure/lib/design/categories/choice-preview.js.map +1 -1
  17. package/configure/lib/design/categories/droppable-placeholder.js +76 -165
  18. package/configure/lib/design/categories/droppable-placeholder.js.map +1 -1
  19. package/configure/lib/design/categories/index.js +199 -384
  20. package/configure/lib/design/categories/index.js.map +1 -1
  21. package/configure/lib/design/choices/choice.js +160 -263
  22. package/configure/lib/design/choices/choice.js.map +1 -1
  23. package/configure/lib/design/choices/config.js +46 -98
  24. package/configure/lib/design/choices/config.js.map +1 -1
  25. package/configure/lib/design/choices/index.js +152 -236
  26. package/configure/lib/design/choices/index.js.map +1 -1
  27. package/configure/lib/design/header.js +62 -111
  28. package/configure/lib/design/header.js.map +1 -1
  29. package/configure/lib/design/index.js +632 -476
  30. package/configure/lib/design/index.js.map +1 -1
  31. package/configure/lib/design/input-header.js +97 -149
  32. package/configure/lib/design/input-header.js.map +1 -1
  33. package/configure/lib/design/utils.js +4 -15
  34. package/configure/lib/design/utils.js.map +1 -1
  35. package/configure/lib/index.js +120 -183
  36. package/configure/lib/index.js.map +1 -1
  37. package/configure/lib/main.js +31 -74
  38. package/configure/lib/main.js.map +1 -1
  39. package/configure/lib/utils.js +22 -32
  40. package/configure/lib/utils.js.map +1 -1
  41. package/configure/package.json +15 -14
  42. package/controller/CHANGELOG.md +62 -0
  43. package/controller/lib/defaults.js +2 -5
  44. package/controller/lib/defaults.js.map +1 -1
  45. package/controller/lib/index.js +238 -315
  46. package/controller/lib/index.js.map +1 -1
  47. package/controller/lib/utils.js +40 -31
  48. package/controller/lib/utils.js.map +1 -1
  49. package/controller/package.json +5 -5
  50. package/lib/categorize/categories.js +110 -164
  51. package/lib/categorize/categories.js.map +1 -1
  52. package/lib/categorize/category.js +72 -122
  53. package/lib/categorize/category.js.map +1 -1
  54. package/lib/categorize/choice.js +116 -245
  55. package/lib/categorize/choice.js.map +1 -1
  56. package/lib/categorize/choices.js +66 -131
  57. package/lib/categorize/choices.js.map +1 -1
  58. package/lib/categorize/droppable-placeholder.js +49 -103
  59. package/lib/categorize/droppable-placeholder.js.map +1 -1
  60. package/lib/categorize/grid-content.js +39 -87
  61. package/lib/categorize/grid-content.js.map +1 -1
  62. package/lib/categorize/index.js +341 -316
  63. package/lib/categorize/index.js.map +1 -1
  64. package/lib/index.js +286 -271
  65. package/lib/index.js.map +1 -1
  66. package/package.json +17 -31
  67. package/LICENSE.md +0 -5
  68. package/esm/configure.js +0 -5025
  69. package/esm/configure.js.map +0 -1
  70. package/esm/controller.js +0 -456
  71. package/esm/controller.js.map +0 -1
  72. package/esm/element.js +0 -3118
  73. package/esm/element.js.map +0 -1
  74. package/module/configure.js +0 -1
  75. package/module/controller.js +0 -6076
  76. package/module/demo.js +0 -382
  77. package/module/element.js +0 -1
  78. package/module/index.html +0 -21
  79. package/module/manifest.json +0 -22
  80. package/module/print-demo.js +0 -420
  81. package/module/print.html +0 -18
@@ -1,114 +1,62 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
- exports["default"] = exports.Config = void 0;
9
-
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
-
16
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
-
18
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
-
20
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
-
7
+ exports.default = exports.Config = void 0;
22
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
9
  var _react = _interopRequireDefault(require("react"));
25
-
26
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
27
-
28
- var _styles = require("@material-ui/core/styles");
29
-
30
- var _classnames = _interopRequireDefault(require("classnames"));
31
-
32
- var _TextField = _interopRequireDefault(require("@material-ui/core/TextField"));
33
-
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
-
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
-
38
- var Config = /*#__PURE__*/function (_React$Component) {
39
- (0, _inherits2["default"])(Config, _React$Component);
40
-
41
- var _super = _createSuper(Config);
42
-
43
- function Config() {
44
- var _this;
45
-
46
- (0, _classCallCheck2["default"])(this, Config);
47
-
48
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
49
- args[_key] = arguments[_key];
50
- }
51
-
52
- _this = _super.call.apply(_super, [this].concat(args));
53
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeLabel", function (_ref) {
54
- var target = _ref.target;
55
-
56
- _this.props.onModelChanged({
11
+ var _styles = require("@mui/material/styles");
12
+ var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
13
+ const ConfigContainer = (0, _styles.styled)('div')(({
14
+ theme
15
+ }) => ({
16
+ paddingTop: theme.spacing(1),
17
+ marginBottom: theme.spacing(1)
18
+ }));
19
+ const StyledTextField = (0, _styles.styled)(_TextField.default)({
20
+ width: '100%'
21
+ });
22
+ class Config extends _react.default.Component {
23
+ constructor(...args) {
24
+ super(...args);
25
+ (0, _defineProperty2.default)(this, "changeLabel", ({
26
+ target
27
+ }) => {
28
+ this.props.onModelChanged({
57
29
  choicesLabel: target.value
58
30
  });
59
31
  });
60
- return _this;
61
32
  }
62
-
63
- (0, _createClass2["default"])(Config, [{
64
- key: "render",
65
- value: function render() {
66
- var _this$props = this.props,
67
- classes = _this$props.classes,
68
- className = _this$props.className,
69
- config = _this$props.config,
70
- spellCheck = _this$props.spellCheck;
71
- return /*#__PURE__*/_react["default"].createElement("div", {
72
- className: (0, _classnames["default"])(classes.config, className)
73
- }, /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
74
- className: classes.label,
75
- InputLabelProps: {
76
- shrink: true
77
- },
78
- variant: "outlined",
79
- label: "Label",
80
- value: config.choicesLabel,
81
- onChange: this.changeLabel,
82
- spellCheck: spellCheck
83
- }));
84
- }
85
- }]);
86
- return Config;
87
- }(_react["default"].Component);
88
-
33
+ render() {
34
+ const {
35
+ className,
36
+ config,
37
+ spellCheck
38
+ } = this.props;
39
+ return /*#__PURE__*/_react.default.createElement(ConfigContainer, {
40
+ className: className
41
+ }, /*#__PURE__*/_react.default.createElement(StyledTextField, {
42
+ InputLabelProps: {
43
+ shrink: true
44
+ },
45
+ variant: "outlined",
46
+ label: "Label",
47
+ value: config.choicesLabel,
48
+ onChange: this.changeLabel,
49
+ spellCheck: spellCheck
50
+ }));
51
+ }
52
+ }
89
53
  exports.Config = Config;
90
- (0, _defineProperty2["default"])(Config, "propTypes", {
91
- classes: _propTypes["default"].object.isRequired,
92
- className: _propTypes["default"].string,
93
- config: _propTypes["default"].object,
94
- onModelChanged: _propTypes["default"].func,
95
- spellCheck: _propTypes["default"].bool
54
+ (0, _defineProperty2.default)(Config, "propTypes", {
55
+ className: _propTypes.default.string,
56
+ config: _propTypes.default.object,
57
+ onModelChanged: _propTypes.default.func,
58
+ spellCheck: _propTypes.default.bool
96
59
  });
97
- (0, _defineProperty2["default"])(Config, "defaultProps", {});
98
-
99
- var styles = function styles(theme) {
100
- return {
101
- config: {
102
- paddingTop: theme.spacing.unit,
103
- marginBottom: theme.spacing.unit
104
- },
105
- label: {
106
- width: '100%'
107
- }
108
- };
109
- };
110
-
111
- var _default = (0, _styles.withStyles)(styles)(Config);
112
-
113
- exports["default"] = _default;
60
+ (0, _defineProperty2.default)(Config, "defaultProps", {});
61
+ var _default = exports.default = Config;
114
62
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/design/choices/config.jsx"],"names":["Config","target","props","onModelChanged","choicesLabel","value","classes","className","config","spellCheck","label","shrink","changeLabel","React","Component","PropTypes","object","isRequired","string","func","bool","styles","theme","paddingTop","spacing","unit","marginBottom","width"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEaA,M;;;;;;;;;;;;;;;oGAWG,gBAAgB;AAAA,UAAbC,MAAa,QAAbA,MAAa;;AAC5B,YAAKC,KAAL,CAAWC,cAAX,CAA0B;AAAEC,QAAAA,YAAY,EAAEH,MAAM,CAACI;AAAvB,OAA1B;AACD,K;;;;;;WAED,kBAAS;AACP,wBAAmD,KAAKH,KAAxD;AAAA,UAAQI,OAAR,eAAQA,OAAR;AAAA,UAAiBC,SAAjB,eAAiBA,SAAjB;AAAA,UAA4BC,MAA5B,eAA4BA,MAA5B;AAAA,UAAoCC,UAApC,eAAoCA,UAApC;AAEA,0BACE;AAAK,QAAA,SAAS,EAAE,4BAAWH,OAAO,CAACE,MAAnB,EAA2BD,SAA3B;AAAhB,sBACE,gCAAC,qBAAD;AACE,QAAA,SAAS,EAAED,OAAO,CAACI,KADrB;AAEE,QAAA,eAAe,EAAE;AACfC,UAAAA,MAAM,EAAE;AADO,SAFnB;AAKE,QAAA,OAAO,EAAC,UALV;AAME,QAAA,KAAK,EAAC,OANR;AAOE,QAAA,KAAK,EAAEH,MAAM,CAACJ,YAPhB;AAQE,QAAA,QAAQ,EAAE,KAAKQ,WARjB;AASE,QAAA,UAAU,EAAEH;AATd,QADF,CADF;AAeD;;;EAjCyBI,kBAAMC,S;;;iCAArBd,M,eACQ;AACjBM,EAAAA,OAAO,EAAES,sBAAUC,MAAV,CAAiBC,UADT;AAEjBV,EAAAA,SAAS,EAAEQ,sBAAUG,MAFJ;AAGjBV,EAAAA,MAAM,EAAEO,sBAAUC,MAHD;AAIjBb,EAAAA,cAAc,EAAEY,sBAAUI,IAJT;AAKjBV,EAAAA,UAAU,EAAEM,sBAAUK;AALL,C;iCADRpB,M,kBASW,E;;AA2BxB,IAAMqB,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBd,IAAAA,MAAM,EAAE;AACNe,MAAAA,UAAU,EAAED,KAAK,CAACE,OAAN,CAAcC,IADpB;AAENC,MAAAA,YAAY,EAAEJ,KAAK,CAACE,OAAN,CAAcC;AAFtB,KADiB;AAKzBf,IAAAA,KAAK,EAAE;AACLiB,MAAAA,KAAK,EAAE;AADF;AALkB,GAAZ;AAAA,CAAf;;eAUe,wBAAWN,MAAX,EAAmBrB,MAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport TextField from '@material-ui/core/TextField';\n\nexport class Config extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n config: PropTypes.object,\n onModelChanged: PropTypes.func,\n spellCheck: PropTypes.bool,\n };\n\n static defaultProps = {};\n\n changeLabel = ({ target }) => {\n this.props.onModelChanged({ choicesLabel: target.value });\n };\n\n render() {\n const { classes, className, config, spellCheck } = this.props;\n\n return (\n <div className={classNames(classes.config, className)}>\n <TextField\n className={classes.label}\n InputLabelProps={{\n shrink: true,\n }}\n variant=\"outlined\"\n label=\"Label\"\n value={config.choicesLabel}\n onChange={this.changeLabel}\n spellCheck={spellCheck}\n />\n </div>\n );\n }\n}\n\nconst styles = (theme) => ({\n config: {\n paddingTop: theme.spacing.unit,\n marginBottom: theme.spacing.unit,\n },\n label: {\n width: '100%',\n },\n});\n\nexport default withStyles(styles)(Config);\n"],"file":"config.js"}
1
+ {"version":3,"file":"config.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_TextField","ConfigContainer","styled","theme","paddingTop","spacing","marginBottom","StyledTextField","TextField","width","Config","React","Component","constructor","args","_defineProperty2","default","target","props","onModelChanged","choicesLabel","value","render","className","config","spellCheck","createElement","InputLabelProps","shrink","variant","label","onChange","changeLabel","exports","PropTypes","string","object","func","bool","_default"],"sources":["../../../src/design/choices/config.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport TextField from '@mui/material/TextField';\n\nconst ConfigContainer = styled('div')(({ theme }) => ({\n paddingTop: theme.spacing(1),\n marginBottom: theme.spacing(1),\n}));\n\nconst StyledTextField = styled(TextField)({\n width: '100%',\n});\n\nexport class Config extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n config: PropTypes.object,\n onModelChanged: PropTypes.func,\n spellCheck: PropTypes.bool,\n };\n\n static defaultProps = {};\n \n changeLabel = ({ target }) => {\n this.props.onModelChanged({ choicesLabel: target.value });\n };\n\n render() {\n const { className, config, spellCheck } = this.props;\n\n return (\n <ConfigContainer className={className}>\n <StyledTextField\n InputLabelProps={{\n shrink: true,\n }}\n variant=\"outlined\"\n label=\"Label\"\n value={config.choicesLabel}\n onChange={this.changeLabel}\n spellCheck={spellCheck}\n />\n </ConfigContainer>\n );\n }\n}\n\nexport default Config;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEA,MAAMI,eAAe,GAAG,IAAAC,cAAM,EAAC,KAAK,CAAC,CAAC,CAAC;EAAEC;AAAM,CAAC,MAAM;EACpDC,UAAU,EAAED,KAAK,CAACE,OAAO,CAAC,CAAC,CAAC;EAC5BC,YAAY,EAAEH,KAAK,CAACE,OAAO,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEH,MAAME,eAAe,GAAG,IAAAL,cAAM,EAACM,kBAAS,CAAC,CAAC;EACxCC,KAAK,EAAE;AACT,CAAC,CAAC;AAEK,MAAMC,MAAM,SAASC,cAAK,CAACC,SAAS,CAAC;EAAAC,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,uBAU5B,CAAC;MAAEC;IAAO,CAAC,KAAK;MAC5B,IAAI,CAACC,KAAK,CAACC,cAAc,CAAC;QAAEC,YAAY,EAAEH,MAAM,CAACI;MAAM,CAAC,CAAC;IAC3D,CAAC;EAAA;EAEDC,MAAMA,CAAA,EAAG;IACP,MAAM;MAAEC,SAAS;MAAEC,MAAM;MAAEC;IAAW,CAAC,GAAG,IAAI,CAACP,KAAK;IAEpD,oBACEvB,MAAA,CAAAqB,OAAA,CAAAU,aAAA,CAACzB,eAAe;MAACsB,SAAS,EAAEA;IAAU,gBACpC5B,MAAA,CAAAqB,OAAA,CAAAU,aAAA,CAACnB,eAAe;MACdoB,eAAe,EAAE;QACfC,MAAM,EAAE;MACV,CAAE;MACFC,OAAO,EAAC,UAAU;MAClBC,KAAK,EAAC,OAAO;MACbT,KAAK,EAAEG,MAAM,CAACJ,YAAa;MAC3BW,QAAQ,EAAE,IAAI,CAACC,WAAY;MAC3BP,UAAU,EAAEA;IAAW,CACxB,CACc,CAAC;EAEtB;AACF;AAACQ,OAAA,CAAAvB,MAAA,GAAAA,MAAA;AAAA,IAAAK,gBAAA,CAAAC,OAAA,EAhCYN,MAAM,eACE;EACjBa,SAAS,EAAEW,kBAAS,CAACC,MAAM;EAC3BX,MAAM,EAAEU,kBAAS,CAACE,MAAM;EACxBjB,cAAc,EAAEe,kBAAS,CAACG,IAAI;EAC9BZ,UAAU,EAAES,kBAAS,CAACI;AACxB,CAAC;AAAA,IAAAvB,gBAAA,CAAAC,OAAA,EANUN,MAAM,kBAQK,CAAC,CAAC;AAAA,IAAA6B,QAAA,GAAAN,OAAA,CAAAjB,OAAA,GA0BXN,MAAM","ignoreList":[]}
@@ -1,285 +1,201 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
- exports["default"] = exports.Choices = void 0;
9
-
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
-
16
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
-
18
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
-
20
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
-
7
+ exports.default = exports.Choices = void 0;
22
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
9
  var _react = _interopRequireDefault(require("react"));
25
-
26
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
27
-
28
- var _styles = require("@material-ui/core/styles");
29
-
30
- var _classnames = _interopRequireDefault(require("classnames"));
31
-
11
+ var _styles = require("@mui/material/styles");
32
12
  var _choice = _interopRequireDefault(require("./choice"));
33
-
34
13
  var _header = _interopRequireDefault(require("../header"));
35
-
36
14
  var _config = _interopRequireDefault(require("./config"));
37
-
38
15
  var _configUi = require("@pie-lib/config-ui");
39
-
40
16
  var _categorize = require("@pie-lib/categorize");
41
-
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
-
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
-
46
- var Choices = /*#__PURE__*/function (_React$Component) {
47
- (0, _inherits2["default"])(Choices, _React$Component);
48
-
49
- var _super = _createSuper(Choices);
50
-
51
- function Choices() {
52
- var _this;
53
-
54
- (0, _classCallCheck2["default"])(this, Choices);
55
-
56
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
57
- args[_key] = arguments[_key];
58
- }
59
-
60
- _this = _super.call.apply(_super, [this].concat(args));
61
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
17
+ const ChoicesContainer = (0, _styles.styled)('div')(({
18
+ theme
19
+ }) => ({
20
+ marginBottom: theme.spacing(2.5)
21
+ }));
22
+ const ChoiceHolder = (0, _styles.styled)('div')(({
23
+ theme
24
+ }) => ({
25
+ paddingTop: theme.spacing(1),
26
+ paddingBottom: theme.spacing(1),
27
+ display: 'grid',
28
+ gridRowGap: `${theme.spacing(1)}px`,
29
+ gridColumnGap: `${theme.spacing(1)}px`
30
+ }));
31
+ const ErrorText = (0, _styles.styled)('div')(({
32
+ theme
33
+ }) => ({
34
+ fontSize: theme.typography.fontSize - 2,
35
+ color: theme.palette.error.main,
36
+ paddingTop: theme.spacing(0.5)
37
+ }));
38
+ class Choices extends _react.default.Component {
39
+ constructor(...args) {
40
+ super(...args);
41
+ (0, _defineProperty2.default)(this, "state", {
62
42
  focusedEl: null
63
43
  });
64
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeChoice", function (choice) {
65
- var _this$props = _this.props,
66
- choices = _this$props.choices,
67
- onModelChanged = _this$props.onModelChanged;
68
- var index = choices.findIndex(function (h) {
69
- return h.id === choice.id;
70
- });
71
-
44
+ (0, _defineProperty2.default)(this, "changeChoice", choice => {
45
+ const {
46
+ choices,
47
+ onModelChanged
48
+ } = this.props;
49
+ const index = choices.findIndex(h => h.id === choice.id);
72
50
  if (index !== -1) {
73
51
  choices.splice(index, 1, choice);
74
52
  onModelChanged({
75
- choices: choices
53
+ choices
76
54
  });
77
55
  }
78
56
  });
79
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "allChoicesHaveCount", function (count) {
80
- var choices = _this.props.choices;
81
- return Array.isArray(choices) && choices.every(function (c) {
82
- return c.categoryCount === count;
83
- });
57
+ (0, _defineProperty2.default)(this, "allChoicesHaveCount", count => {
58
+ const {
59
+ choices
60
+ } = this.props;
61
+ return Array.isArray(choices) && choices.every(c => c.categoryCount === count);
84
62
  });
85
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "addChoice", function () {
86
- var _model$choices;
87
-
88
- var _this$props2 = _this.props,
89
- onModelChanged = _this$props2.onModelChanged,
90
- model = _this$props2.model,
91
- oldChoices = _this$props2.choices;
92
-
93
- var _ref = model || {},
94
- maxAnswerChoices = _ref.maxAnswerChoices;
95
-
96
- if (maxAnswerChoices && ((_model$choices = model.choices) === null || _model$choices === void 0 ? void 0 : _model$choices.length) >= maxAnswerChoices) {
63
+ (0, _defineProperty2.default)(this, "addChoice", () => {
64
+ const {
65
+ onModelChanged,
66
+ model,
67
+ choices: oldChoices
68
+ } = this.props;
69
+ let {
70
+ maxAnswerChoices
71
+ } = model || {};
72
+ if (maxAnswerChoices && model.choices?.length >= maxAnswerChoices) {
97
73
  return;
98
74
  }
99
-
100
- var id = _configUi.choiceUtils.firstAvailableIndex(model.choices.map(function (a) {
101
- return a.id;
102
- }), 1);
103
-
104
- var data = {
105
- id: id,
75
+ const id = _configUi.choiceUtils.firstAvailableIndex(model.choices.map(a => a.id), 1);
76
+ const data = {
77
+ id,
106
78
  content: 'Choice ' + id
107
79
  };
108
-
109
- _this.setState({
80
+ this.setState({
110
81
  focusedEl: oldChoices.length
111
- }, function () {
82
+ }, () => {
112
83
  onModelChanged({
113
84
  choices: model.choices.concat([data])
114
85
  });
115
86
  });
116
87
  });
117
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "deleteFocusedEl", function () {
118
- _this.setState({
88
+ (0, _defineProperty2.default)(this, "deleteFocusedEl", () => {
89
+ this.setState({
119
90
  focusedEl: null
120
91
  });
121
92
  });
122
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "deleteChoice", function (choice) {
123
- var _this$props3 = _this.props,
124
- model = _this$props3.model,
125
- onModelChanged = _this$props3.onModelChanged;
126
- var index = model.choices.findIndex(function (a) {
127
- return a.id === choice.id;
128
- });
129
-
93
+ (0, _defineProperty2.default)(this, "deleteChoice", choice => {
94
+ const {
95
+ model,
96
+ onModelChanged
97
+ } = this.props;
98
+ const index = model.choices.findIndex(a => a.id === choice.id);
130
99
  if (index !== -1) {
131
100
  model.choices.splice(index, 1);
132
101
  model.correctResponse = (0, _categorize.removeAllChoices)(choice.id, model.correctResponse);
133
102
  onModelChanged(model);
134
103
  }
135
104
  });
136
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "rearrangeChoices", function (indexFrom, indexTo) {
137
- var _ref2 = _this.props || {},
138
- model = _ref2.model,
139
- onModelChanged = _ref2.onModelChanged;
140
-
141
- var _ref3 = model || [],
142
- choices = _ref3.choices;
143
-
144
- choices = (0, _categorize.rearrangeChoices)(choices, indexFrom, indexTo);
145
- onModelChanged({
146
- choices: choices
105
+ }
106
+ render() {
107
+ const {
108
+ focusedEl
109
+ } = this.state;
110
+ const {
111
+ className,
112
+ choices,
113
+ model,
114
+ imageSupport,
115
+ uploadSoundSupport,
116
+ onModelChanged,
117
+ spellCheck,
118
+ toolbarOpts,
119
+ configuration,
120
+ defaultImageMaxWidth,
121
+ defaultImageMaxHeight
122
+ } = this.props;
123
+ const {
124
+ errors,
125
+ allowMultiplePlacementsEnabled,
126
+ lockChoiceOrder,
127
+ maxAnswerChoices
128
+ } = model;
129
+ const {
130
+ choicesError,
131
+ choicesErrors
132
+ } = errors || {};
133
+ const {
134
+ maxImageWidth = {},
135
+ maxImageHeight = {}
136
+ } = configuration || {};
137
+ const choiceHolderStyle = {
138
+ gridTemplateColumns: `repeat(${model.categoriesPerRow}, 1fr)`
139
+ };
140
+ const addChoiceButtonTooltip = maxAnswerChoices && choices?.length >= maxAnswerChoices ? `Only ${maxAnswerChoices} allowed maximum` : '';
141
+ return /*#__PURE__*/_react.default.createElement(ChoicesContainer, {
142
+ className: className
143
+ }, /*#__PURE__*/_react.default.createElement(_header.default, {
144
+ label: "Choices",
145
+ buttonLabel: "ADD A CHOICE",
146
+ onAdd: this.addChoice,
147
+ buttonDisabled: maxAnswerChoices && choices && choices?.length >= maxAnswerChoices,
148
+ tooltip: addChoiceButtonTooltip
149
+ }), /*#__PURE__*/_react.default.createElement(_config.default, {
150
+ config: model,
151
+ onModelChanged: onModelChanged,
152
+ spellCheck: spellCheck
153
+ }), /*#__PURE__*/_react.default.createElement(ChoiceHolder, {
154
+ style: choiceHolderStyle
155
+ }, choices.map((h, index) => {
156
+ return /*#__PURE__*/_react.default.createElement(_choice.default, {
157
+ key: h.id,
158
+ choice: h,
159
+ focusedEl: focusedEl,
160
+ deleteFocusedEl: this.deleteFocusedEl,
161
+ correctResponseCount: h.correctResponseCount,
162
+ allowMultiplePlacements: allowMultiplePlacementsEnabled,
163
+ lockChoiceOrder: lockChoiceOrder,
164
+ index: index,
165
+ imageSupport: imageSupport,
166
+ onChange: this.changeChoice,
167
+ onDelete: () => this.deleteChoice(h),
168
+ toolbarOpts: toolbarOpts,
169
+ spellCheck: spellCheck,
170
+ error: choicesErrors && choicesErrors[h.id],
171
+ maxImageWidth: maxImageWidth && maxImageWidth.choice || defaultImageMaxWidth,
172
+ maxImageHeight: maxImageHeight && maxImageHeight.choice || defaultImageMaxHeight,
173
+ uploadSoundSupport: uploadSoundSupport,
174
+ configuration: configuration
147
175
  });
148
- });
149
- return _this;
176
+ })), choicesError && /*#__PURE__*/_react.default.createElement(ErrorText, null, choicesError));
150
177
  }
151
-
152
- (0, _createClass2["default"])(Choices, [{
153
- key: "render",
154
- value: function render() {
155
- var _this2 = this;
156
-
157
- var focusedEl = this.state.focusedEl;
158
- var _this$props4 = this.props,
159
- classes = _this$props4.classes,
160
- className = _this$props4.className,
161
- choices = _this$props4.choices,
162
- model = _this$props4.model,
163
- imageSupport = _this$props4.imageSupport,
164
- uploadSoundSupport = _this$props4.uploadSoundSupport,
165
- onModelChanged = _this$props4.onModelChanged,
166
- spellCheck = _this$props4.spellCheck,
167
- toolbarOpts = _this$props4.toolbarOpts,
168
- configuration = _this$props4.configuration,
169
- defaultImageMaxWidth = _this$props4.defaultImageMaxWidth,
170
- defaultImageMaxHeight = _this$props4.defaultImageMaxHeight;
171
- var errors = model.errors,
172
- allowMultiplePlacementsEnabled = model.allowMultiplePlacementsEnabled,
173
- lockChoiceOrder = model.lockChoiceOrder,
174
- maxAnswerChoices = model.maxAnswerChoices;
175
-
176
- var _ref4 = errors || {},
177
- choicesError = _ref4.choicesError,
178
- choicesErrors = _ref4.choicesErrors;
179
-
180
- var _ref5 = configuration || {},
181
- _ref5$maxImageWidth = _ref5.maxImageWidth,
182
- maxImageWidth = _ref5$maxImageWidth === void 0 ? {} : _ref5$maxImageWidth,
183
- _ref5$maxImageHeight = _ref5.maxImageHeight,
184
- maxImageHeight = _ref5$maxImageHeight === void 0 ? {} : _ref5$maxImageHeight;
185
-
186
- var choiceHolderStyle = {
187
- gridTemplateColumns: "repeat(".concat(model.categoriesPerRow, ", 1fr)")
188
- };
189
- var addChoiceButtonTooltip = maxAnswerChoices && (choices === null || choices === void 0 ? void 0 : choices.length) >= maxAnswerChoices ? "Only ".concat(maxAnswerChoices, " allowed maximum") : '';
190
- return /*#__PURE__*/_react["default"].createElement("div", {
191
- className: (0, _classnames["default"])(classes.choices, className)
192
- }, /*#__PURE__*/_react["default"].createElement(_header["default"], {
193
- label: "Choices",
194
- buttonLabel: "ADD A CHOICE",
195
- onAdd: this.addChoice,
196
- buttonDisabled: maxAnswerChoices && choices && (choices === null || choices === void 0 ? void 0 : choices.length) >= maxAnswerChoices,
197
- tooltip: addChoiceButtonTooltip
198
- }), /*#__PURE__*/_react["default"].createElement(_config["default"], {
199
- config: model,
200
- onModelChanged: onModelChanged,
201
- spellCheck: spellCheck
202
- }), /*#__PURE__*/_react["default"].createElement("div", {
203
- className: classes.choiceHolder,
204
- style: choiceHolderStyle
205
- }, choices.map(function (h, index) {
206
- return /*#__PURE__*/_react["default"].createElement(_choice["default"], {
207
- choice: h,
208
- focusedEl: focusedEl,
209
- deleteFocusedEl: _this2.deleteFocusedEl,
210
- correctResponseCount: h.correctResponseCount,
211
- allowMultiplePlacements: allowMultiplePlacementsEnabled,
212
- lockChoiceOrder: lockChoiceOrder,
213
- index: index,
214
- key: index,
215
- imageSupport: imageSupport,
216
- onChange: _this2.changeChoice,
217
- onDelete: function onDelete() {
218
- return _this2.deleteChoice(h);
219
- },
220
- rearrangeChoices: function rearrangeChoices(indexFrom, indexTo) {
221
- return _this2.rearrangeChoices(indexFrom, indexTo);
222
- },
223
- toolbarOpts: toolbarOpts,
224
- spellCheck: spellCheck,
225
- error: choicesErrors && choicesErrors[h.id],
226
- maxImageWidth: maxImageWidth && maxImageWidth.choice || defaultImageMaxWidth,
227
- maxImageHeight: maxImageHeight && maxImageHeight.choice || defaultImageMaxHeight,
228
- uploadSoundSupport: uploadSoundSupport,
229
- configuration: configuration
230
- });
231
- })), choicesError && /*#__PURE__*/_react["default"].createElement("div", {
232
- className: classes.errorText
233
- }, choicesError));
234
- }
235
- }]);
236
- return Choices;
237
- }(_react["default"].Component);
238
-
178
+ }
239
179
  exports.Choices = Choices;
240
- (0, _defineProperty2["default"])(Choices, "propTypes", {
241
- model: _propTypes["default"].object.isRequired,
242
- configuration: _propTypes["default"].object.isRequired,
243
- classes: _propTypes["default"].object.isRequired,
244
- className: _propTypes["default"].string,
245
- choices: _propTypes["default"].array.isRequired,
246
- defaultImageMaxWidth: _propTypes["default"].number,
247
- defaultImageMaxHeight: _propTypes["default"].number,
248
- onModelChanged: _propTypes["default"].func.isRequired,
249
- imageSupport: _propTypes["default"].shape({
250
- add: _propTypes["default"].func.isRequired,
251
- "delete": _propTypes["default"].func.isRequired
180
+ (0, _defineProperty2.default)(Choices, "propTypes", {
181
+ model: _propTypes.default.object.isRequired,
182
+ configuration: _propTypes.default.object.isRequired,
183
+ className: _propTypes.default.string,
184
+ choices: _propTypes.default.array.isRequired,
185
+ defaultImageMaxWidth: _propTypes.default.number,
186
+ defaultImageMaxHeight: _propTypes.default.number,
187
+ onModelChanged: _propTypes.default.func.isRequired,
188
+ imageSupport: _propTypes.default.shape({
189
+ add: _propTypes.default.func.isRequired,
190
+ delete: _propTypes.default.func.isRequired
252
191
  }),
253
- uploadSoundSupport: _propTypes["default"].shape({
254
- add: _propTypes["default"].func.isRequired,
255
- "delete": _propTypes["default"].func.isRequired
192
+ uploadSoundSupport: _propTypes.default.shape({
193
+ add: _propTypes.default.func.isRequired,
194
+ delete: _propTypes.default.func.isRequired
256
195
  }),
257
- toolbarOpts: _propTypes["default"].object,
258
- spellCheck: _propTypes["default"].bool
196
+ toolbarOpts: _propTypes.default.object,
197
+ spellCheck: _propTypes.default.bool
259
198
  });
260
- (0, _defineProperty2["default"])(Choices, "defaultProps", {});
261
-
262
- var styles = function styles(theme) {
263
- return {
264
- choiceHolder: {
265
- paddingTop: theme.spacing.unit,
266
- paddingBottom: theme.spacing.unit,
267
- display: 'grid',
268
- gridRowGap: "".concat(theme.spacing.unit, "px"),
269
- gridColumnGap: "".concat(theme.spacing.unit, "px")
270
- },
271
- choices: {
272
- marginBottom: theme.spacing.unit * 2.5
273
- },
274
- errorText: {
275
- fontSize: theme.typography.fontSize - 2,
276
- color: theme.palette.error.main,
277
- paddingTop: theme.spacing.unit / 2
278
- }
279
- };
280
- };
281
-
282
- var _default = (0, _styles.withStyles)(styles)(Choices);
283
-
284
- exports["default"] = _default;
199
+ (0, _defineProperty2.default)(Choices, "defaultProps", {});
200
+ var _default = exports.default = Choices;
285
201
  //# sourceMappingURL=index.js.map