@app-studio/components 0.10.25 → 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.
Files changed (117) hide show
  1. package/README.md +2 -0
  2. package/dist/index.d.ts +195 -65
  3. package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.view.js +1 -1
  4. package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.view.js.map +1 -1
  5. package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.view.native.js +1 -1
  6. package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.view.native.js.map +1 -1
  7. package/dist/native/components/Avatar/Avatar/Avatar.props.d.ts +2 -1
  8. package/dist/native/components/ChatInput/ChatInput/ChatInput.props.d.ts +57 -0
  9. package/dist/native/components/ChatInput/ChatInput/ChatInput.state.d.ts +2 -0
  10. package/dist/native/components/ChatInput/ChatInput/ChatInput.state.js +18 -0
  11. package/dist/native/components/ChatInput/ChatInput/ChatInput.state.js.map +1 -1
  12. package/dist/native/components/ChatInput/ChatInput/ChatInput.type.d.ts +1 -0
  13. package/dist/native/components/ChatInput/ChatInput/ChatInput.view.js +5 -2
  14. package/dist/native/components/ChatInput/ChatInput/ChatInput.view.js.map +1 -1
  15. package/dist/native/components/ChatInput/ChatInput.d.ts +2 -2
  16. package/dist/native/components/ChatInput/ChatInput.js +16 -1
  17. package/dist/native/components/ChatInput/ChatInput.js.map +1 -1
  18. package/dist/native/components/ChatInput/EditableInput.d.ts +5 -0
  19. package/dist/native/components/ChatInput/EditableInput.js +74 -5
  20. package/dist/native/components/ChatInput/EditableInput.js.map +1 -1
  21. package/dist/native/components/ChatInput/EditableInput.native.d.ts +5 -0
  22. package/dist/native/components/ChatInput/EditableInput.native.js +4 -2
  23. package/dist/native/components/ChatInput/EditableInput.native.js.map +1 -1
  24. package/dist/native/components/Command/Command/CommandOverlay.js +1 -1
  25. package/dist/native/components/Command/Command/CommandOverlay.js.map +1 -1
  26. package/dist/native/components/ContextMenu/ContextMenu/ContextMenu.view.native.js +1 -1
  27. package/dist/native/components/ContextMenu/ContextMenu/ContextMenu.view.native.js.map +1 -1
  28. package/dist/native/components/Drawer/Drawer/Drawer.view.js +1 -1
  29. package/dist/native/components/Drawer/Drawer/Drawer.view.js.map +1 -1
  30. package/dist/native/components/Drawer/Drawer/Drawer.view.native.js +1 -1
  31. package/dist/native/components/Drawer/Drawer/Drawer.view.native.js.map +1 -1
  32. package/dist/native/components/EmojiPicker/EmojiPicker/EmojiPicker.view.js +1 -1
  33. package/dist/native/components/EmojiPicker/EmojiPicker/EmojiPicker.view.js.map +1 -1
  34. package/dist/native/components/EmojiPicker/EmojiPicker/EmojiPicker.view.native.js +1 -1
  35. package/dist/native/components/EmojiPicker/EmojiPicker/EmojiPicker.view.native.js.map +1 -1
  36. package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.props.d.ts +2 -2
  37. package/dist/native/components/Form/ColorInput/ColorInput/ColorInput.props.d.ts +4 -4
  38. package/dist/native/components/Form/ColorInput/ColorInput/ColorInput.view.js +14 -3
  39. package/dist/native/components/Form/ColorInput/ColorInput/ColorInput.view.js.map +1 -1
  40. package/dist/native/components/Form/ColorInput/ColorInput/ColorInput.view.native.js +1 -3
  41. package/dist/native/components/Form/ColorInput/ColorInput/ColorInput.view.native.js.map +1 -1
  42. package/dist/native/components/Form/CountryPicker/CountryPicker/CountryPicker.props.d.ts +11 -6
  43. package/dist/native/components/Form/CountryPicker/CountryPicker/CountryPicker.view.js +3 -1
  44. package/dist/native/components/Form/CountryPicker/CountryPicker/CountryPicker.view.js.map +1 -1
  45. package/dist/native/components/Form/DatePicker/DatePicker/DatePicker.props.d.ts +5 -3
  46. package/dist/native/components/Form/Password/example/ErrorInput.js +6 -4
  47. package/dist/native/components/Form/Password/example/ErrorInput.js.map +1 -1
  48. package/dist/native/components/Form/Password/example/HelperText.js +6 -4
  49. package/dist/native/components/Form/Password/example/HelperText.js.map +1 -1
  50. package/dist/native/components/Form/Radio/Radio/Radio.props.d.ts +2 -2
  51. package/dist/native/components/Form/Radio/Radio/Radio.view.js +4 -2
  52. package/dist/native/components/Form/Radio/Radio/Radio.view.js.map +1 -1
  53. package/dist/native/components/Form/Radio/Radio/Radio.view.native.js +4 -2
  54. package/dist/native/components/Form/Radio/Radio/Radio.view.native.js.map +1 -1
  55. package/dist/native/components/Form/Select/Select/Select.props.d.ts +35 -15
  56. package/dist/native/components/Form/Select/Select/Select.state.d.ts +2 -2
  57. package/dist/native/components/Form/Select/Select/Select.state.js +48 -13
  58. package/dist/native/components/Form/Select/Select/Select.state.js.map +1 -1
  59. package/dist/native/components/Form/Select/Select/Select.view.js +59 -8
  60. package/dist/native/components/Form/Select/Select/Select.view.js.map +1 -1
  61. package/dist/native/components/Form/Select/Select/Select.view.native.js +6 -2
  62. package/dist/native/components/Form/Select/Select/Select.view.native.js.map +1 -1
  63. package/dist/native/components/Form/Select/Select.js +5 -1
  64. package/dist/native/components/Form/Select/Select.js.map +1 -1
  65. package/dist/native/components/Form/Selector/Selector/Selector.props.d.ts +17 -12
  66. package/dist/native/components/Form/Switch/Switch/Switch.props.d.ts +3 -3
  67. package/dist/native/components/Form/TextArea/TextArea/TextArea.props.d.ts +23 -7
  68. package/dist/native/components/Form/TextArea/TextArea/TextArea.view.js +9 -10
  69. package/dist/native/components/Form/TextArea/TextArea/TextArea.view.js.map +1 -1
  70. package/dist/native/components/Form/TextField/TextField/TextField.props.d.ts +26 -7
  71. package/dist/native/components/Form/TextField/TextField/TextField.view.js +8 -8
  72. package/dist/native/components/Form/TextField/TextField/TextField.view.js.map +1 -1
  73. package/dist/native/components/Formik/Formik.ChatInput.js +4 -1
  74. package/dist/native/components/Formik/Formik.ChatInput.js.map +1 -1
  75. package/dist/native/components/Formik/Formik.Form.js +15 -1
  76. package/dist/native/components/Formik/Formik.Form.js.map +1 -1
  77. package/dist/native/components/Formik/Formik.Select.js +6 -2
  78. package/dist/native/components/Formik/Formik.Select.js.map +1 -1
  79. package/dist/native/components/Link/Link/Link.props.d.ts +1 -1
  80. package/dist/native/components/Message/Message/Message.props.d.ts +4 -4
  81. package/dist/native/components/Message/Message/Message.type.d.ts +1 -1
  82. package/dist/native/components/Modal/Modal/Modal.style.js +1 -1
  83. package/dist/native/components/Modal/Modal/Modal.style.js.map +1 -1
  84. package/dist/native/components/Modal/Modal/Modal.view.js +2 -2
  85. package/dist/native/components/Modal/Modal/Modal.view.js.map +1 -1
  86. package/dist/native/components/Modal/Modal/Modal.view.native.js +1 -1
  87. package/dist/native/components/Modal/Modal/Modal.view.native.js.map +1 -1
  88. package/dist/native/components/OTPInput/OTPInput/OTPInput.props.d.ts +1 -1
  89. package/dist/native/components/OTPInput/OTPInput/OTPInput.state.d.ts +1 -1
  90. package/dist/native/components/OTPInput/OTPInput/OTPInput.state.js +9 -3
  91. package/dist/native/components/OTPInput/OTPInput/OTPInput.state.js.map +1 -1
  92. package/dist/native/components/Sidebar/Sidebar/Sidebar.view.js +1 -1
  93. package/dist/native/components/Sidebar/Sidebar/Sidebar.view.js.map +1 -1
  94. package/dist/native/components/Table/Table/Table.context.d.ts +2 -2
  95. package/dist/native/components/Table/Table/Table.context.js.map +1 -1
  96. package/dist/native/components/Table/Table/Table.props.d.ts +1 -1
  97. package/dist/native/components/Tabs/Tabs/Tabs.props.d.ts +6 -2
  98. package/dist/native/components/Toast/Toast/Toast.view.js +1 -1
  99. package/dist/native/components/Toast/Toast/Toast.view.js.map +1 -1
  100. package/dist/web.cjs.js +9 -9
  101. package/dist/web.cjs.js.map +1 -1
  102. package/dist/web.esm.js +5771 -5623
  103. package/dist/web.esm.js.map +1 -1
  104. package/dist/web.umd.js +10 -10
  105. package/dist/web.umd.js.map +1 -1
  106. package/docs/README.md +1 -1
  107. package/docs/components/Center.mdx +3 -1
  108. package/docs/components/ChatInput.mdx +224 -0
  109. package/docs/components/Form.mdx +34 -7
  110. package/docs/components/Formik.mdx +7 -0
  111. package/docs/components/Select.mdx +36 -0
  112. package/docs/components/TextArea.mdx +7 -4
  113. package/docs/components/TextField.mdx +8 -5
  114. package/docs/components/Vertical.mdx +4 -2
  115. package/docs/getting-started/component-usage.md +40 -16
  116. package/docs/getting-started/react-native.md +66 -0
  117. package/package.json +3 -2
