@mdocui/react 0.1.1 → 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.js CHANGED
@@ -116,10 +116,10 @@ import { ComponentRegistry } from "@mdocui/core";
116
116
  // src/components/content.tsx
117
117
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
118
118
  var calloutColors = {
119
- info: { bg: "#eff6ff", border: "#3b82f6" },
120
- warning: { bg: "#fffbeb", border: "#f59e0b" },
121
- error: { bg: "#fef2f2", border: "#ef4444" },
122
- success: { bg: "#f0fdf4", border: "#22c55e" }
119
+ info: { bg: "rgba(59,130,246,0.1)", border: "#3b82f6" },
120
+ warning: { bg: "rgba(245,158,11,0.1)", border: "#f59e0b" },
121
+ error: { bg: "rgba(239,68,68,0.1)", border: "#ef4444" },
122
+ success: { bg: "rgba(34,197,94,0.1)", border: "#22c55e" }
123
123
  };
124
124
  function Callout({ props, children }) {
125
125
  const type = props.type ?? "info";
@@ -145,11 +145,11 @@ function Callout({ props, children }) {
145
145
  );
146
146
  }
147
147
  var badgeColors = {
148
- default: { bg: "#f1f5f9", color: "#475569" },
149
- success: { bg: "#dcfce7", color: "#166534" },
150
- warning: { bg: "#fef3c7", color: "#92400e" },
151
- error: { bg: "#fee2e2", color: "#991b1b" },
152
- info: { bg: "#dbeafe", color: "#1e40af" }
148
+ default: { bg: "rgba(148,163,184,0.15)", color: "#94a3b8" },
149
+ success: { bg: "rgba(34,197,94,0.15)", color: "#4ade80" },
150
+ warning: { bg: "rgba(245,158,11,0.15)", color: "#fbbf24" },
151
+ error: { bg: "rgba(239,68,68,0.15)", color: "#f87171" },
152
+ info: { bg: "rgba(59,130,246,0.15)", color: "#60a5fa" }
153
153
  };
154
154
  function Badge({ props }) {
155
155
  const label = props.label;
@@ -248,7 +248,7 @@ function Link({ props, onAction, isStreaming }) {
248
248
  "data-mdocui-link": true,
249
249
  href: url ?? "#",
250
250
  onClick: handleClick,
251
- style: { color: "#3b82f6", textDecoration: "underline", cursor: "pointer" },
251
+ style: { color: "#60a5fa", textDecoration: "underline", cursor: "pointer" },
252
252
  children: label
253
253
  }
254
254
  );
