@stackshift-ui/button 6.1.0-beta.3 → 7.0.0-beta.6
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/package.json +4 -4
- package/src/button.tsx +60 -10
- package/dist/button.d.ts +0 -11
- package/dist/button.js +0 -1
- package/dist/button.mjs +0 -1
- package/dist/chunk-UMCCY4XB.mjs +0 -1
- package/dist/helper/index.d.ts +0 -2
- package/dist/helper/index.js +0 -1
- package/dist/helper/index.mjs +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -2
- package/dist/index.mjs +0 -2
- package/dist/types.d.ts +0 -14
- package/dist/types.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackshift-ui/button",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-beta.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"class-variance-authority": "^0.7.1",
|
|
36
36
|
"classnames": "^2.5.1",
|
|
37
37
|
"react-icons": "^5.3.0",
|
|
38
|
-
"@stackshift-ui/system": "
|
|
39
|
-
"@stackshift-ui/
|
|
40
|
-
"@stackshift-ui/
|
|
38
|
+
"@stackshift-ui/system": "7.0.0-beta.4",
|
|
39
|
+
"@stackshift-ui/scripts": "7.0.0-beta.3",
|
|
40
|
+
"@stackshift-ui/link": "7.0.0-beta.4"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@types/react": "16.8 - 19",
|
package/src/button.tsx
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { Slot } from "@radix-ui/react-slot";
|
|
2
|
+
import { Link } from "@stackshift-ui/link";
|
|
3
|
+
import {
|
|
4
|
+
buildSanityLink,
|
|
5
|
+
cn,
|
|
6
|
+
DefaultComponent,
|
|
7
|
+
useStackShiftUIComponents,
|
|
8
|
+
} from "@stackshift-ui/system";
|
|
2
9
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
10
|
import * as React from "react";
|
|
4
|
-
|
|
5
|
-
import { cn, DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
|
|
11
|
+
import { LabeledRoute } from "./types";
|
|
6
12
|
|
|
7
13
|
const displayName = "Button";
|
|
8
14
|
|
|
@@ -34,25 +40,69 @@ const buttonVariants = cva(
|
|
|
34
40
|
},
|
|
35
41
|
);
|
|
36
42
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
type BaseButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> &
|
|
44
|
+
VariantProps<typeof buttonVariants> & {
|
|
45
|
+
asChild?: boolean;
|
|
46
|
+
iconPosition?: "left" | "right";
|
|
47
|
+
icon?: React.ReactNode;
|
|
48
|
+
className?: string;
|
|
49
|
+
children?: React.ReactNode;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type LinkButtonProps = BaseButtonProps & {
|
|
53
|
+
as: "link";
|
|
54
|
+
link: LabeledRoute;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
type DefaultButtonProps = BaseButtonProps & {
|
|
58
|
+
as?: undefined;
|
|
59
|
+
link?: never;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export type ButtonProps = LinkButtonProps | DefaultButtonProps;
|
|
42
63
|
|
|
43
64
|
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
44
|
-
(
|
|
65
|
+
(
|
|
66
|
+
{ className, variant, size, asChild = false, iconPosition = "right", icon, children, ...props },
|
|
67
|
+
ref,
|
|
68
|
+
) => {
|
|
45
69
|
const { [displayName]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
46
70
|
|
|
47
71
|
const Comp = asChild ? Slot : "button";
|
|
48
72
|
|
|
73
|
+
if (props.as === "link") {
|
|
74
|
+
const { link, ...rest } = props as ButtonProps;
|
|
75
|
+
const anchorProps = rest as React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
76
|
+
|
|
77
|
+
if (!link) return;
|
|
78
|
+
|
|
79
|
+
const processedLink = buildSanityLink(link);
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<Link
|
|
83
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
84
|
+
aria-label={link.ariaLabel}
|
|
85
|
+
href={processedLink.href}
|
|
86
|
+
target={processedLink.target}
|
|
87
|
+
rel={processedLink.rel}
|
|
88
|
+
{...anchorProps}>
|
|
89
|
+
{children}
|
|
90
|
+
</Link>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
49
94
|
return (
|
|
50
95
|
<Component
|
|
51
96
|
as={Comp}
|
|
52
97
|
className={cn(buttonVariants({ variant, size, className }))}
|
|
53
98
|
ref={ref}
|
|
54
|
-
{...props}
|
|
55
|
-
|
|
99
|
+
{...props}>
|
|
100
|
+
<span className="flex items-center gap-2">
|
|
101
|
+
{iconPosition === "left" && icon && <span>{icon}</span>}
|
|
102
|
+
{children}
|
|
103
|
+
{iconPosition === "right" && icon && <span>{icon}</span>}
|
|
104
|
+
</span>
|
|
105
|
+
</Component>
|
|
56
106
|
);
|
|
57
107
|
},
|
|
58
108
|
);
|
package/dist/button.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type VariantProps } from "class-variance-authority";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
declare const buttonVariants: (props?: ({
|
|
4
|
-
variant?: "unstyled" | "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
|
|
5
|
-
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
6
|
-
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
-
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
8
|
-
asChild?: boolean;
|
|
9
|
-
}
|
|
10
|
-
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
11
|
-
export { Button, buttonVariants };
|
package/dist/button.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var v=Object.create;var s=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var n in t)s(e,n,{get:t[n],enumerable:!0})},a=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of y(t))!B.call(e,o)&&o!==n&&s(e,o,{get:()=>t[o],enumerable:!(i=h(t,o))||i.enumerable});return e};var k=(e,t,n)=>(n=e!=null?v(x(e)):{},a(t||!e||!e.__esModule?s(n,"default",{value:e,enumerable:!0}):n,e)),w=e=>a(s({},"__esModule",{value:!0}),e);var V={};C(V,{Button:()=>l,buttonVariants:()=>f});module.exports=w(V);var d=require("@radix-ui/react-slot"),u=require("class-variance-authority"),c=k(require("react")),r=require("@stackshift-ui/system"),g=require("react/jsx-runtime"),p="Button",f=(0,u.cva)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{unstyled:"bg-transparent p-0 border-none shadow-none hover:bg-transparent ring-0 outline-none text-inherit",default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),l=c.forwardRef(({className:e,variant:t,size:n,asChild:i=!1,...o},m)=>{let{[p]:b=r.DefaultComponent}=(0,r.useStackShiftUIComponents)();return(0,g.jsx)(b,{as:i?d.Slot:"button",className:(0,r.cn)(f({variant:t,size:n,className:e})),ref:m,...o})});l.displayName=p;0&&(module.exports={Button,buttonVariants});
|
package/dist/button.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-UMCCY4XB.mjs";export{b as Button,a as buttonVariants};
|
package/dist/chunk-UMCCY4XB.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Slot as u}from"@radix-ui/react-slot";import{cva as c}from"class-variance-authority";import*as e from"react";import{cn as p,DefaultComponent as f,useStackShiftUIComponents as l}from"@stackshift-ui/system";import{jsx as b}from"react/jsx-runtime";var t="Button",g=c("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{unstyled:"bg-transparent p-0 border-none shadow-none hover:bg-transparent ring-0 outline-none text-inherit",default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),m=e.forwardRef(({className:n,variant:o,size:r,asChild:i=!1,...s},a)=>{let{[t]:d=f}=l();return b(d,{as:i?u:"button",className:p(g({variant:o,size:r,className:n})),ref:a,...s})});m.displayName=t;export{g as a,m as b};
|
package/dist/helper/index.d.ts
DELETED
package/dist/helper/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var x=(e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})},d=(e,t,r,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of f(t))!p.call(e,a)&&a!==r&&o(e,a,{get:()=>t[a],enumerable:!(u=L(t,a))||u.enumerable});return e};var c=e=>d(o({},"__esModule",{value:!0}),e);var s={};x(s,{extractLink:()=>m});module.exports=c(s);var m=e=>{var t,r;return!(e!=null&&e.internalLink)&&!(e!=null&&e.externalLink)?"/page-not-found":(e==null?void 0:e.type)==="linkInternal"&&((r=(t=e==null?void 0:e.internalLink)==null?void 0:t.toLowerCase())!=null&&r.includes("home"))?"/":(e==null?void 0:e.type)==="linkInternal"?`/${e==null?void 0:e.internalLink}`:(e==null?void 0:e.type)==="linkExternal"?`${e==null?void 0:e.externalLink}`:"/"};0&&(module.exports={extractLink});
|
package/dist/helper/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var a=e=>{var t,r;return!(e!=null&&e.internalLink)&&!(e!=null&&e.externalLink)?"/page-not-found":(e==null?void 0:e.type)==="linkInternal"&&((r=(t=e==null?void 0:e.internalLink)==null?void 0:t.toLowerCase())!=null&&r.includes("home"))?"/":(e==null?void 0:e.type)==="linkInternal"?`/${e==null?void 0:e.internalLink}`:(e==null?void 0:e.type)==="linkExternal"?`${e==null?void 0:e.externalLink}`:"/"};export{a as extractLink};
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./button";
|
package/dist/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";var v=Object.create;var s=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var o in t)s(e,o,{get:t[o],enumerable:!0})},a=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of y(t))!B.call(e,n)&&n!==o&&s(e,n,{get:()=>t[n],enumerable:!(i=h(t,n))||i.enumerable});return e};var k=(e,t,o)=>(o=e!=null?v(x(e)):{},a(t||!e||!e.__esModule?s(o,"default",{value:e,enumerable:!0}):o,e)),w=e=>a(s({},"__esModule",{value:!0}),e);var V={};C(V,{Button:()=>l,buttonVariants:()=>f});module.exports=w(V);var d=require("@radix-ui/react-slot"),u=require("class-variance-authority"),c=k(require("react")),r=require("@stackshift-ui/system"),g=require("react/jsx-runtime"),p="Button",f=(0,u.cva)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{unstyled:"bg-transparent p-0 border-none shadow-none hover:bg-transparent ring-0 outline-none text-inherit",default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),l=c.forwardRef(({className:e,variant:t,size:o,asChild:i=!1,...n},m)=>{let{[p]:b=r.DefaultComponent}=(0,r.useStackShiftUIComponents)();return(0,g.jsx)(b,{as:i?d.Slot:"button",className:(0,r.cn)(f({variant:t,size:o,className:e})),ref:m,...n})});l.displayName=p;0&&(module.exports={Button,buttonVariants});
|
package/dist/index.mjs
DELETED
package/dist/types.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type StyleVariants<T extends string> = Record<T, string>;
|
|
2
|
-
export interface LabeledRoute extends ConditionalLink {
|
|
3
|
-
ariaLabel?: string;
|
|
4
|
-
label?: string;
|
|
5
|
-
linkTarget?: string;
|
|
6
|
-
linkType?: string;
|
|
7
|
-
_type?: string;
|
|
8
|
-
linkInternal?: any;
|
|
9
|
-
}
|
|
10
|
-
export interface ConditionalLink {
|
|
11
|
-
type?: string;
|
|
12
|
-
internalLink?: string | null;
|
|
13
|
-
externalLink?: string | null;
|
|
14
|
-
}
|
package/dist/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var r=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var o=(t,n,l,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of s(n))!g.call(t,e)&&e!==l&&r(t,e,{get:()=>n[e],enumerable:!(i=a(n,e))||i.enumerable});return t};var k=t=>o(r({},"__esModule",{value:!0}),t);var p={};module.exports=k(p);
|