iglooform 2.5.3 → 2.5.4

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.
Files changed (65) hide show
  1. package/es/checkbox/index.d.ts +7 -7
  2. package/es/checkbox/index.js +5 -85
  3. package/es/form/elements.js +1 -3
  4. package/es/index.d.ts +0 -1
  5. package/es/index.js +0 -1
  6. package/es/input/amount.js +3 -14
  7. package/es/input/input-number.js +3 -14
  8. package/es/locale/en-US/messages.json +0 -4
  9. package/es/locale/id-ID/messages.json +0 -4
  10. package/es/locale/th-TH/messages.json +0 -4
  11. package/es/locale/vi-VN/messages.json +0 -4
  12. package/es/locale/zh-CN/messages.json +0 -4
  13. package/es/locale/zh-TW/messages.json +0 -5
  14. package/es/media/media.js +3 -6
  15. package/es/media/preview.js +13 -13
  16. package/es/radio/index.d.ts +6 -6
  17. package/es/radio/index.js +22 -79
  18. package/es/radio/radio-group-with-other.d.ts +1 -1
  19. package/es/radio/radio-group-with-other.js +4 -41
  20. package/es/select/attached-select.d.ts +12 -2
  21. package/es/select/attached-select.js +186 -27
  22. package/es/upload-photo/index.js +32 -33
  23. package/es/upload-photo/media.js +7 -6
  24. package/es/upload-preview/media.js +13 -13
  25. package/lib/checkbox/index.d.ts +7 -7
  26. package/lib/checkbox/index.js +5 -87
  27. package/lib/form/elements.js +1 -4
  28. package/lib/index.d.ts +0 -1
  29. package/lib/index.js +0 -9
  30. package/lib/input/amount.js +3 -14
  31. package/lib/input/input-number.js +3 -14
  32. package/lib/locale/en-US/messages.json +0 -4
  33. package/lib/locale/id-ID/messages.json +0 -4
  34. package/lib/locale/th-TH/messages.json +0 -4
  35. package/lib/locale/vi-VN/messages.json +0 -4
  36. package/lib/locale/zh-CN/messages.json +0 -4
  37. package/lib/locale/zh-TW/messages.json +0 -5
  38. package/lib/media/media.js +3 -6
  39. package/lib/media/preview.js +15 -13
  40. package/lib/radio/index.d.ts +6 -6
  41. package/lib/radio/index.js +22 -83
  42. package/lib/radio/radio-group-with-other.d.ts +1 -1
  43. package/lib/radio/radio-group-with-other.js +3 -41
  44. package/lib/select/attached-select.d.ts +12 -2
  45. package/lib/select/attached-select.js +186 -26
  46. package/lib/upload-photo/index.js +32 -33
  47. package/lib/upload-photo/media.js +9 -6
  48. package/lib/upload-preview/media.js +13 -13
  49. package/package.json +1 -1
  50. package/es/radio/style/empty.svg +0 -12
  51. package/es/search-box/index.d.ts +0 -31
  52. package/es/search-box/index.js +0 -266
  53. package/es/search-box/style/index.d.ts +0 -1
  54. package/es/search-box/style/index.js +0 -1
  55. package/es/search-box/style/index.less +0 -162
  56. package/es/utils/option-utils.d.ts +0 -24
  57. package/es/utils/option-utils.js +0 -233
  58. package/lib/radio/style/empty.svg +0 -12
  59. package/lib/search-box/index.d.ts +0 -31
  60. package/lib/search-box/index.js +0 -287
  61. package/lib/search-box/style/index.d.ts +0 -1
  62. package/lib/search-box/style/index.js +0 -3
  63. package/lib/search-box/style/index.less +0 -162
  64. package/lib/utils/option-utils.d.ts +0 -24
  65. package/lib/utils/option-utils.js +0 -250
