iglooform 2.4.9 → 2.4.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 (208) hide show
  1. package/es/admin-upload/index.d.ts +2 -0
  2. package/es/admin-upload/index.js +25 -11
  3. package/es/admin-upload/job-list.js +2 -2
  4. package/es/alert-message/index.js +2 -2
  5. package/es/amount/index.js +2 -2
  6. package/es/back-top/index.js +2 -2
  7. package/es/button/index.js +2 -2
  8. package/es/button/style/index.less +23 -19
  9. package/es/card-detail/card-item.js +1 -1
  10. package/es/card-detail/card.js +2 -2
  11. package/es/card-detail/utils.js +3 -3
  12. package/es/checkbox/index.js +2 -2
  13. package/es/claim-list/index.js +2 -2
  14. package/es/confirmation/index.js +2 -2
  15. package/es/date-picker/buddhist.js +2 -2
  16. package/es/date-picker/index.js +2 -2
  17. package/es/declaration/index.js +2 -2
  18. package/es/detail-panel/index.js +2 -2
  19. package/es/example/index.js +6 -7
  20. package/es/filter/index.d.ts +1 -0
  21. package/es/filter/index.js +10 -6
  22. package/es/form/addable-section/index.d.ts +19 -0
  23. package/es/form/addable-section/index.js +211 -0
  24. package/es/form/addable-section/style/index.d.ts +1 -0
  25. package/es/form/addable-section/style/index.js +1 -0
  26. package/es/form/addable-section/style/index.less +22 -0
  27. package/es/form/divider/index.js +2 -2
  28. package/es/form/element/index.js +30 -11
  29. package/es/form/element/style/index.less +5 -0
  30. package/es/form/index.js +7 -5
  31. package/es/form/login/index.js +1 -1
  32. package/es/form/page/index.js +1 -1
  33. package/es/form/page/style/index.less +1 -1
  34. package/es/form/pages/index.js +2 -3
  35. package/es/form/pages/style/index.less +3 -1
  36. package/es/form/render/index.js +1 -1
  37. package/es/form/section/index.js +4 -4
  38. package/es/form/step/index.js +1 -1
  39. package/es/form/steps/index.js +2 -3
  40. package/es/{form/context.d.ts → form-context.d.ts} +1 -0
  41. package/es/{form/context.js → form-context.js} +0 -0
  42. package/es/free-form/addable-section/index.d.ts +18 -0
  43. package/es/free-form/addable-section/index.js +286 -0
  44. package/es/free-form/addable-section/style/index.d.ts +1 -0
  45. package/es/free-form/addable-section/style/index.js +1 -0
  46. package/es/free-form/addable-section/style/index.less +22 -0
  47. package/es/free-form/element/index.js +22 -14
  48. package/es/free-form/element/style/index.less +8 -2
  49. package/es/free-form/index.d.ts +5 -1
  50. package/es/free-form/index.js +8 -5
  51. package/es/free-form/page/index.js +8 -7
  52. package/es/free-form/page/style/index.less +3 -1
  53. package/es/free-form/pages/index.js +2 -2
  54. package/es/free-form/section/index.js +10 -9
  55. package/es/free-form/section/style/index.less +4 -0
  56. package/es/free-form/step/index.js +7 -6
  57. package/es/free-form/steps/index.js +2 -2
  58. package/es/global-message/index.js +1 -1
  59. package/es/index.d.ts +1 -0
  60. package/es/index.js +2 -1
  61. package/es/input/amount.js +2 -2
  62. package/es/input/credit-card.js +2 -2
  63. package/es/input/email.js +2 -2
  64. package/es/input/expiry-date.js +2 -2
  65. package/es/input/input-number.js +2 -2
  66. package/es/input/input.js +2 -2
  67. package/es/input/otp.js +2 -2
  68. package/es/input/password.js +2 -2
  69. package/es/input/style/index.less +9 -1
  70. package/es/input/text-area.js +2 -2
  71. package/es/layout/header.js +3 -3
  72. package/es/layout/index.js +2 -2
  73. package/es/locale/en-US/messages.json +2 -0
  74. package/es/locale/id-ID/messages.json +2 -0
  75. package/es/locale/locale-provider.js +2 -2
  76. package/es/locale/th-TH/messages.json +2 -0
  77. package/es/locale/vi-VN/messages.json +2 -0
  78. package/es/locale/zh-CN/messages.json +2 -0
  79. package/es/media/preview.js +2 -2
  80. package/es/mobile-insurer-detail/index.js +2 -2
  81. package/es/mobile-insurer-list/index.js +2 -2
  82. package/es/modal/index.d.ts +4 -3
  83. package/es/modal/index.js +6 -3
  84. package/es/modal/style/index.less +24 -5
  85. package/es/policy-list/index.js +2 -2
  86. package/es/policy-list/policy-card.js +2 -2
  87. package/es/radio/index.js +2 -2
  88. package/es/select/attached-select.js +2 -2
  89. package/es/select/select.js +2 -2
  90. package/es/select/style/index.less +1 -1
  91. package/es/status-box/index.js +2 -2
  92. package/es/table/index.js +3 -3
  93. package/es/tabs/index.js +2 -2
  94. package/es/tabs/style/index.less +1 -1
  95. package/es/types.d.ts +5 -2
  96. package/es/upload/index.d.ts +2 -1
  97. package/es/upload/index.js +121 -77
  98. package/es/upload-photo/index.d.ts +2 -1
  99. package/es/upload-photo/index.js +123 -79
  100. package/es/utils/form-utils.d.ts +1 -0
  101. package/es/utils/form-utils.js +34 -12
  102. package/lib/admin-upload/index.d.ts +2 -0
  103. package/lib/admin-upload/index.js +25 -11
  104. package/lib/admin-upload/job-list.js +2 -2
  105. package/lib/alert-message/index.js +2 -2
  106. package/lib/amount/index.js +2 -2
  107. package/lib/back-top/index.js +2 -2
  108. package/lib/button/index.js +2 -2
  109. package/lib/button/style/index.less +23 -19
  110. package/lib/card-detail/card-item.js +1 -1
  111. package/lib/card-detail/card.js +2 -2
  112. package/lib/card-detail/utils.js +3 -3
  113. package/lib/checkbox/index.js +2 -2
  114. package/lib/claim-list/index.js +2 -2
  115. package/lib/confirmation/index.js +2 -2
  116. package/lib/date-picker/buddhist.js +2 -2
  117. package/lib/date-picker/index.js +2 -2
  118. package/lib/declaration/index.js +2 -2
  119. package/lib/detail-panel/index.js +2 -2
  120. package/lib/example/index.js +7 -8
  121. package/lib/filter/index.d.ts +1 -0
  122. package/lib/filter/index.js +10 -6
  123. package/lib/form/addable-section/index.d.ts +19 -0
  124. package/lib/form/addable-section/index.js +232 -0
  125. package/lib/form/addable-section/style/index.d.ts +1 -0
  126. package/lib/form/addable-section/style/index.js +3 -0
  127. package/lib/form/addable-section/style/index.less +22 -0
  128. package/lib/form/divider/index.js +2 -2
  129. package/lib/form/element/index.js +32 -12
  130. package/lib/form/element/style/index.less +5 -0
  131. package/lib/form/elements.js +1 -1
  132. package/lib/form/index.js +8 -6
  133. package/lib/form/login/index.js +2 -2
  134. package/lib/form/page/index.js +2 -2
  135. package/lib/form/page/style/index.less +1 -1
  136. package/lib/form/pages/index.js +3 -4
  137. package/lib/form/pages/style/index.less +3 -1
  138. package/lib/form/render/index.js +2 -2
  139. package/lib/form/section/index.js +5 -5
  140. package/lib/form/step/index.js +2 -2
  141. package/lib/form/steps/index.js +3 -4
  142. package/lib/{form/context.d.ts → form-context.d.ts} +1 -0
  143. package/lib/{form/context.js → form-context.js} +0 -0
  144. package/lib/free-form/addable-section/index.d.ts +18 -0
  145. package/lib/free-form/addable-section/index.js +306 -0
  146. package/lib/free-form/addable-section/style/index.d.ts +1 -0
  147. package/lib/free-form/addable-section/style/index.js +3 -0
  148. package/lib/free-form/addable-section/style/index.less +22 -0
  149. package/lib/free-form/element/index.js +23 -15
  150. package/lib/free-form/element/style/index.less +8 -2
  151. package/lib/free-form/index.d.ts +5 -1
  152. package/lib/free-form/index.js +9 -6
  153. package/lib/free-form/page/index.js +9 -8
  154. package/lib/free-form/page/style/index.less +3 -1
  155. package/lib/free-form/pages/index.js +2 -2
  156. package/lib/free-form/section/index.js +11 -10
  157. package/lib/free-form/section/style/index.less +4 -0
  158. package/lib/free-form/step/index.js +8 -7
  159. package/lib/free-form/steps/index.js +3 -3
  160. package/lib/global-message/index.js +1 -1
  161. package/lib/index.d.ts +1 -0
  162. package/lib/index.js +11 -2
  163. package/lib/input/amount.js +2 -2
  164. package/lib/input/credit-card.js +2 -2
  165. package/lib/input/email.js +2 -2
  166. package/lib/input/expiry-date.js +2 -2
  167. package/lib/input/input-number.js +2 -2
  168. package/lib/input/input.js +2 -2
  169. package/lib/input/otp.js +2 -2
  170. package/lib/input/password.js +2 -2
  171. package/lib/input/style/index.less +9 -1
  172. package/lib/input/text-area.js +2 -2
  173. package/lib/layout/header.js +3 -3
  174. package/lib/layout/index.js +2 -2
  175. package/lib/locale/en-US/messages.json +2 -0
  176. package/lib/locale/id-ID/messages.json +2 -0
  177. package/lib/locale/locale-provider.js +2 -2
  178. package/lib/locale/th-TH/messages.json +2 -0
  179. package/lib/locale/vi-VN/messages.json +2 -0
  180. package/lib/locale/zh-CN/messages.json +2 -0
  181. package/lib/media/preview.js +2 -2
  182. package/lib/mobile-insurer-detail/index.js +2 -2
  183. package/lib/mobile-insurer-list/index.js +2 -2
  184. package/lib/modal/index.d.ts +4 -3
  185. package/lib/modal/index.js +6 -3
  186. package/lib/modal/style/index.less +24 -5
  187. package/lib/policy-list/index.js +2 -2
  188. package/lib/policy-list/policy-card.js +2 -2
  189. package/lib/radio/index.js +2 -2
  190. package/lib/select/attached-select.js +2 -2
  191. package/lib/select/select.js +2 -2
  192. package/lib/select/style/index.less +1 -1
  193. package/lib/status-box/index.js +2 -2
  194. package/lib/table/index.js +3 -3
  195. package/lib/tabs/index.js +2 -2
  196. package/lib/tabs/style/index.less +1 -1
  197. package/lib/types.d.ts +5 -2
  198. package/lib/upload/index.d.ts +2 -1
  199. package/lib/upload/index.js +122 -77
  200. package/lib/upload-photo/index.d.ts +2 -1
  201. package/lib/upload-photo/index.js +124 -79
  202. package/lib/utils/form-utils.d.ts +1 -0
  203. package/lib/utils/form-utils.js +33 -12
  204. package/package.json +1 -1
  205. package/es/free-form/context.d.ts +0 -19
  206. package/es/free-form/context.js +0 -7
  207. package/lib/free-form/context.d.ts +0 -19
  208. package/lib/free-form/context.js +0 -19
