@fabio.caffarello/react-design-system 3.0.0 → 3.1.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 +80 -80
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4237 -4143
- package/dist/index.js.map +1 -1
- package/dist/react-design-system.css +1 -1
- package/dist/server/index.cjs +19 -19
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +620 -542
- package/dist/server/index.js.map +1 -1
- package/dist/ui/primitives/Button/Button.d.ts +34 -18
- package/dist/ui/primitives/Chip/Chip.d.ts +39 -3
- package/package.json +2 -1
|
@@ -13,39 +13,55 @@ export interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement
|
|
|
13
13
|
as?: ElementType;
|
|
14
14
|
href?: string;
|
|
15
15
|
target?: string;
|
|
16
|
+
/**
|
|
17
|
+
* When true, render via Radix `Slot`: classes, ARIA, ref and remaining
|
|
18
|
+
* props are projected onto the single child element instead of an
|
|
19
|
+
* intrinsic `<button>`. The child keeps its own element type and props
|
|
20
|
+
* intact — including framework-native props like `<Link href prefetch>`.
|
|
21
|
+
*
|
|
22
|
+
* `asChild` takes precedence over `as`: if both are supplied, `as` is
|
|
23
|
+
* ignored and a dev-only warning is logged.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <Button asChild variant="primary">
|
|
28
|
+
* <Link href="/profile" prefetch>Open profile</Link>
|
|
29
|
+
* </Button>
|
|
30
|
+
* // → <a class="…button classes" href="/profile" data-prefetch>Open profile</a>
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
asChild?: boolean;
|
|
16
34
|
}
|
|
17
35
|
/**
|
|
18
36
|
* Button Component
|
|
19
37
|
*
|
|
20
|
-
* A styled button
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
38
|
+
* A styled button with variants, sizes, and loading states.
|
|
39
|
+
*
|
|
40
|
+
* Polymorphism — two APIs:
|
|
41
|
+
* - `as` (legacy): swap the root element type. `<Button as={Link} href="…">`.
|
|
42
|
+
* - `asChild` (recommended): project Button's styling onto the single
|
|
43
|
+
* child element. Idiomatic Radix Slot pattern, preserves the child's
|
|
44
|
+
* own props and TS type (e.g. `<Link href prefetch>`). When `asChild`
|
|
45
|
+
* is true, `as` is ignored.
|
|
24
46
|
*
|
|
25
47
|
* @example
|
|
26
48
|
* ```tsx
|
|
27
49
|
* // Basic usage
|
|
28
|
-
* <Button variant="primary" size="md" onClick={handleClick}>
|
|
29
|
-
* Click me
|
|
30
|
-
* </Button>
|
|
50
|
+
* <Button variant="primary" size="md" onClick={handleClick}>Click me</Button>
|
|
31
51
|
*
|
|
32
52
|
* // With icons
|
|
33
|
-
* <Button leftIcon={<Icon />} rightIcon={<Icon />}>
|
|
34
|
-
* Action
|
|
35
|
-
* </Button>
|
|
53
|
+
* <Button leftIcon={<Icon />} rightIcon={<Icon />}>Action</Button>
|
|
36
54
|
*
|
|
37
55
|
* // Loading state
|
|
38
|
-
* <Button isLoading loadingText="Saving...">
|
|
39
|
-
* Save
|
|
40
|
-
* </Button>
|
|
56
|
+
* <Button isLoading loadingText="Saving...">Save</Button>
|
|
41
57
|
*
|
|
42
|
-
* //
|
|
43
|
-
* <Button
|
|
44
|
-
*
|
|
58
|
+
* // Polymorphic via asChild (preserves Next Link's TS type and native props)
|
|
59
|
+
* <Button asChild variant="primary">
|
|
60
|
+
* <Link href="/page" prefetch>Open</Link>
|
|
45
61
|
* </Button>
|
|
46
62
|
*
|
|
47
|
-
* //
|
|
48
|
-
* <Button
|
|
63
|
+
* // Polymorphic via legacy `as`
|
|
64
|
+
* <Button as="a" href="/page">Navigate</Button>
|
|
49
65
|
* ```
|
|
50
66
|
*/
|
|
51
67
|
declare const Button: import("react").NamedExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,17 +1,53 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
export type ChipVariant = "default" | "outlined" | "filled";
|
|
3
3
|
export type ChipSize = "sm" | "md" | "lg";
|
|
4
|
-
|
|
4
|
+
interface ChipBaseProps {
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
variant?: ChipVariant;
|
|
7
7
|
size?: ChipSize;
|
|
8
|
-
onRemove?: () => void;
|
|
9
8
|
selected?: boolean;
|
|
10
9
|
disabled?: boolean;
|
|
11
10
|
className?: string;
|
|
12
11
|
"aria-label"?: string;
|
|
13
|
-
onClick?: () => void;
|
|
14
12
|
tabIndex?: number;
|
|
15
13
|
}
|
|
14
|
+
interface ChipStandardProps extends ChipBaseProps {
|
|
15
|
+
asChild?: false;
|
|
16
|
+
onRemove?: () => void;
|
|
17
|
+
onClick?: () => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `asChild` collapses the chip into a single node provided by the
|
|
21
|
+
* consumer (typically `<Link>`). The non-interactive frame + inner
|
|
22
|
+
* label-button + X structure is intentionally NOT rendered — the child
|
|
23
|
+
* IS the chip. As a consequence:
|
|
24
|
+
*
|
|
25
|
+
* - `onClick` and `onRemove` are forbidden at the type level. The
|
|
26
|
+
* child's own click handler (and `href`) is what fires; consumers
|
|
27
|
+
* who need a removable selected filter use the standard
|
|
28
|
+
* (non-asChild) form.
|
|
29
|
+
* - `selected` still applies the visual classes via `chipVariants`,
|
|
30
|
+
* but NO `aria-pressed` is emitted. Toggle-button semantics on
|
|
31
|
+
* `<a>` would lie — a link isn't a two-state control. Consumers
|
|
32
|
+
* that need the selected route surfaced to AT users should pass
|
|
33
|
+
* `aria-current="page"` (or similar) directly on the child Link.
|
|
34
|
+
*
|
|
35
|
+
* @see `.claude/rules/components.md` and the inline a11y notes below.
|
|
36
|
+
*/
|
|
37
|
+
interface ChipAsChildProps extends ChipBaseProps {
|
|
38
|
+
asChild: true;
|
|
39
|
+
/**
|
|
40
|
+
* `onClick` is forbidden when `asChild` is true — the child element
|
|
41
|
+
* owns interaction. Pass the handler (or `href`) on the child.
|
|
42
|
+
*/
|
|
43
|
+
onClick?: never;
|
|
44
|
+
/**
|
|
45
|
+
* `onRemove` is forbidden when `asChild` is true — the collapsed
|
|
46
|
+
* node has no slot for an X button. Use the standard (non-asChild)
|
|
47
|
+
* form when removal is required.
|
|
48
|
+
*/
|
|
49
|
+
onRemove?: never;
|
|
50
|
+
}
|
|
51
|
+
export type ChipProps = ChipStandardProps | ChipAsChildProps;
|
|
16
52
|
declare const Chip: import("react").ForwardRefExoticComponent<ChipProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
17
53
|
export default Chip;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabio.caffarello/react-design-system",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.1.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
+
"@radix-ui/react-slot": "^1.2.4",
|
|
80
81
|
"@tailwindcss/postcss": "^4.1.16",
|
|
81
82
|
"class-variance-authority": "^0.7.1",
|
|
82
83
|
"clsx": "^2.1.1",
|