@tsed/react-formio 2.3.0 → 2.3.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/coverage.json +4 -4
- package/dist/components/actions-table/actionsTable.stories.d.ts +8 -53
- package/dist/components/form-access/formAccess.component.d.ts +2 -13
- package/dist/components/form-access/formAccess.stories.d.ts +3 -44
- package/dist/components/form-control/formControl.component.d.ts +3 -11
- package/dist/components/select/select.component.d.ts +5 -18
- package/dist/components/table/components/defaultCellOperations.component.d.ts +12 -1
- package/dist/components/table/components/defaultOperationButton.component.d.ts +4 -4
- package/dist/components/table/hooks/useOperations.hook.d.ts +2 -2
- package/dist/index.js +1113 -1265
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +226 -244
- package/dist/index.modern.js.map +1 -1
- package/package.json +13 -6
- package/src/components/__fixtures__/form-actions.json +240 -0
- package/src/components/actions-table/__fixtures__/data.json +12 -0
- package/src/components/actions-table/actionsTable.component.spec.tsx +42 -11
- package/src/components/actions-table/actionsTable.component.tsx +2 -1
- package/src/components/actions-table/actionsTable.stories.tsx +71 -289
- package/src/components/form-access/formAccess.component.tsx +2 -12
- package/src/components/form-access/formAccess.stories.tsx +55 -49
- package/src/components/form-control/formControl.component.tsx +4 -11
- package/src/components/select/select.component.tsx +9 -22
- package/src/components/table/components/defaultCellOperations.component.tsx +17 -4
- package/src/components/table/components/defaultOperationButton.component.tsx +9 -4
- package/src/components/table/hooks/useOperations.hook.tsx +3 -3
package/dist/index.js
CHANGED
|
@@ -4,13 +4,13 @@ var Wizard = require('formiojs/Wizard');
|
|
|
4
4
|
var WizardBuilder = require('formiojs/WizardBuilder');
|
|
5
5
|
var classnames = require('classnames');
|
|
6
6
|
var noop = require('lodash/noop');
|
|
7
|
-
var React = require('react');
|
|
7
|
+
var React$1 = require('react');
|
|
8
8
|
var formiojs = require('formiojs');
|
|
9
9
|
var Choices = require('@formio/choices.js');
|
|
10
|
-
var PropTypes = require('prop-types');
|
|
11
10
|
var reactDnd = require('react-dnd');
|
|
12
11
|
var reactDndHtml5Backend = require('react-dnd-html5-backend');
|
|
13
12
|
var reactTable = require('react-table');
|
|
13
|
+
var PropTypes = require('prop-types');
|
|
14
14
|
var AllComponents = require('formiojs/components');
|
|
15
15
|
var cloneDeep = require('lodash/cloneDeep');
|
|
16
16
|
var isEqual = require('lodash/isEqual');
|
|
@@ -31,7 +31,7 @@ var Wizard__default = /*#__PURE__*/_interopDefaultLegacy(Wizard);
|
|
|
31
31
|
var WizardBuilder__default = /*#__PURE__*/_interopDefaultLegacy(WizardBuilder);
|
|
32
32
|
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
33
33
|
var noop__default = /*#__PURE__*/_interopDefaultLegacy(noop);
|
|
34
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
34
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React$1);
|
|
35
35
|
var Choices__default = /*#__PURE__*/_interopDefaultLegacy(Choices);
|
|
36
36
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
37
37
|
var AllComponents__default = /*#__PURE__*/_interopDefaultLegacy(AllComponents);
|
|
@@ -46,23 +46,6 @@ var camelCase__default = /*#__PURE__*/_interopDefaultLegacy(camelCase);
|
|
|
46
46
|
var noop__default$1 = /*#__PURE__*/_interopDefaultLegacy(noop$1);
|
|
47
47
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
48
48
|
|
|
49
|
-
function _defineProperties(target, props) {
|
|
50
|
-
for (var i = 0; i < props.length; i++) {
|
|
51
|
-
var descriptor = props[i];
|
|
52
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
53
|
-
descriptor.configurable = true;
|
|
54
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
55
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
59
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
60
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
61
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
62
|
-
writable: false
|
|
63
|
-
});
|
|
64
|
-
return Constructor;
|
|
65
|
-
}
|
|
66
49
|
function _extends() {
|
|
67
50
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
68
51
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -77,18 +60,6 @@ function _extends() {
|
|
|
77
60
|
};
|
|
78
61
|
return _extends.apply(this, arguments);
|
|
79
62
|
}
|
|
80
|
-
function _inheritsLoose(subClass, superClass) {
|
|
81
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
82
|
-
subClass.prototype.constructor = subClass;
|
|
83
|
-
_setPrototypeOf(subClass, superClass);
|
|
84
|
-
}
|
|
85
|
-
function _setPrototypeOf(o, p) {
|
|
86
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
87
|
-
o.__proto__ = p;
|
|
88
|
-
return o;
|
|
89
|
-
};
|
|
90
|
-
return _setPrototypeOf(o, p);
|
|
91
|
-
}
|
|
92
63
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
93
64
|
if (source == null) return {};
|
|
94
65
|
var target = {};
|
|
@@ -101,44 +72,32 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
101
72
|
}
|
|
102
73
|
return target;
|
|
103
74
|
}
|
|
104
|
-
function _toPrimitive(input, hint) {
|
|
105
|
-
if (typeof input !== "object" || input === null) return input;
|
|
106
|
-
var prim = input[Symbol.toPrimitive];
|
|
107
|
-
if (prim !== undefined) {
|
|
108
|
-
var res = prim.call(input, hint || "default");
|
|
109
|
-
if (typeof res !== "object") return res;
|
|
110
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
111
|
-
}
|
|
112
|
-
return (hint === "string" ? String : Number)(input);
|
|
113
|
-
}
|
|
114
|
-
function _toPropertyKey(arg) {
|
|
115
|
-
var key = _toPrimitive(arg, "string");
|
|
116
|
-
return typeof key === "symbol" ? key : String(key);
|
|
117
|
-
}
|
|
118
75
|
|
|
119
76
|
function iconClass(iconset, name, spinning) {
|
|
120
77
|
return formiojs.Templates.current.iconClass(iconset || formiojs.Templates.current.defaultIconset, name, spinning);
|
|
121
78
|
}
|
|
122
79
|
|
|
123
80
|
function getEventValue(event) {
|
|
124
|
-
|
|
81
|
+
const {
|
|
82
|
+
target
|
|
83
|
+
} = event;
|
|
125
84
|
if (event.target.multiple && event.target.selectedOptions) {
|
|
126
|
-
return Array.from(event.target.selectedOptions,
|
|
127
|
-
return option.value;
|
|
128
|
-
});
|
|
85
|
+
return Array.from(event.target.selectedOptions, option => option.value);
|
|
129
86
|
}
|
|
130
87
|
return target.type === "checkbox" ? target.checked : target.value;
|
|
131
88
|
}
|
|
132
89
|
|
|
133
90
|
function FormControl(_ref) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
91
|
+
let {
|
|
92
|
+
children,
|
|
93
|
+
name,
|
|
94
|
+
required,
|
|
95
|
+
prefix,
|
|
96
|
+
suffix,
|
|
97
|
+
description,
|
|
98
|
+
label,
|
|
99
|
+
className
|
|
100
|
+
} = _ref;
|
|
142
101
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
143
102
|
"data-testid": name && "form-group-" + name,
|
|
144
103
|
id: "form-group-" + (name || ""),
|
|
@@ -164,47 +123,42 @@ function FormControl(_ref) {
|
|
|
164
123
|
className: "form-text text-muted"
|
|
165
124
|
}, description));
|
|
166
125
|
}
|
|
167
|
-
FormControl.propTypes = {
|
|
168
|
-
label: PropTypes__default["default"].string,
|
|
169
|
-
name: PropTypes__default["default"].string.isRequired,
|
|
170
|
-
children: PropTypes__default["default"].any,
|
|
171
|
-
required: PropTypes__default["default"].bool,
|
|
172
|
-
description: PropTypes__default["default"].any
|
|
173
|
-
};
|
|
174
126
|
|
|
175
|
-
|
|
127
|
+
const _excluded$g = ["name", "label", "size", "onChange", "required", "value", "choices", "description", "placeholder", "prefix", "suffix", "multiple", "layout"];
|
|
176
128
|
function Select(_ref) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
129
|
+
let {
|
|
130
|
+
name,
|
|
131
|
+
label,
|
|
132
|
+
size,
|
|
133
|
+
onChange,
|
|
134
|
+
required,
|
|
135
|
+
value,
|
|
136
|
+
choices,
|
|
137
|
+
description,
|
|
138
|
+
placeholder,
|
|
139
|
+
prefix,
|
|
140
|
+
suffix,
|
|
141
|
+
multiple,
|
|
142
|
+
layout
|
|
143
|
+
} = _ref,
|
|
144
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$g);
|
|
145
|
+
const ref = React$1.useRef(null);
|
|
146
|
+
React$1.useEffect(() => {
|
|
147
|
+
let instance;
|
|
194
148
|
if (layout === "choicesjs") {
|
|
195
149
|
instance = new Choices__default["default"](ref.current, {
|
|
196
150
|
removeItemButton: true,
|
|
197
151
|
placeholderValue: placeholder
|
|
198
152
|
});
|
|
199
153
|
}
|
|
200
|
-
return
|
|
154
|
+
return () => {
|
|
201
155
|
instance && instance.destroy();
|
|
202
156
|
};
|
|
203
157
|
}, []);
|
|
204
158
|
choices = layout === "choicesjs" || multiple || !placeholder ? choices : [{
|
|
205
159
|
label: placeholder,
|
|
206
160
|
value: ""
|
|
207
|
-
}]
|
|
161
|
+
}, ...choices];
|
|
208
162
|
return /*#__PURE__*/React__default["default"].createElement(FormControl, {
|
|
209
163
|
name: name,
|
|
210
164
|
label: label,
|
|
@@ -214,21 +168,23 @@ function Select(_ref) {
|
|
|
214
168
|
suffix: suffix,
|
|
215
169
|
shadow: false
|
|
216
170
|
}, /*#__PURE__*/React__default["default"].createElement("select", _extends({
|
|
217
|
-
ref: ref
|
|
171
|
+
ref: ref,
|
|
172
|
+
"data-testid": "select_" + name
|
|
218
173
|
}, props, {
|
|
219
|
-
"data-testid": "select_" + name,
|
|
220
174
|
className: classnames__default["default"]("form-control", size && "form-control-" + size),
|
|
221
175
|
name: name,
|
|
222
176
|
id: name,
|
|
223
177
|
multiple: multiple,
|
|
224
178
|
value: value || "",
|
|
225
179
|
placeholder: placeholder,
|
|
226
|
-
onChange:
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
}), choices.map(
|
|
230
|
-
|
|
231
|
-
|
|
180
|
+
onChange: event => {
|
|
181
|
+
onChange && onChange(name, getEventValue(event));
|
|
182
|
+
}
|
|
183
|
+
}), choices.map(_ref2 => {
|
|
184
|
+
let {
|
|
185
|
+
label,
|
|
186
|
+
value
|
|
187
|
+
} = _ref2;
|
|
232
188
|
return /*#__PURE__*/React__default["default"].createElement("option", {
|
|
233
189
|
key: String(value),
|
|
234
190
|
label: label,
|
|
@@ -236,31 +192,25 @@ function Select(_ref) {
|
|
|
236
192
|
}, label);
|
|
237
193
|
})));
|
|
238
194
|
}
|
|
239
|
-
Select.propTypes = {
|
|
240
|
-
label: PropTypes__default["default"].string,
|
|
241
|
-
name: PropTypes__default["default"].string.isRequired,
|
|
242
|
-
value: PropTypes__default["default"].any,
|
|
243
|
-
required: PropTypes__default["default"].bool,
|
|
244
|
-
onChange: PropTypes__default["default"].func,
|
|
245
|
-
choices: PropTypes__default["default"].array.isRequired
|
|
246
|
-
};
|
|
247
195
|
|
|
248
196
|
function DrapNDropContainer(_ref) {
|
|
249
|
-
|
|
250
|
-
|
|
197
|
+
let {
|
|
198
|
+
enableDragNDrop,
|
|
199
|
+
children
|
|
200
|
+
} = _ref;
|
|
251
201
|
return enableDragNDrop ? /*#__PURE__*/React__default["default"].createElement(reactDnd.DndProvider, {
|
|
252
202
|
backend: reactDndHtml5Backend.HTML5Backend
|
|
253
203
|
}, children) : /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, children);
|
|
254
204
|
}
|
|
255
205
|
|
|
256
|
-
|
|
257
|
-
|
|
206
|
+
const LEFT_PAGE = "LEFT";
|
|
207
|
+
const RIGHT_PAGE = "RIGHT";
|
|
258
208
|
function range(from, to, step) {
|
|
259
209
|
if (step === void 0) {
|
|
260
210
|
step = 1;
|
|
261
211
|
}
|
|
262
|
-
|
|
263
|
-
|
|
212
|
+
let i = from;
|
|
213
|
+
const range = [];
|
|
264
214
|
while (i <= to) {
|
|
265
215
|
range.push(i);
|
|
266
216
|
i += step;
|
|
@@ -268,44 +218,46 @@ function range(from, to, step) {
|
|
|
268
218
|
return range;
|
|
269
219
|
}
|
|
270
220
|
function getPageNumbers(_ref) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
pageNeighbours =
|
|
274
|
-
totalPages
|
|
275
|
-
|
|
276
|
-
|
|
221
|
+
let {
|
|
222
|
+
currentPage,
|
|
223
|
+
pageNeighbours = 1,
|
|
224
|
+
totalPages
|
|
225
|
+
} = _ref;
|
|
226
|
+
const totalNumbers = pageNeighbours * 2 + 3;
|
|
227
|
+
const totalBlocks = totalNumbers + 2;
|
|
277
228
|
if (totalPages > totalBlocks) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
229
|
+
const calculatedStartPage = Math.max(2, currentPage - pageNeighbours);
|
|
230
|
+
const calculatedEndPage = Math.min(totalPages - 1, currentPage + pageNeighbours);
|
|
231
|
+
const startPage = calculatedStartPage === 3 ? 2 : calculatedStartPage;
|
|
232
|
+
const endPage = calculatedEndPage === totalPages - 2 ? totalPages - 1 : calculatedEndPage;
|
|
233
|
+
let pages = range(startPage, endPage);
|
|
234
|
+
const hasLeftSpill = startPage > 2;
|
|
235
|
+
const hasRightSpill = totalPages - endPage > 1;
|
|
236
|
+
const spillOffset = totalNumbers - (pages.length + 1);
|
|
237
|
+
let extraPages;
|
|
287
238
|
if (hasLeftSpill && !hasRightSpill) {
|
|
288
239
|
extraPages = range(startPage - spillOffset, startPage - 1);
|
|
289
|
-
pages = [LEFT_PAGE
|
|
240
|
+
pages = [LEFT_PAGE, ...extraPages, ...pages];
|
|
290
241
|
} else if (!hasLeftSpill && hasRightSpill) {
|
|
291
242
|
extraPages = range(endPage + 1, endPage + spillOffset);
|
|
292
|
-
pages = [
|
|
243
|
+
pages = [...pages, ...extraPages, RIGHT_PAGE];
|
|
293
244
|
} else {
|
|
294
|
-
pages = [LEFT_PAGE
|
|
245
|
+
pages = [LEFT_PAGE, ...pages, RIGHT_PAGE];
|
|
295
246
|
}
|
|
296
|
-
return [1
|
|
247
|
+
return [1, ...pages, totalPages];
|
|
297
248
|
}
|
|
298
249
|
return range(1, totalPages);
|
|
299
250
|
}
|
|
300
251
|
|
|
301
|
-
|
|
252
|
+
const _excluded$f = ["component", "children", "disabled", "active"];
|
|
302
253
|
function PaginationButton(props) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
254
|
+
const {
|
|
255
|
+
component: Component = "button",
|
|
256
|
+
children,
|
|
257
|
+
disabled,
|
|
258
|
+
active
|
|
259
|
+
} = props,
|
|
260
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$f);
|
|
309
261
|
return /*#__PURE__*/React__default["default"].createElement(Component, _extends({}, otherProps, {
|
|
310
262
|
"data-testid": "pagination-button",
|
|
311
263
|
disabled: disabled,
|
|
@@ -313,36 +265,31 @@ function PaginationButton(props) {
|
|
|
313
265
|
}), children);
|
|
314
266
|
}
|
|
315
267
|
function Pagination(props) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
pageSizes =
|
|
319
|
-
gotoPage
|
|
320
|
-
canPreviousPage
|
|
321
|
-
previousPage
|
|
322
|
-
nextPage
|
|
323
|
-
canNextPage
|
|
324
|
-
pageCount
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
return f;
|
|
334
|
-
} : _props$i18n;
|
|
335
|
-
var pageNumbers = getPageNumbers({
|
|
268
|
+
const {
|
|
269
|
+
className,
|
|
270
|
+
pageSizes = [10, 25, 50, 100],
|
|
271
|
+
gotoPage,
|
|
272
|
+
canPreviousPage,
|
|
273
|
+
previousPage,
|
|
274
|
+
nextPage,
|
|
275
|
+
canNextPage,
|
|
276
|
+
pageCount,
|
|
277
|
+
pageIndex = 1,
|
|
278
|
+
pageOptions,
|
|
279
|
+
pageSize,
|
|
280
|
+
setPageSize,
|
|
281
|
+
totalLength,
|
|
282
|
+
i18n = f => f
|
|
283
|
+
} = props;
|
|
284
|
+
const pageNumbers = getPageNumbers({
|
|
336
285
|
currentPage: pageIndex,
|
|
337
286
|
// pageNeighbours,
|
|
338
287
|
totalPages: pageCount
|
|
339
288
|
});
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
};
|
|
345
|
-
});
|
|
289
|
+
const choices = pageSizes.map(value => ({
|
|
290
|
+
value,
|
|
291
|
+
label: value
|
|
292
|
+
}));
|
|
346
293
|
return /*#__PURE__*/React__default["default"].createElement("nav", {
|
|
347
294
|
"aria-label": "Page navigation",
|
|
348
295
|
className: classnames__default["default"]("pagination-group -mb-3", className)
|
|
@@ -353,10 +300,8 @@ function Pagination(props) {
|
|
|
353
300
|
}, /*#__PURE__*/React__default["default"].createElement(PaginationButton, {
|
|
354
301
|
tabIndex: -1,
|
|
355
302
|
disabled: !canPreviousPage,
|
|
356
|
-
onClick:
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
}, i18n("Previous"))), pageNumbers.map(function (page) {
|
|
303
|
+
onClick: () => previousPage()
|
|
304
|
+
}, i18n("Previous"))), pageNumbers.map(page => {
|
|
360
305
|
if ([LEFT_PAGE, RIGHT_PAGE].includes(page)) {
|
|
361
306
|
return /*#__PURE__*/React__default["default"].createElement("li", {
|
|
362
307
|
className: "page-item",
|
|
@@ -365,32 +310,28 @@ function Pagination(props) {
|
|
|
365
310
|
"aria-hidden": "true"
|
|
366
311
|
}, "..."));
|
|
367
312
|
}
|
|
368
|
-
|
|
313
|
+
const active = page - 1 === pageIndex;
|
|
369
314
|
return /*#__PURE__*/React__default["default"].createElement("li", {
|
|
370
315
|
className: classnames__default["default"]("page-item", active && "active"),
|
|
371
316
|
key: page
|
|
372
317
|
}, /*#__PURE__*/React__default["default"].createElement(PaginationButton, {
|
|
373
318
|
tabIndex: pageIndex,
|
|
374
319
|
active: active,
|
|
375
|
-
onClick:
|
|
376
|
-
return gotoPage(page - 1);
|
|
377
|
-
}
|
|
320
|
+
onClick: () => gotoPage(page - 1)
|
|
378
321
|
}, page));
|
|
379
322
|
}), /*#__PURE__*/React__default["default"].createElement("li", {
|
|
380
323
|
className: classnames__default["default"]("page-item", !canNextPage && "disabled")
|
|
381
324
|
}, /*#__PURE__*/React__default["default"].createElement(PaginationButton, {
|
|
382
325
|
tabIndex: pageNumbers.length,
|
|
383
326
|
disabled: !canNextPage,
|
|
384
|
-
onClick:
|
|
385
|
-
return nextPage();
|
|
386
|
-
}
|
|
327
|
+
onClick: () => nextPage()
|
|
387
328
|
}, i18n("Next")))), /*#__PURE__*/React__default["default"].createElement("li", {
|
|
388
329
|
className: "mb-3 mr-3 flex items-center"
|
|
389
330
|
}, /*#__PURE__*/React__default["default"].createElement(Select, {
|
|
390
331
|
name: "page",
|
|
391
332
|
value: pageSize,
|
|
392
333
|
choices: choices,
|
|
393
|
-
onChange:
|
|
334
|
+
onChange: (name, value) => {
|
|
394
335
|
setPageSize(+value);
|
|
395
336
|
}
|
|
396
337
|
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
@@ -406,9 +347,13 @@ function Pagination(props) {
|
|
|
406
347
|
}
|
|
407
348
|
|
|
408
349
|
function DefaultArrowSort(_ref) {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
350
|
+
let {
|
|
351
|
+
column
|
|
352
|
+
} = _ref;
|
|
353
|
+
const {
|
|
354
|
+
isSorted,
|
|
355
|
+
isSortedDesc
|
|
356
|
+
} = column;
|
|
412
357
|
return /*#__PURE__*/React__default["default"].createElement("span", {
|
|
413
358
|
className: "table-arrow-sort"
|
|
414
359
|
}, isSorted ? /*#__PURE__*/React__default["default"].createElement("i", {
|
|
@@ -417,7 +362,9 @@ function DefaultArrowSort(_ref) {
|
|
|
417
362
|
}
|
|
418
363
|
|
|
419
364
|
function DefaultCellHeader(_ref) {
|
|
420
|
-
|
|
365
|
+
let {
|
|
366
|
+
column
|
|
367
|
+
} = _ref;
|
|
421
368
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
422
369
|
className: "table-cell-header"
|
|
423
370
|
}, /*#__PURE__*/React__default["default"].createElement("div", _extends({
|
|
@@ -427,95 +374,94 @@ function DefaultCellHeader(_ref) {
|
|
|
427
374
|
}, column.render("Filter")) : null);
|
|
428
375
|
}
|
|
429
376
|
|
|
430
|
-
|
|
431
|
-
|
|
377
|
+
const _excluded$e = ["onDrag", "onDrop", "index"];
|
|
378
|
+
const DND_ITEM_TYPE = "row";
|
|
432
379
|
function useDndRow(_ref) {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
var hoverIndex = index;
|
|
450
|
-
// Don't replace items with themselves
|
|
451
|
-
if (dragIndex === hoverIndex) {
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
// Determine rectangle on screen
|
|
455
|
-
var hoverBoundingRect = dropRef.current.getBoundingClientRect();
|
|
456
|
-
// Get vertical middle
|
|
457
|
-
var hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;
|
|
458
|
-
// Determine mouse position
|
|
459
|
-
var clientOffset = monitor.getClientOffset();
|
|
460
|
-
if (!clientOffset) {
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
// Get pixels to the top
|
|
464
|
-
var hoverClientY = clientOffset.y - hoverBoundingRect.top;
|
|
465
|
-
// Only perform the move when the mouse has crossed half of the items height
|
|
466
|
-
// When dragging downwards, only move when the cursor is below 50%
|
|
467
|
-
// When dragging upwards, only move when the cursor is above 50%
|
|
468
|
-
// Dragging downwards
|
|
469
|
-
if (dragIndex < hoverIndex && hoverClientY < hoverMiddleY) {
|
|
470
|
-
return;
|
|
471
|
-
}
|
|
472
|
-
// Dragging upwards
|
|
473
|
-
if (dragIndex > hoverIndex && hoverClientY > hoverMiddleY) {
|
|
474
|
-
return;
|
|
475
|
-
}
|
|
476
|
-
// Time to actually perform the action
|
|
477
|
-
onDrag(dragIndex, hoverIndex);
|
|
478
|
-
// Note: we're mutating the monitor item here!
|
|
479
|
-
// Generally it's better to avoid mutations,
|
|
480
|
-
// but it's good here for the sake of performance
|
|
481
|
-
// to avoid expensive index searches.
|
|
482
|
-
item.index = hoverIndex;
|
|
380
|
+
let {
|
|
381
|
+
onDrag,
|
|
382
|
+
onDrop,
|
|
383
|
+
index
|
|
384
|
+
} = _ref,
|
|
385
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$e);
|
|
386
|
+
const dropRef = React$1.useRef(null);
|
|
387
|
+
const dragRef = React$1.useRef(null);
|
|
388
|
+
const [, drop] = reactDnd.useDrop({
|
|
389
|
+
accept: DND_ITEM_TYPE,
|
|
390
|
+
drop(item) {
|
|
391
|
+
onDrop(item);
|
|
392
|
+
},
|
|
393
|
+
hover(item, monitor) {
|
|
394
|
+
if (!dropRef.current) {
|
|
395
|
+
return;
|
|
483
396
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
397
|
+
const dragIndex = item.index;
|
|
398
|
+
const hoverIndex = index;
|
|
399
|
+
// Don't replace items with themselves
|
|
400
|
+
if (dragIndex === hoverIndex) {
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
// Determine rectangle on screen
|
|
404
|
+
const hoverBoundingRect = dropRef.current.getBoundingClientRect();
|
|
405
|
+
// Get vertical middle
|
|
406
|
+
const hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;
|
|
407
|
+
// Determine mouse position
|
|
408
|
+
const clientOffset = monitor.getClientOffset();
|
|
409
|
+
if (!clientOffset) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
// Get pixels to the top
|
|
413
|
+
const hoverClientY = clientOffset.y - hoverBoundingRect.top;
|
|
414
|
+
// Only perform the move when the mouse has crossed half of the items height
|
|
415
|
+
// When dragging downwards, only move when the cursor is below 50%
|
|
416
|
+
// When dragging upwards, only move when the cursor is above 50%
|
|
417
|
+
// Dragging downwards
|
|
418
|
+
if (dragIndex < hoverIndex && hoverClientY < hoverMiddleY) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
// Dragging upwards
|
|
422
|
+
if (dragIndex > hoverIndex && hoverClientY > hoverMiddleY) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
// Time to actually perform the action
|
|
426
|
+
onDrag(dragIndex, hoverIndex);
|
|
427
|
+
// Note: we're mutating the monitor item here!
|
|
428
|
+
// Generally it's better to avoid mutations,
|
|
429
|
+
// but it's good here for the sake of performance
|
|
430
|
+
// to avoid expensive index searches.
|
|
431
|
+
item.index = hoverIndex;
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
const [{
|
|
435
|
+
isDragging
|
|
436
|
+
}, drag, preview] = reactDnd.useDrag(() => ({
|
|
437
|
+
type: DND_ITEM_TYPE,
|
|
438
|
+
item: {
|
|
439
|
+
index
|
|
440
|
+
},
|
|
441
|
+
collect: monitor => ({
|
|
442
|
+
isDragging: monitor.isDragging()
|
|
443
|
+
})
|
|
444
|
+
}));
|
|
445
|
+
const opacity = isDragging ? 0 : 1;
|
|
503
446
|
preview(drop(dropRef));
|
|
504
447
|
drag(dragRef);
|
|
505
448
|
return _extends({}, props, {
|
|
506
|
-
opacity
|
|
507
|
-
isDragging
|
|
508
|
-
dropRef
|
|
509
|
-
dragRef
|
|
449
|
+
opacity,
|
|
450
|
+
isDragging,
|
|
451
|
+
dropRef,
|
|
452
|
+
dragRef
|
|
510
453
|
});
|
|
511
454
|
}
|
|
512
455
|
|
|
513
456
|
function DefaultCells(_ref) {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
457
|
+
let {
|
|
458
|
+
row
|
|
459
|
+
} = _ref;
|
|
460
|
+
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, row.cells.map((cell, i) => {
|
|
461
|
+
const {
|
|
462
|
+
hidden,
|
|
463
|
+
colspan
|
|
464
|
+
} = cell.column;
|
|
519
465
|
if (hidden) {
|
|
520
466
|
return null;
|
|
521
467
|
}
|
|
@@ -530,17 +476,18 @@ function DefaultCells(_ref) {
|
|
|
530
476
|
}));
|
|
531
477
|
}
|
|
532
478
|
|
|
533
|
-
|
|
479
|
+
const _excluded$d = ["onClick", "row", "enableDragNDrop", "onDrop", "onDrag"];
|
|
534
480
|
function DefaultDndRow(props) {
|
|
535
|
-
|
|
536
|
-
isDragging
|
|
537
|
-
dragRef
|
|
538
|
-
dropRef
|
|
539
|
-
opacity
|
|
481
|
+
const {
|
|
482
|
+
isDragging,
|
|
483
|
+
dragRef,
|
|
484
|
+
dropRef,
|
|
485
|
+
opacity
|
|
486
|
+
} = useDndRow(props);
|
|
540
487
|
return /*#__PURE__*/React__default["default"].createElement("tr", {
|
|
541
488
|
ref: dropRef,
|
|
542
489
|
style: {
|
|
543
|
-
opacity
|
|
490
|
+
opacity
|
|
544
491
|
}
|
|
545
492
|
}, /*#__PURE__*/React__default["default"].createElement("td", {
|
|
546
493
|
ref: dragRef,
|
|
@@ -556,16 +503,16 @@ function DefaultDndRow(props) {
|
|
|
556
503
|
}))), /*#__PURE__*/React__default["default"].createElement(DefaultCells, props));
|
|
557
504
|
}
|
|
558
505
|
function DefaultRow(_ref) {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
506
|
+
let {
|
|
507
|
+
onClick,
|
|
508
|
+
row,
|
|
509
|
+
enableDragNDrop,
|
|
510
|
+
onDrop,
|
|
511
|
+
onDrag
|
|
512
|
+
} = _ref,
|
|
513
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$d);
|
|
514
|
+
const opts = _extends({}, props, {
|
|
515
|
+
onClick: () => onClick(row.original, "row")
|
|
569
516
|
}, row.getRowProps());
|
|
570
517
|
if (enableDragNDrop) {
|
|
571
518
|
return /*#__PURE__*/React__default["default"].createElement(DefaultDndRow, _extends({}, opts, {
|
|
@@ -580,41 +527,36 @@ function DefaultRow(_ref) {
|
|
|
580
527
|
}
|
|
581
528
|
|
|
582
529
|
function callLast(fn, time) {
|
|
583
|
-
|
|
530
|
+
let last = null;
|
|
584
531
|
return function () {
|
|
585
|
-
var _arguments = arguments;
|
|
586
532
|
if (last) {
|
|
587
533
|
clearTimeout(last);
|
|
588
534
|
last = null;
|
|
589
535
|
}
|
|
590
|
-
last = setTimeout(
|
|
591
|
-
return fn.apply(void 0, [].slice.call(_arguments));
|
|
592
|
-
}, time);
|
|
536
|
+
last = setTimeout(() => fn(...[].slice.call(arguments)), time);
|
|
593
537
|
};
|
|
594
538
|
}
|
|
595
539
|
|
|
596
|
-
|
|
540
|
+
const _excluded$c = ["name", "value", "label", "onChange", "required", "size", "type", "prefix", "suffix", "description", "className", "placeholder"];
|
|
597
541
|
function InputText(_ref) {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
}, [onChange]);
|
|
617
|
-
React.useEffect(function () {
|
|
542
|
+
let {
|
|
543
|
+
name,
|
|
544
|
+
value,
|
|
545
|
+
label,
|
|
546
|
+
onChange,
|
|
547
|
+
required,
|
|
548
|
+
size,
|
|
549
|
+
type,
|
|
550
|
+
prefix,
|
|
551
|
+
suffix,
|
|
552
|
+
description,
|
|
553
|
+
className,
|
|
554
|
+
placeholder
|
|
555
|
+
} = _ref,
|
|
556
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$c);
|
|
557
|
+
const [localValue, setValue] = React$1.useState(value);
|
|
558
|
+
const change = React$1.useMemo(() => onChange && callLast(onChange, 300), [onChange]);
|
|
559
|
+
React$1.useEffect(() => {
|
|
618
560
|
setValue(value);
|
|
619
561
|
}, [value]);
|
|
620
562
|
return /*#__PURE__*/React__default["default"].createElement(FormControl, {
|
|
@@ -634,8 +576,8 @@ function InputText(_ref) {
|
|
|
634
576
|
required: required,
|
|
635
577
|
value: localValue || "",
|
|
636
578
|
placeholder: placeholder,
|
|
637
|
-
onChange:
|
|
638
|
-
|
|
579
|
+
onChange: event => {
|
|
580
|
+
const value = getEventValue(event);
|
|
639
581
|
setValue(value);
|
|
640
582
|
return change && change(name, value);
|
|
641
583
|
}
|
|
@@ -654,16 +596,17 @@ InputText.propTypes = {
|
|
|
654
596
|
};
|
|
655
597
|
|
|
656
598
|
function DefaultColumnFilter(props) {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
599
|
+
const {
|
|
600
|
+
filterId,
|
|
601
|
+
setFilterId,
|
|
602
|
+
column: {
|
|
603
|
+
id,
|
|
604
|
+
filterValue,
|
|
605
|
+
setFilter
|
|
606
|
+
}
|
|
607
|
+
} = props;
|
|
608
|
+
const [value, setValue] = React$1.useState(filterValue || "");
|
|
609
|
+
const onChange = React$1.useCallback((name, value) => {
|
|
667
610
|
setValue(value);
|
|
668
611
|
setFilterId(id);
|
|
669
612
|
setFilter(value || undefined);
|
|
@@ -680,74 +623,69 @@ function DefaultColumnFilter(props) {
|
|
|
680
623
|
});
|
|
681
624
|
}
|
|
682
625
|
|
|
683
|
-
|
|
684
|
-
myArray = []
|
|
685
|
-
|
|
686
|
-
myArray[index1] = _ref[0];
|
|
687
|
-
myArray[index2] = _ref[1];
|
|
626
|
+
const swapElements = (myArray, index1, index2) => {
|
|
627
|
+
myArray = [...myArray];
|
|
628
|
+
[myArray[index1], myArray[index2]] = [myArray[index2], myArray[index1]];
|
|
688
629
|
return myArray;
|
|
689
630
|
};
|
|
690
631
|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
fn();
|
|
695
|
-
};
|
|
632
|
+
const stopPropagationWrapper = fn => event => {
|
|
633
|
+
event.stopPropagation();
|
|
634
|
+
fn();
|
|
696
635
|
};
|
|
697
636
|
|
|
637
|
+
const _excluded$b = ["className", "buttonSize", "buttonType", "buttonOutline", "onClick", "action", "icon", "title", "i18n", "data", "ctx"];
|
|
698
638
|
function DefaultOperationButton(props) {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
i18n = _props$i18n === void 0 ? function (f) {
|
|
714
|
-
return f;
|
|
715
|
-
} : _props$i18n;
|
|
716
|
-
return /*#__PURE__*/React__default["default"].createElement("button", {
|
|
639
|
+
const {
|
|
640
|
+
className = "btn",
|
|
641
|
+
buttonSize = "xs",
|
|
642
|
+
buttonType = "primary",
|
|
643
|
+
buttonOutline,
|
|
644
|
+
onClick,
|
|
645
|
+
action,
|
|
646
|
+
icon = "",
|
|
647
|
+
title = "",
|
|
648
|
+
i18n = f => f
|
|
649
|
+
} = props,
|
|
650
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$b);
|
|
651
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, otherProps, {
|
|
652
|
+
"aria-label": "Operation button: " + (title || action),
|
|
717
653
|
className: classnames__default["default"](className, ["btn", buttonOutline && "outline", buttonType].filter(Boolean).join("-"), "btn-" + buttonSize),
|
|
718
|
-
onClick: stopPropagationWrapper(
|
|
719
|
-
|
|
720
|
-
})
|
|
721
|
-
}, icon ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
654
|
+
onClick: stopPropagationWrapper(() => onClick(action))
|
|
655
|
+
}), icon ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("i", {
|
|
722
656
|
className: iconClass(undefined, icon)
|
|
723
|
-
}), " ", title && " ") : null, title && /*#__PURE__*/
|
|
657
|
+
}), " ", title && " ") : null, title && /*#__PURE__*/React.createElement("span", {
|
|
724
658
|
className: icon && title ? "ml-1" : ""
|
|
725
659
|
}, i18n(title)));
|
|
726
660
|
}
|
|
727
661
|
|
|
728
|
-
|
|
662
|
+
const _excluded$a = ["OperationButton"];
|
|
729
663
|
function DefaultCellOperations(_ref) {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
664
|
+
let {
|
|
665
|
+
operations,
|
|
666
|
+
row,
|
|
667
|
+
onClick,
|
|
668
|
+
ctx,
|
|
669
|
+
i18n
|
|
670
|
+
} = _ref;
|
|
671
|
+
const data = row.original;
|
|
736
672
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
737
673
|
className: "btn-group"
|
|
738
|
-
}, operations.filter(
|
|
739
|
-
|
|
674
|
+
}, operations.filter(_ref2 => {
|
|
675
|
+
let {
|
|
676
|
+
permissionsResolver
|
|
677
|
+
} = _ref2;
|
|
740
678
|
return !permissionsResolver || permissionsResolver(data, ctx);
|
|
741
|
-
}).map(
|
|
742
|
-
|
|
743
|
-
|
|
679
|
+
}).map((_ref3, index) => {
|
|
680
|
+
let {
|
|
681
|
+
OperationButton = DefaultOperationButton
|
|
682
|
+
} = _ref3,
|
|
744
683
|
operation = _objectWithoutPropertiesLoose(_ref3, _excluded$a);
|
|
745
684
|
return /*#__PURE__*/React__default["default"].createElement(OperationButton, _extends({
|
|
746
685
|
key: operation.action
|
|
747
686
|
}, operation, {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
},
|
|
687
|
+
"data-testid": "operation-" + index + "-" + operation.action,
|
|
688
|
+
onClick: action => onClick(data, action),
|
|
751
689
|
data: data,
|
|
752
690
|
i18n: i18n,
|
|
753
691
|
ctx: ctx
|
|
@@ -756,47 +694,39 @@ function DefaultCellOperations(_ref) {
|
|
|
756
694
|
}
|
|
757
695
|
|
|
758
696
|
function useOperations(_ref) {
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
CellOperations =
|
|
762
|
-
onClick
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
return function (hooks) {
|
|
769
|
-
hooks.visibleColumns.push(function (columns) {
|
|
697
|
+
let {
|
|
698
|
+
operations,
|
|
699
|
+
CellOperations = DefaultCellOperations,
|
|
700
|
+
onClick,
|
|
701
|
+
i18n = f => f,
|
|
702
|
+
ctx
|
|
703
|
+
} = _ref;
|
|
704
|
+
return hooks => {
|
|
705
|
+
hooks.visibleColumns.push(columns => {
|
|
770
706
|
if (!operations.length) {
|
|
771
707
|
return columns;
|
|
772
708
|
}
|
|
773
|
-
return [
|
|
709
|
+
return [...columns, {
|
|
774
710
|
id: "operations",
|
|
775
711
|
groupByBoundary: true,
|
|
776
|
-
Header:
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
i18n: i18n
|
|
787
|
-
}));
|
|
788
|
-
}
|
|
789
|
-
}]);
|
|
712
|
+
Header: () => /*#__PURE__*/React__default["default"].createElement("div", {
|
|
713
|
+
className: "text-center"
|
|
714
|
+
}, i18n("Operations")),
|
|
715
|
+
Cell: props => /*#__PURE__*/React__default["default"].createElement(CellOperations, _extends({}, props, {
|
|
716
|
+
operations: operations,
|
|
717
|
+
onClick: onClick,
|
|
718
|
+
ctx: ctx,
|
|
719
|
+
i18n: i18n
|
|
720
|
+
}))
|
|
721
|
+
}];
|
|
790
722
|
});
|
|
791
723
|
};
|
|
792
724
|
}
|
|
793
725
|
|
|
794
|
-
|
|
726
|
+
const _excluded$9 = ["children", "className", "columns", "data", "onChange", "onClick", "onDrag", "onDrop", "operations", "pageSizes", "filters", "filterId", "pageSize", "pageIndex", "totalLength", "sortBy", "isLoading", "disableFilters", "disablePagination", "ArrowSort", "ColumnFilter", "EmptyData", "Loader", "Pagination", "Row", "CellHeader", "CellOperations", "i18n"];
|
|
795
727
|
function getOperationCallback(operations, onClick) {
|
|
796
|
-
return
|
|
797
|
-
|
|
798
|
-
return operation.action === action || operation.alias === action;
|
|
799
|
-
});
|
|
728
|
+
return (data, action) => {
|
|
729
|
+
const operation = operations.find(operation => operation.action === action || operation.alias === action);
|
|
800
730
|
if (operation) {
|
|
801
731
|
onClick(data, operation);
|
|
802
732
|
}
|
|
@@ -812,82 +742,61 @@ function DefaultEmptyData() {
|
|
|
812
742
|
className: "text-center p-2 pb-4 font-bold"
|
|
813
743
|
}, "No data found");
|
|
814
744
|
}
|
|
815
|
-
|
|
745
|
+
const hooks = [reactTable.useFilters, reactTable.useGroupBy, reactTable.useSortBy, reactTable.usePagination];
|
|
816
746
|
function useCustomTable(props) {
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
_props$EmptyData = props.EmptyData,
|
|
848
|
-
EmptyData = _props$EmptyData === void 0 ? DefaultEmptyData : _props$EmptyData,
|
|
849
|
-
_props$Loader = props.Loader,
|
|
850
|
-
Loader = _props$Loader === void 0 ? DefaultLoader : _props$Loader,
|
|
851
|
-
_props$Pagination = props.Pagination,
|
|
852
|
-
Pagination$1 = _props$Pagination === void 0 ? Pagination : _props$Pagination,
|
|
853
|
-
_props$Row = props.Row,
|
|
854
|
-
Row = _props$Row === void 0 ? DefaultRow : _props$Row,
|
|
855
|
-
_props$CellHeader = props.CellHeader,
|
|
856
|
-
CellHeader = _props$CellHeader === void 0 ? DefaultCellHeader : _props$CellHeader,
|
|
857
|
-
CellOperations = props.CellOperations,
|
|
858
|
-
_props$i18n = props.i18n,
|
|
859
|
-
i18n = _props$i18n === void 0 ? function (f) {
|
|
860
|
-
return f;
|
|
861
|
-
} : _props$i18n,
|
|
747
|
+
const {
|
|
748
|
+
children,
|
|
749
|
+
className = "",
|
|
750
|
+
columns,
|
|
751
|
+
data,
|
|
752
|
+
onChange = noop__default["default"],
|
|
753
|
+
onClick = noop__default["default"],
|
|
754
|
+
onDrag = noop__default["default"],
|
|
755
|
+
onDrop = noop__default["default"],
|
|
756
|
+
operations = [],
|
|
757
|
+
pageSizes = [10, 25, 50, 100],
|
|
758
|
+
filters: controlledFilters,
|
|
759
|
+
filterId: controlledFilterId,
|
|
760
|
+
pageSize: controlledPageSize,
|
|
761
|
+
pageIndex: controlledPageIndex,
|
|
762
|
+
totalLength,
|
|
763
|
+
sortBy: controlledSortBy,
|
|
764
|
+
isLoading,
|
|
765
|
+
disableFilters,
|
|
766
|
+
disablePagination,
|
|
767
|
+
ArrowSort = DefaultArrowSort,
|
|
768
|
+
ColumnFilter = DefaultColumnFilter,
|
|
769
|
+
EmptyData = DefaultEmptyData,
|
|
770
|
+
Loader = DefaultLoader,
|
|
771
|
+
Pagination: Pagination$1 = Pagination,
|
|
772
|
+
Row = DefaultRow,
|
|
773
|
+
CellHeader = DefaultCellHeader,
|
|
774
|
+
CellOperations,
|
|
775
|
+
i18n = f => f
|
|
776
|
+
} = props,
|
|
862
777
|
ctx = _objectWithoutPropertiesLoose(props, _excluded$9);
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
}, [ColumnFilter, ArrowSort]);
|
|
871
|
-
var _React$useState = React__default["default"].useState(controlledFilterId),
|
|
872
|
-
filterId = _React$useState[0],
|
|
873
|
-
setFilterId = _React$useState[1];
|
|
778
|
+
const _onClick = getOperationCallback(operations, onClick);
|
|
779
|
+
const defaultColumn = React__default["default"].useMemo(() => ({
|
|
780
|
+
// Let's set up our default Filter UI
|
|
781
|
+
Filter: ColumnFilter,
|
|
782
|
+
ArrowSort
|
|
783
|
+
}), [ColumnFilter, ArrowSort]);
|
|
784
|
+
const [filterId, setFilterId] = React__default["default"].useState(controlledFilterId);
|
|
874
785
|
// DND
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
setRecords = _useState[1];
|
|
878
|
-
React.useEffect(function () {
|
|
786
|
+
const [records, setRecords] = React$1.useState(data);
|
|
787
|
+
React$1.useEffect(() => {
|
|
879
788
|
setRecords(data);
|
|
880
789
|
}, [data]);
|
|
881
|
-
|
|
882
|
-
|
|
790
|
+
const _onDrag = (dragIndex, hoverIndex) => {
|
|
791
|
+
const newRecords = swapElements([...records], dragIndex, hoverIndex);
|
|
883
792
|
setRecords(newRecords);
|
|
884
793
|
onDrag(newRecords);
|
|
885
794
|
};
|
|
886
|
-
|
|
887
|
-
columns
|
|
888
|
-
data
|
|
889
|
-
ctx
|
|
890
|
-
defaultColumn
|
|
795
|
+
const tableInstance = reactTable.useTable(_extends({}, props, {
|
|
796
|
+
columns,
|
|
797
|
+
data,
|
|
798
|
+
ctx,
|
|
799
|
+
defaultColumn,
|
|
891
800
|
// getRowId,
|
|
892
801
|
initialState: _extends({}, props.initialState || {}, {
|
|
893
802
|
filters: controlledFilters || [],
|
|
@@ -898,49 +807,52 @@ function useCustomTable(props) {
|
|
|
898
807
|
manualPagination: props.manualPagination === undefined ? true : props.manualPagination,
|
|
899
808
|
manualSortBy: props.manualSortBy === undefined ? true : props.manualPagination,
|
|
900
809
|
manualFilters: props.manualFilters === undefined ? true : props.manualFilters,
|
|
901
|
-
disableFilters
|
|
902
|
-
filterId
|
|
903
|
-
setFilterId
|
|
904
|
-
})
|
|
905
|
-
operations
|
|
906
|
-
CellOperations
|
|
810
|
+
disableFilters,
|
|
811
|
+
filterId,
|
|
812
|
+
setFilterId
|
|
813
|
+
}), ...hooks, useOperations({
|
|
814
|
+
operations,
|
|
815
|
+
CellOperations,
|
|
907
816
|
onClick: _onClick,
|
|
908
|
-
ctx
|
|
909
|
-
i18n
|
|
910
|
-
})
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
817
|
+
ctx,
|
|
818
|
+
i18n
|
|
819
|
+
}));
|
|
820
|
+
const {
|
|
821
|
+
setPageSize,
|
|
822
|
+
state: {
|
|
823
|
+
pageIndex,
|
|
824
|
+
pageSize,
|
|
825
|
+
sortBy,
|
|
826
|
+
filters
|
|
827
|
+
}
|
|
828
|
+
} = tableInstance;
|
|
829
|
+
React__default["default"].useEffect(() => {
|
|
918
830
|
onChange({
|
|
919
|
-
pageIndex
|
|
920
|
-
pageSize
|
|
921
|
-
sortBy
|
|
922
|
-
filters
|
|
923
|
-
filterId
|
|
831
|
+
pageIndex,
|
|
832
|
+
pageSize,
|
|
833
|
+
sortBy,
|
|
834
|
+
filters,
|
|
835
|
+
filterId
|
|
924
836
|
});
|
|
925
837
|
}, [onChange, pageIndex, pageSize, sortBy, filters, filterId]);
|
|
926
838
|
return {
|
|
927
|
-
className
|
|
928
|
-
tableInstance
|
|
929
|
-
CellHeader
|
|
930
|
-
isLoading
|
|
931
|
-
Loader
|
|
932
|
-
EmptyData
|
|
933
|
-
Row
|
|
934
|
-
data
|
|
935
|
-
disablePagination
|
|
839
|
+
className,
|
|
840
|
+
tableInstance,
|
|
841
|
+
CellHeader,
|
|
842
|
+
isLoading,
|
|
843
|
+
Loader,
|
|
844
|
+
EmptyData,
|
|
845
|
+
Row,
|
|
846
|
+
data,
|
|
847
|
+
disablePagination,
|
|
936
848
|
Pagination: Pagination$1,
|
|
937
|
-
pageIndex
|
|
938
|
-
pageSize
|
|
939
|
-
pageSizes
|
|
940
|
-
totalLength
|
|
941
|
-
setPageSize
|
|
942
|
-
i18n
|
|
943
|
-
children
|
|
849
|
+
pageIndex,
|
|
850
|
+
pageSize,
|
|
851
|
+
pageSizes,
|
|
852
|
+
totalLength,
|
|
853
|
+
setPageSize,
|
|
854
|
+
i18n,
|
|
855
|
+
children,
|
|
944
856
|
onClick: _onClick,
|
|
945
857
|
onDrag: _onDrag,
|
|
946
858
|
onDrop: onDrop,
|
|
@@ -949,28 +861,29 @@ function useCustomTable(props) {
|
|
|
949
861
|
}
|
|
950
862
|
|
|
951
863
|
function Table(props) {
|
|
952
|
-
|
|
953
|
-
className
|
|
954
|
-
tableInstance
|
|
955
|
-
CellHeader
|
|
956
|
-
isLoading
|
|
957
|
-
onClick
|
|
958
|
-
Loader
|
|
959
|
-
EmptyData
|
|
960
|
-
Row
|
|
961
|
-
data
|
|
962
|
-
disablePagination
|
|
963
|
-
Pagination
|
|
964
|
-
pageIndex
|
|
965
|
-
pageSize
|
|
966
|
-
pageSizes
|
|
967
|
-
setPageSize
|
|
968
|
-
totalLength
|
|
969
|
-
i18n
|
|
970
|
-
enableDragNDrop
|
|
971
|
-
children
|
|
972
|
-
onDrag
|
|
973
|
-
onDrop
|
|
864
|
+
const {
|
|
865
|
+
className,
|
|
866
|
+
tableInstance,
|
|
867
|
+
CellHeader,
|
|
868
|
+
isLoading,
|
|
869
|
+
onClick,
|
|
870
|
+
Loader,
|
|
871
|
+
EmptyData,
|
|
872
|
+
Row,
|
|
873
|
+
data,
|
|
874
|
+
disablePagination,
|
|
875
|
+
Pagination,
|
|
876
|
+
pageIndex,
|
|
877
|
+
pageSize,
|
|
878
|
+
pageSizes,
|
|
879
|
+
setPageSize,
|
|
880
|
+
totalLength,
|
|
881
|
+
i18n,
|
|
882
|
+
enableDragNDrop,
|
|
883
|
+
children,
|
|
884
|
+
onDrag,
|
|
885
|
+
onDrop
|
|
886
|
+
} = useCustomTable(props);
|
|
974
887
|
// Render the UI for your table
|
|
975
888
|
return /*#__PURE__*/React__default["default"].createElement(DrapNDropContainer, {
|
|
976
889
|
enableDragNDrop: enableDragNDrop
|
|
@@ -978,22 +891,18 @@ function Table(props) {
|
|
|
978
891
|
className: classnames__default["default"]("table-group table-responsive", className)
|
|
979
892
|
}, /*#__PURE__*/React__default["default"].createElement("table", _extends({
|
|
980
893
|
className: "table table-striped table-hover"
|
|
981
|
-
}, tableInstance.getTableProps()), /*#__PURE__*/React__default["default"].createElement("thead", null, tableInstance.headerGroups.map(
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
column: column
|
|
994
|
-
}));
|
|
995
|
-
}));
|
|
996
|
-
})), !isLoading ? /*#__PURE__*/React__default["default"].createElement("tbody", tableInstance.getTableBodyProps(), tableInstance.page.map(function (row, index) {
|
|
894
|
+
}, tableInstance.getTableProps()), /*#__PURE__*/React__default["default"].createElement("thead", null, tableInstance.headerGroups.map((headerGroup, i) => /*#__PURE__*/React__default["default"].createElement("tr", _extends({}, headerGroup.getHeaderGroupProps(), {
|
|
895
|
+
key: "tableInstance.headerGroups" + i
|
|
896
|
+
}), enableDragNDrop ? /*#__PURE__*/React__default["default"].createElement("th", {
|
|
897
|
+
role: "columnheader",
|
|
898
|
+
className: "text-center"
|
|
899
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
900
|
+
className: "table-cell-header"
|
|
901
|
+
})) : null, headerGroup.headers.map(column => /*#__PURE__*/React__default["default"].createElement("th", _extends({}, column.getHeaderProps(), {
|
|
902
|
+
key: "tableInstance.headers.column." + column.id
|
|
903
|
+
}), /*#__PURE__*/React__default["default"].createElement(CellHeader, {
|
|
904
|
+
column: column
|
|
905
|
+
})))))), !isLoading ? /*#__PURE__*/React__default["default"].createElement("tbody", tableInstance.getTableBodyProps(), tableInstance.page.map((row, index) => {
|
|
997
906
|
tableInstance.prepareRow(row);
|
|
998
907
|
return /*#__PURE__*/React__default["default"].createElement(Row, {
|
|
999
908
|
index: index,
|
|
@@ -1017,25 +926,20 @@ function Table(props) {
|
|
|
1017
926
|
}))) : null, children));
|
|
1018
927
|
}
|
|
1019
928
|
|
|
1020
|
-
|
|
929
|
+
const _excluded$8 = ["disableFilters", "disablePagination", "availableActions", "onAddAction"];
|
|
1021
930
|
function ActionsTable(_ref) {
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
_ref$onAddAction = _ref.onAddAction,
|
|
1029
|
-
onAddAction = _ref$onAddAction === void 0 ? noop__default["default"] : _ref$onAddAction,
|
|
931
|
+
let {
|
|
932
|
+
disableFilters = true,
|
|
933
|
+
disablePagination = true,
|
|
934
|
+
availableActions = [],
|
|
935
|
+
onAddAction = noop__default["default"]
|
|
936
|
+
} = _ref,
|
|
1030
937
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
1031
|
-
|
|
1032
|
-
i18n =
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
currentAction = _useState[0],
|
|
1037
|
-
setAction = _useState[1];
|
|
1038
|
-
var columns = [{
|
|
938
|
+
const {
|
|
939
|
+
i18n = f => f
|
|
940
|
+
} = props;
|
|
941
|
+
const [currentAction, setAction] = React$1.useState("");
|
|
942
|
+
const columns = [{
|
|
1039
943
|
Header: i18n("Actions"),
|
|
1040
944
|
accessor: "title",
|
|
1041
945
|
id: "title"
|
|
@@ -1047,24 +951,21 @@ function ActionsTable(_ref) {
|
|
|
1047
951
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1048
952
|
className: "pagination-group"
|
|
1049
953
|
}, /*#__PURE__*/React__default["default"].createElement(Select, {
|
|
954
|
+
"data-testid": "action-table-select",
|
|
1050
955
|
name: "actions",
|
|
1051
956
|
value: currentAction,
|
|
1052
957
|
choices: [{
|
|
1053
958
|
label: i18n("Select an action"),
|
|
1054
959
|
value: ""
|
|
1055
960
|
}].concat(availableActions),
|
|
1056
|
-
onChange:
|
|
1057
|
-
return setAction(action);
|
|
1058
|
-
}
|
|
961
|
+
onChange: (name, action) => setAction(action)
|
|
1059
962
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1060
963
|
className: "pl-3"
|
|
1061
964
|
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
1062
|
-
"data-testid": "
|
|
965
|
+
"data-testid": "action-table-add",
|
|
1063
966
|
disabled: currentAction === "",
|
|
1064
967
|
className: "btn btn-success",
|
|
1065
|
-
onClick:
|
|
1066
|
-
return currentAction && onAddAction(currentAction);
|
|
1067
|
-
},
|
|
968
|
+
onClick: () => currentAction && onAddAction(currentAction),
|
|
1068
969
|
type: "submit"
|
|
1069
970
|
}, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
1070
971
|
className: classnames__default["default"](iconClass(undefined, "plus"), "mr-1")
|
|
@@ -1079,8 +980,8 @@ function formatError(error) {
|
|
|
1079
980
|
return error.map(formatError);
|
|
1080
981
|
}
|
|
1081
982
|
if (Object.prototype.hasOwnProperty.call(error, "errors")) {
|
|
1082
|
-
return Object.keys(error.errors).map(
|
|
1083
|
-
|
|
983
|
+
return Object.keys(error.errors).map((key, index) => {
|
|
984
|
+
const item = error.errors[key];
|
|
1084
985
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1085
986
|
key: index
|
|
1086
987
|
}, /*#__PURE__*/React__default["default"].createElement("strong", null, item.name, " (", item.path, ")"), " ", "- ", item.message);
|
|
@@ -1092,7 +993,7 @@ function formatError(error) {
|
|
|
1092
993
|
}
|
|
1093
994
|
// If this is a joy validation error.
|
|
1094
995
|
if (Object.prototype.hasOwnProperty.call(error, "name") && error.name === "ValidationError") {
|
|
1095
|
-
return error.details.map(
|
|
996
|
+
return error.details.map((item, index) => {
|
|
1096
997
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1097
998
|
key: index
|
|
1098
999
|
}, item.message);
|
|
@@ -1105,9 +1006,10 @@ function formatError(error) {
|
|
|
1105
1006
|
return "An error occurred. See console logs for details.";
|
|
1106
1007
|
}
|
|
1107
1008
|
function Alert(_ref) {
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
type =
|
|
1009
|
+
let {
|
|
1010
|
+
error,
|
|
1011
|
+
type = "danger"
|
|
1012
|
+
} = _ref;
|
|
1111
1013
|
if (!error || Array.isArray(error) && !error.length) {
|
|
1112
1014
|
return null;
|
|
1113
1015
|
}
|
|
@@ -1118,9 +1020,11 @@ function Alert(_ref) {
|
|
|
1118
1020
|
}
|
|
1119
1021
|
|
|
1120
1022
|
function Card(_ref) {
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1023
|
+
let {
|
|
1024
|
+
children,
|
|
1025
|
+
label,
|
|
1026
|
+
className
|
|
1027
|
+
} = _ref;
|
|
1124
1028
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1125
1029
|
className: classnames__default["default"]("card", className)
|
|
1126
1030
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -1133,7 +1037,7 @@ function Card(_ref) {
|
|
|
1133
1037
|
}, children));
|
|
1134
1038
|
}
|
|
1135
1039
|
|
|
1136
|
-
|
|
1040
|
+
const _excluded$7 = ["src", "form", "options", "submission", "url"];
|
|
1137
1041
|
function _catch$1(body, recover) {
|
|
1138
1042
|
try {
|
|
1139
1043
|
var result = body();
|
|
@@ -1146,21 +1050,21 @@ function _catch$1(body, recover) {
|
|
|
1146
1050
|
return result;
|
|
1147
1051
|
}
|
|
1148
1052
|
function useEvent(event, callback, events) {
|
|
1149
|
-
React.useEffect(
|
|
1053
|
+
React$1.useEffect(() => {
|
|
1150
1054
|
if (callback) {
|
|
1151
1055
|
events.set(event, callback);
|
|
1152
1056
|
}
|
|
1153
1057
|
}, [callback, event, events]);
|
|
1154
1058
|
}
|
|
1155
1059
|
function useEvents(funcs) {
|
|
1156
|
-
|
|
1157
|
-
|
|
1060
|
+
const events = React$1.useRef(new Map());
|
|
1061
|
+
const hasEvent = event => {
|
|
1158
1062
|
return funcs.hasOwnProperty(event) && typeof funcs[event] === "function";
|
|
1159
1063
|
};
|
|
1160
|
-
|
|
1064
|
+
const emit = function (event) {
|
|
1161
1065
|
if (hasEvent(event)) {
|
|
1162
|
-
|
|
1163
|
-
return fn
|
|
1066
|
+
const fn = events.current.has(event) ? events.current.get(event) : funcs[event];
|
|
1067
|
+
return fn(...[].slice.call(arguments, 1));
|
|
1164
1068
|
}
|
|
1165
1069
|
};
|
|
1166
1070
|
useEvent("onBlur", funcs["onBlur"], events.current);
|
|
@@ -1182,17 +1086,17 @@ function useEvents(funcs) {
|
|
|
1182
1086
|
useEvent("onBlur", funcs["onBlur"], events.current);
|
|
1183
1087
|
useEvent("onInitialized", funcs["onInitialized"], events.current);
|
|
1184
1088
|
return {
|
|
1185
|
-
events
|
|
1186
|
-
emit
|
|
1187
|
-
hasEvent
|
|
1089
|
+
events,
|
|
1090
|
+
emit,
|
|
1091
|
+
hasEvent
|
|
1188
1092
|
};
|
|
1189
1093
|
}
|
|
1190
1094
|
function useForm(props) {
|
|
1191
|
-
|
|
1095
|
+
const customValidation = function (submission, callback) {
|
|
1192
1096
|
try {
|
|
1193
|
-
|
|
1097
|
+
const _temp2 = function () {
|
|
1194
1098
|
if (hasEvent("onAsyncSubmit")) {
|
|
1195
|
-
|
|
1099
|
+
const _temp = _catch$1(function () {
|
|
1196
1100
|
return Promise.resolve(emit("onAsyncSubmit", submission, instance.current)).then(function () {});
|
|
1197
1101
|
}, function (err) {
|
|
1198
1102
|
callback((err == null ? void 0 : err.errors) || err);
|
|
@@ -1207,20 +1111,22 @@ function useForm(props) {
|
|
|
1207
1111
|
return Promise.reject(e);
|
|
1208
1112
|
}
|
|
1209
1113
|
};
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1114
|
+
const {
|
|
1115
|
+
src,
|
|
1116
|
+
form,
|
|
1117
|
+
options = {},
|
|
1118
|
+
submission,
|
|
1119
|
+
url
|
|
1120
|
+
} = props,
|
|
1216
1121
|
funcs = _objectWithoutPropertiesLoose(props, _excluded$7);
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
emit
|
|
1222
|
-
hasEvent
|
|
1223
|
-
|
|
1122
|
+
const element = React$1.useRef();
|
|
1123
|
+
const isLoaded = React$1.useRef();
|
|
1124
|
+
const instance = React$1.useRef();
|
|
1125
|
+
const {
|
|
1126
|
+
emit,
|
|
1127
|
+
hasEvent
|
|
1128
|
+
} = useEvents(funcs);
|
|
1129
|
+
const createWebForm = (srcOrForm, options) => {
|
|
1224
1130
|
options = Object.assign({}, options);
|
|
1225
1131
|
srcOrForm = typeof srcOrForm === "string" ? srcOrForm : cloneDeep__default["default"](srcOrForm);
|
|
1226
1132
|
if (!instance.current) {
|
|
@@ -1236,14 +1142,14 @@ function useForm(props) {
|
|
|
1236
1142
|
return;
|
|
1237
1143
|
}
|
|
1238
1144
|
if (event.startsWith("formio.")) {
|
|
1239
|
-
|
|
1145
|
+
const eventName = "on" + event.charAt(7).toUpperCase() + event.slice(8);
|
|
1240
1146
|
if (eventName === "onChange" && !args[0].changed) {
|
|
1241
1147
|
return;
|
|
1242
1148
|
}
|
|
1243
|
-
emit
|
|
1149
|
+
emit(eventName, ...args, instance.current);
|
|
1244
1150
|
}
|
|
1245
1151
|
});
|
|
1246
|
-
instance.current.ready.then(
|
|
1152
|
+
instance.current.ready.then(formio => {
|
|
1247
1153
|
submission && (formio.submission = cloneDeep__default["default"](submission));
|
|
1248
1154
|
if (props.onFormReady) {
|
|
1249
1155
|
props.onFormReady(formio);
|
|
@@ -1253,9 +1159,9 @@ function useForm(props) {
|
|
|
1253
1159
|
}
|
|
1254
1160
|
return instance.current;
|
|
1255
1161
|
};
|
|
1256
|
-
React.useEffect(
|
|
1162
|
+
React$1.useEffect(() => {
|
|
1257
1163
|
if (instance.current) {
|
|
1258
|
-
instance.current.ready.then(
|
|
1164
|
+
instance.current.ready.then(formio => {
|
|
1259
1165
|
if (isEqual__default["default"](formio.submission.data, submission == null ? void 0 : submission.data)) {
|
|
1260
1166
|
return;
|
|
1261
1167
|
}
|
|
@@ -1263,9 +1169,9 @@ function useForm(props) {
|
|
|
1263
1169
|
});
|
|
1264
1170
|
}
|
|
1265
1171
|
}, [submission]);
|
|
1266
|
-
React.useEffect(
|
|
1172
|
+
React$1.useEffect(() => {
|
|
1267
1173
|
if (form && instance.current) {
|
|
1268
|
-
instance.current.ready.then(
|
|
1174
|
+
instance.current.ready.then(formio => {
|
|
1269
1175
|
formio.form = form;
|
|
1270
1176
|
if (url) {
|
|
1271
1177
|
formio.url = url;
|
|
@@ -1273,7 +1179,7 @@ function useForm(props) {
|
|
|
1273
1179
|
});
|
|
1274
1180
|
}
|
|
1275
1181
|
}, [form, url]);
|
|
1276
|
-
React.useEffect(
|
|
1182
|
+
React$1.useEffect(() => {
|
|
1277
1183
|
if (src) {
|
|
1278
1184
|
if (instance.current) {
|
|
1279
1185
|
isLoaded.current = false;
|
|
@@ -1282,24 +1188,25 @@ function useForm(props) {
|
|
|
1282
1188
|
createWebForm(src, options);
|
|
1283
1189
|
}
|
|
1284
1190
|
}, [src]);
|
|
1285
|
-
React.useEffect(
|
|
1191
|
+
React$1.useEffect(() => {
|
|
1286
1192
|
if (form) {
|
|
1287
1193
|
createWebForm(form, options);
|
|
1288
1194
|
}
|
|
1289
|
-
return
|
|
1195
|
+
return () => {
|
|
1290
1196
|
isLoaded.current = false;
|
|
1291
1197
|
instance.current && instance.current.destroy(true);
|
|
1292
1198
|
};
|
|
1293
1199
|
}, []);
|
|
1294
1200
|
return {
|
|
1295
|
-
element
|
|
1201
|
+
element
|
|
1296
1202
|
};
|
|
1297
1203
|
}
|
|
1298
1204
|
|
|
1299
1205
|
formiojs.Components.setComponents(AllComponents__default["default"]);
|
|
1300
1206
|
function Form(props) {
|
|
1301
|
-
|
|
1302
|
-
element
|
|
1207
|
+
const {
|
|
1208
|
+
element
|
|
1209
|
+
} = useForm(props);
|
|
1303
1210
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1304
1211
|
"data-testid": "formioContainer" + (props.name || ""),
|
|
1305
1212
|
ref: element,
|
|
@@ -1358,15 +1265,17 @@ Form.propTypes = {
|
|
|
1358
1265
|
};
|
|
1359
1266
|
|
|
1360
1267
|
function getRoleComponent(_ref) {
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1268
|
+
let {
|
|
1269
|
+
label,
|
|
1270
|
+
key,
|
|
1271
|
+
description,
|
|
1272
|
+
choices,
|
|
1273
|
+
data
|
|
1274
|
+
} = _ref;
|
|
1366
1275
|
return {
|
|
1367
|
-
label
|
|
1368
|
-
key
|
|
1369
|
-
description
|
|
1276
|
+
label,
|
|
1277
|
+
key,
|
|
1278
|
+
description,
|
|
1370
1279
|
type: "select",
|
|
1371
1280
|
labelPosition: "top",
|
|
1372
1281
|
widget: "choicesjs",
|
|
@@ -1396,92 +1305,96 @@ function toDescription(description, hr) {
|
|
|
1396
1305
|
return '<span class="text-sm">' + description + "</span> " + (hr ? '<hr class="mt-6 mb-5 border-gray-200 mx-20"/>' : "");
|
|
1397
1306
|
}
|
|
1398
1307
|
function getSubmissionPermissionForm(_ref2) {
|
|
1399
|
-
|
|
1308
|
+
let {
|
|
1309
|
+
choices
|
|
1310
|
+
} = _ref2;
|
|
1400
1311
|
return {
|
|
1401
1312
|
description: "<strong>Elevated permissions allow users to access and modify other user's entities. Assign with caution.</strong>",
|
|
1402
1313
|
components: [getRoleComponent({
|
|
1403
1314
|
key: "create_own",
|
|
1404
1315
|
label: '<h4 class="text-gray-800">Create Own Submissions</h4>',
|
|
1405
1316
|
description: toDescription("The Create Own Submissions permission will allow a user with one of the Roles to create a Submission. Upon creating the Submission, the user will be defined as its owner."),
|
|
1406
|
-
choices
|
|
1317
|
+
choices
|
|
1407
1318
|
}), getRoleComponent({
|
|
1408
1319
|
key: "create_all",
|
|
1409
1320
|
label: '<h4 class="text-gray-800">Create All Submissions</h4>',
|
|
1410
1321
|
description: toDescription('<strong class="text-yellow-600">Elevated Permission:</strong> The Create All Submissions permission will allow a user with one of the Roles to create a new Submission and assign ownership of that Submission to another user.'),
|
|
1411
|
-
choices
|
|
1322
|
+
choices
|
|
1412
1323
|
}), getRoleComponent({
|
|
1413
1324
|
key: "read_own",
|
|
1414
1325
|
label: '<h4 class="text-gray-800">Read Own Submissions</h4>',
|
|
1415
1326
|
description: toDescription("The Read Own Submissions permission will allow a user with one of the Roles to read a Submission. A user can only read a Submission if they are defined as its owner."),
|
|
1416
|
-
choices
|
|
1327
|
+
choices
|
|
1417
1328
|
}), getRoleComponent({
|
|
1418
1329
|
key: "read_all",
|
|
1419
1330
|
label: '<h4 class="text-gray-800">Read All Submissions</h4>',
|
|
1420
1331
|
description: toDescription('<strong class="text-yellow-600">Elevated Permission:</strong> The Read All Submissions permission will allow a user with one of the Roles to read all Submissions regardless of who owns them.'),
|
|
1421
|
-
choices
|
|
1332
|
+
choices
|
|
1422
1333
|
}), getRoleComponent({
|
|
1423
1334
|
key: "update_own",
|
|
1424
1335
|
label: '<h4 class="text-gray-800">Update Own Submissions</h4>',
|
|
1425
1336
|
description: toDescription("The Update Own Submissions permission will allow a user with one of the Roles to update a Submission. A user can only update a Submission if they are defined as its owner."),
|
|
1426
|
-
choices
|
|
1337
|
+
choices
|
|
1427
1338
|
}), getRoleComponent({
|
|
1428
1339
|
key: "update_all",
|
|
1429
1340
|
label: '<h4 class="text-gray-800">Update All Submissions</h4>',
|
|
1430
1341
|
description: toDescription('<strong class="text-yellow-600">Elevated Permission:</strong> The Update All Submissions permission will allow a user with one of the Roles to update a Submission, regardless of who owns the Submission. Additionally with this permission, a user can change the owner of a Submission.'),
|
|
1431
|
-
choices
|
|
1342
|
+
choices
|
|
1432
1343
|
}), getRoleComponent({
|
|
1433
1344
|
key: "delete_own",
|
|
1434
1345
|
label: '<h4 class="text-gray-800">Delete Own Submissions</h4>',
|
|
1435
1346
|
description: toDescription("The Delete Own Submissions permission will allow a user with one of the Roles, to delete a Submission. A user can only delete a Submission if they are defined as its owner."),
|
|
1436
|
-
choices
|
|
1347
|
+
choices
|
|
1437
1348
|
}), getRoleComponent({
|
|
1438
1349
|
key: "delete_all",
|
|
1439
1350
|
label: '<h4 class="text-gray-800">Delete All Submissions</h4>',
|
|
1440
1351
|
description: toDescription('<strong class="text-yellow-600">Elevated Permission:</strong> The Delete All Submissions permission will allow a user with one of the Roles to delete a Submission, regardless of who owns the Submission.', false),
|
|
1441
|
-
choices
|
|
1352
|
+
choices
|
|
1442
1353
|
})]
|
|
1443
1354
|
};
|
|
1444
1355
|
}
|
|
1445
1356
|
function getAccessPermissionForm(_ref3) {
|
|
1446
|
-
|
|
1357
|
+
let {
|
|
1358
|
+
choices
|
|
1359
|
+
} = _ref3;
|
|
1447
1360
|
return {
|
|
1448
1361
|
description: "<strong>Elevated permissions allow users to access and modify other user's entities. Assign with caution.</strong>",
|
|
1449
1362
|
components: [getRoleComponent({
|
|
1450
1363
|
key: "read_own",
|
|
1451
1364
|
label: '<h4 class="text-gray-800">Read Form Definition (Restricted to owner)</h4>',
|
|
1452
1365
|
description: toDescription("The Read Own permission will allow a user, with one of the given Roles, to read a form. A user can only read a form if they are defined as its owner."),
|
|
1453
|
-
choices
|
|
1366
|
+
choices
|
|
1454
1367
|
}), getRoleComponent({
|
|
1455
1368
|
key: "read_all",
|
|
1456
1369
|
label: "<h4>Read Form Definition</h4>",
|
|
1457
1370
|
description: toDescription('<strong class="text-yellow-600">Elevated Permission:</strong> The Read permission will allow a user, with one of the given Roles, to read the form.'),
|
|
1458
|
-
choices
|
|
1371
|
+
choices
|
|
1459
1372
|
}), getRoleComponent({
|
|
1460
1373
|
key: "update_own",
|
|
1461
1374
|
label: '<h4 class="text-gray-800">Update Form Definition (Restricted to owner)</h4>',
|
|
1462
1375
|
description: toDescription("The Update Own permission will allow a user, with one of the given Roles, to update a form. A user can only update a form if they are defined as its owner."),
|
|
1463
|
-
choices
|
|
1376
|
+
choices
|
|
1464
1377
|
}), getRoleComponent({
|
|
1465
1378
|
key: "update_all",
|
|
1466
1379
|
label: '<h4 class="text-gray-800">Update Form Definition</h4>',
|
|
1467
1380
|
description: toDescription('<strong class="text-yellow-600">Elevated Permission:</strong> The Update permission will allow a user, with one of the given Roles, to read and edit the form.'),
|
|
1468
|
-
choices
|
|
1381
|
+
choices
|
|
1469
1382
|
}), getRoleComponent({
|
|
1470
1383
|
key: "delete_own",
|
|
1471
1384
|
label: '<h4 class="text-gray-800">Delete Form Definition (Restricted to owner)</h4>',
|
|
1472
1385
|
description: toDescription("The Delete Own permission will allow a user, with one of the given Roles, to delete a form. A user can only delete a form if they are defined as its owner."),
|
|
1473
|
-
choices
|
|
1386
|
+
choices
|
|
1474
1387
|
}), getRoleComponent({
|
|
1475
1388
|
key: "delete_all",
|
|
1476
1389
|
label: '<h4 class="text-gray-800">Delete Form Definition</h4>',
|
|
1477
1390
|
description: toDescription('<strong class="text-yellow-600">Elevated Permission:</strong> The Delete permission will allow a user, with one of the given Roles, to delete the form.', false),
|
|
1478
|
-
choices
|
|
1391
|
+
choices
|
|
1479
1392
|
})]
|
|
1480
1393
|
};
|
|
1481
1394
|
}
|
|
1482
1395
|
|
|
1483
1396
|
function rolesToChoices(roles) {
|
|
1484
|
-
return Object.values(roles).map(
|
|
1397
|
+
return Object.values(roles).map(role => {
|
|
1485
1398
|
return {
|
|
1486
1399
|
label: role.title || "",
|
|
1487
1400
|
value: role._id || ""
|
|
@@ -1492,50 +1405,50 @@ function accessToHash(keys, access) {
|
|
|
1492
1405
|
if (access === void 0) {
|
|
1493
1406
|
access = [];
|
|
1494
1407
|
}
|
|
1495
|
-
|
|
1408
|
+
const hash = Object.values(access).reduce((o, role) => {
|
|
1496
1409
|
o[role.type] = role.roles;
|
|
1497
1410
|
return o;
|
|
1498
1411
|
}, {});
|
|
1499
|
-
return (keys || []).filter(Boolean).reduce(
|
|
1500
|
-
|
|
1501
|
-
|
|
1412
|
+
return (keys || []).filter(Boolean).reduce((data, key) => {
|
|
1413
|
+
return _extends({}, data, {
|
|
1414
|
+
[key]: hash[key] || []
|
|
1415
|
+
});
|
|
1502
1416
|
}, {});
|
|
1503
1417
|
}
|
|
1504
1418
|
function hashToAccess(data) {
|
|
1505
|
-
|
|
1506
|
-
Object.entries(data).forEach(
|
|
1507
|
-
|
|
1508
|
-
roles = _ref[1];
|
|
1419
|
+
const accessRoles = [];
|
|
1420
|
+
Object.entries(data).forEach(_ref => {
|
|
1421
|
+
let [accessType, roles] = _ref;
|
|
1509
1422
|
if (accessType === "submit") {
|
|
1510
1423
|
return;
|
|
1511
1424
|
}
|
|
1512
1425
|
accessRoles.push({
|
|
1513
1426
|
type: accessType,
|
|
1514
|
-
roles
|
|
1427
|
+
roles
|
|
1515
1428
|
});
|
|
1516
1429
|
});
|
|
1517
1430
|
return accessRoles;
|
|
1518
1431
|
}
|
|
1519
1432
|
function getFormAccess(roles) {
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
choices
|
|
1433
|
+
const choices = rolesToChoices(roles);
|
|
1434
|
+
const access = getAccessPermissionForm({
|
|
1435
|
+
choices
|
|
1523
1436
|
});
|
|
1524
|
-
|
|
1525
|
-
choices
|
|
1437
|
+
const submissionAccess = getSubmissionPermissionForm({
|
|
1438
|
+
choices
|
|
1526
1439
|
});
|
|
1527
1440
|
return {
|
|
1528
|
-
access
|
|
1529
|
-
submissionAccess
|
|
1441
|
+
access,
|
|
1442
|
+
submissionAccess
|
|
1530
1443
|
};
|
|
1531
1444
|
}
|
|
1532
1445
|
function dataAccessToSubmissions(form, formAccess) {
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
};
|
|
1446
|
+
const getKeys = components => components.map(_ref2 => {
|
|
1447
|
+
let {
|
|
1448
|
+
key
|
|
1449
|
+
} = _ref2;
|
|
1450
|
+
return key;
|
|
1451
|
+
});
|
|
1539
1452
|
return {
|
|
1540
1453
|
access: {
|
|
1541
1454
|
data: accessToHash(getKeys(formAccess.access.components), form.access)
|
|
@@ -1559,34 +1472,31 @@ function updateSubmissions(type, submission, submissions, cb) {
|
|
|
1559
1472
|
cb = noop__default["default"];
|
|
1560
1473
|
}
|
|
1561
1474
|
if (shouldUpdate(type, submission, submissions)) {
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1475
|
+
submissions = _extends({}, submissions, {
|
|
1476
|
+
[type]: {
|
|
1477
|
+
data: submission.data
|
|
1478
|
+
}
|
|
1479
|
+
});
|
|
1566
1480
|
cb(submissions);
|
|
1567
1481
|
}
|
|
1568
1482
|
return submissions;
|
|
1569
1483
|
}
|
|
1570
1484
|
|
|
1571
1485
|
function useFormAccess(_ref) {
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1486
|
+
let {
|
|
1487
|
+
form: formDefinition,
|
|
1488
|
+
roles,
|
|
1489
|
+
onSubmit,
|
|
1490
|
+
options
|
|
1491
|
+
} = _ref;
|
|
1576
1492
|
// eslint-disable-next-line no-undef
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
var _useState = React.useState(function () {
|
|
1581
|
-
return dataAccessToSubmissions(formDefinition, form);
|
|
1582
|
-
}),
|
|
1583
|
-
submissions = _useState[0],
|
|
1584
|
-
setSubmissions = _useState[1];
|
|
1585
|
-
var onChange = React.useCallback(function (type, submission) {
|
|
1493
|
+
const form = React$1.useMemo(() => getFormAccess(roles), [roles]);
|
|
1494
|
+
const [submissions, setSubmissions] = React$1.useState(() => dataAccessToSubmissions(formDefinition, form));
|
|
1495
|
+
const onChange = React$1.useCallback((type, submission) => {
|
|
1586
1496
|
updateSubmissions(type, submission, submissions, setSubmissions);
|
|
1587
1497
|
}, [submissions]);
|
|
1588
|
-
React.useEffect(
|
|
1589
|
-
|
|
1498
|
+
React$1.useEffect(() => {
|
|
1499
|
+
const input = dataAccessToSubmissions(formDefinition, form);
|
|
1590
1500
|
if (formDefinition != null && formDefinition._id) {
|
|
1591
1501
|
if (shouldUpdate("access", submissions.access, input) || shouldUpdate("submissionAccess", submissions.submissionAccess, input)) {
|
|
1592
1502
|
setSubmissions(input);
|
|
@@ -1594,36 +1504,38 @@ function useFormAccess(_ref) {
|
|
|
1594
1504
|
}
|
|
1595
1505
|
}, [formDefinition == null ? void 0 : formDefinition._id]);
|
|
1596
1506
|
return {
|
|
1597
|
-
options
|
|
1598
|
-
form
|
|
1507
|
+
options,
|
|
1508
|
+
form,
|
|
1599
1509
|
type: formDefinition.type,
|
|
1600
|
-
submissions
|
|
1601
|
-
onChange
|
|
1602
|
-
onSubmit:
|
|
1603
|
-
|
|
1510
|
+
submissions,
|
|
1511
|
+
onChange,
|
|
1512
|
+
onSubmit: () => {
|
|
1513
|
+
onSubmit && onSubmit(submissionsToDataAccess(formDefinition, submissions));
|
|
1604
1514
|
}
|
|
1605
1515
|
};
|
|
1606
1516
|
}
|
|
1607
1517
|
function NamedFormAccess(_ref2) {
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1518
|
+
let {
|
|
1519
|
+
name,
|
|
1520
|
+
form,
|
|
1521
|
+
submissions,
|
|
1522
|
+
options,
|
|
1523
|
+
onChange,
|
|
1524
|
+
onSubmit,
|
|
1525
|
+
children
|
|
1526
|
+
} = _ref2;
|
|
1527
|
+
const [isValid, setIsValid] = React$1.useState(true);
|
|
1618
1528
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(Form, {
|
|
1619
1529
|
name: name,
|
|
1620
1530
|
form: form[name],
|
|
1621
1531
|
submission: submissions[name],
|
|
1622
|
-
onChange:
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1532
|
+
onChange: _ref3 => {
|
|
1533
|
+
let {
|
|
1534
|
+
data,
|
|
1535
|
+
isValid
|
|
1536
|
+
} = _ref3;
|
|
1537
|
+
isValid && onChange(name, {
|
|
1538
|
+
data
|
|
1627
1539
|
});
|
|
1628
1540
|
setIsValid(isValid);
|
|
1629
1541
|
},
|
|
@@ -1637,13 +1549,14 @@ function NamedFormAccess(_ref2) {
|
|
|
1637
1549
|
}, "Elevated permissions allow users to access and modify other user's entities. Assign with caution."));
|
|
1638
1550
|
}
|
|
1639
1551
|
function FormAccess(props) {
|
|
1640
|
-
|
|
1641
|
-
type
|
|
1642
|
-
form
|
|
1643
|
-
submissions
|
|
1644
|
-
options
|
|
1645
|
-
onChange
|
|
1646
|
-
onSubmit
|
|
1552
|
+
const {
|
|
1553
|
+
type,
|
|
1554
|
+
form,
|
|
1555
|
+
submissions,
|
|
1556
|
+
options,
|
|
1557
|
+
onChange,
|
|
1558
|
+
onSubmit
|
|
1559
|
+
} = useFormAccess(props);
|
|
1647
1560
|
return /*#__PURE__*/React__default["default"].createElement("div", null, props.children, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1648
1561
|
className: "flex mb-5"
|
|
1649
1562
|
}, /*#__PURE__*/React__default["default"].createElement(Card, {
|
|
@@ -1682,24 +1595,16 @@ function FormAccess(props) {
|
|
|
1682
1595
|
label: "About Form Definition Access"
|
|
1683
1596
|
}, /*#__PURE__*/React__default["default"].createElement("p", null, "These permissions allow you to give access to a single form's JSON definition so they can render the form."), /*#__PURE__*/React__default["default"].createElement("p", null, "Typically you will want to allow all of your roles to be able to Read the form definition."), /*#__PURE__*/React__default["default"].createElement("p", null, "Each form also has an owner at ", /*#__PURE__*/React__default["default"].createElement("strong", null, "form.owner"), " which is the user who created the form. In some applications users are allowed to create their own forms. In those cases it is helpful to have Owner based permissions as well.")))));
|
|
1684
1597
|
}
|
|
1685
|
-
FormAccess.propTypes = {
|
|
1686
|
-
type: PropTypes__default["default"].string.isRequired,
|
|
1687
|
-
form: PropTypes__default["default"].object,
|
|
1688
|
-
roles: PropTypes__default["default"].any,
|
|
1689
|
-
children: PropTypes__default["default"].any,
|
|
1690
|
-
options: PropTypes__default["default"].any,
|
|
1691
|
-
onSubmit: PropTypes__default["default"].func
|
|
1692
|
-
};
|
|
1693
1598
|
|
|
1694
|
-
|
|
1599
|
+
const _excluded$6 = ["action"],
|
|
1695
1600
|
_excluded2 = ["actionInfo", "children", "onSubmit", "options"];
|
|
1696
1601
|
function mapData(options, defaults) {
|
|
1697
1602
|
return _extends({}, defaults, options);
|
|
1698
1603
|
}
|
|
1699
1604
|
function mapSettingsForm(_ref) {
|
|
1700
|
-
|
|
1701
|
-
FormioUtils__default["default"].eachComponent(settingsForm.components,
|
|
1702
|
-
|
|
1605
|
+
let settingsForm = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
1606
|
+
FormioUtils__default["default"].eachComponent(settingsForm.components, component => {
|
|
1607
|
+
const resourceExclude = "";
|
|
1703
1608
|
if (component.type === "resourcefields") {
|
|
1704
1609
|
component.type = "select";
|
|
1705
1610
|
component.label = component.title;
|
|
@@ -1715,23 +1620,26 @@ function mapSettingsForm(_ref) {
|
|
|
1715
1620
|
return settingsForm;
|
|
1716
1621
|
}
|
|
1717
1622
|
function FormAction(_ref2) {
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1623
|
+
let {
|
|
1624
|
+
actionInfo,
|
|
1625
|
+
children,
|
|
1626
|
+
onSubmit,
|
|
1627
|
+
options
|
|
1628
|
+
} = _ref2,
|
|
1722
1629
|
props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1630
|
+
const {
|
|
1631
|
+
form,
|
|
1632
|
+
submission
|
|
1633
|
+
} = (() => {
|
|
1634
|
+
const submission = mapData(props.submission || {}, actionInfo.defaults);
|
|
1635
|
+
const form = mapSettingsForm(actionInfo.settingsForm);
|
|
1636
|
+
return {
|
|
1637
|
+
form,
|
|
1638
|
+
submission: {
|
|
1639
|
+
data: submission
|
|
1640
|
+
}
|
|
1641
|
+
};
|
|
1642
|
+
})();
|
|
1735
1643
|
return /*#__PURE__*/React__default["default"].createElement("div", null, children, /*#__PURE__*/React__default["default"].createElement(Form, {
|
|
1736
1644
|
form: form,
|
|
1737
1645
|
submission: submission,
|
|
@@ -1751,32 +1659,30 @@ function _catch(body, recover) {
|
|
|
1751
1659
|
}
|
|
1752
1660
|
return result;
|
|
1753
1661
|
}
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
components =
|
|
1757
|
-
display
|
|
1758
|
-
options
|
|
1759
|
-
onChange
|
|
1760
|
-
|
|
1761
|
-
|
|
1662
|
+
const createBuilder = function (el, _ref) {
|
|
1663
|
+
let {
|
|
1664
|
+
components = [],
|
|
1665
|
+
display,
|
|
1666
|
+
options,
|
|
1667
|
+
onChange,
|
|
1668
|
+
events = {}
|
|
1669
|
+
} = _ref;
|
|
1762
1670
|
try {
|
|
1763
|
-
|
|
1764
|
-
display
|
|
1765
|
-
components: []
|
|
1671
|
+
const form = {
|
|
1672
|
+
display,
|
|
1673
|
+
components: [...components]
|
|
1766
1674
|
};
|
|
1767
1675
|
return Promise.resolve(_catch(function () {
|
|
1768
1676
|
return Promise.resolve(new FormioFormBuilder__default["default"](el, form, _extends({}, options)).ready).then(function (builder) {
|
|
1769
|
-
|
|
1677
|
+
const handleEvent = event => {
|
|
1770
1678
|
return function () {
|
|
1771
|
-
events[event] && events[event]
|
|
1679
|
+
events[event] && events[event](...[].slice.call(arguments));
|
|
1772
1680
|
if (EVENTS_CHANGE.includes(event)) {
|
|
1773
1681
|
onChange(builder.form.components);
|
|
1774
1682
|
}
|
|
1775
1683
|
};
|
|
1776
1684
|
};
|
|
1777
|
-
EVENTS.forEach(
|
|
1778
|
-
return builder.on(event, callLast(handleEvent(event), 200));
|
|
1779
|
-
});
|
|
1685
|
+
EVENTS.forEach(event => builder.on(event, callLast(handleEvent(event), 200)));
|
|
1780
1686
|
return builder;
|
|
1781
1687
|
});
|
|
1782
1688
|
}, function (er) {
|
|
@@ -1787,91 +1693,88 @@ var createBuilder = function createBuilder(el, _ref2) {
|
|
|
1787
1693
|
}
|
|
1788
1694
|
};
|
|
1789
1695
|
Components__default["default"].setComponents(AllComponents__default["default"]);
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
_this.builderRef = void 0;
|
|
1799
|
-
_this.state = {
|
|
1696
|
+
const EVENTS = ["addComponent", "updateComponent", "removeComponent", "saveComponent", "cancelComponent", "moveComponent", "editComponent", "editJson", "copyComponent", "pasteComponent"];
|
|
1697
|
+
const EVENTS_CHANGE = ["addComponent", "saveComponent", "updateComponent", "removeComponent"];
|
|
1698
|
+
class FormBuilder extends React__default["default"].Component {
|
|
1699
|
+
constructor(props) {
|
|
1700
|
+
super(props);
|
|
1701
|
+
this.elRef = void 0;
|
|
1702
|
+
this.builderRef = void 0;
|
|
1703
|
+
this.state = {
|
|
1800
1704
|
display: props.display,
|
|
1801
1705
|
components: cloneDeep__default["default"](props.components)
|
|
1802
1706
|
};
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
return _this;
|
|
1707
|
+
this.elRef = null;
|
|
1708
|
+
this.builderRef = null;
|
|
1806
1709
|
}
|
|
1807
|
-
|
|
1808
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
1710
|
+
componentDidMount() {
|
|
1809
1711
|
try {
|
|
1810
|
-
|
|
1811
|
-
return Promise.resolve(
|
|
1712
|
+
const _this = this;
|
|
1713
|
+
return Promise.resolve(_this.create(_this.props)).then(function () {});
|
|
1812
1714
|
} catch (e) {
|
|
1813
1715
|
return Promise.reject(e);
|
|
1814
1716
|
}
|
|
1815
|
-
}
|
|
1816
|
-
|
|
1717
|
+
}
|
|
1718
|
+
create(props) {
|
|
1817
1719
|
try {
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1720
|
+
const _this2 = this;
|
|
1721
|
+
const {
|
|
1722
|
+
options,
|
|
1723
|
+
display,
|
|
1724
|
+
components,
|
|
1725
|
+
onAddComponent,
|
|
1726
|
+
onUpdateComponent,
|
|
1727
|
+
onRemoveComponent,
|
|
1728
|
+
onSaveComponent,
|
|
1729
|
+
onCancelComponent,
|
|
1730
|
+
onMoveComponent,
|
|
1731
|
+
onEditComponent,
|
|
1732
|
+
onEditJson,
|
|
1733
|
+
onCopyComponent,
|
|
1734
|
+
onPasteComponent
|
|
1735
|
+
} = props;
|
|
1736
|
+
return Promise.resolve(createBuilder(_this2.elRef.firstChild, {
|
|
1737
|
+
display,
|
|
1834
1738
|
options: _extends({}, options),
|
|
1835
1739
|
components: cloneDeep__default["default"](components),
|
|
1836
|
-
onChange:
|
|
1740
|
+
onChange: _this2.whenComponentsChange.bind(_this2),
|
|
1837
1741
|
events: {
|
|
1838
|
-
onAddComponent
|
|
1839
|
-
onUpdateComponent
|
|
1840
|
-
onRemoveComponent
|
|
1841
|
-
onSaveComponent
|
|
1842
|
-
onCancelComponent
|
|
1843
|
-
onMoveComponent
|
|
1844
|
-
onEditComponent
|
|
1845
|
-
onEditJson
|
|
1846
|
-
onCopyComponent
|
|
1847
|
-
onPasteComponent
|
|
1742
|
+
onAddComponent,
|
|
1743
|
+
onUpdateComponent,
|
|
1744
|
+
onRemoveComponent,
|
|
1745
|
+
onSaveComponent,
|
|
1746
|
+
onCancelComponent,
|
|
1747
|
+
onMoveComponent,
|
|
1748
|
+
onEditComponent,
|
|
1749
|
+
onEditJson,
|
|
1750
|
+
onCopyComponent,
|
|
1751
|
+
onPasteComponent
|
|
1848
1752
|
}
|
|
1849
1753
|
})).then(function (_createBuilder) {
|
|
1850
|
-
|
|
1754
|
+
_this2.builderRef = _createBuilder;
|
|
1851
1755
|
});
|
|
1852
1756
|
} catch (e) {
|
|
1853
1757
|
return Promise.reject(e);
|
|
1854
1758
|
}
|
|
1855
|
-
}
|
|
1856
|
-
|
|
1759
|
+
}
|
|
1760
|
+
componentWillUnmount() {
|
|
1857
1761
|
var _this$builderRef;
|
|
1858
1762
|
(_this$builderRef = this.builderRef) == null ? void 0 : _this$builderRef.destroy();
|
|
1859
1763
|
}
|
|
1860
1764
|
// eslint-disable-next-line react/no-deprecated
|
|
1861
|
-
|
|
1862
|
-
_proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
|
1765
|
+
componentWillReceiveProps(nextProps) {
|
|
1863
1766
|
try {
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
if (
|
|
1867
|
-
|
|
1868
|
-
if (nextProps.display !==
|
|
1869
|
-
return Promise.resolve(
|
|
1767
|
+
const _this3 = this;
|
|
1768
|
+
const _temp2 = function () {
|
|
1769
|
+
if (_this3.builderRef) {
|
|
1770
|
+
const _temp = function () {
|
|
1771
|
+
if (nextProps.display !== _this3.state.display) {
|
|
1772
|
+
return Promise.resolve(_this3.create(_extends({}, _this3.props, {
|
|
1870
1773
|
display: nextProps.display
|
|
1871
1774
|
}))).then(function () {});
|
|
1872
|
-
} else if (nextProps.components !==
|
|
1873
|
-
|
|
1874
|
-
display:
|
|
1775
|
+
} else if (nextProps.components !== _this3.state.components) {
|
|
1776
|
+
_this3.builderRef.form = {
|
|
1777
|
+
display: _this3.state.display,
|
|
1875
1778
|
components: nextProps.components
|
|
1876
1779
|
};
|
|
1877
1780
|
}
|
|
@@ -1883,29 +1786,24 @@ var FormBuilder = /*#__PURE__*/function (_React$Component) {
|
|
|
1883
1786
|
} catch (e) {
|
|
1884
1787
|
return Promise.reject(e);
|
|
1885
1788
|
}
|
|
1886
|
-
}
|
|
1887
|
-
|
|
1888
|
-
var _this5 = this;
|
|
1789
|
+
}
|
|
1790
|
+
whenComponentsChange(components) {
|
|
1889
1791
|
this.setState({
|
|
1890
|
-
components
|
|
1891
|
-
},
|
|
1892
|
-
var
|
|
1893
|
-
((
|
|
1792
|
+
components
|
|
1793
|
+
}, () => {
|
|
1794
|
+
var _this$props;
|
|
1795
|
+
((_this$props = this.props) == null ? void 0 : _this$props.onChange) && this.props.onChange(components);
|
|
1894
1796
|
});
|
|
1895
|
-
}
|
|
1896
|
-
|
|
1897
|
-
var _this6 = this;
|
|
1797
|
+
}
|
|
1798
|
+
render() {
|
|
1898
1799
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1899
|
-
ref:
|
|
1900
|
-
|
|
1800
|
+
ref: ref => {
|
|
1801
|
+
this.elRef = ref;
|
|
1901
1802
|
},
|
|
1902
|
-
onClick:
|
|
1903
|
-
return e.stopPropagation();
|
|
1904
|
-
}
|
|
1803
|
+
onClick: e => e.stopPropagation()
|
|
1905
1804
|
}, /*#__PURE__*/React__default["default"].createElement("div", null));
|
|
1906
|
-
}
|
|
1907
|
-
|
|
1908
|
-
}(React__default["default"].Component);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1909
1807
|
FormBuilder.defaultProps = {
|
|
1910
1808
|
options: {},
|
|
1911
1809
|
onChange: noop__default["default"],
|
|
@@ -1930,46 +1828,45 @@ FormBuilder.propTypes = {
|
|
|
1930
1828
|
};
|
|
1931
1829
|
|
|
1932
1830
|
function useTooltip(options) {
|
|
1933
|
-
|
|
1934
|
-
React.useEffect(
|
|
1831
|
+
const ref = React$1.useRef();
|
|
1832
|
+
React$1.useEffect(() => {
|
|
1935
1833
|
ref.current && new Tooltip__default["default"](ref.current, options);
|
|
1936
1834
|
}, [ref, options]);
|
|
1937
1835
|
return ref;
|
|
1938
1836
|
}
|
|
1939
1837
|
|
|
1940
1838
|
function FormEditCTAs(_ref) {
|
|
1941
|
-
|
|
1942
|
-
saveText =
|
|
1943
|
-
disabled
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
t =
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
var copyTooltipRef = useTooltip({
|
|
1839
|
+
let {
|
|
1840
|
+
saveText = "Save",
|
|
1841
|
+
disabled,
|
|
1842
|
+
options = {},
|
|
1843
|
+
onCopy,
|
|
1844
|
+
hasUndo,
|
|
1845
|
+
hasRedo,
|
|
1846
|
+
onUndo,
|
|
1847
|
+
onRedo,
|
|
1848
|
+
onReset,
|
|
1849
|
+
onSubmit
|
|
1850
|
+
} = _ref;
|
|
1851
|
+
const {
|
|
1852
|
+
i18n: t = t => t
|
|
1853
|
+
} = options;
|
|
1854
|
+
const copyTooltipRef = useTooltip({
|
|
1958
1855
|
trigger: "hover",
|
|
1959
1856
|
placement: "top",
|
|
1960
1857
|
title: t("Copy")
|
|
1961
1858
|
});
|
|
1962
|
-
|
|
1859
|
+
const undoTooltipRef = useTooltip({
|
|
1963
1860
|
trigger: "hover",
|
|
1964
1861
|
placement: "top",
|
|
1965
1862
|
title: t("Undo last change")
|
|
1966
1863
|
});
|
|
1967
|
-
|
|
1864
|
+
const redoTooltipRef = useTooltip({
|
|
1968
1865
|
trigger: "hover",
|
|
1969
1866
|
placement: "top",
|
|
1970
1867
|
title: t("Redo last change")
|
|
1971
1868
|
});
|
|
1972
|
-
|
|
1869
|
+
const resetTooltipRef = useTooltip({
|
|
1973
1870
|
trigger: "hover",
|
|
1974
1871
|
placement: "top",
|
|
1975
1872
|
title: t("Reset all changes")
|
|
@@ -1979,40 +1876,30 @@ function FormEditCTAs(_ref) {
|
|
|
1979
1876
|
}, /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
1980
1877
|
className: "btn btn-primary btn-save flex " + (disabled ? "disabled" : ""),
|
|
1981
1878
|
disabled: disabled,
|
|
1982
|
-
onClick:
|
|
1983
|
-
return !disabled && onSubmit && onSubmit();
|
|
1984
|
-
}
|
|
1879
|
+
onClick: () => !disabled && onSubmit && onSubmit()
|
|
1985
1880
|
}, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
1986
1881
|
className: "mr-1 " + iconClass(options.iconset, "save")
|
|
1987
1882
|
}), saveText), /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
1988
1883
|
className: "btn btn-light btn-undo " + (hasUndo ? "" : "disabled"),
|
|
1989
|
-
onClick:
|
|
1990
|
-
return onUndo && onUndo();
|
|
1991
|
-
},
|
|
1884
|
+
onClick: () => onUndo && onUndo(),
|
|
1992
1885
|
ref: undoTooltipRef
|
|
1993
1886
|
}, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
1994
1887
|
className: iconClass(options.iconset, "undo")
|
|
1995
1888
|
})), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
1996
1889
|
className: "btn btn-light btn-redo " + (hasRedo ? "" : "disabled"),
|
|
1997
|
-
onClick:
|
|
1998
|
-
return onRedo && onRedo();
|
|
1999
|
-
},
|
|
1890
|
+
onClick: () => onRedo && onRedo(),
|
|
2000
1891
|
ref: redoTooltipRef
|
|
2001
1892
|
}, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
2002
1893
|
className: iconClass(options.iconset, "redo")
|
|
2003
1894
|
}))), /*#__PURE__*/React__default["default"].createElement("div", null, onCopy && /*#__PURE__*/React__default["default"].createElement("button", {
|
|
2004
1895
|
className: "btn btn-light",
|
|
2005
|
-
onClick:
|
|
2006
|
-
return onCopy();
|
|
2007
|
-
},
|
|
1896
|
+
onClick: () => onCopy(),
|
|
2008
1897
|
ref: copyTooltipRef
|
|
2009
1898
|
}, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
2010
1899
|
className: iconClass(options.iconset, "copy")
|
|
2011
1900
|
})), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
2012
1901
|
className: "btn btn-light btn-reset",
|
|
2013
|
-
onClick:
|
|
2014
|
-
return onReset && onReset();
|
|
2015
|
-
},
|
|
1902
|
+
onClick: () => onReset && onReset(),
|
|
2016
1903
|
ref: resetTooltipRef
|
|
2017
1904
|
}, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
2018
1905
|
className: iconClass(options.iconset, "reset")
|
|
@@ -2029,35 +1916,34 @@ FormEditCTAs.propTypes = {
|
|
|
2029
1916
|
onReset: PropTypes__default["default"].func
|
|
2030
1917
|
};
|
|
2031
1918
|
|
|
2032
|
-
|
|
1919
|
+
const _excluded$5 = ["name", "value", "label", "onChange", "required", "description", "prefix", "suffix"];
|
|
2033
1920
|
function InputTags(_ref) {
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
1921
|
+
let {
|
|
1922
|
+
name,
|
|
1923
|
+
value = [],
|
|
1924
|
+
label,
|
|
1925
|
+
onChange,
|
|
1926
|
+
required,
|
|
1927
|
+
description,
|
|
1928
|
+
prefix,
|
|
1929
|
+
suffix
|
|
1930
|
+
} = _ref,
|
|
2043
1931
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
2044
|
-
|
|
2045
|
-
React.useEffect(
|
|
2046
|
-
|
|
1932
|
+
const ref = React$1.useRef();
|
|
1933
|
+
React$1.useEffect(() => {
|
|
1934
|
+
const instance = new Choices__default["default"](ref.current, {
|
|
2047
1935
|
delimiter: ",",
|
|
2048
1936
|
editItems: true,
|
|
2049
1937
|
removeItemButton: true
|
|
2050
1938
|
});
|
|
2051
1939
|
instance.setValue([].concat(value, []));
|
|
2052
|
-
instance.passedElement.element.addEventListener("addItem",
|
|
1940
|
+
instance.passedElement.element.addEventListener("addItem", event => {
|
|
2053
1941
|
onChange && onChange(name, uniq__default["default"](value.concat(event.detail.value)));
|
|
2054
1942
|
});
|
|
2055
|
-
instance.passedElement.element.addEventListener("removeItem",
|
|
2056
|
-
onChange && onChange(name, value.filter(
|
|
2057
|
-
return v !== event.detail.value;
|
|
2058
|
-
}));
|
|
1943
|
+
instance.passedElement.element.addEventListener("removeItem", event => {
|
|
1944
|
+
onChange && onChange(name, value.filter(v => v !== event.detail.value));
|
|
2059
1945
|
});
|
|
2060
|
-
return
|
|
1946
|
+
return () => {
|
|
2061
1947
|
instance.destroy();
|
|
2062
1948
|
};
|
|
2063
1949
|
}, []);
|
|
@@ -2084,7 +1970,7 @@ InputTags.propTypes = {
|
|
|
2084
1970
|
onChange: PropTypes__default["default"].func
|
|
2085
1971
|
};
|
|
2086
1972
|
|
|
2087
|
-
|
|
1973
|
+
const defaultDisplayChoices = [{
|
|
2088
1974
|
label: "Form",
|
|
2089
1975
|
value: "form"
|
|
2090
1976
|
}, {
|
|
@@ -2095,21 +1981,17 @@ var defaultDisplayChoices = [{
|
|
|
2095
1981
|
value: "pdf"
|
|
2096
1982
|
}];
|
|
2097
1983
|
function FormParameters(_ref) {
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
enableTags =
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
readonly = _ref$readonly === void 0 ? {} : _ref$readonly,
|
|
2110
|
-
_ref$baseUrl = _ref.baseUrl,
|
|
2111
|
-
baseUrl = _ref$baseUrl === void 0 ? window.location.origin : _ref$baseUrl;
|
|
2112
|
-
var hasTypeChoices = typeChoices && typeChoices.length > 1;
|
|
1984
|
+
let {
|
|
1985
|
+
onChange,
|
|
1986
|
+
form,
|
|
1987
|
+
enableTags = true,
|
|
1988
|
+
typeChoices = [],
|
|
1989
|
+
displayChoices = defaultDisplayChoices,
|
|
1990
|
+
className = "",
|
|
1991
|
+
readonly = {},
|
|
1992
|
+
baseUrl = window.location.origin
|
|
1993
|
+
} = _ref;
|
|
1994
|
+
const hasTypeChoices = typeChoices && typeChoices.length > 1;
|
|
2113
1995
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2114
1996
|
className: "form-edit__settings " + className
|
|
2115
1997
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -2187,9 +2069,7 @@ FormParameters.propTypes = {
|
|
|
2187
2069
|
className: PropTypes__default["default"].string
|
|
2188
2070
|
};
|
|
2189
2071
|
|
|
2190
|
-
|
|
2191
|
-
return !isEqual__default["default"](form, value);
|
|
2192
|
-
};
|
|
2072
|
+
const hasChanged = (form, value) => !isEqual__default["default"](form, value);
|
|
2193
2073
|
function createInitialState(props) {
|
|
2194
2074
|
return {
|
|
2195
2075
|
past: [],
|
|
@@ -2198,40 +2078,44 @@ function createInitialState(props) {
|
|
|
2198
2078
|
original: cloneDeep__default["default"](props.form)
|
|
2199
2079
|
};
|
|
2200
2080
|
}
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2081
|
+
const reducer = (state, _ref) => {
|
|
2082
|
+
let {
|
|
2083
|
+
type,
|
|
2084
|
+
value
|
|
2085
|
+
} = _ref;
|
|
2086
|
+
const {
|
|
2087
|
+
past,
|
|
2088
|
+
current,
|
|
2089
|
+
future
|
|
2090
|
+
} = state;
|
|
2091
|
+
const update = newValue => {
|
|
2208
2092
|
if (newValue.title !== state.current.title && !state.current._id) {
|
|
2209
2093
|
newValue.name = camelCase__default["default"](value.title);
|
|
2210
2094
|
newValue.path = camelCase__default["default"](value.title).toLowerCase();
|
|
2211
2095
|
}
|
|
2212
2096
|
return _extends({}, state, {
|
|
2213
|
-
past: [
|
|
2097
|
+
past: [...past, cloneDeep__default["default"](current)],
|
|
2214
2098
|
current: newValue
|
|
2215
2099
|
});
|
|
2216
2100
|
};
|
|
2217
2101
|
switch (type) {
|
|
2218
2102
|
case "undo":
|
|
2219
2103
|
if (past.length) {
|
|
2220
|
-
|
|
2221
|
-
|
|
2104
|
+
const previous = past[past.length - 1];
|
|
2105
|
+
const newPast = past.slice(0, past.length - 1);
|
|
2222
2106
|
return _extends({}, state, {
|
|
2223
2107
|
past: newPast,
|
|
2224
2108
|
current: cloneDeep__default["default"](previous),
|
|
2225
|
-
future: [cloneDeep__default["default"](current)]
|
|
2109
|
+
future: [cloneDeep__default["default"](current), ...future]
|
|
2226
2110
|
});
|
|
2227
2111
|
}
|
|
2228
2112
|
break;
|
|
2229
2113
|
case "redo":
|
|
2230
2114
|
if (future.length) {
|
|
2231
|
-
|
|
2232
|
-
|
|
2115
|
+
const next = future[0];
|
|
2116
|
+
const newFuture = future.slice(1);
|
|
2233
2117
|
return _extends({}, state, {
|
|
2234
|
-
past: [
|
|
2118
|
+
past: [...past, cloneDeep__default["default"](current)],
|
|
2235
2119
|
current: cloneDeep__default["default"](next),
|
|
2236
2120
|
future: newFuture
|
|
2237
2121
|
});
|
|
@@ -2241,7 +2125,7 @@ var reducer = function reducer(state, _ref) {
|
|
|
2241
2125
|
return update(cloneDeep__default["default"](state.original));
|
|
2242
2126
|
case "formChange":
|
|
2243
2127
|
// eslint-disable-next-line no-case-declarations
|
|
2244
|
-
|
|
2128
|
+
const newValue = _extends({}, state.current, value);
|
|
2245
2129
|
if (hasChanged(state.current, newValue)) {
|
|
2246
2130
|
return update(newValue);
|
|
2247
2131
|
}
|
|
@@ -2258,23 +2142,22 @@ var reducer = function reducer(state, _ref) {
|
|
|
2258
2142
|
};
|
|
2259
2143
|
|
|
2260
2144
|
function useFormEdit(props) {
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
var onSubmit = function onSubmit() {
|
|
2145
|
+
const [{
|
|
2146
|
+
current,
|
|
2147
|
+
future,
|
|
2148
|
+
past
|
|
2149
|
+
}, dispatchFormAction] = React$1.useReducer(reducer, createInitialState(props));
|
|
2150
|
+
const onSubmit = () => {
|
|
2268
2151
|
if (props.onSubmit && typeof props.onSubmit === "function") {
|
|
2269
2152
|
props.onSubmit(current);
|
|
2270
2153
|
}
|
|
2271
2154
|
};
|
|
2272
|
-
|
|
2155
|
+
const onCopy = () => {
|
|
2273
2156
|
if (props.onSubmit && typeof props.onCopy === "function") {
|
|
2274
2157
|
props.onCopy(current);
|
|
2275
2158
|
}
|
|
2276
2159
|
};
|
|
2277
|
-
React.useEffect(
|
|
2160
|
+
React$1.useEffect(() => {
|
|
2278
2161
|
if (props.form && (current._id !== props.form._id || current.modified !== props.form.modified)) {
|
|
2279
2162
|
dispatchFormAction({
|
|
2280
2163
|
type: "replaceForm",
|
|
@@ -2282,7 +2165,7 @@ function useFormEdit(props) {
|
|
|
2282
2165
|
});
|
|
2283
2166
|
}
|
|
2284
2167
|
}, [props.form]);
|
|
2285
|
-
|
|
2168
|
+
const formChange = newForm => {
|
|
2286
2169
|
if (hasChanged(current, _extends({}, current, newForm))) {
|
|
2287
2170
|
dispatchFormAction({
|
|
2288
2171
|
type: "formChange",
|
|
@@ -2290,57 +2173,54 @@ function useFormEdit(props) {
|
|
|
2290
2173
|
});
|
|
2291
2174
|
}
|
|
2292
2175
|
};
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
});
|
|
2307
|
-
};
|
|
2308
|
-
var setChange = function setChange(path, value) {
|
|
2309
|
-
var _extends2;
|
|
2310
|
-
formChange(_extends({}, current, (_extends2 = {}, _extends2[path] = value, _extends2)));
|
|
2176
|
+
const redo = () => dispatchFormAction({
|
|
2177
|
+
type: "redo"
|
|
2178
|
+
});
|
|
2179
|
+
const undo = () => dispatchFormAction({
|
|
2180
|
+
type: "undo"
|
|
2181
|
+
});
|
|
2182
|
+
const reset = () => dispatchFormAction({
|
|
2183
|
+
type: "reset"
|
|
2184
|
+
});
|
|
2185
|
+
const setChange = (path, value) => {
|
|
2186
|
+
formChange(_extends({}, current, {
|
|
2187
|
+
[path]: value
|
|
2188
|
+
}));
|
|
2311
2189
|
};
|
|
2312
2190
|
return {
|
|
2313
2191
|
form: cloneDeep__default["default"](current),
|
|
2314
|
-
redo
|
|
2315
|
-
undo
|
|
2316
|
-
reset
|
|
2192
|
+
redo,
|
|
2193
|
+
undo,
|
|
2194
|
+
reset,
|
|
2317
2195
|
hasChanged: !!past.length,
|
|
2318
2196
|
isValid: current.title && current.name && current.path,
|
|
2319
2197
|
hasUndo: !!past.length,
|
|
2320
2198
|
hasRedo: !!future.length,
|
|
2321
|
-
onSubmit
|
|
2322
|
-
onCopy
|
|
2323
|
-
formChange
|
|
2324
|
-
setChange
|
|
2199
|
+
onSubmit,
|
|
2200
|
+
onCopy,
|
|
2201
|
+
formChange,
|
|
2202
|
+
setChange
|
|
2325
2203
|
};
|
|
2326
2204
|
}
|
|
2327
2205
|
|
|
2328
2206
|
function FormEdit(props) {
|
|
2329
|
-
|
|
2330
|
-
form
|
|
2331
|
-
isValid
|
|
2332
|
-
setChange
|
|
2333
|
-
hasRedo
|
|
2334
|
-
hasChanged
|
|
2335
|
-
hasUndo
|
|
2336
|
-
redo
|
|
2337
|
-
undo
|
|
2338
|
-
reset
|
|
2339
|
-
onSubmit
|
|
2340
|
-
onCopy
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2207
|
+
const {
|
|
2208
|
+
form,
|
|
2209
|
+
isValid,
|
|
2210
|
+
setChange,
|
|
2211
|
+
hasRedo,
|
|
2212
|
+
hasChanged,
|
|
2213
|
+
hasUndo,
|
|
2214
|
+
redo,
|
|
2215
|
+
undo,
|
|
2216
|
+
reset,
|
|
2217
|
+
onSubmit,
|
|
2218
|
+
onCopy
|
|
2219
|
+
} = useFormEdit(props);
|
|
2220
|
+
const {
|
|
2221
|
+
options = {},
|
|
2222
|
+
builder
|
|
2223
|
+
} = props;
|
|
2344
2224
|
return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2345
2225
|
className: "form-edit"
|
|
2346
2226
|
}, /*#__PURE__*/React__default["default"].createElement(FormParameters, _extends({}, props, {
|
|
@@ -2366,7 +2246,7 @@ function FormEdit(props) {
|
|
|
2366
2246
|
display: form.display,
|
|
2367
2247
|
options: options,
|
|
2368
2248
|
builder: builder,
|
|
2369
|
-
onChange:
|
|
2249
|
+
onChange: components => {
|
|
2370
2250
|
setChange("components", components);
|
|
2371
2251
|
}
|
|
2372
2252
|
}));
|
|
@@ -2455,60 +2335,55 @@ function submissionToFormSettings(form, submission) {
|
|
|
2455
2335
|
}
|
|
2456
2336
|
|
|
2457
2337
|
function useFormSettings(_ref) {
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
options
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
var onChange = function onChange(_ref2) {
|
|
2472
|
-
var data = _ref2.data,
|
|
2473
|
-
isValid = _ref2.isValid;
|
|
2338
|
+
let {
|
|
2339
|
+
form: formDefinition,
|
|
2340
|
+
onSubmit = noop__default["default"],
|
|
2341
|
+
options
|
|
2342
|
+
} = _ref;
|
|
2343
|
+
const form = getFormSettingsSchema();
|
|
2344
|
+
const [isValid, setIsValid] = React$1.useState(true);
|
|
2345
|
+
const [submission, setSubmission] = React$1.useState(() => formSettingsToSubmission(formDefinition));
|
|
2346
|
+
const onChange = _ref2 => {
|
|
2347
|
+
let {
|
|
2348
|
+
data,
|
|
2349
|
+
isValid
|
|
2350
|
+
} = _ref2;
|
|
2474
2351
|
if (isValid) {
|
|
2475
2352
|
setSubmission({
|
|
2476
|
-
data
|
|
2353
|
+
data
|
|
2477
2354
|
});
|
|
2478
2355
|
}
|
|
2479
2356
|
setIsValid(isValid);
|
|
2480
2357
|
};
|
|
2481
|
-
React.useEffect(
|
|
2482
|
-
|
|
2358
|
+
React$1.useEffect(() => {
|
|
2359
|
+
const input = formSettingsToSubmission(formDefinition);
|
|
2483
2360
|
if (formDefinition != null && formDefinition._id && !isEqual__default["default"](submission.data, input.data)) {
|
|
2484
2361
|
setSubmission(input);
|
|
2485
2362
|
}
|
|
2486
2363
|
}, [formDefinition == null ? void 0 : formDefinition._id]);
|
|
2487
2364
|
return {
|
|
2488
|
-
options
|
|
2489
|
-
form
|
|
2365
|
+
options,
|
|
2366
|
+
form,
|
|
2490
2367
|
type: formDefinition.type,
|
|
2491
|
-
submission
|
|
2492
|
-
onChange
|
|
2493
|
-
isValid
|
|
2494
|
-
setIsValid
|
|
2495
|
-
onSubmit:
|
|
2496
|
-
|
|
2368
|
+
submission,
|
|
2369
|
+
onChange,
|
|
2370
|
+
isValid,
|
|
2371
|
+
setIsValid,
|
|
2372
|
+
onSubmit: () => {
|
|
2373
|
+
onSubmit(submissionToFormSettings(formDefinition, submission));
|
|
2497
2374
|
}
|
|
2498
2375
|
};
|
|
2499
2376
|
}
|
|
2500
2377
|
function FormSettings(props) {
|
|
2501
|
-
|
|
2502
|
-
form
|
|
2503
|
-
submission
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
return f;
|
|
2511
|
-
};
|
|
2378
|
+
const {
|
|
2379
|
+
form,
|
|
2380
|
+
submission,
|
|
2381
|
+
options = {},
|
|
2382
|
+
onChange,
|
|
2383
|
+
onSubmit,
|
|
2384
|
+
isValid
|
|
2385
|
+
} = useFormSettings(props);
|
|
2386
|
+
const i18n = options.i18n || (f => f);
|
|
2512
2387
|
return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement(Form, {
|
|
2513
2388
|
form: form,
|
|
2514
2389
|
submission: submission,
|
|
@@ -2524,36 +2399,38 @@ function FormSettings(props) {
|
|
|
2524
2399
|
}
|
|
2525
2400
|
|
|
2526
2401
|
function useSelectColumnFilter(props) {
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2402
|
+
const {
|
|
2403
|
+
column
|
|
2404
|
+
} = props;
|
|
2405
|
+
const {
|
|
2406
|
+
id,
|
|
2407
|
+
preFilteredRows
|
|
2408
|
+
} = column;
|
|
2409
|
+
const {
|
|
2410
|
+
choices: customChoices
|
|
2411
|
+
} = column;
|
|
2412
|
+
const {
|
|
2413
|
+
filterValue,
|
|
2414
|
+
setFilter
|
|
2415
|
+
} = column;
|
|
2416
|
+
const choices = (() => {
|
|
2534
2417
|
if (customChoices) {
|
|
2535
2418
|
if (typeof customChoices === "function") {
|
|
2536
2419
|
return customChoices(props);
|
|
2537
2420
|
}
|
|
2538
2421
|
return customChoices;
|
|
2539
2422
|
}
|
|
2540
|
-
return [
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
label: value,
|
|
2547
|
-
value: value
|
|
2548
|
-
};
|
|
2549
|
-
});
|
|
2550
|
-
}();
|
|
2551
|
-
var onChange = function onChange(_, value) {
|
|
2423
|
+
return [...new Set(preFilteredRows.map(row => row.values[id]))].filter(value => value).map(value => ({
|
|
2424
|
+
label: value,
|
|
2425
|
+
value
|
|
2426
|
+
}));
|
|
2427
|
+
})();
|
|
2428
|
+
const onChange = (_, value) => {
|
|
2552
2429
|
setFilter(value || undefined);
|
|
2553
2430
|
};
|
|
2554
2431
|
return {
|
|
2555
2432
|
value: filterValue,
|
|
2556
|
-
onChange
|
|
2433
|
+
onChange,
|
|
2557
2434
|
choices: [{
|
|
2558
2435
|
value: "",
|
|
2559
2436
|
label: "All"
|
|
@@ -2561,10 +2438,11 @@ function useSelectColumnFilter(props) {
|
|
|
2561
2438
|
};
|
|
2562
2439
|
}
|
|
2563
2440
|
function SelectColumnFilter(props) {
|
|
2564
|
-
|
|
2565
|
-
value
|
|
2566
|
-
choices
|
|
2567
|
-
onChange
|
|
2441
|
+
const {
|
|
2442
|
+
value,
|
|
2443
|
+
choices,
|
|
2444
|
+
onChange
|
|
2445
|
+
} = useSelectColumnFilter(props);
|
|
2568
2446
|
return /*#__PURE__*/React__default["default"].createElement(Select, {
|
|
2569
2447
|
key: "filter-" + props.column.id,
|
|
2570
2448
|
name: "filter-" + props.column.id,
|
|
@@ -2691,7 +2569,7 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
2691
2569
|
if (Array.prototype.some) {
|
|
2692
2570
|
some = Array.prototype.some;
|
|
2693
2571
|
} else {
|
|
2694
|
-
some = function
|
|
2572
|
+
some = function (fun) {
|
|
2695
2573
|
var t = Object(this),
|
|
2696
2574
|
len = t.length >>> 0,
|
|
2697
2575
|
i;
|
|
@@ -2904,7 +2782,7 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
2904
2782
|
if (Object.keys) {
|
|
2905
2783
|
keys = Object.keys;
|
|
2906
2784
|
} else {
|
|
2907
|
-
keys = function
|
|
2785
|
+
keys = function (obj) {
|
|
2908
2786
|
var i,
|
|
2909
2787
|
res = [];
|
|
2910
2788
|
for (i in obj) {
|
|
@@ -2945,7 +2823,7 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
2945
2823
|
function addFormatToken(token, padded, ordinal, callback) {
|
|
2946
2824
|
var func = callback;
|
|
2947
2825
|
if (typeof callback === 'string') {
|
|
2948
|
-
func = function
|
|
2826
|
+
func = function () {
|
|
2949
2827
|
return this[callback]();
|
|
2950
2828
|
};
|
|
2951
2829
|
}
|
|
@@ -3248,7 +3126,7 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
3248
3126
|
token = [token];
|
|
3249
3127
|
}
|
|
3250
3128
|
if (isNumber(callback)) {
|
|
3251
|
-
func = function
|
|
3129
|
+
func = function (input, array) {
|
|
3252
3130
|
array[callback] = toInt(input);
|
|
3253
3131
|
};
|
|
3254
3132
|
}
|
|
@@ -3284,7 +3162,7 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
3284
3162
|
if (Array.prototype.indexOf) {
|
|
3285
3163
|
indexOf = Array.prototype.indexOf;
|
|
3286
3164
|
} else {
|
|
3287
|
-
indexOf = function
|
|
3165
|
+
indexOf = function (o) {
|
|
3288
3166
|
// I know
|
|
3289
3167
|
var i;
|
|
3290
3168
|
for (i = 0; i < this.length; ++i) {
|
|
@@ -5046,7 +4924,7 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
5046
4924
|
var args = [].slice.call(arguments, 0);
|
|
5047
4925
|
return pickBy('isAfter', args);
|
|
5048
4926
|
}
|
|
5049
|
-
var now = function
|
|
4927
|
+
var now = function () {
|
|
5050
4928
|
return Date.now ? Date.now() : +new Date();
|
|
5051
4929
|
};
|
|
5052
4930
|
var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond'];
|
|
@@ -6479,8 +6357,8 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
6479
6357
|
proto.toDate = toDate;
|
|
6480
6358
|
proto.toISOString = toISOString;
|
|
6481
6359
|
proto.inspect = inspect;
|
|
6482
|
-
if (typeof Symbol !== 'undefined' && Symbol
|
|
6483
|
-
proto[Symbol
|
|
6360
|
+
if (typeof Symbol !== 'undefined' && Symbol.for != null) {
|
|
6361
|
+
proto[Symbol.for('nodejs.util.inspect.custom')] = function () {
|
|
6484
6362
|
return 'Moment<' + this.format() + '>';
|
|
6485
6363
|
};
|
|
6486
6364
|
}
|
|
@@ -6665,7 +6543,7 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
6665
6543
|
abbr: 'BC'
|
|
6666
6544
|
}],
|
|
6667
6545
|
dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
|
|
6668
|
-
ordinal: function
|
|
6546
|
+
ordinal: function (number) {
|
|
6669
6547
|
var b = number % 10,
|
|
6670
6548
|
output = toInt(number % 100 / 10) === 1 ? 'th' : b === 1 ? 'st' : b === 2 ? 'nd' : b === 3 ? 'rd' : 'th';
|
|
6671
6549
|
return number + output;
|
|
@@ -7107,9 +6985,12 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
7107
6985
|
});
|
|
7108
6986
|
|
|
7109
6987
|
function FormsCell(props) {
|
|
7110
|
-
|
|
7111
|
-
icon =
|
|
7112
|
-
|
|
6988
|
+
const {
|
|
6989
|
+
icon = "server",
|
|
6990
|
+
row: {
|
|
6991
|
+
original: form
|
|
6992
|
+
}
|
|
6993
|
+
} = props;
|
|
7113
6994
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7114
6995
|
className: "p-1"
|
|
7115
6996
|
}, /*#__PURE__*/React__default["default"].createElement("h4", {
|
|
@@ -7126,40 +7007,37 @@ function FormsCell(props) {
|
|
|
7126
7007
|
className: "badge bg-light mr-1"
|
|
7127
7008
|
}, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
7128
7009
|
className: classnames__default["default"](iconClass(undefined, "history"), "mr-1")
|
|
7129
|
-
}), /*#__PURE__*/React__default["default"].createElement("span", null, "Updated ", moment(form.modified).fromNow())), (form.tags || []).map(
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
}), tag);
|
|
7140
|
-
}))));
|
|
7010
|
+
}), /*#__PURE__*/React__default["default"].createElement("span", null, "Updated ", moment(form.modified).fromNow())), (form.tags || []).map((tag, index) => /*#__PURE__*/React__default["default"].createElement("button", {
|
|
7011
|
+
key: index,
|
|
7012
|
+
className: "badge badge-hover bg-secondary mr-1",
|
|
7013
|
+
onClick: stopPropagationWrapper(() => {
|
|
7014
|
+
props.setFilter("tags", tag);
|
|
7015
|
+
props.gotoPage(0);
|
|
7016
|
+
})
|
|
7017
|
+
}, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
7018
|
+
className: classnames__default["default"](iconClass(undefined, "tags"), "mr-1")
|
|
7019
|
+
}), tag)))));
|
|
7141
7020
|
}
|
|
7142
7021
|
|
|
7143
|
-
|
|
7022
|
+
const _excluded$4 = ["Cell"];
|
|
7144
7023
|
function FormsTable(_ref) {
|
|
7145
|
-
|
|
7024
|
+
let {
|
|
7025
|
+
Cell
|
|
7026
|
+
} = _ref,
|
|
7146
7027
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
7147
|
-
|
|
7148
|
-
i18n =
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
var columns = [{
|
|
7028
|
+
const {
|
|
7029
|
+
i18n = f => f,
|
|
7030
|
+
tags
|
|
7031
|
+
} = props;
|
|
7032
|
+
const FormCell = Cell || FormsCell;
|
|
7033
|
+
const columns = [{
|
|
7154
7034
|
Header: i18n("Title"),
|
|
7155
7035
|
accessor: "title",
|
|
7156
7036
|
id: "title",
|
|
7157
|
-
Cell:
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
}));
|
|
7162
|
-
},
|
|
7037
|
+
Cell: props => /*#__PURE__*/React__default["default"].createElement(FormCell, _extends({}, props, {
|
|
7038
|
+
icon: props.icon,
|
|
7039
|
+
i18n: i18n
|
|
7040
|
+
})),
|
|
7163
7041
|
Filter: DefaultColumnFilter,
|
|
7164
7042
|
colspan: 2
|
|
7165
7043
|
}, {
|
|
@@ -7167,13 +7045,11 @@ function FormsTable(_ref) {
|
|
|
7167
7045
|
accessor: "tags",
|
|
7168
7046
|
id: "tags",
|
|
7169
7047
|
hidden: true,
|
|
7170
|
-
Filter:
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
})) : /*#__PURE__*/React__default["default"].createElement(DefaultColumnFilter, props);
|
|
7176
|
-
}
|
|
7048
|
+
Filter: props => tags && tags.length ? /*#__PURE__*/React__default["default"].createElement(SelectColumnFilter, _extends({}, props, {
|
|
7049
|
+
column: _extends({}, props.columns, {
|
|
7050
|
+
choices: tags
|
|
7051
|
+
})
|
|
7052
|
+
})) : /*#__PURE__*/React__default["default"].createElement(DefaultColumnFilter, props)
|
|
7177
7053
|
}];
|
|
7178
7054
|
return /*#__PURE__*/React__default["default"].createElement(Table, _extends({}, props, {
|
|
7179
7055
|
columns: columns
|
|
@@ -7181,13 +7057,12 @@ function FormsTable(_ref) {
|
|
|
7181
7057
|
}
|
|
7182
7058
|
|
|
7183
7059
|
function Loader(_ref) {
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
color =
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
className = _ref$className === void 0 ? "" : _ref$className;
|
|
7060
|
+
let {
|
|
7061
|
+
isActive,
|
|
7062
|
+
color = "blue",
|
|
7063
|
+
icon = "radio-circle",
|
|
7064
|
+
className = ""
|
|
7065
|
+
} = _ref;
|
|
7191
7066
|
if (isActive) {
|
|
7192
7067
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7193
7068
|
className: classnames__default["default"]("opacity-85 z-20 flex items-center justify-center p-5 absolute top-0 right-0 left-0 bottom-0 bg-white", className)
|
|
@@ -7206,48 +7081,43 @@ Loader.propTypes = {
|
|
|
7206
7081
|
className: PropTypes__default["default"].string
|
|
7207
7082
|
};
|
|
7208
7083
|
|
|
7209
|
-
|
|
7084
|
+
const _excluded$3 = ["show", "children", "closeModal", "onClose", "title", "footer", "style", "className"];
|
|
7210
7085
|
function useModal() {
|
|
7211
|
-
|
|
7212
|
-
show = _useState[0],
|
|
7213
|
-
setShowModal = _useState[1];
|
|
7086
|
+
const [show, setShowModal] = React$1.useState(false);
|
|
7214
7087
|
return {
|
|
7215
|
-
show
|
|
7216
|
-
setShowModal
|
|
7217
|
-
openModal
|
|
7088
|
+
show,
|
|
7089
|
+
setShowModal,
|
|
7090
|
+
openModal() {
|
|
7218
7091
|
setShowModal(true);
|
|
7219
7092
|
},
|
|
7220
|
-
closeModal
|
|
7093
|
+
closeModal() {
|
|
7221
7094
|
setShowModal(false);
|
|
7222
7095
|
}
|
|
7223
7096
|
};
|
|
7224
7097
|
}
|
|
7225
7098
|
function Modal(_ref) {
|
|
7226
|
-
|
|
7227
|
-
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
className = _ref$className === void 0 ? "" : _ref$className,
|
|
7099
|
+
let {
|
|
7100
|
+
show,
|
|
7101
|
+
children,
|
|
7102
|
+
closeModal = noop__default$1["default"],
|
|
7103
|
+
onClose = noop__default$1["default"],
|
|
7104
|
+
title,
|
|
7105
|
+
footer: ModalFooter,
|
|
7106
|
+
style,
|
|
7107
|
+
className = ""
|
|
7108
|
+
} = _ref,
|
|
7237
7109
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
setMaxHeight = _useState2[1];
|
|
7243
|
-
var onClickClose = function onClickClose() {
|
|
7110
|
+
const titleRef = React$1.useRef();
|
|
7111
|
+
const footerRef = React$1.useRef();
|
|
7112
|
+
const [maxHeight, setMaxHeight] = React$1.useState();
|
|
7113
|
+
const onClickClose = () => {
|
|
7244
7114
|
closeModal();
|
|
7245
7115
|
onClose();
|
|
7246
7116
|
};
|
|
7247
|
-
React.useEffect(
|
|
7117
|
+
React$1.useEffect(() => {
|
|
7248
7118
|
if (titleRef.current || footerRef.current) {
|
|
7249
7119
|
var _titleRef$current, _footerRef$current;
|
|
7250
|
-
|
|
7120
|
+
const height = ((titleRef == null ? void 0 : (_titleRef$current = titleRef.current) == null ? void 0 : _titleRef$current.offsetHeight) || 0) + ((footerRef == null ? void 0 : (_footerRef$current = footerRef.current) == null ? void 0 : _footerRef$current.offsetHeight) || 0);
|
|
7251
7121
|
setMaxHeight("calc(85vh - " + height + "px)");
|
|
7252
7122
|
} else {
|
|
7253
7123
|
setMaxHeight("auto");
|
|
@@ -7274,7 +7144,7 @@ function Modal(_ref) {
|
|
|
7274
7144
|
}, title) : null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7275
7145
|
className: "formio-dialog-body",
|
|
7276
7146
|
style: {
|
|
7277
|
-
maxHeight
|
|
7147
|
+
maxHeight
|
|
7278
7148
|
},
|
|
7279
7149
|
"data-testid": "modalBody"
|
|
7280
7150
|
}, show && children), ModalFooter ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -7292,16 +7162,15 @@ function Modal(_ref) {
|
|
|
7292
7162
|
})));
|
|
7293
7163
|
}
|
|
7294
7164
|
|
|
7295
|
-
|
|
7165
|
+
const _excluded$2 = ["maxWidth", "children"];
|
|
7296
7166
|
function RemoveModalFooter(_ref) {
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
i18n =
|
|
7303
|
-
|
|
7304
|
-
} : _ref$i18n;
|
|
7167
|
+
let {
|
|
7168
|
+
value,
|
|
7169
|
+
valueToCompare,
|
|
7170
|
+
onSubmit,
|
|
7171
|
+
onClose,
|
|
7172
|
+
i18n = f => f
|
|
7173
|
+
} = _ref;
|
|
7305
7174
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7306
7175
|
className: "flex items-center justify-center bg-white p-2"
|
|
7307
7176
|
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
@@ -7312,7 +7181,7 @@ function RemoveModalFooter(_ref) {
|
|
|
7312
7181
|
disabled: valueToCompare !== value,
|
|
7313
7182
|
"data-testid": "customSubmitModal",
|
|
7314
7183
|
className: "btn btn-danger mx-2",
|
|
7315
|
-
onClick:
|
|
7184
|
+
onClick: e => {
|
|
7316
7185
|
if (valueToCompare === value) {
|
|
7317
7186
|
onSubmit(e);
|
|
7318
7187
|
}
|
|
@@ -7323,21 +7192,19 @@ function RemoveModalFooter(_ref) {
|
|
|
7323
7192
|
}
|
|
7324
7193
|
function RemoveModal(_ref2) {
|
|
7325
7194
|
var _props$itemType, _props$itemType2;
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7195
|
+
let {
|
|
7196
|
+
maxWidth = "300px",
|
|
7197
|
+
children
|
|
7198
|
+
} = _ref2,
|
|
7329
7199
|
props = _objectWithoutPropertiesLoose(_ref2, _excluded$2);
|
|
7330
|
-
|
|
7331
|
-
i18n =
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
var _useState = React.useState(),
|
|
7335
|
-
value = _useState[0],
|
|
7336
|
-
setValue = _useState[1];
|
|
7200
|
+
const {
|
|
7201
|
+
i18n = f => f
|
|
7202
|
+
} = props;
|
|
7203
|
+
const [value, setValue] = React$1.useState();
|
|
7337
7204
|
return /*#__PURE__*/React__default["default"].createElement(Modal, _extends({}, props, {
|
|
7338
7205
|
className: classnames__default["default"](props.className, "formio-dialog-theme-remove"),
|
|
7339
7206
|
style: {
|
|
7340
|
-
maxWidth
|
|
7207
|
+
maxWidth
|
|
7341
7208
|
},
|
|
7342
7209
|
title: "Drop " + ((_props$itemType = props.itemType) == null ? void 0 : _props$itemType.toLowerCase()),
|
|
7343
7210
|
value: value,
|
|
@@ -7349,69 +7216,65 @@ function RemoveModal(_ref2) {
|
|
|
7349
7216
|
}, children, i18n("To drop"), " ", /*#__PURE__*/React__default["default"].createElement("strong", null, props.valueToCompare), ",\xA0", i18n("type the"), "\xA0", /*#__PURE__*/React__default["default"].createElement("strong", null, "\"", (_props$itemType2 = props.itemType) == null ? void 0 : _props$itemType2.toLowerCase(), "\""), "\xA0", i18n("name"), " ", /*#__PURE__*/React__default["default"].createElement("strong", null, "\"", props.valueToCompare, "\""), "."), /*#__PURE__*/React__default["default"].createElement(InputText, {
|
|
7350
7217
|
name: "remove",
|
|
7351
7218
|
value: value,
|
|
7352
|
-
onChange:
|
|
7353
|
-
return setValue(value);
|
|
7354
|
-
}
|
|
7219
|
+
onChange: (name, value) => setValue(value)
|
|
7355
7220
|
})));
|
|
7356
7221
|
}
|
|
7357
7222
|
|
|
7358
|
-
|
|
7359
|
-
_inheritsLoose(ReactComponent, _Components$component);
|
|
7223
|
+
class ReactComponent extends formiojs.Components.components.field {
|
|
7360
7224
|
/**
|
|
7361
7225
|
* This is the first phase of component building where the component is instantiated.
|
|
7362
7226
|
*
|
|
7363
7227
|
* @param component - The component definition created from the settings form.
|
|
7364
7228
|
* @param options - Any options passed into the renderer.
|
|
7365
7229
|
* @param data - The submission data where this component's data exists.
|
|
7366
|
-
*/
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
_this.shouldSetValue = void 0;
|
|
7373
|
-
_this.dataForSetting = void 0;
|
|
7230
|
+
*/ // eslint-disable-next-line no-useless-constructor,import/no-anonymous-default-export
|
|
7231
|
+
constructor(component, options, data) {
|
|
7232
|
+
super(component, options, data);
|
|
7233
|
+
this.reactInstance = void 0;
|
|
7234
|
+
this.shouldSetValue = void 0;
|
|
7235
|
+
this.dataForSetting = void 0;
|
|
7374
7236
|
/**
|
|
7375
7237
|
* The user has changed the value in the component and the value needs to be updated on the main submission object and other components notified of a change event.
|
|
7376
7238
|
*
|
|
7377
7239
|
* @param value
|
|
7378
7240
|
* @param flags
|
|
7379
7241
|
*/
|
|
7380
|
-
|
|
7242
|
+
this.updateValue = (value, flags) => {
|
|
7381
7243
|
flags = flags || {};
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7244
|
+
const newValue = value === undefined || value === null ? this.getValue() : value;
|
|
7245
|
+
const changed = newValue !== undefined ? this.hasChanged(newValue, this.dataValue) : false;
|
|
7246
|
+
this.dataValue = Array.isArray(newValue) ? [...newValue] : newValue;
|
|
7247
|
+
this.updateOnChange(flags, changed);
|
|
7386
7248
|
return changed;
|
|
7387
7249
|
};
|
|
7388
|
-
return _this;
|
|
7389
7250
|
}
|
|
7390
|
-
|
|
7251
|
+
get $reactNode() {
|
|
7252
|
+
return this.refs["react-" + this.id];
|
|
7253
|
+
}
|
|
7391
7254
|
/**
|
|
7392
7255
|
* This method is called any time the component needs to be rebuilt. It is most frequently used to listen to other
|
|
7393
7256
|
* components using the this.on() function.
|
|
7394
7257
|
*/
|
|
7395
|
-
|
|
7396
|
-
return
|
|
7258
|
+
init() {
|
|
7259
|
+
return super.init();
|
|
7397
7260
|
}
|
|
7398
7261
|
/**
|
|
7399
7262
|
* This method is called before the component is going to be destroyed, which is when the component instance is
|
|
7400
7263
|
* destroyed. This is different from detach which is when the component instance still exists but the dom instance is
|
|
7401
7264
|
* removed.
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
return
|
|
7265
|
+
*/
|
|
7266
|
+
destroy() {
|
|
7267
|
+
return super.destroy();
|
|
7405
7268
|
}
|
|
7406
7269
|
/**
|
|
7407
7270
|
* The second phase of component building where the component is rendered as an HTML string.
|
|
7408
7271
|
*
|
|
7409
7272
|
* @returns {string} - The return is the full string of the component
|
|
7410
|
-
|
|
7411
|
-
|
|
7273
|
+
*/
|
|
7274
|
+
render() {
|
|
7412
7275
|
// For react components, we simply render as a div which will become the react instance.
|
|
7413
7276
|
// By calling super.render(string) it will wrap the component with the needed wrappers to make it a full component.
|
|
7414
|
-
return
|
|
7277
|
+
return super.render("<div ref=\"react-" + this.id + "\"></div>");
|
|
7415
7278
|
}
|
|
7416
7279
|
/**
|
|
7417
7280
|
* The third phase of component building where the component has been attached to the DOM as 'element' and is ready
|
|
@@ -7419,22 +7282,24 @@ var ReactComponent = /*#__PURE__*/function (_Components$component) {
|
|
|
7419
7282
|
*
|
|
7420
7283
|
* @param element
|
|
7421
7284
|
* @returns {Promise<void>} - Return a promise that resolves when the attach is complete.
|
|
7422
|
-
|
|
7423
|
-
|
|
7285
|
+
*/
|
|
7286
|
+
attach(element) {
|
|
7424
7287
|
try {
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7288
|
+
const _super$attach = super.attach,
|
|
7289
|
+
_this = this;
|
|
7290
|
+
_super$attach.call(_this, element);
|
|
7428
7291
|
// The loadRefs function will find all dom elements that have the "ref" setting that match the object property.
|
|
7429
7292
|
// It can load a single element or multiple elements with the same ref.
|
|
7430
|
-
|
|
7293
|
+
_this.loadRefs(element, {
|
|
7294
|
+
["react-" + _this.id]: "single"
|
|
7295
|
+
});
|
|
7431
7296
|
// @ts-ignore
|
|
7432
|
-
if (
|
|
7297
|
+
if (_this.refs["react-" + _this.id]) {
|
|
7433
7298
|
// @ts-ignore
|
|
7434
|
-
|
|
7435
|
-
if (
|
|
7436
|
-
|
|
7437
|
-
|
|
7299
|
+
_this.reactInstance = _this.attachReact(_this.refs["react-" + _this.id]);
|
|
7300
|
+
if (_this.shouldSetValue) {
|
|
7301
|
+
_this.setValue(_this.dataForSetting);
|
|
7302
|
+
_this.updateValue(_this.dataForSetting);
|
|
7438
7303
|
}
|
|
7439
7304
|
}
|
|
7440
7305
|
return Promise.resolve();
|
|
@@ -7446,19 +7311,18 @@ var ReactComponent = /*#__PURE__*/function (_Components$component) {
|
|
|
7446
7311
|
* The fourth phase of component building where the component is being removed from the page. This could be a redraw
|
|
7447
7312
|
* or it is being removed from the form.
|
|
7448
7313
|
*/
|
|
7449
|
-
|
|
7450
|
-
_proto.detach = function detach() {
|
|
7314
|
+
detach() {
|
|
7451
7315
|
// @ts-ignore
|
|
7452
7316
|
if (this.refs["react-" + this.id]) {
|
|
7453
7317
|
// @ts-ignore
|
|
7454
7318
|
this.detachReact(this.refs["react-" + this.id]);
|
|
7455
7319
|
}
|
|
7456
|
-
|
|
7320
|
+
super.detach();
|
|
7457
7321
|
}
|
|
7458
7322
|
/**
|
|
7459
7323
|
* Override this function to render a react component.
|
|
7460
|
-
|
|
7461
|
-
|
|
7324
|
+
*/
|
|
7325
|
+
renderReact() {
|
|
7462
7326
|
return null;
|
|
7463
7327
|
}
|
|
7464
7328
|
/**
|
|
@@ -7467,8 +7331,7 @@ var ReactComponent = /*#__PURE__*/function (_Components$component) {
|
|
|
7467
7331
|
* @param element
|
|
7468
7332
|
*/
|
|
7469
7333
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
7470
|
-
|
|
7471
|
-
_proto.attachReact = function attachReact(element) {
|
|
7334
|
+
attachReact(element) {
|
|
7472
7335
|
// eslint-disable-next-line react/no-render-return-value
|
|
7473
7336
|
return ReactDOM__default["default"].render(this.renderReact(), element);
|
|
7474
7337
|
}
|
|
@@ -7476,8 +7339,7 @@ var ReactComponent = /*#__PURE__*/function (_Components$component) {
|
|
|
7476
7339
|
* Override this function.
|
|
7477
7340
|
*/
|
|
7478
7341
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
7479
|
-
|
|
7480
|
-
_proto.detachReact = function detachReact(element) {
|
|
7342
|
+
detachReact(element) {
|
|
7481
7343
|
if (element) {
|
|
7482
7344
|
ReactDOM__default["default"].unmountComponentAtNode(element);
|
|
7483
7345
|
}
|
|
@@ -7487,8 +7349,8 @@ var ReactComponent = /*#__PURE__*/function (_Components$component) {
|
|
|
7487
7349
|
*
|
|
7488
7350
|
* @param value
|
|
7489
7351
|
* @param flags
|
|
7490
|
-
|
|
7491
|
-
|
|
7352
|
+
*/
|
|
7353
|
+
setValue(value, flags) {
|
|
7492
7354
|
if (this.reactInstance) {
|
|
7493
7355
|
this.reactInstance.setState({
|
|
7494
7356
|
value: value
|
|
@@ -7499,13 +7361,13 @@ var ReactComponent = /*#__PURE__*/function (_Components$component) {
|
|
|
7499
7361
|
this.dataForSetting = value;
|
|
7500
7362
|
}
|
|
7501
7363
|
return false;
|
|
7502
|
-
}
|
|
7364
|
+
}
|
|
7503
7365
|
/**
|
|
7504
7366
|
* Get the current value of the component. Should return the value set in the react component.
|
|
7505
7367
|
*
|
|
7506
7368
|
* @returns {*}
|
|
7507
7369
|
*/
|
|
7508
|
-
|
|
7370
|
+
getValue() {
|
|
7509
7371
|
if (this.reactInstance) {
|
|
7510
7372
|
return this.reactInstance.state.value;
|
|
7511
7373
|
}
|
|
@@ -7518,38 +7380,29 @@ var ReactComponent = /*#__PURE__*/function (_Components$component) {
|
|
|
7518
7380
|
* @param dirty
|
|
7519
7381
|
* @param rowData
|
|
7520
7382
|
* @returns {boolean}
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7383
|
+
*/
|
|
7384
|
+
checkValidity(data, dirty, rowData) {
|
|
7385
|
+
const valid = super.checkValidity(data, dirty, rowData);
|
|
7524
7386
|
if (!valid) {
|
|
7525
7387
|
return false;
|
|
7526
7388
|
}
|
|
7527
7389
|
return this.validate(data, dirty, rowData);
|
|
7528
7390
|
}
|
|
7529
7391
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7530
|
-
|
|
7531
|
-
_proto.validate = function validate(data, dirty, rowData) {
|
|
7392
|
+
validate(data, dirty, rowData) {
|
|
7532
7393
|
return true;
|
|
7533
|
-
}
|
|
7534
|
-
|
|
7535
|
-
key: "$reactNode",
|
|
7536
|
-
get: function get() {
|
|
7537
|
-
return this.refs["react-" + this.id];
|
|
7538
|
-
}
|
|
7539
|
-
}]);
|
|
7540
|
-
return ReactComponent;
|
|
7541
|
-
}(formiojs.Components.components.field);
|
|
7394
|
+
}
|
|
7395
|
+
}
|
|
7542
7396
|
|
|
7543
7397
|
function DefaultCell(_ref) {
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
render =
|
|
7547
|
-
|
|
7548
|
-
} : _ref$render;
|
|
7398
|
+
let {
|
|
7399
|
+
value,
|
|
7400
|
+
render = f => f
|
|
7401
|
+
} = _ref;
|
|
7549
7402
|
if (value === undefined) {
|
|
7550
7403
|
return /*#__PURE__*/React__default["default"].createElement("span", null);
|
|
7551
7404
|
}
|
|
7552
|
-
|
|
7405
|
+
const rendered = render(value);
|
|
7553
7406
|
if (value !== rendered) {
|
|
7554
7407
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7555
7408
|
dangerouslySetInnerHTML: {
|
|
@@ -7561,21 +7414,17 @@ function DefaultCell(_ref) {
|
|
|
7561
7414
|
}
|
|
7562
7415
|
|
|
7563
7416
|
function mapFormToColumns(form) {
|
|
7564
|
-
|
|
7565
|
-
FormioUtils__default["default"].eachComponent(form.components,
|
|
7417
|
+
const columns = [];
|
|
7418
|
+
FormioUtils__default["default"].eachComponent(form.components, component => {
|
|
7566
7419
|
if (component.tableView && component.key) {
|
|
7567
|
-
|
|
7568
|
-
|
|
7420
|
+
const cmp = formiojs.Components.create(component, {}, null, true);
|
|
7421
|
+
const column = {
|
|
7569
7422
|
Header: component.label || component.title || component.key,
|
|
7570
7423
|
accessor: "data." + component.key,
|
|
7571
7424
|
className: "text-center",
|
|
7572
|
-
Cell:
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
return cmp.asString(value);
|
|
7576
|
-
}
|
|
7577
|
-
}));
|
|
7578
|
-
}
|
|
7425
|
+
Cell: props => /*#__PURE__*/React__default["default"].createElement(DefaultCell, _extends({}, props, {
|
|
7426
|
+
render: value => cmp.asString(value)
|
|
7427
|
+
}))
|
|
7579
7428
|
};
|
|
7580
7429
|
if (component.type === "select" && component.dataSrc === "values") {
|
|
7581
7430
|
column.Filter = SelectColumnFilter;
|
|
@@ -7587,58 +7436,61 @@ function mapFormToColumns(form) {
|
|
|
7587
7436
|
return columns;
|
|
7588
7437
|
}
|
|
7589
7438
|
|
|
7590
|
-
|
|
7439
|
+
const _excluded$1 = ["form"];
|
|
7591
7440
|
function SubmissionsTable(_ref) {
|
|
7592
|
-
|
|
7441
|
+
let {
|
|
7442
|
+
form
|
|
7443
|
+
} = _ref,
|
|
7593
7444
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
7594
|
-
|
|
7445
|
+
const columns = form && mapFormToColumns(form);
|
|
7595
7446
|
return /*#__PURE__*/React__default["default"].createElement(Table, _extends({}, props, {
|
|
7596
7447
|
columns: columns
|
|
7597
7448
|
}));
|
|
7598
7449
|
}
|
|
7599
7450
|
|
|
7600
7451
|
function SliderColumnFilter(_ref) {
|
|
7601
|
-
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7452
|
+
let {
|
|
7453
|
+
column: {
|
|
7454
|
+
filterValue,
|
|
7455
|
+
setFilter,
|
|
7456
|
+
preFilteredRows,
|
|
7457
|
+
id
|
|
7458
|
+
}
|
|
7459
|
+
} = _ref;
|
|
7460
|
+
const [min, max] = React__default["default"].useMemo(() => {
|
|
7461
|
+
let min = preFilteredRows.length ? preFilteredRows[0].values[id] : 0;
|
|
7462
|
+
let max = preFilteredRows.length ? preFilteredRows[0].values[id] : 0;
|
|
7463
|
+
preFilteredRows.forEach(row => {
|
|
7464
|
+
min = Math.min(row == null ? void 0 : row.values[id], min);
|
|
7465
|
+
max = Math.max(row == null ? void 0 : row.values[id], max);
|
|
7466
|
+
});
|
|
7467
|
+
return [min, max];
|
|
7468
|
+
}, [id, preFilteredRows]);
|
|
7617
7469
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("input", {
|
|
7618
7470
|
type: "range",
|
|
7619
7471
|
min: min,
|
|
7620
7472
|
max: max,
|
|
7621
7473
|
value: filterValue || min,
|
|
7622
|
-
onChange:
|
|
7474
|
+
onChange: e => {
|
|
7623
7475
|
setFilter(parseInt(e.target.value, 10));
|
|
7624
7476
|
}
|
|
7625
7477
|
}), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
7626
|
-
onClick:
|
|
7627
|
-
return setFilter(undefined);
|
|
7628
|
-
}
|
|
7478
|
+
onClick: () => setFilter(undefined)
|
|
7629
7479
|
}, "Off"));
|
|
7630
7480
|
}
|
|
7631
7481
|
|
|
7632
|
-
|
|
7482
|
+
const _excluded = ["style", "current", "items", "children", "HeaderChildren", "AddButton", "Button", "className", "onClick", "i18n"];
|
|
7633
7483
|
function ButtonTab(_ref) {
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7484
|
+
let {
|
|
7485
|
+
icon,
|
|
7486
|
+
back,
|
|
7487
|
+
onClick,
|
|
7488
|
+
isActive,
|
|
7489
|
+
reverse,
|
|
7490
|
+
children,
|
|
7491
|
+
className,
|
|
7492
|
+
after
|
|
7493
|
+
} = _ref;
|
|
7642
7494
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7643
7495
|
title: "button-wrapper",
|
|
7644
7496
|
className: classnames__default["default"]("tw-tabs__button-wrapper", isActive ? "-active" : "", back ? "-back" : "", className)
|
|
@@ -7655,21 +7507,18 @@ function ButtonTab(_ref) {
|
|
|
7655
7507
|
}));
|
|
7656
7508
|
}
|
|
7657
7509
|
function Tabs(_ref2) {
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
i18n = _ref2$i18n === void 0 ? function (f) {
|
|
7671
|
-
return f;
|
|
7672
|
-
} : _ref2$i18n,
|
|
7510
|
+
let {
|
|
7511
|
+
style,
|
|
7512
|
+
current,
|
|
7513
|
+
items = [],
|
|
7514
|
+
children,
|
|
7515
|
+
HeaderChildren,
|
|
7516
|
+
AddButton,
|
|
7517
|
+
Button = ButtonTab,
|
|
7518
|
+
className,
|
|
7519
|
+
onClick,
|
|
7520
|
+
i18n = f => f
|
|
7521
|
+
} = _ref2,
|
|
7673
7522
|
additionalProps = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
7674
7523
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7675
7524
|
"data-testid": "tabs-comp",
|
|
@@ -7681,16 +7530,14 @@ function Tabs(_ref2) {
|
|
|
7681
7530
|
className: "tw-tabs__header-wrapper"
|
|
7682
7531
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7683
7532
|
className: "tw-tabs__header-border"
|
|
7684
|
-
}), items.filter(
|
|
7685
|
-
return item.label || item.icon;
|
|
7686
|
-
}).map(function (item, index) {
|
|
7533
|
+
}), items.filter(item => item.label || item.icon).map((item, index) => {
|
|
7687
7534
|
return /*#__PURE__*/React__default["default"].createElement(Button, _extends({
|
|
7688
7535
|
key: index,
|
|
7689
7536
|
back: item.back,
|
|
7690
7537
|
isActive: (current == null ? void 0 : current.action) === item.action,
|
|
7691
7538
|
exact: item.exact,
|
|
7692
|
-
onClick:
|
|
7693
|
-
|
|
7539
|
+
onClick: () => {
|
|
7540
|
+
onClick && onClick(item);
|
|
7694
7541
|
}
|
|
7695
7542
|
}, additionalProps, item), i18n(item.label || ""));
|
|
7696
7543
|
}), AddButton && /*#__PURE__*/React__default["default"].createElement(AddButton, _extends({}, additionalProps, {
|
|
@@ -7704,11 +7551,12 @@ function Tabs(_ref2) {
|
|
|
7704
7551
|
}
|
|
7705
7552
|
|
|
7706
7553
|
function mapPagination(_temp) {
|
|
7707
|
-
|
|
7708
|
-
skip
|
|
7709
|
-
limit
|
|
7710
|
-
serverCount
|
|
7711
|
-
length
|
|
7554
|
+
let {
|
|
7555
|
+
skip,
|
|
7556
|
+
limit,
|
|
7557
|
+
serverCount,
|
|
7558
|
+
length
|
|
7559
|
+
} = _temp === void 0 ? {} : _temp;
|
|
7712
7560
|
skip = skip || 0;
|
|
7713
7561
|
limit = limit || 10;
|
|
7714
7562
|
serverCount = serverCount || length;
|