@madecki/ui 1.4.0 → 1.5.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/index.cjs +21 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +21 -9
- package/dist/index.js.map +1 -1
- package/llm-context.md +15 -1
- package/package.json +1 -1
package/llm-context.md
CHANGED
|
@@ -47,7 +47,7 @@ When building UI, ALWAYS check if @madecki/ui has a component before creating cu
|
|
|
47
47
|
- `RadioButtons` - Radio group. Props: `name: string`, `options: {label, value}[]`, `onChange: (value) => void`
|
|
48
48
|
|
|
49
49
|
### Forms
|
|
50
|
-
- `Input` - Text input. Props: `name
|
|
50
|
+
- `Input` - Text input. Props: `name`, `label`, `onChange?: (value: string) => void`, optional **`value`** (controlled) or **`defaultValue`** (uncontrolled initial only), `placeholder?`, **`type?`** (any standard HTML input type from React’s `HTMLInputTypeAttribute`, including `date`, `time`, `datetime-local`, etc.), **`maxLength?`**, `variant?`, `required?`, `pattern?`, `title?`, `ariaLabel?`, `spellCheck?`, `disabled?`, `className?`, `icon?`, **`testId?`** (`data-testid` on the native `<input>` for Playwright). See below for controlled vs uncontrolled and testing.
|
|
51
51
|
- `Select` - Combobox styled like `Input`, with trailing chevron. Props: `name`, `label`, `options: { value, label }[]`, `placeholder?`, `variant?` (same as Input), `disabled?`, `className?`, `testId?`. Typing filters the list. **Single (default):** `value?`, `defaultValue?`, `onChange?: (value: string) => void`. **Multi:** `multi={true}`, `value?`, `defaultValue?`, `onChange?: (value: string[]) => void`. The dropdown is absolutely positioned under the field so it does not shift surrounding layout. See below for controlled vs uncontrolled and testing.
|
|
52
52
|
|
|
53
53
|
### Navigation
|
|
@@ -127,6 +127,20 @@ import { Input, Select, Button, Stack } from "@madecki/ui";
|
|
|
127
127
|
</Stack>
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
+
### Input — controlled vs uncontrolled
|
|
131
|
+
|
|
132
|
+
| Mode | What you pass | Who owns the text |
|
|
133
|
+
|------|----------------|-------------------|
|
|
134
|
+
| **Controlled** | `value` (+ `onChange`) | The parent. The field always shows `value`. Update parent state in `onChange` (including for Playwright `fill`) or the UI will not match. |
|
|
135
|
+
| **Uncontrolled** | No `value`; optionally `defaultValue` | The `Input` component. `defaultValue` applies on first mount only; it does not resync if the prop changes later (remount with a `key` if you need that). |
|
|
136
|
+
|
|
137
|
+
If **`value !== undefined`**, the input is controlled (including **`value=""`**).
|
|
138
|
+
|
|
139
|
+
### Input — testing
|
|
140
|
+
|
|
141
|
+
- Prefer **`testId`** so Playwright can target `getByTestId("…")` on the real `<input>` without a generic `locator("input")`.
|
|
142
|
+
- With **controlled** `value` + `onChange`, `fill()` / typing stay in sync as long as the parent updates state from `onChange` (no `onInputCapture` workaround needed).
|
|
143
|
+
|
|
130
144
|
### Select — controlled vs uncontrolled
|
|
131
145
|
|
|
132
146
|
| Mode | What you pass | Who stores the selection |
|