@stackshift-ui/textarea 6.0.12 → 7.0.0-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.
- package/dist/chunk-OMMSNDVN.mjs +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/textarea.d.ts +3 -19
- package/dist/textarea.js +1 -1
- package/dist/textarea.mjs +1 -1
- package/package.json +4 -4
- package/src/textarea.test.tsx +23 -3
- package/src/textarea.tsx +17 -71
- package/dist/chunk-GNX4DKIE.mjs +0 -1
|
@@ -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 f}from"react/jsx-runtime";var o="Textarea",l=e.forwardRef(({className:t,...r},a)=>{let{[o]:n=i}=d();return f(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:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:a,...r})});l.displayName=o;export{l as a};
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var m=Object.create;var s=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var g=(e,o)=>{for(var t in o)s(e,t,{get:o[t],enumerable:!0})},i=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of u(o))!x.call(e,a)&&a!==t&&s(e,a,{get:()=>o[a],enumerable:!(n=p(o,a))||n.enumerable});return e};var v=(e,o,t)=>(t=e!=null?m(b(e)):{},i(o||!e||!e.__esModule?s(t,"default",{value:e,enumerable:!0}):t,e)),y=e=>i(s({},"__esModule",{value:!0}),e);var C={};g(C,{Textarea:()=>f});module.exports=y(C);var l=v(require("react")),r=require("@stackshift-ui/system"),c=require("react/jsx-runtime"),d="Textarea",f=l.forwardRef(({className:e,...o},t)=>{let{[d]:n=r.DefaultComponent}=(0,r.useStackShiftUIComponents)();return(0,c.jsx)(n,{as:"textarea",className:(0,r.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:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:t,...o})});f.displayName=d;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-
|
|
2
|
+
"use strict";import{a as e}from"./chunk-OMMSNDVN.mjs";export{e as Textarea};
|
package/dist/textarea.d.ts
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export
|
|
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
|
|
1
|
+
"use strict";var m=Object.create;var s=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var g=(e,o)=>{for(var t in o)s(e,t,{get:o[t],enumerable:!0})},i=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of u(o))!x.call(e,a)&&a!==t&&s(e,a,{get:()=>o[a],enumerable:!(n=p(o,a))||n.enumerable});return e};var v=(e,o,t)=>(t=e!=null?m(b(e)):{},i(o||!e||!e.__esModule?s(t,"default",{value:e,enumerable:!0}):t,e)),y=e=>i(s({},"__esModule",{value:!0}),e);var C={};g(C,{Textarea:()=>f});module.exports=y(C);var d=v(require("react")),r=require("@stackshift-ui/system"),c=require("react/jsx-runtime"),l="Textarea",f=d.forwardRef(({className:e,...o},t)=>{let{[l]:n=r.DefaultComponent}=(0,r.useStackShiftUIComponents)();return(0,c.jsx)(n,{as:"textarea",className:(0,r.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:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:t,...o})});f.displayName=l;0&&(module.exports={Textarea});
|
package/dist/textarea.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-OMMSNDVN.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": "
|
|
4
|
+
"version": "7.0.0-beta.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"classnames": "^2.5.1",
|
|
37
|
-
"@stackshift-ui/
|
|
38
|
-
"@stackshift-ui/
|
|
37
|
+
"@stackshift-ui/scripts": "6.1.0-beta.0",
|
|
38
|
+
"@stackshift-ui/system": "6.1.0-beta.1"
|
|
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.
|
|
45
|
+
"@stackshift-ui/system": ">=6.1.0-beta.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependenciesMeta": {
|
|
48
48
|
"next": {
|
package/src/textarea.test.tsx
CHANGED
|
@@ -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(
|
|
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}
|
|
11
|
-
|
|
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
|
|
2
|
-
import cn from "classnames";
|
|
3
|
-
import type { ElementType, HTMLProps, ReactNode } from "react";
|
|
1
|
+
import * as React from "react";
|
|
4
2
|
|
|
5
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
57
|
-
<>
|
|
58
|
-
{!noLabel && (
|
|
59
|
-
<label htmlFor={name} className={labelClass}>
|
|
60
|
-
{label || name}
|
|
61
|
-
</label>
|
|
62
|
-
)}
|
|
11
|
+
return (
|
|
63
12
|
<Component
|
|
64
|
-
as=
|
|
65
|
-
{
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 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 };
|
package/dist/chunk-GNX4DKIE.mjs
DELETED
|
@@ -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};
|