@molecule/app-danger-zone-angular 0.0.0-stage → 0.0.1-stage

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.
@@ -0,0 +1,80 @@
1
+ /**
2
+ * DOM helpers for the projected-slot wrapper of {@link DangerZoneSection}.
3
+ *
4
+ * React renders the action label bare inside the button (`{loading ? '…' :
5
+ * actionLabel}`). Angular projection needs an always-mounted `<ng-content>`
6
+ * capture point, so the wrapper span lives in the template unconditionally
7
+ * and {@link SlotWrapper.sync} removes it from the DOM whenever React would
8
+ * not render it (loading, or no projected label).
9
+ *
10
+ * @module
11
+ */
12
+ /**
13
+ * Whether an ng-content wrapper captured any element or text node.
14
+ *
15
+ * @param el - The wrapper element.
16
+ * @returns True when at least one projected node exists.
17
+ */
18
+ export const hasNodes = (el) => {
19
+ if (!el)
20
+ return false;
21
+ for (const node of Array.from(el.childNodes)) {
22
+ if (node.nodeType === 1)
23
+ return true;
24
+ if (node.nodeType === 3 && (node.textContent ?? '').trim())
25
+ return true;
26
+ }
27
+ return false;
28
+ };
29
+ /**
30
+ * Attaches or detaches an always-mounted projection wrapper element from its
31
+ * parent, remembering the re-insertion position with a comment anchor the DOM
32
+ * normalizer strips.
33
+ */
34
+ export class SlotWrapper {
35
+ host;
36
+ renderer;
37
+ anchors = new Map();
38
+ /**
39
+ * Creates the wrapper helper.
40
+ *
41
+ * @param host - The component host element (default detach parent).
42
+ * @param renderer - The DOM renderer.
43
+ */
44
+ constructor(host, renderer) {
45
+ this.host = host;
46
+ this.renderer = renderer;
47
+ }
48
+ /**
49
+ * Attaches or detaches the element (default parent: the component host).
50
+ *
51
+ * @param el - The wrapper element.
52
+ * @param shouldAttach - Whether it should be in the DOM.
53
+ * @param parent - Where the element lives when attached (default: host).
54
+ */
55
+ sync(el, shouldAttach, parent) {
56
+ if (!el)
57
+ return;
58
+ const host = parent ?? this.host.nativeElement;
59
+ if (shouldAttach && !el.isConnected) {
60
+ const anchor = this.anchors.get(el);
61
+ if (anchor?.isConnected) {
62
+ host.insertBefore(el, anchor);
63
+ this.renderer.removeChild(host, anchor);
64
+ this.anchors.delete(el);
65
+ }
66
+ else {
67
+ host.appendChild(el);
68
+ }
69
+ }
70
+ else if (!shouldAttach && el.isConnected) {
71
+ // Placeholder comment keeps the re-insertion position stable; the
72
+ // normalizer strips comment nodes, so it never shows in snapshots.
73
+ const placeholder = this.renderer.createComment('slot');
74
+ host.insertBefore(placeholder, el);
75
+ this.anchors.set(el, placeholder);
76
+ this.renderer.removeChild(host, el);
77
+ }
78
+ }
79
+ }
80
+ //# sourceMappingURL=slot-dom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slot-dom.js","sourceRoot":"","sources":["../src/slot-dom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EAA8B,EAAW,EAAE;IAClE,IAAI,CAAC,EAAE;QAAE,OAAO,KAAK,CAAA;IACrB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7C,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC;YAAE,OAAO,IAAI,CAAA;QACpC,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;YAAE,OAAO,IAAI,CAAA;IACzE,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,OAAO,WAAW;IAUH;IACA;IAVF,OAAO,GAAG,IAAI,GAAG,EAAiB,CAAA;IAEnD;;;;;OAKG;IACH,YACmB,IAA6B,EAC7B,QAAmB;QADnB,SAAI,GAAJ,IAAI,CAAyB;QAC7B,aAAQ,GAAR,QAAQ,CAAW;IACnC,CAAC;IAEJ;;;;;;OAMG;IACH,IAAI,CAAC,EAA8B,EAAE,YAAqB,EAAE,MAAa;QACvE,IAAI,CAAC,EAAE;YAAE,OAAM;QACf,MAAM,IAAI,GAAS,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,aAAa,CAAA;QACpD,IAAI,YAAY,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;YACpC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;YACnC,IAAI,MAAM,EAAE,WAAW,EAAE,CAAC;gBACxB,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;gBAC7B,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;gBACvC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;YACzB,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;YACtB,CAAC;QACH,CAAC;aAAM,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YAC3C,kEAAkE;YAClE,mEAAmE;YACnE,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;YACvD,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;YAClC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,WAAW,CAAC,CAAA;YACjC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QACrC,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Types of `@molecule/app-danger-zone-angular` — the Angular counterpart of
3
+ * `@molecule/app-danger-zone-react`, same props and DOM.
4
+ *
5
+ * @module
6
+ */
7
+ /**
8
+ * Props accepted by {@link ConfirmDialog} — the same props
9
+ * `@molecule/app-danger-zone-react` accepts. Node-valued props (`title`,
10
+ * `description`) are projected content in Angular (an input cannot carry a
11
+ * node), so they are typed `unknown`; `children` is the element's default
12
+ * projection. Callbacks use React's names: the component's `close`/`confirm`
13
+ * outputs are the same contract.
14
+ */
15
+ export interface ConfirmDialogProps {
16
+ /** Whether the dialog is open. */
17
+ open: boolean;
18
+ /** Called when the dialog should close (escape, backdrop, cancel). */
19
+ onClose?: (event?: unknown) => void;
20
+ /** Title (nodes are `[slot=title]` content). */
21
+ title?: unknown;
22
+ /** Body / warning text (nodes are `[slot=description]` content). */
23
+ description?: unknown;
24
+ /** Confirm-button label (e.g. "Delete"). */
25
+ confirmLabel?: string;
26
+ /** Cancel-button label. */
27
+ cancelLabel?: string;
28
+ /** Called when the user confirms. */
29
+ onConfirm?: () => void | Promise<void>;
30
+ /** Is the confirm action destructive? Defaults to true. */
31
+ destructive?: boolean;
32
+ /** Extra body content between description and footer (default projection). */
33
+ children?: unknown;
34
+ /** Disables both buttons; the caller owns the pending state. */
35
+ loading?: boolean;
36
+ }
37
+ /**
38
+ * Props accepted by {@link DangerZoneSection} — the same props
39
+ * `@molecule/app-danger-zone-react` accepts. Node props (`title`,
40
+ * `description`, `actionLabel`, `children`) are projected content in Angular
41
+ * (an input cannot carry a node), so they are typed `unknown`: pass them in
42
+ * the host template (`[slot=title]`, `[slot=description]`,
43
+ * `[slot=actionLabel]` and default content), not as values.
44
+ */
45
+ export interface DangerZoneSectionProps {
46
+ /** Section title (string/number renders as text; nodes are `[slot=title]` content). */
47
+ title?: unknown;
48
+ /** Explanation of the destructive action (nodes are `[slot=description]` content). */
49
+ description?: unknown;
50
+ /** Label on the action button (nodes are `[slot=actionLabel]` content). */
51
+ actionLabel?: unknown;
52
+ /** Called when the button is clicked; receives the DOM click event. */
53
+ onAction?: (event: MouseEvent) => void;
54
+ /** When true, the button disables and shows a loading label. */
55
+ loading?: boolean;
56
+ /** When true, the button is disabled without loading. */
57
+ disabled?: boolean;
58
+ /** Additional content between description and button (e.g. a confirm-text input), projected as the element's default content. */
59
+ children?: unknown;
60
+ /** Extra classes on the Card (the host element). */
61
+ className?: string;
62
+ /** `data-mol-id` for AI-agent selectors. */
63
+ dataMolId?: string;
64
+ }
65
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,kCAAkC;IAClC,IAAI,EAAE,OAAO,CAAA;IACb,sEAAsE;IACtE,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IACnC,gDAAgD;IAChD,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,oEAAoE;IACpE,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACtC,2DAA2D;IAC3D,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,gEAAgE;IAChE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB;IACrC,uFAAuF;IACvF,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,sFAAsF;IACtF,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IACtC,gEAAgE;IAChE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,iIAAiI;IACjI,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
package/dist/types.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Types of `@molecule/app-danger-zone-angular` — the Angular counterpart of
3
+ * `@molecule/app-danger-zone-react`, same props and DOM.
4
+ *
5
+ * @module
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
package/package.json CHANGED
@@ -1,6 +1,71 @@
1
1
  {
2
2
  "name": "@molecule/app-danger-zone-angular",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1-stage",
4
+ "description": "DangerZoneSection + ConfirmDialog for destructive actions (delete account, reset, revoke)",
5
+ "homepage": "https://www.molecule.dev/packages/app-danger-zone-angular",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "ngc",
21
+ "dev": "ngc --watch",
22
+ "test": "vitest run",
23
+ "test:watch": "vitest"
24
+ },
25
+ "keywords": [
26
+ "molecule",
27
+ "danger-zone",
28
+ "angular"
29
+ ],
30
+ "author": "Molecule Dev, Inc. (https://molecule.dev)",
31
+ "license": "Apache-2.0",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/molecule-dev/molecule.git",
35
+ "directory": "packages/app/features/danger-zone-angular"
36
+ },
37
+ "engines": {
38
+ "node": ">=20"
39
+ },
40
+ "bugs": "https://github.com/molecule-dev/molecule/issues",
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "peerDependencies": {
45
+ "@angular/common": "^22.0.0",
46
+ "@angular/core": "^22.0.0",
47
+ "@angular/platform-browser": "^22.0.0",
48
+ "@molecule/app-angular": "^3.5.0",
49
+ "@molecule/app-ui": "^1.0.1",
50
+ "@molecule/app-ui-angular": "^1.1.0"
51
+ },
52
+ "devDependencies": {
53
+ "@angular/common": "22.2.3",
54
+ "@angular/compiler": "22.2.3",
55
+ "@angular/compiler-cli": "22.2.3",
56
+ "@angular/core": "22.2.3",
57
+ "@angular/platform-browser": "22.2.3",
58
+ "@molecule/app-angular": "3.6.0",
59
+ "@molecule/app-framework-conformance": "0.0.0",
60
+ "@molecule/app-i18n": "1.2.1",
61
+ "@molecule/app-icons": "1.0.4",
62
+ "@molecule/app-ui": "1.3.11",
63
+ "@molecule/app-ui-angular": "1.1.2",
64
+ "@types/node": "26.6.5",
65
+ "jsdom": "30.1.3",
66
+ "rxjs": "7.8.2",
67
+ "typescript": "6.0.3",
68
+ "vitest": "4.1.12",
69
+ "zone.js": "0.16.3"
70
+ }
71
+ }