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.
- package/es/admin-upload/index.d.ts +2 -0
- package/es/admin-upload/index.js +25 -11
- package/es/admin-upload/job-list.js +2 -2
- package/es/alert-message/index.js +2 -2
- package/es/amount/index.js +2 -2
- package/es/back-top/index.js +2 -2
- package/es/button/index.js +2 -2
- package/es/button/style/index.less +23 -19
- package/es/card-detail/card-item.js +1 -1
- package/es/card-detail/card.js +2 -2
- package/es/card-detail/utils.js +3 -3
- package/es/checkbox/index.js +2 -2
- package/es/claim-list/index.js +2 -2
- package/es/confirmation/index.js +2 -2
- package/es/date-picker/buddhist.js +2 -2
- package/es/date-picker/index.js +2 -2
- package/es/declaration/index.js +2 -2
- package/es/detail-panel/index.js +2 -2
- package/es/example/index.js +6 -7
- package/es/filter/index.d.ts +1 -0
- package/es/filter/index.js +10 -6
- package/es/form/addable-section/index.d.ts +19 -0
- package/es/form/addable-section/index.js +211 -0
- package/es/form/addable-section/style/index.d.ts +1 -0
- package/es/form/addable-section/style/index.js +1 -0
- package/es/form/addable-section/style/index.less +22 -0
- package/es/form/divider/index.js +2 -2
- package/es/form/element/index.js +30 -11
- package/es/form/element/style/index.less +5 -0
- package/es/form/index.js +7 -5
- package/es/form/login/index.js +1 -1
- package/es/form/page/index.js +1 -1
- package/es/form/page/style/index.less +1 -1
- package/es/form/pages/index.js +2 -3
- package/es/form/pages/style/index.less +3 -1
- package/es/form/render/index.js +1 -1
- package/es/form/section/index.js +4 -4
- package/es/form/step/index.js +1 -1
- package/es/form/steps/index.js +2 -3
- package/es/{form/context.d.ts → form-context.d.ts} +1 -0
- package/es/{form/context.js → form-context.js} +0 -0
- package/es/free-form/addable-section/index.d.ts +18 -0
- package/es/free-form/addable-section/index.js +286 -0
- package/es/free-form/addable-section/style/index.d.ts +1 -0
- package/es/free-form/addable-section/style/index.js +1 -0
- package/es/free-form/addable-section/style/index.less +22 -0
- package/es/free-form/element/index.js +22 -14
- package/es/free-form/element/style/index.less +8 -2
- package/es/free-form/index.d.ts +5 -1
- package/es/free-form/index.js +8 -5
- package/es/free-form/page/index.js +8 -7
- package/es/free-form/page/style/index.less +3 -1
- package/es/free-form/pages/index.js +2 -2
- package/es/free-form/section/index.js +10 -9
- package/es/free-form/section/style/index.less +4 -0
- package/es/free-form/step/index.js +7 -6
- package/es/free-form/steps/index.js +2 -2
- package/es/global-message/index.js +1 -1
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/es/input/amount.js +2 -2
- package/es/input/credit-card.js +2 -2
- package/es/input/email.js +2 -2
- package/es/input/expiry-date.js +2 -2
- package/es/input/input-number.js +2 -2
- package/es/input/input.js +2 -2
- package/es/input/otp.js +2 -2
- package/es/input/password.js +2 -2
- package/es/input/style/index.less +9 -1
- package/es/input/text-area.js +2 -2
- package/es/layout/header.js +3 -3
- package/es/layout/index.js +2 -2
- package/es/locale/en-US/messages.json +2 -0
- package/es/locale/id-ID/messages.json +2 -0
- package/es/locale/locale-provider.js +2 -2
- package/es/locale/th-TH/messages.json +2 -0
- package/es/locale/vi-VN/messages.json +2 -0
- package/es/locale/zh-CN/messages.json +2 -0
- package/es/media/preview.js +2 -2
- package/es/mobile-insurer-detail/index.js +2 -2
- package/es/mobile-insurer-list/index.js +2 -2
- package/es/modal/index.d.ts +4 -3
- package/es/modal/index.js +6 -3
- package/es/modal/style/index.less +24 -5
- package/es/policy-list/index.js +2 -2
- package/es/policy-list/policy-card.js +2 -2
- package/es/radio/index.js +2 -2
- package/es/select/attached-select.js +2 -2
- package/es/select/select.js +2 -2
- package/es/select/style/index.less +1 -1
- package/es/status-box/index.js +2 -2
- package/es/table/index.js +3 -3
- package/es/tabs/index.js +2 -2
- package/es/tabs/style/index.less +1 -1
- package/es/types.d.ts +5 -2
- package/es/upload/index.d.ts +2 -1
- package/es/upload/index.js +121 -77
- package/es/upload-photo/index.d.ts +2 -1
- package/es/upload-photo/index.js +123 -79
- package/es/utils/form-utils.d.ts +1 -0
- package/es/utils/form-utils.js +34 -12
- package/lib/admin-upload/index.d.ts +2 -0
- package/lib/admin-upload/index.js +25 -11
- package/lib/admin-upload/job-list.js +2 -2
- package/lib/alert-message/index.js +2 -2
- package/lib/amount/index.js +2 -2
- package/lib/back-top/index.js +2 -2
- package/lib/button/index.js +2 -2
- package/lib/button/style/index.less +23 -19
- package/lib/card-detail/card-item.js +1 -1
- package/lib/card-detail/card.js +2 -2
- package/lib/card-detail/utils.js +3 -3
- package/lib/checkbox/index.js +2 -2
- package/lib/claim-list/index.js +2 -2
- package/lib/confirmation/index.js +2 -2
- package/lib/date-picker/buddhist.js +2 -2
- package/lib/date-picker/index.js +2 -2
- package/lib/declaration/index.js +2 -2
- package/lib/detail-panel/index.js +2 -2
- package/lib/example/index.js +7 -8
- package/lib/filter/index.d.ts +1 -0
- package/lib/filter/index.js +10 -6
- package/lib/form/addable-section/index.d.ts +19 -0
- package/lib/form/addable-section/index.js +232 -0
- package/lib/form/addable-section/style/index.d.ts +1 -0
- package/lib/form/addable-section/style/index.js +3 -0
- package/lib/form/addable-section/style/index.less +22 -0
- package/lib/form/divider/index.js +2 -2
- package/lib/form/element/index.js +32 -12
- package/lib/form/element/style/index.less +5 -0
- package/lib/form/elements.js +1 -1
- package/lib/form/index.js +8 -6
- package/lib/form/login/index.js +2 -2
- package/lib/form/page/index.js +2 -2
- package/lib/form/page/style/index.less +1 -1
- package/lib/form/pages/index.js +3 -4
- package/lib/form/pages/style/index.less +3 -1
- package/lib/form/render/index.js +2 -2
- package/lib/form/section/index.js +5 -5
- package/lib/form/step/index.js +2 -2
- package/lib/form/steps/index.js +3 -4
- package/lib/{form/context.d.ts → form-context.d.ts} +1 -0
- package/lib/{form/context.js → form-context.js} +0 -0
- package/lib/free-form/addable-section/index.d.ts +18 -0
- package/lib/free-form/addable-section/index.js +306 -0
- package/lib/free-form/addable-section/style/index.d.ts +1 -0
- package/lib/free-form/addable-section/style/index.js +3 -0
- package/lib/free-form/addable-section/style/index.less +22 -0
- package/lib/free-form/element/index.js +23 -15
- package/lib/free-form/element/style/index.less +8 -2
- package/lib/free-form/index.d.ts +5 -1
- package/lib/free-form/index.js +9 -6
- package/lib/free-form/page/index.js +9 -8
- package/lib/free-form/page/style/index.less +3 -1
- package/lib/free-form/pages/index.js +2 -2
- package/lib/free-form/section/index.js +11 -10
- package/lib/free-form/section/style/index.less +4 -0
- package/lib/free-form/step/index.js +8 -7
- package/lib/free-form/steps/index.js +3 -3
- package/lib/global-message/index.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +11 -2
- package/lib/input/amount.js +2 -2
- package/lib/input/credit-card.js +2 -2
- package/lib/input/email.js +2 -2
- package/lib/input/expiry-date.js +2 -2
- package/lib/input/input-number.js +2 -2
- package/lib/input/input.js +2 -2
- package/lib/input/otp.js +2 -2
- package/lib/input/password.js +2 -2
- package/lib/input/style/index.less +9 -1
- package/lib/input/text-area.js +2 -2
- package/lib/layout/header.js +3 -3
- package/lib/layout/index.js +2 -2
- package/lib/locale/en-US/messages.json +2 -0
- package/lib/locale/id-ID/messages.json +2 -0
- package/lib/locale/locale-provider.js +2 -2
- package/lib/locale/th-TH/messages.json +2 -0
- package/lib/locale/vi-VN/messages.json +2 -0
- package/lib/locale/zh-CN/messages.json +2 -0
- package/lib/media/preview.js +2 -2
- package/lib/mobile-insurer-detail/index.js +2 -2
- package/lib/mobile-insurer-list/index.js +2 -2
- package/lib/modal/index.d.ts +4 -3
- package/lib/modal/index.js +6 -3
- package/lib/modal/style/index.less +24 -5
- package/lib/policy-list/index.js +2 -2
- package/lib/policy-list/policy-card.js +2 -2
- package/lib/radio/index.js +2 -2
- package/lib/select/attached-select.js +2 -2
- package/lib/select/select.js +2 -2
- package/lib/select/style/index.less +1 -1
- package/lib/status-box/index.js +2 -2
- package/lib/table/index.js +3 -3
- package/lib/tabs/index.js +2 -2
- package/lib/tabs/style/index.less +1 -1
- package/lib/types.d.ts +5 -2
- package/lib/upload/index.d.ts +2 -1
- package/lib/upload/index.js +122 -77
- package/lib/upload-photo/index.d.ts +2 -1
- package/lib/upload-photo/index.js +124 -79
- package/lib/utils/form-utils.d.ts +1 -0
- package/lib/utils/form-utils.js +33 -12
- package/package.json +1 -1
- package/es/free-form/context.d.ts +0 -19
- package/es/free-form/context.js +0 -7
- package/lib/free-form/context.d.ts +0 -19
- 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
|
+
}
|
package/es/form/divider/index.js
CHANGED
|
@@ -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);
|
|
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]
|
|
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
|
|
package/es/form/element/index.js
CHANGED
|
@@ -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);
|
|
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]
|
|
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";
|
|
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 {
|
|
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 '
|
|
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 (
|
|
110
|
-
var 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 (
|
|
125
|
-
var 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(
|
|
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)]
|
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);
|
|
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]
|
|
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 '
|
|
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,
|
package/es/form/login/index.js
CHANGED
|
@@ -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 '
|
|
13
|
+
import FormContext from '../../form-context';
|
|
14
14
|
import { LocaleContext } from '../../locale';
|
|
15
15
|
import './style/index.less';
|
|
16
16
|
|
package/es/form/page/index.js
CHANGED
|
@@ -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 '
|
|
25
|
+
import FormContext from '../../form-context';
|
|
26
26
|
import { LocaleContext } from '../../locale';
|
|
27
27
|
import './style/index.less';
|
|
28
28
|
|
package/es/form/pages/index.js
CHANGED
|
@@ -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 '
|
|
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 {
|
package/es/form/render/index.js
CHANGED
|
@@ -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 '
|
|
3
|
+
import FormContext from '../../form-context';
|
|
4
4
|
|
|
5
5
|
var RenderElement = function RenderElement(_ref) {
|
|
6
6
|
var _ref$render = _ref.render,
|
package/es/form/section/index.js
CHANGED
|
@@ -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);
|
|
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]
|
|
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 '
|
|
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,
|
package/es/form/step/index.js
CHANGED
|
@@ -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 '
|
|
28
|
+
import FormContext from '../../form-context';
|
|
29
29
|
import './style/index.less';
|
|
30
30
|
var useBreakpoint = _Grid.useBreakpoint;
|
|
31
31
|
|
package/es/form/steps/index.js
CHANGED
|
@@ -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 '
|
|
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;
|