@material/web 1.0.2-nightly.f7a66a8.0 → 1.1.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.
Files changed (118) hide show
  1. package/checkbox/internal/checkbox.d.ts +1 -0
  2. package/checkbox/internal/checkbox.js +6 -1
  3. package/checkbox/internal/checkbox.js.map +1 -1
  4. package/chips/internal/_shared.scss +16 -3
  5. package/chips/internal/_trailing-icon.scss +2 -1
  6. package/chips/internal/assist-styles.css.js +1 -1
  7. package/chips/internal/assist-styles.css.js.map +1 -1
  8. package/chips/internal/chip-set.js +2 -6
  9. package/chips/internal/chip-set.js.map +1 -1
  10. package/chips/internal/chip.d.ts +8 -0
  11. package/chips/internal/chip.js +17 -2
  12. package/chips/internal/chip.js.map +1 -1
  13. package/chips/internal/filter-chip.d.ts +8 -0
  14. package/chips/internal/filter-chip.js +17 -4
  15. package/chips/internal/filter-chip.js.map +1 -1
  16. package/chips/internal/filter-styles.css.js +1 -1
  17. package/chips/internal/filter-styles.css.js.map +1 -1
  18. package/chips/internal/input-styles.css.js +1 -1
  19. package/chips/internal/input-styles.css.js.map +1 -1
  20. package/chips/internal/shared-styles.css.js +1 -1
  21. package/chips/internal/shared-styles.css.js.map +1 -1
  22. package/chips/internal/suggestion-styles.css.js +1 -1
  23. package/chips/internal/suggestion-styles.css.js.map +1 -1
  24. package/chips/internal/trailing-icon-styles.css.js +1 -1
  25. package/chips/internal/trailing-icon-styles.css.js.map +1 -1
  26. package/chips/internal/trailing-icons.js +8 -4
  27. package/chips/internal/trailing-icons.js.map +1 -1
  28. package/fab/internal/_shared.scss +1 -0
  29. package/fab/internal/shared-styles.css.js +1 -1
  30. package/fab/internal/shared-styles.css.js.map +1 -1
  31. package/field/internal/_content.scss +3 -1
  32. package/field/internal/shared-styles.css.js +1 -1
  33. package/field/internal/shared-styles.css.js.map +1 -1
  34. package/internal/aria/aria.d.ts +0 -29
  35. package/internal/aria/aria.js +0 -141
  36. package/internal/aria/aria.js.map +1 -1
  37. package/internal/controller/form-submitter.js +2 -2
  38. package/internal/controller/form-submitter.js.map +1 -1
  39. package/labs/behaviors/constraint-validation.d.ts +2 -2
  40. package/labs/behaviors/constraint-validation.js +18 -1
  41. package/labs/behaviors/constraint-validation.js.map +1 -1
  42. package/labs/behaviors/element-internals.js +1 -5
  43. package/labs/behaviors/element-internals.js.map +1 -1
  44. package/labs/behaviors/focusable.js +20 -7
  45. package/labs/behaviors/focusable.js.map +1 -1
  46. package/labs/behaviors/on-report-validity.d.ts +70 -0
  47. package/labs/behaviors/on-report-validity.js +185 -0
  48. package/labs/behaviors/on-report-validity.js.map +1 -0
  49. package/labs/behaviors/validators/checkbox-validator.d.ts +6 -3
  50. package/labs/behaviors/validators/checkbox-validator.js.map +1 -1
  51. package/labs/behaviors/validators/radio-validator.d.ts +38 -0
  52. package/labs/behaviors/validators/radio-validator.js +65 -0
  53. package/labs/behaviors/validators/radio-validator.js.map +1 -0
  54. package/labs/behaviors/validators/select-validator.d.ts +35 -0
  55. package/labs/behaviors/validators/select-validator.js +33 -0
  56. package/labs/behaviors/validators/select-validator.js.map +1 -0
  57. package/labs/behaviors/validators/text-field-validator.d.ts +110 -0
  58. package/labs/behaviors/validators/text-field-validator.js +146 -0
  59. package/labs/behaviors/validators/text-field-validator.js.map +1 -0
  60. package/labs/behaviors/validators/validator.d.ts +4 -0
  61. package/labs/behaviors/validators/validator.js.map +1 -1
  62. package/labs/card/internal/_outlined-card.scss +1 -1
  63. package/labs/card/internal/_shared.scss +10 -2
  64. package/labs/card/internal/outlined-styles.css.js +1 -1
  65. package/labs/card/internal/outlined-styles.css.js.map +1 -1
  66. package/labs/card/internal/shared-styles.css.js +1 -1
  67. package/labs/card/internal/shared-styles.css.js.map +1 -1
  68. package/labs/segmentedbutton/internal/_shared.scss +1 -0
  69. package/labs/segmentedbutton/internal/shared-styles.css.js +1 -1
  70. package/labs/segmentedbutton/internal/shared-styles.css.js.map +1 -1
  71. package/list/internal/list.js +2 -6
  72. package/list/internal/list.js.map +1 -1
  73. package/list/internal/listitem/_list-item.scss +2 -0
  74. package/list/internal/listitem/list-item-styles.css.js +1 -1
  75. package/list/internal/listitem/list-item-styles.css.js.map +1 -1
  76. package/menu/internal/controllers/menuItemController.d.ts +13 -1
  77. package/menu/internal/controllers/menuItemController.js +32 -6
  78. package/menu/internal/controllers/menuItemController.js.map +1 -1
  79. package/menu/internal/menu.js +7 -8
  80. package/menu/internal/menu.js.map +1 -1
  81. package/menu/internal/menuitem/menu-item.d.ts +2 -0
  82. package/menu/internal/menuitem/menu-item.js +13 -1
  83. package/menu/internal/menuitem/menu-item.js.map +1 -1
  84. package/package.json +1 -1
  85. package/radio/internal/radio.d.ts +11 -1
  86. package/radio/internal/radio.js +28 -2
  87. package/radio/internal/radio.js.map +1 -1
  88. package/radio/internal/single-selection-controller.d.ts +5 -5
  89. package/radio/internal/single-selection-controller.js +16 -14
  90. package/radio/internal/single-selection-controller.js.map +1 -1
  91. package/select/internal/_shared.scss +5 -0
  92. package/select/internal/select.d.ts +21 -72
  93. package/select/internal/select.js +106 -184
  94. package/select/internal/select.js.map +1 -1
  95. package/select/internal/selectoption/select-option.d.ts +2 -0
  96. package/select/internal/selectoption/select-option.js +13 -1
  97. package/select/internal/selectoption/select-option.js.map +1 -1
  98. package/select/internal/selectoption/selectOptionController.d.ts +7 -3
  99. package/select/internal/selectoption/selectOptionController.js +8 -11
  100. package/select/internal/selectoption/selectOptionController.js.map +1 -1
  101. package/select/internal/shared-styles.css.js +1 -1
  102. package/select/internal/shared-styles.css.js.map +1 -1
  103. package/switch/internal/_icon.scss +14 -10
  104. package/switch/internal/switch-styles.css.js +1 -1
  105. package/switch/internal/switch-styles.css.js.map +1 -1
  106. package/switch/internal/switch.js +12 -8
  107. package/switch/internal/switch.js.map +1 -1
  108. package/tabs/internal/tab.js +2 -6
  109. package/tabs/internal/tab.js.map +1 -1
  110. package/tabs/internal/tabs.js +2 -6
  111. package/tabs/internal/tabs.js.map +1 -1
  112. package/textfield/internal/text-field.d.ts +9 -74
  113. package/textfield/internal/text-field.js +34 -150
  114. package/textfield/internal/text-field.js.map +1 -1
  115. package/tokens/_md-comp-assist-chip.scss +11 -0
  116. package/tokens/_md-comp-filter-chip.scss +14 -0
  117. package/tokens/_md-comp-input-chip.scss +14 -0
  118. package/tokens/_md-comp-suggestion-chip.scss +11 -0
