@laser-ui/components 2.0.5 → 2.1.1
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/CHANGELOG.md +12 -0
- package/cascader/Cascader.js +3 -3
- package/date-picker/DatePicker.js +3 -3
- package/dialog-service.d.ts +2 -1
- package/dialog-service.js +35 -31
- package/drawer/Drawer.js +3 -3
- package/dropdown/Dropdown.js +3 -3
- package/hooks/index.d.ts +1 -1
- package/hooks/index.js +1 -1
- package/hooks/useZIndex.d.ts +1 -0
- package/hooks/useZIndex.js +22 -0
- package/image/ImagePreview.js +3 -3
- package/menu/internal/MenuSub.js +4 -3
- package/modal/Modal.js +3 -3
- package/package.json +2 -2
- package/popover/Popover.js +3 -3
- package/select/Select.js +3 -3
- package/time-picker/TimePicker.js +3 -3
- package/tooltip/Tooltip.js +3 -3
- package/tree-select/TreeSelect.js +3 -3
- package/hooks/useMaxIndex.d.ts +0 -1
- package/hooks/useMaxIndex.js +0 -24
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [2.1.1](https://github.com/laser-ui/laser-ui/compare/v2.1.0...v2.1.1) (2025-06-16)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- fix zindex increment ([4ebc565](https://github.com/laser-ui/laser-ui/commit/4ebc565b3a3a645a0ae587e49d58a420c8c47286))
|
|
10
|
+
|
|
11
|
+
# [2.1.0](https://github.com/laser-ui/laser-ui/compare/v2.0.5...v2.1.0) (2025-06-09)
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- **components:** support prevent close dialog ([6431830](https://github.com/laser-ui/laser-ui/commit/6431830b84ad26d3985f634b52e348f959eac674))
|
|
16
|
+
|
|
5
17
|
## [2.0.5](https://github.com/laser-ui/laser-ui/compare/v2.0.4...v2.0.5) (2025-01-13)
|
|
6
18
|
|
|
7
19
|
### Features
|
package/cascader/Cascader.js
CHANGED
|
@@ -14,7 +14,7 @@ import { CLASSES } from './vars';
|
|
|
14
14
|
import { BaseInput } from '../base-input';
|
|
15
15
|
import { CircularProgress } from '../circular-progress';
|
|
16
16
|
import { Dropdown } from '../dropdown';
|
|
17
|
-
import { useComponentProps, useContainerScrolling, useControlled, useDesign, useFocusVisible, useLayout,
|
|
17
|
+
import { useComponentProps, useContainerScrolling, useControlled, useDesign, useFocusVisible, useLayout, useNamespace, useScopedProps, useStyled, useTranslation, useZIndex, } from '../hooks';
|
|
18
18
|
import { Icon } from '../icon';
|
|
19
19
|
import { Portal } from '../internal/portal';
|
|
20
20
|
import { ROOT_DATA } from '../root/vars';
|
|
@@ -174,8 +174,8 @@ export function Cascader(props) {
|
|
|
174
174
|
return findNested(searchList, (item) => item[TREE_NODE_KEY].enabled);
|
|
175
175
|
}
|
|
176
176
|
})();
|
|
177
|
-
const
|
|
178
|
-
const zIndex = `calc(var(--${namespace}-zindex-fixed) + ${
|
|
177
|
+
const zIndexValue = useZIndex(visible);
|
|
178
|
+
const zIndex = `calc(var(--${namespace}-zindex-fixed) + ${zIndexValue})`;
|
|
179
179
|
const updatePosition = useEventCallback(() => {
|
|
180
180
|
if (visible && boxRef.current && popupRef.current) {
|
|
181
181
|
const height = popupRef.current.offsetHeight;
|
|
@@ -13,7 +13,7 @@ import { CLASSES } from './vars';
|
|
|
13
13
|
import { BaseInput } from '../base-input';
|
|
14
14
|
import { Button } from '../button';
|
|
15
15
|
import dayjs from '../dayjs';
|
|
16
|
-
import { useComponentProps, useContainerScrolling, useControlled, useDesign, useLayout,
|
|
16
|
+
import { useComponentProps, useContainerScrolling, useControlled, useDesign, useLayout, useNamespace, useScopedProps, useStyled, useTranslation, useZIndex, } from '../hooks';
|
|
17
17
|
import { Icon } from '../icon';
|
|
18
18
|
import { Portal } from '../internal/portal';
|
|
19
19
|
import { ROOT_DATA } from '../root/vars';
|
|
@@ -115,8 +115,8 @@ export function DatePicker(props) {
|
|
|
115
115
|
? ((_b = placeholder) !== null && _b !== void 0 ? _b : [])
|
|
116
116
|
: [placeholder];
|
|
117
117
|
const { size, disabled } = useScopedProps({ size: sizeProp, disabled: disabledProp || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
|
|
118
|
-
const
|
|
119
|
-
const zIndex = `calc(var(--${namespace}-zindex-fixed) + ${
|
|
118
|
+
const zIndexValue = useZIndex(visible);
|
|
119
|
+
const zIndex = `calc(var(--${namespace}-zindex-fixed) + ${zIndexValue})`;
|
|
120
120
|
const updatePosition = useEventCallback(() => {
|
|
121
121
|
if (visible && boxRef.current && popupRef.current) {
|
|
122
122
|
const height = popupRef.current.offsetHeight;
|
package/dialog-service.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare class DialogInstance<P extends object> {
|
|
|
4
4
|
private type;
|
|
5
5
|
private props;
|
|
6
6
|
private service;
|
|
7
|
+
visible: boolean;
|
|
7
8
|
get node(): React.ReactElement<P>;
|
|
8
9
|
constructor(key: string | number, type: React.FC<P>, props: any, service: DialogService);
|
|
9
10
|
rerender(props: Partial<P>): void;
|
|
@@ -11,8 +12,8 @@ export declare class DialogInstance<P extends object> {
|
|
|
11
12
|
}
|
|
12
13
|
export declare class DialogService {
|
|
13
14
|
private _key;
|
|
14
|
-
private _dialogs;
|
|
15
15
|
private _emitChange;
|
|
16
|
+
dialogs: DialogInstance<any>[];
|
|
16
17
|
constructor(emitChange: (dialogs: DialogInstance<any>[]) => void);
|
|
17
18
|
open<P extends object>(type: React.FC<P>, props: Omit<P, 'visible'>, key?: string | number): DialogInstance<P>;
|
|
18
19
|
emitChange(key: string | number): void;
|
package/dialog-service.js
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
export class DialogInstance {
|
|
3
3
|
get node() {
|
|
4
|
+
var _a;
|
|
4
5
|
const Type = this.type;
|
|
5
|
-
return _jsx(Type, Object.assign({}, this.props
|
|
6
|
+
return (_jsx(Type, Object.assign({}, this.props, { visible: this.visible, skipFirstTransition: (_a = this.props.skipFirstTransition) !== null && _a !== void 0 ? _a : false, onClose: () => {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
const res = (_b = (_a = this.props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
9
|
+
if (res !== false) {
|
|
10
|
+
this.close();
|
|
11
|
+
}
|
|
12
|
+
}, afterVisibleChange: (visible) => {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
(_b = (_a = this.props).afterVisibleChange) === null || _b === void 0 ? void 0 : _b.call(_a, visible);
|
|
15
|
+
if (!visible) {
|
|
16
|
+
const index = this.service.dialogs.findIndex((dialog) => dialog.key === this.key);
|
|
17
|
+
if (index !== -1) {
|
|
18
|
+
this.service.dialogs.splice(index, 1);
|
|
19
|
+
}
|
|
20
|
+
this.service.emitChange(this.key);
|
|
21
|
+
}
|
|
22
|
+
} }), this.key));
|
|
6
23
|
}
|
|
7
24
|
constructor(key, type, props, service) {
|
|
8
25
|
Object.defineProperty(this, "key", {
|
|
@@ -29,13 +46,19 @@ export class DialogInstance {
|
|
|
29
46
|
writable: true,
|
|
30
47
|
value: service
|
|
31
48
|
});
|
|
49
|
+
Object.defineProperty(this, "visible", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
configurable: true,
|
|
52
|
+
writable: true,
|
|
53
|
+
value: true
|
|
54
|
+
});
|
|
32
55
|
}
|
|
33
56
|
rerender(props) {
|
|
34
57
|
Object.assign(this.props, props);
|
|
35
58
|
this.service.emitChange(this.key);
|
|
36
59
|
}
|
|
37
60
|
close() {
|
|
38
|
-
this.
|
|
61
|
+
this.visible = false;
|
|
39
62
|
this.service.emitChange(this.key);
|
|
40
63
|
}
|
|
41
64
|
}
|
|
@@ -47,62 +70,43 @@ export class DialogService {
|
|
|
47
70
|
writable: true,
|
|
48
71
|
value: -1
|
|
49
72
|
});
|
|
50
|
-
Object.defineProperty(this, "
|
|
73
|
+
Object.defineProperty(this, "_emitChange", {
|
|
51
74
|
enumerable: true,
|
|
52
75
|
configurable: true,
|
|
53
76
|
writable: true,
|
|
54
|
-
value:
|
|
77
|
+
value: void 0
|
|
55
78
|
});
|
|
56
|
-
Object.defineProperty(this, "
|
|
79
|
+
Object.defineProperty(this, "dialogs", {
|
|
57
80
|
enumerable: true,
|
|
58
81
|
configurable: true,
|
|
59
82
|
writable: true,
|
|
60
|
-
value:
|
|
83
|
+
value: []
|
|
61
84
|
});
|
|
62
85
|
this._emitChange = () => {
|
|
63
|
-
emitChange([].concat(this.
|
|
86
|
+
emitChange([].concat(this.dialogs));
|
|
64
87
|
};
|
|
65
88
|
}
|
|
66
89
|
open(type, props, key) {
|
|
67
90
|
const dialogKey = key !== null && key !== void 0 ? key : `l_#${++this._key}`;
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
(_b = (_a = props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
71
|
-
const index = this._dialogs.findIndex((dialog) => dialog.key === dialogKey);
|
|
72
|
-
if (index !== -1) {
|
|
73
|
-
const instance = this._dialogs[index];
|
|
74
|
-
instance.close();
|
|
75
|
-
}
|
|
76
|
-
}, afterVisibleChange: (visible) => {
|
|
77
|
-
var _a, _b;
|
|
78
|
-
(_b = (_a = props).afterVisibleChange) === null || _b === void 0 ? void 0 : _b.call(_a, visible);
|
|
79
|
-
if (!visible) {
|
|
80
|
-
const index = this._dialogs.findIndex((dialog) => dialog.key === dialogKey);
|
|
81
|
-
if (index !== -1) {
|
|
82
|
-
this._dialogs.splice(index, 1);
|
|
83
|
-
this._emitChange();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
} });
|
|
87
|
-
const instance = new DialogInstance(dialogKey, type, dialogProps, this);
|
|
88
|
-
this._dialogs.push(instance);
|
|
91
|
+
const instance = new DialogInstance(dialogKey, type, props, this);
|
|
92
|
+
this.dialogs.push(instance);
|
|
89
93
|
this._emitChange();
|
|
90
94
|
return instance;
|
|
91
95
|
}
|
|
92
96
|
emitChange(key) {
|
|
93
|
-
const index = this.
|
|
97
|
+
const index = this.dialogs.findIndex((dialog) => dialog.key === key);
|
|
94
98
|
if (index !== -1) {
|
|
95
99
|
this._emitChange();
|
|
96
100
|
}
|
|
97
101
|
}
|
|
98
102
|
closeAll(animation = true) {
|
|
99
103
|
if (animation) {
|
|
100
|
-
this.
|
|
104
|
+
this.dialogs.forEach((dialog) => {
|
|
101
105
|
dialog.close();
|
|
102
106
|
});
|
|
103
107
|
}
|
|
104
108
|
else {
|
|
105
|
-
this.
|
|
109
|
+
this.dialogs = [];
|
|
106
110
|
this._emitChange();
|
|
107
111
|
}
|
|
108
112
|
}
|
package/drawer/Drawer.js
CHANGED
|
@@ -5,7 +5,7 @@ import { use, useId, useRef, useState } from 'react';
|
|
|
5
5
|
import { DrawerFooter } from './DrawerFooter';
|
|
6
6
|
import { DrawerHeader } from './DrawerHeader';
|
|
7
7
|
import { CLASSES, DrawerContext } from './vars';
|
|
8
|
-
import { useComponentProps, useLockScroll,
|
|
8
|
+
import { useComponentProps, useLockScroll, useNamespace, useStyled, useZIndex } from '../hooks';
|
|
9
9
|
import { LazyLoading } from '../internal/lazy-loading';
|
|
10
10
|
import { Portal } from '../internal/portal';
|
|
11
11
|
import { Mask } from '../mask';
|
|
@@ -38,12 +38,12 @@ export const Drawer = (props) => {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
const [offset, setOffset] = useState(0);
|
|
41
|
-
const
|
|
41
|
+
const zIndexValue = useZIndex(visible);
|
|
42
42
|
const zIndex = !isUndefined(zIndexProp)
|
|
43
43
|
? zIndexProp
|
|
44
44
|
: !isFixed
|
|
45
45
|
? `var(--${namespace}-zindex-absolute)`
|
|
46
|
-
: `calc(var(--${namespace}-zindex-fixed) + ${
|
|
46
|
+
: `calc(var(--${namespace}-zindex-fixed) + ${zIndexValue})`;
|
|
47
47
|
useLockScroll(isFixed && visible);
|
|
48
48
|
return (_jsx(Portal, { selector: isUndefined(container)
|
|
49
49
|
? () => {
|
package/dropdown/Dropdown.js
CHANGED
|
@@ -9,7 +9,7 @@ import { DropdownItem as DropdownItemFC } from './internal/DropdownItem';
|
|
|
9
9
|
import { DropdownSub } from './internal/DropdownSub';
|
|
10
10
|
import { checkEnableItem, getSameLevelEnableItems } from './utils';
|
|
11
11
|
import { CLASSES } from './vars';
|
|
12
|
-
import { useComponentProps, useContainerScrolling, useControlled, useFocusVisible,
|
|
12
|
+
import { useComponentProps, useContainerScrolling, useControlled, useFocusVisible, useNamespace, useNestedPopup, useStyled, useTranslation, useZIndex, } from '../hooks';
|
|
13
13
|
import { Popup } from '../internal/popup';
|
|
14
14
|
import { Portal } from '../internal/portal';
|
|
15
15
|
import { Separator } from '../separator';
|
|
@@ -87,8 +87,8 @@ export function Dropdown(props) {
|
|
|
87
87
|
reduceArr(list);
|
|
88
88
|
setFocusIds(ids);
|
|
89
89
|
};
|
|
90
|
-
const
|
|
91
|
-
const zIndex = !isUndefined(zIndexProp) ? zIndexProp : `calc(var(--${namespace}-zindex-fixed) + ${
|
|
90
|
+
const zIndexValue = useZIndex(visible);
|
|
91
|
+
const zIndex = !isUndefined(zIndexProp) ? zIndexProp : `calc(var(--${namespace}-zindex-fixed) + ${zIndexValue})`;
|
|
92
92
|
const placement = useRef(placementProp);
|
|
93
93
|
const updatePosition = useEventCallback(() => {
|
|
94
94
|
if (visible && triggerRef.current && dropdownRef.current && popupRef.current) {
|
package/hooks/index.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ export { useDialogService } from './useDialogService';
|
|
|
6
6
|
export { useFocusVisible } from './useFocusVisible';
|
|
7
7
|
export { useLayout } from './useLayout';
|
|
8
8
|
export { useLockScroll } from './useLockScroll';
|
|
9
|
-
export { useMaxIndex } from './useMaxIndex';
|
|
10
9
|
export { useNamespace } from './useNamespace';
|
|
11
10
|
export { useNestedPopup } from './useNestedPopup';
|
|
12
11
|
export { useScopedProps } from './useScopedProps';
|
|
13
12
|
export { useStyled } from './useStyled';
|
|
14
13
|
export { useTranslation } from './useTranslation';
|
|
14
|
+
export { useZIndex } from './useZIndex';
|
package/hooks/index.js
CHANGED
|
@@ -6,9 +6,9 @@ export { useDialogService } from './useDialogService';
|
|
|
6
6
|
export { useFocusVisible } from './useFocusVisible';
|
|
7
7
|
export { useLayout } from './useLayout';
|
|
8
8
|
export { useLockScroll } from './useLockScroll';
|
|
9
|
-
export { useMaxIndex } from './useMaxIndex';
|
|
10
9
|
export { useNamespace } from './useNamespace';
|
|
11
10
|
export { useNestedPopup } from './useNestedPopup';
|
|
12
11
|
export { useScopedProps } from './useScopedProps';
|
|
13
12
|
export { useStyled } from './useStyled';
|
|
14
13
|
export { useTranslation } from './useTranslation';
|
|
14
|
+
export { useZIndex } from './useZIndex';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useZIndex(visible: boolean): number;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useUnmount } from '@laser-ui/hooks';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
let ZINDEX = [];
|
|
4
|
+
export function useZIndex(visible) {
|
|
5
|
+
var _a;
|
|
6
|
+
const previousVisible = useRef(false);
|
|
7
|
+
const zIndex = useRef(0);
|
|
8
|
+
if (visible !== previousVisible.current) {
|
|
9
|
+
previousVisible.current = visible;
|
|
10
|
+
if (visible) {
|
|
11
|
+
zIndex.current = ((_a = ZINDEX[ZINDEX.length - 1]) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
12
|
+
ZINDEX.push(zIndex.current);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
ZINDEX = ZINDEX.filter((val) => val !== zIndex.current);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
useUnmount(() => {
|
|
19
|
+
ZINDEX = ZINDEX.filter((z) => z !== zIndex.current);
|
|
20
|
+
});
|
|
21
|
+
return zIndex.current;
|
|
22
|
+
}
|
package/image/ImagePreview.js
CHANGED
|
@@ -12,7 +12,7 @@ import { isNull, isUndefined } from 'lodash';
|
|
|
12
12
|
import { useRef, useState } from 'react';
|
|
13
13
|
import { PREVIEW_CLASSES } from './vars';
|
|
14
14
|
import { Button } from '../button';
|
|
15
|
-
import { useComponentProps, useControlled, useLockScroll,
|
|
15
|
+
import { useComponentProps, useControlled, useLockScroll, useNamespace, useStyled, useZIndex } from '../hooks';
|
|
16
16
|
import { Icon } from '../icon';
|
|
17
17
|
import { Input } from '../input';
|
|
18
18
|
import { Portal } from '../internal/portal';
|
|
@@ -49,8 +49,8 @@ export function ImagePreview(props) {
|
|
|
49
49
|
startIndex = Math.max(endIndex - offset * 2, 0);
|
|
50
50
|
const [isDragging, setIsDragging] = useState(false);
|
|
51
51
|
const listenDragEvent = visible && isDragging;
|
|
52
|
-
const
|
|
53
|
-
const zIndex = !isUndefined(zIndexProp) ? zIndexProp : `calc(var(--${namespace}-zindex-fixed) + ${
|
|
52
|
+
const zIndexValue = useZIndex(visible);
|
|
53
|
+
const zIndex = !isUndefined(zIndexProp) ? zIndexProp : `calc(var(--${namespace}-zindex-fixed) + ${zIndexValue})`;
|
|
54
54
|
useLockScroll(visible);
|
|
55
55
|
const setTransform = (update, scaleByClick = false) => {
|
|
56
56
|
var _a, _b;
|
package/menu/internal/MenuSub.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useEventCallback } from '@laser-ui/hooks';
|
|
|
3
3
|
import { checkNodeExist } from '@laser-ui/utils';
|
|
4
4
|
import { isUndefined } from 'lodash';
|
|
5
5
|
import { useImperativeHandle, useRef } from 'react';
|
|
6
|
-
import {
|
|
6
|
+
import { useTranslation, useZIndex } from '../../hooks';
|
|
7
7
|
import { Popup } from '../../internal/popup';
|
|
8
8
|
import { Portal } from '../../internal/portal';
|
|
9
9
|
import { CollapseTransition, Transition } from '../../transition';
|
|
@@ -42,7 +42,8 @@ export function MenuSub(props) {
|
|
|
42
42
|
popupRef.current.style.width = inHorizontalNav ? width + 'px' : '';
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
|
-
const
|
|
45
|
+
const zIndexValue = useZIndex(visible);
|
|
46
|
+
const zIndex = `calc(var(--${namespace}-zindex-fixed) + ${zIndexValue})`;
|
|
46
47
|
useImperativeHandle(ref, () => updatePosition, [updatePosition]);
|
|
47
48
|
return (_jsxs(_Fragment, { children: [_jsx(Popup, { visible: popupState !== null && popupState !== void 0 ? popupState : false, trigger: trigger, disabled: disabled || mode === 'vertical', updatePosition: {
|
|
48
49
|
fn: updatePosition,
|
|
@@ -78,7 +79,7 @@ export function MenuSub(props) {
|
|
|
78
79
|
}
|
|
79
80
|
return el;
|
|
80
81
|
}, children: _jsx(Transition, { enter: visible, name: `${namespace}-popup-down`, duration: TTANSITION_DURING_POPUP, onSkipEnter: updatePosition, onBeforeEnter: updatePosition, children: (transitionRef, leaved) => (_jsx("div", Object.assign({}, mergeCS(styled('menu-popup'), {
|
|
81
|
-
style: Object.assign(Object.assign({ zIndex
|
|
82
|
+
style: Object.assign(Object.assign({ zIndex }, (inHorizontalNav ? undefined : { '--popup-down-scale': 0.01, minWidth: 160 })), (leaved ? { display: 'none' } : undefined)),
|
|
82
83
|
}), { ref: (instance) => {
|
|
83
84
|
popupRef.current = instance;
|
|
84
85
|
transitionRef(instance);
|
package/modal/Modal.js
CHANGED
|
@@ -6,7 +6,7 @@ import { ModalAlert } from './ModalAlert';
|
|
|
6
6
|
import { ModalFooter } from './ModalFooter';
|
|
7
7
|
import { ModalHeader } from './ModalHeader';
|
|
8
8
|
import { CLASSES, ModalContext } from './vars';
|
|
9
|
-
import { useComponentProps, useLockScroll,
|
|
9
|
+
import { useComponentProps, useLockScroll, useNamespace, useStyled, useZIndex } from '../hooks';
|
|
10
10
|
import { LazyLoading } from '../internal/lazy-loading';
|
|
11
11
|
import { Portal } from '../internal/portal';
|
|
12
12
|
import { Mask } from '../mask';
|
|
@@ -24,8 +24,8 @@ export const Modal = (props) => {
|
|
|
24
24
|
const uniqueId = useId();
|
|
25
25
|
const titleId = `${namespace}-modal-title-${uniqueId}`;
|
|
26
26
|
const bodyId = `${namespace}-modal-content-${uniqueId}`;
|
|
27
|
-
const
|
|
28
|
-
const zIndex = !isUndefined(zIndexProp) ? zIndexProp : `calc(var(--${namespace}-zindex-fixed) + ${
|
|
27
|
+
const zIndexValue = useZIndex(visible);
|
|
28
|
+
const zIndex = !isUndefined(zIndexProp) ? zIndexProp : `calc(var(--${namespace}-zindex-fixed) + ${zIndexValue})`;
|
|
29
29
|
useLockScroll(visible);
|
|
30
30
|
return (_jsx(Portal, { selector: () => {
|
|
31
31
|
let el = document.getElementById(`${namespace}-modal-root`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laser-ui/components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "React components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"access": "public",
|
|
38
38
|
"directory": "../../dist/libs/components"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "2d2d855edaebaab9445064d804a50175a0408b2d"
|
|
41
41
|
}
|
package/popover/Popover.js
CHANGED
|
@@ -6,7 +6,7 @@ import { useId, useImperativeHandle, useRef } from 'react';
|
|
|
6
6
|
import { PopoverFooter } from './PopoverFooter';
|
|
7
7
|
import { PopoverHeader } from './PopoverHeader';
|
|
8
8
|
import { CLASSES, PopoverContext, TTANSITION_DURING } from './vars';
|
|
9
|
-
import { useComponentProps, useControlled, useLockScroll,
|
|
9
|
+
import { useComponentProps, useControlled, useLockScroll, useNamespace, useStyled, useZIndex } from '../hooks';
|
|
10
10
|
import { LazyLoading } from '../internal/lazy-loading';
|
|
11
11
|
import { Popup } from '../internal/popup';
|
|
12
12
|
import { Portal } from '../internal/portal';
|
|
@@ -26,8 +26,8 @@ export const Popover = (props) => {
|
|
|
26
26
|
const popupRef = useRef(null);
|
|
27
27
|
const prevActiveEl = useRef(null);
|
|
28
28
|
const [visible, changeVisible] = useControlled(defaultVisible !== null && defaultVisible !== void 0 ? defaultVisible : false, visibleProp, onVisibleChange);
|
|
29
|
-
const
|
|
30
|
-
const zIndex = !isUndefined(zIndexProp) ? zIndexProp : `calc(var(--${namespace}-zindex-fixed) + ${
|
|
29
|
+
const zIndexValue = useZIndex(visible);
|
|
30
|
+
const zIndex = !isUndefined(zIndexProp) ? zIndexProp : `calc(var(--${namespace}-zindex-fixed) + ${zIndexValue})`;
|
|
31
31
|
const placement = useRef(placementProp);
|
|
32
32
|
const updatePosition = useEventCallback(() => {
|
|
33
33
|
if (visible && triggerRef.current && popoverRef.current && popupRef.current) {
|
package/select/Select.js
CHANGED
|
@@ -16,7 +16,7 @@ import { Checkbox } from '../checkbox';
|
|
|
16
16
|
import { CircularProgress } from '../circular-progress';
|
|
17
17
|
import { Dropdown } from '../dropdown';
|
|
18
18
|
import { Empty } from '../empty';
|
|
19
|
-
import { useComponentProps, useContainerScrolling, useControlled, useDesign, useFocusVisible, useLayout,
|
|
19
|
+
import { useComponentProps, useContainerScrolling, useControlled, useDesign, useFocusVisible, useLayout, useNamespace, useScopedProps, useStyled, useTranslation, useZIndex, } from '../hooks';
|
|
20
20
|
import { Icon } from '../icon';
|
|
21
21
|
import { Portal } from '../internal/portal';
|
|
22
22
|
import { ROOT_DATA } from '../root/vars';
|
|
@@ -169,8 +169,8 @@ export function Select(props) {
|
|
|
169
169
|
onCreateItem === null || onCreateItem === void 0 ? void 0 : onCreateItem(newItem);
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
|
-
const
|
|
173
|
-
const zIndex = `calc(var(--${namespace}-zindex-fixed) + ${
|
|
172
|
+
const zIndexValue = useZIndex(visible);
|
|
173
|
+
const zIndex = `calc(var(--${namespace}-zindex-fixed) + ${zIndexValue})`;
|
|
174
174
|
const updatePosition = useEventCallback(() => {
|
|
175
175
|
if (visible && boxRef.current && popupRef.current) {
|
|
176
176
|
if (monospaced) {
|
|
@@ -13,7 +13,7 @@ import { CLASSES } from './vars';
|
|
|
13
13
|
import { BaseInput } from '../base-input';
|
|
14
14
|
import { Button } from '../button';
|
|
15
15
|
import dayjs from '../dayjs';
|
|
16
|
-
import { useComponentProps, useContainerScrolling, useControlled, useDesign, useLayout,
|
|
16
|
+
import { useComponentProps, useContainerScrolling, useControlled, useDesign, useLayout, useNamespace, useScopedProps, useStyled, useTranslation, useZIndex, } from '../hooks';
|
|
17
17
|
import { Icon } from '../icon';
|
|
18
18
|
import { Portal } from '../internal/portal';
|
|
19
19
|
import { ROOT_DATA } from '../root/vars';
|
|
@@ -102,8 +102,8 @@ export function TimePicker(props) {
|
|
|
102
102
|
? ((_b = placeholder) !== null && _b !== void 0 ? _b : [])
|
|
103
103
|
: [placeholder];
|
|
104
104
|
const { size, disabled } = useScopedProps({ size: sizeProp, disabled: disabledProp || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
|
|
105
|
-
const
|
|
106
|
-
const zIndex = `calc(var(--${namespace}-zindex-fixed) + ${
|
|
105
|
+
const zIndexValue = useZIndex(visible);
|
|
106
|
+
const zIndex = `calc(var(--${namespace}-zindex-fixed) + ${zIndexValue})`;
|
|
107
107
|
const updatePosition = useEventCallback(() => {
|
|
108
108
|
if (visible && boxRef.current && popupRef.current) {
|
|
109
109
|
const height = popupRef.current.offsetHeight;
|
package/tooltip/Tooltip.js
CHANGED
|
@@ -4,7 +4,7 @@ import { useEventCallback, useRefExtra } from '@laser-ui/hooks';
|
|
|
4
4
|
import { isUndefined } from 'lodash';
|
|
5
5
|
import { useId, useImperativeHandle, useRef } from 'react';
|
|
6
6
|
import { CLASSES, TTANSITION_DURING } from './vars';
|
|
7
|
-
import { useComponentProps, useControlled,
|
|
7
|
+
import { useComponentProps, useControlled, useNamespace, useStyled, useZIndex } from '../hooks';
|
|
8
8
|
import { LazyLoading } from '../internal/lazy-loading';
|
|
9
9
|
import { Popup } from '../internal/popup';
|
|
10
10
|
import { Portal } from '../internal/portal';
|
|
@@ -20,8 +20,8 @@ export function Tooltip(props) {
|
|
|
20
20
|
const triggerRef = useRefExtra(() => document.querySelector(`[aria-describedby="${id}"]`));
|
|
21
21
|
const tooltipRef = useRef(null);
|
|
22
22
|
const [visible, changeVisible] = useControlled(defaultVisible !== null && defaultVisible !== void 0 ? defaultVisible : false, visibleProp, onVisibleChange);
|
|
23
|
-
const
|
|
24
|
-
const zIndex = !isUndefined(zIndexProp) ? zIndexProp : `calc(var(--${namespace}-zindex-fixed) + ${
|
|
23
|
+
const zIndexValue = useZIndex(visible);
|
|
24
|
+
const zIndex = !isUndefined(zIndexProp) ? zIndexProp : `calc(var(--${namespace}-zindex-fixed) + ${zIndexValue})`;
|
|
25
25
|
const placement = useRef(placementProp);
|
|
26
26
|
const updatePosition = useEventCallback(() => {
|
|
27
27
|
if (visible && triggerRef.current && tooltipRef.current) {
|
|
@@ -13,7 +13,7 @@ import { CLASSES } from './vars';
|
|
|
13
13
|
import { BaseInput } from '../base-input';
|
|
14
14
|
import { CircularProgress } from '../circular-progress';
|
|
15
15
|
import { Dropdown } from '../dropdown';
|
|
16
|
-
import { useComponentProps, useContainerScrolling, useControlled, useDesign, useFocusVisible, useLayout,
|
|
16
|
+
import { useComponentProps, useContainerScrolling, useControlled, useDesign, useFocusVisible, useLayout, useNamespace, useScopedProps, useStyled, useTranslation, useZIndex, } from '../hooks';
|
|
17
17
|
import { Icon } from '../icon';
|
|
18
18
|
import { Portal } from '../internal/portal';
|
|
19
19
|
import { ROOT_DATA } from '../root/vars';
|
|
@@ -173,8 +173,8 @@ export function TreeSelect(props) {
|
|
|
173
173
|
return findNested(searchList, (item) => item[TREE_NODE_KEY].enabled);
|
|
174
174
|
}
|
|
175
175
|
})();
|
|
176
|
-
const
|
|
177
|
-
const zIndex = `calc(var(--${namespace}-zindex-fixed) + ${
|
|
176
|
+
const zIndexValue = useZIndex(visible);
|
|
177
|
+
const zIndex = `calc(var(--${namespace}-zindex-fixed) + ${zIndexValue})`;
|
|
178
178
|
const updatePosition = useEventCallback(() => {
|
|
179
179
|
if (visible && boxRef.current && popupRef.current) {
|
|
180
180
|
const boxWidth = boxRef.current.offsetWidth;
|
package/hooks/useMaxIndex.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useMaxIndex(visible: boolean): number;
|
package/hooks/useMaxIndex.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { useUnmount } from '@laser-ui/hooks';
|
|
2
|
-
import { nth } from 'lodash';
|
|
3
|
-
import { useMemo, useRef } from 'react';
|
|
4
|
-
let ZINDEX = [];
|
|
5
|
-
export function useMaxIndex(visible) {
|
|
6
|
-
const zIndex = useRef(0);
|
|
7
|
-
const maxZIndex = useMemo(() => {
|
|
8
|
-
var _a;
|
|
9
|
-
if (visible) {
|
|
10
|
-
const z = ((_a = nth(ZINDEX, -1)) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
11
|
-
zIndex.current = z;
|
|
12
|
-
ZINDEX.push(z);
|
|
13
|
-
return z;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
ZINDEX = ZINDEX.filter((z) => z !== zIndex.current);
|
|
17
|
-
return zIndex.current;
|
|
18
|
-
}
|
|
19
|
-
}, [visible]);
|
|
20
|
-
useUnmount(() => {
|
|
21
|
-
ZINDEX = ZINDEX.filter((z) => z !== zIndex.current);
|
|
22
|
-
});
|
|
23
|
-
return maxZIndex;
|
|
24
|
-
}
|