@laser-ui/components 2.0.2 → 2.0.4
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/form/FormItem.js +4 -2
- package/form/hooks.js +4 -2
- package/hooks/useMaxIndex.js +15 -23
- package/package.json +2 -2
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.0.4](https://github.com/laser-ui/laser-ui/compare/v2.0.3...v2.0.4) (2025-01-06)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **components:** fix `useMaxIndex` ([c09e8b9](https://github.com/laser-ui/laser-ui/commit/c09e8b93409f72f3b0ff45564c0228139302905c))
|
|
10
|
+
|
|
11
|
+
## [2.0.3](https://github.com/laser-ui/laser-ui/compare/v2.0.2...v2.0.3) (2024-12-25)
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
- **components:** fix form emit change ([37e7c2b](https://github.com/laser-ui/laser-ui/commit/37e7c2bb37d70190d4d86c021977bcf3cb936134))
|
|
16
|
+
|
|
5
17
|
## [2.0.2](https://github.com/laser-ui/laser-ui/compare/v2.0.1...v2.0.2) (2024-12-19)
|
|
6
18
|
|
|
7
19
|
**Note:** Version bump only for package @laser-ui/components
|
package/form/FormItem.js
CHANGED
|
@@ -43,7 +43,9 @@ export function FormItem(props) {
|
|
|
43
43
|
throw new Error(`Cant find '${controlName}', please check if name exists!`);
|
|
44
44
|
}
|
|
45
45
|
formControl._emitChange = () => {
|
|
46
|
-
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
47
|
+
formControl._emitChange = () => { };
|
|
48
|
+
formControl._emitChanged = true;
|
|
47
49
|
};
|
|
48
50
|
obj[controlName] = {
|
|
49
51
|
control: formControl,
|
|
@@ -58,7 +60,7 @@ export function FormItem(props) {
|
|
|
58
60
|
useEffect(() => {
|
|
59
61
|
const clear = [];
|
|
60
62
|
for (const { control } of Object.values(formControlProviders)) {
|
|
61
|
-
if (control.
|
|
63
|
+
if (control._emitChanged === true) {
|
|
62
64
|
forceUpdate();
|
|
63
65
|
}
|
|
64
66
|
control._emitChange = forceUpdate;
|
package/form/hooks.js
CHANGED
|
@@ -40,7 +40,9 @@ export function useForm(initForm, deps) {
|
|
|
40
40
|
const [form, setForm] = useState(() => {
|
|
41
41
|
const form = initForm();
|
|
42
42
|
form._emitChange = () => {
|
|
43
|
-
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
44
|
+
form._emitChange = () => { };
|
|
45
|
+
form._emitChanged = true;
|
|
44
46
|
};
|
|
45
47
|
return form;
|
|
46
48
|
});
|
|
@@ -58,7 +60,7 @@ export function useForm(initForm, deps) {
|
|
|
58
60
|
forceUpdate();
|
|
59
61
|
});
|
|
60
62
|
useEffect(() => {
|
|
61
|
-
if (form.
|
|
63
|
+
if (form._emitChanged === true) {
|
|
62
64
|
forceUpdate();
|
|
63
65
|
}
|
|
64
66
|
form._emitChange = emitChange;
|
package/hooks/useMaxIndex.js
CHANGED
|
@@ -1,32 +1,24 @@
|
|
|
1
1
|
import { useUnmount } from '@laser-ui/hooks';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
add(id) {
|
|
6
|
-
let n = 1;
|
|
7
|
-
if (this.record.length > 0) {
|
|
8
|
-
n = this.record[this.record.length - 1].n + 1;
|
|
9
|
-
}
|
|
10
|
-
this.record.push({ id, n });
|
|
11
|
-
return n;
|
|
12
|
-
},
|
|
13
|
-
delete(id) {
|
|
14
|
-
this.record = this.record.filter((item) => item.id !== id);
|
|
15
|
-
},
|
|
16
|
-
};
|
|
2
|
+
import { nth } from 'lodash';
|
|
3
|
+
import { useMemo, useRef } from 'react';
|
|
4
|
+
let ZINDEX = [];
|
|
17
5
|
export function useMaxIndex(visible) {
|
|
18
|
-
const
|
|
19
|
-
const prevMaxZIndex = useRef(0);
|
|
6
|
+
const zIndex = useRef(0);
|
|
20
7
|
const maxZIndex = useMemo(() => {
|
|
8
|
+
var _a;
|
|
21
9
|
if (visible) {
|
|
22
|
-
|
|
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;
|
|
23
18
|
}
|
|
24
|
-
|
|
25
|
-
return prevMaxZIndex.current;
|
|
26
|
-
}, [id, visible]);
|
|
27
|
-
prevMaxZIndex.current = maxZIndex;
|
|
19
|
+
}, [visible]);
|
|
28
20
|
useUnmount(() => {
|
|
29
|
-
|
|
21
|
+
ZINDEX = ZINDEX.filter((z) => z !== zIndex.current);
|
|
30
22
|
});
|
|
31
23
|
return maxZIndex;
|
|
32
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laser-ui/components",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
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": "c1b2e9c6d6a38ae529eb752693fcdf3e299fb0e4"
|
|
41
41
|
}
|