@molecule/app-avatar-stack-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,144 @@
1
+ /**
2
+ * AvatarStack component (React parity).
3
+ *
4
+ * @module
5
+ */
6
+ import { Component } from '@angular/core';
7
+ import { getClassMap } from '@molecule/app-ui';
8
+ import { Avatar } from '@molecule/app-ui-angular';
9
+ import * as i0 from "@angular/core";
10
+ function AvatarStack_For_1_Template(rf, ctx) { if (rf & 1) {
11
+ i0.ɵɵelementStart(0, "span");
12
+ i0.ɵɵelement(1, "div", 2);
13
+ i0.ɵɵelementEnd();
14
+ } if (rf & 2) {
15
+ const person_r1 = ctx.$implicit;
16
+ const ɵ$index_1_r2 = ctx.$index;
17
+ const ctx_r2 = i0.ɵɵnextContext();
18
+ i0.ɵɵstyleProp("margin-left", ɵ$index_1_r2 === 0 ? null : ctx_r2.overlapMargin);
19
+ i0.ɵɵadvance();
20
+ i0.ɵɵproperty("src", person_r1.src)("alt", person_r1.alt ?? person_r1.name)("name", person_r1.name)("size", ctx_r2.avatarSize());
21
+ } }
22
+ function AvatarStack_Conditional_2_Template(rf, ctx) { if (rf & 1) {
23
+ i0.ɵɵelementStart(0, "span");
24
+ i0.ɵɵtext(1);
25
+ i0.ɵɵelementEnd();
26
+ } if (rf & 2) {
27
+ const ctx_r2 = i0.ɵɵnextContext();
28
+ i0.ɵɵclassMap(ctx_r2.overflowClasses());
29
+ i0.ɵɵstyleProp("margin-left", ctx_r2.overlapMargin);
30
+ i0.ɵɵattribute("aria-label", "+" + ctx_r2.overflow() + " more");
31
+ i0.ɵɵadvance();
32
+ i0.ɵɵtextInterpolate("+" + ctx_r2.overflow());
33
+ } }
34
+ /**
35
+ * Negative left margin that pulls each avatar over its predecessor so the
36
+ * stack visually overlaps. This is an inline style deliberately: the
37
+ * ClassMap spacing scale (`SpacingScale`) is `0…24`, all non-negative, so
38
+ * neither `cm.sp('ml', n)` nor its compound style form can express a
39
+ * negative margin — one of the sanctioned "ClassMap can't express it"
40
+ * inline-style cases. `-0.5rem` mirrors the intended `-2` Tailwind spacing
41
+ * step.
42
+ */
43
+ const OVERLAP_MARGIN = '-0.5rem';
44
+ /**
45
+ * AvatarStack component.
46
+ *
47
+ * Horizontal stack of overlapping avatars (assignees, attendees, etc.).
48
+ * Renders up to `max` avatars; any remaining are summarised as `+N` in a
49
+ * trailing chip. The host IS the outer `<div>` (`div[mol-avatar-stack]`),
50
+ * matching React's root exactly.
51
+ */
52
+ export class AvatarStack {
53
+ /** People to render. */
54
+ people = [];
55
+ /** Maximum visible avatars (defaults to `4` at read time). */
56
+ max;
57
+ /** Avatar size preset (defaults to `'sm'` at read time). */
58
+ size;
59
+ /** Extra classes on the outer stack. */
60
+ className;
61
+ /** The overlap's negative left margin. */
62
+ overlapMargin = OVERLAP_MARGIN;
63
+ /**
64
+ * The current class map.
65
+ * @returns The UIClassMap.
66
+ */
67
+ cm() {
68
+ return getClassMap();
69
+ }
70
+ /**
71
+ * The avatar size passed to every `<div mol-avatar>` (React's
72
+ * `size = 'sm'` default parameter).
73
+ * @returns The size preset.
74
+ */
75
+ avatarSize() {
76
+ return this.size ?? 'sm';
77
+ }
78
+ /**
79
+ * The avatars that fit within `max` (React's `people.slice(0, max)`).
80
+ * @returns The visible people.
81
+ */
82
+ visible() {
83
+ return this.people.slice(0, this.max ?? 4);
84
+ }
85
+ /**
86
+ * How many people the overflow chip summarises (React's
87
+ * `Math.max(0, people.length - visible.length)`).
88
+ * @returns The overflow count.
89
+ */
90
+ overflow() {
91
+ return Math.max(0, this.people.length - this.visible().length);
92
+ }
93
+ /**
94
+ * Computes the outer stack's class list (`cm.flex({ align: 'center' })` +
95
+ * `className`).
96
+ * @returns The class string.
97
+ */
98
+ classes() {
99
+ return this.cm().cn(this.cm().flex({ align: 'center' }), this.className);
100
+ }
101
+ /**
102
+ * Computes the overflow chip's class list (`cm.flex({ align: 'center',
103
+ * justify: 'center' })` + `cm.roundedFull` + `cm.textSize('xs')` +
104
+ * `cm.fontWeight('medium')`).
105
+ * @returns The class string.
106
+ */
107
+ overflowClasses() {
108
+ const cm = this.cm();
109
+ return cm.cn(cm.flex({ align: 'center', justify: 'center' }), cm.roundedFull, cm.textSize('xs'), cm.fontWeight('medium'));
110
+ }
111
+ static ɵfac = function AvatarStack_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || AvatarStack)(); };
112
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AvatarStack, selectors: [["div", "mol-avatar-stack", ""]], hostVars: 2, hostBindings: function AvatarStack_HostBindings(rf, ctx) { if (rf & 2) {
113
+ i0.ɵɵclassMap(ctx.classes());
114
+ } }, inputs: { people: "people", max: "max", size: "size", className: "className" }, decls: 3, vars: 1, consts: [[3, "margin-left"], [3, "class", "margin-left"], ["mol-avatar", "", 3, "src", "alt", "name", "size"]], template: function AvatarStack_Template(rf, ctx) { if (rf & 1) {
115
+ i0.ɵɵrepeaterCreate(0, AvatarStack_For_1_Template, 2, 6, "span", 0, i0.ɵɵrepeaterTrackByIndex);
116
+ i0.ɵɵconditionalCreate(2, AvatarStack_Conditional_2_Template, 2, 6, "span", 1);
117
+ } if (rf & 2) {
118
+ i0.ɵɵrepeater(ctx.visible());
119
+ i0.ɵɵadvance(2);
120
+ i0.ɵɵconditional(ctx.overflow() > 0 ? 2 : -1);
121
+ } }, dependencies: [Avatar], encapsulation: 2 });
122
+ }
123
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AvatarStack, [{
124
+ type: Component,
125
+ args: [{
126
+ selector: 'div[mol-avatar-stack]',
127
+ standalone: true,
128
+ imports: [Avatar],
129
+ inputs: ['people', 'max', 'size', 'className'],
130
+ host: {
131
+ '[class]': 'classes()',
132
+ },
133
+ // prettier-ignore
134
+ template: `@for (person of visible(); track $index; let index = $index) {
135
+ <span [style.margin-left]="index === 0 ? null : overlapMargin">
136
+ <div mol-avatar [src]="person.src" [alt]="person.alt ?? person.name" [name]="person.name" [size]="avatarSize()"></div>
137
+ </span>
138
+ }@if (overflow() > 0) {
139
+ <span [class]="overflowClasses()" [style.margin-left]="overlapMargin" [attr.aria-label]="'+' + overflow() + ' more'">{{ '+' + overflow() }}</span>
140
+ }`,
141
+ }]
142
+ }], null, null); })();
143
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(AvatarStack, { className: "AvatarStack", filePath: "avatar-stack.component.ts", lineNumber: 51 }); })();
144
+ //# sourceMappingURL=avatar-stack.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatar-stack.component.js","sourceRoot":"","sources":["../src/avatar-stack.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAGzC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;;;IAiC7C,4BAA+D;IAC7D,yBAAsH;IACxH,iBAAO;;;;;IAFD,+EAAwD;IAC5C,cAAkB;IAAwD,AAArB,AAAlC,AAAnB,mCAAkB,wCAAkC,wBAAqB,6BAAsB;;;IAGjH,4BAAqH;IAAA,YAAsB;IAAA,iBAAO;;;IAA5I,uCAA2B;IAAC,mDAAmC;;IAAgD,cAAsB;IAAtB,6CAAsB;;AAjC/I;;;;;;;;GAQG;AACH,MAAM,cAAc,GAAG,SAAS,CAAA;AAEhC;;;;;;;GAOG;AAkBH,MAAM,OAAO,WAAW;IACtB,wBAAwB;IACxB,MAAM,GAAwB,EAAE,CAAA;IAChC,8DAA8D;IAC9D,GAAG,CAAS;IACZ,4DAA4D;IAC5D,IAAI,CAA4B;IAChC,wCAAwC;IACxC,SAAS,CAAS;IAElB,0CAA0C;IACjC,aAAa,GAAG,cAAc,CAAA;IAEvC;;;OAGG;IACH,EAAE;QACA,OAAO,WAAW,EAA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MAAM,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC;gBAC9C,IAAI,EAAE;oBACJ,SAAS,EAAE,WAAW;iBACvB;gBACD,kBAAkB;gBAClB,QAAQ,EAAE;;;;;;IAMR;aACH;;kFACY,WAAW"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Angular avatar-stack and user-chip components — the counterpart of
3
+ * `@molecule/app-avatar-stack-react`: the same props and the same DOM for the
4
+ * same input.
5
+ *
6
+ * Exports:
7
+ * - `<div mol-avatar-stack>` — horizontal stack of up to `max` avatars with a trailing "+N" overflow chip.
8
+ * - `<div mol-user-chip>` — avatar + name + optional subtitle row for dropdowns, mention pickers, and row-level user references.
9
+ *
10
+ * Both render on top of `<div mol-avatar>` from `@molecule/app-ui-angular`, so
11
+ * avatar fallbacks (text initials, color hash) come from there.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { Component } from '@angular/core'
16
+ * import { AvatarStack, UserChip } from '@molecule/app-avatar-stack-angular'
17
+ *
18
+ * @Component({
19
+ * selector: 'app-assignees',
20
+ * standalone: true,
21
+ * imports: [AvatarStack, UserChip],
22
+ * template: `
23
+ * <div mol-avatar-stack [people]="people" [max]="3" size="sm"></div>
24
+ * <div mol-user-chip name="Alice Kim" src="/avatars/alice.jpg">
25
+ * <span slot="subtitle">Admin</span>
26
+ * </div>
27
+ * `,
28
+ * })
29
+ * export class Assignees {
30
+ * people = [
31
+ * { name: 'Alice Kim', src: '/avatars/alice.jpg' },
32
+ * { name: 'Bob Lee' },
33
+ * { name: 'Carol Díaz', src: '/avatars/carol.jpg' },
34
+ * ]
35
+ * }
36
+ * ```
37
+ *
38
+ * @remarks
39
+ * The overflow chip announces "+N more" — this is the only user-visible
40
+ * text (currently English-only). Avatar fallbacks (initials, color hash)
41
+ * come from `<div mol-avatar>` in `@molecule/app-ui-angular`. The overlap is
42
+ * an inline negative left margin (`margin-left: -0.5rem`), not a ClassMap
43
+ * class: the abstract spacing scale is non-negative, so a negative margin is
44
+ * one of the sanctioned inline-style cases. Node props are projected
45
+ * content: `[slot=subtitle]` and `[slot=trailing]`.
46
+ *
47
+ * @module
48
+ */
49
+ export * from './avatar-stack.component.js';
50
+ export * from './types.js';
51
+ export * from './user-chip.component.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,6BAA6B,CAAA;AAC3C,cAAc,YAAY,CAAA;AAC1B,cAAc,0BAA0B,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Angular avatar-stack and user-chip components — the counterpart of
3
+ * `@molecule/app-avatar-stack-react`: the same props and the same DOM for the
4
+ * same input.
5
+ *
6
+ * Exports:
7
+ * - `<div mol-avatar-stack>` — horizontal stack of up to `max` avatars with a trailing "+N" overflow chip.
8
+ * - `<div mol-user-chip>` — avatar + name + optional subtitle row for dropdowns, mention pickers, and row-level user references.
9
+ *
10
+ * Both render on top of `<div mol-avatar>` from `@molecule/app-ui-angular`, so
11
+ * avatar fallbacks (text initials, color hash) come from there.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { Component } from '@angular/core'
16
+ * import { AvatarStack, UserChip } from '@molecule/app-avatar-stack-angular'
17
+ *
18
+ * @Component({
19
+ * selector: 'app-assignees',
20
+ * standalone: true,
21
+ * imports: [AvatarStack, UserChip],
22
+ * template: `
23
+ * <div mol-avatar-stack [people]="people" [max]="3" size="sm"></div>
24
+ * <div mol-user-chip name="Alice Kim" src="/avatars/alice.jpg">
25
+ * <span slot="subtitle">Admin</span>
26
+ * </div>
27
+ * `,
28
+ * })
29
+ * export class Assignees {
30
+ * people = [
31
+ * { name: 'Alice Kim', src: '/avatars/alice.jpg' },
32
+ * { name: 'Bob Lee' },
33
+ * { name: 'Carol Díaz', src: '/avatars/carol.jpg' },
34
+ * ]
35
+ * }
36
+ * ```
37
+ *
38
+ * @remarks
39
+ * The overflow chip announces "+N more" — this is the only user-visible
40
+ * text (currently English-only). Avatar fallbacks (initials, color hash)
41
+ * come from `<div mol-avatar>` in `@molecule/app-ui-angular`. The overlap is
42
+ * an inline negative left margin (`margin-left: -0.5rem`), not a ClassMap
43
+ * class: the abstract spacing scale is non-negative, so a negative margin is
44
+ * one of the sanctioned inline-style cases. Node props are projected
45
+ * content: `[slot=subtitle]` and `[slot=trailing]`.
46
+ *
47
+ * @module
48
+ */
49
+ export * from './avatar-stack.component.js';
50
+ export * from './types.js';
51
+ export * from './user-chip.component.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,6BAA6B,CAAA;AAC3C,cAAc,YAAY,CAAA;AAC1B,cAAc,0BAA0B,CAAA"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Types of `@molecule/app-avatar-stack-angular` — the Angular counterpart of
3
+ * `@molecule/app-avatar-stack-react`, same props and DOM.
4
+ *
5
+ * @module
6
+ */
7
+ /** Represents a single person entry rendered inside an AvatarStack. */
8
+ export interface AvatarStackPerson {
9
+ /** Display name (also used to generate the text fallback). */
10
+ name: string;
11
+ /** Optional avatar image URL. */
12
+ src?: string;
13
+ /** Optional alt text — defaults to `name`. */
14
+ alt?: string;
15
+ }
16
+ /**
17
+ * Props accepted by {@link AvatarStack} — the same props
18
+ * `@molecule/app-avatar-stack-react` accepts. The list itself is the `people`
19
+ * input, so every prop is bindable.
20
+ */
21
+ export interface AvatarStackProps {
22
+ /** People to render. */
23
+ people: AvatarStackPerson[];
24
+ /** Maximum visible avatars. Remaining are summarised in an "overflow" chip. */
25
+ max?: number;
26
+ /** Avatar size preset. */
27
+ size?: 'xs' | 'sm' | 'md' | 'lg';
28
+ /** Extra classes on the outer stack. */
29
+ className?: string;
30
+ }
31
+ /**
32
+ * Props accepted by {@link UserChip} — the same props
33
+ * `@molecule/app-avatar-stack-react` accepts. Node props (`subtitle`,
34
+ * `trailing`) are projected content in Angular (an input cannot carry a node),
35
+ * so they are typed `unknown`: pass them in the host template, projected as
36
+ * `[slot=subtitle]` / `[slot=trailing]`.
37
+ */
38
+ export interface UserChipProps {
39
+ /** Display name. */
40
+ name: string;
41
+ /** Optional avatar image URL. */
42
+ src?: string;
43
+ /** Optional secondary line (role / email / handle), projected as `[slot=subtitle]` content. */
44
+ subtitle?: unknown;
45
+ /** Optional trailing content (action button, status dot, etc.), projected as `[slot=trailing]` content. */
46
+ trailing?: unknown;
47
+ /** Avatar size preset. */
48
+ size?: 'xs' | 'sm' | 'md' | 'lg';
49
+ /** Extra classes on the outer row. */
50
+ className?: string;
51
+ }
52
+ //# 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,uEAAuE;AACvE,MAAM,WAAW,iBAAiB;IAChC,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAA;IACZ,iCAAiC;IACjC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,8CAA8C;IAC9C,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wBAAwB;IACxB,MAAM,EAAE,iBAAiB,EAAE,CAAA;IAC3B,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,0BAA0B;IAC1B,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;IAChC,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,iCAAiC;IACjC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,+FAA+F;IAC/F,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,2GAA2G;IAC3G,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,0BAA0B;IAC1B,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;IAChC,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
package/dist/types.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Types of `@molecule/app-avatar-stack-angular` — the Angular counterpart of
3
+ * `@molecule/app-avatar-stack-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"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * UserChip component (React parity).
3
+ *
4
+ * @module
5
+ */
6
+ import { type AfterViewInit } from '@angular/core';
7
+ import type { UIClassMap } from '@molecule/app-ui';
8
+ import * as i0 from "@angular/core";
9
+ /**
10
+ * UserChip component.
11
+ *
12
+ * Avatar + name + optional subtitle row — useful in dropdowns, mention
13
+ * pickers, assignment popovers, and row-level user references. The host IS the
14
+ * outer `<div>` (`div[mol-user-chip]`), matching React's root exactly. The
15
+ * node props are projected slots: `subtitle` renders inside its own
16
+ * `<span>`, `trailing` renders bare at the end of the row. The subtitle span
17
+ * renders optimistically so a projection can land, then withdraws at view
18
+ * init when neither a text input nor a projection is present — React renders
19
+ * no span at all for an absent or empty subtitle.
20
+ */
21
+ export declare class UserChip implements AfterViewInit {
22
+ /** Display name. */
23
+ name: string;
24
+ /** Optional avatar image URL. */
25
+ src?: string;
26
+ /** Optional secondary line: text, or `[slot=subtitle]` content. */
27
+ subtitle?: unknown;
28
+ /** Optional trailing content: projected `[slot=trailing]` content. */
29
+ trailing?: unknown;
30
+ /** Avatar size preset (defaults to `'sm'` at read time). */
31
+ size?: 'xs' | 'sm' | 'md' | 'lg';
32
+ /** Extra classes on the outer row. */
33
+ className?: string;
34
+ /** The optimistic subtitle span (projected content lands here). */
35
+ private subtitleEl?;
36
+ /** Whether the subtitle span renders (withdrawn when nothing fills it). */
37
+ private readonly subtitleProjected;
38
+ /**
39
+ * The current class map.
40
+ * @returns The UIClassMap.
41
+ */
42
+ cm(): UIClassMap;
43
+ /**
44
+ * The avatar size passed to `<div mol-avatar>` (React's `size = 'sm'`
45
+ * default parameter).
46
+ * @returns The size preset.
47
+ */
48
+ avatarSize(): 'xs' | 'sm' | 'md' | 'lg';
49
+ /**
50
+ * Whether the subtitle span renders.
51
+ * @returns True while the span is kept.
52
+ */
53
+ showSubtitle(): boolean;
54
+ /**
55
+ * Whether the subtitle input itself carries text (React's `{subtitle}` for
56
+ * a string child; a node arrives as `[slot=subtitle]` content instead).
57
+ * @returns True for a string or number subtitle.
58
+ */
59
+ hasTextSubtitle(): boolean;
60
+ /**
61
+ * Computes the outer row's class list (`cm.flex({ align: 'center', gap:
62
+ * 'sm' })` + `className`).
63
+ * @returns The class string.
64
+ */
65
+ classes(): string;
66
+ /**
67
+ * Computes the name/subtitle column's class list (`cm.flex1` +
68
+ * `cm.stack(0)`).
69
+ * @returns The class string.
70
+ */
71
+ bodyClasses(): string;
72
+ /**
73
+ * Computes the name span's class list (`cm.textSize('sm')` +
74
+ * `cm.fontWeight('medium')`).
75
+ * @returns The class string.
76
+ */
77
+ nameClasses(): string;
78
+ /**
79
+ * Withdraws the optimistic subtitle span when its slot projection did not
80
+ * land: when neither a text input nor projected content is present, React
81
+ * renders no span at all. View queries resolve at view init, and a projected
82
+ * slot's content is in place by then.
83
+ */
84
+ ngAfterViewInit(): void;
85
+ static ɵfac: i0.ɵɵFactoryDeclaration<UserChip, never>;
86
+ static ɵcmp: i0.ɵɵComponentDeclaration<UserChip, "div[mol-user-chip]", never, { "name": { "alias": "name"; "required": false; }; "src": { "alias": "src"; "required": false; }; "subtitle": { "alias": "subtitle"; "required": false; }; "trailing": { "alias": "trailing"; "required": false; }; "size": { "alias": "size"; "required": false; }; "className": { "alias": "className"; "required": false; }; }, {}, never, ["[slot=subtitle]", "[slot=trailing]"], true, never>;
87
+ }
88
+ //# sourceMappingURL=user-chip.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-chip.component.d.ts","sourceRoot":"","sources":["../src/user-chip.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAiD,MAAM,eAAe,CAAA;AAEjG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;;AAIlD;;;;;;;;;;;GAWG;AACH,qBAgBa,QAAS,YAAW,aAAa;IAC5C,oBAAoB;IACpB,IAAI,SAAK;IACT,iCAAiC;IACjC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,mEAAmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,4DAA4D;IAC5D,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;IAChC,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,mEAAmE;IAC1C,OAAO,CAAC,UAAU,CAAC,CAA6B;IAEzE,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAe;IAEjD;;;OAGG;IACH,EAAE,IAAI,UAAU;IAIhB;;;;OAIG;IACH,UAAU,IAAI,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI;IAIvC;;;OAGG;IACH,YAAY,IAAI,OAAO;IAIvB;;;;OAIG;IACH,eAAe,IAAI,OAAO;IAI1B;;;;OAIG;IACH,OAAO,IAAI,MAAM;IAIjB;;;;OAIG;IACH,WAAW,IAAI,MAAM;IAIrB;;;;OAIG;IACH,WAAW,IAAI,MAAM;IAIrB;;;;;OAKG;IACH,eAAe,IAAI,IAAI;yCAvFZ,QAAQ;2CAAR,QAAQ;CA6FpB"}
@@ -0,0 +1,181 @@
1
+ /**
2
+ * UserChip component (React parity).
3
+ *
4
+ * @module
5
+ */
6
+ import { Component, signal, ViewChild } from '@angular/core';
7
+ import { getClassMap } from '@molecule/app-ui';
8
+ import { Avatar, hasNodes } from '@molecule/app-ui-angular';
9
+ import * as i0 from "@angular/core";
10
+ const _c0 = ["subtitleEl"];
11
+ const _c1 = [[["", "slot", "trailing"]], [["", "slot", "subtitle"]]];
12
+ const _c2 = ["[slot=trailing]", "[slot=subtitle]"];
13
+ function UserChip_Conditional_4_Conditional_2_Template(rf, ctx) { if (rf & 1) {
14
+ i0.ɵɵelementContainerStart(0);
15
+ i0.ɵɵtext(1);
16
+ i0.ɵɵelementContainerEnd();
17
+ } if (rf & 2) {
18
+ const ctx_r0 = i0.ɵɵnextContext(2);
19
+ i0.ɵɵadvance();
20
+ i0.ɵɵtextInterpolate(ctx_r0.subtitle);
21
+ } }
22
+ function UserChip_Conditional_4_Template(rf, ctx) { if (rf & 1) {
23
+ i0.ɵɵelementStart(0, "span", null, 0);
24
+ i0.ɵɵconditionalCreate(2, UserChip_Conditional_4_Conditional_2_Template, 2, 1, "ng-container");
25
+ i0.ɵɵprojection(3, 1);
26
+ i0.ɵɵelementEnd();
27
+ } if (rf & 2) {
28
+ const ctx_r0 = i0.ɵɵnextContext();
29
+ i0.ɵɵclassMap(ctx_r0.cm().textSize("xs"));
30
+ i0.ɵɵadvance(2);
31
+ i0.ɵɵconditional(ctx_r0.hasTextSubtitle() ? 2 : -1);
32
+ } }
33
+ /**
34
+ * UserChip component.
35
+ *
36
+ * Avatar + name + optional subtitle row — useful in dropdowns, mention
37
+ * pickers, assignment popovers, and row-level user references. The host IS the
38
+ * outer `<div>` (`div[mol-user-chip]`), matching React's root exactly. The
39
+ * node props are projected slots: `subtitle` renders inside its own
40
+ * `<span>`, `trailing` renders bare at the end of the row. The subtitle span
41
+ * renders optimistically so a projection can land, then withdraws at view
42
+ * init when neither a text input nor a projection is present — React renders
43
+ * no span at all for an absent or empty subtitle.
44
+ */
45
+ export class UserChip {
46
+ /** Display name. */
47
+ name = '';
48
+ /** Optional avatar image URL. */
49
+ src;
50
+ /** Optional secondary line: text, or `[slot=subtitle]` content. */
51
+ subtitle;
52
+ /** Optional trailing content: projected `[slot=trailing]` content. */
53
+ trailing;
54
+ /** Avatar size preset (defaults to `'sm'` at read time). */
55
+ size;
56
+ /** Extra classes on the outer row. */
57
+ className;
58
+ /** The optimistic subtitle span (projected content lands here). */
59
+ subtitleEl;
60
+ /** Whether the subtitle span renders (withdrawn when nothing fills it). */
61
+ subtitleProjected = signal(true, /* @ts-ignore */
62
+ ...(ngDevMode ? [{ debugName: "subtitleProjected" }] : /* istanbul ignore next */ []));
63
+ /**
64
+ * The current class map.
65
+ * @returns The UIClassMap.
66
+ */
67
+ cm() {
68
+ return getClassMap();
69
+ }
70
+ /**
71
+ * The avatar size passed to `<div mol-avatar>` (React's `size = 'sm'`
72
+ * default parameter).
73
+ * @returns The size preset.
74
+ */
75
+ avatarSize() {
76
+ return this.size ?? 'sm';
77
+ }
78
+ /**
79
+ * Whether the subtitle span renders.
80
+ * @returns True while the span is kept.
81
+ */
82
+ showSubtitle() {
83
+ return this.subtitleProjected();
84
+ }
85
+ /**
86
+ * Whether the subtitle input itself carries text (React's `{subtitle}` for
87
+ * a string child; a node arrives as `[slot=subtitle]` content instead).
88
+ * @returns True for a string or number subtitle.
89
+ */
90
+ hasTextSubtitle() {
91
+ return typeof this.subtitle === 'string' || typeof this.subtitle === 'number';
92
+ }
93
+ /**
94
+ * Computes the outer row's class list (`cm.flex({ align: 'center', gap:
95
+ * 'sm' })` + `className`).
96
+ * @returns The class string.
97
+ */
98
+ classes() {
99
+ return this.cm().cn(this.cm().flex({ align: 'center', gap: 'sm' }), this.className);
100
+ }
101
+ /**
102
+ * Computes the name/subtitle column's class list (`cm.flex1` +
103
+ * `cm.stack(0)`).
104
+ * @returns The class string.
105
+ */
106
+ bodyClasses() {
107
+ return this.cm().cn(this.cm().flex1, this.cm().stack(0));
108
+ }
109
+ /**
110
+ * Computes the name span's class list (`cm.textSize('sm')` +
111
+ * `cm.fontWeight('medium')`).
112
+ * @returns The class string.
113
+ */
114
+ nameClasses() {
115
+ return this.cm().cn(this.cm().textSize('sm'), this.cm().fontWeight('medium'));
116
+ }
117
+ /**
118
+ * Withdraws the optimistic subtitle span when its slot projection did not
119
+ * land: when neither a text input nor projected content is present, React
120
+ * renders no span at all. View queries resolve at view init, and a projected
121
+ * slot's content is in place by then.
122
+ */
123
+ ngAfterViewInit() {
124
+ const subtitle = this.subtitleEl?.nativeElement;
125
+ if (subtitle && !this.hasTextSubtitle() && !hasNodes(subtitle)) {
126
+ this.subtitleProjected.set(false);
127
+ }
128
+ }
129
+ static ɵfac = function UserChip_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || UserChip)(); };
130
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: UserChip, selectors: [["div", "mol-user-chip", ""]], viewQuery: function UserChip_Query(rf, ctx) { if (rf & 1) {
131
+ i0.ɵɵviewQuery(_c0, 5);
132
+ } if (rf & 2) {
133
+ let _t;
134
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.subtitleEl = _t.first);
135
+ } }, hostVars: 2, hostBindings: function UserChip_HostBindings(rf, ctx) { if (rf & 2) {
136
+ i0.ɵɵclassMap(ctx.classes());
137
+ } }, inputs: { name: "name", src: "src", subtitle: "subtitle", trailing: "trailing", size: "size", className: "className" }, ngContentSelectors: _c2, decls: 6, vars: 10, consts: [["subtitleEl", ""], ["mol-avatar", "", 3, "src", "alt", "name", "size"], [3, "class"]], template: function UserChip_Template(rf, ctx) { if (rf & 1) {
138
+ i0.ɵɵprojectionDef(_c1);
139
+ i0.ɵɵelement(0, "div", 1);
140
+ i0.ɵɵelementStart(1, "div")(2, "span");
141
+ i0.ɵɵtext(3);
142
+ i0.ɵɵelementEnd();
143
+ i0.ɵɵconditionalCreate(4, UserChip_Conditional_4_Template, 4, 3, "span", 2);
144
+ i0.ɵɵelementEnd();
145
+ i0.ɵɵprojection(5);
146
+ } if (rf & 2) {
147
+ i0.ɵɵproperty("src", ctx.src)("alt", ctx.name)("name", ctx.name)("size", ctx.avatarSize());
148
+ i0.ɵɵadvance();
149
+ i0.ɵɵclassMap(ctx.bodyClasses());
150
+ i0.ɵɵadvance();
151
+ i0.ɵɵclassMap(ctx.nameClasses());
152
+ i0.ɵɵadvance();
153
+ i0.ɵɵtextInterpolate(ctx.name);
154
+ i0.ɵɵadvance();
155
+ i0.ɵɵconditional(ctx.showSubtitle() ? 4 : -1);
156
+ } }, dependencies: [Avatar], encapsulation: 2 });
157
+ }
158
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UserChip, [{
159
+ type: Component,
160
+ args: [{
161
+ selector: 'div[mol-user-chip]',
162
+ standalone: true,
163
+ imports: [Avatar],
164
+ inputs: ['name', 'src', 'subtitle', 'trailing', 'size', 'className'],
165
+ host: {
166
+ '[class]': 'classes()',
167
+ },
168
+ // prettier-ignore
169
+ template: `<div mol-avatar [src]="src" [alt]="name" [name]="name" [size]="avatarSize()"></div>
170
+ <div [class]="bodyClasses()">
171
+ <span [class]="nameClasses()">{{ name }}</span>
172
+ @if (showSubtitle()) {<span #subtitleEl [class]="cm().textSize('xs')">@if (hasTextSubtitle()) {<ng-container>{{ subtitle }}</ng-container>}<ng-content select="[slot=subtitle]"></ng-content></span>}
173
+ </div>
174
+ <ng-content select="[slot=trailing]"></ng-content>`,
175
+ }]
176
+ }], null, { subtitleEl: [{
177
+ type: ViewChild,
178
+ args: ['subtitleEl']
179
+ }] }); })();
180
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(UserChip, { className: "UserChip", filePath: "user-chip.component.ts", lineNumber: 41 }); })();
181
+ //# sourceMappingURL=user-chip.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-chip.component.js","sourceRoot":"","sources":["../src/user-chip.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAsB,SAAS,EAAmB,MAAM,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAGjG,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;;;;;;IA0B0C,6BAAc;IAAA,YAAc;;;;IAAd,cAAc;IAAd,qCAAc;;;IAArG,qCAAgD;IAAA,8FAAyB;IAA4C,qBAAkD;IAAA,iBAAO;;;IAA5J,yCAA6B;IAAC,eAAqE;IAArE,mDAAqE;;AAxBjJ;;;;;;;;;;;GAWG;AAiBH,MAAM,OAAO,QAAQ;IACnB,oBAAoB;IACpB,IAAI,GAAG,EAAE,CAAA;IACT,iCAAiC;IACjC,GAAG,CAAS;IACZ,mEAAmE;IACnE,QAAQ,CAAU;IAClB,sEAAsE;IACtE,QAAQ,CAAU;IAClB,4DAA4D;IAC5D,IAAI,CAA4B;IAChC,sCAAsC;IACtC,SAAS,CAAS;IAElB,mEAAmE;IAClC,UAAU,CAA8B;IAEzE,2EAA2E;IAC1D,iBAAiB,GAAG,MAAM,CAAC,IAAI;0FAAC,CAAA;IAEjD;;;OAGG;IACH,EAAE;QACA,OAAO,WAAW,EAAE,CAAA;IACtB,CAAC;IAED;;;;OAIG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,IAAI,IAAI,IAAI,CAAA;IAC1B,CAAC;IAED;;;OAGG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,iBAAiB,EAAE,CAAA;IACjC,CAAC;IAED;;;;OAIG;IACH,eAAe;QACb,OAAO,OAAO,IAAI,CAAC,QAAQ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