@cosborn2/ui 0.1.0-beta.0 → 0.2.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/README.md CHANGED
@@ -1,163 +1,13 @@
1
1
  # @cosborn2/ui
2
2
 
3
- React 19 components for web applications: controls, glass surfaces, accessible dialogs, and settings layouts. MIT licensed. ESM with TypeScript declarations.
3
+ Lightweight React UI components: buttons, forms, dialogs, menus, notifications, and settings layouts.
4
4
 
5
- The package works without Tailwind, a theme provider, Next.js, or a CSS-in-JS runtime. Import each component and its CSS explicitly. There is intentionally no root JavaScript barrel.
6
-
7
- ## Install and render a button
8
-
9
- Install the `beta` tag or an explicit version for prereleases. Stable releases use the default `latest` tag.
10
-
11
- ```sh
12
- npm install @cosborn2/ui@beta react react-dom
13
- ```
14
-
15
- ```tsx
16
- import '@cosborn2/ui/theme.css';
17
- import '@cosborn2/ui/button.css';
18
- import { Button } from '@cosborn2/ui/button';
19
-
20
- export function SaveButton() {
21
- return <Button type="submit">Save changes</Button>;
22
- }
23
- ```
24
-
25
- In Next App Router, the example can run as a Server Component. Event handlers belong in a client component; native form submission does not require an event handler. Button preserves the native default `type="submit"`, so specify `type="button"` for non-submit actions inside forms.
26
-
27
- Import `theme.css` once, normally at the app's CSS entry or root layout. Import component styles there or alongside the component's app-owned adapter. JS entry points contain no CSS imports, so they also work with plain Node SSR. `all.css` is available when intentionally loading every component's styles; prefer individual styles for small consumers.
28
-
29
- ## Components and rendering boundaries
30
-
31
- Each entry exports its prop types. Every entry has a matching `.css` export.
32
-
33
- | Entry | Exports | Rendering |
34
- | --- | --- | --- |
35
- | `button` | `Button`, `buttonClassName` for anchors/router links | Server-compatible |
36
- | `icon-button` | `IconButton` | Server-compatible |
37
- | `ghost-text-button` | `GhostTextButton` | Server-compatible |
38
- | `input`, `select` | `Input`, native `Select` | Server-compatible |
39
- | `switch` | `Switch` (native checkbox) | Server-compatible |
40
- | `skeleton` | `Skeleton` | Server-compatible |
41
- | `pill` | `Pill` | Server-compatible |
42
- | `surface` | `Surface` | Server-compatible |
43
- | `glass-popover-surface` | `GlassPopoverSurface` | Server-compatible |
44
- | `header-shell` | `HeaderShell`, padding constants | Server-compatible |
45
- | `data-table` | `DataTable`, typed columns, loading/empty states | Server-compatible; callbacks require a client caller |
46
- | `pagination` | `Pagination`, `PAGE_SIZE` | Server-compatible links; callbacks require a client caller |
47
- | `settings` | `SettingsLayout`, `SettingsPageHeader`, `SettingsCard`, `SettingsCardHeader`, `SettingsRow`, `SettingsSection`, `SettingsNavigation` | Server-compatible |
48
- | `settings-rail` | `SettingsRail` | Client boundary for callback navigation |
49
- | `expandable-pill` | `ExpandablePill` | Client boundary |
50
- | `segmented-control` | `SegmentedControl` | Client boundary |
51
- | `theme-toggle`, `color-picker` | Controlled `ThemeToggle`, configurable `ColorPicker` | Client boundaries |
52
- | `notice` | `Notice` with neutral/success/danger tones and optional heading/icon/actions | Server-compatible |
53
- | `toast` | Controlled `Toast`, `ToastViewport` presentation | Server-compatible; handlers require a client caller |
54
- | `actions-menu` | `ActionsMenu`, typed actions | Client boundary |
55
- | `modal`, `confirm-dialog` | `Modal`, `ConfirmDialog` | Client boundary |
56
-
57
- “Server-compatible” means the same component can be imported into a Server Component or ordinary client React code. It does not prohibit client use or imply a `server-only` dependency. Interactive entries preserve their own `"use client"` directives in the published modules. No page-wide client wrapper is required.
58
-
59
- `DataTable` renders native table markup. Supply `getRowKey` for stable row identity, `caption` for a visible accessible table name, and `columns` with cell render functions. Static cell render functions execute on the server. For row actions, prefer links/buttons in cells; optional `onRowClick` supports Enter/Space activation when used inside a client component. Optional `onRowIntent(row)` runs on pointer entry or focus within a row, allowing the application to prefetch details. These callbacks require a client caller; static tables add no row event handlers when the callbacks are omitted.
60
-
61
- `Pagination` renders real navigation links with `getPageHref={(page) => "/records?page=" + page}` and works without JavaScript. For local state, pass `onPageChange` from a client component instead. Page indexes start at zero; `pageSize` defaults to 20. Both components import only their own supporting styles through their matching CSS entry.
62
-
63
- `ThemeToggle` accepts `value` (`system`, `light`, or `dark`) and `onChange`; it does not read storage or change document attributes. `ColorPicker` accepts `value`, `onChange`, and a `colors` array of `{ value, label, disabled? }`. Its optional empty selection returns `null`; set `allowNone={false}` to omit it. These controls expose accessible labels/selection and never submit an enclosing form. The application owns persistence and its color palette.
64
-
65
- ## Notices, menus, and notifications
66
-
67
- `Notice` displays inline feedback with `tone="neutral"`, `"success"`, or `"danger"`. It accepts `heading`, decorative `icon`, `actions`, children, and native div attributes/ref. Static notices do not announce themselves. Choose `role="alert"` for an urgent form error or `role="status"` for a polite update when appropriate. Import `notice.css`.
68
-
69
- `ActionsMenu` accepts `items` with `label`, `onClick`, and optional `id`, `icon`, `disabled`, and `variant="danger"`. Give the trigger a contextual `ariaLabel`, such as "Actions for Alex". The default trigger uses Lucide Ellipsis; an optional `trigger` element must forward its ref and native button props. Keyboard navigation, typeahead, disabled-item skipping, collision handling, dismissal, and focus restoration use Radix Dropdown Menu. `open`/`onOpenChange` or `defaultOpen`, `align`, `sideOffset`, `collisionPadding`, `portalContainer`, and `theme` allow customization. Import `actions-menu.css`. Menus inherit tokens from their trigger region and coordinate Escape with shared dialogs.
70
-
71
- `Toast` and `ToastViewport` are presentation components with no notification store, provider, or timer. Pass `message`, `variant="success" | "error" | "info"`, optional `action`, `onDismiss`, and controlled `progress` (remaining fraction from 0 to 1). Import `toast.css`. Applications decide duration, queuing, persistence, and when to remove a notification. A timed host should pause expiry while hovered or while focus is within a toast. Pass native pointer/focus handlers to implement that policy. The message is announced separately from controls and the decorative progress ring. `announce` defaults to `"assertive"` for errors and `"polite"` otherwise; use `"off"` for non-announcing presentation. Use a meaningful `dismissLabel` when needed.
72
-
73
- Keep the viewport mounted when empty. For dynamically added notifications, pass `announcements={{ polite, assertive }}` with keyed message-only children, and use `announce="off"` on each visual Toast. This creates persistent live regions before additions arrive, while omitting action labels, progress changes, and removals from announcements. The app adapters demonstrate this pattern. The visual stack scrolls when it fills its available height; override `--bnh-toast-bottom`, `--bnh-toast-z`, or native styles for app chrome offsets.
74
-
75
- ## Dialogs
76
-
77
- ```tsx
78
- 'use client';
79
-
80
- import { useState, type ReactNode } from 'react';
81
- import { Button } from '@cosborn2/ui/button';
82
- import { Modal } from '@cosborn2/ui/modal';
83
- import '@cosborn2/ui/button.css';
84
- import '@cosborn2/ui/modal.css';
85
-
86
- export function DetailsDialog({ children }: { children: ReactNode }) {
87
- const [open, setOpen] = useState(false);
88
- return (
89
- <Modal
90
- open={open}
91
- onOpenChange={setOpen}
92
- title="Details"
93
- trigger={<Button type="button">Show details</Button>}
94
- >
95
- {children}
96
- </Modal>
97
- );
98
- }
99
- ```
100
-
101
- A Server Component can pass its rendered content as `children` to this client shell. Keep event handlers on the client side of the boundary.
102
-
103
- Modal uses Radix Dialog for focus containment, screen-reader behavior, dismissal, and scroll locking. Give it a `title` or descriptive `ariaLabel`. `persistent` prevents dismissal while an operation is pending. `width` accepts a number in pixels or a CSS width; `zIndex`, `headerActions`, `footer`, `className`, and `bodyClassName` customize layout.
104
-
105
- Portal content mounts after hydration, including when `open` starts true. The server and first browser render agree; dialog content is not promised in the initial server HTML. The trigger and surrounding server content render normally. No `ssr: false` is needed.
106
-
107
- Dialogs inherit `--bnh-*` tokens from their rendering location even when portaled into the document body. Use `theme="light"` / `theme="dark"` for an explicit choice, or `portalContainer` for a custom mount location. Theme attribute/style changes on ancestors are observed while open.
108
-
109
- `ConfirmDialog` adds cancel/confirm actions, optional loading state, and `typeToConfirm`. Its typed phrase resets when the dialog closes. Supply `children` for extra content such as a password field or verification notice, and `confirmDisabled` for application-owned prerequisites. Confirmation stays disabled while loading, while `confirmDisabled` is true, or until the typed phrase matches. The application owns validation and submission. Import `confirm-dialog.css`; it includes the button, input, and modal CSS it needs.
110
-
111
- ## Theme and overrides
112
-
113
- Dark is the default. Set `data-bnh-theme="light"` on the document or a region to use light mode. `data-bnh-theme="dark"`, `.bnh-theme-light`, `.bnh-theme-dark`, and the legacy document `.light` class are supported.
114
-
115
- ```css
116
- @import '@cosborn2/ui/theme.css';
117
- @import '@cosborn2/ui/button.css';
118
-
119
- :root {
120
- --bnh-font-sans: 'Your Sans', system-ui, sans-serif;
121
- --bnh-font-display: 'Your Display', Georgia, serif;
122
- --bnh-accent: #8b5cf6;
123
- }
124
- ```
125
-
126
- The apps own font loading, persistence, and system theme detection. The library downloads no fonts and installs no global reset. Colors, surfaces, radii, fonts, and header/page offsets are available as `--bnh-*` variables. The complete defaults are also exported as `@cosborn2/ui/tokens.json`.
127
-
128
- CSS uses the layer order `theme, base, components, utilities`. Host resets belong in `base`; utility overrides belong in `utilities`; ordinary unlayered CSS also overrides package component styles. Existing Tailwind v4 projects can keep their own utility classes; no package source scanning is needed. Each component accepts appropriate `className`/`style` overrides, without loading a utility-class merger.
129
-
130
- Settings layouts use `--bnh-page-offset` for a page-level banner and `--bnh-header-offset` for header placement. Applications supply those values; there is no impersonation or authentication dependency.
131
-
132
- ## Icons and dependencies
133
-
134
- Plain Button imports no icon or dialog code. Icons are passed as children or rendered slots. Components with built-in icons import only those glyphs. React and React DOM are peer dependencies; Radix Dialog, Radix Dropdown Menu, and the pinned Lucide release are runtime dependencies reachable only from components that use them.
135
-
136
- Lucide `0.577.0` is pinned to preserve server-compatible static icons. Current Lucide v1 uses client context internally. Upgrade only after the server-rendering and bundle fixtures pass; do not replace direct imports with an all-icons registry.
137
-
138
- Installing npm packages downloads their dependency distributions. Tree shaking controls the JS/CSS shipped to the browser, not which files npm downloads. The package tests report those sizes separately.
139
-
140
- ## Development and verification
141
-
142
- From the repository root:
5
+ Plain CSS, shared theme tokens, and individual component imports. Works without Tailwind.
143
6
 
