@aircall/ds 0.50.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-BgeS8KWP.d.ts → data-table-B5VqWPmw.d.ts} +3 -4
- package/dist/data-table.d.ts +1 -1
- package/dist/globals.css +1 -1
- package/dist/index.d.ts +12 -9
- package/dist/index.js +11 -8
- 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,9 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: aircall-ds/migrate-tractor/input
|
|
3
3
|
description: >
|
|
4
|
-
Migrate Tractor
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
Migrate Tractor TextInput (also exported as TextFieldInput in older versions), PasswordInput
|
|
5
|
+
and the @dashboard/library NumberInput to @aircall/ds Input, InputGroup (InputGroupAddon,
|
|
6
|
+
InputGroupButton, InputGroupInput, InputGroupText) and NumericInput. Load when a file imports
|
|
7
|
+
TextInput, TextFieldInput, PasswordInput or NumberInput.
|
|
7
8
|
type: sub-skill
|
|
8
9
|
library: aircall-ds
|
|
9
10
|
requires:
|
|
@@ -11,24 +12,38 @@ requires:
|
|
|
11
12
|
- aircall-ds/migrate-tractor
|
|
12
13
|
sources:
|
|
13
14
|
- "aircall/hydra:docs/migration-guides/tractor-to-ds/recipes/input.md"
|
|
15
|
+
- "aircall/hydra:packages/ds/src/components/input.tsx"
|
|
16
|
+
- "aircall/hydra:packages/ds/src/components/input-group.tsx"
|
|
17
|
+
- "aircall/hydra:packages/ds/src/components/numeric-input.tsx"
|
|
18
|
+
- "aircall/hydra:packages/ds/src/stories/Input.stories.tsx"
|
|
19
|
+
- "aircall/hydra:packages/ds/src/stories/InputGroup.stories.tsx"
|
|
20
|
+
- "aircall/hydra:packages/ds/src/stories/NumericInput.stories.tsx"
|
|
21
|
+
- "aircall/hydra:packages/tractor/src/components/TextInput/TextInput.tsx"
|
|
22
|
+
- "aircall/hydra:packages/tractor/src/components/PasswordInput/PasswordInput.tsx"
|
|
14
23
|
---
|
|
15
24
|
|
|
16
25
|
This skill builds on aircall-ds/migrate-tractor. Apply all cross-cutting rules from that skill (prop renames, `render` prop, data attributes) before the input-specific steps below.
|
|
17
26
|
|
|
27
|
+
For a form that collects and submits data, do not wire `Input` by hand: use `@aircall/blocks` `FormInputField` (and `FormNumericField`) and spread the `inputProps` / `numericProps` bundle (pre-wired `id`, `value`, `onChange`, `onBlur`, `aria-invalid`). See `@aircall/ds#aircall-ds/migrate-tractor/form-and-field` and `@aircall/blocks#aircall-blocks/migrate-dashboard/form-wizard`. The snippets below are the bare primitives.
|
|
28
|
+
|
|
18
29
|
## 1. Component mapping
|
|
19
30
|
|
|
20
|
-
|
|
31
|
+
Tractor's text control is `TextInput` (older `@aircall/tractor` 1.x exported it as `TextFieldInput`; same props). Both map to the same DS parts.
|
|
32
|
+
|
|
33
|
+
| Tractor / @dashboard/library component | DS replacement | Notes |
|
|
21
34
|
| --- | --- | --- |
|
|
22
|
-
| `<TextFieldInput>` | `<Input>` | Drop-in for plain text inputs |
|
|
35
|
+
| `<TextInput>` / `<TextFieldInput>` | `<Input>` | Drop-in for plain text inputs |
|
|
36
|
+
| `<TextInput icon>` / `suffix` / `onClear` | `<InputGroup>` composition | `InputGroupAddon` for decorations, `InputGroupButton` for the clear button |
|
|
23
37
|
| `<PasswordInput>` | `<InputGroup>` composition | No turn-key password component in DS — compose manually |
|
|
24
|
-
|
|
|
38
|
+
| `<NumberInput>` (`@dashboard/library`) / `<TextInput type="number">` | `<NumericInput>` | Locale-aware, built-in `−`/`+` steppers and `prefix`/`suffix` (§5d) |
|
|
25
39
|
|
|
26
40
|
## 2. Verified DS exports (`packages/ds/src/index.ts`)
|
|
27
41
|
|
|
28
42
|
```
|
|
29
43
|
Input,
|
|
30
44
|
InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput,
|
|
31
|
-
InputGroupText, InputGroupTextarea
|
|
45
|
+
InputGroupText, InputGroupTextarea,
|
|
46
|
+
NumericInput, NumericInputControl, NumericInputIncrement, NumericInputDecrement
|
|
32
47
|
```
|
|
33
48
|
|
|
34
49
|
All names used in the Before/After sections below exist in the published public API.
|
|
@@ -47,26 +62,27 @@ import {
|
|
|
47
62
|
InputGroupAddon,
|
|
48
63
|
InputGroupButton,
|
|
49
64
|
InputGroupInput,
|
|
65
|
+
InputGroupText,
|
|
50
66
|
} from '@aircall/ds';
|
|
51
|
-
import {
|
|
67
|
+
import { Eye, EyeOff, Search } from '@aircall/react-icons';
|
|
52
68
|
```
|
|
53
69
|
|
|
54
|
-
Never import icons from `lucide-react` directly — always use `@aircall/react-icons`.
|
|
70
|
+
Never import icons from `lucide-react` directly — always use `@aircall/react-icons`. It re-exports the lucide set, so `VisibleOnFilled`/`VisibleOffFilled` become `Eye`/`EyeOff` and `SearchOutlined` becomes `Search` (see `@aircall/ds#aircall-ds/migrate-icons`). The old `*Fill`/`*Outline` names do not exist there.
|
|
55
71
|
|
|
56
|
-
## 4. Prop renames (
|
|
72
|
+
## 4. Prop renames (TextInput → Input)
|
|
57
73
|
|
|
58
74
|
| Tractor prop | DS prop | Notes |
|
|
59
75
|
| --- | --- | --- |
|
|
60
|
-
| `size="
|
|
61
|
-
| `validationStatus="error"` | `aria-invalid={true}` | DS reads ARIA attributes for error styling |
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
67
|
-
| `
|
|
68
|
-
|
|
69
|
-
|
|
76
|
+
| `size="xSmall"\|"small"\|"regular"\|"large"` | _(removed)_ | DS `Input` is always 40px (Tractor `regular` was 48px, `small` 40px, `xSmall` 32px); drop the prop entirely. There is no 32px Input |
|
|
77
|
+
| `validationStatus="error"` | `aria-invalid={true}` | DS reads ARIA attributes for error styling. `validationStatus="success"` has no equivalent |
|
|
78
|
+
| `icon={Icon}` | `<InputGroupAddon align="inline-start">` + icon | §5c |
|
|
79
|
+
| `suffix={node}` | `<InputGroupAddon align="inline-end">` + node | |
|
|
80
|
+
| `onClear` | conditional `InputGroupButton` in an `inline-end` addon | See the search-with-clear pattern in `Input.stories.tsx` (`InputGroupExamples`); focus the input again after clearing |
|
|
81
|
+
| `variant="list"` | _(removed)_ | Internal to Tractor's list/select triggers |
|
|
82
|
+
| `value`, `onChange`, `placeholder`, `type`, `disabled`, `readOnly`, `required`, `autoFocus`, `id`, `name` | unchanged | `Input` is a plain `<input>` (`React.ComponentProps<'input'>`) |
|
|
83
|
+
| `id` taken from the surrounding `FormItem name` | explicit `id` + `FieldLabel htmlFor` | Tractor wired it implicitly; DS does not |
|
|
84
|
+
|
|
85
|
+
`Input` also has a `block` variant (`w-full`), but the base style is already `w-full`, so it is rarely needed.
|
|
70
86
|
|
|
71
87
|
## 5. Before / After examples
|
|
72
88
|
|
|
@@ -74,9 +90,9 @@ Never import icons from `lucide-react` directly — always use `@aircall/react-i
|
|
|
74
90
|
|
|
75
91
|
**Before (Tractor):**
|
|
76
92
|
```tsx
|
|
77
|
-
import {
|
|
93
|
+
import { TextInput } from '@aircall/tractor';
|
|
78
94
|
|
|
79
|
-
<
|
|
95
|
+
<TextInput
|
|
80
96
|
type="email"
|
|
81
97
|
placeholder="Enter email"
|
|
82
98
|
value={value}
|
|
@@ -101,11 +117,11 @@ import { Input } from '@aircall/ds';
|
|
|
101
117
|
/>
|
|
102
118
|
```
|
|
103
119
|
|
|
104
|
-
> The `size` prop is dropped — DS `Input` is always 40px. The `validationStatus="error"` prop becomes `aria-invalid={true}`; DS picks up the
|
|
120
|
+
> The `size` prop is dropped — DS `Input` is always 40px. The `validationStatus="error"` prop becomes `aria-invalid={true}`; DS picks up the destructive border and focus ring from the ARIA attribute automatically. Put a label and error message around it with `Field`/`FieldLabel`/`FieldError`.
|
|
105
121
|
|
|
106
122
|
### 5b. PasswordInput → InputGroup composition
|
|
107
123
|
|
|
108
|
-
Tractor's `PasswordInput` shipped a built-in eye-toggle button. DS has no turn-key password input; compose one with `InputGroup`, `InputGroupInput`, `InputGroupAddon
|
|
124
|
+
Tractor's `PasswordInput` shipped a built-in eye-toggle button (and forced `type="password"` while disabled). DS has no turn-key password input; compose one with `InputGroup`, `InputGroupInput`, `InputGroupAddon` and `InputGroupButton`.
|
|
109
125
|
|
|
110
126
|
**Before (Tractor):**
|
|
111
127
|
```tsx
|
|
@@ -116,84 +132,156 @@ import { PasswordInput } from '@aircall/tractor';
|
|
|
116
132
|
value={password}
|
|
117
133
|
onChange={onChange}
|
|
118
134
|
placeholder="Enter password"
|
|
135
|
+
visibilityButtonAriaLabel="Show password"
|
|
119
136
|
/>
|
|
120
137
|
```
|
|
121
138
|
|
|
122
139
|
**After (DS):**
|
|
123
140
|
```tsx
|
|
124
141
|
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from '@aircall/ds';
|
|
125
|
-
import {
|
|
142
|
+
import { Eye, EyeOff } from '@aircall/react-icons';
|
|
126
143
|
import { useState } from 'react';
|
|
127
144
|
|
|
128
|
-
function PasswordInput({
|
|
145
|
+
function PasswordInput({
|
|
146
|
+
visibilityButtonAriaLabel = 'Show password',
|
|
147
|
+
...props
|
|
148
|
+
}: React.ComponentProps<typeof InputGroupInput> & { visibilityButtonAriaLabel?: string }) {
|
|
129
149
|
const [shown, setShown] = useState(false);
|
|
130
150
|
|
|
131
151
|
return (
|
|
132
152
|
<InputGroup>
|
|
133
153
|
<InputGroupInput
|
|
134
|
-
id={id}
|
|
135
|
-
type={shown ? 'text' : 'password'}
|
|
136
154
|
{...props}
|
|
155
|
+
// After the spread, so a caller's `type` cannot defeat the disabled safeguard.
|
|
156
|
+
type={shown && !props.disabled ? 'text' : 'password'}
|
|
137
157
|
/>
|
|
138
158
|
<InputGroupAddon align="inline-end">
|
|
139
159
|
<InputGroupButton
|
|
140
|
-
size="icon-
|
|
160
|
+
size="icon-sm"
|
|
161
|
+
disabled={props.disabled}
|
|
141
162
|
onClick={() => setShown(s => !s)}
|
|
142
|
-
aria-label={
|
|
163
|
+
aria-label={visibilityButtonAriaLabel}
|
|
164
|
+
aria-pressed={shown}
|
|
143
165
|
>
|
|
144
|
-
{shown ? <
|
|
166
|
+
{shown ? <EyeOff /> : <Eye />}
|
|
145
167
|
</InputGroupButton>
|
|
146
168
|
</InputGroupAddon>
|
|
147
169
|
</InputGroup>
|
|
148
170
|
);
|
|
149
171
|
}
|
|
172
|
+
|
|
173
|
+
// Callers keep their existing (localized) label:
|
|
174
|
+
<PasswordInput id="password" value={password} onChange={onChange}
|
|
175
|
+
visibilityButtonAriaLabel={t('password.show')} />
|
|
150
176
|
```
|
|
151
177
|
|
|
152
|
-
> `InputGroupInput` is the borderless `Input` variant — the border lives on the surrounding `InputGroup`, so there is no double frame.
|
|
178
|
+
> Like Tractor, the toggle keeps one label (`visibilityButtonAriaLabel`) and `aria-pressed` reports the state, so pass the caller's localized string through rather than hard-coding it. `type` is computed after the prop spread, so it always reverts to `password` while disabled. `InputGroupInput` is the borderless `Input` variant — the border lives on the surrounding `InputGroup`, so there is no double frame. `InputGroupButton` defaults to `variant="ghost"`, `size="sm"` and `type="button"`; use `size="icon-sm"` for an icon-only button (Button sizes are `default`, `sm`, `lg`, `icon`, `icon-sm`, `icon-lg` — there is no `icon-xs`). Icons inside an addon/button are sized `size-4` automatically.
|
|
153
179
|
|
|
154
|
-
### 5c. Input with a prefix icon (search, currency, etc.)
|
|
180
|
+
### 5c. Input with a prefix icon, suffix or clear button (search, currency, etc.)
|
|
155
181
|
|
|
156
182
|
**Before (Tractor):**
|
|
157
183
|
```tsx
|
|
158
|
-
import {
|
|
159
|
-
import {
|
|
184
|
+
import { TextInput } from '@aircall/tractor';
|
|
185
|
+
import { SearchOutlined } from '@aircall/icons';
|
|
160
186
|
|
|
161
|
-
<
|
|
162
|
-
<SearchOutline style={{ position: 'absolute', left: 8, top: 12 }} />
|
|
163
|
-
<TextFieldInput placeholder="Search…" style={{ paddingLeft: 28 }} />
|
|
164
|
-
</div>
|
|
187
|
+
<TextInput icon={SearchOutlined} placeholder="Search…" value={q} onChange={onChange} onClear={() => setQ('')} />
|
|
165
188
|
```
|
|
166
189
|
|
|
167
190
|
**After (DS):**
|
|
168
191
|
```tsx
|
|
169
|
-
import { InputGroup, InputGroupAddon, InputGroupInput } from '@aircall/ds';
|
|
170
|
-
import {
|
|
192
|
+
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from '@aircall/ds';
|
|
193
|
+
import { Search, X } from '@aircall/react-icons';
|
|
194
|
+
import { useRef } from 'react';
|
|
195
|
+
|
|
196
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
171
197
|
|
|
172
198
|
<InputGroup>
|
|
173
199
|
<InputGroupAddon align="inline-start">
|
|
174
|
-
<
|
|
200
|
+
<Search />
|
|
175
201
|
</InputGroupAddon>
|
|
176
|
-
<InputGroupInput placeholder="Search…" />
|
|
202
|
+
<InputGroupInput ref={inputRef} placeholder="Search…" value={q} onChange={e => setQ(e.target.value)} />
|
|
203
|
+
{q && (
|
|
204
|
+
<InputGroupAddon align="inline-end">
|
|
205
|
+
<InputGroupButton
|
|
206
|
+
size="icon-sm"
|
|
207
|
+
aria-label="Clear search"
|
|
208
|
+
onClick={() => {
|
|
209
|
+
setQ('');
|
|
210
|
+
// The button unmounts once q is empty; hand focus back to the field.
|
|
211
|
+
inputRef.current?.focus();
|
|
212
|
+
}}
|
|
213
|
+
>
|
|
214
|
+
<X />
|
|
215
|
+
</InputGroupButton>
|
|
216
|
+
</InputGroupAddon>
|
|
217
|
+
)}
|
|
177
218
|
</InputGroup>
|
|
178
219
|
```
|
|
179
220
|
|
|
180
|
-
|
|
221
|
+
Text affixes (`https://`, `€`) go in an addon as `<InputGroupText>`:
|
|
222
|
+
```tsx
|
|
223
|
+
<InputGroup>
|
|
224
|
+
<InputGroupAddon align="inline-start">
|
|
225
|
+
<InputGroupText>https://</InputGroupText>
|
|
226
|
+
</InputGroupAddon>
|
|
227
|
+
<InputGroupInput type="url" placeholder="aircall.io" />
|
|
228
|
+
</InputGroup>
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
> No manual positioning or padding overrides needed — `InputGroupAddon` with `align="inline-start"`/`"inline-end"` shifts the inner input's padding automatically via a CSS `:has()` rule on the group. `align` also accepts `block-start`/`block-end` (a row above/below the input, used with `InputGroupTextarea`). Clicking an addon (not a button) focuses the input.
|
|
232
|
+
|
|
233
|
+
### 5d. NumberInput / `type="number"` → NumericInput
|
|
234
|
+
|
|
235
|
+
`NumericInput` is the DS numeric field: locale-aware formatting, `min`/`max`/`step`, and built-in `−`/`+` steppers. It renders **its own bordered group** — never nest it inside an `InputGroup`. Prefer it over `<Input type="number">`.
|
|
236
|
+
|
|
237
|
+
**Before (`@dashboard/library`):**
|
|
238
|
+
```tsx
|
|
239
|
+
import { NumberInput } from '@dashboard/library';
|
|
240
|
+
|
|
241
|
+
<NumberInput unit="sec" value={ringTime} onChange={setRingTime} min={0} max={60} step={5} />
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**After (DS):**
|
|
245
|
+
```tsx
|
|
246
|
+
import { NumericInput } from '@aircall/ds';
|
|
247
|
+
|
|
248
|
+
<NumericInput
|
|
249
|
+
aria-label="Ring for"
|
|
250
|
+
value={ringTime}
|
|
251
|
+
onValueChange={value => setRingTime(value ?? 0)}
|
|
252
|
+
min={0}
|
|
253
|
+
max={60}
|
|
254
|
+
step={5}
|
|
255
|
+
suffix="sec"
|
|
256
|
+
/>
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Mapping: `unit` → `suffix` (or `prefix`); `onChange(number)` → `onValueChange(number | null, details)` (`null` when the field is cleared — guard it); `decimalPlaces` → `format={{ minimumFractionDigits, maximumFractionDigits }}`; `hideStepper` hides the buttons (convenience mode only). For a localised unit that pluralises ("1 second" / "25 seconds"), use `format={{ style: 'unit', unit: 'second', unitDisplay: 'long' }}` instead of a static `suffix`. `locale` defaults to the DS i18n language.
|
|
260
|
+
|
|
261
|
+
Convenience mode (no children) forwards `aria-label`/`aria-labelledby`/`aria-describedby`/`aria-invalid` to the input. In **compound mode** (children) compose `NumericInputControl`, `NumericInputDecrement`/`NumericInputIncrement` and `InputGroupAddon` yourself, put the accessible name on `NumericInputControl`, and note that the invalid halo follows the control's `aria-invalid` (or the `Field` state), not the root's:
|
|
262
|
+
|
|
263
|
+
```tsx
|
|
264
|
+
<NumericInput defaultValue={0} min={0} max={59}>
|
|
265
|
+
<NumericInputControl aria-label="Wrap-up minutes" className="text-right" />
|
|
266
|
+
<InputGroupAddon align="inline-end"><InputGroupText>min</InputGroupText></InputGroupAddon>
|
|
267
|
+
</NumericInput>
|
|
268
|
+
```
|
|
181
269
|
|
|
182
270
|
## 6. Common Mistakes
|
|
183
271
|
|
|
184
272
|
### Mistake 1 — Keeping `validationStatus="error"` instead of `aria-invalid`
|
|
185
273
|
|
|
186
274
|
```tsx
|
|
187
|
-
// Wrong — DS Input has no validationStatus prop; the red border never appears
|
|
275
|
+
// Wrong — DS Input has no validationStatus prop (type error); the red border never appears
|
|
188
276
|
<Input value={value} onChange={onChange} validationStatus="error" />
|
|
189
277
|
|
|
190
278
|
// Correct — error styling is driven by the ARIA attribute
|
|
191
279
|
<Input value={value} onChange={onChange} aria-invalid={true} />
|
|
192
280
|
```
|
|
193
281
|
|
|
194
|
-
DS `Input` does not accept a `validationStatus` prop
|
|
282
|
+
DS `Input` does not accept a `validationStatus` prop. The error border and focus-ring color are controlled by `aria-invalid`; without it the field looks visually valid even when it is not. Inside an `InputGroup`, put `aria-invalid` on the `InputGroupInput` — the group border follows it.
|
|
195
283
|
|
|
196
|
-
Source: `packages/ds/src/components/input.tsx` — `inputVariants` keys on `aria-invalid` via `aria-invalid:border-destructive`.
|
|
284
|
+
Source: `packages/ds/src/components/input.tsx` — `inputVariants` keys on `aria-invalid` via `aria-invalid:border-destructive`; `packages/ds/src/components/input-group.tsx` — shell uses `has-[[data-slot][aria-invalid=true]]:border-destructive`.
|
|
197
285
|
|
|
198
286
|
---
|
|
199
287
|
|
|
@@ -213,48 +301,66 @@ Source: `packages/ds/src/components/input.tsx` — `inputVariants` keys on `aria
|
|
|
213
301
|
</InputGroup>
|
|
214
302
|
```
|
|
215
303
|
|
|
216
|
-
`InputGroupInput` renders a borderless, shadow-free, background-transparent `Input`
|
|
304
|
+
`InputGroupInput` renders a borderless, shadow-free, background-transparent `Input` and carries `data-slot="input-group-control"`, which is what makes the surrounding `InputGroup` show the focus ring. Using the plain `Input` inside an `InputGroup` causes a visible double frame because the regular `Input` keeps its own `border-input` border, and the group never lights up on focus.
|
|
217
305
|
|
|
218
|
-
Source: `packages/ds/src/components/input-group.tsx` — `InputGroupInput` applies `border-0 shadow-none
|
|
306
|
+
Source: `packages/ds/src/components/input-group.tsx` — `InputGroupInput` applies `border-0 bg-transparent shadow-none focus-visible:ring-0` and `data-slot="input-group-control"`.
|
|
219
307
|
|
|
220
308
|
---
|
|
221
309
|
|
|
222
|
-
### Mistake 3 —
|
|
310
|
+
### Mistake 3 — Carrying a Tractor `size` over to `Input`
|
|
223
311
|
|
|
224
312
|
```tsx
|
|
225
|
-
// Wrong — a
|
|
226
|
-
//
|
|
313
|
+
// Wrong — a Tractor size name is a type error, and a numeric `size` is the native
|
|
314
|
+
// <input size> attribute (visible character width), not a style variant
|
|
227
315
|
<Input size={fieldSize} value={value} onChange={onChange} />
|
|
228
316
|
|
|
229
317
|
// Correct — remove the size prop entirely; DS Input is always 40px
|
|
230
318
|
<Input value={value} onChange={onChange} />
|
|
231
319
|
```
|
|
232
320
|
|
|
233
|
-
DS `Input` extends `React.ComponentProps<'input'>`, so
|
|
321
|
+
DS `Input` extends `React.ComponentProps<'input'>`, so a `size` that type-checks (a number) flows through to the DOM `<input size="…">` attribute and only changes the visible character width in some browsers. Drop any dynamic `size` variable inherited from Tractor code (`xSmall`/`small`/`regular`/`large`).
|
|
234
322
|
|
|
235
|
-
Source: `packages/ds/src/components/input.tsx` — `Input` spreads `...props` onto `<input>` with no `size`
|
|
323
|
+
Source: `packages/ds/src/components/input.tsx` — `Input` spreads `...props` onto `<input>` with no `size` variant.
|
|
236
324
|
|
|
237
325
|
---
|
|
238
326
|
|
|
239
327
|
### Mistake 4 — Placing a decorative icon directly inside `<InputGroup>` instead of inside `<InputGroupAddon>`
|
|
240
328
|
|
|
241
329
|
```tsx
|
|
242
|
-
// Wrong — a bare icon as a direct child of InputGroup
|
|
243
|
-
//
|
|
330
|
+
// Wrong — a bare icon as a direct child of InputGroup gets no addon spacing, no
|
|
331
|
+
// size-4 sizing, no input padding adjustment and no click-to-focus behavior
|
|
244
332
|
<InputGroup>
|
|
245
|
-
<
|
|
333
|
+
<Search />
|
|
246
334
|
<InputGroupInput placeholder="Search…" />
|
|
247
335
|
</InputGroup>
|
|
248
336
|
|
|
249
337
|
// Correct — wrap the icon in InputGroupAddon with the correct align value
|
|
250
338
|
<InputGroup>
|
|
251
339
|
<InputGroupAddon align="inline-start">
|
|
252
|
-
<
|
|
340
|
+
<Search />
|
|
253
341
|
</InputGroupAddon>
|
|
254
342
|
<InputGroupInput placeholder="Search…" />
|
|
255
343
|
</InputGroup>
|
|
256
344
|
```
|
|
257
345
|
|
|
258
|
-
`InputGroup` is a flex container that relies on `data-align` set by `InputGroupAddon` to apply the correct inner padding to the sibling
|
|
346
|
+
`InputGroup` is a flex container that relies on `data-align` set by `InputGroupAddon` to apply the correct inner padding to the sibling input via a CSS `:has()` rule. A bare icon child is not an `InputGroupAddon`, sets no `data-align`, and is not sized or padded like an addon, so the spacing around it is wrong.
|
|
259
347
|
|
|
260
348
|
Source: `packages/ds/src/components/input-group.tsx` — `has-[>[data-align=inline-start]]:[&>input]:pl-2` depends on `data-align` from `InputGroupAddon`.
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
### Mistake 5 — Nesting `NumericInput` in an `InputGroup`, or using `onValueChange` as if it were `onChange`
|
|
353
|
+
|
|
354
|
+
```tsx
|
|
355
|
+
// Wrong — NumericInput IS the group; nesting gives a double frame. And its callback is not a DOM event
|
|
356
|
+
<InputGroup>
|
|
357
|
+
<NumericInput value={n} onChange={e => setN(Number(e.target.value))} />
|
|
358
|
+
</InputGroup>
|
|
359
|
+
|
|
360
|
+
// Correct
|
|
361
|
+
<NumericInput aria-label="Seats" value={n} onValueChange={v => setN(v ?? 0)} />
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
`NumericInput` renders the same bordered shell as `InputGroup` (`inputGroupShellClassName`) and reports `number | null`, not a change event.
|
|
365
|
+
|
|
366
|
+
Source: `packages/ds/src/components/numeric-input.tsx` — `NumericInputPrimitive.Root` with `className={cn(inputGroupShellClassName, className)}`; `onValueChange?: (value: number | null, eventDetails) => void`.
|