package/docs/README.md CHANGED
@@ -8,7 +8,7 @@ build with the same public API.
8
8
 
9
9
  ### Core Documentation
10
10
  - **[Getting Started](./getting-started/introduction.md)** — Quick introduction and setup (web + RN)
11
- - **[React Native Guide](./getting-started/react-native.md)** — RN peer deps, compatibility matrix, Reanimated, Metro/tsc resolution
11
+ - **[React Native Guide](./getting-started/react-native.md)** — RN peer deps, compatibility matrix, Form/Grid contracts, Reanimated, Metro/tsc resolution
12
12
  - **[Component Development](./component-development/guide.md)** — Building and contributing components (including `.native.tsx` siblings)
13
13
  - **[API Integration](./api-integration.md)** — Backend integration patterns
14
14
  - **[Design System](./design-system/theming.md)** — Theming and styling guidelines
@@ -372,7 +372,9 @@ export const ImagePlaceholder = () => (
372
372
  **Performance:**
373
373
  - Avoid unnecessary nesting of Center components
374
374
  - Use CSS transforms for animations instead of changing layout
375
- - Consider using CSS Grid for complex centered layouts
375
+ - On web, consider CSS Grid for complex centered layouts. On React Native,
376
+ `Grid` supports only fixed integer columns faithfully; use explicit flex rows
377
+ when content needs intrinsic sizing or spanning.
376
378
 
377
379
  ### **Common Patterns**
378
380
 
@@ -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 |
@@ -39,6 +39,24 @@ A comprehensive form system with Formik integration, providing powerful form sta
39
39
  } from '@app-studio/components';
