envoc-form 2.0.1-1 → 2.0.1-13

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 (155) hide show
  1. package/README.md +7 -7
  2. package/dist/css/envoc-form-styles.css +43 -5
  3. package/dist/css/envoc-form-styles.css.map +1 -1
  4. package/es/AddressInput/AddressInput.js +8 -7
  5. package/es/ConfirmBaseForm/ConfirmBaseForm.js +3 -2
  6. package/es/ConfirmDeleteForm/ConfirmDeleteForm.js +3 -2
  7. package/es/DatePickerInput/DatePickerInput.js +3 -2
  8. package/es/FileInput/DefaultFileList.js +36 -0
  9. package/es/FileInput/DropzoneFileInput.js +58 -0
  10. package/es/FileInput/FileInput.js +31 -9
  11. package/es/FileInput/index.js +2 -1
  12. package/es/Form/Form.js +11 -33
  13. package/es/Form/FormBasedPreventNavigation.js +1 -1
  14. package/es/FormGroupWrapper.js +2 -1
  15. package/es/FormInput/FormInput.js +29 -10
  16. package/es/FormInputArray/FormInputArray.js +39 -24
  17. package/es/IconInput.js +2 -1
  18. package/es/ReactSelectField/ReactSelectField.js +6 -3
  19. package/es/SubmitFormButton.js +2 -1
  20. package/es/__Tests__/FormTestBase.js +5 -2
  21. package/es/normalizers.js +10 -5
  22. package/es/useStandardFormInput.js +4 -2
  23. package/es/utils/index.js +3 -0
  24. package/es/utils/objectContainsNonSerializableProperty.js +16 -0
  25. package/es/utils/objectToFormData.js +65 -0
  26. package/es/utils/typeChecks.js +25 -0
  27. package/lib/AddressInput/AddressInput.js +15 -9
  28. package/lib/ConfirmBaseForm/ConfirmBaseForm.js +4 -2
  29. package/lib/ConfirmDeleteForm/ConfirmDeleteForm.js +6 -4
  30. package/lib/DatePickerInput/DatePickerInput.js +4 -2
  31. package/lib/FileInput/DefaultFileList.js +47 -0
  32. package/lib/FileInput/DropzoneFileInput.js +75 -0
  33. package/lib/FileInput/FileInput.js +39 -10
  34. package/lib/FileInput/index.js +13 -3
  35. package/lib/Form/Form.js +19 -39
  36. package/lib/Form/FormBasedPreventNavigation.js +7 -3
  37. package/lib/FormGroupWrapper.js +3 -1
  38. package/lib/FormInput/FormInput.js +31 -11
  39. package/lib/FormInputArray/FormInputArray.js +47 -26
  40. package/lib/FormSection.js +5 -1
  41. package/lib/IconInput.js +3 -1
  42. package/lib/ReactSelectField/ReactSelectField.js +13 -5
  43. package/lib/ReactSelectField/index.js +6 -2
  44. package/lib/SubmitFormButton.js +3 -1
  45. package/lib/__Tests__/FormTestBase.js +6 -2
  46. package/lib/index.js +7 -3
  47. package/lib/normalizers.js +10 -5
  48. package/lib/useStandardFormInput.js +5 -2
  49. package/lib/utils/index.js +23 -0
  50. package/lib/utils/objectContainsNonSerializableProperty.js +24 -0
  51. package/lib/utils/objectToFormData.js +73 -0
  52. package/lib/utils/typeChecks.js +58 -0
  53. package/lib/validators/index.js +5 -1
  54. package/package.json +99 -90
  55. package/src/AddressInput/AddesssInput.test.js +23 -23
  56. package/src/AddressInput/AddressInput.js +73 -73
  57. package/src/AddressInput/UsStates.js +53 -53
  58. package/src/AddressInput/__snapshots__/AddesssInput.test.js.snap +207 -207
  59. package/src/AddressInput/index.js +2 -2
  60. package/src/BoolInput/BoolInput.js +7 -7
  61. package/src/BoolInput/BoolInput.test.js +23 -23
  62. package/src/BoolInput/InlineBoolInput.js +7 -7
  63. package/src/BoolInput/__snapshots__/BoolInput.test.js.snap +89 -89
  64. package/src/BoolInput/boolOptions.js +6 -6
  65. package/src/BoolInput/index.js +4 -4
  66. package/src/ConfirmBaseForm/ConfirmBaseForm.js +37 -37
  67. package/src/ConfirmBaseForm/ConfirmBaseForm.test.js +14 -14
  68. package/src/ConfirmBaseForm/__snapshots__/ConfirmBaseForm.test.js.snap +23 -23
  69. package/src/ConfirmBaseForm/index.js +1 -1
  70. package/src/ConfirmDeleteForm/ConfirmDeleteForm.js +39 -39
  71. package/src/ConfirmDeleteForm/ConfirmDeleteForm.test.js +24 -24
  72. package/src/ConfirmDeleteForm/__snapshots__/ConfirmDeleteForm.test.js.snap +25 -25
  73. package/src/ConfirmDeleteForm/index.js +1 -1
  74. package/src/DatePickerInput/DatePickerInput.js +46 -46
  75. package/src/DatePickerInput/DatePickerInput.test.js +74 -74
  76. package/src/DatePickerInput/__snapshots__/DatePickerInput.test.js.snap +134 -131
  77. package/src/DatePickerInput/date-picker-input.scss +42 -42
  78. package/src/DatePickerInput/index.js +3 -3
  79. package/src/ErrorScrollTarget.js +6 -6
  80. package/src/FileInput/DefaultFileList.js +39 -0
  81. package/src/FileInput/DropzoneFileInput.js +56 -0
  82. package/src/FileInput/DropzoneFileInput.test.js +24 -0
  83. package/src/FileInput/FileInput.js +77 -49
  84. package/src/FileInput/FileInput.test.js +24 -15
  85. package/src/FileInput/__snapshots__/DropzoneFileInput.test.js.snap +57 -0
  86. package/src/FileInput/__snapshots__/FileInput.test.js.snap +58 -22
  87. package/src/FileInput/file-input.scss +58 -17
  88. package/src/FileInput/index.js +4 -3
  89. package/src/Form/FocusError.js +48 -48
  90. package/src/Form/Form.js +139 -161
  91. package/src/Form/Form.test.js +23 -23
  92. package/src/Form/FormBasedPreventNavigation.js +25 -25
  93. package/src/Form/ServerErrorContext.js +7 -7
  94. package/src/Form/__snapshots__/Form.test.js.snap +9 -9
  95. package/src/Form/index.js +3 -3
  96. package/src/FormGroup.js +30 -30
  97. package/src/FormGroupWrapper.js +28 -28
  98. package/src/FormInput/FormInput.js +144 -136
  99. package/src/FormInput/FormInput.test.js +66 -66
  100. package/src/FormInput/__snapshots__/FormInput.test.js.snap +323 -313
  101. package/src/FormInput/form-input.scss +9 -9
  102. package/src/FormInput/index.js +2 -2
  103. package/src/FormInputArray/FormInputArray.js +224 -210
  104. package/src/FormInputArray/FormInputArray.test.js +108 -59
  105. package/src/FormInputArray/__snapshots__/FormInputArray.test.js.snap +52 -40
  106. package/src/FormInputArray/form-input-array.scss +13 -8
  107. package/src/FormInputArray/index.js +2 -2
  108. package/src/FormSection.js +13 -13
  109. package/src/IconInput.js +31 -31
  110. package/src/InlineFormInput/InlineFormInput.js +6 -6
  111. package/src/InlineFormInput/InlineFormInput.test.js +23 -23
  112. package/src/InlineFormInput/__snapshots__/InlineFormInput.test.js.snap +26 -26
  113. package/src/InlineFormInput/index.js +3 -3
  114. package/src/InlineFormInput/inline-form-input.scss +3 -3
  115. package/src/MoneyInput/InlineMoneyInput.js +7 -7
  116. package/src/MoneyInput/MoneyInput.js +7 -7
  117. package/src/MoneyInput/MoneyInputs.test.js +43 -43
  118. package/src/MoneyInput/__snapshots__/MoneyInputs.test.js.snap +81 -81
  119. package/src/MoneyInput/index.js +4 -4
  120. package/src/MoneyInput/money-input.scss +3 -3
  121. package/src/MoneyInput/moneyInputProps.js +12 -12
  122. package/src/NestedFormFieldContext.js +6 -6
  123. package/src/ReactSelectField/ReactSelectField.js +122 -120
  124. package/src/ReactSelectField/index.js +6 -6
  125. package/src/ReactSelectField/react-select-field.scss +5 -5
  126. package/src/StandardFormActions.js +27 -27
  127. package/src/SubmitFormButton.js +28 -28
  128. package/src/__Tests__/FormTestBase.js +14 -11
  129. package/src/__Tests__/IconInput.test.js +23 -23
  130. package/src/__Tests__/StandardFormActions.test.js +23 -23
  131. package/src/__Tests__/SubmitFormButton.test.js +23 -23
  132. package/src/__Tests__/__snapshots__/IconInput.test.js.snap +38 -38
  133. package/src/__Tests__/__snapshots__/StandardFormActions.test.js.snap +25 -25
  134. package/src/__Tests__/__snapshots__/SubmitFormButton.test.js.snap +18 -18
  135. package/src/__Tests__/index.js +2 -2
  136. package/src/_variables.scss +11 -11
  137. package/src/index.js +33 -33
  138. package/src/normalizers.js +42 -32
  139. package/src/selectors.js +3 -3
  140. package/src/styles.scss +7 -7
  141. package/src/useStandardFormInput.js +118 -118
  142. package/src/utils/index.js +3 -0
  143. package/src/utils/objectContainsNonSerializableProperty.js +15 -0
  144. package/src/utils/objectContainsNonSerializableProperty.test.js +49 -0
  145. package/src/utils/objectToFormData.js +89 -0
  146. package/src/utils/objectToFormData.test.js +76 -0
  147. package/src/utils/typeChecks.js +18 -0
  148. package/src/validators/index.js +2 -2
  149. package/src/validators/validators.js +93 -93
  150. package/src/validators/validators.test.js +79 -79
  151. package/CHANGELOG.json +0 -95
  152. package/CHANGELOG.md +0 -58
  153. package/es/FormInput/utilities.js +0 -71
  154. package/lib/FormInput/utilities.js +0 -86
  155. package/src/FormInput/utilities.js +0 -26
