@aircall/ds 0.2.7 → 0.6.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 +95 -11
- package/dist/globals.css +1 -1
- package/dist/index.d.ts +762 -376
- package/dist/index.js +1545 -731
- package/package.json +31 -31
package/README.md
CHANGED
|
@@ -40,6 +40,21 @@ pnpm add @aircall/ds
|
|
|
40
40
|
pnpm add react react-dom @aircall/icons @aircall/numbers
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
+
**Optional peer dependencies (install only if you use these components):**
|
|
44
|
+
|
|
45
|
+
| Component | Packages to install |
|
|
46
|
+
|-----------|-------------------|
|
|
47
|
+
| `Calendar` | `react-day-picker`, `date-fns` |
|
|
48
|
+
| `DataTable` | `@tanstack/react-table` |
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# If using Calendar
|
|
52
|
+
pnpm add react-day-picker date-fns
|
|
53
|
+
|
|
54
|
+
# If using DataTable
|
|
55
|
+
pnpm add @tanstack/react-table
|
|
56
|
+
```
|
|
57
|
+
|
|
43
58
|
## Usage
|
|
44
59
|
|
|
45
60
|
### Import Components
|
|
@@ -134,7 +149,7 @@ Versatile button component with multiple variants, colors, sizes, and shapes.
|
|
|
134
149
|
- `shape`: 'default' | 'square' | 'circle'
|
|
135
150
|
- `readOnly`: boolean
|
|
136
151
|
- `block`: boolean (full width)
|
|
137
|
-
- `
|
|
152
|
+
- `render`: ReactElement — render Button as a different element (e.g. `<a>`). Replaces the former `asChild` / Slot pattern.
|
|
138
153
|
|
|
139
154
|
**Examples:**
|
|
140
155
|
|
|
@@ -162,10 +177,8 @@ Versatile button component with multiple variants, colors, sizes, and shapes.
|
|
|
162
177
|
// Destructive button
|
|
163
178
|
<Button color="destructive">Delete</Button>
|
|
164
179
|
|
|
165
|
-
// Link as button
|
|
166
|
-
<Button
|
|
167
|
-
<a href="/profile">Go to Profile</a>
|
|
168
|
-
</Button>
|
|
180
|
+
// Link rendered as a button — use the `render` prop
|
|
181
|
+
<Button render={<a href="/profile" />}>Go to Profile</Button>
|
|
169
182
|
```
|
|
170
183
|
|
|
171
184
|
## Storybook
|
|
@@ -194,10 +207,11 @@ View at: http://localhost:6008
|
|
|
194
207
|
### Building Storybook
|
|
195
208
|
|
|
196
209
|
```bash
|
|
197
|
-
pnpm sb:build
|
|
210
|
+
pnpm sb:build # plain build — no recipe registry
|
|
211
|
+
pnpm sb:build:deploy # full build including the recipe registry (what CI deploys)
|
|
198
212
|
```
|
|
199
213
|
|
|
200
|
-
Static site output: `storybook-static
|
|
214
|
+
Static site output: `storybook-static/`. See [Recipes (shadcn Registry)](#recipes-shadcn-registry) below for when to use each.
|
|
201
215
|
|
|
202
216
|
## Development
|
|
203
217
|
|
|
@@ -214,7 +228,7 @@ pnpm add <component-name>
|
|
|
214
228
|
|
|
215
229
|
```
|
|
216
230
|
src/
|
|
217
|
-
├── components/ # React components
|
|
231
|
+
├── components/ # React components (published to npm)
|
|
218
232
|
│ └── button/
|
|
219
233
|
│ ├── __stories__/
|
|
220
234
|
│ │ └── Button.stories.tsx
|
|
@@ -226,6 +240,10 @@ src/
|
|
|
226
240
|
│ └── utils.ts # cn() helper for class merging
|
|
227
241
|
├── hooks/ # Custom React hooks
|
|
228
242
|
└── fonts/ # Fellix Aircall font files
|
|
243
|
+
├── recipes/ # shadcn registry recipes (copy-paste patterns)
|
|
244
|
+
│ ├── combobox-searchable-select.tsx
|
|
245
|
+
│ ├── combobox-dropdown-search.tsx
|
|
246
|
+
│ └── combobox-multi-select.tsx
|
|
229
247
|
```
|
|
230
248
|
|
|
231
249
|
### Styling System
|
|
@@ -271,6 +289,64 @@ The design system uses CSS variables with OKLch color space for better color per
|
|
|
271
289
|
|
|
272
290
|
Colors automatically adapt when `data-theme="dark"` is set on the root element.
|
|
273
291
|
|
|
292
|
+
## Recipes (shadcn Registry)
|
|
293
|
+
|
|
294
|
+
Recipes are pre-built, copy-paste component patterns built on top of `@aircall/ds` primitives. They are distributed via the [shadcn registry](https://ui.shadcn.com/docs/registry) — consumers run `shadcn add` to install a recipe into their project, and they own the code afterwards. They can customize it freely.
|
|
295
|
+
|
|
296
|
+
> Note: in the shadcn registry schema these items are typed `registry:block` — that's a shadcn enum value, not our terminology. Internally we call them "recipes".
|
|
297
|
+
|
|
298
|
+
### What is the Registry?
|
|
299
|
+
|
|
300
|
+
The registry is a set of JSON files that describe each recipe — its name, description, npm dependencies, and full source code. These JSON files are generated by `shadcn build` and served as static files alongside the DS Storybook.
|
|
301
|
+
|
|
302
|
+
**How it works:**
|
|
303
|
+
|
|
304
|
+
1. Recipe source files live in `src/recipes/` using relative imports (`../components/combobox`)
|
|
305
|
+
2. `pnpm run registry:build` copies the recipes, rewrites imports to `@aircall/ds`, runs `shadcn build`, and outputs JSON files to `public/r/`
|
|
306
|
+
3. Storybook serves `public/` as static files via `staticDirs` config
|
|
307
|
+
4. A consumer runs `shadcn add <url>` — the CLI fetches the JSON, extracts the source code, and writes it into their project with `@aircall/ds` imports
|
|
308
|
+
|
|
309
|
+
### Local Development
|
|
310
|
+
|
|
311
|
+
Run `pnpm run registry:build` before starting Storybook to generate the JSON files. Then start Storybook:
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
pnpm run registry:build
|
|
315
|
+
pnpm run sb:dev
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
The recipe JSON files are served at `http://localhost:6008/r/<name>.json`. You can test the full consumer flow locally:
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
pnpm dlx shadcn@latest add http://localhost:6008/r/combobox-searchable-select.json
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### Production (Published Storybook)
|
|
325
|
+
|
|
326
|
+
When the DS Storybook is deployed to `ds.aircall.io`, the same JSON files are served at the public URL. Consumers install recipes with:
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
pnpm dlx shadcn@latest add https://ds.aircall.io/r/combobox-searchable-select.json
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
The deployment CI job runs `pnpm sb:build:ds` at the repo root, which maps to `sb:build:deploy` inside this package. That script runs `registry:build` first, then `storybook build` — Storybook's `staticDirs: ['../public']` config picks up `public/r/` and copies it into `storybook-static/r/` so the JSON files ship alongside the deployed Storybook. **`sb:build` on its own does NOT bundle the registry** — use `sb:build:deploy` (or `pnpm sb:build:ds` at the root) whenever you need the registry included.
|
|
333
|
+
|
|
334
|
+
### Available Recipes
|
|
335
|
+
|
|
336
|
+
| Recipe | Description |
|
|
337
|
+
|---|---|
|
|
338
|
+
| `combobox-searchable-select` | Single-select combobox — input acts as trigger and search filter |
|
|
339
|
+
| `combobox-dropdown-search` | Button-triggered combobox with search inside dropdown |
|
|
340
|
+
| `combobox-multi-select` | Multi-select with inline chips and type-ahead filtering |
|
|
341
|
+
|
|
342
|
+
### Adding a New Recipe
|
|
343
|
+
|
|
344
|
+
1. Create `src/recipes/<name>.tsx` — import primitives from `../components/`
|
|
345
|
+
2. Add an entry to `registry.json` at the package root
|
|
346
|
+
3. Add a story in `src/stories/` that imports from the recipe
|
|
347
|
+
4. Run `pnpm run registry:build` to generate JSON in `public/r/`
|
|
348
|
+
5. Verify at `http://localhost:6008/r/<name>.json` after starting Storybook
|
|
349
|
+
|
|
274
350
|
## Scripts
|
|
275
351
|
|
|
276
352
|
```bash
|
|
@@ -283,12 +359,20 @@ pnpm build:package # Build both JS and CSS for publishing
|
|
|
283
359
|
pnpm build:js # Build JavaScript bundle only
|
|
284
360
|
pnpm build:css # Build pre-compiled CSS only
|
|
285
361
|
|
|
362
|
+
# Registry
|
|
363
|
+
pnpm registry:build # Generate recipe JSON files in public/r/
|
|
364
|
+
# (rewrites relative imports to @aircall/ds)
|
|
365
|
+
|
|
366
|
+
# Storybook — three distinct builds
|
|
367
|
+
pnpm sb:build # Plain Storybook build. NO registry JSON.
|
|
368
|
+
pnpm sb:build:chromatic # Storybook build for Chromatic (--test --stats-json). NO registry JSON.
|
|
369
|
+
pnpm sb:build:deploy # Full deployment build: runs registry:build, builds Storybook,
|
|
370
|
+
# and copies public/r into storybook-static/r/.
|
|
371
|
+
# This is what CI runs (via `pnpm sb:build:ds` at the repo root).
|
|
372
|
+
|
|
286
373
|
# Testing Package Locally
|
|
287
374
|
pnpm pack # Create tarball for local testing
|
|
288
375
|
|
|
289
|
-
# Storybook
|
|
290
|
-
pnpm sb:build # Build static Storybook site
|
|
291
|
-
|
|
292
376
|
# Component Management
|
|
293
377
|
pnpm add <component> # Add new shadcn component
|
|
294
378
|
|