@aloudata/aloudata-design 0.2.0-beta.21 → 0.2.0-beta.22
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/Select/BaseSelect.js +5 -2
- package/es/Select/interface.d.ts +5 -0
- package/es/_utils/hooks/useControlledState.d.ts +1 -1
- package/es/_utils/hooks/useControlledState.js +11 -11
- package/lib/Select/BaseSelect.js +5 -2
- package/lib/Select/interface.d.ts +5 -0
- package/lib/_utils/hooks/useControlledState.d.ts +1 -1
- package/lib/_utils/hooks/useControlledState.js +11 -11
- package/package.json +1 -1
package/es/Select/BaseSelect.js
CHANGED
|
@@ -30,6 +30,7 @@ import useCacheOptions from './hooks/useCacheOption';
|
|
|
30
30
|
import useControlledState from '../_utils/hooks/useControlledState';
|
|
31
31
|
var DEFAULT_LIST_HEIGHT = 256;
|
|
32
32
|
var DEFAULT_ACTIVE_INDEX = -1;
|
|
33
|
+
var DEFAULT_SELECT_LIST_INDEX = 1050;
|
|
33
34
|
var ZERO = 0;
|
|
34
35
|
export var Select = function Select(props, ref) {
|
|
35
36
|
var _props$size = props.size,
|
|
@@ -72,7 +73,9 @@ export var Select = function Select(props, ref) {
|
|
|
72
73
|
dropDownStyle = props.dropDownStyle,
|
|
73
74
|
_props$dropdownMatchS = props.dropdownMatchSelectWidth,
|
|
74
75
|
dropdownMatchSelectWidth = _props$dropdownMatchS === void 0 ? 'width' : _props$dropdownMatchS,
|
|
75
|
-
children = props.children
|
|
76
|
+
children = props.children,
|
|
77
|
+
_props$zIndex = props.zIndex,
|
|
78
|
+
zIndex = _props$zIndex === void 0 ? DEFAULT_SELECT_LIST_INDEX : _props$zIndex;
|
|
76
79
|
var prefix = usePrefixCls('select-legacy', customizePrefixCls);
|
|
77
80
|
|
|
78
81
|
var _useControlledState = useControlledState(controlledValue, defaultValue),
|
|
@@ -354,7 +357,7 @@ export var Select = function Select(props, ref) {
|
|
|
354
357
|
popupStyle: dropDownStyle,
|
|
355
358
|
getPopupContainer: getContainer,
|
|
356
359
|
stretch: dropdownMatchSelectWidth ? 'width' : 'minWidth',
|
|
357
|
-
zIndex:
|
|
360
|
+
zIndex: zIndex,
|
|
358
361
|
builtinPlacements: {
|
|
359
362
|
left: {
|
|
360
363
|
points: ['cr', 'cl']
|
package/es/Select/interface.d.ts
CHANGED
|
@@ -159,6 +159,11 @@ export interface ISelectProps {
|
|
|
159
159
|
*/
|
|
160
160
|
label?: React.ReactNode;
|
|
161
161
|
children?: React.ReactNode[] | React.ReactNode;
|
|
162
|
+
/**
|
|
163
|
+
* @description 下拉菜单的 z-index层级 属性
|
|
164
|
+
* @default 1050
|
|
165
|
+
*/
|
|
166
|
+
zIndex?: number;
|
|
162
167
|
}
|
|
163
168
|
export interface ISelectorProps {
|
|
164
169
|
input: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const useControlledState: <T>(
|
|
1
|
+
declare const useControlledState: <T>(outerState: T | (() => T) | undefined, defaultOuterState: T, callback?: ((state: T | (() => T)) => void) | undefined) => [T, (state: T | (() => T), force?: boolean | undefined) => void];
|
|
2
2
|
export default useControlledState;
|
|
@@ -16,18 +16,18 @@ import { isUndefined } from 'lodash';
|
|
|
16
16
|
function format(_ref) {
|
|
17
17
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
18
18
|
innerState = _ref2[0],
|
|
19
|
-
|
|
19
|
+
outerState = _ref2[1];
|
|
20
20
|
|
|
21
|
-
var isControlled = isUndefined(
|
|
22
|
-
var value = isUndefined(
|
|
21
|
+
var isControlled = isUndefined(outerState) ? 'uncontrolled' : 'controlled';
|
|
22
|
+
var value = isUndefined(outerState) ? innerState : outerState;
|
|
23
23
|
return "State is ".concat(isControlled, " | Value is ").concat(value);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
var useControlledState = function useControlledState(
|
|
27
|
-
// if (
|
|
26
|
+
var useControlledState = function useControlledState(outerState, defaultOuterState, callback) {
|
|
27
|
+
// if (outerState === undefined && defaultOuterState === undefined) {
|
|
28
28
|
// throw new TypeError('Either "value" or "defaultValue" variable must be set. Now both are undefined');
|
|
29
29
|
// }
|
|
30
|
-
var _useState = useState(isUndefined(
|
|
30
|
+
var _useState = useState(isUndefined(outerState) ? defaultOuterState : outerState),
|
|
31
31
|
_useState2 = _slicedToArray(_useState, 2),
|
|
32
32
|
innerState = _useState2[0],
|
|
33
33
|
setInnerState = _useState2[1];
|
|
@@ -35,19 +35,19 @@ var useControlledState = function useControlledState(outterState, defaultOutterS
|
|
|
35
35
|
var setState = useRef(function (state) {
|
|
36
36
|
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
37
37
|
|
|
38
|
-
if (isUndefined(
|
|
38
|
+
if (isUndefined(outerState) || force) {
|
|
39
39
|
setInnerState(state);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
callback === null || callback === void 0 ? void 0 : callback(state);
|
|
43
43
|
}).current; // @ts-ignore
|
|
44
44
|
|
|
45
|
-
useDebugValue([innerState,
|
|
45
|
+
useDebugValue([innerState, outerState], format);
|
|
46
46
|
useEffect(function () {
|
|
47
|
-
if (!isUndefined(
|
|
48
|
-
setInnerState(
|
|
47
|
+
if (!isUndefined(outerState)) {
|
|
48
|
+
setInnerState(outerState);
|
|
49
49
|
}
|
|
50
|
-
}, [
|
|
50
|
+
}, [outerState]);
|
|
51
51
|
return [innerState, setState];
|
|
52
52
|
};
|
|
53
53
|
|
package/lib/Select/BaseSelect.js
CHANGED
|
@@ -55,6 +55,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
55
55
|
|
|
56
56
|
var DEFAULT_LIST_HEIGHT = 256;
|
|
57
57
|
var DEFAULT_ACTIVE_INDEX = -1;
|
|
58
|
+
var DEFAULT_SELECT_LIST_INDEX = 1050;
|
|
58
59
|
var ZERO = 0;
|
|
59
60
|
|
|
60
61
|
var Select = function Select(props, ref) {
|
|
@@ -98,7 +99,9 @@ var Select = function Select(props, ref) {
|
|
|
98
99
|
dropDownStyle = props.dropDownStyle,
|
|
99
100
|
_props$dropdownMatchS = props.dropdownMatchSelectWidth,
|
|
100
101
|
dropdownMatchSelectWidth = _props$dropdownMatchS === void 0 ? 'width' : _props$dropdownMatchS,
|
|
101
|
-
children = props.children
|
|
102
|
+
children = props.children,
|
|
103
|
+
_props$zIndex = props.zIndex,
|
|
104
|
+
zIndex = _props$zIndex === void 0 ? DEFAULT_SELECT_LIST_INDEX : _props$zIndex;
|
|
102
105
|
var prefix = (0, _usePrefixCls.default)('select-legacy', customizePrefixCls);
|
|
103
106
|
|
|
104
107
|
var _useControlledState = (0, _useControlledState3.default)(controlledValue, defaultValue),
|
|
@@ -382,7 +385,7 @@ var Select = function Select(props, ref) {
|
|
|
382
385
|
popupStyle: dropDownStyle,
|
|
383
386
|
getPopupContainer: getContainer,
|
|
384
387
|
stretch: dropdownMatchSelectWidth ? 'width' : 'minWidth',
|
|
385
|
-
zIndex:
|
|
388
|
+
zIndex: zIndex,
|
|
386
389
|
builtinPlacements: {
|
|
387
390
|
left: {
|
|
388
391
|
points: ['cr', 'cl']
|
|
@@ -159,6 +159,11 @@ export interface ISelectProps {
|
|
|
159
159
|
*/
|
|
160
160
|
label?: React.ReactNode;
|
|
161
161
|
children?: React.ReactNode[] | React.ReactNode;
|
|
162
|
+
/**
|
|
163
|
+
* @description 下拉菜单的 z-index层级 属性
|
|
164
|
+
* @default 1050
|
|
165
|
+
*/
|
|
166
|
+
zIndex?: number;
|
|
162
167
|
}
|
|
163
168
|
export interface ISelectorProps {
|
|
164
169
|
input: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const useControlledState: <T>(
|
|
1
|
+
declare const useControlledState: <T>(outerState: T | (() => T) | undefined, defaultOuterState: T, callback?: ((state: T | (() => T)) => void) | undefined) => [T, (state: T | (() => T), force?: boolean | undefined) => void];
|
|
2
2
|
export default useControlledState;
|
|
@@ -24,18 +24,18 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
24
24
|
function format(_ref) {
|
|
25
25
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
26
26
|
innerState = _ref2[0],
|
|
27
|
-
|
|
27
|
+
outerState = _ref2[1];
|
|
28
28
|
|
|
29
|
-
var isControlled = (0, _lodash.isUndefined)(
|
|
30
|
-
var value = (0, _lodash.isUndefined)(
|
|
29
|
+
var isControlled = (0, _lodash.isUndefined)(outerState) ? 'uncontrolled' : 'controlled';
|
|
30
|
+
var value = (0, _lodash.isUndefined)(outerState) ? innerState : outerState;
|
|
31
31
|
return "State is ".concat(isControlled, " | Value is ").concat(value);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
var useControlledState = function useControlledState(
|
|
35
|
-
// if (
|
|
34
|
+
var useControlledState = function useControlledState(outerState, defaultOuterState, callback) {
|
|
35
|
+
// if (outerState === undefined && defaultOuterState === undefined) {
|
|
36
36
|
// throw new TypeError('Either "value" or "defaultValue" variable must be set. Now both are undefined');
|
|
37
37
|
// }
|
|
38
|
-
var _useState = (0, _react.useState)((0, _lodash.isUndefined)(
|
|
38
|
+
var _useState = (0, _react.useState)((0, _lodash.isUndefined)(outerState) ? defaultOuterState : outerState),
|
|
39
39
|
_useState2 = _slicedToArray(_useState, 2),
|
|
40
40
|
innerState = _useState2[0],
|
|
41
41
|
setInnerState = _useState2[1];
|
|
@@ -43,19 +43,19 @@ var useControlledState = function useControlledState(outterState, defaultOutterS
|
|
|
43
43
|
var setState = (0, _react.useRef)(function (state) {
|
|
44
44
|
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
45
45
|
|
|
46
|
-
if ((0, _lodash.isUndefined)(
|
|
46
|
+
if ((0, _lodash.isUndefined)(outerState) || force) {
|
|
47
47
|
setInnerState(state);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
callback === null || callback === void 0 ? void 0 : callback(state);
|
|
51
51
|
}).current; // @ts-ignore
|
|
52
52
|
|
|
53
|
-
(0, _react.useDebugValue)([innerState,
|
|
53
|
+
(0, _react.useDebugValue)([innerState, outerState], format);
|
|
54
54
|
(0, _react.useEffect)(function () {
|
|
55
|
-
if (!(0, _lodash.isUndefined)(
|
|
56
|
-
setInnerState(
|
|
55
|
+
if (!(0, _lodash.isUndefined)(outerState)) {
|
|
56
|
+
setInnerState(outerState);
|
|
57
57
|
}
|
|
58
|
-
}, [
|
|
58
|
+
}, [outerState]);
|
|
59
59
|
return [innerState, setState];
|
|
60
60
|
};
|
|
61
61
|
|