@spillway-cms/blocks 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/dist/ask.d.ts +39 -0
- package/dist/ask.js +96 -0
- package/dist/ask.js.map +1 -0
- package/dist/calendar.d.ts +42 -0
- package/dist/calendar.js +96 -0
- package/dist/calendar.js.map +1 -0
- package/dist/collection.d.ts +89 -0
- package/dist/collection.js +304 -0
- package/dist/collection.js.map +1 -0
- package/dist/config.d.ts +246 -0
- package/dist/config.js +638 -0
- package/dist/config.js.map +1 -0
- package/dist/css.d.ts +1 -0
- package/dist/css.js +606 -0
- package/dist/css.js.map +1 -0
- package/dist/docs-feedback.d.ts +34 -0
- package/dist/docs-feedback.js +57 -0
- package/dist/docs-feedback.js.map +1 -0
- package/dist/examples.d.ts +12 -0
- package/dist/examples.js +85 -0
- package/dist/examples.js.map +1 -0
- package/dist/experiment.d.ts +18 -0
- package/dist/experiment.js +20 -0
- package/dist/experiment.js.map +1 -0
- package/dist/form.d.ts +40 -0
- package/dist/form.js +252 -0
- package/dist/form.js.map +1 -0
- package/dist/gallery.d.ts +36 -0
- package/dist/gallery.js +114 -0
- package/dist/gallery.js.map +1 -0
- package/dist/image.d.ts +41 -0
- package/dist/image.js +39 -0
- package/dist/image.js.map +1 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts.d.ts +8 -0
- package/dist/layouts.js +81 -0
- package/dist/layouts.js.map +1 -0
- package/dist/markdown.d.ts +32 -0
- package/dist/markdown.js +283 -0
- package/dist/markdown.js.map +1 -0
- package/dist/marketing.d.ts +70 -0
- package/dist/marketing.js +208 -0
- package/dist/marketing.js.map +1 -0
- package/dist/menu.d.ts +43 -0
- package/dist/menu.js +75 -0
- package/dist/menu.js.map +1 -0
- package/dist/meta.d.ts +14 -0
- package/dist/meta.js +198 -0
- package/dist/meta.js.map +1 -0
- package/dist/module-block.d.ts +32 -0
- package/dist/module-block.js +76 -0
- package/dist/module-block.js.map +1 -0
- package/dist/motion.d.ts +19 -0
- package/dist/motion.js +161 -0
- package/dist/motion.js.map +1 -0
- package/dist/personalize.d.ts +18 -0
- package/dist/personalize.js +32 -0
- package/dist/personalize.js.map +1 -0
- package/dist/players.d.ts +30 -0
- package/dist/players.js +95 -0
- package/dist/players.js.map +1 -0
- package/dist/registry-browse.d.ts +31 -0
- package/dist/registry-browse.js +97 -0
- package/dist/registry-browse.js.map +1 -0
- package/dist/registry-gallery.d.ts +22 -0
- package/dist/registry-gallery.js +73 -0
- package/dist/registry-gallery.js.map +1 -0
- package/dist/registry-org.d.ts +22 -0
- package/dist/registry-org.js +44 -0
- package/dist/registry-org.js.map +1 -0
- package/dist/registry-package.d.ts +27 -0
- package/dist/registry-package.js +145 -0
- package/dist/registry-package.js.map +1 -0
- package/dist/registry-publisher.d.ts +20 -0
- package/dist/registry-publisher.js +46 -0
- package/dist/registry-publisher.js.map +1 -0
- package/dist/registry-shared.d.ts +29 -0
- package/dist/registry-shared.js +122 -0
- package/dist/registry-shared.js.map +1 -0
- package/dist/registry-stats.d.ts +15 -0
- package/dist/registry-stats.js +42 -0
- package/dist/registry-stats.js.map +1 -0
- package/dist/registry-types.d.ts +218 -0
- package/dist/registry-types.js +29 -0
- package/dist/registry-types.js.map +1 -0
- package/dist/sanitize.d.ts +37 -0
- package/dist/sanitize.js +293 -0
- package/dist/sanitize.js.map +1 -0
- package/dist/search.d.ts +25 -0
- package/dist/search.js +77 -0
- package/dist/search.js.map +1 -0
- package/dist/shared.d.ts +27 -0
- package/dist/shared.js +59 -0
- package/dist/shared.js.map +1 -0
- package/dist/status-board.d.ts +49 -0
- package/dist/status-board.js +81 -0
- package/dist/status-board.js.map +1 -0
- package/dist/story.d.ts +23 -0
- package/dist/story.js +58 -0
- package/dist/story.js.map +1 -0
- package/dist/styles.css +1361 -0
- package/dist/styles.d.ts +37 -0
- package/dist/styles.js +242 -0
- package/dist/styles.js.map +1 -0
- package/package.json +47 -3
- package/README.md +0 -3
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DocsFeedback: "Was this page helpful?" at the end of a documentation page. Two submit buttons (Yes, No)
|
|
3
|
+
* and an optional comment post to a form the site defines (`docs_feedback` by default) through the Form
|
|
4
|
+
* block's public submit path, with the page path and the documented version as hidden fields. No personal
|
|
5
|
+
* data is asked for; the forms module's honeypot, time-to-submit rule and rate limit apply like for any form.
|
|
6
|
+
*
|
|
7
|
+
* Server-safe: a plain HTML form that works without JavaScript (the server answers with a redirect back to
|
|
8
|
+
* the page and `?form=<key>&sent=1`, which the block reads to show the thanks line). The server resolves
|
|
9
|
+
* `formKey`'s existence, the page path and the CSP nonce before render; without a resolved form the block
|
|
10
|
+
* renders a placeholder so the editor still shows where it sits.
|
|
11
|
+
*/
|
|
12
|
+
import type { ComponentConfig } from '@puckeditor/core';
|
|
13
|
+
export interface DocsFeedbackProps {
|
|
14
|
+
/** The key of the form that stores the answers (fields: helpful, comment, page, version). */
|
|
15
|
+
formKey: string;
|
|
16
|
+
question: string;
|
|
17
|
+
yesLabel: string;
|
|
18
|
+
noLabel: string;
|
|
19
|
+
commentLabel: string;
|
|
20
|
+
thanksText: string;
|
|
21
|
+
/** The documented version, recorded with every answer (the docs kit fills it at import time). */
|
|
22
|
+
version: string;
|
|
23
|
+
/** Resolved by the server; never stored. */
|
|
24
|
+
resolved?: {
|
|
25
|
+
path: string;
|
|
26
|
+
sent: boolean;
|
|
27
|
+
error: boolean;
|
|
28
|
+
} | null;
|
|
29
|
+
nonce?: string;
|
|
30
|
+
}
|
|
31
|
+
/** Runs once per page: when the browser has fetch, posts the answer in place and shows the thanks line without leaving the page. */
|
|
32
|
+
export declare const DOCS_FEEDBACK_SCRIPT = "(function(){var fs=document.querySelectorAll('form[data-sw-docs-feedback]:not([data-sw-bound])');\nfor(var i=0;i<fs.length;i++)bind(fs[i]);\nfunction bind(f){f.setAttribute('data-sw-bound','1');var t=f.querySelector('input[name=\"_t\"]');if(t)t.value=String(Date.now());\nvar p=f.querySelector('input[name=\"_page\"]');if(p)p.value=location.href;var pg=f.querySelector('input[name=\"page\"]');if(pg&&!pg.value)pg.value=location.pathname;\nvar done=function(ok){var s=f.querySelector('[data-sw-docs-status]');if(!s)return;s.hidden=false;s.textContent=ok?f.getAttribute('data-sw-thanks'):'Something went wrong. Please try again.';var b=f.querySelector('.sw-docs-feedback__body');if(b&&ok)b.hidden=true};\nvar clicked=null;var btns=f.querySelectorAll('button[name=\"helpful\"]');for(var k=0;k<btns.length;k++)btns[k].addEventListener('click',function(e){clicked=e.currentTarget});\nf.addEventListener('submit',function(ev){if(!window.fetch)return;ev.preventDefault();var o={};var els=f.querySelectorAll('input,textarea');for(var j=0;j<els.length;j++){if(els[j].name)o[els[j].name]=els[j].value}if(clicked)o.helpful=clicked.value;\nfor(var m=0;m<btns.length;m++)btns[m].disabled=true;\nfetch(f.getAttribute('action'),{method:'POST',credentials:'same-origin',headers:{'Content-Type':'application/json','Accept':'application/json'},body:JSON.stringify(o)})\n.then(function(r){done(r.ok);if(!r.ok)for(var m=0;m<btns.length;m++)btns[m].disabled=false}).catch(function(){HTMLFormElement.prototype.submit.call(f)})})}})();";
|
|
33
|
+
export declare const docsFeedbackComponent: ComponentConfig<DocsFeedbackProps>;
|
|
34
|
+
export declare const docsFeedbackCss = "/* ---------- Docs feedback ---------- */\n\n.sw-docs-feedback { padding: var(--sw-space-3) 0 var(--sw-space-4); }\n.sw-docs-feedback__form { padding: var(--sw-space-3); border: 1px solid var(--sw-color-border); border-radius: var(--sw-radius, 8px); background: var(--sw-color-surface); }\n.sw-docs-feedback__question { margin: 0 0 var(--sw-space-2); font-weight: 600; }\n.sw-docs-feedback__comment { display: grid; gap: 0.35rem; margin-bottom: var(--sw-space-2); font-size: 0.9rem; color: var(--sw-color-muted); }\n.sw-docs-feedback__comment textarea { width: 100%; padding: 0.55rem 0.7rem; font: inherit; color: var(--sw-color-text); background: var(--sw-color-bg); border: 1px solid var(--sw-color-border); border-radius: var(--sw-radius, 8px); resize: vertical; }\n.sw-docs-feedback__comment textarea:focus-visible { outline: none; border-color: var(--sw-color-primary); box-shadow: var(--sw-focus-ring); }\n.sw-docs-feedback__buttons { display: flex; gap: var(--sw-space-1); flex-wrap: wrap; }\n.sw-docs-feedback__buttons button { font: inherit; cursor: pointer; }\n.sw-docs-feedback__buttons button[disabled] { opacity: 0.6; cursor: progress; }\n.sw-docs-feedback__status { margin: 0; font-weight: 500; }\n.sw-docs-feedback__status[hidden], .sw-docs-feedback__body[hidden] { display: none; }\n.sw-docs-feedback__placeholder { padding: var(--sw-space-2); border: 1px dashed var(--sw-color-border); border-radius: var(--sw-radius, 8px); color: var(--sw-color-muted); font-size: 0.9rem; text-align: center; }\n";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/** Runs once per page: when the browser has fetch, posts the answer in place and shows the thanks line without leaving the page. */
|
|
3
|
+
export const DOCS_FEEDBACK_SCRIPT = `(function(){var fs=document.querySelectorAll('form[data-sw-docs-feedback]:not([data-sw-bound])');
|
|
4
|
+
for(var i=0;i<fs.length;i++)bind(fs[i]);
|
|
5
|
+
function bind(f){f.setAttribute('data-sw-bound','1');var t=f.querySelector('input[name="_t"]');if(t)t.value=String(Date.now());
|
|
6
|
+
var p=f.querySelector('input[name="_page"]');if(p)p.value=location.href;var pg=f.querySelector('input[name="page"]');if(pg&&!pg.value)pg.value=location.pathname;
|
|
7
|
+
var done=function(ok){var s=f.querySelector('[data-sw-docs-status]');if(!s)return;s.hidden=false;s.textContent=ok?f.getAttribute('data-sw-thanks'):'Something went wrong. Please try again.';var b=f.querySelector('.sw-docs-feedback__body');if(b&&ok)b.hidden=true};
|
|
8
|
+
var clicked=null;var btns=f.querySelectorAll('button[name="helpful"]');for(var k=0;k<btns.length;k++)btns[k].addEventListener('click',function(e){clicked=e.currentTarget});
|
|
9
|
+
f.addEventListener('submit',function(ev){if(!window.fetch)return;ev.preventDefault();var o={};var els=f.querySelectorAll('input,textarea');for(var j=0;j<els.length;j++){if(els[j].name)o[els[j].name]=els[j].value}if(clicked)o.helpful=clicked.value;
|
|
10
|
+
for(var m=0;m<btns.length;m++)btns[m].disabled=true;
|
|
11
|
+
fetch(f.getAttribute('action'),{method:'POST',credentials:'same-origin',headers:{'Content-Type':'application/json','Accept':'application/json'},body:JSON.stringify(o)})
|
|
12
|
+
.then(function(r){done(r.ok);if(!r.ok)for(var m=0;m<btns.length;m++)btns[m].disabled=false}).catch(function(){HTMLFormElement.prototype.submit.call(f)})})}})();`;
|
|
13
|
+
export const docsFeedbackComponent = {
|
|
14
|
+
label: 'Docs feedback',
|
|
15
|
+
fields: {
|
|
16
|
+
formKey: { type: 'text', label: 'Form key', placeholder: 'docs_feedback' },
|
|
17
|
+
question: { type: 'text', label: 'Question' },
|
|
18
|
+
yesLabel: { type: 'text', label: 'Yes button' },
|
|
19
|
+
noLabel: { type: 'text', label: 'No button' },
|
|
20
|
+
commentLabel: { type: 'text', label: 'Comment label' },
|
|
21
|
+
thanksText: { type: 'text', label: 'Thanks text' },
|
|
22
|
+
version: { type: 'text', label: 'Documented version (recorded with the answer)' },
|
|
23
|
+
},
|
|
24
|
+
defaultProps: {
|
|
25
|
+
formKey: 'docs_feedback',
|
|
26
|
+
question: 'Was this page helpful?',
|
|
27
|
+
yesLabel: 'Yes',
|
|
28
|
+
noLabel: 'No',
|
|
29
|
+
commentLabel: 'Tell us more (optional)',
|
|
30
|
+
thanksText: 'Thanks for the feedback.',
|
|
31
|
+
version: '',
|
|
32
|
+
},
|
|
33
|
+
render: ({ formKey, question, yesLabel, noLabel, commentLabel, thanksText, version, resolved, nonce }) => {
|
|
34
|
+
const key = (formKey || 'docs_feedback').trim();
|
|
35
|
+
if (!resolved) {
|
|
36
|
+
return (_jsx("section", { className: "sw-block sw-docs-feedback", children: _jsx("div", { className: "sw-container sw-container--narrow", children: _jsxs("div", { className: "sw-docs-feedback__placeholder", role: "note", children: ["Docs feedback: posts to the form ", _jsx("code", { children: key }), " (created by the docs kit)"] }) }) }));
|
|
37
|
+
}
|
|
38
|
+
const id = `docs-feedback-${key}`;
|
|
39
|
+
return (_jsx("section", { className: "sw-block sw-docs-feedback", "aria-labelledby": `${id}-q`, children: _jsxs("div", { className: "sw-container sw-container--narrow", children: [_jsxs("form", { id: id, className: "sw-docs-feedback__form", method: "post", action: `/api/forms/${encodeURIComponent(key)}/submit`, "data-sw-docs-feedback": key, "data-sw-thanks": thanksText, children: [_jsx("p", { className: "sw-docs-feedback__status", "data-sw-docs-status": "", role: "status", "aria-live": "polite", hidden: !resolved.sent && !resolved.error, children: resolved.sent ? thanksText : resolved.error ? 'Something went wrong. Please try again.' : '' }), _jsxs("div", { className: "sw-docs-feedback__body", hidden: resolved.sent, children: [_jsx("p", { className: "sw-docs-feedback__question", id: `${id}-q`, children: question }), _jsxs("label", { className: "sw-docs-feedback__comment", htmlFor: `${id}-comment`, children: [_jsx("span", { children: commentLabel }), _jsx("textarea", { id: `${id}-comment`, name: "comment", rows: 2, maxLength: 2000 })] }), _jsx("input", { type: "hidden", name: "page", value: resolved.path }), _jsx("input", { type: "hidden", name: "version", value: version }), _jsx("input", { type: "hidden", name: "_page", value: resolved.path }), _jsx("input", { type: "hidden", name: "_t", value: String(Date.now()) }), _jsxs("div", { className: "sw-form__hp", "aria-hidden": "true", children: [_jsx("label", { htmlFor: `${id}-_hp`, children: "Leave this field empty" }), _jsx("input", { id: `${id}-_hp`, type: "text", name: "_hp", tabIndex: -1, autoComplete: "off", defaultValue: "" })] }), _jsxs("div", { className: "sw-docs-feedback__buttons", children: [_jsx("button", { type: "submit", className: "sw-button sw-button--secondary", name: "helpful", value: "yes", children: yesLabel }), _jsx("button", { type: "submit", className: "sw-button sw-button--secondary", name: "helpful", value: "no", children: noLabel })] })] })] }), _jsx("script", { nonce: nonce, dangerouslySetInnerHTML: { __html: DOCS_FEEDBACK_SCRIPT } })] }) }));
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
export const docsFeedbackCss = `/* ---------- Docs feedback ---------- */
|
|
43
|
+
|
|
44
|
+
.sw-docs-feedback { padding: var(--sw-space-3) 0 var(--sw-space-4); }
|
|
45
|
+
.sw-docs-feedback__form { padding: var(--sw-space-3); border: 1px solid var(--sw-color-border); border-radius: var(--sw-radius, 8px); background: var(--sw-color-surface); }
|
|
46
|
+
.sw-docs-feedback__question { margin: 0 0 var(--sw-space-2); font-weight: 600; }
|
|
47
|
+
.sw-docs-feedback__comment { display: grid; gap: 0.35rem; margin-bottom: var(--sw-space-2); font-size: 0.9rem; color: var(--sw-color-muted); }
|
|
48
|
+
.sw-docs-feedback__comment textarea { width: 100%; padding: 0.55rem 0.7rem; font: inherit; color: var(--sw-color-text); background: var(--sw-color-bg); border: 1px solid var(--sw-color-border); border-radius: var(--sw-radius, 8px); resize: vertical; }
|
|
49
|
+
.sw-docs-feedback__comment textarea:focus-visible { outline: none; border-color: var(--sw-color-primary); box-shadow: var(--sw-focus-ring); }
|
|
50
|
+
.sw-docs-feedback__buttons { display: flex; gap: var(--sw-space-1); flex-wrap: wrap; }
|
|
51
|
+
.sw-docs-feedback__buttons button { font: inherit; cursor: pointer; }
|
|
52
|
+
.sw-docs-feedback__buttons button[disabled] { opacity: 0.6; cursor: progress; }
|
|
53
|
+
.sw-docs-feedback__status { margin: 0; font-weight: 500; }
|
|
54
|
+
.sw-docs-feedback__status[hidden], .sw-docs-feedback__body[hidden] { display: none; }
|
|
55
|
+
.sw-docs-feedback__placeholder { padding: var(--sw-space-2); border: 1px dashed var(--sw-color-border); border-radius: var(--sw-radius, 8px); color: var(--sw-color-muted); font-size: 0.9rem; text-align: center; }
|
|
56
|
+
`;
|
|
57
|
+
//# sourceMappingURL=docs-feedback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-feedback.js","sourceRoot":"","sources":["../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|
3
|
+
* Every example is rendered by the server renderer in the site's brand, so they double as a visual test of every block.
|
|
4
|
+
* Images point at the server's placeholder (`/_placeholder/<width>x<height>.svg`), which every instance serves.
|
|
5
|
+
* Slot props hold child blocks without ids; the renderer gives them ids.
|
|
6
|
+
*/
|
|
7
|
+
export interface BlockExample {
|
|
8
|
+
key: string;
|
|
9
|
+
label: string;
|
|
10
|
+
props: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export declare const blockExamples: Record<string, BlockExample[]>;
|
package/dist/examples.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const img = (w, h) => `/_placeholder/${w}x${h}.svg`;
|
|
2
|
+
const child = (type, props) => ({ type, props });
|
|
3
|
+
export const blockExamples = {
|
|
4
|
+
Hero: [
|
|
5
|
+
{ key: 'centered', label: 'Centered, two buttons', props: { eyebrow: 'Fall admissions', title: 'Find the program that fits your life', subtitle: 'Over 80 degrees and certificates, on campus and online, with advisors who know your name.', primaryLabel: 'Explore programs', primaryHref: '#', secondaryLabel: 'Visit campus', secondaryHref: '#', align: 'center', size: 'default' } },
|
|
6
|
+
{ key: 'image', label: 'Large, with a background image', props: { eyebrow: '', title: 'Clean water for every neighborhood', subtitle: 'Your gift funds repairs on the oldest mains first.', primaryLabel: 'Donate', primaryHref: '#', secondaryLabel: '', secondaryHref: '', backgroundImage: img(1600, 900), align: 'left', size: 'large' } },
|
|
7
|
+
{ key: 'minimal', label: 'Left aligned, one button', props: { eyebrow: '', title: 'Report a pothole', subtitle: 'Most reports are fixed within two working days.', primaryLabel: 'Start a report', primaryHref: '#', secondaryLabel: '', secondaryHref: '', align: 'left', size: 'default' } },
|
|
8
|
+
],
|
|
9
|
+
Heading: [
|
|
10
|
+
{ key: 'h2', label: 'Section heading (h2)', props: { text: 'What you will learn', level: 'h2', align: 'left' } },
|
|
11
|
+
{ key: 'h3-center', label: 'Centered h3', props: { text: 'Questions people ask', level: 'h3', align: 'center' } },
|
|
12
|
+
],
|
|
13
|
+
Text: [
|
|
14
|
+
{ key: 'body', label: 'Body copy with a list and a link', props: { content: '<p>Our advisors help you choose courses, plan your schedule and find funding. Book a time that suits you, online or in person.</p><ul><li>Course planning</li><li>Financial aid and scholarships</li><li>Transfer credit</li></ul><p>Read the <a href="#">advising guide</a> before your first meeting.</p>', format: 'html', size: 'normal', align: 'left' } },
|
|
15
|
+
{ key: 'lead', label: 'Lead paragraph', props: { content: '<p>Since 1902, the library has been free and open to everyone in the county.</p>', format: 'html', size: 'lead', align: 'left' } },
|
|
16
|
+
],
|
|
17
|
+
Image: [
|
|
18
|
+
{ key: 'caption', label: 'With a caption', props: { src: img(1200, 800), alt: 'Students talking on the lawn in front of the library', caption: 'The main quad in early autumn.', width: 'normal', rounded: true } },
|
|
19
|
+
{ key: 'wide', label: 'Wide, square corners', props: { src: img(1600, 600), alt: 'The river at dusk', caption: '', width: 'wide', rounded: false } },
|
|
20
|
+
],
|
|
21
|
+
Gallery: [
|
|
22
|
+
{
|
|
23
|
+
key: 'three',
|
|
24
|
+
label: 'Three columns, square',
|
|
25
|
+
props: { images: [1, 2, 3, 4, 5, 6].map((n) => ({ src: img(800, 800), alt: `Photo ${n} from the spring open house`, caption: n === 1 ? 'Welcome tent' : '' })), columns: 3, shape: 'square', lightbox: true },
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
Columns: [
|
|
29
|
+
{ key: 'image-text', label: 'Image and text, wide right', props: { ratio: 'wide-right', gap: 'normal', valign: 'center', columns: [{ content: [child('Image', { src: img(800, 600), alt: 'A volunteer planting a tree', caption: '', width: 'normal', rounded: true })] }, { content: [child('Heading', { text: 'Plant a tree this spring', level: 'h3', align: 'left' }), child('Text', { content: '<p>We provide the tree, the tools and a guide. You bring an afternoon.</p>', format: 'html', size: 'normal', align: 'left' }), child('Button', { label: 'Sign up', href: '#', align: 'left' })] }] } },
|
|
30
|
+
{ key: 'three', label: 'Three equal columns', props: { ratio: 'equal', gap: 'normal', valign: 'top', columns: ['Plan', 'Apply', 'Enroll'].map((t) => ({ content: [child('Heading', { text: t, level: 'h3', align: 'left' }), child('Text', { content: `<p>What happens when you ${t.toLowerCase()}, in two short sentences.</p>`, format: 'html', size: 'normal', align: 'left' })] })) } },
|
|
31
|
+
],
|
|
32
|
+
Section: [
|
|
33
|
+
{ key: 'surface', label: 'Surface band with heading, text and buttons', props: { background: 'surface', width: 'normal', content: [child('Heading', { text: 'Visit us', level: 'h2', align: 'left' }), child('Text', { content: '<p>Open Monday to Saturday, 9 to 6. Free parking behind the building.</p>', format: 'html', size: 'normal', align: 'left' }), child('Buttons', { align: 'left', buttons: [{ label: 'Get directions', href: '#', emphasis: 'primary', newTab: false }, { label: 'Opening hours', href: '#', emphasis: 'secondary', newTab: false }] })] } },
|
|
34
|
+
{ key: 'dark', label: 'Dark band, narrow and centered', props: { background: 'dark', width: 'narrow', content: [child('Heading', { text: 'Stay in the loop', level: 'h2', align: 'center' }), child('Text', { content: '<p>One email a month with news and events. No spam.</p>', format: 'html', size: 'normal', align: 'center' })] } },
|
|
35
|
+
],
|
|
36
|
+
CallToAction: [{ key: 'default', label: 'Default', props: { title: 'Ready to apply?', text: 'Applications for spring close on January 15. It takes about twenty minutes.', buttonLabel: 'Start your application', buttonHref: '#' } }],
|
|
37
|
+
Cards: [
|
|
38
|
+
{ key: 'three', label: 'Three cards with images and links', props: { columns: 3, titleLevel: 'h3', cards: [{ title: 'Undergraduate', text: 'Bachelor degrees in 40 subjects.', href: '#', imageUrl: img(800, 500) }, { title: 'Graduate', text: 'Masters and doctoral programs.', href: '#', imageUrl: img(800, 500) }, { title: 'Continuing education', text: 'Evening and online courses.', href: '#', imageUrl: img(800, 500) }] } },
|
|
39
|
+
{ key: 'text-only', label: 'Four text cards', props: { columns: 4, titleLevel: 'h3', cards: ['Pay a bill', 'Report an issue', 'Find a park', 'Apply for a permit'].map((t) => ({ title: t, text: 'One line about the service.', href: '#', imageUrl: '' })) } },
|
|
40
|
+
],
|
|
41
|
+
Faq: [
|
|
42
|
+
{ key: 'admissions', label: 'Admissions questions', props: { title: 'Frequently asked questions', openFirst: true, structuredData: true, items: [{ question: 'How do I apply?', answer: 'Start an application online. It takes about 20 minutes.' }, { question: 'When are the deadlines?', answer: 'March 1 for fall and October 1 for spring.' }, { question: 'Is there an application fee?', answer: 'No. Applying is free.' }] } },
|
|
43
|
+
],
|
|
44
|
+
Testimonials: [
|
|
45
|
+
{ key: 'three', label: 'Three quotes', props: { title: 'What students say', columns: 3, items: [{ quote: 'The team answered every question within a day.', name: 'Maya Chen', role: 'Class of 2025', imageUrl: img(96, 96) }, { quote: 'I found my program in one afternoon.', name: 'Luis Ortega', role: 'Transfer student', imageUrl: img(96, 96) }, { quote: 'Clear, friendly and fast.', name: 'Priya Nair', role: 'Parent', imageUrl: '' }] } },
|
|
46
|
+
{ key: 'one', label: 'One large quote', props: { title: '', columns: 1, items: [{ quote: 'We moved forty sites in a month and our editors never noticed.', name: 'Jordan Lee', role: 'Web director, Riverbend University', imageUrl: '' }] } },
|
|
47
|
+
],
|
|
48
|
+
Stats: [
|
|
49
|
+
{ key: 'three', label: 'Three figures, centered', props: { title: '', align: 'center', items: [{ value: '94%', label: 'of graduates employed within six months' }, { value: '40', label: 'undergraduate majors' }, { value: '14:1', label: 'student to faculty ratio' }] } },
|
|
50
|
+
],
|
|
51
|
+
LogoStrip: [
|
|
52
|
+
{ key: 'partners', label: 'Partners, gray until hovered', props: { title: 'Our partners', grayscale: true, logos: ['Northwind', 'Contoso', 'Fabrikam', 'Tailspin'].map((n) => ({ imageUrl: img(320, 96), name: n, href: '' })) } },
|
|
53
|
+
],
|
|
54
|
+
Lottie: [{ key: 'poster', label: 'An animation with its poster (pick a .json file to play it)', props: { src: '', poster: img(480, 480), alt: '', loop: true, size: 'm', caption: '' } }],
|
|
55
|
+
Model3D: [{ key: 'poster', label: 'A model with its poster (pick a .glb file to turn it)', props: { src: '', alt: 'A chair', poster: img(960, 540), autoRotate: true, ar: false, height: 'm', caption: 'Our best-selling chair' } }],
|
|
56
|
+
Scrollytelling: [
|
|
57
|
+
{ key: 'admissions', label: 'Three steps with images', props: { title: 'From application to first class', mediaSide: 'left', steps: [{ heading: 'Apply', text: 'Start an application online. It takes about 20 minutes.', imageUrl: img(1200, 900), alt: 'A student filling in the application on a laptop' }, { heading: 'Visit', text: 'Tour the campus and meet the people you would study with.', imageUrl: img(1200, 900), alt: 'A campus tour group on the main lawn' }, { heading: 'Enroll', text: 'Accept your offer and pick your first classes.', imageUrl: img(1200, 900), alt: 'New students at orientation' }] } },
|
|
58
|
+
],
|
|
59
|
+
Spacer: [{ key: 'm', label: 'Medium', props: { size: 'm' } }],
|
|
60
|
+
Divider: [{ key: 'normal', label: 'Full width', props: { width: 'normal' } }, { key: 'narrow', label: 'Narrow', props: { width: 'narrow' } }],
|
|
61
|
+
Search: [
|
|
62
|
+
{ key: 'normal', label: 'Inline', props: { label: 'Search this site', showLabel: false, placeholder: 'Search', buttonLabel: 'Search', size: 'normal', align: 'left' } },
|
|
63
|
+
{ key: 'large', label: 'Large and centered, with a label', props: { label: 'How can we help?', showLabel: true, placeholder: 'Try “parking permit”', buttonLabel: 'Search', size: 'large', align: 'center' } },
|
|
64
|
+
],
|
|
65
|
+
Ask: [
|
|
66
|
+
{ key: 'help', label: 'With suggested questions', props: { heading: 'Have a question?', label: 'Ask a question', placeholder: 'For example: when is the application deadline?', buttonLabel: 'Ask', align: 'left', questions: [{ question: 'When is the application deadline?' }, { question: 'How much is tuition?' }, { question: 'Where do I park on campus?' }] } },
|
|
67
|
+
{ key: 'center', label: 'Centered, no suggestions', props: { heading: 'How can we help?', label: 'Ask a question', placeholder: 'Ask anything about the program', buttonLabel: 'Ask', align: 'center', questions: [] } },
|
|
68
|
+
],
|
|
69
|
+
Menu: [
|
|
70
|
+
{ key: 'sidebar', label: 'A section menu in a sidebar, the current page marked', props: { source: 'menu', menuKey: 'main', show: 'branch', depth: 2, heading: '', layout: 'vertical', menuLabel: 'Main navigation', branch: { label: 'Admissions', href: '#' }, items: [{ label: 'Apply', href: '#', current: true, trail: true }, { label: 'Visit campus', href: '#', children: [{ label: 'Tours', href: '#' }, { label: 'Open days', href: '#' }] }, { label: 'Tuition and aid', href: '#' }] } },
|
|
71
|
+
{ key: 'row', label: 'Links in a row', props: { source: 'menu', menuKey: 'footer', show: 'all', depth: 1, heading: 'Quick links', layout: 'horizontal', menuLabel: 'Footer', items: [{ label: 'Pay a bill', href: '#' }, { label: 'Report an issue', href: '#' }, { label: 'Contact us', href: '#' }] } },
|
|
72
|
+
],
|
|
73
|
+
Embed: [{ key: 'map', label: 'An embedded frame with a caption', props: { html: '<iframe src="https://www.openstreetmap.org/export/embed.html?bbox=-0.1,51.5,-0.08,51.51" title="Map of the area" width="600" height="300"></iframe>', caption: 'Map data © OpenStreetMap contributors.' } }],
|
|
74
|
+
Button: [{ key: 'default', label: 'One button', props: { label: 'Download the brochure', href: '#', align: 'left' } }],
|
|
75
|
+
Buttons: [
|
|
76
|
+
{ key: 'pair', label: 'Primary and secondary', props: { align: 'left', buttons: [{ label: 'Book a tour', href: '#', emphasis: 'primary', newTab: false }, { label: 'Ask a question', href: '#', emphasis: 'secondary', newTab: false }] } },
|
|
77
|
+
{ key: 'center', label: 'Three, centered', props: { align: 'center', buttons: [{ label: 'Donate', href: '#', emphasis: 'primary', newTab: false }, { label: 'Volunteer', href: '#', emphasis: 'secondary', newTab: false }, { label: 'Partner with us', href: '#', emphasis: 'secondary', newTab: false }] } },
|
|
78
|
+
],
|
|
79
|
+
Form: [{ key: 'default', label: 'A form by its key', props: { formKey: 'contact', title: 'Contact us', intro: 'We answer within one working day.', submitLabel: 'Send' } }],
|
|
80
|
+
Collection: [{ key: 'cards', label: 'Cards (pick a collection)', props: { collectionId: '', display: 'cards', columns: 3, emptyText: 'Choose a collection to list its items here.' } }],
|
|
81
|
+
Calendar: [{ key: 'month', label: 'Month view (pick a collection)', props: { collectionId: '', view: 'month', monthsAhead: 1 } }],
|
|
82
|
+
DocsFeedback: [{ key: 'default', label: 'Default', props: {} }],
|
|
83
|
+
StatusBoard: [{ key: 'default', label: 'Default', props: { title: 'Status', instances: [], showUptime: true } }],
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=examples.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"examples.js","sourceRoot":"","sources":["../src/examples.ts"],"names":[],"mappings":"AAYA,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC;AACpE,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,KAA8B,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAElF,MAAM,CAAC,MAAM,aAAa,GAAmC;IAC3D,IAAI,EAAE;QACJ,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,uBAAuB,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,sCAAsC,EAAE,QAAQ,EAAE,2FAA2F,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,GAAG,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;QAC1X,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,gCAAgC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,oCAAoC,EAAE,QAAQ,EAAE,oDAAoD,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,eAAe,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;QAC9U,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAA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AE,KAAK,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC;IACjI,YAAY,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAC/D,WAAW,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC;CACjH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Experiment block: slots `a` (control), `b` and the optional `c`. Visitors of a running experiment
|
|
3
|
+
* are assigned a variant by weight (sticky in the `sw_x` cookie); every other status shows `a`.
|
|
4
|
+
* Cached pages render `a` inside `<div data-sw-island="…">`; the island endpoint renders the block
|
|
5
|
+
* with `show` set to the visitor's variant. Server-safe.
|
|
6
|
+
*/
|
|
7
|
+
import type { ComponentConfig, Slot } from '@puckeditor/core';
|
|
8
|
+
export interface ExperimentProps {
|
|
9
|
+
experimentKey: string;
|
|
10
|
+
a: Slot;
|
|
11
|
+
b: Slot;
|
|
12
|
+
c: Slot;
|
|
13
|
+
/** Set by the server on cached pages: `<entityId>/<blockId>`; null renders the content inline. Never stored. */
|
|
14
|
+
island?: string | null;
|
|
15
|
+
/** Set by the island endpoint: the variant this visitor sees (a, b or c). Never stored. */
|
|
16
|
+
show?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const experimentComponent: ComponentConfig<ExperimentProps>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export const experimentComponent = {
|
|
3
|
+
label: 'Experiment',
|
|
4
|
+
fields: {
|
|
5
|
+
experimentKey: { type: 'text', label: 'Experiment key', placeholder: 'from Experiments in the admin' },
|
|
6
|
+
a: { type: 'slot', label: 'Variant A (control)' },
|
|
7
|
+
b: { type: 'slot', label: 'Variant B' },
|
|
8
|
+
c: { type: 'slot', label: 'Variant C (optional)' },
|
|
9
|
+
},
|
|
10
|
+
defaultProps: { experimentKey: '', a: [], b: [], c: [] },
|
|
11
|
+
render: ({ experimentKey, a: A, b: B, c: C, island, show, puck }) => {
|
|
12
|
+
if (puck?.isEditing) {
|
|
13
|
+
return (_jsxs("div", { className: "sw-island sw-island--editing", "data-sw-experiment": experimentKey || undefined, children: [_jsxs("div", { className: "sw-island__label", children: ["Experiment: ", experimentKey || 'none selected', " \u00B7 Variant A (control)"] }), _jsx(A, { className: "sw-island__slot" }), _jsx("div", { className: "sw-island__label", children: "Variant B" }), _jsx(B, { className: "sw-island__slot" }), _jsx("div", { className: "sw-island__label", children: "Variant C (optional)" }), _jsx(C, { className: "sw-island__slot" })] }));
|
|
14
|
+
}
|
|
15
|
+
const variant = show === 'b' ? 'b' : show === 'c' ? 'c' : 'a';
|
|
16
|
+
const Content = variant === 'b' ? B : variant === 'c' ? C : A;
|
|
17
|
+
return (_jsx("div", { className: "sw-island sw-experiment", "data-sw-island": island || undefined, "data-sw-experiment": experimentKey || undefined, "data-sw-variant": variant, children: _jsx(Content, { className: "sw-island__slot" }) }));
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=experiment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"experiment.js","sourceRoot":"","sources":["../src/experiment.tsx"],"names":[],"mappings":";AAmBA,MAAM,CAAC,MAAM,mBAAmB,GAAqC;IACnE,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE;QACN,aAAa,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,+BAA+B,EAAE;QACtG,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,E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AK,SAAS,EAAC,yBAAyB,oBAAiB,MAAM,IAAI,SAAS,wBAAsB,aAAa,IAAI,SAAS,qBAAmB,OAAO,YACpJ,KAAC,OAAO,IAAC,SAAS,EAAC,iBAAiB,GAAG,GACnC,CACP,CAAC;IACJ,CAAC;CACF,CAAC"}
|
package/dist/form.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Form block. Stored props are `formKey`, `title`, `intro` and `submitLabel`; the server
|
|
3
|
+
* resolves `form: FormDefinition` (plus `nonce` and, when the site has one, `captcha`) into the
|
|
4
|
+
* props before render (core registers a resolver for block type "Form"). Without a resolved form,
|
|
5
|
+
* the block renders a placeholder so the editor and an unpublished form still show something sensible.
|
|
6
|
+
*
|
|
7
|
+
* Server-safe: no hooks, no DOM access. Progressive enhancement comes from a tiny inline script
|
|
8
|
+
* (carrying the page's CSP nonce) that evaluates `visibleWhen` rules, drives the stepper (one step
|
|
9
|
+
* at a time, each validated on the server before moving on), intercepts submit (JSON, or multipart
|
|
10
|
+
* when the form takes files) and shows the outcome in place; when fetch fails it lets the browser
|
|
11
|
+
* submit the form normally (303 back to the page). Without JavaScript every step is visible, the
|
|
12
|
+
* server evaluates the same rules and the form works through that redirect.
|
|
13
|
+
*/
|
|
14
|
+
import { type FormCaptchaProvider, type FormDefinition, type FormField } from '@spillway-cms/shared';
|
|
15
|
+
export interface FormProps {
|
|
16
|
+
formKey: string;
|
|
17
|
+
title: string;
|
|
18
|
+
intro: string;
|
|
19
|
+
submitLabel: string;
|
|
20
|
+
}
|
|
21
|
+
/** The CAPTCHA the server resolves for the block: provider, public site key and the widget script. Never the secret. */
|
|
22
|
+
export interface FormCaptchaProps {
|
|
23
|
+
provider: Exclude<FormCaptchaProvider, 'none'>;
|
|
24
|
+
siteKey: string;
|
|
25
|
+
script: string;
|
|
26
|
+
}
|
|
27
|
+
/** The props the server hands to `render`: the stored props plus the resolved definition, the CSP nonce and the CAPTCHA. */
|
|
28
|
+
export type FormRenderProps = FormProps & {
|
|
29
|
+
form?: FormDefinition;
|
|
30
|
+
nonce?: string;
|
|
31
|
+
captcha?: FormCaptchaProps;
|
|
32
|
+
};
|
|
33
|
+
/** The `accept` attribute of a file input from the field's list (extensions get their dot, MIME types pass through). */
|
|
34
|
+
export declare function acceptAttr(field: FormField): string | undefined;
|
|
35
|
+
/** An amount for people: "$25", "€10.50", "¥3,000" (Intl, falling back to "25.00 USD"). */
|
|
36
|
+
export declare function moneyLabel(amount: number, currency: string): string;
|
|
37
|
+
/** The fields of one step: those it lists, in field order; the last step also takes every field no step names. */
|
|
38
|
+
export declare function fieldsOfStep(form: Pick<FormDefinition, 'fields' | 'steps'>, index: number): FormField[];
|
|
39
|
+
export declare function renderForm(props: FormRenderProps): import("react").JSX.Element;
|
|
40
|
+
export declare const FORM_CSS = "\n/* ---------- Form ---------- */\n\n.sw-form-block { padding: var(--sw-space-4) 0; }\n/* Lined up with the headings and text around it; the column is capped so fields stay a readable width. */\n.sw-form-block .sw-container > * { max-width: 45rem; }\n.sw-form__title { margin: 0 0 var(--sw-space-1); font-family: var(--sw-font-heading); font-size: 1.75rem; line-height: 1.2; }\n.sw-form__intro { margin: 0 0 var(--sw-space-3); color: var(--sw-color-muted); }\n.sw-form { display: block; }\n.sw-form--placeholder {\n padding: var(--sw-space-3);\n border: 1px dashed var(--sw-color-border);\n border-radius: var(--sw-radius);\n color: var(--sw-color-muted);\n text-align: center;\n}\n.sw-form__body { display: grid; gap: var(--sw-space-2); }\n.sw-form__field { display: grid; gap: 0.35rem; }\n.sw-form__field[hidden] { display: none; }\n.sw-form__label { font-weight: 600; font-size: 0.95rem; }\n.sw-form__required { color: var(--sw-color-primary); }\n.sw-form input[type=\"text\"],\n.sw-form input[type=\"email\"],\n.sw-form input[type=\"url\"],\n.sw-form input[type=\"search\"],\n.sw-form input[type=\"date\"],\n.sw-form input[type=\"password\"],\n.sw-form input[type=\"tel\"],\n.sw-form input[type=\"number\"],\n.sw-form input[type=\"file\"],\n.sw-form textarea,\n.sw-form select {\n width: 100%;\n padding: 0.65rem 0.8rem;\n font: inherit;\n color: var(--sw-color-text);\n background: var(--sw-color-bg);\n border: 1px solid var(--sw-color-border);\n border-radius: var(--sw-radius);\n transition: border-color 120ms ease, box-shadow 120ms ease;\n}\n.sw-form textarea { resize: vertical; min-height: 7rem; }\n.sw-form input:focus-visible,\n.sw-form textarea:focus-visible,\n.sw-form select:focus-visible,\n.sw-form button:focus-visible { outline: none; border-color: var(--sw-color-primary); box-shadow: var(--sw-focus-ring); }\n.sw-form input:user-invalid,\n.sw-form textarea:user-invalid,\n.sw-form select:user-invalid,\n.sw-form [aria-invalid=\"true\"] { border-color: #b91c1c; }\n.sw-form__check { display: flex; gap: 0.6rem; align-items: flex-start; cursor: pointer; }\n.sw-form__check input { margin-top: 0.3rem; width: 1.1rem; height: 1.1rem; accent-color: var(--sw-color-primary); }\n.sw-form__help { margin: 0; font-size: 0.875rem; color: var(--sw-color-muted); }\n.sw-form__error { margin: 0; font-size: 0.875rem; color: #b91c1c; }\n.sw-form__error[hidden] { display: none; }\n.sw-form__status:empty { padding: 0; margin: 0; border: 0; }\n.sw-form__hp { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; opacity: 0; }\n.sw-form__actions { margin-top: var(--sw-space-1); display: flex; gap: var(--sw-space-1); flex-wrap: wrap; }\n.sw-form__actions [hidden] { display: none; }\n.sw-form button[type=\"submit\"], .sw-form button[type=\"button\"] { font: inherit; cursor: pointer; border: 0; }\n.sw-form button[disabled] { opacity: 0.6; cursor: progress; }\n.sw-form__status { margin: 0 0 var(--sw-space-2); padding: 0.8rem 1rem; border-radius: var(--sw-radius); font-weight: 500; }\n.sw-form__status--success { background: color-mix(in srgb, #16a34a 12%, var(--sw-color-bg)); color: #14532d; border: 1px solid color-mix(in srgb, #16a34a 40%, var(--sw-color-bg)); }\n.sw-form__status--error { background: color-mix(in srgb, #dc2626 10%, var(--sw-color-bg)); color: #7f1d1d; border: 1px solid color-mix(in srgb, #dc2626 40%, var(--sw-color-bg)); }\n.sw-form__captcha { grid-column: 1 / -1; min-height: 65px; }\n.sw-form__payment { grid-column: 1 / -1; margin: 0; padding: 0; border: 0; min-width: 0; }\n.sw-form__payment legend { padding: 0; margin-bottom: 0.35rem; }\n.sw-form__amounts { display: flex; flex-wrap: wrap; gap: 0.5rem; }\n.sw-form__amount { position: relative; display: inline-flex; }\n.sw-form__amount input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }\n.sw-form__amount span { display: inline-block; min-width: 4.5rem; padding: 0.6rem 1rem; text-align: center; font-weight: 600; border: 1px solid var(--sw-color-border); border-radius: var(--sw-radius); background: var(--sw-color-bg); transition: border-color 120ms ease, background-color 120ms ease; }\n.sw-form__amount input:checked + span { border-color: var(--sw-color-primary); background: color-mix(in srgb, var(--sw-color-primary) 12%, var(--sw-color-bg)); color: var(--sw-color-text); box-shadow: inset 0 0 0 1px var(--sw-color-primary); }\n.sw-form__amount input:focus-visible + span { box-shadow: var(--sw-focus-ring); border-color: var(--sw-color-primary); }\n.sw-form__other { display: grid; gap: 0.35rem; margin-top: 0.75rem; max-width: 16rem; }\n.sw-form__other[hidden] { display: none; }\n.sw-form__payment-note { grid-column: 1 / -1; }\n.sw-form__status--info { background: color-mix(in srgb, var(--sw-color-primary) 8%, var(--sw-color-bg)); border: 1px solid var(--sw-color-border); }\n.sw-form__progress { display: flex; flex-wrap: wrap; gap: var(--sw-space-1) var(--sw-space-2); margin: 0 0 var(--sw-space-1); padding: 0; list-style: none; font-size: 0.9rem; color: var(--sw-color-muted); grid-column: 1 / -1; }\n.sw-form__progress li { display: flex; align-items: center; gap: 0.4rem; }\n.sw-form__progress-num { display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem; border-radius: 999px; border: 1px solid var(--sw-color-border); font-size: 0.8rem; font-weight: 600; }\n.sw-form__progress li.is-current { color: var(--sw-color-text); font-weight: 600; }\n.sw-form__progress li.is-current .sw-form__progress-num { background: var(--sw-color-primary); border-color: var(--sw-color-primary); color: #fff; }\n.sw-form__progress li.is-done .sw-form__progress-num { background: color-mix(in srgb, var(--sw-color-primary) 15%, var(--sw-color-bg)); border-color: var(--sw-color-primary); color: var(--sw-color-primary); }\n.sw-form__step { grid-column: 1 / -1; margin: 0; padding: 0; border: 0; min-width: 0; }\n.sw-form__step[hidden] { display: none; }\n.sw-form__step-title { padding: 0; margin: 0 0 var(--sw-space-2); font-family: var(--sw-font-heading); font-size: 1.15rem; font-weight: 600; }\n.sw-form__step-count { color: var(--sw-color-muted); font-weight: 500; }\n.sw-form--js .sw-form__step-count { display: none; }\n.sw-form__step-fields { display: grid; gap: var(--sw-space-2); }\n@media (min-width: 640px) {\n .sw-form__body, .sw-form__step-fields { grid-template-columns: 1fr 1fr; }\n .sw-form__field--textarea, .sw-form__field--checkbox, .sw-form__field--file, .sw-form__actions, .sw-form__hp { grid-column: 1 / -1; }\n}\n";
|