@app-studio/components 0.10.26 → 0.10.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +195 -65
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.view.js +1 -1
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.view.js.map +1 -1
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.view.native.js +1 -1
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.view.native.js.map +1 -1
- package/dist/native/components/Avatar/Avatar/Avatar.props.d.ts +2 -1
- package/dist/native/components/ChatInput/ChatInput/ChatInput.props.d.ts +57 -0
- package/dist/native/components/ChatInput/ChatInput/ChatInput.state.d.ts +2 -0
- package/dist/native/components/ChatInput/ChatInput/ChatInput.state.js +18 -0
- package/dist/native/components/ChatInput/ChatInput/ChatInput.state.js.map +1 -1
- package/dist/native/components/ChatInput/ChatInput/ChatInput.type.d.ts +1 -0
- package/dist/native/components/ChatInput/ChatInput/ChatInput.view.js +5 -2
- package/dist/native/components/ChatInput/ChatInput/ChatInput.view.js.map +1 -1
- package/dist/native/components/ChatInput/ChatInput.d.ts +2 -2
- package/dist/native/components/ChatInput/ChatInput.js +16 -1
- package/dist/native/components/ChatInput/ChatInput.js.map +1 -1
- package/dist/native/components/ChatInput/EditableInput.d.ts +5 -0
- package/dist/native/components/ChatInput/EditableInput.js +74 -5
- package/dist/native/components/ChatInput/EditableInput.js.map +1 -1
- package/dist/native/components/ChatInput/EditableInput.native.d.ts +5 -0
- package/dist/native/components/ChatInput/EditableInput.native.js +4 -2
- package/dist/native/components/ChatInput/EditableInput.native.js.map +1 -1
- package/dist/native/components/Command/Command/CommandOverlay.js +1 -1
- package/dist/native/components/Command/Command/CommandOverlay.js.map +1 -1
- package/dist/native/components/ContextMenu/ContextMenu/ContextMenu.view.native.js +1 -1
- package/dist/native/components/ContextMenu/ContextMenu/ContextMenu.view.native.js.map +1 -1
- package/dist/native/components/Drawer/Drawer/Drawer.view.js +1 -1
- package/dist/native/components/Drawer/Drawer/Drawer.view.js.map +1 -1
- package/dist/native/components/Drawer/Drawer/Drawer.view.native.js +1 -1
- package/dist/native/components/Drawer/Drawer/Drawer.view.native.js.map +1 -1
- package/dist/native/components/EmojiPicker/EmojiPicker/EmojiPicker.view.js +1 -1
- package/dist/native/components/EmojiPicker/EmojiPicker/EmojiPicker.view.js.map +1 -1
- package/dist/native/components/EmojiPicker/EmojiPicker/EmojiPicker.view.native.js +1 -1
- package/dist/native/components/EmojiPicker/EmojiPicker/EmojiPicker.view.native.js.map +1 -1
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.props.d.ts +2 -2
- package/dist/native/components/Form/ColorInput/ColorInput/ColorInput.props.d.ts +4 -4
- package/dist/native/components/Form/ColorInput/ColorInput/ColorInput.view.js +14 -3
- package/dist/native/components/Form/ColorInput/ColorInput/ColorInput.view.js.map +1 -1
- package/dist/native/components/Form/ColorInput/ColorInput/ColorInput.view.native.js +1 -3
- package/dist/native/components/Form/ColorInput/ColorInput/ColorInput.view.native.js.map +1 -1
- package/dist/native/components/Form/CountryPicker/CountryPicker/CountryPicker.props.d.ts +11 -6
- package/dist/native/components/Form/CountryPicker/CountryPicker/CountryPicker.view.js +3 -1
- package/dist/native/components/Form/CountryPicker/CountryPicker/CountryPicker.view.js.map +1 -1
- package/dist/native/components/Form/DatePicker/DatePicker/DatePicker.props.d.ts +5 -3
- package/dist/native/components/Form/Password/example/ErrorInput.js +6 -4
- package/dist/native/components/Form/Password/example/ErrorInput.js.map +1 -1
- package/dist/native/components/Form/Password/example/HelperText.js +6 -4
- package/dist/native/components/Form/Password/example/HelperText.js.map +1 -1
- package/dist/native/components/Form/Radio/Radio/Radio.props.d.ts +2 -2
- package/dist/native/components/Form/Radio/Radio/Radio.view.js +4 -2
- package/dist/native/components/Form/Radio/Radio/Radio.view.js.map +1 -1
- package/dist/native/components/Form/Radio/Radio/Radio.view.native.js +4 -2
- package/dist/native/components/Form/Radio/Radio/Radio.view.native.js.map +1 -1
- package/dist/native/components/Form/Select/Select/Select.props.d.ts +35 -15
- package/dist/native/components/Form/Select/Select/Select.state.d.ts +2 -2
- package/dist/native/components/Form/Select/Select/Select.state.js +48 -13
- package/dist/native/components/Form/Select/Select/Select.state.js.map +1 -1
- package/dist/native/components/Form/Select/Select/Select.view.js +59 -8
- package/dist/native/components/Form/Select/Select/Select.view.js.map +1 -1
- package/dist/native/components/Form/Select/Select/Select.view.native.js +6 -2
- package/dist/native/components/Form/Select/Select/Select.view.native.js.map +1 -1
- package/dist/native/components/Form/Select/Select.js +5 -1
- package/dist/native/components/Form/Select/Select.js.map +1 -1
- package/dist/native/components/Form/Selector/Selector/Selector.props.d.ts +17 -12
- package/dist/native/components/Form/Switch/Switch/Switch.props.d.ts +3 -3
- package/dist/native/components/Form/TextArea/TextArea/TextArea.props.d.ts +23 -7
- package/dist/native/components/Form/TextArea/TextArea/TextArea.view.js +9 -10
- package/dist/native/components/Form/TextArea/TextArea/TextArea.view.js.map +1 -1
- package/dist/native/components/Form/TextField/TextField/TextField.props.d.ts +26 -7
- package/dist/native/components/Form/TextField/TextField/TextField.view.js +8 -8
- package/dist/native/components/Form/TextField/TextField/TextField.view.js.map +1 -1
- package/dist/native/components/Formik/Formik.ChatInput.js +4 -1
- package/dist/native/components/Formik/Formik.ChatInput.js.map +1 -1
- package/dist/native/components/Formik/Formik.Select.js +6 -2
- package/dist/native/components/Formik/Formik.Select.js.map +1 -1
- package/dist/native/components/Link/Link/Link.props.d.ts +1 -1
- package/dist/native/components/Message/Message/Message.props.d.ts +4 -4
- package/dist/native/components/Message/Message/Message.type.d.ts +1 -1
- package/dist/native/components/Modal/Modal/Modal.style.js +1 -1
- package/dist/native/components/Modal/Modal/Modal.style.js.map +1 -1
- package/dist/native/components/Modal/Modal/Modal.view.js +2 -2
- package/dist/native/components/Modal/Modal/Modal.view.js.map +1 -1
- package/dist/native/components/Modal/Modal/Modal.view.native.js +1 -1
- package/dist/native/components/Modal/Modal/Modal.view.native.js.map +1 -1
- package/dist/native/components/OTPInput/OTPInput/OTPInput.props.d.ts +1 -1
- package/dist/native/components/OTPInput/OTPInput/OTPInput.state.d.ts +1 -1
- package/dist/native/components/OTPInput/OTPInput/OTPInput.state.js +9 -3
- package/dist/native/components/OTPInput/OTPInput/OTPInput.state.js.map +1 -1
- package/dist/native/components/Sidebar/Sidebar/Sidebar.view.js +1 -1
- package/dist/native/components/Sidebar/Sidebar/Sidebar.view.js.map +1 -1
- package/dist/native/components/Table/Table/Table.context.d.ts +2 -2
- package/dist/native/components/Table/Table/Table.context.js.map +1 -1
- package/dist/native/components/Table/Table/Table.props.d.ts +1 -1
- package/dist/native/components/Tabs/Tabs/Tabs.props.d.ts +6 -2
- package/dist/native/components/Toast/Toast/Toast.view.js +1 -1
- package/dist/native/components/Toast/Toast/Toast.view.js.map +1 -1
- package/dist/web.cjs.js +9 -9
- package/dist/web.cjs.js.map +1 -1
- package/dist/web.esm.js +5760 -5617
- package/dist/web.esm.js.map +1 -1
- package/dist/web.umd.js +10 -10
- package/dist/web.umd.js.map +1 -1
- package/docs/components/ChatInput.mdx +224 -0
- package/docs/components/Select.mdx +36 -0
- package/docs/components/TextArea.mdx +7 -4
- package/docs/components/TextField.mdx +8 -5
- package/package.json +3 -2
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# ChatInput
|
|
2
|
+
|
|
3
|
+
A chat composer with file attachments, prompt examples, `@` mentions, suggestions, audio recording and agent controls.
|
|
4
|
+
|
|
5
|
+
### **Import**
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { ChatInput } from '@app-studio/components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### **Default**
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import React, { useState } from 'react';
|
|
15
|
+
import { Vertical } from '@app-studio/components';
|
|
16
|
+
import { ChatInput } from '@app-studio/components';
|
|
17
|
+
|
|
18
|
+
export const DefaultChatInput = () => {
|
|
19
|
+
const [value, setValue] = useState('');
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Vertical gap={20}>
|
|
23
|
+
<ChatInput
|
|
24
|
+
value={value}
|
|
25
|
+
onChange={setValue}
|
|
26
|
+
onSubmit={(message) => {
|
|
27
|
+
console.log('submitted', message);
|
|
28
|
+
setValue('');
|
|
29
|
+
}}
|
|
30
|
+
placeholder="Type your message… use @ to mention"
|
|
31
|
+
/>
|
|
32
|
+
</Vertical>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## The input is a `contentEditable` div, not a `<textarea>`
|
|
38
|
+
|
|
39
|
+
This is worth stating plainly, because it changes how you drive the component from outside React.
|
|
40
|
+
|
|
41
|
+
The visible field rendered by `ChatInput` — the one you style through `views.editableInput` — is:
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<div contenteditable="true" role="textbox" aria-multiline="true">…</div>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
A `contentEditable` element is a deliberate choice for a rich composer (inline mentions, pasted rich
|
|
48
|
+
content, custom carets), but it is **not a form control**: it has no `value` property, it does not take
|
|
49
|
+
part in native form submission, and generic code that fills or reads "an input" — test runners, session
|
|
50
|
+
replay, automation, autofill, draft restoration — will silently do nothing or throw against it.
|
|
51
|
+
|
|
52
|
+
So the component also renders a **hidden mirror `<textarea>`** that always carries the same text.
|
|
53
|
+
|
|
54
|
+
### **Hidden mirror `<textarea>`**
|
|
55
|
+
|
|
56
|
+
The mirror is rendered by default, is `aria-hidden` and not focusable (screen readers only ever see the
|
|
57
|
+
real `role="textbox"`), and is marked with `data-editable-input-mirror="true"`. Give it a `name` to
|
|
58
|
+
make it addressable and submittable:
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
<ChatInput name="message" value={value} onChange={setValue} />
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Reading the value**
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
const field = container.querySelector('[name="message"]');
|
|
68
|
+
// or, without a name:
|
|
69
|
+
const field = container.querySelector('[data-editable-input-mirror]');
|
|
70
|
+
|
|
71
|
+
field.value; // → current text, always in sync with what the user sees
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Writing the value** — set `value` then dispatch a bubbling `input` event. The component listens with a
|
|
75
|
+
native DOM listener (not React's synthetic `onChange`), so the plain assignment below is honoured; you do
|
|
76
|
+
not need the `HTMLTextAreaElement.prototype` value-setter trick that React's value tracker normally forces:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
field.value = 'Restored draft';
|
|
80
|
+
field.dispatchEvent(new Event('input', { bubbles: true }));
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
That write propagates to the `contentEditable` area, the placeholder, and `onChange`, exactly as typing
|
|
84
|
+
does. Because it goes through `onChange`, a **controlled** `ChatInput` still needs its parent to apply the
|
|
85
|
+
new value — the same contract as any controlled React input.
|
|
86
|
+
|
|
87
|
+
The mirror also sits inside the component's `<form>`, so with a `name` the message is included in a native
|
|
88
|
+
form submission and in `new FormData(form)`.
|
|
89
|
+
|
|
90
|
+
Set `hiddenInput={false}` to opt out of the extra node, and style it — if you ever need to — through
|
|
91
|
+
`views.hiddenInput`.
|
|
92
|
+
|
|
93
|
+
### **Imperative API (`ref`)**
|
|
94
|
+
|
|
95
|
+
For callers holding a React ref, the same capability is available without touching the DOM. `ChatInput`'s
|
|
96
|
+
ref is a `ChatInputHandle`:
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
import React, { useEffect, useRef } from 'react';
|
|
100
|
+
import { ChatInput, ChatInputHandle } from '@app-studio/components';
|
|
101
|
+
|
|
102
|
+
export const ImperativeChatInput = () => {
|
|
103
|
+
const ref = useRef<ChatInputHandle>(null);
|
|
104
|
+
|
|
105
|
+
// Restore a saved draft without reimplementing DOM writes
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
ref.current?.setValue(localStorage.getItem('draft') ?? '');
|
|
108
|
+
}, []);
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<ChatInput
|
|
112
|
+
ref={ref}
|
|
113
|
+
onSubmit={(message) => {
|
|
114
|
+
console.log(message);
|
|
115
|
+
ref.current?.clear();
|
|
116
|
+
}}
|
|
117
|
+
/>
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
| Method | Description |
|
|
123
|
+
| -------------------- | --------------------------------------------------------------------- |
|
|
124
|
+
| `getValue()` | Current text of the input. |
|
|
125
|
+
| `setValue(value)` | Replaces the text. Fires `onChange` exactly like typing does. |
|
|
126
|
+
| `clear()` | Shorthand for `setValue('')`. |
|
|
127
|
+
| `focus()` / `blur()` | Focuses or blurs the editable area. |
|
|
128
|
+
| `getElement()` | The `contentEditable` element (`role="textbox"`). |
|
|
129
|
+
| `getInputElement()` | The hidden mirror `<textarea>`; `null` when `hiddenInput` is `false`. |
|
|
130
|
+
|
|
131
|
+
### **Standalone `EditableInput`**
|
|
132
|
+
|
|
133
|
+
`EditableInput` — the editable area on its own — takes the same `name`, `id`, `hiddenInput`,
|
|
134
|
+
`hiddenInputRef` and `views.hiddenInput` props, so the mirror is available outside of `ChatInput` too:
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
import React, { useRef, useState } from 'react';
|
|
138
|
+
import { EditableInput } from '@app-studio/components';
|
|
139
|
+
|
|
140
|
+
export const StandaloneEditableInput = () => {
|
|
141
|
+
const [value, setValue] = useState('');
|
|
142
|
+
const editableRef = useRef<HTMLDivElement>(null);
|
|
143
|
+
const inputRef = useRef<HTMLTextAreaElement>(null);
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<EditableInput
|
|
147
|
+
ref={editableRef}
|
|
148
|
+
hiddenInputRef={inputRef}
|
|
149
|
+
name="message"
|
|
150
|
+
value={value}
|
|
151
|
+
onChange={setValue}
|
|
152
|
+
/>
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Note that `EditableInput`'s own `ref` points at the `contentEditable` div (it is what the component uses
|
|
158
|
+
internally for caret handling); the mirror is reached through `hiddenInputRef`.
|
|
159
|
+
|
|
160
|
+
### **React Native**
|
|
161
|
+
|
|
162
|
+
There is no DOM on native, so `EditableInput` renders a real multiline `TextInput` there and no mirror is
|
|
163
|
+
created: `hiddenInput` and `hiddenInputRef` are accepted for API parity and ignored, while `name` and `id`
|
|
164
|
+
are forwarded to the input. `setValue` on the handle falls back to a direct state update, so the
|
|
165
|
+
imperative API behaves the same on both platforms.
|
|
166
|
+
|
|
167
|
+
### **attachments, mentions and suggestions**
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
import React, { useState } from 'react';
|
|
171
|
+
import { ChatInput } from '@app-studio/components';
|
|
172
|
+
|
|
173
|
+
export const RichChatInput = () => {
|
|
174
|
+
const [value, setValue] = useState('');
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<ChatInput
|
|
178
|
+
value={value}
|
|
179
|
+
onChange={setValue}
|
|
180
|
+
onSubmit={(message) => setValue('')}
|
|
181
|
+
mentionData={[
|
|
182
|
+
{ id: '1', name: 'alice', description: 'Product' },
|
|
183
|
+
{ id: '2', name: 'bob', description: 'Engineering' },
|
|
184
|
+
]}
|
|
185
|
+
mentionTrigger="@"
|
|
186
|
+
suggestions={[
|
|
187
|
+
{ id: 's1', text: 'Summarise this thread' },
|
|
188
|
+
{ id: 's2', text: 'Draft a reply' },
|
|
189
|
+
]}
|
|
190
|
+
promptExamples={[{ id: 'p1', text: 'What can you do?' }]}
|
|
191
|
+
enableAudioRecording
|
|
192
|
+
onFileUpload={(file) => console.log('upload', file.name)}
|
|
193
|
+
/>
|
|
194
|
+
);
|
|
195
|
+
};
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### **size, shape, variant**
|
|
199
|
+
|
|
200
|
+
```tsx
|
|
201
|
+
import React from 'react';
|
|
202
|
+
import { Vertical } from '@app-studio/components';
|
|
203
|
+
import { ChatInput } from '@app-studio/components';
|
|
204
|
+
|
|
205
|
+
export const StyledChatInput = () => (
|
|
206
|
+
<Vertical gap={20}>
|
|
207
|
+
<ChatInput size="sm" shape="rounded" variant="outline" />
|
|
208
|
+
<ChatInput size="lg" shape="square" variant="default" />
|
|
209
|
+
</Vertical>
|
|
210
|
+
);
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### **views**
|
|
214
|
+
|
|
215
|
+
| Key | Target |
|
|
216
|
+
| --------------------------------------------------------------------------------------- | ----------------------------------- |
|
|
217
|
+
| `container` | Outer wrapper |
|
|
218
|
+
| `content` | The `<form>` holding the composer |
|
|
219
|
+
| `editableInput` | The `contentEditable` area |
|
|
220
|
+
| `hiddenInput` | The hidden mirror `<textarea>` |
|
|
221
|
+
| `attachments`, `attachmentItem`, `attachmentName`, `attachmentSize`, `attachmentRemove` | Attachment list |
|
|
222
|
+
| `promptExamples`, `promptExampleItem` | Prompt examples |
|
|
223
|
+
| `submitButton`, `fileButton`, `recordButton` | Action buttons |
|
|
224
|
+
| `loadingIndicator`, `bottomTip` | Agent-running row and error message |
|
|
@@ -7,6 +7,9 @@ A customizable UI component for selecting from a list of options.
|
|
|
7
7
|
| Prop | Type | Description | Default |
|
|
8
8
|
| ---------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------- |
|
|
9
9
|
| options | { label: string; value: string }[] | Array of options for the select box. | |
|
|
10
|
+
| value | string \| string[] | Selected option value(s). Supplying it makes the select controlled: the selection follows this prop and only moves when the parent passes a new one. | |
|
|
11
|
+
| defaultValue | string \| string[] | Initial selection for uncontrolled use. Read once on mount, ignored when `value` is supplied. | |
|
|
12
|
+
| onChange | (value) => void | Called with the next selection: the chosen option's value, or the full array of selected values when `isMulti`. | |
|
|
10
13
|
| label | string | Label for the select box. | |
|
|
11
14
|
| placeholder | string | Placeholder text for the select box. | |
|
|
12
15
|
| error | boolean | Flag to indicate if the select has an error state. | false |
|
|
@@ -106,6 +109,39 @@ export const ShadowSelect = () => (
|
|
|
106
109
|
|
|
107
110
|
```
|
|
108
111
|
|
|
112
|
+
### **Controlled**
|
|
113
|
+
Pass `value` to drive the selection from state. The select then never moves on
|
|
114
|
+
its own: it reports the choice through `onChange` and waits for the new value.
|
|
115
|
+
Omit `value` and pass `defaultValue` instead for uncontrolled use — passing both
|
|
116
|
+
is what a native `<select>` refuses, and the component keeps that rule.
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
import React, { useState } from 'react';
|
|
120
|
+
import { Button, Horizontal, Select } from '@app-studio/components';
|
|
121
|
+
|
|
122
|
+
const options = [
|
|
123
|
+
{ label: 'Item1', value: '1' },
|
|
124
|
+
{ label: 'Item2', value: '2' },
|
|
125
|
+
{ label: 'Item3', value: '3' },
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
export const ControlledSelect = () => {
|
|
129
|
+
const [value, setValue] = useState('2');
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<Horizontal gap={12} alignItems="center">
|
|
133
|
+
<Select
|
|
134
|
+
options={options}
|
|
135
|
+
label="Select an item"
|
|
136
|
+
value={value}
|
|
137
|
+
onChange={setValue}
|
|
138
|
+
/>
|
|
139
|
+
<Button onClick={() => setValue('3')}>Jump to Item3</Button>
|
|
140
|
+
</Horizontal>
|
|
141
|
+
);
|
|
142
|
+
};
|
|
143
|
+
```
|
|
144
|
+
|
|
109
145
|
### **isScrollable**
|
|
110
146
|
Boolean to control whether the select options are scrollable
|
|
111
147
|
|
|
@@ -72,9 +72,12 @@ export const HelperTextArea = () => {
|
|
|
72
72
|
setFormErrors(errors);
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
// TextArea's onChange hands you the value, not a DOM event — so the field
|
|
76
|
+
// name comes from the closure rather than `event.target.name`.
|
|
77
|
+
const handleChange =
|
|
78
|
+
(field: keyof typeof initialValues) => (value: string) => {
|
|
79
|
+
setFormValues((current) => ({ ...current, [field]: value }));
|
|
80
|
+
};
|
|
78
81
|
|
|
79
82
|
const handleSubmit = (event: any) => {
|
|
80
83
|
event.preventDefault();
|
|
@@ -91,7 +94,7 @@ export const HelperTextArea = () => {
|
|
|
91
94
|
placeholder="Write here..."
|
|
92
95
|
helperText={formErrors.guess}
|
|
93
96
|
error={!!formErrors.guess}
|
|
94
|
-
onChange={handleChange}
|
|
97
|
+
onChange={handleChange('guess')}
|
|
95
98
|
/>
|
|
96
99
|
<Button type="submit" height="40px" isAuto>
|
|
97
100
|
Submit
|
|
@@ -67,9 +67,12 @@ export const HelperTextInput = () => {
|
|
|
67
67
|
setFormErrors(errors);
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
// TextField's onChange hands you the value, not a DOM event — so the field
|
|
71
|
+
// name comes from the closure rather than `event.target.name`.
|
|
72
|
+
const handleChange =
|
|
73
|
+
(field: keyof typeof initialValues) => (value: string) => {
|
|
74
|
+
setFormValues((current) => ({ ...current, [field]: value }));
|
|
75
|
+
};
|
|
73
76
|
|
|
74
77
|
const handleSubmit = (event: any) => {
|
|
75
78
|
event.preventDefault();
|
|
@@ -86,14 +89,14 @@ export const HelperTextInput = () => {
|
|
|
86
89
|
placeholder="First Name"
|
|
87
90
|
helperText={formErrors.firstName}
|
|
88
91
|
error={!!formErrors.firstName}
|
|
89
|
-
onChange={handleChange}
|
|
92
|
+
onChange={handleChange('firstName')}
|
|
90
93
|
/>
|
|
91
94
|
<TextField
|
|
92
95
|
name="lastName"
|
|
93
96
|
placeholder="Last Name"
|
|
94
97
|
helperText={formErrors.lastName}
|
|
95
98
|
error={!!formErrors.lastName}
|
|
96
|
-
onChange={handleChange}
|
|
99
|
+
onChange={handleChange('lastName')}
|
|
97
100
|
/>
|
|
98
101
|
<Button type="submit" height="40px" isAuto>
|
|
99
102
|
Submit
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@app-studio/components",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.27",
|
|
4
4
|
"main": "dist/web.cjs.js",
|
|
5
5
|
"module": "dist/web.esm.js",
|
|
6
6
|
"react-native": "dist/native/components/index.js",
|
|
@@ -80,6 +80,7 @@
|
|
|
80
80
|
"validate-docs": "node scripts/validate-docs.js",
|
|
81
81
|
"docs:app-studio": "rm -rf docs/app-studio && mkdir -p docs/app-studio && cp -R node_modules/app-studio/docs/* docs/app-studio",
|
|
82
82
|
"api:local": "react-api --useUnionTypes --input http://localhost:3000/docs/swagger.json --output ./src/services/api && prettier --write ./src/services/api",
|
|
83
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
83
84
|
"typecheck:native": "tsc --noEmit -p tsconfig.native.json",
|
|
84
85
|
"build:native": "rm -rf dist/native && tsc -p tsconfig.native.build.json && tsc-alias -p tsconfig.native.build.json",
|
|
85
86
|
"build:native:types": "npm run build:native",
|
|
@@ -192,7 +193,7 @@
|
|
|
192
193
|
"typescript": "^5.2.2",
|
|
193
194
|
"vite": "^5.4.21",
|
|
194
195
|
"vite-plugin-dts": "^4.5.4",
|
|
195
|
-
"vitest": "^
|
|
196
|
+
"vitest": "^3.2.7",
|
|
196
197
|
"webpack": "^5.89.0",
|
|
197
198
|
"webpack-bundle-analyzer": "^4.8.0",
|
|
198
199
|
"yup": "^1.5.0",
|