@appdirect/design-system 0.0.19 → 0.0.21

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 (47) hide show
  1. package/README.md +21 -0
  2. package/bin/ad-sync-agents.mjs +542 -0
  3. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/CustomBottomToolbar.module.css +24 -1
  4. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.js +2 -1
  5. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.tsx +3 -0
  6. package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/CustomToolbarAlertBannerContent.module.css +9 -1
  7. package/dist/ComplexComponents/DataTable/CustomTopToolbar/CustomTopToolbar.module.css +7 -0
  8. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/DateRangeSelectorFilter.module.css +7 -0
  9. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.js +1 -1
  10. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.tsx +1 -0
  11. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.js +4 -2
  12. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.module.css +16 -0
  13. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.tsx +6 -3
  14. package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.js +2 -2
  15. package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.tsx +11 -8
  16. package/dist/ComplexComponents/DataTable/DataTableGrid/DataTableGrid.module.css +17 -3
  17. package/dist/ComplexComponents/DataTable/DataTableGrid/index.js +1 -1
  18. package/dist/ComplexComponents/DataTable/DataTableGrid/index.tsx +2 -2
  19. package/dist/ComplexComponents/DataTable/ToolbarAlertBanner/ToolbarAlertBanner.module.css +4 -1
  20. package/dist/DESIGN.md +49 -7
  21. package/dist/agent-kit/README.md +11 -0
  22. package/dist/agent-kit/manifest.json +81 -0
  23. package/dist/agent-kit/micro-ui/CLAUDE.md +1 -0
  24. package/dist/agent-kit/micro-ui/micro-ui.AGENTS.md +62 -0
  25. package/dist/agent-kit/rules/accessibility.mdc +46 -0
  26. package/dist/agent-kit/rules/module-federation.mdc +30 -0
  27. package/dist/agent-kit/rules/react-stack.mdc +73 -0
  28. package/dist/agent-kit/rules/testing.mdc +44 -0
  29. package/dist/agent-kit/skills/design-feature/SKILL.md +205 -0
  30. package/dist/agent-kit/skills/developer-handoff/SKILL.md +192 -0
  31. package/dist/agent-kit/skills/figma-mcp-integration/SKILL.md +134 -0
  32. package/dist/agent-kit/skills/figma-to-page/SKILL.md +24 -0
  33. package/dist/agent-kit/skills/mantine-combobox/SKILL.md +73 -0
  34. package/dist/agent-kit/skills/mantine-combobox/references/api.md +199 -0
  35. package/dist/agent-kit/skills/mantine-combobox/references/patterns.md +279 -0
  36. package/dist/agent-kit/skills/mantine-custom-components/SKILL.md +112 -0
  37. package/dist/agent-kit/skills/mantine-custom-components/references/api.md +407 -0
  38. package/dist/agent-kit/skills/mantine-custom-components/references/patterns.md +431 -0
  39. package/dist/agent-kit/skills/mantine-form/SKILL.md +103 -0
  40. package/dist/agent-kit/skills/mantine-form/references/api.md +313 -0
  41. package/dist/agent-kit/skills/mantine-form/references/patterns.md +310 -0
  42. package/dist/agent-kit/skills/prototype-page/SKILL.md +82 -0
  43. package/dist/contracts/index.json +1 -1
  44. package/dist/css/mantine.css +4 -4
  45. package/dist/skills/design-feature/SKILL.md +205 -0
  46. package/dist/stories/index.json +1 -1
  47. package/package.json +8 -4
