@praxical/ui 0.0.0-stage → 0.10.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.
- package/LICENSE +21 -0
- package/README.md +23 -2
- package/dist/activity-calendar.d.ts +13 -0
- package/dist/activity-calendar.js +7 -0
- package/dist/activity-heatmap.d.ts +14 -0
- package/dist/activity-heatmap.js +13 -0
- package/dist/chart-data.d.ts +9 -0
- package/dist/chart-data.js +9 -0
- package/dist/charts.d.ts +56 -0
- package/dist/charts.js +424 -0
- package/dist/chunk-7RMPDKZV.js +541 -0
- package/dist/chunk-7RTW3X7C.js +142 -0
- package/dist/chunk-EBF2F3LN.js +1523 -0
- package/dist/chunk-FCYIZANU.js +385 -0
- package/dist/chunk-HMO4VQZN.js +58 -0
- package/dist/chunk-II677WPC.js +177 -0
- package/dist/chunk-KZHUBPY6.js +102 -0
- package/dist/chunk-OLGZOPLD.js +166 -0
- package/dist/chunk-PDSV773E.js +52 -0
- package/dist/chunk-Q4ARHP76.js +457 -0
- package/dist/chunk-U5W7O3QV.js +22 -0
- package/dist/chunk-V6MXR4P2.js +275 -0
- package/dist/chunk-VZZDLRM5.js +152 -0
- package/dist/chunk-WEM2UQPR.js +110 -0
- package/dist/chunk-XFNDEA5M.js +104 -0
- package/dist/chunk-YKFAA7GU.js +72 -0
- package/dist/code-value.d.ts +13 -0
- package/dist/code-value.js +10 -0
- package/dist/code.d.ts +36 -0
- package/dist/code.js +198 -0
- package/dist/collection.d.ts +21 -0
- package/dist/collection.js +48 -0
- package/dist/content.d.ts +42 -0
- package/dist/content.js +122 -0
- package/dist/display.d.ts +58 -0
- package/dist/display.js +27 -0
- package/dist/feedback.d.ts +34 -0
- package/dist/feedback.js +184 -0
- package/dist/file-tree.d.ts +17 -0
- package/dist/file-tree.js +11 -0
- package/dist/forms.d.ts +69 -0
- package/dist/forms.js +273 -0
- package/dist/git-graph.d.ts +8 -0
- package/dist/git-graph.js +15 -0
- package/dist/git-layout.d.ts +24 -0
- package/dist/git-layout.js +7 -0
- package/dist/image-viewer.d.ts +18 -0
- package/dist/image-viewer.js +11 -0
- package/dist/index.d.ts +363 -0
- package/dist/index.js +98 -0
- package/dist/inputs.d.ts +112 -0
- package/dist/inputs.js +938 -0
- package/dist/layout.d.ts +56 -0
- package/dist/layout.js +180 -0
- package/dist/map-frame.d.ts +37 -0
- package/dist/map-frame.js +13 -0
- package/dist/media.d.ts +40 -0
- package/dist/media.js +19 -0
- package/dist/network-layout.d.ts +94 -0
- package/dist/network-layout.js +19 -0
- package/dist/network.d.ts +111 -0
- package/dist/network.js +354 -0
- package/dist/overlays.d.ts +95 -0
- package/dist/overlays.js +25 -0
- package/dist/patterns.d.ts +117 -0
- package/dist/patterns.js +387 -0
- package/dist/power-layout.d.ts +91 -0
- package/dist/power-layout.js +13 -0
- package/dist/power.d.ts +91 -0
- package/dist/power.js +353 -0
- package/dist/signal-context.d.ts +11 -0
- package/dist/signal-context.js +15 -0
- package/dist/strings-es-419.d.ts +13 -0
- package/dist/strings-es-419.js +357 -0
- package/dist/strings-fr.d.ts +15 -0
- package/dist/strings-fr.js +359 -0
- package/dist/strings-ja.d.ts +16 -0
- package/dist/strings-ja.js +357 -0
- package/dist/strings-pt-BR.d.ts +13 -0
- package/dist/strings-pt-BR.js +357 -0
- package/dist/strings.d.ts +394 -0
- package/dist/strings.js +15 -0
- package/dist/styles.css +2 -0
- package/dist/tab-bar.d.ts +20 -0
- package/dist/tab-bar.js +114 -0
- package/package.json +154 -3
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// packages/ui/src/git-layout.ts
|
|
4
|
+
function layoutGitGraph(commits) {
|
|
5
|
+
const order = /* @__PURE__ */ new Map();
|
|
6
|
+
commits.forEach((c, i) => {
|
|
7
|
+
if (order.has(c.id)) throw new Error(`Duplicate commit: ${c.id}`);
|
|
8
|
+
order.set(c.id, i);
|
|
9
|
+
});
|
|
10
|
+
commits.forEach((c, i) => {
|
|
11
|
+
for (const p of c.parents)
|
|
12
|
+
if (order.has(p) && order.get(p) <= i)
|
|
13
|
+
throw new Error(`Parent ${p} must follow commit ${c.id}`);
|
|
14
|
+
});
|
|
15
|
+
let lanes = [];
|
|
16
|
+
let laneCount = 1;
|
|
17
|
+
const edges = [], rows = [];
|
|
18
|
+
const free = (values) => {
|
|
19
|
+
const index = values.indexOf(null);
|
|
20
|
+
return index < 0 ? values.length : index;
|
|
21
|
+
};
|
|
22
|
+
commits.forEach((commit, row) => {
|
|
23
|
+
let lane = lanes.indexOf(commit.id);
|
|
24
|
+
const incoming = lane >= 0;
|
|
25
|
+
if (lane < 0) {
|
|
26
|
+
lane = free(lanes);
|
|
27
|
+
lanes[lane] = commit.id;
|
|
28
|
+
}
|
|
29
|
+
rows.push({ id: commit.id, lane });
|
|
30
|
+
if (incoming)
|
|
31
|
+
edges.push({
|
|
32
|
+
fromLane: lane,
|
|
33
|
+
toLane: lane,
|
|
34
|
+
fromRow: row,
|
|
35
|
+
toRow: row + 0.5,
|
|
36
|
+
dashed: false
|
|
37
|
+
});
|
|
38
|
+
lanes.forEach((id, index) => {
|
|
39
|
+
if (id && index !== lane)
|
|
40
|
+
edges.push({
|
|
41
|
+
fromLane: index,
|
|
42
|
+
toLane: index,
|
|
43
|
+
fromRow: row,
|
|
44
|
+
toRow: row + 1,
|
|
45
|
+
dashed: !order.has(id)
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
const next = [...lanes];
|
|
49
|
+
next[lane] = null;
|
|
50
|
+
[...new Set(commit.parents)].forEach((parent, index) => {
|
|
51
|
+
let target = next.indexOf(parent);
|
|
52
|
+
if (target < 0) {
|
|
53
|
+
target = index === 0 && next[lane] === null ? lane : free(next);
|
|
54
|
+
next[target] = parent;
|
|
55
|
+
}
|
|
56
|
+
edges.push({
|
|
57
|
+
fromLane: lane,
|
|
58
|
+
toLane: target,
|
|
59
|
+
fromRow: row + 0.5,
|
|
60
|
+
toRow: row + 1,
|
|
61
|
+
dashed: !order.has(parent)
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
laneCount = Math.max(laneCount, lanes.length, next.length);
|
|
65
|
+
lanes = next;
|
|
66
|
+
});
|
|
67
|
+
return { rows, edges, laneCount };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
layoutGitGraph
|
|
72
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface CodeValueProps {
|
|
2
|
+
/** Exact, single-line text. An empty string displays a dash and cannot be copied. */
|
|
3
|
+
value: string;
|
|
4
|
+
/** Required accessible name for the value and its copy action. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Supply a native bridge or clipboard fallback; reject/throw on failure. */
|
|
7
|
+
onCopy?: (value: string) => void | Promise<void>;
|
|
8
|
+
/** Disables copying; the value remains selectable. */
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
/** A selectable identifier or URL with an integrated, contextual copy action. */
|
|
13
|
+
export declare function CodeValue({ value, label, onCopy, disabled, className }: CodeValueProps): import("react").JSX.Element;
|
package/dist/code.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import "prismjs/components/prism-typescript.js";
|
|
2
|
+
import "prismjs/components/prism-jsx.js";
|
|
3
|
+
import "prismjs/components/prism-tsx.js";
|
|
4
|
+
import "prismjs/components/prism-json.js";
|
|
5
|
+
import "prismjs/components/prism-bash.js";
|
|
6
|
+
import "prismjs/components/prism-diff.js";
|
|
7
|
+
declare const languages: readonly ["text", "javascript", "typescript", "jsx", "tsx", "json", "css", "markup", "bash", "diff"];
|
|
8
|
+
export type CodeLanguage = (typeof languages)[number];
|
|
9
|
+
export declare function SyntaxCodeBlock({ code, language, label, lineNumbers, onCopy, }: {
|
|
10
|
+
code: string;
|
|
11
|
+
language?: CodeLanguage;
|
|
12
|
+
label?: string;
|
|
13
|
+
lineNumbers?: boolean;
|
|
14
|
+
onCopy?: (code: string) => void | Promise<void>;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
export declare function DiffViewer({ before, after, label, beforeLabel, afterLabel, }: {
|
|
17
|
+
before: string;
|
|
18
|
+
after: string;
|
|
19
|
+
label?: string;
|
|
20
|
+
beforeLabel?: string;
|
|
21
|
+
afterLabel?: string;
|
|
22
|
+
}): import("react").JSX.Element;
|
|
23
|
+
export interface HeatmapCell {
|
|
24
|
+
id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
value: number;
|
|
27
|
+
}
|
|
28
|
+
export declare function Heatmap({ label, cells, columns, onSelect, }: {
|
|
29
|
+
label: string;
|
|
30
|
+
cells: readonly HeatmapCell[];
|
|
31
|
+
columns?: number;
|
|
32
|
+
onSelect?: (cell: HeatmapCell) => void;
|
|
33
|
+
}): import("react").JSX.Element;
|
|
34
|
+
export { FileTree, type FileTreeNode } from "./file-tree.js";
|
|
35
|
+
export { GitGraph, layoutGitGraph, type GitCommit } from "./git-graph.js";
|
|
36
|
+
export { ActivityHeatmap, activityCalendar, type ActivityDay, } from "./activity-heatmap.js";
|
package/dist/code.js
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use client";
|
|
3
|
+
import {
|
|
4
|
+
FileTree
|
|
5
|
+
} from "./chunk-7RTW3X7C.js";
|
|
6
|
+
import {
|
|
7
|
+
GitGraph
|
|
8
|
+
} from "./chunk-XFNDEA5M.js";
|
|
9
|
+
import {
|
|
10
|
+
layoutGitGraph
|
|
11
|
+
} from "./chunk-YKFAA7GU.js";
|
|
12
|
+
import {
|
|
13
|
+
ActivityHeatmap
|
|
14
|
+
} from "./chunk-KZHUBPY6.js";
|
|
15
|
+
import {
|
|
16
|
+
activityCalendar
|
|
17
|
+
} from "./chunk-PDSV773E.js";
|
|
18
|
+
import {
|
|
19
|
+
Button
|
|
20
|
+
} from "./chunk-EBF2F3LN.js";
|
|
21
|
+
import {
|
|
22
|
+
useSignalStrings
|
|
23
|
+
} from "./chunk-U5W7O3QV.js";
|
|
24
|
+
import "./chunk-FCYIZANU.js";
|
|
25
|
+
|
|
26
|
+
// packages/ui/src/code.tsx
|
|
27
|
+
import { useState, useRef } from "react";
|
|
28
|
+
import Prism from "prismjs";
|
|
29
|
+
import "prismjs/components/prism-typescript.js";
|
|
30
|
+
import "prismjs/components/prism-jsx.js";
|
|
31
|
+
import "prismjs/components/prism-tsx.js";
|
|
32
|
+
import "prismjs/components/prism-json.js";
|
|
33
|
+
import "prismjs/components/prism-bash.js";
|
|
34
|
+
import "prismjs/components/prism-diff.js";
|
|
35
|
+
import { diffLines } from "diff";
|
|
36
|
+
import { Copy, Check } from "lucide-react";
|
|
37
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
38
|
+
function highlight(code, language) {
|
|
39
|
+
const grammar = Prism.languages[language];
|
|
40
|
+
if (!grammar) return code;
|
|
41
|
+
const render = (token, index) => typeof token === "string" ? token : /* @__PURE__ */ jsx("span", { className: `signal-syntax-${token.type}`, children: Array.isArray(token.content) ? token.content.map(render) : render(token.content, 0) }, index);
|
|
42
|
+
return Prism.tokenize(code, grammar).map(render);
|
|
43
|
+
}
|
|
44
|
+
function SyntaxCodeBlock({
|
|
45
|
+
code,
|
|
46
|
+
language = "text",
|
|
47
|
+
label,
|
|
48
|
+
lineNumbers = false,
|
|
49
|
+
onCopy
|
|
50
|
+
}) {
|
|
51
|
+
const strings = useSignalStrings();
|
|
52
|
+
const name = label ?? strings.code.label;
|
|
53
|
+
const [copied, setCopied] = useState(false), [error, setError] = useState("");
|
|
54
|
+
return /* @__PURE__ */ jsxs("figure", { className: "signal-code-view", children: [
|
|
55
|
+
/* @__PURE__ */ jsxs("figcaption", { children: [
|
|
56
|
+
/* @__PURE__ */ jsx("strong", { children: name }),
|
|
57
|
+
/* @__PURE__ */ jsx("span", { children: language }),
|
|
58
|
+
onCopy && /* @__PURE__ */ jsxs(
|
|
59
|
+
Button,
|
|
60
|
+
{
|
|
61
|
+
variant: "ghost",
|
|
62
|
+
onClick: async () => {
|
|
63
|
+
try {
|
|
64
|
+
await onCopy(code);
|
|
65
|
+
setCopied(true);
|
|
66
|
+
setError("");
|
|
67
|
+
} catch {
|
|
68
|
+
setError(strings.code.copyFailed);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
children: [
|
|
72
|
+
copied ? /* @__PURE__ */ jsx(Check, {}) : /* @__PURE__ */ jsx(Copy, {}),
|
|
73
|
+
copied ? strings.code.copied : strings.code.copy
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
] }),
|
|
78
|
+
/* @__PURE__ */ jsx("pre", { tabIndex: 0, "aria-label": name, children: /* @__PURE__ */ jsxs("code", { children: [
|
|
79
|
+
lineNumbers && /* @__PURE__ */ jsx("span", { className: "signal-code-gutter", "aria-hidden": "true", children: code.split("\n").map((_, i) => /* @__PURE__ */ jsxs("span", { children: [
|
|
80
|
+
i + 1,
|
|
81
|
+
"\n"
|
|
82
|
+
] }, i)) }),
|
|
83
|
+
/* @__PURE__ */ jsx("span", { children: highlight(code, language) })
|
|
84
|
+
] }) }),
|
|
85
|
+
error && /* @__PURE__ */ jsx("p", { role: "alert", children: error })
|
|
86
|
+
] });
|
|
87
|
+
}
|
|
88
|
+
function DiffViewer({
|
|
89
|
+
before,
|
|
90
|
+
after,
|
|
91
|
+
label,
|
|
92
|
+
beforeLabel,
|
|
93
|
+
afterLabel
|
|
94
|
+
}) {
|
|
95
|
+
const strings = useSignalStrings();
|
|
96
|
+
const name = label ?? strings.diff.label;
|
|
97
|
+
let oldLine = 0, newLine = 0;
|
|
98
|
+
const lines = diffLines(before, after).flatMap((part) => {
|
|
99
|
+
const rows = part.value.split("\n");
|
|
100
|
+
if (rows.at(-1) === "") rows.pop();
|
|
101
|
+
return rows.map((line) => ({
|
|
102
|
+
line,
|
|
103
|
+
kind: part.added ? "added" : part.removed ? "removed" : "same",
|
|
104
|
+
old: part.added ? null : ++oldLine,
|
|
105
|
+
next: part.removed ? null : ++newLine
|
|
106
|
+
}));
|
|
107
|
+
});
|
|
108
|
+
return /* @__PURE__ */ jsxs("figure", { className: "signal-code-view signal-diff", children: [
|
|
109
|
+
/* @__PURE__ */ jsxs("figcaption", { children: [
|
|
110
|
+
/* @__PURE__ */ jsx("strong", { children: name }),
|
|
111
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
112
|
+
beforeLabel ?? strings.diff.before,
|
|
113
|
+
" \u2192",
|
|
114
|
+
" ",
|
|
115
|
+
afterLabel ?? strings.diff.after
|
|
116
|
+
] })
|
|
117
|
+
] }),
|
|
118
|
+
/* @__PURE__ */ jsx("pre", { tabIndex: 0, "aria-label": strings.diff.unified(name), children: /* @__PURE__ */ jsx("code", { children: lines.map((l, i) => /* @__PURE__ */ jsxs("span", { className: "signal-diff-line", "data-kind": l.kind, children: [
|
|
119
|
+
/* @__PURE__ */ jsx("span", { className: "signal-line-number", "aria-hidden": "true", children: l.old ?? "" }),
|
|
120
|
+
/* @__PURE__ */ jsx("span", { className: "signal-line-number", "aria-hidden": "true", children: l.next ?? "" }),
|
|
121
|
+
/* @__PURE__ */ jsx("span", { className: "signal-diff-marker", children: l.kind === "added" ? "+" : l.kind === "removed" ? "-" : " " }),
|
|
122
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
123
|
+
l.line,
|
|
124
|
+
"\n"
|
|
125
|
+
] })
|
|
126
|
+
] }, i)) }) }),
|
|
127
|
+
before === after && /* @__PURE__ */ jsx("p", { className: "signal-muted", children: strings.diff.none })
|
|
128
|
+
] });
|
|
129
|
+
}
|
|
130
|
+
function Heatmap({
|
|
131
|
+
label,
|
|
132
|
+
cells,
|
|
133
|
+
columns = 12,
|
|
134
|
+
onSelect
|
|
135
|
+
}) {
|
|
136
|
+
const strings = useSignalStrings();
|
|
137
|
+
const [focused, setFocused] = useState(0);
|
|
138
|
+
const grid = useRef(null);
|
|
139
|
+
const max = Math.max(
|
|
140
|
+
1,
|
|
141
|
+
...cells.map((c) => Number.isFinite(c.value) ? c.value : 0)
|
|
142
|
+
), cols = Math.max(1, Math.floor(columns));
|
|
143
|
+
return /* @__PURE__ */ jsxs("figure", { className: "signal-heatmap", children: [
|
|
144
|
+
/* @__PURE__ */ jsx("figcaption", { children: label }),
|
|
145
|
+
/* @__PURE__ */ jsx("div", { className: "signal-heatmap-scroll", children: /* @__PURE__ */ jsx(
|
|
146
|
+
"div",
|
|
147
|
+
{
|
|
148
|
+
ref: grid,
|
|
149
|
+
className: "signal-heatmap-grid",
|
|
150
|
+
style: {
|
|
151
|
+
gridTemplateColumns: `repeat(${cols}, minmax(0, 12px))`
|
|
152
|
+
},
|
|
153
|
+
children: cells.map((cell, index) => /* @__PURE__ */ jsx(
|
|
154
|
+
"button",
|
|
155
|
+
{
|
|
156
|
+
type: "button",
|
|
157
|
+
tabIndex: index === Math.min(focused, cells.length - 1) ? 0 : -1,
|
|
158
|
+
onFocus: () => setFocused(index),
|
|
159
|
+
onKeyDown: (event) => {
|
|
160
|
+
const next = {
|
|
161
|
+
ArrowRight: index + 1,
|
|
162
|
+
ArrowLeft: index - 1,
|
|
163
|
+
ArrowDown: index + cols,
|
|
164
|
+
ArrowUp: index - cols,
|
|
165
|
+
Home: 0,
|
|
166
|
+
End: cells.length - 1
|
|
167
|
+
}[event.key];
|
|
168
|
+
if (next !== void 0) {
|
|
169
|
+
event.preventDefault();
|
|
170
|
+
grid.current?.querySelectorAll("button")[Math.max(0, Math.min(cells.length - 1, next))]?.focus();
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
title: strings.heatmap.cell(cell.label, String(cell.value)),
|
|
174
|
+
"aria-label": strings.heatmap.cell(cell.label, String(cell.value)),
|
|
175
|
+
"data-level": cell.value <= 0 ? 0 : Math.min(4, Math.ceil(cell.value / max * 4)),
|
|
176
|
+
onClick: () => onSelect?.(cell)
|
|
177
|
+
},
|
|
178
|
+
cell.id
|
|
179
|
+
))
|
|
180
|
+
}
|
|
181
|
+
) }),
|
|
182
|
+
/* @__PURE__ */ jsxs("div", { className: "signal-heatmap-scale", "aria-hidden": "true", children: [
|
|
183
|
+
/* @__PURE__ */ jsx("span", { children: strings.heatmap.less }),
|
|
184
|
+
[0, 1, 2, 3, 4].map((level) => /* @__PURE__ */ jsx("i", { "data-level": level }, level)),
|
|
185
|
+
/* @__PURE__ */ jsx("span", { children: strings.heatmap.more })
|
|
186
|
+
] })
|
|
187
|
+
] });
|
|
188
|
+
}
|
|
189
|
+
export {
|
|
190
|
+
ActivityHeatmap,
|
|
191
|
+
DiffViewer,
|
|
192
|
+
FileTree,
|
|
193
|
+
GitGraph,
|
|
194
|
+
Heatmap,
|
|
195
|
+
SyntaxCodeBlock,
|
|
196
|
+
activityCalendar,
|
|
197
|
+
layoutGitGraph
|
|
198
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type CollectionState = "loading" | "error" | "empty" | "ready";
|
|
3
|
+
/** Owns the loading, error, empty and ready sequence of a fetched collection,
|
|
4
|
+
* so a page shows one of them and never three at once. Pagers, headers and
|
|
5
|
+
* filters passed as `chrome` render only when there is something to page. */
|
|
6
|
+
export declare function Collection({ state, shape, loadingLabel, error, onRetry, retryLabel, empty, chrome, className, children, }: {
|
|
7
|
+
state: CollectionState;
|
|
8
|
+
/** Placeholder shape while loading. */
|
|
9
|
+
shape?: "rows" | "table" | "card" | ReactNode;
|
|
10
|
+
loadingLabel?: string;
|
|
11
|
+
/** Message for the error state. */
|
|
12
|
+
error?: ReactNode;
|
|
13
|
+
onRetry?: () => void;
|
|
14
|
+
retryLabel?: string;
|
|
15
|
+
/** An EmptyState (or any node) for the empty state. */
|
|
16
|
+
empty: ReactNode;
|
|
17
|
+
/** Pager, result count, bulk actions: shown only when ready. */
|
|
18
|
+
chrome?: ReactNode;
|
|
19
|
+
className?: string;
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use client";
|
|
3
|
+
import {
|
|
4
|
+
SkeletonCard,
|
|
5
|
+
SkeletonRows,
|
|
6
|
+
SkeletonTable
|
|
7
|
+
} from "./chunk-V6MXR4P2.js";
|
|
8
|
+
import {
|
|
9
|
+
Button
|
|
10
|
+
} from "./chunk-EBF2F3LN.js";
|
|
11
|
+
import {
|
|
12
|
+
useSignalStrings
|
|
13
|
+
} from "./chunk-U5W7O3QV.js";
|
|
14
|
+
import "./chunk-FCYIZANU.js";
|
|
15
|
+
|
|
16
|
+
// packages/ui/src/collection.tsx
|
|
17
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
var cx = (...values) => values.filter(Boolean).join(" ");
|
|
19
|
+
function Collection({
|
|
20
|
+
state,
|
|
21
|
+
shape = "rows",
|
|
22
|
+
loadingLabel,
|
|
23
|
+
error,
|
|
24
|
+
onRetry,
|
|
25
|
+
retryLabel,
|
|
26
|
+
empty,
|
|
27
|
+
chrome,
|
|
28
|
+
className,
|
|
29
|
+
children
|
|
30
|
+
}) {
|
|
31
|
+
const strings = useSignalStrings();
|
|
32
|
+
const loading = loadingLabel ?? strings.loading.label;
|
|
33
|
+
return /* @__PURE__ */ jsxs("div", { className: cx("signal-collection", className), "data-state": state, children: [
|
|
34
|
+
state === "loading" && (typeof shape === "string" ? shape === "table" ? /* @__PURE__ */ jsx(SkeletonTable, { label: loadingLabel ?? strings.loading.table }) : shape === "card" ? /* @__PURE__ */ jsx(SkeletonCard, { label: loading }) : /* @__PURE__ */ jsx(SkeletonRows, { label: loading }) : /* @__PURE__ */ jsx("div", { role: "status", "aria-label": loading, children: shape })),
|
|
35
|
+
state === "error" && /* @__PURE__ */ jsxs("div", { className: "signal-collection-error", role: "alert", children: [
|
|
36
|
+
/* @__PURE__ */ jsx("p", { children: error ?? strings.collection.error }),
|
|
37
|
+
onRetry && /* @__PURE__ */ jsx(Button, { onClick: onRetry, children: retryLabel ?? strings.collection.retry })
|
|
38
|
+
] }),
|
|
39
|
+
state === "empty" && empty,
|
|
40
|
+
state === "ready" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
41
|
+
chrome && /* @__PURE__ */ jsx("div", { className: "signal-collection-chrome", children: chrome }),
|
|
42
|
+
children
|
|
43
|
+
] })
|
|
44
|
+
] });
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
Collection
|
|
48
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ReactNode, MouseEvent } from "react";
|
|
2
|
+
export interface AccordionItem {
|
|
3
|
+
id: string;
|
|
4
|
+
title: ReactNode;
|
|
5
|
+
content: ReactNode;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function Accordion({ items, multiple, value, defaultValue, onValueChange, label, }: {
|
|
9
|
+
items: readonly AccordionItem[];
|
|
10
|
+
multiple?: boolean;
|
|
11
|
+
value?: string[];
|
|
12
|
+
defaultValue?: string[];
|
|
13
|
+
onValueChange?: (v: string[]) => void;
|
|
14
|
+
label?: string;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
export type EventState = "complete" | "current" | "pending" | "failed";
|
|
17
|
+
export interface EventStep {
|
|
18
|
+
id: string;
|
|
19
|
+
title: ReactNode;
|
|
20
|
+
detail?: ReactNode;
|
|
21
|
+
state: EventState;
|
|
22
|
+
time?: string;
|
|
23
|
+
dateTime?: string;
|
|
24
|
+
action?: ReactNode;
|
|
25
|
+
}
|
|
26
|
+
/** Event history and staged progress share a vertical, connected sequence. */
|
|
27
|
+
export declare function VerticalStepper({ label, items, onStepSelect, }: {
|
|
28
|
+
label: string;
|
|
29
|
+
items: readonly EventStep[];
|
|
30
|
+
onStepSelect?: (id: string) => void;
|
|
31
|
+
}): import("react").JSX.Element;
|
|
32
|
+
export declare function ImageCard({ src, alt, title, children, eyebrow, href, onClick, footer, aspectRatio, }: {
|
|
33
|
+
src: string;
|
|
34
|
+
alt: string;
|
|
35
|
+
title: string;
|
|
36
|
+
children?: ReactNode;
|
|
37
|
+
eyebrow?: ReactNode;
|
|
38
|
+
footer?: ReactNode;
|
|
39
|
+
href?: string;
|
|
40
|
+
onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
41
|
+
aspectRatio?: string;
|
|
42
|
+
}): import("react").JSX.Element;
|
package/dist/content.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use client";
|
|
3
|
+
import {
|
|
4
|
+
Button
|
|
5
|
+
} from "./chunk-EBF2F3LN.js";
|
|
6
|
+
import {
|
|
7
|
+
useSignalStrings
|
|
8
|
+
} from "./chunk-U5W7O3QV.js";
|
|
9
|
+
import "./chunk-FCYIZANU.js";
|
|
10
|
+
|
|
11
|
+
// packages/ui/src/content.tsx
|
|
12
|
+
import { Accordion as BaseAccordion } from "@base-ui/react/accordion";
|
|
13
|
+
import {
|
|
14
|
+
Check,
|
|
15
|
+
ChevronDown,
|
|
16
|
+
CircleAlert,
|
|
17
|
+
Clock,
|
|
18
|
+
LoaderCircle
|
|
19
|
+
} from "lucide-react";
|
|
20
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
function Accordion({
|
|
22
|
+
items,
|
|
23
|
+
multiple = false,
|
|
24
|
+
value,
|
|
25
|
+
defaultValue,
|
|
26
|
+
onValueChange,
|
|
27
|
+
label
|
|
28
|
+
}) {
|
|
29
|
+
const strings = useSignalStrings();
|
|
30
|
+
return /* @__PURE__ */ jsx(
|
|
31
|
+
BaseAccordion.Root,
|
|
32
|
+
{
|
|
33
|
+
className: "signal-accordion",
|
|
34
|
+
multiple,
|
|
35
|
+
value,
|
|
36
|
+
defaultValue,
|
|
37
|
+
onValueChange,
|
|
38
|
+
"aria-label": label ?? strings.accordion.label,
|
|
39
|
+
children: items.map((item) => /* @__PURE__ */ jsxs(
|
|
40
|
+
BaseAccordion.Item,
|
|
41
|
+
{
|
|
42
|
+
value: item.id,
|
|
43
|
+
disabled: item.disabled,
|
|
44
|
+
children: [
|
|
45
|
+
/* @__PURE__ */ jsx(BaseAccordion.Header, { children: /* @__PURE__ */ jsxs(BaseAccordion.Trigger, { children: [
|
|
46
|
+
item.title,
|
|
47
|
+
/* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": "true" })
|
|
48
|
+
] }) }),
|
|
49
|
+
/* @__PURE__ */ jsx(BaseAccordion.Panel, { children: /* @__PURE__ */ jsx("div", { children: item.content }) })
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
item.id
|
|
53
|
+
))
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
function VerticalStepper({
|
|
58
|
+
label,
|
|
59
|
+
items,
|
|
60
|
+
onStepSelect
|
|
61
|
+
}) {
|
|
62
|
+
const strings = useSignalStrings();
|
|
63
|
+
return /* @__PURE__ */ jsx("ol", { className: "signal-event-steps", "aria-label": label, children: items.map((item, index) => {
|
|
64
|
+
const Icon = item.state === "complete" ? Check : item.state === "failed" ? CircleAlert : item.state === "current" ? LoaderCircle : Clock;
|
|
65
|
+
return /* @__PURE__ */ jsxs(
|
|
66
|
+
"li",
|
|
67
|
+
{
|
|
68
|
+
"data-state": item.state,
|
|
69
|
+
"aria-current": item.state === "current" ? "step" : void 0,
|
|
70
|
+
children: [
|
|
71
|
+
/* @__PURE__ */ jsx("span", { className: "signal-event-marker", "aria-hidden": "true", children: /* @__PURE__ */ jsx(Icon, {}) }),
|
|
72
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
73
|
+
/* @__PURE__ */ jsxs("div", { className: "signal-event-title", children: [
|
|
74
|
+
onStepSelect ? /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => onStepSelect(item.id), children: item.title }) : /* @__PURE__ */ jsx("strong", { children: item.title }),
|
|
75
|
+
/* @__PURE__ */ jsx("span", { className: "signal-event-state", children: strings.eventState[item.state] })
|
|
76
|
+
] }),
|
|
77
|
+
item.detail && /* @__PURE__ */ jsx("div", { className: "signal-event-detail", children: item.detail }),
|
|
78
|
+
item.time && /* @__PURE__ */ jsx("time", { dateTime: item.dateTime, children: item.time }),
|
|
79
|
+
item.action,
|
|
80
|
+
/* @__PURE__ */ jsx("span", { className: "signal-sr-only", children: strings.stepper.position(index + 1, items.length) })
|
|
81
|
+
] })
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
item.id
|
|
85
|
+
);
|
|
86
|
+
}) });
|
|
87
|
+
}
|
|
88
|
+
function ImageCard({
|
|
89
|
+
src,
|
|
90
|
+
alt,
|
|
91
|
+
title,
|
|
92
|
+
children,
|
|
93
|
+
eyebrow,
|
|
94
|
+
href,
|
|
95
|
+
onClick,
|
|
96
|
+
footer,
|
|
97
|
+
aspectRatio = "16 / 9"
|
|
98
|
+
}) {
|
|
99
|
+
const image = /* @__PURE__ */ jsx("img", { src, alt, loading: "lazy", style: { aspectRatio } });
|
|
100
|
+
return /* @__PURE__ */ jsxs("article", { className: "signal-image-card", children: [
|
|
101
|
+
href ? /* @__PURE__ */ jsx("a", { className: "signal-image-card-cover", href, "aria-label": title, children: image }) : onClick ? /* @__PURE__ */ jsx(
|
|
102
|
+
Button,
|
|
103
|
+
{
|
|
104
|
+
className: "signal-image-card-cover",
|
|
105
|
+
onClick,
|
|
106
|
+
"aria-label": title,
|
|
107
|
+
children: image
|
|
108
|
+
}
|
|
109
|
+
) : image,
|
|
110
|
+
/* @__PURE__ */ jsxs("div", { className: "signal-image-card-content", children: [
|
|
111
|
+
eyebrow && /* @__PURE__ */ jsx("span", { className: "signal-image-card-eyebrow", children: eyebrow }),
|
|
112
|
+
/* @__PURE__ */ jsx("h3", { children: href ? /* @__PURE__ */ jsx("a", { href, children: title }) : title }),
|
|
113
|
+
children && /* @__PURE__ */ jsx("div", { children }),
|
|
114
|
+
footer && /* @__PURE__ */ jsx("footer", { children: footer })
|
|
115
|
+
] })
|
|
116
|
+
] });
|
|
117
|
+
}
|
|
118
|
+
export {
|
|
119
|
+
Accordion,
|
|
120
|
+
ImageCard,
|
|
121
|
+
VerticalStepper
|
|
122
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
+
export type Tone = "neutral" | "accent" | "success" | "warning" | "danger";
|
|
3
|
+
/** A text link. `action` renders it at control weight for row and pane actions;
|
|
4
|
+
* `quiet` inherits the surrounding colour and underlines on hover only. */
|
|
5
|
+
export declare function Link({ external, variant, className, children, ...props }: ComponentProps<"a"> & {
|
|
6
|
+
external?: boolean;
|
|
7
|
+
variant?: "inline" | "action" | "quiet";
|
|
8
|
+
}): import("react").JSX.Element;
|
|
9
|
+
/** A removable label for filters, categories and selections. Badges describe
|
|
10
|
+
* state; tags describe membership. */
|
|
11
|
+
export declare function Tag({ tone, icon, onRemove, removeLabel, className, children, ...props }: ComponentProps<"span"> & {
|
|
12
|
+
tone?: Tone;
|
|
13
|
+
icon?: ReactNode;
|
|
14
|
+
onRemove?: () => void;
|
|
15
|
+
removeLabel?: string;
|
|
16
|
+
}): import("react").JSX.Element;
|
|
17
|
+
/** A small square indicator with an accessible name. Never the only cue: pair it with text. */
|
|
18
|
+
export declare function StatusDot({ tone, label, pulse, className, ...props }: ComponentProps<"span"> & {
|
|
19
|
+
tone?: Tone;
|
|
20
|
+
label: string;
|
|
21
|
+
pulse?: boolean;
|
|
22
|
+
}): import("react").JSX.Element;
|
|
23
|
+
/** A formatted `<time>` with the exact instant in its title. Relative output
|
|
24
|
+
* is computed when rendered; pass `now` for deterministic tests. */
|
|
25
|
+
export declare function Time({ value, format, timeZone, now, className, ...props }: Omit<ComponentProps<"time">, "dateTime"> & {
|
|
26
|
+
value: string | Date;
|
|
27
|
+
format?: "datetime" | "date" | "time" | "relative" | "utc";
|
|
28
|
+
timeZone?: string;
|
|
29
|
+
now?: Date;
|
|
30
|
+
}): import("react").JSX.Element;
|
|
31
|
+
/** A page-level notice that spans its container: configuration missing,
|
|
32
|
+
* service degraded, action required. It is flat, edge to edge, and dismissable. */
|
|
33
|
+
export declare function Banner({ tone, title, action, onDismiss, dismissLabel, className, children, ...props }: ComponentProps<"div"> & {
|
|
34
|
+
tone?: Tone;
|
|
35
|
+
title?: ReactNode;
|
|
36
|
+
action?: ReactNode;
|
|
37
|
+
onDismiss?: () => void;
|
|
38
|
+
dismissLabel?: string;
|
|
39
|
+
}): import("react").JSX.Element;
|
|
40
|
+
/** A quiet aside beside the content it explains. Not a warning: use Alert or Banner for those. */
|
|
41
|
+
export declare function Callout({ tone, title, className, children, ...props }: ComponentProps<"aside"> & {
|
|
42
|
+
tone?: "neutral" | "accent";
|
|
43
|
+
title?: ReactNode;
|
|
44
|
+
}): import("react").JSX.Element;
|
|
45
|
+
/** Loading placeholders that match the shape of what arrives. */
|
|
46
|
+
export declare function SkeletonRows({ rows, label, avatar, }: {
|
|
47
|
+
rows?: number;
|
|
48
|
+
label?: string;
|
|
49
|
+
avatar?: boolean;
|
|
50
|
+
}): import("react").JSX.Element;
|
|
51
|
+
export declare function SkeletonTable({ rows, columns, label, }: {
|
|
52
|
+
rows?: number;
|
|
53
|
+
columns?: number;
|
|
54
|
+
label?: string;
|
|
55
|
+
}): import("react").JSX.Element;
|
|
56
|
+
export declare function SkeletonCard({ label }: {
|
|
57
|
+
label?: string;
|
|
58
|
+
}): import("react").JSX.Element;
|
package/dist/display.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use client";
|
|
3
|
+
import {
|
|
4
|
+
Banner,
|
|
5
|
+
Callout,
|
|
6
|
+
Link,
|
|
7
|
+
SkeletonCard,
|
|
8
|
+
SkeletonRows,
|
|
9
|
+
SkeletonTable,
|
|
10
|
+
StatusDot,
|
|
11
|
+
Tag,
|
|
12
|
+
Time
|
|
13
|
+
} from "./chunk-V6MXR4P2.js";
|
|
14
|
+
import "./chunk-EBF2F3LN.js";
|
|
15
|
+
import "./chunk-U5W7O3QV.js";
|
|
16
|
+
import "./chunk-FCYIZANU.js";
|
|
17
|
+
export {
|
|
18
|
+
Banner,
|
|
19
|
+
Callout,
|
|
20
|
+
Link,
|
|
21
|
+
SkeletonCard,
|
|
22
|
+
SkeletonRows,
|
|
23
|
+
SkeletonTable,
|
|
24
|
+
StatusDot,
|
|
25
|
+
Tag,
|
|
26
|
+
Time
|
|
27
|
+
};
|