All blocks
Form Wizard
Four-step cloud workspace onboarding wizard with a pinned horizontal stepper, per-step validation on advance, plan tier radio cards, live monthly cost estimate, optional skippable team setup, editable review cards, and local launch confirmation.
Built withAlertBadgeButtonCardCheckboxCheckbox GroupData ListFieldGridHeadingIconInputInput AddonNumber InputRadio CardRadio GroupSelectSeparatorStackStepsSwitchTextTextareaToast
Create workspace
harbor.cloudOrganization & workspace identity
Name your organization, claim a workspace URL, and create your first cloud project.
harbor.cloud/
harbor.cloud/meridian-labs is available.Creates your first repository link, deployment pipeline, and environment variables store.
Install
1npx stylexblocks add form-wizardSource
components/blocks/ui-sdk/form-wizard.tsx
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267import * as stylex from "@stylexjs/stylex";import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";import { Alert } from "#components/ui/ui-sdk/alert.tsx";import { Badge } from "#components/ui/ui-sdk/badge.tsx";import { Button } from "#components/ui/ui-sdk/button.tsx";import { Card } from "#components/ui/ui-sdk/card.tsx";import { Checkbox } from "#components/ui/ui-sdk/checkbox.tsx";import { CheckboxGroup } from "#components/ui/ui-sdk/checkbox-group.tsx";import { DataList } from "#components/ui/ui-sdk/data-list.tsx";import { Field } from "#components/ui/ui-sdk/field.tsx";import { Grid } from "#components/ui/ui-sdk/grid.tsx";import { Heading } from "#components/ui/ui-sdk/heading.tsx";import { Icon } from "#components/ui/ui-sdk/icon.tsx";import { InputGroup } from "#components/ui/ui-sdk/input-addon.tsx";import { Input } from "#components/ui/ui-sdk/input.tsx";import { NumberInput } from "#components/ui/ui-sdk/number-input.tsx";import { RadioCard } from "#components/ui/ui-sdk/radio-card.tsx";import { RadioGroup } from "#components/ui/ui-sdk/radio-group.tsx";import { Select } from "#components/ui/ui-sdk/select.tsx";import { Separator } from "#components/ui/ui-sdk/separator.tsx";import { HStack, VStack } from "#components/ui/ui-sdk/stack.tsx";import { Steps } from "#components/ui/ui-sdk/steps.tsx";import { Switch } from "#components/ui/ui-sdk/switch.tsx";import { Text } from "#components/ui/ui-sdk/text.tsx";import { Textarea } from "#components/ui/ui-sdk/textarea.tsx";import { Toast, Toaster } from "#components/ui/ui-sdk/toast.tsx";import { semanticColors } from "@stylexblocks/ui/semantic-tokens/colors.stylex.ts";import { accentPalette, greenPalette, redPalette,} from "@stylexblocks/ui/themes/palettes.ts";import { fonts } from "@stylexblocks/ui/tokens/fonts.stylex.ts";import { spacing } from "@stylexblocks/ui/tokens/spacing.stylex.ts";import type { StyleOverrideProps } from "#lib/recipe-props.ts";
// ── Inline SVG icons (zero external icon packages) ───────────────────────────
function CheckIcon() { return ( <Icon size="xs" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="m3.5 8.5 3 3 6-6.5" /> </Icon> );}
function AlertCircleIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <circle cx="10" cy="10" r="7.25" /> <path d="M10 6.75v3.75" /> <path d="M10 13.5v.1" /> </Icon> );}
function CheckCircleIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <circle cx="10" cy="10" r="7.25" /> <path d="m7 10.2 2 2 4-4.4" /> </Icon> );}
function RocketIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M11.5 13.5 6.5 8.5c1.5-3 4.7-5 8.75-5.25-.25 4.05-2.25 7.25-5.25 8.75Z" /> <path d="M6.5 8.5 3.75 9.75l2 2" /> <path d="M11.5 13.5 10.25 16.25l-2-2" /> <circle cx="12.25" cy="7.75" r="1.25" /> </Icon> );}
function ArrowLeftIcon() { return ( <Icon size="xs" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M12.5 8h-9" /> <path d="M7.25 4.25 3.5 8l3.75 3.75" /> </Icon> );}
function ArrowRightIcon() { return ( <Icon size="xs" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M3.5 8h9" /> <path d="M8.75 4.25 12.5 8l-3.75 3.75" /> </Icon> );}
// ── Types & domain configuration ─────────────────────────────────────────────
export type PlanTierId = "developer" | "team" | "scale";export type InviteRoleId = "maintainer" | "developer" | "observer";export type SecurityAddonId = "saml" | "siem" | "kms";
export interface FormWizardValues { organizationName: string; workspaceSlug: string; projectName: string; projectSummary: string; region: string; runtime: string; planId: PlanTierId; seats: number; inviteEmails: string; inviteRole: InviteRoleId; securityAddons: SecurityAddonId[]; requireMfa: boolean; sendInvitesNow: boolean; welcomeNote: string; acceptedTerms: boolean;}
export interface FormWizardCompletionPayload { workspaceId: string; workspaceUrl: string; monthlyTotal: number; invitedCount: number; values: FormWizardValues;}
export interface FormWizardProps extends StyleOverrideProps { /** Primary page heading shown in the pinned header. */ title?: string; /** Hostname prefix used for workspace URLs. */ workspaceDomain?: string; /** Optional initial values overriding the default onboarding preset. */ initialValues?: Partial<FormWizardValues>; /** Called once all steps validate and the user launches the workspace. */ onLaunch?: (payload: FormWizardCompletionPayload) => void; /** Called when the user activates the Cancel action in the header. */ onCancel?: () => void;}
interface StepDefinition { id: string; label: string; isOptional?: boolean;}
const STEPS: readonly StepDefinition[] = [ { id: "organization", label: "Organization" }, { id: "infrastructure", label: "Infrastructure" }, { id: "team", label: "Team & security", isOptional: true }, { id: "review", label: "Review" },];
const REGIONS = [ { value: "us-east-iad", label: "US East — Ashburn (iad1)" }, { value: "us-west-pdx", label: "US West — Portland (pdx1)" }, { value: "eu-central-fra", label: "EU Central — Frankfurt (fra1)" }, { value: "ap-northeast-hnd", label: "Asia Pacific — Tokyo (hnd1)" },] as const;
const RUNTIMES = [ { value: "node-22", label: "Node.js 22 LTS (Containers)" }, { value: "bun-1", label: "Bun 1.x (Edge & Workers)" }, { value: "python-313", label: "Python 3.13 (Async & ML)" }, { value: "go-124", label: "Go 1.24 (Static Binary)" },] as const;
const PLANS: ReadonlyArray<{ id: PlanTierId; label: string; pricePerSeat: number; seatLimit: number; description: string; highlight: string; recommended?: boolean;}> = [ { id: "developer", label: "Developer", pricePerSeat: 0, seatLimit: 3, description: "Personal projects, 2 environments, and community forums.", highlight: "Up to 3 seats · 100 GB egress", }, { id: "team", label: "Team", pricePerSeat: 29, seatLimit: 100, description: "Preview branches, zero-downtime rollouts, and email support.", highlight: "Up to 100 seats · 2 TB egress", recommended: true, }, { id: "scale", label: "Scale", pricePerSeat: 64, seatLimit: 1000, description: "Private VPC peering, 99.99% SLA, and 24/7 incident response.", highlight: "Up to 1,000 seats · Custom quotas", },];
const INVITE_ROLES: ReadonlyArray<{ value: InviteRoleId; label: string; description: string;}> = [ { value: "maintainer", label: "Maintainer", description: "Deploy services, manage environments, and configure billing.", }, { value: "developer", label: "Developer", description: "Push builds, inspect logs, and manage preview branches.", }, { value: "observer", label: "Observer", description: "Read-only access to deployments, metrics, and audit trails.", },];
const SECURITY_ADDONS: ReadonlyArray<{ id: SecurityAddonId; label: string; pricePerSeat: number; description: string;}> = [ { id: "saml", label: "SAML SSO & SCIM", pricePerSeat: 4, description: "Enforce identity provider sign-in via Okta, Entra ID, or Google.", }, { id: "siem", label: "SIEM audit streaming", pricePerSeat: 3, description: "Stream deployment and access logs to Datadog, Splunk, or S3.", }, { id: "kms", label: "Dedicated secrets KMS", pricePerSeat: 5, description: "Customer-managed encryption keys with automatic 90-day rotation.", },];
const DEFAULT_VALUES: FormWizardValues = { organizationName: "Meridian Labs", workspaceSlug: "meridian-labs", projectName: "Core API Gateway", projectSummary: "Edge-routed TypeScript APIs and background job workers.", region: "us-east-iad", runtime: "bun-1", planId: "team", seats: 6, inviteEmails: "nina.patel@meridianlabs.io\ndavid.chen@meridianlabs.io\nclaire.moreau@meridianlabs.io", inviteRole: "developer", securityAddons: ["siem"], requireMfa: true, sendInvitesNow: true, welcomeNote: "", acceptedTerms: false,};
const RESERVED_SLUGS = new Set([ "admin", "api", "billing", "console", "harbor", "status", "support",]);
const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;const SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;const NARROW_HOST_WIDTH = 640;
type ValidatableFieldKey = | "organizationName" | "workspaceSlug" | "projectName" | "seats" | "inviteEmails" | "acceptedTerms";
// ── Helpers ───────────────────────────────────────────────────────────────────
const money = (amount: number) => amount === 0 ? "$0" : `$${amount.toLocaleString("en-US")}`;
function slugify(value: string): string { return value .toLowerCase() .trim() .replace(/[^a-z0-9]+/g, "-") .replace(/^-+|-+$/g, "");}
function parseEmails(raw: string): string[] { return raw .split(/[\n,]/) .map((entry) => entry.trim()) .filter(Boolean);}
function buildWorkspaceId(slug: string): string { let hash = 0; for (let i = 0; i < slug.length; i += 1) { hash = (hash * 31 + slug.charCodeAt(i)) % 46656; } const suffix = hash.toString(36).padStart(4, "0").slice(-4); const prefix = (slug.replace(/[^a-z0-9]/g, "").slice(0, 3) || "hbr").toLowerCase(); return `ws_${prefix}_${suffix}`;}
// ── Styles ────────────────────────────────────────────────────────────────────
const styles = stylex.create({ root: { backgroundColor: semanticColors.bg, color: semanticColors.fg, fontFamily: fonts.body, minHeight: "100%", width: "100%", }, header: { backgroundColor: semanticColors.bg, borderBottomColor: semanticColors.border, borderBottomStyle: "solid", borderBottomWidth: "1px", position: "sticky", top: 0, width: "100%", zIndex: 10, }, headerInner: { marginInline: "auto", maxWidth: "46rem", paddingBlock: spacing._5, paddingInline: spacing._6, width: "100%", }, headerInnerNarrow: { paddingBlock: spacing._4, paddingInline: spacing._4, }, headingReset: { marginBlock: 0, }, stepItemLast: { flexBasis: "auto", flexGrow: 0, flexShrink: 0, }, stepIndicatorError: { backgroundColor: semanticColors.bgError, borderColor: semanticColors.borderError, borderStyle: "solid", borderWidth: "2px", color: semanticColors.fgError, }, stepTitleHidden: { display: "none", }, main: { flexGrow: 1, width: "100%", }, mainInner: { marginInline: "auto", maxWidth: "46rem", paddingBlock: spacing._8, paddingInline: spacing._6, width: "100%", }, mainInnerNarrow: { paddingBlock: spacing._6, paddingInline: spacing._4, }, fullWidth: { width: "100%", }, flexGrow: { flexGrow: 1, }, marginTopAuto: { marginTop: "auto", }, nowrap: { whiteSpace: "nowrap", }, breakWord: { wordBreak: "break-word", }, statusGood: { color: semanticColors.fgSuccess, }, planGridWide: { display: "grid", gap: spacing._3, gridTemplateColumns: "repeat(3, minmax(0, 1fr))", width: "100%", }, planGridNarrow: { display: "flex", flexDirection: "column", gap: spacing._3, width: "100%", }, planCardItem: { height: "100%", }, planCardControl: { alignItems: "flex-start", height: "100%", width: "100%", }, planCardContent: { gap: spacing._2, height: "100%", width: "100%", }, seatsInputRoot: { maxWidth: "12rem", }, estimateCard: { backgroundColor: semanticColors.bgMuted, }, optionItemRow: { alignItems: "flex-start", display: "flex", gap: spacing._2_5, }, optionControlOffset: { marginTop: spacing._0_5, }, switchRow: { alignItems: "center", display: "flex", gap: spacing._4, justifyContent: "space-between", width: "100%", }, issuesList: { marginTop: spacing._1_5, }, issueActionWrap: { marginTop: spacing._2, }, reviewCardHeader: { alignItems: "center", borderBottomColor: semanticColors.border, borderBottomStyle: "solid", borderBottomWidth: "1px", display: "flex", flexDirection: "row", gap: spacing._3, justifyContent: "space-between", paddingBlock: spacing._3, paddingInline: spacing._4, }, reviewCardBody: { paddingBlock: spacing._4, paddingInline: spacing._4, }, reviewDataLabel: { flexShrink: 0, minWidth: "10.5rem", }, reviewDataLabelNarrow: { minWidth: 0, }, termsRow: { alignItems: "flex-start", width: "100%", }, footer: { backgroundColor: semanticColors.bg, borderTopColor: semanticColors.border, borderTopStyle: "solid", borderTopWidth: "1px", bottom: 0, marginTop: "auto", position: "sticky", width: "100%", zIndex: 10, }, footerInner: { marginInline: "auto", maxWidth: "46rem", paddingBlock: spacing._4, paddingInline: spacing._6, width: "100%", }, footerInnerNarrow: { paddingInline: spacing._4, }, footerLeftZone: { flexBasis: 0, flexGrow: 1, minWidth: "4.5rem", }, footerRightZone: { flexBasis: 0, flexGrow: 1, minWidth: "fit-content", },});
// ── Component ─────────────────────────────────────────────────────────────────
/** * FormWizard — four-step workspace and cloud project onboarding wizard with a * pinned header stepper, per-step validation on advance, optional skippable * team step, live monthly cost readout, editable review summary, and local * launch confirmation state. */export function FormWizard({ title = "Create workspace", workspaceDomain = "harbor.cloud", initialValues, onLaunch, onCancel, palette, style,}: FormWizardProps) { const mergedInitial = useMemo<FormWizardValues>( () => ({ ...DEFAULT_VALUES, ...initialValues, securityAddons: initialValues?.securityAddons ? [...initialValues.securityAddons] : [...DEFAULT_VALUES.securityAddons], }), [initialValues], );
const queue = useMemo(() => Toast.createToaster(), []); const slugInputId = useId(); const planGroupLabelId = useId(); const roleGroupLabelId = useId(); const addonsGroupLabelId = useId();
// Responsive container measurement so narrow previews collapse gracefully. const [isNarrow, setIsNarrow] = useState(false); const hostObserverRef = useRef<ResizeObserver | null>(null); const attachHost = useCallback((node: HTMLDivElement | null) => { hostObserverRef.current?.disconnect(); hostObserverRef.current = null; if (!node) return; setIsNarrow(node.getBoundingClientRect().width < NARROW_HOST_WIDTH); if (typeof ResizeObserver === "undefined") return; const observer = new ResizeObserver((entries) => { const width = entries[0]?.contentRect.width; if (typeof width === "number") { setIsNarrow(width < NARROW_HOST_WIDTH); } }); observer.observe(node); hostObserverRef.current = observer; }, []);
// Wizard flow state const [step, setStep] = useState(0); const [attempted, setAttempted] = useState<ReadonlySet<number>>(() => new Set()); const [isLaunched, setIsLaunched] = useState(false); const [launchedWorkspaceId, setLaunchedWorkspaceId] = useState<string | null>(null); const [slugTouched, setSlugTouched] = useState( Boolean(initialValues?.workspaceSlug), );
// Form field state const [organizationName, setOrganizationName] = useState( mergedInitial.organizationName, ); const [workspaceSlug, setWorkspaceSlug] = useState(mergedInitial.workspaceSlug); const [projectName, setProjectName] = useState(mergedInitial.projectName); const [projectSummary, setProjectSummary] = useState(mergedInitial.projectSummary);
const [region, setRegion] = useState(mergedInitial.region); const [runtime, setRuntime] = useState(mergedInitial.runtime); const [planId, setPlanId] = useState<PlanTierId>(mergedInitial.planId); const [seats, setSeats] = useState(mergedInitial.seats);
const [inviteEmails, setInviteEmails] = useState(mergedInitial.inviteEmails); const [inviteRole, setInviteRole] = useState<InviteRoleId>(mergedInitial.inviteRole); const [securityAddons, setSecurityAddons] = useState<SecurityAddonId[]>( mergedInitial.securityAddons, ); const [requireMfa, setRequireMfa] = useState(mergedInitial.requireMfa); const [sendInvitesNow, setSendInvitesNow] = useState(mergedInitial.sendInvitesNow); const [welcomeNote, setWelcomeNote] = useState(mergedInitial.welcomeNote);
const [acceptedTerms, setAcceptedTerms] = useState(mergedInitial.acceptedTerms);
// Focus targets for every validated field, keyed by the same names errorsByStep uses. const organizationNameRef = useRef<HTMLInputElement>(null); const workspaceSlugRef = useRef<HTMLInputElement>(null); const projectNameRef = useRef<HTMLInputElement>(null); const seatsRef = useRef<HTMLInputElement>(null); const inviteEmailsRef = useRef<HTMLTextAreaElement>(null); const acceptedTermsRef = useRef<HTMLButtonElement>(null); const pendingFocusFieldRef = useRef<ValidatableFieldKey | null>(null);
const focusField = useCallback((fieldKey: ValidatableFieldKey) => { const targetMap: Record<ValidatableFieldKey, HTMLElement | null> = { organizationName: organizationNameRef.current, workspaceSlug: workspaceSlugRef.current, projectName: projectNameRef.current, seats: seatsRef.current, inviteEmails: inviteEmailsRef.current, acceptedTerms: acceptedTermsRef.current, }; const element = targetMap[fieldKey]; if (element) { element.focus(); element.scrollIntoView({ block: "center", behavior: "smooth" }); } }, []);
// Derived data & pricing const emails = useMemo(() => parseEmails(inviteEmails), [inviteEmails]); const invalidEmails = useMemo( () => emails.filter((address) => !EMAIL_PATTERN.test(address)), [emails], ); const selectedPlan = useMemo( () => PLANS.find((tier) => tier.id === planId) ?? PLANS[1], [planId], ); const selectedRegion = useMemo( () => REGIONS.find((item) => item.value === region) ?? REGIONS[0], [region], ); const selectedRuntime = useMemo( () => RUNTIMES.find((item) => item.value === runtime) ?? RUNTIMES[0], [runtime], ); const selectedRole = useMemo( () => INVITE_ROLES.find((item) => item.value === inviteRole) ?? INVITE_ROLES[1], [inviteRole], ); const selectedAddonObjects = useMemo( () => SECURITY_ADDONS.filter((addon) => securityAddons.includes(addon.id)), [securityAddons], ); const addonCostPerSeat = useMemo( () => selectedAddonObjects.reduce((sum, addon) => sum + addon.pricePerSeat, 0), [selectedAddonObjects], ); const effectiveSeats = Number.isFinite(seats) && seats > 0 ? seats : 0; const monthlyTotal = (selectedPlan.pricePerSeat + addonCostPerSeat) * effectiveSeats;
// Single source of truth for per-step validation rules. const errorsByStep = useMemo< Array<Partial<Record<ValidatableFieldKey, string>>> >(() => { const normalizedSlug = workspaceSlug.trim();
const step0: Partial<Record<ValidatableFieldKey, string>> = {}; if (!organizationName.trim()) { step0.organizationName = "Enter an organization name."; } if (!normalizedSlug) { step0.workspaceSlug = "Enter a workspace URL slug."; } else if (!SLUG_PATTERN.test(normalizedSlug)) { step0.workspaceSlug = "Use lowercase letters, numbers, and hyphens, starting and ending with a letter or number."; } else if (RESERVED_SLUGS.has(normalizedSlug)) { step0.workspaceSlug = `${workspaceDomain}/${normalizedSlug} is reserved or already taken.`; } if (!projectName.trim()) { step0.projectName = "Enter an initial project name."; }
const step1: Partial<Record<ValidatableFieldKey, string>> = {}; if (!Number.isFinite(seats) || seats < 1) { step1.seats = "A workspace requires at least 1 seat."; } else if (seats > selectedPlan.seatLimit) { step1.seats = `${selectedPlan.label} supports up to ${selectedPlan.seatLimit} seats. Choose a larger tier or reduce seats.`; } else if (seats < emails.length + 1) { step1.seats = `You are inviting ${emails.length} ${ emails.length === 1 ? "teammate" : "teammates" } plus yourself, so you need at least ${emails.length + 1} seats.`; }
const step2: Partial<Record<ValidatableFieldKey, string>> = {}; if (invalidEmails.length > 0) { step2.inviteEmails = `Invalid email address: ${invalidEmails.join(", ")}`; }
const step3: Partial<Record<ValidatableFieldKey, string>> = {}; if (!acceptedTerms) { step3.acceptedTerms = "Accept the Cloud Services Agreement to launch."; }
return [step0, step1, step2, step3]; }, [ organizationName, workspaceSlug, workspaceDomain, projectName, seats, selectedPlan.seatLimit, selectedPlan.label, emails.length, invalidEmails, acceptedTerms, ]);
const shownErrors = useCallback( (index: number) => (attempted.has(index) ? errorsByStep[index] : {}), [attempted, errorsByStep], );
const currentErrors = shownErrors(step); const isLastStep = step === STEPS.length - 1;
// Earlier steps with unresolved validation errors — surfaced on Review so // nothing hides behind another panel before Launch. const outstandingSteps = useMemo( () => STEPS.map((definition, index) => ({ ...definition, index, issues: Object.values(errorsByStep[index]).filter( (message): message is string => Boolean(message), ), })).filter((entry) => entry.index !== step && entry.issues.length > 0), [errorsByStep, step], );
// Apply deferred focus after step transitions render the target field. useEffect(() => { const fieldKey = pendingFocusFieldRef.current; if (!fieldKey) return; pendingFocusFieldRef.current = null; focusField(fieldKey); }, [step, focusField]);
const markAttempted = useCallback((index: number) => { setAttempted((prev) => { if (prev.has(index)) return prev; const next = new Set(prev); next.add(index); return next; }); }, []);
const handleOrganizationChange = (nextValue: string) => { setOrganizationName(nextValue); if (!slugTouched) { setWorkspaceSlug(slugify(nextValue)); } };
const handleSlugChange = (nextValue: string) => { setSlugTouched(true); setWorkspaceSlug(nextValue.toLowerCase()); };
const goToStep = (nextIndex: number) => { if (isLaunched) return; if (nextIndex > step) { markAttempted(step); } setStep(nextIndex); };
const goNext = () => { markAttempted(step);
const stepErrorKeys = Object.keys( errorsByStep[step], ) as ValidatableFieldKey[]; if (stepErrorKeys.length > 0) { focusField(stepErrorKeys[0]); return; }
if (isLastStep) { const firstBrokenStep = errorsByStep.findIndex( (stepErrors) => Object.keys(stepErrors).length > 0, ); if (firstBrokenStep !== -1) { const brokenKeys = Object.keys( errorsByStep[firstBrokenStep], ) as ValidatableFieldKey[]; markAttempted(firstBrokenStep); pendingFocusFieldRef.current = brokenKeys[0] ?? null; setStep(firstBrokenStep); return; }
const normalizedSlug = workspaceSlug.trim(); const workspaceId = buildWorkspaceId(normalizedSlug); const workspaceUrl = `https://${workspaceDomain}/${normalizedSlug}`; const payload: FormWizardCompletionPayload = { workspaceId, workspaceUrl, monthlyTotal, invitedCount: emails.length, values: { organizationName: organizationName.trim(), workspaceSlug: normalizedSlug, projectName: projectName.trim(), projectSummary: projectSummary.trim(), region, runtime, planId, seats, inviteEmails, inviteRole, securityAddons, requireMfa, sendInvitesNow, welcomeNote: welcomeNote.trim(), acceptedTerms, }, };
setLaunchedWorkspaceId(workspaceId); setIsLaunched(true); onLaunch?.(payload); queue.success("Workspace launched", { description: `${organizationName.trim()} is ready at ${workspaceDomain}/${normalizedSlug}.`, }); return; }
setStep((current) => Math.min(STEPS.length - 1, current + 1)); };
// Skip declines the optional Team step outright: clear any partial input and // advance without leaving hidden validation errors behind. const goSkip = () => { setInviteEmails(""); setWelcomeNote(""); setStep((current) => Math.min(STEPS.length - 1, current + 1)); };
const handleCancel = () => { onCancel?.(); queue.info("Onboarding cancelled", { description: "No workspace was provisioned. Draft state remains local.", }); };
const handleResetWizard = () => { setIsLaunched(false); setLaunchedWorkspaceId(null); setStep(0); setAttempted(new Set()); setSlugTouched(Boolean(initialValues?.workspaceSlug)); setOrganizationName(mergedInitial.organizationName); setWorkspaceSlug(mergedInitial.workspaceSlug); setProjectName(mergedInitial.projectName); setProjectSummary(mergedInitial.projectSummary); setRegion(mergedInitial.region); setRuntime(mergedInitial.runtime); setPlanId(mergedInitial.planId); setSeats(mergedInitial.seats); setInviteEmails(mergedInitial.inviteEmails); setInviteRole(mergedInitial.inviteRole); setSecurityAddons([...mergedInitial.securityAddons]); setRequireMfa(mergedInitial.requireMfa); setSendInvitesNow(mergedInitial.sendInvitesNow); setWelcomeNote(mergedInitial.welcomeNote); setAcceptedTerms(false); };
const normalizedSlug = workspaceSlug.trim(); const slugIsValid = normalizedSlug.length > 0 && SLUG_PATTERN.test(normalizedSlug) && !RESERVED_SLUGS.has(normalizedSlug);
return ( <VStack ref={attachHost} gap="0" palette={palette} style={[styles.root, style]} > {/* Pinned header + horizontal stepper */} <header {...stylex.props(styles.header)}> <VStack gap={isNarrow ? "3" : "4"} style={[styles.headerInner, isNarrow && styles.headerInnerNarrow]} > <HStack justify="between" wrap="wrap" gap="3"> <HStack wrap="wrap" gap="2.5"> <Heading render={<h1 />} size="2xl" style={styles.headingReset}> {isLaunched ? "Workspace ready" : title} </Heading> <Badge variant="subtle" size="sm" palette={isLaunched ? greenPalette : accentPalette} > {isLaunched ? "Provisioned" : workspaceDomain} </Badge> </HStack> {!isLaunched ? ( <Button variant="ghost" size="sm" onClick={handleCancel}> Cancel </Button> ) : null} </HStack>
{!isLaunched ? ( <Steps.Root count={STEPS.length} step={step} onStepChange={({ step: next }) => goToStep(next)} size="sm" orientation="horizontal" palette={accentPalette} aria-label="Workspace onboarding progress" > <Steps.List> {STEPS.map((definition, index) => { const hasError = Object.keys(shownErrors(index)).length > 0; const isComplete = index < step && !hasError; const isLast = index === STEPS.length - 1; return ( <Steps.Item key={definition.id} index={index} style={isLast ? styles.stepItemLast : undefined} > <Steps.Trigger aria-label={definition.label}> <Steps.Indicator palette={hasError ? redPalette : undefined} style={hasError ? styles.stepIndicatorError : undefined} > {hasError ? ( <AlertCircleIcon /> ) : isComplete ? ( <CheckIcon /> ) : ( index + 1 )} </Steps.Indicator> <Steps.Title style={ isNarrow && index !== step ? styles.stepTitleHidden : undefined } > <HStack render={<span />} align="baseline" gap="1"> <span>{definition.label}</span> {definition.isOptional && !isNarrow ? ( <Text render={<span />} size="xs" tone="subtle" weight="normal" > (Optional) </Text> ) : null} </HStack> </Steps.Title> </Steps.Trigger> <Steps.Separator /> </Steps.Item> ); })} </Steps.List> </Steps.Root> ) : null} </VStack> </header>
{/* Active step panel (or launch confirmation) */} <VStack render={<main />} gap="0" style={styles.main}> <VStack gap="6" style={[styles.mainInner, isNarrow && styles.mainInnerNarrow]} > {isLaunched ? ( <VStack render={<section aria-label="Workspace launch confirmation" />} gap="6" > <Alert.Root status="success" variant="subtle" size="md" palette={greenPalette} > <Alert.Indicator> <CheckCircleIcon /> </Alert.Indicator> <Alert.Content> <Alert.Title> {organizationName.trim()} provisioned in {selectedRegion.label} </Alert.Title> <Alert.Description> Initial project “{projectName.trim()}” is initialized on {selectedRuntime.label}. This demo records launch state locally without billing or external network calls. </Alert.Description> </Alert.Content> </Alert.Root>
<VStack gap="1.5"> <Heading render={<h2 />} size="xl" style={styles.headingReset}> Your cloud workspace is live </Heading> <Text variant="muted" size="sm"> Review the provisioned workspace details below, jump into the dashboard, or start a fresh onboarding run. </Text> </VStack>
<Card.Root variant="outline" size="md"> <Card.Body style={styles.reviewCardBody}> <DataList.Root orientation={isNarrow ? "vertical" : "horizontal"} variant="subtle" size="md" > <DataList.Item> <DataList.ItemLabel style={ isNarrow ? styles.reviewDataLabelNarrow : styles.reviewDataLabel } > Workspace ID </DataList.ItemLabel> <DataList.ItemValue> <Text render={<span />} variant="mono" size="xs" style={styles.breakWord} > {launchedWorkspaceId} </Text> </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel style={ isNarrow ? styles.reviewDataLabelNarrow : styles.reviewDataLabel } > Workspace URL </DataList.ItemLabel> <DataList.ItemValue> <Text render={<span />} variant="mono" size="xs" style={styles.breakWord} > https://{workspaceDomain}/{normalizedSlug} </Text> </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel style={ isNarrow ? styles.reviewDataLabelNarrow : styles.reviewDataLabel } > Initial project </DataList.ItemLabel> <DataList.ItemValue>{projectName.trim()}</DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel style={ isNarrow ? styles.reviewDataLabelNarrow : styles.reviewDataLabel } > Region & runtime </DataList.ItemLabel> <DataList.ItemValue> {selectedRegion.label} · {selectedRuntime.label} </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel style={ isNarrow ? styles.reviewDataLabelNarrow : styles.reviewDataLabel } > Plan & capacity </DataList.ItemLabel> <DataList.ItemValue> {selectedPlan.label} · {seats}{" "} {seats === 1 ? "seat" : "seats"} ({money(monthlyTotal)}/mo) </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel style={ isNarrow ? styles.reviewDataLabelNarrow : styles.reviewDataLabel } > Team & security </DataList.ItemLabel> <DataList.ItemValue> {emails.length === 0 ? "Owner only" : `${emails.length} ${ emails.length === 1 ? "invite" : "invites" } (${selectedRole.label}${ sendInvitesNow ? ", queued now" : ", draft" })`} {requireMfa ? " · Passkey / 2FA enforced" : ""} </DataList.ItemValue> </DataList.Item> </DataList.Root> </Card.Body> </Card.Root>
<HStack wrap="wrap" gap="3"> <Button variant="solid" palette={accentPalette} onClick={() => queue.info("Opening workspace dashboard", { description: `Routing to https://${workspaceDomain}/${normalizedSlug}`, }) } > <RocketIcon /> Open workspace dashboard </Button> <Button variant="surface" onClick={handleResetWizard}> Create another workspace </Button> </HStack> </VStack> ) : null}
{/* Step 0 — Organization & workspace slug */} {!isLaunched && step === 0 ? ( <VStack render={<section aria-label="Organization details" />} gap="6" > <VStack gap="1.5"> <Heading render={<h2 />} size="xl" style={styles.headingReset}> Organization & workspace identity </Heading> <Text variant="muted" size="sm"> Name your organization, claim a workspace URL, and create your first cloud project. </Text> </VStack>
<VStack gap="5" style={styles.fullWidth}> <Field.Root required invalid={Boolean(currentErrors.organizationName)} > <Field.Label> Organization name <Field.RequiredIndicator /> </Field.Label> <Input ref={organizationNameRef} value={organizationName} onValueChange={handleOrganizationChange} placeholder="Meridian Labs" aria-invalid={ currentErrors.organizationName ? true : undefined } /> {currentErrors.organizationName ? ( <Field.Error match={true}> {currentErrors.organizationName} </Field.Error> ) : null} </Field.Root>
<Field.Root required invalid={Boolean(currentErrors.workspaceSlug)} > <Field.Label htmlFor={slugInputId}> Workspace URL <Field.RequiredIndicator /> </Field.Label> <InputGroup.Root variant="outline" size="md"> <InputGroup.Addon>{workspaceDomain}/</InputGroup.Addon> <InputGroup.Input id={slugInputId} ref={workspaceSlugRef} value={workspaceSlug} onChange={(event) => handleSlugChange(event.currentTarget.value) } placeholder="meridian-labs" autoCapitalize="none" autoCorrect="off" spellCheck={false} aria-invalid={ currentErrors.workspaceSlug ? "true" : undefined } /> </InputGroup.Root> {currentErrors.workspaceSlug ? ( <Field.Error match={true}> {currentErrors.workspaceSlug} </Field.Error> ) : slugIsValid ? ( <HStack render={<span />} gap="1.5" style={styles.statusGood} > <CheckCircleIcon /> <Text render={<span />} size="xs" weight="medium" tone="success" > {workspaceDomain}/{normalizedSlug} is available. </Text> </HStack> ) : ( <Field.Description> Lowercase letters, numbers, and hyphens only. Reserved slugs like “api” or “admin” are unavailable. </Field.Description> )} </Field.Root>
<Separator decorative />
<Field.Root required invalid={Boolean(currentErrors.projectName)} > <Field.Label> Initial project name <Field.RequiredIndicator /> </Field.Label> <Input ref={projectNameRef} value={projectName} onValueChange={setProjectName} placeholder="Core API Gateway" aria-invalid={currentErrors.projectName ? true : undefined} /> <Field.Description> Creates your first repository link, deployment pipeline, and environment variables store. </Field.Description> {currentErrors.projectName ? ( <Field.Error match={true}> {currentErrors.projectName} </Field.Error> ) : null} </Field.Root>
<Field.Root> <Field.Label> Workload summary <Text render={<span />} size="xs" tone="subtle" weight="normal" > Optional </Text> </Field.Label> <Textarea rows={2} maxLength={220} value={projectSummary} onValueChange={setProjectSummary} placeholder="Describe the services or apps running in this project." /> </Field.Root> </VStack> </VStack> ) : null}
{/* Step 1 — Region, runtime & plan tier */} {!isLaunched && step === 1 ? ( <VStack render={<section aria-label="Infrastructure and plan" />} gap="6" > <VStack gap="1.5"> <Heading render={<h2 />} size="xl" style={styles.headingReset}> Region, runtime & plan tier </Heading> <Text variant="muted" size="sm"> Select where encrypted project data lives, your default build runtime, and monthly seat capacity. </Text> </VStack>
<VStack gap="5" style={styles.fullWidth}> <Grid columns={isNarrow ? "1" : "2"} gap="4" style={styles.fullWidth} > <Select.Root items={REGIONS} value={region} onValueChange={(nextRegion) => { if (nextRegion) { setRegion(nextRegion); } }} placeholder="Select region" palette={accentPalette} > <Select.Label>Primary compute region</Select.Label> <Select.Control> <Select.Trigger> <Select.Value /> </Select.Trigger> <Select.IndicatorGroup> <Select.Icon /> </Select.IndicatorGroup> </Select.Control> <Select.Content> {REGIONS.map((option) => ( <Select.Item key={option.value} value={option.value}> <Select.ItemText>{option.label}</Select.ItemText> <Select.ItemIndicator /> </Select.Item> ))} </Select.Content> </Select.Root>
<Select.Root items={RUNTIMES} value={runtime} onValueChange={(nextRuntime) => { if (nextRuntime) { setRuntime(nextRuntime); } }} placeholder="Select runtime" palette={accentPalette} > <Select.Label>Default runtime</Select.Label> <Select.Control> <Select.Trigger> <Select.Value /> </Select.Trigger> <Select.IndicatorGroup> <Select.Icon /> </Select.IndicatorGroup> </Select.Control> <Select.Content> {RUNTIMES.map((option) => ( <Select.Item key={option.value} value={option.value}> <Select.ItemText>{option.label}</Select.ItemText> <Select.ItemIndicator /> </Select.Item> ))} </Select.Content> </Select.Root> </Grid>
<Field.Root> <Field.Label id={planGroupLabelId}>Plan tier</Field.Label> <RadioCard.Root value={planId} onValueChange={(nextPlan) => { if ( nextPlan === "developer" || nextPlan === "team" || nextPlan === "scale" ) { setPlanId(nextPlan); } }} variant="outline" size="md" palette={accentPalette} aria-labelledby={planGroupLabelId} style={isNarrow ? styles.planGridNarrow : styles.planGridWide} > {PLANS.map((tier) => ( <RadioCard.Item key={tier.id} value={tier.id} style={styles.planCardItem} > <RadioCard.ItemControl style={styles.planCardControl}> <RadioCard.ItemContent style={styles.planCardContent}> <HStack justify="between" gap="2" style={styles.fullWidth} > <HStack wrap="wrap" gap="1.5"> <RadioCard.ItemText> {tier.label} </RadioCard.ItemText> {tier.recommended ? ( <Badge variant="subtle" size="xs" palette={greenPalette} > Recommended </Badge> ) : null} </HStack> <RadioCard.ItemIndicator /> </HStack> <Text render={<span />} size="xl" weight="semibold" tabular="true" > {tier.pricePerSeat === 0 ? "Free" : `${money(tier.pricePerSeat)}/seat`} </Text> <RadioCard.ItemDescription> {tier.description} </RadioCard.ItemDescription> <Text render={<span />} size="xs" tone="subtle" style={styles.marginTopAuto} > {tier.highlight} </Text> </RadioCard.ItemContent> </RadioCard.ItemControl> </RadioCard.Item> ))} </RadioCard.Root> </Field.Root>
<Field.Root required invalid={Boolean(currentErrors.seats)}> <Field.Label> Workspace seats <Field.RequiredIndicator /> </Field.Label> <NumberInput.Root value={seats} onValueChange={(nextSeats) => setSeats(nextSeats ?? 0)} min={1} max={selectedPlan.seatLimit} step={1} palette={accentPalette} style={styles.seatsInputRoot} > <NumberInput.Group> <NumberInput.Input ref={seatsRef} aria-label="Workspace seats" aria-invalid={currentErrors.seats ? true : undefined} /> <NumberInput.Control /> </NumberInput.Group> </NumberInput.Root> <Field.Description> Includes you as owner. {selectedPlan.label} allows up to{" "} {selectedPlan.seatLimit.toLocaleString("en-US")} seats. </Field.Description> {currentErrors.seats ? ( <Field.Error match={true}>{currentErrors.seats}</Field.Error> ) : null} </Field.Root> </VStack>
{/* Readout card intentionally outside the form inputs */} <Card.Root variant="outline" size="md" style={styles.estimateCard}> <Card.Body> <HStack justify="between" wrap="wrap" gap="4"> <VStack gap="0.5"> <Text render={<span />} size="sm" weight="medium"> Estimated monthly total </Text> <Text render={<span />} size="xs" tone="muted" tabular="true" > {effectiveSeats}{" "} {effectiveSeats === 1 ? "seat" : "seats"} ×{" "} {money(selectedPlan.pricePerSeat + addonCostPerSeat)} {addonCostPerSeat > 0 ? ` (${money(selectedPlan.pricePerSeat)} plan + ${money(addonCostPerSeat)} security add-ons)` : ` (${selectedPlan.label} tier)`} </Text> </VStack> <Text render={<span />} size="2xl" weight="semibold" tabular="true" > {money(monthlyTotal)} <Text render={<span />} size="sm" tone="muted" weight="normal" > /mo </Text> </Text> </HStack> </Card.Body> </Card.Root> </VStack> ) : null}
{/* Step 2 — Team invites & security defaults (optional) */} {!isLaunched && step === 2 ? ( <VStack render={<section aria-label="Team invites and security defaults" />} gap="6" > <VStack gap="1.5"> <Heading render={<h2 />} size="xl" style={styles.headingReset}> Team invites & security defaults </Heading> <Text variant="muted" size="sm"> Invite teammates and configure compliance controls now, or skip this step and finish setup from workspace settings later. </Text> </VStack>
<VStack gap="5" style={styles.fullWidth}> <Field.Root invalid={Boolean(currentErrors.inviteEmails)}> <Field.Label> Teammate email addresses <Text render={<span />} size="xs" tone="subtle" weight="normal" > Optional </Text> </Field.Label> <Textarea ref={inviteEmailsRef} rows={4} value={inviteEmails} onValueChange={setInviteEmails} placeholder={"alex@meridianlabs.io\nsamira@meridianlabs.io"} aria-invalid={currentErrors.inviteEmails ? true : undefined} /> {currentErrors.inviteEmails ? ( <Field.Error match={true}> {currentErrors.inviteEmails} </Field.Error> ) : emails.length > 0 && invalidEmails.length === 0 ? ( <HStack render={<span />} gap="1.5" style={styles.statusGood} > <CheckCircleIcon /> <Text render={<span />} size="xs" weight="medium" tone="success" > {emails.length}{" "} {emails.length === 1 ? "teammate" : "teammates"} ready to invite. </Text> </HStack> ) : ( <Field.Description> Enter one email per line or separate addresses with commas. </Field.Description> )} </Field.Root>
<Field.Root> <Field.Label id={roleGroupLabelId}> Default role for invitees </Field.Label> <RadioGroup.Root value={inviteRole} onValueChange={setInviteRole} variant="solid" size="md" palette={accentPalette} aria-labelledby={roleGroupLabelId} > {INVITE_ROLES.map((option) => ( <RadioGroup.Item key={option.value} style={styles.optionItemRow} > <RadioGroup.ItemControl value={option.value} style={styles.optionControlOffset} /> <VStack render={<span />} gap="0.5"> <RadioGroup.ItemText>{option.label}</RadioGroup.ItemText> <Text render={<span />} size="xs" tone="muted" weight="normal" > {option.description} </Text> </VStack> </RadioGroup.Item> ))} </RadioGroup.Root> </Field.Root>
<Separator decorative />
<Field.Root> <Field.Label id={addonsGroupLabelId}> Security & compliance add-ons </Field.Label> <CheckboxGroup.Root value={securityAddons} onValueChange={(nextAddons) => setSecurityAddons(nextAddons as SecurityAddonId[]) } variant="solid" size="md" orientation="vertical" palette={accentPalette} aria-labelledby={addonsGroupLabelId} > {SECURITY_ADDONS.map((addon) => ( <CheckboxGroup.Item key={addon.id} style={styles.optionItemRow} > <CheckboxGroup.ItemControl value={addon.id} style={styles.optionControlOffset} /> <VStack render={<span />} gap="0.5"> <HStack render={<span />} wrap="wrap" gap="2"> <CheckboxGroup.ItemLabel> {addon.label} </CheckboxGroup.ItemLabel> <Text render={<span />} size="xs" tone="muted" weight="medium" tabular="true" > +{money(addon.pricePerSeat)}/seat </Text> </HStack> <Text render={<span />} size="xs" tone="muted" weight="normal" > {addon.description} </Text> </VStack> </CheckboxGroup.Item> ))} </CheckboxGroup.Root> </Field.Root>
<Separator decorative />
<VStack gap="4" style={styles.fullWidth}> <Switch.Root variant="solid" size="md" palette={accentPalette} style={styles.switchRow} > <VStack render={<span />} gap="0.5" style={styles.flexGrow} > <Text render={<span />} size="sm" weight="medium"> Require hardware passkeys or 2FA </Text> <Text render={<span />} size="xs" tone="muted"> Prompt every member to enroll a WebAuthn passkey or TOTP app on first sign-in. </Text> </VStack> <Switch.Control checked={requireMfa} onCheckedChange={setRequireMfa} /> </Switch.Root>
<Switch.Root variant="solid" size="md" palette={accentPalette} style={styles.switchRow} > <VStack render={<span />} gap="0.5" style={styles.flexGrow} > <Text render={<span />} size="sm" weight="medium"> Send invite emails immediately on launch </Text> <Text render={<span />} size="xs" tone="muted"> Turn off to save invites as drafts until your first environment is deployed. </Text> </VStack> <Switch.Control checked={sendInvitesNow} onCheckedChange={setSendInvitesNow} /> </Switch.Root> </VStack>
{sendInvitesNow ? ( <Field.Root> <Field.Label> Welcome note <Text render={<span />} size="xs" tone="subtle" weight="normal" > Optional </Text> </Field.Label> <Textarea rows={2} maxLength={240} value={welcomeNote} onValueChange={setWelcomeNote} placeholder="Welcome to our Harbor Cloud workspace — staging deploys live here." /> </Field.Root> ) : null} </VStack> </VStack> ) : null}
{/* Step 3 — Review & launch */} {!isLaunched && step === 3 ? ( <VStack render={<section aria-label="Review and launch workspace" />} gap="6" > <VStack gap="1.5"> <Heading render={<h2 />} size="xl" style={styles.headingReset}> Review & launch </Heading> <Text variant="muted" size="sm"> Nothing is provisioned until you launch. Use Edit on any card or click a step above to adjust settings. </Text> </VStack>
{outstandingSteps.length > 0 ? ( <Alert.Root status="error" variant="subtle" size="md" palette={redPalette} > <Alert.Indicator> <AlertCircleIcon /> </Alert.Indicator> <Alert.Content> <Alert.Title> {outstandingSteps.length}{" "} {outstandingSteps.length === 1 ? "step needs" : "steps need"}{" "} attention before launch </Alert.Title> <VStack gap="2" style={styles.issuesList}> {outstandingSteps.map((entry) => ( <Text key={entry.id} size="xs"> <Text render={<span />} size="xs" weight="semibold"> {entry.label}: </Text>{" "} {entry.issues.join(" ")} </Text> ))} <HStack wrap="wrap" gap="2" style={styles.issueActionWrap} > <Button variant="surface" size="xs" onClick={() => { const target = outstandingSteps[0]; markAttempted(target.index); const [firstKey] = Object.keys( errorsByStep[target.index], ) as ValidatableFieldKey[]; pendingFocusFieldRef.current = firstKey ?? null; setStep(target.index); }} > Fix {outstandingSteps[0].label} </Button> </HStack> </VStack> </Alert.Content> </Alert.Root> ) : null}
<VStack gap="4" style={styles.fullWidth}> {/* Section 1: Organization */} <Card.Root variant="outline" size="md"> <Card.Header style={styles.reviewCardHeader}> <HStack gap="2"> <Card.Title>Organization</Card.Title> {Object.keys(errorsByStep[0]).length > 0 ? ( <Badge variant="subtle" size="xs" palette={redPalette}> Needs attention </Badge> ) : null} </HStack> <Button variant="ghost" size="xs" onClick={() => goToStep(0)}> Edit </Button> </Card.Header> <Card.Body style={styles.reviewCardBody}> <DataList.Root orientation={isNarrow ? "vertical" : "horizontal"} variant="subtle" size="md" > <DataList.Item> <DataList.ItemLabel style={ isNarrow ? styles.reviewDataLabelNarrow : styles.reviewDataLabel } > Organization name </DataList.ItemLabel> <DataList.ItemValue> {organizationName.trim() || "—"} </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel style={ isNarrow ? styles.reviewDataLabelNarrow : styles.reviewDataLabel } > Workspace URL </DataList.ItemLabel> <DataList.ItemValue> <Text render={<span />} variant="mono" size="xs" style={styles.breakWord} > {workspaceDomain}/{normalizedSlug || "—"} </Text> </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel style={ isNarrow ? styles.reviewDataLabelNarrow : styles.reviewDataLabel } > Initial project </DataList.ItemLabel> <DataList.ItemValue> {projectName.trim() || "—"} </DataList.ItemValue> </DataList.Item> {projectSummary.trim() ? ( <DataList.Item> <DataList.ItemLabel style={ isNarrow ? styles.reviewDataLabelNarrow : styles.reviewDataLabel } > Workload summary </DataList.ItemLabel> <DataList.ItemValue> {projectSummary.trim()} </DataList.ItemValue> </DataList.Item> ) : null} </DataList.Root> </Card.Body> </Card.Root>
{/* Section 2: Infrastructure & Plan */} <Card.Root variant="outline" size="md"> <Card.Header style={styles.reviewCardHeader}> <HStack gap="2"> <Card.Title>Infrastructure & plan</Card.Title> {Object.keys(errorsByStep[1]).length > 0 ? ( <Badge variant="subtle" size="xs" palette={redPalette}> Needs attention </Badge> ) : null} </HStack> <Button variant="ghost" size="xs" onClick={() => goToStep(1)}> Edit </Button> </Card.Header> <Card.Body style={styles.reviewCardBody}> <DataList.Root orientation={isNarrow ? "vertical" : "horizontal"} variant="subtle" size="md" > <DataList.Item> <DataList.ItemLabel style={ isNarrow ? styles.reviewDataLabelNarrow : styles.reviewDataLabel } > Primary region </DataList.ItemLabel> <DataList.ItemValue> {selectedRegion.label} </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel style={ isNarrow ? styles.reviewDataLabelNarrow : styles.reviewDataLabel } > Default runtime </DataList.ItemLabel> <DataList.ItemValue> {selectedRuntime.label} </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel style={ isNarrow ? styles.reviewDataLabelNarrow : styles.reviewDataLabel } > Plan tier </DataList.ItemLabel> <DataList.ItemValue> {selectedPlan.pricePerSeat === 0 ? `${selectedPlan.label} (Free)` : `${selectedPlan.label} · ${money(selectedPlan.pricePerSeat)}/seat`} </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel style={ isNarrow ? styles.reviewDataLabelNarrow : styles.reviewDataLabel } > Estimated monthly </DataList.ItemLabel> <DataList.ItemValue> {money(monthlyTotal)}/mo · {effectiveSeats}{" "} {effectiveSeats === 1 ? "seat" : "seats"} </DataList.ItemValue> </DataList.Item> </DataList.Root> </Card.Body> </Card.Root>
{/* Section 3: Team & Security */} <Card.Root variant="outline" size="md"> <Card.Header style={styles.reviewCardHeader}> <HStack gap="2"> <Card.Title>Team & security</Card.Title> {Object.keys(errorsByStep[2]).length > 0 ? ( <Badge variant="subtle" size="xs" palette={redPalette}> Needs attention </Badge> ) : null} </HStack> <Button variant="ghost" size="xs" onClick={() => goToStep(2)}> Edit </Button> </Card.Header> <Card.Body style={styles.reviewCardBody}> <DataList.Root orientation={isNarrow ? "vertical" : "horizontal"} variant="subtle" size="md" > <DataList.Item> <DataList.ItemLabel style={ isNarrow ? styles.reviewDataLabelNarrow : styles.reviewDataLabel } > Invitations </DataList.ItemLabel> <DataList.ItemValue> {emails.length === 0 ? "None (invite teammates later)" : `${emails.length} ${ emails.length === 1 ? "person" : "people" } as ${selectedRole.label}${ sendInvitesNow ? "" : " (saved as drafts)" }`} </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel style={ isNarrow ? styles.reviewDataLabelNarrow : styles.reviewDataLabel } > Security add-ons </DataList.ItemLabel> <DataList.ItemValue> {selectedAddonObjects.length === 0 ? "None" : selectedAddonObjects .map((addon) => addon.label) .join(", ")} </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel style={ isNarrow ? styles.reviewDataLabelNarrow : styles.reviewDataLabel } > Authentication policy </DataList.ItemLabel> <DataList.ItemValue> {requireMfa ? "Hardware passkeys or 2FA required" : "Standard email & password allowed"} </DataList.ItemValue> </DataList.Item> </DataList.Root> </Card.Body> </Card.Root> </VStack>
<Separator decorative />
<Field.Root required invalid={Boolean(currentErrors.acceptedTerms)} > <Checkbox.Root size="md" palette={accentPalette} style={styles.termsRow} > <Checkbox.Control ref={acceptedTermsRef} checked={acceptedTerms} onCheckedChange={(next) => setAcceptedTerms(next === true)} aria-invalid={currentErrors.acceptedTerms ? true : undefined} style={styles.optionControlOffset} /> <VStack render={<span />} gap="0.5"> <Checkbox.Label> I agree to the Cloud Services Agreement and Data Processing Addendum </Checkbox.Label> <Text render={<span />} size="xs" tone="muted" weight="normal" > Billing starts after the 14-day workspace evaluation period. You can downgrade or cancel at any time. </Text> </VStack> </Checkbox.Root> {currentErrors.acceptedTerms ? ( <Field.Error match={true}> {currentErrors.acceptedTerms} </Field.Error> ) : null} </Field.Root> </VStack> ) : null} </VStack> </VStack>
{/* Pinned footer bar with Skip, centered counter, Back, and Next / Launch */} {!isLaunched ? ( <footer {...stylex.props(styles.footer)}> <HStack justify="between" wrap="wrap" gap="3" style={[styles.footerInner, isNarrow && styles.footerInnerNarrow]} > <HStack justify="start" style={styles.footerLeftZone}> {STEPS[step].isOptional ? ( <Button variant="ghost" onClick={goSkip}> Skip </Button> ) : null} </HStack>
<Text render={<span />} size="xs" tone="muted" align="center" tabular="true" style={styles.nowrap} > Step {step + 1} of {STEPS.length} </Text>
<HStack justify="end" gap="2.5" style={styles.footerRightZone}> <Button variant="surface" disabled={step === 0} onClick={() => setStep((current) => Math.max(0, current - 1))} > <ArrowLeftIcon /> Back </Button> <Button variant="solid" palette={accentPalette} onClick={goNext} > {isLastStep ? ( <> <RocketIcon /> Launch workspace </> ) : ( <> Next <ArrowRightIcon /> </> )} </Button> </HStack> </HStack> </footer> ) : null}
<Toaster toaster={queue} /> </VStack> );}
Inspired by the Form Wizard template from Astryx (MIT License · Copyright (c) 2026 Meta Platforms, Inc.).