@ahrowe/ui 0.7.1 → 0.9.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/esm/common/animatedLogo/animatedLogo.mjs +2 -0
- package/dist/esm/common/animatedLogo/animatedLogo.mjs.map +1 -0
- package/dist/esm/common/animatedLogo/animatedLogo.module.mjs +2 -0
- package/dist/esm/common/animatedLogo/animatedLogo.module.mjs.map +1 -0
- package/dist/esm/common/datePicker/datePicker.mjs +1 -1
- package/dist/esm/common/datePicker/datePicker.mjs.map +1 -1
- package/dist/esm/common/datePicker/datePicker.module.mjs +1 -1
- package/dist/esm/common/datePicker/datePicker.module.mjs.map +1 -1
- package/dist/esm/common/dropZone/dropZone.module.mjs.map +1 -1
- package/dist/esm/common/dropdown/dropdown.mjs +1 -1
- package/dist/esm/common/dropdown/dropdown.mjs.map +1 -1
- package/dist/esm/common/radioGroup/radioGroup.mjs +2 -0
- package/dist/esm/common/radioGroup/radioGroup.mjs.map +1 -0
- package/dist/esm/common/radioGroup/radioGroup.module.mjs +2 -0
- package/dist/esm/common/radioGroup/radioGroup.module.mjs.map +1 -0
- package/dist/esm/common/radioGroup/radioGroup.types.mjs +2 -0
- package/dist/esm/common/radioGroup/radioGroup.types.mjs.map +1 -0
- package/dist/esm/common/scrollbarProvider/scrollbarProvider.module.mjs.map +1 -1
- package/dist/esm/common/sticky/sticky.mjs +1 -1
- package/dist/esm/common/sticky/sticky.mjs.map +1 -1
- package/dist/esm/common/sticky/stickyStack.mjs +2 -0
- package/dist/esm/common/sticky/stickyStack.mjs.map +1 -0
- package/dist/esm/favicon.ico +0 -0
- package/dist/esm/index.mjs +1 -1
- package/dist/favicon.ico +0 -0
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/package/common/animatedLogo/animatedLogo.d.ts +4 -0
- package/dist/types/package/common/animatedLogo/animatedLogo.types.d.ts +27 -0
- package/dist/types/package/common/animatedLogo/index.d.ts +2 -0
- package/dist/types/package/common/configProvider/configProvider.types.d.ts +2 -0
- package/dist/types/package/common/radioGroup/index.d.ts +2 -0
- package/dist/types/package/common/radioGroup/radioGroup.d.ts +4 -0
- package/dist/types/package/common/radioGroup/radioGroup.types.d.ts +45 -0
- package/dist/types/package/common/sticky/stickyStack.d.ts +41 -0
- package/dist/types/package/index.d.ts +4 -0
- package/docs/AnimatedLogo.md +60 -0
- package/docs/CLAUDE.md +2 -0
- package/docs/ConfigProvider.md +1 -1
- package/docs/RadioGroup.md +76 -0
- package/docs/Sticky.md +11 -0
- package/package.json +2 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# RadioGroup
|
|
2
|
+
|
|
3
|
+
**When to use:** Single-choice selection from a small, always-visible set of options — plan pickers, shipping methods, yes/no/maybe, settings with 2–5 mutually exclusive choices. Prefer `Dropdown` when the list is long, and `OptionPicker` for a compact segmented control.
|
|
4
|
+
|
|
5
|
+
**Import:** `import { RadioGroup, RadioGroupOrientation } from '@ahrowe/ui'`
|
|
6
|
+
**Types:** `import type { RadioOption, RadioGroupProps, RadioValue } from '@ahrowe/ui'`
|
|
7
|
+
|
|
8
|
+
Follows the ARIA `radiogroup` pattern: one roving tab stop, arrow keys move focus **and** selection (skipping disabled options and wrapping around), Space/Enter selects the focused option.
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import { RadioGroup, RadioGroupOrientation, FormValidator } from '@ahrowe/ui';
|
|
12
|
+
import type { RadioOption } from '@ahrowe/ui';
|
|
13
|
+
|
|
14
|
+
const options: RadioOption[] = [
|
|
15
|
+
{ value: 'free', label: 'Free' },
|
|
16
|
+
{ value: 'pro', label: 'Pro' },
|
|
17
|
+
{ value: 'team', label: 'Team', disabled: true },
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
// Controlled
|
|
21
|
+
<RadioGroup options={options} value={plan} onChange={(v) => setPlan(v as string)} />
|
|
22
|
+
|
|
23
|
+
// Uncontrolled with an initial value
|
|
24
|
+
<RadioGroup options={options} defaultValue="free" />
|
|
25
|
+
|
|
26
|
+
// Horizontal layout
|
|
27
|
+
<RadioGroup options={options} value={plan} onChange={setPlan} orientation={RadioGroupOrientation.Horizontal} />
|
|
28
|
+
|
|
29
|
+
// Per-option descriptions
|
|
30
|
+
<RadioGroup
|
|
31
|
+
options={[
|
|
32
|
+
{ value: 'standard', label: 'Standard', description: '3–5 business days, free' },
|
|
33
|
+
{ value: 'express', label: 'Express', description: 'Next business day, €9.90' },
|
|
34
|
+
]}
|
|
35
|
+
value={shipping}
|
|
36
|
+
onChange={setShipping}
|
|
37
|
+
/>
|
|
38
|
+
|
|
39
|
+
// With FormValidator
|
|
40
|
+
const planValidator = new FormValidator<string | null>(null, [Validators.required()]);
|
|
41
|
+
<RadioGroup options={options} formValidator={planValidator} />
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**RadioGroupOrientation enum:** `RadioGroupOrientation.Vertical` (default) | `RadioGroupOrientation.Horizontal`
|
|
45
|
+
|
|
46
|
+
**RadioOption:**
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
interface RadioOption {
|
|
50
|
+
value: string | number;
|
|
51
|
+
label?: ReactNode; // falls back to `value`
|
|
52
|
+
description?: ReactNode; // secondary text under the label
|
|
53
|
+
disabled?: boolean; // disable just this option
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Key props:**
|
|
58
|
+
|
|
59
|
+
| Prop | Type | Description |
|
|
60
|
+
|------|------|-------------|
|
|
61
|
+
| `options` | `RadioOption[]` | The selectable options |
|
|
62
|
+
| `value` | `string \| number` | Controlled selected value |
|
|
63
|
+
| `defaultValue` | `string \| number` | Initial value when uncontrolled |
|
|
64
|
+
| `onChange` | `(value, event?) => void` | Fires with the newly selected value |
|
|
65
|
+
| `orientation` | `RadioGroupOrientation` | Layout direction (default `Vertical`) |
|
|
66
|
+
| `disabled` | `boolean` | Disable the whole group |
|
|
67
|
+
| `size` | `string` | Diameter of the radio circle (default `'18px'`) |
|
|
68
|
+
| `formValidator` | `FormValidator` | Connects to form validation |
|
|
69
|
+
| `errorMessage` | `string` | Manual error message (when not using a `formValidator`) |
|
|
70
|
+
| `isValid` | `boolean` | Manual valid state (default `true`) |
|
|
71
|
+
|
|
72
|
+
**Validation:** like `Input`, an errored group shows an error `Tooltip` and turns its unselected circles red. With a `formValidator` the error surfaces only after the field is *touched* (focus leaves the group), then on focus or hover; requires `<div id="bodyEnd"></div>` at the app root for the tooltip portal.
|
|
73
|
+
|
|
74
|
+
**Global defaults:** adopts `ConfigProvider` — e.g. `defaultProps={{ RadioGroup: { orientation: RadioGroupOrientation.Horizontal } }}`. See [ConfigProvider.md](ConfigProvider.md).
|
|
75
|
+
|
|
76
|
+
**Slots:** `root` `option` `radio` `dot` `label` `description`
|
package/docs/Sticky.md
CHANGED
|
@@ -26,10 +26,21 @@ import { Sticky } from '@ahrowe/ui';
|
|
|
26
26
|
<Sticky disabled={isEditing}>
|
|
27
27
|
<Header />
|
|
28
28
|
</Sticky>
|
|
29
|
+
|
|
30
|
+
// Two Stickies that overlap horizontally automatically stack — the second
|
|
31
|
+
// pins below the first's height instead of on top of it
|
|
32
|
+
<Sticky offsetTop={0}>
|
|
33
|
+
<TopBar />
|
|
34
|
+
</Sticky>
|
|
35
|
+
<Sticky offsetTop={0}>
|
|
36
|
+
<FilterBar />
|
|
37
|
+
</Sticky>
|
|
29
38
|
```
|
|
30
39
|
|
|
31
40
|
**How it works:** while stuck, the content switches to `position: fixed` (measured to keep the same width and horizontal position) and a placeholder of the same height takes its place in the flow. It tracks scroll on the window *and* any ancestor scroll container, so it works inside scrollable panels too — it always pins to the top of the viewport (offset by `offsetTop`).
|
|
32
41
|
|
|
42
|
+
**Stacking:** every mounted `Sticky` coordinates automatically, no extra markup needed. When more than one is stuck at the same time, a later one (in DOM order) that horizontally overlaps an earlier stuck one pins below it — `offsetTop` plus the overlapping ones' heights — instead of both landing on the same spot. Stickies that don't overlap horizontally (e.g. two half-width ones side by side under a full-width one) land at the same `top`, next to each other, rather than pushing each other down.
|
|
43
|
+
|
|
33
44
|
**Key props:**
|
|
34
45
|
|
|
35
46
|
| Prop | Type | Description |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahrowe/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"scripts": {
|
|
51
51
|
"dev": "vite",
|
|
52
52
|
"build": "vite build",
|
|
53
|
+
"build:demo": "vite build --base=/packages/ui/demo/ --outDir dist-demo",
|
|
53
54
|
"build:lib": "vite build --config vite.lib.config.ts",
|
|
54
55
|
"build:mcp": "vite build --config vite.mcp.config.ts",
|
|
55
56
|
"preview": "vite preview",
|