@agorapulse/ui-components 22.4.13-beta.1 → 22.4.13-beta.2
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/agorapulse-ui-components-22.4.13-beta.2.tgz +0 -0
- package/fesm2022/agorapulse-ui-components-form-field.mjs +36 -11
- package/fesm2022/agorapulse-ui-components-form-field.mjs.map +1 -1
- package/package.json +1 -1
- package/types/agorapulse-ui-components-form-field.d.ts +11 -3
- package/agorapulse-ui-components-22.4.13-beta.1.tgz +0 -0
|
Binary file
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, APP_ID, viewChild, signal, computed, afterRenderEffect, untracked, ViewEncapsulation, ChangeDetectionStrategy, Component, input, booleanAttribute, ElementRef, DestroyRef, Directive } from '@angular/core';
|
|
2
|
+
import { inject, APP_ID, viewChild, signal, computed, afterRenderEffect, untracked, ViewEncapsulation, ChangeDetectionStrategy, Component, input, booleanAttribute, ElementRef, Renderer2, DestroyRef, effect, Directive } from '@angular/core';
|
|
3
3
|
|
|
4
4
|
class FormFieldComponent {
|
|
5
5
|
/**
|
|
@@ -50,10 +50,11 @@ class FormFieldComponent {
|
|
|
50
50
|
this.labelled.set(false);
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
// When the control offers a target `for` can reach, the browser supplies the name and the focusing click, so no ARIA is owed
|
|
53
|
+
// When the control offers a target `for` can reach, the browser supplies the name and the focusing click, so no ARIA is owed;
|
|
54
|
+
// an author's `for` that reaches no control — one aimed at a component host — names nothing, so it is re-aimed.
|
|
54
55
|
const target = this.control()?.labelTarget(`${this.uid}-control`);
|
|
55
56
|
if (target) {
|
|
56
|
-
if (!label.
|
|
57
|
+
if (!label.control) {
|
|
57
58
|
label.htmlFor = target;
|
|
58
59
|
}
|
|
59
60
|
this.labelledById.set(undefined);
|
|
@@ -125,18 +126,23 @@ class FormFieldControlDirective {
|
|
|
125
126
|
/** A disabled control does not take focus from a click on its label. */
|
|
126
127
|
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
127
128
|
element = inject(ElementRef).nativeElement;
|
|
129
|
+
renderer = inject(Renderer2);
|
|
128
130
|
formField = inject(FormFieldComponent, { optional: true });
|
|
131
|
+
authoredDescribedBy = this.element.getAttribute('aria-describedby');
|
|
129
132
|
/** Empty on the native branch, where the label's `for` already carries the association. */
|
|
130
133
|
labelledBy = computed(() => this.formField?.labelledBy(), /* @ts-ignore */
|
|
131
134
|
...(ngDevMode ? [{ debugName: "labelledBy" }] : /* istanbul ignore next */ []));
|
|
132
135
|
/** The fallback only: an `aria-label` wins over a visible label, so it goes out only when no label names the control. */
|
|
133
|
-
label = computed(() => (this.formField?.hasLabel() ? undefined : this.ariaLabel()), /* @ts-ignore */
|
|
136
|
+
label = computed(() => (this.formField?.hasLabel() ? undefined : this.ariaLabel() || undefined), /* @ts-ignore */
|
|
134
137
|
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
135
|
-
describedBy = computed(() => this.formField?.describedBy(), /* @ts-ignore */
|
|
138
|
+
describedBy = computed(() => [this.authoredDescribedBy, this.formField?.describedBy()].filter(Boolean).join(' ') || undefined, /* @ts-ignore */
|
|
136
139
|
...(ngDevMode ? [{ debugName: "describedBy" }] : /* istanbul ignore next */ []));
|
|
137
140
|
constructor() {
|
|
138
141
|
this.formField?.registerControl(this);
|
|
139
142
|
inject(DestroyRef).onDestroy(() => this.formField?.unregisterControl(this));
|
|
143
|
+
this.reflect('aria-labelledby', this.labelledBy);
|
|
144
|
+
this.reflect('aria-label', this.label);
|
|
145
|
+
this.reflect('aria-describedby', this.describedBy);
|
|
140
146
|
}
|
|
141
147
|
labelTarget(fallbackId) {
|
|
142
148
|
if (!LABELABLE.includes(this.element.tagName)) {
|
|
@@ -147,6 +153,30 @@ class FormFieldControlDirective {
|
|
|
147
153
|
}
|
|
148
154
|
return this.element.id;
|
|
149
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Writes the attribute only while there is a value for it, and gives back what the author wrote after: a host binding would
|
|
158
|
+
* clear an author's own `aria-label`, static or bound, whenever the field has nothing to say.
|
|
159
|
+
*/
|
|
160
|
+
reflect(name, value) {
|
|
161
|
+
const authored = this.element.getAttribute(name);
|
|
162
|
+
let written = false;
|
|
163
|
+
effect(() => {
|
|
164
|
+
const next = value();
|
|
165
|
+
if (next !== undefined) {
|
|
166
|
+
this.renderer.setAttribute(this.element, name, next);
|
|
167
|
+
written = true;
|
|
168
|
+
}
|
|
169
|
+
else if (written) {
|
|
170
|
+
if (authored === null) {
|
|
171
|
+
this.renderer.removeAttribute(this.element, name);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
this.renderer.setAttribute(this.element, name, authored);
|
|
175
|
+
}
|
|
176
|
+
written = false;
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
150
180
|
focus() {
|
|
151
181
|
if (this.disabled()) {
|
|
152
182
|
return;
|
|
@@ -159,17 +189,12 @@ class FormFieldControlDirective {
|
|
|
159
189
|
}
|
|
160
190
|
}
|
|
161
191
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: FormFieldControlDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
162
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.5", type: FormFieldControlDirective, isStandalone: true, selector: "[apFormFieldControl]", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "apFormFieldControl", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } },
|
|
192
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.5", type: FormFieldControlDirective, isStandalone: true, selector: "[apFormFieldControl]", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "apFormFieldControl", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
|
|
163
193
|
}
|
|
164
194
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: FormFieldControlDirective, decorators: [{
|
|
165
195
|
type: Directive,
|
|
166
196
|
args: [{
|
|
167
197
|
selector: '[apFormFieldControl]',
|
|
168
|
-
host: {
|
|
169
|
-
'[attr.aria-labelledby]': 'labelledBy()',
|
|
170
|
-
'[attr.aria-label]': 'label()',
|
|
171
|
-
'[attr.aria-describedby]': 'describedBy()',
|
|
172
|
-
},
|
|
173
198
|
}]
|
|
174
199
|
}], ctorParameters: () => [], propDecorators: { ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "apFormFieldControl", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
|
|
175
200
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agorapulse-ui-components-form-field.mjs","sources":["../../../libs/ui-components/form-field/src/form-field.component.ts","../../../libs/ui-components/form-field/src/form-field.component.html","../../../libs/ui-components/form-field/src/form-field-control.directive.ts","../../../libs/ui-components/form-field/src/agorapulse-ui-components-form-field.ts"],"sourcesContent":["import {\n afterRenderEffect,\n APP_ID,\n ChangeDetectionStrategy,\n Component,\n computed,\n ElementRef,\n inject,\n signal,\n untracked,\n viewChild,\n ViewEncapsulation,\n} from '@angular/core';\nimport type { FormFieldControl } from './form-field-control';\n\n@Component({\n selector: 'ap-form-field',\n templateUrl: './form-field.component.html',\n styleUrls: ['./form-field.component.scss'],\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n host: {\n '(click)': 'onClick($event)',\n },\n})\nexport class FormFieldComponent {\n /**\n * Combines the application id — federated Angular apps can share a page — with a per-instance random suffix.\n * Not `crypto.randomUUID()`, which browsers refuse outside a secure context.\n */\n private readonly uid = `${inject(APP_ID)}-form-field-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;\n\n private readonly content = viewChild.required<ElementRef<HTMLElement>>('content');\n private readonly control = signal<FormFieldControl | undefined>(undefined);\n private readonly descriptions = signal<readonly string[]>([]);\n\n private readonly labelledById = signal<string | undefined>(undefined);\n private readonly labelled = signal(false);\n\n /**\n * The label's id when `aria-labelledby` has to carry the association — never on the native branch, where `for` suffices.\n * Undefined until the first render, and when the field has no label: a control must not emit a dangling reference.\n */\n readonly labelledBy = this.labelledById.asReadonly();\n\n /** Whether a label already names the control, by `for` or by `aria-labelledby`. */\n readonly hasLabel = this.labelled.asReadonly();\n\n /** The ids of everything describing the control, for its `aria-describedby`. */\n readonly describedBy = computed(() => this.descriptions().join(' ') || undefined);\n\n constructor() {\n // After render, so outside change detection: the projected content exists and writing signals\n // here cannot trigger NG0100. Re-runs when the control registers, since it picks the branch.\n afterRenderEffect(() => {\n this.content();\n this.control();\n untracked(() => this.associate());\n });\n }\n\n /**\n * Links the projected label to the registered control.\n *\n * Public because `detectChanges()` does not run after-render hooks in a zone.js harness, so a spec has to force the pass —\n * as does a consumer whose label only appears after the first render.\n */\n associate(): void {\n // `:scope >` and not `querySelector('label')`: `ng-content select=\"label\"` only projects direct\n // children, so a deeper label belongs to something else. Among several, the first names the field.\n const label = this.content().nativeElement.querySelector<HTMLLabelElement>(':scope > label');\n if (!label) {\n this.labelledById.set(undefined);\n this.labelled.set(false);\n return;\n }\n\n // When the control offers a target `for` can reach, the browser supplies the name and the focusing click, so no ARIA is owed.\n const target = this.control()?.labelTarget(`${this.uid}-control`);\n if (target) {\n if (!label.htmlFor) {\n label.htmlFor = target;\n }\n this.labelledById.set(undefined);\n this.labelled.set(true);\n return;\n }\n\n this.labelledById.set(this.ensureId(label, 'label'));\n this.labelled.set(true);\n }\n\n registerControl(control: FormFieldControl): void {\n this.control.set(control);\n }\n\n unregisterControl(control: FormFieldControl): void {\n // By identity: a destruction racing a new registration must not clear the live control.\n this.control.update(current => (current === control ? undefined : current));\n }\n\n registerDescription(id: string): void {\n this.descriptions.update(ids => (ids.includes(id) ? ids : [...ids, id]));\n }\n\n unregisterDescription(id: string): void {\n this.descriptions.update(ids => ids.filter(current => current !== id));\n }\n\n /** Only stamps what has no id yet: the author's own may already be referenced elsewhere. */\n private ensureId(element: HTMLElement, suffix: string): string {\n if (!element.id) {\n element.id = `${this.uid}-${suffix}`;\n }\n return element.id;\n }\n\n protected onClick(event: MouseEvent): void {\n const control = this.control();\n if (!control) {\n return;\n }\n\n const label = (event.target as HTMLElement | null)?.closest('label');\n if (!label || label.parentElement !== this.content().nativeElement) {\n return;\n }\n\n // `label.control` is null exactly when the `for` reaches nothing, the case this exists for.\n // `hasAttribute('for')` would instead let an inert `for` through — precisely what is repaired.\n if (label.control) {\n return;\n }\n\n control.focus();\n }\n}\n","<div\n #content\n class=\"ap-form-field\">\n <ng-content select=\"label\"></ng-content>\n <ng-content></ng-content>\n <ng-content select=\"ap-form-message\"></ng-content>\n</div>\n","import { booleanAttribute, computed, DestroyRef, Directive, ElementRef, inject, input } from '@angular/core';\nimport type { FormFieldControl } from './form-field-control';\nimport { FormFieldComponent } from './form-field.component';\n\n/** The elements a `<label for>` can reach. Everything else has to go through `aria-labelledby`. */\nconst LABELABLE = ['BUTTON', 'INPUT', 'METER', 'OUTPUT', 'PROGRESS', 'SELECT', 'TEXTAREA'];\n\n/** Finds the first focusable descendant, for when the designated element is not focusable itself. */\nconst FOCUSABLE =\n 'button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], [tabindex]:not([tabindex=\"-1\"])';\n\n/**\n * Points the surrounding `ap-form-field` at a control's focusable element, and carries the naming that follows.\n *\n * Put it on the element the user actually focuses: the component host when that is it (via `hostDirectives`), otherwise the\n * inner element, in the component's template. With no `ap-form-field` around, it falls back to the `aria-label` it is given.\n */\n@Directive({\n selector: '[apFormFieldControl]',\n host: {\n '[attr.aria-labelledby]': 'labelledBy()',\n '[attr.aria-label]': 'label()',\n '[attr.aria-describedby]': 'describedBy()',\n },\n})\nexport class FormFieldControlDirective implements FormFieldControl {\n /** Fallback name, for a field with no visible label. */\n readonly ariaLabel = input<string | undefined>(undefined, { alias: 'apFormFieldControl' });\n\n /** A disabled control does not take focus from a click on its label. */\n readonly disabled = input(false, { transform: booleanAttribute });\n\n private readonly element: HTMLElement = inject(ElementRef).nativeElement;\n private readonly formField = inject(FormFieldComponent, { optional: true });\n\n /** Empty on the native branch, where the label's `for` already carries the association. */\n protected readonly labelledBy = computed(() => this.formField?.labelledBy());\n\n /** The fallback only: an `aria-label` wins over a visible label, so it goes out only when no label names the control. */\n protected readonly label = computed(() => (this.formField?.hasLabel() ? undefined : this.ariaLabel()));\n\n protected readonly describedBy = computed(() => this.formField?.describedBy());\n\n constructor() {\n this.formField?.registerControl(this);\n inject(DestroyRef).onDestroy(() => this.formField?.unregisterControl(this));\n }\n\n labelTarget(fallbackId: string): string | undefined {\n if (!LABELABLE.includes(this.element.tagName)) {\n return undefined;\n }\n if (!this.element.id) {\n this.element.id = fallbackId;\n }\n return this.element.id;\n }\n\n focus(): void {\n if (this.disabled()) {\n return;\n }\n\n this.element.focus();\n // A named container — `role=\"group\"`, `role=\"listbox\"` — is not always in the tab order; the\n // label should then reach its first focusable element.\n if (document.activeElement !== this.element) {\n this.element.querySelector<HTMLElement>(FOCUSABLE)?.focus();\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;MA0Ba,kBAAkB,CAAA;AAC3B;;;AAGG;AACc,IAAA,GAAG,GAAG,CAAA,EAAG,MAAM,CAAC,MAAM,CAAC,CAAA,YAAA,EAAe,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA,EAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QA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7C,qBAAA;AACJ,iBAAA;;;ACxBD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"agorapulse-ui-components-form-field.mjs","sources":["../../../libs/ui-components/form-field/src/form-field.component.ts","../../../libs/ui-components/form-field/src/form-field.component.html","../../../libs/ui-components/form-field/src/form-field-control.directive.ts","../../../libs/ui-components/form-field/src/agorapulse-ui-components-form-field.ts"],"sourcesContent":["import {\n afterRenderEffect,\n APP_ID,\n ChangeDetectionStrategy,\n Component,\n computed,\n ElementRef,\n inject,\n signal,\n untracked,\n viewChild,\n ViewEncapsulation,\n} from '@angular/core';\nimport type { FormFieldControl } from './form-field-control';\n\n@Component({\n selector: 'ap-form-field',\n templateUrl: './form-field.component.html',\n styleUrls: ['./form-field.component.scss'],\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n host: {\n '(click)': 'onClick($event)',\n },\n})\nexport class FormFieldComponent {\n /**\n * Combines the application id — federated Angular apps can share a page — with a per-instance random suffix.\n * Not `crypto.randomUUID()`, which browsers refuse outside a secure context.\n */\n private readonly uid = `${inject(APP_ID)}-form-field-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;\n\n private readonly content = viewChild.required<ElementRef<HTMLElement>>('content');\n private readonly control = signal<FormFieldControl | undefined>(undefined);\n private readonly descriptions = signal<readonly string[]>([]);\n\n private readonly labelledById = signal<string | undefined>(undefined);\n private readonly labelled = signal(false);\n\n /**\n * The label's id when `aria-labelledby` has to carry the association — never on the native branch, where `for` suffices.\n * Undefined until the first render, and when the field has no label: a control must not emit a dangling reference.\n */\n readonly labelledBy = this.labelledById.asReadonly();\n\n /** Whether a label already names the control, by `for` or by `aria-labelledby`. */\n readonly hasLabel = this.labelled.asReadonly();\n\n /** The ids of everything describing the control, for its `aria-describedby`. */\n readonly describedBy = computed(() => this.descriptions().join(' ') || undefined);\n\n constructor() {\n // After render, so outside change detection: the projected content exists and writing signals\n // here cannot trigger NG0100. Re-runs when the control registers, since it picks the branch.\n afterRenderEffect(() => {\n this.content();\n this.control();\n untracked(() => this.associate());\n });\n }\n\n /**\n * Links the projected label to the registered control.\n *\n * Public because `detectChanges()` does not run after-render hooks in a zone.js harness, so a spec has to force the pass —\n * as does a consumer whose label only appears after the first render.\n */\n associate(): void {\n // `:scope >` and not `querySelector('label')`: `ng-content select=\"label\"` only projects direct\n // children, so a deeper label belongs to something else. Among several, the first names the field.\n const label = this.content().nativeElement.querySelector<HTMLLabelElement>(':scope > label');\n if (!label) {\n this.labelledById.set(undefined);\n this.labelled.set(false);\n return;\n }\n\n // When the control offers a target `for` can reach, the browser supplies the name and the focusing click, so no ARIA is owed;\n // an author's `for` that reaches no control — one aimed at a component host — names nothing, so it is re-aimed.\n const target = this.control()?.labelTarget(`${this.uid}-control`);\n if (target) {\n if (!label.control) {\n label.htmlFor = target;\n }\n this.labelledById.set(undefined);\n this.labelled.set(true);\n return;\n }\n\n this.labelledById.set(this.ensureId(label, 'label'));\n this.labelled.set(true);\n }\n\n registerControl(control: FormFieldControl): void {\n this.control.set(control);\n }\n\n unregisterControl(control: FormFieldControl): void {\n // By identity: a destruction racing a new registration must not clear the live control.\n this.control.update(current => (current === control ? undefined : current));\n }\n\n registerDescription(id: string): void {\n this.descriptions.update(ids => (ids.includes(id) ? ids : [...ids, id]));\n }\n\n unregisterDescription(id: string): void {\n this.descriptions.update(ids => ids.filter(current => current !== id));\n }\n\n /** Only stamps what has no id yet: the author's own may already be referenced elsewhere. */\n private ensureId(element: HTMLElement, suffix: string): string {\n if (!element.id) {\n element.id = `${this.uid}-${suffix}`;\n }\n return element.id;\n }\n\n protected onClick(event: MouseEvent): void {\n const control = this.control();\n if (!control) {\n return;\n }\n\n const label = (event.target as HTMLElement | null)?.closest('label');\n if (!label || label.parentElement !== this.content().nativeElement) {\n return;\n }\n\n // `label.control` is null exactly when the `for` reaches nothing, the case this exists for.\n // `hasAttribute('for')` would instead let an inert `for` through — precisely what is repaired.\n if (label.control) {\n return;\n }\n\n control.focus();\n }\n}\n","<div\n #content\n class=\"ap-form-field\">\n <ng-content select=\"label\"></ng-content>\n <ng-content></ng-content>\n <ng-content select=\"ap-form-message\"></ng-content>\n</div>\n","import { booleanAttribute, computed, DestroyRef, Directive, effect, ElementRef, inject, input, Renderer2, Signal } from '@angular/core';\nimport type { FormFieldControl } from './form-field-control';\nimport { FormFieldComponent } from './form-field.component';\n\n/** The elements a `<label for>` can reach. Everything else has to go through `aria-labelledby`. */\nconst LABELABLE = ['BUTTON', 'INPUT', 'METER', 'OUTPUT', 'PROGRESS', 'SELECT', 'TEXTAREA'];\n\n/** Finds the first focusable descendant, for when the designated element is not focusable itself. */\nconst FOCUSABLE =\n 'button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], [tabindex]:not([tabindex=\"-1\"])';\n\n/**\n * Points the surrounding `ap-form-field` at a control's focusable element, and carries the naming that follows.\n *\n * Put it on the element the user actually focuses: the component host when that is it (via `hostDirectives`), otherwise the\n * inner element, in the component's template. With no `ap-form-field` around, it falls back to the `aria-label` it is given.\n */\n@Directive({\n selector: '[apFormFieldControl]',\n})\nexport class FormFieldControlDirective implements FormFieldControl {\n /** Fallback name, for a field with no visible label. */\n readonly ariaLabel = input<string | undefined>(undefined, { alias: 'apFormFieldControl' });\n\n /** A disabled control does not take focus from a click on its label. */\n readonly disabled = input(false, { transform: booleanAttribute });\n\n private readonly element: HTMLElement = inject(ElementRef).nativeElement;\n private readonly renderer = inject(Renderer2);\n private readonly formField = inject(FormFieldComponent, { optional: true });\n private readonly authoredDescribedBy = this.element.getAttribute('aria-describedby');\n\n /** Empty on the native branch, where the label's `for` already carries the association. */\n protected readonly labelledBy = computed(() => this.formField?.labelledBy());\n\n /** The fallback only: an `aria-label` wins over a visible label, so it goes out only when no label names the control. */\n protected readonly label = computed(() => (this.formField?.hasLabel() ? undefined : this.ariaLabel() || undefined));\n\n protected readonly describedBy = computed(\n () => [this.authoredDescribedBy, this.formField?.describedBy()].filter(Boolean).join(' ') || undefined\n );\n\n constructor() {\n this.formField?.registerControl(this);\n inject(DestroyRef).onDestroy(() => this.formField?.unregisterControl(this));\n this.reflect('aria-labelledby', this.labelledBy);\n this.reflect('aria-label', this.label);\n this.reflect('aria-describedby', this.describedBy);\n }\n\n labelTarget(fallbackId: string): string | undefined {\n if (!LABELABLE.includes(this.element.tagName)) {\n return undefined;\n }\n if (!this.element.id) {\n this.element.id = fallbackId;\n }\n return this.element.id;\n }\n\n /**\n * Writes the attribute only while there is a value for it, and gives back what the author wrote after: a host binding would\n * clear an author's own `aria-label`, static or bound, whenever the field has nothing to say.\n */\n private reflect(name: string, value: Signal<string | undefined>): void {\n const authored = this.element.getAttribute(name);\n let written = false;\n effect(() => {\n const next = value();\n if (next !== undefined) {\n this.renderer.setAttribute(this.element, name, next);\n written = true;\n } else if (written) {\n if (authored === null) {\n this.renderer.removeAttribute(this.element, name);\n } else {\n this.renderer.setAttribute(this.element, name, authored);\n }\n written = false;\n }\n });\n }\n\n focus(): void {\n if (this.disabled()) {\n return;\n }\n\n this.element.focus();\n // A named container — `role=\"group\"`, `role=\"listbox\"` — is not always in the tab order; the\n // label should then reach its first focusable element.\n if (document.activeElement !== this.element) {\n this.element.querySelector<HTMLElement>(FOCUSABLE)?.focus();\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;MA0Ba,kBAAkB,CAAA;AAC3B;;;AAGG;AACc,IAAA,GAAG,GAAG,CAAA,EAAG,MAAM,CAAC,MAAM,CAAC,CAAA,YAAA,EAAe,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA,EAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE;AAErG,IAAA,OAAO,GAAG,SAAS,CAAC,QAAQ,CAA0B,SAAS,CAAC;IAChE,OAAO,GAAG,MAAM,CAA+B,SAA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KAAK,EAAE;;;QAGpB,IAAI,QAAQ,CAAC,aAAa,KAAK,IAAI,CAAC,OAAO,EAAE;YACzC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAc,SAAS,CAAC,EAAE,KAAK,EAAE;QAC/D;IACJ;uGA1ES,yBAAyB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAzB,yBAAyB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,sBAAA,EAAA,MAAA,EAAA,EAAA,SAAA,EAAA,EAAA,iBAAA,EAAA,WAAA,EAAA,UAAA,EAAA,oBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,QAAA,EAAA,EAAA,iBAAA,EAAA,UAAA,EAAA,UAAA,EAAA,UAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAzB,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBAHrC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACP,oBAAA,QAAQ,EAAE,sBAAsB;AACnC,iBAAA;;;ACnBD;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { Signal } from '@angular/core';
|
|
2
3
|
|
|
3
4
|
/** What a control offers the field around it, so that field's label can name it. */
|
|
4
5
|
interface FormFieldControl {
|
|
@@ -24,14 +25,21 @@ declare class FormFieldControlDirective implements FormFieldControl {
|
|
|
24
25
|
/** A disabled control does not take focus from a click on its label. */
|
|
25
26
|
readonly disabled: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
26
27
|
private readonly element;
|
|
28
|
+
private readonly renderer;
|
|
27
29
|
private readonly formField;
|
|
30
|
+
private readonly authoredDescribedBy;
|
|
28
31
|
/** Empty on the native branch, where the label's `for` already carries the association. */
|
|
29
|
-
protected readonly labelledBy:
|
|
32
|
+
protected readonly labelledBy: Signal<string | undefined>;
|
|
30
33
|
/** The fallback only: an `aria-label` wins over a visible label, so it goes out only when no label names the control. */
|
|
31
|
-
protected readonly label:
|
|
32
|
-
protected readonly describedBy:
|
|
34
|
+
protected readonly label: Signal<string | undefined>;
|
|
35
|
+
protected readonly describedBy: Signal<string | undefined>;
|
|
33
36
|
constructor();
|
|
34
37
|
labelTarget(fallbackId: string): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Writes the attribute only while there is a value for it, and gives back what the author wrote after: a host binding would
|
|
40
|
+
* clear an author's own `aria-label`, static or bound, whenever the field has nothing to say.
|
|
41
|
+
*/
|
|
42
|
+
private reflect;
|
|
35
43
|
focus(): void;
|
|
36
44
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormFieldControlDirective, never>;
|
|
37
45
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<FormFieldControlDirective, "[apFormFieldControl]", never, { "ariaLabel": { "alias": "apFormFieldControl"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
Binary file
|