@dxos/react-ui 0.3.5-next.63b0922 → 0.3.5-next.d8a95f3

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.
Files changed (37) hide show
  1. package/dist/lib/browser/index.mjs +63 -66
  2. package/dist/lib/browser/index.mjs.map +3 -3
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/types/src/components/Avatars/Avatar.d.ts +6 -5
  5. package/dist/types/src/components/Avatars/Avatar.d.ts.map +1 -1
  6. package/dist/types/src/components/Avatars/Avatar.stories.d.ts +2 -0
  7. package/dist/types/src/components/Avatars/Avatar.stories.d.ts.map +1 -1
  8. package/dist/types/src/components/Avatars/AvatarGroup.d.ts +4 -4
  9. package/dist/types/src/components/Avatars/AvatarGroup.d.ts.map +1 -1
  10. package/dist/types/src/components/Breadcrumb/Breadcrumb.d.ts +5 -5
  11. package/dist/types/src/components/Buttons/Button.d.ts +2 -2
  12. package/dist/types/src/components/Buttons/Button.stories.d.ts +1 -1
  13. package/dist/types/src/components/Buttons/Toggle.d.ts +1 -1
  14. package/dist/types/src/components/Buttons/ToggleGroup.d.ts +3 -3
  15. package/dist/types/src/components/Card/Card.d.ts +1 -1
  16. package/dist/types/src/components/Card/Card.stories.d.ts +1 -1
  17. package/dist/types/src/components/DropdownMenu/DropdownMenu.d.ts +9 -3
  18. package/dist/types/src/components/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  19. package/dist/types/src/components/Input/Input.d.ts +7 -7
  20. package/dist/types/src/components/Link/Link.d.ts +1 -1
  21. package/dist/types/src/components/List/List.d.ts +1 -1
  22. package/dist/types/src/components/Main/Main.d.ts +4 -4
  23. package/dist/types/src/components/Main/Main.d.ts.map +1 -1
  24. package/dist/types/src/components/Message/Message.d.ts +2 -2
  25. package/dist/types/src/components/Popover/Popover.d.ts +1 -1
  26. package/dist/types/src/components/Select/Select.d.ts +1 -1
  27. package/dist/types/src/components/Tag/Tag.d.ts +1 -1
  28. package/dist/types/src/components/Toast/Toast.d.ts +2 -2
  29. package/dist/types/src/components/Toolbar/Toolbar.d.ts +5 -5
  30. package/dist/types/src/playground/Surfaces.stories.d.ts.map +1 -1
  31. package/package.json +6 -6
  32. package/src/components/Avatars/Avatar.stories.tsx +51 -15
  33. package/src/components/Avatars/Avatar.tsx +75 -69
  34. package/src/components/Avatars/AvatarGroup.tsx +2 -1
  35. package/src/components/DropdownMenu/DropdownMenu.tsx +27 -0
  36. package/src/components/Main/Main.tsx +1 -0
  37. 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, Image as AvatarImagePrimitive, Fallback as AvatarFallbackPrimitive } from "@radix-ui/react-avatar";
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 strokeWidth = 2;
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 imageSizeNumber = size === "px" ? 1 : size * 4;
135
- const ringGap = 3;
136
- const ringWidth = 2;
137
- const r = imageSizeNumber / 2 - ringGap - ringWidth;
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,10 +150,12 @@ var AvatarFrame = /* @__PURE__ */ forwardRef(({ classNames, children, ...props }
149
150
  "aria-describedby": descriptionId
150
151
  }
151
152
  }, /* @__PURE__ */ React2.createElement("svg", {
152
- viewBox: `0 0 ${imageSizeNumber} ${imageSizeNumber}`,
153
- width: imageSizeNumber,
154
- height: imageSizeNumber,
155
- className: tx("avatar.frame", "avatar__frame", {})
153
+ viewBox: `0 0 ${sizePx} ${sizePx}`,
154
+ width: sizePx,
155
+ height: sizePx,
156
+ className: tx("avatar.frame", "avatar__frame", {
157
+ variant
158
+ })
156
159
  }, /* @__PURE__ */ React2.createElement("defs", null, /* @__PURE__ */ React2.createElement("mask", {
157
160
  id: maskId
158
161
  }, variant === "circle" ? /* @__PURE__ */ React2.createElement("circle", {
@@ -165,62 +168,34 @@ var AvatarFrame = /* @__PURE__ */ forwardRef(({ classNames, children, ...props }
165
168
  width: 2 * r,
166
169
  height: 2 * r,
167
170
  x: ringGap + ringWidth,
168
- y: ringGap + ringWidth
169
- }))), variant === "circle" ? /* @__PURE__ */ React2.createElement("g", null, /* @__PURE__ */ React2.createElement("circle", {
170
- fill: "#999",
171
- stroke: "none",
172
- opacity: 0.1,
173
- cx: "50%",
174
- cy: "50%",
175
- r
176
- }), /* @__PURE__ */ React2.createElement("circle", {
177
- stroke: "#888",
178
- fill: "none",
179
- opacity: 0.3,
171
+ y: ringGap + ringWidth,
172
+ rx
173
+ }))), variant === "circle" ? /* @__PURE__ */ React2.createElement("circle", {
174
+ className: `avatarFrameFill${color ? "" : " fill-[var(--surface-bg)]"}`,
180
175
  cx: "50%",
181
176
  cy: "50%",
182
- r
183
- })) : /* @__PURE__ */ React2.createElement("g", null, /* @__PURE__ */ React2.createElement("rect", {
184
- fill: "#999",
185
- stroke: "none",
186
- opacity: 0.1,
187
- width: 2 * r,
188
- height: 2 * r,
177
+ r,
178
+ ...color ? {
179
+ fill: color
180
+ } : {}
181
+ }) : /* @__PURE__ */ React2.createElement("rect", {
182
+ className: "avatarFrameFill fill-[var(--surface-bg)]",
189
183
  x: ringGap + ringWidth,
190
184
  y: ringGap + ringWidth,
191
- rx: 2
192
- }), /* @__PURE__ */ React2.createElement("rect", {
193
- fill: "none",
194
- stroke: "#333",
195
- opacity: 0.15,
196
185
  width: 2 * r,
197
186
  height: 2 * r,
198
- x: ringGap + ringWidth,
199
- y: ringGap + ringWidth,
200
- rx: 2
201
- })), children, variant === "circle" ? /* @__PURE__ */ React2.createElement("circle", {
202
- className: "avatarFrameStroke fill-transparent stroke-[var(--surface-bg)]",
203
- strokeWidth,
204
- fill: "none",
205
- cx: imageSizeNumber / 2,
206
- cy: imageSizeNumber / 2,
207
- r: imageSizeNumber / 2 - strokeWidth / 4
208
- }) : /* @__PURE__ */ React2.createElement("rect", {
209
- className: "avatarFrameStroke fill-transparent stroke-[var(--surface-bg)]",
210
- strokeWidth,
211
- x: strokeWidth / 4,
212
- y: strokeWidth / 4,
213
- fill: "none",
214
- rx,
215
- width: imageSizeNumber - strokeWidth / 4,
216
- height: imageSizeNumber - strokeWidth / 4
217
- })), /* @__PURE__ */ React2.createElement("span", {
187
+ rx
188
+ }), children), /* @__PURE__ */ React2.createElement("span", {
189
+ role: "none",
218
190
  className: tx("avatar.ring", "avatar__ring", {
219
191
  size,
220
192
  variant,
221
193
  status,
222
194
  animation
223
- })
195
+ }),
196
+ style: {
197
+ borderWidth: ringWidth + "px"
198
+ }
224
199
  }));
