@app-studio/components 0.10.25 → 0.10.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/native/components/Formik/Formik.Form.js +15 -1
- package/dist/native/components/Formik/Formik.Form.js.map +1 -1
- package/dist/web.cjs.js +1 -1
- package/dist/web.cjs.js.map +1 -1
- package/dist/web.esm.js +16 -11
- package/dist/web.esm.js.map +1 -1
- package/dist/web.umd.js +1 -1
- package/dist/web.umd.js.map +1 -1
- package/docs/README.md +1 -1
- package/docs/components/Center.mdx +3 -1
- package/docs/components/Form.mdx +34 -7
- package/docs/components/Formik.mdx +7 -0
- package/docs/components/Vertical.mdx +4 -2
- package/docs/getting-started/component-usage.md +40 -16
- package/docs/getting-started/react-native.md +66 -0
- package/package.json +1 -1
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
|
-
-
|
|
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
|
|
package/docs/components/Form.mdx
CHANGED
|
@@ -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
|
-
|
|
674
|
-
<
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
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';
|
|
@@ -471,7 +471,10 @@ export const SplitLayout = () => (
|
|
|
471
471
|
|
|
472
472
|
**Performance:**
|
|
473
473
|
- Avoid deeply nested Vertical components when possible
|
|
474
|
-
-
|
|
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
|
|
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
|
-
|
|
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
|
-
<
|
|
103
|
-
<TextField
|
|
121
|
+
<Form onSubmit={handleSubmit}>
|
|
122
|
+
<TextField
|
|
104
123
|
label="Name"
|
|
124
|
+
accessibilityLabel="Name"
|
|
105
125
|
value={value}
|
|
106
|
-
|
|
126
|
+
onChangeText={setValue}
|
|
127
|
+
returnKeyType="done"
|
|
128
|
+
onSubmitEditing={handleSubmit}
|
|
107
129
|
/>
|
|
108
|
-
<Button type="submit">Submit</Button>
|
|
109
|
-
</
|
|
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
|
-
```
|
|
138
|
+
```tsx
|
|
117
139
|
import React from 'react';
|
|
118
|
-
import { 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
|
-
|
|
128
|
-
<
|
|
129
|
-
|
|
130
|
-
|
|
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:
|