@mdocui/react 0.1.2 → 0.1.3

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/dist/index.cjs CHANGED
@@ -175,10 +175,10 @@ var import_core3 = require("@mdocui/core");
175
175
  // src/components/content.tsx
176
176
  var import_jsx_runtime2 = require("react/jsx-runtime");
177
177
  var calloutColors = {
178
- info: { bg: "#eff6ff", border: "#3b82f6" },
179
- warning: { bg: "#fffbeb", border: "#f59e0b" },
180
- error: { bg: "#fef2f2", border: "#ef4444" },
181
- success: { bg: "#f0fdf4", border: "#22c55e" }
178
+ info: { bg: "rgba(59,130,246,0.1)", border: "#3b82f6" },
179
+ warning: { bg: "rgba(245,158,11,0.1)", border: "#f59e0b" },
180
+ error: { bg: "rgba(239,68,68,0.1)", border: "#ef4444" },
181
+ success: { bg: "rgba(34,197,94,0.1)", border: "#22c55e" }
182
182
  };
183
183
  function Callout({ props, children }) {
184
184
  const type = props.type ?? "info";
@@ -204,11 +204,11 @@ function Callout({ props, children }) {
204
204
  );
205
205
  }
206
206
  var badgeColors = {
207
- default: { bg: "#f1f5f9", color: "#475569" },
208
- success: { bg: "#dcfce7", color: "#166534" },
209
- warning: { bg: "#fef3c7", color: "#92400e" },
210
- error: { bg: "#fee2e2", color: "#991b1b" },
211
- info: { bg: "#dbeafe", color: "#1e40af" }
207
+ default: { bg: "rgba(148,163,184,0.15)", color: "#94a3b8" },
208
+ success: { bg: "rgba(34,197,94,0.15)", color: "#4ade80" },
209
+ warning: { bg: "rgba(245,158,11,0.15)", color: "#fbbf24" },
210
+ error: { bg: "rgba(239,68,68,0.15)", color: "#f87171" },
211
+ info: { bg: "rgba(59,130,246,0.15)", color: "#60a5fa" }
212
212
  };
213
213
  function Badge({ props }) {
214
214
  const label = props.label;
@@ -307,7 +307,7 @@ function Link({ props, onAction, isStreaming }) {
307
307
  "data-mdocui-link": true,
308
308
  href: url ?? "#",
309
309
  onClick: handleClick,
310
- style: { color: "#3b82f6", textDecoration: "underline", cursor: "pointer" },
310
+ style: { color: "#60a5fa", textDecoration: "underline", cursor: "pointer" },
311
311
  children: label
312
312
  }
313
313
  );
@@ -317,36 +317,48 @@ function Link({ props, onAction, isStreaming }) {
317
317
  var import_jsx_runtime3 = require("react/jsx-runtime");
318
318
  function Chart({ props }) {
319
319
  const type = props.type;
320
- const labels = props.labels ?? [];
321
- const values = props.values ?? [];
320
+ const labels = Array.isArray(props.labels) ? props.labels : [];
321
+ const values = Array.isArray(props.values) ? props.values.map(Number) : [];
322
322
  const title = props.title;
323
323
  const max = values.reduce((a, b) => Math.max(a, b), 1);
324
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-mdocui-chart": true, "data-type": type, children: [
325
- title && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontWeight: 600, marginBottom: "8px" }, children: title }),
326
- (type === "bar" || type === "line") && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "flex", alignItems: "flex-end", gap: "4px", height: "120px" }, children: values.map((val, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { flex: 1, textAlign: "center" }, children: [
324
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-mdocui-chart": true, "data-type": type, style: { padding: "12px 0" }, children: [
325
+ title && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontWeight: 600, marginBottom: "12px" }, children: title }),
326
+ (type === "bar" || type === "line") && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "flex", alignItems: "flex-end", gap: "6px", height: "140px" }, children: values.map((val, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { flex: 1, textAlign: "center", display: "flex", flexDirection: "column", justifyContent: "flex-end", height: "100%" }, children: [
327
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "11px", color: "#94a3b8", marginBottom: "4px" }, children: val }),
327
328
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
328
329
  "div",
329
330
  {
330
331
  style: {
331
- height: `${val / max * 100}%`,
332
- background: "#3b82f6",
332
+ height: `${Math.max(val / max * 100, 4)}%`,
333
+ background: "linear-gradient(180deg, #3b82f6, #2563eb)",
333
334
  borderRadius: "4px 4px 0 0",
334
- minHeight: "2px"
335
+ minHeight: "4px"
335
336
  }
336
337
  }
