@dxos/react-ui-card 0.8.2 → 0.11.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.
Files changed (74) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/index.mjs +288 -0
  3. package/dist/lib/index.mjs.map +1 -0
  4. package/dist/lib/translations.mjs +11 -0
  5. package/dist/lib/translations.mjs.map +1 -0
  6. package/dist/types/src/components/Avatar/Avatar.d.ts +14 -0
  7. package/dist/types/src/components/Avatar/Avatar.d.ts.map +1 -0
  8. package/dist/types/src/components/Avatar/Avatar.stories.d.ts +15 -0
  9. package/dist/types/src/components/Avatar/Avatar.stories.d.ts.map +1 -0
  10. package/dist/types/src/components/Avatar/avatar-name.d.ts +6 -0
  11. package/dist/types/src/components/Avatar/avatar-name.d.ts.map +1 -0
  12. package/dist/types/src/components/Avatar/index.d.ts +3 -0
  13. package/dist/types/src/components/Avatar/index.d.ts.map +1 -0
  14. package/dist/types/src/components/CardTile/CardTile.d.ts +46 -0
  15. package/dist/types/src/components/CardTile/CardTile.d.ts.map +1 -0
  16. package/dist/types/src/components/CardTile/CardTile.stories.d.ts +27 -0
  17. package/dist/types/src/components/CardTile/CardTile.stories.d.ts.map +1 -0
  18. package/dist/types/src/components/CardTile/index.d.ts +2 -0
  19. package/dist/types/src/components/CardTile/index.d.ts.map +1 -0
  20. package/dist/types/src/components/Row/Row.d.ts +100 -0
  21. package/dist/types/src/components/Row/Row.d.ts.map +1 -0
  22. package/dist/types/src/components/Row/Row.stories.d.ts +23 -0
  23. package/dist/types/src/components/Row/Row.stories.d.ts.map +1 -0
  24. package/dist/types/src/components/Row/index.d.ts +2 -0
  25. package/dist/types/src/components/Row/index.d.ts.map +1 -0
  26. package/dist/types/src/components/index.d.ts +3 -1
  27. package/dist/types/src/components/index.d.ts.map +1 -1
  28. package/dist/types/src/hooks/index.d.ts +2 -0
  29. package/dist/types/src/hooks/index.d.ts.map +1 -0
  30. package/dist/types/src/hooks/useActorContact.d.ts +5 -0
  31. package/dist/types/src/hooks/useActorContact.d.ts.map +1 -0
  32. package/dist/types/src/index.d.ts +2 -1
  33. package/dist/types/src/index.d.ts.map +1 -1
  34. package/dist/types/src/translations.d.ts +11 -0
  35. package/dist/types/src/translations.d.ts.map +1 -0
  36. package/dist/types/src/util.d.ts +3 -0
  37. package/dist/types/src/util.d.ts.map +1 -0
  38. package/dist/types/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +39 -30
  40. package/src/components/Avatar/Avatar.stories.tsx +31 -0
  41. package/src/components/Avatar/Avatar.tsx +39 -0
  42. package/src/components/Avatar/avatar-name.ts +19 -0
  43. package/src/components/Avatar/index.ts +7 -0
  44. package/src/components/CardTile/CardTile.stories.tsx +54 -0
  45. package/src/components/CardTile/CardTile.tsx +103 -0
  46. package/src/components/CardTile/index.ts +5 -0
  47. package/src/components/Row/Row.stories.tsx +65 -0
  48. package/src/components/Row/Row.tsx +379 -0
  49. package/src/components/Row/index.ts +5 -0
  50. package/src/components/index.ts +4 -2
  51. package/src/hooks/index.ts +5 -0
  52. package/src/hooks/useActorContact.ts +31 -0
  53. package/src/index.ts +3 -2
  54. package/src/translations.ts +19 -0
  55. package/src/util.ts +7 -0
  56. package/README.md +0 -3
  57. package/dist/lib/browser/index.mjs +0 -200
  58. package/dist/lib/browser/index.mjs.map +0 -7
  59. package/dist/lib/browser/meta.json +0 -1
  60. package/dist/lib/node/index.cjs +0 -243
  61. package/dist/lib/node/index.cjs.map +0 -7
  62. package/dist/lib/node/meta.json +0 -1
  63. package/dist/lib/node-esm/index.mjs +0 -202
  64. package/dist/lib/node-esm/index.mjs.map +0 -7
  65. package/dist/lib/node-esm/meta.json +0 -1
  66. package/dist/types/src/components/Card.d.ts +0 -52
  67. package/dist/types/src/components/Card.d.ts.map +0 -1
  68. package/dist/types/src/components/Card.stories.d.ts +0 -57
  69. package/dist/types/src/components/Card.stories.d.ts.map +0 -1
  70. package/dist/types/src/theme.d.ts +0 -31
  71. package/dist/types/src/theme.d.ts.map +0 -1
  72. package/src/components/Card.stories.tsx +0 -217
  73. package/src/components/Card.tsx +0 -149
  74. package/src/theme.ts +0 -101
package/LICENSE CHANGED
@@ -1,8 +1,105 @@
1
- MIT License
2
- Copyright (c) 2022 DXOS
1
+ # Functional Source License, Version 1.1, ALv2 Future License
3
2
 
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
+ ## Abbreviation
5
4
 
6
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+ FSL-1.1-Apache-2.0
7
6
 
