@foxy.io/elements 1.14.0-beta.10 → 1.14.0-beta.11
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 +1 -1
- 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-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 +18 -15
- 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-error-entry-card.js +1 -1
- package/dist/cdn/foxy-form-dialog.js +1 -1
- package/dist/cdn/foxy-i18n.js +1 -1
- package/dist/cdn/foxy-items-form.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-query-builder.js +1 -1
- package/dist/cdn/foxy-sign-in-form.js +1 -1
- package/dist/cdn/foxy-spinner.js +1 -1
- package/dist/cdn/foxy-subscription-card.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +2 -2
- 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-4ba926ca.js → shared-05956f55.js} +1 -1
- package/dist/cdn/{shared-7007dedb.js → shared-05b473a7.js} +1 -1
- package/dist/cdn/{shared-da787055.js → shared-1177fd2a.js} +1 -1
- package/dist/cdn/{shared-c5ae5d33.js → shared-2b685624.js} +1 -1
- package/dist/cdn/{shared-d01035c5.js → shared-4168c6cd.js} +1 -1
- package/dist/cdn/{shared-d05c93a5.js → shared-5d1314d7.js} +1 -1
- package/dist/cdn/{shared-0f9809ab.js → shared-70631d0a.js} +1 -1
- package/dist/cdn/{shared-ca7c3b9a.js → shared-775b37f9.js} +1 -1
- package/dist/cdn/{shared-a3d2c48e.js → shared-8730c141.js} +1 -1
- package/dist/cdn/{shared-5d94bacb.js → shared-93f23978.js} +1 -1
- package/dist/cdn/{shared-007c4e34.js → shared-a94b7271.js} +1 -1
- package/dist/cdn/{shared-daf6b763.js → shared-bda600d6.js} +1 -1
- package/dist/cdn/{shared-b24377bf.js → shared-d3167239.js} +1 -1
- package/dist/cdn/shared-e36452b9.js +1 -0
- package/dist/cdn/{shared-31d03530.js → shared-f968379d.js} +7 -7
- package/dist/cdn/{shared-00070cc4.js → shared-fbeb1de3.js} +1 -1
- package/dist/elements/public/CustomerPortal/InternalCustomerPortalLink.d.ts +1 -0
- package/dist/elements/public/CustomerPortal/InternalCustomerPortalLink.js +17 -8
- package/dist/elements/public/CustomerPortal/InternalCustomerPortalLink.js.map +1 -1
- package/dist/elements/public/CustomerPortal/InternalCustomerPortalSubscriptions.js +11 -3
- package/dist/elements/public/CustomerPortal/InternalCustomerPortalSubscriptions.js.map +1 -1
- package/dist/elements/public/ItemsForm/private/Picture.d.ts +1 -0
- package/dist/elements/public/ItemsForm/private/Picture.js +2 -0
- package/dist/elements/public/ItemsForm/private/Picture.js.map +1 -1
- package/dist/elements/public/SubscriptionForm/SubscriptionForm.js +12 -4
- package/dist/elements/public/SubscriptionForm/SubscriptionForm.js.map +1 -1
- package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.js +20 -13
- package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.js.map +1 -1
- package/dist/mixins/themeable.js +10 -8
- package/dist/mixins/themeable.js.map +1 -1
- package/package.json +1 -1
- package/dist/cdn/shared-fe8a7aa2.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{L as t,j as e,h as s}from"./shared-63eaded9.js";import{b as a}from"./shared-
|
|
1
|
+
import{L as t,j as e,h as s}from"./shared-63eaded9.js";import{b as a}from"./shared-4168c6cd.js";let d,i,r,l=t=>t;class o extends t{constructor(){super(...arguments),this.items=[],this.disabled=!1}static get properties(){return{disabled:{type:Boolean,reflect:!0},items:{attribute:!1}}}static get styles(){return[a.styles,e(d||(d=l`.max-w-0{max-width:0}`))]}render(){const t=this.disabled?"text-disabled":"text-body",e=this.disabled?"text-disabled":"text-secondary",a="max-w-0 truncate py-s";return s(i||(i=l` <table class="font-lumo text-m leading-m w-full"> <tbody class="divide-y divide-contrast-10"> ${0} </tbody> </table> `),this.items.map((({name:d,value:i})=>s(r||(r=l` <tr> <td class="${0} ${0} w-1-3 pr-m" title="${0}">${0}</td> <td class="${0} ${0} w-2-3" title="${0}">${0}</td> </tr> `),a,e,d,d,a,t,i,i))))}}export{o as P};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as t,_ as e,j as i,h as s}from"./shared-63eaded9.js";import"./shared-0ced76a0.js";import{p as r}from"./shared-87ca7818.js";import"./shared-46ee137f.js";import"./shared-df573cea.js";import"./shared-f0a83bd6.js";import{b as a,S as n,c as o}from"./shared-4168c6cd.js";import"./shared-f968379d.js";import"./shared-05956f55.js";import{I as l,D as c}from"./shared-8730c141.js";import{E as h}from"./shared-93f23978.js";import"./shared-ec861f31.js";import"./shared-bb824ab4.js";import"./foxy-i18n.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,4 +1,4 @@
|
|
|
1
|
-
import{k as e,P as t,A as a,L as i,j as s,h as n,_ as r}from"./shared-63eaded9.js";import"./shared-46ee137f.js";import{E as l,C as o,T as d}from"./shared-df573cea.js";import"./shared-f0a83bd6.js";import{a as u,T as
|
|
1
|
+
import{k as e,P as t,A as a,L as i,j as s,h as n,_ as r}from"./shared-63eaded9.js";import"./shared-46ee137f.js";import{E as l,C as o,T as d}from"./shared-df573cea.js";import"./shared-f0a83bd6.js";import{a as u,T as c}from"./shared-bb824ab4.js";import{h,P as p,D as m}from"./shared-ff79f3f9.js";import"./shared-ec861f31.js";import"./foxy-i18n.js";import{Q as g,T as v,U as f,V as y,W as _,X as b,Y as x,Z as w,b as C,$ as E,a0 as k,a1 as T,a2 as $,a3 as V,a4 as S,a5 as I,m as A,a6 as M}from"./shared-1761daef.js";import{p as D}from"./shared-87ca7818.js";import{c as q}from"./shared-4168c6cd.js";import{s as L}from"./shared-b0f0e8b5.js";import{i as N}from"./shared-a46edf4b.js";var B={raise:g,send:v,sendParent:f,sendUpdate:y,log:_,cancel:b,start:x,stop:w,assign:C,after:E,done:k,respond:T,forwardTo:$,escalate:V,choose:S,pure:I};const j=h`<dom-module id="lumo-text-area" theme-for="vaadin-text-area">
|
|
2
2
|
<template>
|
|
3
3
|
<style include="lumo-text-field">
|
|
4
4
|
[part="input-field"],
|
|
@@ -62,7 +62,7 @@ import{k as e,P as t,A as a,L as i,j as s,h as n,_ as r}from"./shared-63eaded9.j
|
|
|
62
62
|
Copyright (c) 2017 Vaadin Ltd.
|
|
63
63
|
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
64
64
|
*/
|
|
65
|
-
class P extends(l(u(o(d(p))))){static get template(){return
|
|
65
|
+
class P extends(l(u(o(d(p))))){static get template(){return h`
|
|
66
66
|
<style include="vaadin-text-field-shared-styles">
|
|
67
67
|
.vaadin-text-area-container {
|
|
68
68
|
flex: auto;
|
|
@@ -131,7 +131,7 @@ class P extends(l(u(o(d(p))))){static get template(){return c`
|
|
|
131
131
|
<div part="error-message" id="[[_errorId]]" aria-live="assertive" aria-hidden\$="[[_getErrorMessageAriaHidden(invalid, errorMessage, _errorId)]]">[[errorMessage]]</div>
|
|
132
132
|
|
|
133
133
|
</div>
|
|
134
|
-
`}static get is(){return"vaadin-text-area"}static get version(){return"2.9.0"}static get properties(){return{pattern:{type:String}}}static get observers(){return["_textAreaValueChanged(value)"]}ready(){super.ready(),this._updateHeight(),this.addEventListener("animationend",this._onAnimationEnd)}_onAnimationEnd(e){0===e.animationName.indexOf("vaadin-text-area-appear")&&this._updateHeight()}get _slottedTagName(){return"textarea"}_textAreaValueChanged(e){this._updateHeight()}_updateHeight(){const e=this.root.querySelector("[part=input-field]"),t=e.scrollTop,a=this.inputElement,i=this.value?this.value.length:0;if(this._oldValueLength>=i){const t=getComputedStyle(e).height,i=getComputedStyle(a).width;e.style.display="block",e.style.height=t,a.style.maxWidth=i,a.style.height="auto"}this._oldValueLength=i;const s=a.scrollHeight;s>a.clientHeight&&(a.style.height=s+"px"),a.style.removeProperty("max-width"),e.style.removeProperty("display"),e.style.removeProperty("height"),e.scrollTop=t,this._dispatchIronResizeEventIfNeeded("InputHeight",s)}checkValidity(){if(!super.checkValidity())return!1;if(!this.pattern||!this.inputElement.value)return!0;try{const e=this.inputElement.value.match(this.pattern);return!!e&&e[0]===e.input}catch(e){return!0}}}customElements.define(P.is,P);const F=
|
|
134
|
+
`}static get is(){return"vaadin-text-area"}static get version(){return"2.9.0"}static get properties(){return{pattern:{type:String}}}static get observers(){return["_textAreaValueChanged(value)"]}ready(){super.ready(),this._updateHeight(),this.addEventListener("animationend",this._onAnimationEnd)}_onAnimationEnd(e){0===e.animationName.indexOf("vaadin-text-area-appear")&&this._updateHeight()}get _slottedTagName(){return"textarea"}_textAreaValueChanged(e){this._updateHeight()}_updateHeight(){const e=this.root.querySelector("[part=input-field]"),t=e.scrollTop,a=this.inputElement,i=this.value?this.value.length:0;if(this._oldValueLength>=i){const t=getComputedStyle(e).height,i=getComputedStyle(a).width;e.style.display="block",e.style.height=t,a.style.maxWidth=i,a.style.height="auto"}this._oldValueLength=i;const s=a.scrollHeight;s>a.clientHeight&&(a.style.height=s+"px"),a.style.removeProperty("max-width"),e.style.removeProperty("display"),e.style.removeProperty("height"),e.scrollTop=t,this._dispatchIronResizeEventIfNeeded("InputHeight",s)}checkValidity(){if(!super.checkValidity())return!1;if(!this.pattern||!this.inputElement.value)return!0;try{const e=this.inputElement.value.match(this.pattern);return!!e&&e[0]===e.input}catch(e){return!0}}}customElements.define(P.is,P);const F=h`<dom-module id="lumo-number-field" theme-for="vaadin-number-field">
|
|
135
135
|
<template>
|
|
136
136
|
<style include="lumo-field-button">
|
|
137
137
|
:host {
|
|
@@ -178,7 +178,7 @@ class P extends(l(u(o(d(p))))){static get template(){return c`
|
|
|
178
178
|
Copyright (c) 2017 Vaadin Ltd.
|
|
179
179
|
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
180
180
|
*/
|
|
181
|
-
const z=
|
|
181
|
+
const z=h`<dom-module id="vaadin-number-field-template">
|
|
182
182
|
<template>
|
|
183
183
|
<style>
|
|
184
184
|
:host([readonly]) [part\$="button"] {
|
|
@@ -252,13 +252,13 @@ const z=c`<dom-module id="vaadin-number-field-template">
|
|
|
252
252
|
</template>
|
|
253
253
|
|
|
254
254
|
|
|
255
|
-
</dom-module>`;let U;document.head.appendChild(z.content);class O extends
|
|
255
|
+
</dom-module>`;let U;document.head.appendChild(z.content);class O extends c{static get is(){return"vaadin-number-field"}static get version(){return"2.9.0"}static get properties(){return{hasControls:{type:Boolean,value:!1,reflectToAttribute:!0},min:{type:Number,reflectToAttribute:!0,observer:"_minChanged"},max:{type:Number,reflectToAttribute:!0,observer:"_maxChanged"},step:{type:Number,value:1,observer:"_stepChanged"}}}ready(){super.ready(),this.__previousValidInput=this.value||"",this.inputElement.type="number",this.inputElement.addEventListener("change",this.__onInputChange.bind(this))}_decreaseButtonTouchend(e){e.preventDefault(),this._decreaseValue()}_increaseButtonTouchend(e){e.preventDefault(),this._increaseValue()}static get template(){if(!U){U=super.template.cloneNode(!0);const e=m.import(this.is+"-template","template"),t=e.content.querySelector('[part="decrease-button"]'),a=e.content.querySelector('[part="increase-button"]'),i=e.content.querySelector("style"),s=U.content.querySelector('[part="input-field"]'),n=U.content.querySelector('[name="prefix"]');s.insertBefore(t,n),s.appendChild(a),U.content.appendChild(i)}return U}_createConstraintsObserver(){this._createMethodObserver("_constraintsChanged(required, minlength, maxlength, pattern, min, max, step)")}_constraintsChanged(e,t,a,i,s,n,r){if(!this.invalid)return;const l=e=>!e&&0!==e;l(s)&&l(n)?super._constraintsChanged(e,t,a,i):this.validate()}_decreaseValue(){this._incrementValue(-1)}_increaseValue(){this._incrementValue(1)}_incrementValue(e){if(this.disabled||this.readonly)return;let t=parseFloat(this.value);this.value?t<this.min?(e=0,t=this.min):t>this.max&&(e=0,t=this.max):0==this.min&&e<0||0==this.max&&e>0||0==this.max&&0==this.min?(e=0,t=0):(null==this.max||this.max>=0)&&(null==this.min||this.min<=0)?t=0:this.min>0?(t=this.min,this.max<0&&e<0&&(t=this.max),e=0):this.max<0&&(t=this.max,e<0?e=0:this._getIncrement(1,t-this.step)>this.max?t-=2*this.step:t-=this.step);const a=this._getIncrement(e,t);this.value&&0!=e&&!this._incrementIsInsideTheLimits(e,t)||this._setValue(a)}_setValue(e){this.value=this.inputElement.value=String(parseFloat(e)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0}))}_getIncrement(e,t){let a=this.step||1,i=this.min||0;const s=Math.max(this._getMultiplier(t),this._getMultiplier(a),this._getMultiplier(i));a*=s,i*=s;const n=((t=Math.round(t*s))-i)%a;return e>0?(t-n+a)/s:e<0?(t-(n||a))/s:t/s}_getDecimalCount(e){const t=String(e),a=t.indexOf(".");return-1===a?1:t.length-a-1}_getMultiplier(e){if(!isNaN(e))return Math.pow(10,this._getDecimalCount(e))}_incrementIsInsideTheLimits(e,t){return e<0?null==this.min||this._getIncrement(e,t)>=this.min:e>0?null==this.max||this._getIncrement(e,t)<=this.max:this._getIncrement(e,t)<=this.max&&this._getIncrement(e,t)>=this.min}_allowed(e){const t=e*(this.step||1),a=parseFloat(this.value);return!this.value||!this.disabled&&this._incrementIsInsideTheLimits(t,a)}_stepChanged(e,t){this.__validateByStep=this.__stepChangedCalled||null!==this.getAttribute("step"),this.inputElement.step=this.__validateByStep?e:"any",this.__stepChangedCalled=!0,this.setAttribute("step",e)}_minChanged(e){this.inputElement.min=e}_maxChanged(e){this.inputElement.max=e}_valueChanged(e,t){e&&isNaN(parseFloat(e))?this.value="":"string"!=typeof this.value&&(this.value=String(this.value)),super._valueChanged(this.value,t)}_onKeyDown(e){38==e.keyCode?(e.preventDefault(),this._increaseValue()):40==e.keyCode&&(e.preventDefault(),this._decreaseValue()),super._onKeyDown(e)}__onInputChange(){this.validate()}checkValidity(){return void 0!==this.min||void 0!==this.max||this.__validateByStep?this.inputElement.checkValidity():super.checkValidity()}}window.customElements.define(O.is,O);
|
|
256
256
|
/**
|
|
257
257
|
@license
|
|
258
258
|
Copyright (c) 2019 Vaadin Ltd.
|
|
259
259
|
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
260
260
|
*/
|
|
261
|
-
const H=
|
|
261
|
+
const H=h`<dom-module id="vaadin-integer-field-template">
|
|
262
262
|
|
|
263
263
|
|
|
264
|
-
</dom-module>`;document.head.appendChild(H.content);class R extends O{static get is(){return"vaadin-integer-field"}static get version(){return"2.9.0"}static get properties(){return{pattern:String,preventInvalidInput:Boolean,minlength:Number,maxlength:Number}}ready(){super.ready(),this._enabledCharPattern="[-+\\d]"}_valueChanged(e,t){if(""!==e&&!this.__isInteger(e))return console.warn(`Trying to set non-integer value "${e}" to <vaadin-integer-field>. Clearing the value.`),void(this.value="");super._valueChanged(e,t)}_stepChanged(e,t){if(!this.__hasOnlyDigits(e))return console.warn(`Trying to set invalid step size "${e}", which is not a positive integer, to <vaadin-integer-field>. Resetting the default value 1.`),void(this.step=1);super._stepChanged(e,t)}__isInteger(e){return/^(-\d)?\d*$/.test(String(e))}__hasOnlyDigits(e){return/^\d*$/.test(String(e))}}window.customElements.define(R.is,R);class Y extends CustomEvent{constructor(e){super("change",{detail:e})}}class W extends CustomEvent{constructor(e){super("change",{detail:e})}}class X extends W{}const K=e((e=>i=>{const{element:s,name:n,strings:r}=i.committer;if(2!==r.length||""!==r[0]||""!==r[1])throw new Error("live directive bindings must not contain any static values");if(i.committer.parts.length>1)throw new Error("live directive must be the only directive for an attribute or property");if(i instanceof t)s[n]!==e&&i.setValue(e);else{if(!(i instanceof a))throw new Error("live directive can only be used on attributes or properties");s.getAttribute(n)!==e&&i.setValue(e)}}));let Q,Z,G=e=>e;class J extends i{constructor(){super(...arguments),this.label="",this.value="",this.disabled=!1,this.readonly=!1,this.errorMessage="",this.__i18n={formatValue:e=>e.join(""),parseValue:e=>{const{count:t,units:a}=D(e);return[t.toString(),a]}},this.__getItems=A((e=>{const t=D(e).count;return[{value:"d",label:this.__t("day",{count:t})},{value:"w",label:this.__t("week",{count:t})},{value:"m",label:this.__t("month",{count:t})},{value:"y",label:this.__t("year",{count:t})}]}))}static get properties(){return{checkValidity:{attribute:!1},errorMessage:{type:String,attribute:"error-message"},disabled:{type:Boolean,reflect:!0},readonly:{type:Boolean,reflect:!0},label:{type:String},value:{type:String},lang:{type:String}}}static get styles(){return s(Q||(Q=G`:host{display:block}vaadin-custom-field{width:100%;font-size:0;line-height:0}vaadin-custom-field::part(label){padding-bottom:var(--lumo-space-s)}vaadin-custom-field::part(error-message)[aria-hidden=false]{padding-top:var(--lumo-space-xs)}vaadin-combo-box,vaadin-integer-field{width:calc(50% - (var(--lumo-space-s)/ 2))}vaadin-integer-field{margin-right:var(--lumo-space-s);padding:0}vaadin-combo-box::part(text-field){padding:0}`))}connectedCallback(){super.connectedCallback(),this.__untrackTranslations=customElements.get("foxy-i18n").onTranslationChange((()=>{var e,t;null===(t=(e=this.__getItems.cache).clear)||void 0===t||t.call(e),this.requestUpdate()}))}render(){return n(Z||(Z=G` <vaadin-custom-field data-testid="field" .i18n="${0}" .label="${0}" .value="${0}" ?disabled="${0}" ?readonly="${0}" .errorMessage="${0}" .checkValidity="${0}" @change="${0}"> <vaadin-integer-field data-testid="value" min="1" max="999" has-controls prevent-invalid-input ?invalid="${0}" ?disabled="${0}" ?readonly="${0}"> </vaadin-integer-field> <vaadin-combo-box data-testid="units" item-value-path="value" item-label-path="label" .items="${0}" ?invalid="${0}" ?disabled="${0}" ?readonly="${0}"> </vaadin-combo-box> </vaadin-custom-field> `),this.__i18n,this.label,K(this.value),this.disabled,this.readonly,this.errorMessage,this.checkValidity,this.__handleChange,!this.checkValidity(),this.disabled,this.readonly,this.__getItems(this.value),!this.checkValidity(),this.disabled,this.readonly)}updated(e){super.updated(e);const t=this.renderRoot.firstElementChild;t.value!==this.value&&(t.value=this.value)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this.__untrackTranslations)||void 0===e||e.call(this)}checkValidity(){return!0}get __t(){return customElements.get("foxy-i18n").i18next.getFixedT(this.lang)}__handleChange(e){const t=e.target;this.value=t.value,this.dispatchEvent(new X(this.value))}}const ee=M({id:"choice",type:"parallel",context:{defaultCustomValue:"",customValue:null,custom:!1,items:[],value:null,type:"text",min:null,max:null},states:{mutability:{initial:"editable",states:{editable:{},readonly:{}},on:{SET_READONLY:[{target:".editable",cond:"isPayloadFalsey"},{target:".readonly",cond:"isPayloadTruthy"}]}},interactivity:{initial:"enabled",states:{enabled:{},disabled:{}},on:{SET_DISABLED:[{target:".enabled",cond:"isPayloadFalsey"},{target:".disabled",cond:"isPayloadTruthy"}]}},selection:{initial:"unknown",states:{unknown:{always:[{target:"multiple",cond:"isValueArray"},{target:"single"}]},none:{},single:{},multiple:{}}},extension:{initial:"unknown",states:{unknown:{always:[{target:"present",cond:"hasCustom"},{target:"absent"}]},absent:{},present:{initial:"unknown",states:{unknown:{always:[{target:"selected",cond:"hasCustomValue"},{target:"available"}]},available:{on:{SET_TYPE:{actions:"setType"}}},selected:{initial:"unknown",states:{unknown:{always:[{target:"integer",cond:"showsIntegerField"},{target:"textarea",cond:"showsTextarea"},{target:"frequency",cond:"showsFrequency"},{target:"text"}]},text:{},frequency:{},textarea:{},integer:{type:"parallel",states:{min:{initial:"unknown",states:{unknown:{always:[{target:"custom",cond:"hasMinConstraint"},{target:"none"}]},none:{},custom:{}}},max:{initial:"unknown",states:{unknown:{always:[{target:"custom",cond:"hasMaxConstraint"},{target:"none"}]},none:{},custom:{}}}}}}}}}}}},on:{SET_DEFAULT_CUSTOM_VALUE:{actions:"setDefaultCustomValue"},SET_CUSTOM:{actions:"setCustom",target:[".selection.unknown",".extension.unknown"]},SET_VALUE:{actions:"setValue",target:[".selection.unknown",".extension.unknown"]},SET_ITEMS:{actions:"setItems",target:[".selection.unknown",".extension.unknown"]},SET_TYPE:{actions:"setType",target:".extension.unknown"},SET_MIN:{actions:"setMin",target:".extension.unknown"},SET_MAX:{actions:"setMax",target:".extension.unknown"}}},{guards:{isPayloadFalsey:(e,t)=>!t.data,isPayloadTruthy:(e,t)=>!!t.data,isValueArray:e=>Array.isArray(e.value),showsIntegerField:e=>"integer"===e.type,showsFrequency:e=>"frequency"===e.type,showsTextarea:e=>"textarea"===e.type,hasMinConstraint:e=>"number"==typeof e.min,hasMaxConstraint:e=>"number"==typeof e.max,hasCustomValue:e=>"string"==typeof e.customValue,hasCustom:e=>e.custom},actions:{setDefaultCustomValue:B.assign({defaultCustomValue:(e,t)=>t.data}),setValue:B.assign({value:(e,t)=>t.data,customValue:(e,t)=>Array.isArray(t.data)?t.data.find((t=>!e.items.includes(t))):e.items.includes(t.data)?null:t.data}),setCustom:B.assign({custom:(e,t)=>t.data}),setItems:B.assign({items:(e,t)=>t.data}),setType:B.assign({type:(e,t)=>t.data}),setMin:B.assign({min:(e,t)=>t.data}),setMax:B.assign({max:(e,t)=>t.data})}});let te,ae,ie,se,ne,re,le,oe,de,ue,he,ce,pe,me=e=>e;const ge=`@foxy.io/elements::other[${(Math.pow(10,10)*Math.random()).toFixed(0)}]`;class ve extends q{constructor(){super(...arguments),this.getText=e=>e,this.__service=N(ee).onChange((()=>this.requestUpdate())).onTransition((({changed:e})=>e&&this.requestUpdate())).start()}static get scopedElements(){return{"vaadin-integer-field":customElements.get("vaadin-integer-field"),"vaadin-text-field":customElements.get("vaadin-text-field"),"x-frequency-input":J,"vaadin-text-area":customElements.get("vaadin-text-area"),"iron-icon":customElements.get("iron-icon")}}static get styles(){return[super.styles,s(ie||(ie=me`:host{--item-width:calc((var(--lumo-space-m) * 2) + 1.25rem)}.ml-xxl{margin-left:var(--item-width)}.item{height:var(--lumo-size-l);width:var(--item-width)}.radio{height:1.25rem;width:1.25rem}.check{height:1.125rem;width:1.125rem}.dot{height:.5rem;width:.5rem}`))]}static get properties(){return r(r({},super.properties),{},{defaultCustomValue:{type:String,attribute:"default-custom-value"},disabled:{type:Boolean},readonly:{type:Boolean},custom:{type:Boolean},type:{type:String},min:{type:Number},max:{type:Number},value:{type:Array},items:{type:Array},getText:{attribute:!1}})}get defaultCustomValue(){return this.__service.state.context.defaultCustomValue}set defaultCustomValue(e){this.__service.send("SET_DEFAULT_CUSTOM_VALUE",{data:e})}get readonly(){return this.__service.state.matches("mutability.readonly")}set readonly(e){this.__service.send("SET_READONLY",{data:e})}get disabled(){return this.__service.state.matches("interactivity.disabled")}set disabled(e){this.__service.send("SET_DISABLED",{data:e})}get custom(){return this.__service.state.matches("extension.present")}set custom(e){this.__service.send("SET_CUSTOM",{data:e})}get type(){return this.__service.state.context.type}set type(e){this.__service.send("SET_TYPE",{data:e})}get min(){return this.__service.state.context.min}set min(e){this.__service.send("SET_MIN",{data:e})}get max(){return this.__service.state.context.max}set max(e){this.__service.send("SET_MAX",{data:e})}get value(){return this.__service.state.context.value}set value(e){this.__service.send("SET_VALUE",{data:e})}get items(){return this.__service.state.context.items}set items(e){this.__service.send("SET_ITEMS",{data:e})}render(){const e=this.custom?[...this.items,ge]:this.items,t=Array.isArray(this.value),a=this.__service.state.matches("extension.present.selected"),i=n(se||(se=me` ${0} `),e.map(((e,i,s)=>{var r;const l=this.custom&&i===s.length-1,o=l?a:t?!!(null===(r=this.value)||void 0===r?void 0:r.includes(e)):e===String(this.value),d=this.disabled||!this._isI18nReady,u=L({value:l?ge:e,name:t?e:"choice","data-testid":`item-${e}`,"?disabled":d,"@change":t=>{if(this.readonly)return t.preventDefault();const a=t.target.checked,i=e===ge?this.defaultCustomValue:e,s=this.value;Array.isArray(s)?this.value=e===ge?a?[...s,i]:s.slice(0,s.length-1):a?[i,...s]:s.filter((e=>e!==i)):this.value=a?i:null,this.dispatchEvent(new Y(this.value))}}),h=n(ne||(ne=me` <div> ${0} </div> `),e===ge?this._t("choice.other").toString():n(re||(re=me`<slot name="${0}">${0}</slot>`),`${e}-label`,this.getText(e)));return n(le||(le=me` <div class="ml-xxl border-t border-contrast-10 ${0}"></div> ${0} <div class="mr-m ml-xxl"> ${0} ${0} </div> `),i?"":"hidden",t?function(e,t,a,i,s){const r="transition ease-in-out duration-200",l=`${r} transform ${a?"scale-100":"scale-0"} ${e?"text-contrast-70":"text-tint"}`;return n(ae||(ae=me` <label class="group flex items-center ${0}"> <div class="item flex items-center justify-center flex-shrink-0 text-primary-contrast"> <div class="check rounded-s ${0} ${0} ${0} focus-within-shadow-outline"> <iron-icon icon="lumo:checkmark" class="block w-full h-full ${0}"></iron-icon> <input type="checkbox" class="sr-only" .checked="${0}" ...="${0}"> </div> </div> <div class="font-lumo leading-m ${0}">${0}</div> </label> `),t||e?"":"cursor-pointer","border "+(e?"border-dashed border-contrast-30":"border-transparent"),r,e?"":t?a?"bg-primary-50":"bg-contrast-10":a?"bg-primary":"bg-contrast-20 group-hover-bg-contrast-30",l,a,i,t?"text-disabled":e?"text-secondary":"text-body",s)}(this.readonly,d,o,u,h):function(e,t,a,i,s){const r="transition ease-in-out duration-200",l=`${r} ${t||e?"":"shadow-xs"} transform ${a?"scale-100":"scale-0"} ${e?"bg-contrast-70":"bg-tint"}`;return n(te||(te=me` <label class="group flex items-center ${0}"> <div class="item flex items-center justify-center flex-shrink-0"> <div class="flex radio rounded-full ${0} ${0} ${0} focus-within-shadow-outline"> <div class="dot m-auto rounded-full ${0}"></div> <input type="radio" class="sr-only" .checked="${0}" ...="${0}"> </div> </div> <div class="font-lumo leading-m ${0}">${0}</div> </label> `),t||e?"":"cursor-pointer","border "+(e?"border-dashed border-contrast-30":"border-transparent"),r,e?"":t?a?"bg-primary-50":"bg-contrast-10":a?"bg-primary":"bg-contrast-20 group-hover-bg-contrast-30",l,a,i,t?"text-disabled":e?"text-secondary":"text-body",s)}(this.readonly,d,o,u,h),e===ge&&a?this.__field:"",e!==ge?n(oe||(oe=me`<slot name="${0}"></slot>`),e):"")})));return n(de||(de=me`<form>${0}</form> `),i)}get __field(){const e=L({placeholder:this._t("choice.other").toString(),class:"w-full mb-m",value:this.__service.state.context.customValue,max:this.max,min:this.min,"?disabled":this.disabled,"?readonly":this.readonly,"data-testid":"field","@change":e=>{e.stopPropagation();const t=e.target.value;Array.isArray(this.value)?this.value=this.value.slice(0,this.value.length-1).concat(t):this.value=t,this.dispatchEvent(new Y(this.value))}});return"frequency"===this.type?n(ue||(ue=me`<x-frequency-input ...="${0}"></x-frequency-input>`),e):"integer"===this.type?n(he||(he=me`<vaadin-integer-field ...="${0}" has-controls></vaadin-integer-field>`),e):"textarea"===this.type?n(ce||(ce=me`<vaadin-text-area ...="${0}"></vaadin-text-area>`),e):n(pe||(pe=me`<vaadin-text-field ...="${0}"></vaadin-text-field>`),e)}}export{ve as C,W as D,R as I,Y as a,B as b};
|
|
264
|
+
</dom-module>`;document.head.appendChild(H.content);class R extends O{static get is(){return"vaadin-integer-field"}static get version(){return"2.9.0"}static get properties(){return{pattern:String,preventInvalidInput:Boolean,minlength:Number,maxlength:Number}}ready(){super.ready(),this._enabledCharPattern="[-+\\d]"}_valueChanged(e,t){if(""!==e&&!this.__isInteger(e))return console.warn(`Trying to set non-integer value "${e}" to <vaadin-integer-field>. Clearing the value.`),void(this.value="");super._valueChanged(e,t)}_stepChanged(e,t){if(!this.__hasOnlyDigits(e))return console.warn(`Trying to set invalid step size "${e}", which is not a positive integer, to <vaadin-integer-field>. Resetting the default value 1.`),void(this.step=1);super._stepChanged(e,t)}__isInteger(e){return/^(-\d)?\d*$/.test(String(e))}__hasOnlyDigits(e){return/^\d*$/.test(String(e))}}window.customElements.define(R.is,R);class Y extends CustomEvent{constructor(e){super("change",{detail:e})}}class W extends CustomEvent{constructor(e){super("change",{detail:e})}}class X extends W{}const K=e((e=>i=>{const{element:s,name:n,strings:r}=i.committer;if(2!==r.length||""!==r[0]||""!==r[1])throw new Error("live directive bindings must not contain any static values");if(i.committer.parts.length>1)throw new Error("live directive must be the only directive for an attribute or property");if(i instanceof t)s[n]!==e&&i.setValue(e);else{if(!(i instanceof a))throw new Error("live directive can only be used on attributes or properties");s.getAttribute(n)!==e&&i.setValue(e)}}));let Q,Z,G=e=>e;class J extends i{constructor(){super(...arguments),this.label="",this.value="",this.disabled=!1,this.readonly=!1,this.errorMessage="",this.__i18n={formatValue:e=>e.join(""),parseValue:e=>{const{count:t,units:a}=D(e);return[t.toString(),a]}},this.__getItems=A((e=>{const t=D(e).count;return[{value:"d",label:this.__t("day",{count:t})},{value:"w",label:this.__t("week",{count:t})},{value:"m",label:this.__t("month",{count:t})},{value:"y",label:this.__t("year",{count:t})}]}))}static get properties(){return{checkValidity:{attribute:!1},errorMessage:{type:String,attribute:"error-message"},disabled:{type:Boolean,reflect:!0},readonly:{type:Boolean,reflect:!0},label:{type:String},value:{type:String},lang:{type:String}}}static get styles(){return s(Q||(Q=G`:host{display:block}vaadin-custom-field{width:100%;font-size:0;line-height:0}vaadin-custom-field::part(label){padding-bottom:var(--lumo-space-s)}vaadin-custom-field::part(error-message)[aria-hidden=false]{padding-top:var(--lumo-space-xs)}vaadin-combo-box,vaadin-integer-field{width:calc(50% - (var(--lumo-space-s)/ 2))}vaadin-integer-field{margin-right:var(--lumo-space-s);padding:0}vaadin-combo-box::part(text-field){padding:0}`))}connectedCallback(){super.connectedCallback(),this.__untrackTranslations=customElements.get("foxy-i18n").onTranslationChange((()=>{var e,t;null===(t=(e=this.__getItems.cache).clear)||void 0===t||t.call(e),this.requestUpdate()}))}render(){return n(Z||(Z=G` <vaadin-custom-field data-testid="field" .i18n="${0}" .label="${0}" .value="${0}" ?disabled="${0}" ?readonly="${0}" .errorMessage="${0}" .checkValidity="${0}" @change="${0}"> <vaadin-integer-field data-testid="value" min="1" max="999" has-controls prevent-invalid-input ?invalid="${0}" ?disabled="${0}" ?readonly="${0}"> </vaadin-integer-field> <vaadin-combo-box data-testid="units" item-value-path="value" item-label-path="label" .items="${0}" ?invalid="${0}" ?disabled="${0}" ?readonly="${0}"> </vaadin-combo-box> </vaadin-custom-field> `),this.__i18n,this.label,K(this.value),this.disabled,this.readonly,this.errorMessage,this.checkValidity,this.__handleChange,!this.checkValidity(),this.disabled,this.readonly,this.__getItems(this.value),!this.checkValidity(),this.disabled,this.readonly)}updated(e){super.updated(e);const t=this.renderRoot.firstElementChild;t.value!==this.value&&(t.value=this.value)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this.__untrackTranslations)||void 0===e||e.call(this)}checkValidity(){return!0}get __t(){return customElements.get("foxy-i18n").i18next.getFixedT(this.lang)}__handleChange(e){const t=e.target;this.value=t.value,this.dispatchEvent(new X(this.value))}}const ee=M({id:"choice",type:"parallel",context:{defaultCustomValue:"",customValue:null,custom:!1,items:[],value:null,type:"text",min:null,max:null},states:{mutability:{initial:"editable",states:{editable:{},readonly:{}},on:{SET_READONLY:[{target:".editable",cond:"isPayloadFalsey"},{target:".readonly",cond:"isPayloadTruthy"}]}},interactivity:{initial:"enabled",states:{enabled:{},disabled:{}},on:{SET_DISABLED:[{target:".enabled",cond:"isPayloadFalsey"},{target:".disabled",cond:"isPayloadTruthy"}]}},selection:{initial:"unknown",states:{unknown:{always:[{target:"multiple",cond:"isValueArray"},{target:"single"}]},none:{},single:{},multiple:{}}},extension:{initial:"unknown",states:{unknown:{always:[{target:"present",cond:"hasCustom"},{target:"absent"}]},absent:{},present:{initial:"unknown",states:{unknown:{always:[{target:"selected",cond:"hasCustomValue"},{target:"available"}]},available:{on:{SET_TYPE:{actions:"setType"}}},selected:{initial:"unknown",states:{unknown:{always:[{target:"integer",cond:"showsIntegerField"},{target:"textarea",cond:"showsTextarea"},{target:"frequency",cond:"showsFrequency"},{target:"text"}]},text:{},frequency:{},textarea:{},integer:{type:"parallel",states:{min:{initial:"unknown",states:{unknown:{always:[{target:"custom",cond:"hasMinConstraint"},{target:"none"}]},none:{},custom:{}}},max:{initial:"unknown",states:{unknown:{always:[{target:"custom",cond:"hasMaxConstraint"},{target:"none"}]},none:{},custom:{}}}}}}}}}}}},on:{SET_DEFAULT_CUSTOM_VALUE:{actions:"setDefaultCustomValue"},SET_CUSTOM:{actions:"setCustom",target:[".selection.unknown",".extension.unknown"]},SET_VALUE:{actions:"setValue",target:[".selection.unknown",".extension.unknown"]},SET_ITEMS:{actions:"setItems",target:[".selection.unknown",".extension.unknown"]},SET_TYPE:{actions:"setType",target:".extension.unknown"},SET_MIN:{actions:"setMin",target:".extension.unknown"},SET_MAX:{actions:"setMax",target:".extension.unknown"}}},{guards:{isPayloadFalsey:(e,t)=>!t.data,isPayloadTruthy:(e,t)=>!!t.data,isValueArray:e=>Array.isArray(e.value),showsIntegerField:e=>"integer"===e.type,showsFrequency:e=>"frequency"===e.type,showsTextarea:e=>"textarea"===e.type,hasMinConstraint:e=>"number"==typeof e.min,hasMaxConstraint:e=>"number"==typeof e.max,hasCustomValue:e=>"string"==typeof e.customValue,hasCustom:e=>e.custom},actions:{setDefaultCustomValue:B.assign({defaultCustomValue:(e,t)=>t.data}),setValue:B.assign({value:(e,t)=>t.data,customValue:(e,t)=>Array.isArray(t.data)?t.data.find((t=>!e.items.includes(t))):e.items.includes(t.data)?null:t.data}),setCustom:B.assign({custom:(e,t)=>t.data}),setItems:B.assign({items:(e,t)=>t.data}),setType:B.assign({type:(e,t)=>t.data}),setMin:B.assign({min:(e,t)=>t.data}),setMax:B.assign({max:(e,t)=>t.data})}});let te,ae,ie,se,ne,re,le,oe,de,ue,ce,he,pe,me=e=>e;const ge=`@foxy.io/elements::other[${(Math.pow(10,10)*Math.random()).toFixed(0)}]`;class ve extends q{constructor(){super(...arguments),this.getText=e=>e,this.__service=N(ee).onChange((()=>this.requestUpdate())).onTransition((({changed:e})=>e&&this.requestUpdate())).start()}static get scopedElements(){return{"vaadin-integer-field":customElements.get("vaadin-integer-field"),"vaadin-text-field":customElements.get("vaadin-text-field"),"x-frequency-input":J,"vaadin-text-area":customElements.get("vaadin-text-area"),"iron-icon":customElements.get("iron-icon")}}static get styles(){return[super.styles,s(ie||(ie=me`:host{--item-width:calc((var(--lumo-space-m) * 2) + 1.25rem)}.ml-xxl{margin-left:var(--item-width)}.item{height:var(--lumo-size-l);width:var(--item-width)}.radio{height:1.25rem;width:1.25rem}.check{height:1.125rem;width:1.125rem}.dot{height:.5rem;width:.5rem}`))]}static get properties(){return r(r({},super.properties),{},{defaultCustomValue:{type:String,attribute:"default-custom-value"},disabled:{type:Boolean},readonly:{type:Boolean},custom:{type:Boolean},type:{type:String},min:{type:Number},max:{type:Number},value:{type:Array},items:{type:Array},getText:{attribute:!1}})}get defaultCustomValue(){return this.__service.state.context.defaultCustomValue}set defaultCustomValue(e){this.__service.send("SET_DEFAULT_CUSTOM_VALUE",{data:e})}get readonly(){return this.__service.state.matches("mutability.readonly")}set readonly(e){this.__service.send("SET_READONLY",{data:e})}get disabled(){return this.__service.state.matches("interactivity.disabled")}set disabled(e){this.__service.send("SET_DISABLED",{data:e})}get custom(){return this.__service.state.matches("extension.present")}set custom(e){this.__service.send("SET_CUSTOM",{data:e})}get type(){return this.__service.state.context.type}set type(e){this.__service.send("SET_TYPE",{data:e})}get min(){return this.__service.state.context.min}set min(e){this.__service.send("SET_MIN",{data:e})}get max(){return this.__service.state.context.max}set max(e){this.__service.send("SET_MAX",{data:e})}get value(){return this.__service.state.context.value}set value(e){this.__service.send("SET_VALUE",{data:e})}get items(){return this.__service.state.context.items}set items(e){this.__service.send("SET_ITEMS",{data:e})}render(){const e=this.custom?[...this.items,ge]:this.items,t=Array.isArray(this.value),a=this.__service.state.matches("extension.present.selected"),i=n(se||(se=me` ${0} `),e.map(((e,i,s)=>{var r;const l=this.custom&&i===s.length-1,o=l?a:t?!!(null===(r=this.value)||void 0===r?void 0:r.includes(e)):e===String(this.value),d=this.disabled||!this._isI18nReady,u=L({value:l?ge:e,name:t?e:"choice","data-testid":`item-${e}`,"?disabled":d,"@change":t=>{if(this.readonly)return t.preventDefault();const a=t.target.checked,i=e===ge?this.defaultCustomValue:e,s=this.value;Array.isArray(s)?this.value=e===ge?a?[...s,i]:s.slice(0,s.length-1):a?[i,...s]:s.filter((e=>e!==i)):this.value=a?i:null,this.dispatchEvent(new Y(this.value))}}),c=n(ne||(ne=me` <div> ${0} </div> `),e===ge?this._t("choice.other").toString():n(re||(re=me`<slot name="${0}">${0}</slot>`),`${e}-label`,this.getText(e)));return n(le||(le=me` <div class="ml-xxl border-t border-contrast-10 ${0}"></div> ${0} <div class="mr-m ml-xxl"> ${0} ${0} </div> `),i?"":"hidden",t?function(e,t,a,i,s){const r="transition ease-in-out duration-200",l=`${r} transform ${a?"scale-100":"scale-0"} ${e?"text-contrast-70":"text-tint"}`;return n(ae||(ae=me` <label class="group flex items-center ${0}"> <div class="item flex items-center justify-center flex-shrink-0 text-primary-contrast"> <div class="check rounded-s ${0} ${0} ${0} focus-within-shadow-outline"> <iron-icon icon="lumo:checkmark" class="block w-full h-full ${0}"></iron-icon> <input type="checkbox" class="sr-only" .checked="${0}" ...="${0}"> </div> </div> <div class="font-lumo leading-m ${0}">${0}</div> </label> `),t||e?"":"cursor-pointer","border "+(e?"border-dashed border-contrast-30":"border-transparent"),r,e?"":t?a?"bg-primary-50":"bg-contrast-10":a?"bg-primary":"bg-contrast-20 group-hover-bg-contrast-30",l,a,i,t?"text-disabled":e?"text-secondary":"text-body",s)}(this.readonly,d,o,u,c):function(e,t,a,i,s){const r="transition ease-in-out duration-200",l=`${r} ${t||e?"":"shadow-xs"} transform ${a?"scale-100":"scale-0"} ${e?"bg-contrast-70":"bg-tint"}`;return n(te||(te=me` <label class="group flex items-center ${0}"> <div class="item flex items-center justify-center flex-shrink-0"> <div class="flex radio rounded-full ${0} ${0} ${0} focus-within-shadow-outline"> <div class="dot m-auto rounded-full ${0}"></div> <input type="radio" class="sr-only" .checked="${0}" ...="${0}"> </div> </div> <div class="font-lumo leading-m ${0}">${0}</div> </label> `),t||e?"":"cursor-pointer","border "+(e?"border-dashed border-contrast-30":"border-transparent"),r,e?"":t?a?"bg-primary-50":"bg-contrast-10":a?"bg-primary":"bg-contrast-20 group-hover-bg-contrast-30",l,a,i,t?"text-disabled":e?"text-secondary":"text-body",s)}(this.readonly,d,o,u,c),e===ge&&a?this.__field:"",e!==ge?n(oe||(oe=me`<slot name="${0}"></slot>`),e):"")})));return n(de||(de=me`<form>${0}</form> `),i)}get __field(){const e=L({placeholder:this._t("choice.other").toString(),class:"w-full mb-m",value:this.__service.state.context.customValue,max:this.max,min:this.min,"?disabled":this.disabled,"?readonly":this.readonly,"data-testid":"field","@change":e=>{e.stopPropagation();const t=e.target.value;Array.isArray(this.value)?this.value=this.value.slice(0,this.value.length-1).concat(t):this.value=t,this.dispatchEvent(new Y(this.value))}});return"frequency"===this.type?n(ue||(ue=me`<x-frequency-input ...="${0}"></x-frequency-input>`),e):"integer"===this.type?n(ce||(ce=me`<vaadin-integer-field ...="${0}" has-controls></vaadin-integer-field>`),e):"textarea"===this.type?n(he||(he=me`<vaadin-text-area ...="${0}"></vaadin-text-area>`),e):n(pe||(pe=me`<vaadin-text-field ...="${0}"></vaadin-text-field>`),e)}}export{ve as C,W as D,R as I,Y as a,B as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as t}from"./shared-63eaded9.js";import{T as e}from"./shared-
|
|
1
|
+
import{_ as t}from"./shared-63eaded9.js";import{T as e}from"./shared-2b685624.js";import{a as s}from"./shared-4168c6cd.js";import{p as a}from"./shared-6b7602c7.js";let n,o,r,i,c=t=>t;class l extends(s(e,"subscriptions-table")){constructor(){super(...arguments),this.columns=[l.priceColumn,l.summaryColumn,l.statusColumn,l.subTokenURLColumn]}}l.priceColumn={cell:e=>{const s=e.data._embedded["fx:last_transaction"],o=`${s.total_order} ${s.currency_code}`;return e.html(n||(n=c`
|
|
2
2
|
<foxy-i18n
|
|
3
3
|
data-testclass="i18n frequencies"
|
|
4
4
|
class="font-semibold text-m font-tnum"
|
|
@@ -4,6 +4,7 @@ declare const InternalCustomerPortalLink_base: typeof LitElement & {
|
|
|
4
4
|
};
|
|
5
5
|
export declare class InternalCustomerPortalLink extends InternalCustomerPortalLink_base {
|
|
6
6
|
static get properties(): PropertyDeclarations;
|
|
7
|
+
disabled: boolean;
|
|
7
8
|
href: string;
|
|
8
9
|
icon: string;
|
|
9
10
|
render(): TemplateResult;
|
|
@@ -1,28 +1,37 @@
|
|
|
1
1
|
import { LitElement, html } from 'lit-element';
|
|
2
2
|
import { ThemeableMixin } from "../../../mixins/themeable.js";
|
|
3
|
+
import { classMap } from "../../../utils/class-map.js";
|
|
3
4
|
export class InternalCustomerPortalLink extends ThemeableMixin(LitElement) {
|
|
4
5
|
constructor() {
|
|
5
6
|
super(...arguments);
|
|
7
|
+
this.disabled = false;
|
|
6
8
|
this.href = '';
|
|
7
9
|
this.icon = '';
|
|
8
10
|
}
|
|
9
11
|
static get properties() {
|
|
10
12
|
return {
|
|
11
13
|
...super.properties,
|
|
14
|
+
disabled: { type: Boolean },
|
|
12
15
|
href: { type: String },
|
|
13
16
|
icon: { type: String },
|
|
14
17
|
};
|
|
15
18
|
}
|
|
16
19
|
render() {
|
|
20
|
+
const actionClass = classMap({
|
|
21
|
+
'flex-auto font-medium tracking-wide text-s rounded-s transition-colors': true,
|
|
22
|
+
'hover-text-primary hover-cursor-pointer': !this.disabled,
|
|
23
|
+
'focus-outline-none focus-ring-2 ring-primary-50 ring-offset-2': !this.disabled,
|
|
24
|
+
'text-disabled cursor-default': this.disabled,
|
|
25
|
+
});
|
|
26
|
+
const actionContent = html `
|
|
27
|
+
${this.icon ? html `<iron-icon icon=${this.icon} class="icon-inline"></iron-icon>` : ''}
|
|
28
|
+
<slot></slot>
|
|
29
|
+
`;
|
|
30
|
+
if (this.disabled) {
|
|
31
|
+
return html `<button class=${actionClass} disabled>${actionContent}</button>`;
|
|
32
|
+
}
|
|
17
33
|
return html `
|
|
18
|
-
<a
|
|
19
|
-
class="flex-auto font-medium tracking-wide cursor-pointer text-s rounded-s hover-text-primary focus-text-primary focus-outline-none focus-ring-2 focus-ring-primary-50 focus-ring-offset-2"
|
|
20
|
-
href=${this.href}
|
|
21
|
-
rel="nofollow noopener"
|
|
22
|
-
>
|
|
23
|
-
${this.icon ? html `<iron-icon icon=${this.icon} class="icon-inline"></iron-icon>` : ''}
|
|
24
|
-
<slot></slot>
|
|
25
|
-
</a>
|
|
34
|
+
<a class=${actionClass} href=${this.href} rel="nofollow noopener">${actionContent}</a>
|
|
26
35
|
`;
|
|
27
36
|
}
|
|
28
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalCustomerPortalLink.js","sourceRoot":"","sources":["../../../../src/elements/public/CustomerPortal/InternalCustomerPortalLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAwC,IAAI,EAAE,MAAM,aAAa,CAAC;AAErF,OAAO,EAAE,cAAc,EAAE,qCAAkC;
|
|
1
|
+
{"version":3,"file":"InternalCustomerPortalLink.js","sourceRoot":"","sources":["../../../../src/elements/public/CustomerPortal/InternalCustomerPortalLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAwC,IAAI,EAAE,MAAM,aAAa,CAAC;AAErF,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AAEpD,MAAM,OAAO,0BAA2B,SAAQ,cAAc,CAAC,UAAU,CAAC;IAA1E;;QAUE,aAAQ,GAAG,KAAK,CAAC;QAEjB,SAAI,GAAG,EAAE,CAAC;QAEV,SAAI,GAAG,EAAE,CAAC;IAuBZ,CAAC;IApCC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;YAC3B,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;YACtB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;SACvB,CAAC;IACJ,CAAC;IAQD,MAAM;QACJ,MAAM,WAAW,GAAG,QAAQ,CAAC;YAC3B,wEAAwE,EAAE,IAAI;YAC9E,yCAAyC,EAAE,CAAC,IAAI,CAAC,QAAQ;YACzD,+DAA+D,EAAE,CAAC,IAAI,CAAC,QAAQ;YAC/E,8BAA8B,EAAE,IAAI,CAAC,QAAQ;SAC9C,CAAC,CAAC;QAEH,MAAM,aAAa,GAAG,IAAI,CAAA;QACtB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA,mBAAmB,IAAI,CAAC,IAAI,mCAAmC,CAAC,CAAC,CAAC,EAAE;;KAEvF,CAAC;QAEF,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,OAAO,IAAI,CAAA,iBAAiB,WAAW,aAAa,aAAa,WAAW,CAAC;SAC9E;QAED,OAAO,IAAI,CAAA;iBACE,WAAW,SAAS,IAAI,CAAC,IAAI,4BAA4B,aAAa;KAClF,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { LitElement, PropertyDeclarations, TemplateResult, html } from 'lit-element';\n\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { classMap } from '../../../utils/class-map';\n\nexport class InternalCustomerPortalLink extends ThemeableMixin(LitElement) {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n disabled: { type: Boolean },\n href: { type: String },\n icon: { type: String },\n };\n }\n\n disabled = false;\n\n href = '';\n\n icon = '';\n\n render(): TemplateResult {\n const actionClass = classMap({\n 'flex-auto font-medium tracking-wide text-s rounded-s transition-colors': true,\n 'hover-text-primary hover-cursor-pointer': !this.disabled,\n 'focus-outline-none focus-ring-2 ring-primary-50 ring-offset-2': !this.disabled,\n 'text-disabled cursor-default': this.disabled,\n });\n\n const actionContent = html`\n ${this.icon ? html`<iron-icon icon=${this.icon} class=\"icon-inline\"></iron-icon>` : ''}\n <slot></slot>\n `;\n\n if (this.disabled) {\n return html`<button class=${actionClass} disabled>${actionContent}</button>`;\n }\n\n return html`\n <a class=${actionClass} href=${this.href} rel=\"nofollow noopener\">${actionContent}</a>\n `;\n }\n}\n"]}
|
|
@@ -12,8 +12,10 @@ export class InternalCustomerPortalSubscriptions extends Base {
|
|
|
12
12
|
this.customer = null;
|
|
13
13
|
this.group = '';
|
|
14
14
|
this.__renderFormHeaderActionsUpdate = (html, host) => {
|
|
15
|
+
var _a;
|
|
16
|
+
const hasEnded = !!((_a = host.data) === null || _a === void 0 ? void 0 : _a.end_date) && new Date(host.data.end_date).getTime() <= Date.now();
|
|
15
17
|
let billingLink = '';
|
|
16
|
-
if (host.in({ idle: 'snapshot' })) {
|
|
18
|
+
if (!hasEnded && host.in({ idle: 'snapshot' })) {
|
|
17
19
|
const link = host.data._links['fx:sub_token_url'].href;
|
|
18
20
|
const updateBillingURL = new URL(link);
|
|
19
21
|
updateBillingURL.searchParams.set('cart', 'checkout');
|
|
@@ -27,6 +29,7 @@ export class InternalCustomerPortalSubscriptions extends Base {
|
|
|
27
29
|
data-testid="header:actions:update"
|
|
28
30
|
href=${billingLink}
|
|
29
31
|
icon="icons:credit-card"
|
|
32
|
+
?disabled=${hasEnded || !host.in('idle')}
|
|
30
33
|
>
|
|
31
34
|
<foxy-i18n lang=${host.lang} key="update_billing" ns=${host.ns}></foxy-i18n>
|
|
32
35
|
</foxy-internal-customer-portal-link>
|
|
@@ -35,8 +38,10 @@ export class InternalCustomerPortalSubscriptions extends Base {
|
|
|
35
38
|
`;
|
|
36
39
|
};
|
|
37
40
|
this.__renderFormHeaderActionsEnd = (html, host) => {
|
|
41
|
+
var _a;
|
|
42
|
+
const hasEndDate = !!((_a = host.data) === null || _a === void 0 ? void 0 : _a.end_date);
|
|
38
43
|
let cancelLink = '';
|
|
39
|
-
if (host.in({ idle: 'snapshot' })) {
|
|
44
|
+
if (!hasEndDate && host.in({ idle: 'snapshot' })) {
|
|
40
45
|
const cancelURL = new URL(host.data._links['fx:sub_token_url'].href);
|
|
41
46
|
cancelURL.searchParams.set('sub_cancel', 'true');
|
|
42
47
|
cancelLink = cancelURL.toString();
|
|
@@ -48,6 +53,7 @@ export class InternalCustomerPortalSubscriptions extends Base {
|
|
|
48
53
|
data-testid="header:actions:end"
|
|
49
54
|
href=${cancelLink}
|
|
50
55
|
icon="icons:block"
|
|
56
|
+
?disabled=${hasEndDate || !host.in('idle')}
|
|
51
57
|
>
|
|
52
58
|
<foxy-i18n lang=${host.lang} key="end_subscription" ns=${host.ns}></foxy-i18n>
|
|
53
59
|
</foxy-internal-customer-portal-link>
|
|
@@ -81,9 +87,10 @@ export class InternalCustomerPortalSubscriptions extends Base {
|
|
|
81
87
|
`;
|
|
82
88
|
};
|
|
83
89
|
this.__renderFormItemsActionsUpdate = (html, host) => {
|
|
84
|
-
var _a, _b, _c;
|
|
90
|
+
var _a, _b, _c, _d;
|
|
85
91
|
// @ts-expect-error missing typedef in SDK
|
|
86
92
|
const itemsLink = (_c = (_b = (_a = host.data) === null || _a === void 0 ? void 0 : _a._links['fx:sub_modification_url']) === null || _b === void 0 ? void 0 : _b.href) !== null && _c !== void 0 ? _c : '';
|
|
93
|
+
const hasEnded = !!((_d = host.data) === null || _d === void 0 ? void 0 : _d.end_date) && new Date(host.data.end_date).getTime() <= Date.now();
|
|
87
94
|
return html `
|
|
88
95
|
${host.renderTemplateOrSlot('items:actions:update:before')}
|
|
89
96
|
|
|
@@ -91,6 +98,7 @@ export class InternalCustomerPortalSubscriptions extends Base {
|
|
|
91
98
|
data-testid="items:actions:update"
|
|
92
99
|
class="text-primary"
|
|
93
100
|
href=${itemsLink}
|
|
101
|
+
?disabled=${hasEnded || !host.in('idle')}
|
|
94
102
|
>
|
|
95
103
|
<foxy-i18n lang=${host.lang} key="update_items" ns=${host.ns}></foxy-i18n>
|
|
96
104
|
</foxy-internal-customer-portal-link>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalCustomerPortalSubscriptions.js","sourceRoot":"","sources":["../../../../src/elements/public/CustomerPortal/InternalCustomerPortalSubscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAY,wCAAqC;AAE3E,OAAO,EAAE,UAAU,EAAwC,IAAI,EAAE,MAAM,aAAa,CAAC;AAQrF,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,IAAI,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,cAAc,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AAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE;;KAEzE,CAAC;IACJ,CAAC;IAED,IAAY,oBAAoB;QAC9B,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,sBAAsB,CAAe,CAAC;IAC7E,CAAC;IAED,IAAY,yBAAyB;QACnC,IAAI;YACF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,QAAS,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,CAAC;YACpE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,6CAA6C,CAAC,CAAC;YAC5E,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;SACvB;QAAC,WAAM;YACN,OAAO,EAAE,CAAC;SACX;IACH,CAAC;CACF","sourcesContent":["import { ConfigurableMixin, Renderer } from '../../../mixins/configurable';\nimport { Graph, Rels } from '@foxy.io/sdk/customer';\nimport { LitElement, PropertyDeclarations, TemplateResult, html } from 'lit-element';\n\nimport { FormDialog } from '../FormDialog/FormDialog';\nimport { FormRendererContext } from '../FormDialog/types';\nimport { ItemRenderer } from '../CollectionPage/types';\nimport { PageRenderer } from '../CollectionPages/types';\nimport { Resource } from '@foxy.io/sdk/core';\nimport { SubscriptionForm } from '../SubscriptionForm/SubscriptionForm';\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 Base = TranslatableMixin(ConfigurableMixin(ThemeableMixin(LitElement)));\n\nexport class InternalCustomerPortalSubscriptions extends Base {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n settings: { attribute: false },\n customer: { attribute: false },\n group: { type: String },\n };\n }\n\n settings: Resource<Rels.CustomerPortalSettings> | null = null;\n\n customer: Resource<Graph> | null = null;\n\n group = '';\n\n private readonly __renderFormHeaderActionsUpdate: Renderer<SubscriptionForm> = (html, host) => {\n let billingLink = '';\n\n if (host.in({ idle: 'snapshot' })) {\n const link = host.data._links['fx:sub_token_url'].href;\n const updateBillingURL = new URL(link);\n\n updateBillingURL.searchParams.set('cart', 'checkout');\n updateBillingURL.searchParams.set('sub_restart', 'auto');\n billingLink = updateBillingURL.toString();\n }\n\n return html`\n ${host.renderTemplateOrSlot('header:actions:update:before')}\n\n <foxy-internal-customer-portal-link\n data-testid=\"header:actions:update\"\n href=${billingLink}\n icon=\"icons:credit-card\"\n >\n <foxy-i18n lang=${host.lang} key=\"update_billing\" ns=${host.ns}></foxy-i18n>\n </foxy-internal-customer-portal-link>\n\n ${host.renderTemplateOrSlot('header:actions:update:after')}\n `;\n };\n\n private readonly __renderFormHeaderActionsEnd: Renderer<SubscriptionForm> = (html, host) => {\n let cancelLink = '';\n\n if (host.in({ idle: 'snapshot' })) {\n const cancelURL = new URL(host.data._links['fx:sub_token_url'].href);\n\n cancelURL.searchParams.set('sub_cancel', 'true');\n cancelLink = cancelURL.toString();\n }\n\n return html`\n ${host.renderTemplateOrSlot('header:actions:end:before')}\n\n <foxy-internal-customer-portal-link\n data-testid=\"header:actions:end\"\n href=${cancelLink}\n icon=\"icons:block\"\n >\n <foxy-i18n lang=${host.lang} key=\"end_subscription\" ns=${host.ns}></foxy-i18n>\n </foxy-internal-customer-portal-link>\n\n ${host.renderTemplateOrSlot('header:actions:end:after')}\n `;\n };\n\n private readonly __renderFormHeaderActions: Renderer<SubscriptionForm> = (html, host) => {\n const isUpdateActionHidden = host.hiddenSelector.matches('header:actions:update');\n const isEndActionHidden = host.hiddenSelector.matches('header:actions:end');\n\n return html`\n <style>\n main {\n display: flex;\n justify-content: space-between;\n padding-top: var(--lumo-space-xs);\n margin-top: var(--lumo-space-s);\n border-top: 1px solid var(--lumo-contrast-10pct);\n color: var(--lumo-secondary-color);\n }\n </style>\n\n ${host.renderTemplateOrSlot('header:actions:before')}\n\n <main data-testid=\"header:actions\">\n ${isUpdateActionHidden ? '' : this.__renderFormHeaderActionsUpdate(html, host)}\n ${isEndActionHidden ? '' : this.__renderFormHeaderActionsEnd(html, host)}\n </main>\n\n ${host.renderTemplateOrSlot('header:actions:after')}\n `;\n };\n\n private readonly __renderFormItemsActionsUpdate: Renderer<SubscriptionForm> = (html, host) => {\n // @ts-expect-error missing typedef in SDK\n const itemsLink = host.data?._links['fx:sub_modification_url']?.href ?? '';\n\n return html`\n ${host.renderTemplateOrSlot('items:actions:update:before')}\n\n <foxy-internal-customer-portal-link\n data-testid=\"items:actions:update\"\n class=\"text-primary\"\n href=${itemsLink}\n >\n <foxy-i18n lang=${host.lang} key=\"update_items\" ns=${host.ns}></foxy-i18n>\n </foxy-internal-customer-portal-link>\n\n ${host.renderTemplateOrSlot('items:actions:update:after')}\n `;\n };\n\n private readonly __renderForm = (ctx: FormRendererContext) => {\n const templates = { ...ctx.dialog.templates };\n const originalHeaderAfterRenderer = templates['header:after'];\n const originalItemsActionsAfterRenderer = templates['items:actions:after'];\n\n templates['header:after'] = (html, host) => {\n const actionsHidden = host.hiddenSelector.matches('header:actions', true);\n return html`\n ${actionsHidden ? '' : this.__renderFormHeaderActions(html, host)}\n ${originalHeaderAfterRenderer?.(html, host)}\n `;\n };\n\n templates['items:actions:after'] = (html, host) => {\n const hasUpdateLink = !!host.data?._links['fx:sub_modification_url'];\n const isUpdateHidden = host.hiddenSelector.matches('items:actions:update', true);\n const isUpdateRendered = hasUpdateLink && !isUpdateHidden;\n\n return html`\n ${isUpdateRendered ? this.__renderFormItemsActionsUpdate(html, host) : ''}\n ${originalItemsActionsAfterRenderer?.(html, host)}\n `;\n };\n\n return html`\n <foxy-subscription-form\n disabledcontrols=${ctx.dialog.disabledControls.toString()}\n readonlycontrols=${ctx.dialog.readonlyControls.toString()}\n hiddencontrols=${ctx.dialog.hiddenControls.toString()}\n settings=${JSON.stringify(this.settings)}\n parent=${ctx.dialog.parent}\n group=${ctx.dialog.group}\n lang=${ctx.dialog.lang}\n href=${ctx.dialog.href}\n ns=${ctx.dialog.ns}\n id=\"form\"\n .templates=${templates}\n @update=${ctx.handleUpdate}\n @fetch=${ctx.handleFetch}\n >\n </foxy-subscription-form>\n `;\n };\n\n private readonly __renderPageItem: ItemRenderer = ({ html, ...ctx }) => {\n return html`\n <button\n class=${classMap({\n 'block w-full border border-contrast-10 p-m rounded-t-l rounded-b-l': true,\n 'focus-outline-none focus-border-primary': true,\n 'hover-border-contrast-30': ctx.data !== null,\n })}\n ?disabled=${ctx.data === null}\n @click=${(evt: Event) => {\n const url = new URL(ctx.href);\n url.searchParams.set('zoom', 'last_transaction,transaction_template:items');\n this.__subscriptionDialog.href = url.toString();\n this.__subscriptionDialog.show(evt.currentTarget as HTMLButtonElement);\n }}\n >\n <foxy-subscription-card\n parent=${ctx.parent}\n group=${ctx.group}\n lang=${ctx.lang}\n href=${ctx.href}\n ns=\"${ctx.ns} ${customElements.get('foxy-subscription-card')?.defaultNS ?? ''}\"\n .templates=${ctx.templates}\n >\n </foxy-subscription-card>\n </button>\n `;\n };\n\n private readonly __renderPage: PageRenderer<any> = ({ html, ...ctx }) => {\n return html`\n <foxy-collection-page\n ns=${ctx.ns}\n href=${ctx.href}\n lang=${ctx.lang}\n group=${ctx.group}\n class=\"space-y-m\"\n .item=${this.__renderPageItem}\n .templates=${ctx.templates}\n >\n </foxy-collection-page>\n `;\n };\n\n private readonly __renderHeader = () => {\n return html`\n ${this.renderTemplateOrSlot('header:before')}\n\n <foxy-i18n\n class=\"block text-l font-semibold\"\n lang=${this.lang}\n key=\"subscription_plural\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n ${this.renderTemplateOrSlot('header:after')}\n `;\n };\n\n private readonly __renderList = () => {\n const disabledSelector = this.disabledSelector.zoom('list');\n const readonlySelector = this.readonlySelector.zoom('list');\n const hiddenSelector = this.hiddenSelector.zoom('list');\n const extendedHiddenControlsArray = [hiddenSelector.zoom('form').toString(), 'end-date'];\n\n return html`\n ${this.renderTemplateOrSlot('list:before')}\n\n <foxy-form-dialog\n readonlycontrols=${readonlySelector.zoom('form').toString()}\n disabledcontrols=${disabledSelector.zoom('form').toString()}\n hiddencontrols=${extendedHiddenControlsArray.join(' ').trim()}\n header=\"update\"\n parent=${ifDefined(this.customer?._links['fx:subscriptions'].href)}\n group=${this.group}\n lang=${this.lang}\n ns=${this.ns}\n id=\"subscription-dialog\"\n .form=${this.__renderForm}\n .templates=${this.getNestedTemplates('list:form')}\n >\n </foxy-form-dialog>\n\n <foxy-collection-pages\n class=\"block space-y-m\"\n first=${this.__activeSubscriptionsLink}\n group=${this.group}\n lang=${this.lang}\n ns=${this.ns}\n manual\n .page=${this.__renderPage}\n .templates=${this.getNestedTemplates('list:card')}\n >\n </foxy-collection-pages>\n\n ${this.renderTemplateOrSlot('list:after')}\n `;\n };\n\n render(): TemplateResult {\n return html`\n <div class=\"space-y-s\" data-testid=\"subscriptions\">\n ${this.hiddenSelector.matches('header', true) ? '' : this.__renderHeader()}\n ${this.hiddenSelector.matches('list', true) ? '' : this.__renderList()}\n </div>\n `;\n }\n\n private get __subscriptionDialog() {\n return this.renderRoot.querySelector('#subscription-dialog') as FormDialog;\n }\n\n private get __activeSubscriptionsLink() {\n try {\n const url = new URL(this.customer!._links['fx:subscriptions'].href);\n url.searchParams.set('zoom', 'last_transaction,transaction_template:items');\n return url.toString();\n } catch {\n return '';\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"InternalCustomerPortalSubscriptions.js","sourceRoot":"","sources":["../../../../src/elements/public/CustomerPortal/InternalCustomerPortalSubscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAY,wCAAqC;AAE3E,OAAO,EAAE,UAAU,EAAwC,IAAI,EAAE,MAAM,aAAa,CAAC;AAQrF,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,SA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QAAQ,EAAE,CAAC;SACvB;QAAC,WAAM;YACN,OAAO,EAAE,CAAC;SACX;IACH,CAAC;CACF","sourcesContent":["import { ConfigurableMixin, Renderer } from '../../../mixins/configurable';\nimport { Graph, Rels } from '@foxy.io/sdk/customer';\nimport { LitElement, PropertyDeclarations, TemplateResult, html } from 'lit-element';\n\nimport { FormDialog } from '../FormDialog/FormDialog';\nimport { FormRendererContext } from '../FormDialog/types';\nimport { ItemRenderer } from '../CollectionPage/types';\nimport { PageRenderer } from '../CollectionPages/types';\nimport { Resource } from '@foxy.io/sdk/core';\nimport { SubscriptionForm } from '../SubscriptionForm/SubscriptionForm';\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 Base = TranslatableMixin(ConfigurableMixin(ThemeableMixin(LitElement)));\n\nexport class InternalCustomerPortalSubscriptions extends Base {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n settings: { attribute: false },\n customer: { attribute: false },\n group: { type: String },\n };\n }\n\n settings: Resource<Rels.CustomerPortalSettings> | null = null;\n\n customer: Resource<Graph> | null = null;\n\n group = '';\n\n private readonly __renderFormHeaderActionsUpdate: Renderer<SubscriptionForm> = (html, host) => {\n const hasEnded = !!host.data?.end_date && new Date(host.data.end_date).getTime() <= Date.now();\n let billingLink = '';\n\n if (!hasEnded && host.in({ idle: 'snapshot' })) {\n const link = host.data._links['fx:sub_token_url'].href;\n const updateBillingURL = new URL(link);\n\n updateBillingURL.searchParams.set('cart', 'checkout');\n updateBillingURL.searchParams.set('sub_restart', 'auto');\n billingLink = updateBillingURL.toString();\n }\n\n return html`\n ${host.renderTemplateOrSlot('header:actions:update:before')}\n\n <foxy-internal-customer-portal-link\n data-testid=\"header:actions:update\"\n href=${billingLink}\n icon=\"icons:credit-card\"\n ?disabled=${hasEnded || !host.in('idle')}\n >\n <foxy-i18n lang=${host.lang} key=\"update_billing\" ns=${host.ns}></foxy-i18n>\n </foxy-internal-customer-portal-link>\n\n ${host.renderTemplateOrSlot('header:actions:update:after')}\n `;\n };\n\n private readonly __renderFormHeaderActionsEnd: Renderer<SubscriptionForm> = (html, host) => {\n const hasEndDate = !!host.data?.end_date;\n let cancelLink = '';\n\n if (!hasEndDate && host.in({ idle: 'snapshot' })) {\n const cancelURL = new URL(host.data._links['fx:sub_token_url'].href);\n\n cancelURL.searchParams.set('sub_cancel', 'true');\n cancelLink = cancelURL.toString();\n }\n\n return html`\n ${host.renderTemplateOrSlot('header:actions:end:before')}\n\n <foxy-internal-customer-portal-link\n data-testid=\"header:actions:end\"\n href=${cancelLink}\n icon=\"icons:block\"\n ?disabled=${hasEndDate || !host.in('idle')}\n >\n <foxy-i18n lang=${host.lang} key=\"end_subscription\" ns=${host.ns}></foxy-i18n>\n </foxy-internal-customer-portal-link>\n\n ${host.renderTemplateOrSlot('header:actions:end:after')}\n `;\n };\n\n private readonly __renderFormHeaderActions: Renderer<SubscriptionForm> = (html, host) => {\n const isUpdateActionHidden = host.hiddenSelector.matches('header:actions:update');\n const isEndActionHidden = host.hiddenSelector.matches('header:actions:end');\n\n return html`\n <style>\n main {\n display: flex;\n justify-content: space-between;\n padding-top: var(--lumo-space-xs);\n margin-top: var(--lumo-space-s);\n border-top: 1px solid var(--lumo-contrast-10pct);\n color: var(--lumo-secondary-color);\n }\n </style>\n\n ${host.renderTemplateOrSlot('header:actions:before')}\n\n <main data-testid=\"header:actions\">\n ${isUpdateActionHidden ? '' : this.__renderFormHeaderActionsUpdate(html, host)}\n ${isEndActionHidden ? '' : this.__renderFormHeaderActionsEnd(html, host)}\n </main>\n\n ${host.renderTemplateOrSlot('header:actions:after')}\n `;\n };\n\n private readonly __renderFormItemsActionsUpdate: Renderer<SubscriptionForm> = (html, host) => {\n // @ts-expect-error missing typedef in SDK\n const itemsLink = host.data?._links['fx:sub_modification_url']?.href ?? '';\n const hasEnded = !!host.data?.end_date && new Date(host.data.end_date).getTime() <= Date.now();\n\n return html`\n ${host.renderTemplateOrSlot('items:actions:update:before')}\n\n <foxy-internal-customer-portal-link\n data-testid=\"items:actions:update\"\n class=\"text-primary\"\n href=${itemsLink}\n ?disabled=${hasEnded || !host.in('idle')}\n >\n <foxy-i18n lang=${host.lang} key=\"update_items\" ns=${host.ns}></foxy-i18n>\n </foxy-internal-customer-portal-link>\n\n ${host.renderTemplateOrSlot('items:actions:update:after')}\n `;\n };\n\n private readonly __renderForm = (ctx: FormRendererContext) => {\n const templates = { ...ctx.dialog.templates };\n const originalHeaderAfterRenderer = templates['header:after'];\n const originalItemsActionsAfterRenderer = templates['items:actions:after'];\n\n templates['header:after'] = (html, host) => {\n const actionsHidden = host.hiddenSelector.matches('header:actions', true);\n return html`\n ${actionsHidden ? '' : this.__renderFormHeaderActions(html, host)}\n ${originalHeaderAfterRenderer?.(html, host)}\n `;\n };\n\n templates['items:actions:after'] = (html, host) => {\n const hasUpdateLink = !!host.data?._links['fx:sub_modification_url'];\n const isUpdateHidden = host.hiddenSelector.matches('items:actions:update', true);\n const isUpdateRendered = hasUpdateLink && !isUpdateHidden;\n\n return html`\n ${isUpdateRendered ? this.__renderFormItemsActionsUpdate(html, host) : ''}\n ${originalItemsActionsAfterRenderer?.(html, host)}\n `;\n };\n\n return html`\n <foxy-subscription-form\n disabledcontrols=${ctx.dialog.disabledControls.toString()}\n readonlycontrols=${ctx.dialog.readonlyControls.toString()}\n hiddencontrols=${ctx.dialog.hiddenControls.toString()}\n settings=${JSON.stringify(this.settings)}\n parent=${ctx.dialog.parent}\n group=${ctx.dialog.group}\n lang=${ctx.dialog.lang}\n href=${ctx.dialog.href}\n ns=${ctx.dialog.ns}\n id=\"form\"\n .templates=${templates}\n @update=${ctx.handleUpdate}\n @fetch=${ctx.handleFetch}\n >\n </foxy-subscription-form>\n `;\n };\n\n private readonly __renderPageItem: ItemRenderer = ({ html, ...ctx }) => {\n return html`\n <button\n class=${classMap({\n 'block w-full border border-contrast-10 p-m rounded-t-l rounded-b-l': true,\n 'focus-outline-none focus-border-primary': true,\n 'hover-border-contrast-30': ctx.data !== null,\n })}\n ?disabled=${ctx.data === null}\n @click=${(evt: Event) => {\n const url = new URL(ctx.href);\n url.searchParams.set('zoom', 'last_transaction,transaction_template:items');\n this.__subscriptionDialog.href = url.toString();\n this.__subscriptionDialog.show(evt.currentTarget as HTMLButtonElement);\n }}\n >\n <foxy-subscription-card\n parent=${ctx.parent}\n group=${ctx.group}\n lang=${ctx.lang}\n href=${ctx.href}\n ns=\"${ctx.ns} ${customElements.get('foxy-subscription-card')?.defaultNS ?? ''}\"\n .templates=${ctx.templates}\n >\n </foxy-subscription-card>\n </button>\n `;\n };\n\n private readonly __renderPage: PageRenderer<any> = ({ html, ...ctx }) => {\n return html`\n <foxy-collection-page\n ns=${ctx.ns}\n href=${ctx.href}\n lang=${ctx.lang}\n group=${ctx.group}\n class=\"space-y-m\"\n .item=${this.__renderPageItem}\n .templates=${ctx.templates}\n >\n </foxy-collection-page>\n `;\n };\n\n private readonly __renderHeader = () => {\n return html`\n ${this.renderTemplateOrSlot('header:before')}\n\n <foxy-i18n\n class=\"block text-l font-semibold\"\n lang=${this.lang}\n key=\"subscription_plural\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n ${this.renderTemplateOrSlot('header:after')}\n `;\n };\n\n private readonly __renderList = () => {\n const disabledSelector = this.disabledSelector.zoom('list');\n const readonlySelector = this.readonlySelector.zoom('list');\n const hiddenSelector = this.hiddenSelector.zoom('list');\n const extendedHiddenControlsArray = [hiddenSelector.zoom('form').toString(), 'end-date'];\n\n return html`\n ${this.renderTemplateOrSlot('list:before')}\n\n <foxy-form-dialog\n readonlycontrols=${readonlySelector.zoom('form').toString()}\n disabledcontrols=${disabledSelector.zoom('form').toString()}\n hiddencontrols=${extendedHiddenControlsArray.join(' ').trim()}\n header=\"update\"\n parent=${ifDefined(this.customer?._links['fx:subscriptions'].href)}\n group=${this.group}\n lang=${this.lang}\n ns=${this.ns}\n id=\"subscription-dialog\"\n .form=${this.__renderForm}\n .templates=${this.getNestedTemplates('list:form')}\n >\n </foxy-form-dialog>\n\n <foxy-collection-pages\n class=\"block space-y-m\"\n first=${this.__activeSubscriptionsLink}\n group=${this.group}\n lang=${this.lang}\n ns=${this.ns}\n manual\n .page=${this.__renderPage}\n .templates=${this.getNestedTemplates('list:card')}\n >\n </foxy-collection-pages>\n\n ${this.renderTemplateOrSlot('list:after')}\n `;\n };\n\n render(): TemplateResult {\n return html`\n <div class=\"space-y-s\" data-testid=\"subscriptions\">\n ${this.hiddenSelector.matches('header', true) ? '' : this.__renderHeader()}\n ${this.hiddenSelector.matches('list', true) ? '' : this.__renderList()}\n </div>\n `;\n }\n\n private get __subscriptionDialog() {\n return this.renderRoot.querySelector('#subscription-dialog') as FormDialog;\n }\n\n private get __activeSubscriptionsLink() {\n try {\n const url = new URL(this.customer!._links['fx:subscriptions'].href);\n url.searchParams.set('zoom', 'last_transaction,transaction_template:items');\n return url.toString();\n } catch {\n return '';\n }\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CSSResultArray, LitElement, PropertyDeclarations, TemplateResult } from 'lit-element';
|
|
2
2
|
import { PreviewItem } from './Preview';
|
|
3
3
|
export declare class Picture extends LitElement {
|
|
4
|
+
static readonly 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";
|
|
4
5
|
static get properties(): PropertyDeclarations;
|
|
5
6
|
static get styles(): CSSResultArray;
|
|
6
7
|
quantity: number;
|
|
@@ -141,6 +141,7 @@ export class Picture extends LitElement {
|
|
|
141
141
|
const image = new Image();
|
|
142
142
|
image.src = this.image;
|
|
143
143
|
image.setAttribute('part', 'picture');
|
|
144
|
+
image.addEventListener('error', () => (image.src = Picture.placeholder));
|
|
144
145
|
this.__setImageState(image, state);
|
|
145
146
|
this.__container.insertBefore(image, refChild);
|
|
146
147
|
return image;
|
|
@@ -158,4 +159,5 @@ export class Picture extends LitElement {
|
|
|
158
159
|
image.className = [shared, states[state]].join(' ');
|
|
159
160
|
}
|
|
160
161
|
}
|
|
162
|
+
Picture.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';
|
|
161
163
|
//# sourceMappingURL=Picture.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Picture.js","sourceRoot":"","sources":["../../../../../src/elements/public/ItemsForm/private/Picture.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAGV,GAAG,EACH,IAAI,GACL,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,SAAS,EAAE,wCAAqC;AAEzD,IAAK,UAMJ;AAND,WAAK,UAAU;IACb,mDAAY,CAAA;IACZ,yDAAe,CAAA;IACf,iDAAW,CAAA;IACX,mDAAY,CAAA;IACZ,uDAAc,CAAA;AAChB,CAAC,EANI,UAAU,KAAV,UAAU,QAMd;AAED,MAAM,OAAO,OAAQ,SAAQ,UAAU;IAAvC;;QAgDS,aAAQ,GAAG,CAAC,CAAC;QAEb,UAAK,GAAG,EAAE,CAAC;IA+GpB,CAAC;IAhKQ,MAAM,KAAK,UAAU;QAC1B,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,QAAQ,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;YAC9B,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;SAC5B,CAAC;IACJ,CAAC;IAEM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KAAK,CAAC,CAAC;QACnC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC/C,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,eAAe,CAAC,KAAuB,EAAE,KAAiB;QAChE,MAAM,MAAM,GACV,qGAAqG,CAAC;QAExG,MAAM,MAAM,GAAG;YACb,WAAW;YACX,yDAAyD;YACzD,UAAU;YACV,8BAA8B;YAC9B,6BAA6B;SAC9B,CAAC;QAEF,KAAK,KAAK,CAAC,YAAY,CAAC,CAAC,SAAS;QAClC,KAAK,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtD,CAAC;CACF","sourcesContent":["import {\n CSSResultArray,\n LitElement,\n PropertyDeclarations,\n TemplateResult,\n css,\n html,\n} from 'lit-element';\n\nimport { PreviewItem } from './Preview';\nimport { Themeable } from '../../../../mixins/themeable';\n\nenum ImageState {\n Excluded = 0,\n BeforeEnter = 1,\n Default = 2,\n Previous = 3,\n BeforeExit = 4,\n}\n\nexport class Picture extends LitElement {\n public static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n quantity: { attribute: false },\n image: { attribute: false },\n };\n }\n\n public static get styles(): CSSResultArray {\n return [\n Themeable.styles,\n css`\n .ease-out-back {\n transition-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);\n }\n\n .blur-1 {\n filter: blur(1px);\n }\n\n .blur-2 {\n filter: blur(2px);\n }\n\n .grayscale {\n filter: grayscale();\n }\n\n .rotate-12 {\n --tw-rotate: 12deg;\n }\n\n .-rotate-12 {\n --tw-rotate: -12deg;\n }\n\n .-rotate-24 {\n --tw-rotate: -24deg;\n }\n\n .translate-y-half {\n --tw-translate-y: 50%;\n }\n `,\n ];\n }\n\n public quantity = 0;\n\n public image = '';\n\n public set empty(newValue: boolean) {\n this.updateComplete.then(() => {\n if (newValue) {\n const [, ...bottomImages] = this.__stack;\n bottomImages.forEach(image => image.remove());\n } else if (this.quantity > 1 && this.__stack.length < 2) {\n this.__insertImage(ImageState.Previous, this.__stack[0]);\n }\n });\n }\n\n public set data({ quantity, image }: PreviewItem) {\n this.quantity = quantity;\n this.image = image;\n }\n\n public render(): TemplateResult {\n return html`<div id=\"image\" class=\"w-full h-full relative\"></div>`;\n }\n\n public firstUpdated(): void {\n const top = this.__insertImage(ImageState.Default);\n if (this.quantity > 1) this.__insertImage(ImageState.Previous, top);\n }\n\n public updated(changedProperties: Map<keyof Picture, unknown>): void {\n if (changedProperties.has('quantity')) {\n const oldValue = changedProperties.get('quantity') as number | undefined;\n if (oldValue !== undefined) this.quantity > oldValue ? this.__add() : this.__remove();\n }\n\n if (changedProperties.has('image')) {\n this.__stack.forEach(image => (image.src = this.image));\n }\n }\n\n private get __container() {\n return this.shadowRoot!.getElementById('image')!;\n }\n\n private get __stack() {\n const list = this.__container?.querySelectorAll(':not(.opacity-0)') ?? [];\n return [...list].reverse() as HTMLImageElement[];\n }\n\n private __add() {\n const [current, previous] = this.__stack;\n\n if (this.quantity > 1) {\n if (current) this.__setImageState(current, ImageState.Previous);\n\n if (previous) {\n this.__setImageState(previous, ImageState.BeforeExit);\n previous.ontransitionend = /* istanbul ignore next */ () => previous.remove();\n }\n\n this.__setImageState(this.__insertImage(ImageState.BeforeEnter), ImageState.Default);\n } else {\n if (current) this.__setImageState(current, ImageState.Default);\n }\n }\n\n private __remove() {\n const [current, previous] = this.__stack;\n let imageToRemove: HTMLImageElement;\n\n if (this.quantity > 0) {\n if (previous) this.__setImageState(previous, ImageState.Default);\n imageToRemove = current;\n } else {\n if (current) this.__setImageState(current, ImageState.Excluded);\n imageToRemove = previous;\n }\n\n if (imageToRemove) {\n this.__setImageState(imageToRemove, ImageState.BeforeEnter);\n imageToRemove.ontransitionend = /* istanbul ignore next */ () => imageToRemove!.remove();\n }\n\n if (this.quantity > 1) {\n const last = this.__insertImage(ImageState.BeforeExit, this.__container.firstElementChild);\n this.__setImageState(last, ImageState.Previous);\n }\n }\n\n private __insertImage(state: ImageState, refChild: Node | null = null) {\n const image = new Image();\n image.src = this.image;\n image.setAttribute('part', 'picture');\n this.__setImageState(image, state);\n this.__container.insertBefore(image, refChild);\n return image;\n }\n\n private __setImageState(image: HTMLImageElement, state: ImageState) {\n const shared =\n 'absolute inset-0 w-full h-full object-cover rounded transform transition duration-700 ease-out-back';\n\n const states = [\n 'grayscale',\n 'shadow-m translate-y-half scale-110 rotate-12 opacity-0',\n 'shadow-m',\n 'blur-1 -rotate-12 opacity-25',\n 'blur-2 -rotate-24 opacity-0',\n ];\n\n void image.offsetHeight; // reflow\n image.className = [shared, states[state]].join(' ');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Picture.js","sourceRoot":"","sources":["../../../../../src/elements/public/ItemsForm/private/Picture.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAGV,GAAG,EACH,IAAI,GACL,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,SAAS,EAAE,wCAAqC;AAEzD,IAAK,UAMJ;AAND,WAAK,UAAU;IACb,mDAAY,CAAA;IACZ,yDAAe,CAAA;IACf,iDAAW,CAAA;IACX,mDAAY,CAAA;IACZ,uDAAc,CAAA;AAChB,CAAC,EANI,UAAU,KAAV,UAAU,QAMd;AAED,MAAM,OAAO,OAAQ,SAAQ,UAAU;IAAvC;;QAmDS,aAAQ,GAAG,CAAC,CAAC;QAEb,UAAK,GAAG,EAAE,CAAC;IAkHpB,CAAC;IAnKQ,MAAM,KAAK,UAAU;QAC1B,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,QAAQ,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;YAC9B,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;SAC5B,CAAC;IACJ,CAAC;IAEM,MAAM,KAAK,MAAM;QACtB,OAAO;YACL,SAAS,CAAC,MAAM;YAChB,GAAG;;;;;;;;;;;;;;;;;;;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AEzE,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACnC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC/C,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,eAAe,CAAC,KAAuB,EAAE,KAAiB;QAChE,MAAM,MAAM,GACV,qGAAqG,CAAC;QAExG,MAAM,MAAM,GAAG;YACb,WAAW;YACX,yDAAyD;YACzD,UAAU;YACV,8BAA8B;YAC9B,6BAA6B;SAC9B,CAAC;QAEF,KAAK,KAAK,CAAC,YAAY,CAAC,CAAC,SAAS;QAClC,KAAK,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtD,CAAC;;AArKsB,mBAAW,GAChC,+wDAA+wD,CAAC","sourcesContent":["import {\n CSSResultArray,\n LitElement,\n PropertyDeclarations,\n TemplateResult,\n css,\n html,\n} from 'lit-element';\n\nimport { PreviewItem } from './Preview';\nimport { Themeable } from '../../../../mixins/themeable';\n\nenum ImageState {\n Excluded = 0,\n BeforeEnter = 1,\n Default = 2,\n Previous = 3,\n BeforeExit = 4,\n}\n\nexport class Picture extends LitElement {\n public static readonly placeholder =\n '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';\n\n public static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n quantity: { attribute: false },\n image: { attribute: false },\n };\n }\n\n public static get styles(): CSSResultArray {\n return [\n Themeable.styles,\n css`\n .ease-out-back {\n transition-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);\n }\n\n .blur-1 {\n filter: blur(1px);\n }\n\n .blur-2 {\n filter: blur(2px);\n }\n\n .grayscale {\n filter: grayscale();\n }\n\n .rotate-12 {\n --tw-rotate: 12deg;\n }\n\n .-rotate-12 {\n --tw-rotate: -12deg;\n }\n\n .-rotate-24 {\n --tw-rotate: -24deg;\n }\n\n .translate-y-half {\n --tw-translate-y: 50%;\n }\n `,\n ];\n }\n\n public quantity = 0;\n\n public image = '';\n\n public set empty(newValue: boolean) {\n this.updateComplete.then(() => {\n if (newValue) {\n const [, ...bottomImages] = this.__stack;\n bottomImages.forEach(image => image.remove());\n } else if (this.quantity > 1 && this.__stack.length < 2) {\n this.__insertImage(ImageState.Previous, this.__stack[0]);\n }\n });\n }\n\n public set data({ quantity, image }: PreviewItem) {\n this.quantity = quantity;\n this.image = image;\n }\n\n public render(): TemplateResult {\n return html`<div id=\"image\" class=\"w-full h-full relative\"></div>`;\n }\n\n public firstUpdated(): void {\n const top = this.__insertImage(ImageState.Default);\n if (this.quantity > 1) this.__insertImage(ImageState.Previous, top);\n }\n\n public updated(changedProperties: Map<keyof Picture, unknown>): void {\n if (changedProperties.has('quantity')) {\n const oldValue = changedProperties.get('quantity') as number | undefined;\n if (oldValue !== undefined) this.quantity > oldValue ? this.__add() : this.__remove();\n }\n\n if (changedProperties.has('image')) {\n this.__stack.forEach(image => (image.src = this.image));\n }\n }\n\n private get __container() {\n return this.shadowRoot!.getElementById('image')!;\n }\n\n private get __stack() {\n const list = this.__container?.querySelectorAll(':not(.opacity-0)') ?? [];\n return [...list].reverse() as HTMLImageElement[];\n }\n\n private __add() {\n const [current, previous] = this.__stack;\n\n if (this.quantity > 1) {\n if (current) this.__setImageState(current, ImageState.Previous);\n\n if (previous) {\n this.__setImageState(previous, ImageState.BeforeExit);\n previous.ontransitionend = /* istanbul ignore next */ () => previous.remove();\n }\n\n this.__setImageState(this.__insertImage(ImageState.BeforeEnter), ImageState.Default);\n } else {\n if (current) this.__setImageState(current, ImageState.Default);\n }\n }\n\n private __remove() {\n const [current, previous] = this.__stack;\n let imageToRemove: HTMLImageElement;\n\n if (this.quantity > 0) {\n if (previous) this.__setImageState(previous, ImageState.Default);\n imageToRemove = current;\n } else {\n if (current) this.__setImageState(current, ImageState.Excluded);\n imageToRemove = previous;\n }\n\n if (imageToRemove) {\n this.__setImageState(imageToRemove, ImageState.BeforeEnter);\n imageToRemove.ontransitionend = /* istanbul ignore next */ () => imageToRemove!.remove();\n }\n\n if (this.quantity > 1) {\n const last = this.__insertImage(ImageState.BeforeExit, this.__container.firstElementChild);\n this.__setImageState(last, ImageState.Previous);\n }\n }\n\n private __insertImage(state: ImageState, refChild: Node | null = null) {\n const image = new Image();\n\n image.src = this.image;\n image.setAttribute('part', 'picture');\n image.addEventListener('error', () => (image.src = Picture.placeholder));\n\n this.__setImageState(image, state);\n this.__container.insertBefore(image, refChild);\n return image;\n }\n\n private __setImageState(image: HTMLImageElement, state: ImageState) {\n const shared =\n 'absolute inset-0 w-full h-full object-cover rounded transform transition duration-700 ease-out-back';\n\n const states = [\n 'grayscale',\n 'shadow-m translate-y-half scale-110 rotate-12 opacity-0',\n 'shadow-m',\n 'blur-1 -rotate-12 opacity-25',\n 'blur-2 -rotate-24 opacity-0',\n ];\n\n void image.offsetHeight; // reflow\n image.className = [shared, states[state]].join(' ');\n }\n}\n"]}
|
|
@@ -466,20 +466,28 @@ export class SubscriptionForm extends Base {
|
|
|
466
466
|
get __isNextTransactionDateVisible() {
|
|
467
467
|
if (this.hiddenSelector.matches('next-transaction-date', true))
|
|
468
468
|
return false;
|
|
469
|
-
if (this.settings === null)
|
|
470
|
-
return true;
|
|
471
469
|
if (this.data === null)
|
|
472
470
|
return false;
|
|
471
|
+
if (this.data.end_date && new Date(this.data.end_date).getTime() <= Date.now())
|
|
472
|
+
return false;
|
|
473
|
+
if (this.data.is_active === false)
|
|
474
|
+
return false;
|
|
475
|
+
if (this.settings === null)
|
|
476
|
+
return true;
|
|
473
477
|
const rules = this.settings.subscriptions.allow_next_date_modification;
|
|
474
478
|
return !!getNextTransactionDateConstraints(this.data, rules);
|
|
475
479
|
}
|
|
476
480
|
get __isFrequencyVisible() {
|
|
477
481
|
if (this.hiddenSelector.matches('frequency', true))
|
|
478
482
|
return false;
|
|
479
|
-
if (this.settings === null)
|
|
480
|
-
return true;
|
|
481
483
|
if (this.data === null)
|
|
482
484
|
return false;
|
|
485
|
+
if (this.data.end_date && new Date(this.data.end_date).getTime() <= Date.now())
|
|
486
|
+
return false;
|
|
487
|
+
if (this.data.is_active === false)
|
|
488
|
+
return false;
|
|
489
|
+
if (this.settings === null)
|
|
490
|
+
return true;
|
|
483
491
|
const allowedFrequencies = getAllowedFrequencies({
|
|
484
492
|
subscription: this.data,
|
|
485
493
|
settings: this.settings,
|