@somewhere-cloud/cli 0.38.95 → 0.38.96
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/CHANGELOG.md +11 -0
- package/dist/commands/deploy.js +2 -2
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/test.js +22 -1
- package/dist/commands/test.js.map +1 -1
- package/dist/lib/declared-data.js +5 -2
- package/dist/lib/declared-data.js.map +1 -1
- package/dist/lib/init-agent-guide.d.ts +2 -2
- package/dist/lib/init-agent-guide.js +11 -5
- package/dist/lib/init-agent-guide.js.map +1 -1
- package/dist/lib/init-feature-template.js +28 -41
- package/dist/lib/init-feature-template.js.map +1 -1
- package/dist/lib/init-green-template.js +2 -1
- package/dist/lib/init-green-template.js.map +1 -1
- package/dist/lib/init-template.js +2 -1
- package/dist/lib/init-template.js.map +1 -1
- package/dist/lib/init-test-template.js +9 -5
- package/dist/lib/init-test-template.js.map +1 -1
- package/dist/lib/init-ui-kit.d.ts +3 -3
- package/dist/lib/init-ui-kit.js +50 -48
- package/dist/lib/init-ui-kit.js.map +1 -1
- package/dist/lib/scaffold.d.ts +2 -2
- package/dist/lib/scaffold.js +5 -3
- package/dist/lib/scaffold.js.map +1 -1
- package/dist/lib/test-scripts.d.ts +21 -0
- package/dist/lib/test-scripts.js +118 -0
- package/dist/lib/test-scripts.js.map +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/runtime/DECLARED-DATA-VENDOR.json +3 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { InitScaffoldFile } from './init-scaffold.js';
|
|
2
2
|
export declare const TOKENS_CSS = "/* Design tokens: the only place colours, type and spacing are defined.\n app.css and src/ui read these; pages never write a raw hex or px value.\n To restyle the whole app, change the values here.\n\n Fonts are local stacks only (no network fonts), chosen so every platform\n falls back to a good face, not to Arial/Times. Prefer one family: set\n --font-display to a serif stack only if the app wants that personality. */\n:root {\n color-scheme: light;\n\n --font-body: system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif;\n --font-display: var(--font-body);\n /* Serif alternative: \"Iowan Old Style\", \"Palatino Linotype\", Palatino, Georgia, serif; */\n --font-mono: ui-monospace, \"SF Mono\", Menlo, Consolas, \"Liberation Mono\", monospace;\n\n --text-xs: 0.75rem;\n --text-sm: 0.875rem;\n --text-base: 1rem;\n --text-lg: 1.125rem;\n --text-xl: 1.375rem;\n --text-2xl: 1.75rem;\n --text-display: clamp(2rem, 4.4vw, 2.75rem);\n --tracking-display: -0.02em;\n --tracking-label: 0.06em;\n\n --space-1: 4px;\n --space-2: 8px;\n --space-3: 12px;\n --space-4: 16px;\n --space-5: 20px;\n --space-6: 24px;\n --space-8: 32px;\n --space-10: 40px;\n --space-12: 48px;\n --space-16: 64px;\n\n --radius-control: 8px;\n --radius-panel: 14px;\n --radius-pill: 999px;\n\n --control-height: 44px;\n --content-width: 1040px;\n\n --shadow-sm: 0 1px 2px rgba(28, 27, 24, 0.05);\n --shadow-md: 0 1px 2px rgba(28, 27, 24, 0.05), 0 16px 40px -28px rgba(28, 27, 24, 0.35);\n --shadow-lg: 0 24px 64px -24px rgba(28, 27, 24, 0.45);\n\n /* Surfaces and text */\n --color-bg: #f5f3ee;\n --color-surface: #ffffff;\n --color-surface-2: #faf8f4;\n --color-text: #1c1b18;\n --color-muted: #66615a;\n --color-border: #e0dbd1;\n --color-border-strong: #c9c2b5;\n\n /* One accent. Everything interactive uses it. */\n --color-accent: #1d6b52;\n --color-accent-hover: #185b46;\n --color-accent-soft: #e3efe9;\n --color-on-accent: #ffffff;\n --color-focus: #1d6b52;\n\n /* Semantic tones for badges, notices and stats: not for buttons. */\n --color-success: #1d6b52;\n --color-success-soft: #e3efe9;\n --color-warning: #8a5a00;\n --color-warning-soft: #f7ebd2;\n --color-danger: #b42318;\n --color-danger-soft: #fbe4e1;\n --color-info: #2a5d9f;\n --color-info-soft: #e1eaf7;\n}\n\n@media (prefers-color-scheme: dark) {\n :root {\n color-scheme: dark;\n\n --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);\n --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -28px rgba(0, 0, 0, 0.7);\n --shadow-lg: 0 24px 64px -24px rgba(0, 0, 0, 0.8);\n\n --color-bg: #15161a;\n --color-surface: #1e2025;\n --color-surface-2: #24272d;\n --color-text: #ecebe6;\n --color-muted: #a19d95;\n --color-border: #31343b;\n --color-border-strong: #454953;\n\n --color-accent: #5fbf9a;\n --color-accent-hover: #74cba9;\n --color-accent-soft: #1f3a31;\n --color-on-accent: #0f1f19;\n --color-focus: #5fbf9a;\n\n --color-success: #5fbf9a;\n --color-success-soft: #1f3a31;\n --color-warning: #e2b25a;\n --color-warning-soft: #3a2f16;\n --color-danger: #f0867c;\n --color-danger-soft: #42221f;\n --color-info: #7fa9e6;\n --color-info-soft: #1f2d42;\n }\n}\n";
|
|
3
|
-
export declare const APP_CSS = "/* Base styles and the classes src/ui components render. Values come from\n tokens.css. Add app-specific styles at the end of this file, or in a new\n file imported from src/main.tsx; do not restyle native elements globally. */\n\n/* ---------- Base ---------- */\n*, *::before, *::after { box-sizing: border-box; }\nhtml { -webkit-text-size-adjust: 100%; }\nbody {\n margin: 0;\n min-width: 320px;\n background: var(--color-bg);\n color: var(--color-text);\n font: 400 var(--text-base)/1.55 var(--font-body);\n -webkit-font-smoothing: antialiased;\n}\nbutton, input, select, textarea { font: inherit; color: inherit; }\nh1, h2, h3, p { margin: 0; }\nh1, h2, h3 { font-family: var(--font-display); line-height: 1.2; letter-spacing: var(--tracking-display); font-weight: 600; }\nh1 { font-size: var(--text-2xl); }\nh2 { font-size: var(--text-xl); }\nh3 { font-size: var(--text-lg); }\na { color: var(--color-accent); text-underline-offset: 3px; }\ncode, kbd { font-family: var(--font-mono); font-size: 0.9em; }\n:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; }\n::placeholder { color: var(--color-muted); opacity: 0.8; }\n\n.muted { color: var(--color-muted); }\n.hint { margin: 0; color: var(--color-muted); font-size: var(--text-sm); font-weight: 400; }\n.error { margin: 0; color: var(--color-danger); font-size: var(--text-sm); }\n.skip-link { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; position: absolute; left: var(--space-3); top: -60px; padding: var(--space-2) var(--space-3); background: var(--color-text); color: var(--color-bg); z-index: 10; }\n.skip-link:focus { top: var(--space-3); }\n.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n\n/* ---------- Layout primitives (src/ui/layout.tsx) ---------- */\n.stack { display: grid; gap: var(--stack-gap, var(--space-4)); align-content: start; }\n.stack > *, .grid > *, .card > *, .content > * { min-width: 0; }\n.inline { display: flex; flex-wrap: wrap; gap: var(--inline-gap, var(--space-2)); align-items: var(--inline-align, center); justify-content: var(--inline-justify, flex-start); }\n.grid { display: grid; gap: var(--grid-gap, var(--space-4)); grid-template-columns: repeat(auto-fit, minmax(min(var(--grid-min, 220px), 100%), 1fr)); }\n.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }\n\n.page-header { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: flex-end; justify-content: space-between; margin-bottom: var(--space-8); }\n.page-header__text { display: grid; gap: var(--space-1); min-width: 0; }\n.page-header__title { font-size: var(--text-display); line-height: 1.1; }\n.page-header__description { color: var(--color-muted); max-width: 60ch; }\n\n.eyebrow { margin: 0; color: var(--color-muted); font-size: var(--text-xs); font-weight: 600; letter-spacing: var(--tracking-label); text-transform: uppercase; }\n.section-title { margin: 0 0 var(--space-3); font-size: var(--text-sm); font-weight: 600; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--color-muted); }\n\n/* ---------- Panel and Card ---------- */\n.panel {\n display: grid;\n gap: var(--space-4);\n padding: var(--space-6);\n border: 1px solid var(--color-border);\n border-radius: var(--radius-panel);\n background: var(--color-surface);\n box-shadow: var(--shadow-md);\n}\n.panel__title { margin: 0; font: 600 var(--text-lg)/1.2 var(--font-display); }\n\n.card { display: grid; gap: 0; padding: 0; border: 1px solid var(--color-border); border-radius: var(--radius-panel); background: var(--color-surface); box-shadow: var(--shadow-sm); overflow: hidden; }\n.card__header { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border); }\n.card__heading { display: grid; gap: 2px; min-width: 0; }\n.card__title { font-size: var(--text-base); font-weight: 600; letter-spacing: 0; }\n.card__description { color: var(--color-muted); font-size: var(--text-sm); }\n.card__body { padding: var(--space-5); }\n.card__body--flush { padding: 0; }\n.card__footer { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; padding: var(--space-3) var(--space-5); border-top: 1px solid var(--color-border); background: var(--color-surface-2); }\n\n/* ---------- Buttons (src/ui/Button.tsx) ---------- */\n.button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--space-2);\n min-height: var(--control-height);\n padding: 0 var(--space-4);\n border: 1px solid var(--color-accent);\n border-radius: var(--radius-control);\n background: var(--color-accent);\n color: var(--color-on-accent);\n font-weight: 600;\n line-height: 1.2;\n white-space: nowrap;\n text-decoration: none;\n cursor: pointer;\n transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;\n}\n.button:hover:not(:disabled) { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }\n.button:disabled { opacity: 0.5; cursor: not-allowed; }\n.button--secondary { background: var(--color-surface); border-color: var(--color-border-strong); color: var(--color-text); }\n.button--secondary:hover:not(:disabled) { background: var(--color-surface-2); border-color: var(--color-border-strong); }\n.button--quiet { background: transparent; border-color: transparent; color: var(--color-text); }\n.button--quiet:hover:not(:disabled) { background: var(--color-accent-soft); border-color: transparent; }\n.button--danger { background: var(--color-danger); border-color: var(--color-danger); color: #fff; }\n.button--danger:hover:not(:disabled) { background: var(--color-danger); border-color: var(--color-danger); filter: brightness(0.92); }\n.button--sm { padding: 0 var(--space-3); font-size: var(--text-sm); }\n.button--block { width: 100%; }\n.button__spinner { width: 1em; height: 1em; border-width: 2px; }\n\n.link-button {\n display: inline-flex; align-items: center; min-height: var(--control-height);\n padding: 0 var(--space-2); border: 0; background: none;\n color: var(--color-accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;\n}\n.link-button:disabled { opacity: 0.5; cursor: not-allowed; }\n.link-button--danger { color: var(--color-danger); }\n\n/* ---------- Fields (src/ui/Field.tsx) ---------- */\n.field { display: grid; gap: 6px; min-width: 0; }\n.field__label { display: flex; justify-content: space-between; gap: var(--space-2); font-size: var(--text-sm); font-weight: 600; }\n.field__optional { color: var(--color-muted); font-weight: 400; }\n.field .control {\n width: 100%;\n min-height: var(--control-height);\n padding: 10px 12px;\n border: 1px solid var(--color-border-strong);\n border-radius: var(--radius-control);\n background: var(--color-surface);\n color: var(--color-text);\n}\n.field .control:hover { border-color: var(--color-muted); }\n.field .control[aria-invalid=\"true\"] { border-color: var(--color-danger); }\n.field .control:disabled { background: var(--color-surface-2); color: var(--color-muted); cursor: not-allowed; }\n.field textarea.control { min-height: calc(var(--control-height) * 2.2); resize: vertical; line-height: 1.5; }\n.field select.control {\n appearance: none;\n padding-right: 40px;\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%2366615a' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E\");\n background-repeat: no-repeat;\n background-position: right 12px center;\n}\n.field input[type=\"date\"].control, .field input[type=\"time\"].control { min-width: 10ch; }\n.field--inline { grid-template-columns: auto 1fr; align-items: center; }\n.field--inline .field__label { font-weight: 400; }\n.field input[type=\"checkbox\"], .field input[type=\"radio\"] { width: 20px; height: 20px; margin: 0; accent-color: var(--color-accent); }\n.field__hint { color: var(--color-muted); font-size: var(--text-sm); }\n.field__error { color: var(--color-danger); font-size: var(--text-sm); }\n.form-row { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(var(--form-row-min, 160px), 100%), 1fr)); align-items: start; }\n\n/* ---------- Tabs (src/ui/Tabs.tsx) ---------- */\n.tabs { display: flex; gap: var(--space-1); padding: var(--space-1); min-height: var(--control-height); border: 1px solid var(--color-border); border-radius: var(--radius-control); background: var(--color-surface-2); overflow-x: auto; scrollbar-width: none; max-width: 100%; }\n.tabs::-webkit-scrollbar { display: none; }\n.tab { flex: 0 0 auto; min-height: calc(var(--control-height) - 8px); padding: 0 var(--space-4); border: 0; border-radius: calc(var(--radius-control) - 2px); background: transparent; color: var(--color-muted); font-weight: 600; font-size: var(--text-sm); white-space: nowrap; cursor: pointer; }\n.tab:hover { color: var(--color-text); }\n.tab[aria-selected=\"true\"] { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-sm); }\n\n/* ---------- Badge (src/ui/Badge.tsx) ---------- */\n.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 10px; border-radius: var(--radius-pill); background: var(--color-surface-2); border: 1px solid var(--color-border); color: var(--color-text); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }\n.badge--accent { background: var(--color-accent-soft); border-color: transparent; color: var(--color-accent); }\n.badge--success { background: var(--color-success-soft); border-color: transparent; color: var(--color-success); }\n.badge--warning { background: var(--color-warning-soft); border-color: transparent; color: var(--color-warning); }\n.badge--danger { background: var(--color-danger-soft); border-color: transparent; color: var(--color-danger); }\n.badge--info { background: var(--color-info-soft); border-color: transparent; color: var(--color-info); }\n.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }\n\n/* ---------- Stat (src/ui/Stat.tsx) ---------- */\n.stat { display: grid; gap: var(--space-2); padding: var(--space-5); border: 1px solid var(--color-border); border-radius: var(--radius-panel); background: var(--color-surface); box-shadow: var(--shadow-sm); }\n.stat__value { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 600; letter-spacing: var(--tracking-display); line-height: 1.1; font-variant-numeric: tabular-nums; }\n.stat__value small { color: var(--color-muted); font-size: 0.55em; font-weight: 500; letter-spacing: 0; margin-left: 0.3em; }\n.stat__detail { color: var(--color-muted); font-size: var(--text-sm); }\n.stat__detail--success { color: var(--color-success); }\n.stat__detail--danger { color: var(--color-danger); }\n.meter { height: 6px; border-radius: var(--radius-pill); background: var(--color-border); overflow: hidden; }\n.meter__fill { height: 100%; border-radius: inherit; background: var(--color-accent); transition: width 240ms ease; }\n\n/* ---------- Table (src/ui/Table.tsx) ---------- */\n.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; container-type: inline-size; }\n.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }\n.table th, .table td { padding: var(--space-3) var(--space-5); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--color-border); }\n.table th { color: var(--color-muted); font-size: var(--text-xs); font-weight: 600; letter-spacing: var(--tracking-label); text-transform: uppercase; white-space: nowrap; background: var(--color-surface-2); }\n.table tbody tr:last-child td { border-bottom: 0; }\n.table tbody tr:hover td { background: var(--color-surface-2); }\n.table .is-numeric { text-align: right; }\n.table__empty { padding: var(--space-8) var(--space-5); text-align: center; color: var(--color-muted); }\n/* A narrow card (a phone): each row becomes a block of label and value lines, so nothing scrolls sideways. */\n@container (max-width: 560px) {\n .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n .table, .table tbody, .table tr { display: block; width: 100%; }\n .table tr { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); }\n .table tbody tr:last-child { border-bottom: 0; }\n .table td { display: flex; gap: var(--space-3); align-items: baseline; padding: var(--space-1) 0; border-bottom: 0; text-align: left; overflow-wrap: anywhere; }\n .table td::before { content: attr(data-label); flex: 0 0 38%; color: var(--color-muted); font-size: var(--text-xs); font-weight: 600; letter-spacing: var(--tracking-label); text-transform: uppercase; }\n .table td.is-numeric { text-align: left; }\n .table tbody tr:hover td { background: transparent; }\n .table .table__empty { display: block; padding: var(--space-6) 0; text-align: center; }\n .table .table__empty::before { content: none; }\n}\n\n/* ---------- Notice (src/ui/Notice.tsx) ---------- */\n.notice { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; padding: var(--space-3) var(--space-4); border: 1px solid var(--color-border); border-left-width: 4px; border-radius: var(--radius-control); background: var(--color-surface); font-size: var(--text-sm); }\n.notice__body { flex: 1 1 240px; display: grid; gap: 2px; min-width: 0; }\n.notice__title { font-weight: 600; }\n.notice--info { border-left-color: var(--color-info); }\n.notice--success { border-left-color: var(--color-success); }\n.notice--warning { border-left-color: var(--color-warning); }\n.notice--danger { border-left-color: var(--color-danger); }\n.notice__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }\n\n/* Alert from feedback.tsx; Notice is preferred for new code. */\n.alert { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); border: 1px solid var(--color-danger); border-radius: var(--radius-control); color: var(--color-danger); background: var(--color-surface); }\n.alert p { margin: 0; }\n\n/* ---------- Dialog (src/ui/Dialog.tsx) ---------- */\n.dialog { width: min(480px, calc(100% - 2 * var(--space-4))); padding: 0; border: 1px solid var(--color-border); border-radius: var(--radius-panel); background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-lg); }\n.dialog::backdrop { background: rgba(20, 20, 18, 0.45); backdrop-filter: blur(2px); }\n.dialog__header { display: flex; align-items: start; justify-content: space-between; gap: var(--space-3); padding: var(--space-5) var(--space-5) 0; }\n.dialog__title { font-size: var(--text-lg); }\n.dialog__body { display: grid; gap: var(--space-4); padding: var(--space-4) var(--space-5) var(--space-5); }\n.dialog__footer { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; padding: var(--space-3) var(--space-5); border-top: 1px solid var(--color-border); background: var(--color-surface-2); }\n\n/* ---------- Skeleton (src/ui/Skeleton.tsx) ---------- */\n.skeleton { display: grid; gap: var(--space-2); }\n.skeleton__line { height: 1em; border-radius: 4px; background: linear-gradient(90deg, var(--color-border) 25%, var(--color-surface-2) 50%, var(--color-border) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }\n@keyframes shimmer { to { background-position: -200% 0; } }\n\n/* ---------- Empty state (src/ui/feedback.tsx) ---------- */\n.empty { display: grid; gap: var(--space-2); justify-items: center; padding: var(--space-10) var(--space-6); border: 1px dashed var(--color-border-strong); border-radius: var(--radius-panel); text-align: center; }\n.empty__title { margin: 0; font: 600 var(--text-lg)/1.3 var(--font-display); }\n.empty__body { margin: 0; color: var(--color-muted); max-width: 44ch; }\n\n/* ---------- Loading, unavailable, banner ---------- */\n.loading { display: grid; place-content: center; justify-items: center; gap: var(--space-3); min-height: 100vh; color: var(--color-muted); }\n.unavailable { max-width: 380px; margin: 0 var(--space-4); color: var(--color-text); }\n.unavailable p { margin: 0; }\n.banner { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: center; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-danger); background: var(--color-surface); color: var(--color-danger); }\n.banner p { margin: 0; }\n.spinner { width: 24px; height: 24px; border: 3px solid var(--color-border); border-top-color: var(--color-accent); border-radius: 50%; animation: spin 0.8s linear infinite; }\n@keyframes spin { to { transform: rotate(360deg); } }\n\n/* ---------- Sign-in (src/ui/AuthCard.tsx) ---------- */\n.auth {\n display: grid;\n grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);\n gap: var(--space-12);\n align-items: center;\n width: min(960px, calc(100% - 2 * var(--space-6)));\n min-height: 100vh;\n margin: 0 auto;\n padding: var(--space-12) 0;\n}\n.auth__intro { display: grid; gap: var(--space-3); align-content: center; }\n.auth__app { margin: 0; color: var(--color-accent); font-weight: 600; }\n.auth__title { margin: 0; font-size: var(--text-display); line-height: 1.05; }\n.auth__column { display: grid; gap: var(--space-4); }\n.auth__form .button { width: 100%; }\n.auth__providers { display: grid; gap: var(--space-2); }\n.auth__switch { margin: 0; text-align: center; color: var(--color-muted); font-size: var(--text-sm); }\n.auth__forgot { margin: 0; text-align: right; font-size: var(--text-sm); }\n.auth__forgot a, .auth__switch a { display: inline-flex; align-items: center; min-height: 44px; }\n.divider { display: flex; align-items: center; gap: var(--space-3); color: var(--color-muted); font-size: var(--text-sm); }\n.divider::before, .divider::after { content: \"\"; flex: 1; height: 1px; background: var(--color-border); }\n.provider-icon { width: 18px; height: 18px; flex: none; }\n\n/* ---------- Signed-in frame (src/ui/AppShell.tsx) ---------- */\n.shell { min-height: 100vh; }\n.topbar {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--space-4);\n width: min(var(--content-width), calc(100% - 2 * var(--space-6)));\n margin: 0 auto;\n padding: var(--space-3) 0;\n border-bottom: 1px solid var(--color-border);\n}\n.topbar__error { width: min(var(--content-width), calc(100% - 2 * var(--space-6))); margin: var(--space-2) auto 0; }\n.brand { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px; font: 600 var(--text-lg)/1 var(--font-display); letter-spacing: var(--tracking-display); color: inherit; text-decoration: none; }\n.account { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }\n.account__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-muted); font-size: var(--text-sm); }\n.content { width: min(var(--content-width), calc(100% - 2 * var(--space-6))); margin: 0 auto; padding: var(--space-8) 0 var(--space-16); outline: none; }\n\n/* ---------- Email verification (src/ui/VerifyEmail.tsx) ---------- */\n.verify-email { margin-bottom: var(--space-6); }\n.verify-email__form { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }\n.verify-email__form .field { grid-template-columns: auto auto; align-items: center; }\n.verify-email__form input { width: 8ch; letter-spacing: 0.2em; text-align: center; }\n\n/* ---------- Responsive ---------- */\n@media (max-width: 760px) {\n .auth { grid-template-columns: 1fr; gap: var(--space-6); align-content: start; padding-top: var(--space-8); }\n .auth__title { font-size: var(--text-2xl); }\n .page-header { margin-bottom: var(--space-6); }\n .page-header__title { font-size: var(--text-2xl); }\n .content { padding-top: var(--space-6); }\n}\n@media (max-width: 480px) {\n .panel { padding: var(--space-4); }\n .card__header, .card__body, .card__footer { padding-left: var(--space-4); padding-right: var(--space-4); }\n .table th, .table td { padding-left: var(--space-4); padding-right: var(--space-4); }\n}\n@media (prefers-reduced-motion: reduce) {\n .spinner { animation-duration: 3s; }\n .skeleton__line { animation: none; }\n .button, .meter__fill { transition: none; }\n}\n\n/* ---------- Your app ---------- */\n/* Add page-specific styles below. Use tokens; add a class, don't restyle a tag. */\n";
|
|
4
|
-
export declare const STYLED_AUTH_CARD = "import type { FormEvent, ReactNode } from 'react';\nimport type { CredentialsForm } from '../../types/auth';\nimport { Button } from './Button';\nimport { TextField } from './Field';\n\ninterface AuthCardProps {\n appName: string;\n /** One line under the title: what the app is for. */\n tagline?: string;\n form: CredentialsForm;\n /** Social sign-in buttons, shown above the email form (see ProviderButtons). */\n providers?: ReactNode;\n /** Anything that belongs under the form: a magic-link form, a terms line. */\n children?: ReactNode;\n}\n\n/** The sign-in page: an intro column and a form column. Add to it through\n * the `providers` and `children` slots; the two-column grid holds exactly\n * these two columns, so don't add siblings to it. */\nexport function AuthCard({ appName, tagline, form, providers, children }: AuthCardProps) {\n
|
|
5
|
-
export declare const PLAIN_AUTH_CARD = "import type { FormEvent, ReactNode } from 'react';\nimport type { CredentialsForm } from '../../types/auth';\nimport { Button } from './Button';\nimport { TextField } from './Field';\n\ninterface AuthCardProps {\n appName: string;\n /** One line under the title: what the app is for. */\n tagline?: string;\n form: CredentialsForm;\n /** Social sign-in buttons, shown above the email form (see ProviderButtons). */\n providers?: ReactNode;\n /** What belongs under the form: a magic-link form, a terms line. */\n children?: ReactNode;\n}\n\n/** The sign-in page. Add to it through the `providers` and `children` slots. */\nexport function AuthCard({ appName, tagline, form, providers, children }: AuthCardProps) {\n
|
|
3
|
+
export declare const APP_CSS = "/* Base styles and the classes src/ui components render. Values come from\n tokens.css. Add app-specific styles at the end of this file, or in a new\n file imported from src/main.tsx; do not restyle native elements globally. */\n\n/* ---------- Base ---------- */\n*, *::before, *::after { box-sizing: border-box; }\nhtml { -webkit-text-size-adjust: 100%; }\nbody {\n margin: 0;\n min-width: 320px;\n background: var(--color-bg);\n color: var(--color-text);\n font: 400 var(--text-base)/1.55 var(--font-body);\n -webkit-font-smoothing: antialiased;\n}\nbutton, input, select, textarea { font: inherit; color: inherit; }\nh1, h2, h3, p { margin: 0; }\nh1, h2, h3 { font-family: var(--font-display); line-height: 1.2; letter-spacing: var(--tracking-display); font-weight: 600; }\nh1 { font-size: var(--text-2xl); }\nh2 { font-size: var(--text-xl); }\nh3 { font-size: var(--text-lg); }\na { color: var(--color-accent); text-underline-offset: 3px; }\ncode, kbd { font-family: var(--font-mono); font-size: 0.9em; }\n:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; }\n::placeholder { color: var(--color-muted); opacity: 0.8; }\n\n.muted { color: var(--color-muted); }\n.hint { margin: 0; color: var(--color-muted); font-size: var(--text-sm); font-weight: 400; }\n.error { margin: 0; color: var(--color-danger); font-size: var(--text-sm); }\n.skip-link { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; position: absolute; left: var(--space-3); top: -60px; padding: var(--space-2) var(--space-3); background: var(--color-text); color: var(--color-bg); z-index: 10; }\n.skip-link:focus { top: var(--space-3); }\n.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n\n/* ---------- Layout primitives (src/ui/layout.tsx) ---------- */\n.stack { display: grid; gap: var(--stack-gap, var(--space-4)); align-content: start; }\n.stack > *, .grid > *, .card > *, .content > * { min-width: 0; }\n.inline { display: flex; flex-wrap: wrap; gap: var(--inline-gap, var(--space-2)); align-items: var(--inline-align, center); justify-content: var(--inline-justify, flex-start); }\n.grid { display: grid; gap: var(--grid-gap, var(--space-4)); grid-template-columns: repeat(auto-fit, minmax(min(var(--grid-min, 220px), 100%), 1fr)); }\n.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }\n\n.page-header { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: flex-end; justify-content: space-between; margin-bottom: var(--space-8); }\n.page-header__text { display: grid; gap: var(--space-1); min-width: 0; }\n.page-header__title { font-size: var(--text-display); line-height: 1.1; }\n.page-header__description { color: var(--color-muted); max-width: 60ch; }\n\n.eyebrow { margin: 0; color: var(--color-muted); font-size: var(--text-xs); font-weight: 600; letter-spacing: var(--tracking-label); text-transform: uppercase; }\n.section-title { margin: 0 0 var(--space-3); font-size: var(--text-sm); font-weight: 600; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--color-muted); }\n\n/* ---------- Panel and Card ---------- */\n.panel {\n display: grid;\n gap: var(--space-4);\n padding: var(--space-6);\n border: 1px solid var(--color-border);\n border-radius: var(--radius-panel);\n background: var(--color-surface);\n box-shadow: var(--shadow-md);\n}\n.panel__title { margin: 0; font: 600 var(--text-lg)/1.2 var(--font-display); }\n\n.card { display: grid; gap: 0; padding: 0; border: 1px solid var(--color-border); border-radius: var(--radius-panel); background: var(--color-surface); box-shadow: var(--shadow-sm); overflow: hidden; }\n.card__header { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border); }\n.card__heading { display: grid; gap: 2px; min-width: 0; }\n.card__title { font-size: var(--text-base); font-weight: 600; letter-spacing: 0; }\n.card__description { color: var(--color-muted); font-size: var(--text-sm); }\n.card__body { padding: var(--space-5); }\n.card__body--flush { padding: 0; }\n.card__footer { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; padding: var(--space-3) var(--space-5); border-top: 1px solid var(--color-border); background: var(--color-surface-2); }\n\n/* ---------- Buttons (src/ui/Button.tsx) ---------- */\n.button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--space-2);\n min-height: var(--control-height);\n padding: 0 var(--space-4);\n border: 1px solid var(--color-accent);\n border-radius: var(--radius-control);\n background: var(--color-accent);\n color: var(--color-on-accent);\n font-weight: 600;\n line-height: 1.2;\n white-space: nowrap;\n text-decoration: none;\n cursor: pointer;\n transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;\n}\n.button:hover:not(:disabled) { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }\n.button:disabled { opacity: 0.5; cursor: not-allowed; }\n.button--secondary { background: var(--color-surface); border-color: var(--color-border-strong); color: var(--color-text); }\n.button--secondary:hover:not(:disabled) { background: var(--color-surface-2); border-color: var(--color-border-strong); }\n.button--quiet { background: transparent; border-color: transparent; color: var(--color-text); }\n.button--quiet:hover:not(:disabled) { background: var(--color-accent-soft); border-color: transparent; }\n.button--danger { background: var(--color-danger); border-color: var(--color-danger); color: #fff; }\n.button--danger:hover:not(:disabled) { background: var(--color-danger); border-color: var(--color-danger); filter: brightness(0.92); }\n.button--sm { padding: 0 var(--space-3); font-size: var(--text-sm); }\n.button--block { width: 100%; }\n.button__spinner { width: 1em; height: 1em; border-width: 2px; }\n\n.link-button {\n display: inline-flex; align-items: center; min-height: var(--control-height);\n padding: 0 var(--space-2); border: 0; background: none;\n color: var(--color-accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;\n}\n.link-button:disabled { opacity: 0.5; cursor: not-allowed; }\n.link-button--danger { color: var(--color-danger); }\n\n/* ---------- Fields (src/ui/Field.tsx) ---------- */\n.field { display: grid; gap: 6px; min-width: 0; }\n.field__label { display: flex; justify-content: space-between; gap: var(--space-2); font-size: var(--text-sm); font-weight: 600; }\n.field__optional { color: var(--color-muted); font-weight: 400; }\n.field .control {\n width: 100%;\n min-height: var(--control-height);\n padding: 10px 12px;\n border: 1px solid var(--color-border-strong);\n border-radius: var(--radius-control);\n background: var(--color-surface);\n color: var(--color-text);\n}\n.field .control:hover { border-color: var(--color-muted); }\n.field .control[aria-invalid=\"true\"] { border-color: var(--color-danger); }\n.field .control:disabled { background: var(--color-surface-2); color: var(--color-muted); cursor: not-allowed; }\n.field textarea.control { min-height: calc(var(--control-height) * 2.2); resize: vertical; line-height: 1.5; }\n.field select.control {\n appearance: none;\n padding-right: 40px;\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%2366615a' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E\");\n background-repeat: no-repeat;\n background-position: right 12px center;\n}\n.field input[type=\"date\"].control, .field input[type=\"time\"].control { min-width: 10ch; }\n.field--inline { grid-template-columns: auto 1fr; align-items: center; }\n.field--inline .field__label { font-weight: 400; }\n.field input[type=\"checkbox\"], .field input[type=\"radio\"] { width: 20px; height: 20px; margin: 0; accent-color: var(--color-accent); }\n.field__hint { color: var(--color-muted); font-size: var(--text-sm); }\n.field__error { color: var(--color-danger); font-size: var(--text-sm); }\n.form-row { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(var(--form-row-min, 160px), 100%), 1fr)); align-items: start; }\n\n/* ---------- Tabs (src/ui/Tabs.tsx) ---------- */\n.tabs { display: flex; gap: var(--space-1); padding: var(--space-1); min-height: var(--control-height); border: 1px solid var(--color-border); border-radius: var(--radius-control); background: var(--color-surface-2); overflow-x: auto; scrollbar-width: none; max-width: 100%; }\n.tabs::-webkit-scrollbar { display: none; }\n.tab { flex: 0 0 auto; min-height: calc(var(--control-height) - 8px); padding: 0 var(--space-4); border: 0; border-radius: calc(var(--radius-control) - 2px); background: transparent; color: var(--color-muted); font-weight: 600; font-size: var(--text-sm); white-space: nowrap; cursor: pointer; }\n.tab:hover { color: var(--color-text); }\n.tab[aria-selected=\"true\"] { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-sm); }\n\n/* ---------- Badge (src/ui/Badge.tsx) ---------- */\n.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 10px; border-radius: var(--radius-pill); background: var(--color-surface-2); border: 1px solid var(--color-border); color: var(--color-text); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }\n.badge--accent { background: var(--color-accent-soft); border-color: transparent; color: var(--color-accent); }\n.badge--success { background: var(--color-success-soft); border-color: transparent; color: var(--color-success); }\n.badge--warning { background: var(--color-warning-soft); border-color: transparent; color: var(--color-warning); }\n.badge--danger { background: var(--color-danger-soft); border-color: transparent; color: var(--color-danger); }\n.badge--info { background: var(--color-info-soft); border-color: transparent; color: var(--color-info); }\n.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }\n\n/* ---------- Stat (src/ui/Stat.tsx) ---------- */\n.stat { display: grid; gap: var(--space-2); padding: var(--space-5); border: 1px solid var(--color-border); border-radius: var(--radius-panel); background: var(--color-surface); box-shadow: var(--shadow-sm); }\n.stat__value { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 600; letter-spacing: var(--tracking-display); line-height: 1.1; font-variant-numeric: tabular-nums; }\n.stat__value small { color: var(--color-muted); font-size: 0.55em; font-weight: 500; letter-spacing: 0; margin-left: 0.3em; }\n.stat__detail { color: var(--color-muted); font-size: var(--text-sm); }\n.stat__detail--success { color: var(--color-success); }\n.stat__detail--danger { color: var(--color-danger); }\n.meter { height: 6px; border-radius: var(--radius-pill); background: var(--color-border); overflow: hidden; }\n.meter__fill { height: 100%; border-radius: inherit; background: var(--color-accent); transition: width 240ms ease; }\n\n/* ---------- Table (src/ui/Table.tsx) ---------- */\n.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; container-type: inline-size; }\n.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }\n.table th, .table td { padding: var(--space-3) var(--space-5); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--color-border); }\n.table th { color: var(--color-muted); font-size: var(--text-xs); font-weight: 600; letter-spacing: var(--tracking-label); text-transform: uppercase; white-space: nowrap; background: var(--color-surface-2); }\n.table tbody tr:last-child td { border-bottom: 0; }\n.table tbody tr:hover td { background: var(--color-surface-2); }\n.table .is-numeric { text-align: right; }\n.table__empty { padding: var(--space-8) var(--space-5); text-align: center; color: var(--color-muted); }\n/* A narrow card (a phone): each row becomes a block of label and value lines, so nothing scrolls sideways. */\n@container (max-width: 560px) {\n .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n .table, .table tbody, .table tr { display: block; width: 100%; }\n .table tr { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); }\n .table tbody tr:last-child { border-bottom: 0; }\n .table td { display: flex; gap: var(--space-3); align-items: baseline; padding: var(--space-1) 0; border-bottom: 0; text-align: left; overflow-wrap: anywhere; }\n .table td::before { content: attr(data-label); flex: 0 0 38%; color: var(--color-muted); font-size: var(--text-xs); font-weight: 600; letter-spacing: var(--tracking-label); text-transform: uppercase; }\n .table td.is-numeric { text-align: left; }\n .table tbody tr:hover td { background: transparent; }\n .table .table__empty { display: block; padding: var(--space-6) 0; text-align: center; }\n .table .table__empty::before { content: none; }\n}\n\n/* ---------- Notice (src/ui/Notice.tsx) ---------- */\n.notice { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; padding: var(--space-3) var(--space-4); border: 1px solid var(--color-border); border-left-width: 4px; border-radius: var(--radius-control); background: var(--color-surface); font-size: var(--text-sm); }\n.notice__body { flex: 1 1 240px; display: grid; gap: 2px; min-width: 0; }\n.notice__title { font-weight: 600; }\n.notice--info { border-left-color: var(--color-info); }\n.notice--success { border-left-color: var(--color-success); }\n.notice--warning { border-left-color: var(--color-warning); }\n.notice--danger { border-left-color: var(--color-danger); }\n.notice__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }\n\n/* Alert from feedback.tsx; Notice is preferred for new code. */\n.alert { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); border: 1px solid var(--color-danger); border-radius: var(--radius-control); color: var(--color-danger); background: var(--color-surface); }\n.alert p { margin: 0; }\n\n/* ---------- Dialog (src/ui/Dialog.tsx) ---------- */\n.dialog { width: min(480px, calc(100% - 2 * var(--space-4))); padding: 0; border: 1px solid var(--color-border); border-radius: var(--radius-panel); background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-lg); }\n.dialog::backdrop { background: rgba(20, 20, 18, 0.45); backdrop-filter: blur(2px); }\n.dialog__header { display: flex; align-items: start; justify-content: space-between; gap: var(--space-3); padding: var(--space-5) var(--space-5) 0; }\n.dialog__title { font-size: var(--text-lg); }\n.dialog__body { display: grid; gap: var(--space-4); padding: var(--space-4) var(--space-5) var(--space-5); }\n.dialog__footer { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; padding: var(--space-3) var(--space-5); border-top: 1px solid var(--color-border); background: var(--color-surface-2); }\n\n/* ---------- Skeleton (src/ui/Skeleton.tsx) ---------- */\n.skeleton { display: grid; gap: var(--space-2); }\n.skeleton__line { height: 1em; border-radius: 4px; background: linear-gradient(90deg, var(--color-border) 25%, var(--color-surface-2) 50%, var(--color-border) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }\n@keyframes shimmer { to { background-position: -200% 0; } }\n\n/* ---------- Empty state (src/ui/feedback.tsx) ---------- */\n.empty { display: grid; gap: var(--space-2); justify-items: center; padding: var(--space-10) var(--space-6); border: 1px dashed var(--color-border-strong); border-radius: var(--radius-panel); text-align: center; }\n.empty__title { margin: 0; font: 600 var(--text-lg)/1.3 var(--font-display); }\n.empty__body { margin: 0; color: var(--color-muted); max-width: 44ch; }\n\n/* ---------- Loading, unavailable, banner ---------- */\n.loading { display: grid; place-content: center; justify-items: center; gap: var(--space-3); min-height: 100vh; color: var(--color-muted); }\n.unavailable { max-width: 380px; margin: 0 var(--space-4); color: var(--color-text); }\n.unavailable p { margin: 0; }\n.banner { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: center; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-danger); background: var(--color-surface); color: var(--color-danger); }\n.banner p { margin: 0; }\n.spinner { width: 24px; height: 24px; border: 3px solid var(--color-border); border-top-color: var(--color-accent); border-radius: 50%; animation: spin 0.8s linear infinite; }\n@keyframes spin { to { transform: rotate(360deg); } }\n\n/* ---------- Sign-in (src/ui/AuthCard.tsx) ---------- */\n.auth {\n display: grid;\n grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);\n gap: var(--space-12);\n align-items: center;\n width: min(960px, calc(100% - 2 * var(--space-6)));\n min-height: 100vh;\n margin: 0 auto;\n padding: var(--space-12) 0;\n}\n.auth__intro { display: grid; gap: var(--space-3); align-content: center; }\n.auth__app { margin: 0; color: var(--color-accent); font-weight: 600; }\n.auth__title { margin: 0; font-size: var(--text-display); line-height: 1.05; }\n.auth__column { display: grid; gap: var(--space-4); }\n.auth__form .button { width: 100%; }\n.auth__providers { display: grid; gap: var(--space-2); }\n.auth__forgot { margin: 0; text-align: right; font-size: var(--text-sm); }\n.auth__switch { margin: 0; text-align: center; color: var(--color-muted); font-size: var(--text-sm); }\n.auth__forgot a, .auth__switch a { display: inline-flex; align-items: center; min-height: 44px; }\n.divider { display: flex; align-items: center; gap: var(--space-3); color: var(--color-muted); font-size: var(--text-sm); }\n.divider::before, .divider::after { content: \"\"; flex: 1; height: 1px; background: var(--color-border); }\n.provider-icon { width: 18px; height: 18px; flex: none; }\n\n/* ---------- Signed-in frame (src/ui/AppShell.tsx) ---------- */\n.shell { min-height: 100vh; }\n.topbar {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--space-4);\n width: min(var(--content-width), calc(100% - 2 * var(--space-6)));\n margin: 0 auto;\n padding: var(--space-3) 0;\n border-bottom: 1px solid var(--color-border);\n}\n.topbar__error { width: min(var(--content-width), calc(100% - 2 * var(--space-6))); margin: var(--space-2) auto 0; }\n.brand { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px; font: 600 var(--text-lg)/1 var(--font-display); letter-spacing: var(--tracking-display); color: inherit; text-decoration: none; }\n.account { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }\n.account__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-muted); font-size: var(--text-sm); }\n.content { width: min(var(--content-width), calc(100% - 2 * var(--space-6))); margin: 0 auto; padding: var(--space-8) 0 var(--space-16); outline: none; }\n\n/* ---------- Email verification (src/ui/VerifyEmail.tsx) ---------- */\n.verify-email { margin-bottom: var(--space-6); }\n.verify-email__form { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }\n.verify-email__form .field { grid-template-columns: auto auto; align-items: center; }\n.verify-email__form input { width: 8ch; letter-spacing: 0.2em; text-align: center; }\n\n/* ---------- Responsive ---------- */\n@media (max-width: 760px) {\n .auth { grid-template-columns: 1fr; gap: var(--space-6); align-content: start; padding-top: var(--space-8); }\n .auth__title { font-size: var(--text-2xl); }\n .page-header { margin-bottom: var(--space-6); }\n .page-header__title { font-size: var(--text-2xl); }\n .content { padding-top: var(--space-6); }\n}\n@media (max-width: 480px) {\n .panel { padding: var(--space-4); }\n .card__header, .card__body, .card__footer { padding-left: var(--space-4); padding-right: var(--space-4); }\n .table th, .table td { padding-left: var(--space-4); padding-right: var(--space-4); }\n}\n@media (prefers-reduced-motion: reduce) {\n .spinner { animation-duration: 3s; }\n .skeleton__line { animation: none; }\n .button, .meter__fill { transition: none; }\n}\n\n/* ---------- Your app ---------- */\n/* Add page-specific styles below. Use tokens; add a class, don't restyle a tag. */\n";
|
|
4
|
+
export declare const STYLED_AUTH_CARD = "import type { FormEvent, ReactNode } from 'react';\nimport type { CredentialsForm } from '../../types/auth';\nimport { Button } from './Button';\nimport { TextField } from './Field';\n\ninterface AuthCardProps {\n appName: string;\n /** One line under the title: what the app is for. */\n tagline?: string;\n form: CredentialsForm;\n /** Social sign-in buttons, shown above the email form (see ProviderButtons). */\n providers?: ReactNode;\n /** Anything that belongs under the form: a magic-link form, a terms line. */\n children?: ReactNode;\n}\n\n/** The sign-in page: an intro column and a form column. Add to it through\n * the `providers` and `children` slots; the two-column grid holds exactly\n * these two columns, so don't add siblings to it. */\nexport function AuthCard({ appName, tagline, form, providers, children }: AuthCardProps) {\n // Enter signs in; Create account is its own button. Both are always on the page.\n function onSubmit(event: FormEvent<HTMLFormElement>) {\n event.preventDefault();\n void form.submit('sign-in');\n }\n\n return (\n <main className=\"auth\">\n <div className=\"auth__intro\">\n <p className=\"auth__app\">{appName}</p>\n <h1 className=\"auth__title\">Welcome</h1>\n <p className=\"muted\">{tagline ?? 'Sign in, or create an account in a few seconds.'}</p>\n </div>\n <div className=\"auth__column\">\n <form className=\"panel auth__form\" onSubmit={onSubmit} noValidate aria-label=\"Sign in or create an account\" data-sw-auth=\"form\">\n {providers ? (\n <>\n {providers}\n <p className=\"divider\" aria-hidden=\"true\">or use email</p>\n </>\n ) : null}\n <TextField id=\"auth-email\" label=\"Email\" type=\"email\" name=\"email\" autoComplete=\"email\" inputMode=\"email\" autoFocus data-sw-auth=\"email\"\n value={form.email} onChange={(event) => form.setEmail(event.target.value)} />\n <TextField id=\"auth-password\" label=\"Password\" type=\"password\" name=\"password\" data-sw-auth=\"password\"\n autoComplete=\"current-password\"\n hint={`A new account needs at least ${form.passwordMinLength} characters.`}\n value={form.password} onChange={(event) => form.setPassword(event.target.value)} />\n <p className=\"auth__forgot\"><a href=\"/forgot-password\">Forgot password?</a></p>\n {form.error ? <p className=\"error\" role=\"alert\" data-sw-auth=\"error\">{form.error}</p> : null}\n <Button type=\"submit\" block disabled={form.pending !== null} pending={form.pending === 'sign-in'} data-sw-auth=\"sign-in\">Sign in</Button>\n <Button variant=\"secondary\" block disabled={form.pending !== null} pending={form.pending === 'sign-up'} data-sw-auth=\"sign-up\"\n onClick={() => void form.submit('sign-up')}>Create account</Button>\n </form>\n {children}\n </div>\n </main>\n );\n}\n";
|
|
5
|
+
export declare const PLAIN_AUTH_CARD = "import type { FormEvent, ReactNode } from 'react';\nimport type { CredentialsForm } from '../../types/auth';\nimport { Button } from './Button';\nimport { TextField } from './Field';\n\ninterface AuthCardProps {\n appName: string;\n /** One line under the title: what the app is for. */\n tagline?: string;\n form: CredentialsForm;\n /** Social sign-in buttons, shown above the email form (see ProviderButtons). */\n providers?: ReactNode;\n /** What belongs under the form: a magic-link form, a terms line. */\n children?: ReactNode;\n}\n\n/** The sign-in page. Add to it through the `providers` and `children` slots. */\nexport function AuthCard({ appName, tagline, form, providers, children }: AuthCardProps) {\n // Enter signs in; Create account is its own button. Both are always on the page.\n function onSubmit(event: FormEvent<HTMLFormElement>) {\n event.preventDefault();\n void form.submit('sign-in');\n }\n\n return (\n <main>\n <h1>Sign in or create an account \u00B7 {appName}</h1>\n {tagline ? <p>{tagline}</p> : null}\n {providers}\n <form onSubmit={onSubmit} noValidate aria-label=\"Sign in or create an account\" data-sw-auth=\"form\">\n <TextField id=\"auth-email\" label=\"Email\" type=\"email\" name=\"email\" autoComplete=\"email\" inputMode=\"email\" autoFocus data-sw-auth=\"email\"\n value={form.email} onChange={(event) => form.setEmail(event.target.value)} />\n <TextField id=\"auth-password\" label=\"Password\" type=\"password\" name=\"password\" data-sw-auth=\"password\"\n autoComplete=\"current-password\"\n hint={`A new account needs at least ${form.passwordMinLength} characters.`}\n value={form.password} onChange={(event) => form.setPassword(event.target.value)} />\n <p><a href=\"/forgot-password\">Forgot password?</a></p>\n {form.error ? <p role=\"alert\" data-sw-auth=\"error\">{form.error}</p> : null}\n <Button type=\"submit\" disabled={form.pending !== null} pending={form.pending === 'sign-in'} data-sw-auth=\"sign-in\">Sign in</Button>{' '}\n <Button variant=\"secondary\" disabled={form.pending !== null} pending={form.pending === 'sign-up'} data-sw-auth=\"sign-up\"\n onClick={() => void form.submit('sign-up')}>Create account</Button>\n </form>\n {children}\n </main>\n );\n}\n";
|
|
6
6
|
export declare const STYLED_VERIFY_EMAIL = "import type { FormEvent } from 'react';\nimport type { EmailVerification } from '../../types/auth';\n\n/** A quiet reminder above the page, never its main call to action. */\nexport function VerifyEmailPanel({ verification }: { verification: EmailVerification }) {\n if (verification.status === 'checking' || verification.status === 'verified') return null;\n if (verification.status === 'unavailable') {\n return (\n <div className=\"notice notice--warning verify-email\" role=\"alert\">\n <p className=\"notice__body\">Could not check whether your email is verified.</p>\n <div className=\"notice__actions\">\n <button type=\"button\" className=\"button button--secondary button--sm\" onClick={verification.retry}>Try again</button>\n </div>\n </div>\n );\n }\n function onSubmit(event: FormEvent<HTMLFormElement>) {\n event.preventDefault();\n void verification.submit();\n }\n return (\n <section className=\"notice notice--info verify-email\" aria-label=\"Verify your email\">\n <div className=\"notice__body\">\n <p className=\"notice__title\">Verify your email</p>\n <p>{verification.sent ? 'Enter the 6-digit code we emailed you.' : verification.entering ? 'Enter the 6-digit code from the latest email we sent you.' : 'We will email you a 6-digit code.'}</p>\n {verification.error ? <p className=\"error\" role=\"alert\">{verification.error}</p> : null}\n </div>\n {verification.entering ? (\n <form className=\"notice__actions verify-email__form\" onSubmit={onSubmit} noValidate>\n <label className=\"visually-hidden\" htmlFor=\"verify-code\">Code</label>\n <input id=\"verify-code\" className=\"control\" inputMode=\"numeric\" autoComplete=\"one-time-code\" maxLength={6} required placeholder=\"000000\"\n value={verification.code} onChange={(event) => verification.setCode(event.target.value)} />\n <button type=\"submit\" className=\"button button--sm\" disabled={!verification.canSubmit} aria-busy={verification.pending}>Verify</button>\n <button type=\"button\" className=\"button button--quiet button--sm\" onClick={() => void verification.sendCode()} disabled={verification.pending}>Send a new code</button>\n </form>\n ) : (\n <div className=\"notice__actions\">\n <button type=\"button\" className=\"button button--secondary button--sm\" onClick={() => void verification.sendCode()} disabled={verification.pending} aria-busy={verification.pending}>\n Email me a code\n </button>\n <button type=\"button\" className=\"button button--quiet button--sm\" onClick={verification.enterCode} disabled={verification.pending}>I already have a code</button>\n </div>\n )}\n </section>\n );\n}\n";
|
|
7
7
|
export declare const STYLED_UI_KIT: InitScaffoldFile[];
|
|
8
8
|
export declare const PLAIN_UI_KIT: InitScaffoldFile[];
|
package/dist/lib/init-ui-kit.js
CHANGED
|
@@ -357,8 +357,8 @@ code, kbd { font-family: var(--font-mono); font-size: 0.9em; }
|
|
|
357
357
|
.auth__column { display: grid; gap: var(--space-4); }
|
|
358
358
|
.auth__form .button { width: 100%; }
|
|
359
359
|
.auth__providers { display: grid; gap: var(--space-2); }
|
|
360
|
-
.auth__switch { margin: 0; text-align: center; color: var(--color-muted); font-size: var(--text-sm); }
|
|
361
360
|
.auth__forgot { margin: 0; text-align: right; font-size: var(--text-sm); }
|
|
361
|
+
.auth__switch { margin: 0; text-align: center; color: var(--color-muted); font-size: var(--text-sm); }
|
|
362
362
|
.auth__forgot a, .auth__switch a { display: inline-flex; align-items: center; min-height: 44px; }
|
|
363
363
|
.divider { display: flex; align-items: center; gap: var(--space-3); color: var(--color-muted); font-size: var(--text-sm); }
|
|
364
364
|
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--color-border); }
|
|
@@ -431,23 +431,21 @@ interface AuthCardProps {
|
|
|
431
431
|
* the \`providers\` and \`children\` slots; the two-column grid holds exactly
|
|
432
432
|
* these two columns, so don't add siblings to it. */
|
|
433
433
|
export function AuthCard({ appName, tagline, form, providers, children }: AuthCardProps) {
|
|
434
|
-
|
|
435
|
-
|
|
434
|
+
// Enter signs in; Create account is its own button. Both are always on the page.
|
|
436
435
|
function onSubmit(event: FormEvent<HTMLFormElement>) {
|
|
437
436
|
event.preventDefault();
|
|
438
|
-
void form.submit();
|
|
437
|
+
void form.submit('sign-in');
|
|
439
438
|
}
|
|
440
439
|
|
|
441
440
|
return (
|
|
442
441
|
<main className="auth">
|
|
443
442
|
<div className="auth__intro">
|
|
444
443
|
<p className="auth__app">{appName}</p>
|
|
445
|
-
<h1 className="auth__title">
|
|
446
|
-
<p className="muted">{tagline ??
|
|
444
|
+
<h1 className="auth__title">Welcome</h1>
|
|
445
|
+
<p className="muted">{tagline ?? 'Sign in, or create an account in a few seconds.'}</p>
|
|
447
446
|
</div>
|
|
448
447
|
<div className="auth__column">
|
|
449
|
-
<form className="panel auth__form" onSubmit={onSubmit} noValidate aria-label=
|
|
450
|
-
data-sw-auth="form" data-sw-auth-mode={form.mode}>
|
|
448
|
+
<form className="panel auth__form" onSubmit={onSubmit} noValidate aria-label="Sign in or create an account" data-sw-auth="form">
|
|
451
449
|
{providers ? (
|
|
452
450
|
<>
|
|
453
451
|
{providers}
|
|
@@ -457,21 +455,14 @@ export function AuthCard({ appName, tagline, form, providers, children }: AuthCa
|
|
|
457
455
|
<TextField id="auth-email" label="Email" type="email" name="email" autoComplete="email" inputMode="email" autoFocus data-sw-auth="email"
|
|
458
456
|
value={form.email} onChange={(event) => form.setEmail(event.target.value)} />
|
|
459
457
|
<TextField id="auth-password" label="Password" type="password" name="password" data-sw-auth="password"
|
|
460
|
-
autoComplete=
|
|
461
|
-
|
|
462
|
-
hint={signUp ? \`At least \${form.passwordMinLength} characters.\` : undefined}
|
|
458
|
+
autoComplete="current-password"
|
|
459
|
+
hint={\`A new account needs at least \${form.passwordMinLength} characters.\`}
|
|
463
460
|
value={form.password} onChange={(event) => form.setPassword(event.target.value)} />
|
|
464
|
-
|
|
461
|
+
<p className="auth__forgot"><a href="/forgot-password">Forgot password?</a></p>
|
|
465
462
|
{form.error ? <p className="error" role="alert" data-sw-auth="error">{form.error}</p> : null}
|
|
466
|
-
<Button type="submit" block disabled={
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
<p className="auth__switch">
|
|
470
|
-
{signUp ? 'Already have an account?' : 'New here?'}{' '}
|
|
471
|
-
<button type="button" className="link-button" onClick={form.toggleMode} disabled={form.pending} data-sw-auth="mode">
|
|
472
|
-
{signUp ? 'Sign in' : 'Create an account'}
|
|
473
|
-
</button>
|
|
474
|
-
</p>
|
|
463
|
+
<Button type="submit" block disabled={form.pending !== null} pending={form.pending === 'sign-in'} data-sw-auth="sign-in">Sign in</Button>
|
|
464
|
+
<Button variant="secondary" block disabled={form.pending !== null} pending={form.pending === 'sign-up'} data-sw-auth="sign-up"
|
|
465
|
+
onClick={() => void form.submit('sign-up')}>Create account</Button>
|
|
475
466
|
</form>
|
|
476
467
|
{children}
|
|
477
468
|
</div>
|
|
@@ -497,37 +488,30 @@ interface AuthCardProps {
|
|
|
497
488
|
|
|
498
489
|
/** The sign-in page. Add to it through the \`providers\` and \`children\` slots. */
|
|
499
490
|
export function AuthCard({ appName, tagline, form, providers, children }: AuthCardProps) {
|
|
500
|
-
|
|
501
|
-
|
|
491
|
+
// Enter signs in; Create account is its own button. Both are always on the page.
|
|
502
492
|
function onSubmit(event: FormEvent<HTMLFormElement>) {
|
|
503
493
|
event.preventDefault();
|
|
504
|
-
void form.submit();
|
|
494
|
+
void form.submit('sign-in');
|
|
505
495
|
}
|
|
506
496
|
|
|
507
497
|
return (
|
|
508
498
|
<main>
|
|
509
|
-
<h1>
|
|
499
|
+
<h1>Sign in or create an account · {appName}</h1>
|
|
510
500
|
{tagline ? <p>{tagline}</p> : null}
|
|
511
501
|
{providers}
|
|
512
|
-
<form onSubmit={onSubmit} noValidate aria-label=
|
|
502
|
+
<form onSubmit={onSubmit} noValidate aria-label="Sign in or create an account" data-sw-auth="form">
|
|
513
503
|
<TextField id="auth-email" label="Email" type="email" name="email" autoComplete="email" inputMode="email" autoFocus data-sw-auth="email"
|
|
514
504
|
value={form.email} onChange={(event) => form.setEmail(event.target.value)} />
|
|
515
505
|
<TextField id="auth-password" label="Password" type="password" name="password" data-sw-auth="password"
|
|
516
|
-
autoComplete=
|
|
517
|
-
|
|
518
|
-
hint={signUp ? \`At least \${form.passwordMinLength} characters.\` : undefined}
|
|
506
|
+
autoComplete="current-password"
|
|
507
|
+
hint={\`A new account needs at least \${form.passwordMinLength} characters.\`}
|
|
519
508
|
value={form.password} onChange={(event) => form.setPassword(event.target.value)} />
|
|
520
|
-
|
|
509
|
+
<p><a href="/forgot-password">Forgot password?</a></p>
|
|
521
510
|
{form.error ? <p role="alert" data-sw-auth="error">{form.error}</p> : null}
|
|
522
|
-
<Button type="submit" disabled={
|
|
523
|
-
|
|
524
|
-
|
|
511
|
+
<Button type="submit" disabled={form.pending !== null} pending={form.pending === 'sign-in'} data-sw-auth="sign-in">Sign in</Button>{' '}
|
|
512
|
+
<Button variant="secondary" disabled={form.pending !== null} pending={form.pending === 'sign-up'} data-sw-auth="sign-up"
|
|
513
|
+
onClick={() => void form.submit('sign-up')}>Create account</Button>
|
|
525
514
|
</form>
|
|
526
|
-
<p>
|
|
527
|
-
<button type="button" onClick={form.toggleMode} disabled={form.pending} data-sw-auth="mode">
|
|
528
|
-
{signUp ? 'Sign in' : 'Create an account'}
|
|
529
|
-
</button>
|
|
530
|
-
</p>
|
|
531
515
|
{children}
|
|
532
516
|
</main>
|
|
533
517
|
);
|
|
@@ -634,7 +618,8 @@ interface FieldChrome {
|
|
|
634
618
|
label: ReactNode;
|
|
635
619
|
hint?: ReactNode;
|
|
636
620
|
error?: string | null;
|
|
637
|
-
/** Shows "optional" next to the label. Required is the default and needs no mark
|
|
621
|
+
/** Shows "optional" next to the label. Required is the default and needs no mark;
|
|
622
|
+
* your onSubmit checks it and shows the error (the browser's check is off). */
|
|
638
623
|
optional?: boolean;
|
|
639
624
|
}
|
|
640
625
|
|
|
@@ -642,6 +627,14 @@ function describedBy(id: string, hint: ReactNode, error: string | null | undefin
|
|
|
642
627
|
return [hint ? \`\${id}-hint\` : null, error ? \`\${id}-error\` : null].filter(Boolean).join(' ') || undefined;
|
|
643
628
|
}
|
|
644
629
|
|
|
630
|
+
/** Kit controls turn off the browser's own form checks (required, type="email",
|
|
631
|
+
* pattern, min/max, minLength) on the form they sit in, so every submit reaches
|
|
632
|
+
* your onSubmit and your app's own error message is what people and tests see.
|
|
633
|
+
* To keep the browser's checks on one form, give it data-browser-checks. */
|
|
634
|
+
function appValidated(control: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | null) {
|
|
635
|
+
if (control?.form && !control.form.hasAttribute('data-browser-checks')) control.form.noValidate = true;
|
|
636
|
+
}
|
|
637
|
+
|
|
645
638
|
/** The label/hint/error frame. Prefer TextField, SelectField and
|
|
646
639
|
* TextareaField; use Field directly for a control they don't cover. */
|
|
647
640
|
export function Field({ id, label, hint, error, optional, children }: FieldChrome & { children: ReactNode }) {
|
|
@@ -663,7 +656,7 @@ type TextFieldProps = FieldChrome & Omit<InputHTMLAttributes<HTMLInputElement>,
|
|
|
663
656
|
export function TextField({ id, label, hint, error, optional, className, ...input }: TextFieldProps) {
|
|
664
657
|
return (
|
|
665
658
|
<Field id={id} label={label} hint={hint} error={error} optional={optional}>
|
|
666
|
-
<input id={id} className={['control', className].filter(Boolean).join(' ')} aria-invalid={error ? true : undefined}
|
|
659
|
+
<input ref={appValidated} id={id} className={['control', className].filter(Boolean).join(' ')} aria-invalid={error ? true : undefined}
|
|
667
660
|
aria-describedby={describedBy(id, hint, error)} required={!optional && input.required !== false} {...input} />
|
|
668
661
|
</Field>
|
|
669
662
|
);
|
|
@@ -680,7 +673,7 @@ type SelectFieldProps = FieldChrome & Omit<SelectHTMLAttributes<HTMLSelectElemen
|
|
|
680
673
|
export function SelectField({ id, label, hint, error, optional, options, placeholder, className, ...select }: SelectFieldProps) {
|
|
681
674
|
return (
|
|
682
675
|
<Field id={id} label={label} hint={hint} error={error} optional={optional}>
|
|
683
|
-
<select id={id} className={['control', className].filter(Boolean).join(' ')} aria-invalid={error ? true : undefined}
|
|
676
|
+
<select ref={appValidated} id={id} className={['control', className].filter(Boolean).join(' ')} aria-invalid={error ? true : undefined}
|
|
684
677
|
aria-describedby={describedBy(id, hint, error)} {...select}>
|
|
685
678
|
{placeholder ? <option value="" disabled>{placeholder}</option> : null}
|
|
686
679
|
{options.map((option) => <option key={option.value} value={option.value} disabled={option.disabled}>{option.label}</option>)}
|
|
@@ -694,7 +687,7 @@ type TextareaFieldProps = FieldChrome & Omit<TextareaHTMLAttributes<HTMLTextArea
|
|
|
694
687
|
export function TextareaField({ id, label, hint, error, optional, className, ...textarea }: TextareaFieldProps) {
|
|
695
688
|
return (
|
|
696
689
|
<Field id={id} label={label} hint={hint} error={error} optional={optional}>
|
|
697
|
-
<textarea id={id} className={['control', className].filter(Boolean).join(' ')} aria-invalid={error ? true : undefined}
|
|
690
|
+
<textarea ref={appValidated} id={id} className={['control', className].filter(Boolean).join(' ')} aria-invalid={error ? true : undefined}
|
|
698
691
|
aria-describedby={describedBy(id, hint, error)} required={!optional && textarea.required !== false} {...textarea} />
|
|
699
692
|
</Field>
|
|
700
693
|
);
|
|
@@ -704,7 +697,7 @@ export function TextareaField({ id, label, hint, error, optional, className, ...
|
|
|
704
697
|
export function CheckboxField({ id, label, hint, className, ...input }: { id: string; label: ReactNode; hint?: ReactNode } & Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'type'>) {
|
|
705
698
|
return (
|
|
706
699
|
<div className="field field--inline">
|
|
707
|
-
<input id={id} type="checkbox" className={className} aria-describedby={hint ? \`\${id}-hint\` : undefined} {...input} />
|
|
700
|
+
<input ref={appValidated} id={id} type="checkbox" className={className} aria-describedby={hint ? \`\${id}-hint\` : undefined} {...input} />
|
|
708
701
|
<label className="field__label" htmlFor={id}><span>{label}</span></label>
|
|
709
702
|
{hint ? <p id={\`\${id}-hint\`} className="field__hint" style={{ gridColumn: 2 }}>{hint}</p> : null}
|
|
710
703
|
</div>
|
|
@@ -1127,7 +1120,8 @@ interface FieldChrome {
|
|
|
1127
1120
|
label: ReactNode;
|
|
1128
1121
|
hint?: ReactNode;
|
|
1129
1122
|
error?: string | null;
|
|
1130
|
-
/** Shows "optional" next to the label. Required is the default and needs no mark
|
|
1123
|
+
/** Shows "optional" next to the label. Required is the default and needs no mark;
|
|
1124
|
+
* your onSubmit checks it and shows the error (the browser's check is off). */
|
|
1131
1125
|
optional?: boolean;
|
|
1132
1126
|
}
|
|
1133
1127
|
|
|
@@ -1135,6 +1129,14 @@ function describedBy(id: string, hint: ReactNode, error: string | null | undefin
|
|
|
1135
1129
|
return [hint ? \`\${id}-hint\` : null, error ? \`\${id}-error\` : null].filter(Boolean).join(' ') || undefined;
|
|
1136
1130
|
}
|
|
1137
1131
|
|
|
1132
|
+
/** Kit controls turn off the browser's own form checks (required, type="email",
|
|
1133
|
+
* pattern, min/max, minLength) on the form they sit in, so every submit reaches
|
|
1134
|
+
* your onSubmit and your app's own error message is what people and tests see.
|
|
1135
|
+
* To keep the browser's checks on one form, give it data-browser-checks. */
|
|
1136
|
+
function appValidated(control: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | null) {
|
|
1137
|
+
if (control?.form && !control.form.hasAttribute('data-browser-checks')) control.form.noValidate = true;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1138
1140
|
/** The label/hint/error frame. Prefer TextField, SelectField and
|
|
1139
1141
|
* TextareaField; use Field directly for a control they don't cover. */
|
|
1140
1142
|
export function Field({ id, label, hint, error, optional, children }: FieldChrome & { children: ReactNode }) {
|
|
@@ -1153,7 +1155,7 @@ type TextFieldProps = FieldChrome & Omit<InputHTMLAttributes<HTMLInputElement>,
|
|
|
1153
1155
|
export function TextField({ id, label, hint, error, optional, className, ...input }: TextFieldProps) {
|
|
1154
1156
|
return (
|
|
1155
1157
|
<Field id={id} label={label} hint={hint} error={error} optional={optional}>
|
|
1156
|
-
<input id={id} className={className} aria-invalid={error ? true : undefined}
|
|
1158
|
+
<input ref={appValidated} id={id} className={className} aria-invalid={error ? true : undefined}
|
|
1157
1159
|
aria-describedby={describedBy(id, hint, error)} required={!optional && input.required !== false} {...input} />
|
|
1158
1160
|
</Field>
|
|
1159
1161
|
);
|
|
@@ -1170,7 +1172,7 @@ type SelectFieldProps = FieldChrome & Omit<SelectHTMLAttributes<HTMLSelectElemen
|
|
|
1170
1172
|
export function SelectField({ id, label, hint, error, optional, options, placeholder, className, ...select }: SelectFieldProps) {
|
|
1171
1173
|
return (
|
|
1172
1174
|
<Field id={id} label={label} hint={hint} error={error} optional={optional}>
|
|
1173
|
-
<select id={id} className={className} aria-invalid={error ? true : undefined}
|
|
1175
|
+
<select ref={appValidated} id={id} className={className} aria-invalid={error ? true : undefined}
|
|
1174
1176
|
aria-describedby={describedBy(id, hint, error)} {...select}>
|
|
1175
1177
|
{placeholder ? <option value="" disabled>{placeholder}</option> : null}
|
|
1176
1178
|
{options.map((option) => <option key={option.value} value={option.value} disabled={option.disabled}>{option.label}</option>)}
|
|
@@ -1184,7 +1186,7 @@ type TextareaFieldProps = FieldChrome & Omit<TextareaHTMLAttributes<HTMLTextArea
|
|
|
1184
1186
|
export function TextareaField({ id, label, hint, error, optional, className, ...textarea }: TextareaFieldProps) {
|
|
1185
1187
|
return (
|
|
1186
1188
|
<Field id={id} label={label} hint={hint} error={error} optional={optional}>
|
|
1187
|
-
<textarea id={id} className={className} aria-invalid={error ? true : undefined}
|
|
1189
|
+
<textarea ref={appValidated} id={id} className={className} aria-invalid={error ? true : undefined}
|
|
1188
1190
|
aria-describedby={describedBy(id, hint, error)} required={!optional && textarea.required !== false} {...textarea} />
|
|
1189
1191
|
</Field>
|
|
1190
1192
|
);
|
|
@@ -1194,7 +1196,7 @@ export function TextareaField({ id, label, hint, error, optional, className, ...
|
|
|
1194
1196
|
export function CheckboxField({ id, label, hint, className, ...input }: { id: string; label: ReactNode; hint?: ReactNode } & Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'type'>) {
|
|
1195
1197
|
return (
|
|
1196
1198
|
<p>
|
|
1197
|
-
<input id={id} type="checkbox" className={className} aria-describedby={hint ? \`\${id}-hint\` : undefined} {...input} />{' '}
|
|
1199
|
+
<input ref={appValidated} id={id} type="checkbox" className={className} aria-describedby={hint ? \`\${id}-hint\` : undefined} {...input} />{' '}
|
|
1198
1200
|
<label htmlFor={id}>{label}</label>
|
|
1199
1201
|
{hint ? <><br /><small id={\`\${id}-hint\`}>{hint}</small></> : null}
|
|
1200
1202
|
</p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-ui-kit.js","sourceRoot":"","sources":["../../src/lib/init-ui-kit.ts"],"names":[],"mappings":"AACA,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,2EAA2E;AAE3E,4EAA4E;AAE5E,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;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,EAAE,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BrC,EAAE;IACD,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDtC,EAAE;IACD,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BrC,EAAE;IACD,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCvC,EAAE;IACD,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCvC,EAAE;IACD,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;CAqBvC,EAAE;IACD,EAAE,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE;;;;;CAKzC,EAAE;IACD,EAAE,IAAI,EAAE,4BAA4B,EAAE,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;CAqBhD,EAAE;IACD,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE;;;;;;;;;;;;;;CAcrC,EAAE;CACF,CAAC"}
|
package/dist/lib/scaffold.d.ts
CHANGED
|
@@ -20,8 +20,8 @@ export declare const SCAFFOLD_GITIGNORE_FILENAME = ".gitignore";
|
|
|
20
20
|
* The starters' .gitignore ( item 8). Deploys skip dotfiles, so a
|
|
21
21
|
* pulled app never brings one down, and `somewhere typecheck`/`dev` then leave
|
|
22
22
|
* the generated schema declarations (thousands of lines under src/) untracked
|
|
23
|
-
* in git.
|
|
24
|
-
*
|
|
23
|
+
* in git. The `somewhere init` starters ship this same text (they call this
|
|
24
|
+
* function); a test pins them.
|
|
25
25
|
*/
|
|
26
26
|
export declare function buildScaffoldGitignore(): string;
|
|
27
27
|
/**
|
package/dist/lib/scaffold.js
CHANGED
|
@@ -21,11 +21,13 @@ export const SCAFFOLD_GITIGNORE_FILENAME = '.gitignore';
|
|
|
21
21
|
* The starters' .gitignore ( item 8). Deploys skip dotfiles, so a
|
|
22
22
|
* pulled app never brings one down, and `somewhere typecheck`/`dev` then leave
|
|
23
23
|
* the generated schema declarations (thousands of lines under src/) untracked
|
|
24
|
-
* in git.
|
|
25
|
-
*
|
|
24
|
+
* in git. The `somewhere init` starters ship this same text (they call this
|
|
25
|
+
* function); a test pins them.
|
|
26
26
|
*/
|
|
27
27
|
export function buildScaffoldGitignore() {
|
|
28
|
-
return 'node_modules\ndist\nbuild\n.env\n# Generated from db/schema.ts by somewhere typecheck, dev and deploy.\n__somewhere_data.d.ts\n__somewhere_files.d.ts\n'
|
|
28
|
+
return 'node_modules\ndist\nbuild\n.env\n# Generated from db/schema.ts by somewhere typecheck, dev and deploy.\n__somewhere_data.d.ts\n__somewhere_files.d.ts\n'
|
|
29
|
+
// This folder's own CLI state: its deploy base, test results and test accounts. Never shared.
|
|
30
|
+
+ '.somewhere/\n';
|
|
29
31
|
}
|
|
30
32
|
/**
|
|
31
33
|
* The lenient tsconfig that catches undefined symbols (TS2304) without
|
package/dist/lib/scaffold.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../src/lib/scaffold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAEtE,MAAM,CAAC,MAAM,0BAA0B,GAAG,eAAe,CAAC;AAC1D,MAAM,CAAC,MAAM,yBAAyB,GAAG,cAAc,CAAC;AACxD,MAAM,CAAC,MAAM,2BAA2B,GAAG,YAAY,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,yJAAyJ,CAAC;
|
|
1
|
+
{"version":3,"file":"scaffold.js","sourceRoot":"","s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,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface ScriptResult {
|
|
2
|
+
script: string;
|
|
3
|
+
ok: boolean;
|
|
4
|
+
exitCode: number;
|
|
5
|
+
ms: number;
|
|
6
|
+
reason: string | null;
|
|
7
|
+
}
|
|
8
|
+
/** Whether the project has any Playwright spec under tests/. */
|
|
9
|
+
export declare function hasSpecFiles(root: string): boolean;
|
|
10
|
+
export declare const isScript: (file: string) => boolean;
|
|
11
|
+
/** The scripts to run: the named ones, or every tests/*.mjs and tests/*.cjs, in name order. */
|
|
12
|
+
export declare function listScripts(root: string, files: string[]): string[];
|
|
13
|
+
/** The line that says why a script failed: its first "FAIL ..." line, else its last error line, else the last line. */
|
|
14
|
+
export declare function failureReason(output: string): string | null;
|
|
15
|
+
/** Run each script once, streaming its output, and return one result per script. */
|
|
16
|
+
export declare function runScripts(root: string, scripts: string[], extraArgs: string[], env?: NodeJS.ProcessEnv): Promise<ScriptResult[]>;
|
|
17
|
+
/** The summary: failures first, one line each, then what to do next. */
|
|
18
|
+
export declare function describeScriptResults(results: ScriptResult[]): string[];
|
|
19
|
+
/** The scripts that failed in the last scripts run here, for --failed. */
|
|
20
|
+
export declare function lastFailedScripts(root: string): string[];
|
|
21
|
+
export declare function recordScriptResults(root: string, results: ScriptResult[], rerunOnly: boolean): void;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { join, relative, resolve } from 'node:path';
|
|
4
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
5
|
+
import { cliConfigDir } from './config.js';
|
|
6
|
+
/** Whether the project has any Playwright spec under tests/. */
|
|
7
|
+
export function hasSpecFiles(root) {
|
|
8
|
+
const walk = (dir) => {
|
|
9
|
+
if (!existsSync(dir))
|
|
10
|
+
return false;
|
|
11
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
12
|
+
if (entry.name === 'node_modules' || entry.name.startsWith('.'))
|
|
13
|
+
continue;
|
|
14
|
+
const path = join(dir, entry.name);
|
|
15
|
+
if (entry.isDirectory() ? walk(path) : /\.spec\.ts$/.test(entry.name))
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
};
|
|
20
|
+
return walk(join(root, 'tests'));
|
|
21
|
+
}
|
|
22
|
+
export const isScript = (file) => /\.[cm]js$/.test(file);
|
|
23
|
+
/** The scripts to run: the named ones, or every tests/*.mjs and tests/*.cjs, in name order. */
|
|
24
|
+
export function listScripts(root, files) {
|
|
25
|
+
if (files.length)
|
|
26
|
+
return files.map((file) => relative(root, resolve(root, file)));
|
|
27
|
+
const dir = join(root, 'tests');
|
|
28
|
+
if (!existsSync(dir))
|
|
29
|
+
return [];
|
|
30
|
+
return readdirSync(dir).filter((name) => isScript(name) && statSync(join(dir, name)).isFile()).sort().map((name) => join('tests', name));
|
|
31
|
+
}
|
|
32
|
+
/** Playwright's own Chromium, which a script's plain chromium.launch() needs: used where it already is, otherwise
|
|
33
|
+
* installed once into the CLI cache. Returns the environment the scripts run with. */
|
|
34
|
+
function scriptBrowserEnv(root) {
|
|
35
|
+
const require = createRequire(join(root, 'package.json'));
|
|
36
|
+
let cli;
|
|
37
|
+
try {
|
|
38
|
+
cli = require.resolve('@playwright/test/cli');
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
throw new Error('Install project test dependencies: npm install -D @playwright/test @somewhere-cloud/cli');
|
|
42
|
+
}
|
|
43
|
+
const env = { ...process.env, PLAYWRIGHT_NO_COPY_PROMPT: '1' };
|
|
44
|
+
const probe = spawnSync(process.execPath, ['-e', 'require(process.argv[1]).chromium.launch().then(b => b.close()).then(() => process.exit(0), () => process.exit(3))', require.resolve('@playwright/test')], { env, stdio: 'ignore' });
|
|
45
|
+
if (probe.status === 0)
|
|
46
|
+
return env;
|
|
47
|
+
env.PLAYWRIGHT_BROWSERS_PATH ??= join(cliConfigDir(), 'cache', 'playwright');
|
|
48
|
+
process.stderr.write('Installing Playwright Chromium in the CLI cache (once).\n');
|
|
49
|
+
const install = spawnSync(process.execPath, [cli, 'install', 'chromium'], { stdio: 'inherit', env });
|
|
50
|
+
if (install.status !== 0)
|
|
51
|
+
throw new Error('Playwright Chromium installation failed');
|
|
52
|
+
return env;
|
|
53
|
+
}
|
|
54
|
+
/** The line that says why a script failed: its first "FAIL ..." line, else its last error line, else the last line. */
|
|
55
|
+
export function failureReason(output) {
|
|
56
|
+
const lines = output.split(/\r?\n/).map((line) => line.trimEnd()).filter(Boolean);
|
|
57
|
+
const fail = lines.find((line) => /^(FAIL\b|✗|not ok\b)/.test(line.trimStart()));
|
|
58
|
+
if (fail)
|
|
59
|
+
return fail.trim().replace(/^(FAIL\b|✗|not ok\b)\s*/, '');
|
|
60
|
+
const error = [...lines].reverse().find((line) => /(Error|assert|Timeout|refused|ECONN)/i.test(line));
|
|
61
|
+
return (error ?? lines.at(-1) ?? null)?.trim().slice(0, 300) ?? null;
|
|
62
|
+
}
|
|
63
|
+
/** Run each script once, streaming its output, and return one result per script. */
|
|
64
|
+
export async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)) {
|
|
65
|
+
const results = [];
|
|
66
|
+
for (const script of scripts) {
|
|
67
|
+
if (!existsSync(join(root, script))) {
|
|
68
|
+
results.push({ script, ok: false, exitCode: 1, ms: 0, reason: 'no such file' });
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
process.stdout.write(`\n▶ ${script}\n`);
|
|
72
|
+
const started = performance.now();
|
|
73
|
+
let output = '';
|
|
74
|
+
const child = spawn(process.execPath, [script, ...extraArgs], { cwd: root, env, stdio: ['inherit', 'pipe', 'pipe'] });
|
|
75
|
+
const keep = (chunk, to) => { to.write(chunk); output = (output + chunk.toString('utf8')).slice(-20_000); };
|
|
76
|
+
child.stdout.on('data', (chunk) => keep(chunk, process.stdout));
|
|
77
|
+
child.stderr.on('data', (chunk) => keep(chunk, process.stderr));
|
|
78
|
+
const exitCode = await new Promise((done) => child.on('close', (code) => done(code ?? 1)));
|
|
79
|
+
results.push({ script, ok: exitCode === 0, exitCode, ms: Math.round(performance.now() - started), reason: exitCode === 0 ? null : failureReason(output) });
|
|
80
|
+
}
|
|
81
|
+
return results;
|
|
82
|
+
}
|
|
83
|
+
/** The summary: failures first, one line each, then what to do next. */
|
|
84
|
+
export function describeScriptResults(results) {
|
|
85
|
+
const failed = results.filter((result) => !result.ok);
|
|
86
|
+
const seconds = (ms) => `${(ms / 1000).toFixed(1)} s`;
|
|
87
|
+
const lines = [
|
|
88
|
+
...failed.map((result) => `FAIL ${result.script} (exit ${result.exitCode}, ${seconds(result.ms)}): ${result.reason ?? 'no output'}`),
|
|
89
|
+
...results.filter((result) => result.ok).map((result) => `PASS ${result.script} (${seconds(result.ms)})`),
|
|
90
|
+
];
|
|
91
|
+
if (!results.length)
|
|
92
|
+
return ['No tests found: add a Playwright script as tests/<name>.mjs or .cjs (somewhere init writes tests/app-check.mjs), then run somewhere test.'];
|
|
93
|
+
lines.push(failed.length
|
|
94
|
+
? `FAILED: ${failed.length} of ${results.length} script${results.length === 1 ? '' : 's'} failed. Fix what each FAIL line names, run somewhere deploy, then somewhere test --failed to rerun only the failed checks.`
|
|
95
|
+
: `PASSED: ${results.length} script${results.length === 1 ? '' : 's'}.`);
|
|
96
|
+
return lines;
|
|
97
|
+
}
|
|
98
|
+
const LAST = join('.somewhere', 'tests', 'scripts-last.json');
|
|
99
|
+
/** The scripts that failed in the last scripts run here, for --failed. */
|
|
100
|
+
export function lastFailedScripts(root) {
|
|
101
|
+
const path = join(root, LAST);
|
|
102
|
+
if (!existsSync(path))
|
|
103
|
+
return [];
|
|
104
|
+
try {
|
|
105
|
+
return (JSON.parse(readFileSync(path, 'utf8')).results ?? []).filter((r) => !r.ok).map((r) => r.script);
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export function recordScriptResults(root, results, rerunOnly) {
|
|
112
|
+
// A --failed run updates only the scripts it reran; every other script keeps its last result.
|
|
113
|
+
const previous = rerunOnly && existsSync(join(root, LAST)) ? (JSON.parse(readFileSync(join(root, LAST), 'utf8')).results ?? []) : [];
|
|
114
|
+
const merged = [...previous.filter((p) => !results.some((r) => r.script === p.script)), ...results];
|
|
115
|
+
mkdirSync(join(root, '.somewhere', 'tests'), { recursive: true });
|
|
116
|
+
writeFileSync(join(root, LAST), JSON.stringify({ finished: new Date().toISOString(), results: merged }, null, 2) + '\n');
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=test-scripts.js.map
|