144
7
  ```sh
145
- bun install --frozen-lockfile
146
- bun run lint
147
- bun run build
148
- bun run test
149
- bunx playwright install chromium
150
- bun run test:browser
8
+ npm install @cosborn2/ui
151
9
  ```
152
10
 
153
- The build emits separate ESM modules, declarations, and plain CSS. `dev` watches source and theme/style changes. The package fixtures install a packed tarball outside this repository and check Node SSR, production Next Server Components, browser hydration/accessibility, and compressed per-component JS/CSS budgets. Browser checks require Playwright Chromium and include the packed-package checks. Use `bun run test:package` when only the non-browser checks are needed.
154
-
155
- Edit `tokens.json` for canonical theme changes, then run `bun run build` to regenerate the packaged theme. Applications own any compatibility aliases or infrastructure pages that consume these tokens. The library does not read application styles during its build.
156
-
157
- ## Release
158
-
159
- Versions are chosen in reviewed PRs. With trusted publishing configured, version changes merged to `main` publish after validation; prereleases use `beta` and stable releases use `latest`. See the [publishing runbook](https://github.com/COsborn2/ui/blob/main/docs/publishing.md) for setup, release checks, and retries.
160
-
161
- The public npm package includes only `dist`, this README, the MIT license, and package metadata. Consumers adopt new versions through their own dependency updates.
11
+ [Component guide](https://github.com/COsborn2/ui/blob/main/docs/components.md) · [Versioning](https://github.com/COsborn2/ui/blob/main/versioning.md) · [Contributing](https://github.com/COsborn2/ui/blob/main/CONTRIBUTING.md)
162
12
 
163
- For development and review expectations, see [CONTRIBUTING.md](https://github.com/COsborn2/ui/blob/main/CONTRIBUTING.md). Report vulnerabilities through the private channel in [SECURITY.md](https://github.com/COsborn2/ui/blob/main/SECURITY.md).
13
+ MIT licensed. Requires React 19.
@@ -1,5 +1,5 @@
1
1
  @layer components {
2
- .bnh-ghost-text-button { box-sizing: border-box; cursor: pointer; border-radius: 6px; border: 0; background: transparent; padding: 6px; font-family: var(--bnh-font-sans, inherit); font-size: 13px; line-height: 1.5; color: var(--bnh-text-mute); transition: color 150ms; }
2
+ .bnh-ghost-text-button { box-sizing: border-box; cursor: pointer; border-radius: 6px; border: 0; background: transparent; padding: 6px; font-family: var(--bnh-font-sans, inherit); font-size: 13px; line-height: 1.5; color: var(--bnh-text-dim); transition: color 150ms; }
3
3
  .bnh-ghost-text-button:hover { color: var(--bnh-text); }
4
4
  .bnh-ghost-text-button:focus-visible { outline: 2px solid var(--bnh-accent); outline-offset: 2px; }
5
5
  .bnh-ghost-text-button:disabled { opacity: .4; cursor: not-allowed; }
@@ -6,6 +6,6 @@
6
6
  .bnh-segmented-control-item:disabled { opacity: .5; cursor: not-allowed; }
7
7
  .bnh-segmented-control-item:focus-visible { outline: 2px solid var(--bnh-accent); outline-offset: 2px; }
8
8
  .bnh-segmented-control-dot { width: 6px; height: 6px; border-radius: 50%; }
9
- .bnh-segmented-control-count { font-family: var(--bnh-font-mono, monospace); font-size: 10px; opacity: .7; }
9
+ .bnh-segmented-control-count { font-family: var(--bnh-font-mono, monospace); font-size: 10px; color: var(--bnh-text-dim); }
10
10
  @media (prefers-reduced-motion: reduce) { .bnh-segmented-control-item { transition: none; } }
11
11
  }
@@ -61,7 +61,7 @@
61
61
  }
62
62
  .bnh-settings-rail-group {
63
63
  font-size: 10px;
64
- color: var(--bnh-text-mute);
64
+ color: var(--bnh-text-dim);
65
65
  letter-spacing: 0.12em;
66
66
  text-transform: uppercase;
67
67
  padding: 16px 14px 6px;
@@ -257,7 +257,7 @@
257
257
  font-family: var(--bnh-font-mono, monospace);
258
258
  font-size: 11px;
259
259
  line-height: 1.5;
260
- color: var(--bnh-text-mute);
260
+ color: var(--bnh-text-dim);
261
261
  letter-spacing: 0.12em;
262
262
  text-transform: uppercase;
263
263
  }
@@ -311,7 +311,7 @@
311
311
  .bnh-settings-rail-badge {
312
312
  font-family: var(--bnh-font-mono, monospace);
313
313
  font-size: 10px;
314
- color: var(--bnh-text-mute);
314
+ color: var(--bnh-text-dim);
315
315
  padding: 1px 6px;
316
316
  border-radius: 999px;
317
317
  background: var(--bnh-surface);
@@ -357,7 +357,7 @@
357
357
  }
358
358
  .bnh-settings-row-hint {
359
359
  font-size: 11.5px;
360
- color: var(--bnh-text-mute);
360
+ color: var(--bnh-text-dim);
361
361
  margin-top: 2px;
362
362
  line-height: 1.45;
363
363
  }
@@ -9,6 +9,6 @@
9
9
  .bnh-switch-input:disabled ~ span { opacity: .5; cursor: not-allowed; }
10
10
  .bnh-switch-copy { display: flex; flex-direction: column; gap: 2px; }
11
11
  .bnh-switch-label { font-size: 13px; font-weight: 500; line-height: 1.5; color: var(--bnh-text); }
12
- .bnh-switch-description { font-size: 11.5px; line-height: 1.45; color: var(--bnh-text-mute); }
12
+ .bnh-switch-description { font-size: 11.5px; line-height: 1.45; color: var(--bnh-text-dim); }
13
13
  @media (prefers-reduced-motion: reduce) { .bnh-switch-track, .bnh-switch-track::after { transition: none; } }
14
14
  }
@@ -63,14 +63,14 @@
63
63
  --bnh-accent: #7c3aed;
64
64
  --bnh-input-focus: color-mix(in oklch, var(--bnh-accent) 55%, transparent);
65
65
  --bnh-input-focus-ring: color-mix(in oklch, var(--bnh-accent) 20%, transparent);
66
- --bnh-green: #16a34a;
66
+ --bnh-green: #166534;
67
67
  --bnh-amber: #d97706;
68
68
  --bnh-violet: #7c3aed;
69
69
  --bnh-blue: #2563eb;
70
- --bnh-red: #e11d48;
70
+ --bnh-red: #9f1239;
71
71
  --bnh-orange: #ea580c;
72
- --bnh-link: #64748b;
73
- --bnh-primary: #7c6540;
72
+ --bnh-link: #475569;
73
+ --bnh-primary: #76603d;
74
74
  --bnh-primary-hover: #6b5636;
75
75
  --bnh-glass-shadow: 0 1px 0 rgba(255,255,255,.9) inset, 0 -1px 0 rgba(0,0,0,.04) inset, 0 12px 40px rgba(30,20,60,.1), 0 2px 8px rgba(30,20,60,.06);
76
76
  --bnh-popover-shadow: 0 1px 0 rgba(255,255,255,.9) inset, 0 -1px 0 rgba(0,0,0,.05) inset, 0 16px 50px rgba(30,20,60,.15), 0 3px 10px rgba(30,20,60,.08);
package/dist/tokens.json CHANGED
@@ -61,14 +61,14 @@
61
61
  "accent": "#7c3aed",
62
62
  "input-focus": "color-mix(in oklch, var(--bnh-accent) 55%, transparent)",
63
63
  "input-focus-ring": "color-mix(in oklch, var(--bnh-accent) 20%, transparent)",
64
- "green": "#16a34a",
64
+ "green": "#166534",
65
65
  "amber": "#d97706",
66
66
  "violet": "#7c3aed",
67
67
  "blue": "#2563eb",
68
- "red": "#e11d48",
68
+ "red": "#9f1239",
69
69
  "orange": "#ea580c",
70
- "link": "#64748b",
71
- "primary": "#7c6540",
70
+ "link": "#475569",
71
+ "primary": "#76603d",
72
72
  "primary-hover": "#6b5636",
73
73
  "radius-sm": "6px",
74
74
  "radius-md": "10px",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cosborn2/ui",
3
- "version": "0.1.0-beta.0",
4
- "description": "Lightweight React components and settings layouts with granular CSS and server-compatible primitives.",
3
+ "version": "0.2.0",
4
+ "description": "Lightweight React UI components.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "publishConfig": {
@@ -146,41 +146,62 @@
146
146
  "./toast.css": "./dist/styles/toast.css"
147
147
  },
