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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["value", "onChange", "options", "otherOptionLabel"];
|
|
1
|
+
var _excluded = ["value", "onChange", "options", "otherOptionLabel", "clearWhenOptionsUpdated"];
|
|
2
2
|
|
|
3
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
4
|
|
|
@@ -31,17 +31,21 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
31
31
|
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; }
|
|
32
32
|
|
|
33
33
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
34
|
-
import { useContext, useState } from 'react';
|
|
34
|
+
import { useContext, useState, useEffect, useRef } from 'react';
|
|
35
35
|
import { RadioGroup } from './index';
|
|
36
36
|
import { TextArea } from '../input';
|
|
37
37
|
import { LocaleContext } from '../locale';
|
|
38
|
+
import { compareOptions, optionsHOC } from '../utils/option-utils';
|
|
38
39
|
var otherKey = 'iglooRadioGroupOther';
|
|
39
40
|
|
|
40
|
-
var
|
|
41
|
+
var InnerRadioGroupWithOther = function InnerRadioGroupWithOther(_ref) {
|
|
41
42
|
var value = _ref.value,
|
|
42
43
|
onChange = _ref.onChange,
|
|
43
|
-
options = _ref.options,
|
|
44
|
+
_ref$options = _ref.options,
|
|
45
|
+
options = _ref$options === void 0 ? [] : _ref$options,
|
|
44
46
|
otherOptionLabel = _ref.otherOptionLabel,
|
|
47
|
+
_ref$clearWhenOptions = _ref.clearWhenOptionsUpdated,
|
|
48
|
+
clearWhenOptionsUpdated = _ref$clearWhenOptions === void 0 ? false : _ref$clearWhenOptions,
|
|
45
49
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
46
50
|
|
|
47
51
|
var _useState = useState(false),
|
|
@@ -49,6 +53,38 @@ var RadioGroupWithOther = function RadioGroupWithOther(_ref) {
|
|
|
49
53
|
otherEnabled = _useState2[0],
|
|
50
54
|
enableOther = _useState2[1];
|
|
51
55
|
|
|
56
|
+
var _useState3 = useState(value),
|
|
57
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
58
|
+
selected = _useState4[0],
|
|
59
|
+
setSelected = _useState4[1];
|
|
60
|
+
|
|
61
|
+
var originOptions = useRef(options);
|
|
62
|
+
useEffect(function () {
|
|
63
|
+
typeof onChange === 'function' && value !== selected && onChange(selected);
|
|
64
|
+
}, [selected]);
|
|
65
|
+
useEffect(function () {
|
|
66
|
+
setSelected(value);
|
|
67
|
+
}, [value]);
|
|
68
|
+
useEffect(function () {
|
|
69
|
+
var setFieldValue = rest.setFieldValue;
|
|
70
|
+
|
|
71
|
+
if (compareOptions(options, originOptions.current)) {
|
|
72
|
+
if (clearWhenOptionsUpdated) {
|
|
73
|
+
typeof setFieldValue === 'function' && setFieldValue();
|
|
74
|
+
} else {
|
|
75
|
+
var foundValue = options.find(function (option) {
|
|
76
|
+
return Array.isArray(value) ? value.includes(option.value) : option.value === value;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
if (!foundValue && value !== undefined) {
|
|
80
|
+
typeof setFieldValue === 'function' && setFieldValue();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
originOptions.current = options;
|
|
85
|
+
}
|
|
86
|
+
}, [options]);
|
|
87
|
+
|
|
52
88
|
var handleChange = function handleChange(e) {
|
|
53
89
|
onChange && onChange(e);
|
|
54
90
|
};
|
|
@@ -82,4 +118,5 @@ var RadioGroupWithOther = function RadioGroupWithOther(_ref) {
|
|
|
82
118
|
});
|
|
83
119
|
};
|
|
84
120
|
|
|
121
|
+
var RadioGroupWithOther = optionsHOC(InnerRadioGroupWithOther);
|
|
85
122
|
export default RadioGroupWithOther;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg width="32" height="25" viewBox="0 0 32 25" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path
|
|
3
|
+
d="M30.6663 18.3333V12.5846C30.6663 12.0654 30.5316 11.5551 30.2752 11.1035L25.4017 2.51891C24.8687 1.58006 23.8724 1 22.7928 1H8.99351C7.89503 1 6.88439 1.60036 6.35896 2.56503L1.69846 11.1215C1.45865 11.5618 1.33301 12.0551 1.33301 12.5565V18.3333"
|
|
4
|
+
stroke="#212121" stroke-width="2" />
|
|
5
|
+
<mask id="path-2-inside-1_8603_29999" fill="white">
|
|
6
|
+
<path fill-rule="evenodd" clip-rule="evenodd"
|
|
7
|
+
d="M9.22038 11.3468C9.22038 10.5263 8.5552 9.86108 7.73467 9.86108H3C1.34315 9.86108 0 11.2042 0 12.8611V22C0 23.6568 1.34315 25 3 25H29C30.6569 25 32 23.6568 32 22V12.8611C32 11.2042 30.6569 9.86108 29 9.86108H24.2654C23.4449 9.86108 22.7797 10.5263 22.7797 11.3468C22.7797 13.0036 21.4366 14.3468 19.7797 14.3468H12.2204C10.5635 14.3468 9.22038 13.0036 9.22038 11.3468Z" />
|
|
8
|
+
</mask>
|
|
9
|
+
<path
|
|
10
|
+
d="M3 11.8611H7.73467V7.86108H3V11.8611ZM2 22V12.8611H-2V22H2ZM29 23H3V27H29V23ZM30 12.8611V22H34V12.8611H30ZM24.2654 11.8611H29V7.86108H24.2654V11.8611ZM20.7797 11.3468C20.7797 11.8991 20.332 12.3468 19.7797 12.3468V16.3468C22.5411 16.3468 24.7797 14.1082 24.7797 11.3468H20.7797ZM19.7797 12.3468H12.2204V16.3468H19.7797V12.3468ZM12.2204 12.3468C11.6681 12.3468 11.2204 11.8991 11.2204 11.3468H7.22038C7.22038 14.1082 9.45895 16.3468 12.2204 16.3468V12.3468ZM24.2654 7.86108C22.3403 7.86108 20.7797 9.42169 20.7797 11.3468H24.7797C24.7797 11.6308 24.5494 11.8611 24.2654 11.8611V7.86108ZM34 12.8611C34 10.0997 31.7614 7.86108 29 7.86108V11.8611C29.5523 11.8611 30 12.3088 30 12.8611H34ZM29 27C31.7614 27 34 24.7614 34 22H30C30 22.5523 29.5523 23 29 23V27ZM-2 22C-2 24.7614 0.238576 27 3 27V23C2.44772 23 2 22.5523 2 22H-2ZM7.73467 11.8611C7.45064 11.8611 7.22038 11.6308 7.22038 11.3468H11.2204C11.2204 9.42168 9.65977 7.86108 7.73467 7.86108V11.8611ZM3 7.86108C0.238578 7.86108 -2 10.0997 -2 12.8611H2C2 12.3088 2.44771 11.8611 3 11.8611V7.86108Z"
|
|
11
|
+
fill="#212121" mask="url(#path-2-inside-1_8603_29999)" />
|
|
12
|
+
</svg>
|
|
@@ -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 {
|
|
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
|
-
|
|
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> {
|