This commit is contained in:
xion 2025-04-06 23:22:16 +08:00
parent 82cc4dab87
commit 6d52707ad3
4 changed files with 33 additions and 6 deletions

View File

@ -15,12 +15,14 @@
"dependencies": { "dependencies": {
"@emotion/react": "^11.14.0", "@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.0", "@emotion/styled": "^11.14.0",
"@kevisual/query-login": "^0.0.4",
"@mui/material": "^7.0.1", "@mui/material": "^7.0.1",
"re-resizable": "^6.11.2", "re-resizable": "^6.11.2",
"react": "19.1.0", "react": "19.1.0",
"react-dom": "19.1.0", "react-dom": "19.1.0",
"react-draggable": "^4.4.6", "react-draggable": "^4.4.6",
"react-hook-form": "^7.55.0" "react-hook-form": "^7.55.0",
"react-i18next": "^15.4.1"
}, },
"exports": { "exports": {
".": "./src/index.tsx", ".": "./src/index.tsx",

View File

@ -11,6 +11,7 @@ type DragModalProps = {
containerClassName?: string; containerClassName?: string;
handleClassName?: string; handleClassName?: string;
contentClassName?: string; contentClassName?: string;
focus?: boolean;
/** /**
* , px * , px
* width: defaultSize.width || 320 * width: defaultSize.width || 320
@ -29,7 +30,7 @@ export const DragModal = (props: DragModalProps) => {
<Draggable <Draggable
nodeRef={dragRef as any} nodeRef={dragRef as any}
onStop={(e, data) => { onStop={(e, data) => {
console.log(e, data); // console.log(e, data);
}} }}
handle='.handle' handle='.handle'
grid={[1, 1]} grid={[1, 1]}
@ -40,7 +41,7 @@ export const DragModal = (props: DragModalProps) => {
y: 0, y: 0,
}}> }}>
<div <div
className={clsxMerge('absolute top-0 left-0 bg-white rounded-md border border-gray-200 shadow-sm', props.containerClassName)} className={clsxMerge('absolute top-0 left-0 bg-white rounded-md border border-gray-200 shadow-sm', props.focus ? 'z-30' : '', props.containerClassName)}
ref={dragRef} ref={dragRef}
style={props.style}> style={props.style}>
<div className={clsxMerge('handle cursor-move border-b border-gray-200 py-2 px-4', props.handleClassName)}>{props.title || 'Move'}</div> <div className={clsxMerge('handle cursor-move border-b border-gray-200 py-2 px-4', props.handleClassName)}>{props.title || 'Move'}</div>
@ -70,15 +71,28 @@ type DragModalTitleProps = {
className?: string; className?: string;
onClose?: () => void; onClose?: () => void;
children?: React.ReactNode; children?: React.ReactNode;
onClick?: () => void;
}; };
export const DragModalTitle = (props: DragModalTitleProps) => { export const DragModalTitle = (props: DragModalTitleProps) => {
return ( return (
<div className={clsxMerge('flex flex-row items-center justify-between', props.className)}> <div
className={clsxMerge('flex flex-row items-center justify-between', props.className)}
onClick={(e) => {
e.stopPropagation();
props.onClick?.();
}}>
<div className='text-sm font-medium text-gray-700'> <div className='text-sm font-medium text-gray-700'>
{props.title} {props.title}
{props.children} {props.children}
</div> </div>
<X className='w-4 h-4 text-gray-500 cursor-pointer' onClick={props.onClose} /> <div
className='text-gray-500 cursor-pointer p-2 hover:bg-gray-100 rounded-md'
onClick={(e) => {
e.stopPropagation();
props.onClose?.();
}}>
<X className='w-4 h-4 ' />
</div>
</div> </div>
); );
}; };

View File

@ -1,4 +1,5 @@
import { ToastContainer } from 'react-toastify'; import { ToastContainer } from 'react-toastify';
import { CustomThemeProvider } from '.';
type ToastProviderProps = { type ToastProviderProps = {
children?: React.ReactNode; children?: React.ReactNode;
@ -11,3 +12,11 @@ export const ToastProvider = ({ children }: ToastProviderProps) => {
</> </>
); );
}; };
export const Provider = ({ children }) => {
return (
<CustomThemeProvider>
{children}
<ToastProvider />
</CustomThemeProvider>
);
};

View File

@ -38,5 +38,7 @@ type ToastLoginProps = {
* }); * });
*/ */
export const toastLogin = (props: ToastLoginProps = {}) => { export const toastLogin = (props: ToastLoginProps = {}) => {
toast.info(<LoginMessage {...props} />); toast.info(<LoginMessage {...props} />, {
autoClose: 5000 * 3,
});
}; };