ngx-com 0.0.1 → 0.0.4
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/fesm2022/ngx-com-components-avatar.mjs +772 -0
- package/fesm2022/ngx-com-components-avatar.mjs.map +1 -0
- package/fesm2022/ngx-com-components-badge.mjs +138 -0
- package/fesm2022/ngx-com-components-badge.mjs.map +1 -0
- package/fesm2022/ngx-com-components-button.mjs +146 -0
- package/fesm2022/ngx-com-components-button.mjs.map +1 -0
- package/fesm2022/ngx-com-components-calendar.mjs +5046 -0
- package/fesm2022/ngx-com-components-calendar.mjs.map +1 -0
- package/fesm2022/ngx-com-components-card.mjs +590 -0
- package/fesm2022/ngx-com-components-card.mjs.map +1 -0
- package/fesm2022/ngx-com-components-checkbox.mjs +344 -0
- package/fesm2022/ngx-com-components-checkbox.mjs.map +1 -0
- package/fesm2022/ngx-com-components-collapsible.mjs +612 -0
- package/fesm2022/ngx-com-components-collapsible.mjs.map +1 -0
- package/fesm2022/ngx-com-components-confirm.mjs +562 -0
- package/fesm2022/ngx-com-components-confirm.mjs.map +1 -0
- package/fesm2022/ngx-com-components-dropdown-testing.mjs +255 -0
- package/fesm2022/ngx-com-components-dropdown-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-dropdown.mjs +2692 -0
- package/fesm2022/ngx-com-components-dropdown.mjs.map +1 -0
- package/fesm2022/ngx-com-components-empty-state.mjs +382 -0
- package/fesm2022/ngx-com-components-empty-state.mjs.map +1 -0
- package/fesm2022/ngx-com-components-form-field.mjs +924 -0
- package/fesm2022/ngx-com-components-form-field.mjs.map +1 -0
- package/fesm2022/ngx-com-components-icon.mjs +183 -0
- package/fesm2022/ngx-com-components-icon.mjs.map +1 -0
- package/fesm2022/ngx-com-components-item.mjs +578 -0
- package/fesm2022/ngx-com-components-item.mjs.map +1 -0
- package/fesm2022/ngx-com-components-menu.mjs +1200 -0
- package/fesm2022/ngx-com-components-menu.mjs.map +1 -0
- package/fesm2022/ngx-com-components-paginator.mjs +823 -0
- package/fesm2022/ngx-com-components-paginator.mjs.map +1 -0
- package/fesm2022/ngx-com-components-popover.mjs +901 -0
- package/fesm2022/ngx-com-components-popover.mjs.map +1 -0
- package/fesm2022/ngx-com-components-radio.mjs +621 -0
- package/fesm2022/ngx-com-components-radio.mjs.map +1 -0
- package/fesm2022/ngx-com-components-segmented-control.mjs +538 -0
- package/fesm2022/ngx-com-components-segmented-control.mjs.map +1 -0
- package/fesm2022/ngx-com-components-sort.mjs +368 -0
- package/fesm2022/ngx-com-components-sort.mjs.map +1 -0
- package/fesm2022/ngx-com-components-spinner.mjs +189 -0
- package/fesm2022/ngx-com-components-spinner.mjs.map +1 -0
- package/fesm2022/ngx-com-components-tabs.mjs +1522 -0
- package/fesm2022/ngx-com-components-tabs.mjs.map +1 -0
- package/fesm2022/ngx-com-components-tooltip.mjs +625 -0
- package/fesm2022/ngx-com-components-tooltip.mjs.map +1 -0
- package/fesm2022/ngx-com-components.mjs +17 -0
- package/fesm2022/ngx-com-components.mjs.map +1 -0
- package/fesm2022/ngx-com-tokens.mjs +12 -0
- package/fesm2022/ngx-com-tokens.mjs.map +1 -0
- package/fesm2022/ngx-com-utils.mjs +601 -0
- package/fesm2022/ngx-com-utils.mjs.map +1 -0
- package/fesm2022/ngx-com.mjs +9 -23
- package/fesm2022/ngx-com.mjs.map +1 -1
- package/package.json +105 -1
- package/types/ngx-com-components-avatar.d.ts +409 -0
- package/types/ngx-com-components-badge.d.ts +97 -0
- package/types/ngx-com-components-button.d.ts +69 -0
- package/types/ngx-com-components-calendar.d.ts +1665 -0
- package/types/ngx-com-components-card.d.ts +373 -0
- package/types/ngx-com-components-checkbox.d.ts +116 -0
- package/types/ngx-com-components-collapsible.d.ts +379 -0
- package/types/ngx-com-components-confirm.d.ts +160 -0
- package/types/ngx-com-components-dropdown-testing.d.ts +116 -0
- package/types/ngx-com-components-dropdown.d.ts +938 -0
- package/types/ngx-com-components-empty-state.d.ts +269 -0
- package/types/ngx-com-components-form-field.d.ts +531 -0
- package/types/ngx-com-components-icon.d.ts +94 -0
- package/types/ngx-com-components-item.d.ts +336 -0
- package/types/ngx-com-components-menu.d.ts +479 -0
- package/types/ngx-com-components-paginator.d.ts +265 -0
- package/types/ngx-com-components-popover.d.ts +309 -0
- package/types/ngx-com-components-radio.d.ts +258 -0
- package/types/ngx-com-components-segmented-control.d.ts +274 -0
- package/types/ngx-com-components-sort.d.ts +133 -0
- package/types/ngx-com-components-spinner.d.ts +120 -0
- package/types/ngx-com-components-tabs.d.ts +396 -0
- package/types/ngx-com-components-tooltip.d.ts +200 -0
- package/types/ngx-com-components.d.ts +12 -0
- package/types/ngx-com-tokens.d.ts +7 -0
- package/types/ngx-com-utils.d.ts +424 -0
- package/types/ngx-com.d.ts +10 -7
package/fesm2022/ngx-com.mjs
CHANGED
|
@@ -1,30 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
com works!
|
|
9
|
-
</p>
|
|
10
|
-
`, isInline: true, styles: [""] });
|
|
11
|
-
}
|
|
12
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: Com, decorators: [{
|
|
13
|
-
type: Component,
|
|
14
|
-
args: [{ selector: 'com-com', imports: [], template: `
|
|
15
|
-
<p>
|
|
16
|
-
com works!
|
|
17
|
-
</p>
|
|
18
|
-
` }]
|
|
19
|
-
}] });
|
|
20
|
-
|
|
21
|
-
/*
|
|
22
|
-
* Public API Surface of com
|
|
1
|
+
/**
|
|
2
|
+
* Public API Surface of ngx-com
|
|
3
|
+
*
|
|
4
|
+
* For specific imports, use subpaths:
|
|
5
|
+
* - ngx-com/components
|
|
6
|
+
* - ngx-com/utils
|
|
7
|
+
* - ngx-com/tokens
|
|
23
8
|
*/
|
|
9
|
+
const VERSION = '0.0.1';
|
|
24
10
|
|
|
25
11
|
/**
|
|
26
12
|
* Generated bundle index. Do not edit.
|
|
27
13
|
*/
|
|
28
14
|
|
|
29
|
-
export {
|
|
15
|
+
export { VERSION };
|
|
30
16
|
//# sourceMappingURL=ngx-com.mjs.map
|
package/fesm2022/ngx-com.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngx-com.mjs","sources":["../../../projects/com/src/
|
|
1
|
+
{"version":3,"file":"ngx-com.mjs","sources":["../../../projects/com/src/public-api.ts","../../../projects/com/src/ngx-com.ts"],"sourcesContent":["/**\n * Public API Surface of ngx-com\n *\n * For specific imports, use subpaths:\n * - ngx-com/components\n * - ngx-com/utils\n * - ngx-com/tokens\n */\n\nexport const VERSION = '0.0.1';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAAA;;;;;;;AAOG;AAEI,MAAM,OAAO,GAAG;;ACTvB;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ngx-com",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/avs2001/ngx-com"
|
|
@@ -22,6 +22,110 @@
|
|
|
22
22
|
".": {
|
|
23
23
|
"types": "./types/ngx-com.d.ts",
|
|
24
24
|
"default": "./fesm2022/ngx-com.mjs"
|
|
25
|
+
},
|
|
26
|
+
"./components": {
|
|
27
|
+
"types": "./types/ngx-com-components.d.ts",
|
|
28
|
+
"default": "./fesm2022/ngx-com-components.mjs"
|
|
29
|
+
},
|
|
30
|
+
"./components/avatar": {
|
|
31
|
+
"types": "./types/ngx-com-components-avatar.d.ts",
|
|
32
|
+
"default": "./fesm2022/ngx-com-components-avatar.mjs"
|
|
33
|
+
},
|
|
34
|
+
"./components/badge": {
|
|
35
|
+
"types": "./types/ngx-com-components-badge.d.ts",
|
|
36
|
+
"default": "./fesm2022/ngx-com-components-badge.mjs"
|
|
37
|
+
},
|
|
38
|
+
"./components/button": {
|
|
39
|
+
"types": "./types/ngx-com-components-button.d.ts",
|
|
40
|
+
"default": "./fesm2022/ngx-com-components-button.mjs"
|
|
41
|
+
},
|
|
42
|
+
"./components/calendar": {
|
|
43
|
+
"types": "./types/ngx-com-components-calendar.d.ts",
|
|
44
|
+
"default": "./fesm2022/ngx-com-components-calendar.mjs"
|
|
45
|
+
},
|
|
46
|
+
"./components/card": {
|
|
47
|
+
"types": "./types/ngx-com-components-card.d.ts",
|
|
48
|
+
"default": "./fesm2022/ngx-com-components-card.mjs"
|
|
49
|
+
},
|
|
50
|
+
"./components/checkbox": {
|
|
51
|
+
"types": "./types/ngx-com-components-checkbox.d.ts",
|
|
52
|
+
"default": "./fesm2022/ngx-com-components-checkbox.mjs"
|
|
53
|
+
},
|
|
54
|
+
"./components/collapsible": {
|
|
55
|
+
"types": "./types/ngx-com-components-collapsible.d.ts",
|
|
56
|
+
"default": "./fesm2022/ngx-com-components-collapsible.mjs"
|
|
57
|
+
},
|
|
58
|
+
"./components/confirm": {
|
|
59
|
+
"types": "./types/ngx-com-components-confirm.d.ts",
|
|
60
|
+
"default": "./fesm2022/ngx-com-components-confirm.mjs"
|
|
61
|
+
},
|
|
62
|
+
"./components/dropdown": {
|
|
63
|
+
"types": "./types/ngx-com-components-dropdown.d.ts",
|
|
64
|
+
"default": "./fesm2022/ngx-com-components-dropdown.mjs"
|
|
65
|
+
},
|
|
66
|
+
"./components/dropdown/testing": {
|
|
67
|
+
"types": "./types/ngx-com-components-dropdown-testing.d.ts",
|
|
68
|
+
"default": "./fesm2022/ngx-com-components-dropdown-testing.mjs"
|
|
69
|
+
},
|
|
70
|
+
"./components/empty-state": {
|
|
71
|
+
"types": "./types/ngx-com-components-empty-state.d.ts",
|
|
72
|
+
"default": "./fesm2022/ngx-com-components-empty-state.mjs"
|
|
73
|
+
},
|
|
74
|
+
"./components/form-field": {
|
|
75
|
+
"types": "./types/ngx-com-components-form-field.d.ts",
|
|
76
|
+
"default": "./fesm2022/ngx-com-components-form-field.mjs"
|
|
77
|
+
},
|
|
78
|
+
"./components/icon": {
|
|
79
|
+
"types": "./types/ngx-com-components-icon.d.ts",
|
|
80
|
+
"default": "./fesm2022/ngx-com-components-icon.mjs"
|
|
81
|
+
},
|
|
82
|
+
"./components/item": {
|
|
83
|
+
"types": "./types/ngx-com-components-item.d.ts",
|
|
84
|
+
"default": "./fesm2022/ngx-com-components-item.mjs"
|
|
85
|
+
},
|
|
86
|
+
"./components/menu": {
|
|
87
|
+
"types": "./types/ngx-com-components-menu.d.ts",
|
|
88
|
+
"default": "./fesm2022/ngx-com-components-menu.mjs"
|
|
89
|
+
},
|
|
90
|
+
"./components/paginator": {
|
|
91
|
+
"types": "./types/ngx-com-components-paginator.d.ts",
|
|
92
|
+
"default": "./fesm2022/ngx-com-components-paginator.mjs"
|
|
93
|
+
},
|
|
94
|
+
"./components/popover": {
|
|
95
|
+
"types": "./types/ngx-com-components-popover.d.ts",
|
|
96
|
+
"default": "./fesm2022/ngx-com-components-popover.mjs"
|
|
97
|
+
},
|
|
98
|
+
"./components/radio": {
|
|
99
|
+
"types": "./types/ngx-com-components-radio.d.ts",
|
|
100
|
+
"default": "./fesm2022/ngx-com-components-radio.mjs"
|
|
101
|
+
},
|
|
102
|
+
"./components/segmented-control": {
|
|
103
|
+
"types": "./types/ngx-com-components-segmented-control.d.ts",
|
|
104
|
+
"default": "./fesm2022/ngx-com-components-segmented-control.mjs"
|
|
105
|
+
},
|
|
106
|
+
"./components/sort": {
|
|
107
|
+
"types": "./types/ngx-com-components-sort.d.ts",
|
|
108
|
+
"default": "./fesm2022/ngx-com-components-sort.mjs"
|
|
109
|
+
},
|
|
110
|
+
"./components/spinner": {
|
|
111
|
+
"types": "./types/ngx-com-components-spinner.d.ts",
|
|
112
|
+
"default": "./fesm2022/ngx-com-components-spinner.mjs"
|
|
113
|
+
},
|
|
114
|
+
"./components/tabs": {
|
|
115
|
+
"types": "./types/ngx-com-components-tabs.d.ts",
|
|
116
|
+
"default": "./fesm2022/ngx-com-components-tabs.mjs"
|
|
117
|
+
},
|
|
118
|
+
"./components/tooltip": {
|
|
119
|
+
"types": "./types/ngx-com-components-tooltip.d.ts",
|
|
120
|
+
"default": "./fesm2022/ngx-com-components-tooltip.mjs"
|
|
121
|
+
},
|
|
122
|
+
"./tokens": {
|
|
123
|
+
"types": "./types/ngx-com-tokens.d.ts",
|
|
124
|
+
"default": "./fesm2022/ngx-com-tokens.mjs"
|
|
125
|
+
},
|
|
126
|
+
"./utils": {
|
|
127
|
+
"types": "./types/ngx-com-utils.d.ts",
|
|
128
|
+
"default": "./fesm2022/ngx-com-utils.mjs"
|
|
25
129
|
}
|
|
26
130
|
}
|
|
27
131
|
}
|
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { TemplateRef, ElementRef, InputSignal, OutputEmitterRef, Signal, WritableSignal } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
/** Avatar size variants. */
|
|
5
|
+
type AvatarSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
6
|
+
/** Avatar color variants. */
|
|
7
|
+
type AvatarColor = 'primary' | 'accent' | 'muted' | 'warn' | 'auto';
|
|
8
|
+
/** Avatar shape variants. */
|
|
9
|
+
type AvatarShape = 'circle' | 'rounded';
|
|
10
|
+
/** Avatar variant types. */
|
|
11
|
+
type AvatarVariant = 'soft' | 'filled' | 'outline';
|
|
12
|
+
/** Resolved color (excludes 'auto' which is computed at runtime). */
|
|
13
|
+
type ResolvedAvatarColor = Exclude<AvatarColor, 'auto'>;
|
|
14
|
+
/**
|
|
15
|
+
* Generates initials from a display name.
|
|
16
|
+
*
|
|
17
|
+
* @param name - The display name to extract initials from
|
|
18
|
+
* @param maxLength - Maximum number of characters (default: 2)
|
|
19
|
+
* @returns Uppercase initials, or empty string if name is empty
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* getInitials('Jane Doe') // 'JD'
|
|
24
|
+
* getInitials('Jane') // 'JA'
|
|
25
|
+
* getInitials('Jane Marie Doe') // 'JD' (first + last)
|
|
26
|
+
* getInitials('j') // 'J'
|
|
27
|
+
* getInitials('') // ''
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare function getInitials(name: string, maxLength?: number): string;
|
|
31
|
+
/**
|
|
32
|
+
* CVA variants for the avatar container.
|
|
33
|
+
*
|
|
34
|
+
* @tokens `--color-primary`, `--color-primary-foreground`, `--color-primary-subtle`, `--color-primary-subtle-foreground`,
|
|
35
|
+
* `--color-accent`, `--color-accent-foreground`, `--color-accent-subtle`, `--color-accent-subtle-foreground`,
|
|
36
|
+
* `--color-warn`, `--color-warn-foreground`, `--color-warn-subtle`, `--color-warn-subtle-foreground`,
|
|
37
|
+
* `--color-muted`, `--color-muted-foreground`,
|
|
38
|
+
* `--color-border`, `--color-background`, `--color-foreground`, `--color-ring`
|
|
39
|
+
*/
|
|
40
|
+
declare const avatarVariants: (props?: {
|
|
41
|
+
size?: AvatarSize;
|
|
42
|
+
shape?: AvatarShape;
|
|
43
|
+
interactive?: boolean;
|
|
44
|
+
}) => string;
|
|
45
|
+
/**
|
|
46
|
+
* CVA variants for the avatar color/variant styling.
|
|
47
|
+
* These are applied based on the resolved color and variant.
|
|
48
|
+
*/
|
|
49
|
+
declare const avatarColorVariants: (props?: {
|
|
50
|
+
variant?: AvatarVariant;
|
|
51
|
+
color?: ResolvedAvatarColor;
|
|
52
|
+
}) => string;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Template context provided to custom avatar templates.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```html
|
|
59
|
+
* <com-avatar name="Acme Corp" size="lg">
|
|
60
|
+
* <ng-template comAvatarCustom let-name let-initials="initials" let-size="size">
|
|
61
|
+
* <img src="/logos/acme.svg" class="size-full object-contain p-1" [alt]="name" />
|
|
62
|
+
* </ng-template>
|
|
63
|
+
* </com-avatar>
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
interface AvatarTemplateContext {
|
|
67
|
+
/** The `name` input value (default for `let-name`). */
|
|
68
|
+
$implicit: string | undefined;
|
|
69
|
+
/** Computed initials from the name. */
|
|
70
|
+
initials: string;
|
|
71
|
+
/** Current size variant, allowing templates to adapt. */
|
|
72
|
+
size: AvatarSize;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Directive to provide a custom template for avatar content.
|
|
76
|
+
*
|
|
77
|
+
* When this directive is used, the avatar ignores the `src`, `name`, and
|
|
78
|
+
* default icon fallback — the template has full control over the content.
|
|
79
|
+
* Use this for company logos, emoji avatars, or custom graphics.
|
|
80
|
+
*
|
|
81
|
+
* @example Company logo
|
|
82
|
+
* ```html
|
|
83
|
+
* <com-avatar name="Acme Corp" size="lg" color="primary">
|
|
84
|
+
* <ng-template comAvatarCustom let-initials="initials">
|
|
85
|
+
* <img src="/logos/acme.svg" class="size-full object-contain p-1" alt="Acme Corp" />
|
|
86
|
+
* </ng-template>
|
|
87
|
+
* </com-avatar>
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @example Emoji avatar
|
|
91
|
+
* ```html
|
|
92
|
+
* <com-avatar name="Bot" color="accent" variant="filled">
|
|
93
|
+
* <ng-template comAvatarCustom>
|
|
94
|
+
* <span class="text-lg">🤖</span>
|
|
95
|
+
* </ng-template>
|
|
96
|
+
* </com-avatar>
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @example Adaptive content using size context
|
|
100
|
+
* ```html
|
|
101
|
+
* <com-avatar name="Jane" [size]="avatarSize">
|
|
102
|
+
* <ng-template comAvatarCustom let-size="size">
|
|
103
|
+
* @if (size === 'xs' || size === 'sm') {
|
|
104
|
+
* <span class="text-xs">👤</span>
|
|
105
|
+
* } @else {
|
|
106
|
+
* <img src="/custom-avatar.png" class="size-full object-cover" />
|
|
107
|
+
* }
|
|
108
|
+
* </ng-template>
|
|
109
|
+
* </com-avatar>
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
declare class ComAvatarCustom {
|
|
113
|
+
readonly templateRef: TemplateRef<AvatarTemplateContext>;
|
|
114
|
+
/**
|
|
115
|
+
* Static type guard for template type checking.
|
|
116
|
+
* Enables type-safe access to context properties in templates.
|
|
117
|
+
*/
|
|
118
|
+
static ngTemplateContextGuard(_dir: ComAvatarCustom, ctx: unknown): ctx is AvatarTemplateContext;
|
|
119
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComAvatarCustom, never>;
|
|
120
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ComAvatarCustom, "ng-template[comAvatarCustom]", never, {}, {}, never, never, true, never>;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Image loading state. */
|
|
124
|
+
type ImageState = 'idle' | 'loading' | 'loaded' | 'error';
|
|
125
|
+
/**
|
|
126
|
+
* Avatar component — displays a user's profile image, initials, or a fallback icon.
|
|
127
|
+
*
|
|
128
|
+
* Handles the full lifecycle of image loading with a graceful fallback chain:
|
|
129
|
+
* 1. Custom template (via `comAvatarCustom` directive) — if provided, always wins
|
|
130
|
+
* 2. Image — if `src` is provided and loads successfully
|
|
131
|
+
* 3. Initials — if `name` is provided, auto-generated from the name
|
|
132
|
+
* 4. Default icon — generic user silhouette via `com-icon`
|
|
133
|
+
*
|
|
134
|
+
* **Note:** The default fallback icon requires the `User` icon from lucide-angular
|
|
135
|
+
* to be registered via `provideComIcons({ User })` in your application config.
|
|
136
|
+
*
|
|
137
|
+
* @tokens `--color-primary`, `--color-primary-foreground`, `--color-primary-subtle`, `--color-primary-subtle-foreground`,
|
|
138
|
+
* `--color-accent`, `--color-accent-foreground`, `--color-accent-subtle`, `--color-accent-subtle-foreground`,
|
|
139
|
+
* `--color-warn`, `--color-warn-foreground`, `--color-warn-subtle`, `--color-warn-subtle-foreground`,
|
|
140
|
+
* `--color-muted`, `--color-muted-foreground`,
|
|
141
|
+
* `--color-border`, `--color-background`, `--color-foreground`, `--color-ring`
|
|
142
|
+
*
|
|
143
|
+
* @example Simple image avatar
|
|
144
|
+
* ```html
|
|
145
|
+
* <com-avatar src="/photos/jane.jpg" name="Jane Doe" />
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @example Initials fallback (no image)
|
|
149
|
+
* ```html
|
|
150
|
+
* <com-avatar name="Jane Doe" />
|
|
151
|
+
* <!-- renders "JD" with auto-computed background color -->
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* @example Explicit color and shape
|
|
155
|
+
* ```html
|
|
156
|
+
* <com-avatar name="John Smith" color="primary" variant="filled" />
|
|
157
|
+
* <com-avatar name="Alice" color="accent" shape="rounded" />
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* @example Sizes — from badge to profile header
|
|
161
|
+
* ```html
|
|
162
|
+
* <!-- Tiny: inside a badge or inline with text -->
|
|
163
|
+
* <com-avatar name="JD" size="xs" />
|
|
164
|
+
*
|
|
165
|
+
* <!-- Small: list items, comments -->
|
|
166
|
+
* <com-avatar src="/photos/jane.jpg" name="Jane" size="sm" />
|
|
167
|
+
*
|
|
168
|
+
* <!-- Medium: default, cards -->
|
|
169
|
+
* <com-avatar src="/photos/jane.jpg" name="Jane" />
|
|
170
|
+
*
|
|
171
|
+
* <!-- Large: profile sidebar -->
|
|
172
|
+
* <com-avatar src="/photos/jane.jpg" name="Jane" size="lg" />
|
|
173
|
+
*
|
|
174
|
+
* <!-- Extra large: profile hero -->
|
|
175
|
+
* <com-avatar src="/photos/jane.jpg" name="Jane" size="xl" />
|
|
176
|
+
*
|
|
177
|
+
* <!-- 2XL: full profile page header -->
|
|
178
|
+
* <com-avatar src="/photos/jane.jpg" name="Jane" size="2xl" />
|
|
179
|
+
* ```
|
|
180
|
+
*
|
|
181
|
+
* @example Default icon fallback (no name, no image)
|
|
182
|
+
* ```html
|
|
183
|
+
* <!-- Shows generic user icon -->
|
|
184
|
+
* <com-avatar />
|
|
185
|
+
* ```
|
|
186
|
+
*
|
|
187
|
+
* @example Interactive (clickable, for menus)
|
|
188
|
+
* ```html
|
|
189
|
+
* <com-avatar
|
|
190
|
+
* src="/photos/me.jpg"
|
|
191
|
+
* name="My Profile"
|
|
192
|
+
* [interactive]="true"
|
|
193
|
+
* (click)="openProfileMenu()"
|
|
194
|
+
* />
|
|
195
|
+
* ```
|
|
196
|
+
*
|
|
197
|
+
* @example With status indicator (composed externally)
|
|
198
|
+
* ```html
|
|
199
|
+
* <!-- The avatar itself doesn't own the status dot — the consumer composes it -->
|
|
200
|
+
* <div class="relative inline-flex">
|
|
201
|
+
* <com-avatar src="/photos/jane.jpg" name="Jane" size="sm" />
|
|
202
|
+
* <span class="absolute bottom-0 right-0 size-2.5 rounded-full bg-success ring-2 ring-background"></span>
|
|
203
|
+
* </div>
|
|
204
|
+
* ```
|
|
205
|
+
*
|
|
206
|
+
* @example Custom template — company logo with fallback
|
|
207
|
+
* ```html
|
|
208
|
+
* <com-avatar name="Acme Corp" size="lg" color="primary">
|
|
209
|
+
* <ng-template comAvatarCustom let-initials="initials">
|
|
210
|
+
* <img src="/logos/acme.svg" class="size-full object-contain p-1" alt="Acme Corp" />
|
|
211
|
+
* </ng-template>
|
|
212
|
+
* </com-avatar>
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* @example Custom template — emoji avatar
|
|
216
|
+
* ```html
|
|
217
|
+
* <com-avatar name="Bot" color="accent" variant="filled">
|
|
218
|
+
* <ng-template comAvatarCustom>
|
|
219
|
+
* <span class="text-lg">🤖</span>
|
|
220
|
+
* </ng-template>
|
|
221
|
+
* </com-avatar>
|
|
222
|
+
* ```
|
|
223
|
+
*
|
|
224
|
+
* @example Inline with text
|
|
225
|
+
* ```html
|
|
226
|
+
* <span class="inline-flex items-center gap-2">
|
|
227
|
+
* <com-avatar name="Jane Doe" size="xs" />
|
|
228
|
+
* <span class="text-sm">Jane Doe</span>
|
|
229
|
+
* </span>
|
|
230
|
+
* ```
|
|
231
|
+
*
|
|
232
|
+
* @example Avatar in a badge context
|
|
233
|
+
* ```html
|
|
234
|
+
* <!-- Works at xs/sm sizes without breaking layout -->
|
|
235
|
+
* <div class="flex items-center gap-1.5 rounded-pill bg-muted px-2 py-0.5">
|
|
236
|
+
* <com-avatar name="Jane" size="xs" />
|
|
237
|
+
* <span class="text-xs">Jane Doe</span>
|
|
238
|
+
* <button class="text-muted-foreground hover:text-foreground">
|
|
239
|
+
* <com-icon name="x" size="xs" />
|
|
240
|
+
* </button>
|
|
241
|
+
* </div>
|
|
242
|
+
* ```
|
|
243
|
+
*
|
|
244
|
+
* @example Outline variant (good for overlapping stacks)
|
|
245
|
+
* ```html
|
|
246
|
+
* <div class="flex -space-x-2">
|
|
247
|
+
* <com-avatar src="/photos/a.jpg" name="Alice" size="sm" variant="outline" />
|
|
248
|
+
* <com-avatar src="/photos/b.jpg" name="Bob" size="sm" variant="outline" />
|
|
249
|
+
* <com-avatar src="/photos/c.jpg" name="Carol" size="sm" variant="outline" />
|
|
250
|
+
* <com-avatar name="+3" size="sm" variant="outline" color="muted" />
|
|
251
|
+
* </div>
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
declare class ComAvatar {
|
|
255
|
+
/** Host element reference (used by ComAvatarGroup). */
|
|
256
|
+
readonly elementRef: ElementRef<HTMLElement>;
|
|
257
|
+
/** Image URL for the avatar. */
|
|
258
|
+
readonly src: InputSignal<string | undefined>;
|
|
259
|
+
/** Alt text for the image. Falls back to `name` if not provided. */
|
|
260
|
+
readonly alt: InputSignal<string | undefined>;
|
|
261
|
+
/** User's display name — used to generate initials and as aria fallback. */
|
|
262
|
+
readonly name: InputSignal<string | undefined>;
|
|
263
|
+
/** Size variant. */
|
|
264
|
+
readonly size: InputSignal<AvatarSize>;
|
|
265
|
+
/** Color variant. 'auto' deterministically picks a color based on the name. */
|
|
266
|
+
readonly color: InputSignal<AvatarColor>;
|
|
267
|
+
/** Shape variant. */
|
|
268
|
+
readonly shape: InputSignal<AvatarShape>;
|
|
269
|
+
/** Visual style variant. */
|
|
270
|
+
readonly variant: InputSignal<AvatarVariant>;
|
|
271
|
+
/** When true, renders as a button with hover/active states. */
|
|
272
|
+
readonly interactive: InputSignal<boolean>;
|
|
273
|
+
/** Emits when the image fails to load (after fallback kicks in). */
|
|
274
|
+
readonly imageError: OutputEmitterRef<void>;
|
|
275
|
+
/** Emits when the image loads successfully. */
|
|
276
|
+
readonly imageLoaded: OutputEmitterRef<void>;
|
|
277
|
+
/** Custom template for full control over avatar content. */
|
|
278
|
+
readonly customTemplate: Signal<ComAvatarCustom | undefined>;
|
|
279
|
+
/**
|
|
280
|
+
* Current image loading state.
|
|
281
|
+
* Resets to 'loading' or 'idle' when `src` changes.
|
|
282
|
+
*/
|
|
283
|
+
protected readonly imageState: WritableSignal<ImageState>;
|
|
284
|
+
/** Resolved color (handles 'auto' based on name). */
|
|
285
|
+
protected readonly resolvedColor: Signal<ResolvedAvatarColor>;
|
|
286
|
+
/** Computed initials from the name. */
|
|
287
|
+
readonly computedInitials: Signal<string>;
|
|
288
|
+
/** Template context for custom templates. */
|
|
289
|
+
protected readonly templateContext: Signal<AvatarTemplateContext>;
|
|
290
|
+
/** CSS classes for the host element. */
|
|
291
|
+
protected readonly hostClasses: Signal<string>;
|
|
292
|
+
/** Font size class for initials. */
|
|
293
|
+
protected readonly initialsSizeClass: Signal<string>;
|
|
294
|
+
/** Icon size for the fallback icon (same as avatar size). */
|
|
295
|
+
protected readonly iconSize: Signal<AvatarSize>;
|
|
296
|
+
/** @internal Handles successful image load. */
|
|
297
|
+
protected onImageLoad(): void;
|
|
298
|
+
/** @internal Handles image load error. */
|
|
299
|
+
protected onImageError(): void;
|
|
300
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComAvatar, never>;
|
|
301
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ComAvatar, "com-avatar", ["comAvatar"], { "src": { "alias": "src"; "required": false; "isSignal": true; }; "alt": { "alias": "alt"; "required": false; "isSignal": true; }; "name": { "alias": "name"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "color": { "alias": "color"; "required": false; "isSignal": true; }; "shape": { "alias": "shape"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "interactive": { "alias": "interactive"; "required": false; "isSignal": true; }; }, { "imageError": "imageError"; "imageLoaded": "imageLoaded"; }, ["customTemplate"], never, true, never>;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Avatar group directive — displays multiple avatars in an overlapping stack.
|
|
306
|
+
*
|
|
307
|
+
* Apply this directive to a container element with `com-avatar` children.
|
|
308
|
+
* The directive handles negative spacing, ring styling for visual separation,
|
|
309
|
+
* and optionally limits the visible avatars with an overflow indicator.
|
|
310
|
+
*
|
|
311
|
+
* **Note:** Child avatars should use `variant="outline"` for best visual results,
|
|
312
|
+
* as this provides the ring that separates overlapping avatars. The directive
|
|
313
|
+
* adds `ring-background` to ensure proper visual separation.
|
|
314
|
+
*
|
|
315
|
+
* @tokens `--color-background`, `--color-muted`, `--color-muted-foreground`
|
|
316
|
+
*
|
|
317
|
+
* @example Basic usage
|
|
318
|
+
* ```html
|
|
319
|
+
* <div comAvatarGroup>
|
|
320
|
+
* <com-avatar src="/photos/a.jpg" name="Alice" variant="outline" />
|
|
321
|
+
* <com-avatar src="/photos/b.jpg" name="Bob" variant="outline" />
|
|
322
|
+
* <com-avatar src="/photos/c.jpg" name="Carol" variant="outline" />
|
|
323
|
+
* </div>
|
|
324
|
+
* ```
|
|
325
|
+
*
|
|
326
|
+
* @example With max limit and overflow indicator
|
|
327
|
+
* ```html
|
|
328
|
+
* <div comAvatarGroup [max]="3">
|
|
329
|
+
* <com-avatar src="/photos/a.jpg" name="Alice" variant="outline" />
|
|
330
|
+
* <com-avatar src="/photos/b.jpg" name="Bob" variant="outline" />
|
|
331
|
+
* <com-avatar src="/photos/c.jpg" name="Carol" variant="outline" />
|
|
332
|
+
* <com-avatar src="/photos/d.jpg" name="Dave" variant="outline" />
|
|
333
|
+
* <com-avatar src="/photos/e.jpg" name="Eve" variant="outline" />
|
|
334
|
+
* </div>
|
|
335
|
+
* <!-- Shows 3 avatars + "+2" indicator -->
|
|
336
|
+
* ```
|
|
337
|
+
*
|
|
338
|
+
* @example Different sizes
|
|
339
|
+
* ```html
|
|
340
|
+
* <div comAvatarGroup size="sm">
|
|
341
|
+
* <com-avatar name="A" size="sm" variant="outline" />
|
|
342
|
+
* <com-avatar name="B" size="sm" variant="outline" />
|
|
343
|
+
* </div>
|
|
344
|
+
*
|
|
345
|
+
* <div comAvatarGroup size="lg">
|
|
346
|
+
* <com-avatar name="A" size="lg" variant="outline" />
|
|
347
|
+
* <com-avatar name="B" size="lg" variant="outline" />
|
|
348
|
+
* </div>
|
|
349
|
+
* ```
|
|
350
|
+
*
|
|
351
|
+
* @example Reversed stacking (last avatar on top)
|
|
352
|
+
* ```html
|
|
353
|
+
* <div comAvatarGroup [reverse]="true">
|
|
354
|
+
* <com-avatar name="First" variant="outline" />
|
|
355
|
+
* <com-avatar name="Second" variant="outline" />
|
|
356
|
+
* <com-avatar name="Third (on top)" variant="outline" />
|
|
357
|
+
* </div>
|
|
358
|
+
* ```
|
|
359
|
+
*/
|
|
360
|
+
declare class ComAvatarGroup {
|
|
361
|
+
private readonly renderer;
|
|
362
|
+
private readonly elementRef;
|
|
363
|
+
/** Query all child ComAvatar components. */
|
|
364
|
+
private readonly avatars;
|
|
365
|
+
/**
|
|
366
|
+
* Size variant — should match child avatar sizes for proper spacing.
|
|
367
|
+
* If not provided, defaults to 'md'.
|
|
368
|
+
*/
|
|
369
|
+
readonly size: InputSignal<AvatarSize>;
|
|
370
|
+
/**
|
|
371
|
+
* Maximum number of avatars to display.
|
|
372
|
+
* When exceeded, remaining avatars are hidden and an overflow indicator shows "+N".
|
|
373
|
+
* Set to 0 or undefined for unlimited.
|
|
374
|
+
*/
|
|
375
|
+
readonly max: InputSignal<number | undefined>;
|
|
376
|
+
/**
|
|
377
|
+
* When true, reverses the stacking order (last avatar on top instead of first).
|
|
378
|
+
* Also reverses the visual order via flex-row-reverse.
|
|
379
|
+
*/
|
|
380
|
+
readonly reverse: InputSignal<boolean>;
|
|
381
|
+
/** Overflow element reference for cleanup. */
|
|
382
|
+
private overflowElement;
|
|
383
|
+
/** Track the number of hidden avatars. */
|
|
384
|
+
protected readonly overflowCount: WritableSignal<number>;
|
|
385
|
+
/** Whether to show the overflow indicator. */
|
|
386
|
+
protected readonly showOverflow: Signal<boolean>;
|
|
387
|
+
constructor();
|
|
388
|
+
/**
|
|
389
|
+
* Applies overlapping styles to child avatars and manages visibility.
|
|
390
|
+
*/
|
|
391
|
+
private applyAvatarStyles;
|
|
392
|
+
/**
|
|
393
|
+
* Gets the native element of an avatar by index.
|
|
394
|
+
*/
|
|
395
|
+
private getAvatarElement;
|
|
396
|
+
/**
|
|
397
|
+
* Creates or updates the overflow indicator element.
|
|
398
|
+
*/
|
|
399
|
+
private updateOverflowIndicator;
|
|
400
|
+
/**
|
|
401
|
+
* Returns size-specific classes for the overflow indicator.
|
|
402
|
+
*/
|
|
403
|
+
private getOverflowSizeClasses;
|
|
404
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComAvatarGroup, never>;
|
|
405
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ComAvatarGroup, "[comAvatarGroup]", ["comAvatarGroup"], { "size": { "alias": "size"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "reverse": { "alias": "reverse"; "required": false; "isSignal": true; }; }, {}, ["avatars"], never, true, never>;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export { ComAvatar, ComAvatarCustom, ComAvatarGroup, avatarColorVariants, avatarVariants, getInitials };
|
|
409
|
+
export type { AvatarColor, AvatarShape, AvatarSize, AvatarTemplateContext, AvatarVariant, ResolvedAvatarColor };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InputSignal, InputSignalWithTransform, Signal } from '@angular/core';
|
|
3
|
+
import { VariantProps } from 'class-variance-authority';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Variant type for badge appearance.
|
|
7
|
+
*/
|
|
8
|
+
type BadgeVariant = 'primary' | 'accent' | 'warn' | 'success' | 'muted' | 'outline';
|
|
9
|
+
/**
|
|
10
|
+
* Size type for badge.
|
|
11
|
+
*/
|
|
12
|
+
type BadgeSize = 'sm' | 'default' | 'lg';
|
|
13
|
+
/**
|
|
14
|
+
* CVA variants for the badge directive.
|
|
15
|
+
*
|
|
16
|
+
* @tokens `--color-primary`, `--color-primary-foreground`, `--color-primary-hover`,
|
|
17
|
+
* `--color-accent`, `--color-accent-foreground`, `--color-accent-hover`,
|
|
18
|
+
* `--color-warn`, `--color-warn-foreground`, `--color-warn-hover`,
|
|
19
|
+
* `--color-success`, `--color-success-foreground`, `--color-success-hover`,
|
|
20
|
+
* `--color-muted`, `--color-muted-foreground`, `--color-muted-hover`,
|
|
21
|
+
* `--color-border`, `--color-foreground`, `--radius-badge`, `--radius-badge-sm`, `--radius-pill`
|
|
22
|
+
*/
|
|
23
|
+
declare const badgeVariants: (props?: {
|
|
24
|
+
variant?: BadgeVariant;
|
|
25
|
+
size?: BadgeSize;
|
|
26
|
+
pill?: boolean;
|
|
27
|
+
}) => string;
|
|
28
|
+
type BadgeVariants = VariantProps<typeof badgeVariants>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Badge directive — applies styled badge classes to any host element.
|
|
32
|
+
*
|
|
33
|
+
* Works on `<span>`, `<a>`, `<button>`, or any other element.
|
|
34
|
+
* Hover styles are automatically applied only on `<a>` elements via `[a&]:hover:`.
|
|
35
|
+
*
|
|
36
|
+
* @tokens `--color-primary`, `--color-primary-foreground`, `--color-primary-hover`,
|
|
37
|
+
* `--color-accent`, `--color-accent-foreground`, `--color-accent-hover`,
|
|
38
|
+
* `--color-warn`, `--color-warn-foreground`, `--color-warn-hover`,
|
|
39
|
+
* `--color-success`, `--color-success-foreground`, `--color-success-hover`,
|
|
40
|
+
* `--color-muted`, `--color-muted-foreground`, `--color-muted-hover`,
|
|
41
|
+
* `--color-border`, `--color-foreground`, `--radius-badge`, `--radius-badge-sm`, `--radius-pill`
|
|
42
|
+
*
|
|
43
|
+
* @example Basic usage
|
|
44
|
+
* ```html
|
|
45
|
+
* <span comBadge>Primary</span>
|
|
46
|
+
* <span comBadge variant="accent">Accent</span>
|
|
47
|
+
* <span comBadge variant="warn">Warning</span>
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @example Pill shape
|
|
51
|
+
* ```html
|
|
52
|
+
* <span comBadge pill>New</span>
|
|
53
|
+
* <span comBadge variant="success" pill>Online</span>
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @example Sizes
|
|
57
|
+
* ```html
|
|
58
|
+
* <span comBadge size="sm">SM</span>
|
|
59
|
+
* <span comBadge>Default</span>
|
|
60
|
+
* <span comBadge size="lg">Large</span>
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @example As a link (hover activates automatically)
|
|
64
|
+
* ```html
|
|
65
|
+
* <a href="/alerts" comBadge variant="warn">3 alerts</a>
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @example With an icon (SVG auto-sized)
|
|
69
|
+
* ```html
|
|
70
|
+
* <span comBadge variant="success">
|
|
71
|
+
* <svg><!-- check icon --></svg>
|
|
72
|
+
* Online
|
|
73
|
+
* </span>
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @example Dynamic variant
|
|
77
|
+
* ```html
|
|
78
|
+
* <span comBadge [variant]="statusVariant()">{{ statusLabel() }}</span>
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
declare class ComBadge {
|
|
82
|
+
/** Visual variant — maps to semantic token pairings */
|
|
83
|
+
readonly variant: InputSignal<BadgeVariant>;
|
|
84
|
+
/** Badge size */
|
|
85
|
+
readonly size: InputSignal<BadgeSize>;
|
|
86
|
+
/** Fully rounded pill shape */
|
|
87
|
+
readonly pill: InputSignalWithTransform<boolean, unknown>;
|
|
88
|
+
/** Consumer CSS classes — merged with variant classes via mergeClasses() */
|
|
89
|
+
readonly userClass: InputSignal<string>;
|
|
90
|
+
/** @internal Computed host class from CVA + consumer overrides */
|
|
91
|
+
protected readonly computedClass: Signal<string>;
|
|
92
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComBadge, never>;
|
|
93
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ComBadge, "[comBadge]", ["comBadge"], { "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "pill": { "alias": "pill"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { ComBadge, badgeVariants };
|
|
97
|
+
export type { BadgeSize, BadgeVariant, BadgeVariants };
|