linkmore-design 1.0.53 → 1.0.54
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/dist/Alert/ErrorBoundary.d.ts +22 -0
- package/dist/{Notification → Alert}/demos/basic.d.ts +0 -0
- package/dist/{Notification/demos/button.d.ts → Alert/demos/visible.d.ts} +0 -0
- package/dist/Alert/index.d.ts +41 -0
- package/dist/{Notification → Alert}/style/index.d.ts +0 -0
- package/dist/CardTable/fns/index.d.ts +7 -3
- package/dist/CardTable/{toolbar → pager}/TablePagination.d.ts +0 -0
- package/dist/CardTable/pager/index.d.ts +3 -0
- package/dist/LmFilter/LmFilter.d.ts +3 -0
- package/dist/LmFilter/baseFilter/index.d.ts +3 -0
- package/dist/LmFilter/clearFilter/index.d.ts +3 -0
- package/dist/LmFilter/complexFilter/index.d.ts +2 -0
- package/dist/LmFilter/components/CascaderFilter.d.ts +5 -0
- package/dist/LmFilter/components/CheckboxFilter.d.ts +5 -0
- package/dist/LmFilter/components/DateFilter.d.ts +5 -0
- package/dist/LmFilter/components/DropdownFIlter.d.ts +3 -0
- package/dist/LmFilter/components/EmptyFilter.d.ts +2 -0
- package/dist/LmFilter/components/InputFilter.d.ts +4 -0
- package/dist/LmFilter/components/InputSearchClose.d.ts +3 -0
- package/dist/LmFilter/components/SelectFilter.d.ts +5 -0
- package/dist/LmFilter/components/fuzzySearch.d.ts +4 -0
- package/dist/LmFilter/components/index.d.ts +3 -0
- package/dist/LmFilter/customFilter/index.d.ts +2 -0
- package/dist/LmFilter/demos/basic.d.ts +2 -0
- package/dist/LmFilter/filterFns/index.d.ts +12 -0
- package/dist/LmFilter/hooks/index.d.ts +1 -0
- package/dist/LmFilter/hooks/useDelayedFn.d.ts +2 -0
- package/dist/LmFilter/index.d.ts +2 -0
- package/dist/LmFilter/style/index.d.ts +1 -0
- package/dist/LmFilter/utils.d.ts +8 -0
- package/dist/LmFilter/wrapper/Filter.d.ts +3 -0
- package/dist/LmFilter/wrapper/FilterContainer.d.ts +3 -0
- package/dist/LmFilter/wrapper/FilterRoot.d.ts +3 -0
- package/dist/LmFilter/wrapper/FilterWrapper.d.ts +3 -0
- package/dist/_util/getDataOrAriaProps.d.ts +1 -0
- package/dist/_util/reactNode.d.ts +7 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.umd.js +3665 -3297
- package/dist/index.umd.min.js +6 -6
- package/dist/{Notification/demos/icon.d.ts → notification/demos/basic.d.ts} +0 -0
- package/dist/notification/demos/button.d.ts +2 -0
- package/dist/notification/demos/icon.d.ts +2 -0
- package/dist/notification/hooks/useNotification.d.ts +7 -0
- package/dist/notification/index.d.ts +54 -0
- package/dist/notification/style/index.d.ts +1 -0
- package/es/Alert/ErrorBoundary.d.ts +22 -0
- package/es/Alert/ErrorBoundary.js +65 -0
- package/es/Alert/index.d.ts +41 -0
- package/es/Alert/index.js +192 -0
- package/es/{Notification → Alert}/style/index.css +25 -2
- package/es/{Notification → Alert}/style/index.d.ts +0 -0
- package/es/{Notification → Alert}/style/index.js +0 -0
- package/es/CardTable/card/PictureTextColumn.js +8 -6
- package/es/CardTable/card/PictureTextRow.js +1 -1
- package/es/CardTable/fns/index.js +38 -9
- package/es/CardTable/{toolbar → pager}/TablePagination.js +0 -0
- package/es/CardTable/pager/index.js +48 -0
- package/es/CardTable/style/index.css +2 -2
- package/es/CardTable/table/TableRoot.js +20 -18
- package/es/CardTable/table/TableWrapper.js +4 -0
- package/es/CardTable/toolbar/ToolBarBottom.js +8 -27
- package/es/LmFilter/LmFilter.js +27 -0
- package/es/LmFilter/baseFilter/index.js +34 -0
- package/es/LmFilter/clearFilter/index.js +33 -0
- package/es/LmFilter/complexFilter/index.js +17 -0
- package/es/LmFilter/components/CascaderFilter.js +183 -0
- package/es/LmFilter/components/CheckboxFilter.js +197 -0
- package/es/LmFilter/components/DateFilter.js +147 -0
- package/es/LmFilter/components/DropdownFIlter.js +162 -0
- package/es/LmFilter/components/EmptyFilter.js +27 -0
- package/es/LmFilter/components/InputFilter.js +52 -0
- package/es/LmFilter/components/InputSearchClose.js +74 -0
- package/es/LmFilter/components/SelectFilter.js +113 -0
- package/es/LmFilter/components/fuzzySearch.js +37 -0
- package/es/LmFilter/components/index.js +97 -0
- package/es/LmFilter/customFilter/index.js +17 -0
- package/es/LmFilter/filterFns/index.js +54 -0
- package/es/LmFilter/hooks/index.js +18 -0
- package/es/LmFilter/hooks/useDelayedFn.js +27 -0
- package/es/LmFilter/icon_placeholder.png +0 -0
- package/es/LmFilter/index.js +16 -0
- package/es/LmFilter/style/index.js +3 -0
- package/es/LmFilter/style/style.css +189 -0
- package/es/LmFilter/utils.js +55 -0
- package/es/LmFilter/wrapper/Filter.js +33 -0
- package/es/LmFilter/wrapper/FilterContainer.js +29 -0
- package/es/LmFilter/wrapper/FilterRoot.js +114 -0
- package/es/LmFilter/wrapper/FilterWrapper.js +25 -0
- package/es/_util/getDataOrAriaProps.d.ts +1 -0
- package/es/_util/getDataOrAriaProps.js +9 -0
- package/es/_util/reactNode.d.ts +7 -0
- package/es/_util/reactNode.js +10 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/message/style/index.css +1 -0
- package/es/notification/hooks/useNotification.d.ts +7 -0
- package/es/notification/hooks/useNotification.js +54 -0
- package/es/notification/index.d.ts +54 -0
- package/es/notification/index.js +342 -0
- package/es/notification/style/index.css +546 -0
- package/{lib/Notification → es/notification}/style/index.d.ts +0 -0
- package/es/notification/style/index.js +1 -0
- package/lib/Alert/ErrorBoundary.d.ts +22 -0
- package/lib/Alert/ErrorBoundary.js +79 -0
- package/lib/Alert/index.d.ts +41 -0
- package/lib/Alert/index.js +215 -0
- package/lib/{Notification → Alert}/style/index.css +25 -2
- package/lib/Alert/style/index.d.ts +1 -0
- package/lib/{Notification → Alert}/style/index.js +0 -0
- package/lib/CardTable/card/PictureTextColumn.js +8 -6
- package/lib/CardTable/card/PictureTextRow.js +1 -1
- package/lib/CardTable/fns/index.js +38 -9
- package/lib/CardTable/{toolbar → pager}/TablePagination.js +0 -0
- package/lib/CardTable/pager/index.js +48 -0
- package/lib/CardTable/style/index.css +2 -2
- package/lib/CardTable/table/TableRoot.js +20 -18
- package/lib/CardTable/table/TableWrapper.js +4 -0
- package/lib/CardTable/toolbar/ToolBarBottom.js +8 -27
- package/lib/LmFilter/LmFilter.js +27 -0
- package/lib/LmFilter/baseFilter/index.js +34 -0
- package/lib/LmFilter/clearFilter/index.js +33 -0
- package/lib/LmFilter/complexFilter/index.js +17 -0
- package/lib/LmFilter/components/CascaderFilter.js +183 -0
- package/lib/LmFilter/components/CheckboxFilter.js +197 -0
- package/lib/LmFilter/components/DateFilter.js +147 -0
- package/lib/LmFilter/components/DropdownFIlter.js +162 -0
- package/lib/LmFilter/components/EmptyFilter.js +27 -0
- package/lib/LmFilter/components/InputFilter.js +52 -0
- package/lib/LmFilter/components/InputSearchClose.js +74 -0
- package/lib/LmFilter/components/SelectFilter.js +113 -0
- package/lib/LmFilter/components/fuzzySearch.js +37 -0
- package/lib/LmFilter/components/index.js +97 -0
- package/lib/LmFilter/customFilter/index.js +17 -0
- package/lib/LmFilter/filterFns/index.js +54 -0
- package/lib/LmFilter/hooks/index.js +18 -0
- package/lib/LmFilter/hooks/useDelayedFn.js +27 -0
- package/lib/LmFilter/icon_placeholder.png +0 -0
- package/lib/LmFilter/index.js +16 -0
- package/lib/LmFilter/style/index.js +3 -0
- package/lib/LmFilter/style/style.css +189 -0
- package/lib/LmFilter/utils.js +55 -0
- package/lib/LmFilter/wrapper/Filter.js +33 -0
- package/lib/LmFilter/wrapper/FilterContainer.js +29 -0
- package/lib/LmFilter/wrapper/FilterRoot.js +114 -0
- package/lib/LmFilter/wrapper/FilterWrapper.js +25 -0
- package/lib/_util/getDataOrAriaProps.d.ts +1 -0
- package/lib/_util/getDataOrAriaProps.js +16 -0
- package/lib/_util/reactNode.d.ts +7 -0
- package/lib/_util/reactNode.js +24 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -2
- package/lib/message/style/index.css +1 -0
- package/lib/notification/hooks/useNotification.d.ts +7 -0
- package/lib/notification/hooks/useNotification.js +69 -0
- package/lib/notification/index.d.ts +54 -0
- package/lib/notification/index.js +365 -0
- package/lib/notification/style/index.css +546 -0
- package/lib/notification/style/index.d.ts +1 -0
- package/lib/notification/style/index.js +3 -0
- package/package.json +1 -1
- package/dist/Notification/index.d.ts +0 -7
- package/es/Notification/index.d.ts +0 -7
- package/es/Notification/index.js +0 -10
- package/lib/Notification/index.d.ts +0 -7
- package/lib/Notification/index.js +0 -23
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default function getDataOrAriaProps(props) {
|
|
2
|
+
return Object.keys(props).reduce(function (prev, key) {
|
|
3
|
+
if ((key.startsWith('data-') || key.startsWith('aria-') || key === 'role') && !key.startsWith('data-__')) {
|
|
4
|
+
prev[key] = props[key];
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
return prev;
|
|
8
|
+
}, {});
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare const isValidElement: typeof React.isValidElement;
|
|
3
|
+
declare type AnyObject = Record<any, any>;
|
|
4
|
+
declare type RenderProps = undefined | AnyObject | ((originProps: AnyObject) => AnyObject | undefined);
|
|
5
|
+
export declare function replaceElement(element: React.ReactNode, replacement: React.ReactNode, props: RenderProps): React.ReactNode;
|
|
6
|
+
export declare function cloneElement(element: React.ReactNode, props?: RenderProps): React.ReactElement;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
var isValidElement = React.isValidElement;
|
|
3
|
+
export { isValidElement };
|
|
4
|
+
export function replaceElement(element, replacement, props) {
|
|
5
|
+
if (!isValidElement(element)) return replacement;
|
|
6
|
+
return /*#__PURE__*/React.cloneElement(element, typeof props === 'function' ? props(element.props || {}) : props);
|
|
7
|
+
}
|
|
8
|
+
export function cloneElement(element, props) {
|
|
9
|
+
return replaceElement(element, element, props);
|
|
10
|
+
}
|
package/es/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export { default as LmSelect } from './LmSelect';
|
|
|
22
22
|
export { default as LoadingPage } from './LoadingPage';
|
|
23
23
|
export { default as Menu } from './Menu';
|
|
24
24
|
export { default as Modal } from './Modal';
|
|
25
|
-
export { default as notification } from './
|
|
25
|
+
export { default as notification } from './notification';
|
|
26
26
|
export { default as OldModal } from './OldModal';
|
|
27
27
|
export { default as Pagination } from './Pagination';
|
|
28
28
|
export { default as PopTable } from './PopTable';
|
package/es/index.js
CHANGED
|
@@ -22,7 +22,7 @@ export { default as LmSelect } from './LmSelect';
|
|
|
22
22
|
export { default as LoadingPage } from './LoadingPage';
|
|
23
23
|
export { default as Menu } from './Menu';
|
|
24
24
|
export { default as Modal } from './Modal';
|
|
25
|
-
export { default as notification } from './
|
|
25
|
+
export { default as notification } from './notification';
|
|
26
26
|
export { default as OldModal } from './OldModal';
|
|
27
27
|
export { default as Pagination } from './Pagination';
|
|
28
28
|
export { default as PopTable } from './PopTable';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NoticeContent as RCNoticeContent, NotificationInstance as RCNotificationInstance } from 'rc-notification/lib/Notification';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import type { ArgsProps, NotificationInstance } from '..';
|
|
4
|
+
export default function createUseNotification(getNotificationInstance: (args: ArgsProps, callback: (info: {
|
|
5
|
+
prefixCls: string;
|
|
6
|
+
instance: RCNotificationInstance;
|
|
7
|
+
}) => void) => void, getRCNoticeProps: (args: ArgsProps, prefixCls: string) => RCNoticeContent): () => [NotificationInstance, React.ReactElement];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import useRCNotification from 'rc-notification/lib/useNotification';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ConfigConsumer } from 'antd/es/config-provider';
|
|
5
|
+
export default function createUseNotification(getNotificationInstance, getRCNoticeProps) {
|
|
6
|
+
var useNotification = function useNotification() {
|
|
7
|
+
// We can only get content by render
|
|
8
|
+
var getPrefixCls; // We create a proxy to handle delay created instance
|
|
9
|
+
|
|
10
|
+
var innerInstance = null;
|
|
11
|
+
var proxy = {
|
|
12
|
+
add: function add(noticeProps, holderCallback) {
|
|
13
|
+
innerInstance === null || innerInstance === void 0 ? void 0 : innerInstance.component.add(noticeProps, holderCallback);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
var _useRCNotification = useRCNotification(proxy),
|
|
18
|
+
_useRCNotification2 = _slicedToArray(_useRCNotification, 2),
|
|
19
|
+
hookNotify = _useRCNotification2[0],
|
|
20
|
+
holder = _useRCNotification2[1];
|
|
21
|
+
|
|
22
|
+
function notify(args) {
|
|
23
|
+
var customizePrefixCls = args.prefixCls;
|
|
24
|
+
var mergedPrefixCls = getPrefixCls('notification', customizePrefixCls);
|
|
25
|
+
getNotificationInstance(Object.assign(Object.assign({}, args), {
|
|
26
|
+
prefixCls: mergedPrefixCls
|
|
27
|
+
}), function (_ref) {
|
|
28
|
+
var prefixCls = _ref.prefixCls,
|
|
29
|
+
instance = _ref.instance;
|
|
30
|
+
innerInstance = instance;
|
|
31
|
+
hookNotify(getRCNoticeProps(args, prefixCls));
|
|
32
|
+
});
|
|
33
|
+
} // Fill functions
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
var hookApiRef = React.useRef({});
|
|
37
|
+
hookApiRef.current.open = notify;
|
|
38
|
+
['success', 'info', 'warning', 'error'].forEach(function (type) {
|
|
39
|
+
hookApiRef.current[type] = function (args) {
|
|
40
|
+
return hookApiRef.current.open(Object.assign(Object.assign({}, args), {
|
|
41
|
+
type: type
|
|
42
|
+
}));
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
return [hookApiRef.current, /*#__PURE__*/React.createElement(ConfigConsumer, {
|
|
46
|
+
key: "holder"
|
|
47
|
+
}, function (context) {
|
|
48
|
+
getPrefixCls = context.getPrefixCls;
|
|
49
|
+
return holder;
|
|
50
|
+
})];
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return useNotification;
|
|
54
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { NotificationInstance as RCNotificationInstance } from 'rc-notification/lib/Notification';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export declare type NotificationPlacement = 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight';
|
|
4
|
+
export declare type IconType = 'success' | 'info' | 'error' | 'warning';
|
|
5
|
+
export interface ConfigProps {
|
|
6
|
+
top?: number;
|
|
7
|
+
bottom?: number;
|
|
8
|
+
duration?: number;
|
|
9
|
+
prefixCls?: string;
|
|
10
|
+
placement?: NotificationPlacement;
|
|
11
|
+
getContainer?: () => HTMLElement;
|
|
12
|
+
closeIcon?: React.ReactNode;
|
|
13
|
+
rtl?: boolean;
|
|
14
|
+
maxCount?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ArgsProps {
|
|
17
|
+
message: React.ReactNode;
|
|
18
|
+
description?: React.ReactNode;
|
|
19
|
+
btn?: React.ReactNode;
|
|
20
|
+
key?: string;
|
|
21
|
+
onClose?: () => void;
|
|
22
|
+
duration?: number | null;
|
|
23
|
+
icon?: React.ReactNode;
|
|
24
|
+
placement?: NotificationPlacement;
|
|
25
|
+
maxCount?: number;
|
|
26
|
+
style?: React.CSSProperties;
|
|
27
|
+
prefixCls?: string;
|
|
28
|
+
className?: string;
|
|
29
|
+
readonly type?: IconType;
|
|
30
|
+
onClick?: () => void;
|
|
31
|
+
top?: number;
|
|
32
|
+
bottom?: number;
|
|
33
|
+
getContainer?: () => HTMLElement;
|
|
34
|
+
closeIcon?: React.ReactNode;
|
|
35
|
+
progress?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface NotificationInstance {
|
|
38
|
+
success(args: ArgsProps): void;
|
|
39
|
+
error(args: ArgsProps): void;
|
|
40
|
+
info(args: ArgsProps): void;
|
|
41
|
+
warning(args: ArgsProps): void;
|
|
42
|
+
open(args: ArgsProps): void;
|
|
43
|
+
}
|
|
44
|
+
export interface NotificationApi extends NotificationInstance {
|
|
45
|
+
warn(args: ArgsProps): void;
|
|
46
|
+
close(key: string): void;
|
|
47
|
+
config(options: ConfigProps): void;
|
|
48
|
+
destroy(): void;
|
|
49
|
+
useNotification: () => [NotificationInstance, React.ReactElement];
|
|
50
|
+
}
|
|
51
|
+
/** @private test Only function. Not work on production */
|
|
52
|
+
export declare const getInstance: (cacheKey: string) => Promise<RCNotificationInstance>;
|
|
53
|
+
declare const _default: NotificationApi;
|
|
54
|
+
export default _default;
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import "antd/es/notification/style";
|
|
2
|
+
import _notification from "antd/es/notification";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
|
|
6
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) {
|
|
8
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
9
|
+
resolve(value);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) {
|
|
15
|
+
try {
|
|
16
|
+
step(generator.next(value));
|
|
17
|
+
} catch (e) {
|
|
18
|
+
reject(e);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function rejected(value) {
|
|
23
|
+
try {
|
|
24
|
+
step(generator["throw"](value));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
reject(e);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function step(result) {
|
|
31
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
import { CheckCircleOutlined, CloseCircleOutlined, CloseOutlined, ExclamationCircleOutlined, InfoCircleOutlined } from '@ant-design/icons';
|
|
39
|
+
import classNames from 'classnames';
|
|
40
|
+
import Notification from 'rc-notification';
|
|
41
|
+
import * as React from 'react';
|
|
42
|
+
import ConfigProvider, { globalConfig } from 'antd/es/config-provider';
|
|
43
|
+
import createUseNotification from './hooks/useNotification';
|
|
44
|
+
var notificationInstance = {};
|
|
45
|
+
var defaultDuration = 4.5;
|
|
46
|
+
var defaultTop = 24;
|
|
47
|
+
var defaultBottom = 24;
|
|
48
|
+
var defaultPrefixCls = '';
|
|
49
|
+
var defaultPlacement = 'topRight';
|
|
50
|
+
var defaultGetContainer;
|
|
51
|
+
var defaultCloseIcon;
|
|
52
|
+
var rtl = false;
|
|
53
|
+
var maxCount;
|
|
54
|
+
|
|
55
|
+
function setNotificationConfig(options) {
|
|
56
|
+
var duration = options.duration,
|
|
57
|
+
placement = options.placement,
|
|
58
|
+
bottom = options.bottom,
|
|
59
|
+
top = options.top,
|
|
60
|
+
getContainer = options.getContainer,
|
|
61
|
+
closeIcon = options.closeIcon,
|
|
62
|
+
prefixCls = options.prefixCls;
|
|
63
|
+
|
|
64
|
+
if (prefixCls !== undefined) {
|
|
65
|
+
defaultPrefixCls = prefixCls;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (duration !== undefined) {
|
|
69
|
+
defaultDuration = duration;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (placement !== undefined) {
|
|
73
|
+
defaultPlacement = placement;
|
|
74
|
+
} else if (options.rtl) {
|
|
75
|
+
defaultPlacement = 'topLeft';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (bottom !== undefined) {
|
|
79
|
+
defaultBottom = bottom;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (top !== undefined) {
|
|
83
|
+
defaultTop = top;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (getContainer !== undefined) {
|
|
87
|
+
defaultGetContainer = getContainer;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (closeIcon !== undefined) {
|
|
91
|
+
defaultCloseIcon = closeIcon;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (options.rtl !== undefined) {
|
|
95
|
+
rtl = options.rtl;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (options.maxCount !== undefined) {
|
|
99
|
+
maxCount = options.maxCount;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function getPlacementStyle(placement) {
|
|
104
|
+
var top = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultTop;
|
|
105
|
+
var bottom = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultBottom;
|
|
106
|
+
var style;
|
|
107
|
+
|
|
108
|
+
switch (placement) {
|
|
109
|
+
case 'top':
|
|
110
|
+
style = {
|
|
111
|
+
left: '50%',
|
|
112
|
+
transform: 'translateX(-50%)',
|
|
113
|
+
right: 'auto',
|
|
114
|
+
top: top,
|
|
115
|
+
bottom: 'auto'
|
|
116
|
+
};
|
|
117
|
+
break;
|
|
118
|
+
|
|
119
|
+
case 'topLeft':
|
|
120
|
+
style = {
|
|
121
|
+
left: 0,
|
|
122
|
+
top: top,
|
|
123
|
+
bottom: 'auto'
|
|
124
|
+
};
|
|
125
|
+
break;
|
|
126
|
+
|
|
127
|
+
case 'topRight':
|
|
128
|
+
style = {
|
|
129
|
+
right: 0,
|
|
130
|
+
top: top,
|
|
131
|
+
bottom: 'auto'
|
|
132
|
+
};
|
|
133
|
+
break;
|
|
134
|
+
|
|
135
|
+
case 'bottom':
|
|
136
|
+
style = {
|
|
137
|
+
left: '50%',
|
|
138
|
+
transform: 'translateX(-50%)',
|
|
139
|
+
right: 'auto',
|
|
140
|
+
top: 'auto',
|
|
141
|
+
bottom: bottom
|
|
142
|
+
};
|
|
143
|
+
break;
|
|
144
|
+
|
|
145
|
+
case 'bottomLeft':
|
|
146
|
+
style = {
|
|
147
|
+
left: 0,
|
|
148
|
+
top: 'auto',
|
|
149
|
+
bottom: bottom
|
|
150
|
+
};
|
|
151
|
+
break;
|
|
152
|
+
|
|
153
|
+
default:
|
|
154
|
+
style = {
|
|
155
|
+
right: 0,
|
|
156
|
+
top: 'auto',
|
|
157
|
+
bottom: bottom
|
|
158
|
+
};
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return style;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function getNotificationInstance(args, callback) {
|
|
166
|
+
var _args$placement = args.placement,
|
|
167
|
+
placement = _args$placement === void 0 ? defaultPlacement : _args$placement,
|
|
168
|
+
top = args.top,
|
|
169
|
+
bottom = args.bottom,
|
|
170
|
+
_args$getContainer = args.getContainer,
|
|
171
|
+
getContainer = _args$getContainer === void 0 ? defaultGetContainer : _args$getContainer,
|
|
172
|
+
customizePrefixCls = args.prefixCls;
|
|
173
|
+
|
|
174
|
+
var _globalConfig = globalConfig(),
|
|
175
|
+
getPrefixCls = _globalConfig.getPrefixCls,
|
|
176
|
+
getIconPrefixCls = _globalConfig.getIconPrefixCls;
|
|
177
|
+
|
|
178
|
+
var prefixCls = getPrefixCls('notification', customizePrefixCls || defaultPrefixCls);
|
|
179
|
+
var iconPrefixCls = getIconPrefixCls();
|
|
180
|
+
var cacheKey = "".concat(prefixCls, "-").concat(placement);
|
|
181
|
+
var cacheInstance = notificationInstance[cacheKey];
|
|
182
|
+
|
|
183
|
+
if (cacheInstance) {
|
|
184
|
+
Promise.resolve(cacheInstance).then(function (instance) {
|
|
185
|
+
callback({
|
|
186
|
+
prefixCls: "".concat(prefixCls, "-notice"),
|
|
187
|
+
iconPrefixCls: iconPrefixCls,
|
|
188
|
+
instance: instance
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
var notificationClass = classNames("".concat(prefixCls, "-").concat(placement), _defineProperty({}, "".concat(prefixCls, "-rtl"), rtl === true));
|
|
195
|
+
notificationInstance[cacheKey] = new Promise(function (resolve) {
|
|
196
|
+
Notification.newInstance({
|
|
197
|
+
prefixCls: prefixCls,
|
|
198
|
+
className: notificationClass,
|
|
199
|
+
style: getPlacementStyle(placement, top, bottom),
|
|
200
|
+
getContainer: getContainer,
|
|
201
|
+
maxCount: maxCount
|
|
202
|
+
}, function (notification) {
|
|
203
|
+
resolve(notification);
|
|
204
|
+
callback({
|
|
205
|
+
prefixCls: "".concat(prefixCls, "-notice"),
|
|
206
|
+
iconPrefixCls: iconPrefixCls,
|
|
207
|
+
instance: notification
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
var typeToIcon = {
|
|
214
|
+
success: CheckCircleOutlined,
|
|
215
|
+
info: InfoCircleOutlined,
|
|
216
|
+
error: CloseCircleOutlined,
|
|
217
|
+
warning: ExclamationCircleOutlined
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
function getRCNoticeProps(args, prefixCls, iconPrefixCls) {
|
|
221
|
+
var durationArg = args.duration,
|
|
222
|
+
icon = args.icon,
|
|
223
|
+
type = args.type,
|
|
224
|
+
description = args.description,
|
|
225
|
+
message = args.message,
|
|
226
|
+
btn = args.btn,
|
|
227
|
+
onClose = args.onClose,
|
|
228
|
+
onClick = args.onClick,
|
|
229
|
+
key = args.key,
|
|
230
|
+
style = args.style,
|
|
231
|
+
className = args.className,
|
|
232
|
+
_args$closeIcon = args.closeIcon,
|
|
233
|
+
closeIcon = _args$closeIcon === void 0 ? defaultCloseIcon : _args$closeIcon,
|
|
234
|
+
_args$progress = args.progress,
|
|
235
|
+
progress = _args$progress === void 0 ? true : _args$progress;
|
|
236
|
+
var duration = durationArg === undefined ? defaultDuration : durationArg;
|
|
237
|
+
var iconNode = null;
|
|
238
|
+
|
|
239
|
+
if (icon) {
|
|
240
|
+
iconNode = /*#__PURE__*/React.createElement("span", {
|
|
241
|
+
className: "".concat(prefixCls, "-icon")
|
|
242
|
+
}, args.icon);
|
|
243
|
+
} else if (type) {
|
|
244
|
+
iconNode = /*#__PURE__*/React.createElement(typeToIcon[type] || null, {
|
|
245
|
+
className: "".concat(prefixCls, "-icon ").concat(prefixCls, "-icon-").concat(type)
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
var closeIconToRender = /*#__PURE__*/React.createElement("span", {
|
|
250
|
+
className: "".concat(prefixCls, "-close-x")
|
|
251
|
+
}, closeIcon || /*#__PURE__*/React.createElement(CloseOutlined, {
|
|
252
|
+
className: "".concat(prefixCls, "-close-icon")
|
|
253
|
+
}));
|
|
254
|
+
var autoMarginTag = !description && iconNode ? /*#__PURE__*/React.createElement("span", {
|
|
255
|
+
className: "".concat(prefixCls, "-message-single-line-auto-margin")
|
|
256
|
+
}) : null;
|
|
257
|
+
return {
|
|
258
|
+
content: /*#__PURE__*/React.createElement(ConfigProvider, {
|
|
259
|
+
iconPrefixCls: iconPrefixCls
|
|
260
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
261
|
+
className: iconNode ? "".concat(prefixCls, "-with-icon") : '',
|
|
262
|
+
role: "alert"
|
|
263
|
+
}, iconNode, /*#__PURE__*/React.createElement("div", {
|
|
264
|
+
className: "".concat(prefixCls, "-message")
|
|
265
|
+
}, autoMarginTag, message), /*#__PURE__*/React.createElement("div", {
|
|
266
|
+
className: "".concat(prefixCls, "-description")
|
|
267
|
+
}, description), btn ? /*#__PURE__*/React.createElement("span", {
|
|
268
|
+
className: "".concat(prefixCls, "-btn")
|
|
269
|
+
}, btn) : null, progress && duration > 0 && /*#__PURE__*/React.createElement("div", {
|
|
270
|
+
className: 'message_progress',
|
|
271
|
+
style: {
|
|
272
|
+
animationDuration: "".concat(duration, "s")
|
|
273
|
+
}
|
|
274
|
+
}))),
|
|
275
|
+
duration: duration,
|
|
276
|
+
closable: true,
|
|
277
|
+
closeIcon: closeIconToRender,
|
|
278
|
+
onClose: onClose,
|
|
279
|
+
onClick: onClick,
|
|
280
|
+
key: key,
|
|
281
|
+
style: style || {},
|
|
282
|
+
className: classNames(className, _defineProperty({}, "".concat(prefixCls, "-").concat(type), !!type), 'lm_notification')
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function notice(args) {
|
|
287
|
+
getNotificationInstance(args, function (_ref) {
|
|
288
|
+
var prefixCls = _ref.prefixCls,
|
|
289
|
+
iconPrefixCls = _ref.iconPrefixCls,
|
|
290
|
+
instance = _ref.instance;
|
|
291
|
+
instance.notice(getRCNoticeProps(args, prefixCls, iconPrefixCls));
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
var api = {
|
|
296
|
+
open: notice,
|
|
297
|
+
close: function close(key) {
|
|
298
|
+
Object.keys(notificationInstance).forEach(function (cacheKey) {
|
|
299
|
+
return Promise.resolve(notificationInstance[cacheKey]).then(function (instance) {
|
|
300
|
+
instance.removeNotice(key);
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
},
|
|
304
|
+
config: setNotificationConfig,
|
|
305
|
+
destroy: function destroy() {
|
|
306
|
+
Object.keys(notificationInstance).forEach(function (cacheKey) {
|
|
307
|
+
Promise.resolve(notificationInstance[cacheKey]).then(function (instance) {
|
|
308
|
+
instance.destroy();
|
|
309
|
+
});
|
|
310
|
+
delete notificationInstance[cacheKey]; // lgtm[js/missing-await]
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
['success', 'info', 'warning', 'error'].forEach(function (type) {
|
|
315
|
+
api[type] = function (args) {
|
|
316
|
+
return api.open(Object.assign(Object.assign({}, args), {
|
|
317
|
+
type: type
|
|
318
|
+
}));
|
|
319
|
+
};
|
|
320
|
+
});
|
|
321
|
+
api.warn = api.warning;
|
|
322
|
+
api.useNotification = createUseNotification(getNotificationInstance, getRCNoticeProps);
|
|
323
|
+
api.antdNotification = _notification;
|
|
324
|
+
/** @private test Only function. Not work on production */
|
|
325
|
+
|
|
326
|
+
export var getInstance = function getInstance(cacheKey) {
|
|
327
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
328
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
329
|
+
while (1) {
|
|
330
|
+
switch (_context.prev = _context.next) {
|
|
331
|
+
case 0:
|
|
332
|
+
return _context.abrupt("return", process.env.NODE_ENV === 'test' ? notificationInstance[cacheKey] : null);
|
|
333
|
+
|
|
334
|
+
case 1:
|
|
335
|
+
case "end":
|
|
336
|
+
return _context.stop();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}, _callee);
|
|
340
|
+
}));
|
|
341
|
+
};
|
|
342
|
+
export default api;
|