337
338
  ),
338
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "11px", marginTop: "4px", color: "#64748b" }, children: labels[i] })
339
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "11px", marginTop: "6px", color: "#64748b" }, children: labels[i] })
339
340
  ] }, labels[i] ?? i)) }),
340
- (type === "pie" || type === "donut") && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" }, children: labels.map((label, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { style: { fontSize: "13px" }, children: [
341
- label,
342
- ": ",
343
- values[i]
344
- ] }, label)) })
341
+ (type === "pie" || type === "donut") && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "flex", gap: "12px", flexWrap: "wrap" }, children: labels.map((label, i) => {
342
+ const total = values.reduce((a, b) => a + b, 0);
343
+ const pct = total > 0 ? Math.round(values[i] / total * 100) : 0;
344
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "6px", fontSize: "13px" }, children: [
345
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { width: 10, height: 10, borderRadius: "50%", background: chartColors[i % chartColors.length] } }),
346
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { children: [
347
+ label,
348
+ ": ",
349
+ values[i],
350
+ " (",
351
+ pct,
352
+ "%)"
353
+ ] })
354
+ ] }, label);
355
+ }) })
345
356
  ] });
346
357
  }
358
+ var chartColors = ["#3b82f6", "#22c55e", "#f59e0b", "#ef4444", "#8b5cf6", "#ec4899", "#06b6d4", "#f97316"];
347
359
  function Table({ props }) {
348
- const headers = props.headers ?? [];
349
- const rows = props.rows ?? [];
360
+ const headers = Array.isArray(props.headers) ? props.headers : [];
361
+ const rows = Array.isArray(props.rows) ? props.rows : [];
350
362
  const caption = props.caption;
351
363
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("table", { "data-mdocui-table": true, style: { width: "100%", borderCollapse: "collapse" }, children: [
352
364
  caption && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("caption", { style: { textAlign: "left", fontWeight: 600, marginBottom: "8px" }, children: caption }),
@@ -356,17 +368,22 @@ function Table({ props }) {
356
368
  style: {
357
369
  textAlign: "left",
358
370
  padding: "8px",
359
- borderBottom: "2px solid #e2e8f0",
360
- fontWeight: 600
371
+ borderBottom: "2px solid #333",
372
+ fontWeight: 600,
373
+ color: "#94a3b8",
374
+ fontSize: "13px"
361
375
  },
362
376
  children: h
363
377
  },
364
378
  h
365
379
  )) }) }),
366
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tbody", { children: rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tr", { children: row.map((cell, _ci) => {
367
- const cellKey = `${row[0]}-${cell}`;
368
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { style: { padding: "8px", borderBottom: "1px solid #f1f5f9" }, children: cell }, cellKey);
369
- }) }, row.join(" "))) })
380
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tbody", { children: rows.map((row) => {
381
+ const cells = Array.isArray(row) ? row : [String(row)];
382
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tr", { children: cells.map((cell) => {
383
+ const cellKey = `${cells[0]}-${cell}`;
384
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { style: { padding: "8px", borderBottom: "1px solid #222" }, children: cell }, cellKey);
385
+ }) }, cells.join(" "));
386
+ }) })
370
387
  ] });
371
388
  }
372
389
  function Stat({ props }) {
@@ -374,24 +391,30 @@ function Stat({ props }) {
374
391
  const value = props.value;
375
392
  const change = props.change;
376
393
  const trend = props.trend ?? "neutral";
377
- const trendColor = trend === "up" ? "#16a34a" : trend === "down" ? "#dc2626" : "#64748b";
378
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-mdocui-stat": true, children: [
394
+ const trendColor = trend === "up" ? "#4ade80" : trend === "down" ? "#f87171" : "#64748b";
395
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-mdocui-stat": true, style: { padding: "8px 0" }, children: [
379
396
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "13px", color: "#64748b" }, children: label }),
380
397
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "24px", fontWeight: 700 }, children: value }),
381
398
  change && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "13px", color: trendColor }, children: change })
382
399
  ] });
383
400
  }
384
401
  function Progress({ props }) {
385
- const value = props.value;
402
+ const value = Number(props.value) || 0;
386
403
  const label = props.label;
387
- const max = props.max ?? 100;
404
+ const max = Number(props.max) || 100;
388
405
  const pct = Math.min(100, Math.max(0, value / max * 100));
389
406
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-mdocui-progress": true, children: [
390
- label && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "13px", marginBottom: "4px" }, children: label }),
407
+ label && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { fontSize: "13px", marginBottom: "4px", display: "flex", justifyContent: "space-between" }, children: [
408
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: label }),
409
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { style: { color: "#64748b" }, children: [
410
+ Math.round(pct),
411
+ "%"
412
+ ] })
413
+ ] }),
391
414
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
392
415
  "div",
