@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.
Files changed (37) hide show
  1. package/coverage.json +4 -4
  2. package/dist/components/actions-table/actionsTable.stories.d.ts +8 -53
  3. package/dist/components/form-access/formAccess.component.d.ts +2 -13
  4. package/dist/components/form-access/formAccess.stories.d.ts +3 -44
  5. package/dist/components/form-control/formControl.component.d.ts +3 -11
  6. package/dist/components/react-component/reactComponent.component.d.ts +1 -1
  7. package/dist/components/select/select.component.d.ts +5 -18
  8. package/dist/components/table/components/defaultCellOperations.component.d.ts +12 -1
  9. package/dist/components/table/components/defaultOperationButton.component.d.ts +4 -4
  10. package/dist/components/table/hooks/useOperations.hook.d.ts +2 -2
  11. package/dist/index.js +1184 -1334
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.modern.js +300 -316
  14. package/dist/index.modern.js.map +1 -1
  15. package/package.json +13 -9
  16. package/src/components/__fixtures__/form-actions.json +240 -0
  17. package/src/components/actions-table/__fixtures__/data.json +12 -0
  18. package/src/components/actions-table/actionsTable.component.spec.tsx +44 -13
  19. package/src/components/actions-table/actionsTable.component.tsx +2 -1
  20. package/src/components/actions-table/actionsTable.stories.tsx +71 -289
  21. package/src/components/form/form.stories.tsx +1 -2
  22. package/src/components/form-access/formAccess.component.tsx +2 -13
  23. package/src/components/form-access/formAccess.stories.tsx +55 -49
  24. package/src/components/form-action/formAction.component.tsx +1 -0
  25. package/src/components/form-control/formControl.component.tsx +3 -10
  26. package/src/components/form-edit/formEdit.reducer.ts +0 -1
  27. package/src/components/form-settings/formSettings.component.spec.tsx +4 -4
  28. package/src/components/pagination/pagination.component.spec.tsx +0 -2
  29. package/src/components/react-component/reactComponent.component.tsx +5 -5
  30. package/src/components/select/select.component.tsx +10 -23
  31. package/src/components/table/components/defaultCellOperations.component.tsx +17 -4
  32. package/src/components/table/components/defaultOperationButton.component.tsx +11 -4
  33. package/src/components/table/components/defaultRow.component.tsx +1 -0
  34. package/src/components/table/filters/defaultColumnFilter.component.tsx +1 -0
  35. package/src/components/table/hooks/useOperations.hook.tsx +3 -3
  36. package/src/react-table.d.ts +2 -0
  37. 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
