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