@material/web 1.5.1 → 1.5.2-nightly.5df9410.0
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/button/internal/button.d.ts +1 -1
- package/button/internal/button.js +2 -3
- package/button/internal/button.js.map +1 -1
- package/checkbox/internal/checkbox.d.ts +1 -1
- package/checkbox/internal/checkbox.js +2 -5
- package/checkbox/internal/checkbox.js.map +1 -1
- package/chips/internal/chip.d.ts +3 -1
- package/chips/internal/chip.js +4 -5
- package/chips/internal/chip.js.map +1 -1
- package/dialog/internal/dialog.d.ts +3 -1
- package/dialog/internal/dialog.js +4 -5
- package/dialog/internal/dialog.js.map +1 -1
- package/fab/internal/shared.d.ts +3 -1
- package/fab/internal/shared.js +4 -5
- package/fab/internal/shared.js.map +1 -1
- package/field/internal/field.js +2 -2
- package/field/internal/field.js.map +1 -1
- package/iconbutton/internal/icon-button.d.ts +1 -1
- package/iconbutton/internal/icon-button.js +2 -3
- package/iconbutton/internal/icon-button.js.map +1 -1
- package/internal/aria/aria.js +1 -1
- package/internal/aria/aria.js.map +1 -1
- package/internal/aria/delegate.d.ts +34 -17
- package/internal/aria/delegate.js +149 -26
- package/internal/aria/delegate.js.map +1 -1
- package/labs/navigationbar/internal/navigation-bar.d.ts +3 -1
- package/labs/navigationbar/internal/navigation-bar.js +4 -5
- package/labs/navigationbar/internal/navigation-bar.js.map +1 -1
- package/labs/navigationdrawer/internal/navigation-drawer-modal.d.ts +3 -1
- package/labs/navigationdrawer/internal/navigation-drawer-modal.js +4 -5
- package/labs/navigationdrawer/internal/navigation-drawer-modal.js.map +1 -1
- package/labs/navigationdrawer/internal/navigation-drawer.d.ts +3 -1
- package/labs/navigationdrawer/internal/navigation-drawer.js +4 -5
- package/labs/navigationdrawer/internal/navigation-drawer.js.map +1 -1
- package/labs/navigationtab/internal/navigation-tab.d.ts +3 -1
- package/labs/navigationtab/internal/navigation-tab.js +4 -5
- package/labs/navigationtab/internal/navigation-tab.js.map +1 -1
- package/labs/segmentedbutton/internal/segmented-button.d.ts +3 -1
- package/labs/segmentedbutton/internal/segmented-button.js +4 -5
- package/labs/segmentedbutton/internal/segmented-button.js.map +1 -1
- package/labs/segmentedbuttonset/internal/segmented-button-set.d.ts +3 -1
- package/labs/segmentedbuttonset/internal/segmented-button-set.js +4 -5
- package/labs/segmentedbuttonset/internal/segmented-button-set.js.map +1 -1
- package/list/internal/listitem/list-item.d.ts +3 -1
- package/list/internal/listitem/list-item.js +4 -5
- package/list/internal/listitem/list-item.js.map +1 -1
- package/menu/internal/menuitem/menu-item.d.ts +3 -1
- package/menu/internal/menuitem/menu-item.js +4 -5
- package/menu/internal/menuitem/menu-item.js.map +1 -1
- package/migrations/v2/query-selector-aria.d.ts +22 -0
- package/migrations/v2/query-selector-aria.js +30 -0
- package/migrations/v2/query-selector-aria.js.map +1 -0
- package/package.json +1 -1
- package/progress/internal/progress.d.ts +3 -1
- package/progress/internal/progress.js +4 -5
- package/progress/internal/progress.js.map +1 -1
- package/select/internal/select.d.ts +1 -1
- package/select/internal/select.js +2 -5
- package/select/internal/select.js.map +1 -1
- package/select/internal/selectoption/select-option.d.ts +2 -1
- package/select/internal/selectoption/select-option.js +4 -5
- package/select/internal/selectoption/select-option.js.map +1 -1
- package/slider/internal/slider.d.ts +1 -1
- package/slider/internal/slider.js +3 -6
- package/slider/internal/slider.js.map +1 -1
- package/switch/internal/switch.d.ts +1 -1
- package/switch/internal/switch.js +2 -5
- package/switch/internal/switch.js.map +1 -1
- package/tabs/internal/tabs.js +1 -1
- package/tabs/internal/tabs.js.map +1 -1
- package/textfield/internal/text-field.d.ts +1 -1
- package/textfield/internal/text-field.js +2 -5
- package/textfield/internal/text-field.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.js","sourceRoot":"","sources":["field.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EACL,IAAI,EACJ,UAAU,EACV,OAAO,EAEP,MAAM,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AO,EAAC,CAAC;wCAAmB;AAClB;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;uCAAkB;AACjB;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;wCAAmB;AACH;IAAzC,QAAQ,CAAC,EAAC,SAAS,EAAE,iBAAiB,EAAC,CAAC;6CAAqB;AACzB;IAApC,QAAQ,CAAC,EAAC,SAAS,EAAE,YAAY,EAAC,CAAC;wCAAgB;AAC1B;IAAzB,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;oCAAY;AACX;IAAzB,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;kCAAU;AAKgB;IAAlD,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAC,CAAC;uCAAkB;AAKnB;IAAhD,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAC,CAAC;qCAAgB;AAG/C;IADhB,qBAAqB,CAAC,EAAC,IAAI,EAAE,kBAAkB,EAAC,CAAC;qDACM;AAmBvC;IAAhB,KAAK,EAAE;0CAA6B;AAOpB;IAAhB,KAAK,EAAE;gDAAmC;AAC1B;IAAhB,KAAK,EAAE;iDAAoC;AAE3B;IADhB,KAAK,CAAC,iBAAiB,CAAC;8CAC6B;AACZ;IAAzC,KAAK,CAAC,gBAAgB,CAAC;6CAAsD;AACxC;IAArC,KAAK,CAAC,YAAY,CAAC;0CAAmD","sourcesContent":["/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n html,\n LitElement,\n nothing,\n PropertyValues,\n render,\n TemplateResult,\n} from 'lit';\nimport {property, query, queryAssignedElements, state} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\n\nimport {EASING} from '../../internal/motion/animation.js';\n\n/**\n * A field component.\n */\nexport class Field extends LitElement {\n @property({type: Boolean}) disabled = false;\n @property({type: Boolean}) error = false;\n @property({type: Boolean}) focused = false;\n @property() label = '';\n @property({type: Boolean, attribute: 'no-asterisk'}) noAsterisk = false;\n @property({type: Boolean}) populated = false;\n @property({type: Boolean}) required = false;\n @property({type: Boolean}) resizable = false;\n @property({attribute: 'supporting-text'}) supportingText = '';\n @property({attribute: 'error-text'}) errorText = '';\n @property({type: Number}) count = -1;\n @property({type: Number}) max = -1;\n\n /**\n * Whether or not the field has leading content.\n */\n @property({type: Boolean, attribute: 'has-start'}) hasStart = false;\n\n /**\n * Whether or not the field has trailing content.\n */\n @property({type: Boolean, attribute: 'has-end'}) hasEnd = false;\n\n @queryAssignedElements({slot: 'aria-describedby'})\n private readonly slottedAriaDescribedBy!: HTMLElement[];\n\n private get counterText() {\n // Count and max are typed as number, but can be set to null when Lit removes\n // their attributes. These getters coerce back to a number for calculations.\n const countAsNumber = this.count ?? -1;\n const maxAsNumber = this.max ?? -1;\n // Counter does not show if count is negative, or max is negative or 0.\n if (countAsNumber < 0 || maxAsNumber <= 0) {\n return '';\n }\n\n return `${countAsNumber} / ${maxAsNumber}`;\n }\n\n private get supportingOrErrorText() {\n return this.error && this.errorText ? this.errorText : this.supportingText;\n }\n\n @state() private isAnimating = false;\n private labelAnimation?: Animation;\n /**\n * When set to true, the error text's `role=\"alert\"` will be removed, then\n * re-added after an animation frame. This will re-announce an error message\n * to screen readers.\n */\n @state() private refreshErrorAlert = false;\n @state() private disableTransitions = false;\n @query('.label.floating')\n private readonly floatingLabelEl!: HTMLElement | null;\n @query('.label.resting') private readonly restingLabelEl!: HTMLElement | null;\n @query('.container') private readonly containerEl!: HTMLElement | null;\n\n /**\n * Re-announces the field's error supporting text to screen readers.\n *\n * Error text announces to screen readers anytime it is visible and changes.\n * Use the method to re-announce the message when the text has not changed,\n * but announcement is still needed (such as for `reportValidity()`).\n */\n reannounceError() {\n this.refreshErrorAlert = true;\n }\n\n protected override update(props: PropertyValues<Field>) {\n // Client-side property updates\n const isDisabledChanging =\n props.has('disabled') && props.get('disabled') !== undefined;\n if (isDisabledChanging) {\n this.disableTransitions = true;\n }\n\n // When disabling, remove focus styles if focused.\n if (this.disabled && this.focused) {\n props.set('focused', true);\n this.focused = false;\n }\n\n // Animate if focused or populated change.\n this.animateLabelIfNeeded({\n wasFocused: props.get('focused'),\n wasPopulated: props.get('populated'),\n });\n\n super.update(props);\n }\n\n protected override render() {\n const floatingLabel = this.renderLabel(/*isFloating*/ true);\n const restingLabel = this.renderLabel(/*isFloating*/ false);\n const outline = this.renderOutline?.(floatingLabel);\n const classes = {\n 'disabled': this.disabled,\n 'disable-transitions': this.disableTransitions,\n 'error': this.error && !this.disabled,\n 'focused': this.focused,\n 'with-start': this.hasStart,\n 'with-end': this.hasEnd,\n 'populated': this.populated,\n 'resizable': this.resizable,\n 'required': this.required,\n 'no-label': !this.label,\n };\n\n return html`\n <div class=\"field ${classMap(classes)}\">\n <div class=\"container-overflow\">\n ${this.renderBackground?.()} ${this.renderIndicator?.()} ${outline}\n <div class=\"container\">\n <div class=\"start\">\n <slot name=\"start\"></slot>\n </div>\n <div class=\"middle\">\n <div class=\"label-wrapper\">\n ${restingLabel} ${outline ? nothing : floatingLabel}\n </div>\n <div class=\"content\">\n <slot></slot>\n </div>\n </div>\n <div class=\"end\">\n <slot name=\"end\"></slot>\n </div>\n </div>\n </div>\n ${this.renderSupportingText()}\n </div>\n `;\n }\n\n protected override updated(changed: PropertyValues<Field>) {\n if (\n changed.has('supportingText') ||\n changed.has('errorText') ||\n changed.has('count') ||\n changed.has('max')\n ) {\n this.updateSlottedAriaDescribedBy();\n }\n\n if (this.refreshErrorAlert) {\n // The past render cycle removed the role=\"alert\" from the error message.\n // Re-add it after an animation frame to re-announce the error.\n requestAnimationFrame(() => {\n this.refreshErrorAlert = false;\n });\n }\n\n if (this.disableTransitions) {\n requestAnimationFrame(() => {\n this.disableTransitions = false;\n });\n }\n }\n\n protected renderBackground?(): TemplateResult;\n protected renderIndicator?(): TemplateResult;\n protected renderOutline?(floatingLabel: unknown): TemplateResult;\n\n private renderSupportingText() {\n const {supportingOrErrorText, counterText} = this;\n if (!supportingOrErrorText && !counterText) {\n return nothing;\n }\n\n // Always render the supporting text span so that our `space-around`\n // container puts the counter at the end.\n const start = html`<span>${supportingOrErrorText}</span>`;\n // Conditionally render counter so we don't render the extra `gap`.\n // TODO(b/244473435): add aria-label and announcements\n const end = counterText\n ? html`<span class=\"counter\">${counterText}</span>`\n : nothing;\n\n // Announce if there is an error and error text visible.\n // If refreshErrorAlert is true, do not announce. This will remove the\n // role=\"alert\" attribute. Another render cycle will happen after an\n // animation frame to re-add the role.\n const shouldErrorAnnounce =\n this.error && this.errorText && !this.refreshErrorAlert;\n const role = shouldErrorAnnounce ? 'alert' : nothing;\n return html`\n <div class=\"supporting-text\" role=${role}>${start}${end}</div>\n <slot\n name=\"aria-describedby\"\n @slotchange=${this.updateSlottedAriaDescribedBy}></slot>\n `;\n }\n\n private updateSlottedAriaDescribedBy() {\n for (const element of this.slottedAriaDescribedBy) {\n render(html`${this.supportingOrErrorText} ${this.counterText}`, element);\n element.setAttribute('hidden', '');\n }\n }\n\n private renderLabel(isFloating: boolean) {\n if (!this.label) {\n return nothing;\n }\n\n let visible: boolean;\n if (isFloating) {\n // Floating label is visible when focused/populated or when animating.\n visible = this.focused || this.populated || this.isAnimating;\n } else {\n // Resting label is visible when unfocused. It is never visible while\n // animating.\n visible = !this.focused && !this.populated && !this.isAnimating;\n }\n\n const classes = {\n 'hidden': !visible,\n 'floating': isFloating,\n 'resting': !isFloating,\n };\n\n // Add '*' if a label is present and the field is required\n const labelText = `${this.label}${\n this.required && !this.noAsterisk ? '*' : ''\n }`;\n\n return html`\n <span class=\"label ${classMap(classes)}\" aria-hidden=${!visible}\n >${labelText}</span\n >\n `;\n }\n\n private animateLabelIfNeeded({\n wasFocused,\n wasPopulated,\n }: {\n wasFocused?: boolean;\n wasPopulated?: boolean;\n }) {\n if (!this.label) {\n return;\n }\n\n wasFocused ??= this.focused;\n wasPopulated ??= this.populated;\n const wasFloating = wasFocused || wasPopulated;\n const shouldBeFloating = this.focused || this.populated;\n if (wasFloating === shouldBeFloating) {\n return;\n }\n\n this.isAnimating = true;\n this.labelAnimation?.cancel();\n\n // Only one label is visible at a time for clearer text rendering.\n // The floating label is visible and used during animation. At the end of\n // the animation, it will either remain visible (if floating) or hide and\n // the resting label will be shown.\n //\n // We don't use forward filling because if the dimensions of the text field\n // change (leading icon removed, density changes, etc), then the animation\n // will be inaccurate.\n //\n // Re-calculating the animation each time will prevent any visual glitches\n // from appearing.\n // TODO(b/241113345): use animation tokens\n this.labelAnimation = this.floatingLabelEl?.animate(\n this.getLabelKeyframes(),\n {duration: 150, easing: EASING.STANDARD},\n );\n\n this.labelAnimation?.addEventListener('finish', () => {\n // At the end of the animation, update the visible label.\n this.isAnimating = false;\n });\n }\n\n private getLabelKeyframes() {\n const {floatingLabelEl, restingLabelEl} = this;\n if (!floatingLabelEl || !restingLabelEl) {\n return [];\n }\n\n const {\n x: floatingX,\n y: floatingY,\n height: floatingHeight,\n } = floatingLabelEl.getBoundingClientRect();\n const {\n x: restingX,\n y: restingY,\n height: restingHeight,\n } = restingLabelEl.getBoundingClientRect();\n const floatingScrollWidth = floatingLabelEl.scrollWidth;\n const restingScrollWidth = restingLabelEl.scrollWidth;\n // Scale by width ratio instead of font size since letter-spacing will scale\n // incorrectly. Using the width we can better approximate the adjusted\n // scale and compensate for tracking and overflow.\n // (use scrollWidth instead of width to account for clipped labels)\n const scale = restingScrollWidth / floatingScrollWidth;\n const xDelta = restingX - floatingX;\n // The line-height of the resting and floating label are different. When\n // we move the floating label down to the resting label's position, it won't\n // exactly match because of this. We need to adjust by half of what the\n // final scaled floating label's height will be.\n const yDelta =\n restingY -\n floatingY +\n Math.round((restingHeight - floatingHeight * scale) / 2);\n\n // Create the two transforms: floating to resting (using the calculations\n // above), and resting to floating (re-setting the transform to initial\n // values).\n const restTransform = `translateX(${xDelta}px) translateY(${yDelta}px) scale(${scale})`;\n const floatTransform = `translateX(0) translateY(0) scale(1)`;\n\n // Constrain the floating labels width to a scaled percentage of the\n // resting label's width. This will prevent long clipped labels from\n // overflowing the container.\n const restingClientWidth = restingLabelEl.clientWidth;\n const isRestingClipped = restingScrollWidth > restingClientWidth;\n const width = isRestingClipped ? `${restingClientWidth / scale}px` : '';\n if (this.focused || this.populated) {\n return [\n {transform: restTransform, width},\n {transform: floatTransform, width},\n ];\n }\n\n return [\n {transform: floatTransform, width},\n {transform: restTransform, width},\n ];\n }\n\n getSurfacePositionClientRect() {\n return this.containerEl!.getBoundingClientRect();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"field.js","sourceRoot":"","sources":["field.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EACL,IAAI,EACJ,UAAU,EACV,OAAO,EAEP,MAAM,GAEP,MAAM,KAAK,CAAC;AACb,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAErD,OAAO,EAAC,MAAM,EAAC,MAAM,oCAAoC,CAAC;AAE1D;;GAEG;AACH,MAAM,OAAO,KAAM,SAAQ,UAAU;IAArC;;QAC6B,aAAQ,GAAG,KAAK,CAAC;QACjB,UAAK,GAAG,KAAK,CAAC;QACd,YAAO,GAAG,KAAK,CAAC;QAC/B,UAAK,GAAG,EAAE,CAAC;QAC8B,eAAU,GAAG,KAAK,CAAC;QAC7C,cAAS,GAAG,KAAK,CAAC;QAClB,aAAQ,GAAG,KAAK,CAAC;QACjB,cAAS,GAAG,KAAK,CAAC;QACH,mBAAc,GAAG,EAAE,CAAC;QACzB,cAAS,GAAG,EAAE,CAAC;QAC1B,UAAK,GAAG,CAAC,CAAC,CAAC;QACX,QAAG,GAAG,CAAC,CAAC,CAAC;QAEnC;;WAEG;QACgD,aAAQ,GAAG,KAAK,CAAC;Q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hB,KAAK,EAAE;0CAA6B;AAOpB;IAAhB,KAAK,EAAE;gDAAmC;AAC1B;IAAhB,KAAK,EAAE;iDAAoC;AAE3B;IADhB,KAAK,CAAC,iBAAiB,CAAC;8CAC6B;AACZ;IAAzC,KAAK,CAAC,gBAAgB,CAAC;6CAAsD;AACxC;IAArC,KAAK,CAAC,YAAY,CAAC;0CAAmD","sourcesContent":["/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n html,\n LitElement,\n nothing,\n PropertyValues,\n render,\n TemplateResult,\n} from 'lit';\nimport {property, query, queryAssignedElements, state} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\n\nimport {EASING} from '../../internal/motion/animation.js';\n\n/**\n * A field component.\n */\nexport class Field extends LitElement {\n @property({type: Boolean}) disabled = false;\n @property({type: Boolean}) error = false;\n @property({type: Boolean}) focused = false;\n @property() label = '';\n @property({type: Boolean, attribute: 'no-asterisk'}) noAsterisk = false;\n @property({type: Boolean}) populated = false;\n @property({type: Boolean}) required = false;\n @property({type: Boolean}) resizable = false;\n @property({attribute: 'supporting-text'}) supportingText = '';\n @property({attribute: 'error-text'}) errorText = '';\n @property({type: Number}) count = -1;\n @property({type: Number}) max = -1;\n\n /**\n * Whether or not the field has leading content.\n */\n @property({type: Boolean, attribute: 'has-start'}) hasStart = false;\n\n /**\n * Whether or not the field has trailing content.\n */\n @property({type: Boolean, attribute: 'has-end'}) hasEnd = false;\n\n @queryAssignedElements({slot: 'aria-describedby'})\n private readonly slottedAriaDescribedBy!: HTMLElement[];\n\n private get counterText() {\n // Count and max are typed as number, but can be set to null when Lit removes\n // their attributes. These getters coerce back to a number for calculations.\n const countAsNumber = this.count ?? -1;\n const maxAsNumber = this.max ?? -1;\n // Counter does not show if count is negative, or max is negative or 0.\n if (countAsNumber < 0 || maxAsNumber <= 0) {\n return '';\n }\n\n return `${countAsNumber} / ${maxAsNumber}`;\n }\n\n private get supportingOrErrorText() {\n return this.error && this.errorText ? this.errorText : this.supportingText;\n }\n\n @state() private isAnimating = false;\n private labelAnimation?: Animation;\n /**\n * When set to true, the error text's `role=\"alert\"` will be removed, then\n * re-added after an animation frame. This will re-announce an error message\n * to screen readers.\n */\n @state() private refreshErrorAlert = false;\n @state() private disableTransitions = false;\n @query('.label.floating')\n private readonly floatingLabelEl!: HTMLElement | null;\n @query('.label.resting') private readonly restingLabelEl!: HTMLElement | null;\n @query('.container') private readonly containerEl!: HTMLElement | null;\n\n /**\n * Re-announces the field's error supporting text to screen readers.\n *\n * Error text announces to screen readers anytime it is visible and changes.\n * Use the method to re-announce the message when the text has not changed,\n * but announcement is still needed (such as for `reportValidity()`).\n */\n reannounceError() {\n this.refreshErrorAlert = true;\n }\n\n protected override update(props: PropertyValues<Field>) {\n // Client-side property updates\n const isDisabledChanging =\n props.has('disabled') && props.get('disabled') !== undefined;\n if (isDisabledChanging) {\n this.disableTransitions = true;\n }\n\n // When disabling, remove focus styles if focused.\n if (this.disabled && this.focused) {\n props.set('focused', true);\n this.focused = false;\n }\n\n // Animate if focused or populated change.\n this.animateLabelIfNeeded({\n wasFocused: props.get('focused'),\n wasPopulated: props.get('populated'),\n });\n\n super.update(props);\n }\n\n protected override render() {\n const floatingLabel = this.renderLabel(/*isFloating*/ true);\n const restingLabel = this.renderLabel(/*isFloating*/ false);\n const outline = this.renderOutline?.(floatingLabel);\n const classes = {\n 'disabled': this.disabled,\n 'disable-transitions': this.disableTransitions,\n 'error': this.error && !this.disabled,\n 'focused': this.focused,\n 'with-start': this.hasStart,\n 'with-end': this.hasEnd,\n 'populated': this.populated,\n 'resizable': this.resizable,\n 'required': this.required,\n 'no-label': !this.label,\n };\n\n return html`\n <div class=\"field ${classMap(classes)}\">\n <div class=\"container-overflow\">\n ${this.renderBackground?.()} ${this.renderIndicator?.()} ${outline}\n <div class=\"container\">\n <div class=\"start\">\n <slot name=\"start\"></slot>\n </div>\n <div class=\"middle\">\n <div class=\"label-wrapper\">\n ${restingLabel} ${outline ? nothing : floatingLabel}\n </div>\n <div class=\"content\">\n <slot></slot>\n </div>\n </div>\n <div class=\"end\">\n <slot name=\"end\"></slot>\n </div>\n </div>\n </div>\n ${this.renderSupportingText()}\n </div>\n `;\n }\n\n protected override updated(changed: PropertyValues<Field>) {\n if (\n changed.has('supportingText') ||\n changed.has('errorText') ||\n changed.has('count') ||\n changed.has('max')\n ) {\n this.updateSlottedAriaDescribedBy();\n }\n\n if (this.refreshErrorAlert) {\n // The past render cycle removed the role=\"alert\" from the error message.\n // Re-add it after an animation frame to re-announce the error.\n requestAnimationFrame(() => {\n this.refreshErrorAlert = false;\n });\n }\n\n if (this.disableTransitions) {\n requestAnimationFrame(() => {\n this.disableTransitions = false;\n });\n }\n }\n\n protected renderBackground?(): TemplateResult;\n protected renderIndicator?(): TemplateResult;\n protected renderOutline?(floatingLabel: unknown): TemplateResult;\n\n private renderSupportingText() {\n const {supportingOrErrorText, counterText} = this;\n if (!supportingOrErrorText && !counterText) {\n return nothing;\n }\n\n // Always render the supporting text span so that our `space-around`\n // container puts the counter at the end.\n const start = html`<span>${supportingOrErrorText}</span>`;\n // Conditionally render counter so we don't render the extra `gap`.\n // TODO(b/244473435): add aria-label and announcements\n const end = counterText\n ? html`<span class=\"counter\">${counterText}</span>`\n : nothing;\n\n // Announce if there is an error and error text visible.\n // If refreshErrorAlert is true, do not announce. This will remove the\n // role=\"alert\" attribute. Another render cycle will happen after an\n // animation frame to re-add the role.\n const shouldErrorAnnounce =\n this.error && this.errorText && !this.refreshErrorAlert;\n const role = shouldErrorAnnounce ? 'alert' : nothing;\n return html`\n <div class=\"supporting-text\" role=${role}>${start}${end}</div>\n <slot\n name=\"aria-describedby\"\n @slotchange=${this.updateSlottedAriaDescribedBy}></slot>\n `;\n }\n\n private updateSlottedAriaDescribedBy() {\n for (const element of this.slottedAriaDescribedBy) {\n render(html`${this.supportingOrErrorText} ${this.counterText}`, element);\n element.setAttribute('hidden', '');\n }\n }\n\n private renderLabel(isFloating: boolean) {\n if (!this.label) {\n return nothing;\n }\n\n let visible: boolean;\n if (isFloating) {\n // Floating label is visible when focused/populated or when animating.\n visible = this.focused || this.populated || this.isAnimating;\n } else {\n // Resting label is visible when unfocused. It is never visible while\n // animating.\n visible = !this.focused && !this.populated && !this.isAnimating;\n }\n\n const classes = {\n 'hidden': !visible,\n 'floating': isFloating,\n 'resting': !isFloating,\n };\n\n // Add '*' if a label is present and the field is required\n const labelText = `${this.label}${\n this.required && !this.noAsterisk ? '*' : ''\n }`;\n\n return html`\n <span class=\"label ${classMap(classes)}\" aria-hidden=${!visible}\n >${labelText}</span\n >\n `;\n }\n\n private animateLabelIfNeeded({\n wasFocused,\n wasPopulated,\n }: {\n wasFocused?: boolean;\n wasPopulated?: boolean;\n }) {\n if (!this.label) {\n return;\n }\n\n wasFocused ??= this.focused;\n wasPopulated ??= this.populated;\n const wasFloating = wasFocused || wasPopulated;\n const shouldBeFloating = this.focused || this.populated;\n if (wasFloating === shouldBeFloating) {\n return;\n }\n\n this.isAnimating = true;\n this.labelAnimation?.cancel();\n\n // Only one label is visible at a time for clearer text rendering.\n // The floating label is visible and used during animation. At the end of\n // the animation, it will either remain visible (if floating) or hide and\n // the resting label will be shown.\n //\n // We don't use forward filling because if the dimensions of the text field\n // change (leading icon removed, density changes, etc), then the animation\n // will be inaccurate.\n //\n // Re-calculating the animation each time will prevent any visual glitches\n // from appearing.\n // TODO(b/241113345): use animation tokens\n this.labelAnimation = this.floatingLabelEl?.animate(\n this.getLabelKeyframes(),\n {duration: 150, easing: EASING.STANDARD},\n );\n\n this.labelAnimation?.addEventListener('finish', () => {\n // At the end of the animation, update the visible label.\n this.isAnimating = false;\n });\n }\n\n private getLabelKeyframes() {\n const {floatingLabelEl, restingLabelEl} = this;\n if (!floatingLabelEl || !restingLabelEl) {\n return [];\n }\n\n const {\n x: floatingX,\n y: floatingY,\n height: floatingHeight,\n } = floatingLabelEl.getBoundingClientRect();\n const {\n x: restingX,\n y: restingY,\n height: restingHeight,\n } = restingLabelEl.getBoundingClientRect();\n const floatingScrollWidth = floatingLabelEl.scrollWidth;\n const restingScrollWidth = restingLabelEl.scrollWidth;\n // Scale by width ratio instead of font size since letter-spacing will scale\n // incorrectly. Using the width we can better approximate the adjusted\n // scale and compensate for tracking and overflow.\n // (use scrollWidth instead of width to account for clipped labels)\n const scale = restingScrollWidth / floatingScrollWidth;\n const xDelta = restingX - floatingX;\n // The line-height of the resting and floating label are different. When\n // we move the floating label down to the resting label's position, it won't\n // exactly match because of this. We need to adjust by half of what the\n // final scaled floating label's height will be.\n const yDelta =\n restingY -\n floatingY +\n Math.round((restingHeight - floatingHeight * scale) / 2);\n\n // Create the two transforms: floating to resting (using the calculations\n // above), and resting to floating (re-setting the transform to initial\n // values).\n const restTransform = `translateX(${xDelta}px) translateY(${yDelta}px) scale(${scale})`;\n const floatTransform = `translateX(0) translateY(0) scale(1)`;\n\n // Constrain the floating labels width to a scaled percentage of the\n // resting label's width. This will prevent long clipped labels from\n // overflowing the container.\n const restingClientWidth = restingLabelEl.clientWidth;\n const isRestingClipped = restingScrollWidth > restingClientWidth;\n const width = isRestingClipped ? `${restingClientWidth / scale}px` : '';\n if (this.focused || this.populated) {\n return [\n {transform: restTransform, width},\n {transform: floatTransform, width},\n ];\n }\n\n return [\n {transform: floatTransform, width},\n {transform: restTransform, width},\n ];\n }\n\n getSurfacePositionClientRect() {\n return this.containerEl!.getBoundingClientRect();\n }\n}\n"]}
|
|
@@ -8,7 +8,7 @@ import '../../ripple/ripple.js';
|
|
|
8
8
|
import { LitElement } from 'lit';
|
|
9
9
|
import { FormSubmitter, type FormSubmitterType } from '../../internal/controller/form-submitter.js';
|
|
10
10
|
type LinkTarget = '_blank' | '_parent' | '_self' | '_top';
|
|
11
|
-
declare const iconButtonBaseClass: import("../../labs/behaviors/mixin.js").MixinReturn<typeof LitElement, import("../../labs/behaviors/element-internals.js").WithElementInternals
|
|
11
|
+
declare const iconButtonBaseClass: import("../../labs/behaviors/mixin.js").MixinReturn<import("../../labs/behaviors/mixin.js").MixinReturn<typeof LitElement, import("../../labs/behaviors/element-internals.js").WithElementInternals>>;
|
|
12
12
|
/**
|
|
13
13
|
* A button for rendering icons.
|
|
14
14
|
*
|
|
@@ -10,12 +10,12 @@ import { html, LitElement, nothing } from 'lit';
|
|
|
10
10
|
import { property, state } from 'lit/decorators.js';
|
|
11
11
|
import { classMap } from 'lit/directives/class-map.js';
|
|
12
12
|
import { literal, html as staticHtml } from 'lit/static-html.js';
|
|
13
|
-
import {
|
|
13
|
+
import { mixinDelegatesAria } from '../../internal/aria/delegate.js';
|
|
14
14
|
import { setupFormSubmitter, } from '../../internal/controller/form-submitter.js';
|
|
15
15
|
import { isRtl } from '../../internal/controller/is-rtl.js';
|
|
16
16
|
import { internals, mixinElementInternals, } from '../../labs/behaviors/element-internals.js';
|
|
17
17
|
// Separate variable needed for closure.
|
|
18
|
-
const iconButtonBaseClass = mixinElementInternals(LitElement);
|
|
18
|
+
const iconButtonBaseClass = mixinDelegatesAria(mixinElementInternals(LitElement));
|
|
19
19
|
/**
|
|
20
20
|
* A button for rendering icons.
|
|
21
21
|
*
|
|
@@ -185,7 +185,6 @@ export class IconButton extends iconButtonBaseClass {
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
(() => {
|
|
188
|
-
requestUpdateOnAriaChange(IconButton);
|
|
189
188
|
setupFormSubmitter(IconButton);
|
|
190
189
|
})();
|
|
191
190
|
/** @nocollapse */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-button.js","sourceRoot":"","sources":["icon-button.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAC,MAAM,KAAK,CAAC;AAC9C,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,QA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AAQ,EAAE;0CAA8B;AAKK;IAA7C,QAAQ,CAAC,EAAC,SAAS,EAAE,qBAAqB,EAAC,CAAC;qDAAwB;AAM1C;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;0CAAgB;AAOA;IAAzC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;4CAAkB;AAM/C;IAAX,QAAQ,EAAE;wCAAoC;AAMpB;IAA1B,QAAQ,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;yCAAY;AAuBrB;IAAhB,KAAK,EAAE;4CAAoD","sourcesContent":["/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../focus/md-focus-ring.js';\nimport '../../ripple/ripple.js';\n\nimport {html, LitElement, nothing} from 'lit';\nimport {property, state} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\nimport {literal, html as staticHtml} from 'lit/static-html.js';\n\nimport {ARIAMixinStrict} from '../../internal/aria/aria.js';\nimport {requestUpdateOnAriaChange} from '../../internal/aria/delegate.js';\nimport {\n FormSubmitter,\n setupFormSubmitter,\n type FormSubmitterType,\n} from '../../internal/controller/form-submitter.js';\nimport {isRtl} from '../../internal/controller/is-rtl.js';\nimport {\n internals,\n mixinElementInternals,\n} from '../../labs/behaviors/element-internals.js';\n\ntype LinkTarget = '_blank' | '_parent' | '_self' | '_top';\n\n// Separate variable needed for closure.\nconst iconButtonBaseClass = mixinElementInternals(LitElement);\n\n/**\n * A button for rendering icons.\n *\n * @fires input {InputEvent} Dispatched when a toggle button toggles --bubbles\n * --composed\n * @fires change {Event} Dispatched when a toggle button toggles --bubbles\n */\nexport class IconButton extends iconButtonBaseClass implements FormSubmitter {\n static {\n requestUpdateOnAriaChange(IconButton);\n setupFormSubmitter(IconButton);\n }\n\n /** @nocollapse */\n static readonly formAssociated = true;\n\n /** @nocollapse */\n static override shadowRootOptions: ShadowRootInit = {\n mode: 'open',\n delegatesFocus: true,\n };\n\n /**\n * Disables the icon button and makes it non-interactive.\n */\n @property({type: Boolean, reflect: true}) disabled = false;\n\n /**\n * Flips the icon if it is in an RTL context at startup.\n */\n @property({type: Boolean, attribute: 'flip-icon-in-rtl'})\n flipIconInRtl = false;\n\n /**\n * Sets the underlying `HTMLAnchorElement`'s `href` resource attribute.\n */\n @property() href = '';\n\n /**\n * Sets the underlying `HTMLAnchorElement`'s `target` attribute.\n */\n @property() target: LinkTarget | '' = '';\n\n /**\n * The `aria-label` of the button when the button is toggleable and selected.\n */\n @property({attribute: 'aria-label-selected'}) ariaLabelSelected = '';\n\n /**\n * When true, the button will toggle between selected and unselected\n * states\n */\n @property({type: Boolean}) toggle = false;\n\n /**\n * Sets the selected state. When false, displays the default icon. When true,\n * displays the selected icon, or the default icon If no `slot=\"selected\"`\n * icon is provided.\n */\n @property({type: Boolean, reflect: true}) selected = false;\n\n /**\n * The default behavior of the button. May be \"button\", \"reset\", or \"submit\"\n * (default).\n */\n @property() type: FormSubmitterType = 'submit';\n\n /**\n * The value added to a form with the button's name when the button submits a\n * form.\n */\n @property({reflect: true}) value = '';\n\n get name() {\n return this.getAttribute('name') ?? '';\n }\n set name(name: string) {\n this.setAttribute('name', name);\n }\n\n /**\n * The associated form element with which this element's value will submit.\n */\n get form() {\n return this[internals].form;\n }\n\n /**\n * The labels this element is associated with.\n */\n get labels() {\n return this[internals].labels;\n }\n\n @state() private flipIcon = isRtl(this, this.flipIconInRtl);\n\n /**\n * Link buttons cannot be disabled.\n */\n protected override willUpdate() {\n if (this.href) {\n this.disabled = false;\n }\n }\n\n protected override render() {\n const tag = this.href ? literal`div` : literal`button`;\n // Needed for closure conformance\n const {ariaLabel, ariaHasPopup, ariaExpanded} = this as ARIAMixinStrict;\n const hasToggledAriaLabel = ariaLabel && this.ariaLabelSelected;\n const ariaPressedValue = !this.toggle ? nothing : this.selected;\n let ariaLabelValue: string | null | typeof nothing = nothing;\n if (!this.href) {\n ariaLabelValue =\n hasToggledAriaLabel && this.selected\n ? this.ariaLabelSelected\n : ariaLabel;\n }\n return staticHtml`<${tag}\n class=\"icon-button ${classMap(this.getRenderClasses())}\"\n id=\"button\"\n aria-label=\"${ariaLabelValue || nothing}\"\n aria-haspopup=\"${(!this.href && ariaHasPopup) || nothing}\"\n aria-expanded=\"${(!this.href && ariaExpanded) || nothing}\"\n aria-pressed=\"${ariaPressedValue}\"\n ?disabled=\"${!this.href && this.disabled}\"\n @click=\"${this.handleClick}\">\n ${this.renderFocusRing()}\n ${this.renderRipple()}\n ${!this.selected ? this.renderIcon() : nothing}\n ${this.selected ? this.renderSelectedIcon() : nothing}\n ${this.renderTouchTarget()}\n ${this.href && this.renderLink()}\n </${tag}>`;\n }\n\n private renderLink() {\n // Needed for closure conformance\n const {ariaLabel} = this as ARIAMixinStrict;\n return html`\n <a\n class=\"link\"\n id=\"link\"\n href=\"${this.href}\"\n target=\"${this.target || nothing}\"\n aria-label=\"${ariaLabel || nothing}\"></a>\n `;\n }\n\n protected getRenderClasses() {\n return {\n 'flip-icon': this.flipIcon,\n 'selected': this.toggle && this.selected,\n };\n }\n\n private renderIcon() {\n return html`<span class=\"icon\"><slot></slot></span>`;\n }\n\n private renderSelectedIcon() {\n // Use default slot as fallback to not require specifying multiple icons\n return html`<span class=\"icon icon--selected\"\n ><slot name=\"selected\"><slot></slot></slot\n ></span>`;\n }\n\n private renderTouchTarget() {\n return html`<span class=\"touch\"></span>`;\n }\n\n private renderFocusRing() {\n // TODO(b/310046938): use the same id for both elements\n return html`<md-focus-ring\n part=\"focus-ring\"\n for=${this.href ? 'link' : 'button'}></md-focus-ring>`;\n }\n\n private renderRipple() {\n // TODO(b/310046938): use the same id for both elements\n return html`<md-ripple\n for=${this.href ? 'link' : nothing}\n ?disabled=\"${!this.href && this.disabled}\"></md-ripple>`;\n }\n\n override connectedCallback() {\n this.flipIcon = isRtl(this, this.flipIconInRtl);\n super.connectedCallback();\n }\n\n private async handleClick(event: Event) {\n // Allow the event to propagate\n await 0;\n if (!this.toggle || this.disabled || event.defaultPrevented) {\n return;\n }\n\n this.selected = !this.selected;\n this.dispatchEvent(\n new InputEvent('input', {bubbles: true, composed: true}),\n );\n // Bubbles but does not compose to mimic native browser <input> & <select>\n // Additionally, native change event is not an InputEvent.\n this.dispatchEvent(new Event('change', {bubbles: true}));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"icon-button.js","sourceRoot":"","sources":["icon-button.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAC,MAAM,KAAK,CAAC;AAC9C,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAC,OAAO,EAAE,IAAI,IAAI,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAG/D,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAEL,kBAAkB,GAEnB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAC,KAAK,EAAC,MAAM,qCAAqC,CAAC;AAC1D,OAAO,EACL,SAAS,EACT,qBAAqB,GACtB,MAAM,2CAA2C,CAAC;AAInD,wCAAwC;AACxC,MAAM,mBAAmB,GAAG,kBAAkB,CAC5C,qBAAqB,CAAC,UAAU,CAAC,CAClC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,OAAO,UAAW,SAAQ,mBAAmB;IAAnD;;QAcE;;WAEG;QACuC,aAAQ,GAAG,KAAK,CAAC;QAE3D;;WAEG;QAEH,kBAAa,GAAG,KAAK,CAAC;QAEtB;;WAEG;QACS,SAAI,GAAG,EAAE,CAAC;QAEtB;;WAEG;QACS,WAAM,GAAoB,EAAE,CAAC;QAEzC;;WAEG;QA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,EAAE,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;;AAnMD;IACE,kBAAkB,CAAC,UAAU,CAAC,CAAC;AACjC,CAAC,GAAA,CAAA;AAED,kBAAkB;AACF,yBAAc,GAAG,IAAI,AAAP,CAAQ;AAEtC,kBAAkB;AACF,4BAAiB,GAAmB;IAClD,IAAI,EAAE,MAAM;IACZ,cAAc,EAAE,IAAI;CACrB,AAHgC,CAG/B;AAKwC;IAAzC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;4CAAkB;AAM3D;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAC,CAAC;iDACnC;AAKV;IAAX,QAAQ,EAAE;wCAAW;AAKV;IAAX,QAAQ,EAAE;0CAA8B;AAKK;IAA7C,QAAQ,CAAC,EAAC,SAAS,EAAE,qBAAqB,EAAC,CAAC;qDAAwB;AAM1C;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;0CAAgB;AAOA;IAAzC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;4CAAkB;AAM/C;IAAX,QAAQ,EAAE;wCAAoC;AAMpB;IAA1B,QAAQ,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;yCAAY;AAuBrB;IAAhB,KAAK,EAAE;4CAAoD","sourcesContent":["/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../focus/md-focus-ring.js';\nimport '../../ripple/ripple.js';\n\nimport {html, LitElement, nothing} from 'lit';\nimport {property, state} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\nimport {literal, html as staticHtml} from 'lit/static-html.js';\n\nimport {ARIAMixinStrict} from '../../internal/aria/aria.js';\nimport {mixinDelegatesAria} from '../../internal/aria/delegate.js';\nimport {\n FormSubmitter,\n setupFormSubmitter,\n type FormSubmitterType,\n} from '../../internal/controller/form-submitter.js';\nimport {isRtl} from '../../internal/controller/is-rtl.js';\nimport {\n internals,\n mixinElementInternals,\n} from '../../labs/behaviors/element-internals.js';\n\ntype LinkTarget = '_blank' | '_parent' | '_self' | '_top';\n\n// Separate variable needed for closure.\nconst iconButtonBaseClass = mixinDelegatesAria(\n mixinElementInternals(LitElement),\n);\n\n/**\n * A button for rendering icons.\n *\n * @fires input {InputEvent} Dispatched when a toggle button toggles --bubbles\n * --composed\n * @fires change {Event} Dispatched when a toggle button toggles --bubbles\n */\nexport class IconButton extends iconButtonBaseClass implements FormSubmitter {\n static {\n setupFormSubmitter(IconButton);\n }\n\n /** @nocollapse */\n static readonly formAssociated = true;\n\n /** @nocollapse */\n static override shadowRootOptions: ShadowRootInit = {\n mode: 'open',\n delegatesFocus: true,\n };\n\n /**\n * Disables the icon button and makes it non-interactive.\n */\n @property({type: Boolean, reflect: true}) disabled = false;\n\n /**\n * Flips the icon if it is in an RTL context at startup.\n */\n @property({type: Boolean, attribute: 'flip-icon-in-rtl'})\n flipIconInRtl = false;\n\n /**\n * Sets the underlying `HTMLAnchorElement`'s `href` resource attribute.\n */\n @property() href = '';\n\n /**\n * Sets the underlying `HTMLAnchorElement`'s `target` attribute.\n */\n @property() target: LinkTarget | '' = '';\n\n /**\n * The `aria-label` of the button when the button is toggleable and selected.\n */\n @property({attribute: 'aria-label-selected'}) ariaLabelSelected = '';\n\n /**\n * When true, the button will toggle between selected and unselected\n * states\n */\n @property({type: Boolean}) toggle = false;\n\n /**\n * Sets the selected state. When false, displays the default icon. When true,\n * displays the selected icon, or the default icon If no `slot=\"selected\"`\n * icon is provided.\n */\n @property({type: Boolean, reflect: true}) selected = false;\n\n /**\n * The default behavior of the button. May be \"button\", \"reset\", or \"submit\"\n * (default).\n */\n @property() type: FormSubmitterType = 'submit';\n\n /**\n * The value added to a form with the button's name when the button submits a\n * form.\n */\n @property({reflect: true}) value = '';\n\n get name() {\n return this.getAttribute('name') ?? '';\n }\n set name(name: string) {\n this.setAttribute('name', name);\n }\n\n /**\n * The associated form element with which this element's value will submit.\n */\n get form() {\n return this[internals].form;\n }\n\n /**\n * The labels this element is associated with.\n */\n get labels() {\n return this[internals].labels;\n }\n\n @state() private flipIcon = isRtl(this, this.flipIconInRtl);\n\n /**\n * Link buttons cannot be disabled.\n */\n protected override willUpdate() {\n if (this.href) {\n this.disabled = false;\n }\n }\n\n protected override render() {\n const tag = this.href ? literal`div` : literal`button`;\n // Needed for closure conformance\n const {ariaLabel, ariaHasPopup, ariaExpanded} = this as ARIAMixinStrict;\n const hasToggledAriaLabel = ariaLabel && this.ariaLabelSelected;\n const ariaPressedValue = !this.toggle ? nothing : this.selected;\n let ariaLabelValue: string | null | typeof nothing = nothing;\n if (!this.href) {\n ariaLabelValue =\n hasToggledAriaLabel && this.selected\n ? this.ariaLabelSelected\n : ariaLabel;\n }\n return staticHtml`<${tag}\n class=\"icon-button ${classMap(this.getRenderClasses())}\"\n id=\"button\"\n aria-label=\"${ariaLabelValue || nothing}\"\n aria-haspopup=\"${(!this.href && ariaHasPopup) || nothing}\"\n aria-expanded=\"${(!this.href && ariaExpanded) || nothing}\"\n aria-pressed=\"${ariaPressedValue}\"\n ?disabled=\"${!this.href && this.disabled}\"\n @click=\"${this.handleClick}\">\n ${this.renderFocusRing()}\n ${this.renderRipple()}\n ${!this.selected ? this.renderIcon() : nothing}\n ${this.selected ? this.renderSelectedIcon() : nothing}\n ${this.renderTouchTarget()}\n ${this.href && this.renderLink()}\n </${tag}>`;\n }\n\n private renderLink() {\n // Needed for closure conformance\n const {ariaLabel} = this as ARIAMixinStrict;\n return html`\n <a\n class=\"link\"\n id=\"link\"\n href=\"${this.href}\"\n target=\"${this.target || nothing}\"\n aria-label=\"${ariaLabel || nothing}\"></a>\n `;\n }\n\n protected getRenderClasses() {\n return {\n 'flip-icon': this.flipIcon,\n 'selected': this.toggle && this.selected,\n };\n }\n\n private renderIcon() {\n return html`<span class=\"icon\"><slot></slot></span>`;\n }\n\n private renderSelectedIcon() {\n // Use default slot as fallback to not require specifying multiple icons\n return html`<span class=\"icon icon--selected\"\n ><slot name=\"selected\"><slot></slot></slot\n ></span>`;\n }\n\n private renderTouchTarget() {\n return html`<span class=\"touch\"></span>`;\n }\n\n private renderFocusRing() {\n // TODO(b/310046938): use the same id for both elements\n return html`<md-focus-ring\n part=\"focus-ring\"\n for=${this.href ? 'link' : 'button'}></md-focus-ring>`;\n }\n\n private renderRipple() {\n // TODO(b/310046938): use the same id for both elements\n return html`<md-ripple\n for=${this.href ? 'link' : nothing}\n ?disabled=\"${!this.href && this.disabled}\"></md-ripple>`;\n }\n\n override connectedCallback() {\n this.flipIcon = isRtl(this, this.flipIconInRtl);\n super.connectedCallback();\n }\n\n private async handleClick(event: Event) {\n // Allow the event to propagate\n await 0;\n if (!this.toggle || this.disabled || event.defaultPrevented) {\n return;\n }\n\n this.selected = !this.selected;\n this.dispatchEvent(\n new InputEvent('input', {bubbles: true, composed: true}),\n );\n // Bubbles but does not compose to mimic native browser <input> & <select>\n // Additionally, native change event is not an InputEvent.\n this.dispatchEvent(new Event('change', {bubbles: true}));\n }\n}\n"]}
|
package/internal/aria/aria.js
CHANGED
|
@@ -60,7 +60,7 @@ export const ARIA_ATTRIBUTES = ARIA_PROPERTIES.map(ariaPropertyToAttribute);
|
|
|
60
60
|
* @return True if the attribute is an aria attribute, or false if not.
|
|
61
61
|
*/
|
|
62
62
|
export function isAriaAttribute(attribute) {
|
|
63
|
-
return
|
|
63
|
+
return ARIA_ATTRIBUTES.includes(attribute);
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
66
|
* Converts an AOM aria property into its corresponding attribute.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aria.js","sourceRoot":"","sources":["aria.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAmB;IAC7C,MAAM;IACN,YAAY;IACZ,kBAAkB;IAClB,UAAU;IACV,aAAa;IACb,cAAc;IACd,cAAc;IACd,aAAa;IACb,aAAa;IACb,cAAc;IACd,cAAc;IACd,cAAc;IACd,YAAY;IACZ,aAAa;IACb,kBAAkB;IAClB,WAAW;IACX,WAAW;IACX,UAAU;IACV,WAAW;IACX,eAAe;IACf,qBAAqB;IACrB,iBAAiB;IACjB,iBAAiB;IACjB,cAAc;IACd,aAAa;IACb,cAAc;IACd,cAAc;IACd,qBAAqB;IACrB,cAAc;IACd,cAAc;IACd,aAAa;IACb,cAAc;IACd,aAAa;IACb,UAAU;IACV,cAAc;IACd,cAAc;IACd,cAAc;IACd,eAAe;CAChB,CAAC;AAOF;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAE5E;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"aria.js","sourceRoot":"","sources":["aria.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAmB;IAC7C,MAAM;IACN,YAAY;IACZ,kBAAkB;IAClB,UAAU;IACV,aAAa;IACb,cAAc;IACd,cAAc;IACd,aAAa;IACb,aAAa;IACb,cAAc;IACd,cAAc;IACd,cAAc;IACd,YAAY;IACZ,aAAa;IACb,kBAAkB;IAClB,WAAW;IACX,WAAW;IACX,UAAU;IACV,WAAW;IACX,eAAe;IACf,qBAAqB;IACrB,iBAAiB;IACjB,iBAAiB;IACjB,cAAc;IACd,aAAa;IACb,cAAc;IACd,cAAc;IACd,qBAAqB;IACrB,cAAc;IACd,cAAc;IACd,aAAa;IACb,cAAc;IACd,aAAa;IACb,UAAU;IACV,cAAc;IACd,cAAc;IACd,cAAc;IACd,eAAe;CAChB,CAAC;AAOF;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAE5E;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,OAAO,eAAe,CAAC,QAAQ,CAAC,SAA0B,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CAAyB,QAAW;IACzE,OACE,QAAQ;SACL,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC;QACzB,kEAAkE;SACjE,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;SACzB,WAAW,EACf,CAAC;AACJ,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * Accessibility Object Model reflective aria property name types.\n */\nexport type ARIAProperty = keyof ARIAMixin;\n\n/**\n * Accessibility Object Model reflective aria properties.\n */\nexport const ARIA_PROPERTIES: ARIAProperty[] = [\n 'role',\n 'ariaAtomic',\n 'ariaAutoComplete',\n 'ariaBusy',\n 'ariaChecked',\n 'ariaColCount',\n 'ariaColIndex',\n 'ariaColSpan',\n 'ariaCurrent',\n 'ariaDisabled',\n 'ariaExpanded',\n 'ariaHasPopup',\n 'ariaHidden',\n 'ariaInvalid',\n 'ariaKeyShortcuts',\n 'ariaLabel',\n 'ariaLevel',\n 'ariaLive',\n 'ariaModal',\n 'ariaMultiLine',\n 'ariaMultiSelectable',\n 'ariaOrientation',\n 'ariaPlaceholder',\n 'ariaPosInSet',\n 'ariaPressed',\n 'ariaReadOnly',\n 'ariaRequired',\n 'ariaRoleDescription',\n 'ariaRowCount',\n 'ariaRowIndex',\n 'ariaRowSpan',\n 'ariaSelected',\n 'ariaSetSize',\n 'ariaSort',\n 'ariaValueMax',\n 'ariaValueMin',\n 'ariaValueNow',\n 'ariaValueText',\n];\n\n/**\n * Accessibility Object Model aria attribute name types.\n */\nexport type ARIAAttribute = ARIAPropertyToAttribute<ARIAProperty>;\n\n/**\n * Accessibility Object Model aria attributes.\n */\nexport const ARIA_ATTRIBUTES = ARIA_PROPERTIES.map(ariaPropertyToAttribute);\n\n/**\n * Checks if an attribute is one of the AOM aria attributes.\n *\n * @example\n * isAriaAttribute('aria-label'); // true\n *\n * @param attribute The attribute to check.\n * @return True if the attribute is an aria attribute, or false if not.\n */\nexport function isAriaAttribute(attribute: string): attribute is ARIAAttribute {\n return ARIA_ATTRIBUTES.includes(attribute as ARIAAttribute);\n}\n\n/**\n * Converts an AOM aria property into its corresponding attribute.\n *\n * @example\n * ariaPropertyToAttribute('ariaLabel'); // 'aria-label'\n *\n * @param property The aria property.\n * @return The aria attribute.\n */\nexport function ariaPropertyToAttribute<K extends ARIAProperty>(property: K) {\n return (\n property\n .replace('aria', 'aria-')\n // IDREF attributes also include an \"Element\" or \"Elements\" suffix\n .replace(/Elements?/g, '')\n .toLowerCase() as ARIAPropertyToAttribute<K>\n );\n}\n\n// Converts an `ariaFoo` string type to an `aria-foo` string type.\ntype ARIAPropertyToAttribute<K extends string> =\n K extends `aria${infer Suffix}Element${infer OptS}`\n ? `aria-${Lowercase<Suffix>}`\n : K extends `aria${infer Suffix}`\n ? `aria-${Lowercase<Suffix>}`\n : K;\n\n/**\n * An extension of `ARIAMixin` that enforces strict value types for aria\n * properties.\n *\n * This is needed for correct typing in render functions with lit analyzer.\n *\n * @example\n * render() {\n * const {ariaLabel} = this as ARIAMixinStrict;\n * return html`\n * <button aria-label=${ariaLabel || nothing}>\n * <slot></slot>\n * </button>\n * `;\n * }\n */\nexport interface ARIAMixinStrict extends ARIAMixin {\n ariaAtomic: 'true' | 'false' | null;\n ariaAutoComplete: 'none' | 'inline' | 'list' | 'both' | null;\n ariaBusy: 'true' | 'false' | null;\n ariaChecked: 'true' | 'false' | null;\n ariaColCount: `${number}` | null;\n ariaColIndex: `${number}` | null;\n ariaColSpan: `${number}` | null;\n ariaCurrent:\n | 'page'\n | 'step'\n | 'location'\n | 'date'\n | 'time'\n | 'true'\n | 'false'\n | null;\n ariaDisabled: 'true' | 'false' | null;\n ariaExpanded: 'true' | 'false' | null;\n ariaHasPopup:\n | 'false'\n | 'true'\n | 'menu'\n | 'listbox'\n | 'tree'\n | 'grid'\n | 'dialog'\n | null;\n ariaHidden: 'true' | 'false' | null;\n ariaInvalid: 'true' | 'false' | null;\n ariaKeyShortcuts: string | null;\n ariaLabel: string | null;\n ariaLevel: `${number}` | null;\n ariaLive: 'assertive' | 'off' | 'polite' | null;\n ariaModal: 'true' | 'false' | null;\n ariaMultiLine: 'true' | 'false' | null;\n ariaMultiSelectable: 'true' | 'false' | null;\n ariaOrientation: 'horizontal' | 'vertical' | 'undefined' | null;\n ariaPlaceholder: string | null;\n ariaPosInSet: `${number}` | null;\n ariaPressed: 'true' | 'false' | null;\n ariaReadOnly: 'true' | 'false' | null;\n ariaRequired: 'true' | 'false' | null;\n ariaRoleDescription: string | null;\n ariaRowCount: `${number}` | null;\n ariaRowIndex: `${number}` | null;\n ariaRowSpan: `${number}` | null;\n ariaSelected: 'true' | 'false' | null;\n ariaSetSize: `${number}` | null;\n ariaSort: 'ascending' | 'descending' | 'none' | 'other' | null;\n ariaValueMax: `${number}` | null;\n ariaValueMin: `${number}` | null;\n ariaValueNow: `${number}` | null;\n ariaValueText: string | null;\n role: ARIARole | null;\n}\n\n/**\n * Valid values for `role`.\n */\nexport type ARIARole =\n | 'alert'\n | 'alertdialog'\n | 'button'\n | 'checkbox'\n | 'dialog'\n | 'gridcell'\n | 'link'\n | 'log'\n | 'marquee'\n | 'menuitem'\n | 'menuitemcheckbox'\n | 'menuitemradio'\n | 'option'\n | 'progressbar'\n | 'radio'\n | 'scrollbar'\n | 'searchbox'\n | 'slider'\n | 'spinbutton'\n | 'status'\n | 'switch'\n | 'tab'\n | 'tabpanel'\n | 'textbox'\n | 'timer'\n | 'tooltip'\n | 'treeitem'\n | 'combobox'\n | 'grid'\n | 'listbox'\n | 'menu'\n | 'menubar'\n | 'radiogroup'\n | 'tablist'\n | 'tree'\n | 'treegrid'\n | 'application'\n | 'article'\n | 'cell'\n | 'columnheader'\n | 'definition'\n | 'directory'\n | 'document'\n | 'feed'\n | 'figure'\n | 'group'\n | 'heading'\n | 'img'\n | 'list'\n | 'listitem'\n | 'math'\n | 'none'\n | 'note'\n | 'presentation'\n | 'region'\n | 'row'\n | 'rowgroup'\n | 'rowheader'\n | 'separator'\n | 'table'\n | 'term'\n | 'text'\n | 'toolbar'\n | 'banner'\n | 'complementary'\n | 'contentinfo'\n | 'form'\n | 'main'\n | 'navigation'\n | 'region'\n | 'search'\n | 'doc-abstract'\n | 'doc-acknowledgments'\n | 'doc-afterword'\n | 'doc-appendix'\n | 'doc-backlink'\n | 'doc-biblioentry'\n | 'doc-bibliography'\n | 'doc-biblioref'\n | 'doc-chapter'\n | 'doc-colophon'\n | 'doc-conclusion'\n | 'doc-cover'\n | 'doc-credit'\n | 'doc-credits'\n | 'doc-dedication'\n | 'doc-endnote'\n | 'doc-endnotes'\n | 'doc-epigraph'\n | 'doc-epilogue'\n | 'doc-errata'\n | 'doc-example'\n | 'doc-footnote'\n | 'doc-foreword'\n | 'doc-glossary'\n | 'doc-glossref'\n | 'doc-index'\n | 'doc-introduction'\n | 'doc-noteref'\n | 'doc-notice'\n | 'doc-pagebreak'\n | 'doc-pagelist'\n | 'doc-part'\n | 'doc-preface'\n | 'doc-prologue'\n | 'doc-pullquote'\n | 'doc-qna'\n | 'doc-subtitle'\n | 'doc-tip'\n | 'doc-toc';\n"]}
|
|
@@ -3,27 +3,24 @@
|
|
|
3
3
|
* Copyright 2023 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { LitElement } from 'lit';
|
|
7
|
+
import { MixinBase, MixinReturn } from '../../labs/behaviors/mixin.js';
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* attributes in their render functions.
|
|
9
|
+
* Mixes in aria delegation for elements that delegate focus and aria to inner
|
|
10
|
+
* shadow root elements.
|
|
11
11
|
*
|
|
12
|
-
* This
|
|
13
|
-
*
|
|
14
|
-
* - Add `role="presentation"` to the host.
|
|
12
|
+
* This mixin fixes invalid aria announcements with shadow roots, caused by
|
|
13
|
+
* duplicate aria attributes on both the host and the inner shadow root element.
|
|
15
14
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* - Delegating the `role` attribute
|
|
15
|
+
* Note: this mixin **does not yet support** ID reference attributes, such as
|
|
16
|
+
* `aria-labelledby` or `aria-controls`.
|
|
19
17
|
*
|
|
20
18
|
* @example
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* }
|
|
19
|
+
* ```ts
|
|
20
|
+
* class MyButton extends mixinDelegatesAria(LitElement) {
|
|
21
|
+
* static shadowRootOptions = {mode: 'open', delegatesFocus: true};
|
|
25
22
|
*
|
|
26
|
-
*
|
|
23
|
+
* render() {
|
|
27
24
|
* return html`
|
|
28
25
|
* <button aria-label=${this.ariaLabel || nothing}>
|
|
29
26
|
* <slot></slot>
|
|
@@ -31,7 +28,27 @@ import { ReactiveElement } from 'lit';
|
|
|
31
28
|
* `;
|
|
32
29
|
* }
|
|
33
30
|
* }
|
|
31
|
+
* ```
|
|
32
|
+
* ```html
|
|
33
|
+
* <my-button aria-label="Plus one">+1</my-button>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* Use `ARIAMixinStrict` for lit analyzer strict types, such as the "role"
|
|
37
|
+
* attribute.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* return html`
|
|
42
|
+
* <button role=${(this as ARIAMixinStrict).role || nothing}>
|
|
43
|
+
* <slot></slot>
|
|
44
|
+
* </button>
|
|
45
|
+
* `;
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* In the future, updates to the Accessibility Object Model (AOM) will provide
|
|
49
|
+
* built-in aria delegation features that will replace this mixin.
|
|
34
50
|
*
|
|
35
|
-
* @param
|
|
51
|
+
* @param base The class to mix functionality into.
|
|
52
|
+
* @return The provided class with aria delegation mixed in.
|
|
36
53
|
*/
|
|
37
|
-
export declare function
|
|
54
|
+
export declare function mixinDelegatesAria<T extends MixinBase<LitElement>>(base: T): MixinReturn<T>;
|
|
@@ -3,27 +3,26 @@
|
|
|
3
3
|
* Copyright 2023 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { isServer } from 'lit';
|
|
7
|
+
import { ARIA_PROPERTIES, ariaPropertyToAttribute, isAriaAttribute, } from './aria.js';
|
|
8
|
+
// Private symbols
|
|
9
|
+
const privateIgnoreAttributeChangesFor = Symbol('privateIgnoreAttributeChangesFor');
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* attributes in their render functions.
|
|
11
|
+
* Mixes in aria delegation for elements that delegate focus and aria to inner
|
|
12
|
+
* shadow root elements.
|
|
11
13
|
*
|
|
12
|
-
* This
|
|
13
|
-
*
|
|
14
|
-
* - Add `role="presentation"` to the host.
|
|
14
|
+
* This mixin fixes invalid aria announcements with shadow roots, caused by
|
|
15
|
+
* duplicate aria attributes on both the host and the inner shadow root element.
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* - Delegating the `role` attribute
|
|
17
|
+
* Note: this mixin **does not yet support** ID reference attributes, such as
|
|
18
|
+
* `aria-labelledby` or `aria-controls`.
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* }
|
|
21
|
+
* ```ts
|
|
22
|
+
* class MyButton extends mixinDelegatesAria(LitElement) {
|
|
23
|
+
* static shadowRootOptions = {mode: 'open', delegatesFocus: true};
|
|
25
24
|
*
|
|
26
|
-
*
|
|
25
|
+
* render() {
|
|
27
26
|
* return html`
|
|
28
27
|
* <button aria-label=${this.ariaLabel || nothing}>
|
|
29
28
|
* <slot></slot>
|
|
@@ -31,23 +30,147 @@ import { ARIA_PROPERTIES, ariaPropertyToAttribute } from './aria.js';
|
|
|
31
30
|
* `;
|
|
32
31
|
* }
|
|
33
32
|
* }
|
|
33
|
+
* ```
|
|
34
|
+
* ```html
|
|
35
|
+
* <my-button aria-label="Plus one">+1</my-button>
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* Use `ARIAMixinStrict` for lit analyzer strict types, such as the "role"
|
|
39
|
+
* attribute.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* return html`
|
|
44
|
+
* <button role=${(this as ARIAMixinStrict).role || nothing}>
|
|
45
|
+
* <slot></slot>
|
|
46
|
+
* </button>
|
|
47
|
+
* `;
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* In the future, updates to the Accessibility Object Model (AOM) will provide
|
|
51
|
+
* built-in aria delegation features that will replace this mixin.
|
|
52
|
+
*
|
|
53
|
+
* @param base The class to mix functionality into.
|
|
54
|
+
* @return The provided class with aria delegation mixed in.
|
|
55
|
+
*/
|
|
56
|
+
export function mixinDelegatesAria(base) {
|
|
57
|
+
var _a;
|
|
58
|
+
if (isServer) {
|
|
59
|
+
// Don't shift attributes when running with lit-ssr. The SSR renderer
|
|
60
|
+
// implements a subset of DOM APIs, including the methods this mixin
|
|
61
|
+
// overrides, causing errors. We don't need to shift on the server anyway
|
|
62
|
+
// since elements will shift attributes immediately once they hydrate.
|
|
63
|
+
return base;
|
|
64
|
+
}
|
|
65
|
+
class WithDelegatesAriaElement extends base {
|
|
66
|
+
constructor() {
|
|
67
|
+
super(...arguments);
|
|
68
|
+
this[_a] = new Set();
|
|
69
|
+
}
|
|
70
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
71
|
+
if (!isAriaAttribute(name)) {
|
|
72
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (this[privateIgnoreAttributeChangesFor].has(name)) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
// Don't trigger another `attributeChangedCallback` once we remove the
|
|
79
|
+
// aria attribute from the host. We check the explicit name of the
|
|
80
|
+
// attribute to ignore since `attributeChangedCallback` can be called
|
|
81
|
+
// multiple times out of an expected order when hydrating an element with
|
|
82
|
+
// multiple attributes.
|
|
83
|
+
this[privateIgnoreAttributeChangesFor].add(name);
|
|
84
|
+
this.removeAttribute(name);
|
|
85
|
+
this[privateIgnoreAttributeChangesFor].delete(name);
|
|
86
|
+
const dataProperty = ariaAttributeToDataProperty(name);
|
|
87
|
+
if (newValue === null) {
|
|
88
|
+
delete this.dataset[dataProperty];
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
this.dataset[dataProperty] = newValue;
|
|
92
|
+
}
|
|
93
|
+
this.requestUpdate(ariaAttributeToDataProperty(name), oldValue);
|
|
94
|
+
}
|
|
95
|
+
getAttribute(name) {
|
|
96
|
+
if (isAriaAttribute(name)) {
|
|
97
|
+
return super.getAttribute(ariaAttributeToDataAttribute(name));
|
|
98
|
+
}
|
|
99
|
+
return super.getAttribute(name);
|
|
100
|
+
}
|
|
101
|
+
removeAttribute(name) {
|
|
102
|
+
super.removeAttribute(name);
|
|
103
|
+
if (isAriaAttribute(name)) {
|
|
104
|
+
super.removeAttribute(ariaAttributeToDataAttribute(name));
|
|
105
|
+
// Since `aria-*` attributes are already removed`, we need to request
|
|
106
|
+
// an update because `attributeChangedCallback` will not be called.
|
|
107
|
+
this.requestUpdate();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
_a = privateIgnoreAttributeChangesFor;
|
|
112
|
+
setupDelegatesAriaProperties(WithDelegatesAriaElement);
|
|
113
|
+
return WithDelegatesAriaElement;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Overrides the constructor's native `ARIAMixin` properties to ensure that
|
|
117
|
+
* aria properties reflect the values that were shifted to a data attribute.
|
|
34
118
|
*
|
|
35
119
|
* @param ctor The `ReactiveElement` constructor to patch.
|
|
36
120
|
*/
|
|
37
|
-
|
|
121
|
+
function setupDelegatesAriaProperties(ctor) {
|
|
38
122
|
for (const ariaProperty of ARIA_PROPERTIES) {
|
|
123
|
+
// The casing between ariaProperty and the dataProperty may be different.
|
|
124
|
+
// ex: aria-haspopup -> ariaHasPopup
|
|
125
|
+
const ariaAttribute = ariaPropertyToAttribute(ariaProperty);
|
|
126
|
+
// ex: aria-haspopup -> data-aria-haspopup
|
|
127
|
+
const dataAttribute = ariaAttributeToDataAttribute(ariaAttribute);
|
|
128
|
+
// ex: aria-haspopup -> dataset.ariaHaspopup
|
|
129
|
+
const dataProperty = ariaAttributeToDataProperty(ariaAttribute);
|
|
130
|
+
// Call `ReactiveElement.createProperty()` so that the `aria-*` and `data-*`
|
|
131
|
+
// attributes are added to the `static observedAttributes` array. This
|
|
132
|
+
// triggers `attributeChangedCallback` for the delegates aria mixin to
|
|
133
|
+
// handle.
|
|
39
134
|
ctor.createProperty(ariaProperty, {
|
|
40
|
-
attribute:
|
|
41
|
-
|
|
135
|
+
attribute: ariaAttribute,
|
|
136
|
+
noAccessor: true,
|
|
42
137
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
138
|
+
ctor.createProperty(Symbol(dataAttribute), {
|
|
139
|
+
attribute: dataAttribute,
|
|
140
|
+
noAccessor: true,
|
|
141
|
+
});
|
|
142
|
+
// Re-define the `ARIAMixin` properties to handle data attribute shifting.
|
|
143
|
+
// It is safe to use `Object.defineProperty` here because the properties
|
|
144
|
+
// are native and not renamed.
|
|
145
|
+
// tslint:disable-next-line:ban-unsafe-reflection
|
|
146
|
+
Object.defineProperty(ctor.prototype, ariaProperty, {
|
|
147
|
+
configurable: true,
|
|
148
|
+
enumerable: true,
|
|
149
|
+
get() {
|
|
150
|
+
return this.dataset[dataProperty] ?? null;
|
|
151
|
+
},
|
|
152
|
+
set(value) {
|
|
153
|
+
const prevValue = this.dataset[dataProperty] ?? null;
|
|
154
|
+
if (value === prevValue) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (value === null) {
|
|
158
|
+
delete this.dataset[dataProperty];
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
this.dataset[dataProperty] = value;
|
|
162
|
+
}
|
|
163
|
+
this.requestUpdate(ariaProperty, prevValue);
|
|
48
164
|
},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function ariaAttributeToDataAttribute(ariaAttribute) {
|
|
169
|
+
// aria-haspopup -> data-aria-haspopup
|
|
170
|
+
return `data-${ariaAttribute}`;
|
|
171
|
+
}
|
|
172
|
+
function ariaAttributeToDataProperty(ariaAttribute) {
|
|
173
|
+
// aria-haspopup -> dataset.ariaHaspopup
|
|
174
|
+
return ariaAttribute.replace(/-\w/, (dashLetter) => dashLetter[1].toUpperCase());
|
|
52
175
|
}
|
|
53
176
|
//# sourceMappingURL=delegate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegate.js","sourceRoot":"","sources":["delegate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"delegate.js","sourceRoot":"","sources":["delegate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAA8B,QAAQ,EAAC,MAAM,KAAK,CAAC;AAG1D,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,eAAe,GAChB,MAAM,WAAW,CAAC;AAEnB,kBAAkB;AAClB,MAAM,gCAAgC,GAAG,MAAM,CAC7C,kCAAkC,CACnC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAO;;IAEP,IA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;gBACD,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,IAAI,CAAC;YAC5C,CAAC;YACD,GAAG,CAAwB,KAAoB;gBAC7C,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,IAAI,CAAC;gBACrD,IAAI,KAAK,KAAK,SAAS,EAAE;oBACvB,OAAO;iBACR;gBAED,IAAI,KAAK,KAAK,IAAI,EAAE;oBAClB,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;iBACnC;qBAAM;oBACL,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC;iBACpC;gBAED,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;YAC9C,CAAC;SACF,CAAC,CAAC;KACJ;AACH,CAAC;AAED,SAAS,4BAA4B,CAAC,aAAqB;IACzD,sCAAsC;IACtC,OAAO,QAAQ,aAAa,EAAE,CAAC;AACjC,CAAC;AAED,SAAS,2BAA2B,CAAC,aAAqB;IACxD,wCAAwC;IACxC,OAAO,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,UAAU,EAAE,EAAE,CACjD,UAAU,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAC5B,CAAC;AACJ,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {LitElement, ReactiveElement, isServer} from 'lit';\n\nimport {MixinBase, MixinReturn} from '../../labs/behaviors/mixin.js';\nimport {\n ARIA_PROPERTIES,\n ariaPropertyToAttribute,\n isAriaAttribute,\n} from './aria.js';\n\n// Private symbols\nconst privateIgnoreAttributeChangesFor = Symbol(\n 'privateIgnoreAttributeChangesFor',\n);\n\n/**\n * Mixes in aria delegation for elements that delegate focus and aria to inner\n * shadow root elements.\n *\n * This mixin fixes invalid aria announcements with shadow roots, caused by\n * duplicate aria attributes on both the host and the inner shadow root element.\n *\n * Note: this mixin **does not yet support** ID reference attributes, such as\n * `aria-labelledby` or `aria-controls`.\n *\n * @example\n * ```ts\n * class MyButton extends mixinDelegatesAria(LitElement) {\n * static shadowRootOptions = {mode: 'open', delegatesFocus: true};\n *\n * render() {\n * return html`\n * <button aria-label=${this.ariaLabel || nothing}>\n * <slot></slot>\n * </button>\n * `;\n * }\n * }\n * ```\n * ```html\n * <my-button aria-label=\"Plus one\">+1</my-button>\n * ```\n *\n * Use `ARIAMixinStrict` for lit analyzer strict types, such as the \"role\"\n * attribute.\n *\n * @example\n * ```ts\n * return html`\n * <button role=${(this as ARIAMixinStrict).role || nothing}>\n * <slot></slot>\n * </button>\n * `;\n * ```\n *\n * In the future, updates to the Accessibility Object Model (AOM) will provide\n * built-in aria delegation features that will replace this mixin.\n *\n * @param base The class to mix functionality into.\n * @return The provided class with aria delegation mixed in.\n */\nexport function mixinDelegatesAria<T extends MixinBase<LitElement>>(\n base: T,\n): MixinReturn<T> {\n if (isServer) {\n // Don't shift attributes when running with lit-ssr. The SSR renderer\n // implements a subset of DOM APIs, including the methods this mixin\n // overrides, causing errors. We don't need to shift on the server anyway\n // since elements will shift attributes immediately once they hydrate.\n return base;\n }\n\n abstract class WithDelegatesAriaElement extends base {\n [privateIgnoreAttributeChangesFor] = new Set();\n\n override attributeChangedCallback(\n name: string,\n oldValue: string | null,\n newValue: string | null,\n ) {\n if (!isAriaAttribute(name)) {\n super.attributeChangedCallback(name, oldValue, newValue);\n return;\n }\n\n if (this[privateIgnoreAttributeChangesFor].has(name)) {\n return;\n }\n\n // Don't trigger another `attributeChangedCallback` once we remove the\n // aria attribute from the host. We check the explicit name of the\n // attribute to ignore since `attributeChangedCallback` can be called\n // multiple times out of an expected order when hydrating an element with\n // multiple attributes.\n this[privateIgnoreAttributeChangesFor].add(name);\n this.removeAttribute(name);\n this[privateIgnoreAttributeChangesFor].delete(name);\n const dataProperty = ariaAttributeToDataProperty(name);\n if (newValue === null) {\n delete this.dataset[dataProperty];\n } else {\n this.dataset[dataProperty] = newValue;\n }\n\n this.requestUpdate(ariaAttributeToDataProperty(name), oldValue);\n }\n\n override getAttribute(name: string) {\n if (isAriaAttribute(name)) {\n return super.getAttribute(ariaAttributeToDataAttribute(name));\n }\n\n return super.getAttribute(name);\n }\n\n override removeAttribute(name: string) {\n super.removeAttribute(name);\n if (isAriaAttribute(name)) {\n super.removeAttribute(ariaAttributeToDataAttribute(name));\n // Since `aria-*` attributes are already removed`, we need to request\n // an update because `attributeChangedCallback` will not be called.\n this.requestUpdate();\n }\n }\n }\n\n setupDelegatesAriaProperties(\n WithDelegatesAriaElement as unknown as typeof ReactiveElement,\n );\n\n return WithDelegatesAriaElement;\n}\n\n/**\n * Overrides the constructor's native `ARIAMixin` properties to ensure that\n * aria properties reflect the values that were shifted to a data attribute.\n *\n * @param ctor The `ReactiveElement` constructor to patch.\n */\nfunction setupDelegatesAriaProperties(ctor: typeof ReactiveElement) {\n for (const ariaProperty of ARIA_PROPERTIES) {\n // The casing between ariaProperty and the dataProperty may be different.\n // ex: aria-haspopup -> ariaHasPopup\n const ariaAttribute = ariaPropertyToAttribute(ariaProperty);\n // ex: aria-haspopup -> data-aria-haspopup\n const dataAttribute = ariaAttributeToDataAttribute(ariaAttribute);\n // ex: aria-haspopup -> dataset.ariaHaspopup\n const dataProperty = ariaAttributeToDataProperty(ariaAttribute);\n\n // Call `ReactiveElement.createProperty()` so that the `aria-*` and `data-*`\n // attributes are added to the `static observedAttributes` array. This\n // triggers `attributeChangedCallback` for the delegates aria mixin to\n // handle.\n ctor.createProperty(ariaProperty, {\n attribute: ariaAttribute,\n noAccessor: true,\n });\n ctor.createProperty(Symbol(dataAttribute), {\n attribute: dataAttribute,\n noAccessor: true,\n });\n\n // Re-define the `ARIAMixin` properties to handle data attribute shifting.\n // It is safe to use `Object.defineProperty` here because the properties\n // are native and not renamed.\n // tslint:disable-next-line:ban-unsafe-reflection\n Object.defineProperty(ctor.prototype, ariaProperty, {\n configurable: true,\n enumerable: true,\n get(this: ReactiveElement): string | null {\n return this.dataset[dataProperty] ?? null;\n },\n set(this: ReactiveElement, value: string | null): void {\n const prevValue = this.dataset[dataProperty] ?? null;\n if (value === prevValue) {\n return;\n }\n\n if (value === null) {\n delete this.dataset[dataProperty];\n } else {\n this.dataset[dataProperty] = value;\n }\n\n this.requestUpdate(ariaProperty, prevValue);\n },\n });\n }\n}\n\nfunction ariaAttributeToDataAttribute(ariaAttribute: string) {\n // aria-haspopup -> data-aria-haspopup\n return `data-${ariaAttribute}`;\n}\n\nfunction ariaAttributeToDataProperty(ariaAttribute: string) {\n // aria-haspopup -> dataset.ariaHaspopup\n return ariaAttribute.replace(/-\\w/, (dashLetter) =>\n dashLetter[1].toUpperCase(),\n );\n}\n"]}
|
|
@@ -7,13 +7,14 @@ import '../../../elevation/elevation.js';
|
|
|
7
7
|
import { LitElement, PropertyValues } from 'lit';
|
|
8
8
|
import { NavigationTab } from '../../navigationtab/internal/navigation-tab.js';
|
|
9
9
|
import { NavigationBarState } from './state.js';
|
|
10
|
+
declare const navigationBarBaseClass: import("../../behaviors/mixin.js").MixinReturn<typeof LitElement>;
|
|
10
11
|
/**
|
|
11
12
|
* b/265346501 - add docs
|
|
12
13
|
*
|
|
13
14
|
* @fires navigation-bar-activated {CustomEvent<tab: NavigationTab, activeIndex: number>}
|
|
14
15
|
* Dispatched whenever the `activeIndex` changes. --bubbles --composed
|
|
15
16
|
*/
|
|
16
|
-
export declare class NavigationBar extends
|
|
17
|
+
export declare class NavigationBar extends navigationBarBaseClass implements NavigationBarState {
|
|
17
18
|
activeIndex: number;
|
|
18
19
|
hideInactiveLabels: boolean;
|
|
19
20
|
tabs: NavigationTab[];
|
|
@@ -28,3 +29,4 @@ export declare class NavigationBar extends LitElement implements NavigationBarSt
|
|
|
28
29
|
private onActiveIndexChange;
|
|
29
30
|
private onHideInactiveLabelsChange;
|
|
30
31
|
}
|
|
32
|
+
export {};
|
|
@@ -7,15 +7,17 @@ import { __decorate } from "tslib";
|
|
|
7
7
|
import '../../../elevation/elevation.js';
|
|
8
8
|
import { html, LitElement, nothing } from 'lit';
|
|
9
9
|
import { property, queryAssignedElements } from 'lit/decorators.js';
|
|
10
|
-
import {
|
|
10
|
+
import { mixinDelegatesAria } from '../../../internal/aria/delegate.js';
|
|
11
11
|
import { isRtl } from '../../../internal/controller/is-rtl.js';
|
|
12
|
+
// Separate variable needed for closure.
|
|
13
|
+
const navigationBarBaseClass = mixinDelegatesAria(LitElement);
|
|
12
14
|
/**
|
|
13
15
|
* b/265346501 - add docs
|
|
14
16
|
*
|
|
15
17
|
* @fires navigation-bar-activated {CustomEvent<tab: NavigationTab, activeIndex: number>}
|
|
16
18
|
* Dispatched whenever the `activeIndex` changes. --bubbles --composed
|
|
17
19
|
*/
|
|
18
|
-
export class NavigationBar extends
|
|
20
|
+
export class NavigationBar extends navigationBarBaseClass {
|
|
19
21
|
constructor() {
|
|
20
22
|
super(...arguments);
|
|
21
23
|
this.activeIndex = 0;
|
|
@@ -130,9 +132,6 @@ export class NavigationBar extends LitElement {
|
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
|
-
(() => {
|
|
134
|
-
requestUpdateOnAriaChange(NavigationBar);
|
|
135
|
-
})();
|
|
136
135
|
__decorate([
|
|
137
136
|
property({ type: Number, attribute: 'active-index' })
|
|
138
137
|
], NavigationBar.prototype, "activeIndex", void 0);
|