iglooform 2.5.6 → 2.5.9
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/confirmation/index.d.ts +2 -2
- package/es/confirmation/index.js +37 -2
- package/es/filter/checkBox.d.ts +4 -3
- package/es/filter/checkBox.js +31 -7
- package/es/filter/index.js +4 -2
- package/es/filter/radioBox.d.ts +2 -1
- package/es/filter/radioBox.js +24 -3
- package/es/form/element/index.js +22 -21
- package/es/form/hstep/index.d.ts +17 -0
- package/es/form/hstep/index.js +158 -0
- package/es/form/hstep/style/index.d.ts +1 -0
- package/es/form/hstep/style/index.js +1 -0
- package/es/form/hstep/style/index.less +84 -0
- package/es/form/hsteps/index.d.ts +19 -0
- package/es/form/hsteps/index.js +407 -0
- package/es/form/hsteps/style/index.d.ts +1 -0
- package/es/form/hsteps/style/index.js +1 -0
- package/es/form/hsteps/style/index.less +78 -0
- package/es/form/index.js +31 -40
- package/es/form/pages/index.js +2 -2
- package/es/form/section/index.d.ts +2 -0
- package/es/form/section/index.js +70 -10
- package/es/form/section/style/index.less +14 -0
- package/es/form/step/index.js +15 -10
- package/es/form/steps/index.js +27 -15
- package/es/form-step-context.d.ts +6 -0
- package/es/form-step-context.js +4 -0
- package/es/free-form/index.js +24 -38
- package/es/input/input-number.js +2 -2
- package/es/locale/en-US/messages.json +9 -0
- package/es/locale/id-ID/messages.json +9 -0
- package/es/locale/th-TH/messages.json +9 -0
- package/es/locale/vi-VN/messages.json +9 -0
- package/es/locale/zh-CN/messages.json +9 -0
- package/es/locale/zh-TW/messages.json +9 -0
- package/es/select/style/index.less +1 -0
- package/es/types.d.ts +13 -1
- package/es/upload-photo/index.js +10 -4
- package/es/utils/form-utils.js +84 -1
- package/lib/confirmation/index.d.ts +2 -2
- package/lib/confirmation/index.js +37 -1
- package/lib/filter/checkBox.d.ts +4 -3
- package/lib/filter/checkBox.js +31 -7
- package/lib/filter/index.js +4 -2
- package/lib/filter/radioBox.d.ts +2 -1
- package/lib/filter/radioBox.js +24 -3
- package/lib/form/element/index.js +22 -21
- package/lib/form/hstep/index.d.ts +17 -0
- package/lib/form/hstep/index.js +183 -0
- package/lib/form/hstep/style/index.d.ts +1 -0
- package/lib/form/hstep/style/index.js +3 -0
- package/lib/form/hstep/style/index.less +84 -0
- package/lib/form/hsteps/index.d.ts +19 -0
- package/lib/form/hsteps/index.js +437 -0
- package/lib/form/hsteps/style/index.d.ts +1 -0
- package/lib/form/hsteps/style/index.js +3 -0
- package/lib/form/hsteps/style/index.less +78 -0
- package/lib/form/index.js +31 -39
- package/lib/form/pages/index.js +2 -2
- package/lib/form/section/index.d.ts +2 -0
- package/lib/form/section/index.js +72 -8
- package/lib/form/section/style/index.less +14 -0
- package/lib/form/step/index.js +15 -10
- package/lib/form/steps/index.js +27 -14
- package/lib/form-step-context.d.ts +6 -0
- package/lib/form-step-context.js +16 -0
- package/lib/free-form/index.js +23 -37
- package/lib/input/input-number.js +2 -2
- package/lib/locale/en-US/messages.json +9 -0
- package/lib/locale/id-ID/messages.json +9 -0
- package/lib/locale/th-TH/messages.json +9 -0
- package/lib/locale/vi-VN/messages.json +9 -0
- package/lib/locale/zh-CN/messages.json +9 -0
- package/lib/locale/zh-TW/messages.json +9 -0
- package/lib/select/style/index.less +1 -0
- package/lib/types.d.ts +13 -1
- package/lib/upload-photo/index.js +10 -4
- package/lib/utils/form-utils.js +85 -1
- package/package.json +1 -1
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import "antd/es/form/style";
|
|
2
|
+
import _Form from "antd/es/form";
|
|
3
|
+
import "antd/es/divider/style";
|
|
4
|
+
import _Divider from "antd/es/divider";
|
|
5
|
+
import "antd/es/grid/style";
|
|
6
|
+
import _Grid from "antd/es/grid";
|
|
7
|
+
|
|
8
|
+
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; }
|
|
9
|
+
|
|
10
|
+
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; }
|
|
11
|
+
|
|
12
|
+
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; }
|
|
13
|
+
|
|
14
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
15
|
+
|
|
16
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
17
|
+
|
|
18
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
19
|
+
|
|
20
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
21
|
+
|
|
22
|
+
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."); }
|
|
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 _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; }
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
30
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
31
|
+
|
|
32
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
33
|
+
import { useState, useContext, useEffect, useReducer, useRef } from 'react';
|
|
34
|
+
import HStep from '../hstep';
|
|
35
|
+
import { calcNamePath } from '../../utils/form-utils';
|
|
36
|
+
import FormContext from '../../form-context';
|
|
37
|
+
import StepContext from '../../form-step-context';
|
|
38
|
+
import './style/index.less';
|
|
39
|
+
import invariant from 'invariant';
|
|
40
|
+
import Confirmation from '../../confirmation';
|
|
41
|
+
import { LocaleContext } from '../../locale';
|
|
42
|
+
import Typography from '../../typography';
|
|
43
|
+
import Button from '../../button';
|
|
44
|
+
import Radio from '../../radio';
|
|
45
|
+
import { SuccessFilled } from 'iglooicon';
|
|
46
|
+
import classNames from 'classnames';
|
|
47
|
+
var useBreakpoint = _Grid.useBreakpoint;
|
|
48
|
+
|
|
49
|
+
var HSteps = function HSteps(_ref) {
|
|
50
|
+
var _renderElements$curre2, _renderElements$curre3;
|
|
51
|
+
|
|
52
|
+
var parentName = _ref.parentName,
|
|
53
|
+
_ref$config = _ref.config,
|
|
54
|
+
_ref$config$elements = _ref$config.elements,
|
|
55
|
+
elements = _ref$config$elements === void 0 ? [] : _ref$config$elements,
|
|
56
|
+
_ref$config$currentSt = _ref$config.currentStep,
|
|
57
|
+
currentStep = _ref$config$currentSt === void 0 ? 0 : _ref$config$currentSt,
|
|
58
|
+
subscribedFields = _ref$config.subscribedFields,
|
|
59
|
+
onEdit = _ref$config.onEdit,
|
|
60
|
+
confirmations = _ref$config.confirmations,
|
|
61
|
+
_ref$config$withRevie = _ref$config.withReview,
|
|
62
|
+
withReview = _ref$config$withRevie === void 0 ? true : _ref$config$withRevie,
|
|
63
|
+
name = _ref$config.name;
|
|
64
|
+
|
|
65
|
+
var _useState = useState(0),
|
|
66
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
67
|
+
current = _useState2[0],
|
|
68
|
+
setCurrent = _useState2[1];
|
|
69
|
+
|
|
70
|
+
var _useState3 = useState(0),
|
|
71
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
72
|
+
last = _useState4[0],
|
|
73
|
+
setLast = _useState4[1];
|
|
74
|
+
|
|
75
|
+
var _useState5 = useState(false),
|
|
76
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
77
|
+
shouldScroll = _useState6[0],
|
|
78
|
+
setShouldScroll = _useState6[1];
|
|
79
|
+
|
|
80
|
+
var _useReducer = useReducer(function (r) {
|
|
81
|
+
return r + 1;
|
|
82
|
+
}, 0),
|
|
83
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
84
|
+
_ = _useReducer2[0],
|
|
85
|
+
dispatch = _useReducer2[1];
|
|
86
|
+
|
|
87
|
+
var _useBreakpoint = useBreakpoint(),
|
|
88
|
+
md = _useBreakpoint.md;
|
|
89
|
+
|
|
90
|
+
var sections = useRef(new Map());
|
|
91
|
+
|
|
92
|
+
var _useContext = useContext(FormContext),
|
|
93
|
+
form = _useContext.form,
|
|
94
|
+
registerDependencies = _useContext.registerDependencies,
|
|
95
|
+
submitText = _useContext.submitText,
|
|
96
|
+
submitting = _useContext.submitting,
|
|
97
|
+
showSubmitButton = _useContext.showSubmitButton;
|
|
98
|
+
|
|
99
|
+
var _useContext2 = useContext(LocaleContext),
|
|
100
|
+
formatMessage = _useContext2.formatMessage;
|
|
101
|
+
|
|
102
|
+
useEffect(function () {
|
|
103
|
+
var subscribe = elements.some(function (_ref2) {
|
|
104
|
+
var shouldRender = _ref2.shouldRender,
|
|
105
|
+
getButtonDisabledState = _ref2.getButtonDisabledState;
|
|
106
|
+
return Boolean(shouldRender) || Boolean(getButtonDisabledState);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
if (subscribe) {
|
|
110
|
+
Array.isArray(subscribedFields) ? registerDependencies(subscribedFields, dispatch) : registerDependencies('SUBSCRIBE_ALL', dispatch);
|
|
111
|
+
}
|
|
112
|
+
}, []);
|
|
113
|
+
useEffect(function () {
|
|
114
|
+
if (currentStep === undefined || currentStep === current) return;
|
|
115
|
+
setCurrent(currentStep);
|
|
116
|
+
}, [currentStep]);
|
|
117
|
+
var renderElements = elements.filter(function (step) {
|
|
118
|
+
invariant(step.type === 'Step', 'Child of steps should be Step');
|
|
119
|
+
return typeof step.shouldRender !== 'function' || step.shouldRender(form);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
var handleNext = /*#__PURE__*/function () {
|
|
123
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
124
|
+
var _allFields$filter;
|
|
125
|
+
|
|
126
|
+
var allFields, _renderElements$curre, currentName, handleNext, namePath, fields, _iterator, _step, collapseSection, errors;
|
|
127
|
+
|
|
128
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
129
|
+
while (1) {
|
|
130
|
+
switch (_context.prev = _context.next) {
|
|
131
|
+
case 0:
|
|
132
|
+
allFields = (form === null || form === void 0 ? void 0 : form.getFieldsError()) || [];
|
|
133
|
+
_renderElements$curre = renderElements[current], currentName = _renderElements$curre.name, handleNext = _renderElements$curre.handleNext;
|
|
134
|
+
namePath = calcNamePath(name, currentName);
|
|
135
|
+
fields = allFields === null || allFields === void 0 ? void 0 : (_allFields$filter = allFields.filter(function (_ref4) {
|
|
136
|
+
var name = _ref4.name;
|
|
137
|
+
return name.join().startsWith(namePath === null || namePath === void 0 ? void 0 : namePath.join());
|
|
138
|
+
})) === null || _allFields$filter === void 0 ? void 0 : _allFields$filter.map(function (_ref5) {
|
|
139
|
+
var name = _ref5.name;
|
|
140
|
+
return name;
|
|
141
|
+
});
|
|
142
|
+
_context.prev = 4;
|
|
143
|
+
_context.next = 7;
|
|
144
|
+
return form === null || form === void 0 ? void 0 : form.validateFields(fields);
|
|
145
|
+
|
|
146
|
+
case 7:
|
|
147
|
+
_context.next = 15;
|
|
148
|
+
break;
|
|
149
|
+
|
|
150
|
+
case 9:
|
|
151
|
+
_context.prev = 9;
|
|
152
|
+
_context.t0 = _context["catch"](4);
|
|
153
|
+
form === null || form === void 0 ? void 0 : form.scrollToField(_context.t0.errorFields[0].name);
|
|
154
|
+
_iterator = _createForOfIteratorHelper(sections.current.values());
|
|
155
|
+
|
|
156
|
+
try {
|
|
157
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
158
|
+
collapseSection = _step.value;
|
|
159
|
+
collapseSection(false);
|
|
160
|
+
}
|
|
161
|
+
} catch (err) {
|
|
162
|
+
_iterator.e(err);
|
|
163
|
+
} finally {
|
|
164
|
+
_iterator.f();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return _context.abrupt("return");
|
|
168
|
+
|
|
169
|
+
case 15:
|
|
170
|
+
if (!(typeof handleNext === 'function')) {
|
|
171
|
+
_context.next = 27;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
_context.prev = 16;
|
|
176
|
+
_context.next = 19;
|
|
177
|
+
return handleNext(form === null || form === void 0 ? void 0 : form.getFieldsValue(fields));
|
|
178
|
+
|
|
179
|
+
case 19:
|
|
180
|
+
errors = _context.sent;
|
|
181
|
+
|
|
182
|
+
if (!Array.isArray(errors)) {
|
|
183
|
+
_context.next = 22;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return _context.abrupt("return", form === null || form === void 0 ? void 0 : form.setFields(errors));
|
|
188
|
+
|
|
189
|
+
case 22:
|
|
190
|
+
_context.next = 27;
|
|
191
|
+
break;
|
|
192
|
+
|
|
193
|
+
case 24:
|
|
194
|
+
_context.prev = 24;
|
|
195
|
+
_context.t1 = _context["catch"](16);
|
|
196
|
+
return _context.abrupt("return");
|
|
197
|
+
|
|
198
|
+
case 27:
|
|
199
|
+
setCurrent(last || current + 1);
|
|
200
|
+
setLast(0);
|
|
201
|
+
setShouldScroll(true);
|
|
202
|
+
|
|
203
|
+
case 30:
|
|
204
|
+
case "end":
|
|
205
|
+
return _context.stop();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}, _callee, null, [[4, 9], [16, 24]]);
|
|
209
|
+
}));
|
|
210
|
+
|
|
211
|
+
return function handleNext() {
|
|
212
|
+
return _ref3.apply(this, arguments);
|
|
213
|
+
};
|
|
214
|
+
}();
|
|
215
|
+
|
|
216
|
+
var handleEdit = function handleEdit(index) {
|
|
217
|
+
setLast(current);
|
|
218
|
+
setCurrent(index);
|
|
219
|
+
setShouldScroll(false);
|
|
220
|
+
typeof onEdit === 'function' && onEdit(index);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
var registerSection = function registerSection(name, toggle) {
|
|
224
|
+
sections.current.set(name, toggle);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
return _jsxs("div", {
|
|
228
|
+
className: 'igloo-hsteps-container',
|
|
229
|
+
children: [md && _jsxs("div", {
|
|
230
|
+
className: 'igloo-hsteps-bar',
|
|
231
|
+
children: [renderElements.map(function (step, index) {
|
|
232
|
+
return _jsxs("div", {
|
|
233
|
+
className: classNames({
|
|
234
|
+
'igloo-hsteps-bar-item': true,
|
|
235
|
+
'igloo-hsteps-bar-item-current': index === current
|
|
236
|
+
}),
|
|
237
|
+
children: [index < current && _jsx(SuccessFilled, {
|
|
238
|
+
className: 'igloo-hsteps-bar-item-icon'
|
|
239
|
+
}), _jsx(Typography, {
|
|
240
|
+
level: "h3a",
|
|
241
|
+
className: 'igloo-hsteps-bar-item-text',
|
|
242
|
+
children: step.label
|
|
243
|
+
})]
|
|
244
|
+
});
|
|
245
|
+
}), withReview && _jsxs("div", {
|
|
246
|
+
className: classNames({
|
|
247
|
+
'igloo-hsteps-bar-item': true,
|
|
248
|
+
'igloo-hsteps-bar-item-current': current === renderElements.length
|
|
249
|
+
}),
|
|
250
|
+
children: [current === renderElements.length && _jsx(Radio, {
|
|
251
|
+
checked: true
|
|
252
|
+
}), _jsx(Typography, {
|
|
253
|
+
level: "h3a",
|
|
254
|
+
className: 'igloo-hsteps-bar-item-text',
|
|
255
|
+
children: formatMessage({
|
|
256
|
+
id: 'Review and Submit'
|
|
257
|
+
})
|
|
258
|
+
})]
|
|
259
|
+
})]
|
|
260
|
+
}), _jsxs("div", {
|
|
261
|
+
className: "igloo-hsteps-content",
|
|
262
|
+
children: [current < renderElements.length && _jsx(StepContext.Provider, {
|
|
263
|
+
value: {
|
|
264
|
+
registerSection: registerSection
|
|
265
|
+
},
|
|
266
|
+
children: _jsx(HStep, {
|
|
267
|
+
config: renderElements[current],
|
|
268
|
+
parentName: calcNamePath(parentName, name),
|
|
269
|
+
index: current,
|
|
270
|
+
total: withReview ? renderElements.length + 1 : renderElements.length,
|
|
271
|
+
preview: false,
|
|
272
|
+
edit: true,
|
|
273
|
+
handleNext: handleNext,
|
|
274
|
+
handleEdit: handleEdit,
|
|
275
|
+
shouldScroll: shouldScroll
|
|
276
|
+
}, ((_renderElements$curre2 = renderElements[current]) === null || _renderElements$curre2 === void 0 ? void 0 : _renderElements$curre2.key) || ((_renderElements$curre3 = renderElements[current]) === null || _renderElements$curre3 === void 0 ? void 0 : _renderElements$curre3.name))
|
|
277
|
+
}), current === renderElements.length && _jsxs("div", {
|
|
278
|
+
className: "igloo-hsteps-confirmation-container",
|
|
279
|
+
children: [withReview && !md && _jsxs(Typography, {
|
|
280
|
+
className: "igloo-hstep-label",
|
|
281
|
+
level: "h3a",
|
|
282
|
+
children: [_jsx("span", {
|
|
283
|
+
className: "igloo-hstep-label-text",
|
|
284
|
+
children: formatMessage({
|
|
285
|
+
id: 'Review and Submit'
|
|
286
|
+
})
|
|
287
|
+
}), _jsxs(Typography, {
|
|
288
|
+
level: "body3",
|
|
289
|
+
children: [renderElements.length + 1, "/", renderElements.length + 1]
|
|
290
|
+
})]
|
|
291
|
+
}), renderElements.map(function (step, index) {
|
|
292
|
+
return _jsx(HStep, {
|
|
293
|
+
config: step,
|
|
294
|
+
parentName: calcNamePath(parentName, name),
|
|
295
|
+
index: index,
|
|
296
|
+
total: withReview ? renderElements.length + 1 : renderElements.length,
|
|
297
|
+
preview: true,
|
|
298
|
+
edit: false,
|
|
299
|
+
handleNext: handleNext,
|
|
300
|
+
handleEdit: handleEdit,
|
|
301
|
+
shouldScroll: shouldScroll
|
|
302
|
+
}, (step === null || step === void 0 ? void 0 : step.key) || (step === null || step === void 0 ? void 0 : step.name));
|
|
303
|
+
}), _jsxs("div", {
|
|
304
|
+
className: "igloo-hsteps-confirmation",
|
|
305
|
+
children: [md && _jsx(Typography, {
|
|
306
|
+
level: "h3a",
|
|
307
|
+
wrapElement: "div",
|
|
308
|
+
children: formatMessage({
|
|
309
|
+
id: 'Review and Submit'
|
|
310
|
+
})
|
|
311
|
+
}), _jsx(Typography, {
|
|
312
|
+
level: md ? 'h3b' : 'body1',
|
|
313
|
+
style: {
|
|
314
|
+
marginTop: 24
|
|
315
|
+
},
|
|
316
|
+
wrapElement: "div",
|
|
317
|
+
children: formatMessage({
|
|
318
|
+
id: 'Please take a moment to review what you’ve told us above.'
|
|
319
|
+
})
|
|
320
|
+
}), _jsx(Typography, {
|
|
321
|
+
level: md ? 'h3b' : 'body2',
|
|
322
|
+
style: {
|
|
323
|
+
marginTop: 24
|
|
324
|
+
},
|
|
325
|
+
wrapElement: "div",
|
|
326
|
+
children: formatMessage({
|
|
327
|
+
id: 'Once you’re happy with the above, and you’ve checked the box below, please go ahead and submit your activation.'
|
|
328
|
+
})
|
|
329
|
+
}), _jsx(_Divider, {}), !confirmations && _jsx(_Form.Item, {
|
|
330
|
+
name: calcNamePath(parentName, 'confirmation'),
|
|
331
|
+
rules: [{
|
|
332
|
+
validator: function validator(_, value) {
|
|
333
|
+
if (!value) {
|
|
334
|
+
return Promise.reject(formatMessage({
|
|
335
|
+
id: 'Please read and agree to Igloo Terms of Use and Privacy Policy'
|
|
336
|
+
}));
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return Promise.resolve();
|
|
340
|
+
}
|
|
341
|
+
}],
|
|
342
|
+
style: {
|
|
343
|
+
margin: 0
|
|
344
|
+
},
|
|
345
|
+
children: _jsx(Confirmation, {})
|
|
346
|
+
}), confirmations && Object.entries(confirmations).map(function (_ref6) {
|
|
347
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
348
|
+
key = _ref7[0],
|
|
349
|
+
_ref7$ = _ref7[1],
|
|
350
|
+
required = _ref7$.required,
|
|
351
|
+
_ref7$$confirmation = _ref7$.confirmation,
|
|
352
|
+
confirmation = _ref7$$confirmation === void 0 ? {} : _ref7$$confirmation;
|
|
353
|
+
|
|
354
|
+
return _jsx(_Form.Item, {
|
|
355
|
+
name: calcNamePath(parentName, key),
|
|
356
|
+
rules: [{
|
|
357
|
+
validator: function validator(_, value) {
|
|
358
|
+
if (required && !value) {
|
|
359
|
+
return Promise.reject(formatMessage({
|
|
360
|
+
id: 'Please read and agree to Igloo Terms of Use and Privacy Policy'
|
|
361
|
+
}));
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return Promise.resolve();
|
|
365
|
+
}
|
|
366
|
+
}],
|
|
367
|
+
style: {
|
|
368
|
+
margin: 0
|
|
369
|
+
},
|
|
370
|
+
children: _jsx(Confirmation, _objectSpread({}, confirmation))
|
|
371
|
+
});
|
|
372
|
+
}), showSubmitButton && md && _jsx(_Form.Item, {
|
|
373
|
+
style: {
|
|
374
|
+
marginBottom: 0
|
|
375
|
+
},
|
|
376
|
+
className: "igloo-hsteps-button-container",
|
|
377
|
+
children: _jsx(Button, {
|
|
378
|
+
type: "primary",
|
|
379
|
+
htmlType: "submit",
|
|
380
|
+
className: 'igloo-hsteps-button',
|
|
381
|
+
loading: submitting,
|
|
382
|
+
children: submitText || formatMessage({
|
|
383
|
+
id: 'Submit'
|
|
384
|
+
})
|
|
385
|
+
})
|
|
386
|
+
})]
|
|
387
|
+
})]
|
|
388
|
+
})]
|
|
389
|
+
}), showSubmitButton && current === renderElements.length && !md && _jsx(_Form.Item, {
|
|
390
|
+
style: {
|
|
391
|
+
marginBottom: 0
|
|
392
|
+
},
|
|
393
|
+
className: "igloo-hsteps-button-container",
|
|
394
|
+
children: _jsx(Button, {
|
|
395
|
+
type: "primary",
|
|
396
|
+
htmlType: "submit",
|
|
397
|
+
className: 'igloo-hsteps-button',
|
|
398
|
+
loading: submitting,
|
|
399
|
+
children: submitText || formatMessage({
|
|
400
|
+
id: 'Submit'
|
|
401
|
+
})
|
|
402
|
+
})
|
|
403
|
+
})]
|
|
404
|
+
});
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
export default HSteps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.less';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.less';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
.igloo-hsteps-container {
|
|
2
|
+
width: 100%;
|
|
3
|
+
|
|
4
|
+
.igloo-hsteps-bar {
|
|
5
|
+
display: flex;
|
|
6
|
+
|
|
7
|
+
.igloo-hsteps-bar-item {
|
|
8
|
+
text-align: center;
|
|
9
|
+
flex: auto;
|
|
10
|
+
border-bottom: 3px solid #eeeeee;
|
|
11
|
+
padding-bottom: 16px;
|
|
12
|
+
|
|
13
|
+
.igloo-hsteps-bar-item-icon {
|
|
14
|
+
color: @primary-color;
|
|
15
|
+
margin-right: 8px;
|
|
16
|
+
font-size: 24px;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.igloo-hsteps-bar-item-current {
|
|
21
|
+
border-bottom-color: @primary-color;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.igloo-hsteps-content {
|
|
26
|
+
width: 100%;
|
|
27
|
+
|
|
28
|
+
.igloo-hsteps-step {
|
|
29
|
+
width: 100%;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.igloo-hsteps-confirmation-container {
|
|
33
|
+
background: #f9f9f9;
|
|
34
|
+
padding: 0;
|
|
35
|
+
margin: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.igloo-hsteps-button {
|
|
39
|
+
margin-top: 24px;
|
|
40
|
+
min-width: 221px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.igloo-hsteps-confirmation {
|
|
44
|
+
width: 100%;
|
|
45
|
+
padding: 32px;
|
|
46
|
+
background: #ffffff;
|
|
47
|
+
margin-top: 32px;
|
|
48
|
+
border-radius: 3px;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@media screen and (max-width: 768px) {
|
|
54
|
+
.igloo-hsteps-container {
|
|
55
|
+
.igloo-hsteps-content {
|
|
56
|
+
width: 100%;
|
|
57
|
+
|
|
58
|
+
.igloo-hsteps-confirmation {
|
|
59
|
+
padding: 16px;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.igloo-hsteps-button-container {
|
|
64
|
+
width: 100%;
|
|
65
|
+
position: sticky;
|
|
66
|
+
bottom: 0;
|
|
67
|
+
box-shadow: 0px 0px 1px rgba(20, 20, 20, 0.04),
|
|
68
|
+
0px 1px 8px 2px rgba(20, 20, 20, 0.08);
|
|
69
|
+
|
|
70
|
+
padding: 24px 16px;
|
|
71
|
+
background: #ffffff;
|
|
72
|
+
|
|
73
|
+
.igloo-hsteps-button {
|
|
74
|
+
width: 100%;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
package/es/form/index.js
CHANGED
|
@@ -29,10 +29,11 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
29
29
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
30
30
|
|
|
31
31
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
32
|
-
import { useState, useImperativeHandle, forwardRef } from 'react';
|
|
32
|
+
import { useState, useImperativeHandle, forwardRef, useRef } from 'react';
|
|
33
33
|
import Pages from './pages';
|
|
34
34
|
import Page from './page';
|
|
35
35
|
import Steps from './steps';
|
|
36
|
+
import HSteps from './hsteps';
|
|
36
37
|
import Login from './login';
|
|
37
38
|
import FormContext from '../form-context';
|
|
38
39
|
import messages from './messages';
|
|
@@ -61,7 +62,9 @@ var IglooForm = function IglooForm(props, ref) {
|
|
|
61
62
|
_props$onFirstModifie = props.onFirstModified,
|
|
62
63
|
onFirstModified = _props$onFirstModifie === void 0 ? function () {} : _props$onFirstModifie,
|
|
63
64
|
uploadApi = props.uploadApi,
|
|
64
|
-
selectDatasourceApi = props.selectDatasourceApi
|
|
65
|
+
selectDatasourceApi = props.selectDatasourceApi,
|
|
66
|
+
_props$stepDirection = props.stepDirection,
|
|
67
|
+
stepDirection = _props$stepDirection === void 0 ? 'vertical' : _props$stepDirection;
|
|
65
68
|
|
|
66
69
|
var _Form$useForm = _Form.useForm(),
|
|
67
70
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
@@ -72,21 +75,18 @@ var IglooForm = function IglooForm(props, ref) {
|
|
|
72
75
|
submitting = _useState2[0],
|
|
73
76
|
setSubmitting = _useState2[1];
|
|
74
77
|
|
|
75
|
-
var
|
|
76
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
77
|
-
dependents = _useState4[0],
|
|
78
|
-
setDependents = _useState4[1];
|
|
78
|
+
var dependents = useRef({});
|
|
79
79
|
|
|
80
|
-
var
|
|
81
|
-
|
|
82
|
-
form =
|
|
80
|
+
var _useState3 = useState(formProp || innerForm),
|
|
81
|
+
_useState4 = _slicedToArray(_useState3, 1),
|
|
82
|
+
form = _useState4[0];
|
|
83
83
|
|
|
84
84
|
var type = config.type;
|
|
85
85
|
|
|
86
|
-
var
|
|
87
|
-
|
|
88
|
-
firstModifiedCalled =
|
|
89
|
-
callFirstModified =
|
|
86
|
+
var _useState5 = useState(false),
|
|
87
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
88
|
+
firstModifiedCalled = _useState6[0],
|
|
89
|
+
callFirstModified = _useState6[1];
|
|
90
90
|
|
|
91
91
|
invariant(type, "Contianer type should be one of ['Pages', 'Page', 'Steps', 'Login']");
|
|
92
92
|
|
|
@@ -172,35 +172,24 @@ var IglooForm = function IglooForm(props, ref) {
|
|
|
172
172
|
|
|
173
173
|
var registerDependencies = function registerDependencies(field, updater) {
|
|
174
174
|
if (Array.isArray(field)) {
|
|
175
|
-
|
|
176
|
-
var
|
|
175
|
+
field.forEach(function (name) {
|
|
176
|
+
var key = Array.isArray(name) ? name.join() : name;
|
|
177
177
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (!newDeps[key]) {
|
|
182
|
-
newDeps[key] = [];
|
|
183
|
-
}
|
|
178
|
+
if (!dependents.current[key]) {
|
|
179
|
+
dependents.current[key] = [];
|
|
180
|
+
}
|
|
184
181
|
|
|
185
|
-
|
|
186
|
-
});
|
|
187
|
-
return newDeps;
|
|
182
|
+
dependents.current[key].push(updater);
|
|
188
183
|
});
|
|
189
|
-
return;
|
|
190
184
|
}
|
|
191
185
|
|
|
192
|
-
|
|
193
|
-
var newDeps = _objectSpread({}, deps);
|
|
194
|
-
|
|
195
|
-
var key = Array.isArray(field) ? field.join() : field;
|
|
186
|
+
var key = Array.isArray(field) ? field.join() : field;
|
|
196
187
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
188
|
+
if (!dependents.current[key]) {
|
|
189
|
+
dependents.current[key] = [];
|
|
190
|
+
}
|
|
200
191
|
|
|
201
|
-
|
|
202
|
-
return newDeps;
|
|
203
|
-
});
|
|
192
|
+
dependents.current[key].push(updater);
|
|
204
193
|
};
|
|
205
194
|
|
|
206
195
|
var handleValuesChange = function handleValuesChange(changedFields) {
|
|
@@ -213,14 +202,14 @@ var IglooForm = function IglooForm(props, ref) {
|
|
|
213
202
|
var changedField = changedFields[0].name;
|
|
214
203
|
var changedKey = Array.isArray(changedField) ? changedField.join() : changedField;
|
|
215
204
|
|
|
216
|
-
if (dependents[changedKey]) {
|
|
217
|
-
dependents[changedKey].forEach(function (updater) {
|
|
205
|
+
if (dependents.current[changedKey]) {
|
|
206
|
+
dependents.current[changedKey].forEach(function (updater) {
|
|
218
207
|
return updater();
|
|
219
208
|
});
|
|
220
209
|
}
|
|
221
210
|
|
|
222
|
-
if (dependents['SUBSCRIBE_ALL']) {
|
|
223
|
-
dependents['SUBSCRIBE_ALL'].forEach(function (updater) {
|
|
211
|
+
if (dependents.current['SUBSCRIBE_ALL']) {
|
|
212
|
+
dependents.current['SUBSCRIBE_ALL'].forEach(function (updater) {
|
|
224
213
|
return updater();
|
|
225
214
|
});
|
|
226
215
|
}
|
|
@@ -256,7 +245,9 @@ var IglooForm = function IglooForm(props, ref) {
|
|
|
256
245
|
config: config
|
|
257
246
|
}), type === 'Page' && _jsx(Page, {
|
|
258
247
|
config: config
|
|
259
|
-
}), type === 'Steps' && _jsx(Steps, {
|
|
248
|
+
}), type === 'Steps' && stepDirection === 'vertical' && _jsx(Steps, {
|
|
249
|
+
config: config
|
|
250
|
+
}), type === 'Steps' && stepDirection === 'horizontal' && _jsx(HSteps, {
|
|
260
251
|
config: config
|
|
261
252
|
}), type === 'Login' && _jsx(Login, {
|
|
262
253
|
config: config
|
package/es/form/pages/index.js
CHANGED
|
@@ -32,9 +32,9 @@ import Typography from '../../typography';
|
|
|
32
32
|
var useBreakpoint = _Grid.useBreakpoint;
|
|
33
33
|
|
|
34
34
|
var Pages = function Pages(_ref) {
|
|
35
|
-
var
|
|
36
|
-
parentName = _ref.parentName,
|
|
35
|
+
var parentName = _ref.parentName,
|
|
37
36
|
_ref$config = _ref.config,
|
|
37
|
+
name = _ref$config.name,
|
|
38
38
|
_ref$config$elements = _ref$config.elements,
|
|
39
39
|
elements = _ref$config$elements === void 0 ? [] : _ref$config$elements,
|
|
40
40
|
subscribedFields = _ref$config.subscribedFields;
|