@pie-lib/mask-markup 1.13.47-next.1 → 1.14.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -47
- package/NEXT.CHANGELOG.json +1 -0
- package/package.json +9 -5
- package/src/__tests__/__snapshots__/drag-in-the-blank.test.js.snap +316 -0
- package/src/__tests__/__snapshots__/mask.test.js.snap +55 -0
- package/src/__tests__/__snapshots__/with-mask.test.js.snap +62 -0
- package/src/__tests__/drag-in-the-blank.test.js +71 -0
- package/src/__tests__/index.test.js +39 -0
- package/src/__tests__/mask.test.js +152 -0
- package/src/__tests__/serialization.test.js +54 -0
- package/src/__tests__/utils.js +1 -0
- package/src/__tests__/with-mask.test.js +51 -0
- package/src/choices/__tests__/__snapshots__/index.test.js.snap +209 -0
- package/src/choices/__tests__/index.test.js +62 -0
- package/src/choices/choice.jsx +60 -6
- package/src/choices/index.jsx +2 -2
- package/src/components/__tests__/__snapshots__/blank.test.js.snap +111 -0
- package/src/components/__tests__/__snapshots__/correct-input.test.js.snap +64 -0
- package/src/components/__tests__/__snapshots__/dropdown.test.js.snap +133 -0
- package/src/components/__tests__/__snapshots__/input.test.js.snap +34 -0
- package/src/components/__tests__/blank.test.js +202 -0
- package/src/components/__tests__/correct-input.test.js +49 -0
- package/src/components/__tests__/dropdown.test.js +51 -0
- package/src/components/__tests__/input.test.js +50 -0
- package/src/components/blank.jsx +139 -28
- package/src/components/correct-input.jsx +6 -1
- package/src/components/dropdown.jsx +192 -71
- package/src/constructed-response.jsx +76 -18
- package/src/customizable.jsx +35 -0
- package/src/drag-in-the-blank.jsx +26 -3
- package/src/index.js +10 -1
- package/src/inline-dropdown.jsx +2 -0
- package/src/mask.jsx +30 -5
- package/src/with-mask.jsx +39 -2
- package/README.md +0 -14
- package/lib/choices/choice.js +0 -158
- package/lib/choices/choice.js.map +0 -1
- package/lib/choices/index.js +0 -127
- package/lib/choices/index.js.map +0 -1
- package/lib/componentize.js +0 -25
- package/lib/componentize.js.map +0 -1
- package/lib/components/blank.js +0 -303
- package/lib/components/blank.js.map +0 -1
- package/lib/components/correct-input.js +0 -113
- package/lib/components/correct-input.js.map +0 -1
- package/lib/components/dropdown.js +0 -216
- package/lib/components/dropdown.js.map +0 -1
- package/lib/components/input.js +0 -57
- package/lib/components/input.js.map +0 -1
- package/lib/constructed-response.js +0 -52
- package/lib/constructed-response.js.map +0 -1
- package/lib/drag-in-the-blank.js +0 -191
- package/lib/drag-in-the-blank.js.map +0 -1
- package/lib/index.js +0 -54
- package/lib/index.js.map +0 -1
- package/lib/inline-dropdown.js +0 -46
- package/lib/inline-dropdown.js.map +0 -1
- package/lib/mask.js +0 -215
- package/lib/mask.js.map +0 -1
- package/lib/serialization.js +0 -207
- package/lib/serialization.js.map +0 -1
- package/lib/with-mask.js +0 -93
- package/lib/with-mask.js.map +0 -1
package/src/with-mask.jsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import Mask from './mask';
|
|
4
5
|
import componentize from './componentize';
|
|
@@ -23,13 +24,49 @@ export const withMask = (type, renderChildren) => {
|
|
|
23
24
|
layout: PropTypes.object,
|
|
24
25
|
value: PropTypes.object,
|
|
25
26
|
onChange: PropTypes.func,
|
|
27
|
+
customMarkMarkupComponent: PropTypes.func,
|
|
28
|
+
elementType: PropTypes.string,
|
|
26
29
|
};
|
|
27
30
|
|
|
31
|
+
componentDidUpdate(prevProps) {
|
|
32
|
+
if (this.props.markup !== prevProps.markup) {
|
|
33
|
+
// eslint-disable-next-line
|
|
34
|
+
const domNode = ReactDOM.findDOMNode(this);
|
|
35
|
+
// Query all elements that may contain outdated MathJax renderings
|
|
36
|
+
const mathElements = domNode && domNode.querySelectorAll('[data-latex][data-math-handled="true"]');
|
|
37
|
+
|
|
38
|
+
// Clean up for fresh MathJax processing
|
|
39
|
+
(mathElements || []).forEach((el) => {
|
|
40
|
+
// Remove the MathJax container to allow for clean updates
|
|
41
|
+
const mjxContainer = el.querySelector('mjx-container');
|
|
42
|
+
|
|
43
|
+
if (mjxContainer) {
|
|
44
|
+
el.removeChild(mjxContainer);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Update the innerHTML to match the raw LaTeX data, ensuring it is reprocessed correctly
|
|
48
|
+
const latexCode = el.getAttribute('data-raw');
|
|
49
|
+
el.innerHTML = latexCode;
|
|
50
|
+
|
|
51
|
+
// Remove the attribute to signal that MathJax should reprocess this element
|
|
52
|
+
el.removeAttribute('data-math-handled');
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
28
57
|
render() {
|
|
29
|
-
const { markup, layout, value, onChange } = this.props;
|
|
58
|
+
const { markup, layout, value, onChange, elementType } = this.props;
|
|
30
59
|
|
|
31
60
|
const maskLayout = layout ? layout : buildLayoutFromMarkup(markup, type);
|
|
32
|
-
return
|
|
61
|
+
return (
|
|
62
|
+
<Mask
|
|
63
|
+
elementType={elementType}
|
|
64
|
+
layout={maskLayout}
|
|
65
|
+
value={value}
|
|
66
|
+
onChange={onChange}
|
|
67
|
+
renderChildren={renderChildren(this.props)}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
33
70
|
}
|
|
34
71
|
};
|
|
35
72
|
};
|
package/README.md
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# mask-markup
|
|
2
|
-
|
|
3
|
-
## issues
|
|
4
|
-
|
|
5
|
-
- dnd
|
|
6
|
-
- simple approach loses context due to stepping out of react tree to run a ReactDOM.render().
|
|
7
|
-
- Would need to pass drag parts as props (no context)
|
|
8
|
-
- Or do the entire tree render in react - like a simple slate
|
|
9
|
-
- HTML5Backend - ? going to be a an issue w/ multiple items using dnd?
|
|
10
|
-
|
|
11
|
-
* hey diddle sample
|
|
12
|
-
* add feedback
|
|
13
|
-
* check perf
|
|
14
|
-
* more complex html
|
package/lib/choices/choice.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = exports.DRAG_TYPE = exports.BlankContent = 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 _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
-
|
|
16
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
-
|
|
18
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
|
-
|
|
20
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
-
|
|
22
|
-
var _react = _interopRequireDefault(require("react"));
|
|
23
|
-
|
|
24
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
25
|
-
|
|
26
|
-
var _drag = require("@pie-lib/drag");
|
|
27
|
-
|
|
28
|
-
var _styles = require("@material-ui/core/styles");
|
|
29
|
-
|
|
30
|
-
var _Chip = _interopRequireDefault(require("@material-ui/core/Chip"));
|
|
31
|
-
|
|
32
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
33
|
-
|
|
34
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
35
|
-
|
|
36
|
-
var _mathRendering = require("@pie-lib/math-rendering");
|
|
37
|
-
|
|
38
|
-
var _renderUi = require("@pie-lib/render-ui");
|
|
39
|
-
|
|
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
|
-
|
|
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
|
-
|
|
44
|
-
var DRAG_TYPE = 'MaskBlank';
|
|
45
|
-
exports.DRAG_TYPE = DRAG_TYPE;
|
|
46
|
-
|
|
47
|
-
var BlankContentComp = /*#__PURE__*/function (_React$Component) {
|
|
48
|
-
(0, _inherits2["default"])(BlankContentComp, _React$Component);
|
|
49
|
-
|
|
50
|
-
var _super = _createSuper(BlankContentComp);
|
|
51
|
-
|
|
52
|
-
function BlankContentComp() {
|
|
53
|
-
(0, _classCallCheck2["default"])(this, BlankContentComp);
|
|
54
|
-
return _super.apply(this, arguments);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
(0, _createClass2["default"])(BlankContentComp, [{
|
|
58
|
-
key: "componentDidUpdate",
|
|
59
|
-
value: function componentDidUpdate() {
|
|
60
|
-
(0, _mathRendering.renderMath)(this.rootRef);
|
|
61
|
-
}
|
|
62
|
-
}, {
|
|
63
|
-
key: "render",
|
|
64
|
-
value: function render() {
|
|
65
|
-
var _this = this;
|
|
66
|
-
|
|
67
|
-
var _this$props = this.props,
|
|
68
|
-
connectDragSource = _this$props.connectDragSource,
|
|
69
|
-
choice = _this$props.choice,
|
|
70
|
-
classes = _this$props.classes,
|
|
71
|
-
disabled = _this$props.disabled; // TODO the Chip element is causing drag problems on touch devices. Avoid using Chip and consider refactoring the code. Keep in mind that Chip is a span with a button role, which interferes with seamless touch device dragging.
|
|
72
|
-
|
|
73
|
-
return connectDragSource( /*#__PURE__*/_react["default"].createElement("span", {
|
|
74
|
-
className: (0, _classnames["default"])(classes.choice, disabled && classes.disabled)
|
|
75
|
-
}, /*#__PURE__*/_react["default"].createElement(_Chip["default"], {
|
|
76
|
-
clickable: false,
|
|
77
|
-
disabled: true,
|
|
78
|
-
ref: function ref(_ref2) {
|
|
79
|
-
//eslint-disable-next-line
|
|
80
|
-
_this.rootRef = _reactDom["default"].findDOMNode(_ref2);
|
|
81
|
-
},
|
|
82
|
-
className: classes.chip,
|
|
83
|
-
label: /*#__PURE__*/_react["default"].createElement("span", {
|
|
84
|
-
className: classes.chipLabel,
|
|
85
|
-
ref: function ref(_ref) {
|
|
86
|
-
if (_ref) {
|
|
87
|
-
_ref.innerHTML = choice.value || ' ';
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}, ' '),
|
|
91
|
-
variant: disabled ? 'outlined' : undefined
|
|
92
|
-
})), {});
|
|
93
|
-
}
|
|
94
|
-
}]);
|
|
95
|
-
return BlankContentComp;
|
|
96
|
-
}(_react["default"].Component);
|
|
97
|
-
|
|
98
|
-
(0, _defineProperty2["default"])(BlankContentComp, "propTypes", {
|
|
99
|
-
disabled: _propTypes["default"].bool,
|
|
100
|
-
choice: _propTypes["default"].object,
|
|
101
|
-
classes: _propTypes["default"].object,
|
|
102
|
-
connectDragSource: _propTypes["default"].func
|
|
103
|
-
});
|
|
104
|
-
var BlankContent = (0, _styles.withStyles)(function (theme) {
|
|
105
|
-
return {
|
|
106
|
-
choice: {
|
|
107
|
-
border: "solid 0px ".concat(theme.palette.primary.main),
|
|
108
|
-
borderRadius: theme.spacing.unit * 2,
|
|
109
|
-
margin: theme.spacing.unit / 2,
|
|
110
|
-
transform: 'translate(0, 0)'
|
|
111
|
-
},
|
|
112
|
-
chip: {
|
|
113
|
-
backgroundColor: _renderUi.color.background(),
|
|
114
|
-
border: "1px solid ".concat(_renderUi.color.text()),
|
|
115
|
-
color: _renderUi.color.text(),
|
|
116
|
-
alignItems: 'center',
|
|
117
|
-
display: 'inline-flex',
|
|
118
|
-
height: 'initial',
|
|
119
|
-
minHeight: '32px',
|
|
120
|
-
fontSize: 'inherit',
|
|
121
|
-
whiteSpace: 'pre-wrap',
|
|
122
|
-
maxWidth: '374px',
|
|
123
|
-
// Added for touch devices, for image content.
|
|
124
|
-
// This will prevent the context menu from appearing and not allowing other interactions with the image.
|
|
125
|
-
// If interactions with the image in the token will be requested we should handle only the context Menu.
|
|
126
|
-
pointerEvents: 'none'
|
|
127
|
-
},
|
|
128
|
-
chipLabel: {
|
|
129
|
-
whiteSpace: 'pre-wrap',
|
|
130
|
-
'& img': {
|
|
131
|
-
display: 'block',
|
|
132
|
-
padding: '2px 0'
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
disabled: {}
|
|
136
|
-
};
|
|
137
|
-
})(BlankContentComp);
|
|
138
|
-
exports.BlankContent = BlankContent;
|
|
139
|
-
var tileSource = {
|
|
140
|
-
canDrag: function canDrag(props) {
|
|
141
|
-
return !props.disabled;
|
|
142
|
-
},
|
|
143
|
-
beginDrag: function beginDrag(props) {
|
|
144
|
-
return {
|
|
145
|
-
choice: props.choice,
|
|
146
|
-
instanceId: props.instanceId
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
var DragDropTile = (0, _drag.DragSource)(DRAG_TYPE, tileSource, function (connect, monitor) {
|
|
151
|
-
return {
|
|
152
|
-
connectDragSource: connect.dragSource(),
|
|
153
|
-
isDragging: monitor.isDragging()
|
|
154
|
-
};
|
|
155
|
-
})(BlankContent);
|
|
156
|
-
var _default = DragDropTile;
|
|
157
|
-
exports["default"] = _default;
|
|
158
|
-
//# sourceMappingURL=choice.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/choices/choice.jsx"],"names":["DRAG_TYPE","BlankContentComp","rootRef","props","connectDragSource","choice","classes","disabled","ref","ReactDOM","findDOMNode","chip","chipLabel","innerHTML","value","undefined","React","Component","PropTypes","bool","object","func","BlankContent","theme","border","palette","primary","main","borderRadius","spacing","unit","margin","transform","backgroundColor","color","background","text","alignItems","display","height","minHeight","fontSize","whiteSpace","maxWidth","pointerEvents","padding","tileSource","canDrag","beginDrag","instanceId","DragDropTile","connect","monitor","dragSource","isDragging"],"mappings":"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","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { DragSource } from '@pie-lib/drag';\nimport { withStyles } from '@material-ui/core/styles';\nimport Chip from '@material-ui/core/Chip';\nimport classnames from 'classnames';\nimport ReactDOM from 'react-dom';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { color } from '@pie-lib/render-ui';\n\nexport const DRAG_TYPE = 'MaskBlank';\n\nclass BlankContentComp extends React.Component {\n static propTypes = {\n disabled: PropTypes.bool,\n choice: PropTypes.object,\n classes: PropTypes.object,\n connectDragSource: PropTypes.func,\n };\n\n componentDidUpdate() {\n renderMath(this.rootRef);\n }\n\n render() {\n const { connectDragSource, choice, classes, disabled } = this.props;\n\n // TODO the Chip element is causing drag problems on touch devices. Avoid using Chip and consider refactoring the code. Keep in mind that Chip is a span with a button role, which interferes with seamless touch device dragging.\n\n return connectDragSource(\n <span className={classnames(classes.choice, disabled && classes.disabled)}>\n <Chip\n clickable={false}\n disabled={true}\n ref={(ref) => {\n //eslint-disable-next-line\n this.rootRef = ReactDOM.findDOMNode(ref);\n }}\n className={classes.chip}\n label={\n <span\n className={classes.chipLabel}\n ref={(ref) => {\n if (ref) {\n ref.innerHTML = choice.value || ' ';\n }\n }}\n >\n {' '}\n </span>\n }\n variant={disabled ? 'outlined' : undefined}\n />\n </span>,\n {},\n );\n }\n}\n\nexport const BlankContent = withStyles((theme) => ({\n choice: {\n border: `solid 0px ${theme.palette.primary.main}`,\n borderRadius: theme.spacing.unit * 2,\n margin: theme.spacing.unit / 2,\n transform: 'translate(0, 0)',\n },\n chip: {\n backgroundColor: color.background(),\n border: `1px solid ${color.text()}`,\n color: color.text(),\n alignItems: 'center',\n display: 'inline-flex',\n height: 'initial',\n minHeight: '32px',\n fontSize: 'inherit',\n whiteSpace: 'pre-wrap',\n maxWidth: '374px',\n // Added for touch devices, for image content.\n // This will prevent the context menu from appearing and not allowing other interactions with the image.\n // If interactions with the image in the token will be requested we should handle only the context Menu.\n pointerEvents: 'none',\n },\n chipLabel: {\n whiteSpace: 'pre-wrap',\n '& img': {\n display: 'block',\n padding: '2px 0',\n },\n },\n disabled: {},\n}))(BlankContentComp);\n\nconst tileSource = {\n canDrag(props) {\n return !props.disabled;\n },\n beginDrag(props) {\n return {\n choice: props.choice,\n instanceId: props.instanceId,\n };\n },\n};\n\nconst DragDropTile = DragSource(DRAG_TYPE, tileSource, (connect, monitor) => ({\n connectDragSource: connect.dragSource(),\n isDragging: monitor.isDragging(),\n}))(BlankContent);\n\nexport default DragDropTile;\n"],"file":"choice.js"}
|
package/lib/choices/index.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = 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
|
-
|
|
22
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
|
-
var _react = _interopRequireDefault(require("react"));
|
|
25
|
-
|
|
26
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
27
|
-
|
|
28
|
-
var _findKey = _interopRequireDefault(require("lodash/findKey"));
|
|
29
|
-
|
|
30
|
-
var _choice = _interopRequireDefault(require("./choice"));
|
|
31
|
-
|
|
32
|
-
var _dragInTheBlankDp = _interopRequireDefault(require("@pie-lib/drag/lib/drag-in-the-blank-dp"));
|
|
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 Choices = /*#__PURE__*/function (_React$Component) {
|
|
39
|
-
(0, _inherits2["default"])(Choices, _React$Component);
|
|
40
|
-
|
|
41
|
-
var _super = _createSuper(Choices);
|
|
42
|
-
|
|
43
|
-
function Choices() {
|
|
44
|
-
var _this;
|
|
45
|
-
|
|
46
|
-
(0, _classCallCheck2["default"])(this, Choices);
|
|
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), "getStyleForWrapper", function () {
|
|
54
|
-
var choicePosition = _this.props.choicePosition;
|
|
55
|
-
|
|
56
|
-
switch (choicePosition) {
|
|
57
|
-
case 'above':
|
|
58
|
-
return {
|
|
59
|
-
margin: '0 0 40px 0'
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
case 'below':
|
|
63
|
-
return {
|
|
64
|
-
margin: '40px 0 0 0'
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
case 'right':
|
|
68
|
-
return {
|
|
69
|
-
margin: '0 0 0 40px'
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
default:
|
|
73
|
-
return {
|
|
74
|
-
margin: '0 40px 0 0'
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
return _this;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
(0, _createClass2["default"])(Choices, [{
|
|
82
|
-
key: "render",
|
|
83
|
-
value: function render() {
|
|
84
|
-
var _this$props = this.props,
|
|
85
|
-
disabled = _this$props.disabled,
|
|
86
|
-
duplicates = _this$props.duplicates,
|
|
87
|
-
choices = _this$props.choices,
|
|
88
|
-
value = _this$props.value;
|
|
89
|
-
var filteredChoices = choices.filter(function (c) {
|
|
90
|
-
if (duplicates === true) {
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
var foundChoice = (0, _findKey["default"])(value, function (v) {
|
|
95
|
-
return v === c.id;
|
|
96
|
-
});
|
|
97
|
-
return foundChoice === undefined;
|
|
98
|
-
});
|
|
99
|
-
var elementStyle = this.getStyleForWrapper();
|
|
100
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
101
|
-
style: elementStyle
|
|
102
|
-
}, /*#__PURE__*/_react["default"].createElement(_dragInTheBlankDp["default"], {
|
|
103
|
-
disabled: disabled
|
|
104
|
-
}, filteredChoices.map(function (c, index) {
|
|
105
|
-
return /*#__PURE__*/_react["default"].createElement(_choice["default"], {
|
|
106
|
-
key: "".concat(c.value, "-").concat(index),
|
|
107
|
-
disabled: disabled,
|
|
108
|
-
choice: c
|
|
109
|
-
});
|
|
110
|
-
})));
|
|
111
|
-
}
|
|
112
|
-
}]);
|
|
113
|
-
return Choices;
|
|
114
|
-
}(_react["default"].Component);
|
|
115
|
-
|
|
116
|
-
exports["default"] = Choices;
|
|
117
|
-
(0, _defineProperty2["default"])(Choices, "propTypes", {
|
|
118
|
-
disabled: _propTypes["default"].bool,
|
|
119
|
-
duplicates: _propTypes["default"].bool,
|
|
120
|
-
choices: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
121
|
-
label: _propTypes["default"].string,
|
|
122
|
-
value: _propTypes["default"].string
|
|
123
|
-
})),
|
|
124
|
-
value: _propTypes["default"].object,
|
|
125
|
-
choicePosition: _propTypes["default"].string.isRequired
|
|
126
|
-
});
|
|
127
|
-
//# sourceMappingURL=index.js.map
|
package/lib/choices/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/choices/index.jsx"],"names":["Choices","choicePosition","props","margin","disabled","duplicates","choices","value","filteredChoices","filter","c","foundChoice","v","id","undefined","elementStyle","getStyleForWrapper","map","index","React","Component","PropTypes","bool","arrayOf","shape","label","string","object","isRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEqBA,O;;;;;;;;;;;;;;;2GASE,YAAM;AACzB,UAAQC,cAAR,GAA2B,MAAKC,KAAhC,CAAQD,cAAR;;AAEA,cAAQA,cAAR;AACE,aAAK,OAAL;AACE,iBAAO;AACLE,YAAAA,MAAM,EAAE;AADH,WAAP;;AAIF,aAAK,OAAL;AACE,iBAAO;AACLA,YAAAA,MAAM,EAAE;AADH,WAAP;;AAIF,aAAK,OAAL;AACE,iBAAO;AACLA,YAAAA,MAAM,EAAE;AADH,WAAP;;AAIF;AACE,iBAAO;AACLA,YAAAA,MAAM,EAAE;AADH,WAAP;AAjBJ;AAqBD,K;;;;;;WAED,kBAAS;AACP,wBAAiD,KAAKD,KAAtD;AAAA,UAAQE,QAAR,eAAQA,QAAR;AAAA,UAAkBC,UAAlB,eAAkBA,UAAlB;AAAA,UAA8BC,OAA9B,eAA8BA,OAA9B;AAAA,UAAuCC,KAAvC,eAAuCA,KAAvC;AACA,UAAMC,eAAe,GAAGF,OAAO,CAACG,MAAR,CAAe,UAACC,CAAD,EAAO;AAC5C,YAAIL,UAAU,KAAK,IAAnB,EAAyB;AACvB,iBAAO,IAAP;AACD;;AACD,YAAMM,WAAW,GAAG,yBAAQJ,KAAR,EAAe,UAACK,CAAD;AAAA,iBAAOA,CAAC,KAAKF,CAAC,CAACG,EAAf;AAAA,SAAf,CAApB;AACA,eAAOF,WAAW,KAAKG,SAAvB;AACD,OANuB,CAAxB;AAOA,UAAMC,YAAY,GAAG,KAAKC,kBAAL,EAArB;AAEA,0BACE;AAAK,QAAA,KAAK,EAAED;AAAZ,sBACE,gCAAC,4BAAD;AAA0B,QAAA,QAAQ,EAAEX;AAApC,SACGI,eAAe,CAACS,GAAhB,CAAoB,UAACP,CAAD,EAAIQ,KAAJ;AAAA,4BACnB,gCAAC,kBAAD;AAAQ,UAAA,GAAG,YAAKR,CAAC,CAACH,KAAP,cAAgBW,KAAhB,CAAX;AAAoC,UAAA,QAAQ,EAAEd,QAA9C;AAAwD,UAAA,MAAM,EAAEM;AAAhE,UADmB;AAAA,OAApB,CADH,CADF,CADF;AASD;;;EAvDkCS,kBAAMC,S;;;iCAAtBpB,O,eACA;AACjBI,EAAAA,QAAQ,EAAEiB,sBAAUC,IADH;AAEjBjB,EAAAA,UAAU,EAAEgB,sBAAUC,IAFL;AAGjBhB,EAAAA,OAAO,EAAEe,sBAAUE,OAAV,CAAkBF,sBAAUG,KAAV,CAAgB;AAAEC,IAAAA,KAAK,EAAEJ,sBAAUK,MAAnB;AAA2BnB,IAAAA,KAAK,EAAEc,sBAAUK;AAA5C,GAAhB,CAAlB,CAHQ;AAIjBnB,EAAAA,KAAK,EAAEc,sBAAUM,MAJA;AAKjB1B,EAAAA,cAAc,EAAEoB,sBAAUK,MAAV,CAAiBE;AALhB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport findKey from 'lodash/findKey';\nimport Choice from './choice';\nimport DragDroppablePlaceholder from '@pie-lib/drag/lib/drag-in-the-blank-dp';\n\nexport default class Choices extends React.Component {\n static propTypes = {\n disabled: PropTypes.bool,\n duplicates: PropTypes.bool,\n choices: PropTypes.arrayOf(PropTypes.shape({ label: PropTypes.string, value: PropTypes.string })),\n value: PropTypes.object,\n choicePosition: PropTypes.string.isRequired,\n };\n\n getStyleForWrapper = () => {\n const { choicePosition } = this.props;\n\n switch (choicePosition) {\n case 'above':\n return {\n margin: '0 0 40px 0',\n };\n\n case 'below':\n return {\n margin: '40px 0 0 0',\n };\n\n case 'right':\n return {\n margin: '0 0 0 40px',\n };\n\n default:\n return {\n margin: '0 40px 0 0',\n };\n }\n };\n\n render() {\n const { disabled, duplicates, choices, value } = this.props;\n const filteredChoices = choices.filter((c) => {\n if (duplicates === true) {\n return true;\n }\n const foundChoice = findKey(value, (v) => v === c.id);\n return foundChoice === undefined;\n });\n const elementStyle = this.getStyleForWrapper();\n\n return (\n <div style={elementStyle}>\n <DragDroppablePlaceholder disabled={disabled}>\n {filteredChoices.map((c, index) => (\n <Choice key={`${c.value}-${index}`} disabled={disabled} choice={c} />\n ))}\n </DragDroppablePlaceholder>\n </div>\n );\n }\n}\n"],"file":"index.js"}
|
package/lib/componentize.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var REGEX = /\{\{(\d+)\}\}/g;
|
|
8
|
-
|
|
9
|
-
var _default = function _default(s, t) {
|
|
10
|
-
if (!s) {
|
|
11
|
-
return {
|
|
12
|
-
markup: ''
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
var markup = s.replace(REGEX, function (match, g) {
|
|
17
|
-
return "<span data-component=\"".concat(t, "\" data-id=\"").concat(g, "\"></span>");
|
|
18
|
-
});
|
|
19
|
-
return {
|
|
20
|
-
markup: markup
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
exports["default"] = _default;
|
|
25
|
-
//# sourceMappingURL=componentize.js.map
|
package/lib/componentize.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/componentize.js"],"names":["REGEX","s","t","markup","replace","match","g"],"mappings":";;;;;;AAAA,IAAMA,KAAK,GAAG,gBAAd;;eAEe,kBAACC,CAAD,EAAIC,CAAJ,EAAU;AACvB,MAAI,CAACD,CAAL,EAAQ;AACN,WAAO;AAAEE,MAAAA,MAAM,EAAE;AAAV,KAAP;AACD;;AAED,MAAMA,MAAM,GAAGF,CAAC,CAACG,OAAF,CAAUJ,KAAV,EAAiB,UAACK,KAAD,EAAQC,CAAR,EAAc;AAC5C,4CAAgCJ,CAAhC,0BAA+CI,CAA/C;AACD,GAFc,CAAf;AAIA,SAAO;AAAEH,IAAAA,MAAM,EAANA;AAAF,GAAP;AACD,C","sourcesContent":["const REGEX = /\\{\\{(\\d+)\\}\\}/g;\n\nexport default (s, t) => {\n if (!s) {\n return { markup: '' };\n }\n\n const markup = s.replace(REGEX, (match, g) => {\n return `<span data-component=\"${t}\" data-id=\"${g}\"></span>`;\n });\n\n return { markup };\n};\n"],"file":"componentize.js"}
|