@seedgrid/fe-components 2026.3.13 → 2026.3.17

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.
@@ -1,1461 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import * as React from "react";
4
- import { SandpackCodeEditor, SandpackPreview, SandpackProvider, useSandpack } from "@codesandbox/sandpack-react";
5
- import { SgButton } from "../buttons/SgButton";
6
- import { SgCard } from "../layout/SgCard";
7
- function cn(...parts) {
8
- return parts.filter(Boolean).join(" ");
9
- }
10
- const DEFAULT_SEEDGRID_DEPENDENCY = "latest";
11
- const DEFAULT_SANDPACK_BUNDLER_URL = "https://sandpack.seedgrid.com.br";
12
- const DEFAULT_SANDPACK_BUNDLER_TIMEOUT_MS = 60000;
13
- const DEFAULT_SANDBOX_BASE_DEPENDENCIES = {
14
- react: "18.2.0",
15
- "react-dom": "18.2.0"
16
- };
17
- const DEFAULT_SEEDGRID_RUNTIME_DEPENDENCIES = {
18
- "react-hook-form": "^7.0.0"
19
- };
20
- // lucide-react is a heavy peer dep (~1400 icons). For non-full presets we shim it with
21
- // a generic SVG placeholder to avoid OOM in the browser bundler.
22
- const SANDPACK_LUCIDE_REACT_SHIM_INDEX_JS = `const React = require("react");
23
- const Icon = function(props) {
24
- return React.createElement("svg", {
25
- xmlns: "http://www.w3.org/2000/svg",
26
- width: props.size || props.width || 16,
27
- height: props.size || props.height || 16,
28
- viewBox: "0 0 24 24",
29
- fill: "none",
30
- stroke: props.color || "currentColor",
31
- strokeWidth: props.strokeWidth || 2,
32
- className: props.className
33
- });
34
- };
35
- const proxy = new Proxy({}, {
36
- get: function(_, key) {
37
- if (key === "__esModule") return true;
38
- return Icon;
39
- }
40
- });
41
- module.exports = proxy;
42
- `;
43
- const DEFAULT_SEEDGRID_EDITOR_DEPENDENCIES = {
44
- "@tiptap/core": "^2.9.1",
45
- "@tiptap/react": "^2.9.1",
46
- "@tiptap/pm": "^2.9.1",
47
- "@tiptap/starter-kit": "^2.9.1",
48
- "@tiptap/extension-underline": "^2.9.1",
49
- "@tiptap/extension-link": "^2.9.1",
50
- "@tiptap/extension-image": "^2.9.1",
51
- "@tiptap/extension-text-align": "^2.9.1",
52
- "@tiptap/extension-text-style": "^2.9.1",
53
- "@tiptap/extension-color": "^2.9.1",
54
- "@tiptap/extension-highlight": "^2.9.1",
55
- "@tiptap/extension-subscript": "^2.9.1",
56
- "@tiptap/extension-superscript": "^2.9.1",
57
- "@tiptap/extension-font-family": "^2.9.1"
58
- };
59
- const DEFAULT_SANDBOX_HOST_DEPENDENCIES = {
60
- "@codesandbox/sandpack-react": "^2.20.0"
61
- };
62
- // Keep this empty: editor runtime uses in-memory shims under /node_modules/*
63
- // for assert/path/process/util/fs and node:* aliases.
64
- // Installing npm polyfill packages here pulls deep transitive trees and may
65
- // explode resolution inside Sandpack (e.g. dunder-proto/get, get-proto, etc).
66
- const DEFAULT_SANDPACK_POLYFILLS = {};
67
- const TIPTAP_SHIM_PACKAGES = [
68
- "@tiptap/core",
69
- "@tiptap/pm",
70
- "@tiptap/starter-kit",
71
- "@tiptap/extension-underline",
72
- "@tiptap/extension-link",
73
- "@tiptap/extension-image",
74
- "@tiptap/extension-text-align",
75
- "@tiptap/extension-text-style",
76
- "@tiptap/extension-color",
77
- "@tiptap/extension-highlight",
78
- "@tiptap/extension-subscript",
79
- "@tiptap/extension-superscript",
80
- "@tiptap/extension-font-family"
81
- ];
82
- const SANDPACK_EXTERNAL_RESOURCES = [];
83
- const SANDPACK_QRCODE_SHIM_INDEX_JS = `const makeError = () =>
84
- new Error(
85
- "qrcode (node build) is not supported in Sandpack browser runtime. Update @seedgrid/fe-components to a browser-safe QR implementation."
86
- );
87
-
88
- const qrcodeShim = {
89
- toDataURL() {
90
- return Promise.reject(makeError());
91
- }
92
- };
93
-
94
- export const toDataURL = (...args) => qrcodeShim.toDataURL(...args);
95
- export default qrcodeShim;
96
- `;
97
- const SANDPACK_MARKDOWN_IT_BIN_SHIM = `import markdownit from "../index.mjs";
98
-
99
- // Browser-safe shim: Sandpack must not execute markdown-it CLI entrypoint.
100
- // Re-export parser factory so accidental imports of the bin path remain harmless.
101
- export default markdownit;
102
- export { markdownit };
103
- `;
104
- const SANDPACK_MARKDOWN_IT_PACKAGE_JSON_SHIM = JSON.stringify({
105
- name: "markdown-it",
106
- version: "14.1.1-shim",
107
- main: "dist/index.cjs.js",
108
- module: "index.mjs",
109
- exports: {
110
- ".": {
111
- import: "./index.mjs",
112
- require: "./dist/index.cjs.js"
113
- },
114
- "./*": {
115
- import: "./*",
116
- require: "./*"
117
- }
118
- },
119
- // Sandpack can accidentally prioritize `bin`; force it to a browser-safe module.
120
- bin: {
121
- "markdown-it": "dist/index.cjs.js"
122
- }
123
- });
124
- const SANDPACK_SANDBOX_SANDPACK_REACT_SHIM_INDEX_JS = `export const SandpackProvider = ({ children }) => children ?? null;
125
- export const SandpackCodeEditor = () => null;
126
- export const SandpackPreview = () => null;
127
- export const useSandpack = () => ({
128
- sandpack: {
129
- activeFile: "/App.tsx",
130
- files: { "/App.tsx": { code: "" } },
131
- runSandpack: async () => {},
132
- clients: {},
133
- status: "idle"
134
- },
135
- dispatch: () => {},
136
- listen: () => () => {}
137
- });
138
- export default {};
139
- `;
140
- const SANDPACK_TIPTAP_REACT_SHIM_INDEX_JS = `export const EditorContent = () => null;
141
- export const BubbleMenu = () => null;
142
- export const FloatingMenu = () => null;
143
- export const useEditor = () => null;
144
- export default {};
145
- `;
146
- const SANDPACK_TIPTAP_EXTENSION_SHIM_INDEX_JS = `const extension = {
147
- configure() {
148
- return extension;
149
- },
150
- extend() {
151
- return extension;
152
- }
153
- };
154
- export default extension;
155
- `;
156
- const SANDPACK_SEEDGRID_TEXT_EDITOR_SHIM_INDEX_JS = `import * as React from "react";
157
-
158
- export function SgTextEditor() {
159
- return React.createElement(
160
- "div",
161
- {
162
- style: {
163
- padding: "0.75rem",
164
- border: "1px solid #e4e4e7",
165
- borderRadius: "0.5rem",
166
- fontSize: "0.875rem",
167
- color: "#6b7280",
168
- background: "#f9fafb"
169
- }
170
- },
171
- "SgTextEditor is disabled in this sandbox preset."
172
- );
173
- }
174
-
175
- export default SgTextEditor;
176
- `;
177
- const SANDPACK_ASSERT_SHIM_INDEX_JS = `function fail(message) {
178
- throw new Error(message || "Assertion failed");
179
- }
180
-
181
- function assert(value, message) {
182
- if (!value) fail(message);
183
- }
184
-
185
- assert.ok = assert;
186
- assert.equal = function equal(actual, expected, message) {
187
- if (actual != expected) fail(message || "Expected values to be loosely equal");
188
- };
189
- assert.strictEqual = function strictEqual(actual, expected, message) {
190
- if (actual !== expected) fail(message || "Expected values to be strictly equal");
191
- };
192
- assert.notEqual = function notEqual(actual, expected, message) {
193
- if (actual == expected) fail(message || "Expected values to be different");
194
- };
195
- assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
196
- if (actual === expected) fail(message || "Expected values to be different");
197
- };
198
- assert.deepEqual = function deepEqual(actual, expected, message) {
199
- try {
200
- if (JSON.stringify(actual) !== JSON.stringify(expected)) {
201
- fail(message || "Expected values to be deeply equal");
202
- }
203
- } catch (_) {
204
- if (actual !== expected) fail(message || "Expected values to be deeply equal");
205
- }
206
- };
207
- assert.throws = function throwsAssertion(fn, message) {
208
- var didThrow = false;
209
- try { fn(); } catch (_) { didThrow = true; }
210
- if (!didThrow) fail(message || "Expected function to throw");
211
- };
212
- assert.fail = fail;
213
-
214
- module.exports = assert;
215
- module.exports.default = assert;
216
- `;
217
- const SANDPACK_UTIL_SHIM_INDEX_JS = `const inspect = function inspect(value) {
218
- try {
219
- return JSON.stringify(value);
220
- } catch (_) {
221
- return String(value);
222
- }
223
- };
224
-
225
- inspect.custom = typeof Symbol !== "undefined" && Symbol.for
226
- ? Symbol.for("nodejs.util.inspect.custom")
227
- : "@@nodejs.util.inspect.custom";
228
-
229
- function deprecate(fn, message) {
230
- var warned = false;
231
- return function deprecatedWrapper() {
232
- if (!warned && typeof console !== "undefined" && typeof console.warn === "function") {
233
- console.warn(message);
234
- warned = true;
235
- }
236
- return fn.apply(this, arguments);
237
- };
238
- }
239
-
240
- function format() {
241
- return Array.prototype.map.call(arguments, function (item) {
242
- return String(item);
243
- }).join(" ");
244
- }
245
-
246
- const utilShim = { inspect, deprecate, format };
247
- module.exports = utilShim;
248
- module.exports.default = utilShim;
249
- `;
250
- const SANDPACK_PATH_SHIM_INDEX_JS = `function normalize(input) {
251
- return String(input || "").replace(/\\\\/g, "/");
252
- }
253
-
254
- function basename(input) {
255
- var text = normalize(input);
256
- var pieces = text.split("/").filter(Boolean);
257
- return pieces.length ? pieces[pieces.length - 1] : "";
258
- }
259
-
260
- function dirname(input) {
261
- var text = normalize(input);
262
- var index = text.lastIndexOf("/");
263
- if (index <= 0) return ".";
264
- return text.slice(0, index);
265
- }
266
-
267
- function join() {
268
- return Array.prototype
269
- .map.call(arguments, normalize)
270
- .filter(Boolean)
271
- .join("/")
272
- .replace(/\\/{2,}/g, "/");
273
- }
274
-
275
- function resolve() {
276
- return join.apply(null, arguments);
277
- }
278
-
279
- const pathShim = {
280
- sep: "/",
281
- delimiter: ":",
282
- basename,
283
- dirname,
284
- join,
285
- resolve,
286
- normalize
287
- };
288
-
289
- module.exports = pathShim;
290
- module.exports.default = pathShim;
291
- `;
292
- const SANDPACK_FS_SHIM_INDEX_JS = `function notSupported(name) {
293
- throw new Error("fs." + name + " is not supported in Sandpack browser runtime.");
294
- }
295
-
296
- const fsShim = {
297
- openSync: function openSync() { return notSupported("openSync"); },
298
- createReadStream: function createReadStream() { return notSupported("createReadStream"); },
299
- createWriteStream: function createWriteStream() { return notSupported("createWriteStream"); },
300
- readFileSync: function readFileSync() { return notSupported("readFileSync"); }
301
- };
302
-
303
- module.exports = fsShim;
304
- module.exports.default = fsShim;
305
- `;
306
- const SANDPACK_PROCESS_SHIM_INDEX_JS = `const processShim = {
307
- env: {},
308
- argv: ["browser"],
309
- stdout: { columns: 80 },
310
- stderr: { columns: 80 },
311
- cwd: function cwd() { return "/"; },
312
- nextTick: function nextTick(fn) {
313
- var args = Array.prototype.slice.call(arguments, 1);
314
- return Promise.resolve().then(function () { return fn.apply(null, args); });
315
- }
316
- };
317
-
318
- if (typeof globalThis !== "undefined" && !globalThis.process) {
319
- globalThis.process = processShim;
320
- }
321
-
322
- module.exports = processShim;
323
- module.exports.default = processShim;
324
- `;
325
- const SANDPACK_NODE_ASSERT_ALIAS_SHIM_INDEX_JS = `const assertShim = require("assert");
326
- module.exports = assertShim;
327
- module.exports.default = assertShim;
328
- `;
329
- const SANDPACK_NODE_UTIL_ALIAS_SHIM_INDEX_JS = `const utilShim = require("util");
330
- module.exports = utilShim;
331
- module.exports.default = utilShim;
332
- `;
333
- const SANDPACK_NODE_PATH_ALIAS_SHIM_INDEX_JS = `const pathShim = require("path");
334
- module.exports = pathShim;
335
- module.exports.default = pathShim;
336
- `;
337
- const SANDPACK_NODE_FS_ALIAS_SHIM_INDEX_JS = `const fsShim = require("fs");
338
- module.exports = fsShim;
339
- module.exports.default = fsShim;
340
- `;
341
- const SANDPACK_NODE_PROCESS_ALIAS_SHIM_INDEX_JS = `const processShim = require("process");
342
- module.exports = processShim;
343
- module.exports.default = processShim;
344
- `;
345
- const SANDPACK_NODE_FS_PROMISES_ALIAS_SHIM_INDEX_JS = `const fsShim = require("fs");
346
- module.exports = fsShim.promises || {};
347
- module.exports.default = module.exports;
348
- `;
349
- const SANDPACK_NODE_ASSERT_PACKAGE_JSON_SHIM = JSON.stringify({
350
- name: "node:assert",
351
- version: "0.0.0-shim",
352
- main: "index.js",
353
- module: "index.js"
354
- });
355
- const SANDPACK_NODE_UTIL_PACKAGE_JSON_SHIM = JSON.stringify({
356
- name: "node:util",
357
- version: "0.0.0-shim",
358
- main: "index.js",
359
- module: "index.js"
360
- });
361
- const SANDPACK_NODE_PATH_PACKAGE_JSON_SHIM = JSON.stringify({
362
- name: "node:path",
363
- version: "0.0.0-shim",
364
- main: "index.js",
365
- module: "index.js"
366
- });
367
- const SANDPACK_NODE_FS_PACKAGE_JSON_SHIM = JSON.stringify({
368
- name: "node:fs",
369
- version: "0.0.0-shim",
370
- main: "index.js",
371
- module: "index.js"
372
- });
373
- const SANDPACK_NODE_PROCESS_PACKAGE_JSON_SHIM = JSON.stringify({
374
- name: "node:process",
375
- version: "0.0.0-shim",
376
- main: "index.js",
377
- module: "index.js"
378
- });
379
- const SANDPACK_NODE_FS_PROMISES_PACKAGE_JSON_SHIM = JSON.stringify({
380
- name: "node:fs/promises",
381
- version: "0.0.0-shim",
382
- main: "index.js",
383
- module: "index.js"
384
- });
385
- const SANDPACK_FALLBACK_THEME_VARS = {
386
- "--sg-mode": "light",
387
- // shadcn/ui design tokens (HSL)
388
- "--background": "0 0% 100%",
389
- "--foreground": "222.2 84% 4.9%",
390
- "--primary": "142 76% 36%",
391
- "--primary-foreground": "0 0% 100%",
392
- "--secondary": "210 40% 96.1%",
393
- "--secondary-foreground": "222.2 47.4% 11.2%",
394
- "--accent": "152 57% 40%",
395
- "--accent-foreground": "0 0% 100%",
396
- "--destructive": "0 84.2% 60.2%",
397
- "--destructive-foreground": "0 0% 100%",
398
- "--border": "214.3 31.8% 91.4%",
399
- "--input": "214.3 31.8% 91.4%",
400
- "--ring": "142 76% 36%",
401
- "--muted": "210 40% 96.1%",
402
- "--muted-foreground": "215.4 16.3% 46.9%",
403
- "--card": "0 0% 100%",
404
- "--card-foreground": "222.2 84% 4.9%",
405
- "--popover": "0 0% 100%",
406
- "--popover-foreground": "222.2 84% 4.9%",
407
- "--radius": "0.5rem",
408
- // SeedGrid neutrals (RGB space-separated)
409
- "--sg-bg": "255 255 255",
410
- "--sg-surface": "248 250 252",
411
- "--sg-muted-surface": "241 245 249",
412
- "--sg-text": "15 23 42",
413
- "--sg-muted": "100 116 139",
414
- "--sg-border": "226 232 240",
415
- "--sg-ring": "74 222 128",
416
- "--sg-disabled": "203 213 225",
417
- "--sg-on-disabled": "148 163 184",
418
- "--sg-link": "22 163 74",
419
- "--sg-link-hover": "21 128 61",
420
- "--sg-radius": "0.5rem",
421
- // On-color tokens
422
- "--sg-on-primary": "255 255 255",
423
- "--sg-on-secondary": "255 255 255",
424
- "--sg-on-tertiary": "255 255 255",
425
- "--sg-on-warning": "255 255 255",
426
- "--sg-on-error": "255 255 255",
427
- "--sg-on-info": "255 255 255",
428
- "--sg-on-success": "255 255 255",
429
- // Primary palette (green)
430
- "--sg-primary-50": "240 253 244",
431
- "--sg-primary-100": "220 252 231",
432
- "--sg-primary-200": "187 247 208",
433
- "--sg-primary-300": "134 239 172",
434
- "--sg-primary-400": "74 222 128",
435
- "--sg-primary-500": "34 197 94",
436
- "--sg-primary-600": "22 163 74",
437
- "--sg-primary-700": "21 128 61",
438
- "--sg-primary-800": "22 101 52",
439
- "--sg-primary-900": "20 83 45",
440
- "--sg-primary-hover": "21 128 61",
441
- "--sg-primary-active": "22 101 52",
442
- // Secondary palette (zinc)
443
- "--sg-secondary-50": "250 250 250",
444
- "--sg-secondary-100": "244 244 245",
445
- "--sg-secondary-200": "228 228 231",
446
- "--sg-secondary-300": "212 212 216",
447
- "--sg-secondary-400": "161 161 170",
448
- "--sg-secondary-500": "113 113 122",
449
- "--sg-secondary-600": "82 82 91",
450
- "--sg-secondary-700": "63 63 70",
451
- "--sg-secondary-800": "39 39 42",
452
- "--sg-secondary-900": "24 24 27",
453
- "--sg-secondary-hover": "63 63 70",
454
- "--sg-secondary-active": "39 39 42",
455
- // Tertiary palette (teal)
456
- "--sg-tertiary-50": "240 253 250",
457
- "--sg-tertiary-100": "204 251 241",
458
- "--sg-tertiary-200": "153 246 228",
459
- "--sg-tertiary-300": "94 234 212",
460
- "--sg-tertiary-400": "45 212 191",
461
- "--sg-tertiary-500": "20 184 166",
462
- "--sg-tertiary-600": "13 148 136",
463
- "--sg-tertiary-700": "15 118 110",
464
- "--sg-tertiary-800": "17 94 89",
465
- "--sg-tertiary-900": "19 78 74",
466
- "--sg-tertiary-hover": "15 118 110",
467
- "--sg-tertiary-active": "17 94 89",
468
- // Warning palette (amber)
469
- "--sg-warning-50": "255 251 235",
470
- "--sg-warning-100": "254 243 199",
471
- "--sg-warning-200": "253 230 138",
472
- "--sg-warning-300": "252 211 77",
473
- "--sg-warning-400": "251 191 36",
474
- "--sg-warning-500": "245 158 11",
475
- "--sg-warning-600": "217 119 6",
476
- "--sg-warning-700": "180 83 9",
477
- "--sg-warning-800": "146 64 14",
478
- "--sg-warning-900": "120 53 15",
479
- "--sg-warning-hover": "180 83 9",
480
- "--sg-warning-active": "146 64 14",
481
- // Error palette (red)
482
- "--sg-error-50": "254 242 242",
483
- "--sg-error-100": "254 226 226",
484
- "--sg-error-200": "254 202 202",
485
- "--sg-error-300": "252 165 165",
486
- "--sg-error-400": "248 113 113",
487
- "--sg-error-500": "239 68 68",
488
- "--sg-error-600": "220 38 38",
489
- "--sg-error-700": "185 28 28",
490
- "--sg-error-800": "153 27 27",
491
- "--sg-error-900": "127 29 29",
492
- "--sg-error-hover": "185 28 28",
493
- "--sg-error-active": "153 27 27",
494
- // Info palette (sky)
495
- "--sg-info-50": "240 249 255",
496
- "--sg-info-100": "224 242 254",
497
- "--sg-info-200": "186 230 253",
498
- "--sg-info-300": "125 211 252",
499
- "--sg-info-400": "56 189 248",
500
- "--sg-info-500": "14 165 233",
501
- "--sg-info-600": "2 132 199",
502
- "--sg-info-700": "3 105 161",
503
- "--sg-info-800": "7 89 133",
504
- "--sg-info-900": "12 74 110",
505
- "--sg-info-hover": "3 105 161",
506
- "--sg-info-active": "7 89 133",
507
- // Success palette (green, same as primary)
508
- "--sg-success-50": "240 253 244",
509
- "--sg-success-100": "220 252 231",
510
- "--sg-success-200": "187 247 208",
511
- "--sg-success-300": "134 239 172",
512
- "--sg-success-400": "74 222 128",
513
- "--sg-success-500": "34 197 94",
514
- "--sg-success-600": "22 163 74",
515
- "--sg-success-700": "21 128 61",
516
- "--sg-success-800": "22 101 52",
517
- "--sg-success-900": "20 83 45",
518
- "--sg-success-hover": "21 128 61",
519
- "--sg-success-active": "22 101 52",
520
- // Button component vars (green primary default)
521
- "--sg-btn-bg": "rgb(22 163 74)",
522
- "--sg-btn-fg": "rgb(255 255 255)",
523
- "--sg-btn-border": "rgb(22 163 74)",
524
- "--sg-btn-hover-bg": "rgb(21 128 61)",
525
- "--sg-btn-hover-fg": "rgb(255 255 255)",
526
- "--sg-btn-hover-border": "rgb(21 128 61)",
527
- "--sg-btn-active-bg": "rgb(22 101 52)",
528
- "--sg-btn-ring": "rgb(74 222 128 / 0.4)",
529
- "--sg-btn-tint": "22 163 74",
530
- // Avatar component vars
531
- "--sg-avatar-bg": "rgb(22 163 74)",
532
- "--sg-avatar-fg": "rgb(255 255 255)",
533
- "--sg-avatar-border": "transparent",
534
- "--sg-avatar-ring": "rgb(74 222 128)",
535
- // Badge component vars
536
- "--sg-badge-bg": "rgb(240 253 244)",
537
- "--sg-badge-fg": "rgb(22 163 74)",
538
- "--sg-badge-border": "rgb(187 247 208)",
539
- "--sg-badge-hover-bg": "rgb(220 252 231)",
540
- "--sg-badge-hover-fg": "rgb(21 128 61)",
541
- "--sg-badge-hover-border": "rgb(134 239 172)",
542
- "--sg-badge-ring": "rgb(74 222 128)",
543
- "--sg-badge-soft-bg": "rgb(240 253 244)",
544
- "--sg-badge-soft-fg": "rgb(22 163 74)",
545
- };
546
- const SANDPACK_CORE_THEME_VARS = [
547
- "--background",
548
- "--foreground",
549
- "--primary",
550
- "--primary-foreground",
551
- "--secondary",
552
- "--secondary-foreground",
553
- "--accent",
554
- "--accent-foreground",
555
- "--destructive",
556
- "--destructive-foreground",
557
- "--border",
558
- "--input",
559
- "--ring",
560
- "--muted",
561
- "--muted-foreground",
562
- "--radius"
563
- ];
564
- // Explicit list of --sg-* vars to read from host via getPropertyValue().
565
- // CSSStyleDeclaration.length/.item() does NOT enumerate CSS custom properties,
566
- // so we must call getPropertyValue() for each var by name.
567
- const SANDPACK_SG_VARS = [
568
- "--sg-mode",
569
- // Neutrals
570
- "--sg-bg", "--sg-surface", "--sg-muted-surface",
571
- "--sg-text", "--sg-muted", "--sg-border", "--sg-ring",
572
- "--sg-disabled", "--sg-on-disabled",
573
- "--sg-link", "--sg-link-hover",
574
- "--sg-radius",
575
- // On-color tokens
576
- "--sg-on-primary", "--sg-on-secondary", "--sg-on-tertiary",
577
- "--sg-on-warning", "--sg-on-error", "--sg-on-info", "--sg-on-success",
578
- // Primary palette
579
- "--sg-primary-50", "--sg-primary-100", "--sg-primary-200", "--sg-primary-300",
580
- "--sg-primary-400", "--sg-primary-500", "--sg-primary-600", "--sg-primary-700",
581
- "--sg-primary-800", "--sg-primary-900", "--sg-primary-hover", "--sg-primary-active",
582
- // Secondary palette
583
- "--sg-secondary-50", "--sg-secondary-100", "--sg-secondary-200", "--sg-secondary-300",
584
- "--sg-secondary-400", "--sg-secondary-500", "--sg-secondary-600", "--sg-secondary-700",
585
- "--sg-secondary-800", "--sg-secondary-900", "--sg-secondary-hover", "--sg-secondary-active",
586
- // Tertiary palette
587
- "--sg-tertiary-50", "--sg-tertiary-100", "--sg-tertiary-200", "--sg-tertiary-300",
588
- "--sg-tertiary-400", "--sg-tertiary-500", "--sg-tertiary-600", "--sg-tertiary-700",
589
- "--sg-tertiary-800", "--sg-tertiary-900", "--sg-tertiary-hover", "--sg-tertiary-active",
590
- // Warning palette
591
- "--sg-warning-50", "--sg-warning-100", "--sg-warning-200", "--sg-warning-300",
592
- "--sg-warning-400", "--sg-warning-500", "--sg-warning-600", "--sg-warning-700",
593
- "--sg-warning-800", "--sg-warning-900", "--sg-warning-hover", "--sg-warning-active",
594
- // Error palette
595
- "--sg-error-50", "--sg-error-100", "--sg-error-200", "--sg-error-300",
596
- "--sg-error-400", "--sg-error-500", "--sg-error-600", "--sg-error-700",
597
- "--sg-error-800", "--sg-error-900", "--sg-error-hover", "--sg-error-active",
598
- // Info palette
599
- "--sg-info-50", "--sg-info-100", "--sg-info-200", "--sg-info-300",
600
- "--sg-info-400", "--sg-info-500", "--sg-info-600", "--sg-info-700",
601
- "--sg-info-800", "--sg-info-900", "--sg-info-hover", "--sg-info-active",
602
- // Success palette
603
- "--sg-success-50", "--sg-success-100", "--sg-success-200", "--sg-success-300",
604
- "--sg-success-400", "--sg-success-500", "--sg-success-600", "--sg-success-700",
605
- "--sg-success-800", "--sg-success-900", "--sg-success-hover", "--sg-success-active",
606
- // Button component vars
607
- "--sg-btn-bg", "--sg-btn-fg", "--sg-btn-border",
608
- "--sg-btn-hover-bg", "--sg-btn-hover-fg", "--sg-btn-hover-border",
609
- "--sg-btn-active-bg", "--sg-btn-ring", "--sg-btn-tint",
610
- // Avatar component vars
611
- "--sg-avatar-bg", "--sg-avatar-fg", "--sg-avatar-border", "--sg-avatar-ring",
612
- // Badge component vars
613
- "--sg-badge-bg", "--sg-badge-fg", "--sg-badge-border",
614
- "--sg-badge-hover-bg", "--sg-badge-hover-fg", "--sg-badge-hover-border",
615
- "--sg-badge-ring", "--sg-badge-soft-bg", "--sg-badge-soft-fg",
616
- ];
617
- const SANDPACK_BASE_STYLES_CSS = `* {
618
- box-sizing: border-box;
619
- }
620
-
621
- html, body, #root {
622
- margin: 0;
623
- min-height: 100%;
624
- }
625
-
626
- #root {
627
- padding: var(--sg-preview-padding, 0px);
628
- }
629
-
630
- body {
631
- font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
632
- background: rgb(var(--sg-bg, 255 255 255));
633
- color: rgb(var(--sg-text, 11 11 12));
634
- }
635
-
636
- /* Classes with arbitrary values used by SeedGrid components */
637
- .bg-\\[var\\(--sg-btn-bg\\)\\] { background-color: var(--sg-btn-bg); }
638
- .text-\\[var\\(--sg-btn-fg\\)\\] { color: var(--sg-btn-fg); }
639
- .border-\\[var\\(--sg-btn-border\\)\\] { border-color: var(--sg-btn-border); }
640
- .hover\\:bg-\\[var\\(--sg-btn-hover-bg\\)\\]:hover { background-color: var(--sg-btn-hover-bg); }
641
- .hover\\:text-\\[var\\(--sg-btn-hover-fg\\)\\]:hover { color: var(--sg-btn-hover-fg); }
642
- .hover\\:border-\\[var\\(--sg-btn-hover-border\\)\\]:hover { border-color: var(--sg-btn-hover-border); }
643
- .active\\:bg-\\[var\\(--sg-btn-active-bg\\)\\]:active { background-color: var(--sg-btn-active-bg); }
644
- .focus-visible\\:ring-\\[var\\(--sg-btn-ring\\)\\]:focus-visible { box-shadow: 0 0 0 4px var(--sg-btn-ring); }
645
- .hover\\:bg-\\[rgb\\(var\\(--sg-btn-tint\\)\\/0\\.12\\)\\]:hover { background-color: rgb(var(--sg-btn-tint) / 0.12); }
646
- .active\\:bg-\\[rgb\\(var\\(--sg-btn-tint\\)\\/0\\.18\\)\\]:active { background-color: rgb(var(--sg-btn-tint) / 0.18); }
647
- .hover\\:bg-\\[rgb\\(var\\(--sg-btn-tint\\)\\/0\\.10\\)\\]:hover { background-color: rgb(var(--sg-btn-tint) / 0.10); }
648
- .active\\:bg-\\[rgb\\(var\\(--sg-btn-tint\\)\\/0\\.16\\)\\]:active { background-color: rgb(var(--sg-btn-tint) / 0.16); }
649
- .transition-\\[background-color\\,color\\,border-color\\,box-shadow\\,transform\\] {
650
- transition-property: background-color, color, border-color, box-shadow, transform;
651
- }
652
- .active\\:translate-y-\\[0\\.5px\\]:active { transform: translateY(0.5px); }
653
- .size-4 { width: 1rem; height: 1rem; }
654
- .size-5 { width: 1.25rem; height: 1.25rem; }
655
- `;
656
- const SANDPACK_HOST_STYLES_CSS = `
657
- .sg-playground-preview .sp-cube-wrapper {
658
- top: 8px !important;
659
- right: 8px !important;
660
- bottom: auto !important;
661
- left: auto !important;
662
- }
663
- `;
664
- // Keep CRA's expected HTML entry file path for react/react-ts templates.
665
- const SANDPACK_TAILWIND_INDEX_HTML = `<!DOCTYPE html>
666
- <html lang="en">
667
- <head>
668
- <meta charset="UTF-8">
669
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
670
- <title>Document</title>
671
- </head>
672
- <body>
673
- <div id="root"></div>
674
- </body>
675
- </html>
676
- `;
677
- function normalizeUrl(raw, fallback) {
678
- const value = raw?.trim();
679
- if (!value)
680
- return fallback;
681
- try {
682
- const parsed = new URL(value);
683
- return parsed.toString().replace(/\/+$/, "");
684
- }
685
- catch {
686
- return fallback;
687
- }
688
- }
689
- function normalizeTimeoutMs(value, fallback) {
690
- if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
691
- return fallback;
692
- }
693
- return Math.round(value);
694
- }
695
- function parseBooleanFlag(value, fallback) {
696
- const normalized = value?.trim().toLowerCase();
697
- if (!normalized)
698
- return fallback;
699
- if (normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on") {
700
- return true;
701
- }
702
- if (normalized === "0" || normalized === "false" || normalized === "no" || normalized === "off") {
703
- return false;
704
- }
705
- return fallback;
706
- }
707
- function resolveDefaultNpmRegistriesFromEnv() {
708
- const registryUrlRaw = process.env.NEXT_PUBLIC_SANDPACK_NPM_REGISTRY_URL?.trim();
709
- if (!registryUrlRaw)
710
- return undefined;
711
- const scopesRaw = process.env.NEXT_PUBLIC_SANDPACK_NPM_REGISTRY_SCOPES;
712
- const enabledScopes = (scopesRaw ?? "@seedgrid")
713
- .split(",")
714
- .map((scope) => scope.trim())
715
- .filter(Boolean);
716
- const limitToScopes = parseBooleanFlag(process.env.NEXT_PUBLIC_SANDPACK_NPM_REGISTRY_LIMIT_TO_SCOPES, true);
717
- const proxyEnabled = parseBooleanFlag(process.env.NEXT_PUBLIC_SANDPACK_NPM_REGISTRY_PROXY_ENABLED, false);
718
- const registryAuthToken = process.env.NEXT_PUBLIC_SANDPACK_NPM_REGISTRY_AUTH_TOKEN?.trim();
719
- return [
720
- {
721
- enabledScopes,
722
- limitToScopes,
723
- registryUrl: registryUrlRaw.replace(/\/+$/, ""),
724
- proxyEnabled,
725
- ...(registryAuthToken ? { registryAuthToken } : {})
726
- }
727
- ];
728
- }
729
- const SANDPACK_MIN_COMPONENT_MESSAGES = {
730
- "components.actions.clear": "Clear",
731
- "components.actions.cancel": "Cancel",
732
- "components.actions.confirm": "Confirm",
733
- "components.inputs.required": "Required field.",
734
- "components.inputs.maxLength": "Maximum {max} characters.",
735
- "components.inputs.minLength": "Minimum {min} characters.",
736
- "components.inputs.minWords": "Minimum {min} words.",
737
- "components.inputs.email.invalid": "Invalid email.",
738
- "components.inputs.phone.invalid": "Invalid phone.",
739
- "components.inputs.date.invalid": "Invalid date.",
740
- "components.inputs.number.min": "Value must be at least {min}.",
741
- "components.inputs.number.max": "Value must be at most {max}.",
742
- "components.password.show": "Show password",
743
- "components.password.hide": "Hide password",
744
- "components.autocomplete.empty": "No records found.",
745
- "components.autocomplete.loading": "Loading...",
746
- "components.rating.cancel": "Cancel rating",
747
- "components.radiogroup.cancel": "No option"
748
- };
749
- // These shims use valid JSON so the Sandpack bundler can parse them as JSON modules.
750
- // (The self-hosted bundler evaluates .json files as JS, wrapping them with module.exports = {...}.)
751
- const SANDPACK_SEEDGRID_PT_BR_JSON_SHIM = JSON.stringify(SANDPACK_MIN_COMPONENT_MESSAGES);
752
- const SANDPACK_SEEDGRID_PT_PT_JSON_SHIM = JSON.stringify(SANDPACK_MIN_COMPONENT_MESSAGES);
753
- const SANDPACK_SEEDGRID_EN_US_JSON_SHIM = JSON.stringify(SANDPACK_MIN_COMPONENT_MESSAGES);
754
- const SANDPACK_SEEDGRID_ES_JSON_SHIM = JSON.stringify(SANDPACK_MIN_COMPONENT_MESSAGES);
755
- const SANDPACK_SEEDGRID_BLOCKED_EMAIL_DOMAINS_JSON_SHIM = JSON.stringify({
756
- blockedEmailDomains: []
757
- });
758
- // CJS shims for .js locale files (new npm versions after the JSON→TypeScript conversion).
759
- const SANDPACK_SEEDGRID_LOCALE_JS_SHIM = `module.exports = ${JSON.stringify(SANDPACK_MIN_COMPONENT_MESSAGES)};`;
760
- const SANDPACK_SEEDGRID_BLOCKED_EMAIL_JS_SHIM = `module.exports = ${JSON.stringify({ blockedEmailDomains: [] })};`;
761
- function parseRgbParts(raw) {
762
- const value = raw.trim();
763
- if (!value)
764
- return null;
765
- const normalized = value
766
- .replace(/^rgb\(/i, "")
767
- .replace(/\)$/g, "")
768
- .replace(/\//g, " ")
769
- .replace(/,/g, " ")
770
- .trim();
771
- const pieces = normalized
772
- .split(/\s+/)
773
- .map((part) => Number(part))
774
- .filter((num) => Number.isFinite(num));
775
- if (pieces.length < 3)
776
- return null;
777
- const r = pieces[0];
778
- const g = pieces[1];
779
- const b = pieces[2];
780
- const clamp = (n) => Math.max(0, Math.min(255, Math.round(n)));
781
- return [clamp(r), clamp(g), clamp(b)];
782
- }
783
- function rgbToHslTriplet(r, g, b) {
784
- const rr = r / 255;
785
- const gg = g / 255;
786
- const bb = b / 255;
787
- const max = Math.max(rr, gg, bb);
788
- const min = Math.min(rr, gg, bb);
789
- const delta = max - min;
790
- let h = 0;
791
- let s = 0;
792
- const l = (max + min) / 2;
793
- if (delta !== 0) {
794
- s = delta / (1 - Math.abs(2 * l - 1));
795
- switch (max) {
796
- case rr:
797
- h = ((gg - bb) / delta + (gg < bb ? 6 : 0)) / 6;
798
- break;
799
- case gg:
800
- h = ((bb - rr) / delta + 2) / 6;
801
- break;
802
- default:
803
- h = ((rr - gg) / delta + 4) / 6;
804
- break;
805
- }
806
- }
807
- const hue = Math.round(h * 360);
808
- const sat = Math.round(s * 100);
809
- const lig = Math.round(l * 100);
810
- return `${hue} ${sat}% ${lig}%`;
811
- }
812
- function toHslFromRgbVar(value) {
813
- if (!value)
814
- return null;
815
- const parts = parseRgbParts(value);
816
- if (!parts)
817
- return null;
818
- return rgbToHslTriplet(parts[0], parts[1], parts[2]);
819
- }
820
- function mapSgVarsToCoreVars(themeVars) {
821
- const mapped = {};
822
- const assignFromSg = (coreVar, sgVar) => {
823
- const hsl = toHslFromRgbVar(themeVars[sgVar]);
824
- if (hsl)
825
- mapped[coreVar] = hsl;
826
- };
827
- assignFromSg("--background", "--sg-bg");
828
- assignFromSg("--foreground", "--sg-text");
829
- assignFromSg("--primary", "--sg-primary-600");
830
- assignFromSg("--primary-foreground", "--sg-on-primary");
831
- assignFromSg("--secondary", "--sg-secondary-600");
832
- assignFromSg("--secondary-foreground", "--sg-on-secondary");
833
- assignFromSg("--accent", "--sg-tertiary-600");
834
- assignFromSg("--accent-foreground", "--sg-on-tertiary");
835
- assignFromSg("--destructive", "--sg-error-600");
836
- assignFromSg("--destructive-foreground", "--sg-on-error");
837
- assignFromSg("--border", "--sg-border");
838
- assignFromSg("--ring", "--sg-primary-400");
839
- return mapped;
840
- }
841
- function readThemeVarsFromHost() {
842
- if (typeof window === "undefined")
843
- return {};
844
- const computed = window.getComputedStyle(document.documentElement);
845
- const themeVars = {};
846
- for (const varName of SANDPACK_CORE_THEME_VARS) {
847
- const value = computed.getPropertyValue(varName).trim();
848
- if (value)
849
- themeVars[varName] = value;
850
- }
851
- // CSSStyleDeclaration.length/.item() does NOT enumerate CSS custom properties,
852
- // so we explicitly call getPropertyValue() for each known --sg-* var.
853
- for (const varName of SANDPACK_SG_VARS) {
854
- const value = computed.getPropertyValue(varName).trim();
855
- if (value)
856
- themeVars[varName] = value;
857
- }
858
- Object.assign(themeVars, mapSgVarsToCoreVars(themeVars));
859
- return themeVars;
860
- }
861
- function resolveSandpackThemeFromHost() {
862
- if (typeof window === "undefined")
863
- return "light";
864
- const root = document.documentElement;
865
- const computed = window.getComputedStyle(root);
866
- const mode = computed.getPropertyValue("--sg-mode").trim().toLowerCase();
867
- if (mode === "dark")
868
- return "dark";
869
- if (mode === "light")
870
- return "light";
871
- const dataTheme = root.getAttribute("data-theme")?.trim().toLowerCase();
872
- if (dataTheme === "dark")
873
- return "dark";
874
- if (dataTheme === "light")
875
- return "light";
876
- if (root.classList.contains("dark"))
877
- return "dark";
878
- return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
879
- }
880
- function getStyleSheetHref(styleSheet) {
881
- const cssSheet = styleSheet;
882
- if (cssSheet.href)
883
- return cssSheet.href;
884
- const ownerNode = cssSheet.ownerNode;
885
- if (!(ownerNode instanceof Element))
886
- return "";
887
- return ownerNode.getAttribute("data-n-href") ?? "";
888
- }
889
- function readHostNextCssText() {
890
- if (typeof document === "undefined")
891
- return "";
892
- const chunks = [];
893
- const sheets = Array.from(document.styleSheets);
894
- for (const sheet of sheets) {
895
- const href = getStyleSheetHref(sheet);
896
- if (!href.includes("/_next/static/css/"))
897
- continue;
898
- let rules;
899
- try {
900
- rules = sheet.cssRules;
901
- }
902
- catch {
903
- continue;
904
- }
905
- for (const rule of Array.from(rules)) {
906
- chunks.push(rule.cssText);
907
- }
908
- }
909
- return chunks.join("\n");
910
- }
911
- function normalizeCssSize(value) {
912
- return typeof value === "number" ? `${value}px` : value;
913
- }
914
- function buildSandpackStylesCss(themeVars, previewPadding, hostCss = "") {
915
- const mergedVars = {
916
- ...SANDPACK_FALLBACK_THEME_VARS,
917
- ...themeVars,
918
- "--sg-preview-padding": previewPadding
919
- };
920
- const rootVars = Object.entries(mergedVars)
921
- .sort(([a], [b]) => a.localeCompare(b))
922
- .map(([varName, value]) => ` ${varName}: ${value};`)
923
- .join("\n");
924
- return `:root {
925
- ${rootVars}
926
- }
927
-
928
- ${SANDPACK_BASE_STYLES_CSS}
929
- ${hostCss ? `\n\n${hostCss}` : ""}`;
930
- }
931
- function ReadonlyBlock({ code }) {
932
- return (_jsx("pre", { className: "overflow-auto rounded-lg border border-border bg-muted/30 p-4 text-xs leading-relaxed", children: _jsx("code", { children: code }) }));
933
- }
934
- function buildAppTsxFromRenderBody(renderBody, defaultImports, wrapperClassName) {
935
- const body = renderBody
936
- .replace(/\t/g, " ")
937
- .split("\n")
938
- .map((line) => (line ? ` ${line}` : ""))
939
- .join("\n");
940
- if (!wrapperClassName) {
941
- return `import * as React from "react";
942
- ${defaultImports}
943
-
944
- export default function App() {
945
- return (
946
- <>
947
- ${body}
948
- </>
949
- );
950
- }
951
- `;
952
- }
953
- return `import * as React from "react";
954
- ${defaultImports}
955
-
956
- export default function App() {
957
- return (
958
- <div className="${wrapperClassName}">
959
- <>
960
- ${body}
961
- </>
962
- </div>
963
- );
964
- }
965
- `;
966
- }
967
- async function copyText(text) {
968
- if (!text)
969
- return false;
970
- if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
971
- await navigator.clipboard.writeText(text);
972
- return true;
973
- }
974
- if (typeof document === "undefined")
975
- return false;
976
- const textarea = document.createElement("textarea");
977
- textarea.value = text;
978
- textarea.setAttribute("readonly", "");
979
- textarea.style.position = "fixed";
980
- textarea.style.opacity = "0";
981
- document.body.appendChild(textarea);
982
- textarea.select();
983
- const ok = document.execCommand("copy");
984
- document.body.removeChild(textarea);
985
- return ok;
986
- }
987
- function CopyButton() {
988
- const { sandpack } = useSandpack();
989
- const [copyState, setCopyState] = React.useState("idle");
990
- const handleCopy = React.useCallback(async () => {
991
- try {
992
- const activeFilePath = sandpack.activeFile;
993
- const activeCode = sandpack.files[activeFilePath]?.code ?? "";
994
- const copied = await copyText(activeCode);
995
- setCopyState(copied ? "success" : "error");
996
- }
997
- catch {
998
- setCopyState("error");
999
- }
1000
- }, [sandpack.activeFile, sandpack.files]);
1001
- React.useEffect(() => {
1002
- if (copyState === "idle")
1003
- return;
1004
- const timerId = window.setTimeout(() => setCopyState("idle"), 1400);
1005
- return () => window.clearTimeout(timerId);
1006
- }, [copyState]);
1007
- return (_jsx(SgButton, { appearance: "outline", size: "sm", onClick: handleCopy, children: copyState === "success" ? "Copiado" : copyState === "error" ? "Erro" : "Copiar" }));
1008
- }
1009
- function RunButton({ onRun }) {
1010
- const { sandpack } = useSandpack();
1011
- const [running, setRunning] = React.useState(false);
1012
- const handleRun = React.useCallback(async () => {
1013
- if (running)
1014
- return;
1015
- setRunning(true);
1016
- onRun?.();
1017
- try {
1018
- if (typeof window !== "undefined") {
1019
- await new Promise((resolve) => {
1020
- window.requestAnimationFrame(() => window.requestAnimationFrame(() => resolve()));
1021
- });
1022
- }
1023
- // On lazy init + hidden preview scenarios, iframe/client registration can lag by a tick.
1024
- for (let attempt = 0; attempt < 3; attempt += 1) {
1025
- await sandpack.runSandpack();
1026
- if (sandpack.status === "running" ||
1027
- sandpack.status === "done" ||
1028
- Object.keys(sandpack.clients ?? {}).length > 0) {
1029
- break;
1030
- }
1031
- await new Promise((resolve) => setTimeout(resolve, 120));
1032
- }
1033
- }
1034
- catch (error) {
1035
- console.error("[SgPlayground] Failed to run Sandpack", error);
1036
- }
1037
- finally {
1038
- if (typeof window !== "undefined") {
1039
- window.setTimeout(() => setRunning(false), 150);
1040
- }
1041
- else {
1042
- setRunning(false);
1043
- }
1044
- }
1045
- }, [onRun, running, sandpack]);
1046
- return (_jsx(SgButton, { severity: "primary", size: "sm", loading: running, onClick: handleRun, children: running ? "Running" : "Run" }));
1047
- }
1048
- const COREJS_PROVIDER_WARNING_PREFIX = "Internal error in the corejs3 provider: unknown polyfill";
1049
- function shouldSuppressCoreJsProviderWarning(args) {
1050
- if (args.length === 0)
1051
- return false;
1052
- const firstArg = args[0];
1053
- return typeof firstArg === "string" && firstArg.includes(COREJS_PROVIDER_WARNING_PREFIX);
1054
- }
1055
- export default function SgPlayground(props) {
1056
- const { code, interactive = false, codeContract = "renderBody", preset = "auto", title, description, height = 360, expandedHeight = "70vh", expandable = true, resizable = true, resizeAxis = "vertical", previewPadding, className, style, dependencies, defaultImports, previewWrapperClassName = "h-[420px] rounded-xl border border-border bg-muted/30 p-3", seedgridDependency, bundlerURL, bundlerTimeoutMs, npmRegistries, withCard = true, collapsible = true, defaultOpen = true, cardId } = props;
1057
- const effectivePreviewPadding = normalizeCssSize(previewPadding ?? (codeContract === "appFile" ? 12 : 0));
1058
- const [sandpackStylesCss, setSandpackStylesCss] = React.useState(() => buildSandpackStylesCss({}, effectivePreviewPadding));
1059
- const [sandpackTheme, setSandpackTheme] = React.useState(() => resolveSandpackThemeFromHost());
1060
- const [isExpanded, setIsExpanded] = React.useState(false);
1061
- const [activePanel, setActivePanel] = React.useState("code");
1062
- React.useEffect(() => {
1063
- if (typeof window === "undefined")
1064
- return;
1065
- const root = document.documentElement;
1066
- const refreshStyles = () => {
1067
- const liveThemeVars = readThemeVarsFromHost();
1068
- const hostCss = readHostNextCssText();
1069
- setSandpackStylesCss(buildSandpackStylesCss(liveThemeVars, effectivePreviewPadding, hostCss));
1070
- setSandpackTheme(resolveSandpackThemeFromHost());
1071
- };
1072
- let frameId = null;
1073
- const scheduleRefresh = () => {
1074
- if (frameId !== null)
1075
- return;
1076
- frameId = window.requestAnimationFrame(() => {
1077
- frameId = null;
1078
- refreshStyles();
1079
- });
1080
- };
1081
- const observer = new MutationObserver(scheduleRefresh);
1082
- observer.observe(root, {
1083
- attributes: true,
1084
- attributeFilter: ["style", "class", "data-theme"]
1085
- });
1086
- refreshStyles();
1087
- return () => {
1088
- observer.disconnect();
1089
- if (frameId !== null) {
1090
- window.cancelAnimationFrame(frameId);
1091
- }
1092
- };
1093
- }, [effectivePreviewPadding]);
1094
- const seedgridDefaultImports = defaultImports ?? `import {
1095
- SgScreen,
1096
- SgMainPanel,
1097
- SgPanel,
1098
- SgGrid,
1099
- SgStack,
1100
- SgButton,
1101
- SgAutocomplete
1102
- } from "@seedgrid/fe-components";`;
1103
- const appTsx = React.useMemo(() => codeContract === "appFile"
1104
- ? code
1105
- : buildAppTsxFromRenderBody(code, seedgridDefaultImports, previewWrapperClassName), [code, codeContract, previewWrapperClassName, seedgridDefaultImports]);
1106
- const resolvedSeedgridDependency = seedgridDependency ??
1107
- process.env.NEXT_PUBLIC_SANDPACK_SEEDGRID_DEPENDENCY ??
1108
- DEFAULT_SEEDGRID_DEPENDENCY;
1109
- const requestedDeps = React.useMemo(() => dependencies ?? {}, [dependencies]);
1110
- const requestedDepKeys = React.useMemo(() => Object.keys(requestedDeps), [requestedDeps]);
1111
- const resolvedBundlerURL = normalizeUrl(bundlerURL ?? process.env.NEXT_PUBLIC_SANDPACK_BUNDLER_URL, DEFAULT_SANDPACK_BUNDLER_URL);
1112
- const resolvedBundlerTimeoutMs = normalizeTimeoutMs(bundlerTimeoutMs ??
1113
- Number(process.env.NEXT_PUBLIC_SANDPACK_BUNDLER_TIMEOUT_MS ?? Number.NaN), DEFAULT_SANDPACK_BUNDLER_TIMEOUT_MS);
1114
- const resolvedNpmRegistries = React.useMemo(() => npmRegistries ?? resolveDefaultNpmRegistriesFromEnv(), [npmRegistries]);
1115
- React.useEffect(() => {
1116
- if (!interactive)
1117
- return;
1118
- if (!parseBooleanFlag(process.env.NEXT_PUBLIC_SANDPACK_DEBUG, false))
1119
- return;
1120
- console.info("[SgPlayground] Sandpack runtime config", {
1121
- bundlerURL: resolvedBundlerURL,
1122
- bundlerTimeoutMs: resolvedBundlerTimeoutMs,
1123
- npmRegistries: (resolvedNpmRegistries ?? []).map((registry) => ({
1124
- enabledScopes: registry.enabledScopes,
1125
- limitToScopes: registry.limitToScopes,
1126
- registryUrl: registry.registryUrl,
1127
- proxyEnabled: registry.proxyEnabled
1128
- }))
1129
- });
1130
- }, [interactive, resolvedBundlerTimeoutMs, resolvedBundlerURL, resolvedNpmRegistries]);
1131
- const codeUsesSeedgrid = /from\s+["']@seedgrid\/fe-components["']/.test(appTsx);
1132
- const codeUsesTextEditor = /\bSgTextEditor\b/.test(appTsx);
1133
- const codeUsesPlaygroundComponent = /\bSgPlayground\b/.test(appTsx);
1134
- const resolvedPreset = preset === "auto"
1135
- ? codeUsesTextEditor
1136
- ? "editor"
1137
- : codeUsesSeedgrid
1138
- ? "seedgrid"
1139
- : "basic"
1140
- : preset;
1141
- const includeSeedgridDependency = resolvedPreset === "seedgrid" ||
1142
- resolvedPreset === "editor" ||
1143
- resolvedPreset === "full" ||
1144
- requestedDepKeys.includes("@seedgrid/fe-components");
1145
- const includeEditorDependencies = resolvedPreset === "editor" ||
1146
- resolvedPreset === "full" ||
1147
- codeUsesTextEditor ||
1148
- requestedDepKeys.some((dep) => dep.startsWith("@tiptap/"));
1149
- const includeSandpackReactDependency = resolvedPreset === "full" ||
1150
- codeUsesPlaygroundComponent ||
1151
- requestedDepKeys.includes("@codesandbox/sandpack-react");
1152
- const shouldShimSandpackReact = includeSeedgridDependency && !includeSandpackReactDependency;
1153
- const shouldShimTiptap = includeSeedgridDependency && !includeEditorDependencies;
1154
- const shouldIncludeNodePolyfills = includeEditorDependencies;
1155
- // Shim lucide-react for all non-full presets to avoid OOM from bundling ~1400 icon components.
1156
- // Full preset gets the real package so icons render correctly.
1157
- const shouldShimLucide = includeSeedgridDependency && resolvedPreset !== "full" && !requestedDepKeys.includes("lucide-react");
1158
- React.useEffect(() => {
1159
- if (!shouldIncludeNodePolyfills)
1160
- return;
1161
- if (typeof window === "undefined")
1162
- return;
1163
- const originalError = console.error;
1164
- const originalWarn = console.warn;
1165
- console.error = (...args) => {
1166
- if (shouldSuppressCoreJsProviderWarning(args))
1167
- return;
1168
- originalError(...args);
1169
- };
1170
- console.warn = (...args) => {
1171
- if (shouldSuppressCoreJsProviderWarning(args))
1172
- return;
1173
- originalWarn(...args);
1174
- };
1175
- return () => {
1176
- console.error = originalError;
1177
- console.warn = originalWarn;
1178
- };
1179
- }, [shouldIncludeNodePolyfills]);
1180
- const files = React.useMemo(() => {
1181
- const nextFiles = {
1182
- "/App.tsx": { code: appTsx, active: true },
1183
- "/styles.css": { code: sandpackStylesCss || buildSandpackStylesCss({}, effectivePreviewPadding) }
1184
- };
1185
- if (includeSeedgridDependency) {
1186
- // Intercept the package entry point and redirect to the pre-compiled sandbox bundle
1187
- // (dist/sandbox.cjs) instead of the tsc barrel file (dist/index.js).
1188
- // This makes the Sandpack bundler fetch and process ONE file instead of 200+ individual files.
1189
- // The real package.json from npm is left intact so version resolution works normally.
1190
- // Requires @seedgrid/fe-components to be built with: pnpm run build:sandbox
1191
- nextFiles["/node_modules/@seedgrid/fe-components/dist/index.js"] = {
1192
- code: `module.exports = require("./sandbox.cjs");`,
1193
- hidden: true
1194
- };
1195
- // Compatibility shim for legacy @seedgrid/fe-components builds that still import "qrcode" (node-only path).
1196
- nextFiles["/node_modules/qrcode/index.js"] = { code: SANDPACK_QRCODE_SHIM_INDEX_JS, hidden: true };
1197
- // Keep CRA's public/index.html entry path expected by the react/react-ts templates.
1198
- nextFiles["/public/index.html"] = { code: SANDPACK_TAILWIND_INDEX_HTML, hidden: true };
1199
- // Sandpack runtime can evaluate JSON files as plain JS modules.
1200
- // Provide CJS-compatible shims to keep @seedgrid/fe-components i18n/validators working.
1201
- // .json shims cover current npm versions; .js shims cover new versions after JSON→TypeScript conversion.
1202
- nextFiles["/node_modules/@seedgrid/fe-components/dist/i18n/pt-BR.json"] = {
1203
- code: SANDPACK_SEEDGRID_PT_BR_JSON_SHIM,
1204
- hidden: true
1205
- };
1206
- nextFiles["/node_modules/@seedgrid/fe-components/dist/i18n/pt-PT.json"] = {
1207
- code: SANDPACK_SEEDGRID_PT_PT_JSON_SHIM,
1208
- hidden: true
1209
- };
1210
- nextFiles["/node_modules/@seedgrid/fe-components/dist/i18n/en-US.json"] = {
1211
- code: SANDPACK_SEEDGRID_EN_US_JSON_SHIM,
1212
- hidden: true
1213
- };
1214
- nextFiles["/node_modules/@seedgrid/fe-components/dist/i18n/es.json"] = {
1215
- code: SANDPACK_SEEDGRID_ES_JSON_SHIM,
1216
- hidden: true
1217
- };
1218
- nextFiles["/node_modules/@seedgrid/fe-components/dist/blocked-email-domains.json"] = {
1219
- code: SANDPACK_SEEDGRID_BLOCKED_EMAIL_DOMAINS_JSON_SHIM,
1220
- hidden: true
1221
- };
1222
- nextFiles["/node_modules/@seedgrid/fe-components/dist/i18n/pt-BR.js"] = {
1223
- code: SANDPACK_SEEDGRID_LOCALE_JS_SHIM,
1224
- hidden: true
1225
- };
1226
- nextFiles["/node_modules/@seedgrid/fe-components/dist/i18n/pt-PT.js"] = {
1227
- code: SANDPACK_SEEDGRID_LOCALE_JS_SHIM,
1228
- hidden: true
1229
- };
1230
- nextFiles["/node_modules/@seedgrid/fe-components/dist/i18n/en-US.js"] = {
1231
- code: SANDPACK_SEEDGRID_LOCALE_JS_SHIM,
1232
- hidden: true
1233
- };
1234
- nextFiles["/node_modules/@seedgrid/fe-components/dist/i18n/es.js"] = {
1235
- code: SANDPACK_SEEDGRID_LOCALE_JS_SHIM,
1236
- hidden: true
1237
- };
1238
- nextFiles["/node_modules/@seedgrid/fe-components/dist/blocked-email-domains.js"] = {
1239
- code: SANDPACK_SEEDGRID_BLOCKED_EMAIL_JS_SHIM,
1240
- hidden: true
1241
- };
1242
- }
1243
- if (shouldIncludeNodePolyfills) {
1244
- const markdownItPackageShimPaths = [
1245
- "/node_modules/markdown-it/package.json",
1246
- "/node_modules/prosemirror-markdown/node_modules/markdown-it/package.json",
1247
- "/node_modules/@tiptap/pm/node_modules/markdown-it/package.json",
1248
- "/node_modules/@tiptap/pm/node_modules/prosemirror-markdown/node_modules/markdown-it/package.json"
1249
- ];
1250
- const markdownItBinShimPaths = [
1251
- "/node_modules/markdown-it/bin/markdown-it.mjs",
1252
- "/node_modules/prosemirror-markdown/node_modules/markdown-it/bin/markdown-it.mjs",
1253
- "/node_modules/@tiptap/pm/node_modules/markdown-it/bin/markdown-it.mjs",
1254
- "/node_modules/@tiptap/pm/node_modules/prosemirror-markdown/node_modules/markdown-it/bin/markdown-it.mjs"
1255
- ];
1256
- // Keep markdown-it package metadata browser-safe. In some Sandpack resolver paths,
1257
- // `bin` can be chosen as entrypoint; forcing it to dist avoids node-only imports.
1258
- for (const shimPath of markdownItPackageShimPaths) {
1259
- nextFiles[shimPath] = {
1260
- code: SANDPACK_MARKDOWN_IT_PACKAGE_JSON_SHIM,
1261
- hidden: true
1262
- };
1263
- }
1264
- // markdown-it CLI entry uses node:fs and breaks in browser runtime.
1265
- for (const shimPath of markdownItBinShimPaths) {
1266
- nextFiles[shimPath] = {
1267
- code: SANDPACK_MARKDOWN_IT_BIN_SHIM,
1268
- hidden: true
1269
- };
1270
- }
1271
- // Node builtin compatibility shims used by transitive dependencies (e.g. argparse from markdown-it/tiptap).
1272
- nextFiles["/node_modules/assert/package.json"] = {
1273
- code: JSON.stringify({ name: "assert", version: "0.0.0-shim", main: "index.js" }),
1274
- hidden: true
1275
- };
1276
- nextFiles["/node_modules/util/package.json"] = {
1277
- code: JSON.stringify({ name: "util", version: "0.0.0-shim", main: "index.js" }),
1278
- hidden: true
1279
- };
1280
- nextFiles["/node_modules/path/package.json"] = {
1281
- code: JSON.stringify({ name: "path", version: "0.0.0-shim", main: "index.js" }),
1282
- hidden: true
1283
- };
1284
- nextFiles["/node_modules/fs/package.json"] = {
1285
- code: JSON.stringify({ name: "fs", version: "0.0.0-shim", main: "index.js" }),
1286
- hidden: true
1287
- };
1288
- nextFiles["/node_modules/process/package.json"] = {
1289
- code: JSON.stringify({ name: "process", version: "0.0.0-shim", main: "index.js" }),
1290
- hidden: true
1291
- };
1292
- nextFiles["/node_modules/assert/index.js"] = { code: SANDPACK_ASSERT_SHIM_INDEX_JS, hidden: true };
1293
- nextFiles["/node_modules/util/index.js"] = { code: SANDPACK_UTIL_SHIM_INDEX_JS, hidden: true };
1294
- nextFiles["/node_modules/path/index.js"] = { code: SANDPACK_PATH_SHIM_INDEX_JS, hidden: true };
1295
- nextFiles["/node_modules/fs/index.js"] = { code: SANDPACK_FS_SHIM_INDEX_JS, hidden: true };
1296
- nextFiles["/node_modules/process/index.js"] = { code: SANDPACK_PROCESS_SHIM_INDEX_JS, hidden: true };
1297
- // node:* specifiers are increasingly used by ESM packages.
1298
- // Mirror aliases to the shims above so both `fs` and `node:fs` resolve.
1299
- nextFiles["/node_modules/node:assert/package.json"] = {
1300
- code: SANDPACK_NODE_ASSERT_PACKAGE_JSON_SHIM,
1301
- hidden: true
1302
- };
1303
- nextFiles["/node_modules/node:assert/index.js"] = {
1304
- code: SANDPACK_NODE_ASSERT_ALIAS_SHIM_INDEX_JS,
1305
- hidden: true
1306
- };
1307
- nextFiles["/node_modules/node:util/package.json"] = {
1308
- code: SANDPACK_NODE_UTIL_PACKAGE_JSON_SHIM,
1309
- hidden: true
1310
- };
1311
- nextFiles["/node_modules/node:util/index.js"] = {
1312
- code: SANDPACK_NODE_UTIL_ALIAS_SHIM_INDEX_JS,
1313
- hidden: true
1314
- };
1315
- nextFiles["/node_modules/node:path/package.json"] = {
1316
- code: SANDPACK_NODE_PATH_PACKAGE_JSON_SHIM,
1317
- hidden: true
1318
- };
1319
- nextFiles["/node_modules/node:path/index.js"] = {
1320
- code: SANDPACK_NODE_PATH_ALIAS_SHIM_INDEX_JS,
1321
- hidden: true
1322
- };
1323
- nextFiles["/node_modules/node:fs/package.json"] = {
1324
- code: SANDPACK_NODE_FS_PACKAGE_JSON_SHIM,
1325
- hidden: true
1326
- };
1327
- nextFiles["/node_modules/node:fs/index.js"] = {
1328
- code: SANDPACK_NODE_FS_ALIAS_SHIM_INDEX_JS,
1329
- hidden: true
1330
- };
1331
- nextFiles["/node_modules/node:process/package.json"] = {
1332
- code: SANDPACK_NODE_PROCESS_PACKAGE_JSON_SHIM,
1333
- hidden: true
1334
- };
1335
- nextFiles["/node_modules/node:process/index.js"] = {
1336
- code: SANDPACK_NODE_PROCESS_ALIAS_SHIM_INDEX_JS,
1337
- hidden: true
1338
- };
1339
- nextFiles["/node_modules/node:fs/promises/package.json"] = {
1340
- code: SANDPACK_NODE_FS_PROMISES_PACKAGE_JSON_SHIM,
1341
- hidden: true
1342
- };
1343
- nextFiles["/node_modules/node:fs/promises/index.js"] = {
1344
- code: SANDPACK_NODE_FS_PROMISES_ALIAS_SHIM_INDEX_JS,
1345
- hidden: true
1346
- };
1347
- }
1348
- if (shouldShimSandpackReact) {
1349
- nextFiles["/node_modules/@codesandbox/sandpack-react/index.js"] = {
1350
- code: SANDPACK_SANDBOX_SANDPACK_REACT_SHIM_INDEX_JS,
1351
- hidden: true
1352
- };
1353
- }
1354
- if (shouldShimTiptap) {
1355
- nextFiles["/node_modules/@seedgrid/fe-components/dist/inputs/SgTextEditor.js"] = {
1356
- code: SANDPACK_SEEDGRID_TEXT_EDITOR_SHIM_INDEX_JS,
1357
- hidden: true
1358
- };
1359
- nextFiles["/node_modules/@seedgrid/fe-components/dist/inputs/SgTextEditor.mjs"] = {
1360
- code: SANDPACK_SEEDGRID_TEXT_EDITOR_SHIM_INDEX_JS,
1361
- hidden: true
1362
- };
1363
- nextFiles["/node_modules/@tiptap/react/package.json"] = {
1364
- code: JSON.stringify({ name: "@tiptap/react", version: "0.0.0-shim", main: "index.js", module: "index.mjs" }),
1365
- hidden: true
1366
- };
1367
- nextFiles["/node_modules/@tiptap/react/index.js"] = {
1368
- code: SANDPACK_TIPTAP_REACT_SHIM_INDEX_JS,
1369
- hidden: true
1370
- };
1371
- nextFiles["/node_modules/@tiptap/react/index.mjs"] = {
1372
- code: SANDPACK_TIPTAP_REACT_SHIM_INDEX_JS,
1373
- hidden: true
1374
- };
1375
- for (const packageName of TIPTAP_SHIM_PACKAGES) {
1376
- nextFiles[`/node_modules/${packageName}/package.json`] = {
1377
- code: JSON.stringify({ name: packageName, version: "0.0.0-shim", main: "index.js", module: "index.mjs" }),
1378
- hidden: true
1379
- };
1380
- nextFiles[`/node_modules/${packageName}/index.js`] = {
1381
- code: SANDPACK_TIPTAP_EXTENSION_SHIM_INDEX_JS,
1382
- hidden: true
1383
- };
1384
- nextFiles[`/node_modules/${packageName}/index.mjs`] = {
1385
- code: SANDPACK_TIPTAP_EXTENSION_SHIM_INDEX_JS,
1386
- hidden: true
1387
- };
1388
- }
1389
- }
1390
- if (shouldShimLucide) {
1391
- nextFiles["/node_modules/lucide-react/package.json"] = {
1392
- code: JSON.stringify({ name: "lucide-react", version: "0.0.0-shim", main: "index.js" }),
1393
- hidden: true
1394
- };
1395
- nextFiles["/node_modules/lucide-react/index.js"] = {
1396
- code: SANDPACK_LUCIDE_REACT_SHIM_INDEX_JS,
1397
- hidden: true
1398
- };
1399
- }
1400
- return nextFiles;
1401
- }, [
1402
- appTsx,
1403
- effectivePreviewPadding,
1404
- includeSeedgridDependency,
1405
- sandpackStylesCss,
1406
- shouldIncludeNodePolyfills,
1407
- shouldShimLucide,
1408
- shouldShimSandpackReact,
1409
- shouldShimTiptap
1410
- ]);
1411
- const deps = React.useMemo(() => ({
1412
- ...DEFAULT_SANDBOX_BASE_DEPENDENCIES,
1413
- ...(includeSeedgridDependency ? DEFAULT_SEEDGRID_RUNTIME_DEPENDENCIES : {}),
1414
- ...(includeSeedgridDependency && !shouldShimLucide ? { "lucide-react": "^0.468.0" } : {}),
1415
- ...(includeEditorDependencies ? DEFAULT_SEEDGRID_EDITOR_DEPENDENCIES : {}),
1416
- ...(includeSandpackReactDependency ? DEFAULT_SANDBOX_HOST_DEPENDENCIES : {}),
1417
- ...(shouldIncludeNodePolyfills ? DEFAULT_SANDPACK_POLYFILLS : {}),
1418
- ...(includeSeedgridDependency ? { "@seedgrid/fe-components": resolvedSeedgridDependency } : {}),
1419
- ...requestedDeps
1420
- }), [
1421
- includeEditorDependencies,
1422
- includeSandpackReactDependency,
1423
- includeSeedgridDependency,
1424
- requestedDeps,
1425
- resolvedSeedgridDependency,
1426
- shouldIncludeNodePolyfills,
1427
- shouldShimLucide
1428
- ]);
1429
- const currentHeight = isExpanded ? expandedHeight : height;
1430
- const resizeClass = !resizable
1431
- ? undefined
1432
- : resizeAxis === "vertical"
1433
- ? "resize-y"
1434
- : resizeAxis === "horizontal"
1435
- ? "resize-x"
1436
- : "resize";
1437
- const sandpackCustomSetup = React.useMemo(() => ({
1438
- dependencies: deps,
1439
- entry: "/index.tsx",
1440
- ...(resolvedNpmRegistries ? { npmRegistries: resolvedNpmRegistries } : {})
1441
- }), [deps, resolvedNpmRegistries]);
1442
- const sandpackOptions = React.useMemo(() => ({
1443
- autorun: false,
1444
- initMode: "lazy",
1445
- bundlerURL: resolvedBundlerURL,
1446
- // Keep both keys while sandpack typings/runtime differ across versions.
1447
- bundlerTimeOut: resolvedBundlerTimeoutMs,
1448
- bundlerTimeout: resolvedBundlerTimeoutMs,
1449
- activeFile: "/App.tsx",
1450
- visibleFiles: ["/App.tsx"],
1451
- externalResources: includeSeedgridDependency ? SANDPACK_EXTERNAL_RESOURCES : []
1452
- }), [includeSeedgridDependency, resolvedBundlerTimeoutMs, resolvedBundlerURL]);
1453
- const content = interactive ? (_jsx("div", { className: cn(withCard ? "" : "rounded-lg border border-border", withCard ? undefined : className), style: withCard ? undefined : style, children: _jsxs(SandpackProvider, { template: "react-ts", files: files, customSetup: sandpackCustomSetup, options: sandpackOptions, theme: sandpackTheme, children: [_jsx("style", { children: SANDPACK_HOST_STYLES_CSS }), _jsxs("div", { className: "flex items-center justify-between border-b border-border px-3 py-2", children: [_jsxs("div", { className: "flex items-center gap-2", children: [withCard ? null : _jsx("span", { className: "text-sm font-medium", children: title ?? "Example" }), _jsx("span", { className: "text-xs text-muted-foreground", children: codeContract === "renderBody" ? "editable snippet" : "editable App.tsx" })] }), _jsxs("div", { className: "flex items-center gap-2", children: [expandable ? (_jsx(SgButton, { appearance: "outline", size: "sm", onClick: () => setIsExpanded((prev) => !prev), children: isExpanded ? "Reduzir" : "Expandir" })) : null, _jsx(RunButton, { onRun: () => setActivePanel("preview") })] })] }), _jsxs("div", { className: "flex md:hidden border-b border-border", children: [_jsx("button", { type: "button", className: cn("flex-1 py-2 text-sm font-medium border-b-2 -mb-px transition-colors", activePanel === "code"
1454
- ? "border-primary text-foreground"
1455
- : "border-transparent text-muted-foreground hover:text-foreground"), onClick: () => setActivePanel("code"), children: "C\u00F3digo" }), _jsx("button", { type: "button", className: cn("flex-1 py-2 text-sm font-medium border-b-2 -mb-px transition-colors", activePanel === "preview"
1456
- ? "border-primary text-foreground"
1457
- : "border-transparent text-muted-foreground hover:text-foreground"), onClick: () => setActivePanel("preview"), children: "Preview" })] }), _jsxs("div", { className: cn("grid overflow-auto min-h-[260px]", "grid-cols-1 md:grid-cols-2", resizeClass), style: { height: currentHeight }, children: [_jsxs("div", { className: cn("min-w-0 md:border-r border-border", activePanel !== "code" ? "hidden md:block" : ""), children: [_jsx(SandpackCodeEditor, { showLineNumbers: true, wrapContent: true, showTabs: false, showRunButton: false, style: { height: "100%" } }), _jsx("div", { className: "flex justify-end border-t border-border px-3 py-2", children: _jsx(CopyButton, {}) })] }), _jsx("div", { className: cn("min-w-0", activePanel !== "preview" ? "hidden md:block" : ""), children: _jsx(SandpackPreview, { className: "sg-playground-preview", style: { height: "100%" }, showOpenInCodeSandbox: false, showRefreshButton: false, showRestartButton: false }) })] })] }) })) : (_jsxs("div", { className: cn(withCard ? undefined : "space-y-2", withCard ? undefined : className), style: withCard ? undefined : style, children: [withCard ? null : title ? _jsx("div", { className: "text-sm font-medium", children: title }) : null, _jsx(ReadonlyBlock, { code: code })] }));
1458
- if (!withCard)
1459
- return content;
1460
- return (_jsx(SgCard, { id: cardId, title: title ?? "Codigo", description: description, collapsible: collapsible, defaultOpen: defaultOpen, className: cn("rounded-lg", className), style: style, bodyClassName: "p-0", children: content }));
1461
- }