@doreamonjs/plugin-shared 0.3.4 → 0.3.7
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 +24 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +5 -0
- package/lib/message.d.ts +51 -0
- package/lib/message.js +48 -0
- package/lib/notification.d.ts +57 -0
- package/lib/notification.js +45 -0
- package/lib/router.d.ts +3 -4
- package/lib/router.js +15 -12
- package/lib/shared.d.ts +8 -0
- package/lib/shared.js +23 -0
- package/lib/type.d.ts +8 -0
- package/lib/type.js +2 -0
- package/package.json +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.3.7](https://github.com/zcorky/zodash/compare/v0.3.6...v0.3.7) (2022-08-31)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @doreamonjs/plugin-shared
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.3.6](https://github.com/zcorky/zodash/compare/v0.3.5...v0.3.6) (2022-08-31)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @doreamonjs/plugin-shared
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [0.3.5](https://github.com/zcorky/zodash/compare/v0.3.4...v0.3.5) (2022-08-31)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @doreamonjs/plugin-shared
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
6
30
|
## [0.3.4](https://github.com/zcorky/zodash/compare/v0.3.3...v0.3.4) (2022-08-31)
|
|
7
31
|
|
|
8
32
|
**Note:** Version bump only for package @doreamonjs/plugin-shared
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -10,4 +10,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
const shared_1 = require("./shared");
|
|
14
|
+
__exportStar(require("./type"), exports);
|
|
15
|
+
__exportStar(require("./message"), exports);
|
|
16
|
+
__exportStar(require("./notification"), exports);
|
|
13
17
|
__exportStar(require("./router"), exports);
|
|
18
|
+
window.__doreamonjs = shared_1.shared;
|
package/lib/message.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ReactNode, CSSProperties, MouseEvent } from 'react';
|
|
2
|
+
export interface IMessage {
|
|
3
|
+
info(content: string, duration?: number, onClose?: () => void): void | Promise<void>;
|
|
4
|
+
success(content: string, duration?: number, onClose?: () => void): void | Promise<void>;
|
|
5
|
+
error(content: string, duration?: number, onClose?: () => void): void | Promise<void>;
|
|
6
|
+
warning(content: string, duration?: number, onClose?: () => void): void | Promise<void>;
|
|
7
|
+
loading(content: string, duration?: number, onClose?: () => void): void | Promise<void>;
|
|
8
|
+
open(config: OpenConfig): void | Promise<void>;
|
|
9
|
+
config(options: ConfigMessageOptions): void;
|
|
10
|
+
}
|
|
11
|
+
export interface ConfigMessageOptions {
|
|
12
|
+
top?: number;
|
|
13
|
+
duration?: number;
|
|
14
|
+
prefixCls?: string;
|
|
15
|
+
getContainer?: () => HTMLElement;
|
|
16
|
+
transitionName?: string;
|
|
17
|
+
maxCount?: number;
|
|
18
|
+
rtl?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface OpenConfig {
|
|
21
|
+
content: ReactNode;
|
|
22
|
+
duration?: number;
|
|
23
|
+
type: NoticeType;
|
|
24
|
+
prefixCls?: string;
|
|
25
|
+
rootPrefixCls?: string;
|
|
26
|
+
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
|
|
27
|
+
onClose?: () => void;
|
|
28
|
+
icon?: ReactNode;
|
|
29
|
+
key?: string | number;
|
|
30
|
+
style?: CSSProperties;
|
|
31
|
+
className?: string;
|
|
32
|
+
onClick?: (e: MouseEvent<HTMLDivElement>) => void;
|
|
33
|
+
}
|
|
34
|
+
export declare type NoticeType = 'info' | 'success' | 'error' | 'warning' | 'loading';
|
|
35
|
+
export interface MessageConfig {
|
|
36
|
+
messager?: IMessage;
|
|
37
|
+
}
|
|
38
|
+
export declare class Message implements IMessage {
|
|
39
|
+
private readonly options?;
|
|
40
|
+
private _messager;
|
|
41
|
+
constructor(options?: MessageConfig);
|
|
42
|
+
private get messager();
|
|
43
|
+
info(content: string, duration?: number, onClose?: () => void): void | Promise<void>;
|
|
44
|
+
success(content: string, duration?: number, onClose?: () => void): void | Promise<void>;
|
|
45
|
+
error(content: string, duration?: number, onClose?: () => void): void | Promise<void>;
|
|
46
|
+
warning(content: string, duration?: number, onClose?: () => void): void | Promise<void>;
|
|
47
|
+
loading(content: string, duration?: number, onClose?: () => void): void | Promise<void>;
|
|
48
|
+
open(config: OpenConfig): void | Promise<void>;
|
|
49
|
+
config(options: ConfigMessageOptions): void;
|
|
50
|
+
}
|
|
51
|
+
export declare const message: Message;
|
package/lib/message.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.message = exports.Message = void 0;
|
|
4
|
+
class Message {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.options = options;
|
|
7
|
+
}
|
|
8
|
+
get messager() {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
if (this._messager)
|
|
11
|
+
return this._messager;
|
|
12
|
+
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.messager) {
|
|
13
|
+
this._messager = (_b = this.options) === null || _b === void 0 ? void 0 : _b.messager;
|
|
14
|
+
}
|
|
15
|
+
else if (window.__doreamonjs.has('message')) {
|
|
16
|
+
this._messager = window.__doreamonjs.get('message');
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
throw new Error('[doreamonjs] message is not registered');
|
|
20
|
+
}
|
|
21
|
+
return this._messager;
|
|
22
|
+
}
|
|
23
|
+
info(content, duration, onClose) {
|
|
24
|
+
return this.messager.info(content, duration, onClose);
|
|
25
|
+
}
|
|
26
|
+
success(content, duration, onClose) {
|
|
27
|
+
return this.messager.success(content, duration, onClose);
|
|
28
|
+
}
|
|
29
|
+
error(content, duration, onClose) {
|
|
30
|
+
return this.messager.error(content, duration, onClose);
|
|
31
|
+
}
|
|
32
|
+
warning(content, duration, onClose) {
|
|
33
|
+
return this.messager.warning(content, duration, onClose);
|
|
34
|
+
}
|
|
35
|
+
loading(content, duration, onClose) {
|
|
36
|
+
return this.messager.loading(content, duration, onClose);
|
|
37
|
+
}
|
|
38
|
+
//
|
|
39
|
+
open(config) {
|
|
40
|
+
return this.messager.open(config);
|
|
41
|
+
}
|
|
42
|
+
config(options) {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
return (_b = (_a = this.messager) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.call(_a, options);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.Message = Message;
|
|
48
|
+
exports.message = new Message();
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ReactNode, CSSProperties } from 'react';
|
|
2
|
+
export interface INotification {
|
|
3
|
+
success(cfg: ArgsProps): void;
|
|
4
|
+
error(cfg: ArgsProps): void;
|
|
5
|
+
info(cfg: ArgsProps): void;
|
|
6
|
+
warning(cfg: ArgsProps): void;
|
|
7
|
+
open(cfg: ArgsProps): void;
|
|
8
|
+
config(options: ConfigNotificationOptions): void;
|
|
9
|
+
}
|
|
10
|
+
export interface ArgsProps {
|
|
11
|
+
message: ReactNode;
|
|
12
|
+
description?: ReactNode;
|
|
13
|
+
btn?: ReactNode;
|
|
14
|
+
key?: string;
|
|
15
|
+
onClose?: () => void;
|
|
16
|
+
duration?: number | null;
|
|
17
|
+
icon?: ReactNode;
|
|
18
|
+
placement?: NotificationPlacement;
|
|
19
|
+
style?: CSSProperties;
|
|
20
|
+
prefixCls?: string;
|
|
21
|
+
className?: string;
|
|
22
|
+
readonly type?: IconType;
|
|
23
|
+
onClick?: () => void;
|
|
24
|
+
top?: number;
|
|
25
|
+
bottom?: number;
|
|
26
|
+
getContainer?: () => HTMLElement;
|
|
27
|
+
closeIcon?: ReactNode;
|
|
28
|
+
}
|
|
29
|
+
export interface ConfigNotificationOptions {
|
|
30
|
+
top?: number;
|
|
31
|
+
bottom?: number;
|
|
32
|
+
duration?: number;
|
|
33
|
+
prefixCls?: string;
|
|
34
|
+
placement?: NotificationPlacement;
|
|
35
|
+
getContainer?: () => HTMLElement;
|
|
36
|
+
closeIcon?: ReactNode;
|
|
37
|
+
rtl?: boolean;
|
|
38
|
+
maxCount?: number;
|
|
39
|
+
}
|
|
40
|
+
export declare type NotificationPlacement = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
|
|
41
|
+
export declare type IconType = 'success' | 'info' | 'error' | 'warning';
|
|
42
|
+
export interface NotificationConfig {
|
|
43
|
+
notifier?: INotification;
|
|
44
|
+
}
|
|
45
|
+
export declare class Notification implements INotification {
|
|
46
|
+
private readonly options?;
|
|
47
|
+
private _notifier;
|
|
48
|
+
constructor(options?: NotificationConfig);
|
|
49
|
+
private get notifier();
|
|
50
|
+
success(cfg: ArgsProps): void;
|
|
51
|
+
error(cfg: ArgsProps): void;
|
|
52
|
+
info(cfg: ArgsProps): void;
|
|
53
|
+
warning(cfg: ArgsProps): void;
|
|
54
|
+
open(cfg: ArgsProps): void;
|
|
55
|
+
config(options: ConfigNotificationOptions): void;
|
|
56
|
+
}
|
|
57
|
+
export declare const notification: Notification;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.notification = exports.Notification = void 0;
|
|
4
|
+
class Notification {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.options = options;
|
|
7
|
+
}
|
|
8
|
+
get notifier() {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
if (this._notifier)
|
|
11
|
+
return this._notifier;
|
|
12
|
+
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.notifier) {
|
|
13
|
+
this._notifier = (_b = this.options) === null || _b === void 0 ? void 0 : _b.notifier;
|
|
14
|
+
}
|
|
15
|
+
else if (window.__doreamonjs.has('notification')) {
|
|
16
|
+
this._notifier = window.__doreamonjs.get('notification');
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
throw new Error('[doreamonjs] nitification is not registered');
|
|
20
|
+
}
|
|
21
|
+
return this._notifier;
|
|
22
|
+
}
|
|
23
|
+
success(cfg) {
|
|
24
|
+
return this.notifier.success(cfg);
|
|
25
|
+
}
|
|
26
|
+
error(cfg) {
|
|
27
|
+
return this.notifier.error(cfg);
|
|
28
|
+
}
|
|
29
|
+
info(cfg) {
|
|
30
|
+
return this.notifier.info(cfg);
|
|
31
|
+
}
|
|
32
|
+
warning(cfg) {
|
|
33
|
+
return this.notifier.warning(cfg);
|
|
34
|
+
}
|
|
35
|
+
//
|
|
36
|
+
open(cfg) {
|
|
37
|
+
return this.notifier.open(cfg);
|
|
38
|
+
}
|
|
39
|
+
config(options) {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
return (_b = (_a = this.notifier) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.call(_a, options);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.Notification = Notification;
|
|
45
|
+
exports.notification = new Notification();
|
package/lib/router.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { History } from 'history';
|
|
2
1
|
export interface IRouter {
|
|
3
2
|
push: (path: string | RouteData, state?: any) => void;
|
|
4
3
|
replace: (path: string | RouteData, state?: any) => void;
|
|
@@ -12,13 +11,13 @@ export interface RouteData {
|
|
|
12
11
|
state?: any;
|
|
13
12
|
}
|
|
14
13
|
export interface RouterOptions {
|
|
15
|
-
|
|
14
|
+
router?: IRouter;
|
|
16
15
|
}
|
|
17
16
|
export declare class Router implements IRouter {
|
|
18
17
|
private readonly options?;
|
|
19
|
-
private
|
|
18
|
+
private _router;
|
|
20
19
|
constructor(options?: RouterOptions);
|
|
21
|
-
private get
|
|
20
|
+
private get router();
|
|
22
21
|
push(path: string | RouteData, state?: any): void;
|
|
23
22
|
replace(path: string | RouteData, state?: any): void;
|
|
24
23
|
go(count: number): void;
|
package/lib/router.js
CHANGED
|
@@ -1,34 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.router = exports.Router = void 0;
|
|
4
|
-
const history_1 = require("history");
|
|
5
4
|
class Router {
|
|
6
5
|
constructor(options) {
|
|
7
6
|
this.options = options;
|
|
8
7
|
}
|
|
9
|
-
get
|
|
8
|
+
get router() {
|
|
10
9
|
var _a, _b;
|
|
11
|
-
if (this.
|
|
12
|
-
return this.
|
|
13
|
-
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.
|
|
14
|
-
this.
|
|
10
|
+
if (this._router)
|
|
11
|
+
return this._router;
|
|
12
|
+
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.router) {
|
|
13
|
+
this._router = (_b = this.options) === null || _b === void 0 ? void 0 : _b.router;
|
|
14
|
+
}
|
|
15
|
+
else if (window.__doreamonjs.has('router')) {
|
|
16
|
+
// doreamonjs
|
|
17
|
+
this._router = window.__doreamonjs.get('router');
|
|
15
18
|
}
|
|
16
19
|
else {
|
|
17
|
-
|
|
20
|
+
throw new Error('[doreamonjs] router is not registered');
|
|
18
21
|
}
|
|
19
|
-
return this.
|
|
22
|
+
return this._router;
|
|
20
23
|
}
|
|
21
24
|
push(path, state) {
|
|
22
|
-
this.
|
|
25
|
+
this.router.push(path, state);
|
|
23
26
|
}
|
|
24
27
|
replace(path, state) {
|
|
25
|
-
this.
|
|
28
|
+
this.router.replace(path, state);
|
|
26
29
|
}
|
|
27
30
|
go(count) {
|
|
28
|
-
this.
|
|
31
|
+
this.router.go(count);
|
|
29
32
|
}
|
|
30
33
|
goBack() {
|
|
31
|
-
this.
|
|
34
|
+
this.router.goBack();
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
37
|
exports.Router = Router;
|
package/lib/shared.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare type SharedServiceKey = 'message' | 'notification' | 'router';
|
|
2
|
+
export declare class Shared {
|
|
3
|
+
private store;
|
|
4
|
+
register(key: SharedServiceKey, value: any): void;
|
|
5
|
+
get(key: SharedServiceKey): any;
|
|
6
|
+
has(key: SharedServiceKey): boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const shared: Shared;
|
package/lib/shared.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shared = exports.Shared = void 0;
|
|
4
|
+
class Shared {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.store = {};
|
|
7
|
+
}
|
|
8
|
+
register(key, value) {
|
|
9
|
+
this.store[key] = value;
|
|
10
|
+
}
|
|
11
|
+
get(key) {
|
|
12
|
+
const service = this.store[key];
|
|
13
|
+
if (!service) {
|
|
14
|
+
throw new Error(`Shared service ${key} not registered`);
|
|
15
|
+
}
|
|
16
|
+
return service;
|
|
17
|
+
}
|
|
18
|
+
has(key) {
|
|
19
|
+
return !!this.store[key];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.Shared = Shared;
|
|
23
|
+
exports.shared = new Shared();
|
package/lib/type.d.ts
ADDED
package/lib/type.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doreamonjs/plugin-shared",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "shared plugin for doreamonjs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"doreamonjs",
|
|
@@ -64,10 +64,12 @@
|
|
|
64
64
|
"bugs": {
|
|
65
65
|
"url": "https://github.com/zcorky/zodash/issues"
|
|
66
66
|
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@types/react": "^16"
|
|
69
|
+
},
|
|
67
70
|
"dependencies": {
|
|
68
|
-
"@zcorky/query-string": "^1.0.2",
|
|
69
71
|
"@zodash/doreamon": "^1.0.17",
|
|
70
72
|
"history": "^5.3.0"
|
|
71
73
|
},
|
|
72
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "2cf9eafc163ecd43d50cb9c6bd5c1c82ab5fb37d"
|
|
73
75
|
}
|