@foxy.io/elements 1.14.0-beta.4 → 1.14.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +1 -1
  2. package/dist/cdn/foxy-attribute-form.js +1 -1
  3. package/dist/cdn/foxy-cancellation-form.js +1 -1
  4. package/dist/cdn/foxy-custom-field-form.js +1 -1
  5. package/dist/cdn/foxy-customer-form.js +1 -1
  6. package/dist/cdn/foxy-customer-portal-settings.js +1 -1
  7. package/dist/cdn/foxy-customer-portal.js +2 -2
  8. package/dist/cdn/foxy-customer.js +1 -1
  9. package/dist/cdn/foxy-donation.js +1 -1
  10. package/dist/cdn/foxy-email-template-form.js +1 -1
  11. package/dist/cdn/foxy-items-form.js +1 -1
  12. package/dist/cdn/foxy-subscription-form.js +1 -1
  13. package/dist/cdn/foxy-tax-form.js +1 -1
  14. package/dist/cdn/foxy-template-config-form.js +2 -2
  15. package/dist/cdn/foxy-template-form.js +1 -1
  16. package/dist/cdn/foxy-user-form.js +1 -1
  17. package/dist/cdn/foxy-users-table.js +1 -1
  18. package/dist/cdn/{shared-18459dcd.js → shared-166c44ae.js} +1 -1
  19. package/dist/cdn/{shared-4be4e513.js → shared-396320f9.js} +1 -1
  20. package/dist/cdn/{shared-b28a59de.js → shared-75ce6e43.js} +1 -1
  21. package/dist/cdn/{shared-c4b96261.js → shared-782bf922.js} +1 -1
  22. package/dist/cdn/{shared-106daaca.js → shared-87190eae.js} +1 -1
  23. package/dist/cdn/translations/shared/en.json +12 -1
  24. package/dist/elements/private/Choice/Choice.js +2 -2
  25. package/dist/elements/private/Choice/Choice.js.map +1 -1
  26. package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.js +1 -1
  27. package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.js.map +1 -1
  28. package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.d.ts +4 -0
  29. package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.js +173 -2
  30. package/dist/elements/public/TemplateConfigForm/TemplateConfigForm.js.map +1 -1
  31. package/dist/elements/public/TemplateConfigForm/types.d.ts +1 -1
  32. package/dist/elements/public/TemplateConfigForm/types.js.map +1 -1
  33. package/dist/elements/public/TemplateForm/TemplateForm.js +1 -1
  34. package/dist/elements/public/TemplateForm/TemplateForm.js.map +1 -1
  35. package/package.json +1 -1
