@guard-rail/core 0.1.0 → 0.1.1
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/react/Admin.js +9 -4
- package/dist/react/Admin.js.map +1 -1
- package/dist/react/GRail/client.js +15 -4
- package/dist/react/GRail/client.js.map +1 -1
- package/dist/react/styles.d.ts +9 -0
- package/dist/react/styles.js +9 -0
- package/dist/react/styles.js.map +1 -1
- package/package.json +1 -1
- package/supabase/migrations/20260911000000_guardrail_init.sql +16 -1
package/dist/react/Admin.js
CHANGED
|
@@ -29,13 +29,18 @@ function GRailAdmin({ toolbarExtra }) {
|
|
|
29
29
|
if (!isAuth) {
|
|
30
30
|
if (!auth.password) {
|
|
31
31
|
return /* @__PURE__ */ jsx("div", { "data-guardrail": true, style: S.banner, children: /* @__PURE__ */ jsxs("div", { style: S.bannerForm, children: [
|
|
32
|
-
/* @__PURE__ */
|
|
33
|
-
|
|
32
|
+
/* @__PURE__ */ jsxs("div", { style: S.brandStack, children: [
|
|
33
|
+
/* @__PURE__ */ jsx("span", { style: S.brand, children: "Guardrail" }),
|
|
34
|
+
!auth.signInUrl && /* @__PURE__ */ jsx("span", { style: { fontSize: 12, color: "#6b7280" }, children: "No sign-in method is configured for this site." })
|
|
35
|
+
] }),
|
|
36
|
+
auth.signInUrl && /* @__PURE__ */ jsx("a", { href: auth.signInUrl, style: { ...S.primaryBtn, textDecoration: "none" }, children: "Sign in" })
|
|
34
37
|
] }) });
|
|
35
38
|
}
|
|
36
39
|
return /* @__PURE__ */ jsx("div", { "data-guardrail": true, style: S.banner, children: /* @__PURE__ */ jsxs("form", { action: formAction, style: S.bannerForm, children: [
|
|
37
|
-
/* @__PURE__ */
|
|
38
|
-
|
|
40
|
+
/* @__PURE__ */ jsxs("div", { style: S.brandStack, children: [
|
|
41
|
+
/* @__PURE__ */ jsx("span", { style: S.brand, children: "Guardrail" }),
|
|
42
|
+
formState.error && /* @__PURE__ */ jsx("span", { style: S.error, children: formState.error })
|
|
43
|
+
] }),
|
|
39
44
|
/* @__PURE__ */ jsx(
|
|
40
45
|
"input",
|
|
41
46
|
{
|
package/dist/react/Admin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react/Admin.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { useActionState, useEffect, useState } from \"react\";\nimport { usePathname, useRouter } from \"next/navigation\";\nimport { loginAction, logoutAction } from \"../server/actions\";\nimport { useGRail } from \"./Provider\";\nimport { TeamDrawer } from \"./Team\";\nimport { LogOutIcon, PeopleIcon } from \"./Icons\";\nimport { S } from \"./styles\";\nimport type { ActionState } from \"../core/types\";\n\nconst initialState: ActionState = { email: \"\", password: \"\" };\n\nexport function GRailAdmin({ toolbarExtra }: { toolbarExtra?: React.ReactNode }) {\n const { isAuth, isEditMode, role, auth } = useGRail();\n const [teamOpen, setTeamOpen] = useState(false);\n const [formState, formAction, isPending] = useActionState(\n loginAction,\n initialState,\n );\n const router = useRouter();\n const pathname = usePathname();\n\n useEffect(() => {\n if (formState.success) router.refresh();\n }, [formState.success, router]);\n\n const signOut = async () => {\n await logoutAction();\n document.cookie =\n \"gr_edit_mode=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT\";\n window.location.href = pathname;\n };\n\n // No intent signalled — render nothing at all.\n if (!isEditMode) return null;\n\n if (!isAuth) {\n // The adapter cannot take a password here, so hand sign-in off rather than\n // showing a form that could never succeed.\n if (!auth.password) {\n return (\n <div data-guardrail style={S.banner}>\n <div style={S.bannerForm}>\n <span style={S.brand}>Guardrail</span>\n
|
|
1
|
+
{"version":3,"sources":["../../src/react/Admin.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { useActionState, useEffect, useState } from \"react\";\nimport { usePathname, useRouter } from \"next/navigation\";\nimport { loginAction, logoutAction } from \"../server/actions\";\nimport { useGRail } from \"./Provider\";\nimport { TeamDrawer } from \"./Team\";\nimport { LogOutIcon, PeopleIcon } from \"./Icons\";\nimport { S } from \"./styles\";\nimport type { ActionState } from \"../core/types\";\n\nconst initialState: ActionState = { email: \"\", password: \"\" };\n\nexport function GRailAdmin({ toolbarExtra }: { toolbarExtra?: React.ReactNode }) {\n const { isAuth, isEditMode, role, auth } = useGRail();\n const [teamOpen, setTeamOpen] = useState(false);\n const [formState, formAction, isPending] = useActionState(\n loginAction,\n initialState,\n );\n const router = useRouter();\n const pathname = usePathname();\n\n useEffect(() => {\n if (formState.success) router.refresh();\n }, [formState.success, router]);\n\n const signOut = async () => {\n await logoutAction();\n document.cookie =\n \"gr_edit_mode=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT\";\n window.location.href = pathname;\n };\n\n // No intent signalled — render nothing at all.\n if (!isEditMode) return null;\n\n if (!isAuth) {\n // The adapter cannot take a password here, so hand sign-in off rather than\n // showing a form that could never succeed.\n if (!auth.password) {\n return (\n <div data-guardrail style={S.banner}>\n <div style={S.bannerForm}>\n <div style={S.brandStack}>\n <span style={S.brand}>Guardrail</span>\n {!auth.signInUrl && (\n <span style={{ fontSize: 12, color: \"#6b7280\" }}>\n No sign-in method is configured for this site.\n </span>\n )}\n </div>\n {auth.signInUrl && (\n <a href={auth.signInUrl} style={{ ...S.primaryBtn, textDecoration: \"none\" }}>\n Sign in\n </a>\n )}\n </div>\n </div>\n );\n }\n\n return (\n <div data-guardrail style={S.banner}>\n <form action={formAction} style={S.bannerForm}>\n <div style={S.brandStack}>\n <span style={S.brand}>Guardrail</span>\n {formState.error && <span style={S.error}>{formState.error}</span>}\n </div>\n <input\n name=\"email\"\n type=\"email\"\n placeholder=\"Email\"\n defaultValue={formState.email}\n required\n style={S.input}\n />\n <input\n name=\"password\"\n type=\"password\"\n placeholder=\"Password\"\n required\n style={S.input}\n />\n <button type=\"submit\" disabled={isPending} style={S.primaryBtn}>\n {isPending ? \"Authenticating…\" : \"Sign In\"}\n </button>\n </form>\n </div>\n );\n }\n\n // Signed in, but holds no role on this site.\n if (!role) {\n return (\n <div data-guardrail style={S.toolbar}>\n <span style={S.toolbarLabel}>No access to this site</span>\n <span style={S.divider} />\n <button\n style={{ ...S.iconBtn, color: \"#9ca3af\" }}\n onClick={signOut}\n title=\"Log out\"\n aria-label=\"Log out\"\n >\n <LogOutIcon />\n </button>\n </div>\n );\n }\n\n return (\n <>\n {teamOpen && <TeamDrawer onClose={() => setTeamOpen(false)} />}\n <div data-guardrail style={S.toolbar}>\n <span style={S.dot} />\n <span style={S.toolbarLabel}>Edit Mode</span>\n <span style={S.divider} />\n <button\n style={{ ...S.iconBtn, color: \"#9ca3af\", width: 24, height: 24 }}\n onClick={() => setTeamOpen(true)}\n title=\"Team\"\n aria-label=\"Team\"\n >\n <PeopleIcon />\n </button>\n\n {toolbarExtra && (\n <>\n <span style={S.divider} />\n {toolbarExtra}\n </>\n )}\n\n <span style={S.divider} />\n <button\n style={{ ...S.iconBtn, color: \"#9ca3af\" }}\n onClick={signOut}\n title=\"Log out\"\n aria-label=\"Log out\"\n >\n <LogOutIcon />\n </button>\n </div>\n </>\n );\n}\n"],"mappings":";AA4CY,SAmFF,UAlFI,KADF;AA1CZ,OAAO,SAAS,gBAAgB,WAAW,gBAAgB;AAC3D,SAAS,aAAa,iBAAiB;AACvC,SAAS,aAAa,oBAAoB;AAC1C,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,YAAY,kBAAkB;AACvC,SAAS,SAAS;AAGlB,MAAM,eAA4B,EAAE,OAAO,IAAI,UAAU,GAAG;AAErD,SAAS,WAAW,EAAE,aAAa,GAAuC;AAC/E,QAAM,EAAE,QAAQ,YAAY,MAAM,KAAK,IAAI,SAAS;AACpD,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;AAC9C,QAAM,CAAC,WAAW,YAAY,SAAS,IAAI;AAAA,IACzC;AAAA,IACA;AAAA,EACF;AACA,QAAM,SAAS,UAAU;AACzB,QAAM,WAAW,YAAY;AAE7B,YAAU,MAAM;AACd,QAAI,UAAU,QAAS,QAAO,QAAQ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EX,8BAAC,cAAW;AAAA;AAAA,MACd;AAAA,OACF;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import React, { useRef, useState } from "react";
|
|
3
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { saveOverride } from "../../server/actions";
|
|
5
5
|
import { GRailRender } from "./render";
|
|
6
6
|
import { useGRail } from "../Provider";
|
|
@@ -22,9 +22,6 @@ function GRailClient({
|
|
|
22
22
|
const rect = useAnchorRect(elementRef, editing);
|
|
23
23
|
const sessionTextRef = useRef(initialOverride.value.text ?? "");
|
|
24
24
|
const draftTextRef = useRef(initialOverride.value.text ?? "");
|
|
25
|
-
if (!isEditMode) {
|
|
26
|
-
return /* @__PURE__ */ jsx(GRailRender, { as, ...htmlProps, override: row.value });
|
|
27
|
-
}
|
|
28
25
|
const isInline = row.value.type === "text" || row.value.type === "button";
|
|
29
26
|
const beginEdit = () => {
|
|
30
27
|
sessionTextRef.current = row.value.text ?? "";
|
|
@@ -56,6 +53,20 @@ function GRailClient({
|
|
|
56
53
|
setError(null);
|
|
57
54
|
setEditing(false);
|
|
58
55
|
};
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (!editing) return;
|
|
58
|
+
const handlePointerDown = (e) => {
|
|
59
|
+
const target = e.target;
|
|
60
|
+
if (elementRef.current?.contains(target)) return;
|
|
61
|
+
if (target instanceof Element && target.closest("[data-guardrail]")) return;
|
|
62
|
+
handleCancel();
|
|
63
|
+
};
|
|
64
|
+
document.addEventListener("mousedown", handlePointerDown);
|
|
65
|
+
return () => document.removeEventListener("mousedown", handlePointerDown);
|
|
66
|
+
}, [editing]);
|
|
67
|
+
if (!isEditMode) {
|
|
68
|
+
return /* @__PURE__ */ jsx(GRailRender, { as, ...htmlProps, override: row.value });
|
|
69
|
+
}
|
|
59
70
|
const renderedValue = editing && isInline ? { ...row.value, text: sessionTextRef.current } : row.value;
|
|
60
71
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
61
72
|
/* @__PURE__ */ jsx(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/react/GRail/client.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { useRef, useState } from \"react\";\nimport { saveOverride } from \"../../server/actions\";\nimport { GRailRender } from \"./render\";\nimport { useGRail } from \"../Provider\";\nimport { useAnchorRect } from \"../useAnchorRect\";\nimport { CheckIcon, CloseIcon, SpinnerIcon } from \"../Icons\";\nimport { S } from \"../styles\";\nimport { MediaPicker } from \"../MediaPicker\";\nimport type { HTMLKeys, OverrideRow, OverrideValue } from \"../../core/types\";\n\nexport function GRailClient({\n as,\n initialOverride,\n ...htmlProps\n}: {\n as?: HTMLKeys;\n initialOverride: OverrideRow;\n [key: string]: unknown;\n}) {\n const { isEditMode } = useGRail();\n const [editing, setEditing] = useState(false);\n const [saving, setSaving] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [row, setRow] = useState<OverrideRow>(initialOverride);\n\n const elementRef = useRef<HTMLElement | null>(null);\n const rect = useAnchorRect(elementRef, editing);\n\n /**\n * The text the element was rendered with when this edit session began.\n *\n * While editing, the DOM owns the text and React must not touch it. Feeding\n * state back into a contentEditable's children makes React replace the text\n * node on every keystroke, which resets the caret to offset 0 — typing then\n * appears reversed and backspace jumps to the start. Holding this value\n * constant means the children prop never changes, so React leaves the node\n * alone and the caret stays put.\n */\n const sessionTextRef = useRef<string>(initialOverride.value.text ?? \"\");\n /** Live DOM text, updated without re-rendering. Read on save. */\n const draftTextRef = useRef<string>(initialOverride.value.text ?? \"\");\n\n if (!isEditMode) {\n return <GRailRender as={as} {...htmlProps} override={row.value} />;\n }\n\n const isInline = row.value.type === \"text\" || row.value.type === \"button\";\n\n const beginEdit = () => {\n sessionTextRef.current = row.value.text ?? \"\";\n draftTextRef.current = row.value.text ?? \"\";\n setError(null);\n setEditing(true);\n };\n\n const updateAttribute = (key: string, value: string) =>\n setRow((prev) => ({ ...prev, value: { ...prev.value, [key]: value } }));\n\n const patchValue = (patch: Partial<OverrideValue>) =>\n setRow((prev) => ({ ...prev, value: { ...prev.value, ...patch } }));\n\n const handleSave = async () => {\n // Inline text lives in the DOM, not in state, so read it back here.\n const next: OverrideRow = isInline\n ? { ...row, value: { ...row.value, text: draftTextRef.current } }\n : row;\n\n setSaving(true);\n setError(null);\n const res = await saveOverride(next);\n setSaving(false);\n\n if (!res.success) {\n setError(res.error ?? \"Save failed.\");\n return;\n }\n setRow(next);\n setEditing(false);\n };\n\n const handleCancel = () => {\n setRow(initialOverride);\n draftTextRef.current = initialOverride.value.text ?? \"\";\n if (isInline && elementRef.current) {\n elementRef.current.textContent = initialOverride.value.text ?? \"\";\n }\n setError(null);\n setEditing(false);\n };\n\n // Frozen during the session so React never rewrites the live text node.\n const renderedValue =\n editing && isInline\n ? { ...row.value, text: sessionTextRef.current }\n : row.value;\n\n return (\n <>\n <GRailRender\n as={as}\n {...htmlProps}\n ref={elementRef}\n override={renderedValue}\n style={{\n ...(htmlProps.style as React.CSSProperties),\n outline: editing ? \"2px solid #2563eb\" : \"1px dashed #60a5fa\",\n outlineOffset: 2,\n cursor: editing ? \"text\" : \"pointer\",\n }}\n onClick={(e: React.MouseEvent) => {\n if (editing) return;\n e.preventDefault();\n // preventDefault only blocks the browser's native action (following\n // an href); it does not stop the click from bubbling. A field\n // rendered inside a Link would still trigger the Link's own onClick\n // and navigate anyway — stopPropagation is what actually claims the\n // click for editing instead. (Use `editable={false}` on fields\n // meant to stay pure navigation, e.g. inside a card that links to\n // that content's own page.)\n e.stopPropagation();\n beginEdit();\n }}\n // Spread only for inline text: images and links would receive invalid\n // DOM props (contentEditable on next/image, etc).\n {...(isInline\n ? {\n contentEditable: editing,\n suppressContentEditableWarning: true,\n onInput: (e: React.FormEvent<HTMLElement>) => {\n // Ref only — setState here re-renders and moves the caret.\n draftTextRef.current = e.currentTarget.textContent ?? \"\";\n },\n onKeyDown: (e: React.KeyboardEvent) => {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n void handleSave();\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n handleCancel();\n }\n },\n }\n : {})}\n />\n\n {editing && rect && (\n <Chrome\n rect={rect}\n isInline={isInline}\n row={row}\n error={error}\n saving={saving}\n onChange={updateAttribute}\n onPatch={patchValue}\n onSave={handleSave}\n onCancel={handleCancel}\n />\n )}\n </>\n );\n}\n\nfunction Chrome({\n rect,\n isInline,\n row,\n error,\n saving,\n onChange,\n onPatch,\n onSave,\n onCancel,\n}: {\n rect: { top: number; left: number; bottom: number; width: number };\n isInline: boolean;\n row: OverrideRow;\n error: string | null;\n saving: boolean;\n onChange: (key: string, value: string) => void;\n onPatch: (patch: Partial<OverrideValue>) => void;\n onSave: () => void;\n onCancel: () => void;\n}) {\n const { storage } = useGRail();\n const [pickerOpen, setPickerOpen] = useState(false);\n const GAP = 8;\n // Flip above the element when there is no room below it.\n const below = rect.bottom + GAP;\n const flip = typeof window !== \"undefined\" && below > window.innerHeight - 120;\n\n const position: React.CSSProperties = {\n left: Math.max(8, rect.left),\n ...(flip ? { top: Math.max(8, rect.top - GAP - 44) } : { top: below }),\n };\n\n const actions = (\n <>\n <button\n style={S.iconBtnPrimary}\n onClick={onSave}\n disabled={saving}\n title=\"Save (Enter)\"\n aria-label=\"Save\"\n >\n {saving ? <SpinnerIcon /> : <CheckIcon />}\n </button>\n <button\n style={S.iconBtn}\n onClick={onCancel}\n disabled={saving}\n title=\"Cancel (Esc)\"\n aria-label=\"Cancel\"\n >\n <CloseIcon />\n </button>\n </>\n );\n\n // Text and buttons edit in place, so they only need the two controls.\n if (isInline) {\n return (\n <div data-guardrail style={{ ...S.anchoredBar, ...position }}>\n {actions}\n {error && <span style={{ ...S.error, margin: \"0 6px\" }}>{error}</span>}\n </div>\n );\n }\n\n // Images and links carry attributes with no on-page representation.\n return (\n <div\n data-guardrail\n style={{ ...S.anchoredPanel, ...position }}\n onClick={(e) => e.stopPropagation()}\n >\n {row.value.type === \"image\" && (\n <>\n {row.value.src && (\n // Plain img: previews must not depend on remotePatterns.\n <img src={row.value.src} alt=\"\" style={S.previewThumb} />\n )}\n\n {storage && (\n <button\n type=\"button\"\n style={S.secondaryBtn}\n onClick={() => setPickerOpen(true)}\n >\n {row.value.src ? \"Replace image\" : \"Choose image\"}\n </button>\n )}\n\n <label style={S.label}>Alt text</label>\n <input\n style={S.field}\n value={row.value.alt || \"\"}\n placeholder=\"Describe the image for screen readers\"\n onChange={(e) => onChange(\"alt\", e.target.value)}\n />\n\n {/* Only without storage: there is no picker then, so a URL is the one\n way to set an image. A typed URL has unknown proportions, so any\n stored dimensions are cleared. */}\n {!storage && (\n <>\n <label style={S.label}>Image URL</label>\n <input\n style={S.field}\n value={row.value.src || \"\"}\n onChange={(e) =>\n onPatch({ src: e.target.value, width: undefined, height: undefined })\n }\n />\n </>\n )}\n\n {pickerOpen && (\n <MediaPicker\n current={row.value.src}\n onClose={() => setPickerOpen(false)}\n onSelect={(image) =>\n onPatch({ src: image.src, width: image.width, height: image.height })\n }\n />\n )}\n </>\n )}\n\n {row.value.type === \"link\" && (\n <>\n <label style={S.label}>Link text</label>\n <input\n style={S.field}\n value={row.value.text || \"\"}\n onChange={(e) => onChange(\"text\", e.target.value)}\n />\n <label style={S.label}>URL</label>\n <input\n style={S.field}\n value={row.value.href || \"\"}\n onChange={(e) => onChange(\"href\", e.target.value)}\n />\n </>\n )}\n\n {error && <div style={{ ...S.error, marginBottom: 8 }}>{error}</div>}\n <div style={{ display: \"flex\", gap: 4, justifyContent: \"flex-end\" }}>\n {actions}\n </div>\n </div>\n );\n}\n"],"mappings":";AA6CW,SAsDP,UAtDO,KAsDP,YAtDO;AA3CX,OAAO,SAAS,QAAQ,gBAAgB;AACxC,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAC9B,SAAS,W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T,QAAQ,EAAE,KAAK,MAAM,KAAK,OAAO,MAAM,OAAO,QAAQ,MAAM,OAAO,CAAC;AAAA;AAAA,UAExE;AAAA,WAEJ;AAAA,QAGD,IAAI,MAAM,SAAS,UAClB,iCACE;AAAA,8BAAC,WAAM,OAAO,EAAE,OAAO,uBAAS;AAAA,UAChC;AAAA,YAAC;AAAA;AAAA,cACC,OAAO,EAAE;AAAA,cACT,OAAO,IAAI,MAAM,QAAQ;AAAA,cACzB,UAAU,CAAC,MAAM,SAAS,QAAQ,EAAE,OAAO,KAAK;AAAA;AAAA,UAClD;AAAA,UACA,oBAAC,WAAM,OAAO,EAAE,OAAO,iBAAG;AAAA,UAC1B;AAAA,YAAC;AAAA;AAAA,cACC,OAAO,EAAE;AAAA,cACT,OAAO,IAAI,MAAM,QAAQ;AAAA,cACzB,UAAU,CAAC,MAAM,SAAS,QAAQ,EAAE,OAAO,KAAK;AAAA;AAAA,UAClD;AAAA,WACF;AAAA,QAGD,SAAS,oBAAC,SAAI,OAAO,EAAE,GAAG,EAAE,OAAO,cAAc,EAAE,GAAI,iBAAM;AAAA,QAC9D,oBAAC,SAAI,OAAO,EAAE,SAAS,QAAQ,KAAK,GAAG,gBAAgB,WAAW,GAC/D,mBACH;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/react/GRail/client.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { saveOverride } from \"../../server/actions\";\nimport { GRailRender } from \"./render\";\nimport { useGRail } from \"../Provider\";\nimport { useAnchorRect } from \"../useAnchorRect\";\nimport { CheckIcon, CloseIcon, SpinnerIcon } from \"../Icons\";\nimport { S } from \"../styles\";\nimport { MediaPicker } from \"../MediaPicker\";\nimport type { HTMLKeys, OverrideRow, OverrideValue } from \"../../core/types\";\n\nexport function GRailClient({\n as,\n initialOverride,\n ...htmlProps\n}: {\n as?: HTMLKeys;\n initialOverride: OverrideRow;\n [key: string]: unknown;\n}) {\n const { isEditMode } = useGRail();\n const [editing, setEditing] = useState(false);\n const [saving, setSaving] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [row, setRow] = useState<OverrideRow>(initialOverride);\n\n const elementRef = useRef<HTMLElement | null>(null);\n const rect = useAnchorRect(elementRef, editing);\n\n /**\n * The text the element was rendered with when this edit session began.\n *\n * While editing, the DOM owns the text and React must not touch it. Feeding\n * state back into a contentEditable's children makes React replace the text\n * node on every keystroke, which resets the caret to offset 0 — typing then\n * appears reversed and backspace jumps to the start. Holding this value\n * constant means the children prop never changes, so React leaves the node\n * alone and the caret stays put.\n */\n const sessionTextRef = useRef<string>(initialOverride.value.text ?? \"\");\n /** Live DOM text, updated without re-rendering. Read on save. */\n const draftTextRef = useRef<string>(initialOverride.value.text ?? \"\");\n\n const isInline = row.value.type === \"text\" || row.value.type === \"button\";\n\n const beginEdit = () => {\n sessionTextRef.current = row.value.text ?? \"\";\n draftTextRef.current = row.value.text ?? \"\";\n setError(null);\n setEditing(true);\n };\n\n const updateAttribute = (key: string, value: string) =>\n setRow((prev) => ({ ...prev, value: { ...prev.value, [key]: value } }));\n\n const patchValue = (patch: Partial<OverrideValue>) =>\n setRow((prev) => ({ ...prev, value: { ...prev.value, ...patch } }));\n\n const handleSave = async () => {\n // Inline text lives in the DOM, not in state, so read it back here.\n const next: OverrideRow = isInline\n ? { ...row, value: { ...row.value, text: draftTextRef.current } }\n : row;\n\n setSaving(true);\n setError(null);\n const res = await saveOverride(next);\n setSaving(false);\n\n if (!res.success) {\n setError(res.error ?? \"Save failed.\");\n return;\n }\n setRow(next);\n setEditing(false);\n };\n\n const handleCancel = () => {\n setRow(initialOverride);\n draftTextRef.current = initialOverride.value.text ?? \"\";\n if (isInline && elementRef.current) {\n elementRef.current.textContent = initialOverride.value.text ?? \"\";\n }\n setError(null);\n setEditing(false);\n };\n\n // Clicking away from an active edit cancels it, the same as Escape. Anything\n // inside the field itself (repositioning the caret) or inside the anchored\n // toolbar/panel (both carry data-guardrail) is not \"away\" — checked via\n // closest() rather than React's onClick so a stopPropagation() inside the\n // chrome (image/link panel inputs) reliably suppresses this too, since that\n // call stops the native event before it ever reaches this document listener.\n useEffect(() => {\n if (!editing) return;\n const handlePointerDown = (e: MouseEvent) => {\n const target = e.target as Node;\n if (elementRef.current?.contains(target)) return;\n if (target instanceof Element && target.closest(\"[data-guardrail]\")) return;\n handleCancel();\n };\n document.addEventListener(\"mousedown\", handlePointerDown);\n return () => document.removeEventListener(\"mousedown\", handlePointerDown);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [editing]);\n\n if (!isEditMode) {\n return <GRailRender as={as} {...htmlProps} override={row.value} />;\n }\n\n // Frozen during the session so React never rewrites the live text node.\n const renderedValue =\n editing && isInline\n ? { ...row.value, text: sessionTextRef.current }\n : row.value;\n\n return (\n <>\n <GRailRender\n as={as}\n {...htmlProps}\n ref={elementRef}\n override={renderedValue}\n style={{\n ...(htmlProps.style as React.CSSProperties),\n outline: editing ? \"2px solid #2563eb\" : \"1px dashed #60a5fa\",\n outlineOffset: 2,\n cursor: editing ? \"text\" : \"pointer\",\n }}\n onClick={(e: React.MouseEvent) => {\n if (editing) return;\n e.preventDefault();\n // preventDefault only blocks the browser's native action (following\n // an href); it does not stop the click from bubbling. A field\n // rendered inside a Link would still trigger the Link's own onClick\n // and navigate anyway — stopPropagation is what actually claims the\n // click for editing instead. (Use `editable={false}` on fields\n // meant to stay pure navigation, e.g. inside a card that links to\n // that content's own page.)\n e.stopPropagation();\n beginEdit();\n }}\n // Spread only for inline text: images and links would receive invalid\n // DOM props (contentEditable on next/image, etc).\n {...(isInline\n ? {\n contentEditable: editing,\n suppressContentEditableWarning: true,\n onInput: (e: React.FormEvent<HTMLElement>) => {\n // Ref only — setState here re-renders and moves the caret.\n draftTextRef.current = e.currentTarget.textContent ?? \"\";\n },\n onKeyDown: (e: React.KeyboardEvent) => {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n void handleSave();\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n handleCancel();\n }\n },\n }\n : {})}\n />\n\n {editing && rect && (\n <Chrome\n rect={rect}\n isInline={isInline}\n row={row}\n error={error}\n saving={saving}\n onChange={updateAttribute}\n onPatch={patchValue}\n onSave={handleSave}\n onCancel={handleCancel}\n />\n )}\n </>\n );\n}\n\nfunction Chrome({\n rect,\n isInline,\n row,\n error,\n saving,\n onChange,\n onPatch,\n onSave,\n onCancel,\n}: {\n rect: { top: number; left: number; bottom: number; width: number };\n isInline: boolean;\n row: OverrideRow;\n error: string | null;\n saving: boolean;\n onChange: (key: string, value: string) => void;\n onPatch: (patch: Partial<OverrideValue>) => void;\n onSave: () => void;\n onCancel: () => void;\n}) {\n const { storage } = useGRail();\n const [pickerOpen, setPickerOpen] = useState(false);\n const GAP = 8;\n // Flip above the element when there is no room below it.\n const below = rect.bottom + GAP;\n const flip = typeof window !== \"undefined\" && below > window.innerHeight - 120;\n\n const position: React.CSSProperties = {\n left: Math.max(8, rect.left),\n ...(flip ? { top: Math.max(8, rect.top - GAP - 44) } : { top: below }),\n };\n\n const actions = (\n <>\n <button\n style={S.iconBtnPrimary}\n onClick={onSave}\n disabled={saving}\n title=\"Save (Enter)\"\n aria-label=\"Save\"\n >\n {saving ? <SpinnerIcon /> : <CheckIcon />}\n </button>\n <button\n style={S.iconBtn}\n onClick={onCancel}\n disabled={saving}\n title=\"Cancel (Esc)\"\n aria-label=\"Cancel\"\n >\n <CloseIcon />\n </button>\n </>\n );\n\n // Text and buttons edit in place, so they only need the two controls.\n if (isInline) {\n return (\n <div data-guardrail style={{ ...S.anchoredBar, ...position }}>\n {actions}\n {error && <span style={{ ...S.error, margin: \"0 6px\" }}>{error}</span>}\n </div>\n );\n }\n\n // Images and links carry attributes with no on-page representation.\n return (\n <div\n data-guardrail\n style={{ ...S.anchoredPanel, ...position }}\n onClick={(e) => e.stopPropagation()}\n >\n {row.value.type === \"image\" && (\n <>\n {row.value.src && (\n // Plain img: previews must not depend on remotePatterns.\n <img src={row.value.src} alt=\"\" style={S.previewThumb} />\n )}\n\n {storage && (\n <button\n type=\"button\"\n style={S.secondaryBtn}\n onClick={() => setPickerOpen(true)}\n >\n {row.value.src ? \"Replace image\" : \"Choose image\"}\n </button>\n )}\n\n <label style={S.label}>Alt text</label>\n <input\n style={S.field}\n value={row.value.alt || \"\"}\n placeholder=\"Describe the image for screen readers\"\n onChange={(e) => onChange(\"alt\", e.target.value)}\n />\n\n {/* Only without storage: there is no picker then, so a URL is the one\n way to set an image. A typed URL has unknown proportions, so any\n stored dimensions are cleared. */}\n {!storage && (\n <>\n <label style={S.label}>Image URL</label>\n <input\n style={S.field}\n value={row.value.src || \"\"}\n onChange={(e) =>\n onPatch({ src: e.target.value, width: undefined, height: undefined })\n }\n />\n </>\n )}\n\n {pickerOpen && (\n <MediaPicker\n current={row.value.src}\n onClose={() => setPickerOpen(false)}\n onSelect={(image) =>\n onPatch({ src: image.src, width: image.width, height: image.height })\n }\n />\n )}\n </>\n )}\n\n {row.value.type === \"link\" && (\n <>\n <label style={S.label}>Link text</label>\n <input\n style={S.field}\n value={row.value.text || \"\"}\n onChange={(e) => onChange(\"text\", e.target.value)}\n />\n <label style={S.label}>URL</label>\n <input\n style={S.field}\n value={row.value.href || \"\"}\n onChange={(e) => onChange(\"href\", e.target.value)}\n />\n </>\n )}\n\n {error && <div style={{ ...S.error, marginBottom: 8 }}>{error}</div>}\n <div style={{ display: \"flex\", gap: 4, justifyContent: \"flex-end\" }}>\n {actions}\n </div>\n </div>\n );\n}\n"],"mappings":";AA4GW,SAUP,UAVO,KAUP,YAVO;AA1GX,OAAO,SAAS,WAAW,QAAQ,gBAAgB;AACnD,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAC9B,SAAS,WAAW,WAAW,mBAAmB;AAClD,SAAS,SAAS;AAClB,SAAS,mBAAmB;AAGrB,SAAS,YAAY;AAAA,EAC1B;AA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BACxB,UAAU,CAAC,MACT,QAAQ,EAAE,KAAK,EAAE,OAAO,OAAO,OAAO,QAAW,QAAQ,OAAU,CAAC;AAAA;AAAA,YAExE;AAAA,aACF;AAAA,UAGD,cACC;AAAA,YAAC;AAAA;AAAA,cACC,SAAS,IAAI,MAAM;AAAA,cACnB,SAAS,MAAM,cAAc,KAAK;AAAA,cAClC,UAAU,CAAC,UACT,QAAQ,EAAE,KAAK,MAAM,KAAK,OAAO,MAAM,OAAO,QAAQ,MAAM,OAAO,CAAC;AAAA;AAAA,UAExE;AAAA,WAEJ;AAAA,QAGD,IAAI,MAAM,SAAS,UAClB,iCACE;AAAA,8BAAC,WAAM,OAAO,EAAE,OAAO,uBAAS;AAAA,UAChC;AAAA,YAAC;AAAA;AAAA,cACC,OAAO,EAAE;AAAA,cACT,OAAO,IAAI,MAAM,QAAQ;AAAA,cACzB,UAAU,CAAC,MAAM,SAAS,QAAQ,EAAE,OAAO,KAAK;AAAA;AAAA,UAClD;AAAA,UACA,oBAAC,WAAM,OAAO,EAAE,OAAO,iBAAG;AAAA,UAC1B;AAAA,YAAC;AAAA;AAAA,cACC,OAAO,EAAE;AAAA,cACT,OAAO,IAAI,MAAM,QAAQ;AAAA,cACzB,UAAU,CAAC,MAAM,SAAS,QAAQ,EAAE,OAAO,KAAK;AAAA;AAAA,UAClD;AAAA,WACF;AAAA,QAGD,SAAS,oBAAC,SAAI,OAAO,EAAE,GAAG,EAAE,OAAO,cAAc,EAAE,GAAI,iBAAM;AAAA,QAC9D,oBAAC,SAAI,OAAO,EAAE,SAAS,QAAQ,KAAK,GAAG,gBAAgB,WAAW,GAC/D,mBACH;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
package/dist/react/styles.d.ts
CHANGED
|
@@ -30,6 +30,15 @@ declare const S: {
|
|
|
30
30
|
fontSize: number;
|
|
31
31
|
textTransform: "uppercase";
|
|
32
32
|
};
|
|
33
|
+
/** Brand plus any status/error text under it, stacked instead of sharing
|
|
34
|
+
* the form's row — otherwise a login error reads as if it's labeling the
|
|
35
|
+
* next field over, not feedback about the brand's own sign-in attempt. */
|
|
36
|
+
brandStack: {
|
|
37
|
+
display: "flex";
|
|
38
|
+
flexDirection: "column";
|
|
39
|
+
alignItems: "flex-start";
|
|
40
|
+
gap: number;
|
|
41
|
+
};
|
|
33
42
|
error: {
|
|
34
43
|
color: "#dc2626";
|
|
35
44
|
fontSize: number;
|
package/dist/react/styles.js
CHANGED
|
@@ -24,6 +24,15 @@ const S = {
|
|
|
24
24
|
fontSize: 12,
|
|
25
25
|
textTransform: "uppercase"
|
|
26
26
|
},
|
|
27
|
+
/** Brand plus any status/error text under it, stacked instead of sharing
|
|
28
|
+
* the form's row — otherwise a login error reads as if it's labeling the
|
|
29
|
+
* next field over, not feedback about the brand's own sign-in attempt. */
|
|
30
|
+
brandStack: {
|
|
31
|
+
display: "flex",
|
|
32
|
+
flexDirection: "column",
|
|
33
|
+
alignItems: "flex-start",
|
|
34
|
+
gap: 2
|
|
35
|
+
},
|
|
27
36
|
error: { color: "#dc2626", fontSize: 12, fontWeight: 700 },
|
|
28
37
|
input: {
|
|
29
38
|
border: "1px solid #d1d5db",
|
package/dist/react/styles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react/styles.ts"],"sourcesContent":["import type { CSSProperties } from \"react\";\n\n/**\n * Guardrail's own chrome is styled with inline styles on purpose. Utility\n * classes would make the package depend on the consumer having Tailwind *and*\n * adding node_modules/guardrail to their content globs — it would render\n * unstyled on a clean install. Developer-authored content is never touched.\n */\nexport const S = {\n banner: {\n position: \"fixed\",\n bottom: 0,\n left: 0,\n width: \"100%\",\n background: \"#fff\",\n color: \"#000\",\n padding: \"12px 16px\",\n zIndex: 10000,\n borderTop: \"1px solid #e5e7eb\",\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n bannerForm: {\n display: \"flex\",\n gap: 12,\n justifyContent: \"center\",\n alignItems: \"center\",\n flexWrap: \"wrap\",\n },\n brand: {\n fontWeight: 900,\n letterSpacing: \"0.15em\",\n fontSize: 12,\n textTransform: \"uppercase\",\n },\n error: { color: \"#dc2626\", fontSize: 12, fontWeight: 700 },\n input: {\n border: \"1px solid #d1d5db\",\n borderRadius: 4,\n padding: \"6px 8px\",\n fontSize: 13,\n color: \"#000\",\n background: \"#fff\",\n outline: \"none\",\n },\n primaryBtn: {\n background: \"#111827\",\n color: \"#fff\",\n padding: \"7px 16px\",\n borderRadius: 4,\n fontSize: 12,\n fontWeight: 700,\n border: \"none\",\n cursor: \"pointer\",\n },\n toolbar: {\n position: \"fixed\",\n bottom: 24,\n left: \"50%\",\n transform: \"translateX(-50%)\",\n zIndex: 9999,\n background: \"rgba(17,24,39,0.95)\",\n backdropFilter: \"blur(8px)\",\n color: \"#fff\",\n padding: \"12px 20px\",\n borderRadius: 9999,\n boxShadow: \"0 20px 40px rgba(0,0,0,0.35)\",\n display: \"flex\",\n alignItems: \"center\",\n gap: 20,\n border: \"1px solid rgba(255,255,255,0.1)\",\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n dot: {\n display: \"inline-block\",\n width: 8,\n height: 8,\n borderRadius: \"50%\",\n background: \"#3b82f6\",\n },\n toolbarLabel: {\n fontSize: 10,\n fontWeight: 900,\n textTransform: \"uppercase\",\n letterSpacing: \"0.2em\",\n color: \"#dbeafe\",\n },\n divider: { width: 1, height: 16, background: \"rgba(255,255,255,0.2)\" },\n linkBtn: {\n fontSize: 10,\n fontWeight: 700,\n textTransform: \"uppercase\",\n letterSpacing: \"0.15em\",\n color: \"#9ca3af\",\n background: \"none\",\n border: \"none\",\n cursor: \"pointer\",\n },\n popover: {\n position: \"fixed\",\n bottom: 90,\n left: \"50%\",\n transform: \"translateX(-50%)\",\n zIndex: 10001,\n background: \"#fff\",\n padding: 16,\n borderRadius: 8,\n boxShadow: \"0 20px 40px rgba(0,0,0,0.25)\",\n border: \"1px solid #e5e7eb\",\n minWidth: 300,\n cursor: \"default\",\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n label: {\n display: \"block\",\n fontSize: 10,\n fontWeight: 700,\n color: \"#9ca3af\",\n marginBottom: 4,\n textTransform: \"uppercase\",\n },\n field: {\n border: \"1px solid #d1d5db\",\n borderRadius: 4,\n padding: \"6px 8px\",\n fontSize: 13,\n color: \"#000\",\n background: \"#fff\",\n width: \"100%\",\n marginBottom: 8,\n boxSizing: \"border-box\",\n },\n row: {\n display: \"flex\",\n gap: 8,\n marginTop: 8,\n paddingTop: 8,\n borderTop: \"1px solid #f3f4f6\",\n },\n cancelBtn: {\n background: \"#f3f4f6\",\n color: \"#4b5563\",\n padding: \"7px 14px\",\n borderRadius: 4,\n fontSize: 12,\n border: \"none\",\n cursor: \"pointer\",\n },\n\n /** Anchored to the element's rect at runtime; top/left are set inline. */\n anchoredBar: {\n position: \"fixed\",\n zIndex: 10001,\n display: \"flex\",\n alignItems: \"center\",\n gap: 4,\n background: \"rgba(17,24,39,0.97)\",\n backdropFilter: \"blur(8px)\",\n padding: 4,\n borderRadius: 8,\n boxShadow: \"0 8px 24px rgba(0,0,0,0.3)\",\n border: \"1px solid rgba(255,255,255,0.12)\",\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n anchoredPanel: {\n position: \"fixed\",\n zIndex: 10001,\n maxHeight: \"calc(100vh - 24px)\",\n overflowY: \"auto\",\n background: \"#fff\",\n padding: 12,\n borderRadius: 8,\n boxShadow: \"0 12px 32px rgba(0,0,0,0.25)\",\n border: \"1px solid #e5e7eb\",\n minWidth: 260,\n maxWidth: \"min(340px, calc(100vw - 16px))\",\n cursor: \"default\",\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n iconBtn: {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: 26,\n height: 26,\n borderRadius: 6,\n border: \"none\",\n background: \"transparent\",\n color: \"#e5e7eb\",\n cursor: \"pointer\",\n padding: 0,\n },\n iconBtnPrimary: {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: 26,\n height: 26,\n borderRadius: 6,\n border: \"none\",\n background: \"#2563eb\",\n color: \"#fff\",\n cursor: \"pointer\",\n padding: 0,\n },\n\n scrim: {\n position: \"fixed\",\n inset: 0,\n background: \"rgba(0,0,0,0.4)\",\n zIndex: 10002,\n },\n drawer: {\n position: \"fixed\",\n top: 0,\n right: 0,\n height: \"100%\",\n width: \"min(420px, 100vw)\",\n background: \"#fff\",\n color: \"#111827\",\n zIndex: 10003,\n boxShadow: \"-12px 0 32px rgba(0,0,0,0.2)\",\n display: \"flex\",\n flexDirection: \"column\",\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n drawerHead: {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n padding: \"16px 20px\",\n borderBottom: \"1px solid #e5e7eb\",\n },\n drawerTitle: { fontSize: 14, fontWeight: 800, margin: 0 },\n drawerBody: { padding: 20, overflowY: \"auto\", flex: 1 },\n memberRow: {\n display: \"flex\",\n alignItems: \"center\",\n gap: 8,\n padding: \"10px 0\",\n borderBottom: \"1px solid #f3f4f6\",\n },\n memberEmail: {\n flex: 1,\n fontSize: 13,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n },\n select: {\n border: \"1px solid #d1d5db\",\n borderRadius: 4,\n padding: \"4px 6px\",\n fontSize: 12,\n background: \"#fff\",\n color: \"#111827\",\n },\n badge: {\n fontSize: 9,\n fontWeight: 800,\n textTransform: \"uppercase\",\n letterSpacing: \"0.1em\",\n padding: \"2px 6px\",\n borderRadius: 999,\n background: \"#fef3c7\",\n color: \"#92400e\",\n },\n sectionLabel: {\n fontSize: 10,\n fontWeight: 800,\n textTransform: \"uppercase\",\n letterSpacing: \"0.15em\",\n color: \"#9ca3af\",\n margin: \"20px 0 8px\",\n },\n\n pickerScrim: {\n position: \"fixed\",\n inset: 0,\n background: \"rgba(0,0,0,0.5)\",\n zIndex: 10010,\n },\n picker: {\n position: \"fixed\",\n top: \"50%\",\n left: \"50%\",\n transform: \"translate(-50%, -50%)\",\n width: \"min(720px, calc(100vw - 32px))\",\n maxHeight: \"min(640px, calc(100vh - 32px))\",\n background: \"#fff\",\n color: \"#111827\",\n borderRadius: 12,\n zIndex: 10011,\n boxShadow: \"0 24px 64px rgba(0,0,0,0.35)\",\n display: \"flex\",\n flexDirection: \"column\",\n overflow: \"hidden\",\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n pickerGrid: {\n display: \"grid\",\n gridTemplateColumns: \"repeat(auto-fill, minmax(120px, 1fr))\",\n gap: 10,\n },\n pickerTile: {\n position: \"relative\",\n aspectRatio: \"1\",\n borderRadius: 8,\n overflow: \"hidden\",\n border: \"2px solid transparent\",\n background: \"#f3f4f6\",\n cursor: \"pointer\",\n padding: 0,\n },\n pickerTileActive: { borderColor: \"#2563eb\" },\n pickerThumb: {\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n display: \"block\",\n },\n dropzone: {\n border: \"1.5px dashed #d1d5db\",\n borderRadius: 8,\n padding: 16,\n textAlign: \"center\",\n fontSize: 13,\n color: \"#6b7280\",\n marginBottom: 14,\n cursor: \"pointer\",\n },\n dropzoneActive: {\n borderColor: \"#2563eb\",\n background: \"#eff6ff\",\n color: \"#1d4ed8\",\n },\n previewThumb: {\n // maxWidth also caps what the image contributes to the panel's width. The\n // panel shrink-wraps its content, so an uncapped width: 100% image grew\n // the whole panel to the picture's natural size.\n width: \"100%\",\n maxWidth: 300,\n height: \"auto\",\n maxHeight: 200,\n objectFit: \"contain\",\n background: \"#f3f4f6\",\n borderRadius: 6,\n display: \"block\",\n marginBottom: 8,\n },\n secondaryBtn: {\n background: \"#f3f4f6\",\n color: \"#111827\",\n padding: \"7px 12px\",\n borderRadius: 4,\n fontSize: 12,\n fontWeight: 600,\n border: \"none\",\n cursor: \"pointer\",\n width: \"100%\",\n marginBottom: 10,\n },\n\n repeaterItem: {\n position: \"relative\",\n outline: \"1px dashed #60a5fa\",\n outlineOffset: 2,\n },\n repeaterToolbar: {\n position: \"absolute\",\n top: 4,\n right: 4,\n zIndex: 20,\n display: \"flex\",\n gap: 2,\n background: \"rgba(17,24,39,0.9)\",\n backdropFilter: \"blur(6px)\",\n padding: 3,\n borderRadius: 6,\n boxShadow: \"0 4px 12px rgba(0,0,0,0.25)\",\n },\n repeaterAddRow: {\n display: \"flex\",\n gap: 8,\n alignItems: \"center\",\n marginTop: 8,\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n repeaterAddBtn: {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: 6,\n padding: \"8px 14px\",\n borderRadius: 6,\n border: \"1.5px dashed #93c5fd\",\n background: \"transparent\",\n color: \"#2563eb\",\n fontSize: 12,\n fontWeight: 700,\n cursor: \"pointer\",\n },\n repeaterSlugInput: {\n border: \"1px solid #d1d5db\",\n borderRadius: 4,\n padding: \"7px 9px\",\n fontSize: 13,\n color: \"#000\",\n background: \"#fff\",\n minWidth: 180,\n },\n} satisfies Record<string, CSSProperties>;\n"],"mappings":"AAQO,MAAM,IAAI;AAAA,EACf,QAAQ;AAAA,IACN,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,YAAY;AAAA,EACd;AAAA,EACA,YAAY;AAAA,IACV,SAAS;AAAA,IACT,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AAAA,EACA,OAAO;AAAA,IACL,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA,OAAO,EAAE,OAAO,WAAW,UAAU,IAAI,YAAY,IAAI;AAAA,EACzD,OAAO;AAAA,IACL,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,SAAS;AAAA,IACT,UA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OAAO;AAAA,IACP,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/react/styles.ts"],"sourcesContent":["import type { CSSProperties } from \"react\";\n\n/**\n * Guardrail's own chrome is styled with inline styles on purpose. Utility\n * classes would make the package depend on the consumer having Tailwind *and*\n * adding node_modules/guardrail to their content globs — it would render\n * unstyled on a clean install. Developer-authored content is never touched.\n */\nexport const S = {\n banner: {\n position: \"fixed\",\n bottom: 0,\n left: 0,\n width: \"100%\",\n background: \"#fff\",\n color: \"#000\",\n padding: \"12px 16px\",\n zIndex: 10000,\n borderTop: \"1px solid #e5e7eb\",\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n bannerForm: {\n display: \"flex\",\n gap: 12,\n justifyContent: \"center\",\n alignItems: \"center\",\n flexWrap: \"wrap\",\n },\n brand: {\n fontWeight: 900,\n letterSpacing: \"0.15em\",\n fontSize: 12,\n textTransform: \"uppercase\",\n },\n /** Brand plus any status/error text under it, stacked instead of sharing\n * the form's row — otherwise a login error reads as if it's labeling the\n * next field over, not feedback about the brand's own sign-in attempt. */\n brandStack: {\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"flex-start\",\n gap: 2,\n },\n error: { color: \"#dc2626\", fontSize: 12, fontWeight: 700 },\n input: {\n border: \"1px solid #d1d5db\",\n borderRadius: 4,\n padding: \"6px 8px\",\n fontSize: 13,\n color: \"#000\",\n background: \"#fff\",\n outline: \"none\",\n },\n primaryBtn: {\n background: \"#111827\",\n color: \"#fff\",\n padding: \"7px 16px\",\n borderRadius: 4,\n fontSize: 12,\n fontWeight: 700,\n border: \"none\",\n cursor: \"pointer\",\n },\n toolbar: {\n position: \"fixed\",\n bottom: 24,\n left: \"50%\",\n transform: \"translateX(-50%)\",\n zIndex: 9999,\n background: \"rgba(17,24,39,0.95)\",\n backdropFilter: \"blur(8px)\",\n color: \"#fff\",\n padding: \"12px 20px\",\n borderRadius: 9999,\n boxShadow: \"0 20px 40px rgba(0,0,0,0.35)\",\n display: \"flex\",\n alignItems: \"center\",\n gap: 20,\n border: \"1px solid rgba(255,255,255,0.1)\",\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n dot: {\n display: \"inline-block\",\n width: 8,\n height: 8,\n borderRadius: \"50%\",\n background: \"#3b82f6\",\n },\n toolbarLabel: {\n fontSize: 10,\n fontWeight: 900,\n textTransform: \"uppercase\",\n letterSpacing: \"0.2em\",\n color: \"#dbeafe\",\n },\n divider: { width: 1, height: 16, background: \"rgba(255,255,255,0.2)\" },\n linkBtn: {\n fontSize: 10,\n fontWeight: 700,\n textTransform: \"uppercase\",\n letterSpacing: \"0.15em\",\n color: \"#9ca3af\",\n background: \"none\",\n border: \"none\",\n cursor: \"pointer\",\n },\n popover: {\n position: \"fixed\",\n bottom: 90,\n left: \"50%\",\n transform: \"translateX(-50%)\",\n zIndex: 10001,\n background: \"#fff\",\n padding: 16,\n borderRadius: 8,\n boxShadow: \"0 20px 40px rgba(0,0,0,0.25)\",\n border: \"1px solid #e5e7eb\",\n minWidth: 300,\n cursor: \"default\",\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n label: {\n display: \"block\",\n fontSize: 10,\n fontWeight: 700,\n color: \"#9ca3af\",\n marginBottom: 4,\n textTransform: \"uppercase\",\n },\n field: {\n border: \"1px solid #d1d5db\",\n borderRadius: 4,\n padding: \"6px 8px\",\n fontSize: 13,\n color: \"#000\",\n background: \"#fff\",\n width: \"100%\",\n marginBottom: 8,\n boxSizing: \"border-box\",\n },\n row: {\n display: \"flex\",\n gap: 8,\n marginTop: 8,\n paddingTop: 8,\n borderTop: \"1px solid #f3f4f6\",\n },\n cancelBtn: {\n background: \"#f3f4f6\",\n color: \"#4b5563\",\n padding: \"7px 14px\",\n borderRadius: 4,\n fontSize: 12,\n border: \"none\",\n cursor: \"pointer\",\n },\n\n /** Anchored to the element's rect at runtime; top/left are set inline. */\n anchoredBar: {\n position: \"fixed\",\n zIndex: 10001,\n display: \"flex\",\n alignItems: \"center\",\n gap: 4,\n background: \"rgba(17,24,39,0.97)\",\n backdropFilter: \"blur(8px)\",\n padding: 4,\n borderRadius: 8,\n boxShadow: \"0 8px 24px rgba(0,0,0,0.3)\",\n border: \"1px solid rgba(255,255,255,0.12)\",\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n anchoredPanel: {\n position: \"fixed\",\n zIndex: 10001,\n maxHeight: \"calc(100vh - 24px)\",\n overflowY: \"auto\",\n background: \"#fff\",\n padding: 12,\n borderRadius: 8,\n boxShadow: \"0 12px 32px rgba(0,0,0,0.25)\",\n border: \"1px solid #e5e7eb\",\n minWidth: 260,\n maxWidth: \"min(340px, calc(100vw - 16px))\",\n cursor: \"default\",\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n iconBtn: {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: 26,\n height: 26,\n borderRadius: 6,\n border: \"none\",\n background: \"transparent\",\n color: \"#e5e7eb\",\n cursor: \"pointer\",\n padding: 0,\n },\n iconBtnPrimary: {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: 26,\n height: 26,\n borderRadius: 6,\n border: \"none\",\n background: \"#2563eb\",\n color: \"#fff\",\n cursor: \"pointer\",\n padding: 0,\n },\n\n scrim: {\n position: \"fixed\",\n inset: 0,\n background: \"rgba(0,0,0,0.4)\",\n zIndex: 10002,\n },\n drawer: {\n position: \"fixed\",\n top: 0,\n right: 0,\n height: \"100%\",\n width: \"min(420px, 100vw)\",\n background: \"#fff\",\n color: \"#111827\",\n zIndex: 10003,\n boxShadow: \"-12px 0 32px rgba(0,0,0,0.2)\",\n display: \"flex\",\n flexDirection: \"column\",\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n drawerHead: {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n padding: \"16px 20px\",\n borderBottom: \"1px solid #e5e7eb\",\n },\n drawerTitle: { fontSize: 14, fontWeight: 800, margin: 0 },\n drawerBody: { padding: 20, overflowY: \"auto\", flex: 1 },\n memberRow: {\n display: \"flex\",\n alignItems: \"center\",\n gap: 8,\n padding: \"10px 0\",\n borderBottom: \"1px solid #f3f4f6\",\n },\n memberEmail: {\n flex: 1,\n fontSize: 13,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n },\n select: {\n border: \"1px solid #d1d5db\",\n borderRadius: 4,\n padding: \"4px 6px\",\n fontSize: 12,\n background: \"#fff\",\n color: \"#111827\",\n },\n badge: {\n fontSize: 9,\n fontWeight: 800,\n textTransform: \"uppercase\",\n letterSpacing: \"0.1em\",\n padding: \"2px 6px\",\n borderRadius: 999,\n background: \"#fef3c7\",\n color: \"#92400e\",\n },\n sectionLabel: {\n fontSize: 10,\n fontWeight: 800,\n textTransform: \"uppercase\",\n letterSpacing: \"0.15em\",\n color: \"#9ca3af\",\n margin: \"20px 0 8px\",\n },\n\n pickerScrim: {\n position: \"fixed\",\n inset: 0,\n background: \"rgba(0,0,0,0.5)\",\n zIndex: 10010,\n },\n picker: {\n position: \"fixed\",\n top: \"50%\",\n left: \"50%\",\n transform: \"translate(-50%, -50%)\",\n width: \"min(720px, calc(100vw - 32px))\",\n maxHeight: \"min(640px, calc(100vh - 32px))\",\n background: \"#fff\",\n color: \"#111827\",\n borderRadius: 12,\n zIndex: 10011,\n boxShadow: \"0 24px 64px rgba(0,0,0,0.35)\",\n display: \"flex\",\n flexDirection: \"column\",\n overflow: \"hidden\",\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n pickerGrid: {\n display: \"grid\",\n gridTemplateColumns: \"repeat(auto-fill, minmax(120px, 1fr))\",\n gap: 10,\n },\n pickerTile: {\n position: \"relative\",\n aspectRatio: \"1\",\n borderRadius: 8,\n overflow: \"hidden\",\n border: \"2px solid transparent\",\n background: \"#f3f4f6\",\n cursor: \"pointer\",\n padding: 0,\n },\n pickerTileActive: { borderColor: \"#2563eb\" },\n pickerThumb: {\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n display: \"block\",\n },\n dropzone: {\n border: \"1.5px dashed #d1d5db\",\n borderRadius: 8,\n padding: 16,\n textAlign: \"center\",\n fontSize: 13,\n color: \"#6b7280\",\n marginBottom: 14,\n cursor: \"pointer\",\n },\n dropzoneActive: {\n borderColor: \"#2563eb\",\n background: \"#eff6ff\",\n color: \"#1d4ed8\",\n },\n previewThumb: {\n // maxWidth also caps what the image contributes to the panel's width. The\n // panel shrink-wraps its content, so an uncapped width: 100% image grew\n // the whole panel to the picture's natural size.\n width: \"100%\",\n maxWidth: 300,\n height: \"auto\",\n maxHeight: 200,\n objectFit: \"contain\",\n background: \"#f3f4f6\",\n borderRadius: 6,\n display: \"block\",\n marginBottom: 8,\n },\n secondaryBtn: {\n background: \"#f3f4f6\",\n color: \"#111827\",\n padding: \"7px 12px\",\n borderRadius: 4,\n fontSize: 12,\n fontWeight: 600,\n border: \"none\",\n cursor: \"pointer\",\n width: \"100%\",\n marginBottom: 10,\n },\n\n repeaterItem: {\n position: \"relative\",\n outline: \"1px dashed #60a5fa\",\n outlineOffset: 2,\n },\n repeaterToolbar: {\n position: \"absolute\",\n top: 4,\n right: 4,\n zIndex: 20,\n display: \"flex\",\n gap: 2,\n background: \"rgba(17,24,39,0.9)\",\n backdropFilter: \"blur(6px)\",\n padding: 3,\n borderRadius: 6,\n boxShadow: \"0 4px 12px rgba(0,0,0,0.25)\",\n },\n repeaterAddRow: {\n display: \"flex\",\n gap: 8,\n alignItems: \"center\",\n marginTop: 8,\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n repeaterAddBtn: {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: 6,\n padding: \"8px 14px\",\n borderRadius: 6,\n border: \"1.5px dashed #93c5fd\",\n background: \"transparent\",\n color: \"#2563eb\",\n fontSize: 12,\n fontWeight: 700,\n cursor: \"pointer\",\n },\n repeaterSlugInput: {\n border: \"1px solid #d1d5db\",\n borderRadius: 4,\n padding: \"7px 9px\",\n fontSize: 13,\n color: \"#000\",\n background: \"#fff\",\n minWidth: 180,\n },\n} satisfies Record<string, CSSProperties>;\n"],"mappings":"AAQO,MAAM,IAAI;AAAA,EACf,QAAQ;AAAA,IACN,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,YAAY;AAAA,EACd;AAAA,EACA,YAAY;AAAA,IACV,SAAS;AAAA,IACT,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AAAA,EACA,OAAO;AAAA,IACL,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAIA,YAAY;AAAA,IACV,SAAS;AAAA,IACT,eAAe;AAAA,IACf,YAAY;AAAA,IACZ,KAAK;AAAA,EACP;AAAA,EACA,OAAO,EAAE,OAAO,WAAW,UAAU,IAAI,YAAY,IAAI;AAAA,EACzD,OAAO;AAAA,IACL,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,SAAS;AAAA,IACT,UAAU;AAAA,IACV,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,SAAS;AAAA,EACX;AAAA,EACA,YAAY;AAAA,IACV,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,SAAS;AAAA,IACT,cAAc;AAAA,IACd,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AAAA,EACA,SAAS;AAAA,IACP,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,OAAO;AAAA,IACP,SAAS;AAAA,IACT,cAAc;A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;AAAA,IACR,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,cAAc;AAAA,EAChB;AAAA,EAEA,cAAc;AAAA,IACZ,UAAU;AAAA,IACV,SAAS;AAAA,IACT,eAAe;AAAA,EACjB;AAAA,EACA,iBAAiB;AAAA,IACf,UAAU;AAAA,IACV,KAAK;AAAA,IACL,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,KAAK;AAAA,IACL,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,SAAS;AAAA,IACT,cAAc;AAAA,IACd,WAAW;AAAA,EACb;AAAA,EACA,gBAAgB;AAAA,IACd,SAAS;AAAA,IACT,KAAK;AAAA,IACL,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,YAAY;AAAA,EACd;AAAA,EACA,gBAAgB;AAAA,IACd,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,KAAK;AAAA,IACL,SAAS;AAAA,IACT,cAAc;AAAA,IACd,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,QAAQ;AAAA,EACV;AAAA,EACA,mBAAmB;AAAA,IACjB,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,SAAS;AAAA,IACT,UAAU;AAAA,IACV,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -204,6 +204,10 @@ create policy "editors manage repeater items"
|
|
|
204
204
|
-- Listing and uploading still go through the policies below. The size and
|
|
205
205
|
-- type limits are enforced by Storage itself, backing up the server action.
|
|
206
206
|
|
|
207
|
+
-- on conflict do nothing: a project that already has a 'gr-media' bucket
|
|
208
|
+
-- (a re-run, or one created by hand before this migration existed) must not
|
|
209
|
+
-- fail the whole migration over a bucket that already exists in the shape
|
|
210
|
+
-- this would create anyway.
|
|
207
211
|
insert into storage.buckets (id, name, public, file_size_limit, allowed_mime_types)
|
|
208
212
|
values (
|
|
209
213
|
'gr-media',
|
|
@@ -211,12 +215,22 @@ values (
|
|
|
211
215
|
true,
|
|
212
216
|
10485760,
|
|
213
217
|
array['image/png', 'image/jpeg', 'image/webp', 'image/gif', 'image/avif']
|
|
214
|
-
)
|
|
218
|
+
)
|
|
219
|
+
on conflict (id) do nothing;
|
|
215
220
|
|
|
216
221
|
-- Objects live under '<site_id>/…', so the first folder names the site and
|
|
217
222
|
-- membership on that site decides who may upload or browse. Scoped to the
|
|
218
223
|
-- 'gr-' prefix, not one bucket name, so any bucket a developer names via
|
|
219
224
|
-- supabaseStorage({ bucket }) is covered without another migration.
|
|
225
|
+
--
|
|
226
|
+
-- storage.objects is shared across the whole project, unlike the guardrail
|
|
227
|
+
-- schema's own tables above (which this same migration just created, so
|
|
228
|
+
-- they cannot already have policies on them) — Postgres has no
|
|
229
|
+
-- `create policy if not exists`, so a project with same-named leftover
|
|
230
|
+
-- policies (e.g. from a hand-built setup predating this migration) needs
|
|
231
|
+
-- the drop first or the whole migration fails on a policy that doesn't
|
|
232
|
+
-- conflict in substance, just in name.
|
|
233
|
+
drop policy if exists "gr editors upload media" on storage.objects;
|
|
220
234
|
create policy "gr editors upload media"
|
|
221
235
|
on storage.objects for insert
|
|
222
236
|
to authenticated
|
|
@@ -225,6 +239,7 @@ create policy "gr editors upload media"
|
|
|
225
239
|
and guardrail.gr_has_role((storage.foldername(name))[1], array['admin', 'editor'])
|
|
226
240
|
);
|
|
227
241
|
|
|
242
|
+
drop policy if exists "gr editors browse media" on storage.objects;
|
|
228
243
|
create policy "gr editors browse media"
|
|
229
244
|
on storage.objects for select
|
|
230
245
|
to authenticated
|