@tsed/react-formio 2.3.0 → 2.3.2

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