@mechane-ai/elements 0.19.0 → 0.20.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/README.md +15 -4
- package/dist/ai.js +4 -4
- package/dist/{categorical-values-D-sSI9JB.js → categorical-values-DG0kzYxN.js} +2 -2
- package/dist/{chart-frame-vwS7YVgv.js → chart-frame-DxAZ0h_q.js} +50 -51
- package/dist/{chart-input-D6Fw2UGV.js → chart-input-Dru0GScv.js} +2 -2
- package/dist/charts/cartesian.js +279 -229
- package/dist/charts/distribution.js +2 -2
- package/dist/charts/graph.js +82 -80
- package/dist/charts/hierarchy.js +3 -3
- package/dist/charts/matrix.js +136 -134
- package/dist/charts/timeline.js +2 -2
- package/dist/charts.js +1 -1
- package/dist/code-block-DlUwVaPP.js +182 -0
- package/dist/collections.js +144 -143
- package/dist/{constants.stylex-bbdiv1fD.js → constants.stylex-BILvnwUk.js} +1 -0
- package/dist/content/code.js +1 -1
- package/dist/content/diff.js +3 -3
- package/dist/content/link.js +1 -1
- package/dist/content/markdown.js +108 -102
- package/dist/content/tree.js +43 -41
- package/dist/{content-link-rdxJ94P8.js → content-link-BIMrgXbz.js} +1 -1
- package/dist/content.js +139 -137
- package/dist/elements.css +34 -0
- package/dist/feedback.js +1 -1
- package/dist/forms/dates.js +1 -1
- package/dist/forms.js +1 -1
- package/dist/index.js +1 -1
- package/dist/layout.js +349 -212
- package/dist/navigation/commands.js +1 -1
- package/dist/navigation.js +0 -1
- package/dist/packages/charts/src/chart-cursor.d.ts +7 -0
- package/dist/packages/charts/src/chart-theme.d.ts +1 -7
- package/dist/packages/feedback/src/async-region.d.ts +3 -1
- package/dist/packages/foundations/src/constants.stylex.d.ts +1 -0
- package/dist/packages/foundations/src/use-scroll-tab-index.d.ts +6 -0
- package/dist/packages/layout/src/app-shell.d.ts +2 -1
- package/dist/packages/layout/src/index.d.ts +2 -0
- package/dist/packages/layout/src/navigation-rail.d.ts +18 -0
- package/dist/packages/layout/src/sidebar.d.ts +2 -1
- package/dist/pierre-diff-CHQsoQSZ.js +72 -0
- package/dist/{pierre-theme-BUeJim8s.js → pierre-theme-CLgk9v3e.js} +1 -1
- package/dist/{pierre-tree-BQBbAhmI.js → pierre-tree-D3XsgEH6.js} +4 -4
- package/dist/{src-BVsyKLQ8.js → src-0mocxTaR.js} +64 -43
- package/dist/{src-Dven_9lR.js → src-D4zPPr32.js} +1 -1
- package/dist/{src-BXh4g2VY.js → src-qU5Z5LRH.js} +1 -0
- package/dist/tokens.js +1 -1
- package/dist/use-scroll-tab-index-Dxpdh4W7.js +45 -0
- package/package.json +1 -1
- package/packages/foundations/src/constants.stylex.ts +1 -1
- package/dist/code-block-DB42-a0M.js +0 -180
- package/dist/pierre-diff-C_j0nxwS.js +0 -71
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { _ as e } from "./src-qU5Z5LRH.js";
|
|
2
|
+
import { r as t } from "./tokens.stylex-DTHHFbyl.js";
|
|
3
|
+
import { t as n } from "./use-scroll-tab-index-Dxpdh4W7.js";
|
|
4
|
+
import { t as r } from "./viewer-styles-CpHqp5Qv.js";
|
|
5
|
+
import { t as i } from "./pierre-theme-CLgk9v3e.js";
|
|
6
|
+
import * as a from "@stylexjs/stylex";
|
|
7
|
+
import { useEffect as o, useRef as s, useState as c } from "react";
|
|
8
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
9
|
+
// packages/content/src/code/use-highlighted-code.ts
|
|
10
|
+
var d = 2e5, f = 4096;
|
|
11
|
+
function p(e, t) {
|
|
12
|
+
let n = s(null), [r, a] = c();
|
|
13
|
+
return o(() => () => {
|
|
14
|
+
n.current !== null && (n.current.tokenizer.dispose(), n.current = null);
|
|
15
|
+
}, []), o(() => {
|
|
16
|
+
let r = !0;
|
|
17
|
+
async function o() {
|
|
18
|
+
try {
|
|
19
|
+
let o = await import("@pierre/highlights");
|
|
20
|
+
if (!r || e.length > d || !o.isSupportedLanguage(t)) return;
|
|
21
|
+
let s = n.current, c = s !== null && s.language === t, l = c ? s : {
|
|
22
|
+
language: t,
|
|
23
|
+
source: e,
|
|
24
|
+
tokenizer: new o.LiveTokenizer({
|
|
25
|
+
code: e,
|
|
26
|
+
lang: t,
|
|
27
|
+
theme: i,
|
|
28
|
+
tokenizeMaxLineLength: f
|
|
29
|
+
})
|
|
30
|
+
};
|
|
31
|
+
if (c) {
|
|
32
|
+
if (e.startsWith(s.source)) {
|
|
33
|
+
let t = l.tokenizer.lineCount - 1, n = {
|
|
34
|
+
line: t,
|
|
35
|
+
character: l.tokenizer.getLineLength(t)
|
|
36
|
+
};
|
|
37
|
+
l.tokenizer.applyEdits([{
|
|
38
|
+
range: {
|
|
39
|
+
start: n,
|
|
40
|
+
end: n
|
|
41
|
+
},
|
|
42
|
+
newText: e.slice(s.source.length)
|
|
43
|
+
}]);
|
|
44
|
+
} else l.tokenizer.reset(e);
|
|
45
|
+
} else s !== null && s.tokenizer.dispose();
|
|
46
|
+
n.current = {
|
|
47
|
+
...l,
|
|
48
|
+
source: e
|
|
49
|
+
};
|
|
50
|
+
let u = l.tokenizer;
|
|
51
|
+
u.flush();
|
|
52
|
+
let p = Array.from({ length: u.lineCount }, (e, t) => u.getLineTokens(t).tokens);
|
|
53
|
+
a({
|
|
54
|
+
code: e,
|
|
55
|
+
language: t,
|
|
56
|
+
lines: p,
|
|
57
|
+
hasFailed: !1
|
|
58
|
+
});
|
|
59
|
+
} catch {
|
|
60
|
+
r && a({
|
|
61
|
+
code: e,
|
|
62
|
+
language: t,
|
|
63
|
+
lines: [],
|
|
64
|
+
hasFailed: !0
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return o(), () => {
|
|
69
|
+
r = !1;
|
|
70
|
+
};
|
|
71
|
+
}, [e, t]), r !== void 0 && r.code === e && r.language === t ? r : void 0;
|
|
72
|
+
}
|
|
73
|
+
// packages/content/src/code/code-block.tsx
|
|
74
|
+
var m = {
|
|
75
|
+
kVQacm: "xysyzu8",
|
|
76
|
+
k9g6sI: "x12h1iku",
|
|
77
|
+
$$css: !0
|
|
78
|
+
}, h = {
|
|
79
|
+
viewport: (e) => [
|
|
80
|
+
m,
|
|
81
|
+
{
|
|
82
|
+
kskxy: e == null ? e : "x1jols5v",
|
|
83
|
+
$$css: !0
|
|
84
|
+
},
|
|
85
|
+
{ "--x-maxHeight": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e) }
|
|
86
|
+
],
|
|
87
|
+
token: (e) => [{
|
|
88
|
+
kMwMTN: e == null ? e : "x14rh7hd",
|
|
89
|
+
$$css: !0
|
|
90
|
+
}, { "--x-color": e ?? void 0 }],
|
|
91
|
+
italic: {
|
|
92
|
+
kKX8nH: "x1k4tb9n",
|
|
93
|
+
$$css: !0
|
|
94
|
+
},
|
|
95
|
+
bold: {
|
|
96
|
+
k63SB2: "x1b5ytql",
|
|
97
|
+
$$css: !0
|
|
98
|
+
}
|
|
99
|
+
}, g = 2e5;
|
|
100
|
+
function _({ token: e }) {
|
|
101
|
+
let n = e.fontStyle ?? 0, [r, i] = [!!(n & 1), !!(n & 2)];
|
|
102
|
+
return /* @__PURE__ */ l("span", {
|
|
103
|
+
...a.props(h.token(e.color ?? t.ink), r && h.italic, i && h.bold),
|
|
104
|
+
children: e.content
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function v({ code: t, language: i = "text", filename: o, isStreaming: s = !1, shouldWrap: c = !1, showLineNumbers: d = !0, selectedLines: f, annotations: m = [], maxHeight: v = 400, maxLines: y = 2e3 }) {
|
|
108
|
+
let b = p(t, i), x = n(), S = t.slice(0, g).split(/\r\n|\n|\r/u), C = S.slice(0, Math.max(1, y)).map((e, t) => ({
|
|
109
|
+
text: e,
|
|
110
|
+
line: t + 1
|
|
111
|
+
})), w = o ?? i;
|
|
112
|
+
return /* @__PURE__ */ u("section", {
|
|
113
|
+
"aria-label": o ?? "Code",
|
|
114
|
+
...a.props(r.root),
|
|
115
|
+
children: [
|
|
116
|
+
/* @__PURE__ */ u("div", {
|
|
117
|
+
...a.props(r.header),
|
|
118
|
+
children: [/* @__PURE__ */ u("span", {
|
|
119
|
+
...a.props(r.label),
|
|
120
|
+
children: [w, s && " · streaming"]
|
|
121
|
+
}), /* @__PURE__ */ l(e, {
|
|
122
|
+
label: o ?? "code",
|
|
123
|
+
value: t,
|
|
124
|
+
children: "Copy"
|
|
125
|
+
})]
|
|
126
|
+
}),
|
|
127
|
+
/* @__PURE__ */ l("div", {
|
|
128
|
+
ref: x.ref,
|
|
129
|
+
role: "region",
|
|
130
|
+
"aria-label": `${w} source`,
|
|
131
|
+
tabIndex: x.tabIndex,
|
|
132
|
+
...a.props(r.scrollRegion, h.viewport(v)),
|
|
133
|
+
children: /* @__PURE__ */ l("pre", {
|
|
134
|
+
...{
|
|
135
|
+
0: { className: "x1ghz6dp xn9t2bk xiard35 xy8obcc x1778rvt xeq4nuv xk8lq53" },
|
|
136
|
+
1: { className: "x1ghz6dp xn9t2bk xiard35 xy8obcc x1778rvt xeq4nuv xeuugli x126k92a xj0a0fe" }
|
|
137
|
+
}[!!c | 0],
|
|
138
|
+
children: /* @__PURE__ */ l("code", {
|
|
139
|
+
className: "xjb2p0i",
|
|
140
|
+
children: C.map(({ text: e, line: t }) => {
|
|
141
|
+
let n = b === void 0 ? void 0 : b.lines[t - 1], r = f !== void 0 && t >= f.start && t <= (f.end ?? f.start), i = m.find((e) => e.line === t);
|
|
142
|
+
return /* @__PURE__ */ u("span", { children: [/* @__PURE__ */ u("span", {
|
|
143
|
+
...{
|
|
144
|
+
0: { className: "x78zum5 x16exltd" },
|
|
145
|
+
1: { className: "x78zum5 x16exltd x1r8u7ye" }
|
|
146
|
+
}[!!r | 0],
|
|
147
|
+
children: [d && /* @__PURE__ */ l("span", {
|
|
148
|
+
"aria-hidden": !0,
|
|
149
|
+
className: "x1rg5ohu x2lah0s xl3ry0p x5g2kb4 xp4054r x153jb6y x87ps6o",
|
|
150
|
+
children: t
|
|
151
|
+
}), /* @__PURE__ */ u("span", {
|
|
152
|
+
className: "x1lliihq x12lumcd x1doqdfy xeuugli",
|
|
153
|
+
children: [n === void 0 ? e : n.map((e) => /* @__PURE__ */ l(_, { token: e }, e.offset)), e.length === 0 && "\n"]
|
|
154
|
+
})]
|
|
155
|
+
}), i !== void 0 && /* @__PURE__ */ l("span", {
|
|
156
|
+
className: "x1lliihq x9f619 x7wzq59 x1o0tod xzfn7dr x1mvvolr x1r7kqkb x1hz01jw xtqrqnz x1778rvt xeaf4i8 xj0a0fe",
|
|
157
|
+
children: i.content
|
|
158
|
+
})] }, t);
|
|
159
|
+
})
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
}),
|
|
163
|
+
S.length > C.length && /* @__PURE__ */ l("div", {
|
|
164
|
+
...a.props(r.note),
|
|
165
|
+
children: "Additional lines omitted. Copy includes the complete source."
|
|
166
|
+
}),
|
|
167
|
+
t.length > g && /* @__PURE__ */ l("div", {
|
|
168
|
+
...a.props(r.note),
|
|
169
|
+
children: "Preview limited to the first 200,000 characters. Copy includes the complete source."
|
|
170
|
+
}),
|
|
171
|
+
t.length === 0 && /* @__PURE__ */ l("div", {
|
|
172
|
+
...a.props(r.note),
|
|
173
|
+
children: "No source text."
|
|
174
|
+
}),
|
|
175
|
+
b !== void 0 && b.hasFailed && /* @__PURE__ */ l("div", {
|
|
176
|
+
...a.props(r.note),
|
|
177
|
+
children: "Syntax highlighting unavailable. The source is shown unchanged."
|
|
178
|
+
})
|
|
179
|
+
]
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
export { v as t };
|