@ptcwebops/ptcw-design 6.4.18 → 6.4.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/academic-form-test_10.cjs.entry.js +12557 -0
- package/dist/cjs/buying-option-cards-slider.cjs.entry.js +4 -0
- package/dist/cjs/event-podcast-slider-example.cjs.entry.js +1 -1
- package/dist/cjs/featured-events-slider-example.cjs.entry.js +1 -1
- package/dist/cjs/homepage-jumbotron.cjs.entry.js +1 -1
- package/dist/cjs/icon-asset.cjs.entry.js +65 -0
- package/dist/cjs/interfaces-574e6df7.js +15 -0
- package/dist/cjs/list-item.cjs.entry.js +52 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/ptc-background-video.cjs.entry.js +152 -0
- package/dist/cjs/ptc-breadcrumb.cjs.entry.js +63 -0
- package/dist/cjs/ptc-case-studies-slider.cjs.entry.js +1 -1
- package/dist/cjs/ptc-icon-card-slider-example.cjs.entry.js +1 -1
- package/dist/cjs/ptc-icon-component.cjs.entry.js +1 -1
- package/dist/cjs/ptc-img.cjs.entry.js +136 -0
- package/dist/cjs/ptc-jumbotron.cjs.entry.js +184 -0
- package/dist/cjs/ptc-multi-select.cjs.entry.js +326 -0
- package/dist/cjs/ptc-picture.cjs.entry.js +185 -0
- package/dist/cjs/ptc-subnav-v2.cjs.entry.js +595 -0
- package/dist/cjs/ptc-tooltip.cjs.entry.js +113 -0
- package/dist/cjs/ptcw-design.cjs.js +1 -1
- package/dist/cjs/storefront-enhanced-product-list-alt-example.cjs.entry.js +1 -1
- package/dist/cjs/storefront-enhanced-product-list-example.cjs.entry.js +1 -1
- package/dist/collection/components/buying-option-cards-slider/buying-option-cards-slider.js +4 -0
- package/dist/collection/components/organism-bundles/event-podcast-slider-example/event-podcast-slider-example.css +16 -11
- package/dist/collection/components/organism-bundles/featured-events-slider-example/featured-events-slider-example.css +16 -11
- package/dist/collection/components/organism-bundles/homepage-jumbotron/homepage-jumbotron.css +16 -11
- package/dist/collection/components/organism-bundles/ptc-icon-card-slider-example/ptc-icon-card-slider-example.css +16 -11
- package/dist/collection/components/organism-bundles/storefront-enhanced-product-list-example/storefront-enhanced-product-list-example.css +16 -11
- package/dist/collection/components/ptc-case-studies-slider/ptc-case-studies-slider.css +16 -11
- package/dist/collection/components/ptc-icon-component/ptc-icon-component.css +16 -11
- package/dist/collection/components/ptc-seo-title/ptc-seo-title.js +3 -3
- package/dist/custom-elements/index.js +11 -7
- package/dist/esm/academic-form-test_10.entry.js +12544 -0
- package/dist/esm/author-listing-example.entry.js +1 -1
- package/dist/esm/blog-detail-content_2.entry.js +2 -2
- package/dist/esm/blog-detail-layout.entry.js +2 -2
- package/dist/esm/blogs-search-section.entry.js +2 -2
- package/dist/esm/bundle-example.entry.js +1 -1
- package/dist/esm/bundle-jumbotron-example.entry.js +1 -1
- package/dist/esm/buying-option-card.entry.js +1 -1
- package/dist/esm/buying-option-cards-slider.entry.js +5 -1
- package/dist/esm/dropdown-item.entry.js +1 -1
- package/dist/esm/dynamic-box-bundle.entry.js +1 -1
- package/dist/esm/embedded-form.entry.js +1 -1
- package/dist/esm/event-jumbotron-example.entry.js +1 -1
- package/dist/esm/event-podcast-slider-example.entry.js +2 -2
- package/dist/esm/featured-events-slider-example.entry.js +2 -2
- package/dist/esm/featured-list.entry.js +1 -1
- package/dist/esm/fl-tab-content_3.entry.js +1 -1
- package/dist/esm/footer-form.entry.js +1 -1
- package/dist/esm/homepage-clickable-tab.entry.js +1 -1
- package/dist/esm/homepage-jumbotron.entry.js +3 -3
- package/dist/esm/homepage-toggled-content.entry.js +2 -2
- package/dist/esm/icon-asset.entry.js +61 -0
- package/dist/esm/{index-0bf594c4.js → index-c83db688.js} +1 -1
- package/dist/esm/innovator-toggle-container.entry.js +2 -2
- package/dist/esm/interfaces-4caedd26.js +12 -0
- package/dist/esm/jumbotron-sub-menu.entry.js +1 -1
- package/dist/esm/jumbotron-sub-mune.entry.js +1 -1
- package/dist/esm/list-item.entry.js +48 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/most-popular-news.entry.js +2 -2
- package/dist/esm/my-component.entry.js +2 -2
- package/dist/esm/news-search-result.entry.js +1 -1
- package/dist/esm/ptc-accordion-item.entry.js +2 -2
- package/dist/esm/ptc-accordion.entry.js +1 -1
- package/dist/esm/ptc-announcement.entry.js +1 -1
- package/dist/esm/ptc-back-to-top.entry.js +1 -1
- package/dist/esm/ptc-background-video.entry.js +148 -0
- package/dist/esm/ptc-badge.entry.js +1 -1
- package/dist/esm/ptc-bio-card.entry.js +1 -1
- package/dist/esm/ptc-blue-pill-announcement-bar.entry.js +1 -1
- package/dist/esm/ptc-breadcrumb.entry.js +59 -0
- package/dist/esm/ptc-brightcov-video.entry.js +1 -1
- package/dist/esm/ptc-card-bottom_2.entry.js +1 -1
- package/dist/esm/ptc-card-content.entry.js +1 -1
- package/dist/esm/ptc-card_2.entry.js +1 -1
- package/dist/esm/ptc-case-studies-slider.entry.js +2 -2
- package/dist/esm/ptc-checkbox-group.entry.js +1 -1
- package/dist/esm/ptc-checkbox.entry.js +1 -1
- package/dist/esm/ptc-close-icon_2.entry.js +1 -1
- package/dist/esm/ptc-collapse-list.entry.js +2 -2
- package/dist/esm/ptc-container.entry.js +1 -1
- package/dist/esm/ptc-countdown.entry.js +1 -1
- package/dist/esm/ptc-date.entry.js +1 -1
- package/dist/esm/ptc-dropdown.entry.js +1 -1
- package/dist/esm/ptc-dynamic-card.entry.js +1 -1
- package/dist/esm/ptc-ellipsis-dropdown.entry.js +1 -1
- package/dist/esm/ptc-embedded-quiz.entry.js +1 -1
- package/dist/esm/ptc-enhanced-product-listing-card.entry.js +1 -1
- package/dist/esm/ptc-featured-list.entry.js +1 -1
- package/dist/esm/ptc-filter-dropdown_4.entry.js +1 -1
- package/dist/esm/ptc-filter-level-theater.entry.js +1 -1
- package/dist/esm/ptc-filter-tag_2.entry.js +1 -1
- package/dist/esm/ptc-footer.entry.js +1 -1
- package/dist/esm/ptc-form-radio-button.entry.js +1 -1
- package/dist/esm/ptc-form-radio-group.entry.js +1 -1
- package/dist/esm/ptc-form.entry.js +1 -1
- package/dist/esm/ptc-hero-footer-cta.entry.js +1 -1
- package/dist/esm/ptc-hero.entry.js +1 -1
- package/dist/esm/ptc-homepage-image-feature.entry.js +2 -2
- package/dist/esm/ptc-homepage-video-background.entry.js +2 -2
- package/dist/esm/ptc-icon-card-slider-example.entry.js +2 -2
- package/dist/esm/ptc-icon-card.entry.js +2 -2
- package/dist/esm/ptc-icon-component.entry.js +2 -2
- package/dist/esm/ptc-icon-list.entry.js +1 -1
- package/dist/esm/ptc-icon-minimize.entry.js +1 -1
- package/dist/esm/ptc-image-download-strip.entry.js +1 -1
- package/dist/esm/ptc-img.entry.js +132 -0
- package/dist/esm/ptc-info-tile.entry.js +1 -1
- package/dist/esm/ptc-inline-cta.entry.js +1 -1
- package/dist/esm/ptc-jumbotron.entry.js +180 -0
- package/dist/esm/ptc-link.entry.js +2 -2
- package/dist/esm/ptc-list.entry.js +1 -1
- package/dist/esm/ptc-media-card.entry.js +2 -2
- package/dist/esm/ptc-minimized-nav.entry.js +1 -1
- package/dist/esm/ptc-mobile-select.entry.js +1 -1
- package/dist/esm/ptc-modal-quiz.entry.js +1 -1
- package/dist/esm/ptc-multi-select.entry.js +322 -0
- package/dist/esm/ptc-nav-card.entry.js +1 -1
- package/dist/esm/ptc-nav-link.entry.js +1 -1
- package/dist/esm/ptc-nav-pills.entry.js +1 -1
- package/dist/esm/ptc-nav-skip-to-content.entry.js +1 -1
- package/dist/esm/ptc-nav-slider.entry.js +1 -1
- package/dist/esm/ptc-nav-submenu.entry.js +1 -1
- package/dist/esm/ptc-nav-tile.entry.js +1 -1
- package/dist/esm/ptc-news.entry.js +1 -1
- package/dist/esm/ptc-office-location-card.entry.js +1 -1
- package/dist/esm/ptc-office-locations.entry.js +1 -1
- package/dist/esm/ptc-overlay.entry.js +1 -1
- package/dist/esm/ptc-picture.entry.js +181 -0
- package/dist/esm/ptc-podcast-card.entry.js +1 -1
- package/dist/esm/ptc-preferance-center-form.entry.js +1 -1
- package/dist/esm/ptc-preloader.entry.js +1 -1
- package/dist/esm/ptc-previous-url.entry.js +1 -1
- package/dist/esm/ptc-pricing-add-on-card.entry.js +1 -1
- package/dist/esm/ptc-pricing-add-on-section.entry.js +1 -1
- package/dist/esm/ptc-pricing-block.entry.js +1 -1
- package/dist/esm/ptc-pricing-packaging-table.entry.js +2 -2
- package/dist/esm/ptc-pricing-tabs.entry.js +2 -2
- package/dist/esm/ptc-product-card.entry.js +1 -1
- package/dist/esm/ptc-product-category.entry.js +1 -1
- package/dist/esm/ptc-product-dropdown.entry.js +1 -1
- package/dist/esm/ptc-product-highlight-card.entry.js +1 -1
- package/dist/esm/ptc-product-list.entry.js +1 -1
- package/dist/esm/ptc-product-sidebar.entry.js +1 -1
- package/dist/esm/ptc-progress-bar.entry.js +1 -1
- package/dist/esm/ptc-quantity-counter.entry.js +1 -1
- package/dist/esm/ptc-quote.entry.js +1 -1
- package/dist/esm/ptc-readmore-char.entry.js +1 -1
- package/dist/esm/ptc-readmore-new.entry.js +1 -1
- package/dist/esm/ptc-readmore-v3.entry.js +1 -1
- package/dist/esm/ptc-readmore.entry.js +1 -1
- package/dist/esm/ptc-related-card-rail.entry.js +1 -1
- package/dist/esm/ptc-responsive-wrapper.entry.js +1 -1
- package/dist/esm/ptc-scroll-button.entry.js +1 -1
- package/dist/esm/ptc-search-field.entry.js +1 -1
- package/dist/esm/ptc-seo-title.entry.js +1 -1
- package/dist/esm/ptc-shopping-cart.entry.js +1 -1
- package/dist/esm/ptc-showcase-card.entry.js +1 -1
- package/dist/esm/ptc-skeleton.entry.js +1 -1
- package/dist/esm/ptc-slit-card.entry.js +1 -1
- package/dist/esm/ptc-social-icons-footer.entry.js +2 -2
- package/dist/esm/ptc-social-icons.entry.js +1 -1
- package/dist/esm/ptc-span.entry.js +1 -1
- package/dist/esm/ptc-square-card.entry.js +1 -1
- package/dist/esm/ptc-sticky-icons.entry.js +1 -1
- package/dist/esm/ptc-sticky-section.entry.js +1 -1
- package/dist/esm/ptc-sticky-title.entry.js +1 -1
- package/dist/esm/ptc-store-card-list.entry.js +1 -1
- package/dist/esm/ptc-store-card.entry.js +1 -1
- package/dist/esm/ptc-subnav-card.entry.js +1 -1
- package/dist/esm/ptc-subnav-v2.entry.js +591 -0
- package/dist/esm/ptc-subnav.entry.js +1 -1
- package/dist/esm/ptc-svg-btn.entry.js +1 -1
- package/dist/esm/ptc-tab-list.entry.js +1 -1
- package/dist/esm/ptc-tab.entry.js +1 -1
- package/dist/esm/ptc-tabs.entry.js +1 -1
- package/dist/esm/ptc-text-copy-with-background.entry.js +1 -1
- package/dist/esm/ptc-theater-video-modal.entry.js +1 -1
- package/dist/esm/ptc-tooltip-v2.entry.js +1 -1
- package/dist/esm/ptc-tooltip-v3.entry.js +1 -1
- package/dist/esm/ptc-tooltip.entry.js +109 -0
- package/dist/esm/ptc-two-column-media.entry.js +1 -1
- package/dist/esm/ptc-value-led-card.entry.js +1 -1
- package/dist/esm/ptc-value-led-content-highlight.entry.js +1 -1
- package/dist/esm/ptc-value-led-content.entry.js +1 -1
- package/dist/esm/ptc-value-led-intro.entry.js +1 -1
- package/dist/esm/ptc-value-led-layout.entry.js +1 -1
- package/dist/esm/ptc-value-led-speed-bump.entry.js +1 -1
- package/dist/esm/ptc-value-prop-card.entry.js +1 -1
- package/dist/esm/ptc-video-embed.entry.js +1 -1
- package/dist/esm/ptc-white-paper.entry.js +1 -1
- package/dist/esm/ptcw-design.js +3 -3
- package/dist/esm/sequential-bundle-example.entry.js +1 -1
- package/dist/esm/sequential-bundle.entry.js +1 -1
- package/dist/esm/storefront-enhanced-product-list-alt-example.entry.js +2 -2
- package/dist/esm/storefront-enhanced-product-list-example.entry.js +2 -2
- package/dist/esm/tab-content.entry.js +1 -1
- package/dist/esm/tab-header.entry.js +1 -1
- package/dist/esm/{utils-a64ba942.js → utils-d14265f5.js} +1 -1
- package/dist/ptcw-design/{p-ad4f4f33.entry.js → p-00e21489.entry.js} +1 -1
- package/dist/ptcw-design/{p-17890eea.entry.js → p-04223295.entry.js} +1 -1
- package/dist/ptcw-design/{p-74a845fd.entry.js → p-04aae3f5.entry.js} +1 -1
- package/dist/ptcw-design/{p-c9a73ad1.entry.js → p-04f0b1ba.entry.js} +1 -1
- package/dist/ptcw-design/p-08f607e5.entry.js +1 -0
- package/dist/ptcw-design/p-0a86d91a.entry.js +1 -0
- package/dist/ptcw-design/{p-e8b51e7d.entry.js → p-0a9ee6c2.entry.js} +1 -1
- package/dist/ptcw-design/p-0b146b4b.entry.js +1 -0
- package/dist/ptcw-design/{p-c80265d9.entry.js → p-0c914932.entry.js} +1 -1
- package/dist/ptcw-design/{p-f004e5de.entry.js → p-0ddf2a09.entry.js} +1 -1
- package/dist/ptcw-design/{p-f9e57052.entry.js → p-136c990d.entry.js} +1 -1
- package/dist/ptcw-design/{p-36d6e662.entry.js → p-13e338a5.entry.js} +1 -1
- package/dist/ptcw-design/{p-8cdcfb51.entry.js → p-15e36f30.entry.js} +1 -1
- package/dist/ptcw-design/{p-f418ef26.entry.js → p-18d699f0.entry.js} +1 -1
- package/dist/ptcw-design/p-1a853854.entry.js +1 -0
- package/dist/ptcw-design/{p-908ad455.entry.js → p-1c63c812.entry.js} +1 -1
- package/dist/ptcw-design/{p-8482f517.entry.js → p-1cb02c28.entry.js} +1 -1
- package/dist/ptcw-design/{p-9a07b9e3.entry.js → p-1e1ed5df.entry.js} +1 -1
- package/dist/ptcw-design/{p-752159e2.entry.js → p-1f356fcf.entry.js} +1 -1
- package/dist/ptcw-design/{p-2fd01953.entry.js → p-21fa5abe.entry.js} +1 -1
- package/dist/ptcw-design/{p-c9762c88.entry.js → p-23cb5b5b.entry.js} +1 -1
- package/dist/ptcw-design/p-243075b7.entry.js +1 -0
- package/dist/ptcw-design/{p-a22d7ae8.entry.js → p-257a68df.entry.js} +1 -1
- package/dist/ptcw-design/p-264cd2d3.entry.js +1 -0
- package/dist/ptcw-design/p-27e39236.entry.js +1 -0
- package/dist/ptcw-design/{p-14c77b5e.entry.js → p-27e47c25.entry.js} +1 -1
- package/dist/ptcw-design/{p-f20e4230.entry.js → p-2a22123e.entry.js} +1 -1
- package/dist/ptcw-design/{p-f4ae5a99.entry.js → p-2b08a37d.entry.js} +1 -1
- package/dist/ptcw-design/{p-315b7885.entry.js → p-2c287230.entry.js} +1 -1
- package/dist/ptcw-design/{p-54891548.entry.js → p-2c2f895a.entry.js} +1 -1
- package/dist/ptcw-design/p-37f92bb4.entry.js +1 -0
- package/dist/ptcw-design/{p-a2710bbf.entry.js → p-3872fce7.entry.js} +1 -1
- package/dist/ptcw-design/{p-9050ab76.entry.js → p-3a034cd1.entry.js} +1 -1
- package/dist/ptcw-design/p-3a24991d.entry.js +1 -0
- package/dist/ptcw-design/p-3ddb6c50.entry.js +1 -0
- package/dist/ptcw-design/{p-3c941935.entry.js → p-3e4861a2.entry.js} +1 -1
- package/dist/ptcw-design/p-3eccbe24.entry.js +1 -0
- package/dist/ptcw-design/p-3ed4a7ed.entry.js +1 -0
- package/dist/ptcw-design/{p-3596ce5a.entry.js → p-44eac15a.entry.js} +1 -1
- package/dist/ptcw-design/{p-83632220.entry.js → p-45623f8a.entry.js} +1 -1
- package/dist/ptcw-design/{p-1e9f25fc.entry.js → p-46f67bec.entry.js} +1 -1
- package/dist/ptcw-design/p-4ab3249d.entry.js +1 -0
- package/dist/ptcw-design/{p-e2da8109.entry.js → p-4c2ffab9.entry.js} +1 -1
- package/dist/ptcw-design/{p-efe8563a.entry.js → p-4d14b3b7.entry.js} +1 -1
- package/dist/ptcw-design/{p-a1dc7ae5.entry.js → p-4f3dea53.entry.js} +1 -1
- package/dist/ptcw-design/{p-ed5a467e.entry.js → p-4f4f97a6.entry.js} +1 -1
- package/dist/ptcw-design/{p-91e5c8d4.entry.js → p-506dac1f.entry.js} +1 -1
- package/dist/ptcw-design/{p-9e8e2835.entry.js → p-523141fd.entry.js} +1 -1
- package/dist/ptcw-design/{p-bca81995.entry.js → p-560b05a5.entry.js} +1 -1
- package/dist/ptcw-design/p-567535fb.entry.js +1 -0
- package/dist/ptcw-design/{p-a31f22a1.entry.js → p-571d9690.entry.js} +1 -1
- package/dist/ptcw-design/{p-c8de7309.entry.js → p-575861b3.entry.js} +1 -1
- package/dist/ptcw-design/{p-ec395ae9.entry.js → p-5877f093.entry.js} +1 -1
- package/dist/ptcw-design/{p-07b46e6e.entry.js → p-58909b95.entry.js} +1 -1
- package/dist/ptcw-design/{p-cab0274c.entry.js → p-5946d7c9.entry.js} +1 -1
- package/dist/ptcw-design/{p-807ad5c4.entry.js → p-5980d65d.entry.js} +1 -1
- package/dist/ptcw-design/{p-7c6d6a5e.entry.js → p-5dd538c4.entry.js} +1 -1
- package/dist/ptcw-design/p-5e4c1edf.entry.js +1 -0
- package/dist/ptcw-design/{p-5fb671ee.entry.js → p-61d28206.entry.js} +1 -1
- package/dist/ptcw-design/{p-9220308d.entry.js → p-62c56201.entry.js} +1 -1
- package/dist/ptcw-design/p-62dcdd28.entry.js +1 -0
- package/dist/ptcw-design/{p-3e13f29c.entry.js → p-66ecd7b9.entry.js} +1 -1
- package/dist/ptcw-design/p-6a561487.entry.js +1 -0
- package/dist/ptcw-design/{p-575c7fc0.entry.js → p-6aa9ed95.entry.js} +1 -1
- package/dist/ptcw-design/p-6abc061b.entry.js +1 -0
- package/dist/ptcw-design/{p-32a1c28b.entry.js → p-6d27b5a2.entry.js} +1 -1
- package/dist/ptcw-design/p-711bcdad.js +1 -0
- package/dist/ptcw-design/{p-c9c55caf.entry.js → p-73fd95da.entry.js} +1 -1
- package/dist/ptcw-design/{p-522cb451.entry.js → p-757954b2.entry.js} +1 -1
- package/dist/ptcw-design/p-761a31f8.entry.js +1 -0
- package/dist/ptcw-design/{p-3e13b735.entry.js → p-76d98c5a.entry.js} +1 -1
- package/dist/ptcw-design/{p-2fdd81d4.entry.js → p-7714bbaf.entry.js} +1 -1
- package/dist/ptcw-design/{p-af32c90a.entry.js → p-784cae5c.entry.js} +1 -1
- package/dist/ptcw-design/{p-ecfc8211.entry.js → p-7a1db471.entry.js} +1 -1
- package/dist/ptcw-design/{p-183ba1ca.entry.js → p-7d29a418.entry.js} +1 -1
- package/dist/ptcw-design/p-7da19c78.entry.js +1 -0
- package/dist/ptcw-design/{p-2fa5814b.entry.js → p-7f4919b7.entry.js} +1 -1
- package/dist/ptcw-design/p-80c69354.entry.js +1 -0
- package/dist/ptcw-design/{p-a974f98f.entry.js → p-8191928d.entry.js} +1 -1
- package/dist/ptcw-design/{p-c1302aea.entry.js → p-8340bed4.entry.js} +1 -1
- package/dist/ptcw-design/{p-ff369ed7.entry.js → p-84c15835.entry.js} +1 -1
- package/dist/ptcw-design/{p-3c52fabe.entry.js → p-8533988f.entry.js} +1 -1
- package/dist/ptcw-design/{p-1ab6201b.entry.js → p-85f32bf5.entry.js} +1 -1
- package/dist/ptcw-design/{p-ce39cff2.entry.js → p-88d1894d.entry.js} +1 -1
- package/dist/ptcw-design/{p-bf2f9183.entry.js → p-89ba3dfd.entry.js} +1 -1
- package/dist/ptcw-design/{p-e2e357e7.entry.js → p-8d4572f7.entry.js} +1 -1
- package/dist/ptcw-design/{p-cf0f6559.entry.js → p-927373d4.entry.js} +1 -1
- package/dist/ptcw-design/{p-e1bd2c43.entry.js → p-92e76318.entry.js} +1 -1
- package/dist/ptcw-design/{p-80c56c81.entry.js → p-931650bb.entry.js} +1 -1
- package/dist/ptcw-design/{p-2ba77e9d.entry.js → p-9354b7fd.entry.js} +1 -1
- package/dist/ptcw-design/{p-3b481342.entry.js → p-9493dfa0.entry.js} +1 -1
- package/dist/ptcw-design/p-97eb1025.entry.js +1 -0
- package/dist/ptcw-design/{p-ce125ef2.entry.js → p-98610430.entry.js} +1 -1
- package/dist/ptcw-design/p-99daf693.entry.js +1 -0
- package/dist/ptcw-design/{p-8eb36507.entry.js → p-9a335b5b.entry.js} +1 -1
- package/dist/ptcw-design/{p-0abb6e77.entry.js → p-9ac99185.entry.js} +1 -1
- package/dist/ptcw-design/{p-290012e3.entry.js → p-9b26ea67.entry.js} +1 -1
- package/dist/ptcw-design/{p-6d628113.entry.js → p-9de963f8.entry.js} +1 -1
- package/dist/ptcw-design/{p-6251a6d6.entry.js → p-9e4e21a4.entry.js} +1 -1
- package/dist/ptcw-design/p-9efa8199.entry.js +1 -0
- package/dist/ptcw-design/{p-5877ab67.entry.js → p-9fc6a83d.entry.js} +1 -1
- package/dist/ptcw-design/{p-afb5bdb9.entry.js → p-a04bedc2.entry.js} +1 -1
- package/dist/ptcw-design/{p-dadbab48.entry.js → p-a0bf3dd2.entry.js} +1 -1
- package/dist/ptcw-design/p-a264f646.entry.js +1 -0
- package/dist/ptcw-design/{p-e2e33ddb.entry.js → p-a37c5209.entry.js} +1 -1
- package/dist/ptcw-design/{p-b6cc4c2a.entry.js → p-a41c7e39.entry.js} +1 -1
- package/dist/ptcw-design/{p-dabb1b70.entry.js → p-a54c6da5.entry.js} +1 -1
- package/dist/ptcw-design/{p-6f29592a.entry.js → p-a5efeb04.entry.js} +1 -1
- package/dist/ptcw-design/{p-991465fb.entry.js → p-a79f33df.entry.js} +1 -1
- package/dist/ptcw-design/{p-7123abad.entry.js → p-a7a41de8.entry.js} +1 -1
- package/dist/ptcw-design/{p-be00fb74.entry.js → p-a7cb3851.entry.js} +1 -1
- package/dist/ptcw-design/{p-ed53cb3a.entry.js → p-a8304a3e.entry.js} +1 -1
- package/dist/ptcw-design/{p-de663192.entry.js → p-a8504f11.entry.js} +1 -1
- package/dist/ptcw-design/{p-11e86045.entry.js → p-a9533f9c.entry.js} +1 -1
- package/dist/ptcw-design/{p-e50a5a46.entry.js → p-a993c0a6.entry.js} +1 -1
- package/dist/ptcw-design/{p-c5417010.entry.js → p-aac082cf.entry.js} +1 -1
- package/dist/ptcw-design/{p-87f07d6b.entry.js → p-aadf9416.entry.js} +1 -1
- package/dist/ptcw-design/{p-6f1cc5e5.entry.js → p-ab4906a7.entry.js} +1 -1
- package/dist/ptcw-design/{p-944c5be8.js → p-ac75c7ad.js} +1 -1
- package/dist/ptcw-design/p-ac766cb3.entry.js +1 -0
- package/dist/ptcw-design/{p-e249cd90.entry.js → p-ac7b2779.entry.js} +1 -1
- package/dist/ptcw-design/{p-b293a0b1.entry.js → p-aea09a70.entry.js} +1 -1
- package/dist/ptcw-design/p-af9912b6.entry.js +1 -0
- package/dist/ptcw-design/p-afc1e1e9.entry.js +1 -0
- package/dist/ptcw-design/{p-b82dd7f9.entry.js → p-b19cda95.entry.js} +1 -1
- package/dist/ptcw-design/{p-79762cf6.entry.js → p-b436f56d.entry.js} +1 -1
- package/dist/ptcw-design/{p-ca039722.entry.js → p-baeee2b4.entry.js} +1 -1
- package/dist/ptcw-design/p-bb9a879f.entry.js +1 -0
- package/dist/ptcw-design/{p-73293d32.entry.js → p-bf84ecc0.entry.js} +1 -1
- package/dist/ptcw-design/{p-9a28ded2.entry.js → p-bfacfe67.entry.js} +1 -1
- package/dist/ptcw-design/{p-fb0c3eeb.entry.js → p-c061b32d.entry.js} +1 -1
- package/dist/ptcw-design/{p-5344a1f4.entry.js → p-c4674bc8.entry.js} +1 -1
- package/dist/ptcw-design/{p-dd38bf84.entry.js → p-c5f42895.entry.js} +1 -1
- package/dist/ptcw-design/{p-61a5012d.entry.js → p-c631608f.entry.js} +1 -1
- package/dist/ptcw-design/{p-e87a4ff8.entry.js → p-c68d31c6.entry.js} +1 -1
- package/dist/ptcw-design/{p-43756439.entry.js → p-c6a0dd99.entry.js} +1 -1
- package/dist/ptcw-design/p-c89030e4.entry.js +1 -0
- package/dist/ptcw-design/p-cbbe2bba.entry.js +1 -0
- package/dist/ptcw-design/{p-384548ef.entry.js → p-cc652ebe.entry.js} +1 -1
- package/dist/ptcw-design/{p-fa045097.entry.js → p-cc92b9ed.entry.js} +1 -1
- package/dist/ptcw-design/p-d6ee094b.entry.js +1 -0
- package/dist/ptcw-design/{p-75d8b6ec.entry.js → p-d74ccb19.entry.js} +1 -1
- package/dist/ptcw-design/{p-81736d6a.entry.js → p-d77531c8.entry.js} +1 -1
- package/dist/ptcw-design/p-d8575311.entry.js +1 -0
- package/dist/ptcw-design/{p-f5665cfe.entry.js → p-d8b2466d.entry.js} +1 -1
- package/dist/ptcw-design/{p-e880b556.entry.js → p-db0fc94d.entry.js} +1 -1
- package/dist/ptcw-design/p-e01173ca.entry.js +1 -0
- package/dist/ptcw-design/{p-7524411a.entry.js → p-e0d95058.entry.js} +1 -1
- package/dist/ptcw-design/p-e0e87d61.entry.js +1 -0
- package/dist/ptcw-design/{p-0bb3ea9a.entry.js → p-e235bf27.entry.js} +1 -1
- package/dist/ptcw-design/{p-53d2547b.entry.js → p-e3867512.entry.js} +1 -1
- package/dist/ptcw-design/{p-d1f57070.entry.js → p-e3bf092e.entry.js} +1 -1
- package/dist/ptcw-design/p-e4fe0995.entry.js +1 -0
- package/dist/ptcw-design/p-e7220c36.entry.js +1 -0
- package/dist/ptcw-design/{p-b1053240.entry.js → p-e73a1a0b.entry.js} +1 -1
- package/dist/ptcw-design/{p-b9966f20.entry.js → p-e9684da3.entry.js} +1 -1
- package/dist/ptcw-design/p-eb193fd7.entry.js +404 -0
- package/dist/ptcw-design/{p-fe56e336.entry.js → p-ee91170c.entry.js} +1 -1
- package/dist/ptcw-design/{p-681d26ef.entry.js → p-eeaa2123.entry.js} +1 -1
- package/dist/ptcw-design/{p-f2006b03.entry.js → p-f5c97ab2.entry.js} +1 -1
- package/dist/ptcw-design/{p-d6271974.entry.js → p-f5d8a3b1.entry.js} +1 -1
- package/dist/ptcw-design/{p-fab2fc8d.entry.js → p-fb835c5a.entry.js} +1 -1
- package/dist/ptcw-design/{p-0ed4609e.entry.js → p-fb8584e4.entry.js} +1 -1
- package/dist/ptcw-design/{p-973c69d8.entry.js → p-fbd9c8fc.entry.js} +1 -1
- package/dist/ptcw-design/p-fd7e5935.entry.js +1 -0
- package/dist/ptcw-design/{p-e6ebc832.entry.js → p-fdee2cdc.entry.js} +1 -1
- package/dist/ptcw-design/{p-22cf00e7.js → p-fe497e4a.js} +1 -1
- package/dist/ptcw-design/ptcw-design.esm.js +1 -1
- package/dist/types/components.d.ts +62 -62
- package/package.json +1 -1
- package/readme.md +1 -1
- package/dist/cjs/academic-form-test.cjs.entry.js +0 -82
- package/dist/cjs/component-06dda623.js +0 -4665
- package/dist/cjs/component-5b5b6a98.js +0 -1819
- package/dist/cjs/icon-asset_14.cjs.entry.js +0 -1982
- package/dist/cjs/ptc-data-lookup.cjs.entry.js +0 -675
- package/dist/cjs/ptc-form-checkbox_2.cjs.entry.js +0 -4476
- package/dist/cjs/ptc-multi-select_2.cjs.entry.js +0 -730
- package/dist/esm/academic-form-test.entry.js +0 -78
- package/dist/esm/component-274da230.js +0 -4663
- package/dist/esm/component-341e4eaa.js +0 -1802
- package/dist/esm/icon-asset_14.entry.js +0 -1965
- package/dist/esm/ptc-data-lookup.entry.js +0 -671
- package/dist/esm/ptc-form-checkbox_2.entry.js +0 -4471
- package/dist/esm/ptc-multi-select_2.entry.js +0 -725
- package/dist/ptcw-design/p-068b64a1.entry.js +0 -1
- package/dist/ptcw-design/p-0824f503.entry.js +0 -1
- package/dist/ptcw-design/p-0ec2a26d.entry.js +0 -1
- package/dist/ptcw-design/p-1b3394a7.entry.js +0 -1
- package/dist/ptcw-design/p-212cdacd.entry.js +0 -1
- package/dist/ptcw-design/p-2bc4bf65.entry.js +0 -1
- package/dist/ptcw-design/p-2f82de8f.entry.js +0 -1
- package/dist/ptcw-design/p-32bbcb5a.entry.js +0 -1
- package/dist/ptcw-design/p-39255f59.entry.js +0 -1
- package/dist/ptcw-design/p-47aa1583.entry.js +0 -1
- package/dist/ptcw-design/p-53e214a6.entry.js +0 -1
- package/dist/ptcw-design/p-5bbfd7b3.entry.js +0 -1
- package/dist/ptcw-design/p-7815e38b.entry.js +0 -1
- package/dist/ptcw-design/p-79a6e764.entry.js +0 -1
- package/dist/ptcw-design/p-7b89a8e1.entry.js +0 -1
- package/dist/ptcw-design/p-83c3d6c9.entry.js +0 -1
- package/dist/ptcw-design/p-87a9a028.entry.js +0 -1
- package/dist/ptcw-design/p-87e4c337.entry.js +0 -1
- package/dist/ptcw-design/p-89da867f.entry.js +0 -1
- package/dist/ptcw-design/p-9461c4eb.entry.js +0 -1
- package/dist/ptcw-design/p-973b06d1.entry.js +0 -1
- package/dist/ptcw-design/p-9d8a9a72.entry.js +0 -1
- package/dist/ptcw-design/p-bdb2e42c.entry.js +0 -1
- package/dist/ptcw-design/p-be533f0d.js +0 -134
- package/dist/ptcw-design/p-bf15988f.entry.js +0 -68
- package/dist/ptcw-design/p-c1513c3f.js +0 -203
- package/dist/ptcw-design/p-c33fd408.entry.js +0 -1
- package/dist/ptcw-design/p-c389eb7d.entry.js +0 -1
- package/dist/ptcw-design/p-d428ba40.entry.js +0 -1
- package/dist/ptcw-design/p-d8c1a14a.entry.js +0 -1
- package/dist/ptcw-design/p-e1373325.entry.js +0 -1
- package/dist/ptcw-design/p-e51bb274.entry.js +0 -1
- package/dist/ptcw-design/p-eabf87be.entry.js +0 -1
- package/dist/ptcw-design/p-edaf241d.entry.js +0 -1
- package/dist/ptcw-design/p-fef688c2.entry.js +0 -1
|
@@ -1,4663 +0,0 @@
|
|
|
1
|
-
import { _ as __extends, a as __assign, b as __read, c as __spreadArray, M as MDCFoundation, m as matches, d as closest, e as MDCComponent, f as __values, g as getCorrectPropertyName, h as MDCRipple, i as MDCRippleFoundation, j as MDCFloatingLabel, k as MDCLineRipple, l as MDCNotchedOutline } from './component-341e4eaa.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @license
|
|
5
|
-
* Copyright 2018 Google Inc.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in
|
|
15
|
-
* all copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
-
* THE SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
var cssClasses$4 = {
|
|
26
|
-
ANCHOR: 'mdc-menu-surface--anchor',
|
|
27
|
-
ANIMATING_CLOSED: 'mdc-menu-surface--animating-closed',
|
|
28
|
-
ANIMATING_OPEN: 'mdc-menu-surface--animating-open',
|
|
29
|
-
FIXED: 'mdc-menu-surface--fixed',
|
|
30
|
-
IS_OPEN_BELOW: 'mdc-menu-surface--is-open-below',
|
|
31
|
-
OPEN: 'mdc-menu-surface--open',
|
|
32
|
-
ROOT: 'mdc-menu-surface',
|
|
33
|
-
};
|
|
34
|
-
// tslint:disable:object-literal-sort-keys
|
|
35
|
-
var strings$5 = {
|
|
36
|
-
CLOSED_EVENT: 'MDCMenuSurface:closed',
|
|
37
|
-
CLOSING_EVENT: 'MDCMenuSurface:closing',
|
|
38
|
-
OPENED_EVENT: 'MDCMenuSurface:opened',
|
|
39
|
-
OPENING_EVENT: 'MDCMenuSurface:opening',
|
|
40
|
-
FOCUSABLE_ELEMENTS: [
|
|
41
|
-
'button:not(:disabled)',
|
|
42
|
-
'[href]:not([aria-disabled="true"])',
|
|
43
|
-
'input:not(:disabled)',
|
|
44
|
-
'select:not(:disabled)',
|
|
45
|
-
'textarea:not(:disabled)',
|
|
46
|
-
'[tabindex]:not([tabindex="-1"]):not([aria-disabled="true"])',
|
|
47
|
-
].join(', '),
|
|
48
|
-
};
|
|
49
|
-
// tslint:enable:object-literal-sort-keys
|
|
50
|
-
var numbers$3 = {
|
|
51
|
-
/** Total duration of menu-surface open animation. */
|
|
52
|
-
TRANSITION_OPEN_DURATION: 120,
|
|
53
|
-
/** Total duration of menu-surface close animation. */
|
|
54
|
-
TRANSITION_CLOSE_DURATION: 75,
|
|
55
|
-
/**
|
|
56
|
-
* Margin left to the edge of the viewport when menu-surface is at maximum
|
|
57
|
-
* possible height. Also used as a viewport margin.
|
|
58
|
-
*/
|
|
59
|
-
MARGIN_TO_EDGE: 32,
|
|
60
|
-
/**
|
|
61
|
-
* Ratio of anchor width to menu-surface width for switching from corner
|
|
62
|
-
* positioning to center positioning.
|
|
63
|
-
*/
|
|
64
|
-
ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO: 0.67,
|
|
65
|
-
/**
|
|
66
|
-
* Amount of time to wait before restoring focus when closing the menu
|
|
67
|
-
* surface. This is important because if a touch event triggered the menu
|
|
68
|
-
* close, and the subsequent mouse event occurs after focus is restored, then
|
|
69
|
-
* the restored focus would be lost.
|
|
70
|
-
*/
|
|
71
|
-
TOUCH_EVENT_WAIT_MS: 30,
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* Enum for bits in the {@see Corner) bitmap.
|
|
75
|
-
*/
|
|
76
|
-
var CornerBit;
|
|
77
|
-
(function (CornerBit) {
|
|
78
|
-
CornerBit[CornerBit["BOTTOM"] = 1] = "BOTTOM";
|
|
79
|
-
CornerBit[CornerBit["CENTER"] = 2] = "CENTER";
|
|
80
|
-
CornerBit[CornerBit["RIGHT"] = 4] = "RIGHT";
|
|
81
|
-
CornerBit[CornerBit["FLIP_RTL"] = 8] = "FLIP_RTL";
|
|
82
|
-
})(CornerBit || (CornerBit = {}));
|
|
83
|
-
/**
|
|
84
|
-
* Enum for representing an element corner for positioning the menu-surface.
|
|
85
|
-
*
|
|
86
|
-
* The START constants map to LEFT if element directionality is left
|
|
87
|
-
* to right and RIGHT if the directionality is right to left.
|
|
88
|
-
* Likewise END maps to RIGHT or LEFT depending on the directionality.
|
|
89
|
-
*/
|
|
90
|
-
var Corner;
|
|
91
|
-
(function (Corner) {
|
|
92
|
-
Corner[Corner["TOP_LEFT"] = 0] = "TOP_LEFT";
|
|
93
|
-
Corner[Corner["TOP_RIGHT"] = 4] = "TOP_RIGHT";
|
|
94
|
-
Corner[Corner["BOTTOM_LEFT"] = 1] = "BOTTOM_LEFT";
|
|
95
|
-
Corner[Corner["BOTTOM_RIGHT"] = 5] = "BOTTOM_RIGHT";
|
|
96
|
-
Corner[Corner["TOP_START"] = 8] = "TOP_START";
|
|
97
|
-
Corner[Corner["TOP_END"] = 12] = "TOP_END";
|
|
98
|
-
Corner[Corner["BOTTOM_START"] = 9] = "BOTTOM_START";
|
|
99
|
-
Corner[Corner["BOTTOM_END"] = 13] = "BOTTOM_END";
|
|
100
|
-
})(Corner || (Corner = {}));
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* @license
|
|
104
|
-
* Copyright 2018 Google Inc.
|
|
105
|
-
*
|
|
106
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
107
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
108
|
-
* in the Software without restriction, including without limitation the rights
|
|
109
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
110
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
111
|
-
* furnished to do so, subject to the following conditions:
|
|
112
|
-
*
|
|
113
|
-
* The above copyright notice and this permission notice shall be included in
|
|
114
|
-
* all copies or substantial portions of the Software.
|
|
115
|
-
*
|
|
116
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
117
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
118
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
119
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
120
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
121
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
122
|
-
* THE SOFTWARE.
|
|
123
|
-
*/
|
|
124
|
-
var _a, _b;
|
|
125
|
-
var cssClasses$3 = {
|
|
126
|
-
LIST_ITEM_ACTIVATED_CLASS: 'mdc-list-item--activated',
|
|
127
|
-
LIST_ITEM_CLASS: 'mdc-list-item',
|
|
128
|
-
LIST_ITEM_DISABLED_CLASS: 'mdc-list-item--disabled',
|
|
129
|
-
LIST_ITEM_SELECTED_CLASS: 'mdc-list-item--selected',
|
|
130
|
-
LIST_ITEM_TEXT_CLASS: 'mdc-list-item__text',
|
|
131
|
-
LIST_ITEM_PRIMARY_TEXT_CLASS: 'mdc-list-item__primary-text',
|
|
132
|
-
ROOT: 'mdc-list',
|
|
133
|
-
};
|
|
134
|
-
var evolutionClassNameMap = (_a = {},
|
|
135
|
-
_a["" + cssClasses$3.LIST_ITEM_ACTIVATED_CLASS] = 'mdc-list-item--activated',
|
|
136
|
-
_a["" + cssClasses$3.LIST_ITEM_CLASS] = 'mdc-list-item',
|
|
137
|
-
_a["" + cssClasses$3.LIST_ITEM_DISABLED_CLASS] = 'mdc-list-item--disabled',
|
|
138
|
-
_a["" + cssClasses$3.LIST_ITEM_SELECTED_CLASS] = 'mdc-list-item--selected',
|
|
139
|
-
_a["" + cssClasses$3.LIST_ITEM_PRIMARY_TEXT_CLASS] = 'mdc-list-item__primary-text',
|
|
140
|
-
_a["" + cssClasses$3.ROOT] = 'mdc-list',
|
|
141
|
-
_a);
|
|
142
|
-
var deprecatedClassNameMap = (_b = {},
|
|
143
|
-
_b["" + cssClasses$3.LIST_ITEM_ACTIVATED_CLASS] = 'mdc-deprecated-list-item--activated',
|
|
144
|
-
_b["" + cssClasses$3.LIST_ITEM_CLASS] = 'mdc-deprecated-list-item',
|
|
145
|
-
_b["" + cssClasses$3.LIST_ITEM_DISABLED_CLASS] = 'mdc-deprecated-list-item--disabled',
|
|
146
|
-
_b["" + cssClasses$3.LIST_ITEM_SELECTED_CLASS] = 'mdc-deprecated-list-item--selected',
|
|
147
|
-
_b["" + cssClasses$3.LIST_ITEM_TEXT_CLASS] = 'mdc-deprecated-list-item__text',
|
|
148
|
-
_b["" + cssClasses$3.LIST_ITEM_PRIMARY_TEXT_CLASS] = 'mdc-deprecated-list-item__primary-text',
|
|
149
|
-
_b["" + cssClasses$3.ROOT] = 'mdc-deprecated-list',
|
|
150
|
-
_b);
|
|
151
|
-
var strings$4 = {
|
|
152
|
-
ACTION_EVENT: 'MDCList:action',
|
|
153
|
-
SELECTION_CHANGE_EVENT: 'MDCList:selectionChange',
|
|
154
|
-
ARIA_CHECKED: 'aria-checked',
|
|
155
|
-
ARIA_CHECKED_CHECKBOX_SELECTOR: '[role="checkbox"][aria-checked="true"]',
|
|
156
|
-
ARIA_CHECKED_RADIO_SELECTOR: '[role="radio"][aria-checked="true"]',
|
|
157
|
-
ARIA_CURRENT: 'aria-current',
|
|
158
|
-
ARIA_DISABLED: 'aria-disabled',
|
|
159
|
-
ARIA_ORIENTATION: 'aria-orientation',
|
|
160
|
-
ARIA_ORIENTATION_HORIZONTAL: 'horizontal',
|
|
161
|
-
ARIA_ROLE_CHECKBOX_SELECTOR: '[role="checkbox"]',
|
|
162
|
-
ARIA_SELECTED: 'aria-selected',
|
|
163
|
-
ARIA_INTERACTIVE_ROLES_SELECTOR: '[role="listbox"], [role="menu"]',
|
|
164
|
-
ARIA_MULTI_SELECTABLE_SELECTOR: '[aria-multiselectable="true"]',
|
|
165
|
-
CHECKBOX_RADIO_SELECTOR: 'input[type="checkbox"], input[type="radio"]',
|
|
166
|
-
CHECKBOX_SELECTOR: 'input[type="checkbox"]',
|
|
167
|
-
CHILD_ELEMENTS_TO_TOGGLE_TABINDEX: "\n ." + cssClasses$3.LIST_ITEM_CLASS + " button:not(:disabled),\n ." + cssClasses$3.LIST_ITEM_CLASS + " a,\n ." + deprecatedClassNameMap[cssClasses$3.LIST_ITEM_CLASS] + " button:not(:disabled),\n ." + deprecatedClassNameMap[cssClasses$3.LIST_ITEM_CLASS] + " a\n ",
|
|
168
|
-
DEPRECATED_SELECTOR: '.mdc-deprecated-list',
|
|
169
|
-
FOCUSABLE_CHILD_ELEMENTS: "\n ." + cssClasses$3.LIST_ITEM_CLASS + " button:not(:disabled),\n ." + cssClasses$3.LIST_ITEM_CLASS + " a,\n ." + cssClasses$3.LIST_ITEM_CLASS + " input[type=\"radio\"]:not(:disabled),\n ." + cssClasses$3.LIST_ITEM_CLASS + " input[type=\"checkbox\"]:not(:disabled),\n ." + deprecatedClassNameMap[cssClasses$3.LIST_ITEM_CLASS] + " button:not(:disabled),\n ." + deprecatedClassNameMap[cssClasses$3.LIST_ITEM_CLASS] + " a,\n ." + deprecatedClassNameMap[cssClasses$3.LIST_ITEM_CLASS] + " input[type=\"radio\"]:not(:disabled),\n ." + deprecatedClassNameMap[cssClasses$3.LIST_ITEM_CLASS] + " input[type=\"checkbox\"]:not(:disabled)\n ",
|
|
170
|
-
RADIO_SELECTOR: 'input[type="radio"]',
|
|
171
|
-
SELECTED_ITEM_SELECTOR: '[aria-selected="true"], [aria-current="true"]',
|
|
172
|
-
};
|
|
173
|
-
var numbers$2 = {
|
|
174
|
-
UNSET_INDEX: -1,
|
|
175
|
-
TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS: 300
|
|
176
|
-
};
|
|
177
|
-
var evolutionAttribute = 'evolution';
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* @license
|
|
181
|
-
* Copyright 2020 Google Inc.
|
|
182
|
-
*
|
|
183
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
184
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
185
|
-
* in the Software without restriction, including without limitation the rights
|
|
186
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
187
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
188
|
-
* furnished to do so, subject to the following conditions:
|
|
189
|
-
*
|
|
190
|
-
* The above copyright notice and this permission notice shall be included in
|
|
191
|
-
* all copies or substantial portions of the Software.
|
|
192
|
-
*
|
|
193
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
194
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
195
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
196
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
197
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
198
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
199
|
-
* THE SOFTWARE.
|
|
200
|
-
*/
|
|
201
|
-
/**
|
|
202
|
-
* KEY provides normalized string values for keys.
|
|
203
|
-
*/
|
|
204
|
-
var KEY = {
|
|
205
|
-
UNKNOWN: 'Unknown',
|
|
206
|
-
BACKSPACE: 'Backspace',
|
|
207
|
-
ENTER: 'Enter',
|
|
208
|
-
SPACEBAR: 'Spacebar',
|
|
209
|
-
PAGE_UP: 'PageUp',
|
|
210
|
-
PAGE_DOWN: 'PageDown',
|
|
211
|
-
END: 'End',
|
|
212
|
-
HOME: 'Home',
|
|
213
|
-
ARROW_LEFT: 'ArrowLeft',
|
|
214
|
-
ARROW_UP: 'ArrowUp',
|
|
215
|
-
ARROW_RIGHT: 'ArrowRight',
|
|
216
|
-
ARROW_DOWN: 'ArrowDown',
|
|
217
|
-
DELETE: 'Delete',
|
|
218
|
-
ESCAPE: 'Escape',
|
|
219
|
-
TAB: 'Tab',
|
|
220
|
-
};
|
|
221
|
-
var normalizedKeys = new Set();
|
|
222
|
-
// IE11 has no support for new Map with iterable so we need to initialize this
|
|
223
|
-
// by hand.
|
|
224
|
-
normalizedKeys.add(KEY.BACKSPACE);
|
|
225
|
-
normalizedKeys.add(KEY.ENTER);
|
|
226
|
-
normalizedKeys.add(KEY.SPACEBAR);
|
|
227
|
-
normalizedKeys.add(KEY.PAGE_UP);
|
|
228
|
-
normalizedKeys.add(KEY.PAGE_DOWN);
|
|
229
|
-
normalizedKeys.add(KEY.END);
|
|
230
|
-
normalizedKeys.add(KEY.HOME);
|
|
231
|
-
normalizedKeys.add(KEY.ARROW_LEFT);
|
|
232
|
-
normalizedKeys.add(KEY.ARROW_UP);
|
|
233
|
-
normalizedKeys.add(KEY.ARROW_RIGHT);
|
|
234
|
-
normalizedKeys.add(KEY.ARROW_DOWN);
|
|
235
|
-
normalizedKeys.add(KEY.DELETE);
|
|
236
|
-
normalizedKeys.add(KEY.ESCAPE);
|
|
237
|
-
normalizedKeys.add(KEY.TAB);
|
|
238
|
-
var KEY_CODE = {
|
|
239
|
-
BACKSPACE: 8,
|
|
240
|
-
ENTER: 13,
|
|
241
|
-
SPACEBAR: 32,
|
|
242
|
-
PAGE_UP: 33,
|
|
243
|
-
PAGE_DOWN: 34,
|
|
244
|
-
END: 35,
|
|
245
|
-
HOME: 36,
|
|
246
|
-
ARROW_LEFT: 37,
|
|
247
|
-
ARROW_UP: 38,
|
|
248
|
-
ARROW_RIGHT: 39,
|
|
249
|
-
ARROW_DOWN: 40,
|
|
250
|
-
DELETE: 46,
|
|
251
|
-
ESCAPE: 27,
|
|
252
|
-
TAB: 9,
|
|
253
|
-
};
|
|
254
|
-
var mappedKeyCodes = new Map();
|
|
255
|
-
// IE11 has no support for new Map with iterable so we need to initialize this
|
|
256
|
-
// by hand.
|
|
257
|
-
mappedKeyCodes.set(KEY_CODE.BACKSPACE, KEY.BACKSPACE);
|
|
258
|
-
mappedKeyCodes.set(KEY_CODE.ENTER, KEY.ENTER);
|
|
259
|
-
mappedKeyCodes.set(KEY_CODE.SPACEBAR, KEY.SPACEBAR);
|
|
260
|
-
mappedKeyCodes.set(KEY_CODE.PAGE_UP, KEY.PAGE_UP);
|
|
261
|
-
mappedKeyCodes.set(KEY_CODE.PAGE_DOWN, KEY.PAGE_DOWN);
|
|
262
|
-
mappedKeyCodes.set(KEY_CODE.END, KEY.END);
|
|
263
|
-
mappedKeyCodes.set(KEY_CODE.HOME, KEY.HOME);
|
|
264
|
-
mappedKeyCodes.set(KEY_CODE.ARROW_LEFT, KEY.ARROW_LEFT);
|
|
265
|
-
mappedKeyCodes.set(KEY_CODE.ARROW_UP, KEY.ARROW_UP);
|
|
266
|
-
mappedKeyCodes.set(KEY_CODE.ARROW_RIGHT, KEY.ARROW_RIGHT);
|
|
267
|
-
mappedKeyCodes.set(KEY_CODE.ARROW_DOWN, KEY.ARROW_DOWN);
|
|
268
|
-
mappedKeyCodes.set(KEY_CODE.DELETE, KEY.DELETE);
|
|
269
|
-
mappedKeyCodes.set(KEY_CODE.ESCAPE, KEY.ESCAPE);
|
|
270
|
-
mappedKeyCodes.set(KEY_CODE.TAB, KEY.TAB);
|
|
271
|
-
var navigationKeys = new Set();
|
|
272
|
-
// IE11 has no support for new Set with iterable so we need to initialize this
|
|
273
|
-
// by hand.
|
|
274
|
-
navigationKeys.add(KEY.PAGE_UP);
|
|
275
|
-
navigationKeys.add(KEY.PAGE_DOWN);
|
|
276
|
-
navigationKeys.add(KEY.END);
|
|
277
|
-
navigationKeys.add(KEY.HOME);
|
|
278
|
-
navigationKeys.add(KEY.ARROW_LEFT);
|
|
279
|
-
navigationKeys.add(KEY.ARROW_UP);
|
|
280
|
-
navigationKeys.add(KEY.ARROW_RIGHT);
|
|
281
|
-
navigationKeys.add(KEY.ARROW_DOWN);
|
|
282
|
-
/**
|
|
283
|
-
* normalizeKey returns the normalized string for a navigational action.
|
|
284
|
-
*/
|
|
285
|
-
function normalizeKey(evt) {
|
|
286
|
-
var key = evt.key;
|
|
287
|
-
// If the event already has a normalized key, return it
|
|
288
|
-
if (normalizedKeys.has(key)) {
|
|
289
|
-
return key;
|
|
290
|
-
}
|
|
291
|
-
// tslint:disable-next-line:deprecation
|
|
292
|
-
var mappedKey = mappedKeyCodes.get(evt.keyCode);
|
|
293
|
-
if (mappedKey) {
|
|
294
|
-
return mappedKey;
|
|
295
|
-
}
|
|
296
|
-
return KEY.UNKNOWN;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* @license
|
|
301
|
-
* Copyright 2020 Google Inc.
|
|
302
|
-
*
|
|
303
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
304
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
305
|
-
* in the Software without restriction, including without limitation the rights
|
|
306
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
307
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
308
|
-
* furnished to do so, subject to the following conditions:
|
|
309
|
-
*
|
|
310
|
-
* The above copyright notice and this permission notice shall be included in
|
|
311
|
-
* all copies or substantial portions of the Software.
|
|
312
|
-
*
|
|
313
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
314
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
315
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
316
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
317
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
318
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
319
|
-
* THE SOFTWARE.
|
|
320
|
-
*/
|
|
321
|
-
var ELEMENTS_KEY_ALLOWED_IN = ['input', 'button', 'textarea', 'select'];
|
|
322
|
-
/**
|
|
323
|
-
* Ensures that preventDefault is only called if the containing element
|
|
324
|
-
* doesn't consume the event, and it will cause an unintended scroll.
|
|
325
|
-
*
|
|
326
|
-
* @param evt keyboard event to be prevented.
|
|
327
|
-
*/
|
|
328
|
-
var preventDefaultEvent = function (evt) {
|
|
329
|
-
var target = evt.target;
|
|
330
|
-
if (!target) {
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
var tagName = ("" + target.tagName).toLowerCase();
|
|
334
|
-
if (ELEMENTS_KEY_ALLOWED_IN.indexOf(tagName) === -1) {
|
|
335
|
-
evt.preventDefault();
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* @license
|
|
341
|
-
* Copyright 2020 Google Inc.
|
|
342
|
-
*
|
|
343
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
344
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
345
|
-
* in the Software without restriction, including without limitation the rights
|
|
346
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
347
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
348
|
-
* furnished to do so, subject to the following conditions:
|
|
349
|
-
*
|
|
350
|
-
* The above copyright notice and this permission notice shall be included in
|
|
351
|
-
* all copies or substantial portions of the Software.
|
|
352
|
-
*
|
|
353
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
354
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
355
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
356
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
357
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
358
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
359
|
-
* THE SOFTWARE.
|
|
360
|
-
*/
|
|
361
|
-
/**
|
|
362
|
-
* Initializes a state object for typeahead. Use the same reference for calls to
|
|
363
|
-
* typeahead functions.
|
|
364
|
-
*
|
|
365
|
-
* @return The current state of the typeahead process. Each state reference
|
|
366
|
-
* represents a typeahead instance as the reference is typically mutated
|
|
367
|
-
* in-place.
|
|
368
|
-
*/
|
|
369
|
-
function initState() {
|
|
370
|
-
var state = {
|
|
371
|
-
bufferClearTimeout: 0,
|
|
372
|
-
currentFirstChar: '',
|
|
373
|
-
sortedIndexCursor: 0,
|
|
374
|
-
typeaheadBuffer: '',
|
|
375
|
-
};
|
|
376
|
-
return state;
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* Initializes typeahead state by indexing the current list items by primary
|
|
380
|
-
* text into the sortedIndexByFirstChar data structure.
|
|
381
|
-
*
|
|
382
|
-
* @param listItemCount numer of items in the list
|
|
383
|
-
* @param getPrimaryTextByItemIndex function that returns the primary text at a
|
|
384
|
-
* given index
|
|
385
|
-
*
|
|
386
|
-
* @return Map that maps the first character of the primary text to the full
|
|
387
|
-
* list text and it's index
|
|
388
|
-
*/
|
|
389
|
-
function initSortedIndex(listItemCount, getPrimaryTextByItemIndex) {
|
|
390
|
-
var sortedIndexByFirstChar = new Map();
|
|
391
|
-
// Aggregate item text to index mapping
|
|
392
|
-
for (var i = 0; i < listItemCount; i++) {
|
|
393
|
-
var primaryText = getPrimaryTextByItemIndex(i).trim();
|
|
394
|
-
if (!primaryText) {
|
|
395
|
-
continue;
|
|
396
|
-
}
|
|
397
|
-
var firstChar = primaryText[0].toLowerCase();
|
|
398
|
-
if (!sortedIndexByFirstChar.has(firstChar)) {
|
|
399
|
-
sortedIndexByFirstChar.set(firstChar, []);
|
|
400
|
-
}
|
|
401
|
-
sortedIndexByFirstChar.get(firstChar).push({ text: primaryText.toLowerCase(), index: i });
|
|
402
|
-
}
|
|
403
|
-
// Sort the mapping
|
|
404
|
-
// TODO(b/157162694): Investigate replacing forEach with Map.values()
|
|
405
|
-
sortedIndexByFirstChar.forEach(function (values) {
|
|
406
|
-
values.sort(function (first, second) {
|
|
407
|
-
return first.index - second.index;
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
return sortedIndexByFirstChar;
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* Given the next desired character from the user, it attempts to find the next
|
|
414
|
-
* list option matching the buffer. Wraps around if at the end of options.
|
|
415
|
-
*
|
|
416
|
-
* @param opts Options and accessors
|
|
417
|
-
* - nextChar - the next character to match against items
|
|
418
|
-
* - sortedIndexByFirstChar - output of `initSortedIndex(...)`
|
|
419
|
-
* - focusedItemIndex - the index of the currently focused item
|
|
420
|
-
* - focusItemAtIndex - function that focuses a list item at given index
|
|
421
|
-
* - skipFocus - whether or not to focus the matched item
|
|
422
|
-
* - isItemAtIndexDisabled - function that determines whether an item at a
|
|
423
|
-
* given index is disabled
|
|
424
|
-
* @param state The typeahead state instance. See `initState`.
|
|
425
|
-
*
|
|
426
|
-
* @return The index of the matched item, or -1 if no match.
|
|
427
|
-
*/
|
|
428
|
-
function matchItem(opts, state) {
|
|
429
|
-
var nextChar = opts.nextChar, focusItemAtIndex = opts.focusItemAtIndex, sortedIndexByFirstChar = opts.sortedIndexByFirstChar, focusedItemIndex = opts.focusedItemIndex, skipFocus = opts.skipFocus, isItemAtIndexDisabled = opts.isItemAtIndexDisabled;
|
|
430
|
-
clearTimeout(state.bufferClearTimeout);
|
|
431
|
-
state.bufferClearTimeout = setTimeout(function () {
|
|
432
|
-
clearBuffer(state);
|
|
433
|
-
}, numbers$2.TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS);
|
|
434
|
-
state.typeaheadBuffer = state.typeaheadBuffer + nextChar;
|
|
435
|
-
var index;
|
|
436
|
-
if (state.typeaheadBuffer.length === 1) {
|
|
437
|
-
index = matchFirstChar(sortedIndexByFirstChar, focusedItemIndex, isItemAtIndexDisabled, state);
|
|
438
|
-
}
|
|
439
|
-
else {
|
|
440
|
-
index = matchAllChars(sortedIndexByFirstChar, isItemAtIndexDisabled, state);
|
|
441
|
-
}
|
|
442
|
-
if (index !== -1 && !skipFocus) {
|
|
443
|
-
focusItemAtIndex(index);
|
|
444
|
-
}
|
|
445
|
-
return index;
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* Matches the user's single input character in the buffer to the
|
|
449
|
-
* next option that begins with such character. Wraps around if at
|
|
450
|
-
* end of options. Returns -1 if no match is found.
|
|
451
|
-
*/
|
|
452
|
-
function matchFirstChar(sortedIndexByFirstChar, focusedItemIndex, isItemAtIndexDisabled, state) {
|
|
453
|
-
var firstChar = state.typeaheadBuffer[0];
|
|
454
|
-
var itemsMatchingFirstChar = sortedIndexByFirstChar.get(firstChar);
|
|
455
|
-
if (!itemsMatchingFirstChar) {
|
|
456
|
-
return -1;
|
|
457
|
-
}
|
|
458
|
-
// Has the same firstChar been recently matched?
|
|
459
|
-
// Also, did starting index remain the same between key presses?
|
|
460
|
-
// If both hold true, simply increment index.
|
|
461
|
-
if (firstChar === state.currentFirstChar &&
|
|
462
|
-
itemsMatchingFirstChar[state.sortedIndexCursor].index ===
|
|
463
|
-
focusedItemIndex) {
|
|
464
|
-
state.sortedIndexCursor =
|
|
465
|
-
(state.sortedIndexCursor + 1) % itemsMatchingFirstChar.length;
|
|
466
|
-
var newIndex = itemsMatchingFirstChar[state.sortedIndexCursor].index;
|
|
467
|
-
if (!isItemAtIndexDisabled(newIndex)) {
|
|
468
|
-
return newIndex;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
// If we're here, it means one of the following happened:
|
|
472
|
-
// - either firstChar or startingIndex has changed, invalidating the
|
|
473
|
-
// cursor.
|
|
474
|
-
// - The next item of typeahead is disabled, so we have to look further.
|
|
475
|
-
state.currentFirstChar = firstChar;
|
|
476
|
-
var newCursorPosition = -1;
|
|
477
|
-
var cursorPosition;
|
|
478
|
-
// Find the first non-disabled item as a fallback.
|
|
479
|
-
for (cursorPosition = 0; cursorPosition < itemsMatchingFirstChar.length; cursorPosition++) {
|
|
480
|
-
if (!isItemAtIndexDisabled(itemsMatchingFirstChar[cursorPosition].index)) {
|
|
481
|
-
newCursorPosition = cursorPosition;
|
|
482
|
-
break;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
// Advance cursor to first item matching the firstChar that is positioned
|
|
486
|
-
// after starting item. Cursor is unchanged from fallback if there's no
|
|
487
|
-
// such item.
|
|
488
|
-
for (; cursorPosition < itemsMatchingFirstChar.length; cursorPosition++) {
|
|
489
|
-
if (itemsMatchingFirstChar[cursorPosition].index > focusedItemIndex &&
|
|
490
|
-
!isItemAtIndexDisabled(itemsMatchingFirstChar[cursorPosition].index)) {
|
|
491
|
-
newCursorPosition = cursorPosition;
|
|
492
|
-
break;
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
if (newCursorPosition !== -1) {
|
|
496
|
-
state.sortedIndexCursor = newCursorPosition;
|
|
497
|
-
return itemsMatchingFirstChar[state.sortedIndexCursor].index;
|
|
498
|
-
}
|
|
499
|
-
return -1;
|
|
500
|
-
}
|
|
501
|
-
/**
|
|
502
|
-
* Attempts to find the next item that matches all of the typeahead buffer.
|
|
503
|
-
* Wraps around if at end of options. Returns -1 if no match is found.
|
|
504
|
-
*/
|
|
505
|
-
function matchAllChars(sortedIndexByFirstChar, isItemAtIndexDisabled, state) {
|
|
506
|
-
var firstChar = state.typeaheadBuffer[0];
|
|
507
|
-
var itemsMatchingFirstChar = sortedIndexByFirstChar.get(firstChar);
|
|
508
|
-
if (!itemsMatchingFirstChar) {
|
|
509
|
-
return -1;
|
|
510
|
-
}
|
|
511
|
-
// Do nothing if text already matches
|
|
512
|
-
var startingItem = itemsMatchingFirstChar[state.sortedIndexCursor];
|
|
513
|
-
if (startingItem.text.lastIndexOf(state.typeaheadBuffer, 0) === 0 &&
|
|
514
|
-
!isItemAtIndexDisabled(startingItem.index)) {
|
|
515
|
-
return startingItem.index;
|
|
516
|
-
}
|
|
517
|
-
// Find next item that matches completely; if no match, we'll eventually
|
|
518
|
-
// loop around to same position
|
|
519
|
-
var cursorPosition = (state.sortedIndexCursor + 1) % itemsMatchingFirstChar.length;
|
|
520
|
-
var nextCursorPosition = -1;
|
|
521
|
-
while (cursorPosition !== state.sortedIndexCursor) {
|
|
522
|
-
var currentItem = itemsMatchingFirstChar[cursorPosition];
|
|
523
|
-
var matches = currentItem.text.lastIndexOf(state.typeaheadBuffer, 0) === 0;
|
|
524
|
-
var isEnabled = !isItemAtIndexDisabled(currentItem.index);
|
|
525
|
-
if (matches && isEnabled) {
|
|
526
|
-
nextCursorPosition = cursorPosition;
|
|
527
|
-
break;
|
|
528
|
-
}
|
|
529
|
-
cursorPosition = (cursorPosition + 1) % itemsMatchingFirstChar.length;
|
|
530
|
-
}
|
|
531
|
-
if (nextCursorPosition !== -1) {
|
|
532
|
-
state.sortedIndexCursor = nextCursorPosition;
|
|
533
|
-
return itemsMatchingFirstChar[state.sortedIndexCursor].index;
|
|
534
|
-
}
|
|
535
|
-
return -1;
|
|
536
|
-
}
|
|
537
|
-
/**
|
|
538
|
-
* Whether or not the given typeahead instaance state is currently typing.
|
|
539
|
-
*
|
|
540
|
-
* @param state The typeahead state instance. See `initState`.
|
|
541
|
-
*/
|
|
542
|
-
function isTypingInProgress(state) {
|
|
543
|
-
return state.typeaheadBuffer.length > 0;
|
|
544
|
-
}
|
|
545
|
-
/**
|
|
546
|
-
* Clears the typeahaed buffer so that it resets item matching to the first
|
|
547
|
-
* character.
|
|
548
|
-
*
|
|
549
|
-
* @param state The typeahead state instance. See `initState`.
|
|
550
|
-
*/
|
|
551
|
-
function clearBuffer(state) {
|
|
552
|
-
state.typeaheadBuffer = '';
|
|
553
|
-
}
|
|
554
|
-
/**
|
|
555
|
-
* Given a keydown event, it calculates whether or not to automatically focus a
|
|
556
|
-
* list item depending on what was typed mimicing the typeahead functionality of
|
|
557
|
-
* a standard <select> element that is open.
|
|
558
|
-
*
|
|
559
|
-
* @param opts Options and accessors
|
|
560
|
-
* - event - the KeyboardEvent to handle and parse
|
|
561
|
-
* - sortedIndexByFirstChar - output of `initSortedIndex(...)`
|
|
562
|
-
* - focusedItemIndex - the index of the currently focused item
|
|
563
|
-
* - focusItemAtIndex - function that focuses a list item at given index
|
|
564
|
-
* - isItemAtFocusedIndexDisabled - whether or not the currently focused item
|
|
565
|
-
* is disabled
|
|
566
|
-
* - isTargetListItem - whether or not the event target is a list item
|
|
567
|
-
* @param state The typeahead state instance. See `initState`.
|
|
568
|
-
*
|
|
569
|
-
* @returns index of the item matched by the keydown. -1 if not matched.
|
|
570
|
-
*/
|
|
571
|
-
function handleKeydown(opts, state) {
|
|
572
|
-
var event = opts.event, isTargetListItem = opts.isTargetListItem, focusedItemIndex = opts.focusedItemIndex, focusItemAtIndex = opts.focusItemAtIndex, sortedIndexByFirstChar = opts.sortedIndexByFirstChar, isItemAtIndexDisabled = opts.isItemAtIndexDisabled;
|
|
573
|
-
var isArrowLeft = normalizeKey(event) === 'ArrowLeft';
|
|
574
|
-
var isArrowUp = normalizeKey(event) === 'ArrowUp';
|
|
575
|
-
var isArrowRight = normalizeKey(event) === 'ArrowRight';
|
|
576
|
-
var isArrowDown = normalizeKey(event) === 'ArrowDown';
|
|
577
|
-
var isHome = normalizeKey(event) === 'Home';
|
|
578
|
-
var isEnd = normalizeKey(event) === 'End';
|
|
579
|
-
var isEnter = normalizeKey(event) === 'Enter';
|
|
580
|
-
var isSpace = normalizeKey(event) === 'Spacebar';
|
|
581
|
-
if (event.altKey || event.ctrlKey || event.metaKey || isArrowLeft ||
|
|
582
|
-
isArrowUp || isArrowRight || isArrowDown || isHome || isEnd || isEnter) {
|
|
583
|
-
return -1;
|
|
584
|
-
}
|
|
585
|
-
var isCharacterKey = !isSpace && event.key.length === 1;
|
|
586
|
-
if (isCharacterKey) {
|
|
587
|
-
preventDefaultEvent(event);
|
|
588
|
-
var matchItemOpts = {
|
|
589
|
-
focusItemAtIndex: focusItemAtIndex,
|
|
590
|
-
focusedItemIndex: focusedItemIndex,
|
|
591
|
-
nextChar: event.key.toLowerCase(),
|
|
592
|
-
sortedIndexByFirstChar: sortedIndexByFirstChar,
|
|
593
|
-
skipFocus: false,
|
|
594
|
-
isItemAtIndexDisabled: isItemAtIndexDisabled,
|
|
595
|
-
};
|
|
596
|
-
return matchItem(matchItemOpts, state);
|
|
597
|
-
}
|
|
598
|
-
if (!isSpace) {
|
|
599
|
-
return -1;
|
|
600
|
-
}
|
|
601
|
-
if (isTargetListItem) {
|
|
602
|
-
preventDefaultEvent(event);
|
|
603
|
-
}
|
|
604
|
-
var typeaheadOnListItem = isTargetListItem && isTypingInProgress(state);
|
|
605
|
-
if (typeaheadOnListItem) {
|
|
606
|
-
var matchItemOpts = {
|
|
607
|
-
focusItemAtIndex: focusItemAtIndex,
|
|
608
|
-
focusedItemIndex: focusedItemIndex,
|
|
609
|
-
nextChar: ' ',
|
|
610
|
-
sortedIndexByFirstChar: sortedIndexByFirstChar,
|
|
611
|
-
skipFocus: false,
|
|
612
|
-
isItemAtIndexDisabled: isItemAtIndexDisabled,
|
|
613
|
-
};
|
|
614
|
-
// space participates in typeahead matching if in rapid typing mode
|
|
615
|
-
return matchItem(matchItemOpts, state);
|
|
616
|
-
}
|
|
617
|
-
return -1;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
/**
|
|
621
|
-
* @license
|
|
622
|
-
* Copyright 2018 Google Inc.
|
|
623
|
-
*
|
|
624
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
625
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
626
|
-
* in the Software without restriction, including without limitation the rights
|
|
627
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
628
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
629
|
-
* furnished to do so, subject to the following conditions:
|
|
630
|
-
*
|
|
631
|
-
* The above copyright notice and this permission notice shall be included in
|
|
632
|
-
* all copies or substantial portions of the Software.
|
|
633
|
-
*
|
|
634
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
635
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
636
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
637
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
638
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
639
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
640
|
-
* THE SOFTWARE.
|
|
641
|
-
*/
|
|
642
|
-
function isNumberArray(selectedIndex) {
|
|
643
|
-
return selectedIndex instanceof Array;
|
|
644
|
-
}
|
|
645
|
-
/** List of modifier keys to consider while handling keyboard events. */
|
|
646
|
-
var handledModifierKeys = ['Alt', 'Control', 'Meta', 'Shift'];
|
|
647
|
-
/** Checks if the event has the given modifier keys. */
|
|
648
|
-
function createModifierChecker(event) {
|
|
649
|
-
var eventModifiers = new Set(event ? handledModifierKeys.filter(function (m) { return event.getModifierState(m); }) : []);
|
|
650
|
-
return function (modifiers) {
|
|
651
|
-
return modifiers.every(function (m) { return eventModifiers.has(m); }) &&
|
|
652
|
-
modifiers.length === eventModifiers.size;
|
|
653
|
-
};
|
|
654
|
-
}
|
|
655
|
-
var MDCListFoundation = /** @class */ (function (_super) {
|
|
656
|
-
__extends(MDCListFoundation, _super);
|
|
657
|
-
function MDCListFoundation(adapter) {
|
|
658
|
-
var _this = _super.call(this, __assign(__assign({}, MDCListFoundation.defaultAdapter), adapter)) || this;
|
|
659
|
-
_this.wrapFocus = false;
|
|
660
|
-
_this.isVertical = true;
|
|
661
|
-
_this.isSingleSelectionList = false;
|
|
662
|
-
_this.areDisabledItemsFocusable = true;
|
|
663
|
-
_this.selectedIndex = numbers$2.UNSET_INDEX;
|
|
664
|
-
_this.focusedItemIndex = numbers$2.UNSET_INDEX;
|
|
665
|
-
_this.useActivatedClass = false;
|
|
666
|
-
_this.useSelectedAttr = false;
|
|
667
|
-
_this.ariaCurrentAttrValue = null;
|
|
668
|
-
_this.isCheckboxList = false;
|
|
669
|
-
_this.isRadioList = false;
|
|
670
|
-
_this.lastSelectedIndex = null;
|
|
671
|
-
_this.hasTypeahead = false;
|
|
672
|
-
// Transiently holds current typeahead prefix from user.
|
|
673
|
-
_this.typeaheadState = initState();
|
|
674
|
-
_this.sortedIndexByFirstChar = new Map();
|
|
675
|
-
return _this;
|
|
676
|
-
}
|
|
677
|
-
Object.defineProperty(MDCListFoundation, "strings", {
|
|
678
|
-
get: function () {
|
|
679
|
-
return strings$4;
|
|
680
|
-
},
|
|
681
|
-
enumerable: false,
|
|
682
|
-
configurable: true
|
|
683
|
-
});
|
|
684
|
-
Object.defineProperty(MDCListFoundation, "cssClasses", {
|
|
685
|
-
get: function () {
|
|
686
|
-
return cssClasses$3;
|
|
687
|
-
},
|
|
688
|
-
enumerable: false,
|
|
689
|
-
configurable: true
|
|
690
|
-
});
|
|
691
|
-
Object.defineProperty(MDCListFoundation, "numbers", {
|
|
692
|
-
get: function () {
|
|
693
|
-
return numbers$2;
|
|
694
|
-
},
|
|
695
|
-
enumerable: false,
|
|
696
|
-
configurable: true
|
|
697
|
-
});
|
|
698
|
-
Object.defineProperty(MDCListFoundation, "defaultAdapter", {
|
|
699
|
-
get: function () {
|
|
700
|
-
return {
|
|
701
|
-
addClassForElementIndex: function () { return undefined; },
|
|
702
|
-
focusItemAtIndex: function () { return undefined; },
|
|
703
|
-
getAttributeForElementIndex: function () { return null; },
|
|
704
|
-
getFocusedElementIndex: function () { return 0; },
|
|
705
|
-
getListItemCount: function () { return 0; },
|
|
706
|
-
hasCheckboxAtIndex: function () { return false; },
|
|
707
|
-
hasRadioAtIndex: function () { return false; },
|
|
708
|
-
isCheckboxCheckedAtIndex: function () { return false; },
|
|
709
|
-
isFocusInsideList: function () { return false; },
|
|
710
|
-
isRootFocused: function () { return false; },
|
|
711
|
-
listItemAtIndexHasClass: function () { return false; },
|
|
712
|
-
notifyAction: function () { return undefined; },
|
|
713
|
-
notifySelectionChange: function () { },
|
|
714
|
-
removeClassForElementIndex: function () { return undefined; },
|
|
715
|
-
setAttributeForElementIndex: function () { return undefined; },
|
|
716
|
-
setCheckedCheckboxOrRadioAtIndex: function () { return undefined; },
|
|
717
|
-
setTabIndexForListItemChildren: function () { return undefined; },
|
|
718
|
-
getPrimaryTextAtIndex: function () { return ''; },
|
|
719
|
-
};
|
|
720
|
-
},
|
|
721
|
-
enumerable: false,
|
|
722
|
-
configurable: true
|
|
723
|
-
});
|
|
724
|
-
MDCListFoundation.prototype.layout = function () {
|
|
725
|
-
if (this.adapter.getListItemCount() === 0) {
|
|
726
|
-
return;
|
|
727
|
-
}
|
|
728
|
-
// TODO(b/172274142): consider all items when determining the list's type.
|
|
729
|
-
if (this.adapter.hasCheckboxAtIndex(0)) {
|
|
730
|
-
this.isCheckboxList = true;
|
|
731
|
-
}
|
|
732
|
-
else if (this.adapter.hasRadioAtIndex(0)) {
|
|
733
|
-
this.isRadioList = true;
|
|
734
|
-
}
|
|
735
|
-
else {
|
|
736
|
-
this.maybeInitializeSingleSelection();
|
|
737
|
-
}
|
|
738
|
-
if (this.hasTypeahead) {
|
|
739
|
-
this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex();
|
|
740
|
-
}
|
|
741
|
-
};
|
|
742
|
-
/** Returns the index of the item that was last focused. */
|
|
743
|
-
MDCListFoundation.prototype.getFocusedItemIndex = function () {
|
|
744
|
-
return this.focusedItemIndex;
|
|
745
|
-
};
|
|
746
|
-
/** Toggles focus wrapping with keyboard navigation. */
|
|
747
|
-
MDCListFoundation.prototype.setWrapFocus = function (value) {
|
|
748
|
-
this.wrapFocus = value;
|
|
749
|
-
};
|
|
750
|
-
/**
|
|
751
|
-
* Toggles orientation direction for keyboard navigation (true for vertical,
|
|
752
|
-
* false for horizontal).
|
|
753
|
-
*/
|
|
754
|
-
MDCListFoundation.prototype.setVerticalOrientation = function (value) {
|
|
755
|
-
this.isVertical = value;
|
|
756
|
-
};
|
|
757
|
-
/** Toggles single-selection behavior. */
|
|
758
|
-
MDCListFoundation.prototype.setSingleSelection = function (value) {
|
|
759
|
-
this.isSingleSelectionList = value;
|
|
760
|
-
if (value) {
|
|
761
|
-
this.maybeInitializeSingleSelection();
|
|
762
|
-
this.selectedIndex = this.getSelectedIndexFromDOM();
|
|
763
|
-
}
|
|
764
|
-
};
|
|
765
|
-
MDCListFoundation.prototype.setDisabledItemsFocusable = function (value) {
|
|
766
|
-
this.areDisabledItemsFocusable = value;
|
|
767
|
-
};
|
|
768
|
-
/**
|
|
769
|
-
* Automatically determines whether the list is single selection list. If so,
|
|
770
|
-
* initializes the internal state to match the selected item.
|
|
771
|
-
*/
|
|
772
|
-
MDCListFoundation.prototype.maybeInitializeSingleSelection = function () {
|
|
773
|
-
var selectedItemIndex = this.getSelectedIndexFromDOM();
|
|
774
|
-
if (selectedItemIndex === numbers$2.UNSET_INDEX)
|
|
775
|
-
return;
|
|
776
|
-
var hasActivatedClass = this.adapter.listItemAtIndexHasClass(selectedItemIndex, cssClasses$3.LIST_ITEM_ACTIVATED_CLASS);
|
|
777
|
-
if (hasActivatedClass) {
|
|
778
|
-
this.setUseActivatedClass(true);
|
|
779
|
-
}
|
|
780
|
-
this.isSingleSelectionList = true;
|
|
781
|
-
this.selectedIndex = selectedItemIndex;
|
|
782
|
-
};
|
|
783
|
-
/** @return Index of the first selected item based on the DOM state. */
|
|
784
|
-
MDCListFoundation.prototype.getSelectedIndexFromDOM = function () {
|
|
785
|
-
var selectedIndex = numbers$2.UNSET_INDEX;
|
|
786
|
-
var listItemsCount = this.adapter.getListItemCount();
|
|
787
|
-
for (var i = 0; i < listItemsCount; i++) {
|
|
788
|
-
var hasSelectedClass = this.adapter.listItemAtIndexHasClass(i, cssClasses$3.LIST_ITEM_SELECTED_CLASS);
|
|
789
|
-
var hasActivatedClass = this.adapter.listItemAtIndexHasClass(i, cssClasses$3.LIST_ITEM_ACTIVATED_CLASS);
|
|
790
|
-
if (!(hasSelectedClass || hasActivatedClass)) {
|
|
791
|
-
continue;
|
|
792
|
-
}
|
|
793
|
-
selectedIndex = i;
|
|
794
|
-
break;
|
|
795
|
-
}
|
|
796
|
-
return selectedIndex;
|
|
797
|
-
};
|
|
798
|
-
/**
|
|
799
|
-
* Sets whether typeahead is enabled on the list.
|
|
800
|
-
* @param hasTypeahead Whether typeahead is enabled.
|
|
801
|
-
*/
|
|
802
|
-
MDCListFoundation.prototype.setHasTypeahead = function (hasTypeahead) {
|
|
803
|
-
this.hasTypeahead = hasTypeahead;
|
|
804
|
-
if (hasTypeahead) {
|
|
805
|
-
this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex();
|
|
806
|
-
}
|
|
807
|
-
};
|
|
808
|
-
/**
|
|
809
|
-
* @return Whether typeahead is currently matching a user-specified prefix.
|
|
810
|
-
*/
|
|
811
|
-
MDCListFoundation.prototype.isTypeaheadInProgress = function () {
|
|
812
|
-
return this.hasTypeahead &&
|
|
813
|
-
isTypingInProgress(this.typeaheadState);
|
|
814
|
-
};
|
|
815
|
-
/** Toggle use of the "activated" CSS class. */
|
|
816
|
-
MDCListFoundation.prototype.setUseActivatedClass = function (useActivated) {
|
|
817
|
-
this.useActivatedClass = useActivated;
|
|
818
|
-
};
|
|
819
|
-
/**
|
|
820
|
-
* Toggles use of the selected attribute (true for aria-selected, false for
|
|
821
|
-
* aria-checked).
|
|
822
|
-
*/
|
|
823
|
-
MDCListFoundation.prototype.setUseSelectedAttribute = function (useSelected) {
|
|
824
|
-
this.useSelectedAttr = useSelected;
|
|
825
|
-
};
|
|
826
|
-
MDCListFoundation.prototype.getSelectedIndex = function () {
|
|
827
|
-
return this.selectedIndex;
|
|
828
|
-
};
|
|
829
|
-
MDCListFoundation.prototype.setSelectedIndex = function (index, options) {
|
|
830
|
-
if (options === void 0) { options = {}; }
|
|
831
|
-
if (!this.isIndexValid(index)) {
|
|
832
|
-
return;
|
|
833
|
-
}
|
|
834
|
-
if (this.isCheckboxList) {
|
|
835
|
-
this.setCheckboxAtIndex(index, options);
|
|
836
|
-
}
|
|
837
|
-
else if (this.isRadioList) {
|
|
838
|
-
this.setRadioAtIndex(index, options);
|
|
839
|
-
}
|
|
840
|
-
else {
|
|
841
|
-
this.setSingleSelectionAtIndex(index, options);
|
|
842
|
-
}
|
|
843
|
-
};
|
|
844
|
-
/**
|
|
845
|
-
* Focus in handler for the list items.
|
|
846
|
-
*/
|
|
847
|
-
MDCListFoundation.prototype.handleFocusIn = function (listItemIndex) {
|
|
848
|
-
if (listItemIndex >= 0) {
|
|
849
|
-
this.focusedItemIndex = listItemIndex;
|
|
850
|
-
this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '0');
|
|
851
|
-
this.adapter.setTabIndexForListItemChildren(listItemIndex, '0');
|
|
852
|
-
}
|
|
853
|
-
};
|
|
854
|
-
/**
|
|
855
|
-
* Focus out handler for the list items.
|
|
856
|
-
*/
|
|
857
|
-
MDCListFoundation.prototype.handleFocusOut = function (listItemIndex) {
|
|
858
|
-
var _this = this;
|
|
859
|
-
if (listItemIndex >= 0) {
|
|
860
|
-
this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '-1');
|
|
861
|
-
this.adapter.setTabIndexForListItemChildren(listItemIndex, '-1');
|
|
862
|
-
}
|
|
863
|
-
/**
|
|
864
|
-
* Between Focusout & Focusin some browsers do not have focus on any
|
|
865
|
-
* element. Setting a delay to wait till the focus is moved to next element.
|
|
866
|
-
*/
|
|
867
|
-
setTimeout(function () {
|
|
868
|
-
if (!_this.adapter.isFocusInsideList()) {
|
|
869
|
-
_this.setTabindexToFirstSelectedOrFocusedItem();
|
|
870
|
-
}
|
|
871
|
-
}, 0);
|
|
872
|
-
};
|
|
873
|
-
MDCListFoundation.prototype.isIndexDisabled = function (index) {
|
|
874
|
-
return this.adapter.listItemAtIndexHasClass(index, cssClasses$3.LIST_ITEM_DISABLED_CLASS);
|
|
875
|
-
};
|
|
876
|
-
/**
|
|
877
|
-
* Key handler for the list.
|
|
878
|
-
*/
|
|
879
|
-
MDCListFoundation.prototype.handleKeydown = function (event, isRootListItem, listItemIndex) {
|
|
880
|
-
var _this = this;
|
|
881
|
-
var _a;
|
|
882
|
-
var isArrowLeft = normalizeKey(event) === 'ArrowLeft';
|
|
883
|
-
var isArrowUp = normalizeKey(event) === 'ArrowUp';
|
|
884
|
-
var isArrowRight = normalizeKey(event) === 'ArrowRight';
|
|
885
|
-
var isArrowDown = normalizeKey(event) === 'ArrowDown';
|
|
886
|
-
var isHome = normalizeKey(event) === 'Home';
|
|
887
|
-
var isEnd = normalizeKey(event) === 'End';
|
|
888
|
-
var isEnter = normalizeKey(event) === 'Enter';
|
|
889
|
-
var isSpace = normalizeKey(event) === 'Spacebar';
|
|
890
|
-
// The keys for forward and back differ based on list orientation.
|
|
891
|
-
var isForward = (this.isVertical && isArrowDown) || (!this.isVertical && isArrowRight);
|
|
892
|
-
var isBack = (this.isVertical && isArrowUp) || (!this.isVertical && isArrowLeft);
|
|
893
|
-
// Have to check both upper and lower case, because having caps lock on
|
|
894
|
-
// affects the value.
|
|
895
|
-
var isLetterA = event.key === 'A' || event.key === 'a';
|
|
896
|
-
var eventHasModifiers = createModifierChecker(event);
|
|
897
|
-
if (this.adapter.isRootFocused()) {
|
|
898
|
-
if ((isBack || isEnd) && eventHasModifiers([])) {
|
|
899
|
-
event.preventDefault();
|
|
900
|
-
this.focusLastElement();
|
|
901
|
-
}
|
|
902
|
-
else if ((isForward || isHome) && eventHasModifiers([])) {
|
|
903
|
-
event.preventDefault();
|
|
904
|
-
this.focusFirstElement();
|
|
905
|
-
}
|
|
906
|
-
else if (isBack && eventHasModifiers(['Shift']) && this.isCheckboxList) {
|
|
907
|
-
event.preventDefault();
|
|
908
|
-
var focusedIndex = this.focusLastElement();
|
|
909
|
-
if (focusedIndex !== -1) {
|
|
910
|
-
this.setSelectedIndexOnAction(focusedIndex, false);
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
else if (isForward && eventHasModifiers(['Shift']) && this.isCheckboxList) {
|
|
914
|
-
event.preventDefault();
|
|
915
|
-
var focusedIndex = this.focusFirstElement();
|
|
916
|
-
if (focusedIndex !== -1) {
|
|
917
|
-
this.setSelectedIndexOnAction(focusedIndex, false);
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
if (this.hasTypeahead) {
|
|
921
|
-
var handleKeydownOpts = {
|
|
922
|
-
event: event,
|
|
923
|
-
focusItemAtIndex: function (index) {
|
|
924
|
-
_this.focusItemAtIndex(index);
|
|
925
|
-
},
|
|
926
|
-
focusedItemIndex: -1,
|
|
927
|
-
isTargetListItem: isRootListItem,
|
|
928
|
-
sortedIndexByFirstChar: this.sortedIndexByFirstChar,
|
|
929
|
-
isItemAtIndexDisabled: function (index) { return _this.isIndexDisabled(index); },
|
|
930
|
-
};
|
|
931
|
-
handleKeydown(handleKeydownOpts, this.typeaheadState);
|
|
932
|
-
}
|
|
933
|
-
return;
|
|
934
|
-
}
|
|
935
|
-
var currentIndex = this.adapter.getFocusedElementIndex();
|
|
936
|
-
if (currentIndex === -1) {
|
|
937
|
-
currentIndex = listItemIndex;
|
|
938
|
-
if (currentIndex < 0) {
|
|
939
|
-
// If this event doesn't have a mdc-list-item ancestor from the
|
|
940
|
-
// current list (not from a sublist), return early.
|
|
941
|
-
return;
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
if (isForward && eventHasModifiers([])) {
|
|
945
|
-
preventDefaultEvent(event);
|
|
946
|
-
this.focusNextElement(currentIndex);
|
|
947
|
-
}
|
|
948
|
-
else if (isBack && eventHasModifiers([])) {
|
|
949
|
-
preventDefaultEvent(event);
|
|
950
|
-
this.focusPrevElement(currentIndex);
|
|
951
|
-
}
|
|
952
|
-
else if (isForward && eventHasModifiers(['Shift']) && this.isCheckboxList) {
|
|
953
|
-
preventDefaultEvent(event);
|
|
954
|
-
var focusedIndex = this.focusNextElement(currentIndex);
|
|
955
|
-
if (focusedIndex !== -1) {
|
|
956
|
-
this.setSelectedIndexOnAction(focusedIndex, false);
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
else if (isBack && eventHasModifiers(['Shift']) && this.isCheckboxList) {
|
|
960
|
-
preventDefaultEvent(event);
|
|
961
|
-
var focusedIndex = this.focusPrevElement(currentIndex);
|
|
962
|
-
if (focusedIndex !== -1) {
|
|
963
|
-
this.setSelectedIndexOnAction(focusedIndex, false);
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
else if (isHome && eventHasModifiers([])) {
|
|
967
|
-
preventDefaultEvent(event);
|
|
968
|
-
this.focusFirstElement();
|
|
969
|
-
}
|
|
970
|
-
else if (isEnd && eventHasModifiers([])) {
|
|
971
|
-
preventDefaultEvent(event);
|
|
972
|
-
this.focusLastElement();
|
|
973
|
-
}
|
|
974
|
-
else if (isHome && eventHasModifiers(['Control', 'Shift']) &&
|
|
975
|
-
this.isCheckboxList) {
|
|
976
|
-
preventDefaultEvent(event);
|
|
977
|
-
if (this.isIndexDisabled(currentIndex)) {
|
|
978
|
-
return;
|
|
979
|
-
}
|
|
980
|
-
this.focusFirstElement();
|
|
981
|
-
this.toggleCheckboxRange(0, currentIndex, currentIndex);
|
|
982
|
-
}
|
|
983
|
-
else if (isEnd && eventHasModifiers(['Control', 'Shift']) &&
|
|
984
|
-
this.isCheckboxList) {
|
|
985
|
-
preventDefaultEvent(event);
|
|
986
|
-
if (this.isIndexDisabled(currentIndex)) {
|
|
987
|
-
return;
|
|
988
|
-
}
|
|
989
|
-
this.focusLastElement();
|
|
990
|
-
this.toggleCheckboxRange(currentIndex, this.adapter.getListItemCount() - 1, currentIndex);
|
|
991
|
-
}
|
|
992
|
-
else if (isLetterA && eventHasModifiers(['Control']) && this.isCheckboxList) {
|
|
993
|
-
event.preventDefault();
|
|
994
|
-
this.checkboxListToggleAll(this.selectedIndex === numbers$2.UNSET_INDEX ?
|
|
995
|
-
[] :
|
|
996
|
-
this.selectedIndex, true);
|
|
997
|
-
}
|
|
998
|
-
else if ((isEnter || isSpace) && eventHasModifiers([])) {
|
|
999
|
-
if (isRootListItem) {
|
|
1000
|
-
// Return early if enter key is pressed on anchor element which triggers
|
|
1001
|
-
// synthetic MouseEvent event.
|
|
1002
|
-
var target = event.target;
|
|
1003
|
-
if (target && target.tagName === 'A' && isEnter) {
|
|
1004
|
-
return;
|
|
1005
|
-
}
|
|
1006
|
-
preventDefaultEvent(event);
|
|
1007
|
-
if (this.isIndexDisabled(currentIndex)) {
|
|
1008
|
-
return;
|
|
1009
|
-
}
|
|
1010
|
-
if (!this.isTypeaheadInProgress()) {
|
|
1011
|
-
if (this.isSelectableList()) {
|
|
1012
|
-
this.setSelectedIndexOnAction(currentIndex, false);
|
|
1013
|
-
}
|
|
1014
|
-
this.adapter.notifyAction(currentIndex);
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
else if ((isEnter || isSpace) && eventHasModifiers(['Shift']) &&
|
|
1019
|
-
this.isCheckboxList) {
|
|
1020
|
-
// Return early if enter key is pressed on anchor element which triggers
|
|
1021
|
-
// synthetic MouseEvent event.
|
|
1022
|
-
var target = event.target;
|
|
1023
|
-
if (target && target.tagName === 'A' && isEnter) {
|
|
1024
|
-
return;
|
|
1025
|
-
}
|
|
1026
|
-
preventDefaultEvent(event);
|
|
1027
|
-
if (this.isIndexDisabled(currentIndex)) {
|
|
1028
|
-
return;
|
|
1029
|
-
}
|
|
1030
|
-
if (!this.isTypeaheadInProgress()) {
|
|
1031
|
-
this.toggleCheckboxRange((_a = this.lastSelectedIndex) !== null && _a !== void 0 ? _a : currentIndex, currentIndex, currentIndex);
|
|
1032
|
-
this.adapter.notifyAction(currentIndex);
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
if (this.hasTypeahead) {
|
|
1036
|
-
var handleKeydownOpts = {
|
|
1037
|
-
event: event,
|
|
1038
|
-
focusItemAtIndex: function (index) { _this.focusItemAtIndex(index); },
|
|
1039
|
-
focusedItemIndex: this.focusedItemIndex,
|
|
1040
|
-
isTargetListItem: isRootListItem,
|
|
1041
|
-
sortedIndexByFirstChar: this.sortedIndexByFirstChar,
|
|
1042
|
-
isItemAtIndexDisabled: function (index) { return _this.isIndexDisabled(index); },
|
|
1043
|
-
};
|
|
1044
|
-
handleKeydown(handleKeydownOpts, this.typeaheadState);
|
|
1045
|
-
}
|
|
1046
|
-
};
|
|
1047
|
-
/**
|
|
1048
|
-
* Click handler for the list.
|
|
1049
|
-
*
|
|
1050
|
-
* @param index Index for the item that has been clicked.
|
|
1051
|
-
* @param isCheckboxAlreadyUpdatedInAdapter Whether the checkbox for
|
|
1052
|
-
* the list item has already been updated in the adapter. This attribute
|
|
1053
|
-
* should be set to `true` when e.g. the click event directly landed on
|
|
1054
|
-
* the underlying native checkbox element which would cause the checked
|
|
1055
|
-
* state to be already toggled within `adapter.isCheckboxCheckedAtIndex`.
|
|
1056
|
-
*/
|
|
1057
|
-
MDCListFoundation.prototype.handleClick = function (index, isCheckboxAlreadyUpdatedInAdapter, event) {
|
|
1058
|
-
var _a;
|
|
1059
|
-
var eventHasModifiers = createModifierChecker(event);
|
|
1060
|
-
if (index === numbers$2.UNSET_INDEX) {
|
|
1061
|
-
return;
|
|
1062
|
-
}
|
|
1063
|
-
if (this.isIndexDisabled(index)) {
|
|
1064
|
-
return;
|
|
1065
|
-
}
|
|
1066
|
-
if (eventHasModifiers([])) {
|
|
1067
|
-
if (this.isSelectableList()) {
|
|
1068
|
-
this.setSelectedIndexOnAction(index, isCheckboxAlreadyUpdatedInAdapter);
|
|
1069
|
-
}
|
|
1070
|
-
this.adapter.notifyAction(index);
|
|
1071
|
-
}
|
|
1072
|
-
else if (this.isCheckboxList && eventHasModifiers(['Shift'])) {
|
|
1073
|
-
this.toggleCheckboxRange((_a = this.lastSelectedIndex) !== null && _a !== void 0 ? _a : index, index, index);
|
|
1074
|
-
this.adapter.notifyAction(index);
|
|
1075
|
-
}
|
|
1076
|
-
};
|
|
1077
|
-
/**
|
|
1078
|
-
* Focuses the next element on the list.
|
|
1079
|
-
*/
|
|
1080
|
-
MDCListFoundation.prototype.focusNextElement = function (index) {
|
|
1081
|
-
var count = this.adapter.getListItemCount();
|
|
1082
|
-
var nextIndex = index;
|
|
1083
|
-
var firstChecked = null;
|
|
1084
|
-
do {
|
|
1085
|
-
nextIndex++;
|
|
1086
|
-
if (nextIndex >= count) {
|
|
1087
|
-
if (this.wrapFocus) {
|
|
1088
|
-
nextIndex = 0;
|
|
1089
|
-
}
|
|
1090
|
-
else {
|
|
1091
|
-
// Return early because last item is already focused.
|
|
1092
|
-
return index;
|
|
1093
|
-
}
|
|
1094
|
-
}
|
|
1095
|
-
if (nextIndex === firstChecked) {
|
|
1096
|
-
return -1;
|
|
1097
|
-
}
|
|
1098
|
-
firstChecked = firstChecked !== null && firstChecked !== void 0 ? firstChecked : nextIndex;
|
|
1099
|
-
} while (!this.areDisabledItemsFocusable && this.isIndexDisabled(nextIndex));
|
|
1100
|
-
this.focusItemAtIndex(nextIndex);
|
|
1101
|
-
return nextIndex;
|
|
1102
|
-
};
|
|
1103
|
-
/**
|
|
1104
|
-
* Focuses the previous element on the list.
|
|
1105
|
-
*/
|
|
1106
|
-
MDCListFoundation.prototype.focusPrevElement = function (index) {
|
|
1107
|
-
var count = this.adapter.getListItemCount();
|
|
1108
|
-
var prevIndex = index;
|
|
1109
|
-
var firstChecked = null;
|
|
1110
|
-
do {
|
|
1111
|
-
prevIndex--;
|
|
1112
|
-
if (prevIndex < 0) {
|
|
1113
|
-
if (this.wrapFocus) {
|
|
1114
|
-
prevIndex = count - 1;
|
|
1115
|
-
}
|
|
1116
|
-
else {
|
|
1117
|
-
// Return early because first item is already focused.
|
|
1118
|
-
return index;
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
if (prevIndex === firstChecked) {
|
|
1122
|
-
return -1;
|
|
1123
|
-
}
|
|
1124
|
-
firstChecked = firstChecked !== null && firstChecked !== void 0 ? firstChecked : prevIndex;
|
|
1125
|
-
} while (!this.areDisabledItemsFocusable && this.isIndexDisabled(prevIndex));
|
|
1126
|
-
this.focusItemAtIndex(prevIndex);
|
|
1127
|
-
return prevIndex;
|
|
1128
|
-
};
|
|
1129
|
-
MDCListFoundation.prototype.focusFirstElement = function () {
|
|
1130
|
-
// Pass -1 to `focusNextElement`, since it will incremement to 0 and focus
|
|
1131
|
-
// the first element.
|
|
1132
|
-
return this.focusNextElement(-1);
|
|
1133
|
-
};
|
|
1134
|
-
MDCListFoundation.prototype.focusLastElement = function () {
|
|
1135
|
-
// Pass the length of the list to `focusNextElement` since it will decrement
|
|
1136
|
-
// to length - 1 and focus the last element.
|
|
1137
|
-
return this.focusPrevElement(this.adapter.getListItemCount());
|
|
1138
|
-
};
|
|
1139
|
-
MDCListFoundation.prototype.focusInitialElement = function () {
|
|
1140
|
-
var initialIndex = this.getFirstSelectedOrFocusedItemIndex();
|
|
1141
|
-
this.focusItemAtIndex(initialIndex);
|
|
1142
|
-
return initialIndex;
|
|
1143
|
-
};
|
|
1144
|
-
/**
|
|
1145
|
-
* @param itemIndex Index of the list item
|
|
1146
|
-
* @param isEnabled Sets the list item to enabled or disabled.
|
|
1147
|
-
*/
|
|
1148
|
-
MDCListFoundation.prototype.setEnabled = function (itemIndex, isEnabled) {
|
|
1149
|
-
if (!this.isIndexValid(itemIndex, false)) {
|
|
1150
|
-
return;
|
|
1151
|
-
}
|
|
1152
|
-
if (isEnabled) {
|
|
1153
|
-
this.adapter.removeClassForElementIndex(itemIndex, cssClasses$3.LIST_ITEM_DISABLED_CLASS);
|
|
1154
|
-
this.adapter.setAttributeForElementIndex(itemIndex, strings$4.ARIA_DISABLED, 'false');
|
|
1155
|
-
}
|
|
1156
|
-
else {
|
|
1157
|
-
this.adapter.addClassForElementIndex(itemIndex, cssClasses$3.LIST_ITEM_DISABLED_CLASS);
|
|
1158
|
-
this.adapter.setAttributeForElementIndex(itemIndex, strings$4.ARIA_DISABLED, 'true');
|
|
1159
|
-
}
|
|
1160
|
-
};
|
|
1161
|
-
MDCListFoundation.prototype.setSingleSelectionAtIndex = function (index, options) {
|
|
1162
|
-
if (options === void 0) { options = {}; }
|
|
1163
|
-
if (this.selectedIndex === index && !options.forceUpdate) {
|
|
1164
|
-
return;
|
|
1165
|
-
}
|
|
1166
|
-
var selectedClassName = cssClasses$3.LIST_ITEM_SELECTED_CLASS;
|
|
1167
|
-
if (this.useActivatedClass) {
|
|
1168
|
-
selectedClassName = cssClasses$3.LIST_ITEM_ACTIVATED_CLASS;
|
|
1169
|
-
}
|
|
1170
|
-
if (this.selectedIndex !== numbers$2.UNSET_INDEX) {
|
|
1171
|
-
this.adapter.removeClassForElementIndex(this.selectedIndex, selectedClassName);
|
|
1172
|
-
}
|
|
1173
|
-
this.setAriaForSingleSelectionAtIndex(index);
|
|
1174
|
-
this.setTabindexAtIndex(index);
|
|
1175
|
-
if (index !== numbers$2.UNSET_INDEX) {
|
|
1176
|
-
this.adapter.addClassForElementIndex(index, selectedClassName);
|
|
1177
|
-
}
|
|
1178
|
-
this.selectedIndex = index;
|
|
1179
|
-
// If the selected value has changed through user interaction,
|
|
1180
|
-
// we want to notify the selection change to the adapter.
|
|
1181
|
-
if (options.isUserInteraction && !options.forceUpdate) {
|
|
1182
|
-
this.adapter.notifySelectionChange([index]);
|
|
1183
|
-
}
|
|
1184
|
-
};
|
|
1185
|
-
/**
|
|
1186
|
-
* Sets aria attribute for single selection at given index.
|
|
1187
|
-
*/
|
|
1188
|
-
MDCListFoundation.prototype.setAriaForSingleSelectionAtIndex = function (index) {
|
|
1189
|
-
// Detect the presence of aria-current and get the value only during list
|
|
1190
|
-
// initialization when it is in unset state.
|
|
1191
|
-
if (this.selectedIndex === numbers$2.UNSET_INDEX) {
|
|
1192
|
-
this.ariaCurrentAttrValue =
|
|
1193
|
-
this.adapter.getAttributeForElementIndex(index, strings$4.ARIA_CURRENT);
|
|
1194
|
-
}
|
|
1195
|
-
var isAriaCurrent = this.ariaCurrentAttrValue !== null;
|
|
1196
|
-
var ariaAttribute = isAriaCurrent ? strings$4.ARIA_CURRENT : strings$4.ARIA_SELECTED;
|
|
1197
|
-
if (this.selectedIndex !== numbers$2.UNSET_INDEX) {
|
|
1198
|
-
this.adapter.setAttributeForElementIndex(this.selectedIndex, ariaAttribute, 'false');
|
|
1199
|
-
}
|
|
1200
|
-
if (index !== numbers$2.UNSET_INDEX) {
|
|
1201
|
-
var ariaAttributeValue = isAriaCurrent ? this.ariaCurrentAttrValue : 'true';
|
|
1202
|
-
this.adapter.setAttributeForElementIndex(index, ariaAttribute, ariaAttributeValue);
|
|
1203
|
-
}
|
|
1204
|
-
};
|
|
1205
|
-
/**
|
|
1206
|
-
* Returns the attribute to use for indicating selection status.
|
|
1207
|
-
*/
|
|
1208
|
-
MDCListFoundation.prototype.getSelectionAttribute = function () {
|
|
1209
|
-
return this.useSelectedAttr ? strings$4.ARIA_SELECTED : strings$4.ARIA_CHECKED;
|
|
1210
|
-
};
|
|
1211
|
-
/**
|
|
1212
|
-
* Toggles radio at give index. Radio doesn't change the checked state if it
|
|
1213
|
-
* is already checked.
|
|
1214
|
-
*/
|
|
1215
|
-
MDCListFoundation.prototype.setRadioAtIndex = function (index, options) {
|
|
1216
|
-
if (options === void 0) { options = {}; }
|
|
1217
|
-
var selectionAttribute = this.getSelectionAttribute();
|
|
1218
|
-
this.adapter.setCheckedCheckboxOrRadioAtIndex(index, true);
|
|
1219
|
-
if (this.selectedIndex === index && !options.forceUpdate) {
|
|
1220
|
-
return;
|
|
1221
|
-
}
|
|
1222
|
-
if (this.selectedIndex !== numbers$2.UNSET_INDEX) {
|
|
1223
|
-
this.adapter.setAttributeForElementIndex(this.selectedIndex, selectionAttribute, 'false');
|
|
1224
|
-
}
|
|
1225
|
-
this.adapter.setAttributeForElementIndex(index, selectionAttribute, 'true');
|
|
1226
|
-
this.selectedIndex = index;
|
|
1227
|
-
// If the selected value has changed through user interaction,
|
|
1228
|
-
// we want to notify the selection change to the adapter.
|
|
1229
|
-
if (options.isUserInteraction && !options.forceUpdate) {
|
|
1230
|
-
this.adapter.notifySelectionChange([index]);
|
|
1231
|
-
}
|
|
1232
|
-
};
|
|
1233
|
-
MDCListFoundation.prototype.setCheckboxAtIndex = function (index, options) {
|
|
1234
|
-
if (options === void 0) { options = {}; }
|
|
1235
|
-
var currentIndex = this.selectedIndex;
|
|
1236
|
-
// If this update is not triggered by a user interaction, we do not
|
|
1237
|
-
// need to know about the currently selected indices and can avoid
|
|
1238
|
-
// constructing the `Set` for performance reasons.
|
|
1239
|
-
var currentlySelected = options.isUserInteraction ?
|
|
1240
|
-
new Set(currentIndex === numbers$2.UNSET_INDEX ? [] :
|
|
1241
|
-
currentIndex) :
|
|
1242
|
-
null;
|
|
1243
|
-
var selectionAttribute = this.getSelectionAttribute();
|
|
1244
|
-
var changedIndices = [];
|
|
1245
|
-
for (var i = 0; i < this.adapter.getListItemCount(); i++) {
|
|
1246
|
-
var previousIsChecked = currentlySelected === null || currentlySelected === void 0 ? void 0 : currentlySelected.has(i);
|
|
1247
|
-
var newIsChecked = index.indexOf(i) >= 0;
|
|
1248
|
-
// If the selection has changed for this item, we keep track of it
|
|
1249
|
-
// so that we can notify the adapter.
|
|
1250
|
-
if (newIsChecked !== previousIsChecked) {
|
|
1251
|
-
changedIndices.push(i);
|
|
1252
|
-
}
|
|
1253
|
-
this.adapter.setCheckedCheckboxOrRadioAtIndex(i, newIsChecked);
|
|
1254
|
-
this.adapter.setAttributeForElementIndex(i, selectionAttribute, newIsChecked ? 'true' : 'false');
|
|
1255
|
-
}
|
|
1256
|
-
this.selectedIndex = index;
|
|
1257
|
-
// If the selected value has changed through user interaction,
|
|
1258
|
-
// we want to notify the selection change to the adapter.
|
|
1259
|
-
if (options.isUserInteraction && changedIndices.length) {
|
|
1260
|
-
this.adapter.notifySelectionChange(changedIndices);
|
|
1261
|
-
}
|
|
1262
|
-
};
|
|
1263
|
-
/**
|
|
1264
|
-
* Toggles the state of all checkboxes in the given range (inclusive) based on
|
|
1265
|
-
* the state of the checkbox at the `toggleIndex`. To determine whether to set
|
|
1266
|
-
* the given range to checked or unchecked, read the value of the checkbox at
|
|
1267
|
-
* the `toggleIndex` and negate it. Then apply that new checked state to all
|
|
1268
|
-
* checkboxes in the range.
|
|
1269
|
-
* @param fromIndex The start of the range of checkboxes to toggle
|
|
1270
|
-
* @param toIndex The end of the range of checkboxes to toggle
|
|
1271
|
-
* @param toggleIndex The index that will be used to determine the new state
|
|
1272
|
-
* of the given checkbox range.
|
|
1273
|
-
*/
|
|
1274
|
-
MDCListFoundation.prototype.toggleCheckboxRange = function (fromIndex, toIndex, toggleIndex) {
|
|
1275
|
-
this.lastSelectedIndex = toggleIndex;
|
|
1276
|
-
var currentlySelected = new Set(this.selectedIndex === numbers$2.UNSET_INDEX ?
|
|
1277
|
-
[] :
|
|
1278
|
-
this.selectedIndex);
|
|
1279
|
-
var newIsChecked = !(currentlySelected === null || currentlySelected === void 0 ? void 0 : currentlySelected.has(toggleIndex));
|
|
1280
|
-
var _a = __read([fromIndex, toIndex].sort(), 2), startIndex = _a[0], endIndex = _a[1];
|
|
1281
|
-
var selectionAttribute = this.getSelectionAttribute();
|
|
1282
|
-
var changedIndices = [];
|
|
1283
|
-
for (var i = startIndex; i <= endIndex; i++) {
|
|
1284
|
-
if (this.isIndexDisabled(i)) {
|
|
1285
|
-
continue;
|
|
1286
|
-
}
|
|
1287
|
-
var previousIsChecked = currentlySelected.has(i);
|
|
1288
|
-
// If the selection has changed for this item, we keep track of it
|
|
1289
|
-
// so that we can notify the adapter.
|
|
1290
|
-
if (newIsChecked !== previousIsChecked) {
|
|
1291
|
-
changedIndices.push(i);
|
|
1292
|
-
this.adapter.setCheckedCheckboxOrRadioAtIndex(i, newIsChecked);
|
|
1293
|
-
this.adapter.setAttributeForElementIndex(i, selectionAttribute, "" + newIsChecked);
|
|
1294
|
-
if (newIsChecked) {
|
|
1295
|
-
currentlySelected.add(i);
|
|
1296
|
-
}
|
|
1297
|
-
else {
|
|
1298
|
-
currentlySelected.delete(i);
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
// If the selected value has changed, update and notify the selection change
|
|
1303
|
-
// to the adapter.
|
|
1304
|
-
if (changedIndices.length) {
|
|
1305
|
-
this.selectedIndex = __spreadArray([], __read(currentlySelected));
|
|
1306
|
-
this.adapter.notifySelectionChange(changedIndices);
|
|
1307
|
-
}
|
|
1308
|
-
};
|
|
1309
|
-
MDCListFoundation.prototype.setTabindexAtIndex = function (index) {
|
|
1310
|
-
if (this.focusedItemIndex === numbers$2.UNSET_INDEX && index !== 0) {
|
|
1311
|
-
// If some list item was selected set first list item's tabindex to -1.
|
|
1312
|
-
// Generally, tabindex is set to 0 on first list item of list that has no
|
|
1313
|
-
// preselected items.
|
|
1314
|
-
this.adapter.setAttributeForElementIndex(0, 'tabindex', '-1');
|
|
1315
|
-
}
|
|
1316
|
-
else if (this.focusedItemIndex >= 0 && this.focusedItemIndex !== index) {
|
|
1317
|
-
this.adapter.setAttributeForElementIndex(this.focusedItemIndex, 'tabindex', '-1');
|
|
1318
|
-
}
|
|
1319
|
-
// Set the previous selection's tabindex to -1. We need this because
|
|
1320
|
-
// in selection menus that are not visible, programmatically setting an
|
|
1321
|
-
// option will not change focus but will change where tabindex should be 0.
|
|
1322
|
-
if (!(this.selectedIndex instanceof Array) &&
|
|
1323
|
-
this.selectedIndex !== index) {
|
|
1324
|
-
this.adapter.setAttributeForElementIndex(this.selectedIndex, 'tabindex', '-1');
|
|
1325
|
-
}
|
|
1326
|
-
if (index !== numbers$2.UNSET_INDEX) {
|
|
1327
|
-
this.adapter.setAttributeForElementIndex(index, 'tabindex', '0');
|
|
1328
|
-
}
|
|
1329
|
-
};
|
|
1330
|
-
/**
|
|
1331
|
-
* @return Return true if it is single selectin list, checkbox list or radio
|
|
1332
|
-
* list.
|
|
1333
|
-
*/
|
|
1334
|
-
MDCListFoundation.prototype.isSelectableList = function () {
|
|
1335
|
-
return this.isSingleSelectionList || this.isCheckboxList ||
|
|
1336
|
-
this.isRadioList;
|
|
1337
|
-
};
|
|
1338
|
-
MDCListFoundation.prototype.setTabindexToFirstSelectedOrFocusedItem = function () {
|
|
1339
|
-
var targetIndex = this.getFirstSelectedOrFocusedItemIndex();
|
|
1340
|
-
this.setTabindexAtIndex(targetIndex);
|
|
1341
|
-
};
|
|
1342
|
-
MDCListFoundation.prototype.getFirstSelectedOrFocusedItemIndex = function () {
|
|
1343
|
-
// Action lists retain focus on the most recently focused item.
|
|
1344
|
-
if (!this.isSelectableList()) {
|
|
1345
|
-
return Math.max(this.focusedItemIndex, 0);
|
|
1346
|
-
}
|
|
1347
|
-
// Single-selection lists focus the selected item.
|
|
1348
|
-
if (typeof this.selectedIndex === 'number' &&
|
|
1349
|
-
this.selectedIndex !== numbers$2.UNSET_INDEX) {
|
|
1350
|
-
return this.selectedIndex;
|
|
1351
|
-
}
|
|
1352
|
-
// Multiple-selection lists focus the first selected item.
|
|
1353
|
-
if (isNumberArray(this.selectedIndex) && this.selectedIndex.length > 0) {
|
|
1354
|
-
return this.selectedIndex.reduce(function (minIndex, currentIndex) { return Math.min(minIndex, currentIndex); });
|
|
1355
|
-
}
|
|
1356
|
-
// Selection lists without a selection focus the first item.
|
|
1357
|
-
return 0;
|
|
1358
|
-
};
|
|
1359
|
-
MDCListFoundation.prototype.isIndexValid = function (index, validateListType) {
|
|
1360
|
-
var _this = this;
|
|
1361
|
-
if (validateListType === void 0) { validateListType = true; }
|
|
1362
|
-
if (index instanceof Array) {
|
|
1363
|
-
if (!this.isCheckboxList && validateListType) {
|
|
1364
|
-
throw new Error('MDCListFoundation: Array of index is only supported for checkbox based list');
|
|
1365
|
-
}
|
|
1366
|
-
if (index.length === 0) {
|
|
1367
|
-
return true;
|
|
1368
|
-
}
|
|
1369
|
-
else {
|
|
1370
|
-
return index.some(function (i) { return _this.isIndexInRange(i); });
|
|
1371
|
-
}
|
|
1372
|
-
}
|
|
1373
|
-
else if (typeof index === 'number') {
|
|
1374
|
-
if (this.isCheckboxList && validateListType) {
|
|
1375
|
-
throw new Error("MDCListFoundation: Expected array of index for checkbox based list but got number: " + index);
|
|
1376
|
-
}
|
|
1377
|
-
return this.isIndexInRange(index) ||
|
|
1378
|
-
this.isSingleSelectionList && index === numbers$2.UNSET_INDEX;
|
|
1379
|
-
}
|
|
1380
|
-
else {
|
|
1381
|
-
return false;
|
|
1382
|
-
}
|
|
1383
|
-
};
|
|
1384
|
-
MDCListFoundation.prototype.isIndexInRange = function (index) {
|
|
1385
|
-
var listSize = this.adapter.getListItemCount();
|
|
1386
|
-
return index >= 0 && index < listSize;
|
|
1387
|
-
};
|
|
1388
|
-
/**
|
|
1389
|
-
* Sets selected index on user action, toggles checkboxes in checkbox lists
|
|
1390
|
-
* by default, unless `isCheckboxAlreadyUpdatedInAdapter` is set to `true`.
|
|
1391
|
-
*
|
|
1392
|
-
* In cases where `isCheckboxAlreadyUpdatedInAdapter` is set to `true`, the
|
|
1393
|
-
* UI is just updated to reflect the value returned by the adapter.
|
|
1394
|
-
*
|
|
1395
|
-
* When calling this, make sure user interaction does not toggle disabled
|
|
1396
|
-
* list items.
|
|
1397
|
-
*/
|
|
1398
|
-
MDCListFoundation.prototype.setSelectedIndexOnAction = function (index, isCheckboxAlreadyUpdatedInAdapter) {
|
|
1399
|
-
this.lastSelectedIndex = index;
|
|
1400
|
-
if (this.isCheckboxList) {
|
|
1401
|
-
this.toggleCheckboxAtIndex(index, isCheckboxAlreadyUpdatedInAdapter);
|
|
1402
|
-
this.adapter.notifySelectionChange([index]);
|
|
1403
|
-
}
|
|
1404
|
-
else {
|
|
1405
|
-
this.setSelectedIndex(index, { isUserInteraction: true });
|
|
1406
|
-
}
|
|
1407
|
-
};
|
|
1408
|
-
MDCListFoundation.prototype.toggleCheckboxAtIndex = function (index, isCheckboxAlreadyUpdatedInAdapter) {
|
|
1409
|
-
var selectionAttribute = this.getSelectionAttribute();
|
|
1410
|
-
var adapterIsChecked = this.adapter.isCheckboxCheckedAtIndex(index);
|
|
1411
|
-
// By default the checked value from the adapter is toggled unless the
|
|
1412
|
-
// checked state in the adapter has already been updated beforehand.
|
|
1413
|
-
// This can be happen when the underlying native checkbox has already
|
|
1414
|
-
// been updated through the native click event.
|
|
1415
|
-
var newCheckedValue;
|
|
1416
|
-
if (isCheckboxAlreadyUpdatedInAdapter) {
|
|
1417
|
-
newCheckedValue = adapterIsChecked;
|
|
1418
|
-
}
|
|
1419
|
-
else {
|
|
1420
|
-
newCheckedValue = !adapterIsChecked;
|
|
1421
|
-
this.adapter.setCheckedCheckboxOrRadioAtIndex(index, newCheckedValue);
|
|
1422
|
-
}
|
|
1423
|
-
this.adapter.setAttributeForElementIndex(index, selectionAttribute, newCheckedValue ? 'true' : 'false');
|
|
1424
|
-
// If none of the checkbox items are selected and selectedIndex is not
|
|
1425
|
-
// initialized then provide a default value.
|
|
1426
|
-
var selectedIndexes = this.selectedIndex === numbers$2.UNSET_INDEX ?
|
|
1427
|
-
[] :
|
|
1428
|
-
this.selectedIndex.slice();
|
|
1429
|
-
if (newCheckedValue) {
|
|
1430
|
-
selectedIndexes.push(index);
|
|
1431
|
-
}
|
|
1432
|
-
else {
|
|
1433
|
-
selectedIndexes = selectedIndexes.filter(function (i) { return i !== index; });
|
|
1434
|
-
}
|
|
1435
|
-
this.selectedIndex = selectedIndexes;
|
|
1436
|
-
};
|
|
1437
|
-
MDCListFoundation.prototype.focusItemAtIndex = function (index) {
|
|
1438
|
-
this.adapter.focusItemAtIndex(index);
|
|
1439
|
-
this.focusedItemIndex = index;
|
|
1440
|
-
};
|
|
1441
|
-
MDCListFoundation.prototype.checkboxListToggleAll = function (currentlySelectedIndexes, isUserInteraction) {
|
|
1442
|
-
var count = this.adapter.getListItemCount();
|
|
1443
|
-
// If all items are selected, deselect everything.
|
|
1444
|
-
if (currentlySelectedIndexes.length === count) {
|
|
1445
|
-
this.setCheckboxAtIndex([], { isUserInteraction: isUserInteraction });
|
|
1446
|
-
}
|
|
1447
|
-
else {
|
|
1448
|
-
// Otherwise select all enabled options.
|
|
1449
|
-
var allIndexes = [];
|
|
1450
|
-
for (var i = 0; i < count; i++) {
|
|
1451
|
-
if (!this.isIndexDisabled(i) ||
|
|
1452
|
-
currentlySelectedIndexes.indexOf(i) > -1) {
|
|
1453
|
-
allIndexes.push(i);
|
|
1454
|
-
}
|
|
1455
|
-
}
|
|
1456
|
-
this.setCheckboxAtIndex(allIndexes, { isUserInteraction: isUserInteraction });
|
|
1457
|
-
}
|
|
1458
|
-
};
|
|
1459
|
-
/**
|
|
1460
|
-
* Given the next desired character from the user, adds it to the typeahead
|
|
1461
|
-
* buffer. Then, attempts to find the next option matching the buffer. Wraps
|
|
1462
|
-
* around if at the end of options.
|
|
1463
|
-
*
|
|
1464
|
-
* @param nextChar The next character to add to the prefix buffer.
|
|
1465
|
-
* @param startingIndex The index from which to start matching. Only relevant
|
|
1466
|
-
* when starting a new match sequence. To start a new match sequence,
|
|
1467
|
-
* clear the buffer using `clearTypeaheadBuffer`, or wait for the buffer
|
|
1468
|
-
* to clear after a set interval defined in list foundation. Defaults to
|
|
1469
|
-
* the currently focused index.
|
|
1470
|
-
* @return The index of the matched item, or -1 if no match.
|
|
1471
|
-
*/
|
|
1472
|
-
MDCListFoundation.prototype.typeaheadMatchItem = function (nextChar, startingIndex, skipFocus) {
|
|
1473
|
-
var _this = this;
|
|
1474
|
-
if (skipFocus === void 0) { skipFocus = false; }
|
|
1475
|
-
var opts = {
|
|
1476
|
-
focusItemAtIndex: function (index) {
|
|
1477
|
-
_this.focusItemAtIndex(index);
|
|
1478
|
-
},
|
|
1479
|
-
focusedItemIndex: startingIndex ? startingIndex : this.focusedItemIndex,
|
|
1480
|
-
nextChar: nextChar,
|
|
1481
|
-
sortedIndexByFirstChar: this.sortedIndexByFirstChar,
|
|
1482
|
-
skipFocus: skipFocus,
|
|
1483
|
-
isItemAtIndexDisabled: function (index) { return _this.isIndexDisabled(index); }
|
|
1484
|
-
};
|
|
1485
|
-
return matchItem(opts, this.typeaheadState);
|
|
1486
|
-
};
|
|
1487
|
-
/**
|
|
1488
|
-
* Initializes the MDCListTextAndIndex data structure by indexing the current
|
|
1489
|
-
* list items by primary text.
|
|
1490
|
-
*
|
|
1491
|
-
* @return The primary texts of all the list items sorted by first character.
|
|
1492
|
-
*/
|
|
1493
|
-
MDCListFoundation.prototype.typeaheadInitSortedIndex = function () {
|
|
1494
|
-
return initSortedIndex(this.adapter.getListItemCount(), this.adapter.getPrimaryTextAtIndex);
|
|
1495
|
-
};
|
|
1496
|
-
/**
|
|
1497
|
-
* Clears the typeahead buffer.
|
|
1498
|
-
*/
|
|
1499
|
-
MDCListFoundation.prototype.clearTypeaheadBuffer = function () {
|
|
1500
|
-
clearBuffer(this.typeaheadState);
|
|
1501
|
-
};
|
|
1502
|
-
return MDCListFoundation;
|
|
1503
|
-
}(MDCFoundation));
|
|
1504
|
-
|
|
1505
|
-
/**
|
|
1506
|
-
* @license
|
|
1507
|
-
* Copyright 2018 Google Inc.
|
|
1508
|
-
*
|
|
1509
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1510
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
1511
|
-
* in the Software without restriction, including without limitation the rights
|
|
1512
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1513
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
1514
|
-
* furnished to do so, subject to the following conditions:
|
|
1515
|
-
*
|
|
1516
|
-
* The above copyright notice and this permission notice shall be included in
|
|
1517
|
-
* all copies or substantial portions of the Software.
|
|
1518
|
-
*
|
|
1519
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1520
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1521
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1522
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1523
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1524
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1525
|
-
* THE SOFTWARE.
|
|
1526
|
-
*/
|
|
1527
|
-
var MDCList = /** @class */ (function (_super) {
|
|
1528
|
-
__extends(MDCList, _super);
|
|
1529
|
-
function MDCList() {
|
|
1530
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1531
|
-
}
|
|
1532
|
-
Object.defineProperty(MDCList.prototype, "vertical", {
|
|
1533
|
-
set: function (value) {
|
|
1534
|
-
this.foundation.setVerticalOrientation(value);
|
|
1535
|
-
},
|
|
1536
|
-
enumerable: false,
|
|
1537
|
-
configurable: true
|
|
1538
|
-
});
|
|
1539
|
-
Object.defineProperty(MDCList.prototype, "listElements", {
|
|
1540
|
-
get: function () {
|
|
1541
|
-
return Array.from(this.root.querySelectorAll("." + this.classNameMap[cssClasses$3.LIST_ITEM_CLASS]));
|
|
1542
|
-
},
|
|
1543
|
-
enumerable: false,
|
|
1544
|
-
configurable: true
|
|
1545
|
-
});
|
|
1546
|
-
Object.defineProperty(MDCList.prototype, "wrapFocus", {
|
|
1547
|
-
set: function (value) {
|
|
1548
|
-
this.foundation.setWrapFocus(value);
|
|
1549
|
-
},
|
|
1550
|
-
enumerable: false,
|
|
1551
|
-
configurable: true
|
|
1552
|
-
});
|
|
1553
|
-
Object.defineProperty(MDCList.prototype, "typeaheadInProgress", {
|
|
1554
|
-
/**
|
|
1555
|
-
* @return Whether typeahead is currently matching a user-specified prefix.
|
|
1556
|
-
*/
|
|
1557
|
-
get: function () {
|
|
1558
|
-
return this.foundation.isTypeaheadInProgress();
|
|
1559
|
-
},
|
|
1560
|
-
enumerable: false,
|
|
1561
|
-
configurable: true
|
|
1562
|
-
});
|
|
1563
|
-
Object.defineProperty(MDCList.prototype, "hasTypeahead", {
|
|
1564
|
-
/**
|
|
1565
|
-
* Sets whether typeahead functionality is enabled on the list.
|
|
1566
|
-
* @param hasTypeahead Whether typeahead is enabled.
|
|
1567
|
-
*/
|
|
1568
|
-
set: function (hasTypeahead) {
|
|
1569
|
-
this.foundation.setHasTypeahead(hasTypeahead);
|
|
1570
|
-
},
|
|
1571
|
-
enumerable: false,
|
|
1572
|
-
configurable: true
|
|
1573
|
-
});
|
|
1574
|
-
Object.defineProperty(MDCList.prototype, "singleSelection", {
|
|
1575
|
-
set: function (isSingleSelectionList) {
|
|
1576
|
-
this.foundation.setSingleSelection(isSingleSelectionList);
|
|
1577
|
-
},
|
|
1578
|
-
enumerable: false,
|
|
1579
|
-
configurable: true
|
|
1580
|
-
});
|
|
1581
|
-
Object.defineProperty(MDCList.prototype, "disabledItemsFocusable", {
|
|
1582
|
-
set: function (areDisabledItemsFocusable) {
|
|
1583
|
-
this.foundation.setDisabledItemsFocusable(areDisabledItemsFocusable);
|
|
1584
|
-
},
|
|
1585
|
-
enumerable: false,
|
|
1586
|
-
configurable: true
|
|
1587
|
-
});
|
|
1588
|
-
Object.defineProperty(MDCList.prototype, "selectedIndex", {
|
|
1589
|
-
get: function () {
|
|
1590
|
-
return this.foundation.getSelectedIndex();
|
|
1591
|
-
},
|
|
1592
|
-
set: function (index) {
|
|
1593
|
-
this.foundation.setSelectedIndex(index);
|
|
1594
|
-
},
|
|
1595
|
-
enumerable: false,
|
|
1596
|
-
configurable: true
|
|
1597
|
-
});
|
|
1598
|
-
MDCList.attachTo = function (root) {
|
|
1599
|
-
return new MDCList(root);
|
|
1600
|
-
};
|
|
1601
|
-
MDCList.prototype.initialSyncWithDOM = function () {
|
|
1602
|
-
this.isEvolutionEnabled =
|
|
1603
|
-
evolutionAttribute in this.root.dataset;
|
|
1604
|
-
if (this.isEvolutionEnabled) {
|
|
1605
|
-
this.classNameMap = evolutionClassNameMap;
|
|
1606
|
-
}
|
|
1607
|
-
else if (matches(this.root, strings$4.DEPRECATED_SELECTOR)) {
|
|
1608
|
-
this.classNameMap = deprecatedClassNameMap;
|
|
1609
|
-
}
|
|
1610
|
-
else {
|
|
1611
|
-
this.classNameMap =
|
|
1612
|
-
Object.values(cssClasses$3)
|
|
1613
|
-
.reduce(function (obj, className) {
|
|
1614
|
-
obj[className] = className;
|
|
1615
|
-
return obj;
|
|
1616
|
-
}, {});
|
|
1617
|
-
}
|
|
1618
|
-
this.handleClick = this.handleClickEvent.bind(this);
|
|
1619
|
-
this.handleKeydown = this.handleKeydownEvent.bind(this);
|
|
1620
|
-
this.focusInEventListener = this.handleFocusInEvent.bind(this);
|
|
1621
|
-
this.focusOutEventListener = this.handleFocusOutEvent.bind(this);
|
|
1622
|
-
this.listen('keydown', this.handleKeydown);
|
|
1623
|
-
this.listen('click', this.handleClick);
|
|
1624
|
-
this.listen('focusin', this.focusInEventListener);
|
|
1625
|
-
this.listen('focusout', this.focusOutEventListener);
|
|
1626
|
-
this.layout();
|
|
1627
|
-
this.initializeListType();
|
|
1628
|
-
this.ensureFocusable();
|
|
1629
|
-
};
|
|
1630
|
-
MDCList.prototype.destroy = function () {
|
|
1631
|
-
this.unlisten('keydown', this.handleKeydown);
|
|
1632
|
-
this.unlisten('click', this.handleClick);
|
|
1633
|
-
this.unlisten('focusin', this.focusInEventListener);
|
|
1634
|
-
this.unlisten('focusout', this.focusOutEventListener);
|
|
1635
|
-
};
|
|
1636
|
-
MDCList.prototype.layout = function () {
|
|
1637
|
-
var direction = this.root.getAttribute(strings$4.ARIA_ORIENTATION);
|
|
1638
|
-
this.vertical = direction !== strings$4.ARIA_ORIENTATION_HORIZONTAL;
|
|
1639
|
-
var itemSelector = "." + this.classNameMap[cssClasses$3.LIST_ITEM_CLASS] + ":not([tabindex])";
|
|
1640
|
-
var childSelector = strings$4.FOCUSABLE_CHILD_ELEMENTS;
|
|
1641
|
-
// List items need to have at least tabindex=-1 to be focusable.
|
|
1642
|
-
var itemEls = this.root.querySelectorAll(itemSelector);
|
|
1643
|
-
if (itemEls.length) {
|
|
1644
|
-
Array.prototype.forEach.call(itemEls, function (el) {
|
|
1645
|
-
el.setAttribute('tabindex', '-1');
|
|
1646
|
-
});
|
|
1647
|
-
}
|
|
1648
|
-
// Child button/a elements are not tabbable until the list item is focused.
|
|
1649
|
-
var focusableChildEls = this.root.querySelectorAll(childSelector);
|
|
1650
|
-
if (focusableChildEls.length) {
|
|
1651
|
-
Array.prototype.forEach.call(focusableChildEls, function (el) {
|
|
1652
|
-
el.setAttribute('tabindex', '-1');
|
|
1653
|
-
});
|
|
1654
|
-
}
|
|
1655
|
-
if (this.isEvolutionEnabled) {
|
|
1656
|
-
this.foundation.setUseSelectedAttribute(true);
|
|
1657
|
-
}
|
|
1658
|
-
this.foundation.layout();
|
|
1659
|
-
};
|
|
1660
|
-
/**
|
|
1661
|
-
* Extracts the primary text from a list item.
|
|
1662
|
-
* @param item The list item element.
|
|
1663
|
-
* @return The primary text in the element.
|
|
1664
|
-
*/
|
|
1665
|
-
MDCList.prototype.getPrimaryText = function (item) {
|
|
1666
|
-
var _a;
|
|
1667
|
-
var primaryText = item.querySelector("." + this.classNameMap[cssClasses$3.LIST_ITEM_PRIMARY_TEXT_CLASS]);
|
|
1668
|
-
if (this.isEvolutionEnabled || primaryText) {
|
|
1669
|
-
return (_a = primaryText === null || primaryText === void 0 ? void 0 : primaryText.textContent) !== null && _a !== void 0 ? _a : '';
|
|
1670
|
-
}
|
|
1671
|
-
var singleLineText = item.querySelector("." + this.classNameMap[cssClasses$3.LIST_ITEM_TEXT_CLASS]);
|
|
1672
|
-
return (singleLineText && singleLineText.textContent) || '';
|
|
1673
|
-
};
|
|
1674
|
-
/**
|
|
1675
|
-
* Initialize selectedIndex value based on pre-selected list items.
|
|
1676
|
-
*/
|
|
1677
|
-
MDCList.prototype.initializeListType = function () {
|
|
1678
|
-
var _this = this;
|
|
1679
|
-
this.isInteractive =
|
|
1680
|
-
matches(this.root, strings$4.ARIA_INTERACTIVE_ROLES_SELECTOR);
|
|
1681
|
-
if (this.isEvolutionEnabled && this.isInteractive) {
|
|
1682
|
-
var selection = Array.from(this.root.querySelectorAll(strings$4.SELECTED_ITEM_SELECTOR), function (listItem) { return _this.listElements.indexOf(listItem); });
|
|
1683
|
-
if (matches(this.root, strings$4.ARIA_MULTI_SELECTABLE_SELECTOR)) {
|
|
1684
|
-
this.selectedIndex = selection;
|
|
1685
|
-
}
|
|
1686
|
-
else if (selection.length > 0) {
|
|
1687
|
-
this.selectedIndex = selection[0];
|
|
1688
|
-
}
|
|
1689
|
-
return;
|
|
1690
|
-
}
|
|
1691
|
-
var checkboxListItems = this.root.querySelectorAll(strings$4.ARIA_ROLE_CHECKBOX_SELECTOR);
|
|
1692
|
-
var radioSelectedListItem = this.root.querySelector(strings$4.ARIA_CHECKED_RADIO_SELECTOR);
|
|
1693
|
-
if (checkboxListItems.length) {
|
|
1694
|
-
var preselectedItems = this.root.querySelectorAll(strings$4.ARIA_CHECKED_CHECKBOX_SELECTOR);
|
|
1695
|
-
this.selectedIndex = Array.from(preselectedItems, function (listItem) { return _this.listElements.indexOf(listItem); });
|
|
1696
|
-
}
|
|
1697
|
-
else if (radioSelectedListItem) {
|
|
1698
|
-
this.selectedIndex = this.listElements.indexOf(radioSelectedListItem);
|
|
1699
|
-
}
|
|
1700
|
-
};
|
|
1701
|
-
/**
|
|
1702
|
-
* Updates the list item at itemIndex to the desired isEnabled state.
|
|
1703
|
-
* @param itemIndex Index of the list item
|
|
1704
|
-
* @param isEnabled Sets the list item to enabled or disabled.
|
|
1705
|
-
*/
|
|
1706
|
-
MDCList.prototype.setEnabled = function (itemIndex, isEnabled) {
|
|
1707
|
-
this.foundation.setEnabled(itemIndex, isEnabled);
|
|
1708
|
-
};
|
|
1709
|
-
/**
|
|
1710
|
-
* Given the next desired character from the user, adds it to the typeahead
|
|
1711
|
-
* buffer. Then, attempts to find the next option matching the buffer. Wraps
|
|
1712
|
-
* around if at the end of options.
|
|
1713
|
-
*
|
|
1714
|
-
* @param nextChar The next character to add to the prefix buffer.
|
|
1715
|
-
* @param startingIndex The index from which to start matching. Defaults to
|
|
1716
|
-
* the currently focused index.
|
|
1717
|
-
* @return The index of the matched item.
|
|
1718
|
-
*/
|
|
1719
|
-
MDCList.prototype.typeaheadMatchItem = function (nextChar, startingIndex) {
|
|
1720
|
-
return this.foundation.typeaheadMatchItem(nextChar, startingIndex, /** skipFocus */ true);
|
|
1721
|
-
};
|
|
1722
|
-
MDCList.prototype.getDefaultFoundation = function () {
|
|
1723
|
-
var _this = this;
|
|
1724
|
-
// DO NOT INLINE this variable. For backward compatibility, foundations take
|
|
1725
|
-
// a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
|
|
1726
|
-
// methods, we need a separate, strongly typed adapter variable.
|
|
1727
|
-
var adapter = {
|
|
1728
|
-
addClassForElementIndex: function (index, className) {
|
|
1729
|
-
var element = _this.listElements[index];
|
|
1730
|
-
if (element) {
|
|
1731
|
-
element.classList.add(_this.classNameMap[className]);
|
|
1732
|
-
}
|
|
1733
|
-
},
|
|
1734
|
-
focusItemAtIndex: function (index) {
|
|
1735
|
-
var element = _this.listElements[index];
|
|
1736
|
-
if (element) {
|
|
1737
|
-
element.focus();
|
|
1738
|
-
}
|
|
1739
|
-
},
|
|
1740
|
-
getAttributeForElementIndex: function (index, attr) {
|
|
1741
|
-
return _this.listElements[index].getAttribute(attr);
|
|
1742
|
-
},
|
|
1743
|
-
getFocusedElementIndex: function () {
|
|
1744
|
-
return _this.listElements.indexOf(document.activeElement);
|
|
1745
|
-
},
|
|
1746
|
-
getListItemCount: function () { return _this.listElements.length; },
|
|
1747
|
-
getPrimaryTextAtIndex: function (index) {
|
|
1748
|
-
return _this.getPrimaryText(_this.listElements[index]);
|
|
1749
|
-
},
|
|
1750
|
-
hasCheckboxAtIndex: function (index) {
|
|
1751
|
-
var listItem = _this.listElements[index];
|
|
1752
|
-
return !!listItem.querySelector(strings$4.CHECKBOX_SELECTOR);
|
|
1753
|
-
},
|
|
1754
|
-
hasRadioAtIndex: function (index) {
|
|
1755
|
-
var listItem = _this.listElements[index];
|
|
1756
|
-
return !!listItem.querySelector(strings$4.RADIO_SELECTOR);
|
|
1757
|
-
},
|
|
1758
|
-
isCheckboxCheckedAtIndex: function (index) {
|
|
1759
|
-
var listItem = _this.listElements[index];
|
|
1760
|
-
var toggleEl = listItem.querySelector(strings$4.CHECKBOX_SELECTOR);
|
|
1761
|
-
return toggleEl.checked;
|
|
1762
|
-
},
|
|
1763
|
-
isFocusInsideList: function () {
|
|
1764
|
-
return _this.root !== document.activeElement &&
|
|
1765
|
-
_this.root.contains(document.activeElement);
|
|
1766
|
-
},
|
|
1767
|
-
isRootFocused: function () { return document.activeElement === _this.root; },
|
|
1768
|
-
listItemAtIndexHasClass: function (index, className) {
|
|
1769
|
-
return _this.listElements[index].classList.contains(_this.classNameMap[className]);
|
|
1770
|
-
},
|
|
1771
|
-
notifyAction: function (index) {
|
|
1772
|
-
_this.emit(strings$4.ACTION_EVENT, { index: index }, /** shouldBubble */ true);
|
|
1773
|
-
},
|
|
1774
|
-
notifySelectionChange: function (changedIndices) {
|
|
1775
|
-
_this.emit(strings$4.SELECTION_CHANGE_EVENT, { changedIndices: changedIndices }, /** shouldBubble */ true);
|
|
1776
|
-
},
|
|
1777
|
-
removeClassForElementIndex: function (index, className) {
|
|
1778
|
-
var element = _this.listElements[index];
|
|
1779
|
-
if (element) {
|
|
1780
|
-
element.classList.remove(_this.classNameMap[className]);
|
|
1781
|
-
}
|
|
1782
|
-
},
|
|
1783
|
-
setAttributeForElementIndex: function (index, attr, value) {
|
|
1784
|
-
var element = _this.listElements[index];
|
|
1785
|
-
if (element) {
|
|
1786
|
-
element.setAttribute(attr, value);
|
|
1787
|
-
}
|
|
1788
|
-
},
|
|
1789
|
-
setCheckedCheckboxOrRadioAtIndex: function (index, isChecked) {
|
|
1790
|
-
var listItem = _this.listElements[index];
|
|
1791
|
-
var toggleEl = listItem.querySelector(strings$4.CHECKBOX_RADIO_SELECTOR);
|
|
1792
|
-
toggleEl.checked = isChecked;
|
|
1793
|
-
var event = document.createEvent('Event');
|
|
1794
|
-
event.initEvent('change', true, true);
|
|
1795
|
-
toggleEl.dispatchEvent(event);
|
|
1796
|
-
},
|
|
1797
|
-
setTabIndexForListItemChildren: function (listItemIndex, tabIndexValue) {
|
|
1798
|
-
var element = _this.listElements[listItemIndex];
|
|
1799
|
-
var selector = strings$4.CHILD_ELEMENTS_TO_TOGGLE_TABINDEX;
|
|
1800
|
-
Array.prototype.forEach.call(element.querySelectorAll(selector), function (el) {
|
|
1801
|
-
el.setAttribute('tabindex', tabIndexValue);
|
|
1802
|
-
});
|
|
1803
|
-
},
|
|
1804
|
-
};
|
|
1805
|
-
return new MDCListFoundation(adapter);
|
|
1806
|
-
};
|
|
1807
|
-
/**
|
|
1808
|
-
* Ensures that at least one item is focusable if the list is interactive and
|
|
1809
|
-
* doesn't specify a suitable tabindex.
|
|
1810
|
-
*/
|
|
1811
|
-
MDCList.prototype.ensureFocusable = function () {
|
|
1812
|
-
if (this.isEvolutionEnabled && this.isInteractive) {
|
|
1813
|
-
if (!this.root.querySelector("." + this.classNameMap[cssClasses$3.LIST_ITEM_CLASS] + "[tabindex=\"0\"]")) {
|
|
1814
|
-
var index = this.initialFocusIndex();
|
|
1815
|
-
if (index !== -1) {
|
|
1816
|
-
this.listElements[index].tabIndex = 0;
|
|
1817
|
-
}
|
|
1818
|
-
}
|
|
1819
|
-
}
|
|
1820
|
-
};
|
|
1821
|
-
MDCList.prototype.initialFocusIndex = function () {
|
|
1822
|
-
if (this.selectedIndex instanceof Array && this.selectedIndex.length > 0) {
|
|
1823
|
-
return this.selectedIndex[0];
|
|
1824
|
-
}
|
|
1825
|
-
if (typeof this.selectedIndex === 'number' &&
|
|
1826
|
-
this.selectedIndex !== numbers$2.UNSET_INDEX) {
|
|
1827
|
-
return this.selectedIndex;
|
|
1828
|
-
}
|
|
1829
|
-
var el = this.root.querySelector("." + this.classNameMap[cssClasses$3.LIST_ITEM_CLASS] + ":not(." + this.classNameMap[cssClasses$3.LIST_ITEM_DISABLED_CLASS] + ")");
|
|
1830
|
-
if (el === null) {
|
|
1831
|
-
return -1;
|
|
1832
|
-
}
|
|
1833
|
-
return this.getListItemIndex(el);
|
|
1834
|
-
};
|
|
1835
|
-
/**
|
|
1836
|
-
* Used to figure out which list item this event is targetting. Or returns -1
|
|
1837
|
-
* if there is no list item
|
|
1838
|
-
*/
|
|
1839
|
-
MDCList.prototype.getListItemIndex = function (el) {
|
|
1840
|
-
var nearestParent = closest(el, "." + this.classNameMap[cssClasses$3.LIST_ITEM_CLASS] + ", ." + this.classNameMap[cssClasses$3.ROOT]);
|
|
1841
|
-
// Get the index of the element if it is a list item.
|
|
1842
|
-
if (nearestParent &&
|
|
1843
|
-
matches(nearestParent, "." + this.classNameMap[cssClasses$3.LIST_ITEM_CLASS])) {
|
|
1844
|
-
return this.listElements.indexOf(nearestParent);
|
|
1845
|
-
}
|
|
1846
|
-
return -1;
|
|
1847
|
-
};
|
|
1848
|
-
/**
|
|
1849
|
-
* Used to figure out which element was clicked before sending the event to
|
|
1850
|
-
* the foundation.
|
|
1851
|
-
*/
|
|
1852
|
-
MDCList.prototype.handleFocusInEvent = function (evt) {
|
|
1853
|
-
var index = this.getListItemIndex(evt.target);
|
|
1854
|
-
this.foundation.handleFocusIn(index);
|
|
1855
|
-
};
|
|
1856
|
-
/**
|
|
1857
|
-
* Used to figure out which element was clicked before sending the event to
|
|
1858
|
-
* the foundation.
|
|
1859
|
-
*/
|
|
1860
|
-
MDCList.prototype.handleFocusOutEvent = function (evt) {
|
|
1861
|
-
var index = this.getListItemIndex(evt.target);
|
|
1862
|
-
this.foundation.handleFocusOut(index);
|
|
1863
|
-
};
|
|
1864
|
-
/**
|
|
1865
|
-
* Used to figure out which element was focused when keydown event occurred
|
|
1866
|
-
* before sending the event to the foundation.
|
|
1867
|
-
*/
|
|
1868
|
-
MDCList.prototype.handleKeydownEvent = function (evt) {
|
|
1869
|
-
var index = this.getListItemIndex(evt.target);
|
|
1870
|
-
var target = evt.target;
|
|
1871
|
-
this.foundation.handleKeydown(evt, target.classList.contains(this.classNameMap[cssClasses$3.LIST_ITEM_CLASS]), index);
|
|
1872
|
-
};
|
|
1873
|
-
/**
|
|
1874
|
-
* Used to figure out which element was clicked before sending the event to
|
|
1875
|
-
* the foundation.
|
|
1876
|
-
*/
|
|
1877
|
-
MDCList.prototype.handleClickEvent = function (evt) {
|
|
1878
|
-
var index = this.getListItemIndex(evt.target);
|
|
1879
|
-
var target = evt.target;
|
|
1880
|
-
// Toggle the checkbox only if it's not the target of the event, or the
|
|
1881
|
-
// checkbox will have 2 change events.
|
|
1882
|
-
var toggleCheckbox = !matches(target, strings$4.CHECKBOX_RADIO_SELECTOR);
|
|
1883
|
-
this.foundation.handleClick(index, toggleCheckbox, evt);
|
|
1884
|
-
};
|
|
1885
|
-
return MDCList;
|
|
1886
|
-
}(MDCComponent));
|
|
1887
|
-
|
|
1888
|
-
/**
|
|
1889
|
-
* @license
|
|
1890
|
-
* Copyright 2018 Google Inc.
|
|
1891
|
-
*
|
|
1892
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1893
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
1894
|
-
* in the Software without restriction, including without limitation the rights
|
|
1895
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1896
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
1897
|
-
* furnished to do so, subject to the following conditions:
|
|
1898
|
-
*
|
|
1899
|
-
* The above copyright notice and this permission notice shall be included in
|
|
1900
|
-
* all copies or substantial portions of the Software.
|
|
1901
|
-
*
|
|
1902
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1903
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1904
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1905
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1906
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1907
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1908
|
-
* THE SOFTWARE.
|
|
1909
|
-
*/
|
|
1910
|
-
var MDCMenuSurfaceFoundation = /** @class */ (function (_super) {
|
|
1911
|
-
__extends(MDCMenuSurfaceFoundation, _super);
|
|
1912
|
-
function MDCMenuSurfaceFoundation(adapter) {
|
|
1913
|
-
var _this = _super.call(this, __assign(__assign({}, MDCMenuSurfaceFoundation.defaultAdapter), adapter)) || this;
|
|
1914
|
-
_this.isSurfaceOpen = false;
|
|
1915
|
-
_this.isQuickOpen = false;
|
|
1916
|
-
_this.isHoistedElement = false;
|
|
1917
|
-
_this.isFixedPosition = false;
|
|
1918
|
-
_this.isHorizontallyCenteredOnViewport = false;
|
|
1919
|
-
_this.maxHeight = 0;
|
|
1920
|
-
_this.openBottomBias = 0;
|
|
1921
|
-
_this.openAnimationEndTimerId = 0;
|
|
1922
|
-
_this.closeAnimationEndTimerId = 0;
|
|
1923
|
-
_this.animationRequestId = 0;
|
|
1924
|
-
_this.anchorCorner = Corner.TOP_START;
|
|
1925
|
-
/**
|
|
1926
|
-
* Corner of the menu surface to which menu surface is attached to anchor.
|
|
1927
|
-
*
|
|
1928
|
-
* Anchor corner --->+----------+
|
|
1929
|
-
* | ANCHOR |
|
|
1930
|
-
* +----------+
|
|
1931
|
-
* Origin corner --->+--------------+
|
|
1932
|
-
* | |
|
|
1933
|
-
* | |
|
|
1934
|
-
* | MENU SURFACE |
|
|
1935
|
-
* | |
|
|
1936
|
-
* | |
|
|
1937
|
-
* +--------------+
|
|
1938
|
-
*/
|
|
1939
|
-
_this.originCorner = Corner.TOP_START;
|
|
1940
|
-
_this.anchorMargin = { top: 0, right: 0, bottom: 0, left: 0 };
|
|
1941
|
-
_this.position = { x: 0, y: 0 };
|
|
1942
|
-
return _this;
|
|
1943
|
-
}
|
|
1944
|
-
Object.defineProperty(MDCMenuSurfaceFoundation, "cssClasses", {
|
|
1945
|
-
get: function () {
|
|
1946
|
-
return cssClasses$4;
|
|
1947
|
-
},
|
|
1948
|
-
enumerable: false,
|
|
1949
|
-
configurable: true
|
|
1950
|
-
});
|
|
1951
|
-
Object.defineProperty(MDCMenuSurfaceFoundation, "strings", {
|
|
1952
|
-
get: function () {
|
|
1953
|
-
return strings$5;
|
|
1954
|
-
},
|
|
1955
|
-
enumerable: false,
|
|
1956
|
-
configurable: true
|
|
1957
|
-
});
|
|
1958
|
-
Object.defineProperty(MDCMenuSurfaceFoundation, "numbers", {
|
|
1959
|
-
get: function () {
|
|
1960
|
-
return numbers$3;
|
|
1961
|
-
},
|
|
1962
|
-
enumerable: false,
|
|
1963
|
-
configurable: true
|
|
1964
|
-
});
|
|
1965
|
-
Object.defineProperty(MDCMenuSurfaceFoundation, "Corner", {
|
|
1966
|
-
get: function () {
|
|
1967
|
-
return Corner;
|
|
1968
|
-
},
|
|
1969
|
-
enumerable: false,
|
|
1970
|
-
configurable: true
|
|
1971
|
-
});
|
|
1972
|
-
Object.defineProperty(MDCMenuSurfaceFoundation, "defaultAdapter", {
|
|
1973
|
-
/**
|
|
1974
|
-
* @see {@link MDCMenuSurfaceAdapter} for typing information on parameters and return types.
|
|
1975
|
-
*/
|
|
1976
|
-
get: function () {
|
|
1977
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
1978
|
-
return {
|
|
1979
|
-
addClass: function () { return undefined; },
|
|
1980
|
-
removeClass: function () { return undefined; },
|
|
1981
|
-
hasClass: function () { return false; },
|
|
1982
|
-
hasAnchor: function () { return false; },
|
|
1983
|
-
isElementInContainer: function () { return false; },
|
|
1984
|
-
isFocused: function () { return false; },
|
|
1985
|
-
isRtl: function () { return false; },
|
|
1986
|
-
getInnerDimensions: function () { return ({ height: 0, width: 0 }); },
|
|
1987
|
-
getAnchorDimensions: function () { return null; },
|
|
1988
|
-
getWindowDimensions: function () { return ({ height: 0, width: 0 }); },
|
|
1989
|
-
getBodyDimensions: function () { return ({ height: 0, width: 0 }); },
|
|
1990
|
-
getWindowScroll: function () { return ({ x: 0, y: 0 }); },
|
|
1991
|
-
setPosition: function () { return undefined; },
|
|
1992
|
-
setMaxHeight: function () { return undefined; },
|
|
1993
|
-
setTransformOrigin: function () { return undefined; },
|
|
1994
|
-
saveFocus: function () { return undefined; },
|
|
1995
|
-
restoreFocus: function () { return undefined; },
|
|
1996
|
-
notifyClose: function () { return undefined; },
|
|
1997
|
-
notifyClosing: function () { return undefined; },
|
|
1998
|
-
notifyOpen: function () { return undefined; },
|
|
1999
|
-
notifyOpening: function () { return undefined; },
|
|
2000
|
-
};
|
|
2001
|
-
// tslint:enable:object-literal-sort-keys
|
|
2002
|
-
},
|
|
2003
|
-
enumerable: false,
|
|
2004
|
-
configurable: true
|
|
2005
|
-
});
|
|
2006
|
-
MDCMenuSurfaceFoundation.prototype.init = function () {
|
|
2007
|
-
var _a = MDCMenuSurfaceFoundation.cssClasses, ROOT = _a.ROOT, OPEN = _a.OPEN;
|
|
2008
|
-
if (!this.adapter.hasClass(ROOT)) {
|
|
2009
|
-
throw new Error(ROOT + " class required in root element.");
|
|
2010
|
-
}
|
|
2011
|
-
if (this.adapter.hasClass(OPEN)) {
|
|
2012
|
-
this.isSurfaceOpen = true;
|
|
2013
|
-
}
|
|
2014
|
-
};
|
|
2015
|
-
MDCMenuSurfaceFoundation.prototype.destroy = function () {
|
|
2016
|
-
clearTimeout(this.openAnimationEndTimerId);
|
|
2017
|
-
clearTimeout(this.closeAnimationEndTimerId);
|
|
2018
|
-
// Cancel any currently running animations.
|
|
2019
|
-
cancelAnimationFrame(this.animationRequestId);
|
|
2020
|
-
};
|
|
2021
|
-
/**
|
|
2022
|
-
* @param corner Default anchor corner alignment of top-left menu surface
|
|
2023
|
-
* corner.
|
|
2024
|
-
*/
|
|
2025
|
-
MDCMenuSurfaceFoundation.prototype.setAnchorCorner = function (corner) {
|
|
2026
|
-
this.anchorCorner = corner;
|
|
2027
|
-
};
|
|
2028
|
-
/**
|
|
2029
|
-
* Flip menu corner horizontally.
|
|
2030
|
-
*/
|
|
2031
|
-
MDCMenuSurfaceFoundation.prototype.flipCornerHorizontally = function () {
|
|
2032
|
-
this.originCorner = this.originCorner ^ CornerBit.RIGHT;
|
|
2033
|
-
};
|
|
2034
|
-
/**
|
|
2035
|
-
* @param margin Set of margin values from anchor.
|
|
2036
|
-
*/
|
|
2037
|
-
MDCMenuSurfaceFoundation.prototype.setAnchorMargin = function (margin) {
|
|
2038
|
-
this.anchorMargin.top = margin.top || 0;
|
|
2039
|
-
this.anchorMargin.right = margin.right || 0;
|
|
2040
|
-
this.anchorMargin.bottom = margin.bottom || 0;
|
|
2041
|
-
this.anchorMargin.left = margin.left || 0;
|
|
2042
|
-
};
|
|
2043
|
-
/** Used to indicate if the menu-surface is hoisted to the body. */
|
|
2044
|
-
MDCMenuSurfaceFoundation.prototype.setIsHoisted = function (isHoisted) {
|
|
2045
|
-
this.isHoistedElement = isHoisted;
|
|
2046
|
-
};
|
|
2047
|
-
/**
|
|
2048
|
-
* Used to set the menu-surface calculations based on a fixed position menu.
|
|
2049
|
-
*/
|
|
2050
|
-
MDCMenuSurfaceFoundation.prototype.setFixedPosition = function (isFixedPosition) {
|
|
2051
|
-
this.isFixedPosition = isFixedPosition;
|
|
2052
|
-
};
|
|
2053
|
-
/**
|
|
2054
|
-
* @return Returns true if menu is in fixed (`position: fixed`) position.
|
|
2055
|
-
*/
|
|
2056
|
-
MDCMenuSurfaceFoundation.prototype.isFixed = function () {
|
|
2057
|
-
return this.isFixedPosition;
|
|
2058
|
-
};
|
|
2059
|
-
/** Sets the menu-surface position on the page. */
|
|
2060
|
-
MDCMenuSurfaceFoundation.prototype.setAbsolutePosition = function (x, y) {
|
|
2061
|
-
this.position.x = this.isFinite(x) ? x : 0;
|
|
2062
|
-
this.position.y = this.isFinite(y) ? y : 0;
|
|
2063
|
-
};
|
|
2064
|
-
/** Sets whether menu-surface should be horizontally centered to viewport. */
|
|
2065
|
-
MDCMenuSurfaceFoundation.prototype.setIsHorizontallyCenteredOnViewport = function (isCentered) {
|
|
2066
|
-
this.isHorizontallyCenteredOnViewport = isCentered;
|
|
2067
|
-
};
|
|
2068
|
-
MDCMenuSurfaceFoundation.prototype.setQuickOpen = function (quickOpen) {
|
|
2069
|
-
this.isQuickOpen = quickOpen;
|
|
2070
|
-
};
|
|
2071
|
-
/**
|
|
2072
|
-
* Sets maximum menu-surface height on open.
|
|
2073
|
-
* @param maxHeight The desired max-height. Set to 0 (default) to
|
|
2074
|
-
* automatically calculate max height based on available viewport space.
|
|
2075
|
-
*/
|
|
2076
|
-
MDCMenuSurfaceFoundation.prototype.setMaxHeight = function (maxHeight) {
|
|
2077
|
-
this.maxHeight = maxHeight;
|
|
2078
|
-
};
|
|
2079
|
-
/**
|
|
2080
|
-
* Set to a positive integer to influence the menu to preferentially open
|
|
2081
|
-
* below the anchor instead of above.
|
|
2082
|
-
* @param bias A value of `x` simulates an extra `x` pixels of available space
|
|
2083
|
-
* below the menu during positioning calculations.
|
|
2084
|
-
*/
|
|
2085
|
-
MDCMenuSurfaceFoundation.prototype.setOpenBottomBias = function (bias) {
|
|
2086
|
-
this.openBottomBias = bias;
|
|
2087
|
-
};
|
|
2088
|
-
MDCMenuSurfaceFoundation.prototype.isOpen = function () {
|
|
2089
|
-
return this.isSurfaceOpen;
|
|
2090
|
-
};
|
|
2091
|
-
/**
|
|
2092
|
-
* Open the menu surface.
|
|
2093
|
-
*/
|
|
2094
|
-
MDCMenuSurfaceFoundation.prototype.open = function () {
|
|
2095
|
-
var _this = this;
|
|
2096
|
-
if (this.isSurfaceOpen) {
|
|
2097
|
-
return;
|
|
2098
|
-
}
|
|
2099
|
-
this.adapter.notifyOpening();
|
|
2100
|
-
this.adapter.saveFocus();
|
|
2101
|
-
if (this.isQuickOpen) {
|
|
2102
|
-
this.isSurfaceOpen = true;
|
|
2103
|
-
this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
|
|
2104
|
-
this.dimensions = this.adapter.getInnerDimensions();
|
|
2105
|
-
this.autoposition();
|
|
2106
|
-
this.adapter.notifyOpen();
|
|
2107
|
-
}
|
|
2108
|
-
else {
|
|
2109
|
-
this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
|
|
2110
|
-
this.animationRequestId = requestAnimationFrame(function () {
|
|
2111
|
-
_this.dimensions = _this.adapter.getInnerDimensions();
|
|
2112
|
-
_this.autoposition();
|
|
2113
|
-
_this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
|
|
2114
|
-
_this.openAnimationEndTimerId = setTimeout(function () {
|
|
2115
|
-
_this.openAnimationEndTimerId = 0;
|
|
2116
|
-
_this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
|
|
2117
|
-
_this.adapter.notifyOpen();
|
|
2118
|
-
}, numbers$3.TRANSITION_OPEN_DURATION);
|
|
2119
|
-
});
|
|
2120
|
-
this.isSurfaceOpen = true;
|
|
2121
|
-
}
|
|
2122
|
-
};
|
|
2123
|
-
/**
|
|
2124
|
-
* Closes the menu surface.
|
|
2125
|
-
*/
|
|
2126
|
-
MDCMenuSurfaceFoundation.prototype.close = function (skipRestoreFocus) {
|
|
2127
|
-
var _this = this;
|
|
2128
|
-
if (skipRestoreFocus === void 0) { skipRestoreFocus = false; }
|
|
2129
|
-
if (!this.isSurfaceOpen) {
|
|
2130
|
-
return;
|
|
2131
|
-
}
|
|
2132
|
-
this.adapter.notifyClosing();
|
|
2133
|
-
if (this.isQuickOpen) {
|
|
2134
|
-
this.isSurfaceOpen = false;
|
|
2135
|
-
if (!skipRestoreFocus) {
|
|
2136
|
-
this.maybeRestoreFocus();
|
|
2137
|
-
}
|
|
2138
|
-
this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
|
|
2139
|
-
this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
|
|
2140
|
-
this.adapter.notifyClose();
|
|
2141
|
-
return;
|
|
2142
|
-
}
|
|
2143
|
-
this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
|
|
2144
|
-
requestAnimationFrame(function () {
|
|
2145
|
-
_this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
|
|
2146
|
-
_this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
|
|
2147
|
-
_this.closeAnimationEndTimerId = setTimeout(function () {
|
|
2148
|
-
_this.closeAnimationEndTimerId = 0;
|
|
2149
|
-
_this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
|
|
2150
|
-
_this.adapter.notifyClose();
|
|
2151
|
-
}, numbers$3.TRANSITION_CLOSE_DURATION);
|
|
2152
|
-
});
|
|
2153
|
-
this.isSurfaceOpen = false;
|
|
2154
|
-
if (!skipRestoreFocus) {
|
|
2155
|
-
this.maybeRestoreFocus();
|
|
2156
|
-
}
|
|
2157
|
-
};
|
|
2158
|
-
/** Handle clicks and close if not within menu-surface element. */
|
|
2159
|
-
MDCMenuSurfaceFoundation.prototype.handleBodyClick = function (evt) {
|
|
2160
|
-
var el = evt.target;
|
|
2161
|
-
if (this.adapter.isElementInContainer(el)) {
|
|
2162
|
-
return;
|
|
2163
|
-
}
|
|
2164
|
-
this.close();
|
|
2165
|
-
};
|
|
2166
|
-
/** Handle keys that close the surface. */
|
|
2167
|
-
MDCMenuSurfaceFoundation.prototype.handleKeydown = function (evt) {
|
|
2168
|
-
var keyCode = evt.keyCode, key = evt.key;
|
|
2169
|
-
var isEscape = key === 'Escape' || keyCode === 27;
|
|
2170
|
-
if (isEscape) {
|
|
2171
|
-
this.close();
|
|
2172
|
-
}
|
|
2173
|
-
};
|
|
2174
|
-
MDCMenuSurfaceFoundation.prototype.autoposition = function () {
|
|
2175
|
-
var _a;
|
|
2176
|
-
// Compute measurements for autoposition methods reuse.
|
|
2177
|
-
this.measurements = this.getAutoLayoutmeasurements();
|
|
2178
|
-
var corner = this.getoriginCorner();
|
|
2179
|
-
var maxMenuSurfaceHeight = this.getMenuSurfaceMaxHeight(corner);
|
|
2180
|
-
var verticalAlignment = this.hasBit(corner, CornerBit.BOTTOM) ? 'bottom' : 'top';
|
|
2181
|
-
var horizontalAlignment = this.hasBit(corner, CornerBit.RIGHT) ? 'right' : 'left';
|
|
2182
|
-
var horizontalOffset = this.getHorizontalOriginOffset(corner);
|
|
2183
|
-
var verticalOffset = this.getVerticalOriginOffset(corner);
|
|
2184
|
-
var _b = this.measurements, anchorSize = _b.anchorSize, surfaceSize = _b.surfaceSize;
|
|
2185
|
-
var position = (_a = {},
|
|
2186
|
-
_a[horizontalAlignment] = horizontalOffset,
|
|
2187
|
-
_a[verticalAlignment] = verticalOffset,
|
|
2188
|
-
_a);
|
|
2189
|
-
// Center align when anchor width is comparable or greater than menu
|
|
2190
|
-
// surface, otherwise keep corner.
|
|
2191
|
-
if (anchorSize.width / surfaceSize.width >
|
|
2192
|
-
numbers$3.ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO) {
|
|
2193
|
-
horizontalAlignment = 'center';
|
|
2194
|
-
}
|
|
2195
|
-
// If the menu-surface has been hoisted to the body, it's no longer relative
|
|
2196
|
-
// to the anchor element
|
|
2197
|
-
if (this.isHoistedElement || this.isFixedPosition) {
|
|
2198
|
-
this.adjustPositionForHoistedElement(position);
|
|
2199
|
-
}
|
|
2200
|
-
this.adapter.setTransformOrigin(horizontalAlignment + " " + verticalAlignment);
|
|
2201
|
-
this.adapter.setPosition(position);
|
|
2202
|
-
this.adapter.setMaxHeight(maxMenuSurfaceHeight ? maxMenuSurfaceHeight + 'px' : '');
|
|
2203
|
-
// If it is opened from the top then add is-open-below class
|
|
2204
|
-
if (!this.hasBit(corner, CornerBit.BOTTOM)) {
|
|
2205
|
-
this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
|
|
2206
|
-
}
|
|
2207
|
-
};
|
|
2208
|
-
/**
|
|
2209
|
-
* @return Measurements used to position menu surface popup.
|
|
2210
|
-
*/
|
|
2211
|
-
MDCMenuSurfaceFoundation.prototype.getAutoLayoutmeasurements = function () {
|
|
2212
|
-
var anchorRect = this.adapter.getAnchorDimensions();
|
|
2213
|
-
var bodySize = this.adapter.getBodyDimensions();
|
|
2214
|
-
var viewportSize = this.adapter.getWindowDimensions();
|
|
2215
|
-
var windowScroll = this.adapter.getWindowScroll();
|
|
2216
|
-
if (!anchorRect) {
|
|
2217
|
-
// tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together
|
|
2218
|
-
anchorRect = {
|
|
2219
|
-
top: this.position.y,
|
|
2220
|
-
right: this.position.x,
|
|
2221
|
-
bottom: this.position.y,
|
|
2222
|
-
left: this.position.x,
|
|
2223
|
-
width: 0,
|
|
2224
|
-
height: 0,
|
|
2225
|
-
};
|
|
2226
|
-
// tslint:enable:object-literal-sort-keys
|
|
2227
|
-
}
|
|
2228
|
-
return {
|
|
2229
|
-
anchorSize: anchorRect,
|
|
2230
|
-
bodySize: bodySize,
|
|
2231
|
-
surfaceSize: this.dimensions,
|
|
2232
|
-
viewportDistance: {
|
|
2233
|
-
// tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together
|
|
2234
|
-
top: anchorRect.top,
|
|
2235
|
-
right: viewportSize.width - anchorRect.right,
|
|
2236
|
-
bottom: viewportSize.height - anchorRect.bottom,
|
|
2237
|
-
left: anchorRect.left,
|
|
2238
|
-
// tslint:enable:object-literal-sort-keys
|
|
2239
|
-
},
|
|
2240
|
-
viewportSize: viewportSize,
|
|
2241
|
-
windowScroll: windowScroll,
|
|
2242
|
-
};
|
|
2243
|
-
};
|
|
2244
|
-
/**
|
|
2245
|
-
* Computes the corner of the anchor from which to animate and position the
|
|
2246
|
-
* menu surface.
|
|
2247
|
-
*
|
|
2248
|
-
* Only LEFT or RIGHT bit is used to position the menu surface ignoring RTL
|
|
2249
|
-
* context. E.g., menu surface will be positioned from right side on TOP_END.
|
|
2250
|
-
*/
|
|
2251
|
-
MDCMenuSurfaceFoundation.prototype.getoriginCorner = function () {
|
|
2252
|
-
var corner = this.originCorner;
|
|
2253
|
-
var _a = this.measurements, viewportDistance = _a.viewportDistance, anchorSize = _a.anchorSize, surfaceSize = _a.surfaceSize;
|
|
2254
|
-
var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE;
|
|
2255
|
-
var isAnchoredToBottom = this.hasBit(this.anchorCorner, CornerBit.BOTTOM);
|
|
2256
|
-
var availableTop;
|
|
2257
|
-
var availableBottom;
|
|
2258
|
-
if (isAnchoredToBottom) {
|
|
2259
|
-
availableTop =
|
|
2260
|
-
viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.bottom;
|
|
2261
|
-
availableBottom =
|
|
2262
|
-
viewportDistance.bottom - MARGIN_TO_EDGE - this.anchorMargin.bottom;
|
|
2263
|
-
}
|
|
2264
|
-
else {
|
|
2265
|
-
availableTop =
|
|
2266
|
-
viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.top;
|
|
2267
|
-
availableBottom = viewportDistance.bottom - MARGIN_TO_EDGE +
|
|
2268
|
-
anchorSize.height - this.anchorMargin.top;
|
|
2269
|
-
}
|
|
2270
|
-
var isAvailableBottom = availableBottom - surfaceSize.height > 0;
|
|
2271
|
-
if (!isAvailableBottom &&
|
|
2272
|
-
availableTop > availableBottom + this.openBottomBias) {
|
|
2273
|
-
// Attach bottom side of surface to the anchor.
|
|
2274
|
-
corner = this.setBit(corner, CornerBit.BOTTOM);
|
|
2275
|
-
}
|
|
2276
|
-
var isRtl = this.adapter.isRtl();
|
|
2277
|
-
var isFlipRtl = this.hasBit(this.anchorCorner, CornerBit.FLIP_RTL);
|
|
2278
|
-
var hasRightBit = this.hasBit(this.anchorCorner, CornerBit.RIGHT) ||
|
|
2279
|
-
this.hasBit(corner, CornerBit.RIGHT);
|
|
2280
|
-
// Whether surface attached to right side of anchor element.
|
|
2281
|
-
var isAnchoredToRight = false;
|
|
2282
|
-
// Anchored to start
|
|
2283
|
-
if (isRtl && isFlipRtl) {
|
|
2284
|
-
isAnchoredToRight = !hasRightBit;
|
|
2285
|
-
}
|
|
2286
|
-
else {
|
|
2287
|
-
// Anchored to right
|
|
2288
|
-
isAnchoredToRight = hasRightBit;
|
|
2289
|
-
}
|
|
2290
|
-
var availableLeft;
|
|
2291
|
-
var availableRight;
|
|
2292
|
-
if (isAnchoredToRight) {
|
|
2293
|
-
availableLeft =
|
|
2294
|
-
viewportDistance.left + anchorSize.width + this.anchorMargin.right;
|
|
2295
|
-
availableRight = viewportDistance.right - this.anchorMargin.right;
|
|
2296
|
-
}
|
|
2297
|
-
else {
|
|
2298
|
-
availableLeft = viewportDistance.left + this.anchorMargin.left;
|
|
2299
|
-
availableRight =
|
|
2300
|
-
viewportDistance.right + anchorSize.width - this.anchorMargin.left;
|
|
2301
|
-
}
|
|
2302
|
-
var isAvailableLeft = availableLeft - surfaceSize.width > 0;
|
|
2303
|
-
var isAvailableRight = availableRight - surfaceSize.width > 0;
|
|
2304
|
-
var isOriginCornerAlignedToEnd = this.hasBit(corner, CornerBit.FLIP_RTL) &&
|
|
2305
|
-
this.hasBit(corner, CornerBit.RIGHT);
|
|
2306
|
-
if (isAvailableRight && isOriginCornerAlignedToEnd && isRtl ||
|
|
2307
|
-
!isAvailableLeft && isOriginCornerAlignedToEnd) {
|
|
2308
|
-
// Attach left side of surface to the anchor.
|
|
2309
|
-
corner = this.unsetBit(corner, CornerBit.RIGHT);
|
|
2310
|
-
}
|
|
2311
|
-
else if (isAvailableLeft && isAnchoredToRight && isRtl ||
|
|
2312
|
-
(isAvailableLeft && !isAnchoredToRight && hasRightBit) ||
|
|
2313
|
-
(!isAvailableRight && availableLeft >= availableRight)) {
|
|
2314
|
-
// Attach right side of surface to the anchor.
|
|
2315
|
-
corner = this.setBit(corner, CornerBit.RIGHT);
|
|
2316
|
-
}
|
|
2317
|
-
return corner;
|
|
2318
|
-
};
|
|
2319
|
-
/**
|
|
2320
|
-
* @param corner Origin corner of the menu surface.
|
|
2321
|
-
* @return Maximum height of the menu surface, based on available space. 0
|
|
2322
|
-
* indicates should not be set.
|
|
2323
|
-
*/
|
|
2324
|
-
MDCMenuSurfaceFoundation.prototype.getMenuSurfaceMaxHeight = function (corner) {
|
|
2325
|
-
if (this.maxHeight > 0) {
|
|
2326
|
-
return this.maxHeight;
|
|
2327
|
-
}
|
|
2328
|
-
var viewportDistance = this.measurements.viewportDistance;
|
|
2329
|
-
var maxHeight = 0;
|
|
2330
|
-
var isBottomAligned = this.hasBit(corner, CornerBit.BOTTOM);
|
|
2331
|
-
var isBottomAnchored = this.hasBit(this.anchorCorner, CornerBit.BOTTOM);
|
|
2332
|
-
var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE;
|
|
2333
|
-
// When maximum height is not specified, it is handled from CSS.
|
|
2334
|
-
if (isBottomAligned) {
|
|
2335
|
-
maxHeight = viewportDistance.top + this.anchorMargin.top - MARGIN_TO_EDGE;
|
|
2336
|
-
if (!isBottomAnchored) {
|
|
2337
|
-
maxHeight += this.measurements.anchorSize.height;
|
|
2338
|
-
}
|
|
2339
|
-
}
|
|
2340
|
-
else {
|
|
2341
|
-
maxHeight = viewportDistance.bottom - this.anchorMargin.bottom +
|
|
2342
|
-
this.measurements.anchorSize.height - MARGIN_TO_EDGE;
|
|
2343
|
-
if (isBottomAnchored) {
|
|
2344
|
-
maxHeight -= this.measurements.anchorSize.height;
|
|
2345
|
-
}
|
|
2346
|
-
}
|
|
2347
|
-
return maxHeight;
|
|
2348
|
-
};
|
|
2349
|
-
/**
|
|
2350
|
-
* @param corner Origin corner of the menu surface.
|
|
2351
|
-
* @return Horizontal offset of menu surface origin corner from corresponding
|
|
2352
|
-
* anchor corner.
|
|
2353
|
-
*/
|
|
2354
|
-
MDCMenuSurfaceFoundation.prototype.getHorizontalOriginOffset = function (corner) {
|
|
2355
|
-
var anchorSize = this.measurements.anchorSize;
|
|
2356
|
-
// isRightAligned corresponds to using the 'right' property on the surface.
|
|
2357
|
-
var isRightAligned = this.hasBit(corner, CornerBit.RIGHT);
|
|
2358
|
-
var avoidHorizontalOverlap = this.hasBit(this.anchorCorner, CornerBit.RIGHT);
|
|
2359
|
-
if (isRightAligned) {
|
|
2360
|
-
var rightOffset = avoidHorizontalOverlap ?
|
|
2361
|
-
anchorSize.width - this.anchorMargin.left :
|
|
2362
|
-
this.anchorMargin.right;
|
|
2363
|
-
// For hoisted or fixed elements, adjust the offset by the difference
|
|
2364
|
-
// between viewport width and body width so when we calculate the right
|
|
2365
|
-
// value (`adjustPositionForHoistedElement`) based on the element
|
|
2366
|
-
// position, the right property is correct.
|
|
2367
|
-
if (this.isHoistedElement || this.isFixedPosition) {
|
|
2368
|
-
return rightOffset -
|
|
2369
|
-
(this.measurements.viewportSize.width -
|
|
2370
|
-
this.measurements.bodySize.width);
|
|
2371
|
-
}
|
|
2372
|
-
return rightOffset;
|
|
2373
|
-
}
|
|
2374
|
-
return avoidHorizontalOverlap ? anchorSize.width - this.anchorMargin.right :
|
|
2375
|
-
this.anchorMargin.left;
|
|
2376
|
-
};
|
|
2377
|
-
/**
|
|
2378
|
-
* @param corner Origin corner of the menu surface.
|
|
2379
|
-
* @return Vertical offset of menu surface origin corner from corresponding
|
|
2380
|
-
* anchor corner.
|
|
2381
|
-
*/
|
|
2382
|
-
MDCMenuSurfaceFoundation.prototype.getVerticalOriginOffset = function (corner) {
|
|
2383
|
-
var anchorSize = this.measurements.anchorSize;
|
|
2384
|
-
var isBottomAligned = this.hasBit(corner, CornerBit.BOTTOM);
|
|
2385
|
-
var avoidVerticalOverlap = this.hasBit(this.anchorCorner, CornerBit.BOTTOM);
|
|
2386
|
-
var y = 0;
|
|
2387
|
-
if (isBottomAligned) {
|
|
2388
|
-
y = avoidVerticalOverlap ? anchorSize.height - this.anchorMargin.top :
|
|
2389
|
-
-this.anchorMargin.bottom;
|
|
2390
|
-
}
|
|
2391
|
-
else {
|
|
2392
|
-
y = avoidVerticalOverlap ?
|
|
2393
|
-
(anchorSize.height + this.anchorMargin.bottom) :
|
|
2394
|
-
this.anchorMargin.top;
|
|
2395
|
-
}
|
|
2396
|
-
return y;
|
|
2397
|
-
};
|
|
2398
|
-
/**
|
|
2399
|
-
* Calculates the offsets for positioning the menu-surface when the
|
|
2400
|
-
* menu-surface has been hoisted to the body.
|
|
2401
|
-
*/
|
|
2402
|
-
MDCMenuSurfaceFoundation.prototype.adjustPositionForHoistedElement = function (position) {
|
|
2403
|
-
var e_1, _a;
|
|
2404
|
-
var _b = this.measurements, windowScroll = _b.windowScroll, viewportDistance = _b.viewportDistance, surfaceSize = _b.surfaceSize, viewportSize = _b.viewportSize;
|
|
2405
|
-
var props = Object.keys(position);
|
|
2406
|
-
try {
|
|
2407
|
-
for (var props_1 = __values(props), props_1_1 = props_1.next(); !props_1_1.done; props_1_1 = props_1.next()) {
|
|
2408
|
-
var prop = props_1_1.value;
|
|
2409
|
-
var value = position[prop] || 0;
|
|
2410
|
-
if (this.isHorizontallyCenteredOnViewport &&
|
|
2411
|
-
(prop === 'left' || prop === 'right')) {
|
|
2412
|
-
position[prop] = (viewportSize.width - surfaceSize.width) / 2;
|
|
2413
|
-
continue;
|
|
2414
|
-
}
|
|
2415
|
-
// Hoisted surfaces need to have the anchor elements location on the page
|
|
2416
|
-
// added to the position properties for proper alignment on the body.
|
|
2417
|
-
value += viewportDistance[prop];
|
|
2418
|
-
// Surfaces that are absolutely positioned need to have additional
|
|
2419
|
-
// calculations for scroll and bottom positioning.
|
|
2420
|
-
if (!this.isFixedPosition) {
|
|
2421
|
-
if (prop === 'top') {
|
|
2422
|
-
value += windowScroll.y;
|
|
2423
|
-
}
|
|
2424
|
-
else if (prop === 'bottom') {
|
|
2425
|
-
value -= windowScroll.y;
|
|
2426
|
-
}
|
|
2427
|
-
else if (prop === 'left') {
|
|
2428
|
-
value += windowScroll.x;
|
|
2429
|
-
}
|
|
2430
|
-
else { // prop === 'right'
|
|
2431
|
-
value -= windowScroll.x;
|
|
2432
|
-
}
|
|
2433
|
-
}
|
|
2434
|
-
position[prop] = value;
|
|
2435
|
-
}
|
|
2436
|
-
}
|
|
2437
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2438
|
-
finally {
|
|
2439
|
-
try {
|
|
2440
|
-
if (props_1_1 && !props_1_1.done && (_a = props_1.return)) _a.call(props_1);
|
|
2441
|
-
}
|
|
2442
|
-
finally { if (e_1) throw e_1.error; }
|
|
2443
|
-
}
|
|
2444
|
-
};
|
|
2445
|
-
/**
|
|
2446
|
-
* The last focused element when the menu surface was opened should regain
|
|
2447
|
-
* focus, if the user is focused on or within the menu surface when it is
|
|
2448
|
-
* closed.
|
|
2449
|
-
*/
|
|
2450
|
-
MDCMenuSurfaceFoundation.prototype.maybeRestoreFocus = function () {
|
|
2451
|
-
var _this = this;
|
|
2452
|
-
var isRootFocused = this.adapter.isFocused();
|
|
2453
|
-
var ownerDocument = this.adapter.getOwnerDocument ?
|
|
2454
|
-
this.adapter.getOwnerDocument() :
|
|
2455
|
-
document;
|
|
2456
|
-
var childHasFocus = ownerDocument.activeElement &&
|
|
2457
|
-
this.adapter.isElementInContainer(ownerDocument.activeElement);
|
|
2458
|
-
if (isRootFocused || childHasFocus) {
|
|
2459
|
-
// Wait before restoring focus when closing the menu surface. This is
|
|
2460
|
-
// important because if a touch event triggered the menu close, and the
|
|
2461
|
-
// subsequent mouse event occurs after focus is restored, then the
|
|
2462
|
-
// restored focus would be lost.
|
|
2463
|
-
setTimeout(function () {
|
|
2464
|
-
_this.adapter.restoreFocus();
|
|
2465
|
-
}, numbers$3.TOUCH_EVENT_WAIT_MS);
|
|
2466
|
-
}
|
|
2467
|
-
};
|
|
2468
|
-
MDCMenuSurfaceFoundation.prototype.hasBit = function (corner, bit) {
|
|
2469
|
-
return Boolean(corner & bit); // tslint:disable-line:no-bitwise
|
|
2470
|
-
};
|
|
2471
|
-
MDCMenuSurfaceFoundation.prototype.setBit = function (corner, bit) {
|
|
2472
|
-
return corner | bit; // tslint:disable-line:no-bitwise
|
|
2473
|
-
};
|
|
2474
|
-
MDCMenuSurfaceFoundation.prototype.unsetBit = function (corner, bit) {
|
|
2475
|
-
return corner ^ bit;
|
|
2476
|
-
};
|
|
2477
|
-
/**
|
|
2478
|
-
* isFinite that doesn't force conversion to number type.
|
|
2479
|
-
* Equivalent to Number.isFinite in ES2015, which is not supported in IE.
|
|
2480
|
-
*/
|
|
2481
|
-
MDCMenuSurfaceFoundation.prototype.isFinite = function (num) {
|
|
2482
|
-
return typeof num === 'number' && isFinite(num);
|
|
2483
|
-
};
|
|
2484
|
-
return MDCMenuSurfaceFoundation;
|
|
2485
|
-
}(MDCFoundation));
|
|
2486
|
-
|
|
2487
|
-
/**
|
|
2488
|
-
* @license
|
|
2489
|
-
* Copyright 2018 Google Inc.
|
|
2490
|
-
*
|
|
2491
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
2492
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
2493
|
-
* in the Software without restriction, including without limitation the rights
|
|
2494
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
2495
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
2496
|
-
* furnished to do so, subject to the following conditions:
|
|
2497
|
-
*
|
|
2498
|
-
* The above copyright notice and this permission notice shall be included in
|
|
2499
|
-
* all copies or substantial portions of the Software.
|
|
2500
|
-
*
|
|
2501
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
2502
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
2503
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
2504
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
2505
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
2506
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
2507
|
-
* THE SOFTWARE.
|
|
2508
|
-
*/
|
|
2509
|
-
var MDCMenuSurface = /** @class */ (function (_super) {
|
|
2510
|
-
__extends(MDCMenuSurface, _super);
|
|
2511
|
-
function MDCMenuSurface() {
|
|
2512
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
2513
|
-
}
|
|
2514
|
-
MDCMenuSurface.attachTo = function (root) {
|
|
2515
|
-
return new MDCMenuSurface(root);
|
|
2516
|
-
};
|
|
2517
|
-
MDCMenuSurface.prototype.initialSyncWithDOM = function () {
|
|
2518
|
-
var _this = this;
|
|
2519
|
-
var parentEl = this.root.parentElement;
|
|
2520
|
-
this.anchorElement = parentEl && parentEl.classList.contains(cssClasses$4.ANCHOR) ? parentEl : null;
|
|
2521
|
-
if (this.root.classList.contains(cssClasses$4.FIXED)) {
|
|
2522
|
-
this.setFixedPosition(true);
|
|
2523
|
-
}
|
|
2524
|
-
this.handleKeydown = function (event) {
|
|
2525
|
-
_this.foundation.handleKeydown(event);
|
|
2526
|
-
};
|
|
2527
|
-
this.handleBodyClick = function (event) {
|
|
2528
|
-
_this.foundation.handleBodyClick(event);
|
|
2529
|
-
};
|
|
2530
|
-
// capture so that no race between handleBodyClick and quickOpen when
|
|
2531
|
-
// menusurface opened on button click which registers this listener
|
|
2532
|
-
this.registerBodyClickListener = function () {
|
|
2533
|
-
document.body.addEventListener('click', _this.handleBodyClick, { capture: true });
|
|
2534
|
-
};
|
|
2535
|
-
this.deregisterBodyClickListener = function () {
|
|
2536
|
-
document.body.removeEventListener('click', _this.handleBodyClick, { capture: true });
|
|
2537
|
-
};
|
|
2538
|
-
this.listen('keydown', this.handleKeydown);
|
|
2539
|
-
this.listen(strings$5.OPENED_EVENT, this.registerBodyClickListener);
|
|
2540
|
-
this.listen(strings$5.CLOSED_EVENT, this.deregisterBodyClickListener);
|
|
2541
|
-
};
|
|
2542
|
-
MDCMenuSurface.prototype.destroy = function () {
|
|
2543
|
-
this.unlisten('keydown', this.handleKeydown);
|
|
2544
|
-
this.unlisten(strings$5.OPENED_EVENT, this.registerBodyClickListener);
|
|
2545
|
-
this.unlisten(strings$5.CLOSED_EVENT, this.deregisterBodyClickListener);
|
|
2546
|
-
_super.prototype.destroy.call(this);
|
|
2547
|
-
};
|
|
2548
|
-
MDCMenuSurface.prototype.isOpen = function () {
|
|
2549
|
-
return this.foundation.isOpen();
|
|
2550
|
-
};
|
|
2551
|
-
MDCMenuSurface.prototype.open = function () {
|
|
2552
|
-
this.foundation.open();
|
|
2553
|
-
};
|
|
2554
|
-
MDCMenuSurface.prototype.close = function (skipRestoreFocus) {
|
|
2555
|
-
if (skipRestoreFocus === void 0) { skipRestoreFocus = false; }
|
|
2556
|
-
this.foundation.close(skipRestoreFocus);
|
|
2557
|
-
};
|
|
2558
|
-
Object.defineProperty(MDCMenuSurface.prototype, "quickOpen", {
|
|
2559
|
-
set: function (quickOpen) {
|
|
2560
|
-
this.foundation.setQuickOpen(quickOpen);
|
|
2561
|
-
},
|
|
2562
|
-
enumerable: false,
|
|
2563
|
-
configurable: true
|
|
2564
|
-
});
|
|
2565
|
-
/** Sets the foundation to use page offsets for an positioning when the menu is hoisted to the body. */
|
|
2566
|
-
MDCMenuSurface.prototype.setIsHoisted = function (isHoisted) {
|
|
2567
|
-
this.foundation.setIsHoisted(isHoisted);
|
|
2568
|
-
};
|
|
2569
|
-
/** Sets the element that the menu-surface is anchored to. */
|
|
2570
|
-
MDCMenuSurface.prototype.setMenuSurfaceAnchorElement = function (element) {
|
|
2571
|
-
this.anchorElement = element;
|
|
2572
|
-
};
|
|
2573
|
-
/** Sets the menu-surface to position: fixed. */
|
|
2574
|
-
MDCMenuSurface.prototype.setFixedPosition = function (isFixed) {
|
|
2575
|
-
if (isFixed) {
|
|
2576
|
-
this.root.classList.add(cssClasses$4.FIXED);
|
|
2577
|
-
}
|
|
2578
|
-
else {
|
|
2579
|
-
this.root.classList.remove(cssClasses$4.FIXED);
|
|
2580
|
-
}
|
|
2581
|
-
this.foundation.setFixedPosition(isFixed);
|
|
2582
|
-
};
|
|
2583
|
-
/** Sets the absolute x/y position to position based on. Requires the menu to be hoisted. */
|
|
2584
|
-
MDCMenuSurface.prototype.setAbsolutePosition = function (x, y) {
|
|
2585
|
-
this.foundation.setAbsolutePosition(x, y);
|
|
2586
|
-
this.setIsHoisted(true);
|
|
2587
|
-
};
|
|
2588
|
-
/**
|
|
2589
|
-
* @param corner Default anchor corner alignment of top-left surface corner.
|
|
2590
|
-
*/
|
|
2591
|
-
MDCMenuSurface.prototype.setAnchorCorner = function (corner) {
|
|
2592
|
-
this.foundation.setAnchorCorner(corner);
|
|
2593
|
-
};
|
|
2594
|
-
MDCMenuSurface.prototype.setAnchorMargin = function (margin) {
|
|
2595
|
-
this.foundation.setAnchorMargin(margin);
|
|
2596
|
-
};
|
|
2597
|
-
MDCMenuSurface.prototype.getDefaultFoundation = function () {
|
|
2598
|
-
var _this = this;
|
|
2599
|
-
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
|
|
2600
|
-
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
|
|
2601
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
2602
|
-
var adapter = {
|
|
2603
|
-
addClass: function (className) { return _this.root.classList.add(className); },
|
|
2604
|
-
removeClass: function (className) { return _this.root.classList.remove(className); },
|
|
2605
|
-
hasClass: function (className) { return _this.root.classList.contains(className); },
|
|
2606
|
-
hasAnchor: function () { return !!_this.anchorElement; },
|
|
2607
|
-
notifyClose: function () {
|
|
2608
|
-
return _this.emit(MDCMenuSurfaceFoundation.strings.CLOSED_EVENT, {});
|
|
2609
|
-
},
|
|
2610
|
-
notifyClosing: function () {
|
|
2611
|
-
_this.emit(MDCMenuSurfaceFoundation.strings.CLOSING_EVENT, {});
|
|
2612
|
-
},
|
|
2613
|
-
notifyOpen: function () {
|
|
2614
|
-
return _this.emit(MDCMenuSurfaceFoundation.strings.OPENED_EVENT, {});
|
|
2615
|
-
},
|
|
2616
|
-
notifyOpening: function () {
|
|
2617
|
-
return _this.emit(MDCMenuSurfaceFoundation.strings.OPENING_EVENT, {});
|
|
2618
|
-
},
|
|
2619
|
-
isElementInContainer: function (el) { return _this.root.contains(el); },
|
|
2620
|
-
isRtl: function () {
|
|
2621
|
-
return getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
|
|
2622
|
-
},
|
|
2623
|
-
setTransformOrigin: function (origin) {
|
|
2624
|
-
var propertyName = getCorrectPropertyName(window, 'transform') + "-origin";
|
|
2625
|
-
_this.root.style.setProperty(propertyName, origin);
|
|
2626
|
-
},
|
|
2627
|
-
isFocused: function () { return document.activeElement === _this.root; },
|
|
2628
|
-
saveFocus: function () {
|
|
2629
|
-
_this.previousFocus =
|
|
2630
|
-
document.activeElement;
|
|
2631
|
-
},
|
|
2632
|
-
restoreFocus: function () {
|
|
2633
|
-
if (_this.root.contains(document.activeElement)) {
|
|
2634
|
-
if (_this.previousFocus && _this.previousFocus.focus) {
|
|
2635
|
-
_this.previousFocus.focus();
|
|
2636
|
-
}
|
|
2637
|
-
}
|
|
2638
|
-
},
|
|
2639
|
-
getInnerDimensions: function () {
|
|
2640
|
-
return {
|
|
2641
|
-
width: _this.root.offsetWidth,
|
|
2642
|
-
height: _this.root.offsetHeight
|
|
2643
|
-
};
|
|
2644
|
-
},
|
|
2645
|
-
getAnchorDimensions: function () { return _this.anchorElement ?
|
|
2646
|
-
_this.anchorElement.getBoundingClientRect() :
|
|
2647
|
-
null; },
|
|
2648
|
-
getWindowDimensions: function () {
|
|
2649
|
-
return { width: window.innerWidth, height: window.innerHeight };
|
|
2650
|
-
},
|
|
2651
|
-
getBodyDimensions: function () {
|
|
2652
|
-
return { width: document.body.clientWidth, height: document.body.clientHeight };
|
|
2653
|
-
},
|
|
2654
|
-
getWindowScroll: function () {
|
|
2655
|
-
return { x: window.pageXOffset, y: window.pageYOffset };
|
|
2656
|
-
},
|
|
2657
|
-
setPosition: function (position) {
|
|
2658
|
-
var rootHTML = _this.root;
|
|
2659
|
-
rootHTML.style.left = 'left' in position ? position.left + "px" : '';
|
|
2660
|
-
rootHTML.style.right = 'right' in position ? position.right + "px" : '';
|
|
2661
|
-
rootHTML.style.top = 'top' in position ? position.top + "px" : '';
|
|
2662
|
-
rootHTML.style.bottom =
|
|
2663
|
-
'bottom' in position ? position.bottom + "px" : '';
|
|
2664
|
-
},
|
|
2665
|
-
setMaxHeight: function (height) {
|
|
2666
|
-
_this.root.style.maxHeight = height;
|
|
2667
|
-
},
|
|
2668
|
-
};
|
|
2669
|
-
// tslint:enable:object-literal-sort-keys
|
|
2670
|
-
return new MDCMenuSurfaceFoundation(adapter);
|
|
2671
|
-
};
|
|
2672
|
-
return MDCMenuSurface;
|
|
2673
|
-
}(MDCComponent));
|
|
2674
|
-
|
|
2675
|
-
/**
|
|
2676
|
-
* @license
|
|
2677
|
-
* Copyright 2018 Google Inc.
|
|
2678
|
-
*
|
|
2679
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
2680
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
2681
|
-
* in the Software without restriction, including without limitation the rights
|
|
2682
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
2683
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
2684
|
-
* furnished to do so, subject to the following conditions:
|
|
2685
|
-
*
|
|
2686
|
-
* The above copyright notice and this permission notice shall be included in
|
|
2687
|
-
* all copies or substantial portions of the Software.
|
|
2688
|
-
*
|
|
2689
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
2690
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
2691
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
2692
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
2693
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
2694
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
2695
|
-
* THE SOFTWARE.
|
|
2696
|
-
*/
|
|
2697
|
-
var cssClasses$2 = {
|
|
2698
|
-
MENU_SELECTED_LIST_ITEM: 'mdc-menu-item--selected',
|
|
2699
|
-
MENU_SELECTION_GROUP: 'mdc-menu__selection-group',
|
|
2700
|
-
ROOT: 'mdc-menu',
|
|
2701
|
-
};
|
|
2702
|
-
var strings$3 = {
|
|
2703
|
-
ARIA_CHECKED_ATTR: 'aria-checked',
|
|
2704
|
-
ARIA_DISABLED_ATTR: 'aria-disabled',
|
|
2705
|
-
CHECKBOX_SELECTOR: 'input[type="checkbox"]',
|
|
2706
|
-
LIST_SELECTOR: '.mdc-list,.mdc-deprecated-list',
|
|
2707
|
-
SELECTED_EVENT: 'MDCMenu:selected',
|
|
2708
|
-
SKIP_RESTORE_FOCUS: 'data-menu-item-skip-restore-focus',
|
|
2709
|
-
};
|
|
2710
|
-
var numbers$1 = {
|
|
2711
|
-
FOCUS_ROOT_INDEX: -1,
|
|
2712
|
-
};
|
|
2713
|
-
var DefaultFocusState;
|
|
2714
|
-
(function (DefaultFocusState) {
|
|
2715
|
-
DefaultFocusState[DefaultFocusState["NONE"] = 0] = "NONE";
|
|
2716
|
-
DefaultFocusState[DefaultFocusState["LIST_ROOT"] = 1] = "LIST_ROOT";
|
|
2717
|
-
DefaultFocusState[DefaultFocusState["FIRST_ITEM"] = 2] = "FIRST_ITEM";
|
|
2718
|
-
DefaultFocusState[DefaultFocusState["LAST_ITEM"] = 3] = "LAST_ITEM";
|
|
2719
|
-
})(DefaultFocusState || (DefaultFocusState = {}));
|
|
2720
|
-
|
|
2721
|
-
/**
|
|
2722
|
-
* @license
|
|
2723
|
-
* Copyright 2018 Google Inc.
|
|
2724
|
-
*
|
|
2725
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
2726
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
2727
|
-
* in the Software without restriction, including without limitation the rights
|
|
2728
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
2729
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
2730
|
-
* furnished to do so, subject to the following conditions:
|
|
2731
|
-
*
|
|
2732
|
-
* The above copyright notice and this permission notice shall be included in
|
|
2733
|
-
* all copies or substantial portions of the Software.
|
|
2734
|
-
*
|
|
2735
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
2736
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
2737
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
2738
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
2739
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
2740
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
2741
|
-
* THE SOFTWARE.
|
|
2742
|
-
*/
|
|
2743
|
-
var MDCMenuFoundation = /** @class */ (function (_super) {
|
|
2744
|
-
__extends(MDCMenuFoundation, _super);
|
|
2745
|
-
function MDCMenuFoundation(adapter) {
|
|
2746
|
-
var _this = _super.call(this, __assign(__assign({}, MDCMenuFoundation.defaultAdapter), adapter)) || this;
|
|
2747
|
-
_this.closeAnimationEndTimerId = 0;
|
|
2748
|
-
_this.defaultFocusState = DefaultFocusState.LIST_ROOT;
|
|
2749
|
-
_this.selectedIndex = -1;
|
|
2750
|
-
return _this;
|
|
2751
|
-
}
|
|
2752
|
-
Object.defineProperty(MDCMenuFoundation, "cssClasses", {
|
|
2753
|
-
get: function () {
|
|
2754
|
-
return cssClasses$2;
|
|
2755
|
-
},
|
|
2756
|
-
enumerable: false,
|
|
2757
|
-
configurable: true
|
|
2758
|
-
});
|
|
2759
|
-
Object.defineProperty(MDCMenuFoundation, "strings", {
|
|
2760
|
-
get: function () {
|
|
2761
|
-
return strings$3;
|
|
2762
|
-
},
|
|
2763
|
-
enumerable: false,
|
|
2764
|
-
configurable: true
|
|
2765
|
-
});
|
|
2766
|
-
Object.defineProperty(MDCMenuFoundation, "numbers", {
|
|
2767
|
-
get: function () {
|
|
2768
|
-
return numbers$1;
|
|
2769
|
-
},
|
|
2770
|
-
enumerable: false,
|
|
2771
|
-
configurable: true
|
|
2772
|
-
});
|
|
2773
|
-
Object.defineProperty(MDCMenuFoundation, "defaultAdapter", {
|
|
2774
|
-
/**
|
|
2775
|
-
* @see {@link MDCMenuAdapter} for typing information on parameters and return types.
|
|
2776
|
-
*/
|
|
2777
|
-
get: function () {
|
|
2778
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
2779
|
-
return {
|
|
2780
|
-
addClassToElementAtIndex: function () { return undefined; },
|
|
2781
|
-
removeClassFromElementAtIndex: function () { return undefined; },
|
|
2782
|
-
addAttributeToElementAtIndex: function () { return undefined; },
|
|
2783
|
-
removeAttributeFromElementAtIndex: function () { return undefined; },
|
|
2784
|
-
getAttributeFromElementAtIndex: function () { return null; },
|
|
2785
|
-
elementContainsClass: function () { return false; },
|
|
2786
|
-
closeSurface: function () { return undefined; },
|
|
2787
|
-
getElementIndex: function () { return -1; },
|
|
2788
|
-
notifySelected: function () { return undefined; },
|
|
2789
|
-
getMenuItemCount: function () { return 0; },
|
|
2790
|
-
focusItemAtIndex: function () { return undefined; },
|
|
2791
|
-
focusListRoot: function () { return undefined; },
|
|
2792
|
-
getSelectedSiblingOfItemAtIndex: function () { return -1; },
|
|
2793
|
-
isSelectableItemAtIndex: function () { return false; },
|
|
2794
|
-
};
|
|
2795
|
-
// tslint:enable:object-literal-sort-keys
|
|
2796
|
-
},
|
|
2797
|
-
enumerable: false,
|
|
2798
|
-
configurable: true
|
|
2799
|
-
});
|
|
2800
|
-
MDCMenuFoundation.prototype.destroy = function () {
|
|
2801
|
-
if (this.closeAnimationEndTimerId) {
|
|
2802
|
-
clearTimeout(this.closeAnimationEndTimerId);
|
|
2803
|
-
}
|
|
2804
|
-
this.adapter.closeSurface();
|
|
2805
|
-
};
|
|
2806
|
-
MDCMenuFoundation.prototype.handleKeydown = function (evt) {
|
|
2807
|
-
var key = evt.key, keyCode = evt.keyCode;
|
|
2808
|
-
var isTab = key === 'Tab' || keyCode === 9;
|
|
2809
|
-
if (isTab) {
|
|
2810
|
-
this.adapter.closeSurface(/** skipRestoreFocus */ true);
|
|
2811
|
-
}
|
|
2812
|
-
};
|
|
2813
|
-
MDCMenuFoundation.prototype.handleItemAction = function (listItem) {
|
|
2814
|
-
var _this = this;
|
|
2815
|
-
var index = this.adapter.getElementIndex(listItem);
|
|
2816
|
-
if (index < 0) {
|
|
2817
|
-
return;
|
|
2818
|
-
}
|
|
2819
|
-
this.adapter.notifySelected({ index: index });
|
|
2820
|
-
var skipRestoreFocus = this.adapter.getAttributeFromElementAtIndex(index, strings$3.SKIP_RESTORE_FOCUS) === 'true';
|
|
2821
|
-
this.adapter.closeSurface(skipRestoreFocus);
|
|
2822
|
-
// Wait for the menu to close before adding/removing classes that affect styles.
|
|
2823
|
-
this.closeAnimationEndTimerId = setTimeout(function () {
|
|
2824
|
-
// Recompute the index in case the menu contents have changed.
|
|
2825
|
-
var recomputedIndex = _this.adapter.getElementIndex(listItem);
|
|
2826
|
-
if (recomputedIndex >= 0 &&
|
|
2827
|
-
_this.adapter.isSelectableItemAtIndex(recomputedIndex)) {
|
|
2828
|
-
_this.setSelectedIndex(recomputedIndex);
|
|
2829
|
-
}
|
|
2830
|
-
}, MDCMenuSurfaceFoundation.numbers.TRANSITION_CLOSE_DURATION);
|
|
2831
|
-
};
|
|
2832
|
-
MDCMenuFoundation.prototype.handleMenuSurfaceOpened = function () {
|
|
2833
|
-
switch (this.defaultFocusState) {
|
|
2834
|
-
case DefaultFocusState.FIRST_ITEM:
|
|
2835
|
-
this.adapter.focusItemAtIndex(0);
|
|
2836
|
-
break;
|
|
2837
|
-
case DefaultFocusState.LAST_ITEM:
|
|
2838
|
-
this.adapter.focusItemAtIndex(this.adapter.getMenuItemCount() - 1);
|
|
2839
|
-
break;
|
|
2840
|
-
case DefaultFocusState.NONE:
|
|
2841
|
-
// Do nothing.
|
|
2842
|
-
break;
|
|
2843
|
-
default:
|
|
2844
|
-
this.adapter.focusListRoot();
|
|
2845
|
-
break;
|
|
2846
|
-
}
|
|
2847
|
-
};
|
|
2848
|
-
/**
|
|
2849
|
-
* Sets default focus state where the menu should focus every time when menu
|
|
2850
|
-
* is opened. Focuses the list root (`DefaultFocusState.LIST_ROOT`) element by
|
|
2851
|
-
* default.
|
|
2852
|
-
*/
|
|
2853
|
-
MDCMenuFoundation.prototype.setDefaultFocusState = function (focusState) {
|
|
2854
|
-
this.defaultFocusState = focusState;
|
|
2855
|
-
};
|
|
2856
|
-
/** @return Index of the currently selected list item within the menu. */
|
|
2857
|
-
MDCMenuFoundation.prototype.getSelectedIndex = function () {
|
|
2858
|
-
return this.selectedIndex;
|
|
2859
|
-
};
|
|
2860
|
-
/**
|
|
2861
|
-
* Selects the list item at `index` within the menu.
|
|
2862
|
-
* @param index Index of list item within the menu.
|
|
2863
|
-
*/
|
|
2864
|
-
MDCMenuFoundation.prototype.setSelectedIndex = function (index) {
|
|
2865
|
-
this.validatedIndex(index);
|
|
2866
|
-
if (!this.adapter.isSelectableItemAtIndex(index)) {
|
|
2867
|
-
throw new Error('MDCMenuFoundation: No selection group at specified index.');
|
|
2868
|
-
}
|
|
2869
|
-
var prevSelectedIndex = this.adapter.getSelectedSiblingOfItemAtIndex(index);
|
|
2870
|
-
if (prevSelectedIndex >= 0) {
|
|
2871
|
-
this.adapter.removeAttributeFromElementAtIndex(prevSelectedIndex, strings$3.ARIA_CHECKED_ATTR);
|
|
2872
|
-
this.adapter.removeClassFromElementAtIndex(prevSelectedIndex, cssClasses$2.MENU_SELECTED_LIST_ITEM);
|
|
2873
|
-
}
|
|
2874
|
-
this.adapter.addClassToElementAtIndex(index, cssClasses$2.MENU_SELECTED_LIST_ITEM);
|
|
2875
|
-
this.adapter.addAttributeToElementAtIndex(index, strings$3.ARIA_CHECKED_ATTR, 'true');
|
|
2876
|
-
this.selectedIndex = index;
|
|
2877
|
-
};
|
|
2878
|
-
/**
|
|
2879
|
-
* Sets the enabled state to isEnabled for the menu item at the given index.
|
|
2880
|
-
* @param index Index of the menu item
|
|
2881
|
-
* @param isEnabled The desired enabled state of the menu item.
|
|
2882
|
-
*/
|
|
2883
|
-
MDCMenuFoundation.prototype.setEnabled = function (index, isEnabled) {
|
|
2884
|
-
this.validatedIndex(index);
|
|
2885
|
-
if (isEnabled) {
|
|
2886
|
-
this.adapter.removeClassFromElementAtIndex(index, cssClasses$3.LIST_ITEM_DISABLED_CLASS);
|
|
2887
|
-
this.adapter.addAttributeToElementAtIndex(index, strings$3.ARIA_DISABLED_ATTR, 'false');
|
|
2888
|
-
}
|
|
2889
|
-
else {
|
|
2890
|
-
this.adapter.addClassToElementAtIndex(index, cssClasses$3.LIST_ITEM_DISABLED_CLASS);
|
|
2891
|
-
this.adapter.addAttributeToElementAtIndex(index, strings$3.ARIA_DISABLED_ATTR, 'true');
|
|
2892
|
-
}
|
|
2893
|
-
};
|
|
2894
|
-
MDCMenuFoundation.prototype.validatedIndex = function (index) {
|
|
2895
|
-
var menuSize = this.adapter.getMenuItemCount();
|
|
2896
|
-
var isIndexInRange = index >= 0 && index < menuSize;
|
|
2897
|
-
if (!isIndexInRange) {
|
|
2898
|
-
throw new Error('MDCMenuFoundation: No list item at specified index.');
|
|
2899
|
-
}
|
|
2900
|
-
};
|
|
2901
|
-
return MDCMenuFoundation;
|
|
2902
|
-
}(MDCFoundation));
|
|
2903
|
-
|
|
2904
|
-
/**
|
|
2905
|
-
* @license
|
|
2906
|
-
* Copyright 2018 Google Inc.
|
|
2907
|
-
*
|
|
2908
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
2909
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
2910
|
-
* in the Software without restriction, including without limitation the rights
|
|
2911
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
2912
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
2913
|
-
* furnished to do so, subject to the following conditions:
|
|
2914
|
-
*
|
|
2915
|
-
* The above copyright notice and this permission notice shall be included in
|
|
2916
|
-
* all copies or substantial portions of the Software.
|
|
2917
|
-
*
|
|
2918
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
2919
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
2920
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
2921
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
2922
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
2923
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
2924
|
-
* THE SOFTWARE.
|
|
2925
|
-
*/
|
|
2926
|
-
var MDCMenu = /** @class */ (function (_super) {
|
|
2927
|
-
__extends(MDCMenu, _super);
|
|
2928
|
-
function MDCMenu() {
|
|
2929
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
2930
|
-
}
|
|
2931
|
-
MDCMenu.attachTo = function (root) {
|
|
2932
|
-
return new MDCMenu(root);
|
|
2933
|
-
};
|
|
2934
|
-
MDCMenu.prototype.initialize = function (menuSurfaceFactory, listFactory) {
|
|
2935
|
-
if (menuSurfaceFactory === void 0) { menuSurfaceFactory = function (el) { return new MDCMenuSurface(el); }; }
|
|
2936
|
-
if (listFactory === void 0) { listFactory = function (el) { return new MDCList(el); }; }
|
|
2937
|
-
this.menuSurfaceFactory = menuSurfaceFactory;
|
|
2938
|
-
this.listFactory = listFactory;
|
|
2939
|
-
};
|
|
2940
|
-
MDCMenu.prototype.initialSyncWithDOM = function () {
|
|
2941
|
-
var _this = this;
|
|
2942
|
-
this.menuSurface = this.menuSurfaceFactory(this.root);
|
|
2943
|
-
var list = this.root.querySelector(strings$3.LIST_SELECTOR);
|
|
2944
|
-
if (list) {
|
|
2945
|
-
this.list = this.listFactory(list);
|
|
2946
|
-
this.list.wrapFocus = true;
|
|
2947
|
-
}
|
|
2948
|
-
else {
|
|
2949
|
-
this.list = null;
|
|
2950
|
-
}
|
|
2951
|
-
this.handleKeydown = function (evt) {
|
|
2952
|
-
_this.foundation.handleKeydown(evt);
|
|
2953
|
-
};
|
|
2954
|
-
this.handleItemAction = function (evt) {
|
|
2955
|
-
_this.foundation.handleItemAction(_this.items[evt.detail.index]);
|
|
2956
|
-
};
|
|
2957
|
-
this.handleMenuSurfaceOpened = function () {
|
|
2958
|
-
_this.foundation.handleMenuSurfaceOpened();
|
|
2959
|
-
};
|
|
2960
|
-
this.menuSurface.listen(MDCMenuSurfaceFoundation.strings.OPENED_EVENT, this.handleMenuSurfaceOpened);
|
|
2961
|
-
this.listen('keydown', this.handleKeydown);
|
|
2962
|
-
this.listen(MDCListFoundation.strings.ACTION_EVENT, this.handleItemAction);
|
|
2963
|
-
};
|
|
2964
|
-
MDCMenu.prototype.destroy = function () {
|
|
2965
|
-
if (this.list) {
|
|
2966
|
-
this.list.destroy();
|
|
2967
|
-
}
|
|
2968
|
-
this.menuSurface.destroy();
|
|
2969
|
-
this.menuSurface.unlisten(MDCMenuSurfaceFoundation.strings.OPENED_EVENT, this.handleMenuSurfaceOpened);
|
|
2970
|
-
this.unlisten('keydown', this.handleKeydown);
|
|
2971
|
-
this.unlisten(MDCListFoundation.strings.ACTION_EVENT, this.handleItemAction);
|
|
2972
|
-
_super.prototype.destroy.call(this);
|
|
2973
|
-
};
|
|
2974
|
-
Object.defineProperty(MDCMenu.prototype, "open", {
|
|
2975
|
-
get: function () {
|
|
2976
|
-
return this.menuSurface.isOpen();
|
|
2977
|
-
},
|
|
2978
|
-
set: function (value) {
|
|
2979
|
-
if (value) {
|
|
2980
|
-
this.menuSurface.open();
|
|
2981
|
-
}
|
|
2982
|
-
else {
|
|
2983
|
-
this.menuSurface.close();
|
|
2984
|
-
}
|
|
2985
|
-
},
|
|
2986
|
-
enumerable: false,
|
|
2987
|
-
configurable: true
|
|
2988
|
-
});
|
|
2989
|
-
Object.defineProperty(MDCMenu.prototype, "wrapFocus", {
|
|
2990
|
-
get: function () {
|
|
2991
|
-
return this.list ? this.list.wrapFocus : false;
|
|
2992
|
-
},
|
|
2993
|
-
set: function (value) {
|
|
2994
|
-
if (this.list) {
|
|
2995
|
-
this.list.wrapFocus = value;
|
|
2996
|
-
}
|
|
2997
|
-
},
|
|
2998
|
-
enumerable: false,
|
|
2999
|
-
configurable: true
|
|
3000
|
-
});
|
|
3001
|
-
Object.defineProperty(MDCMenu.prototype, "hasTypeahead", {
|
|
3002
|
-
/**
|
|
3003
|
-
* Sets whether the menu has typeahead functionality.
|
|
3004
|
-
* @param value Whether typeahead is enabled.
|
|
3005
|
-
*/
|
|
3006
|
-
set: function (value) {
|
|
3007
|
-
if (this.list) {
|
|
3008
|
-
this.list.hasTypeahead = value;
|
|
3009
|
-
}
|
|
3010
|
-
},
|
|
3011
|
-
enumerable: false,
|
|
3012
|
-
configurable: true
|
|
3013
|
-
});
|
|
3014
|
-
Object.defineProperty(MDCMenu.prototype, "typeaheadInProgress", {
|
|
3015
|
-
/**
|
|
3016
|
-
* @return Whether typeahead logic is currently matching some user prefix.
|
|
3017
|
-
*/
|
|
3018
|
-
get: function () {
|
|
3019
|
-
return this.list ? this.list.typeaheadInProgress : false;
|
|
3020
|
-
},
|
|
3021
|
-
enumerable: false,
|
|
3022
|
-
configurable: true
|
|
3023
|
-
});
|
|
3024
|
-
/**
|
|
3025
|
-
* Given the next desired character from the user, adds it to the typeahead
|
|
3026
|
-
* buffer. Then, attempts to find the next option matching the buffer. Wraps
|
|
3027
|
-
* around if at the end of options.
|
|
3028
|
-
*
|
|
3029
|
-
* @param nextChar The next character to add to the prefix buffer.
|
|
3030
|
-
* @param startingIndex The index from which to start matching. Only relevant
|
|
3031
|
-
* when starting a new match sequence. To start a new match sequence,
|
|
3032
|
-
* clear the buffer using `clearTypeaheadBuffer`, or wait for the buffer
|
|
3033
|
-
* to clear after a set interval defined in list foundation. Defaults to
|
|
3034
|
-
* the currently focused index.
|
|
3035
|
-
* @return The index of the matched item, or -1 if no match.
|
|
3036
|
-
*/
|
|
3037
|
-
MDCMenu.prototype.typeaheadMatchItem = function (nextChar, startingIndex) {
|
|
3038
|
-
if (this.list) {
|
|
3039
|
-
return this.list.typeaheadMatchItem(nextChar, startingIndex);
|
|
3040
|
-
}
|
|
3041
|
-
return -1;
|
|
3042
|
-
};
|
|
3043
|
-
/**
|
|
3044
|
-
* Layout the underlying list element in the case of any dynamic updates
|
|
3045
|
-
* to its structure.
|
|
3046
|
-
*/
|
|
3047
|
-
MDCMenu.prototype.layout = function () {
|
|
3048
|
-
if (this.list) {
|
|
3049
|
-
this.list.layout();
|
|
3050
|
-
}
|
|
3051
|
-
};
|
|
3052
|
-
Object.defineProperty(MDCMenu.prototype, "items", {
|
|
3053
|
-
/**
|
|
3054
|
-
* Return the items within the menu. Note that this only contains the set of elements within
|
|
3055
|
-
* the items container that are proper list items, and not supplemental / presentational DOM
|
|
3056
|
-
* elements.
|
|
3057
|
-
*/
|
|
3058
|
-
get: function () {
|
|
3059
|
-
return this.list ? this.list.listElements : [];
|
|
3060
|
-
},
|
|
3061
|
-
enumerable: false,
|
|
3062
|
-
configurable: true
|
|
3063
|
-
});
|
|
3064
|
-
Object.defineProperty(MDCMenu.prototype, "singleSelection", {
|
|
3065
|
-
/**
|
|
3066
|
-
* Turns on/off the underlying list's single selection mode. Used mainly
|
|
3067
|
-
* by select menu.
|
|
3068
|
-
*
|
|
3069
|
-
* @param singleSelection Whether to enable single selection mode.
|
|
3070
|
-
*/
|
|
3071
|
-
set: function (singleSelection) {
|
|
3072
|
-
if (this.list) {
|
|
3073
|
-
this.list.singleSelection = singleSelection;
|
|
3074
|
-
}
|
|
3075
|
-
},
|
|
3076
|
-
enumerable: false,
|
|
3077
|
-
configurable: true
|
|
3078
|
-
});
|
|
3079
|
-
Object.defineProperty(MDCMenu.prototype, "selectedIndex", {
|
|
3080
|
-
/**
|
|
3081
|
-
* Retrieves the selected index. Only applicable to select menus.
|
|
3082
|
-
* @return The selected index, which is a number for single selection and
|
|
3083
|
-
* radio lists, and an array of numbers for checkbox lists.
|
|
3084
|
-
*/
|
|
3085
|
-
get: function () {
|
|
3086
|
-
return this.list ? this.list.selectedIndex : numbers$2.UNSET_INDEX;
|
|
3087
|
-
},
|
|
3088
|
-
/**
|
|
3089
|
-
* Sets the selected index of the list. Only applicable to select menus.
|
|
3090
|
-
* @param index The selected index, which is a number for single selection and
|
|
3091
|
-
* radio lists, and an array of numbers for checkbox lists.
|
|
3092
|
-
*/
|
|
3093
|
-
set: function (index) {
|
|
3094
|
-
if (this.list) {
|
|
3095
|
-
this.list.selectedIndex = index;
|
|
3096
|
-
}
|
|
3097
|
-
},
|
|
3098
|
-
enumerable: false,
|
|
3099
|
-
configurable: true
|
|
3100
|
-
});
|
|
3101
|
-
Object.defineProperty(MDCMenu.prototype, "quickOpen", {
|
|
3102
|
-
set: function (quickOpen) {
|
|
3103
|
-
this.menuSurface.quickOpen = quickOpen;
|
|
3104
|
-
},
|
|
3105
|
-
enumerable: false,
|
|
3106
|
-
configurable: true
|
|
3107
|
-
});
|
|
3108
|
-
/**
|
|
3109
|
-
* Sets default focus state where the menu should focus every time when menu
|
|
3110
|
-
* is opened. Focuses the list root (`DefaultFocusState.LIST_ROOT`) element by
|
|
3111
|
-
* default.
|
|
3112
|
-
* @param focusState Default focus state.
|
|
3113
|
-
*/
|
|
3114
|
-
MDCMenu.prototype.setDefaultFocusState = function (focusState) {
|
|
3115
|
-
this.foundation.setDefaultFocusState(focusState);
|
|
3116
|
-
};
|
|
3117
|
-
/**
|
|
3118
|
-
* @param corner Default anchor corner alignment of top-left menu corner.
|
|
3119
|
-
*/
|
|
3120
|
-
MDCMenu.prototype.setAnchorCorner = function (corner) {
|
|
3121
|
-
this.menuSurface.setAnchorCorner(corner);
|
|
3122
|
-
};
|
|
3123
|
-
MDCMenu.prototype.setAnchorMargin = function (margin) {
|
|
3124
|
-
this.menuSurface.setAnchorMargin(margin);
|
|
3125
|
-
};
|
|
3126
|
-
/**
|
|
3127
|
-
* Sets the list item as the selected row at the specified index.
|
|
3128
|
-
* @param index Index of list item within menu.
|
|
3129
|
-
*/
|
|
3130
|
-
MDCMenu.prototype.setSelectedIndex = function (index) {
|
|
3131
|
-
this.foundation.setSelectedIndex(index);
|
|
3132
|
-
};
|
|
3133
|
-
/**
|
|
3134
|
-
* Sets the enabled state to isEnabled for the menu item at the given index.
|
|
3135
|
-
* @param index Index of the menu item
|
|
3136
|
-
* @param isEnabled The desired enabled state of the menu item.
|
|
3137
|
-
*/
|
|
3138
|
-
MDCMenu.prototype.setEnabled = function (index, isEnabled) {
|
|
3139
|
-
this.foundation.setEnabled(index, isEnabled);
|
|
3140
|
-
};
|
|
3141
|
-
/**
|
|
3142
|
-
* @return The item within the menu at the index specified.
|
|
3143
|
-
*/
|
|
3144
|
-
MDCMenu.prototype.getOptionByIndex = function (index) {
|
|
3145
|
-
var items = this.items;
|
|
3146
|
-
if (index < items.length) {
|
|
3147
|
-
return this.items[index];
|
|
3148
|
-
}
|
|
3149
|
-
else {
|
|
3150
|
-
return null;
|
|
3151
|
-
}
|
|
3152
|
-
};
|
|
3153
|
-
/**
|
|
3154
|
-
* @param index A menu item's index.
|
|
3155
|
-
* @return The primary text within the menu at the index specified.
|
|
3156
|
-
*/
|
|
3157
|
-
MDCMenu.prototype.getPrimaryTextAtIndex = function (index) {
|
|
3158
|
-
var item = this.getOptionByIndex(index);
|
|
3159
|
-
if (item && this.list) {
|
|
3160
|
-
return this.list.getPrimaryText(item) || '';
|
|
3161
|
-
}
|
|
3162
|
-
return '';
|
|
3163
|
-
};
|
|
3164
|
-
MDCMenu.prototype.setFixedPosition = function (isFixed) {
|
|
3165
|
-
this.menuSurface.setFixedPosition(isFixed);
|
|
3166
|
-
};
|
|
3167
|
-
MDCMenu.prototype.setIsHoisted = function (isHoisted) {
|
|
3168
|
-
this.menuSurface.setIsHoisted(isHoisted);
|
|
3169
|
-
};
|
|
3170
|
-
MDCMenu.prototype.setAbsolutePosition = function (x, y) {
|
|
3171
|
-
this.menuSurface.setAbsolutePosition(x, y);
|
|
3172
|
-
};
|
|
3173
|
-
/**
|
|
3174
|
-
* Sets the element that the menu-surface is anchored to.
|
|
3175
|
-
*/
|
|
3176
|
-
MDCMenu.prototype.setAnchorElement = function (element) {
|
|
3177
|
-
this.menuSurface.anchorElement = element;
|
|
3178
|
-
};
|
|
3179
|
-
MDCMenu.prototype.getDefaultFoundation = function () {
|
|
3180
|
-
var _this = this;
|
|
3181
|
-
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
|
|
3182
|
-
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
|
|
3183
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
3184
|
-
var adapter = {
|
|
3185
|
-
addClassToElementAtIndex: function (index, className) {
|
|
3186
|
-
var list = _this.items;
|
|
3187
|
-
list[index].classList.add(className);
|
|
3188
|
-
},
|
|
3189
|
-
removeClassFromElementAtIndex: function (index, className) {
|
|
3190
|
-
var list = _this.items;
|
|
3191
|
-
list[index].classList.remove(className);
|
|
3192
|
-
},
|
|
3193
|
-
addAttributeToElementAtIndex: function (index, attr, value) {
|
|
3194
|
-
var list = _this.items;
|
|
3195
|
-
list[index].setAttribute(attr, value);
|
|
3196
|
-
},
|
|
3197
|
-
removeAttributeFromElementAtIndex: function (index, attr) {
|
|
3198
|
-
var list = _this.items;
|
|
3199
|
-
list[index].removeAttribute(attr);
|
|
3200
|
-
},
|
|
3201
|
-
getAttributeFromElementAtIndex: function (index, attr) {
|
|
3202
|
-
var list = _this.items;
|
|
3203
|
-
return list[index].getAttribute(attr);
|
|
3204
|
-
},
|
|
3205
|
-
elementContainsClass: function (element, className) {
|
|
3206
|
-
return element.classList.contains(className);
|
|
3207
|
-
},
|
|
3208
|
-
closeSurface: function (skipRestoreFocus) {
|
|
3209
|
-
_this.menuSurface.close(skipRestoreFocus);
|
|
3210
|
-
},
|
|
3211
|
-
getElementIndex: function (element) { return _this.items.indexOf(element); },
|
|
3212
|
-
notifySelected: function (evtData) {
|
|
3213
|
-
_this.emit(strings$3.SELECTED_EVENT, {
|
|
3214
|
-
index: evtData.index,
|
|
3215
|
-
item: _this.items[evtData.index],
|
|
3216
|
-
});
|
|
3217
|
-
},
|
|
3218
|
-
getMenuItemCount: function () { return _this.items.length; },
|
|
3219
|
-
focusItemAtIndex: function (index) {
|
|
3220
|
-
_this.items[index].focus();
|
|
3221
|
-
},
|
|
3222
|
-
focusListRoot: function () {
|
|
3223
|
-
_this.root.querySelector(strings$3.LIST_SELECTOR).focus();
|
|
3224
|
-
},
|
|
3225
|
-
isSelectableItemAtIndex: function (index) {
|
|
3226
|
-
return !!closest(_this.items[index], "." + cssClasses$2.MENU_SELECTION_GROUP);
|
|
3227
|
-
},
|
|
3228
|
-
getSelectedSiblingOfItemAtIndex: function (index) {
|
|
3229
|
-
var selectionGroupEl = closest(_this.items[index], "." + cssClasses$2.MENU_SELECTION_GROUP);
|
|
3230
|
-
var selectedItemEl = selectionGroupEl.querySelector("." + cssClasses$2.MENU_SELECTED_LIST_ITEM);
|
|
3231
|
-
return selectedItemEl ? _this.items.indexOf(selectedItemEl) : -1;
|
|
3232
|
-
},
|
|
3233
|
-
};
|
|
3234
|
-
// tslint:enable:object-literal-sort-keys
|
|
3235
|
-
return new MDCMenuFoundation(adapter);
|
|
3236
|
-
};
|
|
3237
|
-
return MDCMenu;
|
|
3238
|
-
}(MDCComponent));
|
|
3239
|
-
|
|
3240
|
-
/**
|
|
3241
|
-
* @license
|
|
3242
|
-
* Copyright 2016 Google Inc.
|
|
3243
|
-
*
|
|
3244
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
3245
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
3246
|
-
* in the Software without restriction, including without limitation the rights
|
|
3247
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
3248
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
3249
|
-
* furnished to do so, subject to the following conditions:
|
|
3250
|
-
*
|
|
3251
|
-
* The above copyright notice and this permission notice shall be included in
|
|
3252
|
-
* all copies or substantial portions of the Software.
|
|
3253
|
-
*
|
|
3254
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
3255
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
3256
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
3257
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
3258
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
3259
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
3260
|
-
* THE SOFTWARE.
|
|
3261
|
-
*/
|
|
3262
|
-
var cssClasses$1 = {
|
|
3263
|
-
ACTIVATED: 'mdc-select--activated',
|
|
3264
|
-
DISABLED: 'mdc-select--disabled',
|
|
3265
|
-
FOCUSED: 'mdc-select--focused',
|
|
3266
|
-
INVALID: 'mdc-select--invalid',
|
|
3267
|
-
MENU_INVALID: 'mdc-select__menu--invalid',
|
|
3268
|
-
OUTLINED: 'mdc-select--outlined',
|
|
3269
|
-
REQUIRED: 'mdc-select--required',
|
|
3270
|
-
ROOT: 'mdc-select',
|
|
3271
|
-
WITH_LEADING_ICON: 'mdc-select--with-leading-icon',
|
|
3272
|
-
};
|
|
3273
|
-
var strings$2 = {
|
|
3274
|
-
ARIA_CONTROLS: 'aria-controls',
|
|
3275
|
-
ARIA_DESCRIBEDBY: 'aria-describedby',
|
|
3276
|
-
ARIA_SELECTED_ATTR: 'aria-selected',
|
|
3277
|
-
CHANGE_EVENT: 'MDCSelect:change',
|
|
3278
|
-
HIDDEN_INPUT_SELECTOR: 'input[type="hidden"]',
|
|
3279
|
-
LABEL_SELECTOR: '.mdc-floating-label',
|
|
3280
|
-
LEADING_ICON_SELECTOR: '.mdc-select__icon',
|
|
3281
|
-
LINE_RIPPLE_SELECTOR: '.mdc-line-ripple',
|
|
3282
|
-
MENU_SELECTOR: '.mdc-select__menu',
|
|
3283
|
-
OUTLINE_SELECTOR: '.mdc-notched-outline',
|
|
3284
|
-
SELECTED_TEXT_SELECTOR: '.mdc-select__selected-text',
|
|
3285
|
-
SELECT_ANCHOR_SELECTOR: '.mdc-select__anchor',
|
|
3286
|
-
VALUE_ATTR: 'data-value',
|
|
3287
|
-
};
|
|
3288
|
-
var numbers = {
|
|
3289
|
-
LABEL_SCALE: 0.75,
|
|
3290
|
-
UNSET_INDEX: -1,
|
|
3291
|
-
CLICK_DEBOUNCE_TIMEOUT_MS: 330,
|
|
3292
|
-
};
|
|
3293
|
-
|
|
3294
|
-
/**
|
|
3295
|
-
* @license
|
|
3296
|
-
* Copyright 2016 Google Inc.
|
|
3297
|
-
*
|
|
3298
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
3299
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
3300
|
-
* in the Software without restriction, including without limitation the rights
|
|
3301
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
3302
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
3303
|
-
* furnished to do so, subject to the following conditions:
|
|
3304
|
-
*
|
|
3305
|
-
* The above copyright notice and this permission notice shall be included in
|
|
3306
|
-
* all copies or substantial portions of the Software.
|
|
3307
|
-
*
|
|
3308
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
3309
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
3310
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
3311
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
3312
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
3313
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
3314
|
-
* THE SOFTWARE.
|
|
3315
|
-
*/
|
|
3316
|
-
var MDCSelectFoundation = /** @class */ (function (_super) {
|
|
3317
|
-
__extends(MDCSelectFoundation, _super);
|
|
3318
|
-
/* istanbul ignore next: optional argument is not a branch statement */
|
|
3319
|
-
/**
|
|
3320
|
-
* @param adapter
|
|
3321
|
-
* @param foundationMap Map from subcomponent names to their subfoundations.
|
|
3322
|
-
*/
|
|
3323
|
-
function MDCSelectFoundation(adapter, foundationMap) {
|
|
3324
|
-
if (foundationMap === void 0) { foundationMap = {}; }
|
|
3325
|
-
var _this = _super.call(this, __assign(__assign({}, MDCSelectFoundation.defaultAdapter), adapter)) || this;
|
|
3326
|
-
// Disabled state
|
|
3327
|
-
_this.disabled = false;
|
|
3328
|
-
// isMenuOpen is used to track the state of the menu by listening to the
|
|
3329
|
-
// MDCMenuSurface:closed event For reference, menu.open will return false if
|
|
3330
|
-
// the menu is still closing, but isMenuOpen returns false only after the menu
|
|
3331
|
-
// has closed
|
|
3332
|
-
_this.isMenuOpen = false;
|
|
3333
|
-
// By default, select is invalid if it is required but no value is selected.
|
|
3334
|
-
_this.useDefaultValidation = true;
|
|
3335
|
-
_this.customValidity = true;
|
|
3336
|
-
_this.lastSelectedIndex = numbers.UNSET_INDEX;
|
|
3337
|
-
_this.clickDebounceTimeout = 0;
|
|
3338
|
-
_this.recentlyClicked = false;
|
|
3339
|
-
_this.leadingIcon = foundationMap.leadingIcon;
|
|
3340
|
-
_this.helperText = foundationMap.helperText;
|
|
3341
|
-
return _this;
|
|
3342
|
-
}
|
|
3343
|
-
Object.defineProperty(MDCSelectFoundation, "cssClasses", {
|
|
3344
|
-
get: function () {
|
|
3345
|
-
return cssClasses$1;
|
|
3346
|
-
},
|
|
3347
|
-
enumerable: false,
|
|
3348
|
-
configurable: true
|
|
3349
|
-
});
|
|
3350
|
-
Object.defineProperty(MDCSelectFoundation, "numbers", {
|
|
3351
|
-
get: function () {
|
|
3352
|
-
return numbers;
|
|
3353
|
-
},
|
|
3354
|
-
enumerable: false,
|
|
3355
|
-
configurable: true
|
|
3356
|
-
});
|
|
3357
|
-
Object.defineProperty(MDCSelectFoundation, "strings", {
|
|
3358
|
-
get: function () {
|
|
3359
|
-
return strings$2;
|
|
3360
|
-
},
|
|
3361
|
-
enumerable: false,
|
|
3362
|
-
configurable: true
|
|
3363
|
-
});
|
|
3364
|
-
Object.defineProperty(MDCSelectFoundation, "defaultAdapter", {
|
|
3365
|
-
/**
|
|
3366
|
-
* See {@link MDCSelectAdapter} for typing information on parameters and return types.
|
|
3367
|
-
*/
|
|
3368
|
-
get: function () {
|
|
3369
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
3370
|
-
return {
|
|
3371
|
-
addClass: function () { return undefined; },
|
|
3372
|
-
removeClass: function () { return undefined; },
|
|
3373
|
-
hasClass: function () { return false; },
|
|
3374
|
-
activateBottomLine: function () { return undefined; },
|
|
3375
|
-
deactivateBottomLine: function () { return undefined; },
|
|
3376
|
-
getSelectedIndex: function () { return -1; },
|
|
3377
|
-
setSelectedIndex: function () { return undefined; },
|
|
3378
|
-
hasLabel: function () { return false; },
|
|
3379
|
-
floatLabel: function () { return undefined; },
|
|
3380
|
-
getLabelWidth: function () { return 0; },
|
|
3381
|
-
setLabelRequired: function () { return undefined; },
|
|
3382
|
-
hasOutline: function () { return false; },
|
|
3383
|
-
notchOutline: function () { return undefined; },
|
|
3384
|
-
closeOutline: function () { return undefined; },
|
|
3385
|
-
setRippleCenter: function () { return undefined; },
|
|
3386
|
-
notifyChange: function () { return undefined; },
|
|
3387
|
-
setSelectedText: function () { return undefined; },
|
|
3388
|
-
isSelectAnchorFocused: function () { return false; },
|
|
3389
|
-
getSelectAnchorAttr: function () { return ''; },
|
|
3390
|
-
setSelectAnchorAttr: function () { return undefined; },
|
|
3391
|
-
removeSelectAnchorAttr: function () { return undefined; },
|
|
3392
|
-
addMenuClass: function () { return undefined; },
|
|
3393
|
-
removeMenuClass: function () { return undefined; },
|
|
3394
|
-
openMenu: function () { return undefined; },
|
|
3395
|
-
closeMenu: function () { return undefined; },
|
|
3396
|
-
getAnchorElement: function () { return null; },
|
|
3397
|
-
setMenuAnchorElement: function () { return undefined; },
|
|
3398
|
-
setMenuAnchorCorner: function () { return undefined; },
|
|
3399
|
-
setMenuWrapFocus: function () { return undefined; },
|
|
3400
|
-
focusMenuItemAtIndex: function () { return undefined; },
|
|
3401
|
-
getMenuItemCount: function () { return 0; },
|
|
3402
|
-
getMenuItemValues: function () { return []; },
|
|
3403
|
-
getMenuItemTextAtIndex: function () { return ''; },
|
|
3404
|
-
isTypeaheadInProgress: function () { return false; },
|
|
3405
|
-
typeaheadMatchItem: function () { return -1; },
|
|
3406
|
-
};
|
|
3407
|
-
// tslint:enable:object-literal-sort-keys
|
|
3408
|
-
},
|
|
3409
|
-
enumerable: false,
|
|
3410
|
-
configurable: true
|
|
3411
|
-
});
|
|
3412
|
-
/** Returns the index of the currently selected menu item, or -1 if none. */
|
|
3413
|
-
MDCSelectFoundation.prototype.getSelectedIndex = function () {
|
|
3414
|
-
return this.adapter.getSelectedIndex();
|
|
3415
|
-
};
|
|
3416
|
-
MDCSelectFoundation.prototype.setSelectedIndex = function (index, closeMenu, skipNotify) {
|
|
3417
|
-
if (closeMenu === void 0) { closeMenu = false; }
|
|
3418
|
-
if (skipNotify === void 0) { skipNotify = false; }
|
|
3419
|
-
if (index >= this.adapter.getMenuItemCount()) {
|
|
3420
|
-
return;
|
|
3421
|
-
}
|
|
3422
|
-
if (index === numbers.UNSET_INDEX) {
|
|
3423
|
-
this.adapter.setSelectedText('');
|
|
3424
|
-
}
|
|
3425
|
-
else {
|
|
3426
|
-
this.adapter.setSelectedText(this.adapter.getMenuItemTextAtIndex(index).trim());
|
|
3427
|
-
}
|
|
3428
|
-
this.adapter.setSelectedIndex(index);
|
|
3429
|
-
if (closeMenu) {
|
|
3430
|
-
this.adapter.closeMenu();
|
|
3431
|
-
}
|
|
3432
|
-
if (!skipNotify && this.lastSelectedIndex !== index) {
|
|
3433
|
-
this.handleChange();
|
|
3434
|
-
}
|
|
3435
|
-
this.lastSelectedIndex = index;
|
|
3436
|
-
};
|
|
3437
|
-
MDCSelectFoundation.prototype.setValue = function (value, skipNotify) {
|
|
3438
|
-
if (skipNotify === void 0) { skipNotify = false; }
|
|
3439
|
-
var index = this.adapter.getMenuItemValues().indexOf(value);
|
|
3440
|
-
this.setSelectedIndex(index, /** closeMenu */ false, skipNotify);
|
|
3441
|
-
};
|
|
3442
|
-
MDCSelectFoundation.prototype.getValue = function () {
|
|
3443
|
-
var index = this.adapter.getSelectedIndex();
|
|
3444
|
-
var menuItemValues = this.adapter.getMenuItemValues();
|
|
3445
|
-
return index !== numbers.UNSET_INDEX ? menuItemValues[index] : '';
|
|
3446
|
-
};
|
|
3447
|
-
MDCSelectFoundation.prototype.getDisabled = function () {
|
|
3448
|
-
return this.disabled;
|
|
3449
|
-
};
|
|
3450
|
-
MDCSelectFoundation.prototype.setDisabled = function (isDisabled) {
|
|
3451
|
-
this.disabled = isDisabled;
|
|
3452
|
-
if (this.disabled) {
|
|
3453
|
-
this.adapter.addClass(cssClasses$1.DISABLED);
|
|
3454
|
-
this.adapter.closeMenu();
|
|
3455
|
-
}
|
|
3456
|
-
else {
|
|
3457
|
-
this.adapter.removeClass(cssClasses$1.DISABLED);
|
|
3458
|
-
}
|
|
3459
|
-
if (this.leadingIcon) {
|
|
3460
|
-
this.leadingIcon.setDisabled(this.disabled);
|
|
3461
|
-
}
|
|
3462
|
-
if (this.disabled) {
|
|
3463
|
-
// Prevent click events from focusing select. Simply pointer-events: none
|
|
3464
|
-
// is not enough since screenreader clicks may bypass this.
|
|
3465
|
-
this.adapter.removeSelectAnchorAttr('tabindex');
|
|
3466
|
-
}
|
|
3467
|
-
else {
|
|
3468
|
-
this.adapter.setSelectAnchorAttr('tabindex', '0');
|
|
3469
|
-
}
|
|
3470
|
-
this.adapter.setSelectAnchorAttr('aria-disabled', this.disabled.toString());
|
|
3471
|
-
};
|
|
3472
|
-
/** Opens the menu. */
|
|
3473
|
-
MDCSelectFoundation.prototype.openMenu = function () {
|
|
3474
|
-
this.adapter.addClass(cssClasses$1.ACTIVATED);
|
|
3475
|
-
this.adapter.openMenu();
|
|
3476
|
-
this.isMenuOpen = true;
|
|
3477
|
-
this.adapter.setSelectAnchorAttr('aria-expanded', 'true');
|
|
3478
|
-
};
|
|
3479
|
-
/**
|
|
3480
|
-
* @param content Sets the content of the helper text.
|
|
3481
|
-
*/
|
|
3482
|
-
MDCSelectFoundation.prototype.setHelperTextContent = function (content) {
|
|
3483
|
-
if (this.helperText) {
|
|
3484
|
-
this.helperText.setContent(content);
|
|
3485
|
-
}
|
|
3486
|
-
};
|
|
3487
|
-
/**
|
|
3488
|
-
* Re-calculates if the notched outline should be notched and if the label
|
|
3489
|
-
* should float.
|
|
3490
|
-
*/
|
|
3491
|
-
MDCSelectFoundation.prototype.layout = function () {
|
|
3492
|
-
if (this.adapter.hasLabel()) {
|
|
3493
|
-
var optionHasValue = this.getValue().length > 0;
|
|
3494
|
-
var isFocused = this.adapter.hasClass(cssClasses$1.FOCUSED);
|
|
3495
|
-
var shouldFloatAndNotch = optionHasValue || isFocused;
|
|
3496
|
-
var isRequired = this.adapter.hasClass(cssClasses$1.REQUIRED);
|
|
3497
|
-
this.notchOutline(shouldFloatAndNotch);
|
|
3498
|
-
this.adapter.floatLabel(shouldFloatAndNotch);
|
|
3499
|
-
this.adapter.setLabelRequired(isRequired);
|
|
3500
|
-
}
|
|
3501
|
-
};
|
|
3502
|
-
/**
|
|
3503
|
-
* Synchronizes the list of options with the state of the foundation. Call
|
|
3504
|
-
* this whenever menu options are dynamically updated.
|
|
3505
|
-
*/
|
|
3506
|
-
MDCSelectFoundation.prototype.layoutOptions = function () {
|
|
3507
|
-
var menuItemValues = this.adapter.getMenuItemValues();
|
|
3508
|
-
var selectedIndex = menuItemValues.indexOf(this.getValue());
|
|
3509
|
-
this.setSelectedIndex(selectedIndex, /** closeMenu */ false, /** skipNotify */ true);
|
|
3510
|
-
};
|
|
3511
|
-
MDCSelectFoundation.prototype.handleMenuOpened = function () {
|
|
3512
|
-
if (this.adapter.getMenuItemValues().length === 0) {
|
|
3513
|
-
return;
|
|
3514
|
-
}
|
|
3515
|
-
// Menu should open to the last selected element, should open to first menu item otherwise.
|
|
3516
|
-
var selectedIndex = this.getSelectedIndex();
|
|
3517
|
-
var focusItemIndex = selectedIndex >= 0 ? selectedIndex : 0;
|
|
3518
|
-
this.adapter.focusMenuItemAtIndex(focusItemIndex);
|
|
3519
|
-
};
|
|
3520
|
-
MDCSelectFoundation.prototype.handleMenuClosing = function () {
|
|
3521
|
-
this.adapter.setSelectAnchorAttr('aria-expanded', 'false');
|
|
3522
|
-
};
|
|
3523
|
-
MDCSelectFoundation.prototype.handleMenuClosed = function () {
|
|
3524
|
-
this.adapter.removeClass(cssClasses$1.ACTIVATED);
|
|
3525
|
-
this.isMenuOpen = false;
|
|
3526
|
-
// Unfocus the select if menu is closed without a selection
|
|
3527
|
-
if (!this.adapter.isSelectAnchorFocused()) {
|
|
3528
|
-
this.blur();
|
|
3529
|
-
}
|
|
3530
|
-
};
|
|
3531
|
-
/**
|
|
3532
|
-
* Handles value changes, via change event or programmatic updates.
|
|
3533
|
-
*/
|
|
3534
|
-
MDCSelectFoundation.prototype.handleChange = function () {
|
|
3535
|
-
this.layout();
|
|
3536
|
-
this.adapter.notifyChange(this.getValue());
|
|
3537
|
-
var isRequired = this.adapter.hasClass(cssClasses$1.REQUIRED);
|
|
3538
|
-
if (isRequired && this.useDefaultValidation) {
|
|
3539
|
-
this.setValid(this.isValid());
|
|
3540
|
-
}
|
|
3541
|
-
};
|
|
3542
|
-
MDCSelectFoundation.prototype.handleMenuItemAction = function (index) {
|
|
3543
|
-
this.setSelectedIndex(index, /** closeMenu */ true);
|
|
3544
|
-
};
|
|
3545
|
-
/**
|
|
3546
|
-
* Handles focus events from select element.
|
|
3547
|
-
*/
|
|
3548
|
-
MDCSelectFoundation.prototype.handleFocus = function () {
|
|
3549
|
-
this.adapter.addClass(cssClasses$1.FOCUSED);
|
|
3550
|
-
this.layout();
|
|
3551
|
-
this.adapter.activateBottomLine();
|
|
3552
|
-
};
|
|
3553
|
-
/**
|
|
3554
|
-
* Handles blur events from select element.
|
|
3555
|
-
*/
|
|
3556
|
-
MDCSelectFoundation.prototype.handleBlur = function () {
|
|
3557
|
-
if (this.isMenuOpen) {
|
|
3558
|
-
return;
|
|
3559
|
-
}
|
|
3560
|
-
this.blur();
|
|
3561
|
-
};
|
|
3562
|
-
MDCSelectFoundation.prototype.handleClick = function (normalizedX) {
|
|
3563
|
-
if (this.disabled || this.recentlyClicked) {
|
|
3564
|
-
return;
|
|
3565
|
-
}
|
|
3566
|
-
this.setClickDebounceTimeout();
|
|
3567
|
-
if (this.isMenuOpen) {
|
|
3568
|
-
this.adapter.closeMenu();
|
|
3569
|
-
return;
|
|
3570
|
-
}
|
|
3571
|
-
this.adapter.setRippleCenter(normalizedX);
|
|
3572
|
-
this.openMenu();
|
|
3573
|
-
};
|
|
3574
|
-
/**
|
|
3575
|
-
* Handles keydown events on select element. Depending on the type of
|
|
3576
|
-
* character typed, does typeahead matching or opens menu.
|
|
3577
|
-
*/
|
|
3578
|
-
MDCSelectFoundation.prototype.handleKeydown = function (event) {
|
|
3579
|
-
if (this.isMenuOpen || !this.adapter.hasClass(cssClasses$1.FOCUSED)) {
|
|
3580
|
-
return;
|
|
3581
|
-
}
|
|
3582
|
-
var isEnter = normalizeKey(event) === KEY.ENTER;
|
|
3583
|
-
var isSpace = normalizeKey(event) === KEY.SPACEBAR;
|
|
3584
|
-
var arrowUp = normalizeKey(event) === KEY.ARROW_UP;
|
|
3585
|
-
var arrowDown = normalizeKey(event) === KEY.ARROW_DOWN;
|
|
3586
|
-
var isModifier = event.ctrlKey || event.metaKey;
|
|
3587
|
-
// Typeahead
|
|
3588
|
-
if (!isModifier &&
|
|
3589
|
-
(!isSpace && event.key && event.key.length === 1 ||
|
|
3590
|
-
isSpace && this.adapter.isTypeaheadInProgress())) {
|
|
3591
|
-
var key = isSpace ? ' ' : event.key;
|
|
3592
|
-
var typeaheadNextIndex = this.adapter.typeaheadMatchItem(key, this.getSelectedIndex());
|
|
3593
|
-
if (typeaheadNextIndex >= 0) {
|
|
3594
|
-
this.setSelectedIndex(typeaheadNextIndex);
|
|
3595
|
-
}
|
|
3596
|
-
event.preventDefault();
|
|
3597
|
-
return;
|
|
3598
|
-
}
|
|
3599
|
-
if (!isEnter && !isSpace && !arrowUp && !arrowDown) {
|
|
3600
|
-
return;
|
|
3601
|
-
}
|
|
3602
|
-
this.openMenu();
|
|
3603
|
-
event.preventDefault();
|
|
3604
|
-
};
|
|
3605
|
-
/**
|
|
3606
|
-
* Opens/closes the notched outline.
|
|
3607
|
-
*/
|
|
3608
|
-
MDCSelectFoundation.prototype.notchOutline = function (openNotch) {
|
|
3609
|
-
if (!this.adapter.hasOutline()) {
|
|
3610
|
-
return;
|
|
3611
|
-
}
|
|
3612
|
-
var isFocused = this.adapter.hasClass(cssClasses$1.FOCUSED);
|
|
3613
|
-
if (openNotch) {
|
|
3614
|
-
var labelScale = numbers.LABEL_SCALE;
|
|
3615
|
-
var labelWidth = this.adapter.getLabelWidth() * labelScale;
|
|
3616
|
-
this.adapter.notchOutline(labelWidth);
|
|
3617
|
-
}
|
|
3618
|
-
else if (!isFocused) {
|
|
3619
|
-
this.adapter.closeOutline();
|
|
3620
|
-
}
|
|
3621
|
-
};
|
|
3622
|
-
/**
|
|
3623
|
-
* Sets the aria label of the leading icon.
|
|
3624
|
-
*/
|
|
3625
|
-
MDCSelectFoundation.prototype.setLeadingIconAriaLabel = function (label) {
|
|
3626
|
-
if (this.leadingIcon) {
|
|
3627
|
-
this.leadingIcon.setAriaLabel(label);
|
|
3628
|
-
}
|
|
3629
|
-
};
|
|
3630
|
-
/**
|
|
3631
|
-
* Sets the text content of the leading icon.
|
|
3632
|
-
*/
|
|
3633
|
-
MDCSelectFoundation.prototype.setLeadingIconContent = function (content) {
|
|
3634
|
-
if (this.leadingIcon) {
|
|
3635
|
-
this.leadingIcon.setContent(content);
|
|
3636
|
-
}
|
|
3637
|
-
};
|
|
3638
|
-
MDCSelectFoundation.prototype.getUseDefaultValidation = function () {
|
|
3639
|
-
return this.useDefaultValidation;
|
|
3640
|
-
};
|
|
3641
|
-
MDCSelectFoundation.prototype.setUseDefaultValidation = function (useDefaultValidation) {
|
|
3642
|
-
this.useDefaultValidation = useDefaultValidation;
|
|
3643
|
-
};
|
|
3644
|
-
MDCSelectFoundation.prototype.setValid = function (isValid) {
|
|
3645
|
-
if (!this.useDefaultValidation) {
|
|
3646
|
-
this.customValidity = isValid;
|
|
3647
|
-
}
|
|
3648
|
-
this.adapter.setSelectAnchorAttr('aria-invalid', (!isValid).toString());
|
|
3649
|
-
if (isValid) {
|
|
3650
|
-
this.adapter.removeClass(cssClasses$1.INVALID);
|
|
3651
|
-
this.adapter.removeMenuClass(cssClasses$1.MENU_INVALID);
|
|
3652
|
-
}
|
|
3653
|
-
else {
|
|
3654
|
-
this.adapter.addClass(cssClasses$1.INVALID);
|
|
3655
|
-
this.adapter.addMenuClass(cssClasses$1.MENU_INVALID);
|
|
3656
|
-
}
|
|
3657
|
-
this.syncHelperTextValidity(isValid);
|
|
3658
|
-
};
|
|
3659
|
-
MDCSelectFoundation.prototype.isValid = function () {
|
|
3660
|
-
if (this.useDefaultValidation &&
|
|
3661
|
-
this.adapter.hasClass(cssClasses$1.REQUIRED) &&
|
|
3662
|
-
!this.adapter.hasClass(cssClasses$1.DISABLED)) {
|
|
3663
|
-
// See notes for required attribute under https://www.w3.org/TR/html52/sec-forms.html#the-select-element
|
|
3664
|
-
// TL;DR: Invalid if no index is selected, or if the first index is selected and has an empty value.
|
|
3665
|
-
return this.getSelectedIndex() !== numbers.UNSET_INDEX &&
|
|
3666
|
-
(this.getSelectedIndex() !== 0 || Boolean(this.getValue()));
|
|
3667
|
-
}
|
|
3668
|
-
return this.customValidity;
|
|
3669
|
-
};
|
|
3670
|
-
MDCSelectFoundation.prototype.setRequired = function (isRequired) {
|
|
3671
|
-
if (isRequired) {
|
|
3672
|
-
this.adapter.addClass(cssClasses$1.REQUIRED);
|
|
3673
|
-
}
|
|
3674
|
-
else {
|
|
3675
|
-
this.adapter.removeClass(cssClasses$1.REQUIRED);
|
|
3676
|
-
}
|
|
3677
|
-
this.adapter.setSelectAnchorAttr('aria-required', isRequired.toString());
|
|
3678
|
-
this.adapter.setLabelRequired(isRequired);
|
|
3679
|
-
};
|
|
3680
|
-
MDCSelectFoundation.prototype.getRequired = function () {
|
|
3681
|
-
return this.adapter.getSelectAnchorAttr('aria-required') === 'true';
|
|
3682
|
-
};
|
|
3683
|
-
MDCSelectFoundation.prototype.init = function () {
|
|
3684
|
-
var anchorEl = this.adapter.getAnchorElement();
|
|
3685
|
-
if (anchorEl) {
|
|
3686
|
-
this.adapter.setMenuAnchorElement(anchorEl);
|
|
3687
|
-
this.adapter.setMenuAnchorCorner(Corner.BOTTOM_START);
|
|
3688
|
-
}
|
|
3689
|
-
this.adapter.setMenuWrapFocus(false);
|
|
3690
|
-
this.setDisabled(this.adapter.hasClass(cssClasses$1.DISABLED));
|
|
3691
|
-
this.syncHelperTextValidity(!this.adapter.hasClass(cssClasses$1.INVALID));
|
|
3692
|
-
this.layout();
|
|
3693
|
-
this.layoutOptions();
|
|
3694
|
-
};
|
|
3695
|
-
/**
|
|
3696
|
-
* Unfocuses the select component.
|
|
3697
|
-
*/
|
|
3698
|
-
MDCSelectFoundation.prototype.blur = function () {
|
|
3699
|
-
this.adapter.removeClass(cssClasses$1.FOCUSED);
|
|
3700
|
-
this.layout();
|
|
3701
|
-
this.adapter.deactivateBottomLine();
|
|
3702
|
-
var isRequired = this.adapter.hasClass(cssClasses$1.REQUIRED);
|
|
3703
|
-
if (isRequired && this.useDefaultValidation) {
|
|
3704
|
-
this.setValid(this.isValid());
|
|
3705
|
-
}
|
|
3706
|
-
};
|
|
3707
|
-
MDCSelectFoundation.prototype.syncHelperTextValidity = function (isValid) {
|
|
3708
|
-
if (!this.helperText) {
|
|
3709
|
-
return;
|
|
3710
|
-
}
|
|
3711
|
-
this.helperText.setValidity(isValid);
|
|
3712
|
-
var helperTextVisible = this.helperText.isVisible();
|
|
3713
|
-
var helperTextId = this.helperText.getId();
|
|
3714
|
-
if (helperTextVisible && helperTextId) {
|
|
3715
|
-
this.adapter.setSelectAnchorAttr(strings$2.ARIA_DESCRIBEDBY, helperTextId);
|
|
3716
|
-
}
|
|
3717
|
-
else {
|
|
3718
|
-
// Needed because screenreaders will read labels pointed to by
|
|
3719
|
-
// `aria-describedby` even if they are `aria-hidden`.
|
|
3720
|
-
this.adapter.removeSelectAnchorAttr(strings$2.ARIA_DESCRIBEDBY);
|
|
3721
|
-
}
|
|
3722
|
-
};
|
|
3723
|
-
MDCSelectFoundation.prototype.setClickDebounceTimeout = function () {
|
|
3724
|
-
var _this = this;
|
|
3725
|
-
clearTimeout(this.clickDebounceTimeout);
|
|
3726
|
-
this.clickDebounceTimeout = setTimeout(function () {
|
|
3727
|
-
_this.recentlyClicked = false;
|
|
3728
|
-
}, numbers.CLICK_DEBOUNCE_TIMEOUT_MS);
|
|
3729
|
-
this.recentlyClicked = true;
|
|
3730
|
-
};
|
|
3731
|
-
return MDCSelectFoundation;
|
|
3732
|
-
}(MDCFoundation));
|
|
3733
|
-
|
|
3734
|
-
/**
|
|
3735
|
-
* @license
|
|
3736
|
-
* Copyright 2018 Google Inc.
|
|
3737
|
-
*
|
|
3738
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
3739
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
3740
|
-
* in the Software without restriction, including without limitation the rights
|
|
3741
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
3742
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
3743
|
-
* furnished to do so, subject to the following conditions:
|
|
3744
|
-
*
|
|
3745
|
-
* The above copyright notice and this permission notice shall be included in
|
|
3746
|
-
* all copies or substantial portions of the Software.
|
|
3747
|
-
*
|
|
3748
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
3749
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
3750
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
3751
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
3752
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
3753
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
3754
|
-
* THE SOFTWARE.
|
|
3755
|
-
*/
|
|
3756
|
-
var strings$1 = {
|
|
3757
|
-
ARIA_HIDDEN: 'aria-hidden',
|
|
3758
|
-
ROLE: 'role',
|
|
3759
|
-
};
|
|
3760
|
-
var cssClasses = {
|
|
3761
|
-
HELPER_TEXT_VALIDATION_MSG: 'mdc-select-helper-text--validation-msg',
|
|
3762
|
-
HELPER_TEXT_VALIDATION_MSG_PERSISTENT: 'mdc-select-helper-text--validation-msg-persistent',
|
|
3763
|
-
};
|
|
3764
|
-
|
|
3765
|
-
/**
|
|
3766
|
-
* @license
|
|
3767
|
-
* Copyright 2018 Google Inc.
|
|
3768
|
-
*
|
|
3769
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
3770
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
3771
|
-
* in the Software without restriction, including without limitation the rights
|
|
3772
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
3773
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
3774
|
-
* furnished to do so, subject to the following conditions:
|
|
3775
|
-
*
|
|
3776
|
-
* The above copyright notice and this permission notice shall be included in
|
|
3777
|
-
* all copies or substantial portions of the Software.
|
|
3778
|
-
*
|
|
3779
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
3780
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
3781
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
3782
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
3783
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
3784
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
3785
|
-
* THE SOFTWARE.
|
|
3786
|
-
*/
|
|
3787
|
-
var MDCSelectHelperTextFoundation = /** @class */ (function (_super) {
|
|
3788
|
-
__extends(MDCSelectHelperTextFoundation, _super);
|
|
3789
|
-
function MDCSelectHelperTextFoundation(adapter) {
|
|
3790
|
-
return _super.call(this, __assign(__assign({}, MDCSelectHelperTextFoundation.defaultAdapter), adapter)) || this;
|
|
3791
|
-
}
|
|
3792
|
-
Object.defineProperty(MDCSelectHelperTextFoundation, "cssClasses", {
|
|
3793
|
-
get: function () {
|
|
3794
|
-
return cssClasses;
|
|
3795
|
-
},
|
|
3796
|
-
enumerable: false,
|
|
3797
|
-
configurable: true
|
|
3798
|
-
});
|
|
3799
|
-
Object.defineProperty(MDCSelectHelperTextFoundation, "strings", {
|
|
3800
|
-
get: function () {
|
|
3801
|
-
return strings$1;
|
|
3802
|
-
},
|
|
3803
|
-
enumerable: false,
|
|
3804
|
-
configurable: true
|
|
3805
|
-
});
|
|
3806
|
-
Object.defineProperty(MDCSelectHelperTextFoundation, "defaultAdapter", {
|
|
3807
|
-
/**
|
|
3808
|
-
* See {@link MDCSelectHelperTextAdapter} for typing information on parameters and return types.
|
|
3809
|
-
*/
|
|
3810
|
-
get: function () {
|
|
3811
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
3812
|
-
return {
|
|
3813
|
-
addClass: function () { return undefined; },
|
|
3814
|
-
removeClass: function () { return undefined; },
|
|
3815
|
-
hasClass: function () { return false; },
|
|
3816
|
-
setAttr: function () { return undefined; },
|
|
3817
|
-
getAttr: function () { return null; },
|
|
3818
|
-
removeAttr: function () { return undefined; },
|
|
3819
|
-
setContent: function () { return undefined; },
|
|
3820
|
-
};
|
|
3821
|
-
// tslint:enable:object-literal-sort-keys
|
|
3822
|
-
},
|
|
3823
|
-
enumerable: false,
|
|
3824
|
-
configurable: true
|
|
3825
|
-
});
|
|
3826
|
-
/**
|
|
3827
|
-
* @return The ID of the helper text, or null if none is set.
|
|
3828
|
-
*/
|
|
3829
|
-
MDCSelectHelperTextFoundation.prototype.getId = function () {
|
|
3830
|
-
return this.adapter.getAttr('id');
|
|
3831
|
-
};
|
|
3832
|
-
/**
|
|
3833
|
-
* @return Whether the helper text is currently visible.
|
|
3834
|
-
*/
|
|
3835
|
-
MDCSelectHelperTextFoundation.prototype.isVisible = function () {
|
|
3836
|
-
return this.adapter.getAttr(strings$1.ARIA_HIDDEN) !== 'true';
|
|
3837
|
-
};
|
|
3838
|
-
/**
|
|
3839
|
-
* Sets the content of the helper text field.
|
|
3840
|
-
*/
|
|
3841
|
-
MDCSelectHelperTextFoundation.prototype.setContent = function (content) {
|
|
3842
|
-
this.adapter.setContent(content);
|
|
3843
|
-
};
|
|
3844
|
-
/**
|
|
3845
|
-
* Sets the helper text to act as a validation message.
|
|
3846
|
-
* By default, validation messages are hidden when the select is valid and
|
|
3847
|
-
* visible when the select is invalid.
|
|
3848
|
-
*
|
|
3849
|
-
* @param isValidation True to make the helper text act as an error validation
|
|
3850
|
-
* message.
|
|
3851
|
-
*/
|
|
3852
|
-
MDCSelectHelperTextFoundation.prototype.setValidation = function (isValidation) {
|
|
3853
|
-
if (isValidation) {
|
|
3854
|
-
this.adapter.addClass(cssClasses.HELPER_TEXT_VALIDATION_MSG);
|
|
3855
|
-
}
|
|
3856
|
-
else {
|
|
3857
|
-
this.adapter.removeClass(cssClasses.HELPER_TEXT_VALIDATION_MSG);
|
|
3858
|
-
}
|
|
3859
|
-
};
|
|
3860
|
-
/**
|
|
3861
|
-
* Sets the persistency of the validation helper text.
|
|
3862
|
-
* This keeps the validation message visible even if the select is valid,
|
|
3863
|
-
* though it will be displayed in the normal (grey) color.
|
|
3864
|
-
*/
|
|
3865
|
-
MDCSelectHelperTextFoundation.prototype.setValidationMsgPersistent = function (isPersistent) {
|
|
3866
|
-
if (isPersistent) {
|
|
3867
|
-
this.adapter.addClass(cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
|
|
3868
|
-
}
|
|
3869
|
-
else {
|
|
3870
|
-
this.adapter.removeClass(cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
|
|
3871
|
-
}
|
|
3872
|
-
};
|
|
3873
|
-
/**
|
|
3874
|
-
* @return Whether the helper text acts as a validation message.
|
|
3875
|
-
* By default, validation messages are hidden when the select is valid and
|
|
3876
|
-
* visible when the select is invalid.
|
|
3877
|
-
*/
|
|
3878
|
-
MDCSelectHelperTextFoundation.prototype.getIsValidation = function () {
|
|
3879
|
-
return this.adapter.hasClass(cssClasses.HELPER_TEXT_VALIDATION_MSG);
|
|
3880
|
-
};
|
|
3881
|
-
/**
|
|
3882
|
-
* @return Whether the validation helper text persists even if the input is
|
|
3883
|
-
* valid. If it is, it will be displayed in the normal (grey) color.
|
|
3884
|
-
*/
|
|
3885
|
-
MDCSelectHelperTextFoundation.prototype.getIsValidationMsgPersistent = function () {
|
|
3886
|
-
return this.adapter.hasClass(cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
|
|
3887
|
-
};
|
|
3888
|
-
/**
|
|
3889
|
-
* When acting as a validation message, shows/hides the helper text and
|
|
3890
|
-
* triggers alerts as necessary based on the select's validity.
|
|
3891
|
-
*/
|
|
3892
|
-
MDCSelectHelperTextFoundation.prototype.setValidity = function (selectIsValid) {
|
|
3893
|
-
var isValidationMsg = this.adapter.hasClass(cssClasses.HELPER_TEXT_VALIDATION_MSG);
|
|
3894
|
-
if (!isValidationMsg) {
|
|
3895
|
-
// Non-validating helper-text is always displayed and does not participate
|
|
3896
|
-
// in validation logic.
|
|
3897
|
-
return;
|
|
3898
|
-
}
|
|
3899
|
-
var isPersistentValidationMsg = this.adapter.hasClass(cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
|
|
3900
|
-
// Validating helper text is displayed if select is invalid, unless it is
|
|
3901
|
-
// set as persistent, in which case it always displays.
|
|
3902
|
-
var msgShouldDisplay = !selectIsValid || isPersistentValidationMsg;
|
|
3903
|
-
if (msgShouldDisplay) {
|
|
3904
|
-
this.showToScreenReader();
|
|
3905
|
-
// In addition to displaying, also trigger an alert if the select
|
|
3906
|
-
// has become invalid.
|
|
3907
|
-
if (!selectIsValid) {
|
|
3908
|
-
this.adapter.setAttr(strings$1.ROLE, 'alert');
|
|
3909
|
-
}
|
|
3910
|
-
else {
|
|
3911
|
-
this.adapter.removeAttr(strings$1.ROLE);
|
|
3912
|
-
}
|
|
3913
|
-
return;
|
|
3914
|
-
}
|
|
3915
|
-
// Hide everything.
|
|
3916
|
-
this.adapter.removeAttr(strings$1.ROLE);
|
|
3917
|
-
this.hide();
|
|
3918
|
-
};
|
|
3919
|
-
/**
|
|
3920
|
-
* Makes the helper text visible to screen readers.
|
|
3921
|
-
*/
|
|
3922
|
-
MDCSelectHelperTextFoundation.prototype.showToScreenReader = function () {
|
|
3923
|
-
this.adapter.removeAttr(strings$1.ARIA_HIDDEN);
|
|
3924
|
-
};
|
|
3925
|
-
/**
|
|
3926
|
-
* Hides the help text from screen readers.
|
|
3927
|
-
*/
|
|
3928
|
-
MDCSelectHelperTextFoundation.prototype.hide = function () {
|
|
3929
|
-
this.adapter.setAttr(strings$1.ARIA_HIDDEN, 'true');
|
|
3930
|
-
};
|
|
3931
|
-
return MDCSelectHelperTextFoundation;
|
|
3932
|
-
}(MDCFoundation));
|
|
3933
|
-
|
|
3934
|
-
/**
|
|
3935
|
-
* @license
|
|
3936
|
-
* Copyright 2018 Google Inc.
|
|
3937
|
-
*
|
|
3938
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
3939
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
3940
|
-
* in the Software without restriction, including without limitation the rights
|
|
3941
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
3942
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
3943
|
-
* furnished to do so, subject to the following conditions:
|
|
3944
|
-
*
|
|
3945
|
-
* The above copyright notice and this permission notice shall be included in
|
|
3946
|
-
* all copies or substantial portions of the Software.
|
|
3947
|
-
*
|
|
3948
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
3949
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
3950
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
3951
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
3952
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
3953
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
3954
|
-
* THE SOFTWARE.
|
|
3955
|
-
*/
|
|
3956
|
-
var MDCSelectHelperText = /** @class */ (function (_super) {
|
|
3957
|
-
__extends(MDCSelectHelperText, _super);
|
|
3958
|
-
function MDCSelectHelperText() {
|
|
3959
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3960
|
-
}
|
|
3961
|
-
MDCSelectHelperText.attachTo = function (root) {
|
|
3962
|
-
return new MDCSelectHelperText(root);
|
|
3963
|
-
};
|
|
3964
|
-
Object.defineProperty(MDCSelectHelperText.prototype, "foundationForSelect", {
|
|
3965
|
-
// Provided for access by MDCSelect component
|
|
3966
|
-
get: function () {
|
|
3967
|
-
return this.foundation;
|
|
3968
|
-
},
|
|
3969
|
-
enumerable: false,
|
|
3970
|
-
configurable: true
|
|
3971
|
-
});
|
|
3972
|
-
MDCSelectHelperText.prototype.getDefaultFoundation = function () {
|
|
3973
|
-
var _this = this;
|
|
3974
|
-
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
|
|
3975
|
-
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
|
|
3976
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
3977
|
-
var adapter = {
|
|
3978
|
-
addClass: function (className) { return _this.root.classList.add(className); },
|
|
3979
|
-
removeClass: function (className) { return _this.root.classList.remove(className); },
|
|
3980
|
-
hasClass: function (className) { return _this.root.classList.contains(className); },
|
|
3981
|
-
getAttr: function (attr) { return _this.root.getAttribute(attr); },
|
|
3982
|
-
setAttr: function (attr, value) { return _this.root.setAttribute(attr, value); },
|
|
3983
|
-
removeAttr: function (attr) { return _this.root.removeAttribute(attr); },
|
|
3984
|
-
setContent: function (content) {
|
|
3985
|
-
_this.root.textContent = content;
|
|
3986
|
-
},
|
|
3987
|
-
};
|
|
3988
|
-
// tslint:enable:object-literal-sort-keys
|
|
3989
|
-
return new MDCSelectHelperTextFoundation(adapter);
|
|
3990
|
-
};
|
|
3991
|
-
return MDCSelectHelperText;
|
|
3992
|
-
}(MDCComponent));
|
|
3993
|
-
|
|
3994
|
-
/**
|
|
3995
|
-
* @license
|
|
3996
|
-
* Copyright 2018 Google Inc.
|
|
3997
|
-
*
|
|
3998
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
3999
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
4000
|
-
* in the Software without restriction, including without limitation the rights
|
|
4001
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
4002
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
4003
|
-
* furnished to do so, subject to the following conditions:
|
|
4004
|
-
*
|
|
4005
|
-
* The above copyright notice and this permission notice shall be included in
|
|
4006
|
-
* all copies or substantial portions of the Software.
|
|
4007
|
-
*
|
|
4008
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
4009
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
4010
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
4011
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
4012
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
4013
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
4014
|
-
* THE SOFTWARE.
|
|
4015
|
-
*/
|
|
4016
|
-
var strings = {
|
|
4017
|
-
ICON_EVENT: 'MDCSelect:icon',
|
|
4018
|
-
ICON_ROLE: 'button',
|
|
4019
|
-
};
|
|
4020
|
-
|
|
4021
|
-
/**
|
|
4022
|
-
* @license
|
|
4023
|
-
* Copyright 2018 Google Inc.
|
|
4024
|
-
*
|
|
4025
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4026
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
4027
|
-
* in the Software without restriction, including without limitation the rights
|
|
4028
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
4029
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
4030
|
-
* furnished to do so, subject to the following conditions:
|
|
4031
|
-
*
|
|
4032
|
-
* The above copyright notice and this permission notice shall be included in
|
|
4033
|
-
* all copies or substantial portions of the Software.
|
|
4034
|
-
*
|
|
4035
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
4036
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
4037
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
4038
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
4039
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
4040
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
4041
|
-
* THE SOFTWARE.
|
|
4042
|
-
*/
|
|
4043
|
-
var INTERACTION_EVENTS = ['click', 'keydown'];
|
|
4044
|
-
var MDCSelectIconFoundation = /** @class */ (function (_super) {
|
|
4045
|
-
__extends(MDCSelectIconFoundation, _super);
|
|
4046
|
-
function MDCSelectIconFoundation(adapter) {
|
|
4047
|
-
var _this = _super.call(this, __assign(__assign({}, MDCSelectIconFoundation.defaultAdapter), adapter)) || this;
|
|
4048
|
-
_this.savedTabIndex = null;
|
|
4049
|
-
_this.interactionHandler = function (evt) {
|
|
4050
|
-
_this.handleInteraction(evt);
|
|
4051
|
-
};
|
|
4052
|
-
return _this;
|
|
4053
|
-
}
|
|
4054
|
-
Object.defineProperty(MDCSelectIconFoundation, "strings", {
|
|
4055
|
-
get: function () {
|
|
4056
|
-
return strings;
|
|
4057
|
-
},
|
|
4058
|
-
enumerable: false,
|
|
4059
|
-
configurable: true
|
|
4060
|
-
});
|
|
4061
|
-
Object.defineProperty(MDCSelectIconFoundation, "defaultAdapter", {
|
|
4062
|
-
/**
|
|
4063
|
-
* See {@link MDCSelectIconAdapter} for typing information on parameters and return types.
|
|
4064
|
-
*/
|
|
4065
|
-
get: function () {
|
|
4066
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
4067
|
-
return {
|
|
4068
|
-
getAttr: function () { return null; },
|
|
4069
|
-
setAttr: function () { return undefined; },
|
|
4070
|
-
removeAttr: function () { return undefined; },
|
|
4071
|
-
setContent: function () { return undefined; },
|
|
4072
|
-
registerInteractionHandler: function () { return undefined; },
|
|
4073
|
-
deregisterInteractionHandler: function () { return undefined; },
|
|
4074
|
-
notifyIconAction: function () { return undefined; },
|
|
4075
|
-
};
|
|
4076
|
-
// tslint:enable:object-literal-sort-keys
|
|
4077
|
-
},
|
|
4078
|
-
enumerable: false,
|
|
4079
|
-
configurable: true
|
|
4080
|
-
});
|
|
4081
|
-
MDCSelectIconFoundation.prototype.init = function () {
|
|
4082
|
-
var e_1, _a;
|
|
4083
|
-
this.savedTabIndex = this.adapter.getAttr('tabindex');
|
|
4084
|
-
try {
|
|
4085
|
-
for (var INTERACTION_EVENTS_1 = __values(INTERACTION_EVENTS), INTERACTION_EVENTS_1_1 = INTERACTION_EVENTS_1.next(); !INTERACTION_EVENTS_1_1.done; INTERACTION_EVENTS_1_1 = INTERACTION_EVENTS_1.next()) {
|
|
4086
|
-
var evtType = INTERACTION_EVENTS_1_1.value;
|
|
4087
|
-
this.adapter.registerInteractionHandler(evtType, this.interactionHandler);
|
|
4088
|
-
}
|
|
4089
|
-
}
|
|
4090
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
4091
|
-
finally {
|
|
4092
|
-
try {
|
|
4093
|
-
if (INTERACTION_EVENTS_1_1 && !INTERACTION_EVENTS_1_1.done && (_a = INTERACTION_EVENTS_1.return)) _a.call(INTERACTION_EVENTS_1);
|
|
4094
|
-
}
|
|
4095
|
-
finally { if (e_1) throw e_1.error; }
|
|
4096
|
-
}
|
|
4097
|
-
};
|
|
4098
|
-
MDCSelectIconFoundation.prototype.destroy = function () {
|
|
4099
|
-
var e_2, _a;
|
|
4100
|
-
try {
|
|
4101
|
-
for (var INTERACTION_EVENTS_2 = __values(INTERACTION_EVENTS), INTERACTION_EVENTS_2_1 = INTERACTION_EVENTS_2.next(); !INTERACTION_EVENTS_2_1.done; INTERACTION_EVENTS_2_1 = INTERACTION_EVENTS_2.next()) {
|
|
4102
|
-
var evtType = INTERACTION_EVENTS_2_1.value;
|
|
4103
|
-
this.adapter.deregisterInteractionHandler(evtType, this.interactionHandler);
|
|
4104
|
-
}
|
|
4105
|
-
}
|
|
4106
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
4107
|
-
finally {
|
|
4108
|
-
try {
|
|
4109
|
-
if (INTERACTION_EVENTS_2_1 && !INTERACTION_EVENTS_2_1.done && (_a = INTERACTION_EVENTS_2.return)) _a.call(INTERACTION_EVENTS_2);
|
|
4110
|
-
}
|
|
4111
|
-
finally { if (e_2) throw e_2.error; }
|
|
4112
|
-
}
|
|
4113
|
-
};
|
|
4114
|
-
MDCSelectIconFoundation.prototype.setDisabled = function (disabled) {
|
|
4115
|
-
if (!this.savedTabIndex) {
|
|
4116
|
-
return;
|
|
4117
|
-
}
|
|
4118
|
-
if (disabled) {
|
|
4119
|
-
this.adapter.setAttr('tabindex', '-1');
|
|
4120
|
-
this.adapter.removeAttr('role');
|
|
4121
|
-
}
|
|
4122
|
-
else {
|
|
4123
|
-
this.adapter.setAttr('tabindex', this.savedTabIndex);
|
|
4124
|
-
this.adapter.setAttr('role', strings.ICON_ROLE);
|
|
4125
|
-
}
|
|
4126
|
-
};
|
|
4127
|
-
MDCSelectIconFoundation.prototype.setAriaLabel = function (label) {
|
|
4128
|
-
this.adapter.setAttr('aria-label', label);
|
|
4129
|
-
};
|
|
4130
|
-
MDCSelectIconFoundation.prototype.setContent = function (content) {
|
|
4131
|
-
this.adapter.setContent(content);
|
|
4132
|
-
};
|
|
4133
|
-
MDCSelectIconFoundation.prototype.handleInteraction = function (evt) {
|
|
4134
|
-
var isEnterKey = evt.key === 'Enter' || evt.keyCode === 13;
|
|
4135
|
-
if (evt.type === 'click' || isEnterKey) {
|
|
4136
|
-
this.adapter.notifyIconAction();
|
|
4137
|
-
}
|
|
4138
|
-
};
|
|
4139
|
-
return MDCSelectIconFoundation;
|
|
4140
|
-
}(MDCFoundation));
|
|
4141
|
-
|
|
4142
|
-
/**
|
|
4143
|
-
* @license
|
|
4144
|
-
* Copyright 2018 Google Inc.
|
|
4145
|
-
*
|
|
4146
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4147
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
4148
|
-
* in the Software without restriction, including without limitation the rights
|
|
4149
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
4150
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
4151
|
-
* furnished to do so, subject to the following conditions:
|
|
4152
|
-
*
|
|
4153
|
-
* The above copyright notice and this permission notice shall be included in
|
|
4154
|
-
* all copies or substantial portions of the Software.
|
|
4155
|
-
*
|
|
4156
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
4157
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
4158
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
4159
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
4160
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
4161
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
4162
|
-
* THE SOFTWARE.
|
|
4163
|
-
*/
|
|
4164
|
-
var MDCSelectIcon = /** @class */ (function (_super) {
|
|
4165
|
-
__extends(MDCSelectIcon, _super);
|
|
4166
|
-
function MDCSelectIcon() {
|
|
4167
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
4168
|
-
}
|
|
4169
|
-
MDCSelectIcon.attachTo = function (root) {
|
|
4170
|
-
return new MDCSelectIcon(root);
|
|
4171
|
-
};
|
|
4172
|
-
Object.defineProperty(MDCSelectIcon.prototype, "foundationForSelect", {
|
|
4173
|
-
// Provided for access by MDCSelect component
|
|
4174
|
-
get: function () {
|
|
4175
|
-
return this.foundation;
|
|
4176
|
-
},
|
|
4177
|
-
enumerable: false,
|
|
4178
|
-
configurable: true
|
|
4179
|
-
});
|
|
4180
|
-
MDCSelectIcon.prototype.getDefaultFoundation = function () {
|
|
4181
|
-
var _this = this;
|
|
4182
|
-
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
|
|
4183
|
-
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
|
|
4184
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
4185
|
-
var adapter = {
|
|
4186
|
-
getAttr: function (attr) { return _this.root.getAttribute(attr); },
|
|
4187
|
-
setAttr: function (attr, value) { return _this.root.setAttribute(attr, value); },
|
|
4188
|
-
removeAttr: function (attr) { return _this.root.removeAttribute(attr); },
|
|
4189
|
-
setContent: function (content) {
|
|
4190
|
-
_this.root.textContent = content;
|
|
4191
|
-
},
|
|
4192
|
-
registerInteractionHandler: function (evtType, handler) {
|
|
4193
|
-
return _this.listen(evtType, handler);
|
|
4194
|
-
},
|
|
4195
|
-
deregisterInteractionHandler: function (evtType, handler) {
|
|
4196
|
-
return _this.unlisten(evtType, handler);
|
|
4197
|
-
},
|
|
4198
|
-
notifyIconAction: function () { return _this.emit(MDCSelectIconFoundation.strings.ICON_EVENT, {} /* evtData */, true /* shouldBubble */); },
|
|
4199
|
-
};
|
|
4200
|
-
// tslint:enable:object-literal-sort-keys
|
|
4201
|
-
return new MDCSelectIconFoundation(adapter);
|
|
4202
|
-
};
|
|
4203
|
-
return MDCSelectIcon;
|
|
4204
|
-
}(MDCComponent));
|
|
4205
|
-
|
|
4206
|
-
/**
|
|
4207
|
-
* @license
|
|
4208
|
-
* Copyright 2016 Google Inc.
|
|
4209
|
-
*
|
|
4210
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4211
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
4212
|
-
* in the Software without restriction, including without limitation the rights
|
|
4213
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
4214
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
4215
|
-
* furnished to do so, subject to the following conditions:
|
|
4216
|
-
*
|
|
4217
|
-
* The above copyright notice and this permission notice shall be included in
|
|
4218
|
-
* all copies or substantial portions of the Software.
|
|
4219
|
-
*
|
|
4220
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
4221
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
4222
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
4223
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
4224
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
4225
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
4226
|
-
* THE SOFTWARE.
|
|
4227
|
-
*/
|
|
4228
|
-
var MDCSelect = /** @class */ (function (_super) {
|
|
4229
|
-
__extends(MDCSelect, _super);
|
|
4230
|
-
function MDCSelect() {
|
|
4231
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
4232
|
-
}
|
|
4233
|
-
MDCSelect.attachTo = function (root) {
|
|
4234
|
-
return new MDCSelect(root);
|
|
4235
|
-
};
|
|
4236
|
-
MDCSelect.prototype.initialize = function (labelFactory, lineRippleFactory, outlineFactory, menuFactory, iconFactory, helperTextFactory) {
|
|
4237
|
-
if (labelFactory === void 0) { labelFactory = function (el) { return new MDCFloatingLabel(el); }; }
|
|
4238
|
-
if (lineRippleFactory === void 0) { lineRippleFactory = function (el) { return new MDCLineRipple(el); }; }
|
|
4239
|
-
if (outlineFactory === void 0) { outlineFactory = function (el) { return new MDCNotchedOutline(el); }; }
|
|
4240
|
-
if (menuFactory === void 0) { menuFactory = function (el) { return new MDCMenu(el); }; }
|
|
4241
|
-
if (iconFactory === void 0) { iconFactory = function (el) { return new MDCSelectIcon(el); }; }
|
|
4242
|
-
if (helperTextFactory === void 0) { helperTextFactory = function (el) { return new MDCSelectHelperText(el); }; }
|
|
4243
|
-
this.selectAnchor =
|
|
4244
|
-
this.root.querySelector(strings$2.SELECT_ANCHOR_SELECTOR);
|
|
4245
|
-
this.selectedText =
|
|
4246
|
-
this.root.querySelector(strings$2.SELECTED_TEXT_SELECTOR);
|
|
4247
|
-
this.hiddenInput = this.root.querySelector(strings$2.HIDDEN_INPUT_SELECTOR);
|
|
4248
|
-
if (!this.selectedText) {
|
|
4249
|
-
throw new Error('MDCSelect: Missing required element: The following selector must be present: ' +
|
|
4250
|
-
("'" + strings$2.SELECTED_TEXT_SELECTOR + "'"));
|
|
4251
|
-
}
|
|
4252
|
-
if (this.selectAnchor.hasAttribute(strings$2.ARIA_CONTROLS)) {
|
|
4253
|
-
var helperTextElement = document.getElementById(this.selectAnchor.getAttribute(strings$2.ARIA_CONTROLS));
|
|
4254
|
-
if (helperTextElement) {
|
|
4255
|
-
this.helperText = helperTextFactory(helperTextElement);
|
|
4256
|
-
}
|
|
4257
|
-
}
|
|
4258
|
-
this.menuSetup(menuFactory);
|
|
4259
|
-
var labelElement = this.root.querySelector(strings$2.LABEL_SELECTOR);
|
|
4260
|
-
this.label = labelElement ? labelFactory(labelElement) : null;
|
|
4261
|
-
var lineRippleElement = this.root.querySelector(strings$2.LINE_RIPPLE_SELECTOR);
|
|
4262
|
-
this.lineRipple =
|
|
4263
|
-
lineRippleElement ? lineRippleFactory(lineRippleElement) : null;
|
|
4264
|
-
var outlineElement = this.root.querySelector(strings$2.OUTLINE_SELECTOR);
|
|
4265
|
-
this.outline = outlineElement ? outlineFactory(outlineElement) : null;
|
|
4266
|
-
var leadingIcon = this.root.querySelector(strings$2.LEADING_ICON_SELECTOR);
|
|
4267
|
-
if (leadingIcon) {
|
|
4268
|
-
this.leadingIcon = iconFactory(leadingIcon);
|
|
4269
|
-
}
|
|
4270
|
-
if (!this.root.classList.contains(cssClasses$1.OUTLINED)) {
|
|
4271
|
-
this.ripple = this.createRipple();
|
|
4272
|
-
}
|
|
4273
|
-
};
|
|
4274
|
-
/**
|
|
4275
|
-
* Initializes the select's event listeners and internal state based
|
|
4276
|
-
* on the environment's state.
|
|
4277
|
-
*/
|
|
4278
|
-
MDCSelect.prototype.initialSyncWithDOM = function () {
|
|
4279
|
-
var _this = this;
|
|
4280
|
-
this.handleFocus = function () {
|
|
4281
|
-
_this.foundation.handleFocus();
|
|
4282
|
-
};
|
|
4283
|
-
this.handleBlur = function () {
|
|
4284
|
-
_this.foundation.handleBlur();
|
|
4285
|
-
};
|
|
4286
|
-
this.handleClick = function (evt) {
|
|
4287
|
-
_this.selectAnchor.focus();
|
|
4288
|
-
_this.foundation.handleClick(_this.getNormalizedXCoordinate(evt));
|
|
4289
|
-
};
|
|
4290
|
-
this.handleKeydown = function (evt) {
|
|
4291
|
-
_this.foundation.handleKeydown(evt);
|
|
4292
|
-
};
|
|
4293
|
-
this.handleMenuItemAction = function (evt) {
|
|
4294
|
-
_this.foundation.handleMenuItemAction(evt.detail.index);
|
|
4295
|
-
};
|
|
4296
|
-
this.handleMenuOpened = function () {
|
|
4297
|
-
_this.foundation.handleMenuOpened();
|
|
4298
|
-
};
|
|
4299
|
-
this.handleMenuClosed = function () {
|
|
4300
|
-
_this.foundation.handleMenuClosed();
|
|
4301
|
-
};
|
|
4302
|
-
this.handleMenuClosing = function () {
|
|
4303
|
-
_this.foundation.handleMenuClosing();
|
|
4304
|
-
};
|
|
4305
|
-
this.selectAnchor.addEventListener('focus', this.handleFocus);
|
|
4306
|
-
this.selectAnchor.addEventListener('blur', this.handleBlur);
|
|
4307
|
-
this.selectAnchor.addEventListener('click', this.handleClick);
|
|
4308
|
-
this.selectAnchor.addEventListener('keydown', this.handleKeydown);
|
|
4309
|
-
this.menu.listen(strings$5.CLOSED_EVENT, this.handleMenuClosed);
|
|
4310
|
-
this.menu.listen(strings$5.CLOSING_EVENT, this.handleMenuClosing);
|
|
4311
|
-
this.menu.listen(strings$5.OPENED_EVENT, this.handleMenuOpened);
|
|
4312
|
-
this.menu.listen(strings$3.SELECTED_EVENT, this.handleMenuItemAction);
|
|
4313
|
-
if (this.hiddenInput) {
|
|
4314
|
-
if (this.hiddenInput.value) {
|
|
4315
|
-
// If the hidden input already has a value, use it to restore the
|
|
4316
|
-
// select's value. This can happen e.g. if the user goes back or (in
|
|
4317
|
-
// some browsers) refreshes the page.
|
|
4318
|
-
this.foundation.setValue(this.hiddenInput.value, /** skipNotify */ true);
|
|
4319
|
-
this.foundation.layout();
|
|
4320
|
-
return;
|
|
4321
|
-
}
|
|
4322
|
-
this.hiddenInput.value = this.value;
|
|
4323
|
-
}
|
|
4324
|
-
};
|
|
4325
|
-
MDCSelect.prototype.destroy = function () {
|
|
4326
|
-
this.selectAnchor.removeEventListener('focus', this.handleFocus);
|
|
4327
|
-
this.selectAnchor.removeEventListener('blur', this.handleBlur);
|
|
4328
|
-
this.selectAnchor.removeEventListener('keydown', this.handleKeydown);
|
|
4329
|
-
this.selectAnchor.removeEventListener('click', this.handleClick);
|
|
4330
|
-
this.menu.unlisten(strings$5.CLOSED_EVENT, this.handleMenuClosed);
|
|
4331
|
-
this.menu.unlisten(strings$5.OPENED_EVENT, this.handleMenuOpened);
|
|
4332
|
-
this.menu.unlisten(strings$3.SELECTED_EVENT, this.handleMenuItemAction);
|
|
4333
|
-
this.menu.destroy();
|
|
4334
|
-
if (this.ripple) {
|
|
4335
|
-
this.ripple.destroy();
|
|
4336
|
-
}
|
|
4337
|
-
if (this.outline) {
|
|
4338
|
-
this.outline.destroy();
|
|
4339
|
-
}
|
|
4340
|
-
if (this.leadingIcon) {
|
|
4341
|
-
this.leadingIcon.destroy();
|
|
4342
|
-
}
|
|
4343
|
-
if (this.helperText) {
|
|
4344
|
-
this.helperText.destroy();
|
|
4345
|
-
}
|
|
4346
|
-
_super.prototype.destroy.call(this);
|
|
4347
|
-
};
|
|
4348
|
-
Object.defineProperty(MDCSelect.prototype, "value", {
|
|
4349
|
-
get: function () {
|
|
4350
|
-
return this.foundation.getValue();
|
|
4351
|
-
},
|
|
4352
|
-
set: function (value) {
|
|
4353
|
-
this.foundation.setValue(value);
|
|
4354
|
-
},
|
|
4355
|
-
enumerable: false,
|
|
4356
|
-
configurable: true
|
|
4357
|
-
});
|
|
4358
|
-
MDCSelect.prototype.setValue = function (value, skipNotify) {
|
|
4359
|
-
if (skipNotify === void 0) { skipNotify = false; }
|
|
4360
|
-
this.foundation.setValue(value, skipNotify);
|
|
4361
|
-
};
|
|
4362
|
-
Object.defineProperty(MDCSelect.prototype, "selectedIndex", {
|
|
4363
|
-
get: function () {
|
|
4364
|
-
return this.foundation.getSelectedIndex();
|
|
4365
|
-
},
|
|
4366
|
-
set: function (selectedIndex) {
|
|
4367
|
-
this.foundation.setSelectedIndex(selectedIndex, /* closeMenu */ true);
|
|
4368
|
-
},
|
|
4369
|
-
enumerable: false,
|
|
4370
|
-
configurable: true
|
|
4371
|
-
});
|
|
4372
|
-
MDCSelect.prototype.setSelectedIndex = function (selectedIndex, skipNotify) {
|
|
4373
|
-
if (skipNotify === void 0) { skipNotify = false; }
|
|
4374
|
-
this.foundation.setSelectedIndex(selectedIndex, /* closeMenu */ true, skipNotify);
|
|
4375
|
-
};
|
|
4376
|
-
Object.defineProperty(MDCSelect.prototype, "disabled", {
|
|
4377
|
-
get: function () {
|
|
4378
|
-
return this.foundation.getDisabled();
|
|
4379
|
-
},
|
|
4380
|
-
set: function (disabled) {
|
|
4381
|
-
this.foundation.setDisabled(disabled);
|
|
4382
|
-
if (this.hiddenInput) {
|
|
4383
|
-
this.hiddenInput.disabled = disabled;
|
|
4384
|
-
}
|
|
4385
|
-
},
|
|
4386
|
-
enumerable: false,
|
|
4387
|
-
configurable: true
|
|
4388
|
-
});
|
|
4389
|
-
Object.defineProperty(MDCSelect.prototype, "leadingIconAriaLabel", {
|
|
4390
|
-
set: function (label) {
|
|
4391
|
-
this.foundation.setLeadingIconAriaLabel(label);
|
|
4392
|
-
},
|
|
4393
|
-
enumerable: false,
|
|
4394
|
-
configurable: true
|
|
4395
|
-
});
|
|
4396
|
-
Object.defineProperty(MDCSelect.prototype, "leadingIconContent", {
|
|
4397
|
-
/**
|
|
4398
|
-
* Sets the text content of the leading icon.
|
|
4399
|
-
*/
|
|
4400
|
-
set: function (content) {
|
|
4401
|
-
this.foundation.setLeadingIconContent(content);
|
|
4402
|
-
},
|
|
4403
|
-
enumerable: false,
|
|
4404
|
-
configurable: true
|
|
4405
|
-
});
|
|
4406
|
-
Object.defineProperty(MDCSelect.prototype, "helperTextContent", {
|
|
4407
|
-
/**
|
|
4408
|
-
* Sets the text content of the helper text.
|
|
4409
|
-
*/
|
|
4410
|
-
set: function (content) {
|
|
4411
|
-
this.foundation.setHelperTextContent(content);
|
|
4412
|
-
},
|
|
4413
|
-
enumerable: false,
|
|
4414
|
-
configurable: true
|
|
4415
|
-
});
|
|
4416
|
-
Object.defineProperty(MDCSelect.prototype, "useDefaultValidation", {
|
|
4417
|
-
/**
|
|
4418
|
-
* Enables or disables the default validation scheme where a required select
|
|
4419
|
-
* must be non-empty. Set to false for custom validation.
|
|
4420
|
-
* @param useDefaultValidation Set this to false to ignore default
|
|
4421
|
-
* validation scheme.
|
|
4422
|
-
*/
|
|
4423
|
-
set: function (useDefaultValidation) {
|
|
4424
|
-
this.foundation.setUseDefaultValidation(useDefaultValidation);
|
|
4425
|
-
},
|
|
4426
|
-
enumerable: false,
|
|
4427
|
-
configurable: true
|
|
4428
|
-
});
|
|
4429
|
-
Object.defineProperty(MDCSelect.prototype, "valid", {
|
|
4430
|
-
/**
|
|
4431
|
-
* Checks if the select is in a valid state.
|
|
4432
|
-
*/
|
|
4433
|
-
get: function () {
|
|
4434
|
-
return this.foundation.isValid();
|
|
4435
|
-
},
|
|
4436
|
-
/**
|
|
4437
|
-
* Sets the current invalid state of the select.
|
|
4438
|
-
*/
|
|
4439
|
-
set: function (isValid) {
|
|
4440
|
-
this.foundation.setValid(isValid);
|
|
4441
|
-
},
|
|
4442
|
-
enumerable: false,
|
|
4443
|
-
configurable: true
|
|
4444
|
-
});
|
|
4445
|
-
Object.defineProperty(MDCSelect.prototype, "required", {
|
|
4446
|
-
/**
|
|
4447
|
-
* Returns whether the select is required.
|
|
4448
|
-
*/
|
|
4449
|
-
get: function () {
|
|
4450
|
-
return this.foundation.getRequired();
|
|
4451
|
-
},
|
|
4452
|
-
/**
|
|
4453
|
-
* Sets the control to the required state.
|
|
4454
|
-
*/
|
|
4455
|
-
set: function (isRequired) {
|
|
4456
|
-
this.foundation.setRequired(isRequired);
|
|
4457
|
-
},
|
|
4458
|
-
enumerable: false,
|
|
4459
|
-
configurable: true
|
|
4460
|
-
});
|
|
4461
|
-
/**
|
|
4462
|
-
* Re-calculates if the notched outline should be notched and if the label
|
|
4463
|
-
* should float.
|
|
4464
|
-
*/
|
|
4465
|
-
MDCSelect.prototype.layout = function () {
|
|
4466
|
-
this.foundation.layout();
|
|
4467
|
-
};
|
|
4468
|
-
/**
|
|
4469
|
-
* Synchronizes the list of options with the state of the foundation. Call
|
|
4470
|
-
* this whenever menu options are dynamically updated.
|
|
4471
|
-
*/
|
|
4472
|
-
MDCSelect.prototype.layoutOptions = function () {
|
|
4473
|
-
this.foundation.layoutOptions();
|
|
4474
|
-
this.menu.layout();
|
|
4475
|
-
// Update cached menuItemValues for adapter.
|
|
4476
|
-
this.menuItemValues =
|
|
4477
|
-
this.menu.items.map(function (el) { return el.getAttribute(strings$2.VALUE_ATTR) || ''; });
|
|
4478
|
-
if (this.hiddenInput) {
|
|
4479
|
-
this.hiddenInput.value = this.value;
|
|
4480
|
-
}
|
|
4481
|
-
};
|
|
4482
|
-
MDCSelect.prototype.getDefaultFoundation = function () {
|
|
4483
|
-
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
|
|
4484
|
-
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
|
|
4485
|
-
var adapter = __assign(__assign(__assign(__assign({}, this.getSelectAdapterMethods()), this.getCommonAdapterMethods()), this.getOutlineAdapterMethods()), this.getLabelAdapterMethods());
|
|
4486
|
-
return new MDCSelectFoundation(adapter, this.getFoundationMap());
|
|
4487
|
-
};
|
|
4488
|
-
/**
|
|
4489
|
-
* Handles setup for the menu.
|
|
4490
|
-
*/
|
|
4491
|
-
MDCSelect.prototype.menuSetup = function (menuFactory) {
|
|
4492
|
-
this.menuElement = this.root.querySelector(strings$2.MENU_SELECTOR);
|
|
4493
|
-
this.menu = menuFactory(this.menuElement);
|
|
4494
|
-
this.menu.hasTypeahead = true;
|
|
4495
|
-
this.menu.singleSelection = true;
|
|
4496
|
-
this.menuItemValues =
|
|
4497
|
-
this.menu.items.map(function (el) { return el.getAttribute(strings$2.VALUE_ATTR) || ''; });
|
|
4498
|
-
};
|
|
4499
|
-
MDCSelect.prototype.createRipple = function () {
|
|
4500
|
-
var _this = this;
|
|
4501
|
-
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
|
|
4502
|
-
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
|
|
4503
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
4504
|
-
var adapter = __assign(__assign({}, MDCRipple.createAdapter({ root: this.selectAnchor })), { registerInteractionHandler: function (evtType, handler) {
|
|
4505
|
-
_this.selectAnchor.addEventListener(evtType, handler);
|
|
4506
|
-
}, deregisterInteractionHandler: function (evtType, handler) {
|
|
4507
|
-
_this.selectAnchor.removeEventListener(evtType, handler);
|
|
4508
|
-
} });
|
|
4509
|
-
// tslint:enable:object-literal-sort-keys
|
|
4510
|
-
return new MDCRipple(this.selectAnchor, new MDCRippleFoundation(adapter));
|
|
4511
|
-
};
|
|
4512
|
-
MDCSelect.prototype.getSelectAdapterMethods = function () {
|
|
4513
|
-
var _this = this;
|
|
4514
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
4515
|
-
return {
|
|
4516
|
-
getMenuItemAttr: function (menuItem, attr) {
|
|
4517
|
-
return menuItem.getAttribute(attr);
|
|
4518
|
-
},
|
|
4519
|
-
setSelectedText: function (text) {
|
|
4520
|
-
_this.selectedText.textContent = text;
|
|
4521
|
-
},
|
|
4522
|
-
isSelectAnchorFocused: function () { return document.activeElement === _this.selectAnchor; },
|
|
4523
|
-
getSelectAnchorAttr: function (attr) {
|
|
4524
|
-
return _this.selectAnchor.getAttribute(attr);
|
|
4525
|
-
},
|
|
4526
|
-
setSelectAnchorAttr: function (attr, value) {
|
|
4527
|
-
_this.selectAnchor.setAttribute(attr, value);
|
|
4528
|
-
},
|
|
4529
|
-
removeSelectAnchorAttr: function (attr) {
|
|
4530
|
-
_this.selectAnchor.removeAttribute(attr);
|
|
4531
|
-
},
|
|
4532
|
-
addMenuClass: function (className) {
|
|
4533
|
-
_this.menuElement.classList.add(className);
|
|
4534
|
-
},
|
|
4535
|
-
removeMenuClass: function (className) {
|
|
4536
|
-
_this.menuElement.classList.remove(className);
|
|
4537
|
-
},
|
|
4538
|
-
openMenu: function () {
|
|
4539
|
-
_this.menu.open = true;
|
|
4540
|
-
},
|
|
4541
|
-
closeMenu: function () {
|
|
4542
|
-
_this.menu.open = false;
|
|
4543
|
-
},
|
|
4544
|
-
getAnchorElement: function () {
|
|
4545
|
-
return _this.root.querySelector(strings$2.SELECT_ANCHOR_SELECTOR);
|
|
4546
|
-
},
|
|
4547
|
-
setMenuAnchorElement: function (anchorEl) {
|
|
4548
|
-
_this.menu.setAnchorElement(anchorEl);
|
|
4549
|
-
},
|
|
4550
|
-
setMenuAnchorCorner: function (anchorCorner) {
|
|
4551
|
-
_this.menu.setAnchorCorner(anchorCorner);
|
|
4552
|
-
},
|
|
4553
|
-
setMenuWrapFocus: function (wrapFocus) {
|
|
4554
|
-
_this.menu.wrapFocus = wrapFocus;
|
|
4555
|
-
},
|
|
4556
|
-
getSelectedIndex: function () {
|
|
4557
|
-
var index = _this.menu.selectedIndex;
|
|
4558
|
-
return index instanceof Array ? index[0] : index;
|
|
4559
|
-
},
|
|
4560
|
-
setSelectedIndex: function (index) {
|
|
4561
|
-
_this.menu.selectedIndex = index;
|
|
4562
|
-
},
|
|
4563
|
-
focusMenuItemAtIndex: function (index) {
|
|
4564
|
-
_this.menu.items[index].focus();
|
|
4565
|
-
},
|
|
4566
|
-
getMenuItemCount: function () { return _this.menu.items.length; },
|
|
4567
|
-
// Cache menu item values. layoutOptions() updates this cache.
|
|
4568
|
-
getMenuItemValues: function () { return _this.menuItemValues; },
|
|
4569
|
-
getMenuItemTextAtIndex: function (index) {
|
|
4570
|
-
return _this.menu.getPrimaryTextAtIndex(index);
|
|
4571
|
-
},
|
|
4572
|
-
isTypeaheadInProgress: function () { return _this.menu.typeaheadInProgress; },
|
|
4573
|
-
typeaheadMatchItem: function (nextChar, startingIndex) {
|
|
4574
|
-
return _this.menu.typeaheadMatchItem(nextChar, startingIndex);
|
|
4575
|
-
},
|
|
4576
|
-
};
|
|
4577
|
-
// tslint:enable:object-literal-sort-keys
|
|
4578
|
-
};
|
|
4579
|
-
MDCSelect.prototype.getCommonAdapterMethods = function () {
|
|
4580
|
-
var _this = this;
|
|
4581
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
4582
|
-
return {
|
|
4583
|
-
addClass: function (className) {
|
|
4584
|
-
_this.root.classList.add(className);
|
|
4585
|
-
},
|
|
4586
|
-
removeClass: function (className) {
|
|
4587
|
-
_this.root.classList.remove(className);
|
|
4588
|
-
},
|
|
4589
|
-
hasClass: function (className) { return _this.root.classList.contains(className); },
|
|
4590
|
-
setRippleCenter: function (normalizedX) {
|
|
4591
|
-
_this.lineRipple && _this.lineRipple.setRippleCenter(normalizedX);
|
|
4592
|
-
},
|
|
4593
|
-
activateBottomLine: function () {
|
|
4594
|
-
_this.lineRipple && _this.lineRipple.activate();
|
|
4595
|
-
},
|
|
4596
|
-
deactivateBottomLine: function () {
|
|
4597
|
-
_this.lineRipple && _this.lineRipple.deactivate();
|
|
4598
|
-
},
|
|
4599
|
-
notifyChange: function (value) {
|
|
4600
|
-
if (_this.hiddenInput) {
|
|
4601
|
-
_this.hiddenInput.value = value;
|
|
4602
|
-
}
|
|
4603
|
-
var index = _this.selectedIndex;
|
|
4604
|
-
_this.emit(strings$2.CHANGE_EVENT, { value: value, index: index }, true /* shouldBubble */);
|
|
4605
|
-
},
|
|
4606
|
-
};
|
|
4607
|
-
// tslint:enable:object-literal-sort-keys
|
|
4608
|
-
};
|
|
4609
|
-
MDCSelect.prototype.getOutlineAdapterMethods = function () {
|
|
4610
|
-
var _this = this;
|
|
4611
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
4612
|
-
return {
|
|
4613
|
-
hasOutline: function () { return Boolean(_this.outline); },
|
|
4614
|
-
notchOutline: function (labelWidth) {
|
|
4615
|
-
_this.outline && _this.outline.notch(labelWidth);
|
|
4616
|
-
},
|
|
4617
|
-
closeOutline: function () {
|
|
4618
|
-
_this.outline && _this.outline.closeNotch();
|
|
4619
|
-
},
|
|
4620
|
-
};
|
|
4621
|
-
// tslint:enable:object-literal-sort-keys
|
|
4622
|
-
};
|
|
4623
|
-
MDCSelect.prototype.getLabelAdapterMethods = function () {
|
|
4624
|
-
var _this = this;
|
|
4625
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
4626
|
-
return {
|
|
4627
|
-
hasLabel: function () { return !!_this.label; },
|
|
4628
|
-
floatLabel: function (shouldFloat) {
|
|
4629
|
-
_this.label && _this.label.float(shouldFloat);
|
|
4630
|
-
},
|
|
4631
|
-
getLabelWidth: function () { return _this.label ? _this.label.getWidth() : 0; },
|
|
4632
|
-
setLabelRequired: function (isRequired) {
|
|
4633
|
-
_this.label && _this.label.setRequired(isRequired);
|
|
4634
|
-
},
|
|
4635
|
-
};
|
|
4636
|
-
// tslint:enable:object-literal-sort-keys
|
|
4637
|
-
};
|
|
4638
|
-
/**
|
|
4639
|
-
* Calculates where the line ripple should start based on the x coordinate within the component.
|
|
4640
|
-
*/
|
|
4641
|
-
MDCSelect.prototype.getNormalizedXCoordinate = function (evt) {
|
|
4642
|
-
var targetClientRect = evt.target.getBoundingClientRect();
|
|
4643
|
-
var xCoordinate = this.isTouchEvent(evt) ? evt.touches[0].clientX : evt.clientX;
|
|
4644
|
-
return xCoordinate - targetClientRect.left;
|
|
4645
|
-
};
|
|
4646
|
-
MDCSelect.prototype.isTouchEvent = function (evt) {
|
|
4647
|
-
return Boolean(evt.touches);
|
|
4648
|
-
};
|
|
4649
|
-
/**
|
|
4650
|
-
* Returns a map of all subcomponents to subfoundations.
|
|
4651
|
-
*/
|
|
4652
|
-
MDCSelect.prototype.getFoundationMap = function () {
|
|
4653
|
-
return {
|
|
4654
|
-
helperText: this.helperText ? this.helperText.foundationForSelect :
|
|
4655
|
-
undefined,
|
|
4656
|
-
leadingIcon: this.leadingIcon ? this.leadingIcon.foundationForSelect :
|
|
4657
|
-
undefined,
|
|
4658
|
-
};
|
|
4659
|
-
};
|
|
4660
|
-
return MDCSelect;
|
|
4661
|
-
}(MDCComponent));
|
|
4662
|
-
|
|
4663
|
-
export { MDCSelect as M };
|