From d05caca6aea2096971d191c994787cef103f695e Mon Sep 17 00:00:00 2001 From: Tommmaso Menga Date: Wed, 23 Oct 2024 10:23:36 +0200 Subject: [PATCH] fix(sbb-radio-button): pr feedbacks --- .../form-associated-radio-button-mixin.ts | 24 +++++++++++++------ .../common/radio-button-common.ts | 4 ++-- .../radio-button/radio-button-panel/readme.md | 6 ++--- .../radio-button/radio-button/readme.md | 6 ++--- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/elements/core/mixins/form-associated-radio-button-mixin.ts b/src/elements/core/mixins/form-associated-radio-button-mixin.ts index b75acfa8f8..1990137507 100644 --- a/src/elements/core/mixins/form-associated-radio-button-mixin.ts +++ b/src/elements/core/mixins/form-associated-radio-button-mixin.ts @@ -38,7 +38,8 @@ export declare class SbbFormAssociatedRadioButtonMixinType } /** - * TODO add docs (maybe move to new file) + * A static registry that holds a collection of `radio-buttons`, grouped by `name`. + * It is mainly used to support the standalone groups of radios. * @internal */ export class RadioButtonRegistry { @@ -46,6 +47,9 @@ export class RadioButtonRegistry { private constructor() {} + /** + * Adds @radio to the @groupName group. Checks for duplicates + */ public static addRadioToGroup( radio: SbbFormAssociatedRadioButtonMixinType, groupName: string, @@ -60,6 +64,9 @@ export class RadioButtonRegistry { this._registry[groupName].push(radio); } + /** + * Removes @radio from the @groupName group. + */ public static removeRadioFromGroup( radio: SbbFormAssociatedRadioButtonMixinType, groupName: string, @@ -75,6 +82,9 @@ export class RadioButtonRegistry { } } + /** + * Return an array of radios that belong to @groupName + */ public static getRadios(groupName: string): SbbFormAssociatedRadioButtonMixinType[] { return this._registry[groupName] ?? []; } @@ -180,7 +190,7 @@ export const SbbFormAssociatedRadioButtonMixin = r.checked && !r.disabled && !r.formDisabled); const focusableIndex = checkedIndex !== -1 @@ -275,7 +285,7 @@ export const SbbFormAssociatedRadioButtonMixin = ( `:is(sbb-radio-button, sbb-radio-button-panel)[name="${groupName}"]`, @@ -289,7 +299,7 @@ export const SbbFormAssociatedRadioButtonMixin = !r.disabled && !r.formDisabled, ); const current: number = enabledRadios.indexOf(this); diff --git a/src/elements/radio-button/common/radio-button-common.ts b/src/elements/radio-button/common/radio-button-common.ts index 8fa320a4ef..5065e03e2f 100644 --- a/src/elements/radio-button/common/radio-button-common.ts +++ b/src/elements/radio-button/common/radio-button-common.ts @@ -88,8 +88,8 @@ export const SbbRadioButtonCommonElementMixin =