AdaptivePolicyWizard
Four-step guided privacy-policy generator with live compliance scoring, sector pre-fills, custom sections, draft autosave, and one-click PDF / DOCX / HTML / Markdown export.
Overview
AdaptivePolicyWizardis the high-level UI for the toolkit's policy engine. It walks the user through four steps — About, Data, Processing, Review — and produces a typed PrivacyPolicy object plus PDF, DOCX, HTML, and Markdown exports.
Unlike the lower-level PolicyGenerator (which renders a single form against a fixed template), the wizard adapts: it pre-fills lawful basis, data categories, sensitive-data flags, and cross-border defaults based on the chosen sector template, and re-runs compliance checks every time the user edits the context.
The wizard is exported from the /policy subpath:
import { AdaptivePolicyWizard } from '@tantainnovative/ndpr-toolkit/policy';Quickstart
import { AdaptivePolicyWizard, templateContextFor } from '@tantainnovative/ndpr-toolkit/policy';
import { localStorageAdapter } from '@tantainnovative/ndpr-toolkit/adapters';
import type { PolicyDraft } from '@tantainnovative/ndpr-toolkit/policy';
export default function PolicyBuilderPage() {
return (
<AdaptivePolicyWizard
// Seed step 1 with an ecommerce-flavoured pre-fill
initialContext={templateContextFor('ecommerce')}
// Auto-save drafts to localStorage every ~2 seconds
adapter={localStorageAdapter<PolicyDraft>('ndpr_policy_draft')}
onComplete={(policy) => {
// policy is a typed PrivacyPolicy object — persist or render it
console.log('finished policy', policy);
}}
/>
);
}Props
| Prop | Type | Description |
|---|---|---|
adapter | StorageAdapter<PolicyDraft> | Optional draft persistence. Pass localStorageAdapter, cookieAdapter, or your own implementation. |
onComplete | (policy: PrivacyPolicy) => void | Fired when the user finishes the Review step. Receives the finalised typed policy. |
initialContext | TemplateContext | Seed for step 1. Use templateContextFor('saas' | 'ecommerce' | 'healthcare' | ...) for a sector pre-fill. A saved draft from adapter wins over initialContext. |
classNames | Record<string, string> | Per-slot class overrides — root, container, topBar, mainPanel, sidebarWrapper, backButton, nextButton, etc. |
unstyled | boolean | Strip every default class for a from-scratch design. |
Wizard vs PolicyGenerator
Both ship in the same module — choose based on how much guidance you want:
PolicyGenerator— single-form, fixed template, no compliance checker. Best when you already know what your policy should contain and just need a form to capture variables.AdaptivePolicyWizard— four-step flow, sector-aware pre-fills, live compliance scoring with one-click fixes, custom sections, autosave, multi-format export. Best for end-user-facing policy builders.
Headless hook: useAdaptivePolicyWizard
If you want the same state machine but a completely custom UI, the wizard is backed by the useAdaptivePolicyWizard hook (also exported from /headless). It returns the same step management, context updates, compliance result, and export handlers — render whatever you like on top.
import { useAdaptivePolicyWizard } from '@tantainnovative/ndpr-toolkit/headless';
const {
currentStep, nextStep, prevStep, canProceed,
context, updateOrg, toggleDataCategory, togglePurpose,
sections, complianceResult, applyFix,
handleExportPDF, handleExportDOCX, handleExportHTML, handleExportMarkdown,
lastSavedAt, isLoading,
} = useAdaptivePolicyWizard({ adapter, onComplete, initialContext });