@hi-ui/tree-select 4.0.0-beta.24 → 4.0.0-beta.27
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/lib/cjs/TreeSelect.js +2 -6
- package/lib/cjs/styles/index.scss.js +1 -1
- package/lib/esm/TreeSelect.js +1 -3
- package/lib/esm/styles/index.scss.js +2 -3
- package/package.json +20 -20
- package/lib/cjs/hooks/use-latest/lib/esm/index.js +0 -64
- package/lib/cjs/hooks/use-merge-refs/lib/esm/index.js +0 -76
- package/lib/cjs/ui/input/lib/esm/Input.js +0 -245
- package/lib/cjs/ui/input/lib/esm/MockInput.js +0 -163
- package/lib/cjs/ui/input/lib/esm/styles/index.scss.js +0 -31
- package/lib/cjs/ui/input/lib/esm/use-input.js +0 -138
- package/lib/cjs/ui/input/lib/esm/utils/index.js +0 -201
- package/lib/cjs/utils/dom-utils/lib/esm/index.js +0 -36
- package/lib/esm/hooks/use-latest/lib/esm/index.js +0 -56
- package/lib/esm/hooks/use-merge-refs/lib/esm/index.js +0 -68
- package/lib/esm/ui/input/lib/esm/Input.js +0 -221
- package/lib/esm/ui/input/lib/esm/MockInput.js +0 -141
- package/lib/esm/ui/input/lib/esm/styles/index.scss.js +0 -26
- package/lib/esm/ui/input/lib/esm/use-input.js +0 -127
- package/lib/esm/ui/input/lib/esm/utils/index.js +0 -185
- package/lib/esm/utils/dom-utils/lib/esm/index.js +0 -29
package/lib/cjs/TreeSelect.js
CHANGED
@@ -39,11 +39,7 @@ var arrayUtils = require('@hi-ui/array-utils');
|
|
39
39
|
|
40
40
|
var highlighter = require('@hi-ui/highlighter');
|
41
41
|
|
42
|
-
require('
|
43
|
-
|
44
|
-
require('./ui/input/lib/esm/Input.js');
|
45
|
-
|
46
|
-
var MockInput = require('./ui/input/lib/esm/MockInput.js');
|
42
|
+
var input = require('@hi-ui/input');
|
47
43
|
|
48
44
|
var icons = require('@hi-ui/icons');
|
49
45
|
|
@@ -264,7 +260,7 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
264
260
|
searchable: searchable,
|
265
261
|
onSearch: funcUtils.callAllFuncs(onSearchProp, onSearch),
|
266
262
|
loading: loading,
|
267
|
-
trigger: /*#__PURE__*/React__default["default"].createElement(
|
263
|
+
trigger: /*#__PURE__*/React__default["default"].createElement(input.MockInput // disabled={disabled}
|
268
264
|
, {
|
269
265
|
// disabled={disabled}
|
270
266
|
clearable: clearable,
|
@@ -12,7 +12,7 @@
|
|
12
12
|
Object.defineProperty(exports, '__esModule', {
|
13
13
|
value: true
|
14
14
|
});
|
15
|
-
var css_248z = "
|
15
|
+
var css_248z = "";
|
16
16
|
|
17
17
|
var __styleInject__ = require('style-inject/dist/style-inject.es.js')["default"];
|
18
18
|
|
package/lib/esm/TreeSelect.js
CHANGED
@@ -19,9 +19,7 @@ import { baseFlattenTree } from '@hi-ui/tree-utils';
|
|
19
19
|
import { isUndef, isArrayNonEmpty } from '@hi-ui/type-assertion';
|
20
20
|
import { uniqBy } from '@hi-ui/array-utils';
|
21
21
|
import { Highlighter } from '@hi-ui/highlighter';
|
22
|
-
import '
|
23
|
-
import './ui/input/lib/esm/Input.js';
|
24
|
-
import { MockInput } from './ui/input/lib/esm/MockInput.js';
|
22
|
+
import { MockInput } from '@hi-ui/input';
|
25
23
|
import { UpOutlined, DownOutlined } from '@hi-ui/icons';
|
26
24
|
import { useLocaleContext } from '@hi-ui/locale-context';
|
27
25
|
import { callAllFuncs } from '@hi-ui/func-utils';
|
@@ -7,9 +7,8 @@
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
9
|
*/
|
10
|
-
|
11
|
-
|
12
|
-
var __styleInject__ = require('style-inject/dist/style-inject.es.js')["default"];
|
10
|
+
import __styleInject__ from 'style-inject/dist/style-inject.es.js';
|
11
|
+
var css_248z = "";
|
13
12
|
|
14
13
|
__styleInject__(css_248z);
|
15
14
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hi-ui/tree-select",
|
3
|
-
"version": "4.0.0-beta.
|
3
|
+
"version": "4.0.0-beta.27",
|
4
4
|
"description": "A sub-package for @hi-ui/hiui.",
|
5
5
|
"keywords": [],
|
6
6
|
"author": "HIUI <mi-hiui@xiaomi.com>",
|
@@ -43,34 +43,34 @@
|
|
43
43
|
"url": "https://github.com/XiaoMi/hiui/issues"
|
44
44
|
},
|
45
45
|
"dependencies": {
|
46
|
-
"@hi-ui/array-utils": "^4.0.0-beta.
|
46
|
+
"@hi-ui/array-utils": "^4.0.0-beta.7",
|
47
47
|
"@hi-ui/classname": "^4.0.0-beta.0",
|
48
|
-
"@hi-ui/core": "^4.0.0-beta.
|
49
|
-
"@hi-ui/core-css": "^4.0.0-beta.
|
48
|
+
"@hi-ui/core": "^4.0.0-beta.8",
|
49
|
+
"@hi-ui/core-css": "^4.0.0-beta.5",
|
50
50
|
"@hi-ui/env": "^4.0.0-beta.0",
|
51
|
-
"@hi-ui/func-utils": "^4.0.0-beta.
|
52
|
-
"@hi-ui/highlighter": "^4.0.0-beta.
|
53
|
-
"@hi-ui/icons": "^4.0.0-beta.
|
54
|
-
"@hi-ui/
|
55
|
-
"@hi-ui/
|
56
|
-
"@hi-ui/
|
57
|
-
"@hi-ui/
|
58
|
-
"@hi-ui/tree": "^4.0.0-beta.
|
59
|
-
"@hi-ui/tree-utils": "^4.0.0-beta.
|
60
|
-
"@hi-ui/type-assertion": "^4.0.0-beta.
|
61
|
-
"@hi-ui/use-data-source": "^4.0.0-beta.
|
62
|
-
"@hi-ui/use-search-mode": "^4.0.0-beta.
|
63
|
-
"@hi-ui/use-toggle": "^4.0.0-beta.
|
64
|
-
"@hi-ui/use-uncontrolled-state": "^4.0.0-beta.
|
51
|
+
"@hi-ui/func-utils": "^4.0.0-beta.10",
|
52
|
+
"@hi-ui/highlighter": "^4.0.0-beta.8",
|
53
|
+
"@hi-ui/icons": "^4.0.0-beta.10",
|
54
|
+
"@hi-ui/input": "^4.0.0-beta.13",
|
55
|
+
"@hi-ui/locale-context": "^4.0.0-beta.16",
|
56
|
+
"@hi-ui/picker": "^4.0.0-beta.21",
|
57
|
+
"@hi-ui/popper": "^4.0.0-beta.12",
|
58
|
+
"@hi-ui/tree": "^4.0.0-beta.25",
|
59
|
+
"@hi-ui/tree-utils": "^4.0.0-beta.4",
|
60
|
+
"@hi-ui/type-assertion": "^4.0.0-beta.4",
|
61
|
+
"@hi-ui/use-data-source": "^4.0.0-beta.5",
|
62
|
+
"@hi-ui/use-search-mode": "^4.0.0-beta.15",
|
63
|
+
"@hi-ui/use-toggle": "^4.0.0-beta.4",
|
64
|
+
"@hi-ui/use-uncontrolled-state": "^4.0.0-beta.4"
|
65
65
|
},
|
66
66
|
"peerDependencies": {
|
67
67
|
"react": ">=16.8.6",
|
68
68
|
"react-dom": ">=16.8.6"
|
69
69
|
},
|
70
70
|
"devDependencies": {
|
71
|
-
"@hi-ui/hi-build": "^4.0.0-beta.
|
71
|
+
"@hi-ui/hi-build": "^4.0.0-beta.4",
|
72
72
|
"react": "^17.0.1",
|
73
73
|
"react-dom": "^17.0.1"
|
74
74
|
},
|
75
|
-
"gitHead": "
|
75
|
+
"gitHead": "322d9175c9135e3fd6ea2971c2781bac2f7300eb"
|
76
76
|
}
|
@@ -1,64 +0,0 @@
|
|
1
|
-
/** @LICENSE
|
2
|
-
* @hi-ui/tree-select
|
3
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/tree-select#readme
|
4
|
-
*
|
5
|
-
* Copyright (c) HIUI <mi-hiui@xiaomi.com>.
|
6
|
-
*
|
7
|
-
* This source code is licensed under the MIT license found in the
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
9
|
-
*/
|
10
|
-
'use strict';
|
11
|
-
|
12
|
-
Object.defineProperty(exports, '__esModule', {
|
13
|
-
value: true
|
14
|
-
});
|
15
|
-
|
16
|
-
var React = require('react');
|
17
|
-
/** @LICENSE
|
18
|
-
* @hi-ui/use-latest
|
19
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/hooks/use-latest#readme
|
20
|
-
*
|
21
|
-
* Copyright (c) HIUI <mi-hiui@xiaomi.com>.
|
22
|
-
*
|
23
|
-
* This source code is licensed under the MIT license found in the
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
25
|
-
*/
|
26
|
-
|
27
|
-
/**
|
28
|
-
* Keep value up-to-date if it changes.
|
29
|
-
*
|
30
|
-
* @param value
|
31
|
-
* @returns
|
32
|
-
*/
|
33
|
-
|
34
|
-
|
35
|
-
var useLatestRef = function useLatestRef(value) {
|
36
|
-
var ref = React.useRef(value);
|
37
|
-
ref.current = value;
|
38
|
-
return ref;
|
39
|
-
};
|
40
|
-
/**
|
41
|
-
* Keep callback function up-to-date if it changes.
|
42
|
-
*
|
43
|
-
* @param callback
|
44
|
-
* @returns
|
45
|
-
*/
|
46
|
-
|
47
|
-
|
48
|
-
var useLatestCallback = function useLatestCallback(callback) {
|
49
|
-
var ref = useLatestRef(callback);
|
50
|
-
return React.useCallback(function () {
|
51
|
-
var _a2;
|
52
|
-
|
53
|
-
var _a;
|
54
|
-
|
55
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
56
|
-
args[_key] = arguments[_key];
|
57
|
-
}
|
58
|
-
|
59
|
-
return (_a = ref.current) === null || _a === void 0 ? void 0 : (_a2 = _a).call.apply(_a2, [ref].concat(args));
|
60
|
-
}, []);
|
61
|
-
};
|
62
|
-
|
63
|
-
exports.useLatestCallback = useLatestCallback;
|
64
|
-
exports.useLatestRef = useLatestRef;
|
@@ -1,76 +0,0 @@
|
|
1
|
-
/** @LICENSE
|
2
|
-
* @hi-ui/tree-select
|
3
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/tree-select#readme
|
4
|
-
*
|
5
|
-
* Copyright (c) HIUI <mi-hiui@xiaomi.com>.
|
6
|
-
*
|
7
|
-
* This source code is licensed under the MIT license found in the
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
9
|
-
*/
|
10
|
-
'use strict';
|
11
|
-
|
12
|
-
Object.defineProperty(exports, '__esModule', {
|
13
|
-
value: true
|
14
|
-
});
|
15
|
-
|
16
|
-
var React = require('react');
|
17
|
-
/** @LICENSE
|
18
|
-
* @hi-ui/use-merge-refs
|
19
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/hooks/use-merge-refs#readme
|
20
|
-
*
|
21
|
-
* Copyright (c) HIUI <mi-hiui@xiaomi.com>.
|
22
|
-
*
|
23
|
-
* This source code is licensed under the MIT license found in the
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
25
|
-
*/
|
26
|
-
|
27
|
-
/**
|
28
|
-
* A hook to merge multiple refs into a single function ref.
|
29
|
-
*
|
30
|
-
* @param refs
|
31
|
-
*/
|
32
|
-
|
33
|
-
|
34
|
-
var useMergeRefs = function useMergeRefs() {
|
35
|
-
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
36
|
-
refs[_key] = arguments[_key];
|
37
|
-
}
|
38
|
-
|
39
|
-
return React.useMemo(function () {
|
40
|
-
return mergeRefs.apply(void 0, refs);
|
41
|
-
}, refs);
|
42
|
-
};
|
43
|
-
/**
|
44
|
-
* Merges multiple refs into a single function ref.
|
45
|
-
*
|
46
|
-
* @param refs
|
47
|
-
* @returns
|
48
|
-
*/
|
49
|
-
|
50
|
-
|
51
|
-
function mergeRefs() {
|
52
|
-
for (var _len2 = arguments.length, refs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
53
|
-
refs[_key2] = arguments[_key2];
|
54
|
-
} // Empty check
|
55
|
-
|
56
|
-
|
57
|
-
if (refs.some(function (ref) {
|
58
|
-
return ref;
|
59
|
-
}) === false) return null;
|
60
|
-
return function (value) {
|
61
|
-
refs.forEach(function (ref) {
|
62
|
-
setRef(ref, value);
|
63
|
-
});
|
64
|
-
};
|
65
|
-
}
|
66
|
-
|
67
|
-
function setRef(ref, value) {
|
68
|
-
if (typeof ref === 'function') {
|
69
|
-
ref(value);
|
70
|
-
} else if (ref) {
|
71
|
-
ref.current = value;
|
72
|
-
}
|
73
|
-
}
|
74
|
-
|
75
|
-
exports.mergeRefs = mergeRefs;
|
76
|
-
exports.useMergeRefs = useMergeRefs;
|
@@ -1,245 +0,0 @@
|
|
1
|
-
/** @LICENSE
|
2
|
-
* @hi-ui/tree-select
|
3
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/tree-select#readme
|
4
|
-
*
|
5
|
-
* Copyright (c) HIUI <mi-hiui@xiaomi.com>.
|
6
|
-
*
|
7
|
-
* This source code is licensed under the MIT license found in the
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
9
|
-
*/
|
10
|
-
'use strict';
|
11
|
-
|
12
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
13
|
-
|
14
|
-
Object.defineProperty(exports, '__esModule', {
|
15
|
-
value: true
|
16
|
-
});
|
17
|
-
|
18
|
-
var tslib = require('tslib');
|
19
|
-
|
20
|
-
var React = require('react');
|
21
|
-
|
22
|
-
var classname = require('@hi-ui/classname');
|
23
|
-
|
24
|
-
var env = require('@hi-ui/env');
|
25
|
-
|
26
|
-
var index = require('../../../../hooks/use-merge-refs/lib/esm/index.js');
|
27
|
-
|
28
|
-
var icons = require('@hi-ui/icons');
|
29
|
-
|
30
|
-
var useInput = require('./use-input.js');
|
31
|
-
|
32
|
-
function _interopDefaultLegacy(e) {
|
33
|
-
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
34
|
-
'default': e
|
35
|
-
};
|
36
|
-
}
|
37
|
-
|
38
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
39
|
-
/** @LICENSE
|
40
|
-
* @hi-ui/input
|
41
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/input#readme
|
42
|
-
*
|
43
|
-
* Copyright (c) HIUI <mi-hiui@xiaomi.com>.
|
44
|
-
*
|
45
|
-
* This source code is licensed under the MIT license found in the
|
46
|
-
* LICENSE file in the root directory of this source tree.
|
47
|
-
*/
|
48
|
-
|
49
|
-
|
50
|
-
var _prefix = classname.getPrefixCls('input');
|
51
|
-
/**
|
52
|
-
* 输入框
|
53
|
-
*
|
54
|
-
* @TODO:
|
55
|
-
* 1. size api 确认
|
56
|
-
* 2. 修改类名结构
|
57
|
-
* 3. 支持带数字展示
|
58
|
-
* 4. InputGroup 模式支持
|
59
|
-
* 5. 手动聚焦支持额外配置
|
60
|
-
*/
|
61
|
-
|
62
|
-
|
63
|
-
var Input = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
64
|
-
var _a$prefixCls = _a.prefixCls,
|
65
|
-
prefixCls = _a$prefixCls === void 0 ? _prefix : _a$prefixCls,
|
66
|
-
_a$role = _a.role,
|
67
|
-
role = _a$role === void 0 ? 'input' : _a$role,
|
68
|
-
className = _a.className,
|
69
|
-
style = _a.style,
|
70
|
-
_a$size = _a.size,
|
71
|
-
size = _a$size === void 0 ? 'md' : _a$size,
|
72
|
-
_a$appearance = _a.appearance,
|
73
|
-
appearance = _a$appearance === void 0 ? 'line' : _a$appearance,
|
74
|
-
prepend = _a.prepend,
|
75
|
-
append = _a.append,
|
76
|
-
prefix = _a.prefix,
|
77
|
-
suffix = _a.suffix,
|
78
|
-
_a$clearableTrigger = _a.clearableTrigger,
|
79
|
-
clearableTrigger = _a$clearableTrigger === void 0 ? 'hover' : _a$clearableTrigger,
|
80
|
-
_a$clearable = _a.clearable,
|
81
|
-
clearable = _a$clearable === void 0 ? false : _a$clearable,
|
82
|
-
_a$invalid = _a.invalid,
|
83
|
-
invalid = _a$invalid === void 0 ? false : _a$invalid,
|
84
|
-
name = _a.name,
|
85
|
-
autoFocus = _a.autoFocus,
|
86
|
-
disabled = _a.disabled,
|
87
|
-
readOnly = _a.readOnly,
|
88
|
-
maxLength = _a.maxLength,
|
89
|
-
placeholder = _a.placeholder,
|
90
|
-
defaultValue = _a.defaultValue,
|
91
|
-
valueProp = _a.value,
|
92
|
-
onChange = _a.onChange,
|
93
|
-
onFocus = _a.onFocus,
|
94
|
-
onBlur = _a.onBlur,
|
95
|
-
trimValueOnBlur = _a.trimValueOnBlur,
|
96
|
-
onClear = _a.onClear,
|
97
|
-
type = _a.type,
|
98
|
-
containerRef = _a.containerRef,
|
99
|
-
rest = tslib.__rest(_a, ["prefixCls", "role", "className", "style", "size", "appearance", "prepend", "append", "prefix", "suffix", "clearableTrigger", "clearable", "invalid", "name", "autoFocus", "disabled", "readOnly", "maxLength", "placeholder", "defaultValue", "value", "onChange", "onFocus", "onBlur", "trimValueOnBlur", "onClear", "type", "containerRef"]); // @TODO: 临时方案,后面迁移至 InputGroup
|
100
|
-
|
101
|
-
|
102
|
-
var _useMemo = React.useMemo(function () {
|
103
|
-
var shouldUnset = [false, false]; // @ts-ignore
|
104
|
-
// @ts-ignore
|
105
|
-
|
106
|
-
if (
|
107
|
-
/*#__PURE__*/
|
108
|
-
|
109
|
-
/*#__PURE__*/
|
110
|
-
React.isValidElement(prepend) && ['Select', 'Button'].includes(prepend.type.HiName)) {
|
111
|
-
shouldUnset[0] = true;
|
112
|
-
} // @ts-ignore
|
113
|
-
// @ts-ignore
|
114
|
-
|
115
|
-
|
116
|
-
if (
|
117
|
-
/*#__PURE__*/
|
118
|
-
|
119
|
-
/*#__PURE__*/
|
120
|
-
React.isValidElement(append) && ['Select', 'Button'].includes(append.type.HiName)) {
|
121
|
-
shouldUnset[1] = true;
|
122
|
-
}
|
123
|
-
|
124
|
-
return shouldUnset;
|
125
|
-
}, [prepend, append]),
|
126
|
-
unsetPrepend = _useMemo[0],
|
127
|
-
unsetAppend = _useMemo[1];
|
128
|
-
|
129
|
-
var inputElementRef = React.useRef(null);
|
130
|
-
var proxyOnChange = React.useCallback(function (value, evt) {
|
131
|
-
if (!onChange) return;
|
132
|
-
onChangeMock(onChange, evt, inputElementRef.current, value);
|
133
|
-
}, [onChange]);
|
134
|
-
var clearElementRef = React.useRef(null);
|
135
|
-
|
136
|
-
var _useInput = useInput.useInput({
|
137
|
-
clearElementRef: clearElementRef,
|
138
|
-
name: name,
|
139
|
-
autoFocus: autoFocus,
|
140
|
-
disabled: disabled,
|
141
|
-
readOnly: readOnly,
|
142
|
-
maxLength: maxLength,
|
143
|
-
placeholder: placeholder,
|
144
|
-
defaultValue: defaultValue,
|
145
|
-
value: valueProp,
|
146
|
-
onChange: proxyOnChange,
|
147
|
-
onFocus: onFocus,
|
148
|
-
onBlur: onBlur,
|
149
|
-
trimValueOnBlur: trimValueOnBlur,
|
150
|
-
type: type
|
151
|
-
}),
|
152
|
-
tryChangeValue = _useInput.tryChangeValue,
|
153
|
-
focused = _useInput.focused,
|
154
|
-
value = _useInput.value,
|
155
|
-
getInputProps = _useInput.getInputProps;
|
156
|
-
|
157
|
-
var focus = React.useCallback(function () {
|
158
|
-
var _a;
|
159
|
-
|
160
|
-
(_a = inputElementRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
161
|
-
}, []);
|
162
|
-
|
163
|
-
var _useState = React.useState(false),
|
164
|
-
hover = _useState[0],
|
165
|
-
setHover = _useState[1]; // 在开启 clearable 下展示 清除内容按钮,可点击进行内容清楚
|
166
|
-
|
167
|
-
|
168
|
-
var showClearableIcon = clearable && !!value && !disabled;
|
169
|
-
var mergedRef = index.useMergeRefs(ref, inputElementRef);
|
170
|
-
var cls = classname.cx(prefixCls, className, prefixCls + "--size-" + size, prefixCls + "--appearance-" + appearance);
|
171
|
-
var outerCls = classname.cx(prefixCls + "__outer", prepend && prefixCls + "__outer--prepend", prepend && unsetPrepend && prefixCls + "__outer--prepend-unset", append && prefixCls + "__outer--append", append && unsetAppend && prefixCls + "__outer--append-unset");
|
172
|
-
return /*#__PURE__*/React__default["default"].createElement("div", {
|
173
|
-
role: role,
|
174
|
-
className: cls,
|
175
|
-
style: style,
|
176
|
-
ref: containerRef
|
177
|
-
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
178
|
-
className: outerCls
|
179
|
-
}, prepend ? /*#__PURE__*/React__default["default"].createElement("div", {
|
180
|
-
className: prefixCls + "__prepend"
|
181
|
-
}, prepend) : null, /*#__PURE__*/React__default["default"].createElement("div", {
|
182
|
-
className: classname.cx(prefixCls + "__inner", prefix && prefixCls + "__inner--prefix", suffix && prefixCls + "__inner--suffix", focused && prefixCls + "__inner--focused", disabled && prefixCls + "__inner--disabled", readOnly && prefixCls + "__inner--readonly", invalid && prefixCls + "__inner--invalid"),
|
183
|
-
onMouseOver: function onMouseOver(e) {
|
184
|
-
setHover(true);
|
185
|
-
},
|
186
|
-
onMouseLeave: function onMouseLeave(e) {
|
187
|
-
setHover(false);
|
188
|
-
}
|
189
|
-
}, prefix ? /*#__PURE__*/React__default["default"].createElement("span", {
|
190
|
-
className: prefixCls + "__prefix"
|
191
|
-
}, prefix) : null, /*#__PURE__*/React__default["default"].createElement("input", Object.assign({
|
192
|
-
ref: mergedRef,
|
193
|
-
className: prefixCls + "__text"
|
194
|
-
}, getInputProps(), rest)), suffix || showClearableIcon ? /*#__PURE__*/React__default["default"].createElement("span", {
|
195
|
-
className: prefixCls + "__suffix"
|
196
|
-
}, showClearableIcon ? /*#__PURE__*/React__default["default"].createElement("span", {
|
197
|
-
ref: clearElementRef,
|
198
|
-
className: classname.cx(prefixCls + "__clear", (clearableTrigger === 'always' || hover) && prefixCls + "__clear--active"),
|
199
|
-
role: "button",
|
200
|
-
tabIndex: -1,
|
201
|
-
onClick: function onClick(evt) {
|
202
|
-
tryChangeValue('', evt);
|
203
|
-
onClear === null || onClear === void 0 ? void 0 : onClear();
|
204
|
-
focus();
|
205
|
-
}
|
206
|
-
}, /*#__PURE__*/React__default["default"].createElement(icons.CloseCircleFilled, null)) : null, suffix) : null), append ? /*#__PURE__*/React__default["default"].createElement("div", {
|
207
|
-
className: prefixCls + "__append"
|
208
|
-
}, append) : null));
|
209
|
-
});
|
210
|
-
|
211
|
-
if (env.__DEV__) {
|
212
|
-
Input.displayName = 'Input';
|
213
|
-
}
|
214
|
-
/**
|
215
|
-
* 模拟伪装目标事件 target
|
216
|
-
*
|
217
|
-
* @param target
|
218
|
-
* @param evt
|
219
|
-
* @param onChange
|
220
|
-
* @param targetValue
|
221
|
-
* @returns
|
222
|
-
*/
|
223
|
-
|
224
|
-
|
225
|
-
function onChangeMock(onChange, evt, target, targetValue) {
|
226
|
-
var event = evt; // 点击 clearIcon 或者 失焦 trim 时,都会代理 onChange 的事件对象 target 指向 input.target
|
227
|
-
|
228
|
-
if (evt.type !== 'change') {
|
229
|
-
if (!target) return;
|
230
|
-
var originalTargetValue = target.value;
|
231
|
-
event = Object.create(evt);
|
232
|
-
event.target = target;
|
233
|
-
event.currentTarget = target;
|
234
|
-
target.value = targetValue;
|
235
|
-
onChange(event, targetValue); // 重置为之前值
|
236
|
-
|
237
|
-
target.value = originalTargetValue;
|
238
|
-
return;
|
239
|
-
}
|
240
|
-
|
241
|
-
onChange(event, targetValue);
|
242
|
-
}
|
243
|
-
|
244
|
-
exports.Input = Input;
|
245
|
-
exports.onChangeMock = onChangeMock;
|
@@ -1,163 +0,0 @@
|
|
1
|
-
/** @LICENSE
|
2
|
-
* @hi-ui/tree-select
|
3
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/tree-select#readme
|
4
|
-
*
|
5
|
-
* Copyright (c) HIUI <mi-hiui@xiaomi.com>.
|
6
|
-
*
|
7
|
-
* This source code is licensed under the MIT license found in the
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
9
|
-
*/
|
10
|
-
'use strict';
|
11
|
-
|
12
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
13
|
-
|
14
|
-
Object.defineProperty(exports, '__esModule', {
|
15
|
-
value: true
|
16
|
-
});
|
17
|
-
|
18
|
-
var tslib = require('tslib');
|
19
|
-
|
20
|
-
var React = require('react');
|
21
|
-
|
22
|
-
var classname = require('@hi-ui/classname');
|
23
|
-
|
24
|
-
var env = require('@hi-ui/env');
|
25
|
-
|
26
|
-
var useUncontrolledState = require('@hi-ui/use-uncontrolled-state');
|
27
|
-
|
28
|
-
var icons = require('@hi-ui/icons');
|
29
|
-
|
30
|
-
function _interopDefaultLegacy(e) {
|
31
|
-
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
32
|
-
'default': e
|
33
|
-
};
|
34
|
-
}
|
35
|
-
|
36
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
37
|
-
/** @LICENSE
|
38
|
-
* @hi-ui/input
|
39
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/input#readme
|
40
|
-
*
|
41
|
-
* Copyright (c) HIUI <mi-hiui@xiaomi.com>.
|
42
|
-
*
|
43
|
-
* This source code is licensed under the MIT license found in the
|
44
|
-
* LICENSE file in the root directory of this source tree.
|
45
|
-
*/
|
46
|
-
|
47
|
-
|
48
|
-
var _role = 'mock-input';
|
49
|
-
|
50
|
-
var _prefix = classname.getPrefixCls(_role);
|
51
|
-
|
52
|
-
var NOOP_VALUE = '';
|
53
|
-
var NOOP_ARRAY = [];
|
54
|
-
/**
|
55
|
-
* 支持自定义渲染输入框内容,暂时仅供内部 Picker 类组件使用,不对外提供
|
56
|
-
*/
|
57
|
-
|
58
|
-
var MockInput = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
59
|
-
var _a$prefixCls = _a.prefixCls,
|
60
|
-
prefixCls = _a$prefixCls === void 0 ? _prefix : _a$prefixCls,
|
61
|
-
_a$role = _a.role,
|
62
|
-
role = _a$role === void 0 ? _role : _a$role,
|
63
|
-
className = _a.className,
|
64
|
-
_a$data = _a.data,
|
65
|
-
data = _a$data === void 0 ? NOOP_ARRAY : _a$data,
|
66
|
-
_a$defaultValue = _a.defaultValue,
|
67
|
-
defaultValue = _a$defaultValue === void 0 ? NOOP_VALUE : _a$defaultValue,
|
68
|
-
valueProp = _a.value,
|
69
|
-
onChange = _a.onChange,
|
70
|
-
placeholder = _a.placeholder,
|
71
|
-
_a$disabled = _a.disabled,
|
72
|
-
disabled = _a$disabled === void 0 ? false : _a$disabled,
|
73
|
-
_a$clearable = _a.clearable,
|
74
|
-
clearable = _a$clearable === void 0 ? false : _a$clearable,
|
75
|
-
_a$focused = _a.focused,
|
76
|
-
focused = _a$focused === void 0 ? false : _a$focused,
|
77
|
-
_a$invalid = _a.invalid,
|
78
|
-
invalid = _a$invalid === void 0 ? false : _a$invalid,
|
79
|
-
_a$readOnly = _a.readOnly,
|
80
|
-
readOnly = _a$readOnly === void 0 ? false : _a$readOnly,
|
81
|
-
_a$size = _a.size,
|
82
|
-
size = _a$size === void 0 ? 'md' : _a$size,
|
83
|
-
_a$appearance = _a.appearance,
|
84
|
-
appearance = _a$appearance === void 0 ? 'line' : _a$appearance,
|
85
|
-
_a$clearableTrigger = _a.clearableTrigger,
|
86
|
-
clearableTrigger = _a$clearableTrigger === void 0 ? 'hover' : _a$clearableTrigger,
|
87
|
-
displayRender = _a.displayRender,
|
88
|
-
suffix = _a.suffix,
|
89
|
-
_onMouseOver = _a.onMouseOver,
|
90
|
-
_onMouseLeave = _a.onMouseLeave,
|
91
|
-
rest = tslib.__rest(_a, ["prefixCls", "role", "className", "data", "defaultValue", "value", "onChange", "placeholder", "disabled", "clearable", "focused", "invalid", "readOnly", "size", "appearance", "clearableTrigger", "displayRender", "suffix", "onMouseOver", "onMouseLeave"]);
|
92
|
-
|
93
|
-
var _useUncontrolledState = useUncontrolledState.useUncontrolledState(defaultValue, valueProp, onChange),
|
94
|
-
value = _useUncontrolledState[0],
|
95
|
-
tryChangeValue = _useUncontrolledState[1];
|
96
|
-
|
97
|
-
var displayItem = React.useMemo(function () {
|
98
|
-
if (value === '') return null;
|
99
|
-
var displayItem = data.find(function (item) {
|
100
|
-
return item.id === value;
|
101
|
-
});
|
102
|
-
return displayItem || null;
|
103
|
-
}, [value, data]);
|
104
|
-
var displayValue = React.useMemo(function () {
|
105
|
-
if (!displayItem) return '';
|
106
|
-
|
107
|
-
if (displayRender) {
|
108
|
-
return displayRender(displayItem);
|
109
|
-
}
|
110
|
-
|
111
|
-
return displayItem.title;
|
112
|
-
}, [displayItem, displayRender]);
|
113
|
-
var handleClear = React.useCallback(function (evt) {
|
114
|
-
if (disabled) return;
|
115
|
-
evt.stopPropagation();
|
116
|
-
tryChangeValue(NOOP_VALUE, displayItem);
|
117
|
-
}, [tryChangeValue, disabled, displayItem]);
|
118
|
-
|
119
|
-
var _useState = React.useState(false),
|
120
|
-
hover = _useState[0],
|
121
|
-
setHover = _useState[1];
|
122
|
-
|
123
|
-
var trySetHover = React.useCallback(function (hovered) {
|
124
|
-
if (disabled) return;
|
125
|
-
setHover(hovered);
|
126
|
-
}, [disabled]);
|
127
|
-
var hasValue = !!displayValue; // 在开启 clearable 下展示 清除内容按钮,可点击进行内容清除
|
128
|
-
|
129
|
-
var showClearableIcon = React.useMemo(function () {
|
130
|
-
return clearable && hasValue && !disabled && (clearableTrigger === 'always' || hover);
|
131
|
-
}, [clearable, hasValue, disabled, clearableTrigger, hover]);
|
132
|
-
var cls = classname.cx(prefixCls, className, prefixCls + "--appearance-" + appearance, prefixCls + "--size-" + size, focused && "focused", disabled && 'disabled', readOnly && 'readonly', invalid && 'invalid');
|
133
|
-
return /*#__PURE__*/React__default["default"].createElement("div", Object.assign({
|
134
|
-
ref: ref,
|
135
|
-
role: role,
|
136
|
-
className: cls,
|
137
|
-
onMouseOver: function onMouseOver(evt) {
|
138
|
-
trySetHover(true);
|
139
|
-
_onMouseOver === null || _onMouseOver === void 0 ? void 0 : _onMouseOver(evt);
|
140
|
-
},
|
141
|
-
onMouseLeave: function onMouseLeave(evt) {
|
142
|
-
trySetHover(false);
|
143
|
-
_onMouseLeave === null || _onMouseLeave === void 0 ? void 0 : _onMouseLeave(evt);
|
144
|
-
}
|
145
|
-
}, rest), hasValue ? /*#__PURE__*/React__default["default"].createElement("span", {
|
146
|
-
className: prefixCls + "__value"
|
147
|
-
}, displayValue) : /*#__PURE__*/React__default["default"].createElement("span", {
|
148
|
-
className: prefixCls + "__placeholder"
|
149
|
-
}, placeholder), suffix || showClearableIcon ? /*#__PURE__*/React__default["default"].createElement("span", {
|
150
|
-
className: prefixCls + "__suffix"
|
151
|
-
}, showClearableIcon ? /*#__PURE__*/React__default["default"].createElement("span", {
|
152
|
-
role: "button",
|
153
|
-
tabIndex: -1,
|
154
|
-
className: classname.cx(prefixCls + "__clear", 'active'),
|
155
|
-
onClick: handleClear
|
156
|
-
}, /*#__PURE__*/React__default["default"].createElement(icons.CloseCircleFilled, null)) : suffix) : null);
|
157
|
-
});
|
158
|
-
|
159
|
-
if (env.__DEV__) {
|
160
|
-
MockInput.displayName = 'MockInput';
|
161
|
-
}
|
162
|
-
|
163
|
-
exports.MockInput = MockInput;
|