@molecule/app-empty-state-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,56 @@
1
+ /**
2
+ * DOM helpers for the projected capture points of the empty-state components.
3
+ *
4
+ * React renders an optional wrapper only when its node prop is present, and
5
+ * drops it otherwise. Angular projection needs an always-mounted `<ng-content>`
6
+ * capture point, so each optional wrapper lives in the template unconditionally
7
+ * and these helpers reconcile it against React's DOM: the wrapper is detached
8
+ * (contents move with it) when React would not render it, and re-attached when a
9
+ * later render supplies one.
10
+ *
11
+ * @module
12
+ */
13
+ import type { ElementRef, Renderer2 } from '@angular/core';
14
+ /**
15
+ * Whether an ng-content wrapper captured any element or text node.
16
+ *
17
+ * @param el - The wrapper element.
18
+ * @returns True when at least one projected node exists.
19
+ */
20
+ export declare const hasNodes: (el: Element | undefined | null) => boolean;
21
+ /**
22
+ * Reconciles one always-mounted wrapper against what React renders.
23
+ *
24
+ * Both operations are idempotent and anchored in the wrapper's current parent
25
+ * (default: the component host), so a wrapper whose contents move with it can
26
+ * be detached and re-attached across prop changes.
27
+ */
28
+ export declare class SlotGuard {
29
+ private readonly host;
30
+ private readonly renderer;
31
+ private readonly anchors;
32
+ /**
33
+ * Creates the guard.
34
+ *
35
+ * @param host - The component host element (default anchor parent).
36
+ * @param renderer - The DOM renderer.
37
+ */
38
+ constructor(host: ElementRef<HTMLElement>, renderer: Renderer2);
39
+ /**
40
+ * Attaches or detaches the element (contents move with it).
41
+ *
42
+ * @param el - The wrapper element.
43
+ * @param shouldAttach - Whether it should be in the DOM.
44
+ */
45
+ toggle(el: Element | undefined | null, shouldAttach: boolean): void;
46
+ /**
47
+ * Returns the wrapper's anchor comment in `parent`, creating (or replacing a
48
+ * stale one) where the wrapper sits.
49
+ *
50
+ * @param parent - The anchor's parent.
51
+ * @param el - The wrapper the anchor stands for.
52
+ * @returns The connected anchor comment.
53
+ */
54
+ private anchorIn;
55
+ }
56
+ //# 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;;;;;;;;;;;GAWG;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;;;;;;GAMG;AACH,qBAAa,SAAS;IAUlB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAV3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IAEtD;;;;;OAKG;gBAEgB,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,EAC7B,QAAQ,EAAE,SAAS;IAGtC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,EAAE,YAAY,EAAE,OAAO,GAAG,IAAI;IAyBnE;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ;CASjB"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * DOM helpers for the projected capture points of the empty-state components.
3
+ *
4
+ * React renders an optional wrapper only when its node prop is present, and
5
+ * drops it otherwise. Angular projection needs an always-mounted `<ng-content>`
6
+ * capture point, so each optional wrapper lives in the template unconditionally
7
+ * and these helpers reconcile it against React's DOM: the wrapper is detached
8
+ * (contents move with it) when React would not render it, and re-attached when a
9
+ * later render supplies one.
10
+ *
11
+ * @module
12
+ */
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 const hasNodes = (el) => {
20
+ if (!el)
21
+ return false;
22
+ for (const node of Array.from(el.childNodes)) {
23
+ if (node.nodeType === 1)
24
+ return true;
25
+ if (node.nodeType === 3 && (node.textContent ?? '').trim())
26
+ return true;
27
+ }
28
+ return false;
29
+ };
30
+ /**
31
+ * Reconciles one always-mounted wrapper against what React renders.
32
+ *
33
+ * Both operations are idempotent and anchored in the wrapper's current parent
34
+ * (default: the component host), so a wrapper whose contents move with it can
35
+ * be detached and re-attached across prop changes.
36
+ */
37
+ export class SlotGuard {
38
+ host;
39
+ renderer;
40
+ anchors = new Map();
41
+ /**
42
+ * Creates the guard.
43
+ *
44
+ * @param host - The component host element (default anchor parent).
45
+ * @param renderer - The DOM renderer.
46
+ */
47
+ constructor(host, renderer) {
48
+ this.host = host;
49
+ this.renderer = renderer;
50
+ }
51
+ /**
52
+ * Attaches or detaches the element (contents move with it).
53
+ *
54
+ * @param el - The wrapper element.
55
+ * @param shouldAttach - Whether it should be in the DOM.
56
+ */
57
+ toggle(el, shouldAttach) {
58
+ if (!el)
59
+ return;
60
+ if (shouldAttach && !el.isConnected) {
61
+ // A wrapper of a nested region has no parent while detached, so it goes
62
+ // back beside the anchor comment it left (its own parent), not the host.
63
+ const anchor = this.anchors.get(el);
64
+ const parent = anchor?.isConnected
65
+ ? anchor.parentNode
66
+ : (el.parentElement ?? this.host.nativeElement);
67
+ if (anchor?.isConnected) {
68
+ parent.insertBefore(el, anchor);
69
+ this.renderer.removeChild(parent, anchor);
70
+ this.anchors.delete(el);
71
+ }
72
+ else {
73
+ parent.appendChild(el);
74
+ }
75
+ }
76
+ else if (!shouldAttach && el.isConnected) {
77
+ // A placeholder comment keeps the re-insertion position stable; the
78
+ // conformance normalizer strips comment nodes, so it never shows.
79
+ const parent = el.parentNode;
80
+ this.anchorIn(parent, el);
81
+ this.renderer.removeChild(parent, el);
82
+ }
83
+ }
84
+ /**
85
+ * Returns the wrapper's anchor comment in `parent`, creating (or replacing a
86
+ * stale one) where the wrapper sits.
87
+ *
88
+ * @param parent - The anchor's parent.
89
+ * @param el - The wrapper the anchor stands for.
90
+ * @returns The connected anchor comment.
91
+ */
92
+ anchorIn(parent, el) {
93
+ const existing = this.anchors.get(el);
94
+ if (existing?.isConnected && existing.parentNode === parent)
95
+ return existing;
96
+ if (existing)
97
+ this.anchors.delete(el);
98
+ const created = this.renderer.createComment('slot');
99
+ parent.insertBefore(created, el.isConnected ? el : null);
100
+ this.anchors.set(el, created);
101
+ return created;
102
+ }
103
+ }
104
+ //# sourceMappingURL=slot-dom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slot-dom.js","sourceRoot":"","sources":["../src/slot-dom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;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;;;;;;GAMG;AACH,MAAM,OAAO,SAAS;IAUD;IACA;IAVF,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAA;IAEtD;;;;;OAKG;IACH,YACmB,IAA6B,EAC7B,QAAmB;QADnB,SAAI,GAAJ,IAAI,CAAyB;QAC7B,aAAQ,GAAR,QAAQ,CAAW;IACnC,CAAC;IAEJ;;;;;OAKG;IACH,MAAM,CAAC,EAA8B,EAAE,YAAqB;QAC1D,IAAI,CAAC,EAAE;YAAE,OAAM;QACf,IAAI,YAAY,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;YACpC,wEAAwE;YACxE,yEAAyE;Y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CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;QACnD,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QACxD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;QAC7B,OAAO,OAAO,CAAA;IAChB,CAAC;CACF"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Types of `@molecule/app-empty-state-angular` — the Angular counterpart of
3
+ * `@molecule/app-empty-state-react`, same props and DOM.
4
+ *
5
+ * @module
6
+ */
7
+ /**
8
+ * Props accepted by {@link EmptyState} — the same props
9
+ * `@molecule/app-empty-state-react` accepts. Node props are an input (a string,
10
+ * or a `TemplateRef` for a node value) or projected content: `icon`, `title`,
11
+ * `description` and `action` are selected by `[slot=icon]`, `[slot=title]`,
12
+ * `[slot=description]` and `[slot=action]`.
13
+ */
14
+ export interface EmptyStateProps {
15
+ /** Visual — an icon node as a `TemplateRef`, or `[slot=icon]` projected content. */
16
+ icon?: unknown;
17
+ /** Primary heading for a general, unselected collection. */
18
+ title?: unknown;
19
+ /** Supporting description shown below the heading. */
20
+ description?: unknown;
21
+ /** Optional action for a general empty state. */
22
+ action?: unknown;
23
+ /**
24
+ * The selected view's translated message and required recovery element, kept
25
+ * together so a filtered or personal list never reuses the whole
26
+ * collection's empty message. Replaces `title`, `description` and `action`
27
+ * when given.
28
+ */
29
+ view?: {
30
+ /** The selected view's translated heading. */
31
+ title: unknown;
32
+ /** The selected view's supporting description. */
33
+ description?: unknown;
34
+ /** The selected view's recovery element — a `TemplateRef` holding a router link or a button. */
35
+ action: unknown;
36
+ };
37
+ /** `data-mol-id` for AI-agent selectors. */
38
+ dataMolId?: string;
39
+ /** Override outer wrapper classes (for per-app dashed-border, background, padding, etc.). */
40
+ className?: string;
41
+ /** Override the icon-badge wrapper classes. */
42
+ iconWrapperClassName?: string;
43
+ }
44
+ /**
45
+ * Props accepted by {@link CtaCard} — the same props
46
+ * `@molecule/app-empty-state-react` accepts. Node props are an input (a string,
47
+ * or a `TemplateRef` for a node value) or projected content: `eyebrow`,
48
+ * `title`, `description`, `action` and `media` are selected by
49
+ * `[slot=eyebrow]`, `[slot=title]`, `[slot=description]`, `[slot=action]` and
50
+ * `[slot=media]`.
51
+ */
52
+ export interface CtaCardProps {
53
+ /** Optional small eyebrow line above the title — a string, a `TemplateRef`, or `[slot=eyebrow]`. */
54
+ eyebrow?: unknown;
55
+ /** Primary heading — a string, a `TemplateRef`, or `[slot=title]`. */
56
+ title?: unknown;
57
+ /** Supporting copy — a string, a `TemplateRef`, or `[slot=description]`. */
58
+ description?: unknown;
59
+ /** Primary call-to-action — a string, a `TemplateRef`, or `[slot=action]`. */
60
+ action?: unknown;
61
+ /** Optional visual / illustration — a `TemplateRef`, or `[slot=media]`. */
62
+ media?: unknown;
63
+ /** `'horizontal'` renders media beside text; `'vertical'` stacks them. Defaults to `'vertical'`. */
64
+ layout?: 'vertical' | 'horizontal';
65
+ /** `data-mol-id` for AI-agent selectors. */
66
+ dataMolId?: string;
67
+ /** Override outer wrapper classes. */
68
+ className?: string;
69
+ }
70
+ //# 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;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,oFAAoF;IACpF,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,4DAA4D;IAC5D,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,sDAAsD;IACtD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,iDAAiD;IACjD,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;;;OAKG;IACH,IAAI,CAAC,EAAE;QACL,8CAA8C;QAC9C,KAAK,EAAE,OAAO,CAAA;QACd,kDAAkD;QAClD,WAAW,CAAC,EAAE,OAAO,CAAA;QACrB,gGAAgG;QAChG,MAAM,EAAE,OAAO,CAAA;KAChB,CAAA;IACD,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,6FAA6F;IAC7F,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,+CAA+C;IAC/C,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAC9B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,oGAAoG;IACpG,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,sEAAsE;IACtE,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,4EAA4E;IAC5E,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,oGAAoG;IACpG,MAAM,CAAC,EAAE,UAAU,GAAG,YAAY,CAAA;IAClC,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
package/dist/types.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Types of `@molecule/app-empty-state-angular` — the Angular counterpart of
3
+ * `@molecule/app-empty-state-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-empty-state-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": "Angular empty-state and CTA-card primitives",
5
+ "homepage": "https://www.molecule.dev/packages/app-empty-state-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
+ "empty-state",
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/empty-state-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.7.0",
59
+ "@molecule/app-framework-conformance": "0.0.0",
60
+ "@molecule/app-i18n": "1.2.2",
61
+ "@molecule/app-icons": "1.0.4",
62
+ "@molecule/app-ui": "1.4.0",
63
+ "@molecule/app-ui-angular": "1.1.3",
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
+ }