@stackshift-ui/sheet 1.0.0-beta.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.
@@ -0,0 +1,37 @@
1
+ import * as SheetPrimitive from "@radix-ui/react-dialog";
2
+ import * as React from "react";
3
+ declare function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
4
+ declare namespace Sheet {
5
+ var displayName: string;
6
+ }
7
+ declare function SheetTrigger({ ...props }: React.ComponentProps<typeof SheetPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
8
+ declare namespace SheetTrigger {
9
+ var displayName: string;
10
+ }
11
+ declare function SheetClose({ ...props }: React.ComponentProps<typeof SheetPrimitive.Close>): import("react/jsx-runtime").JSX.Element;
12
+ declare namespace SheetClose {
13
+ var displayName: string;
14
+ }
15
+ declare function SheetContent({ className, children, side, ...props }: React.ComponentProps<typeof SheetPrimitive.Content> & {
16
+ side?: "top" | "right" | "bottom" | "left";
17
+ }): import("react/jsx-runtime").JSX.Element;
18
+ declare namespace SheetContent {
19
+ var displayName: string;
20
+ }
21
+ declare function SheetHeader({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
22
+ declare namespace SheetHeader {
23
+ var displayName: string;
24
+ }
25
+ declare function SheetFooter({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
26
+ declare namespace SheetFooter {
27
+ var displayName: string;
28
+ }
29
+ declare function SheetTitle({ className, ...props }: React.ComponentProps<typeof SheetPrimitive.Title>): import("react/jsx-runtime").JSX.Element;
30
+ declare namespace SheetTitle {
31
+ var displayName: string;
32
+ }
33
+ declare function SheetDescription({ className, ...props }: React.ComponentProps<typeof SheetPrimitive.Description>): import("react/jsx-runtime").JSX.Element;
34
+ declare namespace SheetDescription {
35
+ var displayName: string;
36
+ }
37
+ export { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, };
package/dist/sheet.js ADDED
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ "use strict";var z=Object.create;var l=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var X=(e,t)=>{for(var a in t)l(e,a,{get:t[a],enumerable:!0})},m=(e,t,a,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of H(t))!U.call(e,n)&&n!==a&&l(e,n,{get:()=>t[n],enumerable:!(r=F(t,n))||r.enumerable});return e};var q=(e,t,a)=>(a=e!=null?z(I(e)):{},m(t||!e||!e.__esModule?l(a,"default",{value:e,enumerable:!0}):a,e)),A=e=>m(l({},"__esModule",{value:!0}),e);var B={};X(B,{Sheet:()=>v,SheetClose:()=>b,SheetContent:()=>T,SheetDescription:()=>k,SheetFooter:()=>w,SheetHeader:()=>D,SheetTitle:()=>O,SheetTrigger:()=>N});module.exports=A(B);var i=q(require("@radix-ui/react-dialog")),p=require("lucide-react"),o=require("@stackshift-ui/system"),s=require("react/jsx-runtime"),d="Sheet",c="SheetTrigger",h="SheetPortal",f="SheetClose",u="SheetOverlay",S="SheetContent",y="SheetHeader",C="SheetFooter",g="SheetTitle",P="SheetDescription";function v({...e}){let{[d]:t=o.DefaultComponent}=(0,o.useStackShiftUIComponents)();return(0,s.jsx)(t,{as:i.Root,"data-slot":"sheet",...e})}v.displayName=d;function N({...e}){let{[c]:t=o.DefaultComponent}=(0,o.useStackShiftUIComponents)();return(0,s.jsx)(t,{as:i.Trigger,"data-slot":"sheet-trigger",...e})}N.displayName=c;function b({...e}){let{[f]:t=o.DefaultComponent}=(0,o.useStackShiftUIComponents)();return(0,s.jsx)(t,{as:i.Close,"data-slot":"sheet-close",...e})}b.displayName=f;function x({...e}){let{[h]:t=o.DefaultComponent}=(0,o.useStackShiftUIComponents)();return(0,s.jsx)(t,{as:i.Portal,"data-slot":"sheet-portal",...e})}x.displayName=h;function R({className:e,...t}){let{[u]:a=o.DefaultComponent}=(0,o.useStackShiftUIComponents)();return(0,s.jsx)(a,{as:i.Overlay,"data-slot":"sheet-overlay",className:(0,o.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}R.displayName=u;function T({className:e,children:t,side:a="right",...r}){let{[S]:n=o.DefaultComponent}=(0,o.useStackShiftUIComponents)();return(0,s.jsxs)(x,{children:[(0,s.jsx)(R,{}),(0,s.jsxs)(n,{as:i.Content,"data-slot":"sheet-content",className:(0,o.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",a==="right"&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",a==="left"&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",a==="top"&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",a==="bottom"&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",e),...r,children:[t,(0,s.jsxs)(i.Close,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[(0,s.jsx)(p.XIcon,{className:"size-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}T.displayName=S;function D({className:e,...t}){let{[y]:a=o.DefaultComponent}=(0,o.useStackShiftUIComponents)();return(0,s.jsx)(a,{"data-slot":"sheet-header",className:(0,o.cn)("flex flex-col gap-1.5 p-4",e),...t})}D.displayName=y;function w({className:e,...t}){let{[C]:a=o.DefaultComponent}=(0,o.useStackShiftUIComponents)();return(0,s.jsx)(a,{"data-slot":"sheet-footer",className:(0,o.cn)("mt-auto flex flex-col gap-2 p-4",e),...t})}w.displayName=C;function O({className:e,...t}){let{[g]:a=o.DefaultComponent}=(0,o.useStackShiftUIComponents)();return(0,s.jsx)(a,{as:i.Title,"data-slot":"sheet-title",className:(0,o.cn)("text-foreground font-semibold",e),...t})}O.displayName=g;function k({className:e,...t}){let{[P]:a=o.DefaultComponent}=(0,o.useStackShiftUIComponents)();return(0,s.jsx)(a,{as:i.Description,"data-slot":"sheet-description",className:(0,o.cn)("text-muted-foreground text-sm",e),...t})}k.displayName=P;0&&(module.exports={Sheet,SheetClose,SheetContent,SheetDescription,SheetFooter,SheetHeader,SheetTitle,SheetTrigger});
package/dist/sheet.mjs ADDED
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ "use strict";import{a,b,c,d,e,f,g,h}from"./chunk-P5DWHNX6.mjs";import"./chunk-3EYN2AKU.mjs";export{a as Sheet,c as SheetClose,d as SheetContent,h as SheetDescription,f as SheetFooter,e as SheetHeader,g as SheetTitle,b as SheetTrigger};
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@stackshift-ui/sheet",
3
+ "description": "Extends the Dialog component to display content that complements the main content of the screen.",
4
+ "version": "1.0.0-beta.1",
5
+ "private": false,
6
+ "sideEffects": false,
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.mjs",
9
+ "types": "./dist/index.d.ts",
10
+ "files": [
11
+ "dist/**",
12
+ "src"
13
+ ],
14
+ "author": "WebriQ <info@webriq.com>",
15
+ "devDependencies": {
16
+ "@testing-library/jest-dom": "^6.5.0",
17
+ "@testing-library/react": "^16.0.1",
18
+ "@testing-library/user-event": "^14.6.1",
19
+ "@types/node": "^22.7.0",
20
+ "@types/react": "^18.3.9",
21
+ "@types/react-dom": "^18.3.0",
22
+ "@vitejs/plugin-react": "^4.3.1",
23
+ "@vitest/coverage-v8": "^2.1.1",
24
+ "esbuild-plugin-rdi": "^0.0.0",
25
+ "esbuild-plugin-react18": "^0.2.5",
26
+ "esbuild-plugin-react18-css": "^0.0.4",
27
+ "jsdom": "^25.0.1",
28
+ "react": "^18.3.1",
29
+ "react-dom": "^18.3.1",
30
+ "tsup": "^8.3.0",
31
+ "typescript": "^5.6.2",
32
+ "vite-tsconfig-paths": "^5.0.1",
33
+ "vitest": "^2.1.1",
34
+ "@stackshift-ui/eslint-config": "6.0.10",
35
+ "@stackshift-ui/typescript-config": "6.0.10"
36
+ },
37
+ "dependencies": {
38
+ "@radix-ui/react-dialog": "^1.1.14",
39
+ "classnames": "^2.5.1",
40
+ "lucide-react": "^0.468.0",
41
+ "@stackshift-ui/scripts": "6.1.0-beta.0",
42
+ "@stackshift-ui/system": "6.1.0-beta.0"
43
+ },
44
+ "peerDependencies": {
45
+ "@stackshift-ui/system": ">=6.1.0-beta.0",
46
+ "@types/react": "16.8 - 19",
47
+ "next": "10 - 14",
48
+ "react": "16.8 - 19",
49
+ "react-dom": "16.8 - 19"
50
+ },
51
+ "peerDependenciesMeta": {
52
+ "next": {
53
+ "optional": true
54
+ }
55
+ },
56
+ "scripts": {
57
+ "build": "tsup && tsc -p tsconfig-build.json",
58
+ "clean": "rm -rf dist",
59
+ "dev": "tsup --watch && tsc -p tsconfig-build.json -w",
60
+ "typecheck": "tsc --noEmit",
61
+ "lint": "eslint src/",
62
+ "test": "vitest run --coverage"
63
+ }
64
+ }
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ "use client";
2
+
3
+ // component exports
4
+ export * from "./sheet";
@@ -0,0 +1,4 @@
1
+ import '@testing-library/jest-dom';
2
+
3
+ export { };
4
+
@@ -0,0 +1,45 @@
1
+ import { cleanup, render, screen } from "@testing-library/react";
2
+ import userEvent from "@testing-library/user-event";
3
+ import { afterEach, describe, test } from "vitest";
4
+ import {
5
+ Sheet,
6
+ SheetContent,
7
+ SheetDescription,
8
+ SheetHeader,
9
+ SheetTitle,
10
+ SheetTrigger,
11
+ } from "./sheet";
12
+
13
+ describe.concurrent("sheet", () => {
14
+ afterEach(cleanup);
15
+
16
+ test("Dummy test - test if renders without errors", async ({ expect }) => {
17
+ const clx = "my-class";
18
+
19
+ const user = userEvent.setup();
20
+
21
+ const { unmount } = render(
22
+ <Sheet>
23
+ <SheetTrigger asChild data-testid="sheet-trigger">
24
+ <button>Open Sheet</button>
25
+ </SheetTrigger>
26
+ <SheetContent data-testid="sheet-container" className={clx}>
27
+ <SheetHeader>
28
+ <SheetTitle>Sheet Title</SheetTitle>
29
+ <SheetDescription>Sheet Description</SheetDescription>
30
+ </SheetHeader>
31
+ </SheetContent>
32
+ </Sheet>,
33
+ );
34
+
35
+ const trigger = screen.getByTestId("sheet-trigger");
36
+ expect(trigger).toBeInTheDocument();
37
+
38
+ user.click(trigger);
39
+
40
+ const sheet = await screen.findByTestId("sheet-container");
41
+
42
+ expect(sheet).toBeInTheDocument();
43
+ unmount();
44
+ });
45
+ });
package/src/sheet.tsx ADDED
@@ -0,0 +1,174 @@
1
+ "use client";
2
+
3
+ import * as SheetPrimitive from "@radix-ui/react-dialog";
4
+ import { XIcon } from "lucide-react";
5
+ import * as React from "react";
6
+
7
+ import { cn, DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
8
+
9
+ const displayName = "Sheet";
10
+ const displayNameTrigger = "SheetTrigger";
11
+ const displayNamePortal = "SheetPortal";
12
+ const displayNameClose = "SheetClose";
13
+ const displayNameOverlay = "SheetOverlay";
14
+ const displayNameContent = "SheetContent";
15
+ const displayNameHeader = "SheetHeader";
16
+ const displayNameFooter = "SheetFooter";
17
+ const displayNameTitle = "SheetTitle";
18
+ const displayNameDescription = "SheetDescription";
19
+
20
+ function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) {
21
+ const { [displayName]: Component = DefaultComponent } = useStackShiftUIComponents();
22
+
23
+ return <Component as={SheetPrimitive.Root} data-slot="sheet" {...props} />;
24
+ }
25
+ Sheet.displayName = displayName;
26
+
27
+ function SheetTrigger({ ...props }: React.ComponentProps<typeof SheetPrimitive.Trigger>) {
28
+ const { [displayNameTrigger]: Component = DefaultComponent } = useStackShiftUIComponents();
29
+
30
+ return <Component as={SheetPrimitive.Trigger} data-slot="sheet-trigger" {...props} />;
31
+ }
32
+ SheetTrigger.displayName = displayNameTrigger;
33
+
34
+ function SheetClose({ ...props }: React.ComponentProps<typeof SheetPrimitive.Close>) {
35
+ const { [displayNameClose]: Component = DefaultComponent } = useStackShiftUIComponents();
36
+
37
+ return <Component as={SheetPrimitive.Close} data-slot="sheet-close" {...props} />;
38
+ }
39
+ SheetClose.displayName = displayNameClose;
40
+
41
+ function SheetPortal({ ...props }: React.ComponentProps<typeof SheetPrimitive.Portal>) {
42
+ const { [displayNamePortal]: Component = DefaultComponent } = useStackShiftUIComponents();
43
+
44
+ return <Component as={SheetPrimitive.Portal} data-slot="sheet-portal" {...props} />;
45
+ }
46
+ SheetPortal.displayName = displayNamePortal;
47
+
48
+ function SheetOverlay({
49
+ className,
50
+ ...props
51
+ }: React.ComponentProps<typeof SheetPrimitive.Overlay>) {
52
+ const { [displayNameOverlay]: Component = DefaultComponent } = useStackShiftUIComponents();
53
+
54
+ return (
55
+ <Component
56
+ as={SheetPrimitive.Overlay}
57
+ data-slot="sheet-overlay"
58
+ className={cn(
59
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
60
+ className,
61
+ )}
62
+ {...props}
63
+ />
64
+ );
65
+ }
66
+ SheetOverlay.displayName = displayNameOverlay;
67
+
68
+ function SheetContent({
69
+ className,
70
+ children,
71
+ side = "right",
72
+ ...props
73
+ }: React.ComponentProps<typeof SheetPrimitive.Content> & {
74
+ side?: "top" | "right" | "bottom" | "left";
75
+ }) {
76
+ const { [displayNameContent]: Component = DefaultComponent } = useStackShiftUIComponents();
77
+
78
+ return (
79
+ <SheetPortal>
80
+ <SheetOverlay />
81
+ <Component
82
+ as={SheetPrimitive.Content}
83
+ data-slot="sheet-content"
84
+ className={cn(
85
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
86
+ side === "right" &&
87
+ "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",
88
+ side === "left" &&
89
+ "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",
90
+ side === "top" &&
91
+ "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
92
+ side === "bottom" &&
93
+ "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
94
+ className,
95
+ )}
96
+ {...props}>
97
+ {children}
98
+ <SheetPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">
99
+ <XIcon className="size-4" />
100
+ <span className="sr-only">Close</span>
101
+ </SheetPrimitive.Close>
102
+ </Component>
103
+ </SheetPortal>
104
+ );
105
+ }
106
+ SheetContent.displayName = displayNameContent;
107
+
108
+ function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
109
+ const { [displayNameHeader]: Component = DefaultComponent } = useStackShiftUIComponents();
110
+
111
+ return (
112
+ <Component
113
+ data-slot="sheet-header"
114
+ className={cn("flex flex-col gap-1.5 p-4", className)}
115
+ {...props}
116
+ />
117
+ );
118
+ }
119
+ SheetHeader.displayName = displayNameHeader;
120
+
121
+ function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
122
+ const { [displayNameFooter]: Component = DefaultComponent } = useStackShiftUIComponents();
123
+
124
+ return (
125
+ <Component
126
+ data-slot="sheet-footer"
127
+ className={cn("mt-auto flex flex-col gap-2 p-4", className)}
128
+ {...props}
129
+ />
130
+ );
131
+ }
132
+ SheetFooter.displayName = displayNameFooter;
133
+
134
+ function SheetTitle({ className, ...props }: React.ComponentProps<typeof SheetPrimitive.Title>) {
135
+ const { [displayNameTitle]: Component = DefaultComponent } = useStackShiftUIComponents();
136
+
137
+ return (
138
+ <Component
139
+ as={SheetPrimitive.Title}
140
+ data-slot="sheet-title"
141
+ className={cn("text-foreground font-semibold", className)}
142
+ {...props}
143
+ />
144
+ );
145
+ }
146
+ SheetTitle.displayName = displayNameTitle;
147
+
148
+ function SheetDescription({
149
+ className,
150
+ ...props
151
+ }: React.ComponentProps<typeof SheetPrimitive.Description>) {
152
+ const { [displayNameDescription]: Component = DefaultComponent } = useStackShiftUIComponents();
153
+
154
+ return (
155
+ <Component
156
+ as={SheetPrimitive.Description}
157
+ data-slot="sheet-description"
158
+ className={cn("text-muted-foreground text-sm", className)}
159
+ {...props}
160
+ />
161
+ );
162
+ }
163
+ SheetDescription.displayName = displayNameDescription;
164
+
165
+ export {
166
+ Sheet,
167
+ SheetClose,
168
+ SheetContent,
169
+ SheetDescription,
170
+ SheetFooter,
171
+ SheetHeader,
172
+ SheetTitle,
173
+ SheetTrigger,
174
+ };