UNPKG

@jupyter/web-components

Version:

A component library for building extensions in Jupyter frontends.

51 lines (50 loc) 1.74 kB
// Copyright (c) Jupyter Development Team. // Copyright (c) Microsoft Corporation. // Distributed under the terms of the Modified BSD License. import { RadioGroup, radioGroupTemplate as template } from '@microsoft/fast-foundation'; import { radioGroupStyles as styles } from './radio-group.styles.js'; import { Observable } from '@microsoft/fast-element'; /** * RadioGroup class * @public * @tagname jp-radio-group */ class JupyterRadioGroup extends RadioGroup { constructor() { super(); // FIXME work around for private slottedRadioButtonsChanged const notifier = Observable.getNotifier(this); const handler = { handleChange(source, propertyName) { if (propertyName === 'slottedRadioButtons') { source.ariaInvalidChanged(); } } }; notifier.subscribe(handler, 'slottedRadioButtons'); } ariaInvalidChanged() { if (this.slottedRadioButtons) { this.slottedRadioButtons.forEach(radio => { var _a; radio.setAttribute('aria-invalid', (_a = this.getAttribute('aria-invalid')) !== null && _a !== void 0 ? _a : 'false'); }); } } } /** * A function that returns a {@link @microsoft/fast-foundation#RadioGroup} registration for configuring the component with a DesignSystem. * Implements {@link @microsoft/fast-foundation#radioGroupTemplate} * * * @public * @remarks * Generates HTML Element: `<jp-radio-group>` */ export const jpRadioGroup = JupyterRadioGroup.compose({ baseName: 'radio-group', baseClass: RadioGroup, template, styles }); export { JupyterRadioGroup as RadioGroup, styles as radioGroupStyles };