@mmapp/react 0.1.0-alpha.18 → 0.1.0-alpha.20

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.
Files changed (55) hide show
  1. package/dist/actions-HOXZPBTT.mjs +116 -0
  2. package/dist/actions-MFI2V4DX.mjs +116 -0
  3. package/dist/atoms/index.d.mts +2 -2
  4. package/dist/atoms/index.d.ts +2 -2
  5. package/dist/atoms/index.js +1 -1
  6. package/dist/atoms/index.mjs +1 -1
  7. package/dist/builtin-atoms-C-sNyYJl.d.mts +647 -0
  8. package/dist/builtin-atoms-C-sNyYJl.d.ts +647 -0
  9. package/dist/builtin-atoms-DCKrjG7i.d.mts +96 -0
  10. package/dist/builtin-atoms-DCKrjG7i.d.ts +96 -0
  11. package/dist/builtin-atoms-DRD3EwG6.d.mts +648 -0
  12. package/dist/builtin-atoms-DRD3EwG6.d.ts +648 -0
  13. package/dist/builtin-atoms-jt04b7Rw.d.mts +643 -0
  14. package/dist/builtin-atoms-jt04b7Rw.d.ts +643 -0
  15. package/dist/chunk-247T4GDJ.mjs +677 -0
  16. package/dist/chunk-3H6CR7E7.mjs +1924 -0
  17. package/dist/chunk-3PL6FL6I.mjs +96 -0
  18. package/dist/chunk-3SJSW3C4.mjs +2039 -0
  19. package/dist/chunk-5OI2VI57.mjs +1964 -0
  20. package/dist/chunk-CL6FYZ43.mjs +105 -0
  21. package/dist/chunk-ENQOCZI5.mjs +1938 -0
  22. package/dist/chunk-FB3WCZAU.mjs +512 -0
  23. package/dist/chunk-FBKUGKQI.mjs +1938 -0
  24. package/dist/chunk-GLJ7VC7Z.mjs +684 -0
  25. package/dist/chunk-HHMWR6NA.mjs +504 -0
  26. package/dist/chunk-HULEMSN2.mjs +120 -0
  27. package/dist/chunk-J5MW6CRU.mjs +1938 -0
  28. package/dist/chunk-PNTTKNYU.mjs +677 -0
  29. package/dist/chunk-TY5OTJP4.mjs +684 -0
  30. package/dist/chunk-WV7DVCP6.mjs +513 -0
  31. package/dist/chunk-YFMPTGUF.mjs +677 -0
  32. package/dist/chunk-ZAHMWAER.mjs +1960 -0
  33. package/dist/{chunk-2VJQJM7S.mjs → chunk-ZDWACXZN.mjs} +1 -1
  34. package/dist/composition-BJ6QQTWT.mjs +12 -0
  35. package/dist/composition-XBGKKCI7.mjs +57 -0
  36. package/dist/content-QVPFUG4P.mjs +246 -0
  37. package/dist/control-flow-CBREHWJW.mjs +35 -0
  38. package/dist/control-flow-FWBOI6SM.mjs +35 -0
  39. package/dist/control-flow-ZWUGCDSP.mjs +35 -0
  40. package/dist/data-WCMIZYKD.mjs +97 -0
  41. package/dist/grouping-E6F377VZ.mjs +204 -0
  42. package/dist/grouping-FRPOEXO3.mjs +233 -0
  43. package/dist/index.d.mts +4 -433
  44. package/dist/index.d.ts +4 -433
  45. package/dist/index.js +3671 -582
  46. package/dist/index.mjs +335 -1040
  47. package/dist/input-PUOZDNSI.mjs +222 -0
  48. package/dist/layout-RATDMCLP.mjs +106 -0
  49. package/dist/navigation-VCT7ZBMA.mjs +15 -0
  50. package/dist/navigation-WFV7YWOU.mjs +14 -0
  51. package/dist/player/index.d.mts +37 -11
  52. package/dist/player/index.d.ts +37 -11
  53. package/dist/player/index.js +3321 -193
  54. package/dist/player/index.mjs +55 -5
  55. package/package.json +4 -4
