diff --git a/src/cdk-experimental/radio/radio.spec.ts b/src/cdk-experimental/radio/radio.spec.ts index 639962e85889..c60db3f54e8f 100644 --- a/src/cdk-experimental/radio/radio.spec.ts +++ b/src/cdk-experimental/radio/radio.spec.ts @@ -119,9 +119,9 @@ describe('CdkRadioGroup', () => { }); }); - it('should set aria-orientation to "horizontal"', () => { + it('should set aria-orientation to "vertical"', () => { setupDefaultRadioGroup(); - expect(radioGroupElement.getAttribute('aria-orientation')).toBe('horizontal'); + expect(radioGroupElement.getAttribute('aria-orientation')).toBe('vertical'); }); it('should set aria-disabled to false', () => { diff --git a/src/cdk-experimental/radio/radio.ts b/src/cdk-experimental/radio/radio.ts index 0fa65156c3e3..40553d753616 100644 --- a/src/cdk-experimental/radio/radio.ts +++ b/src/cdk-experimental/radio/radio.ts @@ -101,7 +101,7 @@ export class CdkRadioGroup { protected items = computed(() => this._cdkRadioButtons().map(radio => radio.pattern)); /** Whether the radio group is vertically or horizontally oriented. */ - orientation = input<'vertical' | 'horizontal'>('horizontal'); + orientation = input<'vertical' | 'horizontal'>('vertical'); /** Whether disabled items in the group should be skipped when navigating. */ skipDisabled = input(true, {transform: booleanAttribute}); diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio-active-descendant/cdk-radio-active-descendant-example.html b/src/components-examples/cdk-experimental/radio/cdk-radio-active-descendant/cdk-radio-active-descendant-example.html new file mode 100644 index 000000000000..4a37726ff265 --- /dev/null +++ b/src/components-examples/cdk-experimental/radio/cdk-radio-active-descendant/cdk-radio-active-descendant-example.html @@ -0,0 +1,21 @@ +
+ +
diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio-active-descendant/cdk-radio-active-descendant-example.ts b/src/components-examples/cdk-experimental/radio/cdk-radio-active-descendant/cdk-radio-active-descendant-example.ts new file mode 100644 index 000000000000..89b5a6b4b33b --- /dev/null +++ b/src/components-examples/cdk-experimental/radio/cdk-radio-active-descendant/cdk-radio-active-descendant-example.ts @@ -0,0 +1,50 @@ +import {Component} from '@angular/core'; +import {FormsModule} from '@angular/forms'; +import {CdkRadioGroup, CdkRadioButton} from '@angular/cdk-experimental/radio'; + +/** @title Active descendant radio group. */ +@Component({ + selector: 'cdk-radio-active-descendant-example', + exportAs: 'cdkRadioActiveDescendantExample', + templateUrl: 'cdk-radio-active-descendant-example.html', + standalone: true, + styleUrl: '../radio-common.css', + imports: [CdkRadioGroup, CdkRadioButton, FormsModule], +}) +export class CdkRadioActiveDescendantExample { + fruits = [ + 'Apple', + 'Apricot', + 'Banana', + 'Blackberry', + 'Blueberry', + 'Cantaloupe', + 'Cherry', + 'Clementine', + 'Cranberry', + 'Dates', + 'Figs', + 'Grapes', + 'Grapefruit', + 'Guava', + 'Kiwi', + 'Kumquat', + 'Lemon', + 'Lime', + 'Mandarin', + 'Mango', + 'Nectarine', + 'Orange', + 'Papaya', + 'Passion', + 'Peach', + 'Pear', + 'Pineapple', + 'Plum', + 'Pomegranate', + 'Raspberries', + 'Strawberry', + 'Tangerine', + 'Watermelon', + ]; +} diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio/cdk-radio-example.html b/src/components-examples/cdk-experimental/radio/cdk-radio-configurable/cdk-radio-configurable-example.html similarity index 64% rename from src/components-examples/cdk-experimental/radio/cdk-radio/cdk-radio-example.html rename to src/components-examples/cdk-experimental/radio/cdk-radio-configurable/cdk-radio-configurable-example.html index 43757b1bc610..4a0841e15224 100644 --- a/src/components-examples/cdk-experimental/radio/cdk-radio/cdk-radio-example.html +++ b/src/components-examples/cdk-experimental/radio/cdk-radio-configurable/cdk-radio-configurable-example.html @@ -3,21 +3,11 @@ Readonly Skip Disabled - - Selected Flavor - - None - @for (flavor of flavors; track flavor) { - {{flavor}} - } - - - Disabled Radio Options - @for (flavor of flavors; track flavor) { - {{flavor}} + @for (fruit of fruits; track fruit) { + {{fruit}} } @@ -42,20 +32,19 @@ diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio/cdk-radio-example.ts b/src/components-examples/cdk-experimental/radio/cdk-radio-configurable/cdk-radio-configurable-example.ts similarity index 53% rename from src/components-examples/cdk-experimental/radio/cdk-radio/cdk-radio-example.ts rename to src/components-examples/cdk-experimental/radio/cdk-radio-configurable/cdk-radio-configurable-example.ts index 6d0cc086b898..bcef87fea15a 100644 --- a/src/components-examples/cdk-experimental/radio/cdk-radio/cdk-radio-example.ts +++ b/src/components-examples/cdk-experimental/radio/cdk-radio-configurable/cdk-radio-configurable-example.ts @@ -5,12 +5,12 @@ import {MatFormFieldModule} from '@angular/material/form-field'; import {MatSelectModule} from '@angular/material/select'; import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; -/** @title Basic CDK Radio Group */ +/** @title Configurable CDK Radio Group */ @Component({ - selector: 'cdk-radio-example', - exportAs: 'cdkRadioExample', - templateUrl: 'cdk-radio-example.html', - styleUrl: 'cdk-radio-example.css', + selector: 'cdk-radio-configurable-example', + exportAs: 'cdkRadioConfigurableExample', + templateUrl: 'cdk-radio-configurable-example.html', + styleUrl: '../radio-common.css', standalone: true, imports: [ CdkRadioGroup, @@ -22,18 +22,51 @@ import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; ReactiveFormsModule, ], }) -export class CdkRadioExample { +export class CdkRadioConfigurableExample { orientation: 'vertical' | 'horizontal' = 'vertical'; disabled = new FormControl(false, {nonNullable: true}); - flavors = ['Vanilla', 'Chocolate', 'Strawberry', 'Mint Chip', 'Cookies & Cream', 'Rocky Road']; + fruits = [ + 'Apple', + 'Apricot', + 'Banana', + 'Blackberry', + 'Blueberry', + 'Cantaloupe', + 'Cherry', + 'Clementine', + 'Cranberry', + 'Dates', + 'Figs', + 'Grapes', + 'Grapefruit', + 'Guava', + 'Kiwi', + 'Kumquat', + 'Lemon', + 'Lime', + 'Mandarin', + 'Mango', + 'Nectarine', + 'Orange', + 'Papaya', + 'Passion', + 'Peach', + 'Pear', + 'Pineapple', + 'Plum', + 'Pomegranate', + 'Raspberries', + 'Strawberry', + 'Tangerine', + 'Watermelon', + ]; // New controls readonly = new FormControl(false, {nonNullable: true}); skipDisabled = new FormControl(true, {nonNullable: true}); focusMode: 'roving' | 'activedescendant' = 'roving'; - selectedValue: string | null = 'Vanilla'; // To control/reflect the radio group's value // Control for which radio options are individually disabled - disabledOptions: string[] = ['Chocolate']; + disabledOptions: string[] = ['Banana']; } diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio-disabled-focusable/cdk-radio-disabled-focusable-example.html b/src/components-examples/cdk-experimental/radio/cdk-radio-disabled-focusable/cdk-radio-disabled-focusable-example.html new file mode 100644 index 000000000000..40d78c7af080 --- /dev/null +++ b/src/components-examples/cdk-experimental/radio/cdk-radio-disabled-focusable/cdk-radio-disabled-focusable-example.html @@ -0,0 +1,22 @@ +
+ +
diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio-disabled-focusable/cdk-radio-disabled-focusable-example.ts b/src/components-examples/cdk-experimental/radio/cdk-radio-disabled-focusable/cdk-radio-disabled-focusable-example.ts new file mode 100644 index 000000000000..f5fa61f7d024 --- /dev/null +++ b/src/components-examples/cdk-experimental/radio/cdk-radio-disabled-focusable/cdk-radio-disabled-focusable-example.ts @@ -0,0 +1,51 @@ +import {Component} from '@angular/core'; +import {FormsModule} from '@angular/forms'; +import {CdkRadioGroup, CdkRadioButton} from '@angular/cdk-experimental/radio'; + +/** @title Radio group with disabled options that are focusable. */ +@Component({ + selector: 'cdk-radio-disabled-focusable-example', + exportAs: 'cdkRadioDisabledFocusableExample', + templateUrl: 'cdk-radio-disabled-focusable-example.html', + styleUrl: '../radio-common.css', + standalone: true, + imports: [CdkRadioGroup, CdkRadioButton, FormsModule], +}) +export class CdkRadioDisabledFocusableExample { + fruits = [ + 'Apple', + 'Apricot', + 'Banana', + 'Blackberry', + 'Blueberry', + 'Cantaloupe', + 'Cherry', + 'Clementine', + 'Cranberry', + 'Dates', + 'Figs', + 'Grapes', + 'Grapefruit', + 'Guava', + 'Kiwi', + 'Kumquat', + 'Lemon', + 'Lime', + 'Mandarin', + 'Mango', + 'Nectarine', + 'Orange', + 'Papaya', + 'Passion', + 'Peach', + 'Pear', + 'Pineapple', + 'Plum', + 'Pomegranate', + 'Raspberries', + 'Strawberry', + 'Tangerine', + 'Watermelon', + ]; + disabledFruits = ['Banana', 'Kiwi']; +} diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio-disabled-skipped/cdk-radio-disabled-skipped-example.html b/src/components-examples/cdk-experimental/radio/cdk-radio-disabled-skipped/cdk-radio-disabled-skipped-example.html new file mode 100644 index 000000000000..bbd845fc927d --- /dev/null +++ b/src/components-examples/cdk-experimental/radio/cdk-radio-disabled-skipped/cdk-radio-disabled-skipped-example.html @@ -0,0 +1,21 @@ +
+ +
diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio-disabled-skipped/cdk-radio-disabled-skipped-example.ts b/src/components-examples/cdk-experimental/radio/cdk-radio-disabled-skipped/cdk-radio-disabled-skipped-example.ts new file mode 100644 index 000000000000..621997762d3b --- /dev/null +++ b/src/components-examples/cdk-experimental/radio/cdk-radio-disabled-skipped/cdk-radio-disabled-skipped-example.ts @@ -0,0 +1,51 @@ +import {Component} from '@angular/core'; +import {FormsModule} from '@angular/forms'; +import {CdkRadioGroup, CdkRadioButton} from '@angular/cdk-experimental/radio'; + +/** @title Radio group with disabled options that are skipped. */ +@Component({ + selector: 'cdk-radio-disabled-skipped-example', + exportAs: 'cdkRadioDisabledSkippedExample', + templateUrl: 'cdk-radio-disabled-skipped-example.html', + styleUrl: '../radio-common.css', + standalone: true, + imports: [CdkRadioGroup, CdkRadioButton, FormsModule], +}) +export class CdkRadioDisabledSkippedExample { + fruits = [ + 'Apple', + 'Apricot', + 'Banana', + 'Blackberry', + 'Blueberry', + 'Cantaloupe', + 'Cherry', + 'Clementine', + 'Cranberry', + 'Dates', + 'Figs', + 'Grapes', + 'Grapefruit', + 'Guava', + 'Kiwi', + 'Kumquat', + 'Lemon', + 'Lime', + 'Mandarin', + 'Mango', + 'Nectarine', + 'Orange', + 'Papaya', + 'Passion', + 'Peach', + 'Pear', + 'Pineapple', + 'Plum', + 'Pomegranate', + 'Raspberries', + 'Strawberry', + 'Tangerine', + 'Watermelon', + ]; + disabledFruits = ['Banana', 'Kiwi']; +} diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio-disabled/cdk-radio-disabled-example.html b/src/components-examples/cdk-experimental/radio/cdk-radio-disabled/cdk-radio-disabled-example.html new file mode 100644 index 000000000000..9009f4cb43e4 --- /dev/null +++ b/src/components-examples/cdk-experimental/radio/cdk-radio-disabled/cdk-radio-disabled-example.html @@ -0,0 +1,20 @@ +
+ +

The entire radio group is disabled. Focus should not enter the group.

+
diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio-disabled/cdk-radio-disabled-example.ts b/src/components-examples/cdk-experimental/radio/cdk-radio-disabled/cdk-radio-disabled-example.ts new file mode 100644 index 000000000000..12f8f284b043 --- /dev/null +++ b/src/components-examples/cdk-experimental/radio/cdk-radio-disabled/cdk-radio-disabled-example.ts @@ -0,0 +1,50 @@ +import {Component} from '@angular/core'; +import {FormsModule} from '@angular/forms'; +import {CdkRadioGroup, CdkRadioButton} from '@angular/cdk-experimental/radio'; + +/** @title Disabled radio group. */ +@Component({ + selector: 'cdk-radio-disabled-example', + exportAs: 'cdkRadioDisabledExample', + templateUrl: 'cdk-radio-disabled-example.html', + styleUrl: '../radio-common.css', + standalone: true, + imports: [CdkRadioGroup, CdkRadioButton, FormsModule], +}) +export class CdkRadioDisabledExample { + fruits = [ + 'Apple', + 'Apricot', + 'Banana', + 'Blackberry', + 'Blueberry', + 'Cantaloupe', + 'Cherry', + 'Clementine', + 'Cranberry', + 'Dates', + 'Figs', + 'Grapes', + 'Grapefruit', + 'Guava', + 'Kiwi', + 'Kumquat', + 'Lemon', + 'Lime', + 'Mandarin', + 'Mango', + 'Nectarine', + 'Orange', + 'Papaya', + 'Passion', + 'Peach', + 'Pear', + 'Pineapple', + 'Plum', + 'Pomegranate', + 'Raspberries', + 'Strawberry', + 'Tangerine', + 'Watermelon', + ]; +} diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio-horizontal/cdk-radio-horizontal-example.html b/src/components-examples/cdk-experimental/radio/cdk-radio-horizontal/cdk-radio-horizontal-example.html new file mode 100644 index 000000000000..2b22dd8b2b7d --- /dev/null +++ b/src/components-examples/cdk-experimental/radio/cdk-radio-horizontal/cdk-radio-horizontal-example.html @@ -0,0 +1,21 @@ +
+ +
diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio-horizontal/cdk-radio-horizontal-example.ts b/src/components-examples/cdk-experimental/radio/cdk-radio-horizontal/cdk-radio-horizontal-example.ts new file mode 100644 index 000000000000..9436a5996402 --- /dev/null +++ b/src/components-examples/cdk-experimental/radio/cdk-radio-horizontal/cdk-radio-horizontal-example.ts @@ -0,0 +1,50 @@ +import {Component} from '@angular/core'; +import {FormsModule} from '@angular/forms'; +import {CdkRadioGroup, CdkRadioButton} from '@angular/cdk-experimental/radio'; + +/** @title Horizontal radio group. */ +@Component({ + selector: 'cdk-radio-horizontal-example', + exportAs: 'cdkRadioHorizontalExample', + templateUrl: 'cdk-radio-horizontal-example.html', + styleUrl: '../radio-common.css', + standalone: true, + imports: [CdkRadioGroup, CdkRadioButton, FormsModule], +}) +export class CdkRadioHorizontalExample { + fruits = [ + 'Apple', + 'Apricot', + 'Banana', + 'Blackberry', + 'Blueberry', + 'Cantaloupe', + 'Cherry', + 'Clementine', + 'Cranberry', + 'Dates', + 'Figs', + 'Grapes', + 'Grapefruit', + 'Guava', + 'Kiwi', + 'Kumquat', + 'Lemon', + 'Lime', + 'Mandarin', + 'Mango', + 'Nectarine', + 'Orange', + 'Papaya', + 'Passion', + 'Peach', + 'Pear', + 'Pineapple', + 'Plum', + 'Pomegranate', + 'Raspberries', + 'Strawberry', + 'Tangerine', + 'Watermelon', + ]; +} diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio-readonly/cdk-radio-readonly-example.html b/src/components-examples/cdk-experimental/radio/cdk-radio-readonly/cdk-radio-readonly-example.html new file mode 100644 index 000000000000..2eaf19aed13c --- /dev/null +++ b/src/components-examples/cdk-experimental/radio/cdk-radio-readonly/cdk-radio-readonly-example.html @@ -0,0 +1,22 @@ +
+ +

The radio group is navigable, but selection cannot be changed.

+
diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio-readonly/cdk-radio-readonly-example.ts b/src/components-examples/cdk-experimental/radio/cdk-radio-readonly/cdk-radio-readonly-example.ts new file mode 100644 index 000000000000..6b87938b7420 --- /dev/null +++ b/src/components-examples/cdk-experimental/radio/cdk-radio-readonly/cdk-radio-readonly-example.ts @@ -0,0 +1,50 @@ +import {Component} from '@angular/core'; +import {FormsModule} from '@angular/forms'; +import {CdkRadioGroup, CdkRadioButton} from '@angular/cdk-experimental/radio'; + +/** @title Readonly radio group. */ +@Component({ + selector: 'cdk-radio-readonly-example', + exportAs: 'cdkRadioReadonlyExample', + templateUrl: 'cdk-radio-readonly-example.html', + styleUrl: '../radio-common.css', + standalone: true, + imports: [CdkRadioGroup, CdkRadioButton, FormsModule], +}) +export class CdkRadioReadonlyExample { + fruits = [ + 'Apple', + 'Apricot', + 'Banana', + 'Blackberry', + 'Blueberry', + 'Cantaloupe', + 'Cherry', + 'Clementine', + 'Cranberry', + 'Dates', + 'Figs', + 'Grapes', + 'Grapefruit', + 'Guava', + 'Kiwi', + 'Kumquat', + 'Lemon', + 'Lime', + 'Mandarin', + 'Mango', + 'Nectarine', + 'Orange', + 'Papaya', + 'Passion', + 'Peach', + 'Pear', + 'Pineapple', + 'Plum', + 'Pomegranate', + 'Raspberries', + 'Strawberry', + 'Tangerine', + 'Watermelon', + ]; +} diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio-rtl-horizontal/cdk-radio-rtl-horizontal-example.html b/src/components-examples/cdk-experimental/radio/cdk-radio-rtl-horizontal/cdk-radio-rtl-horizontal-example.html new file mode 100644 index 000000000000..55d953ccb8a8 --- /dev/null +++ b/src/components-examples/cdk-experimental/radio/cdk-radio-rtl-horizontal/cdk-radio-rtl-horizontal-example.html @@ -0,0 +1,21 @@ +
+ +
diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio-rtl-horizontal/cdk-radio-rtl-horizontal-example.ts b/src/components-examples/cdk-experimental/radio/cdk-radio-rtl-horizontal/cdk-radio-rtl-horizontal-example.ts new file mode 100644 index 000000000000..d710ad2723e2 --- /dev/null +++ b/src/components-examples/cdk-experimental/radio/cdk-radio-rtl-horizontal/cdk-radio-rtl-horizontal-example.ts @@ -0,0 +1,50 @@ +import {Component} from '@angular/core'; +import {FormsModule} from '@angular/forms'; +import {CdkRadioGroup, CdkRadioButton} from '@angular/cdk-experimental/radio'; + +/** @title RTL horizontal radio group. */ +@Component({ + selector: 'cdk-radio-rtl-horizontal-example', + exportAs: 'cdkRadioRtlHorizontalExample', + templateUrl: 'cdk-radio-rtl-horizontal-example.html', + styleUrl: '../radio-common.css', + standalone: true, + imports: [CdkRadioGroup, CdkRadioButton, FormsModule], +}) +export class CdkRadioRtlHorizontalExample { + fruits = [ + 'Apple', + 'Apricot', + 'Banana', + 'Blackberry', + 'Blueberry', + 'Cantaloupe', + 'Cherry', + 'Clementine', + 'Cranberry', + 'Dates', + 'Figs', + 'Grapes', + 'Grapefruit', + 'Guava', + 'Kiwi', + 'Kumquat', + 'Lemon', + 'Lime', + 'Mandarin', + 'Mango', + 'Nectarine', + 'Orange', + 'Papaya', + 'Passion', + 'Peach', + 'Pear', + 'Pineapple', + 'Plum', + 'Pomegranate', + 'Raspberries', + 'Strawberry', + 'Tangerine', + 'Watermelon', + ]; +} diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio-standard/cdk-radio-standard-example.html b/src/components-examples/cdk-experimental/radio/cdk-radio-standard/cdk-radio-standard-example.html new file mode 100644 index 000000000000..d4f2d1b0eaec --- /dev/null +++ b/src/components-examples/cdk-experimental/radio/cdk-radio-standard/cdk-radio-standard-example.html @@ -0,0 +1,18 @@ +
+ +
diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio-standard/cdk-radio-standard-example.ts b/src/components-examples/cdk-experimental/radio/cdk-radio-standard/cdk-radio-standard-example.ts new file mode 100644 index 000000000000..e11121376b0f --- /dev/null +++ b/src/components-examples/cdk-experimental/radio/cdk-radio-standard/cdk-radio-standard-example.ts @@ -0,0 +1,50 @@ +import {Component} from '@angular/core'; +import {FormsModule} from '@angular/forms'; +import {CdkRadioGroup, CdkRadioButton} from '@angular/cdk-experimental/radio'; + +/** @title Basic radio group. */ +@Component({ + selector: 'cdk-radio-standard-example', + exportAs: 'cdkRadioStandardExample', + templateUrl: 'cdk-radio-standard-example.html', + styleUrl: '../radio-common.css', + standalone: true, + imports: [CdkRadioGroup, CdkRadioButton, FormsModule], +}) +export class CdkRadioStandardExample { + fruits = [ + 'Apple', + 'Apricot', + 'Banana', + 'Blackberry', + 'Blueberry', + 'Cantaloupe', + 'Cherry', + 'Clementine', + 'Cranberry', + 'Dates', + 'Figs', + 'Grapes', + 'Grapefruit', + 'Guava', + 'Kiwi', + 'Kumquat', + 'Lemon', + 'Lime', + 'Mandarin', + 'Mango', + 'Nectarine', + 'Orange', + 'Papaya', + 'Passion', + 'Peach', + 'Pear', + 'Pineapple', + 'Plum', + 'Pomegranate', + 'Raspberries', + 'Strawberry', + 'Tangerine', + 'Watermelon', + ]; +} diff --git a/src/components-examples/cdk-experimental/radio/index.ts b/src/components-examples/cdk-experimental/radio/index.ts index 722738a66748..f1debf039fdd 100644 --- a/src/components-examples/cdk-experimental/radio/index.ts +++ b/src/components-examples/cdk-experimental/radio/index.ts @@ -1 +1,9 @@ -export {CdkRadioExample} from './cdk-radio/cdk-radio-example'; +export {CdkRadioStandardExample} from './cdk-radio-standard/cdk-radio-standard-example'; +export {CdkRadioHorizontalExample} from './cdk-radio-horizontal/cdk-radio-horizontal-example'; +export {CdkRadioRtlHorizontalExample} from './cdk-radio-rtl-horizontal/cdk-radio-rtl-horizontal-example'; +export {CdkRadioActiveDescendantExample} from './cdk-radio-active-descendant/cdk-radio-active-descendant-example'; +export {CdkRadioDisabledFocusableExample} from './cdk-radio-disabled-focusable/cdk-radio-disabled-focusable-example'; +export {CdkRadioDisabledSkippedExample} from './cdk-radio-disabled-skipped/cdk-radio-disabled-skipped-example'; +export {CdkRadioReadonlyExample} from './cdk-radio-readonly/cdk-radio-readonly-example'; +export {CdkRadioDisabledExample} from './cdk-radio-disabled/cdk-radio-disabled-example'; +export {CdkRadioConfigurableExample} from './cdk-radio-configurable/cdk-radio-configurable-example'; diff --git a/src/components-examples/cdk-experimental/radio/cdk-radio/cdk-radio-example.css b/src/components-examples/cdk-experimental/radio/radio-common.css similarity index 96% rename from src/components-examples/cdk-experimental/radio/cdk-radio/cdk-radio-example.css rename to src/components-examples/cdk-experimental/radio/radio-common.css index d2ed35cc00c0..d9f137fc65c2 100644 --- a/src/components-examples/cdk-experimental/radio/cdk-radio/cdk-radio-example.css +++ b/src/components-examples/cdk-experimental/radio/radio-common.css @@ -9,14 +9,13 @@ gap: 4px; margin: 0; padding: 8px; - max-height: 50vh; + max-height: 300px; border: 1px solid var(--mat-sys-outline); border-radius: var(--mat-sys-corner-extra-small); display: flex; list-style: none; flex-direction: column; overflow: scroll; - user-select: none; } .example-radio-group[aria-orientation='horizontal'] { @@ -28,6 +27,11 @@ pointer-events: none; } +.example-radio-group label { + padding: 16px; + flex-shrink: 0; +} + .example-radio-button { gap: 16px; padding: 16px; diff --git a/src/dev-app/cdk-experimental-radio/BUILD.bazel b/src/dev-app/cdk-experimental-radio/BUILD.bazel index bbd2644b2cf5..a63cbccf7b22 100644 --- a/src/dev-app/cdk-experimental-radio/BUILD.bazel +++ b/src/dev-app/cdk-experimental-radio/BUILD.bazel @@ -5,17 +5,12 @@ package(default_visibility = ["//visibility:public"]) ng_project( name = "cdk-experimental-radio", srcs = glob(["**/*.ts"]), - assets = ["cdk-radio-demo.html"], + assets = [ + "cdk-radio-demo.html", + ":cdk-radio-demo.css", + ], deps = [ "//:node_modules/@angular/core", "//src/components-examples/cdk-experimental/radio", ], ) - -filegroup( - name = "source-files", - srcs = glob([ - "**/*.ts", - "**/*.html", - ]), -) diff --git a/src/dev-app/cdk-experimental-radio/cdk-radio-demo.css b/src/dev-app/cdk-experimental-radio/cdk-radio-demo.css new file mode 100644 index 000000000000..20307209d88a --- /dev/null +++ b/src/dev-app/cdk-experimental-radio/cdk-radio-demo.css @@ -0,0 +1,20 @@ +.example-radio-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(500px, 1fr)); + gap: 20px; +} + +.example-radio-container { + width: 500px; + display: flex; + flex-direction: column; + justify-content: flex-start; +} + +.example-configurable-radio-container { + padding-top: 40px; +} + +h4 { + height: 36px; +} diff --git a/src/dev-app/cdk-experimental-radio/cdk-radio-demo.html b/src/dev-app/cdk-experimental-radio/cdk-radio-demo.html index ee2ca03aa2b4..de80f235680a 100644 --- a/src/dev-app/cdk-experimental-radio/cdk-radio-demo.html +++ b/src/dev-app/cdk-experimental-radio/cdk-radio-demo.html @@ -1,4 +1,54 @@
-

Radio using UI Patterns

- +
+
+

Standard - Able to navigate to and select an radio button.

+ +
+ +
+

Horizontal Orientation - Able to navigate using left and right arrow keys.

+ +
+ +
+

RTL & Horizontal Orientation - Able to navigate as expected.

+ +
+ +
+

Active Descendant - Able to navigate to and select a radio button.

+ +
+ +
+

+ Disabled Options are Focusable - Able to navigate to a disabled radio button. Disabled radio + buttons are not selectable. +

+ +
+ +
+

+ Disabled Options are Skipped - Disabled radio buttons are skipped over. Disabled radio + buttons are not selectable. +

+ +
+ +
+

Readonly - The radio group is navigable but selection state cannot be changed.

+ +
+ +
+

Disabled - Focus should land on the listbox instead of an option.

+ +
+
+ +
+

Configurable CDK Radio Group

+ +
diff --git a/src/dev-app/cdk-experimental-radio/cdk-radio-demo.ts b/src/dev-app/cdk-experimental-radio/cdk-radio-demo.ts index e170b556d703..6f80fe5e9564 100644 --- a/src/dev-app/cdk-experimental-radio/cdk-radio-demo.ts +++ b/src/dev-app/cdk-experimental-radio/cdk-radio-demo.ts @@ -6,12 +6,34 @@ * found in the LICENSE file at https://angular.dev/license */ -import {ChangeDetectionStrategy, Component} from '@angular/core'; -import {CdkRadioExample} from '@angular/components-examples/cdk-experimental/radio'; +import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core'; +import { + CdkRadioStandardExample, + CdkRadioHorizontalExample, + CdkRadioRtlHorizontalExample, + CdkRadioActiveDescendantExample, + CdkRadioDisabledFocusableExample, + CdkRadioDisabledSkippedExample, + CdkRadioReadonlyExample, + CdkRadioDisabledExample, +} from '@angular/components-examples/cdk-experimental/radio'; +import {CdkRadioConfigurableExample} from '../../components-examples/cdk-experimental/radio/cdk-radio-configurable/cdk-radio-configurable-example'; @Component({ templateUrl: 'cdk-radio-demo.html', - imports: [CdkRadioExample], + imports: [ + CdkRadioStandardExample, + CdkRadioHorizontalExample, + CdkRadioRtlHorizontalExample, + CdkRadioActiveDescendantExample, + CdkRadioDisabledFocusableExample, + CdkRadioDisabledSkippedExample, + CdkRadioReadonlyExample, + CdkRadioDisabledExample, + CdkRadioConfigurableExample, + ], + styleUrl: './cdk-radio-demo.css', + encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, }) export class CdkExperimentalRadioDemo {}