@seedgrid/fe-components 2026.3.2-5 → 2026.3.2-7

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.
@@ -2,6 +2,7 @@ export type SgPlaygroundProps = {
2
2
  code: string;
3
3
  interactive?: boolean;
4
4
  codeContract?: "renderBody" | "appFile";
5
+ preset?: SgPlaygroundPreset;
5
6
  title?: string;
6
7
  description?: string;
7
8
  height?: number | string;
@@ -15,10 +16,21 @@ export type SgPlaygroundProps = {
15
16
  defaultImports?: string;
16
17
  previewWrapperClassName?: string;
17
18
  seedgridDependency?: string;
19
+ bundlerURL?: string;
20
+ bundlerTimeoutMs?: number;
21
+ npmRegistries?: SgPlaygroundNpmRegistry[];
18
22
  withCard?: boolean;
19
23
  collapsible?: boolean;
20
24
  defaultOpen?: boolean;
21
25
  cardId?: string;
22
26
  };
27
+ export type SgPlaygroundPreset = "auto" | "basic" | "seedgrid" | "editor" | "full";
28
+ export type SgPlaygroundNpmRegistry = {
29
+ enabledScopes: string[];
30
+ limitToScopes: boolean;
31
+ registryUrl: string;
32
+ proxyEnabled: boolean;
33
+ registryAuthToken?: string;
34
+ };
23
35
  export default function SgPlayground(props: Readonly<SgPlaygroundProps>): import("react/jsx-runtime").JSX.Element;
24
36
  //# sourceMappingURL=SgPlayground.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SgPlayground.d.ts","sourceRoot":"","sources":["../../src/others/SgPlayground.tsx"],"names":[],"mappings":"AAiBA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,GAAG,YAAY,GAAG,MAAM,CAAC;IAChD,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAimBF,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,2CAyPtE"}
1
+ {"version":3,"file":"SgPlayground.d.ts","sourceRoot":"","sources":["../../src/others/SgPlayground.tsx"],"names":[],"mappings":"AAsBA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACxC,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,GAAG,YAAY,GAAG,MAAM,CAAC;IAChD,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC;AACnF,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AA6sBF,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,2CAyXtE"}
@@ -4,14 +4,26 @@ import * as React from "react";
4
4
  import { SandpackCodeEditor, SandpackPreview, SandpackProvider, useSandpack } from "@codesandbox/sandpack-react";
5
5
  import { SgButton } from "../buttons/SgButton";
6
6
  import { SgCard } from "../layout/SgCard";
7
+ import blockedEmailDomainsConfig from "../blocked-email-domains.json";
8
+ import componentsMessagesEnUsJson from "../i18n/en-US.json";
9
+ import componentsMessagesEsJson from "../i18n/es.json";
10
+ import componentsMessagesPtBrJson from "../i18n/pt-BR.json";
11
+ import componentsMessagesPtPtJson from "../i18n/pt-PT.json";
7
12
  function cn(...parts) {
8
13
  return parts.filter(Boolean).join(" ");
9
14
  }
10
15
  const DEFAULT_SEEDGRID_DEPENDENCY = "latest";
11
- const DEFAULT_SEEDGRID_PEER_DEPENDENCIES = {
12
- "@codesandbox/sandpack-react": "^2.20.0",
16
+ const DEFAULT_SANDPACK_BUNDLER_URL = "https://sandpack.seedgrid.com.br";
17
+ const DEFAULT_SANDPACK_BUNDLER_TIMEOUT_MS = 60000;
18
+ const DEFAULT_SANDBOX_BASE_DEPENDENCIES = {
19
+ react: "18.2.0",
20
+ "react-dom": "18.2.0"
21
+ };
22
+ const DEFAULT_SEEDGRID_RUNTIME_DEPENDENCIES = {
13
23
  "react-hook-form": "^7.0.0",
14
- "lucide-react": "^0.468.0",
24
+ "lucide-react": "^0.468.0"
25
+ };
26
+ const DEFAULT_SEEDGRID_EDITOR_DEPENDENCIES = {
15
27
  "@tiptap/core": "^2.9.1",
16
28
  "@tiptap/react": "^2.9.1",
17
29
  "@tiptap/pm": "^2.9.1",
@@ -27,25 +39,33 @@ const DEFAULT_SEEDGRID_PEER_DEPENDENCIES = {
27
39
  "@tiptap/extension-superscript": "^2.9.1",
28
40
  "@tiptap/extension-font-family": "^2.9.1"
29
41
  };
42
+ const DEFAULT_SANDBOX_HOST_DEPENDENCIES = {
43
+ "@codesandbox/sandpack-react": "^2.20.0"
44
+ };
30
45
  const DEFAULT_SANDPACK_POLYFILLS = {
31
46
  assert: "^2.1.0",
32
47
  process: "^0.11.10",
33
48
  util: "^0.12.5"
34
49
  };
50
+ const TIPTAP_SHIM_PACKAGES = [
51
+ "@tiptap/core",
52
+ "@tiptap/pm",
53
+ "@tiptap/starter-kit",
54
+ "@tiptap/extension-underline",
55
+ "@tiptap/extension-link",
56
+ "@tiptap/extension-image",
57
+ "@tiptap/extension-text-align",
58
+ "@tiptap/extension-text-style",
59
+ "@tiptap/extension-color",
60
+ "@tiptap/extension-highlight",
61
+ "@tiptap/extension-subscript",
62
+ "@tiptap/extension-superscript",
63
+ "@tiptap/extension-font-family"
64
+ ];
35
65
  const SANDPACK_EXTERNAL_RESOURCES = [
36
66
  // Prebuilt utility CSS so classes from @seedgrid/fe-components can render inside Sandpack
37
67
  "https://unpkg.com/tailwindcss@2.2.19/dist/tailwind.min.css"
38
68
  ];
39
- const SANDPACK_QRCODE_SHIM_PACKAGE_JSON = `{
40
- "name": "qrcode",
41
- "version": "0.0.0-sandpack-shim",
42
- "type": "module",
43
- "main": "./index.js",
44
- "module": "./index.js",
45
- "exports": {
46
- ".": "./index.js"
47
- }
48
- }`;
49
69
  const SANDPACK_QRCODE_SHIM_INDEX_JS = `const makeError = () =>
50
70
  new Error(
51
71
  "qrcode (node build) is not supported in Sandpack browser runtime. Update @seedgrid/fe-components to a browser-safe QR implementation."
@@ -67,11 +87,38 @@ const SANDPACK_MARKDOWN_IT_BIN_SHIM = `import markdownit from "../index.mjs";
67
87
  export default markdownit;
68
88
  export { markdownit };
69
89
  `;
70
- const SANDPACK_ASSERT_SHIM_PACKAGE_JSON = `{
71
- "name": "assert",
72
- "version": "0.0.0-sandpack-shim",
73
- "main": "./index.js"
74
- }`;
90
+ const SANDPACK_SANDBOX_SANDPACK_REACT_SHIM_INDEX_JS = `export const SandpackProvider = ({ children }) => children ?? null;
91
+ export const SandpackCodeEditor = () => null;
92
+ export const SandpackPreview = () => null;
93
+ export const useSandpack = () => ({
94
+ sandpack: {
95
+ activeFile: "/App.tsx",
96
+ files: { "/App.tsx": { code: "" } },
97
+ runSandpack: async () => {},
98
+ clients: {},
99
+ status: "idle"
100
+ },
101
+ dispatch: () => {},
102
+ listen: () => () => {}
103
+ });
104
+ export default {};
105
+ `;
106
+ const SANDPACK_TIPTAP_REACT_SHIM_INDEX_JS = `export const EditorContent = () => null;
107
+ export const BubbleMenu = () => null;
108
+ export const FloatingMenu = () => null;
109
+ export const useEditor = () => null;
110
+ export default {};
111
+ `;
112
+ const SANDPACK_TIPTAP_EXTENSION_SHIM_INDEX_JS = `const extension = {
113
+ configure() {
114
+ return extension;
115
+ },
116
+ extend() {
117
+ return extension;
118
+ }
119
+ };
120
+ export default extension;
121
+ `;
75
122
  const SANDPACK_ASSERT_SHIM_INDEX_JS = `function fail(message) {
76
123
  throw new Error(message || "Assertion failed");
77
124
  }
@@ -112,11 +159,6 @@ assert.fail = fail;
112
159
  module.exports = assert;
113
160
  module.exports.default = assert;
114
161
  `;
115
- const SANDPACK_UTIL_SHIM_PACKAGE_JSON = `{
116
- "name": "util",
117
- "version": "0.0.0-sandpack-shim",
118
- "main": "./index.js"
119
- }`;
120
162
  const SANDPACK_UTIL_SHIM_INDEX_JS = `const inspect = function inspect(value) {
121
163
  try {
122
164
  return JSON.stringify(value);
@@ -150,11 +192,6 @@ const utilShim = { inspect, deprecate, format };
150
192
  module.exports = utilShim;
151
193
  module.exports.default = utilShim;
152
194
  `;
153
- const SANDPACK_PATH_SHIM_PACKAGE_JSON = `{
154
- "name": "path",
155
- "version": "0.0.0-sandpack-shim",
156
- "main": "./index.js"
157
- }`;
158
195
  const SANDPACK_PATH_SHIM_INDEX_JS = `function normalize(input) {
159
196
  return String(input || "").replace(/\\\\/g, "/");
160
197
  }
@@ -197,11 +234,6 @@ const pathShim = {
197
234
  module.exports = pathShim;
198
235
  module.exports.default = pathShim;
199
236
  `;
200
- const SANDPACK_FS_SHIM_PACKAGE_JSON = `{
201
- "name": "fs",
202
- "version": "0.0.0-sandpack-shim",
203
- "main": "./index.js"
204
- }`;
205
237
  const SANDPACK_FS_SHIM_INDEX_JS = `function notSupported(name) {
206
238
  throw new Error("fs." + name + " is not supported in Sandpack browser runtime.");
207
239
  }
@@ -216,11 +248,6 @@ const fsShim = {
216
248
  module.exports = fsShim;
217
249
  module.exports.default = fsShim;
218
250
  `;
219
- const SANDPACK_PROCESS_SHIM_PACKAGE_JSON = `{
220
- "name": "process",
221
- "version": "0.0.0-sandpack-shim",
222
- "main": "./index.js"
223
- }`;
224
251
  const SANDPACK_PROCESS_SHIM_INDEX_JS = `const processShim = {
225
252
  env: {},
226
253
  argv: ["browser"],
@@ -314,6 +341,78 @@ body {
314
341
  .size-4 { width: 1rem; height: 1rem; }
315
342
  .size-5 { width: 1.25rem; height: 1.25rem; }
316
343
  `;
344
+ const SANDPACK_HOST_STYLES_CSS = `
345
+ .sg-playground-preview .sp-cube-wrapper {
346
+ top: 8px !important;
347
+ right: 8px !important;
348
+ bottom: auto !important;
349
+ left: auto !important;
350
+ }
351
+ `;
352
+ function normalizeUrl(raw, fallback) {
353
+ const value = raw?.trim();
354
+ if (!value)
355
+ return fallback;
356
+ try {
357
+ const parsed = new URL(value);
358
+ return parsed.toString().replace(/\/+$/, "");
359
+ }
360
+ catch {
361
+ return fallback;
362
+ }
363
+ }
364
+ function normalizeTimeoutMs(value, fallback) {
365
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
366
+ return fallback;
367
+ }
368
+ return Math.round(value);
369
+ }
370
+ function parseBooleanFlag(value, fallback) {
371
+ const normalized = value?.trim().toLowerCase();
372
+ if (!normalized)
373
+ return fallback;
374
+ if (normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on") {
375
+ return true;
376
+ }
377
+ if (normalized === "0" || normalized === "false" || normalized === "no" || normalized === "off") {
378
+ return false;
379
+ }
380
+ return fallback;
381
+ }
382
+ function resolveDefaultNpmRegistriesFromEnv() {
383
+ const registryUrlRaw = process.env.NEXT_PUBLIC_SANDPACK_NPM_REGISTRY_URL?.trim();
384
+ if (!registryUrlRaw)
385
+ return undefined;
386
+ const scopesRaw = process.env.NEXT_PUBLIC_SANDPACK_NPM_REGISTRY_SCOPES;
387
+ const enabledScopes = (scopesRaw ?? "@seedgrid")
388
+ .split(",")
389
+ .map((scope) => scope.trim())
390
+ .filter(Boolean);
391
+ const limitToScopes = parseBooleanFlag(process.env.NEXT_PUBLIC_SANDPACK_NPM_REGISTRY_LIMIT_TO_SCOPES, true);
392
+ const proxyEnabled = parseBooleanFlag(process.env.NEXT_PUBLIC_SANDPACK_NPM_REGISTRY_PROXY_ENABLED, false);
393
+ const registryAuthToken = process.env.NEXT_PUBLIC_SANDPACK_NPM_REGISTRY_AUTH_TOKEN?.trim();
394
+ return [
395
+ {
396
+ enabledScopes,
397
+ limitToScopes,
398
+ registryUrl: registryUrlRaw.replace(/\/+$/, ""),
399
+ proxyEnabled,
400
+ ...(registryAuthToken ? { registryAuthToken } : {})
401
+ }
402
+ ];
403
+ }
404
+ function buildCjsJsonModule(value) {
405
+ const serialized = JSON.stringify(value);
406
+ return `const data = ${serialized};
407
+ module.exports = data;
408
+ module.exports.default = data;
409
+ `;
410
+ }
411
+ const SANDPACK_SEEDGRID_PT_BR_JSON_SHIM = buildCjsJsonModule(componentsMessagesPtBrJson);
412
+ const SANDPACK_SEEDGRID_PT_PT_JSON_SHIM = buildCjsJsonModule(componentsMessagesPtPtJson);
413
+ const SANDPACK_SEEDGRID_EN_US_JSON_SHIM = buildCjsJsonModule(componentsMessagesEnUsJson);
414
+ const SANDPACK_SEEDGRID_ES_JSON_SHIM = buildCjsJsonModule(componentsMessagesEsJson);
415
+ const SANDPACK_SEEDGRID_BLOCKED_EMAIL_DOMAINS_JSON_SHIM = buildCjsJsonModule(blockedEmailDomainsConfig);
317
416
  function parseRgbParts(raw) {
318
417
  const value = raw.trim();
319
418
  if (!value)
@@ -552,7 +651,7 @@ function RunButton({ onRun }) {
552
651
  return (_jsx(SgButton, { severity: "primary", size: "sm", loading: running, onClick: handleRun, children: running ? "Running" : "Run" }));
553
652
  }
554
653
  export default function SgPlayground(props) {
555
- const { code, interactive = false, codeContract = "renderBody", title, description, height = 360, expandedHeight = "70vh", expandable = true, resizable = true, resizeAxis = "vertical", previewPadding, className, dependencies, defaultImports, previewWrapperClassName = "h-[420px] rounded-xl border border-border bg-muted/30 p-3", seedgridDependency, withCard = true, collapsible = true, defaultOpen = true, cardId } = props;
654
+ const { code, interactive = false, codeContract = "renderBody", preset = "auto", title, description, height = 360, expandedHeight = "70vh", expandable = true, resizable = true, resizeAxis = "vertical", previewPadding, className, 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;
556
655
  const effectivePreviewPadding = normalizeCssSize(previewPadding ?? (codeContract === "appFile" ? 12 : 0));
557
656
  const [sandpackStylesCss, setSandpackStylesCss] = React.useState(() => buildSandpackStylesCss({}, effectivePreviewPadding));
558
657
  const [isExpanded, setIsExpanded] = React.useState(false);
@@ -602,36 +701,121 @@ export default function SgPlayground(props) {
602
701
  const resolvedSeedgridDependency = seedgridDependency ??
603
702
  process.env.NEXT_PUBLIC_SANDPACK_SEEDGRID_DEPENDENCY ??
604
703
  DEFAULT_SEEDGRID_DEPENDENCY;
704
+ const requestedDeps = dependencies ?? {};
705
+ const requestedDepKeys = Object.keys(requestedDeps);
706
+ const resolvedBundlerURL = normalizeUrl(bundlerURL ?? process.env.NEXT_PUBLIC_SANDPACK_BUNDLER_URL, DEFAULT_SANDPACK_BUNDLER_URL);
707
+ const resolvedBundlerTimeoutMs = normalizeTimeoutMs(bundlerTimeoutMs ??
708
+ Number(process.env.NEXT_PUBLIC_SANDPACK_BUNDLER_TIMEOUT_MS ?? Number.NaN), DEFAULT_SANDPACK_BUNDLER_TIMEOUT_MS);
709
+ const resolvedNpmRegistries = React.useMemo(() => npmRegistries ?? resolveDefaultNpmRegistriesFromEnv(), [npmRegistries]);
710
+ React.useEffect(() => {
711
+ if (!interactive)
712
+ return;
713
+ if (!parseBooleanFlag(process.env.NEXT_PUBLIC_SANDPACK_DEBUG, false))
714
+ return;
715
+ console.info("[SgPlayground] Sandpack runtime config", {
716
+ bundlerURL: resolvedBundlerURL,
717
+ bundlerTimeoutMs: resolvedBundlerTimeoutMs,
718
+ npmRegistries: (resolvedNpmRegistries ?? []).map((registry) => ({
719
+ enabledScopes: registry.enabledScopes,
720
+ limitToScopes: registry.limitToScopes,
721
+ registryUrl: registry.registryUrl,
722
+ proxyEnabled: registry.proxyEnabled
723
+ }))
724
+ });
725
+ }, [interactive, resolvedBundlerTimeoutMs, resolvedBundlerURL, resolvedNpmRegistries]);
726
+ const codeUsesSeedgrid = /from\s+["']@seedgrid\/fe-components["']/.test(appTsx);
727
+ const codeUsesTextEditor = /\bSgTextEditor\b/.test(appTsx);
728
+ const codeUsesPlaygroundComponent = /\bSgPlayground\b/.test(appTsx);
729
+ const resolvedPreset = preset === "auto"
730
+ ? codeUsesTextEditor
731
+ ? "editor"
732
+ : codeUsesSeedgrid
733
+ ? "seedgrid"
734
+ : "basic"
735
+ : preset;
736
+ const includeSeedgridDependency = resolvedPreset === "seedgrid" ||
737
+ resolvedPreset === "editor" ||
738
+ resolvedPreset === "full" ||
739
+ requestedDepKeys.includes("@seedgrid/fe-components");
740
+ const includeEditorDependencies = resolvedPreset === "editor" ||
741
+ resolvedPreset === "full" ||
742
+ codeUsesTextEditor ||
743
+ requestedDepKeys.some((dep) => dep.startsWith("@tiptap/"));
744
+ const includeSandpackReactDependency = resolvedPreset === "full" ||
745
+ codeUsesPlaygroundComponent ||
746
+ requestedDepKeys.includes("@codesandbox/sandpack-react");
747
+ const shouldShimSandpackReact = includeSeedgridDependency && !includeSandpackReactDependency;
748
+ const shouldShimTiptap = includeSeedgridDependency && !includeEditorDependencies;
749
+ const shouldIncludeNodePolyfills = includeEditorDependencies;
605
750
  const files = {
606
751
  "/App.tsx": { code: appTsx, active: true },
607
- "/styles.css": { code: sandpackStylesCss || buildSandpackStylesCss({}, effectivePreviewPadding) },
752
+ "/styles.css": { code: sandpackStylesCss || buildSandpackStylesCss({}, effectivePreviewPadding) }
753
+ };
754
+ if (includeSeedgridDependency) {
608
755
  // Compatibility shim for legacy @seedgrid/fe-components builds that still import "qrcode" (node-only path).
609
- "/node_modules/qrcode/package.json": { code: SANDPACK_QRCODE_SHIM_PACKAGE_JSON, hidden: true },
610
- "/node_modules/qrcode/index.js": { code: SANDPACK_QRCODE_SHIM_INDEX_JS, hidden: true },
756
+ files["/node_modules/qrcode/index.js"] = { code: SANDPACK_QRCODE_SHIM_INDEX_JS, hidden: true };
757
+ // Sandpack runtime can evaluate JSON files as plain JS modules.
758
+ // Provide CJS-compatible shims to keep @seedgrid/fe-components i18n/validators working.
759
+ files["/node_modules/@seedgrid/fe-components/dist/i18n/pt-BR.json"] = {
760
+ code: SANDPACK_SEEDGRID_PT_BR_JSON_SHIM,
761
+ hidden: true
762
+ };
763
+ files["/node_modules/@seedgrid/fe-components/dist/i18n/pt-PT.json"] = {
764
+ code: SANDPACK_SEEDGRID_PT_PT_JSON_SHIM,
765
+ hidden: true
766
+ };
767
+ files["/node_modules/@seedgrid/fe-components/dist/i18n/en-US.json"] = {
768
+ code: SANDPACK_SEEDGRID_EN_US_JSON_SHIM,
769
+ hidden: true
770
+ };
771
+ files["/node_modules/@seedgrid/fe-components/dist/i18n/es.json"] = {
772
+ code: SANDPACK_SEEDGRID_ES_JSON_SHIM,
773
+ hidden: true
774
+ };
775
+ files["/node_modules/@seedgrid/fe-components/dist/blocked-email-domains.json"] = {
776
+ code: SANDPACK_SEEDGRID_BLOCKED_EMAIL_DOMAINS_JSON_SHIM,
777
+ hidden: true
778
+ };
779
+ }
780
+ if (shouldIncludeNodePolyfills) {
611
781
  // markdown-it CLI entry uses node:fs and breaks in browser runtime.
612
- "/node_modules/markdown-it/bin/markdown-it.mjs": {
782
+ files["/node_modules/markdown-it/bin/markdown-it.mjs"] = {
613
783
  code: SANDPACK_MARKDOWN_IT_BIN_SHIM,
614
784
  hidden: true
615
- },
785
+ };
616
786
  // Node builtin compatibility shims used by transitive dependencies (e.g. argparse from markdown-it/tiptap).
617
- "/node_modules/assert/package.json": { code: SANDPACK_ASSERT_SHIM_PACKAGE_JSON, hidden: true },
618
- "/node_modules/assert/index.js": { code: SANDPACK_ASSERT_SHIM_INDEX_JS, hidden: true },
619
- "/node_modules/util/package.json": { code: SANDPACK_UTIL_SHIM_PACKAGE_JSON, hidden: true },
620
- "/node_modules/util/index.js": { code: SANDPACK_UTIL_SHIM_INDEX_JS, hidden: true },
621
- "/node_modules/path/package.json": { code: SANDPACK_PATH_SHIM_PACKAGE_JSON, hidden: true },
622
- "/node_modules/path/index.js": { code: SANDPACK_PATH_SHIM_INDEX_JS, hidden: true },
623
- "/node_modules/fs/package.json": { code: SANDPACK_FS_SHIM_PACKAGE_JSON, hidden: true },
624
- "/node_modules/fs/index.js": { code: SANDPACK_FS_SHIM_INDEX_JS, hidden: true },
625
- "/node_modules/process/package.json": { code: SANDPACK_PROCESS_SHIM_PACKAGE_JSON, hidden: true },
626
- "/node_modules/process/index.js": { code: SANDPACK_PROCESS_SHIM_INDEX_JS, hidden: true }
627
- };
787
+ files["/node_modules/assert/index.js"] = { code: SANDPACK_ASSERT_SHIM_INDEX_JS, hidden: true };
788
+ files["/node_modules/util/index.js"] = { code: SANDPACK_UTIL_SHIM_INDEX_JS, hidden: true };
789
+ files["/node_modules/path/index.js"] = { code: SANDPACK_PATH_SHIM_INDEX_JS, hidden: true };
790
+ files["/node_modules/fs/index.js"] = { code: SANDPACK_FS_SHIM_INDEX_JS, hidden: true };
791
+ files["/node_modules/process/index.js"] = { code: SANDPACK_PROCESS_SHIM_INDEX_JS, hidden: true };
792
+ }
793
+ if (shouldShimSandpackReact) {
794
+ files["/node_modules/@codesandbox/sandpack-react/index.js"] = {
795
+ code: SANDPACK_SANDBOX_SANDPACK_REACT_SHIM_INDEX_JS,
796
+ hidden: true
797
+ };
798
+ }
799
+ if (shouldShimTiptap) {
800
+ files["/node_modules/@tiptap/react/index.js"] = {
801
+ code: SANDPACK_TIPTAP_REACT_SHIM_INDEX_JS,
802
+ hidden: true
803
+ };
804
+ for (const packageName of TIPTAP_SHIM_PACKAGES) {
805
+ files[`/node_modules/${packageName}/index.js`] = {
806
+ code: SANDPACK_TIPTAP_EXTENSION_SHIM_INDEX_JS,
807
+ hidden: true
808
+ };
809
+ }
810
+ }
628
811
  const deps = {
629
- react: "^19.0.0",
630
- "react-dom": "^19.0.0",
631
- ...DEFAULT_SANDPACK_POLYFILLS,
632
- ...DEFAULT_SEEDGRID_PEER_DEPENDENCIES,
633
- "@seedgrid/fe-components": resolvedSeedgridDependency,
634
- ...(dependencies ?? {})
812
+ ...DEFAULT_SANDBOX_BASE_DEPENDENCIES,
813
+ ...(includeSeedgridDependency ? DEFAULT_SEEDGRID_RUNTIME_DEPENDENCIES : {}),
814
+ ...(includeEditorDependencies ? DEFAULT_SEEDGRID_EDITOR_DEPENDENCIES : {}),
815
+ ...(includeSandpackReactDependency ? DEFAULT_SANDBOX_HOST_DEPENDENCIES : {}),
816
+ ...(shouldIncludeNodePolyfills ? DEFAULT_SANDPACK_POLYFILLS : {}),
817
+ ...(includeSeedgridDependency ? { "@seedgrid/fe-components": resolvedSeedgridDependency } : {}),
818
+ ...requestedDeps
635
819
  };
636
820
  const currentHeight = isExpanded ? expandedHeight : height;
637
821
  const resizeClass = !resizable
@@ -641,21 +825,27 @@ export default function SgPlayground(props) {
641
825
  : resizeAxis === "horizontal"
642
826
  ? "resize-x"
643
827
  : "resize";
644
- const content = interactive ? (_jsx("div", { className: cn(withCard ? "" : "rounded-lg border border-border", withCard ? undefined : className), children: _jsxs(SandpackProvider, { template: "react-ts", files: files, customSetup: { dependencies: deps }, options: {
645
- autorun: false,
646
- initMode: "lazy",
647
- bundlerURL: "https://sandpack.seedgrid.com.br",
648
- // Keep both keys while sandpack typings/runtime differ across versions.
649
- bundlerTimeOut: 60000,
650
- bundlerTimeout: 60000,
651
- activeFile: "/App.tsx",
652
- visibleFiles: ["/App.tsx"],
653
- externalResources: SANDPACK_EXTERNAL_RESOURCES
654
- }, children: [_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"
828
+ const sandpackCustomSetup = React.useMemo(() => ({
829
+ dependencies: deps,
830
+ entry: "/index.tsx",
831
+ ...(resolvedNpmRegistries ? { npmRegistries: resolvedNpmRegistries } : {})
832
+ }), [deps, resolvedNpmRegistries]);
833
+ const sandpackOptions = React.useMemo(() => ({
834
+ autorun: false,
835
+ initMode: "lazy",
836
+ bundlerURL: resolvedBundlerURL,
837
+ // Keep both keys while sandpack typings/runtime differ across versions.
838
+ bundlerTimeOut: resolvedBundlerTimeoutMs,
839
+ bundlerTimeout: resolvedBundlerTimeoutMs,
840
+ activeFile: "/App.tsx",
841
+ visibleFiles: ["/App.tsx"],
842
+ externalResources: SANDPACK_EXTERNAL_RESOURCES
843
+ }), [resolvedBundlerTimeoutMs, resolvedBundlerURL]);
844
+ const content = interactive ? (_jsx("div", { className: cn(withCard ? "" : "rounded-lg border border-border", withCard ? undefined : className), children: _jsxs(SandpackProvider, { template: "react-ts", files: files, customSetup: sandpackCustomSetup, options: sandpackOptions, 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"
655
845
  ? "border-primary text-foreground"
656
846
  : "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"
657
847
  ? "border-primary text-foreground"
658
- : "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, { style: { height: "100%" }, showOpenInCodeSandbox: false, showRefreshButton: false, showRestartButton: false }) })] })] }) })) : (_jsxs("div", { className: cn(withCard ? undefined : "space-y-2", withCard ? undefined : className), children: [withCard ? null : title ? _jsx("div", { className: "text-sm font-medium", children: title }) : null, _jsx(ReadonlyBlock, { code: code })] }));
848
+ : "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), children: [withCard ? null : title ? _jsx("div", { className: "text-sm font-medium", children: title }) : null, _jsx(ReadonlyBlock, { code: code })] }));
659
849
  if (!withCard)
660
850
  return content;
661
851
  return (_jsx(SgCard, { id: cardId, title: title ?? "Codigo", description: description, collapsible: collapsible, defaultOpen: defaultOpen, className: cn("rounded-lg", className), bodyClassName: "p-0", children: content }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seedgrid/fe-components",
3
- "version": "2026.3.2-5",
3
+ "version": "2026.3.2-7",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",