@stackshift-ui/textarea 6.0.2 → 6.0.4-beta.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.
@@ -0,0 +1 @@
1
+ import{DefaultComponent as C,useStackShiftUIComponents as N}from"@stackshift-ui/system";import L from"classnames";import{Fragment as V,jsx as s,jsxs as v}from"react/jsx-runtime";var t="Textarea",S=({required:l=!1,name:e,ariaLabel:i,placeholder:c,onChange:p,labelClass:d,variant:m="primary",label:y,noLabel:g,children:P,className:b,as:T="textarea",...r})=>{var o;let{[t]:x=C}=N(),a="h-24 w-full resize rounded-global p-4 text-xs leading-none",n=`${a}`,h=`${a} p-4 outline-none`,u=`${a} py-3 border border-slate-300`,f=(o={primary:n,outline:u,secondary:h}[m])!=null?o:n;return v(V,{children:[!g&&s("label",{htmlFor:e,className:d,children:y||e}),s(x,{as:T,...r,"data-testid":t,onChange:p,"aria-label":i||e,className:L(f,b),placeholder:c,name:e,required:l,id:e,...r})]})};S.displayName=t;export{S as a};
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";var v=Object.create;var s=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var M=(a,e)=>{for(var t in e)s(a,t,{get:e[t],enumerable:!0})},y=(a,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of R(e))!H.call(a,r)&&r!==t&&s(a,r,{get:()=>e[r],enumerable:!(o=P(e,r))||o.enumerable});return a};var $=(a,e,t)=>(t=a!=null?v(E(a)):{},y(e||!a||!a.__esModule?s(t,"default",{value:a,enumerable:!0}):t,a)),k=a=>y(s({},"__esModule",{value:!0}),a);var q={};M(q,{Textarea:()=>x});module.exports=k(q);var l=require("@stackshift-ui/system"),g=$(require("classnames")),n=require("react/jsx-runtime"),c="Textarea",x=({required:a=!1,name:e,ariaLabel:t,placeholder:o,onChange:r,labelClass:T,variant:b="primary",label:u,noLabel:f,children:F,className:h,as:C="textarea",...p})=>{var m;let{[c]:N=l.DefaultComponent}=(0,l.useStackShiftUIComponents)(),i="h-24 w-full resize rounded p-4 text-xs leading-none",d=`${i}`,L=`${i} p-4 outline-none`,S=`${i} py-3 border border-slate-300`,V=(m={primary:d,outline:S,secondary:L}[b])!=null?m:d;return(0,n.jsxs)(n.Fragment,{children:[!f&&(0,n.jsx)("label",{htmlFor:e,className:T,children:u||e}),(0,n.jsx)(N,{as:C,...p,"data-testid":c,onChange:r,"aria-label":t||e,className:(0,g.default)(V,h),placeholder:o,name:e,required:a,id:e,...p})]})};x.displayName=c;0&&(module.exports={Textarea});
2
+ "use strict";var v=Object.create;var s=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var M=(a,e)=>{for(var t in e)s(a,t,{get:e[t],enumerable:!0})},y=(a,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of R(e))!H.call(a,r)&&r!==t&&s(a,r,{get:()=>e[r],enumerable:!(o=P(e,r))||o.enumerable});return a};var $=(a,e,t)=>(t=a!=null?v(E(a)):{},y(e||!a||!a.__esModule?s(t,"default",{value:a,enumerable:!0}):t,a)),k=a=>y(s({},"__esModule",{value:!0}),a);var q={};M(q,{Textarea:()=>b});module.exports=k(q);var l=require("@stackshift-ui/system"),g=$(require("classnames")),n=require("react/jsx-runtime"),c="Textarea",b=({required:a=!1,name:e,ariaLabel:t,placeholder:o,onChange:r,labelClass:x,variant:T="primary",label:u,noLabel:f,children:F,className:h,as:C="textarea",...p})=>{var m;let{[c]:N=l.DefaultComponent}=(0,l.useStackShiftUIComponents)(),i="h-24 w-full resize rounded-global p-4 text-xs leading-none",d=`${i}`,L=`${i} p-4 outline-none`,S=`${i} py-3 border border-slate-300`,V=(m={primary:d,outline:S,secondary:L}[T])!=null?m:d;return(0,n.jsxs)(n.Fragment,{children:[!f&&(0,n.jsx)("label",{htmlFor:e,className:x,children:u||e}),(0,n.jsx)(N,{as:C,...p,"data-testid":c,onChange:r,"aria-label":t||e,className:(0,g.default)(V,h),placeholder:o,name:e,required:a,id:e,...p})]})};b.displayName=c;0&&(module.exports={Textarea});
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";import{a as e}from"./chunk-I5S3MZFR.mjs";export{e as Textarea};
2
+ "use strict";import{a as e}from"./chunk-GNX4DKIE.mjs";export{e as Textarea};
package/dist/textarea.js CHANGED
@@ -1 +1 @@
1
- "use strict";var v=Object.create;var s=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var M=(a,e)=>{for(var t in e)s(a,t,{get:e[t],enumerable:!0})},y=(a,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of R(e))!H.call(a,r)&&r!==t&&s(a,r,{get:()=>e[r],enumerable:!(o=P(e,r))||o.enumerable});return a};var $=(a,e,t)=>(t=a!=null?v(E(a)):{},y(e||!a||!a.__esModule?s(t,"default",{value:a,enumerable:!0}):t,a)),k=a=>y(s({},"__esModule",{value:!0}),a);var q={};M(q,{Textarea:()=>T});module.exports=k(q);var l=require("@stackshift-ui/system"),g=$(require("classnames")),n=require("react/jsx-runtime"),c="Textarea",T=({required:a=!1,name:e,ariaLabel:t,placeholder:o,onChange:r,labelClass:b,variant:x="primary",label:h,noLabel:u,children:F,className:f,as:C="textarea",...p})=>{var m;let{[c]:N=l.DefaultComponent}=(0,l.useStackShiftUIComponents)(),i="h-24 w-full resize rounded p-4 text-xs leading-none",d=`${i}`,L=`${i} p-4 outline-none`,S=`${i} py-3 border border-slate-300`,V=(m={primary:d,outline:S,secondary:L}[x])!=null?m:d;return(0,n.jsxs)(n.Fragment,{children:[!u&&(0,n.jsx)("label",{htmlFor:e,className:b,children:h||e}),(0,n.jsx)(N,{as:C,...p,"data-testid":c,onChange:r,"aria-label":t||e,className:(0,g.default)(V,f),placeholder:o,name:e,required:a,id:e,...p})]})};T.displayName=c;0&&(module.exports={Textarea});
1
+ "use strict";var v=Object.create;var s=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var M=(a,e)=>{for(var t in e)s(a,t,{get:e[t],enumerable:!0})},y=(a,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of R(e))!H.call(a,r)&&r!==t&&s(a,r,{get:()=>e[r],enumerable:!(o=P(e,r))||o.enumerable});return a};var $=(a,e,t)=>(t=a!=null?v(E(a)):{},y(e||!a||!a.__esModule?s(t,"default",{value:a,enumerable:!0}):t,a)),k=a=>y(s({},"__esModule",{value:!0}),a);var q={};M(q,{Textarea:()=>b});module.exports=k(q);var l=require("@stackshift-ui/system"),g=$(require("classnames")),n=require("react/jsx-runtime"),c="Textarea",b=({required:a=!1,name:e,ariaLabel:t,placeholder:o,onChange:r,labelClass:T,variant:x="primary",label:h,noLabel:u,children:F,className:f,as:C="textarea",...p})=>{var m;let{[c]:N=l.DefaultComponent}=(0,l.useStackShiftUIComponents)(),i="h-24 w-full resize rounded-global p-4 text-xs leading-none",d=`${i}`,L=`${i} p-4 outline-none`,S=`${i} py-3 border border-slate-300`,V=(m={primary:d,outline:S,secondary:L}[x])!=null?m:d;return(0,n.jsxs)(n.Fragment,{children:[!u&&(0,n.jsx)("label",{htmlFor:e,className:T,children:h||e}),(0,n.jsx)(N,{as:C,...p,"data-testid":c,onChange:r,"aria-label":t||e,className:(0,g.default)(V,f),placeholder:o,name:e,required:a,id:e,...p})]})};b.displayName=c;0&&(module.exports={Textarea});
package/dist/textarea.mjs CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-I5S3MZFR.mjs";export{a as Textarea};
1
+ import{a}from"./chunk-GNX4DKIE.mjs";export{a as Textarea};
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@stackshift-ui/textarea",
3
3
  "description": "",
