iglooform 2.5.2 → 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.
Files changed (51) hide show
  1. package/es/checkbox/index.d.ts +7 -7
  2. package/es/checkbox/index.js +85 -5
  3. package/es/form/elements.js +3 -1
  4. package/es/index.d.ts +1 -0
  5. package/es/index.js +1 -0
  6. package/es/locale/en-US/messages.json +4 -0
  7. package/es/locale/id-ID/messages.json +4 -0
  8. package/es/locale/th-TH/messages.json +4 -0
  9. package/es/locale/vi-VN/messages.json +4 -0
  10. package/es/locale/zh-CN/messages.json +4 -0
  11. package/es/locale/zh-TW/messages.json +5 -0
  12. package/es/radio/index.d.ts +6 -6
  13. package/es/radio/index.js +79 -22
  14. package/es/radio/radio-group-with-other.d.ts +1 -1
  15. package/es/radio/radio-group-with-other.js +41 -4
  16. package/es/radio/style/empty.svg +12 -0
  17. package/es/search-box/index.d.ts +31 -0
  18. package/es/search-box/index.js +266 -0
  19. package/es/search-box/style/index.d.ts +1 -0
  20. package/es/search-box/style/index.js +1 -0
  21. package/es/search-box/style/index.less +162 -0
  22. package/es/select/attached-select.d.ts +2 -12
  23. package/es/select/attached-select.js +28 -198
  24. package/es/utils/option-utils.d.ts +24 -0
  25. package/es/utils/option-utils.js +233 -0
  26. package/lib/checkbox/index.d.ts +7 -7
  27. package/lib/checkbox/index.js +87 -5
  28. package/lib/form/elements.js +4 -1
  29. package/lib/index.d.ts +1 -0
  30. package/lib/index.js +9 -0
  31. package/lib/locale/en-US/messages.json +4 -0
  32. package/lib/locale/id-ID/messages.json +4 -0
  33. package/lib/locale/th-TH/messages.json +4 -0
  34. package/lib/locale/vi-VN/messages.json +4 -0
  35. package/lib/locale/zh-CN/messages.json +4 -0
  36. package/lib/locale/zh-TW/messages.json +5 -0
  37. package/lib/radio/index.d.ts +6 -6
  38. package/lib/radio/index.js +83 -22
  39. package/lib/radio/radio-group-with-other.d.ts +1 -1
  40. package/lib/radio/radio-group-with-other.js +41 -3
  41. package/lib/radio/style/empty.svg +12 -0
  42. package/lib/search-box/index.d.ts +31 -0
  43. package/lib/search-box/index.js +287 -0
  44. package/lib/search-box/style/index.d.ts +1 -0
  45. package/lib/search-box/style/index.js +3 -0
  46. package/lib/search-box/style/index.less +162 -0
  47. package/lib/select/attached-select.d.ts +2 -12
  48. package/lib/select/attached-select.js +27 -198
  49. package/lib/utils/option-utils.d.ts +24 -0
  50. package/lib/utils/option-utils.js +250 -0
  51. package/package.json +10 -9
