@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.
- package/LICENSE +202 -0
- package/README.md +521 -2
- package/dist/confirm-dialog.d.ts +23 -0
- package/dist/confirm-dialog.d.ts.map +1 -0
- package/dist/confirm-dialog.js +23 -0
- package/dist/confirm-dialog.js.map +1 -0
- package/dist/danger-zone-section.component.d.ts +139 -0
- package/dist/danger-zone-section.component.d.ts.map +1 -0
- package/dist/danger-zone-section.component.js +299 -0
- package/dist/danger-zone-section.component.js.map +1 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/slot-dom.d.ts +45 -0
- package/dist/slot-dom.d.ts.map +1 -0
- package/dist/slot-dom.js +80 -0
- package/dist/slot-dom.js.map +1 -0
- package/dist/types.d.ts +65 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +69 -4
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DangerZoneSection component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { type AfterViewInit, type DoCheck, ElementRef } from '@angular/core';
|
|
7
|
+
import type { UIClassMap } from '@molecule/app-ui';
|
|
8
|
+
import * as i0 from "@angular/core";
|
|
9
|
+
/**
|
|
10
|
+
* DangerZoneSection component.
|
|
11
|
+
*
|
|
12
|
+
* Card-wrapped section for destructive actions — delete account, reset data,
|
|
13
|
+
* revoke access. Uses the error/danger accent color and puts the action on
|
|
14
|
+
* the right. The host IS the Card's `<div>`
|
|
15
|
+
* (`div[mol-danger-zone-section]`), matching React's root exactly; the Card
|
|
16
|
+
* classes (`cm.card({ variant: 'elevated' })` + `cm.cardPadding('md')`, the
|
|
17
|
+
* UI Card's defaults) are applied through the host class binding.
|
|
18
|
+
*
|
|
19
|
+
* The node props are projected slots: `title` renders inside the `<h3>`,
|
|
20
|
+
* `description` inside the `<p>`, `actionLabel` inside the action `<button>`,
|
|
21
|
+
* and `children` bare between the header and the button row (React renders
|
|
22
|
+
* `{children}` with no wrapper). String inputs render as text instead — the
|
|
23
|
+
* same values React renders. The action label's capture wrapper detaches
|
|
24
|
+
* while `loading` is true: React shows the `…` glyph instead of the label.
|
|
25
|
+
*/
|
|
26
|
+
export declare class DangerZoneSection implements AfterViewInit, DoCheck {
|
|
27
|
+
/** Section title (string/number renders as text; nodes are `[slot=title]` content). */
|
|
28
|
+
title?: unknown;
|
|
29
|
+
/** Explanation of the destructive action (string/number as text; nodes are `[slot=description]` content). */
|
|
30
|
+
description?: unknown;
|
|
31
|
+
/** Label on the action button (string/number as text; nodes are `[slot=actionLabel]` content). */
|
|
32
|
+
actionLabel?: unknown;
|
|
33
|
+
/** When true, the button disables and shows a loading label. */
|
|
34
|
+
loading?: boolean;
|
|
35
|
+
/** When true, the button is disabled without loading. */
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
/** Extra classes on the Card. */
|
|
38
|
+
className?: string;
|
|
39
|
+
/** `data-mol-id` for AI-agent selectors. */
|
|
40
|
+
dataMolId?: string;
|
|
41
|
+
/** Called when the button is clicked; receives the DOM click event (React's `onAction`). */
|
|
42
|
+
onAction?: (event: MouseEvent) => void;
|
|
43
|
+
/** The action label's capture wrapper (moved out of the DOM once read). */
|
|
44
|
+
labelSlot?: ElementRef<HTMLSpanElement>;
|
|
45
|
+
/** Whether the action label slot holds projected content (read once). */
|
|
46
|
+
private hasLabelSlot;
|
|
47
|
+
/** The capture wrapper's parent (the action `<button>`), remembered across detaches. */
|
|
48
|
+
private labelParent?;
|
|
49
|
+
/** The projected label nodes while they render bare (React's `{actionLabel}`). */
|
|
50
|
+
private labelNodes;
|
|
51
|
+
/** Marks the wrapper's position in the button while the projected nodes render bare. */
|
|
52
|
+
private labelAnchor?;
|
|
53
|
+
/** The wrapper sync for the action label's capture wrapper. */
|
|
54
|
+
private readonly sync;
|
|
55
|
+
/** Creates the position anchor comment the DOM normalizer strips. */
|
|
56
|
+
private readonly renderer;
|
|
57
|
+
/**
|
|
58
|
+
* The current class map.
|
|
59
|
+
* @returns The UIClassMap.
|
|
60
|
+
*/
|
|
61
|
+
cm(): UIClassMap;
|
|
62
|
+
/**
|
|
63
|
+
* Computes the Card's class list (`cm.card({ variant: 'elevated' })` +
|
|
64
|
+
* `cm.cardPadding('md')` — the UI Card's defaults — plus `className`).
|
|
65
|
+
* @returns The class string.
|
|
66
|
+
*/
|
|
67
|
+
classes(): string;
|
|
68
|
+
/**
|
|
69
|
+
* Computes the title's class (`cm.textSize('base')` + `cm.fontWeight('semibold')`).
|
|
70
|
+
* @returns The class string.
|
|
71
|
+
*/
|
|
72
|
+
titleClasses(): string;
|
|
73
|
+
/**
|
|
74
|
+
* The title input's text (React's `{title}` for a text child: strings and
|
|
75
|
+
* numbers render; a node arrives as `[slot=title]` content instead).
|
|
76
|
+
* @returns The text, or `''` for a node title.
|
|
77
|
+
*/
|
|
78
|
+
titleText(): string;
|
|
79
|
+
/**
|
|
80
|
+
* The description input's text (React's `{description}` for a text child).
|
|
81
|
+
* @returns The text, or `''` for a node description.
|
|
82
|
+
*/
|
|
83
|
+
descriptionText(): string;
|
|
84
|
+
/**
|
|
85
|
+
* The action label input's text (React's `{actionLabel}` for a text child).
|
|
86
|
+
* @returns The text, or `''` for a node label.
|
|
87
|
+
*/
|
|
88
|
+
actionLabelText(): string;
|
|
89
|
+
/**
|
|
90
|
+
* The button's disabled state (React's `disabled || loading`; an absent
|
|
91
|
+
* boolean input must not show a disabled button).
|
|
92
|
+
* @returns Whether the button is disabled.
|
|
93
|
+
*/
|
|
94
|
+
isDisabled(): boolean;
|
|
95
|
+
/** Runs the click handler the way React forwards the DOM event. */
|
|
96
|
+
handleAction(event: MouseEvent): void;
|
|
97
|
+
/**
|
|
98
|
+
* Reads the label slot's presence (view queries resolve only at view init)
|
|
99
|
+
* and syncs the capture wrapper against React's DOM.
|
|
100
|
+
*/
|
|
101
|
+
ngAfterViewInit(): void;
|
|
102
|
+
/**
|
|
103
|
+
* Re-syncs the wrapper when `loading` changes.
|
|
104
|
+
*/
|
|
105
|
+
ngDoCheck(): void;
|
|
106
|
+
/**
|
|
107
|
+
* Applies React's label branch: the projected label renders only while
|
|
108
|
+
* there is one and the button is not loading (`{loading ? '…' : actionLabel}`),
|
|
109
|
+
* and it renders BARE — the capture wrapper never shows in the DOM.
|
|
110
|
+
*/
|
|
111
|
+
private syncLabels;
|
|
112
|
+
/**
|
|
113
|
+
* Moves the projected nodes out of the capture wrapper to its position and
|
|
114
|
+
* detaches the empty wrapper (React renders the label with no element).
|
|
115
|
+
*
|
|
116
|
+
* @param span - The capture wrapper.
|
|
117
|
+
* @param parent - The wrapper's parent (the action `<button>`).
|
|
118
|
+
*/
|
|
119
|
+
private unwrapLabel;
|
|
120
|
+
/**
|
|
121
|
+
* Creates the position anchor comment and inserts it where the wrapper sits.
|
|
122
|
+
*
|
|
123
|
+
* @param parent - The wrapper's parent (the action `<button>`).
|
|
124
|
+
* @param span - The capture wrapper the anchor replaces.
|
|
125
|
+
* @returns The created anchor comment.
|
|
126
|
+
*/
|
|
127
|
+
private createLabelAnchor;
|
|
128
|
+
/**
|
|
129
|
+
* Puts the projected nodes back inside the capture wrapper (hidden, as
|
|
130
|
+
* React hides the label while loading) and keeps the wrapper out of the DOM.
|
|
131
|
+
*
|
|
132
|
+
* @param span - The capture wrapper.
|
|
133
|
+
* @param parent - The wrapper's parent (the action `<button>`).
|
|
134
|
+
*/
|
|
135
|
+
private wrapLabel;
|
|
136
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DangerZoneSection, never>;
|
|
137
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DangerZoneSection, "div[mol-danger-zone-section]", never, { "title": { "alias": "title"; "required": false; }; "description": { "alias": "description"; "required": false; }; "actionLabel": { "alias": "actionLabel"; "required": false; }; "loading": { "alias": "loading"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "className": { "alias": "className"; "required": false; }; "dataMolId": { "alias": "dataMolId"; "required": false; }; "onAction": { "alias": "onAction"; "required": false; }; }, {}, never, ["[slot=title]", "[slot=description]", "*", "[slot=actionLabel]"], true, never>;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=danger-zone-section.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"danger-zone-section.component.d.ts","sourceRoot":"","sources":["../src/danger-zone-section.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,OAAO,EACZ,UAAU,EAIX,MAAM,eAAe,CAAA;AAEtB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;;AAMlD;;;;;;;;;;;;;;;;GAgBG;AACH,qBA0Ca,iBAAkB,YAAW,aAAa,EAAE,OAAO;IAC9D,uFAAuF;IACvF,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,6GAA6G;IAC7G,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,kGAAkG;IAClG,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,gEAAgE;IAChE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IAEtC,2EAA2E;IACnD,SAAS,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAE/D,yEAAyE;IACzE,OAAO,CAAC,YAAY,CAAQ;IAE5B,wFAAwF;IACxF,OAAO,CAAC,WAAW,CAAC,CAAM;IAE1B,kFAAkF;IAClF,OAAO,CAAC,UAAU,CAAa;IAE/B,wFAAwF;IACxF,OAAO,CAAC,WAAW,CAAC,CAAS;IAE7B,+DAA+D;IAC/D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAyD;IAE9E,qEAAqE;IACrE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;IAE7C;;;OAGG;IACH,EAAE,IAAI,UAAU;IAIhB;;;;OAIG;IACH,OAAO,IAAI,MAAM;IAQjB;;;OAGG;IACH,YAAY,IAAI,MAAM;IAItB;;;;OAIG;IACH,SAAS,IAAI,MAAM;IAMnB;;;OAGG;IACH,eAAe,IAAI,MAAM;IAMzB;;;OAGG;IACH,eAAe,IAAI,MAAM;IAMzB;;;;OAIG;IACH,UAAU,IAAI,OAAO;IAIrB,mEAAmE;IACnE,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAIrC;;;OAGG;IACH,eAAe,IAAI,IAAI;IASvB;;OAEG;IACH,SAAS,IAAI,IAAI;IAIjB;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAWlB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAOnB;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IAOzB;;;;;;OAMG;IACH,OAAO,CAAC,SAAS;yCAxLN,iBAAiB;2CAAjB,iBAAiB;CAgM7B"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DangerZoneSection component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { Component, ElementRef, inject, Renderer2, ViewChild, } from '@angular/core';
|
|
7
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
8
|
+
import { Button } from '@molecule/app-ui-angular';
|
|
9
|
+
import { hasNodes, SlotWrapper } from './slot-dom.js';
|
|
10
|
+
import * as i0 from "@angular/core";
|
|
11
|
+
const _c0 = ["labelSlot"];
|
|
12
|
+
const _c1 = [[["", "slot", "title"]], [["", "slot", "description"]], "*", [["", "slot", "actionlabel"]]];
|
|
13
|
+
const _c2 = ["[slot=title]", "[slot=description]", "*", "[slot=actionLabel]"];
|
|
14
|
+
const _c3 = () => ({ justify: "end" });
|
|
15
|
+
/**
|
|
16
|
+
* DangerZoneSection component.
|
|
17
|
+
*
|
|
18
|
+
* Card-wrapped section for destructive actions — delete account, reset data,
|
|
19
|
+
* revoke access. Uses the error/danger accent color and puts the action on
|
|
20
|
+
* the right. The host IS the Card's `<div>`
|
|
21
|
+
* (`div[mol-danger-zone-section]`), matching React's root exactly; the Card
|
|
22
|
+
* classes (`cm.card({ variant: 'elevated' })` + `cm.cardPadding('md')`, the
|
|
23
|
+
* UI Card's defaults) are applied through the host class binding.
|
|
24
|
+
*
|
|
25
|
+
* The node props are projected slots: `title` renders inside the `<h3>`,
|
|
26
|
+
* `description` inside the `<p>`, `actionLabel` inside the action `<button>`,
|
|
27
|
+
* and `children` bare between the header and the button row (React renders
|
|
28
|
+
* `{children}` with no wrapper). String inputs render as text instead — the
|
|
29
|
+
* same values React renders. The action label's capture wrapper detaches
|
|
30
|
+
* while `loading` is true: React shows the `…` glyph instead of the label.
|
|
31
|
+
*/
|
|
32
|
+
export class DangerZoneSection {
|
|
33
|
+
/** Section title (string/number renders as text; nodes are `[slot=title]` content). */
|
|
34
|
+
title;
|
|
35
|
+
/** Explanation of the destructive action (string/number as text; nodes are `[slot=description]` content). */
|
|
36
|
+
description;
|
|
37
|
+
/** Label on the action button (string/number as text; nodes are `[slot=actionLabel]` content). */
|
|
38
|
+
actionLabel;
|
|
39
|
+
/** When true, the button disables and shows a loading label. */
|
|
40
|
+
loading;
|
|
41
|
+
/** When true, the button is disabled without loading. */
|
|
42
|
+
disabled;
|
|
43
|
+
/** Extra classes on the Card. */
|
|
44
|
+
className;
|
|
45
|
+
/** `data-mol-id` for AI-agent selectors. */
|
|
46
|
+
dataMolId;
|
|
47
|
+
/** Called when the button is clicked; receives the DOM click event (React's `onAction`). */
|
|
48
|
+
onAction;
|
|
49
|
+
/** The action label's capture wrapper (moved out of the DOM once read). */
|
|
50
|
+
labelSlot;
|
|
51
|
+
/** Whether the action label slot holds projected content (read once). */
|
|
52
|
+
hasLabelSlot = false;
|
|
53
|
+
/** The capture wrapper's parent (the action `<button>`), remembered across detaches. */
|
|
54
|
+
labelParent;
|
|
55
|
+
/** The projected label nodes while they render bare (React's `{actionLabel}`). */
|
|
56
|
+
labelNodes = [];
|
|
57
|
+
/** Marks the wrapper's position in the button while the projected nodes render bare. */
|
|
58
|
+
labelAnchor;
|
|
59
|
+
/** The wrapper sync for the action label's capture wrapper. */
|
|
60
|
+
sync = new SlotWrapper(inject(ElementRef), inject(Renderer2));
|
|
61
|
+
/** Creates the position anchor comment the DOM normalizer strips. */
|
|
62
|
+
renderer = inject(Renderer2);
|
|
63
|
+
/**
|
|
64
|
+
* The current class map.
|
|
65
|
+
* @returns The UIClassMap.
|
|
66
|
+
*/
|
|
67
|
+
cm() {
|
|
68
|
+
return getClassMap();
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Computes the Card's class list (`cm.card({ variant: 'elevated' })` +
|
|
72
|
+
* `cm.cardPadding('md')` — the UI Card's defaults — plus `className`).
|
|
73
|
+
* @returns The class string.
|
|
74
|
+
*/
|
|
75
|
+
classes() {
|
|
76
|
+
return this.cm().cn(this.cm().card({ variant: 'elevated' }), this.cm().cardPadding('md'), this.className);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Computes the title's class (`cm.textSize('base')` + `cm.fontWeight('semibold')`).
|
|
80
|
+
* @returns The class string.
|
|
81
|
+
*/
|
|
82
|
+
titleClasses() {
|
|
83
|
+
return this.cm().cn(this.cm().textSize('base'), this.cm().fontWeight('semibold'));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The title input's text (React's `{title}` for a text child: strings and
|
|
87
|
+
* numbers render; a node arrives as `[slot=title]` content instead).
|
|
88
|
+
* @returns The text, or `''` for a node title.
|
|
89
|
+
*/
|
|
90
|
+
titleText() {
|
|
91
|
+
return typeof this.title === 'string' || typeof this.title === 'number'
|
|
92
|
+
? String(this.title)
|
|
93
|
+
: '';
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The description input's text (React's `{description}` for a text child).
|
|
97
|
+
* @returns The text, or `''` for a node description.
|
|
98
|
+
*/
|
|
99
|
+
descriptionText() {
|
|
100
|
+
return typeof this.description === 'string' || typeof this.description === 'number'
|
|
101
|
+
? String(this.description)
|
|
102
|
+
: '';
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The action label input's text (React's `{actionLabel}` for a text child).
|
|
106
|
+
* @returns The text, or `''` for a node label.
|
|
107
|
+
*/
|
|
108
|
+
actionLabelText() {
|
|
109
|
+
return typeof this.actionLabel === 'string' || typeof this.actionLabel === 'number'
|
|
110
|
+
? String(this.actionLabel)
|
|
111
|
+
: '';
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The button's disabled state (React's `disabled || loading`; an absent
|
|
115
|
+
* boolean input must not show a disabled button).
|
|
116
|
+
* @returns Whether the button is disabled.
|
|
117
|
+
*/
|
|
118
|
+
isDisabled() {
|
|
119
|
+
return this.disabled === true || this.loading === true;
|
|
120
|
+
}
|
|
121
|
+
/** Runs the click handler the way React forwards the DOM event. */
|
|
122
|
+
handleAction(event) {
|
|
123
|
+
this.onAction?.(event);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Reads the label slot's presence (view queries resolve only at view init)
|
|
127
|
+
* and syncs the capture wrapper against React's DOM.
|
|
128
|
+
*/
|
|
129
|
+
ngAfterViewInit() {
|
|
130
|
+
const label = this.labelSlot?.nativeElement;
|
|
131
|
+
if (label) {
|
|
132
|
+
this.labelParent = label.parentElement ?? undefined;
|
|
133
|
+
this.hasLabelSlot = hasNodes(label);
|
|
134
|
+
}
|
|
135
|
+
this.syncLabels();
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Re-syncs the wrapper when `loading` changes.
|
|
139
|
+
*/
|
|
140
|
+
ngDoCheck() {
|
|
141
|
+
this.syncLabels();
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Applies React's label branch: the projected label renders only while
|
|
145
|
+
* there is one and the button is not loading (`{loading ? '…' : actionLabel}`),
|
|
146
|
+
* and it renders BARE — the capture wrapper never shows in the DOM.
|
|
147
|
+
*/
|
|
148
|
+
syncLabels() {
|
|
149
|
+
const span = this.labelSlot?.nativeElement;
|
|
150
|
+
const parent = this.labelParent;
|
|
151
|
+
if (!span || !parent)
|
|
152
|
+
return;
|
|
153
|
+
if (this.hasLabelSlot && this.loading !== true) {
|
|
154
|
+
this.unwrapLabel(span, parent);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
this.wrapLabel(span, parent);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Moves the projected nodes out of the capture wrapper to its position and
|
|
162
|
+
* detaches the empty wrapper (React renders the label with no element).
|
|
163
|
+
*
|
|
164
|
+
* @param span - The capture wrapper.
|
|
165
|
+
* @param parent - The wrapper's parent (the action `<button>`).
|
|
166
|
+
*/
|
|
167
|
+
unwrapLabel(span, parent) {
|
|
168
|
+
const anchor = this.labelAnchor ?? this.createLabelAnchor(parent, span);
|
|
169
|
+
this.labelNodes = Array.from(span.childNodes);
|
|
170
|
+
for (const node of this.labelNodes)
|
|
171
|
+
parent.insertBefore(node, anchor);
|
|
172
|
+
if (span.isConnected)
|
|
173
|
+
parent.removeChild(span);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Creates the position anchor comment and inserts it where the wrapper sits.
|
|
177
|
+
*
|
|
178
|
+
* @param parent - The wrapper's parent (the action `<button>`).
|
|
179
|
+
* @param span - The capture wrapper the anchor replaces.
|
|
180
|
+
* @returns The created anchor comment.
|
|
181
|
+
*/
|
|
182
|
+
createLabelAnchor(parent, span) {
|
|
183
|
+
const anchor = this.renderer.createComment('slot');
|
|
184
|
+
this.labelAnchor = anchor;
|
|
185
|
+
parent.insertBefore(anchor, span);
|
|
186
|
+
return anchor;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Puts the projected nodes back inside the capture wrapper (hidden, as
|
|
190
|
+
* React hides the label while loading) and keeps the wrapper out of the DOM.
|
|
191
|
+
*
|
|
192
|
+
* @param span - The capture wrapper.
|
|
193
|
+
* @param parent - The wrapper's parent (the action `<button>`).
|
|
194
|
+
*/
|
|
195
|
+
wrapLabel(span, parent) {
|
|
196
|
+
for (const node of this.labelNodes)
|
|
197
|
+
span.appendChild(node);
|
|
198
|
+
this.labelNodes = [];
|
|
199
|
+
if (!span.isConnected && this.labelAnchor?.isConnected) {
|
|
200
|
+
parent.insertBefore(span, this.labelAnchor);
|
|
201
|
+
}
|
|
202
|
+
this.sync.sync(span, false, parent);
|
|
203
|
+
}
|
|
204
|
+
static ɵfac = function DangerZoneSection_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || DangerZoneSection)(); };
|
|
205
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DangerZoneSection, selectors: [["div", "mol-danger-zone-section", ""]], viewQuery: function DangerZoneSection_Query(rf, ctx) { if (rf & 1) {
|
|
206
|
+
i0.ɵɵviewQuery(_c0, 5);
|
|
207
|
+
} if (rf & 2) {
|
|
208
|
+
let _t;
|
|
209
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.labelSlot = _t.first);
|
|
210
|
+
} }, hostVars: 3, hostBindings: function DangerZoneSection_HostBindings(rf, ctx) { if (rf & 2) {
|
|
211
|
+
i0.ɵɵattribute("data-mol-id", ctx.dataMolId ?? null);
|
|
212
|
+
i0.ɵɵclassMap(ctx.classes());
|
|
213
|
+
} }, inputs: { title: "title", description: "description", actionLabel: "actionLabel", loading: "loading", disabled: "disabled", className: "className", dataMolId: "dataMolId", onAction: "onAction" }, ngContentSelectors: _c2, decls: 15, vars: 17, consts: [["labelSlot", ""], ["mol-button", "", 3, "click", "variant", "color", "disabled"]], template: function DangerZoneSection_Template(rf, ctx) { if (rf & 1) {
|
|
214
|
+
i0.ɵɵprojectionDef(_c1);
|
|
215
|
+
i0.ɵɵelementStart(0, "div")(1, "header")(2, "h3");
|
|
216
|
+
i0.ɵɵtext(3);
|
|
217
|
+
i0.ɵɵprojection(4);
|
|
218
|
+
i0.ɵɵelementEnd();
|
|
219
|
+
i0.ɵɵelementStart(5, "p");
|
|
220
|
+
i0.ɵɵtext(6);
|
|
221
|
+
i0.ɵɵprojection(7, 1);
|
|
222
|
+
i0.ɵɵelementEnd()();
|
|
223
|
+
i0.ɵɵprojection(8, 2);
|
|
224
|
+
i0.ɵɵelementStart(9, "div")(10, "button", 1);
|
|
225
|
+
i0.ɵɵlistener("click", function DangerZoneSection_Template_button_click_10_listener($event) { return ctx.handleAction($event); });
|
|
226
|
+
i0.ɵɵtext(11);
|
|
227
|
+
i0.ɵɵelementStart(12, "span", null, 0);
|
|
228
|
+
i0.ɵɵprojection(14, 3);
|
|
229
|
+
i0.ɵɵelementEnd()()()();
|
|
230
|
+
} if (rf & 2) {
|
|
231
|
+
i0.ɵɵclassMap(ctx.cm().stack(3));
|
|
232
|
+
i0.ɵɵadvance();
|
|
233
|
+
i0.ɵɵclassMap(ctx.cm().stack(1));
|
|
234
|
+
i0.ɵɵadvance();
|
|
235
|
+
i0.ɵɵclassMap(ctx.titleClasses());
|
|
236
|
+
i0.ɵɵadvance();
|
|
237
|
+
i0.ɵɵtextInterpolate1(" ", ctx.titleText());
|
|
238
|
+
i0.ɵɵadvance(2);
|
|
239
|
+
i0.ɵɵclassMap(ctx.cm().textSize("sm"));
|
|
240
|
+
i0.ɵɵadvance();
|
|
241
|
+
i0.ɵɵtextInterpolate1(" ", ctx.descriptionText());
|
|
242
|
+
i0.ɵɵadvance(3);
|
|
243
|
+
i0.ɵɵclassMap(ctx.cm().flex(i0.ɵɵpureFunction0(16, _c3)));
|
|
244
|
+
i0.ɵɵadvance();
|
|
245
|
+
i0.ɵɵproperty("variant", "solid")("color", "error")("disabled", ctx.isDisabled());
|
|
246
|
+
i0.ɵɵadvance();
|
|
247
|
+
i0.ɵɵtextInterpolate1(" ", ctx.loading ? "\u2026" : ctx.actionLabelText());
|
|
248
|
+
} }, dependencies: [Button], encapsulation: 2 });
|
|
249
|
+
}
|
|
250
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DangerZoneSection, [{
|
|
251
|
+
type: Component,
|
|
252
|
+
args: [{
|
|
253
|
+
selector: 'div[mol-danger-zone-section]',
|
|
254
|
+
standalone: true,
|
|
255
|
+
imports: [Button],
|
|
256
|
+
inputs: [
|
|
257
|
+
'title',
|
|
258
|
+
'description',
|
|
259
|
+
'actionLabel',
|
|
260
|
+
'loading',
|
|
261
|
+
'disabled',
|
|
262
|
+
'className',
|
|
263
|
+
'dataMolId',
|
|
264
|
+
'onAction',
|
|
265
|
+
],
|
|
266
|
+
host: {
|
|
267
|
+
'[class]': 'classes()',
|
|
268
|
+
'[attr.data-mol-id]': 'dataMolId ?? null',
|
|
269
|
+
},
|
|
270
|
+
template: `<div [class]="cm().stack(3)">
|
|
271
|
+
<header [class]="cm().stack(1)">
|
|
272
|
+
<h3 [class]="titleClasses()">
|
|
273
|
+
{{ titleText() }}<ng-content select="[slot=title]"></ng-content>
|
|
274
|
+
</h3>
|
|
275
|
+
<p [class]="cm().textSize('sm')">
|
|
276
|
+
{{ descriptionText() }}<ng-content select="[slot=description]"></ng-content>
|
|
277
|
+
</p>
|
|
278
|
+
</header>
|
|
279
|
+
<ng-content></ng-content>
|
|
280
|
+
<div [class]="cm().flex({ justify: 'end' })">
|
|
281
|
+
<button
|
|
282
|
+
mol-button
|
|
283
|
+
[variant]="'solid'"
|
|
284
|
+
[color]="'error'"
|
|
285
|
+
[disabled]="isDisabled()"
|
|
286
|
+
(click)="handleAction($event)"
|
|
287
|
+
>
|
|
288
|
+
{{ loading ? '…' : actionLabelText()
|
|
289
|
+
}}<span #labelSlot><ng-content select="[slot=actionLabel]"></ng-content></span>
|
|
290
|
+
</button>
|
|
291
|
+
</div>
|
|
292
|
+
</div>`,
|
|
293
|
+
}]
|
|
294
|
+
}], null, { labelSlot: [{
|
|
295
|
+
type: ViewChild,
|
|
296
|
+
args: ['labelSlot']
|
|
297
|
+
}] }); })();
|
|
298
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(DangerZoneSection, { className: "DangerZoneSection", filePath: "danger-zone-section.component.ts", lineNumber: 82 }); })();
|
|
299
|
+
//# sourceMappingURL=danger-zone-section.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"danger-zone-section.component.js","sourceRoot":"","sources":["../src/danger-zone-section.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,SAAS,EAET,UAAU,EACV,MAAM,EACN,SAAS,EACT,SAAS,GACV,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AAEjD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;;;;;;AAErD;;;;;;;;;;;;;;;;GAgBG;AA2CH,MAAM,OAAO,iBAAiB;IAC5B,uFAAuF;IACvF,KAAK,CAAU;IACf,6GAA6G;IAC7G,WAAW,CAAU;IACrB,kGAAkG;IAClG,WAAW,CAAU;IACrB,gEAAgE;IAChE,OAAO,CAAU;IACjB,yDAAyD;IACzD,QAAQ,CAAU;IAClB,iCAAiC;IACjC,SAAS,CAAS;IAClB,4CAA4C;IAC5C,SAAS,CAAS;IAClB,4FAA4F;IAC5F,QAAQ,CAA8B;IAEtC,2EAA2E;IACnD,SAAS,CAA8B;IAE/D,yEAAyE;IACjE,YAAY,GAAG,KAAK,CAAA;IAE5B,wFAAwF;IAChF,WAAW,CAA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2DAAJ,IAAI;YAAjB,cAAA,aAAS,CAAQ;;;YAtBxB,AADF,AADS,2BAA6B,aACN,SACD;YAC3B,YAAiB;YAAA,kBAA+C;YAClE,iBAAK;YACL,yBAAiC;YAC/B,YAAuB;YAAA,qBAAqD;YAEhF,AADE,iBAAI,EACG;YACT,qBAAyB;YAEvB,AADF,2BAA6C,iBAO1C;YADC,qGAAS,wBAAoB,IAAC;YAE9B,aACE;YAAA,sCAAiB;YAAA,sBAAqD;YAG9E,AADE,AADE,AAD0E,iBAAO,EACxE,EACL,EACF;;YAtBU,gCAAuB;YAC7B,cAAuB;YAAvB,gCAAuB;YACzB,cAAwB;YAAxB,iCAAwB;YAC1B,cAAiB;YAAjB,2CAAiB;YAEhB,eAA6B;YAA7B,sCAA6B;YAC9B,cAAuB;YAAvB,iDAAuB;YAItB,eAAuC;YAAvC,yDAAuC;YAGxC,cAAmB;YAEnB,AADA,AADA,iCAAmB,kBACF,8BACQ;YAGzB,cACE;YADF,0EACE;4BAlCE,MAAM;;iFAuCL,iBAAiB;cA1C7B,SAAS;eAAC;gBACT,QAAQ,EAAE,8BAA8B;gBACxC,UAAU,EAAE,IAAI;gBAChB,OAAO,EAAE,CAAC,MAAM,CAAC;gBACjB,MAAM,EAAE;oBACN,OAAO;oBACP,aAAa;oBACb,aAAa;oBACb,SAAS;oBACT,UAAU;oBACV,WAAW;oBACX,WAAW;oBACX,UAAU;iBACX;gBACD,IAAI,EAAE;oBACJ,SAAS,EAAE,WAAW;oBACtB,oBAAoB,EAAE,mBAAmB;iBAC1C;gBACD,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;SAsBH;aACR;;kBAoBE,SAAS;mBAAC,WAAW;;kFAnBX,iBAAiB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular destructive-action primitives — the counterpart of
|
|
3
|
+
* `@molecule/app-danger-zone-react`: the same props and the same DOM for the
|
|
4
|
+
* same input.
|
|
5
|
+
*
|
|
6
|
+
* Exports `<DangerZoneSection>` — Card with title/description/button for
|
|
7
|
+
* delete/reset/revoke — and `<ConfirmDialog>`, the standalone "Are you
|
|
8
|
+
* sure?" modal.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Component } from '@angular/core'
|
|
13
|
+
* import { DangerZoneSection } from '@molecule/app-danger-zone-angular'
|
|
14
|
+
*
|
|
15
|
+
* @Component({
|
|
16
|
+
* selector: 'app-account',
|
|
17
|
+
* standalone: true,
|
|
18
|
+
* imports: [DangerZoneSection],
|
|
19
|
+
* template: `
|
|
20
|
+
* <div mol-danger-zone-section
|
|
21
|
+
* title="Delete account"
|
|
22
|
+
* description="This permanently removes your account and all data."
|
|
23
|
+
* actionLabel="Delete account"
|
|
24
|
+
* (click)="openConfirm()"
|
|
25
|
+
* ></div>
|
|
26
|
+
* `,
|
|
27
|
+
* })
|
|
28
|
+
* export class Account {}
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* - Requires a bonded ClassMap (the Card classes, `cm.card` +
|
|
33
|
+
* `cm.cardPadding('md')`) — rendering throws otherwise.
|
|
34
|
+
* - Node props are projected content: `title`, `description` and
|
|
35
|
+
* `actionLabel` are selected by `[slot=title]` / `[slot=description]` /
|
|
36
|
+
* `[slot=actionLabel]`, everything else lands bare between the header and
|
|
37
|
+
* the button row as the default projection. String inputs render as text.
|
|
38
|
+
* - `<ConfirmDialog>` does NOT track `onConfirm`'s promise and does NOT
|
|
39
|
+
* close itself on confirm: set `loading` yourself while the action runs,
|
|
40
|
+
* then call `onClose()` when it settles — otherwise users can double-fire
|
|
41
|
+
* the destructive action or be left staring at an open dialog.
|
|
42
|
+
* Cancel/Confirm fall back to the `confirm.*` i18n keys (companion bond:
|
|
43
|
+
* `@molecule/app-locales-danger-zone`); pass `confirmLabel`/`cancelLabel`
|
|
44
|
+
* for action-specific wording ("Delete", "Revoke"). `destructive`
|
|
45
|
+
* (default true) only switches the confirm button color.
|
|
46
|
+
*
|
|
47
|
+
* @module
|
|
48
|
+
*/
|
|
49
|
+
export * from './confirm-dialog.js';
|
|
50
|
+
export * from './danger-zone-section.component.js';
|
|
51
|
+
export * from './types.js';
|
|
52
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,oCAAoC,CAAA;AAClD,cAAc,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular destructive-action primitives — the counterpart of
|
|
3
|
+
* `@molecule/app-danger-zone-react`: the same props and the same DOM for the
|
|
4
|
+
* same input.
|
|
5
|
+
*
|
|
6
|
+
* Exports `<DangerZoneSection>` — Card with title/description/button for
|
|
7
|
+
* delete/reset/revoke — and `<ConfirmDialog>`, the standalone "Are you
|
|
8
|
+
* sure?" modal.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Component } from '@angular/core'
|
|
13
|
+
* import { DangerZoneSection } from '@molecule/app-danger-zone-angular'
|
|
14
|
+
*
|
|
15
|
+
* @Component({
|
|
16
|
+
* selector: 'app-account',
|
|
17
|
+
* standalone: true,
|
|
18
|
+
* imports: [DangerZoneSection],
|
|
19
|
+
* template: `
|
|
20
|
+
* <div mol-danger-zone-section
|
|
21
|
+
* title="Delete account"
|
|
22
|
+
* description="This permanently removes your account and all data."
|
|
23
|
+
* actionLabel="Delete account"
|
|
24
|
+
* (click)="openConfirm()"
|
|
25
|
+
* ></div>
|
|
26
|
+
* `,
|
|
27
|
+
* })
|
|
28
|
+
* export class Account {}
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* - Requires a bonded ClassMap (the Card classes, `cm.card` +
|
|
33
|
+
* `cm.cardPadding('md')`) — rendering throws otherwise.
|
|
34
|
+
* - Node props are projected content: `title`, `description` and
|
|
35
|
+
* `actionLabel` are selected by `[slot=title]` / `[slot=description]` /
|
|
36
|
+
* `[slot=actionLabel]`, everything else lands bare between the header and
|
|
37
|
+
* the button row as the default projection. String inputs render as text.
|
|
38
|
+
* - `<ConfirmDialog>` does NOT track `onConfirm`'s promise and does NOT
|
|
39
|
+
* close itself on confirm: set `loading` yourself while the action runs,
|
|
40
|
+
* then call `onClose()` when it settles — otherwise users can double-fire
|
|
41
|
+
* the destructive action or be left staring at an open dialog.
|
|
42
|
+
* Cancel/Confirm fall back to the `confirm.*` i18n keys (companion bond:
|
|
43
|
+
* `@molecule/app-locales-danger-zone`); pass `confirmLabel`/`cancelLabel`
|
|
44
|
+
* for action-specific wording ("Delete", "Revoke"). `destructive`
|
|
45
|
+
* (default true) only switches the confirm button color.
|
|
46
|
+
*
|
|
47
|
+
* @module
|
|
48
|
+
*/
|
|
49
|
+
export * from './confirm-dialog.js';
|
|
50
|
+
export * from './danger-zone-section.component.js';
|
|
51
|
+
export * from './types.js';
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,oCAAoC,CAAA;AAClD,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
import type { ElementRef, Renderer2 } from '@angular/core';
|
|
13
|
+
/**
|
|
14
|
+
* Whether an ng-content wrapper captured any element or text node.
|
|
15
|
+
*
|
|
16
|
+
* @param el - The wrapper element.
|
|
17
|
+
* @returns True when at least one projected node exists.
|
|
18
|
+
*/
|
|
19
|
+
export declare const hasNodes: (el: Element | undefined | null) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Attaches or detaches an always-mounted projection wrapper element from its
|
|
22
|
+
* parent, remembering the re-insertion position with a comment anchor the DOM
|
|
23
|
+
* normalizer strips.
|
|
24
|
+
*/
|
|
25
|
+
export declare class SlotWrapper {
|
|
26
|
+
private readonly host;
|
|
27
|
+
private readonly renderer;
|
|
28
|
+
private readonly anchors;
|
|
29
|
+
/**
|
|
30
|
+
* Creates the wrapper helper.
|
|
31
|
+
*
|
|
32
|
+
* @param host - The component host element (default detach parent).
|
|
33
|
+
* @param renderer - The DOM renderer.
|
|
34
|
+
*/
|
|
35
|
+
constructor(host: ElementRef<HTMLElement>, renderer: Renderer2);
|
|
36
|
+
/**
|
|
37
|
+
* Attaches or detaches the element (default parent: the component host).
|
|
38
|
+
*
|
|
39
|
+
* @param el - The wrapper element.
|
|
40
|
+
* @param shouldAttach - Whether it should be in the DOM.
|
|
41
|
+
* @param parent - Where the element lives when attached (default: host).
|
|
42
|
+
*/
|
|
43
|
+
sync(el: Element | undefined | null, shouldAttach: boolean, parent?: Node): void;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=slot-dom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slot-dom.d.ts","sourceRoot":"","sources":["../src/slot-dom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,IAAI,OAAO,GAAG,SAAS,GAAG,IAAI,KAAG,OAOzD,CAAA;AAED;;;;GAIG;AACH,qBAAa,WAAW;IAUpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAV3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2B;IAEnD;;;;;OAKG;gBAEgB,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,EAC7B,QAAQ,EAAE,SAAS;IAGtC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI;CAqBjF"}
|