@aircall/ds 0.18.0 → 0.21.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/dist/globals.css +1 -1
- package/dist/index.d.ts +510 -8
- package/dist/index.js +832 -37
- package/dist/theme.css +1 -1
- package/package.json +3 -2
- package/skills/aircall-ds/adopt-attachment/SKILL.md +283 -0
- package/skills/aircall-ds/migrate-audio-player/SKILL.md +438 -0
- package/skills/aircall-ds/migrate-tractor/SKILL.md +1 -1
- package/skills/aircall-ds/migrate-tractor/data-table/SKILL.md +47 -1
- package/skills/aircall-ds/migrate-tractor/dropzone/SKILL.md +33 -0
package/dist/theme.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */
|
|
2
|
-
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0}}}@property --tw-animation-delay{syntax:"*";inherits:false;initial-value:0s}@property --tw-animation-direction{syntax:"*";inherits:false;initial-value:normal}@property --tw-animation-duration{syntax:"*";inherits:false}@property --tw-animation-fill-mode{syntax:"*";inherits:false;initial-value:none}@property --tw-animation-iteration-count{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-blur{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-opacity{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-rotate{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-scale{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-blur{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-opacity{syntax:"*";inherits:false;initial-value:1}@property --tw-exit-rotate{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-scale{syntax:"*";inherits:false;initial-value:1}@property --tw-exit-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-translate-y{syntax:"*";inherits:false;initial-value:0}:root,:host{--color-charcoal-50:#f6fafc;--color-charcoal-300:#b0c4d1;--color-charcoal-700:#3a5362;--color-charcoal-900:#132c3b;--color-neutral-50:#f8f9fc;--color-neutral-100:#f0f2f6;--color-neutral-200:#e4e6ea;--color-neutral-400:#a4a6aa;--color-neutral-500:#7e8084;--color-neutral-600:#64666a;--color-neutral-700:#4b4d51;--color-neutral-800:#36383c;--color-neutral-900:#24262a;--color-neutral-950:#0b0d11;--color-red-50:#fff7f5;--color-red-400:#ff7256;--color-red-600:#db391a;--color-red-950:#420b00;--color-yellow-50:#fffcf3;--color-yellow-400:#f3ad26;--color-yellow-500:#d68100;--color-yellow-700:#8f5600;--color-yellow-950:#2f1c00;--color-green-50:#f4fffb;--color-green-400:#37cd8e;--color-green-500:#13a96a;--color-green-600:#00884f;--color-green-700:#006a3d;--color-green-950:#002817;--color-blue-50:#f5faff;--color-blue-400:#70b1ff;--color-blue-500:#388ef6;--color-blue-600:#1e74dc;--color-blue-700:#055bc3;--color-blue-950:#001f45;--color-purple-600:#6551d6;--color-purple-700:#4c38bd;--color-pink-500:#eb5e7c;--color-pink-600:#cf4260;--font-sans:"Fellix",sans-serif}.ds-emoji-picker .EmojiPickerReact,.ds-emoji-picker .EmojiPickerReact.epr-dark-theme{--epr-emoji-size:24px;--epr-category-navigation-button-size:24px;--epr-header-padding:calc(var(--spacing)*2)calc(var(--spacing)*2);--epr-category-label-height:calc(var(--spacing)*8);--epr-bg-color:var(--popover);--epr-category-label-bg-color:var(--popover);--epr-picker-border-color:var(--border);--epr-search-input-bg-color:var(--muted);--epr-search-input-bg-color-active:var(--muted);--epr-search-border-color:var(--ring);--epr-category-icon-active-color:var(--primary);font-family:var(--font-sans)}.ds-emoji-picker .EmojiPickerReact *{font-family:inherit}.ds-emoji-picker .EmojiPickerReact .epr-emoji-category>.epr-emoji-category-label{font-weight:400}.ds-emoji-picker .EmojiPickerReact .epr-category-nav>button.epr-cat-btn:focus:before{content:none}@keyframes caret-blink{0%,70%,to{opacity:1}20%,50%{opacity:0}}@keyframes badge-glow{0%,to{filter:drop-shadow(0 0 2px var(--badge-glow))}50%{filter:drop-shadow(0 0 5px var(--badge-glow))}}@layer theme{:root,:host{--background:#fff;--foreground:var(--color-neutral-950);--card:#fff;--card-foreground:var(--color-neutral-950);--popover:#fff;--popover-foreground:var(--color-neutral-950);--primary:var(--color-green-600);--primary-foreground:#fff;--secondary:var(--color-charcoal-700);--secondary-foreground:var(--color-charcoal-50);--info:var(--color-blue-500);--info-foreground:var(--color-blue-700);--info-background:var(--color-blue-50);--success:var(--color-green-500);--success-foreground:var(--color-green-700);--success-background:var(--color-green-50);--warning:var(--color-yellow-500);--warning-foreground:var(--color-yellow-700);--warning-background:var(--color-yellow-50);--muted:var(--color-neutral-100);--muted-foreground:var(--color-neutral-600);--accent:var(--color-neutral-100);--accent-foreground:var(--color-neutral-900);--destructive:var(--color-red-600);--destructive-foreground:var(--color-red-50);--destructive-background:var(--color-red-50);--border:var(--color-neutral-200);--input:var(--color-neutral-200);--ring:var(--color-neutral-400);--chart-1:var(--color-green-600);--chart-2:var(--color-blue-600);--chart-3:var(--color-purple-700);--chart-4:var(--color-yellow-400);--chart-5:var(--color-pink-500);--radius:.625rem;--sidebar:#fff;--sidebar-foreground:var(--color-neutral-800);--sidebar-primary:var(--color-green-600);--sidebar-primary-foreground:#fff;--sidebar-accent:var(--color-neutral-100);--sidebar-accent-foreground:var(--color-neutral-900);--sidebar-border:var(--color-neutral-200);--sidebar-ring:var(--color-neutral-400);--badge-film-10:#ffffff1a;--badge-film-40:#fff6;--badge-film-60:#fff9;--badge-film-80:#fffc}[data-theme=dark],[data-theme=dark] *{--background:var(--color-neutral-950);--foreground:var(--color-neutral-50);--card:var(--color-neutral-900);--card-foreground:var(--color-neutral-50);--popover:var(--color-neutral-800);--popover-foreground:var(--color-neutral-50);--primary:var(--color-green-500);--primary-foreground:var(--color-neutral-950);--secondary:var(--color-charcoal-300);--secondary-foreground:var(--color-charcoal-900);--info:var(--color-blue-500);--info-foreground:var(--color-blue-400);--info-background:var(--color-blue-950);--success:var(--color-green-500);--success-foreground:var(--color-green-400);--success-background:var(--color-green-950);--warning:var(--color-yellow-500);--warning-foreground:var(--color-yellow-400);--warning-background:var(--color-yellow-950);--muted:var(--color-neutral-800);--muted-foreground:var(--color-neutral-400);--accent:var(--color-neutral-700);--accent-foreground:var(--color-neutral-50);--destructive:var(--color-red-400);--destructive-foreground:var(--color-red-50);--destructive-background:var(--color-red-950);--border:oklch(100% 0 0/.1);--input:oklch(100% 0 0/.15);--ring:var(--color-neutral-500);--chart-1:var(--color-green-500);--chart-2:var(--color-blue-500);--chart-3:var(--color-purple-600);--chart-4:var(--color-yellow-500);--chart-5:var(--color-pink-600);--sidebar:var(--color-neutral-900);--sidebar-foreground:var(--color-neutral-50);--sidebar-primary:var(--color-green-500);--sidebar-primary-foreground:#fff;--sidebar-accent:var(--color-neutral-800);--sidebar-accent-foreground:var(--color-neutral-50);--sidebar-border:oklch(100% 0 0/.1);--sidebar-ring:var(--color-neutral-600);--badge-film-10:#0a0a0a1a;--badge-film-40:#0a0a0a66;--badge-film-60:#0a0a0a99;--badge-film-80:#0a0a0acc}}
|
|
2
|
+
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){:root,:host{--shimmer-angle:20deg}*,:before,:after,::backdrop{--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0;--scroll-fade-s:0px;--scroll-fade-e:0px;--scroll-fade-mask:initial;--shimmer-image:initial;--shimmer-text-fill:initial}}}@property --tw-animation-delay{syntax:"*";inherits:false;initial-value:0s}@property --tw-animation-direction{syntax:"*";inherits:false;initial-value:normal}@property --tw-animation-duration{syntax:"*";inherits:false}@property --tw-animation-fill-mode{syntax:"*";inherits:false;initial-value:none}@property --tw-animation-iteration-count{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-blur{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-opacity{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-rotate{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-scale{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-blur{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-opacity{syntax:"*";inherits:false;initial-value:1}@property --tw-exit-rotate{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-scale{syntax:"*";inherits:false;initial-value:1}@property --tw-exit-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-translate-y{syntax:"*";inherits:false;initial-value:0}:root,:host{--color-charcoal-50:#f6fafc;--color-charcoal-300:#b0c4d1;--color-charcoal-700:#3a5362;--color-charcoal-900:#132c3b;--color-neutral-50:#f8f9fc;--color-neutral-100:#f0f2f6;--color-neutral-200:#e4e6ea;--color-neutral-400:#a4a6aa;--color-neutral-500:#7e8084;--color-neutral-600:#64666a;--color-neutral-700:#4b4d51;--color-neutral-800:#36383c;--color-neutral-900:#24262a;--color-neutral-950:#0b0d11;--color-red-50:#fff7f5;--color-red-400:#ff7256;--color-red-600:#db391a;--color-red-950:#420b00;--color-yellow-50:#fffcf3;--color-yellow-400:#f3ad26;--color-yellow-500:#d68100;--color-yellow-700:#8f5600;--color-yellow-950:#2f1c00;--color-green-50:#f4fffb;--color-green-400:#37cd8e;--color-green-500:#13a96a;--color-green-600:#00884f;--color-green-700:#006a3d;--color-green-950:#002817;--color-blue-50:#f5faff;--color-blue-400:#70b1ff;--color-blue-500:#388ef6;--color-blue-600:#1e74dc;--color-blue-700:#055bc3;--color-blue-950:#001f45;--color-purple-600:#6551d6;--color-purple-700:#4c38bd;--color-pink-500:#eb5e7c;--color-pink-600:#cf4260;--font-sans:"Fellix",sans-serif}.ds-emoji-picker .EmojiPickerReact,.ds-emoji-picker .EmojiPickerReact.epr-dark-theme{--epr-emoji-size:24px;--epr-category-navigation-button-size:24px;--epr-header-padding:calc(var(--spacing)*2)calc(var(--spacing)*2);--epr-category-label-height:calc(var(--spacing)*8);--epr-bg-color:var(--popover);--epr-category-label-bg-color:var(--popover);--epr-picker-border-color:var(--border);--epr-search-input-bg-color:var(--muted);--epr-search-input-bg-color-active:var(--muted);--epr-search-border-color:var(--ring);--epr-category-icon-active-color:var(--primary);font-family:var(--font-sans)}.ds-emoji-picker .EmojiPickerReact *{font-family:inherit}.ds-emoji-picker .EmojiPickerReact .epr-emoji-category>.epr-emoji-category-label{font-weight:400}.ds-emoji-picker .EmojiPickerReact .epr-category-nav>button.epr-cat-btn:focus:before{content:none}@keyframes caret-blink{0%,70%,to{opacity:1}20%,50%{opacity:0}}@keyframes badge-glow{0%,to{filter:drop-shadow(0 0 2px var(--badge-glow))}50%{filter:drop-shadow(0 0 5px var(--badge-glow))}}@layer theme{:root,:host{--background:#fff;--foreground:var(--color-neutral-950);--card:#fff;--card-foreground:var(--color-neutral-950);--popover:#fff;--popover-foreground:var(--color-neutral-950);--primary:var(--color-green-600);--primary-foreground:#fff;--secondary:var(--color-charcoal-700);--secondary-foreground:var(--color-charcoal-50);--info:var(--color-blue-500);--info-foreground:var(--color-blue-700);--info-background:var(--color-blue-50);--success:var(--color-green-500);--success-foreground:var(--color-green-700);--success-background:var(--color-green-50);--warning:var(--color-yellow-500);--warning-foreground:var(--color-yellow-700);--warning-background:var(--color-yellow-50);--muted:var(--color-neutral-100);--muted-foreground:var(--color-neutral-600);--accent:var(--color-neutral-100);--accent-foreground:var(--color-neutral-900);--destructive:var(--color-red-600);--destructive-foreground:var(--color-red-50);--destructive-background:var(--color-red-50);--border:var(--color-neutral-200);--input:var(--color-neutral-200);--ring:var(--color-neutral-400);--chart-1:var(--color-green-600);--chart-2:var(--color-blue-600);--chart-3:var(--color-purple-700);--chart-4:var(--color-yellow-400);--chart-5:var(--color-pink-500);--radius:.625rem;--sidebar:#fff;--sidebar-foreground:var(--color-neutral-800);--sidebar-primary:var(--color-green-600);--sidebar-primary-foreground:#fff;--sidebar-accent:var(--color-neutral-100);--sidebar-accent-foreground:var(--color-neutral-900);--sidebar-border:var(--color-neutral-200);--sidebar-ring:var(--color-neutral-400);--badge-film-10:#ffffff1a;--badge-film-40:#fff6;--badge-film-60:#fff9;--badge-film-80:#fffc}[data-theme=dark],[data-theme=dark] *{--background:var(--color-neutral-950);--foreground:var(--color-neutral-50);--card:var(--color-neutral-900);--card-foreground:var(--color-neutral-50);--popover:var(--color-neutral-800);--popover-foreground:var(--color-neutral-50);--primary:var(--color-green-500);--primary-foreground:var(--color-neutral-950);--secondary:var(--color-charcoal-300);--secondary-foreground:var(--color-charcoal-900);--info:var(--color-blue-500);--info-foreground:var(--color-blue-400);--info-background:var(--color-blue-950);--success:var(--color-green-500);--success-foreground:var(--color-green-400);--success-background:var(--color-green-950);--warning:var(--color-yellow-500);--warning-foreground:var(--color-yellow-400);--warning-background:var(--color-yellow-950);--muted:var(--color-neutral-800);--muted-foreground:var(--color-neutral-400);--accent:var(--color-neutral-700);--accent-foreground:var(--color-neutral-50);--destructive:var(--color-red-400);--destructive-foreground:var(--color-red-50);--destructive-background:var(--color-red-950);--border:oklch(100% 0 0/.1);--input:oklch(100% 0 0/.15);--ring:var(--color-neutral-500);--chart-1:var(--color-green-500);--chart-2:var(--color-blue-500);--chart-3:var(--color-purple-600);--chart-4:var(--color-yellow-500);--chart-5:var(--color-pink-600);--sidebar:var(--color-neutral-900);--sidebar-foreground:var(--color-neutral-50);--sidebar-primary:var(--color-green-500);--sidebar-primary-foreground:#fff;--sidebar-accent:var(--color-neutral-800);--sidebar-accent-foreground:var(--color-neutral-50);--sidebar-border:oklch(100% 0 0/.1);--sidebar-ring:var(--color-neutral-600);--badge-film-10:#0a0a0a1a;--badge-film-40:#0a0a0a66;--badge-film-60:#0a0a0a99;--badge-film-80:#0a0a0acc}}@property --scroll-fade-s{syntax:"<length-percentage>";inherits:false;initial-value:0}@property --scroll-fade-e{syntax:"<length-percentage>";inherits:false;initial-value:0}@property --scroll-fade-mask{syntax:"*";inherits:false}@property --shimmer-angle{syntax:"<angle>";inherits:true;initial-value:20deg}@property --shimmer-image{syntax:"*";inherits:false}@property --shimmer-text-fill{syntax:"*";inherits:false}@media (prefers-reduced-motion:reduce){.shimmer{-webkit-text-fill-color:currentColor;background-image:none;animation:none}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aircall/ds",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": [
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"@base-ui/react": "1.3.0",
|
|
56
56
|
"@headless-tree/core": "1.7.0",
|
|
57
57
|
"@headless-tree/react": "1.7.0",
|
|
58
|
+
"@tanstack/react-virtual": "3.13.12",
|
|
58
59
|
"class-variance-authority": "0.7.1",
|
|
59
60
|
"clsx": "2.1.1",
|
|
60
61
|
"cmdk": "1.1.1",
|
|
@@ -129,7 +130,7 @@
|
|
|
129
130
|
"sb:test": "vitest --project=storybook",
|
|
130
131
|
"sb:build:chromatic": "storybook build --test --stats-json",
|
|
131
132
|
"chromatic": "chromatic --storybook-build-dir=./storybook-static",
|
|
132
|
-
"typecheck": "tsc --noEmit -p tsconfig.typecheck.json"
|
|
133
|
+
"typecheck": "tsc --noEmit -p tsconfig.typecheck.json && tsc --noEmit -p tsconfig.strict.json"
|
|
133
134
|
},
|
|
134
135
|
"types": "./dist/index.d.ts",
|
|
135
136
|
"module": "./dist/index.js",
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: aircall-ds/adopt-attachment
|
|
3
|
+
description: >
|
|
4
|
+
Adopt the @aircall/ds Attachment component to display file and image
|
|
5
|
+
attachments (upload state, metadata, actions). Load when a file renders
|
|
6
|
+
uploaded-file rows/cards/chips by hand (a div with a file icon, name, size
|
|
7
|
+
and a remove button), builds an attachment strip, or shows upload progress
|
|
8
|
+
for a picked file. There is no @aircall/tractor predecessor - this is a
|
|
9
|
+
net-new primitive, so the skill is an adoption recipe, not a tractor rename.
|
|
10
|
+
Pairs with aircall-ds/migrate-tractor/dropzone (Dropzone selects files,
|
|
11
|
+
Attachment renders them).
|
|
12
|
+
type: sub-skill
|
|
13
|
+
library: aircall-ds
|
|
14
|
+
library_version: "0.20.0"
|
|
15
|
+
requires:
|
|
16
|
+
- aircall-ds/setup
|
|
17
|
+
sources:
|
|
18
|
+
- "aircall/hydra:packages/ds/src/components/attachment.tsx"
|
|
19
|
+
- "aircall/hydra:packages/ds/src/stories/Attachment.stories.tsx"
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# Adopting @aircall/ds Attachment
|
|
23
|
+
|
|
24
|
+
`Attachment` renders a single file or image attachment with its metadata,
|
|
25
|
+
upload state, and actions. It is **presentational** — it does not pick, upload,
|
|
26
|
+
or store files. Pair it with `Dropzone` or a file input for selection (see
|
|
27
|
+
`aircall-ds/migrate-tractor/dropzone`). There is no Tractor equivalent; this
|
|
28
|
+
skill replaces hand-rolled attachment markup.
|
|
29
|
+
|
|
30
|
+
## 1. Import
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import {
|
|
34
|
+
Attachment,
|
|
35
|
+
AttachmentMedia,
|
|
36
|
+
AttachmentContent,
|
|
37
|
+
AttachmentTitle,
|
|
38
|
+
AttachmentDescription,
|
|
39
|
+
AttachmentActions,
|
|
40
|
+
AttachmentAction,
|
|
41
|
+
AttachmentTrigger,
|
|
42
|
+
AttachmentGroup,
|
|
43
|
+
type AttachmentState,
|
|
44
|
+
} from '@aircall/ds';
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Never import sub-paths (`@aircall/ds/components/attachment`) — use the root barrel.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 2. Anatomy
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
AttachmentGroup // optional: scrollable, snapping row of cards
|
|
55
|
+
└── Attachment // one card — owns state / size / orientation
|
|
56
|
+
├── AttachmentMedia // leading icon (variant="icon") or thumbnail (variant="image")
|
|
57
|
+
├── AttachmentContent
|
|
58
|
+
│ ├── AttachmentTitle // file name (shimmers while uploading/processing)
|
|
59
|
+
│ └── AttachmentDescription // type / size / status
|
|
60
|
+
├── AttachmentActions
|
|
61
|
+
│ └── AttachmentAction // remove / retry / download (wraps DS Button)
|
|
62
|
+
└── AttachmentTrigger // optional full-card overlay (open / preview)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
| Part | Renders | Key props |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| `Attachment` | `div` | `state` (`idle`/`uploading`/`processing`/`error`/`done`, default `done`), `size` (`default`/`sm`/`xs`), `orientation` (`horizontal`/`vertical`) |
|
|
68
|
+
| `AttachmentMedia` | `div` | `variant` (`icon` default / `image`) |
|
|
69
|
+
| `AttachmentContent` | `div` | — |
|
|
70
|
+
| `AttachmentTitle` | `span` | — |
|
|
71
|
+
| `AttachmentDescription` | `span` | — |
|
|
72
|
+
| `AttachmentActions` | `div` | — |
|
|
73
|
+
| `AttachmentAction` | DS `Button` | defaults `variant="ghost"`, `size="icon-sm"`; forward any `Button` prop |
|
|
74
|
+
| `AttachmentTrigger` | `button` (or `render`) | `render` to substitute an element (e.g. an anchor) |
|
|
75
|
+
| `AttachmentGroup` | `div` | — |
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 3. State drives the visuals
|
|
80
|
+
|
|
81
|
+
Set `state` on the root `Attachment` — the children react automatically:
|
|
82
|
+
|
|
83
|
+
| `state` | Card | Title | Media / meta | Typical media child |
|
|
84
|
+
|---|---|---|---|---|
|
|
85
|
+
| `idle` | dashed border | normal | — | clock / file icon |
|
|
86
|
+
| `uploading` | normal | **shimmers** | show `Uploading · 64%` | `<Spinner />` |
|
|
87
|
+
| `processing` | normal | **shimmers** | show `Processing…` | `<Spinner />` |
|
|
88
|
+
| `error` | destructive border/bg | normal | destructive text | warning icon |
|
|
89
|
+
| `done` | resting | normal | — | file icon / `<Check />` |
|
|
90
|
+
|
|
91
|
+
You don't toggle child classes — only `state` on the root.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 4. Pattern picker
|
|
96
|
+
|
|
97
|
+
| Need | Use |
|
|
98
|
+
|---|---|
|
|
99
|
+
| One file row with a remove button | `Attachment` (horizontal) + `AttachmentAction` |
|
|
100
|
+
| Uniform-width rows in a list | wrap each with `className="w-full"` in a fixed-width column |
|
|
101
|
+
| A scrollable strip of thumbnails | `AttachmentGroup` + `Attachment orientation="vertical"` |
|
|
102
|
+
| Whole card opens a preview/link | add `AttachmentTrigger render={<a … />}` |
|
|
103
|
+
| Compact chips (e.g. in a composer) | `Attachment size="xs"` inside an `AttachmentGroup` |
|
|
104
|
+
| Files come from drag-and-drop | `Dropzone` `onFiles` → map to `Attachment` (see §6) |
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 5. Replacing hand-rolled attachment markup
|
|
109
|
+
|
|
110
|
+
Consumers typically hand-roll a flex row with an icon, name, size, and a
|
|
111
|
+
remove button. Map it straight onto the anatomy.
|
|
112
|
+
|
|
113
|
+
**Before (hand-rolled):**
|
|
114
|
+
```tsx
|
|
115
|
+
<div className="flex items-center gap-3 rounded border p-3">
|
|
116
|
+
<FileTextIcon className="size-4" />
|
|
117
|
+
<div className="flex-1 min-w-0">
|
|
118
|
+
<p className="truncate font-medium">{file.name}</p>
|
|
119
|
+
<p className="text-xs text-muted-foreground">{formatSize(file.size)}</p>
|
|
120
|
+
</div>
|
|
121
|
+
<button aria-label={`Remove ${file.name}`} onClick={() => onRemove(file)}>
|
|
122
|
+
<XIcon />
|
|
123
|
+
</button>
|
|
124
|
+
</div>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**After (DS):**
|
|
128
|
+
```tsx
|
|
129
|
+
import { FileText, X } from '@aircall/react-icons';
|
|
130
|
+
|
|
131
|
+
<Attachment className="w-full">
|
|
132
|
+
<AttachmentMedia>
|
|
133
|
+
<FileText />
|
|
134
|
+
</AttachmentMedia>
|
|
135
|
+
<AttachmentContent>
|
|
136
|
+
<AttachmentTitle>{file.name}</AttachmentTitle>
|
|
137
|
+
<AttachmentDescription>{formatSize(file.size)}</AttachmentDescription>
|
|
138
|
+
</AttachmentContent>
|
|
139
|
+
<AttachmentActions>
|
|
140
|
+
<AttachmentAction aria-label={`Remove ${file.name}`} onClick={() => onRemove(file)}>
|
|
141
|
+
<X />
|
|
142
|
+
</AttachmentAction>
|
|
143
|
+
</AttachmentActions>
|
|
144
|
+
</Attachment>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
- Icons come from `@aircall/react-icons`, never `lucide-react` directly.
|
|
148
|
+
- Sizing/padding is owned by `size` — drop the `p-3`/`gap-3`/`text-xs` classes.
|
|
149
|
+
- `className="w-full"` makes cards uniform width in a list (the root defaults to `w-fit`).
|
|
150
|
+
|
|
151
|
+
### Upload progress
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
<Attachment state={isUploading ? 'uploading' : error ? 'error' : 'done'} className="w-full">
|
|
155
|
+
<AttachmentMedia>{isUploading ? <Spinner /> : error ? <FileWarning /> : <FileText />}</AttachmentMedia>
|
|
156
|
+
<AttachmentContent>
|
|
157
|
+
<AttachmentTitle>{file.name}</AttachmentTitle>
|
|
158
|
+
<AttachmentDescription>
|
|
159
|
+
{isUploading ? `Uploading · ${pct}%` : error ? 'Upload failed. Try again.' : formatSize(file.size)}
|
|
160
|
+
</AttachmentDescription>
|
|
161
|
+
</AttachmentContent>
|
|
162
|
+
<AttachmentActions>
|
|
163
|
+
{error && <AttachmentAction aria-label="Retry"><RefreshCw /></AttachmentAction>}
|
|
164
|
+
<AttachmentAction aria-label={`Remove ${file.name}`} onClick={() => onRemove(file)}><X /></AttachmentAction>
|
|
165
|
+
</AttachmentActions>
|
|
166
|
+
</Attachment>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Image thumbnails as a scrollable group
|
|
170
|
+
|
|
171
|
+
```tsx
|
|
172
|
+
<AttachmentGroup className="w-full">
|
|
173
|
+
{images.map(image => (
|
|
174
|
+
<Attachment key={image.name} orientation="vertical">
|
|
175
|
+
<AttachmentMedia variant="image">
|
|
176
|
+
<img src={image.src} alt="" />
|
|
177
|
+
</AttachmentMedia>
|
|
178
|
+
<AttachmentContent>
|
|
179
|
+
<AttachmentTitle>{image.name}</AttachmentTitle>
|
|
180
|
+
<AttachmentDescription>{image.meta}</AttachmentDescription>
|
|
181
|
+
</AttachmentContent>
|
|
182
|
+
<AttachmentActions>
|
|
183
|
+
<AttachmentAction aria-label={`Remove ${image.name}`}><X /></AttachmentAction>
|
|
184
|
+
</AttachmentActions>
|
|
185
|
+
<AttachmentTrigger aria-label={`Open ${image.name}`} render={<a href={image.src} target="_blank" rel="noreferrer" />} />
|
|
186
|
+
</Attachment>
|
|
187
|
+
))}
|
|
188
|
+
</AttachmentGroup>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 6. Pairing with Dropzone (drop-to-attach)
|
|
194
|
+
|
|
195
|
+
`Dropzone` owns selection; `Attachment` renders the result. They stay decoupled.
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
199
|
+
|
|
200
|
+
<Dropzone accept="image/*,application/pdf" multiple onFiles={f => setFiles(prev => [...prev, ...f])}>
|
|
201
|
+
<DropzoneContent>
|
|
202
|
+
<DropzoneIcon><Paperclip /></DropzoneIcon>
|
|
203
|
+
<DropzoneTitle>Drop files to attach</DropzoneTitle>
|
|
204
|
+
<DropzoneActions><DropzoneTrigger>Browse files</DropzoneTrigger></DropzoneActions>
|
|
205
|
+
</DropzoneContent>
|
|
206
|
+
</Dropzone>
|
|
207
|
+
|
|
208
|
+
{files.length > 0 && (
|
|
209
|
+
<AttachmentGroup className="mt-3 w-full">
|
|
210
|
+
{files.map((file, i) => (
|
|
211
|
+
<Attachment key={i} orientation="vertical">
|
|
212
|
+
<AttachmentMedia><FileText /></AttachmentMedia>
|
|
213
|
+
<AttachmentContent>
|
|
214
|
+
<AttachmentTitle>{file.name}</AttachmentTitle>
|
|
215
|
+
<AttachmentDescription>{formatSize(file.size)}</AttachmentDescription>
|
|
216
|
+
</AttachmentContent>
|
|
217
|
+
<AttachmentActions>
|
|
218
|
+
<AttachmentAction aria-label={`Remove ${file.name}`} onClick={() => setFiles(prev => prev.filter((_, j) => j !== i))}><X /></AttachmentAction>
|
|
219
|
+
</AttachmentActions>
|
|
220
|
+
</Attachment>
|
|
221
|
+
))}
|
|
222
|
+
</AttachmentGroup>
|
|
223
|
+
)}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Inside a composer, put the `AttachmentGroup` in an `InputGroupAddon align="block-start"`
|
|
227
|
+
with `size="xs"` chips, and the Paperclip `DropzoneTrigger` + Send in a
|
|
228
|
+
`block-end` addon (see the `In Textarea Composer` story).
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## 7. Common mistakes
|
|
233
|
+
|
|
234
|
+
### Mistake 1 — Icon-only action with no `aria-label`
|
|
235
|
+
`AttachmentAction` renders an icon-only `Button`. Without a label it's
|
|
236
|
+
inaccessible and fails the a11y check.
|
|
237
|
+
|
|
238
|
+
❌ Wrong
|
|
239
|
+
```tsx
|
|
240
|
+
<AttachmentAction><X /></AttachmentAction>
|
|
241
|
+
```
|
|
242
|
+
✅ Correct
|
|
243
|
+
```tsx
|
|
244
|
+
<AttachmentAction aria-label={`Remove ${file.name}`}><X /></AttachmentAction>
|
|
245
|
+
```
|
|
246
|
+
Source: `packages/ds/src/components/attachment.tsx` (AttachmentAction).
|
|
247
|
+
|
|
248
|
+
### Mistake 2 — Passing `size="icon-xs"` to `AttachmentAction`
|
|
249
|
+
The DS `Button` has no `icon-xs` size (that's a shadcn base-nova size). The
|
|
250
|
+
smallest DS icon size is `icon-sm` (also 24px) and is already the default.
|
|
251
|
+
|
|
252
|
+
❌ Wrong: `<AttachmentAction size="icon-xs">` → invalid Button size.
|
|
253
|
+
✅ Correct: omit `size` (defaults to `icon-sm`), or pass `icon-sm`.
|
|
254
|
+
Source: `packages/ds/src/components/button.tsx` (size variants).
|
|
255
|
+
|
|
256
|
+
### Mistake 3 — Full-card trigger swallows the action clicks
|
|
257
|
+
Put clickable controls inside `AttachmentActions` (z-20) so they sit above the
|
|
258
|
+
`AttachmentTrigger` overlay (z-10). A raw button placed elsewhere gets covered.
|
|
259
|
+
|
|
260
|
+
❌ Wrong: `<AttachmentTrigger />` + a loose `<button>` sibling.
|
|
261
|
+
✅ Correct: actions live in `<AttachmentActions>`; `<AttachmentTrigger>` is the only full-card layer.
|
|
262
|
+
Source: `packages/ds/src/components/attachment.tsx` (AttachmentActions z-20 / AttachmentTrigger z-10).
|
|
263
|
+
|
|
264
|
+
### Mistake 4 — `variant="image"` without an `<img>` child
|
|
265
|
+
The image variant styles a direct `img` child (`*:[img]`). Passing an icon or a
|
|
266
|
+
background div won't cover-fit.
|
|
267
|
+
|
|
268
|
+
❌ Wrong: `<AttachmentMedia variant="image"><Icon /></AttachmentMedia>`
|
|
269
|
+
✅ Correct: `<AttachmentMedia variant="image"><img src={src} alt="" /></AttachmentMedia>`
|
|
270
|
+
Source: `packages/ds/src/components/attachment.tsx` (attachmentMediaVariants image).
|
|
271
|
+
|
|
272
|
+
### Mistake 5 — Expecting the shimmer without setting `state`
|
|
273
|
+
The title only shimmers when the root `state` is `uploading` or `processing`.
|
|
274
|
+
Setting a spinner in the media alone does nothing to the title.
|
|
275
|
+
|
|
276
|
+
❌ Wrong: `<Attachment><AttachmentMedia><Spinner /></AttachmentMedia>…`
|
|
277
|
+
✅ Correct: `<Attachment state="uploading">…`
|
|
278
|
+
Source: `packages/ds/src/components/attachment.tsx` (AttachmentTitle group-data-[state=uploading]:shimmer).
|
|
279
|
+
|
|
280
|
+
### Mistake 6 — Vertical actions expected inline
|
|
281
|
+
In `orientation="vertical"`, `AttachmentActions` floats to the top-right corner
|
|
282
|
+
of the tile (not inline after the content). This is intended for thumbnails.
|
|
283
|
+
Source: `packages/ds/src/components/attachment.tsx` (AttachmentActions vertical branch).
|