@dxos/react-ui 0.3.5-next.5910692 → 0.3.5-next.b7dc283
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/lib/browser/index.mjs +47 -64
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/Avatars/Avatar.d.ts +6 -5
- package/dist/types/src/components/Avatars/Avatar.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts +2 -0
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/AvatarGroup.d.ts +4 -4
- package/dist/types/src/components/Avatars/AvatarGroup.d.ts.map +1 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.d.ts +5 -5
- package/dist/types/src/components/Buttons/Button.d.ts +2 -2
- package/dist/types/src/components/Buttons/Button.stories.d.ts +1 -1
- package/dist/types/src/components/Buttons/Toggle.d.ts +1 -1
- package/dist/types/src/components/Buttons/ToggleGroup.d.ts +3 -3
- package/dist/types/src/components/Card/Card.d.ts +1 -1
- package/dist/types/src/components/Card/Card.stories.d.ts +1 -1
- package/dist/types/src/components/DropdownMenu/DropdownMenu.d.ts +1 -1
- package/dist/types/src/components/Input/Input.d.ts +7 -7
- package/dist/types/src/components/Link/Link.d.ts +1 -1
- package/dist/types/src/components/List/List.d.ts +1 -1
- package/dist/types/src/components/Main/Main.d.ts +4 -4
- package/dist/types/src/components/Main/Main.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.d.ts +2 -2
- package/dist/types/src/components/Popover/Popover.d.ts +1 -1
- package/dist/types/src/components/Select/Select.d.ts +1 -1
- package/dist/types/src/components/Tag/Tag.d.ts +1 -1
- package/dist/types/src/components/Toast/Toast.d.ts +2 -2
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +5 -5
- package/dist/types/src/playground/Surfaces.stories.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/components/Avatars/Avatar.stories.tsx +51 -15
- package/src/components/Avatars/Avatar.tsx +74 -68
- package/src/components/Avatars/AvatarGroup.tsx +2 -1
- package/src/components/Main/Main.tsx +1 -0
- package/src/playground/Surfaces.stories.tsx +26 -5
|
@@ -4,7 +4,7 @@ export * from "@dxos/react-ui-types";
|
|
|
4
4
|
export * from "@dxos/react-hooks";
|
|
5
5
|
|
|
6
6
|
// packages/ui/react-ui/src/components/Avatars/Avatar.tsx
|
|
7
|
-
import { Root as AvatarRootPrimitive,
|
|
7
|
+
import { Root as AvatarRootPrimitive, Fallback as AvatarFallbackPrimitive } from "@radix-ui/react-avatar";
|
|
8
8
|
import { createContext as createContext2 } from "@radix-ui/react-context";
|
|
9
9
|
import { Primitive } from "@radix-ui/react-primitive";
|
|
10
10
|
import { Slot } from "@radix-ui/react-slot";
|
|
@@ -111,7 +111,7 @@ var useVisualViewport = (deps) => {
|
|
|
111
111
|
// packages/ui/react-ui/src/components/Avatars/Avatar.tsx
|
|
112
112
|
var AVATAR_NAME = "Avatar";
|
|
113
113
|
var [AvatarProvider, useAvatarContext] = createContext2(AVATAR_NAME);
|
|
114
|
-
var AvatarRoot = ({ size = 10, variant = "circle", status, animation, children, labelId: propsLabelId, descriptionId: propsDescriptionId, maskId: propsMaskId, inGroup }) => {
|
|
114
|
+
var AvatarRoot = ({ size = 10, variant = "circle", status, animation, children, labelId: propsLabelId, descriptionId: propsDescriptionId, maskId: propsMaskId, inGroup, color }) => {
|
|
115
115
|
const labelId = useId("avatar__label", propsLabelId);
|
|
116
116
|
const descriptionId = useId("avatar__description", propsDescriptionId);
|
|
117
117
|
const maskId = useId("avatar__mask", propsMaskId);
|
|
@@ -123,18 +123,19 @@ var AvatarRoot = ({ size = 10, variant = "circle", status, animation, children,
|
|
|
123
123
|
variant,
|
|
124
124
|
status,
|
|
125
125
|
animation,
|
|
126
|
-
inGroup
|
|
126
|
+
inGroup,
|
|
127
|
+
color
|
|
127
128
|
}, children);
|
|
128
129
|
};
|
|
129
|
-
var
|
|
130
|
-
var rx = 8;
|
|
130
|
+
var rx = "0.25rem";
|
|
131
131
|
var AvatarFrame = /* @__PURE__ */ forwardRef(({ classNames, children, ...props }, forwardedRef) => {
|
|
132
|
-
const { size, variant, labelId, descriptionId, maskId, inGroup, status, animation } = useAvatarContext("AvatarFrame");
|
|
132
|
+
const { size, variant, labelId, descriptionId, maskId, inGroup, status, animation, color } = useAvatarContext("AvatarFrame");
|
|
133
133
|
const { tx } = useThemeContext();
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
const ringWidth = 2;
|
|
137
|
-
const
|
|
134
|
+
const numericSize = size === "px" ? 1 : Number(size);
|
|
135
|
+
const sizePx = numericSize * 4;
|
|
136
|
+
const ringWidth = numericSize > 4 ? 2 : numericSize > 3 ? 1 : 1;
|
|
137
|
+
const ringGap = numericSize > 12 ? 3 : numericSize > 4 ? 2 : numericSize > 3 ? 1 : 0;
|
|
138
|
+
const r = sizePx / 2 - ringGap - ringWidth;
|
|
138
139
|
return /* @__PURE__ */ React2.createElement(AvatarRootPrimitive, {
|
|
139
140
|
role: "img",
|
|
140
141
|
...props,
|
|
@@ -149,9 +150,9 @@ var AvatarFrame = /* @__PURE__ */ forwardRef(({ classNames, children, ...props }
|
|
|
149
150
|
"aria-describedby": descriptionId
|
|
150
151
|
}
|
|
151
152
|
}, /* @__PURE__ */ React2.createElement("svg", {
|
|
152
|
-
viewBox: `0 0 ${
|
|
153
|
-
width:
|
|
154
|
-
height:
|
|
153
|
+
viewBox: `0 0 ${sizePx} ${sizePx}`,
|
|
154
|
+
width: sizePx,
|
|
155
|
+
height: sizePx,
|
|
155
156
|
className: tx("avatar.frame", "avatar__frame", {
|
|
156
157
|
variant
|
|
157
158
|
})
|
|
@@ -167,63 +168,34 @@ var AvatarFrame = /* @__PURE__ */ forwardRef(({ classNames, children, ...props }
|
|
|
167
168
|
width: 2 * r,
|
|
168
169
|
height: 2 * r,
|
|
169
170
|
x: ringGap + ringWidth,
|
|
170
|
-
y: ringGap + ringWidth
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
opacity: 0.1,
|
|
175
|
-
cx: "50%",
|
|
176
|
-
cy: "50%",
|
|
177
|
-
r
|
|
178
|
-
}), /* @__PURE__ */ React2.createElement("circle", {
|
|
179
|
-
stroke: "#888",
|
|
180
|
-
fill: "none",
|
|
181
|
-
opacity: 0.3,
|
|
171
|
+
y: ringGap + ringWidth,
|
|
172
|
+
rx
|
|
173
|
+
}))), variant === "circle" ? /* @__PURE__ */ React2.createElement("circle", {
|
|
174
|
+
className: `avatarFrameFill${color ? "" : " fill-[var(--surface-bg)]"}`,
|
|
182
175
|
cx: "50%",
|
|
183
176
|
cy: "50%",
|
|
184
|
-
r
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
height: 2 * r,
|
|
177
|
+
r,
|
|
178
|
+
...color ? {
|
|
179
|
+
fill: color
|
|
180
|
+
} : {}
|
|
181
|
+
}) : /* @__PURE__ */ React2.createElement("rect", {
|
|
182
|
+
className: "avatarFrameFill fill-[var(--surface-bg)]",
|
|
191
183
|
x: ringGap + ringWidth,
|
|
192
184
|
y: ringGap + ringWidth,
|
|
193
|
-
rx: 2
|
|
194
|
-
}), /* @__PURE__ */ React2.createElement("rect", {
|
|
195
|
-
fill: "none",
|
|
196
|
-
stroke: "#333",
|
|
197
|
-
opacity: 0.15,
|
|
198
185
|
width: 2 * r,
|
|
199
186
|
height: 2 * r,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
rx: 2
|
|
203
|
-
})), children, variant === "circle" ? /* @__PURE__ */ React2.createElement("circle", {
|
|
204
|
-
className: "avatarFrameStroke fill-transparent stroke-[var(--surface-bg)]",
|
|
205
|
-
strokeWidth,
|
|
206
|
-
fill: "none",
|
|
207
|
-
cx: imageSizeNumber / 2,
|
|
208
|
-
cy: imageSizeNumber / 2,
|
|
209
|
-
r: imageSizeNumber / 2 - strokeWidth / 4
|
|
210
|
-
}) : /* @__PURE__ */ React2.createElement("rect", {
|
|
211
|
-
className: "avatarFrameStroke fill-transparent stroke-[var(--surface-bg)]",
|
|
212
|
-
strokeWidth,
|
|
213
|
-
x: strokeWidth / 4,
|
|
214
|
-
y: strokeWidth / 4,
|
|
215
|
-
fill: "none",
|
|
216
|
-
rx,
|
|
217
|
-
width: imageSizeNumber - strokeWidth / 4,
|
|
218
|
-
height: imageSizeNumber - strokeWidth / 4
|
|
219
|
-
})), /* @__PURE__ */ React2.createElement("span", {
|
|
187
|
+
rx
|
|
188
|
+
}), children), /* @__PURE__ */ React2.createElement("span", {
|
|
220
189
|
role: "none",
|
|
221
190
|
className: tx("avatar.ring", "avatar__ring", {
|
|
222
191
|
size,
|
|
223
192
|
variant,
|
|
224
193
|
status,
|
|
225
194
|
animation
|
|
226
|
-
})
|
|
195
|
+
}),
|
|
196
|
+
style: {
|
|
197
|
+
borderWidth: ringWidth + "px"
|
|
198
|
+
}
|
|
227
199
|
}));
|
|
228
200
|
});
|
|
229
201
|
var AvatarLabel = /* @__PURE__ */ forwardRef(({ asChild, srOnly, classNames, ...props }, forwardedRef) => {
|
|
@@ -259,7 +231,8 @@ var AvatarMaskedImage = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
|
259
231
|
height: "100%",
|
|
260
232
|
...props,
|
|
261
233
|
mask: `url(#${maskId})`,
|
|
262
|
-
ref: forwardedRef
|
|
234
|
+
ref: forwardedRef,
|
|
235
|
+
preserveAspectRatio: "xMidYMid slice"
|
|
263
236
|
});
|
|
264
237
|
});
|
|
265
238
|
var AvatarMaskedText = (props) => {
|
|
@@ -278,8 +251,12 @@ var AvatarMaskedText = (props) => {
|
|
|
278
251
|
}, props.children);
|
|
279
252
|
};
|
|
280
253
|
var AvatarImage = /* @__PURE__ */ forwardRef(({ onLoadingStatusChange, ...props }, forwardedRef) => {
|
|
281
|
-
|
|
282
|
-
|
|
254
|
+
const { size } = useAvatarContext("AvatarImage");
|
|
255
|
+
const pxSize = size === "px" ? 1 : size * 4;
|
|
256
|
+
if (pxSize <= 20) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
return /* @__PURE__ */ React2.createElement(AvatarFallbackPrimitive, {
|
|
283
260
|
asChild: true
|
|
284
261
|
}, /* @__PURE__ */ React2.createElement(AvatarMaskedImage, {
|
|
285
262
|
...props,
|
|
@@ -288,10 +265,12 @@ var AvatarImage = /* @__PURE__ */ forwardRef(({ onLoadingStatusChange, ...props
|
|
|
288
265
|
});
|
|
289
266
|
var AvatarFallback = /* @__PURE__ */ forwardRef(({ delayMs, text, ...props }, forwardedRef) => {
|
|
290
267
|
const isTextOnly = Boolean(text && /[0-9a-zA-Z]+/.test(text));
|
|
268
|
+
const { size } = useAvatarContext("AvatarFallback");
|
|
269
|
+
const numericSize = size === "px" ? 1 : Number(size);
|
|
291
270
|
return /* @__PURE__ */ React2.createElement(AvatarFallbackPrimitive, {
|
|
292
271
|
delayMs,
|
|
293
272
|
asChild: true
|
|
294
|
-
}, /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(AvatarMaskedImage, {
|
|
273
|
+
}, /* @__PURE__ */ React2.createElement(React2.Fragment, null, numericSize >= 6 && /* @__PURE__ */ React2.createElement(AvatarMaskedImage, {
|
|
295
274
|
...props,
|
|
296
275
|
ref: forwardedRef
|
|
297
276
|
}), text && /* @__PURE__ */ React2.createElement(AvatarMaskedText, {
|
|
@@ -336,7 +315,7 @@ var AvatarGroupRoot = /* @__PURE__ */ forwardRef2(({ labelId: propsLabelId, desc
|
|
|
336
315
|
ref: forwardedRef
|
|
337
316
|
}, children));
|
|
338
317
|
});
|
|
339
|
-
var AvatarGroupItemRoot = ({ maskId, size, variant, status, children }) => {
|
|
318
|
+
var AvatarGroupItemRoot = ({ maskId, size, variant, status, children, ...rest }) => {
|
|
340
319
|
const { labelId, descriptionId, size: contextSize, variant: contextVariant } = useAvatarContext("AvatarGroupItemRoot");
|
|
341
320
|
return /* @__PURE__ */ React3.createElement(Avatar.Root, {
|
|
342
321
|
labelId,
|
|
@@ -345,7 +324,8 @@ var AvatarGroupItemRoot = ({ maskId, size, variant, status, children }) => {
|
|
|
345
324
|
status,
|
|
346
325
|
size: size ?? contextSize,
|
|
347
326
|
variant: variant ?? contextVariant,
|
|
348
|
-
inGroup: true
|
|
327
|
+
inGroup: true,
|
|
328
|
+
...rest
|
|
349
329
|
}, children);
|
|
350
330
|
};
|
|
351
331
|
var AvatarGroupLabel = /* @__PURE__ */ forwardRef2(({ srOnly, classNames, children, ...props }, forwardedRef) => {
|
|
@@ -1556,6 +1536,9 @@ var MainSidebar = /* @__PURE__ */ forwardRef16(({ classNames, children, swipeToD
|
|
|
1556
1536
|
[side === "inline-end" ? "inlineEndSidebarOpen" : "inlineStartSidebarOpen"]: open,
|
|
1557
1537
|
side
|
|
1558
1538
|
}, classNames),
|
|
1539
|
+
...!open && {
|
|
1540
|
+
inert: "true"
|
|
1541
|
+
},
|
|
1559
1542
|
ref
|
|
1560
1543
|
}, /* @__PURE__ */ React20.createElement(ElevationProvider, {
|
|
1561
1544
|
elevation: "group"
|