@ladder-ui/textarea 0.2.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,2 @@
1
+ export { Textarea, type TextareaProps } from "./textarea";
2
+ export { Textarea as default } from "./textarea";
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var concatClassNames = require('@ladder-ui/core/concatClassNames');
7
+
8
+ function Textarea({ ref, className, size = "md", status = "default", fullWidth = true, resize = "vertical", autoResize = false, disabled, readOnly, onInput, style, ...props }) {
9
+ const ariaInvalid = props["aria-invalid"] ?? (status === "error" ? true : undefined);
10
+ return (jsxRuntime.jsx("textarea", { ref: ref, className: concatClassNames("lui-textarea", `lui-textarea--${size}`, status !== "default" && `lui-textarea--${status}`, !autoResize && resize !== "vertical" && `lui-textarea--resize-${resize}`, fullWidth && "lui-textarea--full-width", className), disabled: disabled, readOnly: readOnly, "aria-invalid": ariaInvalid, onInput: (e) => {
11
+ if (autoResize) {
12
+ e.currentTarget.style.height = "auto";
13
+ e.currentTarget.style.height = `${e.currentTarget.scrollHeight}px`;
14
+ }
15
+ onInput?.(e);
16
+ }, style: autoResize ? { overflow: "hidden", resize: "none", ...style } : style, ...props }));
17
+ }
18
+ Textarea.displayName = "Textarea";
19
+
20
+ exports.Textarea = Textarea;
21
+ exports.default = Textarea;
package/dist/index.mjs ADDED
@@ -0,0 +1,16 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import concatClassNames from '@ladder-ui/core/concatClassNames';
3
+
4
+ function Textarea({ ref, className, size = "md", status = "default", fullWidth = true, resize = "vertical", autoResize = false, disabled, readOnly, onInput, style, ...props }) {
5
+ const ariaInvalid = props["aria-invalid"] ?? (status === "error" ? true : undefined);
6
+ return (jsx("textarea", { ref: ref, className: concatClassNames("lui-textarea", `lui-textarea--${size}`, status !== "default" && `lui-textarea--${status}`, !autoResize && resize !== "vertical" && `lui-textarea--resize-${resize}`, fullWidth && "lui-textarea--full-width", className), disabled: disabled, readOnly: readOnly, "aria-invalid": ariaInvalid, onInput: (e) => {
7
+ if (autoResize) {
8
+ e.currentTarget.style.height = "auto";
9
+ e.currentTarget.style.height = `${e.currentTarget.scrollHeight}px`;
10
+ }
11
+ onInput?.(e);
12
+ }, style: autoResize ? { overflow: "hidden", resize: "none", ...style } : style, ...props }));
13
+ }
14
+ Textarea.displayName = "Textarea";
15
+
16
+ export { Textarea, Textarea as default };
@@ -0,0 +1,86 @@
1
+ @layer components {
2
+ .lui-textarea {
3
+ display: block;
4
+ width: 100%;
5
+ min-height: 4rem;
6
+ background-color: var(--lui-textarea-bg);
7
+ color: var(--lui-textarea-text);
8
+ border: var(--lui-border-width) solid var(--lui-textarea-border);
9
+ border-radius: var(--lui-textarea-radius);
10
+ font-family: var(--lui-font-family);
11
+ font-weight: var(--lui-font-weight);
12
+ line-height: 1.5;
13
+ resize: vertical;
14
+ outline: none;
15
+ transition: var(--lui-transition);
16
+ }
17
+ .lui-textarea::placeholder {
18
+ color: var(--lui-textarea-placeholder);
19
+ }
20
+ .lui-textarea:focus-visible {
21
+ border-color: var(--lui-textarea-focus-border);
22
+ box-shadow: 0 0 0 2px var(--lui-textarea-focus-ring-color);
23
+ }
24
+ .lui-textarea:disabled {
25
+ opacity: var(--lui-disabled-opacity);
26
+ cursor: var(--lui-disabled-cursor);
27
+ pointer-events: none;
28
+ }
29
+ .lui-textarea[readonly] {
30
+ cursor: default;
31
+ background-color: var(--lui-surface-raised);
32
+ }
33
+ .lui-textarea--xs {
34
+ padding: 0.25rem 0.5rem;
35
+ font-size: var(--lui-font-size-xs);
36
+ }
37
+ .lui-textarea--sm {
38
+ padding: 0.375rem 0.625rem;
39
+ font-size: var(--lui-font-size-sm);
40
+ }
41
+ .lui-textarea--md {
42
+ padding: 0.5rem 0.75rem;
43
+ font-size: var(--lui-font-size-md);
44
+ }
45
+ .lui-textarea--lg {
46
+ padding: 0.625rem 0.875rem;
47
+ font-size: var(--lui-font-size-lg);
48
+ }
49
+ .lui-textarea--xl {
50
+ padding: 0.75rem 1rem;
51
+ font-size: var(--lui-font-size-xl);
52
+ }
53
+ .lui-textarea--error {
54
+ border-color: var(--lui-error);
55
+ }
56
+ .lui-textarea--error:focus-visible {
57
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--lui-error) 40%, transparent);
58
+ }
59
+ .lui-textarea--success {
60
+ border-color: var(--lui-success);
61
+ }
62
+ .lui-textarea--success:focus-visible {
63
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--lui-success) 40%, transparent);
64
+ }
65
+ .lui-textarea--warning {
66
+ border-color: var(--lui-warning);
67
+ }
68
+ .lui-textarea--warning:focus-visible {
69
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--lui-warning) 40%, transparent);
70
+ }
71
+ .lui-textarea--resize-none {
72
+ resize: none;
73
+ }
74
+ .lui-textarea--resize-both {
75
+ resize: both;
76
+ }
77
+ .lui-textarea--resize-horizontal {
78
+ resize: horizontal;
79
+ }
80
+ .lui-textarea--resize-vertical {
81
+ resize: vertical;
82
+ }
83
+ .lui-textarea--full-width {
84
+ width: 100%;
85
+ }
86
+ }
@@ -0,0 +1,27 @@
1
+ import type { Ref } from "react";
2
+ export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
3
+ /** React 19 ref — points to the native `<textarea>` element */
4
+ ref?: Ref<HTMLTextAreaElement>;
5
+ /** Size variant — controls padding and font size. @default "md" */
6
+ size?: "xs" | "sm" | "md" | "lg" | "xl";
7
+ /**
8
+ * Visual status — controls border color.
9
+ * `"error"` also sets `aria-invalid="true"` automatically.
10
+ * @default "default"
11
+ */
12
+ status?: "default" | "error" | "success" | "warning";
13
+ /** Stretch to fill its container's full width. @default true */
14
+ fullWidth?: boolean;
15
+ /** CSS resize behavior. @default "vertical" */
16
+ resize?: "none" | "both" | "horizontal" | "vertical";
17
+ /**
18
+ * When true the textarea grows automatically with its content.
19
+ * `resize` is ignored and `overflow: hidden` is applied inline.
20
+ * @default false
21
+ */
22
+ autoResize?: boolean;
23
+ }
24
+ export declare function Textarea({ ref, className, size, status, fullWidth, resize, autoResize, disabled, readOnly, onInput, style, ...props }: TextareaProps): import("react/jsx-runtime").JSX.Element;
25
+ export declare namespace Textarea {
26
+ var displayName: string;
27
+ }
@@ -0,0 +1,14 @@
1
+ @layer textarea {
2
+ :root {
3
+ /* Background & text */
4
+ --lui-textarea-bg: var(--lui-surface);
5
+ --lui-textarea-text: var(--lui-surface-text);
6
+ --lui-textarea-placeholder: color-mix(in srgb, var(--lui-surface-text) 40%, transparent);
7
+ /* Border */
8
+ --lui-textarea-border: color-mix(in srgb, var(--lui-surface-border) 93%, var(--lui-surface-text));
9
+ --lui-textarea-focus-border: var(--lui-primary);
10
+ --lui-textarea-focus-ring-color: color-mix(in srgb, var(--lui-primary) 40%, transparent);
11
+ /* Shape */
12
+ --lui-textarea-radius: var(--lui-radius-sm);
13
+ }
14
+ }
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@ladder-ui/textarea",
3
+ "version": "0.2.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "require": "./dist/index.js",
11
+ "import": "./dist/index.mjs",
12
+ "types": "./dist/index.d.ts"
13
+ },
14
+ "./*.css": "./dist/*.css",
15
+ "./styles/*.css": "./dist/*.css"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "keywords": [
21
+ "nodejs",
22
+ "react",
23
+ "ui",
24
+ "components",
25
+ "library",
26
+ "textarea",
27
+ "form"
28
+ ],
29
+ "author": "Ivan Avila <ivelaval@gmail.com> - https://www.vennet.dev",
30
+ "license": "ISC",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+ssh://git@github.com/ivelaval/ladder-ui.git"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/ivelaval/ladder-ui/issues"
37
+ },
38
+ "homepage": "https://github.com/ivelaval/ladder-ui#readme",
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "devDependencies": {
43
+ "@rollup/plugin-typescript": "^11.1.6",
44
+ "@types/react": "^19.0.0",
45
+ "rollup": "^4.59.0",
46
+ "rollup-plugin-postcss": "^4.0.2",
47
+ "sass": "^1.90.0",
48
+ "tslib": "^2.6.2",
49
+ "typescript": "^5.3.3",
50
+ "@ladder-ui/core": "0.2.0"
51
+ },
52
+ "peerDependencies": {
53
+ "@ladder-ui/core": ">=0.0.0",
54
+ "react": ">=18.0.0"
55
+ },
56
+ "sideEffects": [
57
+ "**/*.css"
58
+ ],
59
+ "scripts": {
60
+ "build": "pnpm clean && rollup -c",
61
+ "dev": "rollup -c -w",
62
+ "test": "vitest run",
63
+ "test:watch": "vitest",
64
+ "type-check": "tsc --noEmit",
65
+ "clean": "rm -rf dist"
66
+ }
67
+ }