@@ -258,36 +258,48 @@ function Link({ props, onAction, isStreaming }) {
258
258
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
259
259
  function Chart({ props }) {
260
260
  const type = props.type;
261
- const labels = props.labels ?? [];
262
- const values = props.values ?? [];
261
+ const labels = Array.isArray(props.labels) ? props.labels : [];
262
+ const values = Array.isArray(props.values) ? props.values.map(Number) : [];
263
263
  const title = props.title;
264
264
  const max = values.reduce((a, b) => Math.max(a, b), 1);
265
- return /* @__PURE__ */ jsxs2("div", { "data-mdocui-chart": true, "data-type": type, children: [
266
- title && /* @__PURE__ */ jsx3("div", { style: { fontWeight: 600, marginBottom: "8px" }, children: title }),
267
- (type === "bar" || type === "line") && /* @__PURE__ */ jsx3("div", { style: { display: "flex", alignItems: "flex-end", gap: "4px", height: "120px" }, children: values.map((val, i) => /* @__PURE__ */ jsxs2("div", { style: { flex: 1, textAlign: "center" }, children: [
265
+ return /* @__PURE__ */ jsxs2("div", { "data-mdocui-chart": true, "data-type": type, style: { padding: "12px 0" }, children: [
266
+ title && /* @__PURE__ */ jsx3("div", { style: { fontWeight: 600, marginBottom: "12px" }, children: title }),
267
+ (type === "bar" || type === "line") && /* @__PURE__ */ jsx3("div", { style: { display: "flex", alignItems: "flex-end", gap: "6px", height: "140px" }, children: values.map((val, i) => /* @__PURE__ */ jsxs2("div", { style: { flex: 1, textAlign: "center", display: "flex", flexDirection: "column", justifyContent: "flex-end", height: "100%" }, children: [
268
+ /* @__PURE__ */ jsx3("div", { style: { fontSize: "11px", color: "#94a3b8", marginBottom: "4px" }, children: val }),
268
269
  /* @__PURE__ */ jsx3(
269
270
  "div",
270
271
  {
271
272
  style: {
272
- height: `${val / max * 100}%`,
273
- background: "#3b82f6",
273
+ height: `${Math.max(val / max * 100, 4)}%`,
274
+ background: "linear-gradient(180deg, #3b82f6, #2563eb)",
274
275
  borderRadius: "4px 4px 0 0",
275
- minHeight: "2px"
276
+ minHeight: "4px"
276
277
  }
277
278
  }
278
279
  ),
279
- /* @__PURE__ */ jsx3("div", { style: { fontSize: "11px", marginTop: "4px", color: "#64748b" }, children: labels[i] })
280
+ /* @__PURE__ */ jsx3("div", { style: { fontSize: "11px", marginTop: "6px", color: "#64748b" }, children: labels[i] })
280
281
  ] }, labels[i] ?? i)) }),
281
- (type === "pie" || type === "donut") && /* @__PURE__ */ jsx3("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" }, children: labels.map((label, i) => /* @__PURE__ */ jsxs2("span", { style: { fontSize: "13px" }, children: [
282
- label,
283
- ": ",
284
- values[i]
285
- ] }, label)) })
282
+ (type === "pie" || type === "donut") && /* @__PURE__ */ jsx3("div", { style: { display: "flex", gap: "12px", flexWrap: "wrap" }, children: labels.map((label, i) => {
283
+ const total = values.reduce((a, b) => a + b, 0);
284
+ const pct = total > 0 ? Math.round(values[i] / total * 100) : 0;
285
+ return /* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: "6px", fontSize: "13px" }, children: [
286
+ /* @__PURE__ */ jsx3("div", { style: { width: 10, height: 10, borderRadius: "50%", background: chartColors[i % chartColors.length] } }),
287
+ /* @__PURE__ */ jsxs2("span", { children: [
288
+ label,
289
+ ": ",
290
+ values[i],
291
+ " (",
292
+ pct,
293
+ "%)"
294
+ ] })
295
+ ] }, label);
296
+ }) })
286
297
  ] });
287
298
  }
299
+ var chartColors = ["#3b82f6", "#22c55e", "#f59e0b", "#ef4444", "#8b5cf6", "#ec4899", "#06b6d4", "#f97316"];
288
300
  function Table({ props }) {
289
- const headers = props.headers ?? [];
290
- const rows = props.rows ?? [];
301
+ const headers = Array.isArray(props.headers) ? props.headers : [];
302
+ const rows = Array.isArray(props.rows) ? props.rows : [];
291
303
  const caption = props.caption;
292
304
  return /* @__PURE__ */ jsxs2("table", { "data-mdocui-table": true, style: { width: "100%", borderCollapse: "collapse" }, children: [
293
305
  caption && /* @__PURE__ */ jsx3("caption", { style: { textAlign: "left", fontWeight: 600, marginBottom: "8px" }, children: caption }),
@@ -297,17 +309,22 @@ function Table({ props }) {
297
309
  style: {
298
310
  textAlign: "left",
299
311
  padding: "8px",
300
- borderBottom: "2px solid #e2e8f0",
301
- fontWeight: 600
312
+ borderBottom: "2px solid #333",
313
+ fontWeight: 600,
314
+ color: "#94a3b8",
315
+ fontSize: "13px"
302
316
  },
303
317
  children: h
304
318
  },
305
319
  h
306
320
  )) }) }),
307
- /* @__PURE__ */ jsx3("tbody", { children: rows.map((row) => /* @__PURE__ */ jsx3("tr", { children: row.map((cell, _ci) => {
308
- const cellKey = `${row[0]}-${cell}`;
309
- return /* @__PURE__ */ jsx3("td", { style: { padding: "8px", borderBottom: "1px solid #f1f5f9" }, children: cell }, cellKey);
310
- }) }, row.join(" "))) })
321
+ /* @__PURE__ */ jsx3("tbody", { children: rows.map((row) => {
322
+ const cells = Array.isArray(row) ? row : [String(row)];
323
+ return /* @__PURE__ */ jsx3("tr", { children: cells.map((cell) => {
324
+ const cellKey = `${cells[0]}-${cell}`;
325
+ return /* @__PURE__ */ jsx3("td", { style: { padding: "8px", borderBottom: "1px solid #222" }, children: cell }, cellKey);
326
+ }) }, cells.join(" "));
327
+ }) })
311
328
  ] });