40
40
  ```
41
41
 
42
+ ### **Cross-Platform Form Semantics**
43
+
44
+ `FormikForm` shares validation, field state, errors, and focus rules across web
45
+ and React Native, but its container does not have the same platform semantics:
46
+
47
+ - On web, it renders a real `<form>` and wires Formik's submit/reset handlers.
48
+ - On React Native, it renders a styled `View`. There is no submit event,
49
+ Enter-to-submit, implicit label association, or browser validation.
50
+ - Submit and reset buttons must call `handleSubmit`/`handleReset` explicitly.
51
+ - `FormikForm autoFocus` wires single-line fields through
52
+ `returnKeyType`/`onSubmitEditing`; multi-line inputs retain Return for newlines.
53
+ - Native labels, hints, and errors must be exposed through React Native
54
+ accessibility props, and validation must come from Formik/Yup or application
55
+ code rather than HTML attributes.
56
+
57
+ The rule is: keep form behavior and validation shared, but branch the platform
58
+ wiring.
59
+
42
60
  ### **Basic Form with Formik**
43
61
  ```tsx
44
62
  import React from 'react';
@@ -455,6 +473,8 @@ export const DynamicForm = () => {
455
473
  - Main form wrapper with Formik integration
456
474
  - Provides form context and state management
457
475
  - Supports auto-focus and form navigation
476
+ - Preserves semantic submit/reset events on web
477
+ - Uses explicit button and return-key handlers on React Native
458
478
 
459
479
  **FormikTextField**
460
480
  - Single-line text input with validation
@@ -608,7 +628,8 @@ const CustomFormikField = (props) => {
608
628
  ### **Best Practices**
609
629
 
610
630
  **Form Structure:**
611
- - Use semantic HTML structure
631
+ - Use semantic HTML structure on web; use accessible React Native views and
632
+ control props on native
612
633
  - Group related fields logically
613
634
  - Provide clear labels and instructions
614
635
  - Use appropriate field types for data
@@ -652,7 +673,7 @@ const handleSubmit = async (values, { setSubmitting, setFieldError }) => {
652
673
  };
653
674
  ```
654
675
 
655
- **With File Uploads:**
676
+ **With File Uploads (web only):**
656
677
  ```tsx
657
678
  import { FormikForm, FormikTextField } from '@app-studio/components';
658
679
  import { Uploader } from '@app-studio/components';
@@ -670,12 +691,18 @@ const FormWithUpload = () => {
670
691
  // Submit form data
671
692
  }}
672
693
  >
673
- <FormikForm>
674
- <FormikTextField name="name" label="Name" />
675
- <Uploader onFileSelect={setUploadedFile} />
676
- <Button type="submit">Submit</Button>
677
- </FormikForm>
694
+ {({ handleSubmit }) => (
695
+ <FormikForm>
696
+ <FormikTextField name="name" label="Name" />
697
+ <Uploader onFileSelect={setUploadedFile} />
698
+ <Button type="submit" onClick={handleSubmit}>Submit</Button>
699
+ </FormikForm>
700
+ )}
678
701
  </Formik>
679
702
  );
