@stackshift-ui/stats-card 6.0.2 → 6.0.4-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 @@
1
+ import{DefaultComponent as u,useStackShiftUIComponents as N}from"@stackshift-ui/system";import{Text as b}from"@stackshift-ui/text";import k from"classnames";import{jsx as e,jsxs as m}from"react/jsx-runtime";var s="StatsCard",h=({variant:n="inline",icon:a,value:d,label:p,alt:t,children:v,className:C,as:g,...y})=>{var c,l;let{[s]:f=u}=N(),i="w-full px-4",o={inline:`${i} flex items-center`,stacked:`${i} block`},r={inline:"inline-block p-4 mr-4 rounded bg-secondary/50",stacked:"inline-block p-4 mx-auto rounded bg-secondary/50"},x=(c=o[n])!=null?c:o.inline,T=(l=r[n])!=null?l:r.inline;return m(f,{as:g,className:k(x,C),...y,"data-testid":s,children:[a&&e("div",{className:T,children:e("img",{src:a,width:24,height:24,alt:t!=null?t:"statistics-icon"})}),m("div",{children:[e("p",{className:"text-2xl text-gray-500 font-bold",children:d}),e(b,{muted:!0,children:p})]})]})};h.displayName=s;export{h as a};
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";var v=Object.create;var i=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var L=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},f=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of P(t))!H.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(o=S(t,s))||o.enumerable});return e};var M=(e,t,n)=>(n=e!=null?v(E(e)):{},f(t||!e||!e.__esModule?i(n,"default",{value:e,enumerable:!0}):n,e)),R=e=>f(i({},"__esModule",{value:!0}),e);var V={};L(V,{StatsCard:()=>x});module.exports=R(V);var r=require("@stackshift-ui/system"),C=require("@stackshift-ui/text"),u=M(require("classnames")),a=require("react/jsx-runtime"),c="StatsCard",x=({variant:e="inline",icon:t,value:n,label:o,alt:s,children:w,className:y,as:T,...N})=>{var p,g;let{[c]:b=r.DefaultComponent}=(0,r.useStackShiftUIComponents)(),l="w-full px-4",d={inline:`${l} flex items-center`,stacked:`${l} block`},m={inline:"inline-block p-4 mr-4 rounded bg-secondary-foreground",stacked:"inline-block p-4 mx-auto rounded bg-secondary-foreground"},k=(p=d[e])!=null?p:d.inline,h=(g=m[e])!=null?g:m.inline;return(0,a.jsxs)(b,{as:T,className:(0,u.default)(k,y),...N,"data-testid":c,children:[t&&(0,a.jsx)("div",{className:h,children:(0,a.jsx)("img",{src:t,width:24,height:24,alt:s!=null?s:"statistics-icon"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-2xl text-gray-500 font-bold",children:n}),(0,a.jsx)(C.Text,{muted:!0,children:o})]})]})};x.displayName=c;0&&(module.exports={StatsCard});
2
+ "use strict";var v=Object.create;var o=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var L=(e,t)=>{for(var s in t)o(e,s,{get:t[s],enumerable:!0})},g=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of P(t))!H.call(e,n)&&n!==s&&o(e,n,{get:()=>t[n],enumerable:!(i=S(t,n))||i.enumerable});return e};var M=(e,t,s)=>(s=e!=null?v(E(e)):{},g(t||!e||!e.__esModule?o(s,"default",{value:e,enumerable:!0}):s,e)),R=e=>g(o({},"__esModule",{value:!0}),e);var V={};L(V,{StatsCard:()=>y});module.exports=R(V);var r=require("@stackshift-ui/system"),f=require("@stackshift-ui/text"),x=M(require("classnames")),a=require("react/jsx-runtime"),c="StatsCard",y=({variant:e="inline",icon:t,value:s,label:i,alt:n,children:w,className:u,as:T,...N})=>{var p,C;let{[c]:b=r.DefaultComponent}=(0,r.useStackShiftUIComponents)(),l="w-full px-4",m={inline:`${l} flex items-center`,stacked:`${l} block`},d={inline:"inline-block p-4 mr-4 rounded bg-secondary/50",stacked:"inline-block p-4 mx-auto rounded bg-secondary/50"},k=(p=m[e])!=null?p:m.inline,h=(C=d[e])!=null?C:d.inline;return(0,a.jsxs)(b,{as:T,className:(0,x.default)(k,u),...N,"data-testid":c,children:[t&&(0,a.jsx)("div",{className:h,children:(0,a.jsx)("img",{src:t,width:24,height:24,alt:n!=null?n:"statistics-icon"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-2xl text-gray-500 font-bold",children:s}),(0,a.jsx)(f.Text,{muted:!0,children:i})]})]})};y.displayName=c;0&&(module.exports={StatsCard});
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";import{a as e}from"./chunk-4YF2WLQ3.mjs";export{e as StatsCard};
2
+ "use strict";import{a as e}from"./chunk-PPE2N5CX.mjs";export{e as StatsCard};
@@ -1 +1 @@
1
- "use strict";var v=Object.create;var o=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var L=(e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0})},C=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of P(t))!H.call(e,s)&&s!==n&&o(e,s,{get:()=>t[s],enumerable:!(i=S(t,s))||i.enumerable});return e};var M=(e,t,n)=>(n=e!=null?v(E(e)):{},C(t||!e||!e.__esModule?o(n,"default",{value:e,enumerable:!0}):n,e)),R=e=>C(o({},"__esModule",{value:!0}),e);var V={};L(V,{StatsCard:()=>u});module.exports=R(V);var r=require("@stackshift-ui/system"),f=require("@stackshift-ui/text"),y=M(require("classnames")),a=require("react/jsx-runtime"),c="StatsCard",u=({variant:e="inline",icon:t,value:n,label:i,alt:s,children:w,className:x,as:T,...N})=>{var p,g;let{[c]:b=r.DefaultComponent}=(0,r.useStackShiftUIComponents)(),l="w-full px-4",d={inline:`${l} flex items-center`,stacked:`${l} block`},m={inline:"inline-block p-4 mr-4 rounded bg-secondary-foreground",stacked:"inline-block p-4 mx-auto rounded bg-secondary-foreground"},k=(p=d[e])!=null?p:d.inline,h=(g=m[e])!=null?g:m.inline;return(0,a.jsxs)(b,{as:T,className:(0,y.default)(k,x),...N,"data-testid":c,children:[t&&(0,a.jsx)("div",{className:h,children:(0,a.jsx)("img",{src:t,width:24,height:24,alt:s!=null?s:"statistics-icon"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-2xl text-gray-500 font-bold",children:n}),(0,a.jsx)(f.Text,{muted:!0,children:i})]})]})};u.displayName=c;0&&(module.exports={StatsCard});
1
+ "use strict";var v=Object.create;var o=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var L=(e,t)=>{for(var s in t)o(e,s,{get:t[s],enumerable:!0})},g=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of P(t))!H.call(e,n)&&n!==s&&o(e,n,{get:()=>t[n],enumerable:!(i=S(t,n))||i.enumerable});return e};var M=(e,t,s)=>(s=e!=null?v(E(e)):{},g(t||!e||!e.__esModule?o(s,"default",{value:e,enumerable:!0}):s,e)),R=e=>g(o({},"__esModule",{value:!0}),e);var V={};L(V,{StatsCard:()=>x});module.exports=R(V);var r=require("@stackshift-ui/system"),y=require("@stackshift-ui/text"),f=M(require("classnames")),a=require("react/jsx-runtime"),c="StatsCard",x=({variant:e="inline",icon:t,value:s,label:i,alt:n,children:w,className:T,as:u,...N})=>{var p,C;let{[c]:b=r.DefaultComponent}=(0,r.useStackShiftUIComponents)(),l="w-full px-4",m={inline:`${l} flex items-center`,stacked:`${l} block`},d={inline:"inline-block p-4 mr-4 rounded bg-secondary/50",stacked:"inline-block p-4 mx-auto rounded bg-secondary/50"},k=(p=m[e])!=null?p:m.inline,h=(C=d[e])!=null?C:d.inline;return(0,a.jsxs)(b,{as:u,className:(0,f.default)(k,T),...N,"data-testid":c,children:[t&&(0,a.jsx)("div",{className:h,children:(0,a.jsx)("img",{src:t,width:24,height:24,alt:n!=null?n:"statistics-icon"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-2xl text-gray-500 font-bold",children:s}),(0,a.jsx)(y.Text,{muted:!0,children:i})]})]})};x.displayName=c;0&&(module.exports={StatsCard});
@@ -1 +1 @@
1
- import{a}from"./chunk-4YF2WLQ3.mjs";export{a as StatsCard};
1
+ import{a}from"./chunk-PPE2N5CX.mjs";export{a as StatsCard};
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@stackshift-ui/stats-card",
3
3
  "description": "",
4
- "version": "6.0.2",
4
+ "version": "6.0.4-beta.1",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "main": "./dist/index.js",
8
8
  "module": "./dist/index.mjs",
9
9
  "types": "./dist/index.d.ts",
10
10
  "files": [
11
- "dist/**"
11
+ "dist/**",
12
+ "src"
12
13
  ],
13
14
  "author": "WebriQ <info@webriq.com>",
14
15
  "devDependencies": {
@@ -28,14 +29,14 @@
28
29
  "typescript": "^5.6.2",
29
30
  "vite-tsconfig-paths": "^5.0.1",
30
31
  "vitest": "^2.1.1",
31
- "@stackshift-ui/eslint-config": "6.0.2",
32
- "@stackshift-ui/typescript-config": "6.0.2"
32
+ "@stackshift-ui/typescript-config": "6.0.2",
33
+ "@stackshift-ui/eslint-config": "6.0.2"
33
34
  },
34
35
  "dependencies": {
35
36
  "classnames": "^2.5.1",
36
37
  "@stackshift-ui/scripts": "6.0.2",
37
- "@stackshift-ui/system": "6.0.2",
38
- "@stackshift-ui/text": "6.0.2"
38
+ "@stackshift-ui/text": "6.0.3",
39
+ "@stackshift-ui/system": "6.0.3"
39
40
  },
40
41
  "peerDependencies": {
41
42
  "@types/react": "16.8 - 19",
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ "use client";
2
+
3
+ // component exports
4
+ export * from "./stats-card";
@@ -0,0 +1,19 @@
1
+ import { cleanup, render, screen } from "@testing-library/react";
2
+ import { afterEach, describe, test } from "vitest";
3
+ import { StatsCard } from "./stats-card";
4
+
5
+ const ARGS = {
6
+ LABEL: "Total Revenue",
7
+ VALUE: "$33,261",
8
+ ICON: "https://cdn.sanity.io/images/9itgab5x/staging/97b6696849c90facc200537fd780b03d373e5212-980x830.png",
9
+ };
10
+
11
+ describe.concurrent("stats-card", () => {
12
+ afterEach(cleanup);
13
+
14
+ test("Common: Stats Card - test if renders without errors", ({ expect }) => {
15
+ const clx = "statscard-class";
16
+ render(<StatsCard className={clx} icon={ARGS.ICON} value={ARGS.VALUE} label={ARGS.LABEL} />);
17
+ expect(screen.getByTestId("div").classList).toContain(clx);
18
+ });
19
+ });
@@ -0,0 +1,63 @@
1
+ import { DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
2
+ import { Text } from "@stackshift-ui/text";
3
+ import cn from "classnames";
4
+ import type { ElementType, HTMLProps, ReactNode } from "react";
5
+
6
+ type VariantType = "inline" | "stacked";
7
+
8
+ export interface StatsCardProps extends Omit<HTMLProps<HTMLElement>, "as"> {
9
+ variant?: VariantType;
10
+ icon: string;
11
+ value: string;
12
+ label: string;
13
+ alt?: string;
14
+ children?: ReactNode;
15
+ className?: string;
16
+ as?: ElementType;
17
+ }
18
+
19
+ const displayName = "StatsCard";
20
+
21
+ export const StatsCard: React.FC<StatsCardProps> = ({
22
+ variant = "inline",
23
+ icon,
24
+ value,
25
+ label,
26
+ alt,
27
+ children,
28
+ className,
29
+ as,
30
+ ...props
31
+ }) => {
32
+ const { [displayName]: Component = DefaultComponent } = useStackShiftUIComponents();
33
+
34
+ const commonClass = `w-full px-4`;
35
+ const variantClass = {
36
+ inline: `${commonClass} flex items-center`,
37
+ stacked: `${commonClass} block`,
38
+ };
39
+
40
+ const imageVariantClass = {
41
+ inline: `inline-block p-4 mr-4 rounded bg-secondary/50`,
42
+ stacked: `inline-block p-4 mx-auto rounded bg-secondary/50`,
43
+ };
44
+
45
+ const classes = variantClass[variant] ?? variantClass["inline"];
46
+ const imageClasses = imageVariantClass[variant] ?? imageVariantClass["inline"];
47
+
48
+ return (
49
+ <Component as={as} className={cn(classes, className)} {...props} data-testid={displayName}>
50
+ {icon && (
51
+ <div className={imageClasses}>
52
+ <img src={icon} width={24} height={24} alt={alt ?? "statistics-icon"} />
53
+ </div>
54
+ )}
55
+ <div>
56
+ <p className="text-2xl text-gray-500 font-bold">{value}</p>
57
+ <Text muted>{label}</Text>
58
+ </div>
59
+ </Component>
60
+ );
61
+ };
62
+
63
+ StatsCard.displayName = displayName;
@@ -1 +0,0 @@
1
- import{DefaultComponent as T,useStackShiftUIComponents as N}from"@stackshift-ui/system";import{Text as b}from"@stackshift-ui/text";import k from"classnames";import{jsx as e,jsxs as d}from"react/jsx-runtime";var n="StatsCard",h=({variant:s="inline",icon:a,value:m,label:p,alt:t,children:v,className:g,as:C,...f})=>{var c,l;let{[n]:y=T}=N(),i="w-full px-4",o={inline:`${i} flex items-center`,stacked:`${i} block`},r={inline:"inline-block p-4 mr-4 rounded bg-secondary-foreground",stacked:"inline-block p-4 mx-auto rounded bg-secondary-foreground"},u=(c=o[s])!=null?c:o.inline,x=(l=r[s])!=null?l:r.inline;return d(y,{as:C,className:k(u,g),...f,"data-testid":n,children:[a&&e("div",{className:x,children:e("img",{src:a,width:24,height:24,alt:t!=null?t:"statistics-icon"})}),d("div",{children:[e("p",{className:"text-2xl text-gray-500 font-bold",children:m}),e(b,{muted:!0,children:p})]})]})};h.displayName=n;export{h as a};