@laser-ui/components 2.1.1 → 2.1.2
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 +7 -0
- package/dialog-service.d.ts +1 -1
- package/dialog-service.js +5 -8
- package/hooks/useZIndex.js +21 -11
- package/package.json +2 -2
- package/root/Dialogs.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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.2](https://github.com/laser-ui/laser-ui/compare/v2.1.1...v2.1.2) (2025-06-16)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **components:** fix dialogs ([d4d2d21](https://github.com/laser-ui/laser-ui/commit/d4d2d217aa126119fc4b802fb741c73439f7af85))
|
|
10
|
+
- **components:** fix zindex ([1548071](https://github.com/laser-ui/laser-ui/commit/154807147ff83f860a2c2647a62f27ed99a3b8fd))
|
|
11
|
+
|
|
5
12
|
## [2.1.1](https://github.com/laser-ui/laser-ui/compare/v2.1.0...v2.1.1) (2025-06-16)
|
|
6
13
|
|
|
7
14
|
### Bug Fixes
|
package/dialog-service.d.ts
CHANGED
|
@@ -16,6 +16,6 @@ export declare class DialogService {
|
|
|
16
16
|
dialogs: DialogInstance<any>[];
|
|
17
17
|
constructor(emitChange: (dialogs: DialogInstance<any>[]) => void);
|
|
18
18
|
open<P extends object>(type: React.FC<P>, props: Omit<P, 'visible'>, key?: string | number): DialogInstance<P>;
|
|
19
|
-
emitChange(
|
|
19
|
+
emitChange(): void;
|
|
20
20
|
closeAll(animation?: boolean): void;
|
|
21
21
|
}
|
package/dialog-service.js
CHANGED
|
@@ -17,7 +17,7 @@ export class DialogInstance {
|
|
|
17
17
|
if (index !== -1) {
|
|
18
18
|
this.service.dialogs.splice(index, 1);
|
|
19
19
|
}
|
|
20
|
-
this.service.emitChange(
|
|
20
|
+
this.service.emitChange();
|
|
21
21
|
}
|
|
22
22
|
} }), this.key));
|
|
23
23
|
}
|
|
@@ -55,11 +55,11 @@ export class DialogInstance {
|
|
|
55
55
|
}
|
|
56
56
|
rerender(props) {
|
|
57
57
|
Object.assign(this.props, props);
|
|
58
|
-
this.service.emitChange(
|
|
58
|
+
this.service.emitChange();
|
|
59
59
|
}
|
|
60
60
|
close() {
|
|
61
61
|
this.visible = false;
|
|
62
|
-
this.service.emitChange(
|
|
62
|
+
this.service.emitChange();
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
export class DialogService {
|
|
@@ -93,11 +93,8 @@ export class DialogService {
|
|
|
93
93
|
this._emitChange();
|
|
94
94
|
return instance;
|
|
95
95
|
}
|
|
96
|
-
emitChange(
|
|
97
|
-
|
|
98
|
-
if (index !== -1) {
|
|
99
|
-
this._emitChange();
|
|
100
|
-
}
|
|
96
|
+
emitChange() {
|
|
97
|
+
this._emitChange();
|
|
101
98
|
}
|
|
102
99
|
closeAll(animation = true) {
|
|
103
100
|
if (animation) {
|
package/hooks/useZIndex.js
CHANGED
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
import { useUnmount } from '@laser-ui/hooks';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { isUndefined } from 'lodash';
|
|
3
|
+
import { useId, useRef } from 'react';
|
|
4
|
+
const ZINDEX = [0];
|
|
5
|
+
const INDEX = new Map();
|
|
4
6
|
export function useZIndex(visible) {
|
|
5
|
-
|
|
6
|
-
const previousVisible = useRef(false);
|
|
7
|
+
const id = useId();
|
|
7
8
|
const zIndex = useRef(0);
|
|
8
|
-
if (visible
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
zIndex.current =
|
|
9
|
+
if (visible) {
|
|
10
|
+
const index = INDEX.get(id);
|
|
11
|
+
if (isUndefined(index)) {
|
|
12
|
+
zIndex.current = ZINDEX[ZINDEX.length - 1] + 1;
|
|
12
13
|
ZINDEX.push(zIndex.current);
|
|
14
|
+
INDEX.set(id, ZINDEX.length - 1);
|
|
13
15
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
const index = INDEX.get(id);
|
|
19
|
+
if (!isUndefined(index)) {
|
|
20
|
+
ZINDEX.splice(index, 1);
|
|
21
|
+
INDEX.delete(id);
|
|
16
22
|
}
|
|
17
23
|
}
|
|
18
24
|
useUnmount(() => {
|
|
19
|
-
|
|
25
|
+
const index = INDEX.get(id);
|
|
26
|
+
if (!isUndefined(index)) {
|
|
27
|
+
ZINDEX.splice(index, 1);
|
|
28
|
+
INDEX.delete(id);
|
|
29
|
+
}
|
|
20
30
|
});
|
|
21
31
|
return zIndex.current;
|
|
22
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laser-ui/components",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
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": "52633969337fe51323792d2fb71ad230057b681b"
|
|
41
41
|
}
|
package/root/Dialogs.js
CHANGED