@kohryan/moodui 0.0.15 → 0.0.16
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/cli.mjs +28 -1
- package/dist/index.d.mts +26 -3
- package/dist/index.d.ts +26 -3
- package/dist/index.js +229 -34
- package/dist/index.mjs +227 -34
- package/dist/ui/assets/index-C2YFmKz4.js +64 -0
- package/dist/ui/index.html +1 -1
- package/package.json +2 -1
- package/src/ui/main.tsx +746 -225
- package/dist/ui/assets/index-ViFb9uE_.js +0 -58
package/dist/index.js
CHANGED
|
@@ -30,6 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
MOODUI_ICON_NAMES: () => MOODUI_ICON_NAMES,
|
|
34
|
+
MoodUIIcon: () => MoodUIIcon,
|
|
33
35
|
MoodUIPromptPlayground: () => MoodUIPromptPlayground,
|
|
34
36
|
MoodUIRuntime: () => MoodUIRuntime,
|
|
35
37
|
assertMoodUISpec: () => assertMoodUISpec,
|
|
@@ -110,13 +112,19 @@ function validateNode(input, path) {
|
|
|
110
112
|
else if (!isString(props.src)) errors.push(`${path}.props.src must be a string`);
|
|
111
113
|
break;
|
|
112
114
|
}
|
|
115
|
+
case "icon": {
|
|
116
|
+
const props = input.props;
|
|
117
|
+
if (!isObject(props)) errors.push(`${path}.props must be an object`);
|
|
118
|
+
else if (!isString(props.name)) errors.push(`${path}.props.name must be a string`);
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
113
121
|
case "spacer": {
|
|
114
122
|
const props = input.props;
|
|
115
123
|
if (props != null && !isObject(props)) errors.push(`${path}.props must be an object if provided`);
|
|
116
124
|
break;
|
|
117
125
|
}
|
|
118
126
|
default:
|
|
119
|
-
errors.push(`${path}.type must be one of: box | text | button | input | image | spacer`);
|
|
127
|
+
errors.push(`${path}.type must be one of: box | text | button | input | image | icon | spacer`);
|
|
120
128
|
}
|
|
121
129
|
if (errors.length > 0) return { ok: false, errors };
|
|
122
130
|
return { ok: true, value: input };
|
|
@@ -132,9 +140,11 @@ function isString(value) {
|
|
|
132
140
|
function renderReact(specInput, options = {}) {
|
|
133
141
|
const spec = assertMoodUISpec(specInput);
|
|
134
142
|
const componentName = options.componentName ?? "MoodUIScreen";
|
|
135
|
-
const
|
|
143
|
+
const hasIcons = containsIconNode(spec.root);
|
|
144
|
+
const jsx4 = renderNode(spec.root, { indent: 2, onActionProp: "onAction" });
|
|
136
145
|
return [
|
|
137
146
|
'import * as React from "react";',
|
|
147
|
+
hasIcons ? 'import { MoodUIIcon } from "@kohryan/moodui";' : "",
|
|
138
148
|
"",
|
|
139
149
|
"export type MoodUIScreenActionHandler = (actionId: string) => void;",
|
|
140
150
|
"",
|
|
@@ -145,7 +155,7 @@ function renderReact(specInput, options = {}) {
|
|
|
145
155
|
`export function ${componentName}(props: MoodUIScreenProps) {`,
|
|
146
156
|
" const { onAction } = props;",
|
|
147
157
|
" return (",
|
|
148
|
-
|
|
158
|
+
jsx4,
|
|
149
159
|
" );",
|
|
150
160
|
"}",
|
|
151
161
|
""
|
|
@@ -182,6 +192,8 @@ function renderNode(node, ctx) {
|
|
|
182
192
|
return renderSelfClosingElement("input", node, ctx);
|
|
183
193
|
case "image":
|
|
184
194
|
return renderSelfClosingElement("img", node, ctx);
|
|
195
|
+
case "icon":
|
|
196
|
+
return renderSelfClosingElement("MoodUIIcon", node, ctx);
|
|
185
197
|
case "spacer": {
|
|
186
198
|
const size = node.props?.size ?? 8;
|
|
187
199
|
const style = { width: normalizeCssValue(size), height: normalizeCssValue(size) };
|
|
@@ -228,6 +240,12 @@ function buildProps(tag, node, extraProps) {
|
|
|
228
240
|
if (props.alt) out.push(`alt=${serializeJsxAttrValue(props.alt)}`);
|
|
229
241
|
if (props.fit) mergedStyle.objectFit = props.fit;
|
|
230
242
|
}
|
|
243
|
+
if (tag === "MoodUIIcon") {
|
|
244
|
+
if (props.name) out.push(`name=${serializeJsxAttrValue(props.name)}`);
|
|
245
|
+
if (props.size != null) out.push(`size={${serializeJsValue(props.size)}}`);
|
|
246
|
+
if (props.color) out.push(`color=${serializeJsxAttrValue(props.color)}`);
|
|
247
|
+
if (props.strokeWidth != null) out.push(`strokeWidth={${serializeJsValue(props.strokeWidth)}}`);
|
|
248
|
+
}
|
|
231
249
|
if (Object.keys(mergedStyle).length > 0) {
|
|
232
250
|
out.push(`style={(${serializeJsValue(mergedStyle)} as React.CSSProperties)}`);
|
|
233
251
|
}
|
|
@@ -357,32 +375,184 @@ function safeObjectKey(key) {
|
|
|
357
375
|
function escapeText(value) {
|
|
358
376
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
359
377
|
}
|
|
378
|
+
function containsIconNode(node) {
|
|
379
|
+
if (node.type === "icon") return true;
|
|
380
|
+
if (node.type !== "box") return false;
|
|
381
|
+
return (node.children ?? []).some((child) => containsIconNode(child));
|
|
382
|
+
}
|
|
360
383
|
function indent(spaces) {
|
|
361
384
|
return " ".repeat(spaces);
|
|
362
385
|
}
|
|
363
386
|
|
|
387
|
+
// src/react/MoodUIIcon.tsx
|
|
388
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
389
|
+
var MOODUI_ICON_NAMES = [
|
|
390
|
+
"sparkles",
|
|
391
|
+
"search",
|
|
392
|
+
"settings",
|
|
393
|
+
"user",
|
|
394
|
+
"mail",
|
|
395
|
+
"heart",
|
|
396
|
+
"home",
|
|
397
|
+
"plus",
|
|
398
|
+
"check",
|
|
399
|
+
"arrow-right",
|
|
400
|
+
"calendar",
|
|
401
|
+
"bell",
|
|
402
|
+
"star",
|
|
403
|
+
"chart-bar",
|
|
404
|
+
"message-circle",
|
|
405
|
+
"shield"
|
|
406
|
+
];
|
|
407
|
+
function MoodUIIcon(props) {
|
|
408
|
+
const {
|
|
409
|
+
name,
|
|
410
|
+
size = 20,
|
|
411
|
+
color,
|
|
412
|
+
strokeWidth = 1.8,
|
|
413
|
+
className,
|
|
414
|
+
style,
|
|
415
|
+
title
|
|
416
|
+
} = props;
|
|
417
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
418
|
+
"span",
|
|
419
|
+
{
|
|
420
|
+
className,
|
|
421
|
+
style: {
|
|
422
|
+
display: "inline-flex",
|
|
423
|
+
alignItems: "center",
|
|
424
|
+
justifyContent: "center",
|
|
425
|
+
width: size,
|
|
426
|
+
height: size,
|
|
427
|
+
color,
|
|
428
|
+
lineHeight: 0,
|
|
429
|
+
flexShrink: 0,
|
|
430
|
+
...style
|
|
431
|
+
},
|
|
432
|
+
"aria-hidden": title ? void 0 : true,
|
|
433
|
+
title,
|
|
434
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
435
|
+
"svg",
|
|
436
|
+
{
|
|
437
|
+
viewBox: "0 0 24 24",
|
|
438
|
+
width: "100%",
|
|
439
|
+
height: "100%",
|
|
440
|
+
fill: "none",
|
|
441
|
+
stroke: "currentColor",
|
|
442
|
+
strokeWidth,
|
|
443
|
+
strokeLinecap: "round",
|
|
444
|
+
strokeLinejoin: "round",
|
|
445
|
+
role: "presentation",
|
|
446
|
+
children: renderIconPath(name)
|
|
447
|
+
}
|
|
448
|
+
)
|
|
449
|
+
}
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
function renderIconPath(name) {
|
|
453
|
+
switch (name) {
|
|
454
|
+
case "sparkles":
|
|
455
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
456
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 3l1.4 3.6L17 8l-3.6 1.4L12 13l-1.4-3.6L7 8l3.6-1.4L12 3z" }),
|
|
457
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 14l.9 2.1L8 17l-2.1.9L5 20l-.9-2.1L2 17l2.1-.9L5 14z" }),
|
|
458
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M19 13l.9 2.1L22 16l-2.1.9L19 19l-.9-2.1L16 16l2.1-.9L19 13z" })
|
|
459
|
+
] });
|
|
460
|
+
case "search":
|
|
461
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
462
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "11", cy: "11", r: "6.5" }),
|
|
463
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M16 16l4 4" })
|
|
464
|
+
] });
|
|
465
|
+
case "settings":
|
|
466
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
467
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "3" }),
|
|
468
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M19.4 15a1 1 0 0 0 .2 1.1l.1.1a2 2 0 0 1-2.8 2.8l-.1-.1a1 1 0 0 0-1.1-.2 1 1 0 0 0-.6.9V20a2 2 0 0 1-4 0v-.1a1 1 0 0 0-.6-.9 1 1 0 0 0-1.1.2l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1 1 0 0 0 .2-1.1 1 1 0 0 0-.9-.6H4a2 2 0 0 1 0-4h.1a1 1 0 0 0 .9-.6 1 1 0 0 0-.2-1.1l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1 1 0 0 0 1.1.2 1 1 0 0 0 .6-.9V4a2 2 0 0 1 4 0v.1a1 1 0 0 0 .6.9 1 1 0 0 0 1.1-.2l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1 1 0 0 0-.2 1.1 1 1 0 0 0 .9.6H20a2 2 0 0 1 0 4h-.1a1 1 0 0 0-.9.6z" })
|
|
469
|
+
] });
|
|
470
|
+
case "user":
|
|
471
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
472
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "8", r: "3.5" }),
|
|
473
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 19a7 7 0 0 1 14 0" })
|
|
474
|
+
] });
|
|
475
|
+
case "mail":
|
|
476
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
477
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "3", y: "5", width: "18", height: "14", rx: "2.5" }),
|
|
478
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 7l8 6 8-6" })
|
|
479
|
+
] });
|
|
480
|
+
case "heart":
|
|
481
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 20s-7-4.4-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.6-7 10-7 10z" });
|
|
482
|
+
case "home":
|
|
483
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
484
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 10.5L12 3l9 7.5" }),
|
|
485
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 9.8V20h14V9.8" }),
|
|
486
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10 20v-5h4v5" })
|
|
487
|
+
] });
|
|
488
|
+
case "plus":
|
|
489
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
490
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 5v14" }),
|
|
491
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 12h14" })
|
|
492
|
+
] });
|
|
493
|
+
case "check":
|
|
494
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 12.5l4.2 4.2L19 7.5" });
|
|
495
|
+
case "arrow-right":
|
|
496
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
497
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 12h14" }),
|
|
498
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M13 6l6 6-6 6" })
|
|
499
|
+
] });
|
|
500
|
+
case "calendar":
|
|
501
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
502
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "3", y: "5", width: "18", height: "16", rx: "2.5" }),
|
|
503
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8 3v4" }),
|
|
504
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M16 3v4" }),
|
|
505
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 10h18" })
|
|
506
|
+
] });
|
|
507
|
+
case "bell":
|
|
508
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
509
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M15 18H5.8a1 1 0 0 1-.8-1.6l1-1.4V11a6 6 0 1 1 12 0v4l1 1.4a1 1 0 0 1-.8 1.6H15" }),
|
|
510
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10 20a2 2 0 0 0 4 0" })
|
|
511
|
+
] });
|
|
512
|
+
case "star":
|
|
513
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 3l2.8 5.7L21 9.6l-4.5 4.3 1 6.1L12 17l-5.5 3 1-6.1L3 9.6l6.2-.9L12 3z" });
|
|
514
|
+
case "chart-bar":
|
|
515
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
516
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 20V10" }),
|
|
517
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10 20V4" }),
|
|
518
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M16 20v-7" }),
|
|
519
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M22 20V8" })
|
|
520
|
+
] });
|
|
521
|
+
case "message-circle":
|
|
522
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
523
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M20 11.5a7.5 7.5 0 1 1-3-6" }),
|
|
524
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M20 4v5h-5" })
|
|
525
|
+
] });
|
|
526
|
+
case "shield":
|
|
527
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
528
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 3l7 3v5c0 5-2.7 8.6-7 10-4.3-1.4-7-5-7-10V6l7-3z" }),
|
|
529
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M9.5 12.5l1.8 1.8 3.7-4.3" })
|
|
530
|
+
] });
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
364
534
|
// src/react/MoodUIRuntime.tsx
|
|
365
535
|
var React = __toESM(require("react"));
|
|
366
|
-
var
|
|
536
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
367
537
|
function MoodUIRuntime(props) {
|
|
368
|
-
return /* @__PURE__ */ (0,
|
|
538
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: renderNode2(props.spec.root, props.onAction) });
|
|
369
539
|
}
|
|
370
540
|
function renderNode2(node, onAction) {
|
|
371
541
|
switch (node.type) {
|
|
372
542
|
case "box": {
|
|
373
543
|
const style = computeStyle2(node);
|
|
374
|
-
const children = node.children?.map((c, i) => /* @__PURE__ */ (0,
|
|
375
|
-
return /* @__PURE__ */ (0,
|
|
544
|
+
const children = node.children?.map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(React.Fragment, { children: renderNode2(c, onAction) }, i));
|
|
545
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ...commonAttrs(node), style, children });
|
|
376
546
|
}
|
|
377
547
|
case "text": {
|
|
378
548
|
const Tag = node.props?.as ?? "p";
|
|
379
549
|
const style = computeStyle2(node);
|
|
380
|
-
return /* @__PURE__ */ (0,
|
|
550
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Tag, { ...commonAttrs(node), style, children: node.props?.value ?? "" });
|
|
381
551
|
}
|
|
382
552
|
case "button": {
|
|
383
553
|
const style = computeStyle2(node);
|
|
384
554
|
const actionId = node.props?.actionId;
|
|
385
|
-
return /* @__PURE__ */ (0,
|
|
555
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
386
556
|
"button",
|
|
387
557
|
{
|
|
388
558
|
...commonAttrs(node),
|
|
@@ -395,7 +565,7 @@ function renderNode2(node, onAction) {
|
|
|
395
565
|
}
|
|
396
566
|
case "input": {
|
|
397
567
|
const style = computeStyle2(node);
|
|
398
|
-
return /* @__PURE__ */ (0,
|
|
568
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
399
569
|
"input",
|
|
400
570
|
{
|
|
401
571
|
...commonAttrs(node),
|
|
@@ -408,11 +578,25 @@ function renderNode2(node, onAction) {
|
|
|
408
578
|
}
|
|
409
579
|
case "image": {
|
|
410
580
|
const style = computeStyle2(node);
|
|
411
|
-
return /* @__PURE__ */ (0,
|
|
581
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("img", { ...commonAttrs(node), style, src: node.props?.src, alt: node.props?.alt ?? "" });
|
|
582
|
+
}
|
|
583
|
+
case "icon": {
|
|
584
|
+
const style = computeStyle2(node);
|
|
585
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
586
|
+
MoodUIIcon,
|
|
587
|
+
{
|
|
588
|
+
...commonAttrs(node),
|
|
589
|
+
style,
|
|
590
|
+
name: node.props?.name,
|
|
591
|
+
size: node.props?.size,
|
|
592
|
+
color: node.props?.color,
|
|
593
|
+
strokeWidth: node.props?.strokeWidth
|
|
594
|
+
}
|
|
595
|
+
);
|
|
412
596
|
}
|
|
413
597
|
case "spacer": {
|
|
414
598
|
const size = node.props?.size ?? 8;
|
|
415
|
-
return /* @__PURE__ */ (0,
|
|
599
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { width: size, height: size } });
|
|
416
600
|
}
|
|
417
601
|
}
|
|
418
602
|
}
|
|
@@ -484,6 +668,9 @@ function computeStyle2(node) {
|
|
|
484
668
|
const fit = node.props?.fit;
|
|
485
669
|
if (fit != null) style.objectFit = fit;
|
|
486
670
|
}
|
|
671
|
+
if (node.type === "icon") {
|
|
672
|
+
if (typeof props.color === "string") style.color = props.color;
|
|
673
|
+
}
|
|
487
674
|
if (props.style && typeof props.style === "object" && !Array.isArray(props.style)) {
|
|
488
675
|
Object.assign(style, props.style);
|
|
489
676
|
}
|
|
@@ -581,14 +768,20 @@ function buildSystemPrompt() {
|
|
|
581
768
|
"- button: { type:'button', props: { label: string, variant?, actionId?, disabled?, ...common } }",
|
|
582
769
|
"- input: { type:'input', props?: { name?, placeholder?, defaultValue?, ...common } }",
|
|
583
770
|
"- image: { type:'image', props: { src: string, alt?, fit?, ...common } }",
|
|
771
|
+
"- icon: { type:'icon', props: { name, size?, color?, strokeWidth?, ...common } }",
|
|
584
772
|
"- spacer: { type:'spacer', props?: { size? } }",
|
|
585
773
|
"",
|
|
586
774
|
"common props:",
|
|
587
775
|
"- id, testId, className, style(object), padding, margin, background, borderRadius, width, height",
|
|
588
776
|
"",
|
|
777
|
+
"Reusable icon names:",
|
|
778
|
+
"- sparkles, search, settings, user, mail, heart, home, plus, check, arrow-right, calendar, bell, star, chart-bar, message-circle, shield",
|
|
779
|
+
"",
|
|
589
780
|
"Rules:",
|
|
590
781
|
"- root wajib ada",
|
|
591
782
|
"- minimal pakai box sebagai container utama",
|
|
783
|
+
"- gunakan icon node bila UI membutuhkan icon navigasi, status, statistik, CTA, atau dekorasi ringan",
|
|
784
|
+
"- utamakan layout modern: card, section, spacing konsisten, hierarchy yang jelas",
|
|
592
785
|
"- semua string pakai double quotes (JSON standard)",
|
|
593
786
|
"- jangan pakai function / JS expression apa pun"
|
|
594
787
|
].join("\n");
|
|
@@ -767,7 +960,7 @@ async function generateReactFromPrompt(options) {
|
|
|
767
960
|
}
|
|
768
961
|
|
|
769
962
|
// src/react/MoodUIPromptPlayground.tsx
|
|
770
|
-
var
|
|
963
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
771
964
|
function MoodUIPromptPlayground(props) {
|
|
772
965
|
const provider = props.provider ?? "gemini";
|
|
773
966
|
const [model, setModel] = React2.useState(props.model ?? "gemini-3-flash-preview");
|
|
@@ -858,11 +1051,11 @@ function MoodUIPromptPlayground(props) {
|
|
|
858
1051
|
}
|
|
859
1052
|
}
|
|
860
1053
|
}, [code, componentName]);
|
|
861
|
-
return /* @__PURE__ */ (0,
|
|
862
|
-
/* @__PURE__ */ (0,
|
|
863
|
-
/* @__PURE__ */ (0,
|
|
864
|
-
/* @__PURE__ */ (0,
|
|
865
|
-
/* @__PURE__ */ (0,
|
|
1054
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 16 }, children: [
|
|
1055
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 12 }, children: [
|
|
1056
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontWeight: 700, fontSize: 16 }, children: "MoodUI Prompt" }),
|
|
1057
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", gap: 8, flexWrap: "wrap" }, children: [
|
|
1058
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
866
1059
|
"input",
|
|
867
1060
|
{
|
|
868
1061
|
value: provider,
|
|
@@ -876,7 +1069,7 @@ function MoodUIPromptPlayground(props) {
|
|
|
876
1069
|
}
|
|
877
1070
|
}
|
|
878
1071
|
),
|
|
879
|
-
/* @__PURE__ */ (0,
|
|
1072
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
880
1073
|
"input",
|
|
881
1074
|
{
|
|
882
1075
|
value: model,
|
|
@@ -886,7 +1079,7 @@ function MoodUIPromptPlayground(props) {
|
|
|
886
1079
|
}
|
|
887
1080
|
)
|
|
888
1081
|
] }),
|
|
889
|
-
provider !== "ollama" ? /* @__PURE__ */ (0,
|
|
1082
|
+
provider !== "ollama" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
890
1083
|
"input",
|
|
891
1084
|
{
|
|
892
1085
|
value: apiKey,
|
|
@@ -896,7 +1089,7 @@ function MoodUIPromptPlayground(props) {
|
|
|
896
1089
|
style: { padding: "10px 12px", borderRadius: 10, border: "1px solid #d1d5db" }
|
|
897
1090
|
}
|
|
898
1091
|
) : null,
|
|
899
|
-
/* @__PURE__ */ (0,
|
|
1092
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
900
1093
|
"input",
|
|
901
1094
|
{
|
|
902
1095
|
value: baseUrl,
|
|
@@ -905,7 +1098,7 @@ function MoodUIPromptPlayground(props) {
|
|
|
905
1098
|
style: { padding: "10px 12px", borderRadius: 10, border: "1px solid #d1d5db" }
|
|
906
1099
|
}
|
|
907
1100
|
),
|
|
908
|
-
/* @__PURE__ */ (0,
|
|
1101
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
909
1102
|
"textarea",
|
|
910
1103
|
{
|
|
911
1104
|
value: prompt,
|
|
@@ -920,7 +1113,7 @@ function MoodUIPromptPlayground(props) {
|
|
|
920
1113
|
}
|
|
921
1114
|
}
|
|
922
1115
|
),
|
|
923
|
-
/* @__PURE__ */ (0,
|
|
1116
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
924
1117
|
"button",
|
|
925
1118
|
{
|
|
926
1119
|
type: "button",
|
|
@@ -937,7 +1130,7 @@ function MoodUIPromptPlayground(props) {
|
|
|
937
1130
|
children: loading ? "Generating..." : "Generate"
|
|
938
1131
|
}
|
|
939
1132
|
),
|
|
940
|
-
error ? /* @__PURE__ */ (0,
|
|
1133
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
941
1134
|
"pre",
|
|
942
1135
|
{
|
|
943
1136
|
style: {
|
|
@@ -953,13 +1146,13 @@ function MoodUIPromptPlayground(props) {
|
|
|
953
1146
|
}
|
|
954
1147
|
) : null
|
|
955
1148
|
] }),
|
|
956
|
-
/* @__PURE__ */ (0,
|
|
957
|
-
/* @__PURE__ */ (0,
|
|
958
|
-
/* @__PURE__ */ (0,
|
|
959
|
-
/* @__PURE__ */ (0,
|
|
960
|
-
/* @__PURE__ */ (0,
|
|
961
|
-
/* @__PURE__ */ (0,
|
|
962
|
-
/* @__PURE__ */ (0,
|
|
1149
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 12 }, children: [
|
|
1150
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontWeight: 700, fontSize: 16 }, children: "Preview" }),
|
|
1151
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { minHeight: 240, padding: 16, borderRadius: 16, background: "#ffffff", border: "1px solid #e5e7eb" }, children: spec ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MoodUIRuntime, { spec }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { color: "#6b7280" }, children: "Belum ada hasil" }) }),
|
|
1152
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
1153
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontWeight: 700, fontSize: 16 }, children: "React Code" }),
|
|
1154
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", gap: 8 }, children: [
|
|
1155
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
963
1156
|
"button",
|
|
964
1157
|
{
|
|
965
1158
|
type: "button",
|
|
@@ -977,7 +1170,7 @@ function MoodUIPromptPlayground(props) {
|
|
|
977
1170
|
children: copied ? "Copied!" : "Copy"
|
|
978
1171
|
}
|
|
979
1172
|
),
|
|
980
|
-
/* @__PURE__ */ (0,
|
|
1173
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
981
1174
|
"button",
|
|
982
1175
|
{
|
|
983
1176
|
type: "button",
|
|
@@ -995,7 +1188,7 @@ function MoodUIPromptPlayground(props) {
|
|
|
995
1188
|
children: "Save to File"
|
|
996
1189
|
}
|
|
997
1190
|
),
|
|
998
|
-
/* @__PURE__ */ (0,
|
|
1191
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
999
1192
|
"button",
|
|
1000
1193
|
{
|
|
1001
1194
|
type: "button",
|
|
@@ -1015,7 +1208,7 @@ function MoodUIPromptPlayground(props) {
|
|
|
1015
1208
|
)
|
|
1016
1209
|
] })
|
|
1017
1210
|
] }),
|
|
1018
|
-
/* @__PURE__ */ (0,
|
|
1211
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1019
1212
|
"textarea",
|
|
1020
1213
|
{
|
|
1021
1214
|
value: code,
|
|
@@ -1035,6 +1228,8 @@ function MoodUIPromptPlayground(props) {
|
|
|
1035
1228
|
}
|
|
1036
1229
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1037
1230
|
0 && (module.exports = {
|
|
1231
|
+
MOODUI_ICON_NAMES,
|
|
1232
|
+
MoodUIIcon,
|
|
1038
1233
|
MoodUIPromptPlayground,
|
|
1039
1234
|
MoodUIRuntime,
|
|
1040
1235
|
assertMoodUISpec,
|