@molecule/app-danger-zone-react 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/README.md +192 -0
  2. package/package.json +14 -8
package/README.md ADDED
@@ -0,0 +1,192 @@
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-08-04T01:50:26.098Z
7
+ -->
8
+
9
+ # @molecule/app-danger-zone-react
10
+
11
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
+ > It is written to be read by coding agents as much as by people, and is generated from this
13
+ > package's source — edit `src/index.ts` JSDoc, not this file.
14
+
15
+ React destructive-action primitives.
16
+
17
+ Exports:
18
+
19
+ - `<DangerZoneSection>` — Card with title/description/button for delete/reset/revoke.
20
+ - `<ConfirmDialog>` — standalone "Are you sure?" modal.
21
+
22
+ ## Quick Start
23
+
24
+ ```tsx
25
+ import { ConfirmDialog, DangerZoneSection } from '@molecule/app-danger-zone-react'
26
+
27
+ <DangerZoneSection
28
+ title="Delete account"
29
+ description="This permanently removes your account and all data."
30
+ actionLabel="Delete account"
31
+ onAction={() => setConfirmOpen(true)}
32
+ />
33
+
34
+ <ConfirmDialog
35
+ open={confirmOpen}
36
+ onClose={() => setConfirmOpen(false)}
37
+ title="Delete account?"
38
+ description="This action cannot be undone."
39
+ confirmLabel="Delete"
40
+ onConfirm={handleDelete}
41
+ />
42
+ ```
43
+
44
+ ## Type
45
+
46
+ `feature`
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ npm install @molecule/app-danger-zone-react @molecule/app-react @molecule/app-ui @molecule/app-ui-react react
52
+ npm install -D @types/react
53
+ ```
54
+
55
+ ## API
56
+
57
+ ### Interfaces
58
+
59
+ #### `ConfirmDialogProps`
60
+
61
+ Props for {@link ConfirmDialog}.
62
+
63
+ ```typescript
64
+ interface ConfirmDialogProps {
65
+ /** Whether the dialog is open. */
66
+ open: boolean
67
+ /** Called when the dialog should close (escape, backdrop, cancel). */
68
+ onClose: () => void
69
+ /** Title. */
70
+ title: ReactNode
71
+ /** Body / warning text. */
72
+ description: ReactNode
73
+ /** Confirm-button label (e.g. "Delete"). */
74
+ confirmLabel?: ReactNode
75
+ /** Cancel-button label. */
76
+ cancelLabel?: ReactNode
77
+ /** Called when the user confirms. */
78
+ onConfirm: () => void | Promise<void>
79
+ /** Is the confirm action destructive? Defaults to true. */
80
+ destructive?: boolean
81
+ /** Extra body content between description and footer. */
82
+ children?: ReactNode
83
+ /** Disables both buttons. Set it yourself while your `onConfirm` promise is pending — the dialog does not track it and does not auto-close. */
84
+ loading?: boolean
85
+ }
86
+ ```
87
+
88
+ #### `DangerZoneSectionProps`
89
+
90
+ Props for {@link DangerZoneSection}.
91
+
92
+ ```typescript
93
+ interface DangerZoneSectionProps {
94
+ /** Section title. */
95
+ title: ReactNode
96
+ /** Explanation of the destructive action. */
97
+ description: ReactNode
98
+ /** Label on the action button (e.g. "Delete account"). */
99
+ actionLabel: ReactNode
100
+ /** Called when the button is clicked. */
101
+ onAction: () => void
102
+ /** When true, the button disables and shows a loading label. */
103
+ loading?: boolean
104
+ /** When true, the button is disabled without loading. */
105
+ disabled?: boolean
106
+ /** Additional content between description and button (e.g. a confirm-text input). */
107
+ children?: ReactNode
108
+ /** Extra classes on the Card. */
109
+ className?: string
110
+ /** `data-mol-id` for AI-agent selectors. */
111
+ dataMolId?: string
112
+ }
113
+ ```
114
+
115
+ ### Functions
116
+
117
+ #### `ConfirmDialog(props)`
118
+
119
+ Are-you-sure-style confirmation modal for destructive actions.
120
+
121
+ Use standalone (around delete buttons, revoke tokens, irreversible
122
+ migrations) or wrap DangerZoneSection's action with this dialog.
123
+
124
+ ```typescript
125
+ function ConfirmDialog({
126
+ open,
127
+ onClose,
128
+ title,
129
+ description,
130
+ confirmLabel,
131
+ cancelLabel,
132
+ onConfirm,
133
+ destructive = true,
134
+ children,
135
+ loading,
136
+ }: ConfirmDialogProps): JSX.Element
137
+ ```
138
+
139
+ - `props` — Component props (see {@link ConfirmDialogProps}).
140
+
141
+ #### `DangerZoneSection(props)`
142
+
143
+ Card-wrapped section for destructive actions — delete account,
144
+ reset data, revoke access. Uses the error/danger accent color and
145
+ puts the action on the right.
146
+
147
+ ```typescript
148
+ function DangerZoneSection({
149
+ title,
150
+ description,
151
+ actionLabel,
152
+ onAction,
153
+ loading,
154
+ disabled,
155
+ children,
156
+ className,
157
+ dataMolId,
158
+ }: DangerZoneSectionProps): JSX.Element
159
+ ```
160
+
161
+ - `props` — Component props (see {@link DangerZoneSectionProps}).
162
+
163
+ ## Injection Notes
164
+
165
+ ### Requirements
166
+
167
+ Peer dependencies:
168
+
169
+ - `@molecule/app-react` ^1.0.1
170
+ - `@molecule/app-ui` ^1.0.1
171
+ - `@molecule/app-ui-react` ^1.0.1
172
+ - `react` ^18.0.0 || ^19.0.0
173
+
174
+ ### Runtime Dependencies
175
+
176
+ - `@molecule/app-react`
177
+ - `@molecule/app-ui`
178
+ - `@molecule/app-ui-react`
179
+ - `react`
180
+
181
+ `<ConfirmDialog>` does NOT track `onConfirm`'s promise and does NOT close
182
+ itself on confirm: set `loading` yourself while the action runs, then call
183
+ `onClose()` when it settles — otherwise users can double-fire the
184
+ destructive action or be left staring at an open dialog. Cancel/Confirm
185
+ fall back to the `confirm.*` i18n keys (companion bond:
186
+ `@molecule/app-locales-danger-zone`); pass `confirmLabel`/`cancelLabel`
187
+ for action-specific wording ("Delete", "Revoke"). `destructive` (default
188
+ true) only switches the confirm button color.
189
+
190
+ ## Translations
191
+
192
+ Translation strings are provided by `@molecule/app-locales-danger-zone`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-danger-zone-react",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "DangerZoneSection + ConfirmDialog for destructive actions (delete account, reset, revoke)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -17,7 +17,8 @@
17
17
  }
18
18
  },
19
19
  "files": [
20
- "dist"
20
+ "dist",
21
+ "README.md"
21
22
  ],
22
23
  "keywords": [
23
24
  "molecule",
@@ -25,16 +26,21 @@
25
26
  "react"
26
27
  ],
27
28
  "license": "Apache-2.0",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/molecule-dev/molecule.git",
32
+ "directory": "packages/app/features/danger-zone-react"
33
+ },
28
34
  "peerDependencies": {
29
- "@molecule/app-react": "^1.0.0",
30
- "@molecule/app-ui": "^1.0.0",
31
- "@molecule/app-ui-react": "^1.0.0",
35
+ "@molecule/app-react": "^1.0.1",
36
+ "@molecule/app-ui": "^1.0.1",
37
+ "@molecule/app-ui-react": "^1.0.1",
32
38
  "react": "^18.0.0 || ^19.0.0"
33
39
  },
34
40
  "devDependencies": {
35
- "@molecule/app-react": "1.0.0",
36
- "@molecule/app-ui": "1.0.0",
37
- "@molecule/app-ui-react": "1.0.0",
41
+ "@molecule/app-react": "1.0.1",
42
+ "@molecule/app-ui": "1.0.1",
43
+ "@molecule/app-ui-react": "1.0.1",
38
44
  "@types/node": "26.1.2",
39
45
  "@types/react": "19.2.17",
40
46
  "@types/react-dom": "19.2.3",