@aircall/ds 0.49.0 → 0.50.2
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/{data-table-B3ahtFLP.js → data-table-AX0Mgu6K.js} +5 -0
- package/dist/{data-table-BgeS8KWP.d.ts → data-table-B5VqWPmw.d.ts} +3 -4
- package/dist/data-table.d.ts +1 -1
- package/dist/data-table.js +1 -1
- package/dist/globals.css +1 -1
- package/dist/index.d.ts +53 -16
- package/dist/index.js +113 -20
- package/package.json +2 -2
- package/skills/aircall-ds/migrate-audio-player/SKILL.md +14 -3
- package/skills/aircall-ds/migrate-icons/SKILL.md +45 -16
- package/skills/aircall-ds/migrate-tractor/SKILL.md +34 -31
- package/skills/aircall-ds/migrate-tractor/accordion/SKILL.md +25 -15
- package/skills/aircall-ds/migrate-tractor/alert/SKILL.md +107 -20
- package/skills/aircall-ds/migrate-tractor/avatar/SKILL.md +57 -26
- package/skills/aircall-ds/migrate-tractor/badge/SKILL.md +71 -25
- package/skills/aircall-ds/migrate-tractor/button/SKILL.md +68 -32
- package/skills/aircall-ds/migrate-tractor/card/SKILL.md +62 -42
- package/skills/aircall-ds/migrate-tractor/combobox/SKILL.md +233 -149
- package/skills/aircall-ds/migrate-tractor/data-table/SKILL.md +102 -108
- package/skills/aircall-ds/migrate-tractor/data-table/references/column-widths-and-pinning.md +50 -0
- package/skills/aircall-ds/migrate-tractor/data-table/references/infinite-scroll.md +51 -0
- package/skills/aircall-ds/migrate-tractor/data-table/references/row-actions.md +34 -0
- package/skills/aircall-ds/migrate-tractor/date-picker/SKILL.md +100 -47
- package/skills/aircall-ds/migrate-tractor/dialog/SKILL.md +115 -20
- package/skills/aircall-ds/migrate-tractor/dropdown-menu/SKILL.md +135 -57
- package/skills/aircall-ds/migrate-tractor/dropzone/SKILL.md +2 -0
- package/skills/aircall-ds/migrate-tractor/form-and-field/SKILL.md +111 -49
- package/skills/aircall-ds/migrate-tractor/gauge/SKILL.md +6 -4
- package/skills/aircall-ds/migrate-tractor/input/SKILL.md +165 -59
- package/skills/aircall-ds/migrate-tractor/item/SKILL.md +85 -63
- package/skills/aircall-ds/migrate-tractor/link/SKILL.md +85 -68
- package/skills/aircall-ds/migrate-tractor/popover/SKILL.md +115 -74
- package/skills/aircall-ds/migrate-tractor/select/SKILL.md +117 -64
- package/skills/aircall-ds/migrate-tractor/sheet-vs-drawer/SKILL.md +55 -32
- package/skills/aircall-ds/migrate-tractor/skeleton/SKILL.md +40 -11
- package/skills/aircall-ds/migrate-tractor/styling/SKILL.md +11 -7
- package/skills/aircall-ds/migrate-tractor/tabs/SKILL.md +62 -55
- package/skills/aircall-ds/migrate-tractor/toast/SKILL.md +58 -12
- package/skills/aircall-ds/migrate-tractor/tooltip/SKILL.md +65 -40
- package/skills/aircall-ds/migrate-tractor/tree/SKILL.md +23 -6
- package/skills/aircall-ds/setup/SKILL.md +53 -8
|
@@ -1,78 +1,128 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: aircall-ds/migrate-tractor/date-picker
|
|
3
3
|
description: >
|
|
4
|
-
Migrate Tractor DatePicker (
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
Migrate Tractor DatePicker (inline calendar, `{ startDate, endDate }` value) and the
|
|
5
|
+
@dashboard/library DateSelect (dropdown trigger + calendar + predefined ranges) to the
|
|
6
|
+
@aircall/ds DatePicker (single and range modes), the ds Calendar, or the blocks
|
|
7
|
+
DateRangeCalendar. Also covers migrating ad-hoc day-of-week toggle rows to the
|
|
8
|
+
@aircall/blocks DaysPicker.
|
|
7
9
|
type: recipe
|
|
8
10
|
library: aircall-ds
|
|
9
|
-
library_version: "0.22.0"
|
|
10
11
|
requires:
|
|
12
|
+
- aircall-ds/setup
|
|
11
13
|
- aircall-ds/migrate-tractor
|
|
14
|
+
sources:
|
|
15
|
+
- "aircall/hydra:packages/ds/src/components/date-picker.tsx"
|
|
16
|
+
- "aircall/hydra:packages/ds/src/components/calendar.tsx"
|
|
17
|
+
- "aircall/hydra:packages/ds/src/stories/DatePicker.stories.tsx"
|
|
18
|
+
- "aircall/hydra:packages/blocks/src/components/days-picker.tsx"
|
|
19
|
+
- "aircall/hydra:packages/blocks/src/components/date-range-calendar.tsx"
|
|
20
|
+
- "aircall/hydra:packages/tractor/src/components/DatePicker/DatePicker.decl.ts"
|
|
12
21
|
---
|
|
13
22
|
|
|
14
23
|
# Migrating DatePicker / DateSelect / DaysPicker
|
|
15
24
|
|
|
16
|
-
##
|
|
25
|
+
## What the legacy components actually are
|
|
26
|
+
|
|
27
|
+
- **Tractor `DatePicker`** is an **inline calendar grid** (no input, no popover, no `label`). Props: `value`/`defaultValue: { startDate: Date | null; endDate: Date | null }`, `onChange(value)`, `mode` (**default `'range'`**; `'single'` returns `{ startDate, endDate: null }`), `numberOfMonths`, `initialDate`, `minDate`, `maxDate`, `isDateDisabled(day)`, `calendarDirection`, `transitionTime`, `locale` (string), `data-test`.
|
|
28
|
+
- **`@dashboard/library` `DateSelect`** is a `Dropdown` with an input-like trigger (shows a formatted label, optional clear button) that opens a Tractor `DatePicker` plus an optional list of predefined ranges. Props: `value`/`defaultValue: { startDate, endDate, rangeValue? }`, `onChange`, `ranges: { label, startDate, endDate, rangeValue? }[]`, `footer`, `allowRemove`, `onClear`, `onOpen`/`onClose`, `placeholder`, `w`/`maxW`, plus the DatePicker props.
|
|
29
|
+
|
|
30
|
+
Pick the DS target by what the old code *rendered*:
|
|
31
|
+
|
|
32
|
+
| Old usage | New component |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| `DateSelect` trigger + dropdown (single date or range, form field) | `DatePicker` from `@aircall/ds` (`mode="single"` default, or `mode="range"`) |
|
|
35
|
+
| `DateSelect` with shortcut `ranges` | `DatePicker mode="range"` + `predefinedRanges` |
|
|
36
|
+
| Tractor `DatePicker` rendered inline on the page (no trigger) | `Calendar` from `@aircall/ds` (react-day-picker props: `mode`, `selected`, `onSelect`) |
|
|
37
|
+
| Dashboard filter: calendar with Today / Yesterday / This week … chips | `DateRangeCalendar` from `@aircall/blocks` (value `{ from, to, shortcut? } \| null`, `onChange`) |
|
|
38
|
+
| Hand-rolled Mon–Sun toggle buttons | `DaysPicker` from `@aircall/blocks` |
|
|
39
|
+
|
|
40
|
+
## Tractor DatePicker / DateSelect (single) -> DS DatePicker (single mode)
|
|
17
41
|
|
|
18
42
|
```tsx
|
|
19
|
-
// Before (
|
|
20
|
-
import {
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
43
|
+
// Before (@dashboard/library)
|
|
44
|
+
import { DateSelect } from '@dashboard/library';
|
|
45
|
+
<DateSelect
|
|
46
|
+
mode="single"
|
|
47
|
+
value={{ startDate: date, endDate: null }}
|
|
48
|
+
onChange={v => setDate(v.startDate ?? undefined)}
|
|
49
|
+
minDate={today}
|
|
26
50
|
/>
|
|
27
51
|
|
|
28
52
|
// After (DS)
|
|
29
|
-
import { DatePicker,
|
|
53
|
+
import { DatePicker, Field, FieldLabel } from '@aircall/ds';
|
|
30
54
|
<Field>
|
|
31
55
|
<FieldLabel htmlFor="appointment-date">Appointment date</FieldLabel>
|
|
32
56
|
<DatePicker
|
|
33
57
|
id="appointment-date"
|
|
34
58
|
value={date}
|
|
35
59
|
onValueChange={setDate}
|
|
60
|
+
minDate={today}
|
|
36
61
|
disabled={isLoading}
|
|
62
|
+
triggerClassName="max-w-xs"
|
|
37
63
|
/>
|
|
38
64
|
</Field>
|
|
39
65
|
```
|
|
40
66
|
|
|
41
|
-
**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
49
|
-
|
|
50
|
-
|
|
67
|
+
`DatePicker` renders its own wrapper `Field`; the label above is an ordinary `FieldLabel` whose `htmlFor` targets the `id` forwarded to the **first segment**. Width: the picker is `w-full`; constrain it with `triggerClassName`.
|
|
68
|
+
|
|
69
|
+
**Key prop mapping:**
|
|
70
|
+
| Legacy | DS |
|
|
71
|
+
| --- | --- |
|
|
72
|
+
| `value: { startDate, endDate }` | `value: Date` (single) or `value: DateRange` (`{ from, to? }`, range) |
|
|
73
|
+
| `onChange(value)` | `onValueChange(date: Date \| undefined)` (single), `onRangeChange(range, meta)` (range) |
|
|
74
|
+
| `mode` default `'range'` | `mode` default **`'single'`** — set `mode="range"` explicitly when migrating a range picker |
|
|
75
|
+
| `defaultValue` | `defaultValue` (same shape change as `value`) |
|
|
76
|
+
| `minDate` / `maxDate` (a month bound) | `minDate` / `maxDate` (inclusive **day** bounds; defaults 1900-01-01 / 2100-12-31) |
|
|
77
|
+
| `isDateDisabled(day)` | `disabledDates` (a `Matcher`: predicate, `Date`, `Date[]`, `{ before }`, `{ after }`, `{ from, to }`, `{ dayOfWeek }`) |
|
|
78
|
+
| `locale="fr-FR"` (string) | `locale` is a react-day-picker `Locale` object (e.g. `fr` from `react-day-picker/locale`); omit it to follow the DS i18n language |
|
|
79
|
+
| `onOpen` / `onClose` (DateSelect) | `open` / `onOpenChange` |
|
|
80
|
+
| `placeholder`, `allowRemove`, `onClear`, `w`, `maxW`, `footer` | no `placeholder`/`allowRemove`/`onClear`; clear by emptying the segments (emits `undefined`); width via `triggerClassName`; `footer` is kept (rendered under the calendar) |
|
|
81
|
+
| `numberOfMonths`, `initialDate`, `calendarDirection`, `transitionTime`, `daySize` | removed — single mode shows 1 month, range shows 2; the calendar opens on the selected value's month (or today) |
|
|
82
|
+
| `validationStatus="error"` (on the surrounding `FormItem`) | `invalid` on `DatePicker` (+ your own `FieldError`) |
|
|
83
|
+
| `data-test` | `data-test` (default `date-picker-input`; range adds `data-test-to`, default `date-picker-input-to`) |
|
|
84
|
+
| — | `name`: renders hidden input(s) with `yyyy-MM-dd` local-date strings (range adds `${name}-to`) |
|
|
85
|
+
|
|
86
|
+
Emitted dates are at **local midnight**. `date.toISOString()` can shift the calendar day for users east of UTC; for date-only payloads use `format(date, 'yyyy-MM-dd')` (date-fns).
|
|
87
|
+
|
|
88
|
+
## DateSelect (range + predefined shortcuts) -> DS DatePicker (range mode)
|
|
51
89
|
|
|
52
90
|
```tsx
|
|
53
|
-
// Before (
|
|
54
|
-
import { DateSelect } from '@
|
|
91
|
+
// Before (@dashboard/library)
|
|
92
|
+
import { DateSelect } from '@dashboard/library';
|
|
55
93
|
<DateSelect
|
|
56
|
-
value={
|
|
57
|
-
onChange={setRange}
|
|
58
|
-
|
|
59
|
-
{ label: 'Last 7 days',
|
|
94
|
+
value={{ startDate, endDate, rangeValue }}
|
|
95
|
+
onChange={v => setRange(v)}
|
|
96
|
+
ranges={[
|
|
97
|
+
{ label: 'Last 7 days', rangeValue: 'last-7', startDate: subDays(today, 7), endDate: today }
|
|
60
98
|
]}
|
|
61
99
|
/>
|
|
62
100
|
|
|
63
101
|
// After (DS)
|
|
64
|
-
import { DatePicker } from '@aircall/ds';
|
|
102
|
+
import { DatePicker, type DateRange } from '@aircall/ds';
|
|
65
103
|
<DatePicker
|
|
66
104
|
mode="range"
|
|
67
105
|
value={range}
|
|
68
|
-
onRangeChange={(r, { matchedRangeId }) =>
|
|
106
|
+
onRangeChange={(r, { matchedRangeId }) => {
|
|
107
|
+
setRange(r);
|
|
108
|
+
setRangeId(matchedRangeId); // replaces the legacy `rangeValue`
|
|
109
|
+
}}
|
|
69
110
|
predefinedRanges={[
|
|
70
|
-
{ label: 'Last 7 days', from: subDays(today, 7), to: today
|
|
111
|
+
{ id: 'last-7', label: 'Last 7 days', from: subDays(today, 7), to: today }
|
|
71
112
|
]}
|
|
72
113
|
/>
|
|
73
114
|
```
|
|
74
115
|
|
|
75
|
-
|
|
116
|
+
- `range` is `DateRange | undefined` (`{ from: Date | undefined; to?: Date }`); `startDate`/`endDate` -> `from`/`to`, `endDate: null` -> `to` omitted.
|
|
117
|
+
- Predefined range `rangeValue` -> `id`; the legacy `rangeValue` on the *value* has no counterpart. `meta.matchedRangeId` is set only when the picked range equals a predefined range exactly (both ends by timestamp), so persist it yourself if you need it.
|
|
118
|
+
- Typing a complete "from" emits `{ from }` immediately; a "to" typed while "from" is empty is held back and emitted together with "from" once it is complete.
|
|
119
|
+
- The segmented input shows raw per-segment values; there is no formatted trigger-label string, so no label algorithm is reproduced from `DateSelect`.
|
|
120
|
+
- Pass a stable `predefinedRanges` array and compute `from`/`to` at local midnight, or the exact-match check will not light up the shortcut.
|
|
121
|
+
|
|
122
|
+
## Inline calendar and dashboard filters
|
|
123
|
+
|
|
124
|
+
- Tractor `DatePicker` used inline (no trigger): `import { Calendar } from '@aircall/ds'` then `<Calendar mode="range" selected={range} onSelect={setRange} numberOfMonths={2} />` (`DateRange` shape `{ from, to }`; `disabled` takes the same matchers as `disabledDates`; `captionLayout="dropdown"` for month/year selects).
|
|
125
|
+
- A dashboard filter with Today / Yesterday / This week / Last week / This month / Last month / Last six months chips is `DateRangeCalendar` from `@aircall/blocks`, not a hand-built `DatePicker`: `<DateRangeCalendar value={range} onChange={setRange} />` with `range: { from: Date; to: Date; shortcut?: string } | null`. `from` is the start of its day (00:00:00.000). `to` is the inclusive end of its day (23:59:59.999) for calendar picks and every shortcut except `last_week`, which deliberately ends at 00:00 on its Sunday to match `conversation-center-ext` (see `date-range-shortcuts.ts`). `shortcuts` narrows, reorders or extends the chips.
|
|
76
126
|
|
|
77
127
|
## Ad-hoc day-of-week toggles -> DaysPicker
|
|
78
128
|
|
|
@@ -100,35 +150,36 @@ import { DaysPicker, type DayOfWeek } from '@aircall/blocks';
|
|
|
100
150
|
```
|
|
101
151
|
|
|
102
152
|
**Key differences:**
|
|
103
|
-
- `DaysPicker` is in `@aircall/blocks`, NOT `@aircall/ds`. Import from `@aircall/blocks`.
|
|
104
|
-
- Visible
|
|
105
|
-
i18n instance (en/fr/es/de/it). There are no `labels` or `ariaLabels` override props.
|
|
153
|
+
- `DaysPicker` is in `@aircall/blocks`, NOT `@aircall/ds`. Import from `@aircall/blocks`. It is built on the ds `ToggleGroup` (always multi-select) and accepts the remaining `ToggleGroup` props (e.g. `variant`, `size`, `className`).
|
|
154
|
+
- Visible labels and full-name aria-labels are derived from the blocks/DS i18n (en/fr/es/de/it). There are no `labels` or `ariaLabels` override props. `labelFormat="letter"` (default) shows a single letter; `labelFormat="short"` shows the locale's own abbreviation via `Intl` ("Mon", "lun.", "Mo"). The `aria-label` is the full day name either way.
|
|
106
155
|
- Order is fixed Mon->Sun. Consumer cannot reorder.
|
|
107
156
|
- `onValueChange` receives the full updated `DayOfWeek[]` list.
|
|
108
|
-
- `value`
|
|
157
|
+
- `value` / `defaultValue` are `DayOfWeek[]` (`'mon' | 'tue' | … | 'sun'`, not `string[]`). `DayOfWeek` is exported from `@aircall/blocks`.
|
|
158
|
+
- `disabled` disables all seven toggles; `dataTestPrefix` (default `days-picker`) yields `data-test="${dataTestPrefix}-mon"` etc.
|
|
109
159
|
|
|
110
160
|
## DS DatePicker input model
|
|
111
161
|
|
|
112
162
|
The DS DatePicker is a SEGMENTED date input: day, month, and year are separate
|
|
113
163
|
editable fields (each rendered as `role="spinbutton"`). Segment focus is
|
|
114
164
|
type-only -- the Calendar does NOT open on focus. The calendar opens via the
|
|
115
|
-
calendar icon button (right side of the input group
|
|
116
|
-
segment is focused. On open,
|
|
117
|
-
or day pick), focus returns to
|
|
118
|
-
|
|
165
|
+
calendar icon button (right side of the input group, `aria-label="Choose date"` /
|
|
166
|
+
`"Choose date range"`) or Alt+ArrowDown while any segment is focused. On open,
|
|
167
|
+
focus moves into the calendar grid; on close (Escape or day pick), focus returns to
|
|
168
|
+
the icon button (trap-focus). There is NO `variant` prop and NO separate readonly
|
|
169
|
+
or typeable mode -- there is a single segmented input, and no `readOnly` prop
|
|
170
|
+
(`disabled` is the only non-interactive state).
|
|
119
171
|
|
|
120
172
|
Segment order is derived from the locale (e.g. MM/DD/YYYY in en-US, DD/MM/YYYY
|
|
121
|
-
in fr-FR).
|
|
122
|
-
|
|
173
|
+
in fr-FR). There is no `dateFormat` prop; locale (the `locale` prop, else the DS
|
|
174
|
+
i18n language) is the only thing that decides segment order.
|
|
123
175
|
|
|
124
176
|
The `placeholder` prop is also not supported: each segment self-labels with a
|
|
125
177
|
locale-derived placeholder (`dd`, `mm`, `yyyy`). Remove any `placeholder` prop
|
|
126
178
|
from migrated code.
|
|
127
179
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
choice in the DS API.
|
|
180
|
+
`invalid` is never set by the component -- the consumer owns the error state. When
|
|
181
|
+
`invalid` is true, `data-invalid` lands on the picker's Field and `aria-invalid` on
|
|
182
|
+
every segment, and the transient out-of-bounds hints below are suppressed.
|
|
132
183
|
|
|
133
184
|
## minDate / maxDate -- selection bounds
|
|
134
185
|
|
|
@@ -141,6 +192,7 @@ choice in the DS API.
|
|
|
141
192
|
only on the completed date.
|
|
142
193
|
- `aria-valuemin`/`aria-valuemax` on the year segment still reflect the bounds for
|
|
143
194
|
screen-reader affordance.
|
|
195
|
+
- For a scheduling picker that disallows past dates pass `minDate={new Date()}`.
|
|
144
196
|
|
|
145
197
|
## disabledDates -- full RDP Matcher support
|
|
146
198
|
|
|
@@ -155,3 +207,4 @@ choice in the DS API.
|
|
|
155
207
|
|
|
156
208
|
The same constraint is enforced identically for typed input and calendar clicks.
|
|
157
209
|
Typed disabled dates revert to the last committed value with a "not available" hint.
|
|
210
|
+
In range mode only the range **endpoints** are blocked by `disabledDates`: a disabled day strictly inside the selected range is allowed (it is greyed but the emitted `{ from, to }` is the literal pair of endpoints), so filter interior disabled days yourself if they matter.
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
name: aircall-ds/migrate-tractor/dialog
|
|
3
3
|
description: >
|
|
4
4
|
Migrate Tractor Modal (ModalDialog, ModalHeader, ModalTitle, ModalBody,
|
|
5
|
-
ModalFooter) to the @aircall/ds Dialog compound
|
|
6
|
-
|
|
5
|
+
ModalFooter) to the @aircall/ds Dialog compound, and @dashboard/library
|
|
6
|
+
ConfirmationModal to AlertDialog. Load when a file imports Modal* from
|
|
7
|
+
@aircall/tractor or ConfirmationModal from @dashboard/library.
|
|
7
8
|
type: sub-skill
|
|
8
9
|
library: aircall-ds
|
|
9
10
|
requires:
|
|
@@ -11,6 +12,10 @@ requires:
|
|
|
11
12
|
- aircall-ds/migrate-tractor
|
|
12
13
|
sources:
|
|
13
14
|
- "aircall/hydra:docs/migration-guides/tractor-to-ds/recipes/dialog.md"
|
|
15
|
+
- "aircall/hydra:packages/ds/src/components/dialog.tsx"
|
|
16
|
+
- "aircall/hydra:packages/ds/src/components/alert-dialog.tsx"
|
|
17
|
+
- "aircall/hydra:packages/ds/src/stories/Dialog.stories.tsx"
|
|
18
|
+
- "aircall/hydra:packages/ds/src/stories/AlertDialog.stories.tsx"
|
|
14
19
|
---
|
|
15
20
|
|
|
16
21
|
This skill builds on aircall-ds/migrate-tractor. Apply all cross-cutting rules from that skill (prop renames, `render` prop, data attributes) before the dialog-specific steps below.
|
|
@@ -19,11 +24,13 @@ This skill builds on aircall-ds/migrate-tractor. Apply all cross-cutting rules f
|
|
|
19
24
|
|
|
20
25
|
| Tractor | @aircall/ds |
|
|
21
26
|
| --- | --- |
|
|
22
|
-
| `
|
|
23
|
-
| `ModalHeader` | `DialogHeader` |
|
|
27
|
+
| `ModalDialog` (state owner + panel; `show`, `onHide`, `size`) | `Dialog` (state owner) + `DialogContent` (panel) |
|
|
28
|
+
| `ModalHeader` (with its `closeButton` prop) | `DialogHeader`; the "×" is `DialogContent`'s `showCloseButton` |
|
|
29
|
+
| `ModalClose` | built into `DialogContent` (`showCloseButton`, default `true`); `DialogClose` for your own button |
|
|
24
30
|
| `ModalTitle` | `DialogTitle` |
|
|
25
31
|
| `ModalBody` | — (plain children inside `DialogContent`, no wrapper) |
|
|
26
32
|
| `ModalFooter` | `DialogFooter` |
|
|
33
|
+
| `ConfirmationModal` (`@dashboard/library`) | `AlertDialog` family, see section 5 |
|
|
27
34
|
| — | `DialogTrigger` (uncontrolled open trigger) |
|
|
28
35
|
| — | `DialogClose` (any button that closes the dialog) |
|
|
29
36
|
| — | `DialogDescription` (optional accessible subtitle) |
|
|
@@ -46,13 +53,13 @@ import {
|
|
|
46
53
|
|
|
47
54
|
## 3. Before / After
|
|
48
55
|
|
|
49
|
-
### Controlled (most common — replaces `<
|
|
56
|
+
### Controlled (most common — replaces `<ModalDialog show={…} onHide={…}>`)
|
|
50
57
|
|
|
51
58
|
```tsx
|
|
52
59
|
// Before
|
|
53
|
-
import {
|
|
60
|
+
import { ModalDialog, ModalHeader, ModalTitle, ModalBody, ModalFooter, Button } from '@aircall/tractor';
|
|
54
61
|
|
|
55
|
-
<
|
|
62
|
+
<ModalDialog show={isOpen} onHide={() => setIsOpen(false)} size="regular">
|
|
56
63
|
<ModalHeader>
|
|
57
64
|
<ModalTitle>Confirm delete</ModalTitle>
|
|
58
65
|
</ModalHeader>
|
|
@@ -60,10 +67,10 @@ import { Modal, ModalHeader, ModalTitle, ModalBody, ModalFooter, Button } from '
|
|
|
60
67
|
<p>This will permanently remove the contact. Are you sure?</p>
|
|
61
68
|
</ModalBody>
|
|
62
69
|
<ModalFooter>
|
|
63
|
-
<Button variant="outline" onClick={() => setIsOpen(false)}>Cancel</Button>
|
|
70
|
+
<Button variant="secondary" mode="outline" onClick={() => setIsOpen(false)}>Cancel</Button>
|
|
64
71
|
<Button variant="critical" onClick={onConfirm}>Delete</Button>
|
|
65
72
|
</ModalFooter>
|
|
66
|
-
</
|
|
73
|
+
</ModalDialog>
|
|
67
74
|
|
|
68
75
|
// After
|
|
69
76
|
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, DialogClose, Button } from '@aircall/ds';
|
|
@@ -92,10 +99,24 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, Di
|
|
|
92
99
|
```
|
|
93
100
|
|
|
94
101
|
Key changes:
|
|
95
|
-
- `
|
|
102
|
+
- `show` → `open`; `onHide()` → `onOpenChange(open, eventDetails)`. `onHide` fired only on close; `onOpenChange` fires on open and close, so `onOpenChange={setIsOpen}` is right for a controlled dialog
|
|
96
103
|
- `ModalBody` is removed — body content is plain children inside `DialogContent`
|
|
97
104
|
- `DialogClose` wraps any button that should close the dialog; pass the DS `Button` via `render` and put the label as children of `DialogClose`, not of the inner Button
|
|
98
|
-
- `variant="critical"` → `variant="destructive"` (Button)
|
|
105
|
+
- `variant="critical"` → `variant="destructive"` (Button), `variant="secondary" mode="outline"` → `variant="outline"` (see the button skill)
|
|
106
|
+
- Tractor `Button` defaults to `regular` (48px); the DS stories use `size="lg"` (40px) for dialog footer buttons (`Button` default is 32px)
|
|
107
|
+
|
|
108
|
+
Other `ModalDialog` props:
|
|
109
|
+
|
|
110
|
+
| Tractor | DS |
|
|
111
|
+
| --- | --- |
|
|
112
|
+
| `rootClose={false}` (backdrop click does not close) | `disablePointerDismissal` on `Dialog` |
|
|
113
|
+
| `portalContainer` | no equivalent: `DialogContent` has no `container` prop (unlike `SheetContent`) and always portals into `document.body` |
|
|
114
|
+
| `zIndex` | `className="z-…"` on `DialogContent`; the overlay is `z-50` |
|
|
115
|
+
| `focusOptions` | `initialFocus` / `finalFocus` on `DialogContent` (Base UI popup props) |
|
|
116
|
+
| `data-test` | `data-test` on `DialogContent` |
|
|
117
|
+
| `maxHeight` | `className="max-h-…"` on `DialogContent` |
|
|
118
|
+
|
|
119
|
+
`onOpenChange`'s second argument carries a `reason` (`'escape-key'`, `'outside-press'`, `'close-press'`, `'trigger-press'`…) when the Tractor `onHide` call site needs to tell them apart.
|
|
99
120
|
|
|
100
121
|
### Uncontrolled with a trigger
|
|
101
122
|
|
|
@@ -117,13 +138,23 @@ Key changes:
|
|
|
117
138
|
|
|
118
139
|
### Size
|
|
119
140
|
|
|
120
|
-
`Dialog` has no built-in `size` prop.
|
|
141
|
+
`Dialog` has no built-in `size` prop. `DialogContent` is `w-full max-w-[calc(100%-2rem)] sm:max-w-md` (448px from the `sm` breakpoint up). To widen it, override the **`sm:` max-width**: a bare `max-w-2xl` loses to `sm:max-w-md` on every screen above `sm`, because the two classes are on different breakpoints and are not merged.
|
|
142
|
+
|
|
143
|
+
| Tractor `size` (max width) | DS `className` on `DialogContent` |
|
|
144
|
+
| --- | --- |
|
|
145
|
+
| `xSmall` (320px) | `sm:max-w-xs` |
|
|
146
|
+
| `small` (520px) | `sm:max-w-lg` (512px) |
|
|
147
|
+
| `regular` (670px, the default) | `sm:max-w-2xl` (672px) |
|
|
148
|
+
| `large` (1000px) | `sm:max-w-5xl` (1024px) |
|
|
149
|
+
| `full` (100% × 100vh) | `h-screen max-w-none rounded-none sm:max-w-none` |
|
|
121
150
|
|
|
122
151
|
```tsx
|
|
123
|
-
// Tractor: size="
|
|
124
|
-
<DialogContent className="max-w-2xl">…</DialogContent>
|
|
152
|
+
// Tractor: size="regular"
|
|
153
|
+
<DialogContent className="sm:max-w-2xl">…</DialogContent>
|
|
125
154
|
```
|
|
126
155
|
|
|
156
|
+
Tractor's `ModalDialog` capped its height at `100vh - 2 * xxxl` and scrolled `ModalBody`. `DialogContent` has no `max-height` or scroll handling. For a long body, cap the panel and scroll the body yourself (for example `className="max-h-[calc(100vh-4rem)] grid-rows-[auto_1fr_auto]"` on `DialogContent` and `ScrollArea` or `overflow-y-auto` on the body).
|
|
157
|
+
|
|
127
158
|
### Hiding the default close button
|
|
128
159
|
|
|
129
160
|
`DialogContent` renders a default "×" close button in the top-right. Hide it when you want to force the user to use a footer action:
|
|
@@ -132,21 +163,25 @@ Key changes:
|
|
|
132
163
|
<DialogContent showCloseButton={false}>…</DialogContent>
|
|
133
164
|
```
|
|
134
165
|
|
|
166
|
+
### `DialogFooter` helper
|
|
167
|
+
|
|
168
|
+
`DialogFooter showCloseButton` appends a built-in outline "Close" button after your children. Use it for a dialog whose only action is to close; for Cancel and Confirm, keep an explicit `DialogClose`.
|
|
169
|
+
|
|
135
170
|
---
|
|
136
171
|
|
|
137
172
|
## 4. Common mistakes
|
|
138
173
|
|
|
139
|
-
### Mistake 1 — Passing `onClose` instead of `onOpenChange`
|
|
174
|
+
### Mistake 1 — Passing `show` / `onHide` / `onClose` instead of `open` / `onOpenChange`
|
|
140
175
|
|
|
141
176
|
```tsx
|
|
142
|
-
// ❌ Wrong —
|
|
143
|
-
<Dialog
|
|
177
|
+
// ❌ Wrong — show / onHide are Tractor props; they are type errors on Dialog and do not control it
|
|
178
|
+
<Dialog show={isOpen} onHide={() => setIsOpen(false)}>…</Dialog>
|
|
144
179
|
|
|
145
180
|
// ✅ Correct — onOpenChange receives the new boolean state
|
|
146
181
|
<Dialog open={isOpen} onOpenChange={setIsOpen}>…</Dialog>
|
|
147
182
|
```
|
|
148
183
|
|
|
149
|
-
`onOpenChange` fires with `false` when the dialog closes (backdrop click, Escape, or `DialogClose`).
|
|
184
|
+
`onOpenChange(open, eventDetails)` fires with `false` when the dialog closes (backdrop click, Escape, or `DialogClose`), and `eventDetails.reason` says which. A controlled dialog that only passes `open` can never be closed by the user.
|
|
150
185
|
|
|
151
186
|
Source: `packages/ds/src/components/dialog.tsx`
|
|
152
187
|
|
|
@@ -200,6 +235,66 @@ Source: `packages/ds/src/components/dialog.tsx`
|
|
|
200
235
|
<Button variant="destructive" size="lg" onClick={onConfirm}>Delete</Button>
|
|
201
236
|
```
|
|
202
237
|
|
|
203
|
-
DS renamed `critical` to `destructive` for Button (and other components).
|
|
238
|
+
DS renamed `critical` to `destructive` for Button (and other components). `critical` is a type error; if it slips through, `cva` finds no matching variant and applies no variant classes, so the button has no fill or text colour of its own.
|
|
204
239
|
|
|
205
|
-
Source: `packages/ds/src/components/
|
|
240
|
+
Source: `packages/ds/src/components/button.tsx` (`buttonVariants`)
|
|
241
|
+
|
|
242
|
+
### Mistake 5 — Widening with `max-w-*` instead of `sm:max-w-*`
|
|
243
|
+
|
|
244
|
+
```tsx
|
|
245
|
+
// ❌ Wrong — loses to the built-in sm:max-w-md above 640px, so the dialog stays 448px wide
|
|
246
|
+
<DialogContent className="max-w-2xl">…</DialogContent>
|
|
247
|
+
|
|
248
|
+
// ✅ Correct — same breakpoint as the built-in width
|
|
249
|
+
<DialogContent className="sm:max-w-2xl">…</DialogContent>
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
`DialogContent` sets `sm:max-w-md`. `tailwind-merge` only removes a class that conflicts at the same breakpoint, so `max-w-2xl` is kept as the base value and the `sm:` rule still wins from 640px up.
|
|
253
|
+
|
|
254
|
+
Source: `packages/ds/src/components/dialog.tsx` (`DialogContent` className)
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## 5. Confirmation prompts: `AlertDialog`
|
|
259
|
+
|
|
260
|
+
`@dashboard/library` `ConfirmationModal` (`show`, `onConfirm`, `onCancel`, `disabled`, `loading`, `texts.{confirmation,cancel,confirm,banner,error}`) is a confirm prompt, not a form dialog. Use the `AlertDialog` family from `@aircall/ds`, which is modal, has no "×" button and is not dismissed by a click outside:
|
|
261
|
+
|
|
262
|
+
```tsx
|
|
263
|
+
import {
|
|
264
|
+
AlertDialog,
|
|
265
|
+
AlertDialogAction,
|
|
266
|
+
AlertDialogCancel,
|
|
267
|
+
AlertDialogContent,
|
|
268
|
+
AlertDialogDescription,
|
|
269
|
+
AlertDialogFooter,
|
|
270
|
+
AlertDialogHeader,
|
|
271
|
+
AlertDialogTitle,
|
|
272
|
+
Spinner,
|
|
273
|
+
} from '@aircall/ds';
|
|
274
|
+
|
|
275
|
+
<AlertDialog open={show} onOpenChange={open => { if (!open) onCancel(); }}>
|
|
276
|
+
<AlertDialogContent>
|
|
277
|
+
<AlertDialogHeader>
|
|
278
|
+
<AlertDialogTitle>Delete this project?</AlertDialogTitle>
|
|
279
|
+
<AlertDialogDescription>
|
|
280
|
+
All boards, tickets and integrations tied to this project will be permanently removed.
|
|
281
|
+
</AlertDialogDescription>
|
|
282
|
+
</AlertDialogHeader>
|
|
283
|
+
<AlertDialogFooter>
|
|
284
|
+
<AlertDialogCancel>Keep project</AlertDialogCancel>
|
|
285
|
+
<AlertDialogAction variant="destructive" disabled={disabled || loading} onClick={onConfirm}>
|
|
286
|
+
{loading && <Spinner />}
|
|
287
|
+
Delete project
|
|
288
|
+
</AlertDialogAction>
|
|
289
|
+
</AlertDialogFooter>
|
|
290
|
+
</AlertDialogContent>
|
|
291
|
+
</AlertDialog>
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
- `AlertDialogContent` has `size` `'default' | 'sm'` (`max-w-xs`, `sm:max-w-sm`; `sm` keeps a two-column footer).
|
|
295
|
+
- `AlertDialogCancel` is an outline `Button` that closes the dialog (its `variant` / `size` props are forwarded to `Button`). `AlertDialogAction` is a plain DS `Button`: it does **not** close the dialog on its own, so set `open` to `false` from `onConfirm` once the action is done.
|
|
296
|
+
- `AlertDialogMedia` (an icon tile) goes in `AlertDialogHeader` before the title.
|
|
297
|
+
- `texts.banner` / `texts.error` (inline warning or error rows) become an `Alert` between the header and the footer; see `aircall-ds/migrate-tractor/alert`.
|
|
298
|
+
- Use `Dialog` instead when the prompt holds a form or free content, or needs the "×" button.
|
|
299
|
+
|
|
300
|
+
Source: `packages/ds/src/components/alert-dialog.tsx`, `packages/ds/src/stories/AlertDialog.stories.tsx`
|