@@ -1 +1 @@
1
- {"version":3,"file":"switch-styles.css.js","sourceRoot":"","sources":["switch-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`@layer styles, hcm;@layer styles{:host{--_disabled-selected-handle-color: var(--md-switch-disabled-selected-handle-color, var(--md-sys-color-surface, #fef7ff));--_disabled-selected-handle-opacity: var(--md-switch-disabled-selected-handle-opacity, 1);--_disabled-selected-icon-color: var(--md-switch-disabled-selected-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-selected-icon-opacity: var(--md-switch-disabled-selected-icon-opacity, 0.38);--_disabled-selected-track-color: var(--md-switch-disabled-selected-track-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-track-opacity: var(--md-switch-disabled-track-opacity, 0.12);--_handle-shape: var(--md-switch-handle-shape, 9999px);--_pressed-handle-height: var(--md-switch-pressed-handle-height, 28px);--_pressed-handle-width: var(--md-switch-pressed-handle-width, 28px);--_selected-focus-handle-color: var(--md-switch-selected-focus-handle-color, var(--md-sys-color-primary-container, #eaddff));--_selected-focus-icon-color: var(--md-switch-selected-focus-icon-color, var(--md-sys-color-on-primary-container, #21005d));--_selected-focus-track-color: var(--md-switch-selected-focus-track-color, var(--md-sys-color-primary, #6750a4));--_selected-handle-color: var(--md-switch-selected-handle-color, var(--md-sys-color-on-primary, #fff));--_selected-handle-height: var(--md-switch-selected-handle-height, 24px);--_selected-handle-width: var(--md-switch-selected-handle-width, 24px);--_selected-hover-handle-color: var(--md-switch-selected-hover-handle-color, var(--md-sys-color-primary-container, #eaddff));--_selected-hover-icon-color: var(--md-switch-selected-hover-icon-color, var(--md-sys-color-on-primary-container, #21005d));--_selected-hover-state-layer-color: var(--md-switch-selected-hover-state-layer-color, var(--md-sys-color-primary, #6750a4));--_selected-hover-state-layer-opacity: var(--md-switch-selected-hover-state-layer-opacity, 0.08);--_selected-hover-track-color: var(--md-switch-selected-hover-track-color, var(--md-sys-color-primary, #6750a4));--_selected-icon-color: var(--md-switch-selected-icon-color, var(--md-sys-color-on-primary-container, #21005d));--_selected-icon-size: var(--md-switch-selected-icon-size, 16px);--_selected-pressed-handle-color: var(--md-switch-selected-pressed-handle-color, var(--md-sys-color-primary-container, #eaddff));--_selected-pressed-icon-color: var(--md-switch-selected-pressed-icon-color, var(--md-sys-color-on-primary-container, #21005d));--_selected-pressed-state-layer-color: var(--md-switch-selected-pressed-state-layer-color, var(--md-sys-color-primary, #6750a4));--_selected-pressed-state-layer-opacity: var(--md-switch-selected-pressed-state-layer-opacity, 0.12);--_selected-pressed-track-color: var(--md-switch-selected-pressed-track-color, var(--md-sys-color-primary, #6750a4));--_selected-track-color: var(--md-switch-selected-track-color, var(--md-sys-color-primary, #6750a4));--_state-layer-shape: var(--md-switch-state-layer-shape, 9999px);--_state-layer-size: var(--md-switch-state-layer-size, 40px);--_track-height: var(--md-switch-track-height, 32px);--_track-outline-width: var(--md-switch-track-outline-width, 2px);--_track-shape: var(--md-switch-track-shape, 9999px);--_track-width: var(--md-switch-track-width, 52px);--_with-icon-handle-height: var(--md-switch-with-icon-handle-height, 24px);--_with-icon-handle-width: var(--md-switch-with-icon-handle-width, 24px);--_disabled-handle-color: var(--md-switch-disabled-handle-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-handle-opacity: var(--md-switch-disabled-handle-opacity, 0.38);--_disabled-icon-color: var(--md-switch-disabled-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_disabled-icon-opacity: var(--md-switch-disabled-icon-opacity, 0.38);--_disabled-track-color: var(--md-switch-disabled-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_disabled-track-outline-color: var(--md-switch-disabled-track-outline-color, var(--md-sys-color-on-surface, #1d1b20));--_focus-handle-color: var(--md-switch-focus-handle-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-icon-color: var(--md-switch-focus-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_focus-track-color: var(--md-switch-focus-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_focus-track-outline-color: var(--md-switch-focus-track-outline-color, var(--md-sys-color-outline, #79747e));--_handle-color: var(--md-switch-handle-color, var(--md-sys-color-outline, #79747e));--_handle-height: var(--md-switch-handle-height, 16px);--_handle-width: var(--md-switch-handle-width, 16px);--_hover-handle-color: var(--md-switch-hover-handle-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-icon-color: var(--md-switch-hover-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_hover-state-layer-color: var(--md-switch-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-state-layer-opacity: var(--md-switch-hover-state-layer-opacity, 0.08);--_hover-track-color: var(--md-switch-hover-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_hover-track-outline-color: var(--md-switch-hover-track-outline-color, var(--md-sys-color-outline, #79747e));--_icon-color: var(--md-switch-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_icon-size: var(--md-switch-icon-size, 16px);--_pressed-handle-color: var(--md-switch-pressed-handle-color, var(--md-sys-color-on-surface-variant, #49454f));--_pressed-icon-color: var(--md-switch-pressed-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_pressed-state-layer-color: var(--md-switch-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_pressed-state-layer-opacity: var(--md-switch-pressed-state-layer-opacity, 0.12);--_pressed-track-color: var(--md-switch-pressed-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_pressed-track-outline-color: var(--md-switch-pressed-track-outline-color, var(--md-sys-color-outline, #79747e));--_track-color: var(--md-switch-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_track-outline-color: var(--md-switch-track-outline-color, var(--md-sys-color-outline, #79747e));--_handle-shape-start-start: var( --md-switch-handle-shape-start-start, var(--_handle-shape) );--_handle-shape-start-end: var( --md-switch-handle-shape-start-end, var(--_handle-shape) );--_handle-shape-end-end: var( --md-switch-handle-shape-end-end, var(--_handle-shape) );--_handle-shape-end-start: var( --md-switch-handle-shape-end-start, var(--_handle-shape) );--_track-shape-start-start: var( --md-switch-track-shape-start-start, var(--_track-shape) );--_track-shape-start-end: var( --md-switch-track-shape-start-end, var(--_track-shape) );--_track-shape-end-end: var( --md-switch-track-shape-end-end, var(--_track-shape) );--_track-shape-end-start: var( --md-switch-track-shape-end-start, var(--_track-shape) );display:inline-flex;outline:none;vertical-align:top;-webkit-tap-highlight-color:rgba(0,0,0,0);cursor:pointer}:host([disabled]){cursor:default}:host([touch-target=wrapper]){margin:max(0px,(48px - var(--_track-height))/2) 0px}md-focus-ring{--md-focus-ring-shape-start-start: var(--_track-shape-start-start);--md-focus-ring-shape-start-end: var(--_track-shape-start-end);--md-focus-ring-shape-end-end: var(--_track-shape-end-end);--md-focus-ring-shape-end-start: var(--_track-shape-end-start)}.switch{align-items:center;display:inline-flex;flex-shrink:0;position:relative;width:var(--_track-width);height:var(--_track-height);border-start-start-radius:var(--_track-shape-start-start);border-start-end-radius:var(--_track-shape-start-end);border-end-end-radius:var(--_track-shape-end-end);border-end-start-radius:var(--_track-shape-end-start)}input{appearance:none;height:48px;outline:none;margin:0;position:absolute;width:100%;z-index:1;cursor:inherit}:host([touch-target=none]) input{display:none}}@layer styles{.track{position:absolute;width:100%;height:100%;box-sizing:border-box;border-radius:inherit;display:flex;justify-content:center;align-items:center}.track::before{content:\"\";display:flex;position:absolute;height:100%;width:100%;border-radius:inherit;box-sizing:border-box;transition-property:opacity,background-color;transition-timing-function:linear;transition-duration:67ms}.disabled .track{background-color:rgba(0,0,0,0);border-color:rgba(0,0,0,0)}.disabled .track::before,.disabled .track::after{transition:none;opacity:var(--_disabled-track-opacity)}.disabled .track::before{background-clip:content-box}.selected .track::before{background-color:var(--_selected-track-color)}.selected:hover .track::before{background-color:var(--_selected-hover-track-color)}.selected:focus-within .track::before{background-color:var(--_selected-focus-track-color)}.selected:active .track::before{background-color:var(--_selected-pressed-track-color)}.selected.disabled .track{background-clip:border-box}.selected.disabled .track::before{background-color:var(--_disabled-selected-track-color)}.unselected .track::before{background-color:var(--_track-color);border-color:var(--_track-outline-color);border-style:solid;border-width:var(--_track-outline-width)}.unselected:hover .track::before{background-color:var(--_hover-track-color);border-color:var(--_hover-track-outline-color)}.unselected:focus-visible .track::before{background-color:var(--_focus-track-color);border-color:var(--_focus-track-outline-color)}.unselected:active .track::before{background-color:var(--_pressed-track-color);border-color:var(--_pressed-track-outline-color)}.unselected.disabled .track::before{background-color:var(--_disabled-track-color);border-color:var(--_disabled-track-outline-color)}}@layer hcm{@media(forced-colors: active){.selected .track::before{background:ButtonText;border-color:ButtonText}.disabled .track::before{border-color:GrayText;opacity:1}.disabled.selected .track::before{background:GrayText}}}@layer styles{.handle-container{display:flex;place-content:center;place-items:center;position:relative;transition:margin 300ms cubic-bezier(0.175, 0.885, 0.32, 1.275)}.selected .handle-container{margin-inline-start:calc(var(--_track-width) - var(--_track-height))}.unselected .handle-container{margin-inline-end:calc(var(--_track-width) - var(--_track-height))}.disabled .handle-container{transition:none}.handle{border-start-start-radius:var(--_handle-shape-start-start);border-start-end-radius:var(--_handle-shape-start-end);border-end-end-radius:var(--_handle-shape-end-end);border-end-start-radius:var(--_handle-shape-end-start);height:var(--_handle-height);width:var(--_handle-width);transform-origin:center;transition-property:height,width;transition-duration:250ms,250ms;transition-timing-function:cubic-bezier(0.2, 0, 0, 1),cubic-bezier(0.2, 0, 0, 1);z-index:0}.handle::before{content:\"\";display:flex;inset:0;position:absolute;border-radius:inherit;box-sizing:border-box;transition:background-color 67ms linear}.disabled .handle,.disabled .handle::before{transition:none}.selected .handle{height:var(--_selected-handle-height);width:var(--_selected-handle-width)}.handle.with-icon{height:var(--_with-icon-handle-height);width:var(--_with-icon-handle-width)}.selected:not(.disabled):active .handle,.unselected:not(.disabled):active .handle{height:var(--_pressed-handle-height);width:var(--_pressed-handle-width);transition-timing-function:linear;transition-duration:100ms}.selected .handle::before{background-color:var(--_selected-handle-color)}.selected:hover .handle::before{background-color:var(--_selected-hover-handle-color)}.selected:focus-within .handle::before{background-color:var(--_selected-focus-handle-color)}.selected:active .handle::before{background-color:var(--_selected-pressed-handle-color)}.selected.disabled .handle::before{background-color:var(--_disabled-selected-handle-color);opacity:var(--_disabled-selected-handle-opacity)}.unselected .handle::before{background-color:var(--_handle-color)}.unselected:hover .handle::before{background-color:var(--_hover-handle-color)}.unselected:focus-within .handle::before{background-color:var(--_focus-handle-color)}.unselected:active .handle::before{background-color:var(--_pressed-handle-color)}.unselected.disabled .handle::before{background-color:var(--_disabled-handle-color);opacity:var(--_disabled-handle-opacity)}md-ripple{border-radius:var(--_state-layer-shape);height:var(--_state-layer-size);inset:unset;width:var(--_state-layer-size)}.selected md-ripple{--md-ripple-hover-color: var(--_selected-hover-state-layer-color);--md-ripple-pressed-color: var(--_selected-pressed-state-layer-color);--md-ripple-hover-opacity: var(--_selected-hover-state-layer-opacity);--md-ripple-pressed-opacity: var(--_selected-pressed-state-layer-opacity)}.unselected md-ripple{--md-ripple-hover-color: var(--_hover-state-layer-color);--md-ripple-pressed-color: var(--_pressed-state-layer-color);--md-ripple-hover-opacity: var(--_hover-state-layer-opacity);--md-ripple-pressed-opacity: var(--_pressed-state-layer-opacity)}}@layer hcm{@media(forced-colors: active){.unselected .handle::before{background:ButtonText}.disabled .handle::before{opacity:1}.disabled.unselected .handle::before{background:GrayText}}}@layer styles{.icons{position:relative;height:100%;width:100%}.icon{position:absolute;inset:0;margin:auto;transition:fill 67ms linear,opacity 33ms linear,transform 167ms cubic-bezier(0.2, 0, 0, 1);opacity:0}.disabled .icon{transition:none}.selected .icon--on,.unselected .icon--off{opacity:1}.unselected .handle:not(.with-icon) .icon--on{transform:rotate(-45deg)}.icon--off{width:var(--_icon-size);height:var(--_icon-size);fill:var(--_icon-color)}.unselected:hover .icon--off{fill:var(--_hover-icon-color)}.unselected:focus-within .icon--off{fill:var(--_focus-icon-color)}.unselected:active .icon--off{fill:var(--_pressed-icon-color)}.unselected.disabled .icon--off{fill:var(--_disabled-icon-color);opacity:var(--_disabled-icon-opacity)}.icon--on{width:var(--_selected-icon-size);height:var(--_selected-icon-size);fill:var(--_selected-icon-color)}.selected:hover .icon--on{fill:var(--_selected-hover-icon-color)}.selected:focus-within .icon--on{fill:var(--_selected-focus-icon-color)}.selected:active .icon--on{fill:var(--_selected-pressed-icon-color)}.selected.disabled .icon--on{fill:var(--_disabled-selected-icon-color);opacity:var(--_disabled-selected-icon-opacity)}}@layer hcm{@media(forced-colors: active){.icon--off{fill:Canvas}.icon--on{fill:ButtonText}.disabled.unselected .icon--off,.disabled.selected .icon--on{opacity:1}.disabled .icon--on{fill:GrayText}}}/*# sourceMappingURL=switch-styles.css.map */\n`;\n "]}
1
+ {"version":3,"file":"switch-styles.css.js","sourceRoot":"","sources":["switch-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`@layer styles, hcm;@layer styles{:host{--_disabled-selected-handle-color: var(--md-switch-disabled-selected-handle-color, var(--md-sys-color-surface, #fef7ff));--_disabled-selected-handle-opacity: var(--md-switch-disabled-selected-handle-opacity, 1);--_disabled-selected-icon-color: var(--md-switch-disabled-selected-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-selected-icon-opacity: var(--md-switch-disabled-selected-icon-opacity, 0.38);--_disabled-selected-track-color: var(--md-switch-disabled-selected-track-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-track-opacity: var(--md-switch-disabled-track-opacity, 0.12);--_handle-shape: var(--md-switch-handle-shape, 9999px);--_pressed-handle-height: var(--md-switch-pressed-handle-height, 28px);--_pressed-handle-width: var(--md-switch-pressed-handle-width, 28px);--_selected-focus-handle-color: var(--md-switch-selected-focus-handle-color, var(--md-sys-color-primary-container, #eaddff));--_selected-focus-icon-color: var(--md-switch-selected-focus-icon-color, var(--md-sys-color-on-primary-container, #21005d));--_selected-focus-track-color: var(--md-switch-selected-focus-track-color, var(--md-sys-color-primary, #6750a4));--_selected-handle-color: var(--md-switch-selected-handle-color, var(--md-sys-color-on-primary, #fff));--_selected-handle-height: var(--md-switch-selected-handle-height, 24px);--_selected-handle-width: var(--md-switch-selected-handle-width, 24px);--_selected-hover-handle-color: var(--md-switch-selected-hover-handle-color, var(--md-sys-color-primary-container, #eaddff));--_selected-hover-icon-color: var(--md-switch-selected-hover-icon-color, var(--md-sys-color-on-primary-container, #21005d));--_selected-hover-state-layer-color: var(--md-switch-selected-hover-state-layer-color, var(--md-sys-color-primary, #6750a4));--_selected-hover-state-layer-opacity: var(--md-switch-selected-hover-state-layer-opacity, 0.08);--_selected-hover-track-color: var(--md-switch-selected-hover-track-color, var(--md-sys-color-primary, #6750a4));--_selected-icon-color: var(--md-switch-selected-icon-color, var(--md-sys-color-on-primary-container, #21005d));--_selected-icon-size: var(--md-switch-selected-icon-size, 16px);--_selected-pressed-handle-color: var(--md-switch-selected-pressed-handle-color, var(--md-sys-color-primary-container, #eaddff));--_selected-pressed-icon-color: var(--md-switch-selected-pressed-icon-color, var(--md-sys-color-on-primary-container, #21005d));--_selected-pressed-state-layer-color: var(--md-switch-selected-pressed-state-layer-color, var(--md-sys-color-primary, #6750a4));--_selected-pressed-state-layer-opacity: var(--md-switch-selected-pressed-state-layer-opacity, 0.12);--_selected-pressed-track-color: var(--md-switch-selected-pressed-track-color, var(--md-sys-color-primary, #6750a4));--_selected-track-color: var(--md-switch-selected-track-color, var(--md-sys-color-primary, #6750a4));--_state-layer-shape: var(--md-switch-state-layer-shape, 9999px);--_state-layer-size: var(--md-switch-state-layer-size, 40px);--_track-height: var(--md-switch-track-height, 32px);--_track-outline-width: var(--md-switch-track-outline-width, 2px);--_track-shape: var(--md-switch-track-shape, 9999px);--_track-width: var(--md-switch-track-width, 52px);--_with-icon-handle-height: var(--md-switch-with-icon-handle-height, 24px);--_with-icon-handle-width: var(--md-switch-with-icon-handle-width, 24px);--_disabled-handle-color: var(--md-switch-disabled-handle-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-handle-opacity: var(--md-switch-disabled-handle-opacity, 0.38);--_disabled-icon-color: var(--md-switch-disabled-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_disabled-icon-opacity: var(--md-switch-disabled-icon-opacity, 0.38);--_disabled-track-color: var(--md-switch-disabled-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_disabled-track-outline-color: var(--md-switch-disabled-track-outline-color, var(--md-sys-color-on-surface, #1d1b20));--_focus-handle-color: var(--md-switch-focus-handle-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-icon-color: var(--md-switch-focus-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_focus-track-color: var(--md-switch-focus-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_focus-track-outline-color: var(--md-switch-focus-track-outline-color, var(--md-sys-color-outline, #79747e));--_handle-color: var(--md-switch-handle-color, var(--md-sys-color-outline, #79747e));--_handle-height: var(--md-switch-handle-height, 16px);--_handle-width: var(--md-switch-handle-width, 16px);--_hover-handle-color: var(--md-switch-hover-handle-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-icon-color: var(--md-switch-hover-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_hover-state-layer-color: var(--md-switch-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-state-layer-opacity: var(--md-switch-hover-state-layer-opacity, 0.08);--_hover-track-color: var(--md-switch-hover-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_hover-track-outline-color: var(--md-switch-hover-track-outline-color, var(--md-sys-color-outline, #79747e));--_icon-color: var(--md-switch-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_icon-size: var(--md-switch-icon-size, 16px);--_pressed-handle-color: var(--md-switch-pressed-handle-color, var(--md-sys-color-on-surface-variant, #49454f));--_pressed-icon-color: var(--md-switch-pressed-icon-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_pressed-state-layer-color: var(--md-switch-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_pressed-state-layer-opacity: var(--md-switch-pressed-state-layer-opacity, 0.12);--_pressed-track-color: var(--md-switch-pressed-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_pressed-track-outline-color: var(--md-switch-pressed-track-outline-color, var(--md-sys-color-outline, #79747e));--_track-color: var(--md-switch-track-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_track-outline-color: var(--md-switch-track-outline-color, var(--md-sys-color-outline, #79747e));--_handle-shape-start-start: var( --md-switch-handle-shape-start-start, var(--_handle-shape) );--_handle-shape-start-end: var( --md-switch-handle-shape-start-end, var(--_handle-shape) );--_handle-shape-end-end: var( --md-switch-handle-shape-end-end, var(--_handle-shape) );--_handle-shape-end-start: var( --md-switch-handle-shape-end-start, var(--_handle-shape) );--_track-shape-start-start: var( --md-switch-track-shape-start-start, var(--_track-shape) );--_track-shape-start-end: var( --md-switch-track-shape-start-end, var(--_track-shape) );--_track-shape-end-end: var( --md-switch-track-shape-end-end, var(--_track-shape) );--_track-shape-end-start: var( --md-switch-track-shape-end-start, var(--_track-shape) );display:inline-flex;outline:none;vertical-align:top;-webkit-tap-highlight-color:rgba(0,0,0,0);cursor:pointer}:host([disabled]){cursor:default}:host([touch-target=wrapper]){margin:max(0px,(48px - var(--_track-height))/2) 0px}md-focus-ring{--md-focus-ring-shape-start-start: var(--_track-shape-start-start);--md-focus-ring-shape-start-end: var(--_track-shape-start-end);--md-focus-ring-shape-end-end: var(--_track-shape-end-end);--md-focus-ring-shape-end-start: var(--_track-shape-end-start)}.switch{align-items:center;display:inline-flex;flex-shrink:0;position:relative;width:var(--_track-width);height:var(--_track-height);border-start-start-radius:var(--_track-shape-start-start);border-start-end-radius:var(--_track-shape-start-end);border-end-end-radius:var(--_track-shape-end-end);border-end-start-radius:var(--_track-shape-end-start)}input{appearance:none;height:48px;outline:none;margin:0;position:absolute;width:100%;z-index:1;cursor:inherit}:host([touch-target=none]) input{display:none}}@layer styles{.track{position:absolute;width:100%;height:100%;box-sizing:border-box;border-radius:inherit;display:flex;justify-content:center;align-items:center}.track::before{content:\"\";display:flex;position:absolute;height:100%;width:100%;border-radius:inherit;box-sizing:border-box;transition-property:opacity,background-color;transition-timing-function:linear;transition-duration:67ms}.disabled .track{background-color:rgba(0,0,0,0);border-color:rgba(0,0,0,0)}.disabled .track::before,.disabled .track::after{transition:none;opacity:var(--_disabled-track-opacity)}.disabled .track::before{background-clip:content-box}.selected .track::before{background-color:var(--_selected-track-color)}.selected:hover .track::before{background-color:var(--_selected-hover-track-color)}.selected:focus-within .track::before{background-color:var(--_selected-focus-track-color)}.selected:active .track::before{background-color:var(--_selected-pressed-track-color)}.selected.disabled .track{background-clip:border-box}.selected.disabled .track::before{background-color:var(--_disabled-selected-track-color)}.unselected .track::before{background-color:var(--_track-color);border-color:var(--_track-outline-color);border-style:solid;border-width:var(--_track-outline-width)}.unselected:hover .track::before{background-color:var(--_hover-track-color);border-color:var(--_hover-track-outline-color)}.unselected:focus-visible .track::before{background-color:var(--_focus-track-color);border-color:var(--_focus-track-outline-color)}.unselected:active .track::before{background-color:var(--_pressed-track-color);border-color:var(--_pressed-track-outline-color)}.unselected.disabled .track::before{background-color:var(--_disabled-track-color);border-color:var(--_disabled-track-outline-color)}}@layer hcm{@media(forced-colors: active){.selected .track::before{background:ButtonText;border-color:ButtonText}.disabled .track::before{border-color:GrayText;opacity:1}.disabled.selected .track::before{background:GrayText}}}@layer styles{.handle-container{display:flex;place-content:center;place-items:center;position:relative;transition:margin 300ms cubic-bezier(0.175, 0.885, 0.32, 1.275)}.selected .handle-container{margin-inline-start:calc(var(--_track-width) - var(--_track-height))}.unselected .handle-container{margin-inline-end:calc(var(--_track-width) - var(--_track-height))}.disabled .handle-container{transition:none}.handle{border-start-start-radius:var(--_handle-shape-start-start);border-start-end-radius:var(--_handle-shape-start-end);border-end-end-radius:var(--_handle-shape-end-end);border-end-start-radius:var(--_handle-shape-end-start);height:var(--_handle-height);width:var(--_handle-width);transform-origin:center;transition-property:height,width;transition-duration:250ms,250ms;transition-timing-function:cubic-bezier(0.2, 0, 0, 1),cubic-bezier(0.2, 0, 0, 1);z-index:0}.handle::before{content:\"\";display:flex;inset:0;position:absolute;border-radius:inherit;box-sizing:border-box;transition:background-color 67ms linear}.disabled .handle,.disabled .handle::before{transition:none}.selected .handle{height:var(--_selected-handle-height);width:var(--_selected-handle-width)}.handle.with-icon{height:var(--_with-icon-handle-height);width:var(--_with-icon-handle-width)}.selected:not(.disabled):active .handle,.unselected:not(.disabled):active .handle{height:var(--_pressed-handle-height);width:var(--_pressed-handle-width);transition-timing-function:linear;transition-duration:100ms}.selected .handle::before{background-color:var(--_selected-handle-color)}.selected:hover .handle::before{background-color:var(--_selected-hover-handle-color)}.selected:focus-within .handle::before{background-color:var(--_selected-focus-handle-color)}.selected:active .handle::before{background-color:var(--_selected-pressed-handle-color)}.selected.disabled .handle::before{background-color:var(--_disabled-selected-handle-color);opacity:var(--_disabled-selected-handle-opacity)}.unselected .handle::before{background-color:var(--_handle-color)}.unselected:hover .handle::before{background-color:var(--_hover-handle-color)}.unselected:focus-within .handle::before{background-color:var(--_focus-handle-color)}.unselected:active .handle::before{background-color:var(--_pressed-handle-color)}.unselected.disabled .handle::before{background-color:var(--_disabled-handle-color);opacity:var(--_disabled-handle-opacity)}md-ripple{border-radius:var(--_state-layer-shape);height:var(--_state-layer-size);inset:unset;width:var(--_state-layer-size)}.selected md-ripple{--md-ripple-hover-color: var(--_selected-hover-state-layer-color);--md-ripple-pressed-color: var(--_selected-pressed-state-layer-color);--md-ripple-hover-opacity: var(--_selected-hover-state-layer-opacity);--md-ripple-pressed-opacity: var(--_selected-pressed-state-layer-opacity)}.unselected md-ripple{--md-ripple-hover-color: var(--_hover-state-layer-color);--md-ripple-pressed-color: var(--_pressed-state-layer-color);--md-ripple-hover-opacity: var(--_hover-state-layer-opacity);--md-ripple-pressed-opacity: var(--_pressed-state-layer-opacity)}}@layer hcm{@media(forced-colors: active){.unselected .handle::before{background:ButtonText}.disabled .handle::before{opacity:1}.disabled.unselected .handle::before{background:GrayText}}}@layer styles{.icons{position:relative;height:100%;width:100%}.icon{position:absolute;inset:0;margin:auto;display:flex;align-items:center;justify-content:center;fill:currentColor;transition:fill 67ms linear,opacity 33ms linear,transform 167ms cubic-bezier(0.2, 0, 0, 1);opacity:0}.disabled .icon{transition:none}.selected .icon--on,.unselected .icon--off{opacity:1}.unselected .handle:not(.with-icon) .icon--on{transform:rotate(-45deg)}.icon--off{width:var(--_icon-size);height:var(--_icon-size);color:var(--_icon-color)}.unselected:hover .icon--off{color:var(--_hover-icon-color)}.unselected:focus-within .icon--off{color:var(--_focus-icon-color)}.unselected:active .icon--off{color:var(--_pressed-icon-color)}.unselected.disabled .icon--off{color:var(--_disabled-icon-color);opacity:var(--_disabled-icon-opacity)}.icon--on{width:var(--_selected-icon-size);height:var(--_selected-icon-size);color:var(--_selected-icon-color)}.selected:hover .icon--on{color:var(--_selected-hover-icon-color)}.selected:focus-within .icon--on{color:var(--_selected-focus-icon-color)}.selected:active .icon--on{color:var(--_selected-pressed-icon-color)}.selected.disabled .icon--on{color:var(--_disabled-selected-icon-color);opacity:var(--_disabled-selected-icon-opacity)}}@layer hcm{@media(forced-colors: active){.icon--off{fill:Canvas}.icon--on{fill:ButtonText}.disabled.unselected .icon--off,.disabled.selected .icon--on{opacity:1}.disabled .icon--on{fill:GrayText}}}/*# sourceMappingURL=switch-styles.css.map */\n`;\n "]}
@@ -118,10 +118,12 @@ export class Switch extends switchBaseClass {
118
118
  */
119
119
  renderOnIcon() {
120
120
  return html `
121
- <svg class="icon icon--on" viewBox="0 0 24 24">
122
- <path
123
- d="M9.55 18.2 3.65 12.3 5.275 10.675 9.55 14.95 18.725 5.775 20.35 7.4Z" />
124
- </svg>
121
+ <slot class="icon icon--on" name="on-icon">
122
+ <svg viewBox="0 0 24 24">
123
+ <path
124
+ d="M9.55 18.2 3.65 12.3 5.275 10.675 9.55 14.95 18.725 5.775 20.35 7.4Z" />
125
+ </svg>
126
+ </slot>
125
127
  `;
126
128
  }
127
129
  /**
@@ -129,10 +131,12 @@ export class Switch extends switchBaseClass {
129
131
  */
130
132
  renderOffIcon() {
131
133
  return html `
132
- <svg class="icon icon--off" viewBox="0 0 24 24">
133
- <path
134
- d="M6.4 19.2 4.8 17.6 10.4 12 4.8 6.4 6.4 4.8 12 10.4 17.6 4.8 19.2 6.4 13.6 12 19.2 17.6 17.6 19.2 12 13.6Z" />
135
- </svg>
134
+ <slot class="icon icon--off" name="off-icon">
135
+ <svg viewBox="0 0 24 24">
136
+ <path
137
+ d="M6.4 19.2 4.8 17.6 10.4 12 4.8 6.4 6.4 4.8 12 10.4 17.6 4.8 19.2 6.4 13.6 12 19.2 17.6 17.6 19.2 12 13.6Z" />
138
+ </svg>
139
+ </slot>
136
140
  `;
137
141
  }
138
142
  renderTouchTarget() {
@@ -1 +1 @@
1
- {"version":3,"file":"switch.js","sourceRoot":"","sources":["switch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,wBAAwB,CAAC;AAEhC,OAAO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E,yBAAyB,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC,GAAA,CAAA;AAED,kBAAkB;AACF,wBAAiB,GAAmB;IAClD,IAAI,EAAE,MAAM;IACZ,cAAc,EAAE,IAAI;CACrB,AAHgC,CAG/B;AAMyB;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;wCAAkB;AAKjB;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;qCAAe;AAOzC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,yBAAyB,EAAC,CAAC;oDACnC;AAQF;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;wCAAkB;AAMhC;IAAX,QAAQ,EAAE;qCAAc;AAEQ;IAAhC,KAAK,CAAC,OAAO,CAAC;qCAAkD","sourcesContent":["/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../focus/md-focus-ring.js';\nimport '../../ripple/ripple.js';\n\nimport {html, isServer, LitElement, nothing, TemplateResult} from 'lit';\nimport {property, query} from 'lit/decorators.js';\nimport {ClassInfo, classMap} from 'lit/directives/class-map.js';\n\nimport {requestUpdateOnAriaChange} from '../../internal/aria/delegate.js';\nimport {\n dispatchActivationClick,\n isActivationClick,\n redispatchEvent,\n} from '../../internal/controller/events.js';\nimport {\n createValidator,\n getValidityAnchor,\n mixinConstraintValidation,\n} from '../../labs/behaviors/constraint-validation.js';\nimport {mixinElementInternals} from '../../labs/behaviors/element-internals.js';\nimport {\n getFormState,\n getFormValue,\n mixinFormAssociated,\n} from '../../labs/behaviors/form-associated.js';\nimport {CheckboxValidator} from '../../labs/behaviors/validators/checkbox-validator.js';\n\n// Separate variable needed for closure.\nconst switchBaseClass = mixinConstraintValidation(\n mixinFormAssociated(mixinElementInternals(LitElement)),\n);\n\n/**\n * @fires input {InputEvent} Fired whenever `selected` changes due to user\n * interaction (bubbles and composed).\n * @fires change {Event} Fired whenever `selected` changes due to user\n * interaction (bubbles).\n */\nexport class Switch extends switchBaseClass {\n static {\n requestUpdateOnAriaChange(Switch);\n }\n\n /** @nocollapse */\n static override shadowRootOptions: ShadowRootInit = {\n mode: 'open',\n delegatesFocus: true,\n };\n\n /**\n * Puts the switch in the selected state and sets the form submission value to\n * the `value` property.\n */\n @property({type: Boolean}) selected = false;\n\n /**\n * Shows both the selected and deselected icons.\n */\n @property({type: Boolean}) icons = false;\n\n /**\n * Shows only the selected icon, and not the deselected icon. If `true`,\n * overrides the behavior of the `icons` property.\n */\n @property({type: Boolean, attribute: 'show-only-selected-icon'})\n showOnlySelectedIcon = false;\n\n /**\n * When true, require the switch to be selected when participating in\n * form submission.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#validation\n */\n @property({type: Boolean}) required = false;\n\n /**\n * The value associated with this switch on form submission. `null` is\n * submitted when `selected` is `false`.\n */\n @property() value = 'on';\n\n @query('input') private readonly input!: HTMLInputElement | null;\n\n constructor() {\n super();\n if (!isServer) {\n this.addEventListener('click', (event: MouseEvent) => {\n if (!isActivationClick(event) || !this.input) {\n return;\n }\n this.focus();\n dispatchActivationClick(this.input);\n });\n }\n }\n\n protected override render(): TemplateResult {\n // NOTE: buttons must use only [phrasing\n // content](https://html.spec.whatwg.org/multipage/dom.html#phrasing-content)\n // children, which includes custom elements, but not `div`s\n return html`\n <div class=\"switch ${classMap(this.getRenderClasses())}\">\n <input\n id=\"switch\"\n class=\"touch\"\n type=\"checkbox\"\n role=\"switch\"\n aria-label=${(this as ARIAMixin).ariaLabel || nothing}\n ?checked=${this.selected}\n ?disabled=${this.disabled}\n ?required=${this.required}\n @change=${this.handleChange} />\n\n <md-focus-ring part=\"focus-ring\" for=\"switch\"></md-focus-ring>\n <span class=\"track\"> ${this.renderHandle()} </span>\n </div>\n `;\n }\n\n private getRenderClasses(): ClassInfo {\n return {\n 'selected': this.selected,\n 'unselected': !this.selected,\n 'disabled': this.disabled,\n };\n }\n\n private renderHandle() {\n const classes = {\n 'with-icon': this.showOnlySelectedIcon ? this.selected : this.icons,\n };\n return html`\n ${this.renderTouchTarget()}\n <span class=\"handle-container\">\n <md-ripple for=\"switch\" ?disabled=\"${this.disabled}\"></md-ripple>\n <span class=\"handle ${classMap(classes)}\">\n ${this.shouldShowIcons() ? this.renderIcons() : html``}\n </span>\n </span>\n `;\n }\n\n private renderIcons() {\n return html`\n <div class=\"icons\">\n ${this.renderOnIcon()}\n ${this.showOnlySelectedIcon ? html`` : this.renderOffIcon()}\n </div>\n `;\n }\n\n /**\n * https://fonts.google.com/icons?selected=Material%20Symbols%20Outlined%3Acheck%3AFILL%400%3Bwght%40500%3BGRAD%400%3Bopsz%4024\n */\n private renderOnIcon() {\n return html`\n <svg class=\"icon icon--on\" viewBox=\"0 0 24 24\">\n <path\n d=\"M9.55 18.2 3.65 12.3 5.275 10.675 9.55 14.95 18.725 5.775 20.35 7.4Z\" />\n </svg>\n `;\n }\n\n /**\n * https://fonts.google.com/icons?selected=Material%20Symbols%20Outlined%3Aclose%3AFILL%400%3Bwght%40500%3BGRAD%400%3Bopsz%4024\n */\n private renderOffIcon() {\n return html`\n <svg class=\"icon icon--off\" viewBox=\"0 0 24 24\">\n <path\n d=\"M6.4 19.2 4.8 17.6 10.4 12 4.8 6.4 6.4 4.8 12 10.4 17.6 4.8 19.2 6.4 13.6 12 19.2 17.6 17.6 19.2 12 13.6Z\" />\n </svg>\n `;\n }\n\n private renderTouchTarget() {\n return html`<span class=\"touch\"></span>`;\n }\n\n private shouldShowIcons(): boolean {\n return this.icons || this.showOnlySelectedIcon;\n }\n\n private handleChange(event: Event) {\n const target = event.target as HTMLInputElement;\n this.selected = target.checked;\n redispatchEvent(this, event);\n }\n\n // Writable mixin properties for lit-html binding, needed for lit-analyzer\n declare disabled: boolean;\n declare name: string;\n\n override [getFormValue]() {\n return this.selected ? this.value : null;\n }\n\n override [getFormState]() {\n return String(this.selected);\n }\n\n override formResetCallback() {\n // The selected property does not reflect, so the original attribute set by\n // the user is used to determine the default value.\n this.selected = this.hasAttribute('selected');\n }\n\n override formStateRestoreCallback(state: string) {\n this.selected = state === 'true';\n }\n\n [createValidator]() {\n return new CheckboxValidator(() => ({\n checked: this.selected,\n required: this.required,\n }));\n }\n\n [getValidityAnchor]() {\n return this.input;\n }\n}\n"]}
1
+ {"version":3,"file":"switch.js","sourceRoot":"","sources":["switch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,8BAA8B,CAAC;AACtC,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,EAAY,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAC,yBAAyB,EAAC,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,GAChB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAC,qBAAqB,EAAC,MAAM,2CAA2C,CAAC;AAChF,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,mBAAmB,GACpB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAC,iBAAiB,EAAC,MAAM,uDAAuD,CAAC;AAExF,wCAAwC;AACxC,MAAM,eAAe,GAAG,yBAAyB,CAC/C,mBAAmB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CACvD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,OAAO,MAAO,SAAQ,eAAe;IA6CzC;QACE,KAAK,EAAE,CAAC;QAnCV;;;WAGG;QACwB,aAAQ,GAAG,KAAK,CAAC;QAE5C;;WAEG;QACwB,UA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AC;IAChD,CAAC;IAEQ,wBAAwB,CAAC,KAAa;QAC7C,IAAI,CAAC,QAAQ,GAAG,KAAK,KAAK,MAAM,CAAC;IACnC,CAAC;IAED,CAAC,eAAe,CAAC;QACf,OAAO,IAAI,iBAAiB,CAAC,GAAG,EAAE,CAAC,CAAC;YAClC,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAC,CAAC;IACN,CAAC;IAED,CAAC,iBAAiB,CAAC;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;;AAzLD;IACE,yBAAyB,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC,GAAA,CAAA;AAED,kBAAkB;AACF,wBAAiB,GAAmB;IAClD,IAAI,EAAE,MAAM;IACZ,cAAc,EAAE,IAAI;CACrB,AAHgC,CAG/B;AAMyB;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;wCAAkB;AAKjB;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;qCAAe;AAOzC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,yBAAyB,EAAC,CAAC;oDACnC;AAQF;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;wCAAkB;AAMhC;IAAX,QAAQ,EAAE;qCAAc;AAEQ;IAAhC,KAAK,CAAC,OAAO,CAAC;qCAAkD","sourcesContent":["/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../focus/md-focus-ring.js';\nimport '../../ripple/ripple.js';\n\nimport {html, isServer, LitElement, nothing, TemplateResult} from 'lit';\nimport {property, query} from 'lit/decorators.js';\nimport {ClassInfo, classMap} from 'lit/directives/class-map.js';\n\nimport {requestUpdateOnAriaChange} from '../../internal/aria/delegate.js';\nimport {\n dispatchActivationClick,\n isActivationClick,\n redispatchEvent,\n} from '../../internal/controller/events.js';\nimport {\n createValidator,\n getValidityAnchor,\n mixinConstraintValidation,\n} from '../../labs/behaviors/constraint-validation.js';\nimport {mixinElementInternals} from '../../labs/behaviors/element-internals.js';\nimport {\n getFormState,\n getFormValue,\n mixinFormAssociated,\n} from '../../labs/behaviors/form-associated.js';\nimport {CheckboxValidator} from '../../labs/behaviors/validators/checkbox-validator.js';\n\n// Separate variable needed for closure.\nconst switchBaseClass = mixinConstraintValidation(\n mixinFormAssociated(mixinElementInternals(LitElement)),\n);\n\n/**\n * @fires input {InputEvent} Fired whenever `selected` changes due to user\n * interaction (bubbles and composed).\n * @fires change {Event} Fired whenever `selected` changes due to user\n * interaction (bubbles).\n */\nexport class Switch extends switchBaseClass {\n static {\n requestUpdateOnAriaChange(Switch);\n }\n\n /** @nocollapse */\n static override shadowRootOptions: ShadowRootInit = {\n mode: 'open',\n delegatesFocus: true,\n };\n\n /**\n * Puts the switch in the selected state and sets the form submission value to\n * the `value` property.\n */\n @property({type: Boolean}) selected = false;\n\n /**\n * Shows both the selected and deselected icons.\n */\n @property({type: Boolean}) icons = false;\n\n /**\n * Shows only the selected icon, and not the deselected icon. If `true`,\n * overrides the behavior of the `icons` property.\n */\n @property({type: Boolean, attribute: 'show-only-selected-icon'})\n showOnlySelectedIcon = false;\n\n /**\n * When true, require the switch to be selected when participating in\n * form submission.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#validation\n */\n @property({type: Boolean}) required = false;\n\n /**\n * The value associated with this switch on form submission. `null` is\n * submitted when `selected` is `false`.\n */\n @property() value = 'on';\n\n @query('input') private readonly input!: HTMLInputElement | null;\n\n constructor() {\n super();\n if (!isServer) {\n this.addEventListener('click', (event: MouseEvent) => {\n if (!isActivationClick(event) || !this.input) {\n return;\n }\n this.focus();\n dispatchActivationClick(this.input);\n });\n }\n }\n\n protected override render(): TemplateResult {\n // NOTE: buttons must use only [phrasing\n // content](https://html.spec.whatwg.org/multipage/dom.html#phrasing-content)\n // children, which includes custom elements, but not `div`s\n return html`\n <div class=\"switch ${classMap(this.getRenderClasses())}\">\n <input\n id=\"switch\"\n class=\"touch\"\n type=\"checkbox\"\n role=\"switch\"\n aria-label=${(this as ARIAMixin).ariaLabel || nothing}\n ?checked=${this.selected}\n ?disabled=${this.disabled}\n ?required=${this.required}\n @change=${this.handleChange} />\n\n <md-focus-ring part=\"focus-ring\" for=\"switch\"></md-focus-ring>\n <span class=\"track\"> ${this.renderHandle()} </span>\n </div>\n `;\n }\n\n private getRenderClasses(): ClassInfo {\n return {\n 'selected': this.selected,\n 'unselected': !this.selected,\n 'disabled': this.disabled,\n };\n }\n\n private renderHandle() {\n const classes = {\n 'with-icon': this.showOnlySelectedIcon ? this.selected : this.icons,\n };\n return html`\n ${this.renderTouchTarget()}\n <span class=\"handle-container\">\n <md-ripple for=\"switch\" ?disabled=\"${this.disabled}\"></md-ripple>\n <span class=\"handle ${classMap(classes)}\">\n ${this.shouldShowIcons() ? this.renderIcons() : html``}\n </span>\n </span>\n `;\n }\n\n private renderIcons() {\n return html`\n <div class=\"icons\">\n ${this.renderOnIcon()}\n ${this.showOnlySelectedIcon ? html`` : this.renderOffIcon()}\n </div>\n `;\n }\n\n /**\n * https://fonts.google.com/icons?selected=Material%20Symbols%20Outlined%3Acheck%3AFILL%400%3Bwght%40500%3BGRAD%400%3Bopsz%4024\n */\n private renderOnIcon() {\n return html`\n <slot class=\"icon icon--on\" name=\"on-icon\">\n <svg viewBox=\"0 0 24 24\">\n <path\n d=\"M9.55 18.2 3.65 12.3 5.275 10.675 9.55 14.95 18.725 5.775 20.35 7.4Z\" />\n </svg>\n </slot>\n `;\n }\n\n /**\n * https://fonts.google.com/icons?selected=Material%20Symbols%20Outlined%3Aclose%3AFILL%400%3Bwght%40500%3BGRAD%400%3Bopsz%4024\n */\n private renderOffIcon() {\n return html`\n <slot class=\"icon icon--off\" name=\"off-icon\">\n <svg viewBox=\"0 0 24 24\">\n <path\n d=\"M6.4 19.2 4.8 17.6 10.4 12 4.8 6.4 6.4 4.8 12 10.4 17.6 4.8 19.2 6.4 13.6 12 19.2 17.6 17.6 19.2 12 13.6Z\" />\n </svg>\n </slot>\n `;\n }\n\n private renderTouchTarget() {\n return html`<span class=\"touch\"></span>`;\n }\n\n private shouldShowIcons(): boolean {\n return this.icons || this.showOnlySelectedIcon;\n }\n\n private handleChange(event: Event) {\n const target = event.target as HTMLInputElement;\n this.selected = target.checked;\n redispatchEvent(this, event);\n }\n\n // Writable mixin properties for lit-html binding, needed for lit-analyzer\n declare disabled: boolean;\n declare name: string;\n\n override [getFormValue]() {\n return this.selected ? this.value : null;\n }\n\n override [getFormState]() {\n return String(this.selected);\n }\n\n override formResetCallback() {\n // The selected property does not reflect, so the original attribute set by\n // the user is used to determine the default value.\n this.selected = this.hasAttribute('selected');\n }\n\n override formStateRestoreCallback(state: string) {\n this.selected = state === 'true';\n }\n\n [createValidator]() {\n return new CheckboxValidator(() => ({\n checked: this.selected,\n required: this.required,\n }));\n }\n\n [getValidityAnchor]() {\n return this.input;\n }\n}\n"]}
@@ -11,7 +11,6 @@ import '../../ripple/ripple.js';
11
11
  import { html, isServer, LitElement, nothing } from 'lit';
12
12
  import { property, query, queryAssignedElements, queryAssignedNodes, state, } from 'lit/decorators.js';
13
13
  import { classMap } from 'lit/directives/class-map.js';
14
- import { polyfillARIAMixin, polyfillElementInternalsAria, } from '../../internal/aria/aria.js';
15
14
  import { EASING } from '../../internal/motion/animation.js';
16
15
  import { mixinFocusable } from '../../labs/behaviors/focusable.js';
17
16
  /**
@@ -61,9 +60,9 @@ export class Tab extends tabBaseClass {
61
60
  */
62
61
  this.iconOnly = false;
63
62
  this.fullWidthIndicator = false;
64
- this.internals = polyfillElementInternalsAria(this,
63
+ this.internals =
65
64
  // Cast needed for closure
66
- this.attachInternals());
65
+ this.attachInternals();
67
66
  if (!isServer) {
68
67
  this.internals.role = 'tab';
69
68
  this.addEventListener('keydown', this.handleKeydown.bind(this));
@@ -173,9 +172,6 @@ export class Tab extends tabBaseClass {
173
172
  this.hasIcon = this.assignedIcons.length > 0;
174
173
  }
175
174
  }
176
- (() => {
177
- polyfillARIAMixin(Tab);
178
- })();
179
175
  __decorate([
180
176
  property({ type: Boolean, reflect: true, attribute: 'md-tab' })
181
177
  ], Tab.prototype, "isTab", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"tab.js","sourceRoot":"","sources":["tab.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,8BAA8B,CAAC;AACtC,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAC,MAAM,KAAK,CAAC;AACxD,OAAO,EACL,QAAQ,EACR,KAAK,EACL,qBAAqB,EACrB,kBAAkB,EAClB,KAAK,GACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAY,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EACL,iBAAiB,EACjB,4BAA4B,GAC7B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAC,MAAM,EAAC,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAC,cAAc,EAAC,MAAM,mCAAmC,CAAC;AAEjE;;;GAGG;AACH,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAE5D,wCAAwC;AACxC,MAAM,YAAY,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;AAEhD;;GAEG;AACH,MAAM,OAAO,GAAI,SAAQ,YAAY;IAkBnC;;;OAGG;IAEH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,IAAI,QAAQ,CAAC,MAAe;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;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,YAAY,IAAI,cAAc,EAAE;gBACzD,OAAO;aACR;SACF;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;IAEO,oBAAoB;QAC1B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/C,CAAC;CACF;AAnLC;IACE,iBAAiB,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC,GAAA,CAAA;AAQQ;IADR,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAC,CAAC;kCACxC;AAKoB;IAAzC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;mCAAgB;AAOzD;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;mCAGzB;AAQiD;IAAjD,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAC,CAAC;oCAAiB;AAKf;IAAlD,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAC,CAAC;qCAAkB;AAEtC;IAA7B,KAAK,CAAC,YAAY,CAAC;6BAA2C;AAC5C;IAAlB,KAAK,EAAE;+CAAsC;AAE7B;IADhB,kBAAkB,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;iDACW;AAE9B;IADhB,qBAAqB,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;0CACN;AAyIjD,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/md-focus-ring.js';\nimport '../../ripple/ripple.js';\n\nimport {html, isServer, LitElement, nothing} from 'lit';\nimport {\n property,\n query,\n queryAssignedElements,\n queryAssignedNodes,\n state,\n} from 'lit/decorators.js';\nimport {ClassInfo, classMap} from 'lit/directives/class-map.js';\n\nimport {\n polyfillARIAMixin,\n polyfillElementInternalsAria,\n} from '../../internal/aria/aria.js';\nimport {EASING} from '../../internal/motion/animation.js';\nimport {mixinFocusable} from '../../labs/behaviors/focusable.js';\n\n/**\n * Symbol for tabs to use to animate their indicators based off another tab's\n * indicator.\n */\nconst INDICATOR = Symbol('indicator');\n\n/**\n * Symbol used by the tab bar to request a tab to animate its indicator from a\n * previously selected tab.\n */\nexport const ANIMATE_INDICATOR = Symbol('animateIndicator');\n\n// Separate variable needed for closure.\nconst tabBaseClass = mixinFocusable(LitElement);\n\n/**\n * Tab component.\n */\nexport class Tab extends tabBaseClass {\n static {\n polyfillARIAMixin(Tab);\n }\n\n /**\n * The attribute `md-tab` indicates that the element is a tab for the parent\n * element, `<md-tabs>`. Make sure if you're implementing your own `md-tab`\n * component that you have an `md-tab` attribute set.\n */\n @property({type: Boolean, reflect: true, attribute: 'md-tab'})\n readonly isTab = true;\n\n /**\n * Whether or not the tab is selected.\n **/\n @property({type: Boolean, reflect: true}) active = false;\n\n /**\n * TODO(b/293476210): remove after migrating\n * @deprecated use `active`\n */\n @property({type: Boolean})\n get selected() {\n return this.active;\n }\n set selected(active: boolean) {\n this.active = active;\n }\n\n /**\n * In SSR, set this to true when an icon is present.\n */\n @property({type: Boolean, attribute: 'has-icon'}) hasIcon = false;\n\n /**\n * In SSR, set this to true when there is no label and only an icon.\n */\n @property({type: Boolean, attribute: 'icon-only'}) iconOnly = false;\n\n @query('.indicator') readonly [INDICATOR]!: HTMLElement | null;\n @state() protected fullWidthIndicator = false;\n @queryAssignedNodes({flatten: true})\n private readonly assignedDefaultNodes!: Node[];\n @queryAssignedElements({slot: 'icon', flatten: true})\n private readonly assignedIcons!: HTMLElement[];\n private readonly internals = polyfillElementInternalsAria(\n this,\n // Cast needed for closure\n (this as HTMLElement).attachInternals(),\n );\n\n constructor() {\n super();\n if (!isServer) {\n this.internals.role = 'tab';\n this.addEventListener('keydown', this.handleKeydown.bind(this));\n }\n }\n\n protected override render() {\n const indicator = html`<div class=\"indicator\"></div>`;\n return html`<div\n class=\"button\"\n role=\"presentation\"\n @click=${this.handleContentClick}>\n <md-focus-ring part=\"focus-ring\" inward .control=${this}></md-focus-ring>\n <md-elevation></md-elevation>\n <md-ripple .control=${this}></md-ripple>\n <div\n class=\"content ${classMap(this.getContentClasses())}\"\n role=\"presentation\">\n <slot name=\"icon\" @slotchange=${this.handleIconSlotChange}></slot>\n <slot @slotchange=${this.handleSlotChange}></slot>\n ${this.fullWidthIndicator ? nothing : indicator}\n </div>\n ${this.fullWidthIndicator ? indicator : nothing}\n </div>`;\n }\n\n protected getContentClasses(): ClassInfo {\n return {\n 'has-icon': this.hasIcon,\n 'has-label': !this.iconOnly,\n };\n }\n\n protected override updated() {\n this.internals.ariaSelected = String(this.active);\n }\n\n private async handleKeydown(event: KeyboardEvent) {\n // Allow event to bubble.\n await 0;\n if (event.defaultPrevented) {\n return;\n }\n\n if (event.key === 'Enter' || event.key === ' ') {\n // Prevent default behavior such as scrolling when pressing spacebar.\n event.preventDefault();\n this.click();\n }\n }\n\n private handleContentClick(event: Event) {\n // Ensure the \"click\" target is always the tab, and not content, by stopping\n // propagation of content clicks and re-clicking the host.\n event.stopPropagation();\n this.click();\n }\n\n [ANIMATE_INDICATOR](previousTab: Tab) {\n if (!this[INDICATOR]) {\n return;\n }\n\n this[INDICATOR].getAnimations().forEach((a) => {\n a.cancel();\n });\n const frames = this.getKeyframes(previousTab);\n if (frames !== null) {\n this[INDICATOR].animate(frames, {\n duration: 250,\n easing: EASING.EMPHASIZED,\n });\n }\n }\n\n private getKeyframes(previousTab: Tab) {\n const reduceMotion = shouldReduceMotion();\n if (!this.active) {\n return reduceMotion ? [{'opacity': 1}, {'transform': 'none'}] : null;\n }\n\n const from: Keyframe = {};\n const fromRect =\n previousTab[INDICATOR]?.getBoundingClientRect() ?? ({} as DOMRect);\n const fromPos = fromRect.left;\n const fromExtent = fromRect.width;\n const toRect = this[INDICATOR]!.getBoundingClientRect();\n const toPos = toRect.left;\n const toExtent = toRect.width;\n const scale = fromExtent / toExtent;\n if (\n !reduceMotion &&\n fromPos !== undefined &&\n toPos !== undefined &&\n !isNaN(scale)\n ) {\n from['transform'] = `translateX(${(fromPos - toPos).toFixed(\n 4,\n )}px) scaleX(${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 private handleSlotChange() {\n this.iconOnly = false;\n // Check if there's any label text or elements. If not, then there is only\n // an icon.\n for (const node of this.assignedDefaultNodes) {\n const hasTextContent =\n node.nodeType === Node.TEXT_NODE &&\n !!(node as Text).wholeText.match(/\\S/);\n if (node.nodeType === Node.ELEMENT_NODE || hasTextContent) {\n return;\n }\n }\n\n this.iconOnly = true;\n }\n\n private handleIconSlotChange() {\n this.hasIcon = this.assignedIcons.length > 0;\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,8BAA8B,CAAC;AACtC,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAC,MAAM,KAAK,CAAC;AACxD,OAAO,EACL,QAAQ,EACR,KAAK,EACL,qBAAqB,EACrB,kBAAkB,EAClB,KAAK,GACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAY,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAC,MAAM,EAAC,MAAM,oCAAoC,CAAC;A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AAE7B;IADhB,kBAAkB,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;iDACW;AAE9B;IADhB,qBAAqB,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;0CACN;AAuIjD,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/md-focus-ring.js';\nimport '../../ripple/ripple.js';\n\nimport {html, isServer, LitElement, nothing} from 'lit';\nimport {\n property,\n query,\n queryAssignedElements,\n queryAssignedNodes,\n state,\n} from 'lit/decorators.js';\nimport {ClassInfo, classMap} from 'lit/directives/class-map.js';\n\nimport {EASING} from '../../internal/motion/animation.js';\nimport {mixinFocusable} from '../../labs/behaviors/focusable.js';\n\n/**\n * Symbol for tabs to use to animate their indicators based off another tab's\n * indicator.\n */\nconst INDICATOR = Symbol('indicator');\n\n/**\n * Symbol used by the tab bar to request a tab to animate its indicator from a\n * previously selected tab.\n */\nexport const ANIMATE_INDICATOR = Symbol('animateIndicator');\n\n// Separate variable needed for closure.\nconst tabBaseClass = mixinFocusable(LitElement);\n\n/**\n * Tab component.\n */\nexport class Tab extends tabBaseClass {\n /**\n * The attribute `md-tab` indicates that the element is a tab for the parent\n * element, `<md-tabs>`. Make sure if you're implementing your own `md-tab`\n * component that you have an `md-tab` attribute set.\n */\n @property({type: Boolean, reflect: true, attribute: 'md-tab'})\n readonly isTab = true;\n\n /**\n * Whether or not the tab is selected.\n **/\n @property({type: Boolean, reflect: true}) active = false;\n\n /**\n * TODO(b/293476210): remove after migrating\n * @deprecated use `active`\n */\n @property({type: Boolean})\n get selected() {\n return this.active;\n }\n set selected(active: boolean) {\n this.active = active;\n }\n\n /**\n * In SSR, set this to true when an icon is present.\n */\n @property({type: Boolean, attribute: 'has-icon'}) hasIcon = false;\n\n /**\n * In SSR, set this to true when there is no label and only an icon.\n */\n @property({type: Boolean, attribute: 'icon-only'}) iconOnly = false;\n\n @query('.indicator') readonly [INDICATOR]!: HTMLElement | null;\n @state() protected fullWidthIndicator = false;\n @queryAssignedNodes({flatten: true})\n private readonly assignedDefaultNodes!: Node[];\n @queryAssignedElements({slot: 'icon', flatten: true})\n private readonly assignedIcons!: HTMLElement[];\n private readonly internals =\n // Cast needed for closure\n (this as HTMLElement).attachInternals();\n\n constructor() {\n super();\n if (!isServer) {\n this.internals.role = 'tab';\n this.addEventListener('keydown', this.handleKeydown.bind(this));\n }\n }\n\n protected override render() {\n const indicator = html`<div class=\"indicator\"></div>`;\n return html`<div\n class=\"button\"\n role=\"presentation\"\n @click=${this.handleContentClick}>\n <md-focus-ring part=\"focus-ring\" inward .control=${this}></md-focus-ring>\n <md-elevation></md-elevation>\n <md-ripple .control=${this}></md-ripple>\n <div\n class=\"content ${classMap(this.getContentClasses())}\"\n role=\"presentation\">\n <slot name=\"icon\" @slotchange=${this.handleIconSlotChange}></slot>\n <slot @slotchange=${this.handleSlotChange}></slot>\n ${this.fullWidthIndicator ? nothing : indicator}\n </div>\n ${this.fullWidthIndicator ? indicator : nothing}\n </div>`;\n }\n\n protected getContentClasses(): ClassInfo {\n return {\n 'has-icon': this.hasIcon,\n 'has-label': !this.iconOnly,\n };\n }\n\n protected override updated() {\n this.internals.ariaSelected = String(this.active);\n }\n\n private async handleKeydown(event: KeyboardEvent) {\n // Allow event to bubble.\n await 0;\n if (event.defaultPrevented) {\n return;\n }\n\n if (event.key === 'Enter' || event.key === ' ') {\n // Prevent default behavior such as scrolling when pressing spacebar.\n event.preventDefault();\n this.click();\n }\n }\n\n private handleContentClick(event: Event) {\n // Ensure the \"click\" target is always the tab, and not content, by stopping\n // propagation of content clicks and re-clicking the host.\n event.stopPropagation();\n this.click();\n }\n\n [ANIMATE_INDICATOR](previousTab: Tab) {\n if (!this[INDICATOR]) {\n return;\n }\n\n this[INDICATOR].getAnimations().forEach((a) => {\n a.cancel();\n });\n const frames = this.getKeyframes(previousTab);\n if (frames !== null) {\n this[INDICATOR].animate(frames, {\n duration: 250,\n easing: EASING.EMPHASIZED,\n });\n }\n }\n\n private getKeyframes(previousTab: Tab) {\n const reduceMotion = shouldReduceMotion();\n if (!this.active) {\n return reduceMotion ? [{'opacity': 1}, {'transform': 'none'}] : null;\n }\n\n const from: Keyframe = {};\n const fromRect =\n previousTab[INDICATOR]?.getBoundingClientRect() ?? ({} as DOMRect);\n const fromPos = fromRect.left;\n const fromExtent = fromRect.width;\n const toRect = this[INDICATOR]!.getBoundingClientRect();\n const toPos = toRect.left;\n const toExtent = toRect.width;\n const scale = fromExtent / toExtent;\n if (\n !reduceMotion &&\n fromPos !== undefined &&\n toPos !== undefined &&\n !isNaN(scale)\n ) {\n from['transform'] = `translateX(${(fromPos - toPos).toFixed(\n 4,\n )}px) scaleX(${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 private handleSlotChange() {\n this.iconOnly = false;\n // Check if there's any label text or elements. If not, then there is only\n // an icon.\n for (const node of this.assignedDefaultNodes) {\n const hasTextContent =\n node.nodeType === Node.TEXT_NODE &&\n !!(node as Text).wholeText.match(/\\S/);\n if (node.nodeType === Node.ELEMENT_NODE || hasTextContent) {\n return;\n }\n }\n\n this.iconOnly = true;\n }\n\n private handleIconSlotChange() {\n this.hasIcon = this.assignedIcons.length > 0;\n }\n}\n\nfunction shouldReduceMotion() {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n"]}
@@ -7,7 +7,6 @@ import { __decorate } from "tslib";
7
7
  import '../../divider/divider.js';
8
8
  import { html, isServer, LitElement } from 'lit';
9
9
  import { property, query, queryAssignedElements } from 'lit/decorators.js';
10
- import { polyfillARIAMixin, polyfillElementInternalsAria, } from '../../internal/aria/aria.js';
11
10
  import { ANIMATE_INDICATOR } from './tab.js';
12
11
  /**
13
12
  * @fires change {Event} Fired when the selected tab changes. The target's selected or
@@ -94,9 +93,9 @@ export class Tabs extends LitElement {
94
93
  * Whether or not to automatically select a tab when it is focused.
95
94
  */
96
95
  this.autoActivate = false;
97
- this.internals = polyfillElementInternalsAria(this,
96
+ this.internals =
98
97
  // Cast needed for closure
99
- this.attachInternals());
98
+ this.attachInternals();
100
99
  if (!isServer) {
101
100
  this.internals.role = 'tablist';
102
101
  this.addEventListener('keydown', this.handleKeydown.bind(this));
@@ -266,9 +265,6 @@ export class Tabs extends LitElement {
266
265
  this.scrollToTab(this.activeTab);
267
266
  }
268
267
  }
269
- (() => {
270
- polyfillARIAMixin(Tabs);
271
- })();
272
268
  __decorate([
273
269
  queryAssignedElements({ flatten: true, selector: '[md-tab]' })
274
270
  ], Tabs.prototype, "tabs", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.js","sourceRoot":"","sources":["tabs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,0BAA0B,CAAC;AAElC,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAC,MAAM,KAAK,CAAC;AAC/C,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EACL,iBAAiB,EACjB,4BAA4B,GAC7B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAC,iBAAiB,EAAM,MAAM,UAAU,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,IAAK,SAAQ,UAAU;IAWlC;;;;OAIG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;IACrD,CAAC;IACD,IAAI,SAAS,CAAC,GAAe;QAC3B,2EA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ACjB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;IAEO,cAAc;QACpB,4DAA4D;QAC5D,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE;YACjC,OAAO;SACR;QAED,MAAM,EAAC,SAAS,EAAC,GAAG,IAAI,CAAC;QACzB,IAAI,SAAS,EAAE;YACb,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;SACpC;IACH,CAAC;IAEO,gBAAgB;QACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,QAAQ,EAAE;YAC/B,yEAAyE;YACzE,uDAAuD;YACvD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;SAC5B;QAED,yEAAyE;QACzE,4EAA4E;QAC5E,iCAAiC;QACjC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACnC,CAAC;CACF;AAhRC;IACE,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC,GAAA,CAAA;AAMQ;IADR,qBAAqB,CAAC,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAC,CAAC;kCACvC;AA4DiC;IAAtD,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAC,CAAC;0CAAsB;AAE5C;IAA/B,KAAK,CAAC,MAAM,CAAC;yCAAuD;AA4MvE,SAAS,KAAK,CAAC,OAAgB;IAC7B,OAAO,OAAO,YAAY,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../divider/divider.js';\n\nimport {html, isServer, LitElement} from 'lit';\nimport {property, query, queryAssignedElements} from 'lit/decorators.js';\n\nimport {\n polyfillARIAMixin,\n polyfillElementInternalsAria,\n} from '../../internal/aria/aria.js';\n\nimport {ANIMATE_INDICATOR, Tab} from './tab.js';\n\n/**\n * @fires change {Event} 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. --bubbles\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 static {\n polyfillARIAMixin(Tabs);\n }\n\n /**\n * The tabs of this tab bar.\n */\n @queryAssignedElements({flatten: true, selector: '[md-tab]'})\n readonly tabs!: Tab[];\n\n /**\n * The currently selected tab, `null` only when there are no tab children.\n *\n * @export\n */\n get activeTab() {\n return this.tabs.find((tab) => tab.active) ?? null;\n }\n set activeTab(tab: Tab | null) {\n // Ignore setting activeTab to null. As long as there are children, one tab\n // must be selected.\n if (tab) {\n this.activateTab(tab);\n }\n }\n\n /**\n * The index of the currently selected tab.\n *\n * @export\n */\n get activeTabIndex() {\n return this.tabs.findIndex((tab) => tab.active);\n }\n set activeTabIndex(index: number) {\n const activateTabAtIndex = () => {\n const tab = this.tabs[index];\n // Ignore out-of-bound indices.\n if (tab) {\n this.activateTab(tab);\n }\n };\n\n if (!this.slotElement) {\n // This is needed to support setting the activeTabIndex via a lit property\n // binding.\n //\n // ```ts\n // html`\n // <md-tabs .activeTabIndex=${1}>\n // <md-tab>First</md-tab>\n // <md-tab>Second</md-tab>\n // </md-tabs>\n // `;\n // ```\n //\n // It's needed since lit's rendering lifecycle is asynchronous, and the\n // `<slot>` element hasn't rendered, so `tabs` is empty.\n this.updateComplete.then(activateTabAtIndex);\n return;\n }\n\n activateTabAtIndex();\n }\n\n /**\n * Whether or not to automatically select a tab when it is focused.\n */\n @property({type: Boolean, attribute: 'auto-activate'}) autoActivate = false;\n\n @query('slot') private readonly slotElement!: HTMLSlotElement | null;\n\n private get focusedTab() {\n return this.tabs.find((tab) => tab.matches(':focus-within'));\n }\n\n private readonly internals = polyfillElementInternalsAria(\n this,\n // Cast needed for closure\n (this as HTMLElement).attachInternals(),\n );\n\n constructor() {\n super();\n if (!isServer) {\n this.internals.role = 'tablist';\n this.addEventListener('keydown', this.handleKeydown.bind(this));\n this.addEventListener('keyup', this.handleKeyup.bind(this));\n this.addEventListener('focusout', this.handleFocusout.bind(this));\n }\n }\n\n /**\n * Scrolls the toolbar, if overflowing, to the active tab, or the provided\n * tab.\n *\n * @param tabToScrollTo The tab that should be scrolled to. Defaults to the\n * active tab.\n * @return A Promise that resolves after the tab has been scrolled to.\n */\n async scrollToTab(tabToScrollTo?: Tab | null) {\n await this.updateComplete;\n const {tabs} = this;\n tabToScrollTo ??= this.activeTab;\n if (!tabToScrollTo || !tabs.includes(tabToScrollTo)) {\n return;\n }\n\n // wait for tabs to render.\n for (const tab of this.tabs) {\n await tab.updateComplete;\n }\n\n const offset = tabToScrollTo.offsetLeft;\n const extent = tabToScrollTo.offsetWidth;\n const scroll = this.scrollLeft;\n const hostExtent = this.offsetWidth;\n const scrollMargin = 48;\n const min = offset - scrollMargin;\n const max = offset + extent - hostExtent + scrollMargin;\n const to = Math.min(min, Math.max(max, scroll));\n // TODO(b/299934312): improve focus smoothness\n const behavior: ScrollBehavior = !this.focusedTab ? 'smooth' : 'instant';\n this.scrollTo({behavior, top: 0, left: to});\n }\n\n protected override render() {\n return html`\n <div class=\"tabs\">\n <slot\n @slotchange=${this.handleSlotChange}\n @click=${this.handleTabClick}></slot>\n </div>\n <md-divider part=\"divider\"></md-divider>\n `;\n }\n\n private async handleTabClick(event: Event) {\n const tab = event.target;\n // Allow event to bubble\n await 0;\n if (event.defaultPrevented || !isTab(tab) || tab.active) {\n return;\n }\n\n this.activateTab(tab);\n }\n\n private activateTab(activeTab: Tab) {\n const {tabs} = this;\n const previousTab = this.activeTab;\n if (!tabs.includes(activeTab) || previousTab === activeTab) {\n // Ignore setting activeTab to a tab element that is not a child.\n return;\n }\n\n for (const tab of tabs) {\n tab.active = tab === activeTab;\n }\n\n if (previousTab) {\n // Don't dispatch a change event if activating a tab when no previous tabs\n // were selected, such as when md-tabs auto-selects the first tab.\n const defaultPrevented = !this.dispatchEvent(\n new Event('change', {bubbles: true, cancelable: true}),\n );\n if (defaultPrevented) {\n for (const tab of tabs) {\n tab.active = tab === previousTab;\n }\n return;\n }\n\n activeTab[ANIMATE_INDICATOR](previousTab);\n }\n\n this.updateFocusableTab(activeTab);\n this.scrollToTab(activeTab);\n }\n\n private updateFocusableTab(focusableTab: Tab) {\n for (const tab of this.tabs) {\n tab.tabIndex = tab === focusableTab ? 0 : -1;\n }\n }\n\n // focus item on keydown and optionally select it\n private async handleKeydown(event: KeyboardEvent) {\n // Allow event to bubble.\n await 0;\n const isLeft = event.key === 'ArrowLeft';\n const isRight = event.key === 'ArrowRight';\n const isHome = event.key === 'Home';\n const isEnd = event.key === 'End';\n // Ignore non-navigation keys\n if (event.defaultPrevented || (!isLeft && !isRight && !isHome && !isEnd)) {\n return;\n }\n\n const {tabs} = this;\n // Don't try to select another tab if there aren't any.\n if (tabs.length < 2) {\n return;\n }\n\n // Prevent default interactions, such as scrolling.\n event.preventDefault();\n\n let indexToFocus: number;\n if (isHome || isEnd) {\n indexToFocus = isHome ? 0 : tabs.length - 1;\n } else {\n // Check if moving forwards or backwards\n const isRtl = getComputedStyle(this).direction === 'rtl';\n const forwards = isRtl ? isLeft : isRight;\n const {focusedTab} = this;\n if (!focusedTab) {\n // If there is not already a tab focused, select the first or last tab\n // based on the direction we're traveling.\n indexToFocus = forwards ? 0 : tabs.length - 1;\n } else {\n const focusedIndex = this.tabs.indexOf(focusedTab);\n indexToFocus = forwards ? focusedIndex + 1 : focusedIndex - 1;\n if (indexToFocus >= tabs.length) {\n // Return to start if moving past the last item.\n indexToFocus = 0;\n } else if (indexToFocus < 0) {\n // Go to end if moving before the first item.\n indexToFocus = tabs.length - 1;\n }\n }\n }\n\n const tabToFocus = tabs[indexToFocus];\n tabToFocus.focus();\n if (this.autoActivate) {\n this.activateTab(tabToFocus);\n } else {\n this.updateFocusableTab(tabToFocus);\n }\n }\n\n // scroll to item on keyup.\n private handleKeyup() {\n this.scrollToTab(this.focusedTab ?? this.activeTab);\n }\n\n private handleFocusout() {\n // restore focus to selected item when blurring the tab bar.\n if (this.matches(':focus-within')) {\n return;\n }\n\n const {activeTab} = this;\n if (activeTab) {\n this.updateFocusableTab(activeTab);\n }\n }\n\n private handleSlotChange() {\n const firstTab = this.tabs[0];\n if (!this.activeTab && firstTab) {\n // If the active tab was removed, auto-select the first one. There should\n // always be a selected tab while the bar has children.\n this.activateTab(firstTab);\n }\n\n // When children shift, ensure the active tab is visible. For example, if\n // many children are added before the active tab, it'd be pushed off screen.\n // This ensures it stays visible.\n this.scrollToTab(this.activeTab);\n }\n}\n\nfunction isTab(element: unknown): element is Tab {\n return element instanceof HTMLElement && element.hasAttribute('md-tab');\n}\n"]}
1
+ {"version":3,"file":"tabs.js","sourceRoot":"","sources":["tabs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,0BAA0B,CAAC;AAElC,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAC,MAAM,KAAK,CAAC;AAC/C,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAC,iBAAiB,EAAM,MAAM,UAAU,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,IAAK,SAAQ,UAAU;IAOlC;;;;OAIG;IACH,IAAI,SAAS;QACX,OAAO,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2.0\n */\n\nimport '../../divider/divider.js';\n\nimport {html, isServer, LitElement} from 'lit';\nimport {property, query, queryAssignedElements} from 'lit/decorators.js';\n\nimport {ANIMATE_INDICATOR, Tab} from './tab.js';\n\n/**\n * @fires change {Event} 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. --bubbles\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 /**\n * The tabs of this tab bar.\n */\n @queryAssignedElements({flatten: true, selector: '[md-tab]'})\n readonly tabs!: Tab[];\n\n /**\n * The currently selected tab, `null` only when there are no tab children.\n *\n * @export\n */\n get activeTab() {\n return this.tabs.find((tab) => tab.active) ?? null;\n }\n set activeTab(tab: Tab | null) {\n // Ignore setting activeTab to null. As long as there are children, one tab\n // must be selected.\n if (tab) {\n this.activateTab(tab);\n }\n }\n\n /**\n * The index of the currently selected tab.\n *\n * @export\n */\n get activeTabIndex() {\n return this.tabs.findIndex((tab) => tab.active);\n }\n set activeTabIndex(index: number) {\n const activateTabAtIndex = () => {\n const tab = this.tabs[index];\n // Ignore out-of-bound indices.\n if (tab) {\n this.activateTab(tab);\n }\n };\n\n if (!this.slotElement) {\n // This is needed to support setting the activeTabIndex via a lit property\n // binding.\n //\n // ```ts\n // html`\n // <md-tabs .activeTabIndex=${1}>\n // <md-tab>First</md-tab>\n // <md-tab>Second</md-tab>\n // </md-tabs>\n // `;\n // ```\n //\n // It's needed since lit's rendering lifecycle is asynchronous, and the\n // `<slot>` element hasn't rendered, so `tabs` is empty.\n this.updateComplete.then(activateTabAtIndex);\n return;\n }\n\n activateTabAtIndex();\n }\n\n /**\n * Whether or not to automatically select a tab when it is focused.\n */\n @property({type: Boolean, attribute: 'auto-activate'}) autoActivate = false;\n\n @query('slot') private readonly slotElement!: HTMLSlotElement | null;\n\n private get focusedTab() {\n return this.tabs.find((tab) => tab.matches(':focus-within'));\n }\n\n private readonly internals =\n // Cast needed for closure\n (this as HTMLElement).attachInternals();\n\n constructor() {\n super();\n if (!isServer) {\n this.internals.role = 'tablist';\n this.addEventListener('keydown', this.handleKeydown.bind(this));\n this.addEventListener('keyup', this.handleKeyup.bind(this));\n this.addEventListener('focusout', this.handleFocusout.bind(this));\n }\n }\n\n /**\n * Scrolls the toolbar, if overflowing, to the active tab, or the provided\n * tab.\n *\n * @param tabToScrollTo The tab that should be scrolled to. Defaults to the\n * active tab.\n * @return A Promise that resolves after the tab has been scrolled to.\n */\n async scrollToTab(tabToScrollTo?: Tab | null) {\n await this.updateComplete;\n const {tabs} = this;\n tabToScrollTo ??= this.activeTab;\n if (!tabToScrollTo || !tabs.includes(tabToScrollTo)) {\n return;\n }\n\n // wait for tabs to render.\n for (const tab of this.tabs) {\n await tab.updateComplete;\n }\n\n const offset = tabToScrollTo.offsetLeft;\n const extent = tabToScrollTo.offsetWidth;\n const scroll = this.scrollLeft;\n const hostExtent = this.offsetWidth;\n const scrollMargin = 48;\n const min = offset - scrollMargin;\n const max = offset + extent - hostExtent + scrollMargin;\n const to = Math.min(min, Math.max(max, scroll));\n // TODO(b/299934312): improve focus smoothness\n const behavior: ScrollBehavior = !this.focusedTab ? 'smooth' : 'instant';\n this.scrollTo({behavior, top: 0, left: to});\n }\n\n protected override render() {\n return html`\n <div class=\"tabs\">\n <slot\n @slotchange=${this.handleSlotChange}\n @click=${this.handleTabClick}></slot>\n </div>\n <md-divider part=\"divider\"></md-divider>\n `;\n }\n\n private async handleTabClick(event: Event) {\n const tab = event.target;\n // Allow event to bubble\n await 0;\n if (event.defaultPrevented || !isTab(tab) || tab.active) {\n return;\n }\n\n this.activateTab(tab);\n }\n\n private activateTab(activeTab: Tab) {\n const {tabs} = this;\n const previousTab = this.activeTab;\n if (!tabs.includes(activeTab) || previousTab === activeTab) {\n // Ignore setting activeTab to a tab element that is not a child.\n return;\n }\n\n for (const tab of tabs) {\n tab.active = tab === activeTab;\n }\n\n if (previousTab) {\n // Don't dispatch a change event if activating a tab when no previous tabs\n // were selected, such as when md-tabs auto-selects the first tab.\n const defaultPrevented = !this.dispatchEvent(\n new Event('change', {bubbles: true, cancelable: true}),\n );\n if (defaultPrevented) {\n for (const tab of tabs) {\n tab.active = tab === previousTab;\n }\n return;\n }\n\n activeTab[ANIMATE_INDICATOR](previousTab);\n }\n\n this.updateFocusableTab(activeTab);\n this.scrollToTab(activeTab);\n }\n\n private updateFocusableTab(focusableTab: Tab) {\n for (const tab of this.tabs) {\n tab.tabIndex = tab === focusableTab ? 0 : -1;\n }\n }\n\n // focus item on keydown and optionally select it\n private async handleKeydown(event: KeyboardEvent) {\n // Allow event to bubble.\n await 0;\n const isLeft = event.key === 'ArrowLeft';\n const isRight = event.key === 'ArrowRight';\n const isHome = event.key === 'Home';\n const isEnd = event.key === 'End';\n // Ignore non-navigation keys\n if (event.defaultPrevented || (!isLeft && !isRight && !isHome && !isEnd)) {\n return;\n }\n\n const {tabs} = this;\n // Don't try to select another tab if there aren't any.\n if (tabs.length < 2) {\n return;\n }\n\n // Prevent default interactions, such as scrolling.\n event.preventDefault();\n\n let indexToFocus: number;\n if (isHome || isEnd) {\n indexToFocus = isHome ? 0 : tabs.length - 1;\n } else {\n // Check if moving forwards or backwards\n const isRtl = getComputedStyle(this).direction === 'rtl';\n const forwards = isRtl ? isLeft : isRight;\n const {focusedTab} = this;\n if (!focusedTab) {\n // If there is not already a tab focused, select the first or last tab\n // based on the direction we're traveling.\n indexToFocus = forwards ? 0 : tabs.length - 1;\n } else {\n const focusedIndex = this.tabs.indexOf(focusedTab);\n indexToFocus = forwards ? focusedIndex + 1 : focusedIndex - 1;\n if (indexToFocus >= tabs.length) {\n // Return to start if moving past the last item.\n indexToFocus = 0;\n } else if (indexToFocus < 0) {\n // Go to end if moving before the first item.\n indexToFocus = tabs.length - 1;\n }\n }\n }\n\n const tabToFocus = tabs[indexToFocus];\n tabToFocus.focus();\n if (this.autoActivate) {\n this.activateTab(tabToFocus);\n } else {\n this.updateFocusableTab(tabToFocus);\n }\n }\n\n // scroll to item on keyup.\n private handleKeyup() {\n this.scrollToTab(this.focusedTab ?? this.activeTab);\n }\n\n private handleFocusout() {\n // restore focus to selected item when blurring the tab bar.\n if (this.matches(':focus-within')) {\n return;\n }\n\n const {activeTab} = this;\n if (activeTab) {\n this.updateFocusableTab(activeTab);\n }\n }\n\n private handleSlotChange() {\n const firstTab = this.tabs[0];\n if (!this.activeTab && firstTab) {\n // If the active tab was removed, auto-select the first one. There should\n // always be a selected tab while the bar has children.\n this.activateTab(firstTab);\n }\n\n // When children shift, ensure the active tab is visible. For example, if\n // many children are added before the active tab, it'd be pushed off screen.\n // This ensures it stays visible.\n this.scrollToTab(this.activeTab);\n }\n}\n\nfunction isTab(element: unknown): element is Tab {\n return element instanceof HTMLElement && element.hasAttribute('md-tab');\n}\n"]}
@@ -5,7 +5,10 @@
5
5
  */
6
6
  import { LitElement, PropertyValues } from 'lit';
7
7
  import { StaticValue } from 'lit/static-html.js';
8
+ import { createValidator, getValidityAnchor } from '../../labs/behaviors/constraint-validation.js';
8
9
  import { getFormValue } from '../../labs/behaviors/form-associated.js';
10
+ import { onReportValidity } from '../../labs/behaviors/on-report-validity.js';
11
+ import { Validator } from '../../labs/behaviors/validators/validator.js';
9
12
  /**
10
13
  * Input types that are compatible with the text field.
11
14
  */
@@ -18,7 +21,7 @@ export type UnsupportedTextFieldType = 'color' | 'date' | 'datetime-local' | 'fi
18
21
  * Input types that are incompatible with the text field.
19
22
  */
20
23
  export type InvalidTextFieldType = 'button' | 'checkbox' | 'hidden' | 'image' | 'radio' | 'range' | 'reset' | 'submit';
21
- declare const textFieldBaseClass: import("../../labs/behaviors/mixin.js").MixinReturn<(abstract new (...args: any[]) => import("../../labs/behaviors/element-internals.js").WithElementInternals) & typeof LitElement & import("../../labs/behaviors/form-associated.js").FormAssociatedConstructor, import("../../labs/behaviors/form-associated.js").FormAssociated>;
24
+ declare const textFieldBaseClass: import("../../labs/behaviors/mixin.js").MixinReturn<import("../../labs/behaviors/mixin.js").MixinReturn<import("../../labs/behaviors/mixin.js").MixinReturn<(abstract new (...args: any[]) => import("../../labs/behaviors/element-internals.js").WithElementInternals) & typeof LitElement & import("../../labs/behaviors/form-associated.js").FormAssociatedConstructor, import("../../labs/behaviors/form-associated.js").FormAssociated>, import("../../labs/behaviors/constraint-validation.js").ConstraintValidation>, import("../../labs/behaviors/on-report-validity.js").OnReportValidity>;
22
25
  /**
23
26
  * A text field component.
24
27
  *
@@ -190,19 +193,6 @@ export declare abstract class TextField extends textFieldBaseClass {
190
193
  * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
191
194
  */
192
195
  autocomplete: string;
193
- /**
194
- * Returns the text field's validation error message.
195
- *
196
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation
197
- */
198
- get validationMessage(): string;
199
- /**
200
- * Returns a `ValidityState` object that represents the validity states of the
201
- * text field.
202
- *
203
- * https://developer.mozilla.org/en-US/docs/Web/API/ValidityState
204
- */
205
- get validity(): ValidityState;
206
196
  /**
207
197
  * The text field's value as a number.
208
198
  */
@@ -213,13 +203,6 @@ export declare abstract class TextField extends textFieldBaseClass {
213
203
  */
214
204
  get valueAsDate(): Date | null;
215
205
  set valueAsDate(value: Date | null);
216
- /**
217
- * Returns whether an element will successfully validate based on forms
218
- * validation rules and constraints.
219
- *
220
- * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate
221
- */
222
- get willValidate(): boolean;
223
206
  protected abstract readonly fieldTag: StaticValue;
224
207
  /**
225
208
  * Returns true when the text field has been interacted with. Native
@@ -237,62 +220,16 @@ export declare abstract class TextField extends textFieldBaseClass {
237
220
  */
238
221
  private nativeErrorText;
239
222
  private get hasError();
240
- private readonly inputOrTextarea?;
241
- private readonly field?;
223
+ private readonly inputOrTextarea;
224
+ private readonly field;
242
225
  private readonly leadingIcons;
243
226
  private readonly trailingIcons;
244
- private isCheckingValidity;
245
- private isReportingValidity;
246
- private hasCustomValidityError;
247
- /**
248
- * Checks the text field's native validation and returns whether or not the
249
- * element is valid.
250
- *
251
- * If invalid, this method will dispatch the `invalid` event.
252
- *
253
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity
254
- *
255
- * @return true if the text field is valid, or false if not.
256
- */
257
- checkValidity(): boolean;
258
- /**
259
- * Checks the text field's native validation and returns whether or not the
260
- * element is valid.
261
- *
262
- * If invalid, this method will dispatch the `invalid` event.
263
- *
264
- * This method will display or clear an error text message equal to the text
265
- * field's `validationMessage`, unless the invalid event is canceled.
266
- *
267
- * Use `setCustomValidity()` to customize the `validationMessage`.
268
- *
269
- * This method can also be used to re-announce error messages to screen
270
- * readers.
271
- *
272
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/reportValidity
273
- *
274
- * @return true if the text field is valid, or false if not.
275
- */
276
- reportValidity(): boolean;
277
- private showErrorMessage;
278
227
  /**
279
228
  * Selects all the text in the text field.
280
229
  *
281
230
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select
282
231
  */
283
232
  select(): void;
284
- /**
285
- * Sets a custom validation error message for the text field. Use this for
286
- * custom error message.
287
- *
288
- * When the error is not an empty string, the text field is considered invalid
289
- * and `validity.customError` will be true.
290
- *
291
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity
292
- *
293
- * @param error The error message to display.
294
- */
295
- setCustomValidity(error: string): void;
296
233
  /**
297
234
  * Replaces a range of text with a new string.
298
235
  *
@@ -346,20 +283,18 @@ export declare abstract class TextField extends textFieldBaseClass {
346
283
  private handleFocusin;
347
284
  private handleFocusout;
348
285
  private handleInput;
349
- private handleChange;
350
286
  private redispatchEvent;
351
287
  private getInputOrTextarea;
352
288
  private getInput;
353
- private syncValidity;
354
289
  private handleIconChange;
355
- private readonly onInvalid;
356
- connectedCallback(): void;
357
- disconnectedCallback(): void;
358
290
  disabled: boolean;
359
291
  name: string;
360
292
  [getFormValue](): string;
361
293
  formResetCallback(): void;
362
294
  formStateRestoreCallback(state: string): void;
363
295
  focus(): void;
296
+ [createValidator](): Validator<unknown>;
297
+ [getValidityAnchor](): HTMLElement | null;
298
+ [onReportValidity](invalidEvent: Event | null): void;
364
299
  }
365
300
  export {};