- var target = event.target;
81
+ const {
82
+ target
83
+ } = event;
125
84
  if (event.target.multiple && event.target.selectedOptions) {
126
- return Array.from(event.target.selectedOptions, function (option) {
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
- var children = _ref.children,
135
- name = _ref.name,
136
- required = _ref.required,
137
- prefix = _ref.prefix,
138
- suffix = _ref.suffix,
139
- description = _ref.description,
140
- label = _ref.label,
141
- className = _ref.className;
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
- var _excluded$f = ["name", "label", "size", "onChange", "required", "value", "choices", "description", "placeholder", "prefix", "suffix", "multiple", "layout"];
127
+ const _excluded$g = ["name", "label", "size", "onChange", "required", "value", "choices", "description", "placeholder", "prefix", "suffix", "multiple", "layout"];
176
128
  function Select(_ref) {
177
- var name = _ref.name,
178
- label = _ref.label,
179
- size = _ref.size,
180
- _onChange = _ref.onChange,
181
- required = _ref.required,
182
- value = _ref.value,
183
- choices = _ref.choices,
184
- description = _ref.description,
185
- placeholder = _ref.placeholder,
186
- prefix = _ref.prefix,
187
- suffix = _ref.suffix,
188
- multiple = _ref.multiple,
189
- layout = _ref.layout,
190
- props = _objectWithoutPropertiesLoose(_ref, _excluded$f);
191
- var ref = React.useRef();
192
- React.useEffect(function () {
193
- var instance;
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 function () {
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
- }].concat(choices);
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: function onChange(event) {
227
- _onChange && _onChange(name, getEventValue(event));
228
- }
229
- }), choices.map(function (_ref2) {
230
- var label = _ref2.label,
231
- value = _ref2.value;
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
- var enableDragNDrop = _ref.enableDragNDrop,
250
- children = _ref.children;
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
- var LEFT_PAGE = "LEFT";
257
- var RIGHT_PAGE = "RIGHT";
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
- var i = from;
263
- var range = [];
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
- var currentPage = _ref.currentPage,
272
- _ref$pageNeighbours = _ref.pageNeighbours,
273
- pageNeighbours = _ref$pageNeighbours === void 0 ? 1 : _ref$pageNeighbours,
274
- totalPages = _ref.totalPages;
275
- var totalNumbers = pageNeighbours * 2 + 3;
276
- var totalBlocks = totalNumbers + 2;
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
- var calculatedStartPage = Math.max(2, currentPage - pageNeighbours);
279
- var calculatedEndPage = Math.min(totalPages - 1, currentPage + pageNeighbours);
280
- var startPage = calculatedStartPage === 3 ? 2 : calculatedStartPage;
281
- var endPage = calculatedEndPage === totalPages - 2 ? totalPages - 1 : calculatedEndPage;
282
- var pages = range(startPage, endPage);
283
- var hasLeftSpill = startPage > 2;
284
- var hasRightSpill = totalPages - endPage > 1;
285
- var spillOffset = totalNumbers - (pages.length + 1);
286
- var extraPages;
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].concat(extraPages, pages);
240
+ pages = [LEFT_PAGE, ...extraPages, ...pages];
290
241
  } else if (!hasLeftSpill && hasRightSpill) {
291
242
  extraPages = range(endPage + 1, endPage + spillOffset);
292
- pages = [].concat(pages, extraPages, [RIGHT_PAGE]);
243
+ pages = [...pages, ...extraPages, RIGHT_PAGE];
293
244
  } else {
294
- pages = [LEFT_PAGE].concat(pages, [RIGHT_PAGE]);
245
+ pages = [LEFT_PAGE, ...pages, RIGHT_PAGE];
295
246
  }
296
- return [1].concat(pages, [totalPages]);
247
+ return [1, ...pages, totalPages];
297
248
  }
298
249
  return range(1, totalPages);
299
250
  }
300
251
 
301
- var _excluded$e = ["component", "children", "disabled", "active"];
252
+ const _excluded$f = ["component", "children", "disabled", "active"];
302
253
  function PaginationButton(props) {
303
- var _props$component = props.component,
304
- Component = _props$component === void 0 ? "button" : _props$component,
305
- children = props.children,
306
- disabled = props.disabled,
307
- active = props.active,
308
- otherProps = _objectWithoutPropertiesLoose(props, _excluded$e);
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
- var className = props.className,
317
- _props$pageSizes = props.pageSizes,
318
- pageSizes = _props$pageSizes === void 0 ? [10, 25, 50, 100] : _props$pageSizes,
319
- gotoPage = props.gotoPage,
320
- canPreviousPage = props.canPreviousPage,
321
- previousPage = props.previousPage,
322
- nextPage = props.nextPage,
323
- canNextPage = props.canNextPage,
324
- pageCount = props.pageCount,
325
- _props$pageIndex = props.pageIndex,
326
- pageIndex = _props$pageIndex === void 0 ? 1 : _props$pageIndex,
327
- pageOptions = props.pageOptions,
328
- pageSize = props.pageSize,
329
- setPageSize = props.setPageSize,
330
- totalLength = props.totalLength,
331
- _props$i18n = props.i18n,
332
- i18n = _props$i18n === void 0 ? function (f) {
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
- var choices = pageSizes.map(function (value) {
341
- return {
342
- value: value,
343
- label: value
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: function onClick() {
357
- return previousPage();
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
- var active = page - 1 === pageIndex;
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: function 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: function 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: function onChange(name, value) {
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
- var column = _ref.column;
410
- var isSorted = column.isSorted,
411
- isSortedDesc = column.isSortedDesc;
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
- var column = _ref.column;
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
- var _excluded$d = ["onDrag", "onDrop", "index"];
431
- var DND_ITEM_TYPE = "row";
377
+ const _excluded$e = ["onDrag", "onDrop", "index"];
378
+ const DND_ITEM_TYPE = "row";
432
379
  function useDndRow(_ref) {
433
- var onDrag = _ref.onDrag,
434
- onDrop = _ref.onDrop,
435
- index = _ref.index,
436
- props = _objectWithoutPropertiesLoose(_ref, _excluded$d);
437
- var dropRef = React.useRef(null);
438
- var dragRef = React.useRef(null);
439
- var _useDrop = reactDnd.useDrop({
440
- accept: DND_ITEM_TYPE,
441
- drop: function drop(item) {
442
- onDrop(item);
443
- },
444
- hover: function hover(item, monitor) {
445
- if (!dropRef.current) {
446
- return;
447
- }
448
- var dragIndex = item.index;
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
- drop = _useDrop[1];
486
- var _useDrag = reactDnd.useDrag(function () {
487
- return {
488
- type: DND_ITEM_TYPE,
489
- item: {
490
- index: index
491
- },
492
- collect: function collect(monitor) {
493
- return {
494
- isDragging: monitor.isDragging()
495
- };
496
- }
497
- };
498
- }),
499
- isDragging = _useDrag[0].isDragging,
500
- drag = _useDrag[1],
501
- preview = _useDrag[2];
502
- var opacity = isDragging ? 0 : 1;
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: opacity,
507
- isDragging: isDragging,
508
- dropRef: dropRef,
509
- dragRef: dragRef
449
+ opacity,
450
+ isDragging,
451
+ dropRef,
452
+ dragRef
510
453
  });
511
454
  }
512
455
 
513
456
  function DefaultCells(_ref) {
514
- var row = _ref.row;
515
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, row.cells.map(function (cell, i) {
516
- var _cell$column = cell.column,
517
- hidden = _cell$column.hidden,
518
- colspan = _cell$column.colspan;
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
- var _excluded$c = ["onClick", "row", "enableDragNDrop", "onDrop", "onDrag"];
479
+ const _excluded$d = ["onClick", "row", "enableDragNDrop", "onDrop", "onDrag"];
534
480
  function DefaultDndRow(props) {
535
- var _useDndRow = useDndRow(props),
536
- isDragging = _useDndRow.isDragging,
537
- dragRef = _useDndRow.dragRef,
538
- dropRef = _useDndRow.dropRef,
539
- opacity = _useDndRow.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: 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
- var _onClick = _ref.onClick,
560
- row = _ref.row,
561
- enableDragNDrop = _ref.enableDragNDrop,
562
- onDrop = _ref.onDrop,
563
- onDrag = _ref.onDrag,
564
- props = _objectWithoutPropertiesLoose(_ref, _excluded$c);
565
- var opts = _extends({}, props, {
566
- onClick: function onClick() {
567
- return _onClick(row.original, "row");
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
- var last = null;
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(function () {
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
- var _excluded$b = ["name", "value", "label", "onChange", "required", "size", "type", "prefix", "suffix", "description", "className", "placeholder"];
540
+ const _excluded$c = ["name", "value", "label", "onChange", "required", "size", "type", "prefix", "suffix", "description", "className", "placeholder"];
597
541
  function InputText(_ref) {
598
- var name = _ref.name,
599
- value = _ref.value,
600
- label = _ref.label,
601
- onChange = _ref.onChange,
602
- required = _ref.required,
603
- size = _ref.size,
604
- type = _ref.type,
605
- prefix = _ref.prefix,
606
- suffix = _ref.suffix,
607
- description = _ref.description,
608
- className = _ref.className,
609
- placeholder = _ref.placeholder,
610
- props = _objectWithoutPropertiesLoose(_ref, _excluded$b);
611
- var _useState = React.useState(value),
612
- localValue = _useState[0],
613
- setValue = _useState[1];
614
- var change = React.useMemo(function () {
615
- return onChange && callLast(onChange, 300);
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: function onChange(event) {
638
- var value = getEventValue(event);
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
- var filterId = props.filterId,
658
- setFilterId = props.setFilterId,
659
- _props$column = props.column,
660
- id = _props$column.id,
661
- filterValue = _props$column.filterValue,
662
- setFilter = _props$column.setFilter;
663
- var _useState = React.useState(filterValue || ""),
664
- value = _useState[0],
665
- setValue = _useState[1];
666
- var onChange = React.useCallback(function (name, value) {
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
- var swapElements = function swapElements(myArray, index1, index2) {
684
- myArray = [].concat(myArray);
685
- var _ref = [myArray[index2], myArray[index1]];
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
- var stopPropagationWrapper = function stopPropagationWrapper(fn) {
692
- return function (event) {
693
- event.stopPropagation();
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
- var _props$className = props.className,
700
- className = _props$className === void 0 ? "btn" : _props$className,
701
- _props$buttonSize = props.buttonSize,
702
- buttonSize = _props$buttonSize === void 0 ? "xs" : _props$buttonSize,
703
- _props$buttonType = props.buttonType,
704
- buttonType = _props$buttonType === void 0 ? "primary" : _props$buttonType,
705
- buttonOutline = props.buttonOutline,
706
- onClick = props.onClick,
707
- action = props.action,
708
- _props$icon = props.icon,
709
- icon = _props$icon === void 0 ? "" : _props$icon,
710
- _props$title = props.title,
711
- title = _props$title === void 0 ? "" : _props$title,
712
- _props$i18n = props.i18n,
713
- i18n = _props$i18n === void 0 ? function (f) {
714
- return f;
715
- } : _props$i18n;
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(function () {
719
- return onClick(action);
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__*/React__default["default"].createElement("span", {
661
+ }), " ", title && " ") : null, title && /*#__PURE__*/React.createElement("span", {
724
662
  className: icon && title ? "ml-1" : ""
725
663
  }, i18n(title)));
726
664
  }
727
665
 
728
- var _excluded$a = ["OperationButton"];
666
+ const _excluded$a = ["OperationButton"];
729
667
  function DefaultCellOperations(_ref) {
730
- var operations = _ref.operations,
731
- row = _ref.row,
732
- _onClick = _ref.onClick,
733
- ctx = _ref.ctx,
734
- i18n = _ref.i18n;
735
- var data = row.original;
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(function (_ref2) {
739
- var permissionsResolver = _ref2.permissionsResolver;
678
+ }, operations.filter(_ref2 => {
679
+ let {
680
+ permissionsResolver
681
+ } = _ref2;
740
682
  return !permissionsResolver || permissionsResolver(data, ctx);
741
- }).map(function (_ref3) {
742
- var _ref3$OperationButton = _ref3.OperationButton,
743
- OperationButton = _ref3$OperationButton === void 0 ? DefaultOperationButton : _ref3$OperationButton,
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
- onClick: function onClick(action) {
749
- return _onClick(data, action);
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
- var operations = _ref.operations,
760
- _ref$CellOperations = _ref.CellOperations,
761
- CellOperations = _ref$CellOperations === void 0 ? DefaultCellOperations : _ref$CellOperations,
762
- onClick = _ref.onClick,
763
- _ref$i18n = _ref.i18n,
764
- i18n = _ref$i18n === void 0 ? function (f) {
765
- return f;
766
- } : _ref$i18n,
767
- ctx = _ref.ctx;
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 [].concat(columns, [{
713
+ return [...columns, {
774
714
  id: "operations",
775
715
  groupByBoundary: true,
776
- Header: function Header() {
777
- return /*#__PURE__*/React__default["default"].createElement("div", {
778
- className: "text-center"
779
- }, i18n("Operations"));
780
- },
781
- Cell: function Cell(props) {
782
- return /*#__PURE__*/React__default["default"].createElement(CellOperations, _extends({}, props, {
783
- operations: operations,
784
- onClick: onClick,
785
- ctx: ctx,
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
- var _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"];
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 function (data, action) {
797
- var operation = operations.find(function (operation) {
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
- var hooks = [reactTable.useFilters, reactTable.useGroupBy, reactTable.useSortBy, reactTable.usePagination];
749
+ const hooks = [reactTable.useFilters, reactTable.useGroupBy, reactTable.useSortBy, reactTable.usePagination];
816
750
  function useCustomTable(props) {
817
- var children = props.children,
818
- _props$className = props.className,
819
- className = _props$className === void 0 ? "" : _props$className,
820
- columns = props.columns,
821
- data = props.data,
822
- _props$onChange = props.onChange,
823
- onChange = _props$onChange === void 0 ? noop__default["default"] : _props$onChange,
824
- _props$onClick = props.onClick,
825
- onClick = _props$onClick === void 0 ? noop__default["default"] : _props$onClick,
826
- _props$onDrag = props.onDrag,
827
- onDrag = _props$onDrag === void 0 ? noop__default["default"] : _props$onDrag,
828
- _props$onDrop = props.onDrop,
829
- onDrop = _props$onDrop === void 0 ? noop__default["default"] : _props$onDrop,
830
- _props$operations = props.operations,
831
- operations = _props$operations === void 0 ? [] : _props$operations,
832
- _props$pageSizes = props.pageSizes,
833
- pageSizes = _props$pageSizes === void 0 ? [10, 25, 50, 100] : _props$pageSizes,
834
- controlledFilters = props.filters,
835
- controlledFilterId = props.filterId,
836
- controlledPageSize = props.pageSize,
837
- controlledPageIndex = props.pageIndex,
838
- totalLength = props.totalLength,
839
- controlledSortBy = props.sortBy,
840
- isLoading = props.isLoading,
841
- disableFilters = props.disableFilters,
842
- disablePagination = props.disablePagination,
843
- _props$ArrowSort = props.ArrowSort,
844
- ArrowSort = _props$ArrowSort === void 0 ? DefaultArrowSort : _props$ArrowSort,
845
- _props$ColumnFilter = props.ColumnFilter,
846
- ColumnFilter = _props$ColumnFilter === void 0 ? DefaultColumnFilter : _props$ColumnFilter,
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
- var _onClick = getOperationCallback(operations, onClick);
864
- var defaultColumn = React__default["default"].useMemo(function () {
865
- return {
866
- // Let's set up our default Filter UI
867
- Filter: ColumnFilter,
868
- ArrowSort: ArrowSort
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
- var _useState = React.useState(data),
876
- records = _useState[0],
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
- var _onDrag = function _onDrag(dragIndex, hoverIndex) {
882
- var newRecords = swapElements([].concat(records), dragIndex, hoverIndex);
794
+ const _onDrag = (dragIndex, hoverIndex) => {
795
+ const newRecords = swapElements([...records], dragIndex, hoverIndex);
883
796
  setRecords(newRecords);
884
797
  onDrag(newRecords);
885
798
  };
886
- var tableInstance = reactTable.useTable.apply(void 0, [_extends({}, props, {
887
- columns: columns,
888
- data: data,
889
- ctx: ctx,
890
- defaultColumn: 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: disableFilters,
902
- filterId: filterId,
903
- setFilterId: setFilterId
904
- })].concat(hooks, [useOperations({
905
- operations: operations,
906
- CellOperations: CellOperations,
814
+ disableFilters,
815
+ filterId,
816
+ setFilterId
817
+ }), ...hooks, useOperations({
818
+ operations,
819
+ CellOperations,
907
820
  onClick: _onClick,
908
- ctx: ctx,
909
- i18n: i18n
910
- })]));
911
- var setPageSize = tableInstance.setPageSize,
912
- _tableInstance$state = tableInstance.state,
913
- pageIndex = _tableInstance$state.pageIndex,
914
- pageSize = _tableInstance$state.pageSize,
915
- sortBy = _tableInstance$state.sortBy,
916
- filters = _tableInstance$state.filters;
917
- React__default["default"].useEffect(function () {
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: pageIndex,
920
- pageSize: pageSize,
921
- sortBy: sortBy,
922
- filters: filters,
923
- filterId: 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: className,
928
- tableInstance: tableInstance,
929
- CellHeader: CellHeader,
930
- isLoading: isLoading,
931
- Loader: Loader,
932
- EmptyData: EmptyData,
933
- Row: Row,
934
- data: data,
935
- disablePagination: 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: pageIndex,
938
- pageSize: pageSize,
939
- pageSizes: pageSizes,
940
- totalLength: totalLength,
941
- setPageSize: setPageSize,
942
- i18n: i18n,
943
- children: 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
- var _useCustomTable = useCustomTable(props),
953
- className = _useCustomTable.className,
954
- tableInstance = _useCustomTable.tableInstance,
955
- CellHeader = _useCustomTable.CellHeader,
956
- isLoading = _useCustomTable.isLoading,
957
- onClick = _useCustomTable.onClick,
958
- Loader = _useCustomTable.Loader,
959
- EmptyData = _useCustomTable.EmptyData,
960
- Row = _useCustomTable.Row,
961
- data = _useCustomTable.data,
962
- disablePagination = _useCustomTable.disablePagination,
963
- Pagination = _useCustomTable.Pagination,
964
- pageIndex = _useCustomTable.pageIndex,
965
- pageSize = _useCustomTable.pageSize,
966
- pageSizes = _useCustomTable.pageSizes,
967
- setPageSize = _useCustomTable.setPageSize,
968
- totalLength = _useCustomTable.totalLength,
969
- i18n = _useCustomTable.i18n,
970
- enableDragNDrop = _useCustomTable.enableDragNDrop,
971
- children = _useCustomTable.children,
972
- onDrag = _useCustomTable.onDrag,
973
- onDrop = _useCustomTable.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(function (headerGroup, i) {
982
- return /*#__PURE__*/React__default["default"].createElement("tr", _extends({}, headerGroup.getHeaderGroupProps(), {
983
- key: "tableInstance.headerGroups" + i
984
- }), enableDragNDrop ? /*#__PURE__*/React__default["default"].createElement("th", {
985
- role: "columnheader",
986
- className: "text-center"
987
- }, /*#__PURE__*/React__default["default"].createElement("div", {
988
- className: "table-cell-header"
989
- })) : null, headerGroup.headers.map(function (column) {
990
- return /*#__PURE__*/React__default["default"].createElement("th", _extends({}, column.getHeaderProps(), {
991
- key: "tableInstance.headers.column." + column.id
992
- }), /*#__PURE__*/React__default["default"].createElement(CellHeader, {
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
- var _excluded$8 = ["disableFilters", "disablePagination", "availableActions", "onAddAction"];
933
+ const _excluded$8 = ["disableFilters", "disablePagination", "availableActions", "onAddAction"];
1021
934
  function ActionsTable(_ref) {
1022
- var _ref$disableFilters = _ref.disableFilters,
1023
- disableFilters = _ref$disableFilters === void 0 ? true : _ref$disableFilters,
1024
- _ref$disablePaginatio = _ref.disablePagination,
1025
- disablePagination = _ref$disablePaginatio === void 0 ? true : _ref$disablePaginatio,
1026
- _ref$availableActions = _ref.availableActions,
1027
- availableActions = _ref$availableActions === void 0 ? [] : _ref$availableActions,
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
- var _props$i18n = props.i18n,
1032
- i18n = _props$i18n === void 0 ? function (f) {
1033
- return f;
1034
- } : _props$i18n;
1035
- var _useState = React.useState(""),
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: function onChange(name, action) {
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": "submit",
969
+ "data-testid": "action-table-add",
1063
970
  disabled: currentAction === "",
1064
971
  className: "btn btn-success",
1065
- onClick: function 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(function (key, index) {
1083
- var item = error.errors[key];
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(function (item, index) {
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
- var error = _ref.error,
1109
- _ref$type = _ref.type,
1110
- type = _ref$type === void 0 ? "danger" : _ref$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
- var children = _ref.children,
1122
- label = _ref.label,
1123
- className = _ref.className;
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
- var _excluded$7 = ["src", "form", "options", "submission", "url"];
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(function () {
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
- var events = React.useRef(new Map());
1157
- var hasEvent = function hasEvent(event) {
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
- var emit = function emit(event) {
1068
+ const emit = function (event) {
1161
1069
  if (hasEvent(event)) {
1162
- var fn = events.current.has(event) ? events.current.get(event) : funcs[event];
1163
- return fn.apply(void 0, [].slice.call(arguments, 1));
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: events,
1186
- emit: emit,
1187
- hasEvent: hasEvent
1093
+ events,
1094
+ emit,
1095
+ hasEvent
1188
1096
  };
1189
1097
  }
1190
1098
  function useForm(props) {
1191
- var customValidation = function customValidation(submission, callback) {
1099
+ const customValidation = function (submission, callback) {
1192
1100
  try {
1193
- var _temp2 = function () {
1101
+ const _temp2 = function () {
1194
1102
  if (hasEvent("onAsyncSubmit")) {
1195
- var _temp = _catch$1(function () {
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
- var src = props.src,
1211
- form = props.form,
1212
- _props$options = props.options,
1213
- options = _props$options === void 0 ? {} : _props$options,
1214
- submission = props.submission,
1215
- url = props.url,
1118
+ const {
1119
+ src,
1120
+ form,
1121
+ options = {},
1122
+ submission,
1123
+ url
1124
+ } = props,
1216
1125
  funcs = _objectWithoutPropertiesLoose(props, _excluded$7);
1217
- var element = React.useRef();
1218
- var isLoaded = React.useRef();
1219
- var instance = React.useRef();
1220
- var _useEvents = useEvents(funcs),
1221
- emit = _useEvents.emit,
1222
- hasEvent = _useEvents.hasEvent;
1223
- var createWebForm = function createWebForm(srcOrForm, options) {
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
- var eventName = "on" + event.charAt(7).toUpperCase() + event.slice(8);
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.apply(void 0, [eventName].concat(args, [instance.current]));
1153
+ emit(eventName, ...args, instance.current);
1244
1154
  }
1245
1155
  });
1246
- instance.current.ready.then(function (formio) {
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(function () {
1166
+ React$1.useEffect(() => {
1257
1167
  if (instance.current) {
1258
- instance.current.ready.then(function (formio) {
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(function () {
1176
+ React$1.useEffect(() => {
1267
1177
  if (form && instance.current) {
1268
- instance.current.ready.then(function (formio) {
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(function () {
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(function () {
1195
+ React$1.useEffect(() => {
1286
1196
  if (form) {
1287
1197
  createWebForm(form, options);
1288
1198
  }
1289
- return function () {
1199
+ return () => {
1290
1200
  isLoaded.current = false;
1291
1201
  instance.current && instance.current.destroy(true);
1292
1202
  };
1293
1203
  }, []);
1294
1204
  return {
1295
- element: element
1205
+ element
1296
1206
  };
1297
1207
  }
1298
1208
 
1299
1209
  formiojs.Components.setComponents(AllComponents__default["default"]);
1300
1210
  function Form(props) {
1301
- var _useForm = useForm(props),
1302
- element = _useForm.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
- var label = _ref.label,
1362
- key = _ref.key,
1363
- description = _ref.description,
1364
- choices = _ref.choices,
1365
- data = _ref.data;
1272
+ let {
1273
+ label,
1274
+ key,
1275
+ description,
1276
+ choices,
1277
+ data
1278
+ } = _ref;
1366
1279
  return {
1367
- label: label,
1368
- key: key,
1369
- description: 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
- var choices = _ref2.choices;
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: 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: 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: 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: 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: 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: 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: 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: choices
1356
+ choices
1442
1357
  })]
1443
1358
  };
1444
1359
  }
1445
1360
  function getAccessPermissionForm(_ref3) {
1446
- var choices = _ref3.choices;
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: 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: 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: 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: 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: 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: choices
1395
+ choices
1479
1396
  })]
1480
1397
  };
1481
1398
  }
1482
1399
 
1483
1400
  function rolesToChoices(roles) {
1484
- return Object.values(roles).map(function (role) {
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
- var hash = Object.values(access).reduce(function (o, role) {
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(function (data, key) {
1500
- var _extends2;
1501
- return _extends({}, data, (_extends2 = {}, _extends2[key] = hash[key] || [], _extends2));
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
- var accessRoles = [];
1506
- Object.entries(data).forEach(function (_ref) {
1507
- var accessType = _ref[0],
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: roles
1431
+ roles
1515
1432
  });
1516
1433
  });
1517
1434
  return accessRoles;
1518
1435
  }
1519
1436
  function getFormAccess(roles) {
1520
- var choices = rolesToChoices(roles);
1521
- var access = getAccessPermissionForm({
1522
- choices: choices
1437
+ const choices = rolesToChoices(roles);
1438
+ const access = getAccessPermissionForm({
1439
+ choices
1523
1440
  });
1524
- var submissionAccess = getSubmissionPermissionForm({
1525
- choices: choices
1441
+ const submissionAccess = getSubmissionPermissionForm({
1442
+ choices
1526
1443
  });
1527
1444
  return {
1528
- access: access,
1529
- submissionAccess: submissionAccess
1445
+ access,
1446
+ submissionAccess
1530
1447
  };
1531
1448
  }
1532
1449
  function dataAccessToSubmissions(form, formAccess) {
1533
- var getKeys = function getKeys(components) {
1534
- return components.map(function (_ref2) {
1535
- var key = _ref2.key;
1536
- return key;
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
- var _extends3;
1563
- submissions = _extends({}, submissions, (_extends3 = {}, _extends3[type] = {
1564
- data: submission.data
1565
- }, _extends3));
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
- var formDefinition = _ref.form,
1573
- roles = _ref.roles,
1574
- _onSubmit = _ref.onSubmit,
1575
- options = _ref.options;
1576
- // eslint-disable-next-line no-undef
1577
- var form = React.useMemo(function () {
1578
- return getFormAccess(roles);
1579
- }, [roles]);
1580
- var _useState = React.useState(function () {
1581
- return dataAccessToSubmissions(formDefinition, form);
1582
- }),
1583
- submissions = _useState[0],
1584
- setSubmissions = _useState[1];
1585
- var onChange = React.useCallback(function (type, submission) {
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(function () {
1589
- var input = dataAccessToSubmissions(formDefinition, form);
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: options,
1598
- form: form,
1510
+ options,
1511
+ form,
1599
1512
  type: formDefinition.type,
1600
- submissions: submissions,
1601
- onChange: onChange,
1602
- onSubmit: function onSubmit() {
1603
- _onSubmit && _onSubmit(submissionsToDataAccess(formDefinition, submissions));
1513
+ submissions,
1514
+ onChange,
1515
+ onSubmit: () => {
1516
+ onSubmit && onSubmit(submissionsToDataAccess(formDefinition, submissions));
1604
1517
  }
1605
1518
  };
1606
1519
  }
1607
1520
  function NamedFormAccess(_ref2) {
1608
- var name = _ref2.name,
1609
- form = _ref2.form,
1610
- submissions = _ref2.submissions,
1611
- options = _ref2.options,
1612
- _onChange = _ref2.onChange,
1613
- onSubmit = _ref2.onSubmit,
1614
- children = _ref2.children;
1615
- var _useState2 = React.useState(true),
1616
- isValid = _useState2[0],
1617
- setIsValid = _useState2[1];
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: function onChange(_ref3) {
1623
- var data = _ref3.data,
1624
- isValid = _ref3.isValid;
1625
- isValid && _onChange(name, {
1626
- data: data
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
- var _useFormAccess = useFormAccess(props),
1641
- type = _useFormAccess.type,
1642
- form = _useFormAccess.form,
1643
- submissions = _useFormAccess.submissions,
1644
- options = _useFormAccess.options,
1645
- onChange = _useFormAccess.onChange,
1646
- onSubmit = _useFormAccess.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
- var _excluded$6 = ["action"],
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
- var settingsForm = _objectWithoutPropertiesLoose(_ref, _excluded$6);
1701
- FormioUtils__default["default"].eachComponent(settingsForm.components, function (component) {
1702
- var resourceExclude = "";
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
- var actionInfo = _ref2.actionInfo,
1719
- children = _ref2.children,
1720
- onSubmit = _ref2.onSubmit,
1721
- options = _ref2.options,
1627
+ let {
1628
+ actionInfo,
1629
+ children,
1630
+ onSubmit,
1631
+ options
1632
+ } = _ref2,
1722
1633
  props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
1723
- var _ref3 = function () {
1724
- var submission = mapData(props.submission || {}, actionInfo.defaults);
1725
- var form = mapSettingsForm(actionInfo.settingsForm);
1726
- return {
1727
- form: form,
1728
- submission: {
1729
- data: submission
1730
- }
1731
- };
1732
- }(),
1733
- form = _ref3.form,
1734
- submission = _ref3.submission;
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
- var createBuilder = function createBuilder(el, _ref2) {
1755
- var _ref2$components = _ref2.components,
1756
- components = _ref2$components === void 0 ? [] : _ref2$components,
1757
- display = _ref2.display,
1758
- options = _ref2.options,
1759
- onChange = _ref2.onChange,
1760
- _ref2$events = _ref2.events,
1761
- events = _ref2$events === void 0 ? {} : _ref2$events;
1666
+ const createBuilder = function (el, _ref) {
1667
+ let {
1668
+ components = [],
1669
+ display,
1670
+ options,
1671
+ onChange,
1672
+ events = {}
1673
+ } = _ref;
1762
1674
  try {
1763
- var form = {
1764
- display: display,
1765
- components: [].concat(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
- var handleEvent = function handleEvent(event) {
1681
+ const handleEvent = event => {
1770
1682
  return function () {
1771
- events[event] && events[event].apply(events, [].slice.call(arguments));
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(function (event) {
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
- var EVENTS = ["addComponent", "updateComponent", "removeComponent", "saveComponent", "cancelComponent", "moveComponent", "editComponent", "editJson", "copyComponent", "pasteComponent"];
1791
- var EVENTS_CHANGE = ["addComponent", "saveComponent", "updateComponent", "removeComponent"];
1792
- var FormBuilder = /*#__PURE__*/function (_React$Component) {
1793
- _inheritsLoose(FormBuilder, _React$Component);
1794
- function FormBuilder(props) {
1795
- var _this;
1796
- _this = _React$Component.call(this, props) || this;
1797
- _this.elRef = void 0;
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
- _this.elRef = null;
1804
- _this.builderRef = null;
1805
- return _this;
1711
+ this.elRef = null;
1712
+ this.builderRef = null;
1806
1713
  }
1807
- var _proto = FormBuilder.prototype;
1808
- _proto.componentDidMount = function componentDidMount() {
1714
+ componentDidMount() {
1809
1715
  try {
1810
- var _this2 = this;
1811
- return Promise.resolve(_this2.create(_this2.props)).then(function () {});
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
- _proto.create = function create(props) {
1721
+ }
1722
+ create(props) {
1817
1723
  try {
1818
- var _this3 = this;
1819
- var options = props.options,
1820
- display = props.display,
1821
- components = props.components,
1822
- onAddComponent = props.onAddComponent,
1823
- onUpdateComponent = props.onUpdateComponent,
1824
- onRemoveComponent = props.onRemoveComponent,
1825
- onSaveComponent = props.onSaveComponent,
1826
- onCancelComponent = props.onCancelComponent,
1827
- onMoveComponent = props.onMoveComponent,
1828
- onEditComponent = props.onEditComponent,
1829
- onEditJson = props.onEditJson,
1830
- onCopyComponent = props.onCopyComponent,
1831
- onPasteComponent = props.onPasteComponent;
1832
- return Promise.resolve(createBuilder(_this3.elRef.firstChild, {
1833
- display: display,
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: _this3.whenComponentsChange.bind(_this3),
1744
+ onChange: _this2.whenComponentsChange.bind(_this2),
1837
1745
  events: {
1838
- onAddComponent: onAddComponent,
1839
- onUpdateComponent: onUpdateComponent,
1840
- onRemoveComponent: onRemoveComponent,
1841
- onSaveComponent: onSaveComponent,
1842
- onCancelComponent: onCancelComponent,
1843
- onMoveComponent: onMoveComponent,
1844
- onEditComponent: onEditComponent,
1845
- onEditJson: onEditJson,
1846
- onCopyComponent: onCopyComponent,
1847
- onPasteComponent: 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
- _this3.builderRef = _createBuilder;
1758
+ _this2.builderRef = _createBuilder;
1851
1759
  });
1852
1760
  } catch (e) {
1853
1761
  return Promise.reject(e);
1854
1762
  }
1855
- };
1856
- _proto.componentWillUnmount = function componentWillUnmount() {
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
- var _this4 = this;
1865
- var _temp2 = function () {
1866
- if (_this4.builderRef) {
1867
- var _temp = function () {
1868
- if (nextProps.display !== _this4.state.display) {
1869
- return Promise.resolve(_this4.create(_extends({}, _this4.props, {
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 !== _this4.state.components) {
1873
- _this4.builderRef.form = {
1874
- display: _this4.state.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
- _proto.whenComponentsChange = function whenComponentsChange(components) {
1888
- var _this5 = this;
1793
+ }
1794
+ whenComponentsChange(components) {
1889
1795
  this.setState({
1890
- components: components
1891
- }, function () {
1892
- var _this5$props;
1893
- ((_this5$props = _this5.props) == null ? void 0 : _this5$props.onChange) && _this5.props.onChange(components);
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
- _proto.render = function render() {
1897
- var _this6 = this;
1801
+ }
1802
+ render() {
1898
1803
  return /*#__PURE__*/React__default["default"].createElement("div", {
1899
- ref: function ref(_ref) {
1900
- _this6.elRef = _ref;
1804
+ ref: ref => {
1805
+ this.elRef = ref;
1901
1806
  },
1902
- onClick: function onClick(e) {
1903
- return e.stopPropagation();
1904
- }
1807
+ onClick: e => e.stopPropagation()
1905
1808
  }, /*#__PURE__*/React__default["default"].createElement("div", null));
1906
- };
1907
- return FormBuilder;
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
- var ref = React.useRef();
1934
- React.useEffect(function () {
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
- var _ref$saveText = _ref.saveText,
1942
- saveText = _ref$saveText === void 0 ? "Save" : _ref$saveText,
1943
- disabled = _ref.disabled,
1944
- _ref$options = _ref.options,
1945
- options = _ref$options === void 0 ? {} : _ref$options,
1946
- onCopy = _ref.onCopy,
1947
- hasUndo = _ref.hasUndo,
1948
- hasRedo = _ref.hasRedo,
1949
- onUndo = _ref.onUndo,
1950
- onRedo = _ref.onRedo,
1951
- onReset = _ref.onReset,
1952
- onSubmit = _ref.onSubmit;
1953
- var _options$i18n = options.i18n,
1954
- t = _options$i18n === void 0 ? function (t) {
1955
- return t;
1956
- } : _options$i18n;
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
- var undoTooltipRef = useTooltip({
1863
+ const undoTooltipRef = useTooltip({
1963
1864
  trigger: "hover",
1964
1865
  placement: "top",
1965
1866
  title: t("Undo last change")
1966
1867
  });
1967
- var redoTooltipRef = useTooltip({
1868
+ const redoTooltipRef = useTooltip({
1968
1869
  trigger: "hover",
1969
1870
  placement: "top",
1970
1871
  title: t("Redo last change")
1971
1872
  });
1972
- var resetTooltipRef = useTooltip({
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: function 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: function 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: function 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: function 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: function 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
- var _excluded$5 = ["name", "value", "label", "onChange", "required", "description", "prefix", "suffix"];
1923
+ const _excluded$5 = ["name", "value", "label", "onChange", "required", "description", "prefix", "suffix"];
2033
1924
  function InputTags(_ref) {
2034
- var name = _ref.name,
2035
- _ref$value = _ref.value,
2036
- value = _ref$value === void 0 ? [] : _ref$value,
2037
- label = _ref.label,
2038
- onChange = _ref.onChange,
2039
- required = _ref.required,
2040
- description = _ref.description,
2041
- prefix = _ref.prefix,
2042
- suffix = _ref.suffix,
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
- var ref = React.useRef();
2045
- React.useEffect(function () {
2046
- var instance = new Choices__default["default"](ref.current, {
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", function (event) {
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", function (event) {
2056
- onChange && onChange(name, value.filter(function (v) {
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 function () {
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
- var defaultDisplayChoices = [{
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
- var onChange = _ref.onChange,
2099
- form = _ref.form,
2100
- _ref$enableTags = _ref.enableTags,
2101
- enableTags = _ref$enableTags === void 0 ? true : _ref$enableTags,
2102
- _ref$typeChoices = _ref.typeChoices,
2103
- typeChoices = _ref$typeChoices === void 0 ? [] : _ref$typeChoices,
2104
- _ref$displayChoices = _ref.displayChoices,
2105
- displayChoices = _ref$displayChoices === void 0 ? defaultDisplayChoices : _ref$displayChoices,
2106
- _ref$className = _ref.className,
2107
- className = _ref$className === void 0 ? "" : _ref$className,
2108
- _ref$readonly = _ref.readonly,
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
- var hasChanged = function hasChanged(form, value) {
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
- var reducer = function reducer(state, _ref) {
2202
- var type = _ref.type,
2203
- value = _ref.value;
2204
- var past = state.past,
2205
- current = state.current,
2206
- future = state.future;
2207
- var update = function update(newValue) {
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: [].concat(past, [cloneDeep__default["default"](current)]),
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
- var previous = past[past.length - 1];
2221
- var newPast = past.slice(0, past.length - 1);
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)].concat(future)
2113
+ future: [cloneDeep__default["default"](current), ...future]
2226
2114
  });
2227
2115
  }
2228
2116
  break;
2229
2117
  case "redo":
2230
2118
  if (future.length) {
2231
- var next = future[0];
2232
- var newFuture = future.slice(1);
2119
+ const next = future[0];
2120
+ const newFuture = future.slice(1);
2233
2121
  return _extends({}, state, {
2234
- past: [].concat(past, [cloneDeep__default["default"](current)]),
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
- // eslint-disable-next-line no-case-declarations
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
- var _useReducer = React.useReducer(reducer, createInitialState(props)),
2262
- _useReducer$ = _useReducer[0],
2263
- current = _useReducer$.current,
2264
- future = _useReducer$.future,
2265
- past = _useReducer$.past,
2266
- dispatchFormAction = _useReducer[1];
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
- var onCopy = function onCopy() {
2158
+ const onCopy = () => {
2273
2159
  if (props.onSubmit && typeof props.onCopy === "function") {
2274
2160
  props.onCopy(current);
2275
2161
  }
2276
2162
  };
2277
- React.useEffect(function () {
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
- var formChange = function formChange(newForm) {
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
- var redo = function redo() {
2294
- return dispatchFormAction({
2295
- type: "redo"
2296
- });
2297
- };
2298
- var undo = function undo() {
2299
- return dispatchFormAction({
2300
- type: "undo"
2301
- });
2302
- };
2303
- var reset = function reset() {
2304
- return dispatchFormAction({
2305
- type: "reset"
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: redo,
2315
- undo: undo,
2316
- reset: 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: onSubmit,
2322
- onCopy: onCopy,
2323
- formChange: formChange,
2324
- setChange: setChange
2202
+ onSubmit,
2203
+ onCopy,
2204
+ formChange,
2205
+ setChange
2325
2206
  };
2326
2207
  }
2327
2208
 
2328
2209
  function FormEdit(props) {
2329
- var _useFormEdit = useFormEdit(props),
2330
- form = _useFormEdit.form,
2331
- isValid = _useFormEdit.isValid,
2332
- setChange = _useFormEdit.setChange,
2333
- hasRedo = _useFormEdit.hasRedo,
2334
- hasChanged = _useFormEdit.hasChanged,
2335
- hasUndo = _useFormEdit.hasUndo,
2336
- redo = _useFormEdit.redo,
2337
- undo = _useFormEdit.undo,
2338
- reset = _useFormEdit.reset,
2339
- onSubmit = _useFormEdit.onSubmit,
2340
- onCopy = _useFormEdit.onCopy;
2341
- var _props$options = props.options,
2342
- options = _props$options === void 0 ? {} : _props$options,
2343
- builder = props.builder;
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: function onChange(components) {
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
- var formDefinition = _ref.form,
2459
- _ref$onSubmit = _ref.onSubmit,
2460
- _onSubmit = _ref$onSubmit === void 0 ? noop__default["default"] : _ref$onSubmit,
2461
- options = _ref.options;
2462
- var form = getFormSettingsSchema();
2463
- var _useState = React.useState(true),
2464
- isValid = _useState[0],
2465
- setIsValid = _useState[1];
2466
- var _useState2 = React.useState(function () {
2467
- return formSettingsToSubmission(formDefinition);
2468
- }),
2469
- submission = _useState2[0],
2470
- setSubmission = _useState2[1];
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: data
2356
+ data
2477
2357
  });
2478
2358
  }
2479
2359
  setIsValid(isValid);
2480
2360
  };
2481
- React.useEffect(function () {
2482
- var input = formSettingsToSubmission(formDefinition);
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: options,
2489
- form: form,
2368
+ options,
2369
+ form,
2490
2370
  type: formDefinition.type,
2491
- submission: submission,
2492
- onChange: onChange,
2493
- isValid: isValid,
2494
- setIsValid: setIsValid,
2495
- onSubmit: function onSubmit() {
2496
- _onSubmit(submissionToFormSettings(formDefinition, submission));
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
- var _useFormSettings = useFormSettings(props),
2502
- form = _useFormSettings.form,
2503
- submission = _useFormSettings.submission,
2504
- _useFormSettings$opti = _useFormSettings.options,
2505
- options = _useFormSettings$opti === void 0 ? {} : _useFormSettings$opti,
2506
- onChange = _useFormSettings.onChange,
2507
- onSubmit = _useFormSettings.onSubmit,
2508
- isValid = _useFormSettings.isValid;
2509
- var i18n = options.i18n || function (f) {
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
- var column = props.column;
2528
- var id = column.id,
2529
- preFilteredRows = column.preFilteredRows;
2530
- var customChoices = column.choices;
2531
- var filterValue = column.filterValue,
2532
- setFilter = column.setFilter;
2533
- var choices = function () {
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 [].concat(new Set(preFilteredRows.map(function (row) {
2541
- return row.values[id];
2542
- }))).filter(function (value) {
2543
- return value;
2544
- }).map(function (value) {
2545
- return {
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: 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
- var _useSelectColumnFilte = useSelectColumnFilter(props),
2565
- value = _useSelectColumnFilte.value,
2566
- choices = _useSelectColumnFilte.choices,
2567
- onChange = _useSelectColumnFilte.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 some(fun) {
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 keys(obj) {
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 func() {
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 func(input, array) {
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 indexOf(o) {
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 now() {
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["for"] != null) {
6483
- proto[Symbol["for"]('nodejs.util.inspect.custom')] = function () {
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 ordinal(number) {
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
- var _props$icon = props.icon,
7111
- icon = _props$icon === void 0 ? "server" : _props$icon,
7112
- form = props.row.original;
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(function (tag, index) {
7130
- return /*#__PURE__*/React__default["default"].createElement("button", {
7131
- key: index,
7132
- className: "badge badge-hover bg-secondary mr-1",
7133
- onClick: stopPropagationWrapper(function () {
7134
- props.setFilter("tags", tag);
7135
- props.gotoPage(0);
7136
- })
7137
- }, /*#__PURE__*/React__default["default"].createElement("i", {
7138
- className: classnames__default["default"](iconClass(undefined, "tags"), "mr-1")
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
- var _excluded$4 = ["Cell"];
7025
+ const _excluded$4 = ["Cell"];
7144
7026
  function FormsTable(_ref) {
7145
- var Cell = _ref.Cell,
7027
+ let {
7028
+ Cell
7029
+ } = _ref,
7146
7030
  props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
7147
- var _props$i18n = props.i18n,
7148
- i18n = _props$i18n === void 0 ? function (f) {
7149
- return f;
7150
- } : _props$i18n,
7151
- tags = props.tags;
7152
- var FormCell = Cell || FormsCell;
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: function Cell(props) {
7158
- return /*#__PURE__*/React__default["default"].createElement(FormCell, _extends({}, props, {
7159
- icon: props.icon,
7160
- i18n: i18n
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: function Filter(props) {
7171
- return tags && tags.length ? /*#__PURE__*/React__default["default"].createElement(SelectColumnFilter, _extends({}, props, {
7172
- column: _extends({}, props.columns, {
7173
- choices: tags
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
- var isActive = _ref.isActive,
7185
- _ref$color = _ref.color,
7186
- color = _ref$color === void 0 ? "blue" : _ref$color,
7187
- _ref$icon = _ref.icon,
7188
- icon = _ref$icon === void 0 ? "radio-circle" : _ref$icon,
7189
- _ref$className = _ref.className,
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
- var _excluded$3 = ["show", "children", "closeModal", "onClose", "title", "footer", "style", "className"];
7087
+ const _excluded$3 = ["show", "children", "closeModal", "onClose", "title", "footer", "style", "className"];
7210
7088
  function useModal() {
7211
- var _useState = React.useState(false),
7212
- show = _useState[0],
7213
- setShowModal = _useState[1];
7089
+ const [show, setShowModal] = React$1.useState(false);
7214
7090
  return {
7215
- show: show,
7216
- setShowModal: setShowModal,
7217
- openModal: function openModal() {
7091
+ show,
7092
+ setShowModal,
7093
+ openModal() {
7218
7094
  setShowModal(true);
7219
7095
  },
7220
- closeModal: function closeModal() {
7096
+ closeModal() {
7221
7097
  setShowModal(false);
7222
7098
  }
7223
7099
  };
7224
7100
  }
7225
7101
  function Modal(_ref) {
7226
- var show = _ref.show,
7227
- children = _ref.children,
7228
- _ref$closeModal = _ref.closeModal,
7229
- closeModal = _ref$closeModal === void 0 ? noop__default$1["default"] : _ref$closeModal,
7230
- _ref$onClose = _ref.onClose,
7231
- onClose = _ref$onClose === void 0 ? noop__default$1["default"] : _ref$onClose,
7232
- title = _ref.title,
7233
- ModalFooter = _ref.footer,
7234
- style = _ref.style,
7235
- _ref$className = _ref.className,
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
- var titleRef = React.useRef();
7239
- var footerRef = React.useRef();
7240
- var _useState2 = React.useState(),
7241
- maxHeight = _useState2[0],
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(function () {
7120
+ React$1.useEffect(() => {
7248
7121
  if (titleRef.current || footerRef.current) {
7249
7122
  var _titleRef$current, _footerRef$current;
7250
- var 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);
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: 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
- var _excluded$2 = ["maxWidth", "children"];
7168
+ const _excluded$2 = ["maxWidth", "children"];
7296
7169
  function RemoveModalFooter(_ref) {
7297
- var value = _ref.value,
7298
- valueToCompare = _ref.valueToCompare,
7299
- onSubmit = _ref.onSubmit,
7300
- onClose = _ref.onClose,
7301
- _ref$i18n = _ref.i18n,
7302
- i18n = _ref$i18n === void 0 ? function (f) {
7303
- return f;
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: function onClick(e) {
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
- var _ref2$maxWidth = _ref2.maxWidth,
7327
- maxWidth = _ref2$maxWidth === void 0 ? "300px" : _ref2$maxWidth,
7328
- children = _ref2.children,
7198
+ let {
7199
+ maxWidth = "300px",
7200
+ children
7201
+ } = _ref2,
7329
7202
  props = _objectWithoutPropertiesLoose(_ref2, _excluded$2);
7330
- var _props$i18n = props.i18n,
7331
- i18n = _props$i18n === void 0 ? function (f) {
7332
- return f;
7333
- } : _props$i18n;
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: 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: function onChange(name, value) {
7353
- return setValue(value);
7354
- }
7222
+ onChange: (name, value) => setValue(value)
7355
7223
  })));
7356
7224
  }
7357
7225
 
7358
- var ReactComponent = /*#__PURE__*/function (_Components$component) {
7359
- _inheritsLoose(ReactComponent, _Components$component);
7360
- /**
7361
- * This is the first phase of component building where the component is instantiated.
7362
- *
7363
- * @param component - The component definition created from the settings form.
7364
- * @param options - Any options passed into the renderer.
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
- // eslint-disable-next-line no-useless-constructor,import/no-anonymous-default-export
7368
- function ReactComponent(component, options, data) {
7369
- var _this;
7370
- _this = _Components$component.call(this, component, options, data) || this;
7371
- _this.reactInstance = void 0;
7372
- _this.shouldSetValue = void 0;
7373
- _this.dataForSetting = void 0;
7374
- /**
7375
- * The user has changed the value in the component and the value needs to be updated on the main submission object and other components notified of a change event.
7376
- *
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
- _this.updateValue = function (value, flags) {
7245
+ this.updateValue = (value, flags) => {
7381
7246
  flags = flags || {};
7382
- var newValue = value === undefined || value === null ? _this.getValue() : value;
7383
- var changed = newValue !== undefined ? _this.hasChanged(newValue, _this.dataValue) : false;
7384
- _this.dataValue = Array.isArray(newValue) ? [].concat(newValue) : newValue;
7385
- _this.updateOnChange(flags, changed);
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
- var _proto = ReactComponent.prototype;
7391
- /**
7392
- * This method is called any time the component needs to be rebuilt. It is most frequently used to listen to other
7393
- * components using the this.on() function.
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
- _proto.init = function init() {
7396
- return _Components$component.prototype.init.call(this);
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
- _proto.destroy = function destroy() {
7404
- return _Components$component.prototype.destroy.call(this);
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
- _proto.render = function render() {
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 _Components$component.prototype.render.call(this, "<div ref=\"react-" + this.id + "\"></div>");
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
- _proto.attach = function attach(element) {
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
- var _this2$loadRefs;
7426
- var _this2 = this;
7427
- _Components$component.prototype.attach.call(_this2, element);
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
- _this2.loadRefs(element, (_this2$loadRefs = {}, _this2$loadRefs["react-" + _this2.id] = "single", _this2$loadRefs));
7296
+ _this.loadRefs(element, {
7297
+ ["react-" + _this.id]: "single"
7298
+ });
7431
7299
  // @ts-ignore
7432
- if (_this2.refs["react-" + _this2.id]) {
7300
+ if (_this.refs["react-" + _this.id]) {
7433
7301
  // @ts-ignore
7434
- _this2.reactInstance = _this2.attachReact(_this2.refs["react-" + _this2.id]);
7435
- if (_this2.shouldSetValue) {
7436
- _this2.setValue(_this2.dataForSetting);
7437
- _this2.updateValue(_this2.dataForSetting);
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
- _Components$component.prototype.detach.call(this);
7323
+ super.detach();
7457
7324
  }
7458
- /**
7459
- * Override this function to render a react component.
7460
- */;
7461
- _proto.renderReact = function renderReact() {
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
- // eslint-disable-next-line @typescript-eslint/no-empty-function
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
- // eslint-disable-next-line @typescript-eslint/no-empty-function
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
- _proto.setValue = function setValue(value, flags) {
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
- _proto.getValue = function getValue() {
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
- _proto.checkValidity = function checkValidity(data, dirty, rowData) {
7523
- var valid = _Components$component.prototype.checkValidity.call(this, data, dirty, rowData);
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
- _createClass(ReactComponent, [{
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
- var value = _ref.value,
7545
- _ref$render = _ref.render,
7546
- render = _ref$render === void 0 ? function (f) {
7547
- return f;
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
- var rendered = render(value);
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
- var columns = [];
7565
- FormioUtils__default["default"].eachComponent(form.components, function (component) {
7419
+ const columns = [];
7420
+ FormioUtils__default["default"].eachComponent(form.components, component => {
7566
7421
  if (component.tableView && component.key) {
7567
- var cmp = formiojs.Components.create(component, {}, null, true);
7568
- var column = {
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: function Cell(props) {
7573
- return /*#__PURE__*/React__default["default"].createElement(DefaultCell, _extends({}, props, {
7574
- render: function render(value) {
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
- var _excluded$1 = ["form"];
7441
+ const _excluded$1 = ["form"];
7591
7442
  function SubmissionsTable(_ref) {
7592
- var form = _ref.form,
7443
+ let {
7444
+ form
7445
+ } = _ref,
7593
7446
  props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
7594
- var columns = form && mapFormToColumns(form);
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
- var _ref$column = _ref.column,
7602
- filterValue = _ref$column.filterValue,
7603
- setFilter = _ref$column.setFilter,
7604
- preFilteredRows = _ref$column.preFilteredRows,
7605
- id = _ref$column.id;
7606
- var _React$useMemo = React__default["default"].useMemo(function () {
7607
- var min = preFilteredRows.length ? preFilteredRows[0].values[id] : 0;
7608
- var max = preFilteredRows.length ? preFilteredRows[0].values[id] : 0;
7609
- preFilteredRows.forEach(function (row) {
7610
- min = Math.min(row == null ? void 0 : row.values[id], min);
7611
- max = Math.max(row == null ? void 0 : row.values[id], max);
7612
- });
7613
- return [min, max];
7614
- }, [id, preFilteredRows]),
7615
- min = _React$useMemo[0],
7616
- max = _React$useMemo[1];
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: function onChange(e) {
7476
+ onChange: e => {
7623
7477
  setFilter(parseInt(e.target.value, 10));
7624
7478
  }
7625
7479
  }), /*#__PURE__*/React__default["default"].createElement("button", {
7626
- onClick: function onClick() {
7627
- return setFilter(undefined);
7628
- }
7480
+ onClick: () => setFilter(undefined)
7629
7481
  }, "Off"));
7630
7482
  }
7631
7483
 
7632
- var _excluded = ["style", "current", "items", "children", "HeaderChildren", "AddButton", "Button", "className", "onClick", "i18n"];
7484
+ const _excluded = ["style", "current", "items", "children", "HeaderChildren", "AddButton", "Button", "className", "onClick", "i18n"];
7633
7485
  function ButtonTab(_ref) {
7634
- var icon = _ref.icon,
7635
- back = _ref.back,
7636
- onClick = _ref.onClick,
7637
- isActive = _ref.isActive,
7638
- reverse = _ref.reverse,
7639
- children = _ref.children,
7640
- className = _ref.className,
7641
- after = _ref.after;
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
- var style = _ref2.style,
7659
- current = _ref2.current,
7660
- _ref2$items = _ref2.items,
7661
- items = _ref2$items === void 0 ? [] : _ref2$items,
7662
- children = _ref2.children,
7663
- HeaderChildren = _ref2.HeaderChildren,
7664
- AddButton = _ref2.AddButton,
7665
- _ref2$Button = _ref2.Button,
7666
- Button = _ref2$Button === void 0 ? ButtonTab : _ref2$Button,
7667
- className = _ref2.className,
7668
- _onClick = _ref2.onClick,
7669
- _ref2$i18n = _ref2.i18n,
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(function (item) {
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: function onClick() {
7693
- _onClick && _onClick(item);
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
- var _ref = _temp === void 0 ? {} : _temp,
7708
- skip = _ref.skip,
7709
- limit = _ref.limit,
7710
- serverCount = _ref.serverCount,
7711
- length = _ref.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;