@ahrowe/ui 0.46.0 → 0.47.1
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/CHANGELOG.md +23 -0
- package/dist/cjs-types/common/input/input.types.d.ts +4 -3
- package/dist/esm/common/animatedIcon/animatedIcon.module.mjs.map +1 -1
- package/dist/esm/common/copyButton/copyButton.module.mjs.map +1 -1
- package/dist/esm/common/input/input.mjs +1 -1
- package/dist/esm/common/input/input.mjs.map +1 -1
- package/dist/esm/common/input/input.module.mjs +1 -1
- package/dist/esm/common/input/input.module.mjs.map +1 -1
- package/dist/esm/common/input/input.types.mjs.map +1 -1
- package/dist/esm/common/numberInput/numberInput.module.mjs +1 -1
- package/dist/esm/common/numberInput/numberInput.module.mjs.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/common/input/input.types.d.ts +4 -3
- package/docs/Input.md +27 -9
- package/docs/Textarea.md +1 -1
- package/package.json +1 -1
|
@@ -54,8 +54,10 @@ export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElem
|
|
|
54
54
|
disabled?: boolean;
|
|
55
55
|
upperRightLabel?: string | React.ReactNode;
|
|
56
56
|
labelInBorder?: boolean;
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
/** Show a button that clears the field, whenever it has a value it can change. */
|
|
58
|
+
clearable?: boolean;
|
|
59
|
+
/** Called after a clear button empties the field, by click or key. */
|
|
60
|
+
onClear?: (() => void) | null;
|
|
59
61
|
min?: string | number | null;
|
|
60
62
|
max?: string | number | null;
|
|
61
63
|
placeholder?: string;
|
|
@@ -66,7 +68,6 @@ export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElem
|
|
|
66
68
|
readOnly?: boolean;
|
|
67
69
|
customInput?: React.ReactElement | null;
|
|
68
70
|
autoFocus?: boolean;
|
|
69
|
-
alwaysShowCancel?: boolean;
|
|
70
71
|
formValidator?: FormValidator | null;
|
|
71
72
|
multiline?: boolean;
|
|
72
73
|
rows?: number;
|
package/docs/Input.md
CHANGED
|
@@ -20,7 +20,7 @@ const emailValidator = new FormValidator('', [Validators.required(), Validators.
|
|
|
20
20
|
<Input label="Password" type={InputType.Password} value={pw} onChange={setPw} />
|
|
21
21
|
|
|
22
22
|
// Search — clear button appears automatically once there's a value, and clears itself;
|
|
23
|
-
//
|
|
23
|
+
// onClear is optional, only needed to react to the clear beyond the value itself
|
|
24
24
|
<Input
|
|
25
25
|
type={InputType.Search}
|
|
26
26
|
label="Search"
|
|
@@ -40,6 +40,9 @@ const emailValidator = new FormValidator('', [Validators.required(), Validators.
|
|
|
40
40
|
// With suffix
|
|
41
41
|
<Input label="Amount" suffix="€" value={amount} onChange={setAmount} />
|
|
42
42
|
|
|
43
|
+
// Clear button, shown whenever there is a value to clear
|
|
44
|
+
<Input label="City" clearable value={city} onChange={setCity} />
|
|
45
|
+
|
|
43
46
|
// Row layout
|
|
44
47
|
<Input label="Name" isRow value={name} onChange={setName} />
|
|
45
48
|
|
|
@@ -66,9 +69,9 @@ const emailValidator = new FormValidator('', [Validators.required(), Validators.
|
|
|
66
69
|
|
|
67
70
|
**Custom icon vs. built-in type icon:** passing `icon` alongside a decorative type (`Edit`, `Phone`, `Email`) replaces that type's built-in icon outright, since there's nothing functional attached to it to lose. `Search` and `Password` ignore `icon` — their icon is functional (clear button, show/hide toggle), not decorative, so it always renders regardless of whether `icon` is set.
|
|
68
71
|
|
|
69
|
-
**Search clear icon:** `InputType.Search` shows a magnifying glass that animates into a clear (×) button once the field has a value, rather than the browser's own native search-cancel decoration, which is suppressed so it doesn't clash with the theme.
|
|
72
|
+
**Search clear icon:** `InputType.Search` shows a magnifying glass that animates into a clear (×) button once the field has a value it can change, rather than the browser's own native search-cancel decoration, which is suppressed so it doesn't clash with the theme.
|
|
70
73
|
|
|
71
|
-
**Icon accessibility:** any icon with an active click handler (`onIconClick`, the search clear button, the password show/hide toggle, the
|
|
74
|
+
**Icon accessibility:** any icon with an active click handler (`onIconClick`, the search clear button, the password show/hide toggle, the `clearable` button) is keyboard-focusable (`Tab`) and activates on Enter or Space, with a visible focus outline. The ones with a fixed meaning (search clear, password toggle, clear) also carry an `aria-label`. A purely decorative icon (no click handler) stays out of the tab order. Either clear button puts the cursor back in the field, so a keyboard user does not lose their place.
|
|
72
75
|
|
|
73
76
|
**Mobile keyboard layout:** `Email`, `Phone`, and `Search` each set the matching `inputMode` (`email` / `tel` / `search`), so mobile browsers show the right on-screen keyboard — an `@`-and-`.com` layout for email, a numeric dial pad for phone, a "Go"/search action key for search. `Email`'s native `type` is deliberately left as `text` rather than `email`, to avoid the browser's own "please match the requested format" validation UI fighting the `formValidator`-driven error tooltip this component already shows — `inputMode="email"` alone is enough to get the correct keyboard. Pass `inputMode` directly to override the computed default for any other case.
|
|
74
77
|
|
|
@@ -102,17 +105,16 @@ The stored value is the formatted one, spaces included, so strip them before a l
|
|
|
102
105
|
| `isRequired` | `boolean` | |
|
|
103
106
|
| `errorMessage` | `string` | Manual error (overrides formValidator) |
|
|
104
107
|
| `isValid` | `boolean` | Manual valid state |
|
|
105
|
-
| `multiline` | `boolean` | Renders as textarea |
|
|
108
|
+
| `multiline` | `boolean` | Renders as textarea, resizable from the field's corner; `styles={{ container: { resize: 'none' } }}` turns that off |
|
|
106
109
|
| `rows` | `number` | Textarea row count |
|
|
107
110
|
| `autoResize` | `boolean` | Textarea grows with content |
|
|
108
111
|
| `suffix` | `string \| ReactNode` | Right-side suffix |
|
|
109
|
-
| `icon` | `ReactElement` | Custom icon,
|
|
112
|
+
| `icon` | `ReactElement` | Custom icon, on the side set by `iconPosition`; clickable via `onIconClick`. On the right it follows the `suffix` and the clear button, each in its own space. Replaces the built-in icon for `Edit`/`Phone`/`Email`; ignored for `Search`/`Password` (see below) |
|
|
110
113
|
| `iconPosition` | `InputIconPosition` | Side the input's icon renders on — built-in or custom, whichever is showing (see enum above for the default). On the left, the material label (resting and floated) and the fieldset notch shift right to clear it too |
|
|
111
114
|
| `onIconClick` | `() => void` | Click handler for the custom `icon` |
|
|
112
115
|
| `upperRightLabel` | `string \| ReactNode` | Small label above right |
|
|
113
|
-
| `
|
|
114
|
-
| `
|
|
115
|
-
| `onClearClicked` | `() => void` | Called after the clear button clears the value. Optional — clicking clear always empties the field itself, whether or not this is set |
|
|
116
|
+
| `clearable` | `boolean` | Show a clear button whenever the field has a value it can change (not while `disabled` or `readOnly`). While the field is empty it takes no space, so a `suffix` sits at the edge; the first character grows it in. `InputType.Search` has its own, see below |
|
|
117
|
+
| `onClear` | `() => void` | Called after a clear button empties the field. Optional: clearing always empties the field itself |
|
|
116
118
|
| `isRow` | `boolean` | Horizontal layout |
|
|
117
119
|
| `labelInBorder` | `boolean` | Label inside fieldset border |
|
|
118
120
|
| `alwaysFloatLabel` | `boolean` | Keep the material label floated in the border notch even when empty and unfocused, so an empty field reads as blank instead of showing the label as if it were a value. Only applies with `useMatLabelStyle` (default) |
|
|
@@ -138,4 +140,20 @@ The combobox components — `InputDropdown`, `SearchInput`, `MultiSelect`, `Date
|
|
|
138
140
|
|
|
139
141
|
**Autofilled fields stay on the theme.** Chrome paints `:-webkit-autofill` with its own background and text colour, overriding `background` and `color` outright, which turned a filled field pale blue with near-black text on a dark theme. Input clips that background to the text instead of covering it: the page cannot win on colour, but it can say where a background paints, and `-webkit-text-fill-color` then beats the text colour. The field itself is transparent, so what shows through is whatever is genuinely behind it — inside a Modal, a Card, or a surface of your own — and nothing has to be told what that is.
|
|
140
142
|
|
|
141
|
-
A custom `--input-background` is covered by the same mechanism, because the container paints it and the transparent field reveals it. Setting a background on the field itself with the `background` shorthand — `styles={{ input: { background: '…' } }}` — resets `background-clip` along with it, and an autofilled field there falls back to Chrome's own colours; `background-color` does not.
|
|
143
|
+
A custom `--input-background` is covered by the same mechanism, because the container paints it and the transparent field reveals it. Setting a background on the field itself with the `background` shorthand — `styles={{ input: { background: '…' } }}` — resets `background-clip` along with it, and an autofilled field there falls back to Chrome's own colours; `background-color` does not. Either way it covers only the text: a background meant for the whole field, under the icons and the suffix too, goes on `styles.container`.
|
|
144
|
+
|
|
145
|
+
## Migration from `showCancel`
|
|
146
|
+
|
|
147
|
+
Before 0.47 the clear button came from two props, and its callback had a name that missed key
|
|
148
|
+
presses. TypeScript points at every use:
|
|
149
|
+
|
|
150
|
+
| Before | After |
|
|
151
|
+
|--------|-------|
|
|
152
|
+
| `showCancel` | `clearable` |
|
|
153
|
+
| `alwaysShowCancel` | `clearable` |
|
|
154
|
+
| `onClearClicked={…}` | `onClear={…}` |
|
|
155
|
+
|
|
156
|
+
What changes on screen: `showCancel` showed the button only on hover or focus, and
|
|
157
|
+
`alwaysShowCancel` showed it even on an empty field, where it did nothing. `clearable` shows it
|
|
158
|
+
whenever the field has a value, and never while it is `disabled` or `readOnly`, where both old
|
|
159
|
+
props would still clear it.
|
package/docs/Textarea.md
CHANGED
|
@@ -36,7 +36,7 @@ const descValidator = new FormValidator('', [Validators.required(), Validators.m
|
|
|
36
36
|
| `value` | `string` | Controlled value |
|
|
37
37
|
| `onChange` | `(value: string) => void` | Change handler |
|
|
38
38
|
| `rows` | `number` | Initial visible row count |
|
|
39
|
-
| `autoResize` | `boolean` | Grows with content |
|
|
39
|
+
| `autoResize` | `boolean` | Grows with content, in place of the resize grip. To drop the grip without it: `styles={{ container: { resize: 'none' } }}` |
|
|
40
40
|
| `formValidator` | `FormValidator` | Connects to validation |
|
|
41
41
|
| `placeholder` | `string` | |
|
|
42
42
|
| `readOnly` | `boolean` | |
|