393
416
  {
394
- style: { height: "8px", background: "#e2e8f0", borderRadius: "4px", overflow: "hidden" },
417
+ style: { height: "8px", background: "#27272a", borderRadius: "4px", overflow: "hidden" },
395
418
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
396
419
  "div",
397
420
  {
@@ -439,9 +462,9 @@ function Button({ props, onAction, isStreaming }) {
439
462
  borderRadius: "6px",
440
463
  cursor: isStreaming || disabled ? "not-allowed" : "pointer",
441
464
  opacity: isStreaming || disabled ? 0.6 : 1,
442
- border: variant === "outline" ? "1px solid currentColor" : "none",
443
- background: variant === "primary" ? "#0f172a" : variant === "ghost" ? "transparent" : "#e2e8f0",
444
- color: variant === "primary" ? "#fff" : "inherit"
465
+ border: variant === "outline" ? "1px solid #555" : "none",
466
+ background: variant === "primary" ? "#3b82f6" : variant === "ghost" ? "transparent" : "#27272a",
467
+ color: "#fff"
445
468
  },
446
469
  children: label
447
470
  }
@@ -482,7 +505,9 @@ function Input({ props }) {
482
505
  style: {
483
506
  width: "100%",
484
507
  padding: "8px 12px",
485
- border: "1px solid #e2e8f0",
508
+ border: "1px solid #333",
509
+ background: "#18181b",
510
+ color: "inherit",
486
511
  borderRadius: "6px",
487
512
  boxSizing: "border-box"
488
513
  }
@@ -493,7 +518,7 @@ function Input({ props }) {
493
518
  function Select({ props, onAction, isStreaming }) {
494
519
  const name = props.name;
495
520
  const label = props.label;
496
- const options = props.options ?? [];
521
+ const options = Array.isArray(props.options) ? props.options : [];
497
522
  const placeholder = props.placeholder;
498
523
  const required = props.required ?? false;
499
524
  const id = `mdocui-${name}`;
@@ -518,7 +543,9 @@ function Select({ props, onAction, isStreaming }) {
518
543
  style: {
519
544
  width: "100%",
520
545
  padding: "8px 12px",
521
- border: "1px solid #e2e8f0",
546
+ border: "1px solid #333",
547
+ background: "#18181b",
548
+ color: "inherit",
522
549
  borderRadius: "6px"
523
550
  },
524
551
  children: [
@@ -633,7 +660,7 @@ function Card({ props, children }) {
633
660
  {
634
661
  "data-mdocui-card": true,
635
662
  "data-variant": props.variant ?? "default",
636
- style: { border: "1px solid #e2e8f0", borderRadius: "8px", padding: "16px" },
663
+ style: { border: "1px solid #27272a", borderRadius: "8px", padding: "16px" },
637
664
  children: [
638
665
  title && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { "data-mdocui-card-title": true, style: { fontWeight: 600, marginBottom: "8px" }, children: title }),
639
666
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { "data-mdocui-card-body": true, children })
@@ -646,7 +673,7 @@ function Divider(_) {
646
673
  "hr",
647
674
  {
648
675
  "data-mdocui-divider": true,
649
- style: { border: "none", borderTop: "1px solid #e2e8f0", margin: "8px 0" }
676
+ style: { border: "none", borderTop: "1px solid #27272a", margin: "8px 0" }
650
677
  }
651
678
  );
652
679
  }
@@ -659,7 +686,7 @@ function Accordion({ props, children }) {
659
686
  ] });
660
687
  }
661
688
  function Tabs({ props, children }) {
662
- const labels = props.labels ?? [];
689
+ const labels = Array.isArray(props.labels) ? props.labels : [];
663
690
  const initialActive = props.active ?? 0;
664
691
  const [active, setActive] = (0, import_react4.useState)(initialActive);
665
692
  const childArray = import_react4.default.Children.toArray(children);
@@ -668,7 +695,7 @@ function Tabs({ props, children }) {
668
695
  "div",
669
696
  {
670
697
  role: "tablist",
671
- style: { display: "flex", gap: "4px", borderBottom: "1px solid #e2e8f0" },
698
+ style: { display: "flex", gap: "4px", borderBottom: "1px solid #27272a" },
672
699
  children: labels.map((label, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
673
700
  "button",
674
701
  {