@stackshift-ui/textarea 6.0.12-beta.2 → 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.
@@ -0,0 +1 @@
1
+ import*as e from"react";import{cn as s,DefaultComponent as i,useStackShiftUIComponents as d}from"@stackshift-ui/system";import{jsx as p}from"react/jsx-runtime";var o="Textarea",l=e.forwardRef(({className:r,...t},a)=>{let{[o]:n=i}=d();return p(n,{as:"textarea",className:s("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:border-primary focus-visible:ring-primary/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",r),ref:a,...t})});l.displayName=o;export{l 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:()=>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});
2
+ "use strict";var c=Object.create;var s=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var g=(e,o)=>{for(var r in o)s(e,r,{get:o[r],enumerable:!0})},i=(e,o,r,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of u(o))!x.call(e,a)&&a!==r&&s(e,a,{get:()=>o[a],enumerable:!(n=f(o,a))||n.enumerable});return e};var y=(e,o,r)=>(r=e!=null?c(b(e)):{},i(o||!e||!e.__esModule?s(r,"default",{value:e,enumerable:!0}):r,e)),v=e=>i(s({},"__esModule",{value:!0}),e);var C={};g(C,{Textarea:()=>p});module.exports=v(C);var d=y(require("react")),t=require("@stackshift-ui/system"),m=require("react/jsx-runtime"),l="Textarea",p=d.forwardRef(({className:e,...o},r)=>{let{[l]:n=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,m.jsx)(n,{as:"textarea",className:(0,t.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:border-primary focus-visible:ring-primary/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...o})});p.displayName=l;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-GNX4DKIE.mjs";export{e as Textarea};
2
+ "use strict";import{a as e}from"./chunk-AE3A43CA.mjs";export{e as Textarea};
@@ -1,19 +1,3 @@
1
- import type { ElementType, HTMLProps, ReactNode } from "react";
2
- type Variant = "primary" | "outline" | "secondary";
3
- export interface TextareaProps extends Omit<HTMLProps<HTMLTextAreaElement>, "as"> {
4
- required?: boolean;
5
- name: string;
6
- ariaLabel: string;
7
- placeholder?: string;
8
- onChange?: (...args: any) => any;
9
- labelClass?: string;
10
- variant?: Variant;
11
- label?: string;
12
- noLabel?: boolean;
13
- [key: string]: any;
14
- children?: ReactNode;
15
- className?: string;
16
- as?: ElementType;
17
- }
18
- export declare const Textarea: React.FC<TextareaProps>;
19
- export {};
1
+ import * as React from "react";
2
+ declare const Textarea: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref"> & React.RefAttributes<HTMLTextAreaElement>>;
3
+ export { 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:()=>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});
1
+ "use strict";var c=Object.create;var s=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var g=(e,o)=>{for(var r in o)s(e,r,{get:o[r],enumerable:!0})},i=(e,o,r,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of u(o))!x.call(e,a)&&a!==r&&s(e,a,{get:()=>o[a],enumerable:!(n=f(o,a))||n.enumerable});return e};var y=(e,o,r)=>(r=e!=null?c(b(e)):{},i(o||!e||!e.__esModule?s(r,"default",{value:e,enumerable:!0}):r,e)),v=e=>i(s({},"__esModule",{value:!0}),e);var C={};g(C,{Textarea:()=>p});module.exports=v(C);var d=y(require("react")),t=require("@stackshift-ui/system"),m=require("react/jsx-runtime"),l="Textarea",p=d.forwardRef(({className:e,...o},r)=>{let{[l]:n=t.DefaultComponent}=(0,t.useStackShiftUIComponents)();return(0,m.jsx)(n,{as:"textarea",className:(0,t.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:border-primary focus-visible:ring-primary/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...o})});p.displayName=l;0&&(module.exports={Textarea});
package/dist/textarea.mjs CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-GNX4DKIE.mjs";export{a as Textarea};
1
+ import{a}from"./chunk-AE3A43CA.mjs";export{a as Textarea};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stackshift-ui/textarea",
3
3
  "description": "",
4
- "version": "6.0.12-beta.2",
4
+ "version": "6.1.0",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "main": "./dist/index.js",
@@ -29,20 +29,20 @@
29
29
  "typescript": "^5.6.2",
30
30
  "vite-tsconfig-paths": "^5.0.1",
31
31
  "vitest": "^2.1.1",
32
- "@stackshift-ui/typescript-config": "6.0.10-beta.2",
33
- "@stackshift-ui/eslint-config": "6.0.10-beta.2"
32
+ "@stackshift-ui/typescript-config": "6.0.10",
33
+ "@stackshift-ui/eslint-config": "6.0.10"
34
34
  },
