@fvc/notification 1.0.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/dist/lib/index.js +6 -0
- package/dist/lib/notification/src/Notification.d.ts +3 -0
- package/dist/lib/notification/src/hooks/useNotification.d.ts +2 -0
- package/dist/lib/notification/src/index.d.ts +1 -0
- package/dist/lib/notification/src/types/Notification.types.d.ts +48 -0
- package/dist/lib/notification/src/types/index.d.ts +1 -0
- package/dist/lib/notification/src/utils/helpers.d.ts +7 -0
- package/package.json +31 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{notification as n}from"antd";import t,{useMemo as o}from"react";import{Icon as i}from"@fvc/icons";var r,e=function(){return e=Object.assign||function(n){for(var t,o=1,i=arguments.length;o<i;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n},e.apply(this,arguments)};function c(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}"function"==typeof SuppressedError&&SuppressedError,function(n){n.success="success",n.info="info",n.warning="warning",n.error="error"}(r||(r={}));var a,f={exports:{}};
|
|
2
|
+
/*!
|
|
3
|
+
Copyright (c) 2018 Jed Watson.
|
|
4
|
+
Licensed under the MIT License (MIT), see
|
|
5
|
+
http://jedwatson.github.io/classnames
|
|
6
|
+
*/var s,p=(a||(a=1,s=f,function(){var n={}.hasOwnProperty;function t(){for(var n="",t=0;t<arguments.length;t++){var r=arguments[t];r&&(n=i(n,o(r)))}return n}function o(o){if("string"==typeof o||"number"==typeof o)return o;if("object"!=typeof o)return"";if(Array.isArray(o))return t.apply(null,o);if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]"))return o.toString();var r="";for(var e in o)n.call(o,e)&&o[e]&&(r=i(r,e));return r}function i(n,t){return t?n?n+" "+t:n+t:n}s.exports?(t.default=t,s.exports=t):window.classNames=t}()),f.exports),l=c(p),u="fvc-notification",v=function(n){switch(n){case r.success:return t.createElement(i.CheckCircleOutline,{color:"var(--link-on-dark-bg-color-400)",width:24,height:24});case r.info:return t.createElement(i.Info,{color:"var(--gray-300)",width:24,height:24});case r.warning:return t.createElement(i.Warning,{color:"var(--orange-200)",width:24,height:24});case r.error:return t.createElement(i.Report,{color:"var(--warning-text-on-dark-bg-color-400)",width:24,height:24});default:return}},g=function(n){var t,o=n.icon,i=n.innerComponent,r=function(n,t){var o={};for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&t.indexOf(i)<0&&(o[i]=n[i]);if(null!=n&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(n);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(n,i[r])&&(o[i[r]]=n[i[r]])}return o}(n,["icon","innerComponent"]);return e(e({},r),{icon:o||v(r.type),btn:i,className:l((t={},t[r.className]=!!r.className,t))})},d=function(t,o){return void 0===o&&(o=n),function(n){return o[t](e({},g(e(e({},n),{type:t}))))}};!function(n,t){void 0===t&&(t={});var o=t.insertAt;if("undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===o&&i.firstChild?i.insertBefore(r,i.firstChild):i.appendChild(r),r.styleSheet?r.styleSheet.cssText=n:r.appendChild(document.createTextNode(n))}}('.fvc-notification {\n font-family: "Roboto", sans-serif;\n}\n.fvc-notification .fvc-notification-notice-wrapper {\n background-color: var(--blue-gray-700) !important;\n border-radius: 8px;\n}\n.fvc-notification .fvc-notification-notice-wrapper .fvc-notification-notice {\n padding: 16px;\n}\n.fvc-notification .fvc-notification-notice-wrapper .fvc-notification-notice-close {\n width: 16px;\n height: 16px;\n top: 4px;\n right: 4px;\n border-radius: 50%;\n background-color: var(--blue-gray-900);\n}\n.fvc-notification .fvc-notification-notice-wrapper .fvc-notification-notice-close:hover {\n background-color: var(--blue-gray-900);\n}\n.fvc-notification .fvc-notification-notice-wrapper .fvc-notification-notice-close-icon {\n width: 7px;\n height: 7px;\n color: var(--blue-gray-250);\n}\n.fvc-notification .fvc-notification-notice-wrapper .fvc-notification-notice-with-icon .fvc-notification-notice-message, .fvc-notification .fvc-notification-notice-wrapper .fvc-notification-notice-message {\n font-family: Roboto, Arial, sans-serif;\n font-weight: 400;\n font-size: 14px;\n line-height: 16px;\n margin-bottom: 0;\n margin-left: 0;\n color: var(--neutral-0);\n}\n.fvc-notification .fvc-notification-notice-wrapper .fvc-notification-notice-with-icon .fvc-notification-notice-message {\n margin-left: 32px;\n}\n.fvc-notification .fvc-notification-notice-wrapper .fvc-notification-notice-icon {\n transform: translateY(-3px);\n display: flex;\n align-items: flex-start;\n}\n.fvc-notification .fvc-notification-notice-wrapper .fvc-notification-notice-btn {\n display: flex;\n width: 100%;\n}\n.fvc-notification .fvc-notification-notice-wrapper .fvc-notification-notice-success .fvc-notification-notice-message {\n color: var(--link-on-dark-bg-color-400);\n}\n.fvc-notification .fvc-notification-notice-wrapper .fvc-notification-notice-info .fvc-notification-notice-message {\n color: var(--gray-300);\n}\n.fvc-notification .fvc-notification-notice-wrapper .fvc-notification-notice-error .fvc-notification-notice-message {\n color: var(--warning-icon-on-dark-bg-color-400);\n}\n.fvc-notification .fvc-notification-notice-wrapper .fvc-notification-notice-warning .fvc-notification-notice-message {\n color: var(--orange-200);\n}');var y={config:function(t){n.config(e(e({},t),{prefixCls:u}))},destroy:function(t){n.destroy(t)},open:function(t){n.open(e({},g(t)))},success:d(r.success),info:d(r.info),warning:d(r.warning),error:d(r.error),useNotification:function(t){var i=function(n,t){var o="function"==typeof Symbol&&n[Symbol.iterator];if(!o)return n;var i,r,e=o.call(n),c=[];try{for(;(void 0===t||t-- >0)&&!(i=e.next()).done;)c.push(i.value)}catch(n){r={error:n}}finally{try{i&&!i.done&&(o=e.return)&&o.call(e)}finally{if(r)throw r.error}}return c}(n.useNotification(e(e({},t),{prefixCls:u})),2),c=i[0],a=i[1];return[o((function(){return{info:d(r.info,c),success:d(r.success,c),error:d(r.error,c),warning:d(r.warning,c),open:function(n){c.open(e({},g(e({},n))))},destroy:c.destroy}}),[c]),a]}};export{y as notification};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { notification } from './Notification';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ArgsProps as BaseArgsProps } from 'antd/es/notification';
|
|
3
|
+
import { GlobalConfigProps, NotificationConfig as BaseNotificationConfig, NotificationInstance as BaseNotificationInstance } from 'antd/es/notification/interface';
|
|
4
|
+
export type ArgsProps = Omit<BaseArgsProps, 'description'> & {
|
|
5
|
+
innerComponent?: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
export type StaticFn = (config: ArgsProps) => void;
|
|
8
|
+
export interface NotificationInstance extends BaseNotificationInstance {
|
|
9
|
+
success: StaticFn;
|
|
10
|
+
error: StaticFn;
|
|
11
|
+
info: StaticFn;
|
|
12
|
+
warning: StaticFn;
|
|
13
|
+
open: StaticFn;
|
|
14
|
+
}
|
|
15
|
+
export type TypeUseNotification = (args: BaseNotificationConfig) => readonly [
|
|
16
|
+
NotificationInstance,
|
|
17
|
+
React.ReactElement<unknown, string | React.JSXElementConstructor<ReactNode>>
|
|
18
|
+
];
|
|
19
|
+
export interface NotificationBaseMethods {
|
|
20
|
+
open: (config: ArgsProps) => void;
|
|
21
|
+
destroy: (key?: React.Key) => void;
|
|
22
|
+
config: (config: GlobalConfigProps) => void;
|
|
23
|
+
useNotification: TypeUseNotification;
|
|
24
|
+
}
|
|
25
|
+
export interface NotificationNoticeMethods {
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use `[api, context] = notification.useNotification()` instead
|
|
28
|
+
*/
|
|
29
|
+
success: StaticFn;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated Use `[api, context] = notification.useNotification()` instead
|
|
32
|
+
*/
|
|
33
|
+
info: StaticFn;
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated Use `[api, context] = notification.useNotification()` instead
|
|
36
|
+
*/
|
|
37
|
+
warning: StaticFn;
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated Use `[api, context] = notification.useNotification()` instead
|
|
40
|
+
*/
|
|
41
|
+
error: StaticFn;
|
|
42
|
+
}
|
|
43
|
+
export declare enum NotificationTypes {
|
|
44
|
+
success = "success",
|
|
45
|
+
info = "info",
|
|
46
|
+
warning = "warning",
|
|
47
|
+
error = "error"
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Notification.types';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { notification as baseNotification, NotificationArgsProps as BaseNotificationArgsProps } from 'antd';
|
|
3
|
+
import { ArgsProps, NotificationInstance, NotificationTypes, StaticFn } from '../types';
|
|
4
|
+
export declare const prefixCls = "fvc-notification";
|
|
5
|
+
export declare const getNotificationIcon: (type: BaseNotificationArgsProps["type"]) => React.JSX.Element | undefined;
|
|
6
|
+
export declare const getCommonNotificationProps: ({ icon, innerComponent, ...args }: ArgsProps) => ArgsProps;
|
|
7
|
+
export declare const createNotificationHandler: (type: NotificationTypes, notificationAPI?: NotificationInstance | typeof baseNotification) => StaticFn;
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fvc/notification",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "./dist/lib/index.js",
|
|
5
|
+
"types": "./dist/lib/notification/src/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/lib/index.js",
|
|
8
|
+
"dist/lib/notification",
|
|
9
|
+
"package.json"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/lib/index.js",
|
|
14
|
+
"types": "./dist/lib/notification/src/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./types/*": "./dist/lib/notification/src/types/*"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "rm -rf dist && eslint --config ../../eslint.config.js . && bunx tsc --noEmit && rollup -c ./rollup.config.mjs"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"react": "^18.0.0",
|
|
23
|
+
"antd": "^5.0.0",
|
|
24
|
+
"@fvc/icons": "file:../icons"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@fvc/icons": "*",
|
|
28
|
+
"react": "^18.0.0",
|
|
29
|
+
"antd": "^5.0.0"
|
|
30
|
+
}
|
|
31
|
+
}
|