680
703
  };
681
704
  ```
705
+
706
+ `Uploader` uses browser `File` APIs and is not exported by the React Native
707
+ build. Use a native document/image picker and place its result in Formik state
708
+ for the equivalent mobile flow.
@@ -2,6 +2,13 @@
2
2
 
3
3
  Formik integration components for form state management and validation.
4
4
 
5
+ > **React Native:** `FormikForm` renders through the native `Form` primitive,
6
+ > which is a `View`, not a browser form. Keep `type="submit"`/`type="reset"` for
7
+ > web semantics and also wire `onClick={handleSubmit}` or
8
+ > `onClick={handleReset}` explicitly. With `autoFocus`, single-line
9
+ > fields use `returnKeyType`/`onSubmitEditing` to advance and submit; labels,
10
+ > validation, and accessibility still need their native component wiring.
11
+
5
12
  ### **Import**
6
13
  ```tsx
7
14
  import { FormikForm, FormikTextField, FormikCheckbox, FormikChatInput, FormikColorInput, FormikSelect, FormikSwitch, FormikTextArea, FormikDatePicker, FormikCountryPicker, FormikPassword, FormikComboBox, FormikSlider, FormikIconPicker, FormikEmojiPicker, FormikOTPInput, FormikRadio, FormikSelector, FormikTagInput, FormikToggle, FormikToggleGroup, FormikUploader } from '@app-studio/components';
