@material/web 1.0.0-pre.12 → 1.0.0-pre.13

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.
Files changed (76) hide show
  1. package/button/lib/_icon.scss +9 -9
  2. package/button/lib/_outlined-button.scss +4 -0
  3. package/button/lib/elevated-styles.css.js +1 -1
  4. package/button/lib/elevated-styles.css.js.map +1 -1
  5. package/button/lib/filled-styles.css.js +1 -1
  6. package/button/lib/filled-styles.css.js.map +1 -1
  7. package/button/lib/outlined-styles.css.js +1 -1
  8. package/button/lib/outlined-styles.css.js.map +1 -1
  9. package/button/lib/shared-styles.css.js +1 -1
  10. package/button/lib/shared-styles.css.js.map +1 -1
  11. package/button/lib/text-styles.css.js +1 -1
  12. package/button/lib/text-styles.css.js.map +1 -1
  13. package/button/lib/tonal-styles.css.js +1 -1
  14. package/button/lib/tonal-styles.css.js.map +1 -1
  15. package/chips/lib/filter-chip.js +1 -1
  16. package/chips/lib/filter-chip.js.map +1 -1
  17. package/chips/lib/input-chip.js +1 -1
  18. package/chips/lib/input-chip.js.map +1 -1
  19. package/dialog/lib/_dialog.scss +2 -2
  20. package/dialog/lib/_tokens.scss +5 -22
  21. package/dialog/lib/dialog-styles.css.js +1 -1
  22. package/dialog/lib/dialog-styles.css.js.map +1 -1
  23. package/field/lib/_supporting-text.scss +6 -16
  24. package/field/lib/field.d.ts +26 -2
  25. package/field/lib/field.js +98 -13
  26. package/field/lib/field.js.map +1 -1
  27. package/field/lib/outlined-field.d.ts +1 -2
  28. package/field/lib/outlined-field.js.map +1 -1
  29. package/field/lib/shared-styles.css.js +1 -1
  30. package/field/lib/shared-styles.css.js.map +1 -1
  31. package/labs/segmentedbutton/lib/_shared.scss +7 -7
  32. package/labs/segmentedbutton/lib/outlined-styles.css.js +1 -1
  33. package/labs/segmentedbutton/lib/outlined-styles.css.js.map +1 -1
  34. package/labs/segmentedbutton/lib/shared-styles.css.js +1 -1
  35. package/labs/segmentedbutton/lib/shared-styles.css.js.map +1 -1
  36. package/labs/segmentedbuttonset/lib/outlined-styles.css.js +1 -1
  37. package/labs/segmentedbuttonset/lib/outlined-styles.css.js.map +1 -1
  38. package/list/harness.d.ts +24 -0
  39. package/list/harness.js +25 -0
  40. package/list/harness.js.map +1 -1
  41. package/list/lib/listitem/harness.d.ts +21 -1
  42. package/list/lib/listitem/harness.js +16 -2
  43. package/list/lib/listitem/harness.js.map +1 -1
  44. package/list/lib/listitemlink/list-item-link-only.d.ts +1 -0
  45. package/list/lib/listitemlink/list-item-link-only.js +4 -1
  46. package/list/lib/listitemlink/list-item-link-only.js.map +1 -1
  47. package/menu/harness.js.map +1 -1
  48. package/package.json +2 -1
  49. package/radio/lib/single-selection-controller.js +2 -3
  50. package/radio/lib/single-selection-controller.js.map +1 -1
  51. package/select/harness.js.map +1 -1
  52. package/select/lib/select.d.ts +0 -10
  53. package/select/lib/select.js +4 -40
  54. package/select/lib/select.js.map +1 -1
  55. package/tabs/lib/tab.js +3 -1
  56. package/tabs/lib/tab.js.map +1 -1
  57. package/tabs/lib/tabs.js +2 -0
  58. package/tabs/lib/tabs.js.map +1 -1
  59. package/textfield/lib/_shared.scss +0 -4
  60. package/textfield/lib/shared-styles.css.js +1 -1
  61. package/textfield/lib/shared-styles.css.js.map +1 -1
  62. package/textfield/lib/text-field.d.ts +2 -13
  63. package/textfield/lib/text-field.js +35 -89
  64. package/textfield/lib/text-field.js.map +1 -1
  65. package/tokens/_md-comp-dialog.scss +48 -6
  66. package/tokens/_md-comp-elevated-button.scss +17 -7
  67. package/tokens/_md-comp-elevation.scss +11 -2
  68. package/tokens/_md-comp-filled-button.scss +17 -7
  69. package/tokens/_md-comp-filled-tonal-button.scss +17 -7
  70. package/tokens/_md-comp-list-item.scss +5 -0
  71. package/tokens/_md-comp-menu-item.scss +1 -0
  72. package/tokens/_md-comp-outlined-button.scss +19 -9
  73. package/tokens/_md-comp-outlined-segmented-button.scss +19 -13
  74. package/tokens/_md-comp-slider.scss +48 -2
  75. package/tokens/_md-comp-text-button.scss +17 -7
  76. package/tokens/_values.scss +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"select.js","sourceRoot":"","sources":["select.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;AAEH,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAiB,MAAM,KAAK,CAAC;AAC9D,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAC,IAAI,IAAI,UAAU,EAAc,MAAM,oBAAoB,CAAC;AAGnE,OAAO,EAAC,IAAI,EAAC,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAC,6BAA6B,EAAO,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAwB,kBAAkB,EAAE,eAAe,EAAC,MAAM,0BAA0B,CAAC;AACpG,OAAO,EAAC,gBAAgB,EAAC,MAAM,uCAAuC,CAAC;AAEvE,OAAO,EAAC,gBAAgB,EAAmF,MAAM,aAAa,CAAC;AAE/H,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;AAE9B;;;;;GAKG;AACH,MAAM,OAAgB,MAAO,SAAQ,UAAU;IAA/C;;QACE;;WAEG;QACwB,UAAK,GAAG,KAAK,CAAC;QACzC;;WAEG;QACwB,aAAQ,GAAG,KAAK,CAAC;QAC5C;;WAEG;QACuC,aAAQ,GAAG,KAAK,CAAC;QAC3D;;;;;;;WAOG;QACgD,cAAS,GAAG,EAAE,CAAC;QAClE;;WAEG;QACS,UAAK,GAAG,EAAE,CAAC;QACvB;;;WAGG;QACqD,mBAAc,GAAG,EAAE,CAAC;QAC5E;;;;WAIG;QACuC,UAAK,GAAG,KAAK,CAAC;QACxD;;;WAGG;QACiD,cAAS,GAAG,KAAK,CAAC;QACtE;;;WAGG;Q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I,EAAC,CAAC;6CAClB;AAS3C;IADC,QAAQ,EAAE;mCAGV;AAsBD;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAC,CAAC;2CAKrD","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../menu/menu.js';\n\nimport {html, LitElement, nothing, PropertyValues} from 'lit';\nimport {property, query, queryAssignedElements, state} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\nimport {html as staticHtml, StaticValue} from 'lit/static-html.js';\n\nimport {Field} from '../../field/lib/field.js';\nimport {List} from '../../list/lib/list.js';\nimport {DEFAULT_TYPEAHEAD_BUFFER_TIME, Menu} from '../../menu/lib/menu.js';\nimport {DefaultCloseMenuEvent, isElementInSubtree, isSelectableKey} from '../../menu/lib/shared.js';\nimport {TYPEAHEAD_RECORD} from '../../menu/lib/typeaheadController.js';\n\nimport {getSelectedItems, RequestDeselectionEvent, RequestSelectionEvent, SelectOption, SelectOptionRecord} from './shared.js';\n\nconst VALUE = Symbol('value');\n\n/**\n * @fires input Fired when a selection is made by the user via mouse or keyboard\n * interaction.\n * @fires change Fired when a selection is made by the user via mouse or\n * keyboard interaction.\n */\nexport abstract class Select extends LitElement {\n /**\n * Opens the menu synchronously with no animation.\n */\n @property({type: Boolean}) quick = false;\n /**\n * Whether or not the select is required.\n */\n @property({type: Boolean}) required = false;\n /**\n * Disables the select.\n */\n @property({type: Boolean, reflect: true}) disabled = false;\n /**\n * The error message that replaces supporting text when `error` is true. If\n * `errorText` is an empty string, then the supporting text will continue to\n * show.\n *\n * Calling `reportValidity()` will automatically update `errorText` to the\n * native `validationMessage`.\n */\n @property({type: String, attribute: 'error-text'}) errorText = '';\n /**\n * The floating label for the field.\n */\n @property() label = '';\n /**\n * Conveys additional information below the text field, such as how it should\n * be used.\n */\n @property({type: String, attribute: 'supporting-text'}) supportingText = '';\n /**\n * Gets or sets whether or not the text field is in a visually invalid state.\n *\n * Calling `reportValidity()` will automatically update `error`.\n */\n @property({type: Boolean, reflect: true}) error = false;\n /**\n * Whether or not the underlying md-menu should be position: fixed to display\n * in a top-level manner.\n */\n @property({type: Boolean, attribute: 'menu-fixed'}) menuFixed = false;\n /**\n * The max time between the keystrokes of the typeahead select / menu behavior\n * before it clears the typeahead buffer.\n */\n @property({type: Number, attribute: 'typeahead-delay'})\n typeaheadDelay = DEFAULT_TYPEAHEAD_BUFFER_TIME;\n /**\n * Whether or not the text field has a leading icon. Used for SSR.\n */\n @property({type: Boolean, attribute: 'has-leading-icon'})\n hasLeadingIcon = false;\n /**\n * Whether or not the text field has a trailing icon. Used for SSR.\n */\n @property({type: Boolean, attribute: 'has-trailing-icon'})\n hasTrailingIcon = false;\n /**\n * Text to display in the field. Only set for SSR.\n */\n @property({attribute: 'display-text'}) displayText = '';\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 focused = false;\n @state() private open = false;\n @query('.field') private readonly field!: Field|null;\n @query('md-menu') private readonly menu!: Menu|null;\n @queryAssignedElements({slot: 'leadingicon', flatten: true})\n private readonly leadingIcons!: Element[];\n @queryAssignedElements({slot: 'trailingicon', flatten: true})\n private readonly trailingIcons!: Element[];\n\n /**\n * The value of the currently selected option.\n *\n * Note: For SSR, set `[selected]` on the requested option and `displayText`\n * rather than setting `value` setting `value` will incur a DOM query.\n */\n @property()\n get value(): string {\n return this[VALUE];\n }\n\n set value(value: string) {\n this.lastUserSetValue = value;\n this.select(value);\n }\n\n [VALUE] = '';\n\n get options() {\n // NOTE: this does a DOM query.\n return (this.menu?.items ?? []) as SelectOption[];\n }\n\n /**\n * The index of the currently selected option.\n *\n * Note: For SSR, set `[selected]` on the requested option and `displayText`\n * rather than setting `selectedIndex` setting `selectedIndex` will incur a\n * DOM query.\n */\n @property({type: Number, attribute: 'selected-index'})\n get selectedIndex(): number {\n // tslint:disable-next-line:enforce-name-casing\n const [_option, index] = (this.getSelectedOptions() ?? [])[0] ?? [];\n return index ?? -1;\n }\n\n set selectedIndex(index: number) {\n this.lastUserSetSelectedIndex = index;\n this.selectIndex(index);\n }\n\n /**\n * Returns an array of selected options.\n *\n * NOTE: md-select only suppoprts single selection.\n */\n get selectedOptions() {\n return (this.getSelectedOptions() ?? []).map(([option]) => option);\n }\n\n protected abstract readonly fieldTag: StaticValue;\n\n /**\n * Used for initializing select when the user sets the `value` directly.\n */\n private lastUserSetValue: string|null = null;\n\n /**\n * Used for initializing select when the user sets the `selectedIndex`\n * directly.\n */\n private lastUserSetSelectedIndex: number|null = null;\n\n /**\n * Used for `input` and `change` event change detection.\n */\n private lastSelectedOption: SelectOption|null = null;\n\n // tslint:disable-next-line:enforce-name-casing\n private lastSelectedOptionRecords: SelectOptionRecord[] = [];\n\n protected override render() {\n return html`\n <span\n class=\"select ${classMap(this.getRenderClasses())}\"\n @focusout=${this.handleFocusout}>\n ${this.renderField()}\n ${this.renderMenu()}\n </span>\n `;\n }\n\n private getRenderClasses() {\n return {\n 'disabled': this.disabled,\n 'error': this.error,\n };\n }\n\n private renderField() {\n return staticHtml`\n <${this.fieldTag}\n aria-haspopup=\"listbox\"\n role=\"combobox\"\n tabindex=${this.disabled ? '-1' : '0'}\n aria-expanded=${this.open ? 'true' : 'false'}\n class=\"field\"\n label=${this.label}\n .focused=${this.focused || this.open}\n .populated=${!!this.displayText}\n .disabled=${this.disabled}\n .required=${this.required}\n .error=${this.error}\n .hasStart=${this.hasLeadingIcon}\n .hasEnd=${this.hasTrailingIcon}\n @keydown =${this.handleKeydown}\n @click=${this.handleClick}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}>\n ${this.renderFieldContent()}\n </${this.fieldTag}>`;\n }\n\n private renderFieldContent() {\n return [\n this.renderLeadingIcon(),\n this.renderLabel(),\n this.renderTrailingIcon(),\n this.renderSupportingText(),\n ];\n }\n\n private renderLeadingIcon() {\n return html`\n <span class=\"icon leading\" slot=\"start\">\n <slot name=\"leadingicon\" @slotchange=${this.handleIconChange}></slot>\n </span>\n `;\n }\n\n private renderTrailingIcon() {\n return html`\n <span class=\"icon trailing\" slot=\"end\">\n <slot name=\"trailingicon\" @slotchange=${this.handleIconChange}></slot>\n </span>\n `;\n }\n\n private renderLabel() {\n // need to render &nbsp; so that line-height can apply and give it a\n // non-zero height\n return html`<div\n id=\"label\"\n class=\"label\">${this.displayText || html`&nbsp;`}</div>`;\n }\n\n private renderSupportingText() {\n const text = this.getSupportingText();\n if (!text) {\n return nothing;\n }\n\n return html`<span id=\"support\"\n slot=\"supporting-text\"\n role=${this.shouldErrorAnnounce() ? 'alert' : nothing}>${text}</span>`;\n }\n\n private getSupportingText() {\n return this.error && this.errorText ? this.errorText : this.supportingText;\n }\n\n private shouldErrorAnnounce() {\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 return this.error && !!this.errorText && !this.refreshErrorAlert;\n }\n\n private renderMenu() {\n return html`\n <md-menu\n id=\"listbox\"\n default-focus=\"NONE\"\n listTabIndex=\"-1\"\n type=\"listbox\"\n stay-open-on-focusout\n .anchor=${this.field}\n .open=${this.open}\n .quick=${this.quick}\n .fixed=${this.menuFixed}\n .typeaheadDelay=${this.typeaheadDelay}\n @opening=${this.handleOpening}\n @closing=${this.handleClosing}\n @close-menu=${this.handleCloseMenu}\n @request-selection=${this.handleRequestSelection}\n @request-deselection=${this.handleRequestDeselection}>\n ${this.renderMenuContent()}\n </md-menu>`;\n }\n\n private renderMenuContent() {\n return html`<slot></slot>`;\n }\n\n /**\n * Handles opening the select on keydown and typahead selection when the menu\n * is closed.\n */\n private handleKeydown(e: KeyboardEvent) {\n if (this.open || this.disabled || !this.menu) {\n return;\n }\n\n const typeaheadController = this.menu.typeaheadController;\n const isOpenKey =\n e.code === 'Space' || e.code === 'ArrowDown' || e.code === 'Enter';\n\n // Do not open if currently typing ahead because the user may be typing the\n // spacebar to match a word with a space\n if (!typeaheadController.isTypingAhead && isOpenKey) {\n e.preventDefault();\n this.open = true;\n return;\n }\n\n const isPrintableKey = e.key.length === 1;\n\n // Handles typing ahead when the menu is closed by delegating the event to\n // the underlying menu's typeaheadController\n if (isPrintableKey) {\n typeaheadController.onKeydown(e);\n e.preventDefault();\n\n const {lastActiveRecord} = typeaheadController;\n\n if (!lastActiveRecord) {\n return;\n }\n\n const hasChanged = this.selectItem(\n lastActiveRecord[TYPEAHEAD_RECORD.ITEM] as SelectOption);\n\n if (hasChanged) {\n this.dispatchInteractionEvents();\n }\n }\n }\n\n private handleClick() {\n this.open = true;\n }\n\n private handleFocus() {\n this.focused = true;\n }\n\n private handleBlur() {\n this.focused = false;\n }\n\n /**\n * Handles closing the menu when the focus leaves the select's subtree.\n */\n private handleFocusout(e: FocusEvent) {\n // Don't close the menu if we are switching focus between menu,\n // select-option, and field\n if (e.relatedTarget && isElementInSubtree(e.relatedTarget, this)) {\n return;\n }\n\n this.open = false;\n }\n\n /**\n * Gets a list of all selected select options as a list item record array.\n *\n * @return An array of selected list option records.\n */\n private getSelectedOptions() {\n if (!this.menu) {\n this.lastSelectedOptionRecords = [];\n return null;\n }\n\n const items = this.menu.items as SelectOption[];\n this.lastSelectedOptionRecords = getSelectedItems(items);\n return this.lastSelectedOptionRecords;\n }\n\n override async getUpdateComplete() {\n await this.menu?.updateComplete;\n return super.getUpdateComplete();\n }\n\n /**\n * Gets the selected options from the DOM, and updates the value and display\n * text to the first selected option's value and headline respectively.\n *\n * @return Whether or not the selected option has changed since last update.\n */\n private updateValueAndDisplayText() {\n const selectedOptions = this.getSelectedOptions() ?? [];\n // Used to determine whether or not we need to fire an input / change event\n // which fire whenever the option element changes (value or selectedIndex)\n // on user interaction.\n let hasSelectedOptionChanged = false;\n\n if (selectedOptions.length) {\n const [firstSelectedOption] = selectedOptions[0];\n hasSelectedOptionChanged =\n this.lastSelectedOption !== firstSelectedOption;\n this.lastSelectedOption = firstSelectedOption;\n this[VALUE] = firstSelectedOption.value;\n this.displayText = firstSelectedOption.headline;\n\n } else {\n hasSelectedOptionChanged = this.lastSelectedOption !== null;\n this.lastSelectedOption = null;\n this[VALUE] = '';\n this.displayText = '';\n }\n\n return hasSelectedOptionChanged;\n }\n\n protected override update(changed: PropertyValues<this>) {\n // In SSR the options will be ready to query, so try to figure out what\n // the value and display text should be.\n if (!this.hasUpdated) {\n this.initUserSelection();\n }\n\n super.update(changed);\n }\n\n protected override async firstUpdated(changed: PropertyValues<this>) {\n await this.menu?.updateComplete;\n // If this has been handled on update already due to SSR, try again.\n if (!this.lastSelectedOptionRecords.length) {\n this.initUserSelection();\n }\n\n super.firstUpdated(changed);\n }\n\n protected override updated(changedProperties: PropertyValues) {\n // Keep changedProperties arg so that subclasses may call it\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\n /**\n * Focuses and activates the last selected item upon opening, and resets other\n * active items.\n */\n private async handleOpening() {\n const items = this.menu!.items;\n const activeItem = List.getActiveItem(items)?.item;\n const [selectedItem] = this.lastSelectedOptionRecords[0] ?? [null];\n\n // This is true if the user keys through the list but clicks out of the menu\n // thus no close-menu event is fired by an item and we can't clean up in\n // handleCloseMenu.\n if (activeItem && activeItem !== selectedItem) {\n activeItem.active = false;\n }\n\n if (selectedItem) {\n selectedItem.active = true;\n selectedItem.focus();\n }\n }\n\n private handleClosing() {\n this.open = false;\n }\n\n /**\n * Determines the reason for closing, and updates the UI accordingly.\n */\n private handleCloseMenu(e: InstanceType<typeof DefaultCloseMenuEvent>) {\n const reason = e.reason;\n const item = e.itemPath[0] as SelectOption;\n this.open = false;\n let hasChanged = false;\n\n if (reason.kind === 'CLICK_SELECTION') {\n hasChanged = this.selectItem(item);\n } else if (reason.kind === 'KEYDOWN' && isSelectableKey(reason.key)) {\n hasChanged = this.selectItem(item);\n } else {\n // This can happen on ESC being pressed\n item.active = false;\n item.blur();\n }\n\n // Dispatch interaction events since selection has been made via keyboard\n // or mouse.\n if (hasChanged) {\n this.dispatchInteractionEvents();\n }\n }\n\n /**\n * Selects a given option, deselects other options, and updates the UI.\n *\n * @return Whether the last selected option has changed.\n */\n private selectItem(item: SelectOption) {\n this.lastSelectedOptionRecords.forEach(([option]) => {\n if (item !== option) {\n option.selected = false;\n }\n });\n item.selected = true;\n\n return this.updateValueAndDisplayText();\n }\n\n /**\n * Handles updating selection when an option element requests selection via\n * property / attribute change.\n */\n private handleRequestSelection(e: RequestSelectionEvent) {\n const requestingOptionEl = e.target as SelectOption & HTMLElement;\n\n // No-op if this item is already selected.\n if (this.lastSelectedOptionRecords.some(\n ([option]) => option === requestingOptionEl)) {\n return;\n }\n\n this.selectItem(requestingOptionEl);\n }\n\n /**\n * Handles updating selection when an option element requests deselection via\n * property / attribute change.\n */\n private handleRequestDeselection(e: RequestDeselectionEvent) {\n const requestingOptionEl = e.target as SelectOption & HTMLElement;\n\n // No-op if this item is not even in the list of tracked selected items.\n if (!this.lastSelectedOptionRecords.some(\n ([option]) => option === requestingOptionEl)) {\n return;\n }\n\n this.updateValueAndDisplayText();\n }\n\n /**\n * Selects an option given the value of the option, and updates MdSelect's\n * value.\n */\n select(value: string) {\n const optionToSelect = this.options.find(option => option.value === value);\n if (optionToSelect) {\n this.selectItem(optionToSelect);\n }\n }\n\n /**\n * Selects an option given the index of the option, and updates MdSelect's\n * value.\n */\n selectIndex(index: number) {\n const optionToSelect = this.options[index];\n if (optionToSelect) {\n this.selectItem(optionToSelect);\n }\n }\n\n /**\n * Attempts to initialize the selected option from user-settable values like\n * SSR, setting `value`, or `selectedIndex` at startup.\n */\n private initUserSelection() {\n // User has set `.value` directly, but internals have not yet booted up.\n if (this.lastUserSetValue && !this.lastSelectedOptionRecords.length) {\n this.select(this.lastUserSetValue);\n\n // User has set `.selectedIndex` directly, but internals have not yet\n // booted up.\n } else if (\n this.lastUserSetSelectedIndex !== null &&\n !this.lastSelectedOptionRecords.length) {\n this.selectIndex(this.lastUserSetSelectedIndex);\n\n // Regular boot up!\n } else {\n this.updateValueAndDisplayText();\n }\n }\n\n private handleIconChange() {\n this.hasLeadingIcon = this.leadingIcons.length > 0;\n this.hasTrailingIcon = this.trailingIcons.length > 0;\n }\n\n /**\n * Dispatches the `input` and `change` events.\n */\n private dispatchInteractionEvents() {\n this.dispatchEvent(new Event('input', {bubbles: true, composed: true}));\n this.dispatchEvent(new Event('change', {bubbles: true}));\n }\n}\n"]}
