@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.
- package/README.md +21 -0
- package/bin/ad-sync-agents.mjs +542 -0
- package/dist/ComplexComponents/DataTable/CustomBottomToolbar/CustomBottomToolbar.module.css +24 -1
- package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.js +2 -1
- package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.tsx +3 -0
- package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/CustomToolbarAlertBannerContent.module.css +9 -1
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/CustomTopToolbar.module.css +7 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/DateRangeSelectorFilter.module.css +7 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.js +1 -1
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.tsx +1 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.js +4 -2
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.module.css +16 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.tsx +6 -3
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.js +2 -2
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.tsx +11 -8
- package/dist/ComplexComponents/DataTable/DataTableGrid/DataTableGrid.module.css +17 -3
- package/dist/ComplexComponents/DataTable/DataTableGrid/index.js +1 -1
- package/dist/ComplexComponents/DataTable/DataTableGrid/index.tsx +2 -2
- package/dist/ComplexComponents/DataTable/ToolbarAlertBanner/ToolbarAlertBanner.module.css +4 -1
- package/dist/DESIGN.md +49 -7
- package/dist/agent-kit/README.md +11 -0
- package/dist/agent-kit/manifest.json +81 -0
- package/dist/agent-kit/micro-ui/CLAUDE.md +1 -0
- package/dist/agent-kit/micro-ui/micro-ui.AGENTS.md +62 -0
- package/dist/agent-kit/rules/accessibility.mdc +46 -0
- package/dist/agent-kit/rules/module-federation.mdc +30 -0
- package/dist/agent-kit/rules/react-stack.mdc +73 -0
- package/dist/agent-kit/rules/testing.mdc +44 -0
- package/dist/agent-kit/skills/design-feature/SKILL.md +205 -0
- package/dist/agent-kit/skills/developer-handoff/SKILL.md +192 -0
- package/dist/agent-kit/skills/figma-mcp-integration/SKILL.md +134 -0
- package/dist/agent-kit/skills/figma-to-page/SKILL.md +24 -0
- package/dist/agent-kit/skills/mantine-combobox/SKILL.md +73 -0
- package/dist/agent-kit/skills/mantine-combobox/references/api.md +199 -0
- package/dist/agent-kit/skills/mantine-combobox/references/patterns.md +279 -0
- package/dist/agent-kit/skills/mantine-custom-components/SKILL.md +112 -0
- package/dist/agent-kit/skills/mantine-custom-components/references/api.md +407 -0
- package/dist/agent-kit/skills/mantine-custom-components/references/patterns.md +431 -0
- package/dist/agent-kit/skills/mantine-form/SKILL.md +103 -0
- package/dist/agent-kit/skills/mantine-form/references/api.md +313 -0
- package/dist/agent-kit/skills/mantine-form/references/patterns.md +310 -0
- package/dist/agent-kit/skills/prototype-page/SKILL.md +82 -0
- package/dist/contracts/index.json +1 -1
- package/dist/css/mantine.css +4 -4
- package/dist/skills/design-feature/SKILL.md +205 -0
- package/dist/stories/index.json +1 -1
- package/package.json +8 -4
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: figma-mcp-integration
|
|
3
|
+
description: Use when the user shares a figma.com URL or node id, or before calling any Figma MCP tool, to build micro-ui-ts UI that follows the AppDirect design system.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Figma MCP integration
|
|
7
|
+
|
|
8
|
+
Build the screen from the Figma node using the design system in the root `AGENTS.md`. Token names are in `docs/DESIGN.md`. Copy the token name into code. Leave the hex values in that doc.
|
|
9
|
+
|
|
10
|
+
`get_design_context` output is a layout reference. It often contains Tailwind, hex, `rgb()`, palette props, extra fonts, and absolute positioning. Do not paste those. Snap every measurement onto the scales below.
|
|
11
|
+
|
|
12
|
+
## Read the node
|
|
13
|
+
|
|
14
|
+
1. From `https://figma.com/design/:fileKey/:fileName?node-id=1-2`, the node id is `1:2`.
|
|
15
|
+
2. Follow `figma-design-to-code` before `get_design_context`. Request a screenshot in that call. If none comes back, call `get_screenshot`.
|
|
16
|
+
3. When the response is sparse, fetch the visible child nodes before writing UI.
|
|
17
|
+
4. Use `get_variable_defs` for type, spacing, radius, and color roles. Map each role to a component prop or an `--ad-*` token.
|
|
18
|
+
|
|
19
|
+
## Colour
|
|
20
|
+
|
|
21
|
+
Never write a color as a hex, `rgb()` / `rgba()`, a palette prop (`color="blue"`, `c="gray.6"`, `c="dimmed"`, `bg="gray.0"`, `bg="white"`, `c="black"`), `var(--mantine-color-*)`, or a `style` / `styles` color. The only hex in the product is `#011B58`, and only in app chrome.
|
|
22
|
+
|
|
23
|
+
Color comes from a component variant, or from a CSS module on the component root:
|
|
24
|
+
|
|
25
|
+
```css
|
|
26
|
+
.subtle {
|
|
27
|
+
background: var(--ad-color-bg-subtle);
|
|
28
|
+
color: var(--ad-color-text-dimmed);
|
|
29
|
+
border: 1px solid var(--ad-color-border-default);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Map the Figma fill by role:
|
|
34
|
+
|
|
35
|
+
| Role in the frame | Use |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| Page or card surface | Leave the default, or `--ad-color-bg-default` |
|
|
38
|
+
| Secondary surface | `--ad-color-bg-subtle` |
|
|
39
|
+
| Recessed surface | `--ad-color-bg-muted` |
|
|
40
|
+
| Segmented control track | `--ad-color-bg-tinted` |
|
|
41
|
+
| Body text | Leave the default (`--ad-color-text-default`) |
|
|
42
|
+
| Secondary text | `--ad-color-text-dimmed` |
|
|
43
|
+
| Placeholder | `--ad-color-text-placeholder` |
|
|
44
|
+
| Text on a dark surface | `--ad-color-text-inverse` |
|
|
45
|
+
| Link | `--ad-color-text-link` |
|
|
46
|
+
| Border, hairline, strong border | `--ad-color-border-default`, `--ad-color-border-subtle`, `--ad-color-border-strong` |
|
|
47
|
+
| Focus or active input | `--ad-color-border-primary` |
|
|
48
|
+
| Tinted brand surface | `--ad-color-brand-light` |
|
|
49
|
+
| Solid brand-blue button | `Button` `variant="primary"`. One per view |
|
|
50
|
+
| Solid cyan button | `Button` `variant="secondary"` |
|
|
51
|
+
| White button, neutral border | `Button` `variant="default"` |
|
|
52
|
+
| Transparent, brand text and border | `Button` `variant="outline"` |
|
|
53
|
+
| Red destructive button | `Button` `variant="danger"` |
|
|
54
|
+
| Text-only button | `variant="link"` or `secret` |
|
|
55
|
+
| Green, red, yellow status | `color` `info`, `success`, `danger`, `pending`, or `default` on Alert, Badge, Chip, Indicator, Progress, or ThemeIcon |
|
|
56
|
+
|
|
57
|
+
`Alert` stays `variant="light"`. `warning` is a Badge variant, not an Alert color. Status needs an icon and text. Do not paint body text or a decorative shape with a status color. Do not rebuild a button, badge, or alert in CSS with `--ad-action-*` or `--ad-color-status-*`. Pass `disabled` for a disabled control. Do not invent a disabled color.
|
|
58
|
+
|
|
59
|
+
Allowed non-colour Mantine variables are `--mantine-{spacing,radius,font-size,line-height,shadow,z-index}-*`.
|
|
60
|
+
|
|
61
|
+
## Components
|
|
62
|
+
|
|
63
|
+
Import from `@mantine/core` and `@mantine/dates`. Reach for these first.
|
|
64
|
+
|
|
65
|
+
- Buttons: `Button`, `ActionIcon`, `CloseButton`.
|
|
66
|
+
- Inputs: `TextInput`, `Textarea`, `NumberInput`, `ColorInput`, `Slider`, `Switch`, `SegmentedControl`, `Checkbox`, `Radio`, `RadioGroup`, `FileInput`, `Dropzone`, `DatePickerInput`.
|
|
67
|
+
- Combobox: `Select`, `Autocomplete`, `MultiSelect`, `Combobox`.
|
|
68
|
+
- Navigation: `Tabs`, `Breadcrumbs`, `NavLink`, `Stepper`, `Anchor`.
|
|
69
|
+
- Overlays: `Modal`, `Drawer`, `Menu`, `Popover`, `Tooltip`.
|
|
70
|
+
- Data: `Alert`, `Avatar`, `Badge`, `Card`, `Card.Section`, `Chip`, `Pill`, `Indicator`, `Progress`, `ThemeIcon`, `List`, `Skeleton`. Data grids are `src/components/Table`.
|
|
71
|
+
- Type: `Title`, `Text`, `Code`, `Kbd`. Misc: `Divider`, `Paper`.
|
|
72
|
+
- Layout: `Stack`, `Group`, `Box`, `SimpleGrid`, `Grid`, `Flex`, `Container`, `Center`.
|
|
73
|
+
|
|
74
|
+
`@appdirect/design-tokens` decides which Mantine imports are outside the system. When `ds/no-unadopted-mantine` warns, keep the import if this component is required, prefer the replacement named in the warning, and tell the user it is outside the UX-approved list. `MantineProvider`, `createTheme`, and `DatesProvider` live only in `src/providers/` and `__setup__/`.
|
|
75
|
+
|
|
76
|
+
Buttons and inputs default to `size="sm"` and `radius="sm"`. Button variants are `primary`, `secondary`, `default`, `outline`, `danger`, `link`, and `secret`. Never `filled`, `light`, `subtle`, `transparent`, `white`, or `gradient`. ActionIcon variants are `default`, `outline`, and `link`. Badge and Alert radius stay `sm`. Avatar stays circular.
|
|
77
|
+
|
|
78
|
+
In-app navigation is `component={Link}` on `Anchor`, `Card`, or `Button`. A clickable card is that component, not a `Box` with an `onClick`.
|
|
79
|
+
|
|
80
|
+
## Type
|
|
81
|
+
|
|
82
|
+
Two families only. Inter is already the UI font. `Code` is Roboto Mono for ids, timestamps, and other data. Do not add a font face.
|
|
83
|
+
|
|
84
|
+
| Figma text | Use |
|
|
85
|
+
| --- | --- |
|
|
86
|
+
| Page title | `Title` `order={1}`. One per page |
|
|
87
|
+
| Section or card title | the next `order`. Never skip a level |
|
|
88
|
+
| Body | `Text` `size="md"` |
|
|
89
|
+
| Metadata, captions | `Text` `size="sm"` |
|
|
90
|
+
| Button, tab, and field labels | `Text` `size="sm"` `fw={600}` |
|
|
91
|
+
| Ids and timestamps | `Code` |
|
|
92
|
+
|
|
93
|
+
Do not set `size="16px"` or a CSS `font-size` in pixels. Headings are weight 700, body 400, labels 600. A smaller heading keeps its `order` and sets `size` (`order={2}` `size="h4"`). The heading scale in `docs/DESIGN.md` is h1–h6.
|
|
94
|
+
|
|
95
|
+
## Layout, spacing, radius, shadow
|
|
96
|
+
|
|
97
|
+
Map Figma auto-layout to layout components. Column → `Stack`. Row → `Group`. Grid → `SimpleGrid` or `Grid`. Padding-only frame → `Box`. Do not use a `div` with flex or grid styles.
|
|
98
|
+
|
|
99
|
+
Spacing props are `none` and `xxs` through `xxl`, or `var(--ad-spacing-*)` in a CSS module. Snap Figma pixels to that scale: `xxs` 4, `xs` 10, `sm` 12, `md` 16, `lg` 20, `xl` 32. Card padding is `md`, section gaps `lg`, page padding `xl`, label-to-input gap `xs`.
|
|
100
|
+
|
|
101
|
+
Radius defaults to `sm` (4px) on buttons, inputs, cards, badges, modals, and drawers. `xs` 2, `md` 8, `lg` 16, `xl` 32 only when the frame clearly uses that step. `full` is Avatar only.
|
|
102
|
+
|
|
103
|
+
A Figma drop shadow becomes `shadow="xs"|"sm"|"md"|"lg"|"xl"` on an interactive layer (hover card, menu, modal), or `var(--ad-shadows-*)`. Flat sections use a border or a surface token. No raw `box-shadow`.
|
|
104
|
+
|
|
105
|
+
Styling order:
|
|
106
|
+
|
|
107
|
+
1. Design-system props (`variant`, `size`, `radius` where that component owns them).
|
|
108
|
+
2. Mantine style props that are not colors (`w`, `h`, `p`, `m`, `gap`, `align`, `justify`, `fw`).
|
|
109
|
+
3. A CSS module using `--ad-*`, attached with `className` on the component root.
|
|
110
|
+
|
|
111
|
+
Never `style`, `styles`, `vars`, or `classNames` on design-system components. Never Tailwind. Do not add screen CSS to `src/providers/MantineProviderWrapper/global.css`.
|
|
112
|
+
|
|
113
|
+
## Icons
|
|
114
|
+
|
|
115
|
+
Product icons are Remix (`@remixicon/react`, or `remixicon/icons/**.svg` via SVGR). Tabler stays inside Mantine internals. `@appdirect/ad-svg-icons` is legacy, only when Remix has no suitable icon. Size with the `size` number prop: 12, 14, 16, 18, or 20. Do not resize an icon in CSS.
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
<Stack gap="md">
|
|
119
|
+
<Group justify="space-between">
|
|
120
|
+
<Title order={3}>Invoices</Title>
|
|
121
|
+
<Button variant="primary">Create invoice</Button>
|
|
122
|
+
</Group>
|
|
123
|
+
<Paper withBorder p="md" radius="sm" className={classes.panel}>
|
|
124
|
+
<Text size="sm" className={classes.meta}>Due today</Text>
|
|
125
|
+
</Paper>
|
|
126
|
+
</Stack>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
/* Never: palette, hex, pixel type, or a style color */
|
|
131
|
+
<Button variant="filled" color="blue">Create invoice</Button>
|
|
132
|
+
<Box bg="gray.1" c="gray.6" />
|
|
133
|
+
<Text size="16px" style={{ color: "#868e96" }}>Due today</Text>
|
|
134
|
+
```
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: figma-to-page
|
|
3
|
+
description: Ask which prototype and which Figma node, then copy that frame onto one page. Use when a designer wants to turn a Figma frame into a prototype page.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Figma node to a page
|
|
7
|
+
|
|
8
|
+
Ask, then copy. Ask one question at a time and wait. If they already answered in the same message, use that answer and skip the question.
|
|
9
|
+
|
|
10
|
+
One node becomes one page. If they pasted several node URLs, copy the first, then stop and tell them to paste the next.
|
|
11
|
+
|
|
12
|
+
## Ask
|
|
13
|
+
|
|
14
|
+
1. **Which prototype.** If this workspace is already one prototype — `prototype.json` or `standalone/standalone.config.ts` is at the root, and this is not the platform repo — use that folder and do not ask. If this workspace is ad-design-prototype, run `npm run proto -- list` and ask which `owner/slug`. Work only in `prototypes/<owner>/<slug>/`. If the list is empty, stop and tell them to run `/create-prototype` first.
|
|
15
|
+
2. **Figma URL.** A `figma.com/design/` or `figma.com/file/` link with a `node-id`. The file key is the segment after `/design/` or `/file/`. The node id is the `node-id` query (`1-2` becomes `1:2`). If the link has no node id, ask which frame to copy.
|
|
16
|
+
3. **Which page.** Read `standalone/standalone.config.ts` `pages` and `routePaths` in `src/navigation/router.tsx`. Ask whether this frame replaces one of those pages or is a new page. If there is one page other than `/hello-ts`, offer that path as the default.
|
|
17
|
+
4. **New page only.** Ask the path (it must start with `/`) and the nav label. Keep the menu and section already in `standalone.config.ts`. Ask for a different section only if they say this page belongs somewhere else. Then list each `collectionName` from `standalone/mocks/navigation/<file>.json`.
|
|
18
|
+
|
|
19
|
+
## Copy
|
|
20
|
+
|
|
21
|
+
1. Follow `figma-mcp-integration` for that node, and follow `figma-design-to-code` before calling `get_design_context`. Build the screen with the design system in `AGENTS.md`.
|
|
22
|
+
2. Put the screen in `src/pages/<Name>/`. Add or update its route in `src/navigation/router.tsx` and `routePaths`.
|
|
23
|
+
3. Register or update it in `standalone/standalone.config.ts` `pages`: `path`, `label`, `iconType`, `namespace`, `collection`. `collection` is a `collectionName` from the menu file that namespace loads.
|
|
24
|
+
4. Stop. Tell them the prototype and the path. If the prototype is already running, include `http://localhost:<port><path>`. Do not add another frame in the same turn.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mantine-combobox
|
|
3
|
+
description: >
|
|
4
|
+
Build custom dropdown/select/autocomplete/multiselect components using Mantine's Combobox
|
|
5
|
+
primitives. Use this skill when: (1) creating a new custom select-like component with
|
|
6
|
+
Combobox primitives, (2) building a searchable dropdown, (3) implementing a multi-select
|
|
7
|
+
or tags input variant, (4) customizing option rendering, (5) adding custom filtering logic,
|
|
8
|
+
or (6) any task involving useCombobox, Combobox.Target, Combobox.Option, or Combobox.Dropdown.
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Mantine Combobox Skill
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
`Combobox` provides low-level primitives for building any select-like UI. The built-in
|
|
16
|
+
`Select`, `Autocomplete`, and `TagsInput` components are all built on top of it.
|
|
17
|
+
|
|
18
|
+
## Core Workflow
|
|
19
|
+
|
|
20
|
+
### 1. Create the store
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
const combobox = useCombobox({
|
|
24
|
+
onDropdownClose: () => combobox.resetSelectedOption(),
|
|
25
|
+
onDropdownOpen: () => combobox.selectFirstOption(),
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 2. Render structure
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
<Combobox store={combobox} onOptionSubmit={handleSubmit}>
|
|
33
|
+
<Combobox.Target>
|
|
34
|
+
<InputBase
|
|
35
|
+
component="button"
|
|
36
|
+
pointer
|
|
37
|
+
rightSection={<Combobox.Chevron />}
|
|
38
|
+
onClick={() => combobox.toggleDropdown()}
|
|
39
|
+
>
|
|
40
|
+
{value || <Input.Placeholder>Pick value</Input.Placeholder>}
|
|
41
|
+
</InputBase>
|
|
42
|
+
</Combobox.Target>
|
|
43
|
+
<Combobox.Dropdown>
|
|
44
|
+
<Combobox.Options>
|
|
45
|
+
{options.map((item) => (
|
|
46
|
+
<Combobox.Option value={item} key={item}>{item}</Combobox.Option>
|
|
47
|
+
))}
|
|
48
|
+
</Combobox.Options>
|
|
49
|
+
</Combobox.Dropdown>
|
|
50
|
+
</Combobox>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 3. Handle submit
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
const handleSubmit = (val: string) => {
|
|
57
|
+
setValue(val);
|
|
58
|
+
combobox.closeDropdown();
|
|
59
|
+
};
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Target Types
|
|
63
|
+
|
|
64
|
+
| Scenario | Use |
|
|
65
|
+
|---|---|
|
|
66
|
+
| Button trigger (no text input) | `<Combobox.Target targetType="button">` |
|
|
67
|
+
| Input trigger | `<Combobox.Target>` (default) |
|
|
68
|
+
| Pills + separate input (multi-select) | `<Combobox.DropdownTarget>` + `<Combobox.EventsTarget>` |
|
|
69
|
+
|
|
70
|
+
## References
|
|
71
|
+
|
|
72
|
+
- **[`references/api.md`](references/api.md)** — Full API: `useCombobox` options and store, all sub-component props, CSS variables, Styles API selectors
|
|
73
|
+
- **[`references/patterns.md`](references/patterns.md)** — Code examples: searchable select, multi-select with pills, groups, custom rendering, clear button, form integration
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# Combobox API Reference
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
- [useCombobox hook](#usecombobox-hook)
|
|
5
|
+
- [Combobox (root)](#combobox-root)
|
|
6
|
+
- [Sub-components](#sub-components)
|
|
7
|
+
- [CSS variables & Styles API](#css-variables--styles-api)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## useCombobox hook
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
const combobox = useCombobox(options?: UseComboboxOptions);
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Options:**
|
|
18
|
+
```ts
|
|
19
|
+
interface UseComboboxOptions {
|
|
20
|
+
defaultOpened?: boolean;
|
|
21
|
+
opened?: boolean;
|
|
22
|
+
onOpenedChange?: (opened: boolean) => void;
|
|
23
|
+
onDropdownClose?: (eventSource: 'keyboard' | 'mouse' | 'unknown') => void;
|
|
24
|
+
onDropdownOpen?: (eventSource: 'keyboard' | 'mouse' | 'unknown') => void;
|
|
25
|
+
loop?: boolean; // Default: true — keyboard nav wraps at boundaries
|
|
26
|
+
scrollBehavior?: ScrollBehavior; // Default: 'instant'
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Returned store:**
|
|
31
|
+
```ts
|
|
32
|
+
interface ComboboxStore {
|
|
33
|
+
// Dropdown state
|
|
34
|
+
dropdownOpened: boolean;
|
|
35
|
+
openDropdown(eventSource?: 'keyboard' | 'mouse' | 'unknown'): void;
|
|
36
|
+
closeDropdown(eventSource?: 'keyboard' | 'mouse' | 'unknown'): void;
|
|
37
|
+
toggleDropdown(eventSource?: 'keyboard' | 'mouse' | 'unknown'): void;
|
|
38
|
+
|
|
39
|
+
// Option keyboard navigation
|
|
40
|
+
selectActiveOption(): string | null;
|
|
41
|
+
selectFirstOption(): string | null;
|
|
42
|
+
selectNextOption(): string | null;
|
|
43
|
+
selectPreviousOption(): string | null;
|
|
44
|
+
resetSelectedOption(): void;
|
|
45
|
+
clickSelectedOption(): void;
|
|
46
|
+
updateSelectedOptionIndex(
|
|
47
|
+
target?: 'active' | 'selected' | number,
|
|
48
|
+
options?: { scrollIntoView?: boolean }
|
|
49
|
+
): void;
|
|
50
|
+
|
|
51
|
+
// Programmatic focus
|
|
52
|
+
focusSearchInput(): void;
|
|
53
|
+
focusTarget(): void;
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Combobox (root)
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
<Combobox
|
|
63
|
+
store={combobox} // required — ComboboxStore from useCombobox()
|
|
64
|
+
onOptionSubmit={fn} // (value: string, optionProps) => void
|
|
65
|
+
size="sm" // MantineSize | string, default: 'sm'
|
|
66
|
+
dropdownPadding={4} // number, default: 4
|
|
67
|
+
resetSelectionOnOptionHover // boolean
|
|
68
|
+
readOnly // boolean — disables all interactions
|
|
69
|
+
// + all Popover props (position, offset, width, withinPortal, etc.)
|
|
70
|
+
/>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Sub-components
|
|
76
|
+
|
|
77
|
+
### Combobox.Target
|
|
78
|
+
```tsx
|
|
79
|
+
<Combobox.Target
|
|
80
|
+
targetType="input" // 'button' | 'input', default: 'input'
|
|
81
|
+
withKeyboardNavigation // boolean, default: true
|
|
82
|
+
withAriaAttributes // boolean, default: true
|
|
83
|
+
withExpandedAttribute // boolean, default: false
|
|
84
|
+
autoComplete="off" // string
|
|
85
|
+
>
|
|
86
|
+
{/* single child — the trigger element */}
|
|
87
|
+
</Combobox.Target>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Use `targetType="button"` when the trigger is a button (Space key toggles dropdown).
|
|
91
|
+
|
|
92
|
+
### Combobox.DropdownTarget
|
|
93
|
+
Marks the element used for dropdown positioning when separate from the keyboard events target. Used together with `Combobox.EventsTarget` in multi-select/pills patterns.
|
|
94
|
+
|
|
95
|
+
### Combobox.EventsTarget
|
|
96
|
+
Receives keyboard events for dropdown navigation. Used alongside `Combobox.DropdownTarget` when the typing input is nested inside the trigger (e.g. inside `PillsInput`).
|
|
97
|
+
|
|
98
|
+
### Combobox.Dropdown
|
|
99
|
+
```tsx
|
|
100
|
+
<Combobox.Dropdown hidden={false}>
|
|
101
|
+
{/* dropdown content */}
|
|
102
|
+
</Combobox.Dropdown>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Use `hidden` to hide without unmounting (preserves scroll position).
|
|
106
|
+
|
|
107
|
+
### Combobox.Options
|
|
108
|
+
```tsx
|
|
109
|
+
<Combobox.Options labelledBy="some-label-id">
|
|
110
|
+
{/* Combobox.Option or Combobox.Group elements */}
|
|
111
|
+
</Combobox.Options>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Combobox.Option
|
|
115
|
+
```tsx
|
|
116
|
+
<Combobox.Option
|
|
117
|
+
value="react" // string | number, required
|
|
118
|
+
active={false} // visually marks as selected; used by selectActiveOption()
|
|
119
|
+
disabled={false}
|
|
120
|
+
>
|
|
121
|
+
React
|
|
122
|
+
</Combobox.Option>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Combobox.Search
|
|
126
|
+
Built-in search input, wired to keyboard navigation. Renders sticky at top of dropdown.
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
<Combobox.Search
|
|
130
|
+
value={search}
|
|
131
|
+
onChange={(e) => setSearch(e.currentTarget.value)}
|
|
132
|
+
placeholder="Search..."
|
|
133
|
+
withAriaAttributes // boolean, default: true
|
|
134
|
+
withKeyboardNavigation // boolean, default: true
|
|
135
|
+
// + all Input props
|
|
136
|
+
/>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Combobox.Empty
|
|
140
|
+
```tsx
|
|
141
|
+
<Combobox.Empty>Nothing found</Combobox.Empty>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Combobox.Group
|
|
145
|
+
```tsx
|
|
146
|
+
<Combobox.Group label="Frontend">
|
|
147
|
+
<Combobox.Option value="react">React</Combobox.Option>
|
|
148
|
+
</Combobox.Group>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Combobox.Header / Combobox.Footer
|
|
152
|
+
```tsx
|
|
153
|
+
<Combobox.Header>Custom header</Combobox.Header>
|
|
154
|
+
<Combobox.Footer>Custom footer</Combobox.Footer>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Combobox.Chevron
|
|
158
|
+
```tsx
|
|
159
|
+
<Combobox.Chevron size="sm" error={error} color="blue" />
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Combobox.ClearButton
|
|
163
|
+
```tsx
|
|
164
|
+
<Combobox.ClearButton onClear={() => setValue(null)} />
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Combobox.HiddenInput
|
|
168
|
+
```tsx
|
|
169
|
+
<Combobox.HiddenInput
|
|
170
|
+
value={value} // string | number | (string | number)[] | null
|
|
171
|
+
valuesDivider="," // string, default: ','
|
|
172
|
+
name="myField"
|
|
173
|
+
form="myForm"
|
|
174
|
+
/>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## CSS variables & Styles API
|
|
180
|
+
|
|
181
|
+
### CSS variables (set on root element)
|
|
182
|
+
| Variable | Description |
|
|
183
|
+
|---|---|
|
|
184
|
+
| `--combobox-option-fz` | Option font size (driven by `size` prop) |
|
|
185
|
+
| `--combobox-option-padding` | Option padding (driven by `size` prop) |
|
|
186
|
+
| `--combobox-padding` | Dropdown padding (driven by `dropdownPadding`, default 4px) |
|
|
187
|
+
|
|
188
|
+
### Styles API selectors
|
|
189
|
+
| Selector | Element |
|
|
190
|
+
|---|---|
|
|
191
|
+
| `dropdown` | Dropdown container |
|
|
192
|
+
| `options` | Options listbox |
|
|
193
|
+
| `option` | Individual option |
|
|
194
|
+
| `search` | Search input |
|
|
195
|
+
| `empty` | Nothing found message |
|
|
196
|
+
| `header` | Dropdown header |
|
|
197
|
+
| `footer` | Dropdown footer |
|
|
198
|
+
| `group` | Group container |
|
|
199
|
+
| `groupLabel` | Group label text |
|