@stackshift-ui/dialog 1.0.0-beta.2 → 1.0.0-beta.4
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/chunk-6DZX6EAA.mjs +37 -0
- package/dist/chunk-UQAQSADE.mjs +154 -0
- package/dist/chunk-X66CH5UC.mjs +1 -0
- package/dist/dialog.d.ts +11 -41
- package/dist/dialog.js +1 -1
- package/dist/dialog.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/setupTests.js +36 -40
- package/dist/setupTests.mjs +34 -38
- package/package.json +4 -4
- package/src/dialog.tsx +62 -37
- package/dist/chunk-2VQY25ZS.mjs +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackshift-ui/dialog",
|
|
3
3
|
"description": "A window overlaid on either the primary window or another dialog window, rendering the content underneath inert.",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.4",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"@radix-ui/react-dialog": "^1.1.14",
|
|
39
39
|
"classnames": "^2.5.1",
|
|
40
40
|
"lucide-react": "^0.468.0",
|
|
41
|
-
"@stackshift-ui/
|
|
42
|
-
"@stackshift-ui/
|
|
41
|
+
"@stackshift-ui/system": "6.1.0-beta.3",
|
|
42
|
+
"@stackshift-ui/scripts": "6.1.0-beta.2"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@stackshift-ui/system": ">=6.1.0-beta.
|
|
45
|
+
"@stackshift-ui/system": ">=6.1.0-beta.3",
|
|
46
46
|
"@types/react": "16.8 - 19",
|
|
47
47
|
"next": "10 - 14",
|
|
48
48
|
"react": "16.8 - 19",
|
package/src/dialog.tsx
CHANGED
|
@@ -17,43 +17,56 @@ const displayNameFooter = "DialogFooter";
|
|
|
17
17
|
const displayNameTitle = "DialogTitle";
|
|
18
18
|
const displayNameDescription = "DialogDescription";
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
const Dialog = React.forwardRef<
|
|
21
|
+
React.ElementRef<typeof DialogPrimitive.Root>,
|
|
22
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root>
|
|
23
|
+
>(({ ...props }, ref) => {
|
|
21
24
|
const { [displayName]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
22
25
|
|
|
23
|
-
return <Component as={DialogPrimitive.Root} data-slot="dialog" {...props} />;
|
|
24
|
-
}
|
|
26
|
+
return <Component as={DialogPrimitive.Root} ref={ref} data-slot="dialog" {...props} />;
|
|
27
|
+
});
|
|
25
28
|
Dialog.displayName = displayName;
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
const DialogTrigger = React.forwardRef<
|
|
31
|
+
React.ElementRef<typeof DialogPrimitive.Trigger>,
|
|
32
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Trigger>
|
|
33
|
+
>(({ ...props }, ref) => {
|
|
28
34
|
const { [displayNameTrigger]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
29
35
|
|
|
30
|
-
return <Component as={DialogPrimitive.Trigger} data-slot="dialog-trigger" {...props} />;
|
|
31
|
-
}
|
|
36
|
+
return <Component as={DialogPrimitive.Trigger} ref={ref} data-slot="dialog-trigger" {...props} />;
|
|
37
|
+
});
|
|
32
38
|
DialogTrigger.displayName = displayNameTrigger;
|
|
33
39
|
|
|
34
|
-
|
|
40
|
+
const DialogPortal = React.forwardRef<
|
|
41
|
+
React.ElementRef<typeof DialogPrimitive.Portal>,
|
|
42
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Portal>
|
|
43
|
+
>(({ ...props }, ref) => {
|
|
35
44
|
const { [displayNamePortal]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
36
45
|
|
|
37
|
-
return <Component as={DialogPrimitive.Portal} data-slot="dialog-portal" {...props} />;
|
|
38
|
-
}
|
|
46
|
+
return <Component as={DialogPrimitive.Portal} ref={ref} data-slot="dialog-portal" {...props} />;
|
|
47
|
+
});
|
|
39
48
|
DialogPortal.displayName = displayNamePortal;
|
|
40
49
|
|
|
41
|
-
|
|
50
|
+
const DialogClose = React.forwardRef<
|
|
51
|
+
React.ElementRef<typeof DialogPrimitive.Close>,
|
|
52
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Close>
|
|
53
|
+
>(({ ...props }, ref) => {
|
|
42
54
|
const { [displayNameClose]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
43
55
|
|
|
44
|
-
return <Component as={DialogPrimitive.Close} data-slot="dialog-close" {...props} />;
|
|
45
|
-
}
|
|
56
|
+
return <Component as={DialogPrimitive.Close} ref={ref} data-slot="dialog-close" {...props} />;
|
|
57
|
+
});
|
|
46
58
|
DialogClose.displayName = displayNameClose;
|
|
47
59
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
60
|
+
const DialogOverlay = React.forwardRef<
|
|
61
|
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
62
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
63
|
+
>(({ className, ...props }, ref) => {
|
|
52
64
|
const { [displayNameOverlay]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
53
65
|
|
|
54
66
|
return (
|
|
55
67
|
<Component
|
|
56
68
|
as={DialogPrimitive.Overlay}
|
|
69
|
+
ref={ref}
|
|
57
70
|
data-slot="dialog-overlay"
|
|
58
71
|
className={cn(
|
|
59
72
|
"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",
|
|
@@ -62,17 +75,15 @@ function DialogOverlay({
|
|
|
62
75
|
{...props}
|
|
63
76
|
/>
|
|
64
77
|
);
|
|
65
|
-
}
|
|
78
|
+
});
|
|
66
79
|
DialogOverlay.displayName = displayNameOverlay;
|
|
67
80
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
showCloseButton?: boolean;
|
|
75
|
-
}) {
|
|
81
|
+
const DialogContent = React.forwardRef<
|
|
82
|
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
83
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
|
|
84
|
+
showCloseButton?: boolean;
|
|
85
|
+
}
|
|
86
|
+
>(({ className, children, showCloseButton = true, ...props }, ref) => {
|
|
76
87
|
const { [displayNameContent]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
77
88
|
|
|
78
89
|
return (
|
|
@@ -80,6 +91,7 @@ function DialogContent({
|
|
|
80
91
|
<DialogOverlay />
|
|
81
92
|
<Component
|
|
82
93
|
as={DialogPrimitive.Content}
|
|
94
|
+
ref={ref}
|
|
83
95
|
data-slot="dialog-content"
|
|
84
96
|
className={cn(
|
|
85
97
|
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
|
|
@@ -98,64 +110,77 @@ function DialogContent({
|
|
|
98
110
|
</Component>
|
|
99
111
|
</DialogPortal>
|
|
100
112
|
);
|
|
101
|
-
}
|
|
113
|
+
});
|
|
102
114
|
DialogContent.displayName = displayNameContent;
|
|
103
115
|
|
|
104
|
-
|
|
116
|
+
const DialogHeader = React.forwardRef<
|
|
117
|
+
React.ElementRef<"div">,
|
|
118
|
+
React.ComponentPropsWithoutRef<"div">
|
|
119
|
+
>(({ className, ...props }, ref) => {
|
|
105
120
|
const { [displayNameHeader]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
106
121
|
|
|
107
122
|
return (
|
|
108
123
|
<Component
|
|
124
|
+
ref={ref}
|
|
109
125
|
data-slot="dialog-header"
|
|
110
126
|
className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
|
|
111
127
|
{...props}
|
|
112
128
|
/>
|
|
113
129
|
);
|
|
114
|
-
}
|
|
130
|
+
});
|
|
115
131
|
DialogHeader.displayName = displayNameHeader;
|
|
116
132
|
|
|
117
|
-
|
|
133
|
+
const DialogFooter = React.forwardRef<
|
|
134
|
+
React.ElementRef<"div">,
|
|
135
|
+
React.ComponentPropsWithoutRef<"div">
|
|
136
|
+
>(({ className, ...props }, ref) => {
|
|
118
137
|
const { [displayNameFooter]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
119
138
|
|
|
120
139
|
return (
|
|
121
140
|
<Component
|
|
141
|
+
ref={ref}
|
|
122
142
|
data-slot="dialog-footer"
|
|
123
143
|
className={cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className)}
|
|
124
144
|
{...props}
|
|
125
145
|
/>
|
|
126
146
|
);
|
|
127
|
-
}
|
|
147
|
+
});
|
|
128
148
|
DialogFooter.displayName = displayNameFooter;
|
|
129
149
|
|
|
130
|
-
|
|
150
|
+
const DialogTitle = React.forwardRef<
|
|
151
|
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
152
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
153
|
+
>(({ className, ...props }, ref) => {
|
|
131
154
|
const { [displayNameTitle]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
132
155
|
|
|
133
156
|
return (
|
|
134
157
|
<Component
|
|
135
158
|
as={DialogPrimitive.Title}
|
|
159
|
+
ref={ref}
|
|
136
160
|
data-slot="dialog-title"
|
|
137
161
|
className={cn("text-lg leading-none font-semibold", className)}
|
|
138
162
|
{...props}
|
|
139
163
|
/>
|
|
140
164
|
);
|
|
141
|
-
}
|
|
165
|
+
});
|
|
142
166
|
DialogTitle.displayName = displayNameTitle;
|
|
143
167
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
168
|
+
const DialogDescription = React.forwardRef<
|
|
169
|
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
170
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
171
|
+
>(({ className, ...props }, ref) => {
|
|
148
172
|
const { [displayNameDescription]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
149
173
|
|
|
150
174
|
return (
|
|
151
175
|
<Component
|
|
152
176
|
as={DialogPrimitive.Description}
|
|
177
|
+
ref={ref}
|
|
153
178
|
data-slot="dialog-description"
|
|
154
179
|
className={cn("text-muted-foreground text-sm", className)}
|
|
155
180
|
{...props}
|
|
156
181
|
/>
|
|
157
182
|
);
|
|
158
|
-
}
|
|
183
|
+
});
|
|
159
184
|
DialogDescription.displayName = displayNameDescription;
|
|
160
185
|
|
|
161
186
|
export {
|
package/dist/chunk-2VQY25ZS.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import*as a from"@radix-ui/react-dialog";import{XIcon as R}from"lucide-react";import{cn as l,DefaultComponent as n,useStackShiftUIComponents as s}from"@stackshift-ui/system";import{jsx as e,jsxs as r}from"react/jsx-runtime";var d="Dialog",m="DialogTrigger",p="DialogPortal",g="DialogClose",c="DialogOverlay",f="DialogContent",u="DialogHeader",D="DialogFooter",y="DialogTitle",C="DialogDescription";function b({...o}){let{[d]:t=n}=s();return e(t,{as:a.Root,"data-slot":"dialog",...o})}b.displayName=d;function T({...o}){let{[m]:t=n}=s();return e(t,{as:a.Trigger,"data-slot":"dialog-trigger",...o})}T.displayName=m;function P({...o}){let{[p]:t=n}=s();return e(t,{as:a.Portal,"data-slot":"dialog-portal",...o})}P.displayName=p;function h({...o}){let{[g]:t=n}=s();return e(t,{as:a.Close,"data-slot":"dialog-close",...o})}h.displayName=g;function v({className:o,...t}){let{[c]:i=n}=s();return e(i,{as:a.Overlay,"data-slot":"dialog-overlay",className:l("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",o),...t})}v.displayName=c;function w({className:o,children:t,showCloseButton:i=!0,...N}){let{[f]:x=n}=s();return r(P,{"data-slot":"dialog-portal",children:[e(v,{}),r(x,{as:a.Content,"data-slot":"dialog-content",className:l("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",o),...N,children:[t,i&&r(a.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground 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 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[e(R,{}),e("span",{className:"sr-only",children:"Close"})]})]})]})}w.displayName=f;function z({className:o,...t}){let{[u]:i=n}=s();return e(i,{"data-slot":"dialog-header",className:l("flex flex-col gap-2 text-center sm:text-left",o),...t})}z.displayName=u;function k({className:o,...t}){let{[D]:i=n}=s();return e(i,{"data-slot":"dialog-footer",className:l("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",o),...t})}k.displayName=D;function O({className:o,...t}){let{[y]:i=n}=s();return e(i,{as:a.Title,"data-slot":"dialog-title",className:l("text-lg leading-none font-semibold",o),...t})}O.displayName=y;function F({className:o,...t}){let{[C]:i=n}=s();return e(i,{as:a.Description,"data-slot":"dialog-description",className:l("text-muted-foreground text-sm",o),...t})}F.displayName=C;export{b as a,T as b,P as c,h as d,v as e,w as f,z as g,k as h,O as i,F as j};
|