@@ -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
- const handleChange = (event: any) => {
76
- setFormValues({ ...formValues, [event.target.name]: event.target.value });
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
- const handleChange = (event: any) => {
71
- setFormValues({ ...formValues, [event.target.name]: event.target.value });
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
@@ -471,7 +471,10 @@ export const SplitLayout = () => (
471
471
 
472
472
  **Performance:**
473
473
  - Avoid deeply nested Vertical components when possible
474
- - Use CSS Grid for complex layouts instead of multiple nested flex containers
474
+ - On web, use CSS Grid for complex layouts instead of deeply nested flex
475
+ containers. On React Native, `Grid` is portable only with a fixed integer
476
+ column count; use explicit `Horizontal` rows or a virtualised `FlatList` for
477
+ intrinsic sizing, spanning, or scrollable collections.
475
478
  - Consider virtualization for long lists
476
479
 
477
480
  **Accessibility:**
@@ -563,4 +566,3 @@ import { Vertical, Horizontal, Center } from '@app-studio/components';
563
566
  </Horizontal>
564
567
  </Vertical>
565
568
  ```
566
-
@@ -60,12 +60,14 @@ Layout components help structure your UI. The main layout components are:
60
60
  - `Horizontal`: Horizontal flex container
61
61
  - `Vertical`: Vertical flex container
62
62
  - `Center`: Centered flex container
63
+ - `Grid`: CSS Grid on web; fixed-count flex rows on React Native
63
64
 
64
65
  Example:
65
66
 
66
67
  ```jsx
67
68
  import React from 'react';
68
- import { View, Horizontal, Vertical, Center, Text, Button } from '@app-studio/components';
69
+ import { View, Horizontal, Vertical, Center, Text } from 'app-studio';
70
+ import { Button } from '@app-studio/components';
69
71
 
70
72
  function MyLayout() {
71
73
  return (
@@ -85,38 +87,58 @@ function MyLayout() {
85
87
  }
86
88
  ```
87
89
 
90
+ React Native has no CSS Grid. Use `Grid columns={2}` (a fixed integer) for a
91
+ small, non-virtualised layout. String templates such as `auto-fit`/`auto-fill`
92
+ collapse to one native column and `rows` is ignored. Compose explicit
93
+ `Horizontal` rows for spanning/intrinsic layouts, or use `FlatList` with
94
+ `numColumns` for scrollable card collections.
95
+
88
96
  ## Form Components
89
97
 
90
98
  Form components can be used standalone or integrated with Formik:
91
99
 
92
- ### Standalone Usage
100
+ ### Standalone Cross-Platform Usage
93
101
 
94
- ```jsx
102
+ `Form` is a semantic `<form>` on web and a styled `View` on React Native. Keep
103
+ the state and validation rules shared, then wire native submission, return keys,
104
+ labels, and accessibility explicitly:
105
+
106
+ ```tsx
95
107
  import React, { useState } from 'react';
108
+ import { Form } from 'app-studio';
96
109
  import { TextField, Button } from '@app-studio/components';
97
110
 
98
111
  function MyForm() {
99
112
  const [value, setValue] = useState('');
100
-
113
+
114
+ const handleSubmit = (event?: { preventDefault?: () => void }) => {
115
+ event?.preventDefault?.();
116
+ if (!value.trim()) return;
117
+ alert(`Submitted: ${value}`);
118
+ };
119
+
101
120
  return (
102
- <form onSubmit={(e) => { e.preventDefault(); alert(`Submitted: ${value}`); }}>
103
- <TextField
121
+ <Form onSubmit={handleSubmit}>
122
+ <TextField
104
123
  label="Name"
124
+ accessibilityLabel="Name"
105
125
  value={value}
106
- onChange={(e) => setValue(e.target.value)}
126
+ onChangeText={setValue}
127
+ returnKeyType="done"
128
+ onSubmitEditing={handleSubmit}
107
129
  />
108
- <Button type="submit">Submit</Button>
109
- </form>
130
+ <Button type="submit" onClick={handleSubmit}>Submit</Button>
131
+ </Form>
110
132
  );
111
133
  }
112
134
  ```
113
135
 
114
136
  ### Formik Integration
115
137
 
116
- ```jsx
138
+ ```tsx
117
139
  import React from 'react';
118
- import { Formik, Form } from 'formik';
119
- import { FormikTextField, Button } from '@app-studio/components';
140
+ import { Formik } from 'formik';
141
+ import { FormikForm, FormikTextField, Button } from '@app-studio/components';
120
142
 
121
143
  function MyFormikForm() {
122
144
  return (
@@ -124,10 +146,12 @@ function MyFormikForm() {
124
146
  initialValues={{ name: '' }}
125
147
  onSubmit={(values) => alert(`Submitted: ${values.name}`)}
126
148
  >
127
- <Form>
128
- <FormikTextField name="name" label="Name" />
129
- <Button type="submit">Submit</Button>
130
- </Form>
149
+ {({ handleSubmit }) => (
150
+ <FormikForm autoFocus>
151
+ <FormikTextField name="name" label="Name" />
152
+ <Button type="submit" onClick={handleSubmit}>Submit</Button>
153
+ </FormikForm>
154
+ )}
131
155
  </Formik>
132
156
  );
133
157
  }
@@ -123,6 +123,8 @@ and ProgressBar `shape="circle"` falls back to the linear bar.
123
123
  | Button | ✅ | ✅ | Animations `borderMoving`/`animatedStroke`/`borderReveal` fall back to standard on RN |
124
124
  | Text / Title | ✅ | ✅ | Title `<br>` mapped to `\n`; typewriter/slide effects dropped on RN |
125
125
  | View / Horizontal / Vertical / Center | ✅ | ✅ | Direct primitives from `app-studio` |
126
+ | Grid | ✅ | ⚠️ | Fixed integer `columns` only; intrinsic tracks/spans are not portable |
127
+ | Form | ✅ | ⚠️ | A styled `View` on RN; submit, validation, and label wiring are explicit |
126
128
  | Image | ✅ | ✅ | |
127
129
  | Icon | ✅ | ✅ | Web uses `lucide-react` lazy imports; RN uses `lucide-react-native` static map |
128
130
  | Link | ✅ | ✅ | Web: `react-router-dom`. RN: `Linking.openURL` (external) + `onPress` (internal) |
@@ -160,6 +162,70 @@ and ProgressBar `shape="circle"` falls back to the linear bar.
160
162
 
161
163
  ---
162
164
 
165
+ ## Layout and form semantics on React Native
166
+
167
+ The visual rules are shared across web and native, but the platform wiring is
168
+ not. Two primitives need deliberate native usage: `Form` and `Grid`.
169
+
170
+ ### Form is a view
171
+
172
+ On the web, `Form` renders a real `<form>`. React Native has no equivalent, so
173
+ the same component renders a styled `View`. It does **not** provide a submit
174
+ event, Enter-to-submit, implicit label association, or browser validation.
175
+
176
+ Keep the same validation and accessibility rules on both platforms, but wire
177
+ their native behavior explicitly:
178
+
179
+ - call the form library's submit/reset handlers from button `onClick` (the RN
180
+ button maps it to `onPress`);
181
+ - use `returnKeyType` and `onSubmitEditing` for keyboard progression/submission;
182
+ - expose labels and errors through React Native accessibility props;
183
+ - run schema or application validation instead of relying on HTML attributes.
184
+
185
+ `FormikForm autoFocus` wires the single-line input return-key chain for you. A
186
+ submit or reset button still needs an explicit handler:
187
+
188
+ ```tsx
189
+ <Formik initialValues={{ email: '' }} onSubmit={save} validationSchema={schema}>
190
+ {({ handleSubmit, handleReset }) => (
191
+ <FormikForm autoFocus>
192
+ <FormikTextField name="email" label="Email" type="email" />
193
+ <Button type="submit" onClick={handleSubmit}>Save</Button>
194
+ <Button type="reset" onClick={handleReset}>Reset</Button>
195
+ </FormikForm>
196
+ )}
197
+ </Formik>
198
+ ```
199
+
200
+ The `type` props retain the correct web semantics; the explicit handlers are
201
+ the native wiring. For a plain `Form`, apply the same pattern with controlled
202
+ state and your own validation function.
203
+
204
+ ### Grid is fixed-count only
205
+
206
+ React Native has no CSS Grid underneath. Native `Grid` uses flex rows and is
207
+ faithful for one portable shape: a fixed integer column count.
208
+
209
+ ```tsx
210
+ <Grid columns={2} gap={12}>
211
+ <Card />
212
+ <Card />
213
+ <Card />
214
+ <Card />
215
+ </Grid>
216
+ ```
217
+
218
+ Treat string templates as web-only. In particular, `auto-fit` and `auto-fill`
219
+ collapse to one native column, and `rows` is ignored. Intrinsic sizing, named
220
+ areas, and item spanning therefore need an explicit `Vertical`/`Horizontal`
221
+ row composition per platform.
222
+
223
+ For a scrollable card grid, prefer React Native's virtualised `FlatList` with
224
+ `numColumns`; it avoids rendering the full collection and makes the mobile
225
+ column count intentional.
226
+
227
+ ---
228
+
163
229
  ## Animations on React Native
164
230
 
165
231
  `app-studio` exposes the same `Animation.*` factories on both platforms:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@app-studio/components",
3
- "version": "0.10.25",
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": "^4.0.18",
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",