@@ -1 +1 @@
1
- import"./shared-bb824ab4.js";import"./shared-0ced76a0.js";import"./shared-3d868b17.js";import"./foxy-spinner.js";import"./foxy-i18n.js";import{C as e}from"./shared-1b7e65e4.js";import"./shared-18459dcd.js";import"./shared-4a52d9b5.js";import"./shared-4be4e513.js";import{s,h as t}from"./shared-63eaded9.js";import{S as i,T as r,a}from"./shared-d94ffc2b.js";import"./shared-ec861f31.js";import{m as n}from"./shared-1761daef.js";import{G as l}from"./shared-7a39a41f.js";import"./shared-df573cea.js";import"./shared-46ee137f.js";import"./shared-f0a83bd6.js";import{c as o}from"./shared-4e709717.js";import{C as d}from"./shared-593f7e2c.js";import{N as h}from"./shared-44cfc617.js";import{i as m}from"./shared-6d45a07b.js";import{v as c}from"./shared-b738ee96.js";let C,f,p,g,u=e=>e;const y=[{property:"is_merchant",icon:s(C||(C=u`<svg class="fill-current h-full w-full" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M22.8961 8.89L21.7932 4.52C21.5622 3.62 20.7429 3 19.7871 3H5.1979C4.25259 3 3.42283 3.63 3.20225 4.52L2.0994 8.89C1.84732 9.91 2.07839 10.95 2.75061 11.77C2.83464 11.88 2.95017 11.96 3.0447 12.06V19C3.0447 20.1 3.99001 21 5.14538 21H19.8501C21.0055 21 21.9508 20.1 21.9508 19V12.06C22.0453 11.97 22.1609 11.88 22.2449 11.78C22.9171 10.96 23.1587 9.91 22.8961 8.89ZM19.7556 4.99L20.8584 9.36C20.9635 9.78 20.8689 10.2 20.5958 10.53C20.4488 10.71 20.1337 11 19.6085 11C18.9678 11 18.4111 10.51 18.3376 9.86L17.7284 5L19.7556 4.99ZM13.5481 5H15.6067L16.1739 9.52C16.2264 9.91 16.1004 10.3 15.8273 10.59C15.5962 10.85 15.2601 11 14.8295 11C14.1258 11 13.5481 10.41 13.5481 9.69V5ZM8.81106 9.52L9.38874 5H11.4474V9.69C11.4474 10.41 10.8697 11 10.0925 11C9.73536 11 9.40975 10.85 9.15767 10.59C8.89509 10.3 8.76905 9.91 8.81106 9.52ZM4.13705 9.36L5.1979 5H7.26706L6.65787 9.86C6.57384 10.51 6.02766 11 5.38696 11C4.87229 11 4.54669 10.71 4.41014 10.53C4.12655 10.21 4.03202 9.78 4.13705 9.36ZM5.14538 19V12.97C5.22941 12.98 5.30293 13 5.38696 13C6.30075 13 7.13052 12.64 7.73971 12.05C8.36992 12.65 9.21019 13 10.166 13C11.0798 13 11.8991 12.64 12.5082 12.07C13.1279 12.64 13.9682 13 14.9135 13C15.7958 13 16.6361 12.65 17.2663 12.05C17.8755 12.64 18.7052 13 19.619 13C19.7031 13 19.7766 12.98 19.8606 12.97V19H5.14538Z" /></svg>`)),key:"merchant"},{property:"is_programmer",icon:s(f||(f=u`<svg class="fill-current h-full w-full" viewBox="0 0 20 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M0 3C0 1.34315 1.34315 0 3 0H17C18.6569 0 20 1.34315 20 3V15C20 16.6569 18.6569 18 17 18H3C1.34315 18 0 16.6569 0 15V3ZM3 2C2.44772 2 2 2.44772 2 3V15C2 15.5523 2.44772 16 3 16H17C17.5523 16 18 15.5523 18 15V3C18 2.44772 17.5523 2 17 2H3ZM4.29289 4.29289C4.68342 3.90237 5.31658 3.90237 5.70711 4.29289L9.70711 8.29289C9.89464 8.48043 10 8.73478 10 9C10 9.26522 9.89464 9.51957 9.70711 9.70711L5.70711 13.7071C5.31658 14.0976 4.68342 14.0976 4.29289 13.7071C3.90237 13.3166 3.90237 12.6834 4.29289 12.2929L7.58579 9L4.29289 5.70711C3.90237 5.31658 3.90237 4.68342 4.29289 4.29289ZM9 13C9 12.4477 9.44771 12 10 12H15C15.5523 12 16 12.4477 16 13C16 13.5523 15.5523 14 15 14H10C9.44771 14 9 13.5523 9 13Z"/></svg>`)),key:"backend_developer"},{property:"is_front_end_developer",icon:s(p||(p=u`<svg class="fill-current h-full w-full" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M14.2747 4.03847C14.8058 4.1902 15.1132 4.74368 14.9615 5.27472L10.9615 19.2747C10.8098 19.8058 10.2563 20.1132 9.72528 19.9615C9.19424 19.8098 8.88675 19.2563 9.03848 18.7253L13.0385 4.72528C13.1902 4.19424 13.7437 3.88675 14.2747 4.03847ZM6.70711 7.29289C7.09763 7.68342 7.09763 8.31658 6.70711 8.7071L3.41421 12L6.70711 15.2929C7.09763 15.6834 7.09763 16.3166 6.70711 16.7071C6.31658 17.0976 5.68342 17.0976 5.29289 16.7071L1.29289 12.7071C0.902369 12.3166 0.902369 11.6834 1.29289 11.2929L5.29289 7.29289C5.68342 6.90237 6.31658 6.90237 6.70711 7.29289ZM17.2929 7.29289C17.6834 6.90237 18.3166 6.90237 18.7071 7.29289L22.7071 11.2929C22.8946 11.4804 23 11.7348 23 12C23 12.2652 22.8946 12.5196 22.7071 12.7071L18.7071 16.7071C18.3166 17.0976 17.6834 17.0976 17.2929 16.7071C16.9024 16.3166 16.9024 15.6834 17.2929 15.2929L20.5858 12L17.2929 8.70711C16.9024 8.31658 16.9024 7.68342 17.2929 7.29289Z" /></svg>`)),key:"frontend_developer"},{property:"is_designer",icon:s(g||(g=u`<svg class="fill-current h-full w-full" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10 20C4.49 20 0 15.51 0 10C0 4.49 4.49 0 10 0C15.51 0 20 4.04 20 9C20 12.31 17.31 15 14 15H12.23C11.95 15 11.73 15.22 11.73 15.5C11.73 15.62 11.78 15.73 11.86 15.83C12.27 16.3 12.5 16.89 12.5 17.5C12.5 18.88 11.38 20 10 20ZM10 2C5.59 2 2 5.59 2 10C2 14.41 5.59 18 10 18C10.28 18 10.5 17.78 10.5 17.5C10.5 17.34 10.42 17.22 10.36 17.15C9.95 16.69 9.73 16.1 9.73 15.5C9.73 14.12 10.85 13 12.23 13H14C16.21 13 18 11.21 18 9C18 5.14 14.41 2 10 2Z" /><path d="M4.5 11C5.32843 11 6 10.3284 6 9.5C6 8.67157 5.32843 8 4.5 8C3.67157 8 3 8.67157 3 9.5C3 10.3284 3.67157 11 4.5 11Z" /><path d="M7.5 7C8.32843 7 9 6.32843 9 5.5C9 4.67157 8.32843 4 7.5 4C6.67157 4 6 4.67157 6 5.5C6 6.32843 6.67157 7 7.5 7Z" /><path d="M12.5 7C13.3284 7 14 6.32843 14 5.5C14 4.67157 13.3284 4 12.5 4C11.6716 4 11 4.67157 11 5.5C11 6.32843 11.6716 7 12.5 7Z" /><path d="M15.5 11C16.3284 11 17 10.3284 17 9.5C17 8.67157 16.3284 8 15.5 8C14.6716 8 14 8.67157 14 9.5C14 10.3284 14.6716 11 15.5 11Z" /></svg>`)),key:"designer"}];let v,x,_,b=e=>e;const $=i(r(d(a(h,"user-form"))));class w extends ${constructor(){super(...arguments),this.__getValidator=n((e=>()=>!this.errors.some((s=>s.startsWith(e))))),this.__bindField=n((e=>s=>{const t=s.target;this.edit({[e]:t.value})}))}static get scopedElements(){return{"foxy-internal-confirm-dialog":customElements.get("foxy-internal-confirm-dialog"),"vaadin-text-field":customElements.get("vaadin-text-field"),"vaadin-button":customElements.get("vaadin-button"),"foxy-spinner":customElements.get("foxy-spinner"),"x-checkbox":e,"foxy-i18n":customElements.get("foxy-i18n"),"x-group":l}}static get v8n(){return[({first_name:e})=>!e||e.length<=50||"first_name_too_long",({last_name:e})=>!e||e.length<=50||"last_name_too_long",({email:e})=>e&&e.length>0||"email_required",({email:e})=>e&&e.length<=100||"email_too_long",({email:e})=>e&&c(e)||"email_invalid_email",({phone:e})=>!e||e.length<=50||"phone_too_long"]}render(){const e=this.in({idle:{template:{dirty:"valid"}}}),s=this.in({idle:{snapshot:{dirty:"valid"}}}),i=e||s,r=this.in("busy"),a=this.in("fail"),n=r||a||this.disabled;return t(v||(v=b` <foxy-internal-confirm-dialog data-testid="confirm" message="delete_prompt" confirm="delete" cancel="cancel" header="delete" theme="primary error" lang="${0}" ns="${0}" id="confirm" @hide="${0}"> </foxy-internal-confirm-dialog> <div data-testid="wrapper" aria-busy="${0}" aria-live="polite" class="space-y-l relative"> <div class="grid grid-cols-1 sm-grid-cols-2 gap-m"> ${0} </div> <x-group frame> ${0} </x-group> <vaadin-button data-testid="action" theme="${0}" class="w-full" ?disabled="${0}" @click="${0}"> <foxy-i18n lang="${0}" key="${0}" ns="${0}"> </foxy-i18n> </vaadin-button> <div data-testid="spinner" class="${0}"> <foxy-spinner layout="vertical" class="m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l" state="${0}" lang="${0}" ns="${0}"> </foxy-spinner> </div> </div> `),this.lang,this.ns,this.__handleConfirmHide,this.in("busy"),["first_name","last_name","email","phone"].map((e=>t(x||(x=b` <vaadin-text-field error-message="${0}" data-testid="${0}" ?disabled="${0}" ?readonly="${0}" class="w-full" label="${0}" value="${0}" .checkValidity="${0}" @input="${0}" @keydown="${0}"> </vaadin-text-field> `),this.__getErrorMessage(e),e,n,this.readonly,this.t(e),m(this.form[e]),this.__getValidator(e),this.__bindField(e),this.__handleKeyDown))),y.map(((e,s)=>t(_||(_=b` <hr class="${0}" style="margin-left:calc((var(--lumo-space-m) * 2) + 1.125rem)"> <x-checkbox class="w-full p-m" ?readonly="${0}" ?disabled="${0}" ?checked="${0}" @change="${0}"> <div class="flex items-start leading-s"> <div class="flex-1 flex flex-col"> <foxy-i18n key="${0}" lang="${0}" ns="${0}"></foxy-i18n> <foxy-i18n class="text-s text-secondary" lang="${0}" key="${0}_explainer" ns="${0}"> </foxy-i18n> </div> <div class="mt-xs" style="width:1.125rem;height:1.125rem">${0}</div> </div> </x-checkbox> `),s>0?"border-contrast-10":"hidden",this.readonly,n,this.form[e.property],(s=>{const t=s.target;this.edit({[e.property]:t.checked})}),e.key,this.lang,this.ns,this.lang,e.key,this.ns,e.icon))),this.in("idle")?"primary "+(this.href?"error":"success"):"",this.in({idle:"template"})&&!i||n,this.__handleActionClick,this.lang,this.href?"delete":"create",this.ns,o({"transition duration-500 ease-in-out absolute inset-0 flex":!0,"opacity-0 pointer-events-none":!r&&!a}),a?"error":r?"busy":"empty",this.lang,this.ns)}__getErrorMessage(e){const s=this.errors.find((s=>s.startsWith(e)));return s?this.t(s.replace(e,"v8n")):""}__handleActionClick(e){if(this.in({idle:"snapshot"})){this.renderRoot.querySelector("#confirm").show(e.currentTarget)}else this.submit()}__handleConfirmHide(e){e.detail.cancelled||this.delete()}__handleKeyDown(e){"Enter"===e.key&&this.submit()}}customElements.define("foxy-user-form",w);export{w as U,y as r};
1
+ import"./shared-bb824ab4.js";import"./shared-0ced76a0.js";import"./shared-3d868b17.js";import"./foxy-spinner.js";import"./foxy-i18n.js";import{C as e}from"./shared-1b7e65e4.js";import"./shared-166c44ae.js";import"./shared-4a52d9b5.js";import"./shared-396320f9.js";import{s,h as t}from"./shared-63eaded9.js";import{S as i,T as r,a}from"./shared-d94ffc2b.js";import"./shared-ec861f31.js";import{m as n}from"./shared-1761daef.js";import{G as l}from"./shared-7a39a41f.js";import"./shared-df573cea.js";import"./shared-46ee137f.js";import"./shared-f0a83bd6.js";import{c as o}from"./shared-4e709717.js";import{C as d}from"./shared-593f7e2c.js";import{N as h}from"./shared-44cfc617.js";import{i as m}from"./shared-6d45a07b.js";import{v as c}from"./shared-b738ee96.js";let C,f,p,g,u=e=>e;const y=[{property:"is_merchant",icon:s(C||(C=u`<svg class="fill-current h-full w-full" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M22.8961 8.89L21.7932 4.52C21.5622 3.62 20.7429 3 19.7871 3H5.1979C4.25259 3 3.42283 3.63 3.20225 4.52L2.0994 8.89C1.84732 9.91 2.07839 10.95 2.75061 11.77C2.83464 11.88 2.95017 11.96 3.0447 12.06V19C3.0447 20.1 3.99001 21 5.14538 21H19.8501C21.0055 21 21.9508 20.1 21.9508 19V12.06C22.0453 11.97 22.1609 11.88 22.2449 11.78C22.9171 10.96 23.1587 9.91 22.8961 8.89ZM19.7556 4.99L20.8584 9.36C20.9635 9.78 20.8689 10.2 20.5958 10.53C20.4488 10.71 20.1337 11 19.6085 11C18.9678 11 18.4111 10.51 18.3376 9.86L17.7284 5L19.7556 4.99ZM13.5481 5H15.6067L16.1739 9.52C16.2264 9.91 16.1004 10.3 15.8273 10.59C15.5962 10.85 15.2601 11 14.8295 11C14.1258 11 13.5481 10.41 13.5481 9.69V5ZM8.81106 9.52L9.38874 5H11.4474V9.69C11.4474 10.41 10.8697 11 10.0925 11C9.73536 11 9.40975 10.85 9.15767 10.59C8.89509 10.3 8.76905 9.91 8.81106 9.52ZM4.13705 9.36L5.1979 5H7.26706L6.65787 9.86C6.57384 10.51 6.02766 11 5.38696 11C4.87229 11 4.54669 10.71 4.41014 10.53C4.12655 10.21 4.03202 9.78 4.13705 9.36ZM5.14538 19V12.97C5.22941 12.98 5.30293 13 5.38696 13C6.30075 13 7.13052 12.64 7.73971 12.05C8.36992 12.65 9.21019 13 10.166 13C11.0798 13 11.8991 12.64 12.5082 12.07C13.1279 12.64 13.9682 13 14.9135 13C15.7958 13 16.6361 12.65 17.2663 12.05C17.8755 12.64 18.7052 13 19.619 13C19.7031 13 19.7766 12.98 19.8606 12.97V19H5.14538Z" /></svg>`)),key:"merchant"},{property:"is_programmer",icon:s(f||(f=u`<svg class="fill-current h-full w-full" viewBox="0 0 20 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M0 3C0 1.34315 1.34315 0 3 0H17C18.6569 0 20 1.34315 20 3V15C20 16.6569 18.6569 18 17 18H3C1.34315 18 0 16.6569 0 15V3ZM3 2C2.44772 2 2 2.44772 2 3V15C2 15.5523 2.44772 16 3 16H17C17.5523 16 18 15.5523 18 15V3C18 2.44772 17.5523 2 17 2H3ZM4.29289 4.29289C4.68342 3.90237 5.31658 3.90237 5.70711 4.29289L9.70711 8.29289C9.89464 8.48043 10 8.73478 10 9C10 9.26522 9.89464 9.51957 9.70711 9.70711L5.70711 13.7071C5.31658 14.0976 4.68342 14.0976 4.29289 13.7071C3.90237 13.3166 3.90237 12.6834 4.29289 12.2929L7.58579 9L4.29289 5.70711C3.90237 5.31658 3.90237 4.68342 4.29289 4.29289ZM9 13C9 12.4477 9.44771 12 10 12H15C15.5523 12 16 12.4477 16 13C16 13.5523 15.5523 14 15 14H10C9.44771 14 9 13.5523 9 13Z"/></svg>`)),key:"backend_developer"},{property:"is_front_end_developer",icon:s(p||(p=u`<svg class="fill-current h-full w-full" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M14.2747 4.03847C14.8058 4.1902 15.1132 4.74368 14.9615 5.27472L10.9615 19.2747C10.8098 19.8058 10.2563 20.1132 9.72528 19.9615C9.19424 19.8098 8.88675 19.2563 9.03848 18.7253L13.0385 4.72528C13.1902 4.19424 13.7437 3.88675 14.2747 4.03847ZM6.70711 7.29289C7.09763 7.68342 7.09763 8.31658 6.70711 8.7071L3.41421 12L6.70711 15.2929C7.09763 15.6834 7.09763 16.3166 6.70711 16.7071C6.31658 17.0976 5.68342 17.0976 5.29289 16.7071L1.29289 12.7071C0.902369 12.3166 0.902369 11.6834 1.29289 11.2929L5.29289 7.29289C5.68342 6.90237 6.31658 6.90237 6.70711 7.29289ZM17.2929 7.29289C17.6834 6.90237 18.3166 6.90237 18.7071 7.29289L22.7071 11.2929C22.8946 11.4804 23 11.7348 23 12C23 12.2652 22.8946 12.5196 22.7071 12.7071L18.7071 16.7071C18.3166 17.0976 17.6834 17.0976 17.2929 16.7071C16.9024 16.3166 16.9024 15.6834 17.2929 15.2929L20.5858 12L17.2929 8.70711C16.9024 8.31658 16.9024 7.68342 17.2929 7.29289Z" /></svg>`)),key:"frontend_developer"},{property:"is_designer",icon:s(g||(g=u`<svg class="fill-current h-full w-full" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10 20C4.49 20 0 15.51 0 10C0 4.49 4.49 0 10 0C15.51 0 20 4.04 20 9C20 12.31 17.31 15 14 15H12.23C11.95 15 11.73 15.22 11.73 15.5C11.73 15.62 11.78 15.73 11.86 15.83C12.27 16.3 12.5 16.89 12.5 17.5C12.5 18.88 11.38 20 10 20ZM10 2C5.59 2 2 5.59 2 10C2 14.41 5.59 18 10 18C10.28 18 10.5 17.78 10.5 17.5C10.5 17.34 10.42 17.22 10.36 17.15C9.95 16.69 9.73 16.1 9.73 15.5C9.73 14.12 10.85 13 12.23 13H14C16.21 13 18 11.21 18 9C18 5.14 14.41 2 10 2Z" /><path d="M4.5 11C5.32843 11 6 10.3284 6 9.5C6 8.67157 5.32843 8 4.5 8C3.67157 8 3 8.67157 3 9.5C3 10.3284 3.67157 11 4.5 11Z" /><path d="M7.5 7C8.32843 7 9 6.32843 9 5.5C9 4.67157 8.32843 4 7.5 4C6.67157 4 6 4.67157 6 5.5C6 6.32843 6.67157 7 7.5 7Z" /><path d="M12.5 7C13.3284 7 14 6.32843 14 5.5C14 4.67157 13.3284 4 12.5 4C11.6716 4 11 4.67157 11 5.5C11 6.32843 11.6716 7 12.5 7Z" /><path d="M15.5 11C16.3284 11 17 10.3284 17 9.5C17 8.67157 16.3284 8 15.5 8C14.6716 8 14 8.67157 14 9.5C14 10.3284 14.6716 11 15.5 11Z" /></svg>`)),key:"designer"}];let v,x,_,$=e=>e;const b=i(r(d(a(h,"user-form"))));class w extends b{constructor(){super(...arguments),this.__getValidator=n((e=>()=>!this.errors.some((s=>s.startsWith(e))))),this.__bindField=n((e=>s=>{const t=s.target;this.edit({[e]:t.value})}))}static get scopedElements(){return{"foxy-internal-confirm-dialog":customElements.get("foxy-internal-confirm-dialog"),"vaadin-text-field":customElements.get("vaadin-text-field"),"vaadin-button":customElements.get("vaadin-button"),"foxy-spinner":customElements.get("foxy-spinner"),"x-checkbox":e,"foxy-i18n":customElements.get("foxy-i18n"),"x-group":l}}static get v8n(){return[({first_name:e})=>!e||e.length<=50||"first_name_too_long",({last_name:e})=>!e||e.length<=50||"last_name_too_long",({email:e})=>e&&e.length>0||"email_required",({email:e})=>e&&e.length<=100||"email_too_long",({email:e})=>e&&c(e)||"email_invalid_email",({phone:e})=>!e||e.length<=50||"phone_too_long"]}render(){const e=this.in({idle:{template:{dirty:"valid"}}}),s=this.in({idle:{snapshot:{dirty:"valid"}}}),i=e||s,r=this.in("busy"),a=this.in("fail"),n=r||a||this.disabled;return t(v||(v=$` <foxy-internal-confirm-dialog data-testid="confirm" message="delete_prompt" confirm="delete" cancel="cancel" header="delete" theme="primary error" lang="${0}" ns="${0}" id="confirm" @hide="${0}"> </foxy-internal-confirm-dialog> <div data-testid="wrapper" aria-busy="${0}" aria-live="polite" class="space-y-l relative"> <div class="grid grid-cols-1 sm-grid-cols-2 gap-m"> ${0} </div> <x-group frame> ${0} </x-group> <vaadin-button data-testid="action" theme="${0}" class="w-full" ?disabled="${0}" @click="${0}"> <foxy-i18n lang="${0}" key="${0}" ns="${0}"> </foxy-i18n> </vaadin-button> <div data-testid="spinner" class="${0}"> <foxy-spinner layout="vertical" class="m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l" state="${0}" lang="${0}" ns="${0}"> </foxy-spinner> </div> </div> `),this.lang,this.ns,this.__handleConfirmHide,this.in("busy"),["first_name","last_name","email","phone"].map((e=>t(x||(x=$` <vaadin-text-field error-message="${0}" data-testid="${0}" ?disabled="${0}" ?readonly="${0}" class="w-full" label="${0}" value="${0}" .checkValidity="${0}" @input="${0}" @keydown="${0}"> </vaadin-text-field> `),this.__getErrorMessage(e),e,n,this.readonly,this.t(e),m(this.form[e]),this.__getValidator(e),this.__bindField(e),this.__handleKeyDown))),y.map(((e,s)=>t(_||(_=$` <hr class="${0}" style="margin-left:calc((var(--lumo-space-m) * 2) + 1.125rem)"> <x-checkbox class="w-full p-m" ?readonly="${0}" ?disabled="${0}" ?checked="${0}" @change="${0}"> <div class="flex items-start leading-s"> <div class="flex-1 flex flex-col"> <foxy-i18n key="${0}" lang="${0}" ns="${0}"></foxy-i18n> <foxy-i18n class="text-s text-secondary" lang="${0}" key="${0}_explainer" ns="${0}"> </foxy-i18n> </div> <div class="mt-xs" style="width:1.125rem;height:1.125rem">${0}</div> </div> </x-checkbox> `),s>0?"border-contrast-10":"hidden",this.readonly,n,this.form[e.property],(s=>{const t=s.target;this.edit({[e.property]:t.checked})}),e.key,this.lang,this.ns,this.lang,e.key,this.ns,e.icon))),this.in("idle")?"primary "+(this.href?"error":"success"):"",this.in({idle:"template"})&&!i||n,this.__handleActionClick,this.lang,this.href?"delete":"create",this.ns,o({"transition duration-500 ease-in-out absolute inset-0 flex":!0,"opacity-0 pointer-events-none":!r&&!a}),a?"error":r?"busy":"empty",this.lang,this.ns)}__getErrorMessage(e){const s=this.errors.find((s=>s.startsWith(e)));return s?this.t(s.replace(e,"v8n")):""}__handleActionClick(e){if(this.in({idle:"snapshot"})){this.renderRoot.querySelector("#confirm").show(e.currentTarget)}else this.submit()}__handleConfirmHide(e){e.detail.cancelled||this.delete()}__handleKeyDown(e){"Enter"===e.key&&this.submit()}}customElements.define("foxy-user-form",w);export{w as U,y as r};
@@ -1 +1 @@
1
- import{j as e,_ as t,h as r}from"./shared-63eaded9.js";import{B as s}from"./shared-0ced76a0.js";import{c as n}from"./shared-d94ffc2b.js";import{I as o}from"./shared-4be4e513.js";let i,a,l,c=e=>e;class d{constructor(e="unknown"){this.type=e}}class h extends CustomEvent{constructor(){super("reload")}}class p extends n{constructor(){super(...arguments),this.type="unknown",this.reload=!1}static get scopedElements(){return{"vaadin-button":s,"iron-icon":customElements.get("iron-icon"),"x-i18n":o}}static get styles(){return[super.styles,e(i||(i=c`:host{position:absolute;top:0;right:0;bottom:0;left:0}.container-narrow{max-width:400px}`))]}static get properties(){return t(t({},super.properties),{},{reload:{type:Boolean,reflect:!0},type:{type:String}})}render(){return r(a||(a=c` <article class="bg-base font-lumo text-center leading-m p-m h-full flex flex-col items-center justify-center"> <iron-icon icon="lumo:error" class="text-error w-l h-l mb-m"></iron-icon> <header class="text-xl text-header container-narrow font-medium"> <x-i18n ns="${0}" lang="${0}" key="errors.${0}.title"></x-i18n> </header> <p class="text-m text-secondary container-narrow mb-l"> <x-i18n ns="${0}" lang="${0}" key="errors.${0}.message"></x-i18n> </p> <div class="flex space-x-s"> <a rel="nofollow noreferrer noopener" href="${0}" target="_blank" class="px-m py-xs text-primary font-medium tracking-wide border border-contrast-10 rounded transition-colors duration-200 hover-bg-primary-10 hover-border-primary-10 focus-outline-none focus-shadow-outline" router-ignore> <x-i18n ns="${0}" lang="${0}" key="errors.${0}.action"></x-i18n> </a> ${0} </div> </article> `),this.ns,this.lang,this.type,this.ns,this.lang,this.type,this._i18n.t(`errors.${this.type}.href`).toString(),this.ns,this.lang,this.type,this.reload?r(l||(l=c` <vaadin-button data-testid="reload" theme="primary" @click="${0}"> <x-i18n ns="${0}" lang="${0}" key="reload"></x-i18n> <iron-icon icon="icons:refresh" slot="suffix"></iron-icon> </vaadin-button> `),(()=>this.dispatchEvent(new h)),this.ns,this.lang):"")}}export{p as E,d as F};
1
+ import{j as e,_ as t,h as r}from"./shared-63eaded9.js";import{B as s}from"./shared-0ced76a0.js";import{c as n}from"./shared-d94ffc2b.js";import{I as o}from"./shared-396320f9.js";let i,a,l,c=e=>e;class d{constructor(e="unknown"){this.type=e}}class h extends CustomEvent{constructor(){super("reload")}}class p extends n{constructor(){super(...arguments),this.type="unknown",this.reload=!1}static get scopedElements(){return{"vaadin-button":s,"iron-icon":customElements.get("iron-icon"),"x-i18n":o}}static get styles(){return[super.styles,e(i||(i=c`:host{position:absolute;top:0;right:0;bottom:0;left:0}.container-narrow{max-width:400px}`))]}static get properties(){return t(t({},super.properties),{},{reload:{type:Boolean,reflect:!0},type:{type:String}})}render(){return r(a||(a=c` <article class="bg-base font-lumo text-center leading-m p-m h-full flex flex-col items-center justify-center"> <iron-icon icon="lumo:error" class="text-error w-l h-l mb-m"></iron-icon> <header class="text-xl text-header container-narrow font-medium"> <x-i18n ns="${0}" lang="${0}" key="errors.${0}.title"></x-i18n> </header> <p class="text-m text-secondary container-narrow mb-l"> <x-i18n ns="${0}" lang="${0}" key="errors.${0}.message"></x-i18n> </p> <div class="flex space-x-s"> <a rel="nofollow noreferrer noopener" href="${0}" target="_blank" class="px-m py-xs text-primary font-medium tracking-wide border border-contrast-10 rounded transition-colors duration-200 hover-bg-primary-10 hover-border-primary-10 focus-outline-none focus-shadow-outline" router-ignore> <x-i18n ns="${0}" lang="${0}" key="errors.${0}.action"></x-i18n> </a> ${0} </div> </article> `),this.ns,this.lang,this.type,this.ns,this.lang,this.type,this._i18n.t(`errors.${this.type}.href`).toString(),this.ns,this.lang,this.type,this.reload?r(l||(l=c` <vaadin-button data-testid="reload" theme="primary" @click="${0}"> <x-i18n ns="${0}" lang="${0}" key="reload"></x-i18n> <iron-icon icon="icons:refresh" slot="suffix"></iron-icon> </vaadin-button> `),(()=>this.dispatchEvent(new h)),this.ns,this.lang):"")}}export{p as E,d as F};
@@ -226,5 +226,16 @@
226
226
  "custom_header": "Custom header",