@@ -1,71 +0,0 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
- import lru from 'lru-cache';
5
- import axios from 'axios'; // 500 options list max, each living no more than 5 minutes
6
-
7
- var optionCache = new lru({
8
- max: 500,
9
- maxAge: 1000 * 60 * 5
10
- });
11
- export function loadOptionsData(_x, _x2) {
12
- return _loadOptionsData.apply(this, arguments);
13
- }
14
-
15
- function _loadOptionsData() {
16
- _loadOptionsData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(optionsUrl, cancelToken) {
17
- var result, resp, newData;
18
- return _regeneratorRuntime.wrap(function _callee$(_context) {
19
- while (1) {
20
- switch (_context.prev = _context.next) {
21
- case 0:
22
- result = optionCache.get(optionsUrl);
23
-
24
- if (!result) {
25
- _context.next = 3;
26
- break;
27
- }
28
-
29
- return _context.abrupt("return", result);
30
-
31
- case 3:
32
- _context.prev = 3;
33
- _context.next = 6;
34
- return axios.get(optionsUrl, {
35
- hasLoadingMessage: true,
36
- cancelToken: cancelToken.token
37
- });
38
-
39
- case 6:
40
- resp = _context.sent;
41
- newData = [{
42
- key: null,
43
- value: null
44
- }].concat(_toConsumableArray(resp.data.result));
45
- optionCache.set(optionsUrl, newData);
46
- return _context.abrupt("return", newData);
47
-
48
- case 12:
49
- _context.prev = 12;
50
- _context.t0 = _context["catch"](3);
51
-
52
- if (!_context.t0.handled) {
53
- _context.next = 16;
54
- break;
55
- }
56
-
57
- return _context.abrupt("return", null);
58
-
59
- case 16:
60
- console.error(_context.t0);
61
- return _context.abrupt("return", null);
62
-
63
- case 18:
64
- case "end":
65
- return _context.stop();
66
- }
67
- }
68
- }, _callee, null, [[3, 12]]);
69
- }));
70
- return _loadOptionsData.apply(this, arguments);
71
- }
@@ -1,86 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.loadOptionsData = loadOptionsData;
9
-
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
-
14
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
-
16
- var _lruCache = _interopRequireDefault(require("lru-cache"));
17
-
18
- var _axios = _interopRequireDefault(require("axios"));
19
-
20
- // 500 options list max, each living no more than 5 minutes
21
- var optionCache = new _lruCache["default"]({
22
- max: 500,
23
- maxAge: 1000 * 60 * 5
24
- });
25
-
26
- function loadOptionsData(_x, _x2) {
27
- return _loadOptionsData.apply(this, arguments);
28
- }
29
-
30
- function _loadOptionsData() {
31
- _loadOptionsData = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(optionsUrl, cancelToken) {
32
- var result, resp, newData;
33
- return _regenerator["default"].wrap(function _callee$(_context) {
34
- while (1) {
35
- switch (_context.prev = _context.next) {
36
- case 0:
37
- result = optionCache.get(optionsUrl);
38
-
39
- if (!result) {
40
- _context.next = 3;
41
- break;
42
- }
43
-
44
- return _context.abrupt("return", result);
45
-
46
- case 3:
47
- _context.prev = 3;
48
- _context.next = 6;
49
- return _axios["default"].get(optionsUrl, {
50
- hasLoadingMessage: true,
51
- cancelToken: cancelToken.token
52
- });
53
-
54
- case 6:
55
- resp = _context.sent;
56
- newData = [{
57
- key: null,
58
- value: null
59
- }].concat((0, _toConsumableArray2["default"])(resp.data.result));
60
- optionCache.set(optionsUrl, newData);
61
- return _context.abrupt("return", newData);
62
-
63
- case 12:
64
- _context.prev = 12;
65
- _context.t0 = _context["catch"](3);
66
-
67
- if (!_context.t0.handled) {
68
- _context.next = 16;
69
- break;
70
- }
71
-
72
- return _context.abrupt("return", null);
73
-
74
- case 16:
75
- console.error(_context.t0);
76
- return _context.abrupt("return", null);
77
-
78
- case 18:
79
- case "end":
80
- return _context.stop();
81
- }
82
- }
83
- }, _callee, null, [[3, 12]]);
84
- }));
85
- return _loadOptionsData.apply(this, arguments);
86
- }
@@ -1,26 +0,0 @@
1
- import lru from 'lru-cache';
2
- import axios from 'axios';
3
-
4
- // 500 options list max, each living no more than 5 minutes
5
- const optionCache = new lru({ max: 500, maxAge: 1000 * 60 * 5 });
6
- export async function loadOptionsData(optionsUrl, cancelToken) {
7
- const result = optionCache.get(optionsUrl);
8
- if (result) {
9
- return result;
10
- }
11
- try {
12
- const resp = await axios.get(optionsUrl, {
13
- hasLoadingMessage: true,
14
- cancelToken: cancelToken.token,
15
- });
16
- const newData = [{ key: null, value: null }, ...resp.data.result];
17
- optionCache.set(optionsUrl, newData);
18
- return newData;
19
- } catch (e) {
20
- if (e.handled) {
21
- return null;
22
- }
23
- console.error(e);
24
- return null;
25
- }
26
- }