@@ -0,0 +1,31 @@
1
+ import { FC, IglooComponentProps } from '../types';
2
+ import './style';
3
+ import { ComponentProps } from '../utils/option-utils';
4
+ declare const SearchBox: FC<import("../utils/option-utils").HOCProps & IglooComponentProps & {
5
+ className?: string | undefined;
6
+ onSearch?: any;
7
+ value?: any;
8
+ multiple?: boolean | undefined;
9
+ modalTitle?: string | undefined;
10
+ placeHolder?: string | undefined;
11
+ modalPlaceHolder?: string | undefined;
12
+ optionsUpdating?: boolean | undefined;
13
+ onChange?: any;
14
+ okButtonProps?: Partial<{
15
+ href: string;
16
+ target?: string | undefined;
17
+ onClick?: import("react").MouseEventHandler<HTMLElement> | undefined;
18
+ } & import("antd/lib/button/button").BaseButtonProps & Omit<import("react").AnchorHTMLAttributes<any>, "onClick" | "type"> & {
19
+ htmlType?: "button" | "submit" | "reset" | undefined;
20
+ onClick?: import("react").MouseEventHandler<HTMLElement> | undefined;
21
+ } & Omit<import("react").ButtonHTMLAttributes<any>, "onClick" | "type">> | undefined;
22
+ cancelButtonProps?: Partial<{
23
+ href: string;
24
+ target?: string | undefined;
25
+ onClick?: import("react").MouseEventHandler<HTMLElement> | undefined;
26
+ } & import("antd/lib/button/button").BaseButtonProps & Omit<import("react").AnchorHTMLAttributes<any>, "onClick" | "type"> & {
27
+ htmlType?: "button" | "submit" | "reset" | undefined;
28
+ onClick?: import("react").MouseEventHandler<HTMLElement> | undefined;
29
+ } & Omit<import("react").ButtonHTMLAttributes<any>, "onClick" | "type">> | undefined;
30
+ } & ComponentProps>;
31
+ export default SearchBox;
@@ -0,0 +1,266 @@
1
+ import "antd/es/grid/style";
2
+ import _Grid from "antd/es/grid";
3
+ var _excluded = ["value", "className", "options", "onSearch", "multiple", "modalTitle", "placeHolder", "modalPlaceHolder", "clearWhenOptionsUpdated", "okButtonProps", "cancelButtonProps", "optionsUpdating"];
4
+
5
+ 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; }
6
+
7
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
+
9
+ 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."); }
10
+
11
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
+
13
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
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
+
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; }
28
+
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; }
30
+
31
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
32
+ import classnames from 'classnames';
33
+ import { SearchOutlined, LoadingOutlined, ArrowLeftOutlined } from 'iglooicon';
34
+ import Modal from '@/modal';
35
+ import Input from '@/input';
36
+ import CheckBox from '@/checkbox';
37
+ import Typography from '@/typography';
38
+ import Button from '@/button';
39
+ import { LocaleContext } from '../locale';
40
+ import { useState, useContext, useEffect, useMemo } from 'react';
41
+ import './style';
42
+ import { optionsHOC } from '../utils/option-utils';
43
+
44
+ var IglooSearchBox = function IglooSearchBox(_ref) {
45
+ var valueProp = _ref.value,
46
+ className = _ref.className,
47
+ _ref$options = _ref.options,
48
+ options = _ref$options === void 0 ? [] : _ref$options,
49
+ onSearch = _ref.onSearch,
50
+ _ref$multiple = _ref.multiple,
51
+ multiple = _ref$multiple === void 0 ? false : _ref$multiple,
52
+ modalTitle = _ref.modalTitle,
53
+ placeHolder = _ref.placeHolder,
54
+ modalPlaceHolder = _ref.modalPlaceHolder,
55
+ _ref$clearWhenOptions = _ref.clearWhenOptionsUpdated,
56
+ clearWhenOptionsUpdated = _ref$clearWhenOptions === void 0 ? false : _ref$clearWhenOptions,
57
+ okButtonProps = _ref.okButtonProps,
58
+ cancelButtonProps = _ref.cancelButtonProps,
59
+ searching = _ref.optionsUpdating,
60
+ rest = _objectWithoutProperties(_ref, _excluded);
61
+
62
+ var _useContext = useContext(LocaleContext),
63
+ formatMessage = _useContext.formatMessage;
64
+
65
+ var modalTitleProps = modalTitle || formatMessage({
66
+ id: 'Search'
67
+ });
68
+ var useBreakpoint = _Grid.useBreakpoint;
69
+
70
+ var _useBreakpoint = useBreakpoint(),
71
+ md = _useBreakpoint.md;
72
+
73
+ var _useState = useState(false),
74
+ _useState2 = _slicedToArray(_useState, 2),
75
+ modalVisible = _useState2[0],
76
+ setModalVisible = _useState2[1];
77
+
78
+ var _useState3 = useState([]),
79
+ _useState4 = _slicedToArray(_useState3, 2),
80
+ selected = _useState4[0],
81
+ setSelected = _useState4[1];
82
+
83
+ var _useState5 = useState(''),
84
+ _useState6 = _slicedToArray(_useState5, 2),
85
+ modalInputValue = _useState6[0],
86
+ setModalInputValue = _useState6[1];
87
+
88
+ useEffect(function () {
89
+ var setFieldValue = rest.setFieldValue;
90
+
91
+ if (clearWhenOptionsUpdated) {
92
+ typeof setFieldValue === 'function' && setFieldValue();
93
+ } else {
94
+ var foundValue = options.find(function (option) {
95
+ return Array.isArray(valueProp) ? valueProp.includes(option.value) : option.value === valueProp;
96
+ });
97
+
98
+ if (!foundValue && valueProp !== undefined) {
99
+ typeof setFieldValue === 'function' && setFieldValue();
100
+ }
101
+ }
102
+ }, [options]);
103
+ useEffect(function () {
104
+ setSelected(Array.isArray(valueProp) ? valueProp : [valueProp]);
105
+ }, [valueProp]);
106
+
107
+ function beginSearch() {
108
+ onSearch && onSearch(modalInputValue);
109
+ }
110
+
111
+ function handleSelect(value) {
112
+ if (multiple) {
113
+ selected.includes(value) ? setSelected(selected.filter(function (o) {
114
+ return o !== value;
115
+ })) : setSelected([].concat(_toConsumableArray(selected), [value]));
116
+ } else {
117
+ setSelected([value]);
118
+ }
119
+ }
120
+
121
+ function selectAll() {
122
+ setSelected(options.map(function (o) {
123
+ return o.value;
124
+ }));
125
+ }
126
+
127
+ function cancelAll() {
128
+ setSelected([]);
129
+ }
130
+
131
+ var mobileModalTile = function mobileModalTile() {
132
+ return _jsxs("div", {
133
+ className: "igloo-search-box-modal-mobile-title",
134
+ onClick: function onClick() {
135
+ setModalVisible(false);
136
+ setModalInputValue('');
137
+ onSearch && onSearch('');
138
+ },
139
+ children: [_jsx(ArrowLeftOutlined, {}), _jsx(Typography, {
140
+ level: "h4",
141
+ children: modalTitleProps || formatMessage({
142
+ id: 'Search'
143
+ })
144
+ })]
145
+ });
146
+ };
147
+
148
+ var DisPlayOptions = function DisPlayOptions() {
149
+ return _jsx("div", {
150
+ className: "igloo-search-box-modal-options",
151
+ children: options === null || options === void 0 ? void 0 : options.map(function (o) {
152
+ return _jsxs("div", {
153
+ onClick: function onClick(e) {
154
+ return handleSelect(o.value);
155
+ },
156
+ className: classnames('igloo-search-box-modal-select-item', _defineProperty({}, 'igloo-search-box-active-select-item', selected.includes(o.value))),
157
+ children: [multiple && _jsx(CheckBox, {
158
+ className: 'igloo-search-box-modal-select-item-checkbox',
159
+ checked: selected.includes(o.value)
160
+ }), _jsx(Typography, {
161
+ level: 'body1',
162
+ children: o.label
163
+ })]
164
+ }, o.value);
165
+ })
166
+ });
167
+ }; // ...
168
+
169
+
170
+ var inputDisplayedValue = useMemo(function () {
171
+ return options.filter(function (o) {
172
+ return selected.includes(o.value);
173
+ }).map(function (o) {
174
+ return o.label;
175
+ }).join(',');
176
+ }, [options, selected]);
177
+
178
+ var modalDom = _jsxs(Modal, {
179
+ closable: md,
180
+ maskClosable: false,
181
+ visible: modalVisible,
182
+ title: md ? modalTitleProps : mobileModalTile(),
183
+ className: classnames(md ? 'igloo-search-box-modal-container' : 'igloo-search-box-modal-container-mobile', className),
184
+ onCancel: function onCancel() {
185
+ setModalVisible(false);
186
+ setModalInputValue('');
187
+ onSearch && onSearch('');
188
+ },
189
+ onOk: function onOk() {
190
+ onSearch && onSearch('');
191
+ setModalInputValue('');
192
+ setModalVisible(false);
193
+ typeof rest.onChange === 'function' && valueProp !== selected && rest.onChange(multiple ? selected : selected[0]);
194
+ },
195
+ okText: formatMessage({
196
+ id: 'Done'
197
+ }),
198
+ cancelButtonProps: cancelButtonProps,
199
+ okButtonProps: okButtonProps,
200
+ children: [_jsx(Input, {
201
+ className: "igloo-search-box-modal-input",
202
+ value: modalInputValue,
203
+ onChange: function onChange(e) {
204
+ return setModalInputValue(e.target.value);
205
+ },
206
+ placeholder: modalPlaceHolder,
207
+ suffix: _jsx(SearchOutlined, {
208
+ style: {
209
+ fontSize: 24
210
+ },
211
+ onClick: beginSearch
212
+ }),
213
+ onPressEnter: beginSearch
214
+ }), !!options.length && _jsx("div", {
215
+ style: {
216
+ marginBottom: 32
217
+ }
218
+ }), !!options.length && multiple && _jsxs("div", {
219
+ className: 'igloo-search-box-modal-multiple-top',
220
+ children: [_jsx(Button, {
221
+ type: "link",
222
+ onClick: selectAll,
223
+ children: formatMessage({
224
+ id: 'Select All'
225
+ })
226
+ }), _jsx(Button, {
227
+ type: "link",
228
+ onClick: cancelAll,
229
+ children: formatMessage({
230
+ id: 'Clear All'
231
+ })
232
+ })]
233
+ }), searching ? _jsxs("div", {
234
+ className: "igloo-search-box-searching",
235
+ children: [_jsx(LoadingOutlined, {}), ' ', _jsx(Typography, {
236
+ level: "body1",
237
+ children: formatMessage({
238
+ id: 'Searching...'
239
+ })
240
+ })]
241
+ }) : options.length ? _jsx(DisPlayOptions, {}) : null]
242
+ });
243
+
244
+ return _jsxs("div", {
245
+ children: [_jsx(Input, {
246
+ placeholder: placeHolder,
247
+ suffix: _jsx(SearchOutlined, {
248
+ style: {
249
+ fontSize: 24
250
+ }
251
+ }),
252
+ onClick: function onClick() {
253
+ return setModalVisible(true);
254
+ },
255
+ value: inputDisplayedValue
256
+ }), modalDom]
257
+ });
258
+ };
259
+
260
+ var SearchBox = optionsHOC(IglooSearchBox);
261
+
262
+ SearchBox.formItemPropsHandler = function (config) {
263
+ return {};
264
+ };
265
+
266
+ export default SearchBox;
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -0,0 +1,162 @@
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,21 +1,11 @@
1
1
  import { SelectProps, SelectValue } from 'antd/es/select';
2
2
  import { FC, IglooComponentProps } from '../types';
3
- import { FormInstance } from 'antd/es/form';
4
3
  import './style';
5
- import { NamePath } from 'antd/es/form/interface';
4
+ import { ComponentProps } from '../utils/option-utils';
6
5
  export declare const Option: import("rc-select/lib/Option").OptionFC, OptGroup: import("rc-select/lib/OptGroup").OptionGroupFC;
7
6
  declare type Props = SelectProps<SelectValue> & IglooComponentProps & {
8
- getOptions?: (form: FormInstance) => any[];
9
7
  multiple?: boolean;
10
- clearWhenOptionsUpdated?: boolean;
11
- optionGroups?: {
12
- parentKey: string;
13
- options: Props['options'];
14
- }[];
15
- datasourceKey?: string;
16
- datasourceApi?: string;
17
- dependField?: NamePath;
18
- };
8
+ } & ComponentProps;
19
9
  declare type OptionType = typeof Option;
20
10
  declare type OptGroupType = typeof OptGroup;
21
11
  interface IglooSelectType extends FC<Props> {