@cngx/ui 0.1.0-rc.9 → 0.3.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/README.md +118 -59
- package/action-button/README.md +170 -53
- package/breadcrumb/README.md +5 -6
- package/collection/README.md +1 -1
- package/command-palette/README.md +4 -3
- package/data-grid-accordion/README.md +1 -1
- package/empty-state/README.md +2 -3
- package/feedback/README.md +1 -1
- package/fesm2022/cngx-ui-a11y.mjs +13 -23
- package/fesm2022/cngx-ui-a11y.mjs.map +1 -1
- package/fesm2022/cngx-ui-accordion.mjs +44 -66
- package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-action-button.mjs +213 -335
- package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
- package/fesm2022/cngx-ui-breadcrumb.mjs +60 -80
- package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
- package/fesm2022/cngx-ui-chart-panel.mjs +18 -31
- package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -1
- package/fesm2022/cngx-ui-collection.mjs +28 -44
- package/fesm2022/cngx-ui-collection.mjs.map +1 -1
- package/fesm2022/cngx-ui-command-palette.mjs +29 -51
- package/fesm2022/cngx-ui-command-palette.mjs.map +1 -1
- package/fesm2022/cngx-ui-context-menu.mjs +78 -83
- package/fesm2022/cngx-ui-context-menu.mjs.map +1 -1
- package/fesm2022/cngx-ui-data-grid-accordion.mjs +52 -74
- package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-empty-state.mjs +17 -44
- package/fesm2022/cngx-ui-empty-state.mjs.map +1 -1
- package/fesm2022/cngx-ui-feedback.mjs +589 -467
- package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
- package/fesm2022/cngx-ui-layout.mjs +17 -13
- package/fesm2022/cngx-ui-layout.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-accordion.mjs +3 -5
- package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-paginator.mjs +5 -9
- package/fesm2022/cngx-ui-mat-paginator.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-stepper.mjs +6 -9
- package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-tabs.mjs +71 -68
- package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-nav-rail.mjs +440 -0
- package/fesm2022/cngx-ui-nav-rail.mjs.map +1 -0
- package/fesm2022/cngx-ui-overlay.mjs +9 -10
- package/fesm2022/cngx-ui-overlay.mjs.map +1 -1
- package/fesm2022/cngx-ui-paginator.mjs +149 -171
- package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
- package/fesm2022/cngx-ui-sidenav.mjs +858 -721
- package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
- package/fesm2022/cngx-ui-skeleton.mjs +17 -19
- package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
- package/fesm2022/cngx-ui-speak.mjs +21 -74
- package/fesm2022/cngx-ui-speak.mjs.map +1 -1
- package/fesm2022/cngx-ui-stat-card.mjs +39 -62
- package/fesm2022/cngx-ui-stat-card.mjs.map +1 -1
- package/fesm2022/cngx-ui-stepper.mjs +207 -90
- package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-tabs.mjs +71 -32
- package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-timeline.mjs +21 -27
- package/fesm2022/cngx-ui-timeline.mjs.map +1 -1
- package/fesm2022/cngx-ui-toc.mjs +27 -40
- package/fesm2022/cngx-ui-toc.mjs.map +1 -1
- package/fesm2022/cngx-ui.mjs +5 -5
- package/fesm2022/cngx-ui.mjs.map +1 -1
- package/mat-tabs/README.md +28 -14
- package/mat-tabs/styles/mat-tabs.css +233 -258
- package/nav-rail/README.md +325 -0
- package/package.json +10 -5
- package/paginator/README.md +10 -0
- package/schematics/ng-add/index.js +7 -7
- package/schematics/ng-add/schema.json +5 -0
- package/sidenav/README.md +150 -55
- package/skeleton/README.md +1 -1
- package/speak/README.md +1 -2
- package/stepper/README.md +20 -5
- package/tabs/README.md +13 -0
- package/timeline/README.md +1 -1
- package/toc/README.md +1 -1
- package/types/cngx-ui-a11y.d.ts +20 -38
- package/types/cngx-ui-accordion.d.ts +45 -77
- package/types/cngx-ui-action-button.d.ts +113 -151
- package/types/cngx-ui-breadcrumb.d.ts +58 -94
- package/types/cngx-ui-chart-panel.d.ts +22 -40
- package/types/cngx-ui-collection.d.ts +30 -53
- package/types/cngx-ui-command-palette.d.ts +40 -64
- package/types/cngx-ui-context-menu.d.ts +67 -44
- package/types/cngx-ui-data-grid-accordion.d.ts +49 -77
- package/types/cngx-ui-empty-state.d.ts +18 -8
- package/types/cngx-ui-feedback.d.ts +264 -289
- package/types/cngx-ui-layout.d.ts +4 -12
- package/types/cngx-ui-mat-accordion.d.ts +2 -3
- package/types/cngx-ui-mat-paginator.d.ts +4 -10
- package/types/cngx-ui-mat-stepper.d.ts +5 -10
- package/types/cngx-ui-mat-tabs.d.ts +43 -69
- package/types/cngx-ui-nav-rail.d.ts +416 -0
- package/types/cngx-ui-overlay.d.ts +4 -13
- package/types/cngx-ui-paginator.d.ts +164 -154
- package/types/cngx-ui-sidenav.d.ts +557 -437
- package/types/cngx-ui-skeleton.d.ts +7 -13
- package/types/cngx-ui-speak.d.ts +40 -24
- package/types/cngx-ui-stat-card.d.ts +45 -36
- package/types/cngx-ui-stepper.d.ts +183 -62
- package/types/cngx-ui-tabs.d.ts +101 -27
- package/types/cngx-ui-timeline.d.ts +20 -48
- package/types/cngx-ui-toc.d.ts +30 -51
- package/types/cngx-ui.d.ts +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { inject, TemplateRef, Directive, input, computed, contentChild,
|
|
4
|
-
import {
|
|
3
|
+
import { inject, TemplateRef, Directive, input, computed, contentChild, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
|
+
import { injectEffectiveMotion } from '@cngx/core';
|
|
5
|
+
import { injectLoadingConfig, createVisibilityGate } from '@cngx/core/utils';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Structural slot directive that registers a `<ng-template>` as the
|
|
@@ -50,11 +51,9 @@ import { injectLoadingConfig, createVisibilityGate, createMediaQuerySignal } fro
|
|
|
50
51
|
* </ng-template>
|
|
51
52
|
* ```
|
|
52
53
|
*
|
|
53
|
-
* @category ui/skeleton
|
|
54
|
-
* @docsKind primary
|
|
55
54
|
* @wcag AA
|
|
56
55
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/skeleton/skeleton-placeholder.ts
|
|
57
|
-
* @since 0.
|
|
56
|
+
* @since 0.3.0
|
|
58
57
|
* @relatedTo CngxSkeletonContainer
|
|
59
58
|
*/
|
|
60
59
|
class CngxSkeletonPlaceholder {
|
|
@@ -102,17 +101,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
102
101
|
* </cngx-skeleton>
|
|
103
102
|
* ```
|
|
104
103
|
*
|
|
105
|
-
* @category ui/skeleton
|
|
106
|
-
* @docsKind primary
|
|
107
104
|
* @wcag AA
|
|
108
105
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/skeleton/skeleton-container.ts
|
|
109
|
-
* @since 0.
|
|
106
|
+
* @since 0.3.0
|
|
110
107
|
* @relatedTo CngxSkeletonPlaceholder, CngxAsyncState, CngxEmptyState
|
|
111
108
|
* @slot cngxSkeletonPlaceholder Replaces the generated placeholder shape.
|
|
112
|
-
* <example-url
|
|
113
|
-
* <example-url
|
|
114
|
-
* <example-url
|
|
115
|
-
*
|
|
109
|
+
* <example-url>/#/ui/skeleton/skeleton-container</example-url>
|
|
110
|
+
* <example-url>/#/ui/skeleton/card-skeleton</example-url>
|
|
111
|
+
* <example-url>/#/ui/skeleton/template-context</example-url>
|
|
112
|
+
* @axis level molecule
|
|
116
113
|
*/
|
|
117
114
|
class CngxSkeletonContainer {
|
|
118
115
|
loadingConfig = injectLoadingConfig();
|
|
@@ -140,9 +137,9 @@ class CngxSkeletonContainer {
|
|
|
140
137
|
placeholderTpl = contentChild(CngxSkeletonPlaceholder, ...(ngDevMode ? [{ debugName: "placeholderTpl" }] : /* istanbul ignore next */ []));
|
|
141
138
|
/** Array of indices for internal `@for` rendering. */
|
|
142
139
|
indices = computed(() => Array.from({ length: this.count() }, (_, i) => i), ...(ngDevMode ? [{ debugName: "indices" }] : /* istanbul ignore next */ []));
|
|
143
|
-
|
|
140
|
+
motion = injectEffectiveMotion();
|
|
144
141
|
/** @internal */
|
|
145
|
-
showShimmer = computed(() => this.gatedLoading() && this.shimmer() &&
|
|
142
|
+
showShimmer = computed(() => this.gatedLoading() && this.shimmer() && this.motion() !== 'reduced', ...(ngDevMode ? [{ debugName: "showShimmer" }] : /* istanbul ignore next */ []));
|
|
146
143
|
/** @internal */
|
|
147
144
|
getContext(index) {
|
|
148
145
|
const total = this.count();
|
|
@@ -155,7 +152,7 @@ class CngxSkeletonContainer {
|
|
|
155
152
|
};
|
|
156
153
|
}
|
|
157
154
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSkeletonContainer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
158
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxSkeletonContainer, isStandalone: true, selector: "cngx-skeleton", inputs: { loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, shimmer: { classPropertyName: "shimmer", publicName: "shimmer", isSignal: true, isRequired: false, transformFunction: null }, count: { classPropertyName: "count", publicName: "count", isSignal: true, isRequired: false, transformFunction: null }, showDelay: { classPropertyName: "showDelay", publicName: "showDelay", isSignal: true, isRequired: false, transformFunction: null }, minDwell: { classPropertyName: "minDwell", publicName: "minDwell", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cngx-skeleton--loading": "gatedLoading()", "class.cngx-skeleton--shimmer": "showShimmer()", "attr.aria-busy": "gatedLoading() || null" }, styleAttribute: "display: contents", classAttribute: "cngx-skeleton" }, queries: [{ propertyName: "placeholderTpl", first: true, predicate: CngxSkeletonPlaceholder, descendants: true, isSignal: true }], exportAs: ["cngxSkeletonContainer"], ngImport: i0, template: `
|
|
155
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxSkeletonContainer, isStandalone: true, selector: "cngx-skeleton", inputs: { loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, shimmer: { classPropertyName: "shimmer", publicName: "shimmer", isSignal: true, isRequired: false, transformFunction: null }, count: { classPropertyName: "count", publicName: "count", isSignal: true, isRequired: false, transformFunction: null }, showDelay: { classPropertyName: "showDelay", publicName: "showDelay", isSignal: true, isRequired: false, transformFunction: null }, minDwell: { classPropertyName: "minDwell", publicName: "minDwell", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cngx-skeleton--loading": "gatedLoading()", "class.cngx-skeleton--shimmer": "showShimmer()", "attr.aria-busy": "gatedLoading() || null", "attr.data-cngx-busy": "gatedLoading() || null" }, styleAttribute: "display: contents", classAttribute: "cngx-skeleton" }, queries: [{ propertyName: "placeholderTpl", first: true, predicate: CngxSkeletonPlaceholder, descendants: true, isSignal: true }], exportAs: ["cngxSkeletonContainer"], ngImport: i0, template: `
|
|
159
156
|
@if (gatedLoading()) {
|
|
160
157
|
@for (i of indices(); track i) {
|
|
161
158
|
<ng-container
|
|
@@ -165,7 +162,7 @@ class CngxSkeletonContainer {
|
|
|
165
162
|
} @else {
|
|
166
163
|
<ng-content />
|
|
167
164
|
}
|
|
168
|
-
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-skeleton-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(.88 0 0);}@property --cngx-skeleton-shimmer-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.96 0 0);}@property --cngx-skeleton-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-skeleton-shimmer-duration{syntax: \"<time>\"; inherits: false; initial-value: 1.5s;}:root{--cngx-skeleton-bg: oklch(.88 0 0);--cngx-skeleton-shimmer-color: oklch(.96 0 0)}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-skeleton-bg: oklch(.25 0 0);--cngx-skeleton-shimmer-color: oklch(.35 0 0)}}:root[data-color-scheme=dark],:root.dark{--cngx-skeleton-bg: oklch(.25 0 0);--cngx-skeleton-shimmer-color: oklch(.35 0 0)}:root[data-color-scheme=light],:root.light{--cngx-skeleton-bg: oklch(.88 0 0);--cngx-skeleton-shimmer-color: oklch(.96 0 0)}}@layer cngx.components{@scope(.cngx-skeleton){:scope.cngx-skeleton--shimmer .cngx-
|
|
165
|
+
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-skeleton-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(.88 0 0);}@property --cngx-skeleton-shimmer-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.96 0 0);}@property --cngx-skeleton-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-skeleton-shimmer-duration{syntax: \"<time>\"; inherits: false; initial-value: 1.5s;}:root{--cngx-skeleton-bg: oklch(.88 0 0);--cngx-skeleton-shimmer-color: oklch(.96 0 0)}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-skeleton-bg: oklch(.25 0 0);--cngx-skeleton-shimmer-color: oklch(.35 0 0)}}:root[data-color-scheme=dark],:root.dark{--cngx-skeleton-bg: oklch(.25 0 0);--cngx-skeleton-shimmer-color: oklch(.35 0 0)}:root[data-color-scheme=light],:root.light{--cngx-skeleton-bg: oklch(.88 0 0);--cngx-skeleton-shimmer-color: oklch(.96 0 0)}}@layer cngx.components{@scope(.cngx-skeleton){:scope.cngx-skeleton--shimmer .cngx-skeleton__bone{background-color:var(--cngx-skeleton-bg, oklch(.88 0 0));background-image:linear-gradient(90deg,var(--cngx-skeleton-bg, oklch(.88 0 0)) 0%,var(--cngx-skeleton-shimmer-color, oklch(.96 0 0)) 50%,var(--cngx-skeleton-bg, oklch(.88 0 0)) 100%);background-size:200% 100%;animation:cngx-skeleton-shimmer var(--cngx-skeleton-shimmer-duration, 1.5s) ease-in-out infinite;border-radius:var(--cngx-skeleton-radius, 4px)}@media(prefers-reduced-motion:reduce){:scope.cngx-skeleton--shimmer .cngx-skeleton__bone{animation:none}}}}@keyframes cngx-skeleton-shimmer{0%{background-position:-200% 0}to{background-position:200% 0}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
169
166
|
}
|
|
170
167
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSkeletonContainer, decorators: [{
|
|
171
168
|
type: Component,
|
|
@@ -175,6 +172,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
175
172
|
'[class.cngx-skeleton--loading]': 'gatedLoading()',
|
|
176
173
|
'[class.cngx-skeleton--shimmer]': 'showShimmer()',
|
|
177
174
|
'[attr.aria-busy]': 'gatedLoading() || null',
|
|
175
|
+
'[attr.data-cngx-busy]': 'gatedLoading() || null',
|
|
178
176
|
}, template: `
|
|
179
177
|
@if (gatedLoading()) {
|
|
180
178
|
@for (i of indices(); track i) {
|
|
@@ -185,11 +183,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
185
183
|
} @else {
|
|
186
184
|
<ng-content />
|
|
187
185
|
}
|
|
188
|
-
`, styles: ["@layer cngx.tokens{@property --cngx-skeleton-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(.88 0 0);}@property --cngx-skeleton-shimmer-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.96 0 0);}@property --cngx-skeleton-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-skeleton-shimmer-duration{syntax: \"<time>\"; inherits: false; initial-value: 1.5s;}:root{--cngx-skeleton-bg: oklch(.88 0 0);--cngx-skeleton-shimmer-color: oklch(.96 0 0)}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-skeleton-bg: oklch(.25 0 0);--cngx-skeleton-shimmer-color: oklch(.35 0 0)}}:root[data-color-scheme=dark],:root.dark{--cngx-skeleton-bg: oklch(.25 0 0);--cngx-skeleton-shimmer-color: oklch(.35 0 0)}:root[data-color-scheme=light],:root.light{--cngx-skeleton-bg: oklch(.88 0 0);--cngx-skeleton-shimmer-color: oklch(.96 0 0)}}@layer cngx.components{@scope(.cngx-skeleton){:scope.cngx-skeleton--shimmer .cngx-
|
|
186
|
+
`, styles: ["@layer cngx.tokens{@property --cngx-skeleton-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(.88 0 0);}@property --cngx-skeleton-shimmer-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.96 0 0);}@property --cngx-skeleton-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-skeleton-shimmer-duration{syntax: \"<time>\"; inherits: false; initial-value: 1.5s;}:root{--cngx-skeleton-bg: oklch(.88 0 0);--cngx-skeleton-shimmer-color: oklch(.96 0 0)}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-skeleton-bg: oklch(.25 0 0);--cngx-skeleton-shimmer-color: oklch(.35 0 0)}}:root[data-color-scheme=dark],:root.dark{--cngx-skeleton-bg: oklch(.25 0 0);--cngx-skeleton-shimmer-color: oklch(.35 0 0)}:root[data-color-scheme=light],:root.light{--cngx-skeleton-bg: oklch(.88 0 0);--cngx-skeleton-shimmer-color: oklch(.96 0 0)}}@layer cngx.components{@scope(.cngx-skeleton){:scope.cngx-skeleton--shimmer .cngx-skeleton__bone{background-color:var(--cngx-skeleton-bg, oklch(.88 0 0));background-image:linear-gradient(90deg,var(--cngx-skeleton-bg, oklch(.88 0 0)) 0%,var(--cngx-skeleton-shimmer-color, oklch(.96 0 0)) 50%,var(--cngx-skeleton-bg, oklch(.88 0 0)) 100%);background-size:200% 100%;animation:cngx-skeleton-shimmer var(--cngx-skeleton-shimmer-duration, 1.5s) ease-in-out infinite;border-radius:var(--cngx-skeleton-radius, 4px)}@media(prefers-reduced-motion:reduce){:scope.cngx-skeleton--shimmer .cngx-skeleton__bone{animation:none}}}}@keyframes cngx-skeleton-shimmer{0%{background-position:-200% 0}to{background-position:200% 0}}\n"] }]
|
|
189
187
|
}], propDecorators: { loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], shimmer: [{ type: i0.Input, args: [{ isSignal: true, alias: "shimmer", required: false }] }], count: [{ type: i0.Input, args: [{ isSignal: true, alias: "count", required: false }] }], showDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "showDelay", required: false }] }], minDwell: [{ type: i0.Input, args: [{ isSignal: true, alias: "minDwell", required: false }] }], placeholderTpl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxSkeletonPlaceholder), { isSignal: true }] }] } });
|
|
190
188
|
|
|
191
189
|
/**
|
|
192
|
-
* @module
|
|
190
|
+
* @module `@cngx/ui/skeleton`
|
|
193
191
|
*/
|
|
194
192
|
|
|
195
193
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cngx-ui-skeleton.mjs","sources":["../../../projects/ui/skeleton/skeleton-placeholder.ts","../../../projects/ui/skeleton/skeleton-container.ts","../../../projects/ui/skeleton/public-api.ts","../../../projects/ui/skeleton/cngx-ui-skeleton.ts"],"sourcesContent":["import { Directive, inject, TemplateRef } from '@angular/core';\n\n/**\n * Structural slot directive that registers a `<ng-template>` as the\n * loading-state stand-in for `<cngx-skeleton>`. The container reads\n * it via `contentChild(CngxSkeletonPlaceholder)`; the directive\n * holds only the `TemplateRef` and contributes no DOM of its own.\n *\n * One-per-container contract: the container uses `contentChild`\n * (single), not `contentChildren`. Multiple sibling\n * `<ng-template cngxSkeletonPlaceholder>` blocks resolve to the\n * first match; the rest are dead code. Pick the variant at author\n * time, do not stack alternatives.\n *\n * Repetition: while the container's `loading()` (or\n * `state.isFirstLoad()`) is `true`, the template renders `[count]`\n * times inside the container's internal `@for`. When loading flips\n * to `false`, the skeleton DOM tears down and the projected sibling\n * content renders in its place.\n *\n * Context fields ({@link CngxSkeletonPlaceholderContext}):\n * - `$implicit` / `index` - 0-based iteration index. Drive per-row\n * width variance with it (`i === 0 ? '60%' : '100%'`).\n * - `count` - total placeholders being rendered, mirrors the\n * container's `[count]` input.\n * - `first` / `last` - row markers for end-of-block treatments\n * (e.g. last row without a trailing border).\n *\n * Bind via `let-i` for the implicit index, or `let-x=\"<field>\"`\n * for any other field:\n *\n * ```html\n * <cngx-skeleton [loading]=\"loading()\" [count]=\"3\">\n * <ng-template cngxSkeletonPlaceholder let-i>\n * <div class=\"skeleton-line\"\n * [style.width]=\"i === 0 ? '60%' : '100%'\"></div>\n * </ng-template>\n * <p>Real content</p>\n * </cngx-skeleton>\n * ```\n *\n * Last-row variant using `let-last`:\n *\n * ```html\n * <ng-template cngxSkeletonPlaceholder let-i let-last=\"last\">\n * <div class=\"skeleton-row\" [class.is-last]=\"last\"></div>\n * </ng-template>\n * ```\n *\n * @category ui/skeleton\n * @docsKind primary\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/skeleton/skeleton-placeholder.ts\n * @since 0.1.0\n * @relatedTo CngxSkeletonContainer\n */\n@Directive({\n selector: 'ng-template[cngxSkeletonPlaceholder]',\n standalone: true,\n})\nexport class CngxSkeletonPlaceholder {\n /** Reference to the projected template. Used internally by `CngxSkeletonContainer`. */\n readonly templateRef = inject<TemplateRef<CngxSkeletonPlaceholderContext>>(TemplateRef);\n}\n\n/**\n * Template context for `cngxSkeletonPlaceholder`.\n *\n * @category ui/skeleton\n */\nexport interface CngxSkeletonPlaceholderContext {\n /** Current index (0-based). */\n $implicit: number;\n /** Current index (named). */\n index: number;\n /** Total count. */\n count: number;\n /** Whether this is the first item. */\n first: boolean;\n /** Whether this is the last item. */\n last: boolean;\n}\n","import { DOCUMENT, NgTemplateOutlet } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n computed,\n contentChild,\n DestroyRef,\n inject,\n input,\n ViewEncapsulation,\n} from '@angular/core';\nimport {\n createMediaQuerySignal,\n createVisibilityGate,\n injectLoadingConfig,\n type CngxAsyncState,\n} from '@cngx/core/utils';\n\nimport {\n CngxSkeletonPlaceholder,\n type CngxSkeletonPlaceholderContext,\n} from './skeleton-placeholder';\n\n/**\n * Skeleton loading container with built-in placeholder repetition.\n *\n * Manages CSS classes, ARIA, and reduced-motion handling internally\n * (same behavior as the `CngxSkeleton` atom directive). Adds template projection\n * so the consumer doesn't need `@if`/`@for` boilerplate.\n *\n * - Project a `<ng-template cngxSkeletonPlaceholder>` for the loading state (repeated `count` times).\n * - Project content directly for the loaded state.\n * - Uses `display: contents` - no extra DOM wrapper.\n *\n * ### Basic usage\n * ```html\n * <cngx-skeleton [loading]=\"loading()\" [count]=\"3\">\n * <ng-template cngxSkeletonPlaceholder>\n * <div class=\"skeleton-card\"></div>\n * </ng-template>\n * <app-real-content />\n * </cngx-skeleton>\n * ```\n *\n * ### With template context (index, first, last)\n * ```html\n * <cngx-skeleton [loading]=\"loading()\" [count]=\"5\">\n * <ng-template cngxSkeletonPlaceholder let-i let-last=\"last\">\n * <div class=\"skeleton-line\" [style.width]=\"last ? '60%' : '100%'\"></div>\n * </ng-template>\n * <p>Loaded content here</p>\n * </cngx-skeleton>\n * ```\n *\n * @category ui/skeleton\n * @docsKind primary\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/skeleton/skeleton-container.ts\n * @since 0.1.0\n * @relatedTo CngxSkeletonPlaceholder, CngxAsyncState, CngxEmptyState\n * @slot cngxSkeletonPlaceholder Replaces the generated placeholder shape.\n * <example-url>http://localhost:4200/#/common/layout/skeleton/basic-skeleton</example-url>\n * <example-url>http://localhost:4200/#/common/layout/skeleton/skeleton-container</example-url>\n * <example-url>http://localhost:4200/#/ui/skeleton/card-skeleton</example-url>\n * <example-url>http://localhost:4200/#/ui/skeleton/template-context</example-url>\n */\n@Component({\n selector: 'cngx-skeleton',\n standalone: true,\n imports: [NgTemplateOutlet],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n exportAs: 'cngxSkeletonContainer',\n host: {\n style: 'display: contents',\n class: 'cngx-skeleton',\n '[class.cngx-skeleton--loading]': 'gatedLoading()',\n '[class.cngx-skeleton--shimmer]': 'showShimmer()',\n '[attr.aria-busy]': 'gatedLoading() || null',\n },\n template: `\n @if (gatedLoading()) {\n @for (i of indices(); track i) {\n <ng-container\n *ngTemplateOutlet=\"placeholderTpl()?.templateRef ?? null; context: getContext(i)\"\n />\n }\n } @else {\n <ng-content />\n }\n `,\n styleUrls: ['./skeleton-container.css'],\n})\nexport class CngxSkeletonContainer {\n private readonly loadingConfig = injectLoadingConfig();\n\n /** Controls the loading state directly. */\n readonly loading = input<boolean>(false);\n\n /** Bind an async state - shows skeleton during first load. Takes precedence over `loading`. */\n readonly state = input<CngxAsyncState<unknown> | undefined>(undefined);\n\n /** Enables the `.cngx-skeleton--shimmer` class (respects `prefers-reduced-motion`). */\n readonly shimmer = input<boolean>(true);\n\n /** Repeat count for the placeholder template. */\n readonly count = input<number>(1);\n\n /** Delay in ms before the placeholder shows. Defaults to `CNGX_LOADING_CONFIG.showDelay`. */\n readonly showDelay = input<number>(this.loadingConfig.showDelay);\n\n /** Minimum time in ms the placeholder stays once shown. Defaults to `CNGX_LOADING_CONFIG.minDwell`. */\n readonly minDwell = input<number>(this.loadingConfig.minDwell);\n\n /** Derived loading state: `state.isFirstLoad` takes precedence over `loading` input. */\n protected readonly isLoading = computed(() => this.state()?.isFirstLoad() ?? this.loading());\n\n /**\n * @internal - flash-suppressed loading. A sub-`showDelay` blip never renders the\n * placeholder; once shown it holds for `minDwell`. Drives the placeholder, the\n * `--loading` class, and `aria-busy` so AT and DOM agree.\n */\n protected readonly gatedLoading = createVisibilityGate(\n this.isLoading,\n this.showDelay,\n this.minDwell,\n );\n\n /** @internal - projected placeholder template. */\n protected readonly placeholderTpl = contentChild(CngxSkeletonPlaceholder);\n\n /** Array of indices for internal `@for` rendering. */\n readonly indices = computed(() => Array.from({ length: this.count() }, (_, i) => i));\n\n private readonly prefersReducedMotion = createMediaQuerySignal(\n '(prefers-reduced-motion: reduce)',\n inject(DestroyRef),\n inject(DOCUMENT).defaultView,\n );\n\n /** @internal */\n protected readonly showShimmer = computed(\n () => this.gatedLoading() && this.shimmer() && !this.prefersReducedMotion(),\n );\n\n /** @internal */\n protected getContext(index: number): CngxSkeletonPlaceholderContext {\n const total = this.count();\n return {\n $implicit: index,\n index,\n count: total,\n first: index === 0,\n last: index === total - 1,\n };\n }\n}\n","/**\n * @module @cngx/ui/skeleton\n */\n\nexport { CngxSkeletonContainer } from './skeleton-container';\nexport {\n CngxSkeletonPlaceholder,\n type CngxSkeletonPlaceholderContext,\n} from './skeleton-placeholder';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;AAUT,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,MAAA,EAAA,CAAA,2lDAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EArBS,gBAAgB,EAAA,QAAA,EAAA,oBAAA,EAAA,MAAA,EAAA,CAAA,yBAAA,EAAA,kBAAA,EAAA,0BAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA;;2FAwBf,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBA3BjC,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,eAAe,cACb,IAAI,EAAA,OAAA,EACP,CAAC,gBAAgB,CAAC,EAAA,eAAA,EACV,uBAAuB,CAAC,MAAM,iBAChC,iBAAiB,CAAC,IAAI,EAAA,QAAA,EAC3B,uBAAuB,EAAA,IAAA,EAC3B;AACJ,wBAAA,KAAK,EAAE,mBAAmB;AAC1B,wBAAA,KAAK,EAAE,eAAe;AACtB,wBAAA,gCAAgC,EAAE,gBAAgB;AAClD,wBAAA,gCAAgC,EAAE,eAAe;AACjD,wBAAA,kBAAkB,EAAE,wBAAwB;qBAC7C,EAAA,QAAA,EACS;;;;;;;;;;AAUT,EAAA,CAAA,EAAA,MAAA,EAAA,CAAA,2lDAAA,CAAA,EAAA;qpBAuCgD,uBAAuB,CAAA,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;ACjI1E;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"cngx-ui-skeleton.mjs","sources":["../../../projects/ui/skeleton/skeleton-placeholder.ts","../../../projects/ui/skeleton/skeleton-container.ts","../../../projects/ui/skeleton/public-api.ts","../../../projects/ui/skeleton/cngx-ui-skeleton.ts"],"sourcesContent":["import { Directive, inject, TemplateRef } from '@angular/core';\n\n/**\n * Structural slot directive that registers a `<ng-template>` as the\n * loading-state stand-in for `<cngx-skeleton>`. The container reads\n * it via `contentChild(CngxSkeletonPlaceholder)`; the directive\n * holds only the `TemplateRef` and contributes no DOM of its own.\n *\n * One-per-container contract: the container uses `contentChild`\n * (single), not `contentChildren`. Multiple sibling\n * `<ng-template cngxSkeletonPlaceholder>` blocks resolve to the\n * first match; the rest are dead code. Pick the variant at author\n * time, do not stack alternatives.\n *\n * Repetition: while the container's `loading()` (or\n * `state.isFirstLoad()`) is `true`, the template renders `[count]`\n * times inside the container's internal `@for`. When loading flips\n * to `false`, the skeleton DOM tears down and the projected sibling\n * content renders in its place.\n *\n * Context fields ({@link CngxSkeletonPlaceholderContext}):\n * - `$implicit` / `index` - 0-based iteration index. Drive per-row\n * width variance with it (`i === 0 ? '60%' : '100%'`).\n * - `count` - total placeholders being rendered, mirrors the\n * container's `[count]` input.\n * - `first` / `last` - row markers for end-of-block treatments\n * (e.g. last row without a trailing border).\n *\n * Bind via `let-i` for the implicit index, or `let-x=\"<field>\"`\n * for any other field:\n *\n * ```html\n * <cngx-skeleton [loading]=\"loading()\" [count]=\"3\">\n * <ng-template cngxSkeletonPlaceholder let-i>\n * <div class=\"skeleton-line\"\n * [style.width]=\"i === 0 ? '60%' : '100%'\"></div>\n * </ng-template>\n * <p>Real content</p>\n * </cngx-skeleton>\n * ```\n *\n * Last-row variant using `let-last`:\n *\n * ```html\n * <ng-template cngxSkeletonPlaceholder let-i let-last=\"last\">\n * <div class=\"skeleton-row\" [class.is-last]=\"last\"></div>\n * </ng-template>\n * ```\n *\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/skeleton/skeleton-placeholder.ts\n * @since 0.3.0\n * @relatedTo CngxSkeletonContainer\n */\n@Directive({\n selector: 'ng-template[cngxSkeletonPlaceholder]',\n standalone: true,\n})\nexport class CngxSkeletonPlaceholder {\n /** Reference to the projected template. Used internally by `CngxSkeletonContainer`. */\n readonly templateRef = inject<TemplateRef<CngxSkeletonPlaceholderContext>>(TemplateRef);\n}\n\n/**\n * Template context for `cngxSkeletonPlaceholder`.\n */\nexport interface CngxSkeletonPlaceholderContext {\n /** Current index (0-based). */\n $implicit: number;\n /** Current index (named). */\n index: number;\n /** Total count. */\n count: number;\n /** Whether this is the first item. */\n first: boolean;\n /** Whether this is the last item. */\n last: boolean;\n}\n","import { NgTemplateOutlet } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n computed,\n contentChild,\n input,\n ViewEncapsulation,\n} from '@angular/core';\nimport { injectEffectiveMotion } from '@cngx/core';\nimport { createVisibilityGate, injectLoadingConfig, type CngxAsyncState } from '@cngx/core/utils';\n\nimport {\n CngxSkeletonPlaceholder,\n type CngxSkeletonPlaceholderContext,\n} from './skeleton-placeholder';\n\n/**\n * Skeleton loading container with built-in placeholder repetition.\n *\n * Manages CSS classes, ARIA, and reduced-motion handling internally\n * (same behavior as the `CngxSkeleton` atom directive). Adds template projection\n * so the consumer doesn't need `@if`/`@for` boilerplate.\n *\n * - Project a `<ng-template cngxSkeletonPlaceholder>` for the loading state (repeated `count` times).\n * - Project content directly for the loaded state.\n * - Uses `display: contents` - no extra DOM wrapper.\n *\n * ### Basic usage\n * ```html\n * <cngx-skeleton [loading]=\"loading()\" [count]=\"3\">\n * <ng-template cngxSkeletonPlaceholder>\n * <div class=\"skeleton-card\"></div>\n * </ng-template>\n * <app-real-content />\n * </cngx-skeleton>\n * ```\n *\n * ### With template context (index, first, last)\n * ```html\n * <cngx-skeleton [loading]=\"loading()\" [count]=\"5\">\n * <ng-template cngxSkeletonPlaceholder let-i let-last=\"last\">\n * <div class=\"skeleton-line\" [style.width]=\"last ? '60%' : '100%'\"></div>\n * </ng-template>\n * <p>Loaded content here</p>\n * </cngx-skeleton>\n * ```\n *\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/skeleton/skeleton-container.ts\n * @since 0.3.0\n * @relatedTo CngxSkeletonPlaceholder, CngxAsyncState, CngxEmptyState\n * @slot cngxSkeletonPlaceholder Replaces the generated placeholder shape.\n * <example-url>/#/ui/skeleton/skeleton-container</example-url>\n * <example-url>/#/ui/skeleton/card-skeleton</example-url>\n * <example-url>/#/ui/skeleton/template-context</example-url>\n * @axis level molecule\n */\n@Component({\n selector: 'cngx-skeleton',\n standalone: true,\n imports: [NgTemplateOutlet],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n exportAs: 'cngxSkeletonContainer',\n host: {\n style: 'display: contents',\n class: 'cngx-skeleton',\n '[class.cngx-skeleton--loading]': 'gatedLoading()',\n '[class.cngx-skeleton--shimmer]': 'showShimmer()',\n '[attr.aria-busy]': 'gatedLoading() || null',\n '[attr.data-cngx-busy]': 'gatedLoading() || null',\n },\n template: `\n @if (gatedLoading()) {\n @for (i of indices(); track i) {\n <ng-container\n *ngTemplateOutlet=\"placeholderTpl()?.templateRef ?? null; context: getContext(i)\"\n />\n }\n } @else {\n <ng-content />\n }\n `,\n styleUrls: ['./skeleton-container.css'],\n})\nexport class CngxSkeletonContainer {\n private readonly loadingConfig = injectLoadingConfig();\n\n /** Controls the loading state directly. */\n readonly loading = input<boolean>(false);\n\n /** Bind an async state - shows skeleton during first load. Takes precedence over `loading`. */\n readonly state = input<CngxAsyncState<unknown> | undefined>(undefined);\n\n /** Enables the `.cngx-skeleton--shimmer` class (respects `prefers-reduced-motion`). */\n readonly shimmer = input<boolean>(true);\n\n /** Repeat count for the placeholder template. */\n readonly count = input<number>(1);\n\n /** Delay in ms before the placeholder shows. Defaults to `CNGX_LOADING_CONFIG.showDelay`. */\n readonly showDelay = input<number>(this.loadingConfig.showDelay);\n\n /** Minimum time in ms the placeholder stays once shown. Defaults to `CNGX_LOADING_CONFIG.minDwell`. */\n readonly minDwell = input<number>(this.loadingConfig.minDwell);\n\n /** Derived loading state: `state.isFirstLoad` takes precedence over `loading` input. */\n protected readonly isLoading = computed(() => this.state()?.isFirstLoad() ?? this.loading());\n\n /**\n * @internal - flash-suppressed loading. A sub-`showDelay` blip never renders the\n * placeholder; once shown it holds for `minDwell`. Drives the placeholder, the\n * `--loading` class, and `aria-busy` so AT and DOM agree.\n */\n protected readonly gatedLoading = createVisibilityGate(\n this.isLoading,\n this.showDelay,\n this.minDwell,\n );\n\n /** @internal - projected placeholder template. */\n protected readonly placeholderTpl = contentChild(CngxSkeletonPlaceholder);\n\n /** Array of indices for internal `@for` rendering. */\n readonly indices = computed(() => Array.from({ length: this.count() }, (_, i) => i));\n\n private readonly motion = injectEffectiveMotion();\n\n /** @internal */\n protected readonly showShimmer = computed(\n () => this.gatedLoading() && this.shimmer() && this.motion() !== 'reduced',\n );\n\n /** @internal */\n protected getContext(index: number): CngxSkeletonPlaceholderContext {\n const total = this.count();\n return {\n $implicit: index,\n index,\n count: total,\n first: index === 0,\n last: index === total - 1,\n };\n }\n}\n","/**\n * @module `@cngx/ui/skeleton`\n */\n\nexport { CngxSkeletonContainer } from './skeleton-container';\nexport {\n CngxSkeletonPlaceholder,\n type CngxSkeletonPlaceholderContext,\n} from './skeleton-placeholder';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDG;MAKU,uBAAuB,CAAA;;AAEzB,IAAA,WAAW,GAAG,MAAM,CAA8C,WAAW,CAAC;uGAF5E,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAvB,uBAAuB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,sCAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAvB,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBAJnC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,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A,EAAA,eAAe,cACb,IAAI,EAAA,OAAA,EACP,CAAC,gBAAgB,CAAC,EAAA,eAAA,EACV,uBAAuB,CAAC,MAAM,iBAChC,iBAAiB,CAAC,IAAI,EAAA,QAAA,EAC3B,uBAAuB,EAAA,IAAA,EAC3B;AACJ,wBAAA,KAAK,EAAE,mBAAmB;AAC1B,wBAAA,KAAK,EAAE,eAAe;AACtB,wBAAA,gCAAgC,EAAE,gBAAgB;AAClD,wBAAA,gCAAgC,EAAE,eAAe;AACjD,wBAAA,kBAAkB,EAAE,wBAAwB;AAC5C,wBAAA,uBAAuB,EAAE,wBAAwB;qBAClD,EAAA,QAAA,EACS;;;;;;;;;;AAUT,EAAA,CAAA,EAAA,MAAA,EAAA,CAAA,6lDAAA,CAAA,EAAA;qpBAuCgD,uBAAuB,CAAA,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AC1H1E;;AAEG;;ACFH;;AAEG;;;;"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, inject, input, computed, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { CngxIconSvg } from '@cngx/common/display';
|
|
4
|
+
import { CNGX_ICON_STOP, CNGX_ICON_VOLUME } from '@cngx/utils';
|
|
3
5
|
import { createLanguageSection } from '@cngx/core/i18n';
|
|
4
6
|
import { createFilledOverrideMerge } from '@cngx/core/utils';
|
|
5
7
|
|
|
@@ -7,8 +9,7 @@ import { createFilledOverrideMerge } from '@cngx/core/utils';
|
|
|
7
9
|
* The English speak section: the single source of the speak button's English
|
|
8
10
|
* copy. `CNGX_SPEAK_I18N` defaults to it.
|
|
9
11
|
*
|
|
10
|
-
* @
|
|
11
|
-
* @since 0.1.0
|
|
12
|
+
* @since 0.3.0
|
|
12
13
|
* @relatedTo CNGX_SPEAK_I18N
|
|
13
14
|
*/
|
|
14
15
|
const CNGX_SPEAK_LANGUAGE_EN = {
|
|
@@ -23,31 +24,25 @@ const speakBundleFromPack = createLanguageSection('speak', CNGX_SPEAK_LANGUAGE_E
|
|
|
23
24
|
* section of the active language pack over the English defaults. The value is
|
|
24
25
|
* a `Signal`, shared by every reader under one injector.
|
|
25
26
|
*
|
|
26
|
-
* @category ui/speak/i18n
|
|
27
27
|
* @wcag AA
|
|
28
28
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/speak/speak-i18n.ts
|
|
29
|
-
* @since 0.
|
|
29
|
+
* @since 0.3.0
|
|
30
30
|
* @relatedTo CngxSpeakButton
|
|
31
31
|
*/
|
|
32
32
|
const CNGX_SPEAK_I18N = new InjectionToken('CngxSpeakI18n', {
|
|
33
33
|
providedIn: 'root',
|
|
34
34
|
factory: speakBundleFromPack,
|
|
35
35
|
});
|
|
36
|
-
/** @internal */
|
|
37
|
-
function defineSpeakI18nFeature(fn) {
|
|
38
|
-
return Object.assign(fn, { _target: 'i18n' });
|
|
39
|
-
}
|
|
40
36
|
/**
|
|
41
37
|
* Override i18n labels via a partial bundle - unset keys, and keys set to
|
|
42
38
|
* `null` or `undefined`, keep the language pack's copy, or the English
|
|
43
39
|
* default, so the button never loses its accessible name. Pass a `Signal` of a
|
|
44
40
|
* partial bundle to switch languages at runtime.
|
|
45
41
|
*
|
|
46
|
-
* @
|
|
47
|
-
* @since 0.1.0
|
|
42
|
+
* @since 0.3.0
|
|
48
43
|
*/
|
|
49
44
|
function withSpeakI18nLabels(overrides) {
|
|
50
|
-
return
|
|
45
|
+
return (bundle) => createFilledOverrideMerge(bundle, overrides);
|
|
51
46
|
}
|
|
52
47
|
/**
|
|
53
48
|
* Provider for the speak i18n bundle. Returns a plain `Provider`, so it also
|
|
@@ -61,8 +56,7 @@ function withSpeakI18nLabels(overrides) {
|
|
|
61
56
|
* });
|
|
62
57
|
* ```
|
|
63
58
|
*
|
|
64
|
-
* @
|
|
65
|
-
* @since 0.1.0
|
|
59
|
+
* @since 0.3.0
|
|
66
60
|
*/
|
|
67
61
|
function provideSpeakI18n(...features) {
|
|
68
62
|
return {
|
|
@@ -73,8 +67,7 @@ function provideSpeakI18n(...features) {
|
|
|
73
67
|
/**
|
|
74
68
|
* Inject the resolved speak i18n bundle signal.
|
|
75
69
|
*
|
|
76
|
-
* @
|
|
77
|
-
* @since 0.1.0
|
|
70
|
+
* @since 0.3.0
|
|
78
71
|
*/
|
|
79
72
|
function injectSpeakI18n() {
|
|
80
73
|
return inject(CNGX_SPEAK_I18N);
|
|
@@ -100,13 +93,13 @@ function injectSpeakI18n() {
|
|
|
100
93
|
* @include speak.theme($theme);
|
|
101
94
|
* ```
|
|
102
95
|
*
|
|
103
|
-
* @category ui/speak
|
|
104
|
-
* @docsKind primary
|
|
105
96
|
* @wcag AAA
|
|
106
97
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/speak/speak-button.ts
|
|
107
|
-
* @since 0.
|
|
98
|
+
* @since 0.3.0
|
|
108
99
|
* @relatedTo CngxSpeak
|
|
109
|
-
* <example-url
|
|
100
|
+
* <example-url>/#/ui/speak/speak-button/styled-speaker-icon</example-url>
|
|
101
|
+
* <example-url>/#/ui/speak/speak-button/card-with-speak-badge</example-url>
|
|
102
|
+
* @axis level molecule
|
|
110
103
|
*/
|
|
111
104
|
class CngxSpeakButton {
|
|
112
105
|
i18n = injectSpeakI18n();
|
|
@@ -122,49 +115,27 @@ class CngxSpeakButton {
|
|
|
122
115
|
* interrupt playback. Unbound, `CNGX_SPEAK_I18N.stopSpeaking` applies.
|
|
123
116
|
*/
|
|
124
117
|
stopLabel = input(undefined, ...(ngDevMode ? [{ debugName: "stopLabel" }] : /* istanbul ignore next */ []));
|
|
118
|
+
/** @internal - speaker while idle, stop square while speaking. */
|
|
119
|
+
icon = computed(() => this.speakRef().speaking() ? CNGX_ICON_STOP : CNGX_ICON_VOLUME, ...(ngDevMode ? [{ debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
125
120
|
/** @internal - the label for the current playback state. */
|
|
126
121
|
resolvedLabel = computed(() => this.speakRef().speaking()
|
|
127
122
|
? (this.stopLabel() ?? this.i18n().stopSpeaking)
|
|
128
123
|
: (this.readAloudLabel() ?? this.i18n().readAloud), ...(ngDevMode ? [{ debugName: "resolvedLabel" }] : /* istanbul ignore next */ []));
|
|
129
124
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSpeakButton, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
130
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.
|
|
125
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxSpeakButton, isStandalone: true, selector: "cngx-speak-button", inputs: { speakRef: { classPropertyName: "speakRef", publicName: "speakRef", isSignal: true, isRequired: true, transformFunction: null }, readAloudLabel: { classPropertyName: "readAloudLabel", publicName: "readAloudLabel", isSignal: true, isRequired: false, transformFunction: null }, stopLabel: { classPropertyName: "stopLabel", publicName: "stopLabel", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cngx-speak-button--speaking": "speakRef().speaking()", "hidden": "!speakRef().supported" }, classAttribute: "cngx-speak-button" }, ngImport: i0, template: `
|
|
131
126
|
<button
|
|
132
127
|
type="button"
|
|
133
128
|
class="cngx-speak-button__btn"
|
|
134
129
|
[attr.aria-label]="resolvedLabel()"
|
|
135
130
|
(click)="speakRef().toggle()"
|
|
136
131
|
>
|
|
137
|
-
|
|
138
|
-
<svg
|
|
139
|
-
class="cngx-speak-button__icon"
|
|
140
|
-
viewBox="0 0 24 24"
|
|
141
|
-
fill="currentColor"
|
|
142
|
-
aria-hidden="true"
|
|
143
|
-
>
|
|
144
|
-
<rect x="6" y="6" width="12" height="12" rx="2" />
|
|
145
|
-
</svg>
|
|
146
|
-
} @else {
|
|
147
|
-
<svg
|
|
148
|
-
class="cngx-speak-button__icon"
|
|
149
|
-
viewBox="0 0 24 24"
|
|
150
|
-
fill="none"
|
|
151
|
-
stroke="currentColor"
|
|
152
|
-
stroke-width="2"
|
|
153
|
-
stroke-linecap="round"
|
|
154
|
-
stroke-linejoin="round"
|
|
155
|
-
aria-hidden="true"
|
|
156
|
-
>
|
|
157
|
-
<path d="M11 5L6 9H2v6h4l5 4V5z" />
|
|
158
|
-
<path d="M15.54 8.46a5 5 0 010 7.07" />
|
|
159
|
-
<path d="M19.07 4.93a10 10 0 010 14.14" />
|
|
160
|
-
</svg>
|
|
161
|
-
}
|
|
132
|
+
<svg class="cngx-speak-button__icon" [cngxIconSvg]="icon()"></svg>
|
|
162
133
|
</button>
|
|
163
|
-
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-speak-btn-size{syntax: \"<length>\"; inherits: false; initial-value: 36px;}@property --cngx-speak-btn-icon-size{syntax: \"<length>\"; inherits: false; initial-value:
|
|
134
|
+
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-speak-btn-size{syntax: \"<length>\"; inherits: false; initial-value: 36px;}@property --cngx-speak-btn-icon-size{syntax: \"<length>\"; inherits: false; initial-value: 16px;}@property --cngx-speak-btn-radius{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-speak-btn-border-width{syntax: \"<length>\"; inherits: false; initial-value: 1px;}@property --cngx-speak-btn-bg{syntax: \"<color>\"; inherits: false; initial-value: oklch(1 0 0);}@property --cngx-speak-btn-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.45 0 0);}@property --cngx-speak-btn-transition{syntax: \"<time>\"; inherits: false; initial-value: .15s;}:where(.cngx-speak-button){--cngx-speak-btn-transition: var(--cngx-duration-fast)}@property --cngx-speak-btn-active-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.72 .18 70);}@property --cngx-speak-btn-hover-bg{syntax: \"<color>\"; inherits: false; initial-value: oklch(1 0 0);}@property --cngx-speak-btn-speaking-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(1 0 0);}@property --cngx-speak-btn-speaking-bg{syntax: \"<color>\"; inherits: false; initial-value: oklch(.72 .18 70);}:where(.cngx-speak-button__btn){--cngx-speak-btn-bg: var(--cngx-color-surface);--cngx-speak-btn-hover-bg: var(--cngx-speak-btn-bg);--cngx-speak-btn-speaking-bg: var(--cngx-speak-btn-active-color)}}@layer cngx.components{@scope(.cngx-speak-button){:scope{display:inline-flex}.cngx-speak-button__btn{display:inline-flex;align-items:center;justify-content:center;width:max(var(--cngx-speak-btn-size, 36px),var(--cngx-target-min, 0px));height:max(var(--cngx-speak-btn-size, 36px),var(--cngx-target-min, 0px));padding:0;border:var(--cngx-speak-btn-border-width, 1px) solid var(--cngx-color-border, oklch(.87 0 0));border-radius:var(--cngx-speak-btn-radius, 8px);background:var(--cngx-speak-btn-bg);color:var(--cngx-speak-btn-color, oklch(.45 0 0));cursor:pointer;transition:color var(--cngx-speak-btn-transition, .15s),background var(--cngx-speak-btn-transition, .15s),border-color var(--cngx-speak-btn-transition, .15s);flex-shrink:0}.cngx-speak-button__btn:hover{color:var(--cngx-speak-btn-active-color, oklch(.72 .18 70));border-color:var(--cngx-speak-btn-active-color, oklch(.72 .18 70));background:var(--cngx-speak-btn-hover-bg)}:scope.cngx-speak-button--speaking .cngx-speak-button__btn{color:var(--cngx-speak-btn-speaking-color, oklch(1 0 0));background:var(--cngx-speak-btn-speaking-bg);border-color:var(--cngx-speak-btn-speaking-bg)}.cngx-speak-button__icon{--cngx-icon-svg-size: var(--cngx-speak-btn-icon-size, 16px);transform:translate(1px)}}}\n"], dependencies: [{ kind: "component", type: CngxIconSvg, selector: "svg[cngxIconSvg]", inputs: ["cngxIconSvg"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
164
135
|
}
|
|
165
136
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSpeakButton, decorators: [{
|
|
166
137
|
type: Component,
|
|
167
|
-
args: [{ selector: 'cngx-speak-button', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
|
|
138
|
+
args: [{ selector: 'cngx-speak-button', standalone: true, imports: [CngxIconSvg], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
|
|
168
139
|
class: 'cngx-speak-button',
|
|
169
140
|
'[class.cngx-speak-button--speaking]': 'speakRef().speaking()',
|
|
170
141
|
// Speech synthesis is a hard capability - with no engine the button can
|
|
@@ -179,37 +150,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
179
150
|
[attr.aria-label]="resolvedLabel()"
|
|
180
151
|
(click)="speakRef().toggle()"
|
|
181
152
|
>
|
|
182
|
-
|
|
183
|
-
<svg
|
|
184
|
-
class="cngx-speak-button__icon"
|
|
185
|
-
viewBox="0 0 24 24"
|
|
186
|
-
fill="currentColor"
|
|
187
|
-
aria-hidden="true"
|
|
188
|
-
>
|
|
189
|
-
<rect x="6" y="6" width="12" height="12" rx="2" />
|
|
190
|
-
</svg>
|
|
191
|
-
} @else {
|
|
192
|
-
<svg
|
|
193
|
-
class="cngx-speak-button__icon"
|
|
194
|
-
viewBox="0 0 24 24"
|
|
195
|
-
fill="none"
|
|
196
|
-
stroke="currentColor"
|
|
197
|
-
stroke-width="2"
|
|
198
|
-
stroke-linecap="round"
|
|
199
|
-
stroke-linejoin="round"
|
|
200
|
-
aria-hidden="true"
|
|
201
|
-
>
|
|
202
|
-
<path d="M11 5L6 9H2v6h4l5 4V5z" />
|
|
203
|
-
<path d="M15.54 8.46a5 5 0 010 7.07" />
|
|
204
|
-
<path d="M19.07 4.93a10 10 0 010 14.14" />
|
|
205
|
-
</svg>
|
|
206
|
-
}
|
|
153
|
+
<svg class="cngx-speak-button__icon" [cngxIconSvg]="icon()"></svg>
|
|
207
154
|
</button>
|
|
208
|
-
`, styles: ["@layer cngx.tokens{@property --cngx-speak-btn-size{syntax: \"<length>\"; inherits: false; initial-value: 36px;}@property --cngx-speak-btn-icon-size{syntax: \"<length>\"; inherits: false; initial-value:
|
|
155
|
+
`, styles: ["@layer cngx.tokens{@property --cngx-speak-btn-size{syntax: \"<length>\"; inherits: false; initial-value: 36px;}@property --cngx-speak-btn-icon-size{syntax: \"<length>\"; inherits: false; initial-value: 16px;}@property --cngx-speak-btn-radius{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-speak-btn-border-width{syntax: \"<length>\"; inherits: false; initial-value: 1px;}@property --cngx-speak-btn-bg{syntax: \"<color>\"; inherits: false; initial-value: oklch(1 0 0);}@property --cngx-speak-btn-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.45 0 0);}@property --cngx-speak-btn-transition{syntax: \"<time>\"; inherits: false; initial-value: .15s;}:where(.cngx-speak-button){--cngx-speak-btn-transition: var(--cngx-duration-fast)}@property --cngx-speak-btn-active-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.72 .18 70);}@property --cngx-speak-btn-hover-bg{syntax: \"<color>\"; inherits: false; initial-value: oklch(1 0 0);}@property --cngx-speak-btn-speaking-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(1 0 0);}@property --cngx-speak-btn-speaking-bg{syntax: \"<color>\"; inherits: false; initial-value: oklch(.72 .18 70);}:where(.cngx-speak-button__btn){--cngx-speak-btn-bg: var(--cngx-color-surface);--cngx-speak-btn-hover-bg: var(--cngx-speak-btn-bg);--cngx-speak-btn-speaking-bg: var(--cngx-speak-btn-active-color)}}@layer cngx.components{@scope(.cngx-speak-button){:scope{display:inline-flex}.cngx-speak-button__btn{display:inline-flex;align-items:center;justify-content:center;width:max(var(--cngx-speak-btn-size, 36px),var(--cngx-target-min, 0px));height:max(var(--cngx-speak-btn-size, 36px),var(--cngx-target-min, 0px));padding:0;border:var(--cngx-speak-btn-border-width, 1px) solid var(--cngx-color-border, oklch(.87 0 0));border-radius:var(--cngx-speak-btn-radius, 8px);background:var(--cngx-speak-btn-bg);color:var(--cngx-speak-btn-color, oklch(.45 0 0));cursor:pointer;transition:color var(--cngx-speak-btn-transition, .15s),background var(--cngx-speak-btn-transition, .15s),border-color var(--cngx-speak-btn-transition, .15s);flex-shrink:0}.cngx-speak-button__btn:hover{color:var(--cngx-speak-btn-active-color, oklch(.72 .18 70));border-color:var(--cngx-speak-btn-active-color, oklch(.72 .18 70));background:var(--cngx-speak-btn-hover-bg)}:scope.cngx-speak-button--speaking .cngx-speak-button__btn{color:var(--cngx-speak-btn-speaking-color, oklch(1 0 0));background:var(--cngx-speak-btn-speaking-bg);border-color:var(--cngx-speak-btn-speaking-bg)}.cngx-speak-button__icon{--cngx-icon-svg-size: var(--cngx-speak-btn-icon-size, 16px);transform:translate(1px)}}}\n"] }]
|
|
209
156
|
}], propDecorators: { speakRef: [{ type: i0.Input, args: [{ isSignal: true, alias: "speakRef", required: true }] }], readAloudLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "readAloudLabel", required: false }] }], stopLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "stopLabel", required: false }] }] } });
|
|
210
157
|
|
|
211
158
|
/**
|
|
212
|
-
* @module
|
|
159
|
+
* @module `@cngx/ui/speak`
|
|
213
160
|
*/
|
|
214
161
|
|
|
215
162
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cngx-ui-speak.mjs","sources":["../../../projects/ui/speak/i18n/speak-language-section.ts","../../../projects/ui/speak/speak-i18n.ts","../../../projects/ui/speak/speak-button.ts","../../../projects/ui/speak/public-api.ts","../../../projects/ui/speak/cngx-ui-speak.ts"],"sourcesContent":["/**\n * The speak section of a {@link CngxLanguagePack}: the accessible names of\n * `CngxSpeakButton`. It feeds `CNGX_SPEAK_I18N`; a key set through\n * `withSpeakI18nLabels` still wins.\n *\n * @category ui/speak/i18n\n * @since 0.1.0\n * @relatedTo CNGX_SPEAK_I18N, withSpeakI18nLabels\n */\nexport interface CngxSpeakLanguageSection {\n /** Accessible name of the speak button while idle. */\n readonly readAloud: string;\n /** Accessible name of the speak button while speaking. */\n readonly stopSpeaking: string;\n}\n\n/**\n * The English speak section: the single source of the speak button's English\n * copy. `CNGX_SPEAK_I18N` defaults to it.\n *\n * @category ui/speak/i18n\n * @since 0.1.0\n * @relatedTo CNGX_SPEAK_I18N\n */\nexport const CNGX_SPEAK_LANGUAGE_EN: CngxSpeakLanguageSection = {\n readAloud: 'Read aloud',\n stopSpeaking: 'Stop speaking',\n};\n\ndeclare module '@cngx/core/i18n' {\n interface CngxLanguagePack {\n readonly speak: CngxSpeakLanguageSection;\n }\n}\n","import { inject, InjectionToken, type Provider, type Signal } from '@angular/core';\nimport { createLanguageSection } from '@cngx/core/i18n';\nimport { createFilledOverrideMerge } from '@cngx/core/utils';\n\nimport {\n CNGX_SPEAK_LANGUAGE_EN,\n type CngxSpeakLanguageSection,\n} from './i18n/speak-language-section';\n\n/**\n * Speak i18n surface: the `speak` section of the language pack (English\n * without one); override single keys via {@link provideSpeakI18n}. Reactive\n * from birth: the token carries a `Signal`, and {@link withSpeakI18nLabels}\n * accepts a `Signal` of a partial bundle.\n *\n * `CngxSpeakButton` reads both keys inside a `computed()` while its\n * `readAloudLabel` / `stopLabel` inputs are unbound, so the label follows a\n * language switch.\n *\n * @category ui/speak/i18n\n */\nexport type CngxSpeakI18n = CngxSpeakLanguageSection;\n\n/** The English speak section with the active pack's speak section on top, shared app-wide. */\nconst speakBundleFromPack = createLanguageSection('speak', CNGX_SPEAK_LANGUAGE_EN);\n\n/**\n * DI token for the speak i18n bundle. `providedIn: 'root'`: the `speak`\n * section of the active language pack over the English defaults. The value is\n * a `Signal`, shared by every reader under one injector.\n *\n * @category ui/speak/i18n\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/speak/speak-i18n.ts\n * @since 0.1.0\n * @relatedTo CngxSpeakButton\n */\nexport const CNGX_SPEAK_I18N = new InjectionToken<Signal<CngxSpeakI18n>>('CngxSpeakI18n', {\n providedIn: 'root',\n factory: speakBundleFromPack,\n});\n\n/**\n * Branded feature-fn for {@link provideSpeakI18n}.\n *\n * @category ui/speak/i18n\n * @since 0.1.0\n */\nexport type CngxSpeakI18nFeature = ((bundle: Signal<CngxSpeakI18n>) => Signal<CngxSpeakI18n>) & {\n readonly _target: 'i18n';\n};\n\n/** @internal */\nfunction defineSpeakI18nFeature(\n fn: (bundle: Signal<CngxSpeakI18n>) => Signal<CngxSpeakI18n>,\n): CngxSpeakI18nFeature {\n return Object.assign(fn, { _target: 'i18n' as const });\n}\n\n/**\n * Override i18n labels via a partial bundle - unset keys, and keys set to\n * `null` or `undefined`, keep the language pack's copy, or the English\n * default, so the button never loses its accessible name. Pass a `Signal` of a\n * partial bundle to switch languages at runtime.\n *\n * @category ui/speak/i18n\n * @since 0.1.0\n */\nexport function withSpeakI18nLabels(\n overrides: Partial<CngxSpeakI18n> | Signal<Partial<CngxSpeakI18n>>,\n): CngxSpeakI18nFeature {\n return defineSpeakI18nFeature((bundle) => createFilledOverrideMerge(bundle, overrides));\n}\n\n/**\n * Provider for the speak i18n bundle. Returns a plain `Provider`, so it also\n * scopes a subtree through `viewProviders`.\n *\n * ```ts\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideSpeakI18n(withSpeakI18nLabels({ readAloud: 'Vorlesen', stopSpeaking: 'Vorlesen beenden' })),\n * ],\n * });\n * ```\n *\n * @category ui/speak/i18n\n * @since 0.1.0\n */\nexport function provideSpeakI18n(...features: readonly CngxSpeakI18nFeature[]): Provider {\n return {\n provide: CNGX_SPEAK_I18N,\n useFactory: () =>\n features.reduce<Signal<CngxSpeakI18n>>((bundle, feat) => feat(bundle), speakBundleFromPack()),\n };\n}\n\n/**\n * Inject the resolved speak i18n bundle signal.\n *\n * @category ui/speak/i18n\n * @since 0.1.0\n */\nexport function injectSpeakI18n(): Signal<CngxSpeakI18n> {\n return inject(CNGX_SPEAK_I18N);\n}\n","import { ChangeDetectionStrategy, Component, computed, input, ViewEncapsulation } from '@angular/core';\nimport { type CngxSpeak } from '@cngx/common';\n\nimport { injectSpeakI18n } from './speak-i18n';\n\n/**\n * Ready-made speaker button that connects to a {@link CngxSpeak} directive\n * via an explicit `[speakRef]` input - no ancestor injection.\n *\n * Ships with a speaker/stop SVG icon and CSS custom properties for full\n * theming control. Include `speak-button-theme.scss` for automatic Material\n * theme integration.\n *\n * ### Basic usage\n * ```html\n * <span [cngxSpeak]=\"text\" #tts=\"cngxSpeak\">{{ text }}</span>\n * <cngx-speak-button [speakRef]=\"tts\" />\n * ```\n *\n * ### Material theme integration\n * ```scss\n * @use '@cngx/themes/material/speak-button-theme' as speak;\n * @include speak.theme($theme);\n * ```\n *\n * @category ui/speak\n * @docsKind primary\n * @wcag AAA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/speak/speak-button.ts\n * @since 0.1.0\n * @relatedTo CngxSpeak\n * <example-url>http://localhost:4200/#/ui/speak/speak-button/styled-speaker-icon</example-url>\n */\n@Component({\n selector: 'cngx-speak-button',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'cngx-speak-button',\n '[class.cngx-speak-button--speaking]': 'speakRef().speaking()',\n // Speech synthesis is a hard capability - with no engine the button can\n // only ever be a dead control, so it leaves the layout and the a11y tree\n // entirely rather than sit disabled. `supported` is set once at\n // construction, so this gate never flips at runtime.\n '[hidden]': '!speakRef().supported',\n },\n styleUrls: ['./speak-button.css'],\n template: `\n <button\n type=\"button\"\n class=\"cngx-speak-button__btn\"\n [attr.aria-label]=\"resolvedLabel()\"\n (click)=\"speakRef().toggle()\"\n >\n @if (speakRef().speaking()) {\n <svg\n class=\"cngx-speak-button__icon\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n aria-hidden=\"true\"\n >\n <rect x=\"6\" y=\"6\" width=\"12\" height=\"12\" rx=\"2\" />\n </svg>\n } @else {\n <svg\n class=\"cngx-speak-button__icon\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M11 5L6 9H2v6h4l5 4V5z\" />\n <path d=\"M15.54 8.46a5 5 0 010 7.07\" />\n <path d=\"M19.07 4.93a10 10 0 010 14.14\" />\n </svg>\n }\n </button>\n `,\n})\nexport class CngxSpeakButton {\n private readonly i18n = injectSpeakI18n();\n\n /** The `CngxSpeak` directive instance to connect to. */\n readonly speakRef = input.required<CngxSpeak>();\n\n /**\n * Accessible label while idle - the action the button offers. Unbound,\n * `CNGX_SPEAK_I18N.readAloud` applies.\n */\n readonly readAloudLabel = input<string | undefined>(undefined);\n\n /**\n * Accessible label while speaking - the action the button offers to\n * interrupt playback. Unbound, `CNGX_SPEAK_I18N.stopSpeaking` applies.\n */\n readonly stopLabel = input<string | undefined>(undefined);\n\n /** @internal - the label for the current playback state. */\n protected readonly resolvedLabel = computed(() =>\n this.speakRef().speaking()\n ? (this.stopLabel() ?? this.i18n().stopSpeaking)\n : (this.readAloudLabel() ?? this.i18n().readAloud),\n );\n}\n","/**\n * @module @cngx/ui/speak\n */\n\nexport { CngxSpeakButton } from './speak-button';\nexport {\n CNGX_SPEAK_I18N,\n injectSpeakI18n,\n provideSpeakI18n,\n withSpeakI18nLabels,\n type CngxSpeakI18n,\n type CngxSpeakI18nFeature,\n} from './speak-i18n';\nexport {\n CNGX_SPEAK_LANGUAGE_EN,\n type CngxSpeakLanguageSection,\n} from './i18n/speak-language-section';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAgBA;;;;;;;AAOG;AACI,MAAM,sBAAsB,GAA6B;AAC9D,IAAA,SAAS,EAAE,YAAY;AACvB,IAAA,YAAY,EAAE,eAAe;;;ACH/B;AACA,MAAM,mBAAmB,GAAG,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,CAAC;AAElF;;;;;;;;;;AAUG;MACU,eAAe,GAAG,IAAI,cAAc,CAAwB,eA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mBAAmB,EAAA,UAAA,EACjB,IAAI,EAAA,eAAA,EACC,uBAAuB,CAAC,MAAM,EAAA,aAAA,EAChC,iBAAiB,CAAC,IAAI,EAAA,IAAA,EAC/B;AACJ,wBAAA,KAAK,EAAE,mBAAmB;AAC1B,wBAAA,qCAAqC,EAAE,uBAAuB;;;;;AAK9D,wBAAA,UAAU,EAAE,uBAAuB;qBACpC,EAAA,QAAA,EAES;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCT,EAAA,CAAA,EAAA,MAAA,EAAA,CAAA,+pFAAA,CAAA,EAAA;;;ACjFH;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"cngx-ui-speak.mjs","sources":["../../../projects/ui/speak/i18n/speak-language-section.ts","../../../projects/ui/speak/speak-i18n.ts","../../../projects/ui/speak/speak-button.ts","../../../projects/ui/speak/public-api.ts","../../../projects/ui/speak/cngx-ui-speak.ts"],"sourcesContent":["/**\n * The speak section of a {@link CngxLanguagePack}: the accessible names of\n * `CngxSpeakButton`. It feeds `CNGX_SPEAK_I18N`; a key set through\n * `withSpeakI18nLabels` still wins.\n *\n * @since 0.3.0\n * @relatedTo CNGX_SPEAK_I18N, withSpeakI18nLabels\n */\nexport interface CngxSpeakLanguageSection {\n /** Accessible name of the speak button while idle. */\n readonly readAloud: string;\n /** Accessible name of the speak button while speaking. */\n readonly stopSpeaking: string;\n}\n\n/**\n * The English speak section: the single source of the speak button's English\n * copy. `CNGX_SPEAK_I18N` defaults to it.\n *\n * @since 0.3.0\n * @relatedTo CNGX_SPEAK_I18N\n */\nexport const CNGX_SPEAK_LANGUAGE_EN: CngxSpeakLanguageSection = {\n readAloud: 'Read aloud',\n stopSpeaking: 'Stop speaking',\n};\n\ndeclare module '@cngx/core/i18n' {\n interface CngxLanguagePack {\n readonly speak: CngxSpeakLanguageSection;\n }\n}\n","import { inject, InjectionToken, type Provider, type Signal } from '@angular/core';\nimport { createLanguageSection } from '@cngx/core/i18n';\nimport { createFilledOverrideMerge } from '@cngx/core/utils';\n\nimport {\n CNGX_SPEAK_LANGUAGE_EN,\n type CngxSpeakLanguageSection,\n} from './i18n/speak-language-section';\n\n/**\n * Speak i18n surface: the `speak` section of the language pack (English\n * without one); override single keys via {@link provideSpeakI18n}. Reactive\n * from birth: the token carries a `Signal`, and {@link withSpeakI18nLabels}\n * accepts a `Signal` of a partial bundle.\n *\n * `CngxSpeakButton` reads both keys inside a `computed()` while its\n * `readAloudLabel` / `stopLabel` inputs are unbound, so the label follows a\n * language switch.\n */\nexport type CngxSpeakI18n = CngxSpeakLanguageSection;\n\n/** The English speak section with the active pack's speak section on top, shared app-wide. */\nconst speakBundleFromPack = createLanguageSection('speak', CNGX_SPEAK_LANGUAGE_EN);\n\n/**\n * DI token for the speak i18n bundle. `providedIn: 'root'`: the `speak`\n * section of the active language pack over the English defaults. The value is\n * a `Signal`, shared by every reader under one injector.\n *\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/speak/speak-i18n.ts\n * @since 0.3.0\n * @relatedTo CngxSpeakButton\n */\nexport const CNGX_SPEAK_I18N = new InjectionToken<Signal<CngxSpeakI18n>>('CngxSpeakI18n', {\n providedIn: 'root',\n factory: speakBundleFromPack,\n});\n\n/**\n * A label override feature of `provideSpeakI18n`.\n *\n * @since 0.3.0\n * @relatedTo CNGX_SPEAK_I18N, withSpeakI18nLabels\n */\nexport type CngxSpeakI18nFeature = (bundle: Signal<CngxSpeakI18n>) => Signal<CngxSpeakI18n>;\n\n/**\n * Override i18n labels via a partial bundle - unset keys, and keys set to\n * `null` or `undefined`, keep the language pack's copy, or the English\n * default, so the button never loses its accessible name. Pass a `Signal` of a\n * partial bundle to switch languages at runtime.\n *\n * @since 0.3.0\n */\nexport function withSpeakI18nLabels(\n overrides: Partial<CngxSpeakI18n> | Signal<Partial<CngxSpeakI18n>>,\n): CngxSpeakI18nFeature {\n return (bundle) => createFilledOverrideMerge(bundle, overrides);\n}\n\n/**\n * Provider for the speak i18n bundle. Returns a plain `Provider`, so it also\n * scopes a subtree through `viewProviders`.\n *\n * ```ts\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideSpeakI18n(withSpeakI18nLabels({ readAloud: 'Vorlesen', stopSpeaking: 'Vorlesen beenden' })),\n * ],\n * });\n * ```\n *\n * @since 0.3.0\n */\nexport function provideSpeakI18n(...features: readonly CngxSpeakI18nFeature[]): Provider {\n return {\n provide: CNGX_SPEAK_I18N,\n useFactory: () =>\n features.reduce<Signal<CngxSpeakI18n>>((bundle, feat) => feat(bundle), speakBundleFromPack()),\n };\n}\n\n/**\n * Inject the resolved speak i18n bundle signal.\n *\n * @since 0.3.0\n */\nexport function injectSpeakI18n(): Signal<CngxSpeakI18n> {\n return inject(CNGX_SPEAK_I18N);\n}\n","import { ChangeDetectionStrategy, Component, computed, input, ViewEncapsulation } from '@angular/core';\nimport { type CngxSpeak } from '@cngx/common';\nimport { CngxIconSvg } from '@cngx/common/display';\nimport { CNGX_ICON_STOP, CNGX_ICON_VOLUME } from '@cngx/utils';\n\nimport { injectSpeakI18n } from './speak-i18n';\n\n/**\n * Ready-made speaker button that connects to a {@link CngxSpeak} directive\n * via an explicit `[speakRef]` input - no ancestor injection.\n *\n * Ships with a speaker/stop SVG icon and CSS custom properties for full\n * theming control. Include `speak-button-theme.scss` for automatic Material\n * theme integration.\n *\n * ### Basic usage\n * ```html\n * <span [cngxSpeak]=\"text\" #tts=\"cngxSpeak\">{{ text }}</span>\n * <cngx-speak-button [speakRef]=\"tts\" />\n * ```\n *\n * ### Material theme integration\n * ```scss\n * @use '@cngx/themes/material/speak-button-theme' as speak;\n * @include speak.theme($theme);\n * ```\n *\n * @wcag AAA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/speak/speak-button.ts\n * @since 0.3.0\n * @relatedTo CngxSpeak\n * <example-url>/#/ui/speak/speak-button/styled-speaker-icon</example-url>\n * <example-url>/#/ui/speak/speak-button/card-with-speak-badge</example-url>\n * @axis level molecule\n */\n@Component({\n selector: 'cngx-speak-button',\n standalone: true,\n imports: [CngxIconSvg],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'cngx-speak-button',\n '[class.cngx-speak-button--speaking]': 'speakRef().speaking()',\n // Speech synthesis is a hard capability - with no engine the button can\n // only ever be a dead control, so it leaves the layout and the a11y tree\n // entirely rather than sit disabled. `supported` is set once at\n // construction, so this gate never flips at runtime.\n '[hidden]': '!speakRef().supported',\n },\n styleUrls: ['./speak-button.css'],\n template: `\n <button\n type=\"button\"\n class=\"cngx-speak-button__btn\"\n [attr.aria-label]=\"resolvedLabel()\"\n (click)=\"speakRef().toggle()\"\n >\n <svg class=\"cngx-speak-button__icon\" [cngxIconSvg]=\"icon()\"></svg>\n </button>\n `,\n})\nexport class CngxSpeakButton {\n private readonly i18n = injectSpeakI18n();\n\n /** The `CngxSpeak` directive instance to connect to. */\n readonly speakRef = input.required<CngxSpeak>();\n\n /**\n * Accessible label while idle - the action the button offers. Unbound,\n * `CNGX_SPEAK_I18N.readAloud` applies.\n */\n readonly readAloudLabel = input<string | undefined>(undefined);\n\n /**\n * Accessible label while speaking - the action the button offers to\n * interrupt playback. Unbound, `CNGX_SPEAK_I18N.stopSpeaking` applies.\n */\n readonly stopLabel = input<string | undefined>(undefined);\n\n /** @internal - speaker while idle, stop square while speaking. */\n protected readonly icon = computed(() =>\n this.speakRef().speaking() ? CNGX_ICON_STOP : CNGX_ICON_VOLUME,\n );\n\n /** @internal - the label for the current playback state. */\n protected readonly resolvedLabel = computed(() =>\n this.speakRef().speaking()\n ? (this.stopLabel() ?? this.i18n().stopSpeaking)\n : (this.readAloudLabel() ?? this.i18n().readAloud),\n );\n}\n","/**\n * @module `@cngx/ui/speak`\n */\n\nexport { CngxSpeakButton } from './speak-button';\nexport {\n CNGX_SPEAK_I18N,\n injectSpeakI18n,\n provideSpeakI18n,\n withSpeakI18nLabels,\n type CngxSpeakI18n,\n type CngxSpeakI18nFeature,\n} from './speak-i18n';\nexport {\n CNGX_SPEAK_LANGUAGE_EN,\n type CngxSpeakLanguageSection,\n} from './i18n/speak-language-section';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AAeA;;;;;;AAMG;AACI,MAAM,sBAAsB,GAA6B;AAC9D,IAAA,SAAS,EAAE,YAAY;AACvB,IAAA,YAAY,EAAE,eAAe;;;ACH/B;AACA,MAAM,mBAAmB,GAAG,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,CAAC;AAElF;;;;;;;;;AASG;MACU,eAAe,GAAG,IAAI,cAAc,CAAwB,eAAe,EAAE;AACxF,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,mBAAmB;AAC7B,CAAA;AAUD;;;;;;;AAOG;AACG,SAAU,mBAAmB,CACjC,SAAkE,EAAA;IAElE,OAAO,CAAC,MAAM,KAAK,yBAAyB,CAAC,MAAM,EAAE,SAAS,CAAC;AACjE;AAEA;;;;;;;;;;;;;AAaG;AACG,SAAU,gBAAgB,CAAC,GAAG,QAAyC,EAAA;IAC3E,OAAO;AACL,QAAA,OAAO,EAAE,eAAe;QACxB,UAAU,EAAE,MACV,QAAQ,CAAC,MAAM,CAAwB,CAAC,MAAM,EAAE,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,mBAAmB,EAAE,CAAC;KAChG;AACH;AAEA;;;;AAIG;SACa,eAAe,GAAA;AAC7B,IAAA,OAAO,MAAM,CAAC,eAAe,CAAC;AAChC;;ACnFA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;MA4BU,eAAe,CAAA;IACT,IAAI,GAAG,eAAe,EAAE;;AAGhC,IAAA,QAAQ,GAAG,KAAK,CAAC,QAAQ,8EAAa;AAE/C;;;AAGG;AACM,IAAA,cAAc,GAAG,KAAK,CAAqB,SAAS,qFAAC;AAE9D;;;AAGG;AACM,IAAA,SAAS,GAAG,KAAK,CAAqB,SAAS,gF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