@@ -1,162 +0,0 @@
1
- .igloo-search-box-modal-container {
2
- .ant-modal-body {
3
- .igloo-search-box-modal-options {
4
- max-height: calc(100vh - 340px - 172px);
5
- overflow: scroll;
6
- }
7
-
8
- .ant-input-affix-wrapper-status-error {
9
- border-color: #d9d9d9 !important;
10
- }
11
-
12
- .igloo-search-box-modal-multiple-top {
13
- padding: 8px;
14
- display: flex;
15
- align-items: center;
16
- justify-content: space-between;
17
- }
18
-
19
- .igloo-search-box-searching {
20
- margin-top: 24px;
21
- display: flex;
22
- align-items: center;
23
-
24
- @keyframes rotation {
25
- from {
26
- transform: rotate(0deg);
27
- }
28
- to {
29
- transform: rotate(360deg);
30
- }
31
- }
32
-
33
- & > .igloo-icon {
34
- font-size: 24px;
35
- color: #5858ff;
36
- margin-right: 8px;
37
- animation: rotation 3s linear infinite;
38
- }
39
- }
40
-
41
- .igloo-search-box-modal-select-item {
42
- padding: 8px;
43
- display: flex;
44
- align-items: center;
45
-
46
- .igloo-search-box-modal-select-item-checkbox {
47
- margin-right: 10px;
48
-
49
- .ant-checkbox-checked .ant-checkbox-inner {
50
- background-color: #666666;
51
- }
52
- }
53
-
54
- &:hover {
55
- cursor: pointer;
56
- background: #f9f9f9;
57
- }
58
- }
59
-
60
- .igloo-search-box-active-select-item {
61
- background-color: #f6f6ff;
62
- }
63
- }
64
- }
65
-
66
- .igloo-search-box-modal-container-mobile {
67
- top: 0px !important;
68
- margin: 0px !important;
69
- width: 100vw !important;
70
- max-width: 100vw !important;
71
- height: 100vh !important;
72
-
73
- .igloo-search-box-modal-mobile-title {
74
- display: flex;
75
- align-items: center;
76
- width: 100%;
77
- background-color: white;
78
-
79
- .igloo-icon {
80
- font-size: 24px;
81
- margin-right: 8px;
82
- }
83
- }
84
-
85
- .ant-modal-content {
86
- position: relative;
87
- height: 100%;
88
-
89
- .ant-modal-body {
90
- height: 100%;
91
- max-height: calc(100vh - 140px - 60px);
92
- padding: 24px 16px 0px 16px;
93
-
94
- .igloo-search-box-modal-options {
95
- max-height: calc(100vh - 140px - 60px - 150px);
96
- overflow: scroll;
97
- }
98
-
99
- .ant-input-affix-wrapper-status-error {
100
- border-color: #d9d9d9 !important;
101
- }
102
-
103
- .igloo-search-box-modal-multiple-top {
104
- padding: 8px;
105
- display: flex;
106
- align-items: center;
107
- justify-content: space-between;
108
- }
109
-
110
- .igloo-search-box-searching {
111
- margin-top: 24px;
112
- display: flex;
113
- align-items: center;
114
-
115
- @keyframes rotation {
116
- from {
117
- transform: rotate(0deg);
118
- }
119
- to {
120
- transform: rotate(360deg);
121
- }
122
- }
123
-
124
- & > .igloo-icon {
125
- font-size: 24px;
126
- color: #5858ff;
127
- margin-right: 8px;
128
- animation: rotation 3s linear infinite;
129
- }
130
- }
131
-
132
- .igloo-search-box-modal-select-item {
133
- padding: 8px;
134
- display: flex;
135
- align-items: center;
136
-
137
- .igloo-search-box-modal-select-item-checkbox {
138
- margin-right: 10px;
139
-
140
- .ant-checkbox-checked .ant-checkbox-inner {
141
- background-color: #666666;
142
- }
143
- }
144
-
145
- &:hover {
146
- cursor: pointer;
147
- background: #f9f9f9;
148
- }
149
- }
150
-
151
- .igloo-search-box-active-select-item {
152
- background-color: #f6f6ff;
153
- }
154
- }
155
-
156
- .ant-modal-footer {
157
- position: absolute;
158
- bottom: 0px;
159
- width: 100%;
160
- }
161
- }
162
- }
@@ -1,24 +0,0 @@
1
- import { FC, IglooComponentProps } from '../types';
2
- import { FormInstance } from 'antd/es/form';
3
- import { NamePath } from 'antd/es/form/interface';
4
- import { SelectProps, SelectValue } from 'antd/es/select';
5
- export declare const compareOptions: (newOptions: any[], oldOptions?: any[] | undefined) => boolean;
6
- declare type Options = SelectProps<SelectValue>['options'];
7
- export interface HOCProps extends IglooComponentProps {
8
- options?: Options;
9
- getOptions?: (form: FormInstance) => any[];
10
- optionGroups?: {
11
- parentKey: string;
12
- options: Options;
13
- }[];
14
- datasourceKey?: string;
15
- datasourceApi?: string;
16
- dependField?: NamePath;
17
- passCompareOptions?: boolean;
18
- }
19
- export interface ComponentProps extends IglooComponentProps {
20
- options?: Options;
21
- clearWhenOptionsUpdated?: boolean;
22
- }
23
- export declare function optionsHOC<T>(Component: FC<T>): FC<HOCProps & T>;
24
- export {};
@@ -1,250 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.compareOptions = void 0;
7
- exports.optionsHOC = optionsHOC;
8
-
9
- var _jsxRuntime = require("react/jsx-runtime");
10
-
11
- var _react = require("react");
12
-
13
- var _formContext = _interopRequireDefault(require("../form-context"));
14
-
15
- var _invariant = _interopRequireDefault(require("invariant"));
16
-
17
- var _excluded = ["options", "optionGroups", "getOptions", "datasourceKey", "dependField", "children"];
18
-
19
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
-
21
- 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; }
22
-
23
- 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; }
24
-
25
- 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; }
26
-
27
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
28
-
29
- 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."); }
30
-
31
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
32
-
33
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
34
-
35
- 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); }
36
-
37
- 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); } }
38
-
39
- 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); }); }; }
40
-
41
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
42
-
43
- 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."); }
44
-
45
- 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); }
46
-
47
- 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; }
48
-
49
- 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; }
50
-
51
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
52
-
53
- 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; }
54
-
55
- 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; }
56
-
57
- var compareOptions = function compareOptions(newOptions, oldOptions) {
58
- if (!Array.isArray(oldOptions)) {
59
- return true;
60
- }
61
-
62
- if ((oldOptions === null || oldOptions === void 0 ? void 0 : oldOptions.length) !== newOptions.length) {
63
- return true;
64
- }
65
-
66
- if (Array.isArray(oldOptions)) {
67
- for (var i = 0; i < oldOptions.length; i++) {
68
- var newOption = oldOptions[i];
69
- var originOption = newOptions[i];
70
-
71
- if (newOption.label !== originOption.label || newOption.value !== originOption.value) {
72
- return true;
73
- }
74
- }
75
- }
76
-
77
- return false;
78
- };
79
-
80
- exports.compareOptions = compareOptions;
81
-
82
- function optionsHOC(Component) {
83
- return function (props) {
84
- var options = props.options,
85
- optionGroups = props.optionGroups,
86
- getOptions = props.getOptions,
87
- datasourceKey = props.datasourceKey,
88
- dependField = props.dependField,
89
- children = props.children,
90
- rest = _objectWithoutProperties(props, _excluded);
91
-
92
- var _useState = (0, _react.useState)(false),
93
- _useState2 = _slicedToArray(_useState, 2),
94
- updating = _useState2[0],
95
- setUpdating = _useState2[1];
96
-
97
- var _useState3 = (0, _react.useState)(),
98
- _useState4 = _slicedToArray(_useState3, 2),
99
- _options = _useState4[0],
100
- setOptions = _useState4[1];
101
-
102
- var _useState5 = (0, _react.useState)(),
103
- _useState6 = _slicedToArray(_useState5, 2),
104
- searchKey = _useState6[0],
105
- setSearchKey = _useState6[1];
106
-
107
- var optionsRef = (0, _react.useRef)(_options);
108
-
109
- var _useContext = (0, _react.useContext)(_formContext.default),
110
- selectDatasourceApi = _useContext.selectDatasourceApi;
111
-
112
- var getFormInstance = rest.getFormInstance;
113
- var form = typeof getFormInstance === 'function' && getFormInstance();
114
- var dependFieldValue = form && dependField && form.getFieldValue(dependField);
115
- var optionsFromGetOptions = typeof getOptions === 'function' && form && getOptions(form);
116
- (0, _react.useEffect)(function () {
117
- if (!Array.isArray(optionsFromGetOptions)) {
118
- return;
119
- }
120
-
121
- if (compareOptions(optionsFromGetOptions, optionsRef.current)) {
122
- optionsRef.current = optionsFromGetOptions;
123
- setOptions(optionsFromGetOptions);
124
- }
125
- }, [optionsFromGetOptions]);
126
- (0, _invariant.default)(datasourceKey && selectDatasourceApi || !datasourceKey, 'Please provide selectDatasourceApi in Form props');
127
- (0, _react.useEffect)(function () {
128
- setUpdating(true);
129
-
130
- var calcOptions = /*#__PURE__*/function () {
131
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
132
- var _options2, query, api, rst, _yield$rst$json, data;
133
-
134
- return regeneratorRuntime.wrap(function _callee$(_context) {
135
- while (1) {
136
- switch (_context.prev = _context.next) {
137
- case 0:
138
- if (!Array.isArray(options)) {
139
- _context.next = 2;
140
- break;
141
- }
142
-
143
- return _context.abrupt("return", options);
144
-
145
- case 2:
146
- if (!(Array.isArray(children) || _typeof(children) === 'object')) {
147
- _context.next = 4;
148
- break;
149
- }
150
-
151
- return _context.abrupt("return", Array.isArray(children) ? children.map(function (child) {
152
- return {
153
- label: child.props.children,
154
- value: child.props.value
155
- };
156
- }) : [{
157
- label: children.props.children,
158
- value: children.props.value
159
- }]);
160
-
161
- case 4:
162
- if (!optionGroups) {
163
- _context.next = 9;
164
- break;
165
- }
166
-
167
- if (!dependFieldValue) {
168
- _context.next = 9;
169
- break;
170
- }
171
-
172
- _options2 = [];
173
- optionGroups.forEach(function (_ref2) {
174
- var parentKey = _ref2.parentKey,
175
- _ref2$options = _ref2.options,
176
- options = _ref2$options === void 0 ? [] : _ref2$options;
177
-
178
- if (Array.isArray(dependFieldValue) ? dependFieldValue.includes(parentKey) : parentKey === dependFieldValue) {
179
- _options2.push.apply(_options2, _toConsumableArray(options));
180
- }
181
- });
182
- return _context.abrupt("return", _options2);
183
-
184
- case 9:
185
- if (!(selectDatasourceApi && datasourceKey)) {
186
- _context.next = 27;
187
- break;
188
- }
189
-
190
- query = Array.isArray(dependFieldValue) ? dependFieldValue.map(function (v) {
191
- return "parent=".concat(v);
192
- }).join('&') : dependFieldValue ? "parent=".concat(dependFieldValue) : '';
193
-
194
- if (searchKey) {
195
- query += "&search_keyword=".concat(searchKey);
196
- }
197
-
198
- api = "".concat(selectDatasourceApi, "/").concat(datasourceKey);
199
- _context.prev = 13;
200
- _context.next = 16;
201
- return fetch(query ? "".concat(api, "?").concat(query) : api);
202
-
203
- case 16:
204
- rst = _context.sent;
205
- _context.next = 19;
206
- return rst.json();
207
-
208
- case 19:
209
- _yield$rst$json = _context.sent;
210
- data = _yield$rst$json.data;
211
- return _context.abrupt("return", data || []);
212
-
213
- case 24:
214
- _context.prev = 24;
215
- _context.t0 = _context["catch"](13);
216
- return _context.abrupt("return", []);
217
-
218
- case 27:
219
- return _context.abrupt("return", []);
220
-
221
- case 28:
222
- case "end":
223
- return _context.stop();
224
- }
225
- }
226
- }, _callee, null, [[13, 24]]);
227
- }));
228
-
229
- return function calcOptions() {
230
- return _ref.apply(this, arguments);
231
- };
232
- }();
233
-
234
- calcOptions().then(function (newOptions) {
235
- if (compareOptions(newOptions, optionsRef.current)) {
236
- setOptions(newOptions);
237
- optionsRef.current = newOptions;
238
- }
239
-
240
- setUpdating(false);
241
- });
242
- }, [options, optionGroups, dependFieldValue, searchKey]);
243
- return _options ? (0, _jsxRuntime.jsx)(Component, _objectSpread(_objectSpread({
244
- options: _options
245
- }, rest), {}, {
246
- onSearch: setSearchKey,
247
- optionsUpdating: updating
248
- })) : null;
249
- };
250
- }