@stackshift-ui/badge 6.0.11 → 6.1.0
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/badge.d.ts +11 -6
- package/dist/badge.js +1 -1
- package/dist/badge.mjs +1 -1
- package/dist/chunk-QPNE64XN.mjs +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +7 -6
- package/src/badge.test.tsx +29 -3
- package/src/badge.tsx +32 -20
- package/dist/chunk-53FTCUE2.mjs +0 -1
package/dist/badge.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { type VariantProps } from "class-variance-authority";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
declare const badgeVariants: (props?: ({
|
|
4
|
+
variant?: "default" | "secondary" | "destructive" | "outline" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
+
declare function Badge({ className, variant, ...props }: BadgeProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare namespace Badge {
|
|
10
|
+
var displayName: string;
|
|
11
|
+
}
|
|
12
|
+
export { Badge, badgeVariants };
|
package/dist/badge.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var l=(r,e)=>{for(var t in e)s(r,t,{get:e[t],enumerable:!0})},b=(r,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of g(e))!m.call(r,n)&&n!==t&&s(r,n,{get:()=>e[n],enumerable:!(a=u(e,n))||a.enumerable});return r};var v=r=>b(s({},"__esModule",{value:!0}),r);var y={};l(y,{Badge:()=>f,badgeVariants:()=>c});module.exports=v(y);var i=require("class-variance-authority"),o=require("@stackshift-ui/system"),p=require("react/jsx-runtime"),d="Badge",c=(0,i.cva)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function f({className:r,variant:e,...t}){let{[d]:a=o.DefaultComponent}=(0,o.useStackShiftUIComponents)();return(0,p.jsx)(a,{className:(0,o.cn)(c({variant:e}),r),...t})}f.displayName=d;0&&(module.exports={Badge,badgeVariants});
|
package/dist/badge.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a,b}from"./chunk-QPNE64XN.mjs";export{b as Badge,a as badgeVariants};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cva as a}from"class-variance-authority";import{cn as s,DefaultComponent as i,useStackShiftUIComponents as d}from"@stackshift-ui/system";import{jsx as p}from"react/jsx-runtime";var e="Badge",c=a("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function f({className:r,variant:t,...o}){let{[e]:n=i}=d();return p(n,{className:s(c({variant:t}),r),...o})}f.displayName=e;export{c as a,f as b};
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var s=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var l=(r,e)=>{for(var t in e)s(r,t,{get:e[t],enumerable:!0})},b=(r,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of g(e))!m.call(r,n)&&n!==t&&s(r,n,{get:()=>e[n],enumerable:!(a=u(e,n))||a.enumerable});return r};var v=r=>b(s({},"__esModule",{value:!0}),r);var y={};l(y,{Badge:()=>f,badgeVariants:()=>c});module.exports=v(y);var i=require("class-variance-authority"),o=require("@stackshift-ui/system"),p=require("react/jsx-runtime"),d="Badge",c=(0,i.cva)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function f({className:r,variant:e,...t}){let{[d]:a=o.DefaultComponent}=(0,o.useStackShiftUIComponents)();return(0,p.jsx)(a,{className:(0,o.cn)(c({variant:e}),r),...t})}f.displayName=d;0&&(module.exports={Badge,badgeVariants});
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";import{a as e}from"./chunk-
|
|
2
|
+
"use strict";import{a as e,b as o}from"./chunk-QPNE64XN.mjs";export{o as Badge,e as badgeVariants};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackshift-ui/badge",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "6.0
|
|
4
|
+
"version": "6.1.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -33,17 +33,18 @@
|
|
|
33
33
|
"@stackshift-ui/typescript-config": "6.0.10"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
+
"class-variance-authority": "^0.7.1",
|
|
36
37
|
"classnames": "^2.5.1",
|
|
37
|
-
"@stackshift-ui/
|
|
38
|
-
"@stackshift-ui/system": "6.0
|
|
39
|
-
"@stackshift-ui/
|
|
38
|
+
"@stackshift-ui/flex": "6.1.0",
|
|
39
|
+
"@stackshift-ui/system": "6.1.0",
|
|
40
|
+
"@stackshift-ui/scripts": "6.1.0"
|
|
40
41
|
},
|
|
41
42
|
"peerDependencies": {
|
|
43
|
+
"@stackshift-ui/system": ">=7.0.0",
|
|
42
44
|
"@types/react": "16.8 - 19",
|
|
43
45
|
"next": "10 - 14",
|
|
44
46
|
"react": "16.8 - 19",
|
|
45
|
-
"react-dom": "16.8 - 19"
|
|
46
|
-
"@stackshift-ui/system": ">=6.0.11"
|
|
47
|
+
"react-dom": "16.8 - 19"
|
|
47
48
|
},
|
|
48
49
|
"peerDependenciesMeta": {
|
|
49
50
|
"next": {
|
package/src/badge.test.tsx
CHANGED
|
@@ -6,12 +6,38 @@ describe.concurrent("badge", () => {
|
|
|
6
6
|
afterEach(cleanup);
|
|
7
7
|
|
|
8
8
|
test("Common: Badge - test if renders without errors", ({ expect }) => {
|
|
9
|
-
const
|
|
10
|
-
render(<Badge className={clx} />);
|
|
9
|
+
const { unmount } = render(<Badge data-testid="default-badge" />);
|
|
11
10
|
|
|
12
|
-
const elements = screen.getAllByTestId("
|
|
11
|
+
const elements = screen.getAllByTestId("default-badge");
|
|
13
12
|
elements.forEach(element => {
|
|
14
13
|
expect(element.classList).toBeDefined();
|
|
15
14
|
});
|
|
15
|
+
unmount();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("Common: Badge - test if renders with correct variant", ({ expect }) => {
|
|
19
|
+
const { unmount } = render(<Badge data-testid="badge-secondary" variant="secondary" />);
|
|
20
|
+
|
|
21
|
+
const elements = screen.getAllByTestId("badge-secondary");
|
|
22
|
+
elements.forEach(element => {
|
|
23
|
+
expect(element.classList).toContain("bg-secondary");
|
|
24
|
+
});
|
|
25
|
+
unmount();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("Common: Badge - test if renders with correct text", ({ expect }) => {
|
|
29
|
+
const { unmount } = render(
|
|
30
|
+
<>
|
|
31
|
+
<Badge data-testid="default-badge-2">Test</Badge>
|
|
32
|
+
<Badge data-testid="destructive-badge" variant="destructive">
|
|
33
|
+
Destructive
|
|
34
|
+
</Badge>
|
|
35
|
+
,
|
|
36
|
+
</>,
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
expect(screen.getByTestId("default-badge-2").textContent).toBe("Test");
|
|
40
|
+
expect(screen.getByTestId("destructive-badge").textContent).toBe("Destructive");
|
|
41
|
+
unmount();
|
|
16
42
|
});
|
|
17
43
|
});
|
package/src/badge.tsx
CHANGED
|
@@ -1,27 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import cn from "
|
|
5
|
-
|
|
6
|
-
export interface BadgeProps extends Omit<HTMLProps<HTMLElement>, "as"> {
|
|
7
|
-
children?: ReactNode;
|
|
8
|
-
className?: string;
|
|
9
|
-
as?: ElementType;
|
|
10
|
-
}
|
|
1
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { cn, DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
|
|
11
5
|
|
|
12
6
|
const displayName = "Badge";
|
|
13
7
|
|
|
14
|
-
|
|
8
|
+
const badgeVariants = cva(
|
|
9
|
+
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
10
|
+
{
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
default: "border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
|
|
14
|
+
secondary:
|
|
15
|
+
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
16
|
+
destructive:
|
|
17
|
+
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
|
|
18
|
+
outline: "text-foreground",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
defaultVariants: {
|
|
22
|
+
variant: "default",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export interface BadgeProps
|
|
28
|
+
extends React.HTMLAttributes<HTMLDivElement>,
|
|
29
|
+
VariantProps<typeof badgeVariants> {}
|
|
30
|
+
|
|
31
|
+
function Badge({ className, variant, ...props }: BadgeProps) {
|
|
15
32
|
const { [displayName]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
16
|
-
const defaultClass = "px-3 py-1 text-sm font-bold uppercase rounded-full";
|
|
17
33
|
|
|
18
|
-
return (
|
|
19
|
-
|
|
20
|
-
<Flex>
|
|
21
|
-
<div className={cn(defaultClass, className)}>{children}</div>
|
|
22
|
-
</Flex>
|
|
23
|
-
</Component>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
34
|
+
return <Component className={cn(badgeVariants({ variant }), className)} {...props} />;
|
|
35
|
+
}
|
|
26
36
|
|
|
27
37
|
Badge.displayName = displayName;
|
|
38
|
+
|
|
39
|
+
export { Badge, badgeVariants };
|
package/dist/chunk-53FTCUE2.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{DefaultComponent as n,useStackShiftUIComponents as m}from"@stackshift-ui/system";import{Flex as r}from"@stackshift-ui/flex";import d from"classnames";import{jsx as e}from"react/jsx-runtime";var t="Badge",l=({children:a,className:o,as:c,...s})=>{let{[t]:p=n}=m();return e(p,{className:o,...s,"data-testid":t,children:e(r,{children:e("div",{className:d("px-3 py-1 text-sm font-bold uppercase rounded-full",o),children:a})})})};l.displayName=t;export{l as a};
|