@sproutsocial/seeds-react-card 1.0.0 → 1.1.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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +24 -0
- package/dist/esm/index.js +10 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +30 -7
- package/dist/index.d.ts +30 -7
- package/dist/index.js +14 -21
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
- package/src/Card.tsx +1 -1
- package/src/CardTypes.ts +58 -29
- package/src/__tests__/CardTypes.typetest.tsx +1 -0
package/src/CardTypes.ts
CHANGED
|
@@ -50,36 +50,65 @@ export interface TypeCardStyles
|
|
|
50
50
|
|
|
51
51
|
type TypeOnClick = (event: React.MouseEvent | React.KeyboardEvent) => void;
|
|
52
52
|
|
|
53
|
+
type TypeGenericCard = {
|
|
54
|
+
/** role is used for to set accessibility properties,
|
|
55
|
+
* to determine styling and interaction behavior,
|
|
56
|
+
* and to determine which props should be allowed.*/
|
|
57
|
+
role: "link" | "button" | "checkbox" | "presentation";
|
|
58
|
+
/** When role is link, use href to determine the link destination.
|
|
59
|
+
* Required for role="link", disallowed for all other roles */
|
|
60
|
+
href?: string;
|
|
61
|
+
/** Required for role="button" and role="checkbox",
|
|
62
|
+
* discouraged for role="presentation", and disallowed for role="link" */
|
|
63
|
+
onClick?: TypeOnClick;
|
|
64
|
+
/** Indicates whether the card is selected.
|
|
65
|
+
* Required for role="checkbox", disallowed for all other roles */
|
|
66
|
+
selected?: boolean;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export type TypeLinkCardProps = {
|
|
70
|
+
role: "link";
|
|
71
|
+
href: string;
|
|
72
|
+
onClick?: never;
|
|
73
|
+
selected?: never;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type TypeButtonCardProps = {
|
|
77
|
+
role: "button";
|
|
78
|
+
href?: never;
|
|
79
|
+
onClick: TypeOnClick;
|
|
80
|
+
selected?: never;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type TypeCheckboxCardProps = {
|
|
84
|
+
role: "checkbox";
|
|
85
|
+
href?: never;
|
|
86
|
+
onClick: TypeOnClick;
|
|
87
|
+
selected: boolean;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export type TypePresentationCardProps = {
|
|
91
|
+
role: "presentation";
|
|
92
|
+
href?: never;
|
|
93
|
+
/**
|
|
94
|
+
* **Warning:**
|
|
95
|
+
* `role='presentation'` is outside of the accessibility tree.
|
|
96
|
+
* Using an `onClick` that performs a user action should likely be used
|
|
97
|
+
* with `role='button'` instead.
|
|
98
|
+
*/
|
|
99
|
+
onClick?: TypeOnClick;
|
|
100
|
+
selected?: never;
|
|
101
|
+
};
|
|
102
|
+
|
|
53
103
|
export type TypeCardConditions =
|
|
54
|
-
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
onClick: TypeOnClick;
|
|
63
|
-
}
|
|
64
|
-
| {
|
|
65
|
-
role: "checkbox";
|
|
66
|
-
href?: never;
|
|
67
|
-
onClick: TypeOnClick;
|
|
68
|
-
selected: boolean;
|
|
69
|
-
}
|
|
70
|
-
| {
|
|
71
|
-
role: "presentation";
|
|
72
|
-
href?: never;
|
|
73
|
-
/**
|
|
74
|
-
* **Warning:**
|
|
75
|
-
* `role='presentation'` is outside of the accessiblity tree. Using an `onClick` that performs a user action should likely be used
|
|
76
|
-
* with `role='button'` instead.
|
|
77
|
-
*/
|
|
78
|
-
onClick?: TypeOnClick;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export type TypeCardProps = TypeCardConditions &
|
|
82
|
-
React.PropsWithChildren<TypeCardStyles>;
|
|
104
|
+
| TypeLinkCardProps
|
|
105
|
+
| TypeButtonCardProps
|
|
106
|
+
| TypeCheckboxCardProps
|
|
107
|
+
| TypePresentationCardProps;
|
|
108
|
+
|
|
109
|
+
export type TypeCardProps = React.PropsWithChildren<TypeCardStyles> &
|
|
110
|
+
TypeGenericCard &
|
|
111
|
+
TypeCardConditions;
|
|
83
112
|
|
|
84
113
|
export interface TypeCardArea extends TypeSharedCardSystemProps {
|
|
85
114
|
$divider?: "top" | "bottom";
|
|
@@ -64,6 +64,7 @@ function CardTypes() {
|
|
|
64
64
|
<Card role="presentation" href="">
|
|
65
65
|
This is a card.
|
|
66
66
|
</Card>
|
|
67
|
+
{/* @ts-expect-error - test that selected is never allowed with role=presentation */}
|
|
67
68
|
<Card role="presentation" disabled={true} selected={true}>
|
|
68
69
|
This is a card.
|
|
69
70
|
</Card>
|