@@ -0,0 +1,211 @@
1
+ import "antd/es/row/style";
2
+ import _Row from "antd/es/row";
3
+ import "antd/es/col/style";
4
+ import _Col from "antd/es/col";
5
+
6
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
+
8
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
+
10
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
+
12
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
+
14
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
+
16
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
17
+
18
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
+
20
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
21
+
22
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
23
+
24
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
25
+
26
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
27
+
28
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
29
+
30
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
31
+
32
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
33
+ import { useReducer, useContext, useCallback } from 'react';
34
+ import Element from '../element';
35
+ import FormContext from '../../form-context';
36
+ import { calcNamePath, calcFormItemProps } from '../../utils/form-utils';
37
+ import Typography from '../../typography';
38
+ import Button from '../../button';
39
+ import { LocaleContext } from '../../locale';
40
+ import './style/index.less';
41
+
42
+ var AddableSection = function AddableSection(_ref) {
43
+ var parentName = _ref.parentName,
44
+ config = _ref.config,
45
+ preview = _ref.preview,
46
+ disabled = _ref.disabled,
47
+ setShowStepButton = _ref.setShowStepButton;
48
+ var _config$elements = config.elements,
49
+ elements = _config$elements === void 0 ? [] : _config$elements,
50
+ name = config.name,
51
+ label = config.label,
52
+ _config$labelProps = config.labelProps,
53
+ labelProps = _config$labelProps === void 0 ? {} : _config$labelProps,
54
+ _config$contentProps = config.contentProps,
55
+ contentProps = _config$contentProps === void 0 ? {} : _config$contentProps,
56
+ _config$style = config.style,
57
+ style = _config$style === void 0 ? {} : _config$style,
58
+ _config$max = config.max,
59
+ max = _config$max === void 0 ? Number.MAX_SAFE_INTEGER : _config$max,
60
+ _config$initCount = config.initCount,
61
+ initCount = _config$initCount === void 0 ? 1 : _config$initCount,
62
+ _config$min = config.min,
63
+ min = _config$min === void 0 ? initCount : _config$min,
64
+ addButtonText = config.addButtonText,
65
+ addButtonIcon = config.addButtonIcon;
66
+
67
+ var _useContext = useContext(LocaleContext),
68
+ formatMessage = _useContext.formatMessage;
69
+
70
+ var _useContext2 = useContext(FormContext),
71
+ form = _useContext2.form,
72
+ requiredMark = _useContext2.requiredMark;
73
+
74
+ var namePath = calcNamePath(parentName, name);
75
+ var reducer = useCallback(function (state, action) {
76
+ if (action.type === 'add') {
77
+ return [].concat(_toConsumableArray(state), [action.key]);
78
+ }
79
+
80
+ var found = false;
81
+ return state.filter(function (key, index) {
82
+ if (key === action.key) {
83
+ found = true;
84
+ }
85
+
86
+ if (found) {
87
+ if (index === state.length - 1) {
88
+ form === null || form === void 0 ? void 0 : form.setFields([{
89
+ name: calcNamePath(namePath, index),
90
+ value: undefined
91
+ }]);
92
+ } else {
93
+ form === null || form === void 0 ? void 0 : form.setFields([{
94
+ name: calcNamePath(namePath, index),
95
+ value: form.getFieldValue(calcNamePath(namePath, index + 1))
96
+ }]);
97
+ }
98
+ }
99
+
100
+ return key !== action.key;
101
+ });
102
+ }, []);
103
+
104
+ var _useReducer = useReducer(reducer, function () {
105
+ var init = [];
106
+ var value = (form === null || form === void 0 ? void 0 : form.getFieldValue(namePath)) || [];
107
+
108
+ for (var i = 0; i < Math.max(min, value.length, initCount); i++) {
109
+ init.push(Date.now() + Math.random());
110
+ }
111
+
112
+ return init;
113
+ }()),
114
+ _useReducer2 = _slicedToArray(_useReducer, 2),
115
+ groupKeys = _useReducer2[0],
116
+ dispath = _useReducer2[1];
117
+
118
+ var _calcFormItemProps = calcFormItemProps(config, {
119
+ requiredMark: requiredMark
120
+ }, form, parentName),
121
+ formItemProps = _calcFormItemProps.formItemProps,
122
+ elementProps = _calcFormItemProps.elementProps,
123
+ display = _calcFormItemProps.display;
124
+
125
+ if (formItemProps.copiedValue.copied) {
126
+ var currentValue = form === null || form === void 0 ? void 0 : form.getFieldValue(namePath);
127
+
128
+ var value = _objectSpread(_objectSpread({}, currentValue), formItemProps.copiedValue.value);
129
+
130
+ form === null || form === void 0 ? void 0 : form.setFields([{
131
+ name: namePath,
132
+ value: value,
133
+ errors: []
134
+ }]);
135
+ }
136
+
137
+ if (!display) {
138
+ return null;
139
+ }
140
+
141
+ var groups = groupKeys.map(function (key, index) {
142
+ var parentName = calcNamePath(namePath, index);
143
+ return _jsxs(_Col, {
144
+ span: 24,
145
+ className: 'igloo-freeform-addable-section',
146
+ children: [(groupKeys.length > min && !preview || label) && _jsxs(_Row, {
147
+ justify: "space-between",
148
+ className: 'igloo-addable-section-label',
149
+ children: [label ? _jsxs(Typography, _objectSpread(_objectSpread({}, labelProps), {}, {
150
+ level: "h4",
151
+ wrapElement: "div",
152
+ children: [label, " ", index + 1]
153
+ }), void 0) : _jsx("div", {}, void 0), groupKeys.length > min && !preview && _jsx(Button, {
154
+ type: "link",
155
+ className: "igloo-addable-section-label-remove",
156
+ onClick: function onClick() {
157
+ return dispath({
158
+ type: 'remove',
159
+ key: key
160
+ });
161
+ },
162
+ children: formatMessage({
163
+ id: 'Remove'
164
+ })
165
+ }, void 0)]
166
+ }, void 0), _jsx("div", _objectSpread(_objectSpread({
167
+ className: 'igloo-freeform-addable-section-content'
168
+ }, contentProps), {}, {
169
+ children: _jsx(_Row, {
170
+ gutter: [32, preview ? 16 : 24],
171
+ children: elements.map(function (child, index) {
172
+ return _jsx(Element, {
173
+ parentName: parentName,
174
+ config: child,
175
+ disabled: elementProps.disabled || disabled,
176
+ preview: preview,
177
+ setShowStepButton: setShowStepButton
178
+ }, index);
179
+ })
180
+ }, void 0)
181
+ }), void 0)]
182
+ }, key);
183
+ });
184
+ return _jsxs("div", {
185
+ className: "igloo-freeform-addable-section-container",
186
+ style: {
187
+ width: '100%'
188
+ },
189
+ children: [groups, groupKeys.length < max && !preview && _jsx(_Col, {
190
+ span: 24,
191
+ style: {
192
+ marginTop: 16
193
+ },
194
+ children: _jsx(Button, {
195
+ onClick: function onClick() {
196
+ return dispath({
197
+ type: 'add',
198
+ key: Date.now()
199
+ });
200
+ },
201
+ className: "igloo-addable-section-button",
202
+ icon: addButtonIcon,
203
+ children: addButtonText || "".concat(formatMessage({
204
+ id: 'Add'
205
+ }), " ").concat(label)
206
+ }, void 0)
207
+ }, void 0)]
208
+ }, void 0);
209
+ };
210
+
211
+ export default AddableSection;
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -0,0 +1,22 @@
1
+ .igloo-freeform-addable-section-container {
2
+ .igloo-freeform-addable-section {
3
+ .igloo-freeform-addable-section-label {
4
+ .igloo-freeform-addable-section-label-remove {
5
+ height: auto;
6
+ border: none;
7
+ }
8
+ }
9
+
10
+ .igloo-freeform-addable-section-content {
11
+ margin-top: 16px;
12
+ }
13
+
14
+ & + .igloo-freeform-addable-section {
15
+ margin-top: 24px;
16
+ }
17
+ }
18
+
19
+ .igloo-freeform-addable-section-button {
20
+ min-width: 221px;
21
+ }
22
+ }
@@ -2,9 +2,9 @@ import "antd/es/divider/style";
2
2
  import _Divider from "antd/es/divider";