148
148
  "scripts": {
149
- "build": "tsc -p tsconfig.json && bun scripts/build-css.ts",
149
+ "build": "tsc -p tsconfig.json && bun run build:styles",
150
+ "build:styles": "bun scripts/build-css.ts",
150
151
  "dev": "bun scripts/watch.ts",
152
+ "storybook": "bun run build:styles && storybook dev -p 6006",
153
+ "build-storybook": "bun run build:styles && storybook build --disable-telemetry",
151
154
  "lint": "eslint . && bun run typecheck",
152
- "test": "bun test tests/*.test.ts*",
153
- "test:package": "bun scripts/verify-package.ts",
154
- "test:browser": "bun scripts/verify-browser.ts",
155
+ "test": "bun run build:styles && vitest run",
156
+ "test:unit": "vitest run --project unit",
157
+ "test:stories": "bun run build:styles && vitest run --project storybook",
158
+ "check:package": "bun scripts/check-package.ts",
155
159
  "prepack": "bun run build",
156
160
  "prepublishOnly": "bun scripts/check-release.ts",
157
- "typecheck": "tsc --noEmit -p tsconfig.json && tsc -p tsconfig.tools.json"
161
+ "typecheck": "tsc --noEmit -p tsconfig.json && tsc -p tsconfig.tools.json",
162
+ "release:preview": "bun scripts/release.ts --dry-run"
158
163
  },
