iglooform 2.5.0 → 2.5.3
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/checkbox/index.d.ts +7 -7
- package/es/checkbox/index.js +85 -5
- package/es/form/elements.js +3 -1
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/input/amount.js +14 -3
- package/es/input/input-number.js +14 -3
- package/es/locale/en-US/messages.json +4 -0
- package/es/locale/id-ID/messages.json +4 -0
- package/es/locale/th-TH/messages.json +4 -0
- package/es/locale/vi-VN/messages.json +4 -0
- package/es/locale/zh-CN/messages.json +4 -0
- package/es/locale/zh-TW/messages.json +5 -0
- package/es/radio/index.d.ts +6 -6
- package/es/radio/index.js +79 -22
- package/es/radio/radio-group-with-other.d.ts +1 -1
- package/es/radio/radio-group-with-other.js +41 -4
- package/es/radio/style/empty.svg +12 -0
- package/es/search-box/index.d.ts +31 -0
- package/es/search-box/index.js +266 -0
- package/es/search-box/style/index.d.ts +1 -0
- package/es/search-box/style/index.js +1 -0
- package/es/search-box/style/index.less +162 -0
- package/es/select/attached-select.d.ts +2 -12
- package/es/select/attached-select.js +27 -186
- package/es/upload-photo/index.js +33 -32
- package/es/utils/option-utils.d.ts +24 -0
- package/es/utils/option-utils.js +233 -0
- package/lib/checkbox/index.d.ts +7 -7
- package/lib/checkbox/index.js +87 -5
- package/lib/form/elements.js +4 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +9 -0
- package/lib/input/amount.js +14 -3
- package/lib/input/input-number.js +14 -3
- package/lib/locale/en-US/messages.json +4 -0
- package/lib/locale/id-ID/messages.json +4 -0
- package/lib/locale/th-TH/messages.json +4 -0
- package/lib/locale/vi-VN/messages.json +4 -0
- package/lib/locale/zh-CN/messages.json +4 -0
- package/lib/locale/zh-TW/messages.json +5 -0
- package/lib/radio/index.d.ts +6 -6
- package/lib/radio/index.js +83 -22
- package/lib/radio/radio-group-with-other.d.ts +1 -1
- package/lib/radio/radio-group-with-other.js +41 -3
- package/lib/radio/style/empty.svg +12 -0
- package/lib/search-box/index.d.ts +31 -0
- package/lib/search-box/index.js +287 -0
- package/lib/search-box/style/index.d.ts +1 -0
- package/lib/search-box/style/index.js +3 -0
- package/lib/search-box/style/index.less +162 -0
- package/lib/select/attached-select.d.ts +2 -12
- package/lib/select/attached-select.js +26 -186
- package/lib/upload-photo/index.js +33 -32
- package/lib/utils/option-utils.d.ts +24 -0
- package/lib/utils/option-utils.js +250 -0
- package/package.json +10 -9
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
var _excluded = ["options", "optionGroups", "getOptions", "datasourceKey", "dependField", "children"];
|
|
2
|
+
|
|
3
|
+
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; }
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
7
|
+
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; }
|
|
8
|
+
|
|
9
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
10
|
+
|
|
11
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
+
|
|
13
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
14
|
+
|
|
15
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
|
+
|
|
17
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
18
|
+
|
|
19
|
+
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); } }
|
|
20
|
+
|
|
21
|
+
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); }); }; }
|
|
22
|
+
|
|
23
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
24
|
+
|
|
25
|
+
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."); }
|
|
26
|
+
|
|
27
|
+
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); }
|
|
28
|
+
|
|
29
|
+
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; }
|
|
30
|
+
|
|
31
|
+
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; }
|
|
32
|
+
|
|
33
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
34
|
+
|
|
35
|
+
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; }
|
|
36
|
+
|
|
37
|
+
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; }
|
|
38
|
+
|
|
39
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
40
|
+
import { useEffect, useState, useContext, useRef } from 'react';
|
|
41
|
+
import FormContext from '../form-context';
|
|
42
|
+
import invariant from 'invariant';
|
|
43
|
+
export var compareOptions = function compareOptions(newOptions, oldOptions) {
|
|
44
|
+
if (!Array.isArray(oldOptions)) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if ((oldOptions === null || oldOptions === void 0 ? void 0 : oldOptions.length) !== newOptions.length) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (Array.isArray(oldOptions)) {
|
|
53
|
+
for (var i = 0; i < oldOptions.length; i++) {
|
|
54
|
+
var newOption = oldOptions[i];
|
|
55
|
+
var originOption = newOptions[i];
|
|
56
|
+
|
|
57
|
+
if (newOption.label !== originOption.label || newOption.value !== originOption.value) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return false;
|
|
64
|
+
};
|
|
65
|
+
export function optionsHOC(Component) {
|
|
66
|
+
return function (props) {
|
|
67
|
+
var options = props.options,
|
|
68
|
+
optionGroups = props.optionGroups,
|
|
69
|
+
getOptions = props.getOptions,
|
|
70
|
+
datasourceKey = props.datasourceKey,
|
|
71
|
+
dependField = props.dependField,
|
|
72
|
+
children = props.children,
|
|
73
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
74
|
+
|
|
75
|
+
var _useState = useState(false),
|
|
76
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
77
|
+
updating = _useState2[0],
|
|
78
|
+
setUpdating = _useState2[1];
|
|
79
|
+
|
|
80
|
+
var _useState3 = useState(),
|
|
81
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
82
|
+
_options = _useState4[0],
|
|
83
|
+
setOptions = _useState4[1];
|
|
84
|
+
|
|
85
|
+
var _useState5 = useState(),
|
|
86
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
87
|
+
searchKey = _useState6[0],
|
|
88
|
+
setSearchKey = _useState6[1];
|
|
89
|
+
|
|
90
|
+
var optionsRef = useRef(_options);
|
|
91
|
+
|
|
92
|
+
var _useContext = useContext(FormContext),
|
|
93
|
+
selectDatasourceApi = _useContext.selectDatasourceApi;
|
|
94
|
+
|
|
95
|
+
var getFormInstance = rest.getFormInstance;
|
|
96
|
+
var form = typeof getFormInstance === 'function' && getFormInstance();
|
|
97
|
+
var dependFieldValue = form && dependField && form.getFieldValue(dependField);
|
|
98
|
+
var optionsFromGetOptions = typeof getOptions === 'function' && form && getOptions(form);
|
|
99
|
+
useEffect(function () {
|
|
100
|
+
if (!Array.isArray(optionsFromGetOptions)) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (compareOptions(optionsFromGetOptions, optionsRef.current)) {
|
|
105
|
+
optionsRef.current = optionsFromGetOptions;
|
|
106
|
+
setOptions(optionsFromGetOptions);
|
|
107
|
+
}
|
|
108
|
+
}, [optionsFromGetOptions]);
|
|
109
|
+
invariant(datasourceKey && selectDatasourceApi || !datasourceKey, 'Please provide selectDatasourceApi in Form props');
|
|
110
|
+
useEffect(function () {
|
|
111
|
+
setUpdating(true);
|
|
112
|
+
|
|
113
|
+
var calcOptions = /*#__PURE__*/function () {
|
|
114
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
115
|
+
var _options2, query, api, rst, _yield$rst$json, data;
|
|
116
|
+
|
|
117
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
118
|
+
while (1) {
|
|
119
|
+
switch (_context.prev = _context.next) {
|
|
120
|
+
case 0:
|
|
121
|
+
if (!Array.isArray(options)) {
|
|
122
|
+
_context.next = 2;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return _context.abrupt("return", options);
|
|
127
|
+
|
|
128
|
+
case 2:
|
|
129
|
+
if (!(Array.isArray(children) || _typeof(children) === 'object')) {
|
|
130
|
+
_context.next = 4;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return _context.abrupt("return", Array.isArray(children) ? children.map(function (child) {
|
|
135
|
+
return {
|
|
136
|
+
label: child.props.children,
|
|
137
|
+
value: child.props.value
|
|
138
|
+
};
|
|
139
|
+
}) : [{
|
|
140
|
+
label: children.props.children,
|
|
141
|
+
value: children.props.value
|
|
142
|
+
}]);
|
|
143
|
+
|
|
144
|
+
case 4:
|
|
145
|
+
if (!optionGroups) {
|
|
146
|
+
_context.next = 9;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (!dependFieldValue) {
|
|
151
|
+
_context.next = 9;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
_options2 = [];
|
|
156
|
+
optionGroups.forEach(function (_ref2) {
|
|
157
|
+
var parentKey = _ref2.parentKey,
|
|
158
|
+
_ref2$options = _ref2.options,
|
|
159
|
+
options = _ref2$options === void 0 ? [] : _ref2$options;
|
|
160
|
+
|
|
161
|
+
if (Array.isArray(dependFieldValue) ? dependFieldValue.includes(parentKey) : parentKey === dependFieldValue) {
|
|
162
|
+
_options2.push.apply(_options2, _toConsumableArray(options));
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
return _context.abrupt("return", _options2);
|
|
166
|
+
|
|
167
|
+
case 9:
|
|
168
|
+
if (!(selectDatasourceApi && datasourceKey)) {
|
|
169
|
+
_context.next = 27;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
query = Array.isArray(dependFieldValue) ? dependFieldValue.map(function (v) {
|
|
174
|
+
return "parent=".concat(v);
|
|
175
|
+
}).join('&') : dependFieldValue ? "parent=".concat(dependFieldValue) : '';
|
|
176
|
+
|
|
177
|
+
if (searchKey) {
|
|
178
|
+
query += "&search_keyword=".concat(searchKey);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
api = "".concat(selectDatasourceApi, "/").concat(datasourceKey);
|
|
182
|
+
_context.prev = 13;
|
|
183
|
+
_context.next = 16;
|
|
184
|
+
return fetch(query ? "".concat(api, "?").concat(query) : api);
|
|
185
|
+
|
|
186
|
+
case 16:
|
|
187
|
+
rst = _context.sent;
|
|
188
|
+
_context.next = 19;
|
|
189
|
+
return rst.json();
|
|
190
|
+
|
|
191
|
+
case 19:
|
|
192
|
+
_yield$rst$json = _context.sent;
|
|
193
|
+
data = _yield$rst$json.data;
|
|
194
|
+
return _context.abrupt("return", data || []);
|
|
195
|
+
|
|
196
|
+
case 24:
|
|
197
|
+
_context.prev = 24;
|
|
198
|
+
_context.t0 = _context["catch"](13);
|
|
199
|
+
return _context.abrupt("return", []);
|
|
200
|
+
|
|
201
|
+
case 27:
|
|
202
|
+
return _context.abrupt("return", []);
|
|
203
|
+
|
|
204
|
+
case 28:
|
|
205
|
+
case "end":
|
|
206
|
+
return _context.stop();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}, _callee, null, [[13, 24]]);
|
|
210
|
+
}));
|
|
211
|
+
|
|
212
|
+
return function calcOptions() {
|
|
213
|
+
return _ref.apply(this, arguments);
|
|
214
|
+
};
|
|
215
|
+
}();
|
|
216
|
+
|
|
217
|
+
calcOptions().then(function (newOptions) {
|
|
218
|
+
if (compareOptions(newOptions, optionsRef.current)) {
|
|
219
|
+
setOptions(newOptions);
|
|
220
|
+
optionsRef.current = newOptions;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
setUpdating(false);
|
|
224
|
+
});
|
|
225
|
+
}, [options, optionGroups, dependFieldValue, searchKey]);
|
|
226
|
+
return _options ? _jsx(Component, _objectSpread(_objectSpread({
|
|
227
|
+
options: _options
|
|
228
|
+
}, rest), {}, {
|
|
229
|
+
onSearch: setSearchKey,
|
|
230
|
+
optionsUpdating: updating
|
|
231
|
+
})) : null;
|
|
232
|
+
};
|
|
233
|
+
}
|
package/lib/checkbox/index.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { CheckboxProps, CheckboxGroupProps } from 'antd/es/checkbox';
|
|
2
2
|
import { FC, IglooComponentProps } from '@/types';
|
|
3
|
+
import { ComponentProps } from '../utils/option-utils';
|
|
4
|
+
import { DefaultOptionType } from 'rc-select/lib/Select';
|
|
3
5
|
import './style/index.less';
|
|
4
6
|
interface Props extends IglooComponentProps, CheckboxProps {
|
|
5
7
|
}
|
|
6
|
-
interface Option {
|
|
7
|
-
label?: any;
|
|
8
|
-
value?: string;
|
|
9
|
-
disabled?: boolean;
|
|
8
|
+
export interface Option extends DefaultOptionType {
|
|
10
9
|
extraInfo?: {
|
|
11
10
|
content: any;
|
|
12
11
|
shownTrigger: 'unchecked' | 'checked' | 'all';
|
|
13
12
|
};
|
|
14
13
|
}
|
|
15
|
-
export interface IProps extends IglooComponentProps, Omit<CheckboxGroupProps, 'options'
|
|
16
|
-
options: Option[];
|
|
14
|
+
export interface IProps extends IglooComponentProps, Omit<CheckboxGroupProps, 'options'>, ComponentProps {
|
|
17
15
|
className?: string;
|
|
16
|
+
radioType?: string;
|
|
17
|
+
options: Option[];
|
|
18
18
|
}
|
|
19
19
|
declare const IglooCheckbox: FC<Props>;
|
|
20
20
|
export default IglooCheckbox;
|
|
21
|
-
export declare const CheckboxGroup: FC<IProps>;
|
|
21
|
+
export declare const CheckboxGroup: FC<import("../utils/option-utils").HOCProps & IProps>;
|
package/lib/checkbox/index.js
CHANGED
|
@@ -19,6 +19,8 @@ var _checkbox = _interopRequireDefault(require("antd/es/checkbox"));
|
|
|
19
19
|
|
|
20
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
21
|
|
|
22
|
+
var _react = require("react");
|
|
23
|
+
|
|
22
24
|
var _typography = _interopRequireDefault(require("../typography"));
|
|
23
25
|
|
|
24
26
|
var _formMethods = _interopRequireDefault(require("../utils/form-methods"));
|
|
@@ -27,13 +29,31 @@ var _omit = _interopRequireDefault(require("omit.js"));
|
|
|
27
29
|
|
|
28
30
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
29
31
|
|
|
32
|
+
var _optionUtils = require("../utils/option-utils");
|
|
33
|
+
|
|
34
|
+
var _localeContext = _interopRequireDefault(require("../locale/locale-context"));
|
|
35
|
+
|
|
36
|
+
var _empty = _interopRequireDefault(require("../radio/style/empty.svg"));
|
|
37
|
+
|
|
30
38
|
require("./style/index.less");
|
|
31
39
|
|
|
32
|
-
var _excluded = ["className", "options", "value"],
|
|
40
|
+
var _excluded = ["className", "options", "value", "clearWhenOptionsUpdated"],
|
|
33
41
|
_excluded2 = ["label", "value", "extraInfo"];
|
|
34
42
|
|
|
35
43
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
36
44
|
|
|
45
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
46
|
+
|
|
47
|
+
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."); }
|
|
48
|
+
|
|
49
|
+
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); }
|
|
50
|
+
|
|
51
|
+
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; }
|
|
52
|
+
|
|
53
|
+
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; }
|
|
54
|
+
|
|
55
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
56
|
+
|
|
37
57
|
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; }
|
|
38
58
|
|
|
39
59
|
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; }
|
|
@@ -60,17 +80,54 @@ IglooCheckbox.formItemPropsHandler = function (config) {
|
|
|
60
80
|
var _default = IglooCheckbox;
|
|
61
81
|
exports.default = _default;
|
|
62
82
|
|
|
63
|
-
var
|
|
83
|
+
var InnerCheckboxGroup = function InnerCheckboxGroup(_ref) {
|
|
64
84
|
var className = _ref.className,
|
|
65
85
|
_ref$options = _ref.options,
|
|
66
86
|
options = _ref$options === void 0 ? [] : _ref$options,
|
|
67
87
|
value = _ref.value,
|
|
88
|
+
_ref$clearWhenOptions = _ref.clearWhenOptionsUpdated,
|
|
89
|
+
clearWhenOptionsUpdated = _ref$clearWhenOptions === void 0 ? false : _ref$clearWhenOptions,
|
|
68
90
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
69
91
|
|
|
70
|
-
|
|
92
|
+
var _useState = (0, _react.useState)(value),
|
|
93
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
94
|
+
selected = _useState2[0],
|
|
95
|
+
setSelected = _useState2[1];
|
|
96
|
+
|
|
97
|
+
var originOptions = (0, _react.useRef)(options);
|
|
98
|
+
|
|
99
|
+
var _useContext = (0, _react.useContext)(_localeContext.default),
|
|
100
|
+
formatMessage = _useContext.formatMessage;
|
|
101
|
+
|
|
102
|
+
(0, _react.useEffect)(function () {
|
|
103
|
+
typeof rest.onChange === 'function' && value !== selected && rest.onChange(selected);
|
|
104
|
+
}, [selected]);
|
|
105
|
+
(0, _react.useEffect)(function () {
|
|
106
|
+
setSelected(value);
|
|
107
|
+
}, [value]);
|
|
108
|
+
(0, _react.useEffect)(function () {
|
|
109
|
+
var setFieldValue = rest.setFieldValue;
|
|
110
|
+
|
|
111
|
+
if ((0, _optionUtils.compareOptions)(options, originOptions.current)) {
|
|
112
|
+
if (clearWhenOptionsUpdated) {
|
|
113
|
+
typeof setFieldValue === 'function' && setFieldValue();
|
|
114
|
+
} else {
|
|
115
|
+
var foundValue = options.find(function (option) {
|
|
116
|
+
return Array.isArray(value) ? value.includes(option.value) : option.value === value;
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
if (!foundValue && value !== undefined) {
|
|
120
|
+
typeof setFieldValue === 'function' && setFieldValue();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
originOptions.current = options;
|
|
125
|
+
}
|
|
126
|
+
}, [options]);
|
|
127
|
+
return (0, _jsxRuntime.jsxs)(_checkbox.default.Group, _objectSpread(_objectSpread({}, (0, _omit.default)(rest, _formMethods.default)), {}, {
|
|
71
128
|
className: (0, _classnames.default)('igloo-checkbox-group', className),
|
|
72
129
|
value: value,
|
|
73
|
-
children: (0, _jsxRuntime.jsx)(_row.default, {
|
|
130
|
+
children: [(0, _jsxRuntime.jsx)(_row.default, {
|
|
74
131
|
gutter: [8, 8],
|
|
75
132
|
children: options.map(function (_ref2) {
|
|
76
133
|
var label = _ref2.label,
|
|
@@ -94,10 +151,35 @@ var CheckboxGroup = function CheckboxGroup(_ref) {
|
|
|
94
151
|
})]
|
|
95
152
|
}, key);
|
|
96
153
|
})
|
|
97
|
-
})
|
|
154
|
+
}), !options.length && (0, _jsxRuntime.jsxs)("div", {
|
|
155
|
+
style: {
|
|
156
|
+
display: 'flex',
|
|
157
|
+
flexDirection: 'column',
|
|
158
|
+
background: '#f9f9f9',
|
|
159
|
+
padding: 16,
|
|
160
|
+
alignItems: 'center'
|
|
161
|
+
},
|
|
162
|
+
children: [(0, _jsxRuntime.jsx)("img", {
|
|
163
|
+
src: _empty.default,
|
|
164
|
+
style: {
|
|
165
|
+
width: 32,
|
|
166
|
+
height: 24
|
|
167
|
+
}
|
|
168
|
+
}), (0, _jsxRuntime.jsx)(_typography.default, {
|
|
169
|
+
level: "h5",
|
|
170
|
+
style: {
|
|
171
|
+
color: '#212121',
|
|
172
|
+
marginTop: 8
|
|
173
|
+
},
|
|
174
|
+
children: formatMessage({
|
|
175
|
+
id: 'There are no options available currently'
|
|
176
|
+
})
|
|
177
|
+
})]
|
|
178
|
+
})]
|
|
98
179
|
}));
|
|
99
180
|
};
|
|
100
181
|
|
|
182
|
+
var CheckboxGroup = (0, _optionUtils.optionsHOC)(InnerCheckboxGroup);
|
|
101
183
|
exports.CheckboxGroup = CheckboxGroup;
|
|
102
184
|
|
|
103
185
|
CheckboxGroup.formItemPropsHandler = function () {
|
package/lib/form/elements.js
CHANGED
|
@@ -35,6 +35,8 @@ var _render = _interopRequireDefault(require("./render"));
|
|
|
35
35
|
|
|
36
36
|
var _typography = _interopRequireDefault(require("../typography"));
|
|
37
37
|
|
|
38
|
+
var _searchBox = _interopRequireDefault(require("../search-box"));
|
|
39
|
+
|
|
38
40
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
39
41
|
|
|
40
42
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -71,7 +73,8 @@ var elementMap = {
|
|
|
71
73
|
InputDate: _input.InputDate,
|
|
72
74
|
Confirmation: _confirmation.default,
|
|
73
75
|
ExpiryDate: _input.ExpiryDate,
|
|
74
|
-
Typography: _typography.default
|
|
76
|
+
Typography: _typography.default,
|
|
77
|
+
SearchBox: _searchBox.default
|
|
75
78
|
};
|
|
76
79
|
|
|
77
80
|
var Unknown = function Unknown() {
|
package/lib/index.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export { default as MobileInsurerDetail } from './mobile-insurer-detail';
|
|
|
35
35
|
export { default as Layout } from './layout';
|
|
36
36
|
export { default as DetailPanel } from './detail-panel';
|
|
37
37
|
export { default as message } from './global-message';
|
|
38
|
+
export { default as SearchBox } from './search-box';
|
|
38
39
|
export { default as FreeForm } from './free-form';
|
|
39
40
|
export { default as FormItem } from './free-form/element';
|
|
40
41
|
export { default as FormPages } from './free-form/pages';
|
package/lib/index.js
CHANGED
|
@@ -66,6 +66,7 @@ var _exportNames = {
|
|
|
66
66
|
Layout: true,
|
|
67
67
|
DetailPanel: true,
|
|
68
68
|
message: true,
|
|
69
|
+
SearchBox: true,
|
|
69
70
|
FreeForm: true,
|
|
70
71
|
FormItem: true,
|
|
71
72
|
FormPages: true,
|
|
@@ -405,6 +406,12 @@ Object.defineProperty(exports, "RedButton", {
|
|
|
405
406
|
return _button.RedButton;
|
|
406
407
|
}
|
|
407
408
|
});
|
|
409
|
+
Object.defineProperty(exports, "SearchBox", {
|
|
410
|
+
enumerable: true,
|
|
411
|
+
get: function get() {
|
|
412
|
+
return _searchBox.default;
|
|
413
|
+
}
|
|
414
|
+
});
|
|
408
415
|
Object.defineProperty(exports, "Select", {
|
|
409
416
|
enumerable: true,
|
|
410
417
|
get: function get() {
|
|
@@ -570,6 +577,8 @@ var _detailPanel = _interopRequireDefault(require("./detail-panel"));
|
|
|
570
577
|
|
|
571
578
|
var _globalMessage = _interopRequireDefault(require("./global-message"));
|
|
572
579
|
|
|
580
|
+
var _searchBox = _interopRequireDefault(require("./search-box"));
|
|
581
|
+
|
|
573
582
|
var _freeForm = _interopRequireDefault(require("./free-form"));
|
|
574
583
|
|
|
575
584
|
var _element = _interopRequireDefault(require("./free-form/element"));
|
package/lib/input/amount.js
CHANGED
|
@@ -63,8 +63,15 @@ var Amount = function Amount(_ref) {
|
|
|
63
63
|
var handleOnBlur = function handleOnBlur(e) {
|
|
64
64
|
var onChange = rest.onChange;
|
|
65
65
|
|
|
66
|
-
if (typeof value === 'string'
|
|
67
|
-
|
|
66
|
+
if (typeof value === 'string') {
|
|
67
|
+
if (value.endsWith('.')) {
|
|
68
|
+
e.target.value = value.replace('.', '');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (value.endsWith('0') && value.includes('.')) {
|
|
72
|
+
e.target.value = value.replace(/[0]+$/, '');
|
|
73
|
+
}
|
|
74
|
+
|
|
68
75
|
onChange && onChange(e);
|
|
69
76
|
}
|
|
70
77
|
};
|
|
@@ -91,7 +98,11 @@ Amount.formItemPropsHandler = function (_ref2) {
|
|
|
91
98
|
getValueFromEvent: function getValueFromEvent(e) {
|
|
92
99
|
var value = e.target.value;
|
|
93
100
|
var str = value.replaceAll(seperator, '').replaceAll(/[^0-9\.]/g, '');
|
|
94
|
-
|
|
101
|
+
|
|
102
|
+
if (str.endsWith('.') || str.includes('.') && str.endsWith('0')) {
|
|
103
|
+
return str;
|
|
104
|
+
}
|
|
105
|
+
|
|
95
106
|
return str ? parseFloat(str) : undefined;
|
|
96
107
|
},
|
|
97
108
|
rules: [{
|
|
@@ -30,8 +30,15 @@ var IglooInputNumber = function IglooInputNumber(props) {
|
|
|
30
30
|
var value = props.value,
|
|
31
31
|
onChange = props.onChange;
|
|
32
32
|
|
|
33
|
-
if (typeof value === 'string'
|
|
34
|
-
|
|
33
|
+
if (typeof value === 'string') {
|
|
34
|
+
if (value.endsWith('.')) {
|
|
35
|
+
e.target.value = value.replace('.', '');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (value.endsWith('0') && value.includes('.')) {
|
|
39
|
+
e.target.value = value.replace(/[0]+$/, '');
|
|
40
|
+
}
|
|
41
|
+
|
|
35
42
|
onChange && onChange(e);
|
|
36
43
|
}
|
|
37
44
|
};
|
|
@@ -49,7 +56,11 @@ IglooInputNumber.formItemPropsHandler = function (config) {
|
|
|
49
56
|
getValueFromEvent: function getValueFromEvent(e) {
|
|
50
57
|
var value = e.target.value;
|
|
51
58
|
var str = value.replaceAll(/[^0-9\.]/g, '');
|
|
52
|
-
|
|
59
|
+
|
|
60
|
+
if (str.endsWith('.') || str.includes('.') && str.endsWith('0')) {
|
|
61
|
+
return str;
|
|
62
|
+
}
|
|
63
|
+
|
|
53
64
|
return str ? parseFloat(str) : undefined;
|
|
54
65
|
}
|
|
55
66
|
};
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"Data Processed": "Data Processed",
|
|
22
22
|
"Data Processing...": "Data Processing...",
|
|
23
23
|
"Date": "Date",
|
|
24
|
+
"Done": "Done",
|
|
24
25
|
"Drag and drop a file here": "Drag and drop a file here",
|
|
25
26
|
"Edit": "Edit",
|
|
26
27
|
"Error Report": "Error Report",
|
|
@@ -56,10 +57,13 @@
|
|
|
56
57
|
"Result": "Result",
|
|
57
58
|
"Result: Success {success_num}; Error {fail_num}": "Result: Success {success_num}; Error {fail_num}",
|
|
58
59
|
"Rows per page": "Rows per page",
|
|
60
|
+
"Search": "Search",
|
|
61
|
+
"Searching...": "Searching...",
|
|
59
62
|
"Select All": "Select All",
|
|
60
63
|
"Send OTP": "Send OTP",
|
|
61
64
|
"Submit": "Submit",
|
|
62
65
|
"The file type is not supported.": "The file type is not supported.",
|
|
66
|
+
"There are no options available currently": "There are no options available currently",
|
|
63
67
|
"This Month": "This Month",
|
|
64
68
|
"Unselect All": "Unselect All",
|
|
65
69
|
"Uploading": "Uploading",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"Data Processed": "Data Terproses",
|
|
22
22
|
"Data Processing...": "Data Diproses",
|
|
23
23
|
"Date": "Tanggal",
|
|
24
|
+
"Done": "Selesai",
|
|
24
25
|
"Drag and drop a file here": "Geser dan Letakkan Dokumen disini",
|
|
25
26
|
"Edit": "Ubah",
|
|
26
27
|
"Error Report": "Laporan Kesalahan",
|
|
@@ -56,10 +57,13 @@
|
|
|
56
57
|
"Result": "Hasil",
|
|
57
58
|
"Result: Success {success_num}; Error {fail_num}": "Hasil: Sukses {success_num}; Kesalahan {fail_num}",
|
|
58
59
|
"Rows per page": "Baris per halaman",
|
|
60
|
+
"Search": "Mencari",
|
|
61
|
+
"Searching...": "Mencari...",
|
|
59
62
|
"Select All": "Pilih Semua",
|
|
60
63
|
"Send OTP": "Kirim OTP",
|
|
61
64
|
"Submit": "Ajukan",
|
|
62
65
|
"The file type is not supported.": "Jenis file tidak didukung.",
|
|
66
|
+
"There are no options available currently": "Tidak ada opsi yang tersedia saat ini",
|
|
63
67
|
"This Month": "Bulan ini",
|
|
64
68
|
"Unselect All": "Batalkan semua",
|
|
65
69
|
"Uploading": "Mengunggah",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"Data Processed": "ประมวลข้อมูลสำเร็จแล้ว",
|
|
22
22
|
"Data Processing...": "กำลังประมวลผลข้อมูล...",
|
|
23
23
|
"Date": "วันที่",
|
|
24
|
+
"Done": "เสร็จแล้ว",
|
|
24
25
|
"Drag and drop a file here": "ลากและวางไฟล์มาที่นี่",
|
|
25
26
|
"Edit": "แก้ไข",
|
|
26
27
|
"Error Report": "รายงานข้อผิดพลาด",
|
|
@@ -56,10 +57,13 @@
|
|
|
56
57
|
"Result": "ผลลัพธ์",
|
|
57
58
|
"Result: Success {success_num}; Error {fail_num}": "ผลลัพธ์: สำเร็จ {success_num}; ข้อผิดพลาด {fail_num}",
|
|
58
59
|
"Rows per page": "แถวต่อหน้า",
|
|
60
|
+
"Search": "ค้นหา",
|
|
61
|
+
"Searching...": "กำลังค้นหา...",
|
|
59
62
|
"Select All": "เลือกทั้งหมด",
|
|
60
63
|
"Send OTP": "ส่ง OTP",
|
|
61
64
|
"Submit": "ส่ง/ยืนยัน",
|
|
62
65
|
"The file type is not supported.": "ประเภทไฟล์ไม่รองรับ",
|
|
66
|
+
"There are no options available currently": "ไม่มีตัวเลือกในขณะนี้",
|
|
63
67
|
"This Month": "เดือนนี้",
|
|
64
68
|
"Unselect All": "ไม่เลือกทั้งหมด",
|
|
65
69
|
"Uploading": "กำลังอัพโหลด",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"Data Processed": "Dữ liệu đã xử lý",
|
|
22
22
|
"Data Processing...": "Đang xử lý dữ liệu...",
|
|
23
23
|
"Date": "Ngày",
|
|
24
|
+
"Done": "Xong",
|
|
24
25
|
"Drag and drop a file here": "Thả tệp tin vào đây",
|
|
25
26
|
"Edit": "Sửa",
|
|
26
27
|
"Error Report": "Báo cáo lỗi",
|
|
@@ -56,10 +57,13 @@
|
|
|
56
57
|
"Result": "Kết quả",
|
|
57
58
|
"Result: Success {success_num}; Error {fail_num}": "Kết quả: sự thành công {success_num}; lỗi {fail_num}",
|
|
58
59
|
"Rows per page": "Dòng trên trang",
|
|
60
|
+
"Search": "Tìm kiếm",
|
|
61
|
+
"Searching...": "Đang tìm kiếm...",
|
|
59
62
|
"Select All": "Chọn tất cả",
|
|
60
63
|
"Send OTP": "Gửi OTP",
|
|
61
64
|
"Submit": "Gửi",
|
|
62
65
|
"The file type is not supported.": "Loại tệp không được hỗ trợ.",
|
|
66
|
+
"There are no options available currently": "Hiện tại không có tùy chọn nào",
|
|
63
67
|
"This Month": "Tháng này",
|
|
64
68
|
"Unselect All": "Hủy chọn tất cả",
|
|
65
69
|
"Uploading": "Đang tải lên",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"Data Processed": "已导入",
|
|
22
22
|
"Data Processing...": "导入中",
|
|
23
23
|
"Date": "日期",
|
|
24
|
+
"Done": "完成",
|
|
24
25
|
"Drag and drop a file here": "拖拽一个文件到这里",
|
|
25
26
|
"Edit": "编辑",
|
|
26
27
|
"Error Report": "错误报告",
|
|
@@ -56,10 +57,13 @@
|
|
|
56
57
|
"Result": "结果",
|
|
57
58
|
"Result: Success {success_num}; Error {fail_num}": "结果:成功 {success_num}; 失败 {fail_num}",
|
|
58
59
|
"Rows per page": "每页条数",
|
|
60
|
+
"Search": "搜索",
|
|
61
|
+
"Searching...": "正在搜索...",
|
|
59
62
|
"Select All": "全选",
|
|
60
63
|
"Send OTP": "发送OTP",
|
|
61
64
|
"Submit": "提交",
|
|
62
65
|
"The file type is not supported.": "不支持上传该类型的文件。",
|
|
66
|
+
"There are no options available currently": "当前没有可用的选项",
|
|
63
67
|
"This Month": "当月",
|
|
64
68
|
"Unselect All": "反选",
|
|
65
69
|
"Uploading": "上传中",
|