@tsed/react-formio 2.3.1 → 2.3.3
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/react-component/reactComponent.component.d.ts +1 -1
- 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 +1184 -1334
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +300 -316
- package/dist/index.modern.js.map +1 -1
- package/package.json +13 -9
- 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 +44 -13
- package/src/components/actions-table/actionsTable.component.tsx +2 -1
- package/src/components/actions-table/actionsTable.stories.tsx +71 -289
- package/src/components/form/form.stories.tsx +1 -2
- package/src/components/form-access/formAccess.component.tsx +2 -13
- package/src/components/form-access/formAccess.stories.tsx +55 -49
- package/src/components/form-action/formAction.component.tsx +1 -0
- package/src/components/form-control/formControl.component.tsx +3 -10
- package/src/components/form-edit/formEdit.reducer.ts +0 -1
- package/src/components/form-settings/formSettings.component.spec.tsx +4 -4
- package/src/components/pagination/pagination.component.spec.tsx +0 -2
- package/src/components/react-component/reactComponent.component.tsx +5 -5
- package/src/components/select/select.component.tsx +10 -23
- package/src/components/table/components/defaultCellOperations.component.tsx +17 -4
- package/src/components/table/components/defaultOperationButton.component.tsx +11 -4
- package/src/components/table/components/defaultRow.component.tsx +1 -0
- package/src/components/table/filters/defaultColumnFilter.component.tsx +1 -0
- package/src/components/table/hooks/useOperations.hook.tsx +3 -3
- package/src/react-table.d.ts +2 -0
- package/dist/package.json +0 -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,20 +596,22 @@ 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);
|
|
670
613
|
}, [id, setValue, setFilterId, setFilter]);
|
|
614
|
+
/* eslint-disable jsx-a11y/no-autofocus */
|
|
671
615
|
return /*#__PURE__*/React__default["default"].createElement(InputText, {
|
|
672
616
|
size: "sm",
|
|
673
617
|
id: id,
|
|
@@ -680,74 +624,72 @@ function DefaultColumnFilter(props) {
|
|
|
680
624
|
});
|
|
681
625
|
}
|
|
682
626
|
|
|
683
|
-
|
|
684
|
-
myArray = []
|
|
685
|
-
|
|
686
|
-
myArray[index1] = _ref[0];
|
|
687
|
-
myArray[index2] = _ref[1];
|
|
627
|
+
const swapElements = (myArray, index1, index2) => {
|
|
628
|
+
myArray = [...myArray];
|
|
629
|
+
[myArray[index1], myArray[index2]] = [myArray[index2], myArray[index1]];
|
|
688
630
|
return myArray;
|
|
689
631
|
};
|
|
690
632
|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
fn();
|
|
695
|
-
};
|
|
633
|
+
const stopPropagationWrapper = fn => event => {
|
|
634
|
+
event.stopPropagation();
|
|
635
|
+
fn();
|
|
696
636
|
};
|
|
697
637
|
|
|
638
|
+
const _excluded$b = ["className", "buttonSize", "buttonType", "buttonOutline", "onClick", "action", "icon", "title", "i18n", "data", "ctx"];
|
|
698
639
|
function DefaultOperationButton(props) {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
return /*#__PURE__*/React__default["default"].createElement("button", {
|
|
640
|
+
const {
|
|
641
|
+
className = "btn",
|
|
642
|
+
buttonSize = "xs",
|
|
643
|
+
buttonType = "primary",
|
|
644
|
+
buttonOutline,
|
|
645
|
+
onClick,
|
|
646
|
+
action,
|
|
647
|
+
icon = "",
|
|
648
|
+
title = "",
|
|
649
|
+
i18n = f => f
|
|
650
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
651
|
+
|
|
652
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
653
|
+
} = props,
|
|
654
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$b);
|
|
655
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, otherProps, {
|
|
656
|
+
"aria-label": "Operation button: " + (title || action),
|
|
717
657
|
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", {
|
|
658
|
+
onClick: stopPropagationWrapper(() => onClick(action))
|
|
659
|
+
}), icon ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("i", {
|
|
722
660
|
className: iconClass(undefined, icon)
|
|
723
|
-
}), " ", title && " ") : null, title && /*#__PURE__*/
|
|
661
|
+
}), " ", title && " ") : null, title && /*#__PURE__*/React.createElement("span", {
|
|
724
662
|
className: icon && title ? "ml-1" : ""
|
|
725
663
|
}, i18n(title)));
|
|
726
664
|
}
|
|
727
665
|
|
|
728
|
-
|
|
666
|
+
const _excluded$a = ["OperationButton"];
|
|
729
667
|
function DefaultCellOperations(_ref) {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
668
|
+
let {
|
|
669
|
+
operations,
|
|
670
|
+
row,
|
|
671
|
+
onClick,
|
|
672
|
+
ctx,
|
|
673
|
+
i18n
|
|
674
|
+
} = _ref;
|
|
675
|
+
const data = row.original;
|
|
736
676
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
737
677
|
className: "btn-group"
|
|
738
|
-
}, operations.filter(
|
|
739
|
-
|
|
678
|
+
}, operations.filter(_ref2 => {
|
|
679
|
+
let {
|
|
680
|
+
permissionsResolver
|
|
681
|
+
} = _ref2;
|
|
740
682
|
return !permissionsResolver || permissionsResolver(data, ctx);
|
|
741
|
-
}).map(
|
|
742
|
-
|
|
743
|
-
|
|
683
|
+
}).map((_ref3, index) => {
|
|
684
|
+
let {
|
|
685
|
+
OperationButton = DefaultOperationButton
|
|
686
|
+
} = _ref3,
|
|
744
687
|
operation = _objectWithoutPropertiesLoose(_ref3, _excluded$a);
|
|
745
688
|
return /*#__PURE__*/React__default["default"].createElement(OperationButton, _extends({
|
|
746
689
|
key: operation.action
|
|
747
690
|
}, operation, {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
},
|
|
691
|
+
"data-testid": "operation-" + index + "-" + operation.action,
|
|
692
|
+
onClick: action => onClick(data, action),
|
|
751
693
|
data: data,
|
|
752
694
|
i18n: i18n,
|
|
753
695
|
ctx: ctx
|
|
@@ -756,47 +698,39 @@ function DefaultCellOperations(_ref) {
|
|
|
756
698
|
}
|
|
757
699
|
|
|
758
700
|
function useOperations(_ref) {
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
CellOperations =
|
|
762
|
-
onClick
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
return function (hooks) {
|
|
769
|
-
hooks.visibleColumns.push(function (columns) {
|
|
701
|
+
let {
|
|
702
|
+
operations,
|
|
703
|
+
CellOperations = DefaultCellOperations,
|
|
704
|
+
onClick,
|
|
705
|
+
i18n = f => f,
|
|
706
|
+
ctx
|
|
707
|
+
} = _ref;
|
|
708
|
+
return hooks => {
|
|
709
|
+
hooks.visibleColumns.push(columns => {
|
|
770
710
|
if (!operations.length) {
|
|
771
711
|
return columns;
|
|
772
712
|
}
|
|
773
|
-
return [
|
|
713
|
+
return [...columns, {
|
|
774
714
|
id: "operations",
|
|
775
715
|
groupByBoundary: true,
|
|
776
|
-
Header:
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
i18n: i18n
|
|
787
|
-
}));
|
|
788
|
-
}
|
|
789
|
-
}]);
|
|
716
|
+
Header: () => /*#__PURE__*/React__default["default"].createElement("div", {
|
|
717
|
+
className: "text-center"
|
|
718
|
+
}, i18n("Operations")),
|
|
719
|
+
Cell: props => /*#__PURE__*/React__default["default"].createElement(CellOperations, _extends({}, props, {
|
|
720
|
+
operations: operations,
|
|
721
|
+
onClick: onClick,
|
|
722
|
+
ctx: ctx,
|
|
723
|
+
i18n: i18n
|
|
724
|
+
}))
|
|
725
|
+
}];
|
|
790
726
|
});
|
|
791
727
|
};
|
|
792
728
|
}
|
|
793
729
|
|
|
794
|
-
|
|
730
|
+
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
731
|
function getOperationCallback(operations, onClick) {
|
|
796
|
-
return
|
|
797
|
-
|
|
798
|
-
return operation.action === action || operation.alias === action;
|
|
799
|
-
});
|
|
732
|
+
return (data, action) => {
|
|
733
|
+
const operation = operations.find(operation => operation.action === action || operation.alias === action);
|
|
800
734
|
if (operation) {
|
|
801
735
|
onClick(data, operation);
|
|
802
736
|
}
|
|
@@ -812,82 +746,61 @@ function DefaultEmptyData() {
|
|
|
812
746
|
className: "text-center p-2 pb-4 font-bold"
|
|
813
747
|
}, "No data found");
|
|
814
748
|
}
|
|
815
|
-
|
|
749
|
+
const hooks = [reactTable.useFilters, reactTable.useGroupBy, reactTable.useSortBy, reactTable.usePagination];
|
|
816
750
|
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,
|
|
751
|
+
const {
|
|
752
|
+
children,
|
|
753
|
+
className = "",
|
|
754
|
+
columns,
|
|
755
|
+
data,
|
|
756
|
+
onChange = noop__default["default"],
|
|
757
|
+
onClick = noop__default["default"],
|
|
758
|
+
onDrag = noop__default["default"],
|
|
759
|
+
onDrop = noop__default["default"],
|
|
760
|
+
operations = [],
|
|
761
|
+
pageSizes = [10, 25, 50, 100],
|
|
762
|
+
filters: controlledFilters,
|
|
763
|
+
filterId: controlledFilterId,
|
|
764
|
+
pageSize: controlledPageSize,
|
|
765
|
+
pageIndex: controlledPageIndex,
|
|
766
|
+
totalLength,
|
|
767
|
+
sortBy: controlledSortBy,
|
|
768
|
+
isLoading,
|
|
769
|
+
disableFilters,
|
|
770
|
+
disablePagination,
|
|
771
|
+
ArrowSort = DefaultArrowSort,
|
|
772
|
+
ColumnFilter = DefaultColumnFilter,
|
|
773
|
+
EmptyData = DefaultEmptyData,
|
|
774
|
+
Loader = DefaultLoader,
|
|
775
|
+
Pagination: Pagination$1 = Pagination,
|
|
776
|
+
Row = DefaultRow,
|
|
777
|
+
CellHeader = DefaultCellHeader,
|
|
778
|
+
CellOperations,
|
|
779
|
+
i18n = f => f
|
|
780
|
+
} = props,
|
|
862
781
|
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];
|
|
782
|
+
const _onClick = getOperationCallback(operations, onClick);
|
|
783
|
+
const defaultColumn = React__default["default"].useMemo(() => ({
|
|
784
|
+
// Let's set up our default Filter UI
|
|
785
|
+
Filter: ColumnFilter,
|
|
786
|
+
ArrowSort
|
|
787
|
+
}), [ColumnFilter, ArrowSort]);
|
|
788
|
+
const [filterId, setFilterId] = React__default["default"].useState(controlledFilterId);
|
|
874
789
|
// DND
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
setRecords = _useState[1];
|
|
878
|
-
React.useEffect(function () {
|
|
790
|
+
const [records, setRecords] = React$1.useState(data);
|
|
791
|
+
React$1.useEffect(() => {
|
|
879
792
|
setRecords(data);
|
|
880
793
|
}, [data]);
|
|
881
|
-
|
|
882
|
-
|
|
794
|
+
const _onDrag = (dragIndex, hoverIndex) => {
|
|
795
|
+
const newRecords = swapElements([...records], dragIndex, hoverIndex);
|
|
883
796
|
setRecords(newRecords);
|
|
884
797
|
onDrag(newRecords);
|
|
885
798
|
};
|
|
886
|
-
|
|
887
|
-
columns
|
|
888
|
-
data
|
|
889
|
-
ctx
|
|
890
|
-
defaultColumn
|
|
799
|
+
const tableInstance = reactTable.useTable(_extends({}, props, {
|
|
800
|
+
columns,
|
|
801
|
+
data,
|
|
802
|
+
ctx,
|
|
803
|
+
defaultColumn,
|
|
891
804
|
// getRowId,
|
|
892
805
|
initialState: _extends({}, props.initialState || {}, {
|
|
893
806
|
filters: controlledFilters || [],
|
|
@@ -898,49 +811,52 @@ function useCustomTable(props) {
|
|
|
898
811
|
manualPagination: props.manualPagination === undefined ? true : props.manualPagination,
|
|
899
812
|
manualSortBy: props.manualSortBy === undefined ? true : props.manualPagination,
|
|
900
813
|
manualFilters: props.manualFilters === undefined ? true : props.manualFilters,
|
|
901
|
-
disableFilters
|
|
902
|
-
filterId
|
|
903
|
-
setFilterId
|
|
904
|
-
})
|
|
905
|
-
operations
|
|
906
|
-
CellOperations
|
|
814
|
+
disableFilters,
|
|
815
|
+
filterId,
|
|
816
|
+
setFilterId
|
|
817
|
+
}), ...hooks, useOperations({
|
|
818
|
+
operations,
|
|
819
|
+
CellOperations,
|
|
907
820
|
onClick: _onClick,
|
|
908
|
-
ctx
|
|
909
|
-
i18n
|
|
910
|
-
})
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
821
|
+
ctx,
|
|
822
|
+
i18n
|
|
823
|
+
}));
|
|
824
|
+
const {
|
|
825
|
+
setPageSize,
|
|
826
|
+
state: {
|
|
827
|
+
pageIndex,
|
|
828
|
+
pageSize,
|
|
829
|
+
sortBy,
|
|
830
|
+
filters
|
|
831
|
+
}
|
|
832
|
+
} = tableInstance;
|
|
833
|
+
React__default["default"].useEffect(() => {
|
|
918
834
|
onChange({
|
|
919
|
-
pageIndex
|
|
920
|
-
pageSize
|
|
921
|
-
sortBy
|
|
922
|
-
filters
|
|
923
|
-
filterId
|
|
835
|
+
pageIndex,
|
|
836
|
+
pageSize,
|
|
837
|
+
sortBy,
|
|
838
|
+
filters,
|
|
839
|
+
filterId
|
|
924
840
|
});
|
|
925
841
|
}, [onChange, pageIndex, pageSize, sortBy, filters, filterId]);
|
|
926
842
|
return {
|
|
927
|
-
className
|
|
928
|
-
tableInstance
|
|
929
|
-
CellHeader
|
|
930
|
-
isLoading
|
|
931
|
-
Loader
|
|
932
|
-
EmptyData
|
|
933
|
-
Row
|
|
934
|
-
data
|
|
935
|
-
disablePagination
|
|
843
|
+
className,
|
|
844
|
+
tableInstance,
|
|
845
|
+
CellHeader,
|
|
846
|
+
isLoading,
|
|
847
|
+
Loader,
|
|
848
|
+
EmptyData,
|
|
849
|
+
Row,
|
|
850
|
+
data,
|
|
851
|
+
disablePagination,
|
|
936
852
|
Pagination: Pagination$1,
|
|
937
|
-
pageIndex
|
|
938
|
-
pageSize
|
|
939
|
-
pageSizes
|
|
940
|
-
totalLength
|
|
941
|
-
setPageSize
|
|
942
|
-
i18n
|
|
943
|
-
children
|
|
853
|
+
pageIndex,
|
|
854
|
+
pageSize,
|
|
855
|
+
pageSizes,
|
|
856
|
+
totalLength,
|
|
857
|
+
setPageSize,
|
|
858
|
+
i18n,
|
|
859
|
+
children,
|
|
944
860
|
onClick: _onClick,
|
|
945
861
|
onDrag: _onDrag,
|
|
946
862
|
onDrop: onDrop,
|
|
@@ -949,28 +865,29 @@ function useCustomTable(props) {
|
|
|
949
865
|
}
|
|
950
866
|
|
|
951
867
|
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
|
|
868
|
+
const {
|
|
869
|
+
className,
|
|
870
|
+
tableInstance,
|
|
871
|
+
CellHeader,
|
|
872
|
+
isLoading,
|
|
873
|
+
onClick,
|
|
874
|
+
Loader,
|
|
875
|
+
EmptyData,
|
|
876
|
+
Row,
|
|
877
|
+
data,
|
|
878
|
+
disablePagination,
|
|
879
|
+
Pagination,
|
|
880
|
+
pageIndex,
|
|
881
|
+
pageSize,
|
|
882
|
+
pageSizes,
|
|
883
|
+
setPageSize,
|
|
884
|
+
totalLength,
|
|
885
|
+
i18n,
|
|
886
|
+
enableDragNDrop,
|
|
887
|
+
children,
|
|
888
|
+
onDrag,
|
|
889
|
+
onDrop
|
|
890
|
+
} = useCustomTable(props);
|
|
974
891
|
// Render the UI for your table
|
|
975
892
|
return /*#__PURE__*/React__default["default"].createElement(DrapNDropContainer, {
|
|
976
893
|
enableDragNDrop: enableDragNDrop
|
|
@@ -978,22 +895,18 @@ function Table(props) {
|
|
|
978
895
|
className: classnames__default["default"]("table-group table-responsive", className)
|
|
979
896
|
}, /*#__PURE__*/React__default["default"].createElement("table", _extends({
|
|
980
897
|
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) {
|
|
898
|
+
}, tableInstance.getTableProps()), /*#__PURE__*/React__default["default"].createElement("thead", null, tableInstance.headerGroups.map((headerGroup, i) => /*#__PURE__*/React__default["default"].createElement("tr", _extends({}, headerGroup.getHeaderGroupProps(), {
|
|
899
|
+
key: "tableInstance.headerGroups" + i
|
|
900
|
+
}), enableDragNDrop ? /*#__PURE__*/React__default["default"].createElement("th", {
|
|
901
|
+
role: "columnheader",
|
|
902
|
+
className: "text-center"
|
|
903
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
904
|
+
className: "table-cell-header"
|
|
905
|
+
})) : null, headerGroup.headers.map(column => /*#__PURE__*/React__default["default"].createElement("th", _extends({}, column.getHeaderProps(), {
|
|
906
|
+
key: "tableInstance.headers.column." + column.id
|
|
907
|
+
}), /*#__PURE__*/React__default["default"].createElement(CellHeader, {
|
|
908
|
+
column: column
|
|
909
|
+
})))))), !isLoading ? /*#__PURE__*/React__default["default"].createElement("tbody", tableInstance.getTableBodyProps(), tableInstance.page.map((row, index) => {
|
|
997
910
|
tableInstance.prepareRow(row);
|
|
998
911
|
return /*#__PURE__*/React__default["default"].createElement(Row, {
|
|
999
912
|
index: index,
|
|
@@ -1017,25 +930,20 @@ function Table(props) {
|
|
|
1017
930
|
}))) : null, children));
|
|
1018
931
|
}
|
|
1019
932
|
|
|
1020
|
-
|
|
933
|
+
const _excluded$8 = ["disableFilters", "disablePagination", "availableActions", "onAddAction"];
|
|
1021
934
|
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,
|
|
935
|
+
let {
|
|
936
|
+
disableFilters = true,
|
|
937
|
+
disablePagination = true,
|
|
938
|
+
availableActions = [],
|
|
939
|
+
onAddAction = noop__default["default"]
|
|
940
|
+
} = _ref,
|
|
1030
941
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
1031
|
-
|
|
1032
|
-
i18n =
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
currentAction = _useState[0],
|
|
1037
|
-
setAction = _useState[1];
|
|
1038
|
-
var columns = [{
|
|
942
|
+
const {
|
|
943
|
+
i18n = f => f
|
|
944
|
+
} = props;
|
|
945
|
+
const [currentAction, setAction] = React$1.useState("");
|
|
946
|
+
const columns = [{
|
|
1039
947
|
Header: i18n("Actions"),
|
|
1040
948
|
accessor: "title",
|
|
1041
949
|
id: "title"
|
|
@@ -1047,24 +955,21 @@ function ActionsTable(_ref) {
|
|
|
1047
955
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1048
956
|
className: "pagination-group"
|
|
1049
957
|
}, /*#__PURE__*/React__default["default"].createElement(Select, {
|
|
958
|
+
"data-testid": "action-table-select",
|
|
1050
959
|
name: "actions",
|
|
1051
960
|
value: currentAction,
|
|
1052
961
|
choices: [{
|
|
1053
962
|
label: i18n("Select an action"),
|
|
1054
963
|
value: ""
|
|
1055
964
|
}].concat(availableActions),
|
|
1056
|
-
onChange:
|
|
1057
|
-
return setAction(action);
|
|
1058
|
-
}
|
|
965
|
+
onChange: (name, action) => setAction(action)
|
|
1059
966
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1060
967
|
className: "pl-3"
|
|
1061
968
|
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
1062
|
-
"data-testid": "
|
|
969
|
+
"data-testid": "action-table-add",
|
|
1063
970
|
disabled: currentAction === "",
|
|
1064
971
|
className: "btn btn-success",
|
|
1065
|
-
onClick:
|
|
1066
|
-
return currentAction && onAddAction(currentAction);
|
|
1067
|
-
},
|
|
972
|
+
onClick: () => currentAction && onAddAction(currentAction),
|
|
1068
973
|
type: "submit"
|
|
1069
974
|
}, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
1070
975
|
className: classnames__default["default"](iconClass(undefined, "plus"), "mr-1")
|
|
@@ -1079,8 +984,8 @@ function formatError(error) {
|
|
|
1079
984
|
return error.map(formatError);
|
|
1080
985
|
}
|
|
1081
986
|
if (Object.prototype.hasOwnProperty.call(error, "errors")) {
|
|
1082
|
-
return Object.keys(error.errors).map(
|
|
1083
|
-
|
|
987
|
+
return Object.keys(error.errors).map((key, index) => {
|
|
988
|
+
const item = error.errors[key];
|
|
1084
989
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1085
990
|
key: index
|
|
1086
991
|
}, /*#__PURE__*/React__default["default"].createElement("strong", null, item.name, " (", item.path, ")"), " ", "- ", item.message);
|
|
@@ -1092,7 +997,7 @@ function formatError(error) {
|
|
|
1092
997
|
}
|
|
1093
998
|
// If this is a joy validation error.
|
|
1094
999
|
if (Object.prototype.hasOwnProperty.call(error, "name") && error.name === "ValidationError") {
|
|
1095
|
-
return error.details.map(
|
|
1000
|
+
return error.details.map((item, index) => {
|
|
1096
1001
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1097
1002
|
key: index
|
|
1098
1003
|
}, item.message);
|
|
@@ -1105,9 +1010,10 @@ function formatError(error) {
|
|
|
1105
1010
|
return "An error occurred. See console logs for details.";
|
|
1106
1011
|
}
|
|
1107
1012
|
function Alert(_ref) {
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
type =
|
|
1013
|
+
let {
|
|
1014
|
+
error,
|
|
1015
|
+
type = "danger"
|
|
1016
|
+
} = _ref;
|
|
1111
1017
|
if (!error || Array.isArray(error) && !error.length) {
|
|
1112
1018
|
return null;
|
|
1113
1019
|
}
|
|
@@ -1118,9 +1024,11 @@ function Alert(_ref) {
|
|
|
1118
1024
|
}
|
|
1119
1025
|
|
|
1120
1026
|
function Card(_ref) {
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1027
|
+
let {
|
|
1028
|
+
children,
|
|
1029
|
+
label,
|
|
1030
|
+
className
|
|
1031
|
+
} = _ref;
|
|
1124
1032
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1125
1033
|
className: classnames__default["default"]("card", className)
|
|
1126
1034
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -1133,7 +1041,7 @@ function Card(_ref) {
|
|
|
1133
1041
|
}, children));
|
|
1134
1042
|
}
|
|
1135
1043
|
|
|
1136
|
-
|
|
1044
|
+
const _excluded$7 = ["src", "form", "options", "submission", "url"];
|
|
1137
1045
|
function _catch$1(body, recover) {
|
|
1138
1046
|
try {
|
|
1139
1047
|
var result = body();
|
|
@@ -1146,21 +1054,21 @@ function _catch$1(body, recover) {
|
|
|
1146
1054
|
return result;
|
|
1147
1055
|
}
|
|
1148
1056
|
function useEvent(event, callback, events) {
|
|
1149
|
-
React.useEffect(
|
|
1057
|
+
React$1.useEffect(() => {
|
|
1150
1058
|
if (callback) {
|
|
1151
1059
|
events.set(event, callback);
|
|
1152
1060
|
}
|
|
1153
1061
|
}, [callback, event, events]);
|
|
1154
1062
|
}
|
|
1155
1063
|
function useEvents(funcs) {
|
|
1156
|
-
|
|
1157
|
-
|
|
1064
|
+
const events = React$1.useRef(new Map());
|
|
1065
|
+
const hasEvent = event => {
|
|
1158
1066
|
return funcs.hasOwnProperty(event) && typeof funcs[event] === "function";
|
|
1159
1067
|
};
|
|
1160
|
-
|
|
1068
|
+
const emit = function (event) {
|
|
1161
1069
|
if (hasEvent(event)) {
|
|
1162
|
-
|
|
1163
|
-
return fn
|
|
1070
|
+
const fn = events.current.has(event) ? events.current.get(event) : funcs[event];
|
|
1071
|
+
return fn(...[].slice.call(arguments, 1));
|
|
1164
1072
|
}
|
|
1165
1073
|
};
|
|
1166
1074
|
useEvent("onBlur", funcs["onBlur"], events.current);
|
|
@@ -1182,17 +1090,17 @@ function useEvents(funcs) {
|
|
|
1182
1090
|
useEvent("onBlur", funcs["onBlur"], events.current);
|
|
1183
1091
|
useEvent("onInitialized", funcs["onInitialized"], events.current);
|
|
1184
1092
|
return {
|
|
1185
|
-
events
|
|
1186
|
-
emit
|
|
1187
|
-
hasEvent
|
|
1093
|
+
events,
|
|
1094
|
+
emit,
|
|
1095
|
+
hasEvent
|
|
1188
1096
|
};
|
|
1189
1097
|
}
|
|
1190
1098
|
function useForm(props) {
|
|
1191
|
-
|
|
1099
|
+
const customValidation = function (submission, callback) {
|
|
1192
1100
|
try {
|
|
1193
|
-
|
|
1101
|
+
const _temp2 = function () {
|
|
1194
1102
|
if (hasEvent("onAsyncSubmit")) {
|
|
1195
|
-
|
|
1103
|
+
const _temp = _catch$1(function () {
|
|
1196
1104
|
return Promise.resolve(emit("onAsyncSubmit", submission, instance.current)).then(function () {});
|
|
1197
1105
|
}, function (err) {
|
|
1198
1106
|
callback((err == null ? void 0 : err.errors) || err);
|
|
@@ -1207,20 +1115,22 @@ function useForm(props) {
|
|
|
1207
1115
|
return Promise.reject(e);
|
|
1208
1116
|
}
|
|
1209
1117
|
};
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1118
|
+
const {
|
|
1119
|
+
src,
|
|
1120
|
+
form,
|
|
1121
|
+
options = {},
|
|
1122
|
+
submission,
|
|
1123
|
+
url
|
|
1124
|
+
} = props,
|
|
1216
1125
|
funcs = _objectWithoutPropertiesLoose(props, _excluded$7);
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
emit
|
|
1222
|
-
hasEvent
|
|
1223
|
-
|
|
1126
|
+
const element = React$1.useRef();
|
|
1127
|
+
const isLoaded = React$1.useRef();
|
|
1128
|
+
const instance = React$1.useRef();
|
|
1129
|
+
const {
|
|
1130
|
+
emit,
|
|
1131
|
+
hasEvent
|
|
1132
|
+
} = useEvents(funcs);
|
|
1133
|
+
const createWebForm = (srcOrForm, options) => {
|
|
1224
1134
|
options = Object.assign({}, options);
|
|
1225
1135
|
srcOrForm = typeof srcOrForm === "string" ? srcOrForm : cloneDeep__default["default"](srcOrForm);
|
|
1226
1136
|
if (!instance.current) {
|
|
@@ -1236,14 +1146,14 @@ function useForm(props) {
|
|
|
1236
1146
|
return;
|
|
1237
1147
|
}
|
|
1238
1148
|
if (event.startsWith("formio.")) {
|
|
1239
|
-
|
|
1149
|
+
const eventName = "on" + event.charAt(7).toUpperCase() + event.slice(8);
|
|
1240
1150
|
if (eventName === "onChange" && !args[0].changed) {
|
|
1241
1151
|
return;
|
|
1242
1152
|
}
|
|
1243
|
-
emit
|
|
1153
|
+
emit(eventName, ...args, instance.current);
|
|
1244
1154
|
}
|
|
1245
1155
|
});
|
|
1246
|
-
instance.current.ready.then(
|
|
1156
|
+
instance.current.ready.then(formio => {
|
|
1247
1157
|
submission && (formio.submission = cloneDeep__default["default"](submission));
|
|
1248
1158
|
if (props.onFormReady) {
|
|
1249
1159
|
props.onFormReady(formio);
|
|
@@ -1253,9 +1163,9 @@ function useForm(props) {
|
|
|
1253
1163
|
}
|
|
1254
1164
|
return instance.current;
|
|
1255
1165
|
};
|
|
1256
|
-
React.useEffect(
|
|
1166
|
+
React$1.useEffect(() => {
|
|
1257
1167
|
if (instance.current) {
|
|
1258
|
-
instance.current.ready.then(
|
|
1168
|
+
instance.current.ready.then(formio => {
|
|
1259
1169
|
if (isEqual__default["default"](formio.submission.data, submission == null ? void 0 : submission.data)) {
|
|
1260
1170
|
return;
|
|
1261
1171
|
}
|
|
@@ -1263,9 +1173,9 @@ function useForm(props) {
|
|
|
1263
1173
|
});
|
|
1264
1174
|
}
|
|
1265
1175
|
}, [submission]);
|
|
1266
|
-
React.useEffect(
|
|
1176
|
+
React$1.useEffect(() => {
|
|
1267
1177
|
if (form && instance.current) {
|
|
1268
|
-
instance.current.ready.then(
|
|
1178
|
+
instance.current.ready.then(formio => {
|
|
1269
1179
|
formio.form = form;
|
|
1270
1180
|
if (url) {
|
|
1271
1181
|
formio.url = url;
|
|
@@ -1273,7 +1183,7 @@ function useForm(props) {
|
|
|
1273
1183
|
});
|
|
1274
1184
|
}
|
|
1275
1185
|
}, [form, url]);
|
|
1276
|
-
React.useEffect(
|
|
1186
|
+
React$1.useEffect(() => {
|
|
1277
1187
|
if (src) {
|
|
1278
1188
|
if (instance.current) {
|
|
1279
1189
|
isLoaded.current = false;
|
|
@@ -1282,24 +1192,25 @@ function useForm(props) {
|
|
|
1282
1192
|
createWebForm(src, options);
|
|
1283
1193
|
}
|
|
1284
1194
|
}, [src]);
|
|
1285
|
-
React.useEffect(
|
|
1195
|
+
React$1.useEffect(() => {
|
|
1286
1196
|
if (form) {
|
|
1287
1197
|
createWebForm(form, options);
|
|
1288
1198
|
}
|
|
1289
|
-
return
|
|
1199
|
+
return () => {
|
|
1290
1200
|
isLoaded.current = false;
|
|
1291
1201
|
instance.current && instance.current.destroy(true);
|
|
1292
1202
|
};
|
|
1293
1203
|
}, []);
|
|
1294
1204
|
return {
|
|
1295
|
-
element
|
|
1205
|
+
element
|
|
1296
1206
|
};
|
|
1297
1207
|
}
|
|
1298
1208
|
|
|
1299
1209
|
formiojs.Components.setComponents(AllComponents__default["default"]);
|
|
1300
1210
|
function Form(props) {
|
|
1301
|
-
|
|
1302
|
-
element
|
|
1211
|
+
const {
|
|
1212
|
+
element
|
|
1213
|
+
} = useForm(props);
|
|
1303
1214
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1304
1215
|
"data-testid": "formioContainer" + (props.name || ""),
|
|
1305
1216
|
ref: element,
|
|
@@ -1309,24 +1220,24 @@ function Form(props) {
|
|
|
1309
1220
|
Form.propTypes = {
|
|
1310
1221
|
name: PropTypes__default["default"].string,
|
|
1311
1222
|
className: PropTypes__default["default"].string,
|
|
1312
|
-
/**
|
|
1313
|
-
*
|
|
1223
|
+
/**
|
|
1224
|
+
*
|
|
1314
1225
|
*/
|
|
1315
1226
|
src: PropTypes__default["default"].string,
|
|
1316
|
-
/**
|
|
1317
|
-
* url to fetch form
|
|
1227
|
+
/**
|
|
1228
|
+
* url to fetch form
|
|
1318
1229
|
*/
|
|
1319
1230
|
url: PropTypes__default["default"].string,
|
|
1320
|
-
/**
|
|
1321
|
-
* Raw form object
|
|
1231
|
+
/**
|
|
1232
|
+
* Raw form object
|
|
1322
1233
|
*/
|
|
1323
1234
|
form: PropTypes__default["default"].object,
|
|
1324
|
-
/**
|
|
1325
|
-
* Data submission
|
|
1235
|
+
/**
|
|
1236
|
+
* Data submission
|
|
1326
1237
|
*/
|
|
1327
1238
|
submission: PropTypes__default["default"].object,
|
|
1328
|
-
/**
|
|
1329
|
-
* Configuration option
|
|
1239
|
+
/**
|
|
1240
|
+
* Configuration option
|
|
1330
1241
|
*/
|
|
1331
1242
|
options: PropTypes__default["default"].shape({
|
|
1332
1243
|
readOnly: PropTypes__default["default"].bool,
|
|
@@ -1358,15 +1269,17 @@ Form.propTypes = {
|
|
|
1358
1269
|
};
|
|
1359
1270
|
|
|
1360
1271
|
function getRoleComponent(_ref) {
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1272
|
+
let {
|
|
1273
|
+
label,
|
|
1274
|
+
key,
|
|
1275
|
+
description,
|
|
1276
|
+
choices,
|
|
1277
|
+
data
|
|
1278
|
+
} = _ref;
|
|
1366
1279
|
return {
|
|
1367
|
-
label
|
|
1368
|
-
key
|
|
1369
|
-
description
|
|
1280
|
+
label,
|
|
1281
|
+
key,
|
|
1282
|
+
description,
|
|
1370
1283
|
type: "select",
|
|
1371
1284
|
labelPosition: "top",
|
|
1372
1285
|
widget: "choicesjs",
|
|
@@ -1396,92 +1309,96 @@ function toDescription(description, hr) {
|
|
|
1396
1309
|
return '<span class="text-sm">' + description + "</span> " + (hr ? '<hr class="mt-6 mb-5 border-gray-200 mx-20"/>' : "");
|
|
1397
1310
|
}
|
|
1398
1311
|
function getSubmissionPermissionForm(_ref2) {
|
|
1399
|
-
|
|
1312
|
+
let {
|
|
1313
|
+
choices
|
|
1314
|
+
} = _ref2;
|
|
1400
1315
|
return {
|
|
1401
1316
|
description: "<strong>Elevated permissions allow users to access and modify other user's entities. Assign with caution.</strong>",
|
|
1402
1317
|
components: [getRoleComponent({
|
|
1403
1318
|
key: "create_own",
|
|
1404
1319
|
label: '<h4 class="text-gray-800">Create Own Submissions</h4>',
|
|
1405
1320
|
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
|
|
1321
|
+
choices
|
|
1407
1322
|
}), getRoleComponent({
|
|
1408
1323
|
key: "create_all",
|
|
1409
1324
|
label: '<h4 class="text-gray-800">Create All Submissions</h4>',
|
|
1410
1325
|
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
|
|
1326
|
+
choices
|
|
1412
1327
|
}), getRoleComponent({
|
|
1413
1328
|
key: "read_own",
|
|
1414
1329
|
label: '<h4 class="text-gray-800">Read Own Submissions</h4>',
|
|
1415
1330
|
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
|
|
1331
|
+
choices
|
|
1417
1332
|
}), getRoleComponent({
|
|
1418
1333
|
key: "read_all",
|
|
1419
1334
|
label: '<h4 class="text-gray-800">Read All Submissions</h4>',
|
|
1420
1335
|
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
|
|
1336
|
+
choices
|
|
1422
1337
|
}), getRoleComponent({
|
|
1423
1338
|
key: "update_own",
|
|
1424
1339
|
label: '<h4 class="text-gray-800">Update Own Submissions</h4>',
|
|
1425
1340
|
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
|
|
1341
|
+
choices
|
|
1427
1342
|
}), getRoleComponent({
|
|
1428
1343
|
key: "update_all",
|
|
1429
1344
|
label: '<h4 class="text-gray-800">Update All Submissions</h4>',
|
|
1430
1345
|
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
|
|
1346
|
+
choices
|
|
1432
1347
|
}), getRoleComponent({
|
|
1433
1348
|
key: "delete_own",
|
|
1434
1349
|
label: '<h4 class="text-gray-800">Delete Own Submissions</h4>',
|
|
1435
1350
|
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
|
|
1351
|
+
choices
|
|
1437
1352
|
}), getRoleComponent({
|
|
1438
1353
|
key: "delete_all",
|
|
1439
1354
|
label: '<h4 class="text-gray-800">Delete All Submissions</h4>',
|
|
1440
1355
|
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
|
|
1356
|
+
choices
|
|
1442
1357
|
})]
|
|
1443
1358
|
};
|
|
1444
1359
|
}
|
|
1445
1360
|
function getAccessPermissionForm(_ref3) {
|
|
1446
|
-
|
|
1361
|
+
let {
|
|
1362
|
+
choices
|
|
1363
|
+
} = _ref3;
|
|
1447
1364
|
return {
|
|
1448
1365
|
description: "<strong>Elevated permissions allow users to access and modify other user's entities. Assign with caution.</strong>",
|
|
1449
1366
|
components: [getRoleComponent({
|
|
1450
1367
|
key: "read_own",
|
|
1451
1368
|
label: '<h4 class="text-gray-800">Read Form Definition (Restricted to owner)</h4>',
|
|
1452
1369
|
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
|
|
1370
|
+
choices
|
|
1454
1371
|
}), getRoleComponent({
|
|
1455
1372
|
key: "read_all",
|
|
1456
1373
|
label: "<h4>Read Form Definition</h4>",
|
|
1457
1374
|
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
|
|
1375
|
+
choices
|
|
1459
1376
|
}), getRoleComponent({
|
|
1460
1377
|
key: "update_own",
|
|
1461
1378
|
label: '<h4 class="text-gray-800">Update Form Definition (Restricted to owner)</h4>',
|
|
1462
1379
|
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
|
|
1380
|
+
choices
|
|
1464
1381
|
}), getRoleComponent({
|
|
1465
1382
|
key: "update_all",
|
|
1466
1383
|
label: '<h4 class="text-gray-800">Update Form Definition</h4>',
|
|
1467
1384
|
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
|
|
1385
|
+
choices
|
|
1469
1386
|
}), getRoleComponent({
|
|
1470
1387
|
key: "delete_own",
|
|
1471
1388
|
label: '<h4 class="text-gray-800">Delete Form Definition (Restricted to owner)</h4>',
|
|
1472
1389
|
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
|
|
1390
|
+
choices
|
|
1474
1391
|
}), getRoleComponent({
|
|
1475
1392
|
key: "delete_all",
|
|
1476
1393
|
label: '<h4 class="text-gray-800">Delete Form Definition</h4>',
|
|
1477
1394
|
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
|
|
1395
|
+
choices
|
|
1479
1396
|
})]
|
|
1480
1397
|
};
|
|
1481
1398
|
}
|
|
1482
1399
|
|
|
1483
1400
|
function rolesToChoices(roles) {
|
|
1484
|
-
return Object.values(roles).map(
|
|
1401
|
+
return Object.values(roles).map(role => {
|
|
1485
1402
|
return {
|
|
1486
1403
|
label: role.title || "",
|
|
1487
1404
|
value: role._id || ""
|
|
@@ -1492,50 +1409,50 @@ function accessToHash(keys, access) {
|
|
|
1492
1409
|
if (access === void 0) {
|
|
1493
1410
|
access = [];
|
|
1494
1411
|
}
|
|
1495
|
-
|
|
1412
|
+
const hash = Object.values(access).reduce((o, role) => {
|
|
1496
1413
|
o[role.type] = role.roles;
|
|
1497
1414
|
return o;
|
|
1498
1415
|
}, {});
|
|
1499
|
-
return (keys || []).filter(Boolean).reduce(
|
|
1500
|
-
|
|
1501
|
-
|
|
1416
|
+
return (keys || []).filter(Boolean).reduce((data, key) => {
|
|
1417
|
+
return _extends({}, data, {
|
|
1418
|
+
[key]: hash[key] || []
|
|
1419
|
+
});
|
|
1502
1420
|
}, {});
|
|
1503
1421
|
}
|
|
1504
1422
|
function hashToAccess(data) {
|
|
1505
|
-
|
|
1506
|
-
Object.entries(data).forEach(
|
|
1507
|
-
|
|
1508
|
-
roles = _ref[1];
|
|
1423
|
+
const accessRoles = [];
|
|
1424
|
+
Object.entries(data).forEach(_ref => {
|
|
1425
|
+
let [accessType, roles] = _ref;
|
|
1509
1426
|
if (accessType === "submit") {
|
|
1510
1427
|
return;
|
|
1511
1428
|
}
|
|
1512
1429
|
accessRoles.push({
|
|
1513
1430
|
type: accessType,
|
|
1514
|
-
roles
|
|
1431
|
+
roles
|
|
1515
1432
|
});
|
|
1516
1433
|
});
|
|
1517
1434
|
return accessRoles;
|
|
1518
1435
|
}
|
|
1519
1436
|
function getFormAccess(roles) {
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
choices
|
|
1437
|
+
const choices = rolesToChoices(roles);
|
|
1438
|
+
const access = getAccessPermissionForm({
|
|
1439
|
+
choices
|
|
1523
1440
|
});
|
|
1524
|
-
|
|
1525
|
-
choices
|
|
1441
|
+
const submissionAccess = getSubmissionPermissionForm({
|
|
1442
|
+
choices
|
|
1526
1443
|
});
|
|
1527
1444
|
return {
|
|
1528
|
-
access
|
|
1529
|
-
submissionAccess
|
|
1445
|
+
access,
|
|
1446
|
+
submissionAccess
|
|
1530
1447
|
};
|
|
1531
1448
|
}
|
|
1532
1449
|
function dataAccessToSubmissions(form, formAccess) {
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
};
|
|
1450
|
+
const getKeys = components => components.map(_ref2 => {
|
|
1451
|
+
let {
|
|
1452
|
+
key
|
|
1453
|
+
} = _ref2;
|
|
1454
|
+
return key;
|
|
1455
|
+
});
|
|
1539
1456
|
return {
|
|
1540
1457
|
access: {
|
|
1541
1458
|
data: accessToHash(getKeys(formAccess.access.components), form.access)
|
|
@@ -1559,34 +1476,30 @@ function updateSubmissions(type, submission, submissions, cb) {
|
|
|
1559
1476
|
cb = noop__default["default"];
|
|
1560
1477
|
}
|
|
1561
1478
|
if (shouldUpdate(type, submission, submissions)) {
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1479
|
+
submissions = _extends({}, submissions, {
|
|
1480
|
+
[type]: {
|
|
1481
|
+
data: submission.data
|
|
1482
|
+
}
|
|
1483
|
+
});
|
|
1566
1484
|
cb(submissions);
|
|
1567
1485
|
}
|
|
1568
1486
|
return submissions;
|
|
1569
1487
|
}
|
|
1570
1488
|
|
|
1571
1489
|
function useFormAccess(_ref) {
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
return dataAccessToSubmissions(formDefinition, form);
|
|
1582
|
-
}),
|
|
1583
|
-
submissions = _useState[0],
|
|
1584
|
-
setSubmissions = _useState[1];
|
|
1585
|
-
var onChange = React.useCallback(function (type, submission) {
|
|
1490
|
+
let {
|
|
1491
|
+
form: formDefinition,
|
|
1492
|
+
roles,
|
|
1493
|
+
onSubmit,
|
|
1494
|
+
options
|
|
1495
|
+
} = _ref;
|
|
1496
|
+
const form = React$1.useMemo(() => getFormAccess(roles), [roles]);
|
|
1497
|
+
const [submissions, setSubmissions] = React$1.useState(() => dataAccessToSubmissions(formDefinition, form));
|
|
1498
|
+
const onChange = React$1.useCallback((type, submission) => {
|
|
1586
1499
|
updateSubmissions(type, submission, submissions, setSubmissions);
|
|
1587
1500
|
}, [submissions]);
|
|
1588
|
-
React.useEffect(
|
|
1589
|
-
|
|
1501
|
+
React$1.useEffect(() => {
|
|
1502
|
+
const input = dataAccessToSubmissions(formDefinition, form);
|
|
1590
1503
|
if (formDefinition != null && formDefinition._id) {
|
|
1591
1504
|
if (shouldUpdate("access", submissions.access, input) || shouldUpdate("submissionAccess", submissions.submissionAccess, input)) {
|
|
1592
1505
|
setSubmissions(input);
|
|
@@ -1594,36 +1507,38 @@ function useFormAccess(_ref) {
|
|
|
1594
1507
|
}
|
|
1595
1508
|
}, [formDefinition == null ? void 0 : formDefinition._id]);
|
|
1596
1509
|
return {
|
|
1597
|
-
options
|
|
1598
|
-
form
|
|
1510
|
+
options,
|
|
1511
|
+
form,
|
|
1599
1512
|
type: formDefinition.type,
|
|
1600
|
-
submissions
|
|
1601
|
-
onChange
|
|
1602
|
-
onSubmit:
|
|
1603
|
-
|
|
1513
|
+
submissions,
|
|
1514
|
+
onChange,
|
|
1515
|
+
onSubmit: () => {
|
|
1516
|
+
onSubmit && onSubmit(submissionsToDataAccess(formDefinition, submissions));
|
|
1604
1517
|
}
|
|
1605
1518
|
};
|
|
1606
1519
|
}
|
|
1607
1520
|
function NamedFormAccess(_ref2) {
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1521
|
+
let {
|
|
1522
|
+
name,
|
|
1523
|
+
form,
|
|
1524
|
+
submissions,
|
|
1525
|
+
options,
|
|
1526
|
+
onChange,
|
|
1527
|
+
onSubmit,
|
|
1528
|
+
children
|
|
1529
|
+
} = _ref2;
|
|
1530
|
+
const [isValid, setIsValid] = React$1.useState(true);
|
|
1618
1531
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(Form, {
|
|
1619
1532
|
name: name,
|
|
1620
1533
|
form: form[name],
|
|
1621
1534
|
submission: submissions[name],
|
|
1622
|
-
onChange:
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1535
|
+
onChange: _ref3 => {
|
|
1536
|
+
let {
|
|
1537
|
+
data,
|
|
1538
|
+
isValid
|
|
1539
|
+
} = _ref3;
|
|
1540
|
+
isValid && onChange(name, {
|
|
1541
|
+
data
|
|
1627
1542
|
});
|
|
1628
1543
|
setIsValid(isValid);
|
|
1629
1544
|
},
|
|
@@ -1637,13 +1552,14 @@ function NamedFormAccess(_ref2) {
|
|
|
1637
1552
|
}, "Elevated permissions allow users to access and modify other user's entities. Assign with caution."));
|
|
1638
1553
|
}
|
|
1639
1554
|
function FormAccess(props) {
|
|
1640
|
-
|
|
1641
|
-
type
|
|
1642
|
-
form
|
|
1643
|
-
submissions
|
|
1644
|
-
options
|
|
1645
|
-
onChange
|
|
1646
|
-
onSubmit
|
|
1555
|
+
const {
|
|
1556
|
+
type,
|
|
1557
|
+
form,
|
|
1558
|
+
submissions,
|
|
1559
|
+
options,
|
|
1560
|
+
onChange,
|
|
1561
|
+
onSubmit
|
|
1562
|
+
} = useFormAccess(props);
|
|
1647
1563
|
return /*#__PURE__*/React__default["default"].createElement("div", null, props.children, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1648
1564
|
className: "flex mb-5"
|
|
1649
1565
|
}, /*#__PURE__*/React__default["default"].createElement(Card, {
|
|
@@ -1682,24 +1598,17 @@ function FormAccess(props) {
|
|
|
1682
1598
|
label: "About Form Definition Access"
|
|
1683
1599
|
}, /*#__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
1600
|
}
|
|
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
1601
|
|
|
1694
|
-
|
|
1602
|
+
const _excluded$6 = ["action"],
|
|
1695
1603
|
_excluded2 = ["actionInfo", "children", "onSubmit", "options"];
|
|
1696
1604
|
function mapData(options, defaults) {
|
|
1697
1605
|
return _extends({}, defaults, options);
|
|
1698
1606
|
}
|
|
1607
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1699
1608
|
function mapSettingsForm(_ref) {
|
|
1700
|
-
|
|
1701
|
-
FormioUtils__default["default"].eachComponent(settingsForm.components,
|
|
1702
|
-
|
|
1609
|
+
let settingsForm = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
1610
|
+
FormioUtils__default["default"].eachComponent(settingsForm.components, component => {
|
|
1611
|
+
const resourceExclude = "";
|
|
1703
1612
|
if (component.type === "resourcefields") {
|
|
1704
1613
|
component.type = "select";
|
|
1705
1614
|
component.label = component.title;
|
|
@@ -1715,23 +1624,26 @@ function mapSettingsForm(_ref) {
|
|
|
1715
1624
|
return settingsForm;
|
|
1716
1625
|
}
|
|
1717
1626
|
function FormAction(_ref2) {
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1627
|
+
let {
|
|
1628
|
+
actionInfo,
|
|
1629
|
+
children,
|
|
1630
|
+
onSubmit,
|
|
1631
|
+
options
|
|
1632
|
+
} = _ref2,
|
|
1722
1633
|
props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1634
|
+
const {
|
|
1635
|
+
form,
|
|
1636
|
+
submission
|
|
1637
|
+
} = (() => {
|
|
1638
|
+
const submission = mapData(props.submission || {}, actionInfo.defaults);
|
|
1639
|
+
const form = mapSettingsForm(actionInfo.settingsForm);
|
|
1640
|
+
return {
|
|
1641
|
+
form,
|
|
1642
|
+
submission: {
|
|
1643
|
+
data: submission
|
|
1644
|
+
}
|
|
1645
|
+
};
|
|
1646
|
+
})();
|
|
1735
1647
|
return /*#__PURE__*/React__default["default"].createElement("div", null, children, /*#__PURE__*/React__default["default"].createElement(Form, {
|
|
1736
1648
|
form: form,
|
|
1737
1649
|
submission: submission,
|
|
@@ -1751,32 +1663,30 @@ function _catch(body, recover) {
|
|
|
1751
1663
|
}
|
|
1752
1664
|
return result;
|
|
1753
1665
|
}
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
components =
|
|
1757
|
-
display
|
|
1758
|
-
options
|
|
1759
|
-
onChange
|
|
1760
|
-
|
|
1761
|
-
|
|
1666
|
+
const createBuilder = function (el, _ref) {
|
|
1667
|
+
let {
|
|
1668
|
+
components = [],
|
|
1669
|
+
display,
|
|
1670
|
+
options,
|
|
1671
|
+
onChange,
|
|
1672
|
+
events = {}
|
|
1673
|
+
} = _ref;
|
|
1762
1674
|
try {
|
|
1763
|
-
|
|
1764
|
-
display
|
|
1765
|
-
components: []
|
|
1675
|
+
const form = {
|
|
1676
|
+
display,
|
|
1677
|
+
components: [...components]
|
|
1766
1678
|
};
|
|
1767
1679
|
return Promise.resolve(_catch(function () {
|
|
1768
1680
|
return Promise.resolve(new FormioFormBuilder__default["default"](el, form, _extends({}, options)).ready).then(function (builder) {
|
|
1769
|
-
|
|
1681
|
+
const handleEvent = event => {
|
|
1770
1682
|
return function () {
|
|
1771
|
-
events[event] && events[event]
|
|
1683
|
+
events[event] && events[event](...[].slice.call(arguments));
|
|
1772
1684
|
if (EVENTS_CHANGE.includes(event)) {
|
|
1773
1685
|
onChange(builder.form.components);
|
|
1774
1686
|
}
|
|
1775
1687
|
};
|
|
1776
1688
|
};
|
|
1777
|
-
EVENTS.forEach(
|
|
1778
|
-
return builder.on(event, callLast(handleEvent(event), 200));
|
|
1779
|
-
});
|
|
1689
|
+
EVENTS.forEach(event => builder.on(event, callLast(handleEvent(event), 200)));
|
|
1780
1690
|
return builder;
|
|
1781
1691
|
});
|
|
1782
1692
|
}, function (er) {
|
|
@@ -1787,91 +1697,88 @@ var createBuilder = function createBuilder(el, _ref2) {
|
|
|
1787
1697
|
}
|
|
1788
1698
|
};
|
|
1789
1699
|
Components__default["default"].setComponents(AllComponents__default["default"]);
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
_this.builderRef = void 0;
|
|
1799
|
-
_this.state = {
|
|
1700
|
+
const EVENTS = ["addComponent", "updateComponent", "removeComponent", "saveComponent", "cancelComponent", "moveComponent", "editComponent", "editJson", "copyComponent", "pasteComponent"];
|
|
1701
|
+
const EVENTS_CHANGE = ["addComponent", "saveComponent", "updateComponent", "removeComponent"];
|
|
1702
|
+
class FormBuilder extends React__default["default"].Component {
|
|
1703
|
+
constructor(props) {
|
|
1704
|
+
super(props);
|
|
1705
|
+
this.elRef = void 0;
|
|
1706
|
+
this.builderRef = void 0;
|
|
1707
|
+
this.state = {
|
|
1800
1708
|
display: props.display,
|
|
1801
1709
|
components: cloneDeep__default["default"](props.components)
|
|
1802
1710
|
};
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
return _this;
|
|
1711
|
+
this.elRef = null;
|
|
1712
|
+
this.builderRef = null;
|
|
1806
1713
|
}
|
|
1807
|
-
|
|
1808
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
1714
|
+
componentDidMount() {
|
|
1809
1715
|
try {
|
|
1810
|
-
|
|
1811
|
-
return Promise.resolve(
|
|
1716
|
+
const _this = this;
|
|
1717
|
+
return Promise.resolve(_this.create(_this.props)).then(function () {});
|
|
1812
1718
|
} catch (e) {
|
|
1813
1719
|
return Promise.reject(e);
|
|
1814
1720
|
}
|
|
1815
|
-
}
|
|
1816
|
-
|
|
1721
|
+
}
|
|
1722
|
+
create(props) {
|
|
1817
1723
|
try {
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1724
|
+
const _this2 = this;
|
|
1725
|
+
const {
|
|
1726
|
+
options,
|
|
1727
|
+
display,
|
|
1728
|
+
components,
|
|
1729
|
+
onAddComponent,
|
|
1730
|
+
onUpdateComponent,
|
|
1731
|
+
onRemoveComponent,
|
|
1732
|
+
onSaveComponent,
|
|
1733
|
+
onCancelComponent,
|
|
1734
|
+
onMoveComponent,
|
|
1735
|
+
onEditComponent,
|
|
1736
|
+
onEditJson,
|
|
1737
|
+
onCopyComponent,
|
|
1738
|
+
onPasteComponent
|
|
1739
|
+
} = props;
|
|
1740
|
+
return Promise.resolve(createBuilder(_this2.elRef.firstChild, {
|
|
1741
|
+
display,
|
|
1834
1742
|
options: _extends({}, options),
|
|
1835
1743
|
components: cloneDeep__default["default"](components),
|
|
1836
|
-
onChange:
|
|
1744
|
+
onChange: _this2.whenComponentsChange.bind(_this2),
|
|
1837
1745
|
events: {
|
|
1838
|
-
onAddComponent
|
|
1839
|
-
onUpdateComponent
|
|
1840
|
-
onRemoveComponent
|
|
1841
|
-
onSaveComponent
|
|
1842
|
-
onCancelComponent
|
|
1843
|
-
onMoveComponent
|
|
1844
|
-
onEditComponent
|
|
1845
|
-
onEditJson
|
|
1846
|
-
onCopyComponent
|
|
1847
|
-
onPasteComponent
|
|
1746
|
+
onAddComponent,
|
|
1747
|
+
onUpdateComponent,
|
|
1748
|
+
onRemoveComponent,
|
|
1749
|
+
onSaveComponent,
|
|
1750
|
+
onCancelComponent,
|
|
1751
|
+
onMoveComponent,
|
|
1752
|
+
onEditComponent,
|
|
1753
|
+
onEditJson,
|
|
1754
|
+
onCopyComponent,
|
|
1755
|
+
onPasteComponent
|
|
1848
1756
|
}
|
|
1849
1757
|
})).then(function (_createBuilder) {
|
|
1850
|
-
|
|
1758
|
+
_this2.builderRef = _createBuilder;
|
|
1851
1759
|
});
|
|
1852
1760
|
} catch (e) {
|
|
1853
1761
|
return Promise.reject(e);
|
|
1854
1762
|
}
|
|
1855
|
-
}
|
|
1856
|
-
|
|
1763
|
+
}
|
|
1764
|
+
componentWillUnmount() {
|
|
1857
1765
|
var _this$builderRef;
|
|
1858
1766
|
(_this$builderRef = this.builderRef) == null ? void 0 : _this$builderRef.destroy();
|
|
1859
1767
|
}
|
|
1860
1768
|
// eslint-disable-next-line react/no-deprecated
|
|
1861
|
-
|
|
1862
|
-
_proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
|
1769
|
+
componentWillReceiveProps(nextProps) {
|
|
1863
1770
|
try {
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
if (
|
|
1867
|
-
|
|
1868
|
-
if (nextProps.display !==
|
|
1869
|
-
return Promise.resolve(
|
|
1771
|
+
const _this3 = this;
|
|
1772
|
+
const _temp2 = function () {
|
|
1773
|
+
if (_this3.builderRef) {
|
|
1774
|
+
const _temp = function () {
|
|
1775
|
+
if (nextProps.display !== _this3.state.display) {
|
|
1776
|
+
return Promise.resolve(_this3.create(_extends({}, _this3.props, {
|
|
1870
1777
|
display: nextProps.display
|
|
1871
1778
|
}))).then(function () {});
|
|
1872
|
-
} else if (nextProps.components !==
|
|
1873
|
-
|
|
1874
|
-
display:
|
|
1779
|
+
} else if (nextProps.components !== _this3.state.components) {
|
|
1780
|
+
_this3.builderRef.form = {
|
|
1781
|
+
display: _this3.state.display,
|
|
1875
1782
|
components: nextProps.components
|
|
1876
1783
|
};
|
|
1877
1784
|
}
|
|
@@ -1883,29 +1790,24 @@ var FormBuilder = /*#__PURE__*/function (_React$Component) {
|
|
|
1883
1790
|
} catch (e) {
|
|
1884
1791
|
return Promise.reject(e);
|
|
1885
1792
|
}
|
|
1886
|
-
}
|
|
1887
|
-
|
|
1888
|
-
var _this5 = this;
|
|
1793
|
+
}
|
|
1794
|
+
whenComponentsChange(components) {
|
|
1889
1795
|
this.setState({
|
|
1890
|
-
components
|
|
1891
|
-
},
|
|
1892
|
-
var
|
|
1893
|
-
((
|
|
1796
|
+
components
|
|
1797
|
+
}, () => {
|
|
1798
|
+
var _this$props;
|
|
1799
|
+
((_this$props = this.props) == null ? void 0 : _this$props.onChange) && this.props.onChange(components);
|
|
1894
1800
|
});
|
|
1895
|
-
}
|
|
1896
|
-
|
|
1897
|
-
var _this6 = this;
|
|
1801
|
+
}
|
|
1802
|
+
render() {
|
|
1898
1803
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1899
|
-
ref:
|
|
1900
|
-
|
|
1804
|
+
ref: ref => {
|
|
1805
|
+
this.elRef = ref;
|
|
1901
1806
|
},
|
|
1902
|
-
onClick:
|
|
1903
|
-
return e.stopPropagation();
|
|
1904
|
-
}
|
|
1807
|
+
onClick: e => e.stopPropagation()
|
|
1905
1808
|
}, /*#__PURE__*/React__default["default"].createElement("div", null));
|
|
1906
|
-
}
|
|
1907
|
-
|
|
1908
|
-
}(React__default["default"].Component);
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1909
1811
|
FormBuilder.defaultProps = {
|
|
1910
1812
|
options: {},
|
|
1911
1813
|
onChange: noop__default["default"],
|
|
@@ -1930,46 +1832,45 @@ FormBuilder.propTypes = {
|
|
|
1930
1832
|
};
|
|
1931
1833
|
|
|
1932
1834
|
function useTooltip(options) {
|
|
1933
|
-
|
|
1934
|
-
React.useEffect(
|
|
1835
|
+
const ref = React$1.useRef();
|
|
1836
|
+
React$1.useEffect(() => {
|
|
1935
1837
|
ref.current && new Tooltip__default["default"](ref.current, options);
|
|
1936
1838
|
}, [ref, options]);
|
|
1937
1839
|
return ref;
|
|
1938
1840
|
}
|
|
1939
1841
|
|
|
1940
1842
|
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({
|
|
1843
|
+
let {
|
|
1844
|
+
saveText = "Save",
|
|
1845
|
+
disabled,
|
|
1846
|
+
options = {},
|
|
1847
|
+
onCopy,
|
|
1848
|
+
hasUndo,
|
|
1849
|
+
hasRedo,
|
|
1850
|
+
onUndo,
|
|
1851
|
+
onRedo,
|
|
1852
|
+
onReset,
|
|
1853
|
+
onSubmit
|
|
1854
|
+
} = _ref;
|
|
1855
|
+
const {
|
|
1856
|
+
i18n: t = t => t
|
|
1857
|
+
} = options;
|
|
1858
|
+
const copyTooltipRef = useTooltip({
|
|
1958
1859
|
trigger: "hover",
|
|
1959
1860
|
placement: "top",
|
|
1960
1861
|
title: t("Copy")
|
|
1961
1862
|
});
|
|
1962
|
-
|
|
1863
|
+
const undoTooltipRef = useTooltip({
|
|
1963
1864
|
trigger: "hover",
|
|
1964
1865
|
placement: "top",
|
|
1965
1866
|
title: t("Undo last change")
|
|
1966
1867
|
});
|
|
1967
|
-
|
|
1868
|
+
const redoTooltipRef = useTooltip({
|
|
1968
1869
|
trigger: "hover",
|
|
1969
1870
|
placement: "top",
|
|
1970
1871
|
title: t("Redo last change")
|
|
1971
1872
|
});
|
|
1972
|
-
|
|
1873
|
+
const resetTooltipRef = useTooltip({
|
|
1973
1874
|
trigger: "hover",
|
|
1974
1875
|
placement: "top",
|
|
1975
1876
|
title: t("Reset all changes")
|
|
@@ -1979,40 +1880,30 @@ function FormEditCTAs(_ref) {
|
|
|
1979
1880
|
}, /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
1980
1881
|
className: "btn btn-primary btn-save flex " + (disabled ? "disabled" : ""),
|
|
1981
1882
|
disabled: disabled,
|
|
1982
|
-
onClick:
|
|
1983
|
-
return !disabled && onSubmit && onSubmit();
|
|
1984
|
-
}
|
|
1883
|
+
onClick: () => !disabled && onSubmit && onSubmit()
|
|
1985
1884
|
}, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
1986
1885
|
className: "mr-1 " + iconClass(options.iconset, "save")
|
|
1987
1886
|
}), saveText), /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
1988
1887
|
className: "btn btn-light btn-undo " + (hasUndo ? "" : "disabled"),
|
|
1989
|
-
onClick:
|
|
1990
|
-
return onUndo && onUndo();
|
|
1991
|
-
},
|
|
1888
|
+
onClick: () => onUndo && onUndo(),
|
|
1992
1889
|
ref: undoTooltipRef
|
|
1993
1890
|
}, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
1994
1891
|
className: iconClass(options.iconset, "undo")
|
|
1995
1892
|
})), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
1996
1893
|
className: "btn btn-light btn-redo " + (hasRedo ? "" : "disabled"),
|
|
1997
|
-
onClick:
|
|
1998
|
-
return onRedo && onRedo();
|
|
1999
|
-
},
|
|
1894
|
+
onClick: () => onRedo && onRedo(),
|
|
2000
1895
|
ref: redoTooltipRef
|
|
2001
1896
|
}, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
2002
1897
|
className: iconClass(options.iconset, "redo")
|
|
2003
1898
|
}))), /*#__PURE__*/React__default["default"].createElement("div", null, onCopy && /*#__PURE__*/React__default["default"].createElement("button", {
|
|
2004
1899
|
className: "btn btn-light",
|
|
2005
|
-
onClick:
|
|
2006
|
-
return onCopy();
|
|
2007
|
-
},
|
|
1900
|
+
onClick: () => onCopy(),
|
|
2008
1901
|
ref: copyTooltipRef
|
|
2009
1902
|
}, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
2010
1903
|
className: iconClass(options.iconset, "copy")
|
|
2011
1904
|
})), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
2012
1905
|
className: "btn btn-light btn-reset",
|
|
2013
|
-
onClick:
|
|
2014
|
-
return onReset && onReset();
|
|
2015
|
-
},
|
|
1906
|
+
onClick: () => onReset && onReset(),
|
|
2016
1907
|
ref: resetTooltipRef
|
|
2017
1908
|
}, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
2018
1909
|
className: iconClass(options.iconset, "reset")
|
|
@@ -2029,35 +1920,34 @@ FormEditCTAs.propTypes = {
|
|
|
2029
1920
|
onReset: PropTypes__default["default"].func
|
|
2030
1921
|
};
|
|
2031
1922
|
|
|
2032
|
-
|
|
1923
|
+
const _excluded$5 = ["name", "value", "label", "onChange", "required", "description", "prefix", "suffix"];
|
|
2033
1924
|
function InputTags(_ref) {
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
1925
|
+
let {
|
|
1926
|
+
name,
|
|
1927
|
+
value = [],
|
|
1928
|
+
label,
|
|
1929
|
+
onChange,
|
|
1930
|
+
required,
|
|
1931
|
+
description,
|
|
1932
|
+
prefix,
|
|
1933
|
+
suffix
|
|
1934
|
+
} = _ref,
|
|
2043
1935
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
2044
|
-
|
|
2045
|
-
React.useEffect(
|
|
2046
|
-
|
|
1936
|
+
const ref = React$1.useRef();
|
|
1937
|
+
React$1.useEffect(() => {
|
|
1938
|
+
const instance = new Choices__default["default"](ref.current, {
|
|
2047
1939
|
delimiter: ",",
|
|
2048
1940
|
editItems: true,
|
|
2049
1941
|
removeItemButton: true
|
|
2050
1942
|
});
|
|
2051
1943
|
instance.setValue([].concat(value, []));
|
|
2052
|
-
instance.passedElement.element.addEventListener("addItem",
|
|
1944
|
+
instance.passedElement.element.addEventListener("addItem", event => {
|
|
2053
1945
|
onChange && onChange(name, uniq__default["default"](value.concat(event.detail.value)));
|
|
2054
1946
|
});
|
|
2055
|
-
instance.passedElement.element.addEventListener("removeItem",
|
|
2056
|
-
onChange && onChange(name, value.filter(
|
|
2057
|
-
return v !== event.detail.value;
|
|
2058
|
-
}));
|
|
1947
|
+
instance.passedElement.element.addEventListener("removeItem", event => {
|
|
1948
|
+
onChange && onChange(name, value.filter(v => v !== event.detail.value));
|
|
2059
1949
|
});
|
|
2060
|
-
return
|
|
1950
|
+
return () => {
|
|
2061
1951
|
instance.destroy();
|
|
2062
1952
|
};
|
|
2063
1953
|
}, []);
|
|
@@ -2084,7 +1974,7 @@ InputTags.propTypes = {
|
|
|
2084
1974
|
onChange: PropTypes__default["default"].func
|
|
2085
1975
|
};
|
|
2086
1976
|
|
|
2087
|
-
|
|
1977
|
+
const defaultDisplayChoices = [{
|
|
2088
1978
|
label: "Form",
|
|
2089
1979
|
value: "form"
|
|
2090
1980
|
}, {
|
|
@@ -2095,21 +1985,17 @@ var defaultDisplayChoices = [{
|
|
|
2095
1985
|
value: "pdf"
|
|
2096
1986
|
}];
|
|
2097
1987
|
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;
|
|
1988
|
+
let {
|
|
1989
|
+
onChange,
|
|
1990
|
+
form,
|
|
1991
|
+
enableTags = true,
|
|
1992
|
+
typeChoices = [],
|
|
1993
|
+
displayChoices = defaultDisplayChoices,
|
|
1994
|
+
className = "",
|
|
1995
|
+
readonly = {},
|
|
1996
|
+
baseUrl = window.location.origin
|
|
1997
|
+
} = _ref;
|
|
1998
|
+
const hasTypeChoices = typeChoices && typeChoices.length > 1;
|
|
2113
1999
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2114
2000
|
className: "form-edit__settings " + className
|
|
2115
2001
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -2187,9 +2073,7 @@ FormParameters.propTypes = {
|
|
|
2187
2073
|
className: PropTypes__default["default"].string
|
|
2188
2074
|
};
|
|
2189
2075
|
|
|
2190
|
-
|
|
2191
|
-
return !isEqual__default["default"](form, value);
|
|
2192
|
-
};
|
|
2076
|
+
const hasChanged = (form, value) => !isEqual__default["default"](form, value);
|
|
2193
2077
|
function createInitialState(props) {
|
|
2194
2078
|
return {
|
|
2195
2079
|
past: [],
|
|
@@ -2198,40 +2082,44 @@ function createInitialState(props) {
|
|
|
2198
2082
|
original: cloneDeep__default["default"](props.form)
|
|
2199
2083
|
};
|
|
2200
2084
|
}
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2085
|
+
const reducer = (state, _ref) => {
|
|
2086
|
+
let {
|
|
2087
|
+
type,
|
|
2088
|
+
value
|
|
2089
|
+
} = _ref;
|
|
2090
|
+
const {
|
|
2091
|
+
past,
|
|
2092
|
+
current,
|
|
2093
|
+
future
|
|
2094
|
+
} = state;
|
|
2095
|
+
const update = newValue => {
|
|
2208
2096
|
if (newValue.title !== state.current.title && !state.current._id) {
|
|
2209
2097
|
newValue.name = camelCase__default["default"](value.title);
|
|
2210
2098
|
newValue.path = camelCase__default["default"](value.title).toLowerCase();
|
|
2211
2099
|
}
|
|
2212
2100
|
return _extends({}, state, {
|
|
2213
|
-
past: [
|
|
2101
|
+
past: [...past, cloneDeep__default["default"](current)],
|
|
2214
2102
|
current: newValue
|
|
2215
2103
|
});
|
|
2216
2104
|
};
|
|
2217
2105
|
switch (type) {
|
|
2218
2106
|
case "undo":
|
|
2219
2107
|
if (past.length) {
|
|
2220
|
-
|
|
2221
|
-
|
|
2108
|
+
const previous = past[past.length - 1];
|
|
2109
|
+
const newPast = past.slice(0, past.length - 1);
|
|
2222
2110
|
return _extends({}, state, {
|
|
2223
2111
|
past: newPast,
|
|
2224
2112
|
current: cloneDeep__default["default"](previous),
|
|
2225
|
-
future: [cloneDeep__default["default"](current)]
|
|
2113
|
+
future: [cloneDeep__default["default"](current), ...future]
|
|
2226
2114
|
});
|
|
2227
2115
|
}
|
|
2228
2116
|
break;
|
|
2229
2117
|
case "redo":
|
|
2230
2118
|
if (future.length) {
|
|
2231
|
-
|
|
2232
|
-
|
|
2119
|
+
const next = future[0];
|
|
2120
|
+
const newFuture = future.slice(1);
|
|
2233
2121
|
return _extends({}, state, {
|
|
2234
|
-
past: [
|
|
2122
|
+
past: [...past, cloneDeep__default["default"](current)],
|
|
2235
2123
|
current: cloneDeep__default["default"](next),
|
|
2236
2124
|
future: newFuture
|
|
2237
2125
|
});
|
|
@@ -2240,8 +2128,7 @@ var reducer = function reducer(state, _ref) {
|
|
|
2240
2128
|
case "reset":
|
|
2241
2129
|
return update(cloneDeep__default["default"](state.original));
|
|
2242
2130
|
case "formChange":
|
|
2243
|
-
|
|
2244
|
-
var newValue = _extends({}, state.current, value);
|
|
2131
|
+
const newValue = _extends({}, state.current, value);
|
|
2245
2132
|
if (hasChanged(state.current, newValue)) {
|
|
2246
2133
|
return update(newValue);
|
|
2247
2134
|
}
|
|
@@ -2258,23 +2145,22 @@ var reducer = function reducer(state, _ref) {
|
|
|
2258
2145
|
};
|
|
2259
2146
|
|
|
2260
2147
|
function useFormEdit(props) {
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
var onSubmit = function onSubmit() {
|
|
2148
|
+
const [{
|
|
2149
|
+
current,
|
|
2150
|
+
future,
|
|
2151
|
+
past
|
|
2152
|
+
}, dispatchFormAction] = React$1.useReducer(reducer, createInitialState(props));
|
|
2153
|
+
const onSubmit = () => {
|
|
2268
2154
|
if (props.onSubmit && typeof props.onSubmit === "function") {
|
|
2269
2155
|
props.onSubmit(current);
|
|
2270
2156
|
}
|
|
2271
2157
|
};
|
|
2272
|
-
|
|
2158
|
+
const onCopy = () => {
|
|
2273
2159
|
if (props.onSubmit && typeof props.onCopy === "function") {
|
|
2274
2160
|
props.onCopy(current);
|
|
2275
2161
|
}
|
|
2276
2162
|
};
|
|
2277
|
-
React.useEffect(
|
|
2163
|
+
React$1.useEffect(() => {
|
|
2278
2164
|
if (props.form && (current._id !== props.form._id || current.modified !== props.form.modified)) {
|
|
2279
2165
|
dispatchFormAction({
|
|
2280
2166
|
type: "replaceForm",
|
|
@@ -2282,7 +2168,7 @@ function useFormEdit(props) {
|
|
|
2282
2168
|
});
|
|
2283
2169
|
}
|
|
2284
2170
|
}, [props.form]);
|
|
2285
|
-
|
|
2171
|
+
const formChange = newForm => {
|
|
2286
2172
|
if (hasChanged(current, _extends({}, current, newForm))) {
|
|
2287
2173
|
dispatchFormAction({
|
|
2288
2174
|
type: "formChange",
|
|
@@ -2290,57 +2176,54 @@ function useFormEdit(props) {
|
|
|
2290
2176
|
});
|
|
2291
2177
|
}
|
|
2292
2178
|
};
|
|
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)));
|
|
2179
|
+
const redo = () => dispatchFormAction({
|
|
2180
|
+
type: "redo"
|
|
2181
|
+
});
|
|
2182
|
+
const undo = () => dispatchFormAction({
|
|
2183
|
+
type: "undo"
|
|
2184
|
+
});
|
|
2185
|
+
const reset = () => dispatchFormAction({
|
|
2186
|
+
type: "reset"
|
|
2187
|
+
});
|
|
2188
|
+
const setChange = (path, value) => {
|
|
2189
|
+
formChange(_extends({}, current, {
|
|
2190
|
+
[path]: value
|
|
2191
|
+
}));
|
|
2311
2192
|
};
|
|
2312
2193
|
return {
|
|
2313
2194
|
form: cloneDeep__default["default"](current),
|
|
2314
|
-
redo
|
|
2315
|
-
undo
|
|
2316
|
-
reset
|
|
2195
|
+
redo,
|
|
2196
|
+
undo,
|
|
2197
|
+
reset,
|
|
2317
2198
|
hasChanged: !!past.length,
|
|
2318
2199
|
isValid: current.title && current.name && current.path,
|
|
2319
2200
|
hasUndo: !!past.length,
|
|
2320
2201
|
hasRedo: !!future.length,
|
|
2321
|
-
onSubmit
|
|
2322
|
-
onCopy
|
|
2323
|
-
formChange
|
|
2324
|
-
setChange
|
|
2202
|
+
onSubmit,
|
|
2203
|
+
onCopy,
|
|
2204
|
+
formChange,
|
|
2205
|
+
setChange
|
|
2325
2206
|
};
|
|
2326
2207
|
}
|
|
2327
2208
|
|
|
2328
2209
|
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
|
-
|
|
2210
|
+
const {
|
|
2211
|
+
form,
|
|
2212
|
+
isValid,
|
|
2213
|
+
setChange,
|
|
2214
|
+
hasRedo,
|
|
2215
|
+
hasChanged,
|
|
2216
|
+
hasUndo,
|
|
2217
|
+
redo,
|
|
2218
|
+
undo,
|
|
2219
|
+
reset,
|
|
2220
|
+
onSubmit,
|
|
2221
|
+
onCopy
|
|
2222
|
+
} = useFormEdit(props);
|
|
2223
|
+
const {
|
|
2224
|
+
options = {},
|
|
2225
|
+
builder
|
|
2226
|
+
} = props;
|
|
2344
2227
|
return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2345
2228
|
className: "form-edit"
|
|
2346
2229
|
}, /*#__PURE__*/React__default["default"].createElement(FormParameters, _extends({}, props, {
|
|
@@ -2366,7 +2249,7 @@ function FormEdit(props) {
|
|
|
2366
2249
|
display: form.display,
|
|
2367
2250
|
options: options,
|
|
2368
2251
|
builder: builder,
|
|
2369
|
-
onChange:
|
|
2252
|
+
onChange: components => {
|
|
2370
2253
|
setChange("components", components);
|
|
2371
2254
|
}
|
|
2372
2255
|
}));
|
|
@@ -2455,60 +2338,55 @@ function submissionToFormSettings(form, submission) {
|
|
|
2455
2338
|
}
|
|
2456
2339
|
|
|
2457
2340
|
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;
|
|
2341
|
+
let {
|
|
2342
|
+
form: formDefinition,
|
|
2343
|
+
onSubmit = noop__default["default"],
|
|
2344
|
+
options
|
|
2345
|
+
} = _ref;
|
|
2346
|
+
const form = getFormSettingsSchema();
|
|
2347
|
+
const [isValid, setIsValid] = React$1.useState(true);
|
|
2348
|
+
const [submission, setSubmission] = React$1.useState(() => formSettingsToSubmission(formDefinition));
|
|
2349
|
+
const onChange = _ref2 => {
|
|
2350
|
+
let {
|
|
2351
|
+
data,
|
|
2352
|
+
isValid
|
|
2353
|
+
} = _ref2;
|
|
2474
2354
|
if (isValid) {
|
|
2475
2355
|
setSubmission({
|
|
2476
|
-
data
|
|
2356
|
+
data
|
|
2477
2357
|
});
|
|
2478
2358
|
}
|
|
2479
2359
|
setIsValid(isValid);
|
|
2480
2360
|
};
|
|
2481
|
-
React.useEffect(
|
|
2482
|
-
|
|
2361
|
+
React$1.useEffect(() => {
|
|
2362
|
+
const input = formSettingsToSubmission(formDefinition);
|
|
2483
2363
|
if (formDefinition != null && formDefinition._id && !isEqual__default["default"](submission.data, input.data)) {
|
|
2484
2364
|
setSubmission(input);
|
|
2485
2365
|
}
|
|
2486
2366
|
}, [formDefinition == null ? void 0 : formDefinition._id]);
|
|
2487
2367
|
return {
|
|
2488
|
-
options
|
|
2489
|
-
form
|
|
2368
|
+
options,
|
|
2369
|
+
form,
|
|
2490
2370
|
type: formDefinition.type,
|
|
2491
|
-
submission
|
|
2492
|
-
onChange
|
|
2493
|
-
isValid
|
|
2494
|
-
setIsValid
|
|
2495
|
-
onSubmit:
|
|
2496
|
-
|
|
2371
|
+
submission,
|
|
2372
|
+
onChange,
|
|
2373
|
+
isValid,
|
|
2374
|
+
setIsValid,
|
|
2375
|
+
onSubmit: () => {
|
|
2376
|
+
onSubmit(submissionToFormSettings(formDefinition, submission));
|
|
2497
2377
|
}
|
|
2498
2378
|
};
|
|
2499
2379
|
}
|
|
2500
2380
|
function FormSettings(props) {
|
|
2501
|
-
|
|
2502
|
-
form
|
|
2503
|
-
submission
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
return f;
|
|
2511
|
-
};
|
|
2381
|
+
const {
|
|
2382
|
+
form,
|
|
2383
|
+
submission,
|
|
2384
|
+
options = {},
|
|
2385
|
+
onChange,
|
|
2386
|
+
onSubmit,
|
|
2387
|
+
isValid
|
|
2388
|
+
} = useFormSettings(props);
|
|
2389
|
+
const i18n = options.i18n || (f => f);
|
|
2512
2390
|
return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement(Form, {
|
|
2513
2391
|
form: form,
|
|
2514
2392
|
submission: submission,
|
|
@@ -2524,36 +2402,38 @@ function FormSettings(props) {
|
|
|
2524
2402
|
}
|
|
2525
2403
|
|
|
2526
2404
|
function useSelectColumnFilter(props) {
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2405
|
+
const {
|
|
2406
|
+
column
|
|
2407
|
+
} = props;
|
|
2408
|
+
const {
|
|
2409
|
+
id,
|
|
2410
|
+
preFilteredRows
|
|
2411
|
+
} = column;
|
|
2412
|
+
const {
|
|
2413
|
+
choices: customChoices
|
|
2414
|
+
} = column;
|
|
2415
|
+
const {
|
|
2416
|
+
filterValue,
|
|
2417
|
+
setFilter
|
|
2418
|
+
} = column;
|
|
2419
|
+
const choices = (() => {
|
|
2534
2420
|
if (customChoices) {
|
|
2535
2421
|
if (typeof customChoices === "function") {
|
|
2536
2422
|
return customChoices(props);
|
|
2537
2423
|
}
|
|
2538
2424
|
return customChoices;
|
|
2539
2425
|
}
|
|
2540
|
-
return [
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
label: value,
|
|
2547
|
-
value: value
|
|
2548
|
-
};
|
|
2549
|
-
});
|
|
2550
|
-
}();
|
|
2551
|
-
var onChange = function onChange(_, value) {
|
|
2426
|
+
return [...new Set(preFilteredRows.map(row => row.values[id]))].filter(value => value).map(value => ({
|
|
2427
|
+
label: value,
|
|
2428
|
+
value
|
|
2429
|
+
}));
|
|
2430
|
+
})();
|
|
2431
|
+
const onChange = (_, value) => {
|
|
2552
2432
|
setFilter(value || undefined);
|
|
2553
2433
|
};
|
|
2554
2434
|
return {
|
|
2555
2435
|
value: filterValue,
|
|
2556
|
-
onChange
|
|
2436
|
+
onChange,
|
|
2557
2437
|
choices: [{
|
|
2558
2438
|
value: "",
|
|
2559
2439
|
label: "All"
|
|
@@ -2561,10 +2441,11 @@ function useSelectColumnFilter(props) {
|
|
|
2561
2441
|
};
|
|
2562
2442
|
}
|
|
2563
2443
|
function SelectColumnFilter(props) {
|
|
2564
|
-
|
|
2565
|
-
value
|
|
2566
|
-
choices
|
|
2567
|
-
onChange
|
|
2444
|
+
const {
|
|
2445
|
+
value,
|
|
2446
|
+
choices,
|
|
2447
|
+
onChange
|
|
2448
|
+
} = useSelectColumnFilter(props);
|
|
2568
2449
|
return /*#__PURE__*/React__default["default"].createElement(Select, {
|
|
2569
2450
|
key: "filter-" + props.column.id,
|
|
2570
2451
|
name: "filter-" + props.column.id,
|
|
@@ -2691,7 +2572,7 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
2691
2572
|
if (Array.prototype.some) {
|
|
2692
2573
|
some = Array.prototype.some;
|
|
2693
2574
|
} else {
|
|
2694
|
-
some = function
|
|
2575
|
+
some = function (fun) {
|
|
2695
2576
|
var t = Object(this),
|
|
2696
2577
|
len = t.length >>> 0,
|
|
2697
2578
|
i;
|
|
@@ -2904,7 +2785,7 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
2904
2785
|
if (Object.keys) {
|
|
2905
2786
|
keys = Object.keys;
|
|
2906
2787
|
} else {
|
|
2907
|
-
keys = function
|
|
2788
|
+
keys = function (obj) {
|
|
2908
2789
|
var i,
|
|
2909
2790
|
res = [];
|
|
2910
2791
|
for (i in obj) {
|
|
@@ -2945,7 +2826,7 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
2945
2826
|
function addFormatToken(token, padded, ordinal, callback) {
|
|
2946
2827
|
var func = callback;
|
|
2947
2828
|
if (typeof callback === 'string') {
|
|
2948
|
-
func = function
|
|
2829
|
+
func = function () {
|
|
2949
2830
|
return this[callback]();
|
|
2950
2831
|
};
|
|
2951
2832
|
}
|
|
@@ -3248,7 +3129,7 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
3248
3129
|
token = [token];
|
|
3249
3130
|
}
|
|
3250
3131
|
if (isNumber(callback)) {
|
|
3251
|
-
func = function
|
|
3132
|
+
func = function (input, array) {
|
|
3252
3133
|
array[callback] = toInt(input);
|
|
3253
3134
|
};
|
|
3254
3135
|
}
|
|
@@ -3284,7 +3165,7 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
3284
3165
|
if (Array.prototype.indexOf) {
|
|
3285
3166
|
indexOf = Array.prototype.indexOf;
|
|
3286
3167
|
} else {
|
|
3287
|
-
indexOf = function
|
|
3168
|
+
indexOf = function (o) {
|
|
3288
3169
|
// I know
|
|
3289
3170
|
var i;
|
|
3290
3171
|
for (i = 0; i < this.length; ++i) {
|
|
@@ -5046,7 +4927,7 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
5046
4927
|
var args = [].slice.call(arguments, 0);
|
|
5047
4928
|
return pickBy('isAfter', args);
|
|
5048
4929
|
}
|
|
5049
|
-
var now = function
|
|
4930
|
+
var now = function () {
|
|
5050
4931
|
return Date.now ? Date.now() : +new Date();
|
|
5051
4932
|
};
|
|
5052
4933
|
var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond'];
|
|
@@ -6479,8 +6360,8 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
6479
6360
|
proto.toDate = toDate;
|
|
6480
6361
|
proto.toISOString = toISOString;
|
|
6481
6362
|
proto.inspect = inspect;
|
|
6482
|
-
if (typeof Symbol !== 'undefined' && Symbol
|
|
6483
|
-
proto[Symbol
|
|
6363
|
+
if (typeof Symbol !== 'undefined' && Symbol.for != null) {
|
|
6364
|
+
proto[Symbol.for('nodejs.util.inspect.custom')] = function () {
|
|
6484
6365
|
return 'Moment<' + this.format() + '>';
|
|
6485
6366
|
};
|
|
6486
6367
|
}
|
|
@@ -6665,7 +6546,7 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
6665
6546
|
abbr: 'BC'
|
|
6666
6547
|
}],
|
|
6667
6548
|
dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
|
|
6668
|
-
ordinal: function
|
|
6549
|
+
ordinal: function (number) {
|
|
6669
6550
|
var b = number % 10,
|
|
6670
6551
|
output = toInt(number % 100 / 10) === 1 ? 'th' : b === 1 ? 'st' : b === 2 ? 'nd' : b === 3 ? 'rd' : 'th';
|
|
6671
6552
|
return number + output;
|
|
@@ -7107,9 +6988,12 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
7107
6988
|
});
|
|
7108
6989
|
|
|
7109
6990
|
function FormsCell(props) {
|
|
7110
|
-
|
|
7111
|
-
icon =
|
|
7112
|
-
|
|
6991
|
+
const {
|
|
6992
|
+
icon = "server",
|
|
6993
|
+
row: {
|
|
6994
|
+
original: form
|
|
6995
|
+
}
|
|
6996
|
+
} = props;
|
|
7113
6997
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7114
6998
|
className: "p-1"
|
|
7115
6999
|
}, /*#__PURE__*/React__default["default"].createElement("h4", {
|
|
@@ -7126,40 +7010,37 @@ function FormsCell(props) {
|
|
|
7126
7010
|
className: "badge bg-light mr-1"
|
|
7127
7011
|
}, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
7128
7012
|
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
|
-
}))));
|
|
7013
|
+
}), /*#__PURE__*/React__default["default"].createElement("span", null, "Updated ", moment(form.modified).fromNow())), (form.tags || []).map((tag, index) => /*#__PURE__*/React__default["default"].createElement("button", {
|
|
7014
|
+
key: index,
|
|
7015
|
+
className: "badge badge-hover bg-secondary mr-1",
|
|
7016
|
+
onClick: stopPropagationWrapper(() => {
|
|
7017
|
+
props.setFilter("tags", tag);
|
|
7018
|
+
props.gotoPage(0);
|
|
7019
|
+
})
|
|
7020
|
+
}, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
7021
|
+
className: classnames__default["default"](iconClass(undefined, "tags"), "mr-1")
|
|
7022
|
+
}), tag)))));
|
|
7141
7023
|
}
|
|
7142
7024
|
|
|
7143
|
-
|
|
7025
|
+
const _excluded$4 = ["Cell"];
|
|
7144
7026
|
function FormsTable(_ref) {
|
|
7145
|
-
|
|
7027
|
+
let {
|
|
7028
|
+
Cell
|
|
7029
|
+
} = _ref,
|
|
7146
7030
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
7147
|
-
|
|
7148
|
-
i18n =
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
var columns = [{
|
|
7031
|
+
const {
|
|
7032
|
+
i18n = f => f,
|
|
7033
|
+
tags
|
|
7034
|
+
} = props;
|
|
7035
|
+
const FormCell = Cell || FormsCell;
|
|
7036
|
+
const columns = [{
|
|
7154
7037
|
Header: i18n("Title"),
|
|
7155
7038
|
accessor: "title",
|
|
7156
7039
|
id: "title",
|
|
7157
|
-
Cell:
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
}));
|
|
7162
|
-
},
|
|
7040
|
+
Cell: props => /*#__PURE__*/React__default["default"].createElement(FormCell, _extends({}, props, {
|
|
7041
|
+
icon: props.icon,
|
|
7042
|
+
i18n: i18n
|
|
7043
|
+
})),
|
|
7163
7044
|
Filter: DefaultColumnFilter,
|
|
7164
7045
|
colspan: 2
|
|
7165
7046
|
}, {
|
|
@@ -7167,13 +7048,11 @@ function FormsTable(_ref) {
|
|
|
7167
7048
|
accessor: "tags",
|
|
7168
7049
|
id: "tags",
|
|
7169
7050
|
hidden: true,
|
|
7170
|
-
Filter:
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
})) : /*#__PURE__*/React__default["default"].createElement(DefaultColumnFilter, props);
|
|
7176
|
-
}
|
|
7051
|
+
Filter: props => tags && tags.length ? /*#__PURE__*/React__default["default"].createElement(SelectColumnFilter, _extends({}, props, {
|
|
7052
|
+
column: _extends({}, props.columns, {
|
|
7053
|
+
choices: tags
|
|
7054
|
+
})
|
|
7055
|
+
})) : /*#__PURE__*/React__default["default"].createElement(DefaultColumnFilter, props)
|
|
7177
7056
|
}];
|
|
7178
7057
|
return /*#__PURE__*/React__default["default"].createElement(Table, _extends({}, props, {
|
|
7179
7058
|
columns: columns
|
|
@@ -7181,13 +7060,12 @@ function FormsTable(_ref) {
|
|
|
7181
7060
|
}
|
|
7182
7061
|
|
|
7183
7062
|
function Loader(_ref) {
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
color =
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
className = _ref$className === void 0 ? "" : _ref$className;
|
|
7063
|
+
let {
|
|
7064
|
+
isActive,
|
|
7065
|
+
color = "blue",
|
|
7066
|
+
icon = "radio-circle",
|
|
7067
|
+
className = ""
|
|
7068
|
+
} = _ref;
|
|
7191
7069
|
if (isActive) {
|
|
7192
7070
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7193
7071
|
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 +7084,43 @@ Loader.propTypes = {
|
|
|
7206
7084
|
className: PropTypes__default["default"].string
|
|
7207
7085
|
};
|
|
7208
7086
|
|
|
7209
|
-
|
|
7087
|
+
const _excluded$3 = ["show", "children", "closeModal", "onClose", "title", "footer", "style", "className"];
|
|
7210
7088
|
function useModal() {
|
|
7211
|
-
|
|
7212
|
-
show = _useState[0],
|
|
7213
|
-
setShowModal = _useState[1];
|
|
7089
|
+
const [show, setShowModal] = React$1.useState(false);
|
|
7214
7090
|
return {
|
|
7215
|
-
show
|
|
7216
|
-
setShowModal
|
|
7217
|
-
openModal
|
|
7091
|
+
show,
|
|
7092
|
+
setShowModal,
|
|
7093
|
+
openModal() {
|
|
7218
7094
|
setShowModal(true);
|
|
7219
7095
|
},
|
|
7220
|
-
closeModal
|
|
7096
|
+
closeModal() {
|
|
7221
7097
|
setShowModal(false);
|
|
7222
7098
|
}
|
|
7223
7099
|
};
|
|
7224
7100
|
}
|
|
7225
7101
|
function Modal(_ref) {
|
|
7226
|
-
|
|
7227
|
-
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
className = _ref$className === void 0 ? "" : _ref$className,
|
|
7102
|
+
let {
|
|
7103
|
+
show,
|
|
7104
|
+
children,
|
|
7105
|
+
closeModal = noop__default$1["default"],
|
|
7106
|
+
onClose = noop__default$1["default"],
|
|
7107
|
+
title,
|
|
7108
|
+
footer: ModalFooter,
|
|
7109
|
+
style,
|
|
7110
|
+
className = ""
|
|
7111
|
+
} = _ref,
|
|
7237
7112
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
setMaxHeight = _useState2[1];
|
|
7243
|
-
var onClickClose = function onClickClose() {
|
|
7113
|
+
const titleRef = React$1.useRef();
|
|
7114
|
+
const footerRef = React$1.useRef();
|
|
7115
|
+
const [maxHeight, setMaxHeight] = React$1.useState();
|
|
7116
|
+
const onClickClose = () => {
|
|
7244
7117
|
closeModal();
|
|
7245
7118
|
onClose();
|
|
7246
7119
|
};
|
|
7247
|
-
React.useEffect(
|
|
7120
|
+
React$1.useEffect(() => {
|
|
7248
7121
|
if (titleRef.current || footerRef.current) {
|
|
7249
7122
|
var _titleRef$current, _footerRef$current;
|
|
7250
|
-
|
|
7123
|
+
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
7124
|
setMaxHeight("calc(85vh - " + height + "px)");
|
|
7252
7125
|
} else {
|
|
7253
7126
|
setMaxHeight("auto");
|
|
@@ -7274,7 +7147,7 @@ function Modal(_ref) {
|
|
|
7274
7147
|
}, title) : null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7275
7148
|
className: "formio-dialog-body",
|
|
7276
7149
|
style: {
|
|
7277
|
-
maxHeight
|
|
7150
|
+
maxHeight
|
|
7278
7151
|
},
|
|
7279
7152
|
"data-testid": "modalBody"
|
|
7280
7153
|
}, show && children), ModalFooter ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -7292,16 +7165,15 @@ function Modal(_ref) {
|
|
|
7292
7165
|
})));
|
|
7293
7166
|
}
|
|
7294
7167
|
|
|
7295
|
-
|
|
7168
|
+
const _excluded$2 = ["maxWidth", "children"];
|
|
7296
7169
|
function RemoveModalFooter(_ref) {
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
i18n =
|
|
7303
|
-
|
|
7304
|
-
} : _ref$i18n;
|
|
7170
|
+
let {
|
|
7171
|
+
value,
|
|
7172
|
+
valueToCompare,
|
|
7173
|
+
onSubmit,
|
|
7174
|
+
onClose,
|
|
7175
|
+
i18n = f => f
|
|
7176
|
+
} = _ref;
|
|
7305
7177
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7306
7178
|
className: "flex items-center justify-center bg-white p-2"
|
|
7307
7179
|
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
@@ -7312,7 +7184,7 @@ function RemoveModalFooter(_ref) {
|
|
|
7312
7184
|
disabled: valueToCompare !== value,
|
|
7313
7185
|
"data-testid": "customSubmitModal",
|
|
7314
7186
|
className: "btn btn-danger mx-2",
|
|
7315
|
-
onClick:
|
|
7187
|
+
onClick: e => {
|
|
7316
7188
|
if (valueToCompare === value) {
|
|
7317
7189
|
onSubmit(e);
|
|
7318
7190
|
}
|
|
@@ -7323,21 +7195,19 @@ function RemoveModalFooter(_ref) {
|
|
|
7323
7195
|
}
|
|
7324
7196
|
function RemoveModal(_ref2) {
|
|
7325
7197
|
var _props$itemType, _props$itemType2;
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7198
|
+
let {
|
|
7199
|
+
maxWidth = "300px",
|
|
7200
|
+
children
|
|
7201
|
+
} = _ref2,
|
|
7329
7202
|
props = _objectWithoutPropertiesLoose(_ref2, _excluded$2);
|
|
7330
|
-
|
|
7331
|
-
i18n =
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
var _useState = React.useState(),
|
|
7335
|
-
value = _useState[0],
|
|
7336
|
-
setValue = _useState[1];
|
|
7203
|
+
const {
|
|
7204
|
+
i18n = f => f
|
|
7205
|
+
} = props;
|
|
7206
|
+
const [value, setValue] = React$1.useState();
|
|
7337
7207
|
return /*#__PURE__*/React__default["default"].createElement(Modal, _extends({}, props, {
|
|
7338
7208
|
className: classnames__default["default"](props.className, "formio-dialog-theme-remove"),
|
|
7339
7209
|
style: {
|
|
7340
|
-
maxWidth
|
|
7210
|
+
maxWidth
|
|
7341
7211
|
},
|
|
7342
7212
|
title: "Drop " + ((_props$itemType = props.itemType) == null ? void 0 : _props$itemType.toLowerCase()),
|
|
7343
7213
|
value: value,
|
|
@@ -7349,92 +7219,90 @@ function RemoveModal(_ref2) {
|
|
|
7349
7219
|
}, 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
7220
|
name: "remove",
|
|
7351
7221
|
value: value,
|
|
7352
|
-
onChange:
|
|
7353
|
-
return setValue(value);
|
|
7354
|
-
}
|
|
7222
|
+
onChange: (name, value) => setValue(value)
|
|
7355
7223
|
})));
|
|
7356
7224
|
}
|
|
7357
7225
|
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
*
|
|
7362
|
-
*
|
|
7363
|
-
* @param
|
|
7364
|
-
* @param
|
|
7365
|
-
* @param data - The submission data where this component's data exists.
|
|
7226
|
+
class ReactComponent extends formiojs.Components.components.field {
|
|
7227
|
+
/**
|
|
7228
|
+
* This is the first phase of component building where the component is instantiated.
|
|
7229
|
+
*
|
|
7230
|
+
* @param component - The component definition created from the settings form.
|
|
7231
|
+
* @param options - Any options passed into the renderer.
|
|
7232
|
+
* @param data - The submission data where this component's data exists.
|
|
7366
7233
|
*/
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
*
|
|
7376
|
-
*
|
|
7377
|
-
* @param value
|
|
7378
|
-
* @param flags
|
|
7234
|
+
constructor(component, options, data) {
|
|
7235
|
+
super(component, options, data);
|
|
7236
|
+
this.reactInstance = void 0;
|
|
7237
|
+
this.shouldSetValue = void 0;
|
|
7238
|
+
this.dataForSetting = void 0;
|
|
7239
|
+
/**
|
|
7240
|
+
* 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.
|
|
7241
|
+
*
|
|
7242
|
+
* @param value
|
|
7243
|
+
* @param flags
|
|
7379
7244
|
*/
|
|
7380
|
-
|
|
7245
|
+
this.updateValue = (value, flags) => {
|
|
7381
7246
|
flags = flags || {};
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7247
|
+
const newValue = value === undefined || value === null ? this.getValue() : value;
|
|
7248
|
+
const changed = newValue !== undefined ? this.hasChanged(newValue, this.dataValue) : false;
|
|
7249
|
+
this.dataValue = Array.isArray(newValue) ? [...newValue] : newValue;
|
|
7250
|
+
this.updateOnChange(flags, changed);
|
|
7386
7251
|
return changed;
|
|
7387
7252
|
};
|
|
7388
|
-
return _this;
|
|
7389
7253
|
}
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7254
|
+
get $reactNode() {
|
|
7255
|
+
return this.refs["react-" + this.id];
|
|
7256
|
+
}
|
|
7257
|
+
/**
|
|
7258
|
+
* This method is called any time the component needs to be rebuilt. It is most frequently used to listen to other
|
|
7259
|
+
* components using the this.on() function.
|
|
7394
7260
|
*/
|
|
7395
|
-
|
|
7396
|
-
return
|
|
7261
|
+
init() {
|
|
7262
|
+
return super.init();
|
|
7397
7263
|
}
|
|
7398
|
-
/**
|
|
7399
|
-
* This method is called before the component is going to be destroyed, which is when the component instance is
|
|
7400
|
-
* destroyed. This is different from detach which is when the component instance still exists but the dom instance is
|
|
7401
|
-
* removed.
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
return
|
|
7264
|
+
/**
|
|
7265
|
+
* This method is called before the component is going to be destroyed, which is when the component instance is
|
|
7266
|
+
* destroyed. This is different from detach which is when the component instance still exists but the dom instance is
|
|
7267
|
+
* removed.
|
|
7268
|
+
*/
|
|
7269
|
+
destroy() {
|
|
7270
|
+
return super.destroy();
|
|
7405
7271
|
}
|
|
7406
|
-
/**
|
|
7407
|
-
* The second phase of component building where the component is rendered as an HTML string.
|
|
7408
|
-
*
|
|
7409
|
-
* @returns {string} - The return is the full string of the component
|
|
7410
|
-
|
|
7411
|
-
|
|
7272
|
+
/**
|
|
7273
|
+
* The second phase of component building where the component is rendered as an HTML string.
|
|
7274
|
+
*
|
|
7275
|
+
* @returns {string} - The return is the full string of the component
|
|
7276
|
+
*/
|
|
7277
|
+
render() {
|
|
7412
7278
|
// For react components, we simply render as a div which will become the react instance.
|
|
7413
7279
|
// By calling super.render(string) it will wrap the component with the needed wrappers to make it a full component.
|
|
7414
|
-
return
|
|
7280
|
+
return super.render("<div ref=\"react-" + this.id + "\"></div>");
|
|
7415
7281
|
}
|
|
7416
|
-
/**
|
|
7417
|
-
* The third phase of component building where the component has been attached to the DOM as 'element' and is ready
|
|
7418
|
-
* to have its javascript events attached.
|
|
7419
|
-
*
|
|
7420
|
-
* @param element
|
|
7421
|
-
* @returns {Promise<void>} - Return a promise that resolves when the attach is complete.
|
|
7422
|
-
|
|
7423
|
-
|
|
7282
|
+
/**
|
|
7283
|
+
* The third phase of component building where the component has been attached to the DOM as 'element' and is ready
|
|
7284
|
+
* to have its javascript events attached.
|
|
7285
|
+
*
|
|
7286
|
+
* @param element
|
|
7287
|
+
* @returns {Promise<void>} - Return a promise that resolves when the attach is complete.
|
|
7288
|
+
*/
|
|
7289
|
+
attach(element) {
|
|
7424
7290
|
try {
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7291
|
+
const _super$attach = super.attach,
|
|
7292
|
+
_this = this;
|
|
7293
|
+
_super$attach.call(_this, element);
|
|
7428
7294
|
// The loadRefs function will find all dom elements that have the "ref" setting that match the object property.
|
|
7429
7295
|
// It can load a single element or multiple elements with the same ref.
|
|
7430
|
-
|
|
7296
|
+
_this.loadRefs(element, {
|
|
7297
|
+
["react-" + _this.id]: "single"
|
|
7298
|
+
});
|
|
7431
7299
|
// @ts-ignore
|
|
7432
|
-
if (
|
|
7300
|
+
if (_this.refs["react-" + _this.id]) {
|
|
7433
7301
|
// @ts-ignore
|
|
7434
|
-
|
|
7435
|
-
if (
|
|
7436
|
-
|
|
7437
|
-
|
|
7302
|
+
_this.reactInstance = _this.attachReact(_this.refs["react-" + _this.id]);
|
|
7303
|
+
if (_this.shouldSetValue) {
|
|
7304
|
+
_this.setValue(_this.dataForSetting);
|
|
7305
|
+
_this.updateValue(_this.dataForSetting);
|
|
7438
7306
|
}
|
|
7439
7307
|
}
|
|
7440
7308
|
return Promise.resolve();
|
|
@@ -7442,53 +7310,49 @@ var ReactComponent = /*#__PURE__*/function (_Components$component) {
|
|
|
7442
7310
|
return Promise.reject(e);
|
|
7443
7311
|
}
|
|
7444
7312
|
}
|
|
7445
|
-
/**
|
|
7446
|
-
* The fourth phase of component building where the component is being removed from the page. This could be a redraw
|
|
7447
|
-
* or it is being removed from the form.
|
|
7313
|
+
/**
|
|
7314
|
+
* The fourth phase of component building where the component is being removed from the page. This could be a redraw
|
|
7315
|
+
* or it is being removed from the form.
|
|
7448
7316
|
*/
|
|
7449
|
-
|
|
7450
|
-
_proto.detach = function detach() {
|
|
7317
|
+
detach() {
|
|
7451
7318
|
// @ts-ignore
|
|
7452
7319
|
if (this.refs["react-" + this.id]) {
|
|
7453
7320
|
// @ts-ignore
|
|
7454
7321
|
this.detachReact(this.refs["react-" + this.id]);
|
|
7455
7322
|
}
|
|
7456
|
-
|
|
7323
|
+
super.detach();
|
|
7457
7324
|
}
|
|
7458
|
-
/**
|
|
7459
|
-
* Override this function to render a react component.
|
|
7460
|
-
|
|
7461
|
-
|
|
7325
|
+
/**
|
|
7326
|
+
* Override this function to render a react component.
|
|
7327
|
+
*/
|
|
7328
|
+
renderReact() {
|
|
7462
7329
|
return null;
|
|
7463
7330
|
}
|
|
7464
|
-
/**
|
|
7465
|
-
* Override this function to insert your custom component.
|
|
7466
|
-
*
|
|
7467
|
-
* @param element
|
|
7331
|
+
/**
|
|
7332
|
+
* Override this function to insert your custom component.
|
|
7333
|
+
*
|
|
7334
|
+
* @param element
|
|
7468
7335
|
*/
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
_proto.attachReact = function attachReact(element) {
|
|
7472
|
-
// eslint-disable-next-line react/no-render-return-value
|
|
7336
|
+
attachReact(element) {
|
|
7337
|
+
// eslint-disable-next-line react/no-render-return-value,react/no-deprecated
|
|
7473
7338
|
return ReactDOM__default["default"].render(this.renderReact(), element);
|
|
7474
7339
|
}
|
|
7475
|
-
/**
|
|
7476
|
-
* Override this function.
|
|
7340
|
+
/**
|
|
7341
|
+
* Override this function.
|
|
7477
7342
|
*/
|
|
7478
|
-
|
|
7479
|
-
;
|
|
7480
|
-
_proto.detachReact = function detachReact(element) {
|
|
7343
|
+
detachReact(element) {
|
|
7481
7344
|
if (element) {
|
|
7345
|
+
// eslint-disable-next-line react/no-deprecated
|
|
7482
7346
|
ReactDOM__default["default"].unmountComponentAtNode(element);
|
|
7483
7347
|
}
|
|
7484
7348
|
}
|
|
7485
|
-
/**
|
|
7486
|
-
* Something external has set a value and our component needs to be updated to reflect that. For example, loading a submission.
|
|
7487
|
-
*
|
|
7488
|
-
* @param value
|
|
7489
|
-
* @param flags
|
|
7490
|
-
|
|
7491
|
-
|
|
7349
|
+
/**
|
|
7350
|
+
* Something external has set a value and our component needs to be updated to reflect that. For example, loading a submission.
|
|
7351
|
+
*
|
|
7352
|
+
* @param value
|
|
7353
|
+
* @param flags
|
|
7354
|
+
*/
|
|
7355
|
+
setValue(value) {
|
|
7492
7356
|
if (this.reactInstance) {
|
|
7493
7357
|
this.reactInstance.setState({
|
|
7494
7358
|
value: value
|
|
@@ -7499,57 +7363,48 @@ var ReactComponent = /*#__PURE__*/function (_Components$component) {
|
|
|
7499
7363
|
this.dataForSetting = value;
|
|
7500
7364
|
}
|
|
7501
7365
|
return false;
|
|
7502
|
-
}
|
|
7503
|
-
/**
|
|
7504
|
-
* Get the current value of the component. Should return the value set in the react component.
|
|
7505
|
-
*
|
|
7506
|
-
* @returns {*}
|
|
7366
|
+
}
|
|
7367
|
+
/**
|
|
7368
|
+
* Get the current value of the component. Should return the value set in the react component.
|
|
7369
|
+
*
|
|
7370
|
+
* @returns {*}
|
|
7507
7371
|
*/
|
|
7508
|
-
|
|
7372
|
+
getValue() {
|
|
7509
7373
|
if (this.reactInstance) {
|
|
7510
7374
|
return this.reactInstance.state.value;
|
|
7511
7375
|
}
|
|
7512
7376
|
return this.defaultValue;
|
|
7513
7377
|
}
|
|
7514
|
-
/**
|
|
7515
|
-
* Override normal validation check to insert custom validation in react component.
|
|
7516
|
-
*
|
|
7517
|
-
* @param data
|
|
7518
|
-
* @param dirty
|
|
7519
|
-
* @param rowData
|
|
7520
|
-
* @returns {boolean}
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7378
|
+
/**
|
|
7379
|
+
* Override normal validation check to insert custom validation in react component.
|
|
7380
|
+
*
|
|
7381
|
+
* @param data
|
|
7382
|
+
* @param dirty
|
|
7383
|
+
* @param rowData
|
|
7384
|
+
* @returns {boolean}
|
|
7385
|
+
*/
|
|
7386
|
+
checkValidity(data, dirty, rowData) {
|
|
7387
|
+
const valid = super.checkValidity(data, dirty, rowData);
|
|
7524
7388
|
if (!valid) {
|
|
7525
7389
|
return false;
|
|
7526
7390
|
}
|
|
7527
7391
|
return this.validate(data, dirty, rowData);
|
|
7528
7392
|
}
|
|
7529
7393
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7530
|
-
|
|
7531
|
-
_proto.validate = function validate(data, dirty, rowData) {
|
|
7394
|
+
validate(data, dirty, rowData) {
|
|
7532
7395
|
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);
|
|
7396
|
+
}
|
|
7397
|
+
}
|
|
7542
7398
|
|
|
7543
7399
|
function DefaultCell(_ref) {
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
render =
|
|
7547
|
-
|
|
7548
|
-
} : _ref$render;
|
|
7400
|
+
let {
|
|
7401
|
+
value,
|
|
7402
|
+
render = f => f
|
|
7403
|
+
} = _ref;
|
|
7549
7404
|
if (value === undefined) {
|
|
7550
7405
|
return /*#__PURE__*/React__default["default"].createElement("span", null);
|
|
7551
7406
|
}
|
|
7552
|
-
|
|
7407
|
+
const rendered = render(value);
|
|
7553
7408
|
if (value !== rendered) {
|
|
7554
7409
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7555
7410
|
dangerouslySetInnerHTML: {
|
|
@@ -7561,21 +7416,17 @@ function DefaultCell(_ref) {
|
|
|
7561
7416
|
}
|
|
7562
7417
|
|
|
7563
7418
|
function mapFormToColumns(form) {
|
|
7564
|
-
|
|
7565
|
-
FormioUtils__default["default"].eachComponent(form.components,
|
|
7419
|
+
const columns = [];
|
|
7420
|
+
FormioUtils__default["default"].eachComponent(form.components, component => {
|
|
7566
7421
|
if (component.tableView && component.key) {
|
|
7567
|
-
|
|
7568
|
-
|
|
7422
|
+
const cmp = formiojs.Components.create(component, {}, null, true);
|
|
7423
|
+
const column = {
|
|
7569
7424
|
Header: component.label || component.title || component.key,
|
|
7570
7425
|
accessor: "data." + component.key,
|
|
7571
7426
|
className: "text-center",
|
|
7572
|
-
Cell:
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
return cmp.asString(value);
|
|
7576
|
-
}
|
|
7577
|
-
}));
|
|
7578
|
-
}
|
|
7427
|
+
Cell: props => /*#__PURE__*/React__default["default"].createElement(DefaultCell, _extends({}, props, {
|
|
7428
|
+
render: value => cmp.asString(value)
|
|
7429
|
+
}))
|
|
7579
7430
|
};
|
|
7580
7431
|
if (component.type === "select" && component.dataSrc === "values") {
|
|
7581
7432
|
column.Filter = SelectColumnFilter;
|
|
@@ -7587,58 +7438,61 @@ function mapFormToColumns(form) {
|
|
|
7587
7438
|
return columns;
|
|
7588
7439
|
}
|
|
7589
7440
|
|
|
7590
|
-
|
|
7441
|
+
const _excluded$1 = ["form"];
|
|
7591
7442
|
function SubmissionsTable(_ref) {
|
|
7592
|
-
|
|
7443
|
+
let {
|
|
7444
|
+
form
|
|
7445
|
+
} = _ref,
|
|
7593
7446
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
7594
|
-
|
|
7447
|
+
const columns = form && mapFormToColumns(form);
|
|
7595
7448
|
return /*#__PURE__*/React__default["default"].createElement(Table, _extends({}, props, {
|
|
7596
7449
|
columns: columns
|
|
7597
7450
|
}));
|
|
7598
7451
|
}
|
|
7599
7452
|
|
|
7600
7453
|
function SliderColumnFilter(_ref) {
|
|
7601
|
-
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7454
|
+
let {
|
|
7455
|
+
column: {
|
|
7456
|
+
filterValue,
|
|
7457
|
+
setFilter,
|
|
7458
|
+
preFilteredRows,
|
|
7459
|
+
id
|
|
7460
|
+
}
|
|
7461
|
+
} = _ref;
|
|
7462
|
+
const [min, max] = React__default["default"].useMemo(() => {
|
|
7463
|
+
let min = preFilteredRows.length ? preFilteredRows[0].values[id] : 0;
|
|
7464
|
+
let max = preFilteredRows.length ? preFilteredRows[0].values[id] : 0;
|
|
7465
|
+
preFilteredRows.forEach(row => {
|
|
7466
|
+
min = Math.min(row == null ? void 0 : row.values[id], min);
|
|
7467
|
+
max = Math.max(row == null ? void 0 : row.values[id], max);
|
|
7468
|
+
});
|
|
7469
|
+
return [min, max];
|
|
7470
|
+
}, [id, preFilteredRows]);
|
|
7617
7471
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("input", {
|
|
7618
7472
|
type: "range",
|
|
7619
7473
|
min: min,
|
|
7620
7474
|
max: max,
|
|
7621
7475
|
value: filterValue || min,
|
|
7622
|
-
onChange:
|
|
7476
|
+
onChange: e => {
|
|
7623
7477
|
setFilter(parseInt(e.target.value, 10));
|
|
7624
7478
|
}
|
|
7625
7479
|
}), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
7626
|
-
onClick:
|
|
7627
|
-
return setFilter(undefined);
|
|
7628
|
-
}
|
|
7480
|
+
onClick: () => setFilter(undefined)
|
|
7629
7481
|
}, "Off"));
|
|
7630
7482
|
}
|
|
7631
7483
|
|
|
7632
|
-
|
|
7484
|
+
const _excluded = ["style", "current", "items", "children", "HeaderChildren", "AddButton", "Button", "className", "onClick", "i18n"];
|
|
7633
7485
|
function ButtonTab(_ref) {
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7486
|
+
let {
|
|
7487
|
+
icon,
|
|
7488
|
+
back,
|
|
7489
|
+
onClick,
|
|
7490
|
+
isActive,
|
|
7491
|
+
reverse,
|
|
7492
|
+
children,
|
|
7493
|
+
className,
|
|
7494
|
+
after
|
|
7495
|
+
} = _ref;
|
|
7642
7496
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7643
7497
|
title: "button-wrapper",
|
|
7644
7498
|
className: classnames__default["default"]("tw-tabs__button-wrapper", isActive ? "-active" : "", back ? "-back" : "", className)
|
|
@@ -7655,21 +7509,18 @@ function ButtonTab(_ref) {
|
|
|
7655
7509
|
}));
|
|
7656
7510
|
}
|
|
7657
7511
|
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,
|
|
7512
|
+
let {
|
|
7513
|
+
style,
|
|
7514
|
+
current,
|
|
7515
|
+
items = [],
|
|
7516
|
+
children,
|
|
7517
|
+
HeaderChildren,
|
|
7518
|
+
AddButton,
|
|
7519
|
+
Button = ButtonTab,
|
|
7520
|
+
className,
|
|
7521
|
+
onClick,
|
|
7522
|
+
i18n = f => f
|
|
7523
|
+
} = _ref2,
|
|
7673
7524
|
additionalProps = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
7674
7525
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7675
7526
|
"data-testid": "tabs-comp",
|
|
@@ -7681,16 +7532,14 @@ function Tabs(_ref2) {
|
|
|
7681
7532
|
className: "tw-tabs__header-wrapper"
|
|
7682
7533
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7683
7534
|
className: "tw-tabs__header-border"
|
|
7684
|
-
}), items.filter(
|
|
7685
|
-
return item.label || item.icon;
|
|
7686
|
-
}).map(function (item, index) {
|
|
7535
|
+
}), items.filter(item => item.label || item.icon).map((item, index) => {
|
|
7687
7536
|
return /*#__PURE__*/React__default["default"].createElement(Button, _extends({
|
|
7688
7537
|
key: index,
|
|
7689
7538
|
back: item.back,
|
|
7690
7539
|
isActive: (current == null ? void 0 : current.action) === item.action,
|
|
7691
7540
|
exact: item.exact,
|
|
7692
|
-
onClick:
|
|
7693
|
-
|
|
7541
|
+
onClick: () => {
|
|
7542
|
+
onClick && onClick(item);
|
|
7694
7543
|
}
|
|
7695
7544
|
}, additionalProps, item), i18n(item.label || ""));
|
|
7696
7545
|
}), AddButton && /*#__PURE__*/React__default["default"].createElement(AddButton, _extends({}, additionalProps, {
|
|
@@ -7704,11 +7553,12 @@ function Tabs(_ref2) {
|
|
|
7704
7553
|
}
|
|
7705
7554
|
|
|
7706
7555
|
function mapPagination(_temp) {
|
|
7707
|
-
|
|
7708
|
-
skip
|
|
7709
|
-
limit
|
|
7710
|
-
serverCount
|
|
7711
|
-
length
|
|
7556
|
+
let {
|
|
7557
|
+
skip,
|
|
7558
|
+
limit,
|
|
7559
|
+
serverCount,
|
|
7560
|
+
length
|
|
7561
|
+
} = _temp === void 0 ? {} : _temp;
|
|
7712
7562
|
skip = skip || 0;
|
|
7713
7563
|
limit = limit || 10;
|
|
7714
7564
|
serverCount = serverCount || length;
|