227
227
  "custom_header_helper_text": "Any CSS or JS you need to add to the header can be put here and will be inserted before the </head> tag of your templates. Keep in mind all script file references must be through https or run through the Foxy caching system. Twig syntax is not available in the header.",
228
228
  "custom_footer": "Custom footer",
229
- "custom_footer_helper_text": "Any JS snippets or conversion scripts you need to add to the footer can be put here and will be inserted before the </body> tag. You can use Twig syntax here. For conversion scripts you only want to display once on the receipt page, use {% if first_receipt_display %} {# conversion script content here #} {% endif %}."
229
+ "custom_footer_helper_text": "Any JS snippets or conversion scripts you need to add to the footer can be put here and will be inserted before the </body> tag. You can use Twig syntax here. For conversion scripts you only want to display once on the receipt page, use {% if first_receipt_display %} {# conversion script content here #} {% endif %}.",
230
+ "ga_account_id": "Account ID",
231
+ "ga_account_id_explainer": "You can find the ID in the Admin section of your Analytics in Tracking info > Tracking code.",
232
+ "ga_include_on_site": "Include via loader.js",
233
+ "ga_include_on_site_explainer": "Enable Google Analytics on any page where the loader.js file is included.",
234
+ "sio_account_id": "Write Key",
235
+ "sio_account_id_explainer": "You can find the write key in your project set up guide or in the source’s settings.",
236
+ "troubleshooting": "Troubleshooting",
237
+ "troubleshooting_debug": "Log debug messages in the browser console",
238
+ "troubleshooting_debug_explainer": "Enable this option to trigger console.log() calls for our JS, which can assist with troubleshooting your store.",
239
+ "custom_config": "Custom config",
240
+ "custom_config_helper_text": "If you have any custom values you'd like to make available to your twig template, you can add them here as a valid JSON string."
230
241
  }
