@machinemetrics/mm-react-components 1.4.2 → 1.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@machinemetrics/mm-react-components",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
4
4
  "description": "Industrial-grade React components for manufacturing applications",
5
5
  "keywords": [
6
6
  "react",
@@ -82,6 +82,11 @@
82
82
  "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,css,md}\"",
83
83
  "format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,json,css,md}\"",
84
84
  "test": "playwright test --config=playwright.config.ts --reporter=line",
85
+ "test:skill": "node --test \"tests/skill/*.test.mjs\"",
86
+ "check:theme-parity": "node scripts/check-theme-parity.cjs",
87
+ "check:component-artifacts": "node scripts/check-component-artifacts.cjs --all",
88
+ "verify:component": "node scripts/verify-component.cjs",
89
+ "verify": "npm run lint && npm run type-check && npm run test:skill && npm run check:theme-parity && npm run check:component-artifacts && npm run build",
85
90
  "test:ui": "playwright test --config=playwright.config.ts --ui",
86
91
  "test:headed": "playwright test --config=playwright.config.ts --headed",
87
92
  "test:visual": "npm run test:visual:light && npm run test:visual:dark",
@@ -1,72 +0,0 @@
1
- ---
2
- name: mm-carbide
3
- description: Generate UIs and widgets with Carbide and MachineMetrics React Components. Use when the user asks to create or generate a UI, widget, screen, or interface using mm-react-components, Carbide, or @machinemetrics/mm-react-components.
4
- ---
5
-
6
- # mm-carbide: UI and widget generation with Carbide
7
-
8
- ## Components
9
-
10
- - Use **only** exports from `@machinemetrics/mm-react-components`. Do not create new components or use other UI libraries.
11
- - Use compound components as in the library: Dialog + DialogTrigger + DialogContent; Form + FormField; DataTable + column descriptors; Card + CardHeader + CardContent + CardFooter; Sheet, DropdownMenu, Tabs, etc. Never replace them with raw divs and custom classes.
12
- - Use `cn()` from the library and Tailwind for layout and styling. Respect `data-slot` for Carbide theming where applicable.
13
- - For a component list and patterns, see [reference.md](reference.md). For full widget and visualization rules, see [widget-rules.md](widget-rules.md).
14
-
15
- ## Theme and styling
16
-
17
- - **Color/CSS reference:** Search **`themes/carbide`** (`carbide.css`) for `--` tokens. **`agent-docs/style-color-reference.md`** is a short overview only. Precompiled `/styles` contains only rules from this library’s build.
18
- - **CSS variables only.** Never hardcode colors, spacing, radii, or shadows. Use semantic tokens: `--background`, `--foreground`, `--primary`, `--muted`, `--muted-foreground`, `--destructive`, `--border`, `--ring`, etc.
19
- - **When converting a component to Carbide:** Remove existing inline styles (`style={{ ... }}`) and component-level CSS (e.g. `.module.css`, `<style>`, or component-scoped styles). Carbide supplies appearance via theme tokens and component variants; legacy styles conflict with the theme and break consistency.
20
- - **Variants over one-off styles.** Use component variants and sizes (e.g. Button: `variant="default"|"destructive"|"outline"|"secondary"|"ghost"|"link"`, `size="sm"|"md"|"lg"|"icon"`). Do not apply brand colors or one-off Tailwind color classes to components.
21
- - **Layout.** Use Flexbox/Grid and `gap-*` for spacing; avoid manual margin chains. Prefer `className="flex flex-col gap-4"` (or similar) over stacking margins.
22
- - **App setup.** Consumers must import the library styles and wrap the app (or Carbide subtree) in an element with class `carbide` so the theme applies. See [reference.md](reference.md) for setup.
23
- - **Dark mode.** All styling must work in both light and dark mode via CSS variables; do not hardcode colors that break theme switching.
24
- - **Accessibility.** Use visible focus states, keyboard support, and semantic structure; avoid relying on color alone.
25
-
26
- ## Component discovery
27
-
28
- **When the package is installed in this project:** Check the package’s **agent-docs** at `node_modules/@machinemetrics/mm-react-components/agent-docs/` (start with **agent-documentation-reference.md**). Prefer using or composing library components over building from scratch.
29
-
30
- **When the package is not installed in this workspace:** agent-docs will not exist. Use this skill’s [reference.md](reference.md) for components and patterns and [widget-rules.md](widget-rules.md) for widget rules. Recommend the user install the package in the project (`npx @machinemetrics/mm-react-components mm-init` or `npm install @machinemetrics/mm-react-components`) so full docs and setup guides are available.
31
-
32
- ## When generating UI
33
-
34
- **Do:** Import from the library; use compound components and variants; use Tailwind for layout and spacing; include proper TypeScript types and accessibility (focus, ARIA where needed).
35
-
36
- **Avoid:** Hardcoded colors (e.g. `bg-blue-600`, `text-gray-500`); inline brand styling; non-semantic HTML; missing focus or labels on interactive elements.
37
-
38
- **Scrolling:** There is no Panel component. For panel-like or card-like regions where content can be longer than the box, use **ScrollArea** around the scrollable content. **ScrollArea only scrolls when it has a constrained height**—otherwise the container grows with content and no scroll appears. Always give ScrollArea an explicit height: e.g. `className="h-[300px]"` or `max-h-[50vh]`. In a flex column (e.g. Card with `flex flex-col max-h-[80vh]`), use `ScrollArea className="flex-1 min-h-0"` so the flex item can shrink and scroll; without `min-h-0` the item won’t shrink and scrolling won’t work. Card is for structure only and does not scroll—wrap CardContent (or the scrollable body) in ScrollArea when content may overflow.
39
-
40
- ## Widget rules
41
-
42
- - **Visual, not textual**: Every widget must include at least one chart, graph, or visual data representation. Text is for titles, labels, and brief annotations only (80% visuals / 20% text max).
43
- - **Show data with insight**: Use comparisons, benchmarks, and highlighting. Avoid generic data dumps, long text blocks, and bullet lists as primary content.
44
- - **One theme per widget**: One central message per widget; simplicity above all.
45
-
46
- ## Technical
47
-
48
- - Default widget dimensions: 100% width × 400px.
49
- - Widgets must be fully responsive and respect content containment (no overflow).
50
- - Only use data explicitly provided; never hallucinate or use placeholder data. Adapt to available data without asking for more.
51
-
52
- ## Converting to Carbide (from other libraries or custom UI)
53
-
54
- When converting existing components to Carbide (including from Chakra UI, MUI, Ant Design, custom components, or inline-styled markup):
55
-
56
- 1. **Remove legacy styling.** Strip inline styles (`style={{ ... }}`), component CSS files (e.g. `.module.css`), and any library-specific style props (e.g. Chakra `sx`/`colorScheme`, MUI `sx`). Rely on Carbide’s theme and variants instead.
57
- 2. **Map to library components.** Replace each existing UI primitive with the closest Carbide export (Button, Input, Card, Dialog, DataTable, Form, etc.). Use [reference.md](reference.md) and agent-docs when the package is installed.
58
- 3. **Use variants and tokens.** Express intent via props (`variant`, `size`) and layout via Tailwind with semantic tokens (`bg-background`, `text-muted-foreground`, `border-border`). Do not re-introduce hardcoded colors or one-off CSS.
59
- 4. **Preserve structure and behavior.** Keep markup structure (headings, sections, forms, tables) and behavior (handlers, validation, state); change only the UI layer to Carbide components and Tailwind layout.
60
- 5. **Verify app setup.** Ensure the app imports `@machinemetrics/mm-react-components/styles` and wraps the Carbide subtree in an element with class `carbide`.
61
-
62
- **When the package is installed in this project:** Use agent-docs (e.g. **chakra-migration-\***) for library-specific migration steps in addition to the above.
63
-
64
- ## Setup, init, and migration
65
-
66
- **When the package is installed in this project:** Use the package’s **agent-docs** at `node_modules/@machinemetrics/mm-react-components/agent-docs/` for setup, initialization (`mm-init`), Chakra UI migration, and the full doc index. Start with **agent-documentation-reference.md**; use **ai-agent-init-guide.md** for setup and **ai-agent-guide.md** (and chakra-migration-\*) for migration.
67
-
68
- **When the package is not installed:** agent-docs is not available. Recommend running `npx @machinemetrics/mm-react-components mm-init` from the project root (or `npm install @machinemetrics/mm-react-components` then adding the styles import and `.carbide` class). After install, agent-docs will be in node_modules for full guides.
69
-
70
- ## Version check while using
71
-
72
- When using this skill, if you have terminal/tool access, you may run `npx @machinemetrics/mm-react-components mm-install-skill` once (e.g. at the start of a UI task or when the user asks about updates) to ensure the installed skill matches the package version; the command reports "Already up to date" or updates the skill. If the user is not on Cursor, they can pass `--target=copilot`, `--target=claude`, or `--target=gemini` to install for VS Code/Copilot, Claude Code, or Gemini CLI. Do not run it on every message—once per session or when relevant is enough.
@@ -1,59 +0,0 @@
1
- # mm-carbide reference
2
-
3
- ## Styling and conventions
4
-
5
- - **Authoritative tokens:** **`@machinemetrics/mm-react-components/themes/carbide`** (`carbide.css`) — search for `--` variables and `.carbide` rules. **`agent-docs/style-color-reference.md`** is an overview only. Precompiled `/styles` is scoped to this library’s build; use **`var(--token)`** from `carbide.css` when needed.
6
- - **Colors and tokens:** Use only CSS variables / semantic tokens (e.g. `bg-background`, `text-foreground`, `text-muted-foreground`, `border-border`, `bg-primary`, `text-destructive`). Never use raw Tailwind color classes like `bg-blue-600` or `text-gray-500`. For palette stops, use arbitrary values: `bg-[var(--grey-500)]`, etc.
7
- - **Variants and sizes:** Use component props: `variant="default"|"destructive"|"outline"|"secondary"|"ghost"|"link"`, `size="sm"|"md"|"lg"|"icon"` where supported (Button and similar). **Badge** also supports semantic status variants: `neutral`, `info`, `success`, `critical`, `warning`, `attention`, `production`, `setup`, `custom` — see **agent-documentation-reference.md** (_Badge variants_).
8
- - **Layout:** Use `flex`, `grid`, and `gap-*` for spacing; avoid ad-hoc margins between siblings.
9
- - **Converting to Carbide:** Remove existing inline styles and component CSS; map to library components and use variants/tokens. See SKILL.md section “Converting to Carbide.”
10
- - **Setup:** Import library styles (e.g. `import '@machinemetrics/mm-react-components/styles'`) and wrap the app (or Carbide root) in `<div className="carbide">` so the theme and fonts apply.
11
-
12
- ## Component discovery
13
-
14
- **When the package is installed in this project:** Check **agent-docs** at `node_modules/@machinemetrics/mm-react-components/agent-docs/`; use **agent-documentation-reference.md** as the index for existing components and patterns.
15
-
16
- **When the package is not installed in this workspace:** agent-docs is not present. Use this reference and [widget-rules.md](widget-rules.md); recommend installing the package in the project (`mm-init` or `npm install @machinemetrics/mm-react-components`) for the full doc set.
17
-
18
- ## Key exports (from @machinemetrics/mm-react-components)
19
-
20
- Import from the package main entry (see `src/index.ts` in the repo for the full list).
21
-
22
- **Layout and structure**: PageHeader, Card (CardHeader, CardTitle, CardDescription, CardContent, CardFooter), **ScrollArea** (ScrollBar), Tabs (TabsList, TabsTrigger, TabsContent), Sidebar, Breadcrumb, Field (FieldLabel, FieldDescription, FieldError, FieldGroup, etc.), Item (ItemMedia, ItemContent, ItemActions, etc.).
23
-
24
- **Overlays and dialogs**: Dialog (DialogTrigger, DialogContent, DialogHeader, DialogFooter, etc.), Sheet, Drawer, AlertDialog, Popover, Tooltip (TooltipTrigger, TooltipContent, TooltipProvider), DropdownMenu, HoverCard, ContextMenu.
25
-
26
- **Forms**: Form, FormField, FormItem, FormLabel, FormControl, FormDescription, FormMessage; Input, SearchInput, Textarea, Label, Checkbox, Switch, RadioGroup/RadioGroupItem, Select, Slider, NativeSelect, Combobox, InputOTP, InputGroup, DatePicker, DateRangePicker, Calendar.
27
-
28
- **Data display**: DataTable, DataTablePagination, ResponsiveTable, DataTableToolbar, createColumnDescriptor, createTextColumn, createNumericColumn, createBadgeColumn, createDateColumn, etc.; Table (TableHeader, TableBody, TableRow, TableCell, etc.); ChartContainer, ChartTooltip, ChartLegend, ChartStyle; Progress, Skeleton, Badge, Avatar, HeroMetricCard.
29
-
30
- **Feedback and actions**: Button, buttonVariants, ButtonGroup; Toaster, toast; Alert, AlertTitle, AlertDescription; Spinner, SpinnerCarbide; Pagination, SimplePagination; Empty (EmptyHeader, EmptyTitle, EmptyDescription, etc.).
31
-
32
- **Other**: Accordion, Collapsible, Separator, Dropzone, ResizablePanelGroup, Carousel, Command, CodePreview, Kbd, cn (utility). Theme: activateCarbideTheme, toggleCarbideTheme, isCarbideThemeActive, etc.
33
-
34
- ## Scrolling: Card vs ScrollArea
35
-
36
- There is no "Panel" component. For panel-like or card-like regions where content may be longer than the visible area, use **ScrollArea** for the scrollable region. **Card** is structure only (border, sections) and does not scroll.
37
-
38
- - **ScrollArea only scrolls when it has a constrained height.** Without a height (or max-height) on the ScrollArea root, the container grows with content and no scrollbar appears. Always set an explicit height: e.g. `className="h-[300px]"` or `max-h-[50vh]`.
39
- - In a **flex column** (e.g. Card with `flex flex-col max-h-[80vh]`), use `ScrollArea className="flex-1 min-h-0"`. The `min-h-0` is required so the flex item can shrink below its content size; without it, ScrollArea won’t scroll.
40
- - Put long content inside ScrollArea; use Card for the outer container and ScrollArea inside CardContent (or as the body) when the body should scroll.
41
-
42
- **If ScrollArea doesn’t scroll:** Ensure the ScrollArea element has a bounded height (fixed height, max-height, or `flex-1 min-h-0` inside a constrained flex container). Never use ScrollArea without one of these.
43
-
44
- ## Patterns
45
-
46
- - **PageHeader**: Use for page titles with optional actions, tabs, and breadcrumbs (ActionConfig, TabConfig, MenuItemConfig).
47
- - **DataTable**: Use createColumnDescriptor / createTextColumn / createNumericColumn / createBadgeColumn / createDateColumn and column registry; use useDataTableState, DataTableToolbar, DataTablePagination.
48
- - **Form**: Use Form + FormField with react-hook-form; FormItem, FormLabel, FormControl, FormDescription, FormMessage.
49
- - **Charts**: Use ChartContainer, ChartTooltip, ChartLegend, ChartStyle with recharts; see chart component for config.
50
-
51
- ## Widget rules summary
52
-
53
- - **When to use**: Charts/graphs for trends, comparisons, distributions (with insight annotations). Icons/indicators for status, categories, severity. Metrics/numbers for single KPIs with context (vs target, trend). Text only for labels, brief context, annotations.
54
- - **Insight-driven**: Add comparisons (vs average, vs goal), highlight what matters (color, sizing), show direction/trend (arrows, sparklines), explain significance.
55
- - **Avoid**: Text-only widgets, generic charts without context, equal visual weight for all data, missing comparison or context.
56
- - **Chart limits**: Max 4 lines per line chart, max 4 bars per cluster, max 5 sectors in pie; use small multiples or focus charts if more needed.
57
- - **Accessibility**: WCAG contrast (4.5:1 text, 3:1 graphics); never rely on color alone—use patterns, shapes, or labels; direct labels on data when possible.
58
-
59
- For full widget and visualization rules, see [widget-rules.md](widget-rules.md).