@pie-element/categorize 6.6.0 → 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 +538 -0
- package/configure/CHANGELOG.md +474 -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
|
@@ -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);
|
|
@@ -69,9 +74,7 @@ var Categories = /*#__PURE__*/function (_React$Component) {
|
|
|
69
74
|
disabled = _this$props.disabled,
|
|
70
75
|
_onDropChoice = _this$props.onDropChoice,
|
|
71
76
|
onRemoveChoice = _this$props.onRemoveChoice;
|
|
72
|
-
var
|
|
73
|
-
categoriesPerRow = model.categoriesPerRow;
|
|
74
|
-
var columns = choicesPerRow / categoriesPerRow; // split categories into an array of arrays (inner array),
|
|
77
|
+
var categoriesPerRow = model.categoriesPerRow; // split categories into an array of arrays (inner array),
|
|
75
78
|
// where each inner array represents how many categories should be displayed on one row
|
|
76
79
|
|
|
77
80
|
var chunkedCategories = (0, _chunk["default"])(categories, categoriesPerRow);
|
|
@@ -79,13 +82,13 @@ var Categories = /*#__PURE__*/function (_React$Component) {
|
|
|
79
82
|
columns: categoriesPerRow,
|
|
80
83
|
className: classes.categories,
|
|
81
84
|
rows: Math.ceil(categories.length / categoriesPerRow) * 2
|
|
82
|
-
}, chunkedCategories.map(function (cat) {
|
|
85
|
+
}, chunkedCategories.map(function (cat, rowIndex) {
|
|
83
86
|
var items = []; // for each inner array of categories, create a row with category titles
|
|
84
87
|
|
|
85
|
-
cat.forEach(function (c) {
|
|
88
|
+
cat.forEach(function (c, columnIndex) {
|
|
86
89
|
items.push( /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
87
90
|
className: classes.label,
|
|
88
|
-
key: "category-label-".concat(
|
|
91
|
+
key: "category-label-".concat(rowIndex, "-").concat(columnIndex)
|
|
89
92
|
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
90
93
|
dangerouslySetInnerHTML: {
|
|
91
94
|
__html: c.label
|
|
@@ -93,26 +96,29 @@ var Categories = /*#__PURE__*/function (_React$Component) {
|
|
|
93
96
|
})));
|
|
94
97
|
}); // if the last row has less categories than max on a row, fill the spaces with divs
|
|
95
98
|
|
|
96
|
-
items = items.concat(Array(categoriesPerRow - cat.length).fill( /*#__PURE__*/_react["default"].createElement("div", null))
|
|
99
|
+
items = items.concat(Array(categoriesPerRow - cat.length).fill( /*#__PURE__*/_react["default"].createElement("div", null)).map(function (value, index) {
|
|
100
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
101
|
+
key: "fill-space-".concat(index)
|
|
102
|
+
});
|
|
103
|
+
})); // for each inner array of categories, create a row with category containers
|
|
97
104
|
|
|
98
|
-
cat.forEach(function (c,
|
|
99
|
-
var rows = Math.floor(c.choices.length / columns) + 1;
|
|
105
|
+
cat.forEach(function (c, columnIndex) {
|
|
100
106
|
items.push( /*#__PURE__*/_react["default"].createElement(_category["default"], (0, _extends2["default"])({
|
|
101
|
-
grid: {
|
|
102
|
-
rows: rows,
|
|
103
|
-
columns: columns
|
|
104
|
-
},
|
|
105
107
|
onDropChoice: function onDropChoice(h) {
|
|
106
108
|
return _onDropChoice(c.id, h);
|
|
107
109
|
},
|
|
108
110
|
onRemoveChoice: onRemoveChoice,
|
|
109
111
|
disabled: disabled,
|
|
110
112
|
className: classes.category,
|
|
111
|
-
key:
|
|
113
|
+
key: "category-element-".concat(rowIndex, "-").concat(columnIndex)
|
|
112
114
|
}, c)));
|
|
113
115
|
}); // if the last row has less categories than max on a row, fill the spaces with divs
|
|
114
116
|
|
|
115
|
-
items = items.concat(Array(categoriesPerRow - cat.length).fill( /*#__PURE__*/_react["default"].createElement("div", null)))
|
|
117
|
+
items = items.concat(Array(categoriesPerRow - cat.length).fill( /*#__PURE__*/_react["default"].createElement("div", null)).map(function (value, index) {
|
|
118
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
119
|
+
key: "fill-space-final-".concat(index)
|
|
120
|
+
});
|
|
121
|
+
}));
|
|
116
122
|
return items;
|
|
117
123
|
}));
|
|
118
124
|
}
|
|
@@ -125,8 +131,7 @@ exports.Categories = Categories;
|
|
|
125
131
|
classes: _propTypes["default"].object.isRequired,
|
|
126
132
|
categories: _propTypes["default"].arrayOf(_propTypes["default"].shape(_category.CategoryType)),
|
|
127
133
|
model: _propTypes["default"].shape({
|
|
128
|
-
categoriesPerRow: _propTypes["default"].number
|
|
129
|
-
choicesPerRow: _propTypes["default"].number
|
|
134
|
+
categoriesPerRow: _propTypes["default"].number
|
|
130
135
|
}),
|
|
131
136
|
disabled: _propTypes["default"].bool,
|
|
132
137
|
onDropChoice: _propTypes["default"].func.isRequired,
|
|
@@ -134,19 +139,20 @@ exports.Categories = Categories;
|
|
|
134
139
|
});
|
|
135
140
|
(0, _defineProperty2["default"])(Categories, "defaultProps", {
|
|
136
141
|
model: {
|
|
137
|
-
categoriesPerRow: 1
|
|
138
|
-
choicesPerRow: 1
|
|
142
|
+
categoriesPerRow: 1
|
|
139
143
|
}
|
|
140
144
|
});
|
|
141
145
|
|
|
142
146
|
var styles = function styles(theme) {
|
|
143
147
|
return {
|
|
144
148
|
categories: {
|
|
145
|
-
flex: 1
|
|
149
|
+
flex: 1,
|
|
150
|
+
padding: '8px'
|
|
146
151
|
},
|
|
147
152
|
label: {
|
|
148
153
|
color: _renderUi.color.text(),
|
|
149
154
|
backgroundColor: _renderUi.color.background(),
|
|
155
|
+
fontSize: theme.typography.fontSize,
|
|
150
156
|
textAlign: 'center',
|
|
151
157
|
paddingTop: theme.spacing.unit
|
|
152
158
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/categorize/categories.jsx"],"names":["Categories","props","classes","categories","model","disabled","onDropChoice","onRemoveChoice","
|
|
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","value","index","h","id","category","React","Component","PropTypes","object","isRequired","arrayOf","shape","CategoryType","number","bool","func","styles","theme","flex","padding","color","text","backgroundColor","background","fontSize","typography","textAlign","paddingTop","spacing","unit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;;;;;;;;;IAIaA,U;;;;;;;;;;;;WAkBX,kBAAS;AACP,wBAA+E,KAAKC,KAApF;AAAA,UAAQC,OAAR,eAAQA,OAAR;AAAA,UAAiBC,UAAjB,eAAiBA,UAAjB;AAAA,UAA6BC,KAA7B,eAA6BA,KAA7B;AAAA,UAAoCC,QAApC,eAAoCA,QAApC;AAAA,UAA8CC,aAA9C,eAA8CA,YAA9C;AAAA,UAA4DC,cAA5D,eAA4DA,cAA5D;AACA,UAAQC,gBAAR,GAA6BJ,KAA7B,CAAQI,gBAAR,CAFO,CAIP;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,SAKGC,iBAAiB,CAACI,GAAlB,CAAsB,UAACC,GAAD,EAAMC,QAAN,EAAmB;AACxC,YAAIC,KAAK,GAAG,EAAZ,CADwC,CAGxC;;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,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jCA,CALH,CADF;AA0CD;;;EApE6Be,kBAAMC,S;;;iCAAzBhC,U,eACQ;AACjBE,EAAAA,OAAO,EAAE+B,sBAAUC,MAAV,CAAiBC,UADT;AAEjBhC,EAAAA,UAAU,EAAE8B,sBAAUG,OAAV,CAAkBH,sBAAUI,KAAV,CAAgBC,sBAAhB,CAAlB,CAFK;AAGjBlC,EAAAA,KAAK,EAAE6B,sBAAUI,KAAV,CAAgB;AACrB7B,IAAAA,gBAAgB,EAAEyB,sBAAUM;AADP,GAAhB,CAHU;AAMjBlC,EAAAA,QAAQ,EAAE4B,sBAAUO,IANH;AAOjBlC,EAAAA,YAAY,EAAE2B,sBAAUQ,IAAV,CAAeN,UAPZ;AAQjB5B,EAAAA,cAAc,EAAE0B,sBAAUQ,IAAV,CAAeN;AARd,C;iCADRnC,U,kBAYW;AACpBI,EAAAA,KAAK,EAAE;AACLI,IAAAA,gBAAgB,EAAE;AADb;AADa,C;;AA2DxB,IAAMkC,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBxC,IAAAA,UAAU,EAAE;AACVyC,MAAAA,IAAI,EAAE,CADI;AAEVC,MAAAA,OAAO,EAAE;AAFC,KADa;AAKzBxB,IAAAA,KAAK,EAAE;AACLyB,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADF;AAELC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN,EAFZ;AAGLC,MAAAA,QAAQ,EAAEP,KAAK,CAACQ,UAAN,CAAiBD,QAHtB;AAILE,MAAAA,SAAS,EAAE,QAJN;AAKLC,MAAAA,UAAU,EAAEV,KAAK,CAACW,OAAN,CAAcC;AALrB;AALkB,GAAZ;AAAA,CAAf;;eAae,wBAAWb,MAAX,EAAmB1C,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 { classes, categories, model, disabled, onDropChoice, onRemoveChoice } = 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 {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\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/>).map((value,index) => <div key={`fill-space-${index}`} />));\n\n // for each inner array of categories, create a row with category containers\n cat.forEach((c, columnIndex) => {\n items.push(\n <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\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/>).map((value,index) =><div key={`fill-space-final-${index}`} />));\n\n return items;\n })}\n </GridContent>\n );\n }\n}\n\nconst styles = (theme) => ({\n categories: {\n flex: 1,\n padding: '8px'\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,
|
|
@@ -70,7 +70,6 @@ var Category = /*#__PURE__*/function (_React$Component) {
|
|
|
70
70
|
disabled = _this$props.disabled,
|
|
71
71
|
onDropChoice = _this$props.onDropChoice,
|
|
72
72
|
onRemoveChoice = _this$props.onRemoveChoice,
|
|
73
|
-
grid = _this$props.grid,
|
|
74
73
|
id = _this$props.id,
|
|
75
74
|
correct = _this$props.correct;
|
|
76
75
|
var names = (0, _classnames["default"])(classes.category, className);
|
|
@@ -78,9 +77,6 @@ var Category = /*#__PURE__*/function (_React$Component) {
|
|
|
78
77
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
79
78
|
className: names
|
|
80
79
|
}, /*#__PURE__*/_react["default"].createElement(_droppablePlaceholder["default"], {
|
|
81
|
-
grid: _objectSpread(_objectSpread({}, grid), {}, {
|
|
82
|
-
rowsRepeatValue: 'minmax(60px, auto)'
|
|
83
|
-
}),
|
|
84
80
|
onDropChoice: onDropChoice,
|
|
85
81
|
disabled: disabled,
|
|
86
82
|
className: placeholderNames
|
|
@@ -108,15 +104,22 @@ exports.Category = Category;
|
|
|
108
104
|
}));
|
|
109
105
|
(0, _defineProperty2["default"])(Category, "defaultProps", {});
|
|
110
106
|
|
|
111
|
-
var styles = function styles() {
|
|
107
|
+
var styles = function styles(theme) {
|
|
112
108
|
return {
|
|
113
109
|
incorrect: {
|
|
114
110
|
border: "solid 2px ".concat(_renderUi.color.incorrect())
|
|
115
111
|
},
|
|
116
112
|
placeholder: {
|
|
117
|
-
minHeight: '
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
minHeight: '80px',
|
|
114
|
+
padding: theme.spacing.unit / 2,
|
|
115
|
+
borderRadius: theme.spacing.unit / 2,
|
|
116
|
+
gridColumnGap: 0,
|
|
117
|
+
gridRowGap: 0,
|
|
118
|
+
display: 'flex',
|
|
119
|
+
flexWrap: 'wrap',
|
|
120
|
+
justifyContent: 'center',
|
|
121
|
+
alignItems: 'center',
|
|
122
|
+
alignContent: 'flex-start'
|
|
120
123
|
},
|
|
121
124
|
category: {
|
|
122
125
|
display: 'flex',
|
|
@@ -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","
|
|
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,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Q,EAAAA,YAAY,EAAEV,sBAAUyB,I;AACxBd,EAAAA,cAAc,EAAEX,sBAAUyB;;iCAPjBrB,Q,kBAUW,E;;AA2BxB,IAAMsB,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBV,IAAAA,SAAS,EAAE;AACTW,MAAAA,MAAM,sBAAeC,gBAAMZ,SAAN,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 { classes, className, choices = [], disabled, onDropChoice, onRemoveChoice, id, correct } = this.props;\n\n const names = classNames(classes.category, className);\n const placeholderNames = classNames(classes.placeholder, correct === false && classes.incorrect);\n\n return (\n <div className={names}>\n <PlaceHolder onDropChoice={onDropChoice} disabled={disabled} className={placeholderNames}>\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 = {
|
|
@@ -102,22 +102,28 @@ exports.Layout = Layout;
|
|
|
102
102
|
}));
|
|
103
103
|
(0, _defineProperty2["default"])(Layout, "defaultProps", {});
|
|
104
104
|
|
|
105
|
-
var styles = function styles() {
|
|
105
|
+
var styles = function styles(theme) {
|
|
106
106
|
return {
|
|
107
107
|
choice: {
|
|
108
|
+
direction: 'initial',
|
|
108
109
|
cursor: 'pointer',
|
|
109
|
-
height: '100%',
|
|
110
110
|
width: '100%',
|
|
111
111
|
'&.correct': {
|
|
112
112
|
border: "solid 2px ".concat(_renderUi.color.correct())
|
|
113
113
|
},
|
|
114
114
|
'&.incorrect': {
|
|
115
115
|
border: "solid 2px ".concat(_renderUi.color.incorrect())
|
|
116
|
-
}
|
|
116
|
+
},
|
|
117
|
+
borderRadius: '6px'
|
|
117
118
|
},
|
|
118
119
|
cardRoot: {
|
|
119
120
|
color: _renderUi.color.text(),
|
|
120
121
|
backgroundColor: _renderUi.color.background(),
|
|
122
|
+
fontSize: theme.typography.fontSize + 2,
|
|
123
|
+
'&:last-child': {
|
|
124
|
+
paddingBottom: theme.spacing.unit * 2
|
|
125
|
+
},
|
|
126
|
+
borderRadius: '4px',
|
|
121
127
|
border: '1px solid'
|
|
122
128
|
},
|
|
123
129
|
disabled: {
|
|
@@ -156,12 +162,12 @@ var Choice = /*#__PURE__*/function (_React$Component2) {
|
|
|
156
162
|
content = _this$props2.content,
|
|
157
163
|
disabled = _this$props2.disabled,
|
|
158
164
|
isDragging = _this$props2.isDragging,
|
|
159
|
-
correct = _this$props2.correct
|
|
165
|
+
correct = _this$props2.correct,
|
|
166
|
+
extraStyle = _this$props2.extraStyle;
|
|
160
167
|
return connectDragSource( /*#__PURE__*/_react["default"].createElement("div", {
|
|
161
|
-
style: {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
168
|
+
style: _objectSpread({
|
|
169
|
+
margin: '4px'
|
|
170
|
+
}, extraStyle)
|
|
165
171
|
}, /*#__PURE__*/_react["default"].createElement(Styled, {
|
|
166
172
|
id: id,
|
|
167
173
|
content: content,
|
|
@@ -176,6 +182,7 @@ var Choice = /*#__PURE__*/function (_React$Component2) {
|
|
|
176
182
|
|
|
177
183
|
exports.Choice = Choice;
|
|
178
184
|
(0, _defineProperty2["default"])(Choice, "propTypes", _objectSpread(_objectSpread({}, ChoiceType), {}, {
|
|
185
|
+
extraStyle: _propTypes["default"].object,
|
|
179
186
|
connectDragSource: _propTypes["default"].func.isRequired
|
|
180
187
|
}));
|
|
181
188
|
var spec = {
|
|
@@ -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","
|
|
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,CAAnB;;;IAKMG,M;;;;;;;;;;;;WASX,kBAAS;AACP,wBAAuE,KAAKC,KAA5E;AAAA,UAAQC,OAAR,eAAQA,OAAR;AAAA,UAAiBC,SAAjB,eAAiBA,SAAjB;AAAA,UAA4BR,OAA5B,eAA4BA,OAA5B;AAAA,UAAqCS,UAArC,e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AaA,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 { classes, className, content, isDragging, disabled, correct } = 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 { connectDragSource, id, content, disabled, isDragging, correct, extraStyle } = this.props;\n\n return connectDragSource(\n <div style={{ margin: '4px', ...extraStyle }}>\n <Styled id={id} content={content} disabled={disabled} correct={correct} isDragging={isDragging} />\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,11 +37,15 @@ var _styles = require("@material-ui/core/styles");
|
|
|
37
37
|
|
|
38
38
|
var _choice = _interopRequireWildcard(require("./choice"));
|
|
39
39
|
|
|
40
|
-
var
|
|
40
|
+
var _droppablePlaceholder = _interopRequireDefault(require("./droppable-placeholder"));
|
|
41
|
+
|
|
42
|
+
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); }
|
|
43
|
+
|
|
44
|
+
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; }
|
|
41
45
|
|
|
42
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); }; }
|
|
43
47
|
|
|
44
|
-
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; } }
|
|
45
49
|
|
|
46
50
|
var Blank = function Blank() {
|
|
47
51
|
return /*#__PURE__*/_react["default"].createElement("div", null);
|
|
@@ -66,6 +70,8 @@ var Choices = /*#__PURE__*/function (_React$Component) {
|
|
|
66
70
|
choices = _this$props$choices === void 0 ? [] : _this$props$choices,
|
|
67
71
|
model = _this$props.model,
|
|
68
72
|
disabled = _this$props.disabled,
|
|
73
|
+
onDropChoice = _this$props.onDropChoice,
|
|
74
|
+
onRemoveChoice = _this$props.onRemoveChoice,
|
|
69
75
|
choicePosition = _this$props.choicePosition;
|
|
70
76
|
var style = {
|
|
71
77
|
textAlign: 'center'
|
|
@@ -77,19 +83,29 @@ var Choices = /*#__PURE__*/function (_React$Component) {
|
|
|
77
83
|
|
|
78
84
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
79
85
|
className: classes.wrapper
|
|
86
|
+
}, /*#__PURE__*/_react["default"].createElement(_droppablePlaceholder["default"], {
|
|
87
|
+
onDropChoice: onDropChoice,
|
|
88
|
+
onRemoveChoice: onRemoveChoice,
|
|
89
|
+
disabled: disabled,
|
|
90
|
+
style: {
|
|
91
|
+
background: 'none'
|
|
92
|
+
},
|
|
93
|
+
choiceBoard: true
|
|
80
94
|
}, model.choicesLabel && model.choicesLabel !== '' && /*#__PURE__*/_react["default"].createElement("div", {
|
|
81
|
-
className: classes.labelHolder
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}, choices.map(function (c, index) {
|
|
95
|
+
className: classes.labelHolder,
|
|
96
|
+
dangerouslySetInnerHTML: {
|
|
97
|
+
__html: model.choicesLabel
|
|
98
|
+
}
|
|
99
|
+
}), choices.map(function (c, index) {
|
|
87
100
|
return c.empty ? /*#__PURE__*/_react["default"].createElement(Blank, {
|
|
88
101
|
key: index
|
|
89
102
|
}) : /*#__PURE__*/_react["default"].createElement(_choice["default"], (0, _extends2["default"])({
|
|
90
103
|
disabled: disabled,
|
|
91
104
|
className: classes.choice,
|
|
92
|
-
key: index
|
|
105
|
+
key: index,
|
|
106
|
+
extraStyle: {
|
|
107
|
+
maxWidth: "".concat(95 / model.categoriesPerRow, "%")
|
|
108
|
+
}
|
|
93
109
|
}, c));
|
|
94
110
|
})));
|
|
95
111
|
}
|
|
@@ -104,7 +120,7 @@ exports.Choices = Choices;
|
|
|
104
120
|
empty: _propTypes["default"].bool
|
|
105
121
|
})])),
|
|
106
122
|
model: _propTypes["default"].shape({
|
|
107
|
-
|
|
123
|
+
categoriesPerRow: _propTypes["default"].number,
|
|
108
124
|
choicesLabel: _propTypes["default"].string
|
|
109
125
|
}),
|
|
110
126
|
disabled: _propTypes["default"].bool,
|
|
@@ -112,7 +128,7 @@ exports.Choices = Choices;
|
|
|
112
128
|
});
|
|
113
129
|
(0, _defineProperty2["default"])(Choices, "defaultProps", {
|
|
114
130
|
model: {
|
|
115
|
-
|
|
131
|
+
categoriesPerRow: 1,
|
|
116
132
|
choicesLabel: ''
|
|
117
133
|
}
|
|
118
134
|
});
|
|
@@ -121,11 +137,14 @@ var styles = function styles(theme) {
|
|
|
121
137
|
return {
|
|
122
138
|
wrapper: {
|
|
123
139
|
flex: 1,
|
|
124
|
-
padding: theme.spacing.unit
|
|
140
|
+
padding: theme.spacing.unit,
|
|
141
|
+
touchAction: 'none'
|
|
125
142
|
},
|
|
126
143
|
choices: {
|
|
127
|
-
|
|
128
|
-
|
|
144
|
+
padding: theme.spacing.unit / 2,
|
|
145
|
+
display: 'flex',
|
|
146
|
+
justifyContent: 'center',
|
|
147
|
+
alignItems: 'center'
|
|
129
148
|
},
|
|
130
149
|
labelHolder: {
|
|
131
150
|
margin: '0 auto',
|
|
@@ -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","
|
|
1
|
+
{"version":3,"sources":["../../src/categorize/choices.jsx"],"names":["Blank","Choices","props","classes","choices","model","disabled","onDropChoice","onRemoveChoice","choicePosition","style","textAlign","direction","wrapper","background","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","touchAction","display","justifyContent","alignItems","margin","paddingTop"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAGA,IAAMA,KAAK,GAAG,SAARA,KAAQ;AAAA,sBAAM,4CAAN;AAAA,CAAd;;IAEaC,O;;;;;;;;;;;;WAqBX,kBAAS;AACP,wBAQI,KAAKC,KART;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,YALF,eAKEA,YALF;AAAA,UAMEC,cANF,eAMEA,cANF;AAAA,UAOEC,cAPF,eAOEA,cAPF;AAUA,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,EAAET,OAAO,CAACU;AAAxB,sBACG,gCAAC,gCAAD;AACC,QAAA,YAAY,EAAEN,YADf;AAEC,QAAA,cAAc,EAAEC,cAFjB;AAGC,QAAA,QAAQ,EAAEF,QAHX;AAIC,QAAA,KAAK,EAAE;AAACQ,UAAAA,UAAU,EAAE;AAAb,SAJR;AAKC,QAAA,WAAW,EAAE;AALd,SAOAT,KAAK,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AACLmB,IAAAA,gBAAgB,EAAE,CADb;AAELT,IAAAA,YAAY,EAAE;AAFT;AADa,C;;AAyDxB,IAAMsB,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBzB,IAAAA,OAAO,EAAE;AACP0B,MAAAA,IAAI,EAAE,CADC;AAEPC,MAAAA,OAAO,EAAEF,KAAK,CAACG,OAAN,CAAcC,IAFhB;AAGPC,MAAAA,WAAW,EAAE;AAHN,KADgB;AAMzBvC,IAAAA,OAAO,EAAE;AACPoC,MAAAA,OAAO,EAAEF,KAAK,CAACG,OAAN,CAAcC,IAAd,GAAqB,CADvB;AAEPE,MAAAA,OAAO,EAAE,MAFF;AAGPC,MAAAA,cAAc,EAAE,QAHT;AAIPC,MAAAA,UAAU,EAAE;AAJL,KANgB;AAYzB9B,IAAAA,WAAW,EAAE;AACX+B,MAAAA,MAAM,EAAE,QADG;AAEXpC,MAAAA,SAAS,EAAE,QAFA;AAGXqC,MAAAA,UAAU,EAAEV,KAAK,CAACG,OAAN,CAAcC;AAHf;AAZY,GAAZ;AAAA,CAAf;;eAmBe,wBAAWL,MAAX,EAAmBpC,OAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport Choice, { ChoiceType } from './choice';\nimport DroppablePlaceholder from './droppable-placeholder';\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([PropTypes.shape(ChoiceType), PropTypes.shape({ empty: PropTypes.bool })]),\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 onDropChoice,\n onRemoveChoice,\n choicePosition,\n } = this.props;\n\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 <DroppablePlaceholder\n onDropChoice={onDropChoice}\n onRemoveChoice={onRemoveChoice}\n disabled={disabled}\n style={{background: 'none', }}\n choiceBoard={true}\n >\n {model.choicesLabel && model.choicesLabel !== '' && (\n <div className={classes.labelHolder} dangerouslySetInnerHTML={{ __html: model.choicesLabel }}></div>\n )}\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 </DroppablePlaceholder>\n </div>\n );\n }\n}\n\nconst styles = (theme) => ({\n wrapper: {\n flex: 1,\n padding: theme.spacing.unit,\n touchAction: 'none',\n },\n choices: {\n padding: theme.spacing.unit / 2,\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\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
|
|
|
@@ -54,7 +54,8 @@ var DroppablePlaceholder = /*#__PURE__*/function (_React$Component) {
|
|
|
54
54
|
isOver = _this$props.isOver,
|
|
55
55
|
className = _this$props.className,
|
|
56
56
|
grid = _this$props.grid,
|
|
57
|
-
disabled = _this$props.disabled
|
|
57
|
+
disabled = _this$props.disabled,
|
|
58
|
+
choiceBoard = _this$props.choiceBoard;
|
|
58
59
|
return connectDropTarget( /*#__PURE__*/_react["default"].createElement("div", {
|
|
59
60
|
style: {
|
|
60
61
|
flex: 1
|
|
@@ -63,7 +64,8 @@ var DroppablePlaceholder = /*#__PURE__*/function (_React$Component) {
|
|
|
63
64
|
className: className,
|
|
64
65
|
isOver: isOver,
|
|
65
66
|
grid: grid,
|
|
66
|
-
disabled: disabled
|
|
67
|
+
disabled: disabled,
|
|
68
|
+
choiceBoard: choiceBoard
|
|
67
69
|
}, children)));
|
|
68
70
|
}
|
|
69
71
|
}]);
|