@televet/kibble-ui 5.0.31 → 5.1.0-ne.0
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/AGENTS.md +120 -0
- package/dist/components.json +8874 -0
- package/package.json +8 -4
package/AGENTS.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# AGENTS.md - Kibble UI Component Library
|
|
2
|
+
|
|
3
|
+
> Guidelines for AI agents working in this React/Chakra UI component library codebase.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
Kibble is a React component library (design system) for Otto. Built with:
|
|
8
|
+
|
|
9
|
+
- **React 19** + **TypeScript 5.7**
|
|
10
|
+
- **Chakra UI v3** for component primitives
|
|
11
|
+
- **Vite** for building, **Storybook 10** for documentation
|
|
12
|
+
- **Vitest** + **Playwright** for testing (via Storybook addon)
|
|
13
|
+
|
|
14
|
+
This is an **npm workspace** containing two packages:
|
|
15
|
+
|
|
16
|
+
| Package | Path | Description |
|
|
17
|
+
|---------|------|-------------|
|
|
18
|
+
| `@televet/kibble-ui` | `.` (repo root) | React component library — depends on Chakra UI |
|
|
19
|
+
| `@televet/kibble-primitives` | `packages/kibble-primitives/` | Framework-agnostic design token primitives — zero framework dependencies |
|
|
20
|
+
|
|
21
|
+
**Package boundary rule:** `*.records.ts` and `*.types.ts` token files live in `kibble-primitives`. `*.config.ts` files (which wrap tokens with `defineTokens`/`defineSemanticTokens` from Chakra) stay in `kibble-ui`.
|
|
22
|
+
|
|
23
|
+
## Build / Lint / Test Commands
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm start # Start Storybook dev server on port 6006
|
|
27
|
+
npm run build # Full build (types, icons, logos, docs, then vite)
|
|
28
|
+
npm run build:preparation # Generate theme types, icons, logos
|
|
29
|
+
npm run lint # ESLint with auto-fix on src/
|
|
30
|
+
npm run format # Prettier on all TS/TSX files
|
|
31
|
+
npm run test-storybook # Run all Storybook tests
|
|
32
|
+
npx vitest --project=storybook Button # Run tests for Button stories
|
|
33
|
+
npm run create:component # Create new component via plop
|
|
34
|
+
npm run generate:icons # Regenerate icon components from SVGs
|
|
35
|
+
npm run generate:theme # Generate Chakra theme types
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Project Structure
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
packages/
|
|
42
|
+
kibble-primitives/ # @televet/kibble-primitives — token records + types, no framework deps
|
|
43
|
+
src/
|
|
44
|
+
core/ # Raw token scales (colors, spacing, typography, etc.)
|
|
45
|
+
semantic/ # Theme-aware semantic tokens (light/dark mode mappings)
|
|
46
|
+
src/
|
|
47
|
+
components/ # UI components (Button, Alert, Modal, etc.)
|
|
48
|
+
ComponentName/
|
|
49
|
+
componentName.component.tsx
|
|
50
|
+
componentName.types.ts
|
|
51
|
+
componentName.recipe.ts
|
|
52
|
+
componentName.records.ts
|
|
53
|
+
index.ts
|
|
54
|
+
docs/componentName.stories.tsx
|
|
55
|
+
hooks/
|
|
56
|
+
theme/
|
|
57
|
+
tokens/ # Chakra token config files (*.config.ts) — import from kibble-primitives
|
|
58
|
+
semanticTokens/ # Chakra semantic token config — imports from kibble-primitives
|
|
59
|
+
recipes/
|
|
60
|
+
providers/
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Key Patterns
|
|
64
|
+
|
|
65
|
+
- **Variant system**: `variant` + `onContrast` props on most components
|
|
66
|
+
- **Shared status type**: `'info' | 'success' | 'warning' | 'error' | 'default'`
|
|
67
|
+
- **`forwardRef`**: All components that accept `ref` use `forwardRef` + set `displayName`
|
|
68
|
+
- **Recipes**: Use `defineRecipe` for component variants — no inline styles
|
|
69
|
+
- **Semantic tokens**: `background.primary`, `text.contrast` etc. — never raw Chakra colors
|
|
70
|
+
- **Components & imports**: Prefer **Kibble** components over plain HTML or Chakra primitives. When you need Chakra, import from **`@chakra-ui/react` subpaths** — do not pull Chakra through local re-exports in this repo.
|
|
71
|
+
- **DRY**: Follow **don't repeat yourself** across files: extract shared helpers and repeated patterns (utilities, handlers, layout) instead of duplicating them in each story or doc file.
|
|
72
|
+
- **Micro-files & wrappers**: Don’t add a separate file or tiny wrapper for a **one-line** style or a component used **only once** — inline in the consumer unless it’s reused. See **[docs/conventions.md](./docs/conventions.md)** (*File and Component Extraction*).
|
|
73
|
+
- **Function style & exhaustive records**: Use **arrow functions** for exported components and helpers; type token maps as **`Record<ConcreteTokenType, …>`** for exhaustiveness — see **[docs/conventions.md](./docs/conventions.md)** (*Function Style*, *Typed Records for Exhaustiveness*).
|
|
74
|
+
- **Releases**: When you change **published library components** (anything consumers import), **bump the package version** according to semver.
|
|
75
|
+
|
|
76
|
+
## How consumers import Kibble (v5)
|
|
77
|
+
|
|
78
|
+
One rule, used everywhere: import each component from its own path.
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
import { Button } from '@televet/kibble-ui/Button';
|
|
82
|
+
import { Modal } from '@televet/kibble-ui/Modal';
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The v5 exports map sends `@televet/kibble-ui/<Component>` to that component's built entry
|
|
86
|
+
point, so this only works for a component directory that has an `index.ts`. Adding one is
|
|
87
|
+
what makes a new component importable at all — see the barrel rule under **Don't**.
|
|
88
|
+
|
|
89
|
+
Hooks, higher-order components and shared types keep their own prefixes:
|
|
90
|
+
`@televet/kibble-ui/hooks/useColorMode`, `@televet/kibble-ui/hocs/withFormControl`,
|
|
91
|
+
`@televet/kibble-ui/shared/types`. The theme is `@televet/kibble-ui/theme`.
|
|
92
|
+
|
|
93
|
+
`otto-admin` is still on kibble-ui 3.0.8, which predates this exports map. Leave its
|
|
94
|
+
imports alone until it upgrades.
|
|
95
|
+
|
|
96
|
+
## The component manifest
|
|
97
|
+
|
|
98
|
+
`npm run build` writes `dist/components.json` (via `npm run generate:manifest`) describing
|
|
99
|
+
every component: props with types and defaults, variants, sizes, icon names, semantic
|
|
100
|
+
tokens, and each Storybook story's args. It ships inside the published package.
|
|
101
|
+
|
|
102
|
+
`@televet/kibble-mcp` (in `mcp/`) serves that file to coding agents. If you change a
|
|
103
|
+
component's props, the manifest updates on the next build — there is nothing to hand-write.
|
|
104
|
+
Regenerate it on its own with `npm run generate:manifest` (it needs `dist/` to exist, so run
|
|
105
|
+
a build first).
|
|
106
|
+
|
|
107
|
+
## Don't
|
|
108
|
+
|
|
109
|
+
- Use `@ts-ignore` or `as any`
|
|
110
|
+
- Create empty catch blocks
|
|
111
|
+
- Skip the `data-testid` prop
|
|
112
|
+
- Import from `@chakra-ui/react` directly — use subpaths (`@chakra-ui/react/box`)
|
|
113
|
+
- Forget to export from `index.ts` barrel files
|
|
114
|
+
- Use plain HTML elements (`<div>`, `<button>`, `<table>`, `<tr>`, `<td>`, `<span>`, etc.) in `.tsx` files (including Storybook and docs) — always use Kibble or Chakra components instead (prefer Kibble)
|
|
115
|
+
- Build a custom component before checking whether `Button`, `Swatch`, `Text`, `Table`, or another existing Kibble/Chakra component already covers the need
|
|
116
|
+
|
|
117
|
+
## Extended Documentation
|
|
118
|
+
|
|
119
|
+
- **[docs/conventions.md](./docs/conventions.md)** — file naming, TypeScript, Chakra patterns, BEM/CSS class naming, records files, testing
|
|
120
|
+
- **[docs/patterns.md](./docs/patterns.md)** — compound components, creating new components, variant system details
|