@ladder-ui/textarea 0.3.0 → 0.4.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.
package/dist/index.js CHANGED
@@ -3,14 +3,55 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
- var concatClassNames = require('@ladder-ui/core/concatClassNames');
6
+ var core = require('@ladder-ui/core');
7
7
  var react = require('react');
8
8
 
9
- function Textarea({ ref, className, size = "md", status = "default", fullWidth = true, resize = "vertical", autoResize = false, disabled, readOnly, onInput, style, ...props }) {
9
+ // ── Variants ──────────────────────────────────────────────────────────────────
10
+ const textareaVariants = core.cva({
11
+ base: "lui-textarea",
12
+ variants: {
13
+ size: {
14
+ xs: "lui-textarea--xs",
15
+ sm: "lui-textarea--sm",
16
+ md: "lui-textarea--md",
17
+ lg: "lui-textarea--lg",
18
+ xl: "lui-textarea--xl",
19
+ },
20
+ status: {
21
+ default: "",
22
+ error: "lui-textarea--error",
23
+ success: "lui-textarea--success",
24
+ warning: "lui-textarea--warning",
25
+ },
26
+ resize: {
27
+ vertical: "",
28
+ none: "lui-textarea--resize-none",
29
+ both: "lui-textarea--resize-both",
30
+ horizontal: "lui-textarea--resize-horizontal",
31
+ },
32
+ fullWidth: {
33
+ true: "lui-textarea--full-width",
34
+ false: "",
35
+ },
36
+ },
37
+ defaultVariants: {
38
+ size: "md",
39
+ status: "default",
40
+ resize: "vertical",
41
+ fullWidth: true,
42
+ },
43
+ });
44
+ function Textarea({ ref, className, size, status, fullWidth, resize, autoResize, disabled, readOnly, onInput, style, ...props }) {
10
45
  const ariaInvalid = props["aria-invalid"] ?? (status === "error" ? true : undefined);
11
46
  // Track pending animation frame so rapid typing only triggers one resize per frame
12
47
  const rafRef = react.useRef(0);
13
- 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) => {
48
+ return (jsxRuntime.jsx("textarea", { ref: ref, className: textareaVariants({
49
+ size,
50
+ status,
51
+ resize: autoResize ? "none" : resize,
52
+ fullWidth,
53
+ className,
54
+ }), disabled: disabled, readOnly: readOnly, "aria-invalid": ariaInvalid, onInput: (e) => {
14
55
  if (autoResize) {
15
56
  const el = e.currentTarget;
16
57
  cancelAnimationFrame(rafRef.current);
package/dist/index.mjs CHANGED
@@ -1,12 +1,53 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import concatClassNames from '@ladder-ui/core/concatClassNames';
2
+ import { cva } from '@ladder-ui/core';
3
3
  import { useRef } from 'react';
4
4
 
5
- function Textarea({ ref, className, size = "md", status = "default", fullWidth = true, resize = "vertical", autoResize = false, disabled, readOnly, onInput, style, ...props }) {
5
+ // ── Variants ──────────────────────────────────────────────────────────────────
6
+ const textareaVariants = cva({
7
+ base: "lui-textarea",
8
+ variants: {
9
+ size: {
10
+ xs: "lui-textarea--xs",
11
+ sm: "lui-textarea--sm",
12
+ md: "lui-textarea--md",
13
+ lg: "lui-textarea--lg",
14
+ xl: "lui-textarea--xl",
15
+ },
16
+ status: {
17
+ default: "",
18
+ error: "lui-textarea--error",
19
+ success: "lui-textarea--success",
20
+ warning: "lui-textarea--warning",
21
+ },
22
+ resize: {
23
+ vertical: "",
24
+ none: "lui-textarea--resize-none",
25
+ both: "lui-textarea--resize-both",
26
+ horizontal: "lui-textarea--resize-horizontal",
27
+ },
28
+ fullWidth: {
29
+ true: "lui-textarea--full-width",
30
+ false: "",
31
+ },
32
+ },
33
+ defaultVariants: {
34
+ size: "md",
35
+ status: "default",
36
+ resize: "vertical",
37
+ fullWidth: true,
38
+ },
39
+ });
40
+ function Textarea({ ref, className, size, status, fullWidth, resize, autoResize, disabled, readOnly, onInput, style, ...props }) {
6
41
  const ariaInvalid = props["aria-invalid"] ?? (status === "error" ? true : undefined);
7
42
  // Track pending animation frame so rapid typing only triggers one resize per frame
8
43
  const rafRef = useRef(0);
9
- 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) => {
44
+ return (jsx("textarea", { ref: ref, className: textareaVariants({
45
+ size,
46
+ status,
47
+ resize: autoResize ? "none" : resize,
48
+ fullWidth,
49
+ className,
50
+ }), disabled: disabled, readOnly: readOnly, "aria-invalid": ariaInvalid, onInput: (e) => {
10
51
  if (autoResize) {
11
52
  const el = e.currentTarget;
12
53
  cancelAnimationFrame(rafRef.current);
package/dist/textarea.css CHANGED
@@ -28,7 +28,7 @@
28
28
  }
29
29
  .lui-textarea[readonly] {
30
30
  cursor: default;
31
- background-color: var(--lui-surface-raised);
31
+ background-color: var(--lui-bg-surface-raised);
32
32
  }
33
33
  .lui-textarea--xs {
34
34
  padding: 0.25rem 0.5rem;
@@ -1,5 +1,33 @@
1
+ import { type VariantProps } from "@ladder-ui/core";
1
2
  import type { Ref } from "react";
2
- export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
3
+ declare const textareaVariants: (props?: (import("packages/core/dist/cva").ConfigVariants<{
4
+ size: {
5
+ xs: string;
6
+ sm: string;
7
+ md: string;
8
+ lg: string;
9
+ xl: string;
10
+ };
11
+ status: {
12
+ default: string;
13
+ error: string;
14
+ success: string;
15
+ warning: string;
16
+ };
17
+ resize: {
18
+ vertical: string;
19
+ none: string;
20
+ both: string;
21
+ horizontal: string;
22
+ };
23
+ fullWidth: {
24
+ true: string;
25
+ false: string;
26
+ };
27
+ }> & {
28
+ className?: string;
29
+ }) | undefined) => string;
30
+ export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement>, VariantProps<typeof textareaVariants> {
3
31
  /** React 19 ref — points to the native `<textarea>` element */
4
32
  ref?: Ref<HTMLTextAreaElement>;
5
33
  /** Size variant — controls padding and font size. @default "md" */
@@ -25,3 +53,4 @@ export declare function Textarea({ ref, className, size, status, fullWidth, resi
25
53
  export declare namespace Textarea {
26
54
  var displayName: string;
27
55
  }
56
+ export {};
@@ -1,13 +1,13 @@
1
1
  @layer textarea {
2
2
  :root {
3
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);
4
+ --lui-textarea-bg: var(--lui-bg-surface);
5
+ --lui-textarea-text: var(--lui-text-primary);
6
+ --lui-textarea-placeholder: color-mix(in srgb, var(--lui-text-primary) 40%, transparent);
7
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);
8
+ --lui-textarea-border: color-mix(in srgb, var(--lui-border-default) 93%, var(--lui-text-primary));
9
+ --lui-textarea-focus-border: var(--lui-bg-interactive);
10
+ --lui-textarea-focus-ring-color: color-mix(in srgb, var(--lui-bg-interactive) 40%, transparent);
11
11
  /* Shape */
12
12
  --lui-textarea-radius: var(--lui-radius-sm);
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ladder-ui/textarea",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -47,7 +47,7 @@
47
47
  "sass": "^1.90.0",
48
48
  "tslib": "^2.6.2",
49
49
  "typescript": "^5.3.3",
50
- "@ladder-ui/core": "0.3.0"
50
+ "@ladder-ui/core": "0.4.0"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@ladder-ui/core": ">=0.0.0",