@xwadex/fesd-next 0.3.3 → 0.3.4-4.1
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/README.md +1 -26
- package/dist/components/accordions/accordion.d.ts +10 -0
- package/dist/components/accordions/accordion.js +10 -0
- package/dist/components/accordions/accordionContent.d.ts +11 -0
- package/dist/components/accordions/accordionContent.js +20 -0
- package/dist/components/accordions/accordionItem.d.ts +11 -0
- package/dist/components/accordions/accordionItem.js +14 -0
- package/dist/components/accordions/accordionTrigger.d.ts +11 -0
- package/dist/components/accordions/accordionTrigger.js +88 -0
- package/dist/components/accordions/index.d.ts +35 -0
- package/dist/components/accordions/index.js +11 -0
- package/dist/components/button.d.ts +10 -0
- package/dist/components/button.js +31 -0
- package/dist/components/dragResize/dragResize.d.ts +19 -0
- package/dist/components/dragResize/dragResize.js +77 -0
- package/dist/components/dragResize/dragResize.module.scss +42 -0
- package/dist/components/dragResize/dragResizeContext.d.ts +10 -0
- package/dist/components/dragResize/dragResizeContext.js +9 -0
- package/dist/components/dragResize/index.d.ts +2 -0
- package/dist/components/dragResize/index.js +2 -0
- package/dist/components/dragSortable/dragSortable.d.ts +19 -0
- package/dist/components/dragSortable/dragSortable.js +11 -0
- package/dist/components/dragSortable/dragSortable.module.scss +7 -0
- package/dist/components/dragSortable/index.d.ts +1 -0
- package/dist/components/dragSortable/index.js +1 -0
- package/dist/components/index.d.ts +5 -1
- package/dist/components/index.js +7 -1
- package/dist/components/resizables/index.d.ts +66 -0
- package/dist/components/resizables/index.js +8 -0
- package/dist/components/resizables/resizableHandle.d.ts +11 -0
- package/dist/components/resizables/resizableHandle.js +48 -0
- package/dist/components/resizables/resizablePanel.d.ts +10 -0
- package/dist/components/resizables/resizablePanel.js +9 -0
- package/dist/components/resizables/resizablePanelGroup.d.ts +10 -0
- package/dist/components/resizables/resizablePanelGroup.js +14 -0
- package/dist/components/scrollAreas/index.d.ts +1 -0
- package/dist/components/scrollAreas/index.js +1 -0
- package/dist/components/scrollAreas/scroll-area.d.ts +5 -0
- package/dist/components/scrollAreas/scroll-area.js +11 -0
- package/dist/hooks/index.d.ts +7 -1
- package/dist/hooks/index.js +7 -1
- package/dist/hooks/useAsyncFetcher.d.ts +10 -0
- package/dist/hooks/useAsyncFetcher.js +40 -0
- package/dist/hooks/useCollapse.d.ts +15 -0
- package/dist/hooks/useCollapse.js +52 -0
- package/dist/hooks/useCookies.d.ts +6 -0
- package/dist/hooks/useCookies.js +24 -0
- package/dist/hooks/useDebounce.d.ts +7 -0
- package/dist/hooks/useDebounce.js +16 -0
- package/dist/hooks/useDebounceValue.d.ts +1 -0
- package/dist/hooks/useDebounceValue.js +17 -0
- package/dist/hooks/useDragResize.d.ts +19 -0
- package/dist/hooks/useDragResize.js +63 -0
- package/dist/hooks/useMounted.d.ts +3 -0
- package/dist/hooks/useMounted.js +7 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/styles/defaults.css +155 -0
- package/dist/types/components.type.d.ts +9 -0
- package/dist/types/components.type.js +1 -0
- package/dist/types/index.d.ts +2 -4
- package/dist/types/index.js +2 -1
- package/dist/types/shadcns.type.d.ts +7 -0
- package/dist/types/shadcns.type.js +1 -0
- package/dist/utils/index.d.ts +15 -1
- package/dist/utils/index.js +75 -1
- package/package.json +56 -47
- package/dist/components/myComponents/MyComponent.d.ts +0 -2
- package/dist/components/myComponents/MyComponent.js +0 -4
- package/dist/components/myComponents/MyComponent.module.scss +0 -3
- package/dist/components/myComponents/index.d.ts +0 -1
- package/dist/components/myComponents/index.js +0 -1
- package/dist/hooks/useHooks.d.ts +0 -1
- package/dist/hooks/useHooks.js +0 -3
- package/dist/utils/someUtil.d.ts +0 -1
- package/dist/utils/someUtil.js +0 -3
package/README.md
CHANGED
|
@@ -1,26 +1 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
React UI 元件套件。
|
|
4
|
-
|
|
5
|
-
## 安裝
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install your-ui-package
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## 使用
|
|
12
|
-
|
|
13
|
-
```tsx
|
|
14
|
-
import { MyComponent } from 'your-ui-package';
|
|
15
|
-
|
|
16
|
-
export default function App() {
|
|
17
|
-
return <MyComponent />;
|
|
18
|
-
}
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## 內容
|
|
22
|
-
|
|
23
|
-
- `MyComponent`:簡單的 React 元件
|
|
24
|
-
- `useHooks`:自訂 hook
|
|
25
|
-
- `someUtil`:工具函式
|
|
26
|
-
- 共用型別
|
|
1
|
+
# ui-package
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
2
|
+
import type { ShadcnBaseProps } from "../../types/index.js";
|
|
3
|
+
type PropsType = ShadcnBaseProps<typeof AccordionPrimitive.Root> & {
|
|
4
|
+
as?: React.ElementType;
|
|
5
|
+
};
|
|
6
|
+
declare const Accordion: {
|
|
7
|
+
(props: PropsType): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
displayName: string;
|
|
9
|
+
};
|
|
10
|
+
export default Accordion;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
4
|
+
const Accordion = (props) => {
|
|
5
|
+
const { as, children, ...restProps } = props;
|
|
6
|
+
const Component = as || "div";
|
|
7
|
+
return (_jsx(AccordionPrimitive.Root, { asChild: true, "data-slot": "accordion", ...restProps, children: _jsx(Component, { children: children }) }));
|
|
8
|
+
};
|
|
9
|
+
Accordion.displayName = "Accordion";
|
|
10
|
+
export default Accordion;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
2
|
+
import type { ShadcnBaseProps } from "../../types/index.js";
|
|
3
|
+
type PropsType = ShadcnBaseProps<typeof AccordionPrimitive.Content> & {
|
|
4
|
+
as?: React.ElementType;
|
|
5
|
+
ref?: React.Ref<Element>;
|
|
6
|
+
};
|
|
7
|
+
declare const AccordionContent: {
|
|
8
|
+
(props: PropsType): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
displayName: string;
|
|
10
|
+
};
|
|
11
|
+
export default AccordionContent;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
4
|
+
import { useMounted } from "../../hooks/index.js";
|
|
5
|
+
import { cn } from "../../utils/index.js";
|
|
6
|
+
import { useImperativeHandle, useRef } from "react";
|
|
7
|
+
const AccordionContent = (props) => {
|
|
8
|
+
const { as, ref, className, children, ...restProps } = props;
|
|
9
|
+
const Component = as || "div";
|
|
10
|
+
const insideRef = useRef(null);
|
|
11
|
+
useImperativeHandle(ref, () => insideRef.current);
|
|
12
|
+
const { isMounded } = useMounted();
|
|
13
|
+
return (_jsx(AccordionPrimitive.Content, { asChild: true, "data-slot": "accordion-content", ...restProps, children: _jsx(Component, { ref: insideRef, className: cn(`
|
|
14
|
+
overflow-hidden
|
|
15
|
+
text-sm`, isMounded && `
|
|
16
|
+
data-[state=closed]:animate-accordion-up2
|
|
17
|
+
data-[state=open]:animate-accordion-down2`, className), children: children }) }));
|
|
18
|
+
};
|
|
19
|
+
AccordionContent.displayName = "AccordionContent";
|
|
20
|
+
export default AccordionContent;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
2
|
+
import type { ShadcnBaseProps } from "../../types/index.js";
|
|
3
|
+
type PropsType = ShadcnBaseProps<typeof AccordionPrimitive.Item> & {
|
|
4
|
+
as?: React.ElementType;
|
|
5
|
+
ref?: React.Ref<Element>;
|
|
6
|
+
};
|
|
7
|
+
declare const AccordionItem: {
|
|
8
|
+
(props: PropsType): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
displayName: string;
|
|
10
|
+
};
|
|
11
|
+
export default AccordionItem;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
4
|
+
import { cn } from "../../utils/index.js";
|
|
5
|
+
import { useImperativeHandle, useRef } from "react";
|
|
6
|
+
const AccordionItem = (props) => {
|
|
7
|
+
const { as, ref, className, children, ...restProps } = props;
|
|
8
|
+
const Component = as || "div";
|
|
9
|
+
const insideRef = useRef(null);
|
|
10
|
+
useImperativeHandle(ref, () => insideRef.current);
|
|
11
|
+
return (_jsx(AccordionPrimitive.Item, { asChild: true, "data-slot": "accordion-item", ...restProps, children: _jsx(Component, { ref: insideRef, className: cn(className), children: children }) }));
|
|
12
|
+
};
|
|
13
|
+
AccordionItem.displayName = "AccordionItem";
|
|
14
|
+
export default AccordionItem;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
2
|
+
import type { ShadcnBaseProps } from "../../types/index.js";
|
|
3
|
+
type PropsType = ShadcnBaseProps<typeof AccordionPrimitive.Trigger> & {
|
|
4
|
+
as?: React.ElementType;
|
|
5
|
+
ref?: React.Ref<Element>;
|
|
6
|
+
};
|
|
7
|
+
declare const AccordionTrigger: {
|
|
8
|
+
(props: PropsType): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
displayName: string;
|
|
10
|
+
};
|
|
11
|
+
export default AccordionTrigger;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
4
|
+
import { cn } from "../../utils/index.js";
|
|
5
|
+
import { useImperativeHandle, useRef } from "react";
|
|
6
|
+
const AccordionTrigger = (props) => {
|
|
7
|
+
const { as, ref, children, className, ...restProps } = props;
|
|
8
|
+
const Component = as || "button";
|
|
9
|
+
const isButton = Component === "button";
|
|
10
|
+
const insideRef = useRef(null);
|
|
11
|
+
useImperativeHandle(ref, () => insideRef.current);
|
|
12
|
+
return (_jsx(AccordionPrimitive.Header, { asChild: true, children: _jsx(AccordionPrimitive.Trigger, { asChild: true, "data-slot": "accordion-trigger", ...restProps, children: _jsx(Component, { ref: insideRef, type: isButton ? "button" : undefined, role: !isButton ? "button" : undefined, "aria-expanded": props["aria-expanded"], "aria-controls": props["aria-controls"], tabIndex: 0,
|
|
13
|
+
// onKeyDown={(e) => console.log(e)}
|
|
14
|
+
className: cn(`focus-visible:border-ring
|
|
15
|
+
focus-visible:ring-ring/50
|
|
16
|
+
focus-visible:ring-[3px]`, className), children: children }) }) }));
|
|
17
|
+
};
|
|
18
|
+
// type AccordionTriggerProps<T extends React.ElementType
|
|
19
|
+
// > = ShadcnBaseProps<T, React.ComponentPropsWithoutRef<
|
|
20
|
+
// typeof AccordionPrimitive.Trigger>
|
|
21
|
+
// > & {
|
|
22
|
+
// defaultIcon?: boolean
|
|
23
|
+
// className?: string
|
|
24
|
+
// children?: React.ReactNode
|
|
25
|
+
// }
|
|
26
|
+
// function AccordionTrigger<T extends React.ElementType = "button">({
|
|
27
|
+
// as,
|
|
28
|
+
// asChild,
|
|
29
|
+
// children,
|
|
30
|
+
// className,
|
|
31
|
+
// defaultIcon,
|
|
32
|
+
// ...props
|
|
33
|
+
// }: AccordionTriggerProps<T>) {
|
|
34
|
+
// const Component = as || "button"
|
|
35
|
+
// const isButton = Component === "button"
|
|
36
|
+
// const isUseIcon = defaultIcon && `
|
|
37
|
+
// flex
|
|
38
|
+
// flex-1
|
|
39
|
+
// items-start
|
|
40
|
+
// justify-between
|
|
41
|
+
// gap-4
|
|
42
|
+
// rounded-md
|
|
43
|
+
// text-left
|
|
44
|
+
// focus-visible:ring-[3px]
|
|
45
|
+
// [&[data-state=open]>svg]:rotate-180
|
|
46
|
+
// `
|
|
47
|
+
// return (
|
|
48
|
+
// <AccordionPrimitive.Header asChild>
|
|
49
|
+
// <AccordionPrimitive.Trigger
|
|
50
|
+
// asChild
|
|
51
|
+
// data-slot="accordion-trigger"
|
|
52
|
+
// {...props}
|
|
53
|
+
// >
|
|
54
|
+
// <Component
|
|
55
|
+
// type={isButton ? "button" : undefined}
|
|
56
|
+
// role={!isButton ? "button" : undefined}
|
|
57
|
+
// aria-expanded={props["aria-expanded"]}
|
|
58
|
+
// aria-controls={props["aria-controls"]}
|
|
59
|
+
// tabIndex={0}
|
|
60
|
+
// className={cn(`
|
|
61
|
+
// outline-none
|
|
62
|
+
// focus-visible:border-ring
|
|
63
|
+
// focus-visible:ring-ring/50
|
|
64
|
+
// disabled:pointer-events-none
|
|
65
|
+
// disabled:opacity-50`,
|
|
66
|
+
// isUseIcon,
|
|
67
|
+
// className
|
|
68
|
+
// )}
|
|
69
|
+
// >
|
|
70
|
+
// {children}
|
|
71
|
+
// {isUseIcon && <ChevronDownIcon
|
|
72
|
+
// className={`
|
|
73
|
+
// text-muted-foreground
|
|
74
|
+
// pointer-events-none
|
|
75
|
+
// size-4
|
|
76
|
+
// shrink-0
|
|
77
|
+
// translate-y-0.5
|
|
78
|
+
// transition-transform
|
|
79
|
+
// duration-200
|
|
80
|
+
// `}
|
|
81
|
+
// />}
|
|
82
|
+
// </Component>
|
|
83
|
+
// </AccordionPrimitive.Trigger>
|
|
84
|
+
// </AccordionPrimitive.Header>
|
|
85
|
+
// )
|
|
86
|
+
// }
|
|
87
|
+
AccordionTrigger.displayName = "AccordionTrigger";
|
|
88
|
+
export default AccordionTrigger;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const Accordions: {
|
|
2
|
+
Root: {
|
|
3
|
+
(props: import("../..").ShadcnBaseProps<import("react").ForwardRefExoticComponent<(import("@radix-ui/react-accordion").AccordionSingleProps | import("@radix-ui/react-accordion").AccordionMultipleProps) & import("react").RefAttributes<HTMLDivElement>>> & {
|
|
4
|
+
as?: React.ElementType;
|
|
5
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
displayName: string;
|
|
7
|
+
};
|
|
8
|
+
Content: {
|
|
9
|
+
(props: {
|
|
10
|
+
as?: React.ElementType;
|
|
11
|
+
} & import("@radix-ui/react-accordion").AccordionContentProps & import("react").RefAttributes<HTMLDivElement> & {
|
|
12
|
+
as?: React.ElementType;
|
|
13
|
+
ref?: React.Ref<Element>;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
displayName: string;
|
|
16
|
+
};
|
|
17
|
+
Item: {
|
|
18
|
+
(props: {
|
|
19
|
+
as?: React.ElementType;
|
|
20
|
+
} & import("@radix-ui/react-accordion").AccordionItemProps & import("react").RefAttributes<HTMLDivElement> & {
|
|
21
|
+
as?: React.ElementType;
|
|
22
|
+
ref?: React.Ref<Element>;
|
|
23
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
displayName: string;
|
|
25
|
+
};
|
|
26
|
+
Trigger: {
|
|
27
|
+
(props: {
|
|
28
|
+
as?: React.ElementType;
|
|
29
|
+
} & import("@radix-ui/react-accordion").AccordionTriggerProps & import("react").RefAttributes<HTMLButtonElement> & {
|
|
30
|
+
as?: React.ElementType;
|
|
31
|
+
ref?: React.Ref<Element>;
|
|
32
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
displayName: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as AccordionRoot } from "./accordion";
|
|
2
|
+
import { default as AccordionContent } from "./accordionContent";
|
|
3
|
+
import { default as AccordionItem } from "./accordionItem";
|
|
4
|
+
import { default as AccordionTrigger } from "./accordionTrigger";
|
|
5
|
+
export const Accordions = {
|
|
6
|
+
Root: AccordionRoot,
|
|
7
|
+
Content: AccordionContent,
|
|
8
|
+
Item: AccordionItem,
|
|
9
|
+
Trigger: AccordionTrigger
|
|
10
|
+
};
|
|
11
|
+
// export * from "./accordion"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const buttonVariants: (props?: ({
|
|
4
|
+
variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
5
|
+
size?: "default" | "icon" | "sm" | "lg" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
7
|
+
declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { cn } from "../utils/index.js";
|
|
5
|
+
const buttonVariants = cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", {
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
default: "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
|
|
9
|
+
destructive: "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
10
|
+
outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
|
11
|
+
secondary: "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
|
|
12
|
+
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
13
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
17
|
+
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
18
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
19
|
+
icon: "size-9",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
variant: "default",
|
|
24
|
+
size: "default",
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
function Button({ className, variant, size, asChild = false, ...props }) {
|
|
28
|
+
const Comp = asChild ? Slot : "button";
|
|
29
|
+
return (_jsx(Comp, { "data-slot": "button", className: cn(buttonVariants({ variant, size, className })), ...props }));
|
|
30
|
+
}
|
|
31
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DragResizePropsTypes, ResizeTypes } from "../../hooks/index.js";
|
|
2
|
+
import { AsPropsTypes } from "../../types/index.js";
|
|
3
|
+
type PropsTypes<T extends React.ElementType = "div"> = AsPropsTypes<T, {
|
|
4
|
+
as?: React.ElementType;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
defaultWidth?: number;
|
|
7
|
+
defaultHeight?: number;
|
|
8
|
+
resizeClass?: string;
|
|
9
|
+
dragLineWidth?: number;
|
|
10
|
+
dragLineColor?: string;
|
|
11
|
+
containerClass?: string;
|
|
12
|
+
dragClass?: string;
|
|
13
|
+
resizeStore?: boolean;
|
|
14
|
+
resizeStoreKey?: string;
|
|
15
|
+
resizeStoreValue?: ResizeTypes;
|
|
16
|
+
} & DragResizePropsTypes>;
|
|
17
|
+
declare const DragResizeBase: <T extends React.ElementType = "div">(props: PropsTypes<T>) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
declare const DragResize: React.MemoExoticComponent<typeof DragResizeBase>;
|
|
19
|
+
export default DragResize;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { memo, useCallback, useMemo, useState } from "react";
|
|
4
|
+
import { useDragResize, useCookies } from "../../hooks/index.js";
|
|
5
|
+
import { DragResizeContext } from "./dragResizeContext";
|
|
6
|
+
import { mergeClassName } from "../../utils/index.js";
|
|
7
|
+
import styles from "./dragResize.module.scss";
|
|
8
|
+
const DragResizeBase = (props) => {
|
|
9
|
+
const { as, children, defaultWidth, defaultHeight, resizeClass, containerClass, dragClass, resizeStore = true, resizeStoreKey, resizeStoreValue, active = true, direction = "width", minWidth = 500, maxWidth = 950, dragLineWidth = 5, dragLineColor = "rgba(0, 0, 0, 1)", onInit, onResizeStart, onResizing, onResizeEnd, ...othersProps } = props;
|
|
10
|
+
const RootComponent = as || "div";
|
|
11
|
+
const [isActive, setActive] = useState(active);
|
|
12
|
+
const { setCookies, deleteCookies } = useCookies();
|
|
13
|
+
const resizeCSS = useMemo(() => mergeClassName(styles.root, resizeClass ? resizeClass : ""), [resizeClass]);
|
|
14
|
+
const dragCSS = useMemo(() => mergeClassName(styles.drag, dragClass ? dragClass : "", !isActive ? styles.off : ""), [isActive, dragClass]);
|
|
15
|
+
const containerCSS = useMemo(() => mergeClassName(styles.container, containerClass ? containerClass : ""), [containerClass]);
|
|
16
|
+
const isCookieStore = useMemo(() => resizeStore
|
|
17
|
+
&& resizeStoreKey
|
|
18
|
+
&& resizeStoreKey !== ""
|
|
19
|
+
? true : false, [resizeStore, resizeStoreKey]);
|
|
20
|
+
const resizeDefauleStyles = useMemo(() => {
|
|
21
|
+
if (!isCookieStore || !resizeStoreValue)
|
|
22
|
+
return {
|
|
23
|
+
width: minWidth + "px",
|
|
24
|
+
// height: minHeight + "px"
|
|
25
|
+
};
|
|
26
|
+
const { width, height } = resizeStoreValue;
|
|
27
|
+
return {
|
|
28
|
+
width: width ? width + "px" : "inherit",
|
|
29
|
+
height: height ? height + "px" : "inherit",
|
|
30
|
+
};
|
|
31
|
+
}, [isCookieStore, resizeStoreValue]);
|
|
32
|
+
const onResizeEndHandler = useCallback((size) => {
|
|
33
|
+
onResizeEnd?.(size);
|
|
34
|
+
if (!isCookieStore)
|
|
35
|
+
return;
|
|
36
|
+
setCookies(resizeStoreKey, JSON.stringify(size));
|
|
37
|
+
}, [isCookieStore, onResizeEnd, resizeStore]);
|
|
38
|
+
//Hooks
|
|
39
|
+
const { dragRef, resizeRef } = useDragResize({
|
|
40
|
+
active: isActive,
|
|
41
|
+
direction,
|
|
42
|
+
minWidth,
|
|
43
|
+
maxWidth,
|
|
44
|
+
onInit,
|
|
45
|
+
onResizeStart,
|
|
46
|
+
onResizing,
|
|
47
|
+
onResizeEnd: onResizeEndHandler,
|
|
48
|
+
});
|
|
49
|
+
//Context Functions
|
|
50
|
+
const setResizeActive = useCallback((active) => setActive(active), [setActive]);
|
|
51
|
+
const clearResizeStore = useCallback(() => resizeStoreKey
|
|
52
|
+
? deleteCookies(resizeStoreKey)
|
|
53
|
+
: console.error("resizeStoreKey is not undefined"), [resizeStoreKey]);
|
|
54
|
+
const defaultResizeSize = useCallback(() => {
|
|
55
|
+
if (!resizeRef.current)
|
|
56
|
+
return;
|
|
57
|
+
resizeRef.current.style.width = minWidth + "px";
|
|
58
|
+
// resizeRef.current.style.height = minHeight + "px"
|
|
59
|
+
clearResizeStore();
|
|
60
|
+
}, [resizeRef.current, clearResizeStore]);
|
|
61
|
+
const contextValue = useMemo(() => ({
|
|
62
|
+
setResizeActive,
|
|
63
|
+
clearResizeStore,
|
|
64
|
+
defaultResizeSize
|
|
65
|
+
}), [
|
|
66
|
+
setResizeActive,
|
|
67
|
+
clearResizeStore,
|
|
68
|
+
defaultResizeSize
|
|
69
|
+
]);
|
|
70
|
+
return (_jsx(DragResizeContext, { value: contextValue, children: _jsxs(RootComponent, { ...othersProps, ref: resizeRef, className: resizeCSS, style: resizeDefauleStyles, children: [_jsx("div", { className: containerCSS, children: children }), _jsx("div", { ref: dragRef, className: dragCSS, style: {
|
|
71
|
+
"--drag-line-width": dragLineWidth + "px",
|
|
72
|
+
"--drag-line-color": dragLineColor
|
|
73
|
+
} })] }) }));
|
|
74
|
+
};
|
|
75
|
+
const DragResize = memo(DragResizeBase);
|
|
76
|
+
DragResize.displayName = "DragResize";
|
|
77
|
+
export default DragResize;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
width: inherit;
|
|
3
|
+
height: inherit;
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: row;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.container {
|
|
9
|
+
width: inherit;
|
|
10
|
+
height: inherit;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.drag {
|
|
14
|
+
--drag-line-width: 2px;
|
|
15
|
+
--drag-line-color: rgbs(0, 0, 0, 1);
|
|
16
|
+
|
|
17
|
+
width: 0;
|
|
18
|
+
height: inherit;
|
|
19
|
+
position: relative;
|
|
20
|
+
z-index: 2;
|
|
21
|
+
|
|
22
|
+
&::before {
|
|
23
|
+
content: "";
|
|
24
|
+
width: 0;
|
|
25
|
+
height: inherit;
|
|
26
|
+
border-left: var(--drag-line-width) solid var(--drag-line-color);
|
|
27
|
+
position: absolute;
|
|
28
|
+
inset: 0 0 0 calc(var(--drag-line-width) / 2 * -1);
|
|
29
|
+
z-index: 1;
|
|
30
|
+
opacity: 0;
|
|
31
|
+
transition: 0.5s ease-in-out;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&:not(.off) {
|
|
35
|
+
&:hover {
|
|
36
|
+
cursor: ew-resize;
|
|
37
|
+
&::before {
|
|
38
|
+
opacity: 1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface DragResizeContextType {
|
|
3
|
+
setResizeActive: (active: boolean) => void;
|
|
4
|
+
clearResizeStore: () => void;
|
|
5
|
+
defaultResizeSize: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const DragResizeContext: React.Context<DragResizeContextType | undefined> & {
|
|
8
|
+
displayName: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const useDragResizeContext: () => DragResizeContextType;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { use, createContext } from "react";
|
|
3
|
+
export const DragResizeContext = Object.assign(createContext(undefined), { displayName: "DragResizeContext" });
|
|
4
|
+
export const useDragResizeContext = () => {
|
|
5
|
+
const context = use(DragResizeContext);
|
|
6
|
+
if (context)
|
|
7
|
+
return context;
|
|
8
|
+
throw new Error("DragResizeContext is not defined!!");
|
|
9
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AsPropsTypes } from "../../types/index.js";
|
|
2
|
+
import type { Sortable, Store } from "react-sortablejs";
|
|
3
|
+
type PropsTypes<T extends React.ElementType = "div"> = AsPropsTypes<T, {
|
|
4
|
+
as?: string;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
datasets: any[];
|
|
7
|
+
rootClass?: string;
|
|
8
|
+
sorterClass?: string;
|
|
9
|
+
handlerClass?: string;
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
animation?: number;
|
|
13
|
+
onChange?: (newState: any[], sortable: Sortable | null, store: Store) => void;
|
|
14
|
+
onStart?: ((evt: Sortable.SortableEvent, sortable: Sortable | null, store: Store) => void) | undefined;
|
|
15
|
+
onEnd?: ((evt: Sortable.SortableEvent, sortable: Sortable | null, store: Store) => void) | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
declare const DragSortableBase: <T extends React.ElementType = "div">(props: PropsTypes<T>) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
declare const DragSortable: React.MemoExoticComponent<typeof DragSortableBase>;
|
|
19
|
+
export default DragSortable;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { memo } from "react";
|
|
4
|
+
import { ReactSortable } from "react-sortablejs";
|
|
5
|
+
const DragSortableBase = (props) => {
|
|
6
|
+
const { as, children, datasets = [], rootClass, sorterClass, handlerClass, style, animation = 150, disabled = false, onChange, onStart, onEnd, ...othersProps } = props;
|
|
7
|
+
return (_jsx(ReactSortable, { ...othersProps, tag: as, disabled: disabled, className: rootClass, ghostClass: sorterClass, handle: "." + handlerClass, fallbackClass: "sortable-fallback", list: datasets, setList: onChange, animation: animation, style: style, onStart: onStart, onEnd: onEnd, children: children }));
|
|
8
|
+
};
|
|
9
|
+
const DragSortable = memo(DragSortableBase);
|
|
10
|
+
DragSortable.displayName = "DragSortable";
|
|
11
|
+
export default DragSortable;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as DragSortable } from "./dragSortable";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as DragSortable } from "./dragSortable";
|
package/dist/components/index.js
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export declare const Resizables: {
|
|
2
|
+
Root: {
|
|
3
|
+
(props: Omit<import("react").HTMLAttributes<keyof HTMLElementTagNameMap>, "id"> & {
|
|
4
|
+
autoSaveId?: string | null;
|
|
5
|
+
className?: string;
|
|
6
|
+
direction: import("react-resizable-panels/dist/declarations/src/types").Direction;
|
|
7
|
+
id?: string | null;
|
|
8
|
+
keyboardResizeBy?: number | null;
|
|
9
|
+
onLayout?: import("react-resizable-panels").PanelGroupOnLayout | null;
|
|
10
|
+
storage?: import("react-resizable-panels").PanelGroupStorage;
|
|
11
|
+
style?: import("react").CSSProperties;
|
|
12
|
+
tagName?: keyof HTMLElementTagNameMap;
|
|
13
|
+
dir?: "auto" | "ltr" | "rtl" | undefined;
|
|
14
|
+
} & {
|
|
15
|
+
children?: import("react").ReactNode | undefined;
|
|
16
|
+
} & import("react").RefAttributes<import("react-resizable-panels").ImperativePanelGroupHandle> & {
|
|
17
|
+
as?: keyof HTMLElementTagNameMap;
|
|
18
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
displayName: string;
|
|
20
|
+
};
|
|
21
|
+
Panel: {
|
|
22
|
+
(props: Omit<import("react").HTMLAttributes<HTMLDivElement | HTMLElement | HTMLObjectElement | HTMLInputElement | HTMLProgressElement | HTMLSelectElement | HTMLButtonElement | HTMLAnchorElement | HTMLAreaElement | HTMLAudioElement | HTMLBaseElement | HTMLQuoteElement | HTMLBodyElement | HTMLBRElement | HTMLCanvasElement | HTMLTableColElement | HTMLDataElement | HTMLDataListElement | HTMLModElement | HTMLDetailsElement | HTMLDialogElement | HTMLDListElement | HTMLEmbedElement | HTMLFieldSetElement | HTMLFormElement | HTMLHeadingElement | HTMLHeadElement | HTMLHRElement | HTMLHtmlElement | HTMLIFrameElement | HTMLImageElement | HTMLLabelElement | HTMLLegendElement | HTMLLIElement | HTMLLinkElement | HTMLMapElement | HTMLMetaElement | HTMLMeterElement | HTMLOListElement | HTMLOptGroupElement | HTMLOptionElement | HTMLOutputElement | HTMLParagraphElement | HTMLPreElement | HTMLSlotElement | HTMLScriptElement | HTMLSourceElement | HTMLSpanElement | HTMLStyleElement | HTMLTableElement | HTMLTemplateElement | HTMLTableSectionElement | HTMLTableCellElement | HTMLTextAreaElement | HTMLTimeElement | HTMLTitleElement | HTMLTableRowElement | HTMLTrackElement | HTMLUListElement | HTMLVideoElement | HTMLTableCaptionElement | HTMLMenuElement | HTMLPictureElement>, "id" | "onResize"> & {
|
|
23
|
+
className?: string;
|
|
24
|
+
collapsedSize?: number | undefined;
|
|
25
|
+
collapsible?: boolean | undefined;
|
|
26
|
+
defaultSize?: number | undefined;
|
|
27
|
+
id?: string;
|
|
28
|
+
maxSize?: number | undefined;
|
|
29
|
+
minSize?: number | undefined;
|
|
30
|
+
onCollapse?: import("react-resizable-panels").PanelOnCollapse;
|
|
31
|
+
onExpand?: import("react-resizable-panels").PanelOnExpand;
|
|
32
|
+
onResize?: import("react-resizable-panels").PanelOnResize;
|
|
33
|
+
order?: number;
|
|
34
|
+
style?: object;
|
|
35
|
+
tagName?: keyof HTMLElementTagNameMap | undefined;
|
|
36
|
+
} & {
|
|
37
|
+
children?: import("react").ReactNode | undefined;
|
|
38
|
+
} & import("react").RefAttributes<import("react-resizable-panels").ImperativePanelHandle> & {
|
|
39
|
+
as?: keyof HTMLElementTagNameMap;
|
|
40
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
displayName: string;
|
|
42
|
+
};
|
|
43
|
+
Handle: {
|
|
44
|
+
(props: Omit<import("react").HTMLAttributes<keyof HTMLElementTagNameMap>, "id" | "onFocus" | "onBlur" | "onClick" | "onPointerDown" | "onPointerUp"> & {
|
|
45
|
+
className?: string;
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
hitAreaMargins?: import("react-resizable-panels").PointerHitAreaMargins;
|
|
48
|
+
id?: string | null;
|
|
49
|
+
onBlur?: () => void;
|
|
50
|
+
onClick?: () => void;
|
|
51
|
+
onDragging?: import("react-resizable-panels").PanelResizeHandleOnDragging;
|
|
52
|
+
onFocus?: () => void;
|
|
53
|
+
onPointerDown?: () => void;
|
|
54
|
+
onPointerUp?: () => void;
|
|
55
|
+
style?: import("react").CSSProperties;
|
|
56
|
+
tabIndex?: number;
|
|
57
|
+
tagName?: keyof HTMLElementTagNameMap;
|
|
58
|
+
} & {
|
|
59
|
+
children?: import("react").ReactNode | undefined;
|
|
60
|
+
} & {
|
|
61
|
+
as?: keyof HTMLElementTagNameMap;
|
|
62
|
+
withHandle?: boolean;
|
|
63
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
64
|
+
displayName: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as ResizablePanelGroup } from "./resizablePanelGroup";
|
|
2
|
+
import { default as ResizablePanel } from "./resizablePanel";
|
|
3
|
+
import { default as ResizableHandle } from "./resizableHandle";
|
|
4
|
+
export const Resizables = {
|
|
5
|
+
Root: ResizablePanelGroup,
|
|
6
|
+
Panel: ResizablePanel,
|
|
7
|
+
Handle: ResizableHandle,
|
|
8
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as ResizablePrimitive from 'react-resizable-panels';
|
|
2
|
+
import type { ComponentProps } from "../../types/index.js";
|
|
3
|
+
type PropsType = ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & {
|
|
4
|
+
as?: keyof HTMLElementTagNameMap;
|
|
5
|
+
withHandle?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare const ResizableHandle: {
|
|
8
|
+
(props: PropsType): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
displayName: string;
|
|
10
|
+
};
|
|
11
|
+
export default ResizableHandle;
|