@tantainnovative/ndpr-toolkit 3.12.0 → 4.0.0
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 +139 -0
- package/README.md +1 -1
- package/dist/breach.d.mts +3 -2
- package/dist/breach.d.ts +3 -2
- package/dist/breach.js +1 -1
- package/dist/breach.mjs +1 -1
- package/dist/chunk-37VFK5SR.js +6 -0
- package/dist/chunk-3E4IH7CE.js +1 -0
- package/dist/chunk-3H6FYU3Z.mjs +93 -0
- package/dist/chunk-3I6FYA5C.js +103 -0
- package/dist/chunk-3SIYRGJF.js +93 -0
- package/dist/chunk-3XU6FL2I.js +1 -0
- package/dist/chunk-42JPSNVV.mjs +6 -0
- package/dist/chunk-42UJFTII.js +1 -0
- package/dist/chunk-5F2IAUWJ.js +1 -0
- package/dist/chunk-63WM5PHZ.js +1 -0
- package/dist/chunk-6A6VI7ZP.mjs +1 -0
- package/dist/chunk-7FXNGGMO.js +1 -0
- package/dist/chunk-B2EXRSYG.mjs +1 -0
- package/dist/chunk-BGV2AKT7.mjs +1 -0
- package/dist/chunk-BL5W472Q.js +1 -0
- package/dist/chunk-BPMVJOHH.mjs +1 -0
- package/dist/chunk-D2UWB5OI.js +2 -0
- package/dist/chunk-DK7P5JEG.mjs +2 -0
- package/dist/chunk-ELK6VFKC.mjs +2 -0
- package/dist/chunk-F5MGMNQF.js +2 -0
- package/dist/chunk-FRQFU44F.mjs +1 -0
- package/dist/chunk-GUERZD4O.mjs +1 -0
- package/dist/{chunk-WYH3OA5L.mjs → chunk-I2ZBMR7F.mjs} +1 -1
- package/dist/chunk-J7BIJ45O.mjs +103 -0
- package/dist/{chunk-US2VGJ7I.js → chunk-KH3EQJQE.js} +1 -1
- package/dist/{chunk-IPWX5I5P.mjs → chunk-L3FR4PQE.mjs} +1 -1
- package/dist/chunk-N72RNTGP.mjs +6 -0
- package/dist/chunk-NB6SKG76.mjs +1 -0
- package/dist/chunk-RBKFNCGO.mjs +1 -0
- package/dist/chunk-TTMGFC6C.js +1 -0
- package/dist/{chunk-TWJHEIQH.js → chunk-UZNWXJ2W.js} +1 -1
- package/dist/chunk-V5TZJJWU.mjs +1 -0
- package/dist/chunk-WCTFED27.js +1 -0
- package/dist/chunk-WMISQDSV.js +1 -0
- package/dist/{chunk-MTSZ7GL6.mjs → chunk-WVHMY2BV.mjs} +1 -1
- package/dist/chunk-XYGGUGTO.js +6 -0
- package/dist/chunk-YDKWD6MQ.js +1 -0
- package/dist/chunk-Z2M5VJX2.mjs +1 -0
- package/dist/{chunk-D3DVVJCT.js → chunk-ZD2W3YU2.js} +1 -1
- package/dist/chunk-ZQHGIOYP.mjs +1 -0
- package/dist/consent.js +1 -1
- package/dist/consent.mjs +1 -1
- package/dist/core.d.mts +62 -0
- package/dist/core.d.ts +62 -0
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/cross-border-lite.js +1 -1
- package/dist/cross-border-lite.mjs +1 -1
- package/dist/cross-border.js +1 -1
- package/dist/cross-border.mjs +1 -1
- package/dist/dpia.js +1 -1
- package/dist/dpia.mjs +1 -1
- package/dist/dsr.d.mts +12 -3
- package/dist/dsr.d.ts +12 -3
- package/dist/dsr.js +1 -1
- package/dist/dsr.mjs +1 -1
- package/dist/headless.d.mts +12 -3
- package/dist/headless.d.ts +12 -3
- package/dist/headless.js +1 -1
- package/dist/headless.mjs +1 -1
- package/dist/hooks.d.mts +12 -3
- package/dist/hooks.d.ts +12 -3
- package/dist/hooks.js +1 -1
- package/dist/hooks.mjs +1 -1
- package/dist/index.d.mts +77 -5
- package/dist/index.d.ts +77 -5
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lawful-basis-lite.js +1 -1
- package/dist/lawful-basis-lite.mjs +1 -1
- package/dist/lawful-basis.js +1 -1
- package/dist/lawful-basis.mjs +1 -1
- package/dist/policy.js +1 -1
- package/dist/policy.mjs +1 -1
- package/dist/presets-consent.d.mts +5 -1
- package/dist/presets-consent.d.ts +5 -1
- package/dist/presets-consent.js +1 -1
- package/dist/presets-consent.mjs +1 -1
- package/dist/presets-dsr.js +1 -1
- package/dist/presets-dsr.mjs +1 -1
- package/dist/presets-policy.d.mts +23 -0
- package/dist/presets-policy.d.ts +23 -0
- package/dist/presets-policy.js +1 -1
- package/dist/presets-policy.mjs +1 -1
- package/dist/presets.d.mts +221 -4
- package/dist/presets.d.ts +221 -4
- package/dist/presets.js +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/ropa-lite.js +1 -1
- package/dist/ropa-lite.mjs +1 -1
- package/dist/ropa.js +1 -1
- package/dist/ropa.mjs +1 -1
- package/dist/server.d.mts +62 -0
- package/dist/server.d.ts +62 -0
- package/dist/server.js +1 -1
- package/dist/server.mjs +1 -1
- package/dist/unstyled.js +1 -1
- package/dist/unstyled.mjs +1 -1
- package/package.json +3 -3
- package/dist/chunk-25TNTLHJ.mjs +0 -1
- package/dist/chunk-4GIMXUMI.js +0 -6
- package/dist/chunk-5AECGMEB.js +0 -1
- package/dist/chunk-5EKQX6GM.mjs +0 -1
- package/dist/chunk-67KA345Q.mjs +0 -1
- package/dist/chunk-6GM2PBTF.js +0 -2
- package/dist/chunk-6OWCUDTN.mjs +0 -1
- package/dist/chunk-73BMSK67.js +0 -1
- package/dist/chunk-CAFCRCTZ.mjs +0 -1
- package/dist/chunk-EKNWO4DK.js +0 -1
- package/dist/chunk-FMJ6ICLJ.js +0 -1
- package/dist/chunk-G7JKRYM5.mjs +0 -1
- package/dist/chunk-GEP52QFH.mjs +0 -1
- package/dist/chunk-IB3KSUPZ.mjs +0 -1
- package/dist/chunk-JWAN5J4Y.js +0 -1
- package/dist/chunk-JYZOKO2W.mjs +0 -103
- package/dist/chunk-NDKDKDDX.js +0 -1
- package/dist/chunk-NX5MOBRI.js +0 -1
- package/dist/chunk-OLEUIYE2.mjs +0 -1
- package/dist/chunk-Q4CSVWSS.mjs +0 -1
- package/dist/chunk-QMAVEHOR.js +0 -1
- package/dist/chunk-RBMLGRDN.mjs +0 -1
- package/dist/chunk-ROC64RLP.js +0 -1
- package/dist/chunk-RR3KXNET.mjs +0 -6
- package/dist/chunk-TDHH7GS2.mjs +0 -2
- package/dist/chunk-TN4TH3CT.mjs +0 -2
- package/dist/chunk-VUFTRKKC.js +0 -2
- package/dist/chunk-WKTKTLMF.js +0 -1
- package/dist/chunk-WXUXCRAJ.js +0 -1
- package/dist/chunk-XN2UYZXH.mjs +0 -93
- package/dist/chunk-YK22SYCT.js +0 -103
- package/dist/chunk-YSD2DFBR.js +0 -6
- package/dist/chunk-YWCBI7SI.js +0 -93
- package/dist/chunk-ZHX62QAL.mjs +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,145 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [4.0.0](https://github.com/mr-tanta/ndpr-toolkit/compare/v3.13.0...v4.0.0) (2026-05-27)
|
|
6
|
+
|
|
7
|
+
The consolidated breaking-change window. Every removal here was already deprecated and dev-warned in 3.13.x — if your 3.13.x dev console was clean, your 4.0 upgrade is a one-line bump. Full migration table in [`/docs/guides/migrating-3-13-to-4-0`](https://ndprtoolkit.com.ng/docs/guides/migrating-3-13-to-4-0).
|
|
8
|
+
|
|
9
|
+
### Breaking changes
|
|
10
|
+
|
|
11
|
+
#### React 17 dropped from peer range
|
|
12
|
+
|
|
13
|
+
`peerDependencies.react` is now `^18.0.0 || ^19.0.0` (was `^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0`). The toolkit uses `React.useId` (18+) in several components, so the previous claim was a lie — React 17 consumers installed cleanly then hit cryptic errors at runtime. This release just makes the peer range match reality.
|
|
14
|
+
|
|
15
|
+
**Migration:** if you're on React 17 or earlier, upgrade your app to React 18+ before bumping. React 18 / 19 consumers: no action.
|
|
16
|
+
|
|
17
|
+
#### `formDescription` removed; use `description`
|
|
18
|
+
|
|
19
|
+
`BreachReportForm` and `NDPRBreachReport` previously accepted both `description` and a legacy `formDescription` alias (with a dev warn). The alias is gone.
|
|
20
|
+
|
|
21
|
+
**Migration:** rename every `formDescription` to `description`. (3.13's dev warn told you where.)
|
|
22
|
+
|
|
23
|
+
#### `initialActivities` / `initialTransfers` removed; use `initialData`
|
|
24
|
+
|
|
25
|
+
`NDPRLawfulBasis` and `NDPRCrossBorder` presets now accept `initialData` only, matching `NDPRROPA`. The module-specific aliases are gone.
|
|
26
|
+
|
|
27
|
+
**Migration:**
|
|
28
|
+
```diff
|
|
29
|
+
- <NDPRLawfulBasis initialActivities={activities} />
|
|
30
|
+
+ <NDPRLawfulBasis initialData={activities} />
|
|
31
|
+
|
|
32
|
+
- <NDPRCrossBorder initialTransfers={transfers} />
|
|
33
|
+
+ <NDPRCrossBorder initialData={transfers} />
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
#### `extraOptions` removed from `NDPRConsent`
|
|
37
|
+
|
|
38
|
+
The one-off pattern that extended the toolkit's default options is gone. Pass the full options array via `options` instead.
|
|
39
|
+
|
|
40
|
+
**Migration:** copy the default option set (or build your own) and pass it via `options`. Example in the migration guide.
|
|
41
|
+
|
|
42
|
+
#### `useDSR` default storage flipped to in-memory
|
|
43
|
+
|
|
44
|
+
`useDSR` is the admin tracker hook — its state contains data subjects' PII. The previous default (`useLocalStorage: true`) persisted that PII to the admin's browser's localStorage, which is rarely appropriate. The default is now `useLocalStorage: false`.
|
|
45
|
+
|
|
46
|
+
**Migration:**
|
|
47
|
+
- If you intentionally relied on localStorage persistence, pass `useLocalStorage: true` explicitly (and reconsider whether you actually want it).
|
|
48
|
+
- If you want production persistence, pass `adapter: apiAdapter('/api/dsr')` (or any other `StorageAdapter`).
|
|
49
|
+
- If you don't need persistence, no action — the tracker now starts empty on every reload, which is correct for most admin UI use cases.
|
|
50
|
+
|
|
51
|
+
#### `examples/dsr-backend-prod` renamed to `examples/dsr-backend-reference`
|
|
52
|
+
|
|
53
|
+
The "prod" name oversold what the example does. It demonstrates DSR receipt and confirmation — not the full fulfilment pipeline (identity verification, audit logging, status transitions, request-type-specific handling, deadline tracking, DPO routing). The renamed example ships a "What you still need to build" checklist in its README so consumers don't ship it as-is.
|
|
54
|
+
|
|
55
|
+
**Migration:** if you bookmarked or cloned `examples/dsr-backend-prod/`, update to `examples/dsr-backend-reference/`. The contents and contract are unchanged.
|
|
56
|
+
|
|
57
|
+
### New
|
|
58
|
+
|
|
59
|
+
- New migration guide page at `/docs/guides/migrating-3-13-to-4-0` walks through each break with diffs.
|
|
60
|
+
|
|
61
|
+
### Not in this 4.0
|
|
62
|
+
|
|
63
|
+
The plan originally also included:
|
|
64
|
+
|
|
65
|
+
- list-manager callback rename (`onArchiveActivity` / `onRemoveTransfer` / `onArchiveRecord` → uniform `onArchive`)
|
|
66
|
+
- `NDPRDPIA.onComplete(result: DPIAResult)` instead of `onComplete(answers)`
|
|
67
|
+
- `ROPAManagerLite` accepts `ropa: RecordOfProcessingActivities` instead of `records: ProcessingRecord[]`
|
|
68
|
+
- pure structured validator returns (legacy string returns removed)
|
|
69
|
+
- discriminated-union `onSubmitError`
|
|
70
|
+
- delete the inner `packages/ndpr-toolkit/{tsup.config.ts, tsconfig.json, etc.}` (already marked `private: true` in 3.10.5)
|
|
71
|
+
|
|
72
|
+
Each adds API churn for marginal gain. Deferred to **4.1** so 4.0 stays focused on the items already deprecated in the 3.13 window. The inner-package deletion can land any time; behaviour change otherwise.
|
|
73
|
+
|
|
74
|
+
### Verification
|
|
75
|
+
|
|
76
|
+
- Jest: **1258 / 1258 passing** (no test count drift — deprecated-prop tests were updated to use the canonical names)
|
|
77
|
+
- `tsc --noEmit -p tsconfig.json` clean
|
|
78
|
+
- `pnpm verify:tarball --skip-ts` clean across all 22 subpaths
|
|
79
|
+
|
|
80
|
+
## [3.13.0](https://github.com/mr-tanta/ndpr-toolkit/compare/v3.12.0...v3.13.0) (2026-05-27)
|
|
81
|
+
|
|
82
|
+
Release 5 of 6 on the post-audit roadmap. The **deprecation-window minor** — strictly additive, but every prop alias and behavior change that 4.0 will commit to gets fired here first as a dev-mode warning. Existing 3.x consumers see no breakage; new code can adopt the canonical surface.
|
|
83
|
+
|
|
84
|
+
### i18n is real now — `useNDPRLocale` wired into 17+ components
|
|
85
|
+
|
|
86
|
+
**The big one.** The toolkit shipped 5 locale files (`en`, `yo`, `ig`, `ha`, `pcm`) and exposed `useNDPRLocale()`, but only 3 components consumed the hook (post-3.10.4: `ConsentBanner`, `DSRRequestForm`, `BreachReportForm`). The remaining ~17 components ignored the locale prop, making `<NDPRProvider locale={…}>` mostly cosmetic. The audit's B14 report called this out as a top-tier finding.
|
|
87
|
+
|
|
88
|
+
Newly wired components (each follows the prop-override → locale → English default precedence):
|
|
89
|
+
|
|
90
|
+
- **DSR**: `DSRDashboard`, `DSRTracker`
|
|
91
|
+
- **Breach**: `BreachRiskAssessment`, `BreachNotificationManager`, `RegulatoryReportGenerator`
|
|
92
|
+
- **DPIA**: `DPIAQuestionnaire` (next/prev/submit buttons), `DPIAReport` (report title)
|
|
93
|
+
- **Policy**: `PolicyGenerator`, `PolicyPreview`, `PolicyExporter`, `AdaptivePolicyWizard`
|
|
94
|
+
- **Lawful basis**: `LawfulBasisTracker` + `LawfulBasisTrackerLite`
|
|
95
|
+
- **Cross-border**: `CrossBorderTransferManager` + `CrossBorderTransferManagerLite`
|
|
96
|
+
- **ROPA**: `ROPAManager` + `ROPAManagerLite`
|
|
97
|
+
- **Consent extras**: `ConsentManager` (title/desc/save/reset)
|
|
98
|
+
- **NDPRProvider** error-boundary fallback now reads `locale.common.error`
|
|
99
|
+
|
|
100
|
+
The `NDPRLocale` type at `src/types/locale.ts` was expanded with new keys (`consent.managerTitle`, `dsr.dashboardTitle`, `breach.riskAssessmentTitle`, `policy.generatorTitle`, plus top-level `lawfulBasis`, `crossBorder`, `ropa` groups). All 5 shipped locale files got the matching translations.
|
|
101
|
+
|
|
102
|
+
**21 new i18n regression tests** (3 cases × 7 modules) confirm each component honors the locale prop. Pattern matches `ConsentBanner-i18n.test.tsx` from 3.10.4.
|
|
103
|
+
|
|
104
|
+
### Preset API harmonization (sets up 4.0 deprecation window)
|
|
105
|
+
|
|
106
|
+
- **`submitTo` / `submitOptions` / `onSubmitSuccess` / `onSubmitError`** lifted from `NDPRSubjectRights` to `NDPRBreachReport` and `NDPRDPIA`. The latter two now support the same typed POST-and-route pattern. `NDPRDPIA` posts on last-section completion; both preserve the legacy `onSubmit` / `onComplete` callbacks so existing consumers see no change.
|
|
107
|
+
- **`copy?` prop added to 6 presets** (`NDPRBreachReport`, `NDPRDPIA`, `NDPRLawfulBasis`, `NDPRCrossBorder`, `NDPRROPA`, `NDPRPrivacyPolicy`). Each ships a typed `NDPR<Name>Copy` interface, exported from `src/index.ts`. `NDPRConsent` already had this pattern; the 6 presets now match.
|
|
108
|
+
- **`description` prop added** alongside `formDescription` on `BreachReportForm` + `NDPRBreachReport`. When both set, `description` wins; when only `formDescription` is set, a one-shot dev warn says `[ndpr-toolkit/breach] BreachReportFormProps.formDescription is deprecated; rename to 'description'. Will be removed in 4.0.`
|
|
109
|
+
- **`initialData` prop added** alongside `initialActivities` on `NDPRLawfulBasis` and `initialTransfers` on `NDPRCrossBorder`. Same alias precedence + dev warn for the legacy names.
|
|
110
|
+
|
|
111
|
+
### Privacy guard on `useDSR` default storage
|
|
112
|
+
|
|
113
|
+
`useDSR()` is the admin tracker hook — its state contains OTHER PEOPLE'S PII (DSR requests submitted by data subjects). The current default writes to `localStorage` on the admin's browser, which is rarely the right place.
|
|
114
|
+
|
|
115
|
+
Added a fire-once dev-only `console.warn` when a consumer uses the default `localStorage` path without an explicit adapter:
|
|
116
|
+
|
|
117
|
+
> `[ndpr-toolkit/dsr] useDSR() is using the default localStorageAdapter, which stores DSR requests (including data subjects' PII) in the admin's browser. For production deployments, pass an explicit adapter… In 4.0, the default will switch to in-memory; localStorage will require explicit opt-in.`
|
|
118
|
+
|
|
119
|
+
### Other dev-mode deprecations (queued for removal in 4.0)
|
|
120
|
+
|
|
121
|
+
Every dev warn is guarded by `process.env.NODE_ENV !== 'production'` AND a `useRef`-based fire-once flag — production builds see no overhead, dev consoles see each warning once per component instance.
|
|
122
|
+
|
|
123
|
+
- `NDPRConsentProps.extraOptions` — one-off pattern not used by other presets. Warn fires when passed.
|
|
124
|
+
- `formDescription` on `BreachReportForm` / `NDPRBreachReport` — see above.
|
|
125
|
+
- `initialActivities` on `NDPRLawfulBasis`, `initialTransfers` on `NDPRCrossBorder` — see above.
|
|
126
|
+
|
|
127
|
+
### Deferred from the original 3.13.0 plan
|
|
128
|
+
|
|
129
|
+
- **`useConsent` generic over options array** — non-trivial type-level refactor that needs the existing tests to be re-checked. Higher value if shipped together with the 4.0 type-cleanup window; deferring there.
|
|
130
|
+
- **`useDSR.requestType` generic** — same shape, same reasoning.
|
|
131
|
+
- **`ROPAManager.updateEditingField` generic over `keyof ProcessingRecord`** — internal refactor, defer to 4.0.
|
|
132
|
+
- **`onSubmitError` discriminated union** — the current `{ error?, response? }` shape works for everyone today. Discriminated-union variant is breaking-ish (TS narrows differently); defer to 4.0.
|
|
133
|
+
- **`validate*Structured()` returning `{ field, code, message }[]`** — additive, but the new shape needs its own docs page and migration story. Defer to 4.0 alongside the validator-message harmonization.
|
|
134
|
+
- **`[ndpr-toolkit/<module>]` prefix on every utility error** — bulk-mechanical; defer (already happening organically — every dev warn we added in 3.13.0 carries the prefix).
|
|
135
|
+
- **Arabic locale + RTL CSS conversion** — defer to a focused i18n release after 4.0. The shape is now in place (`ar.ts` can be one file); the logical-property CSS conversion is its own focused chore.
|
|
136
|
+
- **French locale (`fr.ts`)** — same; one data file once the type/wiring is stable.
|
|
137
|
+
|
|
138
|
+
### Verification
|
|
139
|
+
|
|
140
|
+
- Jest: **1258 / 1258 passing** (was 1237; +21 new i18n tests)
|
|
141
|
+
- `tsc --noEmit -p tsconfig.json` clean
|
|
142
|
+
- `pnpm verify:tarball --skip-ts` clean across all 22 subpaths
|
|
143
|
+
|
|
5
144
|
## [3.12.0](https://github.com/mr-tanta/ndpr-toolkit/compare/v3.11.0...v3.12.0) (2026-05-27)
|
|
6
145
|
|
|
7
146
|
Release 4 of 6 on the post-audit roadmap. Accessibility + performance + test coverage. No public API changes — everything is additive or behaviour-preserving internal work. Existing consumers see no breakage; users of assistive tech and consumers of large managers see real improvements.
|
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ v3 ships **zero-config presets**, **pluggable storage adapters**, **compound com
|
|
|
18
18
|
|
|
19
19
|
> **What's new in 3.11.0:** Every component's `Props` interface is now re-exported from the root (consumers can finally wrap toolkit components without copying types). Adapter ecosystem types (`ApiAdapterErrorContext`, `StorageAdapter<T>`, …) and DSR validator types reachable from `/server` + root. 9 new component docs pages cover `NDPRThemeProvider`, `NDPRProvider`, `NDPRDashboard`, `AdaptivePolicyWizard`, `PolicyPage`, the 3 Lite manager variants, and `LegalNotice`.
|
|
20
20
|
>
|
|
21
|
-
> **3.10.x highlights:** Typed theming via `<NDPRThemeProvider>`, a `/headless` subpath alias of `/hooks`, the production-grade DSR backend reference at `examples/dsr-backend-
|
|
21
|
+
> **3.10.x highlights:** Typed theming via `<NDPRThemeProvider>`, a `/headless` subpath alias of `/hooks`, the production-grade DSR backend reference at `examples/dsr-backend-reference/`, plus the `verify:tarball` CI gate that catches broken exports at PR time. Upgrading from 3.7.x? See the [3.7 → 3.10 upgrade guide](https://ndprtoolkit.com.ng/docs/guides/upgrading-3-7-to-3-10). Full history in the [CHANGELOG](https://github.com/mr-tanta/ndpr-toolkit/blob/main/CHANGELOG.md).
|
|
22
22
|
|
|
23
23
|
<p align="center">
|
|
24
24
|
<img src="https://raw.githubusercontent.com/mr-tanta/ndpr-toolkit/v3.11.0/public/screenshots/hero.png" alt="NDPA Toolkit — NDPA Compliance Made Beautiful" width="800" />
|
package/dist/breach.d.mts
CHANGED
|
@@ -353,10 +353,11 @@ declare interface BreachReportFormProps {
|
|
|
353
353
|
*/
|
|
354
354
|
title?: string;
|
|
355
355
|
/**
|
|
356
|
-
* Description text displayed on the form
|
|
356
|
+
* Description text displayed on the form.
|
|
357
|
+
*
|
|
357
358
|
* @default "Use this form to report a suspected or confirmed data breach in accordance with NDPA Section 40. All fields marked with * are required."
|
|
358
359
|
*/
|
|
359
|
-
|
|
360
|
+
description?: string;
|
|
360
361
|
/**
|
|
361
362
|
* Text for the submit button
|
|
362
363
|
* @default "Submit Report"
|
package/dist/breach.d.ts
CHANGED
|
@@ -353,10 +353,11 @@ declare interface BreachReportFormProps {
|
|
|
353
353
|
*/
|
|
354
354
|
title?: string;
|
|
355
355
|
/**
|
|
356
|
-
* Description text displayed on the form
|
|
356
|
+
* Description text displayed on the form.
|
|
357
|
+
*
|
|
357
358
|
* @default "Use this form to report a suspected or confirmed data breach in accordance with NDPA Section 40. All fields marked with * are required."
|
|
358
359
|
*/
|
|
359
|
-
|
|
360
|
+
description?: string;
|
|
360
361
|
/**
|
|
361
362
|
* Text for the submit button
|
|
362
363
|
* @default "Submit Report"
|
package/dist/breach.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
'use strict';var
|
|
2
|
+
'use strict';var chunk3I6FYA5C_js=require('./chunk-3I6FYA5C.js'),chunkD2UWB5OI_js=require('./chunk-D2UWB5OI.js'),chunkEHQVTFYO_js=require('./chunk-EHQVTFYO.js'),chunk3YTAOT5O_js=require('./chunk-3YTAOT5O.js');require('./chunk-UXUMYP4L.js'),require('./chunk-ZVOIR4QH.js'),require('./chunk-AME4HJR4.js'),require('./chunk-YDKWD6MQ.js'),require('./chunk-TTMGFC6C.js'),require('./chunk-VWED6UTN.js');var chunkRFPLZDIO_js=require('./chunk-RFPLZDIO.js'),react=require('react'),jsxRuntime=require('react/jsx-runtime');var c=react.createContext(null);function P(){let e=react.useContext(c);if(!e)throw new Error("Breach compound components must be wrapped in <Breach.Provider>. Example: <Breach.Provider categories={...}><Breach.ReportForm /></Breach.Provider>");return e}var p=({categories:e,adapter:m,storageKey:h,useLocalStorage:B,initialReports:f,onReport:R,onAssessment:x,onNotification:u,children:d})=>{let y=chunkEHQVTFYO_js.a({categories:e,adapter:m,storageKey:h,useLocalStorage:B,initialReports:f,onReport:R,onAssessment:x,onNotification:u}),l=chunkRFPLZDIO_js.b(chunkRFPLZDIO_js.a({},y),{categories:e});return jsxRuntime.jsx(c.Provider,{value:l,children:d})};var A={Provider:p,ReportForm:chunkD2UWB5OI_js.a,RiskAssessment:chunk3I6FYA5C_js.a,NotificationManager:chunk3I6FYA5C_js.b,ReportGenerator:chunk3I6FYA5C_js.c};Object.defineProperty(exports,"BreachNotificationManager",{enumerable:true,get:function(){return chunk3I6FYA5C_js.b}});Object.defineProperty(exports,"BreachRiskAssessment",{enumerable:true,get:function(){return chunk3I6FYA5C_js.a}});Object.defineProperty(exports,"RegulatoryReportGenerator",{enumerable:true,get:function(){return chunk3I6FYA5C_js.c}});Object.defineProperty(exports,"BreachReportForm",{enumerable:true,get:function(){return chunkD2UWB5OI_js.a}});Object.defineProperty(exports,"useBreach",{enumerable:true,get:function(){return chunkEHQVTFYO_js.a}});Object.defineProperty(exports,"calculateBreachSeverity",{enumerable:true,get:function(){return chunk3YTAOT5O_js.a}});exports.Breach=A;exports.BreachProvider=p;exports.useBreachCompound=P;
|
package/dist/breach.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {c as c$1,b,a}from'./chunk-
|
|
2
|
+
import {c as c$1,b,a}from'./chunk-J7BIJ45O.mjs';export{b as BreachNotificationManager,a as BreachRiskAssessment,c as RegulatoryReportGenerator}from'./chunk-J7BIJ45O.mjs';import {a as a$1}from'./chunk-DK7P5JEG.mjs';export{a as BreachReportForm}from'./chunk-DK7P5JEG.mjs';import {a as a$2}from'./chunk-RFXGD5NE.mjs';export{a as useBreach}from'./chunk-RFXGD5NE.mjs';export{a as calculateBreachSeverity}from'./chunk-WTGKZX7J.mjs';import'./chunk-EWVK45Z3.mjs';import'./chunk-ITCY2Z66.mjs';import'./chunk-SFGW37LE.mjs';import'./chunk-FRQFU44F.mjs';import'./chunk-V5TZJJWU.mjs';import'./chunk-DBZSN4WP.mjs';import {b as b$1,a as a$3}from'./chunk-ZJYULEER.mjs';import {createContext,useContext}from'react';import {jsx}from'react/jsx-runtime';var c=createContext(null);function P(){let e=useContext(c);if(!e)throw new Error("Breach compound components must be wrapped in <Breach.Provider>. Example: <Breach.Provider categories={...}><Breach.ReportForm /></Breach.Provider>");return e}var p=({categories:e,adapter:m,storageKey:h,useLocalStorage:B,initialReports:f,onReport:R,onAssessment:x,onNotification:u,children:d})=>{let y=a$2({categories:e,adapter:m,storageKey:h,useLocalStorage:B,initialReports:f,onReport:R,onAssessment:x,onNotification:u}),l=b$1(a$3({},y),{categories:e});return jsx(c.Provider,{value:l,children:d})};var A={Provider:p,ReportForm:a$1,RiskAssessment:a,NotificationManager:b,ReportGenerator:c$1};export{A as Breach,p as BreachProvider,P as useBreachCompound};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'use strict';var chunkZVOIR4QH_js=require('./chunk-ZVOIR4QH.js'),chunkAME4HJR4_js=require('./chunk-AME4HJR4.js'),chunkYDKWD6MQ_js=require('./chunk-YDKWD6MQ.js'),T=require('react'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var T__default=/*#__PURE__*/_interopDefault(T);var G=({result:s,sections:c,showFullReport:g=true,allowPrint:v=true,allowExport:f=true,onExport:b,className:w="",buttonClassName:x="",classNames:h={},unstyled:k=false})=>{var I;let N=(I=chunkYDKWD6MQ_js.c().dpia.reportTitle)!=null?I:"Data Protection Impact Assessment Report",m=T.useMemo(()=>new Date().toLocaleDateString(),[]),r=(a,n)=>{let i=n?h[n]:void 0;return !i&&n==="printButton"&&(i=h.primaryButton),chunkAME4HJR4_js.a(a,i,k)},o=a=>new Date(a).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"}),R=a=>{let n=s.answers[a];return n==null?"Not answered":typeof n=="boolean"?n?"Yes":"No":Array.isArray(n)?n.join(", "):String(n)},p=()=>{window.print();},u=a=>{b&&b(a);},A=a=>jsxRuntime.jsx("span",{className:r(`px-2 py-1 rounded text-xs font-medium ${{low:"ndpr-badge ndpr-badge--success",medium:"ndpr-badge ndpr-badge--warning",high:"ndpr-badge ndpr-badge--warning",critical:"ndpr-badge ndpr-badge--destructive"}[a]}`,"riskBadge"),children:a.charAt(0).toUpperCase()+a.slice(1)});return jsxRuntime.jsxs("div",{"data-ndpr-component":"dpia-report",className:`${r("bg-white dark:bg-gray-800 rounded-lg shadow-md p-6 print:shadow-none print:p-0","root")} ${w}`,children:[jsxRuntime.jsxs("div",{className:r("mb-8 border-b border-gray-200 dark:border-gray-700 pb-6 print:pb-4","header"),children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h1",{className:r("ndpr-card__title","title"),children:N}),jsxRuntime.jsx("h2",{className:"text-xl ndpr-text-muted mb-4",children:s.title})]}),(v||f)&&jsxRuntime.jsxs("div",{className:"flex space-x-2 print:hidden",children:[v&&jsxRuntime.jsx("button",{onClick:p,className:`${r("px-3 py-1 bg-gray-200 text-gray-800 dark:bg-gray-700 dark:text-white rounded hover:bg-gray-300 dark:hover:bg-gray-600","printButton")} ${x}`,children:jsxRuntime.jsxs("span",{className:"flex items-center",children:[jsxRuntime.jsx("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"})}),"Print"]})}),f&&jsxRuntime.jsx("div",{className:"relative inline-block",children:jsxRuntime.jsx("button",{onClick:()=>u("pdf"),className:`px-3 py-1 bg-[rgb(var(--ndpr-primary))] text-white rounded hover:bg-[rgb(var(--ndpr-primary-hover))] ${x}`,children:jsxRuntime.jsxs("span",{className:"flex items-center",children:[jsxRuntime.jsx("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),"Export PDF"]})})})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Assessor:"})," ",s.assessor.name,", ",s.assessor.role]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Contact:"})," ",s.assessor.email]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Started:"})," ",o(s.startedAt)]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Completed:"})," ",s.completedAt?o(s.completedAt):"In progress"]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Next review:"})," ",s.reviewDate?o(s.reviewDate):"Not scheduled"]})]})]})]}),jsxRuntime.jsxs("div",{className:r("mb-8","summary"),children:[jsxRuntime.jsx("h2",{className:"ndpr-section-heading",children:"Executive Summary"}),jsxRuntime.jsxs("div",{className:"ndpr-panel",children:[jsxRuntime.jsxs("div",{className:"flex items-center mb-2",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"font-medium mr-2",children:"Overall Risk Level:"}),A(s.overallRiskLevel)]}),jsxRuntime.jsxs("div",{className:r("mb-2","conclusion"),children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Conclusion:"})," ",s.conclusion]}),jsxRuntime.jsxs("div",{role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Can Proceed:"})," ",s.canProceed?"Yes":"No"]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-medium ndpr-text-foreground mb-2",children:"Processing Activity Description"}),jsxRuntime.jsx("p",{className:"ndpr-text-muted mb-4",children:s.processingDescription}),s.recommendations&&s.recommendations.length>0&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-medium ndpr-text-foreground mb-2",children:"Key Recommendations"}),jsxRuntime.jsx("ul",{className:"list-disc pl-5 ndpr-text-muted",children:s.recommendations.map((a,n)=>jsxRuntime.jsx("li",{className:r("","recommendation"),children:a},n))})]})]})]}),jsxRuntime.jsxs("div",{className:"mb-8",children:[jsxRuntime.jsx("h2",{className:"ndpr-section-heading",children:"Identified Risks"}),s.risks.length===0?jsxRuntime.jsx("p",{className:"ndpr-text-muted",children:"No risks identified."}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:r("min-w-full divide-y divide-gray-200 dark:divide-gray-700","riskTable"),children:[jsxRuntime.jsx("thead",{className:"ndpr-panel",children:jsxRuntime.jsxs("tr",{children:[jsxRuntime.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium ndpr-text-muted uppercase tracking-wider",children:"Risk"}),jsxRuntime.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium ndpr-text-muted uppercase tracking-wider",children:"Likelihood"}),jsxRuntime.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium ndpr-text-muted uppercase tracking-wider",children:"Impact"}),jsxRuntime.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium ndpr-text-muted uppercase tracking-wider",children:"Risk Level"}),jsxRuntime.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium ndpr-text-muted uppercase tracking-wider",children:"Mitigated"})]})}),jsxRuntime.jsx("tbody",{className:"ndpr-table",children:s.risks.map(a=>jsxRuntime.jsxs("tr",{className:r("","riskRow"),children:[jsxRuntime.jsx("td",{className:"ndpr-table__cell",children:a.description}),jsxRuntime.jsxs("td",{className:"ndpr-table__cell ndpr-table__cell--muted",children:[a.likelihood," / 5"]}),jsxRuntime.jsxs("td",{className:"ndpr-table__cell ndpr-table__cell--muted",children:[a.impact," / 5"]}),jsxRuntime.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm",children:A(a.level)}),jsxRuntime.jsx("td",{className:"ndpr-table__cell ndpr-table__cell--muted",children:a.mitigated?jsxRuntime.jsx("span",{className:"ndpr-text-success",children:"Yes"}):jsxRuntime.jsx("span",{className:"ndpr-text-destructive",children:"No"})})]},a.id))})]})})]}),g&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"ndpr-section-heading",children:"Full Assessment Details"}),c.map(a=>{let n=a.questions.filter(i=>s.answers[i.id]!==void 0);return n.length===0?null:jsxRuntime.jsxs("div",{className:"mb-6",children:[jsxRuntime.jsx("h3",{className:"text-lg font-medium ndpr-text-foreground mb-2",children:a.title}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[jsxRuntime.jsx("thead",{className:"ndpr-panel",children:jsxRuntime.jsxs("tr",{children:[jsxRuntime.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium ndpr-text-muted uppercase tracking-wider",children:"Question"}),jsxRuntime.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium ndpr-text-muted uppercase tracking-wider",children:"Answer"})]})}),jsxRuntime.jsx("tbody",{className:"ndpr-table",children:n.map(i=>jsxRuntime.jsxs("tr",{children:[jsxRuntime.jsx("td",{className:"ndpr-table__cell",children:i.text}),jsxRuntime.jsx("td",{className:"px-6 py-4 whitespace-normal text-sm ndpr-text-muted",children:R(i.id)})]},i.id))})]})})]},a.id)})]}),jsxRuntime.jsxs("div",{className:"mt-8 pt-4 border-t border-gray-200 dark:border-gray-700 text-sm ndpr-text-muted",children:[jsxRuntime.jsx("p",{children:"This DPIA was conducted in accordance with NDPA 2023 Section 28."}),jsxRuntime.jsxs("p",{children:["DPIA Report Version: ",s.version]}),jsxRuntime.jsxs("p",{children:["Generated on: ",m]}),jsxRuntime.jsx("p",{className:"mt-2 italic",role:"note",children:chunkZVOIR4QH_js.a})]})]})};var Y=({steps:s,onStepClick:c,clickable:g=true,orientation:v="horizontal",className:f="",activeStepClassName:b="",completedStepClassName:w="",incompleteStepClassName:x="",classNames:h={},unstyled:k=false})=>{let d=(r,o)=>chunkAME4HJR4_js.a(r,o?h[o]:void 0,k),N=r=>{g&&c&&c(r);},m=v==="vertical";return jsxRuntime.jsx("div",{"data-ndpr-component":"dpia-step-indicator",role:"navigation","aria-label":"Step progress",className:`${d(m?"flex flex-col space-y-4":"flex items-center justify-between","root")} ${f}`,children:s.map((r,o)=>{let C=o===s.length-1,D=r.active?d(`font-medium ${b||"ndpr-text-primary"}`,"label"):r.completed?d(w||"ndpr-text-success","label"):d(x||"ndpr-card__subtitle","label"),R=r.active?d("flex items-center justify-center w-8 h-8 rounded-full bg-[rgb(var(--ndpr-primary)/0.1)] dark:bg-[rgb(var(--ndpr-primary)/0.2)] ndpr-text-primary border-2 border-[rgb(var(--ndpr-primary))] dark:border-[rgb(var(--ndpr-primary))]","stepActive"):r.completed?d("flex items-center justify-center w-8 h-8 rounded-full bg-green-100 dark:bg-green-900 ndpr-text-success border-2 border-green-600 dark:border-green-400","stepCompleted"):d("flex items-center justify-center w-8 h-8 rounded-full bg-gray-100 dark:bg-gray-700 ndpr-text-muted border-2 border-gray-300 dark:border-gray-600","stepPending"),p=g&&!!c;return jsxRuntime.jsxs(T__default.default.Fragment,{children:[jsxRuntime.jsxs("div",{className:d(`${m?"flex items-start":"flex flex-col items-center"} ${g?"cursor-pointer":""}`,"step"),role:p?"button":void 0,tabIndex:p?0:void 0,"aria-label":p?`Go to step ${o+1}: ${r.label}`:void 0,onClick:p?()=>N(r.id):void 0,onKeyDown:p?u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),N(r.id));}:void 0,"aria-current":r.active?"step":void 0,children:[jsxRuntime.jsx("div",{className:`
|
|
2
|
+
flex items-center justify-center
|
|
3
|
+
${m?"mr-4":""}
|
|
4
|
+
`,children:jsxRuntime.jsx("div",{className:R,children:r.icon?r.icon:r.completed?jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}):jsxRuntime.jsx("span",{children:o+1})})}),jsxRuntime.jsxs("div",{className:`
|
|
5
|
+
${m?"flex-1":"mt-2 text-center"}
|
|
6
|
+
`,children:[jsxRuntime.jsx("div",{className:`text-sm font-medium ${D}`,children:r.label}),r.description&&jsxRuntime.jsx("div",{className:"ndpr-form-field__hint",children:r.description})]})]}),!C&&jsxRuntime.jsx("div",{className:d(m?"ml-4 h-8 border-l-2 border-gray-300 dark:border-gray-600":"w-full border-t-2 border-gray-300 dark:border-gray-600 hidden sm:block","connector")})]},r.id)})})};exports.a=G;exports.b=Y;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkF5MGMNQF_js=require('./chunk-F5MGMNQF.js'),chunkNUOHT3LO_js=require('./chunk-NUOHT3LO.js'),chunkRFPLZDIO_js=require('./chunk-RFPLZDIO.js'),react=require('react'),jsxRuntime=require('react/jsx-runtime');var C=d=>{var o=d,{template:e,templateOverrides:r,initialContext:t,copy:s}=o,l=chunkRFPLZDIO_js.c(o,["template","templateOverrides","initialContext","copy"]);let n=react.useMemo(()=>{if(t)return t;if(e)return chunkNUOHT3LO_js.b(e,r)},[t,e,r]);return jsxRuntime.jsx(chunkF5MGMNQF_js.a,chunkRFPLZDIO_js.b(chunkRFPLZDIO_js.a({},l),{initialContext:n}))};exports.a=C;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {c as c$1,d,b as b$1}from'./chunk-NBQQ2GN3.mjs';import {a}from'./chunk-SFGW37LE.mjs';import {c}from'./chunk-FRQFU44F.mjs';import {d as d$1,b,a as a$1}from'./chunk-ZJYULEER.mjs';import {useId,useState,useEffect}from'react';import {jsxs,jsx}from'react/jsx-runtime';var Ee=({sections:E=c$1,variables:R=d,onGenerate:S,title:F,description:A,className:N="",buttonClassName:P="",generateButtonText:Y,showPreview:q=true,allowEditing:Q=true,classNames:t,unstyled:y=false})=>{var W,de,ae;let B=c(),Z=(W=F!=null?F:B.policy.generatorTitle)!=null?W:"NDPA Privacy Policy Generator",l=(de=A!=null?A:B.policy.generatorDescription)!=null?de:"Generate an NDPA-compliant privacy policy for your organization in accordance with NDPA Section 24.",i=(ae=Y!=null?Y:B.policy.generate)!=null?ae:"Generate Policy",m=useId(),[L,ee]=useState(E),[b$2,k]=useState(R),[g,$]=useState("sections"),[X,H]=useState(""),[U,M]=useState(""),[ne,T]=useState(false),[h,G]=useState({});useEffect(()=>{ee(E);},[E]),useEffect(()=>{k(R);},[R]);let oe=p=>{ee(c=>c.map(e=>e.id===p?b(a$1({},e),{included:!e.included}):e));},I=(p,c)=>{k(e=>e.map(d=>d.id===p?b(a$1({},d),{value:c}):d)),h[p]&&G(e=>{let d=a$1({},e);return delete d[p],d});},ie=()=>{let p={},c=true;return b$2.forEach(e=>{e.required&&!e.value&&(p[e.id]=`${e.name} is required`,c=false);}),G(p),c},re=()=>{if(!ie()){$("variables");return}let p=L.filter(d=>d.included),c=Object.fromEntries(b$2.map(d=>[d.name,d.value])),e="";p.forEach(d=>{e+=`## ${d.title}
|
|
2
|
+
|
|
3
|
+
`,e+=b$1(d.template,c),e+=`
|
|
4
|
+
|
|
5
|
+
`;}),H(e),M(e),T(true),$("preview");},V=()=>{S({sections:L,variables:b$2,content:Q?U:X});},u=()=>jsxs("div",{"data-ndpr-component":"policy-generator",className:a("ndpr-form-section",t==null?void 0:t.sectionList,y),role:"group","aria-labelledby":`${m}-sections-heading`,children:[jsx("h3",{id:`${m}-sections-heading`,className:"text-lg font-medium mb-4",children:"Select Policy Sections"}),L.map(p=>{let c=`${m}-section-${p.id}`,e=p.description?`${m}-section-desc-${p.id}`:void 0;return jsx("div",{className:a("border border-gray-200 dark:border-gray-700 rounded-md p-4",t==null?void 0:t.sectionItem,y),children:jsxs("div",{className:"flex items-start",children:[jsx("div",{className:"flex items-center h-5",children:jsx("input",{id:c,type:"checkbox",checked:p.included,onChange:()=>oe(p.id),disabled:p.required,"aria-describedby":e,className:a("w-4 h-4 text-[rgb(var(--ndpr-primary))] border-gray-300 rounded focus:ring-[rgb(var(--ndpr-ring))] dark:focus:ring-[rgb(var(--ndpr-ring))] dark:ring-offset-gray-800 dark:focus:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600",t==null?void 0:t.input,y)})}),jsxs("div",{className:"ml-3 text-sm",children:[jsxs("label",{htmlFor:c,className:"font-medium ndpr-text-foreground",children:[p.title," ",p.required&&jsx("span",{className:"text-red-500","aria-hidden":"true",children:"*"}),p.required&&jsx("span",{className:"sr-only",children:" (required)"})]}),p.description&&jsx("p",{id:e,className:"ndpr-text-muted mt-1",children:p.description})]})]})},p.id)}),jsx("div",{className:"mt-6",children:jsx("button",{onClick:()=>$("variables"),className:a(`px-4 py-2 bg-[rgb(var(--ndpr-primary))] text-white rounded hover:bg-[rgb(var(--ndpr-primary-hover))] ${P}`,(t==null?void 0:t.primaryButton)||(t==null?void 0:t.generateButton),y),children:"Next: Fill Variables"})})]}),f=()=>{let p={};return b$2.forEach(c=>{let e=c.id.split(".")[0];p[e]||(p[e]=[]),p[e].push(c);}),jsxs("div",{className:a("",t==null?void 0:t.form,y),children:[jsx("h3",{className:"text-lg font-medium mb-4",children:"Fill Policy Variables"}),jsx("div",{className:"ndpr-form-section",children:Object.entries(p).map(([c,e])=>{let d=L.find(r=>r.id===c);return d&&!d.included?null:jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-md p-4",children:[jsx("h4",{className:"font-medium text-lg mb-3",children:d?d.title:"General Information"}),jsx("div",{className:"ndpr-form-section",children:e.map(r=>{let O=`${m}-var-${r.id}`,j=r.description?`${m}-var-desc-${r.id}`:void 0,le=h[r.id]?`${m}-var-err-${r.id}`:void 0,J=[j,le].filter(Boolean).join(" ")||void 0;return jsxs("div",{children:[jsxs("label",{htmlFor:O,className:"ndpr-form-field__label",children:[r.name," ",r.required&&jsx("span",{className:"text-red-500","aria-hidden":"true",children:"*"})]}),r.description&&jsx("p",{id:j,className:"text-xs ndpr-text-muted mb-2",children:r.description}),r.inputType==="textarea"?jsx("textarea",{id:O,value:r.value,onChange:_=>I(r.id,_.target.value),rows:4,className:a(`w-full px-3 py-2 border ${h[r.id]?"border-red-500 focus:ring-red-500":"border-gray-300 dark:border-gray-600 focus:ring-[rgb(var(--ndpr-ring))]"} rounded-md focus:outline-none focus:ring-2`,t==null?void 0:t.input,y),required:r.required,"aria-required":r.required||void 0,"aria-describedby":J,"aria-invalid":h[r.id]?true:void 0}):r.inputType==="select"&&r.options?jsxs("select",{id:O,value:r.value,onChange:_=>I(r.id,_.target.value),className:a(`w-full px-3 py-2 border ${h[r.id]?"border-red-500 focus:ring-red-500":"border-gray-300 dark:border-gray-600 focus:ring-[rgb(var(--ndpr-ring))]"} rounded-md focus:outline-none focus:ring-2`,t==null?void 0:t.input,y),required:r.required,"aria-required":r.required||void 0,"aria-describedby":J,"aria-invalid":h[r.id]?true:void 0,children:[jsx("option",{value:"",children:"Select an option"}),r.options.map(_=>jsx("option",{value:_,children:_},_))]}):jsx("input",{id:O,type:r.inputType,value:r.value,onChange:_=>I(r.id,_.target.value),className:a(`w-full px-3 py-2 border ${h[r.id]?"border-red-500 focus:ring-red-500":"border-gray-300 dark:border-gray-600 focus:ring-[rgb(var(--ndpr-ring))]"} rounded-md focus:outline-none focus:ring-2`,t==null?void 0:t.input,y),required:r.required,"aria-required":r.required||void 0,"aria-describedby":J,"aria-invalid":h[r.id]?true:void 0}),h[r.id]&&jsx("p",{id:le,role:"alert",className:"mt-1 text-sm ndpr-text-destructive dark:text-red-500",children:h[r.id]})]},r.id)})})]},c)})}),jsxs("div",{className:"mt-6 flex space-x-4",children:[jsx("button",{onClick:()=>$("sections"),className:`px-4 py-2 bg-gray-200 text-gray-800 dark:bg-gray-700 dark:text-white rounded hover:bg-gray-300 dark:hover:bg-gray-600 ${P}`,children:"Back to Sections"}),jsx("button",{onClick:re,className:a(`px-4 py-2 bg-[rgb(var(--ndpr-primary))] text-white rounded hover:bg-[rgb(var(--ndpr-primary-hover))] ${P}`,(t==null?void 0:t.primaryButton)||(t==null?void 0:t.generateButton),y),children:i})]})]})},x=()=>{let p=`${m}-policy-content`;return jsxs("div",{children:[jsx("h3",{className:"text-lg font-medium mb-4",children:"Preview Generated Policy"}),Q?jsxs("div",{className:"ndpr-form-field",children:[jsx("label",{htmlFor:p,className:"ndpr-form-field__label",children:"Edit Policy Content"}),jsx("textarea",{id:p,value:U,onChange:c=>M(c.target.value),rows:20,className:"ndpr-form-field__input ndpr-form-field__input--mono"})]}):jsx("div",{className:"ndpr-panel","aria-live":"polite",children:jsx("div",{className:"prose dark:prose-invert max-w-none",children:X.split(`
|
|
6
|
+
`).map((c,e)=>c.startsWith("## ")?jsx("h3",{className:"text-xl font-bold mt-6 mb-3",children:c.substring(3)},e):c.startsWith("### ")?jsx("h4",{className:"text-lg font-bold mt-4 mb-2",children:c.substring(4)},e):c===""?jsx("br",{},e):jsx("p",{className:"mb-2",children:c},e))})}),jsxs("div",{className:"mt-6 flex space-x-4",children:[jsx("button",{onClick:()=>$("variables"),className:`px-4 py-2 bg-gray-200 text-gray-800 dark:bg-gray-700 dark:text-white rounded hover:bg-gray-300 dark:hover:bg-gray-600 ${P}`,children:"Back to Variables"}),jsx("button",{onClick:V,className:`px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700 ${P}`,children:"Save Policy"})]})]})},C=()=>{switch(g){case "sections":return u();case "variables":return f();case "preview":return x();default:return u()}};return jsxs("div",{className:a(`bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md ${N}`,t==null?void 0:t.root,y),children:[jsxs("div",{className:a("mb-6",t==null?void 0:t.header,y),children:[jsx("h2",{className:a("ndpr-section-heading",t==null?void 0:t.title,y),children:Z}),jsx("p",{className:a("ndpr-card__subtitle",t==null?void 0:t.description,y),children:l})]}),jsx("nav",{"aria-label":"Policy generation steps",className:"mb-8",children:jsxs("ol",{className:"flex items-center w-full",children:[jsxs("li",{className:`flex w-full items-center ${g==="sections"?"ndpr-text-primary":"ndpr-card__subtitle"} after:content-[''] after:w-full after:h-1 after:border-b after:border-gray-200 after:border-1 after:hidden sm:after:inline-block after:mx-6 xl:after:mx-10`,children:[jsx("span",{className:`flex items-center justify-center w-8 h-8 ${g==="sections"?"ndpr-alert ndpr-alert--info":"ndpr-panel"} rounded-full shrink-0`,"aria-current":g==="sections"?"step":void 0,children:"1"}),jsx("span",{className:"hidden sm:inline-flex sm:ml-2",children:"Sections"}),jsx("span",{className:"sr-only",children:g==="sections"?" (current step)":""})]}),jsxs("li",{className:`flex w-full items-center ${g==="variables"?"ndpr-text-primary":"ndpr-card__subtitle"} after:content-[''] after:w-full after:h-1 after:border-b after:border-gray-200 after:border-1 after:hidden sm:after:inline-block after:mx-6 xl:after:mx-10`,children:[jsx("span",{className:`flex items-center justify-center w-8 h-8 ${g==="variables"?"ndpr-alert ndpr-alert--info":"ndpr-panel"} rounded-full shrink-0`,"aria-current":g==="variables"?"step":void 0,children:"2"}),jsx("span",{className:"hidden sm:inline-flex sm:ml-2",children:"Variables"}),jsx("span",{className:"sr-only",children:g==="variables"?" (current step)":""})]}),jsxs("li",{className:`flex items-center ${g==="preview"?"ndpr-text-primary":"ndpr-card__subtitle"}`,children:[jsx("span",{className:`flex items-center justify-center w-8 h-8 ${g==="preview"?"ndpr-alert ndpr-alert--info":"ndpr-panel"} rounded-full shrink-0`,"aria-current":g==="preview"?"step":void 0,children:"3"}),jsx("span",{className:"hidden sm:inline-flex sm:ml-2",children:"Preview"}),jsx("span",{className:"sr-only",children:g==="preview"?" (current step)":""})]})]})}),jsxs("div",{className:a("ndpr-alert ndpr-alert--info",t==null?void 0:t.complianceNotice,y),children:[jsx("h3",{className:"text-sm font-bold ndpr-text-info mb-2",children:"NDPA Compliance Notice"}),jsx("p",{className:"ndpr-text-info text-sm",children:"This tool helps you generate a privacy policy that aligns with the Nigeria Data Protection Act (NDPA) 2023. While we strive to ensure compliance, we recommend having the final policy reviewed by a legal professional familiar with NDPA requirements."})]}),C()]})};var Ie=({content:E,sections:R,variables:S,onExport:F,onEdit:A,title:N,description:P,className:Y="",buttonClassName:q="",showExportOptions:Q=true,showEditButton:t=true,showTableOfContents:y=true,showMetadata:B=true,organizationName:Z,lastUpdated:l,classNames:i,unstyled:m=false})=>{var re,V;let L=c(),ee=(re=N!=null?N:L.policy.previewTitle)!=null?re:"Privacy Policy Preview",b=(V=P!=null?P:L.policy.previewDescription)!=null?V:"Preview your NDPA-compliant privacy policy before exporting.",k=useId(),[g,$]=useState("preview"),X=`${k}-tab-preview`,H=`${k}-tab-markdown`,U=`${k}-panel-preview`,M=`${k}-panel-markdown`,T=(()=>{let u=E.split(`
|
|
7
|
+
`),f=[];return u.forEach(x=>{if(x.startsWith("## ")){let C=x.substring(3).trim(),W=`${k}-${C.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`;f.push({id:W,title:C,level:2});}else if(x.startsWith("### ")){let C=x.substring(4).trim(),W=`${k}-${C.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`;f.push({id:W,title:C,level:3});}}),f})(),h=u=>{if(F)F(u);else if(u==="markdown"){let f=document.createElement("a"),x=new Blob([E],{type:"text/markdown"});f.href=URL.createObjectURL(x),f.download=`privacy-policy-${new Date().toISOString().split("T")[0]}.md`,document.body.appendChild(f),f.click(),document.body.removeChild(f);}},G=()=>!y||T.length===0?null:jsxs("nav",{"aria-label":"Table of contents",className:"ndpr-panel",children:[jsx("h3",{className:"text-lg font-medium mb-3",children:"Table of Contents"}),jsx("ul",{className:"space-y-1",children:T.map((u,f)=>jsx("li",{style:{marginLeft:`${(u.level-2)*1.5}rem`},children:jsx("a",{href:`#${u.id}`,className:"ndpr-text-primary hover:underline",children:u.title})},f))})]}),oe=()=>B?jsxs("div",{"data-ndpr-component":"policy-preview",className:"mb-6",children:[jsx("h1",{className:"ndpr-card__title",children:Z?`${Z} Privacy Policy`:"Privacy Policy"}),jsxs("p",{className:"ndpr-form-field__hint",children:["Last Updated: ",l?l.toLocaleDateString():"N/A"]})]}):null,I=()=>jsx("div",{className:a("prose dark:prose-invert max-w-none",i==null?void 0:i.sectionContent,m),children:E.split(`
|
|
8
|
+
`).map((u,f)=>{if(u.startsWith("## ")){let x=u.substring(3).trim(),C=`${k}-${x.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`;return jsx("h3",{id:C,className:a("text-xl font-bold mt-6 mb-3",i==null?void 0:i.sectionTitle,m),children:x},f)}else if(u.startsWith("### ")){let x=u.substring(4).trim(),C=`${k}-${x.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`;return jsx("h4",{id:C,className:a("text-lg font-bold mt-4 mb-2",i==null?void 0:i.sectionTitle,m),children:x},f)}else return u===""?jsx("br",{},f):jsx("p",{className:"mb-2",children:u},f)})}),ie=()=>Q?jsxs("div",{className:"mt-6",children:[jsx("h3",{className:"text-lg font-medium mb-3",children:"Export Options"}),jsxs("div",{className:"ndpr-card__footer",children:[jsx("button",{onClick:()=>h("pdf"),className:`px-4 py-2 bg-[rgb(var(--ndpr-primary))] text-white rounded hover:bg-[rgb(var(--ndpr-primary-hover))] ${q}`,children:"Export as PDF"}),jsx("button",{onClick:()=>h("docx"),className:`px-4 py-2 bg-[rgb(var(--ndpr-primary))] text-white rounded hover:bg-[rgb(var(--ndpr-primary-hover))] ${q}`,children:"Export as DOCX"}),jsx("button",{onClick:()=>h("html"),className:`px-4 py-2 bg-[rgb(var(--ndpr-primary))] text-white rounded hover:bg-[rgb(var(--ndpr-primary-hover))] ${q}`,children:"Export as HTML"}),jsx("button",{onClick:()=>h("markdown"),className:`px-4 py-2 bg-[rgb(var(--ndpr-primary))] text-white rounded hover:bg-[rgb(var(--ndpr-primary-hover))] ${q}`,children:"Export as Markdown"})]})]}):null;return jsxs("div",{className:a(`bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md ${Y}`,i==null?void 0:i.root,m),children:[jsxs("div",{className:a("flex justify-between items-start mb-6",i==null?void 0:i.header,m),children:[jsxs("div",{children:[jsx("h2",{className:a("ndpr-section-heading",i==null?void 0:i.title,m),children:ee}),jsx("p",{className:a("ndpr-card__subtitle",i==null?void 0:i.description,m),children:b})]}),t&&A&&jsx("button",{onClick:A,className:`px-4 py-2 bg-gray-200 text-gray-800 dark:bg-gray-700 dark:text-white rounded hover:bg-gray-300 dark:hover:bg-gray-600 ${q}`,children:"Edit Policy"})]}),jsxs("div",{className:a("ndpr-alert ndpr-alert--info",i==null?void 0:i.complianceNotice,m),children:[jsx("h3",{className:"text-sm font-bold ndpr-text-info mb-2",children:"NDPA Compliance Notice"}),jsx("p",{className:"ndpr-text-info text-sm",children:"This privacy policy has been generated to align with the Nigeria Data Protection Act (NDPA) 2023. We recommend having the final policy reviewed by a legal professional familiar with NDPA requirements before publishing it on your website or sharing it with your users."})]}),jsx("div",{className:"mb-6 border-b border-gray-200 dark:border-gray-700",children:jsxs("div",{role:"tablist","aria-label":"Policy view options",className:"flex flex-wrap -mb-px",children:[jsx("div",{className:"mr-2",children:jsx("button",{role:"tab",id:X,"aria-selected":g==="preview","aria-controls":U,onClick:()=>$("preview"),className:`inline-block p-4 ${g==="preview"?"text-[rgb(var(--ndpr-primary))] border-b-2 border-[rgb(var(--ndpr-primary))] dark:text-[rgb(var(--ndpr-primary))] dark:border-[rgb(var(--ndpr-primary))]":"text-gray-600 hover:text-gray-700 hover:border-gray-300 dark:text-gray-400 dark:hover:text-gray-300"}`,children:"Preview"})}),jsx("div",{className:"mr-2",children:jsx("button",{role:"tab",id:H,"aria-selected":g==="markdown","aria-controls":M,onClick:()=>$("markdown"),className:`inline-block p-4 ${g==="markdown"?"text-[rgb(var(--ndpr-primary))] border-b-2 border-[rgb(var(--ndpr-primary))] dark:text-[rgb(var(--ndpr-primary))] dark:border-[rgb(var(--ndpr-primary))]":"text-gray-600 hover:text-gray-700 hover:border-gray-300 dark:text-gray-400 dark:hover:text-gray-300"}`,children:"Markdown"})})]})}),jsx("div",{className:a("bg-white dark:bg-gray-800 p-4 rounded-md",i==null?void 0:i.content,m),children:g==="preview"?jsxs("div",{role:"tabpanel",id:U,"aria-labelledby":X,"aria-live":"polite",children:[oe(),G(),jsx("div",{className:a("bg-gray-50 dark:bg-gray-700 p-6 rounded-md",i==null?void 0:i.section,m),children:I()})]}):jsx("div",{role:"tabpanel",id:M,"aria-labelledby":H,children:jsx("pre",{className:"bg-gray-50 dark:bg-gray-700 p-4 rounded-md overflow-auto whitespace-pre-wrap font-mono text-sm text-gray-800 dark:text-gray-200",children:E})})}),ie()]})};var Me=({content:E,title:R,organizationName:S,lastUpdated:F,onExportComplete:A,componentTitle:N="Export Privacy Policy",description:P,className:Y="",buttonClassName:q="",showExportHistory:Q=true,includeComplianceNotice:t=true,includeLogo:y=false,logoUrl:B,customStyles:Z,classNames:l,unstyled:i=false})=>{var p,c$1;let m=c(),L=(p=R!=null?R:m.policy.exporterTitle)!=null?p:"Privacy Policy",ee=(c$1=P!=null?P:m.policy.exporterDescription)!=null?c$1:"Export your NDPA-compliant privacy policy in various formats.",b=useId(),[k,g]=useState([]),[$,X]=useState("pdf"),[H,U]=useState(false),[M,ne]=useState(null),[T,h]=useState(""),[G,oe]=useState(""),[I,ie]=useState(""),[re,V]=useState(false),u=e=>{let d=new Date().toISOString().split("T")[0];return `${S?S.toLowerCase().replace(/[^a-z0-9]+/g,"-"):"privacy-policy"}-privacy-policy-${d}.${e.toLowerCase()}`},f=e=>T?T.endsWith(`.${e.toLowerCase()}`)?T:`${T}.${e.toLowerCase()}`:u(e),x=()=>{let e=S?`${S} ${L}`:L,d=F?F.toLocaleDateString():"N/A",r=`<!DOCTYPE html>
|
|
9
|
+
<html lang="en">
|
|
10
|
+
<head>
|
|
11
|
+
<meta charset="UTF-8">
|
|
12
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
13
|
+
<title>${e}</title>
|
|
14
|
+
<style>
|
|
15
|
+
body {
|
|
16
|
+
font-family: Arial, sans-serif;
|
|
17
|
+
line-height: 1.6;
|
|
18
|
+
color: #333;
|
|
19
|
+
max-width: 800px;
|
|
20
|
+
margin: 0 auto;
|
|
21
|
+
padding: 20px;
|
|
22
|
+
}
|
|
23
|
+
h1 {
|
|
24
|
+
font-size: 24px;
|
|
25
|
+
margin-bottom: 10px;
|
|
26
|
+
}
|
|
27
|
+
h2 {
|
|
28
|
+
font-size: 20px;
|
|
29
|
+
margin-top: 30px;
|
|
30
|
+
margin-bottom: 10px;
|
|
31
|
+
border-bottom: 1px solid #eee;
|
|
32
|
+
padding-bottom: 5px;
|
|
33
|
+
}
|
|
34
|
+
h3 {
|
|
35
|
+
font-size: 18px;
|
|
36
|
+
margin-top: 20px;
|
|
37
|
+
margin-bottom: 10px;
|
|
38
|
+
}
|
|
39
|
+
p {
|
|
40
|
+
margin-bottom: 15px;
|
|
41
|
+
}
|
|
42
|
+
.header {
|
|
43
|
+
text-align: center;
|
|
44
|
+
margin-bottom: 30px;
|
|
45
|
+
}
|
|
46
|
+
.footer {
|
|
47
|
+
margin-top: 50px;
|
|
48
|
+
text-align: center;
|
|
49
|
+
font-size: 12px;
|
|
50
|
+
color: #666;
|
|
51
|
+
border-top: 1px solid #eee;
|
|
52
|
+
padding-top: 20px;
|
|
53
|
+
}
|
|
54
|
+
.logo {
|
|
55
|
+
max-width: 200px;
|
|
56
|
+
margin-bottom: 20px;
|
|
57
|
+
}
|
|
58
|
+
.last-updated {
|
|
59
|
+
font-size: 12px;
|
|
60
|
+
color: #666;
|
|
61
|
+
margin-bottom: 30px;
|
|
62
|
+
}
|
|
63
|
+
.compliance-notice {
|
|
64
|
+
background-color: #f8f9fa;
|
|
65
|
+
border: 1px solid #e9ecef;
|
|
66
|
+
padding: 15px;
|
|
67
|
+
margin-bottom: 30px;
|
|
68
|
+
font-size: 14px;
|
|
69
|
+
}
|
|
70
|
+
${Z||""}
|
|
71
|
+
</style>
|
|
72
|
+
</head>
|
|
73
|
+
<body>
|
|
74
|
+
<div class="header">
|
|
75
|
+
${y&&B?`<img src="${B}" alt="${S||"Company"} Logo" class="logo">`:""}
|
|
76
|
+
${G?`<div class="custom-header">${G}</div>`:""}
|
|
77
|
+
<h1>${e}</h1>
|
|
78
|
+
<div class="last-updated">Last Updated: ${d}</div>
|
|
79
|
+
</div>`;t&&(r+=`
|
|
80
|
+
<div class="compliance-notice">
|
|
81
|
+
<strong>NDPA Compliance Notice:</strong> This privacy policy has been created to comply with the Nigeria Data Protection Act (NDPA) 2023.
|
|
82
|
+
It outlines how we collect, use, disclose, and protect your personal information in accordance with NDPA requirements.
|
|
83
|
+
</div>`);let O=E.replace(/^## (.*?)$/gm,"<h2>$1</h2>").replace(/^### (.*?)$/gm,"<h3>$1</h3>").replace(/\n\n/g,"</p><p>").replace(/\n/g,"<br>");return r+=`
|
|
84
|
+
<div class="content">
|
|
85
|
+
<p>${O}</p>
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<div class="footer">
|
|
89
|
+
${I?`<div class="custom-footer">${I}</div>`:""}
|
|
90
|
+
<p>© ${new Date().getFullYear()} ${S||"Company"}. All rights reserved.</p>
|
|
91
|
+
</div>
|
|
92
|
+
</body>
|
|
93
|
+
</html>`,r},C=()=>d$1(null,null,function*(){U(true),ne(null);try{let e=$.toLowerCase(),d="",r;switch(e){case "pdf":let J=x();r=new Blob([J],{type:"text/html"}),d=URL.createObjectURL(r);break;case "docx":r=new Blob([E],{type:"text/plain"}),d=URL.createObjectURL(r);break;case "html":let _=x();r=new Blob([_],{type:"text/html"}),d=URL.createObjectURL(r);break;default:r=new Blob([E],{type:"text/markdown"}),d=URL.createObjectURL(r);break}let O=f(e),j=document.createElement("a");j.href=d,j.download=O,document.body.appendChild(j),j.click(),document.body.removeChild(j);let le={id:`export_${Date.now()}`,format:e,timestamp:Date.now(),url:d,filename:O};g(J=>[le,...J]),A&&A(e,d);}catch(e){console.error("[ndpr-toolkit/policy] Export failed:",e);let d=e instanceof Error&&e.message?e.message.length>200?`${e.message.slice(0,200)}\u2026`:e.message:null;ne(d?`[ndpr-toolkit/policy] Export failed: ${d}`:"[ndpr-toolkit/policy] Export failed \u2014 see the browser console for the underlying error.");}finally{U(false);}}),W=()=>{let e=[{value:"pdf",label:"PDF Document (.pdf)"},{value:"docx",label:"Word Document (.docx)"},{value:"html",label:"Web Page (.html)"},{value:"markdown",label:"Markdown (.md)"}],d=`${b}-export-format`;return jsxs("div",{"data-ndpr-component":"policy-exporter",className:a("mb-6",l==null?void 0:l.formatSelector,i),children:[jsx("label",{htmlFor:d,className:"ndpr-form-field__label",children:"Export Format"}),jsx("select",{id:d,value:$,onChange:r=>X(r.target.value),className:a("ndpr-form-field__input",l==null?void 0:l.formatOption,i),children:e.map(r=>jsx("option",{value:r.value,children:r.label},r.value))})]})},de=()=>re?jsxs("div",{className:"mb-6 space-y-4 border border-gray-200 dark:border-gray-700 rounded-md p-4",children:[jsxs("div",{className:"flex justify-between items-center",children:[jsx("h3",{className:"text-md font-medium",children:"Advanced Export Options"}),jsx("button",{type:"button",onClick:()=>V(false),className:"ndpr-text-primary text-sm",children:"Hide Advanced Options"})]}),jsxs("div",{children:[jsx("label",{htmlFor:`${b}-custom-filename`,className:"ndpr-form-field__label",children:"Custom Filename"}),jsx("input",{type:"text",id:`${b}-custom-filename`,value:T,onChange:e=>h(e.target.value),placeholder:u($),"aria-describedby":`${b}-custom-filename-desc`,className:"ndpr-form-field__input"}),jsx("p",{id:`${b}-custom-filename-desc`,className:"ndpr-form-field__hint",children:"Leave blank to use the default filename format."})]}),jsxs("div",{children:[jsx("label",{htmlFor:`${b}-custom-header`,className:"ndpr-form-field__label",children:"Custom Header HTML (for HTML/PDF exports)"}),jsx("textarea",{id:`${b}-custom-header`,value:G,onChange:e=>oe(e.target.value),rows:3,placeholder:"<div>Custom header content</div>",className:"ndpr-form-field__input"})]}),jsxs("div",{children:[jsx("label",{htmlFor:`${b}-custom-footer`,className:"ndpr-form-field__label",children:"Custom Footer HTML (for HTML/PDF exports)"}),jsx("textarea",{id:`${b}-custom-footer`,value:I,onChange:e=>ie(e.target.value),rows:3,placeholder:"<div>Custom footer content</div>",className:"ndpr-form-field__input"})]}),jsxs("div",{className:"flex items-start",children:[jsx("div",{className:"flex items-center h-5",children:jsx("input",{id:`${b}-include-compliance-notice`,type:"checkbox",checked:t,onChange:e=>V(e.target.checked),"aria-describedby":`${b}-compliance-notice-desc`,className:"w-4 h-4 text-[rgb(var(--ndpr-primary))] border-gray-300 rounded focus:ring-[rgb(var(--ndpr-ring))] dark:focus:ring-[rgb(var(--ndpr-ring))] dark:ring-offset-gray-800 dark:focus:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"})}),jsxs("div",{className:"ml-3 text-sm",children:[jsx("label",{htmlFor:`${b}-include-compliance-notice`,className:"font-medium ndpr-text-foreground",children:"Include NDPA Compliance Notice"}),jsx("p",{id:`${b}-compliance-notice-desc`,className:"ndpr-card__subtitle",children:"Adds a notice explaining that this policy complies with NDPA requirements."})]})]})]}):jsx("button",{type:"button",onClick:()=>V(true),className:"ndpr-text-primary text-sm mb-6",children:"Show Advanced Options"}),ae=()=>!Q||k.length===0?null:jsxs("div",{className:a("mt-6",l==null?void 0:l.preview,i),children:[jsx("h3",{className:"text-lg font-medium mb-3",children:"Export History"}),jsx("div",{className:"bg-gray-50 dark:bg-gray-700 rounded-md overflow-hidden",children:jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-600",children:[jsx("thead",{className:"bg-gray-100 dark:bg-gray-800",children:jsxs("tr",{children:[jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium ndpr-text-muted uppercase tracking-wider",children:"Date"}),jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium ndpr-text-muted uppercase tracking-wider",children:"Format"}),jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium ndpr-text-muted uppercase tracking-wider",children:"Filename"}),jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium ndpr-text-muted uppercase tracking-wider",children:"Actions"})]})}),jsx("tbody",{className:"bg-white dark:bg-gray-700 divide-y divide-gray-200 dark:divide-gray-600",children:k.map(e=>jsxs("tr",{children:[jsx("td",{className:"ndpr-table__cell",children:new Date(e.timestamp).toLocaleString()}),jsx("td",{className:"ndpr-table__cell",children:e.format.toUpperCase()}),jsx("td",{className:"ndpr-table__cell",children:e.filename}),jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:jsx("a",{href:e.url,download:e.filename,className:"ndpr-text-primary hover:text-[rgb(var(--ndpr-primary-hover))] dark:hover:text-[rgb(var(--ndpr-primary-hover))] mr-4",children:"Download"})})]},e.id))})]})})]});return jsxs("div",{className:a(`bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md ${Y}`,l==null?void 0:l.root,i),children:[jsxs("div",{className:a("mb-6",l==null?void 0:l.header,i),children:[jsx("h2",{className:a("ndpr-section-heading",l==null?void 0:l.title,i),children:N}),jsx("p",{className:a("ndpr-card__subtitle",l==null?void 0:l.description,i),children:ee})]}),W(),de(),jsxs("div",{className:"mb-6",children:[jsx("button",{onClick:C,disabled:H,className:a(`px-6 py-3 bg-[rgb(var(--ndpr-primary))] text-white rounded-md hover:bg-[rgb(var(--ndpr-primary-hover))] focus:outline-none focus:ring-2 focus:ring-[rgb(var(--ndpr-ring))] focus:ring-offset-2 ${q} ${H?"opacity-70 cursor-not-allowed":""}`,(l==null?void 0:l.primaryButton)||(l==null?void 0:l.exportButton),i),children:H?"Exporting...":`Export as ${$.toUpperCase()}`}),M&&jsx("p",{className:"mt-2 text-sm ndpr-text-destructive dark:text-red-500",children:M})]}),jsxs("div",{className:a("ndpr-alert ndpr-alert--info",l==null?void 0:l.complianceNotice,i),children:[jsx("h3",{className:"text-sm font-bold ndpr-text-info mb-2",children:"Export Tips"}),jsxs("ul",{className:"ndpr-text-info text-sm list-disc list-inside space-y-1",children:[jsx("li",{children:"PDF format is recommended for printing or sharing with stakeholders."}),jsx("li",{children:"HTML format is ideal for publishing on your website."}),jsx("li",{children:"DOCX format allows for further editing in Microsoft Word or similar applications."}),jsx("li",{children:"Markdown format is useful for version control systems or technical documentation."})]})]}),ae()]})};export{Ee as a,Ie as b,Me as c};
|