@@ -2,7 +2,7 @@
2
2
  function stub(displayName) {
3
3
  const Component = () => {
4
4
  throw new Error(
5
- `<${displayName}> is a compile-time stub from @mindmatrix/react/atoms. It should only appear in .workflow.tsx files processed by the compiler. At runtime, use the ComponentTreeRenderer which resolves "${displayName}" from the component registry.`
5
+ `<${displayName}> is a compile-time stub from @mmapp/react/atoms. It should only appear in .workflow.tsx files processed by the compiler. At runtime, use the ComponentTreeRenderer which resolves "${displayName}" from the component registry.`
6
6
  );
7
7
  };
8
8
  Component.displayName = displayName;
@@ -0,0 +1,12 @@
1
+ import {
2
+ ModuleOutlet,
3
+ Slot,
4
+ SlotRegistryProvider,
5
+ useSlotContributions
6
+ } from "./chunk-3PL6FL6I.mjs";
7
+ export {
8
+ ModuleOutlet,
9
+ Slot,
10
+ SlotRegistryProvider,
11
+ useSlotContributions
12
+ };
@@ -0,0 +1,57 @@
1
+ // src/player/atoms/composition.tsx
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ var Slot = ({ children, name, fallback, className, style }) => {
4
+ const content = children ?? fallback;
5
+ if (!content) return null;
6
+ return /* @__PURE__ */ jsx(
7
+ "div",
8
+ {
9
+ className,
10
+ "data-slot": name,
11
+ style,
12
+ children: content
13
+ }
14
+ );
15
+ };
16
+ var ModuleOutlet = ({ children, module: moduleName, basePath, className, style }) => {
17
+ if (children) {
18
+ return /* @__PURE__ */ jsx(
19
+ "div",
20
+ {
21
+ className,
22
+ "data-module": moduleName,
23
+ style,
24
+ children
25
+ }
26
+ );
27
+ }
28
+ return /* @__PURE__ */ jsxs(
29
+ "div",
30
+ {
31
+ className,
32
+ "data-module": moduleName,
33
+ style: {
34
+ padding: 16,
35
+ border: "1px dashed #cbd5e0",
36
+ borderRadius: 8,
37
+ color: "#a0aec0",
38
+ fontSize: 13,
39
+ textAlign: "center",
40
+ ...style
41
+ },
42
+ children: [
43
+ "Module: ",
44
+ String(moduleName ?? "unknown"),
45
+ basePath ? /* @__PURE__ */ jsxs("span", { children: [
46
+ " (",
47
+ String(basePath),
48
+ ")"
49
+ ] }) : null
50
+ ]
51
+ }
52
+ );
53
+ };
54
+ export {
55
+ ModuleOutlet,
56
+ Slot
57
+ };
@@ -0,0 +1,246 @@
1
+ // src/player/atoms/content.tsx
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ var Text = ({ value, children, variant, size, weight, color, align, className, style }) => {
4
+ const text = value ?? children;
5
+ const sizeMap = { xs: 11, sm: 13, md: 14, lg: 16, xl: 20, "2xl": 24 };
6
+ const weightMap = { light: 300, normal: 400, medium: 500, semibold: 600, bold: 700 };
7
+ return /* @__PURE__ */ jsx(
8
+ "span",
9
+ {
10
+ className,
11
+ style: {
12
+ fontSize: size ? sizeMap[size] ?? Number(size) : void 0,
13
+ fontWeight: weight ? weightMap[weight] ?? weight : void 0,
14
+ color: variant === "muted" ? "#718096" : variant === "error" ? "#e53e3e" : variant === "success" ? "#38a169" : color,
15
+ textAlign: align,
16
+ ...style
17
+ },
18
+ children: text == null ? "" : String(text)
19
+ }
20
+ );
21
+ };
22
+ var Heading = ({ value, children, level, className, style }) => {
23
+ const text = value ?? children;
24
+ const sizes = { 1: 32, 2: 24, 3: 20, 4: 16, 5: 14, 6: 12 };
25
+ const lvl = Number(level) || 2;
26
+ const Tag = `h${Math.min(Math.max(lvl, 1), 6)}`;
27
+ return /* @__PURE__ */ jsx(
28
+ Tag,
29
+ {
30
+ className,
31
+ style: {
32
+ fontSize: sizes[lvl] ?? 20,
33
+ fontWeight: 600,
34
+ margin: "0 0 8px 0",
35
+ lineHeight: 1.3,
36
+ ...style
37
+ },
38
+ children: text == null ? "" : String(text)
39
+ }
40
+ );
41
+ };
42
+ var Field = ({ label, value, type: _type, children, className, style }) => /* @__PURE__ */ jsxs("div", { className, style: { marginBottom: 8, ...style }, children: [
43
+ label ? /* @__PURE__ */ jsx("label", { style: { display: "block", fontSize: 12, fontWeight: 500, color: "#718096", marginBottom: 2 }, children: String(label) }) : null,
44
+ /* @__PURE__ */ jsx("div", { style: { fontSize: 14 }, children: children ?? (value != null ? String(value) : /* @__PURE__ */ jsx("span", { style: { color: "#a0aec0" }, children: "\u2014" })) })
45
+ ] });
46
+ var Image = ({ src, alt, width, height, fit, radius, className, style }) => /* @__PURE__ */ jsx(
47
+ "img",
48
+ {
49
+ src,
50
+ alt: alt ?? "",
51
+ className,
52
+ style: {
53
+ width: width ? Number(width) : void 0,
54
+ height: height ? Number(height) : void 0,
55
+ objectFit: fit ?? "cover",
56
+ borderRadius: radius ? Number(radius) : void 0,
57
+ maxWidth: "100%",
58
+ ...style
59
+ }
60
+ }
61
+ );
62
+ var Badge = ({ value, children, variant, color, className, style }) => {
63
+ const text = value ?? children;
64
+ const colorMap = {
65
+ default: { bg: "#edf2f7", fg: "#4a5568" },
66
+ primary: { bg: "#ebf8ff", fg: "#2b6cb0" },
67
+ success: { bg: "#f0fff4", fg: "#276749" },
68
+ warning: { bg: "#fffaf0", fg: "#c05621" },
69
+ error: { bg: "#fff5f5", fg: "#c53030" },
70
+ info: { bg: "#ebf8ff", fg: "#2b6cb0" }
71
+ };
72
+ const c = colorMap[variant ?? "default"] ?? colorMap.default;
73
+ return /* @__PURE__ */ jsx(
74
+ "span",
75
+ {
76
+ className,
77
+ style: {
78
+ display: "inline-block",
79
+ padding: "1px 8px",
80
+ borderRadius: 9999,
81
+ fontSize: 12,
82
+ fontWeight: 500,
83
+ background: color ? void 0 : c.bg,
84
+ color: color ?? c.fg,
85
+ ...style
86
+ },
87
+ children: text == null ? "" : String(text)
88
+ }
89
+ );
90
+ };
91
+ var ICON_MAP = {
92
+ "check": "\u2713",
93
+ "x": "\u2715",
94
+ "plus": "+",
95
+ "minus": "\u2212",
96
+ "arrow-right": "\u2192",
97
+ "arrow-left": "\u2190",
98
+ "arrow-up": "\u2191",
99
+ "arrow-down": "\u2193",
100
+ "search": "\u{1F50D}",
101
+ "home": "\u{1F3E0}",
102
+ "user": "\u{1F464}",
103
+ "settings": "\u2699",
104
+ "star": "\u2B50",
105
+ "heart": "\u2764",
106
+ "mail": "\u2709",
107
+ "phone": "\u{1F4DE}",
108
+ "calendar": "\u{1F4C5}",
109
+ "clock": "\u{1F550}",
110
+ "edit": "\u270E",
111
+ "trash": "\u{1F5D1}",
112
+ "download": "\u2B07",
113
+ "upload": "\u2B06",
114
+ "share": "\u2197",
115
+ "lock": "\u{1F512}",
116
+ "unlock": "\u{1F513}",
117
+ "eye": "\u{1F441}",
118
+ "eye-off": "\u{1F648}",
119
+ "bell": "\u{1F514}",
120
+ "info": "\u2139",
121
+ "warning": "\u26A0",
122
+ "error": "\u274C",
123
+ "loading": "\u23F3",
124
+ "menu": "\u2630",
125
+ "close": "\u2715",
126
+ "chevron-right": "\u203A",
127
+ "chevron-left": "\u2039",
128
+ "chevron-up": "\u2038",
129
+ "chevron-down": "\u02EC",
130
+ "copy": "\u{1F4CB}",
131
+ "save": "\u{1F4BE}",
132
+ "refresh": "\u21BB",
133
+ "filter": "\u23CF",
134
+ "sort": "\u21C5"
135
+ };
136
+ var Icon = ({ name, size, color, className, style }) => /* @__PURE__ */ jsx(
137
+ "span",
138
+ {
139
+ className,
140
+ role: "img",
141
+ "aria-label": name,
142
+ style: {
143
+ fontSize: size ? Number(size) : 16,
144
+ color,
145
+ display: "inline-flex",
146
+ alignItems: "center",
147
+ justifyContent: "center",
148
+ ...style
149
+ },
150
+ children: ICON_MAP[name?.toLowerCase()] ?? name ?? "?"
151
+ }
152
+ );
153
+ var Alert = ({ children, variant, title, message, className, style }) => {
154
+ const colorMap = {
155
+ info: { bg: "#ebf8ff", border: "#90cdf4", fg: "#2b6cb0" },
156
+ success: { bg: "#f0fff4", border: "#9ae6b4", fg: "#276749" },
157
+ warning: { bg: "#fffaf0", border: "#fbd38d", fg: "#c05621" },
158
+ error: { bg: "#fff5f5", border: "#feb2b2", fg: "#c53030" }
159
+ };
160
+ const c = colorMap[variant ?? "info"] ?? colorMap.info;
161
+ return /* @__PURE__ */ jsxs(
162
+ "div",
163
+ {
164
+ className,
165
+ role: "alert",
166
+ style: {
167
+ padding: "12px 16px",
168
+ borderRadius: 6,
169
+ border: `1px solid ${c.border}`,
170
+ background: c.bg,
171
+ color: c.fg,
172
+ fontSize: 14,
173
+ ...style
174
+ },
175
+ children: [
176
+ title ? /* @__PURE__ */ jsx("div", { style: { fontWeight: 600, marginBottom: 4 }, children: String(title) }) : null,
177
+ message ? /* @__PURE__ */ jsx("div", { children: String(message) }) : null,
178
+ children
179
+ ]
180
+ }
181
+ );
182
+ };
183
+ var EmptyState = ({ children, title, description, icon, className, style }) => /* @__PURE__ */ jsxs(
184
+ "div",
185
+ {
186
+ className,
187
+ style: {
188
+ textAlign: "center",
189
+ padding: "32px 16px",
190
+ color: "#a0aec0",
191
+ ...style
192
+ },
193
+ children: [
194
+ icon ? /* @__PURE__ */ jsx("div", { style: { fontSize: 40, marginBottom: 12 }, children: ICON_MAP[icon] ?? icon }) : null,
195
+ title ? /* @__PURE__ */ jsx("div", { style: { fontSize: 16, fontWeight: 600, color: "#4a5568", marginBottom: 4 }, children: String(title) }) : null,
196
+ description ? /* @__PURE__ */ jsx("div", { style: { fontSize: 14, marginBottom: 8 }, children: String(description) }) : null,
197
+ children
198
+ ]
199
+ }
200
+ );
201
+ var Markdown = ({ value, children, className, style }) => {
202
+ const text = String(value ?? children ?? "");
203
+ const html = text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>").replace(/\*(.+?)\*/g, "<em>$1</em>").replace(/`(.+?)`/g, '<code style="background:#edf2f7;padding:1px 4px;border-radius:3px;font-size:13px">$1</code>').replace(/\n/g, "<br/>");
204
+ return /* @__PURE__ */ jsx(
205
+ "div",
206
+ {
207
+ className,
208
+ style: { fontSize: 14, lineHeight: 1.6, ...style },
209
+ dangerouslySetInnerHTML: { __html: html }
210
+ }
211
+ );
212
+ };
213
+ var Progress = ({ value, max, label, variant, className, style }) => {
214
+ const pct = Math.min(100, Math.max(0, Number(value) / (Number(max) || 100) * 100));
215
+ const colorMap = {
216
+ default: "#3182ce",
217
+ success: "#38a169",
218
+ warning: "#dd6b20",
219
+ error: "#e53e3e"
220
+ };
221
+ const color = colorMap[variant ?? "default"] ?? colorMap.default;
222
+ return /* @__PURE__ */ jsxs("div", { className, style: { ...style }, children: [
223
+ label ? /* @__PURE__ */ jsx("div", { style: { fontSize: 12, marginBottom: 4, color: "#718096" }, children: String(label) }) : null,
224
+ /* @__PURE__ */ jsx("div", { style: { height: 8, background: "#edf2f7", borderRadius: 4, overflow: "hidden" }, children: /* @__PURE__ */ jsx("div", { style: { height: "100%", width: `${pct}%`, background: color, borderRadius: 4, transition: "width 0.3s" } }) })
225
+ ] });
226
+ };
227
+ var Separator = ({ className, style }) => /* @__PURE__ */ jsx(
228
+ "hr",
229
+ {
230
+ className,
231
+ style: { border: "none", borderTop: "1px solid #e2e8f0", margin: "16px 0", ...style }
232
+ }
233
+ );
234
+ export {
235
+ Alert,
236
+ Badge,
237
+ EmptyState,
238
+ Field,
239
+ Heading,
240
+ Icon,
241
+ Image,
242
+ Markdown,
243
+ Progress,
244
+ Separator,
245
+ Text
246
+ };
@@ -0,0 +1,35 @@
1
+ import {
2
+ ScopeContext,
3
+ buildLoopScope,
4
+ useScope
5
+ } from "./chunk-HHMWR6NA.mjs";
6
+
7
+ // src/player/atoms/control-flow.tsx
8
+ import { Fragment, jsx } from "react/jsx-runtime";
9
+ var Show = ({ when, fallback, children }) => {
10
+ if (when) return /* @__PURE__ */ jsx(Fragment, { children });
11
+ if (fallback) return /* @__PURE__ */ jsx(Fragment, { children: fallback });
12
+ return null;
13
+ };
14
+ var Each = ({ items, as: asName, keyField, children, renderItem, emptyState, className, style }) => {
15
+ const parentScope = useScope();
16
+ const itemArray = Array.isArray(items) ? items : [];
17
+ const varName = asName ?? "item";
18
+ const keyProp = keyField ?? "id";
19
+ if (itemArray.length === 0) {
20
+ if (emptyState) return /* @__PURE__ */ jsx(Fragment, { children: emptyState });
21
+ return null;
22
+ }
23
+ return /* @__PURE__ */ jsx("div", { className, style, children: itemArray.map((item, index) => {
24
+ const loopScope = buildLoopScope(parentScope, item, index, varName);
25
+ const key = item && typeof item === "object" && keyProp in item ? String(item[keyProp]) : String(index);
26
+ if (typeof renderItem === "function") {
27
+ return /* @__PURE__ */ jsx(ScopeContext.Provider, { value: loopScope, children: renderItem(item, index) }, key);
28
+ }
29
+ return /* @__PURE__ */ jsx(ScopeContext.Provider, { value: loopScope, children }, key);
30
+ }) });
31
+ };
32
+ export {
33
+ Each,
34
+ Show
35
+ };
@@ -0,0 +1,35 @@
1
+ import {
2
+ ScopeContext,
3
+ buildLoopScope,
4
+ useScope
5
+ } from "./chunk-FB3WCZAU.mjs";
6
+
7
+ // src/player/atoms/control-flow.tsx
8
+ import { Fragment, jsx } from "react/jsx-runtime";
9
+ var Show = ({ when, fallback, children }) => {
10
+ if (when) return /* @__PURE__ */ jsx(Fragment, { children });
11
+ if (fallback) return /* @__PURE__ */ jsx(Fragment, { children: fallback });
12
+ return null;
13
+ };
14
+ var Each = ({ items, as: asName, keyField, children, renderItem, emptyState, className, style }) => {
15
+ const parentScope = useScope();
16
+ const itemArray = Array.isArray(items) ? items : [];
17
+ const varName = asName ?? "item";
18
+ const keyProp = keyField ?? "id";
19
+ if (itemArray.length === 0) {
20
+ if (emptyState) return /* @__PURE__ */ jsx(Fragment, { children: emptyState });
21
+ return null;
22
+ }
23
+ return /* @__PURE__ */ jsx("div", { className, style, children: itemArray.map((item, index) => {
24
+ const loopScope = buildLoopScope(parentScope, item, index, varName);
25
+ const key = item && typeof item === "object" && keyProp in item ? String(item[keyProp]) : String(index);
26
+ if (typeof renderItem === "function") {
27
+ return /* @__PURE__ */ jsx(ScopeContext.Provider, { value: loopScope, children: renderItem(item, index) }, key);
28
+ }
29
+ return /* @__PURE__ */ jsx(ScopeContext.Provider, { value: loopScope, children }, key);
30
+ }) });
31
+ };
32
+ export {
33
+ Each,
34
+ Show
35
+ };
@@ -0,0 +1,35 @@
1
+ import {
2
+ ScopeContext,
3
+ buildLoopScope,
4
+ useScope
5
+ } from "./chunk-WV7DVCP6.mjs";
6
+
7
+ // src/player/atoms/control-flow.tsx
8
+ import { Fragment, jsx } from "react/jsx-runtime";
9
+ var Show = ({ when, fallback, children }) => {
10
+ if (when) return /* @__PURE__ */ jsx(Fragment, { children });
11
+ if (fallback) return /* @__PURE__ */ jsx(Fragment, { children: fallback });
12
+ return null;
13
+ };
14
+ var Each = ({ items, as: asName, keyField, children, renderItem, emptyState, className, style }) => {
15
+ const parentScope = useScope();
16
+ const itemArray = Array.isArray(items) ? items : [];
17
+ const varName = asName ?? "item";
18
+ const keyProp = keyField ?? "id";
19
+ if (itemArray.length === 0) {
20
+ if (emptyState) return /* @__PURE__ */ jsx(Fragment, { children: emptyState });
21
+ return null;
22
+ }
23
+ return /* @__PURE__ */ jsx("div", { className, style, children: itemArray.map((item, index) => {
24
+ const loopScope = buildLoopScope(parentScope, item, index, varName);
25
+ const key = item && typeof item === "object" && keyProp in item ? String(item[keyProp]) : String(index);
26
+ if (typeof renderItem === "function") {
27
+ return /* @__PURE__ */ jsx(ScopeContext.Provider, { value: loopScope, children: renderItem(item, index) }, key);
28
+ }
29
+ return /* @__PURE__ */ jsx(ScopeContext.Provider, { value: loopScope, children }, key);
30
+ }) });
31
+ };
32
+ export {
33
+ Each,
34
+ Show
35
+ };
@@ -0,0 +1,97 @@
1
+ // src/player/atoms/data.tsx
2
+ import { useState, useMemo } from "react";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ var Table = ({ data, columns, rows, onRowClick, striped, compact, className, style }) => {
5
+ const items = Array.isArray(data ?? rows) ? data ?? rows : [];
6
+ const cols = Array.isArray(columns) ? columns.map(
7
+ (c) => typeof c === "string" ? { key: c, label: c, header: c } : c
8
+ ) : items.length > 0 ? Object.keys(items[0]).filter((k) => k !== "id" && !k.startsWith("_")).map((k) => ({ key: k, label: k, header: k })) : [];
9
+ const pad = compact ? "4px 8px" : "8px 12px";
10
+ return /* @__PURE__ */ jsx("div", { className, style: { overflow: "auto", ...style }, children: /* @__PURE__ */ jsxs("table", { style: { width: "100%", borderCollapse: "collapse", fontSize: 14 }, children: [
11
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: cols.map((col, i) => /* @__PURE__ */ jsx(
12
+ "th",
13
+ {
14
+ style: {
15
+ textAlign: "left",
16
+ padding: pad,
17
+ fontWeight: 600,
18
+ fontSize: 12,
19
+ color: "#718096",
20
+ borderBottom: "2px solid #e2e8f0",
21
+ textTransform: "uppercase",
22
+ letterSpacing: "0.05em"
23
+ },
24
+ children: String(col.label ?? col.header ?? col.key ?? "")
25
+ },
26
+ String(col.key ?? i)
27
+ )) }) }),
28
+ /* @__PURE__ */ jsxs("tbody", { children: [
29
+ items.map((row, ri) => /* @__PURE__ */ jsx(
30
+ "tr",
31
+ {
32
+ onClick: typeof onRowClick === "function" ? () => onRowClick(row) : void 0,
33
+ style: {
34
+ cursor: typeof onRowClick === "function" ? "pointer" : void 0,
35
+ background: striped && ri % 2 === 1 ? "#f7fafc" : void 0
36
+ },
37
+ children: cols.map((col, ci) => {
38
+ const val = row[col.key];
39
+ return /* @__PURE__ */ jsx(
40
+ "td",
41
+ {
42
+ style: { padding: pad, borderBottom: "1px solid #edf2f7" },
43
+ children: val != null ? String(val) : /* @__PURE__ */ jsx("span", { style: { color: "#cbd5e0" }, children: "\u2014" })
44
+ },
45
+ String(col.key ?? ci)
46
+ );
47
+ })
48
+ },
49
+ String(row.id ?? ri)
50
+ )),
51
+ items.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
52
+ "td",
53
+ {
54
+ colSpan: cols.length,
55
+ style: { padding: "24px 12px", textAlign: "center", color: "#a0aec0", fontStyle: "italic" },
56
+ children: "No data"
57
+ }
58
+ ) }) : null
59
+ ] })
60
+ ] }) });
61
+ };
62
+ var DataGrid = ({ data, columns, onRowClick, searchable, className, style, children }) => {
63
+ const [search, setSearch] = useState("");
64
+ const items = Array.isArray(data) ? data : [];
65
+ const filtered = useMemo(() => {
66
+ if (!search) return items;
67
+ const q = search.toLowerCase();
68
+ return items.filter(
69
+ (item) => Object.values(item).some((v) => v != null && String(v).toLowerCase().includes(q))
70
+ );
71
+ }, [items, search]);
72
+ return /* @__PURE__ */ jsxs("div", { className, style, children: [
73
+ searchable ? /* @__PURE__ */ jsx("div", { style: { marginBottom: 12 }, children: /* @__PURE__ */ jsx(
74
+ "input",
75
+ {
76
+ type: "text",
77
+ placeholder: "Search...",
78
+ value: search,
79
+ onChange: (e) => setSearch(e.target.value),
80
+ style: {
81
+ padding: "6px 12px",
82
+ border: "1px solid #e2e8f0",
83
+ borderRadius: 6,
84
+ fontSize: 14,
85
+ width: "100%",
86
+ boxSizing: "border-box"
87
+ }
88
+ }
89
+ ) }) : null,
90
+ /* @__PURE__ */ jsx(Table, { data: filtered, columns, onRowClick, striped: true }),
91
+ children
92
+ ] });
93
+ };
94
+ export {
95
+ DataGrid,
96
+ Table
97
+ };