@tsed/react-formio 1.11.2 → 1.12.0

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 (141) hide show
  1. package/.env +2 -1
  2. package/craco.config.js +11 -1
  3. package/dist/components/alert/alert.component.spec.d.ts +1 -0
  4. package/dist/components/alert/alert.stories.d.ts +15 -0
  5. package/dist/components/form-action/formAction.stories.d.ts +90 -414
  6. package/dist/components/input-text/inputText.component.d.ts +1 -1
  7. package/dist/components/input-text/inputText.component.spec.d.ts +1 -0
  8. package/dist/components/select/select.component.spec.d.ts +1 -0
  9. package/dist/components/tabs/tabs.component.spec.d.ts +1 -0
  10. package/dist/index.js +60 -30
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.modern.js +59 -31
  13. package/dist/index.modern.js.map +1 -1
  14. package/jest.config.js +1 -1
  15. package/package.json +5 -9
  16. package/readme.md +74 -79
  17. package/src/components/__fixtures__/form-schema.json +10 -42
  18. package/src/components/__fixtures__/form.fixture.json +1 -1
  19. package/src/components/actions-table/actionsTable.component.spec.tsx +4 -13
  20. package/src/components/actions-table/actionsTable.component.tsx +3 -11
  21. package/src/components/alert/alert.component.spec.tsx +97 -0
  22. package/src/components/alert/alert.component.tsx +2 -8
  23. package/src/components/alert/alert.stories.tsx +17 -0
  24. package/src/components/card/card.component.tsx +1 -5
  25. package/src/components/form/form.component.tsx +1 -7
  26. package/src/components/form/useForm.hook.ts +4 -13
  27. package/src/components/form-access/formAccess.component.tsx +19 -82
  28. package/src/components/form-access/formAccess.schema.ts +7 -23
  29. package/src/components/form-access/formAccess.stories.tsx +2 -9
  30. package/src/components/form-access/formAccess.utils.spec.ts +4 -22
  31. package/src/components/form-access/formAccess.utils.ts +7 -29
  32. package/src/components/form-action/formAction.component.tsx +3 -19
  33. package/src/components/form-action/formAction.stories.tsx +251 -672
  34. package/src/components/form-builder/formBuilder.component.tsx +4 -13
  35. package/src/components/form-builder/formBuilder.stories.tsx +12 -24
  36. package/src/components/form-control/formControl.component.tsx +2 -8
  37. package/src/components/form-edit/formCtas.component.tsx +5 -23
  38. package/src/components/form-edit/formEdit.component.tsx +2 -20
  39. package/src/components/form-edit/formEdit.reducer.ts +2 -8
  40. package/src/components/form-edit/formEdit.stories.tsx +3 -15
  41. package/src/components/form-edit/formParameters.component.tsx +3 -20
  42. package/src/components/form-edit/useFormEdit.hook.ts +2 -9
  43. package/src/components/form-settings/formSettings.component.spec.tsx +2 -9
  44. package/src/components/form-settings/formSettings.component.tsx +6 -34
  45. package/src/components/form-settings/formSettings.stories.tsx +1 -6
  46. package/src/components/form-settings/formSettings.utils.spec.ts +1 -4
  47. package/src/components/form-settings/formSettings.utils.ts +2 -7
  48. package/src/components/forms-table/components/formCell.component.tsx +2 -6
  49. package/src/components/forms-table/formsTable.component.tsx +2 -7
  50. package/src/components/input-tags/inputTags.component.tsx +10 -34
  51. package/src/components/input-tags/inputTags.stories.tsx +4 -14
  52. package/src/components/input-text/inputText.component.spec.tsx +56 -0
  53. package/src/components/input-text/inputText.component.tsx +4 -5
  54. package/src/components/input-text/inputText.stories.tsx +6 -26
  55. package/src/components/loader/loader.component.tsx +2 -11
  56. package/src/components/modal/modal.component.spec.tsx +8 -14
  57. package/src/components/modal/modal.component.tsx +6 -27
  58. package/src/components/modal/modal.stories.tsx +1 -5
  59. package/src/components/modal/removeModal.component.tsx +4 -22
  60. package/src/components/pagination/pagination.component.spec.tsx +12 -38
  61. package/src/components/pagination/pagination.component.tsx +8 -41
  62. package/src/components/pagination/pagination.stories.tsx +1 -5
  63. package/src/components/react-component/reactComponent.component.tsx +3 -11
  64. package/src/components/select/select.component.spec.tsx +86 -0
  65. package/src/components/select/select.component.tsx +11 -15
  66. package/src/components/select/select.stories.tsx +6 -26
  67. package/src/components/submissions-table/submissionsTable.component.tsx +1 -3
  68. package/src/components/submissions-table/submissionsTable.stories.tsx +1 -1
  69. package/src/components/table/components/defaultArrowSort.component.tsx +1 -10
  70. package/src/components/table/components/defaultCell.component.tsx +1 -4
  71. package/src/components/table/components/defaultCellHeader.component.tsx +4 -14
  72. package/src/components/table/components/defaultCellOperations.component.tsx +14 -25
  73. package/src/components/table/components/defaultOperationButton.component.tsx +2 -10
  74. package/src/components/table/filters/defaultColumnFilter.component.spec.tsx +1 -1
  75. package/src/components/table/filters/selectColumnFilter.component.spec.tsx +2 -10
  76. package/src/components/table/filters/selectColumnFilter.component.tsx +2 -6
  77. package/src/components/table/table.component.tsx +13 -53
  78. package/src/components/table/table.stories.tsx +1 -1
  79. package/src/components/table/utils/getPageNumbers.ts +3 -11
  80. package/src/components/table/utils/mapFormToColumns.tsx +14 -22
  81. package/src/components/table/utils/useOperations.hook.tsx +2 -12
  82. package/src/components/tabs/tabs.component.spec.tsx +86 -0
  83. package/src/components/tabs/tabs.component.stories.tsx +2 -9
  84. package/src/components/tabs/tabs.component.tsx +9 -43
  85. package/src/interfaces/Operation.ts +1 -4
  86. package/src/react-table.d.ts +9 -28
  87. package/src/stores/action/action.actions.ts +31 -33
  88. package/src/stores/action/action.reducers.spec.ts +1 -8
  89. package/src/stores/action/action.reducers.ts +1 -8
  90. package/src/stores/action/action.selectors.ts +1 -2
  91. package/src/stores/action-info/action-info.actions.spec.ts +1 -5
  92. package/src/stores/action-info/action-info.actions.ts +16 -19
  93. package/src/stores/action-info/action-info.reducers.spec.ts +1 -6
  94. package/src/stores/action-info/action-info.reducers.ts +1 -6
  95. package/src/stores/action-info/action-info.selectors.ts +1 -4
  96. package/src/stores/actions/actions.actions.spec.ts +1 -6
  97. package/src/stores/actions/actions.actions.ts +16 -19
  98. package/src/stores/actions/actions.reducers.spec.ts +1 -6
  99. package/src/stores/actions/actions.reducers.ts +1 -6
  100. package/src/stores/actions/actions.selectors.ts +2 -4
  101. package/src/stores/auth/auth.reducers.ts +1 -4
  102. package/src/stores/auth/auth.selectors.spec.ts +1 -5
  103. package/src/stores/auth/auth.selectors.ts +3 -6
  104. package/src/stores/auth/auth.utils.tsx +2 -8
  105. package/src/stores/auth/getAccess.action.spec.ts +11 -54
  106. package/src/stores/auth/getAccess.action.ts +1 -6
  107. package/src/stores/auth/initAuth.action.ts +15 -17
  108. package/src/stores/form/form.actions.spec.ts +8 -39
  109. package/src/stores/form/form.actions.ts +55 -64
  110. package/src/stores/form/form.reducers.spec.ts +1 -7
  111. package/src/stores/form/form.reducers.ts +1 -8
  112. package/src/stores/form/form.selectors.ts +1 -2
  113. package/src/stores/forms/forms.actions.spec.ts +5 -18
  114. package/src/stores/forms/forms.actions.ts +17 -21
  115. package/src/stores/forms/forms.reducers.spec.ts +1 -6
  116. package/src/stores/forms/forms.reducers.ts +2 -13
  117. package/src/stores/forms/forms.selectors.ts +2 -4
  118. package/src/stores/index.spec.ts +6 -9
  119. package/src/stores/root/root.selectors.spec.ts +1 -6
  120. package/src/stores/root/root.selectors.ts +6 -24
  121. package/src/stores/submission/submission.actions.spec.ts +11 -33
  122. package/src/stores/submission/submission.actions.ts +57 -66
  123. package/src/stores/submission/submission.reducers.spec.ts +17 -27
  124. package/src/stores/submission/submission.reducers.ts +1 -4
  125. package/src/stores/submission/submission.selectors.ts +1 -4
  126. package/src/stores/submissions/submissions.actions.spec.ts +5 -18
  127. package/src/stores/submissions/submissions.actions.ts +17 -26
  128. package/src/stores/submissions/submissions.reducers.spec.ts +3 -12
  129. package/src/stores/submissions/submissions.reducers.ts +3 -17
  130. package/src/stores/submissions/submissions.selectors.spec.ts +1 -4
  131. package/src/stores/submissions/submissions.selectors.ts +2 -4
  132. package/src/utils/getEventValue.ts +1 -4
  133. package/src/utils/iconClass.ts +2 -10
  134. package/src/utils/mapPagination.ts +1 -6
  135. package/src/utils/mapRequestParams.ts +2 -12
  136. package/src/utils/url.test.ts +4 -12
  137. package/src/utils/url.ts +2 -7
  138. package/tsconfig.json +4 -12
  139. package/tsconfig.test.json +1 -1
  140. package/.eslintrc +0 -47
  141. package/.prettierrc +0 -10