159
164
  "peerDependencies": {
160
165
  "react": "^19.0.0",
161
166
  "react-dom": "^19.0.0"
162
167
  },
163
168
  "dependencies": {
164
- "@radix-ui/react-dialog": "1.1.20",
165
- "lucide-react": "0.577.0",
166
- "@radix-ui/react-dropdown-menu": "2.1.21"
169
+ "@radix-ui/react-dialog": "1.3.1",
170
+ "@radix-ui/react-dropdown-menu": "2.2.1",
171
+ "lucide-react": "0.577.0"
167
172
  },
168
173
  "devDependencies": {
169
- "react": "19.3.0",
170
- "react-dom": "19.3.0",
174
+ "@storybook/addon-a11y": "10.6.3",
175
+ "@storybook/addon-docs": "10.6.3",
176
+ "@storybook/addon-vitest": "10.6.3",
177
+ "@storybook/react-vite": "10.6.3",
178
+ "@testing-library/jest-dom": "^6.10.0",
179
+ "@testing-library/react": "^16.3.3",
180
+ "@testing-library/user-event": "^14.6.8",
181
+ "@types/bun": "^1.4.4",
182
+ "@types/node": "^26.6.5",
171
183
  "@types/react": "^19.3.0",
172
184
  "@types/react-dom": "^19.3.0",
173
- "@types/node": "^26.3.0",
174
- "@types/bun": "^1.4.0",
185
+ "@types/semver": "7.8.0",
186
+ "@vitejs/plugin-react": "^5.2.0",
187
+ "@vitest/browser-playwright": "4.1.12",
188
+ "@vitest/coverage-v8": "4.1.12",
189
+ "eslint": "^9.39.5",
190
+ "jsdom": "^30.1.3",
191
+ "playwright": "1.64.1",
192
+ "react": "19.3.1",
193
+ "react-dom": "19.3.1",
194
+ "release-it": "21.1.1",
195
+ "semver": "7.8.5",
196
+ "storybook": "10.6.3",
175
197
  "typescript": "^6.0.3",
176
- "esbuild": "^0.25.0",
177
- "lightningcss": "^1.30.0",
178
- "@playwright/test": "^1.55.0",
179
- "next": "16.3.5",
180
- "@tailwindcss/postcss": "4.3.3",
181
- "tailwindcss": "4.3.3",
182
- "eslint": "^9.39.4",
183
- "typescript-eslint": "^8.70.1"
198
+ "typescript-eslint": "^8.72.0",
199
+ "vite": "^7.3.7",
200
+ "vitest": "4.1.12"
184
201
  },
185
- "packageManager": "bun@1.3.10"
202
+ "packageManager": "bun@1.3.10",
203
+ "overrides": {
204
+ "basic-ftp": "^6.2.3",
205
+ "source-map-js": "^1.2.2"
206
+ }
186
207
  }