@seedgrid/fe-components 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gadgets/clock/SgClock.js +40 -40
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/others/SgPlayground.d.ts +24 -0
- package/dist/others/SgPlayground.d.ts.map +1 -0
- package/dist/others/SgPlayground.js +388 -0
- package/package.json +57 -54
|
@@ -318,46 +318,46 @@ function DigitalClock({ timezone, locale = "pt-BR", format = "24h", showSeconds
|
|
|
318
318
|
const glossBottom = "after:absolute after:inset-0 after:bg-gradient-to-t after:from-black/30 after:to-transparent after:content-['']";
|
|
319
319
|
const Colon = () => (_jsxs("div", { className: "flex flex-col items-center justify-center", style: { height: h }, children: [_jsx("div", { className: "h-2 w-2 rounded-full bg-white/80" }), _jsx("div", { className: "mt-2 h-2 w-2 rounded-full bg-white/80" })] }));
|
|
320
320
|
const PeriodCell = ({ value }) => (_jsx("div", { className: cn(panel, glossTop, glossBottom, "flex items-center justify-center"), style: { width: Math.round(w * 1.35), height: h }, children: _jsx("span", { className: "font-semibold text-white/90", style: { fontSize: Math.round(sizePx * 1.05), lineHeight: 1 }, children: value }) }));
|
|
321
|
-
return (_jsxs("div", { className: cn("flex items-center gap-2", className), "aria-label": "Digital clock", children: [_jsx("style", { children: `
|
|
322
|
-
.flip-top {
|
|
323
|
-
background: #1a1a1a;
|
|
324
|
-
border-radius: 8px 8px 0 0;
|
|
325
|
-
animation: sgFlipTop 0.6s cubic-bezier(0.4, 0.0, 0.2, 1) both;
|
|
326
|
-
backface-visibility: hidden;
|
|
327
|
-
transform-style: preserve-3d;
|
|
328
|
-
will-change: transform;
|
|
329
|
-
box-shadow: 0 2px 8px rgba(0,0,0,0.3), inset 0 -2px 4px rgba(0,0,0,0.2);
|
|
330
|
-
}
|
|
331
|
-
.flip-bottom {
|
|
332
|
-
background: #1a1a1a;
|
|
333
|
-
border-radius: 0 0 8px 8px;
|
|
334
|
-
animation: sgFlipBottom 0.6s cubic-bezier(0.4, 0.0, 0.2, 1) both;
|
|
335
|
-
animation-delay: 0.6s;
|
|
336
|
-
backface-visibility: hidden;
|
|
337
|
-
transform-style: preserve-3d;
|
|
338
|
-
will-change: transform;
|
|
339
|
-
box-shadow: 0 -2px 8px rgba(0,0,0,0.3), inset 0 2px 4px rgba(0,0,0,0.2);
|
|
340
|
-
}
|
|
341
|
-
@keyframes sgFlipTop {
|
|
342
|
-
0% {
|
|
343
|
-
transform: rotateX(0deg);
|
|
344
|
-
z-index: 30;
|
|
345
|
-
}
|
|
346
|
-
100% {
|
|
347
|
-
transform: rotateX(-180deg);
|
|
348
|
-
z-index: 5;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
@keyframes sgFlipBottom {
|
|
352
|
-
0% {
|
|
353
|
-
transform: rotateX(180deg);
|
|
354
|
-
z-index: 5;
|
|
355
|
-
}
|
|
356
|
-
100% {
|
|
357
|
-
transform: rotateX(0deg);
|
|
358
|
-
z-index: 30;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
321
|
+
return (_jsxs("div", { className: cn("flex items-center gap-2", className), "aria-label": "Digital clock", children: [_jsx("style", { children: `
|
|
322
|
+
.flip-top {
|
|
323
|
+
background: #1a1a1a;
|
|
324
|
+
border-radius: 8px 8px 0 0;
|
|
325
|
+
animation: sgFlipTop 0.6s cubic-bezier(0.4, 0.0, 0.2, 1) both;
|
|
326
|
+
backface-visibility: hidden;
|
|
327
|
+
transform-style: preserve-3d;
|
|
328
|
+
will-change: transform;
|
|
329
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.3), inset 0 -2px 4px rgba(0,0,0,0.2);
|
|
330
|
+
}
|
|
331
|
+
.flip-bottom {
|
|
332
|
+
background: #1a1a1a;
|
|
333
|
+
border-radius: 0 0 8px 8px;
|
|
334
|
+
animation: sgFlipBottom 0.6s cubic-bezier(0.4, 0.0, 0.2, 1) both;
|
|
335
|
+
animation-delay: 0.6s;
|
|
336
|
+
backface-visibility: hidden;
|
|
337
|
+
transform-style: preserve-3d;
|
|
338
|
+
will-change: transform;
|
|
339
|
+
box-shadow: 0 -2px 8px rgba(0,0,0,0.3), inset 0 2px 4px rgba(0,0,0,0.2);
|
|
340
|
+
}
|
|
341
|
+
@keyframes sgFlipTop {
|
|
342
|
+
0% {
|
|
343
|
+
transform: rotateX(0deg);
|
|
344
|
+
z-index: 30;
|
|
345
|
+
}
|
|
346
|
+
100% {
|
|
347
|
+
transform: rotateX(-180deg);
|
|
348
|
+
z-index: 5;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
@keyframes sgFlipBottom {
|
|
352
|
+
0% {
|
|
353
|
+
transform: rotateX(180deg);
|
|
354
|
+
z-index: 5;
|
|
355
|
+
}
|
|
356
|
+
100% {
|
|
357
|
+
transform: rotateX(0deg);
|
|
358
|
+
z-index: 30;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
361
|
` }), _jsx(FlipDigitCard, { ch: hh.charAt(0), w: w, h: h, digitFont: digitFont }), _jsx(FlipDigitCard, { ch: hh.charAt(1), w: w, h: h, digitFont: digitFont }), _jsx(Colon, {}), _jsx(FlipDigitCard, { ch: mm.charAt(0), w: w, h: h, digitFont: digitFont }), _jsx(FlipDigitCard, { ch: mm.charAt(1), w: w, h: h, digitFont: digitFont }), showSeconds ? (_jsxs(_Fragment, { children: [_jsx(Colon, {}), _jsx(FlipDigitCard, { ch: ss.charAt(0), w: w, h: h, digitFont: digitFont }), _jsx(FlipDigitCard, { ch: ss.charAt(1), w: w, h: h, digitFont: digitFont })] })) : null, format === "12h" && dayPeriod ? _jsx(PeriodCell, { value: dayPeriod.toUpperCase() }) : null] }));
|
|
362
362
|
}
|
|
363
363
|
if (digitalStyle === "roller3d") {
|
package/dist/index.d.ts
CHANGED
|
@@ -61,6 +61,8 @@ export { SgStack } from "./layout/SgStack";
|
|
|
61
61
|
export type { SgStackProps } from "./layout/SgStack";
|
|
62
62
|
export { SgCard } from "./layout/SgCard";
|
|
63
63
|
export type { SgCardProps, SgCardVariant, SgCardSize } from "./layout/SgCard";
|
|
64
|
+
export { default as SgPlayground } from "./others/SgPlayground";
|
|
65
|
+
export type { SgPlaygroundProps } from "./others/SgPlayground";
|
|
64
66
|
export { SgToolBar, SgToolbarIconButton } from "./layout/SgToolBar";
|
|
65
67
|
export type { SgToolBarProps, SgToolBarOrientation, SgToolBarSeverity, SgToolBarSize, SgToolbarIconButtonProps } from "./layout/SgToolBar";
|
|
66
68
|
export { SgDockLayout } from "./layout/SgDockLayout";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,YAAY,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,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Z,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC3G,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,EAC1B,4BAA4B,EAC5B,kCAAkC,EAClC,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,qCAAqC,CAAC;AAC7C,YAAY,EACV,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,qCAAqC,CAAC;AAC7C,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,CAAC,IAAI,WAAW,EAChB,aAAa,IAAI,uBAAuB,EACxC,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,QAAQ,CAAC;AAChB,YAAY,EACV,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,oBAAoB,EACpB,+BAA+B,EAChC,MAAM,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ export { SgPanel } from "./layout/SgPanel";
|
|
|
32
32
|
export { SgGrid } from "./layout/SgGrid";
|
|
33
33
|
export { SgStack } from "./layout/SgStack";
|
|
34
34
|
export { SgCard } from "./layout/SgCard";
|
|
35
|
+
export { default as SgPlayground } from "./others/SgPlayground";
|
|
35
36
|
export { SgToolBar, SgToolbarIconButton } from "./layout/SgToolBar";
|
|
36
37
|
export { SgDockLayout } from "./layout/SgDockLayout";
|
|
37
38
|
export { SgDockZone } from "./layout/SgDockZone";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type SgPlaygroundProps = {
|
|
2
|
+
code: string;
|
|
3
|
+
interactive?: boolean;
|
|
4
|
+
codeContract?: "renderBody" | "appFile";
|
|
5
|
+
title?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
height?: number | string;
|
|
8
|
+
expandedHeight?: number | string;
|
|
9
|
+
expandable?: boolean;
|
|
10
|
+
resizable?: boolean;
|
|
11
|
+
resizeAxis?: "vertical" | "horizontal" | "both";
|
|
12
|
+
previewPadding?: number | string;
|
|
13
|
+
className?: string;
|
|
14
|
+
dependencies?: Record<string, string>;
|
|
15
|
+
defaultImports?: string;
|
|
16
|
+
previewWrapperClassName?: string;
|
|
17
|
+
seedgridDependency?: string;
|
|
18
|
+
withCard?: boolean;
|
|
19
|
+
collapsible?: boolean;
|
|
20
|
+
defaultOpen?: boolean;
|
|
21
|
+
cardId?: string;
|
|
22
|
+
};
|
|
23
|
+
export default function SgPlayground(props: Readonly<SgPlaygroundProps>): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
//# sourceMappingURL=SgPlayground.d.ts.map
|
|
@@ -0,0 +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;AAoVF,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,2CAoMtE"}
|
|
@@ -0,0 +1,388 @@
|
|
|
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 = "0.2.6";
|
|
11
|
+
const DEFAULT_SEEDGRID_PEER_DEPENDENCIES = {
|
|
12
|
+
"react-hook-form": "^7.0.0",
|
|
13
|
+
"lucide-react": "^0.468.0",
|
|
14
|
+
"@tiptap/react": "^2.9.1",
|
|
15
|
+
"@tiptap/starter-kit": "^2.9.1",
|
|
16
|
+
"@tiptap/extension-underline": "^2.9.1",
|
|
17
|
+
"@tiptap/extension-link": "^2.9.1",
|
|
18
|
+
"@tiptap/extension-image": "^2.9.1",
|
|
19
|
+
"@tiptap/extension-text-align": "^2.9.1",
|
|
20
|
+
"@tiptap/extension-text-style": "^2.9.1",
|
|
21
|
+
"@tiptap/extension-color": "^2.9.1",
|
|
22
|
+
"@tiptap/extension-highlight": "^2.9.1",
|
|
23
|
+
"@tiptap/extension-subscript": "^2.9.1",
|
|
24
|
+
"@tiptap/extension-superscript": "^2.9.1",
|
|
25
|
+
"@tiptap/extension-font-family": "^2.9.1"
|
|
26
|
+
};
|
|
27
|
+
const SANDPACK_EXTERNAL_RESOURCES = [
|
|
28
|
+
// Prebuilt utility CSS so classes from @seedgrid/fe-components can render inside Sandpack
|
|
29
|
+
"https://unpkg.com/tailwindcss@2.2.19/dist/tailwind.min.css"
|
|
30
|
+
];
|
|
31
|
+
const SANDPACK_FALLBACK_THEME_VARS = {
|
|
32
|
+
"--background": "0 0% 100%",
|
|
33
|
+
"--foreground": "222.2 84% 4.9%",
|
|
34
|
+
"--primary": "142 76% 36%",
|
|
35
|
+
"--primary-foreground": "0 0% 100%",
|
|
36
|
+
"--secondary": "210 40% 96.1%",
|
|
37
|
+
"--secondary-foreground": "222.2 47.4% 11.2%",
|
|
38
|
+
"--accent": "152 57% 40%",
|
|
39
|
+
"--accent-foreground": "0 0% 100%",
|
|
40
|
+
"--destructive": "0 84.2% 60.2%",
|
|
41
|
+
"--destructive-foreground": "0 0% 100%",
|
|
42
|
+
"--border": "214.3 31.8% 91.4%",
|
|
43
|
+
"--ring": "var(--primary)",
|
|
44
|
+
"--sg-primary-600": "22 163 74",
|
|
45
|
+
"--sg-secondary-600": "82 82 91",
|
|
46
|
+
"--sg-tertiary-600": "20 184 166",
|
|
47
|
+
"--sg-error-600": "220 38 38",
|
|
48
|
+
"--sg-warning-600": "217 119 6",
|
|
49
|
+
"--sg-info-600": "2 132 199",
|
|
50
|
+
"--sg-success-600": "22 163 74"
|
|
51
|
+
};
|
|
52
|
+
const SANDPACK_CORE_THEME_VARS = [
|
|
53
|
+
"--background",
|
|
54
|
+
"--foreground",
|
|
55
|
+
"--primary",
|
|
56
|
+
"--primary-foreground",
|
|
57
|
+
"--secondary",
|
|
58
|
+
"--secondary-foreground",
|
|
59
|
+
"--accent",
|
|
60
|
+
"--accent-foreground",
|
|
61
|
+
"--destructive",
|
|
62
|
+
"--destructive-foreground",
|
|
63
|
+
"--border",
|
|
64
|
+
"--ring"
|
|
65
|
+
];
|
|
66
|
+
const SANDPACK_BASE_STYLES_CSS = `* {
|
|
67
|
+
box-sizing: border-box;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
html, body, #root {
|
|
71
|
+
margin: 0;
|
|
72
|
+
min-height: 100%;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#root {
|
|
76
|
+
padding: var(--sg-preview-padding, 0px);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
body {
|
|
80
|
+
font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
|
|
81
|
+
background: rgb(var(--sg-bg, 255 255 255));
|
|
82
|
+
color: rgb(var(--sg-text, 11 11 12));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Classes with arbitrary values used by SeedGrid components */
|
|
86
|
+
.bg-\\[var\\(--sg-btn-bg\\)\\] { background-color: var(--sg-btn-bg); }
|
|
87
|
+
.text-\\[var\\(--sg-btn-fg\\)\\] { color: var(--sg-btn-fg); }
|
|
88
|
+
.border-\\[var\\(--sg-btn-border\\)\\] { border-color: var(--sg-btn-border); }
|
|
89
|
+
.hover\\:bg-\\[var\\(--sg-btn-hover-bg\\)\\]:hover { background-color: var(--sg-btn-hover-bg); }
|
|
90
|
+
.hover\\:text-\\[var\\(--sg-btn-hover-fg\\)\\]:hover { color: var(--sg-btn-hover-fg); }
|
|
91
|
+
.hover\\:border-\\[var\\(--sg-btn-hover-border\\)\\]:hover { border-color: var(--sg-btn-hover-border); }
|
|
92
|
+
.active\\:bg-\\[var\\(--sg-btn-active-bg\\)\\]:active { background-color: var(--sg-btn-active-bg); }
|
|
93
|
+
.focus-visible\\:ring-\\[var\\(--sg-btn-ring\\)\\]:focus-visible { box-shadow: 0 0 0 4px var(--sg-btn-ring); }
|
|
94
|
+
.hover\\:bg-\\[rgb\\(var\\(--sg-btn-tint\\)\\/0\\.12\\)\\]:hover { background-color: rgb(var(--sg-btn-tint) / 0.12); }
|
|
95
|
+
.active\\:bg-\\[rgb\\(var\\(--sg-btn-tint\\)\\/0\\.18\\)\\]:active { background-color: rgb(var(--sg-btn-tint) / 0.18); }
|
|
96
|
+
.hover\\:bg-\\[rgb\\(var\\(--sg-btn-tint\\)\\/0\\.10\\)\\]:hover { background-color: rgb(var(--sg-btn-tint) / 0.10); }
|
|
97
|
+
.active\\:bg-\\[rgb\\(var\\(--sg-btn-tint\\)\\/0\\.16\\)\\]:active { background-color: rgb(var(--sg-btn-tint) / 0.16); }
|
|
98
|
+
.transition-\\[background-color\\,color\\,border-color\\,box-shadow\\,transform\\] {
|
|
99
|
+
transition-property: background-color, color, border-color, box-shadow, transform;
|
|
100
|
+
}
|
|
101
|
+
.active\\:translate-y-\\[0\\.5px\\]:active { transform: translateY(0.5px); }
|
|
102
|
+
.size-4 { width: 1rem; height: 1rem; }
|
|
103
|
+
.size-5 { width: 1.25rem; height: 1.25rem; }
|
|
104
|
+
`;
|
|
105
|
+
function parseRgbParts(raw) {
|
|
106
|
+
const value = raw.trim();
|
|
107
|
+
if (!value)
|
|
108
|
+
return null;
|
|
109
|
+
const normalized = value
|
|
110
|
+
.replace(/^rgb\(/i, "")
|
|
111
|
+
.replace(/\)$/g, "")
|
|
112
|
+
.replace(/\//g, " ")
|
|
113
|
+
.replace(/,/g, " ")
|
|
114
|
+
.trim();
|
|
115
|
+
const pieces = normalized
|
|
116
|
+
.split(/\s+/)
|
|
117
|
+
.map((part) => Number(part))
|
|
118
|
+
.filter((num) => Number.isFinite(num));
|
|
119
|
+
if (pieces.length < 3)
|
|
120
|
+
return null;
|
|
121
|
+
const r = pieces[0];
|
|
122
|
+
const g = pieces[1];
|
|
123
|
+
const b = pieces[2];
|
|
124
|
+
const clamp = (n) => Math.max(0, Math.min(255, Math.round(n)));
|
|
125
|
+
return [clamp(r), clamp(g), clamp(b)];
|
|
126
|
+
}
|
|
127
|
+
function rgbToHslTriplet(r, g, b) {
|
|
128
|
+
const rr = r / 255;
|
|
129
|
+
const gg = g / 255;
|
|
130
|
+
const bb = b / 255;
|
|
131
|
+
const max = Math.max(rr, gg, bb);
|
|
132
|
+
const min = Math.min(rr, gg, bb);
|
|
133
|
+
const delta = max - min;
|
|
134
|
+
let h = 0;
|
|
135
|
+
let s = 0;
|
|
136
|
+
const l = (max + min) / 2;
|
|
137
|
+
if (delta !== 0) {
|
|
138
|
+
s = delta / (1 - Math.abs(2 * l - 1));
|
|
139
|
+
switch (max) {
|
|
140
|
+
case rr:
|
|
141
|
+
h = ((gg - bb) / delta + (gg < bb ? 6 : 0)) / 6;
|
|
142
|
+
break;
|
|
143
|
+
case gg:
|
|
144
|
+
h = ((bb - rr) / delta + 2) / 6;
|
|
145
|
+
break;
|
|
146
|
+
default:
|
|
147
|
+
h = ((rr - gg) / delta + 4) / 6;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const hue = Math.round(h * 360);
|
|
152
|
+
const sat = Math.round(s * 100);
|
|
153
|
+
const lig = Math.round(l * 100);
|
|
154
|
+
return `${hue} ${sat}% ${lig}%`;
|
|
155
|
+
}
|
|
156
|
+
function toHslFromRgbVar(value) {
|
|
157
|
+
if (!value)
|
|
158
|
+
return null;
|
|
159
|
+
const parts = parseRgbParts(value);
|
|
160
|
+
if (!parts)
|
|
161
|
+
return null;
|
|
162
|
+
return rgbToHslTriplet(parts[0], parts[1], parts[2]);
|
|
163
|
+
}
|
|
164
|
+
function mapSgVarsToCoreVars(themeVars) {
|
|
165
|
+
const mapped = {};
|
|
166
|
+
const assignFromSg = (coreVar, sgVar) => {
|
|
167
|
+
const hsl = toHslFromRgbVar(themeVars[sgVar]);
|
|
168
|
+
if (hsl)
|
|
169
|
+
mapped[coreVar] = hsl;
|
|
170
|
+
};
|
|
171
|
+
assignFromSg("--background", "--sg-bg");
|
|
172
|
+
assignFromSg("--foreground", "--sg-text");
|
|
173
|
+
assignFromSg("--primary", "--sg-primary-600");
|
|
174
|
+
assignFromSg("--primary-foreground", "--sg-on-primary");
|
|
175
|
+
assignFromSg("--secondary", "--sg-secondary-600");
|
|
176
|
+
assignFromSg("--secondary-foreground", "--sg-on-secondary");
|
|
177
|
+
assignFromSg("--accent", "--sg-tertiary-600");
|
|
178
|
+
assignFromSg("--accent-foreground", "--sg-on-tertiary");
|
|
179
|
+
assignFromSg("--destructive", "--sg-error-600");
|
|
180
|
+
assignFromSg("--destructive-foreground", "--sg-on-error");
|
|
181
|
+
assignFromSg("--border", "--sg-border");
|
|
182
|
+
assignFromSg("--ring", "--sg-primary-400");
|
|
183
|
+
return mapped;
|
|
184
|
+
}
|
|
185
|
+
function readThemeVarsFromHost() {
|
|
186
|
+
if (typeof window === "undefined")
|
|
187
|
+
return {};
|
|
188
|
+
const computed = window.getComputedStyle(document.documentElement);
|
|
189
|
+
const themeVars = {};
|
|
190
|
+
for (const varName of SANDPACK_CORE_THEME_VARS) {
|
|
191
|
+
const value = computed.getPropertyValue(varName).trim();
|
|
192
|
+
if (value)
|
|
193
|
+
themeVars[varName] = value;
|
|
194
|
+
}
|
|
195
|
+
for (let index = 0; index < computed.length; index += 1) {
|
|
196
|
+
const varName = computed.item(index)?.trim();
|
|
197
|
+
if (!varName || !varName.startsWith("--sg-"))
|
|
198
|
+
continue;
|
|
199
|
+
const value = computed.getPropertyValue(varName).trim();
|
|
200
|
+
if (value)
|
|
201
|
+
themeVars[varName] = value;
|
|
202
|
+
}
|
|
203
|
+
Object.assign(themeVars, mapSgVarsToCoreVars(themeVars));
|
|
204
|
+
return themeVars;
|
|
205
|
+
}
|
|
206
|
+
function normalizeCssSize(value) {
|
|
207
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
208
|
+
}
|
|
209
|
+
function buildSandpackStylesCss(themeVars, previewPadding) {
|
|
210
|
+
const mergedVars = {
|
|
211
|
+
...SANDPACK_FALLBACK_THEME_VARS,
|
|
212
|
+
...themeVars,
|
|
213
|
+
"--sg-preview-padding": previewPadding
|
|
214
|
+
};
|
|
215
|
+
const rootVars = Object.entries(mergedVars)
|
|
216
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
217
|
+
.map(([varName, value]) => ` ${varName}: ${value};`)
|
|
218
|
+
.join("\n");
|
|
219
|
+
return `:root {
|
|
220
|
+
${rootVars}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
${SANDPACK_BASE_STYLES_CSS}`;
|
|
224
|
+
}
|
|
225
|
+
function ReadonlyBlock({ code }) {
|
|
226
|
+
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 }) }));
|
|
227
|
+
}
|
|
228
|
+
function buildAppTsxFromRenderBody(renderBody, defaultImports, wrapperClassName) {
|
|
229
|
+
const body = renderBody
|
|
230
|
+
.replace(/\t/g, " ")
|
|
231
|
+
.split("\n")
|
|
232
|
+
.map((line) => (line ? ` ${line}` : ""))
|
|
233
|
+
.join("\n");
|
|
234
|
+
if (!wrapperClassName) {
|
|
235
|
+
return `import * as React from "react";
|
|
236
|
+
${defaultImports}
|
|
237
|
+
|
|
238
|
+
export default function App() {
|
|
239
|
+
return (
|
|
240
|
+
<>
|
|
241
|
+
${body}
|
|
242
|
+
</>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
`;
|
|
246
|
+
}
|
|
247
|
+
return `import * as React from "react";
|
|
248
|
+
${defaultImports}
|
|
249
|
+
|
|
250
|
+
export default function App() {
|
|
251
|
+
return (
|
|
252
|
+
<div className="${wrapperClassName}">
|
|
253
|
+
<>
|
|
254
|
+
${body}
|
|
255
|
+
</>
|
|
256
|
+
</div>
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
`;
|
|
260
|
+
}
|
|
261
|
+
async function copyText(text) {
|
|
262
|
+
if (!text)
|
|
263
|
+
return false;
|
|
264
|
+
if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
|
|
265
|
+
await navigator.clipboard.writeText(text);
|
|
266
|
+
return true;
|
|
267
|
+
}
|
|
268
|
+
if (typeof document === "undefined")
|
|
269
|
+
return false;
|
|
270
|
+
const textarea = document.createElement("textarea");
|
|
271
|
+
textarea.value = text;
|
|
272
|
+
textarea.setAttribute("readonly", "");
|
|
273
|
+
textarea.style.position = "fixed";
|
|
274
|
+
textarea.style.opacity = "0";
|
|
275
|
+
document.body.appendChild(textarea);
|
|
276
|
+
textarea.select();
|
|
277
|
+
const ok = document.execCommand("copy");
|
|
278
|
+
document.body.removeChild(textarea);
|
|
279
|
+
return ok;
|
|
280
|
+
}
|
|
281
|
+
function CopyButton() {
|
|
282
|
+
const { sandpack } = useSandpack();
|
|
283
|
+
const [copyState, setCopyState] = React.useState("idle");
|
|
284
|
+
const handleCopy = React.useCallback(async () => {
|
|
285
|
+
try {
|
|
286
|
+
const activeFilePath = sandpack.activeFile;
|
|
287
|
+
const activeCode = sandpack.files[activeFilePath]?.code ?? "";
|
|
288
|
+
const copied = await copyText(activeCode);
|
|
289
|
+
setCopyState(copied ? "success" : "error");
|
|
290
|
+
}
|
|
291
|
+
catch {
|
|
292
|
+
setCopyState("error");
|
|
293
|
+
}
|
|
294
|
+
}, [sandpack.activeFile, sandpack.files]);
|
|
295
|
+
React.useEffect(() => {
|
|
296
|
+
if (copyState === "idle")
|
|
297
|
+
return;
|
|
298
|
+
const timerId = window.setTimeout(() => setCopyState("idle"), 1400);
|
|
299
|
+
return () => window.clearTimeout(timerId);
|
|
300
|
+
}, [copyState]);
|
|
301
|
+
return (_jsx(SgButton, { appearance: "outline", size: "sm", onClick: handleCopy, children: copyState === "success" ? "Copiado" : copyState === "error" ? "Erro" : "Copiar" }));
|
|
302
|
+
}
|
|
303
|
+
function RunButton() {
|
|
304
|
+
const { sandpack } = useSandpack();
|
|
305
|
+
return (_jsx(SgButton, { severity: "primary", size: "sm", onClick: () => sandpack.runSandpack(), children: "Run" }));
|
|
306
|
+
}
|
|
307
|
+
export default function SgPlayground(props) {
|
|
308
|
+
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;
|
|
309
|
+
const effectivePreviewPadding = normalizeCssSize(previewPadding ?? (codeContract === "appFile" ? 12 : 0));
|
|
310
|
+
const [sandpackStylesCss, setSandpackStylesCss] = React.useState(() => buildSandpackStylesCss(readThemeVarsFromHost(), effectivePreviewPadding));
|
|
311
|
+
const [isExpanded, setIsExpanded] = React.useState(false);
|
|
312
|
+
React.useEffect(() => {
|
|
313
|
+
if (typeof window === "undefined")
|
|
314
|
+
return;
|
|
315
|
+
const root = document.documentElement;
|
|
316
|
+
const refreshStyles = () => {
|
|
317
|
+
const liveThemeVars = readThemeVarsFromHost();
|
|
318
|
+
setSandpackStylesCss(buildSandpackStylesCss(liveThemeVars, effectivePreviewPadding));
|
|
319
|
+
};
|
|
320
|
+
let frameId = null;
|
|
321
|
+
const scheduleRefresh = () => {
|
|
322
|
+
if (frameId !== null)
|
|
323
|
+
return;
|
|
324
|
+
frameId = window.requestAnimationFrame(() => {
|
|
325
|
+
frameId = null;
|
|
326
|
+
refreshStyles();
|
|
327
|
+
});
|
|
328
|
+
};
|
|
329
|
+
const observer = new MutationObserver(scheduleRefresh);
|
|
330
|
+
observer.observe(root, {
|
|
331
|
+
attributes: true,
|
|
332
|
+
attributeFilter: ["style", "class", "data-theme"]
|
|
333
|
+
});
|
|
334
|
+
refreshStyles();
|
|
335
|
+
return () => {
|
|
336
|
+
observer.disconnect();
|
|
337
|
+
if (frameId !== null) {
|
|
338
|
+
window.cancelAnimationFrame(frameId);
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
}, [effectivePreviewPadding]);
|
|
342
|
+
const seedgridDefaultImports = defaultImports ?? `import {
|
|
343
|
+
SgScreen,
|
|
344
|
+
SgMainPanel,
|
|
345
|
+
SgPanel,
|
|
346
|
+
SgGrid,
|
|
347
|
+
SgStack,
|
|
348
|
+
SgButton,
|
|
349
|
+
SgAutocomplete
|
|
350
|
+
} from "@seedgrid/fe-components";`;
|
|
351
|
+
const appTsx = codeContract === "appFile"
|
|
352
|
+
? code
|
|
353
|
+
: buildAppTsxFromRenderBody(code, seedgridDefaultImports, previewWrapperClassName);
|
|
354
|
+
const resolvedSeedgridDependency = seedgridDependency ??
|
|
355
|
+
process.env.NEXT_PUBLIC_SANDPACK_SEEDGRID_DEPENDENCY ??
|
|
356
|
+
DEFAULT_SEEDGRID_DEPENDENCY;
|
|
357
|
+
const files = {
|
|
358
|
+
"/App.tsx": { code: appTsx, active: true },
|
|
359
|
+
"/styles.css": { code: sandpackStylesCss || buildSandpackStylesCss({}, effectivePreviewPadding) }
|
|
360
|
+
};
|
|
361
|
+
const deps = {
|
|
362
|
+
react: "^19.0.0",
|
|
363
|
+
"react-dom": "^19.0.0",
|
|
364
|
+
...DEFAULT_SEEDGRID_PEER_DEPENDENCIES,
|
|
365
|
+
"@seedgrid/fe-components": resolvedSeedgridDependency,
|
|
366
|
+
...(dependencies ?? {})
|
|
367
|
+
};
|
|
368
|
+
const currentHeight = isExpanded ? expandedHeight : height;
|
|
369
|
+
const resizeClass = !resizable
|
|
370
|
+
? undefined
|
|
371
|
+
: resizeAxis === "vertical"
|
|
372
|
+
? "resize-y"
|
|
373
|
+
: resizeAxis === "horizontal"
|
|
374
|
+
? "resize-x"
|
|
375
|
+
: "resize";
|
|
376
|
+
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: {
|
|
377
|
+
autorun: false,
|
|
378
|
+
activeFile: "/App.tsx",
|
|
379
|
+
visibleFiles: ["/App.tsx"],
|
|
380
|
+
externalResources: SANDPACK_EXTERNAL_RESOURCES
|
|
381
|
+
}, 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, {})] })] }), _jsxs("div", { className: cn("grid overflow-auto min-h-[260px] min-w-[480px]", resizeClass), style: {
|
|
382
|
+
gridTemplateColumns: "1fr 1fr",
|
|
383
|
+
height: currentHeight
|
|
384
|
+
}, children: [_jsxs("div", { className: "min-w-0 border-r border-border", 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: "min-w-0", 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 })] }));
|
|
385
|
+
if (!withCard)
|
|
386
|
+
return content;
|
|
387
|
+
return (_jsx(SgCard, { id: cardId, title: title ?? "Codigo", description: description, collapsible: collapsible, defaultOpen: defaultOpen, className: cn("rounded-lg", className), bodyClassName: "p-0", children: content }));
|
|
388
|
+
}
|
package/package.json
CHANGED
|
@@ -1,54 +1,57 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@seedgrid/fe-components",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"default": "./dist/index.js"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"files": [
|
|
14
|
-
"dist"
|
|
15
|
-
],
|
|
16
|
-
"scripts": {
|
|
17
|
-
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
18
|
-
"build": "pnpm run clean && tsc -p tsconfig.json",
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"react
|
|
24
|
-
"
|
|
25
|
-
"@
|
|
26
|
-
"
|
|
27
|
-
"@tiptap/
|
|
28
|
-
"@tiptap/
|
|
29
|
-
"@tiptap/extension-
|
|
30
|
-
"@tiptap/extension-
|
|
31
|
-
"@tiptap/extension-
|
|
32
|
-
"@tiptap/extension-
|
|
33
|
-
"@tiptap/extension-
|
|
34
|
-
"@tiptap/extension-
|
|
35
|
-
"@tiptap/extension-
|
|
36
|
-
"@tiptap/extension-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
"@
|
|
43
|
-
"
|
|
44
|
-
"@tiptap/
|
|
45
|
-
"@tiptap/
|
|
46
|
-
"@tiptap/extension-
|
|
47
|
-
"@tiptap/extension-
|
|
48
|
-
"@tiptap/extension-
|
|
49
|
-
"@tiptap/extension-
|
|
50
|
-
"@tiptap/extension-
|
|
51
|
-
"@tiptap/extension-
|
|
52
|
-
"@tiptap/extension-
|
|
53
|
-
|
|
54
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@seedgrid/fe-components",
|
|
3
|
+
"version": "0.2.8",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
18
|
+
"build": "pnpm run clean && tsc -p tsconfig.json",
|
|
19
|
+
"dev": "tsc -p tsconfig.json --watch --preserveWatchOutput",
|
|
20
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"react": "^18.2.0 || ^19.0.0",
|
|
24
|
+
"react-hook-form": "^7.0.0",
|
|
25
|
+
"@codesandbox/sandpack-react": "^2.20.0",
|
|
26
|
+
"lucide-react": "^0.468.0",
|
|
27
|
+
"@tiptap/react": "^2.9.1",
|
|
28
|
+
"@tiptap/starter-kit": "^2.9.1",
|
|
29
|
+
"@tiptap/extension-underline": "^2.9.1",
|
|
30
|
+
"@tiptap/extension-link": "^2.9.1",
|
|
31
|
+
"@tiptap/extension-image": "^2.9.1",
|
|
32
|
+
"@tiptap/extension-text-align": "^2.9.1",
|
|
33
|
+
"@tiptap/extension-text-style": "^2.9.1",
|
|
34
|
+
"@tiptap/extension-color": "^2.9.1",
|
|
35
|
+
"@tiptap/extension-highlight": "^2.9.1",
|
|
36
|
+
"@tiptap/extension-subscript": "^2.9.1",
|
|
37
|
+
"@tiptap/extension-superscript": "^2.9.1",
|
|
38
|
+
"@tiptap/extension-font-family": "^2.9.1"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"react-hook-form": "^7.0.0",
|
|
42
|
+
"@codesandbox/sandpack-react": "^2.20.0",
|
|
43
|
+
"lucide-react": "^0.468.0",
|
|
44
|
+
"@tiptap/react": "^2.9.1",
|
|
45
|
+
"@tiptap/starter-kit": "^2.9.1",
|
|
46
|
+
"@tiptap/extension-underline": "^2.9.1",
|
|
47
|
+
"@tiptap/extension-link": "^2.9.1",
|
|
48
|
+
"@tiptap/extension-image": "^2.9.1",
|
|
49
|
+
"@tiptap/extension-text-align": "^2.9.1",
|
|
50
|
+
"@tiptap/extension-text-style": "^2.9.1",
|
|
51
|
+
"@tiptap/extension-color": "^2.9.1",
|
|
52
|
+
"@tiptap/extension-highlight": "^2.9.1",
|
|
53
|
+
"@tiptap/extension-subscript": "^2.9.1",
|
|
54
|
+
"@tiptap/extension-superscript": "^2.9.1",
|
|
55
|
+
"@tiptap/extension-font-family": "^2.9.1"
|
|
56
|
+
}
|
|
57
|
+
}
|