@appdirect/design-system 0.0.18 → 0.0.20

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 (36) hide show
  1. package/README.md +21 -0
  2. package/bin/ad-sync-agents.mjs +542 -0
  3. package/dist/ComplexComponents/DashboardWidget/DashboardWidget.js +15 -51
  4. package/dist/ComplexComponents/DashboardWidget/DashboardWidget.tsx +91 -139
  5. package/dist/ComplexComponents/KeyInsight/index.ts +1 -1
  6. package/dist/DESIGN.md +49 -7
  7. package/dist/agent-kit/README.md +11 -0
  8. package/dist/agent-kit/manifest.json +81 -0
  9. package/dist/agent-kit/micro-ui/CLAUDE.md +1 -0
  10. package/dist/agent-kit/micro-ui/micro-ui.AGENTS.md +62 -0
  11. package/dist/agent-kit/rules/accessibility.mdc +46 -0
  12. package/dist/agent-kit/rules/module-federation.mdc +30 -0
  13. package/dist/agent-kit/rules/react-stack.mdc +73 -0
  14. package/dist/agent-kit/rules/testing.mdc +44 -0
  15. package/dist/agent-kit/skills/design-feature/SKILL.md +205 -0
  16. package/dist/agent-kit/skills/developer-handoff/SKILL.md +192 -0
  17. package/dist/agent-kit/skills/figma-mcp-integration/SKILL.md +134 -0
  18. package/dist/agent-kit/skills/figma-to-page/SKILL.md +24 -0
  19. package/dist/agent-kit/skills/mantine-combobox/SKILL.md +73 -0
  20. package/dist/agent-kit/skills/mantine-combobox/references/api.md +199 -0
  21. package/dist/agent-kit/skills/mantine-combobox/references/patterns.md +279 -0
  22. package/dist/agent-kit/skills/mantine-custom-components/SKILL.md +112 -0
  23. package/dist/agent-kit/skills/mantine-custom-components/references/api.md +407 -0
  24. package/dist/agent-kit/skills/mantine-custom-components/references/patterns.md +431 -0
  25. package/dist/agent-kit/skills/mantine-form/SKILL.md +103 -0
  26. package/dist/agent-kit/skills/mantine-form/references/api.md +313 -0
  27. package/dist/agent-kit/skills/mantine-form/references/patterns.md +310 -0
  28. package/dist/agent-kit/skills/prototype-page/SKILL.md +82 -0
  29. package/dist/contracts/DashboardWidget.json +92 -0
  30. package/dist/contracts/index.json +6 -1
  31. package/dist/css/mantine.css +172 -6
  32. package/dist/css/tokens.css +54 -4
  33. package/dist/skills/design-feature/SKILL.md +205 -0
  34. package/dist/stories/ComplexComponents/DashboardWidget/DashboardWidget.stories.tsx +76 -1
  35. package/dist/stories/index.json +4 -1
  36. package/package.json +8 -4
