From 82cc4dab87275ee12fe8cea898fbf9fe166be300 Mon Sep 17 00:00:00 2001 From: xion Date: Sun, 6 Apr 2025 01:46:48 +0800 Subject: [PATCH] add provider --- src/drag-modal/index.tsx | 40 +++++++++++++++++++++++++++++++++++++++- src/select/TagsInput.tsx | 5 +++-- src/theme/Provider.tsx | 13 +++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 src/theme/Provider.tsx diff --git a/src/drag-modal/index.tsx b/src/drag-modal/index.tsx index 0a767c2..242d1c7 100644 --- a/src/drag-modal/index.tsx +++ b/src/drag-modal/index.tsx @@ -1,7 +1,8 @@ -import { useRef } from 'react'; +import { useEffect, useRef, useState } from 'react'; import Draggable from 'react-draggable'; import { clsxMerge } from '../clsx'; import { Resizable } from 're-resizable'; +import { X } from 'lucide-react'; type DragModalProps = { title?: React.ReactNode; @@ -63,3 +64,40 @@ export const DragModal = (props: DragModalProps) => { ); }; + +type DragModalTitleProps = { + title?: React.ReactNode; + className?: string; + onClose?: () => void; + children?: React.ReactNode; +}; +export const DragModalTitle = (props: DragModalTitleProps) => { + return ( +
+
+ {props.title} + {props.children} +
+ +
+ ); +}; + +export const getComputedHeight = () => { + const height = window.innerHeight; + const width = window.innerWidth; + return { height, width }; +}; + +export const useComputedHeight = () => { + const [computedHeight, setComputedHeight] = useState({ + height: 0, + width: 0, + }); + useEffect(() => { + const height = window.innerHeight; + const width = window.innerWidth; + setComputedHeight({ height, width }); + }, []); + return computedHeight; +}; diff --git a/src/select/TagsInput.tsx b/src/select/TagsInput.tsx index 3151116..fbfab4d 100644 --- a/src/select/TagsInput.tsx +++ b/src/select/TagsInput.tsx @@ -8,8 +8,9 @@ type TagsInputProps = { placeholder?: string; label?: any; showLabel?: boolean; + options?: string[]; }; -export const TagsInput = ({ value, onChange, placeholder = '', label = '', showLabel = false }: TagsInputProps) => { +export const TagsInput = ({ value, onChange, placeholder = '', label = '', showLabel = false, options = [] }: TagsInputProps) => { const [tags, setTags] = useState(value); useEffect(() => { setTags(value); @@ -21,7 +22,7 @@ export const TagsInput = ({ value, onChange, placeholder = '', label = '', showL { // setTags(newValue as string[]); diff --git a/src/theme/Provider.tsx b/src/theme/Provider.tsx new file mode 100644 index 0000000..da8f8c8 --- /dev/null +++ b/src/theme/Provider.tsx @@ -0,0 +1,13 @@ +import { ToastContainer } from 'react-toastify'; + +type ToastProviderProps = { + children?: React.ReactNode; +}; +export const ToastProvider = ({ children }: ToastProviderProps) => { + return ( + <> + {children} + + + ); +};