@camaradesuk/m3e-angular 0.2.0-alpha.11 → 0.2.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/camaradesuk-m3e-angular.mjs +231 -10
- package/fesm2022/camaradesuk-m3e-angular.mjs.map +1 -1
- package/package.json +1 -1
- package/src/lib/styles/components/all-buttons/button/tokens/_common.scss +32 -5
- package/src/styles/styles.css +30 -15
- package/src/styles/styles.css.map +1 -1
- package/types/camaradesuk-m3e-angular.d.ts +115 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject, signal, ElementRef, model, input, computed, Input, Directive, effect, forwardRef, booleanAttribute, output, contentChildren,
|
|
2
|
+
import { InjectionToken, inject, signal, ElementRef, model, input, ChangeDetectorRef, computed, Input, Directive, effect, forwardRef, booleanAttribute, output, contentChildren, NgZone, afterNextRender, afterRenderEffect, DestroyRef, ChangeDetectionStrategy, Component, ANIMATION_MODULE_TYPE, Injectable, viewChild, PLATFORM_ID, ViewEncapsulation, APP_ID, TemplateRef, ViewContainerRef, untracked, linkedSignal, isDevMode, afterEveryRender, Renderer2, QueryList, Injector, ViewChildren, ContentChildren, contentChild, HostAttributeToken } from '@angular/core';
|
|
3
3
|
import * as i1$2 from '@angular/material/button';
|
|
4
4
|
import { MatIconButton, MatButton, MatFabButton, MatButtonModule } from '@angular/material/button';
|
|
5
5
|
import { gsap } from 'gsap';
|
|
@@ -88,6 +88,7 @@ const MAT_EXP_BUTTON_GROUP_DEFAULT_OPTIONS = {
|
|
|
88
88
|
shape: 'round',
|
|
89
89
|
variant: 'standard',
|
|
90
90
|
selection: 'single-select',
|
|
91
|
+
semantics: 'toggle',
|
|
91
92
|
disableBounce: false,
|
|
92
93
|
// matExpButtonGroupClass: 'mat-exp-button-group',
|
|
93
94
|
};
|
|
@@ -437,6 +438,13 @@ const MAT_EXP_ICON_BUTTON_OPTIONS = _iconButtonOptions.token;
|
|
|
437
438
|
const provideMatExpIconButtonOptions = _iconButtonOptions.provide;
|
|
438
439
|
const injectMatExpIconButtonOptions = _iconButtonOptions.inject;
|
|
439
440
|
|
|
441
|
+
/**
|
|
442
|
+
* The attributes a radio-mode button group writes on each button, saved and restored around radio mode. Not exported
|
|
443
|
+
* from the package barrel.
|
|
444
|
+
* @internal
|
|
445
|
+
*/
|
|
446
|
+
const RADIO_ATTRIBUTES = ['role', 'aria-checked', 'aria-posinset', 'aria-setsize'];
|
|
447
|
+
|
|
440
448
|
/** @internal Shared open-state contract for Expressive triggers and button styling. */
|
|
441
449
|
const MAT_EXP_MENU_OPEN_STATE = new InjectionToken('MAT_EXP_MENU_OPEN_STATE');
|
|
442
450
|
|
|
@@ -499,6 +507,63 @@ class MatExpIconButton {
|
|
|
499
507
|
...(ngDevMode ? [{ debugName: "toggle" }] : /* istanbul ignore next */ []));
|
|
500
508
|
value = model(/* @ts-ignore */
|
|
501
509
|
...(ngDevMode ? [undefined, { debugName: "value" }] : /* istanbul ignore next */ []));
|
|
510
|
+
/**
|
|
511
|
+
* This button's place in a radio-mode group (`semantics="radio"`), or `null` outside one.
|
|
512
|
+
* @internal
|
|
513
|
+
*/
|
|
514
|
+
_radioState = signal(null, { ...(ngDevMode ? { debugName: "_radioState" } : /* istanbul ignore next */ {}), equal: (a, b) => a === b ||
|
|
515
|
+
(!!a &&
|
|
516
|
+
!!b &&
|
|
517
|
+
a.checked === b.checked &&
|
|
518
|
+
a.tabStop === b.tabStop &&
|
|
519
|
+
a.position === b.position &&
|
|
520
|
+
a.size === b.size) });
|
|
521
|
+
/** What the consumer had on the host before radio mode, restored when it ends (null while not in radio mode). */
|
|
522
|
+
/** The view that renders this button's host bindings (Material's `tabindex`), refreshed after a radio write. */
|
|
523
|
+
_changeDetector = inject(ChangeDetectorRef);
|
|
524
|
+
_savedRadioAttributes = null;
|
|
525
|
+
/**
|
|
526
|
+
* Applies or removes radio semantics for a radio-mode group. Outside radio mode the directive writes no ARIA, so a
|
|
527
|
+
* consumer's own `role` or `aria-*` stays as authored; in radio mode it sets `role="radio"`, `aria-checked`,
|
|
528
|
+
* `aria-posinset` and `aria-setsize` on the host itself and restores the consumer's values when the mode ends. The
|
|
529
|
+
* roving Tab stop is written to Material's own `tabIndex` input, so Material keeps one `tabindex` binding (and its
|
|
530
|
+
* disabled handling). The consumer's values are captured when radio mode starts: a consumer binding to `role` or
|
|
531
|
+
* `aria-*` that changes while the button is in radio mode is not supported (it would overwrite the radio value, and
|
|
532
|
+
* the captured value is what comes back).
|
|
533
|
+
* @internal
|
|
534
|
+
*/
|
|
535
|
+
_setRadioState(state) {
|
|
536
|
+
const host = this.matIconButton;
|
|
537
|
+
const element = this._hostElement;
|
|
538
|
+
if (state) {
|
|
539
|
+
if (!this._savedRadioAttributes) {
|
|
540
|
+
this._savedRadioAttributes = {
|
|
541
|
+
tabIndex: host.tabIndex,
|
|
542
|
+
attributes: Object.fromEntries(RADIO_ATTRIBUTES.map((name) => [name, element.getAttribute(name)])),
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
host.tabIndex = state.tabStop ? 0 : -1;
|
|
546
|
+
element.setAttribute('role', 'radio');
|
|
547
|
+
element.setAttribute('aria-checked', String(state.checked));
|
|
548
|
+
element.setAttribute('aria-posinset', String(state.position));
|
|
549
|
+
element.setAttribute('aria-setsize', String(state.size));
|
|
550
|
+
}
|
|
551
|
+
else if (this._savedRadioAttributes) {
|
|
552
|
+
const saved = this._savedRadioAttributes;
|
|
553
|
+
host.tabIndex = saved.tabIndex;
|
|
554
|
+
for (const [name, value] of Object.entries(saved.attributes)) {
|
|
555
|
+
if (value === null)
|
|
556
|
+
element.removeAttribute(name);
|
|
557
|
+
else
|
|
558
|
+
element.setAttribute(name, value);
|
|
559
|
+
}
|
|
560
|
+
this._savedRadioAttributes = null;
|
|
561
|
+
}
|
|
562
|
+
this._radioState.set(state);
|
|
563
|
+
// Material's `[attr.tabindex]` reads the plain `tabIndex` input, so mark this button's view: the new Tab stop
|
|
564
|
+
// reaches the DOM in zoneless apps and OnPush hosts without relying on anything else to refresh the view.
|
|
565
|
+
this._changeDetector.markForCheck();
|
|
566
|
+
}
|
|
502
567
|
/**
|
|
503
568
|
* `aria-pressed`, derived from `toggle()`. `null` when the button does not
|
|
504
569
|
* participate in toggle behavior, so the attribute is omitted entirely
|
|
@@ -507,6 +572,9 @@ class MatExpIconButton {
|
|
|
507
572
|
* @internal
|
|
508
573
|
*/
|
|
509
574
|
ariaPressed = computed(() => {
|
|
575
|
+
// A radio states its choice with `aria-checked` instead.
|
|
576
|
+
if (this._radioState())
|
|
577
|
+
return null;
|
|
510
578
|
const toggle = this.toggle();
|
|
511
579
|
return toggle === undefined ? null : toggle === 'selected' ? 'true' : 'false';
|
|
512
580
|
}, /* @ts-ignore */
|
|
@@ -677,6 +745,14 @@ const MAT_EXP_BUTTON_GROUP_VALUE_ACCESSOR = {
|
|
|
677
745
|
useExisting: forwardRef(() => MatExpButtonGroup),
|
|
678
746
|
multi: true,
|
|
679
747
|
};
|
|
748
|
+
/** A button that can take focus: not natively disabled (a `disabledInteractive` one can). */
|
|
749
|
+
function canTakeFocus(element) {
|
|
750
|
+
return !element.disabled;
|
|
751
|
+
}
|
|
752
|
+
/** A button that can be chosen: neither natively disabled nor `disabledInteractive`. */
|
|
753
|
+
function isEnabled(element) {
|
|
754
|
+
return canTakeFocus(element) && element.getAttribute('aria-disabled') !== 'true';
|
|
755
|
+
}
|
|
680
756
|
/**
|
|
681
757
|
* Component that groups buttons and provides single/multi-select behavior
|
|
682
758
|
* compatible with Angular reactive and template-driven forms.
|
|
@@ -694,6 +770,21 @@ class MatExpButtonGroup {
|
|
|
694
770
|
...(ngDevMode ? [{ debugName: "selection" }] : /* istanbul ignore next */ []));
|
|
695
771
|
/** Prevents user interaction from clearing the last selected button. */
|
|
696
772
|
selectionRequired = input(this._options.selectionRequired ?? false, { ...(ngDevMode ? { debugName: "selectionRequired" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
773
|
+
/**
|
|
774
|
+
* How a single-select group presents itself to assistive technology.
|
|
775
|
+
*
|
|
776
|
+
* - `'toggle'` (default): `role="group"` of toggle buttons with `aria-pressed`. Every button is a
|
|
777
|
+
* Tab stop; arrow keys move focus only.
|
|
778
|
+
* - `'radio'`: the WAI-ARIA radio group pattern, as Angular Material's single-select button toggle
|
|
779
|
+
* group: `role="radiogroup"`, each button `role="radio"` with `aria-checked`, `aria-posinset` and
|
|
780
|
+
* `aria-setsize`; one Tab stop (the chosen button, or the first enabled one); arrow keys, Home and
|
|
781
|
+
* End move focus and choose; a choice cannot be cleared (`selectionRequired` is implied).
|
|
782
|
+
*
|
|
783
|
+
* Ignored (`'toggle'` behaviour) for `multi-select`.
|
|
784
|
+
* @default 'toggle'
|
|
785
|
+
*/
|
|
786
|
+
semantics = input(this._options.semantics ?? 'toggle', /* @ts-ignore */
|
|
787
|
+
...(ngDevMode ? [{ debugName: "semantics" }] : /* istanbul ignore next */ []));
|
|
697
788
|
/** @default 'standard' */
|
|
698
789
|
variant = input(this._options.variant, /* @ts-ignore */
|
|
699
790
|
...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
@@ -727,6 +818,12 @@ class MatExpButtonGroup {
|
|
|
727
818
|
* @internal
|
|
728
819
|
*/
|
|
729
820
|
matExpButtonGroupClass = 'mat-exp-button-group';
|
|
821
|
+
/**
|
|
822
|
+
* Whether the radio group pattern applies: `semantics="radio"` on a single-select group.
|
|
823
|
+
* @internal
|
|
824
|
+
*/
|
|
825
|
+
_radio = computed(() => this.semantics() === 'radio' && this.selection() === 'single-select', /* @ts-ignore */
|
|
826
|
+
...(ngDevMode ? [{ debugName: "_radio" }] : /* istanbul ignore next */ []));
|
|
730
827
|
// Buttons inject this group; defer query tokens for partial-compiled JIT consumers.
|
|
731
828
|
_matExpButtons = contentChildren(forwardRef(() => MatExpButton), /* @ts-ignore */
|
|
732
829
|
...(ngDevMode ? [{ debugName: "_matExpButtons" }] : /* istanbul ignore next */ []));
|
|
@@ -799,6 +896,21 @@ class MatExpButtonGroup {
|
|
|
799
896
|
this._bounce?.destroy();
|
|
800
897
|
}, { signal: this._interactionAbort.signal });
|
|
801
898
|
this._ngZone.runOutsideAngular(() => this._setupBounceInteractions());
|
|
899
|
+
// A button's or the group's disabled state is not a signal the radio effect can track (a form
|
|
900
|
+
// control, Material's `disabled` input), so watch the attributes that carry it and re-choose
|
|
901
|
+
// the roving Tab stop when they change.
|
|
902
|
+
if (typeof MutationObserver !== 'undefined') {
|
|
903
|
+
const observer = new MutationObserver(() => {
|
|
904
|
+
if (this._radio())
|
|
905
|
+
this._ngZone.run(() => this._syncRadioState());
|
|
906
|
+
});
|
|
907
|
+
observer.observe(this._hostElement, {
|
|
908
|
+
subtree: true,
|
|
909
|
+
attributes: true,
|
|
910
|
+
attributeFilter: ['disabled', 'aria-disabled'],
|
|
911
|
+
});
|
|
912
|
+
this._interactionAbort.signal.addEventListener('abort', () => observer.disconnect());
|
|
913
|
+
}
|
|
802
914
|
});
|
|
803
915
|
// Snap any in-flight bounce back to rest immediately when a consumer flips
|
|
804
916
|
// `disableBounce` mid-press, rather than leaving it stuck expanded until
|
|
@@ -808,6 +920,12 @@ class MatExpButtonGroup {
|
|
|
808
920
|
this._bounce?.destroy();
|
|
809
921
|
}
|
|
810
922
|
});
|
|
923
|
+
// Radio mode: roles, `aria-checked`, positions and the single roving Tab stop. Runs after render,
|
|
924
|
+
// so writing Material's `tabIndex` input never changes a binding mid-check; it re-runs whenever
|
|
925
|
+
// the mode, the projected buttons or any button's toggle state changes.
|
|
926
|
+
afterRenderEffect({
|
|
927
|
+
write: () => this._syncRadioState(),
|
|
928
|
+
});
|
|
811
929
|
inject(DestroyRef).onDestroy(() => {
|
|
812
930
|
this._interactionAbort.abort();
|
|
813
931
|
this._bounce?.destroy();
|
|
@@ -882,7 +1000,16 @@ class MatExpButtonGroup {
|
|
|
882
1000
|
}
|
|
883
1001
|
}, { signal });
|
|
884
1002
|
}
|
|
885
|
-
/**
|
|
1003
|
+
/**
|
|
1004
|
+
* Arrow keys, Home and End move focus between the group's buttons (mirrored in RTL).
|
|
1005
|
+
*
|
|
1006
|
+
* - Toggle semantics (default): native Tab order is kept, the arrows only move focus (manual
|
|
1007
|
+
* activation) and they skip natively disabled and `disabledInteractive` buttons.
|
|
1008
|
+
* - Radio semantics: the arrows move across every button that can take focus, the same set the
|
|
1009
|
+
* roving Tab stop is chosen from, and choose the button they land on (automatic activation).
|
|
1010
|
+
* A `disabledInteractive` button takes focus, so its reason can be read, but is not chosen.
|
|
1011
|
+
* @internal
|
|
1012
|
+
*/
|
|
886
1013
|
_onGroupKeydown(event) {
|
|
887
1014
|
if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey || this.disabled())
|
|
888
1015
|
return;
|
|
@@ -893,8 +1020,8 @@ class MatExpButtonGroup {
|
|
|
893
1020
|
if (!(target instanceof Element) ||
|
|
894
1021
|
target.closest('mat-exp-button-group') !== this._hostElement)
|
|
895
1022
|
return;
|
|
896
|
-
const
|
|
897
|
-
|
|
1023
|
+
const radio = this._radio();
|
|
1024
|
+
const controls = this._childButtonElements().filter((element) => radio ? canTakeFocus(element) : isEnabled(element));
|
|
898
1025
|
const current = controls.findIndex((element) => element === target || element.contains(target));
|
|
899
1026
|
if (current < 0 || !controls.length)
|
|
900
1027
|
return;
|
|
@@ -907,6 +1034,13 @@ class MatExpButtonGroup {
|
|
|
907
1034
|
: (current + (backwards ? -1 : 1) + controls.length) % controls.length;
|
|
908
1035
|
event.preventDefault();
|
|
909
1036
|
controls[next].focus();
|
|
1037
|
+
// Radio group pattern: moving focus also chooses (automatic activation), except a
|
|
1038
|
+
// `disabledInteractive` button, which takes focus but cannot be chosen.
|
|
1039
|
+
if (radio && isEnabled(controls[next])) {
|
|
1040
|
+
const button = this._allExpressiveButtons().find((candidate) => candidate._hostElement === controls[next]);
|
|
1041
|
+
if (button && !this._selectionModel.isSelected(button))
|
|
1042
|
+
this._onButtonClick(button);
|
|
1043
|
+
}
|
|
910
1044
|
}
|
|
911
1045
|
// ---- ControlValueAccessor ----
|
|
912
1046
|
writeValue(value) {
|
|
@@ -936,7 +1070,8 @@ class MatExpButtonGroup {
|
|
|
936
1070
|
return;
|
|
937
1071
|
const isSelected = this._selectionModel.isSelected(button);
|
|
938
1072
|
if (isSelected) {
|
|
939
|
-
|
|
1073
|
+
const required = this.selectionRequired() || this._radio();
|
|
1074
|
+
if (required && this._selectionModel.selected.length === 1) {
|
|
940
1075
|
this._onTouched();
|
|
941
1076
|
return;
|
|
942
1077
|
}
|
|
@@ -986,6 +1121,34 @@ class MatExpButtonGroup {
|
|
|
986
1121
|
});
|
|
987
1122
|
this._cdr.markForCheck();
|
|
988
1123
|
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Applies radio semantics to every projected button in radio mode, or removes them. The Tab stop
|
|
1126
|
+
* comes from the same set the arrow keys move across (buttons that can take focus): the chosen
|
|
1127
|
+
* button when it can take focus, otherwise the first fully enabled button, otherwise the first
|
|
1128
|
+
* `disabledInteractive` one. A natively disabled button never takes focus.
|
|
1129
|
+
*/
|
|
1130
|
+
_syncRadioState() {
|
|
1131
|
+
const buttons = [...this._allExpressiveButtons()].sort((a, b) => a._hostElement.compareDocumentPosition(b._hostElement) & Node.DOCUMENT_POSITION_FOLLOWING
|
|
1132
|
+
? -1
|
|
1133
|
+
: 1);
|
|
1134
|
+
if (!this._radio()) {
|
|
1135
|
+
buttons.forEach((button) => button._setRadioState(null));
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1138
|
+
const checked = buttons.map((button) => button.toggle() === 'selected');
|
|
1139
|
+
const chosen = buttons.find((button, index) => checked[index] && canTakeFocus(button._hostElement));
|
|
1140
|
+
const tabStop = chosen ??
|
|
1141
|
+
buttons.find((button) => isEnabled(button._hostElement)) ??
|
|
1142
|
+
buttons.find((button) => canTakeFocus(button._hostElement)) ??
|
|
1143
|
+
null;
|
|
1144
|
+
buttons.forEach((button, index) => button._setRadioState({
|
|
1145
|
+
checked: checked[index],
|
|
1146
|
+
tabStop: button === tabStop,
|
|
1147
|
+
position: index + 1,
|
|
1148
|
+
size: buttons.length,
|
|
1149
|
+
}));
|
|
1150
|
+
this._cdr.markForCheck();
|
|
1151
|
+
}
|
|
989
1152
|
/** Derives `_value` from the current selection model state. */
|
|
990
1153
|
_updateValueFromModel() {
|
|
991
1154
|
const selected = this._selectionModel.selected;
|
|
@@ -997,7 +1160,7 @@ class MatExpButtonGroup {
|
|
|
997
1160
|
}
|
|
998
1161
|
}
|
|
999
1162
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.3", ngImport: i0, type: MatExpButtonGroup, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1000
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.2.3", type: MatExpButtonGroup, isStandalone: true, selector: "mat-exp-button-group", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, shape: { classPropertyName: "shape", publicName: "shape", isSignal: true, isRequired: false, transformFunction: null }, selection: { classPropertyName: "selection", publicName: "selection", isSignal: true, isRequired: false, transformFunction: null }, selectionRequired: { classPropertyName: "selectionRequired", publicName: "selectionRequired", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, disableBounce: { classPropertyName: "disableBounce", publicName: "disableBounce", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { disabled: "disabledChange", selectionChange: "selectionChange" }, host: {
|
|
1163
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.2.3", type: MatExpButtonGroup, isStandalone: true, selector: "mat-exp-button-group", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, shape: { classPropertyName: "shape", publicName: "shape", isSignal: true, isRequired: false, transformFunction: null }, selection: { classPropertyName: "selection", publicName: "selection", isSignal: true, isRequired: false, transformFunction: null }, selectionRequired: { classPropertyName: "selectionRequired", publicName: "selectionRequired", isSignal: true, isRequired: false, transformFunction: null }, semantics: { classPropertyName: "semantics", publicName: "semantics", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, disableBounce: { classPropertyName: "disableBounce", publicName: "disableBounce", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { disabled: "disabledChange", selectionChange: "selectionChange" }, host: { listeners: { "keydown": "_onGroupKeydown($event)" }, properties: { "attr.role": "_radio() ? \"radiogroup\" : \"group\"", "class": "matExpButtonGroupClass", "attr.data-variant": "variant()", "attr.data-selection": "selection()", "attr.data-size": "size()", "attr.data-shape": "shape()", "attr.data-appearance": "appearance()", "attr.data-disabled": "disabled()", "attr.aria-disabled": "disabled()" } }, providers: [
|
|
1001
1164
|
MAT_EXP_BUTTON_GROUP_VALUE_ACCESSOR,
|
|
1002
1165
|
{ provide: MAT_EXP_BUTTON_GROUP, useExisting: MatExpButtonGroup },
|
|
1003
1166
|
], queries: [{ propertyName: "_matExpButtons", predicate: i0.forwardRef(() => MatExpButton), isSignal: true }, { propertyName: "_matExpIconButtons", predicate: i0.forwardRef(() => MatExpIconButton), isSignal: true }], ngImport: i0, template: "<ng-content></ng-content>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
@@ -1008,7 +1171,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.3", ngImpor
|
|
|
1008
1171
|
MAT_EXP_BUTTON_GROUP_VALUE_ACCESSOR,
|
|
1009
1172
|
{ provide: MAT_EXP_BUTTON_GROUP, useExisting: MatExpButtonGroup },
|
|
1010
1173
|
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
1011
|
-
role: 'group',
|
|
1174
|
+
'[attr.role]': '_radio() ? "radiogroup" : "group"',
|
|
1012
1175
|
'[class]': 'matExpButtonGroupClass',
|
|
1013
1176
|
'[attr.data-variant]': 'variant()',
|
|
1014
1177
|
'[attr.data-selection]': 'selection()',
|
|
@@ -1019,7 +1182,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.3", ngImpor
|
|
|
1019
1182
|
'[attr.aria-disabled]': 'disabled()',
|
|
1020
1183
|
'(keydown)': '_onGroupKeydown($event)',
|
|
1021
1184
|
}, template: "<ng-content></ng-content>\n" }]
|
|
1022
|
-
}], ctorParameters: () => [], propDecorators: { size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], shape: [{ type: i0.Input, args: [{ isSignal: true, alias: "shape", required: false }] }], selection: [{ type: i0.Input, args: [{ isSignal: true, alias: "selection", required: false }] }], selectionRequired: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectionRequired", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], appearance: [{ type: i0.Input, args: [{ isSignal: true, alias: "appearance", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], disableBounce: [{ type: i0.Input, args: [{ isSignal: true, alias: "disableBounce", required: false }] }], selectionChange: [{ type: i0.Output, args: ["selectionChange"] }], value: [{
|
|
1185
|
+
}], ctorParameters: () => [], propDecorators: { size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], shape: [{ type: i0.Input, args: [{ isSignal: true, alias: "shape", required: false }] }], selection: [{ type: i0.Input, args: [{ isSignal: true, alias: "selection", required: false }] }], selectionRequired: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectionRequired", required: false }] }], semantics: [{ type: i0.Input, args: [{ isSignal: true, alias: "semantics", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], appearance: [{ type: i0.Input, args: [{ isSignal: true, alias: "appearance", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], disableBounce: [{ type: i0.Input, args: [{ isSignal: true, alias: "disableBounce", required: false }] }], selectionChange: [{ type: i0.Output, args: ["selectionChange"] }], value: [{
|
|
1023
1186
|
type: Input
|
|
1024
1187
|
}], _matExpButtons: [{ type: i0.ContentChildren, args: [forwardRef(() => MatExpButton), { isSignal: true }] }], _matExpIconButtons: [{ type: i0.ContentChildren, args: [forwardRef(() => MatExpIconButton), { isSignal: true }] }] } });
|
|
1025
1188
|
|
|
@@ -1061,6 +1224,63 @@ class MatExpButton {
|
|
|
1061
1224
|
...(ngDevMode ? [{ debugName: "toggle" }] : /* istanbul ignore next */ []));
|
|
1062
1225
|
value = model(/* @ts-ignore */
|
|
1063
1226
|
...(ngDevMode ? [undefined, { debugName: "value" }] : /* istanbul ignore next */ []));
|
|
1227
|
+
/**
|
|
1228
|
+
* This button's place in a radio-mode group (`semantics="radio"`), or `null` outside one.
|
|
1229
|
+
* @internal
|
|
1230
|
+
*/
|
|
1231
|
+
_radioState = signal(null, { ...(ngDevMode ? { debugName: "_radioState" } : /* istanbul ignore next */ {}), equal: (a, b) => a === b ||
|
|
1232
|
+
(!!a &&
|
|
1233
|
+
!!b &&
|
|
1234
|
+
a.checked === b.checked &&
|
|
1235
|
+
a.tabStop === b.tabStop &&
|
|
1236
|
+
a.position === b.position &&
|
|
1237
|
+
a.size === b.size) });
|
|
1238
|
+
/** What the consumer had on the host before radio mode, restored when it ends (null while not in radio mode). */
|
|
1239
|
+
/** The view that renders this button's host bindings (Material's `tabindex`), refreshed after a radio write. */
|
|
1240
|
+
_changeDetector = inject(ChangeDetectorRef);
|
|
1241
|
+
_savedRadioAttributes = null;
|
|
1242
|
+
/**
|
|
1243
|
+
* Applies or removes radio semantics for a radio-mode group. Outside radio mode the directive writes no ARIA, so a
|
|
1244
|
+
* consumer's own `role` or `aria-*` stays as authored; in radio mode it sets `role="radio"`, `aria-checked`,
|
|
1245
|
+
* `aria-posinset` and `aria-setsize` on the host itself and restores the consumer's values when the mode ends. The
|
|
1246
|
+
* roving Tab stop is written to Material's own `tabIndex` input, so Material keeps one `tabindex` binding (and its
|
|
1247
|
+
* disabled handling). The consumer's values are captured when radio mode starts: a consumer binding to `role` or
|
|
1248
|
+
* `aria-*` that changes while the button is in radio mode is not supported (it would overwrite the radio value, and
|
|
1249
|
+
* the captured value is what comes back).
|
|
1250
|
+
* @internal
|
|
1251
|
+
*/
|
|
1252
|
+
_setRadioState(state) {
|
|
1253
|
+
const host = this.materialHost;
|
|
1254
|
+
const element = this._hostElement;
|
|
1255
|
+
if (state) {
|
|
1256
|
+
if (!this._savedRadioAttributes) {
|
|
1257
|
+
this._savedRadioAttributes = {
|
|
1258
|
+
tabIndex: host.tabIndex,
|
|
1259
|
+
attributes: Object.fromEntries(RADIO_ATTRIBUTES.map((name) => [name, element.getAttribute(name)])),
|
|
1260
|
+
};
|
|
1261
|
+
}
|
|
1262
|
+
host.tabIndex = state.tabStop ? 0 : -1;
|
|
1263
|
+
element.setAttribute('role', 'radio');
|
|
1264
|
+
element.setAttribute('aria-checked', String(state.checked));
|
|
1265
|
+
element.setAttribute('aria-posinset', String(state.position));
|
|
1266
|
+
element.setAttribute('aria-setsize', String(state.size));
|
|
1267
|
+
}
|
|
1268
|
+
else if (this._savedRadioAttributes) {
|
|
1269
|
+
const saved = this._savedRadioAttributes;
|
|
1270
|
+
host.tabIndex = saved.tabIndex;
|
|
1271
|
+
for (const [name, value] of Object.entries(saved.attributes)) {
|
|
1272
|
+
if (value === null)
|
|
1273
|
+
element.removeAttribute(name);
|
|
1274
|
+
else
|
|
1275
|
+
element.setAttribute(name, value);
|
|
1276
|
+
}
|
|
1277
|
+
this._savedRadioAttributes = null;
|
|
1278
|
+
}
|
|
1279
|
+
this._radioState.set(state);
|
|
1280
|
+
// Material's `[attr.tabindex]` reads the plain `tabIndex` input, so mark this button's view: the new Tab stop
|
|
1281
|
+
// reaches the DOM in zoneless apps and OnPush hosts without relying on anything else to refresh the view.
|
|
1282
|
+
this._changeDetector.markForCheck();
|
|
1283
|
+
}
|
|
1064
1284
|
/**
|
|
1065
1285
|
* `aria-pressed`, derived from `toggle()`. `null` when the button does not
|
|
1066
1286
|
* participate in toggle behavior, so the attribute is omitted entirely
|
|
@@ -1069,6 +1289,9 @@ class MatExpButton {
|
|
|
1069
1289
|
* @internal
|
|
1070
1290
|
*/
|
|
1071
1291
|
ariaPressed = computed(() => {
|
|
1292
|
+
// A radio states its choice with `aria-checked` instead.
|
|
1293
|
+
if (this._radioState())
|
|
1294
|
+
return null;
|
|
1072
1295
|
const toggle = this.toggle();
|
|
1073
1296
|
return toggle === undefined ? null : toggle === 'selected' ? 'true' : 'false';
|
|
1074
1297
|
}, /* @ts-ignore */
|
|
@@ -9405,8 +9628,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.3", ngImpor
|
|
|
9405
9628
|
args: [{ providedIn: 'root' }]
|
|
9406
9629
|
}] });
|
|
9407
9630
|
|
|
9408
|
-
// | MatExpButtonGroupSelectionRequired;
|
|
9409
|
-
|
|
9410
9631
|
/*
|
|
9411
9632
|
* Public API Surface of mat-exp
|
|
9412
9633
|
*/
|