@nqlib/nqui 0.5.2 → 0.5.3

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": "@nqlib/nqui",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "A React component library with enhanced UI components and developer tools",
5
5
  "type": "module",
6
6
  "main": "./dist/nqui.cjs.js",
@@ -0,0 +1,93 @@
1
+ ---
2
+ description: nqui component implementation guide. Use when building UI with @nqlib/nqui.
3
+ globs: "**/*.{ts,tsx}"
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # nqui Component Guidelines
8
+
9
+ When building UI with @nqlib/nqui, follow these rules so the AI builds components correctly.
10
+
11
+ ## Install (full: nqui + all optional peers)
12
+
13
+ Run this when setting up a new project or when components fail due to missing peers:
14
+
15
+ ```bash
16
+ pnpm add @nqlib/nqui @hugeicons/react @hugeicons/core-free-icons cmdk @dnd-kit/core @dnd-kit/modifiers @dnd-kit/sortable @dnd-kit/utilities embla-carousel-react @tanstack/react-table react-day-picker date-fns sonner vaul react-resizable-panels
17
+ ```
18
+
19
+ Alternative (npm): `npm install @nqlib/nqui @hugeicons/react @hugeicons/core-free-icons cmdk @dnd-kit/core @dnd-kit/modifiers @dnd-kit/sortable @dnd-kit/utilities embla-carousel-react @tanstack/react-table react-day-picker date-fns sonner vaul react-resizable-panels`
20
+
21
+ Or use `npx @nqlib/nqui install-peers` to auto-detect package manager.
22
+
23
+ ## Import
24
+
25
+ ```tsx
26
+ import { Button, ToggleGroup, ToggleGroupItem, Select } from "@nqlib/nqui"
27
+ ```
28
+
29
+ **CSS:** `@import "@nqlib/nqui/styles"` (run `npx @nqlib/nqui init-css` first)
30
+
31
+ ## CSS Setup (First-Run Fix)
32
+
33
+ `init-css` creates `nqui/index.css` and `nqui/nqui-setup.css` in the project root. **User must manually add the import** to their main CSS file. If nqui components render without styles or user reports "CSS import issue":
34
+
35
+ 1. **Check** if the main CSS file has the nqui import. Main files: `app/globals.css` (Next.js), `src/index.css` (Vite), `app/root.css` (Remix).
36
+
37
+ 2. **Fix options:**
38
+ - **Option A (recommended):** Add `@import "@nqlib/nqui/styles";` near the top of the main CSS file (after `@import "tailwindcss"`).
39
+ - **Option B:** If `nqui/nqui-setup.css` exists, copy its contents to the very top of the main CSS file.
40
+
41
+ 3. **Next.js only:** Ensure `@source` directives exist for Tailwind v4:
42
+ ```css
43
+ @source "./**/*.{js,ts,jsx,tsx,mdx}";
44
+ @source "../components/**/*.{js,ts,jsx,tsx,mdx}";
45
+ @source "../node_modules/@nqlib/nqui/dist/**/*.js";
46
+ ```
47
+
48
+ 4. **Vite:** Simpler – just `@import "tailwindcss";` + `@import "tw-animate-css";` + `@import "@nqlib/nqui/styles";`
49
+
50
+ If user hasn't run init-css, suggest: `npx @nqlib/nqui init-css` then add the import as above.
51
+
52
+ ## Component Selection Rules
53
+
54
+ ### Inline/Toolbar Selection → ToggleGroup (never RadioGroup)
55
+
56
+ | Context | Use | NOT |
57
+ |---------|-----|-----|
58
+ | View mode (List/Grid), scale (Linear/Log), size (S/M/L) | **ToggleGroup** `type="single" variant="segmented"` | RadioGroup |
59
+ | Format toolbar (Bold/Italic/Underline) | **ToggleGroup** `type="multiple"` | Multiple Checkboxes |
60
+ | Toolbar actions (Undo/Redo) | **ButtonGroup** | — |
61
+ | Single on/off (Bold, Mute) | **Toggle** | — |
62
+
63
+ **Rule:** Inline/toolbar = ToggleGroup. RadioGroup only for form context (settings modal, stacked list).
64
+
65
+ ### Quick Decision
66
+
67
+ - **ToggleGroup segmented** → 1 of N, 2–4 options, primary fill on selected
68
+ - **ToggleGroup single** → 1 of N, neutral styling
69
+ - **ToggleGroup multiple** → 0+ of N (bold/italic)
70
+ - **Select** → 1 of N, 5+ options or dropdown
71
+ - **ButtonGroup** → Actions (each click = action)
72
+ - **RadioGroup** → Form context only
73
+
74
+ ## Context-First Design
75
+
76
+ **Rule:** Never show Toggle/ToggleGroup/ButtonGroup floating alone. Place in realistic context:
77
+ - Document editor: toolbar above content, `bg-muted/30`, `Separator` between groups
78
+ - Chart/settings: label + inline controls, `rounded-lg border bg-muted/30 p-3`
79
+
80
+ ## Shared Conventions
81
+
82
+ - **Control sizes:** sm=h-6, default=h-7, lg=h-8
83
+ - **Enhanced vs Core:** Default is enhanced. Use `CoreButton`, `CoreBadge` for plain shadcn.
84
+ - **Z-index:** Use CSS vars only, e.g. `z-[var(--z-modal)]`. Never hardcode `z-10`, `z-50`.
85
+ - **Grouped controls:** ButtonGroup, ToggleGroup share container border; ToggleGroup uses item dividers.
86
+
87
+ ## Skills (load for install or component questions)
88
+
89
+ - **Install/setup:** Load `.cursor/skills/nqui-install/SKILL.md` — commands to execute
90
+ - **Components:** Load `.cursor/skills/nqui-components/SKILL.md` — routing for per-component docs
91
+ - **After `init-skills`:** `.cursor/nqui-skills/COMPONENTS_INDEX.md` then **one** file under `.cursor/nqui-skills/components/nqui-<name>.md`
92
+
93
+ Fallback (no init-skills): `node_modules/@nqlib/nqui/docs/components/README.md` (index, skim sections) then `nqui-<name>.md`.
@@ -6,8 +6,30 @@
6
6
  * The skill content itself is read from the SSOT by download-skills.
