@ea-lab/reactive-json-docs 1.2.0 → 1.3.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,297 @@
1
+ # TextAreaField
2
+
3
+ The `TextAreaField` component provides a native HTML textarea element with automatic data synchronization, combining the simplicity of native HTML with the convenience of automatic data binding. It's ideal for multi-line text input such as comments, descriptions, or longer form fields.
4
+
5
+ ## Basic Syntax
6
+
7
+ ```yaml
8
+ - type: TextAreaField
9
+ dataLocation: ~.description
10
+ label: "Description:"
11
+ placeholder: "Enter your description..."
12
+ rows: 5
13
+ ```
14
+
15
+ ## Properties
16
+
17
+ - `dataLocation` (string, optional): Path to bind the field value in the data context.
18
+ - `defaultFieldValue` (string, optional): Default value when no data is present.
19
+ - `label` (string or View props, optional): Field label text (supports template evaluation and View component rendering).
20
+ - `placeholder` (string, optional): Placeholder text (supports template evaluation).
21
+ - `rows` (number, optional): Number of visible text lines (default: `3`, supports template evaluation).
22
+ - `attributes` (object, optional): Attributes applied to the container div (or merged with inputAttributes if no wrapper).
23
+ - `inputAttributes` (object, optional): Attributes applied directly to the textarea element.
24
+ - `labelAttributes` (object, optional): Attributes applied to the label (htmlFor is automatically managed).
25
+ - `forceWrapper` (boolean, optional): Forces the presence (true) or absence (false) of the wrapper div. If omitted, wrapper is automatic only if label is present.
26
+ - `actions` (array, optional): Actions to execute based on field state.
27
+
28
+ ## Data Management
29
+
30
+ The component automatically synchronizes its value with the global data context. When `dataLocation` is used, the value is stored at the specified path. Without `dataLocation`, the value is stored in the template context using the component's `datafield`.
31
+
32
+ The textarea value is always stored as a string, preserving line breaks (`\n`) and whitespace.
33
+
34
+ ## Wrapper Control
35
+
36
+ The component uses a flexible wrapper system similar to `Input`, adapting based on the presence of a label and the `forceWrapper` property.
37
+
38
+ ### Default Behavior
39
+
40
+ When no `forceWrapper` is specified, the component automatically determines whether to use a wrapper div. If a label is present, the component wraps both the label and textarea in a div container. If no label is present, the textarea is rendered directly without a wrapper.
41
+
42
+ ### Explicit Control with `forceWrapper`
43
+
44
+ You can override the default behavior using the `forceWrapper` property. Setting `forceWrapper: true` will always create a wrapper div, even without a label. Setting `forceWrapper: false` will never create a wrapper, even when a label is present.
45
+
46
+ ### HTML Output Examples
47
+
48
+ **With label (automatic wrapper):**
49
+ ```html
50
+ <div>
51
+ <label htmlFor="textarea-abc123">Description:</label>
52
+ <textarea id="textarea-abc123" rows="5" placeholder="Enter description..."></textarea>
53
+ </div>
54
+ ```
55
+
56
+ **Without label (no wrapper):**
57
+ ```html
58
+ <textarea id="textarea-xyz789" rows="3"></textarea>
59
+ ```
60
+
61
+ **Force wrapper without label:**
62
+ ```html
63
+ <div>
64
+ <textarea id="textarea-def456" rows="4"></textarea>
65
+ </div>
66
+ ```
67
+
68
+ ### Attribute Merging
69
+
70
+ When a wrapper is present, the `attributes` are applied to the div container and `inputAttributes` are applied to the textarea element. When no wrapper is present, both `attributes` and `inputAttributes` are merged and applied to the textarea element.
71
+
72
+ ## Label Support
73
+
74
+ The `label` property supports both simple strings and View component rendering, allowing for dynamic and complex label content:
75
+
76
+ ```yaml
77
+ - type: TextAreaField
78
+ dataLocation: ~.comment
79
+ label:
80
+ type: div
81
+ content:
82
+ - "Comment ("
83
+ - type: strong
84
+ content: ~.requiredText
85
+ - "):"
86
+ rows: 5
87
+ ```
88
+
89
+ ## Rows Property
90
+
91
+ The `rows` property controls the visible height of the textarea. It supports template evaluation, allowing dynamic row counts:
92
+
93
+ ```yaml
94
+ - type: TextAreaField
95
+ dataLocation: ~.notes
96
+ rows: ~.defaultRows
97
+ ```
98
+
99
+ **Default**: If `rows` is not specified, it defaults to `3`.
100
+
101
+ ## Examples
102
+
103
+ ### Basic TextAreaField
104
+
105
+ ```yaml
106
+ renderView:
107
+ - type: TextAreaField
108
+ dataLocation: ~.description
109
+ label: "Description:"
110
+ placeholder: "Enter a description..."
111
+
112
+ data:
113
+ description: ""
114
+ ```
115
+
116
+ ### Custom Rows
117
+
118
+ ```yaml
119
+ renderView:
120
+ - type: TextAreaField
121
+ dataLocation: ~.comments
122
+ label: "Comments:"
123
+ rows: 10
124
+ placeholder: "Enter your comments here..."
125
+
126
+ data:
127
+ comments: ""
128
+ ```
129
+
130
+ ### Custom Attributes
131
+
132
+ ```yaml
133
+ renderView:
134
+ - type: TextAreaField
135
+ dataLocation: ~.notes
136
+ label: "Notes:"
137
+ rows: 5
138
+ inputAttributes:
139
+ required: true
140
+ maxLength: 500
141
+ style:
142
+ width: "100%"
143
+ resize: "vertical"
144
+ attributes:
145
+ style:
146
+ marginBottom: "10px"
147
+
148
+ data:
149
+ notes: ""
150
+ ```
151
+
152
+ ### Wrapper Control
153
+
154
+ ```yaml
155
+ renderView:
156
+ # No label → no wrapper automatically
157
+ - type: TextAreaField
158
+ dataLocation: ~.noWrapper
159
+ rows: 3
160
+ placeholder: "Textarea without wrapper"
161
+
162
+ # With label → automatic wrapper
163
+ - type: TextAreaField
164
+ dataLocation: ~.autoWrapper
165
+ label: "With automatic wrapper:"
166
+ rows: 3
167
+ placeholder: "Textarea with wrapper"
168
+
169
+ # Force wrapper even without label
170
+ - type: TextAreaField
171
+ dataLocation: ~.forceWrapper
172
+ rows: 3
173
+ placeholder: "Forced wrapper"
174
+ forceWrapper: true
175
+ attributes:
176
+ style:
177
+ border: "2px solid blue"
178
+ padding: "10px"
179
+
180
+ # No wrapper even with label
181
+ - type: TextAreaField
182
+ dataLocation: ~.noWrapperForced
183
+ label: "Label without wrapper:"
184
+ rows: 3
185
+ placeholder: "Textarea without forced wrapper"
186
+ forceWrapper: false
187
+
188
+ data:
189
+ noWrapper: ""
190
+ autoWrapper: ""
191
+ forceWrapper: ""
192
+ noWrapperForced: ""
193
+ ```
194
+
195
+ ### Custom Label Attributes
196
+
197
+ ```yaml
198
+ renderView:
199
+ - type: TextAreaField
200
+ dataLocation: ~.customLabel
201
+ label: "Custom label:"
202
+ rows: 5
203
+ labelAttributes:
204
+ style:
205
+ color: "blue"
206
+ fontWeight: "bold"
207
+ fontSize: "14px"
208
+ className: "custom-label"
209
+
210
+ data:
211
+ customLabel: ""
212
+ ```
213
+
214
+ ### Dynamic Rows
215
+
216
+ ```yaml
217
+ renderView:
218
+ - type: TextAreaField
219
+ dataLocation: ~.content
220
+ label: "Content:"
221
+ rows: ~.textareaRows
222
+ placeholder: "Enter content..."
223
+
224
+ data:
225
+ textareaRows: 6
226
+ content: ""
227
+ ```
228
+
229
+ ### With Actions
230
+
231
+ ```yaml
232
+ renderView:
233
+ - type: TextAreaField
234
+ dataLocation: ~.message
235
+ label: "Message:"
236
+ rows: 5
237
+ placeholder: "Type your message..."
238
+ actions:
239
+ - what: setData
240
+ when: ~.message
241
+ hasLength: ">0"
242
+ path: ~.hasMessage
243
+ value: true
244
+ - what: setData
245
+ when: ~.message
246
+ isEmpty: true
247
+ path: ~.hasMessage
248
+ value: false
249
+
250
+ data:
251
+ message: ""
252
+ hasMessage: false
253
+ ```
254
+
255
+ ### Preserving Line Breaks
256
+
257
+ ```yaml
258
+ renderView:
259
+ - type: TextAreaField
260
+ dataLocation: ~.multilineText
261
+ label: "Multi-line text:"
262
+ rows: 8
263
+ placeholder: "Enter text with line breaks..."
264
+ - type: div
265
+ attributes:
266
+ style:
267
+ marginTop: "20px"
268
+ padding: "10px"
269
+ backgroundColor: "#f5f5f5"
270
+ whiteSpace: "pre-wrap"
271
+ content: ~.multilineText
272
+
273
+ data:
274
+ multilineText: ""
275
+ ```
276
+
277
+ ## Advantages
278
+
279
+ - **No external dependencies**: Works without any CSS framework
280
+ - **Full control**: Custom styling and behavior
281
+ - **Performance**: Lighter than component libraries
282
+ - **Accessibility**: Direct control over ARIA attributes, automatic htmlFor
283
+ - **Automatic synchronization**: Unlike raw HTML elements that require manual setData actions
284
+ - **Flexible wrapper**: Avoids unnecessary HTML when not needed
285
+ - **Multi-line support**: Native support for multi-line text input with line break preservation
286
+ - **Dynamic rows**: Row count can be controlled via template evaluation
287
+ - **Label flexibility**: Supports both simple strings and View component rendering
288
+
289
+ ## Limitations
290
+
291
+ - No built-in validation beyond HTML5 textarea validation
292
+ - No support for rich text editing (use a specialized rich text editor component)
293
+ - No built-in character counter (can be added via actions)
294
+ - Styling must be provided via external CSS or style attributes
295
+ - Line breaks are preserved as `\n` characters; display formatting requires CSS (`white-space: pre-wrap` or similar)
296
+ - Template evaluation for `rows` should return a number
297
+
@@ -0,0 +1,139 @@
1
+ renderView:
2
+ - type: Markdown
3
+ content: |
4
+ # TextAreaField
5
+
6
+ The `TextAreaField` component provides a native HTML textarea element with automatic data synchronization, combining the simplicity of native HTML with the convenience of automatic data binding. It's ideal for multi-line text input such as comments, descriptions, or longer form fields.
7
+
8
+ - type: Markdown
9
+ content: |
10
+ ## Basic Syntax
11
+
12
+ ```yaml
13
+ - type: TextAreaField
14
+ dataLocation: ~.description
15
+ label: "Description:"
16
+ placeholder: "Enter your description..."
17
+ rows: 5
18
+ ```
19
+
20
+ ## Properties
21
+
22
+ - type: DefinitionList
23
+ content:
24
+ - term:
25
+ code: dataLocation
26
+ after: "(string, optional)"
27
+ details: "Path to bind the field value in the data context."
28
+ - term:
29
+ code: defaultFieldValue
30
+ after: "(string, optional)"
31
+ details: "Default value when no data is present."
32
+ - term:
33
+ code: label
34
+ after: "(string or View props, optional)"
35
+ details: "Field label text (supports template evaluation and View component rendering)."
36
+ - term:
37
+ code: placeholder
38
+ after: "(string, optional)"
39
+ details: "Placeholder text (supports template evaluation)."
40
+ - term:
41
+ code: rows
42
+ after: "(number, optional)"
43
+ details: "Number of visible text lines (default: `3`, supports template evaluation)."
44
+ - term:
45
+ code: attributes
46
+ after: "(object, optional)"
47
+ details: "Attributes applied to the container div (or merged with inputAttributes if no wrapper)."
48
+ - term:
49
+ code: inputAttributes
50
+ after: "(object, optional)"
51
+ details: "Attributes applied directly to the textarea element."
52
+ - term:
53
+ code: labelAttributes
54
+ after: "(object, optional)"
55
+ details: "Attributes applied to the label (htmlFor is automatically managed)."
56
+ - term:
57
+ code: forceWrapper
58
+ after: "(boolean, optional)"
59
+ details: "Forces the presence (true) or absence (false) of the wrapper div. If omitted, wrapper is automatic only if label is present."
60
+ - term:
61
+ code: actions
62
+ after: "(array, optional)"
63
+ details: "Actions to execute based on field state."
64
+
65
+ - type: Markdown
66
+ content: |
67
+ ## Data Management
68
+
69
+ The component automatically synchronizes its value with the global data context. When `dataLocation` is used, the value is stored at the specified path. Without `dataLocation`, the value is stored in the template context using the component's `datafield`.
70
+
71
+ The textarea value is always stored as a string, preserving line breaks (`\n`) and whitespace.
72
+
73
+ ## Wrapper Control
74
+
75
+ The component uses a flexible wrapper system similar to `Input`, adapting based on the presence of a label and the `forceWrapper` property.
76
+
77
+ ### Default Behavior
78
+
79
+ When no `forceWrapper` is specified, the component automatically determines whether to use a wrapper div. If a label is present, the component wraps both the label and textarea in a div container. If no label is present, the textarea is rendered directly without a wrapper.
80
+
81
+ ### Explicit Control with `forceWrapper`
82
+
83
+ You can override the default behavior using the `forceWrapper` property. Setting `forceWrapper: true` will always create a wrapper div, even without a label. Setting `forceWrapper: false` will never create a wrapper, even when a label is present.
84
+
85
+ ### Attribute Merging
86
+
87
+ When a wrapper is present, the `attributes` are applied to the div container and `inputAttributes` are applied to the textarea element. When no wrapper is present, both `attributes` and `inputAttributes` are merged and applied to the textarea element.
88
+
89
+ - type: RjBuildDescriber
90
+ title: "Basic TextAreaField"
91
+ description: "Simple multi-line text input"
92
+ toDescribe:
93
+ renderView:
94
+ - type: TextAreaField
95
+ dataLocation: ~.description
96
+ label: "Description:"
97
+ placeholder: "Enter a description..."
98
+ data:
99
+ description: ""
100
+
101
+ - type: RjBuildDescriber
102
+ title: "Custom Rows"
103
+ description: "Textarea with custom row count"
104
+ toDescribe:
105
+ renderView:
106
+ - type: TextAreaField
107
+ dataLocation: ~.comments
108
+ label: "Comments:"
109
+ rows: 10
110
+ placeholder: "Enter your comments here..."
111
+ data:
112
+ comments: ""
113
+
114
+ - type: Markdown
115
+ content: |
116
+ ## Advantages
117
+
118
+ - **No external dependencies**: Works without any CSS framework
119
+ - **Full control**: Custom styling and behavior
120
+ - **Performance**: Lighter than component libraries
121
+ - **Accessibility**: Direct control over ARIA attributes, automatic htmlFor
122
+ - **Automatic synchronization**: Unlike raw HTML elements that require manual setData actions
123
+ - **Flexible wrapper**: Avoids unnecessary HTML when not needed
124
+ - **Multi-line support**: Native support for multi-line text input with line break preservation
125
+ - **Dynamic rows**: Row count can be controlled via template evaluation
126
+ - **Label flexibility**: Supports both simple strings and View component rendering
127
+
128
+ ## Limitations
129
+
130
+ - No built-in validation beyond HTML5 textarea validation
131
+ - No support for rich text editing (use a specialized rich text editor component)
132
+ - No built-in character counter (can be added via actions)
133
+ - Styling must be provided via external CSS or style attributes
134
+ - Line breaks are preserved as `\n` characters; display formatting requires CSS (`white-space: pre-wrap` or similar)
135
+ - Template evaluation for `rows` should return a number
136
+
137
+ templates: {}
138
+ data: {}
139
+