4
- "version": "6.0.2",
4
+ "version": "6.0.4-beta.0",
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,13 +29,13 @@
28
29
  "typescript": "^5.6.2",
29
30
  "vite-tsconfig-paths": "^5.0.1",
30
31
  "vitest": "^2.1.1",
31
- "@stackshift-ui/typescript-config": "6.0.2",
32
- "@stackshift-ui/eslint-config": "6.0.2"
32
+ "@stackshift-ui/eslint-config": "6.0.2",
33
+ "@stackshift-ui/typescript-config": "6.0.2"
33
34
  },
34
35
  "dependencies": {
35
36
  "classnames": "^2.5.1",
36
- "@stackshift-ui/system": "6.0.2",
37
- "@stackshift-ui/scripts": "6.0.2"
37
+ "@stackshift-ui/scripts": "6.0.2",
38
+ "@stackshift-ui/system": "6.0.3"
38
39
  },
39
40
  "peerDependencies": {
40
41
  "@types/react": "16.8 - 19",
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ "use client";
2
+
3
+ // component exports
4
+ export * from "./textarea";
@@ -0,0 +1,13 @@
1
+ import { cleanup, render, screen } from "@testing-library/react";
2
+ import { afterEach, describe, test } from "vitest";
3
+ import { Textarea } from "./textarea";
4
+
5
+ describe.concurrent("textarea", () => {
6
+ afterEach(cleanup);
7
+
8
+ test("Common: Textarea - test if renders without errors", ({ expect }) => {
9
+ const clx = "textarea-class";
10
+ render(<Textarea className={clx} name="stackshift-textarea" ariaLabel="text area" />);
11
+ expect(screen.getByTestId("textarea").classList).toContain(clx);
12
+ });
13
+ });
@@ -0,0 +1,80 @@
1
+ import { DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
2
+ import cn from "classnames";
3
+ import type { ElementType, HTMLProps, ReactNode } from "react";
4
+
5
+ type StyleVariants<T extends string> = Record<T, string>;
6
+ type Variant = "primary" | "outline" | "secondary";
7
+
8
+ export interface TextareaProps extends Omit<HTMLProps<HTMLTextAreaElement>, "as"> {
9
+ required?: boolean;
10
+ name: string;
11
+ ariaLabel: string;
12
+ placeholder?: string;
13
+ onChange?: (...args: any) => any;
14
+ labelClass?: string;
15
+ variant?: Variant;
16
+ label?: string;
17
+ noLabel?: boolean;
18
+ [key: string]: any;
19
+ children?: ReactNode;
20
+ className?: string;
21
+ as?: ElementType;
22
+ }
23
+
24
+ const displayName = "Textarea";
25
+
26
+ export const Textarea: React.FC<TextareaProps> = ({
27
+ required = false,
28
+ name,
29
+ ariaLabel,
30
+ placeholder,
31
+ onChange,
32
+ labelClass,
33
+ variant = "primary",
34
+ label,
35
+ noLabel,
36
+ children,
37
+ className,
38
+ as = "textarea",
39
+ ...props
40
+ }) => {
41
+ const { [displayName]: Component = DefaultComponent } = useStackShiftUIComponents();
42
+
43
+ const commonStyle = "h-24 w-full resize rounded-global p-4 text-xs leading-none";
44
+ const primary = `${commonStyle}`;
45
+ const secondary = `${commonStyle} p-4 outline-none`;
46
+ const outline = `${commonStyle} py-3 border border-slate-300`;
47
+
48
+ const variants: StyleVariants<Variant> = {
49
+ primary,
50
+ outline,
51
+ secondary,
52
+ };
53
+
54
+ const variantClass = variants[variant] ?? primary;
55
+
56
+ return (
57
+ <>
58
+ {!noLabel && (
59
+ <label htmlFor={name} className={labelClass}>
60
+ {label || name}
61
+ </label>
62
+ )}
63
+ <Component
64
+ as={as}
65
+ {...props}
66
+ data-testid={displayName}
67
+ onChange={onChange}
68
+ aria-label={ariaLabel || name}
69
+ className={cn(variantClass, className)}
70
+ placeholder={placeholder}
71
+ name={name}
72
+ required={required}
73
+ id={name}
74
+ {...props}
75
+ />
76
+ </>
77
+ );
78
+ };
79
+
80
+ Textarea.displayName = displayName;
@@ -1 +0,0 @@
1
- import{DefaultComponent as C,useStackShiftUIComponents as N}from"@stackshift-ui/system";import L from"classnames";import{Fragment as V,jsx as s,jsxs as v}from"react/jsx-runtime";var t="Textarea",S=({required:l=!1,name:e,ariaLabel:i,placeholder:c,onChange:p,labelClass:d,variant:m="primary",label:y,noLabel:g,children:P,className:T,as:b="textarea",...r})=>{var o;let{[t]:x=C}=N(),a="h-24 w-full resize rounded p-4 text-xs leading-none",n=`${a}`,h=`${a} p-4 outline-none`,u=`${a} py-3 border border-slate-300`,f=(o={primary:n,outline:u,secondary:h}[m])!=null?o:n;return v(V,{children:[!g&&s("label",{htmlFor:e,className:d,children:y||e}),s(x,{as:b,...r,"data-testid":t,onChange:p,"aria-label":i||e,className:L(f,T),placeholder:c,name:e,required:l,id:e,...r})]})};S.displayName=t;export{S as a};