@wangs-ui/skills 1.3.0-alpha.13 → 1.3.0-alpha.14
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/dist/bin.js +1 -1
- package/dist/index.js +1 -1
- package/dist/skills/craft-theme/SKILL.md +1 -1
- package/dist/skills/create-form/SKILL.md +11 -9
- package/dist/skills/data-table/SKILL.md +8 -7
- package/dist/skills/dialog-modal/SKILL.md +5 -5
- package/dist/skills/i18n-usage/SKILL.md +7 -7
- package/dist/skills/layout-navigation/SKILL.md +103 -17
- package/dist/skills/responsive-design/SKILL.md +19 -6
- package/dist/skills/universal-layout/SKILL.md +10 -18
- package/dist/skills/wangs-ui-components/SKILL.md +132 -47
- package/dist/{src-DChgYbFi.js → src-ilzo-M7u.js} +9 -9
- package/package.json +1 -1
- package/skills/craft-theme/SKILL.md +1 -1
- package/skills/create-form/SKILL.md +11 -9
- package/skills/data-table/SKILL.md +8 -7
- package/skills/dialog-modal/SKILL.md +5 -5
- package/skills/i18n-usage/SKILL.md +7 -7
- package/skills/layout-navigation/SKILL.md +103 -17
- package/skills/responsive-design/SKILL.md +19 -6
- package/skills/universal-layout/SKILL.md +10 -18
- package/skills/wangs-ui-components/SKILL.md +132 -47
|
@@ -14,13 +14,13 @@ Use this skill when implementing data grids, server-paginated tables, filterable
|
|
|
14
14
|
|
|
15
15
|
Do **NOT** guess table prop names or hardcode table structures. Query the MCP server dynamically to inspect exact TypeScript signatures, live story implementations, and companion controls:
|
|
16
16
|
|
|
17
|
-
### Inspect Component Contracts:
|
|
17
|
+
### Inspect Component Contracts (`component` parameter):
|
|
18
18
|
|
|
19
19
|
```json
|
|
20
|
-
get_component_api({ "
|
|
21
|
-
get_component_api({ "
|
|
22
|
-
get_component_api({ "
|
|
23
|
-
get_component_api({ "
|
|
20
|
+
get_component_api({ "component": "datatable" })
|
|
21
|
+
get_component_api({ "component": "exportbutton" })
|
|
22
|
+
get_component_api({ "component": "filtercontainer" })
|
|
23
|
+
get_component_api({ "component": "bulkactionbutton" })
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
### Read Curated Documentation:
|
|
@@ -55,7 +55,7 @@ query_graph({ "query": "useDataTableFetch" })
|
|
|
55
55
|
The Wangs UI `DataTable` is built on a modular, headless-first architecture:
|
|
56
56
|
|
|
57
57
|
1. **Declarative Column Definitions (`TableColumn<T>[]`)**:
|
|
58
|
-
Columns are configured as typed array objects, not as JSX children. Check `get_component_api({ "
|
|
58
|
+
Columns are configured as typed array objects, not as JSX children. Check `get_component_api({ "component": "datatable" })` for column field types.
|
|
59
59
|
2. **Table Instance Hook (`useDataTable`)**:
|
|
60
60
|
Coordinates table state (sorting, pagination, selection, column ordering, pinning, visibility).
|
|
61
61
|
3. **Data Fetching Hook (`useDataTableFetch`)**:
|
|
@@ -73,4 +73,5 @@ The Wangs UI `DataTable` is built on a modular, headless-first architecture:
|
|
|
73
73
|
1. **Query MCP for Current Code Patterns**: Always run `get_component_examples` for `datatable` before drafting code.
|
|
74
74
|
2. **Strict Subpath Imports**: Import via `@wangs-ui/react-core/primitive/datatable` and companion primitive paths.
|
|
75
75
|
3. **Always Translate Visible Copy**: All column header labels, empty state messages, and action button labels must be wrapped in `t('...')` from `@wangs-ui/react-i18n`.
|
|
76
|
-
4. **Stable Row Identity**: Always configure a unique key identifier for stable selection and row identity.
|
|
76
|
+
4. **Stable Row Identity**: Always configure a unique key identifier (`dataKey` / `rowId`) for stable selection and row identity.
|
|
77
|
+
5. **Zero Redundant Table Wrappers**: Never wrap `<DataTable />` in an isolated `<div>` or `<Box>` solely to set width or margin. Wangs UI DataTable manages its own container scroll and layout dimensions out of the box.
|
|
@@ -14,13 +14,13 @@ Use this skill when building interactive modals, create/edit dialog forms, destr
|
|
|
14
14
|
|
|
15
15
|
Do **NOT** guess overlay props, event names, or footer slots. Query the MCP server dynamically to inspect exact contracts and live story implementations:
|
|
16
16
|
|
|
17
|
-
### Inspect Overlay Contracts:
|
|
17
|
+
### Inspect Overlay Contracts (`component` parameter):
|
|
18
18
|
|
|
19
19
|
```json
|
|
20
|
-
get_component_api({ "
|
|
21
|
-
get_component_api({ "
|
|
22
|
-
get_component_api({ "
|
|
23
|
-
get_component_api({ "
|
|
20
|
+
get_component_api({ "component": "dialog" })
|
|
21
|
+
get_component_api({ "component": "dialogform" })
|
|
22
|
+
get_component_api({ "component": "modal" })
|
|
23
|
+
get_component_api({ "component": "toast" })
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
### Read Curated Overlay Documentation:
|
|
@@ -14,14 +14,14 @@ Use this skill when implementing multi-language interfaces, translating user-fac
|
|
|
14
14
|
|
|
15
15
|
Do **NOT** guess component localization contracts, language switcher variants, or datepicker props. Query the MCP server dynamically to inspect exact props and live story implementations:
|
|
16
16
|
|
|
17
|
-
### Inspect Localized Component Contracts:
|
|
17
|
+
### Inspect Localized Component Contracts (`component` parameter):
|
|
18
18
|
|
|
19
19
|
```json
|
|
20
|
-
get_component_api({ "
|
|
21
|
-
get_component_api({ "
|
|
22
|
-
get_component_api({ "
|
|
23
|
-
get_component_api({ "
|
|
24
|
-
get_component_api({ "
|
|
20
|
+
get_component_api({ "component": "languageswitcher" })
|
|
21
|
+
get_component_api({ "component": "currencyinput" })
|
|
22
|
+
get_component_api({ "component": "datepicker" })
|
|
23
|
+
get_component_api({ "component": "select" })
|
|
24
|
+
get_component_api({ "component": "datatable" })
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
### Read Curated Localization Documentation:
|
|
@@ -140,7 +140,7 @@ selectedCount === 0
|
|
|
140
140
|
Use standard supported HTML tags (`<a>`, `<b>`, `<i>`, `<u>`, `<s>`, `<br/>`, `<sub>`, `<sup>`, `<code>`, `<mark>`) for inline styling. Tags are automatically parsed into React elements without custom regex or string manipulation:
|
|
141
141
|
|
|
142
142
|
```tsx
|
|
143
|
-
import Link from '@wangs-ui/foundation/theme
|
|
143
|
+
import { Link } from '@wangs-ui/foundation/theme';
|
|
144
144
|
|
|
145
145
|
t('You have selected <b>{count} items</b>. Click <a>here</a> to review.', {
|
|
146
146
|
count: selectedCount,
|
|
@@ -4,9 +4,10 @@ description: Architecture, navigation hierarchies, and MCP discovery protocol fo
|
|
|
4
4
|
metadata:
|
|
5
5
|
owner: wangs-ui
|
|
6
6
|
---
|
|
7
|
+
|
|
7
8
|
# Skill: Application Layout & Navigation Hierarchy
|
|
8
9
|
|
|
9
|
-
Use this skill when constructing application shells, multi-level sidebars, page headers, breadcrumbs,
|
|
10
|
+
Use this skill when constructing application shells, multi-level sidebars, page headers, breadcrumbs, tabbed views, or feature routing with `@wangs-ui/react-core`, `@wangs-ui/foundation`, and `@wangs-ui/react-navigation`.
|
|
10
11
|
|
|
11
12
|
---
|
|
12
13
|
|
|
@@ -14,20 +15,23 @@ Use this skill when constructing application shells, multi-level sidebars, page
|
|
|
14
15
|
|
|
15
16
|
Do **NOT** guess layout block slots, sidebar item interfaces, or breadcrumb props. Query the MCP server dynamically to inspect exact contracts and live story implementations:
|
|
16
17
|
|
|
17
|
-
### Inspect Layout & Navigation Contracts:
|
|
18
|
+
### Inspect Layout & Navigation Contracts (`component` parameter):
|
|
18
19
|
|
|
19
20
|
```json
|
|
20
|
-
get_component_api({ "
|
|
21
|
-
get_component_api({ "
|
|
22
|
-
get_component_api({ "
|
|
23
|
-
get_component_api({ "
|
|
21
|
+
get_component_api({ "component": "applayout" })
|
|
22
|
+
get_component_api({ "component": "sidebar" })
|
|
23
|
+
get_component_api({ "component": "tabletoolbar" })
|
|
24
|
+
get_component_api({ "component": "breadcrumb" })
|
|
25
|
+
get_component_api({ "component": "tabs" })
|
|
24
26
|
```
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
|
|
29
|
+
### Read Curated Layout Documentation (`id` parameter):
|
|
27
30
|
|
|
28
31
|
```json
|
|
29
32
|
get_documentation({ "id": "applayout" })
|
|
30
33
|
get_documentation({ "id": "sidebar" })
|
|
34
|
+
get_documentation({ "id": "react-navigation" })
|
|
31
35
|
```
|
|
32
36
|
|
|
33
37
|
### Inspect Live Story Implementations:
|
|
@@ -51,20 +55,102 @@ query_graph({ "query": "Sidebar" })
|
|
|
51
55
|
## 2. Layout Architecture & Mental Model
|
|
52
56
|
|
|
53
57
|
1. **Top-Level App Shell (`AppLayout`)**:
|
|
54
|
-
|
|
58
|
+
- Subpath: `@wangs-ui/react-core/blocks/applayout`
|
|
59
|
+
- Outer responsive shell arranging navigation, navbar, sidebars, main viewport, and footer. Inspect slots and layout variants via `get_component_api({ "component": "applayout" })`.
|
|
55
60
|
2. **Hierarchical Menu (`Sidebar`)**:
|
|
56
|
-
|
|
61
|
+
- Subpath: `@wangs-ui/react-core/blocks/sidebar`
|
|
62
|
+
- Primary app navigation drawer/rail supporting nested menus, badges, and collapse states. Inspect items and events via `get_component_api({ "component": "sidebar" })`.
|
|
57
63
|
3. **Breadcrumb Trail (`Breadcrumb`)**:
|
|
58
|
-
|
|
64
|
+
- Subpath: `@wangs-ui/react-core/primitive/breadcrumb`
|
|
65
|
+
- Secondary hierarchy navigation displaying screen depth. Inspect item structure via `get_component_api({ "component": "breadcrumb" })`.
|
|
59
66
|
4. **Tabbed Sub-Views (`Tabs`)**:
|
|
60
|
-
|
|
67
|
+
- Subpath: `@wangs-ui/react-core/primitive/tabs`
|
|
68
|
+
- In-page view switcher for partitioning entity details into distinct panels. Inspect via `get_component_api({ "component": "tabs" })`.
|
|
69
|
+
5. **Universal Routing (`@wangs-ui/react-navigation`)**:
|
|
70
|
+
- Platform-agnostic route graph abstraction (`buildGraph`, `paramRoute`).
|
|
71
|
+
- Web router bridge: `@wangs-ui/react-navigation/web` (React Router).
|
|
72
|
+
- Native router bridge: `@wangs-ui/react-navigation/native` (React Navigation / Expo).
|
|
61
73
|
|
|
62
74
|
---
|
|
63
75
|
|
|
64
|
-
## 3.
|
|
76
|
+
## 3. Structural Page Blueprint (Standard Pattern)
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import AppLayout from '@wangs-ui/react-core/blocks/applayout';
|
|
80
|
+
import Sidebar from '@wangs-ui/react-core/blocks/sidebar';
|
|
81
|
+
import Breadcrumb from '@wangs-ui/react-core/primitive/breadcrumb';
|
|
82
|
+
import { Container, Section, Stack, HStack } from '@wangs-ui/foundation/layout';
|
|
83
|
+
import { Text } from '@wangs-ui/foundation/theme';
|
|
84
|
+
import { useI18n } from '@wangs-ui/react-i18n';
|
|
85
|
+
import { HomeLine, Settings4Line } from '@wangs-ui/react-icons';
|
|
86
|
+
import { useState } from 'react';
|
|
87
|
+
|
|
88
|
+
export function ApplicationShell({ children }: { children: React.ReactNode }) {
|
|
89
|
+
const { t } = useI18n();
|
|
90
|
+
const [activeRoute, setActiveRoute] = useState('dashboard');
|
|
91
|
+
const [collapsed, setCollapsed] = useState(false);
|
|
92
|
+
|
|
93
|
+
const sidebarItems = [
|
|
94
|
+
{ value: 'dashboard', label: t('Dashboard'), icon: HomeLine, to: '/' },
|
|
95
|
+
{ value: 'settings', label: t('Settings'), icon: Settings4Line, to: '/settings' },
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<AppLayout
|
|
100
|
+
variant="full-sidebar"
|
|
101
|
+
sidebar={
|
|
102
|
+
<Sidebar
|
|
103
|
+
items={sidebarItems}
|
|
104
|
+
value={activeRoute}
|
|
105
|
+
onValueChange={setActiveRoute}
|
|
106
|
+
collapsed={collapsed}
|
|
107
|
+
onCollapsedChange={setCollapsed}
|
|
108
|
+
collapseMode="rail"
|
|
109
|
+
/>
|
|
110
|
+
}
|
|
111
|
+
>
|
|
112
|
+
<Container size="xl">
|
|
113
|
+
<Section space="md">
|
|
114
|
+
<Stack gap="4">
|
|
115
|
+
<Breadcrumb
|
|
116
|
+
items={[
|
|
117
|
+
{ label: t('Home'), href: '/' },
|
|
118
|
+
{ label: t('Dashboard') },
|
|
119
|
+
]}
|
|
120
|
+
/>
|
|
121
|
+
<Text variant="headlineLarge">{t('Overview')}</Text>
|
|
122
|
+
{children}
|
|
123
|
+
</Stack>
|
|
124
|
+
</Section>
|
|
125
|
+
</Container>
|
|
126
|
+
</AppLayout>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
65
132
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
133
|
+
## 4. Mandatory Implementation Rules
|
|
134
|
+
|
|
135
|
+
1. **Query MCP First**: Always inspect `applayout` and `sidebar` stories via MCP before assembling the layout.
|
|
136
|
+
2. **Strict Subpath Imports**:
|
|
137
|
+
- Blocks: `@wangs-ui/react-core/blocks/*` (`applayout`, `sidebar`, `tabletoolbar`)
|
|
138
|
+
- Primitives: `@wangs-ui/react-core/primitive/*` (`breadcrumb`, `tabs`)
|
|
139
|
+
- Layout Primitives: `@wangs-ui/foundation/layout` (`Container`, `Section`, `Stack`, `HStack`, `Box`, `Grid`)
|
|
140
|
+
- Typography: `@wangs-ui/foundation/theme` (`Text`)
|
|
141
|
+
3. **Standard Layout Containers & Spacing**:
|
|
142
|
+
- Use `Container` (max-width rhythm) and `Section` (vertical rhythm) for page boundaries.
|
|
143
|
+
- Use flat numeric Tailwind spacing (`gap="4"`, `p="6"`). Never use legacy named tokens like `p-3xl` or `gap-md`.
|
|
144
|
+
4. **Typography Scale**:
|
|
145
|
+
- Use `<Text variant="headlineLarge">` or `display*` / `title*` for page headers. Never use obsolete `.heading-*` helper classes or raw HTML heading tags without primitives.
|
|
146
|
+
5. **No Redundant Layout Wrappers**:
|
|
147
|
+
- Do NOT insert intermediate pass-through `<div>` or `<Box>` wrappers between `<Card>`/`<Tabs>` and tab contents.
|
|
148
|
+
- Render active tab content directly as a child of the container:
|
|
149
|
+
```tsx
|
|
150
|
+
// ✅ Good
|
|
151
|
+
<Card>
|
|
152
|
+
<Tabs items={tabItems} value={activeTab} onValueChange={setActiveTab} />
|
|
153
|
+
{activeTab === 'general' ? <GeneralTab /> : <SecurityTab />}
|
|
154
|
+
</Card>
|
|
155
|
+
```
|
|
156
|
+
6. **Translate Navigation Labels**: Wrap all sidebar item labels, breadcrumb text, and page headings in `t('...')` from `@wangs-ui/react-i18n`.
|
|
@@ -10,7 +10,17 @@ Use this skill when building responsive pages, layouts, or screen adaptations wi
|
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
## 1.
|
|
13
|
+
## 1. MCP Inspection Protocol (Mandatory Single Source of Truth)
|
|
14
|
+
|
|
15
|
+
Do **NOT** guess responsive prop types or breakpoint keys. Query the MCP server dynamically:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
resolve_type_definition({ "types": ["ResponsiveValue", "Breakpoint", "SpacingKey"] })
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 2. Breakpoint Reference
|
|
14
24
|
|
|
15
25
|
Wangs UI uses three standardized breakpoints:
|
|
16
26
|
|
|
@@ -30,14 +40,17 @@ const { breakpoint } = useTheme(); // 'compact' | 'medium' | 'expanded'
|
|
|
30
40
|
|
|
31
41
|
---
|
|
32
42
|
|
|
33
|
-
##
|
|
43
|
+
## 3. Responsive Props (`ResponsiveValue`)
|
|
34
44
|
|
|
35
45
|
Visual scale props (`size`, layout `gap`, `columns`, `p`, `m`) accept either a single value or an object mapped by breakpoint:
|
|
36
46
|
|
|
37
47
|
```tsx
|
|
48
|
+
import { Button } from '@wangs-ui/react-core/components/button';
|
|
49
|
+
import { Grid, Stack } from '@wangs-ui/foundation/layout';
|
|
50
|
+
|
|
38
51
|
// Static (identical across all devices)
|
|
39
52
|
<Button size="md" />
|
|
40
|
-
<Stack gap=
|
|
53
|
+
<Stack gap="4" />
|
|
41
54
|
|
|
42
55
|
// Adaptive (changes across breakpoints)
|
|
43
56
|
<Button size={{ compact: 'lg', expanded: 'sm' }} />
|
|
@@ -48,7 +61,7 @@ Visual scale props (`size`, layout `gap`, `columns`, `p`, `m`) accept either a s
|
|
|
48
61
|
|
|
49
62
|
---
|
|
50
63
|
|
|
51
|
-
##
|
|
64
|
+
## 4. Conditional Rendering (`<Show>`)
|
|
52
65
|
|
|
53
66
|
Use `<Show>` when a component should be mounted or unmounted based on the active breakpoint:
|
|
54
67
|
|
|
@@ -78,7 +91,7 @@ import { Show } from '@wangs-ui/foundation/theme';
|
|
|
78
91
|
|
|
79
92
|
---
|
|
80
93
|
|
|
81
|
-
##
|
|
94
|
+
## 5. Spacing Conventions
|
|
82
95
|
|
|
83
96
|
Spacing tokens are **flat and fixed** (1 unit = 4px):
|
|
84
97
|
|
|
@@ -87,7 +100,7 @@ Spacing tokens are **flat and fixed** (1 unit = 4px):
|
|
|
87
100
|
|
|
88
101
|
---
|
|
89
102
|
|
|
90
|
-
##
|
|
103
|
+
## 6. Anti-Patterns to Avoid
|
|
91
104
|
|
|
92
105
|
1. **Avoid `hidden md:block` for stateful/heavy trees**: Always prefer `<Show>` so unused components cleanly unmount.
|
|
93
106
|
2. **Never pass responsive objects to behavioral props**: `<Button disabled={{ compact: true }} />` is invalid.
|
|
@@ -18,24 +18,15 @@ Do **NOT** guess layout prop names, spacing scales, or breakpoint keys. Query th
|
|
|
18
18
|
server dynamically:
|
|
19
19
|
|
|
20
20
|
```json
|
|
21
|
-
list_catalog({ "
|
|
22
|
-
|
|
23
|
-
get_component_api({ "id": "layout:grid" })
|
|
24
|
-
get_documentation({ "id": "layout-stack" })
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Resolve shared types before writing responsive props:
|
|
28
|
-
|
|
29
|
-
```json
|
|
30
|
-
resolve_type_definition({ "name": "ResponsiveValue" })
|
|
31
|
-
resolve_type_definition({ "name": "SpacingKey" })
|
|
21
|
+
list_catalog({ "query": "layout" })
|
|
22
|
+
resolve_type_definition({ "types": ["ResponsiveValue", "SpacingKey", "StackProps", "GridProps", "BoxProps", "ScrollAreaProps"] })
|
|
32
23
|
```
|
|
33
24
|
|
|
34
25
|
---
|
|
35
26
|
|
|
36
27
|
## 2. Choosing the Right Primitive
|
|
37
28
|
|
|
38
|
-
1. **Stack (
|
|
29
|
+
1. **Stack (Vertical)** — default for vertical flows (forms, cards, page sections).
|
|
39
30
|
Fixed `column` direction, uniform `gap`, optional auto-`separator`.
|
|
40
31
|
2. **HStack** — horizontal rows with vertical centering (avatar + label + action,
|
|
41
32
|
toolbar clusters). Fixed `row` direction.
|
|
@@ -52,25 +43,26 @@ resolve_type_definition({ "name": "SpacingKey" })
|
|
|
52
43
|
vertical rhythm (`space: 'sm' | 'md' | 'lg'`, default `'md'`). Never nest
|
|
53
44
|
`Container` inside `Container`.
|
|
54
45
|
7. **ZStack** — overlays (badge on card, status dot on avatar, hero overlay).
|
|
55
|
-
8. **
|
|
46
|
+
8. **ScrollArea** — styled, accessible scrollable viewports (`orientation: 'vertical' | 'horizontal' | 'both'`, `variant: 'hover' | 'always' | 'scroll'`).
|
|
47
|
+
9. **AspectRatio / Bleed / Spacer** — media frames (`ratio`), full-bleed breakouts
|
|
56
48
|
inside padded containers (`Bleed`), and flexible fillers in stacks (`Spacer`).
|
|
57
49
|
|
|
58
50
|
---
|
|
59
51
|
|
|
60
52
|
## 3. Mandatory Implementation Rules
|
|
61
53
|
|
|
62
|
-
1. **ResponsiveValue everywhere**: scalar for static (`gap=
|
|
63
|
-
adaptive (`gap={{ compact: 2, medium: 4, expanded: 6 }}`,
|
|
54
|
+
1. **ResponsiveValue everywhere**: scalar for static (`gap="4"`), object for
|
|
55
|
+
adaptive (`gap={{ compact: '2', medium: '4', expanded: '6' }}`,
|
|
64
56
|
`columns={{ compact: 1, medium: 2, expanded: 4 }}`). Breakpoints are
|
|
65
57
|
`compact` (mobile-first base), `medium` (`md:`), `expanded` (`lg:`).
|
|
66
58
|
2. **Separators, not manual dividers**: `<Stack separator={<Divider />}>` inserts
|
|
67
59
|
dividers between children with no trailing element. Never hand-place a divider
|
|
68
60
|
after every child.
|
|
69
|
-
3. **Spacing scale**: `gap`/`p`/`m` use `SpacingKey` (Tailwind numeric scale,
|
|
70
|
-
1
|
|
61
|
+
3. **Spacing scale**: `gap`/`p`/`m` use `SpacingKey` (Tailwind numeric scale strings,
|
|
62
|
+
e.g. `'0'`, `'1'`, `'2'`, `'4'`, `'6'`, `'8'`, `'12'`, `'16'`). Never pass raw pixel strings to spacing props.
|
|
71
63
|
4. **Strict subpath imports**:
|
|
72
64
|
```tsx
|
|
73
|
-
import { Stack, HStack, Grid, Container } from '@wangs-ui/foundation/layout';
|
|
65
|
+
import { Stack, HStack, Grid, Container, Box, Flex, ScrollArea } from '@wangs-ui/foundation/layout';
|
|
74
66
|
```
|
|
75
67
|
5. **Translate visible labels** inside layout children via `t('...')` from
|
|
76
68
|
`@wangs-ui/react-i18n` (layout props themselves are never translated).
|
|
@@ -4,9 +4,10 @@ description: Foundational rules, subpath imports, design tokens, and the MCP Dis
|
|
|
4
4
|
metadata:
|
|
5
5
|
owner: wangs-ui
|
|
6
6
|
---
|
|
7
|
+
|
|
7
8
|
# Skill: Wangs UI Component Fundamentals & MCP Protocol
|
|
8
9
|
|
|
9
|
-
Use this skill whenever you write or modify UI components using Wangs UI (`@wangs-ui/react-core`, `@wangs-ui/react-icons`, `@wangs-ui/react-presets`, `@wangs-ui/
|
|
10
|
+
Use this skill whenever you write or modify UI components using Wangs UI (`@wangs-ui/react-core`, `@wangs-ui/foundation`, `@wangs-ui/react-icons`, `@wangs-ui/react-presets`, `@wangs-ui/form`).
|
|
10
11
|
|
|
11
12
|
---
|
|
12
13
|
|
|
@@ -16,34 +17,42 @@ Do **NOT** guess component props, Pass-Through (`pt`) slots, or event names. Alw
|
|
|
16
17
|
|
|
17
18
|
```mermaid
|
|
18
19
|
graph TD
|
|
19
|
-
A[Identify Component Needed] --> B[list_catalog to confirm
|
|
20
|
-
B --> C[get_component_api for
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
D
|
|
24
|
-
E
|
|
20
|
+
A[Identify Component / Token Needed] --> B[list_catalog to confirm name/id]
|
|
21
|
+
B --> C[get_component_api for typed contract]
|
|
22
|
+
B --> D[get_documentation for curated guidance]
|
|
23
|
+
C --> E{Need live story / variant code?}
|
|
24
|
+
D --> E
|
|
25
|
+
E -->|Yes| F[get_component_examples]
|
|
26
|
+
E -->|No| G[Implement with Modular Subpaths]
|
|
25
27
|
F --> G
|
|
26
|
-
G --> H[Implement Component with Subpath Imports]
|
|
27
28
|
```
|
|
28
29
|
|
|
29
30
|
### Discovery Steps:
|
|
30
31
|
|
|
31
|
-
1. **
|
|
32
|
+
1. **Confirm Available Components & Blocks**:
|
|
33
|
+
```json
|
|
34
|
+
list_catalog({ "query": "button" })
|
|
35
|
+
list_catalog({ "category": "component" })
|
|
36
|
+
```
|
|
37
|
+
2. **Inspect Component Contract & Props** (`component` parameter):
|
|
32
38
|
```json
|
|
33
|
-
get_component_api({ "
|
|
34
|
-
get_component_api({ "
|
|
35
|
-
get_component_api({ "
|
|
39
|
+
get_component_api({ "component": "button" })
|
|
40
|
+
get_component_api({ "component": "input" })
|
|
41
|
+
get_component_api({ "component": "datatable" })
|
|
42
|
+
get_component_api({ "component": "modal" })
|
|
36
43
|
```
|
|
37
|
-
|
|
44
|
+
3. **Inspect Curated Documentation** (`id` parameter):
|
|
38
45
|
```json
|
|
46
|
+
get_documentation({ "id": "foundation" })
|
|
39
47
|
get_documentation({ "id": "button" })
|
|
48
|
+
get_documentation({ "id": "form" })
|
|
40
49
|
```
|
|
41
|
-
|
|
50
|
+
4. **Inspect Live Usage & Story Variants**:
|
|
42
51
|
```json
|
|
43
52
|
get_component_examples({ "component": "button", "variant": "Sizes" })
|
|
44
53
|
get_component_examples({ "component": "datatable", "variant": "CursorPagination" })
|
|
45
54
|
```
|
|
46
|
-
|
|
55
|
+
5. **Query Knowledge Graph & Symbol Relationships**:
|
|
47
56
|
```json
|
|
48
57
|
query_graph({ "query": "DataTable" })
|
|
49
58
|
query_graph({ "query": "usePT" })
|
|
@@ -51,30 +60,55 @@ graph TD
|
|
|
51
60
|
|
|
52
61
|
---
|
|
53
62
|
|
|
54
|
-
## 2. Subpath
|
|
63
|
+
## 2. Modular Subpath Imports (Mandatory)
|
|
55
64
|
|
|
56
65
|
Always import via specific subpaths to guarantee tree-shaking and avoid bundling entire packages:
|
|
57
66
|
|
|
58
67
|
```tsx
|
|
59
|
-
// Primitives (@wangs-ui/react-core/primitive/*)
|
|
68
|
+
// 1. Core Primitives (@wangs-ui/react-core/primitive/*)
|
|
60
69
|
import Button from '@wangs-ui/react-core/primitive/button';
|
|
61
70
|
import Input from '@wangs-ui/react-core/primitive/input';
|
|
62
71
|
import NumberInput from '@wangs-ui/react-core/primitive/numberinput';
|
|
72
|
+
import Textarea from '@wangs-ui/react-core/primitive/textarea';
|
|
63
73
|
import Select from '@wangs-ui/react-core/primitive/select';
|
|
74
|
+
import MultiSelect from '@wangs-ui/react-core/primitive/multiselect';
|
|
75
|
+
import Checkbox from '@wangs-ui/react-core/primitive/checkbox';
|
|
64
76
|
import Badge from '@wangs-ui/react-core/primitive/badge';
|
|
65
77
|
import Card from '@wangs-ui/react-core/primitive/card';
|
|
66
78
|
import DataTable from '@wangs-ui/react-core/primitive/datatable';
|
|
67
|
-
|
|
68
|
-
|
|
79
|
+
import Modal from '@wangs-ui/react-core/primitive/modal';
|
|
80
|
+
import Dialog from '@wangs-ui/react-core/primitive/dialog';
|
|
81
|
+
import DialogForm from '@wangs-ui/react-core/primitive/dialogform';
|
|
82
|
+
import { useForm, Form } from '@wangs-ui/react-core/primitive/form';
|
|
83
|
+
import Field from '@wangs-ui/react-core/primitive/field';
|
|
84
|
+
|
|
85
|
+
// 2. Layout Primitives (@wangs-ui/foundation/layout)
|
|
86
|
+
import {
|
|
87
|
+
Box,
|
|
88
|
+
Flex,
|
|
89
|
+
Stack,
|
|
90
|
+
HStack,
|
|
91
|
+
VStack,
|
|
92
|
+
Grid,
|
|
93
|
+
Container,
|
|
94
|
+
Section,
|
|
95
|
+
Show,
|
|
96
|
+
} from '@wangs-ui/foundation/layout';
|
|
97
|
+
|
|
98
|
+
// 3. Typography Primitives (@wangs-ui/foundation/theme)
|
|
99
|
+
import { Text, Code, Kbd, Link, Mark, Blockquote, List } from '@wangs-ui/foundation/theme';
|
|
100
|
+
|
|
101
|
+
// 4. Blocks & Navigation (@wangs-ui/react-core/blocks/*)
|
|
69
102
|
import AppLayout from '@wangs-ui/react-core/blocks/applayout';
|
|
70
103
|
import Sidebar from '@wangs-ui/react-core/blocks/sidebar';
|
|
104
|
+
import TableToolbar from '@wangs-ui/react-core/blocks/tabletoolbar';
|
|
71
105
|
|
|
72
|
-
// Providers & System Hooks
|
|
106
|
+
// 5. Providers & System Hooks
|
|
73
107
|
import { WangsUiProvider } from '@wangs-ui/react-core/api';
|
|
108
|
+
import { ThemeProvider, useTheme } from '@wangs-ui/foundation/theme';
|
|
74
109
|
import { useI18n } from '@wangs-ui/react-i18n';
|
|
75
|
-
import { useTheme } from '@wangs-ui/foundation/theme';
|
|
76
110
|
|
|
77
|
-
// Icons (@wangs-ui/react-icons)
|
|
111
|
+
// 6. Vector Icons (@wangs-ui/react-icons)
|
|
78
112
|
import { SearchLine, AddLine, DeleteBin6Line, CheckLine } from '@wangs-ui/react-icons';
|
|
79
113
|
```
|
|
80
114
|
|
|
@@ -82,36 +116,87 @@ import { SearchLine, AddLine, DeleteBin6Line, CheckLine } from '@wangs-ui/react-
|
|
|
82
116
|
|
|
83
117
|
## 3. Strict Primitive Substitution Rule
|
|
84
118
|
|
|
85
|
-
Never write raw HTML
|
|
119
|
+
Zero raw HTML elements. Never write raw HTML tags when a Wangs UI primitive exists:
|
|
120
|
+
|
|
121
|
+
| Forbidden Raw HTML | Mandatory Wangs UI Primitive | Import Path | MCP Doc / Catalog ID |
|
|
122
|
+
|:-------------------------------|:-----------------------------------------------------|:---------------------------------------------|:------------------------|
|
|
123
|
+
| `<button>` | `Button` | `@wangs-ui/react-core/primitive/button` | `button` |
|
|
124
|
+
| `<input type="text">` | `Input` | `@wangs-ui/react-core/primitive/input` | `input` |
|
|
125
|
+
| `<input type="number">` | `NumberInput` | `@wangs-ui/react-core/primitive/numberinput` | `numberinput` |
|
|
126
|
+
| `<input type="checkbox">` | `Checkbox` | `@wangs-ui/react-core/primitive/checkbox` | `checkbox` |
|
|
127
|
+
| `<select>` | `Select` / `MultiSelect` | `@wangs-ui/react-core/primitive/select` | `select`, `multiselect` |
|
|
128
|
+
| `<textarea>` | `Textarea` | `@wangs-ui/react-core/primitive/textarea` | `textarea` |
|
|
129
|
+
| `<form>` | `Form` / `DialogForm` | `@wangs-ui/react-core/primitive/form` | `form`, `dialogform` |
|
|
130
|
+
| `<dialog>` / alert modal | `Modal` / `Dialog` | `@wangs-ui/react-core/primitive/modal` | `modal`, `dialog` |
|
|
131
|
+
| `<table>` | `DataTable` | `@wangs-ui/react-core/primitive/datatable` | `datatable` |
|
|
132
|
+
| `<div>` (layout / flex / grid) | `Stack`, `HStack`, `Flex`, `Grid`, `Box` | `@wangs-ui/foundation/layout` | `universal-layout` |
|
|
133
|
+
| `<div>` (surface card) | `Card` | `@wangs-ui/react-core/primitive/card` | `card` |
|
|
134
|
+
| Pill / status chip | `Badge` | `@wangs-ui/react-core/primitive/badge` | `badge` |
|
|
135
|
+
| `<h1>` - `<h6>` | `<Text variant="headline*">` / `display*` / `title*` | `@wangs-ui/foundation/theme` | `foundation` |
|
|
136
|
+
| `<p>`, `<span>` (body text) | `<Text variant="body*">` / `label*` | `@wangs-ui/foundation/theme` | `foundation` |
|
|
137
|
+
| `<a>` | `Link` | `@wangs-ui/foundation/theme` | `foundation` |
|
|
138
|
+
| `<code>` | `Code` | `@wangs-ui/foundation/theme` | `foundation` |
|
|
139
|
+
| `<kbd>` | `Kbd` | `@wangs-ui/foundation/theme` | `foundation` |
|
|
140
|
+
| `<blockquote>` | `Blockquote` | `@wangs-ui/foundation/theme` | `foundation` |
|
|
141
|
+
| `<ul>`, `<ol>` | `List` | `@wangs-ui/foundation/theme` | `foundation` |
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## 4. Typography System & `<Text>` Primitive
|
|
146
|
+
|
|
147
|
+
Wangs UI uses a unified typography token system with standard and emphasized variants. Do **NOT** use arbitrary text utilities (`text-[16px]`, `text-lg`) or obsolete `.heading-*` classes.
|
|
148
|
+
|
|
149
|
+
### Primary Typography Primitive: `<Text>`
|
|
150
|
+
|
|
151
|
+
```tsx
|
|
152
|
+
import { Text } from '@wangs-ui/foundation/theme';
|
|
86
153
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
154
|
+
// Headings & Displays
|
|
155
|
+
<Text variant="displayMedium">Hero Title</Text>
|
|
156
|
+
<Text variant="headlineLarge">Page Header</Text>
|
|
157
|
+
<Text variant="titleMedium">Card Section Header</Text>
|
|
158
|
+
|
|
159
|
+
// Body & Labels
|
|
160
|
+
<Text variant="bodyMedium">Standard reading paragraph text.</Text>
|
|
161
|
+
<Text variant="bodySmall" color="secondary">Helper caption text.</Text>
|
|
162
|
+
<Text variant="labelLarge" weight="bold">Interactive button or badge label</Text>
|
|
163
|
+
|
|
164
|
+
// Polymorphic HTML Tag Override (default maps automatically: display/headline -> h1/h2, body -> p, label -> span)
|
|
165
|
+
<Text variant="titleMedium" as="h3">Custom Tag Title</Text>
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Typography Roles:
|
|
169
|
+
|
|
170
|
+
- **Display**: Page heroes (`displayLarge`, `displayMedium`, `displaySmall`)
|
|
171
|
+
- **Headline**: Screen and page titles (`headlineLarge`, `headlineMedium`, `headlineSmall`)
|
|
172
|
+
- **Title**: Card and modal section headers (`titleLarge`, `titleMedium`, `titleSmall`)
|
|
173
|
+
- **Body**: Main copy and paragraphs (`bodyLarge`, `bodyMedium`, `bodySmall`)
|
|
174
|
+
- **Label**: Buttons, inputs, and badges (`labelLarge`, `labelMedium`, `labelSmall`)
|
|
175
|
+
- Append `Emphasized` for high-emphasis weights (e.g. `headlineMediumEmphasized`, `titleLargeEmphasized`).
|
|
98
176
|
|
|
99
177
|
---
|
|
100
178
|
|
|
101
|
-
##
|
|
179
|
+
## 5. Spacing Scale & Theming Invariants
|
|
102
180
|
|
|
103
|
-
###
|
|
181
|
+
### Flat 4px Spacing Scale
|
|
104
182
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
-
|
|
109
|
-
-
|
|
110
|
-
-
|
|
183
|
+
Keys follow the flat numeric Tailwind step (`1` unit `= 4px`):
|
|
184
|
+
`0`, `0.5` (2px), `1` (4px), `1.5` (6px), `2` (8px), `2.5` (10px), `3` (12px), `3.5` (14px), `4` (16px), `5` (20px), `6` (24px), `8` (32px), `10` (40px), `12` (48px), `16` (64px).
|
|
185
|
+
|
|
186
|
+
- **In Layout Primitives**: Pass keys directly: `<HStack gap="3" p="4">`
|
|
187
|
+
- **In Tailwind Utilities**: Use standard numeric utilities: `p-4`, `gap-3`, `px-6`
|
|
188
|
+
- **In React Native**: Read pixels via `useTheme().spacing`: `spacing[4] === 16`
|
|
189
|
+
|
|
190
|
+
### Theming & Dark Mode Invariants
|
|
191
|
+
|
|
192
|
+
- **Theme Provider**: Wrap app root with `<ThemeProvider defaultPalette="blue" defaultMode="light">`.
|
|
193
|
+
- **Engine Invariant**: **NEVER** override `:root`, `[data-mode='dark']`, or `--color-*` variables in custom CSS. Always customize themes via `ThemeProvider` or `WangsUiProvider.configOptions.preset`.
|
|
194
|
+
- **Dark Mode**: Toggle only via `useTheme().setMode('dark' | 'light')` — never mutate `document.documentElement.classList`.
|
|
195
|
+
|
|
196
|
+
---
|
|
111
197
|
|
|
112
|
-
|
|
198
|
+
## 6. Layout Governance & Redundant Wrapper Rule
|
|
113
199
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
- Responsiveness via `ResponsiveValue<T>` size props and `<Show>`, not per-density spacing tokens
|
|
200
|
+
1. **Use Layout Primitives**: Arrange layouts using `Stack`, `HStack`, `VStack`, `Flex`, `Grid`, and `Box` from `@wangs-ui/foundation/layout`.
|
|
201
|
+
2. **Zero Redundant Wrappers**: Never wrap a single component in an unnecessary `<div>` or `<Box>` (e.g. `<div><DataTable /></div>` or `<Box><Card /></Box>`).
|
|
202
|
+
3. **No Inline Styling Overrides**: Component visual styling lives in global presets. Do not pass ad-hoc utility classes (`className="h-5 w-5"`, `rounded-lg`) directly to primitives or icons unless documented as an MCP exception.
|