@@ -1227,7 +1227,7 @@ function Select(_ref) {
1227
1227
  onChange,
1228
1228
  required,
1229
1229
  value,
1230
- choices = [],
1230
+ choices,
1231
1231
  description,
1232
1232
  placeholder,
1233
1233
  prefix,
@@ -1490,9 +1490,10 @@ function InputText(_ref) {
1490
1490
  prefix,
1491
1491
  suffix,
1492
1492
  description,
1493
- className
1493
+ className,
1494
+ placeholder
1494
1495
  } = _ref,
1495
- props = _objectWithoutPropertiesLoose(_ref, ["name", "value", "label", "onChange", "required", "size", "type", "prefix", "suffix", "description", "className"]);
1496
+ props = _objectWithoutPropertiesLoose(_ref, ["name", "value", "label", "onChange", "required", "size", "type", "prefix", "suffix", "description", "className", "placeholder"]);
1496
1497
 
1497
1498
  const [localValue, setValue] = useState(value);
1498
1499
  const change = useMemo(() => callLast(onChange, 300), [onChange]);
@@ -1514,7 +1515,8 @@ function InputText(_ref) {
1514
1515
  className: classnames("form-control", size && `form-control-${size}`),
1515
1516
  id: name,
1516
1517
  required: required,
1517
- value: localValue || "",
1518
+ value: localValue || placeholder || "",
1519
+ placeholder: placeholder,
1518
1520
  onChange: event => {
1519
1521
  const value = getEventValue(event);
1520
1522
  setValue(value);
@@ -1601,7 +1603,7 @@ function DefaultCellOperations({
1601
1603
  className: 'btn-group'
1602
1604
  }, operations.filter(({
1603
1605
  permissionsResolver
1604
- }) => !permissionsResolver || permissionsResolver(data, ctx)).map((_ref) => {
1606
+ }) => !permissionsResolver || permissionsResolver(data, ctx)).map(_ref => {
1605
1607
  let {
1606
1608
  OperationButton = DefaultOperationButton
1607
1609
  } = _ref,
@@ -2564,7 +2566,8 @@ class FormBuilder extends React.Component {
2564
2566
  var _this$builderRef;
2565
2567
 
2566
2568
  (_this$builderRef = this.builderRef) == null ? void 0 : _this$builderRef.destroy();
2567
- }
2569
+ } // eslint-disable-next-line react/no-deprecated
2570
+
2568
2571
 
2569
2572
  async componentWillReceiveProps(nextProps) {
2570
2573
  if (this.builderRef) {
@@ -3303,9 +3306,10 @@ var moment = createCommonjsModule(function (module, exports) {
3303
3306
 
3304
3307
  function map(arr, fn) {
3305
3308
  var res = [],
3306
- i;
3309
+ i,
3310
+ arrLen = arr.length;
3307
3311
 
3308
- for (i = 0; i < arr.length; ++i) {
3312
+ for (i = 0; i < arrLen; ++i) {
3309
3313
  res.push(fn(arr[i], i));
3310
3314
  }
3311
3315
 
@@ -3424,7 +3428,10 @@ var moment = createCommonjsModule(function (module, exports) {
3424
3428
  updateInProgress = false;
3425
3429
 
3426
3430
  function copyConfig(to, from) {
3427
- var i, prop, val;
3431
+ var i,
3432
+ prop,
3433
+ val,
3434
+ momentPropertiesLen = momentProperties.length;
3428
3435
 
3429
3436
  if (!isUndefined(from._isAMomentObject)) {
3430
3437
  to._isAMomentObject = from._isAMomentObject;
@@ -3466,8 +3473,8 @@ var moment = createCommonjsModule(function (module, exports) {
3466
3473
  to._locale = from._locale;
3467
3474
  }
3468
3475
 
3469
- if (momentProperties.length > 0) {
3470
- for (i = 0; i < momentProperties.length; i++) {
3476
+ if (momentPropertiesLen > 0) {
3477
+ for (i = 0; i < momentPropertiesLen; i++) {
3471
3478
  prop = momentProperties[i];
3472
3479
  val = from[prop];
3473
3480
 
@@ -3519,9 +3526,10 @@ var moment = createCommonjsModule(function (module, exports) {
3519
3526
  var args = [],
3520
3527
  arg,
3521
3528
  i,
3522
- key;
3529
+ key,
3530
+ argLen = arguments.length;
3523
3531
 
3524
- for (i = 0; i < arguments.length; i++) {
3532
+ for (i = 0; i < argLen; i++) {
3525
3533
  arg = '';
3526
3534
 
3527
3535
  if (typeof arguments[i] === 'object') {
@@ -3951,9 +3959,10 @@ var moment = createCommonjsModule(function (module, exports) {
3951
3959
  if (typeof units === 'object') {
3952
3960
  units = normalizeObjectUnits(units);
3953
3961
  var prioritized = getPrioritizedUnits(units),
3954
- i;
3962
+ i,
3963
+ prioritizedLen = prioritized.length;
3955
3964
 
3956
- for (i = 0; i < prioritized.length; i++) {
3965
+ for (i = 0; i < prioritizedLen; i++) {
3957
3966
  this[prioritized[i].unit](units[prioritized[i].unit]);
3958
3967
  }
3959
3968
  } else {
@@ -4034,7 +4043,8 @@ var moment = createCommonjsModule(function (module, exports) {
4034
4043
 
4035
4044
  function addParseToken(token, callback) {
4036
4045
  var i,
4037
- func = callback;
4046
+ func = callback,
4047
+ tokenLen;
4038
4048
 
4039
4049
  if (typeof token === 'string') {
4040
4050
  token = [token];
@@ -4046,7 +4056,9 @@ var moment = createCommonjsModule(function (module, exports) {
4046
4056
  };
4047
4057
  }
4048
4058
 
4049
- for (i = 0; i < token.length; i++) {
4059
+ tokenLen = token.length;
4060
+
4061
+ for (i = 0; i < tokenLen; i++) {
4050
4062
  tokens[token[i]] = func;
4051
4063
  }
4052
4064
  }
@@ -5132,11 +5144,16 @@ var moment = createCommonjsModule(function (module, exports) {
5132
5144
  return globalLocale;
5133
5145
  }
5134
5146
 
5147
+ function isLocaleNameSane(name) {
5148
+ // Prevent names that look like filesystem paths, i.e contain '/' or '\'
5149
+ return name.match('^[^/\\\\]*$') != null;
5150
+ }
5151
+
5135
5152
  function loadLocale(name) {
5136
5153
  var oldLocale = null,
5137
5154
  aliasedRequire; // TODO: Find a better way to register and load all the locales in Node
5138
5155
 
5139
- if (locales[name] === undefined && 'object' !== 'undefined' && module && module.exports) {
5156
+ if (locales[name] === undefined && 'object' !== 'undefined' && module && module.exports && isLocaleNameSane(name)) {
5140
5157
  try {
5141
5158
  oldLocale = globalLocale._abbr;
5142
5159
  aliasedRequire = commonjsRequire;
@@ -5368,12 +5385,14 @@ var moment = createCommonjsModule(function (module, exports) {
5368
5385
  allowTime,
5369
5386
  dateFormat,
5370
5387
  timeFormat,
5371
- tzFormat;
5388
+ tzFormat,
5389
+ isoDatesLen = isoDates.length,
5390
+ isoTimesLen = isoTimes.length;
5372
5391
 
5373
5392
  if (match) {
5374
5393
  getParsingFlags(config).iso = true;
5375
5394
 
5376
- for (i = 0, l = isoDates.length; i < l; i++) {
5395
+ for (i = 0, l = isoDatesLen; i < l; i++) {
5377
5396
  if (isoDates[i][1].exec(match[1])) {
5378
5397
  dateFormat = isoDates[i][0];
5379
5398
  allowTime = isoDates[i][2] !== false;
@@ -5387,7 +5406,7 @@ var moment = createCommonjsModule(function (module, exports) {
5387
5406
  }
5388
5407
 
5389
5408
  if (match[3]) {
5390
- for (i = 0, l = isoTimes.length; i < l; i++) {
5409
+ for (i = 0, l = isoTimesLen; i < l; i++) {
5391
5410
  if (isoTimes[i][1].exec(match[3])) {
5392
5411
  // match[2] should be 'T' or space
5393
5412
  timeFormat = (match[2] || ' ') + isoTimes[i][0];
@@ -5723,10 +5742,12 @@ var moment = createCommonjsModule(function (module, exports) {
5723
5742
  skipped,
5724
5743
  stringLength = string.length,
5725
5744
  totalParsedInputLength = 0,
5726
- era;
5745
+ era,
5746
+ tokenLen;
5727
5747
  tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
5748
+ tokenLen = tokens.length;
5728
5749
 
5729
- for (i = 0; i < tokens.length; i++) {
5750
+ for (i = 0; i < tokenLen; i++) {
5730
5751
  token = tokens[i];
5731
5752
  parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
5732
5753
 
@@ -5819,15 +5840,16 @@ var moment = createCommonjsModule(function (module, exports) {
5819
5840
  i,
5820
5841
  currentScore,
5821
5842
  validFormatFound,
5822
- bestFormatIsValid = false;
5843
+ bestFormatIsValid = false,
5844
+ configfLen = config._f.length;
5823
5845
 
5824
- if (config._f.length === 0) {
5846
+ if (configfLen === 0) {
5825
5847
  getParsingFlags(config).invalidFormat = true;
5826
5848
  config._d = new Date(NaN);
5827
5849
  return;
5828
5850
  }
5829
5851
 
5830
- for (i = 0; i < config._f.length; i++) {
5852
+ for (i = 0; i < configfLen; i++) {
5831
5853
  currentScore = 0;
5832
5854
  validFormatFound = false;
5833
5855
  tempConfig = copyConfig({}, config);
@@ -6049,7 +6071,8 @@ var moment = createCommonjsModule(function (module, exports) {
6049
6071
  function isDurationValid(m) {
6050
6072
  var key,
6051
6073
  unitHasDecimal = false,
6052
- i;
6074
+ i,
6075
+ orderLen = ordering.length;
6053
6076
 
6054
6077
  for (key in m) {
6055
6078
  if (hasOwnProp(m, key) && !(indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
@@ -6057,7 +6080,7 @@ var moment = createCommonjsModule(function (module, exports) {
6057
6080
  }
6058
6081
  }
6059
6082
 
6060
- for (i = 0; i < ordering.length; ++i) {
6083
+ for (i = 0; i < orderLen; ++i) {
6061
6084
  if (m[ordering[i]]) {
6062
6085
  if (unitHasDecimal) {
6063
6086
  return false; // only allow non-integers for smallest unit
@@ -6545,9 +6568,10 @@ var moment = createCommonjsModule(function (module, exports) {
6545
6568
  propertyTest = false,
6546
6569
  properties = ['years', 'year', 'y', 'months', 'month', 'M', 'days', 'day', 'd', 'dates', 'date', 'D', 'hours', 'hour', 'h', 'minutes', 'minute', 'm', 'seconds', 'second', 's', 'milliseconds', 'millisecond', 'ms'],
6547
6570
  i,
6548
- property;
6571
+ property,
6572
+ propertyLen = properties.length;
6549
6573
 
6550
- for (i = 0; i < properties.length; i += 1) {
6574
+ for (i = 0; i < propertyLen; i += 1) {
6551
6575
  property = properties[i];
6552
6576
  propertyTest = propertyTest || hasOwnProp(input, property);
6553
6577
  }
@@ -8289,7 +8313,7 @@ var moment = createCommonjsModule(function (module, exports) {
8289
8313
  config._d = new Date(toInt(input));
8290
8314
  }); //! moment.js
8291
8315
 
8292
- hooks.version = '2.29.1';
8316
+ hooks.version = '2.29.3';
8293
8317
  setHookCallback(createLocal);
8294
8318
  hooks.fn = proto;
8295
8319
  hooks.min = min;
@@ -8856,8 +8880,10 @@ function ButtonTab({
8856
8880
  after
8857
8881
  }) {
8858
8882
  return React.createElement("div", {
8883
+ title: 'button-wrapper',
8859
8884
  className: classnames("tw-tabs__button-wrapper", isActive ? "-active" : "", back ? "-back" : "", className)
8860
8885
  }, React.createElement("button", {
8886
+ title: 'button-tab',
8861
8887
  className: classnames("tw-tabs__button", reverse ? "-reverse" : "", isActive ? "-active" : "", back ? "-back" : ""),
8862
8888
  onClick: onClick
8863
8889
  }, icon && React.createElement("i", {
@@ -8884,6 +8910,7 @@ function Tabs(_ref) {
8884
8910
  additionalProps = _objectWithoutPropertiesLoose(_ref, ["style", "current", "items", "children", "HeaderChildren", "AddButton", "Button", "className", "onClick", "i18n"]);
8885
8911
 
8886
8912
  return React.createElement("div", {
8913
+ "data-testid": 'tabs-comp',
8887
8914
  className: `tw-tabs ${className}`,
8888
8915
  style: style
8889
8916
  }, React.createElement("div", null, React.createElement("nav", {
@@ -8907,6 +8934,7 @@ function Tabs(_ref) {
8907
8934
  })))), HeaderChildren && React.createElement(HeaderChildren, Object.assign({}, additionalProps, {
8908
8935
  current: current
8909
8936
  }))), React.createElement("div", {
8937
+ title: "tab-body",
8910
8938
  className: "tw-tabs__body"
8911
8939
  }, children));
8912
8940
  }