@fabio.caffarello/react-design-system 2.1.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 +114 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4238 -4079
- package/dist/index.js.map +1 -1
- package/dist/react-design-system.css +1 -1
- package/dist/server/index.cjs +28 -28
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +742 -626
- 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/dist/ui/tokens/colors/brand.d.ts +22 -0
- package/dist/ui/tokens/colors/index.d.ts +5 -4
- package/dist/ui/tokens/colors/primitives.d.ts +2 -2
- package/dist/ui/tokens/colors/semantic.d.ts +2 -2
- package/dist/ui/tokens/colors/types.d.ts +11 -4
- package/dist/ui/tokens/colors/utils.d.ts +2 -2
- package/dist/ui/tokens/index.d.ts +1 -1
- package/package.json +3 -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;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brand Primitive Palettes — TS mirror of src/styles/primitives/brand.css
|
|
3
|
+
*
|
|
4
|
+
* Brand-primary: institutional navy from brasil-a-vera globals.css.
|
|
5
|
+
* Brand-secondary: OKLCH-derived from ADR-024 brasil-a-vera purple
|
|
6
|
+
* (reproducible via scripts/derive-brand-secondary.mjs).
|
|
7
|
+
*
|
|
8
|
+
* Distinct from PRIMITIVE_COLORS Tailwind tones (indigo/pink/cyan/...)
|
|
9
|
+
* which stay honest to their official Tailwind v4 values. Semantic tokens
|
|
10
|
+
* point at these brand palettes, not at Tailwind tones.
|
|
11
|
+
*
|
|
12
|
+
* @brand brasil-a-vera (default, overridable)
|
|
13
|
+
*/
|
|
14
|
+
import type { ColorPalette } from "./types";
|
|
15
|
+
/**
|
|
16
|
+
* Brand Primary — institutional navy
|
|
17
|
+
*/
|
|
18
|
+
export declare const BRAND_PRIMARY: ColorPalette;
|
|
19
|
+
/**
|
|
20
|
+
* Brand Secondary — ADR-024 purple, OKLCH-derived (hue 295)
|
|
21
|
+
*/
|
|
22
|
+
export declare const BRAND_SECONDARY: ColorPalette;
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Design System - Color Tokens Index
|
|
3
3
|
*
|
|
4
4
|
* Central export for all color-related tokens and utilities.
|
|
5
5
|
*
|
|
6
|
-
* @brand
|
|
6
|
+
* @brand brasil-a-vera (default, overridable)
|
|
7
7
|
* @version 1.0.0
|
|
8
8
|
*/
|
|
9
9
|
export type { ColorScale, PrimitiveColorName, SemanticColorName, TextColorName, BgColorName, BorderColorName, StateColorName, ThemeMode, ThemeVariant, ColorToken, ColorPalette, SemanticColor, SemanticColorPalette, PrimitiveColors, ThemeColors, GetColorOptions, GetColorClassOptions, } from "./types";
|
|
10
10
|
export { COLOR_SCALES } from "./types";
|
|
11
|
+
export { BRAND_PRIMARY, BRAND_SECONDARY } from "./brand";
|
|
11
12
|
export { INDIGO, VIOLET, CYAN, SLATE, GRAY, EMERALD, GREEN, AMBER, YELLOW, ORANGE, ROSE, RED, SKY, BLUE, FUCHSIA, PINK, PURPLE, TEAL, LIME, PRIMITIVE_COLORS, getPrimitiveColor, getPrimitiveColorPalette, } from "./primitives";
|
|
12
13
|
export { SEMANTIC_COLORS, SEMANTIC_COLORS_LIGHT, SEMANTIC_COLORS_DARK, getSemanticColor, getSemanticColorRole, } from "./semantic";
|
|
13
14
|
export { getColor, getSemanticColorValue, getColorClass, getSemanticColorClass, getHoverColorClass, getFocusColorClass, getFocusRingClass, withOpacity, isLightColor, getContrastColor, blendColors, lighten, darken, } from "./utils";
|
|
14
15
|
export declare const BRAND_COLORS: {
|
|
15
16
|
readonly primary: {
|
|
16
|
-
readonly name: "
|
|
17
|
+
readonly name: "brand-primary";
|
|
17
18
|
readonly light: 400;
|
|
18
19
|
readonly default: 500;
|
|
19
20
|
readonly dark: 600;
|
|
20
21
|
};
|
|
21
22
|
readonly secondary: {
|
|
22
|
-
readonly name: "
|
|
23
|
+
readonly name: "brand-secondary";
|
|
23
24
|
readonly light: 400;
|
|
24
25
|
readonly default: 500;
|
|
25
26
|
readonly dark: 600;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Design System - Primitive Color Tokens
|
|
3
3
|
*
|
|
4
4
|
* Complete color palettes with all shades (50-950).
|
|
5
5
|
* These match the CSS variables defined in primitives/colors.css
|
|
6
6
|
*
|
|
7
|
-
* @brand
|
|
7
|
+
* @brand brasil-a-vera (default, overridable)
|
|
8
8
|
* @version 1.0.0
|
|
9
9
|
*/
|
|
10
10
|
import type { ColorPalette, ColorToken, ColorScale, PrimitiveColorName, PrimitiveColors } from "./types";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Design System - Semantic Color Tokens
|
|
3
3
|
*
|
|
4
4
|
* Semantic colors that reference primitive palettes.
|
|
5
5
|
* These are the colors you should use in components.
|
|
6
6
|
*
|
|
7
|
-
* @brand
|
|
7
|
+
* @brand brasil-a-vera (default, overridable)
|
|
8
8
|
* @version 1.0.0
|
|
9
9
|
*/
|
|
10
10
|
import type { SemanticColor, SemanticColorName, SemanticColorPalette, ColorToken } from "./types";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Design System - Color Token Types
|
|
3
3
|
*
|
|
4
4
|
* TypeScript types for the color system.
|
|
5
5
|
*
|
|
6
|
-
* @brand
|
|
6
|
+
* @brand brasil-a-vera (default, overridable)
|
|
7
7
|
* @version 1.0.0
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
@@ -17,8 +17,15 @@ export type ColorScale = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 90
|
|
|
17
17
|
export declare const COLOR_SCALES: ColorScale[];
|
|
18
18
|
/**
|
|
19
19
|
* Primitive color names (raw color palettes)
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
*
|
|
21
|
+
* Two families coexist:
|
|
22
|
+
* - Tailwind tones (indigo, violet, ..., lime) — honest to Tailwind v4 HEX.
|
|
23
|
+
* - Brand primitives (brand-primary, brand-secondary) — the design system's
|
|
24
|
+
* own scales, declared in src/styles/primitives/brand.css and mirrored
|
|
25
|
+
* in src/ui/tokens/colors/brand.ts. These are the reskin surface;
|
|
26
|
+
* semantic tokens reference them, not Tailwind tones.
|
|
27
|
+
*/
|
|
28
|
+
export type PrimitiveColorName = "brand-primary" | "brand-secondary" | "indigo" | "violet" | "cyan" | "slate" | "gray" | "emerald" | "green" | "amber" | "yellow" | "orange" | "rose" | "red" | "sky" | "blue" | "fuchsia" | "pink" | "purple" | "teal" | "lime";
|
|
22
29
|
/**
|
|
23
30
|
* Semantic color names (meaningful colors)
|
|
24
31
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Design System - Color Utilities
|
|
3
3
|
*
|
|
4
4
|
* Helper functions for working with colors.
|
|
5
5
|
*
|
|
6
|
-
* @brand
|
|
6
|
+
* @brand brasil-a-vera (default, overridable)
|
|
7
7
|
* @version 1.0.0
|
|
8
8
|
*/
|
|
9
9
|
import type { ColorToken, ColorScale, PrimitiveColorName, SemanticColorName, GetColorOptions, GetColorClassOptions } from "./types";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabio.caffarello/react-design-system",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "
|
|
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",
|
|
@@ -111,6 +112,7 @@
|
|
|
111
112
|
"@vitest/coverage-v8": "^4.1.8",
|
|
112
113
|
"autoprefixer": "^10.4.21",
|
|
113
114
|
"baseline-browser-mapping": "^2.10.32",
|
|
115
|
+
"culori": "^4.0.2",
|
|
114
116
|
"dependency-cruiser": "^17.3.6",
|
|
115
117
|
"eslint": "^10.4.1",
|
|
116
118
|
"eslint-plugin-react-hooks": "^5.2.0",
|