jb-textarea 3.12.3 → 3.13.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.
Files changed (56) hide show
  1. package/README.md +240 -171
  2. package/index.js +1 -1
  3. package/package.json +20 -7
  4. package/react/README.md +93 -30
  5. package/react/dist/JBTextarea.cjs.js +65 -1
  6. package/react/dist/JBTextarea.cjs.js.map +1 -1
  7. package/react/dist/JBTextarea.d.ts +68 -30
  8. package/react/dist/JBTextarea.js +53 -1
  9. package/react/dist/JBTextarea.js.map +1 -1
  10. package/react/dist/JBTextarea.umd.js +70 -1
  11. package/react/dist/JBTextarea.umd.js.map +1 -1
  12. package/react/lib/JBTextarea.tsx +15 -32
  13. package/react/lib/attributes-hook.ts +5 -13
  14. package/react/lib/events-hook.ts +4 -4
  15. package/react/lib/module-declaration.ts +20 -0
  16. package/react/tsconfig.json +2 -2
  17. package/web-component/custom-elements.json +494 -0
  18. package/web-component/dist/jb-textarea.cjs.js +238 -0
  19. package/web-component/dist/jb-textarea.cjs.js.br +0 -0
  20. package/web-component/dist/jb-textarea.cjs.js.gz +0 -0
  21. package/web-component/dist/jb-textarea.cjs.js.map +1 -0
  22. package/web-component/dist/jb-textarea.d.ts +311 -0
  23. package/web-component/dist/jb-textarea.d.ts.map +1 -0
  24. package/web-component/dist/jb-textarea.js +241 -0
  25. package/web-component/dist/jb-textarea.js.br +0 -0
  26. package/web-component/dist/jb-textarea.js.gz +0 -0
  27. package/web-component/dist/jb-textarea.js.map +1 -0
  28. package/web-component/dist/jb-textarea.umd.js +247 -0
  29. package/web-component/dist/jb-textarea.umd.js.br +0 -0
  30. package/web-component/dist/jb-textarea.umd.js.gz +0 -0
  31. package/web-component/dist/jb-textarea.umd.js.map +1 -0
  32. package/{lib → web-component/lib}/jb-textarea.css +12 -15
  33. package/{lib → web-component/lib}/jb-textarea.ts +58 -29
  34. package/{lib → web-component/lib}/render.ts +5 -5
  35. package/web-component/lib/variables.css +99 -0
  36. package/dist/jb-textarea.cjs.js +0 -2
  37. package/dist/jb-textarea.cjs.js.br +0 -0
  38. package/dist/jb-textarea.cjs.js.gz +0 -0
  39. package/dist/jb-textarea.cjs.js.map +0 -1
  40. package/dist/jb-textarea.d.ts +0 -39
  41. package/dist/jb-textarea.d.ts.map +0 -1
  42. package/dist/jb-textarea.js +0 -2
  43. package/dist/jb-textarea.js.br +0 -0
  44. package/dist/jb-textarea.js.gz +0 -0
  45. package/dist/jb-textarea.js.map +0 -1
  46. package/dist/jb-textarea.umd.js +0 -2
  47. package/dist/jb-textarea.umd.js.br +0 -0
  48. package/dist/jb-textarea.umd.js.gz +0 -0
  49. package/dist/jb-textarea.umd.js.map +0 -1
  50. package/lib/global.d.ts +0 -15
  51. package/lib/variables.css +0 -39
  52. /package/{dist → web-component/dist}/render.d.ts +0 -0
  53. /package/{dist → web-component/dist}/render.d.ts.map +0 -0
  54. /package/{dist → web-component/dist}/types.d.ts +0 -0
  55. /package/{dist → web-component/dist}/types.d.ts.map +0 -0
  56. /package/{lib → web-component/lib}/types.ts +0 -0
