@laser-ui/components 2.0.4 → 2.1.0
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/dialog-service.d.ts +2 -1
- package/dialog-service.js +35 -31
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +2 -2
- package/root/Dialogs.d.ts +5 -0
- package/root/Dialogs.js +4 -0
- package/root/Root.js +3 -2
- package/root/index.d.ts +1 -0
- package/root/index.js +1 -0
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.0](https://github.com/laser-ui/laser-ui/compare/v2.0.5...v2.1.0) (2025-06-09)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- **components:** support prevent close dialog ([6431830](https://github.com/laser-ui/laser-ui/commit/6431830b84ad26d3985f634b52e348f959eac674))
|
|
10
|
+
|
|
11
|
+
## [2.0.5](https://github.com/laser-ui/laser-ui/compare/v2.0.4...v2.0.5) (2025-01-13)
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- **components:** add `Dialogs` ([eca6d58](https://github.com/laser-ui/laser-ui/commit/eca6d580b7ea94990f8b80e1672f6eaec601550e))
|
|
16
|
+
|
|
5
17
|
## [2.0.4](https://github.com/laser-ui/laser-ui/compare/v2.0.3...v2.0.4) (2025-01-06)
|
|
6
18
|
|
|
7
19
|
### Bug Fixes
|
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/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { useDialogService } from './hooks';
|
|
2
|
-
export { Root, DialogService } from './root';
|
|
2
|
+
export { Root, DialogService, Dialogs } from './root';
|
|
3
3
|
export { ConfigProvider } from './config-provider';
|
|
4
4
|
export { Accordion } from './accordion';
|
|
5
5
|
export { Affix } from './affix';
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { useDialogService } from './hooks';
|
|
2
|
-
export { Root, DialogService } from './root';
|
|
2
|
+
export { Root, DialogService, Dialogs } from './root';
|
|
3
3
|
export { ConfigProvider } from './config-provider';
|
|
4
4
|
export { Accordion } from './accordion';
|
|
5
5
|
export { Affix } from './affix';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laser-ui/components",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
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": "256aa0e63ef12fec93818bc3e528f3bd9f85f048"
|
|
41
41
|
}
|
package/root/Dialogs.js
ADDED
package/root/Root.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEvent, useRefExtra } from '@laser-ui/hooks';
|
|
3
3
|
import { isString, set } from 'lodash';
|
|
4
4
|
import { useEffect, useMemo } from 'react';
|
|
5
|
+
import { Dialogs } from './Dialogs';
|
|
5
6
|
import { useDialogs } from './dialog-service';
|
|
6
7
|
import { ROOT_DATA, RootContext } from './vars';
|
|
7
8
|
import dayjs from '../dayjs';
|
|
@@ -69,5 +70,5 @@ export function Root(props) {
|
|
|
69
70
|
default:
|
|
70
71
|
break;
|
|
71
72
|
}
|
|
72
|
-
return (_jsxs(RootContext, { value: context, children: [children,
|
|
73
|
+
return (_jsxs(RootContext, { value: context, children: [children, _jsx(Dialogs, { dialogs: dialogs })] }));
|
|
73
74
|
}
|
package/root/index.d.ts
CHANGED
package/root/index.js
CHANGED