iglooform 2.5.7 → 2.5.10
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/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 +79 -0
- package/es/form/hsteps/index.d.ts +19 -0
- package/es/form/hsteps/index.js +418 -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 +100 -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 +18 -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 +87 -3
- package/es/input/phone-number.js +80 -20
- package/es/locale/en-US/messages.json +13 -0
- package/es/locale/format-message.js +2 -2
- package/es/locale/id-ID/messages.json +13 -0
- package/es/locale/locale-provider.js +2 -2
- package/es/locale/th-TH/messages.json +13 -0
- package/es/locale/vi-VN/messages.json +13 -0
- package/es/locale/zh-CN/messages.json +13 -0
- package/es/locale/zh-TW/messages.json +13 -0
- package/es/types.d.ts +17 -1
- package/es/upload/style/index.less +2 -0
- 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/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 +79 -0
- package/lib/form/hsteps/index.d.ts +19 -0
- package/lib/form/hsteps/index.js +448 -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 +100 -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 +18 -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 +88 -3
- package/lib/input/phone-number.js +78 -18
- package/lib/locale/en-US/messages.json +13 -0
- package/lib/locale/format-message.js +2 -2
- package/lib/locale/id-ID/messages.json +13 -0
- package/lib/locale/locale-provider.js +2 -2
- package/lib/locale/th-TH/messages.json +13 -0
- package/lib/locale/vi-VN/messages.json +13 -0
- package/lib/locale/zh-CN/messages.json +13 -0
- package/lib/locale/zh-TW/messages.json +13 -0
- package/lib/types.d.ts +17 -1
- package/lib/upload/style/index.less +2 -0
- package/lib/upload-photo/index.js +10 -4
- package/lib/utils/form-utils.js +85 -1
- package/package.json +1 -1
package/es/form/section/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import "antd/es/row/style";
|
|
2
2
|
import _Row from "antd/es/row";
|
|
3
|
+
import "antd/es/divider/style";
|
|
4
|
+
import _Divider from "antd/es/divider";
|
|
3
5
|
import "antd/es/col/style";
|
|
4
6
|
import _Col from "antd/es/col";
|
|
5
|
-
var _excluded = ["elements", "name", "label", "labelProps", "contentProps", "style"];
|
|
7
|
+
var _excluded = ["elements", "name", "label", "labelProps", "contentProps", "style", "collapsable", "defaultCollapsed"];
|
|
6
8
|
|
|
7
9
|
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
10
|
|
|
@@ -10,16 +12,30 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
10
12
|
|
|
11
13
|
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
14
|
|
|
15
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
16
|
+
|
|
17
|
+
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."); }
|
|
18
|
+
|
|
19
|
+
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); }
|
|
20
|
+
|
|
21
|
+
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; }
|
|
22
|
+
|
|
23
|
+
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; }
|
|
24
|
+
|
|
25
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
26
|
+
|
|
13
27
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
14
28
|
|
|
15
29
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
16
30
|
|
|
17
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
-
import { useContext } from 'react';
|
|
31
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
32
|
+
import { useState, useContext, useEffect } from 'react';
|
|
19
33
|
import Element from '../element';
|
|
20
34
|
import FormContext from '../../form-context';
|
|
35
|
+
import StepContext from '../../form-step-context';
|
|
21
36
|
import { calcNamePath, calcFormItemProps } from '../../utils/form-utils';
|
|
22
37
|
import Typography from '../../typography';
|
|
38
|
+
import { ArrowDownOutlined, ArrowUpOutlined } from 'iglooicon';
|
|
23
39
|
import './style/index.less';
|
|
24
40
|
|
|
25
41
|
var Section = function Section(_ref) {
|
|
@@ -35,16 +51,35 @@ var Section = function Section(_ref) {
|
|
|
35
51
|
contentProps = _ref$config$contentPr === void 0 ? {} : _ref$config$contentPr,
|
|
36
52
|
_ref$config$style = _ref$config.style,
|
|
37
53
|
style = _ref$config$style === void 0 ? {} : _ref$config$style,
|
|
54
|
+
_ref$config$collapsab = _ref$config.collapsable,
|
|
55
|
+
collapsable = _ref$config$collapsab === void 0 ? false : _ref$config$collapsab,
|
|
56
|
+
_ref$config$defaultCo = _ref$config.defaultCollapsed,
|
|
57
|
+
defaultCollapsed = _ref$config$defaultCo === void 0 ? false : _ref$config$defaultCo,
|
|
38
58
|
rest = _objectWithoutProperties(_ref$config, _excluded),
|
|
39
59
|
preview = _ref.preview,
|
|
40
60
|
disabled = _ref.disabled,
|
|
41
61
|
setShowStepButton = _ref.setShowStepButton;
|
|
42
62
|
|
|
63
|
+
var _useState = useState(defaultCollapsed && !preview),
|
|
64
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
65
|
+
collapsed = _useState2[0],
|
|
66
|
+
toggle = _useState2[1];
|
|
67
|
+
|
|
43
68
|
var _useContext = useContext(FormContext),
|
|
44
69
|
form = _useContext.form,
|
|
45
70
|
requiredMark = _useContext.requiredMark;
|
|
46
71
|
|
|
72
|
+
var _useContext2 = useContext(StepContext),
|
|
73
|
+
registerSection = _useContext2.registerSection;
|
|
74
|
+
|
|
47
75
|
var namePath = calcNamePath(parentName, name);
|
|
76
|
+
useEffect(function () {
|
|
77
|
+
if (collapsable) {
|
|
78
|
+
registerSection(namePath, function (collapsed) {
|
|
79
|
+
return toggle(collapsed);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}, []);
|
|
48
83
|
|
|
49
84
|
var _calcFormItemProps = calcFormItemProps(rest, {
|
|
50
85
|
requiredMark: requiredMark
|
|
@@ -69,15 +104,40 @@ var Section = function Section(_ref) {
|
|
|
69
104
|
span: 24,
|
|
70
105
|
className: 'igloo-section',
|
|
71
106
|
style: style,
|
|
72
|
-
children: [
|
|
73
|
-
className: 'igloo-section-label'
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
107
|
+
children: [_jsxs("div", {
|
|
108
|
+
className: 'igloo-section-label',
|
|
109
|
+
onClick: function onClick() {
|
|
110
|
+
collapsable && !preview && toggle(function (c) {
|
|
111
|
+
return !c;
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
children: [label && _jsx(Typography, _objectSpread(_objectSpread({}, labelProps), {}, {
|
|
115
|
+
level: "h4",
|
|
116
|
+
wrapElement: "div",
|
|
117
|
+
children: label
|
|
118
|
+
})), collapsable && !preview && _jsxs(_Fragment, {
|
|
119
|
+
children: [_jsx(ArrowDownOutlined, {
|
|
120
|
+
style: {
|
|
121
|
+
opacity: collapsed ? 0 : 1,
|
|
122
|
+
fontSize: 24,
|
|
123
|
+
display: collapsed ? 'none' : 'block'
|
|
124
|
+
}
|
|
125
|
+
}), _jsx(ArrowUpOutlined, {
|
|
126
|
+
style: {
|
|
127
|
+
opacity: collapsed ? 1 : 0,
|
|
128
|
+
fontSize: 24,
|
|
129
|
+
display: collapsed ? 'block' : 'none'
|
|
130
|
+
}
|
|
131
|
+
})]
|
|
132
|
+
})]
|
|
133
|
+
}), collapsable && !preview && _jsx(_Divider, {
|
|
134
|
+
className: "igloo-section-collapse-divider"
|
|
135
|
+
}), _jsx("div", _objectSpread(_objectSpread({
|
|
79
136
|
className: 'igloo-section-content'
|
|
80
137
|
}, contentProps), {}, {
|
|
138
|
+
style: {
|
|
139
|
+
display: !collapsable || !collapsed ? 'block' : 'none'
|
|
140
|
+
},
|
|
81
141
|
children: _jsx(_Row, {
|
|
82
142
|
gutter: [32, preview ? 16 : 24],
|
|
83
143
|
children: elements.map(function (child, index) {
|
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
.igloo-section {
|
|
2
|
+
position: relative;
|
|
3
|
+
|
|
4
|
+
.igloo-section-label {
|
|
5
|
+
display: flex;
|
|
6
|
+
justify-content: space-between;
|
|
7
|
+
align-items: center;
|
|
8
|
+
}
|
|
9
|
+
|
|
2
10
|
.igloo-section-content {
|
|
3
11
|
margin-top: 16px;
|
|
4
12
|
}
|
|
13
|
+
|
|
14
|
+
.igloo-section-collapse-divider {
|
|
15
|
+
margin-bottom: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&:last-child {
|
|
19
|
+
.igloo-section-collapse-divider {
|
|
20
|
+
display: none;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
5
23
|
}
|
package/es/form/step/index.js
CHANGED
|
@@ -29,10 +29,6 @@ import FormContext from '../../form-context';
|
|
|
29
29
|
import './style/index.less';
|
|
30
30
|
var useBreakpoint = _Grid.useBreakpoint;
|
|
31
31
|
|
|
32
|
-
function specialDisplayIndex(index) {
|
|
33
|
-
return index < 10 ? "0".concat(index) : index;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
32
|
var Step = function Step(_ref) {
|
|
37
33
|
var parentName = _ref.parentName,
|
|
38
34
|
_ref$config = _ref.config,
|
|
@@ -81,14 +77,23 @@ var Step = function Step(_ref) {
|
|
|
81
77
|
md = _useBreakpoint.md;
|
|
82
78
|
|
|
83
79
|
useEffect(function () {
|
|
84
|
-
var _containerRef$current, _containerRef$
|
|
80
|
+
var _containerRef$current, _containerRef$current4;
|
|
85
81
|
|
|
86
82
|
if (md || !(shouldScroll && edit)) return;
|
|
87
83
|
var scrollContainer = getScrollContainer() || window;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
84
|
+
if (typeof scrollContainer.scrollTo !== 'function') return;
|
|
85
|
+
|
|
86
|
+
if (containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetTop) {
|
|
87
|
+
var _containerRef$current2, _containerRef$current3;
|
|
88
|
+
|
|
89
|
+
scrollContainer.scrollTo.length === 2 ? scrollContainer.scrollTo(0, (containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.offsetTop) - 50) : scrollContainer.scrollTo({
|
|
90
|
+
top: (containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.offsetTop) - 50,
|
|
91
|
+
behavior: 'smooth'
|
|
92
|
+
});
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.scrollIntoView();
|
|
92
97
|
}, [shouldScroll, edit]);
|
|
93
98
|
var displayTotal = showLastIndex ? total : total - 1;
|
|
94
99
|
return _jsxs("div", {
|
|
@@ -99,7 +104,7 @@ var Step = function Step(_ref) {
|
|
|
99
104
|
children: [_jsxs("div", {
|
|
100
105
|
children: [(index !== total - 1 || showLastIndex) && _jsx("span", {
|
|
101
106
|
className: "igloo-step-label-index",
|
|
102
|
-
children:
|
|
107
|
+
children: String(index + 1).padStart(2, '0')
|
|
103
108
|
}), _jsx("span", {
|
|
104
109
|
className: "igloo-step-label-text",
|
|
105
110
|
children: label
|
package/es/form/steps/index.js
CHANGED
|
@@ -15,17 +15,18 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
15
15
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
16
|
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
-
import { useState, useContext, useEffect, useReducer } from 'react';
|
|
18
|
+
import { useState, useContext, useEffect, useReducer, useRef } from 'react';
|
|
19
19
|
import Step from '../step';
|
|
20
20
|
import { calcNamePath } from '../../utils/form-utils';
|
|
21
21
|
import FormContext from '../../form-context';
|
|
22
|
+
import StepContext from '../../form-step-context';
|
|
22
23
|
import './style/index.less';
|
|
23
24
|
import invariant from 'invariant';
|
|
24
25
|
|
|
25
26
|
var Steps = function Steps(_ref) {
|
|
26
|
-
var
|
|
27
|
-
parentName = _ref.parentName,
|
|
27
|
+
var parentName = _ref.parentName,
|
|
28
28
|
_ref$config = _ref.config,
|
|
29
|
+
name = _ref$config.name,
|
|
29
30
|
_ref$config$elements = _ref$config.elements,
|
|
30
31
|
elements = _ref$config$elements === void 0 ? [] : _ref$config$elements,
|
|
31
32
|
_ref$config$showLastI = _ref$config.showLastIndex,
|
|
@@ -57,6 +58,8 @@ var Steps = function Steps(_ref) {
|
|
|
57
58
|
_ = _useReducer2[0],
|
|
58
59
|
dispatch = _useReducer2[1];
|
|
59
60
|
|
|
61
|
+
var sections = useRef(new Map());
|
|
62
|
+
|
|
60
63
|
var _useContext = useContext(FormContext),
|
|
61
64
|
form = _useContext.form,
|
|
62
65
|
registerDependencies = _useContext.registerDependencies;
|
|
@@ -168,24 +171,33 @@ var Steps = function Steps(_ref) {
|
|
|
168
171
|
typeof onEdit === 'function' && onEdit(index);
|
|
169
172
|
};
|
|
170
173
|
|
|
174
|
+
var registerSection = function registerSection(name, toggle) {
|
|
175
|
+
sections.current.set(name, toggle);
|
|
176
|
+
};
|
|
177
|
+
|
|
171
178
|
return _jsx("div", {
|
|
172
179
|
className: 'igloo-steps-container',
|
|
173
180
|
children: _jsx("div", {
|
|
174
181
|
className: 'igloo-steps-content',
|
|
175
182
|
children: renderElements.map(function (child, index) {
|
|
176
183
|
invariant(child.type === 'Step', 'Child of steps should be Step');
|
|
177
|
-
return _jsx(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
184
|
+
return _jsx(StepContext.Provider, {
|
|
185
|
+
value: {
|
|
186
|
+
registerSection: registerSection
|
|
187
|
+
},
|
|
188
|
+
children: _jsx(Step, {
|
|
189
|
+
config: child,
|
|
190
|
+
parentName: calcNamePath(parentName, name),
|
|
191
|
+
index: index,
|
|
192
|
+
total: renderElements.length,
|
|
193
|
+
preview: current > index,
|
|
194
|
+
edit: current === index,
|
|
195
|
+
handleNext: handleNext,
|
|
196
|
+
handleEdit: handleEdit,
|
|
197
|
+
showLastIndex: showLastIndex,
|
|
198
|
+
shouldScroll: shouldScroll
|
|
199
|
+
}, child.key || child.name)
|
|
200
|
+
});
|
|
189
201
|
})
|
|
190
202
|
})
|
|
191
203
|
});
|
package/es/free-form/index.js
CHANGED
|
@@ -29,7 +29,7 @@ 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 } from "react/jsx-runtime";
|
|
32
|
-
import { useState } from 'react';
|
|
32
|
+
import { useState, useRef } from 'react';
|
|
33
33
|
import FormContext from '../form-context';
|
|
34
34
|
import messages from './messages';
|
|
35
35
|
import './style/index.less';
|
|
@@ -67,19 +67,16 @@ var FreeForm = function FreeForm(props) {
|
|
|
67
67
|
submitting = _useState2[0],
|
|
68
68
|
setSubmitting = _useState2[1];
|
|
69
69
|
|
|
70
|
-
var
|
|
71
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
72
|
-
dependents = _useState4[0],
|
|
73
|
-
setDependents = _useState4[1];
|
|
70
|
+
var dependents = useRef({});
|
|
74
71
|
|
|
75
|
-
var
|
|
76
|
-
|
|
77
|
-
form =
|
|
72
|
+
var _useState3 = useState(formProp || innerForm),
|
|
73
|
+
_useState4 = _slicedToArray(_useState3, 1),
|
|
74
|
+
form = _useState4[0];
|
|
78
75
|
|
|
79
|
-
var
|
|
80
|
-
|
|
81
|
-
firstModifiedCalled =
|
|
82
|
-
callFirstModified =
|
|
76
|
+
var _useState5 = useState(false),
|
|
77
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
78
|
+
firstModifiedCalled = _useState6[0],
|
|
79
|
+
callFirstModified = _useState6[1];
|
|
83
80
|
|
|
84
81
|
var validateMessages = localesProp.validateMessages,
|
|
85
82
|
locales = _objectWithoutProperties(localesProp, _excluded);
|
|
@@ -129,35 +126,24 @@ var FreeForm = function FreeForm(props) {
|
|
|
129
126
|
|
|
130
127
|
var registerDependencies = function registerDependencies(field, updater) {
|
|
131
128
|
if (Array.isArray(field)) {
|
|
132
|
-
|
|
133
|
-
var
|
|
129
|
+
field.forEach(function (name) {
|
|
130
|
+
var key = Array.isArray(name) ? name.join() : name;
|
|
134
131
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (!newDeps[key]) {
|
|
139
|
-
newDeps[key] = [];
|
|
140
|
-
}
|
|
132
|
+
if (!dependents.current[key]) {
|
|
133
|
+
dependents.current[key] = [];
|
|
134
|
+
}
|
|
141
135
|
|
|
142
|
-
|
|
143
|
-
});
|
|
144
|
-
return newDeps;
|
|
136
|
+
dependents.current[key].push(updater);
|
|
145
137
|
});
|
|
146
|
-
return;
|
|
147
138
|
}
|
|
148
139
|
|
|
149
|
-
|
|
150
|
-
var newDeps = _objectSpread({}, deps);
|
|
140
|
+
var key = Array.isArray(field) ? field.join() : field;
|
|
151
141
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
newDeps[key] = [];
|
|
156
|
-
}
|
|
142
|
+
if (!dependents.current[key]) {
|
|
143
|
+
dependents.current[key] = [];
|
|
144
|
+
}
|
|
157
145
|
|
|
158
|
-
|
|
159
|
-
return newDeps;
|
|
160
|
-
});
|
|
146
|
+
dependents.current[key].push(updater);
|
|
161
147
|
};
|
|
162
148
|
|
|
163
149
|
var handleValuesChange = function handleValuesChange(changedFields) {
|
|
@@ -170,14 +156,14 @@ var FreeForm = function FreeForm(props) {
|
|
|
170
156
|
var changedField = changedFields[0].name;
|
|
171
157
|
var changedKey = Array.isArray(changedField) ? changedField.join() : changedField;
|
|
172
158
|
|
|
173
|
-
if (dependents[changedKey]) {
|
|
174
|
-
dependents[changedKey].forEach(function (updater) {
|
|
159
|
+
if (dependents.current[changedKey]) {
|
|
160
|
+
dependents.current[changedKey].forEach(function (updater) {
|
|
175
161
|
return updater();
|
|
176
162
|
});
|
|
177
163
|
}
|
|
178
164
|
|
|
179
|
-
if (dependents['SUBSCRIBE_ALL']) {
|
|
180
|
-
dependents['SUBSCRIBE_ALL'].forEach(function (updater) {
|
|
165
|
+
if (dependents.current['SUBSCRIBE_ALL']) {
|
|
166
|
+
dependents.current['SUBSCRIBE_ALL'].forEach(function (updater) {
|
|
181
167
|
return updater();
|
|
182
168
|
});
|
|
183
169
|
}
|
package/es/input/input-number.js
CHANGED
|
@@ -10,6 +10,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import omit from 'omit.js';
|
|
12
12
|
import formMethods from '../utils/form-methods';
|
|
13
|
+
import { staticFormatMessage } from '../locale';
|
|
13
14
|
import './style/index.less';
|
|
14
15
|
|
|
15
16
|
var IglooInputNumber = function IglooInputNumber(props) {
|
|
@@ -39,17 +40,100 @@ var IglooInputNumber = function IglooInputNumber(props) {
|
|
|
39
40
|
};
|
|
40
41
|
|
|
41
42
|
IglooInputNumber.formItemPropsHandler = function (config) {
|
|
43
|
+
var length = config.length,
|
|
44
|
+
maxLength = config.maxLength,
|
|
45
|
+
minLength = config.minLength,
|
|
46
|
+
label = config.label,
|
|
47
|
+
idType = config.idType;
|
|
48
|
+
var rules = [];
|
|
49
|
+
|
|
50
|
+
if (length !== undefined) {
|
|
51
|
+
rules.push({
|
|
52
|
+
validator: function validator(_, value) {
|
|
53
|
+
if (value === undefined || value === null || String(value).length === length) return Promise.resolve();
|
|
54
|
+
return Promise.reject(staticFormatMessage({
|
|
55
|
+
id: '{label} must be {length} digits.',
|
|
56
|
+
values: {
|
|
57
|
+
length: length,
|
|
58
|
+
label: label
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (maxLength !== undefined && minLength !== undefined) {
|
|
66
|
+
rules.push({
|
|
67
|
+
validator: function validator(_, value) {
|
|
68
|
+
if (value === undefined || value === null || String(value).length >= minLength && String(value).length <= maxLength) return Promise.resolve();
|
|
69
|
+
return Promise.reject(staticFormatMessage({
|
|
70
|
+
id: '{label} must be {minLength} - {maxLength} digits.',
|
|
71
|
+
values: {
|
|
72
|
+
maxLength: maxLength,
|
|
73
|
+
minLength: minLength,
|
|
74
|
+
label: label
|
|
75
|
+
}
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (maxLength !== undefined && minLength === undefined) {
|
|
82
|
+
rules.push({
|
|
83
|
+
validator: function validator(_, value) {
|
|
84
|
+
if (value === undefined || value === null || String(value).length <= maxLength) return Promise.resolve();
|
|
85
|
+
return Promise.reject(staticFormatMessage({
|
|
86
|
+
id: '{label} must be less than {maxLength} digits.',
|
|
87
|
+
values: {
|
|
88
|
+
maxLength: maxLength,
|
|
89
|
+
label: label
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (maxLength === undefined && minLength !== undefined) {
|
|
97
|
+
rules.push({
|
|
98
|
+
validator: function validator(_, value) {
|
|
99
|
+
if (value === undefined || value === null || String(value).length >= minLength) return Promise.resolve();
|
|
100
|
+
return Promise.reject(staticFormatMessage({
|
|
101
|
+
id: '{label} must be at least {minLength} digits.',
|
|
102
|
+
values: {
|
|
103
|
+
minLength: minLength,
|
|
104
|
+
label: label
|
|
105
|
+
}
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (idType === 'KTP') {
|
|
112
|
+
rules.push({
|
|
113
|
+
validator: function validator(rule, value) {
|
|
114
|
+
if (!/^((1[1-9])|(21)|([37][1-6])|(5[1-4])|(6[1-5])|([8-9][1-2]))[0-9]{4}(([0-6][0-9])|(7[0-1]))((0[1-9])|(1[0-2]))[0-9]{6}$/.test(value)) {
|
|
115
|
+
return Promise.reject(staticFormatMessage({
|
|
116
|
+
id: 'Invalid KTP Number.'
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return Promise.resolve();
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
42
125
|
return {
|
|
43
126
|
getValueFromEvent: function getValueFromEvent(e) {
|
|
44
127
|
var value = e.target.value;
|
|
45
|
-
var str = value.replaceAll(/[^0-9
|
|
128
|
+
var str = value.replaceAll(/[^0-9\.-]/g, '');
|
|
46
129
|
|
|
47
|
-
if (str.endsWith('.') || str.includes('.') && str.endsWith('0')) {
|
|
130
|
+
if (str.endsWith('.') || str.includes('.') && str.endsWith('0') || str === '-') {
|
|
48
131
|
return str;
|
|
49
132
|
}
|
|
50
133
|
|
|
51
134
|
return str ? parseFloat(str) : undefined;
|
|
52
|
-
}
|
|
135
|
+
},
|
|
136
|
+
rules: rules
|
|
53
137
|
};
|
|
54
138
|
};
|
|
55
139
|
|
package/es/input/phone-number.js
CHANGED
|
@@ -14,11 +14,11 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
14
14
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
15
|
|
|
16
16
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
-
import { useState,
|
|
17
|
+
import { useState, useEffect } from 'react';
|
|
18
18
|
import classnames from 'classnames';
|
|
19
19
|
import invariant from 'invariant';
|
|
20
20
|
import Select from '../select';
|
|
21
|
-
import { staticFormatMessage
|
|
21
|
+
import { staticFormatMessage as formatMessage } from '../locale';
|
|
22
22
|
import './style/index';
|
|
23
23
|
|
|
24
24
|
var PhoneNumber = function PhoneNumber(_ref) {
|
|
@@ -29,13 +29,6 @@ var PhoneNumber = function PhoneNumber(_ref) {
|
|
|
29
29
|
value = _ref.value,
|
|
30
30
|
formChangeProps = _ref.onChange,
|
|
31
31
|
style = _ref.style;
|
|
32
|
-
|
|
33
|
-
var _useContext = useContext(LocaleContext),
|
|
34
|
-
formatMessage = _useContext.formatMessage;
|
|
35
|
-
|
|
36
|
-
formatMessage({
|
|
37
|
-
id: 'Numbers only, please omit " " or "-".'
|
|
38
|
-
});
|
|
39
32
|
invariant(Array.isArray(areaCode) ? areaCode.length : true, 'areaCode cant be an empty array');
|
|
40
33
|
invariant(areaCode != undefined, 'areaCode must be set');
|
|
41
34
|
|
|
@@ -95,22 +88,89 @@ var PhoneNumber = function PhoneNumber(_ref) {
|
|
|
95
88
|
|
|
96
89
|
PhoneNumber.formItemPropsHandler = function (_ref2) {
|
|
97
90
|
var areaCode = _ref2.areaCode,
|
|
98
|
-
phoneNumber = _ref2.phoneNumber
|
|
91
|
+
phoneNumber = _ref2.phoneNumber,
|
|
92
|
+
length = _ref2.length,
|
|
93
|
+
maxLength = _ref2.maxLength,
|
|
94
|
+
minLength = _ref2.minLength,
|
|
95
|
+
label = _ref2.label;
|
|
96
|
+
var rules = [{
|
|
97
|
+
validator: function validator(rule, value) {
|
|
98
|
+
if (!value) return Promise.resolve();
|
|
99
|
+
var phoneNumber = value.phoneNumber;
|
|
100
|
+
var pattern = /^[0-9]*$/;
|
|
101
|
+
return pattern.test(phoneNumber) ? Promise.resolve() : Promise.reject(formatMessage({
|
|
102
|
+
id: 'Numbers only, please omit " " or "-".'
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
}];
|
|
106
|
+
|
|
107
|
+
if (length !== undefined) {
|
|
108
|
+
rules.push({
|
|
109
|
+
validator: function validator(_, value) {
|
|
110
|
+
if (value === undefined || value === null || value.phoneNumber.length === length) return Promise.resolve();
|
|
111
|
+
return Promise.reject(formatMessage({
|
|
112
|
+
id: '{label} must be {length} digits.',
|
|
113
|
+
values: {
|
|
114
|
+
length: length,
|
|
115
|
+
label: label
|
|
116
|
+
}
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (maxLength !== undefined && minLength !== undefined) {
|
|
123
|
+
rules.push({
|
|
124
|
+
validator: function validator(_, value) {
|
|
125
|
+
if (value === undefined || value === null || value.phoneNumber.length >= minLength && value.phoneNumber.length <= maxLength) return Promise.resolve();
|
|
126
|
+
return Promise.reject(formatMessage({
|
|
127
|
+
id: '{label} must be {minLength} - {maxLength} digits.',
|
|
128
|
+
values: {
|
|
129
|
+
maxLength: maxLength,
|
|
130
|
+
minLength: minLength,
|
|
131
|
+
label: label
|
|
132
|
+
}
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (maxLength !== undefined && minLength === undefined) {
|
|
139
|
+
rules.push({
|
|
140
|
+
validator: function validator(_, value) {
|
|
141
|
+
if (value === undefined || value === null || value.phoneNumber.length <= maxLength) return Promise.resolve();
|
|
142
|
+
return Promise.reject(formatMessage({
|
|
143
|
+
id: '{label} must be less than {maxLength} digits.',
|
|
144
|
+
values: {
|
|
145
|
+
maxLength: maxLength,
|
|
146
|
+
label: label
|
|
147
|
+
}
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (maxLength === undefined && minLength !== undefined) {
|
|
154
|
+
rules.push({
|
|
155
|
+
validator: function validator(_, value) {
|
|
156
|
+
if (value === undefined || value === null || value.phoneNumber.length >= minLength) return Promise.resolve();
|
|
157
|
+
return Promise.reject(formatMessage({
|
|
158
|
+
id: '{label} must be at least {minLength} digits.',
|
|
159
|
+
values: {
|
|
160
|
+
minLength: minLength,
|
|
161
|
+
label: label
|
|
162
|
+
}
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
99
168
|
return {
|
|
100
169
|
initialValue: phoneNumber ? {
|
|
101
170
|
areaCode: Array.isArray(areaCode) ? areaCode[0] : areaCode,
|
|
102
171
|
phoneNumber: phoneNumber
|
|
103
172
|
} : undefined,
|
|
104
|
-
rules:
|
|
105
|
-
validator: function validator(rule, value) {
|
|
106
|
-
if (!value) return Promise.resolve();
|
|
107
|
-
var phoneNumber = value.phoneNumber;
|
|
108
|
-
var pattern = /^[0-9]*$/;
|
|
109
|
-
return pattern.test(phoneNumber) ? Promise.resolve() : Promise.reject(staticFormatMessage({
|
|
110
|
-
id: 'Numbers only, please omit " " or "-".'
|
|
111
|
-
}));
|
|
112
|
-
}
|
|
113
|
-
}],
|
|
173
|
+
rules: rules,
|
|
114
174
|
previewFormater: function previewFormater(_ref3) {
|
|
115
175
|
var areaCode = _ref3.areaCode,
|
|
116
176
|
phoneNumber = _ref3.phoneNumber;
|