@asnewyla/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.
- package/LICENSE +21 -0
- package/README.md +73 -0
- package/dist/index.css +47 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.mts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +33 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 XD
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# @asnewyla/textarea
|
|
2
|
+
|
|
3
|
+
Styled multi-line text input built on `@asnewyla/unstyled-textarea`. Label
|
|
4
|
+
association, inline validation error, and full keyboard/focus
|
|
5
|
+
accessibility.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @asnewyla/textarea
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Import the stylesheet once, anywhere in your app:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import '@asnewyla/textarea/styles.css';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { Textarea } from '@asnewyla/textarea';
|
|
23
|
+
|
|
24
|
+
<Textarea label="Bio" placeholder="Tell us about yourself" />
|
|
25
|
+
|
|
26
|
+
<Textarea label="Bio" error="Bio is required" />
|
|
27
|
+
|
|
28
|
+
// Controlled
|
|
29
|
+
<Textarea
|
|
30
|
+
label="Bio"
|
|
31
|
+
value={bio}
|
|
32
|
+
onChange={(e) => setBio(e.target.value)}
|
|
33
|
+
/>
|
|
34
|
+
|
|
35
|
+
// Any native textarea attribute passes straight through
|
|
36
|
+
<Textarea label="Cover letter" rows={10} />
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Props
|
|
40
|
+
|
|
41
|
+
Everything `@asnewyla/unstyled-textarea` accepts, plus:
|
|
42
|
+
|
|
43
|
+
| Prop | Type | Default |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| `label` | `string` (**required**) | — |
|
|
46
|
+
| `error` | `string` | — |
|
|
47
|
+
|
|
48
|
+
`error` doubles as the invalid-state flag — there's no separate `invalid`
|
|
49
|
+
prop, same convention as `@asnewyla/input`/`@asnewyla/checkbox`/
|
|
50
|
+
`@asnewyla/switch`. Setting `error` sets `aria-invalid`/`data-invalid` on
|
|
51
|
+
the field and links it via `aria-describedby` to the rendered error
|
|
52
|
+
message.
|
|
53
|
+
|
|
54
|
+
Resizing is vertical-only (`resize: vertical`), not the browser's default
|
|
55
|
+
`both` — letting a stacked, block-level field grow wider than its
|
|
56
|
+
container breaks whatever layout it sits in.
|
|
57
|
+
|
|
58
|
+
### Theming
|
|
59
|
+
|
|
60
|
+
Override the CSS custom properties — defaults adapt automatically to
|
|
61
|
+
`prefers-color-scheme` via `@asnewyla/tokens`:
|
|
62
|
+
|
|
63
|
+
```css
|
|
64
|
+
:root {
|
|
65
|
+
--xd-color-primary: #0d9488;
|
|
66
|
+
--xd-color-border: #cbd5e1;
|
|
67
|
+
--xd-color-destructive: #dc2626;
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT
|
package/dist/index.css
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* src/components/Textarea.css */
|
|
2
|
+
.xd-textarea {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: var(--xd-space-xs, 0.25rem);
|
|
6
|
+
}
|
|
7
|
+
.xd-textarea-label {
|
|
8
|
+
font-size: var(--xd-font-size-sm, 0.8125rem);
|
|
9
|
+
font-weight: var(--xd-font-weight-semibold, 600);
|
|
10
|
+
letter-spacing: var(--xd-letter-spacing-label, 0);
|
|
11
|
+
text-transform: var(--xd-text-transform-label, none);
|
|
12
|
+
}
|
|
13
|
+
.xd-textarea-input {
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
width: 100%;
|
|
16
|
+
min-height: 5.5rem;
|
|
17
|
+
border: var(--xd-border-width-thin, 1px) solid var(--xd-color-border, #cbd5e1);
|
|
18
|
+
border-radius: var(--xd-radius-sm, 0.25rem);
|
|
19
|
+
padding: var(--xd-space-sm, 0.375rem) var(--xd-space-md, 0.5rem);
|
|
20
|
+
font-family: inherit;
|
|
21
|
+
font-size: var(--xd-font-size-md, 0.875rem);
|
|
22
|
+
line-height: var(--xd-line-height-normal, 1.25);
|
|
23
|
+
color: inherit;
|
|
24
|
+
background-color: transparent;
|
|
25
|
+
resize: vertical;
|
|
26
|
+
transition: border-color var(--xd-motion-fast, 120ms ease-out), outline-color var(--xd-motion-fast, 120ms ease-out);
|
|
27
|
+
}
|
|
28
|
+
.xd-textarea-input:focus-visible {
|
|
29
|
+
outline: var(--xd-focus-ring-width, 2px) solid var(--xd-color-focus, var(--xd-color-primary, #0d9488));
|
|
30
|
+
outline-offset: var(--xd-focus-ring-offset, 2px);
|
|
31
|
+
}
|
|
32
|
+
.xd-textarea-input[data-invalid=true] {
|
|
33
|
+
border-color: var(--xd-color-destructive, #dc2626);
|
|
34
|
+
}
|
|
35
|
+
.xd-textarea-input[data-invalid=true]:focus-visible {
|
|
36
|
+
outline-color: var(--xd-color-destructive, #dc2626);
|
|
37
|
+
}
|
|
38
|
+
.xd-textarea-error {
|
|
39
|
+
font-size: var(--xd-font-size-sm, 0.8125rem);
|
|
40
|
+
color: var(--xd-color-destructive, #dc2626);
|
|
41
|
+
}
|
|
42
|
+
.xd-textarea-input:disabled {
|
|
43
|
+
opacity: var(--xd-opacity-disabled, 0.5);
|
|
44
|
+
cursor: not-allowed;
|
|
45
|
+
resize: none;
|
|
46
|
+
}
|
|
47
|
+
/*# sourceMappingURL=index.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Textarea.css"],"sourcesContent":[".xd-textarea {\n display: flex;\n flex-direction: column;\n gap: var(--xd-space-xs, 0.25rem);\n}\n\n.xd-textarea-label {\n font-size: var(--xd-font-size-sm, 0.8125rem);\n font-weight: var(--xd-font-weight-semibold, 600);\n letter-spacing: var(--xd-letter-spacing-label, 0);\n text-transform: var(--xd-text-transform-label, none);\n}\n\n.xd-textarea-input {\n box-sizing: border-box;\n width: 100%;\n /* Taller floor than Input's single-line control-height, and a real\n min-height rather than a fixed height -- a textarea grows past this\n with its own native resize handle or a consumer's `rows`. */\n min-height: 5.5rem;\n border: var(--xd-border-width-thin, 1px) solid var(--xd-color-border, #cbd5e1);\n border-radius: var(--xd-radius-sm, 0.25rem);\n padding: var(--xd-space-sm, 0.375rem) var(--xd-space-md, 0.5rem);\n font-family: inherit;\n font-size: var(--xd-font-size-md, 0.875rem);\n line-height: var(--xd-line-height-normal, 1.25);\n color: inherit;\n background-color: transparent;\n /* Vertical-only, not the native default `both` -- letting a stacked\n block-level field grow wider than its container breaks the layout\n it sits in, the same reasoning `resize: vertical` design systems\n converge on. */\n resize: vertical;\n transition:\n border-color var(--xd-motion-fast, 120ms ease-out),\n outline-color var(--xd-motion-fast, 120ms ease-out);\n}\n\n.xd-textarea-input:focus-visible {\n outline: var(--xd-focus-ring-width, 2px) solid\n var(--xd-color-focus, var(--xd-color-primary, #0d9488));\n outline-offset: var(--xd-focus-ring-offset, 2px);\n}\n\n/* --- Invalid --- */\n\n.xd-textarea-input[data-invalid=\"true\"] {\n border-color: var(--xd-color-destructive, #dc2626);\n}\n\n.xd-textarea-input[data-invalid=\"true\"]:focus-visible {\n outline-color: var(--xd-color-destructive, #dc2626);\n}\n\n.xd-textarea-error {\n font-size: var(--xd-font-size-sm, 0.8125rem);\n color: var(--xd-color-destructive, #dc2626);\n}\n\n/* --- Disabled --- */\n\n.xd-textarea-input:disabled {\n opacity: var(--xd-opacity-disabled, 0.5);\n cursor: not-allowed;\n resize: none;\n}\n"],"mappings":";AAAA,CAAC;AACC,WAAS;AACT,kBAAgB;AAChB,OAAK,IAAI,aAAa,EAAE;AAC1B;AAEA,CAAC;AACC,aAAW,IAAI,iBAAiB,EAAE;AAClC,eAAa,IAAI,yBAAyB,EAAE;AAC5C,kBAAgB,IAAI,yBAAyB,EAAE;AAC/C,kBAAgB,IAAI,yBAAyB,EAAE;AACjD;AAEA,CAAC;AACC,cAAY;AACZ,SAAO;AAIP,cAAY;AACZ,UAAQ,IAAI,sBAAsB,EAAE,KAAK,MAAM,IAAI,iBAAiB,EAAE;AACtE,iBAAe,IAAI,cAAc,EAAE;AACnC,WAAS,IAAI,aAAa,EAAE,UAAU,IAAI,aAAa,EAAE;AACzD,eAAa;AACb,aAAW,IAAI,iBAAiB,EAAE;AAClC,eAAa,IAAI,uBAAuB,EAAE;AAC1C,SAAO;AACP,oBAAkB;AAKlB,UAAQ;AACR,cACE,aAAa,IAAI,gBAAgB,EAAE,MAAM,SAAS,EAClD,cAAc,IAAI,gBAAgB,EAAE,MAAM;AAC9C;AAEA,CAzBC,iBAyBiB;AAChB,WAAS,IAAI,qBAAqB,EAAE,KAAK,MACvC,IAAI,gBAAgB,EAAE,IAAI,kBAAkB,EAAE;AAChD,kBAAgB,IAAI,sBAAsB,EAAE;AAC9C;AAIA,CAjCC,iBAiCiB,CAAC;AACjB,gBAAc,IAAI,sBAAsB,EAAE;AAC5C;AAEA,CArCC,iBAqCiB,CAAC,kBAAoB;AACrC,iBAAe,IAAI,sBAAsB,EAAE;AAC7C;AAEA,CAAC;AACC,aAAW,IAAI,iBAAiB,EAAE;AAClC,SAAO,IAAI,sBAAsB,EAAE;AACrC;AAIA,CAhDC,iBAgDiB;AAChB,WAAS,IAAI,qBAAqB,EAAE;AACpC,UAAQ;AACR,UAAQ;AACV;","names":[]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { UnstyledTextareaProps } from '@asnewyla/unstyled-textarea';
|
|
3
|
+
|
|
4
|
+
type TextareaProps = Omit<UnstyledTextareaProps, 'invalid'> & {
|
|
5
|
+
label: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const Textarea: react.ForwardRefExoticComponent<Omit<UnstyledTextareaProps, "invalid"> & {
|
|
9
|
+
label: string;
|
|
10
|
+
error?: string;
|
|
11
|
+
} & react.RefAttributes<HTMLTextAreaElement>>;
|
|
12
|
+
|
|
13
|
+
export { Textarea, type TextareaProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { UnstyledTextareaProps } from '@asnewyla/unstyled-textarea';
|
|
3
|
+
|
|
4
|
+
type TextareaProps = Omit<UnstyledTextareaProps, 'invalid'> & {
|
|
5
|
+
label: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const Textarea: react.ForwardRefExoticComponent<Omit<UnstyledTextareaProps, "invalid"> & {
|
|
9
|
+
label: string;
|
|
10
|
+
error?: string;
|
|
11
|
+
} & react.RefAttributes<HTMLTextAreaElement>>;
|
|
12
|
+
|
|
13
|
+
export { Textarea, type TextareaProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var unstyledTextarea = require('@asnewyla/unstyled-textarea');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
// src/components/Textarea.tsx
|
|
8
|
+
function TextareaInner({ label, id, error, disabled, className, ...rest }, ref) {
|
|
9
|
+
const generatedId = react.useId();
|
|
10
|
+
const textareaId = id ?? generatedId;
|
|
11
|
+
const errorId = `${textareaId}-error`;
|
|
12
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "xd-textarea", children: [
|
|
13
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "xd-textarea-label", htmlFor: textareaId, children: label }),
|
|
14
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
15
|
+
unstyledTextarea.UnstyledTextarea,
|
|
16
|
+
{
|
|
17
|
+
id: textareaId,
|
|
18
|
+
...rest,
|
|
19
|
+
invalid: !!error,
|
|
20
|
+
disabled,
|
|
21
|
+
"aria-describedby": error ? errorId : void 0,
|
|
22
|
+
className: className ? `xd-textarea-input ${className}` : "xd-textarea-input",
|
|
23
|
+
ref
|
|
24
|
+
}
|
|
25
|
+
),
|
|
26
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "xd-textarea-error", id: errorId, children: error })
|
|
27
|
+
] });
|
|
28
|
+
}
|
|
29
|
+
var Textarea = react.forwardRef(
|
|
30
|
+
TextareaInner
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
exports.Textarea = Textarea;
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Textarea.tsx"],"names":["useId","jsxs","jsx","UnstyledTextarea","forwardRef"],"mappings":";;;;;;;AAYA,SAAS,aAAA,CACP,EAAE,KAAA,EAAO,EAAA,EAAI,KAAA,EAAO,UAAU,SAAA,EAAW,GAAG,IAAA,EAAK,EACjD,GAAA,EACA;AACA,EAAA,MAAM,cAAcA,WAAA,EAAM;AAC1B,EAAA,MAAM,aAAa,EAAA,IAAM,WAAA;AACzB,EAAA,MAAM,OAAA,GAAU,GAAG,UAAU,CAAA,MAAA,CAAA;AAE7B,EAAA,uBACEC,eAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,aAAA,EACb,QAAA,EAAA;AAAA,oBAAAC,cAAA,CAAC,OAAA,EAAA,EAAM,SAAA,EAAU,mBAAA,EAAoB,OAAA,EAAS,YAC3C,QAAA,EAAA,KAAA,EACH,CAAA;AAAA,oBACAA,cAAA;AAAA,MAACC,iCAAA;AAAA,MAAA;AAAA,QACC,EAAA,EAAI,UAAA;AAAA,QACH,GAAG,IAAA;AAAA,QACJ,OAAA,EAAS,CAAC,CAAC,KAAA;AAAA,QACX,QAAA;AAAA,QACA,kBAAA,EAAkB,QAAQ,OAAA,GAAU,MAAA;AAAA,QACpC,SAAA,EACE,SAAA,GAAY,CAAA,kBAAA,EAAqB,SAAS,CAAA,CAAA,GAAK,mBAAA;AAAA,QAEjD;AAAA;AAAA,KACF;AAAA,IACC,yBACCD,cAAA,CAAC,KAAA,EAAA,EAAI,WAAU,mBAAA,EAAoB,EAAA,EAAI,SACpC,QAAA,EAAA,KAAA,EACH;AAAA,GAAA,EAEJ,CAAA;AAEJ;AAEO,IAAM,QAAA,GAAWE,gBAAA;AAAA,EACtB;AACF","file":"index.js","sourcesContent":["import {\n UnstyledTextarea,\n type UnstyledTextareaProps,\n} from '@asnewyla/unstyled-textarea';\nimport { type ForwardedRef, forwardRef, useId } from 'react';\nimport './Textarea.css';\n\nexport type TextareaProps = Omit<UnstyledTextareaProps, 'invalid'> & {\n label: string;\n error?: string;\n};\n\nfunction TextareaInner(\n { label, id, error, disabled, className, ...rest }: TextareaProps,\n ref: ForwardedRef<HTMLTextAreaElement>,\n) {\n const generatedId = useId();\n const textareaId = id ?? generatedId;\n const errorId = `${textareaId}-error`;\n\n return (\n <div className=\"xd-textarea\">\n <label className=\"xd-textarea-label\" htmlFor={textareaId}>\n {label}\n </label>\n <UnstyledTextarea\n id={textareaId}\n {...rest}\n invalid={!!error}\n disabled={disabled}\n aria-describedby={error ? errorId : undefined}\n className={\n className ? `xd-textarea-input ${className}` : 'xd-textarea-input'\n }\n ref={ref}\n />\n {error && (\n <div className=\"xd-textarea-error\" id={errorId}>\n {error}\n </div>\n )}\n </div>\n );\n}\n\nexport const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(\n TextareaInner,\n);\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { UnstyledTextarea } from '@asnewyla/unstyled-textarea';
|
|
2
|
+
import { forwardRef, useId } from 'react';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
// src/components/Textarea.tsx
|
|
6
|
+
function TextareaInner({ label, id, error, disabled, className, ...rest }, ref) {
|
|
7
|
+
const generatedId = useId();
|
|
8
|
+
const textareaId = id ?? generatedId;
|
|
9
|
+
const errorId = `${textareaId}-error`;
|
|
10
|
+
return /* @__PURE__ */ jsxs("div", { className: "xd-textarea", children: [
|
|
11
|
+
/* @__PURE__ */ jsx("label", { className: "xd-textarea-label", htmlFor: textareaId, children: label }),
|
|
12
|
+
/* @__PURE__ */ jsx(
|
|
13
|
+
UnstyledTextarea,
|
|
14
|
+
{
|
|
15
|
+
id: textareaId,
|
|
16
|
+
...rest,
|
|
17
|
+
invalid: !!error,
|
|
18
|
+
disabled,
|
|
19
|
+
"aria-describedby": error ? errorId : void 0,
|
|
20
|
+
className: className ? `xd-textarea-input ${className}` : "xd-textarea-input",
|
|
21
|
+
ref
|
|
22
|
+
}
|
|
23
|
+
),
|
|
24
|
+
error && /* @__PURE__ */ jsx("div", { className: "xd-textarea-error", id: errorId, children: error })
|
|
25
|
+
] });
|
|
26
|
+
}
|
|
27
|
+
var Textarea = forwardRef(
|
|
28
|
+
TextareaInner
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export { Textarea };
|
|
32
|
+
//# sourceMappingURL=index.mjs.map
|
|
33
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Textarea.tsx"],"names":[],"mappings":";;;;;AAYA,SAAS,aAAA,CACP,EAAE,KAAA,EAAO,EAAA,EAAI,KAAA,EAAO,UAAU,SAAA,EAAW,GAAG,IAAA,EAAK,EACjD,GAAA,EACA;AACA,EAAA,MAAM,cAAc,KAAA,EAAM;AAC1B,EAAA,MAAM,aAAa,EAAA,IAAM,WAAA;AACzB,EAAA,MAAM,OAAA,GAAU,GAAG,UAAU,CAAA,MAAA,CAAA;AAE7B,EAAA,uBACE,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,aAAA,EACb,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,OAAA,EAAA,EAAM,SAAA,EAAU,mBAAA,EAAoB,OAAA,EAAS,YAC3C,QAAA,EAAA,KAAA,EACH,CAAA;AAAA,oBACA,GAAA;AAAA,MAAC,gBAAA;AAAA,MAAA;AAAA,QACC,EAAA,EAAI,UAAA;AAAA,QACH,GAAG,IAAA;AAAA,QACJ,OAAA,EAAS,CAAC,CAAC,KAAA;AAAA,QACX,QAAA;AAAA,QACA,kBAAA,EAAkB,QAAQ,OAAA,GAAU,MAAA;AAAA,QACpC,SAAA,EACE,SAAA,GAAY,CAAA,kBAAA,EAAqB,SAAS,CAAA,CAAA,GAAK,mBAAA;AAAA,QAEjD;AAAA;AAAA,KACF;AAAA,IACC,yBACC,GAAA,CAAC,KAAA,EAAA,EAAI,WAAU,mBAAA,EAAoB,EAAA,EAAI,SACpC,QAAA,EAAA,KAAA,EACH;AAAA,GAAA,EAEJ,CAAA;AAEJ;AAEO,IAAM,QAAA,GAAW,UAAA;AAAA,EACtB;AACF","file":"index.mjs","sourcesContent":["import {\n UnstyledTextarea,\n type UnstyledTextareaProps,\n} from '@asnewyla/unstyled-textarea';\nimport { type ForwardedRef, forwardRef, useId } from 'react';\nimport './Textarea.css';\n\nexport type TextareaProps = Omit<UnstyledTextareaProps, 'invalid'> & {\n label: string;\n error?: string;\n};\n\nfunction TextareaInner(\n { label, id, error, disabled, className, ...rest }: TextareaProps,\n ref: ForwardedRef<HTMLTextAreaElement>,\n) {\n const generatedId = useId();\n const textareaId = id ?? generatedId;\n const errorId = `${textareaId}-error`;\n\n return (\n <div className=\"xd-textarea\">\n <label className=\"xd-textarea-label\" htmlFor={textareaId}>\n {label}\n </label>\n <UnstyledTextarea\n id={textareaId}\n {...rest}\n invalid={!!error}\n disabled={disabled}\n aria-describedby={error ? errorId : undefined}\n className={\n className ? `xd-textarea-input ${className}` : 'xd-textarea-input'\n }\n ref={ref}\n />\n {error && (\n <div className=\"xd-textarea-error\" id={errorId}>\n {error}\n </div>\n )}\n </div>\n );\n}\n\nexport const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(\n TextareaInner,\n);\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@asnewyla/textarea",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Styled multi-line text input (textarea) with label, validation error display, and accessibility",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/xavierDelaFuente/xd-components.git",
|
|
9
|
+
"directory": "packages/textarea"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"module": "dist/index.mjs",
|
|
16
|
+
"types": "dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.mjs",
|
|
21
|
+
"require": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./styles.css": "./dist/index.css"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"sideEffects": [
|
|
29
|
+
"*.css"
|
|
30
|
+
],
|
|
31
|
+
"keywords": [
|
|
32
|
+
"react",
|
|
33
|
+
"textarea",
|
|
34
|
+
"form",
|
|
35
|
+
"styled",
|
|
36
|
+
"accessible"
|
|
37
|
+
],
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
40
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@asnewyla/unstyled-textarea": "0.2.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@testing-library/jest-dom": "^6.4.0",
|
|
47
|
+
"@testing-library/react": "^16.0.0",
|
|
48
|
+
"@testing-library/user-event": "^14.5.0",
|
|
49
|
+
"@vitest/coverage-v8": "^2.0.0",
|
|
50
|
+
"jsdom": "^24.0.0",
|
|
51
|
+
"react": "^18.3.0",
|
|
52
|
+
"react-dom": "^18.3.0",
|
|
53
|
+
"tsup": "^8.1.0",
|
|
54
|
+
"typescript": "^5.5.0",
|
|
55
|
+
"vitest": "^2.0.0"
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "tsup",
|
|
59
|
+
"test": "vitest run",
|
|
60
|
+
"test:watch": "vitest",
|
|
61
|
+
"test:coverage": "vitest run --coverage",
|
|
62
|
+
"type-check": "tsc --noEmit"
|
|
63
|
+
}
|
|
64
|
+
}
|