klun-ui 0.1.19 → 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.
@@ -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 (`![alt](url)` 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) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: inline(it) }, j)) }, k++)
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({
@@ -3702,6 +3775,30 @@ var Statistic = react.forwardRef(function Statistic2({ label, value, prefix, suf
3702
3775
  ] });
3703
3776
  });
3704
3777
  Statistic.displayName = "Statistic";
3778
+ var StatCard = react.forwardRef(function StatCard2({ label, value, delta, trend = "up", icon, tint = "feature", className, ...props }, ref) {
3779
+ const up = trend === "up";
3780
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: chunkTPGAXYFU_cjs.cx("klun-stat-card", `klun-stat-card--${tint}`, className), ...props, children: [
3781
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "klun-stat-card__head", children: [
3782
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "klun-stat-card__icon", children: icon }),
3783
+ delta != null ? /* @__PURE__ */ jsxRuntime.jsxs(
3784
+ "span",
3785
+ {
3786
+ className: chunkTPGAXYFU_cjs.cx(
3787
+ "klun-stat-card__delta",
3788
+ up ? "klun-stat-card__delta--up" : "klun-stat-card__delta--down"
3789
+ ),
3790
+ children: [
3791
+ /* @__PURE__ */ jsxRuntime.jsx("i", { className: up ? "ri-arrow-up-line" : "ri-arrow-down-line" }),
3792
+ delta
3793
+ ]
3794
+ }
3795
+ ) : null
3796
+ ] }),
3797
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-stat-card__label", children: label }),
3798
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-stat-card__value", children: value })
3799
+ ] });
3800
+ });
3801
+ StatCard.displayName = "StatCard";
3705
3802
  var SIZES2 = { xs: 6, sm: 8, md: 10, lg: 12 };
3706
3803
  var StatusDot = react.forwardRef(function StatusDot2({ tone = "neutral", size = "sm", pulse = false, label, className, style, ...props }, ref) {
3707
3804
  const sizeStyle = { ["--klun-status-dot-size"]: `${SIZES2[size] ?? SIZES2.sm}px` };
@@ -5665,6 +5762,43 @@ var Alert = react.forwardRef(function Alert2({ status = "information", variant =
5665
5762
  );
5666
5763
  });
5667
5764
  Alert.displayName = "Alert";
5765
+ var EmptyState = react.forwardRef(function EmptyState2({ icon, title, description, action, className, ...props }, ref) {
5766
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: chunkTPGAXYFU_cjs.cx("klun-empty-state", className), ...props, children: [
5767
+ icon ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-empty-state__icon", children: icon }) : null,
5768
+ title ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-empty-state__title", children: title }) : null,
5769
+ description ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-empty-state__desc", children: description }) : null,
5770
+ action ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-empty-state__action", children: action }) : null
5771
+ ] });
5772
+ });
5773
+ EmptyState.displayName = "EmptyState";
5774
+ var PRESET_ICON = {
5775
+ success: "ri-checkbox-circle-fill",
5776
+ error: "ri-close-circle-fill",
5777
+ warning: "ri-alert-fill",
5778
+ info: "ri-information-fill",
5779
+ "404": "ri-compass-3-line",
5780
+ "403": "ri-lock-2-line",
5781
+ "500": "ri-server-line"
5782
+ };
5783
+ var Result = react.forwardRef(function Result2({ status = "info", icon, title, subtitle, extra, children, className, ...props }, ref) {
5784
+ const big = status === "404" || status === "403" || status === "500";
5785
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5786
+ "div",
5787
+ {
5788
+ ref,
5789
+ className: chunkTPGAXYFU_cjs.cx("klun-result", `klun-result--${status}`, big && "klun-result--big", className),
5790
+ ...props,
5791
+ children: [
5792
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-result__icon", children: icon || /* @__PURE__ */ jsxRuntime.jsx("i", { className: PRESET_ICON[status] }) }),
5793
+ title ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-result__title", children: title }) : null,
5794
+ subtitle ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-result__subtitle", children: subtitle }) : null,
5795
+ extra ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-result__extra", children: extra }) : null,
5796
+ children ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-result__content", children }) : null
5797
+ ]
5798
+ }
5799
+ );
5800
+ });
5801
+ Result.displayName = "Result";
5668
5802
  var Banner = react.forwardRef(function Banner2({ status = "information", variant = "filled", icon, action, onClose, className, children, ...props }, ref) {
5669
5803
  const { banner } = useLocale();
5670
5804
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -11512,6 +11646,7 @@ exports.DigitInput = DigitInput;
11512
11646
  exports.Divider = Divider;
11513
11647
  exports.Drawer = Drawer;
11514
11648
  exports.Dropdown = Dropdown;
11649
+ exports.EmptyState = EmptyState;
11515
11650
  exports.ExpiryCountdown = ExpiryCountdown;
11516
11651
  exports.FileUpload = FileUpload;
11517
11652
  exports.Flex = Flex;
@@ -11558,6 +11693,7 @@ exports.RadioCard = RadioCard;
11558
11693
  exports.RangeSlider = RangeSlider;
11559
11694
  exports.Rating = Rating;
11560
11695
  exports.RelativeTime = RelativeTime;
11696
+ exports.Result = Result;
11561
11697
  exports.RichEditorToolbar = RichEditorToolbar;
11562
11698
  exports.Row = Row;
11563
11699
  exports.SegmentedControl = SegmentedControl;
@@ -11570,6 +11706,7 @@ exports.Space = Space;
11570
11706
  exports.Spinner = Spinner2;
11571
11707
  exports.Splitter = Splitter2;
11572
11708
  exports.SplitterPanel = SplitterPanel;
11709
+ exports.StatCard = StatCard;
11573
11710
  exports.Statistic = Statistic;
11574
11711
  exports.StatusBadge = StatusBadge;
11575
11712
  exports.StatusDot = StatusDot;
@@ -11618,5 +11755,5 @@ exports.useSize = useSize;
11618
11755
  exports.viVN = viVN;
11619
11756
  exports.zhCN = zhCN;
11620
11757
  exports.zhTW = zhTW;
11621
- //# sourceMappingURL=chunk-XMNM45KO.cjs.map
11622
- //# sourceMappingURL=chunk-XMNM45KO.cjs.map
11758
+ //# sourceMappingURL=chunk-UMR3IWCQ.cjs.map
11759
+ //# sourceMappingURL=chunk-UMR3IWCQ.cjs.map