@heigin/ui 0.0.0-stage → 0.1.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/CHANGELOG.md +20 -0
- package/LICENSE +15 -0
- package/README.md +28 -2
- package/dist/base.css +44 -0
- package/dist/components/crm/activity-timeline.d.ts +23 -0
- package/dist/components/crm/activity-timeline.js +41 -0
- package/dist/components/crm/approval-card.d.ts +33 -0
- package/dist/components/crm/approval-card.js +101 -0
- package/dist/components/crm/channel-mark.d.ts +10 -0
- package/dist/components/crm/channel-mark.js +57 -0
- package/dist/components/crm/conversation-list-item.d.ts +23 -0
- package/dist/components/crm/conversation-list-item.js +62 -0
- package/dist/components/crm/crm.module.js +161 -0
- package/dist/components/crm/deal-stage.d.ts +13 -0
- package/dist/components/crm/deal-stage.js +27 -0
- package/dist/components/crm/detail-list.d.ts +17 -0
- package/dist/components/crm/detail-list.js +35 -0
- package/dist/components/crm/filter-chip.d.ts +16 -0
- package/dist/components/crm/filter-chip.js +45 -0
- package/dist/components/crm/filter-toolbar.d.ts +16 -0
- package/dist/components/crm/filter-toolbar.js +42 -0
- package/dist/components/crm/metric-card.d.ts +30 -0
- package/dist/components/crm/metric-card.js +61 -0
- package/dist/components/crm/money-value.d.ts +9 -0
- package/dist/components/crm/money-value.js +27 -0
- package/dist/components/crm/page-header.d.ts +11 -0
- package/dist/components/crm/page-header.js +28 -0
- package/dist/components/crm/record-header.d.ts +22 -0
- package/dist/components/crm/record-header.js +53 -0
- package/dist/components/crm/sidebar-nav.d.ts +33 -0
- package/dist/components/crm/sidebar-nav.js +53 -0
- package/dist/components/crm/sla-clock.d.ts +11 -0
- package/dist/components/crm/sla-clock.js +41 -0
- package/dist/components/crm/status-badge.d.ts +94 -0
- package/dist/components/crm/status-badge.js +106 -0
- package/dist/components/crm/task-row.d.ts +18 -0
- package/dist/components/crm/task-row.js +52 -0
- package/dist/components/crm/trust-rung-badge.d.ts +14 -0
- package/dist/components/crm/trust-rung-badge.js +35 -0
- package/dist/components/ui/alert-dialog.d.ts +22 -0
- package/dist/components/ui/alert-dialog.js +87 -0
- package/dist/components/ui/avatar.d.ts +13 -0
- package/dist/components/ui/avatar.js +38 -0
- package/dist/components/ui/avatar.module.js +17 -0
- package/dist/components/ui/badge.d.ts +12 -0
- package/dist/components/ui/badge.js +28 -0
- package/dist/components/ui/badge.module.js +25 -0
- package/dist/components/ui/button.d.ts +19 -0
- package/dist/components/ui/button.js +39 -0
- package/dist/components/ui/button.module.js +27 -0
- package/dist/components/ui/card.d.ts +19 -0
- package/dist/components/ui/card.js +35 -0
- package/dist/components/ui/card.module.js +23 -0
- package/dist/components/ui/checkbox.d.ts +11 -0
- package/dist/components/ui/checkbox.js +47 -0
- package/dist/components/ui/choice.module.js +28 -0
- package/dist/components/ui/dialog.d.ts +32 -0
- package/dist/components/ui/dialog.js +67 -0
- package/dist/components/ui/dialog.module.js +39 -0
- package/dist/components/ui/drawer.d.ts +20 -0
- package/dist/components/ui/drawer.js +44 -0
- package/dist/components/ui/dropdown-menu.d.ts +38 -0
- package/dist/components/ui/dropdown-menu.js +66 -0
- package/dist/components/ui/empty-state.d.ts +12 -0
- package/dist/components/ui/empty-state.js +33 -0
- package/dist/components/ui/empty-state.module.js +19 -0
- package/dist/components/ui/field.d.ts +38 -0
- package/dist/components/ui/field.js +77 -0
- package/dist/components/ui/field.module.js +17 -0
- package/dist/components/ui/icon-button.d.ts +9 -0
- package/dist/components/ui/icon-button.js +21 -0
- package/dist/components/ui/input.d.ts +8 -0
- package/dist/components/ui/input.js +23 -0
- package/dist/components/ui/input.module.js +25 -0
- package/dist/components/ui/kbd.d.ts +3 -0
- package/dist/components/ui/kbd.js +34 -0
- package/dist/components/ui/native-select.d.ts +10 -0
- package/dist/components/ui/native-select.js +26 -0
- package/dist/components/ui/pagination.d.ts +13 -0
- package/dist/components/ui/pagination.js +55 -0
- package/dist/components/ui/popover.d.ts +17 -0
- package/dist/components/ui/popover.js +41 -0
- package/dist/components/ui/popup.module.js +39 -0
- package/dist/components/ui/radio-group.d.ts +18 -0
- package/dist/components/ui/radio-group.js +50 -0
- package/dist/components/ui/search-input.d.ts +15 -0
- package/dist/components/ui/search-input.js +64 -0
- package/dist/components/ui/select.d.ts +27 -0
- package/dist/components/ui/select.js +71 -0
- package/dist/components/ui/skeleton.d.ts +12 -0
- package/dist/components/ui/skeleton.js +23 -0
- package/dist/components/ui/skeleton.module.js +15 -0
- package/dist/components/ui/spinner.d.ts +8 -0
- package/dist/components/ui/spinner.js +19 -0
- package/dist/components/ui/spinner.module.js +13 -0
- package/dist/components/ui/switch.d.ts +10 -0
- package/dist/components/ui/switch.js +35 -0
- package/dist/components/ui/table.d.ts +52 -0
- package/dist/components/ui/table.js +143 -0
- package/dist/components/ui/table.module.js +42 -0
- package/dist/components/ui/tabs.d.ts +25 -0
- package/dist/components/ui/tabs.js +47 -0
- package/dist/components/ui/tabs.module.js +21 -0
- package/dist/components/ui/textarea.d.ts +6 -0
- package/dist/components/ui/textarea.js +23 -0
- package/dist/components/ui/toast.d.ts +30 -0
- package/dist/components/ui/toast.js +81 -0
- package/dist/components/ui/toast.module.js +21 -0
- package/dist/components/ui/tooltip.d.ts +18 -0
- package/dist/components/ui/tooltip.js +30 -0
- package/dist/components/ui/visually-hidden.d.ts +3 -0
- package/dist/components/ui/visually-hidden.js +26 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +50 -0
- package/dist/lib/cn.d.ts +2 -0
- package/dist/lib/cn.js +7 -0
- package/dist/lib/format.d.ts +6 -0
- package/dist/lib/format.js +33 -0
- package/dist/styles.css +2317 -0
- package/dist/tailwind.css +82 -0
- package/dist/tokens.css +131 -0
- package/dist/tokens.d.ts +339 -0
- package/dist/tokens.js +790 -0
- package/package.json +54 -4
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type StatusTone = "success" | "warning" | "danger" | "info" | "neutral";
|
|
3
|
+
/**
|
|
4
|
+
* Shared registry of named CRM statuses. Pages pass a key, never an ad-hoc colour.
|
|
5
|
+
* Extend it here (or pass `tone` + `label`) rather than styling statuses locally.
|
|
6
|
+
*/
|
|
7
|
+
export declare const STATUS_REGISTRY: {
|
|
8
|
+
new: {
|
|
9
|
+
label: string;
|
|
10
|
+
tone: "info";
|
|
11
|
+
};
|
|
12
|
+
contacted: {
|
|
13
|
+
label: string;
|
|
14
|
+
tone: "neutral";
|
|
15
|
+
};
|
|
16
|
+
qualified: {
|
|
17
|
+
label: string;
|
|
18
|
+
tone: "success";
|
|
19
|
+
};
|
|
20
|
+
not_interested: {
|
|
21
|
+
label: string;
|
|
22
|
+
tone: "neutral";
|
|
23
|
+
};
|
|
24
|
+
on_track: {
|
|
25
|
+
label: string;
|
|
26
|
+
tone: "success";
|
|
27
|
+
};
|
|
28
|
+
due_soon: {
|
|
29
|
+
label: string;
|
|
30
|
+
tone: "warning";
|
|
31
|
+
icon: import("lucide-react").LucideIcon;
|
|
32
|
+
};
|
|
33
|
+
breached: {
|
|
34
|
+
label: string;
|
|
35
|
+
tone: "danger";
|
|
36
|
+
};
|
|
37
|
+
draft: {
|
|
38
|
+
label: string;
|
|
39
|
+
tone: "neutral";
|
|
40
|
+
};
|
|
41
|
+
awaiting_approval: {
|
|
42
|
+
label: string;
|
|
43
|
+
tone: "warning";
|
|
44
|
+
};
|
|
45
|
+
approved: {
|
|
46
|
+
label: string;
|
|
47
|
+
tone: "success";
|
|
48
|
+
};
|
|
49
|
+
rejected: {
|
|
50
|
+
label: string;
|
|
51
|
+
tone: "danger";
|
|
52
|
+
};
|
|
53
|
+
sent: {
|
|
54
|
+
label: string;
|
|
55
|
+
tone: "info";
|
|
56
|
+
};
|
|
57
|
+
accepted: {
|
|
58
|
+
label: string;
|
|
59
|
+
tone: "success";
|
|
60
|
+
};
|
|
61
|
+
won: {
|
|
62
|
+
label: string;
|
|
63
|
+
tone: "success";
|
|
64
|
+
};
|
|
65
|
+
lost: {
|
|
66
|
+
label: string;
|
|
67
|
+
tone: "neutral";
|
|
68
|
+
};
|
|
69
|
+
paid: {
|
|
70
|
+
label: string;
|
|
71
|
+
tone: "success";
|
|
72
|
+
};
|
|
73
|
+
partially_paid: {
|
|
74
|
+
label: string;
|
|
75
|
+
tone: "warning";
|
|
76
|
+
};
|
|
77
|
+
overdue: {
|
|
78
|
+
label: string;
|
|
79
|
+
tone: "danger";
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
export type StatusKey = keyof typeof STATUS_REGISTRY;
|
|
83
|
+
export interface StatusBadgeProps {
|
|
84
|
+
/** Registry key. */
|
|
85
|
+
status?: StatusKey;
|
|
86
|
+
/** Override or ad-hoc tone (prefer adding to the registry). */
|
|
87
|
+
tone?: StatusTone;
|
|
88
|
+
label?: string;
|
|
89
|
+
/** Hide the icon in dense tables where the column header already gives context. */
|
|
90
|
+
hideIcon?: boolean;
|
|
91
|
+
className?: string;
|
|
92
|
+
}
|
|
93
|
+
/** Status = tint + ink + icon + word, never colour alone. Server-component safe. */
|
|
94
|
+
export declare function StatusBadge({ status, tone, label, hideIcon, className }: StatusBadgeProps): React.JSX.Element;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Badge } from "../ui/badge.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { CircleCheck, CircleDashed, CircleX, Clock, Info, TriangleAlert } from "lucide-react";
|
|
5
|
+
//#region src/components/crm/status-badge.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Shared registry of named CRM statuses. Pages pass a key, never an ad-hoc colour.
|
|
8
|
+
* Extend it here (or pass `tone` + `label`) rather than styling statuses locally.
|
|
9
|
+
*/
|
|
10
|
+
var STATUS_REGISTRY = {
|
|
11
|
+
new: {
|
|
12
|
+
label: "New",
|
|
13
|
+
tone: "info"
|
|
14
|
+
},
|
|
15
|
+
contacted: {
|
|
16
|
+
label: "Contacted",
|
|
17
|
+
tone: "neutral"
|
|
18
|
+
},
|
|
19
|
+
qualified: {
|
|
20
|
+
label: "Qualified",
|
|
21
|
+
tone: "success"
|
|
22
|
+
},
|
|
23
|
+
not_interested: {
|
|
24
|
+
label: "Not interested",
|
|
25
|
+
tone: "neutral"
|
|
26
|
+
},
|
|
27
|
+
on_track: {
|
|
28
|
+
label: "On track",
|
|
29
|
+
tone: "success"
|
|
30
|
+
},
|
|
31
|
+
due_soon: {
|
|
32
|
+
label: "Due soon",
|
|
33
|
+
tone: "warning",
|
|
34
|
+
icon: Clock
|
|
35
|
+
},
|
|
36
|
+
breached: {
|
|
37
|
+
label: "Breached",
|
|
38
|
+
tone: "danger"
|
|
39
|
+
},
|
|
40
|
+
draft: {
|
|
41
|
+
label: "Draft",
|
|
42
|
+
tone: "neutral"
|
|
43
|
+
},
|
|
44
|
+
awaiting_approval: {
|
|
45
|
+
label: "Awaiting approval",
|
|
46
|
+
tone: "warning"
|
|
47
|
+
},
|
|
48
|
+
approved: {
|
|
49
|
+
label: "Approved",
|
|
50
|
+
tone: "success"
|
|
51
|
+
},
|
|
52
|
+
rejected: {
|
|
53
|
+
label: "Rejected",
|
|
54
|
+
tone: "danger"
|
|
55
|
+
},
|
|
56
|
+
sent: {
|
|
57
|
+
label: "Sent",
|
|
58
|
+
tone: "info"
|
|
59
|
+
},
|
|
60
|
+
accepted: {
|
|
61
|
+
label: "Accepted",
|
|
62
|
+
tone: "success"
|
|
63
|
+
},
|
|
64
|
+
won: {
|
|
65
|
+
label: "Won",
|
|
66
|
+
tone: "success"
|
|
67
|
+
},
|
|
68
|
+
lost: {
|
|
69
|
+
label: "Lost",
|
|
70
|
+
tone: "neutral"
|
|
71
|
+
},
|
|
72
|
+
paid: {
|
|
73
|
+
label: "Paid",
|
|
74
|
+
tone: "success"
|
|
75
|
+
},
|
|
76
|
+
partially_paid: {
|
|
77
|
+
label: "Partially paid",
|
|
78
|
+
tone: "warning"
|
|
79
|
+
},
|
|
80
|
+
overdue: {
|
|
81
|
+
label: "Overdue",
|
|
82
|
+
tone: "danger"
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var toneIcon = {
|
|
86
|
+
success: CircleCheck,
|
|
87
|
+
warning: TriangleAlert,
|
|
88
|
+
danger: CircleX,
|
|
89
|
+
info: Info,
|
|
90
|
+
neutral: CircleDashed
|
|
91
|
+
};
|
|
92
|
+
/** Status = tint + ink + icon + word, never colour alone. Server-component safe. */
|
|
93
|
+
function StatusBadge({ status, tone, label, hideIcon = false, className }) {
|
|
94
|
+
const entry = status ? STATUS_REGISTRY[status] : void 0;
|
|
95
|
+
const resolvedTone = tone ?? entry?.tone ?? "neutral";
|
|
96
|
+
const Icon = entry?.icon ?? toneIcon[resolvedTone];
|
|
97
|
+
return /* @__PURE__ */ jsx(Badge, {
|
|
98
|
+
tone: resolvedTone,
|
|
99
|
+
icon: hideIcon ? void 0 : /* @__PURE__ */ jsx(Icon, { strokeWidth: 2 }),
|
|
100
|
+
className,
|
|
101
|
+
"data-status": status,
|
|
102
|
+
children: label ?? entry?.label ?? status
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { STATUS_REGISTRY, StatusBadge };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface TaskRowProps {
|
|
3
|
+
title: string;
|
|
4
|
+
/** Related record, e.g. "Kaveri Textiles · Asha Rao". */
|
|
5
|
+
context?: React.ReactNode;
|
|
6
|
+
/** Due label, e.g. "Today, 4:00 pm". */
|
|
7
|
+
due?: string;
|
|
8
|
+
overdue?: boolean;
|
|
9
|
+
done: boolean;
|
|
10
|
+
onDoneChange: (done: boolean) => void;
|
|
11
|
+
/** Optional trailing slot (assignee avatar, menu). */
|
|
12
|
+
aside?: React.ReactNode;
|
|
13
|
+
/** Opens the task. Rendered as the row's title button. */
|
|
14
|
+
onOpen?: () => void;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
/** A to-do in a list: complete checkbox, title, context, due date. Use inside a <ul>. */
|
|
18
|
+
export declare function TaskRow({ title, context, due, overdue, done, onDoneChange, aside, onOpen, className }: TaskRowProps): React.JSX.Element;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
import { Checkbox } from "../ui/checkbox.js";
|
|
5
|
+
import { Badge } from "../ui/badge.js";
|
|
6
|
+
import crm_module_default from "./crm.module.js";
|
|
7
|
+
import "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
//#region src/components/crm/task-row.tsx
|
|
10
|
+
/** A to-do in a list: complete checkbox, title, context, due date. Use inside a <ul>. */
|
|
11
|
+
function TaskRow({ title, context, due, overdue = false, done, onDoneChange, aside, onOpen, className }) {
|
|
12
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
13
|
+
className: cn(crm_module_default.row, onOpen && crm_module_default.rowInteractive, done && crm_module_default.done, className),
|
|
14
|
+
"data-done": done || void 0,
|
|
15
|
+
children: [
|
|
16
|
+
/* @__PURE__ */ jsx("span", {
|
|
17
|
+
className: crm_module_default.rowControl,
|
|
18
|
+
style: { paddingTop: 1 },
|
|
19
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
20
|
+
"aria-label": `Mark "${title}" as ${done ? "not done" : "done"}`,
|
|
21
|
+
checked: done,
|
|
22
|
+
onCheckedChange: onDoneChange
|
|
23
|
+
})
|
|
24
|
+
}),
|
|
25
|
+
/* @__PURE__ */ jsxs("div", {
|
|
26
|
+
className: crm_module_default.rowMain,
|
|
27
|
+
children: [onOpen ? /* @__PURE__ */ jsx("button", {
|
|
28
|
+
type: "button",
|
|
29
|
+
className: crm_module_default.rowTitle,
|
|
30
|
+
onClick: onOpen,
|
|
31
|
+
children: title
|
|
32
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
33
|
+
className: crm_module_default.rowTitle,
|
|
34
|
+
children: title
|
|
35
|
+
}), context && /* @__PURE__ */ jsx("div", {
|
|
36
|
+
className: crm_module_default.rowMeta,
|
|
37
|
+
children: context
|
|
38
|
+
})]
|
|
39
|
+
}),
|
|
40
|
+
(due || aside) && /* @__PURE__ */ jsxs("div", {
|
|
41
|
+
className: crm_module_default.rowAside,
|
|
42
|
+
children: [due && (overdue && !done ? /* @__PURE__ */ jsxs(Badge, {
|
|
43
|
+
tone: "danger",
|
|
44
|
+
dot: true,
|
|
45
|
+
children: ["Overdue · ", due]
|
|
46
|
+
}) : /* @__PURE__ */ jsx("span", { children: due })), aside]
|
|
47
|
+
})
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { TaskRow };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type TrustRung = 0 | 1 | 2 | 3;
|
|
2
|
+
/** Canonical trust-ladder labels from the HeiGin product context. Use these words everywhere. */
|
|
3
|
+
export declare const TRUST_RUNGS: Record<TrustRung, {
|
|
4
|
+
label: string;
|
|
5
|
+
meaning: string;
|
|
6
|
+
}>;
|
|
7
|
+
export interface TrustRungBadgeProps {
|
|
8
|
+
rung: TrustRung;
|
|
9
|
+
/** Show "R2 · Act with review" instead of just the label. */
|
|
10
|
+
showCode?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
/** The AI agent's autonomy level for a capability. Server-component safe. */
|
|
14
|
+
export declare function TrustRungBadge({ rung, showCode, className }: TrustRungBadgeProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Badge } from "../ui/badge.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/crm/trust-rung-badge.tsx
|
|
4
|
+
/** Canonical trust-ladder labels from the HeiGin product context. Use these words everywhere. */
|
|
5
|
+
var TRUST_RUNGS = {
|
|
6
|
+
0: {
|
|
7
|
+
label: "Read only",
|
|
8
|
+
meaning: "Reads and summarises. Changes nothing."
|
|
9
|
+
},
|
|
10
|
+
1: {
|
|
11
|
+
label: "Propose",
|
|
12
|
+
meaning: "Suggests an action. A human approves before anything happens."
|
|
13
|
+
},
|
|
14
|
+
2: {
|
|
15
|
+
label: "Act with review",
|
|
16
|
+
meaning: "Does the action; a human reviews after, with undo."
|
|
17
|
+
},
|
|
18
|
+
3: {
|
|
19
|
+
label: "Autonomous",
|
|
20
|
+
meaning: "Acts without review. Still logged with undo where possible."
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
/** The AI agent's autonomy level for a capability. Server-component safe. */
|
|
24
|
+
function TrustRungBadge({ rung, showCode = true, className }) {
|
|
25
|
+
const { label, meaning } = TRUST_RUNGS[rung];
|
|
26
|
+
return /* @__PURE__ */ jsx(Badge, {
|
|
27
|
+
tone: rung >= 2 ? "info" : "neutral",
|
|
28
|
+
title: meaning,
|
|
29
|
+
className,
|
|
30
|
+
"data-rung": rung,
|
|
31
|
+
children: showCode ? `R${rung} · ${label}` : label
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { TRUST_RUNGS, TrustRungBadge };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface AlertDialogProps {
|
|
3
|
+
open?: boolean;
|
|
4
|
+
defaultOpen?: boolean;
|
|
5
|
+
onOpenChange?: (open: boolean) => void;
|
|
6
|
+
/** Optional trigger element (e.g. `<Button variant="danger">Delete</Button>`). */
|
|
7
|
+
trigger?: React.ReactElement;
|
|
8
|
+
title: React.ReactNode;
|
|
9
|
+
description: React.ReactNode;
|
|
10
|
+
confirmLabel?: string;
|
|
11
|
+
cancelLabel?: string;
|
|
12
|
+
/** `danger` styles the confirm button as destructive and shows a warning icon. */
|
|
13
|
+
tone?: "default" | "danger";
|
|
14
|
+
/** Called when the user confirms. Return a promise to show a loading state until it settles. */
|
|
15
|
+
onConfirm: () => void | Promise<void>;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Confirmation for consequential actions. Unlike Dialog it does not close on outside click,
|
|
20
|
+
* and initial focus lands on Cancel so Enter never confirms by accident.
|
|
21
|
+
*/
|
|
22
|
+
export declare function AlertDialog({ open, defaultOpen, onOpenChange, trigger, title, description, confirmLabel, cancelLabel, tone, onConfirm, className, }: AlertDialogProps): React.JSX.Element;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
import { Button } from "./button.js";
|
|
5
|
+
import dialog_module_default from "./dialog.module.js";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { TriangleAlert } from "lucide-react";
|
|
9
|
+
import { AlertDialog } from "@base-ui/react/alert-dialog";
|
|
10
|
+
//#region src/components/ui/alert-dialog.tsx
|
|
11
|
+
/**
|
|
12
|
+
* Confirmation for consequential actions. Unlike Dialog it does not close on outside click,
|
|
13
|
+
* and initial focus lands on Cancel so Enter never confirms by accident.
|
|
14
|
+
*/
|
|
15
|
+
function AlertDialog$1({ open, defaultOpen, onOpenChange, trigger, title, description, confirmLabel = "Confirm", cancelLabel = "Cancel", tone = "default", onConfirm, className }) {
|
|
16
|
+
const [internalOpen, setInternalOpen] = React.useState(defaultOpen ?? false);
|
|
17
|
+
const [pending, setPending] = React.useState(false);
|
|
18
|
+
const isOpen = open ?? internalOpen;
|
|
19
|
+
const cancelRef = React.useRef(null);
|
|
20
|
+
const setOpen = (next) => {
|
|
21
|
+
if (pending) return;
|
|
22
|
+
if (open === void 0) setInternalOpen(next);
|
|
23
|
+
onOpenChange?.(next);
|
|
24
|
+
};
|
|
25
|
+
const confirm = async () => {
|
|
26
|
+
try {
|
|
27
|
+
setPending(true);
|
|
28
|
+
await onConfirm();
|
|
29
|
+
setPending(false);
|
|
30
|
+
if (open === void 0) setInternalOpen(false);
|
|
31
|
+
onOpenChange?.(false);
|
|
32
|
+
} catch {
|
|
33
|
+
setPending(false);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return /* @__PURE__ */ jsxs(AlertDialog.Root, {
|
|
37
|
+
open: isOpen,
|
|
38
|
+
onOpenChange: setOpen,
|
|
39
|
+
children: [trigger && /* @__PURE__ */ jsx(AlertDialog.Trigger, { render: trigger }), /* @__PURE__ */ jsxs(AlertDialog.Portal, { children: [/* @__PURE__ */ jsx(AlertDialog.Backdrop, { className: dialog_module_default.backdrop }), /* @__PURE__ */ jsxs(AlertDialog.Popup, {
|
|
40
|
+
className: cn(dialog_module_default.dialog, dialog_module_default.sm, className),
|
|
41
|
+
initialFocus: cancelRef,
|
|
42
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
43
|
+
className: dialog_module_default.header,
|
|
44
|
+
style: {
|
|
45
|
+
borderBottom: 0,
|
|
46
|
+
alignItems: "flex-start",
|
|
47
|
+
paddingTop: "var(--hg-space-5)"
|
|
48
|
+
},
|
|
49
|
+
children: [tone === "danger" && /* @__PURE__ */ jsx("span", {
|
|
50
|
+
className: dialog_module_default.alertIcon,
|
|
51
|
+
"aria-hidden": "true",
|
|
52
|
+
children: /* @__PURE__ */ jsx(TriangleAlert, { strokeWidth: 1.6 })
|
|
53
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
54
|
+
className: dialog_module_default.headings,
|
|
55
|
+
children: [/* @__PURE__ */ jsx(AlertDialog.Title, {
|
|
56
|
+
className: dialog_module_default.title,
|
|
57
|
+
children: title
|
|
58
|
+
}), /* @__PURE__ */ jsx(AlertDialog.Description, {
|
|
59
|
+
className: dialog_module_default.description,
|
|
60
|
+
children: description
|
|
61
|
+
})]
|
|
62
|
+
})]
|
|
63
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
64
|
+
className: dialog_module_default.footer,
|
|
65
|
+
style: {
|
|
66
|
+
paddingTop: "var(--hg-space-5)",
|
|
67
|
+
marginTop: 0
|
|
68
|
+
},
|
|
69
|
+
children: [/* @__PURE__ */ jsx(AlertDialog.Close, {
|
|
70
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
71
|
+
ref: cancelRef,
|
|
72
|
+
variant: "secondary",
|
|
73
|
+
disabled: pending
|
|
74
|
+
}),
|
|
75
|
+
children: cancelLabel
|
|
76
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
77
|
+
variant: tone === "danger" ? "danger" : "primary",
|
|
78
|
+
loading: pending,
|
|
79
|
+
onClick: confirm,
|
|
80
|
+
children: confirmLabel
|
|
81
|
+
})]
|
|
82
|
+
})]
|
|
83
|
+
})] })]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { AlertDialog$1 as AlertDialog };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface AvatarProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "children"> {
|
|
3
|
+
/** Full name; used for initials and as the accessible label. */
|
|
4
|
+
name: string;
|
|
5
|
+
src?: string;
|
|
6
|
+
size?: "xs" | "sm" | "md" | "lg";
|
|
7
|
+
/** Render as decorative (when the name is already shown next to it). */
|
|
8
|
+
decorative?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** Up to two initials from a name: "Asha Rao" -> "AR", "northwind" -> "N". */
|
|
11
|
+
export declare function getInitials(name: string): string;
|
|
12
|
+
/** Circular avatar: image when available, initials otherwise (also the fallback if the image fails). */
|
|
13
|
+
export declare const Avatar: React.ForwardRefExoticComponent<AvatarProps & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
import avatar_module_default from "./avatar.module.js";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/ui/avatar.tsx
|
|
8
|
+
/** Up to two initials from a name: "Asha Rao" -> "AR", "northwind" -> "N". */
|
|
9
|
+
function getInitials(name) {
|
|
10
|
+
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
11
|
+
if (parts.length === 0) return "?";
|
|
12
|
+
return (parts[0].charAt(0) + (parts.length > 1 ? parts[parts.length - 1].charAt(0) : "")).toUpperCase();
|
|
13
|
+
}
|
|
14
|
+
/** Circular avatar: image when available, initials otherwise (also the fallback if the image fails). */
|
|
15
|
+
var Avatar = React.forwardRef(function Avatar({ name, src, size = "md", decorative = false, className, ...props }, ref) {
|
|
16
|
+
const [failed, setFailed] = React.useState(false);
|
|
17
|
+
React.useEffect(() => setFailed(false), [src]);
|
|
18
|
+
const showImage = Boolean(src) && !failed;
|
|
19
|
+
return /* @__PURE__ */ jsx("span", {
|
|
20
|
+
ref,
|
|
21
|
+
role: decorative ? void 0 : "img",
|
|
22
|
+
"aria-label": decorative ? void 0 : name,
|
|
23
|
+
"aria-hidden": decorative || void 0,
|
|
24
|
+
className: cn(avatar_module_default.avatar, avatar_module_default[size], className),
|
|
25
|
+
...props,
|
|
26
|
+
children: showImage ? /* @__PURE__ */ jsx("img", {
|
|
27
|
+
src,
|
|
28
|
+
alt: "",
|
|
29
|
+
className: avatar_module_default.image,
|
|
30
|
+
onError: () => setFailed(true)
|
|
31
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
32
|
+
"aria-hidden": "true",
|
|
33
|
+
children: getInitials(name)
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Avatar, getInitials };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/components/ui/avatar.module.css
|
|
2
|
+
var avatar = "hg-avatar-module_avatar_VXNIM";
|
|
3
|
+
var xs = "hg-avatar-module_xs_ClQiU";
|
|
4
|
+
var sm = "hg-avatar-module_sm_L-cah";
|
|
5
|
+
var md = "hg-avatar-module_md_7WX0P";
|
|
6
|
+
var lg = "hg-avatar-module_lg_WGzan";
|
|
7
|
+
var image = "hg-avatar-module_image_2aRlv";
|
|
8
|
+
var avatar_module_default = {
|
|
9
|
+
avatar,
|
|
10
|
+
xs,
|
|
11
|
+
sm,
|
|
12
|
+
md,
|
|
13
|
+
lg,
|
|
14
|
+
image
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { avatar, avatar_module_default as default, image, lg, md, sm, xs };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type BadgeTone = "neutral" | "info" | "success" | "warning" | "danger" | "outline";
|
|
3
|
+
export interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
4
|
+
tone?: BadgeTone;
|
|
5
|
+
/** Leading status dot. Status must never rely on colour alone, so keep a text label. */
|
|
6
|
+
dot?: boolean;
|
|
7
|
+
/** Leading icon (14px). Decorative; the label carries the meaning. */
|
|
8
|
+
icon?: React.ReactNode;
|
|
9
|
+
size?: "sm" | "md";
|
|
10
|
+
}
|
|
11
|
+
/** Compact label for status, category or count. Server-component safe. */
|
|
12
|
+
export declare const Badge: React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { cn } from "../../lib/cn.js";
|
|
2
|
+
import badge_module_default from "./badge.module.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/ui/badge.tsx
|
|
6
|
+
/** Compact label for status, category or count. Server-component safe. */
|
|
7
|
+
var Badge = React.forwardRef(function Badge({ tone = "neutral", dot = false, icon, size = "md", className, children, ...props }, ref) {
|
|
8
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
9
|
+
ref,
|
|
10
|
+
"data-tone": tone,
|
|
11
|
+
className: cn(badge_module_default.badge, badge_module_default[tone], size === "sm" && badge_module_default.sm, className),
|
|
12
|
+
...props,
|
|
13
|
+
children: [
|
|
14
|
+
dot && /* @__PURE__ */ jsx("span", {
|
|
15
|
+
className: badge_module_default.dot,
|
|
16
|
+
"aria-hidden": "true"
|
|
17
|
+
}),
|
|
18
|
+
icon && /* @__PURE__ */ jsx("span", {
|
|
19
|
+
className: badge_module_default.icon,
|
|
20
|
+
"aria-hidden": "true",
|
|
21
|
+
children: icon
|
|
22
|
+
}),
|
|
23
|
+
children
|
|
24
|
+
]
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
//#endregion
|
|
28
|
+
export { Badge };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/components/ui/badge.module.css
|
|
2
|
+
var badge = "hg-badge-module_badge_hy34V";
|
|
3
|
+
var sm = "hg-badge-module_sm_XswSx";
|
|
4
|
+
var neutral = "hg-badge-module_neutral_5yU4b";
|
|
5
|
+
var info = "hg-badge-module_info_OPMk7";
|
|
6
|
+
var success = "hg-badge-module_success_sEg18";
|
|
7
|
+
var warning = "hg-badge-module_warning_pq0zd";
|
|
8
|
+
var danger = "hg-badge-module_danger_NZ7Bm";
|
|
9
|
+
var outline = "hg-badge-module_outline_PV-w3";
|
|
10
|
+
var dot = "hg-badge-module_dot_AUKJt";
|
|
11
|
+
var icon = "hg-badge-module_icon_MUaiP";
|
|
12
|
+
var badge_module_default = {
|
|
13
|
+
badge,
|
|
14
|
+
sm,
|
|
15
|
+
neutral,
|
|
16
|
+
info,
|
|
17
|
+
success,
|
|
18
|
+
warning,
|
|
19
|
+
danger,
|
|
20
|
+
outline,
|
|
21
|
+
dot,
|
|
22
|
+
icon
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { badge, danger, badge_module_default as default, dot, icon, info, neutral, outline, sm, success, warning };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type ButtonVariant = "primary" | "secondary" | "ghost" | "danger" | "link";
|
|
3
|
+
export type ButtonSize = "sm" | "md" | "lg";
|
|
4
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
5
|
+
/** Visual style. `primary` is the HeiGin near-black accent. */
|
|
6
|
+
variant?: ButtonVariant;
|
|
7
|
+
size?: ButtonSize;
|
|
8
|
+
/** Shows a spinner, sets `aria-busy` and ignores clicks. Focus is kept so screen readers announce the change. */
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
/** Icon rendered before the label. */
|
|
11
|
+
leadingIcon?: React.ReactNode;
|
|
12
|
+
/** Icon rendered after the label. */
|
|
13
|
+
trailingIcon?: React.ReactNode;
|
|
14
|
+
fullWidth?: boolean;
|
|
15
|
+
/** Grow to the 44px touch height below 768px, matching production. Default `true`. */
|
|
16
|
+
touch?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** The primary action control. Renders a native `<button type="button">` by default. */
|
|
19
|
+
export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
import { Spinner } from "./spinner.js";
|
|
5
|
+
import button_module_default from "./button.module.js";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/ui/button.tsx
|
|
9
|
+
/** The primary action control. Renders a native `<button type="button">` by default. */
|
|
10
|
+
var Button = React.forwardRef(function Button({ variant = "primary", size = "md", loading = false, leadingIcon, trailingIcon, fullWidth = false, touch = true, disabled, type = "button", className, children, onClick, ...props }, ref) {
|
|
11
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
12
|
+
ref,
|
|
13
|
+
type,
|
|
14
|
+
disabled,
|
|
15
|
+
"aria-busy": loading || void 0,
|
|
16
|
+
"aria-disabled": loading || void 0,
|
|
17
|
+
"data-variant": variant,
|
|
18
|
+
"data-size": size,
|
|
19
|
+
className: cn(button_module_default.button, button_module_default[variant], size !== "md" && button_module_default[size], touch && variant !== "link" && button_module_default.touch, fullWidth && button_module_default.fullWidth, loading && button_module_default.loading, className),
|
|
20
|
+
onClick: (event) => {
|
|
21
|
+
if (loading) {
|
|
22
|
+
event.preventDefault();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
onClick?.(event);
|
|
26
|
+
},
|
|
27
|
+
...props,
|
|
28
|
+
children: [
|
|
29
|
+
loading ? /* @__PURE__ */ jsx(Spinner, {
|
|
30
|
+
size: "sm",
|
|
31
|
+
label: null
|
|
32
|
+
}) : leadingIcon,
|
|
33
|
+
children,
|
|
34
|
+
!loading && trailingIcon
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
//#endregion
|
|
39
|
+
export { Button };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/components/ui/button.module.css
|
|
2
|
+
var button = "hg-button-module_button_oZUwn";
|
|
3
|
+
var sm = "hg-button-module_sm_PNct0";
|
|
4
|
+
var lg = "hg-button-module_lg_ESWsb";
|
|
5
|
+
var touch = "hg-button-module_touch_sPIXS";
|
|
6
|
+
var fullWidth = "hg-button-module_fullWidth_qIRv5";
|
|
7
|
+
var primary = "hg-button-module_primary_qsCRq";
|
|
8
|
+
var secondary = "hg-button-module_secondary_b9hPX";
|
|
9
|
+
var ghost = "hg-button-module_ghost_d3Zpx";
|
|
10
|
+
var danger = "hg-button-module_danger_wgmQN";
|
|
11
|
+
var link = "hg-button-module_link_Y0HuD";
|
|
12
|
+
var loading = "hg-button-module_loading_-x8oX";
|
|
13
|
+
var button_module_default = {
|
|
14
|
+
button,
|
|
15
|
+
sm,
|
|
16
|
+
lg,
|
|
17
|
+
touch,
|
|
18
|
+
fullWidth,
|
|
19
|
+
primary,
|
|
20
|
+
secondary,
|
|
21
|
+
ghost,
|
|
22
|
+
danger,
|
|
23
|
+
link,
|
|
24
|
+
loading
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { button, danger, button_module_default as default, fullWidth, ghost, lg, link, loading, primary, secondary, sm, touch };
|