@wallarm-org/design-system 2.9.0 → 3.0.0-rc-feat-code-connect.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/README.md +3 -3
- package/dist/components/Avatar/Avatar.d.ts +3 -2
- package/dist/components/Avatar/Avatar.js +79 -60
- package/dist/components/Avatar/AvatarContent.d.ts +6 -0
- package/dist/components/Avatar/AvatarContent.js +47 -0
- package/dist/components/Avatar/AvatarContext.d.ts +4 -0
- package/dist/components/Avatar/AvatarContext.js +5 -0
- package/dist/components/Avatar/AvatarDescription.d.ts +6 -0
- package/dist/components/Avatar/AvatarDescription.js +87 -0
- package/dist/components/Avatar/AvatarFallback.d.ts +2 -2
- package/dist/components/Avatar/AvatarFallback.js +41 -34
- package/dist/components/Avatar/AvatarImage.js +19 -14
- package/dist/components/Avatar/AvatarName.d.ts +6 -0
- package/dist/components/Avatar/AvatarName.js +87 -0
- package/dist/components/Avatar/AvatarOverlay.js +24 -19
- package/dist/components/Avatar/classes.d.ts +17 -2
- package/dist/components/Avatar/classes.js +56 -8
- package/dist/components/Avatar/index.d.ts +3 -0
- package/dist/components/Avatar/index.js +3 -0
- package/dist/components/NavRail/NavRailItem.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/metadata/components.json +944 -99
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -96,13 +96,13 @@ pnpm build
|
|
|
96
96
|
|
|
97
97
|
Icons in `src/icons/` are generated from the [WADS-Iconography](https://www.figma.com/design/ezgUqbCqEBXqC4ViRausYIAN/WADS-Iconography?node-id=5702-845) Figma page — don't edit them by hand.
|
|
98
98
|
|
|
99
|
-
To get a `
|
|
99
|
+
To get a `FIGMA_ACCESS_TOKEN`:
|
|
100
100
|
|
|
101
101
|
1. Sign in to Figma with the account that can open WADS-Iconography (your Wallarm account, not a personal one).
|
|
102
102
|
2. Account menu (top left) → **Settings** → **Security** → **Personal access tokens** → **Generate new token**.
|
|
103
103
|
3. Name it (e.g. `wallarm-icons-sync`), pick an expiration, and set the scopes: **File content → Read-only**. Leave every other scope at **No access** — the sync only reads the page and exports SVGs.
|
|
104
104
|
4. Copy the token right away — Figma shows it only once.
|
|
105
|
-
5. Add `
|
|
105
|
+
5. Add `FIGMA_ACCESS_TOKEN=figd_…` to the repo-root `.env.local` (git-ignored). Never commit it or paste it into chats or PRs. If it leaks, revoke it on the same Settings page.
|
|
106
106
|
|
|
107
107
|
Then:
|
|
108
108
|
|
|
@@ -112,7 +112,7 @@ pnpm --filter @wallarm-org/design-system icons:sync --category 'Edit & Text' #
|
|
|
112
112
|
pnpm --filter @wallarm-org/design-system icons:sync --only Bell,BellOff # refresh just these
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
The command writes the component files, `src/icons/index.ts`, the gallery category (`module/const.ts`) and Code Connect (`module/Icons.figma.
|
|
115
|
+
The command writes the component files, `src/icons/index.ts`, the gallery category (`module/const.ts`) and Code Connect (`module/Icons.figma.batch.json` + its `Icons.figma.batch.ts` template). `scripts/icons/manifest.json` maps Figma nodes to component names, and also holds excluded nodes and the `keep` list of hand-maintained icons. When a new layer's name collides with an existing icon, map it there. Brand icons without a Neutral variant in Figma get a generated `*Neutral` twin. Commit with `[update-screenshots]` so CI refreshes the icon gallery baselines.
|
|
116
116
|
|
|
117
117
|
- [Storybook](https://wallarm.github.io/design-system/) - Interactive examples
|
|
118
118
|
- [NPM](https://www.npmjs.com/package/@wallarm-org/design-system) - NPM package
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ButtonHTMLAttributes, type FC, type HTMLAttributes, type Ref } from 'react';
|
|
2
2
|
import { Avatar as ArkAvatar } from '@ark-ui/react/avatar';
|
|
3
3
|
import type { VariantProps } from 'class-variance-authority';
|
|
4
4
|
import { type TestableProps } from '../../utils/testId.js';
|
|
@@ -26,7 +26,8 @@ type AvatarRootProps = ({
|
|
|
26
26
|
export type AvatarProps = AvatarBaseProps & AvatarRootProps;
|
|
27
27
|
/**
|
|
28
28
|
* A user's photo on a rounded plate, falling back to initials or an icon while the photo loads,
|
|
29
|
-
* when it fails, or when there is none.
|
|
29
|
+
* when it fails, or when there is none. Add `AvatarContent` for the user item: plate + name
|
|
30
|
+
* (+ description) in one row.
|
|
30
31
|
*/
|
|
31
32
|
export declare const Avatar: FC<AvatarProps>;
|
|
32
33
|
export {};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Children, isValidElement } from "react";
|
|
3
4
|
import { Avatar } from "@ark-ui/react/avatar";
|
|
4
5
|
import { cn } from "../../utils/cn.js";
|
|
5
6
|
import { TestIdProvider } from "../../utils/testId.js";
|
|
7
|
+
import { AvatarContent } from "./AvatarContent.js";
|
|
8
|
+
import { AvatarSizeProvider } from "./AvatarContext.js";
|
|
6
9
|
import { avatarVariants } from "./classes.js";
|
|
7
10
|
const Avatar_Avatar = (t0)=>{
|
|
8
|
-
const $ = c(
|
|
11
|
+
const $ = c(53);
|
|
9
12
|
let children;
|
|
10
13
|
let className;
|
|
11
14
|
let disabled;
|
|
@@ -15,14 +18,14 @@ const Avatar_Avatar = (t0)=>{
|
|
|
15
18
|
let onStatusChange;
|
|
16
19
|
let props;
|
|
17
20
|
let ref;
|
|
18
|
-
let size;
|
|
19
21
|
let t1;
|
|
20
22
|
let t2;
|
|
23
|
+
let t3;
|
|
21
24
|
let testId;
|
|
22
25
|
let type;
|
|
23
26
|
let value;
|
|
24
27
|
if ($[0] !== t0) {
|
|
25
|
-
({ ref, id, size, as:
|
|
28
|
+
({ ref, id, size: t1, as: t2, asChild: t3, disabled, type, name, value, form, onStatusChange, className, children, "data-testid": testId, ...props } = t0);
|
|
26
29
|
$[0] = t0;
|
|
27
30
|
$[1] = children;
|
|
28
31
|
$[2] = className;
|
|
@@ -33,9 +36,9 @@ const Avatar_Avatar = (t0)=>{
|
|
|
33
36
|
$[7] = onStatusChange;
|
|
34
37
|
$[8] = props;
|
|
35
38
|
$[9] = ref;
|
|
36
|
-
$[10] =
|
|
37
|
-
$[11] =
|
|
38
|
-
$[12] =
|
|
39
|
+
$[10] = t1;
|
|
40
|
+
$[11] = t2;
|
|
41
|
+
$[12] = t3;
|
|
39
42
|
$[13] = testId;
|
|
40
43
|
$[14] = type;
|
|
41
44
|
$[15] = value;
|
|
@@ -49,63 +52,66 @@ const Avatar_Avatar = (t0)=>{
|
|
|
49
52
|
onStatusChange = $[7];
|
|
50
53
|
props = $[8];
|
|
51
54
|
ref = $[9];
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
t1 = $[10];
|
|
56
|
+
t2 = $[11];
|
|
57
|
+
t3 = $[12];
|
|
55
58
|
testId = $[13];
|
|
56
59
|
type = $[14];
|
|
57
60
|
value = $[15];
|
|
58
61
|
}
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
|
|
62
|
+
const size = void 0 === t1 ? "lg" : t1;
|
|
63
|
+
const Tag = void 0 === t2 ? "span" : t2;
|
|
64
|
+
const asChild = void 0 === t3 ? false : t3;
|
|
65
|
+
const hasContent = Children.toArray(children).some(_temp);
|
|
66
|
+
const role = props.role ?? (!props["aria-label"] || asChild || "button" === Tag || hasContent ? void 0 : "img");
|
|
67
|
+
let t4;
|
|
63
68
|
if ($[16] !== Tag || $[17] !== asChild || $[18] !== disabled || $[19] !== form || $[20] !== name || $[21] !== value) {
|
|
64
|
-
|
|
69
|
+
t4 = asChild || "button" === Tag ? Object.fromEntries(Object.entries({
|
|
65
70
|
disabled,
|
|
66
71
|
name,
|
|
67
72
|
value,
|
|
68
73
|
form
|
|
69
|
-
}).filter(
|
|
74
|
+
}).filter(_temp2)) : {};
|
|
70
75
|
$[16] = Tag;
|
|
71
76
|
$[17] = asChild;
|
|
72
77
|
$[18] = disabled;
|
|
73
78
|
$[19] = form;
|
|
74
79
|
$[20] = name;
|
|
75
80
|
$[21] = value;
|
|
76
|
-
$[22] =
|
|
77
|
-
} else
|
|
78
|
-
const buttonAttributes =
|
|
79
|
-
|
|
81
|
+
$[22] = t4;
|
|
82
|
+
} else t4 = $[22];
|
|
83
|
+
const buttonAttributes = t4;
|
|
84
|
+
const t5 = size ?? "lg";
|
|
85
|
+
let t6;
|
|
80
86
|
if ($[23] !== id) {
|
|
81
|
-
|
|
87
|
+
t6 = id ? {
|
|
82
88
|
root: id
|
|
83
89
|
} : void 0;
|
|
84
90
|
$[23] = id;
|
|
85
|
-
$[24] =
|
|
86
|
-
} else
|
|
87
|
-
const
|
|
88
|
-
let
|
|
91
|
+
$[24] = t6;
|
|
92
|
+
} else t6 = $[24];
|
|
93
|
+
const t7 = ref;
|
|
94
|
+
let t8;
|
|
89
95
|
if ($[25] !== asChild || $[26] !== type) {
|
|
90
|
-
|
|
96
|
+
t8 = asChild && type ? {
|
|
91
97
|
type
|
|
92
98
|
} : {};
|
|
93
99
|
$[25] = asChild;
|
|
94
100
|
$[26] = type;
|
|
95
|
-
$[27] =
|
|
96
|
-
} else
|
|
97
|
-
let
|
|
101
|
+
$[27] = t8;
|
|
102
|
+
} else t8 = $[27];
|
|
103
|
+
let t9;
|
|
98
104
|
if ($[28] !== className || $[29] !== size) {
|
|
99
|
-
|
|
105
|
+
t9 = cn(avatarVariants({
|
|
100
106
|
size
|
|
101
107
|
}), className);
|
|
102
108
|
$[28] = className;
|
|
103
109
|
$[29] = size;
|
|
104
|
-
$[30] =
|
|
105
|
-
} else
|
|
106
|
-
let
|
|
110
|
+
$[30] = t9;
|
|
111
|
+
} else t9 = $[30];
|
|
112
|
+
let t10;
|
|
107
113
|
if ($[31] !== Tag || $[32] !== asChild || $[33] !== children || $[34] !== type) {
|
|
108
|
-
|
|
114
|
+
t10 = asChild ? children : /*#__PURE__*/ jsx(Tag, {
|
|
109
115
|
type: "button" === Tag ? type ?? "button" : void 0,
|
|
110
116
|
children: children
|
|
111
117
|
});
|
|
@@ -113,50 +119,63 @@ const Avatar_Avatar = (t0)=>{
|
|
|
113
119
|
$[32] = asChild;
|
|
114
120
|
$[33] = children;
|
|
115
121
|
$[34] = type;
|
|
116
|
-
$[35] =
|
|
117
|
-
} else
|
|
118
|
-
let
|
|
119
|
-
if ($[36] !== buttonAttributes || $[37] !== onStatusChange || $[38] !== props || $[39] !== role || $[40] !==
|
|
120
|
-
|
|
122
|
+
$[35] = t10;
|
|
123
|
+
} else t10 = $[35];
|
|
124
|
+
let t11;
|
|
125
|
+
if ($[36] !== buttonAttributes || $[37] !== onStatusChange || $[38] !== props || $[39] !== role || $[40] !== t10 || $[41] !== t6 || $[42] !== t7 || $[43] !== t8 || $[44] !== t9 || $[45] !== testId) {
|
|
126
|
+
t11 = /*#__PURE__*/ jsx(Avatar.Root, {
|
|
121
127
|
"data-slot": "avatar",
|
|
122
128
|
...props,
|
|
123
|
-
ids:
|
|
129
|
+
ids: t6,
|
|
124
130
|
...buttonAttributes,
|
|
125
|
-
ref:
|
|
131
|
+
ref: t7,
|
|
126
132
|
role: role,
|
|
127
|
-
...
|
|
133
|
+
...t8,
|
|
128
134
|
"data-testid": testId,
|
|
129
135
|
onStatusChange: onStatusChange,
|
|
130
|
-
className:
|
|
136
|
+
className: t9,
|
|
131
137
|
asChild: true,
|
|
132
|
-
children:
|
|
138
|
+
children: t10
|
|
133
139
|
});
|
|
134
140
|
$[36] = buttonAttributes;
|
|
135
141
|
$[37] = onStatusChange;
|
|
136
142
|
$[38] = props;
|
|
137
143
|
$[39] = role;
|
|
138
|
-
$[40] =
|
|
139
|
-
$[41] =
|
|
140
|
-
$[42] =
|
|
141
|
-
$[43] =
|
|
142
|
-
$[44] =
|
|
144
|
+
$[40] = t10;
|
|
145
|
+
$[41] = t6;
|
|
146
|
+
$[42] = t7;
|
|
147
|
+
$[43] = t8;
|
|
148
|
+
$[44] = t9;
|
|
143
149
|
$[45] = testId;
|
|
144
|
-
$[46] =
|
|
145
|
-
} else
|
|
146
|
-
let
|
|
147
|
-
if ($[47] !==
|
|
148
|
-
|
|
150
|
+
$[46] = t11;
|
|
151
|
+
} else t11 = $[46];
|
|
152
|
+
let t12;
|
|
153
|
+
if ($[47] !== t11 || $[48] !== t5) {
|
|
154
|
+
t12 = /*#__PURE__*/ jsx(AvatarSizeProvider, {
|
|
155
|
+
value: t5,
|
|
156
|
+
children: t11
|
|
157
|
+
});
|
|
158
|
+
$[47] = t11;
|
|
159
|
+
$[48] = t5;
|
|
160
|
+
$[49] = t12;
|
|
161
|
+
} else t12 = $[49];
|
|
162
|
+
let t13;
|
|
163
|
+
if ($[50] !== t12 || $[51] !== testId) {
|
|
164
|
+
t13 = /*#__PURE__*/ jsx(TestIdProvider, {
|
|
149
165
|
value: testId,
|
|
150
|
-
children:
|
|
166
|
+
children: t12
|
|
151
167
|
});
|
|
152
|
-
$[
|
|
153
|
-
$[
|
|
154
|
-
$[
|
|
155
|
-
} else
|
|
156
|
-
return
|
|
168
|
+
$[50] = t12;
|
|
169
|
+
$[51] = testId;
|
|
170
|
+
$[52] = t13;
|
|
171
|
+
} else t13 = $[52];
|
|
172
|
+
return t13;
|
|
157
173
|
};
|
|
158
174
|
Avatar_Avatar.displayName = "Avatar";
|
|
159
|
-
function _temp(
|
|
175
|
+
function _temp(child) {
|
|
176
|
+
return /*#__PURE__*/ isValidElement(child) && child.type === AvatarContent;
|
|
177
|
+
}
|
|
178
|
+
function _temp2(t0) {
|
|
160
179
|
const [, v] = t0;
|
|
161
180
|
return void 0 !== v;
|
|
162
181
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FC, HTMLAttributes, Ref } from 'react';
|
|
2
|
+
export interface AvatarContentProps extends HTMLAttributes<HTMLSpanElement> {
|
|
3
|
+
ref?: Ref<HTMLSpanElement>;
|
|
4
|
+
}
|
|
5
|
+
/** The text beside the plate — `AvatarName` with an optional `AvatarDescription` under it. */
|
|
6
|
+
export declare const AvatarContent: FC<AvatarContentProps>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { useTestId } from "../../utils/testId.js";
|
|
5
|
+
import { avatarContentClassNames } from "./classes.js";
|
|
6
|
+
const AvatarContent = (t0)=>{
|
|
7
|
+
const $ = c(11);
|
|
8
|
+
let className;
|
|
9
|
+
let props;
|
|
10
|
+
let ref;
|
|
11
|
+
if ($[0] !== t0) {
|
|
12
|
+
({ ref, className, ...props } = t0);
|
|
13
|
+
$[0] = t0;
|
|
14
|
+
$[1] = className;
|
|
15
|
+
$[2] = props;
|
|
16
|
+
$[3] = ref;
|
|
17
|
+
} else {
|
|
18
|
+
className = $[1];
|
|
19
|
+
props = $[2];
|
|
20
|
+
ref = $[3];
|
|
21
|
+
}
|
|
22
|
+
const testId = useTestId("content");
|
|
23
|
+
let t1;
|
|
24
|
+
if ($[4] !== className) {
|
|
25
|
+
t1 = cn(avatarContentClassNames, className);
|
|
26
|
+
$[4] = className;
|
|
27
|
+
$[5] = t1;
|
|
28
|
+
} else t1 = $[5];
|
|
29
|
+
let t2;
|
|
30
|
+
if ($[6] !== props || $[7] !== ref || $[8] !== t1 || $[9] !== testId) {
|
|
31
|
+
t2 = /*#__PURE__*/ jsx("span", {
|
|
32
|
+
...props,
|
|
33
|
+
ref: ref,
|
|
34
|
+
"data-slot": "avatar-content",
|
|
35
|
+
"data-testid": testId,
|
|
36
|
+
className: t1
|
|
37
|
+
});
|
|
38
|
+
$[6] = props;
|
|
39
|
+
$[7] = ref;
|
|
40
|
+
$[8] = t1;
|
|
41
|
+
$[9] = testId;
|
|
42
|
+
$[10] = t2;
|
|
43
|
+
} else t2 = $[10];
|
|
44
|
+
return t2;
|
|
45
|
+
};
|
|
46
|
+
AvatarContent.displayName = "AvatarContent";
|
|
47
|
+
export { AvatarContent };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FC, HTMLAttributes, Ref } from 'react';
|
|
2
|
+
export interface AvatarDescriptionProps extends HTMLAttributes<HTMLSpanElement> {
|
|
3
|
+
ref?: Ref<HTMLSpanElement>;
|
|
4
|
+
}
|
|
5
|
+
/** A second line under the name (e.g. the email), on one line, truncated with an ellipsis; the full text shows in a tooltip when it overflows. */
|
|
6
|
+
export declare const AvatarDescription: FC<AvatarDescriptionProps>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { useTestId } from "../../utils/testId.js";
|
|
5
|
+
import { OverflowTooltip, OverflowTooltipContent, OverflowTooltipTrigger } from "../OverflowTooltip/index.js";
|
|
6
|
+
import { useAvatarSize } from "./AvatarContext.js";
|
|
7
|
+
import { avatarDescriptionVariants } from "./classes.js";
|
|
8
|
+
const AvatarDescription = (t0)=>{
|
|
9
|
+
const $ = c(21);
|
|
10
|
+
let children;
|
|
11
|
+
let className;
|
|
12
|
+
let props;
|
|
13
|
+
let ref;
|
|
14
|
+
if ($[0] !== t0) {
|
|
15
|
+
({ ref, className, children, ...props } = t0);
|
|
16
|
+
$[0] = t0;
|
|
17
|
+
$[1] = children;
|
|
18
|
+
$[2] = className;
|
|
19
|
+
$[3] = props;
|
|
20
|
+
$[4] = ref;
|
|
21
|
+
} else {
|
|
22
|
+
children = $[1];
|
|
23
|
+
className = $[2];
|
|
24
|
+
props = $[3];
|
|
25
|
+
ref = $[4];
|
|
26
|
+
}
|
|
27
|
+
const testId = useTestId("description");
|
|
28
|
+
const size = useAvatarSize();
|
|
29
|
+
const t1 = ref;
|
|
30
|
+
let t2;
|
|
31
|
+
if ($[5] !== className || $[6] !== size) {
|
|
32
|
+
t2 = cn(avatarDescriptionVariants({
|
|
33
|
+
size
|
|
34
|
+
}), className);
|
|
35
|
+
$[5] = className;
|
|
36
|
+
$[6] = size;
|
|
37
|
+
$[7] = t2;
|
|
38
|
+
} else t2 = $[7];
|
|
39
|
+
let t3;
|
|
40
|
+
if ($[8] !== children || $[9] !== props || $[10] !== t2 || $[11] !== testId) {
|
|
41
|
+
t3 = /*#__PURE__*/ jsx("span", {
|
|
42
|
+
...props,
|
|
43
|
+
"data-slot": "avatar-description",
|
|
44
|
+
"data-testid": testId,
|
|
45
|
+
className: t2,
|
|
46
|
+
children: children
|
|
47
|
+
});
|
|
48
|
+
$[8] = children;
|
|
49
|
+
$[9] = props;
|
|
50
|
+
$[10] = t2;
|
|
51
|
+
$[11] = testId;
|
|
52
|
+
$[12] = t3;
|
|
53
|
+
} else t3 = $[12];
|
|
54
|
+
let t4;
|
|
55
|
+
if ($[13] !== t1 || $[14] !== t3) {
|
|
56
|
+
t4 = /*#__PURE__*/ jsx(OverflowTooltipTrigger, {
|
|
57
|
+
ref: t1,
|
|
58
|
+
children: t3
|
|
59
|
+
});
|
|
60
|
+
$[13] = t1;
|
|
61
|
+
$[14] = t3;
|
|
62
|
+
$[15] = t4;
|
|
63
|
+
} else t4 = $[15];
|
|
64
|
+
let t5;
|
|
65
|
+
if ($[16] !== children) {
|
|
66
|
+
t5 = /*#__PURE__*/ jsx(OverflowTooltipContent, {
|
|
67
|
+
children: children
|
|
68
|
+
});
|
|
69
|
+
$[16] = children;
|
|
70
|
+
$[17] = t5;
|
|
71
|
+
} else t5 = $[17];
|
|
72
|
+
let t6;
|
|
73
|
+
if ($[18] !== t4 || $[19] !== t5) {
|
|
74
|
+
t6 = /*#__PURE__*/ jsxs(OverflowTooltip, {
|
|
75
|
+
children: [
|
|
76
|
+
t4,
|
|
77
|
+
t5
|
|
78
|
+
]
|
|
79
|
+
});
|
|
80
|
+
$[18] = t4;
|
|
81
|
+
$[19] = t5;
|
|
82
|
+
$[20] = t6;
|
|
83
|
+
} else t6 = $[20];
|
|
84
|
+
return t6;
|
|
85
|
+
};
|
|
86
|
+
AvatarDescription.displayName = "AvatarDescription";
|
|
87
|
+
export { AvatarDescription };
|
|
@@ -2,10 +2,10 @@ import type { ComponentType, FC, HTMLAttributes, Ref } from 'react';
|
|
|
2
2
|
import { type SvgIconProps } from '../../icons/index.js';
|
|
3
3
|
export interface AvatarFallbackProps extends HTMLAttributes<HTMLSpanElement> {
|
|
4
4
|
ref?: Ref<HTMLSpanElement>;
|
|
5
|
-
/** Initials are taken from this: first letter of the first and of the last word. */
|
|
5
|
+
/** Initials are taken from this: first letter of the first and of the last word (first word only at `sm`). */
|
|
6
6
|
name?: string;
|
|
7
7
|
/** Shown when there are no children and `name` gives no initials. */
|
|
8
8
|
icon?: ComponentType<SvgIconProps>;
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
10
|
+
/** The plate: shown while the photo loads, when it fails, and when there is none. */
|
|
11
11
|
export declare const AvatarFallback: FC<AvatarFallbackProps>;
|
|
@@ -5,9 +5,10 @@ import { UserRound } from "../../icons/index.js";
|
|
|
5
5
|
import { cn } from "../../utils/cn.js";
|
|
6
6
|
import { getInitials } from "../../utils/getInitials.js";
|
|
7
7
|
import { useTestId } from "../../utils/testId.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useAvatarSize } from "./AvatarContext.js";
|
|
9
|
+
import { avatarFallbackVariants, avatarPlateVariants } from "./classes.js";
|
|
9
10
|
const AvatarFallback = (t0)=>{
|
|
10
|
-
const $ = c(
|
|
11
|
+
const $ = c(24);
|
|
11
12
|
let children;
|
|
12
13
|
let className;
|
|
13
14
|
let name;
|
|
@@ -33,51 +34,57 @@ const AvatarFallback = (t0)=>{
|
|
|
33
34
|
}
|
|
34
35
|
const Icon = void 0 === t1 ? UserRound : t1;
|
|
35
36
|
const testId = useTestId("fallback");
|
|
37
|
+
const size = useAvatarSize();
|
|
36
38
|
let t2;
|
|
37
|
-
if ($[7] !== name) {
|
|
38
|
-
t2 = name ? getInitials(name) : "";
|
|
39
|
+
if ($[7] !== name || $[8] !== size) {
|
|
40
|
+
t2 = name ? "sm" === size ? name.trim().split(/\s+/).map(getInitials).find(Boolean) ?? "" : getInitials(name) : "";
|
|
39
41
|
$[7] = name;
|
|
40
|
-
$[8] =
|
|
41
|
-
|
|
42
|
+
$[8] = size;
|
|
43
|
+
$[9] = t2;
|
|
44
|
+
} else t2 = $[9];
|
|
42
45
|
const initials = t2;
|
|
43
46
|
const showsInitials = null == children && "" !== initials;
|
|
44
|
-
|
|
47
|
+
let t3;
|
|
48
|
+
if ($[10] !== className || $[11] !== showsInitials || $[12] !== size) {
|
|
49
|
+
t3 = cn(avatarPlateVariants({
|
|
50
|
+
size
|
|
51
|
+
}), avatarFallbackVariants({
|
|
52
|
+
initials: showsInitials
|
|
53
|
+
}), className);
|
|
54
|
+
$[10] = className;
|
|
55
|
+
$[11] = showsInitials;
|
|
56
|
+
$[12] = size;
|
|
57
|
+
$[13] = t3;
|
|
58
|
+
} else t3 = $[13];
|
|
45
59
|
let t4;
|
|
46
|
-
if ($[
|
|
47
|
-
t4 =
|
|
48
|
-
$[9] = className;
|
|
49
|
-
$[10] = t3;
|
|
50
|
-
$[11] = t4;
|
|
51
|
-
} else t4 = $[11];
|
|
52
|
-
let t5;
|
|
53
|
-
if ($[12] !== Icon || $[13] !== children || $[14] !== initials) {
|
|
54
|
-
t5 = children ?? (initials || /*#__PURE__*/ jsx(Icon, {
|
|
60
|
+
if ($[14] !== Icon || $[15] !== children || $[16] !== initials) {
|
|
61
|
+
t4 = children ?? (initials || /*#__PURE__*/ jsx(Icon, {
|
|
55
62
|
size: "md"
|
|
56
63
|
}));
|
|
57
|
-
$[
|
|
58
|
-
$[
|
|
59
|
-
$[
|
|
60
|
-
$[
|
|
61
|
-
} else
|
|
62
|
-
let
|
|
63
|
-
if ($[
|
|
64
|
-
|
|
64
|
+
$[14] = Icon;
|
|
65
|
+
$[15] = children;
|
|
66
|
+
$[16] = initials;
|
|
67
|
+
$[17] = t4;
|
|
68
|
+
} else t4 = $[17];
|
|
69
|
+
let t5;
|
|
70
|
+
if ($[18] !== props || $[19] !== ref || $[20] !== t3 || $[21] !== t4 || $[22] !== testId) {
|
|
71
|
+
t5 = /*#__PURE__*/ jsx(Avatar.Fallback, {
|
|
65
72
|
"aria-hidden": true,
|
|
66
73
|
...props,
|
|
67
74
|
ref: ref,
|
|
68
75
|
"data-slot": "avatar-fallback",
|
|
69
76
|
"data-testid": testId,
|
|
70
|
-
className:
|
|
71
|
-
children:
|
|
77
|
+
className: t3,
|
|
78
|
+
children: t4
|
|
72
79
|
});
|
|
73
|
-
$[
|
|
74
|
-
$[
|
|
75
|
-
$[
|
|
76
|
-
$[
|
|
77
|
-
$[
|
|
78
|
-
$[
|
|
79
|
-
} else
|
|
80
|
-
return
|
|
80
|
+
$[18] = props;
|
|
81
|
+
$[19] = ref;
|
|
82
|
+
$[20] = t3;
|
|
83
|
+
$[21] = t4;
|
|
84
|
+
$[22] = testId;
|
|
85
|
+
$[23] = t5;
|
|
86
|
+
} else t5 = $[23];
|
|
87
|
+
return t5;
|
|
81
88
|
};
|
|
82
89
|
AvatarFallback.displayName = "AvatarFallback";
|
|
83
90
|
export { AvatarFallback };
|
|
@@ -3,9 +3,10 @@ import { c } from "react/compiler-runtime";
|
|
|
3
3
|
import { Avatar } from "@ark-ui/react/avatar";
|
|
4
4
|
import { cn } from "../../utils/cn.js";
|
|
5
5
|
import { useTestId } from "../../utils/testId.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useAvatarSize } from "./AvatarContext.js";
|
|
7
|
+
import { avatarImageClassNames, avatarPlateVariants } from "./classes.js";
|
|
7
8
|
const AvatarImage = (t0)=>{
|
|
8
|
-
const $ = c(
|
|
9
|
+
const $ = c(14);
|
|
9
10
|
let className;
|
|
10
11
|
let props;
|
|
11
12
|
let ref;
|
|
@@ -25,14 +26,18 @@ const AvatarImage = (t0)=>{
|
|
|
25
26
|
}
|
|
26
27
|
const alt = void 0 === t1 ? "" : t1;
|
|
27
28
|
const testId = useTestId("image");
|
|
29
|
+
const size = useAvatarSize();
|
|
28
30
|
let t2;
|
|
29
|
-
if ($[5] !== className) {
|
|
30
|
-
t2 = cn(
|
|
31
|
+
if ($[5] !== className || $[6] !== size) {
|
|
32
|
+
t2 = cn(avatarPlateVariants({
|
|
33
|
+
size
|
|
34
|
+
}), avatarImageClassNames, className);
|
|
31
35
|
$[5] = className;
|
|
32
|
-
$[6] =
|
|
33
|
-
|
|
36
|
+
$[6] = size;
|
|
37
|
+
$[7] = t2;
|
|
38
|
+
} else t2 = $[7];
|
|
34
39
|
let t3;
|
|
35
|
-
if ($[
|
|
40
|
+
if ($[8] !== alt || $[9] !== props || $[10] !== ref || $[11] !== t2 || $[12] !== testId) {
|
|
36
41
|
t3 = /*#__PURE__*/ jsx(Avatar.Image, {
|
|
37
42
|
...props,
|
|
38
43
|
ref: ref,
|
|
@@ -41,13 +46,13 @@ const AvatarImage = (t0)=>{
|
|
|
41
46
|
"data-testid": testId,
|
|
42
47
|
className: t2
|
|
43
48
|
});
|
|
44
|
-
$[
|
|
45
|
-
$[
|
|
46
|
-
$[
|
|
47
|
-
$[
|
|
48
|
-
$[
|
|
49
|
-
$[
|
|
50
|
-
} else t3 = $[
|
|
49
|
+
$[8] = alt;
|
|
50
|
+
$[9] = props;
|
|
51
|
+
$[10] = ref;
|
|
52
|
+
$[11] = t2;
|
|
53
|
+
$[12] = testId;
|
|
54
|
+
$[13] = t3;
|
|
55
|
+
} else t3 = $[13];
|
|
51
56
|
return t3;
|
|
52
57
|
};
|
|
53
58
|
AvatarImage.displayName = "AvatarImage";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FC, HTMLAttributes, Ref } from 'react';
|
|
2
|
+
export interface AvatarNameProps extends HTMLAttributes<HTMLSpanElement> {
|
|
3
|
+
ref?: Ref<HTMLSpanElement>;
|
|
4
|
+
}
|
|
5
|
+
/** The person's name, on one line, truncated with an ellipsis; the full text shows in a tooltip when it overflows. */
|
|
6
|
+
export declare const AvatarName: FC<AvatarNameProps>;
|