8
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7
+ ## Notice
8
+
9
+ Copyright 2026 DXOS
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the Apache License, Version 2.0 that is effective on the second anniversary of
91
+ the date we make the Software available. On or after that date, you may use the
92
+ Software under the Apache License, Version 2.0, in which case the following
93
+ will apply:
94
+
95
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
96
+ this file except in compliance with the License.
97
+
98
+ You may obtain a copy of the License at
99
+
100
+ http://www.apache.org/licenses/LICENSE-2.0
101
+
102
+ Unless required by applicable law or agreed to in writing, software distributed
103
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
+ specific language governing permissions and limitations under the License.
@@ -0,0 +1,288 @@
1
+ import { translationKey } from "./translations.mjs";
2
+ import { toHue } from "@dxos/util";
3
+ import { forwardRef, useCallback, useMemo, useRef } from "react";
4
+ import { DxAvatar } from "@dxos/lit-ui/react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { Card, DxAnchorActivate, Icon, IconButton, SystemIconButton, Tag, useTranslation } from "@dxos/react-ui";
7
+ import { Focus, Mosaic } from "@dxos/react-ui-mosaic";
8
+ import { format, intervalToDuration } from "date-fns";
9
+ import { Filter, Obj } from "@dxos/echo";
10
+ import { EID } from "@dxos/keys";
11
+ import { toHue as toHue$1 } from "@dxos/ui-theme";
12
+ import { useQuery } from "@dxos/echo-react";
13
+ import { Person } from "@dxos/types";
14
+ //#region src/util.ts
15
+ /** Deterministic string hash (djb2), used to map a name to a stable avatar hue. */
16
+ var hashString = (str) => str ? Math.abs(str.split("").reduce((hash, char) => (hash << 5) + hash + char.charCodeAt(0), 0)) : 0;
17
+ //#endregion
18
+ //#region src/components/Avatar/avatar-name.ts
19
+ /** Canonical display name for an actor — the avatar glyph fallback and the hue key are both derived from it. */
20
+ var avatarName = (actor) => actor?.contact?.target?.fullName ?? actor?.name ?? actor?.email ?? "";
21
+ /** Single source for a name→hue mapping, so the same sender is one color across every surface. */
22
+ var nameToHue = (name) => toHue(hashString(name));
23
+ //#endregion
24
+ //#region src/components/Avatar/Avatar.tsx
25
+ /**
26
+ * Sender/participant avatar with one shared name→hue derivation ({@link nameToHue}) so a given
27
+ * person renders the same color across the mailbox list, the opened thread, and preview cards —
28
+ * previously each site hand-rolled `DxAvatar` off a different input.
29
+ */
30
+ var Avatar = ({ actor, name, variant = "circle", size = 6, onClick }) => {
31
+ const label = name ?? avatarName(actor);
32
+ return /* @__PURE__ */ jsx(DxAvatar, {
33
+ hue: nameToHue(label),
34
+ hueVariant: "surface",
35
+ variant,
36
+ size,
37
+ fallback: label,
38
+ onClick
39
+ });
40
+ };
41
+ Avatar.displayName = "Avatar";
42
+ //#endregion
43
+ //#region src/hooks/useActorContact.ts
44
+ var useActorContact = (db, actor) => {
45
+ const contacts = useQuery(!!actor?.contact ? void 0 : db, Filter.type(Person.Person));
46
+ const existingContact = useMemo(() => contacts.find((contact) => contact.emails?.find((email) => email.value === actor?.email)), [contacts, actor?.email]);
47
+ return useMemo(() => actor?.contact ? EID.tryParse(actor.contact.uri) : existingContact ? EID.parse(Obj.getURI(existingContact)) : void 0, [actor?.contact, existingContact]);
48
+ };
49
+ //#endregion
50
+ //#region src/components/Row/Row.tsx
51
+ /**
52
+ * Icon-only button that opens an ECHO object's preview card via `DxAnchorActivate`.
53
+ * Falls back to `onClick` when `value` is absent.
54
+ */
55
+ var AnchorIconButton = ({ compact, icon, fallbackIcon, label, fallbackLabel, title, value, size = 4, onClick }) => {
56
+ const buttonRef = useRef(null);
57
+ const handleClick = useCallback(() => {
58
+ if (value) buttonRef.current?.dispatchEvent(new DxAnchorActivate({
59
+ trigger: buttonRef.current,
60
+ dxn: value.toString(),
61
+ label,
62
+ kind: "card",
63
+ title
64
+ }));
65
+ else onClick?.();
66
+ }, [
67
+ value,
68
+ label,
69
+ title,
70
+ onClick
71
+ ]);
72
+ return /* @__PURE__ */ jsx(IconButton, {
73
+ classNames: compact ? "min-h-0" : "aspect-square",
74
+ variant: "ghost",
75
+ disabled: !value && !onClick,
76
+ icon: value ? icon : fallbackIcon ?? icon,
77
+ iconOnly: true,
78
+ size,
79
+ label: value ? label : fallbackLabel ?? label,
80
+ onClick: handleClick,
81
+ ref: buttonRef
82
+ });
83
+ };
84
+ /** A Card.Row rendering a date or date range with a calendar icon. */
85
+ var RowDate = ({ start, end }) => {
86
+ let { hours = 0, minutes = 0 } = (end && intervalToDuration({
87
+ start,
88
+ end
89
+ })) ?? {};
90
+ if (hours === 1 && minutes !== 0) {
91
+ hours = 0;
92
+ minutes += 60;
93
+ }
94
+ const duration = [hours > 0 && `${hours}h`, minutes > 0 && `${minutes}m`].filter(Boolean).join(" ");
95
+ return /* @__PURE__ */ jsxs(Card.Row, { children: [/* @__PURE__ */ jsx(Card.Block, { children: /* @__PURE__ */ jsx(Icon, { icon: "ph--calendar--regular" }) }), /* @__PURE__ */ jsxs("div", {
96
+ className: "flex items-center gap-2 overflow-hidden whitespace-nowrap",
97
+ children: [/* @__PURE__ */ jsx("div", {
98
+ className: "truncate text-description",
99
+ children: format(start, "PPp")
100
+ }), duration.length > 0 && /* @__PURE__ */ jsxs("div", {
101
+ className: "text-description text-xs",
102
+ children: [
103
+ "(",
104
+ duration,
105
+ ")"
106
+ ]
107
+ })]
108
+ })] });
109
+ };
110
+ RowDate.displayName = "Row.Date";
111
+ /** A Card.Row rendering an ECHO ref/relation with a card-preview anchor icon. */
112
+ var RowRef = ({ object }) => {
113
+ const label = Obj.getLabel(object, { fallback: "typename" }) ?? "object";
114
+ const icon = Obj.getIcon(object)?.icon ?? "ph--cube--regular";
115
+ const echoUri = EID.tryParse(Obj.getURI(object).toString());
116
+ return /* @__PURE__ */ jsxs(Card.Row, { children: [/* @__PURE__ */ jsx(Card.Block, { children: /* @__PURE__ */ jsx(AnchorIconButton, {
117
+ icon,
118
+ label,
119
+ title: label,
120
+ value: echoUri
121
+ }) }), /* @__PURE__ */ jsx("div", {
122
+ className: "flex items-center",
123
+ children: /* @__PURE__ */ jsx("span", {
124
+ className: "truncate text-primary-text",
125
+ children: label
126
+ })
127
+ })] });
128
+ };
129
+ RowRef.displayName = "Row.Ref";
130
+ /**
131
+ * Static avatar variant — no contact resolution. Suitable for virtualized list tiles.
132
+ */
133
+ var PersonAvatarRow = ({ actor, onClick }) => /* @__PURE__ */ jsxs(Card.Row, { children: [/* @__PURE__ */ jsx(Card.Block, { children: /* @__PURE__ */ jsx(Avatar, {
134
+ actor,
135
+ onClick
136
+ }) }), /* @__PURE__ */ jsx(Card.Text, { children: avatarName(actor) || actor.email })] });
137
+ /**
138
+ * Interactive variant — resolves the contact to a card-preview anchor, with a create-contact fallback.
139
+ */
140
+ var PersonAnchorRow = ({ actor, role, db, onContactCreate, onRemove }) => {
141
+ const { t } = useTranslation(translationKey);
142
+ const contactDXN = useActorContact(db, actor);
143
+ const handleContactCreate = useCallback(() => onContactCreate?.(actor), [actor, onContactCreate]);
144
+ return /* @__PURE__ */ jsxs(Card.Row, { children: [
145
+ /* @__PURE__ */ jsx(Card.Block, { children: /* @__PURE__ */ jsx(AnchorIconButton, {
146
+ icon: "ph--user--regular",
147
+ fallbackIcon: "ph--user-plus--regular",
148
+ label: t("show-contact.label"),
149
+ fallbackLabel: t("create-contact.label"),
150
+ title: role ? `${role}: ${actor.name}` : actor.name,
151
+ value: contactDXN,
152
+ onClick: onContactCreate ? handleContactCreate : void 0
153
+ }) }),
154
+ /* @__PURE__ */ jsx(Card.Text, { children: actor.name || actor.email }),
155
+ onRemove && /* @__PURE__ */ jsx(Card.Block, {
156
+ end: true,
157
+ children: /* @__PURE__ */ jsx(IconButton, {
158
+ variant: "ghost",
159
+ iconOnly: true,
160
+ icon: "ph--x--regular",
161
+ label: t("remove-attendee.label"),
162
+ onClick: onRemove
163
+ })
164
+ })
165
+ ] });
166
+ };
167
+ /** A Card.Row rendering a person (sender, recipient, attendee). */
168
+ var RowPerson = ({ avatar, onClick, ...props }) => avatar ? /* @__PURE__ */ jsx(PersonAvatarRow, {
169
+ actor: props.actor,
170
+ onClick
171
+ }) : /* @__PURE__ */ jsx(PersonAnchorRow, { ...props });
172
+ RowPerson.displayName = "Row.Person";
173
+ /** A Card.Row rendering a set of label+hue tag chips, optionally clickable. */
174
+ var RowTags = ({ tags, onTagClick }) => {
175
+ if (!tags?.length) return null;
176
+ return /* @__PURE__ */ jsxs(Card.Row, { children: [/* @__PURE__ */ jsx(Card.Block, { children: /* @__PURE__ */ jsx(Icon, { icon: "ph--tag--regular" }) }), /* @__PURE__ */ jsx("div", {
177
+ className: "flex flex-wrap gap-1 py-1 -mx-0.5",
178
+ "data-testid": "extracted-tags",
179
+ children: tags.map((tag) => /* @__PURE__ */ jsx(Tag, {
180
+ hue: toHue$1(tag.hue),
181
+ "data-testid": `message-tag-${tag.id}`,
182
+ onClick: onTagClick ? (event) => {
183
+ event.stopPropagation();
184
+ onTagClick(tag.label ?? tag.id);
185
+ } : void 0,
186
+ children: tag.label ?? tag.id
187
+ }, tag.id))
188
+ })] });
189
+ };
190
+ RowTags.displayName = "Row.Tags";
191
+ /**
192
+ * A Card.Row listing a message's attachments by name with a generic file icon. Not yet clickable —
193
+ * resolving the attachment's ref to open/preview it is a follow-up.
194
+ */
195
+ var RowAttachments = ({ attachments }) => {
196
+ if (!attachments?.length) return null;
197
+ return /* @__PURE__ */ jsxs(Card.Row, { children: [/* @__PURE__ */ jsx(Card.Block, { children: /* @__PURE__ */ jsx(Icon, { icon: "ph--paperclip--regular" }) }), /* @__PURE__ */ jsx("div", {
198
+ className: "flex flex-wrap gap-1 py-1 -mx-0.5",
199
+ "data-testid": "message-attachments",
200
+ children: attachments.map((attachment) => /* @__PURE__ */ jsxs(Tag, {
201
+ hue: "neutral",
202
+ classNames: "inline-flex items-center gap-1",
203
+ children: [/* @__PURE__ */ jsx(Icon, {
204
+ icon: "ph--file--regular",
205
+ size: 3
206
+ }), attachment.name ?? attachment.ref.uri]
207
+ }, attachment.ref.uri))
208
+ })] });
209
+ };
210
+ RowAttachments.displayName = "Row.Attachments";
211
+ /**
212
+ * Star toggle for a `Card.Block` leading gutter (shared by event/message tiles and headers). Stops
213
+ * the click from bubbling so starring doesn't also select/activate the surrounding tile or card.
214
+ */
215
+ var RowStar = ({ starred, onToggle }) => {
216
+ const handleClick = useCallback((event) => {
217
+ event.stopPropagation();
218
+ onToggle?.();
219
+ }, [onToggle]);
220
+ if (!onToggle) return null;
221
+ return /* @__PURE__ */ jsx(SystemIconButton.Star, {
222
+ iconOnly: true,
223
+ variant: "ghost",
224
+ active: starred,
225
+ onClick: handleClick
226
+ });
227
+ };
228
+ RowStar.displayName = "Row.Star";
229
+ var Row = {
230
+ Date: RowDate,
231
+ Ref: RowRef,
232
+ Person: RowPerson,
233
+ Tags: RowTags,
234
+ Attachments: RowAttachments,
235
+ Star: RowStar
236
+ };
237
+ //#endregion
238
+ //#region src/components/CardTile/CardTile.tsx
239
+ /**
240
+ * Shared mosaic tile shell: `Mosaic.Tile` → `Focus.Item` → `Card.Root`.
241
+ * Callers supply the inner `Card.Header`/`Card.Body` (typically via {@link CardTileHeader} + rows).
242
+ * Activation is committed by the caller's `onCurrentChange` (Mosaic `current`/selection), so click/Enter light the tile up.
243
+ */
244
+ var CardTileRoot = forwardRef(({ id, data, location, current, onCurrentChange, onClick, classNames, children, "data-testid": testId }, forwardedRef) => /* @__PURE__ */ jsx(Mosaic.Tile, {
245
+ asChild: true,
246
+ id,
247
+ data,
248
+ location,
249
+ classNames: classNames ?? "dx-hover dx-current dx-selected p-1 rounded-md border border-subdued-separator",
250
+ children: /* @__PURE__ */ jsx(Focus.Item, {
251
+ asChild: true,
252
+ current,
253
+ onCurrentChange,
254
+ children: /* @__PURE__ */ jsx(Card.Root, {
255
+ fullWidth: true,
256
+ border: false,
257
+ onClick,
258
+ ref: forwardedRef,
259
+ "data-testid": testId,
260
+ children
261
+ })
262
+ })
263
+ }));
264
+ CardTileRoot.displayName = "CardTile.Root";
265
+ /**
266
+ * Tile header row: leading `Row.Star` · title · optional `Card.Menu`. Shared by message/conversation
267
+ * tiles (with menu) and event tiles (star + title only).
268
+ */
269
+ var CardTileHeader = ({ title, starred, menu = false, menuItems, onToggleStar }) => /* @__PURE__ */ jsxs(Card.Header, { children: [
270
+ /* @__PURE__ */ jsx(Card.Block, { children: /* @__PURE__ */ jsx(Row.Star, {
271
+ starred,
272
+ onToggle: onToggleStar
273
+ }) }),
274
+ /* @__PURE__ */ jsx(Card.Title, {
275
+ classNames: "flex items-center gap-3",
276
+ children: title
277
+ }),
278
+ menu && /* @__PURE__ */ jsx(Card.Menu, { items: menuItems })
279
+ ] });
280
+ CardTileHeader.displayName = "CardTile.Header";
281
+ var CardTile = {
282
+ Root: CardTileRoot,
283
+ Header: CardTileHeader
284
+ };
285
+ //#endregion
286
+ export { Avatar, CardTile, Row, avatarName, hashString, nameToHue, useActorContact };
287
+
288
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/util.ts","../../src/components/Avatar/avatar-name.ts","../../src/components/Avatar/Avatar.tsx","../../src/hooks/useActorContact.ts","../../src/components/Row/Row.tsx","../../src/components/CardTile/CardTile.tsx"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n/** Deterministic string hash (djb2), used to map a name to a stable avatar hue. */\nexport const hashString = (str?: string): number =>\n str ? Math.abs(str.split('').reduce((hash, char) => (hash << 5) + hash + char.charCodeAt(0), 0)) : 0;\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { type Actor } from '@dxos/types';\nimport { toHue } from '@dxos/util';\n\nimport { hashString } from '../../util';\n\n// Kept out of `Avatar.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on\n// every edit.\n\n/** Canonical display name for an actor — the avatar glyph fallback and the hue key are both derived from it. */\nexport const avatarName = (actor?: Actor.Actor): string =>\n actor?.contact?.target?.fullName ?? actor?.name ?? actor?.email ?? '';\n\n/** Single source for a name→hue mapping, so the same sender is one color across every surface. */\nexport const nameToHue = (name?: string): string => toHue(hashString(name));\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport React from 'react';\n\nimport { DxAvatar, type DxAvatarProps } from '@dxos/lit-ui/react';\nimport { type Actor } from '@dxos/types';\n\nimport { avatarName } from './avatar-name';\nimport { nameToHue } from './avatar-name';\n\nexport type AvatarProps = Pick<DxAvatarProps, 'variant' | 'size' | 'onClick'> & {\n /** Sender/participant; supplies the display name and the hue. */\n actor?: Actor.Actor;\n /** Label override; defaults to the actor's {@link avatarName}. */\n name?: string;\n};\n\n/**\n * Sender/participant avatar with one shared name→hue derivation ({@link nameToHue}) so a given\n * person renders the same color across the mailbox list, the opened thread, and preview cards —\n * previously each site hand-rolled `DxAvatar` off a different input.\n */\nexport const Avatar = ({ actor, name, variant = 'circle', size = 6, onClick }: AvatarProps) => {\n const label = name ?? avatarName(actor);\n return (\n <DxAvatar\n hue={nameToHue(label)}\n hueVariant='surface'\n variant={variant}\n size={size}\n fallback={label}\n onClick={onClick}\n />\n );\n};\n\nAvatar.displayName = 'Avatar';\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { useMemo } from 'react';\n\nimport { type Database, Filter, Obj } from '@dxos/echo';\nimport { useQuery } from '@dxos/echo-react';\nimport { EID } from '@dxos/keys';\nimport { type Actor, Person } from '@dxos/types';\n\n// TODO(burdon): Factor out lazy update pattern.\nexport const useActorContact = (db?: Database.Database, actor?: Actor.Actor): EID.EID | undefined => {\n // Don't bother querying the space if there is already a reference to the contact.\n const isLinked = !!actor?.contact;\n const contacts = useQuery(isLinked ? undefined : db, Filter.type(Person.Person));\n const existingContact = useMemo(\n () => contacts.find((contact) => contact.emails?.find((email) => email.value === actor?.email)),\n [contacts, actor?.email],\n );\n\n return useMemo(\n () =>\n actor?.contact\n ? EID.tryParse(actor.contact.uri)\n : existingContact\n ? EID.parse(Obj.getURI(existingContact))\n : undefined,\n [actor?.contact, existingContact],\n );\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { format, intervalToDuration } from 'date-fns';\nimport React, { type MouseEvent, useCallback, useRef } from 'react';\n\nimport { type Database, Obj } from '@dxos/echo';\nimport { EID, type URI } from '@dxos/keys';\nimport {\n Card,\n DxAnchorActivate,\n Icon,\n IconButton,\n type IconButtonProps,\n SystemIconButton,\n Tag,\n useTranslation,\n} from '@dxos/react-ui';\nimport { type Actor, type Message } from '@dxos/types';\nimport { toHue } from '@dxos/ui-theme';\n\nimport { useActorContact } from '../../hooks';\nimport { translationKey } from '../../translations';\nimport { Avatar, avatarName } from '../Avatar';\n\n/**\n * Shared Card-row primitives rendered inside a `Card.Body`. These are the single source for the\n * person/date/tags/ref/star rows used across the inbox tiles (`EventStack`/`InboxStack`), the preview\n * cards (`EventCard`/`MessageCard`), and the article headers — so a row of each kind is defined exactly\n * once and every surface composes from it.\n */\n\n//\n// AnchorIconButton — internal helper, not exported on Row.\n//\n\ntype AnchorIconButtonProps = {\n compact?: boolean;\n icon: string;\n fallbackIcon?: string;\n label: string;\n fallbackLabel?: string;\n title?: string;\n value?: URI.URI;\n size?: 4 | 5 | 6;\n onClick?: () => void;\n};\n\n/**\n * Icon-only button that opens an ECHO object's preview card via `DxAnchorActivate`.\n * Falls back to `onClick` when `value` is absent.\n */\nconst AnchorIconButton = ({\n compact,\n icon,\n fallbackIcon,\n label,\n fallbackLabel,\n title,\n value,\n size = 4,\n onClick,\n}: AnchorIconButtonProps) => {\n const buttonRef = useRef<HTMLButtonElement>(null);\n\n const handleClick = useCallback(() => {\n if (value) {\n buttonRef.current?.dispatchEvent(\n new DxAnchorActivate({\n trigger: buttonRef.current,\n dxn: value.toString(),\n label,\n kind: 'card',\n title,\n }),\n );\n } else {\n onClick?.();\n }\n }, [value, label, title, onClick]);\n\n return (\n <IconButton\n classNames={compact ? 'min-h-0' : 'aspect-square'}\n variant='ghost'\n disabled={!value && !onClick}\n icon={value ? icon : (fallbackIcon ?? icon)}\n iconOnly\n size={size}\n label={value ? label : (fallbackLabel ?? label)}\n onClick={handleClick}\n ref={buttonRef}\n />\n );\n};\n\n//\n// Date\n//\n\ntype RowDateProps = {\n start: Date;\n end?: Date;\n};\n\n/** A Card.Row rendering a date or date range with a calendar icon. */\nconst RowDate = ({ start, end }: RowDateProps) => {\n let { hours = 0, minutes = 0 } = (end && intervalToDuration({ start, end })) ?? {};\n // Prefer 90m over 1h 30m.\n if (hours === 1 && minutes !== 0) {\n hours = 0;\n minutes += 60;\n }\n const duration = [hours > 0 && `${hours}h`, minutes > 0 && `${minutes}m`].filter(Boolean).join(' ');\n\n return (\n <Card.Row>\n <Card.Block>\n <Icon icon='ph--calendar--regular' />\n </Card.Block>\n <div className='flex items-center gap-2 overflow-hidden whitespace-nowrap'>\n <div className='truncate text-description'>{format(start, 'PPp')}</div>\n {duration.length > 0 && <div className='text-description text-xs'>({duration})</div>}\n </div>\n </Card.Row>\n );\n};\n\nRowDate.displayName = 'Row.Date';\n\n//\n// Ref\n//\n\ntype RowRefProps = {\n object: Obj.Any;\n};\n\n/** A Card.Row rendering an ECHO ref/relation with a card-preview anchor icon. */\nconst RowRef = ({ object }: RowRefProps) => {\n const label = Obj.getLabel(object, { fallback: 'typename' }) ?? 'object';\n const icon = Obj.getIcon(object)?.icon ?? 'ph--cube--regular';\n const echoUri = EID.tryParse(Obj.getURI(object).toString());\n\n // TODO(burdon): Nav?\n return (\n <Card.Row>\n <Card.Block>\n <AnchorIconButton icon={icon} label={label} title={label} value={echoUri} />\n </Card.Block>\n <div className='flex items-center'>\n <span className='truncate text-primary-text'>{label}</span>\n </div>\n </Card.Row>\n );\n};\n\nRowRef.displayName = 'Row.Ref';\n\n//\n// Person\n//\n\n/** Recipient/participant kind; drives the leading icon and accessible label. */\nexport type PersonRole = 'from' | 'to' | 'cc' | 'bcc' | 'attendee';\n\ntype RowPersonProps = {\n actor: Actor.Actor;\n /** Recipient/participant kind (icon + aria only; no visible prefix). */\n role?: PersonRole;\n /**\n * Render a static `DxAvatar` in the gutter (hook-free) instead of the interactive contact anchor.\n * Used by list tiles where resolving a contact per row (a hook) would be too costly.\n */\n avatar?: boolean;\n db?: Database.Database;\n onContactCreate?: (actor: Actor.Actor) => void;\n /** Render a trailing remove button (e.g. attendee rows in the editable event header). */\n onRemove?: () => void;\n /** Click handler for the avatar (e.g. select the message); avatar variant only. */\n onClick?: (event: MouseEvent) => void;\n};\n\n/**\n * Static avatar variant — no contact resolution. Suitable for virtualized list tiles.\n */\nconst PersonAvatarRow = ({ actor, onClick }: Pick<RowPersonProps, 'actor' | 'onClick'>) => (\n <Card.Row>\n <Card.Block>\n <Avatar actor={actor} onClick={onClick} />\n </Card.Block>\n <Card.Text>{avatarName(actor) || actor.email}</Card.Text>\n </Card.Row>\n);\n\n/**\n * Interactive variant — resolves the contact to a card-preview anchor, with a create-contact fallback.\n */\nconst PersonAnchorRow = ({\n actor,\n role,\n db,\n onContactCreate,\n onRemove,\n}: Omit<RowPersonProps, 'avatar' | 'onClick'>) => {\n const { t } = useTranslation(translationKey);\n const contactDXN = useActorContact(db, actor);\n\n const handleContactCreate = useCallback(() => onContactCreate?.(actor), [actor, onContactCreate]);\n\n // TODO(burdon): Reconcile with Avatar if space member.\n return (\n <Card.Row>\n <Card.Block>\n <AnchorIconButton\n icon='ph--user--regular'\n fallbackIcon='ph--user-plus--regular'\n label={t('show-contact.label')}\n fallbackLabel={t('create-contact.label')}\n title={role ? `${role}: ${actor.name}` : actor.name}\n value={contactDXN}\n onClick={onContactCreate ? handleContactCreate : undefined}\n />\n </Card.Block>\n <Card.Text>{actor.name || actor.email}</Card.Text>\n {onRemove && (\n <Card.Block end>\n <IconButton\n variant='ghost'\n iconOnly\n icon='ph--x--regular'\n label={t('remove-attendee.label')}\n onClick={onRemove}\n />\n </Card.Block>\n )}\n </Card.Row>\n );\n};\n\n/** A Card.Row rendering a person (sender, recipient, attendee). */\nconst RowPerson = ({ avatar, onClick, ...props }: RowPersonProps) =>\n avatar ? <PersonAvatarRow actor={props.actor} onClick={onClick} /> : <PersonAnchorRow {...props} />;\n\nRowPerson.displayName = 'Row.Person';\n\n//\n// Tags\n//\n\ntype TagItem = { id: string; label?: string; hue?: string };\n\ntype RowTagsProps = {\n /** Optional — callers may pass an undefined/empty list (e.g. a message with no tags). */\n tags?: TagItem[];\n /** When provided, each chip is clickable and stops event propagation. */\n onTagClick?: (label: string) => void;\n};\n\n/** A Card.Row rendering a set of label+hue tag chips, optionally clickable. */\nconst RowTags = ({ tags, onTagClick }: RowTagsProps) => {\n if (!tags?.length) {\n return null;\n }\n\n return (\n <Card.Row>\n <Card.Block>\n <Icon icon='ph--tag--regular' />\n </Card.Block>\n <div className='flex flex-wrap gap-1 py-1 -mx-0.5' data-testid='extracted-tags'>\n {tags.map((tag) => (\n <Tag\n key={tag.id}\n hue={toHue(tag.hue)}\n data-testid={`message-tag-${tag.id}`}\n onClick={\n onTagClick\n ? (event) => {\n event.stopPropagation();\n onTagClick(tag.label ?? tag.id);\n }\n : undefined\n }\n >\n {tag.label ?? tag.id}\n </Tag>\n ))}\n </div>\n </Card.Row>\n );\n};\n\nRowTags.displayName = 'Row.Tags';\n\n//\n// Attachments\n//\n\ntype RowAttachmentsProps = {\n /** Optional — callers may pass an undefined/empty list (e.g. a message with no attachments). */\n attachments?: readonly Message.Attachment[];\n};\n\n/**\n * A Card.Row listing a message's attachments by name with a generic file icon. Not yet clickable —\n * resolving the attachment's ref to open/preview it is a follow-up.\n */\nconst RowAttachments = ({ attachments }: RowAttachmentsProps) => {\n if (!attachments?.length) {\n return null;\n }\n\n return (\n <Card.Row>\n <Card.Block>\n <Icon icon='ph--paperclip--regular' />\n </Card.Block>\n <div className='flex flex-wrap gap-1 py-1 -mx-0.5' data-testid='message-attachments'>\n {attachments.map((attachment) => (\n <Tag key={attachment.ref.uri} hue='neutral' classNames='inline-flex items-center gap-1'>\n <Icon icon='ph--file--regular' size={3} />\n {attachment.name ?? attachment.ref.uri}\n </Tag>\n ))}\n </div>\n </Card.Row>\n );\n};\n\nRowAttachments.displayName = 'Row.Attachments';\n\n//\n// Star\n//\n\ntype RowStarProps = {\n starred?: boolean;\n /** Toggle handler; the button renders only when provided. */\n onToggle?: () => void;\n};\n\n/**\n * Star toggle for a `Card.Block` leading gutter (shared by event/message tiles and headers). Stops\n * the click from bubbling so starring doesn't also select/activate the surrounding tile or card.\n */\nconst RowStar = ({ starred, onToggle }: RowStarProps) => {\n const handleClick = useCallback<NonNullable<IconButtonProps['onClick']>>(\n (event) => {\n event.stopPropagation();\n onToggle?.();\n },\n [onToggle],\n );\n\n if (!onToggle) {\n return null;\n }\n\n return <SystemIconButton.Star iconOnly variant='ghost' active={starred} onClick={handleClick} />;\n};\n\nRowStar.displayName = 'Row.Star';\n\n//\n// Row\n//\n\nexport const Row = {\n Date: RowDate,\n Ref: RowRef,\n Person: RowPerson,\n Tags: RowTags,\n Attachments: RowAttachments,\n Star: RowStar,\n};\n\nexport type { RowAttachmentsProps, RowDateProps, RowPersonProps, RowRefProps, RowStarProps, RowTagsProps };\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { type MouseEvent, PropsWithChildren, type ReactNode, forwardRef } from 'react';\n\nimport { Card, type ThemedClassName } from '@dxos/react-ui';\nimport { Focus, Mosaic, type MosaicTileProps } from '@dxos/react-ui-mosaic';\n\nimport { Row } from '../Row';\n\n//\n// Root\n//\n\ntype CardTileRootProps = ThemedClassName<\n PropsWithChildren<\n Pick<MosaicTileProps<unknown>, 'data' | 'location' | 'current'> & {\n 'id': string;\n 'onCurrentChange': () => void;\n 'onClick'?: (event: MouseEvent) => void;\n 'data-testid'?: string;\n }\n >\n>;\n\n/**\n * Shared mosaic tile shell: `Mosaic.Tile` → `Focus.Item` → `Card.Root`.\n * Callers supply the inner `Card.Header`/`Card.Body` (typically via {@link CardTileHeader} + rows).\n * Activation is committed by the caller's `onCurrentChange` (Mosaic `current`/selection), so click/Enter light the tile up.\n */\nconst CardTileRoot = forwardRef<HTMLDivElement, CardTileRootProps>(\n (\n { id, data, location, current, onCurrentChange, onClick, classNames, children, 'data-testid': testId },\n forwardedRef,\n ) => (\n <Mosaic.Tile\n asChild\n id={id}\n data={data}\n location={location}\n classNames={classNames ?? 'dx-hover dx-current dx-selected p-1 rounded-md border border-subdued-separator'}\n >\n <Focus.Item asChild current={current} onCurrentChange={onCurrentChange}>\n <Card.Root fullWidth border={false} onClick={onClick} ref={forwardedRef} data-testid={testId}>\n {children}\n </Card.Root>\n </Focus.Item>\n </Mosaic.Tile>\n ),\n);\n\nCardTileRoot.displayName = 'CardTile.Root';\n\n//\n// Header\n//\n\n/** A single `Card.Menu` dropdown item. */\nexport type CardTileMenuItem = {\n label: string;\n icon?: string;\n onClick: () => void;\n};\n\ntype CardTileHeaderProps = {\n /** Header title content (rendered in a flex row). */\n title: ReactNode;\n /** Whether the tile is starred. `Row.Star` renders the button only when `onToggleStar` is set. */\n starred?: boolean;\n /** Render the trailing `Card.Menu` action slot. */\n menu?: boolean;\n /** Items for the `Card.Menu` dropdown (the trigger is disabled when empty). */\n menuItems?: CardTileMenuItem[];\n onToggleStar?: () => void;\n};\n\n/**\n * Tile header row: leading `Row.Star` · title · optional `Card.Menu`. Shared by message/conversation\n * tiles (with menu) and event tiles (star + title only).\n */\nconst CardTileHeader = ({ title, starred, menu = false, menuItems, onToggleStar }: CardTileHeaderProps) => (\n <Card.Header>\n <Card.Block>\n <Row.Star starred={starred} onToggle={onToggleStar} />\n </Card.Block>\n <Card.Title classNames='flex items-center gap-3'>{title}</Card.Title>\n {menu && <Card.Menu items={menuItems} />}\n </Card.Header>\n);\n\nCardTileHeader.displayName = 'CardTile.Header';\n\n//\n// Tile\n//\n\nexport const CardTile = {\n Root: CardTileRoot,\n Header: CardTileHeader,\n};\n\nexport type { CardTileHeaderProps, CardTileRootProps };\n"],"mappings":";;;;;;;;;;;;;;;AAKA,IAAa,cAAc,QACzB,MAAM,KAAK,IAAI,IAAI,MAAM,EAAE,CAAC,CAAC,QAAQ,MAAM,UAAU,QAAQ,KAAK,OAAO,KAAK,WAAW,CAAC,GAAG,CAAC,CAA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A,IAAI,CAAC,UACH,OAAO;CAGT,OAAO,oBAAC,iBAAiB,MAAlB;EAAuB,UAAA;EAAS,SAAQ;EAAQ,QAAQ;EAAS,SAAS;CAAc,CAAA;AACjG;AAEA,QAAQ,cAAc;AAMtB,IAAa,MAAM;CACjB,MAAM;CACN,KAAK;CACL,QAAQ;CACR,MAAM;CACN,aAAa;CACb,MAAM;AACR;;;;;;;;ACzVA,IAAM,eAAe,YAEjB,EAAE,IAAI,MAAM,UAAU,SAAS,iBAAiB,SAAS,YAAY,UAAU,eAAe,UAC9F,iBAEA,oBAAC,OAAO,MAAR;CACE,SAAA;CACI;CACE;CACI;CACV,YAAY,cAAc;WAE1B,oBAAC,MAAM,MAAP;EAAY,SAAA;EAAiB;EAA0B;YACrD,oBAAC,KAAK,MAAN;GAAW,WAAA;GAAU,QAAQ;GAAgB;GAAS,KAAK;GAAc,eAAa;GACnF;EACQ,CAAA;CACD,CAAA;AACD,CAAA,CAEjB;AAEA,aAAa,cAAc;;;;;AA6B3B,IAAM,kBAAkB,EAAE,OAAO,SAAS,OAAO,OAAO,WAAW,mBACjE,qBAAC,KAAK,QAAN,EAAA,UAAA;CACE,oBAAC,KAAK,OAAN,EAAA,UACE,oBAAC,IAAI,MAAL;EAAmB;EAAS,UAAU;CAAe,CAAA,EAC3C,CAAA;CACZ,oBAAC,KAAK,OAAN;EAAY,YAAW;YAA2B;CAAkB,CAAA;CACnE,QAAQ,oBAAC,KAAK,MAAN,EAAW,OAAO,UAAY,CAAA;AAC5B,EAAA,CAAA;AAGf,eAAe,cAAc;AAM7B,IAAa,WAAW;CACtB,MAAM;CACN,QAAQ;AACV"}
@@ -0,0 +1,11 @@
1
+ //#region src/translations.ts
2
+ var translationKey = "@dxos/react-ui-card";
3
+ var translations = [{ "en-US": { [translationKey]: {
4
+ "show-contact.label": "Show contact",
5
+ "create-contact.label": "Create contact",
6
+ "remove-attendee.label": "Remove attendee"
7
+ } } }];
8
+ //#endregion
9
+ export { translationKey, translations };
10
+
11
+ //# sourceMappingURL=translations.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translations.mjs","names":[],"sources":["../../src/translations.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport { type Resource } from '@dxos/react-ui';\n\nexport const translationKey = '@dxos/react-ui-card';\n\nexport const translations = [\n {\n 'en-US': {\n [translationKey]: {\n 'show-contact.label': 'Show contact',\n 'create-contact.label': 'Create contact',\n 'remove-attendee.label': 'Remove attendee',\n },\n },\n },\n] as const satisfies Resource[];\n"],"mappings":";AAMA,IAAa,iBAAiB;AAE9B,IAAa,eAAe,CAC1B,EACE,SAAS,GACN,iBAAiB;CAChB,sBAAsB;CACtB,wBAAwB;CACxB,yBAAyB;AAC3B,EACF,EACF,CACF"}
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { type DxAvatarProps } from '@dxos/lit-ui/react';
3
+ import { type Actor } from '@dxos/types';
4
+ export type AvatarProps = Pick<DxAvatarProps, 'variant' | 'size' | 'onClick'> & {
5
+ /** Sender/participant; supplies the display name and the hue. */
6
+ actor?: Actor.Actor;
7
+ /** Label override; defaults to the actor's {@link avatarName}. */
8
+ name?: string;
9
+ };
10
+ export declare function Avatar({ actor, name, variant, size, onClick }: AvatarProps): React.JSX.Element;
11
+ export declare namespace Avatar {
12
+ var displayName: string;
13
+ }
14
+ //# sourceMappingURL=Avatar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../../../src/components/Avatar/Avatar.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAKzC,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC,GAAG;IAC9E,iEAAiE;IACjE,KAAK,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC;IACpB,kEAAkE;IAClE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;+BAOqB,EAAE,KAAK,EAAE,IAAI,EAAE,OAAkB,EAAE,IAAQ,EAAE,OAAO,EAAE,EAAE,WAAW"}
@@ -0,0 +1,15 @@
1
+ import { type StoryObj } from '@storybook/react-vite';
2
+ declare const meta: {
3
+ title: string;
4
+ component: {
5
+ ({ actor, name, variant, size, onClick }: import("./Avatar").AvatarProps): import("react").JSX.Element;
6
+ displayName: string;
7
+ };
8
+ decorators: import("@storybook/react").Decorator[];
9
+ };
10
+ export default meta;
11
+ type Story = StoryObj<typeof meta>;
12
+ export declare const Default: Story;
13
+ export declare const Square: Story;
14
+ export declare const EmailOnly: Story;
15
+ //# sourceMappingURL=Avatar.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Avatar.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Avatar/Avatar.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAMjE,QAAA,MAAM,IAAI;;;;;;;CAIqB,CAAC;eAEjB,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAErB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAEpB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAEvB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { type Actor } from '@dxos/types';
2
+ /** Canonical display name for an actor — the avatar glyph fallback and the hue key are both derived from it. */
3
+ export declare const avatarName: (actor?: Actor.Actor) => string;
4
+ /** Single source for a name→hue mapping, so the same sender is one color across every surface. */
5
+ export declare const nameToHue: (name?: string) => string;
6
+ //# sourceMappingURL=avatar-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatar-name.d.ts","sourceRoot":"","sources":["../../../../../src/components/Avatar/avatar-name.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AASzC,gHAAgH;AAChH,eAAO,MAAM,UAAU,WAAY,KAAK,CAAC,KAAK,KAAG,MACsB,CAAC;AAExE,kGAAkG;AAClG,eAAO,MAAM,SAAS,UAAW,MAAM,KAAG,MAAiC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './avatar-name';
2
+ export * from './Avatar';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Avatar/index.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC;AAE9B,cAAc,UAAU,CAAC"}
@@ -0,0 +1,46 @@
1
+ import React, { type MouseEvent, PropsWithChildren, type ReactNode } from 'react';
2
+ import { type ThemedClassName } from '@dxos/react-ui';
3
+ import { type MosaicTileProps } from '@dxos/react-ui-mosaic';
4
+ type CardTileRootProps = ThemedClassName<PropsWithChildren<Pick<MosaicTileProps<unknown>, 'data' | 'location' | 'current'> & {
5
+ 'id': string;
6
+ 'onCurrentChange': () => void;
7
+ 'onClick'?: (event: MouseEvent) => void;
8
+ 'data-testid'?: string;
9
+ }>>;
10
+ /** A single `Card.Menu` dropdown item. */
11
+ export type CardTileMenuItem = {
12
+ label: string;
13
+ icon?: string;
14
+ onClick: () => void;
15
+ };
16
+ type CardTileHeaderProps = {
17
+ /** Header title content (rendered in a flex row). */
18
+ title: ReactNode;
19
+ /** Whether the tile is starred. `Row.Star` renders the button only when `onToggleStar` is set. */
20
+ starred?: boolean;
21
+ /** Render the trailing `Card.Menu` action slot. */
22
+ menu?: boolean;
23
+ /** Items for the `Card.Menu` dropdown (the trigger is disabled when empty). */
24
+ menuItems?: CardTileMenuItem[];
25
+ onToggleStar?: () => void;
26
+ };
27
+ declare function CardTileHeader({ title, starred, menu, menuItems, onToggleStar }: CardTileHeaderProps): React.JSX.Element;
28
+ declare namespace CardTileHeader {
29
+ var displayName: string;
30
+ }
31
+ export declare const CardTile: {
32
+ Root: React.ForwardRefExoticComponent<Omit<PropsWithChildren<Pick<MosaicTileProps<unknown>, "current" | "data" | "location"> & {
33
+ id: string;
34
+ onCurrentChange: () => void;
35
+ onClick?: (event: MouseEvent) => void;
36
+ 'data-testid'?: string;
37
+ }>, "className"> & {
38
+ classNames?: import("@dxos/ui-types").ClassNameValue;
39
+ } & React.RefAttributes<HTMLDivElement>>;
40
+ Header: {
41
+ ({ title, starred, menu, menuItems, onToggleStar }: CardTileHeaderProps): React.JSX.Element;
42
+ displayName: string;
43
+ };
44
+ };
45
+ export type { CardTileHeaderProps, CardTileRootProps };
46
+ //# sourceMappingURL=CardTile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardTile.d.ts","sourceRoot":"","sources":["../../../../../src/components/CardTile/CardTile.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,UAAU,EAAE,iBAAiB,EAAE,KAAK,SAAS,EAAc,MAAM,OAAO,CAAC;AAE9F,OAAO,EAAQ,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAQ5E,KAAK,iBAAiB,GAAG,eAAe,CACtC,iBAAiB,CACf,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC,GAAG;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CACF,CACF,CAAC;AAkCF,0CAA0C;AAC1C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,qDAAqD;IACrD,KAAK,EAAE,SAAS,CAAC;IACjB,kGAAkG;IAClG,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mDAAmD;IACnD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,+EAA+E;IAC/E,SAAS,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;gCAMsB,EAAE,KAAK,EAAE,OAAO,EAAE,IAAY,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,mBAAmB;;;;AAgBtG,eAAO,MAAM,QAAQ;IACnB,IAAI;YAhFM,MAAM;yBACO,MAAM,IAAI;kBACjB,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI;wBACvB,MAAM;;;;IA8E1B,MAAM;4DAlB2E,mBAAmB;;;CAmBrG,CAAC;AAEF,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { type StoryObj } from '@storybook/react-vite';
2
+ import React from 'react';
3
+ declare const meta: {
4
+ title: string;
5
+ render: ({ menu, starred }: {
6
+ menu?: boolean;
7
+ starred?: boolean;
8
+ }) => React.JSX.Element;
9
+ decorators: import("@storybook/react").Decorator[];
10
+ parameters: {
11
+ layout: string;
12
+ translations: [{
13
+ readonly 'en-US': {
14
+ readonly "@dxos/react-ui-card": {
15
+ readonly 'show-contact.label': 'Show contact';
16
+ readonly 'create-contact.label': 'Create contact';
17
+ readonly 'remove-attendee.label': 'Remove attendee';
18
+ };
19
+ };
20
+ }];
21
+ };
22
+ };
23
+ export default meta;
24
+ type Story = StoryObj<typeof meta>;
25
+ export declare const Default: Story;
26
+ export declare const NoStar: Story;
27
+ //# sourceMappingURL=CardTile.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardTile.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/CardTile/CardTile.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAgC1B,QAAA,MAAM,IAAI;;gCArB+B;QAAE,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE;;;;;;;;;;;;;;CA6BzC,CAAC;eAEvB,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAA+C,CAAC;AAEtE,eAAO,MAAM,MAAM,EAAE,KAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './CardTile';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/CardTile/index.ts"],"names":[],"mappings":"AAIA,cAAc,YAAY,CAAC"}