@@ -23,7 +23,7 @@ function radio(readonly, disabled, checked, attrs, label) {
23
23
  const border = `border ${readonly ? 'border-contrast-20' : 'border-transparent'}`;
24
24
  return html `
25
25
  <label class="group flex items-center ${disabled || readonly ? '' : 'cursor-pointer'}">
26
- <div class="item flex items-center justify-center">
26
+ <div class="item flex items-center justify-center flex-shrink-0">
27
27
  <div class="flex radio rounded-full ${border} ${ease} ${bg} focus-within-shadow-outline">
28
28
  <div class="dot m-auto rounded-full ${dot}"></div>
29
29
  <input type="radio" class="sr-only" .checked=${checked} ...=${attrs} />
@@ -44,7 +44,7 @@ function check(readonly, disabled, checked, attrs, label) {
44
44
  const border = `border ${readonly ? 'border-contrast-20' : 'border-transparent'}`;
45
45
  return html `
46
46
  <label class="group flex items-center ${disabled || readonly ? '' : 'cursor-pointer'}">
47
- <div class="item flex items-center justify-center text-primary-contrast">
47
+ <div class="item flex items-center justify-center flex-shrink-0 text-primary-contrast">
48
48
  <div class="check rounded-s ${border} ${ease} ${bg} focus-within-shadow-outline">
49
49
  <iron-icon icon="lumo:checkmark" class="block w-full h-full ${dot}"></iron-icon>
50
50
  <input type="checkbox" class="sr-only" .chec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KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;aAC7E;iBAAM;gBACL,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC;aAC1B;YAED,IAAI,CAAC,aAAa,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACxD,CAAC,CAAC;QAEF,MAAM,UAAU,GAAG,MAAM,CAAC;YACxB,aAAa,EAAE,IAAI,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE;YACjD,OAAO,EAAE,aAAa;YACtB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW;YACjD,KAAK,EAAE,IAAI,CAAC,GAAG;YACf,KAAK,EAAE,IAAI,CAAC,GAAG;YACf,WAAW,EAAE,IAAI,CAAC,QAAQ;YAC1B,WAAW,EAAE,IAAI,CAAC,QAAQ;YAC1B,aAAa,EAAE,OAAO;YACtB,SAAS,EAAE,WAAW;SACvB,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE;YAC7B,OAAO,IAAI,CAAA,0BAA0B,UAAU,uBAAuB,CAAC;SACxE;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;YAClC,OAAO,IAAI,CAAA,6BAA6B,UAAU,uCAAuC,CAAC;SAC3F;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE;YACnC,OAAO,IAAI,CAAA,yBAAyB,UAAU,sBAAsB,CAAC;SACtE;aAAM;YACL,OAAO,IAAI,CAAA,0BAA0B,UAAU,uBAAuB,CAAC;SACxE;IACH,CAAC;CACF","sourcesContent":["import '@polymer/iron-icon';\nimport '@vaadin/vaadin-lumo-styles/icons';\nimport '@vaadin/vaadin-text-field/vaadin-integer-field';\nimport '@vaadin/vaadin-text-field/vaadin-text-area';\nimport '@vaadin/vaadin-text-field/vaadin-text-field';\n\nimport { CSSResultArray, PropertyDeclarations, TemplateResult, css, html } from 'lit-element';\n\nimport { AttributePart } from 'lit-html';\nimport { ChoiceChangeEvent } from './ChoiceChangeEvent';\nimport { FrequencyInput } from '../FrequencyInput/FrequencyInput';\nimport { ScopedElementsMap } from '@open-wc/scoped-elements';\nimport { Translatable } from '../../../mixins/translatable';\nimport { interpret } from 'xstate';\nimport { machine } from './machine';\nimport { spread } from '@open-wc/lit-helpers/src/spread';\n\nconst VALUE_OTHER = `@foxy.io/elements::other[${(Math.pow(10, 10) * Math.random()).toFixed(0)}]`;\n\nfunction radio(\n readonly: boolean,\n disabled: boolean,\n checked: boolean,\n attrs: (part: AttributePart) => void,\n label: TemplateResult\n) {\n const enabledBg = checked ? 'bg-primary' : 'bg-contrast-20 group-hover-bg-contrast-30';\n const disabledBg = checked ? 'bg-primary-50' : 'bg-contrast-10';\n const scale = checked ? 'scale-100' : 'scale-0';\n const color = disabled ? 'text-disabled' : readonly ? 'text-secondary' : 'text-body';\n const ease = 'transition ease-in-out duration-200';\n const dotBg = readonly ? 'bg-contrast-20' : 'bg-tint';\n const dot = `${ease} ${disabled || readonly ? '' : 'shadow-xs'} transform ${scale} ${dotBg}`;\n const bg = readonly ? '' : disabled ? disabledBg : enabledBg;\n const border = `border ${readonly ? 'border-contrast-20' : 'border-transparent'}`;\n\n return html`\n <label class=\"group flex items-center ${disabled || readonly ? '' : 'cursor-pointer'}\">\n <div class=\"item flex items-center justify-center\">\n <div class=\"flex radio rounded-full ${border} ${ease} ${bg} focus-within-shadow-outline\">\n <div class=\"dot m-auto rounded-full ${dot}\"></div>\n <input type=\"radio\" class=\"sr-only\" .checked=${checked} ...=${attrs} />\n </div>\n </div>\n <div class=\"font-lumo leading-m ${color}\">${label}</div>\n </label>\n `;\n}\n\nfunction check(\n readonly: boolean,\n disabled: boolean,\n checked: boolean,\n attrs: (part: AttributePart) => void,\n label: TemplateResult\n) {\n const enabledBg = checked ? 'bg-primary' : 'bg-contrast-20 group-hover-bg-contrast-30';\n const disabledBg = checked ? 'bg-primary-50' : 'bg-contrast-10';\n const scale = checked ? 'scale-100' : 'scale-0';\n const color = disabled ? 'text-disabled' : readonly ? 'text-secondary' : 'text-body';\n const ease = 'transition ease-in-out duration-200';\n const dot = `${ease} transform ${scale} ${readonly ? 'text-contrast-20' : 'text-tint'}`;\n const bg = readonly ? '' : disabled ? disabledBg : enabledBg;\n const border = `border ${readonly ? 'border-contrast-20' : 'border-transparent'}`;\n\n return html`\n <label class=\"group flex items-center ${disabled || readonly ? '' : 'cursor-pointer'}\">\n <div class=\"item flex items-center justify-center text-primary-contrast\">\n <div class=\"check rounded-s ${border} ${ease} ${bg} focus-within-shadow-outline\">\n <iron-icon icon=\"lumo:checkmark\" class=\"block w-full h-full ${dot}\"></iron-icon>\n <input type=\"checkbox\" class=\"sr-only\" .checked=${checked} ...=${attrs} />\n </div>\n </div>\n <div class=\"font-lumo leading-m ${color}\">${label}</div>\n </label>\n `;\n}\n\nexport class Choice extends Translatable {\n public static get scopedElements(): ScopedElementsMap {\n return {\n 'vaadin-integer-field': customElements.get('vaadin-integer-field'),\n 'vaadin-text-field': customElements.get('vaadin-text-field'),\n 'x-frequency-input': FrequencyInput,\n 'vaadin-text-area': customElements.get('vaadin-text-area'),\n 'iron-icon': customElements.get('iron-icon'),\n };\n }\n\n public static get styles(): CSSResultArray {\n return [\n super.styles,\n css`\n :host {\n --item-width: calc((var(--lumo-space-m) * 2) + 1.25rem);\n }\n .ml-xxl {\n margin-left: var(--item-width);\n }\n .item {\n height: var(--lumo-size-l);\n width: var(--item-width);\n }\n .radio {\n height: 1.25rem;\n width: 1.25rem;\n }\n .check {\n height: 1.125rem;\n width: 1.125rem;\n }\n .dot {\n height: 0.5rem;\n width: 0.5rem;\n }\n `,\n ];\n }\n\n public static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n defaultCustomValue: { type: String, attribute: 'default-custom-value' },\n disabled: { type: Boolean },\n readonly: { type: Boolean },\n custom: { type: Boolean },\n type: { type: String },\n min: { type: Number },\n max: { type: Number },\n value: { type: Array },\n items: { type: Array },\n getText: { attribute: false },\n };\n }\n\n public getText: (value: string) => string = v => v;\n\n private __service = interpret(machine)\n .onChange(() => this.requestUpdate())\n .onTransition(({ changed }) => changed && this.requestUpdate())\n .start();\n\n public get defaultCustomValue(): string {\n return this.__service.state.context.defaultCustomValue;\n }\n\n public set defaultCustomValue(data: string) {\n this.__service.send('SET_DEFAULT_CUSTOM_VALUE', { data });\n }\n\n public get readonly(): boolean {\n return this.__service.state.matches('mutability.readonly');\n }\n\n public set readonly(data: boolean) {\n this.__service.send('SET_READONLY', { data });\n }\n\n public get disabled(): boolean {\n return this.__service.state.matches('interactivity.disabled');\n }\n\n public set disabled(data: boolean) {\n this.__service.send('SET_DISABLED', { data });\n }\n\n public get custom(): boolean {\n return this.__service.state.matches('extension.present');\n }\n\n public set custom(data: boolean) {\n this.__service.send('SET_CUSTOM', { data });\n }\n\n public get type(): 'text' | 'textarea' | 'integer' | 'frequency' {\n return this.__service.state.context.type;\n }\n\n public set type(data: 'text' | 'textarea' | 'integer' | 'frequency') {\n this.__service.send('SET_TYPE', { data });\n }\n\n public get min(): number | null {\n return this.__service.state.context.min;\n }\n\n public set min(data: number | null) {\n this.__service.send('SET_MIN', { data });\n }\n\n public get max(): number | null {\n return this.__service.state.context.max;\n }\n\n public set max(data: number | null) {\n this.__service.send('SET_MAX', { data });\n }\n\n public get value(): null | string | string[] {\n return this.__service.state.context.value;\n }\n\n public set value(data: null | string | string[]) {\n this.__service.send('SET_VALUE', { data });\n }\n\n public get items(): string[] {\n return this.__service.state.context.items;\n }\n\n public set items(data: string[]) {\n this.__service.send('SET_ITEMS', { data });\n }\n\n public render(): TemplateResult {\n const items = this.custom ? [...this.items, VALUE_OTHER] : this.items;\n const multiple = Array.isArray(this.value);\n const otherChecked = this.__service.state.matches('extension.present.selected');\n\n const children = html`\n ${items.map((item, index, array) => {\n const other = this.custom && index === array.length - 1;\n const checked = other\n ? otherChecked\n : multiple\n ? !!this.value?.includes(item)\n : item === String(this.value);\n const disabled = this.disabled || !this._isI18nReady;\n const attributes = spread({\n 'value': other ? VALUE_OTHER : item,\n 'name': multiple ? item : 'choice',\n 'data-testid': `item-${item}`,\n '?disabled': disabled || this.readonly,\n '@change': (evt: Event) => {\n const checked = (evt.target as HTMLInputElement).checked;\n const newItem = item === VALUE_OTHER ? this.defaultCustomValue : item;\n const value = this.value;\n if (Array.isArray(value)) {\n if (item === VALUE_OTHER) {\n this.value = checked ? [...value, newItem] : value.slice(0, value.length - 1);\n } else {\n this.value = checked ? [newItem, ...value] : value.filter(v => v !== newItem);\n }\n } else {\n this.value = checked ? newItem : null;\n }\n this.dispatchEvent(new ChoiceChangeEvent(this.value));\n },\n });\n const label = html`\n <div>\n ${item === VALUE_OTHER\n ? this._t('choice.other').toString()\n : html`<slot name=${`${item}-label`}>${this.getText(item)}</slot>`}\n </div>\n `;\n return html`\n <div class=\"ml-xxl border-t border-contrast-10 ${index ? '' : 'hidden'}\"></div>\n ${multiple\n ? check(this.readonly, disabled, checked, attributes, label)\n : radio(this.readonly, disabled, checked, attributes, label)}\n <div class=\"mr-m ml-xxl\">\n ${item === VALUE_OTHER && otherChecked ? this.__field : ''}\n ${item !== VALUE_OTHER ? html`<slot name=${item}></slot>` : ''}\n </div>\n `;\n })}\n `;\n\n return html`<form>${children}</form> `;\n }\n\n private get __field() {\n const handleInput = (evt: Event) => {\n evt.stopPropagation();\n const customValue = (evt.target as HTMLInputElement).value;\n\n if (Array.isArray(this.value)) {\n this.value = this.value.slice(0, this.value.length - 1).concat(customValue);\n } else {\n this.value = customValue;\n }\n\n this.dispatchEvent(new ChoiceChangeEvent(this.value));\n };\n\n const attributes = spread({\n 'placeholder': this._t('choice.other').toString(),\n 'class': 'w-full mb-m',\n 'value': this.__service.state.context.customValue,\n 'max': this.max,\n 'min': this.min,\n '?disabled': this.disabled,\n '?readonly': this.readonly,\n 'data-testid': 'field',\n '@change': handleInput,\n });\n\n if (this.type === 'frequency') {\n return html`<x-frequency-input ...=${attributes}></x-frequency-input>`;\n } else if (this.type === 'integer') {\n return html`<vaadin-integer-field ...=${attributes} has-controls></vaadin-integer-field>`;\n } else if (this.type === 'textarea') {\n return html`<vaadin-text-area ...=${attributes}></vaadin-text-area>`;\n } else {\n return html`<vaadin-text-field ...=${attributes}></vaadin-text-field>`;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"Choice.js","sourceRoot":"","sources":["../../../../src/elements/private/Choice/Choice.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,kCAAkC,CAAC;AAC1C,OAAO,gDAAgD,CAAC;AACxD,OAAO,4CAA4C,CAAC;AACpD,OAAO,6CAA6C,CAAC;AAErD,OAAO,EAAwD,GAAG,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAG9F,OAAO,EAAE,iBAAiB,EAAE,+BAA4B;AACxD,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAElE,OAAO,EAAE,YAAY,EAAE,wCAAqC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,qBAAkB;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAEzD,MAAM,WAAW,GAAG,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;AAEjG,SAAS,KAAK,CACZ,QAAiB,EACjB,QAAiB,EACjB,OAAgB,EAChB,KAAoC,EACpC,KAAqB;IAErB,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,2CAA2C,CAAC;IACvF,MAAM,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CA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C,OAAO,IAAI,CAAA,yBAAyB,UAAU,sBAAsB,CAAC;SACtE;aAAM;YACL,OAAO,IAAI,CAAA,0BAA0B,UAAU,uBAAuB,CAAC;SACxE;IACH,CAAC;CACF","sourcesContent":["import '@polymer/iron-icon';\nimport '@vaadin/vaadin-lumo-styles/icons';\nimport '@vaadin/vaadin-text-field/vaadin-integer-field';\nimport '@vaadin/vaadin-text-field/vaadin-text-area';\nimport '@vaadin/vaadin-text-field/vaadin-text-field';\n\nimport { CSSResultArray, PropertyDeclarations, TemplateResult, css, html } from 'lit-element';\n\nimport { AttributePart } from 'lit-html';\nimport { ChoiceChangeEvent } from './ChoiceChangeEvent';\nimport { FrequencyInput } from '../FrequencyInput/FrequencyInput';\nimport { ScopedElementsMap } from '@open-wc/scoped-elements';\nimport { Translatable } from '../../../mixins/translatable';\nimport { interpret } from 'xstate';\nimport { machine } from './machine';\nimport { spread } from '@open-wc/lit-helpers/src/spread';\n\nconst VALUE_OTHER = `@foxy.io/elements::other[${(Math.pow(10, 10) * Math.random()).toFixed(0)}]`;\n\nfunction radio(\n readonly: boolean,\n disabled: boolean,\n checked: boolean,\n attrs: (part: AttributePart) => void,\n label: TemplateResult\n) {\n const enabledBg = checked ? 'bg-primary' : 'bg-contrast-20 group-hover-bg-contrast-30';\n const disabledBg = checked ? 'bg-primary-50' : 'bg-contrast-10';\n const scale = checked ? 'scale-100' : 'scale-0';\n const color = disabled ? 'text-disabled' : readonly ? 'text-secondary' : 'text-body';\n const ease = 'transition ease-in-out duration-200';\n const dotBg = readonly ? 'bg-contrast-20' : 'bg-tint';\n const dot = `${ease} ${disabled || readonly ? '' : 'shadow-xs'} transform ${scale} ${dotBg}`;\n const bg = readonly ? '' : disabled ? disabledBg : enabledBg;\n const border = `border ${readonly ? 'border-contrast-20' : 'border-transparent'}`;\n\n return html`\n <label class=\"group flex items-center ${disabled || readonly ? '' : 'cursor-pointer'}\">\n <div class=\"item flex items-center justify-center flex-shrink-0\">\n <div class=\"flex radio rounded-full ${border} ${ease} ${bg} focus-within-shadow-outline\">\n <div class=\"dot m-auto rounded-full ${dot}\"></div>\n <input type=\"radio\" class=\"sr-only\" .checked=${checked} ...=${attrs} />\n </div>\n </div>\n <div class=\"font-lumo leading-m ${color}\">${label}</div>\n </label>\n `;\n}\n\nfunction check(\n readonly: boolean,\n disabled: boolean,\n checked: boolean,\n attrs: (part: AttributePart) => void,\n label: TemplateResult\n) {\n const enabledBg = checked ? 'bg-primary' : 'bg-contrast-20 group-hover-bg-contrast-30';\n const disabledBg = checked ? 'bg-primary-50' : 'bg-contrast-10';\n const scale = checked ? 'scale-100' : 'scale-0';\n const color = disabled ? 'text-disabled' : readonly ? 'text-secondary' : 'text-body';\n const ease = 'transition ease-in-out duration-200';\n const dot = `${ease} transform ${scale} ${readonly ? 'text-contrast-20' : 'text-tint'}`;\n const bg = readonly ? '' : disabled ? disabledBg : enabledBg;\n const border = `border ${readonly ? 'border-contrast-20' : 'border-transparent'}`;\n\n return html`\n <label class=\"group flex items-center ${disabled || readonly ? '' : 'cursor-pointer'}\">\n <div class=\"item flex items-center justify-center flex-shrink-0 text-primary-contrast\">\n <div class=\"check rounded-s ${border} ${ease} ${bg} focus-within-shadow-outline\">\n <iron-icon icon=\"lumo:checkmark\" class=\"block w-full h-full ${dot}\"></iron-icon>\n <input type=\"checkbox\" class=\"sr-only\" .checked=${checked} ...=${attrs} />\n </div>\n </div>\n <div class=\"font-lumo leading-m ${color}\">${label}</div>\n </label>\n `;\n}\n\nexport class Choice extends Translatable {\n public static get scopedElements(): ScopedElementsMap {\n return {\n 'vaadin-integer-field': customElements.get('vaadin-integer-field'),\n 'vaadin-text-field': customElements.get('vaadin-text-field'),\n 'x-frequency-input': FrequencyInput,\n 'vaadin-text-area': customElements.get('vaadin-text-area'),\n 'iron-icon': customElements.get('iron-icon'),\n };\n }\n\n public static get styles(): CSSResultArray {\n return [\n super.styles,\n css`\n :host {\n --item-width: calc((var(--lumo-space-m) * 2) + 1.25rem);\n }\n .ml-xxl {\n margin-left: var(--item-width);\n }\n .item {\n height: var(--lumo-size-l);\n width: var(--item-width);\n }\n .radio {\n height: 1.25rem;\n width: 1.25rem;\n }\n .check {\n height: 1.125rem;\n width: 1.125rem;\n }\n .dot {\n height: 0.5rem;\n width: 0.5rem;\n }\n `,\n ];\n }\n\n public static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n defaultCustomValue: { type: String, attribute: 'default-custom-value' },\n disabled: { type: Boolean },\n readonly: { type: Boolean },\n custom: { type: Boolean },\n type: { type: String },\n min: { type: Number },\n max: { type: Number },\n value: { type: Array },\n items: { type: Array },\n getText: { attribute: false },\n };\n }\n\n public getText: (value: string) => string = v => v;\n\n private __service = interpret(machine)\n .onChange(() => this.requestUpdate())\n .onTransition(({ changed }) => changed && this.requestUpdate())\n .start();\n\n public get defaultCustomValue(): string {\n return this.__service.state.context.defaultCustomValue;\n }\n\n public set defaultCustomValue(data: string) {\n this.__service.send('SET_DEFAULT_CUSTOM_VALUE', { data });\n }\n\n public get readonly(): boolean {\n return this.__service.state.matches('mutability.readonly');\n }\n\n public set readonly(data: boolean) {\n this.__service.send('SET_READONLY', { data });\n }\n\n public get disabled(): boolean {\n return this.__service.state.matches('interactivity.disabled');\n }\n\n public set disabled(data: boolean) {\n this.__service.send('SET_DISABLED', { data });\n }\n\n public get custom(): boolean {\n return this.__service.state.matches('extension.present');\n }\n\n public set custom(data: boolean) {\n this.__service.send('SET_CUSTOM', { data });\n }\n\n public get type(): 'text' | 'textarea' | 'integer' | 'frequency' {\n return this.__service.state.context.type;\n }\n\n public set type(data: 'text' | 'textarea' | 'integer' | 'frequency') {\n this.__service.send('SET_TYPE', { data });\n }\n\n public get min(): number | null {\n return this.__service.state.context.min;\n }\n\n public set min(data: number | null) {\n this.__service.send('SET_MIN', { data });\n }\n\n public get max(): number | null {\n return this.__service.state.context.max;\n }\n\n public set max(data: number | null) {\n this.__service.send('SET_MAX', { data });\n }\n\n public get value(): null | string | string[] {\n return this.__service.state.context.value;\n }\n\n public set value(data: null | string | string[]) {\n this.__service.send('SET_VALUE', { data });\n }\n\n public get items(): string[] {\n return this.__service.state.context.items;\n }\n\n public set items(data: string[]) {\n this.__service.send('SET_ITEMS', { data });\n }\n\n public render(): TemplateResult {\n const items = this.custom ? [...this.items, VALUE_OTHER] : this.items;\n const multiple = Array.isArray(this.value);\n const otherChecked = this.__service.state.matches('extension.present.selected');\n\n const children = html`\n ${items.map((item, index, array) => {\n const other = this.custom && index === array.length - 1;\n const checked = other\n ? otherChecked\n : multiple\n ? !!this.value?.includes(item)\n : item === String(this.value);\n const disabled = this.disabled || !this._isI18nReady;\n const attributes = spread({\n 'value': other ? VALUE_OTHER : item,\n 'name': multiple ? item : 'choice',\n 'data-testid': `item-${item}`,\n '?disabled': disabled || this.readonly,\n '@change': (evt: Event) => {\n const checked = (evt.target as HTMLInputElement).checked;\n const newItem = item === VALUE_OTHER ? this.defaultCustomValue : item;\n const value = this.value;\n if (Array.isArray(value)) {\n if (item === VALUE_OTHER) {\n this.value = checked ? [...value, newItem] : value.slice(0, value.length - 1);\n } else {\n this.value = checked ? [newItem, ...value] : value.filter(v => v !== newItem);\n }\n } else {\n this.value = checked ? newItem : null;\n }\n this.dispatchEvent(new ChoiceChangeEvent(this.value));\n },\n });\n const label = html`\n <div>\n ${item === VALUE_OTHER\n ? this._t('choice.other').toString()\n : html`<slot name=${`${item}-label`}>${this.getText(item)}</slot>`}\n </div>\n `;\n return html`\n <div class=\"ml-xxl border-t border-contrast-10 ${index ? '' : 'hidden'}\"></div>\n ${multiple\n ? check(this.readonly, disabled, checked, attributes, label)\n : radio(this.readonly, disabled, checked, attributes, label)}\n <div class=\"mr-m ml-xxl\">\n ${item === VALUE_OTHER && otherChecked ? this.__field : ''}\n ${item !== VALUE_OTHER ? html`<slot name=${item}></slot>` : ''}\n </div>\n `;\n })}\n `;\n\n return html`<form>${children}</form> `;\n }\n\n private get __field() {\n const handleInput = (evt: Event) => {\n evt.stopPropagation();\n const customValue = (evt.target as HTMLInputElement).value;\n\n if (Array.isArray(this.value)) {\n this.value = this.value.slice(0, this.value.length - 1).concat(customValue);\n } else {\n this.value = customValue;\n }\n\n this.dispatchEvent(new ChoiceChangeEvent(this.value));\n };\n\n const attributes = spread({\n 'placeholder': this._t('choice.other').toString(),\n 'class': 'w-full mb-m',\n 'value': this.__service.state.context.customValue,\n 'max': this.max,\n 'min': this.min,\n '?disabled': this.disabled,\n '?readonly': this.readonly,\n 'data-testid': 'field',\n '@change': handleInput,\n });\n\n if (this.type === 'frequency') {\n return html`<x-frequency-input ...=${attributes}></x-frequency-input>`;\n } else if (this.type === 'integer') {\n return html`<vaadin-integer-field ...=${attributes} has-controls></vaadin-integer-field>`;\n } else if (this.type === 'textarea') {\n return html`<vaadin-text-area ...=${attributes}></vaadin-text-area>`;\n } else {\n return html`<vaadin-text-field ...=${attributes}></vaadin-text-field>`;\n }\n }\n}\n"]}
