@foxy.io/elements 1.42.0-beta.6 → 1.42.0-beta.7
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/cdn/foxy-access-recovery-form.js +1 -1
- package/dist/cdn/foxy-address-card.js +5 -5
- package/dist/cdn/foxy-address-form.js +1 -1
- package/dist/cdn/foxy-admin-subscription-card.js +1 -1
- package/dist/cdn/foxy-admin-subscription-form.js +1 -1
- package/dist/cdn/foxy-api-browser.js +1 -1
- package/dist/cdn/foxy-applied-coupon-code-card.js +1 -1
- package/dist/cdn/foxy-applied-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-applied-tax-card.js +1 -1
- package/dist/cdn/foxy-attribute-card.js +1 -1
- package/dist/cdn/foxy-attribute-form.js +1 -1
- package/dist/cdn/foxy-billing-address-card.js +1 -1
- package/dist/cdn/foxy-cancellation-form.js +1 -1
- package/dist/cdn/foxy-cart-card.js +1 -1
- package/dist/cdn/foxy-cart-form.js +2 -2
- package/dist/cdn/foxy-client-card.js +1 -1
- package/dist/cdn/foxy-client-form.js +1 -1
- package/dist/cdn/foxy-collection-page.js +1 -1
- package/dist/cdn/foxy-collection-pages.js +1 -1
- package/dist/cdn/foxy-copy-to-clipboard.js +1 -1
- package/dist/cdn/foxy-coupon-card.js +1 -1
- package/dist/cdn/foxy-coupon-code-card.js +1 -1
- package/dist/cdn/foxy-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-coupon-codes-form.js +1 -1
- package/dist/cdn/foxy-coupon-detail-card.js +1 -1
- package/dist/cdn/foxy-coupon-form.js +1 -1
- package/dist/cdn/foxy-custom-field-card.js +1 -1
- package/dist/cdn/foxy-custom-field-form.js +1 -1
- package/dist/cdn/foxy-customer-card.js +1 -1
- package/dist/cdn/foxy-customer-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings.js +1 -1
- package/dist/cdn/foxy-customer-portal.js +1 -1
- package/dist/cdn/foxy-customer.js +1 -1
- package/dist/cdn/foxy-customers-table.js +1 -1
- package/dist/cdn/foxy-discount-builder.js +1 -1
- package/dist/cdn/foxy-discount-card.js +1 -1
- package/dist/cdn/foxy-discount-detail-card.js +1 -1
- package/dist/cdn/foxy-donation.js +1 -1
- package/dist/cdn/foxy-downloadable-card.js +1 -1
- package/dist/cdn/foxy-downloadable-form.js +1 -1
- package/dist/cdn/foxy-email-template-card.js +1 -1
- package/dist/cdn/foxy-email-template-form.js +1 -1
- package/dist/cdn/foxy-error-entry-card.js +1 -1
- package/dist/cdn/foxy-experimental-add-to-cart-builder.js +1 -1
- package/dist/cdn/foxy-filter-attribute-card.js +1 -1
- package/dist/cdn/foxy-filter-attribute-form.js +1 -1
- package/dist/cdn/foxy-form-dialog.js +1 -1
- package/dist/cdn/foxy-generate-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-card.js +1 -1
- package/dist/cdn/foxy-gift-card-code-card.js +1 -1
- package/dist/cdn/foxy-gift-card-code-form.js +1 -1
- package/dist/cdn/foxy-gift-card-code-log-card.js +1 -1
- package/dist/cdn/foxy-gift-card-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-form.js +1 -1
- package/dist/cdn/foxy-i18n-editor.js +4 -4
- package/dist/cdn/foxy-i18n.js +1 -1
- package/dist/cdn/foxy-integration-card.js +1 -1
- package/dist/cdn/foxy-integration-form.js +1 -1
- package/dist/cdn/foxy-item-card.js +1 -1
- package/dist/cdn/foxy-item-category-card.js +1 -1
- package/dist/cdn/foxy-item-category-form.js +1 -1
- package/dist/cdn/foxy-item-form.js +1 -1
- package/dist/cdn/foxy-item-option-card.js +1 -1
- package/dist/cdn/foxy-item-option-form.js +1 -1
- package/dist/cdn/foxy-items-form.js +1 -1
- package/dist/cdn/foxy-native-integration-card.js +1 -1
- package/dist/cdn/foxy-native-integration-form.js +1 -1
- package/dist/cdn/foxy-pagination.js +1 -1
- package/dist/cdn/foxy-passkey-card.js +1 -1
- package/dist/cdn/foxy-passkey-form.js +1 -1
- package/dist/cdn/foxy-payment-card-embed.js +1 -1
- package/dist/cdn/foxy-payment-card.js +1 -1
- package/dist/cdn/foxy-payment-method-card.js +1 -1
- package/dist/cdn/foxy-payments-api-fraud-protection-card.js +1 -1
- package/dist/cdn/foxy-payments-api-fraud-protection-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-method-card.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-method-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-preset-card.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-preset-form.js +1 -1
- package/dist/cdn/foxy-query-builder.js +1 -1
- package/dist/cdn/foxy-report-form.js +10 -10
- package/dist/cdn/foxy-reports-table.js +1 -1
- package/dist/cdn/foxy-shipment-card.js +1 -1
- package/dist/cdn/foxy-shipping-container-card.js +1 -1
- package/dist/cdn/foxy-shipping-drop-type-card.js +1 -1
- package/dist/cdn/foxy-shipping-method-card.js +1 -1
- package/dist/cdn/foxy-shipping-service-card.js +1 -1
- package/dist/cdn/foxy-sign-in-form.js +1 -1
- package/dist/cdn/foxy-spinner.js +2 -2
- package/dist/cdn/foxy-store-card.js +1 -1
- package/dist/cdn/foxy-store-form.js +1 -1
- package/dist/cdn/foxy-store-shipping-method-form.js +1 -1
- package/dist/cdn/foxy-subscription-card.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +1 -1
- package/dist/cdn/foxy-subscription-settings-form.js +1 -1
- package/dist/cdn/foxy-subscriptions-table.js +1 -1
- package/dist/cdn/foxy-swipe-actions.js +1 -1
- package/dist/cdn/foxy-table.js +1 -1
- package/dist/cdn/foxy-tax-card.js +1 -1
- package/dist/cdn/foxy-tax-form.js +1 -1
- package/dist/cdn/foxy-template-config-form.js +1 -1
- package/dist/cdn/foxy-template-form.js +1 -1
- package/dist/cdn/foxy-template-set-card.js +1 -1
- package/dist/cdn/foxy-template-set-form.js +1 -1
- package/dist/cdn/foxy-transaction-card.js +1 -1
- package/dist/cdn/foxy-transaction.js +1 -1
- package/dist/cdn/foxy-transactions-table.js +7 -7
- package/dist/cdn/foxy-update-payment-method-form.js +1 -1
- package/dist/cdn/foxy-user-card.js +1 -1
- package/dist/cdn/foxy-user-form.js +1 -1
- package/dist/cdn/foxy-user-invitation-card.js +1 -1
- package/dist/cdn/foxy-user-invitation-form.js +1 -1
- package/dist/cdn/foxy-users-table.js +1 -1
- package/dist/cdn/foxy-webhook-card.js +1 -1
- package/dist/cdn/foxy-webhook-form.js +1 -1
- package/dist/cdn/foxy-webhook-log-card.js +1 -1
- package/dist/cdn/foxy-webhook-status-card.js +1 -1
- package/dist/cdn/{shared-864ea319.js → shared-0553380e.js} +1 -1
- package/dist/cdn/{shared-fca3a317.js → shared-0c242246.js} +1 -1
- package/dist/cdn/{shared-25167d28.js → shared-0cc8df04.js} +1 -1
- package/dist/cdn/{shared-4e309d01.js → shared-0cfb1c08.js} +1 -1
- package/dist/cdn/{shared-77f39a8a.js → shared-0f4dfb14.js} +1 -1
- package/dist/cdn/{shared-16ae74b2.js → shared-1aff90a9.js} +1 -1
- package/dist/cdn/shared-1b46df2a.js +417 -0
- package/dist/cdn/{shared-70380f94.js → shared-1d03f911.js} +1 -1
- package/dist/cdn/shared-241b6cca.js +231 -0
- package/dist/cdn/{shared-56d91134.js → shared-2939f350.js} +1 -1
- package/dist/cdn/shared-2b126cea.js +25 -0
- package/dist/cdn/{shared-4ded48ee.js → shared-2fe8aabd.js} +1 -1
- package/dist/cdn/{shared-7a2aaafa.js → shared-330e57d9.js} +1 -1
- package/dist/cdn/shared-35c9fa1d.js +1 -0
- package/dist/cdn/{shared-49337d35.js → shared-393a7ab2.js} +1 -1
- package/dist/cdn/{shared-bc2eb9bb.js → shared-3a2134c8.js} +1 -1
- package/dist/cdn/{shared-7f5f6657.js → shared-3aca4932.js} +1 -1
- package/dist/cdn/{shared-e4768909.js → shared-3cdec25d.js} +9 -9
- package/dist/cdn/{shared-8b891950.js → shared-40028e80.js} +1 -1
- package/dist/cdn/{shared-127ec8a7.js → shared-434cdfec.js} +1 -1
- package/dist/cdn/{shared-df369311.js → shared-46f8e3d9.js} +1 -1
- package/dist/cdn/{shared-5960c279.js → shared-4bd1f3d8.js} +1 -1
- package/dist/cdn/shared-4cae017c.js +1 -0
- package/dist/cdn/{shared-42c91940.js → shared-4d919766.js} +1 -1
- package/dist/cdn/{shared-e55e32dd.js → shared-4f808d2e.js} +1 -1
- package/dist/cdn/{shared-a4ca1c5d.js → shared-53253d60.js} +1 -1
- package/dist/cdn/{shared-663794ff.js → shared-5520b96c.js} +1 -1
- package/dist/cdn/shared-578cde14.js +1 -0
- package/dist/cdn/{shared-7b3aac7e.js → shared-58b6710c.js} +1 -1
- package/dist/cdn/{shared-16d1018b.js → shared-5a04e75c.js} +1 -1
- package/dist/cdn/{shared-92153a7f.js → shared-5d7c4673.js} +1 -1
- package/dist/cdn/{shared-1b7e17c7.js → shared-692691ca.js} +1 -1
- package/dist/cdn/{shared-e653b80e.js → shared-6f08d218.js} +1 -1
- package/dist/cdn/{shared-2a5d1cdf.js → shared-753fdd34.js} +1 -1
- package/dist/cdn/{shared-500b7eb7.js → shared-7977d581.js} +2 -2
- package/dist/cdn/{shared-d5f6483f.js → shared-7eeb591f.js} +1 -1
- package/dist/cdn/{shared-9a4d52dd.js → shared-86337ba8.js} +1 -1
- package/dist/cdn/{shared-3ca95e21.js → shared-8c42634c.js} +1 -1
- package/dist/cdn/{shared-1f6366c0.js → shared-8e010314.js} +1 -1
- package/dist/cdn/{shared-7995cbcf.js → shared-8f81f4ed.js} +1 -1
- package/dist/cdn/{shared-6f1261fa.js → shared-92995c02.js} +1 -1
- package/dist/cdn/{shared-076f086a.js → shared-948919d2.js} +1 -1
- package/dist/cdn/{shared-a1f654fc.js → shared-98f382f3.js} +1 -1
- package/dist/cdn/{shared-76cbea00.js → shared-9d4813e6.js} +1 -1
- package/dist/cdn/{shared-eb086cef.js → shared-a60ca6fe.js} +1 -1
- package/dist/cdn/{shared-ee9ee09a.js → shared-ae2336ab.js} +1 -1
- package/dist/cdn/{shared-6b3b8c63.js → shared-b05ef317.js} +1 -1
- package/dist/cdn/shared-b1c9199f.js +531 -0
- package/dist/cdn/{shared-5714fc55.js → shared-b6c5ac14.js} +2 -2
- package/dist/cdn/{shared-253e51f7.js → shared-c009b9b6.js} +1 -1
- package/dist/cdn/{shared-75e7361d.js → shared-c231e3bf.js} +1 -1
- package/dist/cdn/{shared-a3a18e8d.js → shared-c584966f.js} +1 -1
- package/dist/cdn/{shared-90754404.js → shared-c5b019e5.js} +1 -1
- package/dist/cdn/{shared-eed9b226.js → shared-cae254ee.js} +9 -9
- package/dist/cdn/{shared-771431a9.js → shared-ceeb14e9.js} +1 -1
- package/dist/cdn/{shared-fc66cb5d.js → shared-cf008f13.js} +1 -1
- package/dist/cdn/{shared-f9f64dee.js → shared-d3d4badd.js} +1 -1
- package/dist/cdn/{shared-d2304d50.js → shared-d743d0fd.js} +1 -1
- package/dist/cdn/{shared-a3a4c368.js → shared-d8694661.js} +6 -6
- package/dist/cdn/{shared-1ce5b073.js → shared-e1400289.js} +1 -1
- package/dist/cdn/shared-e615d2d9.js +1 -0
- package/dist/cdn/{shared-677953e0.js → shared-ec9893c7.js} +1 -1
- package/dist/cdn/{shared-68a5368a.js → shared-f79f08cc.js} +1 -1
- package/dist/cdn/translations/admin-subscription-form/en.json +112 -48
- package/dist/cdn/translations/api-browser/en.json +7 -3
- package/dist/cdn/translations/cart-form/en.json +91 -39
- package/dist/cdn/translations/coupon-code-form/en.json +7 -3
- package/dist/cdn/translations/coupon-form/en.json +28 -12
- package/dist/cdn/translations/customer/en.json +28 -12
- package/dist/cdn/translations/customer-portal/de.json +14 -6
- package/dist/cdn/translations/customer-portal/en.json +14 -6
- package/dist/cdn/translations/customer-portal/es.json +14 -6
- package/dist/cdn/translations/customer-portal/fr.json +14 -6
- package/dist/cdn/translations/customer-portal/nl.json +14 -6
- package/dist/cdn/translations/customer-portal/pl.json +14 -6
- package/dist/cdn/translations/customer-portal/sv.json +14 -6
- package/dist/cdn/translations/customer-portal/zh-HK.json +14 -6
- package/dist/cdn/translations/customer-portal-settings-form/en.json +14 -6
- package/dist/cdn/translations/experimental-add-to-cart-builder/en.json +28 -12
- package/dist/cdn/translations/gift-card-code-form/en.json +14 -6
- package/dist/cdn/translations/gift-card-form/en.json +35 -15
- package/dist/cdn/translations/item-category-form/en.json +14 -6
- package/dist/cdn/translations/item-form/en.json +35 -15
- package/dist/cdn/translations/native-integration-form/en.json +14 -6
- package/dist/cdn/translations/pagination/en.json +7 -3
- package/dist/cdn/translations/payment-method-card/en.json +7 -3
- package/dist/cdn/translations/store-shipping-method-form/en.json +28 -12
- package/dist/cdn/translations/subscription-form/en.json +21 -9
- package/dist/cdn/translations/tax-form/en.json +7 -3
- package/dist/cdn/translations/template-set-form/en.json +7 -3
- package/dist/cdn/translations/transaction/en.json +98 -42
- package/dist/cdn/translations/update-payment-method-form/en.json +7 -3
- package/dist/cdn/translations/webhook-form/en.json +14 -6
- package/dist/elements/internal/InternalNumberControl/InternalNumberControl.js +13 -31
- package/dist/elements/internal/InternalNumberControl/InternalNumberControl.js.map +1 -1
- package/dist/elements/public/Pagination/Pagination.js +98 -91
- package/dist/elements/public/Pagination/Pagination.js.map +1 -1
- package/dist/elements/public/Pagination/index.d.ts +1 -0
- package/dist/elements/public/Pagination/index.js +1 -0
- package/dist/elements/public/Pagination/index.js.map +1 -1
- package/dist/elements/public/SwipeActions/SwipeActions.d.ts +1 -0
- package/dist/elements/public/SwipeActions/SwipeActions.js +8 -5
- package/dist/elements/public/SwipeActions/SwipeActions.js.map +1 -1
- package/dist/mixins/themeable.js +0 -18
- package/dist/mixins/themeable.js.map +1 -1
- package/package.json +1 -1
- package/dist/cdn/shared-0662adb7.js +0 -1
- package/dist/cdn/shared-0995ae7c.js +0 -637
- package/dist/cdn/shared-0e1ad508.js +0 -1
- package/dist/cdn/shared-20fb2969.js +0 -88
- package/dist/cdn/shared-21fba20d.js +0 -1
- package/dist/cdn/shared-292dcee0.js +0 -10
- package/dist/cdn/shared-5c057c26.js +0 -419
- package/dist/cdn/shared-651c44fa.js +0 -6
- package/dist/cdn/shared-7a4ca3f1.js +0 -1
- package/dist/cdn/shared-986d0f7f.js +0 -1
- package/dist/cdn/shared-c365c1ae.js +0 -31
- package/dist/cdn/shared-f28e46bf.js +0 -12
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
import"./shared-58b6710c.js";import"./shared-e615d2d9.js";import{h as e,P as t,D as i,t as s,a as o,p as n,i as r,e as a,y as l,z as h}from"./shared-d8694661.js";import"./shared-9d4813e6.js";import{T as d,D as c,E as u}from"./shared-7977d581.js";import{a as _,I as m,b as p}from"./shared-2b126cea.js";import"./shared-d743d0fd.js";import"./shared-2fe8aabd.js";import{C as v}from"./shared-f79f08cc.js";import{t as f,m as g,F as y,P as b,f as I,d as x,O as w,D as S,a as C}from"./shared-241b6cca.js";
|
|
2
|
+
/**
|
|
3
|
+
@license
|
|
4
|
+
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
5
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
6
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
7
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
8
|
+
Code distributed by Google as part of the polymer project is also
|
|
9
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
10
|
+
*/const P={templatize(e,t){this._templatizerTemplate=e,this.ctor=f(e,this,{mutableData:Boolean(t),parentModel:this._parentModel,instanceProps:this._instanceProps,forwardHostProp:this._forwardHostPropV2,notifyInstanceProp:this._notifyInstancePropV2})},stamp(e){return new this.ctor(e)},modelForElement(e){return g(this._templatizerTemplate,e)}},E=e`<dom-module id="lumo-vaadin-overlay" theme-for="vaadin-overlay">
|
|
11
|
+
<template>
|
|
12
|
+
<style include="lumo-overlay">
|
|
13
|
+
/* stylelint-disable no-empty-source */
|
|
14
|
+
</style>
|
|
15
|
+
</template>
|
|
16
|
+
</dom-module>`;document.head.appendChild(E.content);const T=Element.prototype,V=T.matches||T.matchesSelector||T.mozMatchesSelector||T.msMatchesSelector||T.oMatchesSelector||T.webkitMatchesSelector;class O{static getTabbableNodes(e){const t=[];return this._collectTabbableNodes(e,t)?this._sortByTabIndex(t):t}static isFocusable(e){return V.call(e,"input, select, textarea, button, object")?V.call(e,":not([disabled])"):V.call(e,"a[href], area[href], iframe, [tabindex], [contentEditable]")}static isTabbable(e){return this.isFocusable(e)&&V.call(e,':not([tabindex="-1"])')&&this._isVisible(e)}static _normalizedTabIndex(e){if(this.isFocusable(e)){const t=e.getAttribute("tabindex")||0;return Number(t)}return-1}static _collectTabbableNodes(e,t){if(e.nodeType!==Node.ELEMENT_NODE||!this._isVisible(e))return!1;const i=e,s=this._normalizedTabIndex(i);let o,n=s>0;if(s>=0&&t.push(i),o="slot"===i.localName?i.assignedNodes({flatten:!0}):(i.shadowRoot||i).children,o)for(let e=0;e<o.length;e++)n=this._collectTabbableNodes(o[e],t)||n;return n}static _isVisible(e){let t=e.style;return"hidden"!==t.visibility&&"none"!==t.display&&(t=window.getComputedStyle(e),"hidden"!==t.visibility&&"none"!==t.display)}static _sortByTabIndex(e){const t=e.length;if(t<2)return e;const i=Math.ceil(t/2),s=this._sortByTabIndex(e.slice(0,i)),o=this._sortByTabIndex(e.slice(i));return this._mergeSortByTabIndex(s,o)}static _mergeSortByTabIndex(e,t){const i=[];for(;e.length>0&&t.length>0;)this._hasLowerTabOrder(e[0],t[0])?i.push(t.shift()):i.push(e.shift());return i.concat(e,t)}static _hasLowerTabOrder(e,t){const i=Math.max(e.tabIndex,0),s=Math.max(t.tabIndex,0);return 0===i||0===s?s>i:i>s}}
|
|
17
|
+
/**
|
|
18
|
+
@license
|
|
19
|
+
Copyright (c) 2017 Vaadin Ltd.
|
|
20
|
+
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
21
|
+
*/let k=0;const L={},A=e=>{k++;const t=`vaadin-overlay-content-${k}`,i=document.createElement("template"),s=document.createElement("style");s.textContent=":host { display: block; }"+e,i.content.appendChild(s),window.ShadyCSS&&window.ShadyCSS.prepareTemplate(i,t);const o=class extends HTMLElement{static get is(){return t}constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(document.importNode(i.content,!0)))}connectedCallback(){window.ShadyCSS&&window.ShadyCSS.styleElement(this)}};return customElements.define(o.is,o),L[e]=t,t};class R extends(d(c(t))){static get template(){return e`
|
|
22
|
+
<style>
|
|
23
|
+
:host {
|
|
24
|
+
z-index: 200;
|
|
25
|
+
position: fixed;
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
Despite of what the names say, <vaadin-overlay> is just a container
|
|
29
|
+
for position/sizing/alignment. The actual overlay is the overlay part.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
Default position constraints: the entire viewport. Note: themes can
|
|
34
|
+
override this to introduce gaps between the overlay and the viewport.
|
|
35
|
+
*/
|
|
36
|
+
top: 0;
|
|
37
|
+
right: 0;
|
|
38
|
+
bottom: var(--vaadin-overlay-viewport-bottom);
|
|
39
|
+
left: 0;
|
|
40
|
+
|
|
41
|
+
/* Use flexbox alignment for the overlay part. */
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column; /* makes dropdowns sizing easier */
|
|
44
|
+
/* Align to center by default. */
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
|
|
48
|
+
/* Allow centering when max-width/max-height applies. */
|
|
49
|
+
margin: auto;
|
|
50
|
+
|
|
51
|
+
/* The host is not clickable, only the overlay part is. */
|
|
52
|
+
pointer-events: none;
|
|
53
|
+
|
|
54
|
+
/* Remove tap highlight on touch devices. */
|
|
55
|
+
-webkit-tap-highlight-color: transparent;
|
|
56
|
+
|
|
57
|
+
/* CSS API for host */
|
|
58
|
+
--vaadin-overlay-viewport-bottom: 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
:host([hidden]),
|
|
62
|
+
:host(:not([opened]):not([closing])) {
|
|
63
|
+
display: none !important;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
[part="overlay"] {
|
|
67
|
+
-webkit-overflow-scrolling: touch;
|
|
68
|
+
overflow: auto;
|
|
69
|
+
pointer-events: auto;
|
|
70
|
+
|
|
71
|
+
/* Prevent overflowing the host in MSIE 11 */
|
|
72
|
+
max-width: 100%;
|
|
73
|
+
box-sizing: border-box;
|
|
74
|
+
|
|
75
|
+
-webkit-tap-highlight-color: initial; /* reenable tap highlight inside */
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
[part="backdrop"] {
|
|
79
|
+
z-index: -1;
|
|
80
|
+
content: "";
|
|
81
|
+
background: rgba(0, 0, 0, 0.5);
|
|
82
|
+
position: fixed;
|
|
83
|
+
top: 0;
|
|
84
|
+
left: 0;
|
|
85
|
+
bottom: 0;
|
|
86
|
+
right: 0;
|
|
87
|
+
pointer-events: auto;
|
|
88
|
+
}
|
|
89
|
+
</style>
|
|
90
|
+
|
|
91
|
+
<div id="backdrop" part="backdrop" hidden\$="{{!withBackdrop}}"></div>
|
|
92
|
+
<div part="overlay" id="overlay" tabindex="0">
|
|
93
|
+
<div part="content" id="content">
|
|
94
|
+
<slot></slot>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
`}static get is(){return"vaadin-overlay"}static get properties(){return{opened:{type:Boolean,notify:!0,observer:"_openedChanged",reflectToAttribute:!0},owner:Element,renderer:Function,template:{type:Object,notify:!0},instanceProps:{type:Object},content:{type:Object,notify:!0},withBackdrop:{type:Boolean,value:!1,reflectToAttribute:!0},model:Object,modeless:{type:Boolean,value:!1,reflectToAttribute:!0,observer:"_modelessChanged"},hidden:{type:Boolean,reflectToAttribute:!0,observer:"_hiddenChanged"},focusTrap:{type:Boolean,value:!1},restoreFocusOnClose:{type:Boolean,value:!1},_mouseDownInside:{type:Boolean},_mouseUpInside:{type:Boolean},_instance:{type:Object},_originalContentPart:Object,_contentNodes:Array,_oldOwner:Element,_oldModel:Object,_oldTemplate:Object,_oldInstanceProps:Object,_oldRenderer:Object,_oldOpened:Boolean}}static get observers(){return["_templateOrRendererChanged(template, renderer, owner, model, instanceProps, opened)"]}constructor(){super(),this._boundMouseDownListener=this._mouseDownListener.bind(this),this._boundMouseUpListener=this._mouseUpListener.bind(this),this._boundOutsideClickListener=this._outsideClickListener.bind(this),this._boundKeydownListener=this._keydownListener.bind(this),this._observer=new y(this,(e=>{this._setTemplateFromNodes(e.addedNodes)})),this._boundIronOverlayCanceledListener=this._ironOverlayCanceled.bind(this),/iPad|iPhone|iPod/.test(navigator.userAgent)&&(this._boundIosResizeListener=()=>this._detectIosNavbar())}ready(){super.ready(),this._observer.flush(),this.addEventListener("click",(()=>{})),this.$.backdrop.addEventListener("click",(()=>{}))}_detectIosNavbar(){if(!this.opened)return;const e=window.innerHeight,t=window.innerWidth>e,i=document.documentElement.clientHeight;t&&i>e?this.style.setProperty("--vaadin-overlay-viewport-bottom",i-e+"px"):this.style.setProperty("--vaadin-overlay-viewport-bottom","0")}_setTemplateFromNodes(e){this.template=e.filter((e=>e.localName&&"template"===e.localName))[0]||this.template}close(e){var t=new CustomEvent("vaadin-overlay-close",{bubbles:!0,cancelable:!0,detail:{sourceEvent:e}});this.dispatchEvent(t),t.defaultPrevented||(this.opened=!1)}connectedCallback(){super.connectedCallback(),this._boundIosResizeListener&&(this._detectIosNavbar(),window.addEventListener("resize",this._boundIosResizeListener))}disconnectedCallback(){super.disconnectedCallback(),this._boundIosResizeListener&&window.removeEventListener("resize",this._boundIosResizeListener)}_ironOverlayCanceled(e){e.preventDefault()}_mouseDownListener(e){this._mouseDownInside=e.composedPath().indexOf(this.$.overlay)>=0}_mouseUpListener(e){this._mouseUpInside=e.composedPath().indexOf(this.$.overlay)>=0}_outsideClickListener(e){if(-1!==e.composedPath().indexOf(this.$.overlay)||this._mouseDownInside||this._mouseUpInside)return this._mouseDownInside=!1,void(this._mouseUpInside=!1);if(!this._last)return;const t=new CustomEvent("vaadin-overlay-outside-click",{bubbles:!0,cancelable:!0,detail:{sourceEvent:e}});this.dispatchEvent(t),this.opened&&!t.defaultPrevented&&this.close(e)}_keydownListener(e){if(this._last)if("Tab"===e.key&&this.focusTrap&&!e.defaultPrevented)this._cycleTab(e.shiftKey?-1:1),e.preventDefault();else if("Escape"===e.key||"Esc"===e.key){const t=new CustomEvent("vaadin-overlay-escape-press",{bubbles:!0,cancelable:!0,detail:{sourceEvent:e}});this.dispatchEvent(t),this.opened&&!t.defaultPrevented&&this.close(e)}}_ensureTemplatized(){this._setTemplateFromNodes(Array.from(this.children))}_openedChanged(e,t){this._instance||this._ensureTemplatized(),e?(this.__restoreFocusNode=this._getActiveElement(),this._animatedOpening(),_(this,(()=>{this.focusTrap&&!this.contains(document._activeElement||document.activeElement)&&this._cycleTab(0,0);const e=new CustomEvent("vaadin-overlay-open",{bubbles:!0});this.dispatchEvent(e)})),this.modeless||this._addGlobalListeners()):t&&(this._animatedClosing(),this.modeless||this._removeGlobalListeners())}_hiddenChanged(e){e&&this.hasAttribute("closing")&&this._flushAnimation("closing")}_shouldAnimate(){const e=getComputedStyle(this).getPropertyValue("animation-name");return!("none"===getComputedStyle(this).getPropertyValue("display"))&&e&&"none"!=e}_enqueueAnimation(e,t){const i=`__${e}Handler`,s=e=>{e&&e.target!==this||(t(),this.removeEventListener("animationend",s),delete this[i])};this[i]=s,this.addEventListener("animationend",s)}_flushAnimation(e){const t=`__${e}Handler`;"function"==typeof this[t]&&this[t]()}_animatedOpening(){this.parentNode===document.body&&this.hasAttribute("closing")&&this._flushAnimation("closing"),this._attachOverlay(),this.modeless||this._enterModalState(),this.setAttribute("opening","");const e=()=>{document.addEventListener("iron-overlay-canceled",this._boundIronOverlayCanceledListener),this.removeAttribute("opening")};this._shouldAnimate()?this._enqueueAnimation("opening",e):e()}_attachOverlay(){this._placeholder=document.createComment("vaadin-overlay-placeholder"),this.parentNode.insertBefore(this._placeholder,this),document.body.appendChild(this),this.bringToFront()}_animatedClosing(){if(this.hasAttribute("opening")&&this._flushAnimation("opening"),this._placeholder){if(this._exitModalState(),this.restoreFocusOnClose&&this.__restoreFocusNode){const e=this._getActiveElement();(e===document.body||this._deepContains(e))&&this.__restoreFocusNode.focus(),this.__restoreFocusNode=null}this.setAttribute("closing","");const e=()=>{document.removeEventListener("iron-overlay-canceled",this._boundIronOverlayCanceledListener),this._detachOverlay(),this.shadowRoot.querySelector('[part="overlay"]').style.removeProperty("pointer-events"),this.removeAttribute("closing")};this._shouldAnimate()?this._enqueueAnimation("closing",e):e()}}_detachOverlay(){this._placeholder.parentNode.insertBefore(this,this._placeholder),this._placeholder.parentNode.removeChild(this._placeholder)}static get __attachedInstances(){return Array.from(document.body.children).filter((e=>e instanceof R&&!e.hasAttribute("closing"))).sort(((e,t)=>e.__zIndex-t.__zIndex||0))}get _last(){return this===R.__attachedInstances.pop()}_modelessChanged(e){e?(this._removeGlobalListeners(),this._exitModalState()):this.opened&&(this._addGlobalListeners(),this._enterModalState())}_addGlobalListeners(){document.addEventListener("mousedown",this._boundMouseDownListener),document.addEventListener("mouseup",this._boundMouseUpListener),document.documentElement.addEventListener("click",this._boundOutsideClickListener,!0),document.addEventListener("keydown",this._boundKeydownListener)}_enterModalState(){"none"!==document.body.style.pointerEvents&&(this._previousDocumentPointerEvents=document.body.style.pointerEvents,document.body.style.pointerEvents="none"),R.__attachedInstances.forEach((e=>{e!==this&&(e.shadowRoot.querySelector('[part="overlay"]').style.pointerEvents="none")}))}_removeGlobalListeners(){document.removeEventListener("mousedown",this._boundMouseDownListener),document.removeEventListener("mouseup",this._boundMouseUpListener),document.documentElement.removeEventListener("click",this._boundOutsideClickListener,!0),document.removeEventListener("keydown",this._boundKeydownListener)}_exitModalState(){void 0!==this._previousDocumentPointerEvents&&(document.body.style.pointerEvents=this._previousDocumentPointerEvents,delete this._previousDocumentPointerEvents);const e=R.__attachedInstances;let t;for(;(t=e.pop())&&(t===this||(t.shadowRoot.querySelector('[part="overlay"]').style.removeProperty("pointer-events"),t.modeless)););}_removeOldContent(){this.content&&this._contentNodes&&(this._observer.disconnect(),this._contentNodes.forEach((e=>{e.parentNode===this.content&&this.content.removeChild(e)})),this._originalContentPart&&(this.$.content.parentNode.replaceChild(this._originalContentPart,this.$.content),this.$.content=this._originalContentPart,this._originalContentPart=void 0),this._observer.connect(),this._contentNodes=void 0,this.content=void 0)}_stampOverlayTemplate(e,t){this._removeOldContent(),e._Templatizer||(e._Templatizer=f(e,this,{instanceProps:t,forwardHostProp:function(e,t){this._instance&&this._instance.forwardHostProp(e,t)}})),this._instance=new e._Templatizer({}),this._contentNodes=Array.from(this._instance.root.childNodes);const i=e._templateRoot||(e._templateRoot=e.getRootNode());if(i!==document){const e=window.ShadyCSS&&!window.ShadyCSS.nativeShadow;this.$.content.shadowRoot||this.$.content.attachShadow({mode:"open"});let t=Array.from(i.querySelectorAll("style")).reduce(((e,t)=>e+t.textContent),"");if(e){const e=window.ShadyCSS.ScopingShim._styleInfoForNode(i.host);e&&(t+=e._getStyleRules().parsedCssText,t+="}")}if(t=t.replace(/:host/g,":host-nomatch"),t)if(e){const e=(e=>{const t=L[e]||A(e);return document.createElement(t)})(t);e.id="content",e.setAttribute("part","content"),this.$.content.parentNode.replaceChild(e,this.$.content),e.className=this.$.content.className,this._originalContentPart=this.$.content,this.$.content=e}else{const e=document.createElement("style");e.textContent=t,this.$.content.shadowRoot.appendChild(e),this._contentNodes.unshift(e)}this.$.content.shadowRoot.appendChild(this._instance.root),this.content=this.$.content.shadowRoot}else this.appendChild(this._instance.root),this.content=this}_removeNewRendererOrTemplate(e,t,i,s){e!==t?this.template=void 0:i!==s&&(this.renderer=void 0)}render(){this.renderer&&this.renderer.call(this.owner,this.content,this.owner,this.model)}_templateOrRendererChanged(e,t,i,s,o,n){if(e&&t)throw this._removeNewRendererOrTemplate(e,this._oldTemplate,t,this._oldRenderer),new Error("You should only use either a renderer or a template for overlay content");const r=this._oldOwner!==i||this._oldModel!==s;this._oldModel=s,this._oldOwner=i;const a=this._oldInstanceProps!==o||this._oldTemplate!==e;this._oldInstanceProps=o,this._oldTemplate=e;const l=this._oldRenderer!==t;this._oldRenderer=t;const h=this._oldOpened!==n;if(this._oldOpened=n,e&&a)this._stampOverlayTemplate(e,o);else if(t&&(l||h||r)){if(this.content=this,l)for(;this.content.firstChild;)this.content.removeChild(this.content.firstChild);n&&this.render()}}_isFocused(e){return e&&e.getRootNode().activeElement===e}_focusedIndex(e){return(e=e||this._getFocusableElements()).indexOf(e.filter(this._isFocused).pop())}_cycleTab(e,t){const i=this._getFocusableElements();void 0===t&&(t=this._focusedIndex(i)),(t+=e)>=i.length?t=0:t<0&&(t=i.length-1),i[t].focus()}_getFocusableElements(){return O.getTabbableNodes(this.$.overlay)}_getActiveElement(){let e=document._activeElement||document.activeElement;for(e&&e!==document.documentElement&&e instanceof Element!=!1||(e=document.body);e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}_deepContains(e){if(this.contains(e))return!0;let t=e;const i=e.ownerDocument;for(;t&&t!==i&&t!==this;)t=t.parentNode||t.host;return t===this}bringToFront(){let e="";const t=R.__attachedInstances.filter((e=>e!==this)).pop();if(t){e=t.__zIndex+1}this.style.zIndex=e,this.__zIndex=e||parseFloat(getComputedStyle(this).zIndex)}}customElements.define(R.is,R);const B=e`<dom-module id="lumo-combo-box-overlay" theme-for="vaadin-combo-box-overlay">
|
|
98
|
+
<template>
|
|
99
|
+
<style include="lumo-overlay lumo-menu-overlay-core">
|
|
100
|
+
[part="content"] {
|
|
101
|
+
padding: 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
:host {
|
|
105
|
+
/* TODO: using a legacy mixin (unsupported) */
|
|
106
|
+
--iron-list-items-container: {
|
|
107
|
+
border-width: var(--lumo-space-xs);
|
|
108
|
+
border-style: solid;
|
|
109
|
+
border-color: transparent;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* TODO: workaround ShadyCSS issue when using inside of the dom-if */
|
|
114
|
+
:host([opened]) {
|
|
115
|
+
--iron-list-items-container_-_border-width: var(--lumo-space-xs);
|
|
116
|
+
--iron-list-items-container_-_border-style: solid;
|
|
117
|
+
--iron-list-items-container_-_border-color: transparent;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/* Loading state */
|
|
121
|
+
|
|
122
|
+
/* When items are empty, the sinner needs some room */
|
|
123
|
+
:host(:not([closing])) [part~="content"] {
|
|
124
|
+
min-height: calc(2 * var(--lumo-space-s) + var(--lumo-icon-size-s));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
[part~="overlay"] {
|
|
128
|
+
position: relative;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
:host([loading]) [part~="loader"] {
|
|
132
|
+
box-sizing: border-box;
|
|
133
|
+
width: var(--lumo-icon-size-s);
|
|
134
|
+
height: var(--lumo-icon-size-s);
|
|
135
|
+
position: absolute;
|
|
136
|
+
z-index: 1;
|
|
137
|
+
left: var(--lumo-space-s);
|
|
138
|
+
right: var(--lumo-space-s);
|
|
139
|
+
top: var(--lumo-space-s);
|
|
140
|
+
margin-left: auto;
|
|
141
|
+
margin-inline-start: auto;
|
|
142
|
+
margin-inline-end: 0;
|
|
143
|
+
border: 2px solid transparent;
|
|
144
|
+
border-color:
|
|
145
|
+
var(--lumo-primary-color-50pct)
|
|
146
|
+
var(--lumo-primary-color-50pct)
|
|
147
|
+
var(--lumo-primary-color)
|
|
148
|
+
var(--lumo-primary-color);
|
|
149
|
+
border-radius: calc(0.5 * var(--lumo-icon-size-s));
|
|
150
|
+
opacity: 0;
|
|
151
|
+
animation:
|
|
152
|
+
1s linear infinite lumo-combo-box-loader-rotate,
|
|
153
|
+
.3s .1s lumo-combo-box-loader-fade-in both;
|
|
154
|
+
pointer-events: none;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
@keyframes lumo-combo-box-loader-fade-in {
|
|
158
|
+
0% {
|
|
159
|
+
opacity: 0;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
100% {
|
|
163
|
+
opacity: 1;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@keyframes lumo-combo-box-loader-rotate {
|
|
168
|
+
0% {
|
|
169
|
+
transform: rotate(0deg);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
100% {
|
|
173
|
+
transform: rotate(360deg);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/* RTL specific styles */
|
|
178
|
+
|
|
179
|
+
:host([loading][dir="rtl"]) [part~="loader"] {
|
|
180
|
+
left: auto;
|
|
181
|
+
margin-left: 0;
|
|
182
|
+
margin-right: auto;
|
|
183
|
+
margin-inline-start: 0;
|
|
184
|
+
margin-inline-end: auto;
|
|
185
|
+
}
|
|
186
|
+
</style>
|
|
187
|
+
</template>
|
|
188
|
+
</dom-module>`;document.head.appendChild(B.content);const F=e`<dom-module id="lumo-item" theme-for="vaadin-item">
|
|
189
|
+
<template>
|
|
190
|
+
<style>
|
|
191
|
+
:host {
|
|
192
|
+
display: flex;
|
|
193
|
+
align-items: center;
|
|
194
|
+
box-sizing: border-box;
|
|
195
|
+
font-family: var(--lumo-font-family);
|
|
196
|
+
font-size: var(--lumo-font-size-m);
|
|
197
|
+
line-height: var(--lumo-line-height-xs);
|
|
198
|
+
padding: 0.5em 1em;
|
|
199
|
+
min-height: var(--lumo-size-m);
|
|
200
|
+
-webkit-font-smoothing: antialiased;
|
|
201
|
+
-moz-osx-font-smoothing: grayscale;
|
|
202
|
+
-webkit-tap-highlight-color: transparent;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/* Selectable items have a checkmark icon */
|
|
206
|
+
:host([tabindex])::before {
|
|
207
|
+
display: var(--_lumo-item-selected-icon-display, none);
|
|
208
|
+
content: var(--lumo-icons-checkmark);
|
|
209
|
+
font-family: lumo-icons;
|
|
210
|
+
font-size: var(--lumo-icon-size-m);
|
|
211
|
+
line-height: 1;
|
|
212
|
+
font-weight: normal;
|
|
213
|
+
width: 1em;
|
|
214
|
+
height: 1em;
|
|
215
|
+
margin: calc((1 - var(--lumo-line-height-xs)) * var(--lumo-font-size-m) / 2) 0;
|
|
216
|
+
color: var(--lumo-primary-text-color);
|
|
217
|
+
flex: none;
|
|
218
|
+
opacity: 0;
|
|
219
|
+
transition: transform 0.2s cubic-bezier(.12, .32, .54, 2), opacity 0.1s;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
:host([selected])::before {
|
|
223
|
+
opacity: 1;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
:host([active]:not([selected]))::before {
|
|
227
|
+
transform: scale(0.8);
|
|
228
|
+
opacity: 0;
|
|
229
|
+
transition-duration: 0s;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
[part="content"] {
|
|
233
|
+
flex: auto;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/* Disabled item */
|
|
237
|
+
|
|
238
|
+
:host([disabled]) {
|
|
239
|
+
color: var(--lumo-disabled-text-color);
|
|
240
|
+
cursor: default;
|
|
241
|
+
pointer-events: none;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/* Slotted icons */
|
|
245
|
+
|
|
246
|
+
:host ::slotted(iron-icon) {
|
|
247
|
+
width: var(--lumo-icon-size-m);
|
|
248
|
+
height: var(--lumo-icon-size-m);
|
|
249
|
+
}
|
|
250
|
+
</style>
|
|
251
|
+
</template>
|
|
252
|
+
</dom-module>`;document.head.appendChild(F.content);
|
|
253
|
+
/**
|
|
254
|
+
@license
|
|
255
|
+
Copyright (c) 2017 Vaadin Ltd.
|
|
256
|
+
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
257
|
+
*/
|
|
258
|
+
class $ extends(m(d(c(t)))){static get template(){return e`
|
|
259
|
+
<style>
|
|
260
|
+
:host {
|
|
261
|
+
display: inline-block;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
:host([hidden]) {
|
|
265
|
+
display: none !important;
|
|
266
|
+
}
|
|
267
|
+
</style>
|
|
268
|
+
<div part="content">
|
|
269
|
+
<slot></slot>
|
|
270
|
+
</div>
|
|
271
|
+
`}static get is(){return"vaadin-item"}static get version(){return"2.3.0"}constructor(){super(),this.value}}customElements.define($.is,$);const z=e`<dom-module id="lumo-combo-box-item" theme-for="vaadin-combo-box-item">
|
|
272
|
+
<template>
|
|
273
|
+
<style include="lumo-item">
|
|
274
|
+
/* TODO partly duplicated from vaadin-list-box styles. Should find a way to make it DRY */
|
|
275
|
+
|
|
276
|
+
:host {
|
|
277
|
+
cursor: default;
|
|
278
|
+
-webkit-tap-highlight-color: var(--lumo-primary-color-10pct);
|
|
279
|
+
padding-left: calc(var(--lumo-border-radius) / 4);
|
|
280
|
+
padding-right: calc(var(--lumo-space-l) + var(--lumo-border-radius) / 4);
|
|
281
|
+
transition: background-color 100ms;
|
|
282
|
+
border-radius: var(--lumo-border-radius);
|
|
283
|
+
overflow: hidden;
|
|
284
|
+
--_lumo-item-selected-icon-display: block;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/* ShadyCSS workaround (show the selected item checkmark) */
|
|
288
|
+
:host::before {
|
|
289
|
+
display: block;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
:host(:hover) {
|
|
293
|
+
background-color: var(--lumo-primary-color-10pct);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
:host([focused]:not([disabled])) {
|
|
297
|
+
box-shadow: inset 0 0 0 2px var(--lumo-primary-color-50pct);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
@media (pointer: coarse) {
|
|
301
|
+
:host(:hover) {
|
|
302
|
+
background-color: transparent;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
:host([focused]:not([disabled])) {
|
|
306
|
+
box-shadow: none;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/* RTL specific styles */
|
|
311
|
+
:host([dir="rtl"]) {
|
|
312
|
+
padding-right: calc(var(--lumo-border-radius) / 4);
|
|
313
|
+
padding-left: calc(var(--lumo-space-l) + var(--lumo-border-radius) / 4);
|
|
314
|
+
}
|
|
315
|
+
</style>
|
|
316
|
+
</template>
|
|
317
|
+
</dom-module>`;document.head.appendChild(z.content);const H=e`<dom-module id="lumo-combo-box" theme-for="vaadin-combo-box">
|
|
318
|
+
<template>
|
|
319
|
+
<style include="lumo-field-button">
|
|
320
|
+
:host {
|
|
321
|
+
outline: none;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
[part="toggle-button"]::before {
|
|
325
|
+
content: var(--lumo-icons-dropdown);
|
|
326
|
+
}
|
|
327
|
+
</style>
|
|
328
|
+
</template>
|
|
329
|
+
</dom-module>`;document.head.appendChild(H.content);
|
|
330
|
+
/**
|
|
331
|
+
@license
|
|
332
|
+
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
|
333
|
+
This code may only be used under the BSD style license found at
|
|
334
|
+
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
|
|
335
|
+
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
|
|
336
|
+
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
|
|
337
|
+
part of the polymer project is also subject to an additional IP rights grant
|
|
338
|
+
found at http://polymer.github.io/PATENTS.txt
|
|
339
|
+
*/
|
|
340
|
+
const N=b({_template:e`
|
|
341
|
+
<style>
|
|
342
|
+
:host {
|
|
343
|
+
display: inline-block;
|
|
344
|
+
position: fixed;
|
|
345
|
+
clip: rect(0px,0px,0px,0px);
|
|
346
|
+
}
|
|
347
|
+
</style>
|
|
348
|
+
<div aria-live$="[[mode]]">[[_text]]</div>
|
|
349
|
+
`,is:"iron-a11y-announcer",properties:{mode:{type:String,value:"polite"},timeout:{type:Number,value:150},_text:{type:String,value:""}},created:function(){N.instance||(N.instance=this),document.addEventListener("iron-announce",this._onIronAnnounce.bind(this))},announce:function(e){this._text="",this.async((function(){this._text=e}),this.timeout)},_onIronAnnounce:function(e){e.detail&&e.detail.text&&this.announce(e.detail.text)}});N.instance=null,N.requestAvailability=function(){N.instance||(N.instance=document.createElement("iron-a11y-announcer")),document.body?document.body.appendChild(N.instance):document.addEventListener("load",(function(){document.body.appendChild(N.instance)}))};
|
|
350
|
+
/**
|
|
351
|
+
@license
|
|
352
|
+
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
|
353
|
+
This code may only be used under the BSD style license found at
|
|
354
|
+
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
|
|
355
|
+
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
|
|
356
|
+
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
|
|
357
|
+
part of the polymer project is also subject to an additional IP rights grant
|
|
358
|
+
found at http://polymer.github.io/PATENTS.txt
|
|
359
|
+
*/
|
|
360
|
+
var M={"U+0008":"backspace","U+0009":"tab","U+001B":"esc","U+0020":"space","U+007F":"del"},D={8:"backspace",9:"tab",13:"enter",27:"esc",33:"pageup",34:"pagedown",35:"end",36:"home",32:"space",37:"left",38:"up",39:"right",40:"down",46:"del",106:"*"},K={shift:"shiftKey",ctrl:"ctrlKey",alt:"altKey",meta:"metaKey"},j=/[a-z0-9*]/,q=/U\+/,W=/^arrow/,U=/^space(bar)?/,Y=/^escape$/;function G(e,t){var i="";if(e){var s=e.toLowerCase();" "===s||U.test(s)?i="space":Y.test(s)?i="esc":1==s.length?t&&!j.test(s)||(i=s):i=W.test(s)?s.replace("arrow",""):"multiply"==s?"*":s}return i}function X(e,t){return e.key?G(e.key,t):e.detail&&e.detail.key?G(e.detail.key,t):(i=e.keyIdentifier,s="",i&&(i in M?s=M[i]:q.test(i)?(i=parseInt(i.replace("U+","0x"),16),s=String.fromCharCode(i).toLowerCase()):s=i.toLowerCase()),s||function(e){var t="";return Number(e)&&(t=e>=65&&e<=90?String.fromCharCode(32+e):e>=112&&e<=123?"f"+(e-112+1):e>=48&&e<=57?String(e-48):e>=96&&e<=105?String(e-96):D[e]),t}(e.keyCode)||"");var i,s}function J(e,t){return X(t,e.hasModifiers)===e.key&&(!e.hasModifiers||!!t.shiftKey==!!e.shiftKey&&!!t.ctrlKey==!!e.ctrlKey&&!!t.altKey==!!e.altKey&&!!t.metaKey==!!e.metaKey)}function Q(e){return e.trim().split(" ").map((function(e){return function(e){return 1===e.length?{combo:e,key:e,event:"keydown"}:e.split("+").reduce((function(e,t){var i=t.split(":"),s=i[0],o=i[1];return s in K?(e[K[s]]=!0,e.hasModifiers=!0):(e.key=s,e.event=o||"keydown"),e}),{combo:e.split(":").shift()})}(e)}))}const Z={properties:{keyEventTarget:{type:Object,value:function(){return this}},stopKeyboardEventPropagation:{type:Boolean,value:!1},_boundKeyHandlers:{type:Array,value:function(){return[]}},_imperativeKeyBindings:{type:Object,value:function(){return{}}}},observers:["_resetKeyEventListeners(keyEventTarget, _boundKeyHandlers)"],keyBindings:{},registered:function(){this._prepKeyBindings()},attached:function(){this._listenKeyEventListeners()},detached:function(){this._unlistenKeyEventListeners()},addOwnKeyBinding:function(e,t){this._imperativeKeyBindings[e]=t,this._prepKeyBindings(),this._resetKeyEventListeners()},removeOwnKeyBindings:function(){this._imperativeKeyBindings={},this._prepKeyBindings(),this._resetKeyEventListeners()},keyboardEventMatchesKeys:function(e,t){for(var i=Q(t),s=0;s<i.length;++s)if(J(i[s],e))return!0;return!1},_collectKeyBindings:function(){var e=this.behaviors.map((function(e){return e.keyBindings}));return-1===e.indexOf(this.keyBindings)&&e.push(this.keyBindings),e},_prepKeyBindings:function(){for(var e in this._keyBindings={},this._collectKeyBindings().forEach((function(e){for(var t in e)this._addKeyBinding(t,e[t])}),this),this._imperativeKeyBindings)this._addKeyBinding(e,this._imperativeKeyBindings[e]);for(var t in this._keyBindings)this._keyBindings[t].sort((function(e,t){var i=e[0].hasModifiers;return i===t[0].hasModifiers?0:i?-1:1}))},_addKeyBinding:function(e,t){Q(e).forEach((function(e){this._keyBindings[e.event]=this._keyBindings[e.event]||[],this._keyBindings[e.event].push([e,t])}),this)},_resetKeyEventListeners:function(){this._unlistenKeyEventListeners(),this.isAttached&&this._listenKeyEventListeners()},_listenKeyEventListeners:function(){this.keyEventTarget&&Object.keys(this._keyBindings).forEach((function(e){var t=this._keyBindings[e],i=this._onKeyBindingEvent.bind(this,t);this._boundKeyHandlers.push([this.keyEventTarget,e,i]),this.keyEventTarget.addEventListener(e,i)}),this)},_unlistenKeyEventListeners:function(){for(var e,t,i,s;this._boundKeyHandlers.length;)t=(e=this._boundKeyHandlers.pop())[0],i=e[1],s=e[2],t.removeEventListener(i,s)},_onKeyBindingEvent:function(e,t){if(this.stopKeyboardEventPropagation&&t.stopPropagation(),!t.defaultPrevented)for(var i=0;i<e.length;i++){var s=e[i][0],o=e[i][1];if(J(s,t)&&(this._triggerKeyHandler(s,o,t),t.defaultPrevented))return}},_triggerKeyHandler:function(e,t,i){var s=Object.create(e);s.keyboardEvent=i;var o=new CustomEvent(e.event,{detail:s,cancelable:!0});this[t].call(this,o),o.defaultPrevented&&i.preventDefault()}},ee=class{toString(){return""}},te=e=>class extends e{static get properties(){return{opened:{type:Boolean,notify:!0,value:!1,reflectToAttribute:!0,observer:"_openedChanged"},autoOpenDisabled:Boolean,disabled:{type:Boolean,value:!1,reflectToAttribute:!0},readonly:{type:Boolean,value:!1,reflectToAttribute:!0},renderer:Function,items:{type:Array,observer:"_itemsChanged"},allowCustomValue:{type:Boolean,value:!1},filteredItems:{type:Array},value:{type:String,observer:"_valueChanged",notify:!0,value:""},_lastCommittedValue:String,loading:{type:Boolean,value:!1,reflectToAttribute:!0},_focusedIndex:{type:Number,value:-1},filter:{type:String,value:"",notify:!0},selectedItem:{type:Object,notify:!0},_hasInputValue:{type:Boolean,value:!1,observer:"_hasInputValueChanged"},itemLabelPath:{type:String,value:"label",observer:"_itemLabelPathChanged"},itemValuePath:{type:String,value:"value"},itemIdPath:String,name:{type:String},invalid:{type:Boolean,reflectToAttribute:!0,notify:!0,value:!1},_toggleElement:Object,_clearElement:Object,_inputElementValue:String,_closeOnBlurIsPrevented:Boolean,_previousDocumentPointerEvents:String,_itemTemplate:Object}}static get observers(){return["_filterChanged(filter, itemValuePath, itemLabelPath)","_itemsOrPathsChanged(items.*, itemValuePath, itemLabelPath)","_filteredItemsChanged(filteredItems.*, itemValuePath, itemLabelPath)","_templateOrRendererChanged(_itemTemplate, renderer)","_loadingChanged(loading)","_selectedItemChanged(selectedItem, itemValuePath, itemLabelPath)","_toggleElementChanged(_toggleElement)","_inputElementValueChanged(_inputElementValue)"]}constructor(){super(),this._boundOnFocusout=this._onFocusout.bind(this),this._boundOverlaySelectedItemChanged=this._overlaySelectedItemChanged.bind(this),this._boundClose=this.close.bind(this),this._boundOnOpened=this._onOpened.bind(this),this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnClick=this._onClick.bind(this),this._boundOnOverlayTouchAction=this._onOverlayTouchAction.bind(this),this._boundOnTouchend=this._onTouchend.bind(this)}ready(){super.ready(),this.addEventListener("focusout",this._boundOnFocusout),this._lastCommittedValue=this.value,N.requestAvailability(),this.$.overlay.addEventListener("selection-changed",this._boundOverlaySelectedItemChanged),this.addEventListener("vaadin-combo-box-dropdown-closed",this._boundClose),this.addEventListener("vaadin-combo-box-dropdown-opened",this._boundOnOpened),this.addEventListener("keydown",this._boundOnKeyDown),this.addEventListener("click",this._boundOnClick),this.$.overlay.addEventListener("vaadin-overlay-touch-action",this._boundOnOverlayTouchAction),this.addEventListener("touchend",this._boundOnTouchend),this._observer=new y(this,(e=>{this._setTemplateFromNodes(e.addedNodes)}));const e=e=>{const t=this.$.overlay,i=t&&t.$.dropdown;i&&i.$&&this.$.overlay.$.dropdown.$.overlay.bringToFront&&requestAnimationFrame((()=>{i.$.overlay.bringToFront()}))};this.addEventListener("mousedown",e),this.addEventListener("touchstart",e)}render(){this.$.overlay._selector&&this.$.overlay._selector.querySelectorAll("vaadin-combo-box-item").forEach((e=>e._render()))}_setTemplateFromNodes(e){this._itemTemplate=e.filter((e=>e.localName&&"template"===e.localName))[0]||this._itemTemplate}_removeNewRendererOrTemplate(e,t,i,s){e!==t?this._itemTemplate=void 0:i!==s&&(this.renderer=void 0)}_templateOrRendererChanged(e,t){if(e&&t)throw this._removeNewRendererOrTemplate(e,this._oldTemplate,t,this._oldRenderer),new Error("You should only use either a renderer or a template for combo box items");this._oldTemplate=e,this._oldRenderer=t}open(){this.disabled||this.readonly||(this.opened=!0)}close(){this.opened=!1}_openedChanged(e,t){void 0!==t&&(this.opened?(this._openedWithFocusRing=this.hasAttribute("focus-ring")||this.focusElement&&this.focusElement.hasAttribute("focus-ring"),this.hasAttribute("focused")||this.$.overlay.touchDevice||this.focus()):(this._onClosed(),this._openedWithFocusRing&&this.hasAttribute("focused")&&this.focusElement.setAttribute("focus-ring","")))}_onOverlayTouchAction(e){this._closeOnBlurIsPrevented=!0,this.inputElement.blur(),this._closeOnBlurIsPrevented=!1}_onClick(e){this._closeOnBlurIsPrevented=!0;const t=e.composedPath();-1!==t.indexOf(this._clearElement)||"clear-button"===t[0].getAttribute("part")?(this._clear(),this.focus()):-1!==t.indexOf(this.inputElement)&&(t.indexOf(this._toggleElement)>-1&&this.opened?this.close():(t.indexOf(this._toggleElement)>-1||!this.autoOpenDisabled)&&this.open()),this._closeOnBlurIsPrevented=!1}_onKeyDown(e){this._isEventKey(e,"down")?(this._closeOnBlurIsPrevented=!0,this._onArrowDown(),this._closeOnBlurIsPrevented=!1,e.preventDefault()):this._isEventKey(e,"up")?(this._closeOnBlurIsPrevented=!0,this._onArrowUp(),this._closeOnBlurIsPrevented=!1,e.preventDefault()):this._isEventKey(e,"enter")?this._onEnter(e):this._isEventKey(e,"esc")&&this._onEscape(e)}_isEventKey(e,t){return Z.keyboardEventMatchesKeys(e,t)}_getItemLabel(e){return this.$.overlay.getItemLabel(e)}_getItemValue(e){let t=e&&this.itemValuePath?this.get(this.itemValuePath,e):void 0;return void 0===t&&(t=e?e.toString():""),t}_onArrowDown(){this.opened?this.$.overlay._items&&(this._focusedIndex=Math.min(this.$.overlay._items.length-1,this._focusedIndex+1),this._prefillFocusedItemLabel()):this.open()}_onArrowUp(){this.opened?(this._focusedIndex>-1?this._focusedIndex=Math.max(0,this._focusedIndex-1):this.$.overlay._items&&(this._focusedIndex=this.$.overlay._items.length-1),this._prefillFocusedItemLabel()):this.open()}_prefillFocusedItemLabel(){this._focusedIndex>-1&&(this._inputElementValue="",setTimeout((()=>{this._inputElementValue=this._getItemLabel(this.$.overlay._focusedItem),this._markAllSelectionRange()}),1))}_setSelectionRange(e,t){const i=this._nativeInput||this.inputElement;if(this.hasAttribute("focused")&&i&&i.setSelectionRange)try{i.setSelectionRange(e,t)}catch(e){}}_markAllSelectionRange(){void 0!==this._inputElementValue&&this._setSelectionRange(0,this._inputElementValue.length)}_clearSelectionRange(){if(void 0!==this._inputElementValue){const e=this._inputElementValue?this._inputElementValue.length:0;this._setSelectionRange(e,e)}}_closeOrCommit(){this.opened||this.loading?this.close():this._commitValue()}_onEnter(e){(this.opened||this.autoOpenDisabled)&&(this.allowCustomValue||""===this._inputElementValue||this._focusedIndex>-1)&&(this._closeOrCommit(),e.preventDefault(),e.stopPropagation())}_onEscape(e){this.autoOpenDisabled?this.opened||this.value!==this._inputElementValue&&this._inputElementValue.length>0?(this._stopPropagation(e),this._focusedIndex=-1,this.cancel()):this.clearButtonVisible&&!this.opened&&this.value&&(this._stopPropagation(e),this._clear()):this.opened?(this._stopPropagation(e),this._focusedIndex>-1?(this._focusedIndex=-1,this._revertInputValue()):this.cancel()):this.clearButtonVisible&&this.value&&(this._stopPropagation(e),this._clear())}_toggleElementChanged(e){e&&(e.addEventListener("mousedown",(e=>e.preventDefault())),e.addEventListener("click",(e=>{this.$.overlay.touchDevice&&!this.hasAttribute("focused")&&document.activeElement.blur()})))}_clear(){this.selectedItem=null,this.allowCustomValue&&(this._inputElementValue="",this.value=""),this._detectAndDispatchChange()}cancel(){this._revertInputValueToValue(),this._lastCommittedValue=this.value,this._closeOrCommit()}_onOpened(){I(),this.$.overlay.ensureItemsRendered(),this.$.overlay._selector.toggleScrollListener(!0),this.$.overlay.updateViewportBoundaries(),this.$.overlay._selector._increasePoolIfNeeded(),setTimeout((()=>this._resizeDropdown()),1),window.requestAnimationFrame((()=>this.$.overlay.adjustScrollPosition())),this._lastCommittedValue=this.value}_onClosed(){this.opened&&this.close(),this.loading&&!this.allowCustomValue||this._commitValue()}_commitValue(){if(this.$.overlay._items&&this._focusedIndex>-1){const e=this.$.overlay._items[this._focusedIndex];this.selectedItem!==e&&(this.selectedItem=e),this._inputElementValue=this._getItemLabel(this.selectedItem)}else if(""===this._inputElementValue||void 0===this._inputElementValue)this.selectedItem=null,this.allowCustomValue&&(this.value="");else{const e=e=>e&&e.toLowerCase&&e.toLowerCase(),t=[...this.filteredItems||[],this.selectedItem].filter((t=>e(this._getItemLabel(t))===e(this._inputElementValue)))[0];if(this.allowCustomValue&&!t){const e=new CustomEvent("custom-value-set",{detail:this._inputElementValue,composed:!0,cancelable:!0,bubbles:!0});if(this.dispatchEvent(e),!e.defaultPrevented){const e=this._inputElementValue;this._selectItemForValue(e),this.value=e}}else this.allowCustomValue||this.opened||!t?this._inputElementValue=this.selectedItem?this._getItemLabel(this.selectedItem):this.value||"":this.value=this._getItemValue(t)}this._detectAndDispatchChange(),this._clearSelectionRange(),this.dataProvider||(this.filter="")}get _propertyForValue(){return"value"}_inputValueChanged(e){-1!==e.composedPath().indexOf(this.inputElement)&&(e.__fromClearButton||(this._inputElementValue=this.inputElement[this._propertyForValue]),this._filterFromInput(e))}_inputElementValueChanged(e){this._hasInputValue=null!=e&&e.length>0}_filterFromInput(e){this.opened||e.__fromClearButton||this.autoOpenDisabled||this.open(),this.filter===this._inputElementValue?this._filterChanged(this.filter,this.itemValuePath,this.itemLabelPath):this.filter=this._inputElementValue}_itemLabelPathChanged(e,t){"string"!=typeof e&&console.error("You should set itemLabelPath to a valid string")}_filterChanged(e,t,i){void 0!==e&&(this.$.overlay.filterChanged=!0,this.items?this.filteredItems=this._filterItems(this.items,e):this._filteredItemsChanged({path:"filteredItems",value:this.filteredItems},t,i))}_loadingChanged(e){e&&(this._focusedIndex=-1)}_revertInputValue(){""!==this.filter?this._inputElementValue=this.filter:this._revertInputValueToValue(),this._clearSelectionRange()}_revertInputValueToValue(){this.allowCustomValue&&!this.selectedItem?this._inputElementValue=this.value:this._inputElementValue=this._getItemLabel(this.selectedItem)}_resizeDropdown(){this.$.overlay.$.dropdown.notifyResize()}_updateHasValue(e){e?this.setAttribute("has-value",""):this.removeAttribute("has-value")}_selectedItemChanged(e,t){if(null==e)this.filteredItems&&(this.allowCustomValue||(this.value=""),this._updateHasValue(""!==this.value),this._inputElementValue=this.value);else{const t=this._getItemValue(e);if(this.value!==t&&(this.value=t,this.value!==t))return;this._updateHasValue(!0),this._inputElementValue=this._getItemLabel(e),this.inputElement&&(this.inputElement[this._propertyForValue]=this._inputElementValue)}this.$.overlay._selectedItem=e,this.filteredItems&&this.$.overlay._items&&(this._focusedIndex=this.filteredItems.indexOf(e))}_valueChanged(e,t){if(""!==e||void 0!==t){if(this._isValidValue(e)){let t;this._getItemValue(this.selectedItem)!==e?this._selectItemForValue(e):t=this.selectedItem,!t&&this.allowCustomValue&&(this._inputElementValue=e),this._updateHasValue(""!==this.value)}else this.selectedItem=null;this._lastCommittedValue=void 0}}_detectAndDispatchChange(){this.value!==this._lastCommittedValue&&(this.validate(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0})),this._lastCommittedValue=this.value)}_itemsChanged(e,t){this._ensureItemsOrDataProvider((()=>{this.items=t}))}_itemsOrPathsChanged(e,t,i){if("items"===e.path||"items.splices"===e.path){this.items?this.filteredItems=this.items.slice(0):this.__previousItems&&(this.filteredItems=null);const e=this._indexOfValue(this.value,this.items);this._focusedIndex=e;const t=e>-1&&this.items[e];t&&(this.selectedItem=t)}this.__previousItems=e.value}_filteredItemsChanged(e,t,i){"filteredItems"!==e.path&&"filteredItems.splices"!==e.path||(this._setOverlayItems(this.filteredItems),this._focusedIndex=this.opened||this.autoOpenDisabled?this.$.overlay.indexOfLabel(this.filter):this._indexOfValue(this.value,this.filteredItems),this.opened&&this._repositionOverlay())}_filterItems(e,t){if(!e)return e;return e.filter((e=>(t=t?t.toString().toLowerCase():"",this._getItemLabel(e).toString().toLowerCase().indexOf(t)>-1)))}_selectItemForValue(e){const t=this._indexOfValue(e,this.filteredItems),i=this.selectedItem;this.selectedItem=t>=0?this.filteredItems[t]:this.dataProvider&&void 0===this.selectedItem?void 0:null,null===this.selectedItem&&null===i&&this._selectedItemChanged(this.selectedItem)}_setOverlayItems(e){this.$.overlay.set("_items",e)}_repositionOverlay(){this.__repositionOverlayDebouncer=i.debounce(this.__repositionOverlayDebouncer,s.after(500),(()=>{const e=this.$.overlay._selector;e._isClientFull()||e._resetScrollPosition(e._physicalTop),this._resizeDropdown(),this.$.overlay.updateViewportBoundaries(),this.$.overlay.ensureItemsRendered(),e.notifyResize(),I()}))}_indexOfValue(e,t){if(t&&this._isValidValue(e))for(let i=0;i<t.length;i++)if(this._getItemValue(t[i])===e)return i;return-1}_isValidValue(e){return null!=e}_overlaySelectedItemChanged(e){e.stopPropagation(),e.detail.item instanceof ee||(this.opened?(this._focusedIndex=this.filteredItems.indexOf(e.detail.item),this.close()):this.selectedItem!==e.detail.item&&(this.selectedItem=e.detail.item,this._detectAndDispatchChange()))}_onFocusout(e){const t=this.$.overlay.$.dropdown;t&&t.$&&e.relatedTarget===t.$.overlay?e.composedPath()[0].focus():this.readonly||this._closeOnBlurIsPrevented||(this._closeOrCommit(),this.validate())}_onTouchend(e){this._clearElement&&e.composedPath()[0]===this._clearElement&&(e.preventDefault(),this._clear())}_hasInputValueChanged(e,t){(e||t)&&this.dispatchEvent(new CustomEvent("has-input-value-changed"))}_setInvalid(e){this._shouldSetInvalid(e)&&(this.invalid=e)}_shouldSetInvalid(e){return!0}validate(){const e=this.checkValidity();return this._setInvalid(!e),this.dispatchEvent(new CustomEvent("validated",{detail:{valid:e}})),e}checkValidity(){if(this.inputElement.checkValidity)return this.inputElement.checkValidity()}get _instanceProps(){return{item:!0,index:!0,selected:!0,focused:!0}}_ensureTemplatized(){if(!this._TemplateClass){const e=this._itemTemplate||this._getRootTemplate();e&&(this._TemplateClass=f(e,this,{instanceProps:this._instanceProps,forwardHostProp:function(e,t){const i=this.$.overlay._selector.querySelectorAll("vaadin-combo-box-item");Array.prototype.forEach.call(i,(i=>{i._itemTemplateInstance&&(i._itemTemplateInstance.set(e,t),i._itemTemplateInstance.notifyPath(e,t,!0))}))}}))}}_getRootTemplate(){return Array.prototype.filter.call(this.children,(e=>"TEMPLATE"===e.tagName))[0]}_preventInputBlur(){this._toggleElement&&this._toggleElement.addEventListener("click",this._preventDefault),this._clearElement&&this._clearElement.addEventListener("click",this._preventDefault)}_restoreInputBlur(){this._toggleElement&&this._toggleElement.removeEventListener("click",this._preventDefault),this._clearElement&&this._clearElement.removeEventListener("click",this._preventDefault)}_preventDefault(e){e.preventDefault()}_stopPropagation(e){e.stopPropagation()}}
|
|
361
|
+
/**
|
|
362
|
+
@license
|
|
363
|
+
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
|
364
|
+
This code may only be used under the BSD style license found at
|
|
365
|
+
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
|
|
366
|
+
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
|
|
367
|
+
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
|
|
368
|
+
part of the polymer project is also subject to an additional IP rights grant
|
|
369
|
+
found at http://polymer.github.io/PATENTS.txt
|
|
370
|
+
*/,ie={properties:{scrollTarget:{type:HTMLElement,value:function(){return this._defaultScrollTarget}}},observers:["_scrollTargetChanged(scrollTarget, isAttached)"],_shouldHaveListener:!0,_scrollTargetChanged:function(e,t){if(this._oldScrollTarget&&(this._toggleScrollListener(!1,this._oldScrollTarget),this._oldScrollTarget=null),t)if("document"===e)this.scrollTarget=this._doc;else if("string"==typeof e){var i=this.domHost;this.scrollTarget=i&&i.$?i.$[e]:x(this.ownerDocument).querySelector("#"+e)}else this._isValidScrollTarget()&&(this._oldScrollTarget=e,this._toggleScrollListener(this._shouldHaveListener,e))},_scrollHandler:function(){},get _defaultScrollTarget(){return this._doc},get _doc(){return this.ownerDocument.documentElement},get _scrollTop(){return this._isValidScrollTarget()?this.scrollTarget===this._doc?window.pageYOffset:this.scrollTarget.scrollTop:0},get _scrollLeft(){return this._isValidScrollTarget()?this.scrollTarget===this._doc?window.pageXOffset:this.scrollTarget.scrollLeft:0},set _scrollTop(e){this.scrollTarget===this._doc?window.scrollTo(window.pageXOffset,e):this._isValidScrollTarget()&&(this.scrollTarget.scrollTop=e)},set _scrollLeft(e){this.scrollTarget===this._doc?window.scrollTo(e,window.pageYOffset):this._isValidScrollTarget()&&(this.scrollTarget.scrollLeft=e)},scroll:function(e,t){var i;"object"==typeof e?(i=e.left,t=e.top):i=e,i=i||0,t=t||0,this.scrollTarget===this._doc?window.scrollTo(i,t):this._isValidScrollTarget()&&(this.scrollTarget.scrollLeft=i,this.scrollTarget.scrollTop=t)},get _scrollTargetWidth(){return this._isValidScrollTarget()?this.scrollTarget===this._doc?window.innerWidth:this.scrollTarget.offsetWidth:0},get _scrollTargetHeight(){return this._isValidScrollTarget()?this.scrollTarget===this._doc?window.innerHeight:this.scrollTarget.offsetHeight:0},_isValidScrollTarget:function(){return this.scrollTarget instanceof HTMLElement},_toggleScrollListener:function(e,t){var i=t===this._doc?window:t;e?this._boundScrollHandler||(this._boundScrollHandler=this._scrollHandler.bind(this),i.addEventListener("scroll",this._boundScrollHandler)):this._boundScrollHandler&&(i.removeEventListener("scroll",this._boundScrollHandler),this._boundScrollHandler=null)},toggleScrollListener:function(e){this._shouldHaveListener=e,this._toggleScrollListener(e,this.scrollTarget)}};
|
|
371
|
+
/**
|
|
372
|
+
@license
|
|
373
|
+
Copyright (c) 2018 Vaadin Ltd.
|
|
374
|
+
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
375
|
+
*/
|
|
376
|
+
/**
|
|
377
|
+
@license
|
|
378
|
+
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
|
379
|
+
This code may only be used under the BSD style license found at
|
|
380
|
+
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
|
|
381
|
+
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
|
|
382
|
+
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
|
|
383
|
+
part of the polymer project is also subject to an additional IP rights grant
|
|
384
|
+
found at http://polymer.github.io/PATENTS.txt
|
|
385
|
+
*/
|
|
386
|
+
var se=navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/),oe=se&&se[1]>=8,ne="-10000px",re=-100;b({_template:e`
|
|
387
|
+
<style>
|
|
388
|
+
:host {
|
|
389
|
+
display: block;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
@media only screen and (-webkit-max-device-pixel-ratio: 1) {
|
|
393
|
+
:host {
|
|
394
|
+
will-change: transform;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
#items {
|
|
399
|
+
@apply --iron-list-items-container;
|
|
400
|
+
position: relative;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
:host(:not([grid])) #items > ::slotted(*) {
|
|
404
|
+
width: 100%;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
#items > ::slotted(*) {
|
|
408
|
+
box-sizing: border-box;
|
|
409
|
+
margin: 0;
|
|
410
|
+
position: absolute;
|
|
411
|
+
top: 0;
|
|
412
|
+
will-change: transform;
|
|
413
|
+
}
|
|
414
|
+
</style>
|
|
415
|
+
|
|
416
|
+
<array-selector id="selector" items="{{items}}" selected="{{selectedItems}}" selected-item="{{selectedItem}}"></array-selector>
|
|
417
|
+
|
|
418
|
+
<div id="items">
|
|
419
|
+
<slot></slot>
|
|
420
|
+
</div>
|
|
421
|
+
`,is:"iron-list",properties:{items:{type:Array},as:{type:String,value:"item"},indexAs:{type:String,value:"index"},selectedAs:{type:String,value:"selected"},grid:{type:Boolean,value:!1,reflectToAttribute:!0,observer:"_gridChanged"},selectionEnabled:{type:Boolean,value:!1},selectedItem:{type:Object,notify:!0},selectedItems:{type:Object,notify:!0},multiSelection:{type:Boolean,value:!1},scrollOffset:{type:Number,value:0}},observers:["_itemsChanged(items.*)","_selectionEnabledChanged(selectionEnabled)","_multiSelectionChanged(multiSelection)","_setOverflow(scrollTarget, scrollOffset)"],behaviors:[P,p,ie,w],_ratio:.5,_scrollerPaddingTop:0,_scrollPosition:0,_physicalSize:0,_physicalAverage:0,_physicalAverageCount:0,_physicalTop:0,_virtualCount:0,_estScrollHeight:0,_scrollHeight:0,_viewportHeight:0,_viewportWidth:0,_physicalItems:null,_physicalSizes:null,_firstVisibleIndexVal:null,_lastVisibleIndexVal:null,_maxPages:2,_focusedItem:null,_focusedVirtualIndex:-1,_focusedPhysicalIndex:-1,_offscreenFocusedItem:null,_focusBackfillItem:null,_itemsPerRow:1,_itemWidth:0,_rowHeight:0,_templateCost:0,_parentModel:!0,get _physicalBottom(){return this._physicalTop+this._physicalSize},get _scrollBottom(){return this._scrollPosition+this._viewportHeight},get _virtualEnd(){return this._virtualStart+this._physicalCount-1},get _hiddenContentSize(){return(this.grid?this._physicalRows*this._rowHeight:this._physicalSize)-this._viewportHeight},get _itemsParent(){return x(x(this._userTemplate).parentNode)},get _maxScrollTop(){return this._estScrollHeight-this._viewportHeight+this._scrollOffset},get _maxVirtualStart(){var e=this._convertIndexToCompleteRow(this._virtualCount);return Math.max(0,e-this._physicalCount)},set _virtualStart(e){e=this._clamp(e,0,this._maxVirtualStart),this.grid&&(e-=e%this._itemsPerRow),this._virtualStartVal=e},get _virtualStart(){return this._virtualStartVal||0},set _physicalStart(e){(e%=this._physicalCount)<0&&(e=this._physicalCount+e),this.grid&&(e-=e%this._itemsPerRow),this._physicalStartVal=e},get _physicalStart(){return this._physicalStartVal||0},get _physicalEnd(){return(this._physicalStart+this._physicalCount-1)%this._physicalCount},set _physicalCount(e){this._physicalCountVal=e},get _physicalCount(){return this._physicalCountVal||0},get _optPhysicalSize(){return 0===this._viewportHeight?1/0:this._viewportHeight*this._maxPages},get _isVisible(){return Boolean(this.offsetWidth||this.offsetHeight)},get firstVisibleIndex(){var e=this._firstVisibleIndexVal;if(null==e){var t=this._physicalTop+this._scrollOffset;e=this._iterateItems((function(e,i){return(t+=this._getPhysicalSizeIncrement(e))>this._scrollPosition?this.grid?i-i%this._itemsPerRow:i:this.grid&&this._virtualCount-1===i?i-i%this._itemsPerRow:void 0}))||0,this._firstVisibleIndexVal=e}return e},get lastVisibleIndex(){var e=this._lastVisibleIndexVal;if(null==e){if(this.grid)e=Math.min(this._virtualCount,this.firstVisibleIndex+this._estRowsInView*this._itemsPerRow-1);else{var t=this._physicalTop+this._scrollOffset;this._iterateItems((function(i,s){t<this._scrollBottom&&(e=s),t+=this._getPhysicalSizeIncrement(i)}))}this._lastVisibleIndexVal=e}return e},get _defaultScrollTarget(){return this},get _virtualRowCount(){return Math.ceil(this._virtualCount/this._itemsPerRow)},get _estRowsInView(){return Math.ceil(this._viewportHeight/this._rowHeight)},get _physicalRows(){return Math.ceil(this._physicalCount/this._itemsPerRow)},get _scrollOffset(){return this._scrollerPaddingTop+this.scrollOffset},ready:function(){this.addEventListener("focus",this._didFocus.bind(this),!0)},attached:function(){this._debounce("_render",this._render,o),this.listen(this,"iron-resize","_resizeHandler"),this.listen(this,"keydown","_keydownHandler")},detached:function(){this.unlisten(this,"iron-resize","_resizeHandler"),this.unlisten(this,"keydown","_keydownHandler")},_setOverflow:function(e){this.style.webkitOverflowScrolling=e===this?"touch":"",this.style.overflowY=e===this?"auto":"",this._lastVisibleIndexVal=null,this._firstVisibleIndexVal=null,this._debounce("_render",this._render,o)},updateViewportBoundaries:function(){var e=window.getComputedStyle(this);this._scrollerPaddingTop=this.scrollTarget===this?0:parseInt(e["padding-top"],10),this._isRTL=Boolean("rtl"===e.direction),this._viewportWidth=this.$.items.offsetWidth,this._viewportHeight=this._scrollTargetHeight,this.grid&&this._updateGridMetrics()},_scrollHandler:function(){var e=Math.max(0,Math.min(this._maxScrollTop,this._scrollTop)),t=e-this._scrollPosition,i=t>=0;if(this._scrollPosition=e,this._firstVisibleIndexVal=null,this._lastVisibleIndexVal=null,Math.abs(t)>this._physicalSize&&this._physicalSize>0){t-=this._scrollOffset;var s=Math.round(t/this._physicalAverage)*this._itemsPerRow;this._virtualStart=this._virtualStart+s,this._physicalStart=this._physicalStart+s,this._physicalTop=Math.min(Math.floor(this._virtualStart/this._itemsPerRow)*this._physicalAverage,this._scrollPosition),this._update()}else if(this._physicalCount>0){var o=this._getReusables(i);i?(this._physicalTop=o.physicalTop,this._virtualStart=this._virtualStart+o.indexes.length,this._physicalStart=this._physicalStart+o.indexes.length):(this._virtualStart=this._virtualStart-o.indexes.length,this._physicalStart=this._physicalStart-o.indexes.length),this._update(o.indexes,i?null:o.indexes),this._debounce("_increasePoolIfNeeded",this._increasePoolIfNeeded.bind(this,0),n)}},_getReusables:function(e){var t,i,s,o=[],n=this._hiddenContentSize*this._ratio,r=this._virtualStart,a=this._virtualEnd,l=this._physicalCount,h=this._physicalTop+this._scrollOffset,d=this._physicalBottom+this._scrollOffset,c=this._scrollPosition,u=this._scrollBottom;for(e?(t=this._physicalStart,this._physicalEnd,i=c-h):(t=this._physicalEnd,this._physicalStart,i=d-u);i-=s=this._getPhysicalSizeIncrement(t),!(o.length>=l||i<=n);)if(e){if(a+o.length+1>=this._virtualCount)break;if(h+s>=c-this._scrollOffset)break;o.push(t),h+=s,t=(t+1)%l}else{if(r-o.length<=0)break;if(h+this._physicalSize-s<=u)break;o.push(t),h-=s,t=0===t?l-1:t-1}return{indexes:o,physicalTop:h-this._scrollOffset}},_update:function(e,t){if(!(e&&0===e.length||0===this._physicalCount)){if(this._manageFocus(),this._assignModels(e),this._updateMetrics(e),t)for(;t.length;){var i=t.pop();this._physicalTop-=this._getPhysicalSizeIncrement(i)}this._positionItems(),this._updateScrollerSize()}},_createPool:function(e){var t,i;this._ensureTemplatized();var s=new Array(e);for(t=0;t<e;t++)i=this.stamp(null),s[t]=i.root.querySelector("*"),this._itemsParent.appendChild(i.root);return s},_isClientFull:function(){return 0!=this._scrollBottom&&this._physicalBottom-1>=this._scrollBottom&&this._physicalTop<=this._scrollPosition},_increasePoolIfNeeded:function(e){var t=this._clamp(this._physicalCount+e,3,this._virtualCount-this._virtualStart);if(t=this._convertIndexToCompleteRow(t),this.grid){var i=t%this._itemsPerRow;i&&t-i<=this._physicalCount&&(t+=this._itemsPerRow),t-=i}var s=t-this._physicalCount,o=Math.round(.5*this._physicalCount);if(!(s<0)){if(s>0){var a=window.performance.now();[].push.apply(this._physicalItems,this._createPool(s));for(var l=0;l<s;l++)this._physicalSizes.push(0);this._physicalCount=this._physicalCount+s,this._physicalStart>this._physicalEnd&&this._isIndexRendered(this._focusedVirtualIndex)&&this._getPhysicalIndex(this._focusedVirtualIndex)<this._physicalEnd&&(this._physicalStart=this._physicalStart+s),this._update(),this._templateCost=(window.performance.now()-a)/s,o=Math.round(.5*this._physicalCount)}this._virtualEnd>=this._virtualCount-1||0===o||(this._isClientFull()?this._physicalSize<this._optPhysicalSize&&this._debounce("_increasePoolIfNeeded",this._increasePoolIfNeeded.bind(this,this._clamp(Math.round(50/this._templateCost),1,o)),r):this._debounce("_increasePoolIfNeeded",this._increasePoolIfNeeded.bind(this,o),n))}},_render:function(){if(this.isAttached&&this._isVisible)if(0!==this._physicalCount){var e=this._getReusables(!0);this._physicalTop=e.physicalTop,this._virtualStart=this._virtualStart+e.indexes.length,this._physicalStart=this._physicalStart+e.indexes.length,this._update(e.indexes),this._update(),this._increasePoolIfNeeded(0)}else this._virtualCount>0&&(this.updateViewportBoundaries(),this._increasePoolIfNeeded(3))},_ensureTemplatized:function(){if(!this.ctor){this._userTemplate=this.queryEffectiveChildren("template"),this._userTemplate||console.warn("iron-list requires a template to be provided in light-dom");var e={__key__:!0};e[this.as]=!0,e[this.indexAs]=!0,e[this.selectedAs]=!0,e.tabIndex=!0,this._instanceProps=e,this.templatize(this._userTemplate,this.mutableData)}},_gridChanged:function(e,t){void 0!==t&&(this.notifyResize(),I(),e&&this._updateGridMetrics())},_itemsChanged:function(e){if("items"===e.path)this._virtualStart=0,this._physicalTop=0,this._virtualCount=this.items?this.items.length:0,this._physicalIndexForKey={},this._firstVisibleIndexVal=null,this._lastVisibleIndexVal=null,this._physicalCount=this._physicalCount||0,this._physicalItems=this._physicalItems||[],this._physicalSizes=this._physicalSizes||[],this._physicalStart=0,this._scrollTop>this._scrollOffset&&this._resetScrollPosition(0),this._removeFocusedItem(),this._debounce("_render",this._render,o);else if("items.splices"===e.path){if(this._adjustVirtualIndex(e.value.indexSplices),this._virtualCount=this.items?this.items.length:0,e.value.indexSplices.some((function(e){return e.addedCount>0||e.removed.length>0}))){var t=this._getActiveElement();this.contains(t)&&t.blur()}var i=e.value.indexSplices.some((function(e){return e.index+e.addedCount>=this._virtualStart&&e.index<=this._virtualEnd}),this);this._isClientFull()&&!i||this._debounce("_render",this._render,o)}else"items.length"!==e.path&&this._forwardItemPath(e.path,e.value)},_forwardItemPath:function(e,t){var i,s,o,n=(e=e.slice(6)).indexOf(".");-1===n&&(n=e.length);var r=this.modelForElement(this._offscreenFocusedItem),a=parseInt(e.substring(0,n),10);(i=this._isIndexRendered(a))?(s=this._getPhysicalIndex(a),o=this.modelForElement(this._physicalItems[s])):r&&(o=r),o&&o[this.indexAs]===a&&(e=e.substring(n+1),e=this.as+(e?"."+e:""),o._setPendingPropertyOrPath(e,t,!1,!0),o._flushProperties&&o._flushProperties(),i&&(this._updateMetrics([s]),this._positionItems(),this._updateScrollerSize()))},_adjustVirtualIndex:function(e){e.forEach((function(e){if(e.removed.forEach(this._removeItem,this),e.index<this._virtualStart){var t=Math.max(e.addedCount-e.removed.length,e.index-this._virtualStart);this._virtualStart=this._virtualStart+t,this._focusedVirtualIndex>=0&&(this._focusedVirtualIndex=this._focusedVirtualIndex+t)}}),this)},_removeItem:function(e){this.$.selector.deselect(e),this._focusedItem&&this.modelForElement(this._focusedItem)[this.as]===e&&this._removeFocusedItem()},_iterateItems:function(e,t){var i,s,o,n;if(2===arguments.length&&t){for(n=0;n<t.length;n++)if(i=t[n],s=this._computeVidx(i),null!=(o=e.call(this,i,s)))return o}else{for(i=this._physicalStart,s=this._virtualStart;i<this._physicalCount;i++,s++)if(null!=(o=e.call(this,i,s)))return o;for(i=0;i<this._physicalStart;i++,s++)if(null!=(o=e.call(this,i,s)))return o}},_computeVidx:function(e){return e>=this._physicalStart?this._virtualStart+(e-this._physicalStart):this._virtualStart+(this._physicalCount-this._physicalStart)+e},_assignModels:function(e){this._iterateItems((function(e,t){var i=this._physicalItems[e],s=this.items&&this.items[t];if(null!=s){var o=this.modelForElement(i);o.__key__=null,this._forwardProperty(o,this.as,s),this._forwardProperty(o,this.selectedAs,this.$.selector.isSelected(s)),this._forwardProperty(o,this.indexAs,t),this._forwardProperty(o,"tabIndex",this._focusedVirtualIndex===t?0:-1),this._physicalIndexForKey[o.__key__]=e,o._flushProperties&&o._flushProperties(!0),i.removeAttribute("hidden")}else i.setAttribute("hidden","")}),e)},_updateMetrics:function(e){I();var t=0,i=0,s=this._physicalAverageCount,o=this._physicalAverage;this._iterateItems((function(e,s){i+=this._physicalSizes[e],this._physicalSizes[e]=this._physicalItems[e].offsetHeight,t+=this._physicalSizes[e],this._physicalAverageCount+=this._physicalSizes[e]?1:0}),e),this.grid?(this._updateGridMetrics(),this._physicalSize=Math.ceil(this._physicalCount/this._itemsPerRow)*this._rowHeight):(i=1===this._itemsPerRow?i:Math.ceil(this._physicalCount/this._itemsPerRow)*this._rowHeight,this._physicalSize=this._physicalSize+t-i,this._itemsPerRow=1),this._physicalAverageCount!==s&&(this._physicalAverage=Math.round((o*s+t)/this._physicalAverageCount))},_updateGridMetrics:function(){this._itemWidth=this._physicalCount>0?this._physicalItems[0].getBoundingClientRect().width:200,this._rowHeight=this._physicalCount>0?this._physicalItems[0].offsetHeight:200,this._itemsPerRow=this._itemWidth?Math.floor(this._viewportWidth/this._itemWidth):this._itemsPerRow},_positionItems:function(){this._adjustScrollPosition();var e=this._physicalTop;if(this.grid){var t=this._itemsPerRow*this._itemWidth,i=(this._viewportWidth-t)/2;this._iterateItems((function(t,s){var o=s%this._itemsPerRow,n=Math.floor(o*this._itemWidth+i);this._isRTL&&(n*=-1),this.translate3d(n+"px",e+"px",0,this._physicalItems[t]),this._shouldRenderNextRow(s)&&(e+=this._rowHeight)}))}else{const t=[];this._iterateItems((function(i,s){const o=this._physicalItems[i];this.translate3d(0,e+"px",0,o),e+=this._physicalSizes[i];const n=o.id;n&&t.push(n)})),t.length&&this.setAttribute("aria-owns",t.join(" "))}},_getPhysicalSizeIncrement:function(e){return this.grid?this._computeVidx(e)%this._itemsPerRow!=this._itemsPerRow-1?0:this._rowHeight:this._physicalSizes[e]},_shouldRenderNextRow:function(e){return e%this._itemsPerRow==this._itemsPerRow-1},_adjustScrollPosition:function(){var e=0===this._virtualStart?this._physicalTop:Math.min(this._scrollPosition+this._physicalTop,0);if(0!==e){this._physicalTop=this._physicalTop-e;var t=this._scrollPosition;!oe&&t>0&&this._resetScrollPosition(t-e)}},_resetScrollPosition:function(e){this.scrollTarget&&e>=0&&(this._scrollTop=e,this._scrollPosition=this._scrollTop)},_updateScrollerSize:function(e){this.grid?this._estScrollHeight=this._virtualRowCount*this._rowHeight:this._estScrollHeight=this._physicalBottom+Math.max(this._virtualCount-this._physicalCount-this._virtualStart,0)*this._physicalAverage,((e=(e=(e=e||0===this._scrollHeight)||this._scrollPosition>=this._estScrollHeight-this._physicalSize)||this.grid&&this.$.items.style.height<this._estScrollHeight)||Math.abs(this._estScrollHeight-this._scrollHeight)>=this._viewportHeight)&&(this.$.items.style.height=this._estScrollHeight+"px",this._scrollHeight=this._estScrollHeight)},scrollToItem:function(e){return this.scrollToIndex(this.items.indexOf(e))},scrollToIndex:function(e){if(!("number"!=typeof e||e<0||e>this.items.length-1)&&(I(),0!==this._physicalCount)){e=this._clamp(e,0,this._virtualCount-1),(!this._isIndexRendered(e)||e>=this._maxVirtualStart)&&(this._virtualStart=this.grid?e-2*this._itemsPerRow:e-1),this._manageFocus(),this._assignModels(),this._updateMetrics(),this._physicalTop=Math.floor(this._virtualStart/this._itemsPerRow)*this._physicalAverage;for(var t=this._physicalStart,i=this._virtualStart,s=0,o=this._hiddenContentSize;i<e&&s<=o;)s+=this._getPhysicalSizeIncrement(t),t=(t+1)%this._physicalCount,i++;this._updateScrollerSize(!0),this._positionItems(),this._resetScrollPosition(this._physicalTop+this._scrollOffset+s),this._increasePoolIfNeeded(0),this._firstVisibleIndexVal=null,this._lastVisibleIndexVal=null}},_resetAverage:function(){this._physicalAverage=0,this._physicalAverageCount=0},_resizeHandler:function(){this._debounce("_render",(function(){this._firstVisibleIndexVal=null,this._lastVisibleIndexVal=null,this._isVisible?(this.updateViewportBoundaries(),this.toggleScrollListener(!0),this._resetAverage(),this._render()):this.toggleScrollListener(!1)}),o)},selectItem:function(e){return this.selectIndex(this.items.indexOf(e))},selectIndex:function(e){if(!(e<0||e>=this._virtualCount)){if(!this.multiSelection&&this.selectedItem&&this.clearSelection(),this._isIndexRendered(e)){var t=this.modelForElement(this._physicalItems[this._getPhysicalIndex(e)]);t&&(t[this.selectedAs]=!0),this.updateSizeForIndex(e)}this.$.selector.selectIndex(e)}},deselectItem:function(e){return this.deselectIndex(this.items.indexOf(e))},deselectIndex:function(e){if(!(e<0||e>=this._virtualCount)){if(this._isIndexRendered(e))this.modelForElement(this._physicalItems[this._getPhysicalIndex(e)])[this.selectedAs]=!1,this.updateSizeForIndex(e);this.$.selector.deselectIndex(e)}},toggleSelectionForItem:function(e){return this.toggleSelectionForIndex(this.items.indexOf(e))},toggleSelectionForIndex:function(e){(this.$.selector.isIndexSelected?this.$.selector.isIndexSelected(e):this.$.selector.isSelected(this.items[e]))?this.deselectIndex(e):this.selectIndex(e)},clearSelection:function(){this._iterateItems((function(e,t){this.modelForElement(this._physicalItems[e])[this.selectedAs]=!1})),this.$.selector.clearSelection()},_selectionEnabledChanged:function(e){(e?this.listen:this.unlisten).call(this,this,"tap","_selectionHandler")},_selectionHandler:function(e){var t=this.modelForElement(e.target);if(t){var i,s,o=x(e).path[0],n=this._getActiveElement(),r=this._physicalItems[this._getPhysicalIndex(t[this.indexAs])];"input"!==o.localName&&"button"!==o.localName&&"select"!==o.localName&&(i=t.tabIndex,t.tabIndex=re,s=n?n.tabIndex:-1,t.tabIndex=i,n&&r!==n&&r.contains(n)&&s!==re||this.toggleSelectionForItem(t[this.as]))}},_multiSelectionChanged:function(e){this.clearSelection(),this.$.selector.multi=e},updateSizeForItem:function(e){return this.updateSizeForIndex(this.items.indexOf(e))},updateSizeForIndex:function(e){return this._isIndexRendered(e)?(this._updateMetrics([this._getPhysicalIndex(e)]),this._positionItems(),null):null},_manageFocus:function(){var e=this._focusedVirtualIndex;e>=0&&e<this._virtualCount?this._isIndexRendered(e)?this._restoreFocusedItem():this._createFocusBackfillItem():this._virtualCount>0&&this._physicalCount>0&&(this._focusedPhysicalIndex=this._physicalStart,this._focusedVirtualIndex=this._virtualStart,this._focusedItem=this._physicalItems[this._physicalStart])},_convertIndexToCompleteRow:function(e){return this._itemsPerRow=this._itemsPerRow||1,this.grid?Math.ceil(e/this._itemsPerRow)*this._itemsPerRow:e},_isIndexRendered:function(e){return e>=this._virtualStart&&e<=this._virtualEnd},_isIndexVisible:function(e){return e>=this.firstVisibleIndex&&e<=this.lastVisibleIndex},_getPhysicalIndex:function(e){return(this._physicalStart+(e-this._virtualStart))%this._physicalCount},focusItem:function(e){this._focusPhysicalItem(e)},_focusPhysicalItem:function(e){if(!(e<0||e>=this._virtualCount)){this._restoreFocusedItem(),this._isIndexRendered(e)||this.scrollToIndex(e);var t,i=this._physicalItems[this._getPhysicalIndex(e)],s=this.modelForElement(i);s.tabIndex=re,i.tabIndex===re&&(t=i),t||(t=x(i).querySelector('[tabindex="-100"]')),s.tabIndex=0,this._focusedVirtualIndex=e,t&&t.focus()}},_removeFocusedItem:function(){this._offscreenFocusedItem&&this._itemsParent.removeChild(this._offscreenFocusedItem),this._offscreenFocusedItem=null,this._focusBackfillItem=null,this._focusedItem=null,this._focusedVirtualIndex=-1,this._focusedPhysicalIndex=-1},_createFocusBackfillItem:function(){var e=this._focusedPhysicalIndex;if(!(this._offscreenFocusedItem||this._focusedVirtualIndex<0)){if(!this._focusBackfillItem){var t=this.stamp(null);this._focusBackfillItem=t.root.querySelector("*"),this._itemsParent.appendChild(t.root)}this._offscreenFocusedItem=this._physicalItems[e],this.modelForElement(this._offscreenFocusedItem).tabIndex=0,this._physicalItems[e]=this._focusBackfillItem,this._focusedPhysicalIndex=e,this.translate3d(0,ne,0,this._offscreenFocusedItem)}},_restoreFocusedItem:function(){if(this._offscreenFocusedItem&&!(this._focusedVirtualIndex<0)){this._assignModels();var e=this._focusedPhysicalIndex=this._getPhysicalIndex(this._focusedVirtualIndex),t=this._physicalItems[e];if(t){var i=this.modelForElement(t),s=this.modelForElement(this._offscreenFocusedItem);i[this.as]===s[this.as]?(this._focusBackfillItem=t,i.tabIndex=-1,this._physicalItems[e]=this._offscreenFocusedItem,this.translate3d(0,ne,0,this._focusBackfillItem)):(this._removeFocusedItem(),this._focusBackfillItem=null),this._offscreenFocusedItem=null}}},_didFocus:function(e){var t=this.modelForElement(e.target),i=this.modelForElement(this._focusedItem),s=null!==this._offscreenFocusedItem,o=this._focusedVirtualIndex;t&&(i===t?this._isIndexVisible(o)||this.scrollToIndex(o):(this._restoreFocusedItem(),i&&(i.tabIndex=-1),t.tabIndex=0,o=t[this.indexAs],this._focusedVirtualIndex=o,this._focusedPhysicalIndex=this._getPhysicalIndex(o),this._focusedItem=this._physicalItems[this._focusedPhysicalIndex],s&&!this._offscreenFocusedItem&&this._update()))},_keydownHandler:function(e){switch(e.keyCode){case 40:this._focusedVirtualIndex<this._virtualCount-1&&e.preventDefault(),this._focusPhysicalItem(this._focusedVirtualIndex+(this.grid?this._itemsPerRow:1));break;case 39:this.grid&&this._focusPhysicalItem(this._focusedVirtualIndex+(this._isRTL?-1:1));break;case 38:this._focusedVirtualIndex>0&&e.preventDefault(),this._focusPhysicalItem(this._focusedVirtualIndex-(this.grid?this._itemsPerRow:1));break;case 37:this.grid&&this._focusPhysicalItem(this._focusedVirtualIndex+(this._isRTL?1:-1));break;case 13:this._focusPhysicalItem(this._focusedVirtualIndex),this.selectionEnabled&&this._selectionHandler(e)}},_clamp:function(e,t,i){return Math.min(i,Math.max(t,e))},_debounce:function(e,t,s){this._debouncers=this._debouncers||{},this._debouncers[e]=i.debounce(this._debouncers[e],s,t.bind(this)),a(this._debouncers[e])},_forwardProperty:function(e,t,i){e._setPendingProperty(t,i)},_forwardHostPropV2:function(e,t){(this._physicalItems||[]).concat([this._offscreenFocusedItem,this._focusBackfillItem]).forEach((function(i){i&&this.modelForElement(i).forwardHostProp(e,t)}),this)},_notifyInstancePropV2:function(e,t,i){if(l(this.as,t)){var s=e[this.indexAs];t==this.as&&(this.items[s]=i),this.notifyPath(h(this.as,"items."+s,t),i)}},_getStampedChildren:function(){return this._physicalItems},_forwardInstancePath:function(e,t,i){0===t.indexOf(this.as+".")&&this.notifyPath("items."+e.__key__+"."+t.slice(this.as.length+1),i)},_forwardParentPath:function(e,t){(this._physicalItems||[]).concat([this._offscreenFocusedItem,this._focusBackfillItem]).forEach((function(i){i&&this.modelForElement(i).notifyPath(e,t)}),this)},_forwardParentProp:function(e,t){(this._physicalItems||[]).concat([this._offscreenFocusedItem,this._focusBackfillItem]).forEach((function(i){i&&(this.modelForElement(i)[e]=t)}),this)},_getActiveElement:function(){var e=this._itemsParent.node.domHost;return x(e?e.root:document).activeElement}});
|
|
422
|
+
/**
|
|
423
|
+
@license
|
|
424
|
+
Copyright (c) 2017 Vaadin Ltd.
|
|
425
|
+
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
426
|
+
*/
|
|
427
|
+
class ae extends(d(c(t))){static get template(){return e`
|
|
428
|
+
<style>
|
|
429
|
+
:host {
|
|
430
|
+
display: block;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
:host([hidden]) {
|
|
434
|
+
display: none;
|
|
435
|
+
}
|
|
436
|
+
</style>
|
|
437
|
+
<div part="content" id="content"></div>
|
|
438
|
+
`}static get is(){return"vaadin-combo-box-item"}static get properties(){return{index:Number,item:Object,label:String,selected:{type:Boolean,value:!1,reflectToAttribute:!0},focused:{type:Boolean,value:!1,reflectToAttribute:!0},_itemTemplateInstance:Object,renderer:Function,_oldRenderer:Function}}static get observers(){return["_rendererOrItemChanged(renderer, index, item.*)","_updateLabel(label, _itemTemplateInstance)",'_updateTemplateInstanceVariable("index", index, _itemTemplateInstance)','_updateTemplateInstanceVariable("item", item, _itemTemplateInstance)','_updateTemplateInstanceVariable("selected", selected, _itemTemplateInstance)','_updateTemplateInstanceVariable("focused", focused, _itemTemplateInstance)']}connectedCallback(){if(super.connectedCallback(),!this._itemTemplateInstance){const e=this.getRootNode().host.getRootNode().host.__dataHost.getRootNode().host;this._comboBox=e.getRootNode().host,this._comboBox._ensureTemplatized(),this._comboBox._TemplateClass&&(this._itemTemplateInstance=new this._comboBox._TemplateClass({}),this.$.content.textContent="",this.$.content.appendChild(this._itemTemplateInstance.root))}const e=this._comboBox.getAttribute("dir");e&&this.setAttribute("dir",e)}_render(){if(!this.renderer)return;const e={index:this.index,item:this.item};this.renderer(this.$.content,this._comboBox,e)}_rendererOrItemChanged(e,t,i){void 0!==i&&void 0!==t&&(this._oldRenderer!==e&&(this.$.content.innerHTML=""),e&&(this._oldRenderer=e,this._render()))}_updateLabel(e,t){void 0===t&&this.$.content&&!this.renderer&&(this.$.content.textContent=e)}_updateTemplateInstanceVariable(e,t,i){void 0!==e&&void 0!==t&&void 0!==i&&(i[e]=t)}}customElements.define(ae.is,ae);
|
|
439
|
+
/**
|
|
440
|
+
@license
|
|
441
|
+
Copyright (c) 2017 Vaadin Ltd.
|
|
442
|
+
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
443
|
+
*/
|
|
444
|
+
const le=document.createElement("template");let he;le.innerHTML='<dom-module id="vaadin-combo-box-overlay-styles" theme-for="vaadin-combo-box-overlay">\n <template>\n <style>\n :host {\n width: var(--vaadin-combo-box-overlay-width, var(--_vaadin-combo-box-overlay-default-width, auto));\n }\n </style>\n </template>\n</dom-module>',document.head.appendChild(le.content);class de extends R{static get is(){return"vaadin-combo-box-overlay"}static get properties(){return{positionTarget:{type:Object}}}static get template(){return he||(he=super.template.cloneNode(!0),he.content.querySelector('[part~="overlay"]').removeAttribute("tabindex")),he}connectedCallback(){super.connectedCallback();const e=this.__dataHost.getRootNode().host,t=e&&e.getRootNode().host,i=t&&t.getAttribute("dir");i&&this.setAttribute("dir",i)}ready(){super.ready();const e=document.createElement("div");e.setAttribute("part","loader");const t=this.shadowRoot.querySelector('[part~="content"]');t.parentNode.insertBefore(e,t)}_outsideClickListener(e){const t=e.composedPath();t.indexOf(this.positionTarget)<0&&t.indexOf(this)<0&&this.close()}}customElements.define(de.is,de);class ce extends(S(C(p,t))){static get template(){return e`
|
|
445
|
+
<style>
|
|
446
|
+
:host {
|
|
447
|
+
display: block;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
:host > #overlay {
|
|
451
|
+
display: none;
|
|
452
|
+
}
|
|
453
|
+
</style>
|
|
454
|
+
<vaadin-combo-box-overlay id="overlay" hidden\$="[[hidden]]" position-target="[[positionTarget]]" opened="{{opened}}" template="{{template}}" style="align-items: stretch; margin: 0;" theme\$="[[theme]]">
|
|
455
|
+
<slot></slot>
|
|
456
|
+
</vaadin-combo-box-overlay>
|
|
457
|
+
`}static get is(){return"vaadin-combo-box-dropdown"}static get properties(){return{opened:{type:Boolean,observer:"_openedChanged"},template:{type:Object,notify:!0},positionTarget:{type:Object},alignedAbove:{type:Boolean,value:!1},theme:String}}constructor(){super(),this._boundSetPosition=this._setPosition.bind(this)}connectedCallback(){super.connectedCallback(),this.addEventListener("iron-resize",this._boundSetPosition)}ready(){super.ready(),this.$.overlay.addEventListener("vaadin-overlay-outside-click",(e=>{e.preventDefault()}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("iron-resize",this._boundSetPosition),this.opened=!1}notifyResize(){super.notifyResize(),this.positionTarget&&this.opened&&(this._setPosition(),requestAnimationFrame(this._setPosition.bind(this)))}_openedChanged(e,t){!!e!=!!t&&(e?(this.$.overlay.style.position=this._isPositionFixed(this.positionTarget)?"fixed":"absolute",this._setPosition(),window.addEventListener("scroll",this._boundSetPosition,!0),this.dispatchEvent(new CustomEvent("vaadin-combo-box-dropdown-opened",{bubbles:!0,composed:!0}))):this.__emptyItems||(window.removeEventListener("scroll",this._boundSetPosition,!0),this.dispatchEvent(new CustomEvent("vaadin-combo-box-dropdown-closed",{bubbles:!0,composed:!0}))))}_isPositionFixed(e){const t=this._getOffsetParent(e);return"fixed"===window.getComputedStyle(e).position||t&&this._isPositionFixed(t)}_getOffsetParent(e){if(e.assignedSlot)return e.assignedSlot.parentElement;if(e.parentElement)return e.offsetParent;const t=e.parentNode;return t&&11===t.nodeType&&t.host?t.host:void 0}_verticalOffset(e,t){return this.alignedAbove?-e.height:t.height}_shouldAlignAbove(e){return(window.innerHeight-e.bottom-Math.min(document.body.scrollTop,0))/window.innerHeight<.3}_getCustomWidth(){return window.ShadyCSS?window.ShadyCSS.getComputedStyleValue(this,"--vaadin-combo-box-overlay-width"):getComputedStyle(this).getPropertyValue("--vaadin-combo-box-overlay-width")}_setOverlayWidth(){const e=this.positionTarget.clientWidth+"px",t=this._getCustomWidth();window.ShadyCSS&&!window.ShadyCSS.nativeCss?window.ShadyCSS.styleSubtree(this.$.overlay,{"--vaadin-combo-box-overlay-width":t,"--_vaadin-combo-box-overlay-default-width":e}):(this.$.overlay.style.setProperty("--_vaadin-combo-box-overlay-default-width",e),""===t?this.$.overlay.style.removeProperty("--vaadin-combo-box-overlay-width"):this.$.overlay.style.setProperty("--vaadin-combo-box-overlay-width",t))}_setPosition(e){if(this.hidden)return;if(e&&e.target){const t=e.target===document?document.body:e.target,i=this.$.overlay.parentElement;if(!t.contains(this.$.overlay)&&!t.contains(this.positionTarget)||i!==document.body)return}const t=this.positionTarget.getBoundingClientRect();this.alignedAbove=this._shouldAlignAbove(t);const i=this.$.overlay.getBoundingClientRect();this._translateX=t.left-i.left+(this._translateX||0),this._translateY=t.top-i.top+(this._translateY||0)+this._verticalOffset(i,t);const s=window.devicePixelRatio||1;this._translateX=Math.round(this._translateX*s)/s,this._translateY=Math.round(this._translateY*s)/s,this.$.overlay.style.transform=`translate3d(${this._translateX}px, ${this._translateY}px, 0)`,this.$.overlay.style.justifyContent=this.alignedAbove?"flex-end":"flex-start",this._setOverlayWidth(),this.dispatchEvent(new CustomEvent("position-changed"))}}customElements.define(ce.is,ce);
|
|
458
|
+
/**
|
|
459
|
+
@license
|
|
460
|
+
Copyright (c) 2017 Vaadin Ltd.
|
|
461
|
+
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
462
|
+
*/
|
|
463
|
+
const ue=(()=>{try{return document.createEvent("TouchEvent"),!0}catch(e){return!1}})();class _e extends class extends t{}{static get template(){return e`
|
|
464
|
+
<vaadin-combo-box-dropdown id="dropdown" hidden="[[_hidden(_items.*, loading)]]" position-target="[[positionTarget]]" on-template-changed="_templateChanged" on-position-changed="_setOverlayHeight" disable-upgrade="" theme="[[theme]]">
|
|
465
|
+
<template>
|
|
466
|
+
<style>
|
|
467
|
+
#scroller {
|
|
468
|
+
overflow: auto;
|
|
469
|
+
|
|
470
|
+
/* Fixes item background from getting on top of scrollbars on Safari */
|
|
471
|
+
transform: translate3d(0, 0, 0);
|
|
472
|
+
|
|
473
|
+
/* Enable momentum scrolling on iOS (iron-list v1.2+ no longer does it for us) */
|
|
474
|
+
-webkit-overflow-scrolling: touch;
|
|
475
|
+
|
|
476
|
+
/* Fixes scrollbar disappearing when 'Show scroll bars: Always' enabled in Safari */
|
|
477
|
+
box-shadow: 0 0 0 white;
|
|
478
|
+
}
|
|
479
|
+
</style>
|
|
480
|
+
<div id="scroller" on-click="_stopPropagation">
|
|
481
|
+
<iron-list id="selector" role="listbox" items="[[_getItems(opened, _items)]]" scroll-target="[[_scroller]]">
|
|
482
|
+
<template>
|
|
483
|
+
<vaadin-combo-box-item on-click="_onItemClick" index="[[__requestItemByIndex(item, index, _resetScrolling)]]" item="[[item]]" label="[[getItemLabel(item, _itemLabelPath)]]" selected="[[_isItemSelected(item, _selectedItem, _itemIdPath)]]" renderer="[[renderer]]" role\$="[[_getAriaRole(index)]]" aria-selected\$="[[_getAriaSelected(_focusedIndex,index)]]" focused="[[_isItemFocused(_focusedIndex,index)]]" tabindex="-1" theme\$="[[theme]]">
|
|
484
|
+
</vaadin-combo-box-item>
|
|
485
|
+
</template>
|
|
486
|
+
</iron-list>
|
|
487
|
+
</div>
|
|
488
|
+
</template>
|
|
489
|
+
</vaadin-combo-box-dropdown>
|
|
490
|
+
`}static get is(){return"vaadin-combo-box-dropdown-wrapper"}static get properties(){return{touchDevice:{type:Boolean,value:ue},opened:Boolean,positionTarget:{type:Object},renderer:Function,loading:{type:Boolean,value:!1,reflectToAttribute:!0,observer:"_setOverlayHeight"},theme:String,filterChanged:{type:Boolean,value:!1},_resetScrolling:{type:Boolean,value:!1},_selectedItem:{type:Object},_items:{type:Object},_focusedIndex:{type:Number,value:-1,observer:"_focusedIndexChanged"},_focusedItem:{type:String,computed:"_getFocusedItem(_focusedIndex)"},_itemLabelPath:{type:String,value:"label"},_itemValuePath:{type:String,value:"value"},_selector:Object,_itemIdPath:String,_oldScrollerPosition:{type:Number,value:0}}}static get observers(){return["_selectorChanged(_selector)","_loadingChanged(loading)","_openedChanged(opened, _items, loading)","_restoreScrollerPosition(_items)"]}_fireTouchAction(e){this.dispatchEvent(new CustomEvent("vaadin-overlay-touch-action",{detail:{sourceEvent:e}}))}_getItems(e,t){if(e){if(this._isNotEmpty(t)&&this._selector&&!this.filterChanged){const e=this._selector.firstVisibleIndex;0!==e&&(this._oldScrollerPosition=e,this._resetScrolling=!0)}return this.filterChanged=!1,t}return[]}_restoreScrollerPosition(e){this._isNotEmpty(e)&&this._selector&&0!==this._oldScrollerPosition&&(this._scrollIntoView(Math.min(e.length-1,this._oldScrollerPosition)),this._resetScrolling=!1,this._oldScrollerPosition=0)}_isNotEmpty(e){return!this._isEmpty(e)}_isEmpty(e){return!e||!e.length}_openedChanged(e,t,i){if(this.$.dropdown.hasAttribute("disable-upgrade")){if(!e)return;this._initDropdown()}this._isEmpty(t)&&(this.$.dropdown.__emptyItems=!0),this.$.dropdown.opened=!(!e||!i&&!this._isNotEmpty(t)),this.$.dropdown.__emptyItems=!1}_initDropdown(){this.$.dropdown.removeAttribute("disable-upgrade"),this._templateChanged(),this._loadingChanged(this.loading),this.$.dropdown.$.overlay.addEventListener("touchend",(e=>this._fireTouchAction(e))),this.$.dropdown.$.overlay.addEventListener("touchmove",(e=>this._fireTouchAction(e))),this.$.dropdown.$.overlay.addEventListener("mousedown",(e=>e.preventDefault())),/Trident/.test(navigator.userAgent)&&this._scroller.setAttribute("unselectable","on")}_templateChanged(e){this.$.dropdown.hasAttribute("disable-upgrade")||(this._selector=this.$.dropdown.$.overlay.content.querySelector("#selector"),this._scroller=this.$.dropdown.$.overlay.content.querySelector("#scroller"))}_loadingChanged(e){this.$.dropdown.hasAttribute("disable-upgrade")||(e?this.$.dropdown.$.overlay.setAttribute("loading",""):this.$.dropdown.$.overlay.removeAttribute("loading"))}_selectorChanged(e){this._patchWheelOverScrolling()}_setOverlayHeight(){if(!this.opened||!this.positionTarget||!this._selector)return;const e=this.positionTarget.getBoundingClientRect();this._scroller.style.maxHeight=(window.ShadyCSS?window.ShadyCSS.getComputedStyleValue(this,"--vaadin-combo-box-overlay-max-height"):getComputedStyle(this).getPropertyValue("--vaadin-combo-box-overlay-max-height"))||"65vh";const t=this._maxOverlayHeight(e);this.$.dropdown.$.overlay.style.maxHeight=t,this._selector.style.maxHeight=t,this.updateViewportBoundaries()}_maxOverlayHeight(e){return this.$.dropdown.alignedAbove?Math.max(e.top-8+Math.min(document.body.scrollTop,0),116)+"px":Math.max(document.documentElement.clientHeight-e.bottom-8,116)+"px"}_getFocusedItem(e){if(e>=0)return this._items[e]}_isItemSelected(e,t,i){return!(e instanceof ee)&&(i&&void 0!==e&&void 0!==t?this.get(i,e)===this.get(i,t):e===t)}_onItemClick(e){e.detail&&e.detail.sourceEvent&&e.detail.sourceEvent.stopPropagation&&this._stopPropagation(e.detail.sourceEvent),this.dispatchEvent(new CustomEvent("selection-changed",{detail:{item:e.model.item}}))}indexOfLabel(e){if(this._items&&e)for(let t=0;t<this._items.length;t++)if(this.getItemLabel(this._items[t]).toString().toLowerCase()===e.toString().toLowerCase())return t;return-1}__requestItemByIndex(e,t,i){return e instanceof ee&&void 0!==t&&!i&&this.dispatchEvent(new CustomEvent("index-requested",{detail:{index:t,currentScrollerPos:this._oldScrollerPosition}})),t}getItemLabel(e,t){t=t||this._itemLabelPath;let i=e&&t?this.get(t,e):void 0;return null==i&&(i=e?e.toString():""),i}_isItemFocused(e,t){return e==t}_getAriaSelected(e,t){return this._isItemFocused(e,t).toString()}_getAriaRole(e){return void 0!==e&&"option"}_focusedIndexChanged(e){e>=0&&this._scrollIntoView(e)}_scrollIntoView(e){if(!(this.opened&&e>=0))return;const t=this._visibleItemsCount();if(void 0===t)return;let i=e;e>this._selector.lastVisibleIndex-1?(this._selector.scrollToIndex(e),i=e-t+1):e>this._selector.firstVisibleIndex&&(i=this._selector.firstVisibleIndex),this._selector.scrollToIndex(Math.max(0,i));const s=this._selector._getPhysicalIndex(e),o=this._selector._physicalItems[s];if(!o)return;const n=o.getBoundingClientRect(),r=this._scroller.getBoundingClientRect(),a=n.bottom-r.bottom+this._viewportTotalPaddingBottom;a>0&&(this._scroller.scrollTop+=a)}ensureItemsRendered(){this._selector._render()}adjustScrollPosition(){this.opened&&this._items&&this._scrollIntoView(this._focusedIndex)}_patchWheelOverScrolling(){const e=this._selector;e.addEventListener("wheel",(t=>{const i=e._scroller||e.scrollTarget,s=0===i.scrollTop,o=i.scrollHeight-i.scrollTop-i.clientHeight<=1;(s&&t.deltaY<0||o&&t.deltaY>0)&&t.preventDefault()}))}updateViewportBoundaries(){this._cachedViewportTotalPaddingBottom=void 0,this._selector.updateViewportBoundaries()}get _viewportTotalPaddingBottom(){if(void 0===this._cachedViewportTotalPaddingBottom){const e=window.getComputedStyle(this._selector.$.items);this._cachedViewportTotalPaddingBottom=[e.paddingBottom,e.borderBottomWidth].map((e=>parseInt(e,10))).reduce(((e,t)=>e+t))}return this._cachedViewportTotalPaddingBottom}_visibleItemsCount(){if(this._selector)return this._selector.flushDebouncer("_debounceTemplate"),this._selector.scrollToIndex(this._selector.firstVisibleIndex),this.updateViewportBoundaries(),this._selector.lastVisibleIndex-this._selector.firstVisibleIndex+1}_selectItem(e){e="number"==typeof e?this._items[e]:e,this._selector.selectedItem!==e&&this._selector.selectItem(e)}_preventDefault(e){e.cancelable&&e.preventDefault()}_stopPropagation(e){e.stopPropagation()}_hidden(e){return!this.loading&&this._isEmpty(this._items)}}customElements.define(_e.is,_e);
|
|
491
|
+
/**
|
|
492
|
+
@license
|
|
493
|
+
Copyright (c) 2018 Vaadin Ltd.
|
|
494
|
+
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
495
|
+
*/
|
|
496
|
+
const me=e=>class extends e{static get properties(){return{pageSize:{type:Number,value:50,observer:"_pageSizeChanged"},size:{type:Number,observer:"_sizeChanged"},dataProvider:{type:Object,observer:"_dataProviderChanged"},_pendingRequests:{value:()=>({})},__placeHolder:{value:new ee}}}static get observers(){return["_dataProviderFilterChanged(filter, dataProvider)","_dataProviderClearFilter(dataProvider, opened, value)","_warnDataProviderValue(dataProvider, value)","_ensureFirstPage(opened)"]}_dataProviderClearFilter(e,t,i){e&&!this.loading&&this.filter&&(this.size=void 0,this._pendingRequests={},this.filter="",this.clearCache())}ready(){super.ready(),this.clearCache(),this.$.overlay.addEventListener("index-requested",(e=>{const t=e.detail.index,i=e.detail.currentScrollerPos,s=Math.floor(1.5*this.pageSize);if(!this._shouldSkipIndex(t,s,i)&&void 0!==t){const e=this._getPageForIndex(t);this._shouldLoadPage(e)&&this._loadPage(e)}}))}_dataProviderFilterChanged(){this._shouldFetchData()&&(this.size=void 0,this._pendingRequests={},this.clearCache())}_shouldFetchData(){return!!this.dataProvider&&(this.opened||this.filter&&this.filter.length)}_ensureFirstPage(e){e&&this._shouldLoadPage(0)&&this._loadPage(0)}_shouldSkipIndex(e,t,i){return 0!==i&&e>=i-t&&e<=i+t}_shouldLoadPage(e){if(!this.filteredItems||this._forceNextRequest)return this._forceNextRequest=!1,!0;const t=this.filteredItems[e*this.pageSize];return void 0!==t?t instanceof ee:void 0===this.size}_loadPage(e){if(!this._pendingRequests[e]&&this.dataProvider){this.loading=!0;const t={page:e,pageSize:this.pageSize,filter:this.filter},i=(s,o)=>{if(this._pendingRequests[e]===i){if(this.filteredItems)this.splice("filteredItems",t.page*t.pageSize,s.length,...s);else{const e=[];e.splice(t.page*t.pageSize,s.length,...s),this.filteredItems=e}this._isValidValue(this.value)&&this._getItemValue(this.selectedItem)!==this.value&&this._selectItemForValue(this.value),this.opened||this.hasAttribute("focused")||this._commitValue(),this.size=o,delete this._pendingRequests[e],0===Object.keys(this._pendingRequests).length&&(this.loading=!1),0===e&&this.__repositionOverlayDebouncer&&s.length>(this.__maxRenderedItems||0)&&(setTimeout((()=>this.__repositionOverlayDebouncer.flush())),this.__maxRenderedItems=s.length)}};this._pendingRequests[e]||(this._pendingRequests[e]=i,this.dataProvider(t,i))}}_getPageForIndex(e){return Math.floor(e/this.pageSize)}clearCache(){if(!this.dataProvider)return;this._pendingRequests={};const e=[];for(let t=0;t<(this.size||0);t++)e.push(this.__placeHolder);this.filteredItems=e,this._shouldFetchData()?this._loadPage(0):this._forceNextRequest=!0}_sizeChanged(e=0){const t=(this.filteredItems||[]).slice(0,e);for(let i=0;i<e;i++)t[i]=void 0!==t[i]?t[i]:this.__placeHolder;this.filteredItems=t,this._flushPendingRequests(e)}_pageSizeChanged(e,t){if(Math.floor(e)!==e||e<1)throw this.pageSize=t,new Error("`pageSize` value must be an integer > 0");this.clearCache()}_dataProviderChanged(e,t){this._ensureItemsOrDataProvider((()=>{this.dataProvider=t}))}_ensureItemsOrDataProvider(e){if(void 0!==this.items&&void 0!==this.dataProvider)throw e(),new Error("Using `items` and `dataProvider` together is not supported");this.dataProvider&&!this.filteredItems&&(this.filteredItems=[])}_warnDataProviderValue(e,t){if(e&&""!==t&&(void 0===this.selectedItem||null===this.selectedItem)){const e=this._indexOfValue(t,this.filteredItems);(e<0||!this._getItemLabel(this.filteredItems[e]))&&console.warn("Warning: unable to determine the label for the provided `value`. Nothing to display in the text field. This usually happens when setting an initial `value` before any items are returned from the `dataProvider` callback. Consider setting `selectedItem` instead of `value`")}}_flushPendingRequests(e){if(this._pendingRequests){const t=Math.ceil(e/this.pageSize),i=Object.keys(this._pendingRequests);for(let s=0;s<i.length;s++){const o=parseInt(i[s]);o>=t&&this._pendingRequests[o]([],e)}}}}
|
|
497
|
+
/**
|
|
498
|
+
@license
|
|
499
|
+
Copyright (c) 2017 Vaadin Ltd.
|
|
500
|
+
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
501
|
+
*/;class pe extends(u(v(d(me(te(t)))))){static get template(){return e`
|
|
502
|
+
<style>
|
|
503
|
+
:host {
|
|
504
|
+
display: inline-block;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
:host([hidden]) {
|
|
508
|
+
display: none !important;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
:host([opened]) {
|
|
512
|
+
pointer-events: auto;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
[part="text-field"] {
|
|
516
|
+
width: 100%;
|
|
517
|
+
min-width: 0;
|
|
518
|
+
}
|
|
519
|
+
</style>
|
|
520
|
+
|
|
521
|
+
<vaadin-text-field part="text-field" id="input" pattern="[[pattern]]" prevent-invalid-input="[[preventInvalidInput]]" value="[[_inputElementValue]]" autocomplete="off" invalid="[[invalid]]" label="[[label]]" name="[[name]]" placeholder="[[placeholder]]" required="[[required]]" disabled="[[disabled]]" readonly="[[readonly]]" helper-text="[[helperText]]" error-message="[[errorMessage]]" autocapitalize="none" autofocus="[[autofocus]]" on-change="_stopPropagation" on-input="_inputValueChanged" clear-button-visible="[[clearButtonVisible]]" theme\$="[[theme]]">
|
|
522
|
+
<slot name="prefix" slot="prefix"></slot>
|
|
523
|
+
<slot name="helper" slot="helper">[[helperText]]</slot>
|
|
524
|
+
|
|
525
|
+
<div part="toggle-button" id="toggleButton" slot="suffix" role="button" aria-label="Toggle"></div>
|
|
526
|
+
|
|
527
|
+
</vaadin-text-field>
|
|
528
|
+
|
|
529
|
+
<vaadin-combo-box-dropdown-wrapper id="overlay" opened="[[opened]]" renderer="[[renderer]]" position-target="[[_getPositionTarget()]]" _focused-index="[[_focusedIndex]]" _item-id-path="[[itemIdPath]]" _item-label-path="[[itemLabelPath]]" loading="[[loading]]" theme="[[theme]]">
|
|
530
|
+
</vaadin-combo-box-dropdown-wrapper>
|
|
531
|
+
`}constructor(){super(),this.theme}static get is(){return"vaadin-combo-box"}static get version(){return"5.5.3"}static get properties(){return{label:{type:String,reflectToAttribute:!0},required:{type:Boolean,value:!1},disabled:{type:Boolean,value:!1},preventInvalidInput:{type:Boolean},pattern:{type:String},errorMessage:{type:String},autofocus:{type:Boolean},placeholder:{type:String,value:""},helperText:{type:String,value:""},readonly:{type:Boolean,value:!1},clearButtonVisible:{type:Boolean,value:!1}}}static get observers(){return["_updateAriaExpanded(opened)"]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i);/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&this.root&&Array.prototype.forEach.call(this.root.querySelectorAll("*"),(e=>{e.style["-webkit-backface-visibility"]="visible",e.style["-webkit-backface-visibility"]=""}))}ready(){super.ready(),this.inputElement.validate=()=>{},this.inputElement.invalid=this.invalid,this._nativeInput=this.inputElement.focusElement,this._toggleElement=this.$.toggleButton,this._clearElement=this.inputElement.shadowRoot.querySelector('[part="clear-button"]'),this.addEventListener("keydown",(e=>{this._isEventKey(e,"esc")&&this._onEscape(e)}),!0),this._nativeInput.setAttribute("role","combobox"),this._nativeInput.setAttribute("aria-autocomplete","list"),this._updateAriaExpanded()}connectedCallback(){super.connectedCallback(),this._preventInputBlur()}disconnectedCallback(){super.disconnectedCallback(),this._restoreInputBlur()}_getPositionTarget(){return this.$.input}_updateAriaExpanded(){this._nativeInput&&(this._nativeInput.setAttribute("aria-expanded",this.opened),this._toggleElement.setAttribute("aria-expanded",this.opened))}get inputElement(){return this.$.input}get focusElement(){return this.inputElement||this}}customElements.define(pe.is,pe);export{me as C,N as I,R as O,Z as a,te as b};
|