35
35
  "dependencies": {
36
36
  "classnames": "^2.5.1",
37
- "@stackshift-ui/scripts": "6.0.10-beta.2",
38
- "@stackshift-ui/system": "6.0.11-beta.2"
37
+ "@stackshift-ui/scripts": "6.1.0",
38
+ "@stackshift-ui/system": "6.1.0"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@types/react": "16.8 - 19",
42
42
  "next": "10 - 14",
43
43
  "react": "16.8 - 19",
44
44
  "react-dom": "16.8 - 19",
45
- "@stackshift-ui/system": ">=6.0.11-beta.2"
45
+ "@stackshift-ui/system": ">=7.0.0"
46
46
  },
47
47
  "peerDependenciesMeta": {
48
48
  "next": {
@@ -3,11 +3,31 @@ import { afterEach, describe, test } from "vitest";
3
3
  import { Textarea } from "./textarea";
4
4
 
5
5
  describe.concurrent("textarea", () => {
6
- afterEach(cleanup);
6
+ afterEach(() => {
7
+ cleanup();
8
+ });
7
9
 
8
10
  test("Common: Textarea - test if renders without errors", ({ expect }) => {
9
11
  const clx = "textarea-class";
10
- render(<Textarea className={clx} name="stackshift-textarea" ariaLabel="text area" />);
11
- expect(screen.getByTestId("textarea").classList).toContain(clx);
12
+ const { unmount } = render(<Textarea className={clx} placeholder="Enter text here" />);
13
+ const textarea = screen.getByPlaceholderText("Enter text here");
14
+ expect(textarea.classList).toContain(clx);
15
+ expect(textarea.tagName.toLowerCase()).toBe("textarea");
16
+ unmount();
17
+ });
18
+
19
+ test("Common: Textarea - test with aria-label", ({ expect }) => {
20
+ const { unmount } = render(<Textarea aria-label="Text area input" />);
21
+ const textarea = screen.getByLabelText("Text area input");
22
+ expect(textarea.tagName.toLowerCase()).toBe("textarea");
23
+ unmount();
24
+ });
25
+
26
+ test("Common: Textarea - test with rows prop", ({ expect }) => {
27
+ const { unmount } = render(<Textarea placeholder="Test rows" rows={3} />);
28
+ const textarea = screen.getByPlaceholderText("Test rows");
29
+ screen.debug(textarea);
30
+ expect(textarea.getAttribute("rows")).toBe("3");
31
+ unmount();
12
32
  });
13
33
  });
package/src/textarea.tsx CHANGED
@@ -1,80 +1,26 @@
1
- import { DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
2
- import cn from "classnames";
3
- import type { ElementType, HTMLProps, ReactNode } from "react";
1
+ import * as React from "react";
4
2
 
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
- }
3
+ import { cn, DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
23
4
 
24
5
  const displayName = "Textarea";
25
6
 
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;
7
+ const Textarea = React.forwardRef<HTMLTextAreaElement, React.ComponentProps<"textarea">>(
8
+ ({ className, ...props }, ref) => {
9
+ const { [displayName]: Component = DefaultComponent } = useStackShiftUIComponents();
55
10
 
56
- return (
57
- <>
58
- {!noLabel && (
59
- <label htmlFor={name} className={labelClass}>
60
- {label || name}
61
- </label>
62
- )}
11
+ return (
63
12
  <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}
13
+ as="textarea"
14
+ className={cn(
15
+ "flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:border-primary focus-visible:ring-primary/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
16
+ className,
17
+ )}
18
+ ref={ref}
74
19
  {...props}
75
20
  />
76
- </>
77
- );
78
- };
79
-
21
+ );
22
+ },
23
+ );
80
24
  Textarea.displayName = displayName;
25
+
26
+ export { Textarea };
@@ -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: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};