@open-lakehouse/ui-kit 0.0.1 → 0.0.2
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 +14 -0
- package/README.md +5 -1
- package/dist/commit-history.d.ts +76 -0
- package/dist/commit-history.d.ts.map +1 -0
- package/dist/commit-history.js +121 -0
- package/dist/commit-history.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/commit-history.tsx +339 -0
- package/src/index.ts +9 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.0.2](https://github.com/open-lakehouse/trestle/compare/ui-kit-v0.0.1...ui-kit-v0.0.2) - 2026-11-21
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- add a GitHub-style commit history component (#425)
|
package/README.md
CHANGED
|
@@ -24,7 +24,11 @@ Import from the barrel, `@open-lakehouse/ui-kit`:
|
|
|
24
24
|
`Label`, `ResizeHandle` / `usePaneSize`, `Select*`, `Separator`, `Sheet*`,
|
|
25
25
|
`Switch`, `Tabs*`, `Textarea`, `Toaster`, `Tooltip*` (plus the `*Variants` and
|
|
26
26
|
`*Props` for `Badge` / `Button`).
|
|
27
|
-
-
|
|
27
|
+
- Composites: `CommitHistory`, a GitHub-style history (entries grouped by day
|
|
28
|
+
along a timeline, with author, relative time, badges and a copyable ref).
|
|
29
|
+
Hosts map their own records (revisions, commits, table versions) to
|
|
30
|
+
`CommitHistoryEntry`.
|
|
31
|
+
- Helpers: `cn`, `groupByDay`, `formatRelativeTime`.
|
|
28
32
|
- Theme: `ThemeProvider`, `useTheme`.
|
|
29
33
|
|
|
30
34
|
## Tailwind
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
/** Who made a commit. */
|
|
3
|
+
export interface CommitAuthor {
|
|
4
|
+
name: string;
|
|
5
|
+
/** Drawn in place of the initials, where the host has one. */
|
|
6
|
+
avatarUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
/** One commit (or revision, version…) in a `CommitHistory`. */
|
|
9
|
+
export interface CommitHistoryEntry {
|
|
10
|
+
/** Stable identity: the React key and what `selectedId` matches. */
|
|
11
|
+
id: string;
|
|
12
|
+
/** The first line of the message, or a fallback such as "Revision #3". */
|
|
13
|
+
title: ReactNode;
|
|
14
|
+
/** The rest of the message, clamped to two lines. */
|
|
15
|
+
description?: ReactNode;
|
|
16
|
+
/** A short hash or digest, drawn in mono with a copy button. */
|
|
17
|
+
ref?: string;
|
|
18
|
+
/** The full hash, for the ref's tooltip and what the copy button copies. */
|
|
19
|
+
refTitle?: string;
|
|
20
|
+
author?: CommitAuthor;
|
|
21
|
+
/** When it was made (a `Date` or an ISO 8601 string). Entries without one
|
|
22
|
+
* are grouped under "Undated". */
|
|
23
|
+
timestamp?: string | Date;
|
|
24
|
+
/** Small tags next to the ref, e.g. a number or "HEAD". */
|
|
25
|
+
badges?: ReactNode;
|
|
26
|
+
}
|
|
27
|
+
/** The entries made on one calendar day, or the undated ones. */
|
|
28
|
+
export interface CommitDayGroup {
|
|
29
|
+
/** `YYYY-MM-DD` in local time, or `"undated"`. */
|
|
30
|
+
key: string;
|
|
31
|
+
/** Midnight of that day; absent for the undated group. */
|
|
32
|
+
day?: Date;
|
|
33
|
+
entries: CommitHistoryEntry[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Group `entries` by local calendar day, keeping their order: groups appear in
|
|
37
|
+
* the order of their first entry (newest first when the entries are), and
|
|
38
|
+
* entries without a (valid) timestamp come last, under `"undated"`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function groupByDay(entries: readonly CommitHistoryEntry[]): CommitDayGroup[];
|
|
41
|
+
/**
|
|
42
|
+
* How long ago `date` was, relative to `now`: "just now" under a minute, then
|
|
43
|
+
* the largest whole unit ("5 minutes ago", "yesterday", "3 weeks ago").
|
|
44
|
+
* A `date` after `now` reads "just now" too (clock skew between hosts).
|
|
45
|
+
*/
|
|
46
|
+
export declare function formatRelativeTime(date: Date, now?: Date, locale?: string): string;
|
|
47
|
+
export interface CommitHistoryProps {
|
|
48
|
+
/** Newest first. */
|
|
49
|
+
entries: readonly CommitHistoryEntry[];
|
|
50
|
+
/** Makes each entry's title a button. */
|
|
51
|
+
onSelect?: (entry: CommitHistoryEntry) => void;
|
|
52
|
+
/** The highlighted entry. */
|
|
53
|
+
selectedId?: string;
|
|
54
|
+
/** Per-entry actions (e.g. compare), shown on hover and focus. */
|
|
55
|
+
renderActions?: (entry: CommitHistoryEntry) => ReactNode;
|
|
56
|
+
/** Group the entries under a heading per day. Defaults to true. */
|
|
57
|
+
groupByDay?: boolean;
|
|
58
|
+
/** Narrow layout for sidebars: the ref and badges move under the title. */
|
|
59
|
+
compact?: boolean;
|
|
60
|
+
/** A day's heading. Defaults to the date, e.g. "Nov 21, 2026". */
|
|
61
|
+
dayLabel?: (day: Date) => ReactNode;
|
|
62
|
+
/** Drawn when there are no entries. */
|
|
63
|
+
emptyState?: ReactNode;
|
|
64
|
+
/** The reference time for relative timestamps. Defaults to now. */
|
|
65
|
+
now?: Date;
|
|
66
|
+
"aria-label"?: string;
|
|
67
|
+
className?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A commit history in the style of GitHub's commits page: the entries grouped
|
|
71
|
+
* by day along a timeline, each with its title, author, relative time, badges
|
|
72
|
+
* and a copyable ref. Generic over what is being versioned: the host maps its
|
|
73
|
+
* own records (revisions, commits, table versions) to `CommitHistoryEntry`.
|
|
74
|
+
*/
|
|
75
|
+
export declare function CommitHistory({ entries, onSelect, selectedId, renderActions, groupByDay: grouped, compact, dayLabel, emptyState, now, "aria-label": ariaLabel, className, }: CommitHistoryProps): import("react").JSX.Element;
|
|
76
|
+
//# sourceMappingURL=commit-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-history.d.ts","sourceRoot":"","sources":["../src/commit-history.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AAIjD,yBAAyB;AACzB,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,+DAA+D;AAC/D,MAAM,WAAW,kBAAkB;IACjC,oEAAoE;IACpE,EAAE,EAAE,MAAM,CAAC;IACX,0EAA0E;IAC1E,KAAK,EAAE,SAAS,CAAC;IACjB,qDAAqD;IACrD,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,gEAAgE;IAChE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;uCACmC;IACnC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,2DAA2D;IAC3D,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB;AAED,iEAAiE;AACjE,MAAM,WAAW,cAAc;IAC7B,kDAAkD;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,0DAA0D;IAC1D,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,kBAAkB,EAAE,CAAC;CAC/B;AAUD;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,SAAS,kBAAkB,EAAE,GACrC,cAAc,EAAE,CAwBlB;AAWD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,GAAG,GAAE,IAAiB,EACtB,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CASR;AAUD,MAAM,WAAW,kBAAkB;IACjC,oBAAoB;IACpB,OAAO,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACvC,yCAAyC;IACzC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC/C,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,SAAS,CAAC;IACzD,mEAAmE;IACnE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,SAAS,CAAC;IACpC,uCAAuC;IACvC,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,mEAAmE;IACnE,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,QAAQ,EACR,UAAU,EACV,aAAa,EACb,UAAU,EAAE,OAAc,EAC1B,OAAe,EACf,QAA0B,EAC1B,UAAU,EACV,GAAG,EACH,YAAY,EAAE,SAAS,EACvB,SAAS,GACV,EAAE,kBAAkB,+BA4CpB"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Check, Copy, GitCommitHorizontal } from "lucide-react";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { cn } from "./utils.js";
|
|
5
|
+
function toDate(value) {
|
|
6
|
+
if (value === undefined)
|
|
7
|
+
return undefined;
|
|
8
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
9
|
+
return Number.isNaN(date.getTime()) ? undefined : date;
|
|
10
|
+
}
|
|
11
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
12
|
+
/**
|
|
13
|
+
* Group `entries` by local calendar day, keeping their order: groups appear in
|
|
14
|
+
* the order of their first entry (newest first when the entries are), and
|
|
15
|
+
* entries without a (valid) timestamp come last, under `"undated"`.
|
|
16
|
+
*/
|
|
17
|
+
export function groupByDay(entries) {
|
|
18
|
+
const groups = new Map();
|
|
19
|
+
const undated = [];
|
|
20
|
+
for (const entry of entries) {
|
|
21
|
+
const date = toDate(entry.timestamp);
|
|
22
|
+
if (!date) {
|
|
23
|
+
undated.push(entry);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const key = `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
27
|
+
let group = groups.get(key);
|
|
28
|
+
if (!group) {
|
|
29
|
+
group = {
|
|
30
|
+
key,
|
|
31
|
+
day: new Date(date.getFullYear(), date.getMonth(), date.getDate()),
|
|
32
|
+
entries: [],
|
|
33
|
+
};
|
|
34
|
+
groups.set(key, group);
|
|
35
|
+
}
|
|
36
|
+
group.entries.push(entry);
|
|
37
|
+
}
|
|
38
|
+
const out = [...groups.values()];
|
|
39
|
+
if (undated.length > 0)
|
|
40
|
+
out.push({ key: "undated", entries: undated });
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
const UNITS = [
|
|
44
|
+
["minute", 60],
|
|
45
|
+
["hour", 60 * 60],
|
|
46
|
+
["day", 24 * 60 * 60],
|
|
47
|
+
["week", 7 * 24 * 60 * 60],
|
|
48
|
+
["month", 30 * 24 * 60 * 60],
|
|
49
|
+
["year", 365 * 24 * 60 * 60],
|
|
50
|
+
];
|
|
51
|
+
/**
|
|
52
|
+
* How long ago `date` was, relative to `now`: "just now" under a minute, then
|
|
53
|
+
* the largest whole unit ("5 minutes ago", "yesterday", "3 weeks ago").
|
|
54
|
+
* A `date` after `now` reads "just now" too (clock skew between hosts).
|
|
55
|
+
*/
|
|
56
|
+
export function formatRelativeTime(date, now = new Date(), locale) {
|
|
57
|
+
const seconds = Math.round((now.getTime() - date.getTime()) / 1000);
|
|
58
|
+
if (seconds < 60)
|
|
59
|
+
return "just now";
|
|
60
|
+
const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
|
|
61
|
+
let unit = UNITS[0];
|
|
62
|
+
for (const candidate of UNITS) {
|
|
63
|
+
if (seconds >= candidate[1])
|
|
64
|
+
unit = candidate;
|
|
65
|
+
}
|
|
66
|
+
return rtf.format(-Math.floor(seconds / unit[1]), unit[0]);
|
|
67
|
+
}
|
|
68
|
+
function defaultDayLabel(day) {
|
|
69
|
+
return day.toLocaleDateString(undefined, {
|
|
70
|
+
month: "short",
|
|
71
|
+
day: "numeric",
|
|
72
|
+
year: "numeric",
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A commit history in the style of GitHub's commits page: the entries grouped
|
|
77
|
+
* by day along a timeline, each with its title, author, relative time, badges
|
|
78
|
+
* and a copyable ref. Generic over what is being versioned: the host maps its
|
|
79
|
+
* own records (revisions, commits, table versions) to `CommitHistoryEntry`.
|
|
80
|
+
*/
|
|
81
|
+
export function CommitHistory({ entries, onSelect, selectedId, renderActions, groupByDay: grouped = true, compact = false, dayLabel = defaultDayLabel, emptyState, now, "aria-label": ariaLabel, className, }) {
|
|
82
|
+
if (entries.length === 0) {
|
|
83
|
+
return (_jsx("div", { className: cn("text-xs text-muted-foreground", className), children: emptyState ?? "No commits yet." }));
|
|
84
|
+
}
|
|
85
|
+
const groups = grouped
|
|
86
|
+
? groupByDay(entries)
|
|
87
|
+
: [{ key: "all", entries: [...entries] }];
|
|
88
|
+
const row = (entry) => (_jsx(CommitRow, { entry: entry, selected: entry.id === selectedId, onSelect: onSelect, actions: renderActions?.(entry), compact: compact, now: now }, entry.id));
|
|
89
|
+
return (_jsx("section", { "aria-label": ariaLabel, className: cn("text-sm", className), children: groups.map((group) => (_jsxs("div", { children: [grouped && (_jsxs("h3", { className: "flex items-center gap-1.5 py-1 text-xs text-muted-foreground", children: [_jsx(GitCommitHorizontal, { "aria-hidden": true, className: "h-3.5 w-3.5 shrink-0" }), group.day ? dayLabel(group.day) : "Undated"] })), _jsx("div", { className: cn(grouped && "ml-[7px] border-l pb-3 pl-3"), children: _jsx("ol", { className: "divide-y overflow-hidden rounded-md border bg-card text-card-foreground", children: group.entries.map(row) }) })] }, group.key))) }));
|
|
90
|
+
}
|
|
91
|
+
function CommitRow({ entry, selected, onSelect, actions, compact, now, }) {
|
|
92
|
+
const date = toDate(entry.timestamp);
|
|
93
|
+
const titleClass = "block w-full truncate text-left font-medium";
|
|
94
|
+
const tags = (entry.badges || entry.ref) && (_jsxs("span", { className: "flex shrink-0 items-center gap-1", children: [entry.badges, entry.ref && _jsx(RefChip, { value: entry.ref, full: entry.refTitle })] }));
|
|
95
|
+
return (_jsxs("li", { className: cn("group flex items-start gap-2", compact ? "px-2 py-1.5" : "px-3 py-2", selected && "bg-accent text-accent-foreground"), children: [_jsxs("div", { className: "min-w-0 flex-1", children: [onSelect ? (_jsx("button", { type: "button", className: cn(titleClass, "rounded-sm hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"), "aria-current": selected || undefined, onClick: () => onSelect(entry), children: entry.title })) : (_jsx("span", { className: titleClass, children: entry.title })), entry.description && (_jsx("p", { className: "mt-0.5 line-clamp-2 text-xs text-muted-foreground", children: entry.description })), _jsxs("div", { className: "mt-0.5 flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 text-xs text-muted-foreground", children: [entry.author && (_jsxs(_Fragment, { children: [_jsx(Avatar, { author: entry.author }), _jsx("span", { className: "truncate font-medium text-foreground", children: entry.author.name })] })), date && (_jsxs("time", { dateTime: date.toISOString(), title: date.toLocaleString(), children: [entry.author && !compact ? "committed " : "", formatRelativeTime(date, now)] })), compact && tags] })] }), !compact && tags, actions && (_jsx("span", { className: "flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100", children: actions }))] }));
|
|
96
|
+
}
|
|
97
|
+
function Avatar({ author }) {
|
|
98
|
+
if (author.avatarUrl) {
|
|
99
|
+
return (_jsx("img", { src: author.avatarUrl, alt: "", className: "h-4 w-4 shrink-0 rounded-full" }));
|
|
100
|
+
}
|
|
101
|
+
const initials = author.name
|
|
102
|
+
.split(/\s+/)
|
|
103
|
+
.filter(Boolean)
|
|
104
|
+
.slice(0, 2)
|
|
105
|
+
.map((part) => part[0]?.toUpperCase())
|
|
106
|
+
.join("");
|
|
107
|
+
return (_jsx("span", { "aria-hidden": true, className: "inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-muted text-[8px] font-semibold text-muted-foreground", children: initials }));
|
|
108
|
+
}
|
|
109
|
+
/** A short ref in mono, copying the full one on a click. */
|
|
110
|
+
function RefChip({ value, full }) {
|
|
111
|
+
const [copied, setCopied] = useState(false);
|
|
112
|
+
const text = full ?? value;
|
|
113
|
+
const copy = () => {
|
|
114
|
+
void navigator.clipboard?.writeText(text).then(() => {
|
|
115
|
+
setCopied(true);
|
|
116
|
+
setTimeout(() => setCopied(false), 1500);
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
return (_jsxs("span", { className: "inline-flex items-center rounded border bg-background font-mono text-[11px] text-muted-foreground", title: text, children: [_jsx("span", { className: "px-1", children: value }), _jsx("button", { type: "button", "aria-label": `Copy ${text}`, onClick: copy, className: "border-l px-0.5 py-0.5 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&_svg]:h-3 [&_svg]:w-3", children: copied ? _jsx(Check, {}) : _jsx(Copy, {}) })] }));
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=commit-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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D,SAAS,CAAC,IAAI,CAAC,CAAC;YAChB,UAAU,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IACF,OAAO,CACL,gBACE,SAAS,EAAC,mGAAmG,EAC7G,KAAK,EAAE,IAAI,aAEX,eAAM,SAAS,EAAC,MAAM,YAAE,KAAK,GAAQ,EACrC,iBACE,IAAI,EAAC,QAAQ,gBACD,QAAQ,IAAI,EAAE,EAC1B,OAAO,EAAE,IAAI,EACb,SAAS,EAAC,8IAA8I,YAEvJ,MAAM,CAAC,CAAC,CAAC,KAAC,KAAK,KAAG,CAAC,CAAC,CAAC,KAAC,IAAI,KAAG,GACvB,IACJ,CACR,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { Badge, type BadgeProps, badgeVariants } from "./badge.js";
|
|
2
2
|
export { Button, type ButtonProps, buttonVariants } from "./button.js";
|
|
3
3
|
export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "./card.js";
|
|
4
|
+
export { type CommitAuthor, type CommitDayGroup, CommitHistory, type CommitHistoryEntry, type CommitHistoryProps, formatRelativeTime, groupByDay, } from "./commit-history.js";
|
|
4
5
|
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, } from "./dialog.js";
|
|
5
6
|
export { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger, } from "./dropdown-menu.js";
|
|
6
7
|
export { Input } from "./input.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAA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EACL,MAAM,EACN,aAAa,EACb,WAAW,EACX,UAAU,EACV,aAAa,EACb,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,KAAK,EACL,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,UAAU,EACV,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,OAAO,EACP,cAAc,EACd,eAAe,EACf,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
export { Badge, badgeVariants } from "./badge.js";
|
|
7
7
|
export { Button, buttonVariants } from "./button.js";
|
|
8
8
|
export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "./card.js";
|
|
9
|
+
export { CommitHistory, formatRelativeTime, groupByDay, } from "./commit-history.js";
|
|
9
10
|
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, } from "./dialog.js";
|
|
10
11
|
export { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger, } from "./dropdown-menu.js";
|
|
11
12
|
export { Input } from "./input.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,yEAAyE;AACzE,8EAA8E;AAC9E,+EAA+E;AAC/E,2CAA2C;AAE3C,OAAO,EAAE,KAAK,EAAmB,aAAa,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,MAAM,EAAoB,cAAc,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EACL,IAAI,EACJ,WAAW,EACX,eAAe,EACf,UAAU,EACV,UAAU,EACV,SAAS,GACV,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,MAAM,EACN,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,WAAW,EACX,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,YAAY,EAEZ,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,MAAM,EACN,aAAa,EACb,WAAW,EACX,UAAU,EACV,aAAa,EACb,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,KAAK,EACL,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,UAAU,EACV,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,aAA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,YAAY,CAAC;AACnC,OAAO,EACL,YAAY,EAEZ,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,MAAM,EACN,aAAa,EACb,WAAW,EACX,UAAU,EACV,aAAa,EACb,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,KAAK,EACL,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,UAAU,EACV,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,OAAO,EACP,cAAc,EACd,eAAe,EACf,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { Check, Copy, GitCommitHorizontal } from "lucide-react";
|
|
2
|
+
import { type ReactNode, useState } from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "./utils.js";
|
|
5
|
+
|
|
6
|
+
/** Who made a commit. */
|
|
7
|
+
export interface CommitAuthor {
|
|
8
|
+
name: string;
|
|
9
|
+
/** Drawn in place of the initials, where the host has one. */
|
|
10
|
+
avatarUrl?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** One commit (or revision, version…) in a `CommitHistory`. */
|
|
14
|
+
export interface CommitHistoryEntry {
|
|
15
|
+
/** Stable identity: the React key and what `selectedId` matches. */
|
|
16
|
+
id: string;
|
|
17
|
+
/** The first line of the message, or a fallback such as "Revision #3". */
|
|
18
|
+
title: ReactNode;
|
|
19
|
+
/** The rest of the message, clamped to two lines. */
|
|
20
|
+
description?: ReactNode;
|
|
21
|
+
/** A short hash or digest, drawn in mono with a copy button. */
|
|
22
|
+
ref?: string;
|
|
23
|
+
/** The full hash, for the ref's tooltip and what the copy button copies. */
|
|
24
|
+
refTitle?: string;
|
|
25
|
+
author?: CommitAuthor;
|
|
26
|
+
/** When it was made (a `Date` or an ISO 8601 string). Entries without one
|
|
27
|
+
* are grouped under "Undated". */
|
|
28
|
+
timestamp?: string | Date;
|
|
29
|
+
/** Small tags next to the ref, e.g. a number or "HEAD". */
|
|
30
|
+
badges?: ReactNode;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The entries made on one calendar day, or the undated ones. */
|
|
34
|
+
export interface CommitDayGroup {
|
|
35
|
+
/** `YYYY-MM-DD` in local time, or `"undated"`. */
|
|
36
|
+
key: string;
|
|
37
|
+
/** Midnight of that day; absent for the undated group. */
|
|
38
|
+
day?: Date;
|
|
39
|
+
entries: CommitHistoryEntry[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function toDate(value: string | Date | undefined): Date | undefined {
|
|
43
|
+
if (value === undefined) return undefined;
|
|
44
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
45
|
+
return Number.isNaN(date.getTime()) ? undefined : date;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const pad = (n: number) => String(n).padStart(2, "0");
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Group `entries` by local calendar day, keeping their order: groups appear in
|
|
52
|
+
* the order of their first entry (newest first when the entries are), and
|
|
53
|
+
* entries without a (valid) timestamp come last, under `"undated"`.
|
|
54
|
+
*/
|
|
55
|
+
export function groupByDay(
|
|
56
|
+
entries: readonly CommitHistoryEntry[],
|
|
57
|
+
): CommitDayGroup[] {
|
|
58
|
+
const groups = new Map<string, CommitDayGroup>();
|
|
59
|
+
const undated: CommitHistoryEntry[] = [];
|
|
60
|
+
for (const entry of entries) {
|
|
61
|
+
const date = toDate(entry.timestamp);
|
|
62
|
+
if (!date) {
|
|
63
|
+
undated.push(entry);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const key = `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
67
|
+
let group = groups.get(key);
|
|
68
|
+
if (!group) {
|
|
69
|
+
group = {
|
|
70
|
+
key,
|
|
71
|
+
day: new Date(date.getFullYear(), date.getMonth(), date.getDate()),
|
|
72
|
+
entries: [],
|
|
73
|
+
};
|
|
74
|
+
groups.set(key, group);
|
|
75
|
+
}
|
|
76
|
+
group.entries.push(entry);
|
|
77
|
+
}
|
|
78
|
+
const out = [...groups.values()];
|
|
79
|
+
if (undated.length > 0) out.push({ key: "undated", entries: undated });
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const UNITS: [Intl.RelativeTimeFormatUnit, number][] = [
|
|
84
|
+
["minute", 60],
|
|
85
|
+
["hour", 60 * 60],
|
|
86
|
+
["day", 24 * 60 * 60],
|
|
87
|
+
["week", 7 * 24 * 60 * 60],
|
|
88
|
+
["month", 30 * 24 * 60 * 60],
|
|
89
|
+
["year", 365 * 24 * 60 * 60],
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* How long ago `date` was, relative to `now`: "just now" under a minute, then
|
|
94
|
+
* the largest whole unit ("5 minutes ago", "yesterday", "3 weeks ago").
|
|
95
|
+
* A `date` after `now` reads "just now" too (clock skew between hosts).
|
|
96
|
+
*/
|
|
97
|
+
export function formatRelativeTime(
|
|
98
|
+
date: Date,
|
|
99
|
+
now: Date = new Date(),
|
|
100
|
+
locale?: string,
|
|
101
|
+
): string {
|
|
102
|
+
const seconds = Math.round((now.getTime() - date.getTime()) / 1000);
|
|
103
|
+
if (seconds < 60) return "just now";
|
|
104
|
+
const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
|
|
105
|
+
let unit = UNITS[0];
|
|
106
|
+
for (const candidate of UNITS) {
|
|
107
|
+
if (seconds >= candidate[1]) unit = candidate;
|
|
108
|
+
}
|
|
109
|
+
return rtf.format(-Math.floor(seconds / unit[1]), unit[0]);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function defaultDayLabel(day: Date): string {
|
|
113
|
+
return day.toLocaleDateString(undefined, {
|
|
114
|
+
month: "short",
|
|
115
|
+
day: "numeric",
|
|
116
|
+
year: "numeric",
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface CommitHistoryProps {
|
|
121
|
+
/** Newest first. */
|
|
122
|
+
entries: readonly CommitHistoryEntry[];
|
|
123
|
+
/** Makes each entry's title a button. */
|
|
124
|
+
onSelect?: (entry: CommitHistoryEntry) => void;
|
|
125
|
+
/** The highlighted entry. */
|
|
126
|
+
selectedId?: string;
|
|
127
|
+
/** Per-entry actions (e.g. compare), shown on hover and focus. */
|
|
128
|
+
renderActions?: (entry: CommitHistoryEntry) => ReactNode;
|
|
129
|
+
/** Group the entries under a heading per day. Defaults to true. */
|
|
130
|
+
groupByDay?: boolean;
|
|
131
|
+
/** Narrow layout for sidebars: the ref and badges move under the title. */
|
|
132
|
+
compact?: boolean;
|
|
133
|
+
/** A day's heading. Defaults to the date, e.g. "Nov 21, 2026". */
|
|
134
|
+
dayLabel?: (day: Date) => ReactNode;
|
|
135
|
+
/** Drawn when there are no entries. */
|
|
136
|
+
emptyState?: ReactNode;
|
|
137
|
+
/** The reference time for relative timestamps. Defaults to now. */
|
|
138
|
+
now?: Date;
|
|
139
|
+
"aria-label"?: string;
|
|
140
|
+
className?: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* A commit history in the style of GitHub's commits page: the entries grouped
|
|
145
|
+
* by day along a timeline, each with its title, author, relative time, badges
|
|
146
|
+
* and a copyable ref. Generic over what is being versioned: the host maps its
|
|
147
|
+
* own records (revisions, commits, table versions) to `CommitHistoryEntry`.
|
|
148
|
+
*/
|
|
149
|
+
export function CommitHistory({
|
|
150
|
+
entries,
|
|
151
|
+
onSelect,
|
|
152
|
+
selectedId,
|
|
153
|
+
renderActions,
|
|
154
|
+
groupByDay: grouped = true,
|
|
155
|
+
compact = false,
|
|
156
|
+
dayLabel = defaultDayLabel,
|
|
157
|
+
emptyState,
|
|
158
|
+
now,
|
|
159
|
+
"aria-label": ariaLabel,
|
|
160
|
+
className,
|
|
161
|
+
}: CommitHistoryProps) {
|
|
162
|
+
if (entries.length === 0) {
|
|
163
|
+
return (
|
|
164
|
+
<div className={cn("text-xs text-muted-foreground", className)}>
|
|
165
|
+
{emptyState ?? "No commits yet."}
|
|
166
|
+
</div>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
const groups = grouped
|
|
170
|
+
? groupByDay(entries)
|
|
171
|
+
: [{ key: "all", entries: [...entries] } as CommitDayGroup];
|
|
172
|
+
const row = (entry: CommitHistoryEntry) => (
|
|
173
|
+
<CommitRow
|
|
174
|
+
key={entry.id}
|
|
175
|
+
entry={entry}
|
|
176
|
+
selected={entry.id === selectedId}
|
|
177
|
+
onSelect={onSelect}
|
|
178
|
+
actions={renderActions?.(entry)}
|
|
179
|
+
compact={compact}
|
|
180
|
+
now={now}
|
|
181
|
+
/>
|
|
182
|
+
);
|
|
183
|
+
return (
|
|
184
|
+
<section aria-label={ariaLabel} className={cn("text-sm", className)}>
|
|
185
|
+
{groups.map((group) => (
|
|
186
|
+
<div key={group.key}>
|
|
187
|
+
{grouped && (
|
|
188
|
+
<h3 className="flex items-center gap-1.5 py-1 text-xs text-muted-foreground">
|
|
189
|
+
<GitCommitHorizontal
|
|
190
|
+
aria-hidden
|
|
191
|
+
className="h-3.5 w-3.5 shrink-0"
|
|
192
|
+
/>
|
|
193
|
+
{group.day ? dayLabel(group.day) : "Undated"}
|
|
194
|
+
</h3>
|
|
195
|
+
)}
|
|
196
|
+
<div className={cn(grouped && "ml-[7px] border-l pb-3 pl-3")}>
|
|
197
|
+
<ol className="divide-y overflow-hidden rounded-md border bg-card text-card-foreground">
|
|
198
|
+
{group.entries.map(row)}
|
|
199
|
+
</ol>
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
))}
|
|
203
|
+
</section>
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function CommitRow({
|
|
208
|
+
entry,
|
|
209
|
+
selected,
|
|
210
|
+
onSelect,
|
|
211
|
+
actions,
|
|
212
|
+
compact,
|
|
213
|
+
now,
|
|
214
|
+
}: {
|
|
215
|
+
entry: CommitHistoryEntry;
|
|
216
|
+
selected: boolean;
|
|
217
|
+
onSelect?: (entry: CommitHistoryEntry) => void;
|
|
218
|
+
actions: ReactNode;
|
|
219
|
+
compact: boolean;
|
|
220
|
+
now?: Date;
|
|
221
|
+
}) {
|
|
222
|
+
const date = toDate(entry.timestamp);
|
|
223
|
+
const titleClass = "block w-full truncate text-left font-medium";
|
|
224
|
+
const tags = (entry.badges || entry.ref) && (
|
|
225
|
+
<span className="flex shrink-0 items-center gap-1">
|
|
226
|
+
{entry.badges}
|
|
227
|
+
{entry.ref && <RefChip value={entry.ref} full={entry.refTitle} />}
|
|
228
|
+
</span>
|
|
229
|
+
);
|
|
230
|
+
return (
|
|
231
|
+
<li
|
|
232
|
+
className={cn(
|
|
233
|
+
"group flex items-start gap-2",
|
|
234
|
+
compact ? "px-2 py-1.5" : "px-3 py-2",
|
|
235
|
+
selected && "bg-accent text-accent-foreground",
|
|
236
|
+
)}
|
|
237
|
+
>
|
|
238
|
+
<div className="min-w-0 flex-1">
|
|
239
|
+
{onSelect ? (
|
|
240
|
+
<button
|
|
241
|
+
type="button"
|
|
242
|
+
className={cn(
|
|
243
|
+
titleClass,
|
|
244
|
+
"rounded-sm hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
245
|
+
)}
|
|
246
|
+
aria-current={selected || undefined}
|
|
247
|
+
onClick={() => onSelect(entry)}
|
|
248
|
+
>
|
|
249
|
+
{entry.title}
|
|
250
|
+
</button>
|
|
251
|
+
) : (
|
|
252
|
+
<span className={titleClass}>{entry.title}</span>
|
|
253
|
+
)}
|
|
254
|
+
{entry.description && (
|
|
255
|
+
<p className="mt-0.5 line-clamp-2 text-xs text-muted-foreground">
|
|
256
|
+
{entry.description}
|
|
257
|
+
</p>
|
|
258
|
+
)}
|
|
259
|
+
<div className="mt-0.5 flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 text-xs text-muted-foreground">
|
|
260
|
+
{entry.author && (
|
|
261
|
+
<>
|
|
262
|
+
<Avatar author={entry.author} />
|
|
263
|
+
<span className="truncate font-medium text-foreground">
|
|
264
|
+
{entry.author.name}
|
|
265
|
+
</span>
|
|
266
|
+
</>
|
|
267
|
+
)}
|
|
268
|
+
{date && (
|
|
269
|
+
<time dateTime={date.toISOString()} title={date.toLocaleString()}>
|
|
270
|
+
{entry.author && !compact ? "committed " : ""}
|
|
271
|
+
{formatRelativeTime(date, now)}
|
|
272
|
+
</time>
|
|
273
|
+
)}
|
|
274
|
+
{compact && tags}
|
|
275
|
+
</div>
|
|
276
|
+
</div>
|
|
277
|
+
{!compact && tags}
|
|
278
|
+
{actions && (
|
|
279
|
+
<span className="flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100">
|
|
280
|
+
{actions}
|
|
281
|
+
</span>
|
|
282
|
+
)}
|
|
283
|
+
</li>
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function Avatar({ author }: { author: CommitAuthor }) {
|
|
288
|
+
if (author.avatarUrl) {
|
|
289
|
+
return (
|
|
290
|
+
<img
|
|
291
|
+
src={author.avatarUrl}
|
|
292
|
+
alt=""
|
|
293
|
+
className="h-4 w-4 shrink-0 rounded-full"
|
|
294
|
+
/>
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
const initials = author.name
|
|
298
|
+
.split(/\s+/)
|
|
299
|
+
.filter(Boolean)
|
|
300
|
+
.slice(0, 2)
|
|
301
|
+
.map((part) => part[0]?.toUpperCase())
|
|
302
|
+
.join("");
|
|
303
|
+
return (
|
|
304
|
+
<span
|
|
305
|
+
aria-hidden
|
|
306
|
+
className="inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-muted text-[8px] font-semibold text-muted-foreground"
|
|
307
|
+
>
|
|
308
|
+
{initials}
|
|
309
|
+
</span>
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** A short ref in mono, copying the full one on a click. */
|
|
314
|
+
function RefChip({ value, full }: { value: string; full?: string }) {
|
|
315
|
+
const [copied, setCopied] = useState(false);
|
|
316
|
+
const text = full ?? value;
|
|
317
|
+
const copy = () => {
|
|
318
|
+
void navigator.clipboard?.writeText(text).then(() => {
|
|
319
|
+
setCopied(true);
|
|
320
|
+
setTimeout(() => setCopied(false), 1500);
|
|
321
|
+
});
|
|
322
|
+
};
|
|
323
|
+
return (
|
|
324
|
+
<span
|
|
325
|
+
className="inline-flex items-center rounded border bg-background font-mono text-[11px] text-muted-foreground"
|
|
326
|
+
title={text}
|
|
327
|
+
>
|
|
328
|
+
<span className="px-1">{value}</span>
|
|
329
|
+
<button
|
|
330
|
+
type="button"
|
|
331
|
+
aria-label={`Copy ${text}`}
|
|
332
|
+
onClick={copy}
|
|
333
|
+
className="border-l px-0.5 py-0.5 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&_svg]:h-3 [&_svg]:w-3"
|
|
334
|
+
>
|
|
335
|
+
{copied ? <Check /> : <Copy />}
|
|
336
|
+
</button>
|
|
337
|
+
</span>
|
|
338
|
+
);
|
|
339
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,15 @@ export {
|
|
|
14
14
|
CardHeader,
|
|
15
15
|
CardTitle,
|
|
16
16
|
} from "./card.js";
|
|
17
|
+
export {
|
|
18
|
+
type CommitAuthor,
|
|
19
|
+
type CommitDayGroup,
|
|
20
|
+
CommitHistory,
|
|
21
|
+
type CommitHistoryEntry,
|
|
22
|
+
type CommitHistoryProps,
|
|
23
|
+
formatRelativeTime,
|
|
24
|
+
groupByDay,
|
|
25
|
+
} from "./commit-history.js";
|
|
17
26
|
export {
|
|
18
27
|
Dialog,
|
|
19
28
|
DialogClose,
|