package/README.md CHANGED
@@ -1,171 +1,240 @@
1
- # jb-textarea
2
-
3
- [![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/jb-textarea)
4
- [![GitHub license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://raw.githubusercontent.com/javadbat/jb-textarea/main/LICENSE)
5
- [![NPM Version](https://img.shields.io/npm/v/jb-textarea)](https://www.npmjs.com/package/jb-textarea)
6
- ![GitHub Created At](https://img.shields.io/github/created-at/javadbat/jb-textarea)
7
-
8
- Simple textarea web component to input long text
9
-
10
- - lightweight
11
- - zero dependency
12
- - advance validation with [jb-validation](https://github.com/javadbat/jb-validation) module
13
- - help you manage validation in easy way
14
- - config auto height grow ability with max height
15
- - web component so you can use it with any framework you need
16
-
17
- ## Demo
18
-
19
- - [storybook](https://javadbat.github.io/design-system/?path=/docs/components-form-elements-jbtextarea)
20
- - [codepen][https://codepen.io/javadbat/pen/poRZVXe]
21
-
22
- ## using with JS frameworks
23
-
24
- to use this component in **react** see [`jb-textarea/react`](https://github.com/javadbat/jb-textarea/tree/main/react);
25
-
26
- ## installation and setup
27
-
28
- ```sh
29
- npm i jb-textarea
30
- ```
31
-
32
- ```html
33
- <jb-textarea label="description" value="" message="text under the textarea box"></jb-textarea>
34
- ```
35
-
36
- ## get and set value
37
-
38
- ```js
39
- document.querySelector("jb-textarea").value;
40
- // return inputted text
41
- document.querySelector("jb-textarea").value = "hello";
42
- set value to hello
43
- ```
44
- ### set validation
45
-
46
- jb-textarea use [jb-validation](https://github.com/javadbat/jb-validation) inside to handle validation so for more information you can read it's documentation.
47
- for simple usage you can set validation to your input:
48
-
49
- ```js
50
- //you have 2 ways:
51
- //1- set list directly
52
- description.validation.list = [
53
- {
54
- validator: /.{3}/g,
55
- message: 'description must have 3 char at least'
56
- },
57
- //you can use function as a validator too
58
- {
59
- validator: (valueString)=>{return valueString == "hello"},
60
- message: 'you can only type hello in the box'
61
- },
62
- //you can also return string in validator if you want custom error message in some edge cases
63
- {
64
- validator: (valueString)=>{
65
- if(valueString.includes("*")){
66
- return 'you cant write * in your text'
67
- }
68
- return true;
69
- },
70
- message: 'default error when return false'
71
- },
72
- ];
73
- //2- pass a function that returns the validation list so on each validation process we execute your callback function and get the needed validation list
74
- const result = document.getElementByTagName('jb-textarea').validation.addValidationListGetter(getterFunction)
75
- ```
76
-
77
- ### check validation
78
-
79
- like any other jb design system you can access validation by `validation` property:
80
-
81
- ```js
82
- //access validation module
83
- document.getElementByTagName('jb-textarea').validation
84
- // check if input pass all the validations. showError is a boolean that determine your intent to show error to user on invalid status.
85
- const result = document.getElementByTagName('jb-textarea').validation.checkValidity(showError)
86
-
87
- ```
88
-
89
- ## events
90
-
91
- ```js
92
- document.querySelector("jb-textarea").addEventListener('change',func);
93
- document.querySelector("jb-textarea").addEventListener('keydown',func);
94
- document.querySelector("jb-textarea").addEventListener('keyup',func);
95
- document.querySelector("jb-textarea").addEventListener('keypress',func);
96
- document.querySelector("jb-textarea").addEventListener('input',func);
97
- // custom Keyboard event that raise when user press enter (unlike jb-input this enter event raise after keypress because it could be cancelled with prevent default)
98
- document.querySelector("jb-textarea").addEventListener('enter',func);
99
- ```
100
-
101
- ## auto height grow
102
-
103
- you can set `autoHeight` to true so when user type something and text overflow a textarea height component will grow by itself in boundary of `--jb-textarea-min-height` and `--jb-textarea-max-height` that you set by css variable
104
-
105
- ```js
106
- document.querySelector("jb-textarea").autoHeight = true;
107
- ```
108
-
109
- the good point of set boundary with css variable is you can set different min or max base on device by CSS media queries.
110
-
111
- ## set custom style
112
- you have 2 way to customize style,
113
-
114
- 1. using selectors like`:states` or `::part` selector
115
- ```css
116
- jb-textarea::part(label){
117
- font-size: 2rem;
118
- }
119
- jb-textarea:states(invalid)::part(label){
120
- color:red;
121
- }
122
- ```
123
- we have `label`, `textarea-box`, `textarea`, `message` as a supported part in our component. you can also combine them with `disabled`, `invalid` states for different style in different states.
124
-
125
- 2. using css variable
126
-
127
- | css variable name | description |
128
- | ------------- | ------------- |
129
- | --jb-textarea-margin | web-component margin default is `0 12px` |
130
- | --jb-textarea-border-radius | web-component border-radius |
131
- | --jb-textarea-border-width | web-component border-width default is `1px` |
132
- | --jb-textarea-border-color | border color of select in normal mode |
133
- | --jb-textarea-border-color-disabled | border color when disabled |
134
- | --jb-textarea-border-color-focus | border color of select in normal mode |
135
- | --jb-textarea-bgcolor | background color of input |
136
- | --jb-textarea-bgcolor-disabled | background color of input when disabled |
137
- | --jb-textarea-border-bottom-width | border bottom thickness default is `3px` |
138
- | --jb-textarea-label-font-size | font size of input label default is `0.8em` |
139
- | --jb-textarea-value-font-size | font size of input value default is `1.1em` |
140
- | --jb-textarea-value-color | color of value |
141
- | --jb-textarea-value-color-disabled | color of value when disabled |
142
- | --jb-textarea-message-font-size | font size of message we show under input |
143
- | --jb-textarea-message-error-color | change color of error we show under input |
144
- | --jb-textarea-min-height | minimum height of text area default is `80px` |
145
- | --jb-textarea-max-height | minimum height of text area default is `none` |
146
- | --jb-textarea-placeholder-color | placeholder color default is 'initial' |
147
- | --jb-textarea-placeholder-font-size | placeholder font-size default is `initial` |
148
- | --jb-textarea-label-color | label color |
149
- | --jb-textarea-label-color-disabled | label color when disabled |
150
-
151
- ## add custom element in textarea box
152
-
153
- in jb-textarea you can put icon or any other custom html DOM in textarea box. to doing so you just have to place custom DOM in `jb-textarea` tag and add `slot="inline-start-section"` or `slot="inline-end-section"` or `slot="block-start-section"` or `slot="block-end-section"` to place it before or after input field.
154
- example:
155
-
156
- ```HTML
157
- <jb-textarea>
158
- <div slot="inline-start-section">before</div>
159
- <div slot="inline-end-section">after</div>
160
- <div slot="block-start-section">in Top</div>
161
- <div slot="block-end-section">in Bottom</div>
162
- </jb-textarea>
163
- ```
164
-
165
- ## Other Related Docs:
166
-
167
- - see [`jb-textarea/react`](https://github.com/javadbat/jb-textarea/tree/main/react) if you want to use this component in react.
168
-
169
- - see [All JB Design system Component List](https://javadbat.github.io/design-system/) for more components.
170
-
171
- - use [Contribution Guide](https://github.com/javadbat/design-system/blob/main/docs/contribution-guide.md) if you want to contribute in this component.
1
+ # jb-textarea
2
+
3
+ [![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/jb-textarea)
4
+ [![GitHub license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://raw.githubusercontent.com/javadbat/jb-textarea/main/LICENSE)
5
+ [![NPM Version](https://img.shields.io/npm/v/jb-textarea)](https://www.npmjs.com/package/jb-textarea)
6
+ ![GitHub Created At](https://img.shields.io/github/created-at/javadbat/jb-textarea)
7
+
8
+ Simple textarea web component to input long text
9
+
10
+ - lightweight
11
+ - zero dependency
12
+ - advance validation with [jb-validation](https://github.com/javadbat/jb-validation) module
13
+ - help you manage validation in easy way
14
+ - config auto height grow ability with max height
15
+ - web component so you can use it with any framework you need
16
+
17
+ ## When to use
18
+
19
+ Use `jb-textarea` when the user needs to enter multi-line text, long descriptions, comments, notes, or any free-form text that can span multiple lines.
20
+
21
+ Use `jb-input` for single-line text fields.
22
+
23
+ ## Demo
24
+
25
+ - [storybook](https://javadbat.github.io/design-system/?path=/docs/components-form-elements-jbtextarea)
26
+ - [codepen](https://codepen.io/javadbat/pen/poRZVXe)
27
+
28
+ ## Using With JS Frameworks
29
+ - [<img src="https://img.shields.io/badge/React.js-jb--textarea%2Freact-000.svg?logo=react&logoColor=%2361DAFB" height="30" />](https://github.com/javadbat/jb-textarea/tree/main/react)
30
+
31
+ ## Installation
32
+
33
+ ```sh
34
+ npm i jb-textarea
35
+ ```
36
+
37
+ ```html
38
+ <jb-textarea label="description" value="" message="text under the textarea box"></jb-textarea>
39
+ ```
40
+
41
+ ## API reference
42
+
43
+ ### Attributes
44
+
45
+ | name | type | default | description |
46
+ | --- | --- | --- | --- |
47
+ | [`value`](#get-and-set-value) | `string` | `""` | Initial textarea value from markup. Prefer the property for runtime updates. |
48
+ | `label` | `string` | `""` | Visible label text and accessible aria label. |
49
+ | `message` | `string` | `""` | Helper text shown below the textarea when no validation error is visible. |
50
+ | `name` | `string` | `""` | Form field name. |
51
+ | `placeholder` | `string` | `""` | Placeholder forwarded to the inner textarea. |
52
+ | [`required`](#set-validation) | `boolean` | `false` | Enables required validation. |
53
+ | [`error`](#set-validation) | `string` | `""` | External validation error message. |
54
+
55
+ ### Properties
56
+
57
+ | name | type | readonly | description |
58
+ | --- | --- | --- | --- |
59
+ | [`value`](#get-and-set-value) | `string` | no | Canonical textarea value submitted with forms. |
60
+ | [`autoHeight`](#auto-height-grow) | `boolean` | no | Lets the textarea grow between configured min and max height. |
61
+ | `validation` | `ValidationHelper<string>` | yes | Validation helper from `jb-validation`; set `validation.list` for custom rules. |
62
+ | `disabled` | `boolean` | no | Disables the inner textarea and sets the `disabled` custom state. |
63
+ | `required` | `boolean` | no | Enables required validation. |
64
+ | `initialValue` | `string` | no | Baseline value used by `isDirty`. |
65
+ | `isDirty` | `boolean` | yes | `true` when current `value` differs from `initialValue`. |
66
+ | `validationMessage` | `string` | yes | Current native validation message from `ElementInternals`. |
67
+
68
+ ### Methods
69
+
70
+ | name | returns | description |
71
+ | --- | --- | --- |
72
+ | `checkValidity()` | `boolean` | Runs validation without showing the error message. Dispatches `invalid` when invalid. |
73
+ | `reportValidity()` | `boolean` | Runs validation and shows the first error message. Dispatches `invalid` when invalid. |
74
+
75
+ ## get and set value
76
+
77
+ ```js
78
+ document.querySelector("jb-textarea").value;
79
+ // return inputted text
80
+ document.querySelector("jb-textarea").value = "hello";
81
+ set value to hello
82
+ ```
83
+ ### set validation
84
+
85
+ jb-textarea use [jb-validation](https://github.com/javadbat/jb-validation) inside to handle validation so for more information you can read it's documentation.
86
+ for simple usage you can set validation to your input:
87
+
88
+ ```js
89
+ //you have 2 ways:
90
+ //1- set list directly
91
+ description.validation.list = [
92
+ {
93
+ validator: /.{3}/g,
94
+ message: 'description must have 3 char at least'
95
+ },
96
+ //you can use function as a validator too
97
+ {
98
+ validator: (valueString)=>{return valueString == "hello"},
99
+ message: 'you can only type hello in the box'
100
+ },
101
+ //you can also return string in validator if you want custom error message in some edge cases
102
+ {
103
+ validator: (valueString)=>{
104
+ if(valueString.includes("*")){
105
+ return 'you cant write * in your text'
106
+ }
107
+ return true;
108
+ },
109
+ message: 'default error when return false'
110
+ },
111
+ ];
112
+ //2- pass a function that returns the validation list so on each validation process we execute your callback function and get the needed validation list
113
+ const result = document.querySelector('jb-textarea').validation.addValidationListGetter(getterFunction)
114
+ ```
115
+
116
+ ### check validation
117
+
118
+ like any other jb design system you can access validation by `validation` property:
119
+
120
+ ```js
121
+ //access validation module
122
+ document.querySelector('jb-textarea').validation
123
+ // check if input pass all the validations. showError is a boolean that determine your intent to show error to user on invalid status.
124
+ const result = document.querySelector('jb-textarea').validation.checkValidity({showError})
125
+
126
+ ```
127
+
128
+ ## Events
129
+
130
+ | event | cancelable | when it fires |
131
+ | --- | --- | --- |
132
+ | `input` | native behavior | On each user edit after `value` is updated. |
133
+ | `beforeinput` | yes | Before the inner textarea value changes. Call `event.preventDefault()` to block the edit. |
134
+ | `change` | yes | When the user commits the textarea value. |
135
+ | `keydown` | yes | Re-dispatched from the inner textarea. |
136
+ | `keyup` | yes | Re-dispatched from the inner textarea. |
137
+ | `keypress` | yes | Re-dispatched from the inner textarea. |
138
+ | `enter` | yes | From `keypress` when Enter is pressed. |
139
+ | `invalid` | no | When `checkValidity()` or `reportValidity()` finds an invalid value. |
140
+
141
+ ```js
142
+ document.querySelector("jb-textarea").addEventListener('change',func);
143
+ document.querySelector("jb-textarea").addEventListener('keydown',func);
144
+ document.querySelector("jb-textarea").addEventListener('keyup',func);
145
+ document.querySelector("jb-textarea").addEventListener('keypress',func);
146
+ document.querySelector("jb-textarea").addEventListener('input',func);
147
+ // custom Keyboard event that raise when user press enter (unlike jb-input this enter event raise after keypress because it could be cancelled with prevent default)
148
+ document.querySelector("jb-textarea").addEventListener('enter',func);
149
+ ```
150
+
151
+ ## auto height grow
152
+
153
+ you can set `autoHeight` to true so when user type something and text overflow a textarea height component will grow by itself in boundary of `--jb-textarea-min-height` and `--jb-textarea-max-height` that you set by CSS variable
154
+
155
+ ```js
156
+ document.querySelector("jb-textarea").autoHeight = true;
157
+ ```
158
+
159
+ the good point of set boundary with CSS variable is you can set different min or max based on device by CSS media queries.
160
+
161
+ ## set custom style
162
+ you have 2 way to customize style,
163
+
164
+ 1. using selectors like`:states` or `::part` selector
165
+ ```css
166
+ jb-textarea::part(label){
167
+ font-size: 2rem;
168
+ }
169
+ jb-textarea:states(invalid)::part(label){
170
+ color:red;
171
+ }
172
+ jb-textarea:states(invalid)::part(textarea-box){
173
+ border-color:red;
174
+ }
175
+ jb-textarea:states(disabled)::part(textarea){
176
+ cursor:not-allowed;
177
+ }
178
+ ```
179
+ we have `label`, `textarea-box`, `textarea`, `message`, `inline-start-section-wrapper`, `inline-end-section-wrapper`, `block-start-section-wrapper`, and `block-end-section-wrapper` as supported parts in our component. you can also combine them with `disabled`, `invalid` states for different style in different states.
180
+
181
+ 2. using CSS variable
182
+
183
+ For complete styling guidance, live examples, official parts, custom states, and copyable style recipes, see [Styling](https://javadbat.github.io/design-system/?path=/docs/components-form-elements-jbtextarea-styling).
184
+
185
+ ## add custom element in textarea box
186
+
187
+ in jb-textarea you can put icon or any other custom html DOM in textarea box. to doing so you just have to place custom DOM in `jb-textarea` tag and add `slot="inline-start-section"` or `slot="inline-end-section"` or `slot="block-start-section"` or `slot="block-end-section"` to place it before or after input field.
188
+
189
+ | slot | description |
190
+ | --- | --- |
191
+ | `inline-start-section` | Inline content before the textarea. |
192
+ | `inline-end-section` | Inline content after the textarea. |
193
+ | `block-start-section` | Block content above the textarea inside the textarea box. |
194
+ | `block-end-section` | Block content below the textarea inside the textarea box. |
195
+
196
+ example:
197
+
198
+ ```HTML
199
+ <jb-textarea>
200
+ <div slot="inline-start-section">before</div>
201
+ <div slot="inline-end-section">after</div>
202
+ <div slot="block-start-section">in Top</div>
203
+ <div slot="block-end-section">in Bottom</div>
204
+ </jb-textarea>
205
+ ```
206
+
207
+ ## Accessibility notes
208
+
209
+ - The component is form-associated and submits `value` as its form value.
210
+ - `label` is exposed as the component aria label.
211
+ - `message` is exposed as the component aria description when no validation error is visible.
212
+ - `placeholder` is forwarded to the inner textarea and exposed as aria placeholder.
213
+ - `disabled`, `invalid`, and validation state are synchronized with `ElementInternals` where the browser supports it.
214
+ - The shadow root uses `delegatesFocus`, so focusing `<jb-textarea>` focuses the inner native textarea.
215
+
216
+ ## Related Docs
217
+ - see [`jb-textarea/react`](https://github.com/javadbat/jb-textarea/tree/main/react) if you want to use this component in react.
218
+
219
+ - see [All JB Design system Component List](https://javadbat.github.io/design-system/) for more components.
220
+
221
+ - use [Contribution Guide](https://github.com/javadbat/design-system/blob/main/docs/contribution-guide.md) if you want to contribute in this component.
222
+
223
+ ## AI agent notes
224
+
225
+ This package includes [`custom-elements.json`](./custom-elements.json) so documentation tools, IDEs, and AI coding agents can discover the tag name, attributes, properties, events, slots, CSS parts, CSS variables, and public methods.
226
+
227
+ The package also exposes `"customElements": "custom-elements.json"` in `package.json`, which gives tools a stable package-level pointer to the manifest. This field is documented by the Custom Elements Manifest project in its [Referencing manifests from npm packages](https://github.com/webcomponents/custom-elements-manifest#referencing-manifests-from-npm-packages) section.
228
+
229
+ In `custom-elements.json`, the `exports` array describes what this module makes available:
230
+
231
+ | kind | meaning |
232
+ | --- | --- |
233
+ | `js` | A JavaScript/TypeScript export from the module, such as `JBTextareaWebComponent`. |
234
+ | `custom-element-definition` | The custom element registration for a tag name, such as `jb-textarea`. |
235
+
236
+ - Import `jb-textarea` once before using `<jb-textarea>`.
237
+ - Use `jb-textarea` for multi-line text and `jb-input` for single-line text.
238
+ - Use `.value` for the canonical submitted text.
239
+ - Use `autoHeight` when the textarea should grow with content, and control bounds with `--jb-textarea-min-height` and `--jb-textarea-max-height`.
240
+ - Set `error` for externally controlled validation errors; the component observes the attribute and updates its validation UI.
package/index.js CHANGED
@@ -1 +1 @@
1
- export * from './dist/jb-textarea.js';
1
+ export * from './web-component/dist/jb-textarea.js';
package/package.json CHANGED
@@ -14,27 +14,40 @@
14
14
  "web component",
15
15
  "web-component"
16
16
  ],
17
- "version": "3.12.3",
17
+ "version": "3.13.0",
18
18
  "bugs": "https://github.com/javadbat/jb-textarea/issues",
19
19
  "homepage": "https://javadbat.github.io/design-system/?path=/docs/components-form-elements-jbtextarea",
20
20
  "license": "MIT",
21
21
  "files": [
22
22
  "LICENSE",
23
23
  "README.md",
24
- "lib/",
25
- "dist/",
24
+ "web-component/custom-elements.json",
25
+ "web-component/lib/",
26
+ "web-component/dist/",
26
27
  "react/",
27
28
  "react/dist/"
28
29
  ],
29
30
  "main": "index.js",
30
- "types": "./dist/jb-textarea.d.ts",
31
+ "types": "./web-component/dist/jb-textarea.d.ts",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./web-component/dist/jb-textarea.d.ts",
35
+ "default": "./index.js"
36
+ },
37
+ "./react": {
38
+ "types": "./react/dist/JBTextarea.d.ts",
39
+ "default": "./react/index.js"
40
+ },
41
+ "./*": "./*"
42
+ },
43
+ "customElements": "web-component/custom-elements.json",
31
44
  "repository": {
32
45
  "type": "git",
33
46
  "url": "git@github.com:javadbat/jb-textarea.git"
34
47
  },
35
48
  "dependencies": {
36
- "jb-validation":">=0.4.0",
37
- "jb-core":">=0.24.0",
38
- "jb-form":">=0.7.1"
49
+ "jb-validation":">=1.0.0",
50
+ "jb-core":">=0.30.0",
51
+ "jb-form":">=0.12.0"
39
52
  }
40
53
  }
package/react/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # jb-textarea-react
2
2
 
3
+ [![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/jb-textarea)
4
+ [![GitHub license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://raw.githubusercontent.com/javadbat/jb-textarea/main/LICENSE)
5
+ [![NPM Version](https://img.shields.io/npm/v/jb-textarea-react)](https://www.npmjs.com/package/jb-textarea-react)
6
+ ![GitHub Created At](https://img.shields.io/github/created-at/javadbat/jb-textarea)
7
+
3
8
  simple textarea react component to input long text
4
9
 
5
10
  - lightweight
@@ -7,12 +12,11 @@ simple textarea react component to input long text
7
12
  - help you manage validation in easy way
8
13
  - config auto height grow ability with max height
9
14
 
10
- - [codeSandbox preview](https://3f63dj.csb.app/samples/jb-textarea) for just see the demo and [codeSandbox editor](https://codesandbox.io/p/sandbox/jb-design-system-3f63dj?file=%2Fsrc%2Fsamples%2FJBTextarea.tsx) if you want to see and play with code
11
-
12
- - [storybook](https://javadbat.github.io/design-system/?path=/docs/components-form-elements-jbtextarea)
13
-
14
- ## installation and setup
15
+ - [codeSandbox preview](https://3f63dj.csb.app/samples/jb-textarea) for just see the demo and [codeSandbox editor](https://codesandbox.io/p/sandbox/jb-design-system-3f63dj?file=%2Fsrc%2Fsamples%2FJBTextarea.tsx) if you want to see and play with code
16
+
17
+ Storybook: [JBTextarea docs](https://javadbat.github.io/design-system/?path=/docs/components-form-elements-jbtextarea)
15
18
 
19
+ ## Installation
16
20
  ```sh
17
21
  npm i jb-textarea-react
18
22
  ```
@@ -20,8 +24,27 @@ npm i jb-textarea-react
20
24
  ```jsx
21
25
  import {JBTextarea} from 'jb-textarea/react';
22
26
 
23
- <JBTextarea label="label" value={valueState} message="text under the box"></JBTextarea>
24
- ```
27
+ <JBTextarea label="label" value={valueState} message="text under the box"></JBTextarea>
28
+ ```
29
+
30
+ ## When to use
31
+
32
+ Use `JBTextarea` when the user needs to enter multi-line text, long descriptions, comments, notes, or any free-form text that can span multiple lines.
33
+
34
+ ## Props
35
+
36
+ | prop | type | description |
37
+ | --- | --- | --- |
38
+ | `value` | `string \| null \| undefined` | Controlled textarea value. `null` and `undefined` are normalized to an empty string. |
39
+ | `label` | `string` | Visible label text and accessible label. |
40
+ | `message` | `string` | Helper text shown when no validation error is visible. |
41
+ | `name` | `string` | Form field name. |
42
+ | `placeholder` | `string` | Placeholder forwarded to the inner textarea. |
43
+ | `validationList` | `ValidationItem<ValidationValue>[]` | Custom validation rules from `jb-validation`. |
44
+ | `autoHeight` | `boolean` | Lets the textarea grow between configured min and max height. |
45
+ | `required` | `boolean` | Enables required validation. |
46
+ | `error` | `string` | External validation error message. |
47
+ | `disabled` | `boolean` | Disables the textarea. |
25
48
 
26
49
  ## get and set value
27
50
 
@@ -69,36 +92,76 @@ you can check if an input value meet your validation standard by creating a ref
69
92
  if `isValid` is `true` the value of input is valid.
70
93
 
71
94
 
72
- ## events
73
-
74
- ```JSX
75
- <JBTextarea onChange={(e)=>{}}></JBTextarea>
76
- <JBTextarea onKeydown={(e)=>{}}></JBTextarea>
77
- <JBTextarea onKeyup={(e)=>{}}></JBTextarea>
78
- <JBTextarea onKeypress={(e)=>{}}></JBTextarea>
79
- <JBTextarea onInput={(e)=>{}}></JBTextarea>
80
- // custom event for when user press enter
81
- <JBTextarea onEnter={(e)=>{}}></JBTextarea>
82
- ```
95
+ ## Events
96
+ ```JSX
97
+ <JBTextarea onChange={(e)=>{}}></JBTextarea>
98
+ <JBTextarea onKeyDown={(e)=>{}}></JBTextarea>
99
+ <JBTextarea onKeyUp={(e)=>{}}></JBTextarea>
100
+ <JBTextarea onBeforeInput={(e)=>{}}></JBTextarea>
101
+ <JBTextarea onInput={(e)=>{}}></JBTextarea>
102
+ <JBTextarea onFocus={(e)=>{}}></JBTextarea>
103
+ <JBTextarea onBlur={(e)=>{}}></JBTextarea>
104
+ // custom event for when user press enter
105
+ <JBTextarea onEnter={(e)=>{}}></JBTextarea>
106
+ ```
107
+
108
+ | prop | event |
109
+ | --- | --- |
110
+ | `onChange` | `change` |
111
+ | `onInput` | `input` |
112
+ | `onBeforeInput` | `beforeinput` |
113
+ | `onKeyDown` | `keydown` |
114
+ | `onKeyUp` | `keyup` |
115
+ | `onFocus` | `focus` |
116
+ | `onBlur` | `blur` |
117
+ | `onEnter` | `enter` |
118
+ | `onLoad` | `load` |
119
+ | `onInit` | `init` |
83
120
 
84
121
  ## auto height grow
85
122
 
86
- you can set `autoHeight` to true so when user type something and text overflow a textarea height component will grow by itself in boundary of `--jb-textarea-min-height` and `--jb-textarea-max-height` that you set by css variable
123
+ you can set `autoHeight` to true so when user type something and text overflow a textarea height component will grow by itself in boundary of `--jb-textarea-min-height` and `--jb-textarea-max-height` that you set by CSS variable
87
124
 
88
125
  ```js
89
126
  <JBTextarea autoHeight></JBTextarea>
90
127
  ```
91
128
 
92
- the good point of set boundary with css variable is you can set different min or max base on device by CSS media queries.
93
-
94
- ## set custom style
95
-
96
- see see [jb-textarea](https://github.com/javadbat/jb-textarea) document. there is no difference between these 2 in styling.
97
-
98
- ## Other Related Docs:
99
-
129
+ the good point of set boundary with CSS variable is you can set different min or max based on device by CSS media queries.
130
+
131
+ ## set custom style
132
+
133
+ see see [jb-textarea](https://github.com/javadbat/jb-textarea) document. there is no difference between these 2 in styling.
134
+
135
+ ## add custom element in textarea box
136
+
137
+ Pass custom prefix or suffix content as children with `slot="start-section"` or `slot="end-section"`.
138
+
139
+ ```jsx
140
+ <JBTextarea label="Description">
141
+ <span slot="start-section">Notes</span>
142
+ <span slot="end-section">optional</span>
143
+ </JBTextarea>
144
+ ```
145
+
146
+ ## Accessibility notes
147
+
148
+ Set `label` for the textarea name and use `message` for helper text. When `autoHeight` is enabled, keep the configured max height large enough that keyboard users can still review entered content comfortably.
149
+
150
+ ## Shared Documentation
151
+
152
+ For web-component behavior, events, slots, and CSS variables, see [`jb-textarea`](https://github.com/javadbat/jb-textarea).
153
+
154
+ ## Related Docs
100
155
  - see [jb-textarea](https://github.com/javadbat/jb-textarea) if you want to use this component as a web-component in other frameworks.
101
156
 
102
- - see [All JB Design system Component List](https://javadbat.github.io/design-system/) for more components.
103
-
104
- - use [Contribution Guide](https://github.com/javadbat/design-system/blob/main/docs/contribution-guide.md) if you want to contribute in this component.
157
+ - see [All JB Design system Component List](https://javadbat.github.io/design-system/) for more components.
158
+
159
+ - use [Contribution Guide](https://github.com/javadbat/design-system/blob/main/docs/contribution-guide.md) if you want to contribute in this component.
160
+
161
+ ## AI agent notes
162
+
163
+ - Import `JBTextarea` from `jb-textarea/react`; the wrapper imports and registers the underlying `jb-textarea` web component.
164
+ - Use `value` for controlled text and `onChange` or `onInput` to update React state.
165
+ - Use `autoHeight` for growing textareas and CSS variables for min/max height.
166
+ - Use exact React prop casing such as `onKeyDown`, `onKeyUp`, and `onBeforeInput`.
167
+ - Use `error` for externally controlled validation errors.