@cellarnode/ui 0.183.0 → 0.185.0
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/components/journey-card.d.ts.map +1 -1
- package/dist/components/journey-card.js +2 -1
- package/dist/components/journey-card.js.map +1 -1
- package/dist/components/sortable-card-grip.d.ts +23 -0
- package/dist/components/sortable-card-grip.d.ts.map +1 -0
- package/dist/components/sortable-card-grip.js +13 -0
- package/dist/components/sortable-card-grip.js.map +1 -0
- package/dist/components/sortable-card-shell.d.ts +29 -19
- package/dist/components/sortable-card-shell.d.ts.map +1 -1
- package/dist/components/sortable-card-shell.js +49 -27
- package/dist/components/sortable-card-shell.js.map +1 -1
- package/dist/org/index.d.ts +2 -0
- package/dist/org/index.d.ts.map +1 -1
- package/dist/org/index.js +2 -0
- package/dist/org/index.js.map +1 -1
- package/dist/org/organisation-shell.d.ts +41 -0
- package/dist/org/organisation-shell.d.ts.map +1 -0
- package/dist/org/organisation-shell.js +24 -0
- package/dist/org/organisation-shell.js.map +1 -0
- package/dist/profile/account-actions-card.d.ts +28 -0
- package/dist/profile/account-actions-card.d.ts.map +1 -0
- package/dist/profile/account-actions-card.js +37 -0
- package/dist/profile/account-actions-card.js.map +1 -0
- package/dist/profile/account-edit-form.d.ts +84 -0
- package/dist/profile/account-edit-form.d.ts.map +1 -0
- package/dist/profile/account-edit-form.js +168 -0
- package/dist/profile/account-edit-form.js.map +1 -0
- package/dist/profile/account-preferences-card.d.ts +27 -0
- package/dist/profile/account-preferences-card.d.ts.map +1 -0
- package/dist/profile/account-preferences-card.js +53 -0
- package/dist/profile/account-preferences-card.js.map +1 -0
- package/dist/profile/index.d.ts +10 -0
- package/dist/profile/index.d.ts.map +1 -1
- package/dist/profile/index.js +6 -0
- package/dist/profile/index.js.map +1 -1
- package/dist/profile/subscription-card.d.ts +49 -0
- package/dist/profile/subscription-card.d.ts.map +1 -0
- package/dist/profile/subscription-card.js +53 -0
- package/dist/profile/subscription-card.js.map +1 -0
- package/dist/profile/user-information-card.d.ts +55 -0
- package/dist/profile/user-information-card.d.ts.map +1 -0
- package/dist/profile/user-information-card.js +63 -0
- package/dist/profile/user-information-card.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Building2Icon, SquarePenIcon } from "lucide-react";
|
|
3
|
+
import { Avatar } from "../components/avatar.js";
|
|
4
|
+
import { Badge } from "../components/badge.js";
|
|
5
|
+
import { Button } from "../components/button.js";
|
|
6
|
+
import { cn } from "../lib/utils.js";
|
|
7
|
+
import { ProfileActions, ProfileCard, ProfileInfoGrid, ProfileInfoItem } from "./profile.js";
|
|
8
|
+
const DEFAULT_LABELS = {
|
|
9
|
+
title: "User Information",
|
|
10
|
+
description: "Your account identity and access details.",
|
|
11
|
+
role: "Role",
|
|
12
|
+
organisation: "Organisation",
|
|
13
|
+
accountId: "Account ID",
|
|
14
|
+
phone: "Phone",
|
|
15
|
+
editAccount: "Edit Account",
|
|
16
|
+
notSet: "Not set",
|
|
17
|
+
noEmail: "No email available",
|
|
18
|
+
unnamedUser: "User",
|
|
19
|
+
loading: "Loading...",
|
|
20
|
+
unknownRole: "Unknown",
|
|
21
|
+
};
|
|
22
|
+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
23
|
+
/** Initials from a display name: first letters of the first two words. */
|
|
24
|
+
export function deriveInitials(name) {
|
|
25
|
+
const parts = (name ?? "").trim().split(/\s+/).filter(Boolean).slice(0, 2);
|
|
26
|
+
return (parts
|
|
27
|
+
.map((part) => part[0])
|
|
28
|
+
.join("")
|
|
29
|
+
.toUpperCase() || "?");
|
|
30
|
+
}
|
|
31
|
+
/** @internal Trimmed text or null. */
|
|
32
|
+
export function present(value) {
|
|
33
|
+
const trimmed = value?.trim();
|
|
34
|
+
return trimmed ? trimmed : null;
|
|
35
|
+
}
|
|
36
|
+
/** @internal The trimmed organisation name or null. Warns in development when it looks like an id. */
|
|
37
|
+
export function safeOrganisationName(value) {
|
|
38
|
+
const org = present(value);
|
|
39
|
+
if (org && process.env.NODE_ENV !== "production" && UUID_RE.test(org)) {
|
|
40
|
+
console.warn("[@cellarnode/ui/profile] `organisationName` looks like an id. Pass the organisation NAME.");
|
|
41
|
+
}
|
|
42
|
+
return org;
|
|
43
|
+
}
|
|
44
|
+
/** @internal Producer's formatRole: first letter capitalised. */
|
|
45
|
+
export function formatRoleLabel(role, unknown) {
|
|
46
|
+
const value = present(role);
|
|
47
|
+
return value ? value.charAt(0).toUpperCase() + value.slice(1) : unknown;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The "User Information" card of the personal profile page (CEL-2126).
|
|
51
|
+
* Producer's card: avatar, name, email, role badge, organisation name,
|
|
52
|
+
* account id, an optional phone and an optional Edit Account action.
|
|
53
|
+
*/
|
|
54
|
+
export function UserInformationCard({ name, email, avatarUrl, initials, role, organisationName, accountId, phone, onEdit, isLoading = false, labels, className, }) {
|
|
55
|
+
const l = { ...DEFAULT_LABELS, ...labels };
|
|
56
|
+
const displayName = present(name) ?? l.unnamedUser;
|
|
57
|
+
const org = safeOrganisationName(organisationName);
|
|
58
|
+
const phoneText = present(phone);
|
|
59
|
+
const hasPhoneRow = phone !== undefined;
|
|
60
|
+
const footer = onEdit ? (_jsx(ProfileActions, { children: _jsxs(Button, { color: "brand", onClick: onEdit, children: [_jsx(SquarePenIcon, { className: "size-4", "aria-hidden": "true" }), l.editAccount] }) })) : undefined;
|
|
61
|
+
return (_jsxs(ProfileCard, { title: l.title, description: l.description, footer: footer, className: cn(className), children: [_jsxs("div", { className: "mb-5 flex min-w-0 items-center gap-4", children: [_jsx(Avatar, { src: avatarUrl, square: true, initials: initials ?? deriveInitials(displayName), alt: displayName, className: "size-14 rounded-full bg-primary/15 text-primary" }), _jsxs("div", { className: "flex min-w-0 flex-col gap-0.5", children: [_jsx("p", { className: "break-words text-base font-semibold text-foreground", children: isLoading ? l.loading : displayName }), _jsx("p", { className: "break-words text-sm text-muted-foreground", children: present(email) ?? l.noEmail })] })] }), _jsxs(ProfileInfoGrid, { children: [_jsx(ProfileInfoItem, { label: l.role, children: _jsx(Badge, { color: "zinc", className: "bg-primary/10 text-primary", children: formatRoleLabel(role, l.unknownRole) }) }), _jsx(ProfileInfoItem, { label: l.organisation, children: _jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-foreground", children: [_jsx(Building2Icon, { className: "size-4 shrink-0 text-primary", "aria-hidden": "true" }), _jsx("span", { className: "min-w-0 break-words", children: org ?? l.notSet })] }) }), hasPhoneRow ? (_jsx(ProfileInfoItem, { label: l.phone, colSpan: "full", children: _jsx("span", { className: "break-words", children: phoneText ?? l.notSet }) })) : null, _jsx(ProfileInfoItem, { label: l.accountId, colSpan: "full", children: _jsx("span", { className: "break-all font-mono text-sm text-foreground", children: present(accountId) ?? "-" }) })] })] }));
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=user-information-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-information-card.js","sourceRoot":"","sources":["../../src/profile/user-information-card.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AA4C1F,MAAM,cAAc,GAAwC;IAC1D,KAAK,EAAE,kBAAkB;IACzB,WAAW,EAAE,2CAA2C;IACxD,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AO,CAAC,SAAS,CAAC,IAAI,GAAG,GACrB,GACS,IACF,IACN,CACf,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cellarnode/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.185.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"packageManager": "pnpm@10.28.2+sha512.41872f037ad22f7348e3b1debbaf7e867cfd448f2726d9cf74c08f19507c31d2c8e7a11525b983febc2df640b5438dee6023ebb1f84ed43cc2d654d2bc326264",
|