klun-ui 0.1.20 → 0.1.21
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 +16 -0
- package/dist/{chunk-JFRI333P.js → chunk-T3IFNMYU.js} +80 -7
- package/dist/chunk-T3IFNMYU.js.map +1 -0
- package/dist/{chunk-XNBVAUVT.cjs → chunk-UMR3IWCQ.cjs} +80 -7
- package/dist/chunk-UMR3IWCQ.cjs.map +1 -0
- package/dist/index.cjs +158 -158
- package/dist/index.d.cts +17 -3
- package/dist/index.d.ts +17 -3
- package/dist/index.js +1 -1
- package/dist/styles.css +56 -0
- package/dist/templates/index.cjs +89 -89
- package/dist/templates/index.js +1 -1
- package/package.json +19 -12
- package/dist/chunk-JFRI333P.js.map +0 -1
- package/dist/chunk-XNBVAUVT.cjs.map +0 -1
|
@@ -3501,8 +3501,21 @@ var ListItem = react.forwardRef(
|
|
|
3501
3501
|
);
|
|
3502
3502
|
ListItem.displayName = "ListItem";
|
|
3503
3503
|
var k = 0;
|
|
3504
|
+
var wikiResolve;
|
|
3504
3505
|
function inline(text) {
|
|
3505
3506
|
const patterns = [
|
|
3507
|
+
// [[wiki link]] / [[target|label]] — resolved via the wikiLink prop; falls
|
|
3508
|
+
// back to plain text (not raw brackets) when unresolved.
|
|
3509
|
+
{
|
|
3510
|
+
re: /\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/,
|
|
3511
|
+
node: (m) => {
|
|
3512
|
+
const target = m[1].trim();
|
|
3513
|
+
const r = wikiResolve?.(target);
|
|
3514
|
+
const resolved = typeof r === "string" ? { href: r, label: void 0 } : r || null;
|
|
3515
|
+
const label = m[2]?.trim() || resolved?.label || target;
|
|
3516
|
+
return resolved ? /* @__PURE__ */ jsxRuntime.jsx("a", { className: "klun-md-wikilink", href: resolved.href, children: label }, k++) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "klun-md-wikilink klun-md-wikilink--broken", children: label }, k++);
|
|
3517
|
+
}
|
|
3518
|
+
},
|
|
3506
3519
|
{ re: /`([^`]+)`/, node: (m) => /* @__PURE__ */ jsxRuntime.jsx("code", { className: "klun-md-code", children: m[1] }, k++) },
|
|
3507
3520
|
// image before link (`` starts with `!` + link syntax). url allows
|
|
3508
3521
|
// http(s) and data: URIs (base64 has no `)`), so pasted screenshots embed inline.
|
|
@@ -3514,6 +3527,13 @@ function inline(text) {
|
|
|
3514
3527
|
{
|
|
3515
3528
|
re: /\[([^\]]+)\]\(([^)]+)\)/,
|
|
3516
3529
|
node: (m) => /* @__PURE__ */ jsxRuntime.jsx("a", { href: m[2], target: "_blank", rel: "noreferrer", children: m[1] }, k++)
|
|
3530
|
+
},
|
|
3531
|
+
// bare autolink: a plain http(s) URL becomes a link. Runs after the
|
|
3532
|
+
// [text](url)/image patterns — those start at an earlier index (the `[`/`!`)
|
|
3533
|
+
// and so win via the earliest-match selection below.
|
|
3534
|
+
{
|
|
3535
|
+
re: /(https?:\/\/[^\s<>()[\]]+)/,
|
|
3536
|
+
node: (m) => /* @__PURE__ */ jsxRuntime.jsx("a", { href: m[1], target: "_blank", rel: "noreferrer", children: m[1] }, k++)
|
|
3517
3537
|
}
|
|
3518
3538
|
];
|
|
3519
3539
|
const out = [];
|
|
@@ -3534,9 +3554,28 @@ function inline(text) {
|
|
|
3534
3554
|
}
|
|
3535
3555
|
return out;
|
|
3536
3556
|
}
|
|
3557
|
+
function splitRow(line) {
|
|
3558
|
+
let s = line.trim();
|
|
3559
|
+
if (s.startsWith("|")) s = s.slice(1);
|
|
3560
|
+
if (s.endsWith("|")) s = s.slice(0, -1);
|
|
3561
|
+
return s.split("|").map((c) => c.trim());
|
|
3562
|
+
}
|
|
3563
|
+
function tableAligns(delimCells) {
|
|
3564
|
+
return delimCells.map((c) => {
|
|
3565
|
+
const l = c.startsWith(":"), r = c.endsWith(":");
|
|
3566
|
+
return l && r ? "center" : r ? "right" : l ? "left" : void 0;
|
|
3567
|
+
});
|
|
3568
|
+
}
|
|
3569
|
+
function isTableDelim(delim, cols) {
|
|
3570
|
+
if (!delim || !delim.includes("-")) return false;
|
|
3571
|
+
const cells = splitRow(delim);
|
|
3572
|
+
return cells.length === cols && cells.every((c) => /^:?-{1,}:?$/.test(c));
|
|
3573
|
+
}
|
|
3574
|
+
var HR = /^\s{0,3}(-{3,}|\*{3,}|_{3,})\s*$/;
|
|
3537
3575
|
var SPECIAL = /^(#{1,6}\s|>\s?|[-*]\s+|\d+\.\s+|```)/;
|
|
3538
|
-
function renderMarkdown(src) {
|
|
3576
|
+
function renderMarkdown(src, opts) {
|
|
3539
3577
|
k = 0;
|
|
3578
|
+
wikiResolve = opts?.wikiLink;
|
|
3540
3579
|
const lines = src.replace(/\r\n/g, "\n").split("\n");
|
|
3541
3580
|
const blocks = [];
|
|
3542
3581
|
let i = 0;
|
|
@@ -3552,6 +3591,30 @@ function renderMarkdown(src) {
|
|
|
3552
3591
|
);
|
|
3553
3592
|
continue;
|
|
3554
3593
|
}
|
|
3594
|
+
if (line.includes("|")) {
|
|
3595
|
+
const header = splitRow(line);
|
|
3596
|
+
if (i + 1 < lines.length && isTableDelim(lines[i + 1], header.length)) {
|
|
3597
|
+
const aligns = tableAligns(splitRow(lines[i + 1]));
|
|
3598
|
+
i += 2;
|
|
3599
|
+
const rows = [];
|
|
3600
|
+
while (i < lines.length && lines[i].trim() !== "" && lines[i].includes("|")) {
|
|
3601
|
+
rows.push(splitRow(lines[i++]));
|
|
3602
|
+
}
|
|
3603
|
+
const cellStyle = (j) => aligns[j] ? { textAlign: aligns[j] } : void 0;
|
|
3604
|
+
blocks.push(
|
|
3605
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-md-tablewrap", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "klun-md-table", children: [
|
|
3606
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: header.map((c, j) => /* @__PURE__ */ jsxRuntime.jsx("th", { style: cellStyle(j), children: inline(c) }, j)) }) }),
|
|
3607
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: rows.map((r, ri) => /* @__PURE__ */ jsxRuntime.jsx("tr", { children: header.map((_, j) => /* @__PURE__ */ jsxRuntime.jsx("td", { style: cellStyle(j), children: inline(r[j] ?? "") }, j)) }, ri)) })
|
|
3608
|
+
] }) }, k++)
|
|
3609
|
+
);
|
|
3610
|
+
continue;
|
|
3611
|
+
}
|
|
3612
|
+
}
|
|
3613
|
+
if (HR.test(line)) {
|
|
3614
|
+
blocks.push(/* @__PURE__ */ jsxRuntime.jsx("hr", { className: "klun-md-hr" }, k++));
|
|
3615
|
+
i++;
|
|
3616
|
+
continue;
|
|
3617
|
+
}
|
|
3555
3618
|
const h = /^(#{1,6})\s+(.*)$/.exec(line);
|
|
3556
3619
|
if (h) {
|
|
3557
3620
|
const tag = `h${Math.min(h[1].length + 2, 6)}`;
|
|
@@ -3570,8 +3633,18 @@ function renderMarkdown(src) {
|
|
|
3570
3633
|
if (/^[-*]\s+/.test(line)) {
|
|
3571
3634
|
const items2 = [];
|
|
3572
3635
|
while (i < lines.length && /^[-*]\s+/.test(lines[i])) items2.push(lines[i++].replace(/^[-*]\s+/, ""));
|
|
3636
|
+
const hasTask = items2.some((it) => /^\[[ xX]\]\s+/.test(it));
|
|
3573
3637
|
blocks.push(
|
|
3574
|
-
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "klun-md-ul", children: items2.map((it, j) =>
|
|
3638
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: hasTask ? "klun-md-ul klun-md-tasklist" : "klun-md-ul", children: items2.map((it, j) => {
|
|
3639
|
+
const t = /^\[([ xX])\]\s+(.*)$/.exec(it);
|
|
3640
|
+
if (t) {
|
|
3641
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "klun-md-task", children: [
|
|
3642
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: t[1] !== " ", readOnly: true, disabled: true }),
|
|
3643
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: inline(t[2]) })
|
|
3644
|
+
] }, j);
|
|
3645
|
+
}
|
|
3646
|
+
return /* @__PURE__ */ jsxRuntime.jsx("li", { children: inline(it) }, j);
|
|
3647
|
+
}) }, k++)
|
|
3575
3648
|
);
|
|
3576
3649
|
continue;
|
|
3577
3650
|
}
|
|
@@ -3589,16 +3662,16 @@ function renderMarkdown(src) {
|
|
|
3589
3662
|
}
|
|
3590
3663
|
const buf = [line];
|
|
3591
3664
|
i++;
|
|
3592
|
-
while (i < lines.length && lines[i].trim() !== "" && !SPECIAL.test(lines[i])) buf.push(lines[i++]);
|
|
3665
|
+
while (i < lines.length && lines[i].trim() !== "" && !SPECIAL.test(lines[i]) && !HR.test(lines[i])) buf.push(lines[i++]);
|
|
3593
3666
|
blocks.push(
|
|
3594
3667
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "klun-md-p", children: buf.flatMap((l, j) => j ? [/* @__PURE__ */ jsxRuntime.jsx("br", {}, `br${j}`), ...inline(l)] : inline(l)) }, k++)
|
|
3595
3668
|
);
|
|
3596
3669
|
}
|
|
3597
3670
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: blocks });
|
|
3598
3671
|
}
|
|
3599
|
-
var Markdown = react.forwardRef(function Markdown2({ children, source, className, ...props }, ref) {
|
|
3672
|
+
var Markdown = react.forwardRef(function Markdown2({ children, source, className, wikiLink, ...props }, ref) {
|
|
3600
3673
|
const src = source ?? (typeof children === "string" ? children : "") ?? "";
|
|
3601
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: chunkTPGAXYFU_cjs.cx("klun-md", className), ...props, children: renderMarkdown(src) });
|
|
3674
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: chunkTPGAXYFU_cjs.cx("klun-md", className), ...props, children: renderMarkdown(src, { wikiLink }) });
|
|
3602
3675
|
});
|
|
3603
3676
|
Markdown.displayName = "Markdown";
|
|
3604
3677
|
var Money = react.forwardRef(function Money2({
|
|
@@ -11682,5 +11755,5 @@ exports.useSize = useSize;
|
|
|
11682
11755
|
exports.viVN = viVN;
|
|
11683
11756
|
exports.zhCN = zhCN;
|
|
11684
11757
|
exports.zhTW = zhTW;
|
|
11685
|
-
//# sourceMappingURL=chunk-
|
|
11686
|
-
//# sourceMappingURL=chunk-
|
|
11758
|
+
//# sourceMappingURL=chunk-UMR3IWCQ.cjs.map
|
|
11759
|
+
//# sourceMappingURL=chunk-UMR3IWCQ.cjs.map
|