3
3
  var _excluded = ["className"];
4
4
 
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
5
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
6
 
7
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
7
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
8
 
9
9
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
10
 
@@ -13,13 +13,13 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
13
13
 
14
14
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
15
15
 
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
16
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
17
 
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
19
 
20
20
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
21
 
22
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
22
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
23
23
 
24
24
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
25
25
 
@@ -43,11 +43,12 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
43
43
 
44
44
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
45
45
  import { useContext, useEffect, useRef, useReducer } from 'react';
46
- import { CloseCircleFilled } from '@ant-design/icons';
46
+ import { AlertFilled } from 'iglooicon';
47
47
  import { calcFormItemProps } from '../../utils/form-utils';
48
48
  import Section from '../section';
49
+ import AddableSection from '../addable-section';
49
50
  import useComponent from '../elements';
50
- import FormContext from '../context';
51
+ import FormContext from '../../form-context';
51
52
  import invariant from 'invariant';
52
53
  import omit from 'omit.js';
53
54
  import classNames from 'classnames';
@@ -87,7 +88,8 @@ var Element = function Element(_ref) {
87
88
  getOptions = config.getOptions,
88
89
  subscribedFields = config.subscribedFields,
89
90
  disabled = config.disabled,
90
- extraLabel = config.extraLabel;
91
+ extraLabel = config.extraLabel,
92
+ requiredAsserts = config.requiredAsserts;
91
93
  var dependentField = dependencies || [];
92
94
 
93
95
  if (Array.isArray(subscribedFields)) {
@@ -101,13 +103,20 @@ var Element = function Element(_ref) {
101
103
  });
102
104
  }