7
7
  */
8
8
 
9
+ import { readFileSync, existsSync } from 'fs';
10
+ import { dirname, resolve } from 'path';
11
+ import { fileURLToPath } from 'url';
9
12
  import { FULL_PEER_LIST } from './peer-deps.js';
10
13
 
14
+ const __dirname = dirname(fileURLToPath(import.meta.url));
15
+
16
+ /**
17
+ * Full body for `.cursor/rules/nqui-components.mdc` (shipped next to this file in the npm package).
18
+ */
19
+ export function buildCursorRule() {
20
+ const shipped = resolve(__dirname, 'cursor-rule-nqui-components.mdc');
21
+ if (existsSync(shipped)) {
22
+ return readFileSync(shipped, 'utf8');
23
+ }
24
+ const monorepo = resolve(__dirname, '../.cursor/rules/nqui-components.mdc');
25
+ if (existsSync(monorepo)) {
26
+ return readFileSync(monorepo, 'utf8');
27
+ }
28
+ throw new Error(
29
+ 'nqui: missing cursor rule template. Expected cursor-rule-nqui-components.mdc next to skill-templates.js'
30
+ );
31
+ }
32
+
11
33
  const fullInstallCmd = `pnpm add @nqlib/nqui ${FULL_PEER_LIST.join(' ')}`;
12
34
  const npmInstallCmd = `npm install @nqlib/nqui ${FULL_PEER_LIST.join(' ')}`;
13
35