@seedgrid/fe-playground 2026.11.0 → 2026.11.2

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 +1 @@
1
- {"version":3,"file":"SgPlayground.d.ts","sourceRoot":"","sources":["../src/SgPlayground.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAc/B,KAAK,uBAAuB,GAAG;IAC7B,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,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,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,E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AC,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,2CAuoBtE"}
@@ -655,6 +655,9 @@ body {
655
655
  .size-4 { width: 1rem; height: 1rem; }
656
656
  .size-5 { width: 1.25rem; height: 1.25rem; }
657
657
  `;
658
+ // Responsive layout of the playground (code | preview). It lives here, not in Tailwind utilities, because
659
+ // consumers' Tailwind builds only generate classes found in THEIR content globs: with `md:block` etc. missing,
660
+ // the code panel hidden by Run on small screens never came back on desktop ("code disappears after Run").
658
661
  const SANDPACK_HOST_STYLES_CSS = `
659
662
  .sg-playground-preview .sp-cube-wrapper {
660
663
  top: 8px !important;
@@ -662,6 +665,21 @@ const SANDPACK_HOST_STYLES_CSS = `
662
665
  bottom: auto !important;
663
666
  left: auto !important;
664
667
  }
668
+ .sg-pg-tabs { display: flex; }
669
+ .sg-pg-grid {
670
+ display: grid;
671
+ grid-template-columns: minmax(0, 1fr);
672
+ min-height: 260px;
673
+ overflow: auto;
674
+ }
675
+ .sg-pg-panel { min-width: 0; }
676
+ .sg-pg-panel[data-mobile-hidden="true"] { display: none; }
677
+ @media (min-width: 768px) {
678
+ .sg-pg-tabs { display: none; }
679
+ .sg-pg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
680
+ .sg-pg-panel[data-mobile-hidden="true"] { display: block; }
681
+ .sg-pg-code { border-right-width: 1px; border-right-style: solid; }
682
+ }
665
683
  `;
666
684
  // Keep CRA's expected HTML entry file path for react/react-ts templates.
667
685
  const SANDPACK_TAILWIND_INDEX_HTML = `<!DOCTYPE html>
@@ -1008,6 +1026,25 @@ function CopyButton() {
1008
1026
  }, [copyState]);
1009
1027
  return (_jsx(SgButton, { appearance: "outline", size: "sm", onClick: handleCopy, children: copyState === "success" ? "Copiado" : copyState === "error" ? "Erro" : "Copiar" }));
1010
1028
  }
1029
+ /**
1030
+ * Pushes host theme/CSS changes into the sandbox without touching the user-edited files.
1031
+ * SandpackProvider resets EVERY file to the `files` prop whenever that prop changes identity, so
1032
+ * keeping the (host-dependent) stylesheet inside `files` made any theme/style mutation of <html>
1033
+ * wipe the code the user had typed. The stylesheet is now seeded once and kept in sync via updateFile.
1034
+ */
1035
+ function StylesSync({ css }) {
1036
+ const { sandpack } = useSandpack();
1037
+ const updateFileRef = React.useRef(sandpack.updateFile);
1038
+ updateFileRef.current = sandpack.updateFile;
1039
+ const lastCssRef = React.useRef(css);
1040
+ React.useEffect(() => {
1041
+ if (lastCssRef.current === css)
1042
+ return;
1043
+ lastCssRef.current = css;
1044
+ updateFileRef.current("/styles.css", css);
1045
+ }, [css]);
1046
+ return null;
1047
+ }
1011
1048
  function RunButton({ onRun }) {
1012
1049
  const { sandpack } = useSandpack();
1013
1050
  const [running, setRunning] = React.useState(false);
@@ -1209,10 +1246,14 @@ export default function SgPlayground(props) {
1209
1246
  console.warn = originalWarn;
1210
1247
  };
1211
1248
  }, [shouldIncludeNodePolyfills]);
1249
+ // Seed value only: later changes reach the sandbox through <StylesSync/> so they never reset the editor.
1250
+ const initialStylesCssRef = React.useRef(sandpackStylesCss);
1212
1251
  const files = React.useMemo(() => {
1213
1252
  const nextFiles = {
1214
1253
  "/App.tsx": { code: appTsx, active: true },
1215
- "/styles.css": { code: sandpackStylesCss || buildSandpackStylesCss({}, effectivePreviewPadding) }
1254
+ "/styles.css": {
1255
+ code: initialStylesCssRef.current || buildSandpackStylesCss({}, effectivePreviewPadding)
1256
+ }
1216
1257
  };
1217
1258
  if (includeSeedgridDependency) {
1218
1259
  // Intercept the package entry point and redirect to the pre-compiled sandbox bundle
@@ -1434,7 +1475,6 @@ export default function SgPlayground(props) {
1434
1475
  appTsx,
1435
1476
  effectivePreviewPadding,
1436
1477
  includeSeedgridDependency,
1437
- sandpackStylesCss,
1438
1478
  shouldIncludeNodePolyfills,
1439
1479
  shouldShimLucide,
1440
1480
  shouldShimSandpackReact,
@@ -1482,11 +1522,11 @@ export default function SgPlayground(props) {
1482
1522
  visibleFiles: ["/App.tsx"],
1483
1523
  externalResources: includeSeedgridDependency ? SANDPACK_EXTERNAL_RESOURCES : []
1484
1524
  }), [includeSeedgridDependency, resolvedBundlerTimeoutMs, resolvedBundlerURL]);
1485
- 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"
1525
+ 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 }), _jsx(StylesSync, { css: sandpackStylesCss }), _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: "sg-pg-tabs 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"
1486
1526
  ? "border-primary text-foreground"
1487
1527
  : "border-transparent text-muted-foreground hover:text-foreground"), onClick: () => setActivePanel("code"), children: "C\u00C3\u00B3digo" }), _jsx("button", { type: "button", className: cn("flex-1 py-2 text-sm font-medium border-b-2 -mb-px transition-colors", activePanel === "preview"
1488
1528
  ? "border-primary text-foreground"
1489
- : "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: resolvedCode })] }));
1529
+ : "border-transparent text-muted-foreground hover:text-foreground"), onClick: () => setActivePanel("preview"), children: "Preview" })] }), _jsxs("div", { className: cn("sg-pg-grid", resizeClass), style: { height: currentHeight }, children: [_jsxs("div", { className: "sg-pg-panel sg-pg-code border-border", "data-mobile-hidden": activePanel !== "code" ? "true" : "false", 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: "sg-pg-panel", "data-mobile-hidden": activePanel !== "preview" ? "true" : "false", 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: resolvedCode })] }));
1490
1530
  if (!withCard)
1491
1531
  return content;
1492
1532
  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 }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seedgrid/fe-playground",
3
- "version": "2026.11.0",
3
+ "version": "2026.11.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -38,7 +38,7 @@
38
38
  "react": "19.0.0",
39
39
  "react-dom": "19.0.0",
40
40
  "typescript": "^5.5.4",
41
- "@seedgrid/fe-components": "2026.11.0"
41
+ "@seedgrid/fe-components": "2026.11.2"
42
42
  },
43
43
  "scripts": {
44
44
  "clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",