envoc-form 4.1.0 → 5.0.1

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 (223) hide show
  1. package/README.md +236 -180
  2. package/es/AddressInput/AddressInput.d.ts +24 -25
  3. package/es/AddressInput/AddressInput.js +20 -31
  4. package/es/AddressInput/UsStates.d.ts +3 -3
  5. package/es/AddressInput/UsStates.js +53 -53
  6. package/es/ConfirmBaseForm/ConfirmBaseForm.d.ts +26 -26
  7. package/es/ConfirmBaseForm/ConfirmBaseForm.js +42 -42
  8. package/es/ConfirmDeleteForm/ConfirmDeleteForm.d.ts +24 -24
  9. package/es/ConfirmDeleteForm/ConfirmDeleteForm.js +60 -60
  10. package/es/DatePicker/DatePickerGroup.d.ts +13 -14
  11. package/es/DatePicker/DatePickerGroup.js +87 -87
  12. package/es/DatePicker/DatePickerHelper.d.ts +3 -3
  13. package/es/DatePicker/DatePickerHelper.js +1 -1
  14. package/es/DatePicker/StringDateOnlyPickerGroup.d.ts +9 -10
  15. package/es/DatePicker/StringDateOnlyPickerGroup.js +29 -29
  16. package/es/DatePicker/StringDatePickerGroup.d.ts +9 -10
  17. package/es/DatePicker/StringDatePickerGroup.js +24 -24
  18. package/es/Field/CustomFieldInputProps.d.ts +7 -7
  19. package/es/Field/CustomFieldInputProps.js +1 -1
  20. package/es/Field/CustomFieldMetaProps.d.ts +4 -4
  21. package/es/Field/CustomFieldMetaProps.js +1 -1
  22. package/es/Field/Field.d.ts +28 -28
  23. package/es/Field/Field.js +51 -51
  24. package/es/Field/FieldErrorScrollTarget.d.ts +2 -3
  25. package/es/Field/FieldErrorScrollTarget.js +12 -12
  26. package/es/Field/FieldNameContext.d.ts +3 -3
  27. package/es/Field/FieldNameContext.js +3 -3
  28. package/es/Field/FieldSection.d.ts +7 -7
  29. package/es/Field/FieldSection.js +9 -20
  30. package/es/Field/InjectedFieldProps.d.ts +7 -7
  31. package/es/Field/InjectedFieldProps.js +1 -1
  32. package/es/Field/StandAloneInput.d.ts +13 -13
  33. package/es/Field/StandAloneInput.js +50 -50
  34. package/es/Field/useStandardField.d.ts +21 -21
  35. package/es/Field/useStandardField.js +92 -92
  36. package/es/FieldArray/FieldArray.d.ts +24 -24
  37. package/es/FieldArray/FieldArray.js +77 -88
  38. package/es/File/FileGroup.d.ts +10 -10
  39. package/es/File/FileGroup.js +53 -53
  40. package/es/File/FileList.d.ts +5 -6
  41. package/es/File/FileList.js +10 -21
  42. package/es/File/humanFileSize.d.ts +1 -1
  43. package/es/File/humanFileSize.js +6 -6
  44. package/es/Form/FocusError.d.ts +7 -7
  45. package/es/Form/FocusError.js +42 -42
  46. package/es/Form/Form.d.ts +33 -33
  47. package/es/Form/Form.js +141 -141
  48. package/es/Form/FormBasedPreventNavigation.d.ts +6 -7
  49. package/es/Form/FormBasedPreventNavigation.js +20 -20
  50. package/es/Form/LegacyFormBasedPreventNavigation.d.ts +17 -17
  51. package/es/Form/LegacyFormBasedPreventNavigation.js +69 -69
  52. package/es/Form/NewFormBasedPreventNavigation.d.ts +14 -14
  53. package/es/Form/NewFormBasedPreventNavigation.js +39 -39
  54. package/es/Form/ServerErrorContext.d.ts +11 -11
  55. package/es/Form/ServerErrorContext.js +9 -9
  56. package/es/FormActions.d.ts +12 -13
  57. package/es/FormActions.js +16 -27
  58. package/es/FormDefaults.d.ts +4 -4
  59. package/es/FormDefaults.js +2 -2
  60. package/es/Group.d.ts +16 -16
  61. package/es/Group.js +14 -25
  62. package/es/Input/IconInputGroup.d.ts +12 -12
  63. package/es/Input/IconInputGroup.js +43 -43
  64. package/es/Input/InputGroup.d.ts +12 -12
  65. package/es/Input/InputGroup.js +34 -34
  66. package/es/Input/MoneyInputGroup.d.ts +9 -9
  67. package/es/Input/MoneyInputGroup.js +43 -43
  68. package/es/Input/NumberInputGroup.d.ts +9 -9
  69. package/es/Input/NumberInputGroup.js +43 -43
  70. package/es/Input/StringInputGroup.d.ts +8 -8
  71. package/es/Input/StringInputGroup.js +43 -43
  72. package/es/Normalization/NormalizationFunction.d.ts +4 -4
  73. package/es/Normalization/NormalizationFunction.js +1 -1
  74. package/es/Normalization/normalizers.d.ts +4 -4
  75. package/es/Normalization/normalizers.js +32 -32
  76. package/es/Select/BooleanSelectGroup.d.ts +7 -8
  77. package/es/Select/BooleanSelectGroup.js +28 -28
  78. package/es/Select/NumberSelectGroup.d.ts +9 -10
  79. package/es/Select/NumberSelectGroup.js +21 -21
  80. package/es/Select/SelectGroup.d.ts +27 -28
  81. package/es/Select/SelectGroup.js +65 -65
  82. package/es/Select/SelectGroupPropsHelper.d.ts +3 -3
  83. package/es/Select/SelectGroupPropsHelper.js +1 -1
  84. package/es/Select/StringSelectGroup.d.ts +9 -10
  85. package/es/Select/StringSelectGroup.js +21 -21
  86. package/es/StandardFormActions.d.ts +11 -11
  87. package/es/StandardFormActions.js +14 -25
  88. package/es/SubmitFormButton.d.ts +10 -10
  89. package/es/SubmitFormButton.js +40 -40
  90. package/es/TextArea/TextAreaGroup.d.ts +9 -9
  91. package/es/TextArea/TextAreaGroup.js +35 -35
  92. package/es/Validation/ValidatedApiResult.d.ts +6 -6
  93. package/es/Validation/ValidatedApiResult.js +1 -1
  94. package/es/Validation/ValidationError.d.ts +5 -5
  95. package/es/Validation/ValidationError.js +1 -1
  96. package/es/Validation/ValidationFunction.d.ts +4 -4
  97. package/es/Validation/ValidationFunction.js +1 -1
  98. package/es/Validation/validators.d.ts +18 -18
  99. package/es/Validation/validators.js +77 -77
  100. package/es/index.d.ts +73 -73
  101. package/es/index.js +50 -50
  102. package/es/setupTests.d.ts +1 -1
  103. package/es/setupTests.js +1 -1
  104. package/es/utils/objectContainsNonSerializableProperty.d.ts +1 -1
  105. package/es/utils/objectContainsNonSerializableProperty.js +14 -14
  106. package/es/utils/objectToFormData.d.ts +10 -10
  107. package/es/utils/objectToFormData.js +77 -77
  108. package/es/utils/typeChecks.d.ts +8 -8
  109. package/es/utils/typeChecks.js +18 -18
  110. package/lib/AddressInput/AddressInput.d.ts +24 -25
  111. package/lib/AddressInput/AddressInput.js +26 -37
  112. package/lib/AddressInput/UsStates.d.ts +3 -3
  113. package/lib/AddressInput/UsStates.js +55 -55
  114. package/lib/ConfirmBaseForm/ConfirmBaseForm.d.ts +26 -26
  115. package/lib/ConfirmBaseForm/ConfirmBaseForm.js +48 -48
  116. package/lib/ConfirmDeleteForm/ConfirmDeleteForm.d.ts +24 -24
  117. package/lib/ConfirmDeleteForm/ConfirmDeleteForm.js +66 -66
  118. package/lib/DatePicker/DatePickerGroup.d.ts +13 -14
  119. package/lib/DatePicker/DatePickerGroup.js +95 -95
  120. package/lib/DatePicker/DatePickerHelper.d.ts +3 -3
  121. package/lib/DatePicker/DatePickerHelper.js +2 -2
  122. package/lib/DatePicker/StringDateOnlyPickerGroup.d.ts +9 -10
  123. package/lib/DatePicker/StringDateOnlyPickerGroup.js +35 -35
  124. package/lib/DatePicker/StringDatePickerGroup.d.ts +9 -10
  125. package/lib/DatePicker/StringDatePickerGroup.js +30 -30
  126. package/lib/Field/CustomFieldInputProps.d.ts +7 -7
  127. package/lib/Field/CustomFieldInputProps.js +2 -2
  128. package/lib/Field/CustomFieldMetaProps.d.ts +4 -4
  129. package/lib/Field/CustomFieldMetaProps.js +2 -2
  130. package/lib/Field/Field.d.ts +28 -28
  131. package/lib/Field/Field.js +56 -56
  132. package/lib/Field/FieldErrorScrollTarget.d.ts +2 -3
  133. package/lib/Field/FieldErrorScrollTarget.js +15 -15
  134. package/lib/Field/FieldNameContext.d.ts +3 -3
  135. package/lib/Field/FieldNameContext.js +9 -9
  136. package/lib/Field/FieldSection.d.ts +7 -7
  137. package/lib/Field/FieldSection.js +12 -23
  138. package/lib/Field/InjectedFieldProps.d.ts +7 -7
  139. package/lib/Field/InjectedFieldProps.js +2 -2
  140. package/lib/Field/StandAloneInput.d.ts +13 -13
  141. package/lib/Field/StandAloneInput.js +76 -76
  142. package/lib/Field/useStandardField.d.ts +21 -21
  143. package/lib/Field/useStandardField.js +95 -95
  144. package/lib/FieldArray/FieldArray.d.ts +24 -24
  145. package/lib/FieldArray/FieldArray.js +83 -94
  146. package/lib/File/FileGroup.d.ts +10 -10
  147. package/lib/File/FileGroup.js +58 -58
  148. package/lib/File/FileList.d.ts +5 -6
  149. package/lib/File/FileList.js +13 -24
  150. package/lib/File/humanFileSize.d.ts +1 -1
  151. package/lib/File/humanFileSize.js +10 -10
  152. package/lib/Form/FocusError.d.ts +7 -7
  153. package/lib/Form/FocusError.js +48 -48
  154. package/lib/Form/Form.d.ts +33 -33
  155. package/lib/Form/Form.js +147 -147
  156. package/lib/Form/FormBasedPreventNavigation.d.ts +6 -7
  157. package/lib/Form/FormBasedPreventNavigation.js +26 -26
  158. package/lib/Form/LegacyFormBasedPreventNavigation.d.ts +17 -17
  159. package/lib/Form/LegacyFormBasedPreventNavigation.js +72 -72
  160. package/lib/Form/NewFormBasedPreventNavigation.d.ts +14 -14
  161. package/lib/Form/NewFormBasedPreventNavigation.js +42 -42
  162. package/lib/Form/ServerErrorContext.d.ts +11 -11
  163. package/lib/Form/ServerErrorContext.js +15 -15
  164. package/lib/FormActions.d.ts +12 -13
  165. package/lib/FormActions.js +22 -33
  166. package/lib/FormDefaults.d.ts +4 -4
  167. package/lib/FormDefaults.js +5 -5
  168. package/lib/Group.d.ts +16 -16
  169. package/lib/Group.js +20 -31
  170. package/lib/Input/IconInputGroup.d.ts +12 -12
  171. package/lib/Input/IconInputGroup.js +48 -48
  172. package/lib/Input/InputGroup.d.ts +12 -12
  173. package/lib/Input/InputGroup.js +39 -39
  174. package/lib/Input/MoneyInputGroup.d.ts +9 -9
  175. package/lib/Input/MoneyInputGroup.js +48 -48
  176. package/lib/Input/NumberInputGroup.d.ts +9 -9
  177. package/lib/Input/NumberInputGroup.js +48 -48
  178. package/lib/Input/StringInputGroup.d.ts +8 -8
  179. package/lib/Input/StringInputGroup.js +48 -48
  180. package/lib/Normalization/NormalizationFunction.d.ts +4 -4
  181. package/lib/Normalization/NormalizationFunction.js +2 -2
  182. package/lib/Normalization/normalizers.d.ts +4 -4
  183. package/lib/Normalization/normalizers.js +37 -37
  184. package/lib/Select/BooleanSelectGroup.d.ts +7 -8
  185. package/lib/Select/BooleanSelectGroup.js +35 -35
  186. package/lib/Select/NumberSelectGroup.d.ts +9 -10
  187. package/lib/Select/NumberSelectGroup.js +29 -29
  188. package/lib/Select/SelectGroup.d.ts +27 -28
  189. package/lib/Select/SelectGroup.js +71 -71
  190. package/lib/Select/SelectGroupPropsHelper.d.ts +3 -3
  191. package/lib/Select/SelectGroupPropsHelper.js +2 -2
  192. package/lib/Select/StringSelectGroup.d.ts +9 -10
  193. package/lib/Select/StringSelectGroup.js +29 -29
  194. package/lib/StandardFormActions.d.ts +11 -11
  195. package/lib/StandardFormActions.js +20 -31
  196. package/lib/SubmitFormButton.d.ts +10 -10
  197. package/lib/SubmitFormButton.js +45 -45
  198. package/lib/TextArea/TextAreaGroup.d.ts +9 -9
  199. package/lib/TextArea/TextAreaGroup.js +40 -40
  200. package/lib/Validation/ValidatedApiResult.d.ts +6 -6
  201. package/lib/Validation/ValidatedApiResult.js +2 -2
  202. package/lib/Validation/ValidationError.d.ts +5 -5
  203. package/lib/Validation/ValidationError.js +2 -2
  204. package/lib/Validation/ValidationFunction.d.ts +4 -4
  205. package/lib/Validation/ValidationFunction.js +2 -2
  206. package/lib/Validation/validators.d.ts +18 -18
  207. package/lib/Validation/validators.js +90 -90
  208. package/lib/index.d.ts +73 -73
  209. package/lib/index.js +117 -117
  210. package/lib/setupTests.d.ts +1 -1
  211. package/lib/setupTests.js +3 -3
  212. package/lib/utils/objectContainsNonSerializableProperty.d.ts +1 -1
  213. package/lib/utils/objectContainsNonSerializableProperty.js +17 -17
  214. package/lib/utils/objectToFormData.d.ts +10 -10
  215. package/lib/utils/objectToFormData.js +79 -79
  216. package/lib/utils/typeChecks.d.ts +8 -8
  217. package/lib/utils/typeChecks.js +29 -29
  218. package/package.json +12 -12
  219. package/src/AddressInput/__snapshots__/AddressInput.test.tsx.snap +6 -8
  220. package/src/Select/__tests__/__snapshots__/BooleanSelectGroup.test.tsx.snap +6 -8
  221. package/src/Select/__tests__/__snapshots__/NumberSelectGroup.test.tsx.snap +12 -16
  222. package/src/Select/__tests__/__snapshots__/StringSelectGroup.test.tsx.snap +12 -16
  223. package/src/utils/objectToFormData.test.tsx +1 -1