1
+ {"version":3,"file":"select.js","sourceRoot":"","sources":["select.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;AAEH,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAC,IAAI,EAAE,UAAU,EAAiB,MAAM,KAAK,CAAC;AACrD,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAC,IAAI,IAAI,UAAU,EAAc,MAAM,oBAAoB,CAAC;AAGnE,OAAO,EAAC,IAAI,EAAC,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAC,6BAA6B,EAAO,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAwB,kBAAkB,EAAE,eAAe,EAAC,MAAM,0BAA0B,CAAC;AACpG,OAAO,EAAC,gBAAgB,EAAC,MAAM,uCAAuC,CAAC;AAEvE,OAAO,EAAC,gBAAgB,EAAmF,MAAM,aAAa,CAAC;AAE/H,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;AAE9B;;;;;GAKG;AACH,MAAM,OAAgB,MAAO,SAAQ,UAAU;IAA/C;;QACE;;WAEG;QACwB,UAAK,GAAG,KAAK,CAAC;QACzC;;WAEG;QACwB,aAAQ,GAAG,KAAK,CAAC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AS,EAAE,iBAAiB,EAAC,CAAC;8CACR;AAK/C;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAC,CAAC;8CAClC;AAKvB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAC,CAAC;+CAClC;AAIe;IAAtC,QAAQ,CAAC,EAAC,SAAS,EAAE,cAAc,EAAC,CAAC;2CAAkB;AAE/C;IAAR,KAAK,EAAE;uCAAyB;AACxB;IAAR,KAAK,EAAE;oCAAsB;AACb;IAAhB,KAAK,CAAC,QAAQ,CAAC;qCAAqC;AACnC;IAAjB,KAAK,CAAC,SAAS,CAAC;oCAAmC;AAEpD;IADC,qBAAqB,CAAC,EAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;4CAClB;AAE1C;IADC,qBAAqB,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;6CAClB;AAS3C;IADC,QAAQ,EAAE;mCAGV;AAsBD;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAC,CAAC;2CAKrD","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../menu/menu.js';\n\nimport {html, LitElement, PropertyValues} from 'lit';\nimport {property, query, queryAssignedElements, state} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\nimport {html as staticHtml, StaticValue} from 'lit/static-html.js';\n\nimport {Field} from '../../field/lib/field.js';\nimport {List} from '../../list/lib/list.js';\nimport {DEFAULT_TYPEAHEAD_BUFFER_TIME, Menu} from '../../menu/lib/menu.js';\nimport {DefaultCloseMenuEvent, isElementInSubtree, isSelectableKey} from '../../menu/lib/shared.js';\nimport {TYPEAHEAD_RECORD} from '../../menu/lib/typeaheadController.js';\n\nimport {getSelectedItems, RequestDeselectionEvent, RequestSelectionEvent, SelectOption, SelectOptionRecord} from './shared.js';\n\nconst VALUE = Symbol('value');\n\n/**\n * @fires input Fired when a selection is made by the user via mouse or keyboard\n * interaction.\n * @fires change Fired when a selection is made by the user via mouse or\n * keyboard interaction.\n */\nexport abstract class Select extends LitElement {\n /**\n * Opens the menu synchronously with no animation.\n */\n @property({type: Boolean}) quick = false;\n /**\n * Whether or not the select is required.\n */\n @property({type: Boolean}) required = false;\n /**\n * Disables the select.\n */\n @property({type: Boolean, reflect: true}) disabled = false;\n /**\n * The error message that replaces supporting text when `error` is true. If\n * `errorText` is an empty string, then the supporting text will continue to\n * show.\n *\n * Calling `reportValidity()` will automatically update `errorText` to the\n * native `validationMessage`.\n */\n @property({type: String, attribute: 'error-text'}) errorText = '';\n /**\n * The floating label for the field.\n */\n @property() label = '';\n /**\n * Conveys additional information below the text field, such as how it should\n * be used.\n */\n @property({type: String, attribute: 'supporting-text'}) supportingText = '';\n /**\n * Gets or sets whether or not the text field is in a visually invalid state.\n *\n * Calling `reportValidity()` will automatically update `error`.\n */\n @property({type: Boolean, reflect: true}) error = false;\n /**\n * Whether or not the underlying md-menu should be position: fixed to display\n * in a top-level manner.\n */\n @property({type: Boolean, attribute: 'menu-fixed'}) menuFixed = false;\n /**\n * The max time between the keystrokes of the typeahead select / menu behavior\n * before it clears the typeahead buffer.\n */\n @property({type: Number, attribute: 'typeahead-delay'})\n typeaheadDelay = DEFAULT_TYPEAHEAD_BUFFER_TIME;\n /**\n * Whether or not the text field has a leading icon. Used for SSR.\n */\n @property({type: Boolean, attribute: 'has-leading-icon'})\n hasLeadingIcon = false;\n /**\n * Whether or not the text field has a trailing icon. Used for SSR.\n */\n @property({type: Boolean, attribute: 'has-trailing-icon'})\n hasTrailingIcon = false;\n /**\n * Text to display in the field. Only set for SSR.\n */\n @property({attribute: 'display-text'}) displayText = '';\n\n @state() private focused = false;\n @state() private open = false;\n @query('.field') private readonly field!: Field|null;\n @query('md-menu') private readonly menu!: Menu|null;\n @queryAssignedElements({slot: 'leadingicon', flatten: true})\n private readonly leadingIcons!: Element[];\n @queryAssignedElements({slot: 'trailingicon', flatten: true})\n private readonly trailingIcons!: Element[];\n\n /**\n * The value of the currently selected option.\n *\n * Note: For SSR, set `[selected]` on the requested option and `displayText`\n * rather than setting `value` setting `value` will incur a DOM query.\n */\n @property()\n get value(): string {\n return this[VALUE];\n }\n\n set value(value: string) {\n this.lastUserSetValue = value;\n this.select(value);\n }\n\n [VALUE] = '';\n\n get options() {\n // NOTE: this does a DOM query.\n return (this.menu?.items ?? []) as SelectOption[];\n }\n\n /**\n * The index of the currently selected option.\n *\n * Note: For SSR, set `[selected]` on the requested option and `displayText`\n * rather than setting `selectedIndex` setting `selectedIndex` will incur a\n * DOM query.\n */\n @property({type: Number, attribute: 'selected-index'})\n get selectedIndex(): number {\n // tslint:disable-next-line:enforce-name-casing\n const [_option, index] = (this.getSelectedOptions() ?? [])[0] ?? [];\n return index ?? -1;\n }\n\n set selectedIndex(index: number) {\n this.lastUserSetSelectedIndex = index;\n this.selectIndex(index);\n }\n\n /**\n * Returns an array of selected options.\n *\n * NOTE: md-select only suppoprts single selection.\n */\n get selectedOptions() {\n return (this.getSelectedOptions() ?? []).map(([option]) => option);\n }\n\n protected abstract readonly fieldTag: StaticValue;\n\n /**\n * Used for initializing select when the user sets the `value` directly.\n */\n private lastUserSetValue: string|null = null;\n\n /**\n * Used for initializing select when the user sets the `selectedIndex`\n * directly.\n */\n private lastUserSetSelectedIndex: number|null = null;\n\n /**\n * Used for `input` and `change` event change detection.\n */\n private lastSelectedOption: SelectOption|null = null;\n\n // tslint:disable-next-line:enforce-name-casing\n private lastSelectedOptionRecords: SelectOptionRecord[] = [];\n\n protected override render() {\n return html`\n <span\n class=\"select ${classMap(this.getRenderClasses())}\"\n @focusout=${this.handleFocusout}>\n ${this.renderField()}\n ${this.renderMenu()}\n </span>\n `;\n }\n\n private getRenderClasses() {\n return {\n 'disabled': this.disabled,\n 'error': this.error,\n };\n }\n\n private renderField() {\n // TODO(b/290078041): add aria-label/describedby\n return staticHtml`\n <${this.fieldTag}\n aria-haspopup=\"listbox\"\n role=\"combobox\"\n tabindex=${this.disabled ? '-1' : '0'}\n aria-expanded=${this.open ? 'true' : 'false'}\n class=\"field\"\n label=${this.label}\n .focused=${this.focused || this.open}\n .populated=${!!this.displayText}\n .disabled=${this.disabled}\n .required=${this.required}\n .error=${this.error}\n .hasStart=${this.hasLeadingIcon}\n .hasEnd=${this.hasTrailingIcon}\n supporting-text=${this.supportingText}\n error-text=${this.errorText}\n @keydown =${this.handleKeydown}\n @click=${this.handleClick}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}>\n ${this.renderFieldContent()}\n </${this.fieldTag}>`;\n }\n\n private renderFieldContent() {\n return [\n this.renderLeadingIcon(),\n this.renderLabel(),\n this.renderTrailingIcon(),\n ];\n }\n\n private renderLeadingIcon() {\n return html`\n <span class=\"icon leading\" slot=\"start\">\n <slot name=\"leadingicon\" @slotchange=${this.handleIconChange}></slot>\n </span>\n `;\n }\n\n private renderTrailingIcon() {\n return html`\n <span class=\"icon trailing\" slot=\"end\">\n <slot name=\"trailingicon\" @slotchange=${this.handleIconChange}></slot>\n </span>\n `;\n }\n\n private renderLabel() {\n // need to render &nbsp; so that line-height can apply and give it a\n // non-zero height\n return html`<div\n id=\"label\"\n class=\"label\">${this.displayText || html`&nbsp;`}</div>`;\n }\n\n private renderMenu() {\n return html`\n <md-menu\n id=\"listbox\"\n default-focus=\"NONE\"\n listTabIndex=\"-1\"\n type=\"listbox\"\n stay-open-on-focusout\n .anchor=${this.field}\n .open=${this.open}\n .quick=${this.quick}\n .fixed=${this.menuFixed}\n .typeaheadDelay=${this.typeaheadDelay}\n @opening=${this.handleOpening}\n @closing=${this.handleClosing}\n @close-menu=${this.handleCloseMenu}\n @request-selection=${this.handleRequestSelection}\n @request-deselection=${this.handleRequestDeselection}>\n ${this.renderMenuContent()}\n </md-menu>`;\n }\n\n private renderMenuContent() {\n return html`<slot></slot>`;\n }\n\n /**\n * Handles opening the select on keydown and typahead selection when the menu\n * is closed.\n */\n private handleKeydown(e: KeyboardEvent) {\n if (this.open || this.disabled || !this.menu) {\n return;\n }\n\n const typeaheadController = this.menu.typeaheadController;\n const isOpenKey =\n e.code === 'Space' || e.code === 'ArrowDown' || e.code === 'Enter';\n\n // Do not open if currently typing ahead because the user may be typing the\n // spacebar to match a word with a space\n if (!typeaheadController.isTypingAhead && isOpenKey) {\n e.preventDefault();\n this.open = true;\n return;\n }\n\n const isPrintableKey = e.key.length === 1;\n\n // Handles typing ahead when the menu is closed by delegating the event to\n // the underlying menu's typeaheadController\n if (isPrintableKey) {\n typeaheadController.onKeydown(e);\n e.preventDefault();\n\n const {lastActiveRecord} = typeaheadController;\n\n if (!lastActiveRecord) {\n return;\n }\n\n const hasChanged = this.selectItem(\n lastActiveRecord[TYPEAHEAD_RECORD.ITEM] as SelectOption);\n\n if (hasChanged) {\n this.dispatchInteractionEvents();\n }\n }\n }\n\n private handleClick() {\n this.open = true;\n }\n\n private handleFocus() {\n this.focused = true;\n }\n\n private handleBlur() {\n this.focused = false;\n }\n\n /**\n * Handles closing the menu when the focus leaves the select's subtree.\n */\n private handleFocusout(e: FocusEvent) {\n // Don't close the menu if we are switching focus between menu,\n // select-option, and field\n if (e.relatedTarget && isElementInSubtree(e.relatedTarget, this)) {\n return;\n }\n\n this.open = false;\n }\n\n /**\n * Gets a list of all selected select options as a list item record array.\n *\n * @return An array of selected list option records.\n */\n private getSelectedOptions() {\n if (!this.menu) {\n this.lastSelectedOptionRecords = [];\n return null;\n }\n\n const items = this.menu.items as SelectOption[];\n this.lastSelectedOptionRecords = getSelectedItems(items);\n return this.lastSelectedOptionRecords;\n }\n\n override async getUpdateComplete() {\n await this.menu?.updateComplete;\n return super.getUpdateComplete();\n }\n\n /**\n * Gets the selected options from the DOM, and updates the value and display\n * text to the first selected option's value and headline respectively.\n *\n * @return Whether or not the selected option has changed since last update.\n */\n private updateValueAndDisplayText() {\n const selectedOptions = this.getSelectedOptions() ?? [];\n // Used to determine whether or not we need to fire an input / change event\n // which fire whenever the option element changes (value or selectedIndex)\n // on user interaction.\n let hasSelectedOptionChanged = false;\n\n if (selectedOptions.length) {\n const [firstSelectedOption] = selectedOptions[0];\n hasSelectedOptionChanged =\n this.lastSelectedOption !== firstSelectedOption;\n this.lastSelectedOption = firstSelectedOption;\n this[VALUE] = firstSelectedOption.value;\n this.displayText = firstSelectedOption.headline;\n\n } else {\n hasSelectedOptionChanged = this.lastSelectedOption !== null;\n this.lastSelectedOption = null;\n this[VALUE] = '';\n this.displayText = '';\n }\n\n return hasSelectedOptionChanged;\n }\n\n protected override update(changed: PropertyValues<this>) {\n // In SSR the options will be ready to query, so try to figure out what\n // the value and display text should be.\n if (!this.hasUpdated) {\n this.initUserSelection();\n }\n\n super.update(changed);\n }\n\n protected override async firstUpdated(changed: PropertyValues<this>) {\n await this.menu?.updateComplete;\n // If this has been handled on update already due to SSR, try again.\n if (!this.lastSelectedOptionRecords.length) {\n this.initUserSelection();\n }\n\n super.firstUpdated(changed);\n }\n\n /**\n * Focuses and activates the last selected item upon opening, and resets other\n * active items.\n */\n private async handleOpening() {\n const items = this.menu!.items;\n const activeItem = List.getActiveItem(items)?.item;\n const [selectedItem] = this.lastSelectedOptionRecords[0] ?? [null];\n\n // This is true if the user keys through the list but clicks out of the menu\n // thus no close-menu event is fired by an item and we can't clean up in\n // handleCloseMenu.\n if (activeItem && activeItem !== selectedItem) {\n activeItem.active = false;\n }\n\n if (selectedItem) {\n selectedItem.active = true;\n selectedItem.focus();\n }\n }\n\n private handleClosing() {\n this.open = false;\n }\n\n /**\n * Determines the reason for closing, and updates the UI accordingly.\n */\n private handleCloseMenu(e: InstanceType<typeof DefaultCloseMenuEvent>) {\n const reason = e.reason;\n const item = e.itemPath[0] as SelectOption;\n this.open = false;\n let hasChanged = false;\n\n if (reason.kind === 'CLICK_SELECTION') {\n hasChanged = this.selectItem(item);\n } else if (reason.kind === 'KEYDOWN' && isSelectableKey(reason.key)) {\n hasChanged = this.selectItem(item);\n } else {\n // This can happen on ESC being pressed\n item.active = false;\n item.blur();\n }\n\n // Dispatch interaction events since selection has been made via keyboard\n // or mouse.\n if (hasChanged) {\n this.dispatchInteractionEvents();\n }\n }\n\n /**\n * Selects a given option, deselects other options, and updates the UI.\n *\n * @return Whether the last selected option has changed.\n */\n private selectItem(item: SelectOption) {\n this.lastSelectedOptionRecords.forEach(([option]) => {\n if (item !== option) {\n option.selected = false;\n }\n });\n item.selected = true;\n\n return this.updateValueAndDisplayText();\n }\n\n /**\n * Handles updating selection when an option element requests selection via\n * property / attribute change.\n */\n private handleRequestSelection(e: RequestSelectionEvent) {\n const requestingOptionEl = e.target as SelectOption & HTMLElement;\n\n // No-op if this item is already selected.\n if (this.lastSelectedOptionRecords.some(\n ([option]) => option === requestingOptionEl)) {\n return;\n }\n\n this.selectItem(requestingOptionEl);\n }\n\n /**\n * Handles updating selection when an option element requests deselection via\n * property / attribute change.\n */\n private handleRequestDeselection(e: RequestDeselectionEvent) {\n const requestingOptionEl = e.target as SelectOption & HTMLElement;\n\n // No-op if this item is not even in the list of tracked selected items.\n if (!this.lastSelectedOptionRecords.some(\n ([option]) => option === requestingOptionEl)) {\n return;\n }\n\n this.updateValueAndDisplayText();\n }\n\n /**\n * Selects an option given the value of the option, and updates MdSelect's\n * value.\n */\n select(value: string) {\n const optionToSelect = this.options.find(option => option.value === value);\n if (optionToSelect) {\n this.selectItem(optionToSelect);\n }\n }\n\n /**\n * Selects an option given the index of the option, and updates MdSelect's\n * value.\n */\n selectIndex(index: number) {\n const optionToSelect = this.options[index];\n if (optionToSelect) {\n this.selectItem(optionToSelect);\n }\n }\n\n /**\n * Attempts to initialize the selected option from user-settable values like\n * SSR, setting `value`, or `selectedIndex` at startup.\n */\n private initUserSelection() {\n // User has set `.value` directly, but internals have not yet booted up.\n if (this.lastUserSetValue && !this.lastSelectedOptionRecords.length) {\n this.select(this.lastUserSetValue);\n\n // User has set `.selectedIndex` directly, but internals have not yet\n // booted up.\n } else if (\n this.lastUserSetSelectedIndex !== null &&\n !this.lastSelectedOptionRecords.length) {\n this.selectIndex(this.lastUserSetSelectedIndex);\n\n // Regular boot up!\n } else {\n this.updateValueAndDisplayText();\n }\n }\n\n private handleIconChange() {\n this.hasLeadingIcon = this.leadingIcons.length > 0;\n this.hasTrailingIcon = this.trailingIcons.length > 0;\n }\n\n /**\n * Dispatches the `input` and `change` events.\n */\n private dispatchInteractionEvents() {\n this.dispatchEvent(new Event('input', {bubbles: true, composed: true}));\n this.dispatchEvent(new Event('change', {bubbles: true}));\n }\n}\n"]}
package/tabs/lib/tab.js CHANGED
@@ -62,6 +62,8 @@ export class Tab extends LitElement {
62
62
  const contentClasses = {
63
63
  'inline-icon': this.inlineIcon,
64
64
  };
65
+ // Needed for closure conformance
66
+ const { ariaLabel } = this;
65
67
  return html `
66
68
  <button
67
69
  class="button"
@@ -69,7 +71,7 @@ export class Tab extends LitElement {
69
71
  .tabIndex=${this.focusable && !this.disabled ? 0 : -1}
70
72
  aria-selected=${this.selected ? 'true' : 'false'}
71
73
  ?disabled=${this.disabled}
72
- aria-label=${this.ariaLabel || nothing}
74
+ aria-label=${ariaLabel || nothing}
73
75
  >
74
76
  <md-focus-ring inward></md-focus-ring>
75
77
  <md-elevation></md-elevation>
@@ -1 +1 @@
1
- {"version":3,"file":"tab.js","sourceRoot":"","sources":["tab.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,2BAA2B,CAAC;AACnC,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAiB,MAAM,KAAK,CAAC;AACxE,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAErD,OAAO,EAAC,yBA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;AACF,qBAAiB,GACZ,EAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAC,CAAC;AAO/B;IAA1B,QAAQ,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;oCAA8B;AAKd;IAAzC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;qCAAkB;AAKjB;IAAzC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;qCAAkB;AAKhC;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;sCAAmB;AAKQ;IAApD,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAC,CAAC;uCAAoB;AAEtD;IAAjB,KAAK,CAAC,SAAS,CAAC;mCAA4C;AAMxC;IAApB,KAAK,CAAC,YAAY,CAAC;sCAAkC;AAsGxD,SAAS,kBAAkB;IACzB,OAAO,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../elevation/elevation.js';\nimport '../../focus/focus-ring.js';\nimport '../../ripple/ripple.js';\n\nimport {html, isServer, LitElement, nothing, PropertyValues} from 'lit';\nimport {property, query} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\n\nimport {requestUpdateOnAriaChange} from '../../internal/aria/delegate.js';\nimport {dispatchActivationClick, isActivationClick} from '../../internal/controller/events.js';\n\n/**\n * An element that can select items.\n */\nexport interface Tabs extends HTMLElement {\n selected?: number;\n selectedItem?: Tab;\n previousSelectedItem?: Tab;\n}\n\ntype Style = ''|'primary'|'secondary';\ntype Orientation = ''|'vertical';\n\n/**\n * Tab variant can be `primary` or `secondary and can include a space\n * separated `vertical`.\n */\nexport type Variant = Style|`${Style} ${Orientation}`|`${Orientation} ${Style}`;\n\n/**\n * Tab component.\n */\nexport class Tab extends LitElement {\n static {\n requestUpdateOnAriaChange(this);\n }\n\n /** @nocollapse */\n static override shadowRootOptions:\n ShadowRootInit = {mode: 'open', delegatesFocus: true};\n\n /**\n * Styling variant to display, 'primary' or 'secondary' and can also\n * include `vertical`.\n * Defaults to `primary`.\n */\n @property({reflect: true}) variant: Variant = 'primary';\n\n /**\n * Whether or not the tab is `disabled`.\n */\n @property({type: Boolean, reflect: true}) disabled = false;\n\n /**\n * Whether or not the tab is `selected`.\n **/\n @property({type: Boolean, reflect: true}) selected = false;\n\n /**\n * Whether or not the tab is `focusable`.\n */\n @property({type: Boolean}) focusable = false;\n\n /**\n * Whether or not the icon renders inline with label or stacked vertically.\n */\n @property({type: Boolean, attribute: 'inline-icon'}) inlineIcon = false;\n\n @query('.button') private readonly button!: HTMLElement|null;\n\n // note, this is public so it can participate in selection animation.\n /**\n * Selection indicator element.\n */\n @query('.indicator') readonly indicator!: HTMLElement;\n\n constructor() {\n super();\n if (!isServer) {\n this.addEventListener('click', this.handleActivationClick);\n }\n }\n\n override focus() {\n this.button?.focus();\n }\n\n override blur() {\n this.button?.blur();\n }\n\n protected override render() {\n const contentClasses = {\n 'inline-icon': this.inlineIcon,\n };\n return html`\n <button\n class=\"button\"\n role=\"tab\"\n .tabIndex=${this.focusable && !this.disabled ? 0 : -1}\n aria-selected=${this.selected ? 'true' : 'false'}\n ?disabled=${this.disabled}\n aria-label=${this.ariaLabel || nothing}\n >\n <md-focus-ring inward></md-focus-ring>\n <md-elevation></md-elevation>\n <md-ripple ?disabled=${this.disabled}></md-ripple>\n <span class=\"touch\"></span>\n <div class=\"content ${classMap(contentClasses)}\">\n <slot name=\"icon\"></slot>\n <span class=\"label\">\n <slot></slot>\n </span>\n <div class=\"indicator\"></div>\n </div>\n </button>`;\n }\n\n protected override updated(changed: PropertyValues) {\n if (changed.has('selected') && !this.disabled) {\n this.animateSelected();\n }\n }\n\n private readonly handleActivationClick = (event: MouseEvent) => {\n if (!isActivationClick((event)) || !this.button) {\n return;\n }\n this.focus();\n dispatchActivationClick(this.button);\n };\n\n private get tabs() {\n return this.parentElement as Tabs;\n }\n\n private animateSelected() {\n this.indicator.getAnimations().forEach(a => {\n a.cancel();\n });\n const frames = this.getKeyframes();\n if (frames !== null) {\n this.indicator.animate(frames, {duration: 400, easing: 'ease-out'});\n }\n }\n\n private getKeyframes() {\n const reduceMotion = shouldReduceMotion();\n if (!this.selected) {\n return reduceMotion ? [{'opacity': 1}, {'transform': 'none'}] : null;\n }\n const from: Keyframe = {};\n const isVertical = this.variant.includes('vertical');\n const fromRect =\n (this.tabs?.previousSelectedItem?.indicator.getBoundingClientRect() ??\n ({} as DOMRect));\n const fromPos = isVertical ? fromRect.top : fromRect.left;\n const fromExtent = isVertical ? fromRect.height : fromRect.width;\n const toRect = this.indicator.getBoundingClientRect();\n const toPos = isVertical ? toRect.top : toRect.left;\n const toExtent = isVertical ? toRect.height : toRect.width;\n const axis = isVertical ? 'Y' : 'X';\n const scale = fromExtent / toExtent;\n if (!reduceMotion && fromPos !== undefined && toPos !== undefined &&\n !isNaN(scale)) {\n from['transform'] = `translate${axis}(${\n (fromPos - toPos).toFixed(4)}px) scale${axis}(${scale.toFixed(4)})`;\n } else {\n from['opacity'] = 0;\n }\n // note, including `transform: none` avoids quirky Safari behavior\n // that can hide the animation.\n return [from, {'transform': 'none'}];\n }\n}\n\nfunction shouldReduceMotion() {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n"]}
1
+ {"version":3,"file":"tab.js","sourceRoot":"","sources":["tab.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,2BAA2B,CAAC;AACnC,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAiB,MAAM,KAAK,CAAC;AACxE,OAAO,EAAC,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AA+B;QAC/B,OAAO,CAAC,IAAI,EAAE,EAAC,WAAW,EAAE,MAAM,EAAC,CAAC,CAAC;IACvC,CAAC;;;AA9ID;IACE,yBAAyB,CAAC,EAAI,CAAC,CAAC;AAClC,CAAC,GAAA,CAAA;AAED,kBAAkB;AACF,qBAAiB,GACZ,EAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAC,CAAC;AAO/B;IAA1B,QAAQ,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;oCAA8B;AAKd;IAAzC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;qCAAkB;AAKjB;IAAzC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;qCAAkB;AAKhC;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;sCAAmB;AAKQ;IAApD,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAC,CAAC;uCAAoB;AAEtD;IAAjB,KAAK,CAAC,SAAS,CAAC;mCAA4C;AAMxC;IAApB,KAAK,CAAC,YAAY,CAAC;sCAAkC;AAwGxD,SAAS,kBAAkB;IACzB,OAAO,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../elevation/elevation.js';\nimport '../../focus/focus-ring.js';\nimport '../../ripple/ripple.js';\n\nimport {html, isServer, LitElement, nothing, PropertyValues} from 'lit';\nimport {property, query} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\n\nimport {ARIAMixinStrict} from '../../internal/aria/aria.js';\nimport {requestUpdateOnAriaChange} from '../../internal/aria/delegate.js';\nimport {dispatchActivationClick, isActivationClick} from '../../internal/controller/events.js';\n\n/**\n * An element that can select items.\n */\nexport interface Tabs extends HTMLElement {\n selected?: number;\n selectedItem?: Tab;\n previousSelectedItem?: Tab;\n}\n\ntype Style = ''|'primary'|'secondary';\ntype Orientation = ''|'vertical';\n\n/**\n * Tab variant can be `primary` or `secondary and can include a space\n * separated `vertical`.\n */\nexport type Variant = Style|`${Style} ${Orientation}`|`${Orientation} ${Style}`;\n\n/**\n * Tab component.\n */\nexport class Tab extends LitElement {\n static {\n requestUpdateOnAriaChange(this);\n }\n\n /** @nocollapse */\n static override shadowRootOptions:\n ShadowRootInit = {mode: 'open', delegatesFocus: true};\n\n /**\n * Styling variant to display, 'primary' or 'secondary' and can also\n * include `vertical`.\n * Defaults to `primary`.\n */\n @property({reflect: true}) variant: Variant = 'primary';\n\n /**\n * Whether or not the tab is `disabled`.\n */\n @property({type: Boolean, reflect: true}) disabled = false;\n\n /**\n * Whether or not the tab is `selected`.\n **/\n @property({type: Boolean, reflect: true}) selected = false;\n\n /**\n * Whether or not the tab is `focusable`.\n */\n @property({type: Boolean}) focusable = false;\n\n /**\n * Whether or not the icon renders inline with label or stacked vertically.\n */\n @property({type: Boolean, attribute: 'inline-icon'}) inlineIcon = false;\n\n @query('.button') private readonly button!: HTMLElement|null;\n\n // note, this is public so it can participate in selection animation.\n /**\n * Selection indicator element.\n */\n @query('.indicator') readonly indicator!: HTMLElement;\n\n constructor() {\n super();\n if (!isServer) {\n this.addEventListener('click', this.handleActivationClick);\n }\n }\n\n override focus() {\n this.button?.focus();\n }\n\n override blur() {\n this.button?.blur();\n }\n\n protected override render() {\n const contentClasses = {\n 'inline-icon': this.inlineIcon,\n };\n // Needed for closure conformance\n const {ariaLabel} = this as ARIAMixinStrict;\n return html`\n <button\n class=\"button\"\n role=\"tab\"\n .tabIndex=${this.focusable && !this.disabled ? 0 : -1}\n aria-selected=${this.selected ? 'true' : 'false'}\n ?disabled=${this.disabled}\n aria-label=${ariaLabel || nothing}\n >\n <md-focus-ring inward></md-focus-ring>\n <md-elevation></md-elevation>\n <md-ripple ?disabled=${this.disabled}></md-ripple>\n <span class=\"touch\"></span>\n <div class=\"content ${classMap(contentClasses)}\">\n <slot name=\"icon\"></slot>\n <span class=\"label\">\n <slot></slot>\n </span>\n <div class=\"indicator\"></div>\n </div>\n </button>`;\n }\n\n protected override updated(changed: PropertyValues) {\n if (changed.has('selected') && !this.disabled) {\n this.animateSelected();\n }\n }\n\n private readonly handleActivationClick = (event: MouseEvent) => {\n if (!isActivationClick((event)) || !this.button) {\n return;\n }\n this.focus();\n dispatchActivationClick(this.button);\n };\n\n private get tabs() {\n return this.parentElement as Tabs;\n }\n\n private animateSelected() {\n this.indicator.getAnimations().forEach(a => {\n a.cancel();\n });\n const frames = this.getKeyframes();\n if (frames !== null) {\n this.indicator.animate(frames, {duration: 400, easing: 'ease-out'});\n }\n }\n\n private getKeyframes() {\n const reduceMotion = shouldReduceMotion();\n if (!this.selected) {\n return reduceMotion ? [{'opacity': 1}, {'transform': 'none'}] : null;\n }\n const from: Keyframe = {};\n const isVertical = this.variant.includes('vertical');\n const fromRect =\n (this.tabs?.previousSelectedItem?.indicator.getBoundingClientRect() ??\n ({} as DOMRect));\n const fromPos = isVertical ? fromRect.top : fromRect.left;\n const fromExtent = isVertical ? fromRect.height : fromRect.width;\n const toRect = this.indicator.getBoundingClientRect();\n const toPos = isVertical ? toRect.top : toRect.left;\n const toExtent = isVertical ? toRect.height : toRect.width;\n const axis = isVertical ? 'Y' : 'X';\n const scale = fromExtent / toExtent;\n if (!reduceMotion && fromPos !== undefined && toPos !== undefined &&\n !isNaN(scale)) {\n from['transform'] = `translate${axis}(${\n (fromPos - toPos).toFixed(4)}px) scale${axis}(${scale.toFixed(4)})`;\n } else {\n from['opacity'] = 0;\n }\n // note, including `transform: none` avoids quirky Safari behavior\n // that can hide the animation.\n return [from, {'transform': 'none'}];\n }\n}\n\nfunction shouldReduceMotion() {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n"]}
package/tabs/lib/tabs.js CHANGED
@@ -172,6 +172,8 @@ export class Tabs extends LitElement {
172
172
  Object.defineProperties(event, {
173
173
  'defaultPrevented': { value: false, writable: true, configurable: true },
174
174
  'preventDefault': {
175
+ // Type needed for closure conformance. Using the Event type results
176
+ // in a type error.
175
177
  value() {
176
178
  this.defaultPrevented = true;
177
179
  },
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.js","sourceRoot":"","sources":["tabs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAiB,MAAM,KAAK,CAAC;AAC/D,OAAO,EAAC,QAAQ,EAAE,qBAAqB,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAIzE,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,CAAC,SAAS,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IACrC,CAAC,YAAY,EAAE,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC;IACpD,CAAC,UAAU,EAAE,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;CAChD,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,IAAK,SAAQ,UAAU;IA2ClC;;OAEG;IACH,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,IAAI,oBAAoB;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,IAAc,WAAW;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAc,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;IACzE,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AE,EAAE;SAClC,CAAC,CAAC;IACL,CAAC;;AA3RD,kBAAkB;AACO,sBAAiB,GAAG;IAC3C,GAAG,UAAU,CAAC,iBAAiB;IAC/B,cAAc,EAAE,IAAI;CACrB,CAAC;AAOyB;IAA1B,QAAQ,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;qCAA8B;AAK7B;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;sCAAkB;AAKlB;IAAzB,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;sCAAc;AAMvC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAC,CAAC;2CAClC;AAOtB;IADC,qBAAqB,CAAC,EAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;mCAC5B;AAItB;IAAR,KAAK,EAAE;wCAA4B","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {html, isServer, LitElement, PropertyValues} from 'lit';\nimport {property, queryAssignedElements, state} from 'lit/decorators.js';\n\nimport {Tab, Variant} from './tab.js';\n\nconst NAVIGATION_KEYS = new Map([\n ['default', new Set(['Home', 'End'])],\n ['horizontal', new Set(['ArrowLeft', 'ArrowRight'])],\n ['vertical', new Set(['ArrowUp', 'ArrowDown'])]\n]);\n\n/**\n * @fires change Fired when the selected tab changes. The target's selected or\n * selectedItem and previousSelected or previousSelectedItem provide information\n * about the selection change. The change event is fired when a user interaction\n * like a space/enter key or click cause a selection change. The tab selection\n * based on these actions can be cancelled by calling preventDefault on the\n * triggering `keydown` or `click` event.\n *\n * @example\n * // perform an action if a tab is clicked\n * tabs.addEventListener('change', (event: Event) => {\n * if (event.target.selected === 2)\n * takeAction();\n * }\n * });\n *\n * // prevent a click from triggering tab selection under some condition\n * tabs.addEventListener('click', (event: Event) => {\n * if (notReady)\n * event.preventDefault();\n * }\n * });\n *\n */\nexport class Tabs extends LitElement {\n /** @nocollapse */\n static override readonly shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true\n };\n\n /**\n * Styling variant to display, 'primary' or 'secondary' and can also\n * include `vertical`.\n * Defaults to `primary`.\n */\n @property({reflect: true}) variant: Variant = 'primary';\n\n /**\n * Whether or not the item is `disabled`.\n */\n @property({type: Boolean}) disabled = false;\n\n /**\n * Index of the selected item.\n */\n @property({type: Number}) selected = 0;\n\n /**\n * Whether or not to select an item when focused.\n */\n @property({type: Boolean, attribute: 'select-on-focus'})\n selectOnFocus = false;\n\n private previousSelected = -1;\n private orientation = 'horizontal';\n private readonly scrollMargin = 48;\n\n @queryAssignedElements({selector: 'md-tab', flatten: true})\n private readonly items!: Tab[];\n\n // this tracks if items have changed, which triggers rendering so they can\n // be kept in sync\n @state() private itemsDirty = false;\n\n private readonly selectedAttribute = `selected`;\n\n /**\n * The item currently selected.\n */\n get selectedItem() {\n return this.items[this.selected];\n }\n\n /**\n * The item previously selected.\n */\n get previousSelectedItem() {\n return this.items[this.previousSelected];\n }\n\n /**\n * The item currently focused.\n */\n protected get focusedItem() {\n return this.items.find((e: HTMLElement) => e.matches(':focus-within'));\n }\n\n constructor() {\n super();\n if (!isServer) {\n this.addEventListener('keydown', this.handleKeydown);\n this.addEventListener('keyup', this.handleKeyup);\n this.addEventListener('focusout', this.handleFocusout);\n }\n }\n\n override connectedCallback() {\n super.connectedCallback();\n this.setAttribute('role', 'tablist');\n }\n\n // focus item on keydown and optionally select it\n private readonly handleKeydown = async (event: KeyboardEvent) => {\n const {key} = event;\n const shouldHandleKey = NAVIGATION_KEYS.get('default')!.has(key) ||\n NAVIGATION_KEYS.get(this.orientation)!.has(key);\n // await to after user may cancel event.\n if (!shouldHandleKey || (await this.wasEventPrevented(event, true)) ||\n this.disabled) {\n return;\n }\n let indexToFocus = -1;\n const focused = this.focusedItem ?? this.selectedItem;\n const itemCount = this.items.length;\n const isPrevKey = key === 'ArrowLeft' || key === 'ArrowUp';\n if (key === 'Home') {\n indexToFocus = 0;\n } else if (key === 'End') {\n indexToFocus = itemCount - 1;\n } else {\n const focusedIndex = this.items.indexOf(focused) || 0;\n indexToFocus = focusedIndex + (isPrevKey ? -1 : 1);\n indexToFocus =\n indexToFocus < 0 ? itemCount - 1 : indexToFocus % itemCount;\n }\n const itemToFocus =\n this.findFocusableItem(indexToFocus, key === 'End' || isPrevKey);\n indexToFocus = this.items.indexOf(itemToFocus!);\n if (itemToFocus !== null && itemToFocus !== focused) {\n this.updateFocusableItem(itemToFocus);\n itemToFocus.focus();\n if (this.selectOnFocus) {\n this.selected = indexToFocus;\n await this.dispatchInteraction();\n }\n }\n };\n\n // scroll to item on keyup.\n private readonly handleKeyup = () => {\n this.scrollItemIntoView(this.focusedItem ?? this.selectedItem);\n };\n\n // restore focus to selected item when blurring.\n private readonly handleFocusout = async () => {\n await this.updateComplete;\n const nowFocused =\n (this.getRootNode() as unknown as DocumentOrShadowRoot).activeElement as\n Tab;\n if (this.items.indexOf(nowFocused) === -1) {\n this.updateFocusableItem(this.selectedItem);\n }\n };\n\n private findFocusableItem(i = -1, prev = false, tries = 0): Tab|null {\n const itemCount = this.items.length - 1;\n while (this.items[i]?.disabled && tries <= itemCount) {\n tries++;\n i = (i + (prev ? -1 : 1));\n if (i > itemCount) {\n return this.findFocusableItem(0, false, tries);\n } else if (i < 0) {\n return this.findFocusableItem(itemCount, true, tries);\n }\n }\n return this.items[i] ?? null;\n }\n\n // Note, this is async to allow the event to bubble to user code, which\n // may call `preventDefault`. If it does, avoid performing the tabs action\n // which is selecting a new tab. Sometimes, the native event must be\n // prevented to avoid, for example, scrolling. In this case, the event is\n // patched to be able to detect if the user calls prevent default.\n // Alternatively, the event could be stopped and re-dispatched synchroously,\n // but this would be complicated since the event should be re-dispatched from\n // the initial element to potentially trigger a native action (e.g. a history\n // navigation via a tab label), and this could result in some listener hearing\n // 2x events.\n private async wasEventPrevented(event: Event, preventNativeDefault = false) {\n if (preventNativeDefault) {\n // prevent native default to stop, e.g. scrolling.\n event.preventDefault();\n // reset prevention to see if user is cancelling this action.\n Object.defineProperties(event, {\n 'defaultPrevented': {value: false, writable: true, configurable: true},\n 'preventDefault': {\n value() {\n this.defaultPrevented = true;\n },\n writable: true,\n configurable: true\n }\n });\n }\n // allow event to propagate to user code.\n await new Promise(requestAnimationFrame);\n return event.defaultPrevented;\n }\n\n private async dispatchInteraction() {\n // wait for items to render.\n await new Promise(requestAnimationFrame);\n const event = new Event('change', {bubbles: true});\n this.dispatchEvent(event);\n }\n\n protected override willUpdate(changed: PropertyValues) {\n if (changed.has('selected')) {\n this.previousSelected = changed.get('selected') ?? -1;\n }\n if (changed.has('variant')) {\n this.orientation =\n this.variant.includes('vertical') ? 'vertical' : 'horizontal';\n }\n if (this.itemsDirty) {\n this.itemsDirty = false;\n this.previousSelected = -1;\n }\n }\n\n protected override async updated(changed: PropertyValues) {\n const itemsOrVariantChanged =\n changed.has('itemsDirty') || changed.has('variant');\n // sync state with items.\n if (itemsOrVariantChanged || changed.has('disabled')) {\n this.items.forEach((item, i) => {\n item.selected = this.selected === i;\n item.variant = this.variant;\n item.disabled = this.disabled;\n });\n }\n if (itemsOrVariantChanged || changed.has('selected')) {\n if (this.previousSelectedItem !== this.selectedItem) {\n this.previousSelectedItem?.removeAttribute(this.selectedAttribute);\n this.selectedItem?.setAttribute(this.selectedAttribute, '');\n }\n if (this.selectedItem !== this.focusedItem) {\n this.updateFocusableItem(this.selectedItem);\n }\n await this.scrollItemIntoView();\n }\n }\n\n private updateFocusableItem(focusableItem: HTMLElement|null) {\n for (const item of this.items) {\n item.focusable = item === focusableItem;\n }\n }\n\n protected override render() {\n return html`\n <slot @slotchange=${this.handleSlotChange} @click=${\n this.handleItemClick}></slot>\n `;\n }\n\n private async handleItemClick(event: Event) {\n const {target} = event;\n if (await this.wasEventPrevented(event)) {\n return;\n }\n const item = (target as Element).closest(`${this.localName} > *`) as Tab;\n const i = this.items.indexOf(item);\n if (i > -1 && this.selected !== i) {\n this.selected = i;\n this.updateFocusableItem(this.selectedItem);\n // note, Safari will not focus the button here, but if focus is manually\n // triggered, this can match focus-visible and show the focus-ring,\n // so avoid the temptation to cal focus!\n await this.dispatchInteraction();\n }\n }\n\n private handleSlotChange() {\n this.itemsDirty = true;\n }\n\n private async itemsUpdateComplete() {\n for (const item of this.items) {\n await item.updateComplete;\n }\n return true;\n }\n\n // ensures the given item is visible in view; defaults to the selected item\n private async scrollItemIntoView(item = this.selectedItem) {\n if (!item) {\n return;\n }\n // wait for items to render.\n await this.itemsUpdateComplete();\n const isVertical = this.orientation === 'vertical';\n const offset = isVertical ? item.offsetTop : item.offsetLeft;\n const extent = isVertical ? item.offsetHeight : item.offsetWidth;\n const scroll = isVertical ? this.scrollTop : this.scrollLeft;\n const hostExtent = isVertical ? this.offsetHeight : this.offsetWidth;\n const min = offset - this.scrollMargin;\n const max = offset + extent - hostExtent + this.scrollMargin;\n const to = Math.min(min, Math.max(max, scroll));\n const behavior =\n // type annotation because `instant` is valid but not included in type.\n this.focusedItem !== undefined ? 'smooth' : 'instant' as ScrollBehavior;\n this.scrollTo({\n behavior,\n [isVertical ? 'left' : 'top']: 0,\n [isVertical ? 'top' : 'left']: to\n });\n }\n}\n"]}
1
+ {"version":3,"file":"tabs.js","sourceRoot":"","sources":["tabs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAiB,MAAM,KAAK,CAAC;AAC/D,OAAO,EAAC,QAAQ,EAAE,qBAAqB,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAIzE,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,CAAC,SAAS,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IACrC,CAAC,YAAY,EAAE,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,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-License-Identifier: Apache-2.0\n */\n\nimport {html, isServer, LitElement, PropertyValues} from 'lit';\nimport {property, queryAssignedElements, state} from 'lit/decorators.js';\n\nimport {Tab, Variant} from './tab.js';\n\nconst NAVIGATION_KEYS = new Map([\n ['default', new Set(['Home', 'End'])],\n ['horizontal', new Set(['ArrowLeft', 'ArrowRight'])],\n ['vertical', new Set(['ArrowUp', 'ArrowDown'])]\n]);\n\n/**\n * @fires change Fired when the selected tab changes. The target's selected or\n * selectedItem and previousSelected or previousSelectedItem provide information\n * about the selection change. The change event is fired when a user interaction\n * like a space/enter key or click cause a selection change. The tab selection\n * based on these actions can be cancelled by calling preventDefault on the\n * triggering `keydown` or `click` event.\n *\n * @example\n * // perform an action if a tab is clicked\n * tabs.addEventListener('change', (event: Event) => {\n * if (event.target.selected === 2)\n * takeAction();\n * }\n * });\n *\n * // prevent a click from triggering tab selection under some condition\n * tabs.addEventListener('click', (event: Event) => {\n * if (notReady)\n * event.preventDefault();\n * }\n * });\n *\n */\nexport class Tabs extends LitElement {\n /** @nocollapse */\n static override readonly shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true\n };\n\n /**\n * Styling variant to display, 'primary' or 'secondary' and can also\n * include `vertical`.\n * Defaults to `primary`.\n */\n @property({reflect: true}) variant: Variant = 'primary';\n\n /**\n * Whether or not the item is `disabled`.\n */\n @property({type: Boolean}) disabled = false;\n\n /**\n * Index of the selected item.\n */\n @property({type: Number}) selected = 0;\n\n /**\n * Whether or not to select an item when focused.\n */\n @property({type: Boolean, attribute: 'select-on-focus'})\n selectOnFocus = false;\n\n private previousSelected = -1;\n private orientation = 'horizontal';\n private readonly scrollMargin = 48;\n\n @queryAssignedElements({selector: 'md-tab', flatten: true})\n private readonly items!: Tab[];\n\n // this tracks if items have changed, which triggers rendering so they can\n // be kept in sync\n @state() private itemsDirty = false;\n\n private readonly selectedAttribute = `selected`;\n\n /**\n * The item currently selected.\n */\n get selectedItem() {\n return this.items[this.selected];\n }\n\n /**\n * The item previously selected.\n */\n get previousSelectedItem() {\n return this.items[this.previousSelected];\n }\n\n /**\n * The item currently focused.\n */\n protected get focusedItem() {\n return this.items.find((e: HTMLElement) => e.matches(':focus-within'));\n }\n\n constructor() {\n super();\n if (!isServer) {\n this.addEventListener('keydown', this.handleKeydown);\n this.addEventListener('keyup', this.handleKeyup);\n this.addEventListener('focusout', this.handleFocusout);\n }\n }\n\n override connectedCallback() {\n super.connectedCallback();\n this.setAttribute('role', 'tablist');\n }\n\n // focus item on keydown and optionally select it\n private readonly handleKeydown = async (event: KeyboardEvent) => {\n const {key} = event;\n const shouldHandleKey = NAVIGATION_KEYS.get('default')!.has(key) ||\n NAVIGATION_KEYS.get(this.orientation)!.has(key);\n // await to after user may cancel event.\n if (!shouldHandleKey || (await this.wasEventPrevented(event, true)) ||\n this.disabled) {\n return;\n }\n let indexToFocus = -1;\n const focused = this.focusedItem ?? this.selectedItem;\n const itemCount = this.items.length;\n const isPrevKey = key === 'ArrowLeft' || key === 'ArrowUp';\n if (key === 'Home') {\n indexToFocus = 0;\n } else if (key === 'End') {\n indexToFocus = itemCount - 1;\n } else {\n const focusedIndex = this.items.indexOf(focused) || 0;\n indexToFocus = focusedIndex + (isPrevKey ? -1 : 1);\n indexToFocus =\n indexToFocus < 0 ? itemCount - 1 : indexToFocus % itemCount;\n }\n const itemToFocus =\n this.findFocusableItem(indexToFocus, key === 'End' || isPrevKey);\n indexToFocus = this.items.indexOf(itemToFocus!);\n if (itemToFocus !== null && itemToFocus !== focused) {\n this.updateFocusableItem(itemToFocus);\n itemToFocus.focus();\n if (this.selectOnFocus) {\n this.selected = indexToFocus;\n await this.dispatchInteraction();\n }\n }\n };\n\n // scroll to item on keyup.\n private readonly handleKeyup = () => {\n this.scrollItemIntoView(this.focusedItem ?? this.selectedItem);\n };\n\n // restore focus to selected item when blurring.\n private readonly handleFocusout = async () => {\n await this.updateComplete;\n const nowFocused =\n (this.getRootNode() as unknown as DocumentOrShadowRoot).activeElement as\n Tab;\n if (this.items.indexOf(nowFocused) === -1) {\n this.updateFocusableItem(this.selectedItem);\n }\n };\n\n private findFocusableItem(i = -1, prev = false, tries = 0): Tab|null {\n const itemCount = this.items.length - 1;\n while (this.items[i]?.disabled && tries <= itemCount) {\n tries++;\n i = (i + (prev ? -1 : 1));\n if (i > itemCount) {\n return this.findFocusableItem(0, false, tries);\n } else if (i < 0) {\n return this.findFocusableItem(itemCount, true, tries);\n }\n }\n return this.items[i] ?? null;\n }\n\n // Note, this is async to allow the event to bubble to user code, which\n // may call `preventDefault`. If it does, avoid performing the tabs action\n // which is selecting a new tab. Sometimes, the native event must be\n // prevented to avoid, for example, scrolling. In this case, the event is\n // patched to be able to detect if the user calls prevent default.\n // Alternatively, the event could be stopped and re-dispatched synchroously,\n // but this would be complicated since the event should be re-dispatched from\n // the initial element to potentially trigger a native action (e.g. a history\n // navigation via a tab label), and this could result in some listener hearing\n // 2x events.\n private async wasEventPrevented(event: Event, preventNativeDefault = false) {\n if (preventNativeDefault) {\n // prevent native default to stop, e.g. scrolling.\n event.preventDefault();\n // reset prevention to see if user is cancelling this action.\n Object.defineProperties(event, {\n 'defaultPrevented': {value: false, writable: true, configurable: true},\n 'preventDefault': {\n // Type needed for closure conformance. Using the Event type results\n // in a type error.\n value(this: {defaultPrevented: boolean}) {\n this.defaultPrevented = true;\n },\n writable: true,\n configurable: true\n }\n });\n }\n // allow event to propagate to user code.\n await new Promise(requestAnimationFrame);\n return event.defaultPrevented;\n }\n\n private async dispatchInteraction() {\n // wait for items to render.\n await new Promise(requestAnimationFrame);\n const event = new Event('change', {bubbles: true});\n this.dispatchEvent(event);\n }\n\n protected override willUpdate(changed: PropertyValues) {\n if (changed.has('selected')) {\n this.previousSelected = changed.get('selected') ?? -1;\n }\n if (changed.has('variant')) {\n this.orientation =\n this.variant.includes('vertical') ? 'vertical' : 'horizontal';\n }\n if (this.itemsDirty) {\n this.itemsDirty = false;\n this.previousSelected = -1;\n }\n }\n\n protected override async updated(changed: PropertyValues) {\n const itemsOrVariantChanged =\n changed.has('itemsDirty') || changed.has('variant');\n // sync state with items.\n if (itemsOrVariantChanged || changed.has('disabled')) {\n this.items.forEach((item, i) => {\n item.selected = this.selected === i;\n item.variant = this.variant;\n item.disabled = this.disabled;\n });\n }\n if (itemsOrVariantChanged || changed.has('selected')) {\n if (this.previousSelectedItem !== this.selectedItem) {\n this.previousSelectedItem?.removeAttribute(this.selectedAttribute);\n this.selectedItem?.setAttribute(this.selectedAttribute, '');\n }\n if (this.selectedItem !== this.focusedItem) {\n this.updateFocusableItem(this.selectedItem);\n }\n await this.scrollItemIntoView();\n }\n }\n\n private updateFocusableItem(focusableItem: HTMLElement|null) {\n for (const item of this.items) {\n item.focusable = item === focusableItem;\n }\n }\n\n protected override render() {\n return html`\n <slot @slotchange=${this.handleSlotChange} @click=${\n this.handleItemClick}></slot>\n `;\n }\n\n private async handleItemClick(event: Event) {\n const {target} = event;\n if (await this.wasEventPrevented(event)) {\n return;\n }\n const item = (target as Element).closest(`${this.localName} > *`) as Tab;\n const i = this.items.indexOf(item);\n if (i > -1 && this.selected !== i) {\n this.selected = i;\n this.updateFocusableItem(this.selectedItem);\n // note, Safari will not focus the button here, but if focus is manually\n // triggered, this can match focus-visible and show the focus-ring,\n // so avoid the temptation to cal focus!\n await this.dispatchInteraction();\n }\n }\n\n private handleSlotChange() {\n this.itemsDirty = true;\n }\n\n private async itemsUpdateComplete() {\n for (const item of this.items) {\n await item.updateComplete;\n }\n return true;\n }\n\n // ensures the given item is visible in view; defaults to the selected item\n private async scrollItemIntoView(item = this.selectedItem) {\n if (!item) {\n return;\n }\n // wait for items to render.\n await this.itemsUpdateComplete();\n const isVertical = this.orientation === 'vertical';\n const offset = isVertical ? item.offsetTop : item.offsetLeft;\n const extent = isVertical ? item.offsetHeight : item.offsetWidth;\n const scroll = isVertical ? this.scrollTop : this.scrollLeft;\n const hostExtent = isVertical ? this.offsetHeight : this.offsetWidth;\n const min = offset - this.scrollMargin;\n const max = offset + extent - hostExtent + this.scrollMargin;\n const to = Math.min(min, Math.max(max, scroll));\n const behavior =\n // type annotation because `instant` is valid but not included in type.\n this.focusedItem !== undefined ? 'smooth' : 'instant' as ScrollBehavior;\n this.scrollTo({\n behavior,\n [isVertical ? 'left' : 'top']: 0,\n [isVertical ? 'top' : 'left']: to\n });\n }\n}\n"]}
@@ -32,10 +32,6 @@
32
32
  cursor: default;
33
33
  }
34
34
 
35
- .counter {
36
- white-space: nowrap;
37
- }
38
-
39
35
  @include icon.styles;
40
36
  @include input.styles;
41
37
  }
@@ -4,6 +4,6 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { css } from 'lit';
7
- export const styles = css `:host{display:inline-flex;outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.text-field{display:inline-flex;flex:1}.field{cursor:text;flex:1}.disabled .field{cursor:default}.counter{white-space:nowrap}.icon{color:currentColor;display:flex;fill:currentColor}.icon ::slotted(*){display:flex}[hasstart] .icon.leading{font-size:var(--_leading-icon-size);height:var(--_leading-icon-size);width:var(--_leading-icon-size)}[hasend] .icon.trailing{font-size:var(--_trailing-icon-size);height:var(--_trailing-icon-size);width:var(--_trailing-icon-size)}input{appearance:none;background:none;border:none;caret-color:var(--_caret-color);color:currentColor;font:inherit;outline:none;padding:0;text-align:inherit;width:100%}input::placeholder{color:currentColor;opacity:1}input::-webkit-calendar-picker-indicator{display:none}@media(forced-colors: active){input{background-color:Field}}:focus-within input{caret-color:var(--_focus-caret-color)}.error:focus-within input{caret-color:var(--_error-focus-caret-color)}.text-field:not(.disabled) .prefix{color:var(--_input-text-prefix-color)}.text-field:not(.disabled) .suffix{color:var(--_input-text-suffix-color)}.text-field:not(.disabled) input::placeholder{color:var(--_input-text-placeholder-color)}.prefix{padding-inline-end:var(--_input-text-prefix-padding)}.suffix{padding-inline-start:var(--_input-text-suffix-padding)}/*# sourceMappingURL=shared-styles.css.map */
7
+ export const styles = css `:host{display:inline-flex;outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.text-field{display:inline-flex;flex:1}.field{cursor:text;flex:1}.disabled .field{cursor:default}.icon{color:currentColor;display:flex;fill:currentColor}.icon ::slotted(*){display:flex}[hasstart] .icon.leading{font-size:var(--_leading-icon-size);height:var(--_leading-icon-size);width:var(--_leading-icon-size)}[hasend] .icon.trailing{font-size:var(--_trailing-icon-size);height:var(--_trailing-icon-size);width:var(--_trailing-icon-size)}input{appearance:none;background:none;border:none;caret-color:var(--_caret-color);color:currentColor;font:inherit;outline:none;padding:0;text-align:inherit;width:100%}input::placeholder{color:currentColor;opacity:1}input::-webkit-calendar-picker-indicator{display:none}@media(forced-colors: active){input{background-color:Field}}:focus-within input{caret-color:var(--_focus-caret-color)}.error:focus-within input{caret-color:var(--_error-focus-caret-color)}.text-field:not(.disabled) .prefix{color:var(--_input-text-prefix-color)}.text-field:not(.disabled) .suffix{color:var(--_input-text-suffix-color)}.text-field:not(.disabled) input::placeholder{color:var(--_input-text-placeholder-color)}.prefix{padding-inline-end:var(--_input-text-prefix-padding)}.suffix{padding-inline-start:var(--_input-text-suffix-padding)}/*# sourceMappingURL=shared-styles.css.map */
8
8
  `;
9
9
  //# sourceMappingURL=shared-styles.css.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared-styles.css.js","sourceRoot":"","sources":["shared-styles.css.ts"],"names":[],"mappings":"AAAA;;;;IAII;AACH,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;CACzB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n import {css} from 'lit';\n export const styles = css`:host{display:inline-flex;outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.text-field{display:inline-flex;flex:1}.field{cursor:text;flex:1}.disabled .field{cursor:default}.counter{white-space:nowrap}.icon{color:currentColor;display:flex;fill:currentColor}.icon ::slotted(*){display:flex}[hasstart] .icon.leading{font-size:var(--_leading-icon-size);height:var(--_leading-icon-size);width:var(--_leading-icon-size)}[hasend] .icon.trailing{font-size:var(--_trailing-icon-size);height:var(--_trailing-icon-size);width:var(--_trailing-icon-size)}input{appearance:none;background:none;border:none;caret-color:var(--_caret-color);color:currentColor;font:inherit;outline:none;padding:0;text-align:inherit;width:100%}input::placeholder{color:currentColor;opacity:1}input::-webkit-calendar-picker-indicator{display:none}@media(forced-colors: active){input{background-color:Field}}:focus-within input{caret-color:var(--_focus-caret-color)}.error:focus-within input{caret-color:var(--_error-focus-caret-color)}.text-field:not(.disabled) .prefix{color:var(--_input-text-prefix-color)}.text-field:not(.disabled) .suffix{color:var(--_input-text-suffix-color)}.text-field:not(.disabled) input::placeholder{color:var(--_input-text-placeholder-color)}.prefix{padding-inline-end:var(--_input-text-prefix-padding)}.suffix{padding-inline-start:var(--_input-text-suffix-padding)}/*# sourceMappingURL=shared-styles.css.map */\n`;\n "]}
1
+ {"version":3,"file":"shared-styles.css.js","sourceRoot":"","sources":["shared-styles.css.ts"],"names":[],"mappings":"AAAA;;;;IAII;AACH,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;CACzB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n import {css} from 'lit';\n export const styles = css`:host{display:inline-flex;outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.text-field{display:inline-flex;flex:1}.field{cursor:text;flex:1}.disabled .field{cursor:default}.icon{color:currentColor;display:flex;fill:currentColor}.icon ::slotted(*){display:flex}[hasstart] .icon.leading{font-size:var(--_leading-icon-size);height:var(--_leading-icon-size);width:var(--_leading-icon-size)}[hasend] .icon.trailing{font-size:var(--_trailing-icon-size);height:var(--_trailing-icon-size);width:var(--_trailing-icon-size)}input{appearance:none;background:none;border:none;caret-color:var(--_caret-color);color:currentColor;font:inherit;outline:none;padding:0;text-align:inherit;width:100%}input::placeholder{color:currentColor;opacity:1}input::-webkit-calendar-picker-indicator{display:none}@media(forced-colors: active){input{background-color:Field}}:focus-within input{caret-color:var(--_focus-caret-color)}.error:focus-within input{caret-color:var(--_error-focus-caret-color)}.text-field:not(.disabled) .prefix{color:var(--_input-text-prefix-color)}.text-field:not(.disabled) .suffix{color:var(--_input-text-suffix-color)}.text-field:not(.disabled) input::placeholder{color:var(--_input-text-placeholder-color)}.prefix{padding-inline-end:var(--_input-text-prefix-padding)}.suffix{padding-inline-start:var(--_input-text-suffix-padding)}/*# sourceMappingURL=shared-styles.css.map */\n`;\n "]}
@@ -41,7 +41,7 @@ export declare abstract class TextField extends LitElement {
41
41
  * native `validationMessage`.
42
42
  */
43
43
  errorText: string;
44
- label?: string;
44
+ label: string;
45
45
  required: boolean;
46
46
  /**
47
47
  * The current value of the text field. It is always a string.
@@ -188,12 +188,6 @@ export declare abstract class TextField extends LitElement {
188
188
  */
189
189
  private dirty;
190
190
  private focused;
191
- /**
192
- * When set to true, the error text's `role="alert"` will be removed, then
193
- * re-added after an animation frame. This will re-announce an error message
194
- * to screen readers.
195
- */
196
- private refreshErrorAlert;
197
191
  /**
198
192
  * Whether or not a native error has been reported via `reportValidity()`.
199
193
  */
@@ -205,6 +199,7 @@ export declare abstract class TextField extends LitElement {
205
199
  private nativeErrorText;
206
200
  private get hasError();
207
201
  private readonly input?;
202
+ private readonly field?;
208
203
  private readonly leadingIcons;
209
204
  private readonly trailingIcons;
210
205
  private readonly internals;
@@ -307,16 +302,10 @@ export declare abstract class TextField extends LitElement {
307
302
  private renderLeadingIcon;
308
303
  private renderTrailingIcon;
309
304
  private renderInput;
310
- private getAriaDescribedBy;
311
305
  private renderPrefix;
312
306
  private renderSuffix;
313
307
  private renderAffix;
314
- private renderSupportingText;
315
- private getSupportingText;
316
308
  private getErrorText;
317
- private shouldErrorAnnounce;
318
- private renderCounter;
319
- private getCounterText;
320
309
  private handleFocusin;
321
310
  private handleFocusout;
322
311
  private handleInput;
@@ -134,6 +134,7 @@ export class TextField extends LitElement {
134
134
  * native `validationMessage`.
135
135
  */
136
136
  this.errorText = '';
137
+ this.label = '';
137
138
  this.required = false;
138
139
  /**
139
140
  * The current value of the text field. It is always a string.
@@ -221,12 +222,6 @@ export class TextField extends LitElement {
221
222
  */
222
223
  this.dirty = false;
223
224
  this.focused = false;
224
- /**
225
- * When set to true, the error text's `role="alert"` will be removed, then
226
- * re-added after an animation frame. This will re-announce an error message
227
- * to screen readers.
228
- */
229
- this.refreshErrorAlert = false;
230
225
  /**
231
226
  * Whether or not a native error has been reported via `reportValidity()`.
232
227
  */
@@ -292,9 +287,8 @@ export class TextField extends LitElement {
292
287
  const prevMessage = this.getErrorText();
293
288
  this.nativeError = !valid;
294
289
  this.nativeErrorText = this.validationMessage;
295
- const needsRefresh = this.shouldErrorAnnounce() && prevMessage === this.getErrorText();
296
- if (needsRefresh) {
297
- this.refreshErrorAlert = true;
290
+ if (prevMessage === this.getErrorText()) {
291
+ this.field?.reannounceError();
298
292
  }
299
293
  }
300
294
  return valid;
@@ -405,13 +399,6 @@ export class TextField extends LitElement {
405
399
  // before checking its value.
406
400
  this.value = value;
407
401
  }
408
- if (this.refreshErrorAlert) {
409
- // The past render cycle removed the role="alert" from the error message.
410
- // Re-add it after an animation frame to re-announce the error.
411
- requestAnimationFrame(() => {
412
- this.refreshErrorAlert = false;
413
- });
414
- }
415
402
  }
416
403
  renderField() {
417
404
  const prefix = this.renderPrefix();
@@ -424,15 +411,17 @@ export class TextField extends LitElement {
424
411
  ?focused=${this.focused}
425
412
  ?has-end=${this.hasTrailingIcon}
426
413
  ?has-start=${this.hasLeadingIcon}
427
- .label=${this.label}
414
+ label=${this.label}
428
415
  ?populated=${!!this.value}
429
416
  ?required=${this.required}
417
+ supporting-text=${this.supportingText}
418
+ error-text=${this.getErrorText()}
419
+ count=${this.value.length}
420
+ max=${this.maxLength}
430
421
  >
431
422
  ${this.renderLeadingIcon()}
432
423
  ${prefix}${input}${suffix}
433
424
  ${this.renderTrailingIcon()}
434
- ${this.renderSupportingText()}
435
- ${this.renderCounter()}
436
425
  </${this.fieldTag}>`;
437
426
  }
438
427
  renderLeadingIcon() {
@@ -453,39 +442,30 @@ export class TextField extends LitElement {
453
442
  const style = { direction: this.textDirection };
454
443
  // TODO(b/243805848): remove `as unknown as number` once lit analyzer is
455
444
  // fixed
456
- return html `<input
457
- style=${styleMap(style)}
458
- aria-autocomplete=${this.ariaAutoComplete || nothing}
459
- aria-describedby=${this.getAriaDescribedBy() || nothing}
460
- aria-expanded=${this.ariaExpanded || nothing}
461
- aria-invalid=${this.hasError}
462
- aria-label=${this.ariaLabel || this.label || nothing}
463
- ?disabled=${this.disabled}
464
- max=${(this.max || nothing)}
465
- maxlength=${this.maxLength > -1 ? this.maxLength : nothing}
466
- min=${(this.min || nothing)}
467
- minlength=${this.minLength > -1 ? this.minLength : nothing}
468
- pattern=${this.pattern || nothing}
469
- placeholder=${this.placeholder || nothing}
470
- ?readonly=${this.readOnly}
471
- ?required=${this.required}
472
- step=${(this.step || nothing)}
473
- type=${this.type}
474
- .value=${live(this.value)}
475
- @change=${this.redispatchEvent}
476
- @input=${this.handleInput}
477
- @select=${this.redispatchEvent}
478
- >`;
479
- }
480
- getAriaDescribedBy() {
481
- const ids = [];
482
- if (this.getSupportingText()) {
483
- ids.push('support');
484
- }
485
- if (this.getCounterText()) {
486
- ids.push('counter');
487
- }
488
- return ids.join(' ');
445
+ return html `
446
+ <input
447
+ style=${styleMap(style)}
448
+ aria-describedby="description"
449
+ aria-invalid=${this.hasError}
450
+ aria-label=${this.ariaLabel || this.label || nothing}
451
+ ?disabled=${this.disabled}
452
+ max=${(this.max || nothing)}
453
+ maxlength=${this.maxLength > -1 ? this.maxLength : nothing}
454
+ min=${(this.min || nothing)}
455
+ minlength=${this.minLength > -1 ? this.minLength : nothing}
456
+ pattern=${this.pattern || nothing}
457
+ placeholder=${this.placeholder || nothing}
458
+ ?readonly=${this.readOnly}
459
+ ?required=${this.required}
460
+ step=${(this.step || nothing)}
461
+ type=${this.type}
462
+ .value=${live(this.value)}
463
+ @change=${this.redispatchEvent}
464
+ @input=${this.handleInput}
465
+ @select=${this.redispatchEvent}
466
+ >
467
+ <div id="description" slot="aria-describedby"></div>
468
+ `;
489
469
  }
490
470
  renderPrefix() {
491
471
  return this.renderAffix(this.prefixText, /* isSuffix */ false);
@@ -503,43 +483,9 @@ export class TextField extends LitElement {
503
483
  };
504
484
  return html `<span class="${classMap(classes)}">${text}</span>`;
505
485
  }
506
- renderSupportingText() {
507
- const text = this.getSupportingText();
508
- if (!text) {
509
- return nothing;
510
- }
511
- return html `<span id="support"
512
- slot="supporting-text"
513
- role=${this.shouldErrorAnnounce() ? 'alert' : nothing}>${text}</span>`;
514
- }
515
- getSupportingText() {
516
- const errorText = this.getErrorText();
517
- return this.hasError && errorText ? errorText : this.supportingText;
518
- }
519
486
  getErrorText() {
520
487
  return this.error ? this.errorText : this.nativeErrorText;
521
488
  }
522
- shouldErrorAnnounce() {
523
- // Announce if there is an error and error text visible.
524
- // If refreshErrorAlert is true, do not announce. This will remove the
525
- // role="alert" attribute. Another render cycle will happen after an
526
- // animation frame to re-add the role.
527
- return this.hasError && !!this.getErrorText() && !this.refreshErrorAlert;
528
- }
529
- renderCounter() {
530
- const text = this.getCounterText();
531
- if (!text) {
532
- return nothing;
533
- }
534
- // TODO(b/244473435): add aria-label and announcements
535
- return html `<span id="counter"
536
- class="counter"
537
- slot="supporting-text-end">${text}</span>`;
538
- }
539
- getCounterText() {
540
- return this.maxLength > -1 ? `${this.value.length} / ${this.maxLength}` :
541
- '';
542
- }
543
489
  handleFocusin() {
544
490
  this.focused = true;
545
491
  }
@@ -674,9 +620,6 @@ __decorate([
674
620
  __decorate([
675
621
  state()
676
622
  ], TextField.prototype, "focused", void 0);
677
- __decorate([
678
- state()
679
- ], TextField.prototype, "refreshErrorAlert", void 0);
680
623
  __decorate([
681
624
  state()
682
625
  ], TextField.prototype, "nativeError", void 0);
@@ -686,6 +629,9 @@ __decorate([
686
629
  __decorate([
687
630
  query('input')
688
631
  ], TextField.prototype, "input", void 0);
632
+ __decorate([
633
+ query('.field')
634
+ ], TextField.prototype, "field", void 0);
689
635
  __decorate([
690
636
  queryAssignedElements({ slot: 'leadingicon' })
691
637
  ], TextField.prototype, "leadingIcons", void 0);