@behivetech/atoms.textarea 0.0.0-stage → 0.4.2
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/README.md +28 -2
- package/dist/index.cjs +174 -0
- package/dist/index.css +44 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +160 -0
- package/docs.json +22 -0
- package/index.ts +2 -0
- package/package.json +57 -3
- package/textarea.example.tsx +26 -0
- package/textarea.module.scss +63 -0
- package/textarea.tsx +33 -0
package/README.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Textarea
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A bare multi-line text input — the native `<textarea>` is this component's own root element. It has no built-in label/hint/error; wrap it in `FormField` for that chrome. Works standalone too — not every textarea needs the full form suite.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
import { Textarea } from '@behivetech/atoms.textarea';
|
|
9
|
+
import { FormField } from '@behivetech/forms.form-field';
|
|
10
|
+
|
|
11
|
+
const [value, setValue] = useState('');
|
|
12
|
+
|
|
13
|
+
<Textarea value={value} onChange={(e) => setValue(e.target.value)} />
|
|
14
|
+
|
|
15
|
+
<FormField label="Bio" htmlFor="bio" hint="Max 200 characters.">
|
|
16
|
+
<Textarea id="bio" rows={3} />
|
|
17
|
+
</FormField>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Pass `aria-invalid="true"` to visually mark the field as invalid (pair with `FormField`'s `error` prop for the message).
|
|
21
|
+
|
|
22
|
+
## Props
|
|
23
|
+
|
|
24
|
+
Extends the native `<textarea>` element's attributes with:
|
|
25
|
+
|
|
26
|
+
| Prop | Type | Default | Description |
|
|
27
|
+
| ----------- | -------- | ------- | ---------------------- |
|
|
28
|
+
| `rows` | `number` | `4` | Number of visible rows |
|
|
29
|
+
| `className` | `string` | — | Additional class names |
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// ../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js
|
|
34
|
+
var require_classnames = __commonJS({
|
|
35
|
+
"../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js"(exports2, module2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
(function() {
|
|
38
|
+
"use strict";
|
|
39
|
+
var hasOwn = {}.hasOwnProperty;
|
|
40
|
+
function classNames() {
|
|
41
|
+
var classes = "";
|
|
42
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
43
|
+
var arg = arguments[i];
|
|
44
|
+
if (arg) {
|
|
45
|
+
classes = appendClass(classes, parseValue(arg));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return classes;
|
|
49
|
+
}
|
|
50
|
+
function parseValue(arg) {
|
|
51
|
+
if (typeof arg === "string" || typeof arg === "number") {
|
|
52
|
+
return arg;
|
|
53
|
+
}
|
|
54
|
+
if (typeof arg !== "object") {
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
if (Array.isArray(arg)) {
|
|
58
|
+
return classNames.apply(null, arg);
|
|
59
|
+
}
|
|
60
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
61
|
+
return arg.toString();
|
|
62
|
+
}
|
|
63
|
+
var classes = "";
|
|
64
|
+
for (var key in arg) {
|
|
65
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
66
|
+
classes = appendClass(classes, key);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return classes;
|
|
70
|
+
}
|
|
71
|
+
function appendClass(value, newClass) {
|
|
72
|
+
if (!newClass) {
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
if (value) {
|
|
76
|
+
return value + " " + newClass;
|
|
77
|
+
}
|
|
78
|
+
return value + newClass;
|
|
79
|
+
}
|
|
80
|
+
if (typeof module2 !== "undefined" && module2.exports) {
|
|
81
|
+
classNames.default = classNames;
|
|
82
|
+
module2.exports = classNames;
|
|
83
|
+
} else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
|
|
84
|
+
define("classnames", [], function() {
|
|
85
|
+
return classNames;
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
window.classNames = classNames;
|
|
89
|
+
}
|
|
90
|
+
})();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// index.ts
|
|
95
|
+
var index_exports = {};
|
|
96
|
+
__export(index_exports, {
|
|
97
|
+
Textarea: () => Textarea
|
|
98
|
+
});
|
|
99
|
+
module.exports = __toCommonJS(index_exports);
|
|
100
|
+
|
|
101
|
+
// textarea.tsx
|
|
102
|
+
var import_react = require("react");
|
|
103
|
+
|
|
104
|
+
// ../../../../packages/registry/class-names/dist/index.js
|
|
105
|
+
var import_classnames = __toESM(require_classnames(), 1);
|
|
106
|
+
var getClassName = ({
|
|
107
|
+
className,
|
|
108
|
+
modifiers = {},
|
|
109
|
+
rootClass,
|
|
110
|
+
styles = {}
|
|
111
|
+
}) => {
|
|
112
|
+
function getModifiers() {
|
|
113
|
+
const updatedModifiers = {};
|
|
114
|
+
const modifierKeys = Object.keys(modifiers);
|
|
115
|
+
if (modifierKeys.length) {
|
|
116
|
+
modifierKeys.forEach((modKey) => {
|
|
117
|
+
const classKey = `${rootClass}--${modKey}`;
|
|
118
|
+
const newClassName = styles[classKey] || classKey;
|
|
119
|
+
updatedModifiers[newClassName] = modifiers[modKey] ?? false;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return updatedModifiers;
|
|
123
|
+
}
|
|
124
|
+
function getChildClass(childClassName) {
|
|
125
|
+
const classKey = `${rootClass}__${childClassName}`;
|
|
126
|
+
return styles[classKey] || classKey;
|
|
127
|
+
}
|
|
128
|
+
function getRootStyles() {
|
|
129
|
+
return (0, import_classnames.default)(
|
|
130
|
+
className,
|
|
131
|
+
{
|
|
132
|
+
...getModifiers()
|
|
133
|
+
},
|
|
134
|
+
styles[rootClass] || rootClass
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
return [getRootStyles(), getChildClass];
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// textarea.module.scss
|
|
141
|
+
var textarea_module_default = {
|
|
142
|
+
"BHT__Textarea": "BHT__Textarea"
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// textarea.tsx
|
|
146
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
147
|
+
var Textarea = ({
|
|
148
|
+
className,
|
|
149
|
+
id,
|
|
150
|
+
rows = 4,
|
|
151
|
+
...rest
|
|
152
|
+
}) => {
|
|
153
|
+
const generatedId = (0, import_react.useId)();
|
|
154
|
+
const textareaId = id ?? generatedId;
|
|
155
|
+
const [rootClass] = getClassName({
|
|
156
|
+
className,
|
|
157
|
+
rootClass: "BHT__Textarea",
|
|
158
|
+
styles: textarea_module_default
|
|
159
|
+
});
|
|
160
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", { ...rest, id: textareaId, rows, className: rootClass });
|
|
161
|
+
};
|
|
162
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
163
|
+
0 && (module.exports = {
|
|
164
|
+
Textarea
|
|
165
|
+
});
|
|
166
|
+
/*! Bundled license information:
|
|
167
|
+
|
|
168
|
+
classnames/index.js:
|
|
169
|
+
(*!
|
|
170
|
+
Copyright (c) 2018 Jed Watson.
|
|
171
|
+
Licensed under the MIT License (MIT), see
|
|
172
|
+
http://jedwatson.github.io/classnames
|
|
173
|
+
*)
|
|
174
|
+
*/
|
package/dist/index.css
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/* esbuild-sass-plugin:css-chunktextarea.module.scss */
|
|
2
|
+
.BHT__Textarea {
|
|
3
|
+
width: 100%;
|
|
4
|
+
padding: var(--spacing-2, 0.5rem) var(--spacing-3, 0.75rem);
|
|
5
|
+
font-family: var(--md-sys-typescale-body-large-font, var(--font-body));
|
|
6
|
+
font-size: var(--md-sys-typescale-body-large-size, 1rem);
|
|
7
|
+
font-weight: var(--md-sys-typescale-body-large-weight, 400);
|
|
8
|
+
line-height: var(--md-sys-typescale-body-large-line-height, 1.5rem);
|
|
9
|
+
letter-spacing: var(--md-sys-typescale-body-large-tracking, 0.0313em);
|
|
10
|
+
color: var(--md-sys-color-on-surface, var(--color-on-surface));
|
|
11
|
+
caret-color: var(--md-sys-color-primary, var(--color-primary));
|
|
12
|
+
background: transparent;
|
|
13
|
+
border: 1px solid var(--md-sys-color-outline, var(--color-border-strong));
|
|
14
|
+
border-radius: var(--md-sys-shape-corner-extra-small, 4px);
|
|
15
|
+
transition: border-color var(--md-sys-motion-duration-short-3, 150ms) var(--md-sys-motion-easing-standard, ease), box-shadow var(--md-sys-motion-duration-short-3, 150ms) var(--md-sys-motion-easing-standard, ease);
|
|
16
|
+
outline: none;
|
|
17
|
+
resize: vertical;
|
|
18
|
+
}
|
|
19
|
+
.BHT__Textarea::placeholder {
|
|
20
|
+
color: var(--md-sys-color-on-surface-variant, var(--color-text-muted));
|
|
21
|
+
}
|
|
22
|
+
.BHT__Textarea:hover:not(:disabled, :focus) {
|
|
23
|
+
border-color: var(--md-sys-color-on-surface, var(--color-on-surface));
|
|
24
|
+
}
|
|
25
|
+
.BHT__Textarea:focus {
|
|
26
|
+
border-color: var(--md-sys-color-primary, var(--color-border-focus));
|
|
27
|
+
box-shadow: inset 0 0 0 1px var(--md-sys-color-primary, var(--color-border-focus));
|
|
28
|
+
}
|
|
29
|
+
.BHT__Textarea:disabled {
|
|
30
|
+
opacity: 0.45;
|
|
31
|
+
cursor: not-allowed;
|
|
32
|
+
resize: none;
|
|
33
|
+
}
|
|
34
|
+
.BHT__Textarea[aria-invalid=true] {
|
|
35
|
+
border-color: var(--md-sys-color-error, var(--color-error));
|
|
36
|
+
caret-color: var(--md-sys-color-error, var(--color-error));
|
|
37
|
+
}
|
|
38
|
+
.BHT__Textarea[aria-invalid=true]:hover:not(:disabled, :focus) {
|
|
39
|
+
border-color: var(--md-sys-color-on-error-container, var(--color-error));
|
|
40
|
+
}
|
|
41
|
+
.BHT__Textarea[aria-invalid=true]:focus {
|
|
42
|
+
border-color: var(--md-sys-color-error, var(--color-error));
|
|
43
|
+
box-shadow: inset 0 0 0 1px var(--md-sys-color-error, var(--color-error));
|
|
44
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { TextareaHTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
5
|
+
/** Additional class names to merge with the component root element */
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Bare textarea — the native `<textarea>` is this component's own root
|
|
10
|
+
* element, no built-in label/hint/error. Wrap it in `FormField` for that
|
|
11
|
+
* chrome: `<FormField label="..." htmlFor="x"><Textarea id="x" /></FormField>`.
|
|
12
|
+
*/
|
|
13
|
+
declare const Textarea: ({ className, id, rows, ...rest }: TextareaProps) => react.JSX.Element;
|
|
14
|
+
|
|
15
|
+
export { Textarea, type TextareaProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
// ../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js
|
|
28
|
+
var require_classnames = __commonJS({
|
|
29
|
+
"../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js"(exports, module) {
|
|
30
|
+
"use strict";
|
|
31
|
+
(function() {
|
|
32
|
+
"use strict";
|
|
33
|
+
var hasOwn = {}.hasOwnProperty;
|
|
34
|
+
function classNames() {
|
|
35
|
+
var classes = "";
|
|
36
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
37
|
+
var arg = arguments[i];
|
|
38
|
+
if (arg) {
|
|
39
|
+
classes = appendClass(classes, parseValue(arg));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return classes;
|
|
43
|
+
}
|
|
44
|
+
function parseValue(arg) {
|
|
45
|
+
if (typeof arg === "string" || typeof arg === "number") {
|
|
46
|
+
return arg;
|
|
47
|
+
}
|
|
48
|
+
if (typeof arg !== "object") {
|
|
49
|
+
return "";
|
|
50
|
+
}
|
|
51
|
+
if (Array.isArray(arg)) {
|
|
52
|
+
return classNames.apply(null, arg);
|
|
53
|
+
}
|
|
54
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
55
|
+
return arg.toString();
|
|
56
|
+
}
|
|
57
|
+
var classes = "";
|
|
58
|
+
for (var key in arg) {
|
|
59
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
60
|
+
classes = appendClass(classes, key);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return classes;
|
|
64
|
+
}
|
|
65
|
+
function appendClass(value, newClass) {
|
|
66
|
+
if (!newClass) {
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
if (value) {
|
|
70
|
+
return value + " " + newClass;
|
|
71
|
+
}
|
|
72
|
+
return value + newClass;
|
|
73
|
+
}
|
|
74
|
+
if (typeof module !== "undefined" && module.exports) {
|
|
75
|
+
classNames.default = classNames;
|
|
76
|
+
module.exports = classNames;
|
|
77
|
+
} else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
|
|
78
|
+
define("classnames", [], function() {
|
|
79
|
+
return classNames;
|
|
80
|
+
});
|
|
81
|
+
} else {
|
|
82
|
+
window.classNames = classNames;
|
|
83
|
+
}
|
|
84
|
+
})();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// textarea.tsx
|
|
89
|
+
import { useId } from "react";
|
|
90
|
+
|
|
91
|
+
// ../../../../packages/registry/class-names/dist/index.js
|
|
92
|
+
var import_classnames = __toESM(require_classnames(), 1);
|
|
93
|
+
var getClassName = ({
|
|
94
|
+
className,
|
|
95
|
+
modifiers = {},
|
|
96
|
+
rootClass,
|
|
97
|
+
styles = {}
|
|
98
|
+
}) => {
|
|
99
|
+
function getModifiers() {
|
|
100
|
+
const updatedModifiers = {};
|
|
101
|
+
const modifierKeys = Object.keys(modifiers);
|
|
102
|
+
if (modifierKeys.length) {
|
|
103
|
+
modifierKeys.forEach((modKey) => {
|
|
104
|
+
const classKey = `${rootClass}--${modKey}`;
|
|
105
|
+
const newClassName = styles[classKey] || classKey;
|
|
106
|
+
updatedModifiers[newClassName] = modifiers[modKey] ?? false;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return updatedModifiers;
|
|
110
|
+
}
|
|
111
|
+
function getChildClass(childClassName) {
|
|
112
|
+
const classKey = `${rootClass}__${childClassName}`;
|
|
113
|
+
return styles[classKey] || classKey;
|
|
114
|
+
}
|
|
115
|
+
function getRootStyles() {
|
|
116
|
+
return (0, import_classnames.default)(
|
|
117
|
+
className,
|
|
118
|
+
{
|
|
119
|
+
...getModifiers()
|
|
120
|
+
},
|
|
121
|
+
styles[rootClass] || rootClass
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
return [getRootStyles(), getChildClass];
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// textarea.module.scss
|
|
128
|
+
var textarea_module_default = {
|
|
129
|
+
"BHT__Textarea": "BHT__Textarea"
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// textarea.tsx
|
|
133
|
+
import { jsx } from "react/jsx-runtime";
|
|
134
|
+
var Textarea = ({
|
|
135
|
+
className,
|
|
136
|
+
id,
|
|
137
|
+
rows = 4,
|
|
138
|
+
...rest
|
|
139
|
+
}) => {
|
|
140
|
+
const generatedId = useId();
|
|
141
|
+
const textareaId = id ?? generatedId;
|
|
142
|
+
const [rootClass] = getClassName({
|
|
143
|
+
className,
|
|
144
|
+
rootClass: "BHT__Textarea",
|
|
145
|
+
styles: textarea_module_default
|
|
146
|
+
});
|
|
147
|
+
return /* @__PURE__ */ jsx("textarea", { ...rest, id: textareaId, rows, className: rootClass });
|
|
148
|
+
};
|
|
149
|
+
export {
|
|
150
|
+
Textarea
|
|
151
|
+
};
|
|
152
|
+
/*! Bundled license information:
|
|
153
|
+
|
|
154
|
+
classnames/index.js:
|
|
155
|
+
(*!
|
|
156
|
+
Copyright (c) 2018 Jed Watson.
|
|
157
|
+
Licensed under the MIT License (MIT), see
|
|
158
|
+
http://jedwatson.github.io/classnames
|
|
159
|
+
*)
|
|
160
|
+
*/
|
package/docs.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://github.com/behivetech/bht-component-registry/docs.schema.json",
|
|
3
|
+
"version": 2,
|
|
4
|
+
"generatedAt": "2026-10-20T05:49:46.791Z",
|
|
5
|
+
"docs": [
|
|
6
|
+
{
|
|
7
|
+
"displayName": "Textarea",
|
|
8
|
+
"description": "Bare textarea — the native `<textarea>` is this component's own root\nelement, no built-in label/hint/error. Wrap it in `FormField` for that\nchrome: `<FormField label=\"...\" htmlFor=\"x\"><Textarea id=\"x\" /></FormField>`.",
|
|
9
|
+
"extendsNative": true,
|
|
10
|
+
"props": [
|
|
11
|
+
{
|
|
12
|
+
"name": "className",
|
|
13
|
+
"type": "string",
|
|
14
|
+
"required": false,
|
|
15
|
+
"defaultValue": null,
|
|
16
|
+
"description": "Additional class names to merge with the component root element"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"functions": []
|
|
22
|
+
}
|
package/index.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behivetech/atoms.textarea",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.4.2",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"private": false,
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
},
|
|
13
|
+
"./styles.css": "./dist/index.css"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"index.ts",
|
|
19
|
+
"textarea.tsx",
|
|
20
|
+
"textarea.module.scss",
|
|
21
|
+
"*.example.tsx",
|
|
22
|
+
"docs.json"
|
|
23
|
+
],
|
|
24
|
+
"registry": {
|
|
25
|
+
"status": "stable",
|
|
26
|
+
"tags": []
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": "^19.2.7",
|
|
30
|
+
"react-dom": "^19.2.7"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/react": "19.2.17",
|
|
34
|
+
"@types/react-dom": "19.2.3",
|
|
35
|
+
"eslint": "^9.39.5",
|
|
36
|
+
"tsup": "^8.5.1",
|
|
37
|
+
"typescript": "^6.0.3",
|
|
38
|
+
"vitest": "^4.1.10",
|
|
39
|
+
"@behivetech/forms.form-field": "0.3.2",
|
|
40
|
+
"@bht-component-registry/class-names": "0.0.6",
|
|
41
|
+
"@bht-component-registry/env": "0.1.0"
|
|
42
|
+
},
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/behivetech/bht-galaxy.git",
|
|
46
|
+
"directory": "registry/behivetech/atoms/textarea"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"registry": "https://registry.npmjs.org",
|
|
50
|
+
"access": "public",
|
|
51
|
+
"provenance": true
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsup && bht-registry-docgen",
|
|
55
|
+
"dev": "tsup --watch",
|
|
56
|
+
"lint": "eslint . --max-warnings 0",
|
|
57
|
+
"check-types": "tsc --noEmit",
|
|
58
|
+
"test": "vitest run"
|
|
59
|
+
}
|
|
6
60
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FormField } from "@behivetech/forms.form-field";
|
|
2
|
+
import { Textarea } from "./textarea.js";
|
|
3
|
+
|
|
4
|
+
export const BasicTextarea = () => (
|
|
5
|
+
<Textarea placeholder="Type your message..." />
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
export const TextareaWithFormField = () => (
|
|
9
|
+
<FormField label="Bio" htmlFor="bio" hint="Max 200 characters.">
|
|
10
|
+
<Textarea id="bio" rows={3} />
|
|
11
|
+
</FormField>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export const TextareaWithError = () => (
|
|
15
|
+
<FormField
|
|
16
|
+
label="Description"
|
|
17
|
+
htmlFor="description"
|
|
18
|
+
error="Description is required."
|
|
19
|
+
>
|
|
20
|
+
<Textarea id="description" aria-invalid="true" />
|
|
21
|
+
</FormField>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export const DisabledTextarea = () => (
|
|
25
|
+
<Textarea disabled value="Cannot edit this" onChange={() => {}} />
|
|
26
|
+
);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Material Design 3 outlined text field, multi-line (the input only — label
|
|
2
|
+
// and supporting text live in FormField).
|
|
3
|
+
//
|
|
4
|
+
// The 2px focus/error edge is drawn as a 1px inset shadow on top of the 1px
|
|
5
|
+
// border rather than by widening the border, so the text never shifts when the
|
|
6
|
+
// field gains focus.
|
|
7
|
+
|
|
8
|
+
.BHT__Textarea {
|
|
9
|
+
width: 100%;
|
|
10
|
+
padding: var(--spacing-2, 0.5rem) var(--spacing-3, 0.75rem);
|
|
11
|
+
font-family: var(--md-sys-typescale-body-large-font, var(--font-body));
|
|
12
|
+
font-size: var(--md-sys-typescale-body-large-size, 1rem);
|
|
13
|
+
font-weight: var(--md-sys-typescale-body-large-weight, 400);
|
|
14
|
+
line-height: var(--md-sys-typescale-body-large-line-height, 1.5rem);
|
|
15
|
+
letter-spacing: var(--md-sys-typescale-body-large-tracking, 0.0313em);
|
|
16
|
+
color: var(--md-sys-color-on-surface, var(--color-on-surface));
|
|
17
|
+
caret-color: var(--md-sys-color-primary, var(--color-primary));
|
|
18
|
+
// Outlined fields have no container fill; they take the surface they sit on.
|
|
19
|
+
background: transparent;
|
|
20
|
+
border: 1px solid var(--md-sys-color-outline, var(--color-border-strong));
|
|
21
|
+
border-radius: var(--md-sys-shape-corner-extra-small, 4px);
|
|
22
|
+
transition:
|
|
23
|
+
border-color var(--md-sys-motion-duration-short-3, 150ms)
|
|
24
|
+
var(--md-sys-motion-easing-standard, ease),
|
|
25
|
+
box-shadow var(--md-sys-motion-duration-short-3, 150ms)
|
|
26
|
+
var(--md-sys-motion-easing-standard, ease);
|
|
27
|
+
outline: none;
|
|
28
|
+
resize: vertical;
|
|
29
|
+
|
|
30
|
+
&::placeholder {
|
|
31
|
+
color: var(--md-sys-color-on-surface-variant, var(--color-text-muted));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&:hover:not(:disabled, :focus) {
|
|
35
|
+
border-color: var(--md-sys-color-on-surface, var(--color-on-surface));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&:focus {
|
|
39
|
+
border-color: var(--md-sys-color-primary, var(--color-border-focus));
|
|
40
|
+
box-shadow: inset 0 0 0 1px
|
|
41
|
+
var(--md-sys-color-primary, var(--color-border-focus));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&:disabled {
|
|
45
|
+
opacity: 0.45;
|
|
46
|
+
cursor: not-allowed;
|
|
47
|
+
resize: none;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&[aria-invalid="true"] {
|
|
51
|
+
border-color: var(--md-sys-color-error, var(--color-error));
|
|
52
|
+
caret-color: var(--md-sys-color-error, var(--color-error));
|
|
53
|
+
|
|
54
|
+
&:hover:not(:disabled, :focus) {
|
|
55
|
+
border-color: var(--md-sys-color-on-error-container, var(--color-error));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&:focus {
|
|
59
|
+
border-color: var(--md-sys-color-error, var(--color-error));
|
|
60
|
+
box-shadow: inset 0 0 0 1px var(--md-sys-color-error, var(--color-error));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
package/textarea.tsx
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type TextareaHTMLAttributes, useId } from "react";
|
|
2
|
+
import { getClassName } from "@bht-component-registry/class-names";
|
|
3
|
+
import styles from "./textarea.module.scss";
|
|
4
|
+
|
|
5
|
+
export interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
6
|
+
/** Additional class names to merge with the component root element */
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Bare textarea — the native `<textarea>` is this component's own root
|
|
12
|
+
* element, no built-in label/hint/error. Wrap it in `FormField` for that
|
|
13
|
+
* chrome: `<FormField label="..." htmlFor="x"><Textarea id="x" /></FormField>`.
|
|
14
|
+
*/
|
|
15
|
+
export const Textarea = ({
|
|
16
|
+
className,
|
|
17
|
+
id,
|
|
18
|
+
rows = 4,
|
|
19
|
+
...rest
|
|
20
|
+
}: TextareaProps) => {
|
|
21
|
+
const generatedId = useId();
|
|
22
|
+
const textareaId = id ?? generatedId;
|
|
23
|
+
|
|
24
|
+
const [rootClass] = getClassName({
|
|
25
|
+
className,
|
|
26
|
+
rootClass: "BHT__Textarea",
|
|
27
|
+
styles,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<textarea {...rest} id={textareaId} rows={rows} className={rootClass} />
|
|
32
|
+
);
|
|
33
|
+
};
|