@@ -139,7 +139,7 @@ export class EmailTemplateForm extends Base {
139
139
  >
140
140
  ${['default', 'url', 'clipboard'].map(value => {
141
141
  return html `
142
- <div slot="${value}-label" class="py-s">
142
+ <div slot="${value}-label" class="py-s leading-s">
143
143
  <foxy-i18n class="block" lang=${this.lang} key="template_${value}" ns=${this.ns}>
144
144
  </foxy-i18n>
145
145
 
@@ -1 +1 @@
1
- {"version":3,"file":"EmailTemplateForm.js","sourceRoot":"","sources":["../../../../src/elements/public/EmailTemplateForm/EmailTemplateForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwD,GAAG,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,+BAA4B;AACnE,OAAO,EAAqB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,gCAA6B;AACzD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAIjE,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAGlE,OAAO,EAAE,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AAC,MAAM,CAAC,SAAS;gBAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QAC3C,CAAC;;;;;;kBAMO,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE;wBACxD,MAAM;sBACR,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,UAAU;mBAC5D,WAAW;;0BAEJ,EAAE,QAAQ,MAAM,SAAS,IAAI;;;UAG7C,IAAI,CAAC,oBAAoB,CAAC,GAAG,MAAM,QAAQ,CAAC;;KAEjD,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,OAAO;;QACnB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;QAE3B,IAAI;YACF,MAAM,GAAG,eAAG,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,UAAU,EAAE,IAAI,mCAAI,EAAE,CAAC;YACrD,MAAM,QAAQ,GAAG,MAAM,IAAI,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YAEtF,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;SACnD;QAAC,WAAM;YACN,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;SAC5B;IACH,CAAC;CACF","sourcesContent":["import { CSSResultArray, PropertyDeclarations, TemplateResult, css, html } from 'lit-element';\nimport { Choice, Group, PropertyTable } from '../../private/index';\nimport { ScopedElementsMap, ScopedElementsMixin } from '@open-wc/scoped-elements';\n\nimport { ChoiceChangeEvent } from '../../private/events';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { Data } from './types';\nimport { DialogHideEvent } from '../../private/Dialog/DialogHideEvent';\nimport { InternalConfirmDialog } from '../../internal/InternalConfirmDialog/InternalConfirmDialog';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { TextAreaElement } from '@vaadin/vaadin-text-field/vaadin-text-area';\nimport { TextFieldElement } from '@vaadin/vaadin-text-field';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { ifDefined } from 'lit-html/directives/if-defined';\n\nconst NS = 'email-template-form';\nconst Base = ScopedElementsMixin(\n ThemeableMixin(ConfigurableMixin(TranslatableMixin(NucleonElement, NS)))\n);\n\nexport class EmailTemplateForm extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __cacheState: { attribute: false },\n __contentChoice: { attribute: false },\n };\n }\n\n static get styles(): CSSResultArray {\n return [\n ...super.styles,\n css`\n #cached-content::part(input-field) {\n max-height: 15em;\n }\n `,\n ];\n }\n\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n 'vaadin-text-field': customElements.get('vaadin-text-field'),\n 'vaadin-text-area': customElements.get('vaadin-text-area'),\n 'vaadin-button': customElements.get('vaadin-button'),\n 'x-property-table': PropertyTable,\n 'x-choice': Choice,\n 'x-group': Group,\n };\n }\n\n private __cacheState: 'idle' | 'busy' | 'fail' = 'idle';\n\n private __contentChoice: 'default' | 'url' | 'clipboard' = 'default';\n\n render(): TemplateResult {\n const { hiddenSelector, href, lang, ns } = this;\n const action = href ? 'delete' : 'create';\n const isBusy = this.in('busy');\n const isFail = this.in('fail');\n\n return html`\n <div class=\"space-y-m\">\n ${hiddenSelector.matches('description', true) ? '' : this.__renderDescription()}\n ${hiddenSelector.matches('content', true) ? '' : this.__renderContent()}\n ${hiddenSelector.matches('timestamps', true) || !href ? '' : this.__renderTimestamps()}\n ${hiddenSelector.matches(action) ? '' : this.__renderAction(action)}\n\n <div\n data-testid=\"spinner\"\n class=${classMap({\n 'transition duration-500 ease-in-out absolute inset-0 flex': true,\n 'opacity-0 pointer-events-none': !isBusy && !isFail,\n })}\n >\n <foxy-spinner\n layout=\"vertical\"\n class=\"m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l\"\n state=${isFail ? 'error' : isBusy ? 'busy' : 'empty'}\n lang=${lang}\n ns=\"${ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n private __renderDescription() {\n return html`\n <div>\n ${this.renderTemplateOrSlot('description:before')}\n\n <vaadin-text-field\n class=\"w-full mb-s\"\n label=${this.t('description')}\n .value=${this.form?.description ?? ''}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.submit()}\n @input=${(evt: CustomEvent) => {\n this.edit({ description: (evt.currentTarget as TextFieldElement).value });\n }}\n >\n </vaadin-text-field>\n\n ${this.renderTemplateOrSlot('description:after')}\n </div>\n `;\n }\n\n private __renderContent() {\n return html`\n <div>\n ${this.renderTemplateOrSlot('content:before')}\n\n <div class=\"space-y-l\">\n ${this.__renderTabContent('content_text_url', 'content_text', 'text_template')}\n ${this.__renderTabContent('content_html_url', 'content_html', 'html_template')}\n </div>\n\n ${this.renderTemplateOrSlot('content:after')}\n </div>\n `;\n }\n\n private __renderTabContent(\n urlPath: 'content_text_url' | 'content_html_url',\n textPath: 'content_text' | 'content_html',\n header: string\n ) {\n const contentChoice = this.form[urlPath]\n ? 'url'\n : this.form[textPath]\n ? 'clipboard'\n : this.__contentChoice;\n\n return html`\n <x-group frame>\n <foxy-i18n lang=${this.lang} slot=\"header\" key=${header} ns=${this.ns}></foxy-i18n>\n\n <x-choice\n data-testid=\"template-type\"\n .value=${contentChoice}\n .items=${['default', 'url', 'clipboard']}\n ?readonly=${this.readonlySelector.matches('content', true)}\n ?disabled=${this.in('busy') || this.disabledSelector.matches('content', true)}\n @change=${(evt: Event) => {\n if (evt instanceof ChoiceChangeEvent) {\n this.edit({ [textPath]: '', [urlPath]: '' });\n this.__contentChoice = evt.detail as 'url' | 'clipboard' | 'default';\n }\n }}\n >\n ${['default', 'url', 'clipboard'].map(value => {\n return html`\n <div slot=\"${value}-label\" class=\"py-s\">\n <foxy-i18n class=\"block\" lang=${this.lang} key=\"template_${value}\" ns=${this.ns}>\n </foxy-i18n>\n\n <foxy-i18n\n class=\"block text-s opacity-70\"\n lang=${this.lang}\n key=\"template_${value}_explainer\"\n ns=${this.ns}\n >\n </foxy-i18n>\n </div>\n `;\n })}\n\n <div slot=\"url\" ?hidden=${contentChoice !== 'url'}>\n <div class=\"flex items-center mt-0 mb-m\">\n <vaadin-text-field\n data-testid=\"content_url\"\n value=${ifDefined(this.form[urlPath])}\n class=\"mr-s flex-grow\"\n @input=${(evt: CustomEvent) => {\n const value = (evt.currentTarget as TextFieldElement).value;\n this.edit({ [textPath]: '', [urlPath]: value });\n }}\n >\n </vaadin-text-field>\n\n ${this.form[urlPath] === this.data?.[urlPath]\n ? html`\n <vaadin-button\n class=\"relative\"\n ?disabled=${this.__cacheState === 'busy'}\n @click=${this.__cache}\n >\n <foxy-i18n\n class=${classMap({\n 'relative transition-opacity': true,\n 'opacity-0': this.__cacheState !== 'idle',\n })}\n lang=${this.lang}\n key=\"cache\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n <div\n class=${classMap({\n 'absolute inset-0 flex transition-opacity': true,\n 'opacity-0': this.__cacheState === 'idle',\n })}\n >\n <foxy-spinner\n layout=\"no-label\"\n class=\"m-auto\"\n state=${this.__cacheState === 'fail' ? 'error' : 'busy'}\n lang=${this.lang}\n ns=${this.ns}\n >\n </foxy-spinner>\n </div>\n </vaadin-button>\n `\n : ''}\n </div>\n </div>\n\n <div slot=\"clipboard\" ?hidden=${contentChoice !== 'clipboard'}>\n <vaadin-text-area\n id=\"cached-content\"\n data-testid=\"content\"\n class=\"w-full mb-m\"\n .value=${this.form[textPath]}\n @input=${(evt: CustomEvent) => {\n const value = (evt.currentTarget as TextAreaElement).value;\n this.edit({ [textPath]: value, [urlPath]: '' });\n }}\n >\n </vaadin-text-area>\n </div>\n </x-choice>\n </x-group>\n `;\n }\n\n private __renderTimestamps() {\n return html`\n <div>\n ${this.renderTemplateOrSlot('timestamps:before')}\n\n <x-property-table\n data-testid=\"timestamps\"\n .items=${(['date_modified', 'date_created'] as const).map(field => ({\n name: this.t(field),\n value: this.data?.[field]\n ? this.t('date', { value: new Date(this.data[field] as string) })\n : '',\n }))}\n >\n </x-property-table>\n\n ${this.renderTemplateOrSlot('timestamps:after')}\n </div>\n `;\n }\n\n private __renderAction(action: string) {\n const { disabledSelector, href, lang, ns } = this;\n\n const isTemplateValid = this.in({ idle: { template: { dirty: 'valid' } } });\n const isSnapshotValid = this.in({ idle: { snapshot: { dirty: 'valid' } } });\n const isDisabled = !this.in('idle') || disabledSelector.matches(action, true);\n const isValid = isTemplateValid || isSnapshotValid;\n\n const handleClick = (evt: Event) => {\n if (action === 'delete') {\n const confirm = this.renderRoot.querySelector('#confirm');\n (confirm as InternalConfirmDialog).show(evt.currentTarget as HTMLElement);\n } else {\n this.submit();\n }\n };\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${action}:before`)}\n\n <foxy-internal-confirm-dialog\n message=\"delete_prompt\"\n confirm=\"delete\"\n cancel=\"cancel\"\n header=\"delete\"\n theme=\"primary error\"\n lang=${lang}\n ns=${ns}\n id=\"confirm\"\n data-testid=\"confirm\"\n @hide=${(evt: DialogHideEvent) => {\n if (!evt.detail.cancelled) this.delete();\n }}\n >\n </foxy-internal-confirm-dialog>\n\n <vaadin-button\n class=\"w-full\"\n theme=${this.in('idle') ? `primary ${href ? 'error' : 'success'}` : ''}\n data-testid=${action}\n ?disabled=${(this.in({ idle: 'template' }) && !isValid) || isDisabled}\n @click=${handleClick}\n >\n <foxy-i18n ns=${ns} key=${action} lang=${lang}></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot(`${action}:after`)}\n </div>\n `;\n }\n\n private async __cache(): Promise<void> {\n this.__cacheState = 'busy';\n\n try {\n const url = this.data?._links['fx:cache'].href ?? '';\n const response = await new EmailTemplateForm.API(this).fetch(url, { method: 'POST' });\n\n this.__cacheState = response.ok ? 'idle' : 'fail';\n } catch {\n this.__cacheState = 'fail';\n }\n }\n}\n"]}
1
+ {"version":3,"file":"EmailTemplateForm.js","sourceRoot":"","sources":["../../../../src/elements/public/EmailTemplateForm/EmailTemplateForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwD,GAAG,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,+BAA4B;AACnE,OAAO,EAAqB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,gCAA6B;AACzD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAIjE,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAGlE,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,MAAM,EAAE,GAAG,qBAAqB,CAAC;AACjC,MAAM,IAAI,GAAG,mBAAmB,CAC9B,cAAc,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,CACzE,CAAC;AAEF,MAAM,OAAO,iBAAkB,SAAQ,IAAU;IAAjD;;QAmCU,iBAAY,GAA6B,MAAM,CAAC;QAEhD,oBAAe,GAAoC,SAAS,CAAC;IA+QvE,CAAC;IAnTC,MAAM,KAAK,UAAU;QACnB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C;IACJ,CAAC;IAEO,KAAK,CAAC,OAAO;;QACnB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;QAE3B,IAAI;YACF,MAAM,GAAG,eAAG,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,UAAU,EAAE,IAAI,mCAAI,EAAE,CAAC;YACrD,MAAM,QAAQ,GAAG,MAAM,IAAI,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YAEtF,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;SACnD;QAAC,WAAM;YACN,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;SAC5B;IACH,CAAC;CACF","sourcesContent":["import { CSSResultArray, PropertyDeclarations, TemplateResult, css, html } from 'lit-element';\nimport { Choice, Group, PropertyTable } from '../../private/index';\nimport { ScopedElementsMap, ScopedElementsMixin } from '@open-wc/scoped-elements';\n\nimport { ChoiceChangeEvent } from '../../private/events';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { Data } from './types';\nimport { DialogHideEvent } from '../../private/Dialog/DialogHideEvent';\nimport { InternalConfirmDialog } from '../../internal/InternalConfirmDialog/InternalConfirmDialog';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { TextAreaElement } from '@vaadin/vaadin-text-field/vaadin-text-area';\nimport { TextFieldElement } from '@vaadin/vaadin-text-field';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { ifDefined } from 'lit-html/directives/if-defined';\n\nconst NS = 'email-template-form';\nconst Base = ScopedElementsMixin(\n ThemeableMixin(ConfigurableMixin(TranslatableMixin(NucleonElement, NS)))\n);\n\nexport class EmailTemplateForm extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n __cacheState: { attribute: false },\n __contentChoice: { attribute: false },\n };\n }\n\n static get styles(): CSSResultArray {\n return [\n ...super.styles,\n css`\n #cached-content::part(input-field) {\n max-height: 15em;\n }\n `,\n ];\n }\n\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-confirm-dialog': customElements.get('foxy-internal-confirm-dialog'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n 'vaadin-text-field': customElements.get('vaadin-text-field'),\n 'vaadin-text-area': customElements.get('vaadin-text-area'),\n 'vaadin-button': customElements.get('vaadin-button'),\n 'x-property-table': PropertyTable,\n 'x-choice': Choice,\n 'x-group': Group,\n };\n }\n\n private __cacheState: 'idle' | 'busy' | 'fail' = 'idle';\n\n private __contentChoice: 'default' | 'url' | 'clipboard' = 'default';\n\n render(): TemplateResult {\n const { hiddenSelector, href, lang, ns } = this;\n const action = href ? 'delete' : 'create';\n const isBusy = this.in('busy');\n const isFail = this.in('fail');\n\n return html`\n <div class=\"space-y-m\">\n ${hiddenSelector.matches('description', true) ? '' : this.__renderDescription()}\n ${hiddenSelector.matches('content', true) ? '' : this.__renderContent()}\n ${hiddenSelector.matches('timestamps', true) || !href ? '' : this.__renderTimestamps()}\n ${hiddenSelector.matches(action) ? '' : this.__renderAction(action)}\n\n <div\n data-testid=\"spinner\"\n class=${classMap({\n 'transition duration-500 ease-in-out absolute inset-0 flex': true,\n 'opacity-0 pointer-events-none': !isBusy && !isFail,\n })}\n >\n <foxy-spinner\n layout=\"vertical\"\n class=\"m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l\"\n state=${isFail ? 'error' : isBusy ? 'busy' : 'empty'}\n lang=${lang}\n ns=\"${ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n `;\n }\n\n private __renderDescription() {\n return html`\n <div>\n ${this.renderTemplateOrSlot('description:before')}\n\n <vaadin-text-field\n class=\"w-full mb-s\"\n label=${this.t('description')}\n .value=${this.form?.description ?? ''}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.submit()}\n @input=${(evt: CustomEvent) => {\n this.edit({ description: (evt.currentTarget as TextFieldElement).value });\n }}\n >\n </vaadin-text-field>\n\n ${this.renderTemplateOrSlot('description:after')}\n </div>\n `;\n }\n\n private __renderContent() {\n return html`\n <div>\n ${this.renderTemplateOrSlot('content:before')}\n\n <div class=\"space-y-l\">\n ${this.__renderTabContent('content_text_url', 'content_text', 'text_template')}\n ${this.__renderTabContent('content_html_url', 'content_html', 'html_template')}\n </div>\n\n ${this.renderTemplateOrSlot('content:after')}\n </div>\n `;\n }\n\n private __renderTabContent(\n urlPath: 'content_text_url' | 'content_html_url',\n textPath: 'content_text' | 'content_html',\n header: string\n ) {\n const contentChoice = this.form[urlPath]\n ? 'url'\n : this.form[textPath]\n ? 'clipboard'\n : this.__contentChoice;\n\n return html`\n <x-group frame>\n <foxy-i18n lang=${this.lang} slot=\"header\" key=${header} ns=${this.ns}></foxy-i18n>\n\n <x-choice\n data-testid=\"template-type\"\n .value=${contentChoice}\n .items=${['default', 'url', 'clipboard']}\n ?readonly=${this.readonlySelector.matches('content', true)}\n ?disabled=${this.in('busy') || this.disabledSelector.matches('content', true)}\n @change=${(evt: Event) => {\n if (evt instanceof ChoiceChangeEvent) {\n this.edit({ [textPath]: '', [urlPath]: '' });\n this.__contentChoice = evt.detail as 'url' | 'clipboard' | 'default';\n }\n }}\n >\n ${['default', 'url', 'clipboard'].map(value => {\n return html`\n <div slot=\"${value}-label\" class=\"py-s leading-s\">\n <foxy-i18n class=\"block\" lang=${this.lang} key=\"template_${value}\" ns=${this.ns}>\n </foxy-i18n>\n\n <foxy-i18n\n class=\"block text-s opacity-70\"\n lang=${this.lang}\n key=\"template_${value}_explainer\"\n ns=${this.ns}\n >\n </foxy-i18n>\n </div>\n `;\n })}\n\n <div slot=\"url\" ?hidden=${contentChoice !== 'url'}>\n <div class=\"flex items-center mt-0 mb-m\">\n <vaadin-text-field\n data-testid=\"content_url\"\n value=${ifDefined(this.form[urlPath])}\n class=\"mr-s flex-grow\"\n @input=${(evt: CustomEvent) => {\n const value = (evt.currentTarget as TextFieldElement).value;\n this.edit({ [textPath]: '', [urlPath]: value });\n }}\n >\n </vaadin-text-field>\n\n ${this.form[urlPath] === this.data?.[urlPath]\n ? html`\n <vaadin-button\n class=\"relative\"\n ?disabled=${this.__cacheState === 'busy'}\n @click=${this.__cache}\n >\n <foxy-i18n\n class=${classMap({\n 'relative transition-opacity': true,\n 'opacity-0': this.__cacheState !== 'idle',\n })}\n lang=${this.lang}\n key=\"cache\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n <div\n class=${classMap({\n 'absolute inset-0 flex transition-opacity': true,\n 'opacity-0': this.__cacheState === 'idle',\n })}\n >\n <foxy-spinner\n layout=\"no-label\"\n class=\"m-auto\"\n state=${this.__cacheState === 'fail' ? 'error' : 'busy'}\n lang=${this.lang}\n ns=${this.ns}\n >\n </foxy-spinner>\n </div>\n </vaadin-button>\n `\n : ''}\n </div>\n </div>\n\n <div slot=\"clipboard\" ?hidden=${contentChoice !== 'clipboard'}>\n <vaadin-text-area\n id=\"cached-content\"\n data-testid=\"content\"\n class=\"w-full mb-m\"\n .value=${this.form[textPath]}\n @input=${(evt: CustomEvent) => {\n const value = (evt.currentTarget as TextAreaElement).value;\n this.edit({ [textPath]: value, [urlPath]: '' });\n }}\n >\n </vaadin-text-area>\n </div>\n </x-choice>\n </x-group>\n `;\n }\n\n private __renderTimestamps() {\n return html`\n <div>\n ${this.renderTemplateOrSlot('timestamps:before')}\n\n <x-property-table\n data-testid=\"timestamps\"\n .items=${(['date_modified', 'date_created'] as const).map(field => ({\n name: this.t(field),\n value: this.data?.[field]\n ? this.t('date', { value: new Date(this.data[field] as string) })\n : '',\n }))}\n >\n </x-property-table>\n\n ${this.renderTemplateOrSlot('timestamps:after')}\n </div>\n `;\n }\n\n private __renderAction(action: string) {\n const { disabledSelector, href, lang, ns } = this;\n\n const isTemplateValid = this.in({ idle: { template: { dirty: 'valid' } } });\n const isSnapshotValid = this.in({ idle: { snapshot: { dirty: 'valid' } } });\n const isDisabled = !this.in('idle') || disabledSelector.matches(action, true);\n const isValid = isTemplateValid || isSnapshotValid;\n\n const handleClick = (evt: Event) => {\n if (action === 'delete') {\n const confirm = this.renderRoot.querySelector('#confirm');\n (confirm as InternalConfirmDialog).show(evt.currentTarget as HTMLElement);\n } else {\n this.submit();\n }\n };\n\n return html`\n <div>\n ${this.renderTemplateOrSlot(`${action}:before`)}\n\n <foxy-internal-confirm-dialog\n message=\"delete_prompt\"\n confirm=\"delete\"\n cancel=\"cancel\"\n header=\"delete\"\n theme=\"primary error\"\n lang=${lang}\n ns=${ns}\n id=\"confirm\"\n data-testid=\"confirm\"\n @hide=${(evt: DialogHideEvent) => {\n if (!evt.detail.cancelled) this.delete();\n }}\n >\n </foxy-internal-confirm-dialog>\n\n <vaadin-button\n class=\"w-full\"\n theme=${this.in('idle') ? `primary ${href ? 'error' : 'success'}` : ''}\n data-testid=${action}\n ?disabled=${(this.in({ idle: 'template' }) && !isValid) || isDisabled}\n @click=${handleClick}\n >\n <foxy-i18n ns=${ns} key=${action} lang=${lang}></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot(`${action}:after`)}\n </div>\n `;\n }\n\n private async __cache(): Promise<void> {\n this.__cacheState = 'busy';\n\n try {\n const url = this.data?._links['fx:cache'].href ?? '';\n const response = await new EmailTemplateForm.API(this).fetch(url, { method: 'POST' });\n\n this.__cacheState = response.ok ? 'idle' : 'fail';\n } catch {\n this.__cacheState = 'fail';\n }\n }\n}\n"]}
@@ -19,6 +19,10 @@ export declare class TemplateConfigForm extends Base<Data> {
19
19
  private __renderFoxycomplete;
20
20
  private __renderLocations;
21
21
  private __renderHiddenFields;
22
+ private __renderGoogleAnalytics;
23
+ private __renderSegmentIo;
24
+ private __renderTroubleshooting;
25
+ private __renderCustomConfig;
22
26
  private __renderHeader;
23
27
  private __renderFooter;
24
28
  }
@@ -60,6 +60,10 @@ export class TemplateConfigForm extends Base {
60
60
  ${hidden.matches('foxycomplete', true) ? '' : this.__renderFoxycomplete(json)}
61
61
  ${hidden.matches('locations', true) ? '' : this.__renderLocations(json)}
62
62
  ${hidden.matches('hidden-fields', true) ? '' : this.__renderHiddenFields(json)}
63
+ ${hidden.matches('google-analytics', true) ? '' : this.__renderGoogleAnalytics(json)}
64
+ ${hidden.matches('segment-io', true) ? '' : this.__renderSegmentIo(json)}
65
+ ${hidden.matches('troubleshooting', true) ? '' : this.__renderTroubleshooting(json)}
66
+ ${hidden.matches('custom-config', true) ? '' : this.__renderCustomConfig(json)}
63
67
  ${hidden.matches('header', true) ? '' : this.__renderHeader(json)}
64
68
  ${hidden.matches('footer', true) ? '' : this.__renderFooter(json)}
65
69
  </div>
@@ -106,7 +110,7 @@ export class TemplateConfigForm extends Base {
106
110
  <div slot="${item}-label" class="grid leading-s py-s">
107
111
  <foxy-i18n lang=${lang} key="cart_type_${item}" ns=${ns}></foxy-i18n>
108
112
  <foxy-i18n
109
- class="text-tertiary text-s"
113
+ class="text-secondary text-xs"
110
114
  lang=${lang}
111
115
  key="cart_type_${item}_explainer"
112
116
  ns=${ns}
@@ -176,7 +180,7 @@ export class TemplateConfigForm extends Base {
176
180
  <div slot="${item}-label" class="grid leading-s py-s">
177
181
  <foxy-i18n lang=${lang} key="foxycomplete_${item}" ns=${ns}></foxy-i18n>
178
182
  <foxy-i18n
179
- class="text-tertiary text-s"
183
+ class="text-secondary text-xs"
180
184
  lang=${lang}
181
185
  key="foxycomplete_${item}_explainer"
182
186
  ns=${ns}
@@ -471,6 +475,173 @@ export class TemplateConfigForm extends Base {
471
475
  </div>
472
476
  `;
473
477
  }
478
+ __renderGoogleAnalytics(json) {
479
+ const { lang, ns } = this;
480
+ const config = json.analytics_config;
481
+ const sioConfig = config.segment_io;
482
+ const gaConfig = config.google_analytics;
483
+ const isDisabled = this.disabledSelector.matches('google-analytics', true);
484
+ const isReadonly = this.readonlySelector.matches('google-analytics', true);
485
+ return html `
486
+ <div>
487
+ ${this.renderTemplateOrSlot('google-analytics:before')}
488
+
489
+ <x-group frame>
490
+ <span slot="header">Google Analytics</span>
491
+
492
+ <div class="p-m space-y-m">
493
+ <vaadin-text-field
494
+ class="w-full"
495
+ label=${this.t('ga_account_id')}
496
+ placeholder="UA-1234567-1"
497
+ helper-text=${this.t('ga_account_id_explainer')}
498
+ .value=${live(gaConfig.account_id)}
499
+ ?disabled=${isDisabled}
500
+ ?readonly=${isReadonly}
501
+ clear-button-visible
502
+ @keydown=${(evt) => evt.key === 'Enter' && this.submit()}
503
+ @input=${(evt) => {
504
+ gaConfig.account_id = evt.currentTarget.value;
505
+ gaConfig.usage = gaConfig.account_id ? 'required' : 'none';
506
+ config.usage = gaConfig.account_id || sioConfig.account_id ? 'required' : 'none';
507
+ }}
508
+ >
509
+ </vaadin-text-field>
510
+
511
+ <x-checkbox
512
+ ?disabled=${isDisabled}
513
+ ?readonly=${isReadonly}
514
+ ?checked=${gaConfig.include_on_site}
515
+ @change=${(evt) => {
516
+ gaConfig.include_on_site = evt.detail;
517
+ this.edit({ json: JSON.stringify(json) });
518
+ }}
519
+ >
520
+ <div class="flex flex-col">
521
+ <foxy-i18n lang=${lang} key="ga_include_on_site" ns=${ns}></foxy-i18n>
522
+ <foxy-i18n
523
+ class="text-xs leading-s text-secondary"
524
+ lang=${lang}
525
+ key="ga_include_on_site_explainer"
526
+ ns=${ns}
527
+ >
528
+ </foxy-i18n>
529
+ </div>
530
+ </x-checkbox>
531
+ </div>
532
+ </x-group>
533
+
534
+ ${this.renderTemplateOrSlot('google-analytics:after')}
535
+ </div>
536
+ `;
537
+ }
538
+ __renderSegmentIo(json) {
539
+ const config = json.analytics_config;
540
+ const sioConfig = config.segment_io;
541
+ const gaConfig = config.google_analytics;
542
+ const isDisabled = this.disabledSelector.matches('segment-io', true);
543
+ const isReadonly = this.readonlySelector.matches('segment-io', true);
544
+ return html `
545
+ <div>
546
+ ${this.renderTemplateOrSlot('segment-io:before')}
547
+
548
+ <x-group frame>
549
+ <span slot="header">Segment.io</span>
550
+
551
+ <div class="p-m">
552
+ <vaadin-text-field
553
+ class="w-full"
554
+ label=${this.t('sio_account_id')}
555
+ placeholder="MY-WRITE-KEY"
556
+ helper-text=${this.t('sio_account_id_explainer')}
557
+ .value=${live(sioConfig.account_id)}
558
+ ?disabled=${isDisabled}
559
+ ?readonly=${isReadonly}
560
+ clear-button-visible
561
+ @keydown=${(evt) => evt.key === 'Enter' && this.submit()}
562
+ @input=${(evt) => {
563
+ sioConfig.account_id = evt.currentTarget.value;
564
+ sioConfig.usage = sioConfig.account_id ? 'required' : 'none';
565
+ config.usage = gaConfig.account_id || sioConfig.account_id ? 'required' : 'none';
566
+ }}
567
+ >
568
+ </vaadin-text-field>
569
+ </div>
570
+ </x-group>
571
+
572
+ ${this.renderTemplateOrSlot('segment-io:after')}
573
+ </div>
574
+ `;
575
+ }
576
+ __renderTroubleshooting(json) {
577
+ const { lang, ns } = this;
578
+ const config = json.debug;
579
+ return html `
580
+ <div>
581
+ ${this.renderTemplateOrSlot('troubleshooting:before')}
582
+
583
+ <x-group frame>
584
+ <foxy-i18n slot="header" lang=${lang} key="troubleshooting" ns=${ns}></foxy-i18n>
585
+
586
+ <div class="p-m space-y-m">
587
+ <x-checkbox
588
+ ?disabled=${this.disabledSelector.matches('troubleshooting', true)}
589
+ ?readonly=${this.readonlySelector.matches('troubleshooting', true)}
590
+ ?checked=${config.usage === 'required'}
591
+ @change=${(evt) => {
592
+ config.usage = evt.detail ? 'required' : 'none';
593
+ this.edit({ json: JSON.stringify(json) });
594
+ }}
595
+ >
596
+ <div class="flex flex-col">
597
+ <foxy-i18n lang=${lang} key="troubleshooting_debug" ns=${ns}></foxy-i18n>
598
+ <foxy-i18n
599
+ class="text-xs leading-s text-secondary"
600
+ lang=${lang}
601
+ key="troubleshooting_debug_explainer"
602
+ ns=${ns}
603
+ >
604
+ </foxy-i18n>
605
+ </div>
606
+ </x-checkbox>
607
+ </div>
608
+ </x-group>
609
+
610
+ ${this.renderTemplateOrSlot('troubleshooting:after')}
611
+ </div>
612
+ `;
613
+ }
614
+ __renderCustomConfig(json) {
615
+ return html `
616
+ <div>
617
+ ${this.renderTemplateOrSlot('custom-config:before')}
618
+
619
+ <vaadin-text-area
620
+ class="w-full"
621
+ label=${this.t('custom_config')}
622
+ placeholder='{ "key": "value" }'
623
+ helper-text=${this.t('custom_config_helper_text')}
624
+ .value=${json.custom_config ? JSON.stringify(json.custom_config, null, 2) : ''}
625
+ ?disabled=${this.disabledSelector.matches('custom-config', true)}
626
+ ?readonly=${this.readonlySelector.matches('custom-config', true)}
627
+ @input=${(evt) => {
628
+ const input = evt.currentTarget;
629
+ try {
630
+ json.custom_config = input.value ? JSON.parse(input.value) : '';
631
+ this.edit({ json: JSON.stringify(json) });
632
+ input.invalid = false;
633
+ }
634
+ catch (_a) {
635
+ input.invalid = true;
636
+ }
637
+ }}
638
+ >
639
+ </vaadin-text-area>
640
+
641
+ ${this.renderTemplateOrSlot('custom-config:after')}
642
+ </div>
643
+ `;
644
+ }
474
645
  __renderHeader(json) {
475
646
  return html `
476
647
  <div>