@cngx/common 0.0.1-rc.0
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 +21 -0
- package/README.md +18 -0
- package/a11y/README.md +77 -0
- package/card/README.md +79 -0
- package/chart/README.md +31 -0
- package/data/README.md +883 -0
- package/dialog/README.md +84 -0
- package/display/README.md +30 -0
- package/fesm2022/cngx-common-a11y.mjs +1260 -0
- package/fesm2022/cngx-common-a11y.mjs.map +1 -0
- package/fesm2022/cngx-common-card.mjs +765 -0
- package/fesm2022/cngx-common-card.mjs.map +1 -0
- package/fesm2022/cngx-common-chart.mjs +2943 -0
- package/fesm2022/cngx-common-chart.mjs.map +1 -0
- package/fesm2022/cngx-common-data.mjs +2886 -0
- package/fesm2022/cngx-common-data.mjs.map +1 -0
- package/fesm2022/cngx-common-dialog.mjs +1366 -0
- package/fesm2022/cngx-common-dialog.mjs.map +1 -0
- package/fesm2022/cngx-common-display.mjs +1603 -0
- package/fesm2022/cngx-common-display.mjs.map +1 -0
- package/fesm2022/cngx-common-interactive.mjs +8185 -0
- package/fesm2022/cngx-common-interactive.mjs.map +1 -0
- package/fesm2022/cngx-common-layout.mjs +1335 -0
- package/fesm2022/cngx-common-layout.mjs.map +1 -0
- package/fesm2022/cngx-common-popover.mjs +1200 -0
- package/fesm2022/cngx-common-popover.mjs.map +1 -0
- package/fesm2022/cngx-common-stepper.mjs +1350 -0
- package/fesm2022/cngx-common-stepper.mjs.map +1 -0
- package/fesm2022/cngx-common-tabs.mjs +1551 -0
- package/fesm2022/cngx-common-tabs.mjs.map +1 -0
- package/fesm2022/cngx-common.mjs +34 -0
- package/fesm2022/cngx-common.mjs.map +1 -0
- package/interactive/README.md +211 -0
- package/layout/README.md +117 -0
- package/package.json +100 -0
- package/popover/README.md +218 -0
- package/stepper/README.md +102 -0
- package/tabs/README.md +32 -0
- package/types/cngx-common-a11y.d.ts +616 -0
- package/types/cngx-common-card.d.ts +413 -0
- package/types/cngx-common-chart.d.ts +1081 -0
- package/types/cngx-common-data.d.ts +1460 -0
- package/types/cngx-common-dialog.d.ts +772 -0
- package/types/cngx-common-display.d.ts +1136 -0
- package/types/cngx-common-interactive.d.ts +5013 -0
- package/types/cngx-common-layout.d.ts +737 -0
- package/types/cngx-common-popover.d.ts +520 -0
- package/types/cngx-common-stepper.d.ts +982 -0
- package/types/cngx-common-tabs.d.ts +1237 -0
- package/types/cngx-common.d.ts +13 -0
|
@@ -0,0 +1,1603 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, ChangeDetectionStrategy, Component, Directive, signal, computed, inject, ElementRef, Renderer2, afterRenderEffect, effect, DestroyRef, output, InjectionToken, TemplateRef, contentChild, ViewEncapsulation, makeEnvironmentProviders, contentChildren, afterNextRender, untracked, isDevMode } from '@angular/core';
|
|
3
|
+
import { nextUid } from '@cngx/core/utils';
|
|
4
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Display atom for icons. Projects its content (font glyph, SVG, image, custom
|
|
8
|
+
* element) and adds size, colour, and ARIA semantics.
|
|
9
|
+
*
|
|
10
|
+
* Decorative by default (`aria-hidden="true"`); set `label` to make it
|
|
11
|
+
* informative (`role="img"`, `aria-label`).
|
|
12
|
+
*/
|
|
13
|
+
class CngxIcon {
|
|
14
|
+
/** Accessible label. When set, the icon is treated as informative content. */
|
|
15
|
+
label = input(undefined, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
16
|
+
/** Size preset. Maps to CSS custom properties on the host. */
|
|
17
|
+
size = input('md', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
18
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxIcon, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
19
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxIcon, isStandalone: true, selector: "cngx-icon, [cngxIcon]", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.role": "label() ? \"img\" : null", "attr.aria-label": "label() ?? null", "attr.aria-hidden": "label() ? null : \"true\"", "class.cngx-icon--xs": "size() === \"xs\"", "class.cngx-icon--sm": "size() === \"sm\"", "class.cngx-icon--md": "size() === \"md\"", "class.cngx-icon--lg": "size() === \"lg\"", "class.cngx-icon--xl": "size() === \"xl\"" }, classAttribute: "cngx-icon" }, exportAs: ["cngxIcon"], ngImport: i0, template: '<ng-content />', isInline: true, styles: [":host{display:inline-flex;align-items:center;justify-content:center;vertical-align:middle;line-height:1;font-size:var(--cngx-icon-size, 1.25em);color:var(--cngx-icon-color, currentColor);flex:0 0 auto}:host(.cngx-icon--xs){--cngx-icon-size: .75em}:host(.cngx-icon--sm){--cngx-icon-size: 1em}:host(.cngx-icon--md){--cngx-icon-size: 1.25em}:host(.cngx-icon--lg){--cngx-icon-size: 1.5em}:host(.cngx-icon--xl){--cngx-icon-size: 2em}:host>::ng-deep svg{width:1em;height:1em;fill:currentColor;display:block}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
20
|
+
}
|
|
21
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxIcon, decorators: [{
|
|
22
|
+
type: Component,
|
|
23
|
+
args: [{ selector: 'cngx-icon, [cngxIcon]', exportAs: 'cngxIcon', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: '<ng-content />', host: {
|
|
24
|
+
class: 'cngx-icon',
|
|
25
|
+
'[attr.role]': 'label() ? "img" : null',
|
|
26
|
+
'[attr.aria-label]': 'label() ?? null',
|
|
27
|
+
'[attr.aria-hidden]': 'label() ? null : "true"',
|
|
28
|
+
'[class.cngx-icon--xs]': 'size() === "xs"',
|
|
29
|
+
'[class.cngx-icon--sm]': 'size() === "sm"',
|
|
30
|
+
'[class.cngx-icon--md]': 'size() === "md"',
|
|
31
|
+
'[class.cngx-icon--lg]': 'size() === "lg"',
|
|
32
|
+
'[class.cngx-icon--xl]': 'size() === "xl"',
|
|
33
|
+
}, styles: [":host{display:inline-flex;align-items:center;justify-content:center;vertical-align:middle;line-height:1;font-size:var(--cngx-icon-size, 1.25em);color:var(--cngx-icon-color, currentColor);flex:0 0 auto}:host(.cngx-icon--xs){--cngx-icon-size: .75em}:host(.cngx-icon--sm){--cngx-icon-size: 1em}:host(.cngx-icon--md){--cngx-icon-size: 1.25em}:host(.cngx-icon--lg){--cngx-icon-size: 1.5em}:host(.cngx-icon--xl){--cngx-icon-size: 2em}:host>::ng-deep svg{width:1em;height:1em;fill:currentColor;display:block}\n"] }]
|
|
34
|
+
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }] } });
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Thin presentational separator with proper ARIA semantics.
|
|
38
|
+
*
|
|
39
|
+
* Renders `role="separator"` + `aria-orientation` — required for assistive
|
|
40
|
+
* technologies to announce the divider correctly. Visual style is driven by
|
|
41
|
+
* CSS custom properties (`--cngx-divider-color`, `--cngx-divider-thickness`,
|
|
42
|
+
* `--cngx-divider-inset`). Consumers apply their own styles through
|
|
43
|
+
* `.cngx-divider` or override the variables.
|
|
44
|
+
*/
|
|
45
|
+
class CngxDivider {
|
|
46
|
+
/** Layout axis. Horizontal dividers sit between rows; vertical between columns. */
|
|
47
|
+
orientation = input('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
48
|
+
/** Whether start/end padding is applied inside the separator. */
|
|
49
|
+
inset = input(false, ...(ngDevMode ? [{ debugName: "inset" }] : /* istanbul ignore next */ []));
|
|
50
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDivider, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
51
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxDivider, isStandalone: true, selector: "cngx-divider, [cngxDivider]", inputs: { orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, inset: { classPropertyName: "inset", publicName: "inset", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "separator" }, properties: { "attr.aria-orientation": "orientation()", "class.cngx-divider--vertical": "orientation() === \"vertical\"", "class.cngx-divider--inset": "inset()" }, classAttribute: "cngx-divider" }, exportAs: ["cngxDivider"], ngImport: i0 });
|
|
52
|
+
}
|
|
53
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDivider, decorators: [{
|
|
54
|
+
type: Directive,
|
|
55
|
+
args: [{
|
|
56
|
+
selector: 'cngx-divider, [cngxDivider]',
|
|
57
|
+
exportAs: 'cngxDivider',
|
|
58
|
+
standalone: true,
|
|
59
|
+
host: {
|
|
60
|
+
role: 'separator',
|
|
61
|
+
class: 'cngx-divider',
|
|
62
|
+
'[attr.aria-orientation]': 'orientation()',
|
|
63
|
+
'[class.cngx-divider--vertical]': 'orientation() === "vertical"',
|
|
64
|
+
'[class.cngx-divider--inset]': 'inset()',
|
|
65
|
+
},
|
|
66
|
+
}]
|
|
67
|
+
}], propDecorators: { orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], inset: [{ type: i0.Input, args: [{ isSignal: true, alias: "inset", required: false }] }] } });
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Display atom for user/person/entity avatars.
|
|
71
|
+
*
|
|
72
|
+
* Rendering cascade:
|
|
73
|
+
* 1. Image (`src` set and not errored).
|
|
74
|
+
* 2. Initials (`initials` set).
|
|
75
|
+
* 3. Projected content (`<ng-content>`) — typically a `<cngx-icon>`.
|
|
76
|
+
*
|
|
77
|
+
* Optional status indicator dot via `status`. Size and shape driven by
|
|
78
|
+
* CSS custom properties.
|
|
79
|
+
*/
|
|
80
|
+
class CngxAvatar {
|
|
81
|
+
/** Image URL. When set and loads successfully, the image is shown. */
|
|
82
|
+
src = input(undefined, ...(ngDevMode ? [{ debugName: "src" }] : /* istanbul ignore next */ []));
|
|
83
|
+
/** Alternate text for the image. Required when `src` is used. */
|
|
84
|
+
alt = input(undefined, ...(ngDevMode ? [{ debugName: "alt" }] : /* istanbul ignore next */ []));
|
|
85
|
+
/** Initials fallback used when no image loads. */
|
|
86
|
+
initials = input(undefined, ...(ngDevMode ? [{ debugName: "initials" }] : /* istanbul ignore next */ []));
|
|
87
|
+
/** Size preset driving CSS custom properties on the host. */
|
|
88
|
+
size = input('md', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
89
|
+
/** Visual shape. */
|
|
90
|
+
shape = input('circle', ...(ngDevMode ? [{ debugName: "shape" }] : /* istanbul ignore next */ []));
|
|
91
|
+
/** Optional user-presence status indicator. */
|
|
92
|
+
status = input(undefined, ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
|
|
93
|
+
imageLoadedState = signal(false, ...(ngDevMode ? [{ debugName: "imageLoadedState" }] : /* istanbul ignore next */ []));
|
|
94
|
+
imageErroredState = signal(false, ...(ngDevMode ? [{ debugName: "imageErroredState" }] : /* istanbul ignore next */ []));
|
|
95
|
+
/** Whether the image loaded successfully. */
|
|
96
|
+
imageLoaded = this.imageLoadedState.asReadonly();
|
|
97
|
+
/** Whether the fallback path (initials or ng-content) is currently rendered. */
|
|
98
|
+
showFallback = computed(() => !this.showImage(), ...(ngDevMode ? [{ debugName: "showFallback" }] : /* istanbul ignore next */ []));
|
|
99
|
+
/** Whether the `<img>` element should be rendered. */
|
|
100
|
+
showImage = computed(() => !!this.src() && !this.imageErroredState(), ...(ngDevMode ? [{ debugName: "showImage" }] : /* istanbul ignore next */ []));
|
|
101
|
+
handleLoad() {
|
|
102
|
+
this.imageLoadedState.set(true);
|
|
103
|
+
this.imageErroredState.set(false);
|
|
104
|
+
}
|
|
105
|
+
handleError() {
|
|
106
|
+
this.imageLoadedState.set(false);
|
|
107
|
+
this.imageErroredState.set(true);
|
|
108
|
+
}
|
|
109
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAvatar, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
110
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxAvatar, isStandalone: true, selector: "cngx-avatar", inputs: { src: { classPropertyName: "src", publicName: "src", isSignal: true, isRequired: false, transformFunction: null }, alt: { classPropertyName: "alt", publicName: "alt", isSignal: true, isRequired: false, transformFunction: null }, initials: { classPropertyName: "initials", publicName: "initials", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, shape: { classPropertyName: "shape", publicName: "shape", isSignal: true, isRequired: false, transformFunction: null }, status: { classPropertyName: "status", publicName: "status", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cngx-avatar--xs": "size() === \"xs\"", "class.cngx-avatar--sm": "size() === \"sm\"", "class.cngx-avatar--md": "size() === \"md\"", "class.cngx-avatar--lg": "size() === \"lg\"", "class.cngx-avatar--xl": "size() === \"xl\"", "class.cngx-avatar--square": "shape() === \"square\"", "class.cngx-avatar--circle": "shape() === \"circle\"" }, classAttribute: "cngx-avatar" }, exportAs: ["cngxAvatar"], ngImport: i0, template: `
|
|
111
|
+
@if (showImage()) {
|
|
112
|
+
<img
|
|
113
|
+
class="cngx-avatar__img"
|
|
114
|
+
[src]="src()!"
|
|
115
|
+
[alt]="alt() ?? ''"
|
|
116
|
+
(load)="handleLoad()"
|
|
117
|
+
(error)="handleError()"
|
|
118
|
+
/>
|
|
119
|
+
} @else if (initials()) {
|
|
120
|
+
<span class="cngx-avatar__initials" aria-hidden="true">{{ initials() }}</span>
|
|
121
|
+
} @else {
|
|
122
|
+
<ng-content />
|
|
123
|
+
}
|
|
124
|
+
@if (status()) {
|
|
125
|
+
<span
|
|
126
|
+
class="cngx-avatar__status"
|
|
127
|
+
[class.cngx-avatar__status--online]="status() === 'online'"
|
|
128
|
+
[class.cngx-avatar__status--offline]="status() === 'offline'"
|
|
129
|
+
[class.cngx-avatar__status--busy]="status() === 'busy'"
|
|
130
|
+
[class.cngx-avatar__status--away]="status() === 'away'"
|
|
131
|
+
[attr.aria-label]="status()"
|
|
132
|
+
></span>
|
|
133
|
+
}
|
|
134
|
+
`, isInline: true, styles: [":host{display:inline-flex;align-items:center;justify-content:center;position:relative;width:var(--cngx-avatar-size, 2.5rem);height:var(--cngx-avatar-size, 2.5rem);background:var(--cngx-avatar-bg, #e0e5ec);color:var(--cngx-avatar-color, #333);font-size:var(--cngx-avatar-font-size, 1rem);font-weight:600;line-height:1;flex:0 0 auto;-webkit-user-select:none;user-select:none;overflow:visible}:host(.cngx-avatar--circle){border-radius:999px}:host(.cngx-avatar--square){border-radius:var(--cngx-avatar-square-radius, 6px)}:host(.cngx-avatar--xs){--cngx-avatar-size: 1.5rem;--cngx-avatar-font-size: .625rem}:host(.cngx-avatar--sm){--cngx-avatar-size: 2rem;--cngx-avatar-font-size: .75rem}:host(.cngx-avatar--md){--cngx-avatar-size: 2.5rem;--cngx-avatar-font-size: 1rem}:host(.cngx-avatar--lg){--cngx-avatar-size: 3rem;--cngx-avatar-font-size: 1.125rem}:host(.cngx-avatar--xl){--cngx-avatar-size: 4rem;--cngx-avatar-font-size: 1.5rem}.cngx-avatar__img{width:100%;height:100%;object-fit:cover;border-radius:inherit}.cngx-avatar__initials{text-transform:uppercase}.cngx-avatar__status{position:absolute;right:-2px;bottom:-2px;width:var(--cngx-avatar-status-size, .65em);height:var(--cngx-avatar-status-size, .65em);border-radius:999px;border:2px solid var(--cngx-avatar-status-border, #fff);background:var(--cngx-avatar-status-bg, #9aa3ac)}.cngx-avatar__status--online{background:var(--cngx-avatar-status-online, #22c55e)}.cngx-avatar__status--offline{background:var(--cngx-avatar-status-offline, #9aa3ac)}.cngx-avatar__status--busy{background:var(--cngx-avatar-status-busy, #ef4444)}.cngx-avatar__status--away{background:var(--cngx-avatar-status-away, #f59e0b)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
135
|
+
}
|
|
136
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAvatar, decorators: [{
|
|
137
|
+
type: Component,
|
|
138
|
+
args: [{ selector: 'cngx-avatar', exportAs: 'cngxAvatar', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
139
|
+
class: 'cngx-avatar',
|
|
140
|
+
'[class.cngx-avatar--xs]': 'size() === "xs"',
|
|
141
|
+
'[class.cngx-avatar--sm]': 'size() === "sm"',
|
|
142
|
+
'[class.cngx-avatar--md]': 'size() === "md"',
|
|
143
|
+
'[class.cngx-avatar--lg]': 'size() === "lg"',
|
|
144
|
+
'[class.cngx-avatar--xl]': 'size() === "xl"',
|
|
145
|
+
'[class.cngx-avatar--square]': 'shape() === "square"',
|
|
146
|
+
'[class.cngx-avatar--circle]': 'shape() === "circle"',
|
|
147
|
+
}, template: `
|
|
148
|
+
@if (showImage()) {
|
|
149
|
+
<img
|
|
150
|
+
class="cngx-avatar__img"
|
|
151
|
+
[src]="src()!"
|
|
152
|
+
[alt]="alt() ?? ''"
|
|
153
|
+
(load)="handleLoad()"
|
|
154
|
+
(error)="handleError()"
|
|
155
|
+
/>
|
|
156
|
+
} @else if (initials()) {
|
|
157
|
+
<span class="cngx-avatar__initials" aria-hidden="true">{{ initials() }}</span>
|
|
158
|
+
} @else {
|
|
159
|
+
<ng-content />
|
|
160
|
+
}
|
|
161
|
+
@if (status()) {
|
|
162
|
+
<span
|
|
163
|
+
class="cngx-avatar__status"
|
|
164
|
+
[class.cngx-avatar__status--online]="status() === 'online'"
|
|
165
|
+
[class.cngx-avatar__status--offline]="status() === 'offline'"
|
|
166
|
+
[class.cngx-avatar__status--busy]="status() === 'busy'"
|
|
167
|
+
[class.cngx-avatar__status--away]="status() === 'away'"
|
|
168
|
+
[attr.aria-label]="status()"
|
|
169
|
+
></span>
|
|
170
|
+
}
|
|
171
|
+
`, styles: [":host{display:inline-flex;align-items:center;justify-content:center;position:relative;width:var(--cngx-avatar-size, 2.5rem);height:var(--cngx-avatar-size, 2.5rem);background:var(--cngx-avatar-bg, #e0e5ec);color:var(--cngx-avatar-color, #333);font-size:var(--cngx-avatar-font-size, 1rem);font-weight:600;line-height:1;flex:0 0 auto;-webkit-user-select:none;user-select:none;overflow:visible}:host(.cngx-avatar--circle){border-radius:999px}:host(.cngx-avatar--square){border-radius:var(--cngx-avatar-square-radius, 6px)}:host(.cngx-avatar--xs){--cngx-avatar-size: 1.5rem;--cngx-avatar-font-size: .625rem}:host(.cngx-avatar--sm){--cngx-avatar-size: 2rem;--cngx-avatar-font-size: .75rem}:host(.cngx-avatar--md){--cngx-avatar-size: 2.5rem;--cngx-avatar-font-size: 1rem}:host(.cngx-avatar--lg){--cngx-avatar-size: 3rem;--cngx-avatar-font-size: 1.125rem}:host(.cngx-avatar--xl){--cngx-avatar-size: 4rem;--cngx-avatar-font-size: 1.5rem}.cngx-avatar__img{width:100%;height:100%;object-fit:cover;border-radius:inherit}.cngx-avatar__initials{text-transform:uppercase}.cngx-avatar__status{position:absolute;right:-2px;bottom:-2px;width:var(--cngx-avatar-status-size, .65em);height:var(--cngx-avatar-status-size, .65em);border-radius:999px;border:2px solid var(--cngx-avatar-status-border, #fff);background:var(--cngx-avatar-status-bg, #9aa3ac)}.cngx-avatar__status--online{background:var(--cngx-avatar-status-online, #22c55e)}.cngx-avatar__status--offline{background:var(--cngx-avatar-status-offline, #9aa3ac)}.cngx-avatar__status--busy{background:var(--cngx-avatar-status-busy, #ef4444)}.cngx-avatar__status--away{background:var(--cngx-avatar-status-away, #f59e0b)}\n"] }]
|
|
172
|
+
}], propDecorators: { src: [{ type: i0.Input, args: [{ isSignal: true, alias: "src", required: false }] }], alt: [{ type: i0.Input, args: [{ isSignal: true, alias: "alt", required: false }] }], initials: [{ type: i0.Input, args: [{ isSignal: true, alias: "initials", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], shape: [{ type: i0.Input, args: [{ isSignal: true, alias: "shape", required: false }] }], status: [{ type: i0.Input, args: [{ isSignal: true, alias: "status", required: false }] }] } });
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Generic counter / dot indicator that attaches a small floating element to
|
|
176
|
+
* any host. Purely presentational (`aria-hidden="true"`) — semantic meaning
|
|
177
|
+
* must live on the host (`aria-label`).
|
|
178
|
+
*
|
|
179
|
+
* Supports:
|
|
180
|
+
* - Numeric values (capped by `max` with "N+" fallback)
|
|
181
|
+
* - String values (rendered verbatim)
|
|
182
|
+
* - Boolean `true` (dot mode, no text)
|
|
183
|
+
*/
|
|
184
|
+
class CngxBadge {
|
|
185
|
+
/** Raw value. Numbers show as text (respecting `max`); booleans flip dot mode; strings render verbatim. */
|
|
186
|
+
cngxBadge = input.required(...(ngDevMode ? [{ debugName: "cngxBadge" }] : /* istanbul ignore next */ []));
|
|
187
|
+
/** Color variant. */
|
|
188
|
+
color = input('primary', ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
|
|
189
|
+
/** Anchor position relative to the host. */
|
|
190
|
+
position = input('above-end', ...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
|
|
191
|
+
/** Whether the indicator is hidden regardless of value. */
|
|
192
|
+
hidden = input(false, ...(ngDevMode ? [{ debugName: "hidden" }] : /* istanbul ignore next */ []));
|
|
193
|
+
/** Cap for numeric values — anything over renders as `"{max}+"`. */
|
|
194
|
+
max = input(99, ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
|
|
195
|
+
hostEl = inject((ElementRef));
|
|
196
|
+
renderer = inject(Renderer2);
|
|
197
|
+
badgeEl = null;
|
|
198
|
+
/** Whether the badge shows as a solid dot (no text). */
|
|
199
|
+
isDotMode = computed(() => this.cngxBadge() === true, ...(ngDevMode ? [{ debugName: "isDotMode" }] : /* istanbul ignore next */ []));
|
|
200
|
+
/** Whether the badge is empty (no value, 0, empty string, or false). */
|
|
201
|
+
isEmpty = computed(() => {
|
|
202
|
+
const v = this.cngxBadge();
|
|
203
|
+
if (typeof v === 'number') {
|
|
204
|
+
return v === 0;
|
|
205
|
+
}
|
|
206
|
+
if (typeof v === 'boolean') {
|
|
207
|
+
return v === false;
|
|
208
|
+
}
|
|
209
|
+
return v === '';
|
|
210
|
+
}, ...(ngDevMode ? [{ debugName: "isEmpty" }] : /* istanbul ignore next */ []));
|
|
211
|
+
/** Displayed text, or `null` when in dot mode or empty. */
|
|
212
|
+
displayValue = computed(() => {
|
|
213
|
+
const v = this.cngxBadge();
|
|
214
|
+
if (typeof v === 'boolean') {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
if (typeof v === 'number') {
|
|
218
|
+
const m = this.max();
|
|
219
|
+
return v > m ? `${m}+` : String(v);
|
|
220
|
+
}
|
|
221
|
+
return v;
|
|
222
|
+
}, ...(ngDevMode ? [{ debugName: "displayValue" }] : /* istanbul ignore next */ []));
|
|
223
|
+
constructor() {
|
|
224
|
+
let hostPositionEnsured = false;
|
|
225
|
+
afterRenderEffect(() => {
|
|
226
|
+
if (hostPositionEnsured || this.position() === 'inline') {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const host = this.hostEl.nativeElement;
|
|
230
|
+
const current = getComputedStyle(host).position;
|
|
231
|
+
if (current === 'static') {
|
|
232
|
+
this.renderer.setStyle(host, 'position', 'relative');
|
|
233
|
+
}
|
|
234
|
+
hostPositionEnsured = true;
|
|
235
|
+
});
|
|
236
|
+
effect(() => {
|
|
237
|
+
const shouldShow = !this.hidden() && (this.isDotMode() || !this.isEmpty());
|
|
238
|
+
if (!shouldShow) {
|
|
239
|
+
this.removeBadge();
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
this.ensureBadge();
|
|
243
|
+
this.applyClasses();
|
|
244
|
+
this.applyContent();
|
|
245
|
+
});
|
|
246
|
+
inject(DestroyRef).onDestroy(() => this.removeBadge());
|
|
247
|
+
}
|
|
248
|
+
ensureBadge() {
|
|
249
|
+
if (this.badgeEl) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
this.badgeEl = this.renderer.createElement('span');
|
|
253
|
+
this.renderer.setAttribute(this.badgeEl, 'aria-hidden', 'true');
|
|
254
|
+
this.renderer.addClass(this.badgeEl, 'cngx-badge-indicator');
|
|
255
|
+
this.renderer.appendChild(this.hostEl.nativeElement, this.badgeEl);
|
|
256
|
+
}
|
|
257
|
+
applyClasses() {
|
|
258
|
+
if (!this.badgeEl) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
const COLORS = ['primary', 'error', 'warning', 'neutral'];
|
|
262
|
+
const POSITIONS = [
|
|
263
|
+
'inline',
|
|
264
|
+
'above-start',
|
|
265
|
+
'above-end',
|
|
266
|
+
'below-start',
|
|
267
|
+
'below-end',
|
|
268
|
+
];
|
|
269
|
+
for (const c of COLORS) {
|
|
270
|
+
this.renderer.removeClass(this.badgeEl, `cngx-badge-indicator--${c}`);
|
|
271
|
+
}
|
|
272
|
+
for (const p of POSITIONS) {
|
|
273
|
+
this.renderer.removeClass(this.badgeEl, `cngx-badge-indicator--${p}`);
|
|
274
|
+
}
|
|
275
|
+
this.renderer.addClass(this.badgeEl, `cngx-badge-indicator--${this.color()}`);
|
|
276
|
+
this.renderer.addClass(this.badgeEl, `cngx-badge-indicator--${this.position()}`);
|
|
277
|
+
if (this.isDotMode()) {
|
|
278
|
+
this.renderer.addClass(this.badgeEl, 'cngx-badge-indicator--dot');
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
this.renderer.removeClass(this.badgeEl, 'cngx-badge-indicator--dot');
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
applyContent() {
|
|
285
|
+
if (!this.badgeEl) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
const value = this.displayValue();
|
|
289
|
+
this.badgeEl.textContent = value ?? '';
|
|
290
|
+
}
|
|
291
|
+
removeBadge() {
|
|
292
|
+
if (this.badgeEl?.parentNode) {
|
|
293
|
+
this.renderer.removeChild(this.badgeEl.parentNode, this.badgeEl);
|
|
294
|
+
}
|
|
295
|
+
this.badgeEl = null;
|
|
296
|
+
}
|
|
297
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBadge, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
298
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxBadge, isStandalone: true, selector: "[cngxBadge]", inputs: { cngxBadge: { classPropertyName: "cngxBadge", publicName: "cngxBadge", isSignal: true, isRequired: true, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, hidden: { classPropertyName: "hidden", publicName: "hidden", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cngx-badge-host": "true" } }, exportAs: ["cngxBadge"], ngImport: i0 });
|
|
299
|
+
}
|
|
300
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBadge, decorators: [{
|
|
301
|
+
type: Directive,
|
|
302
|
+
args: [{
|
|
303
|
+
selector: '[cngxBadge]',
|
|
304
|
+
exportAs: 'cngxBadge',
|
|
305
|
+
standalone: true,
|
|
306
|
+
host: {
|
|
307
|
+
'[class.cngx-badge-host]': 'true',
|
|
308
|
+
},
|
|
309
|
+
}]
|
|
310
|
+
}], ctorParameters: () => [], propDecorators: { cngxBadge: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxBadge", required: true }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], hidden: [{ type: i0.Input, args: [{ isSignal: true, alias: "hidden", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }] } });
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Chip / tag molecule — a small, self-contained pill rendering projected
|
|
314
|
+
* content plus an optional close affordance.
|
|
315
|
+
*
|
|
316
|
+
* **Why this exists.**
|
|
317
|
+
* Multi-value triggers (`CngxMultiSelect` today; `CngxMultiCombobox`,
|
|
318
|
+
* `CngxTagInput`, toolbar filter-chips tomorrow) all want the same pill
|
|
319
|
+
* surface and the same remove interaction. Inlining `<span>`/`<button>`
|
|
320
|
+
* pairs per consumer (a) duplicates ARIA wiring and (b) defeats
|
|
321
|
+
* atomic-decompose: ejecting a parent component drags a block of raw
|
|
322
|
+
* markup into the consumer's source instead of a clean molecule.
|
|
323
|
+
*
|
|
324
|
+
* **Responsibilities (intentionally narrow).**
|
|
325
|
+
* - Render projected `<ng-content>` as the chip label.
|
|
326
|
+
* - Render a close button when `removable()` is true, emit `(remove)`
|
|
327
|
+
* on click.
|
|
328
|
+
* - Provide a stable DOM id for ARIA wiring (auto-generated or
|
|
329
|
+
* consumer-supplied).
|
|
330
|
+
*
|
|
331
|
+
* **Non-responsibilities.**
|
|
332
|
+
* - Selection state — parent tracks which value(s) are picked.
|
|
333
|
+
* - Commit/async behaviour — remove simply fires an event; the parent
|
|
334
|
+
* decides whether to write state directly or route through a commit
|
|
335
|
+
* flow. This keeps the chip usable from any level of the stack.
|
|
336
|
+
*/
|
|
337
|
+
class CngxChip {
|
|
338
|
+
/**
|
|
339
|
+
* Whether the close button is rendered. Typed as `boolean` — bind a
|
|
340
|
+
* signal getter (`[removable]="!select.disabled()"`) if the flag
|
|
341
|
+
* needs to react to upstream state.
|
|
342
|
+
*/
|
|
343
|
+
removable = input(false, ...(ngDevMode ? [{ debugName: "removable" }] : /* istanbul ignore next */ []));
|
|
344
|
+
/**
|
|
345
|
+
* Optional DOM id. When unset, a stable auto-id (`cngx-chip-N`) is
|
|
346
|
+
* applied so `aria-describedby` / `aria-labelledby` hooks from the
|
|
347
|
+
* parent can reference the chip.
|
|
348
|
+
*/
|
|
349
|
+
id = input(null, ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
350
|
+
/**
|
|
351
|
+
* A11y label for the close button. Defaults to a generic "Remove";
|
|
352
|
+
* consumers with option labels on hand should supply something more
|
|
353
|
+
* specific (e.g. `"Remove Red"`) so screen readers know which chip
|
|
354
|
+
* the button removes.
|
|
355
|
+
*/
|
|
356
|
+
removeAriaLabel = input('Remove', ...(ngDevMode ? [{ debugName: "removeAriaLabel" }] : /* istanbul ignore next */ []));
|
|
357
|
+
/** Fires when the user clicks the close button. */
|
|
358
|
+
remove = output();
|
|
359
|
+
autoId = nextUid('cngx-chip');
|
|
360
|
+
/** @internal — resolved DOM id for host binding. */
|
|
361
|
+
resolvedId = computed(() => this.id() ?? this.autoId, ...(ngDevMode ? [{ debugName: "resolvedId" }] : /* istanbul ignore next */ []));
|
|
362
|
+
/** @internal — delegates to the output; kept as a method so the click handler stays in the template. */
|
|
363
|
+
handleRemoveClick(event) {
|
|
364
|
+
this.remove.emit(event);
|
|
365
|
+
}
|
|
366
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChip, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
367
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxChip, isStandalone: true, selector: "cngx-chip", inputs: { removable: { classPropertyName: "removable", publicName: "removable", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, removeAriaLabel: { classPropertyName: "removeAriaLabel", publicName: "removeAriaLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { remove: "remove" }, host: { properties: { "attr.id": "resolvedId()" }, classAttribute: "cngx-chip" }, exportAs: ["cngxChip"], ngImport: i0, template: `
|
|
368
|
+
<span class="cngx-chip__label">
|
|
369
|
+
<ng-content />
|
|
370
|
+
</span>
|
|
371
|
+
@if (removable()) {
|
|
372
|
+
<button
|
|
373
|
+
type="button"
|
|
374
|
+
class="cngx-chip__remove"
|
|
375
|
+
[attr.aria-label]="removeAriaLabel()"
|
|
376
|
+
(click)="handleRemoveClick($event)"
|
|
377
|
+
>
|
|
378
|
+
<!--
|
|
379
|
+
Named content slot for the close glyph. Default renders the
|
|
380
|
+
library's × — consumers project any icon component by tagging
|
|
381
|
+
it with the attribute:
|
|
382
|
+
|
|
383
|
+
<cngx-chip [removable]="true">
|
|
384
|
+
Label
|
|
385
|
+
<my-icon cngxChipClose name="cross" />
|
|
386
|
+
</cngx-chip>
|
|
387
|
+
|
|
388
|
+
Kept as an ng-content slot (not an input TemplateRef) so
|
|
389
|
+
consumers can drop in their own component instances without
|
|
390
|
+
the TemplateRef/outlet dance.
|
|
391
|
+
-->
|
|
392
|
+
<ng-content select="[cngxChipClose]">
|
|
393
|
+
<span aria-hidden="true">✕</span>
|
|
394
|
+
</ng-content>
|
|
395
|
+
</button>
|
|
396
|
+
}
|
|
397
|
+
`, isInline: true, styles: [":host{display:inline-flex;align-items:center;gap:var(--cngx-chip-inner-gap, .25rem);padding:var(--cngx-chip-padding, .125rem .5rem);border-radius:var(--cngx-chip-radius, 999px);background:var(--cngx-chip-bg, rgba(25, 118, 210, .12));color:var(--cngx-chip-color, inherit);font-size:var(--cngx-chip-font-size, .875em);line-height:1.25;max-width:100%}.cngx-chip__label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.cngx-chip__remove{appearance:none;border:0;background:transparent;color:inherit;cursor:pointer;padding:0 .125rem;font:inherit;line-height:1;opacity:var(--cngx-chip-remove-opacity, .7);border-radius:var(--cngx-chip-remove-radius, .125rem);flex:0 0 auto}.cngx-chip__remove:hover{opacity:1}.cngx-chip__remove:focus-visible{outline:var(--cngx-chip-remove-focus-outline, 2px solid var(--cngx-focus-ring, #1976d2));outline-offset:1px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
398
|
+
}
|
|
399
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChip, decorators: [{
|
|
400
|
+
type: Component,
|
|
401
|
+
args: [{ selector: 'cngx-chip', exportAs: 'cngxChip', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
402
|
+
class: 'cngx-chip',
|
|
403
|
+
'[attr.id]': 'resolvedId()',
|
|
404
|
+
}, template: `
|
|
405
|
+
<span class="cngx-chip__label">
|
|
406
|
+
<ng-content />
|
|
407
|
+
</span>
|
|
408
|
+
@if (removable()) {
|
|
409
|
+
<button
|
|
410
|
+
type="button"
|
|
411
|
+
class="cngx-chip__remove"
|
|
412
|
+
[attr.aria-label]="removeAriaLabel()"
|
|
413
|
+
(click)="handleRemoveClick($event)"
|
|
414
|
+
>
|
|
415
|
+
<!--
|
|
416
|
+
Named content slot for the close glyph. Default renders the
|
|
417
|
+
library's × — consumers project any icon component by tagging
|
|
418
|
+
it with the attribute:
|
|
419
|
+
|
|
420
|
+
<cngx-chip [removable]="true">
|
|
421
|
+
Label
|
|
422
|
+
<my-icon cngxChipClose name="cross" />
|
|
423
|
+
</cngx-chip>
|
|
424
|
+
|
|
425
|
+
Kept as an ng-content slot (not an input TemplateRef) so
|
|
426
|
+
consumers can drop in their own component instances without
|
|
427
|
+
the TemplateRef/outlet dance.
|
|
428
|
+
-->
|
|
429
|
+
<ng-content select="[cngxChipClose]">
|
|
430
|
+
<span aria-hidden="true">✕</span>
|
|
431
|
+
</ng-content>
|
|
432
|
+
</button>
|
|
433
|
+
}
|
|
434
|
+
`, styles: [":host{display:inline-flex;align-items:center;gap:var(--cngx-chip-inner-gap, .25rem);padding:var(--cngx-chip-padding, .125rem .5rem);border-radius:var(--cngx-chip-radius, 999px);background:var(--cngx-chip-bg, rgba(25, 118, 210, .12));color:var(--cngx-chip-color, inherit);font-size:var(--cngx-chip-font-size, .875em);line-height:1.25;max-width:100%}.cngx-chip__label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.cngx-chip__remove{appearance:none;border:0;background:transparent;color:inherit;cursor:pointer;padding:0 .125rem;font:inherit;line-height:1;opacity:var(--cngx-chip-remove-opacity, .7);border-radius:var(--cngx-chip-remove-radius, .125rem);flex:0 0 auto}.cngx-chip__remove:hover{opacity:1}.cngx-chip__remove:focus-visible{outline:var(--cngx-chip-remove-focus-outline, 2px solid var(--cngx-focus-ring, #1976d2));outline-offset:1px}\n"] }]
|
|
435
|
+
}], propDecorators: { removable: [{ type: i0.Input, args: [{ isSignal: true, alias: "removable", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], removeAriaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "removeAriaLabel", required: false }] }], remove: [{ type: i0.Output, args: ["remove"] }] } });
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Presentational checkbox / checkmark indicator.
|
|
439
|
+
*
|
|
440
|
+
* **Why this exists.**
|
|
441
|
+
* Across the library, "is this row selected?" shows up as a bare
|
|
442
|
+
* `<span class="cngx-select__check">✓</span>` in the forms/select panel,
|
|
443
|
+
* a future grid/tree cell will want a checkbox with indeterminate state, and
|
|
444
|
+
* `ng decompose cngx-*` schematics should emit a consistent indicator shape
|
|
445
|
+
* regardless of which list-like component they originated from. This atom
|
|
446
|
+
* unifies all three surfaces behind a single presentational molecule —
|
|
447
|
+
* purely decorative (`aria-hidden="true"`), zero outputs, two variants,
|
|
448
|
+
* full `--cngx-checkbox-*` theming.
|
|
449
|
+
*
|
|
450
|
+
* **Responsibilities (intentionally narrow).**
|
|
451
|
+
* - Render a boxed checkbox or a bare checkmark glyph (`variant`).
|
|
452
|
+
* - Express checked / indeterminate / disabled visual state via host classes
|
|
453
|
+
* the consumer (or upstream CSS) can theme.
|
|
454
|
+
* - Apply size presets (`sm` / `md` / `lg`) as CSS-custom-property modifiers.
|
|
455
|
+
*
|
|
456
|
+
* **Non-responsibilities.**
|
|
457
|
+
* - Selection state — controlled entirely by the parent via `checked` /
|
|
458
|
+
* `indeterminate` inputs.
|
|
459
|
+
* - Interaction — no `click` output, no keyboard handling. The parent (option
|
|
460
|
+
* row, tree cell, grid row) owns the hit area and toggle semantics.
|
|
461
|
+
* - Accessibility announcements — `aria-hidden="true"` unconditionally. The
|
|
462
|
+
* truth about "selected" is communicated by the row's own `aria-selected`
|
|
463
|
+
* / `role="option"` ARIA, not by this decoration.
|
|
464
|
+
*/
|
|
465
|
+
class CngxCheckboxIndicator {
|
|
466
|
+
/**
|
|
467
|
+
* Visual form. `'checkbox'` renders a bordered box containing the glyph;
|
|
468
|
+
* `'checkmark'` renders the bare glyph only (no box). Consumers pick the
|
|
469
|
+
* mode-appropriate form themselves — `@cngx/forms/select` resolves it
|
|
470
|
+
* from its `selectionIndicatorVariant` config.
|
|
471
|
+
*/
|
|
472
|
+
variant = input('checkbox', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
473
|
+
/** Whether the current value is selected. */
|
|
474
|
+
checked = input(false, ...(ngDevMode ? [{ debugName: "checked" }] : /* istanbul ignore next */ []));
|
|
475
|
+
/**
|
|
476
|
+
* Partial-selection state. Takes precedence over `checked` — when both
|
|
477
|
+
* are true, the dash glyph is rendered. Intended for tree / group rows
|
|
478
|
+
* where some-but-not-all descendants are selected.
|
|
479
|
+
*/
|
|
480
|
+
indeterminate = input(false, ...(ngDevMode ? [{ debugName: "indeterminate" }] : /* istanbul ignore next */ []));
|
|
481
|
+
/**
|
|
482
|
+
* Disabled visual state. Purely cosmetic (opacity dim) — the indicator
|
|
483
|
+
* never intercepts events, so this is a hint, not a block.
|
|
484
|
+
*/
|
|
485
|
+
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
486
|
+
/** Size preset. Maps to a `--cngx-checkbox-size` custom property. */
|
|
487
|
+
size = input('md', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
488
|
+
/**
|
|
489
|
+
* Consumer-supplied template for the check glyph. When `null` (default),
|
|
490
|
+
* the built-in `<span class="cngx-checkbox-indicator__check">✓</span>`
|
|
491
|
+
* is rendered. When set, the consumer template replaces the glyph span
|
|
492
|
+
* entirely — the `__check` class is NOT applied to the custom content
|
|
493
|
+
* (consumers own the styling of their replacement).
|
|
494
|
+
*
|
|
495
|
+
* Convention-compatible with `*cngxSelectCheck` / `*cngxSelectOptionLabel`:
|
|
496
|
+
* pass a `TemplateRef<void>` obtained via `#myGlyphTpl`. Useful for
|
|
497
|
+
* `CngxTreeCheckboxHeader` or other consumers that need a custom glyph
|
|
498
|
+
* without forking the atom.
|
|
499
|
+
*/
|
|
500
|
+
checkGlyph = input(null, ...(ngDevMode ? [{ debugName: "checkGlyph" }] : /* istanbul ignore next */ []));
|
|
501
|
+
/**
|
|
502
|
+
* Consumer-supplied template for the indeterminate dash glyph. Mirrors
|
|
503
|
+
* {@link checkGlyph} — defaults to the built-in
|
|
504
|
+
* `<span class="cngx-checkbox-indicator__dash">−</span>`.
|
|
505
|
+
*/
|
|
506
|
+
dashGlyph = input(null, ...(ngDevMode ? [{ debugName: "dashGlyph" }] : /* istanbul ignore next */ []));
|
|
507
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCheckboxIndicator, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
508
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxCheckboxIndicator, isStandalone: true, selector: "cngx-checkbox-indicator", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, indeterminate: { classPropertyName: "indeterminate", publicName: "indeterminate", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, checkGlyph: { classPropertyName: "checkGlyph", publicName: "checkGlyph", isSignal: true, isRequired: false, transformFunction: null }, dashGlyph: { classPropertyName: "dashGlyph", publicName: "dashGlyph", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "aria-hidden": "true" }, properties: { "class.cngx-checkbox-indicator--checkbox": "variant() === 'checkbox'", "class.cngx-checkbox-indicator--checkmark": "variant() === 'checkmark'", "class.cngx-checkbox-indicator--checked": "checked()", "class.cngx-checkbox-indicator--indeterminate": "indeterminate()", "class.cngx-checkbox-indicator--disabled": "disabled()", "class.cngx-checkbox-indicator--sm": "size() === 'sm'", "class.cngx-checkbox-indicator--md": "size() === 'md'", "class.cngx-checkbox-indicator--lg": "size() === 'lg'" }, classAttribute: "cngx-checkbox-indicator" }, exportAs: ["cngxCheckboxIndicator"], ngImport: i0, template: `
|
|
509
|
+
<ng-template #defaultDashGlyph>
|
|
510
|
+
<span aria-hidden="true" class="cngx-checkbox-indicator__dash">−</span>
|
|
511
|
+
</ng-template>
|
|
512
|
+
<ng-template #defaultCheckGlyph>
|
|
513
|
+
<span aria-hidden="true" class="cngx-checkbox-indicator__check">✓</span>
|
|
514
|
+
</ng-template>
|
|
515
|
+
|
|
516
|
+
@if (variant() === 'checkbox') {
|
|
517
|
+
<span class="cngx-checkbox-indicator__box">
|
|
518
|
+
@if (indeterminate()) {
|
|
519
|
+
<ng-container *ngTemplateOutlet="dashGlyph() ?? defaultDashGlyph" />
|
|
520
|
+
} @else if (checked()) {
|
|
521
|
+
<ng-container *ngTemplateOutlet="checkGlyph() ?? defaultCheckGlyph" />
|
|
522
|
+
}
|
|
523
|
+
</span>
|
|
524
|
+
} @else {
|
|
525
|
+
@if (indeterminate()) {
|
|
526
|
+
<ng-container *ngTemplateOutlet="dashGlyph() ?? defaultDashGlyph" />
|
|
527
|
+
} @else if (checked()) {
|
|
528
|
+
<ng-container *ngTemplateOutlet="checkGlyph() ?? defaultCheckGlyph" />
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
`, isInline: true, styles: [":host{display:inline-flex;align-items:center;justify-content:center;vertical-align:middle;line-height:1;color:var(--cngx-checkbox-color, currentColor);flex:0 0 auto}:host(.cngx-checkbox-indicator--sm){--cngx-checkbox-size: .875em}:host(.cngx-checkbox-indicator--md){--cngx-checkbox-size: 1em}:host(.cngx-checkbox-indicator--lg){--cngx-checkbox-size: 1.25em}.cngx-checkbox-indicator__box{display:inline-flex;align-items:center;justify-content:center;width:var(--cngx-checkbox-size, 1em);height:var(--cngx-checkbox-size, 1em);border:var(--cngx-checkbox-border, 1.5px solid currentColor);border-radius:var(--cngx-checkbox-radius, .125rem);background:var(--cngx-checkbox-bg, transparent);color:inherit;line-height:1}:host(.cngx-checkbox-indicator--checked) .cngx-checkbox-indicator__box,:host(.cngx-checkbox-indicator--indeterminate) .cngx-checkbox-indicator__box{background:var(--cngx-checkbox-checked-bg, var(--cngx-focus-ring, #1976d2));border-color:var(--cngx-checkbox-checked-bg, var(--cngx-focus-ring, #1976d2));color:var(--cngx-checkbox-checked-color, #fff)}:host(.cngx-checkbox-indicator--disabled){opacity:var(--cngx-checkbox-disabled-opacity, .5)}.cngx-checkbox-indicator__check,.cngx-checkbox-indicator__dash{font-size:calc(var(--cngx-checkbox-size, 1em) * .75);line-height:1;font-weight:700;-webkit-user-select:none;user-select:none}:host(.cngx-checkbox-indicator--checkmark) .cngx-checkbox-indicator__check,:host(.cngx-checkbox-indicator--checkmark) .cngx-checkbox-indicator__dash{color:var(--cngx-checkbox-color, var(--cngx-focus-ring, #1976d2));font-size:var(--cngx-checkbox-size, 1em)}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
532
|
+
}
|
|
533
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCheckboxIndicator, decorators: [{
|
|
534
|
+
type: Component,
|
|
535
|
+
args: [{ selector: 'cngx-checkbox-indicator', exportAs: 'cngxCheckboxIndicator', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgTemplateOutlet], host: {
|
|
536
|
+
class: 'cngx-checkbox-indicator',
|
|
537
|
+
'aria-hidden': 'true',
|
|
538
|
+
'[class.cngx-checkbox-indicator--checkbox]': "variant() === 'checkbox'",
|
|
539
|
+
'[class.cngx-checkbox-indicator--checkmark]': "variant() === 'checkmark'",
|
|
540
|
+
'[class.cngx-checkbox-indicator--checked]': 'checked()',
|
|
541
|
+
'[class.cngx-checkbox-indicator--indeterminate]': 'indeterminate()',
|
|
542
|
+
'[class.cngx-checkbox-indicator--disabled]': 'disabled()',
|
|
543
|
+
'[class.cngx-checkbox-indicator--sm]': "size() === 'sm'",
|
|
544
|
+
'[class.cngx-checkbox-indicator--md]': "size() === 'md'",
|
|
545
|
+
'[class.cngx-checkbox-indicator--lg]': "size() === 'lg'",
|
|
546
|
+
}, template: `
|
|
547
|
+
<ng-template #defaultDashGlyph>
|
|
548
|
+
<span aria-hidden="true" class="cngx-checkbox-indicator__dash">−</span>
|
|
549
|
+
</ng-template>
|
|
550
|
+
<ng-template #defaultCheckGlyph>
|
|
551
|
+
<span aria-hidden="true" class="cngx-checkbox-indicator__check">✓</span>
|
|
552
|
+
</ng-template>
|
|
553
|
+
|
|
554
|
+
@if (variant() === 'checkbox') {
|
|
555
|
+
<span class="cngx-checkbox-indicator__box">
|
|
556
|
+
@if (indeterminate()) {
|
|
557
|
+
<ng-container *ngTemplateOutlet="dashGlyph() ?? defaultDashGlyph" />
|
|
558
|
+
} @else if (checked()) {
|
|
559
|
+
<ng-container *ngTemplateOutlet="checkGlyph() ?? defaultCheckGlyph" />
|
|
560
|
+
}
|
|
561
|
+
</span>
|
|
562
|
+
} @else {
|
|
563
|
+
@if (indeterminate()) {
|
|
564
|
+
<ng-container *ngTemplateOutlet="dashGlyph() ?? defaultDashGlyph" />
|
|
565
|
+
} @else if (checked()) {
|
|
566
|
+
<ng-container *ngTemplateOutlet="checkGlyph() ?? defaultCheckGlyph" />
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
`, styles: [":host{display:inline-flex;align-items:center;justify-content:center;vertical-align:middle;line-height:1;color:var(--cngx-checkbox-color, currentColor);flex:0 0 auto}:host(.cngx-checkbox-indicator--sm){--cngx-checkbox-size: .875em}:host(.cngx-checkbox-indicator--md){--cngx-checkbox-size: 1em}:host(.cngx-checkbox-indicator--lg){--cngx-checkbox-size: 1.25em}.cngx-checkbox-indicator__box{display:inline-flex;align-items:center;justify-content:center;width:var(--cngx-checkbox-size, 1em);height:var(--cngx-checkbox-size, 1em);border:var(--cngx-checkbox-border, 1.5px solid currentColor);border-radius:var(--cngx-checkbox-radius, .125rem);background:var(--cngx-checkbox-bg, transparent);color:inherit;line-height:1}:host(.cngx-checkbox-indicator--checked) .cngx-checkbox-indicator__box,:host(.cngx-checkbox-indicator--indeterminate) .cngx-checkbox-indicator__box{background:var(--cngx-checkbox-checked-bg, var(--cngx-focus-ring, #1976d2));border-color:var(--cngx-checkbox-checked-bg, var(--cngx-focus-ring, #1976d2));color:var(--cngx-checkbox-checked-color, #fff)}:host(.cngx-checkbox-indicator--disabled){opacity:var(--cngx-checkbox-disabled-opacity, .5)}.cngx-checkbox-indicator__check,.cngx-checkbox-indicator__dash{font-size:calc(var(--cngx-checkbox-size, 1em) * .75);line-height:1;font-weight:700;-webkit-user-select:none;user-select:none}:host(.cngx-checkbox-indicator--checkmark) .cngx-checkbox-indicator__check,:host(.cngx-checkbox-indicator--checkmark) .cngx-checkbox-indicator__dash{color:var(--cngx-checkbox-color, var(--cngx-focus-ring, #1976d2));font-size:var(--cngx-checkbox-size, 1em)}\n"] }]
|
|
570
|
+
}], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }], indeterminate: [{ type: i0.Input, args: [{ isSignal: true, alias: "indeterminate", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], checkGlyph: [{ type: i0.Input, args: [{ isSignal: true, alias: "checkGlyph", required: false }] }], dashGlyph: [{ type: i0.Input, args: [{ isSignal: true, alias: "dashGlyph", required: false }] }] } });
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Presentational radio indicator — circle with a centred dot when checked.
|
|
574
|
+
*
|
|
575
|
+
* **Why this exists.**
|
|
576
|
+
* The library's `@cngx/forms/select` panel currently composes
|
|
577
|
+
* {@link import('../checkbox-indicator/checkbox-indicator.component').CngxCheckboxIndicator}
|
|
578
|
+
* for both single-select (`'checkmark'`) and multi-select (`'checkbox'`)
|
|
579
|
+
* indicators. The form-primitives spec (Brain vs. Skin) introduces a
|
|
580
|
+
* radio variant — `selectionIndicatorVariant: 'radio'` for single-select
|
|
581
|
+
* panels — that needs the dot-in-circle visual independently of the
|
|
582
|
+
* box/checkmark shapes. This atom is the radio counterpart: same
|
|
583
|
+
* decorative-only contract, same `--cngx-*` theming surface, same
|
|
584
|
+
* `aria-hidden="true"` discipline. Future single-value form atoms in
|
|
585
|
+
* `@cngx/common/interactive` will compose this same skin once they
|
|
586
|
+
* land in their own phase.
|
|
587
|
+
*
|
|
588
|
+
* **Responsibilities (intentionally narrow).**
|
|
589
|
+
* - Render a circle frame and, when `checked` is true, a centred dot.
|
|
590
|
+
* - Express checked / disabled visual state via host classes the
|
|
591
|
+
* consumer (or upstream CSS) can theme.
|
|
592
|
+
* - Apply size presets (`sm` / `md` / `lg`) as CSS-custom-property
|
|
593
|
+
* modifiers — same scale token as `CngxCheckboxIndicator` so the
|
|
594
|
+
* two atoms render at matching sizes inside a select panel.
|
|
595
|
+
*
|
|
596
|
+
* **Non-responsibilities.**
|
|
597
|
+
* - Selection state — controlled by the parent via `checked`.
|
|
598
|
+
* - No `indeterminate` — radios are exclusive by definition; the
|
|
599
|
+
* group enforces single-selection at the brain layer.
|
|
600
|
+
* - Interaction — no `click` output, no keyboard handling. The radio
|
|
601
|
+
* row (or the consuming select panel) owns the hit area.
|
|
602
|
+
* - Accessibility announcements — `aria-hidden="true"` unconditionally.
|
|
603
|
+
* Selection is announced via the row's `role="radio"` /
|
|
604
|
+
* `aria-checked` ARIA, never by this decoration.
|
|
605
|
+
*/
|
|
606
|
+
class CngxRadioIndicator {
|
|
607
|
+
/** Whether the current value is selected. */
|
|
608
|
+
checked = input(false, ...(ngDevMode ? [{ debugName: "checked" }] : /* istanbul ignore next */ []));
|
|
609
|
+
/**
|
|
610
|
+
* Disabled visual state. Purely cosmetic (opacity dim) — the indicator
|
|
611
|
+
* never intercepts events, so this is a hint, not a block.
|
|
612
|
+
*/
|
|
613
|
+
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
614
|
+
/** Size preset. Maps to a `--cngx-radio-indicator-size` custom property. */
|
|
615
|
+
size = input('md', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
616
|
+
/**
|
|
617
|
+
* Consumer-supplied template for the centred dot. When `null` (default),
|
|
618
|
+
* the built-in `<span class="cngx-radio-indicator__dot"></span>` is
|
|
619
|
+
* rendered. When set, the consumer template replaces the dot span
|
|
620
|
+
* entirely — the `__dot` class is NOT applied to the custom content
|
|
621
|
+
* (consumers own the styling of their replacement).
|
|
622
|
+
*
|
|
623
|
+
* Convention-compatible with `CngxCheckboxIndicator.checkGlyph`: pass a
|
|
624
|
+
* `TemplateRef<void>` obtained via `#myDotTpl`. Useful for
|
|
625
|
+
* design-system overrides that want a brand-glyph dot without
|
|
626
|
+
* forking the atom.
|
|
627
|
+
*/
|
|
628
|
+
dotGlyph = input(null, ...(ngDevMode ? [{ debugName: "dotGlyph" }] : /* istanbul ignore next */ []));
|
|
629
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxRadioIndicator, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
630
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxRadioIndicator, isStandalone: true, selector: "cngx-radio-indicator", inputs: { checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, dotGlyph: { classPropertyName: "dotGlyph", publicName: "dotGlyph", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "aria-hidden": "true" }, properties: { "class.cngx-radio-indicator--checked": "checked()", "class.cngx-radio-indicator--disabled": "disabled()", "class.cngx-radio-indicator--sm": "size() === 'sm'", "class.cngx-radio-indicator--md": "size() === 'md'", "class.cngx-radio-indicator--lg": "size() === 'lg'" }, classAttribute: "cngx-radio-indicator" }, exportAs: ["cngxRadioIndicator"], ngImport: i0, template: `
|
|
631
|
+
<ng-template #defaultDotGlyph>
|
|
632
|
+
<span aria-hidden="true" class="cngx-radio-indicator__dot"></span>
|
|
633
|
+
</ng-template>
|
|
634
|
+
|
|
635
|
+
<span class="cngx-radio-indicator__circle">
|
|
636
|
+
@if (checked()) {
|
|
637
|
+
<ng-container *ngTemplateOutlet="dotGlyph() ?? defaultDotGlyph" />
|
|
638
|
+
}
|
|
639
|
+
</span>
|
|
640
|
+
`, isInline: true, styles: [":host{display:inline-flex;align-items:center;justify-content:center;vertical-align:middle;line-height:1;color:var(--cngx-radio-indicator-color, currentColor);flex:0 0 auto}:host(.cngx-radio-indicator--sm){--cngx-radio-indicator-size: .875em}:host(.cngx-radio-indicator--md){--cngx-radio-indicator-size: 1em}:host(.cngx-radio-indicator--lg){--cngx-radio-indicator-size: 1.25em}.cngx-radio-indicator__circle{display:inline-flex;align-items:center;justify-content:center;width:var(--cngx-radio-indicator-size, 1em);height:var(--cngx-radio-indicator-size, 1em);border:var(--cngx-radio-indicator-border-width, 1.5px) solid currentColor;border-radius:50%;background:var(--cngx-radio-indicator-bg, transparent);color:inherit;line-height:1;transition:var(--cngx-radio-indicator-transition, border-color .12s ease, background-color .12s ease)}:host(.cngx-radio-indicator--checked) .cngx-radio-indicator__circle{border-color:var(--cngx-radio-indicator-checked-color, var(--cngx-focus-ring, #1976d2))}.cngx-radio-indicator__dot{display:inline-block;width:var(--cngx-radio-indicator-dot-size, calc(var(--cngx-radio-indicator-size, 1em) * .5));height:var(--cngx-radio-indicator-dot-size, calc(var(--cngx-radio-indicator-size, 1em) * .5));border-radius:50%;background:var(--cngx-radio-indicator-checked-color, var(--cngx-focus-ring, #1976d2));transition:var(--cngx-radio-indicator-transition, transform .12s ease)}:host(.cngx-radio-indicator--disabled){opacity:var(--cngx-radio-indicator-disabled-opacity, .5)}@media(prefers-reduced-motion:reduce){.cngx-radio-indicator__circle,.cngx-radio-indicator__dot{transition:none}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
641
|
+
}
|
|
642
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxRadioIndicator, decorators: [{
|
|
643
|
+
type: Component,
|
|
644
|
+
args: [{ selector: 'cngx-radio-indicator', exportAs: 'cngxRadioIndicator', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgTemplateOutlet], host: {
|
|
645
|
+
class: 'cngx-radio-indicator',
|
|
646
|
+
'aria-hidden': 'true',
|
|
647
|
+
'[class.cngx-radio-indicator--checked]': 'checked()',
|
|
648
|
+
'[class.cngx-radio-indicator--disabled]': 'disabled()',
|
|
649
|
+
'[class.cngx-radio-indicator--sm]': "size() === 'sm'",
|
|
650
|
+
'[class.cngx-radio-indicator--md]': "size() === 'md'",
|
|
651
|
+
'[class.cngx-radio-indicator--lg]': "size() === 'lg'",
|
|
652
|
+
}, template: `
|
|
653
|
+
<ng-template #defaultDotGlyph>
|
|
654
|
+
<span aria-hidden="true" class="cngx-radio-indicator__dot"></span>
|
|
655
|
+
</ng-template>
|
|
656
|
+
|
|
657
|
+
<span class="cngx-radio-indicator__circle">
|
|
658
|
+
@if (checked()) {
|
|
659
|
+
<ng-container *ngTemplateOutlet="dotGlyph() ?? defaultDotGlyph" />
|
|
660
|
+
}
|
|
661
|
+
</span>
|
|
662
|
+
`, styles: [":host{display:inline-flex;align-items:center;justify-content:center;vertical-align:middle;line-height:1;color:var(--cngx-radio-indicator-color, currentColor);flex:0 0 auto}:host(.cngx-radio-indicator--sm){--cngx-radio-indicator-size: .875em}:host(.cngx-radio-indicator--md){--cngx-radio-indicator-size: 1em}:host(.cngx-radio-indicator--lg){--cngx-radio-indicator-size: 1.25em}.cngx-radio-indicator__circle{display:inline-flex;align-items:center;justify-content:center;width:var(--cngx-radio-indicator-size, 1em);height:var(--cngx-radio-indicator-size, 1em);border:var(--cngx-radio-indicator-border-width, 1.5px) solid currentColor;border-radius:50%;background:var(--cngx-radio-indicator-bg, transparent);color:inherit;line-height:1;transition:var(--cngx-radio-indicator-transition, border-color .12s ease, background-color .12s ease)}:host(.cngx-radio-indicator--checked) .cngx-radio-indicator__circle{border-color:var(--cngx-radio-indicator-checked-color, var(--cngx-focus-ring, #1976d2))}.cngx-radio-indicator__dot{display:inline-block;width:var(--cngx-radio-indicator-dot-size, calc(var(--cngx-radio-indicator-size, 1em) * .5));height:var(--cngx-radio-indicator-dot-size, calc(var(--cngx-radio-indicator-size, 1em) * .5));border-radius:50%;background:var(--cngx-radio-indicator-checked-color, var(--cngx-focus-ring, #1976d2));transition:var(--cngx-radio-indicator-transition, transform .12s ease)}:host(.cngx-radio-indicator--disabled){opacity:var(--cngx-radio-indicator-disabled-opacity, .5)}@media(prefers-reduced-motion:reduce){.cngx-radio-indicator__circle,.cngx-radio-indicator__dot{transition:none}}\n"] }]
|
|
663
|
+
}], propDecorators: { checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], dotGlyph: [{ type: i0.Input, args: [{ isSignal: true, alias: "dotGlyph", required: false }] }] } });
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* DI token for parent `CngxTagGroup` <-> child `CngxTag` ARIA wiring.
|
|
667
|
+
* Atomic-decompose rule 4 — communication via `InjectionToken`,
|
|
668
|
+
* never via concrete parent class injection.
|
|
669
|
+
*
|
|
670
|
+
* `CngxTag` injects the token `{ optional: true }` and, when present,
|
|
671
|
+
* derives its own `role="listitem"` from `host.semanticList()` via a
|
|
672
|
+
* single `computed()`. When absent (Tag rendered outside any group),
|
|
673
|
+
* the role attribute stays unset.
|
|
674
|
+
*
|
|
675
|
+
* Defaults to no provider — the token resolves to `null` for any
|
|
676
|
+
* `CngxTag` that lives outside a `CngxTagGroup`.
|
|
677
|
+
*/
|
|
678
|
+
const CNGX_TAG_GROUP = new InjectionToken('CNGX_TAG_GROUP');
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Library defaults for the tag-family configuration cascade. English
|
|
682
|
+
* by default per `feedback_en_default_locale`; locale overrides ride
|
|
683
|
+
* the future `withAriaLabels` feature once it lands.
|
|
684
|
+
*
|
|
685
|
+
* Exported for intra-lib consumers (`provideTagConfig` deep-merges
|
|
686
|
+
* with this base) but **NOT** re-exported from `public-api.ts` —
|
|
687
|
+
* downstream consumers should reach the defaults via
|
|
688
|
+
* `inject(CNGX_TAG_CONFIG)` so `provideTagConfig` /
|
|
689
|
+
* `provideTagConfigAt` overrides take precedence.
|
|
690
|
+
*
|
|
691
|
+
* @internal
|
|
692
|
+
*/
|
|
693
|
+
const CNGX_TAG_DEFAULTS = {
|
|
694
|
+
defaults: {
|
|
695
|
+
variant: 'filled',
|
|
696
|
+
color: 'neutral',
|
|
697
|
+
size: 'md',
|
|
698
|
+
truncate: false,
|
|
699
|
+
maxWidth: null,
|
|
700
|
+
},
|
|
701
|
+
groupDefaults: {
|
|
702
|
+
gap: 'sm',
|
|
703
|
+
align: 'start',
|
|
704
|
+
semanticList: false,
|
|
705
|
+
},
|
|
706
|
+
colors: {},
|
|
707
|
+
templates: {},
|
|
708
|
+
};
|
|
709
|
+
/**
|
|
710
|
+
* App-wide configuration cascade for the tag family. Resolves in
|
|
711
|
+
* priority order:
|
|
712
|
+
*
|
|
713
|
+
* 1. Per-instance Input binding.
|
|
714
|
+
* 2. `provideTagConfigAt(...)` in a parent component's `viewProviders`.
|
|
715
|
+
* 3. `provideTagConfig(...)` at the application root.
|
|
716
|
+
* 4. Library defaults (this token's `factory`).
|
|
717
|
+
*
|
|
718
|
+
* `providedIn: 'root'` with a default factory means consumers never
|
|
719
|
+
* need to provide the token explicitly — `inject(CNGX_TAG_CONFIG)`
|
|
720
|
+
* always resolves. Consumers who want overrides call
|
|
721
|
+
* `provideTagConfig(...features)` in `bootstrapApplication` providers
|
|
722
|
+
* (root cascade) or `provideTagConfigAt(...features)` in a component's
|
|
723
|
+
* `viewProviders` (sub-tree cascade).
|
|
724
|
+
*/
|
|
725
|
+
const CNGX_TAG_CONFIG = new InjectionToken('CNGX_TAG_CONFIG', {
|
|
726
|
+
providedIn: 'root',
|
|
727
|
+
factory: () => CNGX_TAG_DEFAULTS,
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* Convenience accessor for the tag-family configuration cascade.
|
|
732
|
+
* Runs in injection context; resolves through the priority chain
|
|
733
|
+
* (per-instance Input → `provideTagConfigAt` → `provideTagConfig`
|
|
734
|
+
* → library defaults).
|
|
735
|
+
*
|
|
736
|
+
* Equivalent to `inject(CNGX_TAG_CONFIG)` — the helper exists so
|
|
737
|
+
* consumers don't need to import the token directly. Mirrors
|
|
738
|
+
* `injectSelectConfig` in `@cngx/forms/select`.
|
|
739
|
+
*
|
|
740
|
+
* ```ts
|
|
741
|
+
* export class MyDirective {
|
|
742
|
+
* private readonly cfg = injectTagConfig();
|
|
743
|
+
* readonly variant = input<CngxTagVariant>(
|
|
744
|
+
* this.cfg.defaults?.variant ?? 'filled',
|
|
745
|
+
* );
|
|
746
|
+
* }
|
|
747
|
+
* ```
|
|
748
|
+
*/
|
|
749
|
+
function injectTagConfig() {
|
|
750
|
+
return inject(CNGX_TAG_CONFIG);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* Wraps a `contentChild` directive query in a 3-stage slot-resolution
|
|
755
|
+
* cascade:
|
|
756
|
+
*
|
|
757
|
+
* 1. Instance directive (highest) — consumer-projected
|
|
758
|
+
* `<ng-template cngxTag*>` template.
|
|
759
|
+
* 2. `CNGX_TAG_CONFIG.templates[<key>]` (app-wide cascade via
|
|
760
|
+
* `provideTagConfig` / `provideTagConfigAt`).
|
|
761
|
+
* 3. `null` (the host's default `<ng-template>` body wins, e.g.
|
|
762
|
+
* `CngxTag`'s `<span class="cngx-tag__label"><ng-content /></span>`
|
|
763
|
+
* label fallback).
|
|
764
|
+
*
|
|
765
|
+
* `inject(CNGX_TAG_CONFIG, { optional: true })` mirrors the select-
|
|
766
|
+
* shared helper exactly — `providedIn: 'root'` always resolves so
|
|
767
|
+
* the optional flag is defensive, not load-bearing.
|
|
768
|
+
*
|
|
769
|
+
* **Why a copy and not an import from `@cngx/forms/select/shared`.**
|
|
770
|
+
* Sheriff blocks `lib:common-display` from importing
|
|
771
|
+
* `lib:forms-select`. Hoisting the helper to `@cngx/core/utils`
|
|
772
|
+
* would let both libs share it, but that refactor touches every
|
|
773
|
+
* select call site and belongs in a separate utils-consolidation
|
|
774
|
+
* plan (see
|
|
775
|
+
* `.internal/architektur/plans/tag-family-architectural-a-plus-pass-plan.md`,
|
|
776
|
+
* "Architectural decisions (locked)" — `injectResolvedTemplate
|
|
777
|
+
* location` row).
|
|
778
|
+
*
|
|
779
|
+
* @internal
|
|
780
|
+
*/
|
|
781
|
+
function injectResolvedTagTemplate(directive, configKey) {
|
|
782
|
+
const config = inject(CNGX_TAG_CONFIG, { optional: true });
|
|
783
|
+
return computed(() => {
|
|
784
|
+
const instance = directive()?.templateRef;
|
|
785
|
+
if (instance) {
|
|
786
|
+
return instance;
|
|
787
|
+
}
|
|
788
|
+
const global = config?.templates?.[configKey];
|
|
789
|
+
return global ?? null;
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* Override template for the label region of `<span cngxTag>`.
|
|
795
|
+
*
|
|
796
|
+
* The default label slot wraps projected content in
|
|
797
|
+
* `<span class="cngx-tag__label">` so `text-overflow: ellipsis`
|
|
798
|
+
* has a shrinkable inner with `min-width: 0`. Replace this slot
|
|
799
|
+
* when you need a different inner element (e.g. `<bdi>` for
|
|
800
|
+
* bidi-safe rendering, an inline link, or a richer label
|
|
801
|
+
* composition with icons + counts).
|
|
802
|
+
*
|
|
803
|
+
* Replacing the label drops the default ellipsis hook — the
|
|
804
|
+
* consumer template owns the overflow strategy.
|
|
805
|
+
*
|
|
806
|
+
* ```html
|
|
807
|
+
* <span cngxTag [color]="'success'">
|
|
808
|
+
* <ng-template cngxTagLabel>
|
|
809
|
+
* <bdi>{{ user.name }}</bdi>
|
|
810
|
+
* </ng-template>
|
|
811
|
+
* </span>
|
|
812
|
+
* ```
|
|
813
|
+
*/
|
|
814
|
+
class CngxTagLabel {
|
|
815
|
+
templateRef = inject(TemplateRef);
|
|
816
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTagLabel, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
817
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxTagLabel, isStandalone: true, selector: "ng-template[cngxTagLabel]", exportAs: ["cngxTagLabel"], ngImport: i0 });
|
|
818
|
+
}
|
|
819
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTagLabel, decorators: [{
|
|
820
|
+
type: Directive,
|
|
821
|
+
args: [{
|
|
822
|
+
selector: 'ng-template[cngxTagLabel]',
|
|
823
|
+
standalone: true,
|
|
824
|
+
exportAs: 'cngxTagLabel',
|
|
825
|
+
}]
|
|
826
|
+
}] });
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* Override template for content rendered BEFORE the label region of
|
|
830
|
+
* `<span cngxTag>`. Use for icon glyphs, status dots, count badges,
|
|
831
|
+
* or any per-tag prefix decoration.
|
|
832
|
+
*
|
|
833
|
+
* The slot has no default body — when not projected, no DOM is
|
|
834
|
+
* rendered in the prefix position.
|
|
835
|
+
*
|
|
836
|
+
* ```html
|
|
837
|
+
* <span cngxTag [color]="'warning'">
|
|
838
|
+
* <ng-template cngxTagPrefix>
|
|
839
|
+
* <cngx-icon name="alert-triangle" />
|
|
840
|
+
* </ng-template>
|
|
841
|
+
* Action required
|
|
842
|
+
* </span>
|
|
843
|
+
* ```
|
|
844
|
+
*/
|
|
845
|
+
class CngxTagPrefix {
|
|
846
|
+
templateRef = inject(TemplateRef);
|
|
847
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTagPrefix, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
848
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxTagPrefix, isStandalone: true, selector: "ng-template[cngxTagPrefix]", exportAs: ["cngxTagPrefix"], ngImport: i0 });
|
|
849
|
+
}
|
|
850
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTagPrefix, decorators: [{
|
|
851
|
+
type: Directive,
|
|
852
|
+
args: [{
|
|
853
|
+
selector: 'ng-template[cngxTagPrefix]',
|
|
854
|
+
standalone: true,
|
|
855
|
+
exportAs: 'cngxTagPrefix',
|
|
856
|
+
}]
|
|
857
|
+
}] });
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* Override template for content rendered AFTER the label region of
|
|
861
|
+
* `<span cngxTag>`. Use for trailing chevrons, sort indicators, or
|
|
862
|
+
* any per-tag suffix decoration.
|
|
863
|
+
*
|
|
864
|
+
* The slot has no default body — when not projected, no DOM is
|
|
865
|
+
* rendered in the suffix position. Removable affordances belong on
|
|
866
|
+
* `CngxChip` (which ships its own remove button + announcer
|
|
867
|
+
* wiring), not as a Tag suffix slot.
|
|
868
|
+
*
|
|
869
|
+
* ```html
|
|
870
|
+
* <span cngxTag [color]="'info'">
|
|
871
|
+
* Filter
|
|
872
|
+
* <ng-template cngxTagSuffix>
|
|
873
|
+
* <cngx-icon name="chevron-down" />
|
|
874
|
+
* </ng-template>
|
|
875
|
+
* </span>
|
|
876
|
+
* ```
|
|
877
|
+
*/
|
|
878
|
+
class CngxTagSuffix {
|
|
879
|
+
templateRef = inject(TemplateRef);
|
|
880
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTagSuffix, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
881
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxTagSuffix, isStandalone: true, selector: "ng-template[cngxTagSuffix]", exportAs: ["cngxTagSuffix"], ngImport: i0 });
|
|
882
|
+
}
|
|
883
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTagSuffix, decorators: [{
|
|
884
|
+
type: Directive,
|
|
885
|
+
args: [{
|
|
886
|
+
selector: 'ng-template[cngxTagSuffix]',
|
|
887
|
+
standalone: true,
|
|
888
|
+
exportAs: 'cngxTagSuffix',
|
|
889
|
+
}]
|
|
890
|
+
}] });
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* Decorative tag / label / badge atom.
|
|
894
|
+
*
|
|
895
|
+
* **Why this exists.**
|
|
896
|
+
* `CngxChip` (`@cngx/common/display`) covers the *removable pill*
|
|
897
|
+
* surface inside chip strips. `CngxTag` covers the long tail of
|
|
898
|
+
* static labels: status indicators on a list row, taxonomy badges
|
|
899
|
+
* on a card, role markers in an admin table, pre-filter chips in a
|
|
900
|
+
* dashboard sidebar. Two narrow atoms with non-overlapping
|
|
901
|
+
* concerns beat one chip-tag hybrid with mode flags
|
|
902
|
+
* (Pillar 3 — Komposition statt Konfiguration).
|
|
903
|
+
*
|
|
904
|
+
* **Responsibilities (intentionally narrow).**
|
|
905
|
+
* - Apply variant / color / size / truncate / maxWidth host
|
|
906
|
+
* classes + style bindings to any host element (`<span>`,
|
|
907
|
+
* `<a>`, `<button>`, `<div>`).
|
|
908
|
+
* - When projected inside a `<cngx-tag-group [semanticList]="true">`,
|
|
909
|
+
* reactively expose `role="listitem"` so the parent's
|
|
910
|
+
* `role="list"` semantics propagate without consumer wiring.
|
|
911
|
+
* The cascade reads `CNGX_TAG_GROUP.semanticList()` through a
|
|
912
|
+
* single `computed<'listitem' | null>()` (Pillar 1 —
|
|
913
|
+
* derivation; Pillar 2 — ARIA in the reactive graph).
|
|
914
|
+
*
|
|
915
|
+
* **Non-responsibilities.**
|
|
916
|
+
* - Removable affordance — use `CngxChip` instead.
|
|
917
|
+
* - Clickable / interactive semantics — wrap with native
|
|
918
|
+
* `<button cngxTag>` or `<a cngxTag>` for keyboard +
|
|
919
|
+
* focus + Enter/Space.
|
|
920
|
+
* - Configuration cascade — deferred (see
|
|
921
|
+
* `display-accepted-debt.md §1`).
|
|
922
|
+
*/
|
|
923
|
+
class CngxTag {
|
|
924
|
+
/**
|
|
925
|
+
* Snapshot of the resolved tag-family config at construction
|
|
926
|
+
* time. Drives the per-input fallback defaults below — Angular's
|
|
927
|
+
* input-default rule means per-instance `[variant]="..."`
|
|
928
|
+
* bindings still win.
|
|
929
|
+
*
|
|
930
|
+
* **Field-init ordering is load-bearing.** TypeScript class-field
|
|
931
|
+
* initialisers run in source order; `cfg` MUST be declared before
|
|
932
|
+
* any input field that reads `this.cfg`. A reorder pass that
|
|
933
|
+
* moved this declaration below the inputs would silently produce
|
|
934
|
+
* `undefined` at the input's init call site (runtime crash on
|
|
935
|
+
* first construction). Per the
|
|
936
|
+
* `tag-family-architectural-a-plus-pass` plan Architectural-
|
|
937
|
+
* Decisions table — flagged in cngx-plan-review 2026-04-29.
|
|
938
|
+
*/
|
|
939
|
+
cfg = injectTagConfig();
|
|
940
|
+
/** Visual variant. `filled` (default) | `outline` | `subtle`. */
|
|
941
|
+
variant = input(this.cfg.defaults?.variant ?? 'filled', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
942
|
+
/**
|
|
943
|
+
* Semantic colour. Predefined keys (`neutral` default, `success`,
|
|
944
|
+
* `warning`, `error`, `info`) plus any consumer-defined string
|
|
945
|
+
* which is emitted verbatim as a `data-color` attribute.
|
|
946
|
+
*/
|
|
947
|
+
color = input(this.cfg.defaults?.color ?? 'neutral', ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
|
|
948
|
+
/** Density. `md` (default) | `sm` | `lg` | `xl`. */
|
|
949
|
+
size = input(this.cfg.defaults?.size ?? 'md', ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
950
|
+
/**
|
|
951
|
+
* When `true`, applies `text-overflow: ellipsis` + `white-space: nowrap`
|
|
952
|
+
* to the inner `.cngx-tag__label` span. Pair with `[maxWidth]` for a
|
|
953
|
+
* hard upper bound. Visual-only — the full text remains in the DOM
|
|
954
|
+
* for AT.
|
|
955
|
+
*
|
|
956
|
+
* Deliberately CSS-only — `CngxTruncate` (`@cngx/common/layout`) is the
|
|
957
|
+
* right tool for multi-line clamp + expand/collapse state on long-form
|
|
958
|
+
* text, but its reactive machinery (effect + ResizeObserver + isClamped
|
|
959
|
+
* signal) is overkill for a chip-style single-line overflow.
|
|
960
|
+
*/
|
|
961
|
+
truncate = input(this.cfg.defaults?.truncate ?? false, ...(ngDevMode ? [{ debugName: "truncate" }] : /* istanbul ignore next */ []));
|
|
962
|
+
/**
|
|
963
|
+
* Optional CSS `max-width` (e.g. `'12rem'`, `'200px'`). Bound
|
|
964
|
+
* inline so consumers don't need a CSS authoring step for ad-hoc
|
|
965
|
+
* width caps. `null` clears the binding.
|
|
966
|
+
*/
|
|
967
|
+
maxWidth = input(this.cfg.defaults?.maxWidth ?? null, ...(ngDevMode ? [{ debugName: "maxWidth" }] : /* istanbul ignore next */ []));
|
|
968
|
+
/**
|
|
969
|
+
* Optional parent group (Phase 3 ships `CngxTagGroup` as the
|
|
970
|
+
* default implementer). When present and `semanticList()` is
|
|
971
|
+
* `true`, the host carries `role="listitem"` so the parent's
|
|
972
|
+
* `role="list"` propagates. When absent, no synthetic role is
|
|
973
|
+
* set — `<a cngxTag>` keeps its native `role="link"`,
|
|
974
|
+
* `<button cngxTag>` keeps its `role="button"`, etc.
|
|
975
|
+
*/
|
|
976
|
+
group = inject(CNGX_TAG_GROUP, { optional: true });
|
|
977
|
+
/**
|
|
978
|
+
* Per-instance label-slot directive — projected as
|
|
979
|
+
* `<ng-template cngxTagLabel>...</ng-template>`. Resolved through
|
|
980
|
+
* {@link injectResolvedTagTemplate} so consumers can override the
|
|
981
|
+
* default `<span class="cngx-tag__label">` wrapper without forking
|
|
982
|
+
* the directive.
|
|
983
|
+
*/
|
|
984
|
+
labelSlot = contentChild(CngxTagLabel, ...(ngDevMode ? [{ debugName: "labelSlot" }] : /* istanbul ignore next */ []));
|
|
985
|
+
/** Per-instance prefix-slot directive — projected before the label. */
|
|
986
|
+
prefixSlot = contentChild(CngxTagPrefix, ...(ngDevMode ? [{ debugName: "prefixSlot" }] : /* istanbul ignore next */ []));
|
|
987
|
+
/** Per-instance suffix-slot directive — projected after the label. */
|
|
988
|
+
suffixSlot = contentChild(CngxTagSuffix, ...(ngDevMode ? [{ debugName: "suffixSlot" }] : /* istanbul ignore next */ []));
|
|
989
|
+
/**
|
|
990
|
+
* Resolved label template. Phase 1 cascade: instance slot → host
|
|
991
|
+
* `@else` default (`<span class="cngx-tag__label"><ng-content /></span>`).
|
|
992
|
+
* Phase 4 commit 5 inserts `CNGX_TAG_CONFIG.templates.label` as a
|
|
993
|
+
* middle tier without touching this call site.
|
|
994
|
+
*/
|
|
995
|
+
labelTpl = injectResolvedTagTemplate(this.labelSlot, 'label');
|
|
996
|
+
/** Resolved prefix template. Same 2-stage cascade as {@link labelTpl}. */
|
|
997
|
+
prefixTpl = injectResolvedTagTemplate(this.prefixSlot, 'prefix');
|
|
998
|
+
/** Resolved suffix template. Same 2-stage cascade as {@link labelTpl}. */
|
|
999
|
+
suffixTpl = injectResolvedTagTemplate(this.suffixSlot, 'suffix');
|
|
1000
|
+
/**
|
|
1001
|
+
* Reactive bundle exposed to every slot's `*ngTemplateOutletContext`.
|
|
1002
|
+
* The three slot context interfaces are structurally identical in
|
|
1003
|
+
* Phase 1; the same computed source serves all three. Consumer
|
|
1004
|
+
* templates `let-variant="variant"` etc. read the live state without
|
|
1005
|
+
* injecting the directive.
|
|
1006
|
+
*
|
|
1007
|
+
* Explicit structural `equal` fn — without it, a fresh literal each
|
|
1008
|
+
* CD cycle would force `ngTemplateOutlet` to rebind embedded views
|
|
1009
|
+
* even when no input changed. Per `reference_signal_architecture` §1
|
|
1010
|
+
* Equality Rule: every `computed` returning an object MUST pass an
|
|
1011
|
+
* `equal` fn.
|
|
1012
|
+
*/
|
|
1013
|
+
slotContext = computed(() => ({
|
|
1014
|
+
$implicit: undefined,
|
|
1015
|
+
variant: this.variant(),
|
|
1016
|
+
color: this.color(),
|
|
1017
|
+
size: this.size(),
|
|
1018
|
+
truncate: this.truncate(),
|
|
1019
|
+
}), { ...(ngDevMode ? { debugName: "slotContext" } : /* istanbul ignore next */ {}), equal: (a, b) => a.variant === b.variant &&
|
|
1020
|
+
a.color === b.color &&
|
|
1021
|
+
a.size === b.size &&
|
|
1022
|
+
a.truncate === b.truncate });
|
|
1023
|
+
/**
|
|
1024
|
+
* Reactive `role` attribute. Returns `'listitem'` when projected
|
|
1025
|
+
* inside a `<cngx-tag-group [semanticList]="true">`; `null`
|
|
1026
|
+
* otherwise. No explicit `equal` fn passed — primitive string
|
|
1027
|
+
* output, default `Object.is` is correct (per
|
|
1028
|
+
* `reference_signal_architecture` §1: equality discipline applies
|
|
1029
|
+
* to object/array results, not primitives).
|
|
1030
|
+
*
|
|
1031
|
+
* @internal
|
|
1032
|
+
*/
|
|
1033
|
+
roleAttr = computed(() => this.group?.semanticList() ? 'listitem' : null, ...(ngDevMode ? [{ debugName: "roleAttr" }] : /* istanbul ignore next */ []));
|
|
1034
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTag, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1035
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxTag, isStandalone: true, selector: "[cngxTag], cngx-tag", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, truncate: { classPropertyName: "truncate", publicName: "truncate", isSignal: true, isRequired: false, transformFunction: null }, maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cngx-tag--filled": "variant() === 'filled'", "class.cngx-tag--outline": "variant() === 'outline'", "class.cngx-tag--subtle": "variant() === 'subtle'", "class.cngx-tag--sm": "size() === 'sm'", "class.cngx-tag--md": "size() === 'md'", "class.cngx-tag--lg": "size() === 'lg'", "class.cngx-tag--xl": "size() === 'xl'", "class.cngx-tag--truncate": "truncate()", "attr.data-color": "color()", "style.max-width": "maxWidth()", "attr.role": "roleAttr()" }, classAttribute: "cngx-tag" }, queries: [{ propertyName: "labelSlot", first: true, predicate: CngxTagLabel, descendants: true, isSignal: true }, { propertyName: "prefixSlot", first: true, predicate: CngxTagPrefix, descendants: true, isSignal: true }, { propertyName: "suffixSlot", first: true, predicate: CngxTagSuffix, descendants: true, isSignal: true }], exportAs: ["cngxTag"], ngImport: i0, template: `
|
|
1036
|
+
@if (prefixTpl(); as t) {
|
|
1037
|
+
<ng-container *ngTemplateOutlet="t; context: slotContext()" />
|
|
1038
|
+
}
|
|
1039
|
+
@if (labelTpl(); as t) {
|
|
1040
|
+
<ng-container *ngTemplateOutlet="t; context: slotContext()" />
|
|
1041
|
+
} @else {
|
|
1042
|
+
<span class="cngx-tag__label"><ng-content /></span>
|
|
1043
|
+
}
|
|
1044
|
+
@if (suffixTpl(); as t) {
|
|
1045
|
+
<ng-container *ngTemplateOutlet="t; context: slotContext()" />
|
|
1046
|
+
}
|
|
1047
|
+
`, isInline: true, styles: [".cngx-tag{display:inline-flex;align-items:center;gap:var(--cngx-tag-gap, .25rem);padding:var(--cngx-tag-padding, .125rem .5rem);font-size:var(--cngx-tag-font-size, .75rem);line-height:1.25;max-width:100%}.cngx-tag--sm{padding:var(--cngx-tag-sm-padding, 0 .375rem);font-size:var(--cngx-tag-sm-font-size, .6875rem)}.cngx-tag--lg{padding:var(--cngx-tag-lg-padding, .25rem .625rem);font-size:var(--cngx-tag-lg-font-size, .875rem)}.cngx-tag--xl{padding:var(--cngx-tag-xl-padding, .375rem .75rem);font-size:var(--cngx-tag-xl-font-size, 1rem)}.cngx-tag__label{min-width:0;overflow:hidden}.cngx-tag--truncate .cngx-tag__label{text-overflow:ellipsis;white-space:nowrap}.cngx-tag-group{display:flex;flex-direction:column;gap:var(--cngx-tag-group-stack-gap, .5rem)}.cngx-tag-group__row{display:flex;flex-wrap:wrap;align-items:center;gap:var(--cngx-tag-group-gap, .5rem);justify-content:flex-start}.cngx-tag-group--gap-xs>.cngx-tag-group__row{gap:var(--cngx-tag-group-gap-xs, .25rem)}.cngx-tag-group--gap-md>.cngx-tag-group__row{gap:var(--cngx-tag-group-gap-md, .75rem)}.cngx-tag-group--align-start>.cngx-tag-group__row{justify-content:flex-start}.cngx-tag-group--align-center>.cngx-tag-group__row{justify-content:center}.cngx-tag-group--align-end>.cngx-tag-group__row{justify-content:flex-end}.cngx-tag-group--align-between>.cngx-tag-group__row{justify-content:space-between}\n", ".cngx-tag{border-radius:var(--cngx-tag-radius, 4px);font-weight:var(--cngx-tag-font-weight, 500);background:var(--cngx-tag-bg, transparent);color:var(--cngx-tag-color, inherit);border:var(--cngx-tag-border, 1px solid transparent)}.cngx-tag--filled[data-color=neutral]{--cngx-tag-bg: var(--cngx-tag-neutral-bg, #e5e7eb);--cngx-tag-color: var(--cngx-tag-neutral-color, #374151);--cngx-tag-border: 1px solid var(--cngx-tag-neutral-border, transparent)}.cngx-tag--filled[data-color=success]{--cngx-tag-bg: var(--cngx-tag-success-bg, #d1fae5);--cngx-tag-color: var(--cngx-tag-success-color, #065f46);--cngx-tag-border: 1px solid var(--cngx-tag-success-border, transparent)}.cngx-tag--filled[data-color=warning]{--cngx-tag-bg: var(--cngx-tag-warning-bg, #fef3c7);--cngx-tag-color: var(--cngx-tag-warning-color, #92400e);--cngx-tag-border: 1px solid var(--cngx-tag-warning-border, transparent)}.cngx-tag--filled[data-color=error]{--cngx-tag-bg: var(--cngx-tag-error-bg, #fee2e2);--cngx-tag-color: var(--cngx-tag-error-color, #991b1b);--cngx-tag-border: 1px solid var(--cngx-tag-error-border, transparent)}.cngx-tag--filled[data-color=info]{--cngx-tag-bg: var(--cngx-tag-info-bg, #dbeafe);--cngx-tag-color: var(--cngx-tag-info-color, #1e40af);--cngx-tag-border: 1px solid var(--cngx-tag-info-border, transparent)}.cngx-tag--outline[data-color=neutral]{--cngx-tag-bg: transparent;--cngx-tag-color: var(--cngx-tag-neutral-color, #374151);--cngx-tag-border: 1px solid var(--cngx-tag-neutral-color, #9ca3af)}.cngx-tag--outline[data-color=success]{--cngx-tag-bg: transparent;--cngx-tag-color: var(--cngx-tag-success-color, #065f46);--cngx-tag-border: 1px solid var(--cngx-tag-success-color, #10b981)}.cngx-tag--outline[data-color=warning]{--cngx-tag-bg: transparent;--cngx-tag-color: var(--cngx-tag-warning-color, #92400e);--cngx-tag-border: 1px solid var(--cngx-tag-warning-color, #f59e0b)}.cngx-tag--outline[data-color=error]{--cngx-tag-bg: transparent;--cngx-tag-color: var(--cngx-tag-error-color, #991b1b);--cngx-tag-border: 1px solid var(--cngx-tag-error-color, #ef4444)}.cngx-tag--outline[data-color=info]{--cngx-tag-bg: transparent;--cngx-tag-color: var(--cngx-tag-info-color, #1e40af);--cngx-tag-border: 1px solid var(--cngx-tag-info-color, #3b82f6)}.cngx-tag--subtle[data-color=neutral]{--cngx-tag-bg: var(--cngx-tag-neutral-subtle-bg, #f3f4f6);--cngx-tag-color: var(--cngx-tag-neutral-color, #374151);--cngx-tag-border: 1px solid transparent}.cngx-tag--subtle[data-color=success]{--cngx-tag-bg: var(--cngx-tag-success-subtle-bg, #ecfdf5);--cngx-tag-color: var(--cngx-tag-success-color, #065f46);--cngx-tag-border: 1px solid transparent}.cngx-tag--subtle[data-color=warning]{--cngx-tag-bg: var(--cngx-tag-warning-subtle-bg, #fffbeb);--cngx-tag-color: var(--cngx-tag-warning-color, #92400e);--cngx-tag-border: 1px solid transparent}.cngx-tag--subtle[data-color=error]{--cngx-tag-bg: var(--cngx-tag-error-subtle-bg, #fef2f2);--cngx-tag-color: var(--cngx-tag-error-color, #991b1b);--cngx-tag-border: 1px solid transparent}.cngx-tag--subtle[data-color=info]{--cngx-tag-bg: var(--cngx-tag-info-subtle-bg, #eff6ff);--cngx-tag-color: var(--cngx-tag-info-color, #1e40af);--cngx-tag-border: 1px solid transparent}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1048
|
+
}
|
|
1049
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTag, decorators: [{
|
|
1050
|
+
type: Component,
|
|
1051
|
+
args: [{ selector: '[cngxTag], cngx-tag', exportAs: 'cngxTag', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [NgTemplateOutlet], template: `
|
|
1052
|
+
@if (prefixTpl(); as t) {
|
|
1053
|
+
<ng-container *ngTemplateOutlet="t; context: slotContext()" />
|
|
1054
|
+
}
|
|
1055
|
+
@if (labelTpl(); as t) {
|
|
1056
|
+
<ng-container *ngTemplateOutlet="t; context: slotContext()" />
|
|
1057
|
+
} @else {
|
|
1058
|
+
<span class="cngx-tag__label"><ng-content /></span>
|
|
1059
|
+
}
|
|
1060
|
+
@if (suffixTpl(); as t) {
|
|
1061
|
+
<ng-container *ngTemplateOutlet="t; context: slotContext()" />
|
|
1062
|
+
}
|
|
1063
|
+
`, host: {
|
|
1064
|
+
class: 'cngx-tag',
|
|
1065
|
+
'[class.cngx-tag--filled]': "variant() === 'filled'",
|
|
1066
|
+
'[class.cngx-tag--outline]': "variant() === 'outline'",
|
|
1067
|
+
'[class.cngx-tag--subtle]': "variant() === 'subtle'",
|
|
1068
|
+
'[class.cngx-tag--sm]': "size() === 'sm'",
|
|
1069
|
+
'[class.cngx-tag--md]': "size() === 'md'",
|
|
1070
|
+
'[class.cngx-tag--lg]': "size() === 'lg'",
|
|
1071
|
+
'[class.cngx-tag--xl]': "size() === 'xl'",
|
|
1072
|
+
'[class.cngx-tag--truncate]': 'truncate()',
|
|
1073
|
+
'[attr.data-color]': 'color()',
|
|
1074
|
+
'[style.max-width]': 'maxWidth()',
|
|
1075
|
+
'[attr.role]': 'roleAttr()',
|
|
1076
|
+
}, styles: [".cngx-tag{display:inline-flex;align-items:center;gap:var(--cngx-tag-gap, .25rem);padding:var(--cngx-tag-padding, .125rem .5rem);font-size:var(--cngx-tag-font-size, .75rem);line-height:1.25;max-width:100%}.cngx-tag--sm{padding:var(--cngx-tag-sm-padding, 0 .375rem);font-size:var(--cngx-tag-sm-font-size, .6875rem)}.cngx-tag--lg{padding:var(--cngx-tag-lg-padding, .25rem .625rem);font-size:var(--cngx-tag-lg-font-size, .875rem)}.cngx-tag--xl{padding:var(--cngx-tag-xl-padding, .375rem .75rem);font-size:var(--cngx-tag-xl-font-size, 1rem)}.cngx-tag__label{min-width:0;overflow:hidden}.cngx-tag--truncate .cngx-tag__label{text-overflow:ellipsis;white-space:nowrap}.cngx-tag-group{display:flex;flex-direction:column;gap:var(--cngx-tag-group-stack-gap, .5rem)}.cngx-tag-group__row{display:flex;flex-wrap:wrap;align-items:center;gap:var(--cngx-tag-group-gap, .5rem);justify-content:flex-start}.cngx-tag-group--gap-xs>.cngx-tag-group__row{gap:var(--cngx-tag-group-gap-xs, .25rem)}.cngx-tag-group--gap-md>.cngx-tag-group__row{gap:var(--cngx-tag-group-gap-md, .75rem)}.cngx-tag-group--align-start>.cngx-tag-group__row{justify-content:flex-start}.cngx-tag-group--align-center>.cngx-tag-group__row{justify-content:center}.cngx-tag-group--align-end>.cngx-tag-group__row{justify-content:flex-end}.cngx-tag-group--align-between>.cngx-tag-group__row{justify-content:space-between}\n", ".cngx-tag{border-radius:var(--cngx-tag-radius, 4px);font-weight:var(--cngx-tag-font-weight, 500);background:var(--cngx-tag-bg, transparent);color:var(--cngx-tag-color, inherit);border:var(--cngx-tag-border, 1px solid transparent)}.cngx-tag--filled[data-color=neutral]{--cngx-tag-bg: var(--cngx-tag-neutral-bg, #e5e7eb);--cngx-tag-color: var(--cngx-tag-neutral-color, #374151);--cngx-tag-border: 1px solid var(--cngx-tag-neutral-border, transparent)}.cngx-tag--filled[data-color=success]{--cngx-tag-bg: var(--cngx-tag-success-bg, #d1fae5);--cngx-tag-color: var(--cngx-tag-success-color, #065f46);--cngx-tag-border: 1px solid var(--cngx-tag-success-border, transparent)}.cngx-tag--filled[data-color=warning]{--cngx-tag-bg: var(--cngx-tag-warning-bg, #fef3c7);--cngx-tag-color: var(--cngx-tag-warning-color, #92400e);--cngx-tag-border: 1px solid var(--cngx-tag-warning-border, transparent)}.cngx-tag--filled[data-color=error]{--cngx-tag-bg: var(--cngx-tag-error-bg, #fee2e2);--cngx-tag-color: var(--cngx-tag-error-color, #991b1b);--cngx-tag-border: 1px solid var(--cngx-tag-error-border, transparent)}.cngx-tag--filled[data-color=info]{--cngx-tag-bg: var(--cngx-tag-info-bg, #dbeafe);--cngx-tag-color: var(--cngx-tag-info-color, #1e40af);--cngx-tag-border: 1px solid var(--cngx-tag-info-border, transparent)}.cngx-tag--outline[data-color=neutral]{--cngx-tag-bg: transparent;--cngx-tag-color: var(--cngx-tag-neutral-color, #374151);--cngx-tag-border: 1px solid var(--cngx-tag-neutral-color, #9ca3af)}.cngx-tag--outline[data-color=success]{--cngx-tag-bg: transparent;--cngx-tag-color: var(--cngx-tag-success-color, #065f46);--cngx-tag-border: 1px solid var(--cngx-tag-success-color, #10b981)}.cngx-tag--outline[data-color=warning]{--cngx-tag-bg: transparent;--cngx-tag-color: var(--cngx-tag-warning-color, #92400e);--cngx-tag-border: 1px solid var(--cngx-tag-warning-color, #f59e0b)}.cngx-tag--outline[data-color=error]{--cngx-tag-bg: transparent;--cngx-tag-color: var(--cngx-tag-error-color, #991b1b);--cngx-tag-border: 1px solid var(--cngx-tag-error-color, #ef4444)}.cngx-tag--outline[data-color=info]{--cngx-tag-bg: transparent;--cngx-tag-color: var(--cngx-tag-info-color, #1e40af);--cngx-tag-border: 1px solid var(--cngx-tag-info-color, #3b82f6)}.cngx-tag--subtle[data-color=neutral]{--cngx-tag-bg: var(--cngx-tag-neutral-subtle-bg, #f3f4f6);--cngx-tag-color: var(--cngx-tag-neutral-color, #374151);--cngx-tag-border: 1px solid transparent}.cngx-tag--subtle[data-color=success]{--cngx-tag-bg: var(--cngx-tag-success-subtle-bg, #ecfdf5);--cngx-tag-color: var(--cngx-tag-success-color, #065f46);--cngx-tag-border: 1px solid transparent}.cngx-tag--subtle[data-color=warning]{--cngx-tag-bg: var(--cngx-tag-warning-subtle-bg, #fffbeb);--cngx-tag-color: var(--cngx-tag-warning-color, #92400e);--cngx-tag-border: 1px solid transparent}.cngx-tag--subtle[data-color=error]{--cngx-tag-bg: var(--cngx-tag-error-subtle-bg, #fef2f2);--cngx-tag-color: var(--cngx-tag-error-color, #991b1b);--cngx-tag-border: 1px solid transparent}.cngx-tag--subtle[data-color=info]{--cngx-tag-bg: var(--cngx-tag-info-subtle-bg, #eff6ff);--cngx-tag-color: var(--cngx-tag-info-color, #1e40af);--cngx-tag-border: 1px solid transparent}\n"] }]
|
|
1077
|
+
}], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], truncate: [{ type: i0.Input, args: [{ isSignal: true, alias: "truncate", required: false }] }], maxWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxWidth", required: false }] }], labelSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxTagLabel), { isSignal: true }] }], prefixSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxTagPrefix), { isSignal: true }] }], suffixSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxTagSuffix), { isSignal: true }] }] } });
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* Reduces a list of feature objects into a partial config — last
|
|
1081
|
+
* write wins per sub-tree. Inner objects are spread-merged so
|
|
1082
|
+
* partial overrides (e.g. just `variant` without `color`) compose
|
|
1083
|
+
* cleanly with prior writes.
|
|
1084
|
+
*
|
|
1085
|
+
* @internal
|
|
1086
|
+
*/
|
|
1087
|
+
function reduceFeatures(features) {
|
|
1088
|
+
const out = {};
|
|
1089
|
+
for (const f of features) {
|
|
1090
|
+
switch (f.kind) {
|
|
1091
|
+
case 'defaults':
|
|
1092
|
+
out.defaults = { ...out.defaults, ...f.payload };
|
|
1093
|
+
break;
|
|
1094
|
+
case 'groupDefaults':
|
|
1095
|
+
out.groupDefaults = { ...out.groupDefaults, ...f.payload };
|
|
1096
|
+
break;
|
|
1097
|
+
case 'colors':
|
|
1098
|
+
out.colors = { ...out.colors, ...f.payload };
|
|
1099
|
+
break;
|
|
1100
|
+
case 'templates':
|
|
1101
|
+
out.templates = { ...out.templates, ...f.payload };
|
|
1102
|
+
break;
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
return out;
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Two-level deep merge: top-level keys (`defaults`/`groupDefaults`/
|
|
1109
|
+
* `colors`/`templates`/`ariaLabels`) are spread-merged so the
|
|
1110
|
+
* partial fills in missing keys without nuking unrelated config
|
|
1111
|
+
* sub-trees. Inner objects are flat (no nested objects beyond one
|
|
1112
|
+
* level) so a single spread per key is sufficient.
|
|
1113
|
+
*
|
|
1114
|
+
* @internal
|
|
1115
|
+
*/
|
|
1116
|
+
function mergeConfig(base, partial) {
|
|
1117
|
+
return {
|
|
1118
|
+
defaults: { ...base.defaults, ...partial.defaults },
|
|
1119
|
+
groupDefaults: { ...base.groupDefaults, ...partial.groupDefaults },
|
|
1120
|
+
colors: { ...base.colors, ...partial.colors },
|
|
1121
|
+
templates: { ...base.templates, ...partial.templates },
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Application-root configuration cascade for the tag family. Pass
|
|
1126
|
+
* any combination of `withTagDefaults` / `withTagGroupDefaults` /
|
|
1127
|
+
* `withTagColors` / `withTagSlots` features in
|
|
1128
|
+
* `bootstrapApplication`'s providers array.
|
|
1129
|
+
*
|
|
1130
|
+
* Resolution priority (high → low):
|
|
1131
|
+
* 1. Per-instance Input binding.
|
|
1132
|
+
* 2. `provideTagConfigAt(...)` in a parent component's
|
|
1133
|
+
* `viewProviders`.
|
|
1134
|
+
* 3. `provideTagConfig(...)` at the application root.
|
|
1135
|
+
* 4. Library defaults (`CNGX_TAG_DEFAULTS`).
|
|
1136
|
+
*
|
|
1137
|
+
* The provider deep-merges supplied features with the library
|
|
1138
|
+
* defaults so consumers only declare keys they want to override.
|
|
1139
|
+
*
|
|
1140
|
+
* ```ts
|
|
1141
|
+
* bootstrapApplication(AppComponent, {
|
|
1142
|
+
* providers: [
|
|
1143
|
+
* provideTagConfig(
|
|
1144
|
+
* withTagDefaults({ variant: 'subtle' }),
|
|
1145
|
+
* withTagColors({
|
|
1146
|
+
* 'my-brand': {
|
|
1147
|
+
* bg: '#4f46e5',
|
|
1148
|
+
* color: '#ffffff',
|
|
1149
|
+
* border: 'transparent',
|
|
1150
|
+
* },
|
|
1151
|
+
* }),
|
|
1152
|
+
* ),
|
|
1153
|
+
* ],
|
|
1154
|
+
* });
|
|
1155
|
+
* ```
|
|
1156
|
+
*/
|
|
1157
|
+
function provideTagConfig(...features) {
|
|
1158
|
+
// Empty-features call: don't override the token. The root factory
|
|
1159
|
+
// already returns `CNGX_TAG_DEFAULTS` — re-providing a fresh
|
|
1160
|
+
// `mergeConfig(...)` would allocate identical content under a new
|
|
1161
|
+
// reference and bust downstream identity comparisons that consumers
|
|
1162
|
+
// of `injectTagConfig()` may rely on.
|
|
1163
|
+
if (features.length === 0) {
|
|
1164
|
+
return makeEnvironmentProviders([]);
|
|
1165
|
+
}
|
|
1166
|
+
const partial = reduceFeatures(features);
|
|
1167
|
+
return makeEnvironmentProviders([
|
|
1168
|
+
{
|
|
1169
|
+
provide: CNGX_TAG_CONFIG,
|
|
1170
|
+
useValue: mergeConfig(CNGX_TAG_DEFAULTS, partial),
|
|
1171
|
+
},
|
|
1172
|
+
]);
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Component-scoped configuration cascade for the tag family. Pass
|
|
1176
|
+
* any combination of feature factories in a parent component's
|
|
1177
|
+
* `viewProviders` array.
|
|
1178
|
+
*
|
|
1179
|
+
* Unlike `provideTagConfig` (root-only), `provideTagConfigAt` injects
|
|
1180
|
+
* the parent injector's `CNGX_TAG_CONFIG` value (resolves through
|
|
1181
|
+
* the priority chain — root provider, library defaults, or another
|
|
1182
|
+
* `provideTagConfigAt` further up) and deep-merges the supplied
|
|
1183
|
+
* features on top. This produces cumulative cascade behaviour:
|
|
1184
|
+
* descendant tag instances see the merged config, sibling sub-trees
|
|
1185
|
+
* keep the inherited value untouched.
|
|
1186
|
+
*
|
|
1187
|
+
* ```ts
|
|
1188
|
+
* @Component({
|
|
1189
|
+
* selector: 'admin-section',
|
|
1190
|
+
* viewProviders: [
|
|
1191
|
+
* provideTagConfigAt(
|
|
1192
|
+
* withTagDefaults({ size: 'sm' }),
|
|
1193
|
+
* ),
|
|
1194
|
+
* ],
|
|
1195
|
+
* template: '<span cngxTag>Compact</span>',
|
|
1196
|
+
* })
|
|
1197
|
+
* class AdminSection {}
|
|
1198
|
+
* ```
|
|
1199
|
+
*/
|
|
1200
|
+
function provideTagConfigAt(...features) {
|
|
1201
|
+
// Empty-features call: parent value flows through untouched.
|
|
1202
|
+
// Skipping the factory preserves reference identity through the
|
|
1203
|
+
// sub-tree.
|
|
1204
|
+
if (features.length === 0) {
|
|
1205
|
+
return [];
|
|
1206
|
+
}
|
|
1207
|
+
const partial = reduceFeatures(features);
|
|
1208
|
+
return [
|
|
1209
|
+
{
|
|
1210
|
+
provide: CNGX_TAG_CONFIG,
|
|
1211
|
+
useFactory: () => {
|
|
1212
|
+
const parent = inject(CNGX_TAG_CONFIG, { skipSelf: true });
|
|
1213
|
+
return mergeConfig(parent, partial);
|
|
1214
|
+
},
|
|
1215
|
+
},
|
|
1216
|
+
];
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
/**
|
|
1220
|
+
* Override the default `CngxTag` input values (`variant`, `color`,
|
|
1221
|
+
* `size`, `truncate`, `maxWidth`). Per-instance bindings still win
|
|
1222
|
+
* over the cascade — this only sets the *fallback* per directive.
|
|
1223
|
+
*
|
|
1224
|
+
* ```ts
|
|
1225
|
+
* provideTagConfig(
|
|
1226
|
+
* withTagDefaults({ variant: 'subtle', size: 'sm' }),
|
|
1227
|
+
* );
|
|
1228
|
+
* ```
|
|
1229
|
+
*/
|
|
1230
|
+
function withTagDefaults(payload) {
|
|
1231
|
+
return { kind: 'defaults', payload };
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* Override the default `CngxTagGroup` input values (`gap`, `align`,
|
|
1235
|
+
* `semanticList`). Per-instance bindings still win.
|
|
1236
|
+
*
|
|
1237
|
+
* ```ts
|
|
1238
|
+
* provideTagConfig(
|
|
1239
|
+
* withTagGroupDefaults({ gap: 'md', semanticList: true }),
|
|
1240
|
+
* );
|
|
1241
|
+
* ```
|
|
1242
|
+
*/
|
|
1243
|
+
function withTagGroupDefaults(payload) {
|
|
1244
|
+
return { kind: 'groupDefaults', payload };
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1247
|
+
* Register consumer-defined colour entries. Each key adds a
|
|
1248
|
+
* `[data-color="<key>"]` cascade entry resolved through
|
|
1249
|
+
* `--cngx-tag-bg/-color/-border` custom properties at the consumer's
|
|
1250
|
+
* own CSS layer.
|
|
1251
|
+
*
|
|
1252
|
+
* The five predefined keys (`neutral`/`success`/`warning`/`error`/
|
|
1253
|
+
* `info`) ship in `tag.css` and are NOT part of this map; passing
|
|
1254
|
+
* them here is a no-op against the predefined cascade. Consumer
|
|
1255
|
+
* keys composed via `data-color="my-brand"` resolve through the
|
|
1256
|
+
* registered entry.
|
|
1257
|
+
*
|
|
1258
|
+
* ```ts
|
|
1259
|
+
* provideTagConfig(
|
|
1260
|
+
* withTagColors({
|
|
1261
|
+
* 'my-brand': {
|
|
1262
|
+
* bg: '#4f46e5',
|
|
1263
|
+
* color: '#ffffff',
|
|
1264
|
+
* border: 'transparent',
|
|
1265
|
+
* },
|
|
1266
|
+
* }),
|
|
1267
|
+
* );
|
|
1268
|
+
* ```
|
|
1269
|
+
*/
|
|
1270
|
+
function withTagColors(payload) {
|
|
1271
|
+
return { kind: 'colors', payload };
|
|
1272
|
+
}
|
|
1273
|
+
/**
|
|
1274
|
+
* Register app-wide template overrides for the five Tag-family
|
|
1275
|
+
* slots. Resolved in tier 2 of the slot cascade — instance
|
|
1276
|
+
* directives still win, the host's `<ng-template>` default body is
|
|
1277
|
+
* the floor.
|
|
1278
|
+
*
|
|
1279
|
+
* **Staging note.** This factory ships ahead of a documented second
|
|
1280
|
+
* consumer — the headless `CngxTag` + `CngxTagGroup` are the only
|
|
1281
|
+
* current consumers. The staging is intentional and tracked in
|
|
1282
|
+
* `display-accepted-debt.md §2` (Material organism deferral): a
|
|
1283
|
+
* future `cngx-mat-tag` / `cngx-mat-tag-group` wrapper inherits the
|
|
1284
|
+
* cascade for free without forking. If §2 is rejected outright,
|
|
1285
|
+
* `withTagSlots` re-evaluates as a sunsetting candidate at the same
|
|
1286
|
+
* time. Per the cngx-review architecture lens, the surface is
|
|
1287
|
+
* tracked rather than left silent.
|
|
1288
|
+
*
|
|
1289
|
+
* ```ts
|
|
1290
|
+
* @Component({
|
|
1291
|
+
* template: `
|
|
1292
|
+
* <ng-template #brandLabel let-color="color">
|
|
1293
|
+
* <strong>{{ color }}</strong>
|
|
1294
|
+
* </ng-template>
|
|
1295
|
+
* `,
|
|
1296
|
+
* })
|
|
1297
|
+
* class AppShell {
|
|
1298
|
+
* readonly brandLabel = viewChild.required<TemplateRef<unknown>>('brandLabel');
|
|
1299
|
+
* }
|
|
1300
|
+
*
|
|
1301
|
+
* // Then in providers:
|
|
1302
|
+
* provideTagConfig(withTagSlots({ label: shell.brandLabel() }));
|
|
1303
|
+
* ```
|
|
1304
|
+
*/
|
|
1305
|
+
function withTagSlots(payload) {
|
|
1306
|
+
return { kind: 'templates', payload };
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
/**
|
|
1310
|
+
* Override template for the accessory zone of `<cngx-tag-group>` —
|
|
1311
|
+
* projected BELOW the row of tags. Use for clear-all buttons,
|
|
1312
|
+
* sort toggles that span the group, secondary actions, or any
|
|
1313
|
+
* trailing decoration the consumer wants to bundle with the
|
|
1314
|
+
* layout.
|
|
1315
|
+
*
|
|
1316
|
+
* The slot has no default body — when not projected, no DOM is
|
|
1317
|
+
* rendered below the tag row. The reactive count of projected
|
|
1318
|
+
* `<span cngxTag>` siblings is exposed via the slot context so
|
|
1319
|
+
* consumer "Clear all (5)" patterns work without injection.
|
|
1320
|
+
*
|
|
1321
|
+
* ```html
|
|
1322
|
+
* <cngx-tag-group [semanticList]="true" label="Active filters">
|
|
1323
|
+
* <span cngxTag>Frontend</span>
|
|
1324
|
+
* <span cngxTag>Backend</span>
|
|
1325
|
+
* <ng-template cngxTagGroupAccessory let-count="count">
|
|
1326
|
+
* <button (click)="clearAll()">Clear all ({{ count }})</button>
|
|
1327
|
+
* </ng-template>
|
|
1328
|
+
* </cngx-tag-group>
|
|
1329
|
+
* ```
|
|
1330
|
+
*/
|
|
1331
|
+
class CngxTagGroupAccessory {
|
|
1332
|
+
templateRef = inject(TemplateRef);
|
|
1333
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTagGroupAccessory, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1334
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxTagGroupAccessory, isStandalone: true, selector: "ng-template[cngxTagGroupAccessory]", exportAs: ["cngxTagGroupAccessory"], ngImport: i0 });
|
|
1335
|
+
}
|
|
1336
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTagGroupAccessory, decorators: [{
|
|
1337
|
+
type: Directive,
|
|
1338
|
+
args: [{
|
|
1339
|
+
selector: 'ng-template[cngxTagGroupAccessory]',
|
|
1340
|
+
standalone: true,
|
|
1341
|
+
exportAs: 'cngxTagGroupAccessory',
|
|
1342
|
+
}]
|
|
1343
|
+
}] });
|
|
1344
|
+
|
|
1345
|
+
/**
|
|
1346
|
+
* Override template for the header zone of `<cngx-tag-group>` —
|
|
1347
|
+
* projected ABOVE the row of tags. Use for label-prefix
|
|
1348
|
+
* ("Filters"), count badges, sort toggles that span the group, or
|
|
1349
|
+
* any header decoration the consumer wants to bundle with the
|
|
1350
|
+
* layout.
|
|
1351
|
+
*
|
|
1352
|
+
* The slot has no default body — when not projected, no DOM is
|
|
1353
|
+
* rendered above the tag row. The reactive count of projected
|
|
1354
|
+
* `<span cngxTag>` siblings is exposed via the slot context for
|
|
1355
|
+
* consumer "Filters ({{ count }})" patterns without injection.
|
|
1356
|
+
*
|
|
1357
|
+
* ```html
|
|
1358
|
+
* <cngx-tag-group [semanticList]="true" label="Filters">
|
|
1359
|
+
* <ng-template cngxTagGroupHeader let-count="count">
|
|
1360
|
+
* <strong>Filters ({{ count }})</strong>
|
|
1361
|
+
* </ng-template>
|
|
1362
|
+
* <span cngxTag>Frontend</span>
|
|
1363
|
+
* <span cngxTag>Backend</span>
|
|
1364
|
+
* </cngx-tag-group>
|
|
1365
|
+
* ```
|
|
1366
|
+
*/
|
|
1367
|
+
class CngxTagGroupHeader {
|
|
1368
|
+
templateRef = inject(TemplateRef);
|
|
1369
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTagGroupHeader, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1370
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxTagGroupHeader, isStandalone: true, selector: "ng-template[cngxTagGroupHeader]", exportAs: ["cngxTagGroupHeader"], ngImport: i0 });
|
|
1371
|
+
}
|
|
1372
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTagGroupHeader, decorators: [{
|
|
1373
|
+
type: Directive,
|
|
1374
|
+
args: [{
|
|
1375
|
+
selector: 'ng-template[cngxTagGroupHeader]',
|
|
1376
|
+
standalone: true,
|
|
1377
|
+
exportAs: 'cngxTagGroupHeader',
|
|
1378
|
+
}]
|
|
1379
|
+
}] });
|
|
1380
|
+
|
|
1381
|
+
/**
|
|
1382
|
+
* Layout-only container for a row of `CngxTag` siblings.
|
|
1383
|
+
*
|
|
1384
|
+
* **Why this exists.**
|
|
1385
|
+
* Pairs with `CngxTag` to satisfy the long tail of "render N taxonomy
|
|
1386
|
+
* badges in a row, optionally as a semantic list" needs. The component
|
|
1387
|
+
* owns *only* the flex-wrap layout (gap / align), the `role="list"` +
|
|
1388
|
+
* `aria-label` ARIA opt-in, and the `<ng-template>`-driven header /
|
|
1389
|
+
* accessory slot zones. The cascade that flips each child's
|
|
1390
|
+
* `role="listitem"` lives on the `CngxTag` side (`tag.directive.ts`
|
|
1391
|
+
* reads `CNGX_TAG_GROUP.semanticList()` through a `computed`); this
|
|
1392
|
+
* component just provides the implementer of that token (Pillar 1 —
|
|
1393
|
+
* derivation rather than imperative sync; Pillar 2 — ARIA in the
|
|
1394
|
+
* reactive graph).
|
|
1395
|
+
*
|
|
1396
|
+
* **Responsibilities (intentionally narrow).**
|
|
1397
|
+
* - Apply gap / align host-class modifiers + thematic CSS custom
|
|
1398
|
+
* properties.
|
|
1399
|
+
* - Bind `role="list"` reactively from `[semanticList]`.
|
|
1400
|
+
* - Bind `aria-label` reactively from `[label]`.
|
|
1401
|
+
* - Provide `CNGX_TAG_GROUP` so descendant `CngxTag` directives can
|
|
1402
|
+
* read `semanticList()` without injecting this concrete class
|
|
1403
|
+
* (atomic-decompose rule 4).
|
|
1404
|
+
* - Project consumer-supplied `*cngxTagGroupHeader` /
|
|
1405
|
+
* `*cngxTagGroupAccessory` templates above / below the tag row,
|
|
1406
|
+
* exposing the live group state plus `count` of projected
|
|
1407
|
+
* `CngxTag` children via the slot context.
|
|
1408
|
+
*
|
|
1409
|
+
* **Non-responsibilities.**
|
|
1410
|
+
* - No `role="listitem"` cascade implementation here — that lives in
|
|
1411
|
+
* `CngxTag` so the cascade survives any future non-component
|
|
1412
|
+
* implementer of `CngxTagGroupHost` (test doubles, programmatic
|
|
1413
|
+
* groups).
|
|
1414
|
+
* - No `hostDirectives` — decorative atoms have no shared cross-cutting
|
|
1415
|
+
* behaviour to compose. Per atomic-decompose rule 1 the absence is
|
|
1416
|
+
* the right call until a future shared concern lands.
|
|
1417
|
+
* - Configuration cascade (`provideTagConfig`) — deferred (see
|
|
1418
|
+
* `display-accepted-debt.md §1`).
|
|
1419
|
+
*/
|
|
1420
|
+
class CngxTagGroup {
|
|
1421
|
+
/**
|
|
1422
|
+
* Snapshot of the resolved tag-family config at construction
|
|
1423
|
+
* time. Drives the per-input fallback defaults below.
|
|
1424
|
+
*
|
|
1425
|
+
* **Field-init ordering is load-bearing** — must be declared
|
|
1426
|
+
* before any input field that reads `this.cfg.groupDefaults?.*`.
|
|
1427
|
+
* Per the `tag-family-architectural-a-plus-pass` plan
|
|
1428
|
+
* Architectural-Decisions table.
|
|
1429
|
+
*/
|
|
1430
|
+
cfg = injectTagConfig();
|
|
1431
|
+
/** Spacing between projected tags. `sm` (default) | `xs` | `md`. */
|
|
1432
|
+
gap = input(this.cfg.groupDefaults?.gap ?? 'sm', ...(ngDevMode ? [{ debugName: "gap" }] : /* istanbul ignore next */ []));
|
|
1433
|
+
/** Cross-axis distribution. `start` (default) | `center` | `end` | `between`. */
|
|
1434
|
+
align = input(this.cfg.groupDefaults?.align ?? 'start', ...(ngDevMode ? [{ debugName: "align" }] : /* istanbul ignore next */ []));
|
|
1435
|
+
/**
|
|
1436
|
+
* Optional label rendered as `aria-label` on the host. When the
|
|
1437
|
+
* group also opts into `[semanticList]="true"`, AT reads "Tags,
|
|
1438
|
+
* list, N items"; without `semanticList`, the label sits on a
|
|
1439
|
+
* decorative grouping (no `role`).
|
|
1440
|
+
*/
|
|
1441
|
+
label = input(undefined, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
1442
|
+
/**
|
|
1443
|
+
* Input-binding hook for the public `[semanticList]` attribute.
|
|
1444
|
+
* Accessed by Angular's template type-checker on consumer
|
|
1445
|
+
* markup — therefore must be class-public (Angular rejects
|
|
1446
|
+
* `private` per NG1053; `protected` blocks external template
|
|
1447
|
+
* bindings). The hook is intentionally **not** the contract
|
|
1448
|
+
* surface — that role belongs to `semanticList` below, typed
|
|
1449
|
+
* `Signal<boolean>` so test doubles and programmatic
|
|
1450
|
+
* implementers of `CngxTagGroupHost` can satisfy the interface
|
|
1451
|
+
* without owning an Angular `input()`.
|
|
1452
|
+
*
|
|
1453
|
+
* @internal
|
|
1454
|
+
*/
|
|
1455
|
+
semanticListInput = input(this.cfg.groupDefaults?.semanticList ?? false, { ...(ngDevMode ? { debugName: "semanticListInput" } : /* istanbul ignore next */ {}), alias: 'semanticList' });
|
|
1456
|
+
/**
|
|
1457
|
+
* Public host-contract field. `InputSignal<boolean>` already
|
|
1458
|
+
* structurally extends `Signal<boolean>`, so the assignment narrows
|
|
1459
|
+
* the public type without a runtime conversion. Read by
|
|
1460
|
+
* `CngxTag.roleAttr` through `CNGX_TAG_GROUP` to derive
|
|
1461
|
+
* `role="listitem"` reactively.
|
|
1462
|
+
*/
|
|
1463
|
+
semanticList = this.semanticListInput;
|
|
1464
|
+
/**
|
|
1465
|
+
* Live count of projected `<span cngxTag>` direct children. Drives
|
|
1466
|
+
* the `count` field of the header / accessory slot contexts so
|
|
1467
|
+
* consumer "Filters ({{ count }})" patterns work without
|
|
1468
|
+
* injection. Default `Object.is` equality is correct for a
|
|
1469
|
+
* primitive number.
|
|
1470
|
+
*/
|
|
1471
|
+
count = computed(() => this.projectedTags().length, ...(ngDevMode ? [{ debugName: "count" }] : /* istanbul ignore next */ []));
|
|
1472
|
+
/**
|
|
1473
|
+
* Per-instance header-slot directive — projected as
|
|
1474
|
+
* `<ng-template cngxTagGroupHeader>...</ng-template>`. Resolved
|
|
1475
|
+
* through {@link injectResolvedTagTemplate} so consumers can
|
|
1476
|
+
* project a header without wrapping the group component.
|
|
1477
|
+
*/
|
|
1478
|
+
headerSlot = contentChild(CngxTagGroupHeader, ...(ngDevMode ? [{ debugName: "headerSlot" }] : /* istanbul ignore next */ []));
|
|
1479
|
+
/** Per-instance accessory-slot directive — projected below the row. */
|
|
1480
|
+
accessorySlot = contentChild(CngxTagGroupAccessory, ...(ngDevMode ? [{ debugName: "accessorySlot" }] : /* istanbul ignore next */ []));
|
|
1481
|
+
/**
|
|
1482
|
+
* Resolved header template. Phase 2 cascade: instance slot → null
|
|
1483
|
+
* (no DOM rendered above the row when not projected). Phase 4
|
|
1484
|
+
* commit 5 inserts `CNGX_TAG_CONFIG.templates.header` as a middle
|
|
1485
|
+
* tier without touching this call site.
|
|
1486
|
+
*/
|
|
1487
|
+
headerTpl = injectResolvedTagTemplate(this.headerSlot, 'header');
|
|
1488
|
+
/** Resolved accessory template. Same 2-stage cascade as {@link headerTpl}. */
|
|
1489
|
+
accessoryTpl = injectResolvedTagTemplate(this.accessorySlot, 'accessory');
|
|
1490
|
+
/**
|
|
1491
|
+
* Projected `<span cngxTag>` siblings. Default-scoped
|
|
1492
|
+
* (`descendants: false`) so tags inside consumer-projected header /
|
|
1493
|
+
* accessory templates do NOT inflate the count — the count
|
|
1494
|
+
* represents the row's own taxonomy items, not arbitrary tag
|
|
1495
|
+
* usage inside the slot zones.
|
|
1496
|
+
*/
|
|
1497
|
+
projectedTags = contentChildren(CngxTag, ...(ngDevMode ? [{ debugName: "projectedTags" }] : /* istanbul ignore next */ []));
|
|
1498
|
+
/**
|
|
1499
|
+
* Reactive bundle exposed to header / accessory slots'
|
|
1500
|
+
* `*ngTemplateOutletContext`. The two slot context interfaces are
|
|
1501
|
+
* structurally identical in Phase 2; the same computed source
|
|
1502
|
+
* serves both. Consumer templates `let-count="count"` etc. read
|
|
1503
|
+
* the live state without injecting the directive.
|
|
1504
|
+
*
|
|
1505
|
+
* Explicit structural `equal` fn — without it, a fresh literal
|
|
1506
|
+
* each CD cycle would force `ngTemplateOutlet` to rebind embedded
|
|
1507
|
+
* views even when no input changed. Per
|
|
1508
|
+
* `reference_signal_architecture` §1 Equality Rule: every
|
|
1509
|
+
* `computed` returning an object MUST pass an `equal` fn.
|
|
1510
|
+
*/
|
|
1511
|
+
slotContext = computed(() => ({
|
|
1512
|
+
$implicit: undefined,
|
|
1513
|
+
gap: this.gap(),
|
|
1514
|
+
align: this.align(),
|
|
1515
|
+
semanticList: this.semanticList(),
|
|
1516
|
+
label: this.label(),
|
|
1517
|
+
count: this.count(),
|
|
1518
|
+
}), { ...(ngDevMode ? { debugName: "slotContext" } : /* istanbul ignore next */ {}), equal: (a, b) => a.gap === b.gap &&
|
|
1519
|
+
a.align === b.align &&
|
|
1520
|
+
a.semanticList === b.semanticList &&
|
|
1521
|
+
a.label === b.label &&
|
|
1522
|
+
a.count === b.count });
|
|
1523
|
+
constructor() {
|
|
1524
|
+
// Dev-mode advisory: `<cngx-tag-group [label]="...">` without
|
|
1525
|
+
// `[semanticList]="true"` lands the `aria-label` on a generic
|
|
1526
|
+
// `<div>` (no `role="list"`). AT then exposes the aria-label
|
|
1527
|
+
// but doesn't surface "list, N items" — likely not the
|
|
1528
|
+
// consumer's intent. One-shot post-mount check; tree-shaken in
|
|
1529
|
+
// prod via the `isDevMode()` guard.
|
|
1530
|
+
//
|
|
1531
|
+
// `afterNextRender` is the canonical hook for one-shot
|
|
1532
|
+
// post-mount checks (per `reference_signal_architecture` Hook
|
|
1533
|
+
// Selection Matrix); `effect()` would re-fire on every input
|
|
1534
|
+
// change. Reads are wrapped in `untracked()` defensively —
|
|
1535
|
+
// `afterNextRender` does not establish a reactive scope, but
|
|
1536
|
+
// the explicit wrapper documents one-shot intent and matches
|
|
1537
|
+
// the cngx style-guide bias toward signal-read hygiene.
|
|
1538
|
+
afterNextRender(() => {
|
|
1539
|
+
const { label, semanticList } = untracked(() => ({
|
|
1540
|
+
label: this.label(),
|
|
1541
|
+
semanticList: this.semanticList(),
|
|
1542
|
+
}));
|
|
1543
|
+
if (isDevMode() && label && !semanticList) {
|
|
1544
|
+
console.warn('[cngx-tag-group] [label] is bound without [semanticList]="true"; ' +
|
|
1545
|
+
'the aria-label lands on a generic <div>. Add ' +
|
|
1546
|
+
'[semanticList]="true" to expose role="list" + aria-label, ' +
|
|
1547
|
+
'or remove [label].');
|
|
1548
|
+
}
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1551
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTagGroup, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1552
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxTagGroup, isStandalone: true, selector: "cngx-tag-group", inputs: { gap: { classPropertyName: "gap", publicName: "gap", isSignal: true, isRequired: false, transformFunction: null }, align: { classPropertyName: "align", publicName: "align", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, semanticListInput: { classPropertyName: "semanticListInput", publicName: "semanticList", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cngx-tag-group--gap-xs": "gap() === 'xs'", "class.cngx-tag-group--gap-md": "gap() === 'md'", "class.cngx-tag-group--align-start": "align() === 'start'", "class.cngx-tag-group--align-center": "align() === 'center'", "class.cngx-tag-group--align-end": "align() === 'end'", "class.cngx-tag-group--align-between": "align() === 'between'", "attr.role": "semanticList() ? 'list' : null", "attr.aria-label": "label() ?? null" }, classAttribute: "cngx-tag-group" }, providers: [{ provide: CNGX_TAG_GROUP, useExisting: CngxTagGroup }], queries: [{ propertyName: "headerSlot", first: true, predicate: CngxTagGroupHeader, descendants: true, isSignal: true }, { propertyName: "accessorySlot", first: true, predicate: CngxTagGroupAccessory, descendants: true, isSignal: true }, { propertyName: "projectedTags", predicate: CngxTag, isSignal: true }], exportAs: ["cngxTagGroup"], ngImport: i0, template: `
|
|
1553
|
+
@if (headerTpl(); as t) {
|
|
1554
|
+
<ng-container *ngTemplateOutlet="t; context: slotContext()" />
|
|
1555
|
+
}
|
|
1556
|
+
<div class="cngx-tag-group__row">
|
|
1557
|
+
<ng-content />
|
|
1558
|
+
</div>
|
|
1559
|
+
@if (accessoryTpl(); as t) {
|
|
1560
|
+
<ng-container *ngTemplateOutlet="t; context: slotContext()" />
|
|
1561
|
+
}
|
|
1562
|
+
`, isInline: true, styles: [".cngx-tag{display:inline-flex;align-items:center;gap:var(--cngx-tag-gap, .25rem);padding:var(--cngx-tag-padding, .125rem .5rem);font-size:var(--cngx-tag-font-size, .75rem);line-height:1.25;max-width:100%}.cngx-tag--sm{padding:var(--cngx-tag-sm-padding, 0 .375rem);font-size:var(--cngx-tag-sm-font-size, .6875rem)}.cngx-tag--lg{padding:var(--cngx-tag-lg-padding, .25rem .625rem);font-size:var(--cngx-tag-lg-font-size, .875rem)}.cngx-tag--xl{padding:var(--cngx-tag-xl-padding, .375rem .75rem);font-size:var(--cngx-tag-xl-font-size, 1rem)}.cngx-tag__label{min-width:0;overflow:hidden}.cngx-tag--truncate .cngx-tag__label{text-overflow:ellipsis;white-space:nowrap}.cngx-tag-group{display:flex;flex-direction:column;gap:var(--cngx-tag-group-stack-gap, .5rem)}.cngx-tag-group__row{display:flex;flex-wrap:wrap;align-items:center;gap:var(--cngx-tag-group-gap, .5rem);justify-content:flex-start}.cngx-tag-group--gap-xs>.cngx-tag-group__row{gap:var(--cngx-tag-group-gap-xs, .25rem)}.cngx-tag-group--gap-md>.cngx-tag-group__row{gap:var(--cngx-tag-group-gap-md, .75rem)}.cngx-tag-group--align-start>.cngx-tag-group__row{justify-content:flex-start}.cngx-tag-group--align-center>.cngx-tag-group__row{justify-content:center}.cngx-tag-group--align-end>.cngx-tag-group__row{justify-content:flex-end}.cngx-tag-group--align-between>.cngx-tag-group__row{justify-content:space-between}\n", ""], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1563
|
+
}
|
|
1564
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTagGroup, decorators: [{
|
|
1565
|
+
type: Component,
|
|
1566
|
+
args: [{ selector: 'cngx-tag-group', exportAs: 'cngxTagGroup', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgTemplateOutlet], encapsulation: ViewEncapsulation.None, template: `
|
|
1567
|
+
@if (headerTpl(); as t) {
|
|
1568
|
+
<ng-container *ngTemplateOutlet="t; context: slotContext()" />
|
|
1569
|
+
}
|
|
1570
|
+
<div class="cngx-tag-group__row">
|
|
1571
|
+
<ng-content />
|
|
1572
|
+
</div>
|
|
1573
|
+
@if (accessoryTpl(); as t) {
|
|
1574
|
+
<ng-container *ngTemplateOutlet="t; context: slotContext()" />
|
|
1575
|
+
}
|
|
1576
|
+
`, providers: [{ provide: CNGX_TAG_GROUP, useExisting: CngxTagGroup }], host: {
|
|
1577
|
+
class: 'cngx-tag-group',
|
|
1578
|
+
'[class.cngx-tag-group--gap-xs]': "gap() === 'xs'",
|
|
1579
|
+
'[class.cngx-tag-group--gap-md]': "gap() === 'md'",
|
|
1580
|
+
'[class.cngx-tag-group--align-start]': "align() === 'start'",
|
|
1581
|
+
'[class.cngx-tag-group--align-center]': "align() === 'center'",
|
|
1582
|
+
'[class.cngx-tag-group--align-end]': "align() === 'end'",
|
|
1583
|
+
'[class.cngx-tag-group--align-between]': "align() === 'between'",
|
|
1584
|
+
'[attr.role]': "semanticList() ? 'list' : null",
|
|
1585
|
+
'[attr.aria-label]': 'label() ?? null',
|
|
1586
|
+
}, styles: [".cngx-tag{display:inline-flex;align-items:center;gap:var(--cngx-tag-gap, .25rem);padding:var(--cngx-tag-padding, .125rem .5rem);font-size:var(--cngx-tag-font-size, .75rem);line-height:1.25;max-width:100%}.cngx-tag--sm{padding:var(--cngx-tag-sm-padding, 0 .375rem);font-size:var(--cngx-tag-sm-font-size, .6875rem)}.cngx-tag--lg{padding:var(--cngx-tag-lg-padding, .25rem .625rem);font-size:var(--cngx-tag-lg-font-size, .875rem)}.cngx-tag--xl{padding:var(--cngx-tag-xl-padding, .375rem .75rem);font-size:var(--cngx-tag-xl-font-size, 1rem)}.cngx-tag__label{min-width:0;overflow:hidden}.cngx-tag--truncate .cngx-tag__label{text-overflow:ellipsis;white-space:nowrap}.cngx-tag-group{display:flex;flex-direction:column;gap:var(--cngx-tag-group-stack-gap, .5rem)}.cngx-tag-group__row{display:flex;flex-wrap:wrap;align-items:center;gap:var(--cngx-tag-group-gap, .5rem);justify-content:flex-start}.cngx-tag-group--gap-xs>.cngx-tag-group__row{gap:var(--cngx-tag-group-gap-xs, .25rem)}.cngx-tag-group--gap-md>.cngx-tag-group__row{gap:var(--cngx-tag-group-gap-md, .75rem)}.cngx-tag-group--align-start>.cngx-tag-group__row{justify-content:flex-start}.cngx-tag-group--align-center>.cngx-tag-group__row{justify-content:center}.cngx-tag-group--align-end>.cngx-tag-group__row{justify-content:flex-end}.cngx-tag-group--align-between>.cngx-tag-group__row{justify-content:space-between}\n"] }]
|
|
1587
|
+
}], ctorParameters: () => [], propDecorators: { gap: [{ type: i0.Input, args: [{ isSignal: true, alias: "gap", required: false }] }], align: [{ type: i0.Input, args: [{ isSignal: true, alias: "align", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], semanticListInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "semanticList", required: false }] }], headerSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxTagGroupHeader), { isSignal: true }] }], accessorySlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxTagGroupAccessory), { isSignal: true }] }], projectedTags: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CngxTag), { isSignal: true }] }] } });
|
|
1588
|
+
|
|
1589
|
+
/**
|
|
1590
|
+
* @module @cngx/common/display
|
|
1591
|
+
*
|
|
1592
|
+
* Display-only atoms: no behavior, no state beyond presentational flags.
|
|
1593
|
+
* Icons, avatars, badges, dividers — building blocks that render content
|
|
1594
|
+
* without reacting to user input. For interactive atoms (ripple, async-click,
|
|
1595
|
+
* nav badges) see `@cngx/common/interactive`.
|
|
1596
|
+
*/
|
|
1597
|
+
|
|
1598
|
+
/**
|
|
1599
|
+
* Generated bundle index. Do not edit.
|
|
1600
|
+
*/
|
|
1601
|
+
|
|
1602
|
+
export { CNGX_TAG_CONFIG, CNGX_TAG_GROUP, CngxAvatar, CngxBadge, CngxCheckboxIndicator, CngxChip, CngxDivider, CngxIcon, CngxRadioIndicator, CngxTag, CngxTagGroup, CngxTagGroupAccessory, CngxTagGroupHeader, CngxTagLabel, CngxTagPrefix, CngxTagSuffix, injectTagConfig, provideTagConfig, provideTagConfigAt, withTagColors, withTagDefaults, withTagGroupDefaults, withTagSlots };
|
|
1603
|
+
//# sourceMappingURL=cngx-common-display.mjs.map
|