225
200
  });
226
201
  var AvatarLabel = /* @__PURE__ */ forwardRef(({ asChild, srOnly, classNames, ...props }, forwardedRef) => {
@@ -256,7 +231,8 @@ var AvatarMaskedImage = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
256
231
  height: "100%",
257
232
  ...props,
258
233
  mask: `url(#${maskId})`,
259
- ref: forwardedRef
234
+ ref: forwardedRef,
235
+ preserveAspectRatio: "xMidYMid slice"
260
236
  });
261
237
  });
262
238
  var AvatarMaskedText = (props) => {
@@ -275,8 +251,12 @@ var AvatarMaskedText = (props) => {
275
251
  }, props.children);
276
252
  };
277
253
  var AvatarImage = /* @__PURE__ */ forwardRef(({ onLoadingStatusChange, ...props }, forwardedRef) => {
278
- return /* @__PURE__ */ React2.createElement(AvatarImagePrimitive, {
279
- onLoadingStatusChange,
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, {
280
260
  asChild: true
281
261
  }, /* @__PURE__ */ React2.createElement(AvatarMaskedImage, {
282
262
  ...props,
@@ -285,10 +265,12 @@ var AvatarImage = /* @__PURE__ */ forwardRef(({ onLoadingStatusChange, ...props
285
265
  });
286
266
  var AvatarFallback = /* @__PURE__ */ forwardRef(({ delayMs, text, ...props }, forwardedRef) => {
287
267
  const isTextOnly = Boolean(text && /[0-9a-zA-Z]+/.test(text));
268
+ const { size } = useAvatarContext("AvatarFallback");
269
+ const numericSize = size === "px" ? 1 : Number(size);
288
270
  return /* @__PURE__ */ React2.createElement(AvatarFallbackPrimitive, {
289
271
  delayMs,
290
272
  asChild: true
291
- }, /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(AvatarMaskedImage, {
273
+ }, /* @__PURE__ */ React2.createElement(React2.Fragment, null, numericSize >= 6 && /* @__PURE__ */ React2.createElement(AvatarMaskedImage, {
292
274
  ...props,
293
275
  ref: forwardedRef
294
276
  }), text && /* @__PURE__ */ React2.createElement(AvatarMaskedText, {
@@ -333,7 +315,7 @@ var AvatarGroupRoot = /* @__PURE__ */ forwardRef2(({ labelId: propsLabelId, desc
333
315
  ref: forwardedRef
334
316
  }, children));
335
317
  });
336
- var AvatarGroupItemRoot = ({ maskId, size, variant, status, children }) => {
318
+ var AvatarGroupItemRoot = ({ maskId, size, variant, status, children, ...rest }) => {
337
319
  const { labelId, descriptionId, size: contextSize, variant: contextVariant } = useAvatarContext("AvatarGroupItemRoot");
338
320
  return /* @__PURE__ */ React3.createElement(Avatar.Root, {
339
321
  labelId,
@@ -342,7 +324,8 @@ var AvatarGroupItemRoot = ({ maskId, size, variant, status, children }) => {
342
324
  status,
343
325
  size: size ?? contextSize,
344
326
  variant: variant ?? contextVariant,
345
- inGroup: true
327
+ inGroup: true,
328
+ ...rest
346
329
  }, children);
347
330
  };
348
331
  var AvatarGroupLabel = /* @__PURE__ */ forwardRef2(({ srOnly, classNames, children, ...props }, forwardedRef) => {
@@ -559,7 +542,7 @@ import { DotsSixVertical, DotsThreeVertical } from "@phosphor-icons/react";
559
542
  import React11, { forwardRef as forwardRef9 } from "react";
560
543
 
561
544
  // packages/ui/react-ui/src/components/DropdownMenu/DropdownMenu.tsx
562
- import { Root as DropdownMenuRootPrimitive, DropdownMenuTrigger as DropdownMenuTriggerPrimitive, DropdownMenuPortal as DropdownMenuPortalPrimitive, DropdownMenuContent as DropdownMenuContentPrimitive, DropdownMenuArrow as DropdownMenuArrowPrimitive, DropdownMenuGroup as DropdownMenuGroupPrimitive, DropdownMenuItem as DropdownMenuItemPrimitive, DropdownMenuSeparator as DropdownMenuSeparatorPrimitive, DropdownMenuLabel as DropdownMenuLabelPrimitive } from "@radix-ui/react-dropdown-menu";
545
+ import { Root as DropdownMenuRootPrimitive, DropdownMenuTrigger as DropdownMenuTriggerPrimitive, DropdownMenuPortal as DropdownMenuPortalPrimitive, DropdownMenuContent as DropdownMenuContentPrimitive, DropdownMenuArrow as DropdownMenuArrowPrimitive, DropdownMenuGroup as DropdownMenuGroupPrimitive, DropdownMenuItem as DropdownMenuItemPrimitive, DropdownMenuCheckboxItem as DropdownMenuCheckboxItemPrimitive, DropdownMenuItemIndicator as DropdownMenuItemIndicatorPrimitive, DropdownMenuSeparator as DropdownMenuSeparatorPrimitive, DropdownMenuLabel as DropdownMenuLabelPrimitive } from "@radix-ui/react-dropdown-menu";
563
546
  import { Primitive as Primitive5 } from "@radix-ui/react-primitive";
564
547
  import { Slot as Slot5 } from "@radix-ui/react-slot";
565
548
  import React10, { forwardRef as forwardRef8 } from "react";
@@ -609,6 +592,7 @@ var DropdownMenuArrow = /* @__PURE__ */ forwardRef8(({ classNames, ...props }, f
609
592
  });
610
593
  });
611
594
  var DropdownMenuGroup = DropdownMenuGroupPrimitive;
595
+ var DropdownMenuItemIndicator = DropdownMenuItemIndicatorPrimitive;
612
596
  var DropdownMenuItem = /* @__PURE__ */ forwardRef8(({ classNames, ...props }, forwardedRef) => {
613
597
  const { tx } = useThemeContext();
614
598
  return /* @__PURE__ */ React10.createElement(DropdownMenuItemPrimitive, {
@@ -617,6 +601,14 @@ var DropdownMenuItem = /* @__PURE__ */ forwardRef8(({ classNames, ...props }, fo
617
601
  ref: forwardedRef
618
602
  });
619
603
  });
604
+ var DropdownMenuCheckboxItem = /* @__PURE__ */ forwardRef8(({ classNames, ...props }, forwardedRef) => {
605
+ const { tx } = useThemeContext();
606
+ return /* @__PURE__ */ React10.createElement(DropdownMenuCheckboxItemPrimitive, {
607
+ ...props,
608
+ className: tx("dropdownMenu.item", "dropdown-menu__item--checkbox", {}, classNames),
609
+ ref: forwardedRef
610
+ });
611
+ });
620
612
  var DropdownMenuSeparator = /* @__PURE__ */ forwardRef8(({ classNames, ...props }, forwardedRef) => {
621
613
  const { tx } = useThemeContext();
622
614
  return /* @__PURE__ */ React10.createElement(DropdownMenuSeparatorPrimitive, {
@@ -642,6 +634,8 @@ var DropdownMenu = {
642
634
  Arrow: DropdownMenuArrow,
643
635
  Group: DropdownMenuGroup,
644
636
  Item: DropdownMenuItem,
637
+ CheckboxItem: DropdownMenuCheckboxItem,
638
+ ItemIndicator: DropdownMenuItemIndicator,
645
639
  Separator: DropdownMenuSeparator,
646
640
  GroupLabel: DropdownMenuGroupLabel
647
641
  };
@@ -1542,6 +1536,9 @@ var MainSidebar = /* @__PURE__ */ forwardRef16(({ classNames, children, swipeToD
1542
1536
  [side === "inline-end" ? "inlineEndSidebarOpen" : "inlineStartSidebarOpen"]: open,
1543
1537
  side
1544
1538
  }, classNames),
1539
+ ...!open && {
1540
+ inert: "true"
1541
+ },
1545
1542
  ref
1546
1543
  }, /* @__PURE__ */ React20.createElement(ElevationProvider, {
1547
1544
  elevation: "group"