103
105
 
106
+ if (requiredAsserts && requiredAsserts.length) {
107
+ requiredAsserts.forEach(function (_ref3) {
108
+ var field = _ref3.field;
109
+ return dependentField.push(field);
110
+ });
111
+ }
112
+
104
113
  if (copyValue) {
105
114
  dependentField.push(copyValue.assert.field);
106
115
  }
107
116
 
108
117
  if (selectValue && selectValue.length) {
109
- selectValue.forEach(function (_ref3) {
110
- var assert = _ref3.assert;
118
+ selectValue.forEach(function (_ref4) {
119
+ var assert = _ref4.assert;
111
120
  return dependentField.push(assert.field);
112
121
  });
113
122
  }
@@ -121,8 +130,8 @@ var Element = function Element(_ref) {
121
130
  }
122
131
 
123
132
  if (Array.isArray(disabled)) {
124
- disabled.forEach(function (_ref4) {
125
- var field = _ref4.field;
133
+ disabled.forEach(function (_ref5) {
134
+ var field = _ref5.field;
126
135
  return dependentField.push(field);
127
136
  });
128
137
  } else if (_typeof(disabled) === 'object') {
@@ -151,6 +160,16 @@ var Element = function Element(_ref) {
151
160
  }, void 0);
152
161
  }
153
162
 
163
+ if (type === 'AddableSection') {
164
+ return _jsx(AddableSection, {
165
+ parentName: parentName,
166
+ config: config,
167
+ preview: preview,
168
+ disabled: disabled,
169
+ setShowStepButton: setShowStepButton
170
+ }, void 0);
171
+ }
172
+
154
173
  var _calcFormItemProps = calcFormItemProps(config, _objectSpread(_objectSpread({}, extraConfig), {}, {
155
174
  requiredMark: requiredMark
156
175
  }), form, parentName),
@@ -286,7 +305,7 @@ var Element = function Element(_ref) {
286
305
  sm: 24,
287
306
  xs: 24,
288
307
  className: "igloo-element-preview-value",
289
- children: [error && !!error.length && _jsx(CloseCircleFilled, {
308
+ children: [error && !!error.length && _jsx(AlertFilled, {
290
309
  className: "igloo-element-preview-value-icon"
291
310
  }, void 0), previewFormater ? previewFormater(value, form) : value || '-']
292
311
  }, void 0)]
@@ -20,6 +20,11 @@
20
20
  white-space: pre-wrap;
21
21
  word-break: break-word;
22
22
  line-height: 24px;
23
+
24
+ .igloo-element-preview-value-icon {
25
+ color: @error-color;
26
+ margin-right: 8px;
27
+ }
23
28
  }
24
29
  }
25
30
 
package/es/form/index.js CHANGED
@@ -2,9 +2,9 @@ import "antd/es/form/style";
2
2
  import _Form from "antd/es/form";
3
3
  var _excluded = ["validateMessages"];
4
4
 
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
5
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
6
 
7
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
7
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
8
 
9
9
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
10
 
@@ -34,7 +34,7 @@ import Pages from './pages';
34
34
  import Page from './page';
35
35
  import Steps from './steps';
36
36
  import Login from './login';
37
- import FormContext from './context';
37
+ import FormContext from '../form-context';
38
38
  import messages from './messages';
39
39
  import './style/index.less';
40
40
  import classNames from 'classnames';
@@ -59,7 +59,8 @@ var IglooForm = function IglooForm(props, ref) {
59
59
  return window;
60
60
  } : _props$getScrollConta,
61
61
  _props$onFirstModifie = props.onFirstModified,
62
- onFirstModified = _props$onFirstModifie === void 0 ? function () {} : _props$onFirstModifie;
62
+ onFirstModified = _props$onFirstModifie === void 0 ? function () {} : _props$onFirstModifie,
63
+ uploadApi = props.uploadApi;
63
64
 
64
65
  var _Form$useForm = _Form.useForm(),
65
66
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
@@ -237,7 +238,8 @@ var IglooForm = function IglooForm(props, ref) {
237
238
  requiredMark: requiredMark,
238
239
  showSubmitButton: showSubmitButton,
239
240
  getScrollContainer: getScrollContainer,
240
- registerDependencies: registerDependencies
241
+ registerDependencies: registerDependencies,
242
+ uploadApi: uploadApi
241
243
  }, locales),
242
244
  children: _jsxs(_Form, {
243
245
  form: form,
@@ -10,7 +10,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
10
  import { useContext } from 'react';
11
11
  import Element from '../element';
12
12
  import { calcNamePath } from '../../utils/form-utils';
13
- import FormContext from '../context';
13
+ import FormContext from '../../form-context';
14
14
  import { LocaleContext } from '../../locale';
15
15
  import './style/index.less';
16
16
 
@@ -22,7 +22,7 @@ import { useContext, useEffect, useReducer } from 'react';
22
22
  import Button from '../../button';
23
23
  import Element from '../element';
24
24
  import { calcNamePath } from '../../utils/form-utils';
25
- import FormContext from '../context';
25
+ import FormContext from '../../form-context';
26
26
  import { LocaleContext } from '../../locale';
27
27
  import './style/index.less';
28
28
 
@@ -39,11 +39,11 @@
39
39
  .igloo-page-footer {
40
40
  display: flex;
41
41
  flex-direction: column-reverse;
42
- row-gap: 16px;
43
42
 
44
43
  .igloo-page-cancel-button {
45
44
  min-width: none;
46
45
  width: 100%;
46
+ margin-top: 16px;
47
47
  }
48
48
 
49
49
  .igloo-page-submit-button {
@@ -24,7 +24,7 @@ import { useState, useContext, useReducer, useEffect } from 'react';
24
24
  import Button from '../../button';
25
25
  import Page from '../page';
26
26
  import { calcNamePath } from '../../utils/form-utils';
27
- import FormContext from '../context';
27
+ import FormContext from '../../form-context';
28
28
  import { LocaleContext } from '../../locale';
29
29
  import './style/index.less';
30
30
  import invariant from 'invariant';
@@ -80,7 +80,6 @@ var Pages = function Pages(_ref) {
80
80
  md = _useBreakpoint.md;
81
81
 
82
82
  var renderElements = elements.filter(function (page) {
83
- page.key = page.name || page.key || Math.random();
84
83
  return typeof page.shouldRender !== 'function' || page.shouldRender(form);
85
84
  });
86
85
 
@@ -194,7 +193,7 @@ var Pages = function Pages(_ref) {
194
193
  parentName: calcNamePath(parentName, name),
195
194
  showFooter: false
196
195
  }, void 0)
197
- }, child.key);
196
+ }, child.key || child.name);
198
197
  }), _jsxs("div", {
199
198
  className: 'igloo-pages-footer',
200
199
  children: [current === 0 && _jsx("div", {}, void 0), current > 0 && _jsx(Button, {
@@ -56,21 +56,23 @@
56
56
  padding: 0 16px 24px 16px;
57
57
  display: flex;
58
58
  flex-direction: column-reverse;
59
- row-gap: 16px;
60
59
 
61
60
  .igloo-pages-preview-button {
62
61
  min-width: none;
63
62
  width: 100%;
63
+ margin-top: 16px;
64
64
  }
65
65
 
66
66
  .igloo-pages-next-button {
67
67
  min-width: none;
68
68
  width: 100%;
69
+ margin-top: 16px;
69
70
  }
70
71
 
71
72
  .igloo-pages-cancel-button {
72
73
  min-width: none;
73
74
  width: 100%;
75
+ margin-top: 16px;
74
76
  }
75
77
 
76
78
  .igloo-pages-submit-button {
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useContext, useCallback } from 'react';
3
- import FormContext from '../context';
3
+ import FormContext from '../../form-context';
4
4
 
5
5
  var RenderElement = function RenderElement(_ref) {
6
6
  var _ref$render = _ref.render,
@@ -4,9 +4,9 @@ import "antd/es/col/style";
4
4
  import _Col from "antd/es/col";
5
5
  var _excluded = ["elements", "name", "label", "labelProps", "contentProps", "style"];
6
6
 
7
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
7
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
8
 
9
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
9
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
10
 
11
11
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
12
 
@@ -17,7 +17,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
17
17
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
18
  import { useContext } from 'react';
19
19
  import Element from '../element';
20
- import FormContext from '../context';
20
+ import FormContext from '../../form-context';
21
21
  import { calcNamePath, calcFormItemProps } from '../../utils/form-utils';
22
22
  import Typography from '../../typography';
23
23
  import './style/index.less';
@@ -79,7 +79,7 @@ var Section = function Section(_ref) {
79
79
  className: 'igloo-section-content'
80
80
  }, contentProps), {}, {
81
81
  children: _jsx(_Row, {
82
- gutter: [32, 24],
82
+ gutter: [32, preview ? 16 : 24],
83
83
  children: elements.map(function (child, index) {
84
84
  return _jsx(Element, {
85
85
  parentName: namePath,
@@ -25,7 +25,7 @@ import { LocaleContext } from '../../locale';
25
25
  import Button from '../../button';
26
26
  import Element from '../element';
27
27
  import { calcNamePath } from '../../utils/form-utils';
28
- import FormContext from '../context';
28
+ import FormContext from '../../form-context';
29
29
  import './style/index.less';
30
30
  var useBreakpoint = _Grid.useBreakpoint;
31
31
 
@@ -18,7 +18,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
18
18
  import { useState, useContext, useEffect, useReducer } from 'react';
19
19
  import Step from '../step';
20
20
  import { calcNamePath } from '../../utils/form-utils';
21
- import FormContext from '../context';
21
+ import FormContext from '../../form-context';
22
22
  import './style/index.less';
23
23
  import invariant from 'invariant';
24
24
 
@@ -77,7 +77,6 @@ var Steps = function Steps(_ref) {
77
77
  setCurrent(currentStep);
78
78
  }, [currentStep]);
79
79
  var renderElements = elements.filter(function (step) {
80
- step.key = step.name || step.key;
81
80
  return typeof step.shouldRender !== 'function' || step.shouldRender(form);
82
81
  });
83
82
 
@@ -186,7 +185,7 @@ var Steps = function Steps(_ref) {
186
185
  handleEdit: handleEdit,
187
186
  showLastIndex: showLastIndex,
188
187
  shouldScroll: shouldScroll
189
- }, child.key);
188
+ }, child.key || child.name);
190
189
  })
191
190
  }, void 0)
192
191
  }, void 0);
@@ -15,5 +15,6 @@ declare const _default: React.Context<{
15
15
  showSubmitButton?: boolean | undefined;
16
16
  getScrollContainer: () => HTMLElement | Window | null;
17
17
  registerDependencies: (name: FormItemName | FormItemName[], updater: Function) => void;
18
+ uploadApi?: string | undefined;
18
19
  }>;
19
20
  export default _default;
File without changes
@@ -0,0 +1,18 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import { FormItemProps } from 'antd/es/form';
3
+ import { FormItemConfig, FormItemName } from '../../types';
4
+ import './style/index.less';
5
+ export interface AddableSectionProps extends FormItemConfig {
6
+ parentName?: FormItemName;
7
+ formItemProps?: FormItemProps;
8
+ preview?: boolean;
9
+ disabledFromParent?: boolean;
10
+ setShowStepButton?: (showButton: boolean) => void;
11
+ max?: number;
12
+ min?: number;
13
+ initCount?: number;
14
+ addButtonText?: string;
15
+ addButtonIcon?: ReactNode;
16
+ }
17
+ declare const AddableSection: FC<AddableSectionProps>;
18
+ export default AddableSection;