312
329
  }
313
330
  function Stat({ props }) {
@@ -315,24 +332,30 @@ function Stat({ props }) {
315
332
  const value = props.value;
316
333
  const change = props.change;
317
334
  const trend = props.trend ?? "neutral";
318
- const trendColor = trend === "up" ? "#16a34a" : trend === "down" ? "#dc2626" : "#64748b";
319
- return /* @__PURE__ */ jsxs2("div", { "data-mdocui-stat": true, children: [
335
+ const trendColor = trend === "up" ? "#4ade80" : trend === "down" ? "#f87171" : "#64748b";
336
+ return /* @__PURE__ */ jsxs2("div", { "data-mdocui-stat": true, style: { padding: "8px 0" }, children: [
320
337
  /* @__PURE__ */ jsx3("div", { style: { fontSize: "13px", color: "#64748b" }, children: label }),
321
338
  /* @__PURE__ */ jsx3("div", { style: { fontSize: "24px", fontWeight: 700 }, children: value }),
322
339
  change && /* @__PURE__ */ jsx3("div", { style: { fontSize: "13px", color: trendColor }, children: change })
323
340
  ] });
324
341
  }
325
342
  function Progress({ props }) {
326
- const value = props.value;
343
+ const value = Number(props.value) || 0;
327
344
  const label = props.label;
328
- const max = props.max ?? 100;
345
+ const max = Number(props.max) || 100;
329
346
  const pct = Math.min(100, Math.max(0, value / max * 100));
330
347
  return /* @__PURE__ */ jsxs2("div", { "data-mdocui-progress": true, children: [
331
- label && /* @__PURE__ */ jsx3("div", { style: { fontSize: "13px", marginBottom: "4px" }, children: label }),
348
+ label && /* @__PURE__ */ jsxs2("div", { style: { fontSize: "13px", marginBottom: "4px", display: "flex", justifyContent: "space-between" }, children: [
349
+ /* @__PURE__ */ jsx3("span", { children: label }),
350
+ /* @__PURE__ */ jsxs2("span", { style: { color: "#64748b" }, children: [
351
+ Math.round(pct),
352
+ "%"
353
+ ] })
354
+ ] }),
332
355
  /* @__PURE__ */ jsx3(
333
356
  "div",
334
357
  {
335
- style: { height: "8px", background: "#e2e8f0", borderRadius: "4px", overflow: "hidden" },
358
+ style: { height: "8px", background: "#27272a", borderRadius: "4px", overflow: "hidden" },
336
359
  children: /* @__PURE__ */ jsx3(
337
360
  "div",
338
361
  {
@@ -380,9 +403,9 @@ function Button({ props, onAction, isStreaming }) {
380
403
  borderRadius: "6px",
381
404
  cursor: isStreaming || disabled ? "not-allowed" : "pointer",
382
405
  opacity: isStreaming || disabled ? 0.6 : 1,
383
- border: variant === "outline" ? "1px solid currentColor" : "none",
384
- background: variant === "primary" ? "#0f172a" : variant === "ghost" ? "transparent" : "#e2e8f0",
385
- color: variant === "primary" ? "#fff" : "inherit"
406
+ border: variant === "outline" ? "1px solid #555" : "none",
407
+ background: variant === "primary" ? "#3b82f6" : variant === "ghost" ? "transparent" : "#27272a",
408
+ color: "#fff"
386
409
  },
387
410
  children: label
388
411
  }
@@ -423,7 +446,9 @@ function Input({ props }) {
423
446
  style: {
424
447
  width: "100%",
425
448
  padding: "8px 12px",
426
- border: "1px solid #e2e8f0",
449
+ border: "1px solid #333",
450
+ background: "#18181b",
451
+ color: "inherit",
427
452
  borderRadius: "6px",
428
453
  boxSizing: "border-box"
429
454
  }
@@ -434,7 +459,7 @@ function Input({ props }) {
434
459
  function Select({ props, onAction, isStreaming }) {
435
460
  const name = props.name;
436
461
  const label = props.label;
437
- const options = props.options ?? [];
462
+ const options = Array.isArray(props.options) ? props.options : [];
438
463
  const placeholder = props.placeholder;
439
464
  const required = props.required ?? false;
440
465
  const id = `mdocui-${name}`;
@@ -459,7 +484,9 @@ function Select({ props, onAction, isStreaming }) {
459
484
  style: {
460
485
  width: "100%",
461
486
  padding: "8px 12px",
462
- border: "1px solid #e2e8f0",
487
+ border: "1px solid #333",
488
+ background: "#18181b",
489
+ color: "inherit",
463
490
  borderRadius: "6px"
464
491
  },
465
492
  children: [
@@ -574,7 +601,7 @@ function Card({ props, children }) {
574
601
  {
575
602
  "data-mdocui-card": true,
576
603
  "data-variant": props.variant ?? "default",
577
- style: { border: "1px solid #e2e8f0", borderRadius: "8px", padding: "16px" },
604
+ style: { border: "1px solid #27272a", borderRadius: "8px", padding: "16px" },
578
605
  children: [
579
606
  title && /* @__PURE__ */ jsx5("div", { "data-mdocui-card-title": true, style: { fontWeight: 600, marginBottom: "8px" }, children: title }),
580
607
  /* @__PURE__ */ jsx5("div", { "data-mdocui-card-body": true, children })
@@ -587,7 +614,7 @@ function Divider(_) {
587
614
  "hr",
588
615
  {
589
616
  "data-mdocui-divider": true,
590
- style: { border: "none", borderTop: "1px solid #e2e8f0", margin: "8px 0" }
617
+ style: { border: "none", borderTop: "1px solid #27272a", margin: "8px 0" }
591
618
  }
592
619
  );
593
620
  }
@@ -600,7 +627,7 @@ function Accordion({ props, children }) {
600
627
  ] });
601
628
  }
602
629
  function Tabs({ props, children }) {
603
- const labels = props.labels ?? [];
630
+ const labels = Array.isArray(props.labels) ? props.labels : [];
604
631
  const initialActive = props.active ?? 0;
605
632
  const [active, setActive] = useState2(initialActive);
606
633
  const childArray = React.Children.toArray(children);
@@ -609,7 +636,7 @@ function Tabs({ props, children }) {
609
636
  "div",
610
637
  {
611
638
  role: "tablist",
612
- style: { display: "flex", gap: "4px", borderBottom: "1px solid #e2e8f0" },
639
+ style: { display: "flex", gap: "4px", borderBottom: "1px solid #27272a" },
613
640
  children: labels.map((label, i) => /* @__PURE__ */ jsx5(
614
641
  "button",
615
642
  {