iglooform 2.4.8 → 2.4.12
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/float.js +25 -35
- package/es/admin-upload/index.d.ts +2 -0
- package/es/admin-upload/index.js +43 -36
- package/es/admin-upload/job-list.js +85 -115
- package/es/admin-upload/modal.js +19 -26
- package/es/alert-message/index.js +11 -9
- package/es/amount/index.js +10 -5
- package/es/back-top/index.js +14 -10
- package/es/button/index.js +23 -28
- package/es/button/style/index.less +23 -19
- package/es/card-detail/card-group.js +16 -22
- package/es/card-detail/card-item.js +16 -21
- package/es/card-detail/card-page.js +11 -15
- package/es/card-detail/card.js +24 -24
- package/es/card-detail/utils.js +6 -7
- package/es/checkbox/index.js +23 -22
- package/es/claim-list/index.js +53 -70
- package/es/confirmation/index.js +7 -9
- package/es/date-picker/buddhist.js +3 -3
- package/es/date-picker/index.js +10 -4
- package/es/declaration/index.js +16 -13
- package/es/detail-panel/index.js +67 -83
- package/es/documents/index.js +6 -8
- package/es/example/index.js +9 -11
- package/es/filter/checkBox.js +33 -45
- package/es/filter/customize.js +3 -4
- package/es/filter/index.d.ts +1 -0
- package/es/filter/index.js +88 -112
- package/es/filter/radioBox.js +23 -31
- package/es/filter/rangePicker.js +43 -59
- 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 +7 -1
- package/es/form/element/index.js +58 -47
- package/es/form/element/style/index.less +9 -0
- package/es/form/index.js +16 -17
- package/es/form/login/index.js +15 -20
- package/es/form/page/index.js +18 -24
- package/es/form/page/style/index.less +1 -1
- package/es/form/pages/index.js +23 -32
- package/es/form/pages/style/index.less +3 -1
- package/es/form/render/index.js +1 -1
- package/es/form/section/index.js +14 -17
- package/es/form/step/index.js +31 -42
- package/es/form/steps/index.js +8 -11
- 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 +43 -41
- package/es/free-form/element/style/index.less +12 -2
- package/es/free-form/index.d.ts +5 -1
- package/es/free-form/index.js +17 -17
- package/es/free-form/page/index.js +36 -46
- package/es/free-form/page/style/index.less +3 -1
- package/es/free-form/pages/index.js +8 -10
- package/es/free-form/section/index.js +20 -22
- package/es/free-form/section/style/index.less +4 -0
- package/es/free-form/step/index.js +37 -47
- package/es/free-form/steps/index.js +8 -10
- package/es/global-message/index.js +1 -1
- package/es/home-menu/index.js +52 -71
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/es/input/amount.js +10 -5
- package/es/input/credit-card.js +7 -1
- package/es/input/email.js +8 -1
- package/es/input/expiry-date.js +14 -18
- package/es/input/input-date.js +12 -16
- package/es/input/input-number.js +9 -2
- package/es/input/input.js +9 -2
- package/es/input/otp.js +17 -15
- package/es/input/password.js +12 -6
- package/es/input/phone-number.js +6 -8
- package/es/input/style/index.less +9 -1
- package/es/input/text-area.js +14 -10
- package/es/layout/defaultFooter.js +60 -82
- package/es/layout/defaultHeader.js +11 -15
- package/es/layout/footer.js +108 -148
- package/es/layout/header.js +51 -60
- package/es/layout/index.js +16 -12
- package/es/locale/en-US/messages.json +2 -0
- package/es/locale/id-ID/messages.json +2 -0
- package/es/locale/locale-provider.js +8 -10
- 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/login-page/index.js +30 -42
- package/es/media/index.js +20 -27
- package/es/media/media.js +9 -12
- package/es/media/preview.js +8 -10
- package/es/mobile-insurer-detail/index.js +74 -91
- package/es/mobile-insurer-list/index.js +34 -38
- package/es/modal/index.d.ts +4 -3
- package/es/modal/index.js +25 -27
- package/es/modal/style/index.less +24 -5
- package/es/platform/platform-card/index.js +9 -12
- package/es/platform/switch-platform/index.js +24 -32
- package/es/policy-list/index.js +11 -14
- package/es/policy-list/policy-card.js +119 -153
- package/es/radio/index.js +33 -35
- package/es/select/attached-select.js +31 -34
- package/es/select/select.js +12 -8
- package/es/select/style/index.less +1 -1
- package/es/select/time-select.js +12 -16
- package/es/status-box/index.js +8 -10
- package/es/table/index.js +72 -96
- package/es/tabs/index.js +7 -1
- package/es/types.d.ts +4 -2
- package/es/typography/index.js +6 -8
- package/es/upload/index.d.ts +2 -1
- package/es/upload/index.js +169 -143
- package/es/upload-photo/index.d.ts +2 -1
- package/es/upload-photo/index.js +170 -142
- package/es/upload-photo/media.js +3 -4
- package/es/upload-preview/index.js +9 -12
- package/es/upload-preview/media.js +12 -16
- package/es/utils/form-utils.js +49 -36
- package/lib/admin-upload/float.js +25 -35
- package/lib/admin-upload/index.d.ts +2 -0
- package/lib/admin-upload/index.js +43 -36
- package/lib/admin-upload/job-list.js +85 -115
- package/lib/admin-upload/modal.js +19 -26
- package/lib/alert-message/index.js +11 -9
- package/lib/amount/index.js +10 -5
- package/lib/back-top/index.js +14 -10
- package/lib/button/index.js +24 -29
- package/lib/button/style/index.less +23 -19
- package/lib/card-detail/card-group.js +16 -22
- package/lib/card-detail/card-item.js +16 -21
- package/lib/card-detail/card-page.js +11 -15
- package/lib/card-detail/card.js +24 -24
- package/lib/card-detail/index.js +6 -6
- package/lib/card-detail/utils.js +7 -8
- package/lib/checkbox/index.js +24 -23
- package/lib/claim-list/index.js +53 -70
- package/lib/confirmation/index.js +7 -9
- package/lib/date-picker/buddhist.js +3 -3
- package/lib/date-picker/index.js +11 -5
- package/lib/declaration/index.js +16 -13
- package/lib/detail-panel/index.js +67 -83
- package/lib/documents/index.js +6 -8
- package/lib/example/index.js +10 -12
- package/lib/filter/checkBox.js +33 -45
- package/lib/filter/customize.js +3 -4
- package/lib/filter/index.d.ts +1 -0
- package/lib/filter/index.js +88 -112
- package/lib/filter/radioBox.js +23 -31
- package/lib/filter/rangePicker.js +43 -59
- 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 +7 -1
- package/lib/form/element/index.js +60 -48
- package/lib/form/element/style/index.less +9 -0
- package/lib/form/elements.js +1 -1
- package/lib/form/index.js +16 -17
- package/lib/form/login/index.js +16 -21
- package/lib/form/page/index.js +19 -25
- package/lib/form/page/style/index.less +1 -1
- package/lib/form/pages/index.js +24 -33
- package/lib/form/pages/style/index.less +3 -1
- package/lib/form/render/index.js +2 -2
- package/lib/form/section/index.js +15 -18
- package/lib/form/step/index.js +32 -43
- package/lib/form/steps/index.js +9 -12
- 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 +44 -42
- package/lib/free-form/element/style/index.less +12 -2
- package/lib/free-form/index.d.ts +5 -1
- package/lib/free-form/index.js +17 -17
- package/lib/free-form/page/index.js +37 -47
- package/lib/free-form/page/style/index.less +3 -1
- package/lib/free-form/pages/index.js +8 -10
- package/lib/free-form/section/index.js +21 -23
- package/lib/free-form/section/style/index.less +4 -0
- package/lib/free-form/step/index.js +38 -48
- package/lib/free-form/steps/index.js +9 -11
- package/lib/global-message/index.js +1 -1
- package/lib/home-menu/index.js +52 -71
- package/lib/index.d.ts +1 -0
- package/lib/index.js +141 -132
- package/lib/input/amount.js +10 -5
- package/lib/input/credit-card.js +7 -1
- package/lib/input/email.js +7 -1
- package/lib/input/expiry-date.js +14 -18
- package/lib/input/index.js +18 -18
- package/lib/input/input-date.js +12 -16
- package/lib/input/input-number.js +8 -2
- package/lib/input/input.js +8 -2
- package/lib/input/otp.js +17 -15
- package/lib/input/password.js +11 -6
- package/lib/input/phone-number.js +6 -8
- package/lib/input/style/index.less +9 -1
- package/lib/input/text-area.js +14 -10
- package/lib/layout/defaultFooter.js +60 -82
- package/lib/layout/defaultHeader.js +11 -15
- package/lib/layout/footer.js +108 -148
- package/lib/layout/header.js +51 -60
- package/lib/layout/index.js +15 -12
- package/lib/locale/en-US/messages.json +2 -0
- package/lib/locale/format-message.js +1 -1
- package/lib/locale/id-ID/messages.json +2 -0
- package/lib/locale/index.js +4 -4
- package/lib/locale/locale-provider.js +9 -11
- 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/login-page/index.js +30 -42
- package/lib/media/index.js +20 -27
- package/lib/media/media.js +9 -12
- package/lib/media/preview.js +8 -10
- package/lib/mobile-insurer-detail/index.js +74 -91
- package/lib/mobile-insurer-list/index.js +34 -38
- package/lib/modal/index.d.ts +4 -3
- package/lib/modal/index.js +25 -27
- package/lib/modal/style/index.less +24 -5
- package/lib/platform/platform-card/index.js +9 -12
- package/lib/platform/switch-platform/index.js +24 -32
- package/lib/policy-list/index.js +11 -14
- package/lib/policy-list/policy-card.js +119 -153
- package/lib/radio/index.js +33 -35
- package/lib/select/attached-select.js +32 -35
- package/lib/select/select.js +13 -9
- package/lib/select/style/index.less +1 -1
- package/lib/select/time-select.js +12 -16
- package/lib/status-box/index.js +8 -10
- package/lib/table/index.js +72 -96
- package/lib/tabs/index.js +8 -2
- package/lib/types.d.ts +4 -2
- package/lib/typography/index.js +6 -8
- package/lib/upload/index.d.ts +2 -1
- package/lib/upload/index.js +170 -143
- package/lib/upload-photo/index.d.ts +2 -1
- package/lib/upload-photo/index.js +171 -142
- package/lib/upload-photo/media.js +3 -4
- package/lib/upload-preview/index.js +9 -12
- package/lib/upload-preview/media.js +12 -16
- package/lib/utils/form-utils.js +49 -37
- 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
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';
|
|
@@ -65,24 +65,21 @@ var Section = function Section(_ref) {
|
|
|
65
65
|
}]);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
return display ? _jsxs(_Col,
|
|
68
|
+
return display ? _jsxs(_Col, {
|
|
69
69
|
span: 24,
|
|
70
70
|
className: 'igloo-section',
|
|
71
|
-
style: style
|
|
72
|
-
|
|
73
|
-
children: [label && _jsx(Typography, Object.assign({
|
|
71
|
+
style: style,
|
|
72
|
+
children: [label && _jsx(Typography, _objectSpread(_objectSpread({
|
|
74
73
|
className: 'igloo-section-label'
|
|
75
|
-
}, labelProps, {
|
|
74
|
+
}, labelProps), {}, {
|
|
76
75
|
level: "h4",
|
|
77
|
-
wrapElement: "div"
|
|
78
|
-
}, {
|
|
76
|
+
wrapElement: "div",
|
|
79
77
|
children: label
|
|
80
|
-
}), void 0), _jsx("div",
|
|
78
|
+
}), void 0), _jsx("div", _objectSpread(_objectSpread({
|
|
81
79
|
className: 'igloo-section-content'
|
|
82
|
-
}, contentProps, {
|
|
83
|
-
children: _jsx(_Row,
|
|
84
|
-
gutter: [32, 24]
|
|
85
|
-
}, {
|
|
80
|
+
}, contentProps), {}, {
|
|
81
|
+
children: _jsx(_Row, {
|
|
82
|
+
gutter: [32, preview ? 16 : 24],
|
|
86
83
|
children: elements.map(function (child, index) {
|
|
87
84
|
return _jsx(Element, {
|
|
88
85
|
parentName: namePath,
|
|
@@ -92,9 +89,9 @@ var Section = function Section(_ref) {
|
|
|
92
89
|
setShowStepButton: setShowStepButton
|
|
93
90
|
}, index);
|
|
94
91
|
})
|
|
95
|
-
}
|
|
92
|
+
}, void 0)
|
|
96
93
|
}), void 0)]
|
|
97
|
-
}
|
|
94
|
+
}, void 0) : null;
|
|
98
95
|
};
|
|
99
96
|
|
|
100
97
|
export default Section;
|
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
|
|
|
@@ -90,26 +90,21 @@ var Step = function Step(_ref) {
|
|
|
90
90
|
}) : containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.scrollIntoView();
|
|
91
91
|
}, [shouldScroll, edit]);
|
|
92
92
|
var displayTotal = showLastIndex ? total : total - 1;
|
|
93
|
-
return _jsxs("div",
|
|
93
|
+
return _jsxs("div", {
|
|
94
94
|
className: 'igloo-step-container',
|
|
95
|
-
ref: containerRef
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
className: "igloo-step-label"
|
|
99
|
-
}, {
|
|
95
|
+
ref: containerRef,
|
|
96
|
+
children: [label && _jsxs("div", {
|
|
97
|
+
className: "igloo-step-label",
|
|
100
98
|
children: [_jsxs("div", {
|
|
101
|
-
children: [(index !== total - 1 || showLastIndex) && _jsx("span",
|
|
102
|
-
className: "igloo-step-label-index"
|
|
103
|
-
}, {
|
|
99
|
+
children: [(index !== total - 1 || showLastIndex) && _jsx("span", {
|
|
100
|
+
className: "igloo-step-label-index",
|
|
104
101
|
children: specialDisplayIndex(index + 1)
|
|
105
|
-
}
|
|
106
|
-
className: "igloo-step-label-text"
|
|
107
|
-
}, {
|
|
102
|
+
}, void 0), _jsx("span", {
|
|
103
|
+
className: "igloo-step-label-text",
|
|
108
104
|
children: label
|
|
109
|
-
}
|
|
110
|
-
}, void 0), !preview && (index !== total - 1 || showLastIndex) && _jsx("div",
|
|
111
|
-
className: "igloo-step-label-step-count"
|
|
112
|
-
}, {
|
|
105
|
+
}, void 0)]
|
|
106
|
+
}, void 0), !preview && (index !== total - 1 || showLastIndex) && _jsx("div", {
|
|
107
|
+
className: "igloo-step-label-step-count",
|
|
113
108
|
children: formatMessage({
|
|
114
109
|
id: "{currentStep} of {allSteps}",
|
|
115
110
|
values: {
|
|
@@ -117,22 +112,19 @@ var Step = function Step(_ref) {
|
|
|
117
112
|
allSteps: displayTotal
|
|
118
113
|
}
|
|
119
114
|
})
|
|
120
|
-
}
|
|
115
|
+
}, void 0), preview && _jsx(Button, {
|
|
121
116
|
type: "link",
|
|
122
117
|
className: "igloo-step-label-edit",
|
|
123
118
|
onClick: handleEdit,
|
|
124
|
-
disabled: disableEditButton
|
|
125
|
-
}, {
|
|
119
|
+
disabled: disableEditButton,
|
|
126
120
|
children: editButtonLabel || formatMessage({
|
|
127
121
|
id: 'Edit'
|
|
128
122
|
})
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
className: 'igloo-step-content'
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
gutter: [32, preview ? 16 : 24]
|
|
135
|
-
}, {
|
|
123
|
+
}, void 0)]
|
|
124
|
+
}, void 0), (edit || preview) && _jsxs("div", {
|
|
125
|
+
className: 'igloo-step-content',
|
|
126
|
+
children: [_jsx(_Row, {
|
|
127
|
+
gutter: [32, preview ? 16 : 24],
|
|
136
128
|
children: elements.map(function (child, index) {
|
|
137
129
|
return _jsx(Element, {
|
|
138
130
|
config: child,
|
|
@@ -141,38 +133,35 @@ var Step = function Step(_ref) {
|
|
|
141
133
|
preview: preview
|
|
142
134
|
}, index);
|
|
143
135
|
})
|
|
144
|
-
}
|
|
145
|
-
children: _jsx(Button,
|
|
136
|
+
}, void 0), edit && index !== total - 1 && showButton && _jsx(_Row, {
|
|
137
|
+
children: _jsx(Button, {
|
|
146
138
|
onClick: handleNext,
|
|
147
139
|
className: 'igloo-step-button',
|
|
148
140
|
type: "primary",
|
|
149
|
-
disabled: buttonDisabled
|
|
150
|
-
}, {
|
|
141
|
+
disabled: buttonDisabled,
|
|
151
142
|
children: continueText || formatMessage({
|
|
152
143
|
id: 'Continue'
|
|
153
144
|
})
|
|
154
|
-
}
|
|
155
|
-
}, void 0), edit && index === total - 1 && showButton && showSubmitButton && _jsx(_Form.Item,
|
|
145
|
+
}, void 0)
|
|
146
|
+
}, void 0), edit && index === total - 1 && showButton && showSubmitButton && _jsx(_Form.Item, {
|
|
156
147
|
style: {
|
|
157
148
|
marginBottom: 0
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
children: _jsx(Button, Object.assign({
|
|
149
|
+
},
|
|
150
|
+
children: _jsx(Button, {
|
|
161
151
|
type: "primary",
|
|
162
152
|
htmlType: "submit",
|
|
163
153
|
className: 'igloo-step-button',
|
|
164
154
|
loading: submitting,
|
|
165
|
-
disabled: buttonDisabled
|
|
166
|
-
}, {
|
|
155
|
+
disabled: buttonDisabled,
|
|
167
156
|
children: submitText || formatMessage({
|
|
168
157
|
id: 'Submit'
|
|
169
158
|
})
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
159
|
+
}, void 0)
|
|
160
|
+
}, void 0)]
|
|
161
|
+
}, void 0), !edit && !preview && _jsx(_Divider, {
|
|
173
162
|
className: "igloo-step-divider"
|
|
174
163
|
}, void 0)]
|
|
175
|
-
}
|
|
164
|
+
}, void 0);
|
|
176
165
|
};
|
|
177
166
|
|
|
178
167
|
export default Step;
|
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
|
|
|
@@ -169,12 +168,10 @@ var Steps = function Steps(_ref) {
|
|
|
169
168
|
typeof onEdit === 'function' && onEdit(index);
|
|
170
169
|
};
|
|
171
170
|
|
|
172
|
-
return _jsx("div",
|
|
173
|
-
className: 'igloo-steps-container'
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
className: 'igloo-steps-content'
|
|
177
|
-
}, {
|
|
171
|
+
return _jsx("div", {
|
|
172
|
+
className: 'igloo-steps-container',
|
|
173
|
+
children: _jsx("div", {
|
|
174
|
+
className: 'igloo-steps-content',
|
|
178
175
|
children: renderElements.map(function (child, index) {
|
|
179
176
|
invariant(child.type === 'Step', 'Child of steps should be Step');
|
|
180
177
|
return _jsx(Step, {
|
|
@@ -188,10 +185,10 @@ var Steps = function Steps(_ref) {
|
|
|
188
185
|
handleEdit: handleEdit,
|
|
189
186
|
showLastIndex: showLastIndex,
|
|
190
187
|
shouldScroll: shouldScroll
|
|
191
|
-
}, child.key);
|
|
188
|
+
}, child.key || child.name);
|
|
192
189
|
})
|
|
193
|
-
}
|
|
194
|
-
}
|
|
190
|
+
}, void 0)
|
|
191
|
+
}, void 0);
|
|
195
192
|
};
|
|
196
193
|
|
|
197
194
|
export default Steps;
|
|
@@ -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;
|
|
@@ -0,0 +1,286 @@
|
|
|
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 _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); }
|
|
13
|
+
|
|
14
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
15
|
+
|
|
16
|
+
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."); }
|
|
17
|
+
|
|
18
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
19
|
+
|
|
20
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
21
|
+
|
|
22
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
23
|
+
|
|
24
|
+
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."); }
|
|
25
|
+
|
|
26
|
+
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); }
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
30
|
+
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; }
|
|
31
|
+
|
|
32
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
33
|
+
|
|
34
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
35
|
+
import { useReducer, useContext, useEffect, useCallback, cloneElement, isValidElement } from 'react';
|
|
36
|
+
import FormContext from '../../form-context';
|
|
37
|
+
import { calcNamePath, calcFormItemProps } from '../../utils/form-utils';
|
|
38
|
+
import Typography from '../../typography';
|
|
39
|
+
import Button from '../../button';
|
|
40
|
+
import { LocaleContext } from '../../locale';
|
|
41
|
+
import './style/index.less';
|
|
42
|
+
|
|
43
|
+
var AddableSection = function AddableSection(props) {
|
|
44
|
+
var name = props.name,
|
|
45
|
+
_props$label = props.label,
|
|
46
|
+
label = _props$label === void 0 ? '' : _props$label,
|
|
47
|
+
_props$labelProps = props.labelProps,
|
|
48
|
+
labelProps = _props$labelProps === void 0 ? {} : _props$labelProps,
|
|
49
|
+
_props$contentProps = props.contentProps,
|
|
50
|
+
contentProps = _props$contentProps === void 0 ? {} : _props$contentProps,
|
|
51
|
+
_props$max = props.max,
|
|
52
|
+
max = _props$max === void 0 ? Number.MAX_SAFE_INTEGER : _props$max,
|
|
53
|
+
_props$initCount = props.initCount,
|
|
54
|
+
initCount = _props$initCount === void 0 ? 1 : _props$initCount,
|
|
55
|
+
_props$min = props.min,
|
|
56
|
+
min = _props$min === void 0 ? initCount : _props$min,
|
|
57
|
+
parentName = props.parentName,
|
|
58
|
+
preview = props.preview,
|
|
59
|
+
disabledFromParent = props.disabledFromParent,
|
|
60
|
+
setShowStepButton = props.setShowStepButton,
|
|
61
|
+
addButtonText = props.addButtonText,
|
|
62
|
+
addButtonIcon = props.addButtonIcon,
|
|
63
|
+
children = props.children;
|
|
64
|
+
|
|
65
|
+
var _useReducer = useReducer(function (r) {
|
|
66
|
+
return r + 1;
|
|
67
|
+
}, 0),
|
|
68
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
69
|
+
_ = _useReducer2[0],
|
|
70
|
+
dispatch = _useReducer2[1];
|
|
71
|
+
|
|
72
|
+
var _useContext = useContext(LocaleContext),
|
|
73
|
+
formatMessage = _useContext.formatMessage;
|
|
74
|
+
|
|
75
|
+
var _useContext2 = useContext(FormContext),
|
|
76
|
+
form = _useContext2.form,
|
|
77
|
+
requiredMark = _useContext2.requiredMark,
|
|
78
|
+
registerDependencies = _useContext2.registerDependencies;
|
|
79
|
+
|
|
80
|
+
var namePath = calcNamePath(parentName, name);
|
|
81
|
+
var reducer = useCallback(function (state, action) {
|
|
82
|
+
if (action.type === 'add') {
|
|
83
|
+
return [].concat(_toConsumableArray(state), [action.key]);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var found = false;
|
|
87
|
+
return state.filter(function (key, index) {
|
|
88
|
+
if (key === action.key) {
|
|
89
|
+
found = true;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (found) {
|
|
93
|
+
if (index === state.length - 1) {
|
|
94
|
+
form === null || form === void 0 ? void 0 : form.setFields([{
|
|
95
|
+
name: calcNamePath(namePath, index),
|
|
96
|
+
value: undefined
|
|
97
|
+
}]);
|
|
98
|
+
} else {
|
|
99
|
+
form === null || form === void 0 ? void 0 : form.setFields([{
|
|
100
|
+
name: calcNamePath(namePath, index),
|
|
101
|
+
value: form.getFieldValue(calcNamePath(namePath, index + 1))
|
|
102
|
+
}]);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return key !== action.key;
|
|
107
|
+
});
|
|
108
|
+
}, []);
|
|
109
|
+
|
|
110
|
+
var _useReducer3 = useReducer(reducer, function () {
|
|
111
|
+
var init = [];
|
|
112
|
+
var value = (form === null || form === void 0 ? void 0 : form.getFieldValue(namePath)) || [];
|
|
113
|
+
|
|
114
|
+
for (var i = 0; i < Math.max(min, value.length, initCount); i++) {
|
|
115
|
+
init.push(Date.now() + Math.random());
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return init;
|
|
119
|
+
}()),
|
|
120
|
+
_useReducer4 = _slicedToArray(_useReducer3, 2),
|
|
121
|
+
groupKeys = _useReducer4[0],
|
|
122
|
+
dispath = _useReducer4[1];
|
|
123
|
+
|
|
124
|
+
useEffect(function () {
|
|
125
|
+
var dependencies = props.dependencies,
|
|
126
|
+
asserts = props.asserts,
|
|
127
|
+
copyValue = props.copyValue,
|
|
128
|
+
selectValue = props.selectValue,
|
|
129
|
+
shouldRender = props.shouldRender,
|
|
130
|
+
subscribedFields = props.subscribedFields,
|
|
131
|
+
disabled = props.disabled;
|
|
132
|
+
var dependentField = dependencies || [];
|
|
133
|
+
|
|
134
|
+
if (Array.isArray(subscribedFields)) {
|
|
135
|
+
dependentField.push.apply(dependentField, _toConsumableArray(subscribedFields));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (asserts && asserts.length) {
|
|
139
|
+
asserts.forEach(function (_ref) {
|
|
140
|
+
var field = _ref.field;
|
|
141
|
+
return dependentField.push(field);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (copyValue) {
|
|
146
|
+
dependentField.push(copyValue.assert.field);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (selectValue && selectValue.length) {
|
|
150
|
+
selectValue.forEach(function (_ref2) {
|
|
151
|
+
var assert = _ref2.assert;
|
|
152
|
+
return dependentField.push(assert.field);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (shouldRender && !Array.isArray(subscribedFields)) {
|
|
157
|
+
dependentField.push('SUBSCRIBE_ALL');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (Array.isArray(disabled)) {
|
|
161
|
+
disabled.forEach(function (_ref3) {
|
|
162
|
+
var field = _ref3.field;
|
|
163
|
+
return dependentField.push(field);
|
|
164
|
+
});
|
|
165
|
+
} else if (_typeof(disabled) === 'object') {
|
|
166
|
+
dependentField.push(disabled.field);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
registerDependencies(dependentField, dispatch);
|
|
170
|
+
}, []);
|
|
171
|
+
|
|
172
|
+
var _calcFormItemProps = calcFormItemProps(props, {
|
|
173
|
+
requiredMark: requiredMark
|
|
174
|
+
}, form, parentName),
|
|
175
|
+
formItemProps = _calcFormItemProps.formItemProps,
|
|
176
|
+
elementProps = _calcFormItemProps.elementProps,
|
|
177
|
+
display = _calcFormItemProps.display;
|
|
178
|
+
|
|
179
|
+
if (formItemProps.copiedValue.copied) {
|
|
180
|
+
var currentValue = form === null || form === void 0 ? void 0 : form.getFieldValue(namePath);
|
|
181
|
+
|
|
182
|
+
var value = _objectSpread(_objectSpread({}, currentValue), formItemProps.copiedValue.value);
|
|
183
|
+
|
|
184
|
+
form === null || form === void 0 ? void 0 : form.setFields([{
|
|
185
|
+
name: namePath,
|
|
186
|
+
value: value,
|
|
187
|
+
errors: []
|
|
188
|
+
}]);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
var transformChildren = function transformChildren(parentName) {
|
|
192
|
+
if (Array.isArray(children)) {
|
|
193
|
+
return children.map(function (c, index) {
|
|
194
|
+
var _c$type;
|
|
195
|
+
|
|
196
|
+
if (['Igloo_Free_Form_Item', 'Igloo_Free_Form_Section', 'Igloo_Free_Form_AddabledSection'].includes(c === null || c === void 0 ? void 0 : (_c$type = c.type) === null || _c$type === void 0 ? void 0 : _c$type.displayName)) {
|
|
197
|
+
return /*#__PURE__*/cloneElement(c, _objectSpread(_objectSpread({
|
|
198
|
+
key: index
|
|
199
|
+
}, c.props), {}, {
|
|
200
|
+
parentName: parentName,
|
|
201
|
+
setShowStepButton: setShowStepButton,
|
|
202
|
+
preview: preview,
|
|
203
|
+
disabledFromParent: elementProps.disabled || disabledFromParent
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return c;
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return /*#__PURE__*/isValidElement(children) ? /*#__PURE__*/cloneElement(children, _objectSpread(_objectSpread({}, children.props), {}, {
|
|
212
|
+
parentName: parentName,
|
|
213
|
+
setShowStepButton: setShowStepButton,
|
|
214
|
+
preview: preview,
|
|
215
|
+
disabledFromParent: elementProps.disabled
|
|
216
|
+
})) : children;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
if (!display) {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
var groups = groupKeys.map(function (key, index) {
|
|
224
|
+
var parentName = calcNamePath(namePath, index);
|
|
225
|
+
return _jsxs(_Col, {
|
|
226
|
+
span: 24,
|
|
227
|
+
className: 'igloo-addable-section',
|
|
228
|
+
children: [(groupKeys.length > min && !preview || label) && _jsxs(_Row, {
|
|
229
|
+
justify: "space-between",
|
|
230
|
+
className: 'igloo-addable-section-label',
|
|
231
|
+
children: [label ? _jsxs(Typography, _objectSpread(_objectSpread({}, labelProps), {}, {
|
|
232
|
+
level: "h4",
|
|
233
|
+
wrapElement: "div",
|
|
234
|
+
children: [label, " ", index + 1]
|
|
235
|
+
}), void 0) : _jsx("div", {}, void 0), groupKeys.length > min && !preview && _jsx(Button, {
|
|
236
|
+
type: "link",
|
|
237
|
+
className: "igloo-addable-section-label-remove",
|
|
238
|
+
onClick: function onClick() {
|
|
239
|
+
return dispath({
|
|
240
|
+
type: 'remove',
|
|
241
|
+
key: key
|
|
242
|
+
});
|
|
243
|
+
},
|
|
244
|
+
children: formatMessage({
|
|
245
|
+
id: 'Remove'
|
|
246
|
+
})
|
|
247
|
+
}, void 0)]
|
|
248
|
+
}, void 0), _jsx("div", _objectSpread(_objectSpread({
|
|
249
|
+
className: 'igloo-addable-section-content'
|
|
250
|
+
}, contentProps), {}, {
|
|
251
|
+
children: _jsx(_Row, {
|
|
252
|
+
gutter: [32, preview ? 16 : 24],
|
|
253
|
+
children: transformChildren(parentName)
|
|
254
|
+
}, void 0)
|
|
255
|
+
}), void 0)]
|
|
256
|
+
}, key);
|
|
257
|
+
});
|
|
258
|
+
return _jsxs("div", {
|
|
259
|
+
className: "igloo-addable-section-container",
|
|
260
|
+
style: {
|
|
261
|
+
width: '100%'
|
|
262
|
+
},
|
|
263
|
+
children: [groups, groupKeys.length < max && !preview && _jsx(_Col, {
|
|
264
|
+
span: 24,
|
|
265
|
+
style: {
|
|
266
|
+
marginTop: 16
|
|
267
|
+
},
|
|
268
|
+
children: _jsx(Button, {
|
|
269
|
+
onClick: function onClick() {
|
|
270
|
+
return dispath({
|
|
271
|
+
type: 'add',
|
|
272
|
+
key: Date.now()
|
|
273
|
+
});
|
|
274
|
+
},
|
|
275
|
+
className: "igloo-addable-section-button",
|
|
276
|
+
icon: addButtonIcon,
|
|
277
|
+
children: addButtonText || "".concat(formatMessage({
|
|
278
|
+
id: 'Add'
|
|
279
|
+
}), " ").concat(label)
|
|
280
|
+
}, void 0)
|
|
281
|
+
}, void 0)]
|
|
282
|
+
}, void 0);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
export default AddableSection;
|
|
286
|
+
AddableSection.displayName = 'Igloo_Free_Form_AddableSection';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.less';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.less';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.igloo-addable-section-container {
|
|
2
|
+
.igloo-addable-section {
|
|
3
|
+
.igloo-addable-section-label {
|
|
4
|
+
.igloo-addable-section-label-remove {
|
|
5
|
+
height: auto;
|
|
6
|
+
border: none;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.igloo-addable-section-content {
|
|
11
|
+
margin-top: 16px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
& + .igloo-addable-section {
|
|
15
|
+
margin-top: 24px;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.igloo-addable-section-button {
|
|
20
|
+
min-width: 221px;
|
|
21
|
+
}
|
|
22
|
+
}
|