@@ -1,94 +1,83 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __rest = (this && this.__rest) || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
- t[p] = s[p];
17
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
- t[p[i]] = s[p[i]];
21
- }
22
- return t;
23
- };
24
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
25
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
26
- if (ar || !(i in from)) {
27
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
28
- ar[i] = from[i];
29
- }
30
- }
31
- return to.concat(ar || Array.prototype.slice.call(from));
32
- };
33
- var __importDefault = (this && this.__importDefault) || function (mod) {
34
- return (mod && mod.__esModule) ? mod : { "default": mod };
35
- };
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- var jsx_runtime_1 = require("react/jsx-runtime");
38
- var classnames_1 = __importDefault(require("classnames"));
39
- var Field_1 = __importDefault(require("../Field/Field"));
40
- var FieldNameContext_1 = require("../Field/FieldNameContext");
41
- var useStandardField_1 = __importDefault(require("../Field/useStandardField"));
42
- var FormDefaults_1 = require("../FormDefaults");
43
- /**
44
- * An array of fields that allows the user to add multiple instances of the same field.
45
- *
46
- * Includes "Add Item" and "Remove Item" buttons to allow the user to speicify the number of fields.
47
- */
48
- function FieldArray(_a) {
49
- var _b;
50
- var name = _a.name, label = _a.label, validate = _a.validate, disabled = _a.disabled, children = _a.children, rest = __rest(_a, ["name", "label", "validate", "disabled", "children"]);
51
- var input = (0, useStandardField_1.default)({
52
- name: String(name),
53
- validate: validate,
54
- disabled: disabled,
55
- })[0];
56
- var values = !input.value
57
- ? []
58
- : Array.isArray(input.value)
59
- ? input.value
60
- : [];
61
- return ((0, jsx_runtime_1.jsxs)("div", __assign({ className: FormDefaults_1.FormDefaults.cssClassPrefix + 'field-array' }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ className: FormDefaults_1.FormDefaults.cssClassPrefix + 'field-array-header' }, { children: [(0, jsx_runtime_1.jsx)("div", __assign({ className: FormDefaults_1.FormDefaults.cssClassPrefix + 'field-array-title' }, { children: label })), (0, jsx_runtime_1.jsx)("button", __assign({ className: (0, classnames_1.default)(FormDefaults_1.FormDefaults.cssClassPrefix + 'add-array-item-button', (_b = {}, _b[FormDefaults_1.FormDefaults.cssClassPrefix + 'disabled'] = disabled, _b)), title: "Add Item", type: "button", onClick: addItem }, { children: "+" }))] })), (0, jsx_runtime_1.jsx)("div", __assign({ className: FormDefaults_1.FormDefaults.cssClassPrefix + 'field-array-body' }, { children: values.map(function (value, index) {
62
- var _a, _b;
63
- var itemName = "".concat(input.name, "[").concat(index, "]");
64
- return ((0, jsx_runtime_1.jsxs)("div", __assign({ className: (0, classnames_1.default)(FormDefaults_1.FormDefaults.cssClassPrefix + 'field-array-item', (_a = {},
65
- _a[FormDefaults_1.FormDefaults.cssClassPrefix + 'removed'] = value.isDeleted,
66
- _a)), role: "listitem" }, { children: [(0, jsx_runtime_1.jsx)(FieldNameContext_1.FieldNameContext.Provider, __assign({ value: itemName }, { children: children({
67
- Field: Field_1.default,
68
- FieldArray: FieldArray,
69
- }) })), (0, jsx_runtime_1.jsx)("button", __assign({ className: (0, classnames_1.default)(FormDefaults_1.FormDefaults.cssClassPrefix + 'remove-array-item-button', (_b = {}, _b[FormDefaults_1.FormDefaults.cssClassPrefix + 'disabled'] = disabled, _b)), type: "button", title: "Remove Item", onClick: function () { return removeItem(value); } }, { children: "-" }))] }), (value && value['form-input-array-key']) ||
70
- (value && value['id']) ||
71
- itemName));
72
- }) }))] })));
73
- function addItem() {
74
- if (disabled) {
75
- return;
76
- }
77
- input.onChange(__spreadArray(__spreadArray([], values, true), [{}], false));
78
- }
79
- function removeItem(item) {
80
- if (disabled) {
81
- return;
82
- }
83
- // assumes anything from the server has an 'id' value sent
84
- if (!item.id) {
85
- input.onChange(values.filter(function (x) { return x !== item; }));
86
- return;
87
- }
88
- var mapped = values.map(function (x) {
89
- return x !== item ? x : Object.assign({}, x, { isDeleted: true });
90
- });
91
- input.onChange(mapped);
92
- }
93
- }
94
- exports.default = FieldArray;
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
+ if (ar || !(i in from)) {
16
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
+ ar[i] = from[i];
18
+ }
19
+ }
20
+ return to.concat(ar || Array.prototype.slice.call(from));
21
+ };
22
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ var jsx_runtime_1 = require("react/jsx-runtime");
27
+ var classnames_1 = __importDefault(require("classnames"));
28
+ var Field_1 = __importDefault(require("../Field/Field"));
29
+ var FieldNameContext_1 = require("../Field/FieldNameContext");
30
+ var useStandardField_1 = __importDefault(require("../Field/useStandardField"));
31
+ var FormDefaults_1 = require("../FormDefaults");
32
+ /**
33
+ * An array of fields that allows the user to add multiple instances of the same field.
34
+ *
35
+ * Includes "Add Item" and "Remove Item" buttons to allow the user to speicify the number of fields.
36
+ */
37
+ function FieldArray(_a) {
38
+ var _b;
39
+ var name = _a.name, label = _a.label, validate = _a.validate, disabled = _a.disabled, children = _a.children, rest = __rest(_a, ["name", "label", "validate", "disabled", "children"]);
40
+ var input = (0, useStandardField_1.default)({
41
+ name: String(name),
42
+ validate: validate,
43
+ disabled: disabled,
44
+ })[0];
45
+ var values = !input.value
46
+ ? []
47
+ : Array.isArray(input.value)
48
+ ? input.value
49
+ : [];
50
+ return ((0, jsx_runtime_1.jsxs)("div", { className: FormDefaults_1.FormDefaults.cssClassPrefix + 'field-array', children: [(0, jsx_runtime_1.jsxs)("div", { className: FormDefaults_1.FormDefaults.cssClassPrefix + 'field-array-header', children: [(0, jsx_runtime_1.jsx)("div", { className: FormDefaults_1.FormDefaults.cssClassPrefix + 'field-array-title', children: label }), (0, jsx_runtime_1.jsx)("button", { className: (0, classnames_1.default)(FormDefaults_1.FormDefaults.cssClassPrefix + 'add-array-item-button', (_b = {}, _b[FormDefaults_1.FormDefaults.cssClassPrefix + 'disabled'] = disabled, _b)), title: "Add Item", type: "button", onClick: addItem, children: "+" })] }), (0, jsx_runtime_1.jsx)("div", { className: FormDefaults_1.FormDefaults.cssClassPrefix + 'field-array-body', children: values.map(function (value, index) {
51
+ var _a, _b;
52
+ var itemName = "".concat(input.name, "[").concat(index, "]");
53
+ return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(FormDefaults_1.FormDefaults.cssClassPrefix + 'field-array-item', (_a = {},
54
+ _a[FormDefaults_1.FormDefaults.cssClassPrefix + 'removed'] = value.isDeleted,
55
+ _a)), role: "listitem", children: [(0, jsx_runtime_1.jsx)(FieldNameContext_1.FieldNameContext.Provider, { value: itemName, children: children({
56
+ Field: Field_1.default,
57
+ FieldArray: FieldArray,
58
+ }) }), (0, jsx_runtime_1.jsx)("button", { className: (0, classnames_1.default)(FormDefaults_1.FormDefaults.cssClassPrefix + 'remove-array-item-button', (_b = {}, _b[FormDefaults_1.FormDefaults.cssClassPrefix + 'disabled'] = disabled, _b)), type: "button", title: "Remove Item", onClick: function () { return removeItem(value); }, children: "-" })] }, (value && value['form-input-array-key']) ||
59
+ (value && value['id']) ||
60
+ itemName));
61
+ }) })] }));
62
+ function addItem() {
63
+ if (disabled) {
64
+ return;
65
+ }
66
+ input.onChange(__spreadArray(__spreadArray([], values, true), [{}], false));
67
+ }
68
+ function removeItem(item) {
69
+ if (disabled) {
70
+ return;
71
+ }
72
+ // assumes anything from the server has an 'id' value sent
73
+ if (!item.id) {
74
+ input.onChange(values.filter(function (x) { return x !== item; }));
75
+ return;
76
+ }
77
+ var mapped = values.map(function (x) {
78
+ return x !== item ? x : Object.assign({}, x, { isDeleted: true });
79
+ });
80
+ input.onChange(mapped);
81
+ }
82
+ }
83
+ exports.default = FieldArray;
@@ -1,10 +1,10 @@
1
- import React from 'react';
2
- import { InjectedFieldProps } from '../Field/InjectedFieldProps';
3
- import { GroupProps } from '../Group';
4
- export interface FileGroupProps extends InjectedFieldProps<any | undefined | null>, Omit<GroupProps, keyof InjectedFieldProps<any> | 'children'>, Omit<React.HTMLProps<HTMLInputElement>, keyof InjectedFieldProps<any> | 'children' | 'className' | 'label'> {
5
- /** Allow multiple files to be uploaded. */
6
- multiple?: boolean | undefined;
7
- }
8
- /** File upload input group. */
9
- declare const FileGroupWithRef: React.ComponentType<FileGroupProps>;
10
- export default FileGroupWithRef;
1
+ import React from 'react';
2
+ import { InjectedFieldProps } from '../Field/InjectedFieldProps';
3
+ import { GroupProps } from '../Group';
4
+ export interface FileGroupProps extends InjectedFieldProps<any | undefined | null>, Omit<GroupProps, keyof InjectedFieldProps<any> | 'children'>, Omit<React.HTMLProps<HTMLInputElement>, keyof InjectedFieldProps<any> | 'children' | 'className' | 'label'> {
5
+ /** Allow multiple files to be uploaded. */
6
+ multiple?: boolean | undefined;
7
+ }
8
+ /** File upload input group. */
9
+ declare const FileGroupWithRef: React.ComponentType<FileGroupProps>;
10
+ export default FileGroupWithRef;
@@ -1,58 +1,58 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __rest = (this && this.__rest) || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
- t[p] = s[p];
17
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
- t[p[i]] = s[p[i]];
21
- }
22
- return t;
23
- };
24
- var __importDefault = (this && this.__importDefault) || function (mod) {
25
- return (mod && mod.__esModule) ? mod : { "default": mod };
26
- };
27
- Object.defineProperty(exports, "__esModule", { value: true });
28
- var jsx_runtime_1 = require("react/jsx-runtime");
29
- var react_1 = __importDefault(require("react"));
30
- var classnames_1 = __importDefault(require("classnames"));
31
- var FileList_1 = __importDefault(require("./FileList"));
32
- var FormDefaults_1 = require("../FormDefaults");
33
- var Group_1 = __importDefault(require("../Group"));
34
- function FileGroup(_a, ref) {
35
- var _b;
36
- var input = _a.input, meta = _a.meta, label = _a.label, helpText = _a.helpText, className = _a.className, required = _a.required, disabled = _a.disabled, multiple = _a.multiple, rest = __rest(_a, ["input", "meta", "label", "helpText", "className", "required", "disabled", "multiple"]);
37
- return ((0, jsx_runtime_1.jsxs)(Group_1.default, __assign({ input: input, meta: meta, label: label, helpText: helpText, className: (0, classnames_1.default)(className, (_b = {}, _b[FormDefaults_1.FormDefaults.cssClassPrefix + 'multiple'] = multiple, _b), FormDefaults_1.FormDefaults.cssClassPrefix + 'file-group'), required: required, disabled: disabled }, { children: [(0, jsx_runtime_1.jsx)("input", __assign({}, input, rest, { multiple: multiple, onChange: function (e) {
38
- var _a, _b;
39
- if (!((_b = (_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b.length)) {
40
- input.onChange(undefined);
41
- }
42
- else {
43
- var files = [];
44
- for (var i = 0; i < e.target.files.length; i++) {
45
- files.push(e.target.files[i]);
46
- }
47
- if (!multiple) {
48
- input.onChange(files[0]);
49
- }
50
- else {
51
- input.onChange(files);
52
- }
53
- }
54
- }, value: undefined, ref: ref, type: "file", className: (0, classnames_1.default)(className, FormDefaults_1.FormDefaults.cssClassPrefix + 'file-group') })), (0, jsx_runtime_1.jsx)(FileList_1.default, { files: input.value })] })));
55
- }
56
- /** File upload input group. */
57
- var FileGroupWithRef = react_1.default.forwardRef(FileGroup);
58
- exports.default = FileGroupWithRef;
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ var __importDefault = (this && this.__importDefault) || function (mod) {
25
+ return (mod && mod.__esModule) ? mod : { "default": mod };
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ var jsx_runtime_1 = require("react/jsx-runtime");
29
+ var react_1 = __importDefault(require("react"));
30
+ var classnames_1 = __importDefault(require("classnames"));
31
+ var FileList_1 = __importDefault(require("./FileList"));
32
+ var FormDefaults_1 = require("../FormDefaults");
33
+ var Group_1 = __importDefault(require("../Group"));
34
+ function FileGroup(_a, ref) {
35
+ var _b;
36
+ var input = _a.input, meta = _a.meta, label = _a.label, helpText = _a.helpText, className = _a.className, required = _a.required, disabled = _a.disabled, multiple = _a.multiple, rest = __rest(_a, ["input", "meta", "label", "helpText", "className", "required", "disabled", "multiple"]);
37
+ return ((0, jsx_runtime_1.jsxs)(Group_1.default, { input: input, meta: meta, label: label, helpText: helpText, className: (0, classnames_1.default)(className, (_b = {}, _b[FormDefaults_1.FormDefaults.cssClassPrefix + 'multiple'] = multiple, _b), FormDefaults_1.FormDefaults.cssClassPrefix + 'file-group'), required: required, disabled: disabled, children: [(0, jsx_runtime_1.jsx)("input", __assign({}, input, rest, { multiple: multiple, onChange: function (e) {
38
+ var _a, _b;
39
+ if (!((_b = (_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b.length)) {
40
+ input.onChange(undefined);
41
+ }
42
+ else {
43
+ var files = [];
44
+ for (var i = 0; i < e.target.files.length; i++) {
45
+ files.push(e.target.files[i]);
46
+ }
47
+ if (!multiple) {
48
+ input.onChange(files[0]);
49
+ }
50
+ else {
51
+ input.onChange(files);
52
+ }
53
+ }
54
+ }, value: undefined, ref: ref, type: "file", className: (0, classnames_1.default)(className, FormDefaults_1.FormDefaults.cssClassPrefix + 'file-group') })), (0, jsx_runtime_1.jsx)(FileList_1.default, { files: input.value })] }));
55
+ }
56
+ /** File upload input group. */
57
+ var FileGroupWithRef = react_1.default.forwardRef(FileGroup);
58
+ exports.default = FileGroupWithRef;
@@ -1,6 +1,5 @@
1
- /// <reference types="react" />
2
- export interface FileListProps {
3
- files?: File | File[] | undefined | null;
4
- rejectedFiles?: File | File[] | undefined | null;
5
- }
6
- export default function FileList({ files, rejectedFiles }: FileListProps): JSX.Element;
1
+ export interface FileListProps {
2
+ files?: File | File[] | undefined | null;
3
+ rejectedFiles?: File | File[] | undefined | null;
4
+ }
5
+ export default function FileList({ files, rejectedFiles }: FileListProps): import("react/jsx-runtime").JSX.Element;
@@ -1,24 +1,13 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- var jsx_runtime_1 = require("react/jsx-runtime");
15
- var FormDefaults_1 = require("../FormDefaults");
16
- function FileList(_a) {
17
- var files = _a.files, rejectedFiles = _a.rejectedFiles;
18
- return ((0, jsx_runtime_1.jsx)("div", __assign({ className: FormDefaults_1.FormDefaults.cssClassPrefix + 'file-list' }, { children: !files ? null : Array.isArray(files) ? (files.map(function (x, i) { return (0, jsx_runtime_1.jsx)(File, { file: x }, i); })) : ((0, jsx_runtime_1.jsx)(File, { file: files })) })));
19
- }
20
- exports.default = FileList;
21
- function File(_a) {
22
- var file = _a.file;
23
- return null;
24
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var jsx_runtime_1 = require("react/jsx-runtime");
4
+ var FormDefaults_1 = require("../FormDefaults");
5
+ function FileList(_a) {
6
+ var files = _a.files, rejectedFiles = _a.rejectedFiles;
7
+ return ((0, jsx_runtime_1.jsx)("div", { className: FormDefaults_1.FormDefaults.cssClassPrefix + 'file-list', children: !files ? null : Array.isArray(files) ? (files.map(function (x, i) { return (0, jsx_runtime_1.jsx)(File, { file: x }, i); })) : ((0, jsx_runtime_1.jsx)(File, { file: files })) }));
8
+ }
9
+ exports.default = FileList;
10
+ function File(_a) {
11
+ var file = _a.file;
12
+ return null;
13
+ }
@@ -1 +1 @@
1
- export declare function humanFileSize(size: number): string;
1
+ export declare function humanFileSize(size: number): string;
@@ -1,10 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.humanFileSize = void 0;
4
- function humanFileSize(size) {
5
- var i = Math.floor(Math.log(size) / Math.log(1024));
6
- return ((size / Math.pow(1024, i)).toFixed(2) +
7
- ' ' +
8
- ['B', 'KB', 'MB', 'GB', 'TB'][i]);
9
- }
10
- exports.humanFileSize = humanFileSize;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.humanFileSize = void 0;
4
+ function humanFileSize(size) {
5
+ var i = Math.floor(Math.log(size) / Math.log(1024));
6
+ return ((size / Math.pow(1024, i)).toFixed(2) +
7
+ ' ' +
8
+ ['B', 'KB', 'MB', 'GB', 'TB'][i]);
9
+ }
10
+ exports.humanFileSize = humanFileSize;
@@ -1,7 +1,7 @@
1
- import { ServerErrorContextProps } from './ServerErrorContext';
2
- export interface FocusErrorProps {
3
- /** Validation errors that have been received from the server. */
4
- serverErrors: ServerErrorContextProps;
5
- }
6
- /** Function to scroll to the field that has an error. */
7
- export default function FocusError(props: FocusErrorProps): null;
1
+ import { ServerErrorContextProps } from './ServerErrorContext';
2
+ export interface FocusErrorProps {
3
+ /** Validation errors that have been received from the server. */
4
+ serverErrors: ServerErrorContextProps;
5
+ }
6
+ /** Function to scroll to the field that has an error. */
7
+ export default function FocusError(props: FocusErrorProps): null;
@@ -1,48 +1,48 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var react_1 = require("react");
7
- var formik_1 = require("formik");
8
- var smoothscroll_polyfill_1 = __importDefault(require("smoothscroll-polyfill"));
9
- /** Function to scroll to the field that has an error. */
10
- function FocusError(props) {
11
- var _a = (0, formik_1.useFormikContext)(), errors = _a.errors, isSubmitting = _a.isSubmitting, isValidating = _a.isValidating;
12
- smoothscroll_polyfill_1.default.polyfill();
13
- (0, react_1.useEffect)(function () {
14
- if (!isSubmitting || isValidating) {
15
- return;
16
- }
17
- //This block handles any front-end input validation errors
18
- //e.g. required fields, max characters, etc
19
- var keys = Object.keys(errors);
20
- if (keys.length > 0) {
21
- return scrollToErrorElement(keys);
22
- }
23
- //This block handles any input-specific server-side errors
24
- //e.g. improper email formatting, invalid phone number, etc.
25
- if (props.serverErrors.errors &&
26
- Object.values(props.serverErrors.errors).some(function (x) { return !!x; })) {
27
- var names = Object.keys(props.serverErrors.errors);
28
- return scrollToErrorElement(names);
29
- }
30
- }, [errors, isSubmitting, isValidating, props]);
31
- return null;
32
- }
33
- exports.default = FocusError;
34
- var scrollToErrorElement = function (keys) {
35
- var firstErrorElement = document.getElementById("".concat(keys[0].toLowerCase(), "-error-scroll-target"));
36
- if (!firstErrorElement || !firstErrorElement.parentNode) {
37
- return;
38
- }
39
- firstErrorElement = firstErrorElement.parentNode;
40
- var headerOffset = -110;
41
- var y = firstErrorElement.getBoundingClientRect().top +
42
- window.pageYOffset +
43
- headerOffset;
44
- window.scrollTo({ top: y, behavior: 'smooth' });
45
- setTimeout(function () {
46
- firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus();
47
- }, 500);
48
- };
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var react_1 = require("react");
7
+ var formik_1 = require("formik");
8
+ var smoothscroll_polyfill_1 = __importDefault(require("smoothscroll-polyfill"));
9
+ /** Function to scroll to the field that has an error. */
10
+ function FocusError(props) {
11
+ var _a = (0, formik_1.useFormikContext)(), errors = _a.errors, isSubmitting = _a.isSubmitting, isValidating = _a.isValidating;
12
+ smoothscroll_polyfill_1.default.polyfill();
13
+ (0, react_1.useEffect)(function () {
14
+ if (!isSubmitting || isValidating) {
15
+ return;
16
+ }
17
+ //This block handles any front-end input validation errors
18
+ //e.g. required fields, max characters, etc
19
+ var keys = Object.keys(errors);
20
+ if (keys.length > 0) {
21
+ return scrollToErrorElement(keys);
22
+ }
23
+ //This block handles any input-specific server-side errors
24
+ //e.g. improper email formatting, invalid phone number, etc.
25
+ if (props.serverErrors.errors &&
26
+ Object.values(props.serverErrors.errors).some(function (x) { return !!x; })) {
27
+ var names = Object.keys(props.serverErrors.errors);
28
+ return scrollToErrorElement(names);
29
+ }
30
+ }, [errors, isSubmitting, isValidating, props]);
31
+ return null;
32
+ }
33
+ exports.default = FocusError;
34
+ var scrollToErrorElement = function (keys) {
35
+ var firstErrorElement = document.getElementById("".concat(keys[0].toLowerCase(), "-error-scroll-target"));
36
+ if (!firstErrorElement || !firstErrorElement.parentNode) {
37
+ return;
38
+ }
39
+ firstErrorElement = firstErrorElement.parentNode;
40
+ var headerOffset = -110;
41
+ var y = firstErrorElement.getBoundingClientRect().top +
42
+ window.pageYOffset +
43
+ headerOffset;
44
+ window.scrollTo({ top: y, behavior: 'smooth' });
45
+ setTimeout(function () {
46
+ firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus();
47
+ }, 500);
48
+ };
@@ -1,33 +1,33 @@
1
- import { CSSProperties, ElementType } from 'react';
2
- import { FormikHelpers } from 'formik';
3
- import { FieldProps } from '../Field/Field';
4
- import { FieldArrayProps } from '../FieldArray/FieldArray';
5
- import { ValidatedApiResult } from '../Validation/ValidatedApiResult';
6
- export declare type FormBuilderProp<TForm extends object> = {
7
- Field: <TProp extends keyof TForm, TRenderComponent extends ElementType>(props: FieldProps<TForm, TProp, TRenderComponent>) => JSX.Element;
8
- FieldArray: <TProp extends keyof TForm>(props: FieldArrayProps<TForm, TProp>) => JSX.Element;
9
- };
10
- export interface FullFormProps<TForm extends object> {
11
- /** The `<Field/>` and `<FieldArray/>` components. */
12
- children: (formBuilder: FormBuilderProp<TForm>) => JSX.Element;
13
- /** Submission handler */
14
- onSubmit: (formValues: TForm, formikBag: FormikHelpers<TForm>) => Promise<ValidatedApiResult>;
15
- /** Submission handler for forms that use [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData).*/
16
- onFormDataSubmit: (formValues: FormData, formikBag: FormikHelpers<TForm>) => Promise<ValidatedApiResult>;
17
- className?: string;
18
- style?: CSSProperties;
19
- /** Prevent the user from leaving the form if they have edited any field. This is presented as a JS `alert()`. */
20
- ignoreLostChanges?: boolean;
21
- /** The intitial values of the form. */
22
- initialValues?: TForm;
23
- }
24
- declare type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
25
- [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
26
- }[Keys];
27
- export declare type FormProps<TForm extends object> = RequireAtLeastOne<FullFormProps<TForm>, 'onSubmit' | 'onFormDataSubmit'>;
28
- /** Define a form. Uses [formik](https://formik.org/docs/overview). Usually contains many `<Field/>` components. */
29
- declare function Form<TForm extends object>({ children, className, style, ignoreLostChanges, onSubmit, onFormDataSubmit, initialValues, ...props }: FormProps<TForm>): JSX.Element;
30
- declare namespace Form {
31
- var DisplayFormState: () => JSX.Element;
32
- }
33
- export default Form;
1
+ import { CSSProperties, ElementType } from 'react';
2
+ import { FormikHelpers } from 'formik';
3
+ import { FieldProps } from '../Field/Field';
4
+ import { FieldArrayProps } from '../FieldArray/FieldArray';
5
+ import { ValidatedApiResult } from '../Validation/ValidatedApiResult';
6
+ export type FormBuilderProp<TForm extends object> = {
7
+ Field: <TProp extends keyof TForm, TRenderComponent extends ElementType>(props: FieldProps<TForm, TProp, TRenderComponent>) => JSX.Element;
8
+ FieldArray: <TProp extends keyof TForm>(props: FieldArrayProps<TForm, TProp>) => JSX.Element;
9
+ };
10
+ export interface FullFormProps<TForm extends object> {
11
+ /** The `<Field/>` and `<FieldArray/>` components. */
12
+ children: (formBuilder: FormBuilderProp<TForm>) => JSX.Element;
13
+ /** Submission handler */
14
+ onSubmit: (formValues: TForm, formikBag: FormikHelpers<TForm>) => Promise<ValidatedApiResult>;
15
+ /** Submission handler for forms that use [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData).*/
16
+ onFormDataSubmit: (formValues: FormData, formikBag: FormikHelpers<TForm>) => Promise<ValidatedApiResult>;
17
+ className?: string;
18
+ style?: CSSProperties;
19
+ /** Prevent the user from leaving the form if they have edited any field. This is presented as a JS `alert()`. */
20
+ ignoreLostChanges?: boolean;
21
+ /** The intitial values of the form. */
22
+ initialValues?: TForm;
23
+ }
24
+ type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
25
+ [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
26
+ }[Keys];
27
+ export type FormProps<TForm extends object> = RequireAtLeastOne<FullFormProps<TForm>, 'onSubmit' | 'onFormDataSubmit'>;
28
+ /** Define a form. Uses [formik](https://formik.org/docs/overview). Usually contains many `<Field/>` components. */
29
+ declare function Form<TForm extends object>({ children, className, style, ignoreLostChanges, onSubmit, onFormDataSubmit, initialValues, ...props }: FormProps<TForm>): import("react/jsx-runtime").JSX.Element;
30
+ declare namespace Form {
31
+ var DisplayFormState: () => import("react/jsx-runtime").JSX.Element;
32
+ }
33
+ export default Form;