react-survey-builder 1.0.1
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/LICENSE +7 -0
- package/README.md +236 -0
- package/dist/967.index.js +1 -0
- package/dist/app.css +1 -0
- package/dist/app.css.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.LICENSE.txt +46 -0
- package/lib/ItemTypes.js +10 -0
- package/lib/UUID.js +65 -0
- package/lib/dynamic-option-list.js +188 -0
- package/lib/fieldset/FieldSet.js +118 -0
- package/lib/fieldset/index.js +13 -0
- package/lib/form.js +604 -0
- package/lib/functions/index.js +45 -0
- package/lib/index.js +139 -0
- package/lib/language-provider/IntlMessages.js +15 -0
- package/lib/language-provider/entries/en-us.js +16 -0
- package/lib/language-provider/entries/it-it.js +16 -0
- package/lib/language-provider/entries/vi-vn.js +16 -0
- package/lib/language-provider/index.js +32 -0
- package/lib/language-provider/locales/en-us.json +97 -0
- package/lib/language-provider/locales/it-it.json +92 -0
- package/lib/language-provider/locales/vi-vn.json +82 -0
- package/lib/multi-column/MultiColumnRow.js +134 -0
- package/lib/multi-column/dustbin.js +152 -0
- package/lib/multi-column/grip.js +51 -0
- package/lib/multi-column/index.js +24 -0
- package/lib/preview.js +388 -0
- package/lib/sortable-element.js +177 -0
- package/lib/sortable-form-elements.js +67 -0
- package/lib/stores/registry.js +42 -0
- package/lib/stores/requests.js +31 -0
- package/lib/stores/store.js +138 -0
- package/lib/survey-dynamic-edit.js +54 -0
- package/lib/survey-elements/component-drag-handle.js +90 -0
- package/lib/survey-elements/component-drag-layer.js +68 -0
- package/lib/survey-elements/component-drag-preview.js +57 -0
- package/lib/survey-elements/component-header.js +29 -0
- package/lib/survey-elements/component-label.js +26 -0
- package/lib/survey-elements/custom-element.js +70 -0
- package/lib/survey-elements/date-picker.js +278 -0
- package/lib/survey-elements/header-bar.js +54 -0
- package/lib/survey-elements/index.js +1196 -0
- package/lib/survey-elements/myxss.js +29 -0
- package/lib/survey-elements/star-rating.js +335 -0
- package/lib/survey-elements-edit.js +613 -0
- package/lib/survey-place-holder.js +51 -0
- package/lib/survey-validator.js +103 -0
- package/lib/toolbar-draggable-item.js +59 -0
- package/lib/toolbar-group-item.js +39 -0
- package/lib/toolbar.js +680 -0
- package/lib/utils/custom-date-picker.js +93 -0
- package/package.json +114 -0
- package/types/index.d.ts +180 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
exports["default"] = void 0;
|
8
|
+
var _xss = _interopRequireDefault(require("xss"));
|
9
|
+
var myxss = new _xss["default"].FilterXSS({
|
10
|
+
whiteList: {
|
11
|
+
a: ['href', 'title', 'target'],
|
12
|
+
u: [],
|
13
|
+
br: [],
|
14
|
+
b: [],
|
15
|
+
i: [],
|
16
|
+
ol: ['style'],
|
17
|
+
ul: ['style'],
|
18
|
+
li: [],
|
19
|
+
p: ['style'],
|
20
|
+
sub: [],
|
21
|
+
sup: [],
|
22
|
+
div: ['style'],
|
23
|
+
em: [],
|
24
|
+
strong: [],
|
25
|
+
span: ['style'],
|
26
|
+
ins: []
|
27
|
+
}
|
28
|
+
});
|
29
|
+
var _default = exports["default"] = myxss;
|
@@ -0,0 +1,335 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
exports["default"] = void 0;
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
9
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
10
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
11
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
12
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
13
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
15
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
16
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
17
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
18
|
+
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); }; }
|
19
|
+
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; } }
|
20
|
+
/**
|
21
|
+
* @fileoverview react-star-rating
|
22
|
+
* @author @cameronjroe
|
23
|
+
* <StarRating
|
24
|
+
* name={string} - name for form input (required)
|
25
|
+
* caption={string} - caption for rating (optional)
|
26
|
+
* ratingAmount={number} - the rating amount (required, default: 5)
|
27
|
+
* rating={number} - a set rating between the rating amount (optional)
|
28
|
+
* disabled={boolean} - whether to disable the rating from being selected (optional)
|
29
|
+
* editing={boolean} - whether the rating is explicitly in editing mode (optional)
|
30
|
+
* size={string} - size of stars (optional)
|
31
|
+
* onRatingClick={function} - a handler function that gets called onClick of the rating (optional)
|
32
|
+
* />
|
33
|
+
*/
|
34
|
+
var StarRating = exports["default"] = /*#__PURE__*/function (_React$Component) {
|
35
|
+
(0, _inherits2["default"])(StarRating, _React$Component);
|
36
|
+
var _super = _createSuper(StarRating);
|
37
|
+
function StarRating(props) {
|
38
|
+
var _this;
|
39
|
+
(0, _classCallCheck2["default"])(this, StarRating);
|
40
|
+
_this = _super.call(this, props);
|
41
|
+
_this.min = 0;
|
42
|
+
_this.max = props.ratingAmount || 5;
|
43
|
+
var ratingVal = props.rating;
|
44
|
+
var ratingCache = {
|
45
|
+
pos: ratingVal ? _this.getStarRatingPosition(ratingVal) : 0,
|
46
|
+
rating: props.rating
|
47
|
+
};
|
48
|
+
_this.state = {
|
49
|
+
ratingCache: ratingCache,
|
50
|
+
editing: props.editing || !props.rating,
|
51
|
+
stars: 5,
|
52
|
+
rating: ratingCache.rating,
|
53
|
+
pos: ratingCache.pos,
|
54
|
+
glyph: _this.getStars()
|
55
|
+
};
|
56
|
+
return _this;
|
57
|
+
}
|
58
|
+
|
59
|
+
/**
|
60
|
+
* Gets the stars based on ratingAmount
|
61
|
+
* @return {string} stars
|
62
|
+
*/
|
63
|
+
(0, _createClass2["default"])(StarRating, [{
|
64
|
+
key: "getStars",
|
65
|
+
value: function getStars() {
|
66
|
+
var stars = '';
|
67
|
+
var numRating = this.props.ratingAmount;
|
68
|
+
for (var i = 0; i < numRating; i++) {
|
69
|
+
stars += "\u2605";
|
70
|
+
}
|
71
|
+
return stars;
|
72
|
+
}
|
73
|
+
|
74
|
+
// componentWillMount() {
|
75
|
+
// this.min = 0;
|
76
|
+
// this.max = this.props.ratingAmount || 5;
|
77
|
+
// if (this.props.rating) {
|
78
|
+
// this.state.editing = this.props.editing || false;
|
79
|
+
// const ratingVal = this.props.rating;
|
80
|
+
// this.state.ratingCache.pos = this.getStarRatingPosition(ratingVal);
|
81
|
+
// this.state.ratingCache.rating = ratingVal;
|
82
|
+
|
83
|
+
// this.setState({
|
84
|
+
// ratingCache: this.state.ratingCache,
|
85
|
+
// rating: ratingVal,
|
86
|
+
// pos: this.getStarRatingPosition(ratingVal),
|
87
|
+
// });
|
88
|
+
// }
|
89
|
+
// }
|
90
|
+
}, {
|
91
|
+
key: "componentDidMount",
|
92
|
+
value: function componentDidMount() {
|
93
|
+
this.root = _reactDom["default"].findDOMNode(this.rootNode);
|
94
|
+
this.ratingContainer = _reactDom["default"].findDOMNode(this.node);
|
95
|
+
}
|
96
|
+
}, {
|
97
|
+
key: "componentWillUnmount",
|
98
|
+
value: function componentWillUnmount() {
|
99
|
+
delete this.root;
|
100
|
+
delete this.ratingContainer;
|
101
|
+
}
|
102
|
+
}, {
|
103
|
+
key: "getPosition",
|
104
|
+
value: function getPosition(e) {
|
105
|
+
return e.pageX - this.root.getBoundingClientRect().left;
|
106
|
+
}
|
107
|
+
}, {
|
108
|
+
key: "applyPrecision",
|
109
|
+
value: function applyPrecision(val, precision) {
|
110
|
+
return parseFloat(val.toFixed(precision));
|
111
|
+
}
|
112
|
+
}, {
|
113
|
+
key: "getDecimalPlaces",
|
114
|
+
value: function getDecimalPlaces(num) {
|
115
|
+
var match = "".concat(num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
|
116
|
+
return !match ? 0 : Math.max(0, (match[1] ? match[1].length : 0) - (match[2] ? +match[2] : 0));
|
117
|
+
}
|
118
|
+
}, {
|
119
|
+
key: "getWidthFromValue",
|
120
|
+
value: function getWidthFromValue(val) {
|
121
|
+
var min = this.min;
|
122
|
+
var max = this.max;
|
123
|
+
if (val <= min || min === max) {
|
124
|
+
return 0;
|
125
|
+
}
|
126
|
+
if (val >= max) {
|
127
|
+
return 100;
|
128
|
+
}
|
129
|
+
return val / (max - min) * 100;
|
130
|
+
}
|
131
|
+
}, {
|
132
|
+
key: "getValueFromPosition",
|
133
|
+
value: function getValueFromPosition(pos) {
|
134
|
+
var precision = this.getDecimalPlaces(this.props.step);
|
135
|
+
var maxWidth = this.ratingContainer.offsetWidth;
|
136
|
+
var diff = this.max - this.min;
|
137
|
+
var factor = diff * pos / (maxWidth * this.props.step);
|
138
|
+
factor = Math.ceil(factor);
|
139
|
+
var val = this.applyPrecision(parseFloat(this.min + factor * this.props.step), precision);
|
140
|
+
val = Math.max(Math.min(val, this.max), this.min);
|
141
|
+
return val;
|
142
|
+
}
|
143
|
+
}, {
|
144
|
+
key: "calculate",
|
145
|
+
value: function calculate(pos) {
|
146
|
+
var val = this.getValueFromPosition(pos);
|
147
|
+
var width = this.getWidthFromValue(val);
|
148
|
+
width += '%';
|
149
|
+
return {
|
150
|
+
width: width,
|
151
|
+
val: val
|
152
|
+
};
|
153
|
+
}
|
154
|
+
}, {
|
155
|
+
key: "getStarRatingPosition",
|
156
|
+
value: function getStarRatingPosition(val) {
|
157
|
+
var width = "".concat(this.getWidthFromValue(val), "%");
|
158
|
+
return width;
|
159
|
+
}
|
160
|
+
}, {
|
161
|
+
key: "getRatingEvent",
|
162
|
+
value: function getRatingEvent(e) {
|
163
|
+
var pos = this.getPosition(e);
|
164
|
+
return this.calculate(pos);
|
165
|
+
}
|
166
|
+
}, {
|
167
|
+
key: "getSvg",
|
168
|
+
value: function getSvg() {
|
169
|
+
return /*#__PURE__*/_react["default"].createElement("svg", {
|
170
|
+
className: "react-star-rating__star",
|
171
|
+
viewBox: "0 0 286 272",
|
172
|
+
version: "1.1",
|
173
|
+
xmlns: "http://www.w3.org/2000/svg"
|
174
|
+
}, /*#__PURE__*/_react["default"].createElement("g", {
|
175
|
+
stroke: "none",
|
176
|
+
"stroke-width": "1",
|
177
|
+
fill: "none",
|
178
|
+
"fill-rule": "evenodd"
|
179
|
+
}, /*#__PURE__*/_react["default"].createElement("polygon", {
|
180
|
+
id: "star-flat",
|
181
|
+
points: "143 225 54.8322122 271.352549 71.6707613 173.176275 0.341522556 103.647451 98.9161061 89.3237254 143 0 187.083894 89.3237254 285.658477 103.647451 214.329239 173.176275 231.167788 271.352549 "
|
182
|
+
})));
|
183
|
+
}
|
184
|
+
}, {
|
185
|
+
key: "handleMouseLeave",
|
186
|
+
value: function handleMouseLeave() {
|
187
|
+
this.setState({
|
188
|
+
pos: this.state.ratingCache.pos,
|
189
|
+
rating: this.state.ratingCache.rating
|
190
|
+
});
|
191
|
+
}
|
192
|
+
}, {
|
193
|
+
key: "handleMouseMove",
|
194
|
+
value: function handleMouseMove(e) {
|
195
|
+
// get hover position
|
196
|
+
var ratingEvent = this.getRatingEvent(e);
|
197
|
+
this.updateRating(ratingEvent.width, ratingEvent.val);
|
198
|
+
}
|
199
|
+
}, {
|
200
|
+
key: "updateRating",
|
201
|
+
value: function updateRating(width, val) {
|
202
|
+
this.setState({
|
203
|
+
pos: width,
|
204
|
+
rating: val
|
205
|
+
});
|
206
|
+
}
|
207
|
+
}, {
|
208
|
+
key: "shouldComponentUpdate",
|
209
|
+
value: function shouldComponentUpdate(nextProps, nextState) {
|
210
|
+
if (nextProps !== this.props) {
|
211
|
+
this.updateRating(this.getStarRatingPosition(nextProps.rating), nextProps.rating);
|
212
|
+
return true;
|
213
|
+
}
|
214
|
+
return nextState.ratingCache.rating !== this.state.ratingCache.rating || nextState.rating !== this.state.rating;
|
215
|
+
}
|
216
|
+
}, {
|
217
|
+
key: "handleClick",
|
218
|
+
value: function handleClick(e) {
|
219
|
+
// is it disabled?
|
220
|
+
if (this.props.disabled) {
|
221
|
+
e.stopPropagation();
|
222
|
+
e.preventDefault();
|
223
|
+
return false;
|
224
|
+
}
|
225
|
+
var ratingCache = {
|
226
|
+
pos: this.state.pos,
|
227
|
+
rating: this.state.rating,
|
228
|
+
caption: this.props.caption,
|
229
|
+
name: this.props.name
|
230
|
+
};
|
231
|
+
this.setState({
|
232
|
+
ratingCache: ratingCache
|
233
|
+
});
|
234
|
+
this.props.onRatingClick(e, ratingCache);
|
235
|
+
return true;
|
236
|
+
}
|
237
|
+
}, {
|
238
|
+
key: "treatName",
|
239
|
+
value: function treatName(title) {
|
240
|
+
if (typeof title === 'string') {
|
241
|
+
return title.toLowerCase().split(' ').join('_');
|
242
|
+
}
|
243
|
+
return null;
|
244
|
+
}
|
245
|
+
}, {
|
246
|
+
key: "render",
|
247
|
+
value: function render() {
|
248
|
+
var _this2 = this;
|
249
|
+
// let caption = null;
|
250
|
+
var classes = (0, _classnames["default"])((0, _defineProperty2["default"])((0, _defineProperty2["default"])({
|
251
|
+
'react-star-rating__root': true,
|
252
|
+
'rating-disabled': this.props.disabled
|
253
|
+
}, "react-star-rating__size--".concat(this.props.size), this.props.size), 'rating-editing', this.state.editing));
|
254
|
+
|
255
|
+
// is there a caption?
|
256
|
+
// if (this.props.caption) {
|
257
|
+
// caption = (<span className="react-rating-caption">{this.props.caption}</span>);
|
258
|
+
// }
|
259
|
+
|
260
|
+
// are we editing this rating?
|
261
|
+
var starRating;
|
262
|
+
if (this.state.editing) {
|
263
|
+
starRating = /*#__PURE__*/_react["default"].createElement("div", {
|
264
|
+
ref: function ref(c) {
|
265
|
+
return _this2.node = c;
|
266
|
+
},
|
267
|
+
className: "rating-container rating-gly-star",
|
268
|
+
"data-content": this.state.glyph,
|
269
|
+
onMouseMove: this.handleMouseMove.bind(this),
|
270
|
+
onMouseLeave: this.handleMouseLeave.bind(this),
|
271
|
+
onClick: this.handleClick.bind(this)
|
272
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
273
|
+
className: "rating-stars",
|
274
|
+
"data-content": this.state.glyph,
|
275
|
+
style: {
|
276
|
+
width: this.state.pos
|
277
|
+
}
|
278
|
+
}));
|
279
|
+
} else {
|
280
|
+
starRating = /*#__PURE__*/_react["default"].createElement("div", {
|
281
|
+
ref: function ref(c) {
|
282
|
+
return _this2.node = c;
|
283
|
+
},
|
284
|
+
className: "rating-container rating-gly-star",
|
285
|
+
"data-content": this.state.glyph
|
286
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
287
|
+
className: "rating-stars",
|
288
|
+
"data-content": this.state.glyph,
|
289
|
+
style: {
|
290
|
+
width: this.state.pos
|
291
|
+
}
|
292
|
+
}));
|
293
|
+
}
|
294
|
+
return /*#__PURE__*/_react["default"].createElement("span", {
|
295
|
+
className: "react-star-rating"
|
296
|
+
}, /*#__PURE__*/_react["default"].createElement("span", {
|
297
|
+
ref: function ref(c) {
|
298
|
+
return _this2.rootNode = c;
|
299
|
+
},
|
300
|
+
style: {
|
301
|
+
cursor: 'pointer'
|
302
|
+
},
|
303
|
+
className: classes
|
304
|
+
}, starRating, /*#__PURE__*/_react["default"].createElement("input", {
|
305
|
+
type: "hidden",
|
306
|
+
name: this.props.name,
|
307
|
+
value: this.state.ratingCache.rating,
|
308
|
+
style: {
|
309
|
+
display: 'none !important',
|
310
|
+
width: 65
|
311
|
+
},
|
312
|
+
min: this.min,
|
313
|
+
max: this.max,
|
314
|
+
readOnly: true
|
315
|
+
})));
|
316
|
+
}
|
317
|
+
}]);
|
318
|
+
return StarRating;
|
319
|
+
}(_react["default"].Component);
|
320
|
+
StarRating.propTypes = {
|
321
|
+
name: _propTypes["default"].string.isRequired,
|
322
|
+
caption: _propTypes["default"].string,
|
323
|
+
ratingAmount: _propTypes["default"].number.isRequired,
|
324
|
+
rating: _propTypes["default"].number,
|
325
|
+
onRatingClick: _propTypes["default"].func,
|
326
|
+
disabled: _propTypes["default"].bool,
|
327
|
+
editing: _propTypes["default"].bool,
|
328
|
+
size: _propTypes["default"].string
|
329
|
+
};
|
330
|
+
StarRating.defaultProps = {
|
331
|
+
step: 0.5,
|
332
|
+
ratingAmount: 5,
|
333
|
+
onRatingClick: function onRatingClick() {},
|
334
|
+
disabled: false
|
335
|
+
};
|