@foxy.io/elements 1.15.0-beta.5 → 1.15.0-beta.8
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 +2 -2
- package/dist/cdn/foxy-address-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-cancellation-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-coupon-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-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.js +1 -1
- package/dist/cdn/foxy-customer-portal.js +2 -2
- package/dist/cdn/foxy-customer.js +1 -1
- package/dist/cdn/foxy-customers-table.js +1 -1
- package/dist/cdn/foxy-discount-card.js +1 -1
- package/dist/cdn/foxy-donation.js +1 -1
- package/dist/cdn/foxy-email-template-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-form.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.js +1 -1
- package/dist/cdn/foxy-items-form.js +1 -1
- package/dist/cdn/foxy-pagination.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-sign-in-form.js +1 -1
- package/dist/cdn/foxy-spinner.js +2 -2
- package/dist/cdn/foxy-subscription-card.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +1 -1
- package/dist/cdn/foxy-subscriptions-table.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-transaction-card.js +1 -1
- package/dist/cdn/foxy-transactions-table.js +1 -1
- package/dist/cdn/foxy-user-form.js +1 -1
- package/dist/cdn/foxy-users-table.js +1 -1
- package/dist/cdn/{shared-f0a83bd6.js → shared-073cb8e9.js} +1 -1
- package/dist/cdn/{shared-94b0ae99.js → shared-0f38a631.js} +2 -2
- package/dist/cdn/shared-11708514.js +1 -0
- package/dist/cdn/{shared-b30bc42d.js → shared-1934524e.js} +3 -3
- package/dist/cdn/{shared-200f613b.js → shared-1a67bc75.js} +2 -2
- package/dist/cdn/{shared-5639389e.js → shared-20b9ce70.js} +1 -1
- package/dist/cdn/{shared-0032dc09.js → shared-223508ae.js} +8 -8
- package/dist/cdn/shared-253e59d2.js +1 -0
- package/dist/cdn/{shared-0ced76a0.js → shared-5a54a9bc.js} +1 -1
- package/dist/cdn/{shared-36629ded.js → shared-65dfd512.js} +3 -3
- package/dist/cdn/shared-805d18a2.js +1 -0
- package/dist/cdn/{shared-df573cea.js → shared-8b20bc23.js} +0 -0
- package/dist/cdn/{shared-bb824ab4.js → shared-a040d79d.js} +2 -2
- package/dist/cdn/shared-a7b6feb2.js +1 -0
- package/dist/cdn/{shared-40b5267a.js → shared-b5754a42.js} +1 -1
- package/dist/cdn/shared-c5de42f7.js +1 -0
- package/dist/cdn/{shared-67ca44d2.js → shared-dcc9c325.js} +1 -1
- package/dist/cdn/{shared-4cc1da27.js → shared-e2c878c7.js} +3 -3
- package/dist/cdn/{shared-16f72e27.js → shared-f4ad24f4.js} +1 -1
- package/dist/cdn/{shared-ec861f31.js → shared-fab8c705.js} +3 -3
- package/dist/cdn/translations/shared/en.json +3 -1
- package/dist/elements/public/CouponCard/CouponCard.js +3 -3
- package/dist/elements/public/CouponCard/CouponCard.js.map +1 -1
- package/dist/elements/public/CouponCodeForm/CouponCodeForm.js +2 -2
- package/dist/elements/public/CouponCodeForm/CouponCodeForm.js.map +1 -1
- package/dist/elements/public/CouponCodesForm/CouponCodesForm.js +6 -3
- package/dist/elements/public/CouponCodesForm/CouponCodesForm.js.map +1 -1
- package/dist/elements/public/CouponCodesForm/types.d.ts +3 -2
- package/dist/elements/public/CouponCodesForm/types.js.map +1 -1
- package/dist/elements/public/CouponForm/CouponForm.js +3 -1
- package/dist/elements/public/CouponForm/CouponForm.js.map +1 -1
- package/dist/elements/public/GenerateCodesForm/GenerateCodesForm.d.ts +4 -0
- package/dist/elements/public/GenerateCodesForm/GenerateCodesForm.js +109 -57
- package/dist/elements/public/GenerateCodesForm/GenerateCodesForm.js.map +1 -1
- package/dist/elements/public/GiftCardCard/GiftCardCard.js +6 -29
- package/dist/elements/public/GiftCardCard/GiftCardCard.js.map +1 -1
- package/dist/elements/public/GiftCardCodeForm/GiftCardCodeForm.js +1 -1
- package/dist/elements/public/GiftCardCodeForm/GiftCardCodeForm.js.map +1 -1
- package/dist/elements/public/GiftCardCodesForm/GiftCardCodesForm.d.ts +6 -0
- package/dist/elements/public/GiftCardCodesForm/GiftCardCodesForm.js +53 -4
- package/dist/elements/public/GiftCardCodesForm/GiftCardCodesForm.js.map +1 -1
- package/dist/elements/public/GiftCardCodesForm/index.d.ts +1 -0
- package/dist/elements/public/GiftCardCodesForm/index.js +1 -0
- package/dist/elements/public/GiftCardCodesForm/index.js.map +1 -1
- package/dist/elements/public/GiftCardCodesForm/types.d.ts +3 -2
- package/dist/elements/public/GiftCardCodesForm/types.js.map +1 -1
- package/dist/elements/public/GiftCardForm/GiftCardForm.d.ts +3 -2
- package/dist/elements/public/GiftCardForm/GiftCardForm.js +29 -13
- package/dist/elements/public/GiftCardForm/GiftCardForm.js.map +1 -1
- package/dist/elements/public/I18n/format/index.js +2 -0
- package/dist/elements/public/I18n/format/index.js.map +1 -1
- package/dist/elements/public/I18n/format/relative.d.ts +6 -0
- package/dist/elements/public/I18n/format/relative.js +15 -0
- package/dist/elements/public/I18n/format/relative.js.map +1 -0
- package/package.json +3 -3
- package/dist/cdn/shared-05488216.js +0 -1
- package/dist/cdn/shared-0e4d19e2.js +0 -1
- package/dist/cdn/shared-43abbdd9.js +0 -1
- package/dist/cdn/shared-8a5ec3cf.js +0 -1
- package/dist/cdn/shared-cf6751d3.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as t,_ as e,j as i,h as s}from"./shared-63eaded9.js";import"./shared-5a54a9bc.js";import{p as r}from"./shared-11708514.js";import"./shared-46ee137f.js";import"./shared-8b20bc23.js";import"./shared-073cb8e9.js";import{b as a,S as n,c as o}from"./shared-e68b9c83.js";import"./shared-223508ae.js";import"./shared-66633ff7.js";import{I as l,D as c}from"./shared-e2c878c7.js";import{E as h}from"./shared-dcc9c325.js";import"./shared-65dfd512.js";import"./shared-a040d79d.js";import"./shared-fab8c705.js";import"./shared-60126eee.js";import{s as d}from"./shared-b0f0e8b5.js";class u extends CustomEvent{constructor(t){super("change",{detail:t})}}class m extends CustomEvent{constructor(t){super("submit",{detail:t,cancelable:!0})}}let _,p,g=t=>t;var y;!function(t){t[t.Excluded=0]="Excluded",t[t.BeforeEnter=1]="BeforeEnter",t[t.Default=2]="Default",t[t.Previous=3]="Previous",t[t.BeforeExit=4]="BeforeExit"}(y||(y={}));class f extends t{constructor(){super(...arguments),this.quantity=0,this.image=""}static get properties(){return e(e({},super.properties),{},{quantity:{attribute:!1},image:{attribute:!1}})}static get styles(){return[a.styles,i(_||(_=g`.ease-out-back{transition-timing-function:cubic-bezier(.34,1.56,.64,1)}.blur-1{filter:blur(1px)}.blur-2{filter:blur(2px)}.grayscale{filter:grayscale()}.rotate-12{--tw-rotate:12deg}.-rotate-12{--tw-rotate:-12deg}.-rotate-24{--tw-rotate:-24deg}.translate-y-half{--tw-translate-y:50%}`))]}set empty(t){this.updateComplete.then((()=>{if(t){const[,...t]=this.__stack;t.forEach((t=>t.remove()))}else this.quantity>1&&this.__stack.length<2&&this.__insertImage(y.Previous,this.__stack[0])}))}set data({quantity:t,image:e}){this.quantity=t,this.image=e}render(){return s(p||(p=g`<div id="image" class="w-full h-full relative"></div>`))}firstUpdated(){const t=this.__insertImage(y.Default);this.quantity>1&&this.__insertImage(y.Previous,t)}updated(t){if(t.has("quantity")){const e=t.get("quantity");void 0!==e&&(this.quantity>e?this.__add():this.__remove())}t.has("image")&&this.__stack.forEach((t=>t.src=this.image))}get __container(){return this.shadowRoot.getElementById("image")}get __stack(){var t,e;return[...null!==(e=null===(t=this.__container)||void 0===t?void 0:t.querySelectorAll(":not(.opacity-0)"))&&void 0!==e?e:[]].reverse()}__add(){const[t,e]=this.__stack;this.quantity>1?(t&&this.__setImageState(t,y.Previous),e&&(this.__setImageState(e,y.BeforeExit),e.ontransitionend=()=>e.remove()),this.__setImageState(this.__insertImage(y.BeforeEnter),y.Default)):t&&this.__setImageState(t,y.Default)}__remove(){const[t,e]=this.__stack;let i;if(this.quantity>0?(e&&this.__setImageState(e,y.Default),i=t):(t&&this.__setImageState(t,y.Excluded),i=e),i&&(this.__setImageState(i,y.BeforeEnter),i.ontransitionend=()=>i.remove()),this.quantity>1){const t=this.__insertImage(y.BeforeExit,this.__container.firstElementChild);this.__setImageState(t,y.Previous)}}__insertImage(t,e=null){const i=new Image;return i.src=this.image,i.setAttribute("part","picture"),i.addEventListener("error",(()=>i.src=f.placeholder)),this.__setImageState(i,t),this.__container.insertBefore(i,e),i}__setImageState(t,e){t.offsetHeight,t.className=["absolute inset-0 w-full h-full object-cover rounded transform transition duration-700 ease-out-back",["grayscale","shadow-m translate-y-half scale-110 rotate-12 opacity-0","shadow-m","blur-1 -rotate-12 opacity-25","blur-2 -rotate-24 opacity-0"][e]].join(" ")}}f.placeholder='data:image/svg+xml,%3Csvg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg"%3E%3Crect width="40" height="40" fill="%23E8E8E8"/%3E%3Cpath d="M31.5143 0H24.5476L0 24.5476V31.5143L11.7046 19.8097L11.9841 17.0782C12.0983 15.9624 13.0131 15.1154 14.1038 15.1154H15.7373V12.1923C15.7373 10.9815 16.6915 10 17.8687 10H21.5143L31.5143 0Z" fill="white"/%3E%3Cpath d="M11.5434 21.3852L0 32.9285V39.8953L11.5822 28.3131C11.172 27.8663 10.9438 27.2444 11.012 26.5782L11.5434 21.3852Z" fill="white"/%3E%3Cpath d="M12.4305 28.879L1.30951 40H8.27631L19.2763 29H13.1316C12.8853 29 12.6495 28.9573 12.4305 28.879Z" fill="white"/%3E%3Cpath d="M28.3113 19.965L28.0159 17.0782C27.9116 16.0591 27.1395 15.2642 26.1754 15.1341L40 1.3095V8.27627L28.3113 19.965Z" fill="white"/%3E%3Cpath d="M20.6905 29L9.69049 40H16.6572L27.9755 28.6817C27.6541 28.8832 27.2756 29 26.8684 29H20.6905Z" fill="white"/%3E%3Cpath d="M28.6572 28C28.9128 27.5952 29.0415 27.1003 28.988 26.5782L28.4426 21.2479L40 9.69053V16.6572L28.6572 28Z" fill="white"/%3E%3Cpath d="M25.0381 40H18.0715L40 18.0715V25.0381L25.0381 40Z" fill="white"/%3E%3Cpath d="M26.4524 40H33.4191L40 33.4191V26.4524L26.4524 40Z" fill="white"/%3E%3Cpath d="M40 40H34.8333L40 34.8333V40Z" fill="white"/%3E%3Cpath d="M16.1666 0H23.1334L0 23.1334V16.1666L16.1666 0Z" fill="white"/%3E%3Cpath d="M14.7524 0H7.78571L0 7.78573V14.7524L14.7524 0Z" fill="white"/%3E%3Cpath d="M0 0H6.37152L0 6.37151V0Z" fill="white"/%3E%3Cpath d="M21.467 11.4615H17.8687C17.4763 11.4615 17.1582 11.7887 17.1582 12.1923V15.1154H22.8418V12.1923C22.8418 11.7887 22.5237 11.4615 22.1313 11.4615H21.467Z" fill="white"/%3E%3Cpath d="M24.7798 15.1154H24.2627V12.1923C24.2627 11.227 23.6562 10.4075 22.8138 10.1148L32.9286 0H39.89L24.7798 15.1154Z" fill="white"/%3E%3C/svg%3E';let v,b,w,x,q,I,E,$,C=t=>t;class S extends(n(t)){constructor(){super(...arguments),this.empty=!1,this.data=[]}static get properties(){return e(e({},super.properties),{},{empty:{attribute:!1},data:{attribute:!1}})}static get styles(){return[a.styles,i(v||(v=C`.w-preview{width:5.5rem}.h-preview{height:5.5rem}.ease-out-back{transition-timing-function:cubic-bezier(.34,1.56,.64,1)}.grayscale{filter:grayscale()}.grid-2>:nth-child(1),.grid-3>:nth-child(1),.grid-4-plus>:nth-child(1),.grid-4>:nth-child(1){--tw-scale-x:calc(2.5 / 5.5);--tw-scale-y:var(--tw-scale-x)}.grid-1>:nth-child(2){opacity:0;--tw-translate-x:100%;--tw-translate-y:var(--tw-translate-x)}.grid-2>:nth-child(2),.grid-3>:nth-child(2),.grid-4-plus>:nth-child(2),.grid-4>:nth-child(2){--tw-scale-x:calc(2.5 / 5.5);--tw-scale-y:var(--tw-scale-x)}.grid-3>:nth-child(2),.grid-4-plus>:nth-child(2),.grid-4>:nth-child(2){transform-origin:top right}.grid-1>:nth-child(3),.grid-2>:nth-child(3),.grid-3>:nth-child(3),.grid-4-plus>:nth-child(3),.grid-4>:nth-child(3){--tw-scale-x:calc(2.5 / 5.5);--tw-scale-y:var(--tw-scale-x)}.grid-1>:nth-child(3),.grid-2>:nth-child(3){opacity:0;--tw-translate-y:100%}.grid-3>:nth-child(3){transform-origin:bottom right}.grid-4-plus>:nth-child(3),.grid-4>:nth-child(3){transform-origin:bottom left}.grid-1>:nth-child(4),.grid-2>:nth-child(4),.grid-3>:nth-child(4),.grid-4-plus>:nth-child(4),.grid-4>:nth-child(4){--tw-scale-x:calc(2.5 / 5.5);--tw-scale-y:var(--tw-scale-x)}.grid-1>:nth-child(4),.grid-2>:nth-child(4),.grid-3>:nth-child(4){opacity:0;transform-origin:bottom left;--tw-translate-x:100%}.grid-1>:nth-child(4)>:first-child,.grid-2>:nth-child(4)>:first-child,.grid-3>:nth-child(4)>:first-child,.grid-4>:nth-child(4)>:first-child{transform:perspective(250px) rotateX(-90deg)}.grid-4-plus>:nth-child(4)>:first-child,.grid-4>:nth-child(4)>:last-child{transition-delay:.15s;transition-timing-function:ease-out}.grid-4-plus>:nth-child(4)>:last-child,.grid-4>:nth-child(4)>:first-child{transition-timing-function:ease-in}.grid-4-plus>:nth-child(4)>:last-child{transform:perspective(250px) rotateX(90deg)}.grid-1>:nth-child(5),.grid-3>:nth-child(5),.grid-4-plus>:nth-child(5),.grid-4>:nth-child(5){opacity:0}.grid-1>:nth-child(5){--tw-translate-x:100%}.grid-2>:nth-child(5),.grid-3>:nth-child(5),.grid-4-plus>:nth-child(5),.grid-4>:nth-child(5){--tw-scale-x:calc(2.5 / 5.5);--tw-scale-y:var(--tw-scale-x)}.grid-3>:nth-child(5),.grid-4-plus>:nth-child(5),.grid-4>:nth-child(5){--tw-translate-y:-100%}.grid-1>:nth-child(6),.grid-4-plus>:nth-child(6),.grid-4>:nth-child(6){opacity:0}.grid-1>:nth-child(6){--tw-translate-y:100%}.grid-2>:nth-child(6),.grid-3>:nth-child(6),.grid-4-plus>:nth-child(6),.grid-4>:nth-child(6){--tw-scale-x:calc(2.5 / 5.5);--tw-scale-y:var(--tw-scale-x)}.grid-4-plus>:nth-child(6),.grid-4>:nth-child(6){--tw-translate-x:-100%}`))]}render(){const t=this.data.length,e="rounded bg-contrast-10",i="transition-all duration-700 ease-out-back transform absolute inset-0",r=this.empty?"grayscale":"",a=t>4?"grid-4-plus":`grid-${Math.max(1,t)}`,n=d({exportparts:"picture",class:"w-full h-full",".empty":this.empty}),[o,l,c,h]=this.data;return s(b||(b=C` <div class="${0} w-preview h-preview relative font-lumo"> <div class="${0} ${0} origin-top-left"> ${0} </div> <div class="${0} ${0} origin-bottom-right"> ${0} </div> <div class="${0} ${0} origin-top-right"> ${0} </div> <div class="${0} ${0} origin-bottom-right"> <div class="${0} flex text-body transition duration-150 absolute inset-0"> ${0} </div> <div class="transition duration-150 absolute inset-0"> ${0} </div> </div> <div class="${0} ${0} origin-top-right"></div> <div class="${0} ${0} origin-bottom-left"></div> </div> `),a,i,r,o?s(w||(w=C`<x-pic ...="${0}" .data="${0}"></x-pic>`),n,o):"",i,r,l?s(x||(x=C`<x-pic ...="${0}" .data="${0}"></x-pic>`),n,l):"",i,r,c?s(q||(q=C`<x-pic ...="${0}" .data="${0}"></x-pic>`),n,c):"",i,r,e,t>102?s(I||(I=C`<iron-icon icon="icons:more-horiz" class="m-auto w-xl h-xl"></iron-icon>`)):s(E||(E=C`<div class="m-auto text-xxxl">+${0}</div>`),t-3),h?s($||($=C`<x-pic ...="${0}" .data="${0}"></x-pic>`),n,h):"",i,e,i,e)}}let D,k,L=t=>t;class A extends S{static get scopedElements(){return{"x-pic":f}}}class N extends S{static get scopedElements(){return{"x-pic":A}}}class P extends(n(t)){constructor(){super(...arguments),this.quantity=0,this.items=[]}static get scopedElements(){return{"x-picture":f,"x-bundle-grid":N}}static get properties(){return{quantity:{attribute:!1},image:{attribute:!1},items:{attribute:!1}}}static get styles(){return a.styles}render(){const{quantity:t,image:e=""}=this,i=0===t,r=d({class:"w-full h-full",exportparts:"picture"});if(0===this.items.length)return s(D||(D=L`<x-picture ...="${0}" .data="${0}"></x-picture>`),r,{quantity:t,image:e});{const e=new Array(Math.max(1,t)).fill(this.items);return s(k||(k=L`<x-bundle-grid ...="${0}" .empty="${0}" .data="${0}"></x-bundle-grid>`),r,i,e)}}}class j extends o{static get properties(){return e(e({},super.properties),{},{open:{type:Object},signatures:{type:Object,converter:t=>{const e=JSON.parse(t);for(const t of Object.keys(e))64!=e[t].length&&console.error("There is something wrong with the signature. It should have 64 characters.");return e}}})}signedName(t){return this.signatures&&this.signatures[t]?`${t}||${this.signatures[t]}${this.isOpen(t)?"||open":""}`:t}isOpen(t){return!(!this.open||!this.open[t])}}let F,T,O,V,M,H,B,Z=t=>t;class R extends j{constructor(){super("items-form"),this.rel="product_item",this.readonly=!1,this.quantity=0,this.total=this.__computeTotalPrice(),this.currency="",this.isItem=!0,this.isChildItem=!1,this.pid=R.__newId(),this.__modified=!1,this.__childPrices=[],this.__images=[],this.__childrenCount=0,this.__itemDescription="",this.__handleQuantity={handleEvent:t=>{const e=Number(t.target.value);this.quantity=e,this.__modified=!0,this.__images=[this.getImageDescription()].concat(this.__images.slice(1,this.__images.length))}},this.__childItemsObserver=new MutationObserver(this.__observeItems.bind(this)),this.__childItemsObserver.observe(this,{childList:!0,attributes:!1,subtree:!0}),this.updateComplete.then((()=>{this.__setCode(),this.__acknowledgeChildItems(),this.__changedChildItem(),this.__isValid()||console.error("Invalid item",this.value)}))}static get styles(){return[super.styles,i(F||(F=Z`:host{--quantity-width:6.5rem;--preview-size:5.5rem;--threshold:20rem}.min-w-description::before{content:'';width:var(--threshold);display:block;overflow:hidden}.ml-description{--min-width:calc(var(--threshold) + var(--preview-size) + var(--lumo-space-l));--free-space:calc(100% - var(--min-width));--max-margin-left:calc(var(--preview-size) + var(--lumo-space-l));--final-margin-left:clamp(0rem, var(--free-space) * 999999999, var(--max-margin-left));margin-left:var(--final-margin-left)}.mr-quantity{--min-width:var(--threshold);--free-space:calc(100% - var(--min-width));--max-margin-right:calc(var(--quantity-width) + var(--lumo-space-l));--final-margin-right:clamp(0rem, var(--free-space) * 999999999, var(--max-margin-right));margin-right:var(--final-margin-right)}:host([data-bundled]:not(:last-of-type)) .separator::after{content:' ';display:block;position:absolute;width:100vw;border-bottom:solid thin var(--lumo-shade-10pct);left:0;bottom:0}.w-quantity{width:var(--quantity-width)}.w-preview{width:var(--preview-size)}.h-preview{height:var(--preview-size)}`))]}static get scopedElements(){return{"vaadin-integer-field":customElements.get("vaadin-integer-field"),"x-error-screen":h,"x-preview":P,"x-i18n":l}}static get properties(){return e(e({},super.properties),{},{__modified:{},readonly:{type:Boolean,reflect:!0},currency:{type:String},category:{type:String},code:{type:String,reflect:!0},expires:{type:String},height:{type:Number},image:{type:String},length:{type:Number},name:{type:String},parent_code:{type:String},price:{type:Number},quantity:{type:Number,reflect:!0},quantity_max:{type:Number},quantity_min:{type:String},shipto:{type:String},total:{type:Number,reflect:!0,attribute:"total"},url:{type:String},value:{type:Object},weight:{type:Number},width:{type:Number},__childPrices:{},__childrenCount:{},__images:{},alt:{type:String},isChildItem:{type:Boolean,reflect:!0,attribute:"data-bundled"},isItem:{type:Boolean,reflect:!0,attribute:"data-item"},open:{type:Object},pid:{type:Number,reflect:!0},items:{type:Array}})}get items(){const t=[];return this.__onEachChildItem([e=>t.push(e.value)]),t}set items(t){this.__createItems(t)}get value(){const t={};for(let e=0;e<this.attributes.length;e++)t[this.attributes[e].name]=this.attributes[e].value;return t.items=this.items,t}set value(t){this.__itemDescription="";for(const e in t){let i="";if("description"!=e){if("object"==typeof t[e])i=JSON.stringify(t[e]);else{const s=e;(t[s]&&"undefined"!==t[s]||0===t[s])&&(i=t[e].toString())}this.setAttribute(e,t[e]?i:"")}else this.__itemDescription=t[e]}}updated(t){t.forEach(((t,e)=>{"__itemDescription"!=e&&"isChildItem"!=e||this.__updateDescriptionEl()})),this.__setTotalPrice(),this.dispatchEvent(new Event("change"))}render(){var t;if(!this.__isValid())return s(T||(T=Z`<x-error-screen type="setup_needed" class="relative"></x-error-screen>`));const e=`font-lumo text-body text-s leading-m transition duration-100 ${this.quantity?"":"removed opacity-50"}`;if(this.isChildItem)return s(O||(O=Z` <article part="item" class="py-s w-full relative separator item-summary flex justify-between ${0}"> <div class="description flex-1"> <h1 class="text-header font-medium">${0}</h1> <section class="description text-secondary"> <slot></slot> </section> </div> ${0} </article> `),e,this.name,this.quantity<2?"":s(V||(V=Z` <section class="quantity font-medium text-tertiary whitespace-nowrap"> ${0} </section> `),this._t("item.items",{quantity:this.quantity})));{const i=(null!==(t=this.price)&&void 0!==t?t:0)+this.__childPrices.reduce(((t,e)=>t+e),0),r=this.__translateAmount(i*this.quantity),a=this.__translateAmount(i);return s(M||(M=Z` <article part="item" class="p-l relative item ${0} ${0}"> <x-preview class="preview float-left w-preview h-preview mr-l mb-l" exportparts="picture" .image="${0}" .quantity="${0}" .items="${0}"> </x-preview> <section class="description min-w-description ml-description"> <h1 class="text-header font-medium text-l leading-none mr-quantity mb-s"> ${0} </h1> <div class="item-description text-secondary mr-quantity mb-s"> <slot></slot> </div> <div class="child-items mb-s"> <slot name="items"></slot> </div> ${0} </section> <section class="quantity w-quantity absolute top-0 right-0 m-l"> <vaadin-integer-field class="w-full p-0" name="quantity" @change="${0}" value="${0}" min="0" has-controls ?readonly="${0}"> </vaadin-integer-field> ${0} </section> </article> `),e,this.__modified?"modified":"",this.image,this.quantity,[...this.querySelectorAll("[data-bundled]")].map((t=>{var e;return{quantity:t.quantity,image:null!==(e=t.image)&&void 0!==e?e:""}})),this.name,a?s(H||(H=Z`<div class="font-medium price text-l">${0}</div>`),a):"",this.__handleQuantity,this.quantity,this.readonly,this.quantity>1?s(B||(B=Z` <x-i18n .ns="${0}" .lang="${0}" .opts="${0}" class="price-total text-secondary text-xs text-center block mt-xs" key="price.total"> </x-i18n> `),this.ns,this.lang,{amount:r}):"")}}getImageDescription(){return{src:this.image,alt:this.alt,quantity:this.quantity}}signedName(t){const e=super.signedName(t);return`${this.pid.toString()}:${e}`}static __newId(){const t=R.__existingIds.reduce(((t,e)=>e>t?e:t),0)+1;return R.__existingIds.push(t),t}__updateDescriptionEl(){if(this.__itemDescription){let t=this.shadowRoot.querySelector("data-item-description");t||(t=document.createElement("p"),t.dataset.itemDescription="true",this.__addSlottedEl(t)),t.innerText=this.__itemDescription}else{const t=this.shadowRoot.querySelector("data-item-description");t&&t.remove()}}__addSlottedEl(t){const e=this.shadowRoot.querySelector("article");e&&e.appendChild(t)}__setCode(){this.code||(this.code=`RAND${Math.random()}`)}__createItems(t){t.forEach((t=>{const e=document.createElement(this.tagName);e.value=t,e.currency=this.currency,e.__computeTotalPrice(),this.__acknowledgeItem(e),this.appendChild(e)}))}__setTotalPrice(){this.total=this.__computeTotalPrice()}__computeTotalPrice(){if(!this.__childPrices)return this.price?this.price*this.quantity:0;let t=0;return this.__childPrices.forEach((e=>{t+=e})),t+=this.price,t*=this.quantity,t}__isValid(){const t=[];return this.name&&this.name.length||t.push("The name attribute of an item is required."),this.price||0===this.price||t.push("The price attribute of an item is required."),this.price&&this.price<0&&t.push("Item added with negative price."),this.quantity_min&&this.quantity&&this.quantity<this.quantity_min&&t.push("Quantity amount is less than minimum quantity."),this.quantity_max&&this.quantity&&this.quantity>this.quantity_max&&t.push("Quantity amount is more than maximum quantity."),console.error(...t),!t.length}__translateAmount(t){return this.currency?t.toLocaleString(this.lang,{minimumFractionDigits:2,currency:this.currency,style:"currency"}):""}__observeItems(t){t.forEach((t=>{"childList"==t.type&&t.addedNodes.forEach((t=>{t.nodeType===Node.DOCUMENT_NODE&&this.__acknowledgeItem(t)}))})),this.__setTotalPrice()}__acknowledgeChildItems(){var t;null===(t=this.shadowRoot)||void 0===t||t.querySelectorAll("[data-item]").forEach((t=>this.__acknowledgeItem(t))),this.querySelectorAll("[data-item]").forEach((t=>this.__acknowledgeItem(t)))}__acknowledgeItem(t){t.addEventListener("change",this.__changedChildItem.bind(this)),t.currency=this.currency,t.isItem=!1,t.isChildItem=!0,this.code&&(t.parent_code=this.code)}__changedChildItem(){const t=[],e=[];let i=0;this.__onEachChildItem([e=>{void 0!==e.total&&t.push(e.total)},t=>{e.push(t.getImageDescription())},()=>i+=1]),this.image&&0===e.length&&e.push(this.getImageDescription()),this.__childPrices=t,this.__images=e,this.__childrenCount=i,this.__setTotalPrice()}__onEachChildItem(t){const e=this.querySelectorAll("[data-bundled]");for(const i of e)for(const e of t)e(i)}}R.__existingIds=[];let z,Q,W,J,U,X,G=t=>t;class K extends j{constructor(){super("items-form"),this.readonly=!1,this.target="_top",this.cart="checkout",this.sub_modify="replace",this.sub_restart="auto",this.frequencies=[],this.handleSubmit={handleEvent:()=>{null!==this.__data&&this.dispatchEvent(new m(this.__data))&&this.shadowRoot.querySelector("form").submit()}},this.__hasValidItems=!1,this.__total=0,this.__handleFrequency={handleEvent:t=>{const e=t.detail.replace(/([wydm])\w*/,"$1").replace(/ /g,"").replace(/^0/,"");K.__validFrequency(e)?this.sub_frequency=e:this.sub_frequency="",this.__updateData()}},this.__data=new FormData,this.__childItemsObserver=new MutationObserver(this.__observeChildren.bind(this)),this.__childItemsObserver.observe(this,{childList:!0,attributes:!1,subtree:!0}),this.updateComplete.then((()=>{this.__acknowledgeItemElements(),this.__computeTotalPrice(),this.__updateData()}))}static get scopedElements(){return{"x-error-screen":h,"vaadin-button":customElements.get("vaadin-button"),"x-dropdown":c,"x-item":R}}static get properties(){return e(e({},super.properties),{},{currency:{type:String},readonly:{type:Boolean},cart:{type:String,converter:t=>t&&!["checkout","add"].includes(t)?null:t},target:{type:String},store:{type:String,attribute:"store"},sub_frequency:{type:String},sub_startdate:{type:String,converter:t=>K.__validDate(t)?t:(console.error("Invalid start date",t),"")},sub_enddate:{type:String,converter:t=>K.__validDateFuture(t)?t:(console.error("Invalid end date",t),"")},sub_token:{type:String},sub_modify:{type:String,converter:t=>""===t||"append"===t?"":"replace"},sub_restart:{type:String,converter:t=>"true"===t?t:"auto"},frequencies:{converter:t=>{if(!t)return[];const e=JSON.parse(t);if(!Array.isArray(e))return console.error("Invalid frequency","Frequency options must be an array."),[];for(const t of e)if(!K.__validFrequency(t))return console.error("Invalid frequency","Invalid frequency option.\n Please, check https://wiki.foxycart.com/v/2.0/products#subscription_product_options for possible values.\n Each frequency must be a in the format:\n - 1d (a number followed by d, for day)\n - 1w (a number followed by w, for week)\n - 1m (a number followed by m, for month)\n - 1y (a number followed by y, for year)\n or .5m (no other decimals are allowed, and this is only for months)\n ",t),[];return e.filter(K.__validFrequency)}},items:{type:Array},__hasValidItems:{attribute:!1},__total:{attribute:!1},__data:{attribute:!1}})}get items(){const t=[];return this.__itemElements.forEach((e=>{const i=new Proxy(e,{set:function(t,e,i){const s=Object.keys(t.value);return!("string"!=typeof e||!s.includes(e))&&(t[e]=i,!0)},get:function(t,e){return t.value[e]}});t.push(i)})),t}set items(t){this.__removeItems(),this.__createItemsFromItemArray(t)}get total(){return this.__total}render(){var t;return this.store&&this.currency?s(Q||(Q=G` <div> <form class="overflow-hidden" method="POST" target="${0}" action="https://${0}/cart" data-testid="form" class="hidden" hidden> ${0} </form> <section class="items"> <slot></slot> </section> ${0} </div> `),this.target,this.store,this.__data?s(W||(W=G` ${0}`),[...this.__data.entries()].map((([t,e])=>s(J||(J=G`<input type="hidden" name="${0}" value="${0}">`),t,e)))):"",this.readonly?"":s(U||(U=G` <section class="actions flex flex-wrap justify-end m-m"> ${0} <vaadin-button class="m-s w-full sm-w-auto" theme="primary" data-testid="submit" ?disabled="${0}" @click="${0}"> <span class="total"> ${0} </span> </vaadin-button> </section> `),this.frequencies&&this.frequencies.length?s(X||(X=G` <x-dropdown type="text" name="frequency" class="subscription m-s w-full sm-w-auto" lang="${0}" .value="${0}" .items="${0}" .getText="${0}" @change="${0}"> </x-dropdown> `),this.lang,null!==(t=this.sub_frequency)&&void 0!==t?t:"0",this.frequencies.concat(["0"]),this.__translateFrequency.bind(this),this.__handleFrequency):"",!this.__hasValidItems,this.handleSubmit,this.__submitBtnText(this.__translateAmount(this.total)))):s(z||(z=G`<x-error-screen type="setup_needed" class="relative"></x-error-screen>`))}addItems(t){for(const e of t){const t=this.createItem(e);this.appendChild(t),this.__acknowledgeItemElement(t)}}removeItems(t){this.__removeItems((e=>t.includes(e.pid)))}updated(){this.dispatchEvent(new u(this.__data))}createItem(t){const e=this.constructor.getScopedTagName("x-item"),i=document.createElement(e);return i.value=t,i.currency=this.currency,i.readonly=this.readonly,i}__submitBtnText(t){if(this.sub_frequency&&"0"!=this.sub_frequency){const e=r(this.sub_frequency);return 1===e.count?this._t("checkout.subscribe_single_unit",{value:t,period:this._t(e.units).toLowerCase()}):this._t("checkout.subscribe_muiltiple_units",{value:t,period:this.__translateFrequency(this.sub_frequency).toLowerCase()})}return this._t("checkout.buy",{value:t})}get __itemElements(){return this.querySelectorAll("[data-item]")}__createItemsFromItemArray(t){this.addItems(t)}__removeItems(t=(()=>!0)){this.__itemElements.forEach((e=>{t(e)&&e.remove()}))}__addSignature(t,e,i){return`${t}||${e}${i?"||open":""}`}__formDataFill(t){let e=0;return this.__itemElements.forEach((i=>{e+=this.__formDataAddItem(t,i)})),this.__formDataAddCartWideSubscriptionFields(t),e}__formDataCustomInputs(t){this.querySelectorAll("[name]").forEach((e=>{const i=e;"INPUT"==i.tagName&&["checkbox","radio"].includes(i.type)&&!i.checked||"OPTION"!=i.tagName&&i.value&&["number","string"].includes(typeof i.value)&&t.set(i.name,i.value)}))}__isAttributeReserved(t){return["alt","currency","description","isChildren","isItem","items","open","pid","signatures","slot","total"].includes(t)}__formDataAddItem(t,e,i=null){let s=0;if(this.__validItem(e)){if(!e.value.pid)throw new Error("Attempt to convert a item without a propper ID");i&&i.getAttribute("code")&&e.setAttribute("parent_code",i.getAttribute("code"));for(let s=0;s<e.attributes.length;s++){const r=e.attributes[s];if(!this.__isAttributeReserved(r.name)&&!r.name.startsWith("data-")){let s=e[r.name];e.code&&["string","number"].includes(typeof s)&&(i&&"quantity"==r.name&&(s=Number(r.value)*i.quantity),t.set(e.signedName(r.name),s.toString()))}}s+=1,this.__formDataAddSubscriptionFields(t,e)}const r=e.querySelectorAll("[data-bundled]");if(r&&e.quantity>0)for(const i of r)s+=this.__formDataAddItem(t,i,e);return s}__formDataAddSubscriptionFields(t,e){if(this.sub_frequency)for(const i of["sub_frequency","sub_startdate","sub_enddate"])this[i]&&t.set(e.signedName(i),this[i])}__formDataAddCartWideSubscriptionFields(t){this.sub_frequency&&(this.sub_token&&t.set(this.signedName("sub_token"),this.sub_token),t.set(this.signedName("sub_modify"),this.sub_modify),t.set(this.signedName("sub_restart"),this.sub_restart))}__formDataAddCartFields(t){this.cart?t.set("cart",this.cart):t.delete("cart")}static __validDate(t){return null!=t&&(t.match(/^(\d{1,2}|\d{8})$/)?!(t.match(/^\d{2}$/)&&Number(t)>31):!(t.match(/^\.5m/)||!K.__validFrequency(t)))}static __validDateFuture(t){let e=!1;if(K.__validDate(t))if(t.match(/^\d{8}/)){e=(new Date).toISOString().replace(/(-|T.*)/g,"")<=t}else e=!0;return e}static __validFrequency(t){return!!t&&!!t.match(/^(\.5m|\d+[dwmy])$/)}__observeChildren(t){t.forEach((t=>{"childList"==t.type&&t.addedNodes.forEach((t=>{t.addEventListener("change",this.__itemChange.bind(this))}))})),this.__acknowledgeItemElements(),this.__computeTotalPrice(),this.__updateData()}__itemChange(){this.__computeTotalPrice(),this.__updateData()}__computeTotalPrice(){let t=0;this.__itemElements.forEach((e=>{const i=e;i.total&&(t+=Number(i.total))})),this.__total=Number(t.toFixed(2))}__acknowledgeItemElements(){this.__itemElements.forEach((t=>{const e=t;this.__acknowledgeItemElement(e)}))}__acknowledgeItemElement(t){t.addEventListener("change",this.__itemChange.bind(this)),t.currency=this.currency}__validItem(t){const e=t.getAttribute("pid"),i=Number(t.getAttribute("quantity")),s=Number(t.getAttribute("price"));return!!(e&&i>0&&s>=0)}__translateFrequency(t){if(t.startsWith("0"))return this._t("frequency_once");if(".5m"===t)return this._t("frequency_0_5m");const{count:e,units:i}=r(t);return this._t("frequency",{units:this._t(i,{count:e}),count:e})}__translateAmount(t){return t.toLocaleString(this.lang,{minimumFractionDigits:2,currency:this.currency,style:"currency"})}__updateData(){this.__data=null;if(!this.shadowRoot.querySelector("form"))return;const t=new FormData,e=this.__formDataFill(t);this.__hasValidItems=!!e,this.__formDataAddCartFields(t),this.__formDataCustomInputs(t),this.__data=t}}customElements.define("foxy-items-form",K),customElements.define("foxy-item",R);export{K as I,P,R as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{L as e,_ as s,j as t,h as r}from"./shared-63eaded9.js";import"./shared-46ee137f.js";import"./shared-
|
|
1
|
+
import{L as e,_ as s,j as t,h as r}from"./shared-63eaded9.js";import"./shared-46ee137f.js";import"./shared-8b20bc23.js";import"./shared-073cb8e9.js";import{T as a}from"./shared-e68b9c83.js";import{c as i}from"./shared-4e709717.js";class c extends CustomEvent{constructor(e){super("change",{detail:e})}}let o,l,d=e=>e;class h extends(a(e)){constructor(){super(...arguments),this.readonly=!1,this.disabled=!1,this.checked=!1}static get properties(){return s(s({},super.properties),{},{readonly:{type:Boolean},disabled:{type:Boolean},checked:{type:Boolean}})}static get styles(){return[super.styles,t(o||(o=d`:host{--check-size:1.125rem}label{margin:calc(((1rem * var(--lumo-line-height-s)) - var(--check-size))/ -2) 0}label>:first-child{height:calc(1rem * var(--lumo-line-height-s))}.ml-xxl{margin-left:calc(var(--lumo-space-m) + var(--check-size))}.check{height:var(--check-size);width:var(--check-size)}`))]}render(){return r(l||(l=d` <label class="${0}"> <div class="flex items-center"> <div class="${0}"> <iron-icon icon="lumo:checkmark" class="${0}"> </iron-icon> <input type="checkbox" class="sr-only" .checked="${0}" ?disabled="${0}" data-testid="input" @change="${0}"> </div> </div> <div class="flex-1 font-lumo leading-s ml-m"> <slot></slot> </div> </label> <div class="${0}"> <slot name="content"></slot> </div> `),i({"flex items-start group transition-colors":!0,"cursor-default":this.disabled||this.readonly,"text-disabled":this.disabled,"text-secondary":this.readonly,"cursor-pointer":!this.disabled}),i({"flex-shrink-0 check transition-colors rounded-s border":!0,"focus-within-shadow-outline":!0,"bg-primary text-primary-contrast":!this.readonly&&this.checked,"border-dashed border-contrast-30":this.readonly,"border-transparent":!this.readonly,"opacity-50":this.disabled,"text-secondary bg-contrast-20":!this.readonly&&!this.checked,"group-hover-bg-contrast-30":!this.readonly&&!this.checked}),i({"block w-full h-full transition-transform transform":!0,"scale-100":this.checked,"scale-0":!this.checked}),this.checked,this.disabled,(e=>{if(this.readonly)return e.preventDefault();e.stopPropagation(),this.checked=!this.checked,this.dispatchEvent(new c(this.checked))}),i({"font-lumo ml-xxl transition-colors":!0,"text-disabled":this.disabled}))}}export{h as C,c as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./shared-5a54a9bc.js";import"./shared-11708514.js";import{_ as t,h as e}from"./shared-63eaded9.js";import{D as s}from"./shared-66633ff7.js";let i,n=t=>t;customElements.define("foxy-internal-confirm-dialog",class extends s{constructor(){super(...arguments),this.closable=!1,this.editable=!1,this.alert=!0,this.confirm="confirm",this.message="message",this.cancel="cancel",this.theme="primary"}static get properties(){return t(t({},super.properties),{},{confirm:{type:String},message:{type:String},cancel:{type:String},theme:{type:String}})}render(){return super.render((()=>e(i||(i=n` <foxy-i18n class="block font-lumo text-m text-body text-center mb-m" lang="${0}" key="${0}" ns="${0}"> </foxy-i18n> <div class="grid grid-cols-2 gap-m"> <vaadin-button data-testid="cancelButton" @click="${0}"> <foxy-i18n ns="${0}" lang="${0}" key="${0}"></foxy-i18n> </vaadin-button> <vaadin-button theme="${0}" data-testid="confirmButton" @click="${0}"> <foxy-i18n ns="${0}" lang="${0}" key="${0}"></foxy-i18n> </vaadin-button> </div> `),this.lang,this.message,this.ns,this.__handleCancel,this.ns,this.lang,this.cancel,this.theme,this.__handleConfirm,this.ns,this.lang,this.confirm)))}async __handleCancel(){await this.hide(!0)}async __handleConfirm(){await this.hide()}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,_ as t,h as r}from"./shared-63eaded9.js";import{B as s}from"./shared-
|
|
1
|
+
import{j as e,_ as t,h as r}from"./shared-63eaded9.js";import{B as s}from"./shared-5a54a9bc.js";import{c as n}from"./shared-e68b9c83.js";import{I as o}from"./shared-e2c878c7.js";let i,a,l,c=e=>e;class d{constructor(e="unknown"){this.type=e}}class h extends CustomEvent{constructor(){super("reload")}}class p extends n{constructor(){super(...arguments),this.type="unknown",this.reload=!1}static get scopedElements(){return{"vaadin-button":s,"iron-icon":customElements.get("iron-icon"),"x-i18n":o}}static get styles(){return[super.styles,e(i||(i=c`:host{position:absolute;top:0;right:0;bottom:0;left:0}.container-narrow{max-width:400px}`))]}static get properties(){return t(t({},super.properties),{},{reload:{type:Boolean,reflect:!0},type:{type:String}})}render(){return r(a||(a=c` <article class="bg-base font-lumo text-center leading-m p-m h-full flex flex-col items-center justify-center"> <iron-icon icon="lumo:error" class="text-error w-l h-l mb-m"></iron-icon> <header class="text-xl text-header container-narrow font-medium"> <x-i18n ns="${0}" lang="${0}" key="errors.${0}.title"></x-i18n> </header> <p class="text-m text-secondary container-narrow mb-l"> <x-i18n ns="${0}" lang="${0}" key="errors.${0}.message"></x-i18n> </p> <div class="flex space-x-s"> <a rel="nofollow noreferrer noopener" href="${0}" target="_blank" class="px-m py-xs text-primary font-medium tracking-wide border border-contrast-10 rounded transition-colors duration-200 hover-bg-primary-10 hover-border-primary-10 focus-outline-none focus-shadow-outline" router-ignore> <x-i18n ns="${0}" lang="${0}" key="errors.${0}.action"></x-i18n> </a> ${0} </div> </article> `),this.ns,this.lang,this.type,this.ns,this.lang,this.type,this._i18n.t(`errors.${this.type}.href`).toString(),this.ns,this.lang,this.type,this.reload?r(l||(l=c` <vaadin-button data-testid="reload" theme="primary" @click="${0}"> <x-i18n ns="${0}" lang="${0}" key="reload"></x-i18n> <iron-icon icon="icons:refresh" slot="suffix"></iron-icon> </vaadin-button> `),(()=>this.dispatchEvent(new h)),this.ns,this.lang):"")}}export{p as E,d as F};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as e,j as t,L as s,_ as i,h as n}from"./shared-63eaded9.js";import{a as r,E as o,T as l,C as a}from"./shared-
|
|
1
|
+
import{C as e,j as t,L as s,_ as i,h as n}from"./shared-63eaded9.js";import{a as r,E as o,T as l,C as a}from"./shared-8b20bc23.js";import{T as d}from"./shared-a040d79d.js";import{O as A,I as h}from"./shared-fab8c705.js";import{h as c,a as m,t as u,P as p}from"./shared-ff79f3f9.js";import{F as g,P as v,a as y}from"./shared-46ee137f.js";import{D as _}from"./shared-223508ae.js";import{b as f,c as b}from"./shared-e68b9c83.js";class w extends CustomEvent{constructor(e){super("change",{detail:e})}}class x extends w{}const E=c`<dom-module id="lumo-list-box" theme-for="vaadin-list-box">
|
|
2
2
|
<template>
|
|
3
3
|
<style>
|
|
4
4
|
:host {
|
|
@@ -301,7 +301,7 @@ const R=document.createElement("template");R.innerHTML="<custom-style>\n <style
|
|
|
301
301
|
<vaadin-select-overlay opened="{{opened}}" with-backdrop="[[_phone]]" phone\$="[[_phone]]" theme\$="[[theme]]"></vaadin-select-overlay>
|
|
302
302
|
|
|
303
303
|
<iron-media-query query="[[_phoneMediaQuery]]" query-matches="{{_phone}}"></iron-media-query>
|
|
304
|
-
`}static get is(){return"vaadin-select"}static get version(){return"2.4.
|
|
304
|
+
`}static get is(){return"vaadin-select"}static get version(){return"2.4.3"}static get properties(){return{opened:{type:Boolean,value:!1,notify:!0,reflectToAttribute:!0,observer:"_openedChanged"},renderer:Function,errorMessage:{type:String,value:""},label:{type:String},value:{type:String,value:"",notify:!0,observer:"_valueChanged"},required:{type:Boolean,reflectToAttribute:!0,observer:"_requiredChanged"},invalid:{type:Boolean,reflectToAttribute:!0,notify:!0,value:!1},name:{type:String,reflectToAttribute:!0},placeholder:{type:String},helperText:{type:String,value:""},readonly:{type:Boolean,value:!1,reflectToAttribute:!0},_phone:Boolean,_phoneMediaQuery:{value:"(max-width: 420px), (max-height: 420px)"},_overlayElement:Object,_inputElement:Object,_toggleElement:Object,_items:Object,_contentTemplate:Object,_oldTemplate:Object,_oldRenderer:Object}}static get observers(){return["_updateSelectedItem(value, _items)","_updateAriaExpanded(opened, _toggleElement, _inputElement)","_templateOrRendererChanged(_contentTemplate, renderer, _overlayElement)"]}constructor(){super(),this._boundSetPosition=this._setPosition.bind(this)}connectedCallback(){super.connectedCallback(),this.addEventListener("iron-resize",this._boundSetPosition)}ready(){super.ready(),this._overlayElement=this.shadowRoot.querySelector("vaadin-select-overlay"),this._valueElement=this.shadowRoot.querySelector('[part="value"]'),this._toggleElement=this.shadowRoot.querySelector('[part="toggle-button"]'),this._nativeInput=this.focusElement.shadowRoot.querySelector("input"),this._nativeInput.setAttribute("aria-hidden",!0),this._nativeInput.setAttribute("tabindex",-1),this._nativeInput.style.pointerEvents="none",this.focusElement.addEventListener("click",(e=>{const t=Array.from(e.composedPath()).some((e=>e.nodeType===Node.ELEMENT_NODE&&"helper"===e.getAttribute("slot")));this.opened=!this.readonly&&!t})),this.focusElement.addEventListener("keydown",(e=>this._onKeyDown(e))),this._observer=new g(this,(e=>this._setTemplateFromNodes(e.addedNodes))),this._observer.flush()}_setTemplateFromNodes(e){const t=Array.from(e).filter((e=>e.localName&&"template"===e.localName))[0]||this._contentTemplate;this._overlayElement.template=this._contentTemplate=t,this._setForwardHostProps()}_setForwardHostProps(){if(this._overlayElement.content){const e=this._overlayElement._instance&&this._overlayElement._instance.forwardHostProp;this._overlayElement._instance&&(this._overlayElement._instance.forwardHostProp=(...t)=>{e.apply(this._overlayElement._instance,t),setTimeout((()=>{this._updateValueSlot()}))},this._assignMenuElement())}}render(){this._overlayElement&&(this._overlayElement.render(),this._menuElement&&this._menuElement.items&&this._updateSelectedItem(this.value,this._menuElement.items))}_removeNewRendererOrTemplate(e,t,s,i){e!==t?this._contentTemplate=void 0:s!==i&&(this.renderer=void 0)}_templateOrRendererChanged(e,t,s){if(s){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 select content");this._oldTemplate=e,this._oldRenderer=t,t&&(s.setProperties({owner:this,renderer:t}),this.render(),s.content.firstChild&&this._assignMenuElement())}}_assignMenuElement(){this._menuElement=Array.from(this._overlayElement.content.children).filter((e=>"style"!==e.localName))[0],this._menuElement&&(this._menuElement.addEventListener("items-changed",(e=>{this._items=this._menuElement.items,this._items.forEach((e=>e.setAttribute("role","option")))})),this._menuElement.addEventListener("selected-changed",(e=>this._updateValueSlot())),this._menuElement.addEventListener("keydown",(e=>this._onKeyDownInside(e))),this._menuElement.addEventListener("click",(e=>{this.__userInteraction=!0,this.opened=!1}),!0),this._menuElement.setAttribute("role","listbox"))}get focusElement(){return this._inputElement||(this._inputElement=this.shadowRoot.querySelector("vaadin-select-text-field"))}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)))}_requiredChanged(e){this.setAttribute("aria-required",e)}_valueChanged(e,t){""===e?this.focusElement.removeAttribute("has-value"):this.focusElement.setAttribute("has-value",""),""===e&&void 0===t||this.validate()}_onKeyDown(e){if(!this.readonly&&!this.opened)if(/^(Enter|SpaceBar|\s|ArrowDown|Down|ArrowUp|Up)$/.test(e.key))e.preventDefault(),this.opened=!0;else if(/[a-zA-Z0-9]/.test(e.key)&&1===e.key.length){const t=this._menuElement.selected,s=void 0!==t?t:-1,i=this._menuElement._searchKey(s,e.key);i>=0&&(this.__userInteraction=!0,this._updateSelectedItem(this._items[i].value,this._items))}}_onKeyDownInside(e){/^(Tab)$/.test(e.key)&&(this.opened=!1)}_openedChanged(e,t){if(e){if(!this._overlayElement||!this._menuElement||!this._toggleElement||!this.focusElement||this.disabled||this.readonly)return void(this.opened=!1);this._openedWithFocusRing=this.hasAttribute("focus-ring")||this.focusElement.hasAttribute("focus-ring"),this._menuElement.focus(),this._setPosition(),window.addEventListener("scroll",this._boundSetPosition,!0)}else t&&(this.focusElement.focus(),this._openedWithFocusRing&&this.focusElement.setAttribute("focus-ring",""),this.validate(),window.removeEventListener("scroll",this._boundSetPosition,!0))}_hasContent(e){return!!e&&Boolean(e.hasAttribute("label")?e.getAttribute("label"):e.textContent.trim()||e.children.length)}_attachSelectedItem(e){if(!e)return;let t;e.hasAttribute("label")?(t=document.createElement("vaadin-item"),t.textContent=e.getAttribute("label")):t=e.cloneNode(!0),t._sourceItem=e,t.removeAttribute("tabindex"),t.removeAttribute("role"),this._valueElement.appendChild(t),t.selected=!0}_updateAriaExpanded(e,t,s){t&&t.setAttribute("aria-expanded",e),s&&s.focusElement&&s.focusElement.setAttribute("aria-expanded",e)}_updateValueSlot(){this.opened=!1,this._valueElement.innerHTML="";const e=this._items[this._menuElement.selected],t=this._hasContent(e),s=this._inputElement.shadowRoot.querySelector('slot[name="input"]')?"input":"value";this._valueElement.slot=t?s:"",t&&window.ShadyDOM&&window.ShadyDOM.flush(),this._attachSelectedItem(e),!this._valueChanging&&e&&(this._selectedChanging=!0,this.value=e.value||"",this.__userInteraction&&(this.dispatchEvent(new CustomEvent("change",{bubbles:!0})),this.__userInteraction=!1),delete this._selectedChanging)}_updateSelectedItem(e,t){t&&(this._menuElement.selected=t.reduce(((t,s,i)=>void 0===t&&s.value===e?i:t),void 0),this._selectedChanging||(this._valueChanging=!0,this._updateValueSlot(),delete this._valueChanging))}_setFocused(e){super._setFocused(this.opened||e),this.focusElement._setFocused(this.hasAttribute("focused")),!this.hasAttribute("focused")&&this.validate()}_setPosition(){const e=this._inputElement.shadowRoot.querySelector('[part~="input-field"]').getBoundingClientRect(),t=Math.min(window.innerHeight,document.documentElement.clientHeight),s=e.top>(t-e.height)/2;"rtl"===this.getAttribute("dir")?this._overlayElement.style.right=document.documentElement.clientWidth-e.right+"px":this._overlayElement.style.left=e.left+"px",s?(this._overlayElement.setAttribute("bottom-aligned",""),this._overlayElement.style.removeProperty("top"),this._overlayElement.style.bottom=t-e.bottom+"px"):(this._overlayElement.removeAttribute("bottom-aligned"),this._overlayElement.style.removeProperty("bottom"),this._overlayElement.style.top=e.top+"px"),this._overlayElement.updateStyles({"--vaadin-select-text-field-width":e.width+"px"})}validate(){return!(this.invalid=!(this.disabled||!this.required||this.value))}}customElements.define(Q.is,Q);let D=0;const q={},$=(t,s,i)=>{const n=i&&i.moduleId||"custom-style-module-"+D++;Array.isArray(s)||(s=s?[s]:[]),s.forEach((t=>{if(!(t instanceof e))throw new Error("An item in styles is not of type CSSResult. Use `unsafeCSS` or `css`.");if(!q[t]){const e=document.createElement("dom-module");e.innerHTML=`\n <template>\n <style>${t.toString()}</style>\n </template>\n `;const s="custom-style-module-"+D++;e.register(s),q[t]=s}}));const r=document.createElement("dom-module");if(t){const e=window.customElements&&window.customElements.get(t);e&&e.hasOwnProperty("__finalized")&&console.warn(`The custom element definition for "${t}"\n was finalized before a style module was registered.\n Make sure to add component specific style modules before\n importing the corresponding custom element.`),r.setAttribute("theme-for",t)}const o=i&&i.include||[];r.innerHTML=`\n <template>\n ${o.map((e=>`<style include=${e}></style>`))}\n ${s.map((e=>`<style include=${q[e]}></style>`))}\n </template>\n `,r.register(n)};let O,P,H=e=>e;$("vaadin-list-box",t(O||(O=H`
|
|
305
305
|
[part='items'] ::slotted(vaadin-item.dropdown-divisor){
|
|
306
306
|
color:var(--lumo-contrast-40pct);
|
|
307
307
|
box-shadow:0 1px var(--lumo-contrast-10pct);
|
|
@@ -311,4 +311,4 @@ const R=document.createElement("template");R.innerHTML="<custom-style>\n <style
|
|
|
311
311
|
[part='items'] ::slotted(vaadin-item.dropdown-sub-item){
|
|
312
312
|
margin-left:var(--lumo-space-l);
|
|
313
313
|
}
|
|
314
|
-
`)));class j extends s{constructor(){super(),this.disabled=!1,this.label="",this.value=null,this.items=null,this.getText=e=>e,this.__unexistentValue=`@foxy.io/elements#dropdown-${Math.random().toFixed(16).substr(2)}`,this.__renderedItems={},this.__list=document.createElement("vaadin-list-box")}static get properties(){return i(i({},super.properties),{},{disabled:{type:Boolean},getText:{type:Object,attribute:!1},items:{type:Array},label:{type:String},value:{type:String}})}static get styles(){return f.styles}render(){return n(P||(P=H` <vaadin-select class="w-full ${0}" data-testid="select" .label="${0}" .value="${0}" .disabled="${0}" .renderer="${0}" @change="${0}"> </vaadin-select> `),this.label?"-mt-m":"",this.label,null===this.value?this.__unexistentValue:this.value,this.disabled,this.__renderItems.bind(this),this.__handleChange)}__renderItems(e){var t;let s=e.querySelector("vaadin-list-box");null===s&&(e.appendChild(this.__list),s=this.__list);for(const e of Object.values(this.__renderedItems))e.dataset.keep="";const i=null!==(t=this.items)&&void 0!==t?t:[];for(let e=0;e<i.length;++e)if("string"==typeof i[e])this.__addOrKeepItem(i[e],i[e],s).classList.add("dropdown-item");else if(Array.isArray(i[e])){const t=this.__addOrKeepItem(i[e][0],i[e][0],s);t.classList.add("dropdown-item","dropdown-divisor"),t.disabled=!0;for(const t of i[e][1])this.__addOrKeepItem(i[e][0]+": "+t,t,s).classList.add("dropdown-sub-item")}for(const e of Object.values(this.__renderedItems)){const t=e;t.dataset.keep||(e.remove(),delete this.__renderedItems[t.dataset.trackId])}}__addOrKeepItem(e,t,s){let i;return this.__renderedItems[e]?i=this.__renderedItems[e]:(i=document.createElement("vaadin-item"),this.__renderedItems[e]=i,i.value=e,s.appendChild(i)),i.dataset.keep="true",i.dataset.trackId=e,i.textContent=this.getText(t),i}__handleChange(e){const t=e.target.value,s=t===this.__unexistentValue?null:t;this.dispatchEvent(new _(s))}}let V,N,z=e=>e;class F extends s{constructor(){super(...arguments),this.variant=null}static get styles(){return[f.styles,t(V||(V=z`@keyframes blink{from{opacity:.5}to{opacity:1}}.animated{animation:blink .5s infinite alternate}:host{display:inline-block;min-width:4rem}`))]}static get properties(){return i(i({},super.properties),{},{variant:{type:String}})}render(){const e="error"===this.variant?"bg-error-10":"bg-contrast-10",t=null===this.variant?"animated":"";return n(N||(N=z` <div class="relative"> <span class="opacity-0"><slot></slot></span> <div class="${0} ${0} rounded my-xs absolute inset-0"></div> </div> `),e,t)}}let K,G,W,U=e=>e;class Y extends b{constructor(){super(...arguments),this.key=""}static get scopedElements(){return{"x-skeleton":F}}static get properties(){return i(i({},super.properties),{},{key:{type:String,reflect:!0},opts:{type:Object}})}static get styles(){return[super.styles,t(K||(K=U`:host{display:inline-block}`))]}get whenReady(){return this._whenI18nReady.then((()=>this.updateComplete))}render(){return this._isI18nReady?n(G||(G=U`${0}<slot></slot>`),this._t(this.key,this.opts)):n(W||(W=U`<x-skeleton class="block">${0}<slot></slot></x-skeleton>`),this.key)}}function J(...e){return e.filter((e=>!!e))}let Z,X,ee,te,se=e=>e;class ie extends b{constructor(){super(...arguments),this.disabled=!1,this.value=[]}static get scopedElements(){return{"x-i18n":Y}}static get properties(){return i(i({},super.properties),{},{disabled:{type:Boolean},value:{type:Array}})}render(){const e=ie._allDays.map((e=>{try{return e.toLocaleString(this.lang,{minimumIntegerDigits:2})}catch(t){return e.toString()}}));return n(Z||(Z=se` <div class="space-y-s"> <div class="flex flex-wrap -mx-xs -mb-xs" style="max-width:364px;font-feature-settings:'tnum' 1"> ${0} </div> ${0} </div> `),ie._allDays.map(((t,s)=>n(X||(X=se` <label class="${0}"> ${0} <input type="checkbox" class="sr-only" ?disabled="${0}" ?checked="${0}" @change="${0}"> </label> `),this._getLabelClass(t),e[s],this.disabled,this.value.includes(t),(e=>this._handleChange(e,t))))),J(this.value.length>0&&n(ee||(ee=se` <p class="text-s text-tertiary leading-s"> <x-i18n key="monthday-picker.hint" .opts="${0}" .lang="${0}"> </x-i18n> ${0} </p> `),{days:this.value},this.lang,J([29,30,31].some((e=>this.value.includes(e)))&&n(te||(te=se`<x-i18n key="monthday-picker.warning" .lang="${0}"></x-i18n>`),this.lang)))))}_getLabelClass(e){let t="flex items-center justify-center m-xs p-s rounded text-m font-medium transition duration-200 sm-p-0 sm-h-m sm-w-l ";return this.value.includes(e)||(t+="bg-contrast-5 "),this._isI18nReady&&!this.disabled?(t+="cursor-pointer ",t+=this.value.includes(e)?"text-base ":"hover-bg-primary-10 ",e<29?(t+="focus-within-shadow-outline ",t+=this.value.includes(e)?"bg-primary":"text-body"):(t+="focus-within-shadow-outline-error ",t+=this.value.includes(e)?"bg-error":"text-error")):(t+="text-transparent ",this.value.includes(e)&&(t+=e<29?"bg-primary-50":"bg-error-10")),t}_handleChange(e,t){e.stopPropagation(),this._toggle(t),this._sendChange()}_sendChange(){this.dispatchEvent(new w(this.value))}_toggle(e){const t=this.value.indexOf(e);this.value=-1===t?[...this.value,e]:this.value.filter(((e,s)=>s!==t))}}ie._allDays=Array.from(new Array(31),((e,t)=>t+1));const ne=document.createElement("template");function re(e,t,s="long"){const i=new Date;for(;i.getDay()!==e;)i.setDate(i.getDate()+1);return i.toLocaleDateString(t,{weekday:s})}ne.innerHTML='<dom-module id="lumo-badge">\n <template>\n <style>\n [theme~="badge"] {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n padding: 0.4em calc(0.5em + var(--lumo-border-radius-s) / 4);\n color: var(--lumo-primary-text-color);\n background-color: var(--lumo-primary-color-10pct);\n border-radius: var(--lumo-border-radius-s);\n font-family: var(--lumo-font-family);\n font-size: var(--lumo-font-size-s);\n line-height: 1;\n font-weight: 500;\n text-transform: initial;\n letter-spacing: initial;\n min-width: calc(var(--lumo-line-height-xs) * 1em + 0.45em);\n }\n\n /* Ensure proper vertical alignment */\n [theme~="badge"]::before {\n display: inline-block;\n content: "\\2003";\n width: 0;\n }\n\n [theme~="badge"][theme~="small"] {\n font-size: var(--lumo-font-size-xxs);\n line-height: 1;\n }\n\n /* Colors */\n\n [theme~="badge"][theme~="success"] {\n color: var(--lumo-success-text-color);\n background-color: var(--lumo-success-color-10pct);\n }\n\n [theme~="badge"][theme~="error"] {\n color: var(--lumo-error-text-color);\n background-color: var(--lumo-error-color-10pct);\n }\n\n [theme~="badge"][theme~="contrast"] {\n color: var(--lumo-contrast-80pct);\n background-color: var(--lumo-contrast-5pct);\n }\n\n /* Primary */\n\n [theme~="badge"][theme~="primary"] {\n color: var(--lumo-primary-contrast-color);\n background-color: var(--lumo-primary-color);\n }\n\n [theme~="badge"][theme~="success"][theme~="primary"] {\n color: var(--lumo-success-contrast-color);\n background-color: var(--lumo-success-color);\n }\n\n [theme~="badge"][theme~="error"][theme~="primary"] {\n color: var(--lumo-error-contrast-color);\n background-color: var(--lumo-error-color);\n }\n\n [theme~="badge"][theme~="contrast"][theme~="primary"] {\n color: var(--lumo-base-color);\n background-color: var(--lumo-contrast);\n }\n\n /* Links */\n\n [theme~="badge"][href]:hover {\n text-decoration: none;\n }\n\n /* Icon */\n\n [theme~="badge"] iron-icon {\n margin: -0.25em 0;\n --iron-icon-width: 1.5em;\n --iron-icon-height: 1.5em;\n }\n\n [theme~="badge"] iron-icon:first-child {\n margin-left: -0.375em;\n }\n\n [theme~="badge"] iron-icon:last-child {\n margin-right: -0.375em;\n }\n\n [theme~="badge"][icon] {\n min-width: 0;\n padding: 0;\n font-size: 1rem;\n --iron-icon-width: var(--lumo-icon-size-m);\n --iron-icon-height: var(--lumo-icon-size-m);\n }\n\n [theme~="badge"][icon][theme~="small"] {\n --iron-icon-width: var(--lumo-icon-size-s);\n --iron-icon-height: var(--lumo-icon-size-s);\n }\n\n /* Empty */\n\n [theme~="badge"]:not([icon]):empty {\n min-width: 0;\n width: 1em;\n height: 1em;\n padding: 0;\n border-radius: 50%;\n background-color: var(--lumo-primary-color);\n }\n\n [theme~="badge"][theme~="small"]:not([icon]):empty {\n width: 0.75em;\n height: 0.75em;\n }\n\n [theme~="badge"][theme~="contrast"]:not([icon]):empty {\n background-color: var(--lumo-contrast);\n }\n\n [theme~="badge"][theme~="success"]:not([icon]):empty {\n background-color: var(--lumo-success-color);\n }\n\n [theme~="badge"][theme~="error"]:not([icon]):empty {\n background-color: var(--lumo-error-color);\n }\n\n /* Pill */\n\n [theme~="badge"][theme~="pill"] {\n --lumo-border-radius-s: 1em;\n }\n\n /* RTL specific styles */\n\n [dir="rtl"][theme~="badge"] iron-icon:first-child {\n margin-right: -0.375em;\n margin-left: 0;\n }\n\n [dir="rtl"][theme~="badge"] iron-icon:last-child {\n margin-left: -0.375em;\n margin-right: 0;\n }\n </style>\n </template>\n</dom-module>',document.head.appendChild(ne.content);let oe,le,ae,de=e=>e;class Ae extends ie{render(){return n(oe||(oe=de` <div class="space-y-s"> <div class="flex flex-wrap -mx-xs -mb-xs text-m uppercase"> ${0} </div> ${0} </div> `),Ae._allDays.map((e=>n(le||(le=de` <label class="${0}"> ${0} <input type="checkbox" class="sr-only" ?disabled="${0}" ?checked="${0}" @change="${0}"> </label> `),this._getLabelClass(e),re(e,this.lang,"short"),this.disabled||!this._isI18nReady,this.value.includes(e),(t=>this._handleChange(t,e))))),J(this.value.length>0&&n(ae||(ae=de` <p class="text-s text-tertiary leading-s"> <x-i18n key="weekday-picker.hint" .lang="${0}" .opts="${0}"> </x-i18n> </p> `),this.lang,{days:this.value})))}_getLabelClass(e){let t="flex items-center justify-center m-xs h-m w-xl rounded font-medium transition duration-200 ";return this._isI18nReady&&!this.disabled?(t+="cursor-pointer focus-within-shadow-outline ",t+=this.value.includes(e)?"text-base bg-primary":"bg-contrast-5 hover-bg-contrast-10 text-body"):(t+="text-transparent ",t+=this.value.includes(e)?"bg-primary-50":"bg-contrast-5"),t}_sendChange(){this.dispatchEvent(new x(this.value))}}Ae._allDays=new Array(7).fill(0).map(((e,t)=>t));export{j as D,Y as I,ie as M,F as S,Ae as W,Q as a,J as c,$ as r,re as t};
|
|
314
|
+
`)));class j extends s{constructor(){super(),this.disabled=!1,this.label="",this.value=null,this.items=null,this.getText=e=>e,this.__unexistentValue=`@foxy.io/elements#dropdown-${Math.random().toFixed(16).substr(2)}`,this.__renderedItems={},this.__list=document.createElement("vaadin-list-box")}static get properties(){return i(i({},super.properties),{},{disabled:{type:Boolean},getText:{type:Object,attribute:!1},items:{type:Array},label:{type:String},value:{type:String}})}static get styles(){return f.styles}render(){return n(P||(P=H` <vaadin-select class="w-full ${0}" data-testid="select" .label="${0}" .value="${0}" .disabled="${0}" .renderer="${0}" @change="${0}"> </vaadin-select> `),this.label?"-mt-m":"",this.label,null===this.value?this.__unexistentValue:this.value,this.disabled,this.__renderItems.bind(this),this.__handleChange)}__renderItems(e){var t;let s=e.querySelector("vaadin-list-box");null===s&&(e.appendChild(this.__list),s=this.__list);for(const e of Object.values(this.__renderedItems))e.dataset.keep="";const i=null!==(t=this.items)&&void 0!==t?t:[];for(let e=0;e<i.length;++e)if("string"==typeof i[e])this.__addOrKeepItem(i[e],i[e],s).classList.add("dropdown-item");else if(Array.isArray(i[e])){const t=this.__addOrKeepItem(i[e][0],i[e][0],s);t.classList.add("dropdown-item","dropdown-divisor"),t.disabled=!0;for(const t of i[e][1])this.__addOrKeepItem(i[e][0]+": "+t,t,s).classList.add("dropdown-sub-item")}for(const e of Object.values(this.__renderedItems)){const t=e;t.dataset.keep||(e.remove(),delete this.__renderedItems[t.dataset.trackId])}}__addOrKeepItem(e,t,s){let i;return this.__renderedItems[e]?i=this.__renderedItems[e]:(i=document.createElement("vaadin-item"),this.__renderedItems[e]=i,i.value=e,s.appendChild(i)),i.dataset.keep="true",i.dataset.trackId=e,i.textContent=this.getText(t),i}__handleChange(e){const t=e.target.value,s=t===this.__unexistentValue?null:t;this.dispatchEvent(new _(s))}}let V,N,z=e=>e;class K extends s{constructor(){super(...arguments),this.variant=null}static get styles(){return[f.styles,t(V||(V=z`@keyframes blink{from{opacity:.5}to{opacity:1}}.animated{animation:blink .5s infinite alternate}:host{display:inline-block;min-width:4rem}`))]}static get properties(){return i(i({},super.properties),{},{variant:{type:String}})}render(){const e="error"===this.variant?"bg-error-10":"bg-contrast-10",t=null===this.variant?"animated":"";return n(N||(N=z` <div class="relative"> <span class="opacity-0"><slot></slot></span> <div class="${0} ${0} rounded my-xs absolute inset-0"></div> </div> `),e,t)}}let F,G,W,U=e=>e;class Y extends b{constructor(){super(...arguments),this.key=""}static get scopedElements(){return{"x-skeleton":K}}static get properties(){return i(i({},super.properties),{},{key:{type:String,reflect:!0},opts:{type:Object}})}static get styles(){return[super.styles,t(F||(F=U`:host{display:inline-block}`))]}get whenReady(){return this._whenI18nReady.then((()=>this.updateComplete))}render(){return this._isI18nReady?n(G||(G=U`${0}<slot></slot>`),this._t(this.key,this.opts)):n(W||(W=U`<x-skeleton class="block">${0}<slot></slot></x-skeleton>`),this.key)}}function J(...e){return e.filter((e=>!!e))}let Z,X,ee,te,se=e=>e;class ie extends b{constructor(){super(...arguments),this.disabled=!1,this.value=[]}static get scopedElements(){return{"x-i18n":Y}}static get properties(){return i(i({},super.properties),{},{disabled:{type:Boolean},value:{type:Array}})}render(){const e=ie._allDays.map((e=>{try{return e.toLocaleString(this.lang,{minimumIntegerDigits:2})}catch(t){return e.toString()}}));return n(Z||(Z=se` <div class="space-y-s"> <div class="flex flex-wrap -mx-xs -mb-xs" style="max-width:364px;font-feature-settings:'tnum' 1"> ${0} </div> ${0} </div> `),ie._allDays.map(((t,s)=>n(X||(X=se` <label class="${0}"> ${0} <input type="checkbox" class="sr-only" ?disabled="${0}" ?checked="${0}" @change="${0}"> </label> `),this._getLabelClass(t),e[s],this.disabled,this.value.includes(t),(e=>this._handleChange(e,t))))),J(this.value.length>0&&n(ee||(ee=se` <p class="text-s text-tertiary leading-s"> <x-i18n key="monthday-picker.hint" .opts="${0}" .lang="${0}"> </x-i18n> ${0} </p> `),{days:this.value},this.lang,J([29,30,31].some((e=>this.value.includes(e)))&&n(te||(te=se`<x-i18n key="monthday-picker.warning" .lang="${0}"></x-i18n>`),this.lang)))))}_getLabelClass(e){let t="flex items-center justify-center m-xs p-s rounded text-m font-medium transition duration-200 sm-p-0 sm-h-m sm-w-l ";return this.value.includes(e)||(t+="bg-contrast-5 "),this._isI18nReady&&!this.disabled?(t+="cursor-pointer ",t+=this.value.includes(e)?"text-base ":"hover-bg-primary-10 ",e<29?(t+="focus-within-shadow-outline ",t+=this.value.includes(e)?"bg-primary":"text-body"):(t+="focus-within-shadow-outline-error ",t+=this.value.includes(e)?"bg-error":"text-error")):(t+="text-transparent ",this.value.includes(e)&&(t+=e<29?"bg-primary-50":"bg-error-10")),t}_handleChange(e,t){e.stopPropagation(),this._toggle(t),this._sendChange()}_sendChange(){this.dispatchEvent(new w(this.value))}_toggle(e){const t=this.value.indexOf(e);this.value=-1===t?[...this.value,e]:this.value.filter(((e,s)=>s!==t))}}ie._allDays=Array.from(new Array(31),((e,t)=>t+1));const ne=document.createElement("template");function re(e,t,s="long"){const i=new Date;for(;i.getDay()!==e;)i.setDate(i.getDate()+1);return i.toLocaleDateString(t,{weekday:s})}ne.innerHTML='<dom-module id="lumo-badge">\n <template>\n <style>\n [theme~="badge"] {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n padding: 0.4em calc(0.5em + var(--lumo-border-radius-s) / 4);\n color: var(--lumo-primary-text-color);\n background-color: var(--lumo-primary-color-10pct);\n border-radius: var(--lumo-border-radius-s);\n font-family: var(--lumo-font-family);\n font-size: var(--lumo-font-size-s);\n line-height: 1;\n font-weight: 500;\n text-transform: initial;\n letter-spacing: initial;\n min-width: calc(var(--lumo-line-height-xs) * 1em + 0.45em);\n }\n\n /* Ensure proper vertical alignment */\n [theme~="badge"]::before {\n display: inline-block;\n content: "\\2003";\n width: 0;\n }\n\n [theme~="badge"][theme~="small"] {\n font-size: var(--lumo-font-size-xxs);\n line-height: 1;\n }\n\n /* Colors */\n\n [theme~="badge"][theme~="success"] {\n color: var(--lumo-success-text-color);\n background-color: var(--lumo-success-color-10pct);\n }\n\n [theme~="badge"][theme~="error"] {\n color: var(--lumo-error-text-color);\n background-color: var(--lumo-error-color-10pct);\n }\n\n [theme~="badge"][theme~="contrast"] {\n color: var(--lumo-contrast-80pct);\n background-color: var(--lumo-contrast-5pct);\n }\n\n /* Primary */\n\n [theme~="badge"][theme~="primary"] {\n color: var(--lumo-primary-contrast-color);\n background-color: var(--lumo-primary-color);\n }\n\n [theme~="badge"][theme~="success"][theme~="primary"] {\n color: var(--lumo-success-contrast-color);\n background-color: var(--lumo-success-color);\n }\n\n [theme~="badge"][theme~="error"][theme~="primary"] {\n color: var(--lumo-error-contrast-color);\n background-color: var(--lumo-error-color);\n }\n\n [theme~="badge"][theme~="contrast"][theme~="primary"] {\n color: var(--lumo-base-color);\n background-color: var(--lumo-contrast);\n }\n\n /* Links */\n\n [theme~="badge"][href]:hover {\n text-decoration: none;\n }\n\n /* Icon */\n\n [theme~="badge"] iron-icon {\n margin: -0.25em 0;\n --iron-icon-width: 1.5em;\n --iron-icon-height: 1.5em;\n }\n\n [theme~="badge"] iron-icon:first-child {\n margin-left: -0.375em;\n }\n\n [theme~="badge"] iron-icon:last-child {\n margin-right: -0.375em;\n }\n\n [theme~="badge"][icon] {\n min-width: 0;\n padding: 0;\n font-size: 1rem;\n --iron-icon-width: var(--lumo-icon-size-m);\n --iron-icon-height: var(--lumo-icon-size-m);\n }\n\n [theme~="badge"][icon][theme~="small"] {\n --iron-icon-width: var(--lumo-icon-size-s);\n --iron-icon-height: var(--lumo-icon-size-s);\n }\n\n /* Empty */\n\n [theme~="badge"]:not([icon]):empty {\n min-width: 0;\n width: 1em;\n height: 1em;\n padding: 0;\n border-radius: 50%;\n background-color: var(--lumo-primary-color);\n }\n\n [theme~="badge"][theme~="small"]:not([icon]):empty {\n width: 0.75em;\n height: 0.75em;\n }\n\n [theme~="badge"][theme~="contrast"]:not([icon]):empty {\n background-color: var(--lumo-contrast);\n }\n\n [theme~="badge"][theme~="success"]:not([icon]):empty {\n background-color: var(--lumo-success-color);\n }\n\n [theme~="badge"][theme~="error"]:not([icon]):empty {\n background-color: var(--lumo-error-color);\n }\n\n /* Pill */\n\n [theme~="badge"][theme~="pill"] {\n --lumo-border-radius-s: 1em;\n }\n\n /* RTL specific styles */\n\n [dir="rtl"][theme~="badge"] iron-icon:first-child {\n margin-right: -0.375em;\n margin-left: 0;\n }\n\n [dir="rtl"][theme~="badge"] iron-icon:last-child {\n margin-left: -0.375em;\n margin-right: 0;\n }\n </style>\n </template>\n</dom-module>',document.head.appendChild(ne.content);let oe,le,ae,de=e=>e;class Ae extends ie{render(){return n(oe||(oe=de` <div class="space-y-s"> <div class="flex flex-wrap -mx-xs -mb-xs text-m uppercase"> ${0} </div> ${0} </div> `),Ae._allDays.map((e=>n(le||(le=de` <label class="${0}"> ${0} <input type="checkbox" class="sr-only" ?disabled="${0}" ?checked="${0}" @change="${0}"> </label> `),this._getLabelClass(e),re(e,this.lang,"short"),this.disabled||!this._isI18nReady,this.value.includes(e),(t=>this._handleChange(t,e))))),J(this.value.length>0&&n(ae||(ae=de` <p class="text-s text-tertiary leading-s"> <x-i18n key="weekday-picker.hint" .lang="${0}" .opts="${0}"> </x-i18n> </p> `),this.lang,{days:this.value})))}_getLabelClass(e){let t="flex items-center justify-center m-xs h-m w-xl rounded font-medium transition duration-200 ";return this._isI18nReady&&!this.disabled?(t+="cursor-pointer focus-within-shadow-outline ",t+=this.value.includes(e)?"text-base bg-primary":"bg-contrast-5 hover-bg-contrast-10 text-body"):(t+="text-transparent ",t+=this.value.includes(e)?"bg-primary-50":"bg-contrast-5"),t}_sendChange(){this.dispatchEvent(new x(this.value))}}Ae._allDays=new Array(7).fill(0).map(((e,t)=>t));export{j as D,Y as I,ie as M,K as S,Ae as W,Q as a,J as c,$ as r,re as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{E as e,C as t,T as o}from"./shared-
|
|
1
|
+
import{E as e,C as t,T as o}from"./shared-8b20bc23.js";import{h as i,G as r,P as a}from"./shared-ff79f3f9.js";const s=i`<dom-module id="lumo-checkbox" theme-for="vaadin-checkbox">
|
|
2
2
|
<template>
|
|
3
3
|
<style include="lumo-checkbox-style lumo-checkbox-effects">
|
|
4
4
|
/* IE11 only */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{T as e,D as t,E as i,C as s}from"./shared-
|
|
1
|
+
import{T as e,D as t,E as i,C as s}from"./shared-8b20bc23.js";import{h as o,P as n,a as r,t as a,F as l,b as h,q as d,i as c,e as u,I as _,J as m}from"./shared-ff79f3f9.js";import"./shared-a040d79d.js";import{t as p,m as v,F as f,P as g,f as y,d as b,O as I,D as x,a as w}from"./shared-46ee137f.js";
|
|
2
2
|
/**
|
|
3
3
|
@license
|
|
4
4
|
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
@@ -372,7 +372,7 @@ found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
|
|
|
372
372
|
part of the polymer project is also subject to an additional IP rights grant
|
|
373
373
|
found at http://polymer.github.io/PATENTS.txt
|
|
374
374
|
*/
|
|
375
|
-
var U={"U+0008":"backspace","U+0009":"tab","U+001B":"esc","U+0020":"space","U+007F":"del"},Y={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:"*"},G={shift:"shiftKey",ctrl:"ctrlKey",alt:"altKey",meta:"metaKey"},X=/[a-z0-9*]/,J=/U\+/,Q=/^arrow/,Z=/^space(bar)?/,ee=/^escape$/;function te(e,t){var i="";if(e){var s=e.toLowerCase();" "===s||Z.test(s)?i="space":ee.test(s)?i="esc":1==s.length?t&&!X.test(s)||(i=s):i=Q.test(s)?s.replace("arrow",""):"multiply"==s?"*":s}return i}function ie(e,t){return e.key?te(e.key,t):e.detail&&e.detail.key?te(e.detail.key,t):(i=e.keyIdentifier,s="",i&&(i in U?s=U[i]:J.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):Y[e]),t}(e.keyCode)||"");var i,s}function se(e,t){return ie(t,e.hasModifiers)===e.key&&(!e.hasModifiers||!!t.shiftKey==!!e.shiftKey&&!!t.ctrlKey==!!e.ctrlKey&&!!t.altKey==!!e.altKey&&!!t.metaKey==!!e.metaKey)}function oe(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 G?(e[G[s]]=!0,e.hasModifiers=!0):(e.key=s,e.event=o||"keydown"),e}),{combo:e.split(":").shift()})}(e)}))}const ne={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=oe(t),s=0;s<i.length;++s)if(se(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){oe(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(se(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()}},re=class{toString(){return""}},ae=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},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)"]}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,W.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 f(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 ne.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.value=""),this._detectAndDispatchChange()}cancel(){this._revertInputValueToValue(),this._lastCommittedValue=this.value,this._closeOrCommit()}_onOpened(){y(),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.filteredItems.filter((t=>e(this._getItemLabel(t))===e(this._inputElementValue)))||[];if(this.allowCustomValue&&!t.length){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.length>0?this.value=this._getItemValue(t[0]):this._inputElementValue=this.selectedItem?this._getItemLabel(this.selectedItem):this.value||""}this._detectAndDispatchChange(),this._clearSelectionRange(),this.dataProvider||(this.filter="")}get _propertyForValue(){return"value"}_inputValueChanged(e){-1!==e.composedPath().indexOf(this.inputElement)&&(this._inputElementValue=this.inputElement[this._propertyForValue],this._filterFromInput(e))}_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.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=r.debounce(this.__repositionOverlayDebouncer,a.after(500),(()=>{const e=this.$.overlay._selector;e._isClientFull()||e._resetScrollPosition(e._physicalTop),this._resizeDropdown(),this.$.overlay.updateViewportBoundaries(),this.$.overlay.ensureItemsRendered(),e.notifyResize(),y()}))}_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 re||(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()}_onTouchend(e){this._clearElement&&e.composedPath()[0]===this._clearElement&&(e.preventDefault(),this._clear())}validate(){return!(this.invalid=!this.checkValidity())}checkValidity(){if(this.inputElement.validate)return this.inputElement.validate()}get _instanceProps(){return{item:!0,index:!0,selected:!0,focused:!0}}_ensureTemplatized(){if(!this._TemplateClass){const e=this._itemTemplate||this._getRootTemplate();e&&(this._TemplateClass=p(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()}}
|
|
375
|
+
var U={"U+0008":"backspace","U+0009":"tab","U+001B":"esc","U+0020":"space","U+007F":"del"},Y={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:"*"},G={shift:"shiftKey",ctrl:"ctrlKey",alt:"altKey",meta:"metaKey"},X=/[a-z0-9*]/,J=/U\+/,Q=/^arrow/,Z=/^space(bar)?/,ee=/^escape$/;function te(e,t){var i="";if(e){var s=e.toLowerCase();" "===s||Z.test(s)?i="space":ee.test(s)?i="esc":1==s.length?t&&!X.test(s)||(i=s):i=Q.test(s)?s.replace("arrow",""):"multiply"==s?"*":s}return i}function ie(e,t){return e.key?te(e.key,t):e.detail&&e.detail.key?te(e.detail.key,t):(i=e.keyIdentifier,s="",i&&(i in U?s=U[i]:J.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):Y[e]),t}(e.keyCode)||"");var i,s}function se(e,t){return ie(t,e.hasModifiers)===e.key&&(!e.hasModifiers||!!t.shiftKey==!!e.shiftKey&&!!t.ctrlKey==!!e.ctrlKey&&!!t.altKey==!!e.altKey&&!!t.metaKey==!!e.metaKey)}function oe(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 G?(e[G[s]]=!0,e.hasModifiers=!0):(e.key=s,e.event=o||"keydown"),e}),{combo:e.split(":").shift()})}(e)}))}const ne={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=oe(t),s=0;s<i.length;++s)if(se(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){oe(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(se(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()}},re=class{toString(){return""}},ae=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},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)"]}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,W.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 f(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 ne.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.value=""),this._detectAndDispatchChange()}cancel(){this._revertInputValueToValue(),this._lastCommittedValue=this.value,this._closeOrCommit()}_onOpened(){y(),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)&&(this._inputElementValue=this.inputElement[this._propertyForValue],this._filterFromInput(e))}_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.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=r.debounce(this.__repositionOverlayDebouncer,a.after(500),(()=>{const e=this.$.overlay._selector;e._isClientFull()||e._resetScrollPosition(e._physicalTop),this._resizeDropdown(),this.$.overlay.updateViewportBoundaries(),this.$.overlay.ensureItemsRendered(),e.notifyResize(),y()}))}_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 re||(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()}_onTouchend(e){this._clearElement&&e.composedPath()[0]===this._clearElement&&(e.preventDefault(),this._clear())}validate(){return!(this.invalid=!this.checkValidity())}checkValidity(){if(this.inputElement.validate)return this.inputElement.validate()}get _instanceProps(){return{item:!0,index:!0,selected:!0,focused:!0}}_ensureTemplatized(){if(!this._TemplateClass){const e=this._itemTemplate||this._getRootTemplate();e&&(this._TemplateClass=p(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()}}
|
|
376
376
|
/**
|
|
377
377
|
@license
|
|
378
378
|
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
|
@@ -553,4 +553,4 @@ This program is available under Apache License Version 2.0, available at https:/
|
|
|
553
553
|
|
|
554
554
|
<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]]">
|
|
555
555
|
</vaadin-combo-box-dropdown-wrapper>
|
|
556
|
-
`}constructor(){super(),this.theme}static get is(){return"vaadin-combo-box"}static get version(){return"5.4.
|
|
556
|
+
`}constructor(){super(),this.theme}static get is(){return"vaadin-combo-box"}static get version(){return"5.4.12"}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._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(Ie.is,Ie);export{he as I,$ as O,V as a,W as b,ne as c};
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"back": "Back",
|
|
21
21
|
"backend_developer": "Backend developer",
|
|
22
22
|
"backend_developer_explainer": "Manages server-side code in PHP, Python, Ruby, etc.",
|
|
23
|
+
"balance": "Balance",
|
|
23
24
|
"billing": "Billing",
|
|
24
25
|
"block": "Block",
|
|
25
26
|
"blocklist": "Ban all except",
|
|
@@ -282,7 +283,7 @@
|
|
|
282
283
|
"error": "Error",
|
|
283
284
|
"expires": "Expires",
|
|
284
285
|
"expires_after": "Expires after",
|
|
285
|
-
"expires_after_value": "Expires {{value}}",
|
|
286
|
+
"expires_after_value": "Expires {{value, relative}}",
|
|
286
287
|
"field": "Field",
|
|
287
288
|
"field_plural": "Fields",
|
|
288
289
|
"filter": "Filter",
|
|
@@ -537,6 +538,7 @@
|
|
|
537
538
|
"uses_to_total_count": "{{count}}/{{total}} uses",
|
|
538
539
|
"v8n_format_error": "Invalid format",
|
|
539
540
|
"v8n_invalid_email": "Invalid email",
|
|
541
|
+
"v8n_negative": "Negative values are not allowed",
|
|
540
542
|
"v8n_required": "Required",
|
|
541
543
|
"v8n_too_long": "Too long",
|
|
542
544
|
"value": "Value",
|
|
@@ -62,7 +62,7 @@ export class CouponCard extends Base {
|
|
|
62
62
|
const count = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.number_of_uses_to_date) !== null && _b !== void 0 ? _b : 0;
|
|
63
63
|
const total = (_d = (_c = this.data) === null || _c === void 0 ? void 0 : _c.number_of_uses_allowed) !== null && _d !== void 0 ? _d : 0;
|
|
64
64
|
return html `
|
|
65
|
-
<div>
|
|
65
|
+
<div data-testid="title">
|
|
66
66
|
${this.renderTemplateOrSlot('title:before')}
|
|
67
67
|
|
|
68
68
|
<div class="flex items-center justify-between">
|
|
@@ -98,7 +98,7 @@ export class CouponCard extends Base {
|
|
|
98
98
|
`;
|
|
99
99
|
}
|
|
100
100
|
return html `
|
|
101
|
-
<div>
|
|
101
|
+
<div data-testid="description">
|
|
102
102
|
${this.renderTemplateOrSlot('description:before')}
|
|
103
103
|
<div class="truncate text-s text-secondary">${summary !== null && summary !== void 0 ? summary : html `​`}</div>
|
|
104
104
|
${this.renderTemplateOrSlot('description:after')}
|
|
@@ -110,7 +110,7 @@ export class CouponCard extends Base {
|
|
|
110
110
|
const { start_date: start, end_date: end } = (_a = this.data) !== null && _a !== void 0 ? _a : {};
|
|
111
111
|
const type = start && end ? 'complete' : start ? 'from' : end ? 'until' : 'any';
|
|
112
112
|
return html `
|
|
113
|
-
<div>
|
|
113
|
+
<div data-testid="status">
|
|
114
114
|
${this.renderTemplateOrSlot('status:before')}
|
|
115
115
|
|
|
116
116
|
<foxy-i18n
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CouponCard.js","sourceRoot":"","sources":["../../../../src/elements/public/CouponCard/CouponCard.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAClE,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AAEpD,MAAM,EAAE,GAAG,aAAa,CAAC;AACzB,MAAM,IAAI,GAAG,cAAc,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AAEtF;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,UAAW,SAAQ,IAAU;IAA1C;;QACE,cAAS,GAAc,EAAE,CAAC;IA8G5B,CAAC;IA5GC,MAAM;;QACJ,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QAE3C,OAAO,IAAI,CAAA;;oBAEK,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;;;;qBAId,QAAQ,CAAC,EAAE,oBAAoB,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YAC1E,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE;YAC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CAAC,cAAc,CAAC;;KAE9C,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { Data, Templates } from './types';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\n\nconst NS = 'coupon-card';\nconst Base = ThemeableMixin(ConfigurableMixin(TranslatableMixin(NucleonElement, NS)));\n\n/**\n * Basic card displaying a coupon.\n *\n * @slot title:before\n * @slot title:after\n * @slot description:before\n * @slot description:after\n * @slot status:before\n * @slot status:after\n *\n * @element foxy-coupon-card\n * @since 1.15.0\n */\nexport class CouponCard extends Base<Data> {\n templates: Templates = {};\n\n render(): TemplateResult {\n const hiddenSelector = this.hiddenSelector;\n\n return html`\n <div\n aria-busy=${this.in('busy')}\n aria-live=\"polite\"\n class=\"relative leading-m font-lumo text-m\"\n >\n <div class=${classMap({ 'transition-opacity': true, 'opacity-0': !this.data })}>\n ${hiddenSelector.matches('title', true) ? '' : this.__renderTitle()}\n ${hiddenSelector.matches('description', true) ? '' : this.__renderDescription()}\n ${hiddenSelector.matches('status', true) ? '' : this.__renderStatus()}\n </div>\n\n <div\n class=${classMap({\n 'pointer-events-none absolute inset-0 flex transition-opacity': true,\n 'opacity-0': !!this.data,\n })}\n >\n <foxy-spinner\n data-testid=\"spinner\"\n state=${this.in('fail') ? 'error' : this.in({ idle: 'template' }) ? 'empty' : 'busy'}\n class=\"m-auto\"\n lang=${this.lang}\n ns=\"${this.ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n private __renderTitle() {\n const count = this.data?.number_of_uses_to_date ?? 0;\n const total = this.data?.number_of_uses_allowed ?? 0;\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('title:before')}\n\n <div class=\"flex items-center justify-between\">\n <div class=\"font-semibold truncate\">${this.data?.name ?? html`​`}</div>\n\n <foxy-i18n\n options=${JSON.stringify({ count, total })}\n class=\"text-tertiary text-s flex-shrink-0\"\n lang=${this.lang}\n key=${total === 0 ? 'uses_count' : 'uses_to_total_count'}\n ns=${this.ns}\n >\n </foxy-i18n>\n </div>\n\n ${this.renderTemplateOrSlot('title:after')}\n </div>\n `;\n }\n\n private __renderDescription() {\n let summary: TemplateResult | null = null;\n\n if (this.data) {\n const details = this.data.coupon_discount_details;\n const type = this.data.coupon_discount_type;\n\n summary = html`\n <foxy-i18n\n options=${JSON.stringify({ params: { details, type } })}\n lang=${this.lang}\n key=\"discount_summary\"\n ns=${this.ns}\n >\n </foxy-i18n>\n `;\n }\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('description:before')}\n <div class=\"truncate text-s text-secondary\">${summary ?? html`​`}</div>\n ${this.renderTemplateOrSlot('description:after')}\n </div>\n `;\n }\n\n private __renderStatus() {\n const { start_date: start, end_date: end } = this.data ?? {};\n const type = start && end ? 'complete' : start ? 'from' : end ? 'until' : 'any';\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('status:before')}\n\n <foxy-i18n\n options=${JSON.stringify({ start, end })}\n class=\"block truncate text-s text-tertiary\"\n lang=${this.lang}\n key=\"date_range_${type}\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n ${this.renderTemplateOrSlot('status:after')}\n </div>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CouponCard.js","sourceRoot":"","sources":["../../../../src/elements/public/CouponCard/CouponCard.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAClE,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,QAAQ,EAAE,oCAAi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AAI,CAAC,oBAAoB,CAAC,mBAAmB,CAAC;;KAEnD,CAAC;IACJ,CAAC;IAEO,cAAc;;QACpB,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAG,IAAI,CAAC,IAAI,mCAAI,EAAE,CAAC;QAC7D,MAAM,IAAI,GAAG,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;QAEhF,OAAO,IAAI,CAAA;;UAEL,IAAI,CAAC,oBAAoB,CAAC,eAAe,CAAC;;;oBAGhC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;;iBAEjC,IAAI,CAAC,IAAI;4BACE,IAAI;eACjB,IAAI,CAAC,EAAE;;;;UAIZ,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC;;KAE9C,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { Data, Templates } from './types';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\n\nconst NS = 'coupon-card';\nconst Base = ThemeableMixin(ConfigurableMixin(TranslatableMixin(NucleonElement, NS)));\n\n/**\n * Basic card displaying a coupon.\n *\n * @slot title:before\n * @slot title:after\n * @slot description:before\n * @slot description:after\n * @slot status:before\n * @slot status:after\n *\n * @element foxy-coupon-card\n * @since 1.15.0\n */\nexport class CouponCard extends Base<Data> {\n templates: Templates = {};\n\n render(): TemplateResult {\n const hiddenSelector = this.hiddenSelector;\n\n return html`\n <div\n aria-busy=${this.in('busy')}\n aria-live=\"polite\"\n class=\"relative leading-m font-lumo text-m\"\n >\n <div class=${classMap({ 'transition-opacity': true, 'opacity-0': !this.data })}>\n ${hiddenSelector.matches('title', true) ? '' : this.__renderTitle()}\n ${hiddenSelector.matches('description', true) ? '' : this.__renderDescription()}\n ${hiddenSelector.matches('status', true) ? '' : this.__renderStatus()}\n </div>\n\n <div\n class=${classMap({\n 'pointer-events-none absolute inset-0 flex transition-opacity': true,\n 'opacity-0': !!this.data,\n })}\n >\n <foxy-spinner\n data-testid=\"spinner\"\n state=${this.in('fail') ? 'error' : this.in({ idle: 'template' }) ? 'empty' : 'busy'}\n class=\"m-auto\"\n lang=${this.lang}\n ns=\"${this.ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n private __renderTitle() {\n const count = this.data?.number_of_uses_to_date ?? 0;\n const total = this.data?.number_of_uses_allowed ?? 0;\n\n return html`\n <div data-testid=\"title\">\n ${this.renderTemplateOrSlot('title:before')}\n\n <div class=\"flex items-center justify-between\">\n <div class=\"font-semibold truncate\">${this.data?.name ?? html`​`}</div>\n\n <foxy-i18n\n options=${JSON.stringify({ count, total })}\n class=\"text-tertiary text-s flex-shrink-0\"\n lang=${this.lang}\n key=${total === 0 ? 'uses_count' : 'uses_to_total_count'}\n ns=${this.ns}\n >\n </foxy-i18n>\n </div>\n\n ${this.renderTemplateOrSlot('title:after')}\n </div>\n `;\n }\n\n private __renderDescription() {\n let summary: TemplateResult | null = null;\n\n if (this.data) {\n const details = this.data.coupon_discount_details;\n const type = this.data.coupon_discount_type;\n\n summary = html`\n <foxy-i18n\n options=${JSON.stringify({ params: { details, type } })}\n lang=${this.lang}\n key=\"discount_summary\"\n ns=${this.ns}\n >\n </foxy-i18n>\n `;\n }\n\n return html`\n <div data-testid=\"description\">\n ${this.renderTemplateOrSlot('description:before')}\n <div class=\"truncate text-s text-secondary\">${summary ?? html`​`}</div>\n ${this.renderTemplateOrSlot('description:after')}\n </div>\n `;\n }\n\n private __renderStatus() {\n const { start_date: start, end_date: end } = this.data ?? {};\n const type = start && end ? 'complete' : start ? 'from' : end ? 'until' : 'any';\n\n return html`\n <div data-testid=\"status\">\n ${this.renderTemplateOrSlot('status:before')}\n\n <foxy-i18n\n options=${JSON.stringify({ start, end })}\n class=\"block truncate text-s text-tertiary\"\n lang=${this.lang}\n key=\"date_range_${type}\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n ${this.renderTemplateOrSlot('status:after')}\n </div>\n `;\n }\n}\n"]}
|
|
@@ -125,7 +125,7 @@ export class CouponCodeForm extends Base {
|
|
|
125
125
|
>
|
|
126
126
|
</vaadin-text-field>
|
|
127
127
|
|
|
128
|
-
${this.renderTemplateOrSlot('
|
|
128
|
+
${this.renderTemplateOrSlot('code:after')}
|
|
129
129
|
</div>
|
|
130
130
|
`;
|
|
131
131
|
}
|
|
@@ -169,7 +169,7 @@ export class CouponCodeForm extends Base {
|
|
|
169
169
|
class="w-full"
|
|
170
170
|
theme="primary success"
|
|
171
171
|
?disabled=${isBusy || isInvalid || this.disabledSelector.matches('create', true)}
|
|
172
|
-
@click=${this.submit}
|
|
172
|
+
@click=${() => this.submit()}
|
|
173
173
|
>
|
|
174
174
|
<foxy-i18n ns=${this.ns} key="create" lang=${this.lang}></foxy-i18n>
|
|
175
175
|
</vaadin-button>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CouponCodeForm.js","sourceRoot":"","sources":["../../../../src/elements/public/CouponCodeForm/CouponCodeForm.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAGjE,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAElE,OAAO,EAAE,aAAa,EAAE,+BAA4B;AAEpD,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB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AAC;YACnF,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,aAA8B,CAAC,CAAC;QACnD,CAAC;;0BAEe,IAAI,CAAC,EAAE,sBAAsB,IAAI,CAAC,IAAI;;;UAGtD,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC;;KAE9C,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { Data, Templates } from './types';\nimport { ScopedElementsMap, ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { ButtonElement } from '@vaadin/vaadin-button';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { DialogHideEvent } from '../../private/Dialog/DialogHideEvent';\nimport { InternalConfirmDialog } from '../../internal/InternalConfirmDialog/InternalConfirmDialog';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { NucleonV8N } from '../NucleonElement/types';\nimport { PropertyTable } from '../../private/index';\nimport { TextFieldElement } from '@vaadin/vaadin-text-field';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { ifDefined } from 'lit-html/directives/if-defined';\n\nconst NS = 'coupon-code-form';\nconst Base = ConfigurableMixin(\n ThemeableMixin(ScopedElementsMixin(TranslatableMixin(NucleonElement, NS)))\n);\n\n/**\n * Form element for creating or editing coupon codes (`fx:coupon_code`).\n *\n * @slot code:before\n * @slot code:after\n *\n * @slot timestamps:before\n * @slot timestamps:after\n *\n * @slot delete:before\n * @slot delete:after\n *\n * @slot create:before\n * @slot create:after\n *\n * @element foxy-coupon-code-form\n * @since 1.15.0\n */\nexport class CouponCodeForm extends Base<Data> {\n static get scopedElements(): ScopedElementsMap {\n return {\n 'vaadin-text-field': customElements.get('vaadin-text-field'),\n 'vaadin-button': customElements.get('vaadin-button'),\n\n 'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n\n 'x-property-table': PropertyTable,\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ code: v }) => !!v || 'code_required',\n ({ code: v }) => !v || v.length <= 50 || 'code_too_long',\n ];\n }\n\n templates: Templates = {};\n\n render(): TemplateResult {\n return html`\n <div class=\"relative space-y-m\">\n ${this.__isCodeHidden ? null : this.__renderCode()}\n ${this.__isTimestampsHidden ? null : this.__renderTimestamps()}\n ${this.__isCreateHidden ? null : this.__renderCreate()}\n ${this.__isDeleteHidden ? null : this.__renderDelete()}\n\n <div\n data-testid=\"spinner\"\n class=${classMap({\n 'transition duration-500 ease-in-out absolute inset-0 flex': true,\n 'opacity-0 pointer-events-none': !this.in('busy') && !this.in('fail'),\n })}\n >\n <foxy-spinner\n layout=\"vertical\"\n class=\"m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l\"\n state=${this.in('fail') ? 'error' : this.in('busy') ? 'busy' : 'empty'}\n lang=${this.lang}\n ns=\"${this.ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n private get __isCodeHidden(): boolean {\n return this.hiddenSelector.matches('code', true);\n }\n\n private get __isTimestampsHidden(): boolean {\n if (this.hiddenSelector.matches('timestamps', true)) return true;\n return !this.data;\n }\n\n private get __isCreateHidden(): boolean {\n if (this.hiddenSelector.matches('create', true)) return true;\n return !!this.data;\n }\n\n private get __isDeleteHidden(): boolean {\n if (this.hiddenSelector.matches('delete', true)) return true;\n return !this.data;\n }\n\n private __getErrorMessage(prefix: string) {\n const error = this.errors.find(err => err.startsWith(prefix));\n return error ? this.t(error.replace(prefix, 'v8n')).toString() : '';\n }\n\n private __getValidator(prefix: string) {\n return () => !this.errors.some(err => err.startsWith(prefix));\n }\n\n private __renderCode(): TemplateResult {\n return html`\n <div>\n ${this.renderTemplateOrSlot('code:before')}\n\n <vaadin-text-field\n data-testid=\"code\"\n class=\"w-full\"\n label=${this.t('code')}\n value=${ifDefined(this.form.code)}\n .checkValidity=${this.__getValidator('code')}\n .errorMessage=${this.__getErrorMessage('code')}\n ?disabled=${this.in('busy') || this.disabledSelector.matches('code', true)}\n ?readonly=${this.readonlySelector.matches('code', true)}\n required\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.submit()}\n @input=${(evt: CustomEvent) => {\n const newCode = (evt.currentTarget as TextFieldElement).value;\n this.edit({ code: newCode });\n }}\n >\n </vaadin-text-field>\n\n ${this.renderTemplateOrSlot('name:after')}\n </div>\n `;\n }\n\n private __renderTimestamps(): TemplateResult {\n return html`\n <div>\n ${this.renderTemplateOrSlot('timestamps:before')}\n\n <x-property-table\n data-testid=\"timestamps\"\n .items=${(['date_modified', 'date_created'] as const).map(field => ({\n name: this.t(field),\n value: this.data?.[field]\n ? this.t('date', { value: new Date(this.data[field] as string) })\n : '',\n }))}\n >\n </x-property-table>\n\n ${this.renderTemplateOrSlot('timestamps:after')}\n </div>\n `;\n }\n\n private __renderCreate(): TemplateResult {\n const isCleanTemplateInvalid = this.in({ idle: { template: { clean: 'invalid' } } });\n const isDirtyTemplateInvalid = this.in({ idle: { template: { dirty: 'invalid' } } });\n const isCleanSnapshotInvalid = this.in({ idle: { snapshot: { clean: 'invalid' } } });\n const isDirtySnapshotInvalid = this.in({ idle: { snapshot: { dirty: 'invalid' } } });\n const isTemplateInvalid = isCleanTemplateInvalid || isDirtyTemplateInvalid;\n const isSnaphotInvalid = isCleanSnapshotInvalid || isDirtySnapshotInvalid;\n const isInvalid = isTemplateInvalid || isSnaphotInvalid;\n const isBusy = this.in('busy');\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('create:before')}\n\n <vaadin-button\n data-testid=\"create\"\n class=\"w-full\"\n theme=\"primary success\"\n ?disabled=${isBusy || isInvalid || this.disabledSelector.matches('create', true)}\n @click=${this.submit}\n >\n <foxy-i18n ns=${this.ns} key=\"create\" lang=${this.lang}></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot('create:after')}\n </div>\n `;\n }\n\n private __renderDelete(): TemplateResult {\n return html`\n <div>\n <foxy-internal-confirm-dialog\n data-testid=\"confirm\"\n message=\"delete_prompt\"\n confirm=\"delete\"\n cancel=\"cancel\"\n header=\"delete\"\n theme=\"primary error\"\n lang=${this.lang}\n ns=${this.ns}\n id=\"confirm\"\n @hide=${(evt: DialogHideEvent) => !evt.detail.cancelled && this.delete()}\n >\n </foxy-internal-confirm-dialog>\n\n ${this.renderTemplateOrSlot('delete:before')}\n\n <vaadin-button\n data-testid=\"delete\"\n theme=\"primary error\"\n class=\"w-full\"\n ?disabled=${this.in('busy') || this.disabledSelector.matches('delete', true)}\n @click=${(evt: CustomEvent) => {\n const confirm = this.renderRoot.querySelector('#confirm') as InternalConfirmDialog;\n confirm.show(evt.currentTarget as ButtonElement);\n }}\n >\n <foxy-i18n ns=${this.ns} key=\"delete\" lang=${this.lang}></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot('delete:after')}\n </div>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CouponCodeForm.js","sourceRoot":"","sources":["../../../../src/elements/public/CouponCodeForm/CouponCodeForm.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAGjE,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAElE,OAAO,EAAE,aAAa,EAAE,+BAA4B;AAEpD,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,MAAM,EAAE,GAAG,kBAAkB,CAAC;AA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,IAAI;;;UAGtD,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC;;KAE9C,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { Data, Templates } from './types';\nimport { ScopedElementsMap, ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { TemplateResult, html } from 'lit-html';\n\nimport { ButtonElement } from '@vaadin/vaadin-button';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { DialogHideEvent } from '../../private/Dialog/DialogHideEvent';\nimport { InternalConfirmDialog } from '../../internal/InternalConfirmDialog/InternalConfirmDialog';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { NucleonV8N } from '../NucleonElement/types';\nimport { PropertyTable } from '../../private/index';\nimport { TextFieldElement } from '@vaadin/vaadin-text-field';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { ifDefined } from 'lit-html/directives/if-defined';\n\nconst NS = 'coupon-code-form';\nconst Base = ConfigurableMixin(\n ThemeableMixin(ScopedElementsMixin(TranslatableMixin(NucleonElement, NS)))\n);\n\n/**\n * Form element for creating or editing coupon codes (`fx:coupon_code`).\n *\n * @slot code:before\n * @slot code:after\n *\n * @slot timestamps:before\n * @slot timestamps:after\n *\n * @slot delete:before\n * @slot delete:after\n *\n * @slot create:before\n * @slot create:after\n *\n * @element foxy-coupon-code-form\n * @since 1.15.0\n */\nexport class CouponCodeForm extends Base<Data> {\n static get scopedElements(): ScopedElementsMap {\n return {\n 'vaadin-text-field': customElements.get('vaadin-text-field'),\n 'vaadin-button': customElements.get('vaadin-button'),\n\n 'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n\n 'x-property-table': PropertyTable,\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ code: v }) => !!v || 'code_required',\n ({ code: v }) => !v || v.length <= 50 || 'code_too_long',\n ];\n }\n\n templates: Templates = {};\n\n render(): TemplateResult {\n return html`\n <div class=\"relative space-y-m\">\n ${this.__isCodeHidden ? null : this.__renderCode()}\n ${this.__isTimestampsHidden ? null : this.__renderTimestamps()}\n ${this.__isCreateHidden ? null : this.__renderCreate()}\n ${this.__isDeleteHidden ? null : this.__renderDelete()}\n\n <div\n data-testid=\"spinner\"\n class=${classMap({\n 'transition duration-500 ease-in-out absolute inset-0 flex': true,\n 'opacity-0 pointer-events-none': !this.in('busy') && !this.in('fail'),\n })}\n >\n <foxy-spinner\n layout=\"vertical\"\n class=\"m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l\"\n state=${this.in('fail') ? 'error' : this.in('busy') ? 'busy' : 'empty'}\n lang=${this.lang}\n ns=\"${this.ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n private get __isCodeHidden(): boolean {\n return this.hiddenSelector.matches('code', true);\n }\n\n private get __isTimestampsHidden(): boolean {\n if (this.hiddenSelector.matches('timestamps', true)) return true;\n return !this.data;\n }\n\n private get __isCreateHidden(): boolean {\n if (this.hiddenSelector.matches('create', true)) return true;\n return !!this.data;\n }\n\n private get __isDeleteHidden(): boolean {\n if (this.hiddenSelector.matches('delete', true)) return true;\n return !this.data;\n }\n\n private __getErrorMessage(prefix: string) {\n const error = this.errors.find(err => err.startsWith(prefix));\n return error ? this.t(error.replace(prefix, 'v8n')).toString() : '';\n }\n\n private __getValidator(prefix: string) {\n return () => !this.errors.some(err => err.startsWith(prefix));\n }\n\n private __renderCode(): TemplateResult {\n return html`\n <div>\n ${this.renderTemplateOrSlot('code:before')}\n\n <vaadin-text-field\n data-testid=\"code\"\n class=\"w-full\"\n label=${this.t('code')}\n value=${ifDefined(this.form.code)}\n .checkValidity=${this.__getValidator('code')}\n .errorMessage=${this.__getErrorMessage('code')}\n ?disabled=${this.in('busy') || this.disabledSelector.matches('code', true)}\n ?readonly=${this.readonlySelector.matches('code', true)}\n required\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.submit()}\n @input=${(evt: CustomEvent) => {\n const newCode = (evt.currentTarget as TextFieldElement).value;\n this.edit({ code: newCode });\n }}\n >\n </vaadin-text-field>\n\n ${this.renderTemplateOrSlot('code:after')}\n </div>\n `;\n }\n\n private __renderTimestamps(): TemplateResult {\n return html`\n <div>\n ${this.renderTemplateOrSlot('timestamps:before')}\n\n <x-property-table\n data-testid=\"timestamps\"\n .items=${(['date_modified', 'date_created'] as const).map(field => ({\n name: this.t(field),\n value: this.data?.[field]\n ? this.t('date', { value: new Date(this.data[field] as string) })\n : '',\n }))}\n >\n </x-property-table>\n\n ${this.renderTemplateOrSlot('timestamps:after')}\n </div>\n `;\n }\n\n private __renderCreate(): TemplateResult {\n const isCleanTemplateInvalid = this.in({ idle: { template: { clean: 'invalid' } } });\n const isDirtyTemplateInvalid = this.in({ idle: { template: { dirty: 'invalid' } } });\n const isCleanSnapshotInvalid = this.in({ idle: { snapshot: { clean: 'invalid' } } });\n const isDirtySnapshotInvalid = this.in({ idle: { snapshot: { dirty: 'invalid' } } });\n const isTemplateInvalid = isCleanTemplateInvalid || isDirtyTemplateInvalid;\n const isSnaphotInvalid = isCleanSnapshotInvalid || isDirtySnapshotInvalid;\n const isInvalid = isTemplateInvalid || isSnaphotInvalid;\n const isBusy = this.in('busy');\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('create:before')}\n\n <vaadin-button\n data-testid=\"create\"\n class=\"w-full\"\n theme=\"primary success\"\n ?disabled=${isBusy || isInvalid || this.disabledSelector.matches('create', true)}\n @click=${() => this.submit()}\n >\n <foxy-i18n ns=${this.ns} key=\"create\" lang=${this.lang}></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot('create:after')}\n </div>\n `;\n }\n\n private __renderDelete(): TemplateResult {\n return html`\n <div>\n <foxy-internal-confirm-dialog\n data-testid=\"confirm\"\n message=\"delete_prompt\"\n confirm=\"delete\"\n cancel=\"cancel\"\n header=\"delete\"\n theme=\"primary error\"\n lang=${this.lang}\n ns=${this.ns}\n id=\"confirm\"\n @hide=${(evt: DialogHideEvent) => !evt.detail.cancelled && this.delete()}\n >\n </foxy-internal-confirm-dialog>\n\n ${this.renderTemplateOrSlot('delete:before')}\n\n <vaadin-button\n data-testid=\"delete\"\n theme=\"primary error\"\n class=\"w-full\"\n ?disabled=${this.in('busy') || this.disabledSelector.matches('delete', true)}\n @click=${(evt: CustomEvent) => {\n const confirm = this.renderRoot.querySelector('#confirm') as InternalConfirmDialog;\n confirm.show(evt.currentTarget as ButtonElement);\n }}\n >\n <foxy-i18n ns=${this.ns} key=\"delete\" lang=${this.lang}></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot('delete:after')}\n </div>\n `;\n }\n}\n"]}
|