@@ -0,0 +1,431 @@
1
+ # Custom Component Patterns
2
+
3
+ ## Table of Contents
4
+ - [Minimal component (no styles API)](#minimal-component-no-styles-api)
5
+ - [Component with CSS variables](#component-with-css-variables)
6
+ - [Compound component with context](#compound-component-with-context)
7
+ - [Polymorphic component](#polymorphic-component)
8
+ - [Generic component](#generic-component)
9
+ - [Theme integration](#theme-integration)
10
+ - [Namespace exports](#namespace-exports)
11
+
12
+ ---
13
+
14
+ ## Minimal component (no styles API)
15
+
16
+ When you don't need theming/Styles API support — just Box + useProps.
17
+
18
+ ```tsx
19
+ import { Box, BoxProps, ElementProps, factory, Factory, useProps } from '@mantine/core';
20
+
21
+ export interface MinimalProps extends BoxProps, ElementProps<'div'> {
22
+ label?: string;
23
+ }
24
+
25
+ export type MinimalFactory = Factory<{
26
+ props: MinimalProps;
27
+ ref: HTMLDivElement;
28
+ }>;
29
+
30
+ const defaultProps = {} satisfies Partial<MinimalProps>;
31
+
32
+ export const Minimal = factory<MinimalFactory>((_props) => {
33
+ const props = useProps('Minimal', defaultProps, _props);
34
+ const { label, children, ...others } = props;
35
+
36
+ return (
37
+ <Box {...others}>
38
+ {label && <span>{label}</span>}
39
+ {children}
40
+ </Box>
41
+ );
42
+ });
43
+
44
+ Minimal.displayName = '@mantine/core/Minimal';
45
+ ```
46
+
47
+ ---
48
+
49
+ ## Component with CSS variables
50
+
51
+ Full example with Styles API, CSS variables, and theme integration.
52
+
53
+ **MyComponent.module.css:**
54
+ ```css
55
+ .root {
56
+ border-radius: var(--my-radius);
57
+ padding: var(--my-padding);
58
+ }
59
+
60
+ .inner {
61
+ font-size: var(--my-fz);
62
+ }
63
+ ```
64
+
65
+ **MyComponent.tsx:**
66
+ ```tsx
67
+ import {
68
+ Box, BoxProps, createVarsResolver, ElementProps, factory, Factory,
69
+ getFontSize, getRadius, getSpacing, MantineFontSize, MantineRadius,
70
+ MantineSpacing, StylesApiProps, useProps, useStyles,
71
+ } from '@mantine/core';
72
+ import classes from './MyComponent.module.css';
73
+
74
+ export type MyComponentStylesNames = 'root' | 'inner';
75
+ export type MyComponentVariant = 'filled' | 'outline';
76
+ export type MyComponentCssVariables = {
77
+ root: '--my-radius' | '--my-padding';
78
+ inner: '--my-fz';
79
+ };
80
+
81
+ export interface MyComponentProps
82
+ extends BoxProps, StylesApiProps<MyComponentFactory>, ElementProps<'div'> {
83
+ radius?: MantineRadius;
84
+ padding?: MantineSpacing;
85
+ size?: MantineFontSize;
86
+ variant?: MyComponentVariant;
87
+ }
88
+
89
+ export type MyComponentFactory = Factory<{
90
+ props: MyComponentProps;
91
+ ref: HTMLDivElement;
92
+ stylesNames: MyComponentStylesNames;
93
+ vars: MyComponentCssVariables;
94
+ variant: MyComponentVariant;
95
+ }>;
96
+
97
+ const defaultProps = {
98
+ radius: 'sm',
99
+ padding: 'md',
100
+ size: 'md',
101
+ } satisfies Partial<MyComponentProps>;
102
+
103
+ const varsResolver = createVarsResolver<MyComponentFactory>((_theme, { radius, padding, size }) => ({
104
+ root: {
105
+ '--my-radius': getRadius(radius),
106
+ '--my-padding': getSpacing(padding),
107
+ },
108
+ inner: {
109
+ '--my-fz': getFontSize(size),
110
+ },
111
+ }));
112
+
113
+ export const MyComponent = factory<MyComponentFactory>((_props) => {
114
+ const props = useProps('MyComponent', defaultProps, _props);
115
+ const {
116
+ classNames, className, style, styles, unstyled, vars, attributes,
117
+ radius, padding, size,
118
+ children,
119
+ ...others
120
+ } = props;
121
+
122
+ const getStyles = useStyles<MyComponentFactory>({
123
+ name: 'MyComponent',
124
+ classes,
125
+ props,
126
+ className,
127
+ style,
128
+ classNames,
129
+ styles,
130
+ unstyled,
131
+ vars,
132
+ attributes,
133
+ varsResolver,
134
+ });
135
+
136
+ return (
137
+ <Box {...getStyles('root')} {...others}>
138
+ <div {...getStyles('inner')}>{children}</div>
139
+ </Box>
140
+ );
141
+ });
142
+
143
+ MyComponent.displayName = '@mantine/core/MyComponent';
144
+ MyComponent.classes = classes;
145
+ MyComponent.varsResolver = varsResolver;
146
+ ```
147
+
148
+ ---
149
+
150
+ ## Compound component with context
151
+
152
+ Pattern for components with typed sub-components (e.g. `Card.Section`, `Tabs.Tab`).
153
+
154
+ **MyCard.context.ts:**
155
+ ```ts
156
+ import { createSafeContext, GetStylesApi } from '@mantine/core';
157
+ import type { MyCardFactory } from './MyCard';
158
+
159
+ interface MyCardContextValue {
160
+ getStyles: GetStylesApi<MyCardFactory>;
161
+ orientation: 'horizontal' | 'vertical';
162
+ }
163
+
164
+ export const [MyCardProvider, useMyCardContext] = createSafeContext<MyCardContextValue>(
165
+ 'MyCard component was not found in tree'
166
+ );
167
+ ```
168
+
169
+ **MyCardSection.tsx** (sub-component):
170
+ ```tsx
171
+ import {
172
+ Box, BoxProps, CompoundStylesApiProps, ElementProps,
173
+ factory, Factory, useProps, useStyles,
174
+ } from '@mantine/core';
175
+ import { useMyCardContext } from './MyCard.context';
176
+ import classes from './MyCard.module.css';
177
+
178
+ export type MyCardSectionStylesNames = 'section';
179
+
180
+ export interface MyCardSectionProps
181
+ extends BoxProps, CompoundStylesApiProps<MyCardSectionFactory>, ElementProps<'div'> {
182
+ withBorder?: boolean;
183
+ }
184
+
185
+ export type MyCardSectionFactory = Factory<{
186
+ props: MyCardSectionProps;
187
+ ref: HTMLDivElement;
188
+ stylesNames: MyCardSectionStylesNames;
189
+ compound: true; // marks as a compound sub-component
190
+ }>;
191
+
192
+ const defaultProps = {} satisfies Partial<MyCardSectionProps>;
193
+
194
+ export const MyCardSection = factory<MyCardSectionFactory>((_props) => {
195
+ const props = useProps('MyCardSection', defaultProps, _props);
196
+ const { className, style, classNames, styles, withBorder, children, ...others } = props;
197
+
198
+ // Access styles from parent context
199
+ const { getStyles } = useMyCardContext();
200
+
201
+ return (
202
+ <Box
203
+ {...getStyles('section', { className, style, classNames, styles })}
204
+ data-with-border={withBorder || undefined}
205
+ {...others}
206
+ >
207
+ {children}
208
+ </Box>
209
+ );
210
+ });
211
+
212
+ MyCardSection.displayName = '@mantine/core/MyCardSection';
213
+ ```
214
+
215
+ **MyCard.tsx** (root component):
216
+ ```tsx
217
+ import { MyCardProvider } from './MyCard.context';
218
+
219
+ // ... (same Styles API setup as above)
220
+
221
+ export type MyCardFactory = Factory<{
222
+ props: MyCardProps;
223
+ ref: HTMLDivElement;
224
+ stylesNames: 'root' | 'section'; // include sub-component selectors too
225
+ staticComponents: {
226
+ Section: typeof MyCardSection;
227
+ };
228
+ }>;
229
+
230
+ export const MyCard = factory<MyCardFactory>((_props) => {
231
+ const props = useProps('MyCard', defaultProps, _props);
232
+ const {
233
+ classNames, className, style, styles, unstyled, vars, attributes,
234
+ orientation, children, ...others
235
+ } = props;
236
+
237
+ const getStyles = useStyles<MyCardFactory>({ ... });
238
+
239
+ return (
240
+ <MyCardProvider value={{ getStyles, orientation: orientation ?? 'vertical' }}>
241
+ <Box {...getStyles('root')} {...others}>{children}</Box>
242
+ </MyCardProvider>
243
+ );
244
+ });
245
+
246
+ MyCard.displayName = '@mantine/core/MyCard';
247
+ MyCard.classes = classes;
248
+ MyCard.Section = MyCardSection; // attach sub-component
249
+ ```
250
+
251
+ ---
252
+
253
+ ## Polymorphic component
254
+
255
+ Supports `component` prop to render as any element or React component.
256
+
257
+ ```tsx
258
+ import {
259
+ Box, BoxProps, polymorphicFactory, PolymorphicFactory,
260
+ StylesApiProps, useProps, useStyles,
261
+ } from '@mantine/core';
262
+
263
+ export type MyLinkStylesNames = 'root';
264
+
265
+ export interface MyLinkProps extends BoxProps, StylesApiProps<MyLinkFactory> {
266
+ active?: boolean;
267
+ }
268
+
269
+ export type MyLinkFactory = PolymorphicFactory<{
270
+ props: MyLinkProps;
271
+ defaultRef: HTMLAnchorElement;
272
+ defaultComponent: 'a'; // renders as <a> unless component prop is provided
273
+ stylesNames: MyLinkStylesNames;
274
+ }>;
275
+
276
+ const defaultProps = {} satisfies Partial<MyLinkProps>;
277
+
278
+ export const MyLink = polymorphicFactory<MyLinkFactory>((_props) => {
279
+ const props = useProps('MyLink', defaultProps, _props);
280
+ const {
281
+ classNames, className, style, styles, unstyled, vars, attributes,
282
+ active, ...others
283
+ } = props;
284
+
285
+ const getStyles = useStyles<MyLinkFactory>({
286
+ name: 'MyLink', classes, props, className, style,
287
+ classNames, styles, unstyled, vars, attributes,
288
+ });
289
+
290
+ return (
291
+ <Box
292
+ component="a" // default element
293
+ data-active={active || undefined}
294
+ {...getStyles('root')}
295
+ {...others}
296
+ />
297
+ );
298
+ });
299
+
300
+ MyLink.displayName = '@mantine/core/MyLink';
301
+ MyLink.classes = classes;
302
+ ```
303
+
304
+ **Usage:**
305
+ ```tsx
306
+ <MyLink href="/about">Link</MyLink>
307
+ <MyLink component="button" onClick={fn}>As button</MyLink>
308
+ <MyLink component={RouterLink} to="/about">Router link</MyLink>
309
+ ```
310
+
311
+ ---
312
+
313
+ ## Generic component
314
+
315
+ For components where prop types depend on a generic parameter.
316
+
317
+ ```tsx
318
+ import { factory, Factory, genericFactory, useProps } from '@mantine/core';
319
+
320
+ type SelectValue<M extends boolean> = M extends true ? string[] : string | null;
321
+
322
+ export interface MySelectProps<M extends boolean = false>
323
+ extends BoxProps, StylesApiProps<MySelectFactory> {
324
+ multiple?: M;
325
+ value?: SelectValue<M>;
326
+ defaultValue?: SelectValue<M>;
327
+ onChange?: (value: SelectValue<M>) => void;
328
+ }
329
+
330
+ export type MySelectFactory = Factory<{
331
+ props: MySelectProps;
332
+ ref: HTMLDivElement;
333
+ signature: <M extends boolean = false>(props: MySelectProps<M>) => React.JSX.Element;
334
+ stylesNames: 'root';
335
+ }>;
336
+
337
+ const defaultProps = { multiple: false } satisfies Partial<MySelectProps>;
338
+
339
+ export const MySelect = genericFactory<MySelectFactory>((_props) => {
340
+ const props = useProps('MySelect', defaultProps as any, _props);
341
+ const { multiple, value, onChange, ...others } = props;
342
+ // ...
343
+ });
344
+
345
+ MySelect.displayName = '@mantine/core/MySelect';
346
+ ```
347
+
348
+ **Usage:**
349
+ ```tsx
350
+ // TypeScript infers value as string | null
351
+ <MySelect value={val} onChange={(v) => setVal(v)} />
352
+
353
+ // TypeScript infers value as string[]
354
+ <MySelect multiple value={vals} onChange={(v) => setVals(v)} />
355
+ ```
356
+
357
+ ---
358
+
359
+ ## Theme integration
360
+
361
+ Components built with `factory()` automatically get `.extend()` and `.withProps()`.
362
+
363
+ **`.extend()`** — for theme-level configuration in `createTheme`:
364
+ ```tsx
365
+ const theme = createTheme({
366
+ components: {
367
+ MyComponent: MyComponent.extend({
368
+ // Override default props
369
+ defaultProps: {
370
+ radius: 'xl',
371
+ size: 'lg',
372
+ },
373
+ // Add classes to selectors
374
+ classNames: {
375
+ root: 'my-root-class',
376
+ inner: 'my-inner-class',
377
+ },
378
+ // Add inline styles to selectors
379
+ styles: {
380
+ root: { border: '1px solid red' },
381
+ },
382
+ // Or use a callback for theme-aware styles
383
+ styles: (theme) => ({
384
+ root: { background: theme.colors.blue[0] },
385
+ }),
386
+ // Override CSS variables
387
+ vars: (_theme, props) => ({
388
+ root: { '--my-radius': props.radius ? getRadius(props.radius) : undefined },
389
+ }),
390
+ }),
391
+ },
392
+ });
393
+ ```
394
+
395
+ **`.withProps()`** — create a pre-configured variant at the call site:
396
+ ```tsx
397
+ const BigMyComponent = MyComponent.withProps({ size: 'xl', radius: 'lg' });
398
+
399
+ // Same as MyComponent but with size and radius pre-set
400
+ <BigMyComponent>Content</BigMyComponent>
401
+ ```
402
+
403
+ ---
404
+
405
+ ## Namespace exports
406
+
407
+ Add at the bottom of the component file or `index.ts` to let consumers access types without extra imports.
408
+
409
+ ```tsx
410
+ export namespace MyComponent {
411
+ export type Props = MyComponentProps;
412
+ export type StylesNames = MyComponentStylesNames;
413
+ export type CssVariables = MyComponentCssVariables;
414
+ export type Factory = MyComponentFactory;
415
+ export type Variant = MyComponentVariant;
416
+
417
+ export namespace Section {
418
+ export type Props = MyComponentSectionProps;
419
+ export type StylesNames = MyComponentSectionStylesNames;
420
+ export type Factory = MyComponentSectionFactory;
421
+ }
422
+ }
423
+ ```
424
+
425
+ **Usage:**
426
+ ```ts
427
+ import { MyComponent } from './MyComponent';
428
+
429
+ // No need to import MyComponentProps separately
430
+ const props: MyComponent.Props = { radius: 'md' };
431
+ ```
@@ -0,0 +1,103 @@
1
+ ---
2
+ name: mantine-form
3
+ description: >
4
+ Build forms using @mantine/form in the mantine-9 repository. Use this skill when: (1) setting
5
+ up a form with useForm, (2) adding validation rules or async validation, (3) working with nested
6
+ object or array fields, (4) sharing form state across components with createFormContext,
7
+ (5) using uncontrolled mode for performance, (6) using the standalone useField hook, or
8
+ (7) any task involving useForm, getInputProps, onSubmit, insertListItem, or form validation.
9
+ ---
10
+
11
+ # Mantine Form Skill
12
+
13
+ ## Core Workflow
14
+
15
+ ### 1. Set up the form
16
+
17
+ ```tsx
18
+ const form = useForm({
19
+ mode: "controlled", // or 'uncontrolled' for large forms
20
+ initialValues: {
21
+ email: "",
22
+ age: 0,
23
+ },
24
+ validate: {
25
+ email: isEmail("Invalid email"),
26
+ age: isInRange({ min: 18 }, "Must be at least 18"),
27
+ },
28
+ });
29
+ ```
30
+
31
+ ### 2. Wire inputs with getInputProps
32
+
33
+ ```tsx
34
+ <TextInput {...form.getInputProps('email')} label="Email" />
35
+ <NumberInput {...form.getInputProps('age')} label="Age" />
36
+ ```
37
+
38
+ For checkboxes pass `{ type: 'checkbox' }`:
39
+
40
+ ```tsx
41
+ <Checkbox {...form.getInputProps("agreed", { type: "checkbox" })} label="I agree" />
42
+ ```
43
+
44
+ ### 3. Handle submission
45
+
46
+ ```tsx
47
+ <form onSubmit={form.onSubmit(values => console.log(values))}>
48
+ ...
49
+ <Button type="submit">Submit</Button>
50
+ </form>
51
+ ```
52
+
53
+ `onSubmit` only calls the handler when validation passes. To handle failures:
54
+
55
+ ```tsx
56
+ form.onSubmit(
57
+ values => save(values),
58
+ errors => console.log("Validation failed", errors)
59
+ );
60
+ ```
61
+
62
+ ## Validation
63
+
64
+ ### Rules object (most common)
65
+
66
+ ```tsx
67
+ validate: {
68
+ name: isNotEmpty('Required'),
69
+ email: isEmail('Invalid email'),
70
+ password: hasLength({ min: 8 }, 'Min 8 chars'),
71
+ confirmPassword: matchesField('password', 'Passwords do not match'),
72
+ }
73
+ ```
74
+
75
+ ### Function (for cross-field logic)
76
+
77
+ ```tsx
78
+ validate: values => ({
79
+ endDate: values.endDate < values.startDate ? "End must be after start" : null,
80
+ });
81
+ ```
82
+
83
+ ### When to validate
84
+
85
+ ```tsx
86
+ validateInputOnChange: true, // validate all fields on every change
87
+ validateInputOnChange: ['email'], // validate specific fields only
88
+ validateInputOnBlur: true, // validate on blur instead
89
+ ```
90
+
91
+ ## Modes
92
+
93
+ | Mode | State storage | Re-renders | Input props |
94
+ | ------------------------ | ------------- | --------------- | --------------------------- |
95
+ | `'controlled'` (default) | React state | On every change | `value` + `onChange` |
96
+ | `'uncontrolled'` | Refs | None | `defaultValue` + `onChange` |
97
+
98
+ In uncontrolled mode, use `form.key('fieldPath')` as the React `key` prop when you need to force a re-render of an input.
99
+
100
+ ## References
101
+
102
+ - **[`references/api.md`](references/api.md)** — Full API: `useForm` options, complete return value, `useField`, `createFormContext`, `createFormActions`, all built-in validators, key types
103
+ - **[`references/patterns.md`](references/patterns.md)** — Code examples: nested objects, array fields, async validation, form context across components, `transformValues`, `useField` standalone