@@ -0,0 +1,313 @@
1
+ # @mantine/form API Reference
2
+
3
+ ## Table of Contents
4
+ - [useForm options](#useform-options)
5
+ - [useForm return value](#useform-return-value)
6
+ - [useField](#usefield-hook)
7
+ - [createFormContext](#createformcontext)
8
+ - [createFormActions](#createformactions)
9
+ - [Built-in validators](#built-in-validators)
10
+ - [Validation rule format](#validation-rule-format)
11
+ - [Key types](#key-types)
12
+
13
+ ---
14
+
15
+ ## useForm options
16
+
17
+ ```ts
18
+ useForm<Values, TransformedValues>({
19
+ mode?,
20
+ initialValues?,
21
+ initialErrors?,
22
+ initialTouched?,
23
+ initialDirty?,
24
+ validate?,
25
+ validateInputOnChange?,
26
+ validateInputOnBlur?,
27
+ clearInputErrorOnChange?,
28
+ transformValues?,
29
+ onValuesChange?,
30
+ enhanceGetInputProps?,
31
+ onSubmitPreventDefault?,
32
+ touchTrigger?,
33
+ validateDebounce?,
34
+ resolveValidationError?,
35
+ name?,
36
+ })
37
+ ```
38
+
39
+ | Option | Type | Default | Description |
40
+ |---|---|---|---|
41
+ | `mode` | `'controlled' \| 'uncontrolled'` | `'controlled'` | Controlled: React state, re-renders on change. Uncontrolled: refs, no re-renders. |
42
+ | `initialValues` | `Values` | — | Starting values for all fields |
43
+ | `initialErrors` | `FormErrors` | `{}` | Starting error messages |
44
+ | `initialTouched` | `FormStatus` | `{}` | Starting touched flags |
45
+ | `initialDirty` | `FormStatus` | `{}` | Starting dirty flags |
46
+ | `validate` | `FormRules \| (values) => FormErrors \| Promise<FormErrors>` | — | Validation rules or function |
47
+ | `validateInputOnChange` | `boolean \| string[]` | `false` | Validate on change (all or named fields) |
48
+ | `validateInputOnBlur` | `boolean \| string[]` | `false` | Validate on blur (all or named fields) |
49
+ | `clearInputErrorOnChange` | `boolean` | `true` | Clear field error when its value changes |
50
+ | `transformValues` | `(values: Values) => TransformedValues` | identity | Transform values before they reach `onSubmit` handler |
51
+ | `onValuesChange` | `(values, previous) => void` | — | Called whenever any value changes |
52
+ | `enhanceGetInputProps` | `(payload) => object \| void` | — | Merge extra props into every `getInputProps` call |
53
+ | `onSubmitPreventDefault` | `'always' \| 'never' \| 'validation-failed'` | `'always'` | When to call `event.preventDefault()` |
54
+ | `touchTrigger` | `'focus' \| 'change'` | `'change'` | When a field becomes touched |
55
+ | `validateDebounce` | `number` | `0` | Debounce validation calls (ms) |
56
+ | `resolveValidationError` | `(error: unknown) => ReactNode` | message extractor | Transform raw validation errors to display values |
57
+ | `name` | `string` | — | Form name for `createFormActions` event bus |
58
+
59
+ ---
60
+
61
+ ## useForm return value
62
+
63
+ ### Values
64
+
65
+ | Member | Type | Description |
66
+ |---|---|---|
67
+ | `values` | `Values` | Current form values (reactive in controlled mode) |
68
+ | `errors` | `FormErrors` | Current errors keyed by field path |
69
+ | `submitting` | `boolean` | True while async `onSubmit` handler is pending |
70
+ | `initialized` | `boolean` | True after `initialize()` has been called |
71
+
72
+ ### Getting & setting values
73
+
74
+ | Method | Signature | Description |
75
+ |---|---|---|
76
+ | `getValues` | `() => Values` | Get current values snapshot |
77
+ | `getInitialValues` | `() => Values` | Get initial values snapshot |
78
+ | `setValues` | `(values: Partial<Values>) => void` | Merge partial values into form state |
79
+ | `setFieldValue` | `(path, value \| updater) => void` | Set a single field by dot-path |
80
+ | `setInitialValues` | `(values: Values) => void` | Update the initial values reference |
81
+ | `initialize` | `(values: Values) => void` | Reset form to given values and mark as initialized |
82
+ | `reset` | `() => void` | Reset to `initialValues`, clear errors/touched/dirty |
83
+ | `resetField` | `(path) => void` | Reset a single field to its initial value |
84
+
85
+ ### Errors
86
+
87
+ | Method | Signature | Description |
88
+ |---|---|---|
89
+ | `setErrors` | `(errors: FormErrors) => void` | Replace all errors |
90
+ | `setFieldError` | `(path, error: ReactNode) => void` | Set one field's error |
91
+ | `clearFieldError` | `(path) => void` | Clear one field's error |
92
+ | `clearErrors` | `() => void` | Clear all errors |
93
+
94
+ ### Dirty & touched
95
+
96
+ | Method | Signature | Description |
97
+ |---|---|---|
98
+ | `isDirty` | `(path?) => boolean` | True if field (or any field) differs from initial value |
99
+ | `isTouched` | `(path?) => boolean` | True if field (or any field) has been interacted with |
100
+ | `getDirty` | `() => FormStatus` | All dirty flags |
101
+ | `getTouched` | `() => FormStatus` | All touched flags |
102
+ | `setDirty` | `(status: FormStatus) => void` | Overwrite dirty flags |
103
+ | `setTouched` | `(status: FormStatus) => void` | Overwrite touched flags |
104
+ | `resetDirty` | `(values?) => void` | Reset dirty tracking (optionally to new baseline) |
105
+ | `resetTouched` | `() => void` | Reset all touched flags |
106
+
107
+ ### Array fields
108
+
109
+ | Method | Signature | Description |
110
+ |---|---|---|
111
+ | `insertListItem` | `(path, item, index?) => void` | Insert item at index (appends if omitted) |
112
+ | `removeListItem` | `(path, index) => void` | Remove item at index |
113
+ | `reorderListItem` | `(path, { from, to }) => void` | Move item from one index to another |
114
+ | `replaceListItem` | `(path, index, item) => void` | Replace item at index |
115
+
116
+ ### Validation
117
+
118
+ | Method | Signature | Description |
119
+ |---|---|---|
120
+ | `validate` | `() => FormValidationResult \| Promise<...>` | Validate all fields, returns result |
121
+ | `validateField` | `(path) => FormFieldValidationResult \| Promise<...>` | Validate one field |
122
+ | `isValid` | `(path?) => boolean \| Promise<boolean>` | True if form/field has no errors |
123
+ | `isValidating` | `(path?) => boolean` | True if async validation is pending |
124
+ | `setSubmitting` | `(value: boolean) => void` | Manually control `submitting` flag |
125
+
126
+ ### Submission
127
+
128
+ | Method | Signature | Description |
129
+ |---|---|---|
130
+ | `onSubmit` | `(handler, onError?) => FormEventHandler` | Returns event handler; calls `handler(values)` only when valid |
131
+ | `onReset` | `FormEventHandler` | Pass to `<form onReset>` to reset on native reset |
132
+ | `getTransformedValues` | `(values?) => TransformedValues` | Apply `transformValues` to given or current values |
133
+
134
+ ### Input binding
135
+
136
+ | Method | Signature | Description |
137
+ |---|---|---|
138
+ | `getInputProps` | `(path, options?) => object` | Returns `{ value, onChange, error, onFocus, onBlur }` to spread on an input |
139
+ | `getInputNode` | `(path) => HTMLElement \| null` | Get the DOM node for a field (uncontrolled mode) |
140
+ | `key` | `(path) => string` | React `key` for uncontrolled inputs that need forced re-renders |
141
+
142
+ **`getInputProps` options:**
143
+ ```ts
144
+ {
145
+ type?: 'input' | 'checkbox' // 'checkbox' uses checked/defaultChecked instead of value
146
+ withError?: boolean // default true — include error prop
147
+ withFocus?: boolean // default true — include onFocus/onBlur for touched tracking
148
+ }
149
+ ```
150
+
151
+ ### Watch
152
+
153
+ | Method | Signature | Description |
154
+ |---|---|---|
155
+ | `watch` | `(path, subscriber) => void` | Subscribe to a field's changes |
156
+
157
+ Subscriber receives `{ value, previousValue, touched, dirty }`.
158
+
159
+ ---
160
+
161
+ ## useField hook
162
+
163
+ Standalone single-field hook — no full form needed.
164
+
165
+ ```ts
166
+ const field = useField({
167
+ initialValue,
168
+ validate?,
169
+ validateOnChange?, // boolean, default false
170
+ validateOnBlur?, // boolean, default false
171
+ clearErrorOnChange?, // boolean, default true
172
+ initialError?,
173
+ initialTouched?, // boolean, default false
174
+ onValueChange?,
175
+ type?, // 'input' | 'checkbox', default 'input'
176
+ mode?, // 'controlled' | 'uncontrolled', default 'controlled'
177
+ resolveValidationError?,
178
+ })
179
+ ```
180
+
181
+ **Return value:**
182
+ ```ts
183
+ {
184
+ getInputProps(options?) // spread on input
185
+ getValue() // current value
186
+ setValue(value) // set value
187
+ reset() // reset to initial state
188
+ validate() // returns Promise<ReactNode | void>
189
+ isValidating // boolean
190
+ error // ReactNode
191
+ setError(error)
192
+ isTouched() // boolean
193
+ isDirty() // boolean
194
+ resetTouched()
195
+ key // number — for uncontrolled re-render forcing
196
+ }
197
+ ```
198
+
199
+ ---
200
+
201
+ ## createFormContext
202
+
203
+ Shares a `useForm` instance across multiple components via React context.
204
+
205
+ ```ts
206
+ const [FormProvider, useFormContext, useForm] = createFormContext<Values>();
207
+ ```
208
+
209
+ Returns a tuple:
210
+ - **`FormProvider`** — `<FormProvider form={form}>` wraps the subtree
211
+ - **`useFormContext`** — access the form anywhere inside the provider (throws if used outside)
212
+ - **`useForm`** — same as the package-level `useForm` but typed to `Values`
213
+
214
+ ---
215
+
216
+ ## createFormActions
217
+
218
+ Event-bus API for controlling a named form from outside its React tree.
219
+
220
+ ```ts
221
+ const actions = createFormActions<Values>('my-form-name');
222
+ ```
223
+
224
+ The form must be created with the same `name`:
225
+ ```ts
226
+ const form = useForm({ name: 'my-form-name', initialValues: {...} });
227
+ ```
228
+
229
+ **Available actions** (all dispatch custom DOM events):
230
+ `setFieldValue`, `setValues`, `setInitialValues`, `setErrors`, `setFieldError`,
231
+ `clearFieldError`, `clearErrors`, `reset`, `validate`, `validateField`,
232
+ `insertListItem`, `removeListItem`, `reorderListItem`, `setDirty`, `setTouched`,
233
+ `resetDirty`, `resetTouched`
234
+
235
+ ---
236
+
237
+ ## Built-in validators
238
+
239
+ All validators return a rule function `(value, values) => ReactNode | null`.
240
+
241
+ | Validator | Signature | Validates |
242
+ |---|---|---|
243
+ | `isNotEmpty(error?)` | — | Not null, undefined, false, empty string, or empty array |
244
+ | `isEmail(error?)` | — | Valid email format |
245
+ | `isUrl(error?)` | `isUrl({ protocols?, allowLocalhost? }, error?)` | Valid URL (default: http/https, no localhost) |
246
+ | `matches(regexp, error?)` | — | String matches regex |
247
+ | `hasLength(payload, error?)` | `payload: number \| { min?, max? }` | String/array length (exact or range) |
248
+ | `isInRange({ min?, max? }, error?)` | — | Number within range |
249
+ | `matchesField(fieldName, error?)` | — | Value equals another field's value |
250
+ | `isNotEmptyHTML(error?)` | — | HTML string is not empty after stripping tags |
251
+ | `isJSONString(error?)` | — | String is valid JSON |
252
+ | `isOneOf(values[], error?)` | — | Value is one of allowed values |
253
+
254
+ All `error` arguments are optional `ReactNode` — omit to use a default message.
255
+
256
+ ---
257
+
258
+ ## Validation rule format
259
+
260
+ ```ts
261
+ // Rules object — keys match form field names, nested objects follow the values shape
262
+ validate: {
263
+ name: isNotEmpty(),
264
+ address: {
265
+ street: isNotEmpty(),
266
+ zip: matches(/^\d{5}$/, 'Invalid ZIP'),
267
+ },
268
+ // Validate the array itself (not its items) with formRootRule:
269
+ tags: {
270
+ [formRootRule]: (tags) => tags.length > 0 ? null : 'At least one tag required',
271
+ 0: isNotEmpty(), // validates items too
272
+ }
273
+ }
274
+
275
+ // Function — receives full values, returns errors object
276
+ validate: (values) => ({
277
+ endDate: values.endDate <= values.startDate ? 'Must be after start date' : null,
278
+ })
279
+
280
+ // Async — return a Promise from any rule
281
+ validate: {
282
+ username: async (value, values, path, signal) => {
283
+ const taken = await checkUsername(value, { signal });
284
+ if (signal?.aborted) return null;
285
+ return taken ? 'Username is taken' : null;
286
+ }
287
+ }
288
+ ```
289
+
290
+ Validators receive `(value, allValues, fieldPath, abortSignal?)`. The `abortSignal` is provided for async rules — check `signal.aborted` before applying stale results.
291
+
292
+ ---
293
+
294
+ ## Key types
295
+
296
+ ```ts
297
+ type FormErrors = Record<string, ReactNode>
298
+ type FormStatus = Record<string, boolean>
299
+
300
+ interface FormValidationResult {
301
+ hasErrors: boolean
302
+ errors: FormErrors
303
+ }
304
+
305
+ interface FormFieldValidationResult {
306
+ hasError: boolean
307
+ error: ReactNode
308
+ }
309
+
310
+ // Path utilities (for typed field paths)
311
+ type LooseKeys<T> // union of all dot-paths into T
312
+ type FormPathValue<T, Path> // value type at a given path
313
+ ```
@@ -0,0 +1,310 @@
1
+ # @mantine/form Patterns
2
+
3
+ ## Table of Contents
4
+ - [Basic form with validation](#basic-form-with-validation)
5
+ - [Nested object fields](#nested-object-fields)
6
+ - [Array / list fields](#array--list-fields)
7
+ - [Async validation](#async-validation)
8
+ - [Form context across components](#form-context-across-components)
9
+ - [transformValues](#transformvalues)
10
+ - [Uncontrolled mode](#uncontrolled-mode)
11
+ - [Standalone useField](#standalone-usefield)
12
+ - [Server errors after submission](#server-errors-after-submission)
13
+
14
+ ---
15
+
16
+ ## Basic form with validation
17
+
18
+ ```tsx
19
+ import { useForm, isEmail, isNotEmpty, hasLength } from '@mantine/form';
20
+
21
+ function BasicForm() {
22
+ const form = useForm({
23
+ initialValues: { name: '', email: '', password: '' },
24
+ validate: {
25
+ name: isNotEmpty('Name is required'),
26
+ email: isEmail('Invalid email'),
27
+ password: hasLength({ min: 8 }, 'Password must be at least 8 characters'),
28
+ },
29
+ });
30
+
31
+ return (
32
+ <form onSubmit={form.onSubmit((values) => console.log(values))}>
33
+ <TextInput label="Name" {...form.getInputProps('name')} />
34
+ <TextInput label="Email" {...form.getInputProps('email')} />
35
+ <PasswordInput label="Password" {...form.getInputProps('password')} />
36
+ <Button type="submit">Submit</Button>
37
+ </form>
38
+ );
39
+ }
40
+ ```
41
+
42
+ ---
43
+
44
+ ## Nested object fields
45
+
46
+ Use dot notation to address nested fields.
47
+
48
+ ```tsx
49
+ const form = useForm({
50
+ initialValues: {
51
+ user: {
52
+ name: '',
53
+ address: {
54
+ city: '',
55
+ zip: '',
56
+ },
57
+ },
58
+ },
59
+ validate: {
60
+ user: {
61
+ name: isNotEmpty('Required'),
62
+ address: {
63
+ city: isNotEmpty('City is required'),
64
+ zip: matches(/^\d{5}$/, 'Must be 5 digits'),
65
+ },
66
+ },
67
+ },
68
+ });
69
+
70
+ // Access nested fields with dot notation
71
+ <TextInput {...form.getInputProps('user.name')} />
72
+ <TextInput {...form.getInputProps('user.address.city')} />
73
+ <TextInput {...form.getInputProps('user.address.zip')} />
74
+ ```
75
+
76
+ ---
77
+
78
+ ## Array / list fields
79
+
80
+ ```tsx
81
+ interface Employee {
82
+ name: string;
83
+ role: string;
84
+ }
85
+
86
+ const form = useForm({
87
+ initialValues: {
88
+ employees: [{ name: '', role: '' }] as Employee[],
89
+ },
90
+ validate: {
91
+ employees: {
92
+ name: isNotEmpty('Name required'),
93
+ role: isNotEmpty('Role required'),
94
+ },
95
+ },
96
+ });
97
+
98
+ // Render the list
99
+ const fields = form.values.employees.map((_, index) => (
100
+ <Group key={form.key(`employees.${index}`)}>
101
+ <TextInput
102
+ {...form.getInputProps(`employees.${index}.name`)}
103
+ placeholder="Name"
104
+ />
105
+ <TextInput
106
+ {...form.getInputProps(`employees.${index}.role`)}
107
+ placeholder="Role"
108
+ />
109
+ <ActionIcon onClick={() => form.removeListItem('employees', index)}>
110
+ <IconTrash />
111
+ </ActionIcon>
112
+ </Group>
113
+ ));
114
+
115
+ return (
116
+ <form onSubmit={form.onSubmit((values) => console.log(values))}>
117
+ {fields}
118
+ <Button onClick={() => form.insertListItem('employees', { name: '', role: '' })}>
119
+ Add employee
120
+ </Button>
121
+ <Button type="submit">Submit</Button>
122
+ </form>
123
+ );
124
+ ```
125
+
126
+ **List methods:**
127
+ ```tsx
128
+ form.insertListItem('employees', { name: '', role: '' }); // append
129
+ form.insertListItem('employees', { name: '', role: '' }, 0); // prepend
130
+ form.removeListItem('employees', index);
131
+ form.reorderListItem('employees', { from: 2, to: 0 });
132
+ form.replaceListItem('employees', index, { name: 'New', role: 'Dev' });
133
+ ```
134
+
135
+ ---
136
+
137
+ ## Async validation
138
+
139
+ Return a `Promise` from any validator. Use the provided `AbortSignal` to avoid stale results.
140
+
141
+ ```tsx
142
+ const form = useForm({
143
+ initialValues: { username: '' },
144
+ validate: {
145
+ username: async (value, _values, _path, signal) => {
146
+ if (!value) return 'Username is required';
147
+ const response = await fetch(`/api/check-username?q=${value}`, { signal });
148
+ if (signal?.aborted) return null;
149
+ const { taken } = await response.json();
150
+ return taken ? 'Username is already taken' : null;
151
+ },
152
+ },
153
+ validateInputOnChange: ['username'],
154
+ validateDebounce: 500, // debounce async calls
155
+ });
156
+ ```
157
+
158
+ Check `form.isValidating()` to show a loading indicator while async validation runs.
159
+
160
+ ---
161
+
162
+ ## Form context across components
163
+
164
+ Share one form instance across a component tree without prop drilling.
165
+
166
+ ```tsx
167
+ // 1. Create typed context once
168
+ import { createFormContext, isNotEmpty } from '@mantine/form';
169
+
170
+ interface ProfileValues {
171
+ bio: string;
172
+ website: string;
173
+ }
174
+
175
+ const [FormProvider, useFormContext, useProfileForm] = createFormContext<ProfileValues>();
176
+
177
+ // 2. Wrap your form tree with FormProvider
178
+ function ProfileForm() {
179
+ const form = useProfileForm({
180
+ initialValues: { bio: '', website: '' },
181
+ validate: {
182
+ bio: isNotEmpty('Bio is required'),
183
+ },
184
+ });
185
+
186
+ return (
187
+ <FormProvider form={form}>
188
+ <form onSubmit={form.onSubmit((values) => save(values))}>
189
+ <BioField />
190
+ <WebsiteField />
191
+ <Button type="submit">Save</Button>
192
+ </form>
193
+ </FormProvider>
194
+ );
195
+ }
196
+
197
+ // 3. Access form in any child — no prop drilling
198
+ function BioField() {
199
+ const form = useFormContext();
200
+ return <Textarea label="Bio" {...form.getInputProps('bio')} />;
201
+ }
202
+
203
+ function WebsiteField() {
204
+ const form = useFormContext();
205
+ return <TextInput label="Website" {...form.getInputProps('website')} />;
206
+ }
207
+ ```
208
+
209
+ ---
210
+
211
+ ## transformValues
212
+
213
+ Shape the values before they reach `onSubmit`. The transform is applied transparently — `onSubmit` receives `TransformedValues`, not `Values`.
214
+
215
+ ```tsx
216
+ const form = useForm({
217
+ initialValues: {
218
+ price: '', // stored as string in input
219
+ tags: 'a, b, c', // stored as comma-separated string
220
+ },
221
+ transformValues: (values) => ({
222
+ price: Number(values.price),
223
+ tags: values.tags.split(',').map((t) => t.trim()),
224
+ }),
225
+ });
226
+
227
+ // handler receives { price: number, tags: string[] }
228
+ form.onSubmit((values) => console.log(values));
229
+ ```
230
+
231
+ ---
232
+
233
+ ## Uncontrolled mode
234
+
235
+ Use when performance matters (large forms, frequent updates). The form does not cause React re-renders on input changes.
236
+
237
+ ```tsx
238
+ const form = useForm({
239
+ mode: 'uncontrolled',
240
+ initialValues: { name: '', email: '' },
241
+ validate: { email: isEmail() },
242
+ });
243
+
244
+ // Same API — getInputProps works identically
245
+ <TextInput {...form.getInputProps('name')} label="Name" />
246
+ <TextInput {...form.getInputProps('email')} label="Email" />
247
+
248
+ // To read current values imperatively:
249
+ const current = form.getValues();
250
+
251
+ // To force a controlled re-render of a specific input (e.g. after reset):
252
+ <TextInput key={form.key('name')} {...form.getInputProps('name')} />
253
+ ```
254
+
255
+ `form.values` and `form.errors` are not reactive in uncontrolled mode — use `form.getValues()` and `form.errors` only inside event handlers, or subscribe via `watch`.
256
+
257
+ ---
258
+
259
+ ## Standalone useField
260
+
261
+ Manage a single field without a full form — useful for isolated inputs or custom field components.
262
+
263
+ ```tsx
264
+ import { useField, isEmail } from '@mantine/form';
265
+
266
+ function EmailField() {
267
+ const field = useField({
268
+ initialValue: '',
269
+ validate: isEmail('Invalid email'),
270
+ validateOnBlur: true,
271
+ });
272
+
273
+ return (
274
+ <TextInput
275
+ label="Email"
276
+ {...field.getInputProps()}
277
+ onBlur={() => field.validate()}
278
+ />
279
+ );
280
+ }
281
+ ```
282
+
283
+ ---
284
+
285
+ ## Server errors after submission
286
+
287
+ Set server-side errors on fields after a failed API call.
288
+
289
+ ```tsx
290
+ const form = useForm({ initialValues: { email: '', password: '' } });
291
+
292
+ const handleSubmit = async (values: typeof form.values) => {
293
+ try {
294
+ await login(values);
295
+ } catch (error) {
296
+ if (error.fields) {
297
+ // Map server field errors onto form
298
+ form.setErrors(error.fields);
299
+ } else {
300
+ form.setFieldError('password', 'Invalid email or password');
301
+ }
302
+ }
303
+ };
304
+
305
+ <form onSubmit={form.onSubmit(handleSubmit)}>
306
+ <TextInput {...form.getInputProps('email')} label="Email" />
307
+ <PasswordInput {...form.getInputProps('password')} label="Password" />
308
+ <Button type="submit" loading={form.submitting}>Sign in</Button>
309
+ </form>
310
+ ```
@@ -0,0 +1,82 @@
1
+ ---
2
+ name: prototype-page
3
+ description: Build or change one screen in a micro-ui-ts standalone prototype. Use when a PM or designer asks for a screen, when editing standalone mode, or when placing a page in merchant-nav. Ask which menu it belongs in, and show the menu list, before building.
4
+ ---
5
+
6
+ # Standalone prototype
7
+
8
+ Standalone mode is the host. Prototype screens live in `src/` so they can be copied into a real micro UI. `standalone/` is only the shell: layout, config, and navigation mocks. Do not put screens there.
9
+
10
+ Header is always on. Sidenav is secondary plus tertiary for one namespace. It is optional (`sidenav: false`).
11
+
12
+ Copying a Figma node onto a page is the `figma-to-page` skill. That skill asks which prototype, the Figma URL, and which page. Do not ask for the URL in this skill.
13
+
14
+ ## Ask before building
15
+
16
+ Ask which menu first, unless it was already chosen. Show this list in the question and wait. Do not guess.
17
+
18
+ - Account — `account`
19
+ - Analytics — `analytics`
20
+ - Network — `corporate`
21
+ - Platform Manager — `admin`
22
+ - Energy Customer Portal — `box-customer-portal`
23
+ - Developer — `cms`
24
+ - Distribution — `distribution`
25
+ - Unified Expense Management — `expense`
26
+ - Marketplace — `marketplace`
27
+ - The Grid — `provider-exchange`
28
+ - Advisor Portal — namespace `reseller`, menu `advisor` (`standalone/mocks/navigation/advisor.json`)
29
+ - Reseller — namespace `reseller`, menu `reseller` (`standalone/mocks/navigation/reseller.json`)
30
+ - Superuser — `superuser`
31
+ - ASO — `aso`
32
+ - vCom — `vcomnetwork` (`standalone/mocks/navigation/vcomnetwork.json`; not in the navigation service)
33
+
34
+ The value after the dash is the `namespace` in `standalone/standalone.config.ts`. Advisor Portal and Reseller share `reseller`; set `menus.reseller` to `advisor` or `reseller`.
35
+
36
+ Then ask whatever is still unanswered. Do not build yet.
37
+
38
+ **PM**
39
+
40
+ - Who is looking at this? Persona: `end-user`, `company-admin`, `marketplace-manager`, `reseller`, `reseller-manager`, `network-manager`, `reports-manager`, `developer`, `sales-support`, `customer-support`, `product-support`, `superuser`, `super-support`.
41
+ - Which edition? `standard`, `professional-enterprise`, or `appsmart`.
42
+ - Should the sidenav be open, and which secondary item is selected?
43
+ - What job is this screen for, and what is out of scope?
44
+ - What data is on the screen? If the API shape is unknown, say so — the prototype will use a labeled mock.
45
+ - Which states matter for review: empty, loading, error, success?
46
+
47
+ **UX**
48
+
49
+ - Nav label, icon, and the tertiary collection the item belongs to (`collectionName` in `standalone/mocks/navigation/<namespace>.json`).
50
+ - The one primary action.
51
+ - What copy and data are real, and what is placeholder.
52
+ - Desktop only, or also the compact sidenav (under 1280px).
53
+
54
+ Build that one screen after the answers. Do not add other screens in the same turn.
55
+
56
+ ## Config
57
+
58
+ Edit `standalone/standalone.config.ts`:
59
+
60
+ - `merchantNavUrl` — script URL. Local default `http://localhost:9000/merchant-nav.js`.
61
+ - `persona`, `edition`, `sidenav` (`{ namespace, selected }` or `false`).
62
+ - `menus` — which menu file a namespace loads. `menus.reseller` is `"advisor"` (Advisor Portal) or `"reseller"` (Reseller). Edit that file, not the other one.
63
+ - `sidenavTitles` — optional heading override. Leave it out and the reseller menu sets the heading: Advisor Portal or Reseller.
64
+ - `sidenavSubtitles` — optional second line under that heading. vCom uses "Manage Network & Mobile".
65
+ - `pages[]` — `path`, `label`, `iconType`, `namespace`, `collection`.
66
+
67
+ Query overrides: `?persona=&edition=&namespace=&menu=&merchantNav=`. `menu` is `advisor` or `reseller` and only applies with `namespace=reseller`.
68
+
69
+ `collection` must be a `collectionName` from the menu file that namespace loads (`secondaryNav` or `tertiary-*`). For reseller, that is `advisor.json` or `reseller.json`. `path` must also be in `routePaths` in `src/navigation/router.tsx`.
70
+
71
+ ## Build
72
+
73
+ 1. Read `standalone/AGENTS.md`, the design-system section of the root `AGENTS.md`, and `.cursor/rules/accessibility.mdc`.
74
+ 2. Add the page under `src/pages/<Name>/` and the route. Append the path to `routePaths`.
75
+ 3. Register it in `pages` so it shows in the sidenav.
76
+ 4. For data, run `npm run new:resource <name>`. That wires the mock store (fixture + collection + service). The page imports only the hook. Never call `/api/prototype/…` over the network. If the API is unknown, write the type and a `satisfies` fixture and mark the fields the PM has not confirmed. Scenarios and per-role seeds are the `add-mock-data` skill in the prototype platform. Do not edit the top bar.
77
+ 5. User-facing text goes through `translate("key")` from `fe-tools/lib/api/translate`. Use the same key the Localization Service already has. Standalone does not define a second key. Add the English value to `standalone/mocks/localization/en-US.json` (ICU syntax, e.g. `{count}`). `standalone/mocks/localization.ts` serves that file on the same URL fe-tools calls. The federated build does not include it.
78
+ 6. Use `@mantine/core` and `--ad-*` tokens. No Tailwind. No hex except the header chrome already in the shell.
79
+
80
+ ## Run
81
+
82
+ Merchant-nav first (`npm run dev` in that repo, port 9000), then `npm run standalone` here (port 7240). Open the page path. Click the injected nav item and check the states you agreed with the PM.